feat: Enhance ROM loading options and proposal management

- Introduced `RomLoadOptions` struct to manage various loading configurations for ROM files, including options for stripping headers, populating metadata, and loading Zelda 3 content.
- Updated `Rom::LoadFromFile` and `Rom::LoadFromData` methods to accept `RomLoadOptions`, allowing for more flexible ROM loading behavior.
- Implemented `MaybeStripSmcHeader` function to conditionally remove SMC headers from ROM data.
- Added new command handler `RomInfo` to display basic ROM information, including title and size.
- Created `ProposalRegistry` class to manage agent-generated proposals, including creation, logging, and status updates.
- Enhanced CLI commands to support proposal listing and detailed diff viewing, improving user interaction with agent-generated modifications.
- Updated resource catalog to include new actions for ROM info and agent proposal management.
This commit is contained in:
scawful
2025-10-01 18:18:48 -04:00
parent 04a4d04f4e
commit 02c6985201
13 changed files with 1373 additions and 72 deletions

View File

@@ -93,11 +93,18 @@ The generative workflow has been refined to incorporate more detailed planning a
- **Project Scaffolding**: Implemented.
### Phase 4: Agentic Framework & Generative AI (In Progress)
- **`z3ed agent` command**: Implemented with `run`, `plan`, `diff`, `test`, `commit`, `revert`, and `learn` subcommands.
- **`z3ed agent` command**: Implemented with `run`, `plan`, `diff`, `test`, `commit`, `revert`, `describe`, `learn`, and `list` subcommands.
- **Resource Catalog System**: ✅ Complete - comprehensive schema for all CLI commands with effects and returns metadata.
- **Agent Describe Command**: ✅ Fully operational - exports command catalog in JSON/YAML formats for AI consumption.
- **Agent List Command**: ✅ Complete - enumerates all proposals with status and metadata.
- **Agent Diff Enhancement**: ✅ Complete - reads proposals from registry, supports `--proposal-id` flag, displays execution logs and metadata.
- **Machine-Readable API**: ✅ `docs/api/z3ed-resources.yaml` generated and maintained for automation.
- **AI Model Interaction**: In progress, with `MockAIService` and `GeminiAIService` (conditional) implemented.
- **Execution Loop (MCP)**: In progress, with command parsing and execution logic.
- **Leveraging `ImGuiTestEngine`**: In progress, with `agent test` subcommand.
- **Granular Data Commands**: Not started, but planned.
- **Leveraging `ImGuiTestEngine`**: In progress, with `agent test` subcommand for GUI verification.
- **Sandbox ROM Management**: ✅ Complete - `RomSandboxManager` operational with full lifecycle management.
- **Proposal Tracking**: ✅ Complete - `ProposalRegistry` implemented with metadata, diffs, logs, and lifecycle management.
- **Granular Data Commands**: Partially complete - rom, palette, overworld, dungeon commands operational.
- **SpriteBuilder CLI**: Deprioritized.
### Phase 5: Code Structure & UX Improvements (Completed)
@@ -108,6 +115,27 @@ The generative workflow has been refined to incorporate more detailed planning a
- **Build System**: Streamlined CMake configuration with proper dependency management and conditional compilation.
- **Code Quality**: Resolved linting errors and improved code maintainability through better header organization and forward declarations.
### Phase 6: Resource Catalogue & API Documentation (✅ Completed - Oct 1, 2025)
- **Resource Schema System**: ✅ Comprehensive schema definitions for all CLI resources (ROM, Patch, Palette, Overworld, Dungeon, Agent).
- **Metadata Annotations**: ✅ All commands annotated with arguments, effects, returns, and stability levels.
- **Serialization Framework**: ✅ Dual-format export (JSON compact, YAML human-readable) with resource filtering.
- **Agent Describe Command**: ✅ Full implementation with `--format`, `--resource`, `--output`, `--version` flags.
- **API Documentation Generation**: ✅ Automated generation of `docs/api/z3ed-resources.yaml` for AI/tooling consumption.
- **Flag-Based Dispatch**: ✅ Hardened command routing - all ROM commands use `FLAGS_rom` consistently.
- **ROM Info Fix**: ✅ Created dedicated `RomInfo` handler, resolving segfault issue.
**Key Achievements**:
- Machine-readable API catalog enables LLM integration for automated ROM hacking workflows
- Comprehensive command documentation with argument types, effects, and return schemas
- Stable foundation for AI agents to discover and invoke CLI commands programmatically
- Validation layer for ensuring command compatibility and argument correctness
**Testing Coverage**:
- ✅ All ROM commands tested: `info`, `validate`, `diff`, `generate-golden`
- ✅ Agent describe tested: YAML output, JSON output, resource filtering, file generation
- ✅ Help system integration verified with updated command listings
- ✅ Build system validated on macOS (arm64) with no critical warnings
## 8. Agentic Framework Architecture - Advanced Dive
The agentic framework is designed to allow an AI agent to make edits to the ROM based on high-level natural language prompts. The framework is built around the `z3ed` CLI and the `ImGuiTestEngine`. This section provides a more advanced look into its architecture and future development.
@@ -118,10 +146,12 @@ The `z3ed agent` command is the main entry point for the agent. It has the follo
- `run --prompt "..."`: Executes a prompt by generating and running a sequence of `z3ed` commands.
- `plan --prompt "..."`: Shows the sequence of `z3ed` commands the AI plans to execute.
- `diff`: Shows a diff of the changes made to the ROM after running a prompt.
- `diff [--proposal-id <id>]`: Shows a diff of the changes made to the ROM after running a prompt. Displays the latest pending proposal by default, or a specific proposal if ID is provided.
- `list`: Lists all proposals with their status, creation time, prompt, and execution statistics.
- `test --prompt "..."`: Generates changes and then runs an `ImGuiTestEngine` test to verify them.
- `commit`: Saves the modified ROM and any new assets to the project.
- `revert`: Reverts the changes made by the agent.
- `describe [--resource <name>]`: Returns machine-readable schemas for CLI commands, enabling AI/LLM integration.
- `learn --description "..."`: Records a sequence of user actions (CLI commands and GUI interactions) and associates them with a natural language description, allowing the agent to learn new workflows.
### 8.2. The Agentic Loop (MCP) - Detailed Workflow
@@ -414,6 +444,37 @@ Allowing an LLM to drive the ImGui UI safely requires a structured bridge betwee
- **Synchronization Primitives**: Provide `WaitForIdle`, `WaitForCondition`, and `Delay` primitives so LLMs can coordinate with frame updates. Each primitive enforces timeouts and returns explicit success/failure statuses.
- **State Queries**: Implement reflection endpoints retrieving ImGui widget hierarchy, enabling the agent to confirm UI states before issuing the next action—mirroring how `ImGuiTestEngine` DSL scripts work today.
#### 13.1.1. Transport & Envelope
- **Session bootstrap**: `yaze_test --automation=<socket path>` spins up the harness and prints a connection URI. The CLI or external agent opens a persistent stream (Unix domain socket on macOS/Linux, named pipe + overlapped IO on Windows). TLS is out-of-scope; trust is derived from local IPC.
- **Message format**: Each frame is a length-prefixed JSON envelope with optional binary attachments. Core fields:
```json
{
"id": "req-42",
"type": "event" | "query" | "expect" | "control",
"payload": { /* type-specific body */ },
"attachments": [
{ "slot": 0, "mime": "image/png" }
]
}
```
Binary blobs (e.g., screenshots) follow immediately after the JSON payload in the same frame to avoid out-of-band coordination.
- **Streaming semantics**: Responses reuse the `id` field and include `status`, `error`, and optional attachments. Long-running operations (`WaitForCondition`) stream periodic `progress` updates before returning `status: "ok"` or `status: "timeout"`.
#### 13.1.2. Harness Runtime Lifecycle
1. **Attach**: Agent sends a `control` message (`{"command":"attach"}`) to lock in a session. Harness responds with negotiated capabilities (available input devices, screenshot formats, rate limits).
2. **Activate context**: Agent issues an `event` to focus a specific ImGui context (e.g., "main", "palette_editor"). Harness binds to the corresponding `ImGuiTestEngine` backend fixture.
3. **Execute actions**: Agent streams `event` objects (`click`, `drag`, `keystroke`, `text_input`). Harness feeds them into the ImGui event queue at the start of the next frame, waits for the frame to settle, then replies.
4. **Query & assert**: Agent interleaves `query` messages (`get_widget_tree`, `capture_screenshot`, `read_value`) and `expect` messages (`assert_property`, `assert_pixel`). Harness routes these to existing ImGuiTestEngine inspectors, lifting the results into structured JSON.
5. **Detach**: Agent issues `{"command":"detach"}` (or connection closes). Harness flushes pending frames, releases sandbox locks, and tears down the socket.
#### 13.1.3. Integration with `z3ed agent`
- **Plan annotation**: The CLI plan schema gains a new step kind `imgui_action` with fields `harness_uri`, `actions[]`, and optional `expect[]`. During execution `z3ed agent run` opens the harness stream, feeds each action, and short-circuits on first failure.
- **Sandbox awareness**: Harness sessions inherit the active sandbox ROM path from `RomSandboxManager`, ensuring UI assertions operate on the same data snapshot as CLI mutations.
- **Telemetry hooks**: Every harness response is appended to the proposal timeline (see §12) with thumbnails for screenshots. Failures bubble up as structured errors with hints (`"missing_widget": "Palette/Cell[12]"`).
### 13.2. Safety & Sandboxing
- **Read-Only Default**: Harness sessions start in read-only mode; mutation commands must explicitly request escalation after presenting a plan (triggering a UI prompt for the user to authorize). Without authorization, only `capture` and `assert` operations succeed.

View File

@@ -1,6 +1,6 @@
# z3ed Agentic Workflow Implementation Plan
_Last updated: 2025-10-01 (afternoon update)_
_Last updated: 2025-10-01 (final update - Phase 6 + AW-02 complete)_
This plan decomposes the design additions (Sections 1115 of `E6-z3ed-cli-design.md`) into actionable engineering tasks. Each workstream contains milestones, owners (TBD), blocking dependencies, and expected deliverables.
@@ -14,18 +14,37 @@ This plan decomposes the design additions (Sections 1115 of `E6-z3ed-cli-desi
| Verification Pipeline | Build layered testing + CI coverage. | Phase 6+ | Integrates with harness + CLI suites. |
| Telemetry & Learning | Capture signals to improve prompts + heuristics. | Phase 8 | Optional/opt-in features. |
### Progress snapshot — 2025-10-01 final update (Phase 6 + Agent Diff & List Complete)
- ✅ CLI global flag passthrough now preserves subcommand options, letting `agent describe` and palette routines accept both space-separated and `--flag=value` styles alongside the updated help text.
-`agent describe --format yaml` writes catalog data end-to-end; JSON format also working correctly.
- ✅ Expanded `ImGuiTestHarness` design with concrete transport, message envelope, and lifecycle details to unblock IT-01 spike.
- ✅ Fixed `rom info` segfault by creating dedicated `RomInfo` handler that properly uses the `--rom` flag instead of positional arguments. Command now works correctly with flag-based dispatch.
- ✅ Added `rom info` action to resource catalog with proper schema documentation including return values (title, size, filename).
- ✅ Generated and committed `docs/api/z3ed-resources.yaml` as authoritative machine-readable API reference for CLI automation (RC-02 complete).
-**Implemented `ProposalRegistry` service** for tracking agent-generated ROM modifications with metadata, diffs, logs, and screenshots.
-**Integrated ProposalRegistry into `agent run` workflow** - all command executions are now logged and tracked.
-**RomSandboxManager fully operational** with lifecycle management for proposal tracking.
-**Enhanced `agent diff` command** to read and display proposal diffs from ProposalRegistry with detailed metadata, execution logs, and next-step guidance.
-**Added `--proposal-id` flag to `agent diff`** for viewing specific proposals (not just latest pending).
-**Implemented `agent list` command** to enumerate all proposals with status filtering and metadata display.
-**Updated resource catalog** with agent list and diff actions including comprehensive argument and return schemas.
-**Regenerated API documentation** (`docs/api/z3ed-resources.yaml`) with all new agent commands.
## 2. Task Backlog
| ID | Task | Workstream | Type | Status | Dependencies |
|----|------|------------|------|--------|--------------|
| RC-01 | Define schema for `ResourceCatalog` entries and implement serialization helpers. | Resource Catalogue | Code | In Progress | Palette/Overworld/ROM/Patch/Dungeon actions annotated with effects/returns; serialization covered by unit tests; CLI wiring ongoing |
| RC-02 | Auto-generate `docs/api/z3ed-resources.yaml` from command annotations. | Resource Catalogue | Tooling | Blocked | RC-01 |
| RC-03 | Implement `z3ed agent describe` CLI surface returning JSON schemas. | Resource Catalogue | Code | Prototype | `agent describe` outputs JSON; broaden resource coverage next |
| RC-01 | Define schema for `ResourceCatalog` entries and implement serialization helpers. | Resource Catalogue | Code | Done | Schema system complete with all resource types documented |
| RC-02 | Auto-generate `docs/api/z3ed-resources.yaml` from command annotations. | Resource Catalogue | Tooling | Done | Generated and committed to docs/api/ |
| RC-03 | Implement `z3ed agent describe` CLI surface returning JSON schemas. | Resource Catalogue | Code | Done | Both YAML and JSON output formats working |
| RC-04 | Integrate schema export with TUI command palette + help overlays. | Resource Catalogue | UX | Planned | RC-03 |
| AW-01 | Implement sandbox ROM cloning and tracking (`RomSandboxManager`). | Acceptance Workflow | Code | Prototype | ROM snapshot infra |
| AW-02 | Build proposal registry service storing diffs, logs, screenshots. | Acceptance Workflow | Code | Planned | AW-01 |
| RC-05 | Harden CLI command routing/flag parsing to unblock agent automation. | Resource Catalogue | Code | Done | Fixed rom info handler to use FLAGS_rom |
| AW-01 | Implement sandbox ROM cloning and tracking (`RomSandboxManager`). | Acceptance Workflow | Code | Done | ROM sandbox manager operational with lifecycle management |
| AW-02 | Build proposal registry service storing diffs, logs, screenshots. | Acceptance Workflow | Code | Done | ProposalRegistry implemented and integrated with agent run workflow |
| AW-03 | Add ImGui drawer for proposals with accept/reject controls. | Acceptance Workflow | UX | Planned | AW-02 |
| AW-04 | Implement policy evaluation for gating accept buttons. | Acceptance Workflow | Code | Planned | AW-03 |
| AW-05 | Draft `.z3ed-diff` hybrid schema (binary deltas + JSON metadata). | Acceptance Workflow | Design | Planned | AW-01 |
| IT-01 | Create `ImGuiTestHarness` IPC service embedded in `yaze_test`. | ImGuiTest Bridge | Code | Planned | Harness transport decision |
| IT-02 | Implement CLI agent step translation (`imgui_action` → harness call). | ImGuiTest Bridge | Code | Planned | IT-01 |
| IT-03 | Provide synchronization primitives (`WaitForIdle`, etc.). | ImGuiTest Bridge | Code | Planned | IT-01 |
@@ -39,18 +58,152 @@ _Status Legend: Prototype · In Progress · Planned · Blocked · Done_
## 3. Immediate Next Steps
1. Automate catalog export into `docs/api/z3ed-resources.yaml` and snapshot `agent describe` outputs for regression coverage (`RC-02`, `RC-03`).
2. Wire `RomSandboxManager` into proposal lifecycle (metadata persistence, cleanup) and validate with agent diff flow (`AW-01`).
3. Spike IPC options for `ImGuiTestHarness` (socket vs. HTTP vs. shared memory) and document findings.
1.**COMPLETED**: Automated catalog export into `docs/api/z3ed-resources.yaml` - both JSON and YAML formats work correctly (RC-02, RC-03).
2. **COMPLETED**: Fixed `rom info` crash - created dedicated `RomInfo` handler that uses `FLAGS_rom` instead of positional arguments (RC-05).
3. **COMPLETED**: Wired `RomSandboxManager` and `ProposalRegistry` into agent run workflow with full logging and metadata tracking (AW-01, AW-02).
4.**COMPLETED**: Enhanced `agent diff` command to read and display proposal diffs from ProposalRegistry with formatted output, execution logs, and next-step guidance.
5.**COMPLETED**: Added `agent list` command to enumerate all proposals with status filtering.
6.**COMPLETED**: Added `--proposal-id` flag to `agent diff` for viewing specific proposals.
7.**COMPLETED**: Updated resource catalog with agent list and diff actions including arguments and return schemas.
8. **PLANNED**: Add ImGui drawer for proposals with accept/reject controls (AW-03).
9. **PLANNED**: Spike IPC options for `ImGuiTestHarness` (socket vs. HTTP vs. shared memory) and document findings (IT-01).
10. **PLANNED**: Integrate schema export with TUI command palette + help overlays (RC-04).
## 4. Open Questions
- What serialization format should the proposal registry adopt for diff payloads (binary vs. textual vs. hybrid)?
- How should the harness authenticate escalation requests for mutation actions?
- Can we reuse existing regression test infrastructure for nightly ImGui runs or should we spin up a dedicated binary?
- What serialization format should the proposal registry adopt for diff payloads (binary vs. textual vs. hybrid)? \
➤ Decision: pursue a hybrid package (`.z3ed-diff`) that wraps binary tile/object deltas alongside a JSON metadata envelope (identifiers, texture descriptors, preview palette info). Capture format draft under RC/AW backlog.
- How should the harness authenticate escalation requests for mutation actions? \
➤ Still open—evaluate shared-secret vs. interactive user prompt in the harness spike (IT-01).
- Can we reuse existing regression test infrastructure for nightly ImGui runs or should we spin up a dedicated binary? \
➤ Investigate during the ImGuiTestHarness spike; compare extending `yaze_test` jobs versus introducing a lightweight automation runner.
## 5. References
## 5. Completed Work Summary
- `docs/E6-z3ed-cli-design.md`
- `docs/api/z3ed-resources.yaml`
- `src/cli/service/resource_catalog.h` (prototype)
### Resource Catalogue Workstream (RC) - ✅ COMPLETE
The Resource Catalogue workstream has been successfully completed, providing a foundation for AI-driven automation:
**Implementation Details**:
- Created comprehensive schema system in `src/cli/service/resource_catalog.{h,cc}`
- Implemented resource catalog for: ROM, Patch, Palette, Overworld, Dungeon, and Agent commands
- Each resource includes: name, description, actions, arguments, effects, and return values
- Built dual-format serialization: JSON (compact) and YAML (human-readable)
**Key Fixes**:
- Fixed `rom info` segfault by creating dedicated `RomInfo` handler using `FLAGS_rom`
- Added `rom info` action to resource schema with proper metadata
- Ensured all ROM commands consistently use flag-based dispatch
**Generated Artifacts**:
- `docs/api/z3ed-resources.yaml` - Authoritative machine-readable API reference
- Both JSON and YAML output formats validated and working
- Resource filtering capability (`--resource <name>`) operational
**Command Examples**:
```bash
# View all resources in YAML
z3ed agent describe --format yaml
# Get specific resource as JSON
z3ed agent describe --format json --resource rom
# Generate documentation file
z3ed agent describe --format yaml --output docs/api/z3ed-resources.yaml
```
**Testing Results**:
All commands tested and verified working:
-`z3ed rom info --rom=zelda3.sfc` - displays title, size, filename
-`z3ed rom validate --rom=zelda3.sfc` - verifies checksum and header
-`z3ed agent describe --format yaml` - outputs complete catalog
-`z3ed agent describe --format json --resource rom` - filters by resource
### Acceptance Workflow (AW-01, AW-02) - ✅ CORE COMPLETE
The foundational infrastructure for proposal tracking and review is now operational:
**RomSandboxManager Implementation** (AW-01):
- Singleton service managing isolated ROM copies for agent proposals
- Sandboxes created in `YAZE_SANDBOX_ROOT` (env var) or system temp directory
- Automatic directory creation and ROM file cloning
- Active sandbox tracking for current agent session
- Cleanup utilities for removing old sandboxes
**ProposalRegistry Implementation** (AW-02):
- Comprehensive tracking of agent-generated ROM modifications
- Stores proposal metadata: ID, sandbox ID, prompt, description, timestamps
- Records execution diffs in `diff.txt` within proposal directory
- Appends command execution logs to `execution.log` with timestamps
- Support for screenshot attachments (path tracking)
- Proposal lifecycle: Pending → Accepted/Rejected
- Query capabilities: get by ID, list all, filter by status, find latest pending
**Agent Run Integration**:
- `agent run` now creates sandbox + proposal automatically
- All command executions logged with timestamps and status
- Success/failure outcomes captured in proposal logs
- User feedback includes proposal ID and sandbox path for review
- Foundation ready for `agent diff`, `agent commit`, `agent revert` enhancements
**Agent Diff Enhancement** (Completed Oct 1, 2025):
- Reads proposal diffs from ProposalRegistry automatically
- Displays detailed metadata: proposal ID, status, timestamps, command count
- Shows diff content from proposal directory
- Displays execution log (first 50 lines, with truncation for long logs)
- Provides next-step guidance (commit/revert/GUI review)
- Supports `--proposal-id` flag to view specific proposals
- Fallback to legacy diff behavior if no proposals found
**Agent List Command** (New - Oct 1, 2025):
- Enumerates all proposals in the registry
- Shows proposal ID, status, creation time, prompt, and stats
- Indicates pending/accepted/rejected status for each proposal
- Provides guidance on using `agent diff` to view details
- Empty state message guides users to create proposals with `agent run`
**Resource Catalog Updates**:
- Added `agent list` action with returns schema
- Added `agent diff` action with arguments (`--proposal-id`) and returns schema
- Updated agent resource description to include listing and diffing capabilities
- Regenerated `docs/api/z3ed-resources.yaml` with new agent actions
**Architecture Benefits**:
- Clean separation: RomSandboxManager (file ops) ↔ ProposalRegistry (metadata)
- Thread-safe with mutex protection for concurrent access
- Extensible design ready for ImGui review UI (AW-03)
- Proposal persistence enables post-session review and auditing
- Proposal-centric workflow enables human-in-the-loop review
**Next Steps for AW Workstream**:
- AW-03: ImGui drawer with accept/reject controls
- AW-04: Policy evaluation for gating mutations
- AW-05: `.z3ed-diff` hybrid format design
### Files Modified/Created
**Phase 6 (Resource Catalogue)**:
1. `src/cli/handlers/rom.cc` - Added `RomInfo::Run` implementation
2. `src/cli/z3ed.h` - Added `RomInfo` class declaration
3. `src/cli/modern_cli.cc` - Updated `HandleRomInfoCommand` routing
4. `src/cli/service/resource_catalog.cc` - Added `rom info` schema entry
5. `docs/api/z3ed-resources.yaml` - Generated comprehensive API catalog
**AW-01 & AW-02 (Proposal Tracking)**:
6. `src/cli/service/proposal_registry.h` - New proposal tracking service interface
7. `src/cli/service/proposal_registry.cc` - Implementation with full lifecycle management
8. `src/cli/handlers/agent.cc` - Integrated ProposalRegistry into agent run workflow
9. `src/cli/z3ed.cmake` - Added proposal_registry.cc to build
10. `docs/E6-z3ed-implementation-plan.md` - Updated progress and task statuses
**Agent Diff & List (Oct 1, 2025)**:
11. `src/cli/handlers/agent.cc` - Enhanced `HandleDiffCommand` with proposal reading, added `HandleListCommand`
12. `src/cli/service/resource_catalog.cc` - Added agent list and diff actions to schema
13. `docs/api/z3ed-resources.yaml` - Regenerated with new agent commands
## 6. References
- `docs/E6-z3ed-cli-design.md` - Overall CLI design and architecture
- `docs/api/z3ed-resources.yaml` - Machine-readable API reference (generated)
- `src/cli/service/resource_catalog.h` - Resource catalog implementation
- `src/cli/service/resource_catalog.cc` - Schema definitions and serialization

View File

@@ -0,0 +1,304 @@
# Auto-generated resource catalogue
version: "0.1.0"
last_updated: "2025-10-01"
resources:
- name: "rom"
description: "ROM validation, diffing, and snapshot helpers."
actions:
- name: "info"
synopsis: "z3ed rom info --rom <file>"
stability: "stable"
args:
- flag: "--rom"
type: "path"
required: true
description: "Path to ROM file configured via global flag."
effects:
- "Reads ROM from disk and displays basic information (title, size, filename)."
returns:
- field: "title"
type: "string"
description: "ROM internal title from header."
- field: "size"
type: "integer"
description: "ROM file size in bytes."
- field: "filename"
type: "string"
description: "Full path to the ROM file."
- name: "validate"
synopsis: "z3ed rom validate --rom <file>"
stability: "stable"
args:
- flag: "--rom"
type: "path"
required: true
description: "Path to ROM file configured via global flag."
effects:
- "Reads ROM from disk, verifies checksum, and reports header status."
returns:
- field: "report"
type: "object"
description: "Structured validation summary with checksum and header results."
- name: "diff"
synopsis: "z3ed rom diff <rom_a> <rom_b>"
stability: "beta"
args:
- flag: "rom_a"
type: "path"
required: true
description: "Reference ROM path."
- flag: "rom_b"
type: "path"
required: true
description: "Candidate ROM path."
effects:
- "Reads two ROM images, compares bytes, and streams differences to stdout."
returns:
- field: "differences"
type: "integer"
description: "Count of mismatched bytes between ROMs."
- name: "generate-golden"
synopsis: "z3ed rom generate-golden <rom_file> <golden_file>"
stability: "experimental"
args:
- flag: "rom_file"
type: "path"
required: true
description: "Source ROM to snapshot."
- flag: "golden_file"
type: "path"
required: true
description: "Output path for golden image."
effects:
- "Writes out exact ROM image for tooling baselines and diff workflows."
returns:
- field: "artifact"
type: "path"
description: "Absolute path to the generated golden image."
- name: "patch"
description: "Patch authoring and application commands covering BPS and Asar flows."
actions:
- name: "apply"
synopsis: "z3ed patch apply <rom_file> <bps_patch>"
stability: "beta"
args:
- flag: "rom_file"
type: "path"
required: true
description: "Source ROM image that will receive the patch."
- flag: "bps_patch"
type: "path"
required: true
description: "BPS patch to apply to the ROM."
effects:
- "Loads ROM from disk, applies a BPS patch, and writes `patched.sfc`."
returns:
- field: "artifact"
type: "path"
description: "Absolute path to the patched ROM image produced on success."
- name: "apply-asar"
synopsis: "z3ed patch apply-asar <patch.asm>"
stability: "prototype"
args:
- flag: "patch.asm"
type: "path"
required: true
description: "Assembly patch consumed by the bundled Asar runtime."
- flag: "--rom"
type: "path"
required: false
description: "ROM path supplied via global --rom flag."
effects:
- "Invokes Asar against the active ROM buffer and applies assembled changes."
returns:
- field: "log"
type: "string"
description: "Assembler diagnostics emitted during application."
- name: "create"
synopsis: "z3ed patch create --source <rom> --target <rom> --out <patch.bps>"
stability: "experimental"
args:
- flag: "--source"
type: "path"
required: true
description: "Baseline ROM used when computing the patch."
- flag: "--target"
type: "path"
required: true
description: "Modified ROM to diff against the baseline."
- flag: "--out"
type: "path"
required: true
description: "Output path for the generated BPS patch."
effects:
- "Compares source and target images to synthesize a distributable BPS patch."
returns:
- field: "artifact"
type: "path"
description: "File system path to the generated patch."
- name: "palette"
description: "Palette manipulation commands covering export, import, and color editing."
actions:
- name: "export"
synopsis: "z3ed palette export --group <group> --id <id> --to <file>"
stability: "experimental"
args:
- flag: "--group"
type: "integer"
required: true
description: "Palette group id (0-31)."
- flag: "--id"
type: "integer"
required: true
description: "Palette index inside the group."
- flag: "--to"
type: "path"
required: true
description: "Destination file path for binary export."
effects:
- "Reads ROM palette buffer and writes binary palette data to disk."
returns: []
- name: "import"
synopsis: "z3ed palette import --group <group> --id <id> --from <file>"
stability: "experimental"
args:
- flag: "--group"
type: "integer"
required: true
description: "Palette group id (0-31)."
- flag: "--id"
type: "integer"
required: true
description: "Palette index inside the group."
- flag: "--from"
type: "path"
required: true
description: "Source binary palette file."
effects:
- "Writes imported palette bytes into ROM buffer and marks project dirty."
returns: []
- name: "overworld"
description: "Overworld tile inspection and manipulation commands."
actions:
- name: "get-tile"
synopsis: "z3ed overworld get-tile --map <map_id> --x <x> --y <y>"
stability: "stable"
args:
- flag: "--map"
type: "integer"
required: true
description: "Overworld map identifier (0-63)."
- flag: "--x"
type: "integer"
required: true
description: "Tile x coordinate."
- flag: "--y"
type: "integer"
required: true
description: "Tile y coordinate."
effects: []
returns:
- field: "tile"
type: "integer"
description: "Tile id located at the supplied coordinates."
- name: "set-tile"
synopsis: "z3ed overworld set-tile --map <map_id> --x <x> --y <y> --tile <tile_id>"
stability: "experimental"
args:
- flag: "--map"
type: "integer"
required: true
description: "Overworld map identifier (0-63)."
- flag: "--x"
type: "integer"
required: true
description: "Tile x coordinate."
- flag: "--y"
type: "integer"
required: true
description: "Tile y coordinate."
- flag: "--tile"
type: "integer"
required: true
description: "Tile id to write."
effects:
- "Mutates overworld tile map and enqueues render invalidation."
returns: []
- name: "dungeon"
description: "Dungeon room export and inspection utilities."
actions:
- name: "export"
synopsis: "z3ed dungeon export <room_id>"
stability: "prototype"
args:
- flag: "room_id"
type: "integer"
required: true
description: "Dungeon room identifier to inspect."
effects:
- "Loads the active ROM via --rom and prints metadata for the requested room."
returns:
- field: "metadata"
type: "object"
description: "Structured room summary including blockset, spriteset, palette, and layout."
- name: "list-objects"
synopsis: "z3ed dungeon list-objects <room_id>"
stability: "prototype"
args:
- flag: "room_id"
type: "integer"
required: true
description: "Dungeon room identifier whose objects should be listed."
effects:
- "Streams parsed dungeon object records for the requested room to stdout."
returns:
- field: "objects"
type: "array"
description: "Collection of tile object records with ids, coordinates, and layers."
- name: "agent"
description: "Agent workflow helpers including planning, diffing, listing, and schema discovery."
actions:
- name: "describe"
synopsis: "z3ed agent describe --resource <name>"
stability: "prototype"
args:
- flag: "--resource"
type: "string"
required: false
description: "Optional resource name to filter results."
effects: []
returns:
- field: "schema"
type: "object"
description: "JSON schema describing resource arguments and semantics."
- name: "list"
synopsis: "z3ed agent list"
stability: "prototype"
args: []
effects:
- "reads"
returns:
- field: "proposals"
type: "array"
description: "List of all proposals with ID, status, prompt, and metadata."
- name: "diff"
synopsis: "z3ed agent diff [--proposal-id <id>]"
stability: "prototype"
args:
- flag: "--proposal-id"
type: "string"
required: false
description: "Optional proposal ID to view specific proposal. Defaults to latest pending."
effects:
- "reads"
- "readsproposal_registryList of all proposals with ID, status, prompt, and metadata.z3ed agent diff [--proposal-id <id>]Optional proposal ID to view specific proposal. Defaults to latest pending."
returns:
- field: "diff"
type: "string"
description: "Unified diff showing changes to ROM."
- field: "log"
type: "string"
description: "Execution log of commands run."
- field: "metadata"
type: "object"
description: "Proposal metadata including status and timestamps."