# z3ed CLI Technical Reference **Version**: 0.1.0-alpha **Last Updated**: [Current Date] **Status**: Production Ready (macOS), Windows Testing Pending --- ## Table of Contents 1. [Architecture Overview](#architecture-overview) 2. [Command Reference](#command-reference) 3. [Implementation Guide](#implementation-guide) 4. [Testing & Validation](#testing--validation) 5. [Development Workflows](#development-workflows) 6. [Troubleshooting](#troubleshooting) 7. [API Reference](#api-reference) 8. [Platform Notes](#platform-notes) --- ## Architecture Overview ### System Components ``` ┌─────────────────────────────────────────────────────────┐ │ AI Agent Layer (LLM) │ │ └─ Natural language prompts │ └────────────────────┬────────────────────────────────────┘ │ ┌────────────────────▼────────────────────────────────────┐ │ z3ed CLI (Command-Line Interface) │ │ ├─ agent run --prompt "..." --sandbox │ │ ├─ agent test --prompt "..." (IT-02) │ │ ├─ agent list │ │ ├─ agent diff --proposal-id │ │ ├─ agent describe [--resource ] │ │ ├─ rom info/validate/diff/generate-golden │ │ ├─ palette export/import/list │ │ ├─ overworld get-tile/set-tile │ │ └─ dungeon list-rooms/add-object │ └────────────────────┬────────────────────────────────────┘ │ ┌────────────────────▼────────────────────────────────────┐ │ Service Layer (Singleton Services) │ │ ├─ ProposalRegistry (proposal tracking) │ │ ├─ RomSandboxManager (isolated ROM copies) │ │ ├─ ResourceCatalog (machine-readable API specs) │ │ ├─ GuiAutomationClient (gRPC wrapper) │ │ ├─ TestWorkflowGenerator (NL → test steps) │ │ └─ PolicyEvaluator (YAML constraints) [Planned] │ └────────────────────┬────────────────────────────────────┘ │ ┌────────────────────▼────────────────────────────────────┐ │ ImGuiTestHarness (gRPC Server) │ │ ├─ Ping (health check) │ │ ├─ Click (button, menu, tab) │ │ ├─ Type (text input) │ │ ├─ Wait (condition polling) │ │ ├─ Assert (state validation) │ │ └─ Screenshot (capture) [Stub] │ └────────────────────┬────────────────────────────────────┘ │ ┌────────────────────▼────────────────────────────────────┐ │ YAZE GUI (ImGui Application) │ │ ├─ ProposalDrawer (Debug → Agent Proposals) │ │ │ ├─ List/detail views │ │ │ ├─ Accept/Reject/Delete │ │ │ └─ ROM merging │ │ └─ Editor Windows │ │ ├─ Overworld Editor │ │ ├─ Dungeon Editor │ │ ├─ Palette Editor │ │ └─ Graphics Editor │ └─────────────────────────────────────────────────────────┘ ``` ### Data Flow: Proposal Lifecycle ``` User: z3ed agent run "Make soldiers red" --sandbox │ ▼ ┌────────────────────────┐ │ MockAIService │ → ["palette export sprites_aux1 4 soldier.col"] └────────┬───────────────┘ │ ▼ ┌────────────────────────┐ │ RomSandboxManager │ → Creates: /tmp/.../sandboxes/20251002T100000/zelda3.sfc └────────┬───────────────┘ │ ▼ ┌────────────────────────┐ │ Execute Commands │ → Runs: palette export on sandbox ROM └────────┬───────────────┘ │ ▼ ┌────────────────────────┐ │ ProposalRegistry │ → Creates: proposal-20251002T100000/ │ │ • execution.log │ │ • diff.txt (if generated) └────────┬───────────────┘ │ ▼ (User opens YAZE GUI) ┌────────────────────────┐ │ ProposalDrawer │ → Displays: List of proposals └────────┬───────────────┘ │ ▼ (User clicks "Accept") ┌────────────────────────┐ │ AcceptProposal() │ → 1. Load sandbox ROM │ │ 2. rom_->WriteVector(0, sandbox_rom.vector()) │ │ 3. ROM marked dirty │ │ 4. User saves ROM └────────────────────────┘ ``` --- ## Command Reference ### Agent Commands #### `agent run` - Execute AI-driven ROM modifications ```bash z3ed agent run --prompt "" --rom [--sandbox] Options: --prompt Natural language description of desired changes --rom Path to ROM file (default: current ROM) --sandbox Create isolated copy for testing (recommended) Example: z3ed agent run --prompt "Change soldier armor to red" \ --rom=zelda3.sfc --sandbox ``` **Output**: - Proposal ID - Sandbox path - Command execution log - Next steps guidance #### `agent list` - Show all proposals ```bash z3ed agent list Example Output: === Agent Proposals === ID: proposal-20251002T100000-1 Status: Pending Created: 2025-10-02 10:00:00 Prompt: Change soldier armor to red Commands: 3 Bytes Changed: 128 Total: 1 proposal(s) ``` #### `agent diff` - Show proposal changes ```bash z3ed agent diff [--proposal-id ] Options: --proposal-id View specific proposal (default: latest pending) Example: z3ed agent diff --proposal-id proposal-20251002T100000-1 ``` **Output**: - Proposal metadata - Execution log - Diff content - Next steps #### `agent describe` - Export machine-readable API specs ```bash z3ed agent describe [--format ] [--resource ] [--output ] Options: --format Output format: yaml or json (default: yaml) --resource Filter to specific resource (rom, palette, etc.) --output Write to file instead of stdout Examples: z3ed agent describe --format yaml z3ed agent describe --format json --resource rom z3ed agent describe --output docs/api/z3ed-resources.yaml ``` **Resources Available**: - `rom` - ROM file operations - `patch` - Patch application - `palette` - Palette manipulation - `overworld` - Overworld editing - `dungeon` - Dungeon editing - `agent` - Agent commands #### `agent test` - Automated GUI testing (IT-02) ```bash z3ed agent test --prompt "" [--host ] [--port ] Options: --prompt Natural language test description --host Test harness hostname (default: localhost) --port Test harness port (default: 50052) --timeout Maximum test duration (default: 30) Supported Prompt Patterns: - "Open editor" - "Open and verify it loads" - "Click