nubos-pilot 0.5.4 → 0.5.5

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.
@@ -89,6 +89,7 @@ Run each dimension below; for every failure, emit one finding using the matching
89
89
  - Every `<task>` MUST have `id="M<NNN>-S<NNN>-T<NNNN>"` matching the enclosing slice (milestone and slice numbers must agree with the file path). Mismatch → `broken-dependency`.
90
90
  - Missing `depends_on`, `wave`, or `tier` attribute on the opening `<task>` tag → the scaffolder will drop it. Emit `fake-promotion-trigger` with a message telling the planner which task is missing which attribute.
91
91
  - `wave="<N>"` should equal the slice's S-number (e.g. S002 → wave="2"). Mismatch is a soft finding (`fake-promotion-trigger`).
92
+ - **Task numbering restarts per slice.** Inside each `S<NNN>-PLAN.md`, the task IDs MUST start at `T0001` and increment contiguously (`T0001, T0002, …`). Counter that continues across slices (e.g. `S002` starting at `T0002` because `S001` used `T0001`) → `broken-dependency` with `target: S<NNN>-PLAN.md task <n>` and a message naming the expected vs. observed T-number. Gaps (`T0001, T0003`) are the same finding.
92
93
 
93
94
  ### Dimension 7: Nyquist Coverage Annotation
94
95
 
@@ -216,7 +216,7 @@ If any check fails, fix before returning. Plan-checker will catch what you miss,
216
216
 
217
217
  Inside each `S<NNN>-PLAN.md`, every `<task>` tag MUST have these four attributes on the opening tag:
218
218
 
219
- - `id="M<NNN>-S<NNN>-T<NNNN>"` — full-id, e.g. `id="M001-S001-T0001"`. Milestone 3 digits, slice 3 digits, task **4 digits**.
219
+ - `id="M<NNN>-S<NNN>-T<NNNN>"` — full-id, e.g. `id="M001-S001-T0001"`. Milestone 3 digits, slice 3 digits, task **4 digits**. **Task numbering restarts at `T0001` inside every slice.** The first task of `S002` is `M<NNN>-S002-T0001`, the first task of `S003` is `M<NNN>-S003-T0001`. Tasks within a slice run `T0001, T0002, T0003, …` without gaps. Never continue the counter across slices (`S001-T0001, S002-T0002` is wrong — it must be `S001-T0001, S002-T0001`).
220
220
  - `depends_on="<id>[,<id>...]"` — comma-separated predecessor task full-ids, or empty string `""`. Must only reference tasks in **earlier slices** (cross-slice forward deps) or be empty (intra-slice tasks are implicitly parallel, never serial).
221
221
  - `wave="<N>"` — integer equal to the slice number. For S001 use `wave="1"`, for S002 use `wave="2"`, etc.
222
222
  - `tier="<haiku|sonnet|opus>"` — executor tier, picks the model via resolve-model.
@@ -257,7 +257,16 @@ Create `LoginForm.tsx` with email + password inputs. Wire it to the
257
257
  </tasks>
258
258
  ```
259
259
 
260
- Note both tasks have `depends_on=""` — they're in the same slice and run in parallel. If `T0002` truly needs `T0001` first, move `T0002` into a new slice `S002` and write `depends_on="M001-S001-T0001" wave="2"`.
260
+ Note both tasks have `depends_on=""` — they're in the same slice and run in parallel. If `T0002` truly needs `T0001` first, move `T0002` into a new slice `S002` and renumber it to `T0001` — each slice owns its own task counter:
261
+
262
+ ```
263
+ <task id="M001-S002-T0001" depends_on="M001-S001-T0001" wave="2" tier="sonnet">
264
+ <name>Use login handler in session flow</name>
265
+ ...
266
+ </task>
267
+ ```
268
+
269
+ The cross-slice dep `M001-S001-T0001` flows forward (S001 → S002); the new task is `T0001` of S002, not `T0003`.
261
270
  </task_format>
262
271
 
263
272
  <tooling_conventions>
package/bin/install.js CHANGED
@@ -663,6 +663,12 @@ function _runUninstallLocked(projectRoot) {
663
663
 
664
664
  async function main() {
665
665
  const rawArgs = process.argv.slice(2);
666
+ if (rawArgs.includes('--version') || rawArgs.includes('-v')) {
667
+ let version = '0.0.0';
668
+ try { version = String(require('../package.json').version || '0.0.0'); } catch {}
669
+ process.stdout.write(version + '\n');
670
+ return;
671
+ }
666
672
  const { flags, rest } = parseInstallFlags(rawArgs);
667
673
  const sub = rest[0];
668
674
  const cwd = process.cwd();
@@ -47,6 +47,7 @@ const COMMANDS = [
47
47
  { name: 'text-mode', category: 'Utility', description: 'Print whether text mode is active (config.workflow.text_mode ∨ CLAUDECODE)' },
48
48
  { name: 'generate-slug', category: 'Utility', description: 'Slugify text via lib/layout.cjs.slugify' },
49
49
  { name: 'stats', category: 'Utility', description: 'Aggregated project stats (roadmap + STATE + git + metrics JSON shape)' },
50
+ { name: 'detect-runtime', category: 'Utility', description: 'Print detected runtime id (claude, codex, gemini, …) — reads config.json ∨ env ∨ default' },
50
51
 
51
52
  { name: 'thread', category: 'Utility', description: 'Cross-session thread CRUD (create/resume under .nubos-pilot/threads/)' },
52
53
  { name: 'session-report', category: 'Utility', description: 'Generate session report from metrics since .last-session pointer' },
@@ -0,0 +1,24 @@
1
+ 'use strict';
2
+
3
+ const { detect } = require('../../lib/runtime/index.cjs');
4
+
5
+ function run(argv, ctx) {
6
+ const context = ctx || {};
7
+ const cwd = context.cwd || process.cwd();
8
+ const stdout = context.stdout || process.stdout;
9
+ const args = Array.isArray(argv) ? argv.slice() : [];
10
+ const result = detect({ cwd });
11
+ if (args.includes('--json')) {
12
+ stdout.write(JSON.stringify(result) + '\n');
13
+ } else {
14
+ stdout.write(result.runtime + '\n');
15
+ }
16
+ return 0;
17
+ }
18
+
19
+ module.exports = { run };
20
+
21
+ if (require.main === module) {
22
+ const code = run(process.argv.slice(2));
23
+ if (typeof code === 'number' && code !== 0) process.exit(code);
24
+ }
@@ -0,0 +1,47 @@
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
+ const { Writable } = require('node:stream');
7
+
8
+ const cli = require('./detect-runtime.cjs');
9
+
10
+ function makeSink() {
11
+ const chunks = [];
12
+ const w = new Writable({
13
+ write(chunk, _enc, cb) { chunks.push(chunk); cb(); },
14
+ });
15
+ w.toString = () => Buffer.concat(chunks.map((c) => Buffer.isBuffer(c) ? c : Buffer.from(String(c)))).toString('utf-8');
16
+ return w;
17
+ }
18
+
19
+ function makeSandbox(runtime) {
20
+ const root = fs.mkdtempSync(path.join(os.tmpdir(), 'np-detect-rt-'));
21
+ fs.mkdirSync(path.join(root, '.nubos-pilot'), { recursive: true });
22
+ if (runtime) {
23
+ fs.writeFileSync(
24
+ path.join(root, '.nubos-pilot', 'config.json'),
25
+ JSON.stringify({ runtime, runtime_source: 'config' }),
26
+ );
27
+ }
28
+ return root;
29
+ }
30
+
31
+ test('detect-runtime: reads runtime from .nubos-pilot/config.json', () => {
32
+ const sb = makeSandbox('gemini');
33
+ const stdout = makeSink();
34
+ const code = cli.run([], { cwd: sb, stdout });
35
+ assert.equal(code, 0);
36
+ assert.equal(stdout.toString().trim(), 'gemini');
37
+ });
38
+
39
+ test('detect-runtime --json emits {runtime, source}', () => {
40
+ const sb = makeSandbox('codex');
41
+ const stdout = makeSink();
42
+ const code = cli.run(['--json'], { cwd: sb, stdout });
43
+ assert.equal(code, 0);
44
+ const parsed = JSON.parse(stdout.toString());
45
+ assert.equal(parsed.runtime, 'codex');
46
+ assert.ok(parsed.source);
47
+ });
@@ -1,14 +1,78 @@
1
+ const fs = require('node:fs');
1
2
  const path = require('node:path');
2
3
  const { execFileSync } = require('node:child_process');
3
4
  const { NubosPilotError, findProjectRoot } = require('../../lib/core.cjs');
4
5
  const { parseRoadmap } = require('../../lib/roadmap.cjs');
5
6
  const { readState } = require('../../lib/state.cjs');
6
7
  const { aggregatePhase } = require('../../lib/metrics-aggregate.cjs');
8
+ const { extractFrontmatter } = require('../../lib/frontmatter.cjs');
9
+ const layout = require('../../lib/layout.cjs');
7
10
 
8
- const SCHEMA_VERSION = 1;
11
+ const SCHEMA_VERSION = 2;
9
12
 
10
13
  function _usage() {
11
- return 'Usage:\n np-tools.cjs stats json';
14
+ return 'Usage:\n np-tools.cjs stats json\n np-tools.cjs stats bar';
15
+ }
16
+
17
+ function _percent(num, den) {
18
+ if (!den || den <= 0) return 0;
19
+ return Math.min(100, Math.round((num / den) * 100));
20
+ }
21
+
22
+ function _taskStatus(planPath) {
23
+ try {
24
+ const raw = fs.readFileSync(planPath, 'utf-8');
25
+ const { frontmatter } = extractFrontmatter(raw);
26
+ return frontmatter && typeof frontmatter.status === 'string'
27
+ ? frontmatter.status : null;
28
+ } catch {
29
+ return null;
30
+ }
31
+ }
32
+
33
+ function _collectTaskAndSliceStats(cwd) {
34
+ let tasksTotal = 0;
35
+ let tasksComplete = 0;
36
+ let slicesTotal = 0;
37
+ let slicesComplete = 0;
38
+ const milestones = layout.listMilestones(cwd);
39
+ for (const m of milestones) {
40
+ const slices = layout.listSlices(m.number, cwd);
41
+ for (const s of slices) {
42
+ slicesTotal += 1;
43
+ const tasks = layout.listTasks(m.number, s.number, cwd);
44
+ if (tasks.length === 0) continue;
45
+ let doneInSlice = 0;
46
+ for (const t of tasks) {
47
+ if (!fs.existsSync(t.plan_path)) continue;
48
+ tasksTotal += 1;
49
+ if (_taskStatus(t.plan_path) === 'done') {
50
+ tasksComplete += 1;
51
+ doneInSlice += 1;
52
+ }
53
+ }
54
+ if (doneInSlice === tasks.length && tasks.length > 0) slicesComplete += 1;
55
+ }
56
+ }
57
+ return {
58
+ tasks: {
59
+ total: tasksTotal,
60
+ complete: tasksComplete,
61
+ percent: _percent(tasksComplete, tasksTotal),
62
+ },
63
+ slices: {
64
+ total: slicesTotal,
65
+ complete: slicesComplete,
66
+ percent: _percent(slicesComplete, slicesTotal),
67
+ },
68
+ };
69
+ }
70
+
71
+ function _renderBar(label, percent, width) {
72
+ const w = Math.max(4, Math.min(60, width || 24));
73
+ const filled = Math.round((percent / 100) * w);
74
+ const bar = '█'.repeat(filled) + '░'.repeat(w - filled);
75
+ return label + ' [' + bar + '] ' + String(percent).padStart(3, ' ') + '%';
12
76
  }
13
77
 
14
78
  function _emitError(err, stderr) {
@@ -81,7 +145,8 @@ async function _buildStats(cwd) {
81
145
  plansTotal += ph.plans_total;
82
146
  plansComplete += ph.plans_complete;
83
147
  }
84
- const percent = plansTotal > 0 ? Math.round((plansComplete / plansTotal) * 100) : 0;
148
+ const percent = _percent(plansComplete, plansTotal);
149
+ const fs_progress = _collectTaskAndSliceStats(useCwd);
85
150
  let lastActivity = null;
86
151
  try {
87
152
  const st = readState(useCwd);
@@ -108,6 +173,8 @@ async function _buildStats(cwd) {
108
173
  plans_total: plansTotal,
109
174
  plans_complete: plansComplete,
110
175
  percent,
176
+ tasks: fs_progress.tasks,
177
+ slices: fs_progress.slices,
111
178
  git,
112
179
  last_activity: lastActivity,
113
180
  metrics_by_phase,
@@ -121,7 +188,7 @@ async function run(argv, ctx) {
121
188
  const stderr = context.stderr || process.stderr;
122
189
  const args = Array.isArray(argv) ? argv.slice() : [];
123
190
  const sub = args.shift();
124
- if (sub !== 'json') {
191
+ if (sub !== 'json' && sub !== 'bar') {
125
192
  stderr.write(_usage() + '\n');
126
193
  return 1;
127
194
  }
@@ -133,6 +200,11 @@ async function run(argv, ctx) {
133
200
  }
134
201
  try {
135
202
  const out = await _buildStats(cwd);
203
+ if (sub === 'bar') {
204
+ stdout.write(_renderBar('Tasks ', out.tasks.percent) + ' (' + out.tasks.complete + '/' + out.tasks.total + ')\n');
205
+ stdout.write(_renderBar('Slices', out.slices.percent) + ' (' + out.slices.complete + '/' + out.slices.total + ')\n');
206
+ return 0;
207
+ }
136
208
  stdout.write(JSON.stringify(out, null, 2) + '\n');
137
209
  return 0;
138
210
  } catch (err) {
@@ -141,7 +213,7 @@ async function run(argv, ctx) {
141
213
  }
142
214
  }
143
215
 
144
- module.exports = { run, _buildStats, _collectPhases, _milestoneEntry };
216
+ module.exports = { run, _buildStats, _collectPhases, _milestoneEntry, _collectTaskAndSliceStats, _renderBar };
145
217
 
146
218
  if (require.main === module) {
147
219
  run(process.argv.slice(2)).then((code) => process.exit(code)).catch((err) => {
@@ -87,17 +87,99 @@ test('STATS-1: stats json emits schema_version + phases + git + metrics_by_phase
87
87
  const code = await statsCli.run(['json'], { cwd: sb, stdout, stderr });
88
88
  assert.equal(code, 0, 'stderr=' + stderr.toString());
89
89
  const parsed = JSON.parse(stdout.toString());
90
- assert.equal(parsed.schema_version, 1);
90
+ assert.equal(parsed.schema_version, 2);
91
91
  assert.ok(parsed.milestone);
92
92
  assert.equal(parsed.phases.length, 2);
93
93
  assert.equal(parsed.plans_total, 2);
94
94
  assert.equal(parsed.plans_complete, 1);
95
95
  assert.equal(parsed.percent, 50);
96
+ assert.ok(parsed.tasks);
97
+ assert.equal(typeof parsed.tasks.total, 'number');
98
+ assert.equal(typeof parsed.tasks.complete, 'number');
99
+ assert.equal(typeof parsed.tasks.percent, 'number');
100
+ assert.ok(parsed.slices);
101
+ assert.equal(typeof parsed.slices.total, 'number');
102
+ assert.equal(typeof parsed.slices.complete, 'number');
103
+ assert.equal(typeof parsed.slices.percent, 'number');
96
104
  assert.ok(parsed.git);
97
105
  assert.ok(typeof parsed.git.commits === 'number');
98
106
  assert.ok(parsed.metrics_by_phase);
99
107
  });
100
108
 
109
+ function writeTaskPlan(root, mNum, sNum, tNum, status) {
110
+ const mid = 'M' + String(mNum).padStart(3, '0');
111
+ const sid = 'S' + String(sNum).padStart(3, '0');
112
+ const tid = 'T' + String(tNum).padStart(4, '0');
113
+ const dir = path.join(root, '.nubos-pilot', 'milestones', mid, 'slices', sid, 'tasks', tid);
114
+ fs.mkdirSync(dir, { recursive: true });
115
+ const fm = [
116
+ '---',
117
+ `id: ${mid}-${sid}-${tid}`,
118
+ `slice: ${mid}-${sid}`,
119
+ `milestone: ${mid}`,
120
+ 'type: execute',
121
+ `status: ${status}`,
122
+ 'tier: sonnet',
123
+ 'owner: executor',
124
+ `wave: ${sNum}`,
125
+ 'depends_on: []',
126
+ 'files_modified: []',
127
+ 'autonomous: true',
128
+ 'must_haves: {}',
129
+ '---',
130
+ '',
131
+ `# ${mid}-${sid}-${tid}`,
132
+ '',
133
+ ].join('\n');
134
+ fs.writeFileSync(path.join(dir, tid + '-PLAN.md'), fm);
135
+ }
136
+
137
+ test('STATS-4: tasks + slices percent reflect filesystem task status', async () => {
138
+ const sb = makeSandbox(DEMO_YAML, DEMO_STATE);
139
+ writeTaskPlan(sb, 1, 1, 1, 'done');
140
+ writeTaskPlan(sb, 1, 1, 2, 'done');
141
+ writeTaskPlan(sb, 1, 2, 1, 'done');
142
+ writeTaskPlan(sb, 1, 2, 2, 'pending');
143
+ writeTaskPlan(sb, 1, 3, 1, 'pending');
144
+ const stdout = makeSink();
145
+ const stderr = makeSink();
146
+ const code = await statsCli.run(['json'], { cwd: sb, stdout, stderr });
147
+ assert.equal(code, 0, 'stderr=' + stderr.toString());
148
+ const parsed = JSON.parse(stdout.toString());
149
+ assert.equal(parsed.tasks.total, 5);
150
+ assert.equal(parsed.tasks.complete, 3);
151
+ assert.equal(parsed.tasks.percent, 60);
152
+ assert.equal(parsed.slices.total, 3);
153
+ assert.equal(parsed.slices.complete, 1, 'only S001 has all tasks done');
154
+ assert.equal(parsed.slices.percent, 33);
155
+ });
156
+
157
+ test('STATS-5: tasks + slices are 0 when nothing scaffolded', async () => {
158
+ const sb = makeSandbox(DEMO_YAML, DEMO_STATE);
159
+ const stdout = makeSink();
160
+ const stderr = makeSink();
161
+ await statsCli.run(['json'], { cwd: sb, stdout, stderr });
162
+ const parsed = JSON.parse(stdout.toString());
163
+ assert.equal(parsed.tasks.total, 0);
164
+ assert.equal(parsed.tasks.percent, 0);
165
+ assert.equal(parsed.slices.total, 0);
166
+ assert.equal(parsed.slices.percent, 0);
167
+ });
168
+
169
+ test('STATS-6: stats bar renders two progress rows on stdout', async () => {
170
+ const sb = makeSandbox(DEMO_YAML, DEMO_STATE);
171
+ writeTaskPlan(sb, 1, 1, 1, 'done');
172
+ writeTaskPlan(sb, 1, 1, 2, 'pending');
173
+ const stdout = makeSink();
174
+ const stderr = makeSink();
175
+ const code = await statsCli.run(['bar'], { cwd: sb, stdout, stderr });
176
+ assert.equal(code, 0, 'stderr=' + stderr.toString());
177
+ const out = stdout.toString();
178
+ assert.match(out, /Tasks .*\d+%/);
179
+ assert.match(out, /Slices.*\d+%/);
180
+ assert.match(out, /1\/2/);
181
+ });
182
+
101
183
  test('STATS-2: unknown subcommand prints usage', async () => {
102
184
  const sb = makeSandbox(DEMO_YAML, DEMO_STATE);
103
185
  const stdout = makeSink();
package/np-tools.cjs CHANGED
@@ -47,6 +47,7 @@ const topLevelCommands = {
47
47
  'stats': require('./bin/np-tools/stats.cjs'),
48
48
  'lang-directive': require('./bin/np-tools/lang-directive.cjs'),
49
49
  'text-mode': require('./bin/np-tools/text-mode.cjs'),
50
+ 'detect-runtime': require('./bin/np-tools/detect-runtime.cjs'),
50
51
  };
51
52
 
52
53
  const THRESHOLD = 16 * 1024;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nubos-pilot",
3
- "version": "0.5.4",
3
+ "version": "0.5.5",
4
4
  "description": "AI-driven planning and execution tool for code projects",
5
5
  "homepage": "https://github.com/Nubos-AI/nubos-pilot",
6
6
  "repository": {
@@ -20,7 +20,7 @@ LANG_DIRECTIVE=$(node .nubos-pilot/bin/np-tools.cjs lang-directive)
20
20
  INIT=$(node .nubos-pilot/bin/np-tools.cjs init execute-milestone init "$PHASE")
21
21
  if [[ "$INIT" == @file:* ]]; then INIT=$(cat "${INIT#@file:}"); fi
22
22
  AGENT_SKILLS_EXECUTOR=$(node .nubos-pilot/bin/np-tools.cjs agent-skills executor 2>/dev/null)
23
- RUNTIME=$(node -e "console.log(require('./lib/runtime/index.cjs').detect().runtime)")
23
+ RUNTIME=$(node .nubos-pilot/bin/np-tools.cjs detect-runtime)
24
24
  ```
25
25
 
26
26
  **Language (SSOT = `.nubos-pilot/config.json` → `response_language`).**
@@ -77,7 +77,7 @@ INIT=$(node .nubos-pilot/bin/np-tools.cjs init plan-milestone init "$PHASE")
77
77
  if [[ "$INIT" == @file:* ]]; then INIT=$(cat "${INIT#@file:}"); fi
78
78
  AGENT_SKILLS_PLANNER=$(node .nubos-pilot/bin/np-tools.cjs agent-skills planner 2>/dev/null)
79
79
  AGENT_SKILLS_CHECKER=$(node .nubos-pilot/bin/np-tools.cjs agent-skills plan-checker 2>/dev/null)
80
- RUNTIME=$(node -e "console.log(require('./lib/runtime/index.cjs').detect().runtime)")
80
+ RUNTIME=$(node .nubos-pilot/bin/np-tools.cjs detect-runtime)
81
81
  ```
82
82
 
83
83
  **Language (SSOT = `.nubos-pilot/config.json` → `response_language`).**
@@ -95,7 +95,7 @@ payload; larger payloads are written to a tmp file and referenced via
95
95
  LANG_DIRECTIVE=$(node .nubos-pilot/bin/np-tools.cjs lang-directive)
96
96
  INIT=$(node .nubos-pilot/bin/np-tools.cjs init research-phase "$PHASE")
97
97
  if [[ "$INIT" == @file:* ]]; then INIT=$(cat "${INIT#@file:}"); fi
98
- RUNTIME=$(node -e "console.log(require('./lib/runtime/index.cjs').detect().runtime)")
98
+ RUNTIME=$(node .nubos-pilot/bin/np-tools.cjs detect-runtime)
99
99
  ```
100
100
 
101
101
  **Language (SSOT = `.nubos-pilot/config.json` → `response_language`).**
@@ -22,7 +22,7 @@ fi
22
22
  LANG_DIRECTIVE=$(node .nubos-pilot/bin/np-tools.cjs lang-directive)
23
23
  INIT=$(node .nubos-pilot/bin/np-tools.cjs init verify-work "$PHASE")
24
24
  if [[ "$INIT" == @file:* ]]; then INIT=$(cat "${INIT#@file:}"); fi
25
- RUNTIME=$(node -e "console.log(require('./lib/runtime/index.cjs').detect().runtime)")
25
+ RUNTIME=$(node .nubos-pilot/bin/np-tools.cjs detect-runtime)
26
26
  ```
27
27
 
28
28
  **Language (SSOT = `.nubos-pilot/config.json` → `response_language`).**