nubos-pilot 1.3.1 → 1.3.2
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.
- package/CHANGELOG.md +10 -0
- package/bin/np-tools/doctor.cjs +25 -3
- package/bin/np-tools/resume-work.cjs +9 -0
- package/bin/np-tools/resume-work.test.cjs +21 -1
- package/lib/checkpoint-reconcile.cjs +42 -0
- package/lib/checkpoint-reconcile.test.cjs +106 -0
- package/lib/git.cjs +4 -2
- package/package.json +1 -1
- package/workflows/execute-phase.md +10 -2
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,16 @@ All notable changes to nubos-pilot are documented in this file. Format
|
|
|
4
4
|
follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/); versioning
|
|
5
5
|
follows [SemVer](https://semver.org/spec/v2.0.0.html).
|
|
6
6
|
|
|
7
|
+
## [1.3.3] — 2026-06-24
|
|
8
|
+
|
|
9
|
+
A finished milestone can no longer block the start of the next one with a stale checkpoint.
|
|
10
|
+
|
|
11
|
+
- `init resume-work` now reconciles every checkpoint against git before deciding orphan: a checkpoint whose task already has a `task(<id>):` commit is a tombstone left behind when the checkpoint was never unlinked (a crash between commit and unlink, or a commit made outside `commit-task`). Those are pruned silently and reported in `pruned_checkpoints`; only genuinely uncommitted checkpoints still surface as `orphan`. Git is the source of truth, so a committed task is never mistaken for in-flight work.
|
|
12
|
+
- `np:doctor` is git-aware for the same case: a committed-but-unlinked checkpoint is reported as `info` / `fixable: auto` with the commit sha, not as a manual-fix `warn`.
|
|
13
|
+
- The `execute-phase` orphan-checkpoint guard's two remediation options are now wired — "reset-slice" and "resume" were previously no-op `case` branches that left the file in place, so the prompt re-fired on every run.
|
|
14
|
+
|
|
15
|
+
Full documentation at <https://pilot.nubos.cloud>.
|
|
16
|
+
|
|
7
17
|
## [1.3.0] — 2026-06-17
|
|
8
18
|
|
|
9
19
|
Run any agent on any model, not only Claude.
|
package/bin/np-tools/doctor.cjs
CHANGED
|
@@ -543,6 +543,28 @@ function _checkOrphanCheckpoints(projectRoot) {
|
|
|
543
543
|
catch { continue; }
|
|
544
544
|
if (!cp || cp.status !== 'in-progress') continue;
|
|
545
545
|
if (currentTask === taskId) continue;
|
|
546
|
+
|
|
547
|
+
let committedSha = null;
|
|
548
|
+
try { committedSha = require('../../lib/checkpoint-reconcile.cjs').committedSha(taskId, projectRoot); }
|
|
549
|
+
catch { committedSha = null; }
|
|
550
|
+
|
|
551
|
+
if (committedSha) {
|
|
552
|
+
issues.push({
|
|
553
|
+
id: 'orphan-checkpoint',
|
|
554
|
+
severity: 'info',
|
|
555
|
+
fixable: 'auto',
|
|
556
|
+
details: {
|
|
557
|
+
task_id: taskId,
|
|
558
|
+
checkpoint: path.relative(projectRoot, cpPath),
|
|
559
|
+
current_task: currentTask,
|
|
560
|
+
committed_sha: committedSha,
|
|
561
|
+
hint: 'Task is already committed (' + committedSha.slice(0, 8) + ') but its checkpoint was never unlinked. '
|
|
562
|
+
+ 'A stale tombstone, not in-flight work. `np-tools resume-work` reconciles it against git and prunes it automatically.',
|
|
563
|
+
},
|
|
564
|
+
});
|
|
565
|
+
continue;
|
|
566
|
+
}
|
|
567
|
+
|
|
546
568
|
issues.push({
|
|
547
569
|
id: 'orphan-checkpoint',
|
|
548
570
|
severity: 'warn',
|
|
@@ -551,9 +573,9 @@ function _checkOrphanCheckpoints(projectRoot) {
|
|
|
551
573
|
task_id: taskId,
|
|
552
574
|
checkpoint: path.relative(projectRoot, cpPath),
|
|
553
575
|
current_task: currentTask,
|
|
554
|
-
hint: 'Checkpoint marks task as in-progress
|
|
555
|
-
+ 'Likely a crash
|
|
556
|
-
+ 'Run `np-tools undo-task ' + taskId + '` to clean up, or
|
|
576
|
+
hint: 'Checkpoint marks task as in-progress, no matching commit exists, and STATE.md.current_task does not match. '
|
|
577
|
+
+ 'Likely a genuine crash mid-flight. '
|
|
578
|
+
+ 'Run `np-tools undo-task ' + taskId + '` to clean up, or resume the task, after verifying its state.',
|
|
557
579
|
},
|
|
558
580
|
});
|
|
559
581
|
}
|
|
@@ -3,6 +3,7 @@ const path = require('node:path');
|
|
|
3
3
|
const { NubosPilotError } = require('../../lib/core.cjs');
|
|
4
4
|
const { readState } = require('../../lib/state.cjs');
|
|
5
5
|
const { readCheckpoint, listCheckpoints } = require('../../lib/checkpoint.cjs');
|
|
6
|
+
const { reconcileCommittedCheckpoints } = require('../../lib/checkpoint-reconcile.cjs');
|
|
6
7
|
const { TASK_ID_RE } = require('../../lib/ids.cjs');
|
|
7
8
|
const textMode = require('../../lib/text-mode.cjs');
|
|
8
9
|
const layout = require('../../lib/layout.cjs');
|
|
@@ -48,6 +49,12 @@ function run(_args, ctx) {
|
|
|
48
49
|
|
|
49
50
|
const state = _safeReadState(cwd);
|
|
50
51
|
const currentTask = state && state.frontmatter ? state.frontmatter.current_task : null;
|
|
52
|
+
|
|
53
|
+
let pruned = [];
|
|
54
|
+
try {
|
|
55
|
+
pruned = reconcileCommittedCheckpoints(cwd, { exclude: currentTask }).pruned;
|
|
56
|
+
} catch { pruned = []; }
|
|
57
|
+
|
|
51
58
|
const cpFiles = listCheckpoints(cwd);
|
|
52
59
|
|
|
53
60
|
let payload;
|
|
@@ -104,6 +111,8 @@ function run(_args, ctx) {
|
|
|
104
111
|
};
|
|
105
112
|
}
|
|
106
113
|
|
|
114
|
+
if (pruned.length > 0) payload.pruned_checkpoints = pruned;
|
|
115
|
+
|
|
107
116
|
const tmDetail = textMode.resolveTextModeDetail(cwd);
|
|
108
117
|
payload.text_mode = tmDetail.enabled;
|
|
109
118
|
payload.text_mode_source = tmDetail.source;
|
|
@@ -3,9 +3,10 @@ const assert = require('node:assert/strict');
|
|
|
3
3
|
const fs = require('node:fs');
|
|
4
4
|
const path = require('node:path');
|
|
5
5
|
const os = require('node:os');
|
|
6
|
+
const { execFileSync } = require('node:child_process');
|
|
6
7
|
|
|
7
8
|
const subcmd = require('./resume-work.cjs');
|
|
8
|
-
const { startTask } = require('../../lib/checkpoint.cjs');
|
|
9
|
+
const { startTask, listCheckpoints } = require('../../lib/checkpoint.cjs');
|
|
9
10
|
|
|
10
11
|
const _roots = [];
|
|
11
12
|
|
|
@@ -78,6 +79,25 @@ test('RW-3: orphan when checkpoint files exist but no matching STATE.current_tas
|
|
|
78
79
|
assert.ok(p.checkpoint_ids.includes('M006-S001-T0005'));
|
|
79
80
|
});
|
|
80
81
|
|
|
82
|
+
test('RW-5: committed orphan is reconciled against git and pruned (not surfaced)', () => {
|
|
83
|
+
const root = makeRoot(null);
|
|
84
|
+
execFileSync('git', ['init', '-q', '-b', 'main', root], { stdio: 'pipe' });
|
|
85
|
+
execFileSync('git', ['-C', root, 'config', 'user.email', 'test@nubos.local']);
|
|
86
|
+
execFileSync('git', ['-C', root, 'config', 'user.name', 'nubos-test']);
|
|
87
|
+
execFileSync('git', ['-C', root, 'commit', '--allow-empty', '-q', '-m', 'chore: init'], { stdio: 'pipe' });
|
|
88
|
+
startTask({ id: 'M013-S005-T0002', phase: 6, plan: '06-01', wave: 1 }, root);
|
|
89
|
+
execFileSync('git', ['-C', root, 'commit', '--allow-empty', '-q', '-m', 'task(M013-S005-T0002): demo'], { stdio: 'pipe' });
|
|
90
|
+
const statePath = path.join(root, '.nubos-pilot', 'STATE.md');
|
|
91
|
+
fs.writeFileSync(statePath, fs.readFileSync(statePath, 'utf-8').replace(/current_task:.*/, 'current_task: null'), 'utf-8');
|
|
92
|
+
|
|
93
|
+
const cap = _capture();
|
|
94
|
+
const p = subcmd.run([], { cwd: root, stdout: cap.stub });
|
|
95
|
+
assert.equal(p.status, 'clean');
|
|
96
|
+
assert.ok(Array.isArray(p.pruned_checkpoints));
|
|
97
|
+
assert.equal(p.pruned_checkpoints[0].task_id, 'M013-S005-T0002');
|
|
98
|
+
assert.deepEqual(listCheckpoints(root), []);
|
|
99
|
+
});
|
|
100
|
+
|
|
81
101
|
test('RW-4: malformed checkpoint → checkpoint-schema-mismatch (T-06-12)', () => {
|
|
82
102
|
const root = makeRoot('M006-S001-T0009');
|
|
83
103
|
const cpDir = path.join(root, '.nubos-pilot', 'checkpoints');
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
const path = require('node:path');
|
|
2
|
+
const { listCheckpoints, deleteCheckpoint } = require('./checkpoint.cjs');
|
|
3
|
+
const { findCommitByTaskId } = require('./git.cjs');
|
|
4
|
+
const { TASK_ID_RE } = require('./ids.cjs');
|
|
5
|
+
|
|
6
|
+
function committedSha(taskId, cwd) {
|
|
7
|
+
try {
|
|
8
|
+
return findCommitByTaskId(taskId, cwd);
|
|
9
|
+
} catch {
|
|
10
|
+
return null;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
function reconcileCommittedCheckpoints(cwd = process.cwd(), opts = {}) {
|
|
15
|
+
const exclude = opts.exclude || null;
|
|
16
|
+
const pruned = [];
|
|
17
|
+
const remaining = [];
|
|
18
|
+
for (const file of listCheckpoints(cwd)) {
|
|
19
|
+
const taskId = path.basename(file, '.json');
|
|
20
|
+
if (!TASK_ID_RE.test(taskId)) {
|
|
21
|
+
remaining.push(taskId);
|
|
22
|
+
continue;
|
|
23
|
+
}
|
|
24
|
+
if (exclude && taskId === exclude) {
|
|
25
|
+
remaining.push(taskId);
|
|
26
|
+
continue;
|
|
27
|
+
}
|
|
28
|
+
const sha = committedSha(taskId, cwd);
|
|
29
|
+
if (sha) {
|
|
30
|
+
deleteCheckpoint(taskId, cwd);
|
|
31
|
+
pruned.push({ task_id: taskId, sha });
|
|
32
|
+
} else {
|
|
33
|
+
remaining.push(taskId);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
return { pruned, remaining };
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
module.exports = {
|
|
40
|
+
committedSha,
|
|
41
|
+
reconcileCommittedCheckpoints,
|
|
42
|
+
};
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
const { test, after } = require('node:test');
|
|
2
|
+
const assert = require('node:assert/strict');
|
|
3
|
+
const fs = require('node:fs');
|
|
4
|
+
const path = require('node:path');
|
|
5
|
+
const os = require('node:os');
|
|
6
|
+
const { execFileSync } = require('node:child_process');
|
|
7
|
+
|
|
8
|
+
const { startTask, listCheckpoints } = require('./checkpoint.cjs');
|
|
9
|
+
const { reconcileCommittedCheckpoints, committedSha } = require('./checkpoint-reconcile.cjs');
|
|
10
|
+
|
|
11
|
+
const _repos = [];
|
|
12
|
+
|
|
13
|
+
function makeRepo() {
|
|
14
|
+
const root = fs.mkdtempSync(path.join(os.tmpdir(), 'np-cr-'));
|
|
15
|
+
execFileSync('git', ['init', '-q', '-b', 'main', root], { stdio: 'pipe' });
|
|
16
|
+
execFileSync('git', ['-C', root, 'config', 'user.email', 'test@nubos.local']);
|
|
17
|
+
execFileSync('git', ['-C', root, 'config', 'user.name', 'nubos-test']);
|
|
18
|
+
execFileSync('git', ['-C', root, 'commit', '--allow-empty', '-q', '-m', 'chore: init'], { stdio: 'pipe' });
|
|
19
|
+
fs.mkdirSync(path.join(root, '.nubos-pilot'), { recursive: true });
|
|
20
|
+
fs.writeFileSync(path.join(root, '.nubos-pilot', 'STATE.md'), `---
|
|
21
|
+
schema_version: 2
|
|
22
|
+
milestone: m1
|
|
23
|
+
milestone_name: m1
|
|
24
|
+
current_phase: null
|
|
25
|
+
current_plan: null
|
|
26
|
+
current_task: null
|
|
27
|
+
last_updated: "2026-04-15T00:00:00Z"
|
|
28
|
+
progress:
|
|
29
|
+
total_phases: 0
|
|
30
|
+
completed_phases: 0
|
|
31
|
+
total_plans: 0
|
|
32
|
+
completed_plans: 0
|
|
33
|
+
percent: 0
|
|
34
|
+
session:
|
|
35
|
+
stopped_at: null
|
|
36
|
+
resume_file: null
|
|
37
|
+
last_activity: null
|
|
38
|
+
---
|
|
39
|
+
|
|
40
|
+
# State
|
|
41
|
+
`, 'utf-8');
|
|
42
|
+
_repos.push(root);
|
|
43
|
+
return root;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
function commitFor(root, taskId) {
|
|
47
|
+
execFileSync('git', ['-C', root, 'commit', '--allow-empty', '-q', '-m', `task(${taskId}): demo`], { stdio: 'pipe' });
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
after(() => {
|
|
51
|
+
while (_repos.length) {
|
|
52
|
+
const r = _repos.pop();
|
|
53
|
+
try { fs.rmSync(r, { recursive: true, force: true }); } catch {}
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
test('CR-1: prunes a checkpoint whose task already has a commit', () => {
|
|
58
|
+
const root = makeRepo();
|
|
59
|
+
startTask({ id: 'M013-S005-T0002', phase: 6, plan: '06-01', wave: 1 }, root);
|
|
60
|
+
commitFor(root, 'M013-S005-T0002');
|
|
61
|
+
|
|
62
|
+
const { pruned, remaining } = reconcileCommittedCheckpoints(root);
|
|
63
|
+
assert.equal(pruned.length, 1);
|
|
64
|
+
assert.equal(pruned[0].task_id, 'M013-S005-T0002');
|
|
65
|
+
assert.match(pruned[0].sha, /^[0-9a-f]{40}$/);
|
|
66
|
+
assert.deepEqual(remaining, []);
|
|
67
|
+
assert.deepEqual(listCheckpoints(root), []);
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
test('CR-2: keeps a checkpoint with no matching commit (genuine orphan)', () => {
|
|
71
|
+
const root = makeRepo();
|
|
72
|
+
startTask({ id: 'M013-S005-T0003', phase: 6, plan: '06-01', wave: 1 }, root);
|
|
73
|
+
|
|
74
|
+
const { pruned, remaining } = reconcileCommittedCheckpoints(root);
|
|
75
|
+
assert.deepEqual(pruned, []);
|
|
76
|
+
assert.deepEqual(remaining, ['M013-S005-T0003']);
|
|
77
|
+
assert.equal(listCheckpoints(root).length, 1);
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
test('CR-3: excludes the active current_task even when committed', () => {
|
|
81
|
+
const root = makeRepo();
|
|
82
|
+
startTask({ id: 'M013-S005-T0004', phase: 6, plan: '06-01', wave: 1 }, root);
|
|
83
|
+
commitFor(root, 'M013-S005-T0004');
|
|
84
|
+
|
|
85
|
+
const { pruned, remaining } = reconcileCommittedCheckpoints(root, { exclude: 'M013-S005-T0004' });
|
|
86
|
+
assert.deepEqual(pruned, []);
|
|
87
|
+
assert.deepEqual(remaining, ['M013-S005-T0004']);
|
|
88
|
+
assert.equal(listCheckpoints(root).length, 1);
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
test('CR-4: prunes committed tombstone but keeps uncommitted sibling', () => {
|
|
92
|
+
const root = makeRepo();
|
|
93
|
+
startTask({ id: 'M013-S005-T0002', phase: 6, plan: '06-01', wave: 1 }, root);
|
|
94
|
+
startTask({ id: 'M013-S005-T0003', phase: 6, plan: '06-01', wave: 1 }, root);
|
|
95
|
+
commitFor(root, 'M013-S005-T0002');
|
|
96
|
+
|
|
97
|
+
const { pruned, remaining } = reconcileCommittedCheckpoints(root);
|
|
98
|
+
assert.deepEqual(pruned.map((p) => p.task_id), ['M013-S005-T0002']);
|
|
99
|
+
assert.deepEqual(remaining, ['M013-S005-T0003']);
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
test('CR-5: committedSha returns null outside a git repo (no throw)', () => {
|
|
103
|
+
const root = fs.mkdtempSync(path.join(os.tmpdir(), 'np-cr-nogit-'));
|
|
104
|
+
_repos.push(root);
|
|
105
|
+
assert.equal(committedSha('M013-S005-T0002', root), null);
|
|
106
|
+
});
|
package/lib/git.cjs
CHANGED
|
@@ -92,7 +92,7 @@ function commitTask(taskId, files, message) {
|
|
|
92
92
|
};
|
|
93
93
|
}
|
|
94
94
|
|
|
95
|
-
function findCommitByTaskId(id) {
|
|
95
|
+
function findCommitByTaskId(id, cwd) {
|
|
96
96
|
if (typeof id !== 'string' || !TASK_ID_RE.test(id)) {
|
|
97
97
|
throw new NubosPilotError(
|
|
98
98
|
'task-commit-not-found',
|
|
@@ -101,6 +101,8 @@ function findCommitByTaskId(id) {
|
|
|
101
101
|
);
|
|
102
102
|
}
|
|
103
103
|
|
|
104
|
+
const spawnOpts = { encoding: 'utf-8', timeout: GIT_TIMEOUT_MS };
|
|
105
|
+
if (cwd) spawnOpts.cwd = cwd;
|
|
104
106
|
const out = execFileSync(
|
|
105
107
|
'git',
|
|
106
108
|
[
|
|
@@ -112,7 +114,7 @@ function findCommitByTaskId(id) {
|
|
|
112
114
|
'1',
|
|
113
115
|
'--format=%H',
|
|
114
116
|
],
|
|
115
|
-
|
|
117
|
+
spawnOpts,
|
|
116
118
|
).trim();
|
|
117
119
|
if (!out) {
|
|
118
120
|
throw new NubosPilotError(
|
package/package.json
CHANGED
|
@@ -118,16 +118,17 @@ If zero skills match, omit the block — do **not** invent skills. Adding new sk
|
|
|
118
118
|
|
|
119
119
|
## Pre-Flight — orphan-checkpoint guard
|
|
120
120
|
|
|
121
|
-
Detect stale checkpoints from a prior run before starting new work:
|
|
121
|
+
Detect stale checkpoints from a prior run before starting new work. `init resume-work` first **reconciles every checkpoint against git** (`lib/checkpoint-reconcile.cjs`): any checkpoint whose task already has a `task(<id>):` commit is a tombstone (finishTask never unlinked it — crash between commit and unlink, or a commit made outside `commit-task`) and is pruned silently. They surface in `RESUME.pruned_checkpoints` for the log, never as a prompt. Only genuinely **uncommitted** checkpoints reach `status: orphan` and the dialog below — so a finished milestone can never block the next one.
|
|
122
122
|
|
|
123
123
|
```bash
|
|
124
124
|
RESUME=$(node .nubos-pilot/bin/np-tools.cjs init resume-work)
|
|
125
125
|
RESUME_STATUS=$(echo "$RESUME" | node -e "process.stdin.on('data', d => console.log(JSON.parse(d).status))")
|
|
126
126
|
if [ "$RESUME_STATUS" = "orphan" ]; then
|
|
127
|
+
ORPHAN_ID=$(echo "$RESUME" | node -e "process.stdin.on('data', d => { const p = JSON.parse(d); console.log((p.checkpoint_ids || [])[0] || '') })")
|
|
127
128
|
CHOICE=$(node .nubos-pilot/bin/np-tools.cjs askuser --json '{
|
|
128
129
|
"type": "select",
|
|
129
130
|
"header": "Verwaiste Checkpoints gefunden",
|
|
130
|
-
"question": "Vor dem Milestone-Start
|
|
131
|
+
"question": "Vor dem Milestone-Start wurde ein uncommitteter Checkpoint ohne passenden STATE.current_task gefunden (kein zugehöriger Commit). Was tun?",
|
|
131
132
|
"options": [
|
|
132
133
|
{"label": "Clean working tree (reset-slice)", "description": "Verwirft die in-flight Task und löscht ihren Checkpoint."},
|
|
133
134
|
{"label": "Resume the orphan task", "description": "Setzt STATE.current_task auf den Checkpoint-Eintrag und spawnt den Executor."},
|
|
@@ -135,6 +136,13 @@ if [ "$RESUME_STATUS" = "orphan" ]; then
|
|
|
135
136
|
]
|
|
136
137
|
}')
|
|
137
138
|
case "$CHOICE" in
|
|
139
|
+
"Clean working tree (reset-slice)")
|
|
140
|
+
node .nubos-pilot/bin/np-tools.cjs reset-slice "$ORPHAN_ID"
|
|
141
|
+
;;
|
|
142
|
+
"Resume the orphan task")
|
|
143
|
+
echo "execute-phase: resuming orphan task $ORPHAN_ID — run /np:resume-work" >&2
|
|
144
|
+
exit 0
|
|
145
|
+
;;
|
|
138
146
|
"Abort") exit 0 ;;
|
|
139
147
|
esac
|
|
140
148
|
fi
|