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
package/lib/verify.cjs ADDED
@@ -0,0 +1,116 @@
1
+ const fs = require('node:fs');
2
+ const path = require('node:path');
3
+ const { withFileLock, atomicWriteFileSync, NubosPilotError } = require('./core.cjs');
4
+ const { getPhase } = require('./roadmap.cjs');
5
+ const { paddedPhase, findPhaseDir } = require('./phase.cjs');
6
+
7
+ const _SUBJECTIVE_RE = /\b(subjective|feels?|UX|usability|look|looks|aesthetic|intuitive)\b/i;
8
+
9
+ function verifyPhase(n, { cwd = process.cwd() } = {}) {
10
+ const phase = getPhase(n, cwd);
11
+ const criteria = phase.success_criteria || [];
12
+ return criteria.map((sc, idx) => ({
13
+ id: 'SC-' + (idx + 1),
14
+ text: sc,
15
+ status: null,
16
+ classified_by: null,
17
+ evidence: [],
18
+ notes: '',
19
+ needs_user_confirm: _SUBJECTIVE_RE.test(sc),
20
+ }));
21
+ }
22
+
23
+ function _phaseStatusFromResults(results) {
24
+
25
+ if (results.some((r) => r.status === 'Fail')) return 'failed';
26
+
27
+ if (results.some((r) => r.status === 'Defer')) return 'deferred';
28
+ if (results.some((r) => r.needs_user_confirm && r.status == null)) return 'deferred';
29
+
30
+ if (results.every((r) => r.status === 'Pass')) return 'verified';
31
+
32
+ return 'deferred';
33
+ }
34
+
35
+ function renderVerificationMd(n, phaseName, results) {
36
+ const phaseStatus = _phaseStatusFromResults(results);
37
+ const ts = new Date().toISOString().slice(0, 10);
38
+ const lines = [];
39
+ lines.push('# Phase ' + n + ': ' + phaseName + ' - Verification');
40
+ lines.push('');
41
+ lines.push('**Verified:** ' + ts);
42
+ lines.push('**Phase Status:** ' + phaseStatus);
43
+ lines.push('');
44
+ lines.push('## Success Criteria');
45
+ lines.push('');
46
+ for (const r of results) {
47
+ lines.push('### ' + r.id + ': ' + r.text);
48
+ lines.push('- **Status:** ' + (r.status || 'Pending'));
49
+ lines.push('- **Classified by:** ' + (r.classified_by || 'n/a'));
50
+ const evidence = Array.isArray(r.evidence) && r.evidence.length > 0
51
+ ? r.evidence.join(', ')
52
+ : '—';
53
+ lines.push('- **Evidence:** ' + evidence);
54
+ if (r.notes) {
55
+ lines.push('- **Notes:** ' + r.notes);
56
+ }
57
+ if (r.needs_user_confirm && r.status == null) {
58
+ lines.push('- **Needs user confirm:** true');
59
+ }
60
+ lines.push('');
61
+ }
62
+ return lines.join('\n');
63
+ }
64
+
65
+ const _SC_RE = /^### (SC-\d+): ([^\n]+)\n- \*\*Status:\*\* (\w+)/gm;
66
+
67
+ function parseVerificationMd(filePath) {
68
+ let raw;
69
+ try {
70
+ raw = fs.readFileSync(filePath, 'utf-8');
71
+ } catch (err) {
72
+ throw new NubosPilotError(
73
+ 'verify-file-unreadable',
74
+ 'VERIFICATION.md not readable at ' + filePath,
75
+ { path: filePath, cause: err && err.code },
76
+ );
77
+ }
78
+
79
+
80
+
81
+ const out = [];
82
+ for (const m of raw.matchAll(_SC_RE)) {
83
+ out.push({
84
+ id: m[1],
85
+ text: m[2].trim(),
86
+ status: m[3],
87
+ });
88
+ }
89
+ return out;
90
+ }
91
+
92
+ function writeVerificationMd(n, cwd = process.cwd()) {
93
+ const phase = getPhase(n, cwd);
94
+ const phaseDir = findPhaseDir(n, cwd);
95
+ if (!phaseDir) {
96
+ throw new NubosPilotError(
97
+ 'verify-phase-dir-missing',
98
+ 'Phase directory not found for phase ' + n,
99
+ { phase: n },
100
+ );
101
+ }
102
+ const padded = paddedPhase(n);
103
+ const target = path.join(phaseDir, padded + '-VERIFICATION.md');
104
+ const results = verifyPhase(n, { cwd });
105
+ const md = renderVerificationMd(n, phase.name, results);
106
+ return withFileLock(target, () => atomicWriteFileSync(target, md));
107
+ }
108
+
109
+ module.exports = {
110
+ verifyPhase,
111
+ renderVerificationMd,
112
+ parseVerificationMd,
113
+ writeVerificationMd,
114
+
115
+ _phaseStatusFromResults,
116
+ };
@@ -0,0 +1,187 @@
1
+ const fs = require('node:fs');
2
+ const os = require('node:os');
3
+ const path = require('node:path');
4
+ const { test } = require('node:test');
5
+ const assert = require('node:assert/strict');
6
+
7
+ const verify = require('./verify.cjs');
8
+ const {
9
+ verifyPhase,
10
+ renderVerificationMd,
11
+ parseVerificationMd,
12
+ writeVerificationMd,
13
+ } = verify;
14
+
15
+ const _sandboxes = [];
16
+
17
+ function makeRoadmapSandbox(phases) {
18
+ const root = fs.mkdtempSync(path.join(os.tmpdir(), 'np-verify-'));
19
+ fs.mkdirSync(path.join(root, '.nubos-pilot'), { recursive: true });
20
+ fs.mkdirSync(path.join(root, '.nubos-pilot', 'phases'), { recursive: true });
21
+ const doc = {
22
+ milestones: [
23
+ {
24
+ id: 'v1.0',
25
+ name: 'verify-test-milestone',
26
+ phases: phases,
27
+ },
28
+ ],
29
+ };
30
+
31
+ const YAML = require('yaml');
32
+ fs.writeFileSync(
33
+ path.join(root, '.nubos-pilot', 'roadmap.yaml'),
34
+ YAML.stringify(doc, { indent: 2 }),
35
+ 'utf-8',
36
+ );
37
+ _sandboxes.push(root);
38
+ return root;
39
+ }
40
+
41
+ function cleanupAll() {
42
+ while (_sandboxes.length) {
43
+ const r = _sandboxes.pop();
44
+ try { fs.rmSync(r, { recursive: true, force: true }); } catch { }
45
+ }
46
+ }
47
+
48
+ test.afterEach(() => cleanupAll());
49
+
50
+ test('VR-1: renderVerificationMd emits D-24-schema headers and per-SC blocks', () => {
51
+ const results = [
52
+ {
53
+ id: 'SC-1', text: 'first criterion', status: 'Pass',
54
+ classified_by: 'np-verifier', evidence: ['abc1234', 'lib/foo.cjs'],
55
+ notes: '', needs_user_confirm: false,
56
+ },
57
+ {
58
+ id: 'SC-2', text: 'second criterion', status: 'Fail',
59
+ classified_by: 'np-verifier', evidence: [], notes: 'missing export',
60
+ needs_user_confirm: false,
61
+ },
62
+ ];
63
+ const md = renderVerificationMd(6, 'test-phase', results);
64
+
65
+ assert.match(md, /^# Phase 6: test-phase - Verification$/m);
66
+ assert.match(md, /^\*\*Verified:\*\* \d{4}-\d{2}-\d{2}$/m);
67
+ assert.match(md, /^\*\*Phase Status:\*\* (verified|failed|deferred)$/m);
68
+ assert.match(md, /^## Success Criteria$/m);
69
+
70
+ assert.match(md, /^### SC-1: first criterion$/m);
71
+ assert.match(md, /^- \*\*Status:\*\* Pass$/m);
72
+ assert.match(md, /^- \*\*Classified by:\*\* np-verifier$/m);
73
+ assert.match(md, /^- \*\*Evidence:\*\* abc1234, lib\/foo\.cjs$/m);
74
+ assert.match(md, /^### SC-2: second criterion$/m);
75
+ assert.match(md, /^- \*\*Status:\*\* Fail$/m);
76
+ assert.match(md, /^- \*\*Notes:\*\* missing export$/m);
77
+ });
78
+
79
+ test('VR-2: parseVerificationMd round-trip extracts id/text/status', () => {
80
+ const results = [
81
+ { id: 'SC-1', text: 'alpha', status: 'Pass', classified_by: 'np-verifier', evidence: [], notes: '', needs_user_confirm: false },
82
+ { id: 'SC-2', text: 'beta', status: 'Fail', classified_by: 'user', evidence: [], notes: '', needs_user_confirm: false },
83
+ { id: 'SC-3', text: 'gamma', status: 'Defer', classified_by: 'user', evidence: [], notes: '', needs_user_confirm: false },
84
+ ];
85
+ const md = renderVerificationMd(7, 'round-trip-phase', results);
86
+
87
+ const tmp = path.join(os.tmpdir(), 'np-verify-round-' + Date.now() + '.md');
88
+ fs.writeFileSync(tmp, md, 'utf-8');
89
+ try {
90
+ const parsed = parseVerificationMd(tmp);
91
+ assert.equal(parsed.length, 3);
92
+ assert.deepEqual(
93
+ parsed.map((r) => ({ id: r.id, text: r.text, status: r.status })),
94
+ [
95
+ { id: 'SC-1', text: 'alpha', status: 'Pass' },
96
+ { id: 'SC-2', text: 'beta', status: 'Fail' },
97
+ { id: 'SC-3', text: 'gamma', status: 'Defer' },
98
+ ],
99
+ );
100
+ } finally {
101
+ try { fs.unlinkSync(tmp); } catch {}
102
+ }
103
+ });
104
+
105
+ test('VR-3: phase status — any Fail → failed', () => {
106
+ const results = [
107
+ { id: 'SC-1', text: 't', status: 'Pass', classified_by: 'np-verifier', evidence: [], notes: '', needs_user_confirm: false },
108
+ { id: 'SC-2', text: 't', status: 'Fail', classified_by: 'np-verifier', evidence: [], notes: '', needs_user_confirm: false },
109
+ { id: 'SC-3', text: 't', status: 'Defer', classified_by: 'user', evidence: [], notes: '', needs_user_confirm: false },
110
+ ];
111
+ const md = renderVerificationMd(1, 'n', results);
112
+ assert.match(md, /^\*\*Phase Status:\*\* failed$/m);
113
+ });
114
+
115
+ test('VR-4: phase status — no Fail, any Defer → deferred', () => {
116
+ const results = [
117
+ { id: 'SC-1', text: 't', status: 'Pass', classified_by: 'np-verifier', evidence: [], notes: '', needs_user_confirm: false },
118
+ { id: 'SC-2', text: 't', status: 'Defer', classified_by: 'user', evidence: [], notes: '', needs_user_confirm: false },
119
+ ];
120
+ const md = renderVerificationMd(1, 'n', results);
121
+ assert.match(md, /^\*\*Phase Status:\*\* deferred$/m);
122
+ });
123
+
124
+ test('VR-5: phase status — all Pass → verified', () => {
125
+ const results = [
126
+ { id: 'SC-1', text: 't', status: 'Pass', classified_by: 'np-verifier', evidence: [], notes: '', needs_user_confirm: false },
127
+ { id: 'SC-2', text: 't', status: 'Pass', classified_by: 'np-verifier', evidence: [], notes: '', needs_user_confirm: false },
128
+ ];
129
+ const md = renderVerificationMd(1, 'n', results);
130
+ assert.match(md, /^\*\*Phase Status:\*\* verified$/m);
131
+ });
132
+
133
+ test('VR-6: verifyPhase returns skeleton Result[] with null status per SC', () => {
134
+ const sb = makeRoadmapSandbox([
135
+ {
136
+ number: 6,
137
+ name: 'exec-phase',
138
+ slug: 'exec-phase',
139
+ goal: 'execute things',
140
+ success_criteria: [
141
+ 'criterion one works',
142
+ 'criterion two works',
143
+ 'criterion three works',
144
+ ],
145
+ requirements: [],
146
+ status: 'pending',
147
+ plans: [],
148
+ },
149
+ ]);
150
+ const results = verifyPhase(6, { cwd: sb });
151
+ assert.equal(results.length, 3);
152
+ for (let i = 0; i < results.length; i++) {
153
+ const r = results[i];
154
+ assert.equal(r.id, 'SC-' + (i + 1));
155
+ assert.equal(r.status, null);
156
+ assert.equal(r.classified_by, null);
157
+ assert.ok(Array.isArray(r.evidence));
158
+ assert.equal(r.needs_user_confirm, false);
159
+ }
160
+ assert.equal(results[0].text, 'criterion one works');
161
+ });
162
+
163
+ test('VR-7: writeVerificationMd persists under <phase_dir>/<padded>-VERIFICATION.md', () => {
164
+ const sb = makeRoadmapSandbox([
165
+ {
166
+ number: 6,
167
+ name: 'exec-phase',
168
+ slug: 'exec-phase',
169
+ goal: 'execute things',
170
+ success_criteria: ['only one thing'],
171
+ requirements: [],
172
+ status: 'pending',
173
+ plans: [],
174
+ },
175
+ ]);
176
+
177
+ const phaseDir = path.join(sb, '.nubos-pilot', 'phases', '06-exec-phase');
178
+ fs.mkdirSync(phaseDir, { recursive: true });
179
+
180
+ writeVerificationMd(6, sb);
181
+
182
+ const target = path.join(phaseDir, '06-VERIFICATION.md');
183
+ assert.ok(fs.existsSync(target), 'VERIFICATION.md should exist at ' + target);
184
+ const content = fs.readFileSync(target, 'utf-8');
185
+ assert.match(content, /^# Phase 6: exec-phase - Verification$/m);
186
+ assert.match(content, /^### SC-1: only one thing$/m);
187
+ });
package/np-tools.cjs ADDED
@@ -0,0 +1,303 @@
1
+ #!/usr/bin/env node
2
+ const fs = require('node:fs');
3
+ const path = require('node:path');
4
+ const crypto = require('node:crypto');
5
+ const { projectStateDir, NubosPilotError } = require('./lib/core.cjs');
6
+ const { getPhase } = require('./lib/roadmap.cjs');
7
+ const { paddedPhase, phaseSlug, findPhaseDir } = require('./lib/phase.cjs');
8
+ const { parsePlan, listPlans } = require('./lib/plan.cjs');
9
+ const { loadTaskGraph } = require('./lib/tasks.cjs');
10
+ const { COMMANDS } = require('./bin/np-tools/_commands.cjs');
11
+
12
+ const initWorkflows = {
13
+ 'plan-phase': require('./bin/np-tools/plan-phase.cjs'),
14
+ 'discuss-phase': require('./bin/np-tools/discuss-phase.cjs'),
15
+ 'discuss-phase-power': require('./bin/np-tools/discuss-phase-power.cjs'),
16
+ 'research-phase': require('./bin/np-tools/research-phase.cjs'),
17
+ 'new-project': require('./bin/np-tools/new-project.cjs'),
18
+ 'new-milestone': require('./bin/np-tools/new-milestone.cjs'),
19
+ 'plan-milestone-gaps': require('./bin/np-tools/plan-milestone-gaps.cjs'),
20
+
21
+ 'execute-phase': require('./bin/np-tools/execute-phase.cjs'),
22
+ 'execute-plan': require('./bin/np-tools/execute-plan.cjs'),
23
+ 'autonomous': require('./bin/np-tools/autonomous.cjs'),
24
+ 'verify-work': require('./bin/np-tools/verify-work.cjs'),
25
+ 'add-tests': require('./bin/np-tools/add-tests.cjs'),
26
+ 'pause-work': require('./bin/np-tools/pause-work.cjs'),
27
+ 'resume-work': require('./bin/np-tools/resume-work.cjs'),
28
+
29
+ 'ai-integration-phase': require('./bin/np-tools/ai-integration-phase.cjs'),
30
+ 'ui-phase': require('./bin/np-tools/ui-phase.cjs'),
31
+ 'ui-review': require('./bin/np-tools/ui-review.cjs'),
32
+ 'eval-review': require('./bin/np-tools/eval-review.cjs'),
33
+
34
+ 'code-review': require('./bin/np-tools/code-review.cjs'),
35
+
36
+ 'add-todo': require('./bin/np-tools/add-todo.cjs'),
37
+ };
38
+
39
+ const topLevelCommands = {
40
+ 'agent-skills': require('./bin/np-tools/agent-skills.cjs'),
41
+
42
+ 'commit-task': require('./bin/np-tools/commit-task.cjs'),
43
+ 'checkpoint': require('./bin/np-tools/checkpoint.cjs'),
44
+
45
+ 'undo': require('./bin/np-tools/undo.cjs'),
46
+ 'undo-task': require('./bin/np-tools/undo-task.cjs'),
47
+ 'reset-slice': require('./bin/np-tools/reset-slice.cjs'),
48
+ 'skip': require('./bin/np-tools/skip.cjs'),
49
+ 'park': require('./bin/np-tools/park.cjs'),
50
+ 'unpark': require('./bin/np-tools/unpark.cjs'),
51
+ 'askuser': require('./bin/np-tools/askuser.cjs'),
52
+ 'commit': require('./bin/np-tools/commit.cjs'),
53
+ 'config-get': require('./bin/np-tools/config.cjs'),
54
+ 'dispatch': require('./bin/np-tools/dispatch.cjs'),
55
+ 'doctor': require('./bin/np-tools/doctor.cjs'),
56
+ 'generate-slug': require('./bin/np-tools/slug.cjs'),
57
+ 'metrics': require('./bin/np-tools/metrics.cjs'),
58
+ 'phase': require('./bin/np-tools/phase.cjs'),
59
+ 'plan-diff': require('./bin/np-tools/plan-diff.cjs'),
60
+ 'queue': require('./bin/np-tools/queue.cjs'),
61
+ 'resolve-model': require('./bin/np-tools/resolve-model.cjs'),
62
+ 'stats': require('./bin/np-tools/stats.cjs'),
63
+ 'triage': require('./bin/np-tools/triage.cjs'),
64
+ };
65
+
66
+ const THRESHOLD = 16 * 1024;
67
+
68
+ function _resolveStateDir(cwd) {
69
+ try {
70
+ return projectStateDir(cwd);
71
+ } catch (err) {
72
+ if (err && err.code === 'not-in-project') {
73
+ const boot = path.join(path.resolve(cwd), '.planning');
74
+ if (fs.existsSync(boot)) return boot;
75
+ }
76
+ throw err;
77
+ }
78
+ }
79
+
80
+ function _resolvePhaseDir(n, cwd) {
81
+ try {
82
+ const hit = findPhaseDir(n, cwd);
83
+ if (hit) return hit;
84
+ } catch (err) {
85
+ if (!err || err.code !== 'not-in-project') throw err;
86
+ }
87
+ const padded = paddedPhase(n);
88
+ const stateDir = _resolveStateDir(cwd);
89
+ const phasesRoot = path.join(stateDir, 'phases');
90
+ let entries;
91
+ try {
92
+ entries = fs.readdirSync(phasesRoot, { withFileTypes: true });
93
+ } catch (err) {
94
+ if (err && err.code === 'ENOENT') return null;
95
+ throw err;
96
+ }
97
+ const matches = entries
98
+ .filter((e) => e.isDirectory())
99
+ .filter((e) => e.name === padded || e.name.startsWith(padded + '-'))
100
+ .map((e) => e.name)
101
+ .sort((a, b) => b.length - a.length);
102
+ if (matches.length === 0) return null;
103
+ return path.join(phasesRoot, matches[0]);
104
+ }
105
+
106
+ function _sanitizeLabel(s) {
107
+ return String(s).replace(/[^a-zA-Z0-9-]/g, '_');
108
+ }
109
+
110
+ function emit(payload, _stdout, _cwd) {
111
+ const stdout = _stdout || process.stdout;
112
+ const cwd = _cwd || process.cwd();
113
+ const json = JSON.stringify(payload, null, 2);
114
+ if (Buffer.byteLength(json, 'utf-8') <= THRESHOLD) {
115
+ stdout.write(json);
116
+ return;
117
+ }
118
+ const stateDir = _resolveStateDir(cwd);
119
+ const tmpDir = path.join(stateDir, '.tmp');
120
+ fs.mkdirSync(tmpDir, { recursive: true });
121
+ const workflow = _sanitizeLabel(payload && payload._workflow ? payload._workflow : 'init');
122
+ const suffix = process.pid + '-' + crypto.randomBytes(4).toString('hex');
123
+ const tmpPath = path.join(tmpDir, 'init-' + workflow + '-' + suffix + '.json');
124
+ fs.writeFileSync(tmpPath, json, 'utf-8');
125
+ stdout.write('@file:' + tmpPath);
126
+ }
127
+
128
+ function _makePhasePayload(n, cwd, workflowLabel) {
129
+ const padded = paddedPhase(n);
130
+ const phase = getPhase(n, cwd);
131
+ const phase_dir = _resolvePhaseDir(n, cwd);
132
+ const stateDir = _resolveStateDir(cwd);
133
+ let has_context = false;
134
+ let has_research = false;
135
+ let has_plans = false;
136
+ if (phase_dir) {
137
+ has_context = fs.existsSync(path.join(phase_dir, padded + '-CONTEXT.md'));
138
+ has_research = fs.existsSync(path.join(phase_dir, padded + '-RESEARCH.md'));
139
+ has_plans = listPlans(phase_dir).length > 0;
140
+ }
141
+ return {
142
+ _workflow: workflowLabel,
143
+ phase_number: String(n),
144
+ padded_phase: padded,
145
+ phase_slug: phase_dir ? path.basename(phase_dir).slice(padded.length + 1) : phaseSlug(phase.name),
146
+ phase_name: phase.name,
147
+ phase_dir,
148
+ phase_found: !!phase_dir,
149
+ roadmap_path: path.join(stateDir, 'ROADMAP.md'),
150
+ state_path: path.join(stateDir, 'STATE.md'),
151
+ has_context,
152
+ has_research,
153
+ has_plans,
154
+ goal: phase.goal,
155
+ requirements: phase.requirements,
156
+ success_criteria: phase.success_criteria,
157
+ };
158
+ }
159
+
160
+ function composeInit(workflow, args, cwd) {
161
+ const useCwd = cwd || process.cwd();
162
+ switch (workflow) {
163
+ case 'phase-op':
164
+ return _makePhasePayload(args[0], useCwd, 'phase-op');
165
+ case 'plan-phase': {
166
+ const base = _makePhasePayload(args[0], useCwd, 'plan-phase');
167
+ if (base.phase_dir) {
168
+ base.planned_plans = listPlans(base.phase_dir);
169
+ base.context_path = base.has_context
170
+ ? path.join(base.phase_dir, base.padded_phase + '-CONTEXT.md')
171
+ : null;
172
+ base.research_path = base.has_research
173
+ ? path.join(base.phase_dir, base.padded_phase + '-RESEARCH.md')
174
+ : null;
175
+ } else {
176
+ base.planned_plans = [];
177
+ base.context_path = null;
178
+ base.research_path = null;
179
+ }
180
+ return base;
181
+ }
182
+ case 'execute-phase': {
183
+ const base = _makePhasePayload(args[0], useCwd, 'execute-phase');
184
+ base.plans = [];
185
+ if (base.phase_dir) {
186
+ for (const planPath of listPlans(base.phase_dir)) {
187
+ const parsed = parsePlan(planPath);
188
+ const planDir = path.dirname(planPath);
189
+ const tg = loadTaskGraph(planDir);
190
+ base.plans.push({
191
+ plan_path: planPath,
192
+ plan_frontmatter: parsed.frontmatter,
193
+ tasks_dir: path.join(planDir, 'tasks'),
194
+ task_count: tg.tasks.length,
195
+ waves: tg.waves,
196
+ warnings: tg.warnings,
197
+ });
198
+ }
199
+ }
200
+ return base;
201
+ }
202
+ default: {
203
+ if (args[0]) {
204
+ try {
205
+ return _makePhasePayload(args[0], useCwd, workflow);
206
+ } catch (err) {
207
+ if (err && err.code === 'phase-not-found') {
208
+ return { _workflow: workflow, phase_found: false, phase_number: String(args[0]) };
209
+ }
210
+ throw err;
211
+ }
212
+ }
213
+ return { _workflow: workflow, phase_found: false };
214
+ }
215
+ }
216
+ }
217
+
218
+ function main() {
219
+ const args = process.argv.slice(2);
220
+ try {
221
+ const cmd = args[0];
222
+ let payload;
223
+ switch (cmd) {
224
+ case 'init': {
225
+ const wf = args[1];
226
+
227
+
228
+
229
+
230
+ if (wf && Object.prototype.hasOwnProperty.call(initWorkflows, wf)) {
231
+ const rc = initWorkflows[wf].run(args.slice(2));
232
+ if (rc && typeof rc.then === 'function') {
233
+ rc.then((code) => {
234
+ if (typeof code === 'number' && code !== 0) process.exit(code);
235
+ }).catch((err) => {
236
+ process.stderr.write(String((err && err.stack) || err) + '\n');
237
+ process.exit(1);
238
+ });
239
+ } else if (typeof rc === 'number' && rc !== 0) {
240
+ process.exit(rc);
241
+ }
242
+ return;
243
+ }
244
+ payload = composeInit(wf, args.slice(2));
245
+ break;
246
+ }
247
+ case 'next':
248
+ payload = require('./bin/np-tools/next.cjs').run(args.slice(1));
249
+ break;
250
+ case 'progress':
251
+ payload = require('./bin/np-tools/progress.cjs').run(args.slice(1));
252
+ break;
253
+ case 'state':
254
+ payload = require('./bin/np-tools/state.cjs').run(args.slice(1));
255
+ break;
256
+ case 'help':
257
+ payload = require('./bin/np-tools/help.cjs').run(args.slice(1));
258
+ break;
259
+ default: {
260
+
261
+
262
+ if (cmd && Object.prototype.hasOwnProperty.call(topLevelCommands, cmd)) {
263
+ const rc = topLevelCommands[cmd].run(args.slice(1));
264
+ if (rc && typeof rc.then === 'function') {
265
+ rc.then((code) => {
266
+ if (typeof code === 'number' && code !== 0) process.exit(code);
267
+ }).catch((err) => {
268
+ process.stderr.write(String((err && err.stack) || err) + '\n');
269
+ process.exit(1);
270
+ });
271
+ } else if (typeof rc === 'number' && rc !== 0) {
272
+ process.exit(rc);
273
+ }
274
+ return;
275
+ }
276
+ throw new NubosPilotError(
277
+ 'unknown-command',
278
+ 'Unknown command: ' + cmd,
279
+ { cmd },
280
+ );
281
+ }
282
+ }
283
+ emit(payload);
284
+ } catch (err) {
285
+ const code = (err && err.code) || 'init-internal-error';
286
+ const message = (err && err.message) || String(err);
287
+ const details = (err && err.details) || null;
288
+ fs.writeSync(2, JSON.stringify({ error: { code, message, details } }) + '\n');
289
+ process.exit(1);
290
+ }
291
+ }
292
+
293
+ if (require.main === module) main();
294
+
295
+ module.exports = {
296
+ composeInit,
297
+ emit,
298
+ _makePhasePayload,
299
+ main,
300
+ COMMANDS,
301
+ initWorkflows,
302
+ topLevelCommands,
303
+ };
package/package.json ADDED
@@ -0,0 +1,39 @@
1
+ {
2
+ "name": "nubos-pilot",
3
+ "version": "0.1.0",
4
+ "description": "AI-driven planning and execution tool for code projects",
5
+ "homepage": "https://github.com/Nubos-AI/nubos-pilot",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "git+https://github.com/Nubos-AI/nubos-pilot.git"
9
+ },
10
+ "bugs": {
11
+ "url": "https://github.com/Nubos-AI/nubos-pilot/issues"
12
+ },
13
+ "license": "MIT",
14
+ "engines": {
15
+ "node": ">=22"
16
+ },
17
+ "dependencies": {
18
+ "yaml": "^2.8.0"
19
+ },
20
+ "bin": {
21
+ "nubos-pilot": "bin/install.js"
22
+ },
23
+ "files": [
24
+ "bin/",
25
+ "lib/",
26
+ "templates/",
27
+ "workflows/",
28
+ "agents/",
29
+ "docs/",
30
+ "np-tools.cjs",
31
+ "README.md"
32
+ ],
33
+ "scripts": {
34
+ "test": "node --test 'lib/**/*.test.cjs' 'tests/**/*.test.cjs' 'bin/**/*.test.cjs'",
35
+ "test:coverage": "node --test --experimental-test-coverage --test-coverage-include='lib/**' 'lib/**/*.test.cjs' 'tests/**/*.test.cjs' 'bin/**/*.test.cjs'",
36
+ "check-coverage": "node bin/check-coverage.cjs",
37
+ "ci": "npm run test && npm run check-coverage"
38
+ }
39
+ }