feat(agents): add ZCode (Z.ai) agent adapter - #157
Geerdan1995 wants to merge 1 commit into
Conversation
- detect.ts: zcode entry (protocol argv, ZCODE_BIN override) - argv.ts: --json -p flags + single-JSON-document parser (response/usage) - invoke.ts: deliver the prompt via --attach temp file — multi-line prompts cannot survive Windows cmd.exe argv (npm .cmd shims re-parse at newlines), and zcode -p takes no stdin sentinel. Skips the per-line stdout loop like openclaw (whole-document parse on close). Verified end-to-end on Windows: zcode 0.16.9 via GLM-5.3 coding plan generates a full magazine-article HTML through the app.
|
Heads-up: #139 is also open for ZCode support. Both PRs change |
mrcfps
left a comment
There was a problem hiding this comment.
@Geerdan1995 thanks for this tidy adapter — the Windows --attach workaround is a thoughtful catch.
Verified the three-file change against ZCode's current CLI (--json / -p / --attach, one closing JSON document with response / sessionId). Detection, argv, whole-document parse-on-close, and temp-file cleanup on the success and abort paths all line up with the stated headless shape, and the special-case in invoke.ts leaves the other argv agents alone.
Nice work shipping a real end-to-end path on Windows 11. 🙌
🔁 Powered by Looper · runner=reviewer · agent=omp · An autonomous AI dev team for your GitHub repos.
What
Adds a ZCode agent adapter (Z.ai's coding agent CLI, open-sourced last week at zai-org/ZCode) — the "hook up a new coding-agent CLI" bucket from CONTRIBUTING (~an entry + argv + parser, plus one Windows-specific delivery fix in
invoke.ts).ZCode's headless shape is
zcode --json -p "<prompt>": one yolo-permissioned turn, printing a single JSON document ({sessionId, response, usage}) on close — no ndjson stream, no stdin prompt sentinel.Changes
zcodeentry (protocolargv,ZCODE_BINoverride). No--modelflag exists in the CLI yet, so only the syntheticDEFAULT_MODELis offered (the CLI's configured default model wins).--json -pflags; parser extractsresponse/sessionId/usage.totalTokensfrom the closing JSON document.--attach <temp-file>instead of-p <text>: multi-line prompts cannot survive Windows argv — npm's.cmdshims (and the existingshell: truespawn) re-parse the command line at newlines, so the 4KB skill prompt arrives truncated and-perrors with "argument missing".zcode --attachis the CLI's native file-input path.Verification
End-to-end on Windows 11, zcode 0.16.9 running GLM-5.3 via a Z.AI coding plan:
available: truevia the npm-shim patharticle-magazineconversion through the app produces a complete 12.6KB standalone HTML document (<!DOCTYPE html>…</html>)中文摘要:接入 ZCode(Z.ai 刚开源的 Agent CLI)。无头形态是
zcode --json -p单轮执行 + 关流时输出单个 JSON 文档。Windows 上多行提示词过 cmd.exe 会被截断,所以提示词经--attach临时文件投递(CLI 原生能力),解析器从整份 JSON 中提取 response/usage。已在 GLM-5.3 Coding Plan 上端到端验证杂志模板真实生成。Related: #156 (community desktop packaging — same author).