zcode-agent 1.0.0 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,26 +1,26 @@
1
1
  <p align="center">
2
2
  <picture>
3
3
  <source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/0xgeorgemathew/zcode-agent/main/docs/assets/hero-dark.svg">
4
- <img src="https://raw.githubusercontent.com/0xgeorgemathew/zcode-agent/main/docs/assets/hero-light.svg" width="960" alt="Your agent (Claude Code, Codex or any agent with a shell) writes the decisions and a task contract. zcode-agent runs parallel GLM-5.3-Flash sessions that build, run their own checks, repair failures and have a fresh session judge screenshots. One handback line returns to your agent.">
4
+ <img src="https://raw.githubusercontent.com/0xgeorgemathew/zcode-agent/main/docs/assets/hero-light.svg" width="960" alt="Your agent (Claude Code, Codex or any agent with a shell) writes the decisions and a task contract. zcode-agent runs parallel GLM-5.3 sessions that build, run their own checks and repair failures, and has a fresh GLM-5.3-Flash session judge screenshots. One handback line returns to your agent.">
5
5
  </picture>
6
6
  </p>
7
7
 
8
8
  <p align="center">
9
9
  <a href="https://www.npmjs.com/package/zcode-agent"><img src="https://img.shields.io/npm/v/zcode-agent.svg?color=2E2A7A&label=npm" alt="npm version"></a>
10
10
  <img src="https://img.shields.io/badge/node-%E2%89%A522.13-2E2A7A" alt="node 22.13 or later">
11
- <img src="https://img.shields.io/badge/model-GLM--5.3--Flash-1C7C54" alt="runs on GLM-5.3-Flash">
11
+ <img src="https://img.shields.io/badge/models-GLM--5.3%20%C2%B7%20GLM--5.3--Flash-1C7C54" alt="runs on GLM-5.3 and GLM-5.3-Flash">
12
12
  <a href="https://github.com/0xgeorgemathew/zcode-agent/blob/main/LICENSE"><img src="https://img.shields.io/badge/license-MIT-2E2A7A" alt="MIT license"></a>
13
13
  </p>
14
14
 
15
15
  # zcode-agent
16
16
 
17
- zcode-agent is a command-line executor for any agent that can run a shell command: Claude Code, Codex, or your own. Your agent writes the decisions and a task contract. zcode-agent builds it with GLM-5.3-Flash, runs your checks itself, repairs what fails, and has a separate Flash session that never saw the code look at screenshots of the result. It returns one line of JSON. Your agent never reads the diff, re-runs the tests or opens a screenshot, so its expensive tokens go to decisions and exceptions.
17
+ zcode-agent is a command-line executor for any agent that can run a shell command: Claude Code, Codex, or your own. Your agent writes the decisions and a task contract. zcode-agent builds it with GLM-5.3, runs your checks itself, repairs what fails, and has a separate GLM-5.3-Flash session that never saw the code look at screenshots of the result. It returns one line of JSON. Your agent never reads the diff, re-runs the tests or opens a screenshot, so its expensive tokens go to decisions and exceptions.
18
18
 
19
19
  | | does | never does |
20
20
  |---|---|---|
21
21
  | **Your agent** | product, design and logic decisions; splits the work; answers questions | writes code, re-runs checks, looks at screenshots |
22
- | **zcode-agent** (GLM-5.3-Flash) | builds inside the paths it owns, runs subagents in parallel, runs the checks, fixes failures | invents anything user-visible the decisions left open, commits, deploys |
23
- | **The verifier** (a fresh Flash session) | serves the app, screenshots every viewport, quotes the text it can read, judges each criterion | edits files, trusts the DOM over the pixels |
22
+ | **zcode-agent** (GLM-5.3, or Flash with `--model flash`) | builds inside the paths it owns, runs subagents in parallel, runs the checks, fixes failures | invents anything user-visible the decisions left open, commits, deploys |
23
+ | **The verifier** (a fresh GLM-5.3-Flash session) | serves the app, screenshots every viewport, quotes the text it can read, judges each criterion | edits files, trusts the DOM over the pixels |
24
24
 
25
25
  &nbsp;
26
26
 
@@ -41,6 +41,8 @@ npx zcode-agent task \
41
41
 
42
42
  To skip `npx`, install it once with `npm install -g zcode-agent`. It needs Node 22.13 or later.
43
43
 
44
+ zcode-agent is also an [ACP](https://agentclientprotocol.com) agent: `zcode-agent acp` lets you chat with GLM-5.3 directly in T3 Code, Zed or any other Agent Client Protocol client. See [Use it in T3 Code, Zed or any ACP client](#use-it-in-t3-code-zed-or-any-acp-client).
45
+
44
46
  **With the ZCode app installed, there is nothing to configure.** zcode-agent reads the app's Z.ai API key where it is stored (it never copies or prints it) and gives every session the app's MCP servers and skills. It leaves out remote MCP servers that sign in with OAuth, because a headless session can't complete the sign-in, and it skips a server that failed to connect for the next six hours. The app's plugins, agent profiles and your global `AGENTS.md` stay out unless you pass `--inherit-desktop`. `--hermetic` leaves out the app's MCP servers and skills as well.
45
47
 
46
48
  **Without the app**, set an API key and install a browser for visual checks:
@@ -184,14 +186,14 @@ Flags cover the common fields. For a larger handoff, pass `--task contract.json`
184
186
 
185
187
  ## Models and effort
186
188
 
187
- Every command runs on GLM-5.3-Flash at effort `max` unless you pass a flag. Flash reads images, so the executor can check its own UI and the verifier can judge screenshots. `--model glm-5.3` is an override for work that needs the larger model, and it cannot read images.
189
+ Every command runs on GLM-5.3 at effort `high` unless you pass a flag, in `zcode-agent acp` as well as on the command line. Both models are always available: `--model flash` switches to GLM-5.3-Flash, which is cheaper and faster and, unlike GLM-5.3, can read images. The visual verifier always runs on Flash, so `--visual` works on either model. Pass `--model flash` when the executor should look at its own screenshots too.
188
190
 
189
191
  | flag | values | default |
190
192
  |---|---|---|
191
- | `--model` | `glm-5.3-flash`, `glm-5.3` | Flash |
192
- | `--effort` | `low`, `high`, `max` | `max` |
193
+ | `--model` | `glm-5.3`, `glm-5.3-flash` | GLM-5.3 |
194
+ | `--effort` | `low`, `high`, `max` | `high` |
193
195
 
194
- `--model` also takes the short names `flash`, `5.3-flash` and `53f` for Flash, and `5.3` and `53` for GLM-5.3. A contract can set `"model"` and `"effort"`, and flags override it. A resumed session keeps its model and effort unless you pass the flags again. Any other model or an unsupported effort exits 2 before anything starts.
196
+ `--model` also takes the short names `5.3` and `53` for GLM-5.3, and `flash`, `5.3-flash` and `53f` for Flash. A contract can set `"model"` and `"effort"`, and flags override it. A resumed session keeps its model and effort unless you pass the flags again. Any other model or an unsupported effort exits 2 before anything starts.
195
197
 
196
198
  &nbsp;
197
199
 
@@ -270,6 +272,61 @@ The counts come from each session's own engine database and include the executor
270
272
 
271
273
  &nbsp;
272
274
 
275
+ ## Use it in T3 Code, Zed or any ACP client
276
+
277
+ <p align="center">
278
+ <picture>
279
+ <source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/0xgeorgemathew/zcode-agent/main/docs/assets/acp-dark.svg">
280
+ <img src="https://raw.githubusercontent.com/0xgeorgemathew/zcode-agent/main/docs/assets/acp-light.svg" width="960" alt="An ACP client such as T3 Code or Zed sends prompts and answers to zcode-agent over stdio. zcode-agent streams text, diffs and the plan back and asks before edits and commands. Mode, model and effort are pickers; the defaults are GLM-5.3, effort high and Ask mode.">
281
+ </picture>
282
+ </p>
283
+
284
+ `zcode-agent acp` speaks the [Agent Client Protocol](https://agentclientprotocol.com) (v1) on stdio, so an ACP client drives GLM-5.3 directly: you chat with it, approve its edits and commands, and watch its tool calls, diffs and plan as they happen. `zcode-agent-acp` is the same command for clients that take only an executable. Key, MCP servers and skills work the same way as for `task`.
285
+
286
+ **T3 Code** (a build with the ACP Registry provider): install zcode-agent globally, then add a provider in Settings → Providers. Choose **ACP Registry**, set **ACP source** to **Local command** and **Executable override** to `zcode-agent-acp`. To set it in `~/.t3/userdata/settings.json` instead:
287
+
288
+ ```json
289
+ "providerInstances": {
290
+ "zcodeAgent": {
291
+ "driver": "acpRegistry",
292
+ "displayName": "zcode-agent (GLM-5.3)",
293
+ "enabled": true,
294
+ "config": { "source": "local", "commandPath": "zcode-agent-acp", "commandArgs": [] }
295
+ }
296
+ }
297
+ ```
298
+
299
+ T3 Code then offers GLM-5.3 (the default, at effort high) and GLM-5.3-Flash, with **Mode** and **Effort** pickers. Its runtime modes map onto the agent's approvals: in full access T3 answers every approval itself, and in approval-required it asks you. T3's plan mode switches the agent to its read-only Plan mode.
300
+
301
+ **Zed** (`settings.json`):
302
+
303
+ ```json
304
+ "agent_servers": {
305
+ "zcode-agent": { "type": "custom", "command": "zcode-agent", "args": ["acp"], "env": {} }
306
+ }
307
+ ```
308
+
309
+ | mode | the agent… |
310
+ |---|---|
311
+ | `build` (Ask, default) | asks before every edit and command |
312
+ | `edit` (Accept edits) | edits files freely and asks before commands |
313
+ | `plan` | only reads, then asks to start with a plan you approve |
314
+ | `yolo` (Full access) | runs every tool without asking |
315
+
316
+ What the client gets:
317
+
318
+ - **Live output.** Streaming text and reasoning, tool calls with titles, file locations and diffs, command output, and the to-do list as the plan.
319
+ - **Approvals.** The engine's permission prompts (allow once, always allow in this project, deny) are forwarded to you.
320
+ - **Picker updates.** Mode, model and effort as session config options; switching model keeps the effort when the new model supports it.
321
+ - **Usage.** Context use and the session's GLM cost so far at API list price, after every turn.
322
+ - **Sessions.** `session/list` and `session/load`: a session reopens in a new process with its history replayed. Every ACP session is a zcode-agent session (`kind: "acp"`), so `zcode-agent status`, `watch` and `cost` include it.
323
+ - **Inputs.** Images (saved to the session's tmp dir; GLM-5.3 cannot read them, so the prompt says so and suggests GLM-5.3-Flash), embedded files and file links in prompts. Your client's MCP servers (stdio, HTTP, SSE) are added to the session.
324
+ - **Cancel.** Stops the running turn and its tools.
325
+
326
+ The engine starts at the first prompt, not at `session/new`, so client probes cost nothing and leave no session behind. Flags set the defaults for new sessions: `--mode`, `--model`, `--effort`, `--hermetic` (fastest start: none of the app's MCP servers to connect), `--no-browser`, `--mcp`, `--skills`, `--timeout-ms` (per prompt; default none). `ZCODE_ACP_MODE` sets the default mode for clients that take no arguments, and `ZCODE_ACP_LOG=<file>` logs every frame. Questions the model would ask through a form are asked in its reply instead, because ACP v1 has no form UI.
327
+
328
+ &nbsp;
329
+
273
330
  ## Machine interface
274
331
 
275
332
  With `--json`, stdout carries NDJSON events and then exactly one `{"type":"result",…}` line. With `--quiet`, the result line is the only output. Task sessions leave text deltas out of the events unless you pass `--stream`, so your agent pays only for the lifecycle events.
@@ -334,8 +391,8 @@ The brief lists only failing checks (`checksPassed` counts the rest), unmet visu
334
391
  | `--serve` | task: the command that serves the app on `$ZCODE_PORT` |
335
392
  | `--max-repairs` | task and resume: repair turns after failures. Default: 2 |
336
393
  | `--check-timeout-ms` | task and resume: time limit per check. Default: 300000 |
337
- | `--model` | `glm-5.3-flash` (default) or `glm-5.3` |
338
- | `--effort` | `low`, `high` or `max` (default) |
394
+ | `--model` | `glm-5.3` (default) or `glm-5.3-flash` |
395
+ | `--effort` | `low`, `high` (default) or `max` |
339
396
  | `--timeout-ms` | the whole run, checks and repairs included. Default: 10 min for run, 2 h for task |
340
397
  | `--session` | run: continue by zcode-agent id or engine `sess_` id |
341
398
  | `--profile` | agent: the subagent profile. Default: `general-purpose` |
@@ -0,0 +1,11 @@
1
+ # zcode-agent (ACP)
2
+
3
+ You are the coding agent behind an editor or app that speaks the Agent Client Protocol (T3 Code, Zed, …). A person reads your messages and may be asked to approve your tool calls.
4
+
5
+ - When you need a decision only the person can make, ask it plainly at the end of your reply and stop; their next message is the answer. Otherwise act on sensible defaults and say which you chose.
6
+ - Use TodoWrite for multi-step work: the client shows your list as the plan.
7
+ - Commands must not block on input: pass non-interactive flags (`--yes`, `CI=1`, `--no-open`); no editors, pagers or watch modes. Run servers in the background and stop them when done.
8
+ - Bind `$ZCODE_PORT` for a server you start unless the person names a port. Scratch files go under `$ZCODE_TMP`.
9
+ - Don't commit, push, publish, deploy or install global packages unless asked.
10
+ - Images the person attaches are saved as files and named in their message: open them with the Read tool.
11
+ - Drive browsers only through the Playwright MCP tools.
@@ -0,0 +1,11 @@
1
+ #!/usr/bin/env node
2
+ 'use strict';
3
+ // `zcode-agent-acp [options]` = `zcode-agent acp [options]`, for ACP clients
4
+ // whose settings take only an executable (T3 Code's provider form).
5
+ const { main } = require('./zcode-agent.js');
6
+
7
+ process.argv.splice(2, 0, 'acp');
8
+ main().catch((err) => {
9
+ process.stderr.write(`zcode-agent: internal error: ${err && err.stack ? err.stack : err}\n`);
10
+ process.exit(1);
11
+ });
@@ -2,7 +2,7 @@
2
2
  'use strict';
3
3
  // zcode — CLI entry: argv parsing + command dispatch. Parsing rejects bad
4
4
  // input (exit 2) before any engine spawn or session record exists.
5
- const { normalizeModel, unknownModelMessage, normalizeEffort, EFFORT_LEVELS, DEFAULT_MODEL } = require('../lib/models.js');
5
+ const { normalizeModel, unknownModelMessage, normalizeEffort, EFFORT_LEVELS, DEFAULT_MODEL, DEFAULT_EFFORT } = require('../lib/models.js');
6
6
 
7
7
  const USAGE = `usage:
8
8
  zcode-agent task [options] <objective…> execute a task contract, verify it, hand back
@@ -30,6 +30,9 @@ const USAGE = `usage:
30
30
  engine, key, inherited setup and browser report
31
31
  zcode-agent skills [install|uninstall] [claude|codex]
32
32
  install the orchestrator skills (default: status)
33
+ zcode-agent acp [--mode m] [--model id] [--effort l]
34
+ serve the Agent Client Protocol on stdio (T3 Code,
35
+ Zed, any ACP client; see "acp" below)
33
36
 
34
37
  session:
35
38
  --id <id> name the session (letters, digits, . _ -); default zc-<random>.
@@ -83,11 +86,19 @@ plan (zcode-agent plan run <plan.json>):
83
86
  --id <name> plan name (default: the file's basename)
84
87
  --session <id> plan resume: only this session
85
88
 
89
+ acp (zcode-agent acp):
90
+ --mode <mode> default permission mode of new sessions: build (ask before
91
+ edits and commands) | edit (accept edits) | plan | yolo
92
+ (full access). default: build; clients switch it per session
93
+ --timeout-ms <n> per prompt (default: none)
94
+ also: --model, --effort, --mcp, --hermetic, --no-browser,
95
+ --skills, --no-skills, --inherit-desktop
96
+
86
97
  execution:
87
- --model <id> glm-5.3 | glm-5.3-flash (+aliases). default: glm-5.3-flash
98
+ --model <id> glm-5.3 | glm-5.3-flash (+aliases). default: glm-5.3
88
99
  --effort <level> low | high | max for both models (zcode-agent doctor lists the
89
100
  engine's levels per model); an unsupported level exits 2
90
- before any spawn. default: max
101
+ before any spawn. default: high
91
102
  --timeout-ms <n> whole invocation incl. checks/repairs (default 600000;
92
103
  task default 7200000 = 2 h)
93
104
  --profile <name> subagent profile (agent command; default general-purpose)
@@ -154,7 +165,9 @@ function parseMcpSpec(value) {
154
165
  return parsed;
155
166
  }
156
167
 
157
- const COMMANDS = new Set(['run', 'task', 'agent', 'resume', 'status', 'list', 'wait', 'watch', 'cost', 'cancel', 'login', 'doctor', 'skills', 'result', 'plan', '__plan', '__exec']);
168
+ const COMMANDS = new Set(['run', 'task', 'agent', 'resume', 'status', 'list', 'wait', 'watch', 'cost', 'cancel', 'login', 'doctor', 'skills', 'result', 'plan', 'acp', '__plan', '__exec']);
169
+ // The flags `zcode-agent acp` accepts (session defaults for the ACP agent).
170
+ const ACP_FLAGS = new Set(['model', 'effort', 'mode', 'timeoutMs', 'mcpSpecs', 'mcpInherit', 'hermetic', 'noBrowser', 'skillsDirs', 'noSkills', 'inheritDesktop']);
158
171
  const TASK_ONLY = new Set(['task', 'accept', 'check', 'file', 'context', 'touch', 'maxRepairs', 'checkTimeoutMs', 'decisions', 'units', 'visual', 'viewports', 'serve', 'preflight']);
159
172
  const FULL_COMMANDS = new Set(['run', 'task', 'agent', 'resume', 'wait', 'result', '__exec']);
160
173
  const START_ONLY = new Set(['id', 'label', 'owns', 'touch', 'preflight', 'allowOverlap', 'mcpSpecs', 'mcpInherit', 'hermetic', 'noBrowser', 'skillsDirs', 'noSkills', 'inheritDesktop', 'profile', 'cwd']);
@@ -166,7 +179,7 @@ function parseArgv(argv) {
166
179
  given: new Set(),
167
180
  flags: {
168
181
  model: DEFAULT_MODEL,
169
- effort: 'max',
182
+ effort: DEFAULT_EFFORT,
170
183
  cwd: process.cwd(),
171
184
  json: false,
172
185
  fresh: false,
@@ -212,6 +225,7 @@ function parseArgv(argv) {
212
225
  all: false,
213
226
  app: false,
214
227
  installBrowser: false,
228
+ mode: undefined,
215
229
  },
216
230
  };
217
231
  const valueFlags = new Map([
@@ -219,6 +233,7 @@ function parseArgv(argv) {
219
233
  ['--timeout-ms', 'timeoutMs'], ['-p', 'prompt'], ['--prompt', 'prompt'], ['--session', 'session'],
220
234
  ['--id', 'id'], ['--label', 'label'], ['--task', 'task'], ['--max-repairs', 'maxRepairs'],
221
235
  ['--check-timeout-ms', 'checkTimeoutMs'], ['--serve', 'serve'], ['--plan', 'plan'], ['--stall-min', 'stallMin'],
236
+ ['--mode', 'mode'],
222
237
  ]);
223
238
  const listFlags = new Map([
224
239
  ['--mcp', 'mcpSpecs'], ['--skills', 'skillsDirs'], ['--accept', 'accept'], ['--check', 'check'],
@@ -313,6 +328,13 @@ function parseArgv(argv) {
313
328
  if (out.given.has(key)) fail(2, `--${flagName(key)} cannot change on resume; it is fixed when the session starts.`);
314
329
  }
315
330
  }
331
+ if (cmd === 'acp') {
332
+ for (const key of out.given) {
333
+ if (!ACP_FLAGS.has(key)) fail(2, `--${flagName(key)} is not valid with "zcode-agent acp".`);
334
+ }
335
+ } else if (out.given.has('mode')) {
336
+ fail(2, '--mode is only valid with "zcode-agent acp".');
337
+ }
316
338
  if (out.given.has('all') && cmd !== 'status') fail(2, '--all is only valid with "zcode-agent status".');
317
339
  for (const k of ['plan', 'stallMin']) {
318
340
  if (out.given.has(k) && cmd !== 'watch') fail(2, `--${flagName(k)} is only valid with "zcode-agent watch".`);
@@ -401,13 +423,15 @@ async function main() {
401
423
  return require('../lib/commands/doctor.js')(parsed);
402
424
  case 'skills':
403
425
  return require('../lib/commands/skills.js')(parsed);
426
+ case 'acp':
427
+ return require('../lib/commands/acp.js')(parsed);
404
428
  default:
405
429
  return fail(2, `unknown command "${parsed.command}" (see zcode-agent --help).`);
406
430
  }
407
431
  }
408
432
 
409
433
  // Exported before main() runs: the plan supervisor reuses parseArgv.
410
- module.exports = { parseArgv, USAGE };
434
+ module.exports = { parseArgv, USAGE, main };
411
435
 
412
436
  if (require.main === module) {
413
437
  main().catch((err) => {