peaks-loop 3.0.0 → 3.0.2

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 (244) hide show
  1. package/.claude-plugin/marketplace.json +3 -3
  2. package/CHANGELOG.md +94 -59
  3. package/README-en.md +2 -2
  4. package/README.md +2 -2
  5. package/agents/karpathy-reviewer.md +2 -2
  6. package/dist/src/cli/commands/agent-commands.js +3 -3
  7. package/dist/src/cli/commands/audit-commands.d.ts +1 -1
  8. package/dist/src/cli/commands/audit-commands.js +6 -6
  9. package/dist/src/cli/commands/classify-classify-commands.js +1 -1
  10. package/dist/src/cli/commands/code-review-commands.d.ts +3 -3
  11. package/dist/src/cli/commands/code-review-commands.js +5 -5
  12. package/dist/src/cli/commands/compact-command.d.ts +21 -0
  13. package/dist/src/cli/commands/compact-command.js +252 -0
  14. package/dist/src/cli/commands/context-commands.d.ts +1 -1
  15. package/dist/src/cli/commands/context-commands.js +1 -1
  16. package/dist/src/cli/commands/contract-commands.d.ts +1 -1
  17. package/dist/src/cli/commands/core/session-command.js +17 -7
  18. package/dist/src/cli/commands/core/skill-command.js +1 -1
  19. package/dist/src/cli/commands/feedback-commands.js +1 -1
  20. package/dist/src/cli/commands/hook-handle.d.ts +1 -1
  21. package/dist/src/cli/commands/hook-handle.js +1 -1
  22. package/dist/src/cli/commands/legacy-commands.d.ts +1 -1
  23. package/dist/src/cli/commands/legacy-commands.js +2 -2
  24. package/dist/src/cli/commands/log-commands.js +2 -2
  25. package/dist/src/cli/commands/loop-commands.d.ts +1 -1
  26. package/dist/src/cli/commands/loop-commands.js +1 -1
  27. package/dist/src/cli/commands/loop-eval-commands.d.ts +1 -1
  28. package/dist/src/cli/commands/loop-eval-commands.js +1 -1
  29. package/dist/src/cli/commands/playwright-commands.d.ts +1 -1
  30. package/dist/src/cli/commands/playwright-commands.js +2 -2
  31. package/dist/src/cli/commands/request-commands.js +40 -1
  32. package/dist/src/cli/commands/role-commands.js +1 -1
  33. package/dist/src/cli/commands/slice-commands.js +5 -5
  34. package/dist/src/cli/commands/understand-commands.js +36 -0
  35. package/dist/src/cli/commands/upgrade-commands.d.ts +1 -1
  36. package/dist/src/cli/commands/upgrade-commands.js +6 -6
  37. package/dist/src/cli/commands/workspace/init-command.js +2 -2
  38. package/dist/src/cli/program.js +10 -1
  39. package/dist/src/services/agent/ecc-agent-service.js +5 -5
  40. package/dist/src/services/audit/artifact-writer.d.ts +1 -1
  41. package/dist/src/services/audit/artifact-writer.js +1 -1
  42. package/dist/src/services/audit/decision-writer.d.ts +1 -1
  43. package/dist/src/services/audit/decision-writer.js +1 -1
  44. package/dist/src/services/audit/enforcers/lint-output-style.js +5 -5
  45. package/dist/src/services/audit/enforcers/mock-placement.d.ts +1 -1
  46. package/dist/src/services/audit/enforcers/mock-placement.js +1 -1
  47. package/dist/src/services/audit/enforcers/no-root-pollution.js +1 -1
  48. package/dist/src/services/audit/red-line-catalog-p2-a.js +2 -2
  49. package/dist/src/services/audit/red-line-catalog-p2-b.js +2 -2
  50. package/dist/src/services/audit/static-service.d.ts +1 -1
  51. package/dist/src/services/audit/static-service.js +5 -5
  52. package/dist/src/services/audit/types.d.ts +1 -1
  53. package/dist/src/services/audit/types.js +1 -1
  54. package/dist/src/services/audit-independent/perf-audit-service.js +1 -1
  55. package/dist/src/services/audit-independent/security-audit-service.js +1 -1
  56. package/dist/src/services/classify/classify-service.d.ts +1 -1
  57. package/dist/src/services/classify/classify-service.js +1 -1
  58. package/dist/src/services/classify/classify-types.d.ts +1 -1
  59. package/dist/src/services/classify/classify-types.js +1 -1
  60. package/dist/src/services/code-review/ecc-bridge.d.ts +2 -2
  61. package/dist/src/services/code-review/ecc-bridge.js +2 -2
  62. package/dist/src/services/code-review/ocr-service.d.ts +9 -9
  63. package/dist/src/services/code-review/ocr-service.js +16 -16
  64. package/dist/src/services/compact/decision-tables.d.ts +66 -0
  65. package/dist/src/services/compact/decision-tables.js +127 -0
  66. package/dist/src/services/compact/request-transition-hook.d.ts +20 -0
  67. package/dist/src/services/compact/request-transition-hook.js +110 -0
  68. package/dist/src/services/compact/suggest-service.d.ts +74 -0
  69. package/dist/src/services/compact/suggest-service.js +203 -0
  70. package/dist/src/services/config/config-migration.js +1 -1
  71. package/dist/src/services/config/config-safety.d.ts +1 -1
  72. package/dist/src/services/config/config-safety.js +1 -1
  73. package/dist/src/services/config/config-service.d.ts +1 -1
  74. package/dist/src/services/config/config-service.js +1 -1
  75. package/dist/src/services/context/auto-compact-dispatcher.js +4 -4
  76. package/dist/src/services/context/auto-compact-types.d.ts +6 -6
  77. package/dist/src/services/context/auto-compact-types.js +5 -5
  78. package/dist/src/services/dispatch/sub-agent-dispatcher.js +1 -1
  79. package/dist/src/services/dispatch/test-tool-detection.d.ts +1 -1
  80. package/dist/src/services/dispatch/test-tool-detection.js +1 -1
  81. package/dist/src/services/doctor/doctor-service.d.ts +1 -1
  82. package/dist/src/services/doctor/doctor-service.js +5 -5
  83. package/dist/src/services/hooks/presence-marker-detector.js +5 -5
  84. package/dist/src/services/ide/adapters/claude-code-adapter.d.ts +1 -1
  85. package/dist/src/services/ide/adapters/claude-code-adapter.js +2 -2
  86. package/dist/src/services/ide/adapters/codex-adapter.d.ts +2 -2
  87. package/dist/src/services/ide/adapters/codex-adapter.js +2 -2
  88. package/dist/src/services/ide/adapters/cursor-adapter.d.ts +2 -2
  89. package/dist/src/services/ide/adapters/cursor-adapter.js +2 -2
  90. package/dist/src/services/ide/adapters/hermes-adapter.d.ts +1 -1
  91. package/dist/src/services/ide/adapters/hermes-adapter.js +1 -1
  92. package/dist/src/services/ide/adapters/openclaw-adapter.d.ts +1 -1
  93. package/dist/src/services/ide/adapters/openclaw-adapter.js +1 -1
  94. package/dist/src/services/ide/adapters/trae-adapter.d.ts +1 -1
  95. package/dist/src/services/ide/adapters/trae-adapter.js +1 -1
  96. package/dist/src/services/ide/ide-types.d.ts +9 -9
  97. package/dist/src/services/legacy/legacy-detector.d.ts +1 -1
  98. package/dist/src/services/legacy/legacy-detector.js +1 -1
  99. package/dist/src/services/log/log-commands-service.d.ts +1 -1
  100. package/dist/src/services/log/log-commands-service.js +1 -1
  101. package/dist/src/services/log/logger.d.ts +3 -3
  102. package/dist/src/services/log/logger.js +3 -3
  103. package/dist/src/services/log/redact.d.ts +1 -1
  104. package/dist/src/services/log/redact.js +1 -1
  105. package/dist/src/services/loop/evaluator-dispatcher.d.ts +1 -1
  106. package/dist/src/services/loop/evaluator-dispatcher.js +16 -15
  107. package/dist/src/services/loop/monotonic-guard.js +35 -18
  108. package/dist/src/services/loop/monotonic-runner.d.ts +3 -0
  109. package/dist/src/services/loop/monotonic-runner.js +62 -28
  110. package/dist/src/services/loop/run-driver.js +45 -24
  111. package/dist/src/services/memory/llm-reranker.d.ts +1 -1
  112. package/dist/src/services/memory/llm-reranker.js +1 -1
  113. package/dist/src/services/mut/production-stryker.d.ts +0 -5
  114. package/dist/src/services/mut/production-stryker.js +19 -10
  115. package/dist/src/services/openspec/openspec-propose-from-doctor-service.d.ts +1 -1
  116. package/dist/src/services/openspec/openspec-propose-from-doctor-service.js +1 -1
  117. package/dist/src/services/perf/perf-baseline-service.d.ts +2 -2
  118. package/dist/src/services/perf/perf-baseline-service.js +2 -2
  119. package/dist/src/services/prd/handoff-auto-regen.js +1 -1
  120. package/dist/src/services/prd/project-scan-sediment.js +3 -3
  121. package/dist/src/services/prd/project-scan-types.d.ts +1 -1
  122. package/dist/src/services/preferences/preferences-types.d.ts +3 -3
  123. package/dist/src/services/preferences/preferences-types.js +2 -2
  124. package/dist/src/services/role/role-registry.d.ts +1 -1
  125. package/dist/src/services/role/role-registry.js +1 -1
  126. package/dist/src/services/sc/sc-service.js +3 -3
  127. package/dist/src/services/skill/resume-detector.js +2 -2
  128. package/dist/src/services/skills/sync-service.d.ts +3 -3
  129. package/dist/src/services/skills/sync-service.js +9 -9
  130. package/dist/src/services/slice/calibration-store.d.ts +1 -1
  131. package/dist/src/services/slice/calibration-store.js +1 -1
  132. package/dist/src/services/solo/auto-compact-orchestrator.d.ts +1 -1
  133. package/dist/src/services/solo/auto-compact-orchestrator.js +7 -7
  134. package/dist/src/services/solo/dag-orchestrator.js +1 -1
  135. package/dist/src/services/solo/mode-gate.d.ts +1 -1
  136. package/dist/src/services/solo/mode-gate.js +4 -4
  137. package/dist/src/services/solo/user-touchpoint-classifier.js +1 -1
  138. package/dist/src/services/standards/migrate-claude-rules-service.js +5 -5
  139. package/dist/src/services/standards/migrate-service.d.ts +3 -3
  140. package/dist/src/services/standards/migrate-service.js +5 -5
  141. package/dist/src/services/standards/project-standards-service.js +1 -1
  142. package/dist/src/services/understand/hybrid-types.d.ts +32 -0
  143. package/dist/src/services/understand/hybrid-types.js +1 -0
  144. package/dist/src/services/understand/understand-hybrid-service.d.ts +10 -0
  145. package/dist/src/services/understand/understand-hybrid-service.js +100 -0
  146. package/dist/src/services/upgrade/gitignore-migrate-service.d.ts +3 -3
  147. package/dist/src/services/upgrade/gitignore-migrate-service.js +4 -4
  148. package/dist/src/services/upgrade/upgrade-service.d.ts +1 -1
  149. package/dist/src/services/upgrade/upgrade-service.js +5 -5
  150. package/dist/src/services/verdict/envelopes.d.ts +1 -1
  151. package/dist/src/services/verdict/envelopes.js +1 -1
  152. package/dist/src/services/workflow/workflow-loader.js +1 -1
  153. package/dist/src/services/workspace/migrate-1-4-1-service.d.ts +1 -1
  154. package/dist/src/services/workspace/migrate-1-4-1-service.js +1 -1
  155. package/dist/src/services/workspace/migrate-types.d.ts +1 -1
  156. package/dist/src/services/workspace/migrate-types.js +1 -1
  157. package/dist/src/services/workspace/workspace-claude-settings-materializer.d.ts +2 -2
  158. package/dist/src/services/workspace/workspace-claude-settings-materializer.js +9 -9
  159. package/dist/src/services/workspace/workspace-service.d.ts +1 -1
  160. package/dist/src/services/workspace/workspace-service.js +1 -1
  161. package/dist/src/shared/path-safety.d.ts +1 -1
  162. package/dist/src/shared/path-safety.js +1 -1
  163. package/dist/src/shared/version.d.ts +1 -1
  164. package/dist/src/shared/version.js +1 -1
  165. package/output-styles/peaks-skill-swarm.md +33 -33
  166. package/package.json +5 -4
  167. package/schemas/decomposition-v1.json +1 -1
  168. package/schemas/decomposition-v2.json +1 -1
  169. package/schemas/replay-fixture.schema.json +1 -1
  170. package/schemas/reviewer-envelope.schema.json +1 -1
  171. package/scripts/install-skills.mjs +11 -11
  172. package/skills/peaks-audit/SKILL.md +2 -2
  173. package/skills/peaks-doctor/SKILL.md +4 -4
  174. package/skills/peaks-final-review/SKILL.md +2 -2
  175. package/skills/peaks-ide/SKILL.md +3 -3
  176. package/skills/peaks-perf-audit/SKILL.md +1 -1
  177. package/skills/peaks-prd/SKILL.md +14 -14
  178. package/skills/peaks-prd/references/workflow.md +1 -1
  179. package/skills/peaks-qa/SKILL.md +17 -17
  180. package/skills/peaks-qa/references/artifact-per-request.md +1 -1
  181. package/skills/peaks-qa/references/browser-validation-contracts.md +2 -2
  182. package/skills/peaks-qa/references/codegraph-regression-focus.md +1 -1
  183. package/skills/peaks-qa/references/external-capability-guidance.md +2 -2
  184. package/skills/peaks-qa/references/qa-fanout-contract.md +1 -1
  185. package/skills/peaks-qa/references/qa-gstack-integration.md +3 -3
  186. package/skills/peaks-qa/references/qa-local-artifacts.md +1 -1
  187. package/skills/peaks-qa/references/qa-matt-pocock-integration.md +1 -1
  188. package/skills/peaks-qa/references/qa-runbook.md +3 -3
  189. package/skills/peaks-qa/references/qa-skill-presence.md +1 -1
  190. package/skills/peaks-qa/references/qa-standards-preflight.md +2 -2
  191. package/skills/peaks-qa/references/qa-transition-gates.md +9 -9
  192. package/skills/peaks-qa/references/regression-gates.md +1 -1
  193. package/skills/peaks-rd/SKILL.md +13 -13
  194. package/skills/peaks-rd/references/artifact-and-standards-output.md +1 -1
  195. package/skills/peaks-rd/references/codegraph-project-analysis.md +1 -1
  196. package/skills/peaks-rd/references/external-references.md +3 -3
  197. package/skills/peaks-rd/references/karpathy-reviewer-prompt.md +1 -1
  198. package/skills/peaks-rd/references/mandatory-perf-baseline.md +1 -1
  199. package/skills/peaks-rd/references/matt-pocock-integration.md +2 -2
  200. package/skills/peaks-rd/references/ocr-integration.md +19 -19
  201. package/skills/peaks-rd/references/openspec-cli.md +2 -2
  202. package/skills/peaks-rd/references/rd-gstack-integration.md +5 -5
  203. package/skills/peaks-rd/references/rd-runbook.md +9 -9
  204. package/skills/peaks-rd/references/rd-standards-preflight.md +1 -1
  205. package/skills/peaks-rd/references/rd-transition-gates.md +13 -13
  206. package/skills/peaks-rd/references/skill-presence-and-title.md +1 -1
  207. package/skills/peaks-reviewer/SKILL.md +2 -2
  208. package/skills/peaks-sc/SKILL.md +9 -9
  209. package/skills/peaks-security-audit/SKILL.md +1 -1
  210. package/skills/peaks-slice-decompose/SKILL.md +2 -2
  211. package/skills/peaks-solo/SKILL.md +49 -49
  212. package/skills/peaks-solo/references/a2a-artifact-mapping.md +8 -8
  213. package/skills/peaks-solo/references/anchoring-and-session-info.md +3 -3
  214. package/skills/peaks-solo/references/boundaries.md +4 -4
  215. package/skills/peaks-solo/references/browser-workflow.md +2 -2
  216. package/skills/peaks-solo/references/codegraph-orchestration.md +1 -1
  217. package/skills/peaks-solo/references/completion-handoff.md +2 -2
  218. package/skills/peaks-solo/references/external-references.md +3 -3
  219. package/skills/peaks-solo/references/external-skill-invocation.md +2 -2
  220. package/skills/peaks-solo/references/frontend-only-mode.md +1 -1
  221. package/skills/peaks-solo/references/gstack-integration.md +4 -4
  222. package/skills/peaks-solo/references/local-artifact-workspace.md +2 -2
  223. package/skills/peaks-solo/references/micro-cycle.md +4 -4
  224. package/skills/peaks-solo/references/mode-selection.md +5 -5
  225. package/skills/peaks-solo/references/openspec-workflow.md +2 -2
  226. package/skills/peaks-solo/references/playwright-mcp-multi-terminal.md +1 -1
  227. package/skills/peaks-solo/references/project-memory-loading.md +1 -1
  228. package/skills/peaks-solo/references/project-scan-checklist.md +1 -1
  229. package/skills/peaks-solo/references/quality-gate-cheatsheet.md +1 -1
  230. package/skills/peaks-solo/references/resume-detection.md +1 -1
  231. package/skills/peaks-solo/references/runbook.md +20 -20
  232. package/skills/peaks-solo/references/skill-presence-and-title.md +2 -2
  233. package/skills/peaks-solo/references/standards-preflight.md +2 -2
  234. package/skills/peaks-solo/references/step-0-55-1x-detection.md +3 -3
  235. package/skills/peaks-solo/references/sub-agent-dispatch.md +3 -3
  236. package/skills/peaks-solo/references/swarm-dispatch-contract.md +3 -3
  237. package/skills/peaks-solo/references/workflow-gates-and-types.md +34 -34
  238. package/skills/peaks-solo-resume/SKILL.md +2 -2
  239. package/skills/peaks-solo-status/SKILL.md +4 -4
  240. package/skills/peaks-solo-test/SKILL.md +4 -4
  241. package/skills/peaks-sop/SKILL.md +5 -5
  242. package/skills/peaks-txt/SKILL.md +17 -17
  243. package/skills/peaks-ui/SKILL.md +17 -17
  244. package/skills/peaks-ui/references/workflow.md +1 -1
@@ -1,20 +1,23 @@
1
+ /**
2
+ * Production Stryker invoker. Uses @stryker-mutator/core programmatic API.
3
+ * Note: this is a thin wrapper — actual Stryker invocation requires the
4
+ * Stryker config in `stryker.conf.js` to live at the project root.
5
+ */
6
+ import { relative, isAbsolute } from 'node:path';
1
7
  export function createProductionStrykerInvoker() {
2
- return async ({ project, testFiles }) => {
8
+ return async ({ project, testFiles: _testFiles }) => {
3
9
  // Lazy-load Stryker so unit tests don't need it installed.
4
10
  // eslint-disable-next-line @typescript-eslint/no-require-imports
5
11
  const Stryker = (await import('@stryker-mutator/core')).Stryker;
6
- const options = {
7
- // Project-rooted config; explicit overrides here are minimal.
8
- mutate: [...testFiles],
9
- };
10
- // Single cast derives from Stryker's actual constructor signature.
11
- // Stryker 8's MutantResult extends our local StrykerMutant structurally.
12
- const stryker = new Stryker(options);
12
+ // Mutation surface is owned by stryker.conf.js. testFiles is a runtime
13
+ // hint (consumed by the configured testRunner, not by Stryker's `mutate`
14
+ // field — `mutate` is source files to mutate, never test paths).
15
+ const stryker = new Stryker({});
13
16
  const mutants = (await stryker.runMutationTest());
14
17
  return normalize(mutants, project);
15
18
  };
16
19
  }
17
- function normalize(mutants, _project) {
20
+ function normalize(mutants, project) {
18
21
  let mutantsKilled = 0;
19
22
  let mutantsSurvived = 0;
20
23
  let mutantsTimeout = 0;
@@ -31,7 +34,13 @@ function normalize(mutants, _project) {
31
34
  // empty (as v0 did) silently swallowed those followups in production.
32
35
  const byFile = new Map();
33
36
  for (const m of mutants) {
34
- const file = m.fileName;
37
+ // Stryker 8 returns absolute paths in MutantResult.fileName. Strip the
38
+ // project root so byFile[].file is repo-relative (e.g. "src/services/loop/...").
39
+ // path.relative falls back to the absolute path when input is outside
40
+ // project, which is the safest failure mode.
41
+ const file = isAbsolute(m.fileName) && m.fileName.startsWith(project)
42
+ ? relative(project, m.fileName)
43
+ : m.fileName;
35
44
  let bucket = byFile.get(file);
36
45
  if (!bucket) {
37
46
  bucket = { killed: 0, survived: 0, survivedEntries: [] };
@@ -4,7 +4,7 @@
4
4
  *
5
5
  * Per L1+L2+L3 redesign §5.4: "CRITICAL → proposal 草稿生成". The doctor
6
6
  * scans the project for issues; when a CRITICAL finding is surfaced,
7
- * peaks-cli generates a draft `openspec/changes/<id>/proposal.md` so the
7
+ * peaks-loop generates a draft `openspec/changes/<id>/proposal.md` so the
8
8
  * LLM doesn't have to start from scratch.
9
9
  *
10
10
  * The draft proposal is INFORMATIONAL — it requires the LLM to review +
@@ -4,7 +4,7 @@
4
4
  *
5
5
  * Per L1+L2+L3 redesign §5.4: "CRITICAL → proposal 草稿生成". The doctor
6
6
  * scans the project for issues; when a CRITICAL finding is surfaced,
7
- * peaks-cli generates a draft `openspec/changes/<id>/proposal.md` so the
7
+ * peaks-loop generates a draft `openspec/changes/<id>/proposal.md` so the
8
8
  * LLM doesn't have to start from scratch.
9
9
  *
10
10
  * The draft proposal is INFORMATIONAL — it requires the LLM to review +
@@ -16,7 +16,7 @@
16
16
  * `.peaks/_runtime/<sid>/rd/perf-baseline.md` so QA Gate A4 has a known-good
17
17
  * reference to diff against. The CLI itself only writes the scaffold
18
18
  * and records the path; the actual measurement is a project-local
19
- * concern that lives in the README, not in peaks-cli.
19
+ * concern that lives in the README, not in peaks-loop.
20
20
  *
21
21
  * The four-grounds check (per the skill-primary-CLI-auxiliary dev
22
22
  * preference):
@@ -33,7 +33,7 @@
33
33
  * NOT add a lint gate here.
34
34
  *
35
35
  * Net: CLI is justified. The destructive --apply default is dry-run,
36
- * matching the rest of peaks-cli's scaffolding pattern.
36
+ * matching the rest of peaks-loop's scaffolding pattern.
37
37
  */
38
38
  export type PerfBaselineInitOptions = {
39
39
  projectRoot: string;
@@ -16,7 +16,7 @@
16
16
  * `.peaks/_runtime/<sid>/rd/perf-baseline.md` so QA Gate A4 has a known-good
17
17
  * reference to diff against. The CLI itself only writes the scaffold
18
18
  * and records the path; the actual measurement is a project-local
19
- * concern that lives in the README, not in peaks-cli.
19
+ * concern that lives in the README, not in peaks-loop.
20
20
  *
21
21
  * The four-grounds check (per the skill-primary-CLI-auxiliary dev
22
22
  * preference):
@@ -33,7 +33,7 @@
33
33
  * NOT add a lint gate here.
34
34
  *
35
35
  * Net: CLI is justified. The destructive --apply default is dry-run,
36
- * matching the rest of peaks-cli's scaffolding pattern.
36
+ * matching the rest of peaks-loop's scaffolding pattern.
37
37
  */
38
38
  import { mkdir, writeFile } from 'node:fs/promises';
39
39
  import { existsSync } from 'node:fs';
@@ -41,7 +41,7 @@ export async function autoRegenPrdHandoff(opts) {
41
41
  const sha256 = sha256OfBody(body);
42
42
  // v2.13.3 AC-4 — align with `AUDIT_REQUIRES_HANDOFF` prereq which
43
43
  // pins `mustContain: ['schemaVersion: 2', 'sha256:']`. The previous
44
- // field name `handoffHash` made peaks-cli write a handoff that the
44
+ // field name `handoffHash` made peaks-loop write a handoff that the
45
45
  // own prereq resolver would reject with "missing section(s): sha256:".
46
46
  // Primary field is now `sha256`; `handoffHash` is kept as a literal
47
47
  // alias for back-compat with any consumer (UI / external scripts)
@@ -307,9 +307,9 @@ function splitTableRow(row) {
307
307
  }
308
308
  function renderFreshAuditPatternBody(args) {
309
309
  const titleByKind = {
310
- 'security-audit': 'Security Audit Template (peaks-cli v2.12.0)',
311
- 'perf-audit': 'Performance Audit Template (peaks-cli v2.12.0)',
312
- 'audit-output-schema': 'Audit Output Schema (peaks-cli v2.12.0)'
310
+ 'security-audit': 'Security Audit Template (peaks-loop v2.12.0)',
311
+ 'perf-audit': 'Performance Audit Template (peaks-loop v2.12.0)',
312
+ 'audit-output-schema': 'Audit Output Schema (peaks-loop v2.12.0)'
313
313
  };
314
314
  const appliesToByKind = {
315
315
  'security-audit': 'peaks-security-audit skill',
@@ -19,7 +19,7 @@
19
19
  */
20
20
  /** Tech-stack snapshot. `language` / `packageManager` are closed
21
21
  * unions (Karpathy §2 — no string sprawl); `runtime` / `buildTool`
22
- * are free-form (peaks-cli does not constrain them). */
22
+ * are free-form (peaks-loop does not constrain them). */
23
23
  export interface ProjectScanTechStack {
24
24
  readonly language: 'typescript';
25
25
  readonly packageManager: 'pnpm';
@@ -1,9 +1,9 @@
1
1
  /**
2
- * peaks-cli 2.0 project-local preferences schema.
2
+ * peaks-loop 2.0 project-local preferences schema.
3
3
  * Per spec §8.4 — per-project state lives in `.peaks/preferences.json`,
4
4
  * NOT in `~/.peaks/config.json` (which is slim global).
5
5
  *
6
- * Spec reference: docs/superpowers/specs/2026-06-11-peaks-cli-l1-l2-l3-redesign.md §8.4
6
+ * Spec reference: docs/superpowers/specs/2026-06-11-peaks-loop-l1-l2-l3-redesign.md §8.4
7
7
  */
8
8
  export declare const PREFERENCES_SCHEMA_VERSION = "2.0.0";
9
9
  /**
@@ -110,7 +110,7 @@ export interface ProjectPreferences {
110
110
  *
111
111
  * When true, `peaks audit static` spawns `npx ecc-agentshield scan --json`
112
112
  * and merges its findings into the audit report. When false (default),
113
- * the audit runs peaks-cli-only and the subprocess is never spawned.
113
+ * the audit runs peaks-loop-only and the subprocess is never spawned.
114
114
  *
115
115
  * The preference is independent of whether ECC is installed — i.e.
116
116
  * `agentShieldEnabled: true` with ECC missing surfaces a soft
@@ -1,9 +1,9 @@
1
1
  /**
2
- * peaks-cli 2.0 project-local preferences schema.
2
+ * peaks-loop 2.0 project-local preferences schema.
3
3
  * Per spec §8.4 — per-project state lives in `.peaks/preferences.json`,
4
4
  * NOT in `~/.peaks/config.json` (which is slim global).
5
5
  *
6
- * Spec reference: docs/superpowers/specs/2026-06-11-peaks-cli-l1-l2-l3-redesign.md §8.4
6
+ * Spec reference: docs/superpowers/specs/2026-06-11-peaks-loop-l1-l2-l3-redesign.md §8.4
7
7
  */
8
8
  export const PREFERENCES_SCHEMA_VERSION = '2.0.0';
9
9
  export const FANOUT_MODES = ['fan-out'];
@@ -32,7 +32,7 @@ export declare function upsertRole(registry: RoleRegistry, role: Role): RoleRegi
32
32
  export declare function grantPermission(registry: RoleRegistry, roleName: string, permission: string): RoleRegistry;
33
33
  /** Check if a role has a permission. */
34
34
  export declare function roleHasPermission(registry: RoleRegistry, roleName: string, permission: string): boolean;
35
- /** Permission categories that align with the peaks-cli 12 Gaps memory. */
35
+ /** Permission categories that align with the peaks-loop 12 Gaps memory. */
36
36
  export declare const DEFAULT_PERMISSIONS: readonly string[];
37
37
  /** Default role preset for a Senior FE on a 24h AI programmer team. */
38
38
  export declare const DEFAULT_SENIOR_FE_ROLE: Role;
@@ -59,7 +59,7 @@ export function roleHasPermission(registry, roleName, permission) {
59
59
  return false;
60
60
  return role.permissions.includes(permission);
61
61
  }
62
- /** Permission categories that align with the peaks-cli 12 Gaps memory. */
62
+ /** Permission categories that align with the peaks-loop 12 Gaps memory. */
63
63
  export const DEFAULT_PERMISSIONS = [
64
64
  'prd.write',
65
65
  'prd.confirm',
@@ -23,7 +23,7 @@ const RETENTION_REQUIREMENTS = [
23
23
  ['txt', 'context-capsule.md']
24
24
  ];
25
25
  /**
26
- * "Modern" retention requirements for the current peaks-cli artifact
26
+ * "Modern" retention requirements for the current peaks-loop artifact
27
27
  * naming convention. The legacy `RETENTION_REQUIREMENTS` above assume
28
28
  * older `refactor-goal.md` / `slice-spec.md` / `coverage-report.md` /
29
29
  * `validation-report.md` / `change-impact.json` / `retention-boundary.md`
@@ -502,10 +502,10 @@ export function validateArtifactRetention(sliceId) {
502
502
  // If the legacy check is short (i.e. we're missing a lot of legacy-named
503
503
  // files) but the resolver landed on a real session, ALSO accept the
504
504
  // modern set. The legacy set was designed for an older workflow naming
505
- // and a freshly-minted session in the current peaks-cli flow will not
505
+ // and a freshly-minted session in the current peaks-loop flow will not
506
506
  // have the legacy names. This keeps `peaks sc validate --slice-id <rid>`
507
507
  // returning `valid: true` for slices that completed under the current
508
- // peaks-cli convention.
508
+ // peaks-loop convention.
509
509
  if (missingArtifacts.length > 0 && resolvedPeaksSessionDir !== null) {
510
510
  const modernMissing = modernRequirementRelativePaths(sliceId).filter((rel) => !resolvedPresent(...rel.split('/')));
511
511
  if (modernMissing.length === 0) {
@@ -1,8 +1,8 @@
1
1
  /**
2
- * Peaks-Cli Solo Step 0.7 — Resume-mode detector.
2
+ * Peaks-Loop Solo Step 0.7 — Resume-mode detector.
3
3
  *
4
4
  * Mirrors the classification table in
5
- * `skills/peaks-solo/SKILL.md` "Peaks-Cli Step 0.7: Detect unfinished work
5
+ * `skills/peaks-solo/SKILL.md` "Peaks-Loop Step 0.7: Detect unfinished work
6
6
  * and offer resume". The function is a pure read of session artifacts;
7
7
  * it performs no side effects and is safe to call from hooks, scripts,
8
8
  * and skills.
@@ -47,10 +47,10 @@ interface InstallResult {
47
47
  }
48
48
  type InstallerFn = (opts: InstallBundledSkillsOptions) => InstallResult;
49
49
  /**
50
- * Resolve the path of `install-skills.mjs` inside the peaks-cli
50
+ * Resolve the path of `install-skills.mjs` inside the peaks-loop
51
51
  * install root, walking up from `import.meta.url` until a
52
- * `package.json` with `"name": "peaks-cli"` is found. Returns
53
- * `null` when peaks-cli is not on the import path or the script
52
+ * `package.json` with `"name": "peaks-loop"` is found. Returns
53
+ * `null` when peaks-loop is not on the import path or the script
54
54
  * is absent (e.g. a partial install).
55
55
  */
56
56
  export declare function resolvePeaksCliInstallerPath(): string | null;
@@ -9,13 +9,13 @@
9
9
  * is `scripts/install-skills.mjs::installBundledSkills` (dynamically
10
10
  * imported so this module does not require a build step).
11
11
  *
12
- * Slice 2.0.1-bug2-skill-sync-fallback: when peaks-cli is
12
+ * Slice 2.0.1-bug2-skill-sync-fallback: when peaks-loop is
13
13
  * installed from npm into a consumer project, that consumer's
14
14
  * CWD does not contain `scripts/install-skills.mjs`. The previous
15
15
  * hard-coded `join(process.cwd(), 'scripts', 'install-skills.mjs')`
16
16
  * therefore threw `ERR_MODULE_NOT_FOUND` in every consumer run.
17
17
  * The fix is a three-tier probe:
18
- * 1. peaks-cli's own install path (resolved from
18
+ * 1. peaks-loop's own install path (resolved from
19
19
  * `import.meta.url` walking up to the package root, or
20
20
  * from `process.argv[1]` for CJS-equivalent entrypoints),
21
21
  * 2. the consumer CWD (`<cwd>/scripts/install-skills.mjs`),
@@ -62,7 +62,7 @@ function noopInstaller(_opts) {
62
62
  return {
63
63
  installed: [],
64
64
  skipped: [
65
- 'install-skills.mjs not found in project; skill sync skipped — bundled skills are installed via peaks-cli postinstall',
65
+ 'install-skills.mjs not found in project; skill sync skipped — bundled skills are installed via peaks-loop postinstall',
66
66
  ],
67
67
  };
68
68
  }
@@ -79,10 +79,10 @@ const services = {
79
79
  loadInstallerForTest,
80
80
  };
81
81
  /**
82
- * Resolve the path of `install-skills.mjs` inside the peaks-cli
82
+ * Resolve the path of `install-skills.mjs` inside the peaks-loop
83
83
  * install root, walking up from `import.meta.url` until a
84
- * `package.json` with `"name": "peaks-cli"` is found. Returns
85
- * `null` when peaks-cli is not on the import path or the script
84
+ * `package.json` with `"name": "peaks-loop"` is found. Returns
85
+ * `null` when peaks-loop is not on the import path or the script
86
86
  * is absent (e.g. a partial install).
87
87
  */
88
88
  export function resolvePeaksCliInstallerPath() {
@@ -154,7 +154,7 @@ export async function loadInstallerForTest(scriptPath) {
154
154
  }
155
155
  /**
156
156
  * Resolve and load the installer, memoizing the outcome.
157
- * Three-tier probe (peaks-cli install path → CWD → no-op),
157
+ * Three-tier probe (peaks-loop install path → CWD → no-op),
158
158
  * with the "not found" outcome memoized as a sentinel so the
159
159
  * warning is logged at most once per process.
160
160
  *
@@ -171,7 +171,7 @@ async function loadInstaller() {
171
171
  if (cachedInstaller !== null) {
172
172
  return cachedInstaller;
173
173
  }
174
- // Tier 1: peaks-cli install path.
174
+ // Tier 1: peaks-loop install path.
175
175
  const peaksCliScript = services.resolvePeaksCliInstallerPath();
176
176
  if (peaksCliScript !== null) {
177
177
  const installer = await services.loadInstallerForTest(peaksCliScript);
@@ -191,7 +191,7 @@ async function loadInstaller() {
191
191
  cachedInstaller = NO_INSTALLER_SENTINEL;
192
192
  // eslint-disable-next-line no-console -- intentional user-visible signal
193
193
  console.warn('peaks skill sync: install-skills.mjs not found in project; ' +
194
- 'skipping (bundled skills come from peaks-cli postinstall).');
194
+ 'skipping (bundled skills come from peaks-loop postinstall).');
195
195
  return noopInstaller;
196
196
  }
197
197
  /**
@@ -10,7 +10,7 @@
10
10
  * sample size >= 5 for a complexity bucket, switch to percentile-based
11
11
  * estimate with confidence 'high'.
12
12
  *
13
- * v1 rationale: peaks-cli itself has fewer than 5 completed refactor slices
13
+ * v1 rationale: peaks-loop itself has fewer than 5 completed refactor slices
14
14
  * (per the design doc R3), so v1 cannot be calibrated yet. v1 ships the
15
15
  * heuristic AND records every estimate to `.peaks/_runtime/<sid>/sc/
16
16
  * slice-calibration/<rid>.json` so the next slice can use the prior data.
@@ -10,7 +10,7 @@
10
10
  * sample size >= 5 for a complexity bucket, switch to percentile-based
11
11
  * estimate with confidence 'high'.
12
12
  *
13
- * v1 rationale: peaks-cli itself has fewer than 5 completed refactor slices
13
+ * v1 rationale: peaks-loop itself has fewer than 5 completed refactor slices
14
14
  * (per the design doc R3), so v1 cannot be calibrated yet. v1 ships the
15
15
  * heuristic AND records every estimate to `.peaks/_runtime/<sid>/sc/
16
16
  * slice-calibration/<rid>.json` so the next slice can use the prior data.
@@ -7,7 +7,7 @@ export interface AutoCompactInput {
7
7
  readonly inFlightBatch?: InFlightBatchProbe | undefined;
8
8
  /**
9
9
  * Force execute even when ratio < threshold (test seam). In
10
- * production this is always `false` — peaks-cli drives compact
10
+ * production this is always `false` — peaks-loop drives compact
11
11
  * autonomously at 0.85+ with zero human / zero LLM intervention.
12
12
  */
13
13
  readonly force?: boolean | undefined;
@@ -2,29 +2,29 @@
2
2
  * Auto-compact orchestrator (v2.13.0 AC-2 + AC-3 + AC-4).
3
3
  *
4
4
  * Closes the loop between `peaks context now` (AC-1) and the IDE's
5
- * native compact capability (AC-3). peaks-cli is project-aware: it
5
+ * native compact capability (AC-3). peaks-loop is project-aware: it
6
6
  * knows the current plan, open questions, recent decisions, in-flight
7
7
  * batches, todo state, git status, and active skills. That context is
8
8
  * strictly more valuable than what `/compact` can synthesize from raw
9
- * conversation history — so peaks-cli drives the entire compaction:
9
+ * conversation history — so peaks-loop drives the entire compaction:
10
10
  *
11
11
  * 1. Read current context % (via IDE adapter's `readContextPercent`).
12
- * 2. If ratio ≥ 0.95 (RED LINE): synchronous gate — peaks-cli
12
+ * 2. If ratio ≥ 0.95 (RED LINE): synchronous gate — peaks-loop
13
13
  * refuses sub-agent dispatch and forces IDE compact immediately.
14
14
  * The LLM cannot opt out (compact red line — keeps the runner
15
15
  * alive).
16
- * 3. If 0.85 ≤ ratio < 0.95 (pre-compact zone): peaks-cli prepares
16
+ * 3. If 0.85 ≤ ratio < 0.95 (pre-compact zone): peaks-loop prepares
17
17
  * the convergence toolkit (checkpoint + auto-decisions log +
18
18
  * IDE-dispatch handle) and surfaces it to the LLM. The LLM
19
19
  * DECIDES when to fire `peaks solo auto-compact --execute`;
20
- * peaks-cli does NOT auto-fire. The toolkit is ready so the
20
+ * peaks-loop does NOT auto-fire. The toolkit is ready so the
21
21
  * LLM doesn't lose context to a last-second `/compact` panic.
22
22
  * 4. If ratio < 0.85: skip — return a one-line info row.
23
23
  *
24
24
  * Why two tiers (vs. one): the LLM uses the 0.85–0.95 zone for
25
25
  * intelligent convergence — wait for in-flight sub-agents, finish
26
26
  * the current todo row, persist a checkpoint, then compact. At 0.95
27
- * the window is gone; peaks-cli takes over synchronously. Net effect:
27
+ * the window is gone; peaks-loop takes over synchronously. Net effect:
28
28
  * the LLM-runner keeps working with context < 95% without human
29
29
  * intervention.
30
30
  */
@@ -95,7 +95,7 @@ export function evaluateAutoCompactDecision(input) {
95
95
  if (input.force) {
96
96
  return { shouldCompact: true, reason: 'pre-compact', trigger };
97
97
  }
98
- // Default: peaks-cli drives pre-compact autonomously.
98
+ // Default: peaks-loop drives pre-compact autonomously.
99
99
  return { shouldCompact: true, reason: 'pre-compact', trigger };
100
100
  }
101
101
  /**
@@ -105,7 +105,7 @@ export function buildDispatchSpec(dag, sliceId, contracts, defaultPrompt) {
105
105
  '',
106
106
  `[slice-dag-dispatcher MVP 1.2] execute slice "${sliceId}" (role=${node.role})${labelFragment}.`,
107
107
  '',
108
- 'Scope: this is the 2.7.0 MVP dogfood of peaks-cli DAG-aware dispatch. You are one leaf in a multi-slice plan; the orchestrator has already validated the DAG, built a topological order, and injected your upstream contracts above.',
108
+ 'Scope: this is the 2.7.0 MVP dogfood of peaks-loop DAG-aware dispatch. You are one leaf in a multi-slice plan; the orchestrator has already validated the DAG, built a topological order, and injected your upstream contracts above.',
109
109
  '',
110
110
  'Handoff protocol (REQUIRED — orchestrator depends on this):',
111
111
  ' 1. Execute the slice to completion.',
@@ -144,7 +144,7 @@ export declare function formatAutoProceedLogLine(opts: {
144
144
  * - `git-tag` → `git tag v2.15.0`, `git tag -a v2.15.0 -m ...`
145
145
  * - `npm-publish` → `npm publish`, `npm publish --access public`
146
146
  * - `npm-install-global` → `npm install -g <pkg>`, `npm i -g <pkg>`
147
- * - `peaks-global-install`→ `npm install -g peaks-cli`, `pnpm add -g peaks-cli`
147
+ * - `peaks-global-install`→ `npm install -g peaks-loop`, `pnpm add -g peaks-loop`
148
148
  *
149
149
  * These are coarse — false positives are fine (worst case: a
150
150
  * non-actionable command gets paused for confirmation; the user
@@ -164,7 +164,7 @@ export function formatAutoProceedLogLine(opts) {
164
164
  * - `git-tag` → `git tag v2.15.0`, `git tag -a v2.15.0 -m ...`
165
165
  * - `npm-publish` → `npm publish`, `npm publish --access public`
166
166
  * - `npm-install-global` → `npm install -g <pkg>`, `npm i -g <pkg>`
167
- * - `peaks-global-install`→ `npm install -g peaks-cli`, `pnpm add -g peaks-cli`
167
+ * - `peaks-global-install`→ `npm install -g peaks-loop`, `pnpm add -g peaks-loop`
168
168
  *
169
169
  * These are coarse — false positives are fine (worst case: a
170
170
  * non-actionable command gets paused for confirmation; the user
@@ -176,7 +176,7 @@ export const COMMIT_BOUNDARY_PATTERNS = {
176
176
  'git-tag': /\bgit\s+tag\b/,
177
177
  'npm-publish': /\bnpm\s+(publish|pub)\b/,
178
178
  'npm-install-global': /\bnpm\s+(install|i|add)\s+(-g|--global)\b/,
179
- 'peaks-global-install': /\b(peaks-cli)\b/
179
+ 'peaks-global-install': /\b(peaks-loop)\b/
180
180
  };
181
181
  /**
182
182
  * v2.15.0 slice 002 AC-4: detect whether a Bash command matches any
@@ -190,8 +190,8 @@ export function detectCommitBoundaryAction(command) {
190
190
  if (typeof command !== 'string' || command.length === 0)
191
191
  return null;
192
192
  // Order matters: peaks-global-install is the most specific
193
- // (matches only the peaks-cli package name). Test that FIRST so
194
- // `npm install -g peaks-cli` is attributed correctly. Then
193
+ // (matches only the peaks-loop package name). Test that FIRST so
194
+ // `npm install -g peaks-loop` is attributed correctly. Then
195
195
  // git-push, git-tag, npm-publish, npm-install-global.
196
196
  if (COMMIT_BOUNDARY_PATTERNS['peaks-global-install'].test(command)) {
197
197
  return 'peaks-global-install';
@@ -141,5 +141,5 @@ export const COMMIT_BOUNDARY_ACTIONS_LIST = [
141
141
  { id: 'git-tag', description: 'git tag v2.15.0 / git tag -a ...' },
142
142
  { id: 'npm-publish', description: 'npm publish / npm pub' },
143
143
  { id: 'npm-install-global', description: 'npm install -g / npm i -g / npm add -g' },
144
- { id: 'peaks-global-install', description: 'peaks-cli 全局安装 / npm install -g peaks-cli' }
144
+ { id: 'peaks-global-install', description: 'peaks-loop 全局安装 / npm install -g peaks-loop' }
145
145
  ];
@@ -2,7 +2,7 @@
2
2
  * peaks standards migrate — .claude/rules/ tree thinning.
3
3
  * Slice: 2026-06-12-standards-migrate-claude-rules.
4
4
  *
5
- * The 1.x peaks-cli install copied a thick .claude/rules
5
+ * The 1.x peaks-loop install copied a thick .claude/rules
6
6
  * tree (skill-first / CLI-auxiliary / dogfood / commit-trailer
7
7
  * rules) into consumer projects. In 2.0, the canonical rules
8
8
  * live at .peaks/standards/ and every markdown file under
@@ -23,7 +23,7 @@
23
23
  */
24
24
  import { existsSync, mkdirSync, readdirSync, readFileSync, statSync, writeFileSync } from 'node:fs';
25
25
  import { join } from 'node:path';
26
- const POINTER_TEXT = (canonicalPath) => `# Canonical peaks-cli 2.0 rules live at: ${canonicalPath}\n# This file is a 2-line pointer. Edit the canonical file instead.\n`;
26
+ const POINTER_TEXT = (canonicalPath) => `# Canonical peaks-loop 2.0 rules live at: ${canonicalPath}\n# This file is a 2-line pointer. Edit the canonical file instead.\n`;
27
27
  function timestampSlug() {
28
28
  return new Date().toISOString().replace(/[:.]/g, '-');
29
29
  }
@@ -47,13 +47,13 @@ function isAlreadyPointer(filePath) {
47
47
  return false;
48
48
  try {
49
49
  const body = readFileSync(filePath, 'utf8');
50
- return body.includes('Canonical peaks-cli 2.0 rules live at:');
50
+ return body.includes('Canonical peaks-loop 2.0 rules live at:');
51
51
  }
52
52
  catch {
53
53
  return false;
54
54
  }
55
55
  }
56
- const CANONICAL_2_0_DEV_PREFERENCE = `# Peaks-Cli dev preference (2.0 canonical)
56
+ const CANONICAL_2_0_DEV_PREFERENCE = `# Peaks-Loop dev preference (2.0 canonical)
57
57
 
58
58
  > Project-local preference, captured from the 1.x install + re-rendered with the 2.0 vocabulary.
59
59
  > Scope: applies to every iteration, adjustment, fix, or tweak on this project.
@@ -61,7 +61,7 @@ const CANONICAL_2_0_DEV_PREFERENCE = `# Peaks-Cli dev preference (2.0 canonical)
61
61
 
62
62
  ## Rule 1 — Skill-first, CLI-auxiliary
63
63
 
64
- When designing or modifying a peaks-cli feature, default to the **skill-first** design. CLI commands are **invoked by the skill prompt** when they are the right primitive: a side effect that must be atomic, a gate that must be machine-enforced, a probe that needs structured JSON, or a backstop that prevents the LLM from skipping a step. Behaviour only an LLM in a skill prompt would use lives **in the relevant skill's SKILL.md**, not as a new CLI command. See \`.claude/rules/common/dev-preference.md\` for the decision template.
64
+ When designing or modifying a peaks-loop feature, default to the **skill-first** design. CLI commands are **invoked by the skill prompt** when they are the right primitive: a side effect that must be atomic, a gate that must be machine-enforced, a probe that needs structured JSON, or a backstop that prevents the LLM from skipping a step. Behaviour only an LLM in a skill prompt would use lives **in the relevant skill's SKILL.md**, not as a new CLI command. See \`.claude/rules/common/dev-preference.md\` for the decision template.
65
65
 
66
66
  ## Rule 2 — Dogfood on every adjustment
67
67
 
@@ -8,9 +8,9 @@
8
8
  * 2. required the LLM to invoke `peaks skill heartbeat:touch` and
9
9
  * `peaks skill presence:clear` on every turn;
10
10
  * 3. ended with an `External reference: https://github.com/affaan-m/...`
11
- * line that was peaks-cli-internal, not consumer-facing.
11
+ * line that was peaks-loop-internal, not consumer-facing.
12
12
  *
13
- * The replacement text matches the post-slice-025 peaks-cli repo's own
13
+ * The replacement text matches the post-slice-025 peaks-loop repo's own
14
14
  * `CLAUDE.md`: route the LLM through `peaks skill presence --json` and
15
15
  * render a compact status header when a valid skill is active. This
16
16
  * service is the deterministic in-place rewriter that brings existing
@@ -27,7 +27,7 @@
27
27
  * - File missing → `file: null`, no throw.
28
28
  * - Legacy block not present → `foundOldBlock: false`, no write.
29
29
  */
30
- export declare const NEW_TEMPLATE_TEXT = "Active Peaks-Cli skill presence: at the start of every response, run `peaks skill presence --json` to read the active skill marker. The CLI handles canonical-path resolution (`.peaks/_runtime/active-skill.json` with back-compat fallback to `.peaks/.active-skill.json`); do not read those files directly. When the response includes a valid skill name, display the compact status header: `Peaks-Cli Skill: <skill> | Peaks-Cli Gate: <gate> | Next: <one short action>`. Display the header on every turn while the CLI returns an active skill; omit when the CLI returns no active skill.";
30
+ export declare const NEW_TEMPLATE_TEXT = "Active Peaks-Loop skill presence: at the start of every response, run `peaks skill presence --json` to read the active skill marker. The CLI handles canonical-path resolution (`.peaks/_runtime/active-skill.json` with back-compat fallback to `.peaks/.active-skill.json`); do not read those files directly. When the response includes a valid skill name, display the compact status header: `Peaks-Loop Skill: <skill> | Peaks-Loop Gate: <gate> | Next: <one short action>`. Display the header on every turn while the CLI returns an active skill; omit when the CLI returns no active skill.";
31
31
  export type MigrateStandardsInput = {
32
32
  project: string;
33
33
  apply?: boolean;
@@ -10,9 +10,9 @@ import { isAbsolute, resolve } from 'node:path';
10
10
  * 2. required the LLM to invoke `peaks skill heartbeat:touch` and
11
11
  * `peaks skill presence:clear` on every turn;
12
12
  * 3. ended with an `External reference: https://github.com/affaan-m/...`
13
- * line that was peaks-cli-internal, not consumer-facing.
13
+ * line that was peaks-loop-internal, not consumer-facing.
14
14
  *
15
- * The replacement text matches the post-slice-025 peaks-cli repo's own
15
+ * The replacement text matches the post-slice-025 peaks-loop repo's own
16
16
  * `CLAUDE.md`: route the LLM through `peaks skill presence --json` and
17
17
  * render a compact status header when a valid skill is active. This
18
18
  * service is the deterministic in-place rewriter that brings existing
@@ -29,8 +29,8 @@ import { isAbsolute, resolve } from 'node:path';
29
29
  * - File missing → `file: null`, no throw.
30
30
  * - Legacy block not present → `foundOldBlock: false`, no write.
31
31
  */
32
- export const NEW_TEMPLATE_TEXT = 'Active Peaks-Cli skill presence: at the start of every response, run `peaks skill presence --json` to read the active skill marker. The CLI handles canonical-path resolution (`.peaks/_runtime/active-skill.json` with back-compat fallback to `.peaks/.active-skill.json`); do not read those files directly. When the response includes a valid skill name, display the compact status header: `Peaks-Cli Skill: <skill> | Peaks-Cli Gate: <gate> | Next: <one short action>`. Display the header on every turn while the CLI returns an active skill; omit when the CLI returns no active skill.';
33
- const LEGACY_BLOCK_OPENER_LINE = 'Peaks-Cli 心跳检测 (heartbeat check)';
32
+ export const NEW_TEMPLATE_TEXT = 'Active Peaks-Loop skill presence: at the start of every response, run `peaks skill presence --json` to read the active skill marker. The CLI handles canonical-path resolution (`.peaks/_runtime/active-skill.json` with back-compat fallback to `.peaks/.active-skill.json`); do not read those files directly. When the response includes a valid skill name, display the compact status header: `Peaks-Loop Skill: <skill> | Peaks-Loop Gate: <gate> | Next: <one short action>`. Display the header on every turn while the CLI returns an active skill; omit when the CLI returns no active skill.';
33
+ const LEGACY_BLOCK_OPENER_LINE = 'Peaks-Loop 心跳检测 (heartbeat check)';
34
34
  const LEGACY_BLOCK_CLOSER = 'External reference: https://github.com/affaan-m/everything-claude-code';
35
35
  const LEGACY_MARKER_FALLBACK = 'Do NOT skip step 3-5. The CLI heartbeat:touch command';
36
36
  const FORBIDDEN_LEGACY_STRINGS = [
@@ -152,7 +152,7 @@ export function migrateStandards(input) {
152
152
  applied: false,
153
153
  before: { lines: original.split('\n').length },
154
154
  after: null,
155
- nextActions: ['CLAUDE.md has no peaks-cli block; nothing to migrate']
155
+ nextActions: ['CLAUDE.md has no peaks-loop block; nothing to migrate']
156
156
  },
157
157
  warnings: []
158
158
  };
@@ -159,7 +159,7 @@ function renderClaudeMd(language, ctx) {
159
159
  '- Read `.claude/rules/common/security.md` before touching filesystem, user input, external calls, auth, or secrets.',
160
160
  `- Read .claude/rules/${language}/coding-style.md for language-specific standards when applicable.`,
161
161
  '',
162
- 'Active Peaks-Cli skill presence: at the start of every response, run `peaks skill presence --json` to read the active skill marker. The CLI handles canonical-path resolution (`.peaks/_runtime/active-skill.json` with back-compat fallback to `.peaks/.active-skill.json`); do not read those files directly. When the response includes a valid skill name, display the compact status header: `Peaks-Cli Skill: <skill> | Peaks-Cli Gate: <gate> | Next: <one short action>`. Display the header on every turn while the CLI returns an active skill; omit when the CLI returns no active skill.'
162
+ 'Active Peaks-Loop skill presence: at the start of every response, run `peaks skill presence --json` to read the active skill marker. The CLI handles canonical-path resolution (`.peaks/_runtime/active-skill.json` with back-compat fallback to `.peaks/.active-skill.json`); do not read those files directly. When the response includes a valid skill name, display the compact status header: `Peaks-Loop Skill: <skill> | Peaks-Loop Gate: <gate> | Next: <one short action>`. Display the header on every turn while the CLI returns an active skill; omit when the CLI returns no active skill.'
163
163
  ].join('\n');
164
164
  const stack = renderProjectStackSection(ctx);
165
165
  return stack === '' ? head : `${head}\n${stack}`;
@@ -0,0 +1,32 @@
1
+ import type { CodegraphExecutionResult } from '../codegraph/codegraph-service.js';
2
+ import type { UnderstandScanReport } from './understand-types.js';
3
+ import type { UnderstandGraphSummary } from './understand-scan-service.js';
4
+ /**
5
+ * Slice 2026-07-02-codegraph-ua-hybrid — envelope contract for the
6
+ * `peaks understand context` command. The service layer decides which
7
+ * evidence to include based on environment detection; the source field
8
+ * is the authoritative routing signal.
9
+ */
10
+ export type UnderstandContextSource = 'ua-only' | 'ua-missing-fallback-codegraph' | 'ua-and-codegraph-hybrid' | 'both-missing';
11
+ export type CodegraphContextBlock = {
12
+ invocation: {
13
+ subcommand: 'affected';
14
+ files: string[];
15
+ };
16
+ execution: CodegraphExecutionResult;
17
+ /** Parsed JSON from `codegraph affected --json` when exitCode === 0; null otherwise. */
18
+ payload: unknown;
19
+ parseError?: string;
20
+ };
21
+ export type UnderstandContextResult = {
22
+ projectRoot: string;
23
+ source: UnderstandContextSource;
24
+ ua?: {
25
+ scan: UnderstandScanReport;
26
+ summary?: UnderstandGraphSummary;
27
+ };
28
+ codegraph?: CodegraphContextBlock;
29
+ /** Wall-clock milliseconds spent on the slowest parallel branch. */
30
+ durationMs: number;
31
+ warnings: string[];
32
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,10 @@
1
+ import { type CodegraphProcessRunner } from '../codegraph/codegraph-service.js';
2
+ import type { UnderstandContextResult } from './hybrid-types.js';
3
+ export type BuildUnderstandContextOptions = {
4
+ projectRoot: string;
5
+ files?: string[];
6
+ sampleSize?: number;
7
+ artifactDir?: string;
8
+ codegraphRunner?: CodegraphProcessRunner;
9
+ };
10
+ export declare function buildUnderstandContext(options: BuildUnderstandContextOptions): Promise<UnderstandContextResult>;