@pareto4/pp-core 1.11.0 → 1.12.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (256) hide show
  1. package/.claude-plugin/plugin.json +1 -1
  2. package/README.md +31 -0
  3. package/agents/pp-code-fixer.md +1 -1
  4. package/agents/pp-debug-session-manager.md +1 -1
  5. package/agents/pp-debugger.md +1 -1
  6. package/agents/pp-executor.md +20 -10
  7. package/agents/pp-intel-updater.md +1 -1
  8. package/agents/pp-phase-researcher.md +1 -1
  9. package/agents/pp-plan-checker.md +5 -5
  10. package/agents/pp-planner.md +10 -24
  11. package/agents/pp-project-researcher.md +1 -1
  12. package/agents/pp-research-synthesizer.md +1 -1
  13. package/agents/pp-ui-researcher.md +1 -1
  14. package/agents/pp-verifier.md +8 -4
  15. package/bin/install.js +429 -82
  16. package/commands/pp-autonomous.md +8 -6
  17. package/commands/pp-discovery-to-build.md +1 -1
  18. package/commands/pp-discovery.md +3 -2
  19. package/commands/pp-discuss-phase.md +2 -2
  20. package/commands/pp-execute-phase.md +3 -1
  21. package/commands/pp-graphify.md +5 -5
  22. package/commands/pp-import.md +1 -1
  23. package/commands/pp-map-codebase.md +1 -1
  24. package/commands/pp-ns-project.md +2 -3
  25. package/commands/pp-ns-workflow.md +1 -1
  26. package/commands/pp-plan-phase.md +2 -1
  27. package/commands/pp-verify-work.md +2 -1
  28. package/gemini-extension.json +1 -1
  29. package/hooks/dist/pp-cursor-session-start.js +2 -2
  30. package/hooks/dist/pp-session-state.sh +1 -1
  31. package/hooks/dist/pp-statusline.js +21 -2
  32. package/hooks/pp-cursor-session-start.js +2 -2
  33. package/hooks/pp-session-state.sh +1 -1
  34. package/hooks/pp-statusline.js +21 -2
  35. package/package.json +18 -5
  36. package/pareto-skills/pp-project-setup/SKILL.md +5 -63
  37. package/pp-core/bin/detect-build-commands.sh +182 -0
  38. package/pp-core/bin/lib/capability-registry.cjs +65 -7
  39. package/pp-core/bin/lib/check-command-router.cjs +79 -38
  40. package/pp-core/bin/lib/clusters.cjs +2 -3
  41. package/pp-core/bin/lib/command-aliases.cjs +36 -0
  42. package/pp-core/bin/lib/command-arg-projection.cjs +99 -1
  43. package/pp-core/bin/lib/commands.cjs +21 -6
  44. package/pp-core/bin/lib/compose-bindings.cjs +128 -15
  45. package/pp-core/bin/lib/config-schema.cjs +16 -0
  46. package/pp-core/bin/lib/config.cjs +142 -27
  47. package/pp-core/bin/lib/core-utils.cjs +43 -7
  48. package/pp-core/bin/lib/discovery-input-check.cjs +218 -0
  49. package/pp-core/bin/lib/discovery-rebaseline.cjs +1372 -0
  50. package/pp-core/bin/lib/discovery-research-track.cjs +979 -0
  51. package/pp-core/bin/lib/discovery-rollup.cjs +476 -0
  52. package/pp-core/bin/lib/discovery-screens.cjs +1995 -0
  53. package/pp-core/bin/lib/discovery-sweep.cjs +390 -0
  54. package/pp-core/bin/lib/discovery-table.cjs +98 -0
  55. package/pp-core/bin/lib/dispatch-plan.cjs +472 -0
  56. package/pp-core/bin/lib/frontmatter.cjs +17 -2
  57. package/pp-core/bin/lib/init-command-router.cjs +8 -5
  58. package/pp-core/bin/lib/init-contract.cjs +213 -33
  59. package/pp-core/bin/lib/init-interactive.cjs +20 -1
  60. package/pp-core/bin/lib/init.cjs +124 -134
  61. package/pp-core/bin/lib/install-profiles.cjs +5 -0
  62. package/pp-core/bin/lib/install-run.cjs +536 -0
  63. package/pp-core/bin/lib/io.cjs +15 -0
  64. package/pp-core/bin/lib/loop-resolver.cjs +24 -0
  65. package/pp-core/bin/lib/milestone.cjs +345 -48
  66. package/pp-core/bin/lib/phase-command-router.cjs +23 -1
  67. package/pp-core/bin/lib/phase-locator.cjs +15 -6
  68. package/pp-core/bin/lib/phase-scope.cjs +91 -0
  69. package/pp-core/bin/lib/phase-tier.cjs +467 -0
  70. package/pp-core/bin/lib/phase.cjs +247 -21
  71. package/pp-core/bin/lib/phases-command-router.cjs +2 -0
  72. package/pp-core/bin/lib/plan-graph.cjs +368 -0
  73. package/pp-core/bin/lib/planning-workspace.cjs +53 -0
  74. package/pp-core/bin/lib/platform-bindings.cjs +32 -2
  75. package/pp-core/bin/lib/profile-output.cjs +11 -3
  76. package/pp-core/bin/lib/prohibition-enforcement.cjs +112 -0
  77. package/pp-core/bin/lib/roadmap-parser.cjs +366 -99
  78. package/pp-core/bin/lib/roadmap.cjs +141 -39
  79. package/pp-core/bin/lib/runtime-hooks-surface.cjs +1 -1
  80. package/pp-core/bin/lib/shell-command-projection.cjs +24 -0
  81. package/pp-core/bin/lib/state-command-router.cjs +82 -13
  82. package/pp-core/bin/lib/state-document.cjs +124 -7
  83. package/pp-core/bin/lib/state.cjs +784 -257
  84. package/pp-core/bin/lib/template.cjs +22 -6
  85. package/pp-core/bin/lib/vault-command-router.cjs +57 -6
  86. package/pp-core/bin/lib/vault-practices.cjs +6 -36
  87. package/pp-core/bin/lib/vault-write-back.cjs +20 -4
  88. package/pp-core/bin/lib/vault.cjs +555 -23
  89. package/pp-core/bin/lib/verify.cjs +53 -31
  90. package/pp-core/bin/lib/workstream.cjs +1 -1
  91. package/pp-core/bin/lib/worktree-safety.cjs +26 -15
  92. package/pp-core/bin/portable-timeout.sh +89 -0
  93. package/pp-core/bin/pp-tools.cjs +158 -8
  94. package/pp-core/bin/shared/config-defaults.manifest.json +7 -0
  95. package/pp-core/bin/shared/config-schema.manifest.json +3 -0
  96. package/pp-core/references/autonomous-best-effort.md +461 -0
  97. package/pp-core/references/autonomous-lifecycle.md +146 -0
  98. package/pp-core/references/autonomous-smart-discuss.md +16 -12
  99. package/pp-core/references/checkpoints.md +1 -1
  100. package/pp-core/references/discovery-id-conventions.md +202 -0
  101. package/pp-core/references/discovery-rebaseline.md +254 -0
  102. package/pp-core/references/discovery-research-track.md +283 -0
  103. package/pp-core/references/discovery-traceability.md +400 -0
  104. package/pp-core/references/loop-hook-dispatch.md +7 -0
  105. package/pp-core/references/mandatory-initial-read.md +1 -1
  106. package/pp-core/references/planner-gap-closure.md +1 -0
  107. package/pp-core/references/planner-human-verify-mode.md +1 -1
  108. package/pp-core/references/planner-load-graph-context.md +1 -1
  109. package/pp-core/references/planner-plan-graph.md +66 -0
  110. package/pp-core/references/planner-tdd.md +1 -0
  111. package/pp-core/references/planning-config.md +8 -0
  112. package/pp-core/references/sketch-tooling.md +4 -0
  113. package/pp-core/references/tdd.md +1 -0
  114. package/pp-core/templates/claude-md.md +1 -1
  115. package/pp-core/templates/phase-prompt.md +6 -2
  116. package/pp-core/templates/prototype-review/review.js +303 -0
  117. package/pp-core/templates/state.md +6 -0
  118. package/pp-core/workflows/_runtime-launcher.snippet.sh +1 -1
  119. package/pp-core/workflows/add-backlog.md +1 -1
  120. package/pp-core/workflows/add-phase.md +1 -1
  121. package/pp-core/workflows/add-tests.md +1 -1
  122. package/pp-core/workflows/add-todo.md +1 -1
  123. package/pp-core/workflows/ai-integration-phase.md +2 -2
  124. package/pp-core/workflows/audit-fix.md +12 -16
  125. package/pp-core/workflows/audit-milestone.md +1 -1
  126. package/pp-core/workflows/audit-uat.md +1 -1
  127. package/pp-core/workflows/autonomous.md +68 -306
  128. package/pp-core/workflows/check-todos.md +1 -1
  129. package/pp-core/workflows/cleanup.md +1 -1
  130. package/pp-core/workflows/code-review-fix.md +1 -1
  131. package/pp-core/workflows/code-review.md +19 -7
  132. package/pp-core/workflows/complete-milestone.md +41 -60
  133. package/pp-core/workflows/debug.md +1 -1
  134. package/pp-core/workflows/diagnose-issues.md +1 -1
  135. package/pp-core/workflows/discovery-sprint/gap-analysis.md +140 -0
  136. package/pp-core/workflows/discovery-sprint/input-package.md +140 -0
  137. package/pp-core/workflows/discovery-sprint/prefill.md +92 -0
  138. package/pp-core/workflows/discovery-sprint/prototype.md +257 -0
  139. package/pp-core/workflows/discovery-sprint/rebaseline.md +276 -0
  140. package/pp-core/workflows/discovery-sprint/session-13-gates.md +24 -0
  141. package/pp-core/workflows/discovery-sprint/sessions/01-kick-off.md +92 -0
  142. package/pp-core/workflows/discovery-sprint/sessions/02-as-is.md +98 -0
  143. package/pp-core/workflows/discovery-sprint/sessions/03-to-be.md +215 -0
  144. package/pp-core/workflows/discovery-sprint/sessions/04-ux-design.md +146 -0
  145. package/pp-core/workflows/discovery-sprint/sessions/05-architecture.md +98 -0
  146. package/pp-core/workflows/discovery-sprint/sessions/06-security.md +107 -0
  147. package/pp-core/workflows/discovery-sprint/sessions/07-identity.md +98 -0
  148. package/pp-core/workflows/discovery-sprint/sessions/08-integration.md +85 -0
  149. package/pp-core/workflows/discovery-sprint/sessions/09-qa.md +109 -0
  150. package/pp-core/workflows/discovery-sprint/sessions/10-infrastructure.md +119 -0
  151. package/pp-core/workflows/discovery-sprint/sessions/11-roadmap.md +92 -0
  152. package/pp-core/workflows/discovery-sprint/sessions/12-delivery-model.md +98 -0
  153. package/pp-core/workflows/discovery-sprint/sessions/13-wrap-up.md +205 -0
  154. package/pp-core/workflows/discovery-sprint/templates/context-template.md +266 -0
  155. package/pp-core/workflows/discovery-sprint.md +79 -1714
  156. package/pp-core/workflows/discovery-to-build/steps/architecture-deliverables.md +5 -5
  157. package/pp-core/workflows/discovery-to-build/steps/screen-inventory-gate.md +70 -0
  158. package/pp-core/workflows/discovery-to-build/templates/discovery-references.md +54 -0
  159. package/pp-core/workflows/discovery-to-build/templates/pp-handoff.md +184 -0
  160. package/pp-core/workflows/discovery-to-build.md +21 -238
  161. package/pp-core/workflows/discuss-phase/modes/advisor.md +1 -1
  162. package/pp-core/workflows/discuss-phase/modes/auto.md +1 -1
  163. package/pp-core/workflows/discuss-phase/modes/chain.md +1 -1
  164. package/pp-core/workflows/discuss-phase-assumptions.md +1 -1
  165. package/pp-core/workflows/discuss-phase.md +9 -2
  166. package/pp-core/workflows/do.md +4 -4
  167. package/pp-core/workflows/docs-update.md +1 -1
  168. package/pp-core/workflows/edit-phase.md +1 -1
  169. package/pp-core/workflows/eval-review.md +1 -1
  170. package/pp-core/workflows/execute-phase/steps/checkpoint-handling.md +45 -0
  171. package/pp-core/workflows/execute-phase/steps/client-context-gate.md +1 -1
  172. package/pp-core/workflows/execute-phase/steps/codebase-drift-gate.md +1 -1
  173. package/pp-core/workflows/execute-phase/steps/cross-ai-delegation.md +90 -0
  174. package/pp-core/workflows/execute-phase/steps/install-run.md +29 -0
  175. package/pp-core/workflows/execute-phase/steps/phase-close-rebaseline.md +23 -0
  176. package/pp-core/workflows/execute-phase/steps/post-merge-gate.md +76 -77
  177. package/pp-core/workflows/execute-phase/steps/serial-group-dispatch.md +72 -0
  178. package/pp-core/workflows/execute-phase/steps/vault-fetch.md +5 -5
  179. package/pp-core/workflows/execute-phase/steps/vault-load-gate.md +19 -112
  180. package/pp-core/workflows/execute-phase.md +102 -216
  181. package/pp-core/workflows/execute-plan.md +6 -2
  182. package/pp-core/workflows/explore.md +1 -1
  183. package/pp-core/workflows/extract-learnings.md +1 -1
  184. package/pp-core/workflows/forensics.md +4 -4
  185. package/pp-core/workflows/graduation.md +1 -1
  186. package/pp-core/workflows/health.md +1 -1
  187. package/pp-core/workflows/help/modes/brief.md +1 -0
  188. package/pp-core/workflows/help/modes/default.md +2 -1
  189. package/pp-core/workflows/help/modes/full.md +12 -5
  190. package/pp-core/workflows/import.md +1 -1
  191. package/pp-core/workflows/ingest-docs.md +1 -1
  192. package/pp-core/workflows/init.md +18 -2
  193. package/pp-core/workflows/insert-phase.md +1 -1
  194. package/pp-core/workflows/list-workspaces.md +1 -1
  195. package/pp-core/workflows/manager.md +3 -3
  196. package/pp-core/workflows/map-codebase.md +2 -2
  197. package/pp-core/workflows/milestone-summary.md +4 -4
  198. package/pp-core/workflows/mvp-phase.md +1 -1
  199. package/pp-core/workflows/new-milestone.md +7 -8
  200. package/pp-core/workflows/new-project.md +6 -1
  201. package/pp-core/workflows/new-workspace.md +1 -1
  202. package/pp-core/workflows/next.md +2 -2
  203. package/pp-core/workflows/note.md +2 -2
  204. package/pp-core/workflows/pause-work.md +1 -1
  205. package/pp-core/workflows/plan-milestone-gaps.md +1 -1
  206. package/pp-core/workflows/plan-phase/steps/chunked-planning.md +111 -0
  207. package/pp-core/workflows/plan-phase/steps/phase-tier.md +34 -0
  208. package/pp-core/workflows/plan-phase.md +43 -167
  209. package/pp-core/workflows/plan-review-convergence.md +2 -2
  210. package/pp-core/workflows/plant-seed.md +1 -1
  211. package/pp-core/workflows/pr-branch.md +1 -1
  212. package/pp-core/workflows/profile-user.md +1 -1
  213. package/pp-core/workflows/progress.md +3 -3
  214. package/pp-core/workflows/quick.md +3 -1
  215. package/pp-core/workflows/remove-phase.md +1 -1
  216. package/pp-core/workflows/remove-workspace.md +1 -1
  217. package/pp-core/workflows/resume-project.md +6 -12
  218. package/pp-core/workflows/review.md +1 -1
  219. package/pp-core/workflows/scan.md +1 -1
  220. package/pp-core/workflows/secure-phase.md +1 -1
  221. package/pp-core/workflows/settings-advanced.md +1 -1
  222. package/pp-core/workflows/settings-integrations.md +1 -1
  223. package/pp-core/workflows/settings.md +1 -1
  224. package/pp-core/workflows/ship.md +25 -8
  225. package/pp-core/workflows/sketch-wrap-up.md +1 -1
  226. package/pp-core/workflows/sketch.md +2 -1
  227. package/pp-core/workflows/spec-phase.md +1 -1
  228. package/pp-core/workflows/spike-wrap-up.md +1 -1
  229. package/pp-core/workflows/spike.md +1 -1
  230. package/pp-core/workflows/stats.md +2 -2
  231. package/pp-core/workflows/thread.md +1 -1
  232. package/pp-core/workflows/transition.md +5 -9
  233. package/pp-core/workflows/ui-phase.md +23 -2
  234. package/pp-core/workflows/ui-review.md +1 -1
  235. package/pp-core/workflows/ultraplan-phase.md +2 -2
  236. package/pp-core/workflows/validate-phase.md +1 -1
  237. package/pp-core/workflows/vault-write-back.md +1 -1
  238. package/pp-core/workflows/verify-phase.md +29 -26
  239. package/pp-core/workflows/verify-work.md +14 -10
  240. package/scripts/base64-scan.sh +7 -41
  241. package/scripts/changeset/cli.cjs +25 -5
  242. package/scripts/dev-env.cjs +462 -0
  243. package/scripts/lib/allowlist-ratchet.cjs +103 -1
  244. package/scripts/lib/size-budget.cjs +311 -0
  245. package/scripts/lint-neutrality-names.cjs +694 -0
  246. package/scripts/lint-org-coordinates.allowlist.json +35 -0
  247. package/scripts/lint-org-coordinates.cjs +426 -0
  248. package/scripts/lint-skill-deps.cjs +48 -9
  249. package/scripts/lint-test-file-count.cjs +17 -2
  250. package/scripts/prompt-injection-scan.sh +41 -20
  251. package/scripts/sync-manifest-versions.cjs +41 -7
  252. package/scripts/sync-runtime-launcher.cjs +106 -1
  253. package/scripts/update-size-baseline.cjs +274 -30
  254. package/scripts/workflow-size.cjs +61 -9
  255. package/commands/pp-build-handoff.md +0 -46
  256. package/pp-core/workflows/execute-phase/steps/per-plan-worktree-gate.md +0 -94
@@ -19,8 +19,8 @@ const io = require("./io.cjs");
19
19
  const configLoader = require("./config-loader.cjs");
20
20
  // eslint-disable-next-line @typescript-eslint/no-require-imports -- model-resolver.cjs is an export= CommonJS module
21
21
  const modelResolver = require("./model-resolver.cjs");
22
- // eslint-disable-next-line @typescript-eslint/no-require-imports -- phase-locator.cjs is an export= CommonJS module
23
- const phaseLocator = require("./phase-locator.cjs");
22
+ // eslint-disable-next-line @typescript-eslint/no-require-imports -- phase-scope.cjs is an export= CommonJS module
23
+ const phaseScope = require("./phase-scope.cjs");
24
24
  // eslint-disable-next-line @typescript-eslint/no-require-imports -- roadmap-parser.cjs is an export= CommonJS module
25
25
  const roadmapParser = require("./roadmap-parser.cjs");
26
26
  // eslint-disable-next-line @typescript-eslint/no-require-imports -- core-utils.cjs is an export= CommonJS module
@@ -32,6 +32,7 @@ const worktreeSafety = require("./worktree-safety.cjs");
32
32
  // eslint-disable-next-line @typescript-eslint/no-require-imports -- planning-workspace.cjs is an export= CommonJS module
33
33
  const planningWorkspace = require("./planning-workspace.cjs");
34
34
  const secrets_cjs_1 = require("./secrets.cjs");
35
+ const phase_tier_cjs_1 = require("./phase-tier.cjs");
35
36
  // eslint-disable-next-line @typescript-eslint/no-require-imports -- plan-scan.cjs is an export= CommonJS module
36
37
  const scanPhasePlans = require("./plan-scan.cjs");
37
38
  const state_document_cjs_1 = require("./state-document.cjs");
@@ -51,12 +52,12 @@ const { gitWorktreeInfoInternal } = gitBaseBranch;
51
52
  const { output, error } = io;
52
53
  const { loadConfig } = configLoader;
53
54
  const { resolveModelInternal, resolveGranularityInternal, assertValidGranularityOverride } = modelResolver;
54
- const { findPhaseInternal } = phaseLocator;
55
- const { getRoadmapPhaseInternal, getMilestoneInfo, getMilestonePhaseFilter, stripShippedMilestones, extractCurrentMilestone, } = roadmapParser;
55
+ const { resolvePhaseScope } = phaseScope;
56
+ const { getMilestoneInfo, getMilestonePhaseFilter, stripShippedMilestones, extractCurrentMilestone, } = roadmapParser;
56
57
  const { pathExistsInternal, generateSlugInternal, toPosixPath } = coreUtils;
57
58
  const { normalizePhaseName, phaseTokenMatches } = phaseId;
58
59
  const { pruneOrphanedWorktrees } = worktreeSafety;
59
- const { planningPaths, planningDir, planningRoot, findContextMdIn, } = planningWorkspace;
60
+ const { planningPaths, planningDir, planningRoot, resolveProjectFile, findContextMdIn, } = planningWorkspace;
60
61
  const { determinePhaseStatus } = commandsMod;
61
62
  const { extractFrontmatter } = frontmatterMod;
62
63
  // Unused but imported for structural parity
@@ -70,16 +71,22 @@ function listPhasePlanFiles(phaseDir) {
70
71
  return scanPhasePlans(phaseDir)['planFiles'];
71
72
  }
72
73
  function getLatestCompletedMilestone(cwd) {
73
- const milestonesPath = node_path_1.default.join(planningRoot(cwd), 'MILESTONES.md');
74
+ // CARRY-05: resolve through planningPaths — the same owner `milestone
75
+ // complete` writes through — so a workstream-archived milestone record is
76
+ // visible here. This used to be planningRoot(cwd), which made every
77
+ // partitioned project report latest_completed_milestone: null.
78
+ const milestonesPath = planningPaths(cwd).milestones;
74
79
  const content = (0, shell_command_projection_cjs_1.platformReadSync)(milestonesPath);
75
80
  if (content === null)
76
81
  return null;
77
- const match = content.match(/^##\s+(v[\d.]+)\s+(.+?)\s+\(Shipped:/m);
82
+ // 261007-rly D-2: the name is optional — `milestone complete` without --name
83
+ // writes `## v1.0 (Shipped: …)`, the version once, and the name is then the version.
84
+ const match = content.match(/^##\s+(v[\d.]+)(?:\s+(.+?))?\s+\(Shipped:/m);
78
85
  if (!match)
79
86
  return null;
80
87
  return {
81
88
  version: match[1],
82
- name: match[2].trim(),
89
+ name: match[2] ? match[2].trim() : match[1],
83
90
  };
84
91
  }
85
92
  function withProjectRoot(cwd, result) {
@@ -97,8 +104,9 @@ function withProjectRoot(cwd, result) {
97
104
  if (config.project_code) {
98
105
  result['project_code'] = config.project_code;
99
106
  }
100
- const projectMdPath = node_path_1.default.join(planningDir(cwd), 'PROJECT.md');
101
- const content = (0, shell_command_projection_cjs_1.platformReadSync)(projectMdPath);
107
+ // D1 (261007-jkl): read the PROJECT.md that answers for this cwd, so a
108
+ // workstream without its own file still reports the shared project's title.
109
+ const content = (0, shell_command_projection_cjs_1.platformReadSync)(resolveProjectFile(cwd).path);
102
110
  if (content) {
103
111
  const h1Match = content.match(/^#\s+(.+)$/m);
104
112
  if (h1Match) {
@@ -174,17 +182,25 @@ function getInitGitState(cwd) {
174
182
  in_nested_subdir: inNestedSubdir,
175
183
  };
176
184
  }
177
- function cmdInitExecutePhase(cwd, phase, raw, options = {}) {
178
- if (!phase) {
179
- error('phase required for init execute-phase');
180
- }
181
- const config = loadConfig(cwd);
182
- let phaseInfo = findPhaseInternal(cwd, phase);
183
- const milestone = getMilestoneInfo(cwd);
184
- const roadmapPhase = getRoadmapPhaseInternal(cwd, phase);
185
- if (phaseInfo?.['archived'] && roadmapPhase?.['found']) {
186
- phaseInfo = null;
187
- }
185
+ /**
186
+ * The init family's "which phase directory answers N", consumed by init
187
+ * execute-phase, plan-phase, verify-work and phase-op.
188
+ *
189
+ * Quick 261007-jkl, D2 (todo "init execute-phase returns null phase_dir for an
190
+ * archived phase") put the "is this archived match the current milestone's?"
191
+ * compare HERE, for these four verbs only; every other consumer of the raw
192
+ * locator kept the archive fall-through with no compare. The decision now lives in ONE owner, src/phase-scope.cts, which
193
+ * every consumer shares: a phase archived in the CURRENT milestone keeps its
194
+ * match, directory and artifacts; a PRIOR milestone's archived phase whose
195
+ * number the current ROADMAP reuses is dropped (the pins in tests/init.test.cjs
196
+ * "init commands ignore archived phases from prior milestones sharing a number"
197
+ * and #2391). This wrapper takes the owner's reader answer and only adds init's
198
+ * own output shape: a ROADMAP-only phase is synthesised with directory null.
199
+ */
200
+ function resolvePhaseForInit(cwd, phase) {
201
+ const scope = resolvePhaseScope(cwd, phase);
202
+ let phaseInfo = scope.forRead;
203
+ const roadmapPhase = scope.roadmapPhase;
188
204
  if (!phaseInfo && roadmapPhase?.['found']) {
189
205
  const phaseName = roadmapPhase['phase_name'];
190
206
  phaseInfo = {
@@ -204,12 +220,42 @@ function cmdInitExecutePhase(cwd, phase, raw, options = {}) {
204
220
  has_reviews: false,
205
221
  };
206
222
  }
223
+ return { phaseInfo, roadmapPhase };
224
+ }
225
+ /**
226
+ * The phase's resolved ceremony tier for an init payload (src/phase-tier.cts).
227
+ * Init's gate booleans (`research_enabled`, `plan_checker_enabled`,
228
+ * `verifier_enabled`, …) are read from this, never from raw config, so a
229
+ * workflow that reads init reads the tier-resolved set.
230
+ */
231
+ function initPhaseTier(cwd, phase, options) {
232
+ const flag = options['tier'];
233
+ let cli = null;
234
+ if (typeof flag === 'string') {
235
+ const v = flag.trim().toLowerCase();
236
+ if (!(0, phase_tier_cjs_1.isPhaseTier)(v))
237
+ error(`--tier needs one of ${phase_tier_cjs_1.PHASE_TIERS.join(', ')}`);
238
+ cli = v;
239
+ }
240
+ return (0, phase_tier_cjs_1.resolvePhaseTierForProject)(cwd, phase, cli);
241
+ }
242
+ function phaseTierSummary(t) {
243
+ return { tier: t.tier, source: t.source, gates: t.gates, suppressed: t.suppressed };
244
+ }
245
+ function cmdInitExecutePhase(cwd, phase, raw, options = {}) {
246
+ if (!phase) {
247
+ error('phase required for init execute-phase');
248
+ }
249
+ const config = loadConfig(cwd);
250
+ const { phaseInfo, roadmapPhase } = resolvePhaseForInit(cwd, phase);
251
+ const milestone = getMilestoneInfo(cwd);
207
252
  const reqMatch = roadmapPhase?.['section']?.match(REQUIREMENTS_HEADER_RE);
208
253
  const reqExtracted = reqMatch
209
254
  ? reqMatch[1].replace(/[\[\]]/g, '').split(',').map((s) => s.trim()).filter(Boolean).join(', ')
210
255
  : null;
211
256
  const phase_req_ids = reqExtracted && reqExtracted !== 'TBD' ? reqExtracted : null;
212
257
  const wf = (config.workflow ?? {});
258
+ const tier = initPhaseTier(cwd, phase, options);
213
259
  const result = {
214
260
  executor_model: resolveModelInternal(cwd, 'pp-executor'),
215
261
  verifier_model: resolveModelInternal(cwd, 'pp-verifier'),
@@ -221,7 +267,12 @@ function cmdInitExecutePhase(cwd, phase, raw, options = {}) {
221
267
  branching_strategy: config.branching_strategy,
222
268
  phase_branch_template: config.phase_branch_template,
223
269
  milestone_branch_template: config.milestone_branch_template,
224
- verifier_enabled: config.verifier,
270
+ verifier_enabled: tier.gates.verifier,
271
+ code_review_enabled: tier.gates.code_review,
272
+ security_enforcement_enabled: tier.gates.security_enforcement,
273
+ nyquist_validation_enabled: tier.gates.nyquist_validation,
274
+ install_verification_enabled: tier.gates.install_verification,
275
+ phase_tier: phaseTierSummary(tier),
225
276
  phase_found: !!phaseInfo,
226
277
  phase_dir: phaseInfo?.['directory'] || null,
227
278
  phase_number: phaseInfo?.['phase_number'] || null,
@@ -282,30 +333,7 @@ function cmdInitPlanPhase(cwd, phase, raw, options = {}) {
282
333
  error('phase required for init plan-phase');
283
334
  }
284
335
  const config = loadConfig(cwd);
285
- let phaseInfo = findPhaseInternal(cwd, phase);
286
- const roadmapPhase = getRoadmapPhaseInternal(cwd, phase);
287
- if (phaseInfo?.['archived'] && roadmapPhase?.['found']) {
288
- phaseInfo = null;
289
- }
290
- if (!phaseInfo && roadmapPhase?.['found']) {
291
- const phaseName = roadmapPhase['phase_name'];
292
- phaseInfo = {
293
- found: true,
294
- directory: null,
295
- phase_number: roadmapPhase['phase_number'],
296
- phase_name: phaseName,
297
- phase_slug: phaseName
298
- ? phaseName.toLowerCase().replace(/[^a-z0-9]+/g, '-').replace(/^-+|-+$/g, '')
299
- : null,
300
- plans: [],
301
- summaries: [],
302
- incomplete_plans: [],
303
- has_research: false,
304
- has_context: false,
305
- has_verification: false,
306
- has_reviews: false,
307
- };
308
- }
336
+ const { phaseInfo, roadmapPhase } = resolvePhaseForInit(cwd, phase);
309
337
  const reqMatch = roadmapPhase?.['section']?.match(REQUIREMENTS_HEADER_RE);
310
338
  const reqExtracted = reqMatch
311
339
  ? reqMatch[1].replace(/[\[\]]/g, '').split(',').map((s) => s.trim()).filter(Boolean).join(', ')
@@ -329,15 +357,22 @@ function cmdInitPlanPhase(cwd, phase, raw, options = {}) {
329
357
  assertValidGranularityOverride(granularityOverride, error);
330
358
  const granularity = resolveGranularityInternal(cwd, 'planning', granularityOverride || undefined);
331
359
  const wf = (config.workflow ?? {});
360
+ const tier = initPhaseTier(cwd, phase, options);
332
361
  const result = {
333
362
  researcher_model: resolveModelInternal(cwd, 'pp-phase-researcher'),
334
363
  planner_model: resolveModelInternal(cwd, 'pp-planner'),
335
364
  checker_model: resolveModelInternal(cwd, 'pp-plan-checker'),
336
365
  tdd_mode: options['tdd'] || Boolean(wf['tdd_mode']) || false,
337
366
  granularity,
338
- research_enabled: wf['research'],
339
- plan_checker_enabled: config.plan_checker,
340
- nyquist_validation_enabled: wf['nyquist_validation'],
367
+ research_enabled: tier.gates.research,
368
+ plan_checker_enabled: tier.gates.plan_check,
369
+ plan_check_passes: tier.gates.plan_check_passes,
370
+ nyquist_validation_enabled: tier.gates.nyquist_validation,
371
+ pattern_mapper_enabled: tier.gates.pattern_mapper,
372
+ post_planning_gaps_enabled: tier.gates.post_planning_gaps,
373
+ security_enforcement_enabled: tier.gates.security_enforcement,
374
+ plan_bounce_enabled: tier.gates.plan_bounce,
375
+ phase_tier: phaseTierSummary(tier),
341
376
  commit_docs: config.commit_docs,
342
377
  text_mode: config.text_mode,
343
378
  auto_advance: !!(config.auto_advance),
@@ -498,12 +533,14 @@ function cmdInitNewProject(cwd, raw) {
498
533
  pathExistsInternal(cwd, 'build.zig') ||
499
534
  pathExistsInternal(cwd, 'mix.exs') ||
500
535
  pathExistsInternal(cwd, 'project.clj');
536
+ // D1 (261007-jkl): the PROJECT.md that answers for this cwd — the workstream's own, else the shared one.
537
+ const project = resolveProjectFile(cwd);
501
538
  const result = {
502
539
  researcher_model: resolveModelInternal(cwd, 'pp-project-researcher'),
503
540
  synthesizer_model: resolveModelInternal(cwd, 'pp-research-synthesizer'),
504
541
  roadmapper_model: resolveModelInternal(cwd, 'pp-roadmapper'),
505
542
  commit_docs: config.commit_docs,
506
- project_exists: pathExistsInternal(cwd, '.planning/PROJECT.md'),
543
+ project_exists: project.exists,
507
544
  has_codebase_map: pathExistsInternal(cwd, '.planning/codebase'),
508
545
  planning_exists: pathExistsInternal(cwd, '.planning'),
509
546
  has_existing_code: hasCode,
@@ -514,7 +551,7 @@ function cmdInitNewProject(cwd, raw) {
514
551
  brave_search_available: hasBraveSearch,
515
552
  firecrawl_available: hasFirecrawl,
516
553
  exa_search_available: hasExaSearch,
517
- project_path: '.planning/PROJECT.md',
554
+ project_path: toPosixPath(node_path_1.default.relative(cwd, project.path)),
518
555
  };
519
556
  output(withProjectRoot(cwd, result), raw);
520
557
  }
@@ -537,6 +574,8 @@ function cmdInitNewMilestone(cwd, raw) {
537
574
  /* intentionally empty */
538
575
  }
539
576
  const wf = (config.workflow ?? {});
577
+ // D1 (261007-jkl): the PROJECT.md that answers for this cwd — the workstream's own, else the shared one.
578
+ const project = resolveProjectFile(cwd);
540
579
  const result = {
541
580
  researcher_model: resolveModelInternal(cwd, 'pp-project-researcher'),
542
581
  synthesizer_model: resolveModelInternal(cwd, 'pp-research-synthesizer'),
@@ -548,13 +587,17 @@ function cmdInitNewMilestone(cwd, raw) {
548
587
  latest_completed_milestone: latestCompleted?.version || null,
549
588
  latest_completed_milestone_name: latestCompleted?.name || null,
550
589
  phase_dir_count: phaseDirCount,
590
+ // CARRY-05: the archive directory comes from planningPaths, not a second
591
+ // copy of the reasoning rooted at planningRoot(cwd) — otherwise a
592
+ // partitioned project pointed callers at a repo-root path that does not
593
+ // exist.
551
594
  phase_archive_path: latestCompleted
552
- ? toPosixPath(node_path_1.default.relative(cwd, node_path_1.default.join(planningRoot(cwd), 'milestones', `${latestCompleted.version}-phases`)))
595
+ ? toPosixPath(node_path_1.default.relative(cwd, node_path_1.default.join(planningPaths(cwd).milestonesArchive, `${latestCompleted.version}-phases`)))
553
596
  : null,
554
- project_exists: pathExistsInternal(cwd, '.planning/PROJECT.md'),
597
+ project_exists: project.exists,
555
598
  roadmap_exists: node_fs_1.default.existsSync(node_path_1.default.join(planningDir(cwd), 'ROADMAP.md')),
556
599
  state_exists: node_fs_1.default.existsSync(node_path_1.default.join(planningDir(cwd), 'STATE.md')),
557
- project_path: '.planning/PROJECT.md',
600
+ project_path: toPosixPath(node_path_1.default.relative(cwd, project.path)),
558
601
  roadmap_path: toPosixPath(node_path_1.default.relative(cwd, node_path_1.default.join(planningDir(cwd), 'ROADMAP.md'))),
559
602
  state_path: toPosixPath(node_path_1.default.relative(cwd, node_path_1.default.join(planningDir(cwd), 'STATE.md'))),
560
603
  };
@@ -600,11 +643,13 @@ function cmdInitQuick(cwd, description, raw) {
600
643
  }
601
644
  function cmdInitIngestDocs(cwd, raw) {
602
645
  const config = loadConfig(cwd);
646
+ // D1 (261007-jkl): the PROJECT.md that answers for this cwd — the workstream's own, else the shared one.
647
+ const project = resolveProjectFile(cwd);
603
648
  const result = {
604
- project_exists: pathExistsInternal(cwd, '.planning/PROJECT.md'),
649
+ project_exists: project.exists,
605
650
  planning_exists: node_fs_1.default.existsSync(planningRoot(cwd)),
606
651
  ...getInitGitState(cwd),
607
- project_path: '.planning/PROJECT.md',
652
+ project_path: toPosixPath(node_path_1.default.relative(cwd, project.path)),
608
653
  commit_docs: config.commit_docs,
609
654
  };
610
655
  output(withProjectRoot(cwd, result), raw);
@@ -615,57 +660,38 @@ function cmdInitResume(cwd, raw) {
615
660
  const agentIdRaw = (0, shell_command_projection_cjs_1.platformReadSync)(node_path_1.default.join(planningRoot(cwd), 'current-agent-id.txt'));
616
661
  if (agentIdRaw !== null)
617
662
  interruptedAgentId = agentIdRaw.trim();
663
+ // D1 (261007-jkl): the PROJECT.md that answers for this cwd — the workstream's own, else the shared one.
664
+ const project = resolveProjectFile(cwd);
618
665
  const result = {
619
666
  state_exists: node_fs_1.default.existsSync(node_path_1.default.join(planningDir(cwd), 'STATE.md')),
620
667
  roadmap_exists: node_fs_1.default.existsSync(node_path_1.default.join(planningDir(cwd), 'ROADMAP.md')),
621
- project_exists: pathExistsInternal(cwd, '.planning/PROJECT.md'),
668
+ project_exists: project.exists,
622
669
  planning_exists: node_fs_1.default.existsSync(planningRoot(cwd)),
623
670
  state_path: toPosixPath(node_path_1.default.relative(cwd, node_path_1.default.join(planningDir(cwd), 'STATE.md'))),
624
671
  roadmap_path: toPosixPath(node_path_1.default.relative(cwd, node_path_1.default.join(planningDir(cwd), 'ROADMAP.md'))),
625
- project_path: '.planning/PROJECT.md',
672
+ project_path: toPosixPath(node_path_1.default.relative(cwd, project.path)),
626
673
  has_interrupted_agent: !!interruptedAgentId,
627
674
  interrupted_agent_id: interruptedAgentId,
628
675
  commit_docs: config.commit_docs,
629
676
  };
630
677
  output(withProjectRoot(cwd, result), raw);
631
678
  }
632
- function cmdInitVerifyWork(cwd, phase, raw) {
679
+ function cmdInitVerifyWork(cwd, phase, raw, options = {}) {
633
680
  if (!phase) {
634
681
  error('phase required for init verify-work');
635
682
  }
636
683
  const config = loadConfig(cwd);
637
- let phaseInfo = findPhaseInternal(cwd, phase);
638
- if (phaseInfo?.['archived']) {
639
- const roadmapPhase = getRoadmapPhaseInternal(cwd, phase);
640
- if (roadmapPhase?.['found']) {
641
- phaseInfo = null;
642
- }
643
- }
644
- if (!phaseInfo) {
645
- const roadmapPhase = getRoadmapPhaseInternal(cwd, phase);
646
- if (roadmapPhase?.['found']) {
647
- const phaseName = roadmapPhase['phase_name'];
648
- phaseInfo = {
649
- found: true,
650
- directory: null,
651
- phase_number: roadmapPhase['phase_number'],
652
- phase_name: phaseName,
653
- phase_slug: phaseName
654
- ? phaseName.toLowerCase().replace(/[^a-z0-9]+/g, '-').replace(/^-+|-+$/g, '')
655
- : null,
656
- plans: [],
657
- summaries: [],
658
- incomplete_plans: [],
659
- has_research: false,
660
- has_context: false,
661
- has_verification: false,
662
- };
663
- }
664
- }
684
+ const { phaseInfo } = resolvePhaseForInit(cwd, phase);
685
+ const tier = initPhaseTier(cwd, phase, options);
665
686
  const result = {
666
687
  planner_model: resolveModelInternal(cwd, 'pp-planner'),
667
688
  checker_model: resolveModelInternal(cwd, 'pp-plan-checker'),
668
689
  commit_docs: config.commit_docs,
690
+ plan_checker_enabled: tier.gates.plan_check,
691
+ plan_check_passes: tier.gates.plan_check_passes,
692
+ security_enforcement_enabled: tier.gates.security_enforcement,
693
+ nyquist_validation_enabled: tier.gates.nyquist_validation,
694
+ phase_tier: phaseTierSummary(tier),
669
695
  phase_found: !!phaseInfo,
670
696
  phase_dir: phaseInfo?.['directory'] || null,
671
697
  phase_number: phaseInfo?.['phase_number'] || null,
@@ -676,49 +702,7 @@ function cmdInitVerifyWork(cwd, phase, raw) {
676
702
  }
677
703
  function cmdInitPhaseOp(cwd, phase, raw) {
678
704
  const config = loadConfig(cwd);
679
- let phaseInfo = findPhaseInternal(cwd, phase);
680
- if (phaseInfo?.['archived']) {
681
- const roadmapPhase = getRoadmapPhaseInternal(cwd, phase);
682
- if (roadmapPhase?.['found']) {
683
- const phaseName = roadmapPhase['phase_name'];
684
- phaseInfo = {
685
- found: true,
686
- directory: null,
687
- phase_number: roadmapPhase['phase_number'],
688
- phase_name: phaseName,
689
- phase_slug: phaseName
690
- ? phaseName.toLowerCase().replace(/[^a-z0-9]+/g, '-').replace(/^-+|-+$/g, '')
691
- : null,
692
- plans: [],
693
- summaries: [],
694
- incomplete_plans: [],
695
- has_research: false,
696
- has_context: false,
697
- has_verification: false,
698
- };
699
- }
700
- }
701
- if (!phaseInfo) {
702
- const roadmapPhase = getRoadmapPhaseInternal(cwd, phase);
703
- if (roadmapPhase?.['found']) {
704
- const phaseName = roadmapPhase['phase_name'];
705
- phaseInfo = {
706
- found: true,
707
- directory: null,
708
- phase_number: roadmapPhase['phase_number'],
709
- phase_name: phaseName,
710
- phase_slug: phaseName
711
- ? phaseName.toLowerCase().replace(/[^a-z0-9]+/g, '-').replace(/^-+|-+$/g, '')
712
- : null,
713
- plans: [],
714
- summaries: [],
715
- incomplete_plans: [],
716
- has_research: false,
717
- has_context: false,
718
- has_verification: false,
719
- };
720
- }
721
- }
705
+ const { phaseInfo } = resolvePhaseForInit(cwd, phase);
722
706
  const phaseDir = phaseInfo?.['directory'] || null;
723
707
  const phaseNumber = phaseInfo?.['phase_number'] || null;
724
708
  const phaseName = phaseInfo?.['phase_name'] || null;
@@ -931,6 +915,8 @@ function cmdInitMilestoneOp(cwd, raw) {
931
915
  catch {
932
916
  /* intentionally empty */
933
917
  }
918
+ // D1 (261007-jkl): the PROJECT.md that answers for this cwd — the workstream's own, else the shared one.
919
+ const project = resolveProjectFile(cwd);
934
920
  const result = {
935
921
  commit_docs: config.commit_docs,
936
922
  milestone_version: milestone['version'],
@@ -941,7 +927,7 @@ function cmdInitMilestoneOp(cwd, raw) {
941
927
  all_phases_complete: phaseCount > 0 && phaseCount === completedPhases,
942
928
  archived_milestones: archivedMilestones,
943
929
  archive_count: archivedMilestones.length,
944
- project_exists: pathExistsInternal(cwd, '.planning/PROJECT.md'),
930
+ project_exists: project.exists,
945
931
  roadmap_exists: node_fs_1.default.existsSync(node_path_1.default.join(planningDir(cwd), 'ROADMAP.md')),
946
932
  state_exists: node_fs_1.default.existsSync(node_path_1.default.join(planningDir(cwd), 'STATE.md')),
947
933
  archive_exists: node_fs_1.default.existsSync(node_path_1.default.join(planningRoot(cwd), 'archive')),
@@ -1230,6 +1216,8 @@ function cmdInitManager(cwd, raw) {
1230
1216
  plan: sanitizeFlags(mgrFlags?.['plan']),
1231
1217
  execute: sanitizeFlags(mgrFlags?.['execute']),
1232
1218
  };
1219
+ // D1 (261007-jkl): the PROJECT.md that answers for this cwd — the workstream's own, else the shared one.
1220
+ const project = resolveProjectFile(cwd);
1233
1221
  const result = {
1234
1222
  milestone_version: milestone['version'],
1235
1223
  milestone_name: milestone['name'],
@@ -1240,7 +1228,7 @@ function cmdInitManager(cwd, raw) {
1240
1228
  recommended_actions: filteredActions,
1241
1229
  waiting_signal: waitingSignal,
1242
1230
  all_complete: completedCount === nonBacklogPhases.length && nonBacklogPhases.length > 0,
1243
- project_exists: pathExistsInternal(cwd, '.planning/PROJECT.md'),
1231
+ project_exists: project.exists,
1244
1232
  roadmap_exists: true,
1245
1233
  state_exists: true,
1246
1234
  manager_flags: managerFlags,
@@ -1362,6 +1350,8 @@ function cmdInitProgress(cwd, raw) {
1362
1350
  if (pauseMatch)
1363
1351
  pausedAt = pauseMatch[1].trim();
1364
1352
  }
1353
+ // D1 (261007-jkl): the PROJECT.md that answers for this cwd — the workstream's own, else the shared one.
1354
+ const project = resolveProjectFile(cwd);
1365
1355
  const result = {
1366
1356
  executor_model: resolveModelInternal(cwd, 'pp-executor'),
1367
1357
  planner_model: resolveModelInternal(cwd, 'pp-planner'),
@@ -1376,12 +1366,12 @@ function cmdInitProgress(cwd, raw) {
1376
1366
  next_phase: nextPhase,
1377
1367
  paused_at: pausedAt,
1378
1368
  has_work_in_progress: !!currentPhase,
1379
- project_exists: pathExistsInternal(cwd, '.planning/PROJECT.md'),
1369
+ project_exists: project.exists,
1380
1370
  roadmap_exists: node_fs_1.default.existsSync(node_path_1.default.join(planningDir(cwd), 'ROADMAP.md')),
1381
1371
  state_exists: node_fs_1.default.existsSync(node_path_1.default.join(planningDir(cwd), 'STATE.md')),
1382
1372
  state_path: toPosixPath(node_path_1.default.relative(cwd, node_path_1.default.join(planningDir(cwd), 'STATE.md'))),
1383
1373
  roadmap_path: toPosixPath(node_path_1.default.relative(cwd, node_path_1.default.join(planningDir(cwd), 'ROADMAP.md'))),
1384
- project_path: '.planning/PROJECT.md',
1374
+ project_path: toPosixPath(node_path_1.default.relative(cwd, project.path)),
1385
1375
  config_path: toPosixPath(node_path_1.default.relative(cwd, node_path_1.default.join(planningDir(cwd), 'config.json'))),
1386
1376
  };
1387
1377
  output(withProjectRoot(cwd, result), raw);
@@ -27,6 +27,10 @@ const shell_command_projection_cjs_1 = require("./shell-command-projection.cjs")
27
27
  */
28
28
  const PROFILES = Object.freeze({
29
29
  core: Object.freeze([
30
+ // init is the front door every installer/hook/no-project message
31
+ // names, so it ships in every profile — a minimal install must not print a
32
+ // start command it did not install.
33
+ 'init',
30
34
  'new-project',
31
35
  'discuss-phase',
32
36
  'plan-phase',
@@ -38,6 +42,7 @@ const PROFILES = Object.freeze({
38
42
  ]),
39
43
  standard: Object.freeze([
40
44
  // Core loop
45
+ 'init',
41
46
  'new-project',
42
47
  'discuss-phase',
43
48
  'plan-phase',