You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
+1 — strong support for this. Did a read-only pass over 3.2.5 and it turns out most of the machinery for a single-shot mode already ships in the bundle; what's missing is just a user-facing -p-style entrypoint. Hoping this evidence makes the issue easier to triage.
What already exists under the hood (from app.asar, ZCode 3.2.5):
A real CLI exists: apps/zcode-cli/packages/cli/dist/zcode.cjs, launched via a shebang wrapper (#!/bin/sh … exec "$runtime_root/node" …).
It already runs as a JSON-RPC-over-stdio service: app-server --stdio (controlled via ZCODE_AGENT_SERVER_ARGS_JSON / ZCODE_AGENT_SERVER_CWD, spawned under ELECTRON_RUN_AS_NODE=1).
Full ACP-style session methods are reachable from that interface: session/create, session/send, session/subscribe, session/steer, session/events, session/read, session/list, plus turn.*/part.*/message.* event streams.
@agentclientprotocol/sdk is bundled, so the same protocol shape used to drive claude -p / codex exec is viable here.
So zcode -p "<prompt>" is essentially: session/create → session/send → drain until turn.completed → print the final assistant part(s) to stdout → exit.
Proposed entrypoint shape (stacking on the list already in the issue):
Semantics worth pinning: --json streams the raw event stream (turn.*/part.*); plain mode (default) emits only final assistant text on stdout with progress/diagnostics on stderr to keep stdout clean — matches claude -p.
Rabbit holes worth flagging up front:
MCP process lifecycle — a non-interactive session/create has to tear down MCP servers cleanly on exit or single-shot scripts will leak processes. There are already two open bugs on exactly this (MCP server 进程在重连/重启时未回收旧实例 and 同一 workspace 重复 session/create 导致 MCP 进程泄漏); a headless CLI would hit the same path on every run. Suggest agent-level cleanup after turn.completed, or an explicit --no-mcp.
Auth / credentials — a headless CI runner has no desktop OAuth. Needs ZCODE_* env-var / API-key auth (GLM Coding Plan already has an API-key mechanism; expose it).
Permission mode — for unattended runs the default must be non-interactive (either auto-deny tool calls, or a --permission-mode à la acceptEdits/bypassPermissions like Claude Code). Popping an interactive confirm with no TTY would just hang.
Steering/queue relationship — session/steer currently returns {kind:"unsupported", message:"ZCode Protocol steering is not wired yet."} (see [建议 / Feature] Enter=排队 / queue, Ctrl+Enter=引导 / steer (对齐 Codex 行为) #95). Doesn't block -p`, but worth noting it's the same family of "expose existing internals via the protocol".
Output determinism — for CI gates (pass/fail) the exit-code contract matters (e.g. non-zero = review failed, 0 = passed). Suggest not overloading exit codes for anything else.
Why this is high-leverage: it's not a greenfield feature — it's wiring a thin command layer on top of the existing zcode.cjs that maps to session/create+session/send+drain, plus a defined stdout/stderr/exit-code contract. ACP + the stdio JSON-RPC server already do the heavy lifting.
Happy to attach a PoC patch or a worked transcript. Watching this one. 🙌
The following issues describe the same problem and are now tracked here: #8, #26, #215, #270
Shared root cause: ZCode can only be driven interactively from the desktop app today. The community needs a non-interactive entry point callable from shell / CI / git hooks, plus a standalone CLI distribution with a working TUI (the bundled zcode.cjs is missing the @zcode/tui package).
Distinct reporters: 5
Priority raised from P2 to P1.
Updates will only be posted on this issue; the merged ones are closed and labelled duplicate. If you think one of them is actually a different problem, reply there and we'll split it back out.
POST https://open.bigmodel.cn/api/paas/c1f3a7e2/v2/client
{"code":1000,"msg":"身份验证失败","success":false}
Activity
github-actions commentedon Jun 21, 2026
👋 感谢你的反馈,我们已经收到。
status: 待评估,你可以随时补充信息。needs: 更多信息标签并 @ 你。👋 Thanks — we've received your issue.
status: 待评估(Triage); feel free to add context.needs: 更多信息and ping you.vtsixthai commentedon Jul 6, 2026
+1 — strong support for this. Did a read-only pass over 3.2.5 and it turns out most of the machinery for a single-shot mode already ships in the bundle; what's missing is just a user-facing
-p-style entrypoint. Hoping this evidence makes the issue easier to triage.What already exists under the hood (from
app.asar, ZCode 3.2.5):apps/zcode-cli/packages/cli/dist/zcode.cjs, launched via a shebang wrapper (#!/bin/sh…exec "$runtime_root/node" …).app-server --stdio(controlled viaZCODE_AGENT_SERVER_ARGS_JSON/ZCODE_AGENT_SERVER_CWD, spawned underELECTRON_RUN_AS_NODE=1).session/create,session/send,session/subscribe,session/steer,session/events,session/read,session/list, plusturn.*/part.*/message.*event streams.@agentclientprotocol/sdkis bundled, so the same protocol shape used to driveclaude -p/codex execis viable here.So
zcode -p "<prompt>"is essentially:session/create→session/send→ drain untilturn.completed→ print the final assistant part(s) to stdout → exit.Proposed entrypoint shape (stacking on the list already in the issue):
Semantics worth pinning:
--jsonstreams the raw event stream (turn.*/part.*); plain mode (default) emits only final assistant text on stdout with progress/diagnostics on stderr to keep stdout clean — matchesclaude -p.Rabbit holes worth flagging up front:
session/createhas to tear down MCP servers cleanly on exit or single-shot scripts will leak processes. There are already two open bugs on exactly this (MCP server 进程在重连/重启时未回收旧实例and同一 workspace 重复 session/create 导致 MCP 进程泄漏); a headless CLI would hit the same path on every run. Suggest agent-level cleanup afterturn.completed, or an explicit--no-mcp.ZCODE_*env-var / API-key auth (GLM Coding Plan already has an API-key mechanism; expose it).--permission-modeà laacceptEdits/bypassPermissionslike Claude Code). Popping an interactive confirm with no TTY would just hang.session/steercurrently returns{kind:"unsupported", message:"ZCode Protocol steering is not wired yet."}(see [建议 / Feature] Enter=排队 / queue, Ctrl+Enter=引导 / steer (对齐 Codex 行为) #95). Doesn't block-p`, but worth noting it's the same family of "expose existing internals via the protocol".pass/fail) the exit-code contract matters (e.g. non-zero = review failed, 0 = passed). Suggest not overloading exit codes for anything else.Why this is high-leverage: it's not a greenfield feature — it's wiring a thin command layer on top of the existing
zcode.cjsthat maps tosession/create+session/send+drain, plus a defined stdout/stderr/exit-code contract. ACP + the stdio JSON-RPC server already do the heavy lifting.Happy to attach a PoC patch or a worked transcript. Watching this one. 🙌
panda920 commentedon Aug 17, 2026
📌 已把重复反馈合并到这条
以下 issue 反映的是同一个问题,已合并到这里统一跟进:#8、#26、#215、#270
共同根因:ZCode 目前只能通过桌面端交互使用。社区需要一个可被 shell/CI/git hook 调用的非交互执行入口,以及一个可独立安装、TUI 可用的 CLI 发行版(桌面端内置的 zcode.cjs 缺 @zcode/tui 包)。
独立反馈人数:5
优先级已从 P2 调整为 P1。
后续进展只会更新在这条 issue 下,被合并的几条已关闭并打上
duplicate。如果你认为其中某条其实是另一个问题,在那条下面回复,我们会重新拆出来。📌 Duplicate reports consolidated here
The following issues describe the same problem and are now tracked here: #8, #26, #215, #270
Shared root cause: ZCode can only be driven interactively from the desktop app today. The community needs a non-interactive entry point callable from shell / CI / git hooks, plus a standalone CLI distribution with a working TUI (the bundled zcode.cjs is missing the @zcode/tui package).
Distinct reporters: 5
Priority raised from P2 to P1.
Updates will only be posted on this issue; the merged ones are closed and labelled
duplicate. If you think one of them is actually a different problem, reply there and we'll split it back out.demouo commentedon Sep 4, 2026
您好!非常需要zcode cli 蛮多服务器是无桌面的 glm-5.3还是在zcode上用更加丝滑,感谢
Tr0jAnV1rU4 commentedon Sep 6, 2026
希望推进该想法,真的很需要CLI工具
fely-zhao commentedon Sep 7, 2026
+1非常需要cli....现在都是通过wsl开发,且在wsl中统一管理所有agent...虽然目前版本远程开发已经可以了,但是不怎么方便。。
liubaicai commentedon Sep 8, 2026
we need chinese...对不起走错台了,we need cli
Hyacinth-YX commentedon Sep 8, 2026
we need cli 👍
ahxinin commentedon Sep 8, 2026
i need cli
mahan002 commentedon Sep 9, 2026
非常需要cli
LetterTree commentedon Sep 10, 2026
need CLI!
beiyanpiki commentedon Sep 10, 2026
不止cli, 最好能同时将tui适配一下
JamesbbBriz commentedon Sep 10, 2026
非常需要
agent-labs1998 commentedon Sep 12, 2026
+1,非常期待并强烈支持 ZCode CLI / TUI 及非交互单轮执行模式(对标 codex exec / claude -p)的落地!
结合我们日常的真实开发工作流,补充几个为什么我们非 CLI / TUI 不可的核心场景与痛点:
无桌面环境(Headless / Remote Linux Server / WSL)的刚性需求:
嵌入现有工具链与脚本自动化(CI/CD Gate & Git Hooks):
cat changed.diff | zcode exec "review 这段 diff,只输出 pass/fail")进行静默 Review,并根据返回结果决定是否阻断提交。--output-format json输出。Unix Pipeline 数据流与 Agent 工具链链式调用:
补全桌面版内置 CLI 缺陷(如缺少 @zcode/tui 包):
zcode.cjs缺少@zcode/tui导致终端 UI 无法正常拉起的问题。总结:
ZCode 的模型能力和 Agent 表现非常出色,但只有具备了独立的 CLI / TUI 及非交互脚本化模式,它才能从“桌面辅助工具”真正升级为“研发流程基础设施”。感谢社区维护者的倾听与跟进,希望能尽快看到 CLI 发行版的落地!
Martian101 commentedon Sep 13, 2026
非常需要,做基于tmux的多agent协同,通过cli还是很方便的
longbow1998 commentedon Sep 14, 2026
需要cli
ryaningli commentedon Sep 29, 2026
期待cli、tui
maxweight commentedon Oct 6, 2026
we need cli😭
misa527528 commentedon Oct 8, 2026
很需要 cli,期待早日推出,感恩
zm112211mz commentedon Oct 27, 2026
补充:独立 CLI(node-bundle 0.17.0 / Desktop 3.16.3)headless 链路排查——三处断点与复现
环境:macOS (Apple Silicon)、ZCode.app 3.16.3、内置 CLI
zcode.cjs0.17.0(node-bundle artifact)。目标场景:在本 issue 的目标(shell/CI/git hook 可调用的非交互入口)下,让
zcode -p复用桌面端已登录的 bigmodel 套餐(含闲时免费额度)跑 headless 任务。TL;DR:
-p在独立运行时存在三处相互叠加的断点,导致账户供应商永远无法进入注册表,最终表现为Error: Select a model before sending a message;login命令报 OAuth 错误也是同一根因。三处均已定位到具体函数。断点 1(即 #51 已报告的打包缺陷):CLI 相对自身目录定位内置 Provider 配置失败
resolveBundledZCodeBuiltinProviderConfig依次查找<glm>/provider/zcode-builtin.json与<glm>/../../../../../config/provider/zcode-builtin.json,与 App 实际布局Resources/config/provider/zcode-builtin.json不符。可用环境变量绕过(prepareCliProviderRuntimeEnv的 pass-through 分支):绕过后
-p可进入模型选择阶段。断点 2(核心):独立模式账户源 bootstrap 必然为空
AccountProviderService为纯内存实现,无持久化,每次启动经njn→ejn重新解析;configuredProviders为空 →ejn走已有配置分支 → 返回空列表 → 之后永远为空(bootstrap 悖论);login路径(ejn无入参分支)读取内置配置的config.providers字段,但现行配置格式(revision 33)中账户供应商实际声明在config.providerConfigRules.providerRules(access.type === "zhipu-account"条目,含account:bigmodel-start-plan、account:bigmodel-offpeak-idle-plan等 10 个),config.providers字段不存在 →t.providers.entries()抛 TypeError → 被onDidRefreshError静默吞掉;xet({configuredDefault, registry})遍历registry.providers为空 →source:"none"→Select a model before sending a message。断点 3:OAuth JWT 无法通过 V4 请求签名
D1r)只接受两类格式:payload 含api_key字段的 JWT,或id.secret形式的 API Key;~/.zcode/v2/credentials.json的oauth:bigmodel:access_tokenpayload 仅含 user_id / user_key / customer_id 等,无api_key→ClientRequestSigningV4Error: Client signing requires an API Key or Project Access Token.;project-key-location条目仅含 organizationId/projectId/apiKeyId 元数据,密钥本体不在本地);providerConfigRules.providerRules[0].config.access.apiKey填入任意值,即可让bigmodel-api模板供应商进入注册表并自动选中模型(说明注册/选择链路本身是通的),仅在签名层被拒。复现步骤
影响:未创建 Coding Plan API Key 的套餐用户(含仅使用闲时免费额度的用户)完全无法使用 headless CLI;独立 CLI 的登录复用在此版本不可用。
修复建议:
ejn的 bootstrap/login 分支回退解析config.providerConfigRules.providerRules中access.type === "zhipu-account"的条目(数据已存在于配置中,仅字段路径不匹配);@zcode/tui;doctor增加 standalone 账户源自检项,使被吞掉的onDidRefreshError对用户可见;credentials.json可由机器派生密钥解密,已验证可行)。SeveNOlogy7 commentedon Nov 2, 2026
交叉引用(#855 / #51 的打包层定位)+ 一组对照数据:清掉断点 1 之后
-p能跑,但没有走套餐 provider按你给的 env 旁路,我在 Windows 上复现了断点 1,同时得到一个与断点 2 / 3 直接相关的对照数据点 —— 结论不否定你的分析,但可以把「打包层」和「账户层」分得更干净。
1. 断点 1 在 Windows 侧完全一致
Desktop 3.17.1 / 内置 CLI 0.17.1(node-bundle,
sea: no)。zcode.cjs里等价代码:而 App 实际把配置发布在
resources\config\provider\zcode-builtin.json(rev 43,260,787 B)—— 只差 1 层,代码却往上找了 5 层。完整的 A/B 报错原文与三种改法我补在 #855 了。你给的旁路确认可用;补充一点:两个变量必须成对设置,只设一个会直接抛
2. 对照数据:
-p跑通了,但落到的是 api-key provider同一时刻日志(
~/.zcode/cli/log/zcode-YYYY-MM-DD.jsonl):原因在 personal 配置里:
providerOrder里没有任何account:*—— 所以-p只会选中 api-key provider。更准确的表述是:
providerRules/providerOrder里有没有可用的非账户 provider-p表现opencode-go-chat)Select a modelSelect a model before sending a message这还解释了一个容易误判的现象:有套餐的用户在
-p下可能悄悄用掉另一个 provider 的额度,看起来"套餐可用",实际根本没走套餐。3. 你的断点 2 细节被证实
rev 43 的
config只有providerConfigRules/modelConfigRules,确实没有config.providers;而zcode_protocol.provider_registry.ready的accountRevision里 10 条zhipu-account全部是entitled:false:4. 一个供继续验证的反差
同一台机器上,同一个 bundled CLI 的交互式会话日志里能看到账户 provider 的成功请求:
也就是说账户源并非在整个 CLI 里都不可用,差异更像是出现在
-p的引导 / 模型选择阶段(ejn的首轮 resolve),而不是账户源本身。如果这一点成立,修复面会比"账户源完全不可用"小不少。5. 建议的判别命令
opencode-*/ 其它 api-key provider → 与本机一致,需要把defaultModelSelection指向账户 provider 才能验证断点 3(签名层);account:*→ 说明断点 2 在 0.17.1 已部分改善。6. 小结
这里其实是两处独立修复,互不替代:
@zcode/tui未随包分发;providerConfigRules.providerRules的数据源与ejnbootstrap 分支。前者修好之前,用户会先撞一次墙(
无法定位 …/Cannot find package '@zcode/tui'),所以两条 issue 的症状很容易混在一起。SeveNOlogy7 commentedon Nov 2, 2026
补充一条受控实验:Windows 0.17.1 上独立
-p的失败点是「签名层」(断点 3),不是「模型选择」(断点 2)—— 并更正我上一条里的一处推断1. 受控实验
方法:把
~/.zcode/v2/provider_config.json的defaultModelSelection临时指向账户 provider,跑一次-p,然后立刻按备份还原(sha256 校验一致)。这样能把「模型选择」和「认证/签名」两段分开。日志(
~/.zcode/cli/log/…jsonl)里的完整链条,baseURL =open.bigmodel.cn:读法:
Select a model before sending a message;handshake-business/businessCode=1000)→ CLI 改为无签名发送 → 401。所以在这台机器上,账户 provider 的注册 / 选择是通的,卡住的是「用 OAuth 凭据生成 V4 签名」这一步 —— 与你的断点 3 描述一致。
2. 更正:上一条里「交互式会话能成功」的推断
上一条我写「交互式会话日志里能看到账户 provider 的成功请求」,依据是同一份 CLI 日志里带
account:bigmodel-individual-coding-plan的model.sdk.stream.completed。查了 session 库后确认:那些记录来自一个长期并发的会话(同一个 id 从 10/31 持续到 11/02,工作目录是另一个项目,21 次请求、带 22 次工具调用),不是一次受控的独立 CLI 调用 —— 它很可能来自桌面宿主(按你的说法,宿主会注入凭据)。
因此那条推断撤回:目前唯一受控的独立 CLI 数据点,是上面这次签名失败。抱歉造成误导。
3. 对定位的意义
providerRules里已存在account:*条目时不会为空 → 与你的「已有配置即走另一分支」推测一致handshake-business 1000→ 无签名发送 → 401provider_not_configured结论:#855 修好之后,套餐用户的
-p仍会卡在断点 3;而断点 2 更像是一个「配置为空 + 首轮 resolve」的边界条件,值得单独确认。如果需要,我可以把这次实验的完整日志链(含时间戳、traceId,已去除个人路径)整理后贴上来。
SeveNOlogy7 commentedon Nov 6, 2026
更正上一条:断点 3 不是签名协议问题,而是「用哪个凭据去签」—— project access token 可以通过 V4 签名
上一条我写「断点 3 复现:签名握手失败」。继续做 A/B 后需要更正:签名协议本身是通的,结果取决于 standalone CLI 选用的凭据来源。
复现(Windows / CLI 0.17.1)
zcode -p hi,defaultModelSelection = account:bigmodel-individual-coding-plan / GLM-5.3-Flash:握手响应体(只读探针,HTTP 200 但业务码非 200):
实际送出的凭据形状:
field=apiKey apiKeyId.len=32 secret.len=16 secret.dots=0换到 OAuth 来源后
createStandaloneProviderRuntimeHeadersPort.refreshBeforeModelRequest里有两条分支:把分支强制到 oauth 后(只改诊断副本,不改安装包):
签名成功,请求到达模型端,返回的是配额而不是 401:
对断点 3 的修正
handshakeFieldid.secret)apiKeycode 1000 身份验证失败token_use:"project_access")accessTokencode 200 操作成功所以在这台机器上 断点 3 不成立 —— 用 project access token 时 V4 签名是通的。真正卡住的是:
auth-source=manual时,standalone CLI 会拿 coding-plan API key 当签名凭据,而签名服务不接受它;失败后按failOpenEligible降级为无签名发送,才得到 401。给维护者的两个问题
auth-source=manual时用 coding-plan API key 做 V4 握手,是设计如此,还是应该改用别的凭据?refreshBeforeModelRequest是否应在降级成 unsigned 之前回退到 oauth(现在会直接 401)?不贴凭据的判别命令:
gzhanlei commentedon Nov 17, 2026
补一个刚实测过的真实用例(CoDelphi Radar skill),支持这个提案,并补充一个重要场景维度:「单发直调」不只是 CI 场景,也是 skill 协议里"宿主代为执行模型任务"的基础设施。
背景
CoDelphi 的开源 radar skill(分析一个 Git 仓库生成产品功能 HTML 报告)已经按"宿主原生模式"设计:skill 先确定性切出 65 个自包含工单(源码嵌在 prompt 里、禁用工具、纯补全、一发一分区),期望宿主把每个工单单轮直调给当前模型。这个形态天然适配
zcode exec:stdin/参数进 prompt → stdout 出 JSON。实测数据(Sure 仓库,65 分区)
(token 差 ~30 倍:agent 路径 90% 消耗在把工单分段 Read 进上下文的工具循环里。直调路径产出的结果通过了同一套证据校验:47 条 evidence 路径全部合法、字段名契约完全符合。)
对提案的补充诉求
--output-format json外,希望文档化多开并发的限流行为(并发 N 个zcode exec进程时的队列/退避语义)——skill 需要按此校准并行度;zcode exec+ skill 协议组合后,ZCode 用户可以获得与claude -p/codex exec同级的自动化能力,这一档(订阅账号、无裸 API key 的 headless 子命令)正是当前市面主流宿主的标配形态。