zcode-app-cli 3.3.5-1

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.
Files changed (169) hide show
  1. package/LICENSE +24 -0
  2. package/README.md +642 -0
  3. package/bin/zcode.js +848 -0
  4. package/config.example.json +110 -0
  5. package/package.json +81 -0
  6. package/vendor/.node-bundle-meta.json +6 -0
  7. package/vendor/extraction.json +11 -0
  8. package/vendor/node_modules/@zcode/tui/dist/index.js +161875 -0
  9. package/vendor/node_modules/@zcode/tui/package.json +14 -0
  10. package/vendor/packages/android-emulator-plugin/.mcp.json +19 -0
  11. package/vendor/packages/android-emulator-plugin/.zcode-plugin/plugin.json +63 -0
  12. package/vendor/packages/android-emulator-plugin/README.md +134 -0
  13. package/vendor/packages/android-emulator-plugin/commands/android-dev.md +11 -0
  14. package/vendor/packages/android-emulator-plugin/dist/lib/path.d.ts +4 -0
  15. package/vendor/packages/android-emulator-plugin/dist/lib/path.js +17 -0
  16. package/vendor/packages/android-emulator-plugin/dist/lib/result.d.ts +5 -0
  17. package/vendor/packages/android-emulator-plugin/dist/lib/result.js +22 -0
  18. package/vendor/packages/android-emulator-plugin/dist/lib/run.d.ts +18 -0
  19. package/vendor/packages/android-emulator-plugin/dist/lib/run.js +99 -0
  20. package/vendor/packages/android-emulator-plugin/dist/mcp/server.d.ts +3 -0
  21. package/vendor/packages/android-emulator-plugin/dist/mcp/server.js +47607 -0
  22. package/vendor/packages/android-emulator-plugin/dist/providers/app.d.ts +39 -0
  23. package/vendor/packages/android-emulator-plugin/dist/providers/app.js +50 -0
  24. package/vendor/packages/android-emulator-plugin/dist/providers/avd.d.ts +37 -0
  25. package/vendor/packages/android-emulator-plugin/dist/providers/avd.js +185 -0
  26. package/vendor/packages/android-emulator-plugin/dist/providers/build.d.ts +68 -0
  27. package/vendor/packages/android-emulator-plugin/dist/providers/build.js +131 -0
  28. package/vendor/packages/android-emulator-plugin/dist/providers/config.d.ts +7 -0
  29. package/vendor/packages/android-emulator-plugin/dist/providers/config.js +29 -0
  30. package/vendor/packages/android-emulator-plugin/dist/providers/device.d.ts +20 -0
  31. package/vendor/packages/android-emulator-plugin/dist/providers/device.js +91 -0
  32. package/vendor/packages/android-emulator-plugin/dist/providers/logs.d.ts +15 -0
  33. package/vendor/packages/android-emulator-plugin/dist/providers/logs.js +31 -0
  34. package/vendor/packages/android-emulator-plugin/dist/providers/preflight.d.ts +15 -0
  35. package/vendor/packages/android-emulator-plugin/dist/providers/preflight.js +123 -0
  36. package/vendor/packages/android-emulator-plugin/dist/providers/project-template.d.ts +13 -0
  37. package/vendor/packages/android-emulator-plugin/dist/providers/project-template.js +211 -0
  38. package/vendor/packages/android-emulator-plugin/dist/providers/project.d.ts +33 -0
  39. package/vendor/packages/android-emulator-plugin/dist/providers/project.js +195 -0
  40. package/vendor/packages/android-emulator-plugin/dist/providers/screenshot.d.ts +14 -0
  41. package/vendor/packages/android-emulator-plugin/dist/providers/screenshot.js +73 -0
  42. package/vendor/packages/android-emulator-plugin/dist/providers/sdk.d.ts +14 -0
  43. package/vendor/packages/android-emulator-plugin/dist/providers/sdk.js +185 -0
  44. package/vendor/packages/android-emulator-plugin/dist/providers/ui.d.ts +92 -0
  45. package/vendor/packages/android-emulator-plugin/dist/providers/ui.js +146 -0
  46. package/vendor/packages/android-emulator-plugin/hooks/hooks.json +3 -0
  47. package/vendor/packages/android-emulator-plugin/package.json +35 -0
  48. package/vendor/packages/android-emulator-plugin/skills/android-dev/INSTALL_ENVIRONMENT.md +357 -0
  49. package/vendor/packages/android-emulator-plugin/skills/android-dev/SKILL.md +73 -0
  50. package/vendor/packages/android-emulator-plugin/templates/compose-app/README.md +5 -0
  51. package/vendor/packages/document-skills-plugin/.zcode-plugin/plugin.json +8 -0
  52. package/vendor/packages/document-skills-plugin/package.json +8 -0
  53. package/vendor/packages/document-skills-plugin/skills/docx/LICENSE.txt +13 -0
  54. package/vendor/packages/document-skills-plugin/skills/docx/SKILL.md +201 -0
  55. package/vendor/packages/document-skills-plugin/skills/docx/references/chart-templates.md +386 -0
  56. package/vendor/packages/document-skills-plugin/skills/docx/references/common-rules.md +419 -0
  57. package/vendor/packages/document-skills-plugin/skills/docx/references/decorations.md +537 -0
  58. package/vendor/packages/document-skills-plugin/skills/docx/references/design-system.md +1797 -0
  59. package/vendor/packages/document-skills-plugin/skills/docx/references/docx-js-advanced.md +257 -0
  60. package/vendor/packages/document-skills-plugin/skills/docx/references/docx-js-core.md +332 -0
  61. package/vendor/packages/document-skills-plugin/skills/docx/references/faq.md +323 -0
  62. package/vendor/packages/document-skills-plugin/skills/docx/references/math-formulas.md +276 -0
  63. package/vendor/packages/document-skills-plugin/skills/docx/references/ooxml.md +222 -0
  64. package/vendor/packages/document-skills-plugin/skills/docx/references/toc.md +264 -0
  65. package/vendor/packages/document-skills-plugin/skills/docx/routes/comment.md +88 -0
  66. package/vendor/packages/document-skills-plugin/skills/docx/routes/create.md +207 -0
  67. package/vendor/packages/document-skills-plugin/skills/docx/routes/edit.md +115 -0
  68. package/vendor/packages/document-skills-plugin/skills/docx/routes/format.md +120 -0
  69. package/vendor/packages/document-skills-plugin/skills/docx/routes/read.md +114 -0
  70. package/vendor/packages/document-skills-plugin/skills/docx/scenes/academic.md +783 -0
  71. package/vendor/packages/document-skills-plugin/skills/docx/scenes/contract.md +463 -0
  72. package/vendor/packages/document-skills-plugin/skills/docx/scenes/copywriting.md +139 -0
  73. package/vendor/packages/document-skills-plugin/skills/docx/scenes/exam.md +698 -0
  74. package/vendor/packages/document-skills-plugin/skills/docx/scenes/official-doc.md +411 -0
  75. package/vendor/packages/document-skills-plugin/skills/docx/scenes/report.md +340 -0
  76. package/vendor/packages/document-skills-plugin/skills/docx/scenes/resume.md +534 -0
  77. package/vendor/packages/document-skills-plugin/skills/docx/scripts/__init__.py +1 -0
  78. package/vendor/packages/document-skills-plugin/skills/docx/scripts/add_toc_placeholders.py +749 -0
  79. package/vendor/packages/document-skills-plugin/skills/docx/scripts/document.py +1333 -0
  80. package/vendor/packages/document-skills-plugin/skills/docx/scripts/postcheck.py +807 -0
  81. package/vendor/packages/document-skills-plugin/skills/docx/scripts/templates/comments.xml +3 -0
  82. package/vendor/packages/document-skills-plugin/skills/docx/scripts/templates/commentsExtended.xml +3 -0
  83. package/vendor/packages/document-skills-plugin/skills/docx/scripts/templates/commentsExtensible.xml +3 -0
  84. package/vendor/packages/document-skills-plugin/skills/docx/scripts/templates/commentsIds.xml +3 -0
  85. package/vendor/packages/document-skills-plugin/skills/docx/scripts/templates/people.xml +3 -0
  86. package/vendor/packages/document-skills-plugin/skills/docx/scripts/utilities.py +374 -0
  87. package/vendor/packages/document-skills-plugin/skills/docx/setup.sh +177 -0
  88. package/vendor/packages/document-skills-plugin/skills/pdf/LICENSE.txt +13 -0
  89. package/vendor/packages/document-skills-plugin/skills/pdf/SKILL.md +919 -0
  90. package/vendor/packages/document-skills-plugin/skills/pdf/briefs/academic.md +1058 -0
  91. package/vendor/packages/document-skills-plugin/skills/pdf/briefs/creative.md +770 -0
  92. package/vendor/packages/document-skills-plugin/skills/pdf/briefs/poster.md +702 -0
  93. package/vendor/packages/document-skills-plugin/skills/pdf/briefs/process-advanced.md +284 -0
  94. package/vendor/packages/document-skills-plugin/skills/pdf/briefs/process.md +319 -0
  95. package/vendor/packages/document-skills-plugin/skills/pdf/briefs/report.md +1659 -0
  96. package/vendor/packages/document-skills-plugin/skills/pdf/configs/components.md +153 -0
  97. package/vendor/packages/document-skills-plugin/skills/pdf/configs/fonts.md +93 -0
  98. package/vendor/packages/document-skills-plugin/skills/pdf/configs/visual_framework.md +263 -0
  99. package/vendor/packages/document-skills-plugin/skills/pdf/references/resume-academic.tex +130 -0
  100. package/vendor/packages/document-skills-plugin/skills/pdf/references/resume-altacv.tex +190 -0
  101. package/vendor/packages/document-skills-plugin/skills/pdf/scripts/cover_validate.js +367 -0
  102. package/vendor/packages/document-skills-plugin/skills/pdf/scripts/design_engine.py +2816 -0
  103. package/vendor/packages/document-skills-plugin/skills/pdf/scripts/html2pdf-next.js +754 -0
  104. package/vendor/packages/document-skills-plugin/skills/pdf/scripts/html2poster.js +256 -0
  105. package/vendor/packages/document-skills-plugin/skills/pdf/scripts/pdf.py +2959 -0
  106. package/vendor/packages/document-skills-plugin/skills/pdf/scripts/pdf_qa.py +901 -0
  107. package/vendor/packages/document-skills-plugin/skills/pdf/scripts/poster_validate.py +1337 -0
  108. package/vendor/packages/document-skills-plugin/skills/pdf/scripts/setup.sh +269 -0
  109. package/vendor/packages/document-skills-plugin/skills/pdf/scripts/toc_validate.py +2075 -0
  110. package/vendor/packages/document-skills-plugin/skills/pdf/typesetting/charts.md +320 -0
  111. package/vendor/packages/document-skills-plugin/skills/pdf/typesetting/cover-backgrounds.md +384 -0
  112. package/vendor/packages/document-skills-plugin/skills/pdf/typesetting/cover.md +1442 -0
  113. package/vendor/packages/document-skills-plugin/skills/pdf/typesetting/fill-engine.md +527 -0
  114. package/vendor/packages/document-skills-plugin/skills/pdf/typesetting/geometry.md +142 -0
  115. package/vendor/packages/document-skills-plugin/skills/pdf/typesetting/overflow.md +630 -0
  116. package/vendor/packages/document-skills-plugin/skills/pdf/typesetting/pagination.md +367 -0
  117. package/vendor/packages/document-skills-plugin/skills/pdf/typesetting/palette.md +217 -0
  118. package/vendor/packages/document-skills-plugin/skills/pdf/typesetting/typography.md +20 -0
  119. package/vendor/packages/ios-simulator-plugin/.mcp.json +15 -0
  120. package/vendor/packages/ios-simulator-plugin/.zcode-plugin/plugin.json +34 -0
  121. package/vendor/packages/ios-simulator-plugin/README.md +111 -0
  122. package/vendor/packages/ios-simulator-plugin/commands/ios-dev.md +11 -0
  123. package/vendor/packages/ios-simulator-plugin/dist/lib/path.d.ts +4 -0
  124. package/vendor/packages/ios-simulator-plugin/dist/lib/path.js +18 -0
  125. package/vendor/packages/ios-simulator-plugin/dist/lib/result.d.ts +5 -0
  126. package/vendor/packages/ios-simulator-plugin/dist/lib/result.js +20 -0
  127. package/vendor/packages/ios-simulator-plugin/dist/lib/run.d.ts +17 -0
  128. package/vendor/packages/ios-simulator-plugin/dist/lib/run.js +83 -0
  129. package/vendor/packages/ios-simulator-plugin/dist/mcp/server.d.ts +3 -0
  130. package/vendor/packages/ios-simulator-plugin/dist/mcp/server.js +46833 -0
  131. package/vendor/packages/ios-simulator-plugin/dist/providers/build.d.ts +112 -0
  132. package/vendor/packages/ios-simulator-plugin/dist/providers/build.js +99 -0
  133. package/vendor/packages/ios-simulator-plugin/dist/providers/logs.d.ts +21 -0
  134. package/vendor/packages/ios-simulator-plugin/dist/providers/logs.js +26 -0
  135. package/vendor/packages/ios-simulator-plugin/dist/providers/preflight.d.ts +12 -0
  136. package/vendor/packages/ios-simulator-plugin/dist/providers/preflight.js +62 -0
  137. package/vendor/packages/ios-simulator-plugin/dist/providers/project.d.ts +35 -0
  138. package/vendor/packages/ios-simulator-plugin/dist/providers/project.js +288 -0
  139. package/vendor/packages/ios-simulator-plugin/dist/providers/screenshot.d.ts +22 -0
  140. package/vendor/packages/ios-simulator-plugin/dist/providers/screenshot.js +30 -0
  141. package/vendor/packages/ios-simulator-plugin/dist/providers/sim.d.ts +60 -0
  142. package/vendor/packages/ios-simulator-plugin/dist/providers/sim.js +116 -0
  143. package/vendor/packages/ios-simulator-plugin/dist/providers/ui.d.ts +57 -0
  144. package/vendor/packages/ios-simulator-plugin/dist/providers/ui.js +67 -0
  145. package/vendor/packages/ios-simulator-plugin/hooks/hooks.json +3 -0
  146. package/vendor/packages/ios-simulator-plugin/package.json +35 -0
  147. package/vendor/packages/ios-simulator-plugin/skills/ios-dev/SKILL.md +45 -0
  148. package/vendor/packages/ios-simulator-plugin/templates/swiftui-app/README.md +5 -0
  149. package/vendor/packages/restore-legacy-sessions-plugin/.zcode-plugin/plugin.json +9 -0
  150. package/vendor/packages/restore-legacy-sessions-plugin/README.md +35 -0
  151. package/vendor/packages/restore-legacy-sessions-plugin/commands/restore-legacy-sessions.md +11 -0
  152. package/vendor/packages/restore-legacy-sessions-plugin/package.json +8 -0
  153. package/vendor/packages/restore-legacy-sessions-plugin/skills/restore-legacy-sessions/SKILL.md +92 -0
  154. package/vendor/packages/restore-legacy-sessions-plugin/skills/restore-legacy-sessions/scripts/restore-conversation.mjs +648 -0
  155. package/vendor/packages/restore-legacy-sessions-plugin/skills/restore-legacy-sessions/scripts/scan-legacy-sessions.mjs +422 -0
  156. package/vendor/packages/skill-creator-plugin/.zcode-plugin/plugin.json +8 -0
  157. package/vendor/packages/skill-creator-plugin/package.json +8 -0
  158. package/vendor/packages/skill-creator-plugin/skills/skill-creator/SKILL.md +159 -0
  159. package/vendor/packages/zcode-guide-plugin/.zcode-plugin/plugin.json +8 -0
  160. package/vendor/packages/zcode-guide-plugin/README.md +22 -0
  161. package/vendor/packages/zcode-guide-plugin/package.json +8 -0
  162. package/vendor/packages/zcode-guide-plugin/skills/diagnosing-commands/SKILL.md +66 -0
  163. package/vendor/packages/zcode-guide-plugin/skills/diagnosing-hooks/SKILL.md +66 -0
  164. package/vendor/packages/zcode-guide-plugin/skills/diagnosing-mcp/SKILL.md +97 -0
  165. package/vendor/packages/zcode-guide-plugin/skills/diagnosing-plugins/SKILL.md +59 -0
  166. package/vendor/packages/zcode-guide-plugin/skills/diagnosing-skills/SKILL.md +61 -0
  167. package/vendor/packages/zcode-guide-plugin/skills/zcode-configuration-guide/SKILL.md +99 -0
  168. package/vendor/zcode.cjs +2926 -0
  169. package/zcode-runtime.lock.json +8 -0
package/LICENSE ADDED
@@ -0,0 +1,24 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 zcode-app-cli contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
22
+
23
+ This license covers this repository's original wrapper and automation code.
24
+ It does not grant rights to ZCode or any extracted upstream runtime.
package/README.md ADDED
@@ -0,0 +1,642 @@
1
+ # zcode-app-cli
2
+
3
+ Unofficial terminal client for the official agent runtime shipped with ZCode Desktop.
4
+
5
+ The project extracts the upstream `resources/glm` runtime, injects a local
6
+ `@zcode/tui` implementation based on
7
+ [`@earendil-works/pi-tui`](https://github.com/earendil-works/pi/tree/main/packages/tui),
8
+ and starts it through the native [`zigpty`](https://github.com/pithings/zigpty)
9
+ PTY binding for Node.js.
10
+
11
+ This project is not affiliated with or endorsed by Z.ai. ZCode and its bundled
12
+ runtime remain subject to their upstream terms. Confirm that you are allowed to
13
+ redistribute the extracted runtime before publishing the npm package.
14
+
15
+ ## Install and update
16
+
17
+ Install or update the CLI through the `latest` dist-tag:
18
+
19
+ ```bash
20
+ npm install -g zcode-app-cli@latest
21
+ # or
22
+ bun add -g zcode-app-cli@latest
23
+ ```
24
+
25
+ Using `@latest` is intentional because the App-aligned release format uses a
26
+ SemVer prerelease segment such as `3.3.5-2`. The tag always points to the
27
+ newest validated App-plus-build release.
28
+
29
+ A normal installation requires only Node.js. `zigpty` ships small prebuilt
30
+ native bindings for each supported platform, with no compiler or postinstall
31
+ step required.
32
+
33
+ ## Architecture
34
+
35
+ ```text
36
+ Node.js npm launcher
37
+ └─ zigpty (PTY / resize / input forwarding)
38
+ └─ Node.js
39
+ └─ official zcode.cjs agent runtime
40
+ └─ local @zcode/tui adapter
41
+ └─ @earendil-works/pi-tui
42
+ ```
43
+
44
+ The official agent, model, session, tool, plugin, MCP, credential store and
45
+ provider-configuration logic remains in the extracted runtime. The local
46
+ package supplies the missing terminal interface and a narrow macOS callback
47
+ bridge for Z.AI's registered Desktop OAuth flow.
48
+
49
+ Node.js starts the public npm command and remains the compatibility host for the
50
+ extracted upstream kernel. `zigpty` owns the native terminal while the official
51
+ runtime stays in a separate PTY child process. Synchronization adds the local
52
+ TUI/data bridge, OAuth compatibility handoff and clearer HTTP diagnostics. OAuth
53
+ callbacks are passed to the official runtime over stdin; its encrypted credential
54
+ store, Coding Plan key resolver and config writer remain the only persistence
55
+ path.
56
+
57
+ ## Current TUI functionality
58
+
59
+ - pi-tui differential rendering and CJK-aware multi-line editor;
60
+ - streamed assistant text from official ZCode session events;
61
+ - slash-command and workspace-path completion;
62
+ - persisted prompt history through ZCode's history API;
63
+ - `/mode`, `/model`, `/resume`, `/plugins` and other upstream slash commands;
64
+ - searchable model and reasoning-effort selectors, plus MCP and workflow panels;
65
+ - status-bar-only Shift+Tab mode, Ctrl+N model, Ctrl+L autonomy and empty-prompt Tab effort cycling;
66
+ - structured session-goal status in the right side of the turn footer;
67
+ - responsive context-remaining and session-token metrics in the status line;
68
+ - generic upstream selection dialogs for sessions, plugins and checkpoints;
69
+ - `/login` setup choices with masked API-key entry, redacted transcript/history and OAuth waiting state;
70
+ - suspended Z.AI browser login with terminal restoration and an optional `ZCODE_TUI_LOGIN_CMD` override;
71
+ - interactive tool-permission approval dialogs;
72
+ - clipboard image attachments through Ctrl+V or `/paste-image`;
73
+ - compact tool execution views with path, command, progress, result and image previews;
74
+ - parent/child Agent tool trees with resumable subagent metadata and expandable Prompt/Response details;
75
+ - syntax-highlighted Markdown code blocks with stable streaming-block rendering;
76
+ - Pierre-style inline diffs with line numbers, syntax highlighting, word-level changes and CJK wrapping;
77
+ - `/diff` browser for current Git changes and per-turn file changes, including paged details and binary/untracked states;
78
+ - terminal-native Mermaid previews with source fallback for unsupported or oversized diagrams;
79
+ - `/context` prompt-composition, cache and context-usage details;
80
+ - `/status` session, runtime, goal, MCP and workspace details;
81
+ - searchable transcript navigation with per-block expansion, selected-block copying and `n`/`N` match traversal;
82
+ - persistent active-tool, background-task and open-plan activity between the transcript and editor;
83
+ - active-turn steering, cancellation and error reporting;
84
+ - unfocused turn-completion notifications through terminal-native OSC 9 or BEL, with optional desktop commands;
85
+ - double-Esc rewind with input-point selection and safe conversation/workspace scopes;
86
+ - `/copy`, `/clear`, `/exit`, Ctrl+C and Ctrl+D handling with token usage and resume guidance on exit;
87
+ - `--no-color` and `NO_COLOR` support.
88
+
89
+ ### Referencing workspace files
90
+
91
+ Type `@` at the start of the prompt or after whitespace to open project file
92
+ completion. Continue typing a path, use Up/Down to choose a candidate, then
93
+ press Tab or Enter to insert it. Selecting a directory lets you continue with
94
+ the next path segment.
95
+
96
+ ```text
97
+ Explain @README.md
98
+ Compare @src/index.ts with @"docs/design notes.md"
99
+ ```
100
+
101
+ Suggestions come from the official ZCode runtime, stay inside the current
102
+ workspace and exclude common repository metadata and dependency directories.
103
+ Paths containing spaces are inserted in the quoted `@"..."` form.
104
+
105
+ ### Turn completion notifications
106
+
107
+ Notifications are enabled by default and emitted after a normal agent turn
108
+ completes or fails while the terminal is unfocused. Following Codex's terminal
109
+ capability fallback, `auto` uses OSC 9 in Ghostty, iTerm2, Kitty, Warp and
110
+ WezTerm, and BEL in terminals such as Apple Terminal. Selecting OSC 9 in an
111
+ unsupported terminal also falls back to BEL instead of silently emitting an
112
+ ignored sequence.
113
+
114
+ The `unfocused` condition uses DEC focus reporting when the terminal provides
115
+ it. Until focus support is confirmed, ZCode sends the notification instead of
116
+ permanently suppressing it as focused. `native` is an explicit opt-in that uses
117
+ an existing system command: `terminal-notifier` on macOS, `notify-send` on
118
+ Linux, or `SnoreToast` on Windows. These tools are not bundled, keeping the
119
+ default terminal notification path dependency-free. If the selected command is
120
+ unavailable or delivery fails, ZCode falls back to BEL. On macOS, the detected
121
+ terminal application is used as both the sender and click target. Exact tab or
122
+ pane restoration remains terminal-dependent; use the default `auto` setting so
123
+ OSC-capable terminals can preserve their native session behavior.
124
+
125
+ Open the interactive settings picker inside the TUI (both commands are
126
+ equivalent):
127
+
128
+ ```text
129
+ /config
130
+ /settings
131
+ ```
132
+
133
+ Saving a value returns to the settings root so several options can be changed
134
+ in one visit. `Esc` returns from a setting to the root, then closes the root.
135
+
136
+ The picker updates the active session immediately and persists the selected
137
+ values under `ui.notifications` in the cross-platform user `config.json`:
138
+
139
+ ```json
140
+ {
141
+ "ui": {
142
+ "notifications": {
143
+ "method": "auto",
144
+ "condition": "unfocused"
145
+ }
146
+ }
147
+ }
148
+ ```
149
+
150
+ Environment variables override `config.json` on startup and are useful for a
151
+ temporary per-shell setting:
152
+
153
+ ```bash
154
+ export ZCODE_TUI_NOTIFICATION_METHOD=auto # auto|osc9|bel|native|off
155
+ export ZCODE_TUI_NOTIFICATION_CONDITION=always # unfocused|always
156
+ node bin/zcode.js
157
+ ```
158
+
159
+ ### Conversation rewind
160
+
161
+ With an empty editor and no active turn, press `Esc` twice within 800 ms to
162
+ open the conversation rewind picker. Choose the user input to return to, review
163
+ the available workspace checkpoints, then select one of the available scopes:
164
+
165
+ - **Conversation only** removes later conversation turns, keeps workspace
166
+ files unchanged, and restores the selected input to the editor;
167
+ - **Conversation and workspace** also restores safe checkpointed file changes;
168
+ - **Workspace only** restores safe checkpointed files without changing the
169
+ conversation.
170
+
171
+ The scope picker only offers workspace restoration when the official ZCode
172
+ runtime reports a complete safe checkpoint plan. Files changed externally are
173
+ not overwritten, and Bash or terminal file mutations are reported as ignored
174
+ because they do not have restorable ZCode checkpoints. Press `Esc` in the scope
175
+ picker to return to input selection, then `Esc` again to close rewind.
176
+
177
+ ### TUI inspection and navigation
178
+
179
+ ```text
180
+ /diff browse current and per-turn file changes
181
+ /context inspect context usage and source composition
182
+ /status inspect detailed runtime and session status
183
+ /tasks inspect or stop background tasks
184
+ /search <text> search retained transcript blocks
185
+ /search next|prev|clear navigate or close transcript search
186
+ /transcript latest select the latest transcript block
187
+ /transcript next|prev|close navigate or leave transcript selection
188
+ /copy copy the selected block, or the latest response
189
+ ```
190
+
191
+ While the editor is empty, `Alt+Up` and `Alt+Down` navigate selected transcript
192
+ blocks. `Ctrl+O` expands only the selected/search-matched block; without a
193
+ selection it toggles all expandable content. During transcript search, `n` and
194
+ `N` move to the next and previous match. `PageUp` and `PageDown` page through
195
+ an oversized selected block without rendering the entire message at once.
196
+ `Esc` leaves search or transcript navigation.
197
+
198
+ ## Requirements
199
+
200
+ - Node.js 22.19 or newer;
201
+ - macOS, Linux or Windows on x64 or ARM64.
202
+
203
+ Developing or publishing from source additionally requires Bun 1.3 or newer.
204
+ `7z` is needed only when downloading and extracting a remote installer. npm
205
+ installs the approximately 422 KB `zigpty` package containing all supported
206
+ prebuilt PTY bindings.
207
+
208
+ Z.AI browser OAuth currently requires macOS because the registered provider
209
+ callback is `zcode://zai-auth/callback`; API-key and custom-provider access work
210
+ on every supported platform.
211
+
212
+ Set `ZCODE_NODE=/absolute/path/to/node` when the desired Node.js executable is
213
+ not available on `PATH`.
214
+
215
+ ## Model access and configuration
216
+
217
+ On first launch, ZCode recursively creates the configuration directory and a
218
+ credential-free `config.json` when it is missing. Existing files are never
219
+ replaced. The location is `~/.zcode/cli/config.json` on macOS and Linux, and
220
+ `%USERPROFILE%\.zcode\cli\config.json` on Windows. Newly created directories
221
+ and files use private permissions on POSIX; Windows keeps the current user's
222
+ inherited ACLs.
223
+
224
+ The generated file contains the complete non-secret configuration shape plus
225
+ valid Z.AI model metadata, but deliberately omits `apiKey` until one is
226
+ configured. This lets the official runtime and TUI start cleanly without
227
+ pretending that model access is already configured. Choose one of these
228
+ model-access paths before sending a prompt:
229
+
230
+ - Z.AI OAuth on macOS: run `zcode login` when no provider is configured, or
231
+ `zcode login --oauth` to force reauthorization;
232
+ - Z.AI/BigModel Coding Plan API key: open `/login` in the TUI and choose the
233
+ matching masked API-key option;
234
+ - direct API key with a custom provider: use the
235
+ [`config.example.json`](./config.example.json) template and do not log in.
236
+
237
+ When `model.main` already resolves to a configured provider/model with an
238
+ inline API key, plain `zcode login` exits successfully and explains that OAuth
239
+ is unnecessary. This prevents a custom provider from being replaced by an
240
+ unrelated login flow.
241
+
242
+ ### Coding Plan API key
243
+
244
+ Start the TUI and open its setup picker:
245
+
246
+ ```text
247
+ /login
248
+ ```
249
+
250
+ Choose either **Z.AI Coding Plan API Key** or **BigModel Coding Plan API Key**,
251
+ then paste the key into the masked prompt. The raw key is sent only to the
252
+ official runtime's `configureCodingPlanApiKey` implementation. The local TUI
253
+ does not add it to editor history or the visible/session transcript, and error
254
+ messages are redacted before rendering.
255
+
256
+ The same picker includes a **Custom provider** entry that points to the
257
+ configuration-template path below. Custom providers do not use OAuth.
258
+
259
+ Selecting **Z.AI Coding Plan** releases TUI raw mode and starts the registered
260
+ Desktop authorization-code flow. On macOS the CLI temporarily installs a
261
+ background-only callback receiver, verifies the returned `state`, restores the
262
+ previous `zcode://` handler, and hands the callback to the official runtime.
263
+ The authorization code travels over stdin instead of command-line arguments or
264
+ environment variables. The runtime performs token exchange, encrypted
265
+ credential persistence, Coding Plan API-key resolution and `config.json`
266
+ updates. The TUI is then restored and the model configuration is re-read.
267
+
268
+ The callback receiver is removed after success, cancellation or timeout. A
269
+ small recovery record lets the next login restore the previous handler after
270
+ an unclean process exit. The BigModel option continues to use the official
271
+ localhost-callback implementation inside the runtime.
272
+
273
+ ### Custom provider without login
274
+
275
+ Start `zcode` once to generate the full user configuration automatically. From
276
+ a source checkout, `config.example.json` contains the same initial structure
277
+ for reference. Then edit the generated file:
278
+
279
+ ```bash
280
+ zcode
281
+ ```
282
+
283
+ Edit these four areas in `~/.zcode/cli/config.json` (or the Windows path shown
284
+ above):
285
+
286
+ 1. `provider.zai.kind`: use `anthropic`, `openai-compatible`, or `openai`;
287
+ 2. `provider.zai.options.baseURL`: use the provider's API root;
288
+ 3. `provider.zai.options.apiKey`: insert the direct API key;
289
+ 4. replace the entries in `provider.zai.models`, then point both `model.main`
290
+ and `model.lite` at the desired model IDs.
291
+
292
+ The provider map key is deliberately `zai`. The upstream CLI 0.15.x TUI
293
+ considers a direct API key configured only when it is stored under provider ID
294
+ `zai` or `bigmodel`. An arbitrary provider ID is valid model configuration,
295
+ but as the only provider it still triggers the upstream login gate. The
296
+ display name, API format, endpoint, headers and models remain fully custom.
297
+
298
+ For an Anthropic-compatible endpoint:
299
+
300
+ ```json
301
+ {
302
+ "kind": "anthropic",
303
+ "options": {
304
+ "baseURL": "https://example.com/api/anthropic",
305
+ "apiKey": "YOUR_API_KEY",
306
+ "apiKeyRequired": true
307
+ }
308
+ }
309
+ ```
310
+
311
+ Use the API root, not a final `/messages` path. For an OpenAI-compatible
312
+ endpoint, set `kind` to `openai-compatible` and normally use a root ending in
313
+ `/v1`, not `/chat/completions`. For the official OpenAI API, use `openai`;
314
+ `baseURL` can be omitted.
315
+
316
+ The object keys form the runtime model reference:
317
+
318
+ ```text
319
+ provider.<provider-id>.models.<model-id>
320
+ -> <provider-id>/<model-id>
321
+ ```
322
+
323
+ Set both roles to keep all work on the custom provider:
324
+
325
+ ```json
326
+ {
327
+ "model": {
328
+ "main": "zai/your-model-id",
329
+ "lite": "zai/your-model-id"
330
+ }
331
+ }
332
+ ```
333
+
334
+ `main` is the normal conversation model. `lite` is used for lightweight and
335
+ subagent work. Model IDs are case-sensitive and must match the endpoint.
336
+
337
+ The no-login TUI path currently requires a non-empty `options.apiKey` in the
338
+ local config; an environment-only API key does not satisfy the upstream login
339
+ gate. Never commit the populated file, and keep its mode at `600`.
340
+
341
+ ### Use the custom provider
342
+
343
+ After saving the config, no login command is required. Start the client:
344
+
345
+ ```bash
346
+ node bin/zcode.js
347
+ ```
348
+
349
+ Or, after `bun link` or an npm installation:
350
+
351
+ ```bash
352
+ zcode
353
+ ```
354
+
355
+ Use these commands inside the TUI:
356
+
357
+ ```text
358
+ /model # show the active and available models
359
+ /model zai/your-model-id # switch to the custom provider explicitly
360
+ /new # start a new session with the configured default
361
+ ```
362
+
363
+ The status line should show `zai/your-model-id`. Setting both `model.main` and
364
+ `model.lite` in the config makes the custom provider the default for normal,
365
+ lightweight and subagent work. A resumed session may retain its previous model,
366
+ so use `/new` after changing the default.
367
+
368
+ Headless prompts use the same provider configuration:
369
+
370
+ ```bash
371
+ zcode --prompt "Explain this repository"
372
+ ```
373
+
374
+ `ZCODE_MODEL`, `zcode.json`, or `.zcode/config.json` can override the
375
+ user-level default. Running `/model` does not call the provider, so it is a safe
376
+ configuration check before the first prompt.
377
+
378
+ ## Local development
379
+
380
+ Install dependencies and extract the already installed macOS application:
381
+
382
+ ```bash
383
+ bun install
384
+ bun run sync:local
385
+ ```
386
+
387
+ Run all validation layers:
388
+
389
+ ```bash
390
+ bun run typecheck
391
+ bun test
392
+ bun run check
393
+ bun run check:tui
394
+ ```
395
+
396
+ `check:tui` runs two real-PTY scenarios. The official runtime scenario completes
397
+ masked Coding Plan API-key setup in a temporary home, verifies the official
398
+ config output, executes `/help`, switches to plan mode, and exits. The offline
399
+ feature scenario also covers suspended login restoration, selectors, image
400
+ attachments, nested Agent tools, Markdown, Mermaid, diffs, transcript
401
+ navigation, context/status details, MCP actions, background tasks and the
402
+ workflow panel. Both scenarios advance from observed terminal output instead
403
+ of fixed timers and do not make model API calls.
404
+
405
+ Start the client directly:
406
+
407
+ ```bash
408
+ node bin/zcode.js
409
+ ```
410
+
411
+ For the OAuth path:
412
+
413
+ ```bash
414
+ node bin/zcode.js login --oauth
415
+ node bin/zcode.js
416
+ ```
417
+
418
+ To print the authorization URL without launching the browser:
419
+
420
+ ```bash
421
+ node bin/zcode.js login --oauth --no-browser
422
+ ```
423
+
424
+ The URL must still be opened on the same Mac so its `zcode://` callback reaches
425
+ the waiting CLI. Cross-device SSH login is not supported by this provider flow;
426
+ use the masked Z.AI Coding Plan API-key option instead. The wrapper no longer
427
+ uses the upstream `oauth/cli/init` polling endpoint, which currently returns
428
+ HTTP 404.
429
+
430
+ Verify native callback capture and automatic handler restoration without
431
+ contacting Z.AI or changing the real `zcode://` association:
432
+
433
+ ```bash
434
+ bun run check:oauth-callback
435
+ ```
436
+
437
+ To hand `/login` to another interactive command, set an explicit override:
438
+
439
+ ```bash
440
+ export ZCODE_TUI_LOGIN_CMD='zcode login --oauth'
441
+ ```
442
+
443
+ The TUI then releases raw terminal mode, runs that command with inherited
444
+ stdio, restores the interface, and checks `~/.zcode/cli/config.json` again.
445
+
446
+ For the direct API-key path, follow
447
+ [Custom provider without login](#custom-provider-without-login) instead.
448
+
449
+ Install a local `zcode` command:
450
+
451
+ ```bash
452
+ bun link
453
+ zcode
454
+ ```
455
+
456
+ Headless and protocol commands bypass the PTY and preserve ordinary stdio:
457
+
458
+ ```bash
459
+ zcode --version
460
+ zcode doctor --json
461
+ zcode --prompt "Explain this repository"
462
+ zcode app-server
463
+ ```
464
+
465
+ ## Remote extraction
466
+
467
+ The same path used by CI can be run locally:
468
+
469
+ ```bash
470
+ brew install sevenzip
471
+ bun run sync -- --platform linux --arch x64
472
+ ```
473
+
474
+ Use the committed artifact instead of the latest updater manifest when
475
+ rebuilding a reviewed release:
476
+
477
+ ```bash
478
+ bun run sync:locked
479
+ ```
480
+
481
+ The synchronization command:
482
+
483
+ 1. reads the official updater manifest;
484
+ 2. downloads the matching installer;
485
+ 3. verifies its SHA-512 from the manifest;
486
+ 4. extracts `resources/glm`;
487
+ 5. builds and injects the local `@zcode/tui` adapter;
488
+ 6. validates the official CLI version;
489
+ 7. records provenance in `vendor/extraction.json`;
490
+ 8. records the remote artifact URL and SHA-512 in
491
+ `zcode-runtime.lock.json`;
492
+ 9. aligns the npm version prefix with the ZCode App version while preserving
493
+ the independently incremented CLI build revision.
494
+
495
+ ## npm package contents
496
+
497
+ The published package is controlled by the `files` allowlist in `package.json`.
498
+ It contains only:
499
+
500
+ - `bin/zcode.js`, the bundled executable Node.js launcher;
501
+ - `vendor/`, the verified official `zcode.cjs` runtime, official bundled
502
+ plugins and the compiled local `@zcode/tui` adapter;
503
+ - `config.example.json` and `zcode-runtime.lock.json`;
504
+ - `README.md`, `LICENSE` and the required npm `package.json`.
505
+
506
+ Tests, GitHub workflows, build scripts, launcher/TUI TypeScript sources, local
507
+ config, `.release/` artifacts and development `node_modules` are not published.
508
+ npm installs only the declared pi-tui and zigpty runtime dependencies. The
509
+ launcher and TUI are compiled to JavaScript with `tsdown`; its launcher banner
510
+ adds the Node.js shebang directly, with no post-build rewrite. The compiled TUI
511
+ is injected into `vendor/` before publication.
512
+
513
+ ## Automated npm publishing
514
+
515
+ Package versions use `<app-version>-<build>`, for example `3.3.5-2`. The prefix
516
+ tracks the upstream ZCode App. The globally increasing build revision tracks
517
+ fixes and features in this project. Do not use `3.3.5+build.2`: SemVer ignores
518
+ `+build` metadata when comparing upgrades.
519
+
520
+ Increment the project revision before publishing a local fix or feature:
521
+
522
+ ```bash
523
+ bun run version:build
524
+ ```
525
+
526
+ The release workflows normally perform that increment for you. The command is
527
+ also available for local inspection and exceptional manual preparation.
528
+
529
+ ### Release flow
530
+
531
+ Publishing is split into two workflows so the committed version, npm package,
532
+ Git tag and GitHub Release all describe the same release:
533
+
534
+ 1. `.github/workflows/prepare-release.yml` extracts and validates the current
535
+ official runtime, then opens or updates a Release PR containing the exact
536
+ `package.json` version and `zcode-runtime.lock.json` build input;
537
+ 2. a maintainer reviews and merges that PR;
538
+ 3. `.github/workflows/publish.yml` checks out its merge commit, rebuilds the
539
+ exact locked runtime, audits and install-tests the tarball, publishes through
540
+ npm Trusted Publishing, then creates `v<version>` and the corresponding
541
+ GitHub Release.
542
+
543
+ The generated `vendor/` directory remains ignored by Git and is rebuilt in both
544
+ workflows. Its updater URL and SHA-512 are committed in
545
+ `zcode-runtime.lock.json`. Preparation resolves the latest manifest; publishing
546
+ downloads the committed URL and verifies the locked SHA-512, so a later upstream
547
+ update cannot silently change a reviewed release.
548
+
549
+ The preparation workflow runs every day at 02:23 UTC in `upstream` mode. It
550
+ creates a PR when the ZCode App version or the pinned installer changes. A
551
+ same-version upstream repack increments the global build so npm still receives
552
+ an immutable new version. From the Actions page, run **Prepare ZCode CLI
553
+ release** with one of these modes:
554
+
555
+ - `cli` increments the global build and also aligns with the latest App;
556
+ - `upstream` checks for an App update without incrementing the build.
557
+
558
+ The modes use `release/zcode-cli` and `release/zcode-upstream` respectively. If
559
+ both PRs are open, merge one and rerun the other preparation mode so its version
560
+ is recalculated from the new `main` branch.
561
+
562
+ Merging either Release PR publishes automatically. **Publish ZCode CLI
563
+ release** can also be started manually for recovery. Its `publish` checkbox can
564
+ be disabled to run all validation and consistency checks without changing npm,
565
+ Git tags or GitHub Releases. Publication, tag creation and GitHub Release
566
+ creation are independently idempotent, so a partially completed run can be
567
+ retried safely.
568
+
569
+ ### Local release build
570
+
571
+ Local packaging uses the same commands as the publishing workflow. Start from
572
+ the exact clean commit whose version will be published:
573
+
574
+ ```bash
575
+ bun install --frozen-lockfile
576
+ bun run release:build
577
+ git diff --exit-code -- package.json zcode-runtime.lock.json
578
+ bun run release:pack
579
+ ```
580
+
581
+ `release:build` runs TypeScript checking and all tests, downloads the artifact
582
+ from `zcode-runtime.lock.json`, verifies its SHA-512, builds and injects the TUI,
583
+ then runs runtime and PTY smoke tests. `release:pack` runs the offline
584
+ `prepack` guard, creates `.release/zcode-app-cli-<version>.tgz`, audits every
585
+ included path and executable mode, installs it into a temporary directory, and
586
+ runs the installed `zcode --version`. Its final size, integrity and file count
587
+ are written to `.release/release.json`.
588
+
589
+ Inspect that manifest and then publish explicitly:
590
+
591
+ ```bash
592
+ npm login
593
+ npm publish --access public --tag latest --provenance=false
594
+ ```
595
+
596
+ The final `npm publish` intentionally remains explicit to avoid an accidental
597
+ registry mutation. It reruns the same offline `prepack` guard and fails if the
598
+ compiled TUI, runtime provenance, lock file, launcher permissions or package
599
+ allowlist are stale. `--provenance=false` applies only to this local bootstrap
600
+ path; GitHub OIDC generates provenance automatically.
601
+
602
+ Publish from the repository root as shown, rather than passing the `.tgz` to
603
+ `npm publish`: directory publication lets npm record the current Git `gitHead`,
604
+ which the recovery workflow later verifies. The tarball is the audited preview
605
+ and install-test artifact.
606
+
607
+ ### Initial npm setup
608
+
609
+ If the package does not exist on npm yet, bootstrap it once from the exact
610
+ committed `main` revision using the local release build above. If its Git diff
611
+ check fails, do not publish from that working tree; refresh the Release PR or
612
+ restore the committed version and lock first.
613
+
614
+ Synchronization preserves the build when the upstream App version changes. For
615
+ example, syncing `3.3.5-12` against ZCode App `3.4.0` produces `3.4.0-12`.
616
+
617
+ Before enabling publication:
618
+
619
+ 1. confirm that `zcode-app-cli` is the npm package name you control;
620
+ 2. confirm redistribution rights for the extracted ZCode runtime;
621
+ 3. under the GitHub repository's **Settings** → **Actions** → **General**,
622
+ enable **Allow GitHub Actions to create and approve pull requests**;
623
+ 4. open the package on npmjs.com and select **Settings** →
624
+ **Trusted Publisher** → **GitHub Actions**;
625
+ 5. enter the GitHub organization or user, repository, and workflow filename
626
+ `publish.yml`; leave the environment name empty because this
627
+ workflow does not use a GitHub Environment, and select `npm publish` under
628
+ **Allowed actions**;
629
+ 6. save the publisher, prepare a `cli` release, and merge its Release PR to
630
+ verify an OIDC publication.
631
+
632
+ The publisher runs on a GitHub-hosted runner with Node 24, grants
633
+ `id-token: write`, and updates npm to the current release. It never reads an
634
+ `NPM_TOKEN` repository secret; npm attaches provenance from the OIDC identity.
635
+ After verifying the first OIDC release, npm recommends setting **Publishing
636
+ access** to require 2FA and disallow tokens, then revoking any obsolete
637
+ automation token.
638
+
639
+ The publisher skips an identical existing version, refuses older versions,
640
+ verifies every existing npm release's `gitHead`, and refuses to reuse a tag
641
+ that points at another commit. The `latest` dist-tag therefore advances only
642
+ to the newest validated App-plus-build release.