dsh-harness-kit 0.1.5 → 0.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.
Files changed (36) hide show
  1. package/README.md +30 -15
  2. package/README.zh-CN.md +29 -18
  3. package/client.js +108 -11
  4. package/docs/DETAIL.en.md +30 -10
  5. package/docs/DETAIL.md +15 -5
  6. package/kernel/advance.js +3 -3
  7. package/kernel/bindings.js +11 -6
  8. package/kernel/commands.js +257 -20
  9. package/kernel/local-files.js +175 -0
  10. package/kernel/metrics.js +280 -0
  11. package/kernel/panel.js +141 -7
  12. package/kernel/paths.js +62 -1
  13. package/kernel/setup.js +20 -19
  14. package/kernel/te.js +4 -4
  15. package/kernel/worktree.js +164 -20
  16. package/package.json +1 -1
  17. package/packs/ai-coding/agents/business-analyst.md +4 -4
  18. package/packs/ai-coding/agents/code-reviewer.md +6 -6
  19. package/packs/ai-coding/agents/developer.md +5 -5
  20. package/packs/ai-coding/agents/solution-architect.md +2 -2
  21. package/packs/ai-coding/assets/scripts/codebase_guide_init.py +70 -48
  22. package/packs/ai-coding/assets/scripts/harness_init.py +30 -11
  23. package/packs/ai-coding/assets/scripts/te_lease.py +106 -0
  24. package/packs/ai-coding/assets/scripts/update_board.py +30 -0
  25. package/packs/ai-coding/assets/scripts/verify.py +3 -3
  26. package/packs/ai-coding/assets/templates/dotnet/dotnet-multimodule/{app-CLAUDE.tmpl → app-AGENTS.tmpl} +5 -5
  27. package/packs/ai-coding/assets/templates/dotnet/dotnet-multimodule/{module-CLAUDE.tmpl → module-AGENTS.tmpl} +5 -5
  28. package/packs/ai-coding/assets/templates/dotnet/dotnet-multimodule/{root-CLAUDE.tmpl → root-AGENTS.tmpl} +3 -3
  29. package/packs/ai-coding/assets/templates/java/maven/{root-CLAUDE.tmpl → root-AGENTS.tmpl} +3 -3
  30. package/packs/ai-coding/assets/templates/java/maven-multimodule/{module-CLAUDE.tmpl → module-AGENTS.tmpl} +5 -5
  31. package/packs/ai-coding/assets/templates/java/maven-multimodule/{root-CLAUDE.tmpl → root-AGENTS.tmpl} +3 -3
  32. package/packs/ai-coding/assets/templates/javascript/mobile-app/{root-CLAUDE.tmpl → root-AGENTS.tmpl} +3 -3
  33. package/packs/ai-coding/assets/templates/javascript/uniapp/{root-CLAUDE.tmpl → root-AGENTS.tmpl} +3 -3
  34. package/packs/ai-coding/assets/templates/javascript/vue-multimodule/{app-CLAUDE.tmpl → app-AGENTS.tmpl} +4 -4
  35. package/packs/ai-coding/assets/templates/javascript/vue-multimodule/{root-CLAUDE.tmpl → root-AGENTS.tmpl} +3 -3
  36. package/packs/ai-coding/flows/init.yml +7 -7
package/README.md CHANGED
@@ -9,7 +9,7 @@ asset repository that keeps every round's output. **AI executes, humans gate, as
9
9
  Used alone, it is your project memory and a second pair of eyes. Used by a team, it is a shared
10
10
  process and shared assets.
11
11
 
12
- `7 roles` · `4 flow profiles` · `10 commands` · `zero runtime dependencies` · `local-first`
12
+ `7 roles` · `4 flow profiles` · `4 daily commands` · `zero runtime dependencies` · `local-first`
13
13
 
14
14
  English | [简体中文](README.zh-CN.md)
15
15
 
@@ -24,8 +24,8 @@ Harness Kit is not only a workflow. After the workspace is created, **Start init
24
24
  orchestration** probes the registered source repositories and fills in the project knowledge AI
25
25
  would otherwise rediscover every time:
26
26
 
27
- - a root `AGENTS.md` and a one-line `CLAUDE.md` pointer
28
- - per-repository `CLAUDE.md` (stack, module entry points) and `docs/CODE_STANDARDS.md` (coding rules)
27
+ - a root `AGENTS.md`; existing `CLAUDE.md` is left untouched and also read by DSH
28
+ - per-repository `AGENTS.md` (or an existing `CLAUDE.md`) and `docs/CODE_STANDARDS.md` (coding rules)
29
29
  - `<repo>/.harness/build.json`: build, start and test commands
30
30
  - `codebase-guide/`: module docs loaded on demand instead of into every prompt
31
31
  - per-repository `.codegraph/`: class, method and call-chain indexes the AI can query instead of reading everything
@@ -195,7 +195,8 @@ go only to the provider you configure.
195
195
  ├── deliverables/ # per-round artifacts + _archive/
196
196
  ├── specs/ # capability specs, appended per round
197
197
  ├── memory/ # lessons, one file per entry
198
- ├── tasks/ # board + machine-local state (sessions, claims, worktrees, test lease)
198
+ ├── tasks/ # board + shared claims
199
+ ├── local/ # machine-local state (sessions, worktrees, lease, local config)
199
200
  ├── agents/ flows/ # project-level role and flow overrides
200
201
  └── scripts/ rules/ # refreshed with the plugin, not committed
201
202
  ```
@@ -207,23 +208,37 @@ go only to the provider you configure.
207
208
  - Test-environment lease: `/hk-te` keeps one task at a time on the single test environment
208
209
  - Model routing: `kit.json` maps logical names (`reasoning`, `coding`, `fast`, or a role name) to a
209
210
  concrete provider/model; unmapped names fall back to the session default
211
+ - Zero-touch closeout: `/hk close` updates the target branch, merges a clean task branch locally,
212
+ releases the slot and deletes the merged branch. It never pushes; conflicts or ambiguous targets
213
+ stop before archiving. `--no-merge` archives documents only, `--dry-run` previews the plan.
214
+ - Per-round run records: every archive writes `_archive/<task>/metrics/R<N>.json` with the actual
215
+ provider/model/effort, token components, active duration and tool failures. The panel shows the
216
+ same summary live. No prompts, message bodies or raw session ids are recorded.
210
217
 
211
218
  ---
212
219
 
213
- ## Command reference (advanced)
220
+ ## Command reference
221
+
222
+ Four daily entries:
223
+
224
+ | Command | What it does |
225
+ |---|---|
226
+ | `/hk init [--assets <url\|init\|local>]` | Initialize or repair `.harness/`, bind the asset repository |
227
+ | `/hk task [<task>] <description> [--file <path>] [--fix]` | Start a full-flow task; `--fix` starts the quick fix path |
228
+ | `/hk close <task> [--merge\|--no-merge] [--dry-run]` | Archive a round, close the worktree and write run metrics |
229
+ | `/hk doctor [--fix]` | Health check; `--fix` repairs deterministic gaps |
230
+
231
+ Advanced aliases remain available:
214
232
 
215
233
  | Command | What it does |
216
234
  |---|---|
217
235
  | `/hk-setup [--add <git-url>]` | Register source repositories in `kit.json`, cloning missing ones |
218
- | `/hk-init [--assets <url\|init\|local>]` | Initialize or refresh `.harness/`, bind the asset repository |
219
- | `/hk-new [<task>] <description> [--file <path>]` | Start a full-flow task |
220
- | `/hk-propose <task>` | Run the propose phase |
221
- | `/hk-apply <task> [feedback]` | Run the apply phase |
222
- | `/hk-archive <task>` | Archive the round and run Spec/Memory merge |
223
- | `/hk-fix [<task>] <description> [--full\|--light]` | Run the lightweight fix path |
236
+ | `/hk-new` / `/hk-fix` | Task creation aliases |
237
+ | `/hk-propose` / `/hk-apply` | Manual recovery of the automatic propose/apply handoff |
238
+ | `/hk-archive` | Alias of `/hk close` |
224
239
  | `/hk-te [acquire\|release <task> \| status]` | Serial test-environment lease |
240
+ | `/hk-local [...]` | Discover/approve git-ignored local config files |
225
241
  | `/hk-sync` | Sync the asset repository (commit → rebase → append merge → push) |
226
- | `/hk-doctor` | Check workspace health: kit, roles, rules, flows, scripts, board, model mappings |
227
242
 
228
243
  ---
229
244
 
@@ -234,7 +249,7 @@ go only to the provider you configure.
234
249
  **Plugins → Add plugin**, then enter:
235
250
 
236
251
  ```
237
- dsh-harness-kit@0.1.5
252
+ dsh-harness-kit@0.2.0
238
253
  ```
239
254
 
240
255
  Enable the bundle after installation.
@@ -242,7 +257,7 @@ Enable the bundle after installation.
242
257
  ### Command line
243
258
 
244
259
  ```sh
245
- dsh plugin --profile desktop add dsh-harness-kit@0.1.5
260
+ dsh plugin --profile desktop add dsh-harness-kit@0.2.0
246
261
  ```
247
262
 
248
263
  Quit DSH Desktop first; replace `desktop` with your profile name for other profiles.
@@ -282,7 +297,7 @@ rework and handover cost earlier instead of removing them.
282
297
  **Is it worth it for a solo developer?**
283
298
  Yes. Solo work loses context and rhythm most easily: the harness keeps each round's specs, lessons
284
299
  and decisions in files, so the next session does not start from zero. The CR/TE roles act as a fixed
285
- second pass, and the generated `CLAUDE.md`, `build.json` and CodeGraph index save the AI from
300
+ second pass, and the generated `AGENTS.md` (or existing `CLAUDE.md`), `build.json` and CodeGraph index save the AI from
286
301
  re-reading the project every time.
287
302
 
288
303
  **Do I have to use the full flow?**
package/README.zh-CN.md CHANGED
@@ -6,7 +6,7 @@ Harness Kit 是 DeepSeek Harness 的多 Agent 工程流程插件:它把方案
6
6
 
7
7
  一个人用,它是你的项目记忆和第二双眼睛;一个团队用,它是共享的流程和资产。
8
8
 
9
- `7 个角色` · `4 档流程` · `10 个命令` · `零运行时依赖` · `数据留在本地`
9
+ `7 个角色` · `4 档流程` · `4 个日常入口` · `零运行时依赖` · `数据留在本地`
10
10
 
11
11
  [English](README.md) | 简体中文
12
12
 
@@ -18,8 +18,8 @@ Harness Kit 是 DeepSeek Harness 的多 Agent 工程流程插件:它把方案
18
18
 
19
19
  Harness Kit 不只是"加流程"。创建完成后点「启动初始化编排」,它会探测已登记的子工程,把 AI 每次都要重新摸索的项目知识补齐:
20
20
 
21
- - 根目录 `AGENTS.md`,以及一行指针 `CLAUDE.md`
22
- - 每个子工程的 `CLAUDE.md`(技术栈、模块入口)和 `docs/CODE_STANDARDS.md`(编码规范)
21
+ - 根目录 `AGENTS.md`;已有 `CLAUDE.md` 不覆盖,DSH 也会读取
22
+ - 每个子工程的 `AGENTS.md`(已有 `CLAUDE.md` 则保留)和 `docs/CODE_STANDARDS.md`(编码规范)
23
23
  - `<子工程>/.harness/build.json`:编译、启动、测试命令
24
24
  - `codebase-guide/`:模块级文档,按需加载,不占上下文
25
25
  - 每个子工程的 `.codegraph/`:类、方法、调用链索引,AI 直接查,不必全量读代码
@@ -46,13 +46,13 @@ Harness Kit 不只是"加流程"。创建完成后点「启动初始化编排」
46
46
 
47
47
  ### 2. 点「+」立项
48
48
 
49
- - 选「需求」或「fix 直通」
49
+ - 选「需求」或「快速修复」
50
50
  - 写一句话描述;任务名可以留空,自动生成英文短名
51
51
  - 可选附一份需求文件
52
52
 
53
53
  点「立项」后会自动打开一个**专属会话**开始执行:需求模式从 proposal 起草开始,fix 模式从缺陷文档与质量门开始。
54
54
 
55
- ![新建任务:需求或 fix 直通,一句话描述即可立项](docs/assets/ui-new-task.png)
55
+ ![新建任务:需求或快速修复,一句话描述即可立项](docs/assets/ui-new-task.png)
56
56
 
57
57
  ### 3. 回到面板推进
58
58
 
@@ -149,7 +149,7 @@ AI 写得越快,需要看的越多。固定角色让 CR/TE 各自只做一件
149
149
  ### 审批点与护栏
150
150
 
151
151
  - 审批 1:方案阶段结束,人决定是否进入开发
152
- - 质量门:fix 直通由人裁决「轻量」或「--full」
152
+ - 质量门:快速修复由人裁决「轻量」或「--full」
153
153
  - 审批 2:实施与测试结束,人决定是否归档
154
154
  - 护栏:质量门未裁决时禁止写源码区;破坏性 git 命令(`reset --hard`、`clean -f`、`push --force`)直接拦截
155
155
 
@@ -163,7 +163,8 @@ AI 写得越快,需要看的越多。固定角色让 CR/TE 各自只做一件
163
163
  ├── deliverables/ # 每轮交付物 + _archive/
164
164
  ├── specs/ # 能力规格,按轮次追加
165
165
  ├── memory/ # 踩坑记忆,一人一文件
166
- ├── tasks/ # 看板 + 本机状态(会话绑定、认领、worktree、测试环境租约)
166
+ ├── tasks/ # 看板 + 共享认领记录
167
+ ├── local/ # 本机状态(会话绑定、worktree、租约、本地配置)
167
168
  ├── agents/ flows/ # 项目级角色/流程覆写
168
169
  └── scripts/ rules/ # 随插件版本刷新,不入资产仓库
169
170
  ```
@@ -173,23 +174,33 @@ AI 写得越快,需要看的越多。固定角色让 CR/TE 各自只做一件
173
174
  - 池化 worktree:多个任务同时开发时,按仓库分配复用工作区,避免分支互相污染
174
175
  - 测试环境租约:`/hk-te` 保证同一时间只有一个任务占用测试环境
175
176
  - 模型路由:`kit.json` 把逻辑名(`reasoning` / `coding` / `fast` 或角色名)映射到具体 provider/model,未映射时回退会话默认
177
+ - 零人工收尾:`/hk close` 先同步目标基线,再把干净任务分支本地合入、释放槽位并删除已合入分支。不自动 push;冲突或目标异常在归档前停下。`--no-merge` 只归档文档,`--dry-run` 只预演。
178
+ - 每轮运行统计:归档写入 `_archive/<任务>/metrics/R<N>.json`,记录实际 provider/model/推理等级、token 分项、活动耗时和工具失败;面板可实时查看同一份汇总。不记录 prompt、消息正文或原始 session id。
176
179
 
177
180
  ---
178
181
 
179
- ## 命令速查(进阶)
182
+ ## 命令速查
183
+
184
+ 四个日常入口:
185
+
186
+ | 命令 | 作用 |
187
+ |---|---|
188
+ | `/hk init [--assets <url\|init\|local>]` | 初始化/修复 `.harness/`,绑定资产仓库 |
189
+ | `/hk task [<任务>] <描述> [--file <路径>] [--fix]` | 启动任务;`--fix` 走快速修复 |
190
+ | `/hk close <任务> [--merge\|--no-merge] [--dry-run]` | 归档本轮、收尾工作区并写入运行统计 |
191
+ | `/hk doctor [--fix]` | 体检;`--fix` 修复确定性缺件 |
192
+
193
+ 高级别名继续可用:
180
194
 
181
195
  | 命令 | 作用 |
182
196
  |---|---|
183
197
  | `/hk-setup [--add <git-url>]` | 登记代码仓库到 `kit.json`,缺少的自动 clone |
184
- | `/hk-init [--assets <url\|init\|local>]` | 初始化/刷新 `.harness/`,绑定资产仓库 |
185
- | `/hk-new [<任务>] <描述> [--file <路径>]` | 启动全流程任务 |
186
- | `/hk-propose <任务>` | 执行方案阶段 |
187
- | `/hk-apply <任务> [反馈]` | 执行实施阶段 |
188
- | `/hk-archive <任务>` | 归档本轮产物,执行 Spec/Memory Merge |
189
- | `/hk-fix [<任务>] <描述> [--full\|--light]` | 轻量修复直通 |
198
+ | `/hk-new` / `/hk-fix` | 任务创建别名 |
199
+ | `/hk-propose` / `/hk-apply` | 自动续接失败时的人工恢复入口 |
200
+ | `/hk-archive` | `/hk close` 的别名 |
190
201
  | `/hk-te [acquire\|release <任务> \| status]` | 测试环境串行租约 |
202
+ | `/hk-local [...]` | 发现/确认 git-ignored 本地配置 |
191
203
  | `/hk-sync` | 资产仓库同步(提交 → rebase → 追加合并 → push) |
192
- | `/hk-doctor` | 工作区体检:kit、角色、规则、流程、脚本、看板、模型映射 |
193
204
 
194
205
  ---
195
206
 
@@ -200,7 +211,7 @@ AI 写得越快,需要看的越多。固定角色让 CR/TE 各自只做一件
200
211
  **Plugins → Add plugin**,输入:
201
212
 
202
213
  ```
203
- dsh-harness-kit@0.1.5
214
+ dsh-harness-kit@0.2.0
204
215
  ```
205
216
 
206
217
  安装后启用 bundle。
@@ -208,7 +219,7 @@ dsh-harness-kit@0.1.5
208
219
  ### 命令行
209
220
 
210
221
  ```sh
211
- dsh plugin --profile desktop add dsh-harness-kit@0.1.5
222
+ dsh plugin --profile desktop add dsh-harness-kit@0.2.0
212
223
  ```
213
224
 
214
225
  需要先完全退出 DSH Desktop;其他 profile 把 `desktop` 换成实际名称。
@@ -243,7 +254,7 @@ dsh plugin --profile desktop add /绝对路径/HarnessKit
243
254
  单文件小改会;需要反复迭代、跨模块、隔一段时间再回来接手的活不会。它把返工和交接成本提前,而不是消灭。
244
255
 
245
256
  **一个人有必要用吗?**
246
- 有。一个人最容易丢的是上下文和节奏:harness 把每轮的规格、踩坑和决策留在文件里,下次不用重新解释;CR/TE 角色相当于固定的第二遍审查;初始化补齐的 `CLAUDE.md`、`build.json`、`CodeGraph` 让 AI 不必每次重读整个项目。
257
+ 有。一个人最容易丢的是上下文和节奏:harness 把每轮的规格、踩坑和决策留在文件里,下次不用重新解释;CR/TE 角色相当于固定的第二遍审查;初始化补齐的 `AGENTS.md`(或已有 `CLAUDE.md`)、`build.json`、`CodeGraph` 让 AI 不必每次重读整个项目。
247
258
 
248
259
  **必须走完整流程吗?**
249
260
  不用。四档流程 + `/hk-fix` 直通,可以先只用轻量档;流程档位在立项时确定。
package/client.js CHANGED
@@ -174,7 +174,7 @@ window.__ModuleLoader__.load({
174
174
  // 看板链词表 → 中文显示名(证据推导路径的阶段名本身即中文,原样通过)
175
175
  const STAGE_LABEL = {
176
176
  propose: '需求方案', Dev: '开发', CR: '代码审查', TE: '测试', 验证: '验证',
177
- 审批1: '审批 1', 审批2: '审批 2', 质量门: '质量门', 影响面: '影响面分析',
177
+ 审批1: '方案审批', 审批2: '交付审批', 质量门: '质量门', 影响面: '影响面分析',
178
178
  };
179
179
  const stageLabel = (name) => STAGE_LABEL[name] || name;
180
180
 
@@ -300,6 +300,7 @@ window.__ModuleLoader__.load({
300
300
  const [activity, setActivity] = useState(null);
301
301
  const [toasts, setToasts] = useState([]);
302
302
  const [expanded, setExpanded] = useState(() => new Set());
303
+ const [insight, setInsight] = useState({}); // task -> { loading, data, error }
303
304
  const [histOpen, setHistOpen] = useState(false);
304
305
  const [histQuery, setHistQuery] = useState('');
305
306
  const [modal, setModal] = useState(null); // {name, desc, file}
@@ -385,7 +386,7 @@ window.__ModuleLoader__.load({
385
386
  }).catch((e) => toast(e.message, false)).finally(() => setBusy(false));
386
387
  }, [ws, toast, fetchState, openFallbackSession]);
387
388
 
388
- // 立项/fix 直通:为任务开专属新会话(openWorkspace 在当前窗口直达新会话,
389
+ // 立项/快速修复:为任务开专属新会话(openWorkspace 在当前窗口直达新会话,
389
390
  // beforeOpen 同步拿到 sessionId),再把命令定向注入该会话——host 端轮询等
390
391
  // agent 就绪(≤15s),用户全程看到执行现场,侧栏也有新会话记录。
391
392
  // 打开失败/被取代则回落旧路径(注入最近活动会话)。
@@ -407,6 +408,15 @@ window.__ModuleLoader__.load({
407
408
  setTimeout(fetchState, 600);
408
409
  }, [ws, uiWorkspace, run, toast, fetchState]);
409
410
 
411
+ const loadInsight = useCallback((t) => {
412
+ if (!ws) return;
413
+ setInsight((prev) => ({ ...prev, [t.task]: { loading: true } }));
414
+ fetch(`/harness-kit/task-insight?workspace=${encodeURIComponent(ws.id)}&task=${encodeURIComponent(t.task)}`, { cache: 'no-store' })
415
+ .then((r) => r.json())
416
+ .then((j) => setInsight((prev) => ({ ...prev, [t.task]: { loading: false, data: j.ok ? j.metrics : null, error: j.ok ? null : j.error || '读取失败' } })))
417
+ .catch((e) => setInsight((prev) => ({ ...prev, [t.task]: { loading: false, data: null, error: e.message } })));
418
+ }, [ws]);
419
+
410
420
  const syncNow = useCallback(() => {
411
421
  if (!ws) return;
412
422
  // embedded 兜底:不 POST(host 会回"不适用"),直接指路
@@ -558,8 +568,8 @@ window.__ModuleLoader__.load({
558
568
  h('span', { style: { flex: 1 } }),
559
569
  h('button', { style: { ...S.btn(false), fontSize: 12 }, title: '新建 / 打开工作区', onClick: () => setObMode('choice') }, '+ 工作区'),
560
570
  ws && h('button', { style: S.iconBtn, title: '新建任务', onClick: () => setModal({ name: '', desc: '', file: '' }) }, '+'),
561
- ws && h('button', { style: S.iconBtn, title: '团队动态', onClick: () => setView(view === 'activity' ? 'main' : 'activity') }, '🕘'),
562
- ws && h('button', { style: S.iconBtn, title: '配置', onClick: () => setView(view === 'config' ? 'main' : 'config') }, '⚙'),
571
+ ws && h('button', { style: S.iconBtn, title: '团队', onClick: () => setView(view === 'activity' ? 'main' : 'activity') }, '🕘'),
572
+ ws && h('button', { style: S.iconBtn, title: '工作区', onClick: () => setView(view === 'config' ? 'main' : 'config') }, '⚙'),
563
573
  h('button', { style: S.iconBtn, title: '刷新', onClick: fetchState }, '⟳'),
564
574
  );
565
575
 
@@ -605,7 +615,7 @@ window.__ModuleLoader__.load({
605
615
  return h('div', { style: S.wrap, className: 'hk-root' }, header, h('div', { style: S.body },
606
616
  h('div', { style: { display: 'flex', alignItems: 'center', gap: 8, margin: '12px 0' } },
607
617
  h('button', { style: S.iconBtn, onClick: () => setView('main') }, '←'),
608
- h('span', { style: S.hTitle }, `配置 · ${ws.title || ws.id}`)),
618
+ h('span', { style: S.hTitle }, `工作区 · ${ws.title || ws.id}`)),
609
619
  !config ? h('div', { style: S.empty }, '加载中…') : h(ConfigView, { config, syncMeta, ws, busy, saveConfig, runInit: runInitPanel, onOrchestrate: () => run('/hk-init'), catalog: config.catalog ?? [], toast }),
610
620
  ), h('div', { style: S.toastWrap }, toasts.map((tst) => h('div', { key: tst.id, style: S.toast(tst.ok), onClick: () => !tst.ok && setToasts((ts) => ts.filter((x) => x.id !== tst.id)) }, tst.text))));
611
621
  }
@@ -633,7 +643,7 @@ window.__ModuleLoader__.load({
633
643
  return h('div', { style: S.wrap, className: 'hk-root' }, header, h('div', { style: S.body },
634
644
  h('div', { style: { display: 'flex', alignItems: 'center', gap: 8, margin: '12px 0' } },
635
645
  h('button', { style: S.iconBtn, onClick: () => setView('main') }, '←'),
636
- h('span', { style: S.hTitle }, `团队动态 · ${ws.title || ws.id}`)),
646
+ h('span', { style: S.hTitle }, `团队 · ${ws.title || ws.id}`)),
637
647
  content));
638
648
  }
639
649
 
@@ -695,6 +705,29 @@ window.__ModuleLoader__.load({
695
705
  t.apply && t.apply !== '—' && h('div', null, h('b', null, 'Apply:'), t.apply),
696
706
  t.progress.deliverables.length > 0 && h('div', null, h('b', null, '产物:'), t.progress.deliverables.join('、')),
697
707
  t.hint && t.hint !== '—' && h('div', null, h('b', null, '续接:'), t.hint),
708
+ h('div', { style: { marginTop: 8 } },
709
+ h('button', { style: S.btn(false), onClick: () => loadInsight(t) }, insight[t.task]?.loading ? '读取中…' : (insight[t.task]?.data ? '刷新运行记录' : '查看运行记录')),
710
+ (() => {
711
+ const ins = insight[t.task];
712
+ if (!ins) return null;
713
+ if (ins.loading) return h('div', { style: { fontSize: 11, color: V.sub, marginTop: 4 } }, '读取会话统计…');
714
+ if (ins.error) return h('div', { style: { fontSize: 11, color: V.err, marginTop: 4 } }, ins.error);
715
+ const d = ins.data;
716
+ const n = (x) => (typeof x === 'number' ? x.toLocaleString() : '—');
717
+ return h('div', { style: { marginTop: 6 } },
718
+ h('div', { style: { fontSize: 11, color: d.coverage === 'complete' ? V.ok : V.warn, marginBottom: 4 } },
719
+ `覆盖率 ${d.coverage} · ${d.totals.agents} 个 Agent · ${n(d.totals.totalTokens)} tokens · ${Math.round((d.totals.activeDurationMs || 0) / 1000)}s · 失败 ${d.totals.toolFailures}`),
720
+ h('table', { style: S.table },
721
+ h('thead', null, h('tr', null, ['Agent', '模型', '轮次', 'tokens', '耗时', '失败'].map((x) => h('th', { key: x, style: S.th }, x)))),
722
+ h('tbody', null, (d.agents ?? []).map((a) => h('tr', { key: a.label },
723
+ h('td', { style: S.td }, a.label),
724
+ h('td', { style: S.td }, `${a.provider || '—'}/${a.model || '—'}${a.reasoningEffort ? ` · ${a.reasoningEffort}` : ''}`),
725
+ h('td', { style: S.td }, n(a.turns)),
726
+ h('td', { style: S.td }, n(a.totalTokens)),
727
+ h('td', { style: S.td }, `${Math.round((a.activeDurationMs || 0) / 1000)}s`),
728
+ h('td', { style: S.td }, n(a.toolFailures)))))),
729
+ (d.notes ?? []).length > 0 && h('div', { style: { fontSize: 11, color: V.sub, marginTop: 4 } }, d.notes.join(';')));
730
+ })()),
698
731
  t.progress.pendingApproval && h('div', { style: { color: V.warn } }, `⛔ ${t.progress.pendingApproval} 等待人工审批(在会话中答复,并写入通过标记)`)),
699
732
  );
700
733
  };
@@ -745,7 +778,7 @@ window.__ModuleLoader__.load({
745
778
  histOpen && h('div', { style: { padding: '0 12px 12px' } },
746
779
  h('input', { style: { ...S.input, width: 220, marginBottom: 8 }, placeholder: '搜索任务名…', value: histQuery, onChange: (e) => setHistQuery(e.target.value) }),
747
780
  h('table', { style: S.table },
748
- h('thead', null, h('tr', null, ['任务', 'Profile', '完成时间'].map((x) => h('th', { key: x, style: S.th }, x)))),
781
+ h('thead', null, h('tr', null, ['任务', '流程', '完成时间'].map((x) => h('th', { key: x, style: S.th }, x)))),
749
782
  h('tbody', null, histRows.map((t) => h('tr', { key: t.task },
750
783
  h('td', { style: S.td }, t.task),
751
784
  h('td', { style: S.td }, t.profile),
@@ -756,7 +789,7 @@ window.__ModuleLoader__.load({
756
789
  h('div', { style: S.modal, onClick: (e) => e.stopPropagation() },
757
790
  h('div', { style: { ...S.hTitle, marginBottom: 10 } }, '新建任务'),
758
791
  h('div', { style: { display: 'flex', gap: 6, marginBottom: 14 } },
759
- [['new', '需求'], ['fix', 'fix 直通']].map(([m, label]) =>
792
+ [['new', '需求'], ['fix', '快速修复']].map(([m, label]) =>
760
793
  h('button', {
761
794
  key: m,
762
795
  style: { ...S.btn(false), padding: '4px 12px', fontSize: 12, borderRadius: 14,
@@ -767,7 +800,7 @@ window.__ModuleLoader__.load({
767
800
  h('div', { style: { fontSize: 11, color: V.sub, margin: '-8px 0 12px' } },
768
801
  (modal.mode ?? 'new') === 'fix'
769
802
  ? '简单 bug 修复:跳过文档审批,PM 评估质量门后交你裁决(轻量=只开发+验证)'
770
- : '完整流程:提案澄清 → Profile 判定 → 人工审批 → 开发实施'),
803
+ : '完整流程:提案澄清 → 流程判定 → 人工审批 → 开发实施'),
771
804
  h('div', { style: S.field }, h('label', { style: S.label }, '任务名(可选,留空自动按描述生成英文短名)'),
772
805
  h('input', { style: S.input, value: modal.name, autoFocus: true, placeholder: '留空自动起名;仅限英文/数字/-_', onChange: (e) => setModal({ ...modal, name: e.target.value }) })),
773
806
  h('div', { style: S.field }, h('label', { style: S.label }, '一句话需求描述'),
@@ -868,14 +901,37 @@ window.__ModuleLoader__.load({
868
901
  });
869
902
  const [branches, setBranches] = useState(() => Object.fromEntries((k.sources ?? []).map((s) => [s.name, s.branch ?? ''])));
870
903
  const [autoSync, setAutoSync] = useState(k.assets?.autoSync === true);
904
+ const [autoClose, setAutoClose] = useState(k.worktree?.autoClose === true);
905
+ const [targetSync, setTargetSync] = useState(k.worktree?.targetSync ?? 'safe');
906
+ const [local, setLocal] = useState(null);
907
+ const [localBusy, setLocalBusy] = useState(false);
871
908
  const [models, setModels] = useState(() => Object.entries(k.models ?? {}).map(([name, m]) => toModelRow(name, m)));
872
909
  const [applyMode, setApplyMode] = useState(k.applyMode ?? 'auto');
873
910
  useEffect(() => {
874
911
  setBranches(Object.fromEntries((k.sources ?? []).map((s) => [s.name, s.branch ?? ''])));
875
912
  setAutoSync(k.assets?.autoSync === true);
913
+ setAutoClose(k.worktree?.autoClose === true);
914
+ setTargetSync(k.worktree?.targetSync ?? 'safe');
876
915
  setModels(Object.entries(k.models ?? {}).map(([name, m]) => toModelRow(name, m)));
877
916
  setApplyMode(k.applyMode ?? 'auto');
878
917
  }, [ws.id]);
918
+ const loadLocal = useCallback(() => {
919
+ fetch(`/harness-kit/local?workspace=${encodeURIComponent(ws.id)}`, { cache: 'no-store' })
920
+ .then((r) => r.json())
921
+ .then((j) => setLocal(j.ok ? j : { sources: [] }))
922
+ .catch(() => setLocal({ sources: [] }));
923
+ }, [ws.id]);
924
+ useEffect(() => { loadLocal(); }, [loadLocal]);
925
+ const localAction = (repo, action, paths) => {
926
+ setLocalBusy(true);
927
+ fetch('/harness-kit/local', {
928
+ method: 'POST', headers: { 'content-type': 'application/json' },
929
+ body: JSON.stringify({ workspace: ws.id, repo, action, paths }),
930
+ }).then((r) => r.json()).then((j) => {
931
+ toast(j.ok ? (j.notes?.length ? j.notes.join(';') : (action === 'approve' ? '已确认' : '已跳过')) : j.error || '操作失败', j.ok);
932
+ if (j.ok) loadLocal();
933
+ }).catch((e) => toast(e.message, false)).finally(() => setLocalBusy(false));
934
+ };
879
935
  const kv = (label, value) => h('div', { style: S.kv }, h('span', { style: { color: V.sub, minWidth: 96 } }, label), h('span', null, value ?? '—'));
880
936
 
881
937
  return h('div', null,
@@ -904,6 +960,27 @@ window.__ModuleLoader__.load({
904
960
  title: '点击复制完整路径',
905
961
  onClick: () => { try { navigator.clipboard?.writeText(`${ws.path}/.worktrees/${repo}/${s.slot}`); toast('路径已复制'); } catch { /* 剪贴板不可用时无操作 */ } },
906
962
  }, `${ws.path}/.worktrees/${repo}/${s.slot}`)))))),
963
+ // 本机配置(git-ignored):确认一次,新 slot 自动补齐;只影响本机,不进团队资产
964
+ h('div', { style: S.section },
965
+ h('div', { style: S.secTitle }, '本机配置(git-ignored)'),
966
+ h('div', { style: { fontSize: 12, color: V.sub, marginBottom: 8 } },
967
+ '从主工作树发现本地配置候选;确认后写入本机清单,并为已绑定 slot 补齐。只影响本机,不提交到资产仓库。'),
968
+ local === null && h('div', { style: { fontSize: 12, color: V.sub } }, '扫描中…'),
969
+ local && (local.sources ?? []).length === 0 && h('div', { style: { fontSize: 12, color: V.sub } }, '未登记子工程。'),
970
+ local && (local.sources ?? []).map((s) => {
971
+ const pending = (s.candidates ?? []).filter((c) => c.pending);
972
+ return h('div', { key: s.name, style: { marginBottom: 10, paddingBottom: 8, borderBottom: `1px solid ${V.border}` } },
973
+ h('div', { style: { fontSize: 12, fontWeight: 600, marginBottom: 3 } },
974
+ `${s.name}:已确认 ${s.approved.length} 个,待确认 ${pending.length} 个`,
975
+ h('span', { style: { marginLeft: 8, color: V.sub, fontWeight: 400 } }, `模式 ${s.mode}`)),
976
+ pending.length > 0 && h('div', { style: { marginBottom: 5 } },
977
+ pending.slice(0, 8).map((c) => h('div', { key: c.path, style: { fontFamily: 'monospace', fontSize: 11, color: V.sub } },
978
+ `${c.reason === 'high' ? '高' : '配置'} · ${c.kind} · ${c.path}`)),
979
+ pending.length > 8 && h('div', { style: { fontSize: 11, color: V.sub } }, `… 另 ${pending.length - 8} 个`)),
980
+ pending.length > 0 && h('div', { style: { display: 'flex', gap: 6 } },
981
+ h('button', { style: S.btn(localBusy, true), disabled: localBusy, onClick: () => localAction(s.name, 'approve', pending.map((c) => c.path)) }, '全部确认'),
982
+ h('button', { style: S.btn(localBusy), disabled: localBusy, onClick: () => localAction(s.name, 'skip', pending.map((c) => c.path)) }, '全部跳过')));
983
+ })),
907
984
  // ② 可配项
908
985
  (k.sources ?? []).length > 0 && h('div', { style: S.section },
909
986
  h('div', { style: S.secTitle }, '子工程基线分支'),
@@ -916,7 +993,7 @@ window.__ModuleLoader__.load({
916
993
  }, '保存分支')),
917
994
  // 流程模式(原 .harness/config.json 的 apply-mode,已并入 kit.json)
918
995
  h('div', { style: S.section },
919
- h('div', { style: S.secTitle }, '流程模式'),
996
+ h('div', { style: S.secTitle }, '流程设置'),
920
997
  h('div', { style: { fontSize: 12, color: V.sub, marginBottom: 8 } },
921
998
  'applyMode 决定 CR 通过后是否进入人工审查点(review = CR PASS 后暂停等人工审查,auto = 直接进 TE)。'),
922
999
  k.legacyConfig && h('div', { style: { ...S.attn('warn'), marginBottom: 8 } },
@@ -931,6 +1008,23 @@ window.__ModuleLoader__.load({
931
1008
  style: S.btn(busy, true), disabled: busy,
932
1009
  onClick: () => saveConfig({ applyMode }, '流程配置已保存'),
933
1010
  }, '保存'))),
1011
+ h('div', { style: S.section },
1012
+ h('div', { style: S.secTitle }, '任务收尾'),
1013
+ h('div', { style: { fontSize: 12, color: V.sub, marginBottom: 8 } },
1014
+ '开启后归档会先同步目标基线并本地合入干净任务分支;冲突、目标脏或分叉时停下,不会自动 push。'),
1015
+ h('label', { style: { display: 'flex', gap: 8, alignItems: 'center', fontSize: 12, marginBottom: 8, cursor: 'pointer' } },
1016
+ h('input', { type: 'checkbox', checked: autoClose, onChange: (e) => setAutoClose(e.target.checked) }),
1017
+ '归档时自动收尾(autoClose)'),
1018
+ h('div', { style: { display: 'flex', gap: 8, alignItems: 'center', marginBottom: 8, fontSize: 12 } },
1019
+ h('span', { style: { minWidth: 96, color: V.sub } }, '目标同步'),
1020
+ h('select', { style: { ...S.select, width: 150 }, value: targetSync, onChange: (e) => setTargetSync(e.target.value) },
1021
+ h('option', { value: 'safe' }, 'safe(推荐)'),
1022
+ h('option', { value: 'ff-only' }, 'ff-only(严格)'),
1023
+ h('option', { value: 'off' }, 'off(不同步)'))),
1024
+ h('button', {
1025
+ style: S.btn(busy, true), disabled: busy,
1026
+ onClick: () => saveConfig({ worktree: { autoClose, targetSync } }, '任务收尾配置已保存'),
1027
+ }, '保存')),
934
1028
  h('div', { style: S.section },
935
1029
  h('div', { style: S.secTitle }, '自动同步'),
936
1030
  h('label', { style: { display: 'flex', gap: 8, alignItems: 'center', fontSize: 12, marginBottom: 8, cursor: 'pointer' } },
@@ -938,7 +1032,7 @@ window.__ModuleLoader__.load({
938
1032
  '归档后自动执行资产同步(/hk-sync)'),
939
1033
  h('button', { style: S.btn(busy, true), disabled: busy, onClick: () => saveConfig({ autoSync }, autoSync ? '已开启自动同步' : '已关闭自动同步') }, '保存')),
940
1034
  h('div', { style: S.section },
941
- h('div', { style: S.secTitle }, 'Worker 模型映射'),
1035
+ h('div', { style: S.secTitle }, '高级:Worker 模型映射'),
942
1036
  h('div', { style: { fontSize: 12, color: V.sub, marginBottom: 8 } },
943
1037
  '键支持角色名(优先)或逻辑名(fast / coding / reasoning);未配置的角色走会话默认。'),
944
1038
  h('div', { style: { fontSize: 12, color: V.sub, marginBottom: 8 } },
@@ -1007,6 +1101,9 @@ window.__ModuleLoader__.load({
1007
1101
  h('span', null, '🟠'),
1008
1102
  h('span', { style: { flex: 1 } }, initGap.text),
1009
1103
  h('button', { style: S.btn(busy, true), disabled: busy, onClick: onOrchestrate }, '启动初始化编排')),
1104
+ (ws?.initGaps ?? []).length > 0 && h('div', { style: { fontSize: 11, color: V.sub, marginBottom: 8 } },
1105
+ (ws.initGaps ?? []).map((g) => h('div', { key: `${g.kind}:${g.repo ?? 'root'}`, style: { marginBottom: 2 } },
1106
+ `• ${g.label}(${g.kind === 'build-json' ? 'build.json 可补齐' : '需初始化编排生成'})`))),
1010
1107
  ws?.init && !ws.init.done && h('div', { style: { ...S.attn('warn'), marginBottom: 8 } },
1011
1108
  h('span', null, '🔧'),
1012
1109
  h('span', { style: { flex: 1 } }, `初始化进行中:${ws.init.stage}${ws.init.detail ? ` — ${ws.init.detail}` : ''}(刷新不影响,完成后再重跑以免重复克隆)`)),
package/docs/DETAIL.en.md CHANGED
@@ -14,7 +14,7 @@ process and shared assets.
14
14
  ## It also fills in the project context
15
15
 
16
16
  After the workspace exists, **Start initialization orchestration** probes the registered source
17
- repositories and generates or fills in the root `AGENTS.md`, per-repository `CLAUDE.md` and
17
+ repositories and generates or fills in the root `AGENTS.md`, per-repository `AGENTS.md` (or legacy `CLAUDE.md`) and
18
18
  `docs/CODE_STANDARDS.md`, `<repo>/.harness/build.json` (build, start and test commands),
19
19
  `codebase-guide/` module docs and a `.codegraph/` index. Existing files are skipped, and you confirm
20
20
  the plan before anything is written.
@@ -26,12 +26,12 @@ the plan before anything is written.
26
26
  wizard checks `git` and `Python 3` first and shows install commands when something is missing.
27
27
  Initialization runs in the background and survives a refresh; then start the initialization
28
28
  orchestration to generate docs and indexes.
29
- 2. **Create a task**: + → Requirement or Fix → one sentence (the task name can stay empty). A
30
- dedicated session opens automatically.
29
+ 2. **Create a task**: + → Requirement or Quick fix → one sentence (the task name can stay empty).
30
+ A dedicated session opens automatically.
31
31
  3. **Work from the panel**: cards move between Planning / Implementing / To archive. **Needs you**
32
32
  lists approvals, archives and sync problems; **Continue session** jumps to the task session.
33
- Archived work moves to the history board; 🕘 shows team activity; ⚙ edits source branches,
34
- auto-sync and model mappings.
33
+ Archived work moves to the history board; 🕘 opens Team; ⚙ opens Workspace (source branches,
34
+ auto-sync and model mappings).
35
35
 
36
36
  Approvals are written by a human (`proposal.md` for approval 1, `bugfix.md` for the quality gate);
37
37
  the panel only reminds. Asset rebinding and removing source repositories stay in commands.
@@ -64,18 +64,38 @@ Four profiles plus the `fix` shortcut:
64
64
  - `quick`: small changes, with a self readiness check
65
65
  - `bugfix`: full defect-fix flow
66
66
  - `refactor`: blast-radius analysis first
67
- - `fix`: quality gate → Dev → (`--full` adds CR/TE, `--light` verifies only) → archive
67
+ - `fix` (quick fix): quality gate → Dev → (`--full` adds CR/TE, `--light` verifies only) → archive
68
68
 
69
69
  Source writes are blocked until the quality gate is recorded; `reset --hard`, `clean -f` and
70
70
  `push --force` are rejected.
71
71
 
72
+ ## Closeout and run records
73
+
74
+ Four daily entries cover the workflow: `/hk init`, `/hk task`, `/hk close`, `/hk doctor`. Existing
75
+ `/hk-*` commands remain as advanced aliases.
76
+
77
+ `/hk close` enables `worktree.autoClose` by default for new workspaces. It aligns the local target
78
+ with `origin` according to `targetSync` (default `safe`, local only), merges a clean task branch
79
+ locally, releases the slot and deletes the merged task branch. It never pushes. Conflicts, a dirty
80
+ target or a diverged target stop before archiving, leaving the task active. `--no-merge` archives
81
+ documents only; `--dry-run` previews.
82
+
83
+ Each archive writes `.harness/deliverables/_archive/<task>/metrics/R<N>.json` with the actual
84
+ provider/model/reasoning effort, turns, token components, active duration, tool failures and
85
+ coverage. The panel's run record uses the same collector. Only metadata is stored: no prompts,
86
+ message bodies or raw session ids. Historical tasks are not backfilled.
87
+
72
88
  ## Assets accumulate
73
89
 
74
90
  `.harness/` is the working copy of the asset repository: `kit.json`, `deliverables/`, `specs/`,
75
- `memory/`, `tasks/`, and project-level `agents/ flows/`. Every round settles specs and lessons;
76
- used solo this matters most, because the longer you use it, the thicker the assets and the less the
77
- next session has to re-explain. Templates and rules
78
- also live under `.harness/` and can be adapted and committed per team.
91
+ `memory/`, `tasks/` (board and shared claims), `local/` (machine-local state), and project-level
92
+ `agents/ flows/`. Every round settles specs and lessons; used solo this matters most, because the
93
+ longer you use it, the thicker the assets and the less the next session has to re-explain. Templates
94
+ and rules also live under `.harness/` and can be adapted and committed per team.
95
+
96
+ `.harness/local/` holds session bindings, the worktree ledger, decisions, the test lease and local
97
+ config approvals; the whole directory is ignored. Legacy `tasks/*.json` files migrate automatically
98
+ on first read or `/hk init`.
79
99
 
80
100
  ## Requirements
81
101
 
package/docs/DETAIL.md CHANGED
@@ -10,13 +10,13 @@ Harness Kit 把方案、开发、评审、测试拆给固定角色,在关键
10
10
 
11
11
  ## 它还会补齐项目上下文
12
12
 
13
- 创建完成后点「启动初始化编排」,它会探测已登记的子工程,生成/补齐根 `AGENTS.md`、子工程 `CLAUDE.md`、`docs/CODE_STANDARDS.md`、`<子工程>/.harness/build.json`(构建/启动/测试命令)、`codebase-guide/` 模块文档与 `.codegraph/` 索引;已有文件跳过,生成前先给计划确认。
13
+ 创建完成后点「启动初始化编排」,它会探测已登记的子工程,生成/补齐根 `AGENTS.md`、子工程 `AGENTS.md`(已有 `CLAUDE.md` 则跳过)、`docs/CODE_STANDARDS.md`、`<子工程>/.harness/build.json`(构建/启动/测试命令)、`codebase-guide/` 模块文档与 `.codegraph/` 索引;已有文件跳过,生成前先给计划确认。
14
14
 
15
15
  ## 三步上手(界面)
16
16
 
17
17
  1. **新建工作区**:侧栏 Harness Kit →「+ 工作区」→「新建工作区」,选目录、资产仓库、子工程,点「创建并初始化」。向导先检查 `git` / `Python 3`,缺失时直接给出安装命令;初始化在后台执行,刷新页面不中断,完成后可启动初始化编排生成文档与索引。
18
- 2. **立项**:顶部「+」→「需求」或「fix 直通」→ 一句话描述(任务名可留空)→ 自动打开专属会话。
19
- 3. **推进**:任务卡片在「规划中 / 实施中 / 待归档」之间移动;「需要你」提醒审批、归档、同步;点「继续会话」处理。归档后进历史任务板;🕘 团队动态;⚙ 配置分支、自动同步与模型映射。
18
+ 2. **立项**:顶部「+」→「需求」或「快速修复」→ 一句话描述(任务名可留空)→ 自动打开专属会话。
19
+ 3. **推进**:任务卡片在「规划中 / 实施中 / 待归档」之间移动;「需要你」提醒审批、归档、同步;点「继续会话」处理。归档后进历史任务板;🕘 团队;⚙ 工作区(分支、自动同步、模型映射)。
20
20
 
21
21
  审批由人写下(`proposal.md` 的「审批 1:通过」、`bugfix.md` 的质量门裁决),面板只提醒、不代写。资产换绑与删除子工程仍走命令。
22
22
 
@@ -46,13 +46,23 @@ Project Manager(当前会话 Lead,编排与看板)、Business Analyst(`r
46
46
  - `quick`:小改动,SA 做就绪自评
47
47
  - `bugfix`:缺陷修复全流程
48
48
  - `refactor`:SA 先做影响面分析
49
- - `fix` 直通:质量门 → Dev →(`--full` 含 CR/TE,`--light` 只验证)→ 归档
49
+ - `fix` 快速修复:质量门 → Dev →(`--full` 含 CR/TE,`--light` 只验证)→ 归档
50
50
 
51
51
  质量门未裁决时禁止写源码区;`reset --hard`、`clean -f`、`push --force` 直接拦截。
52
52
 
53
+ ## 收尾与运行统计
54
+
55
+ 四个日常入口是 `/hk init`、`/hk task`、`/hk close`、`/hk doctor`;旧 `/hk-*` 命令保留为高级别名。
56
+
57
+ `/hk close` 默认开启 `worktree.autoClose`(新工作区默认):先按 `targetSync`(默认 `safe`,只做本地同步)把本地目标对齐 `origin`,再把干净任务分支本地合入、释放 slot 并删除任务分支。不会自动 push;冲突、目标脏或分叉会在归档前停下,任务保持活跃。`--no-merge` 只归档文档,`--dry-run` 只预演。
58
+
59
+ 每次归档会在 `.harness/deliverables/_archive/<任务>/metrics/R<N>.json` 留下本轮统计:实际 provider/model/推理等级、轮次、token 分项、活动耗时、工具失败与覆盖率。面板的「查看运行记录」使用同一采集函数;只收元数据,不记录 prompt、消息正文或原始 session id。历史任务没有自动补录。
60
+
53
61
  ## 资产沉淀
54
62
 
55
- `.harness/` 是资产仓库的工作副本:`kit.json`、`deliverables/`、`specs/`、`memory/`、`tasks/`、项目级 `agents/ flows/`。每跑完一轮,规格与踩坑记忆都会沉淀下来;一个人用尤其明显:用得越久,资产越厚,下一次从零解释的成本越低。模板和规则也在 `.harness/` 里,可按团队习惯改写并提交。
63
+ `.harness/` 是资产仓库的工作副本:`kit.json`、`deliverables/`、`specs/`、`memory/`、`tasks/`(看板与共享认领)、`local/`(本机状态)、项目级 `agents/ flows/`。每跑完一轮,规格与踩坑记忆都会沉淀下来;一个人用尤其明显:用得越久,资产越厚,下一次从零解释的成本越低。模板和规则也在 `.harness/` 里,可按团队习惯改写并提交。
64
+
65
+ `.harness/local/` 存放会话绑定、worktree 台账、决策点、TE 租约、本机配置确认等本机状态,整体被 `.gitignore` 排除;旧 `tasks/*.json` 会在首次读取或 `/hk init` 时自动迁移。
56
66
 
57
67
  ## 要求
58
68
 
package/kernel/advance.js CHANGED
@@ -5,13 +5,13 @@
5
5
  // 审批 1 通过 + 看板 IN_PROGRESS → /hk-apply <task>
6
6
  // 触发守卫:
7
7
  // - 看板状态行是第一道闸(hk-propose 成功会置 IN_PROGRESS,天然阻断重复触发);
8
- // - 一次性标记落盘 .harness/tasks/auto-advance.json(host 重载后仍然幂等;
8
+ // - 一次性标记落盘 .harness/local/auto-advance.json(host 重载后仍然幂等;
9
9
  // /hk-new、/hk-fix、/hk-archive 会清理对应任务标记,重建/归档后可重新接力);
10
10
  // - 审批/归档本身仍是人裁决:本引擎只在人写下 approved / 审批 1:通过 之后接力。
11
11
  // 修复直通(fix profile)没有这两个闸门,不参与自动续接。
12
12
  import fs from 'node:fs';
13
13
  import path from 'node:path';
14
- import { harnessDir } from './paths.js';
14
+ import { harnessDir, localStatePath } from './paths.js';
15
15
 
16
16
  // 与 kernel/commands.js 的闸门正则同源(那边用于命令准入,这边用于触发扫描)。
17
17
  const APPROVAL1 = /审批\s*1[^0-9\n]{0,20}(通过|PASS)/i;
@@ -21,7 +21,7 @@ const APPROVAL2 = /审批\s*2\s*(✅|通过|PASS)/i;
21
21
  const STATUS_APPROVED = /状态[**]*[::][ \t]*`?approved(?![\w-])/im;
22
22
  const TASK_RE = /^[A-Za-z0-9][A-Za-z0-9_-]*$/;
23
23
 
24
- const marksPath = (ws) => path.join(harnessDir(ws), 'tasks', 'auto-advance.json');
24
+ const marksPath = (ws) => localStatePath(ws, 'auto-advance.json', 'tasks/auto-advance.json');
25
25
 
26
26
  /** 读一次性触发标记(坏文件容忍为 {})。 */
27
27
  export function readAdvanceMarks(ws) {