peaks-loop 4.0.50 → 4.0.52
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +34 -0
- package/README-en.md +1 -1
- package/README.md +1 -1
- package/dist/cli/commands/baseline-commands.js +11 -1
- package/dist/cli/commands/codegraph-command-runtime.d.ts +28 -0
- package/dist/cli/commands/codegraph-command-runtime.js +72 -0
- package/dist/cli/commands/codegraph-commands.d.ts +2 -11
- package/dist/cli/commands/codegraph-commands.js +173 -228
- package/dist/cli/commands/codegraph-status-command.d.ts +22 -0
- package/dist/cli/commands/codegraph-status-command.js +299 -0
- package/dist/cli/commands/core/memory-command.js +6 -2
- package/dist/cli/commands/job-commands.js +121 -30
- package/dist/cli/commands/project-commands.js +13 -3
- package/dist/cli/commands/request-commands.js +19 -8
- package/dist/cli/commands/share-commands.js +85 -18
- package/dist/cli/commands/slice-commands.js +2 -2
- package/dist/services/artifacts/artifact-prerequisites.js +23 -1
- package/dist/services/codegraph/codegraph-autorefresh.d.ts +16 -0
- package/dist/services/codegraph/codegraph-autorefresh.js +51 -5
- package/dist/services/codegraph/codegraph-config-repair-writer.d.ts +88 -0
- package/dist/services/codegraph/codegraph-config-repair-writer.js +322 -0
- package/dist/services/codegraph/codegraph-exclude-integrity.d.ts +20 -2
- package/dist/services/codegraph/codegraph-exclude-integrity.js +24 -3
- package/dist/services/codegraph/codegraph-exclude-reconciler.d.ts +23 -2
- package/dist/services/codegraph/codegraph-exclude-reconciler.js +123 -12
- package/dist/services/codegraph/codegraph-exclude-repair.d.ts +109 -55
- package/dist/services/codegraph/codegraph-exclude-repair.js +249 -195
- package/dist/services/codegraph/codegraph-include-reconciler.d.ts +10 -0
- package/dist/services/codegraph/codegraph-include-reconciler.js +160 -0
- package/dist/services/codegraph/codegraph-index-integrity.d.ts +268 -0
- package/dist/services/codegraph/codegraph-index-integrity.js +471 -0
- package/dist/services/codegraph/codegraph-service.d.ts +54 -0
- package/dist/services/codegraph/codegraph-service.js +84 -1
- package/dist/services/dispatch/sub-agent-dispatcher.d.ts +11 -30
- package/dist/services/dispatch/sub-agent-dispatcher.js +5 -48
- package/dist/services/doctor/doctor-service/checks/codegraph-exclude-integrity.js +19 -4
- package/dist/services/doctor/doctor-service/checks/codegraph-index-integrity.d.ts +54 -0
- package/dist/services/doctor/doctor-service/checks/codegraph-index-integrity.js +151 -0
- package/dist/services/doctor/doctor-service/checks/l3-orphan-sessions.js +10 -10
- package/dist/services/doctor/doctor-service/plugin-registry.js +2 -0
- package/dist/services/doctor/doctor-service/types.d.ts +25 -0
- package/dist/services/ide/adapters/claude-code-adapter.js +0 -1
- package/dist/services/ide/adapters/codex-adapter.js +1 -2
- package/dist/services/ide/adapters/cursor-adapter.js +1 -2
- package/dist/services/ide/adapters/hermes-adapter.js +1 -2
- package/dist/services/ide/adapters/openclaw-adapter.js +1 -2
- package/dist/services/ide/adapters/qoder-adapter.js +1 -2
- package/dist/services/ide/adapters/tongyi-lingma-adapter.js +1 -2
- package/dist/services/ide/adapters/trae-adapter.js +1 -2
- package/dist/services/ide/adapters/zcode-adapter.js +0 -1
- package/dist/services/ide/ide-types.d.ts +0 -2
- package/dist/services/memory/project-memory-service/index/kind-dispatch.js +48 -13
- package/dist/services/memory/project-memory-service/index.d.ts +5 -3
- package/dist/services/memory/project-memory-service/index.js +2 -2
- package/dist/services/memory/project-memory-service/parsers/frontmatter.d.ts +15 -1
- package/dist/services/memory/project-memory-service/parsers/frontmatter.js +34 -6
- package/dist/services/memory/project-memory-service/parsers/markdown-pure.d.ts +27 -1
- package/dist/services/memory/project-memory-service/parsers/markdown-pure.js +92 -7
- package/dist/services/memory/project-memory-service/types.d.ts +86 -0
- package/dist/services/slice/slice-check-types.d.ts +1 -1
- package/dist/services/workspace/runtime-layout.d.ts +91 -0
- package/dist/services/workspace/runtime-layout.js +148 -0
- package/dist/services/workspace/workspace-claude-settings-materializer.js +14 -0
- package/package.json +6 -6
- package/scripts/clean-dist.mjs +15 -3
- package/scripts/sync-version.mjs +26 -4
- package/skills/bee/peaks-perf-audit/SKILL.md +2 -2
- package/skills/bee/peaks-perf-audit/references/audit-protocol.md +1 -1
- package/skills/bee/peaks-prd/SKILL.md +4 -4
- package/skills/bee/peaks-prd/references/prd-for-multi-pass.md +1 -1
- package/skills/bee/peaks-prd/references/workflow.md +1 -1
- package/skills/bee/peaks-qa/SKILL.md +6 -6
- package/skills/bee/peaks-qa/references/external-capability-guidance.md +1 -1
- package/skills/bee/peaks-qa/references/qa-fanout-contract.md +1 -1
- package/skills/bee/peaks-qa/references/qa-skill-presence.md +1 -1
- package/skills/bee/peaks-qa/references/reading-handoff-frontmatter.md +2 -2
- package/skills/bee/peaks-rd/SKILL.md +2 -2
- package/skills/bee/peaks-rd/references/code-reviewer-4dim-hint.md +1 -1
- package/skills/bee/peaks-rd/references/external-references.md +1 -1
- package/skills/bee/peaks-rd/references/mandatory-perf-baseline.md +1 -1
- package/skills/bee/peaks-rd/references/ocr-multilang-1.8.md +2 -2
- package/skills/bee/peaks-rd/references/parallel-review-fanout.md +2 -2
- package/skills/bee/peaks-rd/references/rd-fanout-contracts.md +11 -8
- package/skills/bee/peaks-rd/references/rd-runbook.md +1 -1
- package/skills/bee/peaks-rd/references/rd-sub-agent-dispatch.md +7 -7
- package/skills/bee/peaks-rd/references/rd-transition-gates.md +1 -1
- package/skills/bee/peaks-rd/references/reading-v2-slice-results.md +1 -1
- package/skills/bee/peaks-rd/references/skill-presence-and-title.md +1 -1
- package/skills/bee/peaks-rd/references/v2-12-fanout-collapse.md +7 -5
- package/skills/bee/peaks-rd/references/writing-handoff-frontmatter.md +3 -3
- package/skills/bee/peaks-reviewer/SKILL.md +1 -1
- package/skills/bee/peaks-sc/SKILL.md +1 -1
- package/skills/bee/peaks-security-audit/SKILL.md +3 -3
- package/skills/bee/peaks-security-audit/references/audit-protocol.md +1 -1
- package/skills/bee/peaks-txt/SKILL.md +3 -3
- package/skills/bee/peaks-txt/references/context-capsule.md +1 -1
- package/skills/bee/peaks-ui/SKILL.md +1 -1
- package/skills/peaks-audit/SKILL.md +1 -1
- package/skills/peaks-code/SKILL.md +9 -9
- package/skills/peaks-code/references/context-governance.md +1 -1
- package/skills/peaks-code/references/dag-orchestrator.md +3 -4
- package/skills/peaks-code/references/external-references.md +1 -1
- package/skills/peaks-code/references/external-skill-invocation.md +2 -2
- package/skills/peaks-code/references/fanout-mandatory.md +3 -3
- package/skills/peaks-code/references/frontend-only-mode.md +2 -2
- package/skills/peaks-code/references/gstack-integration.md +1 -1
- package/skills/peaks-code/references/micro-cycle.md +1 -1
- package/skills/peaks-code/references/periodic-checkpoint.md +2 -2
- package/skills/peaks-code/references/project-memory-loading.md +19 -1
- package/skills/peaks-code/references/project-scan-checklist.md +1 -1
- package/skills/peaks-code/references/resume-detection.md +1 -1
- package/skills/peaks-code/references/runbook.md +3 -3
- package/skills/peaks-code/references/session-overload-signal-index.md +2 -2
- package/skills/peaks-code/references/startup-sequence.md +16 -16
- package/skills/peaks-code/references/step-11-memory-sediment.md +3 -3
- package/skills/peaks-code/references/sub-agent-dispatch.md +7 -6
- package/skills/peaks-code/references/swarm-dispatch-contract.md +1 -1
- package/skills/peaks-code/references/workflow-gates-and-types.md +3 -3
- package/skills/peaks-code/references/worktree-governance.md +1 -1
- package/skills/peaks-final-review/SKILL.md +3 -3
- package/skills/peaks-ide/references/audit-log-helper.md +5 -4
- package/skills/peaks-resume/SKILL.md +1 -1
- package/skills/peaks-slice-decompose/SKILL.md +4 -4
- package/skills/peaks-slice-decompose/references/cross-pass-edge-interpretation.md +1 -1
- package/skills/peaks-slice-decompose/references/granularity-decision.md +1 -1
- package/skills/peaks-slice-decompose/references/v2-schema.md +2 -2
- package/skills/peaks-solo/SKILL.md +1 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,39 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 4.0.52 — 2026-09-17 (codegraph 索引完整性检测闸门 + repair-index 强制重建 + 套用到本仓:include gap 31→0、dead rows 4→0、strict-mode exit 75→0)
|
|
4
|
+
|
|
5
|
+
**Highlights**:
|
|
6
|
+
|
|
7
|
+
1. **codegraph 索引完整性的"不能评估"路径是一个静默假绿(exit 0)。** `codegraph-index-integrity.ts` 的 `try/catch` 只裹住 `new Database(...)`;`db.prepare('SELECT path FROM files').all()` 在 `try { … } finally { db.close() }` 里 —— `no such table: files`(上游 schema 漂移)会**裸抛**到 `codegraph-commands.ts:304-309`,那里把 `indexIntegrity` 写成 `null`,下游 `integrity?.gap === true || indexGap ? … : undefined` 把 null 视作 false,stdout 一行 `[WARN] codegraph index integrity not evaluated` 然后 `process.exitCode = 0`。这是**本仓签名缺陷**:`codegraph-exclude-reconciler.ts:76-82` 自己的注释 verbatim 写着 *"`peaks codegraph status` turned that into `[WARN] … not evaluated` with exit 0 — a silent false pass over a real index gap, which is precisely what this module exists to prevent"* —— exclude 轴曾用这条理由加固过;index 轴却**重新引入**。现在:不可读 = 失败(exit 75、stderr),advisory by default(`peaks codegraph status` 仍以非阻塞告警呈现),strict mode 通过 `PEAKS_CODEGRAPH_INDEX_STRICT=1` 让任何 gap 强制 exit 1。注入验证:基线 → `consistent`;把基线 `sourceFiles` 里一条指到磁盘上不存在的路径 → `drifted` + `SOURCE_FILE_MISSING` 点名 J01。
|
|
8
|
+
|
|
9
|
+
2. **repair-index:把同一条 repair 缝(`repairCodegraphExcludeFromProject`)扩到 include 轴,并把"清死行"做成端到端可执行的命令。** `peaks codegraph repair-index` 是新公开命令,先调上游 `cg.clear()` 再 `index --force`;不修缝就修不了"旧的无效的也要删除"那条 directive —— 增量 `index` 永不删行(`.peaks/memory/codegraph-status-ok.md` 已记),只有 `--force` 会。**execution proven, not inferred**:在 throwaway fixture 上跑 `peaks codegraph repair-index --project <tmp>` → `git rm` 后的死行从 3 → 2(fixture 三个文件、删一个、强制重建剩两个);同时 `peaks codegraph init` 走同一缝自动给 fresh project 补 include(无需手动改 `.codegraph/config.json`,directive 3 对新项目成立)。缝的 3 个调用点(`init` / preflight / post-slice auto-refresh)都自动受益,没有新增平行缝。**两件本轮发现并报出的事,未在本片修**:旧 `--force` 在并行负载下与 slice-003 的写者撞锁(slice-003 改为清 shm/wal 旁路);`--reindex` 是"保留 cfg 已写行 + 不回滚 cfg",与用户预期的"回滚到修前"有距离,本片仅命名、闭环留给后续。
|
|
10
|
+
|
|
11
|
+
3. **套用到本仓(slice-003):include gap 31 → 0、dead rows 4 → 0、strict-mode exit 75 → 0。** baseline **必须当场重取** —— 这棵 db 的 mtime 在 slice-001/002 中被自动 incremental refresh(`refreshCodegraphAfterSlice`,两个 fail-silent 触发点:`CLI job checkpoint --state done`、`CLI request transition`)改过三次,1213 → 1220 → 1224 行而两轴缺陷**纹丝不动**:增量不删行,也不扩 include。修前 sha256 + 行/死行计数在同一步取,然后修,然后比对。修前 `.codegraph/codegraph.db-shm` 与 `codegraph.db-wal` 旁路清掉(WAL 留在原地会让 byte-exact diff 出假阳性;slice-003 完整记录这套对齐步骤)。**诚实报出**:本次套用是**在已有写过的 cfg 上重写 include + 清死行** —— 任何下游若基于旧 cfg 生成过副产物,需要重新生成;本片未做迁移路径,只点名。
|
|
12
|
+
|
|
13
|
+
4. **用户报后修。** (a) **7 个 SKILL.md 文件**里 hand-maintained 的 `kind` 词汇漂移出 21-value canonical tuple —— 现在 fixed + guarded(4.0.51 那片把引用完整性守卫的语料扩到 `skills/**`;本片把 `kind` 字段接进守卫),未来漂移一发生即红。(b) **一份文档教了 parser 拒绝的语法** —— 修正,反 vacuity 测试(合法样本通过、拒绝样本仍被拒绝),不让读者照字面抄就静默 0。
|
|
14
|
+
|
|
15
|
+
5. **缺陷扫荡(12+):codegraph 错误消息、refresh 可见性、`.bak` 忽略、mode 保留、memory 契约、doctor allow-list(带 AST 守卫)、test-infra 过期、超大文件、exit-code 真相、引用完整性、ENV surface(单源)。** 统一动作:每条都接住一个"读到的是这样,证据说的是那样"对位,修后配注入验证(基线 → 绿;注入 → 红;移除 → 复绿)。**单源原则是这一轮的暗线**:凡有"两个地方算同一个数 / 同一个字符串"的地方,本片都合并到唯一来源(`vitest.workers.ts` 是 maxWorkers 单源;ENV 表面单源;doctor allow-list 单源)。
|
|
16
|
+
|
|
17
|
+
6. **`vitest.workers.ts`:单源 `maxWorkers`,默认 2(负载形 flake safety),`PEAKS_VITEST_MAX_WORKERS` 覆盖。** 之前的最大值是分散在两套配置里算的(`Math.max(2, …)`),但其中一个入口从来没被走过;负载一上来就在 worker 数不稳定的两条路径之间漂。
|
|
18
|
+
|
|
19
|
+
**验证**:290/290 unit tests、`tsc` 142、`lint` 6/6、`peaks codegraph status` 在 strict 模式下本仓 `consistent`、`codegraph.db` 行 1224 + 0 dead rows、`config.json` 与 `codegraph.db` 的 sha256 在 repair 前后取两次确认未引入新漂移。
|
|
20
|
+
|
|
21
|
+
**明确未验证的(不当作已完成)**:`peaks codegraph repair-index` 的回滚契约 —— 现实现是 `--reindex`(不动 cfg 已写行 + 不回滚 cfg),与用户预期的"回滚到修前"有距离,本片仅命名 + 留口,未做;`refreshCodegraphAfterSlice` 仍是 fail-silent —— 本片不修,因为改它需要同时改两处调用点的契约(`job-commands.ts:306` / `request-commands.ts:468`),超出本版范围;slice-001 的 `indexIntegrity === null` 路径现在**不再静默**,但若上游 `codegraph.db` 合法但表完全缺(比 `no such table: files` 更罕见),错误消息的精细度还有一格没补。
|
|
22
|
+
|
|
23
|
+
## 4.0.51 — 2026-09-16 (子代理 await 永远报不出结果 + 49 处"声称有测试守护、测试早已删除" + 9 个恒真断言 + 三个不可达导出)
|
|
24
|
+
|
|
25
|
+
**Highlights**:
|
|
26
|
+
|
|
27
|
+
1. **`peaks sub-agent await` 永远不可能报告任何结果。** `share-commands.ts` 把 `recordPaths` **硬编码成空数组**,而 `await-batch.ts` 在它为空时**直接短路** —— 于是这个命令每次都走空分支,静默返回。文件自己的注释就承认了这个状态(*"`recordPaths: []` case"*)。现在:新增 `resolveBatchRecords` 扫 `.peaks/_sub_agents/<sid>/dispatch-*.json` 并按 record **自己的 `batchId`** 匹配 —— 用的是 `finalize --batch` 与 `findBatchRecords` **已经在用的同一套约定**,没有另发明路径约定;`dispatchCount` 是真实计数;**零匹配 → `NO_DISPATCH_RECORDS` + exit 1**;ok 信封新增 `unreadableRecords` 与告警,**不可读的候选不再沉默**。反例对照:把 `recordPaths: []` 重新注入 → 新增的 7 个测试**全部失败**;还原 → 7/7 通过。
|
|
28
|
+
|
|
29
|
+
2. **49 处在文档里声称"由某个测试守护",而那些测试早就被删了 —— 包括守卫自己文件头里写的那次提交删掉的那个。** 引用完整性守卫原先的语料是 `CLAUDE.md` / `.peaks/PROJECT.md` / `README.md` / `.peaks/standards` —— **不含 `skills/**`**,而它的锚点正则里明明列着 `skills/`。把 `skills/**` 加进语料后,**守卫自己吐出 178 处悬空引用 / 64 文件**(此前临时扫描器估的 95 **低了近一倍**,且它归因的 `de0872b7` 只占 11 处)。修了 93 处后剩 85 处,**全部逐条处置、零白名单化**:其中 **43 处引用 21 个测试** —— 1 个删于 `457b9a87`(**正是守卫文件头自称"它存在的理由"的那次提交**)、20 个删于 `f17aa377`(*"delete 559 legacy unit tests"*)、**2 个从未在任何 commit 里存在过**;另有 6 处悬空文档互引。**每一条都逐站改写,不做批量正则替换**("由 X 守护"与"见 X"语义不同)。**残留如实披露而非关闭**:这 49 站现在如实说明"无物钉住它",并逐个点名了真实的覆盖缺口 —— `isDeprecatedReviewer` / `RD_DEPRECATED_REVIEWERS`、prereq 向后兼容形态、G11.5 标题锁、20-次调用节奏、handoff frontmatter(`gateEvidence` 在 `src/` 里**无人读取**)、superpowers 四条款规则、`peaks-ide` 审计日志助手。**未补测试(超出本片范围),也未放宽或删除任何一个。**
|
|
30
|
+
|
|
31
|
+
3. **9 个 `supportsScope` 断言全部恒真,且唯一消费者是一个循环论证的测试。** 接口声明 `supportsScope(scope: 'project' | 'global')`,9 个 adapter 的实现是 1 个 `() => true` 加 8 个逐字相同、**在类型上必然为真**的表达式 —— 没有一个能返回 `false`。**生产零调用者**:全仓唯一消费者是一个把它"characterise"成两个 scope 都返回 true 的新测试。**删除**(接口 + 9 实现 + 那个测试)。理由:参数类型即值域、无 adapter 只支持单一 scope(9/9 `resolveSettingsFile` 双 scope 对称),且真实属性已被 `adapter-runtime-surfaces.test.ts` 钉住。
|
|
32
|
+
|
|
33
|
+
4. **两个不可达导出与一处死参数。** `traeCnSubAgentDispatcher` 有导出、有测试、**没注册到任何 adapter**(8 个 adapter 分别注册了 claudeCode / codex / cursor / trae / null —— 且**没有 `trae-cn` adapter**,`IdeId` 里也没有)。它唯一可引的"支持"证据是 postinstall 的目录映射,**不是适配器注册** —— 给它建 adapter 等于**发明一条不存在的接线**,故删除。`awaitByLlmFallback` 生产零调用者(它的"向后兼容测试"只证明它自己存在 —— 与第 3 条同型的循环),且其注释里承诺的目标在 1.3 已兑现,故删除。另报出:`PollDispatchRecordsOptions.ide` **从未被 `pollDispatchRecords` 读取**(既有死表面,属三项目标之外,仅报出未修)。共 15 文件 **+61/−170**。
|
|
34
|
+
|
|
35
|
+
5. **守卫的射程缺口与被裁掉的候选一起被记录。** 本片为 31 处误报新增了 5 条**带理由**的候选排除规则(省略号族、`./` 消费者根、`<…>` 模板、illustration 提示、`isDocumentRelative`),为 5 处运行时路径新增 `RUNTIME_STATE_PREFIXES`(`_runtime/` / `cron/` / `cache/`,各带理由)—— `OPTIONAL_RUNTIME_PATHS` **未增长(仍 2 条)**。**同时如实报出两个未修的射程缺口**:裸文件名引用(如 `skills-skill-md-naming.test.ts`)与围栏 ` ```bash ` 代码块对候选规则**不可见**。守卫的注入验证含**一条负对照**:同一路径写成 `mappers/…` 保持绿 —— 那正是本片唯一收窄候选集的地方,公开标注以免被读成"全都能抓"。
|
|
36
|
+
|
|
3
37
|
## 4.0.50 — 2026-09-16 (自审把 29% 从分母里排除 + 反漂移闸门报 15/15 而只跑了 1 条 + 一条"no exceptions"的红线没有任何执行者 + 五个测试套件从未运行过 + macOS 从未进 CI)
|
|
4
38
|
|
|
5
39
|
**Highlights**:
|
package/README-en.md
CHANGED
|
@@ -140,7 +140,7 @@ Every lane opens with **one slash command**.
|
|
|
140
140
|
|
|
141
141
|
| | |
|
|
142
142
|
| --- | --- |
|
|
143
|
-
| **Latest** | [](https://www.npmjs.com/package/peaks-loop) — 4.0.
|
|
143
|
+
| **Latest** | [](https://www.npmjs.com/package/peaks-loop) — 4.0.52 (2026-09-17) |
|
|
144
144
|
| **Domains** | Code (`peaks-code`) · Content (`peaks-content`) · Project health (`peaks-doctor`) · Issue sweep (`peaks-issue-fix-orchestrator`) · Custom SOP (`peaks-sop`) · Cross-domain primitives (`peaks-solo` dispatcher · `peaks-resume` · `peaks-status` · `peaks-test` · `peaks-slice-decompose`) |
|
|
145
145
|
| **Sediment pool** | `~/.peaks/` local pool · twice-clean runs auto-promote to a bee · broken runs come back for you to redefine · the bee grows with your taste |
|
|
146
146
|
| **Test suite** | 285+ cases · 4 packages (peaks-loop / peaks-loop-mut / peaks-loop-shared-channel / peaks-loop-shared) · **0 timeouts** · 14 BDD caller-binding edge cases |
|
package/README.md
CHANGED
|
@@ -140,7 +140,7 @@ npm i -g peaks-loop
|
|
|
140
140
|
|
|
141
141
|
| | |
|
|
142
142
|
| --- | --- |
|
|
143
|
-
| **最新版本** | [](https://www.npmjs.com/package/peaks-loop) — 4.0.
|
|
143
|
+
| **最新版本** | [](https://www.npmjs.com/package/peaks-loop) — 4.0.52(2026-09-17) |
|
|
144
144
|
| **覆盖域** | 代码(`peaks-code`) · 内容(`peaks-content`) · 项目健康(`peaks-doctor`) · 批量修 issue(`peaks-issue-fix-orchestrator`) · 自定义 SOP(`peaks-sop`) · 通用原语(`peaks-solo` 分诊 / `peaks-resume` 续 / `peaks-status` 看 / `peaks-test` 测 / `peaks-slice-decompose` 切片) |
|
|
145
145
|
| **沉淀池** | `~/.peaks/` 本地池 · 跑两次自动晋升成 bee · 跑翻车让你重定义 · bee 跟着你的口味长 |
|
|
146
146
|
| **测试套件** | 1096 cases · 4 packages (peaks-loop 1015 / runtime 39 / mut 22 / shared-channel 20) · **CI 首次全绿**(ubuntu + windows) · 14 BDD caller-binding coverage |
|
|
@@ -6,6 +6,7 @@ import { validateBaselineFile } from '../../services/capability-baseline/validat
|
|
|
6
6
|
import { P0_JOURNEY_IDS } from '../../services/capability-baseline/types.js';
|
|
7
7
|
import { GUARD_CONTRACTS, getGuardContract, isJourneyId } from '../../services/capability-guard-runner/registry.js';
|
|
8
8
|
import { exitCodeForGuardSummary, runAllGuards } from '../../services/capability-guard-runner/runner.js';
|
|
9
|
+
import { RUNTIME_SESSIONLESS_SCOPE } from '../../services/workspace/runtime-layout.js';
|
|
9
10
|
function fail(io, code, message, data = {}) {
|
|
10
11
|
io.stdout(JSON.stringify({ ok: false, command: `baseline`, code, message, data, warnings: [], nextActions: [] }));
|
|
11
12
|
process.exitCode = 1;
|
|
@@ -163,9 +164,18 @@ export function registerBaselineCommands(program, io) {
|
|
|
163
164
|
// It is handed the frozen rows and the registry, not just the guard
|
|
164
165
|
// summary — a scorer that only sees the guard result is a restatement.
|
|
165
166
|
const { runAudit } = await import('../../services/capability-audit-service/runner.js');
|
|
167
|
+
// `sessionId` is the on-disk scope for the audit artifacts. This command
|
|
168
|
+
// has NO session — it is the credential-free scorer that runs inside the
|
|
169
|
+
// secretless OIDC publish gate — and it used to pass the literal `'cli'`,
|
|
170
|
+
// so every run wrote `.peaks/_runtime/cli/capability-audit/*.json` into
|
|
171
|
+
// the operator's real workspace. That directory is indistinguishable from
|
|
172
|
+
// a session dir whose id failed validation, so `peaks doctor`'s
|
|
173
|
+
// orphan-session check failed on it permanently (`4 orphan session(s)
|
|
174
|
+
// …: callers, cli, unknown-sid, x`, exit 1). The reserved
|
|
175
|
+
// underscore-prefixed scope says "machinery, not a session" in the name.
|
|
166
176
|
const audit = await runAudit({
|
|
167
177
|
projectRoot,
|
|
168
|
-
sessionId:
|
|
178
|
+
sessionId: RUNTIME_SESSIONLESS_SCOPE,
|
|
169
179
|
journeyId: 'J01',
|
|
170
180
|
scorerMode: opts.scorer,
|
|
171
181
|
baselineRows: r.file.rows,
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { type CodegraphInvocationOptions } from '../../services/codegraph/codegraph-service.js';
|
|
2
|
+
import { type ProgramIO } from '../cli-helpers.js';
|
|
3
|
+
export interface CommonCodegraphOptions {
|
|
4
|
+
project: string;
|
|
5
|
+
peaksJson?: boolean;
|
|
6
|
+
}
|
|
7
|
+
export declare function printCodegraphFailure(io: ProgramIO, command: string, error: unknown, asJson?: boolean, exitCode?: number): void;
|
|
8
|
+
/**
|
|
9
|
+
* Rewrites bare upstream `codegraph <subcommand>` hints to the peaks-loop
|
|
10
|
+
* equivalent (`peaks codegraph <subcommand>`). The upstream binary is a
|
|
11
|
+
* nested transitive dependency and is NOT on PATH, so an LLM that follows
|
|
12
|
+
* a bare hint like `Run "codegraph init" to initialize` would hit
|
|
13
|
+
* "command not found". Already-prefixed `peaks codegraph ...` hints and
|
|
14
|
+
* other `codegraph` references (e.g. `@colbymchenry/codegraph`) are left
|
|
15
|
+
* untouched.
|
|
16
|
+
*/
|
|
17
|
+
export declare function rewriteBareCodegraphHints(text: string): string;
|
|
18
|
+
/**
|
|
19
|
+
* Proxy one upstream invocation. Returns whether UPSTREAM FAILED — the
|
|
20
|
+
* caller needs that to rank the exit-code precedence (an upstream failure
|
|
21
|
+
* outranks every localized integrity verdict: see the tail of
|
|
22
|
+
* `runCodegraphStatusCommand`), and it cannot re-derive it from
|
|
23
|
+
* `process.exitCode` once a later branch has overwritten it.
|
|
24
|
+
*
|
|
25
|
+
* Callers that do not rank precedence (every command but `status`) simply
|
|
26
|
+
* ignore the return value.
|
|
27
|
+
*/
|
|
28
|
+
export declare function runCodegraphCommand(io: ProgramIO, command: string, options: CodegraphInvocationOptions, asJson?: boolean, attributeStdout?: (text: string) => string): Promise<boolean>;
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
// src/cli/commands/codegraph-command-runtime.ts
|
|
2
|
+
//
|
|
3
|
+
// Shared invocation runtime for every `peaks codegraph <verb>`: the option
|
|
4
|
+
// shape they all extend, the failure envelope they all print, the hint
|
|
5
|
+
// rewriter that keeps upstream's bare `codegraph …` hints runnable, and the
|
|
6
|
+
// upstream proxy itself.
|
|
7
|
+
//
|
|
8
|
+
// Extracted verbatim from `codegraph-commands.ts` (rid
|
|
9
|
+
// 2026-09-17-oversize-and-scale, D1 — the 800-line file-size cap). Every moved
|
|
10
|
+
// line is byte-identical and no behaviour changed; `codegraph-commands.ts`
|
|
11
|
+
// re-exports `rewriteBareCodegraphHints` so the public surface is stable.
|
|
12
|
+
//
|
|
13
|
+
// This module is the BOTTOM of the codegraph CLI's import graph. It must not
|
|
14
|
+
// import `codegraph-commands.ts` or `codegraph-status-command.ts`, or the
|
|
15
|
+
// extraction would introduce a cycle.
|
|
16
|
+
import { createCodegraphInvocation, executeCodegraphInvocation } from '../../services/codegraph/codegraph-service.js';
|
|
17
|
+
import { fail } from 'peaks-loop-shared/result';
|
|
18
|
+
import { getErrorMessage, printResult, redactSensitiveErrorMessage } from '../cli-helpers.js';
|
|
19
|
+
export function printCodegraphFailure(io, command, error, asJson, exitCode = 1) {
|
|
20
|
+
printResult(io, fail(command, 'CODEGRAPH_COMMAND_FAILED', redactSensitiveErrorMessage(getErrorMessage(error)), {}, ['Check the codegraph command options and project path before retrying']), asJson);
|
|
21
|
+
process.exitCode = exitCode;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Rewrites bare upstream `codegraph <subcommand>` hints to the peaks-loop
|
|
25
|
+
* equivalent (`peaks codegraph <subcommand>`). The upstream binary is a
|
|
26
|
+
* nested transitive dependency and is NOT on PATH, so an LLM that follows
|
|
27
|
+
* a bare hint like `Run "codegraph init" to initialize` would hit
|
|
28
|
+
* "command not found". Already-prefixed `peaks codegraph ...` hints and
|
|
29
|
+
* other `codegraph` references (e.g. `@colbymchenry/codegraph`) are left
|
|
30
|
+
* untouched.
|
|
31
|
+
*/
|
|
32
|
+
export function rewriteBareCodegraphHints(text) {
|
|
33
|
+
return text.replace(/(?<![\w-])(?<!peaks\s)codegraph(?=\s+(?:status|init|index|query|files|context|affected)\b)/g, 'peaks codegraph');
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Proxy one upstream invocation. Returns whether UPSTREAM FAILED — the
|
|
37
|
+
* caller needs that to rank the exit-code precedence (an upstream failure
|
|
38
|
+
* outranks every localized integrity verdict: see the tail of
|
|
39
|
+
* `runCodegraphStatusCommand`), and it cannot re-derive it from
|
|
40
|
+
* `process.exitCode` once a later branch has overwritten it.
|
|
41
|
+
*
|
|
42
|
+
* Callers that do not rank precedence (every command but `status`) simply
|
|
43
|
+
* ignore the return value.
|
|
44
|
+
*/
|
|
45
|
+
export async function runCodegraphCommand(io, command, options, asJson, attributeStdout) {
|
|
46
|
+
try {
|
|
47
|
+
const invocation = createCodegraphInvocation(options);
|
|
48
|
+
const result = await executeCodegraphInvocation(invocation);
|
|
49
|
+
if (result.exitCode !== null && result.exitCode !== 0 && asJson === true) {
|
|
50
|
+
printCodegraphFailure(io, command, new Error(result.stderr || result.stdout || `codegraph exited with code ${result.exitCode}`), true, result.exitCode);
|
|
51
|
+
return true;
|
|
52
|
+
}
|
|
53
|
+
const didFail = result.exitCode !== null && result.exitCode !== 0;
|
|
54
|
+
const rewritten = rewriteBareCodegraphHints(result.stdout);
|
|
55
|
+
const stdout = attributeStdout === undefined ? rewritten : attributeStdout(rewritten);
|
|
56
|
+
const stderr = rewriteBareCodegraphHints(result.stderr);
|
|
57
|
+
if (stdout.length > 0) {
|
|
58
|
+
io.stdout((didFail ? redactSensitiveErrorMessage(stdout) : stdout).trimEnd());
|
|
59
|
+
}
|
|
60
|
+
if (stderr.length > 0) {
|
|
61
|
+
io.stderr((didFail ? redactSensitiveErrorMessage(stderr) : stderr).trimEnd());
|
|
62
|
+
}
|
|
63
|
+
if (didFail) {
|
|
64
|
+
process.exitCode = result.exitCode;
|
|
65
|
+
}
|
|
66
|
+
return didFail;
|
|
67
|
+
}
|
|
68
|
+
catch (error) {
|
|
69
|
+
printCodegraphFailure(io, command, error, asJson);
|
|
70
|
+
return true;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
@@ -1,14 +1,5 @@
|
|
|
1
1
|
import { Command } from 'commander';
|
|
2
2
|
import { type ProgramIO } from '../cli-helpers.js';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
* equivalent (`peaks codegraph <subcommand>`). The upstream binary is a
|
|
6
|
-
* nested transitive dependency and is NOT on PATH, so an LLM that follows
|
|
7
|
-
* a bare hint like `Run "codegraph init" to initialize` would hit
|
|
8
|
-
* "command not found". Already-prefixed `peaks codegraph ...` hints and
|
|
9
|
-
* other `codegraph` references (e.g. `@colbymchenry/codegraph`) are left
|
|
10
|
-
* untouched.
|
|
11
|
-
*/
|
|
12
|
-
export declare function rewriteBareCodegraphHints(text: string): string;
|
|
13
|
-
export declare function attributeUpstreamUpToDateLine(stdout: string): string;
|
|
3
|
+
export { rewriteBareCodegraphHints } from './codegraph-command-runtime.js';
|
|
4
|
+
export { attributeUpstreamUpToDateLine } from './codegraph-status-command.js';
|
|
14
5
|
export declare function registerCodegraphCommands(program: Command, io: ProgramIO): void;
|