Skip to content

feat(agents): add ZCode CLI as a supported TUI agent - #21756

Open
sunganhao8-lgtm wants to merge 1 commit into
stablyai:mainfrom
sunganhao8-lgtm:feat/zcode-agent
Open

sunganhao8-lgtm wants to merge 1 commit into
stablyai:mainfrom
sunganhao8-lgtm:feat/zcode-agent

Conversation

@sunganhao8-lgtm

Copy link
Copy Markdown

Summary

Adds Z.ai's ZCode CLI to the built-in agent roster, following the same shape as the Trae addition (#10763):

  • zcode joins the TuiAgent union, TUI_AGENT_CONFIG (detect on the standard zcode command), the telemetry AgentKind enum, TUI_AGENT_DISPLAY_NAMES, TUI_AGENT_AUTO_PICK_ORDER, agent-type-label, the headless one-shot matchers, and the skills CLI key mapping (zcode, already a valid key in the skills CLI namespace).
  • Yolo launches pre-fill --mode yolo, ZCode's documented permission-bypass flag.
  • Bundled 64×64 agent icon (src/shared/agent-icons/zcode.png), renderer favicon assets, mobile icon assets + favicon domain, agent catalog entry, and the en/es/ja/ko/zh locale labels.
  • Docs row in docs/site/content/docs/agents/supported.mdx.

Prompt injection

ZCode has no argv prompt form — unknown positionals exit with Unknown command: … — and no prefill flag or env seeding, so the entry uses stdin-after-start (launch the bare TUI, paste once the composer is up), the same path Kimi/Aider/Qwen use. The new tui-agent-startup test pins this contract.

Out of scope: usage / rate-limit tracking

Unlike Kimi (documented managed-usage endpoint) or MiniMax, Z.ai does not publish a usage API for the coding plan, so no usage provider is included in this PR. Happy to follow up once there's a stable path (also filed an issue to discuss).

Verification

  • pnpm run typecheck (node/cli/web/e2e projects) — clean
  • vitest for tui-agent-config, agent-kind, skills-cli-agent-keys, agent-process-recognition, require-tui-agent-config, agent-status, tui-agent-startup — 202 tests passing
  • verify:localization-catalog / verify:localization-coverage — passing
  • oxfmt applied to all touched files

Add Z.ai's ZCode CLI to the built-in agent roster, following the same
shape as the Trae addition: launch config, telemetry kind, skills CLI
mapping, display names, bundled icon, mobile assets, i18n labels, docs.

Detection runs on the standard `zcode` command. ZCode has no argv or
prefill prompt form (unknown positionals exit with `Unknown command`),
so prompts inject via the stdin-after-start path like Kimi/Aider.

Usage/rate-limit tracking is intentionally out of scope: Z.ai does not
publish a usage API for the coding plan yet, unlike Kimi's documented
managed-usage endpoint.
@coderabbitai

coderabbitai Bot commented Sep 20, 2026

Copy link
Copy Markdown
Contributor

Review Change StackReview Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Advanced

Run ID: 860dd2eb-d2c7-4e04-a493-717bb39a64a6

📥 Commits

Reviewing files that changed from the base of the PR and between ee61e3b and e732fdf.

⛔ Files ignored due to path filters (1)
  • src/shared/agent-icons/zcode.png is excluded by !**/*.png
📒 Files selected for processing (23)
  • docs/site/content/docs/agents/supported.mdx
  • mobile/src/components/mobile-agent-icon-assets.ts
  • mobile/src/tasks/mobile-tui-agents.ts
  • src/renderer/src/i18n/locales/en.json
  • src/renderer/src/i18n/locales/es.json
  • src/renderer/src/i18n/locales/ja.json
  • src/renderer/src/i18n/locales/ko.json
  • src/renderer/src/i18n/locales/zh.json
  • src/renderer/src/lib/agent-catalog.tsx
  • src/renderer/src/lib/agent-favicon-assets.ts
  • src/renderer/src/lib/agent-status.test.ts
  • src/renderer/src/lib/agent-status.ts
  • src/renderer/src/lib/tui-agent-startup.test.ts
  • src/shared/agent-headless-command.ts
  • src/shared/agent-kind.ts
  • src/shared/agent-type-label.ts
  • src/shared/skills-cli-agent-keys.ts
  • src/shared/telemetry-property-schemas.ts
  • src/shared/tui-agent-config.ts
  • src/shared/tui-agent-display-names.ts
  • src/shared/tui-agent-permissions.ts
  • src/shared/tui-agent-selection.ts
  • src/shared/tui-agent.ts

Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review.


📝 Walkthrough

Walkthrough

Adds ZCode as a supported TUI agent. Shared configuration covers detection, startup prompt injection, permissions, telemetry, labels, selection, and headless command matching. Renderer code adds catalog, favicon, localization, and status support with tests. Mobile code adds icon and domain mappings. Documentation lists ZCode as supported with auto-setup.

Priority: ⬇️ Low

Merge Risk: ⚪ Minimal · up to e732f

The ZCode integration has no confirmed correctness or localization defect requiring a merge block and is ready to merge after normal checks.

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description explains the implementation and verification, but it does not follow the repository template. It omits required sections such as ELI5, What Changed, Why, Visual Proof, Testing checkbox… Update the description to include all template sections. Add the required Fixes #... issue reference, state N/A with a reason for Visual Proof if applicable, document manual and automated testing, complete the required checklists, and a…
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 1 functions across 17 files. (6 skipped: 6… Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely identifies the main change: adding ZCode CLI as a supported TUI agent.
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.
Full details: Description check

Explanation

The description explains the implementation and verification, but it does not follow the repository template. It omits required sections such as ELI5, What Changed, Why, Visual Proof, Testing checkboxes, AI Disclosure, Review, Agent skill upstream boundary, Notes, and Checklist. It also does not provide the required issue reference in a Fixes #... entry.

Resolution

Update the description to include all template sections. Add the required Fixes #... issue reference, state N/A with a reason for Visual Proof if applicable, document manual and automated testing, complete the required checklists, and address AI disclosure, review, upstream-boundary, and compatibility notes.

Full details: Docstring Coverage

Explanation

Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 1 functions across 17 files. (6 skipped: 6 unsupported.)

  • Fix all pre-merge checks with AI

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.

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Important

Two things to settle before merge: the zcode binary is an unofficial third-party client, not a Z.ai first-party CLI, and the headless matcher is incomplete for the CLI's --print / --target one-shot forms.

Reviewed changes

  • New TuiAgent member zcode wired through the full registration surface (tui-agent.ts, tui-agent-config.ts, display names, auto-pick order, agent-kind.ts, agent-type-label.ts, skills key, telemetry enum, ICONABLE_AGENT_TYPES) plus bundled icon, favicon assets, mobile assets, catalog entry, and locale labels.
  • Prompt injection uses stdin-after-start (bare TUI + paste after composer), matching the comment that positionals are parsed as commands.
  • Yolo launch appends --mode yolo via YUI_AGENT_PERMISSIONS/YOLO_TUI_AGENT_ARGS.
  • Headless one-shot matching maps zcode to the Ante matcher.
  • Docs + tests: a row in supported.mdx, a formatAgentTypeLabel/icon test, and a tui-agent-startup launch-plan test.

⚠️ The zcode command comes from an unofficial community client, not Z.ai

ZCode itself is a desktop Electron ADE — the Z.ai docs (zcode.z.ai/en/docs/install, docs.z.ai/devpack/tool/zcode) only document a desktop download with no CLI, zcode on PATH, or --mode flag. The zcode npm bin is published by the unofficial package zcode-app-cli (repo kingsword09/zcode-cli, "Unofficial terminal client for the official agent runtime shipped with ZCode Desktop"). That project's HOST_INTEGRATION.md explicitly names Orca as a supported host, so this is very likely the intended target — but the PR titles it "Z.ai's ZCode CLI" and points the catalog homepageUrl and the docs row at the desktop app, which misattributes an unaffiliated MIT client to Z.ai.

Technical details
# Third-party vs first-party provenance

## Affected sites
- `src/renderer/src/lib/agent-catalog.tsx:128` — `homepageUrl: 'https://zcode.z.ai'` (desktop app)
- `docs/site/content/docs/agents/supported.mdx:62` — row says "Auto-setup" linking Z.ai
- `src/shared/tui-agent-config.ts:125-129` — `detectCmd: 'zcode'`

## Required outcome
- Confirm the intended target with maintainers. If it is `zcode-app-cli`, label it as a
  community/unofficial client in the PR title/body, docs row, and ideally the catalog label or
  a homepage that identifies the actual package (`https://github.com/kingsword09/zcode-cli` or
  the npm page).
- If a first-party ZCode CLI exists that this targets instead, cite it; the linked docs don't
  describe one.

## Open questions for the human
- Is adding an unofficial, unaffiliated terminal client to the built-in "Auto-setup" roster
  acceptable? Existing entries are first-party CLIs.

Pullfrog  | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

'prime-agent': isPrimeAgentHeadlessOneShotCommand,
ante: isAnteHeadlessOneShotCommand
ante: isAnteHeadlessOneShotCommand,
zcode: isAnteHeadlessOneShotCommand

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This matcher is incomplete for ZCode. The community CLI's launcher treats --prompt/-p, --print, and --target as non-TUI invocations, but isAnteHeadlessOneShotCommand only matches --prompt/-p (and -p*), so zcode --print … and zcode --target … escape filterHeadlessOneShotAgentCommand and get treated as interactive agent invocations. Since ZCode's headless surface differs from Ante's, it likely needs its own matcher (as Prime Agent has) covering all four forms.

Technical details
# zcode headless one-shot matcher is incomplete

## Affected sites
- `src/shared/agent-headless-command.ts:16` — reuses `isAnteHeadlessOneShotCommand`
- `src/shared/ante-headless-command.ts:3` — flags are only `--prompt`, `-p`
- `src/shared/agent-process-recognition.ts:301,318` — the filter's only call sites

## Evidence
- `zcode-app-cli` `src/launcher.ts` marks `--prompt`, `--target`, `--print`, and `-p` as
  `agentInvocation` (non-TUI), while `isTuiRuntimeInvocation` returns false for all of them.

## Required outcome
- Every non-TUI `zcode` invocation is filtered so Orca does not host it as a TUI agent.

## Suggested approach
- Add a `zcode-headless-command.ts` matcher covering `--prompt`/`-p`, `--print`, and `--target`,
  and add a recognition test mirroring the existing one-shot cases.

@nwparker

Copy link
Copy Markdown
Contributor

ZCode harness is green — please try it and comment on #22464

Test instructions: #22464 (comment)

Build: https://github.com/stablyai/orca-adhoc/releases/tag/v1.4.210-adhoc.20260923230858
orca-macos-arm64.dmg · orca-macos-x64.dmg · orca-windows-setup.exe (unsigned on Windows — SmartScreen → More info → Run anyway)

CI is now fully green (31/31). Please comment on #22464 with what you find — whether it works or breaks. Include your OS and zcode --version. Once a few people confirm it works on real machines, we approve and merge.

The two gaps I can't close myself:

  • A live session with a real Z.ai account. My test box has no model configured, so I proved the status pipeline with ZCode's own hook payloads rather than real turns. Nobody has watched an actual ZCode session drive Orca end to end.
  • Windows, Linux, and SSH on real hardware. Covered by contract tests, never run on a real host.

This branch has not been deployed

No deployments
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