peaks-loop 4.1.4 → 4.1.6

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 (294) hide show
  1. package/.claude-plugin/marketplace.json +7 -2
  2. package/CHANGELOG.md +148 -0
  3. package/README-en.md +47 -183
  4. package/README.md +24 -188
  5. package/dist/cli/cli-helpers.d.ts +20 -0
  6. package/dist/cli/cli-helpers.js +34 -0
  7. package/dist/cli/commands/_register.js +2 -0
  8. package/dist/cli/commands/best-practice-scan-command.d.ts +11 -6
  9. package/dist/cli/commands/best-practice-scan-command.js +35 -20
  10. package/dist/cli/commands/best-practice-scan-helpers.d.ts +47 -0
  11. package/dist/cli/commands/best-practice-scan-helpers.js +88 -5
  12. package/dist/cli/commands/best-practice-scan-lookup-results.d.ts +13 -0
  13. package/dist/cli/commands/best-practice-scan-lookup-results.js +237 -0
  14. package/dist/cli/commands/code-commands.d.ts +6 -4
  15. package/dist/cli/commands/code-commands.js +6 -4
  16. package/dist/cli/commands/code-gate-command.d.ts +5 -5
  17. package/dist/cli/commands/code-gate-command.js +49 -9
  18. package/dist/cli/commands/code-mode-gate-plan-command.d.ts +1 -1
  19. package/dist/cli/commands/code-mode-gate-plan-command.js +2 -2
  20. package/dist/cli/commands/core/memory-extract-command.js +10 -5
  21. package/dist/cli/commands/dispatch-cli-invocation-check.d.ts +108 -0
  22. package/dist/cli/commands/dispatch-cli-invocation-check.js +87 -0
  23. package/dist/cli/commands/dispatch-cli-invocation-scan.d.ts +66 -0
  24. package/dist/cli/commands/dispatch-cli-invocation-scan.js +162 -0
  25. package/dist/cli/commands/dispatch-command-spec.js +1 -1
  26. package/dist/cli/commands/dispatch-commands.js +12 -5
  27. package/dist/cli/commands/dispatch-isolation-lease.d.ts +1 -1
  28. package/dist/cli/commands/dispatch-isolation-lease.js +6 -53
  29. package/dist/cli/commands/dispatch-preflight.js +46 -0
  30. package/dist/cli/commands/dispatch-prompt-blocks.d.ts +1 -1
  31. package/dist/cli/commands/dispatch-prompt-composition.d.ts +7 -1
  32. package/dist/cli/commands/dispatch-prompt-composition.js +29 -7
  33. package/dist/cli/commands/dispatch-record-write.d.ts +1 -1
  34. package/dist/cli/commands/dispatch-tool-call.d.ts +1 -1
  35. package/dist/cli/commands/doc-commands.js +1 -1
  36. package/dist/cli/commands/feedback-commands-helpers.js +1 -1
  37. package/dist/cli/commands/final-review-prepare-command.js +22 -1
  38. package/dist/cli/commands/gate-commands-enforce.js +3 -3
  39. package/dist/cli/commands/hook-handle.js +41 -20
  40. package/dist/cli/commands/lint-commands.js +3 -1
  41. package/dist/cli/commands/loop-eval-capture-index.js +2 -4
  42. package/dist/cli/commands/openspec-command-shared.js +2 -2
  43. package/dist/cli/commands/perf-audit-commands.js +15 -5
  44. package/dist/cli/commands/project-commands.js +9 -6
  45. package/dist/cli/commands/race-commands.d.ts +15 -0
  46. package/dist/cli/commands/race-commands.js +65 -0
  47. package/dist/cli/commands/race-pilot-gate-record-command.d.ts +3 -0
  48. package/dist/cli/commands/race-pilot-gate-record-command.js +81 -0
  49. package/dist/cli/commands/request-command-options.d.ts +8 -0
  50. package/dist/cli/commands/request-commands.js +2 -0
  51. package/dist/cli/commands/request-init-command.js +67 -12
  52. package/dist/cli/commands/{vm-status-command.d.ts → request-retag-command.d.ts} +1 -1
  53. package/dist/cli/commands/request-retag-command.js +50 -0
  54. package/dist/cli/commands/request-show-command.d.ts +8 -0
  55. package/dist/cli/commands/request-show-command.js +14 -1
  56. package/dist/cli/commands/request-transition-command.js +12 -4
  57. package/dist/cli/commands/request-transition-failures.d.ts +14 -0
  58. package/dist/cli/commands/request-transition-failures.js +76 -7
  59. package/dist/cli/commands/request-transition-preflight.js +1 -1
  60. package/dist/cli/commands/scan-scope-commands.js +2 -2
  61. package/dist/cli/commands/security-audit-commands.js +26 -6
  62. package/dist/cli/commands/slice-decompose-artifacts.js +2 -1
  63. package/dist/cli/commands/verdict-aggregate-command.js +2 -1
  64. package/dist/cli/commands/workflow-gate-commands.js +4 -4
  65. package/dist/cli/commands/worktree-lease-gc-command.js +1 -1
  66. package/dist/cli/program.js +0 -2
  67. package/dist/services/artifacts/artifact-contract-block.d.ts +53 -0
  68. package/dist/services/artifacts/artifact-contract-block.js +231 -0
  69. package/dist/services/artifacts/artifact-prerequisites.d.ts +27 -19
  70. package/dist/services/artifacts/artifact-prerequisites.js +65 -135
  71. package/dist/services/artifacts/artifact-templates.d.ts +1 -1
  72. package/dist/services/artifacts/artifact-templates.js +17 -10
  73. package/dist/services/artifacts/prerequisite-checks.d.ts +87 -0
  74. package/dist/services/artifacts/prerequisite-checks.js +198 -0
  75. package/dist/services/artifacts/prerequisite-transition-event.d.ts +20 -0
  76. package/dist/services/artifacts/prerequisite-transition-event.js +27 -0
  77. package/dist/services/artifacts/rd-transition-gates.d.ts +33 -0
  78. package/dist/services/artifacts/rd-transition-gates.js +71 -0
  79. package/dist/services/artifacts/request-artifact-metadata.d.ts +31 -0
  80. package/dist/services/artifacts/request-artifact-metadata.js +44 -0
  81. package/dist/services/artifacts/request-artifact-service.d.ts +5 -0
  82. package/dist/services/artifacts/request-artifact-service.js +43 -69
  83. package/dist/services/artifacts/request-artifact-state-helpers.d.ts +21 -1
  84. package/dist/services/artifacts/request-artifact-state-helpers.js +34 -8
  85. package/dist/services/artifacts/request-retag-service.d.ts +68 -0
  86. package/dist/services/artifacts/request-retag-service.js +125 -0
  87. package/dist/services/artifacts/request-state-order.d.ts +38 -0
  88. package/dist/services/artifacts/request-state-order.js +99 -0
  89. package/dist/services/artifacts/request-type-demand.d.ts +44 -0
  90. package/dist/services/artifacts/request-type-demand.js +71 -0
  91. package/dist/services/audit/audit-goal-service.d.ts +7 -0
  92. package/dist/services/audit/enforcers/active-skill-resolver.d.ts +18 -0
  93. package/dist/services/audit/enforcers/active-skill-resolver.js +48 -1
  94. package/dist/services/audit/enforcers/code-ban.d.ts +11 -2
  95. package/dist/services/audit/enforcers/code-ban.js +21 -1
  96. package/dist/services/audit/red-line-catalog-p2-a-bee-runtime.d.ts +17 -0
  97. package/dist/services/audit/red-line-catalog-p2-a-bee-runtime.js +24 -7
  98. package/dist/services/audit-independent/handoff-missing-refusal.d.ts +26 -0
  99. package/dist/services/audit-independent/handoff-missing-refusal.js +109 -0
  100. package/dist/services/audit-independent/handoff-readers.d.ts +37 -0
  101. package/dist/services/audit-independent/handoff-readers.js +81 -0
  102. package/dist/services/audit-independent/index.d.ts +6 -1
  103. package/dist/services/audit-independent/index.js +6 -1
  104. package/dist/services/audit-independent/judged-declaration-build.d.ts +48 -0
  105. package/dist/services/audit-independent/judged-declaration-build.js +73 -0
  106. package/dist/services/audit-independent/judged-declaration-check.d.ts +80 -0
  107. package/dist/services/audit-independent/judged-declaration-check.js +216 -0
  108. package/dist/services/audit-independent/judged-declaration.d.ts +94 -0
  109. package/dist/services/audit-independent/judged-declaration.js +218 -0
  110. package/dist/services/audit-independent/perf-audit-service.js +12 -14
  111. package/dist/services/audit-independent/security-audit-artifact.d.ts +28 -0
  112. package/dist/services/audit-independent/security-audit-artifact.js +90 -0
  113. package/dist/services/audit-independent/security-audit-service.d.ts +6 -53
  114. package/dist/services/audit-independent/security-audit-service.js +34 -178
  115. package/dist/services/capability-guard-runner/contracts/J05.js +60 -14
  116. package/dist/services/codegraph/codegraph-index-integrity.js +2 -0
  117. package/dist/services/context/build-dispatch-system-prompt.d.ts +8 -12
  118. package/dist/services/context/build-dispatch-system-prompt.js +18 -18
  119. package/dist/services/context/collector.js +5 -1
  120. package/dist/services/context/post-compact-reinjection.js +1 -1
  121. package/dist/services/dispatch/active-dispatch-index.d.ts +36 -0
  122. package/dist/services/dispatch/active-dispatch-index.js +118 -0
  123. package/dist/services/dispatch/batch-counter.js +1 -2
  124. package/dist/services/dispatch/dispatch-record-writer.d.ts +29 -16
  125. package/dist/services/dispatch/dispatch-record-writer.js +58 -100
  126. package/dist/services/dispatch/dispatch-sub-agent.js +1 -1
  127. package/dist/services/dispatch/karpathy-block.d.ts +55 -0
  128. package/dist/services/dispatch/karpathy-block.js +101 -0
  129. package/dist/services/dispatch/ledger-reaper.d.ts +80 -0
  130. package/dist/services/dispatch/ledger-reaper.js +131 -0
  131. package/dist/services/dispatch/test-tool-detection.d.ts +17 -1
  132. package/dist/services/dispatch/test-tool-detection.js +12 -1
  133. package/dist/services/evidence/evidence-generator.js +23 -12
  134. package/dist/services/feedback/feedback-promotion-service.d.ts +8 -11
  135. package/dist/services/feedback/feedback-promotion-service.js +30 -35
  136. package/dist/services/feedback/promotion-artifact-json-evidence.d.ts +18 -0
  137. package/dist/services/feedback/promotion-artifact-missing.d.ts +22 -0
  138. package/dist/services/feedback/promotion-artifact-missing.js +63 -0
  139. package/dist/services/final-review/final-review-contract.d.ts +95 -4
  140. package/dist/services/final-review/final-review-contract.js +64 -0
  141. package/dist/services/final-review/final-review-delivery.d.ts +13 -0
  142. package/dist/services/final-review/final-review-delivery.js +26 -12
  143. package/dist/services/final-review/final-review-evidence-collect.js +8 -53
  144. package/dist/services/final-review/final-review-evidence-records.d.ts +21 -0
  145. package/dist/services/final-review/final-review-evidence-records.js +67 -0
  146. package/dist/services/final-review/final-review-evidence-sources.d.ts +22 -0
  147. package/dist/services/final-review/final-review-evidence-sources.js +28 -4
  148. package/dist/services/final-review/final-review-prompt.js +19 -6
  149. package/dist/services/final-review/final-review-runner.js +5 -0
  150. package/dist/services/final-review/final-review-service.d.ts +2 -2
  151. package/dist/services/final-review/index.d.ts +1 -1
  152. package/dist/services/final-review/pre-post-diff.d.ts +2 -75
  153. package/dist/services/final-review/pre-post-diff.js +60 -59
  154. package/dist/services/hooks/pre-tool-code-gate.d.ts +7 -1
  155. package/dist/services/hooks/pre-tool-code-gate.js +21 -2
  156. package/dist/services/hooks/worktree-authorization-gate.js +6 -31
  157. package/dist/services/hooks/worktree-refusal-messages.d.ts +74 -0
  158. package/dist/services/hooks/worktree-refusal-messages.js +102 -0
  159. package/dist/services/lint/eslint-runner-support.d.ts +1 -1
  160. package/dist/services/lint/eslint-runner-support.js +2 -1
  161. package/dist/services/lint/eslint-runner-types.d.ts +8 -0
  162. package/dist/services/lint/eslint-runner.js +17 -4
  163. package/dist/services/llm/anthropic-runner.js +24 -7
  164. package/dist/services/loop/loop-observability.d.ts +39 -0
  165. package/dist/services/loop/loop-observability.js +55 -0
  166. package/dist/services/loop/monotonic-guard.js +6 -9
  167. package/dist/services/loop/monotonic-runner.js +8 -7
  168. package/dist/services/loop/run-driver.js +18 -22
  169. package/dist/services/memory/project-memory-service/index/kind-dispatch.js +14 -1
  170. package/dist/services/memory/project-memory-service/index/project-memory-plan-exec.js +13 -2
  171. package/dist/services/memory/project-memory-service/index.d.ts +2 -2
  172. package/dist/services/memory/project-memory-service/index.js +1 -1
  173. package/dist/services/memory/project-memory-service/parsers/frontmatter-parse.d.ts +36 -0
  174. package/dist/services/memory/project-memory-service/parsers/frontmatter-parse.js +48 -2
  175. package/dist/services/memory/project-memory-service/parsers/markdown-pure.d.ts +23 -1
  176. package/dist/services/memory/project-memory-service/parsers/markdown-pure.js +37 -0
  177. package/dist/services/memory/project-memory-service/types.d.ts +32 -0
  178. package/dist/services/observability/observability-service.d.ts +7 -0
  179. package/dist/services/observability/observability-service.js +2 -1
  180. package/dist/services/openspec/coverage-evidence-reader.d.ts +9 -9
  181. package/dist/services/openspec/coverage-evidence-reader.js +8 -8
  182. package/dist/services/openspec/openspec-archive-service.d.ts +1 -1
  183. package/dist/services/openspec/openspec-archive-service.js +6 -6
  184. package/dist/services/prd/gate-evidence-derivation.d.ts +4 -3
  185. package/dist/services/prd/gate-evidence-derivation.js +4 -3
  186. package/dist/services/qa/bdd-test-style-verifier.js +22 -8
  187. package/dist/services/race/gate2-evaluator.d.ts +58 -0
  188. package/dist/services/race/gate2-evaluator.js +111 -0
  189. package/dist/services/race/gate2-policy.d.ts +17 -0
  190. package/dist/services/race/gate2-policy.js +31 -0
  191. package/dist/services/race/lane-phase.d.ts +19 -0
  192. package/dist/services/race/lane-phase.js +113 -0
  193. package/dist/services/race/pilot-gate-store.d.ts +67 -0
  194. package/dist/services/race/pilot-gate-store.js +227 -0
  195. package/dist/services/scan/file-size-baseline.d.ts +33 -0
  196. package/dist/services/scan/file-size-baseline.js +173 -0
  197. package/dist/services/scan/file-size-scan.d.ts +35 -3
  198. package/dist/services/scan/file-size-scan.js +63 -42
  199. package/dist/services/scan/type-corroboration.d.ts +32 -0
  200. package/dist/services/scan/type-corroboration.js +51 -0
  201. package/dist/services/scan/type-sanity-service.d.ts +14 -0
  202. package/dist/services/scan/type-sanity-service.js +23 -22
  203. package/dist/services/security/safe-settings-path.d.ts +5 -0
  204. package/dist/services/security/safe-settings-path.js +64 -8
  205. package/dist/services/skill/resume-detector.js +11 -11
  206. package/dist/services/skills/hooks-codegate-superpowers.d.ts +5 -6
  207. package/dist/services/skills/hooks-codegate-superpowers.js +7 -8
  208. package/dist/services/skills/hooks-settings-service.d.ts +1 -1
  209. package/dist/services/skills/hooks-settings-service.js +1 -1
  210. package/dist/services/skills/presence-lease-order.d.ts +13 -0
  211. package/dist/services/skills/presence-lease-order.js +24 -0
  212. package/dist/services/skills/skill-conformance-service.js +1 -0
  213. package/dist/services/skills/skill-statusline-service.js +4 -7
  214. package/dist/services/slice/slice-check-service.js +8 -8
  215. package/dist/services/workflow/pipeline-verify-gate-support.d.ts +24 -8
  216. package/dist/services/workflow/pipeline-verify-gate-support.js +34 -39
  217. package/dist/services/workflow/pipeline-verify-qa-phase.d.ts +102 -0
  218. package/dist/services/workflow/pipeline-verify-qa-phase.js +176 -0
  219. package/dist/services/workflow/pipeline-verify-service.js +27 -28
  220. package/dist/services/workflow/request-type-resolution.d.ts +99 -0
  221. package/dist/services/workflow/request-type-resolution.js +130 -0
  222. package/dist/services/workflow/workflow-skip-service.d.ts +1 -20
  223. package/dist/services/workflow/workflow-skip-service.js +22 -25
  224. package/dist/services/workflow/workflow-state-store.d.ts +9 -0
  225. package/dist/services/workflow/workflow-state-store.js +26 -1
  226. package/dist/services/workspace/claude-settings-retirements.d.ts +54 -0
  227. package/dist/services/workspace/claude-settings-retirements.js +112 -0
  228. package/dist/services/workspace/claude-settings-template-merge.d.ts +35 -15
  229. package/dist/services/workspace/claude-settings-template-merge.js +33 -53
  230. package/dist/services/workspace/claude-settings-template.d.ts +62 -12
  231. package/dist/services/workspace/claude-settings-template.js +58 -58
  232. package/dist/services/workspace/migrate-1-4-1-service.js +3 -0
  233. package/dist/services/workspace/reconcile-service.js +0 -1
  234. package/dist/shared/incrementing-number.d.ts +33 -2
  235. package/dist/shared/incrementing-number.js +72 -3
  236. package/package.json +5 -7
  237. package/skills/bee/peaks-perf-audit/SKILL.md +1 -1
  238. package/skills/bee/peaks-prd/SKILL.md +4 -3
  239. package/skills/bee/peaks-qa/SKILL.md +1 -1
  240. package/skills/bee/peaks-qa/references/qa-sub-agent-dispatch.md +2 -2
  241. package/skills/bee/peaks-qa/references/qa-transition-gates.md +1 -1
  242. package/skills/bee/peaks-rd/SKILL.md +2 -2
  243. package/skills/bee/peaks-rd/references/rd-fanout-contracts.md +1 -1
  244. package/skills/bee/peaks-rd/references/rd-sub-agent-dispatch.md +8 -4
  245. package/skills/bee/peaks-rd/references/rd-transition-gates.md +3 -3
  246. package/skills/bee/peaks-rd/references/v2-12-fanout-collapse.md +2 -2
  247. package/skills/bee/peaks-rd/references/writing-handoff-frontmatter.md +1 -1
  248. package/skills/bee/peaks-reviewer/SKILL.md +1 -1
  249. package/skills/bee/peaks-sc/SKILL.md +1 -1
  250. package/skills/bee/peaks-security-audit/SKILL.md +10 -2
  251. package/skills/bee/peaks-txt/SKILL.md +4 -3
  252. package/skills/bee/peaks-ui/SKILL.md +3 -3
  253. package/skills/peaks-audit/SKILL.md +29 -1
  254. package/skills/peaks-code/SKILL.md +37 -17
  255. package/skills/peaks-code/references/fast-lane-norm.md +42 -0
  256. package/skills/peaks-code/references/fast-mode.md +3 -2
  257. package/skills/peaks-code/references/local-artifact-workspace.md +3 -3
  258. package/skills/peaks-code/references/micro-cycle.md +3 -3
  259. package/skills/peaks-code/references/resume-detection.md +1 -1
  260. package/skills/peaks-code/references/runbook.md +12 -6
  261. package/skills/peaks-code/references/step-11-memory-sediment.md +4 -0
  262. package/skills/peaks-code/references/sub-agent-dispatch.md +1 -1
  263. package/skills/peaks-code/references/swarm-dispatch-contract.md +40 -16
  264. package/skills/peaks-code/references/workflow-gates-and-types.md +6 -6
  265. package/skills/peaks-code/references/worktree-governance.md +4 -4
  266. package/skills/peaks-content/SKILL.md +1 -1
  267. package/skills/peaks-doctor/SKILL.md +1 -1
  268. package/skills/peaks-final-review/SKILL.md +31 -11
  269. package/skills/peaks-ide/SKILL.md +1 -1
  270. package/skills/peaks-issue-fix-orchestrator/SKILL.md +1 -1
  271. package/skills/peaks-race-code/SKILL.md +185 -0
  272. package/skills/peaks-resume/SKILL.md +1 -1
  273. package/skills/peaks-slice-decompose/SKILL.md +1 -1
  274. package/skills/peaks-solo/SKILL.md +1 -1
  275. package/skills/peaks-sop/SKILL.md +1 -1
  276. package/skills/peaks-status/SKILL.md +1 -1
  277. package/skills/peaks-test/SKILL.md +7 -4
  278. package/dist/cli/commands/vm-command-shared.d.ts +0 -23
  279. package/dist/cli/commands/vm-command-shared.js +0 -23
  280. package/dist/cli/commands/vm-commands.d.ts +0 -3
  281. package/dist/cli/commands/vm-commands.js +0 -45
  282. package/dist/cli/commands/vm-hypervisor-probe.d.ts +0 -27
  283. package/dist/cli/commands/vm-hypervisor-probe.js +0 -78
  284. package/dist/cli/commands/vm-hypervisor-runtime.d.ts +0 -15
  285. package/dist/cli/commands/vm-hypervisor-runtime.js +0 -64
  286. package/dist/cli/commands/vm-release-command.d.ts +0 -5
  287. package/dist/cli/commands/vm-release-command.js +0 -101
  288. package/dist/cli/commands/vm-spawn-command.d.ts +0 -5
  289. package/dist/cli/commands/vm-spawn-command.js +0 -177
  290. package/dist/cli/commands/vm-status-command.js +0 -50
  291. package/dist/services/audit/enforcers/lint-peaks-skill-runtime.d.ts +0 -23
  292. package/dist/services/audit/enforcers/lint-peaks-skill-runtime.js +0 -64
  293. package/dist/services/vm/vm-lease.d.ts +0 -40
  294. package/dist/services/vm/vm-lease.js +0 -160
@@ -1,27 +1,81 @@
1
1
  import { createRequestArtifact, VALID_REQUEST_TYPES } from '../../services/artifacts/request-artifact-service.js';
2
2
  import { parseRole, parseRequestType, VALID_ROLES } from './request-format-helpers.js';
3
3
  import { fail, ok } from 'peaks-loop-shared/result';
4
- import { addJsonOption, getErrorMessage, printResult } from '../cli-helpers.js';
4
+ import { addJsonOption, getErrorMessage, printResult, printableWarningText } from '../cli-helpers.js';
5
+ import { isUnsafePathInput } from '../../shared/path-safety.js';
6
+ import { getCurrentSessionId } from '../../services/skills/skill-presence-service.js';
5
7
  const INIT_DESCRIPTION = 'Create the per-request artifact template for a Peaks role (dry-run by default)';
6
8
  const INIT_ID_HELP = 'request id, e.g. 2026-05-23-add-foo. With --apply, also pre-creates the canonical change-id scope dir at .peaks/_runtime/change/<id>/ so sub-agents never write .peaks/_runtime/<id>/ at top level.';
7
9
  const INIT_PROJECT_HELP = 'target project root';
8
- const INIT_SESSION_HELP = 'override the default date-stamped session id';
10
+ const INIT_SESSION_HELP = 'explicit session id (default: the active session recorded in .peaks/_runtime/session.json)';
9
11
  const INIT_APPLY_HELP = 'write the artifact file (default: preview only)';
10
12
  const INIT_CALLER_ID_HELP = 'Override the caller id for this invocation (D4 priority: flag beats env beats platform fallback). The resolved callerId is stamped on the artifact body and surfaced in the response envelope.';
11
13
  const CALLER_ID_INVALID_HINTS = [
12
14
  'Set --caller-id to a value matching ^[a-zA-Z0-9._-]{1,200}$',
13
15
  'Or set PEAKS_CALLER_ID env var (or CLAUDE_CODE_SESSION_ID for Claude Code)'
14
16
  ];
15
- function failInitSessionIdRequired(io, options) {
16
- printResult(io, fail('request.init', 'SESSION_ID_REQUIRED', '--session-id is required: the CLI writes envelopes only to .peaks/_runtime/<sessionId>/... (one-axis layout)', { role: options.role, requestId: options.id }, ['Re-run with --session-id <sid>', 'Or run `peaks workspace init` to create a session first']), options.json);
17
+ const INIT_SESSION_HINTS = [
18
+ 'Re-run with --session-id <sid>',
19
+ 'Or run `peaks workspace init` to create a session first'
20
+ ];
21
+ function initSessionProblemMessage(problem) {
22
+ if (problem === 'blank') {
23
+ return '--session-id was passed but is blank. Give it a session id, or omit the flag to use the session recorded in .peaks/_runtime/session.json';
24
+ }
25
+ if (problem === 'malformed') {
26
+ return 'the session id recorded in .peaks/_runtime/session.json is not usable: it must be one printable path segment, because the artifact is scoped to a directory named after it. Pass --session-id, or re-run `peaks workspace init`';
27
+ }
28
+ return 'no session id: pass --session-id, or run inside a workspace that records one in .peaks/_runtime/session.json (the CLI writes envelopes only to .peaks/_runtime/<sessionId>/..., one-axis layout)';
29
+ }
30
+ function failInitSession(io, options, problem) {
31
+ printResult(io, fail('request.init', 'SESSION_ID_REQUIRED', initSessionProblemMessage(problem), { role: options.role, requestId: options.id }, INIT_SESSION_HINTS), options.json);
17
32
  process.exitCode = 1;
18
33
  }
34
+ /**
35
+ * The session id is used verbatim as ONE directory name under `.peaks/_runtime/`,
36
+ * so a usable one is a single printable path segment. `isUnsafePathInput` covers
37
+ * `.`/`..`, separators, drive/UNC/URL shapes — and NOT the C0/C1 control
38
+ * characters, so a recorded id carrying a newline would be accepted and would
39
+ * forge a line in the preview and in the artifact body's `session:` field.
40
+ * `printableWarningText` is the canonical control-character check; a value equal
41
+ * to its printable form carries none.
42
+ */
43
+ function isUsableSessionSegment(value) {
44
+ return !isUnsafePathInput(value) && printableWarningText(value) === value;
45
+ }
46
+ /**
47
+ * The session id the artifact must land under. An explicit `--session-id` wins;
48
+ * otherwise read the workspace's active session from
49
+ * `.peaks/_runtime/session.json` — the source `peaks sub-agent dispatch` and
50
+ * `peaks skill presence` already read for this same id. The caller refuses
51
+ * rather than writing under a placeholder directory; unlike dispatch, this
52
+ * command never falls back to `'unknown-sid'`, because it writes files.
53
+ *
54
+ * A SUPPLIED-but-blank flag is its own problem, not an omission: silently
55
+ * substituting the workspace id would hide a caller mistake (an unset variable
56
+ * expanding to empty would quietly target a different session), and this is the
57
+ * behaviour the flag had before the fallback existed.
58
+ *
59
+ * Only the fallback value is shape-checked here. A value passed via
60
+ * `--session-id` flows downstream exactly as it did before, so a caller who
61
+ * passes that flag sees no change.
62
+ */
63
+ function resolveInitSessionId(options) {
64
+ if (options.sessionId !== undefined) {
65
+ const explicit = options.sessionId.trim();
66
+ return explicit.length === 0 ? { problem: 'blank' } : { id: explicit };
67
+ }
68
+ const recorded = getCurrentSessionId(options.project);
69
+ if (recorded === null)
70
+ return { problem: 'absent' };
71
+ return isUsableSessionSegment(recorded) ? { id: recorded } : { problem: 'malformed' };
72
+ }
19
73
  function buildInitServiceOptions(options, sessionId) {
20
- // One-axis layout: --session-id is REQUIRED. The on-disk root
21
- // is always `.peaks/_runtime/<sessionId>/<role>/...`. The user
22
- // has forbidden the `.peaks/_runtime/<id>/` root layout — without an
23
- // explicit session id, we cannot guarantee the artifact lands
24
- // under `_runtime/`. See
74
+ // One-axis layout: the on-disk root is always
75
+ // `.peaks/_runtime/<sessionId>/<role>/...`, and the session id arrives
76
+ // already resolved (`resolveInitSessionId`) — the caller refuses when it
77
+ // could not be. The user has forbidden the `.peaks/_runtime/<id>/` root
78
+ // layout. See
25
79
  // `.peaks/memory/2026-06-21-peaks-request-session-id-leaks-into-change-id.md`.
26
80
  const serviceOptions = {
27
81
  role: options.role,
@@ -66,11 +120,12 @@ async function resolveInitCallerId(io, options) {
66
120
  }
67
121
  async function runRequestInit(options, io) {
68
122
  try {
69
- if (options.sessionId === undefined || options.sessionId.trim().length === 0) {
70
- failInitSessionIdRequired(io, options);
123
+ const resolved = resolveInitSessionId(options);
124
+ if (resolved.id === undefined) {
125
+ failInitSession(io, options, resolved.problem);
71
126
  return;
72
127
  }
73
- const serviceOptions = buildInitServiceOptions(options, options.sessionId);
128
+ const serviceOptions = buildInitServiceOptions(options, resolved.id);
74
129
  const callerId = await resolveInitCallerId(io, options);
75
130
  if (callerId === null)
76
131
  return;
@@ -1,3 +1,3 @@
1
1
  import type { Command } from 'commander';
2
2
  import { type ProgramIO } from '../cli-helpers.js';
3
- export declare function registerVmStatusCommand(vm: Command, io: ProgramIO): void;
3
+ export declare function registerRequestRetagCommand(request: Command, io: ProgramIO): void;
@@ -0,0 +1,50 @@
1
+ import { retagRequestArtifact, describeRetag } from '../../services/artifacts/request-retag-service.js';
2
+ import { VALID_REQUEST_TYPES } from '../../services/artifacts/request-artifact-service.js';
3
+ import { parseRequestType, parseRole, VALID_ROLES } from './request-format-helpers.js';
4
+ import { fail, ok } from 'peaks-loop-shared/result';
5
+ import { addJsonOption, getErrorMessage, printResult } from '../cli-helpers.js';
6
+ const RETAG_DESCRIPTION = "Set a request artifact's type, replacing whatever it currently records. Reports the prerequisite table the new type selects and any of its artifacts that are not on disk yet.";
7
+ const RETAG_REQUEST_ID_HELP = 'request id, e.g. 2026-05-23-add-foo';
8
+ const RETAG_TYPE_HELP = `request type (${VALID_REQUEST_TYPES.join(' | ')})`;
9
+ const RETAG_PROJECT_HELP = 'target project root';
10
+ /**
11
+ * Required, unlike the read verbs' optional flag. `showRequestArtifact` resolves
12
+ * the first session holding a matching rid when none is given, which is a fine
13
+ * way to READ and a way to WRITE the wrong artifact — so this verb names its
14
+ * target or does nothing.
15
+ */
16
+ const RETAG_SESSION_HELP = 'session id holding the artifact to retag (required)';
17
+ async function runRequestRetag(requestId, options, io) {
18
+ try {
19
+ const result = await retagRequestArtifact({
20
+ projectRoot: options.project,
21
+ role: options.role,
22
+ requestId,
23
+ requestType: options.type,
24
+ sessionId: options.sessionId
25
+ });
26
+ if (result === null) {
27
+ printResult(io, fail('request.retag', 'REQUEST_NOT_FOUND', `No artifact found for role=${options.role} requestId=${requestId}`, { role: options.role, requestId }, ['Verify the request id, role, and session id']), options.json);
28
+ process.exitCode = 1;
29
+ return;
30
+ }
31
+ printResult(io, ok('request.retag', result, describeRetag(result)), options.json);
32
+ }
33
+ catch (error) {
34
+ printResult(io, fail('request.retag', 'REQUEST_RETAG_FAILED', getErrorMessage(error), {
35
+ role: options.role,
36
+ requestId
37
+ }), options.json);
38
+ process.exitCode = 1;
39
+ }
40
+ }
41
+ export function registerRequestRetagCommand(request, io) {
42
+ addJsonOption(request
43
+ .command('retag')
44
+ .description(RETAG_DESCRIPTION)
45
+ .argument('<request-id>', RETAG_REQUEST_ID_HELP)
46
+ .requiredOption('--role <role>', `target role (${VALID_ROLES.join(' | ')})`, parseRole)
47
+ .requiredOption('--type <type>', RETAG_TYPE_HELP, parseRequestType)
48
+ .requiredOption('--project <path>', RETAG_PROJECT_HELP)
49
+ .requiredOption('--session-id <session>', RETAG_SESSION_HELP)).action((requestId, options) => runRequestRetag(requestId, options, io));
50
+ }
@@ -1,3 +1,11 @@
1
1
  import type { Command } from 'commander';
2
+ import { type ShowRequestArtifactResult } from '../../services/artifacts/request-artifact-service.js';
2
3
  import { type ProgramIO } from '../cli-helpers.js';
4
+ /**
5
+ * The type a `request show` reports is the EFFECTIVE one: an artifact that
6
+ * records no type still reads as `feature`, and a reader who cannot tell that
7
+ * from a chosen `feature` cannot tell which prerequisite table the next gate
8
+ * will apply. The field says which; this line says it in words.
9
+ */
10
+ export declare function typeProvenanceWarning(result: ShowRequestArtifactResult): string[];
3
11
  export declare function registerRequestShowCommand(request: Command, io: ProgramIO): void;
@@ -21,6 +21,19 @@ function buildShowPayload(result, options) {
21
21
  const transformed = applyPerArtifactFormat(result, override ?? format);
22
22
  return transformed === result ? { ...result, format } : transformed;
23
23
  }
24
+ /**
25
+ * The type a `request show` reports is the EFFECTIVE one: an artifact that
26
+ * records no type still reads as `feature`, and a reader who cannot tell that
27
+ * from a chosen `feature` cannot tell which prerequisite table the next gate
28
+ * will apply. The field says which; this line says it in words.
29
+ */
30
+ export function typeProvenanceWarning(result) {
31
+ if (result.requestTypeSource !== 'default')
32
+ return [];
33
+ return [
34
+ `request type '${result.requestType}' is the DEFAULT — this artifact records no type, so the '${result.requestType}' prerequisite table applies. Set one with: peaks request retag <request-id> --role ${result.role} --type <type> --project <path>`
35
+ ];
36
+ }
24
37
  async function runRequestShow(requestId, options, io) {
25
38
  try {
26
39
  const showOptions = {
@@ -36,7 +49,7 @@ async function runRequestShow(requestId, options, io) {
36
49
  failShowNotFound(io, options, requestId);
37
50
  return;
38
51
  }
39
- printResult(io, ok('request.show', buildShowPayload(result, options)), options.json);
52
+ printResult(io, ok('request.show', buildShowPayload(result, options), typeProvenanceWarning(result)), options.json);
40
53
  }
41
54
  catch (error) {
42
55
  printResult(io, fail('request.show', 'REQUEST_SHOW_FAILED', getErrorMessage(error), { role: options.role, requestId }, ['Check role, request id, and project path before retrying']), options.json);
@@ -1,9 +1,9 @@
1
1
  import { transitionRequestArtifact } from '../../services/artifacts/request-artifact-service.js';
2
2
  import { parseRole, parseStateForRole, VALID_ROLES } from './request-format-helpers.js';
3
3
  import { fail, ok } from 'peaks-loop-shared/result';
4
- import { addJsonOption, printResult } from '../cli-helpers.js';
4
+ import { addJsonOption, printableWarningText, printResult } from '../cli-helpers.js';
5
5
  import { runTransitionPreflight } from './request-transition-preflight.js';
6
- import { reportTransitionFailure } from './request-transition-failures.js';
6
+ import { reportTransitionFailure, softWarningExpiryClause } from './request-transition-failures.js';
7
7
  import { buildPrdHandoffResult, collectQaHandoffHooks, preCompactNote } from './request-transition-hooks.js';
8
8
  const TRANSITION_DESCRIPTION = 'Move a per-request artifact to a new state defined by its role state machine';
9
9
  const TRANSITION_REQUEST_ID_HELP = 'request id, e.g. 2026-05-23-add-foo';
@@ -11,7 +11,7 @@ const TRANSITION_STATE_HELP = 'new state name; allowed values depend on role';
11
11
  const TRANSITION_PROJECT_HELP = 'target project root';
12
12
  const TRANSITION_SESSION_HELP = 'restrict to a specific session id';
13
13
  const TRANSITION_REASON_HELP = 'reason appended as a transition note; required when --allow-incomplete is set';
14
- const TRANSITION_ALLOW_INCOMPLETE_HELP = 'bypass artifact prerequisite checks; requires --reason and records the bypass in the artifact';
14
+ const TRANSITION_ALLOW_INCOMPLETE_HELP = 'bypass the prerequisite, lint, file-size and state-order checks; requires --reason and records the bypass in the artifact';
15
15
  const TRANSITION_CONFIRM_HELP = 'skip the confirmation gate (for non-interactive / LLM contexts)';
16
16
  const TRANSITION_FORCE_CONFIRM_HELP = 'bypass mode-enforced confirmation (use with caution)';
17
17
  function buildTransitionOptions(requestId, role, newState, options) {
@@ -71,7 +71,15 @@ function printTransitionResult(io, options, result, hooks) {
71
71
  codegraphRefresh: hooks.codegraphRefresh
72
72
  }, [
73
73
  ...(note === null ? [] : [note]),
74
- ...(hooks.codegraphWarning === null ? [] : [hooks.codegraphWarning])
74
+ ...(hooks.codegraphWarning === null ? [] : [hooks.codegraphWarning]),
75
+ // A soft-passed prerequisite is a warning, not a silent pass: the
76
+ // envelope carries it (and `printResult` puts it on stderr for a human
77
+ // run). `data.prerequisiteWarnings` holds the structured entries.
78
+ // `softWarningExpiryClause` adds the one thing the entry cannot say
79
+ // without `message` moving: whether the window it names has closed.
80
+ ...(result.prerequisiteWarnings ?? []).map((warning) => `Soft prerequisite (not enforced): ${printableWarningText(warning.path)} ` +
81
+ `[${printableWarningText(warning.code)}] — ${printableWarningText(warning.message)}` +
82
+ softWarningExpiryClause(warning))
75
83
  ]), options.json);
76
84
  }
77
85
  async function runRequestTransition(requestId, options, io) {
@@ -1,5 +1,19 @@
1
1
  import { type ProgramIO } from '../cli-helpers.js';
2
2
  import type { RequestTransitionOptions } from './request-command-options.js';
3
+ /**
4
+ * The clause a soft-pass warning gains once its back-compat window has closed.
5
+ * It renders the `expiredWindow` the resolver set (the release the table
6
+ * declared, plus the build it was compared against) and is empty while the
7
+ * window is open — an open window is already the future tense the warning's own
8
+ * message uses, so it needs no clause.
9
+ *
10
+ * Shared with `printTransitionResult` in `request-transition-command.ts`: the
11
+ * success arm and this refusal arm render one fact one way, so an operator who
12
+ * sees the same soft pass through either arm reads the same sentence.
13
+ */
14
+ export declare function softWarningExpiryClause(warning: {
15
+ expiredWindow?: string;
16
+ }): string;
3
17
  /**
4
18
  * Map a thrown transition error to its envelope. `InvalidArgumentError` is
5
19
  * re-thrown: Commander raises it for an unparsable `--state`, and swallowing it
@@ -4,9 +4,27 @@
4
4
  // readable and every branch keeps setting `process.exitCode = 1`.
5
5
  import { InvalidArgumentError } from 'commander';
6
6
  import { PrerequisitesNotSatisfiedError, LintGateError, TypeSanityViolationError, FileSizeViolationError } from '../../services/artifacts/request-artifact-service.js';
7
+ import { StateOrderViolationError } from '../../services/artifacts/request-state-order.js';
8
+ import { TypeCorroborationViolationError } from '../../services/artifacts/rd-transition-gates.js';
7
9
  import { ConfirmationRequiredError } from '../../services/mode/mode-enforcement.js';
8
10
  import { fail } from 'peaks-loop-shared/result';
9
- import { getErrorMessage, printResult } from '../cli-helpers.js';
11
+ import { getErrorMessage, printableWarningText, printResult } from '../cli-helpers.js';
12
+ /**
13
+ * The clause a soft-pass warning gains once its back-compat window has closed.
14
+ * It renders the `expiredWindow` the resolver set (the release the table
15
+ * declared, plus the build it was compared against) and is empty while the
16
+ * window is open — an open window is already the future tense the warning's own
17
+ * message uses, so it needs no clause.
18
+ *
19
+ * Shared with `printTransitionResult` in `request-transition-command.ts`: the
20
+ * success arm and this refusal arm render one fact one way, so an operator who
21
+ * sees the same soft pass through either arm reads the same sentence.
22
+ */
23
+ export function softWarningExpiryClause(warning) {
24
+ return warning.expiredWindow === undefined
25
+ ? ''
26
+ : ` — past expiry: ${printableWarningText(warning.expiredWindow)}`;
27
+ }
10
28
  function reportPrerequisitesFailure(io, options, error) {
11
29
  // The `warnings` list is surfaced inside the 1-minor-release back-compat
12
30
  // window (e.g. MUT_REPORT) so the operator sees both the hard-blocked
@@ -19,17 +37,54 @@ function reportPrerequisitesFailure(io, options, error) {
19
37
  missing: error.missing,
20
38
  warnings: error.warnings
21
39
  }, [
22
- ...error.missing.map((entry) => `Produce ${entry.path}: ${entry.description}`),
23
- ...error.warnings.map((w) => `Soft-blocked (v2.13.3 back-compat window): ${w.path} — ${w.message}`),
24
- 'Once every required artifact exists, rerun this transition.',
40
+ // `Satisfy`, not `Produce`: a `missing` entry is an unmet REQUIREMENT, not
41
+ // necessarily an absent file. A present artifact refused for the judged
42
+ // declaration it does not carry was reported as one to "Produce", and a
43
+ // producer that did exactly that changed nothing.
44
+ ...error.missing.map((entry) => `Satisfy ${entry.path}: ${entry.description}`),
45
+ // Sanitised for the same reason the success branch sanitises: a
46
+ // `gateEvidence.<key>` warning can carry a control character decoded out
47
+ // of the handoff frontmatter, and `printResult` puts these on stderr.
48
+ ...error.warnings.map((w) => `Soft-blocked (v2.13.3 back-compat window): ${printableWarningText(w.path)} — ` +
49
+ `${printableWarningText(w.message)}${softWarningExpiryClause(w)}`),
50
+ 'Once every unmet requirement above is met, rerun this transition.',
25
51
  'For exceptional cases (docs-only / config-only change), bypass with: --allow-incomplete --reason "<justification>"'
26
52
  ]), options.json);
27
53
  process.exitCode = 1;
28
54
  }
29
55
  function reportLintGateFailure(io, options, error) {
30
- printResult(io, fail('request.transition', error.code, error.message, { role: error.role, newState: error.newState, errorCount: error.errorCount }, [
56
+ printResult(io, fail('request.transition', error.code, error.message, {
57
+ role: error.role,
58
+ newState: error.newState,
59
+ errorCount: error.errorCount,
60
+ findings: error.findings
61
+ }, [
62
+ // One line per unmet placeholder, naming the line, the offending text and
63
+ // the rule's own reason. The refusal used to carry only their count, so a
64
+ // producer was told HOW MANY were wrong and not one of them WHERE or WHY.
65
+ ...error.findings.map((finding) => `Line ${finding.line}: ${printableWarningText(finding.text)} — ` +
66
+ printableWarningText(finding.reason)),
31
67
  'Fix lint errors in the artifact before transitioning.',
32
- 'Run `peaks request lint --role <role> --id <rid> --project <path>` to see details.',
68
+ // The rid is POSITIONAL; `--id` is not an option this command has, and the
69
+ // earlier hint named it — so the one remedy this refusal offered was a
70
+ // command the CLI answers with `unknown option '--id'`. Verified by running
71
+ // the substituted form: it reaches the action.
72
+ 'Run `peaks request lint <rid> --role <role> --project <path>` to see details.',
73
+ 'Or bypass with: --allow-incomplete --reason "<justification>"'
74
+ ]), options.json);
75
+ process.exitCode = 1;
76
+ }
77
+ function reportStateOrderFailure(io, options, error) {
78
+ printResult(io, fail('request.transition', error.code, error.message, {
79
+ role: error.role,
80
+ from: error.from,
81
+ newState: error.to,
82
+ skipped: error.skipped
83
+ }, [
84
+ error.kind === 'unreadable'
85
+ ? "Restore the artifact's '- state:' line: an unreadable state fails this gate closed"
86
+ : `Walk the states in order — from '${error.from}' the next legal state is ` +
87
+ `'${error.skipped[0] ?? error.to}'`,
33
88
  'Or bypass with: --allow-incomplete --reason "<justification>"'
34
89
  ]), options.json);
35
90
  process.exitCode = 1;
@@ -47,11 +102,17 @@ function reportTypeSanityFailure(io, options, error) {
47
102
  }
48
103
  function reportFileSizeFailure(io, options, error) {
49
104
  printResult(io, fail('request.transition', error.code, error.message, { violations: error.violations }, [
50
- ...error.violations.map((v) => `Split ${v.file} (${v.lines} lines) below its ${v.cap}-line cap`),
105
+ ...error.violations.map((v) => v.previousLines === null
106
+ ? `Split ${v.file} (${v.lines} lines) below its ${v.cap}-line cap — this change created it over the cap`
107
+ : `Split ${v.file} back below its ${v.cap}-line cap, or at least down to the ${v.previousLines} lines it had at the base ref (grew +${v.lines - v.previousLines})`),
51
108
  'Or bypass with: --allow-incomplete --reason "<justification>"'
52
109
  ]), options.json);
53
110
  process.exitCode = 1;
54
111
  }
112
+ function reportTypeCorroborationFailure(io, options, error) {
113
+ printResult(io, fail('request.transition', error.code, error.message, { declaredType: error.declaredType, kind: error.kind }, ['Or bypass with: --allow-incomplete --reason "<justification>"']), options.json);
114
+ process.exitCode = 1;
115
+ }
55
116
  function reportConfirmationFailure(io, options, requestId, error) {
56
117
  printResult(io, fail('request.transition', 'CONFIRMATION_REQUIRED', error.message, { role: options.role, requestId, transitionKey: error.transitionKey, mode: error.mode }, [...error.nextActions]), options.json);
57
118
  process.exitCode = 1;
@@ -73,6 +134,10 @@ export function reportTransitionFailure(io, options, requestId, error) {
73
134
  reportLintGateFailure(io, options, error);
74
135
  return;
75
136
  }
137
+ if (error instanceof StateOrderViolationError) {
138
+ reportStateOrderFailure(io, options, error);
139
+ return;
140
+ }
76
141
  if (error instanceof TypeSanityViolationError) {
77
142
  reportTypeSanityFailure(io, options, error);
78
143
  return;
@@ -81,6 +146,10 @@ export function reportTransitionFailure(io, options, requestId, error) {
81
146
  reportFileSizeFailure(io, options, error);
82
147
  return;
83
148
  }
149
+ if (error instanceof TypeCorroborationViolationError) {
150
+ reportTypeCorroborationFailure(io, options, error);
151
+ return;
152
+ }
84
153
  if (error instanceof ConfirmationRequiredError) {
85
154
  reportConfirmationFailure(io, options, requestId, error);
86
155
  return;
@@ -48,7 +48,7 @@ function refuseAllowIncompleteRestricted(io, ctx, mode) {
48
48
  process.exitCode = 1;
49
49
  }
50
50
  function refuseBypassLimitReached(io, ctx) {
51
- printResult(io, fail('request.transition', 'BYPASS_LIMIT_REACHED', `--allow-incomplete limit reached (${MAX_BYPASSES_PER_SESSION} per session)`, { role: ctx.role, requestId: ctx.requestId, limit: MAX_BYPASSES_PER_SESSION }, ['Produce the missing artifacts instead of bypassing.']), ctx.options.json);
51
+ printResult(io, fail('request.transition', 'BYPASS_LIMIT_REACHED', `--allow-incomplete limit reached (${MAX_BYPASSES_PER_SESSION} per session)`, { role: ctx.role, requestId: ctx.requestId, limit: MAX_BYPASSES_PER_SESSION }, ['Satisfy the unmet requirements instead of bypassing.']), ctx.options.json);
52
52
  process.exitCode = 1;
53
53
  }
54
54
  /**
@@ -16,7 +16,7 @@ import { acceptanceCoverageNextActions, diffVsScopeNextActions, printAcceptanceC
16
16
  const REQUEST_TYPE_SANITY_DESCRIPTION = 'Cross-verify a declared --type against the actual git diff file mix (catches "feature mis-declared as docs" workflow violations)';
17
17
  const ACCEPTANCE_COVERAGE_DESCRIPTION = 'Verify every PRD "Acceptance criteria" item has at least one linked QA test case (via `- **Acceptance:** A1, A2` field in qa/test-cases/<rid>.md)';
18
18
  const DIFF_VS_SCOPE_DESCRIPTION = 'Verify every file in the git diff matches the RD artifact "Red-line scope" patterns; flags out-of-scope writes and unclassified files';
19
- const FILE_SIZE_DESCRIPTION = 'Check git diff for files exceeding a line count threshold (karpathy-skills "Simplicity First"; tool output, lockfiles and append-only records such as CHANGELOG.md excluded)';
19
+ const FILE_SIZE_DESCRIPTION = 'Check git diff for files this change grew past the line-count cap, or created over it (karpathy-skills "Simplicity First"; a file already over cap at the base ref is accepted, as the gate baseline ratchets it; a rename is measured against its pre-rename size; tool output, lockfiles and append-only records such as CHANGELOG.md excluded)';
20
20
  function runScanRequestTypeSanity(options, io) {
21
21
  try {
22
22
  const serviceOptions = {
@@ -108,7 +108,7 @@ function runScanFileSize(options, io) {
108
108
  });
109
109
  const nextActions = [];
110
110
  if (!result.ok) {
111
- nextActions.push(`${result.violations.length} file(s) exceed their file-size cap. Split into smaller modules.`);
111
+ nextActions.push(`${result.violations.length} file(s) exceed their file-size cap because this change grew them past it (or created them over it). Split into smaller modules.`);
112
112
  }
113
113
  printResult(io, ok('scan.file-size', result, [], nextActions), options.json);
114
114
  if (!result.ok) {
@@ -2,6 +2,14 @@ import { readFileSync } from 'node:fs';
2
2
  import { detectSecurityAudit, isSecurityAuditEnvelope, runSecurityAudit } from '../../services/audit-independent/index.js';
3
3
  import { addJsonOption, getErrorMessage, printResult } from '../cli-helpers.js';
4
4
  import { fail, ok } from 'peaks-loop-shared/result';
5
+ /**
6
+ * The judged paths as the service takes them. A call, not a `??` inside the
7
+ * action, because the action's branch budget is already at its cap and a second
8
+ * operator there is a `complexity` finding on the whole command.
9
+ */
10
+ function resolveJudgedPaths(judged) {
11
+ return judged ?? [];
12
+ }
5
13
  function resolveEnvelope(envelopePath) {
6
14
  if (envelopePath === undefined || envelopePath === '-') {
7
15
  // Read from stdin
@@ -19,9 +27,7 @@ function readStdinSync() {
19
27
  // Node 22: read stdin synchronously via fs.readFileSync(0, 'utf8').
20
28
  // We use the file descriptor 0 convention.
21
29
  try {
22
- // Lazy import to avoid pulling readline at module load
23
- const { readFileSync: rfs } = require('node:fs');
24
- const raw = rfs(0, 'utf8');
30
+ const raw = readFileSync(0, 'utf8');
25
31
  if (raw.trim().length === 0) {
26
32
  throw new Error('stdin was empty; expected JSON envelope on stdin or --envelope <path>');
27
33
  }
@@ -63,7 +69,14 @@ export function registerSecurityAuditCommands(program, io) {
63
69
  });
64
70
  const envelope = detect.state === 'ready'
65
71
  ? ok('security-audit.detect', detect, [...detect.warnings], [...detect.nextActions])
66
- : fail('security-audit.detect', detect.state.toUpperCase().replace(/-/g, '_'), `security-audit is not ready: ${detect.state}`, detect, [...detect.nextActions]);
72
+ : {
73
+ // `fail()` builds `warnings: []`, so the detector's own diagnosis is
74
+ // spread over it. Without this the human-readable refusal drops the
75
+ // sentence saying WHY the run is not ready, while `--json` keeps it
76
+ // at `data.detect.warnings` — the 9.2 shape, one surface over.
77
+ ...fail('security-audit.detect', detect.state.toUpperCase().replace(/-/g, '_'), `security-audit is not ready: ${detect.state}`, detect, [...detect.nextActions]),
78
+ warnings: [...detect.warnings]
79
+ };
67
80
  printResult(io, envelope, options.json);
68
81
  if (detect.state !== 'ready') {
69
82
  process.exitCode = 1;
@@ -86,7 +99,8 @@ export function registerSecurityAuditCommands(program, io) {
86
99
  .option('--rid <rid>', 'request id (e.g. 2026-06-27-v2-12-...)')
87
100
  .option('--sid <sid>', 'session id (e.g. 2026-06-27-session-...)')
88
101
  .option('--project <path>', 'project root (default: cwd)')
89
- .option('--envelope <path>', 'path to envelope JSON file; "-" reads from stdin (default: stdin)')).action((options) => {
102
+ .option('--envelope <path>', 'path to envelope JSON file; "-" reads from stdin (default: stdin)')
103
+ .option('--judged <paths...>', 'project-relative paths this audit judged; written into the artifact as the declaration the rd:qa-handoff gate reads back. Not enforced by the parser: an empty or unhashable list is refused by the run itself, which exits 1 and writes nothing.')).action((options) => {
90
104
  const projectRoot = options.project ?? process.cwd();
91
105
  const sid = options.sid;
92
106
  const rid = options.rid;
@@ -115,10 +129,16 @@ export function registerSecurityAuditCommands(program, io) {
115
129
  sessionId: sid,
116
130
  rid,
117
131
  generatedAt: new Date().toISOString(),
132
+ judgedPaths: resolveJudgedPaths(options.judged),
118
133
  envelope: envelopeValue
119
134
  });
120
135
  if (result.detect.state !== 'ready' || result.artifactPath === null) {
121
- printResult(io, fail('security-audit.run', result.detect.state.toUpperCase().replace(/-/g, '_'), `security-audit is not ready: ${result.detect.state}`, result, [...result.detect.nextActions]), options.json);
136
+ printResult(io, {
137
+ // Same spread as the detect arm: the run's refusal is the only place
138
+ // the detector's warning would reach a person, and `fail()` empties it.
139
+ ...fail('security-audit.run', result.detect.state.toUpperCase().replace(/-/g, '_'), `security-audit is not ready: ${result.detect.state}`, result, [...result.detect.nextActions]),
140
+ warnings: [...result.detect.warnings]
141
+ }, options.json);
122
142
  process.exitCode = 1;
123
143
  return;
124
144
  }
@@ -4,6 +4,7 @@
4
4
  // 300-line file cap.
5
5
  import { readFileSync, writeFileSync, mkdirSync, existsSync, readdirSync } from 'node:fs';
6
6
  import { join } from 'node:path';
7
+ import { slugifyDescription } from '../../shared/incrementing-number.js';
7
8
  export function readPrdBody(rid, projectRoot) {
8
9
  // Search all .peaks/**/prd/requests/*-<rid>.md and .peaks/**/prd/requests/<rid>.md
9
10
  const searchRoots = [
@@ -25,7 +26,7 @@ export function readPrdBody(rid, projectRoot) {
25
26
  for (const entry of entries) {
26
27
  if (!entry.endsWith('.md'))
27
28
  continue;
28
- if (entry === `${rid}.md` || entry.endsWith(`-${rid}.md`)) {
29
+ if (entry === `${rid}.md` || entry.endsWith(`-${slugifyDescription(rid)}.md`)) {
29
30
  return readFileSync(join(dir, entry), 'utf8');
30
31
  }
31
32
  }
@@ -8,6 +8,7 @@ import { isUnsafePathInput } from '../../shared/path-safety.js';
8
8
  import { DEFAULT_REQUEST_TYPE } from '../../services/artifacts/artifact-prerequisites.js';
9
9
  import { REQUEST_ID_PATTERN } from '../../services/artifacts/request-artifact-service.js';
10
10
  import { contractEvidencePaths } from '../../services/workflow/pipeline-verify-gate-support.js';
11
+ import { slugifyDescription } from '../../shared/incrementing-number.js';
11
12
  // filenames carry the rid. The ridless names are the pre-rid locations and
12
13
  // see `MUT_REPORT` in `artifact-prerequisites.ts`: no producer in the repo
13
14
  // look for a file that no writer can create.
@@ -176,7 +177,7 @@ async function readMut(projectRoot, sid) {
176
177
  }
177
178
  function readQa(projectRoot, sid, rid) {
178
179
  const dir = join(projectRoot, '.peaks', '_runtime', sid, QA_REL);
179
- const candidates = [`${rid}.md`, `001-${rid}.md`];
180
+ const candidates = [`${rid}.md`, `001-${slugifyDescription(rid)}.md`];
180
181
  for (const name of candidates) {
181
182
  const path = join(dir, name);
182
183
  if (existsSync(path)) {
@@ -2,9 +2,9 @@ import { addJsonOption, getErrorMessage, printResult } from '../cli-helpers.js';
2
2
  import { fail, ok } from 'peaks-loop-shared/result';
3
3
  import { getSessionId } from '../../services/session/session-manager.js';
4
4
  import { verifyPipeline } from '../../services/workflow/pipeline-verify-service.js';
5
- import { applySkip, detectCallerKind } from '../../services/workflow/workflow-skip-service.js';
5
+ import { applySkip, detectCallerKind, SKIPPABLE_TYPES } from '../../services/workflow/workflow-skip-service.js';
6
6
  const VERIFY_PIPELINE_DESCRIPTION = 'Verify the complete rd→qa pipeline was followed for a request. Scans the v2.17.0 canonical session-axis layout (artifacts under _runtime per-session) and falls back to the legacy v2.16.0 change-axis forms during the 1-minor-release deprecation window.';
7
- const SKIP_DESCRIPTION = 'Skip specific gates for a request (RD/QA). Use --dry-run to preview without writing. Allowed gate names: QA / RD (phase shortcuts) or specific gate names (rd-request-exists, prd-handoff, bug-analysis, code-review, security-review, perf-baseline, qa-request-exists, test-cases, test-report). Three rules apply: (1) only docs/config/chore slices can skip; (2) skip is one-time per rid; (3) script callers must also pass --i-have-reviewed.';
7
+ const SKIP_DESCRIPTION = `Skip specific gates for a request (RD/QA). Use --dry-run to preview without writing. Allowed gate names: QA / RD (phase shortcuts) or specific gate names (rd-request-exists, prd-handoff, bug-analysis, code-review, security-review, perf-baseline, qa-request-exists, test-cases, test-report). Three rules apply: (1) only ${SKIPPABLE_TYPES.join('/')} slices can skip; (2) skip is one-time per rid; (3) script callers must also pass --i-have-reviewed.`;
8
8
  /** The action body, lifted to a module-level function so both it and the registrar fit in 50 lines. */
9
9
  async function runVerifyPipeline(options, io) {
10
10
  try {
@@ -50,7 +50,7 @@ function reportSkipOutcome(io, options, sessionId, result) {
50
50
  }
51
51
  // applied:false + reason → rejection.
52
52
  printResult(io, fail('workflow.skip', 'SKIP_REJECTED', result.reason ?? 'unknown rejection', result, [
53
- 'See RD request for the three rules: docs/config/chore only, one-time per rid, script callers need --i-have-reviewed.'
53
+ `See RD request for the three rules: ${SKIPPABLE_TYPES.join('/')} only, one-time per rid, script callers need --i-have-reviewed.`
54
54
  ]), options.json);
55
55
  process.exitCode = 1;
56
56
  }
@@ -97,7 +97,7 @@ export function registerWorkflowGateCommands(workflow, io) {
97
97
  .description(VERIFY_PIPELINE_DESCRIPTION)
98
98
  .requiredOption('--rid <rid>', 'request identifier')
99
99
  .requiredOption('--project <path>', 'project root path')
100
- .option('--type <type>', 'request type: feature, bugfix, refactor, docs, config, chore', 'feature')
100
+ .option('--type <type>', "request type: feature, bugfix, refactor, docs, config, chore. Omit it and the rid's own request artifact decides — the recorded `- type:` line on its RD (then PRD, then QA) carrier. Only a `--type` given here overrides that.")
101
101
  .option('--session-id <sid>', 'slice 2026-06-13-peaks-workflow-skip: session id under which to read the skip-state file. When omitted, no skip-state is consulted (legacy behavior).')).action((options) => runVerifyPipeline(options, io));
102
102
  // Mark gates as bypassed for a specific rid, so the next
103
103
  // `verify-pipeline` reports them as `status: 'skipped'` instead of
@@ -66,7 +66,7 @@ function printGcOk(io, options, ctx) {
66
66
  dryRun
67
67
  ? `[dry-run] Would gc ${swept.length} lease(s); no filesystem changes were made.`
68
68
  : `Gc'd ${swept.length} lease(s).`,
69
- 'For per-lease detail, run `peaks worktree status --lease-id <id>`.'
69
+ 'For per-lease detail, run `peaks worktree lease-status --lease-id <id>`.'
70
70
  ]), options.json);
71
71
  }
72
72
  function printGcFailed(io, options, err, sessionId) {
@@ -11,7 +11,6 @@ import { registerLeaseMetricsCommand } from './commands/lease-metrics-commands.j
11
11
  import { registerMcpCommands } from './commands/mcp-commands.js';
12
12
  import { registerLeaseStatsCommand } from './commands/lease-stats-commands.js';
13
13
  import { registerContainerCommand } from './commands/container-commands.js';
14
- import { registerVmCommand } from './commands/vm-commands.js';
15
14
  import { registerCronCommand } from './commands/cron-commands.js';
16
15
  import { registerCronSchedulerCommand } from './commands/cron-scheduler-commands.js';
17
16
  import { registerWorkspaceCommands } from './commands/workspace-commands.js';
@@ -195,7 +194,6 @@ Run peaks (no arguments) for a quickstart. You likely want one of:
195
194
  registerLeaseMetricsCommand(program, io);
196
195
  registerLeaseStatsCommand(program, io);
197
196
  registerContainerCommand(program, io);
198
- registerVmCommand(program, io);
199
197
  registerCronCommand(program, io);
200
198
  registerCronSchedulerCommand(program, io);
201
199
  // The read-only MCP surface's command family. `serve` spawns the server