zcode-agent 0.0.0-stage → 1.0.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/lib/help.js ADDED
@@ -0,0 +1,128 @@
1
+ 'use strict';
2
+ // Per-command help: `zcode <command> --help` prints the command's usage and
3
+ // only the flags that apply to it (each text <= 2000 bytes). The full text
4
+ // (bin/zcode-agent.js USAGE) is for `zcode --help` with no command.
5
+ const SESSION = ` --id <id> name the session (existing id is never re-run: use resume)
6
+ --label <text> free-form label shown in status
7
+ --detach start in the background, print the id, exit 0
8
+ --cwd <dir> workspace (default: current dir)
9
+ --owns <path> repeatable: paths this session may change (default: whole workspace)
10
+ --allow-overlap start despite overlapping ownership`;
11
+ const EXEC = ` --model <id> glm-5.3 | glm-5.3-flash (default glm-5.3-flash)
12
+ --effort <lvl> low | high | max (default max)
13
+ --mcp <json|@f> add MCP servers (repeatable) --mcp-inherit --no-browser
14
+ --skills <dir> add skills (repeatable) --no-skills
15
+ --inherit-desktop give the executor the desktop's AGENTS.md, skills, plugins
16
+ --json NDJSON events; last line is the compact brief (--full: whole record)
17
+ --quiet no progress feed; with --json only the result line`;
18
+
19
+ const HELP = {
20
+ task: `usage: zcode-agent task [options] <objective...>
21
+ Execute a task contract, verify it with zcode-run checks, hand back.
22
+
23
+ contract:
24
+ --task <file|-> JSON contract or markdown brief (- = stdin)
25
+ --accept <text> repeatable acceptance criterion
26
+ --check <command> repeatable shell check zcode-agent runs after the work
27
+ --file <path> repeatable file to read first
28
+ --context <text|@f> repeatable context --decision <text> / --decisions <@f>
29
+ --touch <path> repeatable minimal edits allowed outside --owns
30
+ --unit "n: goal [owns a,b]" repeatable subagent unit
31
+ --visual <criterion> repeatable --viewport <WxH> --serve <cmd>
32
+ --preflight read-only: list open questions, no edits
33
+ --max-repairs <n> default 2 --check-timeout-ms <n> default 300000
34
+ session:
35
+ ${SESSION}
36
+ --timeout-ms <n> whole invocation (default 7200000 = 2 h)
37
+ ${EXEC}
38
+ Full reference: zcode-agent --help`,
39
+ run: `usage: zcode-agent [run] [options] <prompt...>
40
+ One-shot turn (prompt via stdin when piped).
41
+ --session <id> continue a session
42
+ --timeout-ms <n> default 600000
43
+ --thinking | --no-thinking mirror reasoning to stderr
44
+ ${SESSION}
45
+ ${EXEC}
46
+ Full reference: zcode-agent --help`,
47
+ agent: `usage: zcode-agent agent [options] <instructions...>
48
+ Turn that MUST dispatch a subagent.
49
+ --profile <name> subagent profile (default general-purpose)
50
+ --timeout-ms <n> default 600000
51
+ ${SESSION}
52
+ ${EXEC}
53
+ Full reference: zcode-agent --help`,
54
+ resume: `usage: zcode-agent resume <id> [message...]
55
+ Continue a session: answer questions, follow up, or retry after a timeout.
56
+ Pass "-" as the message to read it from stdin.
57
+ --timeout-ms <n> --max-repairs <n> --check-timeout-ms <n>
58
+ --model <id> --effort <lvl>
59
+ --json --full --quiet --include-reasoning
60
+ Start-time flags (--id, --owns, --cwd, ...) cannot change on resume.`,
61
+ status: `usage: zcode-agent status [<id>] [--all] [--json]
62
+ One session in detail, or the 15 most recent (--all: every session).
63
+ --json machine-readable list or detail`,
64
+ wait: `usage: zcode-agent wait <id...> [--any] [--json] [--full] [--timeout-ms n]
65
+ Block until sessions finish; print each handback.
66
+ --any return when the FIRST id finishes
67
+ --timeout-ms <n> one line per pending session, exit 124
68
+ --json briefs --full full records`,
69
+ watch: `usage: zcode-agent watch [<id>… | --plan <name>] [--stall-min n]
70
+ Live view of sessions, no model tokens. One line each:
71
+ id state phase[ n/m] elapsed last: <tool> <age> ago req <n> sub <running> $cost
72
+ "thinking 12m 40k chars" / "writing …" appears while one model request streams.
73
+ cost: every GLM request so far (implementer, subagents, verifier) at Z.ai API
74
+ list price, from the engine's own ledger; with several sessions a total line
75
+ follows. STALLED? is appended when a running session has had no engine event for
76
+ --stall-min minutes (default 8). Nothing is done automatically.
77
+ <id…> the sessions to watch
78
+ --plan name every session of a plan
79
+ (no args) live sessions and those finished in the last 10 minutes
80
+ TTY: redraws every 2 s. Piped: a line is printed only when a session changes.
81
+ Exits 0 when every watched session has finished; Ctrl-C exits 0.`,
82
+ cost: `usage: zcode-agent cost [<dir>] [--app] [--json]
83
+ GLM cost of every zcode-agent session whose workspace is <dir> or below it (default:
84
+ the current directory), per session and in total, at Z.ai API list price
85
+ (USD per M tokens: GLM-5.3-Flash 0.15 input / 0.03 cached / 0.50 output;
86
+ GLM-5.3 1.40 / 0.26 / 4.40). Counts come from each session's engine DB:
87
+ every request of the implementer, its subagents and the visual verifier,
88
+ across resumes. ~ marks an estimate (no cache split).
89
+ --app also the desktop app's own sessions in that directory
90
+ --json {type:"cost", dir, total, sessions[, app]}
91
+ ZCODE_PRICES='{"GLM-5.3-Flash":{"input":0.15,"cached":0.03,"output":0.5}}' overrides.`,
92
+ result: `usage: zcode-agent result <id> [--json] [--full]
93
+ Print a finished session's handback without waiting (exit 7 if running).
94
+ --json compact brief --full the whole record`,
95
+ cancel: `usage: zcode-agent cancel <id> [--json]
96
+ Stop a running session (SIGTERM, SIGKILL after 15 s). No-op when finished.`,
97
+ plan: `usage: zcode-agent plan <subcommand>
98
+ zcode-agent plan check <file> validate (ids, after, cycles, owns, effort)
99
+ zcode-agent plan run <file> [--preflight] [--detach] [--timeout-ms n] [--id name] [--json]
100
+ zcode-agent plan wait|status <name> [--timeout-ms n] [--json]
101
+ zcode-agent plan resume <name> [message...] [--session <id>]
102
+ plan file: {cwd?, decisions?, context?, files?, model?, effort?, limits?,
103
+ sessions:[{id, after?:[ids], label?, ...task contract keys}]}
104
+ top-level decisions/context/files are prepended to every session; limits
105
+ ({timeoutMs,maxRepairs,checkTimeoutMs}) default every session; "@file"
106
+ resolves next to the plan file, then against its cwd.
107
+ --preflight read-only preflight of every session (sessions with "after"
108
+ are told to assume their prerequisites)
109
+ --detach supervise in a background process
110
+ --id <name> plan name (default: file basename)
111
+ --cwd <dir> workspace override
112
+ Exit: 0 completed, 10 blocked, 8 partial/failed, 124 timeout.`,
113
+ login: `usage: printf %s "$ZAI_API_KEY" | zcode-agent login
114
+ Store a Z.ai API key (read from piped stdin, never echoed) in ~/.zcode-agent.
115
+ Not needed when ZAI_API_KEY is set or the ZCode app holds a key.`,
116
+ doctor: `usage: zcode-agent doctor [--json] [--install-browser]
117
+ Engine, key, inherited MCP servers and skills, and browser report.
118
+ --install-browser installs the Chromium build the default Playwright server
119
+ drives (needed only without the ZCode app's own Playwright server).`,
120
+ skills: `usage: zcode-agent skills [install|uninstall] [claude|codex]
121
+ Install the orchestrator skills (default: show status).`,
122
+ };
123
+
124
+ function commandHelp(command) {
125
+ return HELP[command] || null;
126
+ }
127
+
128
+ module.exports = { commandHelp };