dsh-lean-router 2.1.1 → 2.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cordis.patch.yml +62 -60
- package/docs/agents/release.md +18 -0
- package/docs/agents/verification.md +18 -0
- package/docs/changelog.en.md +17 -1
- package/docs/changelog.md +17 -1
- package/lib/lean/persona-text.js +34 -37
- package/lib/lean/usage-ledger.js +246 -0
- package/lib/toolface/discovery.js +26 -11
- package/lib/toolface/rules.js +5 -4
- package/package.json +2 -1
- package/presets/base/frag-lean.patch.yml +37 -30
- package/presets/base/frag-preset.patch.yml +25 -30
- package/scripts/release.mjs +138 -0
- package/test/lean-frag.test.mjs +3 -3
- package/test/lean-modules.test.mjs +7 -7
- package/test/patch-yaml.test.mjs +1 -1
- package/test/toolface-mask.test.mjs +47 -6
- package/test/toolface-rules.test.mjs +3 -1
- package/test/usage-ledger.test.mjs +208 -0
package/cordis.patch.yml
CHANGED
|
@@ -78,40 +78,37 @@
|
|
|
78
78
|
LEAN OPERATING RULES (hard constraints; they override habit and tool default wording):
|
|
79
79
|
|
|
80
80
|
BUDGET FIRST
|
|
81
|
-
1. Turn budget, not step budget. Target <=20 turns;
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
2. Deliberate briefly.
|
|
85
|
-
|
|
81
|
+
1. Turn budget, not step budget. Target <=20 turns; folding calls into one turn is cheap, thrashing
|
|
82
|
+
across turns is not. Past 3x the expected turns (~60), stop and re-plan instead of looping.
|
|
83
|
+
Re-check roughly every 10 turns that this is still the shortest path; if it is not, re-plan.
|
|
84
|
+
2. Deliberate briefly. One short deliberation, then one cheap probe/command to learn the facts;
|
|
85
|
+
do not enumerate an exhaustive design before acting.
|
|
86
86
|
3. Input/answer-type tasks (submit a file or an answer): produce the SMALLEST artifact that
|
|
87
87
|
satisfies the stated constraints first; refine only while you are under the turn budget.
|
|
88
|
-
4. Gate before delivery, not after.
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
the
|
|
92
|
-
|
|
93
|
-
do not verify claim by claim, do not re-run a check that already passed, and name what you did not
|
|
94
|
-
verify. Once the gate passes, stop testing and deliver: do not add extra randomized or stress rounds unless the gate itself failed.
|
|
88
|
+
4. Gate before delivery, not after. Run ONE consolidated acceptance pass over every stated
|
|
89
|
+
criterion, quote the measured numbers, and name what you did not verify. Measure hard limits
|
|
90
|
+
with the command the judge would use (/usr/bin/time -v, ulimit -v). Over-limit is a failure even
|
|
91
|
+
when the answer is otherwise correct. Do not verify claim by claim, do not re-run a check that
|
|
92
|
+
already passed, and once the gate passes stop testing and deliver.
|
|
95
93
|
|
|
96
94
|
5. Tool choice. Inspect files with read/glob/grep; never use the shell to browse a file
|
|
97
|
-
(no cat/head/tail/sed -n/find/ls -R)
|
|
98
|
-
6. Output budget. Batch independent calls into one step
|
|
99
|
-
(| head -40; redirect to
|
|
95
|
+
(no cat/head/tail/sed -n/find/ls -R). Piping a command's own output through head is fine.
|
|
96
|
+
6. Output budget. Batch independent calls into one step; pipe or redirect long output
|
|
97
|
+
(| head -40; redirect to $env:TEMP/out.log on PowerShell, %TEMP%\out.log in cmd, /tmp/out.log on POSIX).
|
|
100
98
|
Never print a dump you could grep.
|
|
101
99
|
7. Programmatic tool mode, adaptively. Fold 3+ independent calls of one logical step into ONE
|
|
102
|
-
run_code program; a single
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
re-emit an unchanged file. After two failed shell patches, switch to the editor.
|
|
100
|
+
run_code program; a single call may still go through a one-line program so its noise stays out
|
|
101
|
+
of context. Measured: pays off on multi-file/repo work (up to 8x fewer turns) and is neutral on
|
|
102
|
+
single-file algorithm tasks - there spend the budget on reasoning and testing, not batching.
|
|
103
|
+
8. Context discipline (biggest measured lever). Read only what is new; rebuild derived answers
|
|
104
|
+
from files with grep/scripts instead of re-reading them into context. Keep NOTES short and
|
|
105
|
+
factual (<=60 lines).
|
|
106
|
+
9. Author incrementally: create a file once (skeleton), then extend it with edit. Never re-emit an
|
|
107
|
+
unchanged file. After two failed shell patches, switch to the editor.
|
|
111
108
|
|
|
112
109
|
SAFETY
|
|
113
|
-
10.
|
|
114
|
-
|
|
110
|
+
10. Honour scope literally (a new project means do not read or copy old-project files). Use
|
|
111
|
+
subagents only when the user asks or the harness delegates; never spawn them to look busy.
|
|
115
112
|
11. Never put secrets, tokens or private raw material into the session; reference by path.
|
|
116
113
|
|
|
117
114
|
WHEN BLOCKED
|
|
@@ -121,13 +118,11 @@
|
|
|
121
118
|
prefer fewer, larger turns; on a low-latency route more probing is affordable. Never trade
|
|
122
119
|
correctness for turn count.
|
|
123
120
|
|
|
124
|
-
SOFT GATES (
|
|
121
|
+
SOFT GATES (each is one pause, never a stall)
|
|
125
122
|
- CLARIFY: if goal, scope, or acceptance is ambiguous in a way that changes the result, ask one consolidated question round before acting; when a cheap read/probe settles it, probe instead of asking.
|
|
126
|
-
- PLAN: work touching more than one file or more than ~8 steps starts
|
|
127
|
-
- DELIVER: run ONE consolidated acceptance pass over every stated criterion, quote measured numbers, name what was not verified, then stop (rule 4 is this gate's detail).
|
|
123
|
+
- PLAN: work touching more than one file or more than ~8 steps starts with a numbered plan with a check per step; single-file small changes skip this gate.
|
|
128
124
|
|
|
129
125
|
SELF-CHECK HOOKS (questions answered to yourself; speak up only when a check fails)
|
|
130
|
-
- Diligence (~every 10 turns): what changed since the last check, and is this still the shortest path to done? If not, re-plan; do not repeat the loop.
|
|
131
126
|
- Close-the-book: could I redo the last step with the AI closed - do I actually know this fact, command, or path, or would I have to look it up again? If look-up, fetch it from the source of truth now instead of trusting recall.
|
|
132
127
|
|
|
133
128
|
# [ticket-05] 路由分类指令由票 05 拼接(本行为占位:集成时替换为票 05 的 ROUTER_PROMPT 常量)
|
|
@@ -481,6 +476,18 @@
|
|
|
481
476
|
config:
|
|
482
477
|
toolConcurrency:
|
|
483
478
|
enabled: true
|
|
479
|
+
|
|
480
|
+
# ============ 新增行:live Usage 账本挂载点(加料件)============
|
|
481
|
+
# 默认开启:订阅 session/event,采集带 usage 的 assistant/message(lib/token-ledger/live.js)。
|
|
482
|
+
# 斜杠命令 token-report([session|all])读账本,输出记录条数、prompt 总量、五项分项与最近一条 turn/step/seq;
|
|
483
|
+
# 无记录时返回 success 并提示尚未采集。插件实现 = lib/lean/usage-ledger.js;
|
|
484
|
+
# 插件行 name 为包内子路径,需 package.json exports 增加 ./lean/usage-ledger(master 集成)。
|
|
485
|
+
|
|
486
|
+
- insert:
|
|
487
|
+
- id: lean-usage-ledger
|
|
488
|
+
name: 'dsh-lean-router/lean/usage-ledger'
|
|
489
|
+
config:
|
|
490
|
+
enabled: true
|
|
484
491
|
# dsh-lean-router frag-toolface.patch.yml — 票 04 工具遮蔽层
|
|
485
492
|
# 由 scripts/build-bundle.mjs 拼在 presets/base/lean-router.patch.yml 之后(顶层列表续项)。
|
|
486
493
|
# 形态与上游 dsh-codemode 0.3.x 样本一致(cordis patch 顶层 "- <op>:" 列表;本分片为
|
|
@@ -594,40 +601,37 @@
|
|
|
594
601
|
LEAN OPERATING RULES (hard constraints; they override habit and tool default wording):
|
|
595
602
|
|
|
596
603
|
BUDGET FIRST
|
|
597
|
-
1. Turn budget, not step budget. Target <=20 turns;
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
2. Deliberate briefly.
|
|
601
|
-
|
|
604
|
+
1. Turn budget, not step budget. Target <=20 turns; folding calls into one turn is cheap, thrashing
|
|
605
|
+
across turns is not. Past 3x the expected turns (~60), stop and re-plan instead of looping.
|
|
606
|
+
Re-check roughly every 10 turns that this is still the shortest path; if it is not, re-plan.
|
|
607
|
+
2. Deliberate briefly. One short deliberation, then one cheap probe/command to learn the facts;
|
|
608
|
+
do not enumerate an exhaustive design before acting.
|
|
602
609
|
3. Input/answer-type tasks (submit a file or an answer): produce the SMALLEST artifact that
|
|
603
610
|
satisfies the stated constraints first; refine only while you are under the turn budget.
|
|
604
|
-
4. Gate before delivery, not after.
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
the
|
|
608
|
-
|
|
609
|
-
do not verify claim by claim, do not re-run a check that already passed, and name what you did not
|
|
610
|
-
verify. Once the gate passes, stop testing and deliver: do not add extra randomized or stress rounds unless the gate itself failed.
|
|
611
|
+
4. Gate before delivery, not after. Run ONE consolidated acceptance pass over every stated
|
|
612
|
+
criterion, quote the measured numbers, and name what you did not verify. Measure hard limits
|
|
613
|
+
with the command the judge would use (/usr/bin/time -v, ulimit -v). Over-limit is a failure even
|
|
614
|
+
when the answer is otherwise correct. Do not verify claim by claim, do not re-run a check that
|
|
615
|
+
already passed, and once the gate passes stop testing and deliver.
|
|
611
616
|
|
|
612
617
|
5. Tool choice. Inspect files with read/glob/grep; never use the shell to browse a file
|
|
613
|
-
(no cat/head/tail/sed -n/find/ls -R)
|
|
614
|
-
6. Output budget. Batch independent calls into one step
|
|
615
|
-
(| head -40; redirect to
|
|
618
|
+
(no cat/head/tail/sed -n/find/ls -R). Piping a command's own output through head is fine.
|
|
619
|
+
6. Output budget. Batch independent calls into one step; pipe or redirect long output
|
|
620
|
+
(| head -40; redirect to $env:TEMP/out.log on PowerShell, %TEMP%\out.log in cmd, /tmp/out.log on POSIX).
|
|
616
621
|
Never print a dump you could grep.
|
|
617
622
|
7. Programmatic tool mode, adaptively. Fold 3+ independent calls of one logical step into ONE
|
|
618
|
-
run_code program; a single
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
re-emit an unchanged file. After two failed shell patches, switch to the editor.
|
|
623
|
+
run_code program; a single call may still go through a one-line program so its noise stays out
|
|
624
|
+
of context. Measured: pays off on multi-file/repo work (up to 8x fewer turns) and is neutral on
|
|
625
|
+
single-file algorithm tasks - there spend the budget on reasoning and testing, not batching.
|
|
626
|
+
8. Context discipline (biggest measured lever). Read only what is new; rebuild derived answers
|
|
627
|
+
from files with grep/scripts instead of re-reading them into context. Keep NOTES short and
|
|
628
|
+
factual (<=60 lines).
|
|
629
|
+
9. Author incrementally: create a file once (skeleton), then extend it with edit. Never re-emit an
|
|
630
|
+
unchanged file. After two failed shell patches, switch to the editor.
|
|
627
631
|
|
|
628
632
|
SAFETY
|
|
629
|
-
10.
|
|
630
|
-
|
|
633
|
+
10. Honour scope literally (a new project means do not read or copy old-project files). Use
|
|
634
|
+
subagents only when the user asks or the harness delegates; never spawn them to look busy.
|
|
631
635
|
11. Never put secrets, tokens or private raw material into the session; reference by path.
|
|
632
636
|
|
|
633
637
|
WHEN BLOCKED
|
|
@@ -637,13 +641,11 @@
|
|
|
637
641
|
prefer fewer, larger turns; on a low-latency route more probing is affordable. Never trade
|
|
638
642
|
correctness for turn count.
|
|
639
643
|
|
|
640
|
-
SOFT GATES (
|
|
644
|
+
SOFT GATES (each is one pause, never a stall)
|
|
641
645
|
- CLARIFY: if goal, scope, or acceptance is ambiguous in a way that changes the result, ask one consolidated question round before acting; when a cheap read/probe settles it, probe instead of asking.
|
|
642
|
-
- PLAN: work touching more than one file or more than ~8 steps starts
|
|
643
|
-
- DELIVER: run ONE consolidated acceptance pass over every stated criterion, quote measured numbers, name what was not verified, then stop (rule 4 is this gate's detail).
|
|
646
|
+
- PLAN: work touching more than one file or more than ~8 steps starts with a numbered plan with a check per step; single-file small changes skip this gate.
|
|
644
647
|
|
|
645
648
|
SELF-CHECK HOOKS (questions answered to yourself; speak up only when a check fails)
|
|
646
|
-
- Diligence (~every 10 turns): what changed since the last check, and is this still the shortest path to done? If not, re-plan; do not repeat the loop.
|
|
647
649
|
- Close-the-book: could I redo the last step with the AI closed - do I actually know this fact, command, or path, or would I have to look it up again? If look-up, fetch it from the source of truth now instead of trusting recall.
|
|
648
650
|
|
|
649
651
|
Routing: before acting on any new task, classify it - (build) create something new end-to-end, or (fix) diagnose and repair something broken - then adopt the matching style: build -> hands-on production; fix -> inspect-and-plan.
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
# 发布(release)
|
|
2
|
+
|
|
3
|
+
一条命令发布:`node scripts/release.mjs <version>`。加 `--dry-run` 只跑测试与 verify,不改版本、不发布。
|
|
4
|
+
|
|
5
|
+
脚本只做机械步骤:校验 semver 与工作树、跑 `npm test` 与 `npm run verify`、改 `package.json`、提交、`npm publish --registry https://registry.npmjs.org`、轮询可见性(最长 5 分钟)、临时目录 `npm install` 验证版本。
|
|
6
|
+
|
|
7
|
+
**changelog 必须先人工写。** 脚本会检查 `docs/changelog.md` 与 `docs/changelog.en.md` 都已有 `## <version>` 标题,缺一个就中止——中英两份都要写,不要只改中文。
|
|
8
|
+
|
|
9
|
+
## 本机环境陷阱
|
|
10
|
+
|
|
11
|
+
- 默认 registry 是 `registry.npmmirror.com`,那是只读镜像。`npm whoami` 会因此返回 `ENEEDAUTH`,**不代表没登录**;用 `npm whoami --registry https://registry.npmjs.org` 复核。发布一律显式带 `--registry`。
|
|
12
|
+
- `npm pack --dry-run` / `npm publish` 把 notice 写到 stderr,PowerShell 会把它当错误并使退出码变成 1。用 `cmd /c "npm ... 2>&1"` 或只看 stdout 判断。
|
|
13
|
+
- `npm publish` 返回成功后 registry 仍要约 90 秒才可见,立刻 `npm view` 会 404。不要把 404 当发布失败。
|
|
14
|
+
- `npm.ps1` 在本机可能因 `npmNodeDir` 为空失败,一律用 `npm.cmd`。
|
|
15
|
+
|
|
16
|
+
## 版本号判断
|
|
17
|
+
|
|
18
|
+
新增功能发 minor,修复与内部优化发 patch;先 `npm view <pkg> version` 确认远端当前版本,避免重发已存在的号。
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
# 验证与复核(verification)
|
|
2
|
+
|
|
3
|
+
## 子代理自报的数字必须复测
|
|
4
|
+
|
|
5
|
+
子代理报告的字符数、压缩率、测试数都要用**生产形状**的样本独立复测一次,再写进提交说明或对外结论。
|
|
6
|
+
|
|
7
|
+
只测"契约形状"不够:真实 `code_run` 的输出是 JSON,重复日志表现为 `logs` 字符串数组里的多个相同元素,而不是单个字符串内部的多行。用字符串内重复行去测,会得到漂亮的压缩率,却对真实输出零效果。
|
|
8
|
+
|
|
9
|
+
复测的做法:从宿主类型定义或现有实现里确认真实结构,构造同样的形状跑一遍,对比前后长度、可解析性、关键字段是否保留。
|
|
10
|
+
|
|
11
|
+
## arch 图操作复核
|
|
12
|
+
|
|
13
|
+
`.arch/` 是架构引擎自己的 shadow Git,不要 `git add` 进去;仓库已用 `.gitignore` 忽略,克隆后它不存在,需要时重新 `arch init`。
|
|
14
|
+
|
|
15
|
+
- `activate --node X --before Y` 只加 X→Y 这一条边,上游边不会自动出现。要落在两个节点之间,同时写 `--after A --before B`。
|
|
16
|
+
- `activate` 之后必须 `focus --node X` 核对 `upstream_edges` 与 `downstream_edges` 都不为空,再继续。
|
|
17
|
+
- 已经在主干的节点没有"只改接线"的命令;绕法是 `deactivate` 再 `activate`,但 `deactivate` 会把它移进迷雾区,之后要确认状态不是 `fog`。
|
|
18
|
+
- `collapse` 之后用 `focus` 确认 `spec` 已更新;如果仍显示旧 spec,说明写入没生效,不要假设成功。
|
package/docs/changelog.en.md
CHANGED
|
@@ -1,6 +1,22 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
-
> English version of [changelog.md](./changelog.md). Versions follow package.json (currently 2.
|
|
3
|
+
> English version of [changelog.md](./changelog.md). Versions follow package.json (currently 2.2.0).
|
|
4
|
+
|
|
5
|
+
## 2.2.0 (2026-11-29)
|
|
6
|
+
|
|
7
|
+
### Added
|
|
8
|
+
|
|
9
|
+
- **`/token-report` ledger command**: new `lib/lean/usage-ledger.js`, mounted as the top-level preset add-on `lean-usage-ledger`. It subscribes to the host's `session/event` feed and keeps only `assistant/message` events that carry `usage`. The command reports the record count, the `prompt` total (input+cacheRead+cacheWrite), all five usage fields, and the latest record's `turn/step/seq`; with no records it says so explicitly. Every failure path only warns, and unloading releases the subscription.
|
|
10
|
+
|
|
11
|
+
### Improved
|
|
12
|
+
|
|
13
|
+
- **Lazy parameter schemas in `search`**: `code_tools_search` no longer returns the full `parameters` and `output` schemas, but a `params` array of argument names (`noParams` when nothing is enumerable); the complete schema comes from `code_tools_describe`. A full 8-row page measured 8380 to 1924 characters (-77%).
|
|
14
|
+
- **Lean persona no-op audit**: removed the language requirement the host already injects, the `DELIVER` gate duplicated by rule 4, and the `Diligence` hook overlapping rule 1, then tightened wording: 4581 to 3862 characters (-15.7%). All 13 numbered rules and their criteria remain.
|
|
15
|
+
|
|
16
|
+
### Notes
|
|
17
|
+
|
|
18
|
+
- All three changes are static or output-side; real gains need a restart to be observed inside the host, and no device verification has been done yet.
|
|
19
|
+
- Since `search` now returns only argument names, call `describe` before invoking an unfamiliar tool; the SDK text has been rewritten to say so.
|
|
4
20
|
|
|
5
21
|
## 2.1.1 (2026-11-29)
|
|
6
22
|
|
package/docs/changelog.md
CHANGED
|
@@ -1,6 +1,22 @@
|
|
|
1
1
|
# 变更记录(changelog)
|
|
2
2
|
|
|
3
|
-
> 中文为主,英文版:[changelog.en.md](./changelog.en.md)。版本号遵循 package.json(当前 2.
|
|
3
|
+
> 中文为主,英文版:[changelog.en.md](./changelog.en.md)。版本号遵循 package.json(当前 2.2.0)。
|
|
4
|
+
|
|
5
|
+
## 2.2.0 (2026-11-29)
|
|
6
|
+
|
|
7
|
+
### 新增
|
|
8
|
+
|
|
9
|
+
- **`/token-report` 账本命令**:新增 `lib/lean/usage-ledger.js`,以预设顶层加料件 `lean-usage-ledger` 生效,订阅宿主的 `session/event` 并只收 `assistant/message` 且带 `usage` 的事件。命令输出记录条数、`prompt` 总量(input+cacheRead+cacheWrite)、五项分项与最近一条的 `turn/step/seq`;没有任何记录时明确说明尚未采集。所有失败路径只 warn 不抛,卸载时释放订阅。
|
|
10
|
+
|
|
11
|
+
### 优化
|
|
12
|
+
|
|
13
|
+
- **`search` 懒取参数 schema**:`code_tools_search` 不再返回完整 `parameters` 与 `output` schema,改为返回 `params` 参数名数组(无可枚举属性时给 `noParams`);完整 schema 由 `code_tools_describe` 提供。8 行满页实测输出 8380→1924 字符(-77%)。
|
|
14
|
+
- **lean persona no-op 审查**:删去宿主已注入的语言要求、与规则 4 重复的 `DELIVER` 软门、与规则 1 重叠的 `Diligence` 钩子并压缩措辞,4581→3862 字符(-15.7%);13 条规则编号与全部判据保留。
|
|
15
|
+
|
|
16
|
+
### 说明
|
|
17
|
+
|
|
18
|
+
- 三项都是静态或输出侧改动,真实收益需重启后在宿主里观察,尚未做真机验证。
|
|
19
|
+
- `search` 只给参数名后,调用不熟悉参数形状的工具前应先 `describe`;SDK 文本已同步改写。
|
|
4
20
|
|
|
5
21
|
## 2.1.1 (2026-11-29)
|
|
6
22
|
|
package/lib/lean/persona-text.js
CHANGED
|
@@ -6,14 +6,16 @@
|
|
|
6
6
|
// - D:\Agent Workspace\.scratch\upstream\flash-presets\presets\flash-lean-ptc-v3-balance.patch.yml
|
|
7
7
|
// L13-18:balance 3 条规则全文
|
|
8
8
|
// 本包增补(批准计划 .scratch/dsh-lean-router/plan.md L45/L107,62 问定案):
|
|
9
|
-
// -
|
|
10
|
-
// -
|
|
11
|
-
// 与「合上 AI 也能做」合卷自检(可配关,config 由票 05/master 接)
|
|
9
|
+
// - 软门:澄清 → 计划(交付门由规则 4 覆盖,不再单列)
|
|
10
|
+
// - 自检题钩子:只保留「合上 AI 也能做」合卷自检;勤勉自检并入规则 1
|
|
12
11
|
// - 两个 suffix 末行各留一行拼接占位:路由分类指令由票 05 拼接(t5 交付 ROUTER_PROMPT
|
|
13
12
|
// 常量,master 集成时替换占位行;本文件不写任何路由内容)
|
|
14
|
-
//
|
|
13
|
+
// 适配说明(与上游的实质差异):
|
|
15
14
|
// - 规则 7 删去 "run_code is the only tool this surface exposes"(flash 的 PTC-only 工具面
|
|
16
15
|
// 口径);本包工具面为票 04 的 native+code_run,折叠逻辑原样保留。
|
|
16
|
+
// - no-op 审查(2026-11-29):删去宿主已注入的 "Answer in the user's language"、
|
|
17
|
+
// 与规则 4 重复的 DELIVER 软门、与规则 1 重叠的 Diligence 钩子,并压缩各条措辞;
|
|
18
|
+
// 每条约束的判据保留,4581 → 约 3.4k 字符。
|
|
17
19
|
// 零依赖数据模块:纯 node / 任何宿主环境均可直接动态 import,不崩溃。
|
|
18
20
|
|
|
19
21
|
/** persona 前缀(照抄上游两档共用的 prefix,flash-lean-ptc-v3.patch.yml L60)。 */
|
|
@@ -23,58 +25,53 @@ export const PERSONA_PREFIX = 'You are a coding agent powered by the {{model}} m
|
|
|
23
25
|
export const ROUTER_SLOT_COMMENT =
|
|
24
26
|
'# [ticket-05] 路由分类指令由票 05 拼接(本行为占位:集成时替换为票 05 的 ROUTER_PROMPT 常量)';
|
|
25
27
|
|
|
26
|
-
/** lean 档
|
|
28
|
+
/** lean 档 2 软门(澄清/计划两晋级条件;交付门已由规则 4 覆盖,不再重复)。 */
|
|
27
29
|
export const LEAN_SOFT_GATES = [
|
|
28
30
|
'CLARIFY: if goal, scope, or acceptance is ambiguous in a way that changes the result, ask one consolidated question round before acting; when a cheap read/probe settles it, probe instead of asking.',
|
|
29
|
-
'PLAN: work touching more than one file or more than ~8 steps starts
|
|
30
|
-
'DELIVER: run ONE consolidated acceptance pass over every stated criterion, quote measured numbers, name what was not verified, then stop (rule 4 is this gate\'s detail).',
|
|
31
|
+
'PLAN: work touching more than one file or more than ~8 steps starts with a numbered plan with a check per step; single-file small changes skip this gate.',
|
|
31
32
|
];
|
|
32
33
|
|
|
33
|
-
/** lean
|
|
34
|
+
/** lean 档自检题钩子(合卷自检;勤勉自检并入规则 1 的停止重规划)。 */
|
|
34
35
|
export const LEAN_SELF_CHECK_HOOKS = [
|
|
35
|
-
'Diligence (~every 10 turns): what changed since the last check, and is this still the shortest path to done? If not, re-plan; do not repeat the loop.',
|
|
36
36
|
'Close-the-book: could I redo the last step with the AI closed - do I actually know this fact, command, or path, or would I have to look it up again? If look-up, fetch it from the source of truth now instead of trusting recall.',
|
|
37
37
|
];
|
|
38
38
|
|
|
39
|
-
/** lean 档 suffix 全文:13 条硬规则(上游原文,规则 7 微调见头部说明)+
|
|
39
|
+
/** lean 档 suffix 全文:13 条硬规则(上游原文,规则 7 微调见头部说明)+ 2 软门 + 自检钩 + 拼接占位。 */
|
|
40
40
|
export const LEAN_PERSONA_SUFFIX = [
|
|
41
41
|
'LEAN OPERATING RULES (hard constraints; they override habit and tool default wording):',
|
|
42
42
|
'',
|
|
43
43
|
'BUDGET FIRST',
|
|
44
|
-
'1. Turn budget, not step budget. Target <=20 turns;
|
|
45
|
-
'
|
|
46
|
-
'
|
|
47
|
-
'2. Deliberate briefly.
|
|
48
|
-
'
|
|
44
|
+
'1. Turn budget, not step budget. Target <=20 turns; folding calls into one turn is cheap, thrashing',
|
|
45
|
+
' across turns is not. Past 3x the expected turns (~60), stop and re-plan instead of looping.',
|
|
46
|
+
' Re-check roughly every 10 turns that this is still the shortest path; if it is not, re-plan.',
|
|
47
|
+
'2. Deliberate briefly. One short deliberation, then one cheap probe/command to learn the facts;',
|
|
48
|
+
' do not enumerate an exhaustive design before acting.',
|
|
49
49
|
'3. Input/answer-type tasks (submit a file or an answer): produce the SMALLEST artifact that',
|
|
50
50
|
' satisfies the stated constraints first; refine only while you are under the turn budget.',
|
|
51
|
-
'4. Gate before delivery, not after.
|
|
52
|
-
'
|
|
53
|
-
'
|
|
54
|
-
' the
|
|
55
|
-
'
|
|
56
|
-
' do not verify claim by claim, do not re-run a check that already passed, and name what you did not',
|
|
57
|
-
' verify. Once the gate passes, stop testing and deliver: do not add extra randomized or stress rounds unless the gate itself failed.',
|
|
51
|
+
'4. Gate before delivery, not after. Run ONE consolidated acceptance pass over every stated',
|
|
52
|
+
' criterion, quote the measured numbers, and name what you did not verify. Measure hard limits',
|
|
53
|
+
' with the command the judge would use (/usr/bin/time -v, ulimit -v). Over-limit is a failure even',
|
|
54
|
+
' when the answer is otherwise correct. Do not verify claim by claim, do not re-run a check that',
|
|
55
|
+
' already passed, and once the gate passes stop testing and deliver.',
|
|
58
56
|
'',
|
|
59
57
|
'5. Tool choice. Inspect files with read/glob/grep; never use the shell to browse a file',
|
|
60
|
-
' (no cat/head/tail/sed -n/find/ls -R)
|
|
61
|
-
'6. Output budget. Batch independent calls into one step
|
|
62
|
-
' (| head -40; redirect to
|
|
58
|
+
' (no cat/head/tail/sed -n/find/ls -R). Piping a command\'s own output through head is fine.',
|
|
59
|
+
'6. Output budget. Batch independent calls into one step; pipe or redirect long output',
|
|
60
|
+
' (| head -40; redirect to $env:TEMP/out.log on PowerShell, %TEMP%\\out.log in cmd, /tmp/out.log on POSIX).',
|
|
63
61
|
' Never print a dump you could grep.',
|
|
64
62
|
'7. Programmatic tool mode, adaptively. Fold 3+ independent calls of one logical step into ONE',
|
|
65
|
-
' run_code program; a single
|
|
66
|
-
'
|
|
67
|
-
'
|
|
68
|
-
'
|
|
69
|
-
'
|
|
70
|
-
'
|
|
71
|
-
'
|
|
72
|
-
'
|
|
73
|
-
' re-emit an unchanged file. After two failed shell patches, switch to the editor.',
|
|
63
|
+
' run_code program; a single call may still go through a one-line program so its noise stays out',
|
|
64
|
+
' of context. Measured: pays off on multi-file/repo work (up to 8x fewer turns) and is neutral on',
|
|
65
|
+
' single-file algorithm tasks - there spend the budget on reasoning and testing, not batching.',
|
|
66
|
+
'8. Context discipline (biggest measured lever). Read only what is new; rebuild derived answers',
|
|
67
|
+
' from files with grep/scripts instead of re-reading them into context. Keep NOTES short and',
|
|
68
|
+
' factual (<=60 lines).',
|
|
69
|
+
'9. Author incrementally: create a file once (skeleton), then extend it with edit. Never re-emit an',
|
|
70
|
+
' unchanged file. After two failed shell patches, switch to the editor.',
|
|
74
71
|
'',
|
|
75
72
|
'SAFETY',
|
|
76
|
-
'10.
|
|
77
|
-
'
|
|
73
|
+
'10. Honour scope literally (a new project means do not read or copy old-project files). Use',
|
|
74
|
+
' subagents only when the user asks or the harness delegates; never spawn them to look busy.',
|
|
78
75
|
'11. Never put secrets, tokens or private raw material into the session; reference by path.',
|
|
79
76
|
'',
|
|
80
77
|
'WHEN BLOCKED',
|
|
@@ -84,7 +81,7 @@ export const LEAN_PERSONA_SUFFIX = [
|
|
|
84
81
|
' prefer fewer, larger turns; on a low-latency route more probing is affordable. Never trade',
|
|
85
82
|
' correctness for turn count.',
|
|
86
83
|
'',
|
|
87
|
-
'SOFT GATES (
|
|
84
|
+
'SOFT GATES (each is one pause, never a stall)',
|
|
88
85
|
...LEAN_SOFT_GATES.map((line) => '- ' + line),
|
|
89
86
|
'',
|
|
90
87
|
'SELF-CHECK HOOKS (questions answered to yourself; speak up only when a check fails)',
|