@ai-dossier/cli 0.14.0 → 0.19.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.
- package/README.md +169 -0
- package/dist/cache-resolver.d.ts.map +1 -1
- package/dist/cache-resolver.js +2 -11
- package/dist/cache-resolver.js.map +1 -1
- package/dist/cap-log.d.ts +31 -0
- package/dist/cap-log.d.ts.map +1 -0
- package/dist/cap-log.js +30 -0
- package/dist/cap-log.js.map +1 -0
- package/dist/capability.d.ts +108 -0
- package/dist/capability.d.ts.map +1 -0
- package/dist/capability.js +407 -0
- package/dist/capability.js.map +1 -0
- package/dist/cli.js +6 -0
- package/dist/cli.js.map +1 -1
- package/dist/commands/cap.d.ts +13 -0
- package/dist/commands/cap.d.ts.map +1 -0
- package/dist/commands/cap.js +105 -0
- package/dist/commands/cap.js.map +1 -0
- package/dist/commands/plan.d.ts +20 -0
- package/dist/commands/plan.d.ts.map +1 -0
- package/dist/commands/plan.js +323 -0
- package/dist/commands/plan.js.map +1 -0
- package/dist/commands/runstate.d.ts.map +1 -1
- package/dist/commands/runstate.js +51 -290
- package/dist/commands/runstate.js.map +1 -1
- package/dist/commands/sched.d.ts +13 -0
- package/dist/commands/sched.d.ts.map +1 -0
- package/dist/commands/sched.js +432 -0
- package/dist/commands/sched.js.map +1 -0
- package/dist/gh.d.ts +155 -0
- package/dist/gh.d.ts.map +1 -0
- package/dist/gh.js +357 -0
- package/dist/gh.js.map +1 -0
- package/dist/helpers.d.ts +7 -0
- package/dist/helpers.d.ts.map +1 -1
- package/dist/helpers.js +19 -0
- package/dist/helpers.js.map +1 -1
- package/dist/issue-selection.js +2 -2
- package/dist/issue-selection.js.map +1 -1
- package/dist/jsonl-log.d.ts +14 -0
- package/dist/jsonl-log.d.ts.map +1 -0
- package/dist/jsonl-log.js +32 -0
- package/dist/jsonl-log.js.map +1 -0
- package/dist/plan-artifact.d.ts +123 -0
- package/dist/plan-artifact.d.ts.map +1 -0
- package/dist/plan-artifact.js +213 -0
- package/dist/plan-artifact.js.map +1 -0
- package/dist/run-log.d.ts.map +1 -1
- package/dist/run-log.js +2 -9
- package/dist/run-log.js.map +1 -1
- package/dist/runstate.d.ts +0 -2
- package/dist/runstate.d.ts.map +1 -1
- package/dist/runstate.js +2 -5
- package/dist/runstate.js.map +1 -1
- package/dist/version.d.ts +10 -0
- package/dist/version.d.ts.map +1 -0
- package/dist/version.js +23 -0
- package/dist/version.js.map +1 -0
- package/package.json +3 -2
|
@@ -0,0 +1,432 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* `ai-dossier sched` — the deterministic scheduler core (RFC-0001 §C.1, issue #460).
|
|
4
|
+
*
|
|
5
|
+
* enqueue / status / pause / resume / abandon manage the queue and state
|
|
6
|
+
* (#460); `sched start` runs the dispatch engine (#464: spawning agent
|
|
7
|
+
* processes, verifying their completion against ground truth, mechanizing
|
|
8
|
+
* the stall/escalation ladder) and since #468 also the detached-ship tail:
|
|
9
|
+
* watching parked PRs, script-based teardown of merged worktrees, and the
|
|
10
|
+
* cheap-tier report dispatch.
|
|
11
|
+
*/
|
|
12
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
13
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
14
|
+
};
|
|
15
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
|
+
exports.registerSchedCommand = registerSchedCommand;
|
|
17
|
+
const node_fs_1 = __importDefault(require("node:fs"));
|
|
18
|
+
const sched_1 = require("@ai-dossier/sched");
|
|
19
|
+
const duration_1 = require("../duration");
|
|
20
|
+
const helpers_1 = require("../helpers");
|
|
21
|
+
const issue_selection_1 = require("../issue-selection");
|
|
22
|
+
const table_1 = require("../table");
|
|
23
|
+
function parseMode(raw) {
|
|
24
|
+
if (raw === undefined || raw === 'full')
|
|
25
|
+
return 'full';
|
|
26
|
+
if (raw === 'slot')
|
|
27
|
+
return 'slot';
|
|
28
|
+
(0, helpers_1.fail)([`--mode must be 'full' or 'slot', got '${raw}'`]);
|
|
29
|
+
}
|
|
30
|
+
function parseTier(raw) {
|
|
31
|
+
if (raw === undefined || raw === 'mid')
|
|
32
|
+
return 'mid';
|
|
33
|
+
if (raw === 'mechanical' || raw === 'strong')
|
|
34
|
+
return raw;
|
|
35
|
+
(0, helpers_1.fail)([`--tier must be mechanical | mid | strong, got '${raw}'`]);
|
|
36
|
+
}
|
|
37
|
+
/** Parse an issue selection (`4,5` or `4..9`), failing through the CLI's exit path. */
|
|
38
|
+
function issueList(raw, flag) {
|
|
39
|
+
try {
|
|
40
|
+
return (0, issue_selection_1.parseIssueSelection)(raw);
|
|
41
|
+
}
|
|
42
|
+
catch (err) {
|
|
43
|
+
(0, helpers_1.fail)([`--${flag}: ${err.message}`]);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Resolve the state store: explicit `--project`, else the repo's slug
|
|
48
|
+
* (gh owner-repo, git toplevel basename fallback — fleet-cycle's convention).
|
|
49
|
+
*/
|
|
50
|
+
function resolveStore(opts) {
|
|
51
|
+
const project = opts.project ?? (0, sched_1.resolveProjectSlug)(sched_1.defaultExec);
|
|
52
|
+
if (!opts.project && project === 'default') {
|
|
53
|
+
console.error('⚠ Could not resolve a repo from the current directory — operating on the "default" state bucket. Run sched from the repo, or pass --project.');
|
|
54
|
+
}
|
|
55
|
+
return { store: new sched_1.SchedStore((0, sched_1.schedStateDir)(project)), project };
|
|
56
|
+
}
|
|
57
|
+
/** Route package errors through the CLI's exit path instead of a stack trace. */
|
|
58
|
+
function handleKnownError(err) {
|
|
59
|
+
if (err instanceof sched_1.CorruptStateError ||
|
|
60
|
+
err instanceof sched_1.LockTimeoutError ||
|
|
61
|
+
err instanceof sched_1.EnqueueError ||
|
|
62
|
+
err instanceof sched_1.IllegalTransitionError ||
|
|
63
|
+
err instanceof sched_1.SchedNotFoundError) {
|
|
64
|
+
(0, helpers_1.fail)([err.message]);
|
|
65
|
+
}
|
|
66
|
+
throw err;
|
|
67
|
+
}
|
|
68
|
+
// --- status rendering (the CLI's shared table renderer, like every other
|
|
69
|
+
// table-printing command; the package deliberately has no CLI dependencies) ---
|
|
70
|
+
function renderReport(report) {
|
|
71
|
+
const lines = [];
|
|
72
|
+
const state = report.paused ? 'PAUSED' : 'running';
|
|
73
|
+
const runnable = report.runnable_units.length > 0 ? report.runnable_units.join(', ') : 'none';
|
|
74
|
+
lines.push(`Scheduler [${report.project}]: ${state} · slots ${report.live_slots}/${report.max_slots} live`);
|
|
75
|
+
lines.push(`Runnable units: ${runnable}`);
|
|
76
|
+
lines.push('');
|
|
77
|
+
lines.push('== Queue ==');
|
|
78
|
+
lines.push((0, table_1.renderTable)(['issue', 'mode', 'batch', 'tier', 'deps', 'status', 'pr', 'cleanup'], report.queue.map((e) => [
|
|
79
|
+
`#${e.issue}`,
|
|
80
|
+
e.mode,
|
|
81
|
+
e.batch ?? '-',
|
|
82
|
+
e.tier,
|
|
83
|
+
e.deps.length > 0 ? e.deps.map((d) => `#${d}`).join(',') : '-',
|
|
84
|
+
e.status,
|
|
85
|
+
e.pr !== null && e.pr !== undefined ? String(e.pr) : '-',
|
|
86
|
+
e.cleanup ?? '-',
|
|
87
|
+
])));
|
|
88
|
+
lines.push('');
|
|
89
|
+
if (report.parked.length > 0) {
|
|
90
|
+
const lastPoll = report.last_pr_poll_at
|
|
91
|
+
? `; last poll ${relativeTime(report.last_pr_poll_at)}`
|
|
92
|
+
: '; never polled';
|
|
93
|
+
lines.push(`== Parked PRs (watched, zero slots${lastPoll}) ==`);
|
|
94
|
+
lines.push(report.parked
|
|
95
|
+
.map((p) => `#${p.issue} — PR #${p.pr} (parked ${relativeTime(p.since)})`)
|
|
96
|
+
.join('\n'));
|
|
97
|
+
lines.push('');
|
|
98
|
+
}
|
|
99
|
+
lines.push('== Slots ==');
|
|
100
|
+
lines.push(report.slots.length === 0
|
|
101
|
+
? '(no slots materialized yet)'
|
|
102
|
+
: (0, table_1.renderTable)(['slot', 'status', 'unit', 'pid', 'phase', 'last-progress', 'recoveries'], report.slots.map((s) => [
|
|
103
|
+
String(s.id),
|
|
104
|
+
s.status,
|
|
105
|
+
s.unit ?? '-',
|
|
106
|
+
s.pid !== null ? String(s.pid) : '-',
|
|
107
|
+
s.phase ?? '-',
|
|
108
|
+
s.last_progress_at !== null ? relativeTime(s.last_progress_at) : '-',
|
|
109
|
+
String(s.recoveries),
|
|
110
|
+
])));
|
|
111
|
+
lines.push('');
|
|
112
|
+
lines.push('== Batches ==');
|
|
113
|
+
lines.push(report.batches.length === 0
|
|
114
|
+
? '(no batches)'
|
|
115
|
+
: (0, table_1.renderTable)(['batch', 'status', 'members', 'member-in-work'], report.batches.map((b) => [
|
|
116
|
+
b.id,
|
|
117
|
+
b.status,
|
|
118
|
+
b.members.length > 0 ? b.members.map((m) => `#${m}`).join(',') : '-',
|
|
119
|
+
b.executing_member > 0 ? `${b.executing_member}/${b.members.length}` : '-',
|
|
120
|
+
])));
|
|
121
|
+
lines.push('');
|
|
122
|
+
lines.push('== Blocked ==');
|
|
123
|
+
lines.push(report.blocked.length > 0
|
|
124
|
+
? report.blocked.map((b) => `#${b.issue} [${b.status}] — ${b.reason}`).join('\n')
|
|
125
|
+
: '(none)');
|
|
126
|
+
lines.push('');
|
|
127
|
+
lines.push('== Failed ==');
|
|
128
|
+
lines.push(report.failed.length > 0
|
|
129
|
+
? report.failed.map((f) => `#${f.issue} — ${f.reason ?? f.status}`).join('\n')
|
|
130
|
+
: '(none)');
|
|
131
|
+
return lines.join('\n');
|
|
132
|
+
}
|
|
133
|
+
/** `5m ago` / `2h ago` — compact last-progress rendering for the slot table. */
|
|
134
|
+
function relativeTime(iso, now = Date.now()) {
|
|
135
|
+
const then = Date.parse(iso);
|
|
136
|
+
if (Number.isNaN(then))
|
|
137
|
+
return '-';
|
|
138
|
+
return (0, duration_1.formatAge)(Math.max(0, now - then), ' ago');
|
|
139
|
+
}
|
|
140
|
+
// --- subcommands ---
|
|
141
|
+
function registerEnqueueSubcommand(cmd) {
|
|
142
|
+
cmd
|
|
143
|
+
.command('enqueue')
|
|
144
|
+
.description('Add issues to the scheduler queue (flags, a --from-manifest JSON file, or both)')
|
|
145
|
+
.option('--issues <numbers>', 'Comma-separated issue numbers or ranges, e.g. 101,105..109')
|
|
146
|
+
.option('--mode <mode>', "Execution mode: 'full' (default) or 'slot'", 'full')
|
|
147
|
+
.option('--batch <id>', 'Batch id (required for slot mode)')
|
|
148
|
+
.option('--deps <numbers>', 'Comma-separated dependency issue numbers (applied to all)')
|
|
149
|
+
.option('--tier <tier>', 'Model tier: mechanical | mid (default) | strong', 'mid')
|
|
150
|
+
.option('--from-manifest <path>', 'JSON file of entries (batch-prep output)')
|
|
151
|
+
.option('--project <slug>', 'Project slug (default: owner-repo of the current directory)')
|
|
152
|
+
.option('--json', 'Output the result as JSON')
|
|
153
|
+
.action((opts) => {
|
|
154
|
+
const { store, project } = resolveStore(opts);
|
|
155
|
+
const inputs = [];
|
|
156
|
+
let manifestProject = null;
|
|
157
|
+
if (opts.fromManifest) {
|
|
158
|
+
let raw;
|
|
159
|
+
try {
|
|
160
|
+
raw = node_fs_1.default.readFileSync(opts.fromManifest, 'utf-8');
|
|
161
|
+
}
|
|
162
|
+
catch (err) {
|
|
163
|
+
(0, helpers_1.fail)([`Cannot read manifest ${opts.fromManifest}: ${err.message}`]);
|
|
164
|
+
}
|
|
165
|
+
let parsed;
|
|
166
|
+
try {
|
|
167
|
+
parsed = JSON.parse(raw);
|
|
168
|
+
}
|
|
169
|
+
catch (err) {
|
|
170
|
+
(0, helpers_1.fail)([`Manifest is not valid JSON: ${err.message}`]);
|
|
171
|
+
}
|
|
172
|
+
if (parsed &&
|
|
173
|
+
typeof parsed === 'object' &&
|
|
174
|
+
typeof parsed.project === 'string') {
|
|
175
|
+
manifestProject = parsed.project;
|
|
176
|
+
}
|
|
177
|
+
try {
|
|
178
|
+
inputs.push(...(0, sched_1.parseManifest)(parsed));
|
|
179
|
+
}
|
|
180
|
+
catch (err) {
|
|
181
|
+
(0, helpers_1.fail)([err.message]);
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
if (manifestProject !== null && manifestProject !== project) {
|
|
185
|
+
console.error(`⚠ Manifest was prepared for project '${manifestProject}' but enqueueing into '${project}'`);
|
|
186
|
+
}
|
|
187
|
+
if (opts.issues) {
|
|
188
|
+
const mode = parseMode(opts.mode);
|
|
189
|
+
const tier = parseTier(opts.tier);
|
|
190
|
+
const deps = opts.deps ? issueList(opts.deps, 'deps') : [];
|
|
191
|
+
for (const issue of issueList(opts.issues, 'issues')) {
|
|
192
|
+
inputs.push({ issue, mode, batch: opts.batch ?? null, deps, tier });
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
if (inputs.length === 0) {
|
|
196
|
+
(0, helpers_1.fail)(['Nothing to enqueue — pass --issues or --from-manifest']);
|
|
197
|
+
}
|
|
198
|
+
let enqueued;
|
|
199
|
+
try {
|
|
200
|
+
enqueued = store.withLock((state) => {
|
|
201
|
+
const next = (0, sched_1.enqueueEntries)(state, inputs);
|
|
202
|
+
return { state: next, result: next.entries.length };
|
|
203
|
+
});
|
|
204
|
+
}
|
|
205
|
+
catch (err) {
|
|
206
|
+
handleKnownError(err);
|
|
207
|
+
}
|
|
208
|
+
if (opts.json) {
|
|
209
|
+
console.log(JSON.stringify({ project, enqueued: inputs.length, queue_depth: enqueued }));
|
|
210
|
+
}
|
|
211
|
+
else {
|
|
212
|
+
console.log(`✓ Enqueued ${inputs.length} issue(s) for ${project} (queue depth: ${enqueued})`);
|
|
213
|
+
}
|
|
214
|
+
});
|
|
215
|
+
}
|
|
216
|
+
function registerStatusSubcommand(cmd) {
|
|
217
|
+
cmd
|
|
218
|
+
.command('status')
|
|
219
|
+
.description('Render the queue, slots, batches, and blocked/failed sets')
|
|
220
|
+
.option('--project <slug>', 'Project slug (default: owner-repo of the current directory)')
|
|
221
|
+
.option('--json', 'Output the report as JSON')
|
|
222
|
+
.action((opts) => {
|
|
223
|
+
const { store, project } = resolveStore(opts);
|
|
224
|
+
try {
|
|
225
|
+
const report = (0, sched_1.buildStatusReport)(store.load(), store.loadConfig(), project);
|
|
226
|
+
if (opts.json) {
|
|
227
|
+
console.log(JSON.stringify(report, null, 2));
|
|
228
|
+
}
|
|
229
|
+
else {
|
|
230
|
+
console.log(renderReport(report));
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
catch (err) {
|
|
234
|
+
handleKnownError(err);
|
|
235
|
+
}
|
|
236
|
+
});
|
|
237
|
+
}
|
|
238
|
+
function registerPauseResumeSubcommand(cmd, pause) {
|
|
239
|
+
cmd
|
|
240
|
+
.command(pause ? 'pause' : 'resume')
|
|
241
|
+
.description(pause
|
|
242
|
+
? 'Stop making new slot assignments (live units keep running)'
|
|
243
|
+
: 'Resume making new slot assignments')
|
|
244
|
+
.option('--project <slug>', 'Project slug (default: owner-repo of the current directory)')
|
|
245
|
+
.option('--json', 'Output the result as JSON')
|
|
246
|
+
.action((opts) => {
|
|
247
|
+
const { store, project } = resolveStore(opts);
|
|
248
|
+
try {
|
|
249
|
+
const paused = store.withLock((state) => ({
|
|
250
|
+
state: (0, sched_1.setPaused)(state, pause),
|
|
251
|
+
result: pause,
|
|
252
|
+
}));
|
|
253
|
+
if (opts.json) {
|
|
254
|
+
console.log(JSON.stringify({ project, paused }));
|
|
255
|
+
}
|
|
256
|
+
else {
|
|
257
|
+
console.log(paused ? '⏸ Scheduler paused' : '▶ Scheduler resumed');
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
catch (err) {
|
|
261
|
+
handleKnownError(err);
|
|
262
|
+
}
|
|
263
|
+
});
|
|
264
|
+
}
|
|
265
|
+
function registerAbandonSubcommand(cmd) {
|
|
266
|
+
cmd
|
|
267
|
+
.command('abandon')
|
|
268
|
+
.description('Fail an issue entry (or dissolve a batch and requeue its members as full-cycle)')
|
|
269
|
+
.option('--issue <number>', 'Issue number to abandon')
|
|
270
|
+
.option('--batch <id>', 'Batch id to dissolve')
|
|
271
|
+
.option('--reason <text>', 'Reason recorded on the entry')
|
|
272
|
+
.option('--project <slug>', 'Project slug (default: owner-repo of the current directory)')
|
|
273
|
+
.option('--json', 'Output the result as JSON')
|
|
274
|
+
.action((opts) => {
|
|
275
|
+
if ((opts.issue ? 1 : 0) + (opts.batch ? 1 : 0) !== 1) {
|
|
276
|
+
(0, helpers_1.fail)(['Pass exactly one of --issue <number> or --batch <id>']);
|
|
277
|
+
}
|
|
278
|
+
const { store } = resolveStore(opts);
|
|
279
|
+
const reason = opts.reason ?? 'abandoned';
|
|
280
|
+
try {
|
|
281
|
+
if (opts.issue) {
|
|
282
|
+
const issue = issueList(opts.issue, 'issue')[0];
|
|
283
|
+
const result = store.withLock((state) => {
|
|
284
|
+
const r = (0, sched_1.abandonIssue)(state, issue, reason);
|
|
285
|
+
return { state: r.state, result: r.releasedSlots };
|
|
286
|
+
});
|
|
287
|
+
if (opts.json) {
|
|
288
|
+
console.log(JSON.stringify({ abandoned: `issue:${issue}`, released_slots: result }));
|
|
289
|
+
}
|
|
290
|
+
else {
|
|
291
|
+
console.log(`✓ Abandoned issue #${issue} (released ${result.length} slot(s))`);
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
else if (opts.batch) {
|
|
295
|
+
const requeued = store.withLock((state) => {
|
|
296
|
+
const r = (0, sched_1.abandonBatch)(state, opts.batch, reason);
|
|
297
|
+
return { state: r.state, result: r.requeued };
|
|
298
|
+
});
|
|
299
|
+
if (opts.json) {
|
|
300
|
+
console.log(JSON.stringify({ abandoned: `batch:${opts.batch}`, requeued }));
|
|
301
|
+
}
|
|
302
|
+
else {
|
|
303
|
+
console.log(`✓ Dissolved batch ${opts.batch}; requeued ${requeued.length} member(s) as full-cycle`);
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
catch (err) {
|
|
308
|
+
handleKnownError(err);
|
|
309
|
+
}
|
|
310
|
+
});
|
|
311
|
+
}
|
|
312
|
+
function registerStartSubcommand(cmd) {
|
|
313
|
+
cmd
|
|
314
|
+
.command('start')
|
|
315
|
+
.description('Run the dispatch engine: spawn agents, verify completion, escalate stalls, watch parked PRs, tear down merged worktrees, dispatch report agents (Ctrl-C stops the engine; agents keep running)')
|
|
316
|
+
.option('--interval <seconds>', 'Reconcile tick interval in seconds (default 60)', Number.parseInt)
|
|
317
|
+
.option('--once', 'Run a single reconcile+refill tick and exit (cron-style)')
|
|
318
|
+
.option('--project <slug>', 'Project slug (default: owner-repo of the current directory)')
|
|
319
|
+
.option('--json', 'Output tick results as JSON')
|
|
320
|
+
.action(async (opts) => {
|
|
321
|
+
const { store, project } = resolveStore(opts);
|
|
322
|
+
let config;
|
|
323
|
+
try {
|
|
324
|
+
config = store.loadConfig();
|
|
325
|
+
}
|
|
326
|
+
catch (err) {
|
|
327
|
+
handleKnownError(err);
|
|
328
|
+
}
|
|
329
|
+
// CLI flag beats config.json beats the engine default (60s).
|
|
330
|
+
if (opts.interval !== undefined) {
|
|
331
|
+
if (!Number.isInteger(opts.interval) || opts.interval <= 0) {
|
|
332
|
+
(0, helpers_1.fail)(['--interval must be a positive number of seconds']);
|
|
333
|
+
}
|
|
334
|
+
config = { ...config, reconcile_interval_ms: opts.interval * 1000 };
|
|
335
|
+
}
|
|
336
|
+
// Resolve the agent command: config dispatch.command wins; otherwise
|
|
337
|
+
// auto-detect (claude first, opencode fallback — the run machinery's
|
|
338
|
+
// order, #459) and use the matching headless template.
|
|
339
|
+
const dispatchCommand = config.dispatch?.command ??
|
|
340
|
+
((0, helpers_1.detectLlm)('auto', true) === 'opencode' ? [...sched_1.OPENCODE_DISPATCH_COMMAND] : undefined);
|
|
341
|
+
const engineConfig = dispatchCommand
|
|
342
|
+
? { ...config, dispatch: { ...config.dispatch, command: dispatchCommand } }
|
|
343
|
+
: config;
|
|
344
|
+
const deps = {
|
|
345
|
+
store,
|
|
346
|
+
journal: new sched_1.Journal(store.dir),
|
|
347
|
+
groundTruth: (0, sched_1.createExecGroundTruth)(undefined, { repoDir: process.cwd() }),
|
|
348
|
+
spawnDeps: (0, sched_1.createSpawnDeps)(process.cwd()),
|
|
349
|
+
now: () => new Date(),
|
|
350
|
+
repoDir: process.cwd(),
|
|
351
|
+
teardownExec: (0, sched_1.createExecFn)(sched_1.TEARDOWN_TIMEOUT_MS, {
|
|
352
|
+
onError: (file, args, err) => process.stderr.write(`⚠ sched teardown: '${file} ${args.join(' ')}' failed: ${err.message}\n`),
|
|
353
|
+
}),
|
|
354
|
+
};
|
|
355
|
+
const describe = (result) => {
|
|
356
|
+
const parts = [];
|
|
357
|
+
if (result.spawned.length > 0)
|
|
358
|
+
parts.push(`spawned ${result.spawned.join(', ')}`);
|
|
359
|
+
if (result.parked.length > 0)
|
|
360
|
+
parts.push(`parked ${result.parked.join(', ')}`);
|
|
361
|
+
if (result.mergeAccepted.length > 0)
|
|
362
|
+
parts.push(`merge accepted ${result.mergeAccepted.join(', ')}`);
|
|
363
|
+
if (result.teardownDone.length > 0)
|
|
364
|
+
parts.push(`teardown done ${result.teardownDone.join(', ')}`);
|
|
365
|
+
if (result.teardownFailed.length > 0)
|
|
366
|
+
parts.push(`teardown failed ${result.teardownFailed.join(', ')}`);
|
|
367
|
+
if (result.reportDispatched.length > 0)
|
|
368
|
+
parts.push(`report dispatched ${result.reportDispatched.join(', ')}`);
|
|
369
|
+
if (result.reportWaiting > 0)
|
|
370
|
+
parts.push(`${result.reportWaiting} report(s) waiting for a free slot`);
|
|
371
|
+
if (result.externalAdvances.length > 0)
|
|
372
|
+
parts.push(`externally completed ${result.externalAdvances.join(', ')}`);
|
|
373
|
+
if (result.completed.length > 0)
|
|
374
|
+
parts.push(`completed ${result.completed.join(', ')}`);
|
|
375
|
+
if (result.redispatched.length > 0)
|
|
376
|
+
parts.push(`redispatched ${result.redispatched.join(', ')}`);
|
|
377
|
+
if (result.failed.length > 0)
|
|
378
|
+
parts.push(`failed ${result.failed.join(', ')}`);
|
|
379
|
+
if (result.blocked.length > 0)
|
|
380
|
+
parts.push(`blocked ${result.blocked.map((i) => `#${i}`).join(', ')}`);
|
|
381
|
+
return parts.length > 0 ? parts.join(' · ') : 'nothing to do';
|
|
382
|
+
};
|
|
383
|
+
if (opts.once) {
|
|
384
|
+
let result;
|
|
385
|
+
try {
|
|
386
|
+
result = (0, sched_1.tick)(deps, engineConfig);
|
|
387
|
+
}
|
|
388
|
+
catch (err) {
|
|
389
|
+
// Route known package errors through the CLI exit path; any other
|
|
390
|
+
// failure must not surface as an unhandled async rejection (this is
|
|
391
|
+
// the cron path).
|
|
392
|
+
handleKnownError(err);
|
|
393
|
+
(0, helpers_1.fail)([`sched tick failed: ${err.name}: ${err.message}`]);
|
|
394
|
+
}
|
|
395
|
+
if (opts.json) {
|
|
396
|
+
console.log(JSON.stringify(result, null, 2));
|
|
397
|
+
}
|
|
398
|
+
else {
|
|
399
|
+
console.log(`✓ [${project}] tick: ${describe(result)}`);
|
|
400
|
+
}
|
|
401
|
+
return;
|
|
402
|
+
}
|
|
403
|
+
const interval = (engineConfig.reconcile_interval_ms ?? sched_1.DEFAULT_RECONCILE_INTERVAL_MS) / 1000;
|
|
404
|
+
console.log(`▶ Scheduler engine running for ${project} (tick every ${interval}s, Ctrl-C to stop)`);
|
|
405
|
+
let stopping = false;
|
|
406
|
+
process.on('SIGINT', () => {
|
|
407
|
+
if (stopping)
|
|
408
|
+
process.exit(130);
|
|
409
|
+
stopping = true;
|
|
410
|
+
console.log('\n⏹ Stopping engine (spawned agents keep running)…');
|
|
411
|
+
});
|
|
412
|
+
await (0, sched_1.runLoop)(deps, engineConfig, () => stopping, (result) => {
|
|
413
|
+
if (!opts.json)
|
|
414
|
+
console.log(`✓ [${new Date().toISOString()}] ${describe(result)}`);
|
|
415
|
+
else
|
|
416
|
+
console.log(JSON.stringify({ ts: new Date().toISOString(), ...result }));
|
|
417
|
+
});
|
|
418
|
+
console.log('⏹ Engine stopped');
|
|
419
|
+
});
|
|
420
|
+
}
|
|
421
|
+
function registerSchedCommand(program) {
|
|
422
|
+
const schedCmd = program
|
|
423
|
+
.command('sched')
|
|
424
|
+
.description('Deterministic scheduler core — queue, slots, dispatch, verification, stall ladder (RFC-0001)');
|
|
425
|
+
registerEnqueueSubcommand(schedCmd);
|
|
426
|
+
registerStatusSubcommand(schedCmd);
|
|
427
|
+
registerPauseResumeSubcommand(schedCmd, true);
|
|
428
|
+
registerPauseResumeSubcommand(schedCmd, false);
|
|
429
|
+
registerAbandonSubcommand(schedCmd);
|
|
430
|
+
registerStartSubcommand(schedCmd);
|
|
431
|
+
}
|
|
432
|
+
//# sourceMappingURL=sched.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sched.js","sourceRoot":"","sources":["../../src/commands/sched.ts"],"names":[],"mappings":";AAAA;;;;;;;;;GASG;;;;;AAggBH,oDAaC;AA3gBD,sDAAyB;AAEzB,6CA2B2B;AAE3B,0CAAwC;AACxC,wCAA6C;AAC7C,wDAAyD;AACzD,oCAAuC;AA2BvC,SAAS,SAAS,CAAC,GAAuB;IACxC,IAAI,GAAG,KAAK,SAAS,IAAI,GAAG,KAAK,MAAM;QAAE,OAAO,MAAM,CAAC;IACvD,IAAI,GAAG,KAAK,MAAM;QAAE,OAAO,MAAM,CAAC;IAClC,IAAA,cAAI,EAAC,CAAC,yCAAyC,GAAG,GAAG,CAAC,CAAC,CAAC;AAC1D,CAAC;AAED,SAAS,SAAS,CAAC,GAAuB;IACxC,IAAI,GAAG,KAAK,SAAS,IAAI,GAAG,KAAK,KAAK;QAAE,OAAO,KAAK,CAAC;IACrD,IAAI,GAAG,KAAK,YAAY,IAAI,GAAG,KAAK,QAAQ;QAAE,OAAO,GAAG,CAAC;IACzD,IAAA,cAAI,EAAC,CAAC,kDAAkD,GAAG,GAAG,CAAC,CAAC,CAAC;AACnE,CAAC;AAED,uFAAuF;AACvF,SAAS,SAAS,CAAC,GAAW,EAAE,IAAY;IAC1C,IAAI,CAAC;QACH,OAAO,IAAA,qCAAmB,EAAC,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|
+
* Every command that reads or writes GitHub issue comments through `gh` needs the
|
|
6
|
+
* same things: run a subprocess and keep WHY it failed, turn `gh`'s stderr into a
|
|
7
|
+
* named cause with a fix, parse `--json` output without a throw, and reject
|
|
8
|
+
* values that cannot be safely passed on a command line. These lived privately in
|
|
9
|
+
* `commands/runstate.ts` until the second consumer (`commands/plan.ts`) arrived;
|
|
10
|
+
* they are extracted verbatim rather than reimplemented per command — and anything
|
|
11
|
+
* BOTH command suites do (fetch comments, post a comment, print a dry-run) lives
|
|
12
|
+
* here once, not twice.
|
|
13
|
+
*/
|
|
14
|
+
/**
|
|
15
|
+
* Fail on stderr and exit 1, so a calling dossier can detect it.
|
|
16
|
+
*
|
|
17
|
+
* Each entry is one problem. An entry may span lines: the first gets the ❌, the rest are
|
|
18
|
+
* indented under it, which is how a cause line and its "Fix:" line stay visibly one item.
|
|
19
|
+
*/
|
|
20
|
+
export declare function fail(lines: string[]): never;
|
|
21
|
+
/** Why a subprocess did not produce output — enough to name the actual cause. */
|
|
22
|
+
export interface ExecFailure {
|
|
23
|
+
/** The binary itself is missing from PATH (ENOENT), rather than having exited non-zero. */
|
|
24
|
+
notFound: boolean;
|
|
25
|
+
/** The process was killed after {@link EXEC_TIMEOUT_MS} instead of answering. */
|
|
26
|
+
timedOut: boolean;
|
|
27
|
+
/** Exit status, or null when the process never ran or was killed by a signal. */
|
|
28
|
+
status: number | null;
|
|
29
|
+
/** Whatever the command wrote to stderr, falling back to the thrown message. */
|
|
30
|
+
stderr: string;
|
|
31
|
+
}
|
|
32
|
+
export type ExecResult = {
|
|
33
|
+
ok: true;
|
|
34
|
+
stdout: string;
|
|
35
|
+
} | {
|
|
36
|
+
ok: false;
|
|
37
|
+
error: ExecFailure;
|
|
38
|
+
};
|
|
39
|
+
/**
|
|
40
|
+
* Run a command, keeping WHY it failed.
|
|
41
|
+
*
|
|
42
|
+
* The whole point of the comment-protocol subcommands is that agents were silently
|
|
43
|
+
* getting things wrong, so a discarded stderr is the one thing we cannot afford:
|
|
44
|
+
* "gh is not installed", "gh is not logged in", and "issue 440 does not exist" need
|
|
45
|
+
* three different fixes and are indistinguishable without it. A hard timeout keeps a
|
|
46
|
+
* network-stalled gh from hanging an agent-driven run with nothing to debug.
|
|
47
|
+
*/
|
|
48
|
+
export declare function exec(file: string, args: string[]): ExecResult;
|
|
49
|
+
/**
|
|
50
|
+
* Collapse output to one bounded line so a huge or binary payload stays readable.
|
|
51
|
+
* Control characters (ANSI/OSC escapes included) are stripped — snippets come from
|
|
52
|
+
* network-reachable comment bodies, and a terminal escape re-emitted raw can
|
|
53
|
+
* rewrite the operator's screen or clipboard.
|
|
54
|
+
*/
|
|
55
|
+
export declare function snippet(text: string, max?: number): string;
|
|
56
|
+
/**
|
|
57
|
+
* `JSON.parse` for a `gh --json` payload: `null` instead of a throw, and the caller's
|
|
58
|
+
* declared shape instead of `any`. Every gh call here reads a `--json` payload, so all
|
|
59
|
+
* call sites need the same "gh exited 0 but printed something that is not JSON" branch —
|
|
60
|
+
* they differ only in what they say about it. Fields stay `unknown` because gh's output is
|
|
61
|
+
* remote data — {@link asString} narrows each one at the point of use.
|
|
62
|
+
*/
|
|
63
|
+
export declare function parseGhJson<T>(raw: string): T | null;
|
|
64
|
+
/** A JSON field as a string, or `fallback` when gh omitted it or sent another type. */
|
|
65
|
+
export declare function asString(value: unknown, fallback?: string): string;
|
|
66
|
+
/**
|
|
67
|
+
* Turn a failed `gh` invocation into a message that names the cause and the fix.
|
|
68
|
+
*
|
|
69
|
+
* `action` is what we were trying to do, e.g. "Could not read issue #440".
|
|
70
|
+
*/
|
|
71
|
+
export declare function ghFailure(action: string, err: ExecFailure, repo?: string): string;
|
|
72
|
+
/** GitHub issue numbers are positive integers; anything else is a caller mistake. */
|
|
73
|
+
export declare function isIssueNumber(value: string): boolean;
|
|
74
|
+
/** Reject a non-numeric `--issue` here rather than letting gh (or `mint`) fail obscurely. */
|
|
75
|
+
export declare function requireIssueNumber(issue: string): void;
|
|
76
|
+
/** `--repo owner/name` appended to a gh invocation when the caller supplied one. */
|
|
77
|
+
export declare function repoArgs(repo?: string): string[];
|
|
78
|
+
/** Reject a `--repo` that is not a repository slug before handing it to gh. */
|
|
79
|
+
export declare function requireRepoSlug(repo?: string): void;
|
|
80
|
+
/**
|
|
81
|
+
* The `--issue`/`--repo` checks every issue-targeting subcommand runs before it starts.
|
|
82
|
+
* Kept together so a new subcommand cannot pick up one guard and miss the other.
|
|
83
|
+
*/
|
|
84
|
+
export declare function requireIssueTarget(options: {
|
|
85
|
+
issue: string;
|
|
86
|
+
repo?: string;
|
|
87
|
+
}): void;
|
|
88
|
+
/**
|
|
89
|
+
* Whether a value read back OUT of a comment may be passed to `git`/`gh`.
|
|
90
|
+
*
|
|
91
|
+
* These values are attacker-reachable: anyone who can comment on the issue can post a
|
|
92
|
+
* protocol comment, so values like `branch=`, `head=` and `pr=` arrive from the network
|
|
93
|
+
* rather than from the caller. Every invocation here is `execFileSync` with an argument
|
|
94
|
+
* array and no shell, so there is no command injection — but a value that begins with `-`
|
|
95
|
+
* is still read as a FLAG rather than as data. `gh` (cobra) parses flags interspersed with
|
|
96
|
+
* positionals, so `pr=--repo=someone/else` or `pr=--web` would silently retarget, or add a
|
|
97
|
+
* side effect to, a subcommand documented as strictly read-only.
|
|
98
|
+
*/
|
|
99
|
+
export declare function isSafeArg(value: string): boolean;
|
|
100
|
+
/**
|
|
101
|
+
* Paths are only ever passed in value position (`git -C <path>`) or to `fs.statSync`, so
|
|
102
|
+
* they cannot be mistaken for a flag — but the protocol requires them absolute, and a
|
|
103
|
+
* relative path from a forged comment would resolve against whatever directory the agent
|
|
104
|
+
* happens to be in.
|
|
105
|
+
*/
|
|
106
|
+
export declare function isSafePath(value: string): boolean;
|
|
107
|
+
/** Formats why a local `git` probe could not answer — shared by every git-reading command. */
|
|
108
|
+
export declare function gitFailure(err: ExecFailure): string;
|
|
109
|
+
/** A comment as gh reports it; every field but `body` may be absent. */
|
|
110
|
+
export interface GhComment {
|
|
111
|
+
body?: unknown;
|
|
112
|
+
url?: unknown;
|
|
113
|
+
createdAt?: unknown;
|
|
114
|
+
author?: {
|
|
115
|
+
login?: unknown;
|
|
116
|
+
} | null;
|
|
117
|
+
authorAssociation?: unknown;
|
|
118
|
+
}
|
|
119
|
+
/** A comment-read, or the one reason it could not be read. */
|
|
120
|
+
export type CommentsResult = {
|
|
121
|
+
ok: true;
|
|
122
|
+
comments: GhComment[];
|
|
123
|
+
} | {
|
|
124
|
+
ok: false;
|
|
125
|
+
error: string;
|
|
126
|
+
};
|
|
127
|
+
/**
|
|
128
|
+
* Read an issue's comments through gh, reporting WHY rather than exiting.
|
|
129
|
+
*
|
|
130
|
+
* The single-issue subcommands turn a failure here into an immediate exit; `stats
|
|
131
|
+
* --issues` cannot, because one unreadable issue in a set must not discard the rest. So
|
|
132
|
+
* the decision of what a failure means belongs to the caller, and this function only
|
|
133
|
+
* reports it.
|
|
134
|
+
*/
|
|
135
|
+
export declare function tryFetchComments(issue: string, repo?: string): CommentsResult;
|
|
136
|
+
/** `--dry-run` support for comment-posting subcommands: show the body, post nothing. */
|
|
137
|
+
export declare function printDryRun(body: string, json?: boolean, extra?: Record<string, unknown>): void;
|
|
138
|
+
/**
|
|
139
|
+
* Comment `body` onto an issue, with the shared failure taxonomy, the paste-safe retry
|
|
140
|
+
* hint, and the success output both protocols use.
|
|
141
|
+
*
|
|
142
|
+
* `jsonExtras` merge into the `--json` result (e.g. `head` for plans); `successLine`
|
|
143
|
+
* renders the human-mode success line for the caller's protocol.
|
|
144
|
+
*/
|
|
145
|
+
export declare function postIssueComment(options: {
|
|
146
|
+
issue: string;
|
|
147
|
+
repo?: string;
|
|
148
|
+
body: string;
|
|
149
|
+
noun: string;
|
|
150
|
+
action: string;
|
|
151
|
+
json?: boolean;
|
|
152
|
+
jsonExtras?: Record<string, unknown>;
|
|
153
|
+
successLine: (url: string) => string;
|
|
154
|
+
}): void;
|
|
155
|
+
//# sourceMappingURL=gh.d.ts.map
|
package/dist/gh.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