@kodax-ai/kodax 0.7.50 → 0.7.52

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 (55) hide show
  1. package/CHANGELOG.md +1814 -1773
  2. package/README.md +1215 -1213
  3. package/README_CN.md +636 -634
  4. package/dist/chunks/agent-XXTR7T37.js +2 -0
  5. package/dist/chunks/argument-completer-VMH6VZ4X.js +2 -0
  6. package/dist/chunks/chunk-4RVSFOUT.js +420 -0
  7. package/dist/chunks/chunk-5USNUSTL.js +648 -0
  8. package/dist/chunks/chunk-7X7SOVER.js +492 -0
  9. package/dist/chunks/{chunk-HR64F32V.js → chunk-BFXFSEHK.js} +1 -1
  10. package/dist/chunks/chunk-HMATTIU6.js +574 -0
  11. package/dist/chunks/{chunk-SK4HOYT2.js → chunk-JJTUBNQX.js} +1 -1
  12. package/dist/chunks/chunk-LE6STNVN.js +31 -0
  13. package/dist/chunks/chunk-MFPYZT52.js +301 -0
  14. package/dist/chunks/{compaction-config-DDJSQ4OT.js → compaction-config-UBPCNGC2.js} +1 -1
  15. package/dist/chunks/{construction-bootstrap-4QNM2BVM.js → construction-bootstrap-BXRMA3KL.js} +1 -1
  16. package/dist/chunks/dist-IHH4BYIU.js +2 -0
  17. package/dist/chunks/{dist-OJSNNI7P.js → dist-Z6U7TWKJ.js} +1 -1
  18. package/dist/chunks/utils-6WZHBMCC.js +2 -0
  19. package/dist/index.d.ts +11 -11
  20. package/dist/index.js +4 -4
  21. package/dist/kodax_cli.js +1004 -978
  22. package/dist/provider-capabilities.json +2 -0
  23. package/dist/sdk-agent.d.ts +16 -10
  24. package/dist/sdk-agent.js +1 -1
  25. package/dist/sdk-coding.d.ts +32 -16
  26. package/dist/sdk-coding.js +1 -1
  27. package/dist/sdk-llm.d.ts +3 -5
  28. package/dist/sdk-llm.js +1 -1
  29. package/dist/sdk-mcp.js +1 -1
  30. package/dist/sdk-repl.d.ts +16 -727
  31. package/dist/sdk-repl.js +2 -2
  32. package/dist/sdk-session.d.ts +8 -224
  33. package/dist/sdk-session.js +1 -1
  34. package/dist/sdk-skills.js +1 -1
  35. package/dist/types-chunks/{types.d-rPRl2LSB.d.ts → base.d-BBNUF9nz.d.ts} +271 -3
  36. package/dist/types-chunks/{bash-prefix-extractor.d-B0CIb0N3.d.ts → bash-prefix-extractor.d-DBFZEwop.d.ts} +15 -521
  37. package/dist/types-chunks/{capsule.d-CwBEm6M-.d.ts → capsule.d-CNonpwAZ.d.ts} +3 -3
  38. package/dist/types-chunks/guardrail.d-B18oO1gt.d.ts +518 -0
  39. package/dist/types-chunks/{process.d-BbiXD24v.d.ts → process.d-Bj82oJhD.d.ts} +348 -275
  40. package/dist/types-chunks/{resolver.d-CQfaJbht.d.ts → resolver.d-CCX9NXWP.d.ts} +2 -2
  41. package/dist/types-chunks/sdk-session-D4tqRl0_.d.ts +977 -0
  42. package/dist/types-chunks/{storage.d-J2GqOgaX.d.ts → storage.d-CabW10Nt.d.ts} +78 -3
  43. package/dist/types-chunks/types.d-D4jL-gAA.d.ts +273 -0
  44. package/dist/types-chunks/{utils.d-D_-jrRku.d.ts → utils.d-23Gn14zP.d.ts} +7 -81
  45. package/package.json +3 -3
  46. package/dist/chunks/argument-completer-3WX5B42G.js +0 -2
  47. package/dist/chunks/chunk-5UJQ2GKJ.js +0 -574
  48. package/dist/chunks/chunk-MFOMFMSK.js +0 -1056
  49. package/dist/chunks/chunk-UB5IAZHF.js +0 -476
  50. package/dist/chunks/chunk-XZY4CIDV.js +0 -31
  51. package/dist/chunks/chunk-YJLRBIEW.js +0 -301
  52. package/dist/chunks/dist-T256OSDI.js +0 -2
  53. package/dist/chunks/utils-JHIEOX6Z.js +0 -2
  54. package/dist/types-chunks/base.d-C4jYVjJh.d.ts +0 -270
  55. package/dist/types-chunks/types.d-BnjX2Gn4.d.ts +0 -297
package/README.md CHANGED
@@ -1,1213 +1,1215 @@
1
- <p align="center">
2
- <picture>
3
- <source media="(prefers-color-scheme: dark)" srcset="assets/logo-dark.svg">
4
- <source media="(prefers-color-scheme: light)" srcset="assets/logo-light.svg">
5
- <img src="assets/logo-light.svg" alt="KodaX" width="640">
6
- </picture>
7
- </p>
8
-
9
- <p align="center">
10
- <b>Open-source AI coding agent on every LLM you can reach.</b><br>
11
- Anthropic · OpenAI · DeepSeek · Kimi · Zhipu · MiniMax · MiMo · Ark · Qwen · Gemini · Codex.<br>
12
- REPL · CLI · library · Node-free single binary.
13
- </p>
14
-
15
- <p align="center">
16
- <a href="https://www.npmjs.com/package/@kodax-ai/kodax"><img alt="npm version" src="https://img.shields.io/npm/v/@kodax-ai/kodax?style=flat-square&color=cb3837"></a>
17
- <a href="LICENSE"><img alt="license" src="https://img.shields.io/badge/license-Apache--2.0-blue?style=flat-square"></a>
18
- <a href="https://github.com/icetomoyo/KodaX/stargazers"><img alt="GitHub stars" src="https://img.shields.io/github/stars/icetomoyo/KodaX?style=flat-square&logo=github&color=f1c40f"></a>
19
- <a href="https://github.com/icetomoyo/KodaX/actions"><img alt="CI" src="https://img.shields.io/github/actions/workflow/status/icetomoyo/KodaX/release.yml?style=flat-square&label=release"></a>
20
- <img alt="providers" src="https://img.shields.io/badge/LLMs-14_aliases_+_custom-2ecc71?style=flat-square">
21
- </p>
22
-
23
- <p align="center">
24
- <a href="#install-in-30-seconds">Install</a> ·
25
- <a href="#four-ways-to-use-kodax">Usage</a> ·
26
- <a href="#sdk-usage">SDK</a> ·
27
- <a href="CHANGELOG.md">Changelog</a> ·
28
- <a href="docs/FEATURE_LIST.md">Roadmap</a> ·
29
- <a href="https://github.com/icetomoyo/KodaX/discussions">Discussions</a> ·
30
- <a href="README_CN.md">中文 README</a>
31
- </p>
32
-
33
- <p align="center">
34
- <img src="kodax.gif" alt="KodaX in action" width="880">
35
- </p>
36
-
37
- ---
38
-
39
- ## Install in 30 seconds
40
-
41
- ```bash
42
- npm i -g @kodax-ai/kodax
43
-
44
- # Pick any one you have an API key for:
45
- export ZHIPU_API_KEY=... # or ANTHROPIC_API_KEY / OPENAI_API_KEY / KIMI_API_KEY /
46
- # MINIMAX_API_KEY / MIMO_API_KEY / ARK_API_KEY / QWEN_API_KEY /
47
- # DEEPSEEK_API_KEY / GEMINI_API_KEY
48
-
49
- kodax
50
- ```
51
-
52
- That's it. You're in the REPL — ask anything in natural language.
53
-
54
- > **No-Node target machines:** download a Bun-compiled single binary for Windows / macOS / Linux × x64 + arm64 from the [GitHub Releases](https://github.com/icetomoyo/KodaX/releases) page. See [docs/release.md](docs/release.md) for the build pipeline.
55
-
56
- ---
57
-
58
- ## Four ways to use KodaX
59
-
60
- | Form | Command / Import | When to use it |
61
- |---|---|---|
62
- | **REPL** | `kodax` | Interactive multi-turn coding session with streaming UI, permissions, slash commands |
63
- | **CLI** | `kodax -p "your task"` | One-shot scripted task, CI runs, batch processing |
64
- | **Library** | `import { runKodaX } from '@kodax-ai/kodax'` | Embed in your own tool / agent / web service |
65
- | **Single binary** | `./kodax` | Distribute to machines that don't have Node installed |
66
-
67
- ---
68
-
69
- ## Why KodaX
70
-
71
- <table>
72
- <tr>
73
- <td width="33%" align="center" valign="top">
74
- <h3>🇨🇳 6 China-native LLMs</h3>
75
- <sub>Zhipu · Kimi · MiniMax · MiMo · Ark · Qwen</sub>
76
- <br><br>
77
- First-class adapters with cross-provider <a href="benchmark/EVAL_GUIDELINES.md">prompt-eval calibration</a> on a canonical 5-alias panel — not OpenAI-compat shims.
78
- </td>
79
- <td width="33%" align="center" valign="top">
80
- <h3>📦 Single-file binary</h3>
81
- <sub>Bun --compile · Win / macOS / Linux · x64 + arm64</sub>
82
- <br><br>
83
- No Node required on the target machine. Drop one file, run anywhere — restricted envs, CI runners, air-gapped boxes.
84
- </td>
85
- <td width="33%" align="center" valign="top">
86
- <h3>🌳 Branchable session lineage</h3>
87
- <sub>Fork · rewind · parallel edit</sub>
88
- <br><br>
89
- Conversation history is a DAG, not a list. Powers the upcoming <b>KodaX Space</b> desktop app.
90
- </td>
91
- </tr>
92
- <tr>
93
- <td align="center" valign="top">
94
- <h3>🤖 Multi-agent by default</h3>
95
- <sub>V2 Worker single-loop + Sidecar Verifier + async children</sub>
96
- <br><br>
97
- <code>dispatch_child_task</code>, <code>send_message</code>, <code>task_stop</code>, multi-instance auto-coordination with content-hash safety net.
98
- </td>
99
- <td align="center" valign="top">
100
- <h3>🧩 Skills + self-construction</h3>
101
- <sub>Markdown skills, NL triggers</sub>
102
- <br><br>
103
- 5-stage self-modification staircase (scaffold → validate → stage → test → activate) gated by an 8-invariant admission contract.
104
- </td>
105
- <td align="center" valign="top">
106
- <h3>🛠 50+ built-in tools</h3>
107
- <sub>File · shell · search · MCP · ACP</sub>
108
- <br><br>
109
- Repo intelligence, semantic search, git worktree, web fetch — all addressable through one clean tool surface.
110
- </td>
111
- </tr>
112
- </table>
113
-
114
- ## How KodaX compares
115
-
116
- | Feature | **KodaX** | Claude Code | Aider | Codex CLI | Cursor | Cline |
117
- |---|---|---|---|---|---|---|
118
- | Open source | ✅ Apache&nbsp;2.0 | ❌ Source-available | ✅ Apache&nbsp;2.0 | ✅ Apache&nbsp;2.0 | ❌ Proprietary | ✅ Apache&nbsp;2.0 |
119
- | Node-free single binary | ✅ Bun | ❌ Node | ❌ Python | ✅ Rust | ❌ Electron | ❌ Extension |
120
- | Native China providers<br><sub>(Zhipu · Kimi · MiniMax · MiMo · Ark · Qwen)</sub> | ✅ 6 native | ❌ | ⚠ via LiteLLM | ❌ OpenAI-first | ❌ no provider menu | ⚠ Kimi / Qwen / DeepSeek |
121
- | Branchable session lineage | ✅ fork & rewind | ⚠ routines / sessions | ❌ | ❌ | ❌ | ⚠ checkpoints |
122
- | Multi-agent + MCP + 50+ tools | ✅ all three | ✅ all three | ⚠ tools, no MCP | ✅ all three | ⚠ Composer + MCP | ✅ all three |
123
-
124
- <sub>Data verified May 2026 against public docs ([Claude Code](https://github.com/anthropics/claude-code) · [Aider](https://aider.chat/docs/llms.html) · [Codex CLI](https://github.com/openai/codex) · [Cursor](https://cursor.com) · [Cline](https://github.com/cline/cline)). ⚠ = partial / requires extra setup / not first-class. Corrections welcome via PR.</sub>
125
-
126
- ## Detailed Setup
127
-
128
- > The `npm i -g @kodax-ai/kodax` one-liner above is the fastest path. This section is for building from source, configuring custom providers, or using KodaX as a library.
129
-
130
- ### 1. Build the CLI from source
131
-
132
- ```bash
133
- git clone https://github.com/icetomoyo/KodaX.git
134
- cd KodaX
135
- npm install
136
- npm run build
137
- npm link
138
- ```
139
-
140
- ### 2. Configure a provider
141
-
142
- KodaX reads API keys from environment variables. For built-in providers, the fastest path is:
143
-
144
- ```bash
145
- # macOS / Linux
146
- export ZHIPU_API_KEY=your_api_key
147
-
148
- # PowerShell
149
- $env:ZHIPU_API_KEY="your_api_key"
150
- ```
151
-
152
- For CLI defaults, create `~/.kodax/config.json`:
153
-
154
- ```json
155
- {
156
- "provider": "zhipu-coding",
157
- "reasoningMode": "auto"
158
- }
159
- ```
160
-
161
- If you need a custom base URL or an OpenAI/Anthropic-compatible endpoint, define a custom provider in the same config file:
162
-
163
- ```json
164
- {
165
- "provider": "my-openai-compatible",
166
- "customProviders": [
167
- {
168
- "name": "my-openai-compatible",
169
- "protocol": "openai",
170
- "baseUrl": "https://example.com/v1",
171
- "apiKeyEnv": "MY_LLM_API_KEY",
172
- "model": "my-model",
173
- "userAgentMode": "compat"
174
- }
175
- ]
176
- }
177
- ```
178
-
179
- `userAgentMode` defaults to `"compat"`, which sends `KodaX` instead of the official SDK User-Agent. Switch it to `"sdk"` only when your gateway expects the upstream SDK header.
180
-
181
- #### OpenAI-compatible reasoning providers
182
-
183
- Some OpenAI-compatible reasoning models require KodaX to replay the previous assistant turn's `reasoning_content` on later requests. DeepSeek V4 thinking mode is the known load-bearing case. Built-in DeepSeek already opts in; custom providers must say so explicitly:
184
-
185
- ```json
186
- {
187
- "customProviders": [
188
- {
189
- "name": "my-deepseek-v4",
190
- "protocol": "openai",
191
- "baseUrl": "https://example.com/v1",
192
- "apiKeyEnv": "MY_DEEPSEEK_API_KEY",
193
- "model": "deepseek-v4-flash",
194
- "supportsThinking": true,
195
- "reasoningCapability": "native-toggle",
196
- "replayReasoningContent": true
197
- }
198
- ]
199
- }
200
- ```
201
-
202
- Keep `replayReasoningContent` unset or `false` for OpenAI proper and gateways that reject unknown assistant-message fields. If one gateway routes mixed models, prefer per-model overrides:
203
-
204
- ```json
205
- {
206
- "models": [
207
- { "id": "deepseek-v4-flash", "replayReasoningContent": true },
208
- { "id": "gpt-5", "replayReasoningContent": false }
209
- ]
210
- }
211
- ```
212
-
213
- Sidecar verifier judge calls use provider-level forced tool choice when supported. If a compatible endpoint rejects the `tool_choice` parameter, KodaX retries that verifier request once without forced tool choice and still fails open rather than blocking the main Worker.
214
-
215
- #### Opting a custom provider into image / vision input (FEATURE_134 v0.7.40)
216
-
217
- If your custom provider's underlying model supports image input (vision), add a `capabilityProfile.multimodalSupport: "image-input"` block so KodaX does not artificially block multimodal requests at the SA-path policy gate. Built-in vision-capable aliases (Anthropic, OpenAI, Anthropic-/OpenAI-compatible aliases such as DeepSeek, Kimi, Qwen, Zhipu, MiniMax, MiMo, Ark, plus Gemini-CLI via the CLI's `@<path>` file-include syntax) already ship with this flag enabled by default; Codex-CLI and custom providers need to opt in when their underlying model supports image input.
218
-
219
- ```json
220
- {
221
- "customProviders": [
222
- {
223
- "name": "my-vision-provider",
224
- "protocol": "openai",
225
- "baseUrl": "https://example.com/v1",
226
- "apiKeyEnv": "MY_LLM_API_KEY",
227
- "model": "my-vision-model",
228
- "capabilityProfile": {
229
- "transport": "native-api",
230
- "conversationSemantics": "full-history",
231
- "mcpSupport": "none",
232
- "contextFidelity": "full",
233
- "toolCallingFidelity": "full",
234
- "sessionSupport": "full",
235
- "longRunningSupport": "full",
236
- "multimodalSupport": "image-input",
237
- "evidenceSupport": "full"
238
- }
239
- }
240
- ]
241
- }
242
- ```
243
-
244
- The serializer layer (`packages/llm/src/providers/anthropic.ts:770` for Anthropic-compat, `openai.ts:904` for OpenAI-compat) forwards image blocks automatically through base-class inheritance. The flag only gates whether KodaX's policy layer pre-rejects multimodal requests — the model-level vision contract remains your upstream provider's responsibility. If the model is actually text-only, you'll see the real upstream API error instead of a KodaX-side rejection.
245
-
246
- ### 3. Start in REPL or run a one-shot task
247
-
248
- ```bash
249
- # Interactive REPL
250
- kodax
251
-
252
- # Then ask naturally inside the REPL
253
- Read package.json and summarize the architecture
254
- /mode
255
- /help
256
-
257
- # One-shot CLI usage
258
- kodax "Review this repository and summarize the architecture"
259
- kodax --session review "Find the riskiest parts of src/"
260
- kodax --session review "Give me concrete fix suggestions"
261
- ```
262
-
263
- ### 4. Use it as a library
264
-
265
- Library usage still expects API keys from environment variables. If you want custom provider names or base URLs in code, register them explicitly:
266
-
267
- ```typescript
268
- import { registerCustomProviders, runKodaX } from '@kodax-ai/kodax';
269
-
270
- registerCustomProviders([
271
- {
272
- name: 'my-openai-compatible',
273
- protocol: 'openai',
274
- baseUrl: 'https://example.com/v1',
275
- apiKeyEnv: 'MY_LLM_API_KEY',
276
- model: 'my-model',
277
- userAgentMode: 'compat',
278
- },
279
- ]);
280
-
281
- const result = await runKodaX(
282
- {
283
- provider: 'my-openai-compatible',
284
- reasoningMode: 'auto',
285
- },
286
- 'Explain this codebase'
287
- );
288
- ```
289
-
290
- > **Embedding KodaX inside another app?** (KodaX Space, IDE extensions, custom CLIs)
291
- > See [docs/SDK_EMBEDDER_GUIDE.md](docs/SDK_EMBEDDER_GUIDE.md) for the runtime-mutation
292
- > surface (`startKodaX` + `RunningSession`), MCP popout manager API (`McpManager`),
293
- > Skill `` !`cmd` `` host hook, and per-app data dir namespacing (`getAppDataDir`).
294
-
295
- ## Repo Intelligence (optional premium engine)
296
-
297
- KodaX ships with built-in OSS repo intelligence (`repo_overview`, `module_context`, `symbol_context`, `process_context`, `impact_estimate`, …) that helps the coding agent understand large codebases without ad-hoc grep/glob exploration.
298
-
299
- An optional **premium engine** (`repointel` local daemon, distributed via the sibling `KodaX-private` repo) adds proactive context injection, deeper module capsules, and a native auto-lane integration. KodaX automatically falls back to OSS when premium is unavailable.
300
-
301
- ```bash
302
- # Pick a runtime mode (off | oss | premium-shared | premium-native | auto)
303
- kodax --repo-intelligence premium-native --repo-intelligence-trace
304
- ```
305
-
306
- Setup, runtime modes, REPL controls, config schema, and external-host integrations: see [docs/REPOINTEL.md](docs/REPOINTEL.md).
307
-
308
- ## Architecture
309
-
310
- KodaX uses a **monorepo architecture** with npm workspaces. Source layout currently has 4 workspace packages; published as a single bundled npm package `@kodax-ai/kodax` with 7 SDK subpath exports (`/agent`, `/llm`, `/coding`, `/repl`, `/skills`, `/mcp`, `/session`; ADR-024 + ADR-032 + ADR-038, with ADR-036 consolidation):
311
-
312
- ```
313
- KodaX/
314
- ├── packages/ # 4 workspace packages (FEATURE_194 v0.7.43)
315
- │ ├── llm/ # @kodax-ai/llm - LLM abstraction (14 built-in provider aliases)
316
- │ │ └── providers/ # Anthropic, OpenAI, DeepSeek, Kimi, MiMo, MiniMax, Zhipu, Ark, …
317
- │ │
318
- │ ├── agent/ # @kodax-ai/agent - Generic Agent framework
319
- │ │ ├── orchestration/ # Runner, runFanOut, runWithIdleYield, ChildTaskRegistry
320
- │ │ ├── session-lineage/ # branchable session tree (inline v0.7.43)
321
- │ │ ├── capabilities/
322
- │ │ │ ├── mcp/ # MCP integration (inline v0.7.43)
323
- │ │ │ └── skills/ # Skills standard implementation + builtin (inline v0.7.43)
324
- │ │ └── tracing/ # tracing / observability (inline v0.7.43)
325
- │ │
326
- │ ├── coding/ # @kodax-ai/coding - Coding Agent (tools + prompts)
327
- │ │ ├── tools/ # 50+ tools: read, write, edit, bash, glob, grep, undo,
328
- │ │ │ # dispatch_child_task, send_message, task_stop,
329
- │ │ │ # ask_user_question, repo-intelligence, …
330
- │ │ └── repo-intelligence/ # incl. protocol.ts (inline v0.7.43)
331
- │ │
332
- │ └── repl/ # @kodax-ai/repl - Interactive terminal UI (Ink TUI)
333
-
334
- ├── src/ # CLI entry + SDK subpath entries
335
- │ ├── kodax_cli.ts # Main CLI entry point (bin: `kodax`)
336
- │ └── sdk-*.ts # SDK subpath re-exports → @kodax-ai/kodax/{agent,llm,coding,repl,skills,mcp,session}
337
-
338
- └── package.json # Root workspace config; release.mjs rewrites name + injects subpath exports
339
- ```
340
-
341
- ### Package Dependencies
342
-
343
- ```
344
- ┌──────────────────┐
345
- │ kodax (root) │
346
- │ CLI Entry │
347
- └────────┬─────────┘
348
-
349
- ┌──────────────┴──────────────┐
350
- │ │
351
- ▼ ▼
352
- ┌──────────────┐ ┌────────────────┐
353
- │@kodax-ai/repl│ │@kodax-ai/coding│
354
- │ UI Layer │ │ Tools+Prompts │
355
- └──────┬───────┘ └──────┬─────────┘
356
- │ │
357
- │ ┌──────────────┴──────────────┐
358
- │ │ │
359
- ▼ ▼ ▼
360
- ┌──────────────┐ ┌──────────────────────────┐ ┌──────────────┐
361
- │@kodax-ai/ │ │@kodax-ai/agent │ │@kodax-ai/llm │
362
- │coding (via │ │Runner + fan-out + │ │LLM Abstract │
363
- │above) │ │idle-yield + session- │ │(14 aliases) │
364
- │ │ │lineage + skills + mcp + │ │ │
365
- │ │ │tracing (FEATURE_194) │ │ │
366
- └──────────────┘ └──────────────────────────┘ └──────────────┘
367
- ```
368
-
369
- ### Package Overview
370
-
371
- Source-side workspace package names (`@kodax-ai/*`). npm consumers install the single bundled `@kodax-ai/kodax` package and import from SDK subpaths — see [Source-side vs npm-published surface](#source-side-vs-npm-published-surface) and [SDK Usage](#sdk-usage) below.
372
-
373
- | Workspace package | Purpose | Key Dependencies |
374
- |---------|---------|------------------|
375
- | `@kodax-ai/llm` | LLM abstraction (14 built-in provider aliases + custom registration) | @anthropic-ai/sdk, openai |
376
- | `@kodax-ai/agent` | Generic Agent framework — Runner, fan-out, idle-yield, session-lineage, capabilities (mcp + skills), tracing (ADR-036 v0.7.43 consolidation; subpaths: `/session-lineage`, `/capabilities/mcp`, `/capabilities/skills`, `/tracing`) | @kodax-ai/llm, js-tiktoken, fflate, yaml |
377
- | `@kodax-ai/coding` | Coding Agent — 50+ tools (incl. `dispatch_child_task` / `send_message` / `task_stop`) + role prompts + auto-continue + repo-intelligence protocol | @kodax-ai/llm, @kodax-ai/agent |
378
- | `@kodax-ai/repl` | Complete interactive terminal UI (Ink/React, permission modes, commands, streaming) | @kodax-ai/coding, ink, react |
379
-
380
- ### Source-side vs npm-published surface
381
-
382
- KodaX has two layers that consumers should understand separately:
383
-
384
- - **Source-side**: 4 workspace packages above (what developers see when reading the repo).
385
- - **npm-published**: a single bundled package `@kodax-ai/kodax` with 7 SDK subpaths (what SDK consumers `import` from). The subpaths are split into two roles:
386
- - **Full-package subpaths** (`/agent`, `/llm`, `/coding`, `/repl`) — each one maps 1:1 to a source workspace and exposes its complete public API.
387
- - **Narrow-subset subpaths** (`/skills`, `/mcp`, `/session`) — each one exposes only a focused capability slice carved out of `/agent` or `/repl`. This lets consumers who only need (say) the Skills system import a much smaller surface without pulling in the full agent framework.
388
-
389
- | Source package | npm subpath | Type | What you get | Example consumer |
390
- |---|---|---|---|---|
391
- | `packages/llm` | `@kodax-ai/kodax/llm` | Full package | 14-alias LLM abstraction (77 exports) | Standalone LLM clients |
392
- | `packages/agent` | `@kodax-ai/kodax/agent` | Full package | Runner / fan-out / session-lineage / capabilities / tracing (202 exports) | Custom agent frameworks |
393
- | `packages/agent` | `@kodax-ai/kodax/skills` | **Narrow subset** | Skills system only — `SkillRegistry` / `loadFullSkill` / `expandSkillForLLM` / ... (26 exports = pre-v0.7.43 `@kodax-ai/skills` complete API) | Skill loaders, IDE plugins |
394
- | `packages/agent` | `@kodax-ai/kodax/mcp` | **Narrow subset** | MCP only — `McpCapabilityProvider` / `createMcpTransport` / `searchMcpCatalog` / ... (11 exports = pre-v0.7.43 `@kodax-ai/mcp` complete API) | MCP server hosts |
395
- | `packages/coding` | `@kodax-ai/kodax/coding` | Full package | Coding agent + 50+ tools + repo-intelligence (342 exports) | Build a Claude Code-shape product |
396
- | `packages/repl` | `@kodax-ai/kodax/repl` | Full package | Ink TUI + permission modes + commands (193 exports) | Terminal-UI consumers |
397
- | `packages/repl` | `@kodax-ai/kodax/session` | **Narrow subset** | Session management only — `listSessions` / `forkSession` / `watchSessions` / ... (9 exports) | IDE plugins reading session history |
398
-
399
- **Rule of thumb**: if you need Runner / Agent / fan-out, import from `/agent`. If you only need skills or mcp APIs, import from `/skills` or `/mcp` to get a smaller bundle. The narrow subsets are subsets of the full packages — they do **not** expose extra symbols.
400
-
401
- **Dynamic Workflows (FEATURE_217, v0.7.49)**: the domain-neutral workflow runtime is part of `/agent` — `import { createWorkflowRuntime, runWorkflow, WorkflowAbortError, WorkflowLimitError } from '@kodax-ai/kodax/agent'`. The coding-side integration (agent backend + built-in workflows + saved-workflow discovery/generation: `createCodingWorkflowBackend`, `runWorkflowFromOptions`, `parallelInvestigation`, `discoverSavedWorkflows`, `generateWorkflowFromOptions`, …) is part of `/coding`. FEATURE_217 is the v0.7.49 home for the full Dynamic Workflow product loop: `/workflow create <request>` generates restricted scripts, `/workflow save <runId> <name>` stores `.workflow.json` rerunnable workflows, generated/saved scripts coordinate agents through `WorkflowApi`, run lifecycle state stays observable, opt-in `isolation:"worktree"` routes selected children to parent-managed worktrees, and all file/shell effects still pass through agent tools and the existing permission gates. There is **no** separate `@kodax-ai/kodax/agent/workflow` root-package subpath; source-package consumers of `@kodax-ai/agent` can still use that package's `./workflow` subpath.
402
-
403
- **Workflow Process Surface (FEATURE_229, v0.7.50 implementation complete; release validation pending)**: workflow progress is now a reusable Agent-layer process contract rather than private REPL text. SDK hosts can subscribe to `WorkflowProcessEvent`/poll `WorkflowProcessSnapshot`, use `createWorkflowRunManager` and `createWorkflowLifecycleController` for stop/pause/resume/result/artifact/delete/prune/identity/preflight controls, and receive ANSI-free provenance fields (`source`, `sourceRunId`, `sourceWorkflowName`, `savedWorkflowName`, `revisionOf`) plus `resultSummary`. `/coding` owns the coding workflow backend and run graph, `/repl` renders the same snapshots, and the terminal UI is not the hidden source of truth. `KodaXEvents` callbacks also take an optional metadata arg (`KodaXToolEventMeta` / `KodaXActivityEventMeta` / `KodaXWorkflowEventMeta`) so a host can attribute every child-agent tool/thinking/progress event to its workflow run and child id without a second event protocol, and generated/saved workflow scripts pass `validateRestrictedWorkflowSource` (compile + source-policy check) plus a generator repair/smoke loop before they run. See [docs/ADR.md ADR-040](docs/ADR.md) for the layering rationale.
404
-
405
- ---
406
-
407
- ## Features
408
-
409
- - **Modular Architecture** - Use as CLI, as a library, or as a Node-free single binary
410
- - **14 Built-in Provider Aliases** - Anthropic, OpenAI, DeepSeek, Kimi, Kimi Code, Qwen, Zhipu, Zhipu Coding, MiniMax Coding, MiMo Coding, MiMo, Ark Coding, Gemini CLI, Codex CLI - plus user-defined OpenAI/Anthropic-compatible providers
411
- - **Dynamic Workflows + SDK Process Surface** - Generate/reuse capability-routed workflows, observe live progress through `WorkflowProcessSnapshot`, and control workflow lifecycle from SDK hosts without parsing REPL output
412
- - **V2 Worker single-loop + Sidecar Verifier (default)** - Single-agent main loop with an out-of-band Sidecar Verifier as Stop-hook (claudecode-shape; FEATURE_184 v0.7.42, ADR-030). Verifier returns accept/revise/blocked verdict on Worker text-only termination. The pre-v0.7.43 V1 chain is retired, `emit_handoff` is deleted, accept-verdict UI silently passes through, and content-aware gating skips trivial-chat sidecar calls. Async child steering uses `dispatch_child_task` + `send_message` + `task_stop` with idle-yield wait; specialist routing uses `subagent_type`.
413
- - **Reasoning Modes** - Unified `off/auto/quick/balanced/deep` interface across providers
414
- - **Streaming Output** - Real-time response display
415
- - **Session Management** - JSONL format with branchable session lineage tree
416
- - **Skills System** - Natural language triggering, extensible, role-projected in AMA
417
- - **Repo Intelligence** - OSS baseline + optional `repointel` premium engine, with native KodaX auto-injection lane
418
- - **Rich Tool Surface** - 50+ built-in tools across file ops, shell, search, repo intelligence, MCP capabilities, git worktree, and agent control
419
- - **Permission Control** - 3 permission modes with pattern-based control
420
- - **Standalone Binary** - `bun --compile` releases for Win/macOS/Linux x64+arm64, no Node.js required on target machines
421
- - **Cross-Platform** - Windows/macOS/Linux
422
- - **TypeScript Native** - Full type safety and IDE support
423
-
424
- ---
425
-
426
- ## Installation
427
-
428
- ### As CLI Tool
429
-
430
- ```bash
431
- # Clone repository
432
- git clone https://github.com/icetomoyo/KodaX.git
433
- cd KodaX
434
-
435
- # Install dependencies (includes workspace packages)
436
- npm install
437
-
438
- # Build the monorepo
439
- npm run build
440
-
441
- # Link globally (development mode)
442
- npm link
443
-
444
- # Now you can use 'kodax' anywhere
445
- kodax "your task"
446
- ```
447
-
448
- ### As Standalone Binary (no Node required on target)
449
-
450
- KodaX can be packaged into a single executable + a small `builtin/` sidecar directory using `bun --compile`. The target machine does **not** need Node.js or any other runtime.
451
-
452
- Supported targets: `win-x64`, `linux-x64`, `linux-arm64`, `darwin-x64`, `darwin-arm64`. Win7 / pre-glibc-2.27 distros / LoongArch are not supported.
453
-
454
- **Build locally**:
455
-
456
- ```bash
457
- # Install Bun once on your build machine
458
- npm i -g bun # or scoop/brew/curl install — see docs/release.md
459
-
460
- npm run build:binary # Current host platform (fastest)
461
- npm run build:binary:all # All five targets in sequence
462
- node scripts/build-binary.mjs --target=linux-arm64 # Specific target
463
- ```
464
-
465
- Output lives under `dist/binary/<target>/`:
466
-
467
- ```
468
- dist/binary/linux-x64/
469
- ├── kodax # ~60 MB Bun-compiled executable
470
- └── builtin/ # Sidecar built-in skills
471
- ```
472
-
473
- Smoke-test: `dist/binary/<host>/kodax --version`.
474
-
475
- **Automated release**: pushing a `v*` git tag triggers `.github/workflows/release.yml`, which builds all five targets on native runners, runs smoke tests, and publishes a GitHub Release with archives + SHA256SUMS. Use the `workflow_dispatch` button in the Actions UI to test the pipeline without tagging.
476
-
477
- See [docs/release.md](docs/release.md) for full details on build flags, archive layout, troubleshooting, and the build-time `KODAX_BUNDLED` / `KODAX_VERSION` defines.
478
-
479
- ### As Library
480
-
481
- ```bash
482
- npm install @kodax-ai/kodax
483
- ```
484
-
485
- ```typescript
486
- import { runKodaX } from '@kodax-ai/kodax';
487
-
488
- process.env.ZHIPU_API_KEY = process.env.ZHIPU_API_KEY ?? 'your_api_key';
489
-
490
- const result = await runKodaX({
491
- provider: 'zhipu-coding',
492
- reasoningMode: 'auto',
493
- events: {
494
- onTextDelta: (text) => process.stdout.write(text),
495
- onComplete: () => console.log('\nDone!'),
496
- },
497
- }, 'your task');
498
-
499
- console.log(result.lastText);
500
- ```
501
-
502
- #### SDK Subpath Imports (v0.7.39+)
503
-
504
- For smaller surface and tree-shake-friendly imports, the SDK is also exposed via subpath exports — pick only the package(s) you need:
505
-
506
- ```typescript
507
- import { Runner } from '@kodax-ai/kodax/agent'; // agent runtime
508
- import { getProvider } from '@kodax-ai/kodax/llm'; // LLM abstraction (14 aliases)
509
- import { runKodaX } from '@kodax-ai/kodax/coding'; // coding tools + prompts
510
- import { SkillRegistry } from '@kodax-ai/kodax/skills'; // zero-dep skill loader
511
- import { loadConfig } from '@kodax-ai/kodax/repl'; // REPL config / session helpers
512
- import { createMcpManager } from '@kodax-ai/kodax/mcp'; // MCP popout manager (v0.7.42)
513
- import { listSessions } from '@kodax-ai/kodax/session'; // session history helpers
514
- ```
515
-
516
- All 8 SDK entries (root + 7 subpaths) share internal code via ESM chunk splitting — importing from `/agent` does not pull in `/repl`'s Ink + React surface.
517
-
518
- > **ESM-only.** The SDK is published as ES Modules. In a CommonJS context (Electron main process, legacy Webpack CJS bundles, `require()`-based code) you must use `await import(...)` instead of `require()`. See [docs/SDK_EMBEDDER_GUIDE.md §5](docs/SDK_EMBEDDER_GUIDE.md#5-consuming-from-a-commonjs-context-electron-main-cjs-bundles) for the canonical recipe + the technical reason most subpaths cannot ship a dual ESM/CJS build.
519
-
520
- For CLI users, provider defaults live in `~/.kodax/config.json`. For library users, API keys are still read from environment variables; if you need custom base URLs or provider aliases, use `registerCustomProviders()` as shown above.
521
-
522
- ---
523
-
524
- ## Usage
525
-
526
- ### REPL Quickstart
527
-
528
- Running `kodax` with no prompt starts the interactive REPL.
529
-
530
- ```bash
531
- kodax
532
- ```
533
-
534
- Inside the REPL you can type normal requests or slash commands:
535
-
536
- ```text
537
- Read package.json and summarize the architecture
538
- /model
539
- /mode
540
- /help
541
- ```
542
-
543
- ### CLI Quickstart
544
-
545
- ```bash
546
- # Set API key
547
- export ZHIPU_API_KEY=your_api_key
548
-
549
- # Basic usage
550
- kodax "Help me create a TypeScript project"
551
-
552
- # Choose a provider explicitly
553
- kodax --provider openai --model gpt-5.4 "Create a REST API"
554
-
555
- # Use a deeper reasoning mode
556
- kodax --reasoning deep "Review this architecture"
557
- ```
558
-
559
- ### Session Workflows
560
-
561
- Use a session when you want memory across turns. Without a session, each CLI call is independent.
562
-
563
- ```bash
564
- # No memory: two separate calls
565
- kodax "Read src/auth.ts"
566
- kodax "Summarize it"
567
-
568
- # With memory: same session
569
- kodax --session my-project "Read package.json"
570
- kodax --session my-project "Summarize it"
571
- kodax --session my-project "How should I fix the first issue?"
572
-
573
- # Session management
574
- kodax --session list
575
- kodax --session resume "continue"
576
- ```
577
-
578
- ### Session Patterns
579
-
580
- ```bash
581
- # ❌ No memory: two independent calls
582
- kodax "Read src/auth.ts" # Agent reads and responds
583
- kodax "Summarize it" # Agent doesn't know what to summarize
584
-
585
- # With memory: same session
586
- kodax --session auth-review "Read src/auth.ts"
587
- kodax --session auth-review "Summarize it" # Agent knows to summarize auth.ts
588
- kodax --session auth-review "How to fix first issue" # Agent has context
589
- ```
590
-
591
- ### Workflow Examples
592
-
593
- ```bash
594
- # Code review (multi-turn conversation)
595
- kodax --session review "Review src/ directory"
596
- kodax --session review "Focus on security issues"
597
- kodax --session review "Give me fix suggestions"
598
-
599
- # Project development (continuous session)
600
- kodax --session todo-app "Create a Todo application"
601
- kodax --session todo-app "Add delete functionality"
602
- kodax --session todo-app "Write tests"
603
- ```
604
-
605
- ### CLI Reference
606
-
607
- ```text
608
- kodax Start the interactive REPL
609
- -h, --help [topic] Show help or topic help
610
- -p, --print <text> Run a single task and exit
611
- -c, --continue Continue the most recent conversation in this directory
612
- -r, --resume [id] Resume a session by ID, or the latest session
613
- -m, --provider Provider to use
614
- --model <name> Override the model
615
- --reasoning <mode> off | auto | quick | balanced | deep
616
- -t, --thinking Compatibility alias for --reasoning auto
617
- -s, --session <op> Session ID or legacy session operation
618
- -j, --parallel Enable parallel tool execution
619
- --max-iter <n> Max iterations
620
- ```
621
-
622
- ### Permission Control
623
-
624
- KodaX provides 3 permission modes for fine-grained control:
625
-
626
- | Mode | Description | Tools Need Confirmation |
627
- |------|-------------|------------------------|
628
- | `plan` | Read-only planning mode | All modification tools blocked |
629
- | `accept-edits` | Auto-accept file edits | bash only |
630
- | `auto-in-project` | Full auto within project | None (project-scoped) |
631
-
632
- ```bash
633
- # In REPL, use /mode command
634
- /mode plan # Switch to plan mode (read-only)
635
- /mode accept-edits # Switch to accept-edits mode
636
- /mode auto-in-project # Switch to auto-in-project mode
637
- /auto # Alias for auto-in-project
638
-
639
- # Check current mode
640
- /mode
641
- ```
642
-
643
- **Features:**
644
- - In `accept-edits` mode, choosing "always" can persist safe Bash allow-patterns
645
- - Plan mode includes system prompt context for LLM awareness
646
- - Permanent protection zones: `.kodax/`, `~/.kodax/`, paths outside project
647
- - Pattern-based permission: Allow specific Bash commands (e.g., `Bash(npm install)`)
648
- - Unified diff display for write/edit operations
649
-
650
- ### CLI Help Topics
651
-
652
- Get detailed help for specific topics:
653
-
654
- ```bash
655
- # Basic help
656
- kodax -h
657
- kodax --help
658
-
659
- # Detailed topic help
660
- kodax -h sessions # Session management details
661
- kodax -h init # Long-running project initialization
662
- kodax -h project # Project mode / harness workflow
663
- kodax -h auto # Auto-continue mode
664
- kodax -h provider # LLM provider configuration
665
- kodax -h thinking # Thinking/reasoning mode
666
- kodax -h team # Multi-agent parallel execution
667
- kodax -h print # Print configuration
668
- ```
669
-
670
- ### Environment Variables
671
-
672
- KodaX recognizes a number of environment variables for tuning runtime behavior. The most commonly used ones are listed below; for the full list, search the repo for `process.env.KODAX_`.
673
-
674
- #### `KODAX_MAX_OUTPUT_TOKENS`
675
-
676
- Overrides the per-turn `max_tokens` value sent to **every** provider (Anthropic, OpenAI, Zhipu, Kimi, MiniMax, Qwen, DeepSeek, MiMo, Gemini, Codex, …). Set to a positive integer; unset or non-numeric values are ignored. This is an **explicit user intent**: when set, it wins over the provider's model descriptor cap, over the provider config default, and over the global `KODAX_MAX_TOKENS` fallback. RST defense is handled at the provider config layer (`streamMaxDurationMs` watchdog + non-streaming fallback in `packages/llm/src/providers/registry.ts`), so this variable is purely an output-budget knob.
677
-
678
- ```bash
679
- # Allow up to 48K output tokens per turn (use a higher cap when generating long files)
680
- export KODAX_MAX_OUTPUT_TOKENS=48000
681
- kodax "generate the full implementation"
682
-
683
- # Unset to restore default behavior
684
- unset KODAX_MAX_OUTPUT_TOKENS
685
- ```
686
-
687
- Precedence used by every provider's `getEffectiveMaxOutputTokens()` (see `packages/llm/src/providers/base.ts`):
688
-
689
- 1. One-shot per-request override (agent-loop escalation / context-overflow recovery — internal)
690
- 2. **`KODAX_MAX_OUTPUT_TOKENS`** (this variable, explicit user intent)
691
- 3. Active model descriptor's `maxOutputTokens` (FEATURE_098 per-model cap)
692
- 4. Provider config default
693
- 5. Global `KODAX_MAX_TOKENS` fallback
694
-
695
- Related variables: `KODAX_MAX_TOKENS` (global fallback when no provider/model cap applies), `KODAX_ESCALATED_MAX_OUTPUT_TOKENS` (escalation budget used by the agent loop when a turn returns `stop_reason: max_tokens`).
696
-
697
- > **Retired in v0.7.42**: `KODAX_RST_PRONE_PROVIDERS` and `KODAX_WRITE_TURN_MAX_TOKENS` (the v0.7.28 P2b write-turn cap mechanism) are no longer recognized. The 2026-04 bench measured RST as time-based (zhipu-coding 308s server kill window), not payload-size-based, so the cap was retired in favor of the per-provider `streamMaxDurationMs` watchdog + non-streaming fallback chain (configured in `registry.ts`). Existing env exports become silent no-ops; remove them from shell profiles when convenient.
698
-
699
- #### Sidecar verifier diagnostics
700
-
701
- Use these when diagnosing Worker text-only completion stalls or custom provider verifier behavior:
702
-
703
- ```bash
704
- export KODAX_VERIFIER_LOG=1
705
- export KODAX_VERIFIER_PROVIDER=anthropic
706
- export KODAX_VERIFIER_MODEL=claude-haiku-4-5-20251001
707
- ```
708
-
709
- - `KODAX_VERIFIER_LOG=1` shows verifier gate/elapsed/trace information and is equivalent to `"verifierLog": true` in `~/.kodax/config.json`.
710
- - `KODAX_VERIFIER_PROVIDER` + `KODAX_VERIFIER_MODEL` route the verifier to a separate provider/model instead of inheriting the main Worker model. Set both together.
711
- - `KODAX_VERIFIER_ALWAYS=1` forces the verifier to fire on every text-only completion for debugging/regression sweeps.
712
-
713
- ## Advanced Library Usage
714
-
715
- #### Simple Mode (runKodaX)
716
-
717
- ```typescript
718
- import { runKodaX, KodaXEvents } from '@kodax-ai/kodax';
719
-
720
- const events: KodaXEvents = {
721
- onTextDelta: (text) => process.stdout.write(text),
722
- onThinkingDelta: (text) => console.log(`Thinking delta: ${text.length} chars`),
723
- onToolResult: (result) => console.log(`Tool ${result.name}: ${result.content.slice(0, 100)}`),
724
- onComplete: () => console.log('\nDone!'),
725
- onError: (e) => console.error(e.message),
726
- };
727
-
728
- const result = await runKodaX({
729
- provider: 'zhipu-coding',
730
- reasoningMode: 'auto',
731
- events,
732
- }, 'What is 1+1?');
733
-
734
- console.log(result.lastText);
735
- ```
736
-
737
- #### Continuous Session (KodaXClient)
738
-
739
- ```typescript
740
- import { KodaXClient } from '@kodax-ai/kodax';
741
-
742
- const client = new KodaXClient({
743
- provider: 'zhipu-coding',
744
- reasoningMode: 'auto',
745
- events: {
746
- onTextDelta: (t) => process.stdout.write(t),
747
- },
748
- });
749
-
750
- // First message
751
- await client.send('Read package.json');
752
-
753
- // Continue same session
754
- await client.send('Summarize it');
755
-
756
- console.log(client.getSessionId());
757
- ```
758
-
759
- #### Custom Session Storage
760
-
761
- ```typescript
762
- import { runKodaX, KodaXSessionStorage, KodaXMessage } from '@kodax-ai/kodax';
763
-
764
- class MyDatabaseStorage implements KodaXSessionStorage {
765
- async save(id: string, data: { messages: KodaXMessage[]; title: string; gitRoot: string }) {
766
- // Save to your database
767
- }
768
- async load(id: string) {
769
- // Load from your database
770
- return null;
771
- }
772
- }
773
-
774
- await runKodaX({
775
- provider: 'zhipu-coding',
776
- session: {
777
- id: 'my-session-123',
778
- storage: new MyDatabaseStorage(),
779
- },
780
- events: { ... },
781
- }, 'task');
782
- ```
783
-
784
- ### Library Modes Comparison
785
-
786
- | Feature | runKodaX | KodaXClient |
787
- |---------|----------|-------------|
788
- | **Message Memory** | No | Yes |
789
- | **Call Style** | Function | Class instance |
790
- | **Context** | Independent each time | Accumulates |
791
- | **Use Case** | Single tasks, batch processing | Interactive dialogue, multi-step tasks |
792
-
793
- ---
794
-
795
- ## SDK Usage
796
-
797
- KodaX ships as a single npm package `@kodax-ai/kodax` with 7 SDK subpath exports (ADR-024 v0.7.39 + ADR-032 v0.7.42 + ADR-038 v0.7.49). Each subpath is tree-shake-friendly so consumers pull only what they need:
798
-
799
- ```bash
800
- npm install @kodax-ai/kodax
801
- ```
802
-
803
- ```typescript
804
- import { runKodaX } from '@kodax-ai/kodax'; // root: CLI helpers + runKodaX
805
- import { Runner, runFanOut } from '@kodax-ai/kodax/agent'; // generic Agent framework
806
- import { getProvider } from '@kodax-ai/kodax/llm'; // 14-alias LLM abstraction
807
- import { KODAX_TOOLS } from '@kodax-ai/kodax/coding'; // tools + prompts + agent loop
808
- import { runInkInteractiveMode } from '@kodax-ai/kodax/repl'; // Ink TUI entrypoint
809
- import { SkillRegistry } from '@kodax-ai/kodax/skills'; // zero-dep skill loader
810
- import { createMcpManager } from '@kodax-ai/kodax/mcp'; // MCP popout manager (v0.7.42)
811
- import { listSessions } from '@kodax-ai/kodax/session'; // session history helpers
812
- ```
813
-
814
- > The SDK is **ESM-only**. CommonJS consumers (Electron main / Webpack CJS / `require()` callers) must use `await import('@kodax-ai/kodax/...')` — see [docs/SDK_EMBEDDER_GUIDE.md §5](docs/SDK_EMBEDDER_GUIDE.md#5-consuming-from-a-commonjs-context-electron-main-cjs-bundles).
815
-
816
- ### `@kodax-ai/kodax/llm` — LLM Abstraction
817
-
818
- 14 built-in provider aliases (Anthropic, OpenAI, DeepSeek, Kimi, Kimi-Code, Qwen, Zhipu, Zhipu-Coding, MiniMax-Coding, MiMo, MiMo-Coding, Ark-Coding, Gemini-CLI, Codex-CLI) + custom provider registration.
819
-
820
- ```typescript
821
- import { getProvider, KodaXBaseProvider } from '@kodax-ai/kodax/llm';
822
-
823
- const provider = getProvider('anthropic');
824
- const stream = await provider.streamCompletion(
825
- [{ role: 'user', content: 'Hello!' }],
826
- { onTextDelta: (text) => process.stdout.write(text) }
827
- );
828
-
829
- for await (const result of stream) {
830
- if (result.type === 'text') { /* … */ }
831
- else if (result.type === 'tool_use') { /* … */ }
832
- }
833
- ```
834
-
835
- **Key Features**: unified provider interface · streaming · reasoning modes (`off/auto/quick/balanced/deep`) · per-provider retry + error handling · zero business-logic dependencies.
836
-
837
- ### `@kodax-ai/kodax/agent` Agent Framework (standalone-consumable)
838
-
839
- ADR-021 standalone-consumable: `@kodax-ai/agent` has **zero inbound `@kodax-ai/coding` dependency** you can wire any tool surface on top of it.
840
-
841
- ```typescript
842
- import {
843
- Runner,
844
- runFanOut,
845
- runWithIdleYield,
846
- registerChildTask,
847
- type ChildTaskRegistry,
848
- generateSessionId,
849
- estimateTokens,
850
- DefaultSummaryCompaction,
851
- } from '@kodax-ai/kodax/agent';
852
-
853
- // Bounded-concurrency fan-out with abort + structured progress events (v0.7.39 FEATURE_120)
854
- const result = await runFanOut({
855
- bundles: [{ id: 'a', task: 'audit-foo' }, { id: 'b', task: 'audit-bar' }],
856
- maxParallel: 4,
857
- run: async (bundle) => doWork(bundle),
858
- });
859
-
860
- // Idle-yield wait — pause when out of useful work, resume when a wake event arrives
861
- await runWithIdleYield({ runOnce, computeSnapshot, registry, messageQueue, agentId });
862
-
863
- // Pluggable compaction policy (FEATURE_081)
864
- const policy = new DefaultSummaryCompaction({ thresholdRatio: 0.8, keepRecent: 10 });
865
- ```
866
-
867
- **Key Features**: `Runner` + per-step lifecycle · `runFanOut` (bounded-concurrency + abort + progress events) · `runWithIdleYield` (chat-while-waiting) · `ChildTaskRegistry` / `TaskAbortRegistry` · session-id generation · tiktoken-based token estimation · `CompactionPolicy` interface.
868
-
869
- ### `@kodax-ai/kodax/skills` Skills System
870
-
871
- Zero external dependencies. Markdown-based skill files with natural-language triggers and variable resolution.
872
-
873
- ```typescript
874
- import {
875
- SkillRegistry,
876
- discoverSkills,
877
- executeSkill,
878
- type SkillContext,
879
- } from '@kodax-ai/kodax/skills';
880
-
881
- const skills = await discoverSkills(['/path/to/skills']);
882
- const registry = new SkillRegistry();
883
- await registry.registerSkills(skills);
884
-
885
- const result = await executeSkill({
886
- skillId: 'code-review',
887
- arguments: { target: 'src/' },
888
- workingDirectory: process.cwd(),
889
- });
890
- ```
891
-
892
- **Key Features**: zero deps · markdown-based skill files · natural-language triggering · variable resolution · built-in skills included.
893
-
894
- ### `@kodax-ai/kodax/coding` Coding Agent
895
-
896
- Complete coding agent: 50+ tools (`read`/`write`/`edit`/`bash`/`grep`/`glob`/`dispatch_child_task`/`send_message`/`task_stop`/...) + Worker role prompt + Sidecar Verifier (out-of-band Stop-hook) + agent loop + auto-continue + session management.
897
-
898
- ```typescript
899
- import { runKodaX, KodaXClient, KODAX_TOOLS } from '@kodax-ai/kodax/coding';
900
-
901
- // Single-task helper
902
- const result = await runKodaX({
903
- provider: 'zhipu-coding',
904
- reasoningMode: 'auto',
905
- events: { onTextDelta: (text) => process.stdout.write(text) },
906
- }, 'Read package.json and explain the dependencies');
907
-
908
- // Continuous session
909
- const client = new KodaXClient({
910
- provider: 'anthropic',
911
- reasoningMode: 'auto',
912
- events: { /* … */ },
913
- });
914
- await client.send('Create a new file');
915
- await client.send('Add a function to it'); // Has context from previous message
916
- ```
917
-
918
- **Key Features**: 50+ built-in tools (see [Tools](#tools)) · V2 Worker single-loop + Sidecar Verifier (FEATURE_184 v0.7.42 / V1 chain fully retired by FEATURE_193 v0.7.43) · async child steering via `send_message` / `task_stop` (FEATURE_120, v0.7.39) · idle-yield wait mechanic (FEATURE_155, v0.7.38) · specialist routing via `subagent_type` (FEATURE_191, v0.7.43) · auto-continue · session lineage.
919
-
920
- ### `@kodax-ai/kodax/repl` Interactive Terminal UI
921
-
922
- Ink/React-based interactive REPL. Permission modes, command system, themed streaming display.
923
-
924
- ```typescript
925
- import { runInkInteractiveMode } from '@kodax-ai/kodax/repl';
926
-
927
- // Usually used via the `kodax` bin command; can be embedded:
928
- // - Interactive terminal UI (Ink components)
929
- // - Permission control (auto/plan/accept-edits modes)
930
- // - Command system (/help, /mode, /clear, /status, …)
931
- // - Skills integration
932
- // - Theme support
933
- await runInkInteractiveMode({ provider: 'zhipu-coding', reasoningMode: 'auto' });
934
- ```
935
-
936
- **Key Features**: Ink-based React components · 3 permission modes (auto / plan / accept-edits) · built-in commands · real-time streaming display · context-usage indicator.
937
-
938
- ### Package Dependency Graph (workspace internal)
939
-
940
- ```
941
- @kodax-ai/llm (zero business-logic deps)
942
-
943
- @kodax-ai/agent (depends @kodax-ai/llm; ADR-021 standalone-consumable;
944
- inlines session-lineage + capabilities/{mcp,skills} +
945
- tracing per ADR-036 v0.7.43)
946
-
947
- @kodax-ai/coding (depends llm + agent; inlines repo-intelligence/protocol per ADR-036)
948
-
949
- @kodax-ai/repl (depends coding + ink + react)
950
- ```
951
-
952
- **Subpath Recommendations**:
953
-
954
- | Use Case | Subpath | Why |
955
- |----------|---------|-----|
956
- | Only need LLM abstraction | `@kodax-ai/kodax/llm` | Minimal deps; 14 built-in aliases |
957
- | Building custom agent | `@kodax-ai/kodax/agent` | Runner + fan-out + idle-yield + session-lineage + capabilities |
958
- | Coding tasks | `@kodax-ai/kodax/coding` | Complete coding agent + tools |
959
- | Terminal app | `@kodax-ai/kodax/repl` | Full interactive experience |
960
-
961
- ---
962
-
963
- | Provider | Environment Variable | Reasoning Support | Default Model |
964
- |----------|----------------------|-------------------|---------------|
965
- | anthropic | `ANTHROPIC_API_KEY` | Native | claude-sonnet-4-6 (`claude-opus-4-6` / `claude-haiku-4-5` via `/model`) |
966
- | openai | `OPENAI_API_KEY` | Native | gpt-5.3-codex (`gpt-5.4` / `gpt-5.3-codex-spark` via `/model`) |
967
- | kimi | `KIMI_API_KEY` | Native | kimi-k2.6 (`kimi-k2.7-code` 256K / `k2.5` via `/model`) |
968
- | kimi-code | `KIMI_CODE_API_KEY` | Native | kimi-for-coding |
969
- | qwen | `QWEN_API_KEY` | Native | qwen3.5-plus |
970
- | zhipu | `ZHIPU_API_KEY` | Native | glm-5 (`glm-5.2` 1M ctx / `glm-5.1` / `glm-5-turbo` via `/model`) |
971
- | zhipu-coding | `ZHIPU_CODING_API_KEY` | Native | glm-5 (`glm-5.2` 1M ctx / `glm-5.1` / `glm-5-turbo` via `/model`) |
972
- | minimax-coding | `MINIMAX_CODING_API_KEY` | Native | MiniMax-M2.7 (`MiniMax-M3` Frontier Coding, native multimodal + 1M ctx, plus `MiniMax-M2.7-highspeed` via `/model`) |
973
- | mimo | `MIMO_API_KEY` | Native | mimo-v2.5-pro (Xiaomi MiMo pay-per-token, Anthropic-compat) |
974
- | mimo-coding | `MIMO_CODING_API_KEY` | Native | mimo-v2.5-pro (Xiaomi Token Plan, Anthropic-compat) |
975
- | ark-coding | `ARK_CODING_API_KEY` | Native | glm-5.1 (Volcengine Ark Coding Plan: GLM, Kimi, MiniMax M3/M2.7, DeepSeek V3.2/V4, Doubao Seed 2.0 routes) |
976
- | deepseek | `DEEPSEEK_API_KEY` | Native | deepseek-v4-flash (`deepseek-v4-pro` via `/model`) |
977
- | gemini-cli | `GEMINI_API_KEY` | Prompt-only / CLI bridge | (via gemini CLI) |
978
- | codex-cli | `OPENAI_API_KEY` | Prompt-only / CLI bridge | (via codex CLI) |
979
-
980
- > **Custom providers**: any OpenAI- or Anthropic-compatible endpoint can be added via `customProviders[]` in `~/.kodax/config.json` (CLI) or `registerCustomProviders()` (library). See the [Quick Start](#2-configure-a-provider) for the configuration shape.
981
-
982
- ### Examples
983
-
984
- ```bash
985
- # Use Zhipu Coding
986
- kodax --provider zhipu-coding --thinking "Help me optimize this code"
987
-
988
- # Use OpenAI
989
- export OPENAI_API_KEY=your_key
990
- kodax --provider openai "Create a REST API"
991
-
992
- # Resume last session
993
- kodax --session resume
994
-
995
- # List all sessions
996
- kodax --session list
997
-
998
- # Parallel tool execution
999
- kodax --parallel "Read package.json and tsconfig.json"
1000
-
1001
- # Adaptive multi-agent (AMA) mode — V2 Worker single-loop with `dispatch_child_task` fan-out
1002
- kodax --agent-mode ama "Analyze code structure, check test coverage, find bugs"
1003
- ```
1004
-
1005
- ---
1006
-
1007
- ## Tools
1008
-
1009
- KodaX ships 50+ built-in tools, grouped below. They are registered as a single flat tool surface to the LLM; the categories here are just for navigation.
1010
-
1011
- ### File operations
1012
- | Tool | Description |
1013
- |------|-------------|
1014
- | `read` | Read file contents (supports offset/limit) |
1015
- | `write` | Write a new file or fully rewrite an existing one |
1016
- | `edit` | Exact string replacement (supports `replace_all`) |
1017
- | `multi_edit` | Atomic batch of independent edits to one file |
1018
- | `insert_after_anchor` | Insert content after a unique anchor without rewriting the file |
1019
- | `undo` | Revert the last file modification |
1020
-
1021
- ### Shell & search
1022
- | Tool | Description |
1023
- |------|-------------|
1024
- | `bash` | Execute a shell command (supports `run_in_background`, output truncation) |
1025
- | `glob` | Find files by pattern |
1026
- | `grep` | Regex content search (context lines, multiline, file-type filter, pagination) |
1027
- | `code_search` | Lower-noise code search (extension-provider aware) |
1028
- | `semantic_lookup` | Symbol/module/process-aware search backed by repo intelligence |
1029
- | `web_search` | Discovery-oriented web search with trust + freshness signals |
1030
- | `web_fetch` | Fetch a specific URL with provenance hints |
1031
-
1032
- ### Repo Intelligence (working tools)
1033
- | Tool | Description |
1034
- |------|-------------|
1035
- | `repo_overview` | Summarize structure, key areas, entry hints, intelligence snapshot |
1036
- | `changed_scope` | Which files/areas/categories the current diff touches |
1037
- | `changed_diff` | Paged diff slice for a single file |
1038
- | `changed_diff_bundle` | Paged diff slices for multiple files in one call |
1039
- | `module_context` | Module capsule (deps, entries, symbols, tests, docs) |
1040
- | `symbol_context` | Definition + probable callers/callees + alternatives |
1041
- | `process_context` | Approximate static execution capsule for an entry |
1042
- | `impact_estimate` | Blast radius for a symbol/path/module |
1043
-
1044
- ### MCP capabilities (when MCP servers are configured)
1045
- | Tool | Description |
1046
- |------|-------------|
1047
- | `mcp_search` / `mcp_describe` / `mcp_call` | Discover and invoke MCP tools through the shared capability runtime |
1048
- | `mcp_read_resource` / `mcp_get_prompt` | Read MCP resources and prompts |
1049
-
1050
- ### Git worktree
1051
- | Tool | Description |
1052
- |------|-------------|
1053
- | `worktree_create` | Create a new worktree on an isolated branch for safe agent work |
1054
- | `worktree_remove` | Remove a worktree (with safety checks) |
1055
-
1056
- ### Agent control & UX
1057
- | Tool | Description |
1058
- |------|-------------|
1059
- | `dispatch_child_task` | Spawn a sub-agent for an independent investigation/edit task. Optional `model_hint: 'fast' \| 'balanced' \| 'deep'` (advisory; routing no-op until FEATURE_102 v0.7.45). |
1060
- | `send_message` | Append an instruction to an in-flight child's queue — surfaces as `<coordinator-instruction>` at the child's next turn boundary. Coordinator-only. (FEATURE_120, v0.7.39) |
1061
- | `task_stop` | Request graceful exit of a specific child. Current tool finishes atomically, then the child sees a `<coordinator-stop-request>` and emits a final summary. Coordinator-only. (FEATURE_120, v0.7.39) |
1062
- | `ask_user_question` | Single/multi-select or free-text prompt back to the user |
1063
- | `exit_plan_mode` | Present a finalized plan for approval (REPL only) |
1064
- | `emit_managed_protocol` | Internal managed-task protocol side-channel for role payloads (verdict). V2 Worker single-loop + Sidecar Verifier is the default since v0.7.42 (FEATURE_184); V1 chain retired in v0.7.43 (FEATURE_193). |
1065
-
1066
- ---
1067
-
1068
- ## Skills System
1069
-
1070
- KodaX includes a built-in Skills system that can be triggered by natural language:
1071
-
1072
- ```bash
1073
- # Natural language triggering (no explicit /skill needed)
1074
- kodax "帮我审查代码" # Triggers code-review skill
1075
- kodax "写测试用例" # Triggers tdd skill
1076
- kodax "提交代码" # Triggers git-workflow skill
1077
-
1078
- # Explicit skill command
1079
- kodax /skill:code-review
1080
- ```
1081
-
1082
- Built-in skills include:
1083
- - **code-review** - Code review and quality analysis
1084
- - **tdd** - Test-driven development workflow
1085
- - **git-workflow** - Git commit and workflow automation
1086
-
1087
- Skills are stored in `~/.kodax/skills/` and can be extended with custom skills.
1088
-
1089
- ---
1090
-
1091
- ## Commands (CLI)
1092
-
1093
- Commands are `/xxx` shortcuts in CLI:
1094
-
1095
- ```bash
1096
- kodax /review src/auth.ts
1097
- kodax /test
1098
- ```
1099
-
1100
- Commands are stored in `~/.kodax/commands/`:
1101
- - `.md` files → Prompt commands (content used as prompt)
1102
- - `.ts/.js` files Programmable commands
1103
-
1104
- ---
1105
-
1106
- ## API Exports
1107
-
1108
- ```typescript
1109
- // Main functions
1110
- export { runKodaX, KodaXClient };
1111
-
1112
- // Types
1113
- export type {
1114
- KodaXEvents, KodaXOptions, KodaXResult,
1115
- KodaXMessage, KodaXContentBlock,
1116
- KodaXSessionStorage, KodaXToolDefinition
1117
- };
1118
-
1119
- // Tools
1120
- export { KODAX_TOOLS, KODAX_TOOL_REQUIRED_PARAMS, executeTool };
1121
-
1122
- // Providers
1123
- export { getProvider, KODAX_PROVIDERS, KodaXBaseProvider };
1124
-
1125
- // Utilities
1126
- export {
1127
- estimateTokens,
1128
- getGitRoot, getGitContext, getEnvContext, getProjectSnapshot,
1129
- checkPromiseSignal
1130
- };
1131
- ```
1132
-
1133
- ---
1134
-
1135
- ## Development
1136
-
1137
- ```bash
1138
- # Development mode (using tsx)
1139
- npm run dev "your task"
1140
-
1141
- # Build
1142
- npm run build
1143
-
1144
- # Optional: only build workspace packages
1145
- npm run build:packages
1146
-
1147
- # Build standalone binary (current platform / all platforms)
1148
- npm run build:binary
1149
- npm run build:binary:all
1150
-
1151
- # Run tests
1152
- npm test
1153
-
1154
- # Eval-driven development tests (provider matrices, identity round-trip, etc.)
1155
- npm run test:eval
1156
-
1157
- # Clean
1158
- npm run clean
1159
- ```
1160
-
1161
- ### Repo Intelligence cache directories
1162
-
1163
- KodaX now uses two repo-intelligence cache locations on disk:
1164
-
1165
- - `.agent/repo-intelligence/`
1166
- - OSS baseline repo-intelligence artifacts and existing task-engine snapshots.
1167
- - `.repointel/`
1168
- - Premium `repointel` workspace cache shared by the local daemon/native frontdoor.
1169
-
1170
- They are intentionally separated so:
1171
-
1172
- - OSS fallback stays available even when premium is disabled or unavailable.
1173
- - Premium cache does not pollute OSS artifacts.
1174
- - KodaX and other hosts can share the same premium workspace cache.
1175
-
1176
- `.repointel/` is a local generated directory and should not be committed.
1177
-
1178
- ---
1179
-
1180
- ## Code Style
1181
-
1182
- ### Comment Guidelines
1183
-
1184
- KodaX uses an **English-first** comment style with selective Chinese brief notes for complex logic.
1185
-
1186
- | Situation | Style | Example |
1187
- |-----------|-------|---------|
1188
- | Import/Export | English only | `// Import dependencies` |
1189
- | Simple constants | English only | `// Max retry count` |
1190
- | Simple logic | English only | `// Return if null` |
1191
- | **Business rules** | English + Chinese | `// Skip tool_result - 跳过工具结果块` |
1192
- | **Platform compatibility** | English + Chinese | `// Windows path handling - Windows 路径处理` |
1193
- | **Performance optimization** | English + Chinese | `// Debounce to prevent flicker - 防抖避免闪烁` |
1194
-
1195
- ---
1196
-
1197
- ## Documentation
1198
-
1199
- - [README_CN.md](README_CN.md) - Chinese Documentation
1200
- - [docs/release.md](docs/release.md) - Standalone binary build & release pipeline
1201
- - [docs/PRD.md](docs/PRD.md) - Product Requirements
1202
- - [docs/ADR.md](docs/ADR.md) - Architecture Decisions
1203
- - [docs/HLD.md](docs/HLD.md) - High-Level Design
1204
- - [docs/DD.md](docs/DD.md) - Detailed Design
1205
- - [docs/FEATURE_LIST.md](docs/FEATURE_LIST.md) - Feature Tracking
1206
- - [docs/test-guides/](docs/test-guides/) - Feature-specific test guides
1207
- - [CHANGELOG.md](CHANGELOG.md) - Version History (v0.7.0+; [archive](docs/CHANGELOG_ARCHIVE.md) for older)
1208
-
1209
- ---
1210
-
1211
- ## License
1212
-
1213
- [Apache License 2.0](LICENSE) - Copyright 2026 [icetomoyo](mailto:icetomoyo@gmail.com)
1
+ <p align="center">
2
+ <picture>
3
+ <source media="(prefers-color-scheme: dark)" srcset="assets/logo-dark.svg">
4
+ <source media="(prefers-color-scheme: light)" srcset="assets/logo-light.svg">
5
+ <img src="assets/logo-light.svg" alt="KodaX" width="640">
6
+ </picture>
7
+ </p>
8
+
9
+ <p align="center">
10
+ <b>Open-source AI coding agent on every LLM you can reach.</b><br>
11
+ Anthropic · OpenAI · DeepSeek · Kimi · Zhipu · MiniMax · MiMo · Ark · Qwen · Gemini · Codex.<br>
12
+ REPL · CLI · library · Node-free single binary.
13
+ </p>
14
+
15
+ <p align="center">
16
+ <a href="https://www.npmjs.com/package/@kodax-ai/kodax"><img alt="npm version" src="https://img.shields.io/npm/v/@kodax-ai/kodax?style=flat-square&color=cb3837"></a>
17
+ <a href="LICENSE"><img alt="license" src="https://img.shields.io/badge/license-Apache--2.0-blue?style=flat-square"></a>
18
+ <a href="https://github.com/icetomoyo/KodaX/stargazers"><img alt="GitHub stars" src="https://img.shields.io/github/stars/icetomoyo/KodaX?style=flat-square&logo=github&color=f1c40f"></a>
19
+ <a href="https://github.com/icetomoyo/KodaX/actions"><img alt="CI" src="https://img.shields.io/github/actions/workflow/status/icetomoyo/KodaX/release.yml?style=flat-square&label=release"></a>
20
+ <img alt="providers" src="https://img.shields.io/badge/LLMs-14_aliases_+_custom-2ecc71?style=flat-square">
21
+ </p>
22
+
23
+ <p align="center">
24
+ <a href="#install-in-30-seconds">Install</a> ·
25
+ <a href="#four-ways-to-use-kodax">Usage</a> ·
26
+ <a href="#sdk-usage">SDK</a> ·
27
+ <a href="CHANGELOG.md">Changelog</a> ·
28
+ <a href="docs/FEATURE_LIST.md">Roadmap</a> ·
29
+ <a href="https://github.com/icetomoyo/KodaX/discussions">Discussions</a> ·
30
+ <a href="README_CN.md">中文 README</a>
31
+ </p>
32
+
33
+ <p align="center">
34
+ <img src="kodax.gif" alt="KodaX in action" width="880">
35
+ </p>
36
+
37
+ ---
38
+
39
+ ## Install in 30 seconds
40
+
41
+ ```bash
42
+ npm i -g @kodax-ai/kodax
43
+
44
+ # Pick any one you have an API key for:
45
+ export ZHIPU_API_KEY=... # or ANTHROPIC_API_KEY / OPENAI_API_KEY / KIMI_API_KEY /
46
+ # MINIMAX_API_KEY / MIMO_API_KEY / ARK_API_KEY / QWEN_API_KEY /
47
+ # DEEPSEEK_API_KEY / GEMINI_API_KEY
48
+
49
+ kodax
50
+ ```
51
+
52
+ That's it. You're in the REPL — ask anything in natural language.
53
+
54
+ > **No-Node target machines:** download a Bun-compiled single binary for Windows / macOS / Linux × x64 + arm64 from the [GitHub Releases](https://github.com/icetomoyo/KodaX/releases) page. See [docs/release.md](docs/release.md) for the build pipeline.
55
+
56
+ ---
57
+
58
+ ## Four ways to use KodaX
59
+
60
+ | Form | Command / Import | When to use it |
61
+ |---|---|---|
62
+ | **REPL** | `kodax` | Interactive multi-turn coding session with streaming UI, permissions, slash commands |
63
+ | **CLI** | `kodax -p "your task"` | One-shot scripted task, CI runs, batch processing |
64
+ | **Library** | `import { runKodaX } from '@kodax-ai/kodax'` | Embed in your own tool / agent / web service |
65
+ | **Single binary** | `./kodax` | Distribute to machines that don't have Node installed |
66
+
67
+ ---
68
+
69
+ ## Why KodaX
70
+
71
+ <table>
72
+ <tr>
73
+ <td width="33%" align="center" valign="top">
74
+ <h3>🇨🇳 6 China-native LLMs</h3>
75
+ <sub>Zhipu · Kimi · MiniMax · MiMo · Ark · Qwen</sub>
76
+ <br><br>
77
+ First-class adapters with cross-provider <a href="benchmark/EVAL_GUIDELINES.md">prompt-eval calibration</a> on a canonical 5-alias panel — not OpenAI-compat shims.
78
+ </td>
79
+ <td width="33%" align="center" valign="top">
80
+ <h3>📦 Single-file binary</h3>
81
+ <sub>Bun --compile · Win / macOS / Linux · x64 + arm64</sub>
82
+ <br><br>
83
+ No Node required on the target machine. Drop one file, run anywhere — restricted envs, CI runners, air-gapped boxes.
84
+ </td>
85
+ <td width="33%" align="center" valign="top">
86
+ <h3>🌳 Branchable session lineage</h3>
87
+ <sub>Fork · rewind · parallel edit</sub>
88
+ <br><br>
89
+ Conversation history is a DAG, not a list. Powers the upcoming <b>KodaX Space</b> desktop app.
90
+ </td>
91
+ </tr>
92
+ <tr>
93
+ <td align="center" valign="top">
94
+ <h3>🤖 Multi-agent by default</h3>
95
+ <sub>V2 Worker single-loop + Sidecar Verifier + async children</sub>
96
+ <br><br>
97
+ <code>dispatch_child_task</code>, <code>send_message</code>, <code>task_stop</code>, multi-instance auto-coordination with content-hash safety net.
98
+ </td>
99
+ <td align="center" valign="top">
100
+ <h3>🧩 Skills + self-construction</h3>
101
+ <sub>Markdown skills, NL triggers</sub>
102
+ <br><br>
103
+ 5-stage self-modification staircase (scaffold → validate → stage → test → activate) gated by an 8-invariant admission contract.
104
+ </td>
105
+ <td align="center" valign="top">
106
+ <h3>🛠 50+ built-in tools</h3>
107
+ <sub>File · shell · search · MCP · ACP</sub>
108
+ <br><br>
109
+ Repo intelligence, semantic search, git worktree, web fetch — all addressable through one clean tool surface.
110
+ </td>
111
+ </tr>
112
+ </table>
113
+
114
+ ## How KodaX compares
115
+
116
+ | Feature | **KodaX** | Claude Code | Aider | Codex CLI | Cursor | Cline |
117
+ |---|---|---|---|---|---|---|
118
+ | Open source | ✅ Apache&nbsp;2.0 | ❌ Source-available | ✅ Apache&nbsp;2.0 | ✅ Apache&nbsp;2.0 | ❌ Proprietary | ✅ Apache&nbsp;2.0 |
119
+ | Node-free single binary | ✅ Bun | ❌ Node | ❌ Python | ✅ Rust | ❌ Electron | ❌ Extension |
120
+ | Native China providers<br><sub>(Zhipu · Kimi · MiniMax · MiMo · Ark · Qwen)</sub> | ✅ 6 native | ❌ | ⚠ via LiteLLM | ❌ OpenAI-first | ❌ no provider menu | ⚠ Kimi / Qwen / DeepSeek |
121
+ | Branchable session lineage | ✅ fork & rewind | ⚠ routines / sessions | ❌ | ❌ | ❌ | ⚠ checkpoints |
122
+ | Multi-agent + MCP + 50+ tools | ✅ all three | ✅ all three | ⚠ tools, no MCP | ✅ all three | ⚠ Composer + MCP | ✅ all three |
123
+
124
+ <sub>Data verified May 2026 against public docs ([Claude Code](https://github.com/anthropics/claude-code) · [Aider](https://aider.chat/docs/llms.html) · [Codex CLI](https://github.com/openai/codex) · [Cursor](https://cursor.com) · [Cline](https://github.com/cline/cline)). ⚠ = partial / requires extra setup / not first-class. Corrections welcome via PR.</sub>
125
+
126
+ ## Detailed Setup
127
+
128
+ > The `npm i -g @kodax-ai/kodax` one-liner above is the fastest path. This section is for building from source, configuring custom providers, or using KodaX as a library.
129
+
130
+ ### 1. Build the CLI from source
131
+
132
+ ```bash
133
+ git clone https://github.com/icetomoyo/KodaX.git
134
+ cd KodaX
135
+ npm install
136
+ npm run build
137
+ npm link
138
+ ```
139
+
140
+ ### 2. Configure a provider
141
+
142
+ KodaX reads API keys from environment variables. For built-in providers, the fastest path is:
143
+
144
+ ```bash
145
+ # macOS / Linux
146
+ export ZHIPU_API_KEY=your_api_key
147
+
148
+ # PowerShell
149
+ $env:ZHIPU_API_KEY="your_api_key"
150
+ ```
151
+
152
+ For CLI defaults, create `~/.kodax/config.json`:
153
+
154
+ ```json
155
+ {
156
+ "provider": "zhipu-coding",
157
+ "reasoningMode": "auto"
158
+ }
159
+ ```
160
+
161
+ If you need a custom base URL or an OpenAI/Anthropic-compatible endpoint, define a custom provider in the same config file:
162
+
163
+ ```json
164
+ {
165
+ "provider": "my-openai-compatible",
166
+ "customProviders": [
167
+ {
168
+ "name": "my-openai-compatible",
169
+ "protocol": "openai",
170
+ "baseUrl": "https://example.com/v1",
171
+ "apiKeyEnv": "MY_LLM_API_KEY",
172
+ "model": "my-model",
173
+ "userAgentMode": "compat"
174
+ }
175
+ ]
176
+ }
177
+ ```
178
+
179
+ `userAgentMode` defaults to `"compat"`, which sends `KodaX` instead of the official SDK User-Agent. Switch it to `"sdk"` only when your gateway expects the upstream SDK header.
180
+
181
+ #### OpenAI-compatible reasoning providers
182
+
183
+ Some OpenAI-compatible reasoning models require KodaX to replay the previous assistant turn's `reasoning_content` on later requests. DeepSeek V4 thinking mode is the known load-bearing case. Built-in DeepSeek already opts in; custom providers must say so explicitly:
184
+
185
+ ```json
186
+ {
187
+ "customProviders": [
188
+ {
189
+ "name": "my-deepseek-v4",
190
+ "protocol": "openai",
191
+ "baseUrl": "https://example.com/v1",
192
+ "apiKeyEnv": "MY_DEEPSEEK_API_KEY",
193
+ "model": "deepseek-v4-flash",
194
+ "supportsThinking": true,
195
+ "reasoningCapability": "native-toggle",
196
+ "replayReasoningContent": true
197
+ }
198
+ ]
199
+ }
200
+ ```
201
+
202
+ Keep `replayReasoningContent` unset or `false` for OpenAI proper and gateways that reject unknown assistant-message fields. If one gateway routes mixed models, prefer per-model overrides:
203
+
204
+ ```json
205
+ {
206
+ "models": [
207
+ { "id": "deepseek-v4-flash", "replayReasoningContent": true },
208
+ { "id": "gpt-5", "replayReasoningContent": false }
209
+ ]
210
+ }
211
+ ```
212
+
213
+ Sidecar verifier judge calls use provider-level forced tool choice when supported. If a compatible endpoint rejects the `tool_choice` parameter, KodaX retries that verifier request once without forced tool choice and still fails open rather than blocking the main Worker.
214
+
215
+ #### Opting a custom provider into image / vision input (FEATURE_134 v0.7.40)
216
+
217
+ If your custom provider's underlying model supports image input (vision), add a `capabilityProfile.multimodalSupport: "image-input"` block so KodaX does not artificially block multimodal requests at the SA-path policy gate. Built-in vision-capable aliases (Anthropic, OpenAI, Anthropic-/OpenAI-compatible aliases such as DeepSeek, Kimi, Qwen, Zhipu, MiniMax, MiMo, Ark, plus Gemini-CLI via the CLI's `@<path>` file-include syntax) already ship with this flag enabled by default; Codex-CLI and custom providers need to opt in when their underlying model supports image input.
218
+
219
+ ```json
220
+ {
221
+ "customProviders": [
222
+ {
223
+ "name": "my-vision-provider",
224
+ "protocol": "openai",
225
+ "baseUrl": "https://example.com/v1",
226
+ "apiKeyEnv": "MY_LLM_API_KEY",
227
+ "model": "my-vision-model",
228
+ "capabilityProfile": {
229
+ "transport": "native-api",
230
+ "conversationSemantics": "full-history",
231
+ "mcpSupport": "none",
232
+ "contextFidelity": "full",
233
+ "toolCallingFidelity": "full",
234
+ "sessionSupport": "full",
235
+ "longRunningSupport": "full",
236
+ "multimodalSupport": "image-input",
237
+ "evidenceSupport": "full"
238
+ }
239
+ }
240
+ ]
241
+ }
242
+ ```
243
+
244
+ The serializer layer (`packages/llm/src/providers/anthropic.ts:770` for Anthropic-compat, `openai.ts:904` for OpenAI-compat) forwards image blocks automatically through base-class inheritance. The flag only gates whether KodaX's policy layer pre-rejects multimodal requests — the model-level vision contract remains your upstream provider's responsibility. If the model is actually text-only, you'll see the real upstream API error instead of a KodaX-side rejection.
245
+
246
+ ### 3. Start in REPL or run a one-shot task
247
+
248
+ ```bash
249
+ # Interactive REPL
250
+ kodax
251
+
252
+ # Then ask naturally inside the REPL
253
+ Read package.json and summarize the architecture
254
+ /mode
255
+ /help
256
+
257
+ # One-shot CLI usage
258
+ kodax "Review this repository and summarize the architecture"
259
+ kodax --session review "Find the riskiest parts of src/"
260
+ kodax --session review "Give me concrete fix suggestions"
261
+ ```
262
+
263
+ ### 4. Use it as a library
264
+
265
+ Library usage still expects API keys from environment variables. If you want custom provider names or base URLs in code, register them explicitly:
266
+
267
+ ```typescript
268
+ import { registerCustomProviders, runKodaX } from '@kodax-ai/kodax';
269
+
270
+ registerCustomProviders([
271
+ {
272
+ name: 'my-openai-compatible',
273
+ protocol: 'openai',
274
+ baseUrl: 'https://example.com/v1',
275
+ apiKeyEnv: 'MY_LLM_API_KEY',
276
+ model: 'my-model',
277
+ userAgentMode: 'compat',
278
+ },
279
+ ]);
280
+
281
+ const result = await runKodaX(
282
+ {
283
+ provider: 'my-openai-compatible',
284
+ reasoningMode: 'auto',
285
+ },
286
+ 'Explain this codebase'
287
+ );
288
+ ```
289
+
290
+ > **Embedding KodaX inside another app?** (KodaX Space, IDE extensions, custom CLIs)
291
+ > See [docs/SDK_EMBEDDER_GUIDE.md](docs/SDK_EMBEDDER_GUIDE.md) for the runtime-mutation
292
+ > surface (`startKodaX` + `RunningSession`), MCP popout manager API (`McpManager`),
293
+ > Skill `` !`cmd` `` host hook, and per-app data dir namespacing (`getAppDataDir`).
294
+
295
+ ## Repo Intelligence (optional premium engine)
296
+
297
+ KodaX ships with built-in OSS repo intelligence (`repo_overview`, `module_context`, `symbol_context`, `process_context`, `impact_estimate`, …) that helps the coding agent understand large codebases without ad-hoc grep/glob exploration.
298
+
299
+ An optional **premium engine** (`repointel` local daemon, distributed via the sibling `KodaX-private` repo) adds proactive context injection, deeper module capsules, and a native auto-lane integration. KodaX automatically falls back to OSS when premium is unavailable.
300
+
301
+ ```bash
302
+ # Pick a runtime mode (off | oss | premium-shared | premium-native | auto)
303
+ kodax --repo-intelligence premium-native --repo-intelligence-trace
304
+ ```
305
+
306
+ Setup, runtime modes, REPL controls, config schema, and external-host integrations: see [docs/REPOINTEL.md](docs/REPOINTEL.md).
307
+
308
+ ## Architecture
309
+
310
+ KodaX uses a **monorepo architecture** with npm workspaces. Source layout currently has 4 workspace packages; published as a single bundled npm package `@kodax-ai/kodax` with 7 SDK subpath exports (`/agent`, `/llm`, `/coding`, `/repl`, `/skills`, `/mcp`, `/session`; ADR-024 + ADR-032 + ADR-038, with ADR-036 consolidation):
311
+
312
+ ```
313
+ KodaX/
314
+ ├── packages/ # 4 workspace packages (FEATURE_194 v0.7.43)
315
+ │ ├── llm/ # @kodax-ai/llm - LLM abstraction (14 built-in provider aliases)
316
+ │ │ └── providers/ # Anthropic, OpenAI, DeepSeek, Kimi, MiMo, MiniMax, Zhipu, Ark, …
317
+ │ │
318
+ │ ├── agent/ # @kodax-ai/agent - Generic Agent framework
319
+ │ │ ├── orchestration/ # Runner, runFanOut, runWithIdleYield, ChildTaskRegistry
320
+ │ │ ├── session-lineage/ # branchable session tree (inline v0.7.43)
321
+ │ │ ├── capabilities/
322
+ │ │ │ ├── mcp/ # MCP integration (inline v0.7.43)
323
+ │ │ │ └── skills/ # Skills standard implementation + builtin (inline v0.7.43)
324
+ │ │ └── tracing/ # tracing / observability (inline v0.7.43)
325
+ │ │
326
+ │ ├── coding/ # @kodax-ai/coding - Coding Agent (tools + prompts)
327
+ │ │ ├── tools/ # 50+ tools: read, write, edit, bash, glob, grep, undo,
328
+ │ │ │ # dispatch_child_task, send_message, task_stop,
329
+ │ │ │ # ask_user_question, repo-intelligence, …
330
+ │ │ └── repo-intelligence/ # incl. protocol.ts (inline v0.7.43)
331
+ │ │
332
+ │ └── repl/ # @kodax-ai/repl - Interactive terminal UI (Ink TUI)
333
+
334
+ ├── src/ # CLI entry + SDK subpath entries
335
+ │ ├── kodax_cli.ts # Main CLI entry point (bin: `kodax`)
336
+ │ └── sdk-*.ts # SDK subpath re-exports → @kodax-ai/kodax/{agent,llm,coding,repl,skills,mcp,session}
337
+
338
+ └── package.json # Root workspace config; release.mjs rewrites name + injects subpath exports
339
+ ```
340
+
341
+ ### Package Dependencies
342
+
343
+ ```
344
+ ┌──────────────────┐
345
+ │ kodax (root) │
346
+ │ CLI Entry │
347
+ └────────┬─────────┘
348
+
349
+ ┌──────────────┴──────────────┐
350
+ │ │
351
+ ▼ ▼
352
+ ┌──────────────┐ ┌────────────────┐
353
+ │@kodax-ai/repl│ │@kodax-ai/coding│
354
+ │ UI Layer │ │ Tools+Prompts │
355
+ └──────┬───────┘ └──────┬─────────┘
356
+ │ │
357
+ │ ┌──────────────┴──────────────┐
358
+ │ │ │
359
+ ▼ ▼ ▼
360
+ ┌──────────────┐ ┌──────────────────────────┐ ┌──────────────┐
361
+ │@kodax-ai/ │ │@kodax-ai/agent │ │@kodax-ai/llm │
362
+ │coding (via │ │Runner + fan-out + │ │LLM Abstract │
363
+ │above) │ │idle-yield + session- │ │(14 aliases) │
364
+ │ │ │lineage + skills + mcp + │ │ │
365
+ │ │ │tracing (FEATURE_194) │ │ │
366
+ └──────────────┘ └──────────────────────────┘ └──────────────┘
367
+ ```
368
+
369
+ ### Package Overview
370
+
371
+ Source-side workspace package names (`@kodax-ai/*`). npm consumers install the single bundled `@kodax-ai/kodax` package and import from SDK subpaths — see [Source-side vs npm-published surface](#source-side-vs-npm-published-surface) and [SDK Usage](#sdk-usage) below.
372
+
373
+ | Workspace package | Purpose | Key Dependencies |
374
+ |---------|---------|------------------|
375
+ | `@kodax-ai/llm` | LLM abstraction (14 built-in provider aliases + custom registration) | @anthropic-ai/sdk, openai |
376
+ | `@kodax-ai/agent` | Generic Agent framework — Runner, fan-out, idle-yield, session-lineage, capabilities (mcp + skills), tracing (ADR-036 v0.7.43 consolidation; subpaths: `/session-lineage`, `/capabilities/mcp`, `/capabilities/skills`, `/tracing`) | @kodax-ai/llm, js-tiktoken, fflate, yaml |
377
+ | `@kodax-ai/coding` | Coding Agent — 50+ tools (incl. `dispatch_child_task` / `send_message` / `task_stop`) + role prompts + auto-continue + repo-intelligence protocol | @kodax-ai/llm, @kodax-ai/agent |
378
+ | `@kodax-ai/repl` | Complete interactive terminal UI (Ink/React, permission modes, commands, streaming) | @kodax-ai/coding, ink, react |
379
+
380
+ ### Source-side vs npm-published surface
381
+
382
+ KodaX has two layers that consumers should understand separately:
383
+
384
+ - **Source-side**: 4 workspace packages above (what developers see when reading the repo).
385
+ - **npm-published**: a single bundled package `@kodax-ai/kodax` with 7 SDK subpaths (what SDK consumers `import` from). The subpaths are split into two roles:
386
+ - **Full-package subpaths** (`/agent`, `/llm`, `/coding`, `/repl`) — each one maps 1:1 to a source workspace and exposes its complete public API.
387
+ - **Narrow-subset subpaths** (`/skills`, `/mcp`, `/session`) — each one exposes only a focused capability slice carved out of `/agent` or `/repl`. This lets consumers who only need (say) the Skills system import a much smaller surface without pulling in the full agent framework.
388
+
389
+ | Source package | npm subpath | Type | What you get | Example consumer |
390
+ |---|---|---|---|---|
391
+ | `packages/llm` | `@kodax-ai/kodax/llm` | Full package | 14-alias LLM abstraction (77 exports) | Standalone LLM clients |
392
+ | `packages/agent` | `@kodax-ai/kodax/agent` | Full package | Runner / fan-out / session-lineage / capabilities / tracing (202 exports) | Custom agent frameworks |
393
+ | `packages/agent` | `@kodax-ai/kodax/skills` | **Narrow subset** | Skills system only — `SkillRegistry` / `loadFullSkill` / `expandSkillForLLM` / ... (26 exports = pre-v0.7.43 `@kodax-ai/skills` complete API) | Skill loaders, IDE plugins |
394
+ | `packages/agent` | `@kodax-ai/kodax/mcp` | **Narrow subset** | MCP only — `McpCapabilityProvider` / `createMcpTransport` / `searchMcpCatalog` / ... (11 exports = pre-v0.7.43 `@kodax-ai/mcp` complete API) | MCP server hosts |
395
+ | `packages/coding` | `@kodax-ai/kodax/coding` | Full package | Coding agent + 50+ tools + repo-intelligence (342 exports) | Build a Claude Code-shape product |
396
+ | `packages/repl` | `@kodax-ai/kodax/repl` | Full package | Ink TUI + permission modes + commands (193 exports) | Terminal-UI consumers |
397
+ | `packages/repl` | `@kodax-ai/kodax/session` | **Narrow subset** | Session management only — `listSessions` / `forkSession` / `watchSessions` / ... (9 exports) | IDE plugins reading session history |
398
+
399
+ **Rule of thumb**: if you need Runner / Agent / fan-out, import from `/agent`. If you only need skills or mcp APIs, import from `/skills` or `/mcp` to get a smaller bundle. The narrow subsets are subsets of the full packages — they do **not** expose extra symbols.
400
+
401
+ **Dynamic Workflows (FEATURE_217, v0.7.49)**: the domain-neutral workflow runtime is part of `/agent` — `import { createWorkflowRuntime, runWorkflow, WorkflowAbortError, WorkflowLimitError } from '@kodax-ai/kodax/agent'`. The coding-side integration (agent backend + built-in workflows + saved-workflow discovery/generation: `createCodingWorkflowBackend`, `runWorkflowFromOptions`, `parallelInvestigation`, `discoverSavedWorkflows`, `generateWorkflowFromOptions`, …) is part of `/coding`. FEATURE_217 is the v0.7.49 home for the full Dynamic Workflow product loop: `/workflow create <request>` generates restricted scripts, `/workflow save <runId> <name>` stores `.workflow.json` rerunnable workflows, generated/saved scripts coordinate agents through `WorkflowApi`, run lifecycle state stays observable, opt-in `isolation:"worktree"` routes selected children to parent-managed worktrees, and all file/shell effects still pass through agent tools and the existing permission gates. There is **no** separate `@kodax-ai/kodax/agent/workflow` root-package subpath; source-package consumers of `@kodax-ai/agent` can still use that package's `./workflow` subpath.
402
+
403
+ **Workflow Process Surface (FEATURE_229, v0.7.50)**: workflow progress is now a reusable Agent-layer process contract rather than private REPL text. SDK hosts can subscribe to `WorkflowProcessEvent`/poll `WorkflowProcessSnapshot`, use `createWorkflowRunManager` and `createWorkflowLifecycleController` for stop/pause/resume/result/artifact/delete/prune/identity/preflight controls, and receive ANSI-free provenance fields (`source`, `sourceRunId`, `sourceWorkflowName`, `savedWorkflowName`, `revisionOf`) plus `resultSummary`. `/coding` owns the coding workflow backend and run graph, `/repl` renders the same snapshots, and the terminal UI is not the hidden source of truth. `KodaXEvents` callbacks also take an optional metadata arg (`KodaXToolEventMeta` / `KodaXActivityEventMeta` / `KodaXWorkflowEventMeta`) so a host can attribute every child-agent tool/thinking/progress event to its workflow run and child id without a second event protocol, and generated/saved workflow scripts pass `validateRestrictedWorkflowSource` (compile + source-policy check) plus a generator repair/smoke loop before they run. See [docs/ADR.md ADR-040](docs/ADR.md) for the layering rationale.
404
+
405
+ **Host Reads Persisted History (FEATURE_230 + FEATURE_234, v0.7.51)**: two additive closures for hosts that read persisted state. **Durable tool transcript replay** — a resumed session now replays the tool cards the assistant used instead of degrading to text-only. `messages` / `lineage` stay canonical; `SessionData.uiHistory` becomes a bounded, sanitized, terminal-only replay cache. The SDK transcript contract is explicit: `loadSession()` = active model context, `loadFullTranscript()` = append-order host scrollback, `uiHistory` = optional replay cache, and tool cards can always be reconstructed from canonical messages (replay types exported from `@kodax-ai/kodax/session`). **Workflow run host attribution** — `WorkflowProcessTrackerOptions` / `WorkflowProcessSnapshot` gain a host-owned opaque `hostMetadata?: Record<string, string>` that the SDK stores, persists to `run.json`, and echoes back (including after a restart) without interpreting it, so a host can map a run to the session/surface that launched it with zero side table. Unstamped/legacy runs honestly echo `hostMetadata === undefined`. See [docs/features/v0.7.51.md](docs/features/v0.7.51.md).
406
+
407
+ ---
408
+
409
+ ## Features
410
+
411
+ - **Modular Architecture** - Use as CLI, as a library, or as a Node-free single binary
412
+ - **14 Built-in Provider Aliases** - Anthropic, OpenAI, DeepSeek, Kimi, Kimi Code, Qwen, Zhipu, Zhipu Coding, MiniMax Coding, MiMo Coding, MiMo, Ark Coding, Gemini CLI, Codex CLI - plus user-defined OpenAI/Anthropic-compatible providers
413
+ - **Dynamic Workflows + SDK Process Surface** - Generate/reuse capability-routed workflows, observe live progress through `WorkflowProcessSnapshot`, and control workflow lifecycle from SDK hosts without parsing REPL output
414
+ - **V2 Worker single-loop + Sidecar Verifier (default)** - Single-agent main loop with an out-of-band Sidecar Verifier as Stop-hook (claudecode-shape; FEATURE_184 v0.7.42, ADR-030). Verifier returns accept/revise/blocked verdict on Worker text-only termination. The pre-v0.7.43 V1 chain is retired, `emit_handoff` is deleted, accept-verdict UI silently passes through, and content-aware gating skips trivial-chat sidecar calls. Async child steering uses `dispatch_child_task` + `send_message` + `task_stop` with idle-yield wait; specialist routing uses `subagent_type`.
415
+ - **Reasoning Modes** - Unified `off/auto/quick/balanced/deep` interface across providers
416
+ - **Streaming Output** - Real-time response display
417
+ - **Session Management** - JSONL format with branchable session lineage tree
418
+ - **Skills System** - Natural language triggering, extensible, role-projected in AMA
419
+ - **Repo Intelligence** - OSS baseline + optional `repointel` premium engine, with native KodaX auto-injection lane
420
+ - **Rich Tool Surface** - 50+ built-in tools across file ops, shell, search, repo intelligence, MCP capabilities, git worktree, and agent control
421
+ - **Permission Control** - 3 permission modes with pattern-based control
422
+ - **Standalone Binary** - `bun --compile` releases for Win/macOS/Linux x64+arm64, no Node.js required on target machines
423
+ - **Cross-Platform** - Windows/macOS/Linux
424
+ - **TypeScript Native** - Full type safety and IDE support
425
+
426
+ ---
427
+
428
+ ## Installation
429
+
430
+ ### As CLI Tool
431
+
432
+ ```bash
433
+ # Clone repository
434
+ git clone https://github.com/icetomoyo/KodaX.git
435
+ cd KodaX
436
+
437
+ # Install dependencies (includes workspace packages)
438
+ npm install
439
+
440
+ # Build the monorepo
441
+ npm run build
442
+
443
+ # Link globally (development mode)
444
+ npm link
445
+
446
+ # Now you can use 'kodax' anywhere
447
+ kodax "your task"
448
+ ```
449
+
450
+ ### As Standalone Binary (no Node required on target)
451
+
452
+ KodaX can be packaged into a single executable + a small `builtin/` sidecar directory using `bun --compile`. The target machine does **not** need Node.js or any other runtime.
453
+
454
+ Supported targets: `win-x64`, `linux-x64`, `linux-arm64`, `darwin-x64`, `darwin-arm64`. Win7 / pre-glibc-2.27 distros / LoongArch are not supported.
455
+
456
+ **Build locally**:
457
+
458
+ ```bash
459
+ # Install Bun once on your build machine
460
+ npm i -g bun # or scoop/brew/curl install — see docs/release.md
461
+
462
+ npm run build:binary # Current host platform (fastest)
463
+ npm run build:binary:all # All five targets in sequence
464
+ node scripts/build-binary.mjs --target=linux-arm64 # Specific target
465
+ ```
466
+
467
+ Output lives under `dist/binary/<target>/`:
468
+
469
+ ```
470
+ dist/binary/linux-x64/
471
+ ├── kodax # ~60 MB Bun-compiled executable
472
+ └── builtin/ # Sidecar built-in skills
473
+ ```
474
+
475
+ Smoke-test: `dist/binary/<host>/kodax --version`.
476
+
477
+ **Automated release**: pushing a `v*` git tag triggers `.github/workflows/release.yml`, which builds all five targets on native runners, runs smoke tests, and publishes a GitHub Release with archives + SHA256SUMS. Use the `workflow_dispatch` button in the Actions UI to test the pipeline without tagging.
478
+
479
+ See [docs/release.md](docs/release.md) for full details on build flags, archive layout, troubleshooting, and the build-time `KODAX_BUNDLED` / `KODAX_VERSION` defines.
480
+
481
+ ### As Library
482
+
483
+ ```bash
484
+ npm install @kodax-ai/kodax
485
+ ```
486
+
487
+ ```typescript
488
+ import { runKodaX } from '@kodax-ai/kodax';
489
+
490
+ process.env.ZHIPU_API_KEY = process.env.ZHIPU_API_KEY ?? 'your_api_key';
491
+
492
+ const result = await runKodaX({
493
+ provider: 'zhipu-coding',
494
+ reasoningMode: 'auto',
495
+ events: {
496
+ onTextDelta: (text) => process.stdout.write(text),
497
+ onComplete: () => console.log('\nDone!'),
498
+ },
499
+ }, 'your task');
500
+
501
+ console.log(result.lastText);
502
+ ```
503
+
504
+ #### SDK Subpath Imports (v0.7.39+)
505
+
506
+ For smaller surface and tree-shake-friendly imports, the SDK is also exposed via subpath exports — pick only the package(s) you need:
507
+
508
+ ```typescript
509
+ import { Runner } from '@kodax-ai/kodax/agent'; // agent runtime
510
+ import { getProvider } from '@kodax-ai/kodax/llm'; // LLM abstraction (14 aliases)
511
+ import { runKodaX } from '@kodax-ai/kodax/coding'; // coding tools + prompts
512
+ import { SkillRegistry } from '@kodax-ai/kodax/skills'; // zero-dep skill loader
513
+ import { loadConfig } from '@kodax-ai/kodax/repl'; // REPL config / session helpers
514
+ import { createMcpManager } from '@kodax-ai/kodax/mcp'; // MCP popout manager (v0.7.42)
515
+ import { listSessions } from '@kodax-ai/kodax/session'; // session history helpers
516
+ ```
517
+
518
+ All 8 SDK entries (root + 7 subpaths) share internal code via ESM chunk splitting importing from `/agent` does not pull in `/repl`'s Ink + React surface.
519
+
520
+ > **ESM-only.** The SDK is published as ES Modules. In a CommonJS context (Electron main process, legacy Webpack CJS bundles, `require()`-based code) you must use `await import(...)` instead of `require()`. See [docs/SDK_EMBEDDER_GUIDE.md §5](docs/SDK_EMBEDDER_GUIDE.md#5-consuming-from-a-commonjs-context-electron-main-cjs-bundles) for the canonical recipe + the technical reason most subpaths cannot ship a dual ESM/CJS build.
521
+
522
+ For CLI users, provider defaults live in `~/.kodax/config.json`. For library users, API keys are still read from environment variables; if you need custom base URLs or provider aliases, use `registerCustomProviders()` as shown above.
523
+
524
+ ---
525
+
526
+ ## Usage
527
+
528
+ ### REPL Quickstart
529
+
530
+ Running `kodax` with no prompt starts the interactive REPL.
531
+
532
+ ```bash
533
+ kodax
534
+ ```
535
+
536
+ Inside the REPL you can type normal requests or slash commands:
537
+
538
+ ```text
539
+ Read package.json and summarize the architecture
540
+ /model
541
+ /mode
542
+ /help
543
+ ```
544
+
545
+ ### CLI Quickstart
546
+
547
+ ```bash
548
+ # Set API key
549
+ export ZHIPU_API_KEY=your_api_key
550
+
551
+ # Basic usage
552
+ kodax "Help me create a TypeScript project"
553
+
554
+ # Choose a provider explicitly
555
+ kodax --provider openai --model gpt-5.4 "Create a REST API"
556
+
557
+ # Use a deeper reasoning mode
558
+ kodax --reasoning deep "Review this architecture"
559
+ ```
560
+
561
+ ### Session Workflows
562
+
563
+ Use a session when you want memory across turns. Without a session, each CLI call is independent.
564
+
565
+ ```bash
566
+ # No memory: two separate calls
567
+ kodax "Read src/auth.ts"
568
+ kodax "Summarize it"
569
+
570
+ # With memory: same session
571
+ kodax --session my-project "Read package.json"
572
+ kodax --session my-project "Summarize it"
573
+ kodax --session my-project "How should I fix the first issue?"
574
+
575
+ # Session management
576
+ kodax --session list
577
+ kodax --session resume "continue"
578
+ ```
579
+
580
+ ### Session Patterns
581
+
582
+ ```bash
583
+ # No memory: two independent calls
584
+ kodax "Read src/auth.ts" # Agent reads and responds
585
+ kodax "Summarize it" # Agent doesn't know what to summarize
586
+
587
+ # With memory: same session
588
+ kodax --session auth-review "Read src/auth.ts"
589
+ kodax --session auth-review "Summarize it" # Agent knows to summarize auth.ts
590
+ kodax --session auth-review "How to fix first issue" # Agent has context
591
+ ```
592
+
593
+ ### Workflow Examples
594
+
595
+ ```bash
596
+ # Code review (multi-turn conversation)
597
+ kodax --session review "Review src/ directory"
598
+ kodax --session review "Focus on security issues"
599
+ kodax --session review "Give me fix suggestions"
600
+
601
+ # Project development (continuous session)
602
+ kodax --session todo-app "Create a Todo application"
603
+ kodax --session todo-app "Add delete functionality"
604
+ kodax --session todo-app "Write tests"
605
+ ```
606
+
607
+ ### CLI Reference
608
+
609
+ ```text
610
+ kodax Start the interactive REPL
611
+ -h, --help [topic] Show help or topic help
612
+ -p, --print <text> Run a single task and exit
613
+ -c, --continue Continue the most recent conversation in this directory
614
+ -r, --resume [id] Resume a session by ID, or the latest session
615
+ -m, --provider Provider to use
616
+ --model <name> Override the model
617
+ --reasoning <mode> off | auto | quick | balanced | deep
618
+ -t, --thinking Compatibility alias for --reasoning auto
619
+ -s, --session <op> Session ID or legacy session operation
620
+ -j, --parallel Enable parallel tool execution
621
+ --max-iter <n> Max iterations
622
+ ```
623
+
624
+ ### Permission Control
625
+
626
+ KodaX provides 3 permission modes for fine-grained control:
627
+
628
+ | Mode | Description | Tools Need Confirmation |
629
+ |------|-------------|------------------------|
630
+ | `plan` | Read-only planning mode | All modification tools blocked |
631
+ | `accept-edits` | Auto-accept file edits | bash only |
632
+ | `auto-in-project` | Full auto within project | None (project-scoped) |
633
+
634
+ ```bash
635
+ # In REPL, use /mode command
636
+ /mode plan # Switch to plan mode (read-only)
637
+ /mode accept-edits # Switch to accept-edits mode
638
+ /mode auto-in-project # Switch to auto-in-project mode
639
+ /auto # Alias for auto-in-project
640
+
641
+ # Check current mode
642
+ /mode
643
+ ```
644
+
645
+ **Features:**
646
+ - In `accept-edits` mode, choosing "always" can persist safe Bash allow-patterns
647
+ - Plan mode includes system prompt context for LLM awareness
648
+ - Permanent protection zones: `.kodax/`, `~/.kodax/`, paths outside project
649
+ - Pattern-based permission: Allow specific Bash commands (e.g., `Bash(npm install)`)
650
+ - Unified diff display for write/edit operations
651
+
652
+ ### CLI Help Topics
653
+
654
+ Get detailed help for specific topics:
655
+
656
+ ```bash
657
+ # Basic help
658
+ kodax -h
659
+ kodax --help
660
+
661
+ # Detailed topic help
662
+ kodax -h sessions # Session management details
663
+ kodax -h init # Long-running project initialization
664
+ kodax -h project # Project mode / harness workflow
665
+ kodax -h auto # Auto-continue mode
666
+ kodax -h provider # LLM provider configuration
667
+ kodax -h thinking # Thinking/reasoning mode
668
+ kodax -h team # Multi-agent parallel execution
669
+ kodax -h print # Print configuration
670
+ ```
671
+
672
+ ### Environment Variables
673
+
674
+ KodaX recognizes a number of environment variables for tuning runtime behavior. The most commonly used ones are listed below; for the full list, search the repo for `process.env.KODAX_`.
675
+
676
+ #### `KODAX_MAX_OUTPUT_TOKENS`
677
+
678
+ Overrides the per-turn `max_tokens` value sent to **every** provider (Anthropic, OpenAI, Zhipu, Kimi, MiniMax, Qwen, DeepSeek, MiMo, Gemini, Codex, …). Set to a positive integer; unset or non-numeric values are ignored. This is an **explicit user intent**: when set, it wins over the provider's model descriptor cap, over the provider config default, and over the global `KODAX_MAX_TOKENS` fallback. RST defense is handled at the provider config layer (`streamMaxDurationMs` watchdog + non-streaming fallback in `packages/llm/src/providers/registry.ts`), so this variable is purely an output-budget knob.
679
+
680
+ ```bash
681
+ # Allow up to 48K output tokens per turn (use a higher cap when generating long files)
682
+ export KODAX_MAX_OUTPUT_TOKENS=48000
683
+ kodax "generate the full implementation"
684
+
685
+ # Unset to restore default behavior
686
+ unset KODAX_MAX_OUTPUT_TOKENS
687
+ ```
688
+
689
+ Precedence used by every provider's `getEffectiveMaxOutputTokens()` (see `packages/llm/src/providers/base.ts`):
690
+
691
+ 1. One-shot per-request override (agent-loop escalation / context-overflow recovery — internal)
692
+ 2. **`KODAX_MAX_OUTPUT_TOKENS`** (this variable, explicit user intent)
693
+ 3. Active model descriptor's `maxOutputTokens` (FEATURE_098 per-model cap)
694
+ 4. Provider config default
695
+ 5. Global `KODAX_MAX_TOKENS` fallback
696
+
697
+ Related variables: `KODAX_MAX_TOKENS` (global fallback when no provider/model cap applies), `KODAX_ESCALATED_MAX_OUTPUT_TOKENS` (escalation budget used by the agent loop when a turn returns `stop_reason: max_tokens`).
698
+
699
+ > **Retired in v0.7.42**: `KODAX_RST_PRONE_PROVIDERS` and `KODAX_WRITE_TURN_MAX_TOKENS` (the v0.7.28 P2b write-turn cap mechanism) are no longer recognized. The 2026-04 bench measured RST as time-based (zhipu-coding 308s server kill window), not payload-size-based, so the cap was retired in favor of the per-provider `streamMaxDurationMs` watchdog + non-streaming fallback chain (configured in `registry.ts`). Existing env exports become silent no-ops; remove them from shell profiles when convenient.
700
+
701
+ #### Sidecar verifier diagnostics
702
+
703
+ Use these when diagnosing Worker text-only completion stalls or custom provider verifier behavior:
704
+
705
+ ```bash
706
+ export KODAX_VERIFIER_LOG=1
707
+ export KODAX_VERIFIER_PROVIDER=anthropic
708
+ export KODAX_VERIFIER_MODEL=claude-haiku-4-5-20251001
709
+ ```
710
+
711
+ - `KODAX_VERIFIER_LOG=1` shows verifier gate/elapsed/trace information and is equivalent to `"verifierLog": true` in `~/.kodax/config.json`.
712
+ - `KODAX_VERIFIER_PROVIDER` + `KODAX_VERIFIER_MODEL` route the verifier to a separate provider/model instead of inheriting the main Worker model. Set both together.
713
+ - `KODAX_VERIFIER_ALWAYS=1` forces the verifier to fire on every text-only completion for debugging/regression sweeps.
714
+
715
+ ## Advanced Library Usage
716
+
717
+ #### Simple Mode (runKodaX)
718
+
719
+ ```typescript
720
+ import { runKodaX, KodaXEvents } from '@kodax-ai/kodax';
721
+
722
+ const events: KodaXEvents = {
723
+ onTextDelta: (text) => process.stdout.write(text),
724
+ onThinkingDelta: (text) => console.log(`Thinking delta: ${text.length} chars`),
725
+ onToolResult: (result) => console.log(`Tool ${result.name}: ${result.content.slice(0, 100)}`),
726
+ onComplete: () => console.log('\nDone!'),
727
+ onError: (e) => console.error(e.message),
728
+ };
729
+
730
+ const result = await runKodaX({
731
+ provider: 'zhipu-coding',
732
+ reasoningMode: 'auto',
733
+ events,
734
+ }, 'What is 1+1?');
735
+
736
+ console.log(result.lastText);
737
+ ```
738
+
739
+ #### Continuous Session (KodaXClient)
740
+
741
+ ```typescript
742
+ import { KodaXClient } from '@kodax-ai/kodax';
743
+
744
+ const client = new KodaXClient({
745
+ provider: 'zhipu-coding',
746
+ reasoningMode: 'auto',
747
+ events: {
748
+ onTextDelta: (t) => process.stdout.write(t),
749
+ },
750
+ });
751
+
752
+ // First message
753
+ await client.send('Read package.json');
754
+
755
+ // Continue same session
756
+ await client.send('Summarize it');
757
+
758
+ console.log(client.getSessionId());
759
+ ```
760
+
761
+ #### Custom Session Storage
762
+
763
+ ```typescript
764
+ import { runKodaX, KodaXSessionStorage, KodaXMessage } from '@kodax-ai/kodax';
765
+
766
+ class MyDatabaseStorage implements KodaXSessionStorage {
767
+ async save(id: string, data: { messages: KodaXMessage[]; title: string; gitRoot: string }) {
768
+ // Save to your database
769
+ }
770
+ async load(id: string) {
771
+ // Load from your database
772
+ return null;
773
+ }
774
+ }
775
+
776
+ await runKodaX({
777
+ provider: 'zhipu-coding',
778
+ session: {
779
+ id: 'my-session-123',
780
+ storage: new MyDatabaseStorage(),
781
+ },
782
+ events: { ... },
783
+ }, 'task');
784
+ ```
785
+
786
+ ### Library Modes Comparison
787
+
788
+ | Feature | runKodaX | KodaXClient |
789
+ |---------|----------|-------------|
790
+ | **Message Memory** | No | Yes |
791
+ | **Call Style** | Function | Class instance |
792
+ | **Context** | Independent each time | Accumulates |
793
+ | **Use Case** | Single tasks, batch processing | Interactive dialogue, multi-step tasks |
794
+
795
+ ---
796
+
797
+ ## SDK Usage
798
+
799
+ KodaX ships as a single npm package `@kodax-ai/kodax` with 7 SDK subpath exports (ADR-024 v0.7.39 + ADR-032 v0.7.42 + ADR-038 v0.7.49). Each subpath is tree-shake-friendly so consumers pull only what they need:
800
+
801
+ ```bash
802
+ npm install @kodax-ai/kodax
803
+ ```
804
+
805
+ ```typescript
806
+ import { runKodaX } from '@kodax-ai/kodax'; // root: CLI helpers + runKodaX
807
+ import { Runner, runFanOut } from '@kodax-ai/kodax/agent'; // generic Agent framework
808
+ import { getProvider } from '@kodax-ai/kodax/llm'; // 14-alias LLM abstraction
809
+ import { KODAX_TOOLS } from '@kodax-ai/kodax/coding'; // tools + prompts + agent loop
810
+ import { runInkInteractiveMode } from '@kodax-ai/kodax/repl'; // Ink TUI entrypoint
811
+ import { SkillRegistry } from '@kodax-ai/kodax/skills'; // zero-dep skill loader
812
+ import { createMcpManager } from '@kodax-ai/kodax/mcp'; // MCP popout manager (v0.7.42)
813
+ import { listSessions } from '@kodax-ai/kodax/session'; // session history helpers
814
+ ```
815
+
816
+ > The SDK is **ESM-only**. CommonJS consumers (Electron main / Webpack CJS / `require()` callers) must use `await import('@kodax-ai/kodax/...')` — see [docs/SDK_EMBEDDER_GUIDE.md §5](docs/SDK_EMBEDDER_GUIDE.md#5-consuming-from-a-commonjs-context-electron-main-cjs-bundles).
817
+
818
+ ### `@kodax-ai/kodax/llm` LLM Abstraction
819
+
820
+ 14 built-in provider aliases (Anthropic, OpenAI, DeepSeek, Kimi, Kimi-Code, Qwen, Zhipu, Zhipu-Coding, MiniMax-Coding, MiMo, MiMo-Coding, Ark-Coding, Gemini-CLI, Codex-CLI) + custom provider registration.
821
+
822
+ ```typescript
823
+ import { getProvider, KodaXBaseProvider } from '@kodax-ai/kodax/llm';
824
+
825
+ const provider = getProvider('anthropic');
826
+ const stream = await provider.streamCompletion(
827
+ [{ role: 'user', content: 'Hello!' }],
828
+ { onTextDelta: (text) => process.stdout.write(text) }
829
+ );
830
+
831
+ for await (const result of stream) {
832
+ if (result.type === 'text') { /* … */ }
833
+ else if (result.type === 'tool_use') { /* … */ }
834
+ }
835
+ ```
836
+
837
+ **Key Features**: unified provider interface · streaming · reasoning modes (`off/auto/quick/balanced/deep`) · per-provider retry + error handling · zero business-logic dependencies.
838
+
839
+ ### `@kodax-ai/kodax/agent` — Agent Framework (standalone-consumable)
840
+
841
+ ADR-021 standalone-consumable: `@kodax-ai/agent` has **zero inbound `@kodax-ai/coding` dependency** — you can wire any tool surface on top of it.
842
+
843
+ ```typescript
844
+ import {
845
+ Runner,
846
+ runFanOut,
847
+ runWithIdleYield,
848
+ registerChildTask,
849
+ type ChildTaskRegistry,
850
+ generateSessionId,
851
+ estimateTokens,
852
+ DefaultSummaryCompaction,
853
+ } from '@kodax-ai/kodax/agent';
854
+
855
+ // Bounded-concurrency fan-out with abort + structured progress events (v0.7.39 FEATURE_120)
856
+ const result = await runFanOut({
857
+ bundles: [{ id: 'a', task: 'audit-foo' }, { id: 'b', task: 'audit-bar' }],
858
+ maxParallel: 4,
859
+ run: async (bundle) => doWork(bundle),
860
+ });
861
+
862
+ // Idle-yield wait — pause when out of useful work, resume when a wake event arrives
863
+ await runWithIdleYield({ runOnce, computeSnapshot, registry, messageQueue, agentId });
864
+
865
+ // Pluggable compaction policy (FEATURE_081)
866
+ const policy = new DefaultSummaryCompaction({ thresholdRatio: 0.8, keepRecent: 10 });
867
+ ```
868
+
869
+ **Key Features**: `Runner` + per-step lifecycle · `runFanOut` (bounded-concurrency + abort + progress events) · `runWithIdleYield` (chat-while-waiting) · `ChildTaskRegistry` / `TaskAbortRegistry` · session-id generation · tiktoken-based token estimation · `CompactionPolicy` interface.
870
+
871
+ ### `@kodax-ai/kodax/skills` Skills System
872
+
873
+ Zero external dependencies. Markdown-based skill files with natural-language triggers and variable resolution.
874
+
875
+ ```typescript
876
+ import {
877
+ SkillRegistry,
878
+ discoverSkills,
879
+ executeSkill,
880
+ type SkillContext,
881
+ } from '@kodax-ai/kodax/skills';
882
+
883
+ const skills = await discoverSkills(['/path/to/skills']);
884
+ const registry = new SkillRegistry();
885
+ await registry.registerSkills(skills);
886
+
887
+ const result = await executeSkill({
888
+ skillId: 'code-review',
889
+ arguments: { target: 'src/' },
890
+ workingDirectory: process.cwd(),
891
+ });
892
+ ```
893
+
894
+ **Key Features**: zero deps · markdown-based skill files · natural-language triggering · variable resolution · built-in skills included.
895
+
896
+ ### `@kodax-ai/kodax/coding` Coding Agent
897
+
898
+ Complete coding agent: 50+ tools (`read`/`write`/`edit`/`bash`/`grep`/`glob`/`dispatch_child_task`/`send_message`/`task_stop`/...) + Worker role prompt + Sidecar Verifier (out-of-band Stop-hook) + agent loop + auto-continue + session management.
899
+
900
+ ```typescript
901
+ import { runKodaX, KodaXClient, KODAX_TOOLS } from '@kodax-ai/kodax/coding';
902
+
903
+ // Single-task helper
904
+ const result = await runKodaX({
905
+ provider: 'zhipu-coding',
906
+ reasoningMode: 'auto',
907
+ events: { onTextDelta: (text) => process.stdout.write(text) },
908
+ }, 'Read package.json and explain the dependencies');
909
+
910
+ // Continuous session
911
+ const client = new KodaXClient({
912
+ provider: 'anthropic',
913
+ reasoningMode: 'auto',
914
+ events: { /* */ },
915
+ });
916
+ await client.send('Create a new file');
917
+ await client.send('Add a function to it'); // Has context from previous message
918
+ ```
919
+
920
+ **Key Features**: 50+ built-in tools (see [Tools](#tools)) · V2 Worker single-loop + Sidecar Verifier (FEATURE_184 v0.7.42 / V1 chain fully retired by FEATURE_193 v0.7.43) · async child steering via `send_message` / `task_stop` (FEATURE_120, v0.7.39) · idle-yield wait mechanic (FEATURE_155, v0.7.38) · specialist routing via `subagent_type` (FEATURE_191, v0.7.43) · auto-continue · session lineage.
921
+
922
+ ### `@kodax-ai/kodax/repl` Interactive Terminal UI
923
+
924
+ Ink/React-based interactive REPL. Permission modes, command system, themed streaming display.
925
+
926
+ ```typescript
927
+ import { runInkInteractiveMode } from '@kodax-ai/kodax/repl';
928
+
929
+ // Usually used via the `kodax` bin command; can be embedded:
930
+ // - Interactive terminal UI (Ink components)
931
+ // - Permission control (auto/plan/accept-edits modes)
932
+ // - Command system (/help, /mode, /clear, /status, …)
933
+ // - Skills integration
934
+ // - Theme support
935
+ await runInkInteractiveMode({ provider: 'zhipu-coding', reasoningMode: 'auto' });
936
+ ```
937
+
938
+ **Key Features**: Ink-based React components · 3 permission modes (auto / plan / accept-edits) · built-in commands · real-time streaming display · context-usage indicator.
939
+
940
+ ### Package Dependency Graph (workspace internal)
941
+
942
+ ```
943
+ @kodax-ai/llm (zero business-logic deps)
944
+
945
+ @kodax-ai/agent (depends @kodax-ai/llm; ADR-021 standalone-consumable;
946
+ inlines session-lineage + capabilities/{mcp,skills} +
947
+ tracing per ADR-036 v0.7.43)
948
+
949
+ @kodax-ai/coding (depends llm + agent; inlines repo-intelligence/protocol per ADR-036)
950
+
951
+ @kodax-ai/repl (depends coding + ink + react)
952
+ ```
953
+
954
+ **Subpath Recommendations**:
955
+
956
+ | Use Case | Subpath | Why |
957
+ |----------|---------|-----|
958
+ | Only need LLM abstraction | `@kodax-ai/kodax/llm` | Minimal deps; 14 built-in aliases |
959
+ | Building custom agent | `@kodax-ai/kodax/agent` | Runner + fan-out + idle-yield + session-lineage + capabilities |
960
+ | Coding tasks | `@kodax-ai/kodax/coding` | Complete coding agent + tools |
961
+ | Terminal app | `@kodax-ai/kodax/repl` | Full interactive experience |
962
+
963
+ ---
964
+
965
+ | Provider | Environment Variable | Reasoning Support | Default Model |
966
+ |----------|----------------------|-------------------|---------------|
967
+ | anthropic | `ANTHROPIC_API_KEY` | Native | claude-sonnet-4-6 (`claude-opus-4-6` / `claude-haiku-4-5` via `/model`) |
968
+ | openai | `OPENAI_API_KEY` | Native | gpt-5.3-codex (`gpt-5.4` / `gpt-5.3-codex-spark` via `/model`) |
969
+ | kimi | `KIMI_API_KEY` | Native | kimi-k2.6 (`kimi-k2.7-code` 256K / `k2.5` via `/model`) |
970
+ | kimi-code | `KIMI_CODE_API_KEY` | Native | kimi-for-coding |
971
+ | qwen | `QWEN_API_KEY` | Native | qwen3.5-plus |
972
+ | zhipu | `ZHIPU_API_KEY` | Native | glm-5 (`glm-5.2` 1M ctx / `glm-5.1` / `glm-5-turbo` via `/model`) |
973
+ | zhipu-coding | `ZHIPU_CODING_API_KEY` | Native | glm-5 (`glm-5.2` 1M ctx / `glm-5.1` / `glm-5-turbo` via `/model`) |
974
+ | minimax-coding | `MINIMAX_CODING_API_KEY` | Native | MiniMax-M2.7 (`MiniMax-M3` Frontier Coding, native multimodal + 1M ctx, plus `MiniMax-M2.7-highspeed` via `/model`) |
975
+ | mimo | `MIMO_API_KEY` | Native | mimo-v2.5-pro (Xiaomi MiMo pay-per-token, Anthropic-compat) |
976
+ | mimo-coding | `MIMO_CODING_API_KEY` | Native | mimo-v2.5-pro (Xiaomi Token Plan, Anthropic-compat) |
977
+ | ark-coding | `ARK_CODING_API_KEY` | Native | glm-5.1 (Volcengine Ark Coding Plan: GLM, Kimi, MiniMax M3/M2.7, DeepSeek V3.2/V4, Doubao Seed 2.0 routes) |
978
+ | deepseek | `DEEPSEEK_API_KEY` | Native | deepseek-v4-flash (`deepseek-v4-pro` via `/model`) |
979
+ | gemini-cli | `GEMINI_API_KEY` | Prompt-only / CLI bridge | (via gemini CLI) |
980
+ | codex-cli | `OPENAI_API_KEY` | Prompt-only / CLI bridge | (via codex CLI) |
981
+
982
+ > **Custom providers**: any OpenAI- or Anthropic-compatible endpoint can be added via `customProviders[]` in `~/.kodax/config.json` (CLI) or `registerCustomProviders()` (library). See the [Quick Start](#2-configure-a-provider) for the configuration shape.
983
+
984
+ ### Examples
985
+
986
+ ```bash
987
+ # Use Zhipu Coding
988
+ kodax --provider zhipu-coding --thinking "Help me optimize this code"
989
+
990
+ # Use OpenAI
991
+ export OPENAI_API_KEY=your_key
992
+ kodax --provider openai "Create a REST API"
993
+
994
+ # Resume last session
995
+ kodax --session resume
996
+
997
+ # List all sessions
998
+ kodax --session list
999
+
1000
+ # Parallel tool execution
1001
+ kodax --parallel "Read package.json and tsconfig.json"
1002
+
1003
+ # Adaptive multi-agent (AMA) mode — V2 Worker single-loop with `dispatch_child_task` fan-out
1004
+ kodax --agent-mode ama "Analyze code structure, check test coverage, find bugs"
1005
+ ```
1006
+
1007
+ ---
1008
+
1009
+ ## Tools
1010
+
1011
+ KodaX ships 50+ built-in tools, grouped below. They are registered as a single flat tool surface to the LLM; the categories here are just for navigation.
1012
+
1013
+ ### File operations
1014
+ | Tool | Description |
1015
+ |------|-------------|
1016
+ | `read` | Read file contents (supports offset/limit) |
1017
+ | `write` | Write a new file or fully rewrite an existing one |
1018
+ | `edit` | Exact string replacement (supports `replace_all`) |
1019
+ | `multi_edit` | Atomic batch of independent edits to one file |
1020
+ | `insert_after_anchor` | Insert content after a unique anchor without rewriting the file |
1021
+ | `undo` | Revert the last file modification |
1022
+
1023
+ ### Shell & search
1024
+ | Tool | Description |
1025
+ |------|-------------|
1026
+ | `bash` | Execute a shell command (supports `run_in_background`, output truncation) |
1027
+ | `glob` | Find files by pattern |
1028
+ | `grep` | Regex content search (context lines, multiline, file-type filter, pagination) |
1029
+ | `code_search` | Lower-noise code search (extension-provider aware) |
1030
+ | `semantic_lookup` | Symbol/module/process-aware search backed by repo intelligence |
1031
+ | `web_search` | Discovery-oriented web search with trust + freshness signals |
1032
+ | `web_fetch` | Fetch a specific URL with provenance hints |
1033
+
1034
+ ### Repo Intelligence (working tools)
1035
+ | Tool | Description |
1036
+ |------|-------------|
1037
+ | `repo_overview` | Summarize structure, key areas, entry hints, intelligence snapshot |
1038
+ | `changed_scope` | Which files/areas/categories the current diff touches |
1039
+ | `changed_diff` | Paged diff slice for a single file |
1040
+ | `changed_diff_bundle` | Paged diff slices for multiple files in one call |
1041
+ | `module_context` | Module capsule (deps, entries, symbols, tests, docs) |
1042
+ | `symbol_context` | Definition + probable callers/callees + alternatives |
1043
+ | `process_context` | Approximate static execution capsule for an entry |
1044
+ | `impact_estimate` | Blast radius for a symbol/path/module |
1045
+
1046
+ ### MCP capabilities (when MCP servers are configured)
1047
+ | Tool | Description |
1048
+ |------|-------------|
1049
+ | `mcp_search` / `mcp_describe` / `mcp_call` | Discover and invoke MCP tools through the shared capability runtime |
1050
+ | `mcp_read_resource` / `mcp_get_prompt` | Read MCP resources and prompts |
1051
+
1052
+ ### Git worktree
1053
+ | Tool | Description |
1054
+ |------|-------------|
1055
+ | `worktree_create` | Create a new worktree on an isolated branch for safe agent work |
1056
+ | `worktree_remove` | Remove a worktree (with safety checks) |
1057
+
1058
+ ### Agent control & UX
1059
+ | Tool | Description |
1060
+ |------|-------------|
1061
+ | `dispatch_child_task` | Spawn a sub-agent for an independent investigation/edit task. Optional `model_hint: 'fast' \| 'balanced' \| 'deep'` (advisory; routing no-op until FEATURE_102 v0.7.45). |
1062
+ | `send_message` | Append an instruction to an in-flight child's queue surfaces as `<coordinator-instruction>` at the child's next turn boundary. Coordinator-only. (FEATURE_120, v0.7.39) |
1063
+ | `task_stop` | Request graceful exit of a specific child. Current tool finishes atomically, then the child sees a `<coordinator-stop-request>` and emits a final summary. Coordinator-only. (FEATURE_120, v0.7.39) |
1064
+ | `ask_user_question` | Single/multi-select or free-text prompt back to the user |
1065
+ | `exit_plan_mode` | Present a finalized plan for approval (REPL only) |
1066
+ | `emit_managed_protocol` | Internal managed-task protocol side-channel for role payloads (verdict). V2 Worker single-loop + Sidecar Verifier is the default since v0.7.42 (FEATURE_184); V1 chain retired in v0.7.43 (FEATURE_193). |
1067
+
1068
+ ---
1069
+
1070
+ ## Skills System
1071
+
1072
+ KodaX includes a built-in Skills system that can be triggered by natural language:
1073
+
1074
+ ```bash
1075
+ # Natural language triggering (no explicit /skill needed)
1076
+ kodax "帮我审查代码" # Triggers code-review skill
1077
+ kodax "写测试用例" # Triggers tdd skill
1078
+ kodax "提交代码" # Triggers git-workflow skill
1079
+
1080
+ # Explicit skill command
1081
+ kodax /skill:code-review
1082
+ ```
1083
+
1084
+ Built-in skills include:
1085
+ - **code-review** - Code review and quality analysis
1086
+ - **tdd** - Test-driven development workflow
1087
+ - **git-workflow** - Git commit and workflow automation
1088
+
1089
+ Skills are stored in `~/.kodax/skills/` and can be extended with custom skills.
1090
+
1091
+ ---
1092
+
1093
+ ## Commands (CLI)
1094
+
1095
+ Commands are `/xxx` shortcuts in CLI:
1096
+
1097
+ ```bash
1098
+ kodax /review src/auth.ts
1099
+ kodax /test
1100
+ ```
1101
+
1102
+ Commands are stored in `~/.kodax/commands/`:
1103
+ - `.md` files → Prompt commands (content used as prompt)
1104
+ - `.ts/.js` files → Programmable commands
1105
+
1106
+ ---
1107
+
1108
+ ## API Exports
1109
+
1110
+ ```typescript
1111
+ // Main functions
1112
+ export { runKodaX, KodaXClient };
1113
+
1114
+ // Types
1115
+ export type {
1116
+ KodaXEvents, KodaXOptions, KodaXResult,
1117
+ KodaXMessage, KodaXContentBlock,
1118
+ KodaXSessionStorage, KodaXToolDefinition
1119
+ };
1120
+
1121
+ // Tools
1122
+ export { KODAX_TOOLS, KODAX_TOOL_REQUIRED_PARAMS, executeTool };
1123
+
1124
+ // Providers
1125
+ export { getProvider, KODAX_PROVIDERS, KodaXBaseProvider };
1126
+
1127
+ // Utilities
1128
+ export {
1129
+ estimateTokens,
1130
+ getGitRoot, getGitContext, getEnvContext, getProjectSnapshot,
1131
+ checkPromiseSignal
1132
+ };
1133
+ ```
1134
+
1135
+ ---
1136
+
1137
+ ## Development
1138
+
1139
+ ```bash
1140
+ # Development mode (using tsx)
1141
+ npm run dev "your task"
1142
+
1143
+ # Build
1144
+ npm run build
1145
+
1146
+ # Optional: only build workspace packages
1147
+ npm run build:packages
1148
+
1149
+ # Build standalone binary (current platform / all platforms)
1150
+ npm run build:binary
1151
+ npm run build:binary:all
1152
+
1153
+ # Run tests
1154
+ npm test
1155
+
1156
+ # Eval-driven development tests (provider matrices, identity round-trip, etc.)
1157
+ npm run test:eval
1158
+
1159
+ # Clean
1160
+ npm run clean
1161
+ ```
1162
+
1163
+ ### Repo Intelligence cache directories
1164
+
1165
+ KodaX now uses two repo-intelligence cache locations on disk:
1166
+
1167
+ - `.agent/repo-intelligence/`
1168
+ - OSS baseline repo-intelligence artifacts and existing task-engine snapshots.
1169
+ - `.repointel/`
1170
+ - Premium `repointel` workspace cache shared by the local daemon/native frontdoor.
1171
+
1172
+ They are intentionally separated so:
1173
+
1174
+ - OSS fallback stays available even when premium is disabled or unavailable.
1175
+ - Premium cache does not pollute OSS artifacts.
1176
+ - KodaX and other hosts can share the same premium workspace cache.
1177
+
1178
+ `.repointel/` is a local generated directory and should not be committed.
1179
+
1180
+ ---
1181
+
1182
+ ## Code Style
1183
+
1184
+ ### Comment Guidelines
1185
+
1186
+ KodaX uses an **English-first** comment style with selective Chinese brief notes for complex logic.
1187
+
1188
+ | Situation | Style | Example |
1189
+ |-----------|-------|---------|
1190
+ | Import/Export | English only | `// Import dependencies` |
1191
+ | Simple constants | English only | `// Max retry count` |
1192
+ | Simple logic | English only | `// Return if null` |
1193
+ | **Business rules** | English + Chinese | `// Skip tool_result - 跳过工具结果块` |
1194
+ | **Platform compatibility** | English + Chinese | `// Windows path handling - Windows 路径处理` |
1195
+ | **Performance optimization** | English + Chinese | `// Debounce to prevent flicker - 防抖避免闪烁` |
1196
+
1197
+ ---
1198
+
1199
+ ## Documentation
1200
+
1201
+ - [README_CN.md](README_CN.md) - Chinese Documentation
1202
+ - [docs/release.md](docs/release.md) - Standalone binary build & release pipeline
1203
+ - [docs/PRD.md](docs/PRD.md) - Product Requirements
1204
+ - [docs/ADR.md](docs/ADR.md) - Architecture Decisions
1205
+ - [docs/HLD.md](docs/HLD.md) - High-Level Design
1206
+ - [docs/DD.md](docs/DD.md) - Detailed Design
1207
+ - [docs/FEATURE_LIST.md](docs/FEATURE_LIST.md) - Feature Tracking
1208
+ - [docs/test-guides/](docs/test-guides/) - Feature-specific test guides
1209
+ - [CHANGELOG.md](CHANGELOG.md) - Version History (v0.7.0+; [archive](docs/CHANGELOG_ARCHIVE.md) for older)
1210
+
1211
+ ---
1212
+
1213
+ ## License
1214
+
1215
+ [Apache License 2.0](LICENSE) - Copyright 2026 [icetomoyo](mailto:icetomoyo@gmail.com)