@xcompiler/cli 0.2.2 → 0.2.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/.env.example ADDED
@@ -0,0 +1,18 @@
1
+ # OpenRouter Free mode(默认;OpenAI-compatible /v1 接口)
2
+ # Free model catalog: https://openrouter.ai/models?max_price=0
3
+ OPENROUTER_API_KEY=
4
+ OPENROUTER_BASE_URL=https://openrouter.ai/api/v1
5
+ OPENROUTER_MODEL=openrouter/free
6
+
7
+ # Local OpenAI-compatible backup(默认在 config 中注释)
8
+ # 本地无鉴权服务可留空 LOCAL_OPENAI_API_KEY。
9
+ # LOCAL_OPENAI_API_KEY=
10
+ # LOCAL_OPENAI_BASE_URL=http://127.0.0.1:8000/v1
11
+ # LOCAL_OPENAI_MODEL=local-model
12
+
13
+ # Ollama backup(默认在 config 中注释;弱服务器首次加载大模型可能需要数分钟)
14
+ # OLLAMA_BASE_URL=http://localhost:11434
15
+ # OLLAMA_REQUEST_TIMEOUT_MS=900000
16
+ # OLLAMA_STREAM_IDLE_TIMEOUT_MS=300000
17
+ # OLLAMA_DESIGN_MODEL=gemma4:31b-mlx
18
+ # OLLAMA_CODE_MODEL=qwen3.6:35b-mlx
package/README.CN.md CHANGED
@@ -17,8 +17,8 @@ XCompiler 把"写代码"这件事按"编译 → 执行"两阶段拆分,对标
17
17
 
18
18
  | 命令 | 定位 | 输入 | 输出 |
19
19
  |---|---|---|---|
20
- | **`xcompiler build`** | **AI 编译器** —— 把自然语言需求"翻译"成可执行的阶段步骤(plan) | 一段需求文本(`-i req.md` 或交互输入) | `plan.json`(拓扑有序的 Step DAG)+ `topic.md` + `plan.md` |
21
- | **`xcompiler run`** | **AI 执行器** —— 按拓扑顺序依次执行编译输出的阶段步骤 | `plan.json` | 可运行 Python/TypeScript 工程 + 绿色测试 + `docs/05-delivery.md` |
20
+ | **`xcompiler build`** | **AI 编译器** —— 把自然语言需求"翻译"成阶段计划和当前阶段可执行步骤 | 一段需求文本(`-i req.md` 或交互输入) | `phasePlan.json` + `plan.P1.json`(当前阶段 Step DAG)+ `topic.md` + `plan.md` |
21
+ | **`xcompiler run`** | **AI 执行器** —— 执行阶段计划中的当前阶段 | `phasePlan.json`(仍兼容历史 `plan.json`) | 可运行 Python/TypeScript 工程 + 绿色测试 + `docs/05-delivery.md` |
22
22
 
23
23
  > 类比:`xcompiler build` ≈ 编译器把 C 源码翻译成机器指令;`xcompiler run` ≈ CPU 顺次执行这些指令。
24
24
  > 区别:XCompiler 的"指令"是 V 模型阶段(REQUIREMENT / ARCH / CODE / TEST / REFACTOR / DELIVERY),"执行单元"是受沙盒约束的多 Agent 循环。
@@ -34,7 +34,7 @@ XCompiler 把软件工程的 **V 模型** 直接编码为 `xcompiler build` 的
34
34
  ```text
35
35
  ┌────────── xcompiler build (AI 编译器) ──────────┐
36
36
  │ │
37
- 需求 (NL) ───► Intake ──► Clarify ──► Decompose ──► plan.json
37
+ 需求 (NL) ───► Intake ──► Clarify ──► PhasePlan ──► plan.P1.json
38
38
  │ │
39
39
  └─ Gate 1 ───┘ Gate 2 (人工双确认门)
40
40
 
@@ -106,7 +106,7 @@ XCompiler 把软件工程的 **V 模型** 直接编码为 `xcompiler build` 的
106
106
  │ LLM Router │ │ Sandbox │ │ Workspace │
107
107
  │ chain + │ │ subprocess │ │ git + audit │
108
108
  │ fallback │ │ / docker │ │ + .xcompiler/ │
109
- │ (ollama, │ │ venv 隔离 │ │ plan.json
109
+ │ (ollama, │ │ venv 隔离 │ │ phasePlan/plan.Px
110
110
  │ openai) │ │ │ │ │
111
111
  └──────────────┘ └──────────────┘ └──────────────────┘
112
112
  ```
@@ -131,7 +131,7 @@ XCompiler 把软件工程的 **V 模型** 直接编码为 `xcompiler build` 的
131
131
  ```bash
132
132
  # 1. 安装依赖
133
133
  npm ci
134
- cp .env.example .env # 填入 OLLAMA_BASE_URL
134
+ cp .env.example .env # 填入 OPENROUTER_API_KEY,默认走 OpenRouter Free provider
135
135
  cp config.example.yaml config.yaml
136
136
 
137
137
  # 2. 构建并安装为全局命令
@@ -144,17 +144,28 @@ echo "把 DBC 文件解析为 Excel 报表" > req.md
144
144
  xcompiler build -i req.md --yes
145
145
 
146
146
  # 4. 执行 plan
147
- xcompiler run /tmp/xcompiler-<时间戳>/plan.json
147
+ xcompiler run /tmp/xcompiler-<时间戳>/phasePlan.json
148
148
 
149
149
  # 5. 之后从生成的工程文件恢复
150
150
  xcompiler load /tmp/xcompiler-<时间戳>/xcompiler-<时间戳>.xc
151
151
  ```
152
152
 
153
+ 如果你使用的是已发布的 npm 包,而不是直接在源码仓库中运行,请先从包内模板创建自己的本地配置:
154
+
155
+ ```bash
156
+ npm install -g @xcompiler/cli
157
+ cp "$(npm root -g)/@xcompiler/cli/config.example.yaml" config.yaml
158
+ cp "$(npm root -g)/@xcompiler/cli/.env.example" .env
159
+ # 然后编辑 .env,填入 OPENROUTER_API_KEY
160
+ ```
161
+
162
+ `config.yaml` 和 `llm_scores.yaml` 都是用户本地运行态文件,故意不提交到仓库;npm 包只发布 `config.example.yaml` 和 `.env.example` 作为模板。
163
+
153
164
  开发模式(无需构建):
154
165
 
155
166
  ```bash
156
167
  npm run dev -- build
157
- npm run dev -- run path/to/plan.json
168
+ npm run dev -- run path/to/phasePlan.json
158
169
  ```
159
170
 
160
171
  基于已有工程做增量开发:
@@ -180,7 +191,7 @@ xcompiler bootstrap -r path/to/XCompiler -i self_req.md --yes
180
191
  | `xcompiler build` | `-i <file>` | 使用需求文件,跳过交互输入 |
181
192
  | `xcompiler build` | `-t <file>` | 复用已有 `topic.md`,跳过 Gate 1 |
182
193
  | `xcompiler build` | `--intent <greenfield\|feature\|refactor\|self>` | 选择新建、增量或隔离自举规划 |
183
- | `xcompiler build` | `--baseline-plan <file>` | 为增量规划显式指定已有 `plan.json` |
194
+ | `xcompiler build` | `--baseline-plan <file>` | 为增量规划显式指定已有 `phasePlan.json` 或历史 `plan.json` |
184
195
  | `xcompiler build` / `xcompiler run` | `--project-file <file>` | 创建/更新指定的 `XXX.xc` 工程文件 |
185
196
  | `xcompiler build` | `--force` | 覆写 workspace 锁,强制重新生成 plan |
186
197
  | `xcompiler evolve` | `...` | 先编译增量 plan,再在同一 workspace 内立即执行 |
@@ -192,15 +203,19 @@ xcompiler bootstrap -r path/to/XCompiler -i self_req.md --yes
192
203
  | `xcompiler run` | `--force` | 等价于 `--reset` + 覆写锁 |
193
204
  | `xcompiler run` | `--from <stepId>` / `--phase <phase>` | 断点续跑 / 仅跑某阶段 |
194
205
  | `xcompiler run` | `--dry-run` | 仅打印拓扑顺序 |
195
- | `xcompiler ls` | — | 扫描 workspace 列出所有 plan 状态 |
206
+ | `xcompiler ls` | — | 扫描 workspace 列出所有阶段计划状态 |
196
207
  | `xcompiler show <stepId>` | — | 查看单 Step 定义 / 产物 / 最近审计 |
197
208
 
198
209
  ---
199
210
 
200
211
  ## 默认运行时
201
212
 
202
- - **LLM**:本地 ollama(`gemma4:31b` Planner/Architect,`qwen3-coder:30b` Coder/Tester/Debugger)。
203
- 在 `config.yaml` `fallbacks: [openai]` 让主链失败时自动回落 OpenAI 兼容 endpoint。
213
+ - **LLM**:默认使用 OpenRouter Free mode,并在 `config.yaml` 中显式配置为 `type: openai` 的 OpenAI-compatible provider。
214
+ `.env` 中填写 `OPENROUTER_API_KEY`;`config.example.yaml` 已经指向 `https://openrouter.ai/api/v1`,并默认使用 `model: openrouter/free`,复制默认配置后即可先跑验证。
215
+ 如果 key 缺失或无效,XCompiler 会报告失败的 provider、model、base URL、HTTP 状态/响应体,并明确提示设置 `OPENROUTER_API_KEY`。
216
+ 工程化运行建议为每个角色配置专用首选模型,并把 `openrouter_free`(`model: openrouter/free`,`tags: [cluster]`)追加为每个角色链的最后兜底。
217
+ cluster provider 默认动态评分范围为 `0.2..0.5`,因此正常情况下排在专用模型之后,只有主模型失败或评分衰减后才会前移。
218
+ 配置步骤和官方链接见 [docs/openrouter.md](docs/openrouter.md)。
204
219
  - **i18n**:在 `config.yaml` 顶层设置 `locale: en` 或 `locale: zh`,控制 CLI 与 prompt 语言。
205
220
  - **Sandbox**:默认 `subprocess`(在 `<workspace>/.sandbox/<project>/` 建独立 venv);可切到 `docker` 走 bind-mount + 网络/资源限制。
206
221
  - **Audit**:每次运行生成 `<workspace>/.xcompiler/audit.jsonl` 与 `docs/process_log.md`,记录全部 LLM 输入输出、工具调用、Step 状态变更。
@@ -213,6 +228,7 @@ xcompiler bootstrap -r path/to/XCompiler -i self_req.md --yes
213
228
  |---|---|
214
229
  | [docs/XCompiler_design.md](docs/XCompiler_design.md) | 总体设计:V 模型阶段、Agent / Skill / Tool 抽象、Sandbox 与 Workspace |
215
230
  | [docs/implementation_plan.md](docs/implementation_plan.md) | M1 → M6 里程碑与落地步骤 |
231
+ | [docs/openrouter.md](docs/openrouter.md) | OpenRouter Free mode 配置教程,含 `type: openai` provider 示例 |
216
232
  | [docs/deploy.md](docs/deploy.md) | 部署指南(本地 + Docker) |
217
233
  | [docs/plugin_api.md](docs/plugin_api.md) | 插件 API、生命周期 Hooks、执行顺序与失败策略 |
218
234
  | [docs/versioning.md](docs/versioning.md) | 核心版本、Plugin API 版本、同步命令与发版校验 |
@@ -228,6 +244,8 @@ xcompiler bootstrap -r path/to/XCompiler -i self_req.md --yes
228
244
 
229
245
  ## 运行期调优(`config.yaml → agent.*`)
230
246
 
247
+ LLM 路由在 `config.yaml → llm.*` 中配置。推荐使用 `roles.<Role>` 数组表达每个角色的候选链,`scores.<provider>: 0` 表示禁用某个 provider;若希望 `openrouter/free` 作为 cluster 兜底更积极或更保守,可调 `cluster_score_min` / `cluster_score_max`。
248
+
231
249
  | 字段 | 默认 | 作用 |
232
250
  |---|---|---|
233
251
  | `max_rounds_per_step` | 6 | 单 Step 中 LLM 多轮对话上限 |
@@ -235,7 +253,7 @@ xcompiler bootstrap -r path/to/XCompiler -i self_req.md --yes
235
253
  | `max_debug_retries` | 3 | DEBUG 重试最大次数 |
236
254
  | `max_edit_lines_per_step` | `auto` | EditGuard 单 Step 累计写入行数;`auto` 按 phase/tools/outputs/prompt 上下文自适应,数字值表示固定硬上限 |
237
255
  | `max_write_chunk_bytes` | `auto` | `write_file` / `append_file` 单次 content 字节预算;`auto` 按 phase/context 自适应,复杂工程仍应按模块/函数/类边界拆分 |
238
- | `sandbox_limits.network` | `pypi-only` | docker 模式下;`off` `--network none` |
256
+ | `sandbox_limits.network` | `download-only` | 默认允许出站下载且不发布入站端口;`off` 走断网隔离 |
239
257
 
240
258
  ---
241
259
 
package/README.md CHANGED
@@ -17,8 +17,8 @@ XCompiler splits "writing code" into two phases — **compile** and **execute**
17
17
 
18
18
  | Command | Role | Input | Output |
19
19
  |---|---|---|---|
20
- | **`xcompiler build`** | **AI Compiler** — translates natural-language requirements into executable phase-steps (a plan) | A requirement text (`-i req.md`, `-t topic.md`, or interactive) | `plan.json` (topologically ordered Step DAG) + `topic.md` + `plan.md` |
21
- | **`xcompiler run`** | **AI Executor** — runs the compiled phase-steps in topological order | `plan.json` | Runnable Python/TypeScript project + green tests + `docs/05-delivery.md` |
20
+ | **`xcompiler build`** | **AI Compiler** — translates natural-language requirements into a phase plan and executable current-phase steps | A requirement text (`-i req.md`, `-t topic.md`, or interactive) | `phasePlan.json` + `plan.P1.json` (current phase Step DAG) + `topic.md` + `plan.md` |
21
+ | **`xcompiler run`** | **AI Executor** — runs the current phase from the compiled phase plan | `phasePlan.json` (legacy `plan.json` remains readable) | Runnable Python/TypeScript project + green tests + `docs/05-delivery.md` |
22
22
 
23
23
  > Analogy: `xcompiler build` ≈ a compiler turning C source into machine instructions; `xcompiler run` ≈ the CPU executing those instructions.
24
24
  > Difference: XCompiler's "instructions" are V-model phases (REQUIREMENT / ARCH / CODE / TEST / REFACTOR / DELIVERY), and each "execution unit" is a sandbox-constrained multi-Agent loop.
@@ -34,7 +34,7 @@ XCompiler encodes the **V-model** of software engineering directly as the decomp
34
34
  ```text
35
35
  ┌────────── xcompiler build (AI Compiler) ──────────┐
36
36
  │ │
37
- Requirement ──► Intake ──► Clarify ──► Decompose ──► plan.json
37
+ Requirement ──► Intake ──► Clarify ──► PhasePlan ──► plan.P1.json
38
38
  (NL) │ │
39
39
  └─ Gate 1 ───┘ Gate 2 (two human confirmation gates)
40
40
 
@@ -106,7 +106,7 @@ XCompiler encodes the **V-model** of software engineering directly as the decomp
106
106
  │ LLM Router │ │ Sandbox │ │ Workspace │
107
107
  │ chain + │ │ subprocess │ │ git + audit │
108
108
  │ fallback │ │ / docker │ │ + .xcompiler/ │
109
- │ (ollama, │ │ venv iso. │ │ plan.json
109
+ │ (ollama, │ │ venv iso. │ │ phasePlan/plan.Px
110
110
  │ openai) │ │ │ │ │
111
111
  └──────────────┘ └──────────────┘ └──────────────────┘
112
112
  ```
@@ -132,7 +132,7 @@ Layer responsibilities:
132
132
  ```bash
133
133
  # 1. Install dependencies
134
134
  npm ci
135
- cp .env.example .env # fill OLLAMA_BASE_URL etc.
135
+ cp .env.example .env # fill OPENROUTER_API_KEY for the default OpenRouter Free provider
136
136
  cp config.example.yaml config.yaml
137
137
 
138
138
  # 2. Build and install as a global command
@@ -145,17 +145,28 @@ echo "Parse a DBC file into an Excel report" > req.md
145
145
  xcompiler build -i req.md --yes
146
146
 
147
147
  # 4. Execute the plan
148
- xcompiler run /tmp/xcompiler-<timestamp>/plan.json
148
+ xcompiler run /tmp/xcompiler-<timestamp>/phasePlan.json
149
149
 
150
150
  # 5. Resume later from the generated project file
151
151
  xcompiler load /tmp/xcompiler-<timestamp>/xcompiler-<timestamp>.xc
152
152
  ```
153
153
 
154
+ If you installed the published npm package instead of running from this source tree, create your own local config from the packaged templates first:
155
+
156
+ ```bash
157
+ npm install -g @xcompiler/cli
158
+ cp "$(npm root -g)/@xcompiler/cli/config.example.yaml" config.yaml
159
+ cp "$(npm root -g)/@xcompiler/cli/.env.example" .env
160
+ # then edit .env and set OPENROUTER_API_KEY
161
+ ```
162
+
163
+ `config.yaml` and `llm_scores.yaml` are user/local runtime files. They are intentionally not committed; the npm package only ships `config.example.yaml` and `.env.example` as templates.
164
+
154
165
  Dev mode (no build step):
155
166
 
156
167
  ```bash
157
168
  npm run dev -- build
158
- npm run dev -- run path/to/plan.json
169
+ npm run dev -- run path/to/phasePlan.json
159
170
  ```
160
171
 
161
172
  Incremental evolution on top of an existing workspace:
@@ -181,7 +192,7 @@ xcompiler bootstrap -r path/to/XCompiler -i self_req.md --yes
181
192
  | `xcompiler build` | `-i <file>` | Use a requirements file (non-interactive) |
182
193
  | `xcompiler build` | `-t <file>` | Reuse a previously clarified `topic.md` and skip Gate 1 |
183
194
  | `xcompiler build` | `--intent <greenfield\|feature\|refactor\|self>` | Choose greenfield, incremental, or isolated self-bootstrap planning |
184
- | `xcompiler build` | `--baseline-plan <file>` | Point incremental planning at an explicit existing `plan.json` |
195
+ | `xcompiler build` | `--baseline-plan <file>` | Point incremental planning at an explicit existing `phasePlan.json` or legacy `plan.json` |
185
196
  | `xcompiler build` / `xcompiler run` | `--project-file <file>` | Create/update a specific `XXX.xc` project file |
186
197
  | `xcompiler build` | `--force` | Override the workspace lock and regenerate the plan |
187
198
  | `xcompiler evolve` | `...` | Compile an incremental plan, then immediately execute it in the same workspace |
@@ -193,15 +204,19 @@ xcompiler bootstrap -r path/to/XCompiler -i self_req.md --yes
193
204
  | `xcompiler run` | `--force` | Equivalent to `--reset` + override lock |
194
205
  | `xcompiler run` | `--from <stepId>` / `--phase <phase>` | Resume / run only one phase |
195
206
  | `xcompiler run` | `--dry-run` | Print topology only |
196
- | `xcompiler ls` | — | Scan workspace and list every plan's status |
207
+ | `xcompiler ls` | — | Scan workspace and list every phase plan's status |
197
208
  | `xcompiler show <stepId>` | — | Inspect a single Step (definition / outputs / recent audit) |
198
209
 
199
210
  ---
200
211
 
201
212
  ## Default runtime
202
213
 
203
- - **LLM**: local ollama (`gemma4:31b` for Planner / Architect, `qwen3-coder:30b` for Coder / Tester / Debugger).
204
- Set `fallbacks: [openai]` in `config.yaml` to fall back to an OpenAI-compatible endpoint when the primary chain fails.
214
+ - **LLM**: OpenRouter Free mode by default, configured as an explicit `type: openai` OpenAI-compatible provider.
215
+ Put `OPENROUTER_API_KEY` in `.env`; `config.example.yaml` already points to `https://openrouter.ai/api/v1` and uses `model: openrouter/free`, so the copied default config is enough for a first validation run.
216
+ If the key is missing or invalid, XCompiler reports the failing provider, model, base URL, HTTP status/body, and an explicit hint to set `OPENROUTER_API_KEY`.
217
+ For production-like engineering runs, give each role a dedicated first-choice model and append `openrouter_free` (`model: openrouter/free`, `tags: [cluster]`) as the last fallback in every role chain.
218
+ Cluster providers default to the lower dynamic score band `0.2..0.5`, so they remain backups unless the dedicated models fail or their scores decay.
219
+ See [docs/openrouter.md](docs/openrouter.md) for the setup guide and official OpenRouter links.
205
220
  - **i18n**: set top-level `locale: en` or `locale: zh` in `config.yaml` to control CLI and prompt language.
206
221
  - **Sandbox**: `subprocess` by default (creates an isolated venv at `<workspace>/.sandbox/<project>/`); switch to `docker` for bind-mount + network / resource limits.
207
222
  - **Audit**: every run writes `<workspace>/.xcompiler/audit.jsonl` and `docs/process_log.md`, recording all LLM I/O, tool calls and Step state transitions.
@@ -215,6 +230,7 @@ xcompiler bootstrap -r path/to/XCompiler -i self_req.md --yes
215
230
  |---|---|
216
231
  | [docs/XCompiler_design.md](docs/XCompiler_design.md) | Overall design: V-model phases, Agent / Skill / Tool abstractions, Sandbox & Workspace |
217
232
  | [docs/implementation_plan.md](docs/implementation_plan.md) | M1 → M6 milestones and landing steps |
233
+ | [docs/openrouter.md](docs/openrouter.md) | OpenRouter Free-mode setup with `type: openai` provider config |
218
234
  | [docs/deploy.md](docs/deploy.md) | Deployment guide (local + Docker) |
219
235
  | [docs/plugin_api.md](docs/plugin_api.md) | Typed plugin API, lifecycle hooks, ordering and failure policy |
220
236
  | [docs/versioning.md](docs/versioning.md) | Core and Plugin API version sources, sync commands and release checks |
@@ -230,6 +246,8 @@ xcompiler bootstrap -r path/to/XCompiler -i self_req.md --yes
230
246
 
231
247
  ## Runtime tuning (`config.yaml → agent.*`)
232
248
 
249
+ LLM routing is configured under `config.yaml → llm.*`. Use `roles.<Role>` arrays for role-specific chains, set `scores.<provider>: 0` to disable a provider, and tune cluster fallback score bounds with `cluster_score_min` / `cluster_score_max` when you want `openrouter/free` to be more or less aggressive as a backup.
250
+
233
251
  | Field | Default | Effect |
234
252
  |---|---|---|
235
253
  | `max_rounds_per_step` | 6 | Upper bound on LLM dialogue rounds within a single Step |
@@ -0,0 +1,106 @@
1
+ locale: zh # CLI / prompt 语言:en 或 zh
2
+
3
+ llm:
4
+ # Default: OpenRouter Free mode through an OpenAI-compatible /v1 endpoint.
5
+ # Uses OpenRouter's free-route alias by default.
6
+ default: openrouter_free
7
+ providers:
8
+ openrouter_free:
9
+ type: openai
10
+ api_key: ${OPENROUTER_API_KEY}
11
+ base_url: https://openrouter.ai/api/v1
12
+ model: openrouter/free
13
+ tags: [cluster]
14
+ # If a provider rejects json_object, set: json_response_format: json_schema
15
+ request_timeout_ms: 900000
16
+ stream_idle_timeout_ms: 300000
17
+
18
+ # Backup: local OpenAI-compatible endpoint, e.g. mlx-server or vLLM.
19
+ # Local/no-auth servers may leave api_key empty; cloud providers usually require one.
20
+ # local_openai:
21
+ # type: openai
22
+ # api_key: ${LOCAL_OPENAI_API_KEY}
23
+ # base_url: ${LOCAL_OPENAI_BASE_URL}
24
+ # model: ${LOCAL_OPENAI_MODEL}
25
+ # request_timeout_ms: 900000
26
+ # stream_idle_timeout_ms: 300000
27
+
28
+ # Backup: local Ollama models.
29
+ # ollama_design:
30
+ # type: ollama
31
+ # base_url: ${OLLAMA_BASE_URL}
32
+ # model: ${OLLAMA_DESIGN_MODEL}
33
+ # request_timeout_ms: 900000
34
+ # stream_idle_timeout_ms: 300000
35
+ # think: false
36
+ # ollama_code:
37
+ # type: ollama
38
+ # base_url: ${OLLAMA_BASE_URL}
39
+ # model: ${OLLAMA_CODE_MODEL}
40
+ # request_timeout_ms: 900000
41
+ # stream_idle_timeout_ms: 300000
42
+ # think: false
43
+
44
+ # 角色 → provider 数组(兼容单字符串)。
45
+ # 数组里的 provider 按 ScoreStore 评分降序使用;用户手动设置 score=0 时跳过该 provider。
46
+ # 默认只启用 OpenRouter;如需本地备选,取消 providers 中对应块注释并加入各角色数组。
47
+ roles:
48
+ Planner: [openrouter_free]
49
+ Architect: [openrouter_free]
50
+ Coder: [openrouter_free]
51
+ Tester: [openrouter_free]
52
+ Debugger: [openrouter_free]
53
+
54
+ # 评分快照(preflight 与运行时自动维护,落盘到同目录的 llm_scores.yaml)。
55
+ # 这里可以手工写初值;空 = 全部默认 1.0;显式写 0 表示用户禁用。
56
+ # tags: [cluster] 的聚合/路由 provider 默认动态评分范围为 0.2~0.5;
57
+ # 可按需调整上下限(min 最低 0.1,max 最高 1.0)。
58
+ cluster_score_min: 0.2
59
+ cluster_score_max: 0.5
60
+ scores: {}
61
+
62
+ # 全局 fallback 链:默认不启用本地备选;如已取消 provider 注释,可设为 [local_openai] 或 [local_openai, ollama_code]。
63
+ fallbacks: []
64
+ role_fallbacks: {}
65
+
66
+ agent:
67
+ # python | typescript
68
+ language: python
69
+ max_steps: 50
70
+ max_debug_retries: 3
71
+ # Debugger 滑动窗口的硬上限:LLM 持续健康输出时窗口可扩到该值;
72
+ # 出现解析失败/重复 actions/无进展时窗口快速收缩,连续 2 次低质量直接放弃。
73
+ # 默认 = max(max_debug_retries * 4, 10)
74
+ # max_debug_retries_cap: 12
75
+ # EditGuard 单 Step 累计行数预算。auto 会按 phase/tools/outputs/prompt 上下文自适应;
76
+ # 如需固定硬上限,可设为数字,例如 400。
77
+ # max_edit_lines_per_step: auto
78
+ # write_file / append_file 单次 content 字节预算。auto 会按 phase/tools/outputs/context 自适应;
79
+ # 大型工程仍应拆成模块/函数/类边界增量写入,而不是单次写巨型文件。
80
+ # max_write_chunk_bytes: auto
81
+ # subprocess | docker
82
+ # subprocess (默认):在嬿主机 venv 内直接 spawn,快但无隔离
83
+ # docker: 使用系统 docker daemon,bind-mount 工程目录到容器;debug 时直接修改工程代码即生效
84
+ sandbox: subprocess
85
+ sandbox_limits:
86
+ cpu: 1
87
+ memory_mb: 1024
88
+ wall_seconds: 60
89
+ # off | download-only (default) | full
90
+ # download-only — outbound HTTP/HTTPS allowed, no inbound port publishing
91
+ # pypi-only — legacy value, rejected because Docker cannot enforce a domain allowlist
92
+ # full — also publishes `expose_ports` to 127.0.0.1 for testing
93
+ # Python / Node network apps from the host side
94
+ network: download-only
95
+ # When network=full, container ports listed here are published on
96
+ # 127.0.0.1:<port> so host-side tests can reach the running app.
97
+ # expose_ports: [8000]
98
+ sandbox_docker:
99
+ # Default image is chosen from agent.language:
100
+ # python -> python:3.11-slim
101
+ # typescript -> node:20-slim
102
+ image: python:3.11-slim
103
+ workdir: /workspace
104
+ pull: false
105
+ docker_bin: docker
106
+ extra_run_args: []
@@ -129,6 +129,7 @@ declare const PlanSchema: z.ZodPipe<z.ZodObject<{
129
129
  refactor: "refactor";
130
130
  self: "self";
131
131
  }>>;
132
+ phaseId: z.ZodDefault<z.ZodString>;
132
133
  projectType: z.ZodDefault<z.ZodEnum<{
133
134
  application: "application";
134
135
  library: "library";
@@ -222,6 +223,7 @@ declare const PlanSchema: z.ZodPipe<z.ZodObject<{
222
223
  version: "1";
223
224
  language: "python" | "typescript";
224
225
  intent: "greenfield" | "feature" | "refactor" | "self";
226
+ phaseId: string;
225
227
  projectType: "application" | "library" | "mixed";
226
228
  requirementDigest: string;
227
229
  globalPrompt: string;
@@ -278,6 +280,7 @@ declare const PlanSchema: z.ZodPipe<z.ZodObject<{
278
280
  version: "1";
279
281
  language: "python" | "typescript";
280
282
  intent: "greenfield" | "feature" | "refactor" | "self";
283
+ phaseId: string;
281
284
  projectType: "application" | "library" | "mixed";
282
285
  requirementDigest: string;
283
286
  globalPrompt: string;
@@ -362,6 +365,12 @@ interface ChatOptions {
362
365
  * 空输出、model token loop 等“表面成功但语义不可用”场景。
363
366
  */
364
367
  validate?: (text: string) => void;
368
+ /**
369
+ * Whether a provider response should increase its dynamic score.
370
+ * Step/workflow executors should disable this and score quality through
371
+ * their own validation instead of treating "returned text" as task success.
372
+ */
373
+ scoreSuccess?: boolean;
365
374
  /**
366
375
  * 调用者可传入回调,与 LLM 输出一同拿到实际产出该响应的 provider 名。
367
376
  * 主要用于追溯:在 FallbackClient 中服务于响应的是链中某一个后选 provider,
@@ -515,7 +524,7 @@ interface Sandbox {
515
524
  /**
516
525
  * 运行工程入口程序。
517
526
  * - Python:`python <args>`(自动选用 venv 内解释器)。
518
- * - TypeScript:`npx tsx <args>`。
527
+ * - TypeScript:默认 `npx tsx <entry>`;当 args 以 `npm`/`npx`/`node`/`tsx`/`tsc` 开头时执行对应项目命令。
519
528
  */
520
529
  runProgram(args: string[], extra?: ExecExtra): Promise<ExecResult>;
521
530
  /**
@@ -577,6 +586,8 @@ interface ToolContext {
577
586
  language?: Language;
578
587
  /** 当前 Step 的 write_file / append_file 单次 content 字节预算。 */
579
588
  writeChunkBytes?: number;
589
+ /** run_tests 未提供有效过滤参数时使用的当前阶段默认测试范围。 */
590
+ defaultTestArgs?: string[];
580
591
  /** Optional protocol/UI permission hook for sensitive tool operations. */
581
592
  requestPermission?: ToolPermissionRequester;
582
593
  /** Optional protocol/UI event hook for tool calls and file changes. */
@@ -653,6 +664,8 @@ interface HookContextMap {
653
664
  'compile.finish': {
654
665
  plan: Plan;
655
666
  planPath: string;
667
+ phasePlanPath?: string;
668
+ currentPlanPath?: string;
656
669
  };
657
670
  'run.before': {
658
671
  plan: Plan;
@@ -868,7 +881,7 @@ interface CompileOptions {
868
881
  * 已澄清的 topic.md 直接输入:跳过 intake / clarify / Addenda / Gate 1,把该文件
869
882
  * 内容当作冻结后的项目选题书,直接进入 decompose。常用于:
870
883
  * - 用户上次已澄清并保留了 topic.md,重新跑 decompose 不想再问一遍
871
- * - 离线编辑了 topic.md 想直接拿来出 plan.json
884
+ * - 离线编辑了 topic.md 想直接拿来出 phasePlan.json 与当前阶段计划
872
885
  * 与 --input 互斥;同时给则 --topic 优先并打印警告。
873
886
  */
874
887
  topicFile?: string;