zelari-code 0.7.9 โ†’ 0.7.11

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 (108) hide show
  1. package/LICENSE +37 -37
  2. package/README.md +320 -295
  3. package/bin/zelari-code.js +62 -62
  4. package/dist/cli/app.js +33 -3
  5. package/dist/cli/app.js.map +1 -1
  6. package/dist/cli/components/LiveRegion.js +7 -3
  7. package/dist/cli/components/LiveRegion.js.map +1 -1
  8. package/dist/cli/components/SelectList.js +67 -0
  9. package/dist/cli/components/SelectList.js.map +1 -0
  10. package/dist/cli/components/Spinner.js +51 -0
  11. package/dist/cli/components/Spinner.js.map +1 -0
  12. package/dist/cli/components/SplashScreen.js +85 -85
  13. package/dist/cli/components/StatusBar.js +42 -34
  14. package/dist/cli/components/StatusBar.js.map +1 -1
  15. package/dist/cli/headless.js +10 -10
  16. package/dist/cli/hooks/useSlashDispatch.js +11 -1
  17. package/dist/cli/hooks/useSlashDispatch.js.map +1 -1
  18. package/dist/cli/keyStore.js +2 -2
  19. package/dist/cli/keyStore.js.map +1 -1
  20. package/dist/cli/main.bundled.js +15146 -14919
  21. package/dist/cli/main.bundled.js.map +4 -4
  22. package/dist/cli/main.js +1 -1
  23. package/dist/cli/main.js.map +1 -1
  24. package/dist/cli/modelDiscovery.js +42 -5
  25. package/dist/cli/modelDiscovery.js.map +1 -1
  26. package/dist/cli/provider/openai-compatible.js +4 -2
  27. package/dist/cli/provider/openai-compatible.js.map +1 -1
  28. package/dist/cli/slashCommands.js +22 -5
  29. package/dist/cli/slashCommands.js.map +1 -1
  30. package/dist/cli/slashHandlers/provider.js +102 -5
  31. package/dist/cli/slashHandlers/provider.js.map +1 -1
  32. package/package.json +2 -2
  33. package/dist/agents/advancedTools.js +0 -115
  34. package/dist/agents/advancedTools.js.map +0 -1
  35. package/dist/agents/councilApi.js +0 -375
  36. package/dist/agents/councilApi.js.map +0 -1
  37. package/dist/agents/councilDirectives.js +0 -100
  38. package/dist/agents/councilDirectives.js.map +0 -1
  39. package/dist/agents/promoteMember.js +0 -210
  40. package/dist/agents/promoteMember.js.map +0 -1
  41. package/dist/agents/promptModules.js +0 -139
  42. package/dist/agents/promptModules.js.map +0 -1
  43. package/dist/agents/roles.js +0 -299
  44. package/dist/agents/roles.js.map +0 -1
  45. package/dist/agents/skills/builtin/debugging.js +0 -248
  46. package/dist/agents/skills/builtin/debugging.js.map +0 -1
  47. package/dist/agents/skills/builtin/docs.js +0 -301
  48. package/dist/agents/skills/builtin/docs.js.map +0 -1
  49. package/dist/agents/skills/builtin/git-ops.js +0 -301
  50. package/dist/agents/skills/builtin/git-ops.js.map +0 -1
  51. package/dist/agents/skills/builtin/planning.js +0 -335
  52. package/dist/agents/skills/builtin/planning.js.map +0 -1
  53. package/dist/agents/skills/builtin/refactoring.js +0 -261
  54. package/dist/agents/skills/builtin/refactoring.js.map +0 -1
  55. package/dist/agents/skills/builtin/review.js +0 -302
  56. package/dist/agents/skills/builtin/review.js.map +0 -1
  57. package/dist/agents/skills/builtin/testing.js +0 -245
  58. package/dist/agents/skills/builtin/testing.js.map +0 -1
  59. package/dist/agents/skills.js +0 -272
  60. package/dist/agents/skills.js.map +0 -1
  61. package/dist/agents/systemPromptBuilder.js +0 -151
  62. package/dist/agents/systemPromptBuilder.js.map +0 -1
  63. package/dist/agents/toolSchemas.js +0 -249
  64. package/dist/agents/toolSchemas.js.map +0 -1
  65. package/dist/agents/tools.js +0 -196
  66. package/dist/agents/tools.js.map +0 -1
  67. package/dist/agents/vaultTools.js +0 -134
  68. package/dist/agents/vaultTools.js.map +0 -1
  69. package/dist/cli/components/CollapsibleToolOutput.js +0 -43
  70. package/dist/cli/components/CollapsibleToolOutput.js.map +0 -1
  71. package/dist/cli/components/Header.js +0 -38
  72. package/dist/cli/components/Header.js.map +0 -1
  73. package/dist/main/core/AgentHarness.js +0 -467
  74. package/dist/main/core/AgentHarness.js.map +0 -1
  75. package/dist/main/core/providerStream.js +0 -99
  76. package/dist/main/core/providerStream.js.map +0 -1
  77. package/dist/main/core/sessionJsonl.js +0 -99
  78. package/dist/main/core/sessionJsonl.js.map +0 -1
  79. package/dist/main/core/tools/auditLog.js +0 -26
  80. package/dist/main/core/tools/auditLog.js.map +0 -1
  81. package/dist/main/core/tools/builtin/filesystem.js +0 -110
  82. package/dist/main/core/tools/builtin/filesystem.js.map +0 -1
  83. package/dist/main/core/tools/builtin/listFiles.js +0 -86
  84. package/dist/main/core/tools/builtin/listFiles.js.map +0 -1
  85. package/dist/main/core/tools/builtin/search.js +0 -56
  86. package/dist/main/core/tools/builtin/search.js.map +0 -1
  87. package/dist/main/core/tools/builtin/shell.js +0 -51
  88. package/dist/main/core/tools/builtin/shell.js.map +0 -1
  89. package/dist/main/core/tools/registry.js +0 -71
  90. package/dist/main/core/tools/registry.js.map +0 -1
  91. package/dist/main/core/tools/toolTypes.js +0 -8
  92. package/dist/main/core/tools/toolTypes.js.map +0 -1
  93. package/dist/main/core/tools/zodBridge.js +0 -56
  94. package/dist/main/core/tools/zodBridge.js.map +0 -1
  95. package/dist/shared/eventBus.js +0 -104
  96. package/dist/shared/eventBus.js.map +0 -1
  97. package/dist/shared/events.js +0 -73
  98. package/dist/shared/events.js.map +0 -1
  99. package/dist/shared/index.js +0 -8
  100. package/dist/shared/index.js.map +0 -1
  101. package/dist/types/context.js +0 -3
  102. package/dist/types/context.js.map +0 -1
  103. package/dist/types/index.js +0 -2
  104. package/dist/types/index.js.map +0 -1
  105. package/dist/types/knowledge.js +0 -2
  106. package/dist/types/knowledge.js.map +0 -1
  107. package/dist/types/systemTypes.js +0 -10
  108. package/dist/types/systemTypes.js.map +0 -1
package/README.md CHANGED
@@ -1,296 +1,321 @@
1
- # Zelari Code
2
-
3
- ```
4
- -#%=
5
- .*%%%@#:
6
- =%%%%%%%@*
7
- +%%%%%%%%%%#.
8
- +%%%@@@@@@@%@#.
9
- .*%@@@@@@@@@@@@@%-
10
- .#%@@@@@@@@@@@@@@@@-
11
- *%@@@@@@@@@@@@@@@@@%.
12
- :@%%@@@@@@%:+%@@@@@%@=
13
- =@%%@@@@@%.=-+%@%%@*
14
- .=@@%@@@@%.*@*-+@@*.
15
- -*%@@@@@@@@%.*@@@+:#@@#=.
16
- *%%%%%%@@@@@@.*#%#=-:+@@@%
17
- :@%%%%%%@@@@@@.:=.*:*@@@@@@=
18
- *@%%@%%@@@@@@@*%@*:-:%@@@@@%.
19
- :@@@%@@@@@@@@@@@@@@#%@@@@@@@@=
20
- *%%%%%%%%%%%%%%%%%%%%%%%%%%%%#
21
-
22
- Z E L A R I C O D E
23
- N-THEM Studio
24
- ```
25
-
26
- > AI Council coding agent CLI โ€” multi-agent orchestration with slash commands, provider-agnostic LLM streaming, and self-update.
27
-
28
- ![Version](https://img.shields.io/npm/v/zelari-code)
29
- ![License](https://img.shields.io/badge/license-Proprietary-red)
30
- ![Node](https://img.shields.io/node/v/zelari-code)
31
-
32
- **Zelari Code** is a standalone CLI extracted from [AnathemaBrain](https://github.com/N-THEM-Studio/AnathemaBrain). It brings the multi-agent council (Caronte, Nettuno, Gerione, Plutone, Minosse, Lucifero) directly into your terminal with a rich TUI (Ink + React), slash command system, and provider-agnostic LLM streaming (OpenAI-compatible, xAI Grok with OAuth, GLM/Z.AI).
33
-
34
- > **Upgrading from โ‰ค 0.4.x?** See [MIGRATION.md](./MIGRATION.md) โ€” the internal
35
- > `src/main/core/`, `src/agents/`, `src/shared/`, `src/types/` paths no longer
36
- > exist. The published core package is `@zelari/core` (MIT). 9 subpath exports.
37
-
38
- ## Install
39
-
40
- ```bash
41
- npm install -g zelari-code
42
- zelari-code
43
- ```
44
-
45
- Requires **Node.js โ‰ฅ 20**.
46
-
47
- ### `zelari-code: command not found` (Windows)
48
-
49
- After `npm install -g`, the `zelari-code` command may not be on your `PATH`. Fix:
50
-
51
- **PowerShell** (run as admin, then restart your terminal):
52
- ```powershell
53
- $npmPrefix = npm config get prefix
54
- [Environment]::SetEnvironmentVariable("Path", $env:Path + ";$npmPrefix", "User")
55
- ```
56
-
57
- **Git Bash / WSL:**
58
- ```bash
59
- echo 'export PATH="$(npm config get prefix):$PATH"' >> ~/.bashrc
60
- source ~/.bashrc
61
- ```
62
-
63
- Verify the fix: `where zelari-code` (CMD) or `which zelari-code` (Bash) should print a path.
64
-
65
- ## First Run
66
-
67
- The first time you run `zelari-code` (or whenever your provider config
68
- is missing), the CLI launches a 5-step onboarding wizard instead of
69
- the regular TUI:
70
-
71
- ```
72
- โ•ญโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฎ
73
- โ”‚ zelari-code v0.6.0 โ€” first-time setup โ”‚
74
- โ”‚ 1/welcome 2/provider 3/model 4/apikey 5/...โ”‚
75
- โ”‚ โ”‚
76
- โ”‚ Welcome! Let's get you coding in under 2 min. โ”‚
77
- โ”‚ Press [Enter] to continue, [Q] to quit. โ”‚
78
- โ•ฐโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฏ
79
- ```
80
-
81
- The wizard walks you through:
82
-
83
- 1. **Welcome** โ€” overview + how to quit.
84
- 2. **Provider** โ€” pick from `grok`, `minimax`, `glm`, `openai-compatible` (โ†‘/โ†“ + Enter).
85
- 3. **Model** โ€” type a model name or accept the default (Enter).
86
- 4. **API key** โ€” choose `env` (use `GROK_API_KEY` etc.), `keystore` (save locally), or `skip` (set later via `/login`).
87
- 5. **Confirm** โ€” review + Enter to commit.
88
-
89
- When you press Enter on confirm, the wizard writes `~/.tmp/zelari-code/provider.json` (and `keys.json` if you chose keystore), shows a brief "โœ“ Setup complete!" banner, **then transparently transitions into the regular TUI** โ€” no need to re-launch.
90
-
91
- ### Skipping / re-running
92
-
93
- ```bash
94
- zelari-code --no-wizard # skip wizard even on first run
95
- zelari-code --reset-config # force re-run wizard (clears provider.json)
96
- ZELARI_NO_WIZARD=1 zelari-code # env equivalent of --no-wizard
97
- zelari-code --version # print version + exit (no TUI)
98
- zelari-code --help # print help + exit (no TUI)
99
- ```
100
-
101
- The wizard re-runs automatically if `provider.json` is missing on the next launch.
102
-
103
- ## Quick Start
104
-
105
- ```bash
106
- # Set your OpenAI-compatible API key (OpenAI, Together, Groq, custom endpoint, etc.)
107
- export OPENAI_API_KEY=sk-...
108
-
109
- # Or use Grok via OAuth (Device Authorization Grant โ€” RFC 8628)
110
- zelari-code
111
- # Inside the TUI: /login grok
112
- # โ†’ A code + verification URL appears; open the URL, enter the code, authorize.
113
-
114
- # Or use GLM/Z.AI
115
- export GLM_API_KEY=...
116
-
117
- # Run zelari-code from any directory
118
- zelari-code
119
- ```
120
-
121
- ## Slash Commands
122
-
123
- | Command | Description |
124
- |---|---|
125
- | `/help` | List all available commands |
126
- | `/skill <name>` | Invoke a coding skill (refactoring, testing, debugging, review, planning, docs, git-ops) |
127
- | `/skills` | List available skills |
128
- | `/skill-suggest <query>` | Get skill suggestions for a coding task |
129
- | `/skill-history` | Show skill invocation history |
130
- | `/skill-compare <id1> <id2>` | Compare two skills' stats |
131
- | `/provider` | Show/set active LLM provider |
132
- | `/model <model>` | Set model for current provider |
133
- | `/key <provider>` | Set API key (or start device OAuth flow for Grok) |
134
- | `/cost` | Show session cost breakdown |
135
- | `/compact` | Compact the chat transcript |
136
- | `/session` | Show session info |
137
- | `/sessions` | List past sessions |
138
- | `/resume [id]` | Resume a past session |
139
- | `/branch [name]` | Create/list/switch git branches |
140
- | `/diff` | Show working diff |
141
- | `/undo` | Undo working changes |
142
- | `/update` | Check for CLI updates |
143
- | `/update --yes` | Apply update |
144
- | `/update force` | Reinstall latest version |
145
- | `/steer <text>` | Queue follow-up prompt during active run |
146
- | `/steer --interrupt <text>` | Cancel current run + enqueue prompt |
147
- | `/promote-member <role>` | Promote a council member (role depth system) |
148
- | `/council` | Dispatch council task |
149
- | `/quit` / `/exit` | Exit the CLI |
150
-
151
- ## Self-Update
152
-
153
- Zelari Code includes a built-in update mechanism:
154
-
155
- ```bash
156
- # Inside the TUI:
157
- /update # check for updates (prints current vs latest)
158
- /update --yes # apply update (runs npm install -g zelari-code@latest)
159
- /update force # reinstall latest (even if already on latest)
160
- ```
161
-
162
- On startup, the CLI silently checks the npm registry. If a newer version is available, it prints a one-line hint to stderr.
163
-
164
- Disable auto-check: `ZELARI_DEV=1 zelari-code`
165
-
166
- ## Features
167
-
168
- - ๐Ÿค– **Multi-agent council** โ€” 6 roles (Caronte, Nettuno, Gerione, Plutone, Minosse, Lucifero) with feedback loops and member promotion
169
- - โ‡งโ‡ฅ **Agent/council mode switch** โ€” `shift+tab` toggles free-form prompts between the single agent and the full council pipeline (mode shown in the status line)
170
- - ๐ŸŽจ **Rich TUI** โ€” Ink + React: native-scrollback chat stream, input bar with status line below it (mode ยท provider ยท model ยท session ยท cwd ยท execution timer)
171
- - ๐Ÿ—‚๏ธ **Live git sidebar** โ€” right-hand panel with the N-THEM emblem and the working-tree changes (`+added`/`-removed` per file, refreshed every 4s; auto-hidden on narrow terminals)
172
- - โฑ๏ธ **Execution timer** โ€” elapsed time of the in-flight turn in the status line (`โฑ 12s`), frozen as `last 34s` when the run completes
173
- - ๐Ÿง  **Provider-agnostic** โ€” OpenAI-compatible APIs (OpenAI, Together, Groq, custom), xAI Grok with OAuth refresh, GLM/Z.AI
174
- - ๐Ÿ› ๏ธ **Built-in tools** โ€” filesystem (read/write/edit), shell (bash), search (grep), git operations
175
- - ๐Ÿ“š **7 coding skills** โ€” refactoring, testing, debugging, review, planning, docs, git-ops
176
- - ๐Ÿ”„ **Cross-provider failover** โ€” automatic retry with provider swap on transient errors
177
- - ๐Ÿ’ฐ **Cost tracking** โ€” per-turn + cumulative USD cost via model pricing registry
178
- - ๐Ÿ“Š **Metrics + skill history** โ€” fire-and-forget logging to `~/.tmp/zelari-code/`
179
- - ๐Ÿ—œ๏ธ **Session management** โ€” JSONL transcripts, resume across restarts, compaction
180
- - ๐ŸŒฟ **Branch isolation** โ€” worktree-per-session mode for safe experimentation
181
- - ๐Ÿ”Œ **Slash command system** โ€” 30+ commands for skill invocation, provider config, cost, sessions, etc.
182
- - ๐Ÿ†• **Self-update** โ€” `/update` slash command + silent registry check on startup
183
-
184
- ## Architecture
185
-
186
- ```
187
- zelari-code (CLI)
188
- โ”œโ”€โ”€ src/cli/ # Ink UI (app.tsx, slashCommands.ts, updater.ts, โ€ฆ)
189
- โ”‚ โ”œโ”€โ”€ components/ # Header, ChatStream, InputBar, Sidebar, โ€ฆ
190
- โ”‚ โ”œโ”€โ”€ provider/ # OpenAI-compatible adapter
191
- โ”‚ โ””โ”€โ”€ โ€ฆ
192
- โ”œโ”€โ”€ src/agents/ # Council (councilApi), skills registry, promoteMember
193
- โ”œโ”€โ”€ src/main/core/ # AgentHarness (provider-neutral agent loop)
194
- โ”‚ โ””โ”€โ”€ tools/ # Tool registry + filesystem/shell/search builtins
195
- โ”œโ”€โ”€ src/shared/ # BrainEvent types (provider-neutral event contract)
196
- โ””โ”€โ”€ src/types/ # Workspace, context, knowledge types
197
- ```
198
-
199
- `AgentHarness` is the core: it takes (model, provider, messages, tools) + a streaming function and yields an `AsyncIterable<BrainEvent>`. The CLI subscribes to the event stream and updates the chat transcript via `eventsToMessages()`.
200
-
201
- ## Environment Variables
202
-
203
- | Variable | Description |
204
- |---|---|
205
- | `OPENAI_API_KEY` | OpenAI API key |
206
- | `OPENAI_MODEL` | Default model (default: `grok-4`) |
207
- | `OPENAI_BASE_URL` | Custom OpenAI-compatible endpoint |
208
- | `GLM_API_KEY` | GLM/Z.AI API key |
209
- | `GROK_API_KEY` | xAI Grok API key (alternative to OAuth) |
210
- | `ZELARI_DEV=1` | Disable silent update check on startup |
211
- | `ANATHEMA_FAILOVER=0` | Disable cross-provider failover |
212
-
213
- ## Council Workspace
214
-
215
- The CLI persists council output (decisions, risks, docs, plan, reviews) into a **project-local** `.zelari/` directory and auto-curates an `AGENTS.MD` at the project root.
216
-
217
- ### Layout
218
-
219
- ```
220
- .zelari/ # auto-gitignored, per-project
221
- โ”œโ”€โ”€ plan.md # phases / tasks / milestones (Markdown + YAML frontmatter)
222
- โ”œโ”€โ”€ risks.md # risk register (live, ordered by severity)
223
- โ”œโ”€โ”€ decisions/ # ADRs (Architecture Decision Records) โ€” 001-<slug>.md
224
- โ”œโ”€โ”€ reviews/ # Minosse verdict per council run
225
- โ””โ”€โ”€ docs/ # doc drafts produced by the council
226
- AGENTS.MD # committed at project root, auto-curated from .zelari/
227
- ```
228
-
229
- ### Slash commands
230
-
231
- | Command | Effect |
232
- | --- | --- |
233
- | `/workspace` | List all artifacts + usage hint |
234
- | `/workspace show plan` | Render `.zelari/plan.md` |
235
- | `/workspace show decisions` | List all ADRs (id, status, title) |
236
- | `/workspace show risks` | Render `.zelari/risks.md` |
237
- | `/workspace show agents` | Render `AGENTS.MD` (project root) |
238
- | `/workspace show docs` | List `.zelari/docs/` drafts |
239
- | `/workspace sync` | Re-run AGENTS.MD auto-curation (idempotent โ€” no-op if unchanged) |
240
- | `/workspace reset --yes` | Delete `.zelari/` (destructive โ€” requires confirmation) |
241
-
242
- ### AGENTS.MD format
243
-
244
- `AGENTS.MD` is partitioned into:
245
-
246
- 1. **Manual blocks** (free-form, preserved verbatim across updates) โ€” write anything you want here.
247
- 2. **Auto-managed sections** delimited by `<!-- zelari:auto:start section="..." -->` / `<!-- zelari:auto:end -->` markers โ€” overwritten each sync.
248
-
249
- Auto-managed sections:
250
- - `tech-stack` โ€” languages, frameworks, build tools (derived from `package.json`)
251
- - `decisions` โ€” accepted ADRs (newest first, capped)
252
- - `conventions` โ€” code conventions observed in source tree
253
- - `build` โ€” build/test/lint commands
254
- - `open-questions` โ€” info-level risks + unsolved questions
255
-
256
- Set `ZELARI_AGENTS_MD=0` to disable AGENTS.MD auto-curation.
257
-
258
- ### Storage layout internals
259
-
260
- - Frontmatter: subset YAML (scalars, flow/sequence/block-sequence arrays, flow/block maps) โ€” no external deps.
261
- - Concurrency: per-key mutex (filesystem writes are serialized per artifact).
262
- - Idempotency: hash comparison โ€” AGENTS.MD write is skipped when no section changed (clean git diff).
263
-
264
- See [`docs/plans/2026-07-01-council-workspace-cli-stubs.md`](./docs/plans/2026-07-01-council-workspace-cli-stubs.md) for the full schema.
265
-
266
- ## Development
267
-
268
- ```bash
269
- git clone https://github.com/N-THEM-Studio/zelari-code.git
270
- cd zelari-code
271
- npm install
272
- npm run build:cli
273
- npm link
274
- zelari-code
275
- ```
276
-
277
- ### Run tests
278
-
279
- ```bash
280
- npm test
281
- ```
282
-
283
- ### Typecheck
284
-
285
- ```bash
286
- npm run typecheck
287
- ```
288
-
289
- ## Related Projects
290
-
291
- - [AnathemaBrain](https://github.com/N-THEM-Studio/AnathemaBrain) โ€” the Electron desktop GUI that shares the agent runtime + council system with this CLI
292
- - Zelari Coder originated as the `npm run coder` script inside AnathemaBrain
293
-
294
- ## License
295
-
1
+ # Zelari Code
2
+
3
+ ```
4
+ -#%=
5
+ .*%%%@#:
6
+ =%%%%%%%@*
7
+ +%%%%%%%%%%#.
8
+ +%%%@@@@@@@%@#.
9
+ .*%@@@@@@@@@@@@@%-
10
+ .#%@@@@@@@@@@@@@@@@-
11
+ *%@@@@@@@@@@@@@@@@@%.
12
+ :@%%@@@@@@%:+%@@@@@%@=
13
+ =@%%@@@@@%.=-+%@%%@*
14
+ .=@@%@@@@%.*@*-+@@*.
15
+ -*%@@@@@@@@%.*@@@+:#@@#=.
16
+ *%%%%%%@@@@@@.*#%#=-:+@@@%
17
+ :@%%%%%%@@@@@@.:=.*:*@@@@@@=
18
+ *@%%@%%@@@@@@@*%@*:-:%@@@@@%.
19
+ :@@@%@@@@@@@@@@@@@@#%@@@@@@@@=
20
+ *%%%%%%%%%%%%%%%%%%%%%%%%%%%%#
21
+
22
+ Z E L A R I C O D E
23
+ N-THEM Studio
24
+ ```
25
+
26
+ > AI Council coding agent CLI โ€” multi-agent orchestration with slash commands, provider-agnostic LLM streaming, and self-update.
27
+
28
+ ![Version](https://img.shields.io/npm/v/zelari-code)
29
+ ![License](https://img.shields.io/badge/license-Proprietary-red)
30
+ ![Node](https://img.shields.io/node/v/zelari-code)
31
+
32
+ ๐Ÿ“– **[Guida completa all'uso (IT)](./docs/GUIDA.md)** โ€” installazione, TUI, comandi slash, council, skills, workspace, headless, MCP.
33
+
34
+ **Zelari Code** is a standalone CLI extracted from [AnathemaBrain](https://github.com/N-THEM-Studio/AnathemaBrain). It brings the multi-agent council (Caronte, Nettuno, Gerione, Plutone, Minosse, Lucifero) directly into your terminal with a rich TUI (Ink + React), slash command system, and provider-agnostic LLM streaming (OpenAI-compatible, xAI Grok with OAuth, GLM/Z.AI).
35
+
36
+ > **Upgrading from โ‰ค 0.4.x?** See [MIGRATION.md](./MIGRATION.md) โ€” the internal
37
+ > `src/main/core/`, `src/agents/`, `src/shared/`, `src/types/` paths no longer
38
+ > exist. The published core package is `@zelari/core` (MIT). 9 subpath exports.
39
+
40
+ ## Install
41
+
42
+ ```bash
43
+ npm install -g zelari-code
44
+ zelari-code
45
+ ```
46
+
47
+ Requires **Node.js โ‰ฅ 20**.
48
+
49
+ ### `zelari-code: command not found` (Windows)
50
+
51
+ After `npm install -g`, the `zelari-code` command may not be on your `PATH`. Fix:
52
+
53
+ **PowerShell** (run as admin, then restart your terminal):
54
+ ```powershell
55
+ $npmPrefix = npm config get prefix
56
+ [Environment]::SetEnvironmentVariable("Path", $env:Path + ";$npmPrefix", "User")
57
+ ```
58
+
59
+ **Git Bash / WSL:**
60
+ ```bash
61
+ echo 'export PATH="$(npm config get prefix):$PATH"' >> ~/.bashrc
62
+ source ~/.bashrc
63
+ ```
64
+
65
+ Verify the fix: `where zelari-code` (CMD) or `which zelari-code` (Bash) should print a path.
66
+
67
+ ## First Run
68
+
69
+ The first time you run `zelari-code` (or whenever your provider config
70
+ is missing), the CLI launches a 5-step onboarding wizard instead of
71
+ the regular TUI:
72
+
73
+ ```
74
+ โ•ญโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฎ
75
+ โ”‚ zelari-code v0.6.0 โ€” first-time setup โ”‚
76
+ โ”‚ 1/welcome 2/provider 3/model 4/apikey 5/...โ”‚
77
+ โ”‚ โ”‚
78
+ โ”‚ Welcome! Let's get you coding in under 2 min. โ”‚
79
+ โ”‚ Press [Enter] to continue, [Q] to quit. โ”‚
80
+ โ•ฐโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฏ
81
+ ```
82
+
83
+ The wizard walks you through:
84
+
85
+ 1. **Welcome** โ€” overview + how to quit.
86
+ 2. **Provider** โ€” pick from `grok`, `minimax`, `glm`, `openai-compatible` (โ†‘/โ†“ + Enter).
87
+ 3. **Model** โ€” type a model name or accept the default (Enter).
88
+ 4. **API key** โ€” choose `env` (use `GROK_API_KEY` etc.), `keystore` (save locally), or `skip` (set later via `/login`).
89
+ 5. **Confirm** โ€” review + Enter to commit.
90
+
91
+ When you press Enter on confirm, the wizard writes `~/.tmp/zelari-code/provider.json` (and `keys.json` if you chose keystore), shows a brief "โœ“ Setup complete!" banner, **then transparently transitions into the regular TUI** โ€” no need to re-launch.
92
+
93
+ ### Skipping / re-running
94
+
95
+ ```bash
96
+ zelari-code --no-wizard # skip wizard even on first run
97
+ zelari-code --reset-config # force re-run wizard (clears provider.json)
98
+ ZELARI_NO_WIZARD=1 zelari-code # env equivalent of --no-wizard
99
+ zelari-code --version # print version + exit (no TUI)
100
+ zelari-code --help # print help + exit (no TUI)
101
+ ```
102
+
103
+ The wizard re-runs automatically if `provider.json` is missing on the next launch.
104
+
105
+ ## Quick Start
106
+
107
+ ```bash
108
+ # Set your OpenAI-compatible API key (OpenAI, Together, Groq, custom endpoint, etc.)
109
+ export OPENAI_API_KEY=sk-...
110
+
111
+ # Or use Grok via OAuth (Device Authorization Grant โ€” RFC 8628)
112
+ zelari-code
113
+ # Inside the TUI: /login grok
114
+ # โ†’ A code + verification URL appears; open the URL, enter the code, authorize.
115
+
116
+ # Or use GLM/Z.AI
117
+ export GLM_API_KEY=...
118
+
119
+ # Run zelari-code from any directory
120
+ zelari-code
121
+ ```
122
+
123
+ ## Slash Commands
124
+
125
+ Full reference: **[docs/GUIDA.md](./docs/GUIDA.md#comandi-slash)** (all flags, examples, skill IDs).
126
+
127
+ | Command | Description |
128
+ |---|---|
129
+ | `/help` | List all commands + loaded skills |
130
+ | `/exit` | Exit the CLI |
131
+ | `/login <provider> [key]` | Set API key; `/login grok` starts OAuth |
132
+ | `/provider`, `/provider <id>` | Show / switch LLM provider |
133
+ | `/provider custom <url>` | Self-hosted endpoint (Ollama, LM Studio, โ€ฆ) |
134
+ | `/model <name>`, `/models` | Set model / list discovered models |
135
+ | `/skill <id> [input]` | Invoke a coding skill (23 built-in + SKILL.md) |
136
+ | `/skill-stats [id]` | Skill invocation stats |
137
+ | `/skill-compare <id1> <id2>` | Compare two skills' stats |
138
+ | `/council <input>` | Run the 6-member council pipeline |
139
+ | `/council-feedback <id> <1-5>` | Rate a council member |
140
+ | `/promote-member <id>` | Promote a council member to a skill |
141
+ | `/sessions`, `/resume <id>`, `/new` | Session management |
142
+ | `/branch <name>`, `/branches`, `/checkout <name>` | Session branches |
143
+ | `/compact`, `/clear` | Compact / clear transcript |
144
+ | `/diff [--staged]`, `/undo --yes` | Git diff / revert (destructive) |
145
+ | `/steer <text>`, `/steer --interrupt <text>` | Queue follow-up during a run |
146
+ | `/workspace โ€ฆ` | `.zelari/` artifacts + `AGENTS.MD` |
147
+ | `/update`, `/update --yes` | Check / install CLI updates |
148
+
149
+ **TUI:** `shift+tab` toggles **agent** โ†” **council** mode for free-form prompts.
150
+
151
+ ## Headless Mode
152
+
153
+ Run a single task without the TUI (CI/scripts):
154
+
155
+ ```bash
156
+ zelari-code --headless --task "Explain src/cli/main.ts" --output plain
157
+ zelari-code --headless --task "Design a REST API" --council --output json
158
+ ```
159
+
160
+ See **[docs/GUIDA.md](./docs/GUIDA.md#modalitร -headless-ciscript)** for exit codes and all flags.
161
+
162
+ ## Self-Update
163
+
164
+ Zelari Code includes a built-in update mechanism:
165
+
166
+ ```bash
167
+ # Inside the TUI:
168
+ /update # check for updates (prints current vs latest)
169
+ /update --yes # apply update (runs npm install -g zelari-code@latest)
170
+ ```
171
+
172
+ On startup, the CLI silently checks the npm registry. If a newer version is available, it prints a one-line hint to stderr.
173
+
174
+ Disable auto-check: `ANATHEMA_DEV=1 zelari-code`
175
+
176
+ ## Features
177
+
178
+ - ๐Ÿค– **Multi-agent council** โ€” 6 roles (Caronte, Nettuno, Gerione, Plutone, Minosse, Lucifero) with feedback loops and member promotion
179
+ - โ‡งโ‡ฅ **Agent/council mode switch** โ€” `shift+tab` toggles free-form prompts between the single agent and the full council pipeline (mode shown in the status line)
180
+ - ๐ŸŽจ **Rich TUI** โ€” Ink + React: native-scrollback chat stream, input bar with status line below it (mode ยท provider ยท model ยท session ยท cwd ยท execution timer)
181
+ - ๐Ÿ—‚๏ธ **Live git sidebar** โ€” right-hand panel with the N-THEM emblem and the working-tree changes (`+added`/`-removed` per file, refreshed every 4s; auto-hidden on narrow terminals)
182
+ - โฑ๏ธ **Execution timer** โ€” elapsed time of the in-flight turn in the status line (`โฑ 12s`), frozen as `last 34s` when the run completes
183
+ - ๐Ÿง  **Provider-agnostic** โ€” OpenAI-compatible APIs (OpenAI, Together, Groq, custom), xAI Grok with OAuth refresh, GLM/Z.AI
184
+ - ๐Ÿ› ๏ธ **Built-in tools** โ€” filesystem (read/write/edit), shell (bash), search (grep), web fetch/search
185
+ - ๐Ÿ“š **23 coding skills** (+ user `SKILL.md` from `.zelari/skills/`, `.claude/skills/`, โ€ฆ)
186
+ - ๐Ÿ”„ **Cross-provider failover** โ€” automatic retry with provider swap on transient errors
187
+ - ๐Ÿ“Š **Metrics + skill history** โ€” fire-and-forget logging to `~/.tmp/zelari-code/`
188
+ - ๐Ÿ—œ๏ธ **Session management** โ€” JSONL transcripts, resume across restarts, compaction
189
+ - ๐ŸŒฟ **Branch isolation** โ€” session snapshots per branch
190
+ - ๐Ÿ”Œ **MCP** โ€” external MCP servers via `.zelari/mcp.json`
191
+ - ๐Ÿ†• **Self-update** โ€” `/update` slash command + silent registry check on startup
192
+
193
+ ## Architecture
194
+
195
+ ```
196
+ zelari-code (CLI, proprietary)
197
+ โ”œโ”€โ”€ src/cli/ # Ink TUI, provider config, workspace, wizard, MCP
198
+ โ”‚ โ”œโ”€โ”€ components/ # ChatStream, InputBar, Sidebar, StatusBar, โ€ฆ
199
+ โ”‚ โ”œโ”€โ”€ slashHandlers/ # /provider, /workspace, /update, โ€ฆ
200
+ โ”‚ โ””โ”€โ”€ workspace/ # .zelari/ persistence + AGENTS.MD curation
201
+ โ””โ”€โ”€ packages/core/ # @zelari/core (MIT, npm)
202
+ โ”œโ”€โ”€ core/ # AgentHarness โ€” provider-neutral agent loop
203
+ โ”œโ”€โ”€ agents/ # Council API, roles, 23 skills, tool schemas
204
+ โ”œโ”€โ”€ harness/tools/ # Tool registry + filesystem/shell/search/web
205
+ โ”œโ”€โ”€ events/ # BrainEvent contract
206
+ โ””โ”€โ”€ council/ # Run mode, tier banners
207
+ ```
208
+
209
+ `AgentHarness` takes (model, provider, messages, tools) + a streaming function and yields `AsyncIterable<BrainEvent>`. The CLI subscribes and renders via `eventsToMessages()`. See [MIGRATION.md](./MIGRATION.md) for the v0.5+ package boundary.
210
+
211
+ ## Environment Variables
212
+
213
+ | Variable | Description |
214
+ |---|---|
215
+ | `OPENAI_API_KEY` | OpenAI API key |
216
+ | `OPENAI_MODEL` | Default model (default: `grok-4`) |
217
+ | `OPENAI_BASE_URL` | Custom OpenAI-compatible endpoint |
218
+ | `GLM_API_KEY` | GLM/Z.AI API key |
219
+ | `GROK_API_KEY` | xAI Grok API key (alternative to OAuth) |
220
+ | `ANATHEMA_DEV=1` | Disable silent update check on startup |
221
+ | `ZELARI_NO_WIZARD=1` | Skip first-run wizard |
222
+ | `ZELARI_COUNCIL_TIER=lite` | Council with 3 members instead of 6 |
223
+ | `ZELARI_MCP=0` | Disable MCP servers |
224
+ | `ANATHEMA_FAILOVER=0` | Disable cross-provider failover |
225
+
226
+ See **[docs/GUIDA.md](./docs/GUIDA.md#variabili-dambiente)** for the full list.
227
+
228
+ ## Council Workspace
229
+
230
+ The CLI persists council output (decisions, risks, docs, plan, reviews) into a **project-local** `.zelari/` directory and auto-curates an `AGENTS.MD` at the project root.
231
+
232
+ ### Layout
233
+
234
+ ```
235
+ .zelari/ # auto-gitignored, per-project
236
+ โ”œโ”€โ”€ plan.md # phases / tasks / milestones (Markdown + YAML frontmatter)
237
+ โ”œโ”€โ”€ risks.md # risk register (live, ordered by severity)
238
+ โ”œโ”€โ”€ decisions/ # ADRs (Architecture Decision Records) โ€” 001-<slug>.md
239
+ โ”œโ”€โ”€ reviews/ # Minosse verdict per council run
240
+ โ””โ”€โ”€ docs/ # doc drafts produced by the council
241
+ AGENTS.MD # committed at project root, auto-curated from .zelari/
242
+ ```
243
+
244
+ ### Slash commands
245
+
246
+ | Command | Effect |
247
+ | --- | --- |
248
+ | `/workspace` | List all artifacts + usage hint |
249
+ | `/workspace show plan` | Render `.zelari/plan.md` |
250
+ | `/workspace show decisions` | List all ADRs (id, status, title) |
251
+ | `/workspace show risks` | Render `.zelari/risks.md` |
252
+ | `/workspace show agents` | Render `AGENTS.MD` (project root) |
253
+ | `/workspace show docs` | List `.zelari/docs/` drafts |
254
+ | `/workspace sync` | Re-run AGENTS.MD auto-curation (idempotent โ€” no-op if unchanged) |
255
+ | `/workspace reset --yes` | Delete `.zelari/` (destructive โ€” requires confirmation) |
256
+
257
+ ### AGENTS.MD format
258
+
259
+ `AGENTS.MD` is partitioned into:
260
+
261
+ 1. **Manual blocks** (free-form, preserved verbatim across updates) โ€” write anything you want here.
262
+ 2. **Auto-managed sections** delimited by `<!-- zelari:auto:start section="..." -->` / `<!-- zelari:auto:end -->` markers โ€” overwritten each sync.
263
+
264
+ Auto-managed sections:
265
+ - `tech-stack` โ€” languages, frameworks, build tools (derived from `package.json`)
266
+ - `decisions` โ€” accepted ADRs (newest first, capped)
267
+ - `conventions` โ€” code conventions observed in source tree
268
+ - `build` โ€” build/test/lint commands
269
+ - `open-questions` โ€” info-level risks + unsolved questions
270
+
271
+ Set `ZELARI_AGENTS_MD=0` to disable AGENTS.MD auto-curation.
272
+
273
+ ### Storage layout internals
274
+
275
+ - Frontmatter: subset YAML (scalars, flow/sequence/block-sequence arrays, flow/block maps) โ€” no external deps.
276
+ - Concurrency: per-key mutex (filesystem writes are serialized per artifact).
277
+ - Idempotency: hash comparison โ€” AGENTS.MD write is skipped when no section changed (clean git diff).
278
+
279
+ See [`docs/plans/2026-07-01-council-workspace-cli-stubs.md`](./docs/plans/2026-07-01-council-workspace-cli-stubs.md) for the full schema.
280
+
281
+ ## Documentation
282
+
283
+ | Doc | Description |
284
+ |---|---|
285
+ | [docs/GUIDA.md](./docs/GUIDA.md) | **Guida utente completa** (IT) |
286
+ | [docs/TOOLS.md](./docs/TOOLS.md) | Tool builtin, workspace, MCP |
287
+ | [MIGRATION.md](./MIGRATION.md) | Upgrade from โ‰ค 0.4.x |
288
+ | [docs/decisions/](./docs/decisions/) | ADRs (monorepo, npm publish, API policy) |
289
+
290
+ ## Development
291
+
292
+ ```bash
293
+ git clone https://github.com/N-THEM-Studio/zelari-code.git
294
+ cd zelari-code
295
+ npm install
296
+ npm run build:cli
297
+ npm link
298
+ zelari-code
299
+ ```
300
+
301
+ ### Run tests
302
+
303
+ ```bash
304
+ npm test
305
+ ```
306
+
307
+ ### Typecheck
308
+
309
+ ```bash
310
+ npm run typecheck
311
+ ```
312
+
313
+ ## Related Projects
314
+
315
+ - [AnathemaBrain](https://github.com/N-THEM-Studio/AnathemaBrain) โ€” the Electron desktop GUI that shares the agent runtime + council system with this CLI
316
+ - Zelari Coder originated as the `npm run coder` script inside AnathemaBrain
317
+ - [@zelari/core on npm](https://www.npmjs.com/package/@zelari/core) โ€” reusable agent runtime (MIT)
318
+
319
+ ## License
320
+
296
321
  Proprietary ยฉ 2026 [N-THEM Studio](https://github.com/N-THEM-Studio). See [LICENSE](./LICENSE).