@rasensio/aidlc 2.12.0 → 2.14.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/dist/autopilot/answers.d.ts +85 -0
- package/dist/autopilot/answers.d.ts.map +1 -0
- package/dist/autopilot/answers.js +249 -0
- package/dist/autopilot/answers.js.map +1 -0
- package/dist/autopilot/decisions.d.ts +4 -2
- package/dist/autopilot/decisions.d.ts.map +1 -1
- package/dist/autopilot/decisions.js +5 -3
- package/dist/autopilot/decisions.js.map +1 -1
- package/dist/autopilot/driver.d.ts +12 -1
- package/dist/autopilot/driver.d.ts.map +1 -1
- package/dist/autopilot/driver.js +24 -16
- package/dist/autopilot/driver.js.map +1 -1
- package/dist/autopilot/open-decisions.d.ts +17 -0
- package/dist/autopilot/open-decisions.d.ts.map +1 -1
- package/dist/autopilot/open-decisions.js +45 -1
- package/dist/autopilot/open-decisions.js.map +1 -1
- package/dist/autopilot/pending.d.ts +122 -0
- package/dist/autopilot/pending.d.ts.map +1 -0
- package/dist/autopilot/pending.js +534 -0
- package/dist/autopilot/pending.js.map +1 -0
- package/dist/autopilot/state.d.ts +9 -0
- package/dist/autopilot/state.d.ts.map +1 -1
- package/dist/autopilot/state.js.map +1 -1
- package/dist/autopilot/wait.d.ts +36 -0
- package/dist/autopilot/wait.d.ts.map +1 -0
- package/dist/autopilot/wait.js +39 -0
- package/dist/autopilot/wait.js.map +1 -0
- package/dist/commands/autopilot.d.ts +11 -0
- package/dist/commands/autopilot.d.ts.map +1 -1
- package/dist/commands/autopilot.js +180 -14
- package/dist/commands/autopilot.js.map +1 -1
- package/dist/commands/roadmap.d.ts +9 -0
- package/dist/commands/roadmap.d.ts.map +1 -1
- package/dist/commands/roadmap.js +42 -0
- package/dist/commands/roadmap.js.map +1 -1
- package/dist/doctor/migrations/index.d.ts.map +1 -1
- package/dist/doctor/migrations/index.js +3 -0
- package/dist/doctor/migrations/index.js.map +1 -1
- package/dist/doctor/migrations/roadmap-merged-items.d.ts +19 -0
- package/dist/doctor/migrations/roadmap-merged-items.d.ts.map +1 -0
- package/dist/doctor/migrations/roadmap-merged-items.js +79 -0
- package/dist/doctor/migrations/roadmap-merged-items.js.map +1 -0
- package/dist/events/event-bus.d.ts.map +1 -1
- package/dist/events/event-bus.js +42 -0
- package/dist/events/event-bus.js.map +1 -1
- package/dist/roadmap/merged.d.ts +86 -0
- package/dist/roadmap/merged.d.ts.map +1 -0
- package/dist/roadmap/merged.js +170 -0
- package/dist/roadmap/merged.js.map +1 -0
- package/dist/roadmap/triage.d.ts +46 -0
- package/dist/roadmap/triage.d.ts.map +1 -0
- package/dist/roadmap/triage.js +134 -0
- package/dist/roadmap/triage.js.map +1 -0
- package/package.json +2 -2
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What an autopilot run waits on a person for, as one list (autopilot-watcher-asks-person).
|
|
3
|
+
*
|
|
4
|
+
* The run's unattended agents can ask nobody, so every decision only a person can make ends
|
|
5
|
+
* up in a file: a paused item and its question files, the decision log, `hold/`, `inbox/`, a
|
|
6
|
+
* retro marker, a halted queue. `aidlc autopilot pending` reads them all and lists each as an
|
|
7
|
+
* entry with options, and the session that started the run asks the person about each one,
|
|
8
|
+
* then applies the answer with `aidlc autopilot answer` (`answers.ts`).
|
|
9
|
+
*
|
|
10
|
+
* Read-only, and pure over its inputs. Every string from a file was written by an agent, so it
|
|
11
|
+
* goes through `oneLine` before it is listed (AC-13).
|
|
12
|
+
*
|
|
13
|
+
* Design: design.md C1
|
|
14
|
+
*
|
|
15
|
+
* @module
|
|
16
|
+
*/
|
|
17
|
+
import { type RunMode } from '../roadmap/next.js';
|
|
18
|
+
import { type TriageTarget } from '../roadmap/triage.js';
|
|
19
|
+
import type { AutopilotState, RunRecord } from './state.js';
|
|
20
|
+
export declare const PENDING_KINDS: readonly ["phase-question", "awaiting-review", "open-question", "interpretation", "parked", "triage", "retro-pending", "release-failed"];
|
|
21
|
+
export type PendingKind = (typeof PENDING_KINDS)[number];
|
|
22
|
+
export type PendingAction = {
|
|
23
|
+
do: 'record';
|
|
24
|
+
}
|
|
25
|
+
/** Run nothing: print `steps` for the person, from `cwd` (AC-20). */
|
|
26
|
+
| {
|
|
27
|
+
do: 'handoff';
|
|
28
|
+
cwd: string;
|
|
29
|
+
steps: string[];
|
|
30
|
+
} | {
|
|
31
|
+
do: 'write-answer';
|
|
32
|
+
file: string;
|
|
33
|
+
question: string;
|
|
34
|
+
text: string;
|
|
35
|
+
} | {
|
|
36
|
+
do: 'triage';
|
|
37
|
+
item: string;
|
|
38
|
+
to: TriageTarget;
|
|
39
|
+
rank?: number;
|
|
40
|
+
run?: RunMode;
|
|
41
|
+
} | {
|
|
42
|
+
do: 'retry';
|
|
43
|
+
instance: string;
|
|
44
|
+
}
|
|
45
|
+
/** Approve the phase the item paused after, as `aidlc autopilot approve` does (Q1: B). */
|
|
46
|
+
| {
|
|
47
|
+
do: 'approve';
|
|
48
|
+
instance: string;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Write `verdict` on each of `entries` in the log at `file`, as `aidlc autopilot review` does;
|
|
52
|
+
* an entry is named by number and title, so a log rewritten since the list refuses (Q1: B).
|
|
53
|
+
* `next` is printed after, for the person: what the verdict leaves them to do.
|
|
54
|
+
*/
|
|
55
|
+
| {
|
|
56
|
+
do: 'verdict';
|
|
57
|
+
file: string;
|
|
58
|
+
entries: {
|
|
59
|
+
n: number;
|
|
60
|
+
title: string;
|
|
61
|
+
}[];
|
|
62
|
+
verdict: 'kept' | 'rejected';
|
|
63
|
+
next: string[];
|
|
64
|
+
};
|
|
65
|
+
export interface PendingOption {
|
|
66
|
+
id: string;
|
|
67
|
+
label: string;
|
|
68
|
+
/** What choosing it does, in one line. */
|
|
69
|
+
consequence: string;
|
|
70
|
+
recommended: boolean;
|
|
71
|
+
/** For an open question: the option the agent already built. */
|
|
72
|
+
current: boolean;
|
|
73
|
+
/** Only a person may apply it, in their own terminal; `answer` hands it to them. */
|
|
74
|
+
person: boolean;
|
|
75
|
+
/** What the watching session runs: `aidlc autopilot answer <fingerprint> <id>`. */
|
|
76
|
+
command: string;
|
|
77
|
+
/** The command it comes down to, for the message; null when it is `answer`'s own write or a record. */
|
|
78
|
+
applies: string | null;
|
|
79
|
+
action: PendingAction;
|
|
80
|
+
}
|
|
81
|
+
export interface PendingEntry {
|
|
82
|
+
fingerprint: string;
|
|
83
|
+
kind: PendingKind;
|
|
84
|
+
instance: string | null;
|
|
85
|
+
/** The roadmap item's file name, for a roadmap entry. */
|
|
86
|
+
item: string | null;
|
|
87
|
+
/** Blocks the run (holds it open or leaves it nothing to build), or only waits. */
|
|
88
|
+
blocks: boolean;
|
|
89
|
+
/** When it started waiting, ISO date or time; null when unknown. */
|
|
90
|
+
since: string | null;
|
|
91
|
+
question: string;
|
|
92
|
+
/** At most two lines. */
|
|
93
|
+
summary: string[];
|
|
94
|
+
artifact: string | null;
|
|
95
|
+
options: PendingOption[];
|
|
96
|
+
}
|
|
97
|
+
export interface PendingInput {
|
|
98
|
+
/** The primary checkout's project root. */
|
|
99
|
+
repo: string;
|
|
100
|
+
state: AutopilotState;
|
|
101
|
+
run: RunRecord | null;
|
|
102
|
+
/** The file's text, or null when absent or unreadable (AC-14). */
|
|
103
|
+
read: (path: string) => string | null;
|
|
104
|
+
/** The names in a directory; [] when absent or unreadable (AC-14). */
|
|
105
|
+
listDir: (dir: string) => string[];
|
|
106
|
+
/** A parked instance's worktree, from the registry; null when unknown. */
|
|
107
|
+
worktreeOf: (instance: string) => string | null;
|
|
108
|
+
/** The retro-pending marker directory. */
|
|
109
|
+
retroDir: string;
|
|
110
|
+
}
|
|
111
|
+
/** The first 12 hex digits of the sha256 of `parts`: stable across sessions, new when a part changes (design D4). */
|
|
112
|
+
export declare function fingerprint(parts: readonly string[]): string;
|
|
113
|
+
export declare const FINGERPRINT_RE: RegExp;
|
|
114
|
+
/** The command that applies an option; the one place it is spelled. */
|
|
115
|
+
export declare const answerCommand: (fp: string, id: string) => string;
|
|
116
|
+
/** Every entry, less those `answered` names, in asking order (AC-1..AC-14). */
|
|
117
|
+
export declare function collectPending(input: PendingInput, answered: ReadonlySet<string>): PendingEntry[];
|
|
118
|
+
/** `pending --json`: the run, and every entry without its internal action (AC-1, AC-2). */
|
|
119
|
+
export declare function pendingJson(run: RunRecord | null, entries: readonly PendingEntry[]): string;
|
|
120
|
+
/** `pending` without `--json` (AC-15). */
|
|
121
|
+
export declare function pendingText(entries: readonly PendingEntry[]): string[];
|
|
122
|
+
//# sourceMappingURL=pending.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pending.d.ts","sourceRoot":"","sources":["../../src/autopilot/pending.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAQH,OAAO,EAA2B,KAAK,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAE3E,OAAO,EAAc,KAAK,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAGrE,OAAO,KAAK,EAAiB,cAAc,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAE3E,eAAO,MAAM,aAAa,0IAShB,CAAC;AACX,MAAM,MAAM,WAAW,GAAG,CAAC,OAAO,aAAa,CAAC,CAAC,MAAM,CAAC,CAAC;AAEzD,MAAM,MAAM,aAAa,GACrB;IAAE,EAAE,EAAE,QAAQ,CAAA;CAAE;AAClB,qEAAqE;GACnE;IAAE,EAAE,EAAE,SAAS,CAAC;IAAC,GAAG,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,EAAE,CAAA;CAAE,GAC/C;IAAE,EAAE,EAAE,cAAc,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GACpE;IAAE,EAAE,EAAE,QAAQ,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,EAAE,EAAE,YAAY,CAAC;IAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IAAC,GAAG,CAAC,EAAE,OAAO,CAAA;CAAE,GAC9E;IAAE,EAAE,EAAE,OAAO,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE;AACnC,0FAA0F;GACxF;IAAE,EAAE,EAAE,SAAS,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE;AACrC;;;;GAIG;GACD;IAAE,EAAE,EAAE,SAAS,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE;QAAE,CAAC,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;IAAC,OAAO,EAAE,MAAM,GAAG,UAAU,CAAC;IAAC,IAAI,EAAE,MAAM,EAAE,CAAA;CAAE,CAAC;AAE3H,MAAM,WAAW,aAAa;IAC5B,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,0CAA0C;IAC1C,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,OAAO,CAAC;IACrB,gEAAgE;IAChE,OAAO,EAAE,OAAO,CAAC;IACjB,oFAAoF;IACpF,MAAM,EAAE,OAAO,CAAC;IAChB,mFAAmF;IACnF,OAAO,EAAE,MAAM,CAAC;IAChB,uGAAuG;IACvG,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,MAAM,EAAE,aAAa,CAAC;CACvB;AAED,MAAM,WAAW,YAAY;IAC3B,WAAW,EAAE,MAAM,CAAC;IACpB,IAAI,EAAE,WAAW,CAAC;IAClB,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,yDAAyD;IACzD,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IACpB,mFAAmF;IACnF,MAAM,EAAE,OAAO,CAAC;IAChB,oEAAoE;IACpE,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,QAAQ,EAAE,MAAM,CAAC;IACjB,yBAAyB;IACzB,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,OAAO,EAAE,aAAa,EAAE,CAAC;CAC1B;AAED,MAAM,WAAW,YAAY;IAC3B,2CAA2C;IAC3C,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,cAAc,CAAC;IACtB,GAAG,EAAE,SAAS,GAAG,IAAI,CAAC;IACtB,kEAAkE;IAClE,IAAI,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,MAAM,GAAG,IAAI,CAAC;IACtC,sEAAsE;IACtE,OAAO,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,MAAM,EAAE,CAAC;IACnC,0EAA0E;IAC1E,UAAU,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,MAAM,GAAG,IAAI,CAAC;IAChD,0CAA0C;IAC1C,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,qHAAqH;AACrH,wBAAgB,WAAW,CAAC,KAAK,EAAE,SAAS,MAAM,EAAE,GAAG,MAAM,CAE5D;AAED,eAAO,MAAM,cAAc,QAAmB,CAAC;AAE/C,uEAAuE;AACvE,eAAO,MAAM,aAAa,GAAI,IAAI,MAAM,EAAE,IAAI,MAAM,KAAG,MAA8C,CAAC;AAigBtG,+EAA+E;AAC/E,wBAAgB,cAAc,CAAC,KAAK,EAAE,YAAY,EAAE,QAAQ,EAAE,WAAW,CAAC,MAAM,CAAC,GAAG,YAAY,EAAE,CAyBjG;AAED,2FAA2F;AAC3F,wBAAgB,WAAW,CAAC,GAAG,EAAE,SAAS,GAAG,IAAI,EAAE,OAAO,EAAE,SAAS,YAAY,EAAE,GAAG,MAAM,CAS3F;AAED,0CAA0C;AAC1C,wBAAgB,WAAW,CAAC,OAAO,EAAE,SAAS,YAAY,EAAE,GAAG,MAAM,EAAE,CAatE"}
|
|
@@ -0,0 +1,534 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What an autopilot run waits on a person for, as one list (autopilot-watcher-asks-person).
|
|
3
|
+
*
|
|
4
|
+
* The run's unattended agents can ask nobody, so every decision only a person can make ends
|
|
5
|
+
* up in a file: a paused item and its question files, the decision log, `hold/`, `inbox/`, a
|
|
6
|
+
* retro marker, a halted queue. `aidlc autopilot pending` reads them all and lists each as an
|
|
7
|
+
* entry with options, and the session that started the run asks the person about each one,
|
|
8
|
+
* then applies the answer with `aidlc autopilot answer` (`answers.ts`).
|
|
9
|
+
*
|
|
10
|
+
* Read-only, and pure over its inputs. Every string from a file was written by an agent, so it
|
|
11
|
+
* goes through `oneLine` before it is listed (AC-13).
|
|
12
|
+
*
|
|
13
|
+
* Design: design.md C1
|
|
14
|
+
*
|
|
15
|
+
* @module
|
|
16
|
+
*/
|
|
17
|
+
import { createHash } from 'node:crypto';
|
|
18
|
+
import { join } from 'node:path';
|
|
19
|
+
import { parse as parseYaml } from 'yaml';
|
|
20
|
+
import { readItemFields } from '../roadmap/item-fields.js';
|
|
21
|
+
import { parsePriority, pickNext } from '../roadmap/next.js';
|
|
22
|
+
import { frontmatter, itemBody, listStatusAt, primaryCheckout, roadmapRoot } from '../roadmap/paths.js';
|
|
23
|
+
import { lastReason } from '../roadmap/triage.js';
|
|
24
|
+
import { parseLog } from './decisions.js';
|
|
25
|
+
import { QUESTION_PHASES, oneLine, openDecisions, parseDefaultedAnswers } from './open-decisions.js';
|
|
26
|
+
export const PENDING_KINDS = [
|
|
27
|
+
'phase-question',
|
|
28
|
+
'awaiting-review',
|
|
29
|
+
'open-question',
|
|
30
|
+
'interpretation',
|
|
31
|
+
'parked',
|
|
32
|
+
'triage',
|
|
33
|
+
'retro-pending',
|
|
34
|
+
'release-failed',
|
|
35
|
+
];
|
|
36
|
+
/** The first 12 hex digits of the sha256 of `parts`: stable across sessions, new when a part changes (design D4). */
|
|
37
|
+
export function fingerprint(parts) {
|
|
38
|
+
return createHash('sha256').update(parts.join('\u0000')).digest('hex').slice(0, 12);
|
|
39
|
+
}
|
|
40
|
+
export const FINGERPRINT_RE = /^[0-9a-f]{12}$/;
|
|
41
|
+
/** The command that applies an option; the one place it is spelled. */
|
|
42
|
+
export const answerCommand = (fp, id) => `aidlc autopilot answer ${fp} ${id}`;
|
|
43
|
+
/** The artifact each pause point's phase ends with, when its phase file does not say. */
|
|
44
|
+
const PHASE_ARTIFACT = {
|
|
45
|
+
requirements: 'requirements.md',
|
|
46
|
+
design: 'design.md',
|
|
47
|
+
implementation: 'code-complete.md',
|
|
48
|
+
testing: 'test-results.md',
|
|
49
|
+
};
|
|
50
|
+
const later = (what) => ({
|
|
51
|
+
id: 'later',
|
|
52
|
+
label: 'Leave it for now',
|
|
53
|
+
consequence: `nothing changes; ${what}, and you are not asked about it again`,
|
|
54
|
+
recommended: false,
|
|
55
|
+
current: false,
|
|
56
|
+
person: false,
|
|
57
|
+
applies: null,
|
|
58
|
+
action: { do: 'record' },
|
|
59
|
+
});
|
|
60
|
+
const handoff = (id, label, consequence, cwd, steps, extra = {}) => ({
|
|
61
|
+
id,
|
|
62
|
+
label,
|
|
63
|
+
consequence,
|
|
64
|
+
recommended: extra.recommended ?? false,
|
|
65
|
+
current: extra.current ?? false,
|
|
66
|
+
person: true,
|
|
67
|
+
applies: `cd ${cwd} && ${steps.join(' && ')}`,
|
|
68
|
+
action: { do: 'handoff', cwd, steps },
|
|
69
|
+
});
|
|
70
|
+
/** The instance's state directory: its worktree's while that holds the instance, else the primary checkout's. */
|
|
71
|
+
function stateDirOf(input, item) {
|
|
72
|
+
const inWorktree = join(item.worktree, '.aidlc', 'state', item.name);
|
|
73
|
+
return input.read(join(inWorktree, 'instance.yaml')) !== null ? inWorktree : join(input.repo, '.aidlc', 'state', item.name);
|
|
74
|
+
}
|
|
75
|
+
/** The checkout `aidlc autopilot review` reads the log in: the one whose state directory is used. */
|
|
76
|
+
const checkoutOf = (input, item) => stateDirOf(input, item).startsWith(join(item.worktree, '.aidlc')) ? item.worktree : input.repo;
|
|
77
|
+
function phaseArtifact(input, stateDir, phase) {
|
|
78
|
+
const raw = input.read(join(stateDir, `phase-${phase}.yaml`));
|
|
79
|
+
try {
|
|
80
|
+
const doc = raw === null ? null : parseYaml(raw);
|
|
81
|
+
const name = doc?.artifacts?.[0]?.name;
|
|
82
|
+
// A name, never a path: the file is agent-written.
|
|
83
|
+
if (typeof name === 'string' && /^[A-Za-z0-9._-]+$/.test(name))
|
|
84
|
+
return join(stateDir, name);
|
|
85
|
+
}
|
|
86
|
+
catch {
|
|
87
|
+
// unreadable YAML: the default name below
|
|
88
|
+
}
|
|
89
|
+
return join(stateDir, PHASE_ARTIFACT[phase] ?? `${phase}.md`);
|
|
90
|
+
}
|
|
91
|
+
/** The value of an entry's `**Field:**` line, cleaned; null when absent. */
|
|
92
|
+
function logField(entry, name) {
|
|
93
|
+
const label = `**${name}:**`;
|
|
94
|
+
const line = entry.lines.find((l) => l.startsWith(label));
|
|
95
|
+
return line === undefined ? null : oneLine(line.slice(label.length)) || null;
|
|
96
|
+
}
|
|
97
|
+
const since = (item) => item.step_since?.at ?? item.started_at ?? null;
|
|
98
|
+
function decisionOptions(d, file) {
|
|
99
|
+
const order = d.options.map((_, i) => i);
|
|
100
|
+
if (d.recommended !== null)
|
|
101
|
+
order.sort((a, b) => (a === d.recommended ? -1 : b === d.recommended ? 1 : 0));
|
|
102
|
+
const seen = new Set(['later', 'other']);
|
|
103
|
+
return order.map((i, k) => {
|
|
104
|
+
const o = d.options[i];
|
|
105
|
+
let id = o.marker !== null && /^[a-z0-9]{1,4}$/i.test(o.marker) ? o.marker.toLowerCase() : `o${k + 1}`;
|
|
106
|
+
if (seen.has(id))
|
|
107
|
+
id = `o${k + 1}`;
|
|
108
|
+
seen.add(id);
|
|
109
|
+
return {
|
|
110
|
+
id,
|
|
111
|
+
label: o.text,
|
|
112
|
+
consequence: `written as the answer in ${file}; the agent reads it when it carries on`,
|
|
113
|
+
recommended: i === d.recommended,
|
|
114
|
+
current: false,
|
|
115
|
+
person: false,
|
|
116
|
+
applies: null,
|
|
117
|
+
action: { do: 'write-answer', file, question: d.question, text: o.text },
|
|
118
|
+
};
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
/** An option `answer` applies itself, in-process (Q1: B); `applies` names the command it stands for. */
|
|
122
|
+
const inProcess = (id, label, consequence, applies, action, extra = {}) => ({
|
|
123
|
+
id,
|
|
124
|
+
label,
|
|
125
|
+
consequence,
|
|
126
|
+
recommended: extra.recommended ?? false,
|
|
127
|
+
current: extra.current ?? false,
|
|
128
|
+
person: false,
|
|
129
|
+
applies,
|
|
130
|
+
action,
|
|
131
|
+
});
|
|
132
|
+
/** A paused item's open questions, then its approval (AC-4). */
|
|
133
|
+
function awaitingReview(input, item) {
|
|
134
|
+
const stateDir = stateDirOf(input, item);
|
|
135
|
+
const phase = item.review ?? 'a phase';
|
|
136
|
+
const open = openDecisions(input.read, stateDir);
|
|
137
|
+
const drafts = open.map((d) => {
|
|
138
|
+
const file = join(stateDir, d.file);
|
|
139
|
+
return {
|
|
140
|
+
key: ['phase-question', item.name, d.file, d.question],
|
|
141
|
+
kind: 'phase-question',
|
|
142
|
+
instance: item.name,
|
|
143
|
+
item: item.file,
|
|
144
|
+
blocks: true,
|
|
145
|
+
since: since(item),
|
|
146
|
+
question: d.question,
|
|
147
|
+
summary: [d.why ?? `${item.name} paused after ${phase} with this question open`, `answer in: ${file}`],
|
|
148
|
+
artifact: file,
|
|
149
|
+
options: [...decisionOptions(d, file), later('the question stays open in the file')],
|
|
150
|
+
};
|
|
151
|
+
});
|
|
152
|
+
const artifact = item.review === undefined ? null : phaseArtifact(input, stateDir, item.review);
|
|
153
|
+
const first = open.length === 0 ? '' : `answer its ${open.length} open question${open.length === 1 ? '' : 's'} first; `;
|
|
154
|
+
drafts.push({
|
|
155
|
+
key: ['awaiting-review', item.name, phase, item.step_since?.at ?? ''],
|
|
156
|
+
kind: 'awaiting-review',
|
|
157
|
+
instance: item.name,
|
|
158
|
+
item: item.file,
|
|
159
|
+
blocks: true,
|
|
160
|
+
since: since(item),
|
|
161
|
+
question: oneLine(`Approve ${item.name} after ${phase}?`),
|
|
162
|
+
summary: [oneLine(`paused after ${phase} in ${item.worktree}`), artifact === null ? 'no artifact named' : oneLine(`read: ${artifact}`)],
|
|
163
|
+
artifact,
|
|
164
|
+
options: [
|
|
165
|
+
inProcess('approve', 'Approve it', `${first}${item.name} is approved after ${phase} in your name, and the next pass carries it on`, `aidlc autopilot approve ${item.name}`, { do: 'approve', instance: item.name }, { recommended: true }),
|
|
166
|
+
later('the item keeps waiting for your review'),
|
|
167
|
+
],
|
|
168
|
+
});
|
|
169
|
+
return drafts;
|
|
170
|
+
}
|
|
171
|
+
/** Unreviewed open questions and interpretations in the item's log, and defaulted answers (AC-5, AC-6, AC-7). */
|
|
172
|
+
function logged(input, item) {
|
|
173
|
+
const stateDir = stateDirOf(input, item);
|
|
174
|
+
const cwd = checkoutOf(input, item);
|
|
175
|
+
const review = `aidlc autopilot review ${item.name}`;
|
|
176
|
+
const log = join(stateDir, 'unattended-stops.md');
|
|
177
|
+
const amend = `cd ${cwd} && aidlc amend ${item.name} --impact`;
|
|
178
|
+
const entries = parseLog(input.read(log) ?? '');
|
|
179
|
+
const drafts = [];
|
|
180
|
+
for (const e of entries.filter((x) => x.type === 'open-question' && x.verdict === null)) {
|
|
181
|
+
const title = oneLine(e.title);
|
|
182
|
+
drafts.push({
|
|
183
|
+
key: ['open-question', item.name, String(e.n), e.title],
|
|
184
|
+
kind: 'open-question',
|
|
185
|
+
instance: item.name,
|
|
186
|
+
item: item.file,
|
|
187
|
+
blocks: false,
|
|
188
|
+
since: item.started_at ?? null,
|
|
189
|
+
question: oneLine(`${item.name}: ${title} — keep what was built?`),
|
|
190
|
+
summary: [logField(e, 'Decided') ?? `entry ${e.n} of the item's decision log`, logField(e, 'Why') ?? log],
|
|
191
|
+
artifact: log,
|
|
192
|
+
options: [
|
|
193
|
+
inProcess('keep', 'Keep what was built', `entry ${e.n} is kept in your name in its decision log; then its pull request can merge`, `cd ${cwd} && ${review}`, { do: 'verdict', file: log, entries: [{ n: e.n, title: e.title }], verdict: 'kept', next: [] }, { recommended: true, current: true }),
|
|
194
|
+
inProcess('switch', 'Switch to another option', `entry ${e.n} is rejected in your name; then reopen the phase with amend, and its agent rebuilds it with your answer`, `cd ${cwd} && ${review}`, { do: 'verdict', file: log, entries: [{ n: e.n, title: e.title }], verdict: 'rejected', next: [amend] }),
|
|
195
|
+
later('the pull request keeps waiting for a person'),
|
|
196
|
+
],
|
|
197
|
+
});
|
|
198
|
+
}
|
|
199
|
+
for (const phase of QUESTION_PHASES) {
|
|
200
|
+
const file = `${phase}-questions.md`;
|
|
201
|
+
const text = input.read(join(stateDir, file));
|
|
202
|
+
if (text === null)
|
|
203
|
+
continue;
|
|
204
|
+
for (const d of parseDefaultedAnswers(file, text)) {
|
|
205
|
+
drafts.push({
|
|
206
|
+
key: ['open-question', item.name, file, d.question],
|
|
207
|
+
kind: 'open-question',
|
|
208
|
+
instance: item.name,
|
|
209
|
+
item: item.file,
|
|
210
|
+
blocks: false,
|
|
211
|
+
since: item.started_at ?? null,
|
|
212
|
+
question: oneLine(`${item.name}: ${d.question}`),
|
|
213
|
+
summary: [oneLine(`the agent answered for you: ${d.answer}`), oneLine(`in: ${join(stateDir, file)}`)],
|
|
214
|
+
artifact: join(stateDir, file),
|
|
215
|
+
options: [
|
|
216
|
+
{
|
|
217
|
+
id: 'keep',
|
|
218
|
+
label: 'Keep what was built',
|
|
219
|
+
consequence: 'the answer the agent took stands; nothing changes',
|
|
220
|
+
recommended: true,
|
|
221
|
+
current: true,
|
|
222
|
+
person: false,
|
|
223
|
+
applies: null,
|
|
224
|
+
action: { do: 'record' },
|
|
225
|
+
},
|
|
226
|
+
handoff('switch', 'Switch to another option', `you reopen the ${phase} phase with amend; its agent rebuilds it with your answer`, cwd, [
|
|
227
|
+
`aidlc amend ${item.name} --impact`,
|
|
228
|
+
]),
|
|
229
|
+
later('the answer the agent took stands for now'),
|
|
230
|
+
],
|
|
231
|
+
});
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
const calls = entries.filter((x) => x.type === 'interpretation' && x.verdict === null);
|
|
235
|
+
if (calls.length > 0) {
|
|
236
|
+
const n = calls.length;
|
|
237
|
+
drafts.push({
|
|
238
|
+
key: ['interpretation', item.name, calls.map((c) => String(c.n)).join(',')],
|
|
239
|
+
kind: 'interpretation',
|
|
240
|
+
instance: item.name,
|
|
241
|
+
item: item.file,
|
|
242
|
+
blocks: false,
|
|
243
|
+
since: item.started_at ?? null,
|
|
244
|
+
question: oneLine(`${item.name}: keep the ${n} call${n === 1 ? '' : 's'} its agent made?`),
|
|
245
|
+
summary: [oneLine(calls.map((c) => `${c.n}. ${c.title}`).join('; ')), oneLine(`in: ${log}`)],
|
|
246
|
+
artifact: log,
|
|
247
|
+
options: [
|
|
248
|
+
inProcess('keep', n === 1 ? 'Keep it' : `Keep all ${n}`, `${n === 1 ? 'the call is' : `the ${n} calls are`} kept in your name in its decision log; nothing is promoted`, `cd ${cwd} && ${review}`, { do: 'verdict', file: log, entries: calls.map((c) => ({ n: c.n, title: c.title })), verdict: 'kept', next: [] }, { recommended: true }),
|
|
249
|
+
// Rejecting or promoting one call is a choice per call, which one answer cannot carry.
|
|
250
|
+
handoff('review', 'Review each one', 'you keep, reject or promote each one in review, in your own terminal', cwd, [review]),
|
|
251
|
+
later('they block nothing'),
|
|
252
|
+
],
|
|
253
|
+
});
|
|
254
|
+
}
|
|
255
|
+
return drafts;
|
|
256
|
+
}
|
|
257
|
+
/** An item the merge queue halted on, or that stopped (AC-11). */
|
|
258
|
+
function failed(input, item) {
|
|
259
|
+
const canRetry = item.resume_step !== undefined;
|
|
260
|
+
const options = [];
|
|
261
|
+
if (canRetry) {
|
|
262
|
+
options.push({
|
|
263
|
+
id: 'retry',
|
|
264
|
+
label: 'Retry it',
|
|
265
|
+
consequence: `${item.name} goes back to ${item.resume_step}, as a new run would put it, and the next pass tries again`,
|
|
266
|
+
recommended: true,
|
|
267
|
+
current: false,
|
|
268
|
+
person: false,
|
|
269
|
+
applies: null,
|
|
270
|
+
action: { do: 'retry', instance: item.name },
|
|
271
|
+
});
|
|
272
|
+
}
|
|
273
|
+
options.push(handoff('by-hand', 'Finish it by hand', 'you finish the failed step yourself, then tell autopilot to stop tracking it', input.repo, ['aidlc autopilot status', `aidlc autopilot forget ${item.name}`], { recommended: !canRetry }), later('the queue stays halted on it'));
|
|
274
|
+
return {
|
|
275
|
+
key: ['release-failed', item.name, item.error ?? ''],
|
|
276
|
+
kind: 'release-failed',
|
|
277
|
+
instance: item.name,
|
|
278
|
+
item: item.file,
|
|
279
|
+
blocks: true,
|
|
280
|
+
since: since(item),
|
|
281
|
+
question: oneLine(`${item.name} stopped — what now?`),
|
|
282
|
+
summary: [oneLine(item.error ?? 'no error recorded'), item.pr === null ? 'no pull request' : `pull request #${item.pr}`],
|
|
283
|
+
artifact: null,
|
|
284
|
+
options,
|
|
285
|
+
};
|
|
286
|
+
}
|
|
287
|
+
const PARKED = 'parked — ';
|
|
288
|
+
function lastAt(item) {
|
|
289
|
+
const history = frontmatter(item.raw)?.data.history;
|
|
290
|
+
if (!Array.isArray(history) || history.length === 0)
|
|
291
|
+
return null;
|
|
292
|
+
const at = history[history.length - 1]?.at;
|
|
293
|
+
if (at instanceof Date)
|
|
294
|
+
return at.toISOString().slice(0, 10);
|
|
295
|
+
return typeof at === 'string' ? at : null;
|
|
296
|
+
}
|
|
297
|
+
/** Items this run parked or could not start; never a declined one or one with no reason (AC-8). */
|
|
298
|
+
function parked(input) {
|
|
299
|
+
const run = input.run;
|
|
300
|
+
if (run === null)
|
|
301
|
+
return [];
|
|
302
|
+
const day = run.started_at.slice(0, 10);
|
|
303
|
+
return listStatusAt(roadmapRoot(input.repo), 'hold').flatMap((item) => {
|
|
304
|
+
const reason = lastReason(item);
|
|
305
|
+
if (reason === null || !reason.startsWith(PARKED))
|
|
306
|
+
return [];
|
|
307
|
+
const at = lastAt(item);
|
|
308
|
+
const ours = item.promotedTo !== null && run.started.includes(item.promotedTo);
|
|
309
|
+
const unstartable = reason.startsWith(`${PARKED}could not start:`) && at !== null && at >= day;
|
|
310
|
+
if (!ours && !unstartable)
|
|
311
|
+
return [];
|
|
312
|
+
const name = item.promotedTo;
|
|
313
|
+
const worktree = name === null ? null : input.worktreeOf(name);
|
|
314
|
+
const options = [
|
|
315
|
+
{
|
|
316
|
+
id: 'keep-parked',
|
|
317
|
+
label: 'Keep it parked',
|
|
318
|
+
consequence: 'it stays in hold/ with its reason, and you are not asked about it again',
|
|
319
|
+
recommended: true,
|
|
320
|
+
current: false,
|
|
321
|
+
person: false,
|
|
322
|
+
applies: null,
|
|
323
|
+
action: { do: 'record' },
|
|
324
|
+
},
|
|
325
|
+
];
|
|
326
|
+
if (name !== null) {
|
|
327
|
+
options.push(handoff('resume', 'Resume it by hand', `you continue ${name} yourself; autopilot does not take it back`, worktree ?? input.repo, [`aidlc continue ${name}`]), handoff('rescope', 'Re-scope it', `you edit what the item asks for, then continue ${name} yourself`, worktree ?? input.repo, [
|
|
328
|
+
`edit ${item.file}`,
|
|
329
|
+
`aidlc continue ${name}`,
|
|
330
|
+
]));
|
|
331
|
+
}
|
|
332
|
+
options.push({
|
|
333
|
+
id: 'decline',
|
|
334
|
+
label: 'Decline it',
|
|
335
|
+
consequence: 'it stays in hold/, declined — not ever, rather than not now',
|
|
336
|
+
recommended: false,
|
|
337
|
+
current: false,
|
|
338
|
+
person: false,
|
|
339
|
+
applies: `aidlc roadmap triage ${item.filename} decline --reason "<your note>"`,
|
|
340
|
+
action: { do: 'triage', item: item.filename, to: 'decline' },
|
|
341
|
+
});
|
|
342
|
+
return [
|
|
343
|
+
{
|
|
344
|
+
key: ['parked', item.filename, reason],
|
|
345
|
+
kind: 'parked',
|
|
346
|
+
instance: name,
|
|
347
|
+
item: item.filename,
|
|
348
|
+
blocks: false,
|
|
349
|
+
since: at,
|
|
350
|
+
question: oneLine(`${item.title ?? item.filename} was parked — what now?`),
|
|
351
|
+
summary: [oneLine(reason), oneLine(worktree === null ? `item: ${item.file}` : `worktree: ${worktree}`)],
|
|
352
|
+
artifact: item.file,
|
|
353
|
+
options,
|
|
354
|
+
},
|
|
355
|
+
];
|
|
356
|
+
});
|
|
357
|
+
}
|
|
358
|
+
/** The executive summary's labelled line, cleaned; null when absent. */
|
|
359
|
+
function summaryLine(item, label) {
|
|
360
|
+
const re = new RegExp(`^\\s*[-*]\\s+\\*\\*${label}\\*\\*\\s*[—–-]\\s*(.*)$`, 'm');
|
|
361
|
+
const m = re.exec(itemBody(item.raw));
|
|
362
|
+
return m === null ? null : oneLine(m[1]) || null;
|
|
363
|
+
}
|
|
364
|
+
function declared(repo, field) {
|
|
365
|
+
const fields = readItemFields(primaryCheckout(repo));
|
|
366
|
+
return fields.kind === 'ok' && fields.fields.some((f) => f.name === field);
|
|
367
|
+
}
|
|
368
|
+
/** Inbox items, when the run has nothing to build or fewer than it has left to start (AC-9). */
|
|
369
|
+
function triage(input) {
|
|
370
|
+
const root = roadmapRoot(input.repo);
|
|
371
|
+
const inbox = listStatusAt(root, 'inbox');
|
|
372
|
+
if (inbox.length === 0)
|
|
373
|
+
return [];
|
|
374
|
+
const ready = pickNext(input.repo, { autopilot: true }).ready.length;
|
|
375
|
+
const run = input.run;
|
|
376
|
+
const short = run !== null && run.limit !== null && ready < run.limit - run.started.length;
|
|
377
|
+
if (ready > 0 && !short)
|
|
378
|
+
return [];
|
|
379
|
+
const ranks = declared(input.repo, 'priority');
|
|
380
|
+
const modes = declared(input.repo, 'run');
|
|
381
|
+
const ranked = listStatusAt(root, 'backlog').filter((b) => typeof parsePriority(frontmatter(b.raw)?.data.priority) === 'number').length;
|
|
382
|
+
const rank = ranks ? ranked + 1 : undefined;
|
|
383
|
+
const at = rank === undefined ? '' : ` at rank ${rank}`;
|
|
384
|
+
const flags = (run_) => `${rank === undefined ? '' : ` --rank ${rank}`}${run_ === undefined ? '' : ` --run ${run_}`}`;
|
|
385
|
+
return inbox.map((item) => {
|
|
386
|
+
const backlog = (id, label, mode, consequence, recommended) => ({
|
|
387
|
+
id,
|
|
388
|
+
label,
|
|
389
|
+
consequence,
|
|
390
|
+
recommended,
|
|
391
|
+
current: false,
|
|
392
|
+
person: false,
|
|
393
|
+
applies: `aidlc roadmap triage ${item.filename} backlog${flags(mode)}`,
|
|
394
|
+
action: { do: 'triage', item: item.filename, to: 'backlog', rank, run: mode },
|
|
395
|
+
});
|
|
396
|
+
const options = modes
|
|
397
|
+
? [
|
|
398
|
+
backlog('backlog-autopilot', `Backlog${at}, autopilot builds it`, 'autopilot', `it joins the backlog${at}, and this run can start it`, true),
|
|
399
|
+
backlog('backlog-attended', `Backlog${at}, a person builds it`, 'attended', `it joins the backlog${at}; autopilot leaves it for a person`, false),
|
|
400
|
+
]
|
|
401
|
+
: [backlog('backlog', `Backlog${at}`, undefined, `it joins the backlog${at}, and this run can start it`, true)];
|
|
402
|
+
const hold = (to, label, consequence) => ({
|
|
403
|
+
id: to,
|
|
404
|
+
label,
|
|
405
|
+
consequence,
|
|
406
|
+
recommended: false,
|
|
407
|
+
current: false,
|
|
408
|
+
person: false,
|
|
409
|
+
applies: `aidlc roadmap triage ${item.filename} ${to} --reason "<your note>"`,
|
|
410
|
+
action: { do: 'triage', item: item.filename, to },
|
|
411
|
+
});
|
|
412
|
+
options.push(hold('park', 'Park it', 'it goes to hold/ as not now, with your note as the reason'), hold('decline', 'Decline it', 'it goes to hold/ as not ever, with your note as the reason'));
|
|
413
|
+
const what = summaryLine(item, 'What it is');
|
|
414
|
+
const rec = summaryLine(item, 'Recommendation');
|
|
415
|
+
const firstAt = (() => {
|
|
416
|
+
const history = frontmatter(item.raw)?.data.history;
|
|
417
|
+
const at0 = Array.isArray(history) ? history[0]?.at : undefined;
|
|
418
|
+
if (at0 instanceof Date)
|
|
419
|
+
return at0.toISOString().slice(0, 10);
|
|
420
|
+
const m = /^(\d{4})(\d{2})(\d{2})-/.exec(item.filename);
|
|
421
|
+
return typeof at0 === 'string' ? at0 : m === null ? null : `${m[1]}-${m[2]}-${m[3]}`;
|
|
422
|
+
})();
|
|
423
|
+
return {
|
|
424
|
+
key: ['triage', item.filename],
|
|
425
|
+
kind: 'triage',
|
|
426
|
+
instance: null,
|
|
427
|
+
item: item.filename,
|
|
428
|
+
blocks: true,
|
|
429
|
+
since: firstAt,
|
|
430
|
+
question: oneLine(`Triage "${item.title ?? item.filename}": where does it go?`),
|
|
431
|
+
summary: [what ?? oneLine(`item: ${item.file}`), rec === null ? (ready === 0 ? 'nothing in the backlog is ready to build' : `only ${ready} ready`) : `its summary recommends: ${rec}`],
|
|
432
|
+
artifact: item.file,
|
|
433
|
+
options,
|
|
434
|
+
};
|
|
435
|
+
});
|
|
436
|
+
}
|
|
437
|
+
/** Retro markers for this run's instances and the tracked items (AC-10). */
|
|
438
|
+
function retros(input) {
|
|
439
|
+
const ours = new Set([...(input.run?.started ?? []), ...input.state.items.map((i) => i.name)]);
|
|
440
|
+
return input.listDir(input.retroDir).flatMap((name) => {
|
|
441
|
+
if (!ours.has(name))
|
|
442
|
+
return [];
|
|
443
|
+
const stamp = (input.read(join(input.retroDir, name)) ?? '').trim();
|
|
444
|
+
const at = /^\d{4}-\d{2}-\d{2}/.test(stamp) ? oneLine(stamp) : null;
|
|
445
|
+
return [
|
|
446
|
+
{
|
|
447
|
+
key: ['retro-pending', name, stamp],
|
|
448
|
+
kind: 'retro-pending',
|
|
449
|
+
instance: name,
|
|
450
|
+
item: null,
|
|
451
|
+
blocks: false,
|
|
452
|
+
since: at,
|
|
453
|
+
question: oneLine(`Run the retrospective for ${name}?`),
|
|
454
|
+
summary: [oneLine(`${name} completed and its retrospective has not run`), 'it writes lessons every later item reads'],
|
|
455
|
+
artifact: null,
|
|
456
|
+
options: [
|
|
457
|
+
handoff('run-now', 'Run it now', 'you start a new agent session in the primary checkout and run the aidlc-retrospective skill', input.repo, [
|
|
458
|
+
`start an agent session and run the aidlc-retrospective skill for ${name}`,
|
|
459
|
+
], { recommended: true }),
|
|
460
|
+
later('the marker stays, and aidlc status keeps naming it'),
|
|
461
|
+
],
|
|
462
|
+
},
|
|
463
|
+
];
|
|
464
|
+
});
|
|
465
|
+
}
|
|
466
|
+
/** Blocking first, then the oldest, then by name; ties keep the order they were found in (AC-3). */
|
|
467
|
+
function compare(a, b) {
|
|
468
|
+
if (a.blocks !== b.blocks)
|
|
469
|
+
return a.blocks ? -1 : 1;
|
|
470
|
+
if (a.since !== b.since) {
|
|
471
|
+
if (a.since === null)
|
|
472
|
+
return 1;
|
|
473
|
+
if (b.since === null)
|
|
474
|
+
return -1;
|
|
475
|
+
return a.since < b.since ? -1 : 1;
|
|
476
|
+
}
|
|
477
|
+
const an = a.instance ?? a.item ?? '';
|
|
478
|
+
const bn = b.instance ?? b.item ?? '';
|
|
479
|
+
return an < bn ? -1 : an > bn ? 1 : 0;
|
|
480
|
+
}
|
|
481
|
+
/** Every entry, less those `answered` names, in asking order (AC-1..AC-14). */
|
|
482
|
+
export function collectPending(input, answered) {
|
|
483
|
+
const drafts = [];
|
|
484
|
+
const safely = (f) => {
|
|
485
|
+
try {
|
|
486
|
+
drafts.push(...f());
|
|
487
|
+
}
|
|
488
|
+
catch {
|
|
489
|
+
// A source that cannot be read is skipped (AC-14).
|
|
490
|
+
}
|
|
491
|
+
};
|
|
492
|
+
for (const item of input.state.items) {
|
|
493
|
+
if (item.step === 'awaiting-review')
|
|
494
|
+
safely(() => awaitingReview(input, item));
|
|
495
|
+
safely(() => logged(input, item));
|
|
496
|
+
if (item.step === 'error')
|
|
497
|
+
safely(() => [failed(input, item)]);
|
|
498
|
+
}
|
|
499
|
+
safely(() => parked(input));
|
|
500
|
+
safely(() => triage(input));
|
|
501
|
+
safely(() => retros(input));
|
|
502
|
+
return drafts
|
|
503
|
+
.map(({ key, options, ...rest }) => {
|
|
504
|
+
const fp = fingerprint(key);
|
|
505
|
+
return { ...rest, fingerprint: fp, options: options.map((o) => ({ ...o, command: answerCommand(fp, o.id) })) };
|
|
506
|
+
})
|
|
507
|
+
.filter((e) => !answered.has(e.fingerprint))
|
|
508
|
+
.sort(compare);
|
|
509
|
+
}
|
|
510
|
+
/** `pending --json`: the run, and every entry without its internal action (AC-1, AC-2). */
|
|
511
|
+
export function pendingJson(run, entries) {
|
|
512
|
+
return JSON.stringify({
|
|
513
|
+
run: run === null ? null : { pid: run.pid, started_at: run.started_at, limit: run.limit, started: run.started, finished: run.finished },
|
|
514
|
+
entries: entries.map((e) => ({ ...e, options: e.options.map(({ action: _action, ...o }) => o) })),
|
|
515
|
+
}, null, 2);
|
|
516
|
+
}
|
|
517
|
+
/** `pending` without `--json` (AC-15). */
|
|
518
|
+
export function pendingText(entries) {
|
|
519
|
+
if (entries.length === 0)
|
|
520
|
+
return ['nothing waits for you'];
|
|
521
|
+
const lines = [`${entries.length} waiting for you:`];
|
|
522
|
+
for (const e of entries) {
|
|
523
|
+
lines.push('', `[${e.blocks ? 'blocks' : 'waits'}] ${e.kind} ${e.instance ?? e.item ?? ''} — ${e.question}`);
|
|
524
|
+
for (const s of e.summary)
|
|
525
|
+
lines.push(` ${s}`);
|
|
526
|
+
for (const o of e.options) {
|
|
527
|
+
const marks = [o.recommended ? 'recommended' : null, o.current ? 'built' : null, o.person ? 'you run it' : null].filter(Boolean);
|
|
528
|
+
lines.push(` ${o.id}: ${o.label}${marks.length === 0 ? '' : ` (${marks.join(', ')})`} — ${o.consequence}`);
|
|
529
|
+
}
|
|
530
|
+
lines.push(` answer: ${answerCommand(e.fingerprint, '<option>')}`);
|
|
531
|
+
}
|
|
532
|
+
return lines;
|
|
533
|
+
}
|
|
534
|
+
//# sourceMappingURL=pending.js.map
|