nubos-pilot 0.1.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 (273) hide show
  1. package/agents/np-ai-researcher.md +140 -0
  2. package/agents/np-code-fixer.md +363 -0
  3. package/agents/np-code-reviewer.md +351 -0
  4. package/agents/np-domain-researcher.md +136 -0
  5. package/agents/np-eval-auditor.md +167 -0
  6. package/agents/np-eval-planner.md +153 -0
  7. package/agents/np-executor.md +72 -0
  8. package/agents/np-framework-selector.md +171 -0
  9. package/agents/np-nyquist-auditor.md +185 -0
  10. package/agents/np-plan-checker.md +165 -0
  11. package/agents/np-planner.md +199 -0
  12. package/agents/np-researcher.md +150 -0
  13. package/agents/np-security-auditor.md +206 -0
  14. package/agents/np-ui-auditor.md +369 -0
  15. package/agents/np-ui-checker.md +192 -0
  16. package/agents/np-ui-researcher.md +324 -0
  17. package/agents/np-verifier.md +79 -0
  18. package/bin/check-coverage.cjs +40 -0
  19. package/bin/check-workflows.cjs +171 -0
  20. package/bin/check-workflows.test.cjs +208 -0
  21. package/bin/install.js +500 -0
  22. package/bin/np-tools/_commands.cjs +70 -0
  23. package/bin/np-tools/add-tests.cjs +171 -0
  24. package/bin/np-tools/add-tests.test.cjs +122 -0
  25. package/bin/np-tools/add-todo.cjs +108 -0
  26. package/bin/np-tools/add-todo.test.cjs +112 -0
  27. package/bin/np-tools/agent-skills.cjs +14 -0
  28. package/bin/np-tools/agent-skills.test.cjs +42 -0
  29. package/bin/np-tools/ai-integration-phase.cjs +109 -0
  30. package/bin/np-tools/ai-integration-phase.test.cjs +123 -0
  31. package/bin/np-tools/askuser.cjs +53 -0
  32. package/bin/np-tools/askuser.test.cjs +49 -0
  33. package/bin/np-tools/autonomous.cjs +69 -0
  34. package/bin/np-tools/autonomous.test.cjs +74 -0
  35. package/bin/np-tools/checkpoint.cjs +101 -0
  36. package/bin/np-tools/checkpoint.test.cjs +119 -0
  37. package/bin/np-tools/code-review.cjs +133 -0
  38. package/bin/np-tools/code-review.test.cjs +96 -0
  39. package/bin/np-tools/commit-task.cjs +120 -0
  40. package/bin/np-tools/commit-task.test.cjs +160 -0
  41. package/bin/np-tools/commit.cjs +103 -0
  42. package/bin/np-tools/commit.test.cjs +93 -0
  43. package/bin/np-tools/config.cjs +101 -0
  44. package/bin/np-tools/config.test.cjs +71 -0
  45. package/bin/np-tools/discuss-phase-power.cjs +265 -0
  46. package/bin/np-tools/discuss-phase-power.test.cjs +242 -0
  47. package/bin/np-tools/discuss-phase.cjs +132 -0
  48. package/bin/np-tools/discuss-phase.test.cjs +148 -0
  49. package/bin/np-tools/dispatch.cjs +116 -0
  50. package/bin/np-tools/doctor.cjs +242 -0
  51. package/bin/np-tools/eval-review.cjs +116 -0
  52. package/bin/np-tools/eval-review.test.cjs +123 -0
  53. package/bin/np-tools/execute-phase.cjs +182 -0
  54. package/bin/np-tools/execute-phase.test.cjs +116 -0
  55. package/bin/np-tools/execute-plan.cjs +124 -0
  56. package/bin/np-tools/execute-plan.test.cjs +82 -0
  57. package/bin/np-tools/help.cjs +28 -0
  58. package/bin/np-tools/help.test.cjs +29 -0
  59. package/bin/np-tools/init-dispatch.test.cjs +91 -0
  60. package/bin/np-tools/metrics.cjs +97 -0
  61. package/bin/np-tools/metrics.test.cjs +188 -0
  62. package/bin/np-tools/new-milestone.cjs +288 -0
  63. package/bin/np-tools/new-milestone.test.cjs +166 -0
  64. package/bin/np-tools/new-project.cjs +284 -0
  65. package/bin/np-tools/new-project.test.cjs +165 -0
  66. package/bin/np-tools/next.cjs +7 -0
  67. package/bin/np-tools/next.test.cjs +30 -0
  68. package/bin/np-tools/park.cjs +48 -0
  69. package/bin/np-tools/park.test.cjs +50 -0
  70. package/bin/np-tools/pause-work.cjs +24 -0
  71. package/bin/np-tools/pause-work.test.cjs +74 -0
  72. package/bin/np-tools/phase.cjs +71 -0
  73. package/bin/np-tools/phase.test.cjs +81 -0
  74. package/bin/np-tools/plan-diff.cjs +57 -0
  75. package/bin/np-tools/plan-diff.test.cjs +134 -0
  76. package/bin/np-tools/plan-milestone-gaps.cjs +115 -0
  77. package/bin/np-tools/plan-milestone-gaps.test.cjs +122 -0
  78. package/bin/np-tools/plan-phase.cjs +350 -0
  79. package/bin/np-tools/plan-phase.test.cjs +263 -0
  80. package/bin/np-tools/progress.cjs +7 -0
  81. package/bin/np-tools/progress.test.cjs +44 -0
  82. package/bin/np-tools/queue.cjs +213 -0
  83. package/bin/np-tools/research-phase.cjs +144 -0
  84. package/bin/np-tools/research-phase.test.cjs +154 -0
  85. package/bin/np-tools/reset-slice.cjs +17 -0
  86. package/bin/np-tools/reset-slice.test.cjs +96 -0
  87. package/bin/np-tools/resolve-model.cjs +110 -0
  88. package/bin/np-tools/resolve-model.test.cjs +200 -0
  89. package/bin/np-tools/resume-work.cjs +76 -0
  90. package/bin/np-tools/resume-work.test.cjs +91 -0
  91. package/bin/np-tools/skip.cjs +48 -0
  92. package/bin/np-tools/skip.test.cjs +66 -0
  93. package/bin/np-tools/slug.cjs +34 -0
  94. package/bin/np-tools/slug.test.cjs +46 -0
  95. package/bin/np-tools/state.cjs +16 -0
  96. package/bin/np-tools/state.test.cjs +40 -0
  97. package/bin/np-tools/stats.cjs +151 -0
  98. package/bin/np-tools/stats.test.cjs +118 -0
  99. package/bin/np-tools/triage.cjs +128 -0
  100. package/bin/np-tools/ui-phase.cjs +108 -0
  101. package/bin/np-tools/ui-phase.test.cjs +121 -0
  102. package/bin/np-tools/ui-review.cjs +108 -0
  103. package/bin/np-tools/ui-review.test.cjs +120 -0
  104. package/bin/np-tools/undo-task.cjs +31 -0
  105. package/bin/np-tools/undo-task.test.cjs +117 -0
  106. package/bin/np-tools/undo.cjs +43 -0
  107. package/bin/np-tools/undo.test.cjs +120 -0
  108. package/bin/np-tools/unpark.cjs +48 -0
  109. package/bin/np-tools/unpark.test.cjs +50 -0
  110. package/bin/np-tools/verify-work.cjs +186 -0
  111. package/bin/np-tools/verify-work.test.cjs +97 -0
  112. package/docs/adr/0001-no-daemon-invariant.md +82 -0
  113. package/docs/adr/0002-zero-runtime-dependencies.md +90 -0
  114. package/docs/adr/0003-max-six-unit-types.md +85 -0
  115. package/docs/adr/0004-atomic-commit-per-unit.md +102 -0
  116. package/docs/adr/0005-three-orthogonal-file-trees.md +98 -0
  117. package/docs/adr/0006-yaml-dependency-amendment.md +60 -0
  118. package/docs/adr/README.md +27 -0
  119. package/docs/agent-frontmatter-schema.md +84 -0
  120. package/docs/phase-artifact-schemas.md +292 -0
  121. package/docs/phase-directory-layout.md +82 -0
  122. package/lib/__tests__/README.md +1 -0
  123. package/lib/agents.cjs +98 -0
  124. package/lib/agents.test.cjs +286 -0
  125. package/lib/askuser.cjs +36 -0
  126. package/lib/askuser.test.cjs +310 -0
  127. package/lib/checkpoint.cjs +135 -0
  128. package/lib/checkpoint.test.cjs +184 -0
  129. package/lib/core.cjs +165 -0
  130. package/lib/core.test.cjs +405 -0
  131. package/lib/fixtures/README.md +1 -0
  132. package/lib/fixtures/phase-tree/README.md +1 -0
  133. package/lib/fixtures/plans/cycle/PLAN.md +16 -0
  134. package/lib/fixtures/plans/cycle/tasks/T-01.md +20 -0
  135. package/lib/fixtures/plans/cycle/tasks/T-02.md +20 -0
  136. package/lib/fixtures/plans/cycle/tasks/T-03.md +20 -0
  137. package/lib/fixtures/plans/linear/PLAN.md +16 -0
  138. package/lib/fixtures/plans/linear/tasks/T-01.md +20 -0
  139. package/lib/fixtures/plans/linear/tasks/T-02.md +20 -0
  140. package/lib/fixtures/plans/linear/tasks/T-03.md +20 -0
  141. package/lib/fixtures/plans/parallel/PLAN.md +16 -0
  142. package/lib/fixtures/plans/parallel/tasks/T-01.md +20 -0
  143. package/lib/fixtures/plans/parallel/tasks/T-02.md +20 -0
  144. package/lib/fixtures/plans/parallel/tasks/T-03.md +20 -0
  145. package/lib/fixtures/plans/wave-conflict/PLAN.md +16 -0
  146. package/lib/fixtures/plans/wave-conflict/tasks/T-01.md +20 -0
  147. package/lib/fixtures/plans/wave-conflict/tasks/T-02.md +20 -0
  148. package/lib/fixtures/roadmap/ROADMAP-malformed.md +3 -0
  149. package/lib/fixtures/roadmap/ROADMAP-minimal.md +51 -0
  150. package/lib/fixtures/roadmap/roadmap-malformed.yaml +7 -0
  151. package/lib/fixtures/roadmap/roadmap-minimal.yaml +40 -0
  152. package/lib/fixtures/roadmap/roadmap-ten-phases.yaml +101 -0
  153. package/lib/fixtures/templates/phase-context.md +6 -0
  154. package/lib/fixtures/templates/plan-skeleton.md +6 -0
  155. package/lib/frontmatter.cjs +251 -0
  156. package/lib/frontmatter.test.cjs +177 -0
  157. package/lib/gaps.cjs +197 -0
  158. package/lib/gaps.test.cjs +200 -0
  159. package/lib/git.cjs +207 -0
  160. package/lib/git.test.cjs +305 -0
  161. package/lib/install/agents-md.cjs +77 -0
  162. package/lib/install/backup.cjs +70 -0
  163. package/lib/install/codex-toml.cjs +440 -0
  164. package/lib/install/managed-block.cjs +30 -0
  165. package/lib/install/manifest.cjs +148 -0
  166. package/lib/install/mcp-writer.cjs +127 -0
  167. package/lib/install/runtime-detect.cjs +44 -0
  168. package/lib/install/staging.cjs +149 -0
  169. package/lib/metrics-aggregate.cjs +229 -0
  170. package/lib/metrics-aggregate.test.cjs +192 -0
  171. package/lib/metrics.cjs +120 -0
  172. package/lib/metrics.test.cjs +182 -0
  173. package/lib/model-aliases.regression.test.cjs +16 -0
  174. package/lib/model-profiles.cjs +42 -0
  175. package/lib/model-profiles.test.cjs +61 -0
  176. package/lib/next.cjs +236 -0
  177. package/lib/next.test.cjs +194 -0
  178. package/lib/phase.cjs +95 -0
  179. package/lib/phase.test.cjs +189 -0
  180. package/lib/plan-checker-contract.test.cjs +72 -0
  181. package/lib/plan-diff.cjs +173 -0
  182. package/lib/plan-diff.test.cjs +217 -0
  183. package/lib/plan.cjs +85 -0
  184. package/lib/plan.test.cjs +263 -0
  185. package/lib/progress.cjs +95 -0
  186. package/lib/progress.test.cjs +116 -0
  187. package/lib/researcher-contract.test.cjs +61 -0
  188. package/lib/roadmap-render.cjs +206 -0
  189. package/lib/roadmap-render.test.cjs +121 -0
  190. package/lib/roadmap.cjs +416 -0
  191. package/lib/roadmap.test.cjs +371 -0
  192. package/lib/runtime/_contract.test.cjs +61 -0
  193. package/lib/runtime/_readline.cjs +119 -0
  194. package/lib/runtime/_readline.test.cjs +126 -0
  195. package/lib/runtime/claude.cjs +48 -0
  196. package/lib/runtime/claude.test.cjs +101 -0
  197. package/lib/runtime/codex.cjs +35 -0
  198. package/lib/runtime/codex.test.cjs +114 -0
  199. package/lib/runtime/gemini.cjs +35 -0
  200. package/lib/runtime/gemini.test.cjs +109 -0
  201. package/lib/runtime/index.cjs +49 -0
  202. package/lib/runtime/index.test.cjs +181 -0
  203. package/lib/runtime/opencode.cjs +35 -0
  204. package/lib/runtime/opencode.test.cjs +124 -0
  205. package/lib/state.cjs +205 -0
  206. package/lib/state.test.cjs +264 -0
  207. package/lib/surface-audit.test.cjs +46 -0
  208. package/lib/tasks.cjs +327 -0
  209. package/lib/tasks.test.cjs +389 -0
  210. package/lib/template.cjs +66 -0
  211. package/lib/template.test.cjs +159 -0
  212. package/lib/undo.cjs +179 -0
  213. package/lib/undo.test.cjs +261 -0
  214. package/lib/verify.cjs +116 -0
  215. package/lib/verify.test.cjs +187 -0
  216. package/np-tools.cjs +303 -0
  217. package/package.json +39 -0
  218. package/templates/AI-SPEC.md +90 -0
  219. package/templates/CONTEXT.md +32 -0
  220. package/templates/PLAN.md +69 -0
  221. package/templates/PROJECT.md +60 -0
  222. package/templates/REQUIREMENTS.md +38 -0
  223. package/templates/SECURITY.md +61 -0
  224. package/templates/UI-SPEC.md +64 -0
  225. package/templates/VALIDATION.md +76 -0
  226. package/templates/claude/payload/README.md +11 -0
  227. package/templates/opencode/opencode.json +6 -0
  228. package/templates/opencode/payload/AGENTS.md +9 -0
  229. package/workflows/add-backlog.md +212 -0
  230. package/workflows/add-tests.md +69 -0
  231. package/workflows/add-todo.md +222 -0
  232. package/workflows/ai-integration-phase.md +230 -0
  233. package/workflows/autonomous.md +94 -0
  234. package/workflows/cleanup.md +325 -0
  235. package/workflows/code-review-fix.md +435 -0
  236. package/workflows/code-review.md +447 -0
  237. package/workflows/discuss-phase-assumptions.md +269 -0
  238. package/workflows/discuss-phase-power.md +139 -0
  239. package/workflows/discuss-phase.md +386 -0
  240. package/workflows/dispatch.md +9 -0
  241. package/workflows/doctor.md +10 -0
  242. package/workflows/eval-review.md +243 -0
  243. package/workflows/execute-phase.md +142 -0
  244. package/workflows/execute-plan.md +82 -0
  245. package/workflows/help.md +8 -0
  246. package/workflows/new-milestone.md +166 -0
  247. package/workflows/new-project.md +213 -0
  248. package/workflows/next.md +8 -0
  249. package/workflows/note.md +244 -0
  250. package/workflows/park.md +29 -0
  251. package/workflows/pause-work.md +34 -0
  252. package/workflows/plan-milestone-gaps.md +233 -0
  253. package/workflows/plan-phase.md +351 -0
  254. package/workflows/progress.md +8 -0
  255. package/workflows/queue.md +9 -0
  256. package/workflows/research-phase.md +327 -0
  257. package/workflows/reset-slice.md +39 -0
  258. package/workflows/resume-work.md +79 -0
  259. package/workflows/review.md +489 -0
  260. package/workflows/secure-phase.md +209 -0
  261. package/workflows/session-report.md +243 -0
  262. package/workflows/skip.md +29 -0
  263. package/workflows/state.md +7 -0
  264. package/workflows/stats.md +170 -0
  265. package/workflows/thread.md +214 -0
  266. package/workflows/triage.md +9 -0
  267. package/workflows/ui-phase.md +246 -0
  268. package/workflows/ui-review.md +222 -0
  269. package/workflows/undo-task.md +42 -0
  270. package/workflows/undo.md +55 -0
  271. package/workflows/unpark.md +29 -0
  272. package/workflows/validate-phase.md +231 -0
  273. package/workflows/verify-work.md +83 -0
@@ -0,0 +1,351 @@
1
+ ---
2
+ command: np:plan-phase
3
+ description: Creates PLAN.md for a phase with a 2-iteration planner ↔ plan-checker verification loop.
4
+ ---
5
+
6
+ # np:plan-phase
7
+
8
+ Minimum Phase-5 scope: spawn `agents/np-planner.md` (opus) to write PLAN.md,
9
+ spawn `agents/np-plan-checker.md` (opus) to verify, iterate at most twice
10
+ (D-15), then either commit or escalate via `askuser` gate (D-17). All
11
+ state — including the verification audit trail — lives in append-only
12
+ `{phase_dir}/{padded}-PLAN-REVIEW.md` (D-16).
13
+
14
+ **Scope note (Phase 5):** No advisor subagent, no `--chain` auto-advance, no
15
+ multi-plan batching. One phase → one run → one PLAN.md (± `tasks/` when
16
+ promotion triggers fire per Plan 05-04).
17
+
18
+ ## Initialize
19
+
20
+ ```bash
21
+ INIT=$(node np-tools.cjs init plan-phase init "$PHASE")
22
+ if [[ "$INIT" == @file:* ]]; then INIT=$(cat "${INIT#@file:}"); fi
23
+ AGENT_SKILLS_PLANNER=$(node np-tools.cjs agent-skills planner 2>/dev/null)
24
+ AGENT_SKILLS_CHECKER=$(node np-tools.cjs agent-skills plan-checker 2>/dev/null)
25
+ RUNTIME=$(node -e "console.log(require('./lib/runtime/index.cjs').detect().runtime)")
26
+ ```
27
+
28
+ Parse JSON for: `phase`, `padded`, `phase_dir`, `phase_name`, `goal`,
29
+ `requirements`, `success_criteria`, `has_context`, `has_research`, `has_plan`,
30
+ `context_path`, `research_path`, `plan_review_path`, `planner_tier`,
31
+ `checker_tier`, `agent_skills`.
32
+
33
+ `PLAN_ID` and `TASK_ID` default to `${padded}-01` / `${padded}-plan` for the
34
+ metrics records below; the planner loop itself is the single Plan 01 task from
35
+ the runtime's point of view.
36
+
37
+ ```bash
38
+ PLAN_ID="${padded}-01"
39
+ TASK_ID="${padded}-plan"
40
+ ```
41
+
42
+ ## Pre-Flight Guards
43
+
44
+ <pre_flight>
45
+ Three independent gates. Each uses `np-tools.cjs askuser` (never a bare
46
+ host-specific prompt tool — executor-host portability invariant per Phase 3 SC-5).
47
+
48
+ ### Gate 1 — Missing CONTEXT.md
49
+
50
+ If `has_context == false`:
51
+
52
+ ```bash
53
+ CHOICE=$(node np-tools.cjs askuser --json '{
54
+ "type": "select",
55
+ "header": "Missing CONTEXT.md",
56
+ "question": "CONTEXT.md is not present for this phase. Continue?",
57
+ "options": [
58
+ {"label": "Run /np:discuss-phase first", "description": "Recommended — capture user decisions before planning."},
59
+ {"label": "Continue without CONTEXT.md", "description": "Not recommended — planner will work from roadmap goal alone."},
60
+ {"label": "Abort", "description": "Exit without changes."}
61
+ ]
62
+ }')
63
+ case "$CHOICE" in
64
+ "Run /np:discuss-phase"*) echo "Run: /np:discuss-phase $PHASE"; exit 0 ;;
65
+ "Abort") exit 0 ;;
66
+ esac
67
+ ```
68
+
69
+ ### Gate 2 — Missing RESEARCH.md
70
+
71
+ If `has_research == false` AND workflow config requires it:
72
+
73
+ ```bash
74
+ CHOICE=$(node np-tools.cjs askuser --json '{
75
+ "type": "select",
76
+ "header": "Missing RESEARCH.md",
77
+ "question": "RESEARCH.md is not present for this phase. Continue?",
78
+ "options": [
79
+ {"label": "Run /np:research-phase first", "description": "Recommended — stack + pitfalls guide planning."},
80
+ {"label": "Skip research", "description": "Planner proceeds with CONTEXT-only context."},
81
+ {"label": "Abort", "description": "Exit without changes."}
82
+ ]
83
+ }')
84
+ case "$CHOICE" in
85
+ "Run /np:research-phase"*) echo "Run: /np:research-phase $PHASE"; exit 0 ;;
86
+ "Abort") exit 0 ;;
87
+ esac
88
+ ```
89
+
90
+ ### Gate 3 — PLAN.md already exists
91
+
92
+ If `has_plan == true`:
93
+
94
+ ```bash
95
+ CHOICE=$(node np-tools.cjs askuser --json '{
96
+ "type": "select",
97
+ "header": "PLAN.md already exists",
98
+ "question": "A PLAN.md is already present for this phase. Overwrite?",
99
+ "options": [
100
+ {"label": "Overwrite", "description": "Back up current PLAN.md to PLAN.md.archive.md and replan."},
101
+ {"label": "Abort", "description": "Exit without changes."}
102
+ ]
103
+ }')
104
+ case "$CHOICE" in
105
+ "Abort") exit 0 ;;
106
+ "Overwrite")
107
+ for p in "$phase_dir"/*-PLAN.md; do
108
+ [ -f "$p" ] && mv "$p" "$p.archive.md"
109
+ done
110
+ ;;
111
+ esac
112
+ ```
113
+ </pre_flight>
114
+
115
+ ## Downstream Awareness
116
+
117
+ <!-- downstream_awareness -->
118
+ **PLAN.md feeds into:**
119
+
120
+ 1. **plan-checker** — Goal-backward verification. Every task must trace back
121
+ to one or more requirements from the roadmap, and every success criterion
122
+ must have at least one covering task.
123
+ 2. **executor** (`/np:execute-phase`) — Reads PLAN.md as a prompt, not a doc.
124
+ Tasks must be atomic (one test, one implementation, one commit each).
125
+ 3. **verifier** (Phase 10) — Re-runs goal-backward checks against executed
126
+ artifacts. Same taxonomy as plan-checker.
127
+
128
+ **PLAN-REVIEW.md feeds into:**
129
+
130
+ - The user (audit trail on every iteration, preserved across abort/restart).
131
+ - Phase 6 `np:undo` (reads PLAN-REVIEW.md to detect mid-iteration state).
132
+ - Phase 10 review commands (verdict history for regression analysis).
133
+ <!-- /downstream_awareness -->
134
+
135
+ ## Philosophy
136
+
137
+ <!-- philosophy -->
138
+ A plan is a **prompt**, not a document. If the executor has to re-interpret
139
+ the plan, it will drift from what the user asked for. The plan-checker is an
140
+ **adversarial reader** — it assumes the planner missed something and tries to
141
+ find it before the executor burns context discovering the gap.
142
+
143
+ Two iterations is the hard ceiling (D-15). If the planner cannot satisfy the
144
+ checker in 2 rounds, the loop is pathological — either the context is
145
+ unclear or the goal is ambiguous. The 3-option escalation gate hands control
146
+ back to the user rather than spinning indefinitely.
147
+
148
+ **Append-only audit trail (D-16):** PLAN-REVIEW.md is never truncated, even
149
+ on abort. Every iteration adds a dated section. This lets the user (and
150
+ future agents) replay exactly what the planner produced and what the checker
151
+ flagged, commit-by-commit.
152
+ <!-- /philosophy -->
153
+
154
+ ## Scope Guardrail
155
+
156
+ <!-- scope_guardrail -->
157
+ **Do:**
158
+ - Spawn planner → plan-checker in strict sequence.
159
+ - Append every verdict to PLAN-REVIEW.md before deciding pass/fail.
160
+ - Commit PLAN.md only after a `passed` verdict OR an explicit
161
+ "commit-with-warnings" user choice on the iter-2 gate.
162
+ - Scaffold `tasks/` directory ONLY when `plan-phase-promote-check` returns
163
+ `promote: true`. No override flag (D-20).
164
+
165
+ **Don't:**
166
+ - Run a third planner iteration. The loop is fixed at 2 rounds.
167
+ - Modify PLAN-REVIEW.md except via `np-tools.cjs init plan-phase plan-review-append`.
168
+ - Delete PLAN-REVIEW.md on abort (D-17).
169
+ - Promote to `tasks/` based on planner judgement — deterministic triggers only.
170
+ - Invoke host-specific prompt tools directly. Always `np-tools.cjs askuser --json …`.
171
+ <!-- /scope_guardrail -->
172
+
173
+ ## Verification Loop
174
+
175
+ The loop runs at most twice. Each iteration: spawn planner → spawn plan-checker
176
+ → append verdict → decide.
177
+
178
+ ```bash
179
+ LAST_FINDINGS=""
180
+ for ITER in 1 2; do
181
+ MODE="initial"
182
+ [ "$ITER" = "2" ] && MODE="revise"
183
+
184
+ # --- Spawn planner ---
185
+ PLANNER_START=$(node np-tools.cjs metrics start-timestamp)
186
+ PLANNER_MODEL=$(node np-tools.cjs resolve-model planner --profile balanced)
187
+ # Spawn agent=np-planner tier=opus model=$PLANNER_MODEL mode=$MODE phase=$PHASE
188
+ # prior_findings=$LAST_FINDINGS agent_skills=$AGENT_SKILLS_PLANNER
189
+ # (Abstract spawn-call — the host runtime resolves `tier: opus` to the
190
+ # concrete provider model; the orchestrator does NOT hard-code a model ID.)
191
+ PLANNER_END=$(node np-tools.cjs metrics end-timestamp)
192
+ node np-tools.cjs metrics record \
193
+ --agent np-planner --tier opus --resolved-model "$PLANNER_MODEL" \
194
+ --phase "$PHASE" --plan "$PLAN_ID" --task "$TASK_ID" \
195
+ --started "$PLANNER_START" --ended "$PLANNER_END" \
196
+ --tokens-in "${TOKENS_IN:-0}" --tokens-out "${TOKENS_OUT:-0}" \
197
+ --retry-count 0 --status ok --runtime "$RUNTIME"
198
+
199
+ # --- Spawn plan-checker ---
200
+ CHECKER_START=$(node np-tools.cjs metrics start-timestamp)
201
+ CHECKER_MODEL=$(node np-tools.cjs resolve-model plan-checker --profile balanced)
202
+ # Spawn agent=np-plan-checker tier=opus model=$CHECKER_MODEL phase=$PHASE plan=$PLAN_PATH
203
+ # agent_skills=$AGENT_SKILLS_CHECKER
204
+ # Checker writes YAML verdict to $VERDICT_YAML_PATH; orchestrator converts
205
+ # to JSON and passes to plan-review-append below.
206
+ CHECKER_END=$(node np-tools.cjs metrics end-timestamp)
207
+ node np-tools.cjs metrics record \
208
+ --agent np-plan-checker --tier opus --resolved-model "$CHECKER_MODEL" \
209
+ --phase "$PHASE" --plan "$PLAN_ID" --task "$TASK_ID" \
210
+ --started "$CHECKER_START" --ended "$CHECKER_END" \
211
+ --tokens-in "${TOKENS_IN:-0}" --tokens-out "${TOKENS_OUT:-0}" \
212
+ --retry-count 0 --status ok --runtime "$RUNTIME"
213
+
214
+ VERDICT_JSON_PATH="$phase_dir/.tmp-verdict-$ITER.json"
215
+ # (verdict JSON: {status: passed|issues_found, findings: [...] })
216
+
217
+ node np-tools.cjs init plan-phase plan-review-append "$PHASE" "$ITER" "$VERDICT_JSON_PATH"
218
+
219
+ STATUS=$(node -e "console.log(JSON.parse(require('fs').readFileSync(process.argv[1],'utf-8')).status)" "$VERDICT_JSON_PATH")
220
+ if [ "$STATUS" = "passed" ]; then
221
+ break
222
+ fi
223
+
224
+ LAST_FINDINGS="$VERDICT_JSON_PATH"
225
+
226
+ if [ "$ITER" = "2" ]; then
227
+ # --- Iteration-2 escalation gate (D-17 verbatim) ---
228
+ CHOICE=$(node np-tools.cjs askuser --json '{
229
+ "type": "select",
230
+ "header": "Plan-Checker Stall",
231
+ "question": "Plan-Checker hat 2 Iterationen lang Fail gemeldet. Was tun?",
232
+ "options": [
233
+ {"label": "Plan mit Warnings committen", "description": "PLAN.md wird committet; PLAN-REVIEW.md bleibt als Audit."},
234
+ {"label": "Abort (Plan verwerfen)", "description": "PLAN.md wird gelöscht, PLAN-REVIEW.md bleibt."},
235
+ {"label": "Manuell editieren und erneut prüfen", "description": "Plan-Checker wird nach manueller Bearbeitung neu aufgerufen."}
236
+ ]
237
+ }')
238
+ case "$CHOICE" in
239
+ "Abort"*)
240
+ node np-tools.cjs init plan-phase plan-phase-abort "$PHASE"
241
+ exit 1
242
+ ;;
243
+ "Plan mit Warnings"*)
244
+ # proceed to commit below — PLAN.md stays as-is
245
+ break
246
+ ;;
247
+ "Manuell editieren"*)
248
+ node np-tools.cjs askuser --json '{"type":"input","question":"Edit PLAN.md in your editor, then press Enter to re-check."}'
249
+ # Re-spawn plan-checker against the edited PLAN.md; append as iter 3
250
+ # (documented exception — user-driven, not automatic).
251
+ # Loop exits after this branch.
252
+ break
253
+ ;;
254
+ esac
255
+ fi
256
+ done
257
+ ```
258
+
259
+ ## Promotion Decision (Plan 05-04)
260
+
261
+ <!-- answer_validation -->
262
+ After a successful iteration (or a "commit-with-warnings" choice), decide
263
+ whether to scaffold `tasks/` based on deterministic triggers:
264
+
265
+ ```bash
266
+ PROMOTE_JSON=$(node np-tools.cjs init plan-phase plan-phase-promote-check "$PHASE")
267
+ PROMOTE=$(echo "$PROMOTE_JSON" | node -e "process.stdin.on('data', d => console.log(JSON.parse(d).promote))")
268
+ if [ "$PROMOTE" = "true" ]; then
269
+ mkdir -p "$phase_dir/tasks"
270
+ # Planner's PLAN.md must contain a `## Task Promotion` section with the
271
+ # triggers list. Plan-checker enforced that; no extra action here.
272
+ fi
273
+ ```
274
+
275
+ Three triggers (any one fires → promote):
276
+ 1. **parallelism** — `computeWaves(tasks).length > 1 && max(waves.length) >= 2`
277
+ 2. **mixed-tiers** — `new Set(tasks.tier).size >= 2`
278
+ 3. **non-linear-deps** — `tasks.some(t => t.depends_on.length >= 2)`
279
+
280
+ No override flag. Planner judgement does not promote (D-20).
281
+ <!-- /answer_validation -->
282
+
283
+ ## Plan-Diff Approval Gate
284
+
285
+ <plan_diff_gate>
286
+ This gate fires only when the phase+plan already has a committed PLAN.md in HEAD (re-plan case). First-time planning (`plan_diff_required: false`) skips this section entirely. First plan-id is `${padded}-01` by convention.
287
+
288
+ ```bash
289
+ PLAN_ID="${padded}-01"
290
+ if [[ "$PLAN_DIFF_REQUIRED" == "true" ]]; then
291
+ echo "Plan-Diff: this is a re-plan — reviewing changes against HEAD:" >&2
292
+ node np-tools.cjs plan-diff "$PHASE" "$PLAN_ID" | sed 's/^/ /'
293
+ CHOICE=$(node np-tools.cjs askuser --json '{
294
+ "type": "select",
295
+ "header": "PLAN.md Re-Run — review diff",
296
+ "question": "Approve the new PLAN.md, reject and restore HEAD, or loop the planner with feedback?",
297
+ "options": [
298
+ {"label": "Approve + proceed", "description": "Keep the new PLAN.md; workflow commits it."},
299
+ {"label": "Reject (keep old)", "description": "Archive the new draft and restore HEAD."},
300
+ {"label": "Edit (loop planner)", "description": "Ask the planner for a revision with your feedback."}
301
+ ]
302
+ }')
303
+ case "$CHOICE" in
304
+ "Approve"*)
305
+ echo "approved — proceeding to commit" >&2
306
+ ;;
307
+ "Reject"*)
308
+ REASON=$(node np-tools.cjs askuser --json '{"type":"input","question":"Reason for rejection?"}')
309
+ node np-tools.cjs plan-diff --archive-rejected "$PHASE" "$PLAN_ID" --reason "$REASON"
310
+ echo "rejected — HEAD restored, draft archived" >&2
311
+ exit 0
312
+ ;;
313
+ "Edit"*)
314
+ FEEDBACK=$(node np-tools.cjs askuser --json '{"type":"input","question":"Feedback for the planner:"}')
315
+ export PLANNER_USER_FEEDBACK="$FEEDBACK"
316
+ # Sentinel exit — orchestrator re-enters the Verification Loop above
317
+ # with <user_feedback> appended to the planner prompt (Phase 5 D-15).
318
+ exit 2
319
+ ;;
320
+ esac
321
+ fi
322
+ ```
323
+ </plan_diff_gate>
324
+
325
+ ## Commit
326
+
327
+ ```bash
328
+ # Respects config.commit_docs (Phase 4 D-21).
329
+ # NN is the plan number inside the phase — first plan is 01.
330
+ git add "$phase_dir/${padded}-01-PLAN.md" "$phase_dir/${padded}-PLAN-REVIEW.md"
331
+ [ -d "$phase_dir/tasks" ] && git add "$phase_dir/tasks"
332
+ git commit -m "docs(${padded}-01): PLAN.md ready for execute"
333
+ ```
334
+
335
+ ## Abort path
336
+
337
+ If the user chose "Abort" at the iter-2 gate, `plan-phase-abort` already ran:
338
+ PLAN.md + `tasks/` are gone, PLAN-REVIEW.md preserved. Exit 1.
339
+
340
+ ## Structured results
341
+
342
+ Return to the orchestrator:
343
+
344
+ ```
345
+ status: passed | committed-with-warnings | aborted | manual-edit
346
+ iterations: 1 | 2 | 3
347
+ plan_path: <absolute path to PLAN.md, or null on abort>
348
+ review_path: <absolute path to PLAN-REVIEW.md>
349
+ promoted: true | false
350
+ triggers: [parallelism, mixed-tiers, non-linear-deps]
351
+ ```
@@ -0,0 +1,8 @@
1
+ # np:progress
2
+
3
+ Report percent-complete across phases and plans from the persisted progress
4
+ block in STATE.md (O(1) read; recomputation is a write-side concern).
5
+
6
+ ```bash
7
+ node np-tools.cjs progress
8
+ ```
@@ -0,0 +1,9 @@
1
+ # np:queue
2
+
3
+ Unified queue across 4 sources: `.nubos-pilot/todos/pending/`, backlog phases
4
+ (999.x), pending VERIFICATION/UAT items, and roadmap phases without PLAN.md.
5
+ Emits a flat JSON table to stdout.
6
+
7
+ ```bash
8
+ node np-tools.cjs queue "$@"
9
+ ```