Skip to content

feat(zcode): add ZCode as supported tool#1209

Open
fyeeme wants to merge 5 commits into
Fission-AI:mainfrom
fyeeme:feat/zcode-support
Open

feat(zcode): add ZCode as supported tool#1209
fyeeme wants to merge 5 commits into
Fission-AI:mainfrom
fyeeme:feat/zcode-support

Conversation

@fyeeme

@fyeeme fyeeme commented Jun 14, 2026

Copy link
Copy Markdown

Register ZCode in the AI tools registry and provide a command adapter so openspec init --tools zcode generates per-project artifacts under a single .zcode/ root (no split across .agents + .zcode):

  • Skills: .zcode/skills/openspec-*/SKILL.md (ZCode-native discovery path, highest priority among project-level skill roots)
  • Commands: .zcode/commands/opsx/.md (Claude-compatible frontmatter)

Both .zcode/skills and .agents/skills are valid ZCode discovery roots (verified from ZCode source: skillRootsForBase registers them in pairs); we use .zcode to keep all artifacts under one directory.

ZCode auto-detection triggers on .zcode or .agents at the project root.

Verification:

  • pnpm build passes (TypeScript compiles clean)
  • pnpm lint passes (no new warnings)
  • pnpm test: 1661 tests pass (no regressions)
  • E2E: openspec init --tools zcode --profile core produces 5 skills + 5 commands, all under .zcode/ (no .agents created)

Summary by CodeRabbit

  • New Features
    • Added ZCode as a supported tool integration.
    • Enable ZCode via tool configuration options.
    • ZCode projects are auto-detected based on the presence of a .zcode directory.
    • Command and skill generation now outputs in native ZCode format under .zcode/commands/opsx/.
  • Documentation
    • Updated supported tools documentation to include ZCode and its available tool ID.
  • Tests
    • Added coverage for ZCode detection, command/adaptor formatting, and init/update generation behavior.

Register ZCode in the AI tools registry and provide a command adapter
so `openspec init --tools zcode` generates per-project artifacts under
a single .zcode/ root (no split across .agents + .zcode):

- Skills: .zcode/skills/openspec-*/SKILL.md (ZCode-native discovery path,
  highest priority among project-level skill roots)
- Commands: .zcode/commands/opsx/<id>.md (Claude-compatible frontmatter)

Both .zcode/skills and .agents/skills are valid ZCode discovery roots
(verified from ZCode source: skillRootsForBase registers them in pairs);
we use .zcode to keep all artifacts under one directory.

ZCode auto-detection triggers on .zcode or .agents at the project root.

Verification:
- pnpm build passes (TypeScript compiles clean)
- pnpm lint passes (no new warnings)
- pnpm test: 1661 tests pass (no regressions)
- E2E: `openspec init --tools zcode --profile core` produces
  5 skills + 5 commands, all under .zcode/ (no .agents created)
@fyeeme fyeeme requested a review from TabishB as a code owner June 14, 2026 05:54
@coderabbitai

coderabbitai Bot commented Jun 14, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 75bc1412-715e-48f6-9135-9ae7dcd65505

📥 Commits

Reviewing files that changed from the base of the PR and between 3fea146 and ea1ec4f.

📒 Files selected for processing (6)
  • src/core/config.ts
  • test/core/available-tools.test.ts
  • test/core/command-generation/adapters.test.ts
  • test/core/command-generation/registry.test.ts
  • test/core/init.test.ts
  • test/core/update.test.ts

📝 Walkthrough

Walkthrough

Adds ZCode as a supported AI tool by creating a new command adapter with YAML frontmatter generation and escaping helpers, registering it in CommandAdapterRegistry, adding a zcode entry to the AI_TOOLS configuration array, and updating docs/supported-tools.md with the corresponding table row and tool ID. Comprehensive test coverage validates adapter behavior, registry wiring, tool detection, and end-to-end initialization and update workflows.

Changes

ZCode Tool Integration

Layer / File(s) Summary
ZCode adapter implementation with YAML escaping
src/core/command-generation/adapters/zcode.ts, test/core/command-generation/adapters.test.ts
Implements escapeYamlValue() to conditionally quote and escape YAML scalar values (backslashes, quotes, newlines) and formatTagsArray() to transform tags into YAML array syntax. Exports zcodeAdapter with toolId: 'zcode', getFilePath() generating .zcode/commands/opsx/<id>.md, and formatFile() rendering YAML frontmatter (name, description, category, escaped tags) followed by command body. Tests cover tool identity, path generation, and extensive YAML formatting edge cases including empty tags, special characters, and whitespace handling.
Configuration and registry registration
src/core/config.ts, src/core/command-generation/registry.ts, test/core/command-generation/registry.test.ts, test/core/available-tools.test.ts
Adds ZCode entry to AI_TOOLS with value: 'zcode', skillsDir: '.zcode', and successLabel: 'ZCode'. Imports and registers zcodeAdapter in CommandAdapterRegistry's static initializer. Tests verify registry lookups (get, getAll, has for zcode adapter) and confirm tool detection logic correctly identifies ZCode when .zcode/ exists, distinguishes it from the .agents/ marker, and handles detection with both directories present.
Documentation and integration tests
docs/supported-tools.md, test/core/init.test.ts, test/core/update.test.ts
Adds ZCode to the supported-tools directory table with skills and command path patterns, and to the available --tools IDs list. Integration tests validate --tools zcode initialization creates expected .zcode/skills and .zcode/commands/opsx output with YAML frontmatter, and UpdateCommand regenerates commands from outdated skills. Both tests assert .agents detection-only marker is never created during generation or updates.

Sequence Diagram(s)

sequenceDiagram
  participant Client as CLI
  participant InitCmd as InitCommand
  participant ZCodeAdapter as zcodeAdapter
  participant YAML as YAML Formatter
  participant FS as File System

  Client->>InitCmd: --tools zcode
  InitCmd->>ZCodeAdapter: formatFile(command)
  ZCodeAdapter->>YAML: escapeYamlValue(description)
  YAML-->>ZCodeAdapter: quoted/escaped string
  ZCodeAdapter->>YAML: formatTagsArray(tags)
  YAML-->>ZCodeAdapter: YAML array string
  ZCodeAdapter-->>InitCmd: frontmatter + body
  InitCmd->>FS: write to .zcode/commands/opsx/<id>.md
  FS-->>Client: ✓ ZCode generation complete
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • Fission-AI/OpenSpec#1003: Both PRs extend src/core/config.ts's exported AI_TOOLS list (adding a new selectable tool ID: zcode vs kimi) and add/adjust init coverage around tool handling.
  • Fission-AI/OpenSpec#853: Both PRs modify the same wiring points—CommandAdapterRegistry registration and AI_TOOLS config extension—to add a new tool adapter (zcodeAdapter vs junieAdapter).
  • Fission-AI/OpenSpec#227: Both PRs modify the AI tool configuration plumbing in src/core/config.ts's exported AI_TOOLS entries to add/adjust supported assistant/tool definitions.

Suggested reviewers

  • TabishB

Poem

🐇 A new tool hops into the fold,
ZCode commands, freshly enrolled!
YAML frontmatter, escaped with care,
.zcode/commands/opsx — right there.
The registry grows, the docs ring true,
Another adapter, shiny and new! 🌟

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely summarizes the main change: adding ZCode as a supported tool to the system, which matches the primary objective of the changeset.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@alfred-openspec alfred-openspec left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the scoped ZCode support. The adapter/config shape looks plausible and a local smoke generated the expected .zcode/skills/... plus .zcode/commands/opsx/*.md files, but this adds a new supported tool without focused regression coverage.

Please add tests that lock down the ZCode contract before merge: adapter path/frontmatter escaping, registry presence, .zcode + .agents auto-detection semantics, and init/update generation staying under .zcode without creating .agents. The existing broad tests pass, but they do not protect the new adapter path/detection behavior.

young added 4 commits June 15, 2026 01:00
ZCode's detectionPaths included '.agents', a generic directory used by
many agent frameworks. A bare '.agents' at the project root caused
false-positive ZCode detection (mirroring the Copilot bare-.github
problem the codebase already guards against).

Drop the detectionPaths override so ZCode is detected solely via its
strongly-identifying skillsDir '.zcode'. Add tests locking the new
contract: a bare '.agents' must not trigger detection, and '.agents'
co-located with '.zcode' must not suppress real detection.
Add focused coverage for the ZCode command adapter that the existing
broad tests did not protect:

- getFilePath lands under .zcode/commands/opsx/<id>.md and never
  references .agents
- formatFile emits name/description/category/tags frontmatter
- YAML escaping across all branches: colons/quotes/newlines (quoted
  values), special chars in name/category, per-tag quoting, plus the
  previously uncovered backslash-doubling and leading/trailing
  whitespace branches
Verify the ZCode adapter is registered in CommandAdapterRegistry so
openspec init/update can resolve it via get/getAll/has. The existing
registry tests only sampled a few tools, so a future refactor that
drops the zcode registration would have passed silently.
End-to-end coverage that init and update generate ZCode skills and
commands under .zcode/ and never create a .agents directory. The
adapter path/detection unit tests alone cannot catch a generation-time
regression that writes outside .zcode, so this asserts the contract on
disk for both entry points.
@fyeeme

fyeeme commented Jun 14, 2026

Copy link
Copy Markdown
Author

Unit tests have been added and all passed. The configuration of the zcode directory has also been fixed. @alfred-openspec

@alfred-openspec alfred-openspec left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the quick cleanup. I rechecked the updated head: detection is now scoped to .zcode, the new adapter/registry/init/update coverage is in place, and the focused local tests passed. The remaining YAML helper dedupe is already tracked separately in #1204/#1205, so I do not think it should block this adapter.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants