peaks-loop 4.1.26 → 4.2.1

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 (157) hide show
  1. package/.claude-plugin/marketplace.json +2 -2
  2. package/CHANGELOG.md +160 -0
  3. package/contracts/readonly-argv-whitelist.json +116 -0
  4. package/dist/cli/commands/code-auto-compact-command.js +15 -3
  5. package/dist/cli/commands/core/session-info-command.js +3 -4
  6. package/dist/cli/commands/core/skill-presence-housekeeping-commands.js +7 -1
  7. package/dist/cli/commands/dashboard-long-run.js +2 -1
  8. package/dist/cli/commands/doctor/invoke-from-code.js +6 -1
  9. package/dist/cli/commands/job-state-root.js +4 -2
  10. package/dist/cli/commands/lease-metrics-commands-support.js +2 -1
  11. package/dist/cli/commands/loop-eval-capture-index.js +2 -1
  12. package/dist/cli/commands/loop-eval-eval-command.js +2 -1
  13. package/dist/cli/commands/mut-commands-helpers.d.ts +9 -28
  14. package/dist/cli/commands/mut-commands-helpers.js +53 -80
  15. package/dist/cli/commands/mut-failure-diagnostic.d.ts +48 -0
  16. package/dist/cli/commands/mut-failure-diagnostic.js +147 -0
  17. package/dist/cli/commands/outer-cache-commands.js +3 -2
  18. package/dist/cli/commands/playwright-session-store.js +5 -2
  19. package/dist/cli/commands/project-context-command.js +7 -2
  20. package/dist/cli/commands/qa-archive-screenshots-command.js +2 -1
  21. package/dist/cli/commands/request-transition-preflight.js +2 -2
  22. package/dist/cli/commands/slice-decompose-artifacts.js +10 -2
  23. package/dist/cli/commands/verdict-aggregate-command.js +4 -3
  24. package/dist/cli/commands/workspace/init-actions.js +5 -0
  25. package/dist/cli/commands/workspace/init-context.js +1 -0
  26. package/dist/cli/commands/worktree-lease-effects.d.ts +13 -0
  27. package/dist/cli/commands/worktree-lease-effects.js +23 -0
  28. package/dist/cli/commands/worktree-lease-gc-command.d.ts +3 -4
  29. package/dist/cli/commands/worktree-lease-gc-command.js +59 -58
  30. package/dist/cli/commands/worktree-lease-git.d.ts +13 -18
  31. package/dist/cli/commands/worktree-lease-git.js +21 -44
  32. package/dist/cli/commands/worktree-lease-list-command.js +1 -1
  33. package/dist/cli/commands/worktree-lease-load.d.ts +19 -7
  34. package/dist/cli/commands/worktree-lease-load.js +37 -9
  35. package/dist/cli/commands/worktree-lease-release-command.d.ts +4 -5
  36. package/dist/cli/commands/worktree-lease-release-command.js +60 -47
  37. package/dist/cli/commands/worktree-lease-renew-command.d.ts +5 -4
  38. package/dist/cli/commands/worktree-lease-renew-command.js +36 -32
  39. package/dist/cli/commands/worktree-lease-session.d.ts +7 -5
  40. package/dist/cli/commands/worktree-lease-session.js +9 -6
  41. package/dist/cli/commands/worktree-lease-spawn-command.d.ts +4 -3
  42. package/dist/cli/commands/worktree-lease-spawn-command.js +38 -46
  43. package/dist/cli/commands/worktree-lease-status-command.js +1 -1
  44. package/dist/cli/commands/worktree-lease-store.d.ts +3 -2
  45. package/dist/cli/commands/worktree-lease-store.js +3 -2
  46. package/dist/services/artifacts/prerequisite-path-resolver.js +5 -1
  47. package/dist/services/audit/enforcers/lint-output-style.js +5 -1
  48. package/dist/services/audit/enforcers/lint-rd-handoff-coverage.js +9 -4
  49. package/dist/services/audit-independent/handoff-missing-refusal.js +16 -1
  50. package/dist/services/audit-independent/judged-declaration-check.js +5 -1
  51. package/dist/services/audit-independent/perf-audit-service.d.ts +2 -4
  52. package/dist/services/audit-independent/perf-audit-service.js +4 -5
  53. package/dist/services/audit-independent/security-audit-artifact.js +5 -1
  54. package/dist/services/capability-audit-service/runner.js +4 -1
  55. package/dist/services/capability-baseline/store.js +2 -1
  56. package/dist/services/capability-guard-runner/contracts/J05.js +4 -2
  57. package/dist/services/capability-guard-runner/contracts/J12.js +2 -2
  58. package/dist/services/code/auto-compact-artifacts.js +42 -10
  59. package/dist/services/code/auto-compact-checkpoint-content.d.ts +49 -0
  60. package/dist/services/code/auto-compact-checkpoint-content.js +157 -0
  61. package/dist/services/code/auto-compact-envelopes.d.ts +11 -2
  62. package/dist/services/code/auto-compact-envelopes.js +18 -4
  63. package/dist/services/code/auto-compact-orchestrator.js +1 -1
  64. package/dist/services/code/emit-handoff.js +8 -1
  65. package/dist/services/code/job-shape-decision.js +13 -2
  66. package/dist/services/code/job-shape-provisional.js +9 -1
  67. package/dist/services/code/post-compact-detector.js +9 -1
  68. package/dist/services/code/step-08-session-readers.js +14 -5
  69. package/dist/services/compact/request-transition-hook.js +6 -1
  70. package/dist/services/compact/suggest-service.js +8 -1
  71. package/dist/services/context/post-compact-reinjection.js +15 -14
  72. package/dist/services/context/spillover-store.js +2 -1
  73. package/dist/services/dispatch/contract-store.d.ts +11 -4
  74. package/dist/services/dispatch/contract-store.js +21 -8
  75. package/dist/services/doctor/doctor-service/checks/workspace-layout.js +8 -3
  76. package/dist/services/doctor/doctor-service/index.js +2 -1
  77. package/dist/services/final-review/final-review-evidence-collect.js +5 -1
  78. package/dist/services/fresh-context/fresh-context-block.js +5 -1
  79. package/dist/services/hooks/auto-compact-hook-install.d.ts +13 -3
  80. package/dist/services/hooks/auto-compact-hook-install.js +13 -3
  81. package/dist/services/hooks/worktree-authorization-gate.d.ts +1 -1
  82. package/dist/services/hooks/worktree-authorization-gate.js +14 -11
  83. package/dist/services/loop/evaluator-dispatcher.js +7 -7
  84. package/dist/services/loop/monotonic-runner.js +2 -1
  85. package/dist/services/loop/spec-service.js +10 -9
  86. package/dist/services/mcp/context-tool.d.ts +3 -0
  87. package/dist/services/mcp/context-tool.js +135 -0
  88. package/dist/services/mcp/surface.js +7 -1
  89. package/dist/services/mcp/tools.js +3 -1
  90. package/dist/services/memory/project-context-service.d.ts +10 -1
  91. package/dist/services/memory/project-context-service.js +13 -6
  92. package/dist/services/observability/jsonl-store.js +4 -1
  93. package/dist/services/polyrepo/polyrepo-dispatcher.js +5 -1
  94. package/dist/services/prd/prd-blocks-checker.js +12 -6
  95. package/dist/services/prd/project-scan-body-tables.d.ts +33 -0
  96. package/dist/services/prd/project-scan-body-tables.js +185 -0
  97. package/dist/services/prd/project-scan-bootstrap-service.d.ts +16 -3
  98. package/dist/services/prd/project-scan-bootstrap-service.js +127 -231
  99. package/dist/services/prd/project-scan-content.d.ts +24 -0
  100. package/dist/services/prd/project-scan-content.js +207 -0
  101. package/dist/services/prd/project-scan-existing-state.d.ts +22 -0
  102. package/dist/services/prd/project-scan-existing-state.js +61 -0
  103. package/dist/services/prd/project-scan-field-refresh.d.ts +87 -0
  104. package/dist/services/prd/project-scan-field-refresh.js +217 -0
  105. package/dist/services/prd/project-scan-frontmatter.d.ts +32 -0
  106. package/dist/services/prd/project-scan-frontmatter.js +34 -0
  107. package/dist/services/prd/project-scan-library-versions.d.ts +60 -0
  108. package/dist/services/prd/project-scan-library-versions.js +135 -0
  109. package/dist/services/prd/project-scan-techstack.d.ts +34 -0
  110. package/dist/services/prd/project-scan-techstack.js +167 -0
  111. package/dist/services/reviewer/reviewer-artifacts.js +2 -1
  112. package/dist/services/sc/sc-service.js +8 -8
  113. package/dist/services/scan/api-diff-recorded.d.ts +2 -3
  114. package/dist/services/scan/api-diff-recorded.js +5 -5
  115. package/dist/services/session/binding-status-service.js +2 -1
  116. package/dist/services/session/binding-store.js +6 -7
  117. package/dist/services/session/caller-binding-service.js +5 -2
  118. package/dist/services/session/getSessionDir.d.ts +4 -0
  119. package/dist/services/session/getSessionDir.js +38 -13
  120. package/dist/services/session/session-binding-bridge.d.ts +3 -6
  121. package/dist/services/session/session-binding-bridge.js +13 -13
  122. package/dist/services/session/session-checkpoint-service.js +22 -3
  123. package/dist/services/session/session-manager.js +16 -20
  124. package/dist/services/skills/presence-lease-resolver.js +3 -2
  125. package/dist/services/skills/presence-lease-service.js +7 -15
  126. package/dist/services/skills/presence-lease-store.d.ts +26 -0
  127. package/dist/services/skills/presence-lease-store.js +60 -5
  128. package/dist/services/skills/skill-presence-service.js +13 -20
  129. package/dist/services/skills/skill-statusline-model.js +7 -2
  130. package/dist/services/slice/slice-archive-service.js +4 -1
  131. package/dist/services/standards/missing-standards-detector.js +2 -1
  132. package/dist/services/test-cache/test-cache-service.js +2 -1
  133. package/dist/services/workflow/artifact-paths.js +6 -2
  134. package/dist/services/workflow/pipeline-verify-gate-support.d.ts +1 -1
  135. package/dist/services/workflow/pipeline-verify-gate-support.js +23 -11
  136. package/dist/services/workflow/workflow-graph-store-helpers.js +12 -3
  137. package/dist/services/workflow/workflow-state-store.js +11 -4
  138. package/dist/services/workspace/migrate-1-4-1-service.js +2 -1
  139. package/dist/services/workspace/reconcile-migrate.js +2 -2
  140. package/dist/services/workspace/reconcile-service.d.ts +4 -6
  141. package/dist/services/workspace/reconcile-service.js +11 -11
  142. package/dist/services/workspace/workspace-service.js +5 -5
  143. package/dist/services/worktree/dispatch-provenance.d.ts +1 -1
  144. package/dist/services/worktree/dispatch-provenance.js +9 -2
  145. package/dist/services/worktree/host-worktree-reconciler.d.ts +1 -1
  146. package/dist/services/worktree/host-worktree-reconciler.js +5 -3
  147. package/dist/shared/runtime-root.js +6 -1
  148. package/package.json +6 -5
  149. package/skills/peaks-code/SKILL.md +1 -1
  150. package/skills/peaks-code/references/project-scan-checklist.md +3 -1
  151. package/skills/peaks-mut/SKILL.md +6 -2
  152. package/dist/services/worktree/git-worktree-parser.d.ts +0 -8
  153. package/dist/services/worktree/git-worktree-parser.js +0 -55
  154. package/dist/services/worktree/worktree-lease-types.d.ts +0 -52
  155. package/dist/services/worktree/worktree-lease-types.js +0 -9
  156. package/dist/services/worktree/worktree-lease.d.ts +0 -116
  157. package/dist/services/worktree/worktree-lease.js +0 -252
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "metadata": {
3
3
  "pluginRoot": ".",
4
- "version": "4.1.26"
4
+ "version": "4.2.1"
5
5
  },
6
6
  "plugins": [
7
7
  {
8
8
  "name": "peaks-loop",
9
9
  "description": "Loop Engineering CLI — workflow primitive / loop guards / evaluators / slice orchestration",
10
- "version": "4.1.26",
10
+ "version": "4.2.1",
11
11
  "author": {
12
12
  "name": "SquabbyZ"
13
13
  },
package/CHANGELOG.md CHANGED
@@ -1,5 +1,165 @@
1
1
  # Changelog
2
2
 
3
+ ## 4.2.1 — 2026-11-17(auto-compact 真正接上恢复;project-scan 不再冻结)
4
+
5
+ **版本级别**:**patch**(三个缺陷修复 + 一个 MCP 工具;无门禁阈值放宽,无 schema 变更)。
6
+ 门禁天花板只降不升:`fileSizeExcessLines` 21801 → 21715。
7
+
8
+ **一句话:这一版让 `.peaks/project-scan/project-scan.md` 不再装完就冻结,让 auto-compact 在子目录下
9
+ 不再静默失效,并让压缩后的恢复真的拿到内容,而不是一个空壳。**
10
+
11
+ ### 1. `project-scan.md` 从「写一次就冻结」改成「机器字段就地刷新」
12
+
13
+ `bootstrapProjectScan` 过去写完一次就永远跳过:盘上只要有 `schemaVersion: 1`,之后每次运行都报
14
+ `skipped: true`,`libraryVersions` 冻结在装机当天的版本。而该文件是**消费方契约**——peaks-rd 读它的
15
+ `## Library versions` 去比对 `schemas/library-breaking-changes.data.json`,它同时被声明为 Gate C 证据,
16
+ 所以一份冻结的版本表会让破坏性变更检查**在过期输入上通过**。
17
+
18
+ 死选项 `force`(声明了、读了、但没有任何调用方传 `true`)替换为只重写 `capturedAt` / `techStack` /
19
+ `libraryVersions` 三个字段的就地刷新,其余字节原样保留。`peaks project context` 默认刷新,
20
+ `--no-project-scan-refresh` 关闭。
21
+
22
+ 同批修掉的、每个都由一次复现发现的:
23
+
24
+ - **CRLF**。`core.autocrlf=true` 是 Windows 默认,版本探测和 frontmatter 切分都改成 `\r?\n` 锚定。
25
+ 此前 CRLF 文件会落到 CREATE 分支,**销毁**手写架构说明、锁定版本注释和 memory 块。
26
+ - 文件**存在但无法归类**时刷新,绝不重建。
27
+ - `libraryVersions` 的 specifier 读**根 manifest**。取扫描首行时,除 `packages/*` 外的 workspace glob
28
+ (`apps/*`、`libs/*`)会把工作区的 `^5.4.0` 记成项目版本,覆盖根上的 `^5.7.2`。
29
+ - 正文 `## Library versions` 表跟随 frontmatter(改版本单元格、补缺行、保留 Notes 列)。
30
+ 修复前实测:frontmatter 32 个包,正文表 21 行。
31
+ - **正文散文永不覆盖**:`## Tech stack` 表只填空单元格,截断的派生 `buildTool` 不得替换更完整的作者行。
32
+ - 源码探测覆盖 `app/`、`server/` 和扁平根目录,这些布局不再被误判为 0-1 而永远陈旧。
33
+ - 读到坏的 `package.json` 时降级,不再让 `peaks project context` 失败。
34
+
35
+ ### 2. `AUTO_COMPACT_NO_SESSION`:hook 在子目录下静默失效
36
+
37
+ `peaks code auto-compact` 由 PreToolUse hook 在每次 Bash/Task 调用时触发,参数是 `--project .`。
38
+ `.` 相对**hook 的工作目录**解析,所以在子目录里跑的工具调用会让它去子目录找
39
+ `.peaks/_runtime/session.json`,找不到就返回 `AUTO_COMPACT_NO_SESSION`。
40
+
41
+ 比报错更糟的是:**hook 忽略退出码**,所以从那一刻起整个会话的 auto-compact 静默失效。
42
+ 2026-11-16 实测:同一条命令在仓库根成功(ratio 31.8%),在 `./src` 失败。
43
+
44
+ 命令构造 input 时直接用了 `opts.project`,从未做规范化,而该文件自己的注释声称 `.` 会被
45
+ `resolveCanonicalProjectRoot` 提升到 git 根——**注释描述的调用根本不存在**。现在真正调用了。
46
+
47
+ 曾尝试把 hook 改成 `${CLAUDE_PROJECT_DIR:-.}` 并回退:本项目的 Windows hook 由 PowerShell 承载,
48
+ 变量不展开,`--project` 收到字面文本、运行器试图 `mkdir` 同名目录。CLI 侧修复不依赖任何展开。
49
+
50
+ ### 3. 压缩后的 checkpoint 从空壳变成可用
51
+
52
+ `writePreCompactCheckpoint` 把 post-compact 探测器要读的字段全部写空:`openQuestions` /
53
+ `recentDecisions` / `recentArtifactPaths` 是 `[]`,`gitStatus` 是 `''`,`currentPlan` 只有一句
54
+ "resume from auto-decisions.md"。于是恢复时**无从恢复**。
55
+
56
+ 实测:一个有活跃 request、且 `txt/auto-decisions.md` 有内容的会话,checkpoint 仍带 7 个空字段。
57
+ 修复后只剩 1 个(`todoState`,无可信数据源,保持为空而不是编造)。
58
+
59
+ 数据一直都在盘上,只是没被读:决策日志给出 resume hint 与 next actions,会话的 request 产物给出
60
+ 恢复时先开的路径,`git status --porcelain -b` 给出工作树状态。
61
+
62
+ ### 4. 新增 MCP 工具 `peaks_context_compress`
63
+
64
+ 在可选 rid/role 下返回工作流当前状态的事实摘要——活跃技能、gate、上下文占比、request 状态与产物路径
65
+ ——供模型在把旧轮次移出工作集**之前**取用。
66
+
67
+ **它不是压缩。** MCP 工具返回的是一个**值**,这里的值是文本。billion-context 的压缩靠坐在网络路径上
68
+ 改写出站请求体,peaks-loop 不在那个位置(其 `writeMainSessionCompactIntent` 的头注释写明:
69
+ hook 只能观察或否决,不能发起)。它不减少任何 token 账单,也不替代 `/compact`;收益在「不必重读」。
70
+
71
+ 它**按组合方式保持只读**:只运行已为 `peaks_status` 白名单化的 argv,不新增 CLI 命令,不新增 argv,
72
+ `validateSurface` 仍在漂移时拒绝启动。
73
+
74
+ ### 5. `peaks mut` 从「完全不可用」修成「可跑」
75
+
76
+ 两处独立的工具链缺陷,都让变异测试在任何项目上都无法启动:
77
+
78
+ - **沙箱复制 `.peaks/` 撞上 Windows junction**。Stryker 把项目整树复制进
79
+ `.stryker-tmp/sandbox-*`,而 `.peaks/_runtime/` 里存着往期会话的 scratch fixture,
80
+ 含 junction/符号链接,复制以 `EPERM: operation not permitted, copyfile` 失败——一次都没跑起来,
81
+ 而它的失败与待测代码毫无关系。`.peaks` 现加入 `alwaysIgnoredPatterns`(与 `.stryker-tmp` 同级):
82
+ 运行时产物树不进沙箱,既避开链接,也不必为每个变异体复制整个会话档案。
83
+ - **`--test-files` 被项目的 `include` 过滤成 0 个测试**。`stryker.conf.js` 把
84
+ `vitest.configFile` 指向 `stryker.vitest.config.mjs`,后者的 `include` 是**两个硬编码文件**;
85
+ vitest 会用 `--test-files` 去过滤这个 `include`,于是任何别的文件都选不中,dry run 以
86
+ "No tests were executed" 中止。**新写的测试根本无法进入变异测试。**
87
+ 现在每次运行生成一份临时 config,`include` 就是调用方给的文件。
88
+
89
+ 顺带修掉的:
90
+
91
+ - `sessionId` 在 CLI → runner → invoker → options builder 这条链上断了三处,逐个接上。
92
+ - 生成的 config 用**相对路径**且**不设 `root`**:Stryker 在沙箱内求值该 config,
93
+ 绝对路径会指向原始树(在沙箱 `root` 之外),vitest 全部过滤掉——实测正是 0 tests。
94
+ - `.stryker-tmp` 之前**不在 `.gitignore`**:崩溃的 run 会留下整树副本,
95
+ 门禁把它当作「未声明的可执行代码」。已忽略,并清掉残留。
96
+
97
+ **首次实测**:152 变异体 / 92 杀 / kill rate **60.5%**(阈值 80%)。
98
+ 这说明新代码的断言仍偏弱——是变异测试**应该**告诉我们的信息,已单独记录待补。
99
+
100
+ ### 6. 已知未修
101
+
102
+ - `scanLibraries` 仍为每个 workspace 各返回一行,同一包名重复。本次只在消费端修正了 specifier 来源;
103
+ 改 scan service 会影响 `peaks scan libraries` 的输出契约与集成测试断言。
104
+ - **kill rate 60.5% < 80% 阈值**:52 个变异体存活,断言覆盖不足,待补。
105
+ - **全局安装的 `peaks` 找不到 `typescript`**:全局 `node_modules` 没有这个 devDependency。
106
+ 用项目本地命令可绕过,且全局安装本就不宜跑变异测试。
107
+ - **依赖运行时状态的测试不能做变异目标**:`context-tool.test.ts` 在沙箱内失败(它读 `.peaks/`,
108
+ 而该树已被忽略)。应给出明确前置提示,而不是让 Stryker 报 "failed tests in initial run"。
109
+ - `todoState` 保持空:会话树里尚无可信的待办来源。
110
+
111
+ ## 4.2.0 — 2026-11-06(运行态接缝收口)
112
+
113
+ **版本级别**:**minor**(新增 `peaks mut run --ignore` 能力,并把一个新的 workspace 包发到 registry)。
114
+ 本次**没有**改任何门禁阈值或放行条件;**没有**改事件 schema 版本号(`schemaVersion` 仍是 `z.literal(1)`)。
115
+ 门禁的天花板只降不升:`eslintFindings` 1667 → 1666、`eslintErrors` 553 → 552、
116
+ `fileSizeExcessLines` 21825 → 21801。
117
+
118
+ **一句话:这一版把「运行态路径从哪里拼」收成一个入口,并把 `peaks mut run` 从「只在一个仓库上能用」
119
+ 修成「在任何仓库上都能用」。**
120
+
121
+ ### 1. 72 处手拼路径收进 state-root 接缝
122
+
123
+ `src/**` 里 72 处手写 `join(root, '.peaks', '_runtime', sid)` 全部改走
124
+ `getSessionDir` / `tryGetSessionDir` / `defaultStateRoot`。**抛错 / 保持 total 的语义逐个核对过**:
125
+ 原本会抛的仍然抛,原本承诺不抛的改走 `tryGetSessionDir` 并把 `ok:false` 映射回该帧原有的失败形态
126
+ (例如 `gcStalePresenceLeases` 对无法解析的 lease 记一条告警行,而不是抛)。
127
+ 单行形态的棘轮基线由 72 条降到 **2 条**——剩下两条是「项目相对路径、无 `projectRoot`、纯函数且从不抛」,
128
+ 接缝表达不了,已注明原因。**多行 `join(...)` / `resolve(...)` 形态不在本次范围内**(属已排期的后续清扫)。
129
+
130
+ ### 2. `--branch` 的 shell 注入面关闭
131
+
132
+ `peaks worktree spawn --branch` 的值此前经双引号拼进 `execSync` 的命令串。现改为
133
+ `execFileSync('git', argv, …)`:不再经过任何 shell,含引号、反引号、`$(...)` 的分支名以**单个 argv 元素**
134
+ 到达 git。失败信息形状随之变为不带引号的 `Command failed: git worktree add <path> -b <branch>`(已实测确认,
135
+ 仓库内无测试钉住旧形状)。独立安全审计由 `warn` 转为 **`pass`**。
136
+
137
+ ### 3. Windows 分隔符 bug
138
+
139
+ `workflow-graph-store-helpers.ts` 用 `resolve()` 得到的原生分隔符去和接缝产出的正斜杠根路径做
140
+ `startsWith`,在 Windows 上对**每一个**合法图引用都判为越界,`peaks workflow init` 直接失败。
141
+ 改为 `relative()` 包含判断,并补了一个在旧代码下必红的测试。
142
+
143
+ ### 4. `peaks mut run` 真正可用
144
+
145
+ - 新增 `--ignore <patterns...>`:沙箱复制时排除指定路径(默认空,`.stryker-tmp` 始终排除)。
146
+ 此前仓库里任何 gitignored 目录带符号链接都会让 Stryker 复制沙箱 `EPERM`。
147
+ - 失败时写出 `stryker-failure.log` 并在信封里给出其路径——此前 `logLevel: 'off'` 把真因吞掉,
148
+ 只能看到一句 `Something went wrong in the initial test run`。
149
+ - 变异面新增 `src/services/session/getSessionDir.ts`(本次 72 处调用的共同入口),
150
+ **33 个变异体全部被杀死**(killRate 1.0)。
151
+
152
+ ### 5. 构建完整性
153
+
154
+ `packages/peaks-loop-workspace-runtime` 的 `package.json#exports` 声明 `./lease` / `./worktree`,
155
+ 而 `check-build-integrity.mjs` 按子路径推导 `src/<subpath>.ts`。补两个一行 re-export shim 之后
156
+ `pnpm build` 端到端干净(此前是 `phantom export` 失败)。
157
+
158
+ ### 6. 新包首次发布
159
+
160
+ `peaks-loop-workspace-runtime@0.0.1` 首次发到公共 registry;`peaks-loop` 依赖它,
161
+ `workspace:*` 由 `pnpm pack` 改写成精确版本。
162
+
3
163
  ## 4.1.26 — 2026-10-30(授权与发布物)
4
164
  > **这一版原定是 4.1.25。** 那个 tag 已在 2026-10-30 推送,但发布没有完成 —— publish job 的
5
165
  > 30 分钟预算不足以跑完它要跑的链(install + build + 窄测试 + 五道门 + **五个包的 OIDC 带 provenance
@@ -206,6 +206,122 @@
206
206
  ],
207
207
  "positionalCount": 1
208
208
  }
209
+ },
210
+ {
211
+ "id": "ctx-skill-presence",
212
+ "tool": "peaks_context_compress",
213
+ "commandPath": [
214
+ "skill",
215
+ "presence"
216
+ ],
217
+ "argv": [
218
+ {
219
+ "kind": "literal",
220
+ "value": "skill"
221
+ },
222
+ {
223
+ "kind": "literal",
224
+ "value": "presence"
225
+ },
226
+ {
227
+ "kind": "literal",
228
+ "value": "--json"
229
+ }
230
+ ],
231
+ "params": {},
232
+ "introspection": {
233
+ "optionTokens": [
234
+ "--json"
235
+ ],
236
+ "positionalCount": 0
237
+ }
238
+ },
239
+ {
240
+ "id": "ctx-request-show",
241
+ "tool": "peaks_context_compress",
242
+ "commandPath": [
243
+ "request",
244
+ "show"
245
+ ],
246
+ "argv": [
247
+ {
248
+ "kind": "literal",
249
+ "value": "request"
250
+ },
251
+ {
252
+ "kind": "literal",
253
+ "value": "show"
254
+ },
255
+ {
256
+ "kind": "param",
257
+ "name": "rid"
258
+ },
259
+ {
260
+ "kind": "literal",
261
+ "value": "--role"
262
+ },
263
+ {
264
+ "kind": "param",
265
+ "name": "role"
266
+ },
267
+ {
268
+ "kind": "literal",
269
+ "value": "--json"
270
+ },
271
+ {
272
+ "kind": "literal",
273
+ "value": "--project"
274
+ },
275
+ {
276
+ "kind": "param",
277
+ "name": "project"
278
+ }
279
+ ],
280
+ "params": {
281
+ "rid": {
282
+ "type": "slug",
283
+ "pattern": "^[a-z0-9][a-z0-9-]*$",
284
+ "binding": {
285
+ "kind": "positional",
286
+ "token": "request-id",
287
+ "required": true
288
+ },
289
+ "constraintSource": "handwritten"
290
+ },
291
+ "role": {
292
+ "type": "enum",
293
+ "values": [
294
+ "prd",
295
+ "ui",
296
+ "rd",
297
+ "qa",
298
+ "sc"
299
+ ],
300
+ "binding": {
301
+ "kind": "option",
302
+ "token": "--role",
303
+ "required": true
304
+ },
305
+ "constraintSource": "handwritten"
306
+ },
307
+ "project": {
308
+ "type": "path",
309
+ "binding": {
310
+ "kind": "option",
311
+ "token": "--project",
312
+ "required": true
313
+ },
314
+ "constraintSource": "handwritten"
315
+ }
316
+ },
317
+ "introspection": {
318
+ "optionTokens": [
319
+ "--role",
320
+ "--json",
321
+ "--project"
322
+ ],
323
+ "positionalCount": 1
324
+ }
209
325
  }
210
326
  ]
211
327
  }
@@ -6,6 +6,7 @@ import { resolveAutoCompactProfile } from '../../services/code/auto-compact-prof
6
6
  import { probeInFlightBatch } from '../../services/workflow/workflow-inflight-probe.js';
7
7
  import { readDispatchLedgerFacts } from '../../services/dispatch/dispatch-ledger-reader.js';
8
8
  import { readActiveSid } from './code-runtime-session.js';
9
+ import { resolveCanonicalProjectRoot } from '../../services/config/config-safety.js';
9
10
  import { emitResultDocument } from '../../services/hooks/output.js';
10
11
  import { buildAutoCompactEnvelope } from './code-auto-compact-envelope.js';
11
12
  import { describeDeferral, withDeferralDetail } from './code-auto-compact-deferral.js';
@@ -46,10 +47,18 @@ function buildAutoCompactInput(opts, modeName, capture) {
46
47
  // `workflow-inflight-probe.ts` service fed by the ledger reader, so the
47
48
  // production decision is ledger-backed.
48
49
  const isTestSeam = process.env.PEAKS_TEST_SEAM === '1';
49
- const projectRoot = opts.project;
50
+ // CANONICALISE. The hook fires on every Bash/Task call, and `--project .`
51
+ // resolves against the HOOK'S working directory, which is wherever the tool
52
+ // call happens to run — a `cd src && ...` puts it in a subdirectory, where
53
+ // `.peaks/_runtime/session.json` is not on the path and the run reported
54
+ // `AUTO_COMPACT_NO_SESSION` (non-blocking, so it failed silently). Promoting
55
+ // `.` to the git root is what makes the documented contract true; the
56
+ // previous version passed `opts.project` through untouched and the comment
57
+ // claiming otherwise was wrong. Measured 2026-11-16 from `./src`.
58
+ const projectRoot = resolveCanonicalProjectRoot(opts.project);
50
59
  return {
51
60
  projectRoot,
52
- sessionId: opts.sessionId ?? readActiveSid(opts.project) ?? undefined,
61
+ sessionId: opts.sessionId ?? readActiveSid(projectRoot) ?? undefined,
53
62
  ...(isTestSeam && opts.inFlightBatch === true
54
63
  ? { inFlightBatch: { hasInFlightBatch: true } }
55
64
  : {}),
@@ -113,7 +122,10 @@ async function runAutoCompactAction(opts, io) {
113
122
  reportInvalidAutoCompactMode(io, opts.mode, opts.json);
114
123
  return;
115
124
  }
116
- const selection = resolveAutoCompactProfile({ projectRoot: opts.project, cliMode });
125
+ const selection = resolveAutoCompactProfile({
126
+ projectRoot: resolveCanonicalProjectRoot(opts.project),
127
+ cliMode
128
+ });
117
129
  const capture = { last: null };
118
130
  const result = await runAutoCompact(buildAutoCompactInput(opts, selection.profile, capture));
119
131
  const code = result.code;
@@ -1,5 +1,6 @@
1
1
  import { existsSync } from 'node:fs';
2
2
  import { join } from 'node:path';
3
+ import { defaultStateRoot } from 'peaks-loop-workspace-runtime';
3
4
  import { getSessionMeta } from '../../../services/session/session-manager.js';
4
5
  import { resolveCanonicalProjectRoot } from '../../../services/config/config-service.js';
5
6
  import { findProjectRoot } from '../../../services/config/config-safety.js';
@@ -12,13 +13,11 @@ const EXIT_DATAERR = 65;
12
13
  const LEGACY_WARNING = 'Read from legacy back-compat path .peaks/.session.json. Run `peaks workspace reconcile --apply` to migrate to the canonical home (.peaks/_runtime/session.json).';
13
14
  /** `canonical` = `.peaks/_runtime/session.json`; `legacy` = `.peaks/.session.json`. */
14
15
  function bindingSourceOf(projectRoot) {
15
- return existsSync(join(projectRoot, '.peaks', '_runtime', 'session.json'))
16
- ? 'canonical'
17
- : 'legacy';
16
+ return existsSync(join(defaultStateRoot(projectRoot), 'session.json')) ? 'canonical' : 'legacy';
18
17
  }
19
18
  function bindingPathOf(projectRoot, source) {
20
19
  return source === 'canonical'
21
- ? join(projectRoot, '.peaks', '_runtime', 'session.json')
20
+ ? join(defaultStateRoot(projectRoot), 'session.json')
22
21
  : join(projectRoot, '.peaks', '.session.json');
23
22
  }
24
23
  /** A `--caller-id` the resolver rejected (D5 → exit 65; EX_USAGE → exit 64). */
@@ -48,7 +48,13 @@ async function runPresenceClear(options, io) {
48
48
  // bootstraps `.peaks/project-scan/` (idempotent). Await the async
49
49
  // signature; failure is still non-fatal so we don't block the clear.
50
50
  try {
51
- await generateProjectContext(projectRoot);
51
+ // `refreshProjectScan: false` keeps this housekeeping path's semantics
52
+ // unchanged: it regenerates `.peaks/PROJECT.md` and does NOT refresh the
53
+ // scan's machine fields. (The bootstrap it calls still repairs a
54
+ // never-populated shell on any path — that arm does not consult this
55
+ // option. `peaks project context` is the surface that refreshes a populated
56
+ // scan's fields; this path leaves those alone.)
57
+ await generateProjectContext(projectRoot, { refreshProjectScan: false });
52
58
  }
53
59
  catch {
54
60
  // TODO(g2): legacy silent catch — grace: 1 minor release (v2.14.0)
@@ -2,6 +2,7 @@ import { existsSync, readFileSync } from 'node:fs';
2
2
  import { join } from 'node:path';
3
3
  import { resolveCanonicalProjectRoot } from '../../services/config/config-service.js';
4
4
  import { isUnsafePathInput } from '../../shared/path-safety.js';
5
+ import { getSessionDir } from '../../services/session/getSessionDir.js';
5
6
  import { read24hState } from '../../services/24h-mode/index.js';
6
7
  import { getErrorMessage } from '../cli-helpers.js';
7
8
  const SINCE_PATTERN = /^(\d+)([smhd])$/i;
@@ -36,7 +37,7 @@ function readSlices(projectRoot, sessionId) {
36
37
  if (isUnsafePathInput(sessionId)) {
37
38
  throw new Error(`Invalid session id: ${sessionId} (must be a single path segment)`);
38
39
  }
39
- const path = join(projectRoot, '.peaks', '_runtime', sessionId, 'metrics', 'slices.jsonl');
40
+ const path = join(getSessionDir(projectRoot, sessionId), 'metrics', 'slices.jsonl');
40
41
  if (!existsSync(path))
41
42
  return 0;
42
43
  try {
@@ -6,6 +6,7 @@
6
6
  */
7
7
  import { mkdirSync, writeFileSync } from 'node:fs';
8
8
  import { join } from 'node:path';
9
+ import { defaultStateRoot, sessionRuntimeDir } from 'peaks-loop-workspace-runtime';
9
10
  import { isUnsafePathInput } from '../../../shared/path-safety.js';
10
11
  export async function doctorInvokeFromCode(opts) {
11
12
  // Sid axis: `opts.sid` is the sole path segment between the runtime root and
@@ -13,7 +14,11 @@ export async function doctorInvokeFromCode(opts) {
13
14
  if (isUnsafePathInput(opts.sid)) {
14
15
  throw new Error(`Invalid session id: ${opts.sid} (must be a single path segment)`);
15
16
  }
16
- const dir = join('.peaks', '_runtime', opts.sid, 'doctor');
17
+ // No project root reaches this frame: the stub is written relative to the
18
+ // caller's cwd on purpose, and the returned path stays relative. So the
19
+ // runtime root is the one of the current directory ("."), and the session
20
+ // segment goes through the same seam as every other session-scoped path.
21
+ const dir = join(sessionRuntimeDir({ stateRoot: defaultStateRoot('.'), sessionId: opts.sid }), 'doctor');
17
22
  mkdirSync(dir, { recursive: true });
18
23
  const proposalPath = join(dir, 'proposal.md');
19
24
  // Stub: real implementation invokes peaks-doctor sub-skill
@@ -3,7 +3,9 @@
3
3
  // `<project>/.peaks/_runtime/<sessionId>/job/<jobId>/state.json`.
4
4
  import { existsSync, readdirSync } from 'node:fs';
5
5
  import { join } from 'node:path';
6
+ import { defaultStateRoot } from 'peaks-loop-workspace-runtime';
6
7
  import { isUnsafePathInput } from '../../shared/path-safety.js';
8
+ import { getSessionDir } from '../../services/session/getSessionDir.js';
7
9
  import { getCurrentSessionId } from '../../services/skills/skill-presence-service.js';
8
10
  import { projectRoot } from './job-command-shared.js';
9
11
  /**
@@ -20,7 +22,7 @@ export const SESSION_ID_HELP = 'session id (default: resolve from .peaks/_runtim
20
22
  * session must be reported by name so the caller can re-run with --session-id.
21
23
  */
22
24
  function findSessionHoldingJob(project, jobId) {
23
- const runtimeDir = join(project, '.peaks', '_runtime');
25
+ const runtimeDir = defaultStateRoot(project);
24
26
  if (!existsSync(runtimeDir))
25
27
  return null;
26
28
  for (const entry of readdirSync(runtimeDir, { withFileTypes: true })) {
@@ -65,7 +67,7 @@ export function resolveJobStateRoot(opts, jobId) {
65
67
  if (isUnsafePathInput(sessionId)) {
66
68
  throw new Error(`Invalid session id: ${sessionId} (must be a single path segment)`);
67
69
  }
68
- const rootDir = join(project, '.peaks', '_runtime', sessionId, 'job');
70
+ const rootDir = join(getSessionDir(project, sessionId), 'job');
69
71
  if (jobId && !existsSync(join(rootDir, jobId, 'state.json'))) {
70
72
  const other = findSessionHoldingJob(project, jobId);
71
73
  throw new Error(other
@@ -12,6 +12,7 @@
12
12
  */
13
13
  import { existsSync, readdirSync, statSync } from 'node:fs';
14
14
  import { join } from 'node:path';
15
+ import { defaultStateRoot } from 'peaks-loop-workspace-runtime';
15
16
  import { readObservabilityEvents } from '../../services/observability/observability-service.js';
16
17
  export const EMPTY_COUNTS = {
17
18
  spawn: 0,
@@ -29,7 +30,7 @@ export const EMPTY_COUNTS = {
29
30
  * has no lease events to report; that's not an error).
30
31
  */
31
32
  export function readAllSessionLeaseEvents(projectRoot) {
32
- const runtimeDir = join(projectRoot, '.peaks', '_runtime');
33
+ const runtimeDir = defaultStateRoot(projectRoot);
33
34
  if (!existsSync(runtimeDir))
34
35
  return { sessions: [], missingSessions: 0 };
35
36
  let entries;
@@ -4,6 +4,7 @@
4
4
  import { existsSync, readdirSync } from 'node:fs';
5
5
  import { join } from 'node:path';
6
6
  import { isUnsafePathInput } from '../../shared/path-safety.js';
7
+ import { getSessionDir } from '../../services/session/getSessionDir.js';
7
8
  /** Test seam: pick the next cycle-N.json number for capture-score
8
9
  * writes. The run-driver also writes to the same dir; the next
9
10
  * index = max(prior)+1, or 1. */
@@ -19,7 +20,7 @@ export function nextEvalCaptureIndex(projectRoot, sid, rid) {
19
20
  if (isUnsafePathInput(rid)) {
20
21
  throw new Error(`Invalid request id: ${rid} (must be a single path segment)`);
21
22
  }
22
- const dir = join(projectRoot, '.peaks', '_runtime', sid, 'loop', rid, 'cycles');
23
+ const dir = join(getSessionDir(projectRoot, sid), 'loop', rid, 'cycles');
23
24
  if (!existsSync(dir))
24
25
  return 1;
25
26
  let entries;
@@ -1,6 +1,7 @@
1
1
  import { mkdirSync, writeFileSync } from 'node:fs';
2
2
  import { join } from 'node:path';
3
3
  import { isUnsafePathInput } from '../../shared/path-safety.js';
4
+ import { getSessionDir } from '../../services/session/getSessionDir.js';
4
5
  import { dispatchEvaluator } from '../../services/loop/evaluator-dispatcher.js';
5
6
  import { addJsonOption, getErrorMessage, printResult } from '../cli-helpers.js';
6
7
  import { fail, ok } from 'peaks-loop-shared/result';
@@ -65,7 +66,7 @@ function captureEvalScore(rid, sid, projectRoot, envelope) {
65
66
  : envelope.gateAction === 'warn'
66
67
  ? 0.5
67
68
  : 0.0;
68
- const dir = join(projectRoot, '.peaks', '_runtime', sid, 'loop', rid, 'cycles');
69
+ const dir = join(getSessionDir(projectRoot, sid), 'loop', rid, 'cycles');
69
70
  const n = nextEvalCaptureIndex(projectRoot, sid, rid);
70
71
  const path = join(dir, `cycle-${n}.json`);
71
72
  try {
@@ -2,12 +2,13 @@
2
2
  * `peaks mut` — command builders and helper functions.
3
3
  *
4
4
  * Originally extracted from `mut-commands.ts` (file-size cap campaign).
5
- * It holds the stub-report factories, the summary emitter, the named-error
6
- * mapping, and — after the `max-lines-per-function` rule was measured at
7
- * 209 code lines for `createMutCommands` — the three subcommand builders
8
- * that drive the mutation pipeline (`run`, `mutants`, `asserts`).
5
+ * It holds the stub-report factories, the summary emitter and — after the
6
+ * `max-lines-per-function` rule was measured at 209 code lines for
7
+ * `createMutCommands` — the three subcommand builders that drive the
8
+ * mutation pipeline (`run`, `mutants`, `asserts`).
9
9
  * The `report` subcommand — a pure reader of an already-written file —
10
- * lives with the CLI surface in `mut-commands.ts`.
10
+ * lives with the CLI surface in `mut-commands.ts`; the named-error mapping
11
+ * and the failure diagnostic live in `mut-failure-diagnostic.ts`.
11
12
  *
12
13
  * The named-error part exists for R7: a missing or unloadable mutation
13
14
  * toolchain must surface a MACHINE-READABLE error code (for example
@@ -18,13 +19,7 @@
18
19
  */
19
20
  import { Command } from 'commander';
20
21
  import { type AssertionsReport, type MutationReport, type StrykerInvoker } from 'peaks-loop-mut';
21
- import { type ProgramIO } from '../cli-helpers.js';
22
- /**
23
- * Fallback code for a mutation failure that carries no named code of its
24
- * own. The production invoker raises the specific codes; anything that
25
- * escapes it without one still gets a stable, greppable name.
26
- */
27
- export declare const MUT_CLI_ERROR_CODE = "MUT_FAILED";
22
+ import type { ProgramIO } from '../cli-helpers.js';
28
23
  /**
29
24
  * The IO the mut family writes to when the caller injects none. Same
30
25
  * shape as `src/cli/program.ts`'s default sinks: one trailing newline
@@ -36,6 +31,8 @@ export interface MutCommandArgs {
36
31
  readonly project: string;
37
32
  readonly testFiles: string[];
38
33
  readonly mutate?: string[];
34
+ /** Patterns NOT to copy into the Stryker sandbox. Empty by default. */
35
+ readonly ignore?: string[];
39
36
  readonly inputSig: string;
40
37
  readonly sessionId: string;
41
38
  readonly out: string;
@@ -65,22 +62,6 @@ export declare function emitSummary(io: ProgramIO, json: boolean, payload: {
65
62
  passed: boolean;
66
63
  path: string;
67
64
  }): void;
68
- /**
69
- * Read the machine-readable code off a failure. The production invoker
70
- * raises named codes (`MUT_TOOLCHAIN_UNAVAILABLE`, `MUT_NO_MUTANTS`,
71
- * `MUT_MUTATE_PATTERN_REQUIRED`, …) and `runMutation` preserves them
72
- * while wrapping. Anything without a recognised code falls back to
73
- * `MUT_FAILED` so the envelope is never anonymous.
74
- */
75
- export declare function mutErrorCode(err: unknown): string;
76
- /** The human-readable half of the envelope. */
77
- export declare function mutErrorMessage(err: unknown): string;
78
- /**
79
- * Emit the failure envelope on stderr and set a non-zero exit code. Its
80
- * `data` field carries the machine-readable detail — where an ABSOLUTE path
81
- * belongs; stdout stays reserved for the `--json` payload (R6).
82
- */
83
- export declare function emitMutError(io: ProgramIO, err: unknown): void;
84
65
  /**
85
66
  * `peaks mut run` — the full mut pipeline (Stryker + assertion scan +
86
67
  * report). One-axis: --session-id required.