Skip to content

feat(zcode): integrate ZCode as a built-in agent - #768

Open
asteroida123 wants to merge 6 commits into
xintaofei:mainfrom
asteroida123:feat/zcode-builtin-agent
Open

asteroida123 wants to merge 6 commits into
xintaofei:mainfrom
asteroida123:feat/zcode-builtin-agent

Conversation

@asteroida123

Copy link
Copy Markdown
Collaborator

What

Integrates ZCode as the sixteenth built-in agent, driven through the pinned community adapter zcode-codeg-adapter@0.1.3 (stdio ACP; the ZCode CLI itself ships no ACP server). This follows the DeepSeek Harness pattern — built-in enum entry + npm-distributed adapter — with one architectural difference called out below.

ZCode's own backend keeps its history in a private store, which codeg deliberately does not parse. ZCode is therefore the first built-in whose history is codeg's own ACP recording (parsers::acp_native, the same transcript path custom agents use) — transcript_dir_for now covers Custom(_) | ZCode. Every other built-in keeps its dedicated native-store parser.

Notable decisions

  • Launch contract: the adapter requires ZCODE_CODEG_ENTRY (absolute path to the ZCode app's .cjs entry) and exits before the handshake without it. codeg validates an explicit Agent Settings → ZCode env override, else probes the standard install locations (/Applications/ZCode.app/..., ~/Applications/...); failure routes to an install-prompt error instead of an opaque mid-handshake exit.
  • Identity compatibility: zcode-codeg stays a valid custom-agent id, so conversations persisted as custom:zcode-codeg (the pre-builtin registration) keep resolving; no forced migration.
  • MCP: wire-only delivery (deliberately off the forward skip list — the codeg-mcp companion must reach it); no codeg-side native MCP store, so ZCode stays out of McpAppType and the MCP settings page. Skills stay undeclared until there is ZCode-side evidence of a load path.
  • default_enabled: the variant is listed explicitly — the surrounding matches! compiles non-exhaustively, and without the arm the agent is born disabled and never appears in the picker.
  • READMEs: built-in count fifteen → sixteen and ZCode joins the supported-agent roster, all ten languages.

Live acceptance (ZCode CLI 0.16.5, macOS arm64)

  • Multi-turn chat with context retention; streaming and clean turn settlement
  • Tool cards for Read / Write / Edit / Bash with plan-mode read-only enforcement
  • Permission cards (Allow once / Always allow in this project / Deny) — the adapter maps ZCode's native option kinds into the closed ACP enum; off-enum kinds used to fail client-side deserialization and tear the connection down
  • Writes verified on disk; cancellation settles with stop_reason=cancelled and the session stays usable
  • Server restart replays history exactly once (no duplicates) and the conversation continues via session/load
  • Model selector lists the full desktop-config catalog (16 models across 9 providers on the test machine) with working switching on the 0.16.5 wire shape (session/setModel with options.reasoningLevel)

Checks

  • cargo test --features test-utils — 3953 passed
  • cargo test --no-default-features --bin codeg-server --lib — clean
  • cargo clippy ×3 modes with -D warnings — clean
  • pnpm test — 6609 passed; pnpm build (static export) — clean
  • New unit tests: launch-entry preflight matrix, transcript-recording coverage, delegation enum counts, registry pin assertions

The adapter itself is MIT-licensed, stdio-only, and pinned exactly; its audit trail (backend contract probes, dual-generation model-switch protocol, permission-kind mapping) lives in the adapter repo.

ZCode becomes the sixteenth built-in, and the first one whose history
is codeg's own ACP recording rather than a dedicated native-store
parser: the pinned zcode-codeg-adapter keeps ZCode's store private, so
the built-in rides the same parsers::acp_native transcript path as
custom agents (transcript_dir_for now covers Custom(_) | ZCode).

- models/agent.rs: AgentType::ZCode, wire "zcode", ordering, shadow
  list; "zcode-codeg" deliberately stays a valid custom id so existing
  custom:zcode-codeg conversations keep resolving. default_enabled
  lists the variant (a matches! arm compiles non-exhaustively — without
  it the agent is born disabled and invisible).
- acp/registry.rs: AcpAgentMeta with the pinned npx distribution
  (zcode-codeg-adapter@0.1.3, node floor 22.16.0), registry id
  "zcode-acp".
- acp/connection.rs: ZCODE_CODEG_ENTRY launch preflight — an explicit
  Agent Settings value wins (and is validated), else the standard
  install locations are probed; failure routes to the install prompt
  instead of the adapter's E_EXIT mid-handshake.
- MCP: wire-only delivery (off the forward skip list), no codeg-side
  native store; skills intentionally undeclared until ZCode-side
  evidence exists; sandbox roots stay empty like custom agents.
- Frontend: type/order/name/color entries, Z monogram placeholder icon,
  delegation defaults list; McpAppType untouched (no store to manage).
- READMEs: the built-in count moves fifteen → sixteen and ZCode joins
  the supported-agent roster in all ten languages.
- Tests: entry-env preflight matrix, transcript-recording coverage,
  companion enum counts (16 builtins), registry npx pin.

Live acceptance on ZCode CLI 0.16.5: multi-turn chat with context
retention, tool cards (Read/Write/Edit/Bash) with plan-mode read-only
enforcement, permission cards (Allow once / Always / Deny), writes
verified on disk, cancellation settles cleanly and the session stays
usable, server restart replays history once with no duplicates and
continues, and the model selector lists the full desktop-config catalog
(16 models across 9 providers) with working switching on the 0.16.5
wire shape.
@asteroida123

Copy link
Copy Markdown
Collaborator Author

zcode暴露出了[上传工作区/.git记录到云端]的问题,可能快要开源了,说不定近期有大变化,可以等等看。

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.

1 participant