@wildorder/nightshift 0.2.0 → 0.3.1
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/cli.js +23 -0
- package/dist/cli.js.map +1 -1
- package/dist/decision-ledger.d.ts +68 -0
- package/dist/decision-ledger.d.ts.map +1 -0
- package/dist/decision-ledger.js +108 -0
- package/dist/decision-ledger.js.map +1 -0
- package/dist/decision.d.ts +59 -0
- package/dist/decision.d.ts.map +1 -0
- package/dist/decision.js +0 -0
- package/dist/decision.js.map +1 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -0
- package/dist/index.js.map +1 -1
- package/dist/manifest.d.ts +76 -0
- package/dist/manifest.d.ts.map +1 -0
- package/dist/manifest.js +95 -0
- package/dist/manifest.js.map +1 -0
- package/dist/prompt.d.ts.map +1 -1
- package/dist/prompt.js +18 -1
- package/dist/prompt.js.map +1 -1
- package/dist/run-program.d.ts +74 -0
- package/dist/run-program.d.ts.map +1 -0
- package/dist/run-program.js +509 -0
- package/dist/run-program.js.map +1 -0
- package/package.json +2 -1
package/dist/prompt.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prompt.js","sourceRoot":"","sources":["../src/prompt.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AA+BH,MAAM,WAAW,GAAG,aAAa,CAAC;AAClC,MAAM,WAAW,GAAG,aAAa,CAAC;AAElC,MAAM,UAAU,cAAc;IAC5B,OAAO,EAAE,KAAK,EAAE,OAAO,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,CAAC,MAAM,EAAE,CAAC;AAC1D,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,aAAa,CAC3B,UAAyB,cAAc,EAAE,EACzC,MAAyB,OAAO,CAAC,GAAG;IAEpC,OAAO,CACL,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC;QAC5B,OAAO,CAAC,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AE,OAAO,EAAE,OAAO,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QACxD,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,GAAG,EAAE,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;KAC7C,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { type AgentRunner, type VerifyRunner } from "./agent-runner.js";
|
|
2
|
+
import type { NightshiftConfig } from "./config.js";
|
|
3
|
+
import { type DecisionRecord } from "./decision-ledger.js";
|
|
4
|
+
import { type Workstream } from "./manifest.js";
|
|
5
|
+
/**
|
|
6
|
+
* Git operations the runner needs, injectable so tests drive a real
|
|
7
|
+
* temporary repository or a fake. The runner owns commits — workstream
|
|
8
|
+
* agents are instructed never to commit — and every decision is anchored to
|
|
9
|
+
* the commit that preceded it so a human can replay from there.
|
|
10
|
+
*/
|
|
11
|
+
export interface GitOps {
|
|
12
|
+
isRepository(cwd: string): Promise<boolean>;
|
|
13
|
+
currentCommit(cwd: string): Promise<string | undefined>;
|
|
14
|
+
/** Stages everything and commits; undefined result means nothing to commit. */
|
|
15
|
+
commitAll(cwd: string, message: string): Promise<string | undefined>;
|
|
16
|
+
diffSince(cwd: string, commit: string): Promise<string>;
|
|
17
|
+
/** Repo-relative paths with uncommitted changes (staged or not). */
|
|
18
|
+
dirtyPaths(cwd: string): Promise<string[]>;
|
|
19
|
+
}
|
|
20
|
+
export declare const defaultGitOps: GitOps;
|
|
21
|
+
export interface RunProgramOptions {
|
|
22
|
+
cwd: string;
|
|
23
|
+
programId: string;
|
|
24
|
+
config: NightshiftConfig;
|
|
25
|
+
agentRunner?: AgentRunner;
|
|
26
|
+
verifyRunner?: VerifyRunner;
|
|
27
|
+
git?: GitOps;
|
|
28
|
+
log?: (line: string) => void;
|
|
29
|
+
now?: () => Date;
|
|
30
|
+
}
|
|
31
|
+
export type WorkstreamOutcome = {
|
|
32
|
+
status: "complete";
|
|
33
|
+
commit?: string;
|
|
34
|
+
} | {
|
|
35
|
+
status: "failed";
|
|
36
|
+
reason: string;
|
|
37
|
+
} | {
|
|
38
|
+
status: "parked";
|
|
39
|
+
reason: string;
|
|
40
|
+
} | {
|
|
41
|
+
status: "skipped";
|
|
42
|
+
reason: string;
|
|
43
|
+
};
|
|
44
|
+
export interface WorkstreamResult {
|
|
45
|
+
id: string;
|
|
46
|
+
name: string;
|
|
47
|
+
outcome: WorkstreamOutcome;
|
|
48
|
+
summary?: string;
|
|
49
|
+
decisionIds: string[];
|
|
50
|
+
/** Decision blocks the agent garbled; surfaced, never fatal. */
|
|
51
|
+
decisionErrors: string[];
|
|
52
|
+
}
|
|
53
|
+
export interface RunProgramResult {
|
|
54
|
+
programId: string;
|
|
55
|
+
/** True when every workstream is complete. */
|
|
56
|
+
complete: boolean;
|
|
57
|
+
workstreams: WorkstreamResult[];
|
|
58
|
+
escalations: DecisionRecord[];
|
|
59
|
+
reportPath: string;
|
|
60
|
+
}
|
|
61
|
+
/** Every workstream in the transitive downstream cone of the given ids. */
|
|
62
|
+
export declare function downstreamCone(workstreams: readonly Workstream[], rootIds: readonly string[]): Set<string>;
|
|
63
|
+
/**
|
|
64
|
+
* The decide-and-continue runner.
|
|
65
|
+
*
|
|
66
|
+
* A run always terminates: either everything built, or the failures are
|
|
67
|
+
* parked with a diagnosis while everything outside their downstream cones
|
|
68
|
+
* built anyway. Decisions agents surface are journaled with the commit that
|
|
69
|
+
* preceded them, reviewed by the decider when one is configured, and
|
|
70
|
+
* reported — the run never stops to ask. The runner owns commits, runs the
|
|
71
|
+
* verify commands itself, and writes the run report last, whatever happened.
|
|
72
|
+
*/
|
|
73
|
+
export declare function runProgram(options: RunProgramOptions): Promise<RunProgramResult>;
|
|
74
|
+
//# sourceMappingURL=run-program.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"run-program.d.ts","sourceRoot":"","sources":["../src/run-program.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IAAC,MAAM,CAAC,EAAE,MAAM,CAAA;CAAE,GACvC;IAAE,MAAM,EAAE,QAAQ,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,GACpC;IAAE,MAAM,EAAE,QAAQ,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,GACpC;IAAE,MAAM,EAAE,SAAS,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC;AAE1C,MAAM,WAAW,gBAAgB;IAC/B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,iBAAiB,CAAC;IAC3B,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,WAAW,EAAE,MAAM,EAAE,CAAC;IACtB,gEAAgE;IAChE,cAAc,EAAE,MAAM,EAAE,CAAC;CAC1B;AAED,MAAM,WAAW,gBAAgB;IAC/B,SAAS,EAAE,MAAM,CAAC;IAClB,8CAA8C;IAC9C,QAAQ,EAAE,OAAO,CAAC;IAClB,WAAW,EAAE,gBAAgB,EAAE,CAAC;IAChC,WAAW,EAAE,cAAc,EAAE,CAAC;IAC9B,UAAU,EAAE,MAAM,CAAC;CACpB;AAgJD,2EAA2E;AAC3E,wBAAgB,cAAc,CAC5B,WAAW,EAAE,SAAS,UAAU,EAAE,EAClC,OAAO,EAAE,SAAS,MAAM,EAAE,GACzB,GAAG,CAAC,MAAM,CAAC,CAeb;AAED;;;;;;;;;GASG;AACH,wBAAsB,UAAU,CAC9B,OAAO,EAAE,iBAAiB,GACzB,OAAO,CAAC,gBAAgB,CAAC,CAsU3B"}
|
|
@@ -0,0 +1,509 @@
|
|
|
1
|
+
import { execFile } from "node:child_process";
|
|
2
|
+
import { readFile, writeFile } from "node:fs/promises";
|
|
3
|
+
import { join, resolve } from "node:path";
|
|
4
|
+
import { promisify } from "node:util";
|
|
5
|
+
import { defaultAgentRunner, defaultVerifyRunner, describeAgent, resolveAgent, resolveDeciderAgent, resolveRecoveryAgent, tail, } from "./agent-runner.js";
|
|
6
|
+
import { resolveSummary, summaryContract } from "./agent-summary.js";
|
|
7
|
+
import { decisionContract, decisionFingerprint, extractDecisions, } from "./decision.js";
|
|
8
|
+
import { appendLedgerEvents, readDecisionLedger, } from "./decision-ledger.js";
|
|
9
|
+
import { findCycles, stableTopologicalOrder } from "./graph.js";
|
|
10
|
+
import { loadManifest, saveManifest, } from "./manifest.js";
|
|
11
|
+
const execFileAsync = promisify(execFile);
|
|
12
|
+
export const defaultGitOps = {
|
|
13
|
+
async isRepository(cwd) {
|
|
14
|
+
try {
|
|
15
|
+
await execFileAsync("git", ["rev-parse", "--is-inside-work-tree"], { cwd });
|
|
16
|
+
return true;
|
|
17
|
+
}
|
|
18
|
+
catch {
|
|
19
|
+
return false;
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
async currentCommit(cwd) {
|
|
23
|
+
try {
|
|
24
|
+
const { stdout } = await execFileAsync("git", ["rev-parse", "HEAD"], { cwd });
|
|
25
|
+
return stdout.trim();
|
|
26
|
+
}
|
|
27
|
+
catch {
|
|
28
|
+
return undefined;
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
async commitAll(cwd, message) {
|
|
32
|
+
await execFileAsync("git", ["add", "-A"], { cwd });
|
|
33
|
+
try {
|
|
34
|
+
await execFileAsync("git", ["commit", "-m", message], { cwd });
|
|
35
|
+
}
|
|
36
|
+
catch (error) {
|
|
37
|
+
const output = String(error.stdout ?? "");
|
|
38
|
+
// An empty commit is not a failure; anything else is.
|
|
39
|
+
if (/nothing to commit|nothing added to commit/u.test(output)) {
|
|
40
|
+
return undefined;
|
|
41
|
+
}
|
|
42
|
+
throw error;
|
|
43
|
+
}
|
|
44
|
+
return this.currentCommit(cwd);
|
|
45
|
+
},
|
|
46
|
+
async diffSince(cwd, commit) {
|
|
47
|
+
try {
|
|
48
|
+
const { stdout } = await execFileAsync("git", ["diff", commit, "--", ".", ":!docs/programs"], { cwd, maxBuffer: 10 * 1024 * 1024 });
|
|
49
|
+
return stdout;
|
|
50
|
+
}
|
|
51
|
+
catch {
|
|
52
|
+
return "";
|
|
53
|
+
}
|
|
54
|
+
},
|
|
55
|
+
async dirtyPaths(cwd) {
|
|
56
|
+
try {
|
|
57
|
+
const { stdout } = await execFileAsync("git", ["status", "--porcelain"], { cwd });
|
|
58
|
+
return stdout
|
|
59
|
+
.split(/\r?\n/u)
|
|
60
|
+
.filter((line) => line.trim() !== "")
|
|
61
|
+
.map((line) => line.slice(3).trim());
|
|
62
|
+
}
|
|
63
|
+
catch {
|
|
64
|
+
return [];
|
|
65
|
+
}
|
|
66
|
+
},
|
|
67
|
+
};
|
|
68
|
+
const DIFF_LIMIT = 20_000;
|
|
69
|
+
function implementerBrief(manifest, workstream, spec, priorFailure) {
|
|
70
|
+
const roster = manifest.workstreams
|
|
71
|
+
.map((entry) => {
|
|
72
|
+
const scope = entry.scope?.summary ?? entry.name;
|
|
73
|
+
return `- ${entry.id} ${entry.name}: ${scope}`;
|
|
74
|
+
})
|
|
75
|
+
.join("\n");
|
|
76
|
+
return [
|
|
77
|
+
`# Workstream ${workstream.id}: ${workstream.name}`,
|
|
78
|
+
"",
|
|
79
|
+
`Program: ${manifest.program.id} — ${manifest.program.name}`,
|
|
80
|
+
"",
|
|
81
|
+
"You are implementing exactly one workstream of a larger program. The",
|
|
82
|
+
"full roster, so you know what exists and do not rebuild another",
|
|
83
|
+
"workstream's work (conform only to your declared dependencies):",
|
|
84
|
+
"",
|
|
85
|
+
roster,
|
|
86
|
+
"",
|
|
87
|
+
...(priorFailure
|
|
88
|
+
? [
|
|
89
|
+
"## Previous attempt failed",
|
|
90
|
+
"",
|
|
91
|
+
"A previous attempt at this workstream failed. Its diagnosis:",
|
|
92
|
+
"",
|
|
93
|
+
priorFailure,
|
|
94
|
+
"",
|
|
95
|
+
"Start from the diagnosis; the working tree may already contain",
|
|
96
|
+
"partial work from that attempt.",
|
|
97
|
+
"",
|
|
98
|
+
]
|
|
99
|
+
: []),
|
|
100
|
+
"## Specification",
|
|
101
|
+
"",
|
|
102
|
+
spec.trim(),
|
|
103
|
+
"",
|
|
104
|
+
"## Rules",
|
|
105
|
+
"",
|
|
106
|
+
"- Never commit; the runner owns commits and commits only verified work.",
|
|
107
|
+
"- Follow the repository's AGENTS.md if present.",
|
|
108
|
+
"- Run the project's checks yourself as you work; the runner verifies",
|
|
109
|
+
" independently afterwards and your claim of success is never trusted",
|
|
110
|
+
" without it.",
|
|
111
|
+
"",
|
|
112
|
+
decisionContract(),
|
|
113
|
+
"",
|
|
114
|
+
summaryContract(),
|
|
115
|
+
].join("\n");
|
|
116
|
+
}
|
|
117
|
+
function deciderBrief(manifest, record, diff) {
|
|
118
|
+
const clippedDiff = diff.length > DIFF_LIMIT
|
|
119
|
+
? `${diff.slice(0, DIFF_LIMIT)}\n… (diff clipped at ${DIFF_LIMIT} characters)`
|
|
120
|
+
: diff;
|
|
121
|
+
return [
|
|
122
|
+
"# Review one decision",
|
|
123
|
+
"",
|
|
124
|
+
`Program: ${manifest.program.id} — ${manifest.program.name}`,
|
|
125
|
+
`Workstream: ${record.workstream}`,
|
|
126
|
+
"",
|
|
127
|
+
"An implementing agent made the judgment call below and continued. Your",
|
|
128
|
+
"job is to review that one decision — not the code style, not the whole",
|
|
129
|
+
"diff — from the program's point of view. You never edit anything.",
|
|
130
|
+
"",
|
|
131
|
+
"```json",
|
|
132
|
+
JSON.stringify(record.decision, null, 2),
|
|
133
|
+
"```",
|
|
134
|
+
"",
|
|
135
|
+
"The work that resulted:",
|
|
136
|
+
"",
|
|
137
|
+
"```diff",
|
|
138
|
+
clippedDiff.trim() === "" ? "(no diff available)" : clippedDiff,
|
|
139
|
+
"```",
|
|
140
|
+
"",
|
|
141
|
+
"Reply with exactly one verdict block:",
|
|
142
|
+
"",
|
|
143
|
+
"```verdict",
|
|
144
|
+
"{",
|
|
145
|
+
' "verdict": "ratify" | "escalate",',
|
|
146
|
+
' "rationale": "One or two sentences, written for the human who reads the run report."',
|
|
147
|
+
"}",
|
|
148
|
+
"```",
|
|
149
|
+
"",
|
|
150
|
+
"Ratify when the choice is defensible — it does not have to be the one",
|
|
151
|
+
"you would have made. Escalate when the choice materially affects",
|
|
152
|
+
"user-visible behavior, data, or a public contract AND you believe the",
|
|
153
|
+
"human would plausibly choose differently; say what you would ask them.",
|
|
154
|
+
"One review, one verdict: this is a judgment, not a dialogue.",
|
|
155
|
+
].join("\n");
|
|
156
|
+
}
|
|
157
|
+
function extractVerdict(output) {
|
|
158
|
+
const matches = [...output.matchAll(/```verdict[^\S\r\n]*\r?\n([\s\S]*?)```/gu)];
|
|
159
|
+
for (const match of matches.reverse()) {
|
|
160
|
+
try {
|
|
161
|
+
const parsed = JSON.parse(match[1] ?? "");
|
|
162
|
+
if ((parsed.verdict === "ratify" || parsed.verdict === "escalate") &&
|
|
163
|
+
typeof parsed.rationale === "string") {
|
|
164
|
+
return { verdict: parsed.verdict, rationale: parsed.rationale };
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
catch {
|
|
168
|
+
// Try an earlier block.
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
return undefined;
|
|
172
|
+
}
|
|
173
|
+
async function invokeAgent(runner, agent, prompt, cwd) {
|
|
174
|
+
return runner({
|
|
175
|
+
command: agent.command,
|
|
176
|
+
args: agent.args,
|
|
177
|
+
prompt,
|
|
178
|
+
promptMode: agent.promptMode,
|
|
179
|
+
cwd,
|
|
180
|
+
});
|
|
181
|
+
}
|
|
182
|
+
/** Every workstream in the transitive downstream cone of the given ids. */
|
|
183
|
+
export function downstreamCone(workstreams, rootIds) {
|
|
184
|
+
const cone = new Set(rootIds);
|
|
185
|
+
let grew = true;
|
|
186
|
+
while (grew) {
|
|
187
|
+
grew = false;
|
|
188
|
+
for (const workstream of workstreams) {
|
|
189
|
+
if (cone.has(workstream.id))
|
|
190
|
+
continue;
|
|
191
|
+
if (workstream.dependencies.some((dependency) => cone.has(dependency))) {
|
|
192
|
+
cone.add(workstream.id);
|
|
193
|
+
grew = true;
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
for (const id of rootIds)
|
|
198
|
+
cone.delete(id);
|
|
199
|
+
return cone;
|
|
200
|
+
}
|
|
201
|
+
/**
|
|
202
|
+
* The decide-and-continue runner.
|
|
203
|
+
*
|
|
204
|
+
* A run always terminates: either everything built, or the failures are
|
|
205
|
+
* parked with a diagnosis while everything outside their downstream cones
|
|
206
|
+
* built anyway. Decisions agents surface are journaled with the commit that
|
|
207
|
+
* preceded them, reviewed by the decider when one is configured, and
|
|
208
|
+
* reported — the run never stops to ask. The runner owns commits, runs the
|
|
209
|
+
* verify commands itself, and writes the run report last, whatever happened.
|
|
210
|
+
*/
|
|
211
|
+
export async function runProgram(options) {
|
|
212
|
+
const root = resolve(options.cwd);
|
|
213
|
+
const config = options.config;
|
|
214
|
+
const agentRunner = options.agentRunner ?? defaultAgentRunner;
|
|
215
|
+
const verifyRunner = options.verifyRunner ?? defaultVerifyRunner;
|
|
216
|
+
const git = options.git ?? defaultGitOps;
|
|
217
|
+
const log = options.log ?? ((line) => console.log(line));
|
|
218
|
+
const now = options.now ?? (() => new Date());
|
|
219
|
+
const manifest = await loadManifest(root, options.programId);
|
|
220
|
+
const resolvedAgent = resolveAgent(config);
|
|
221
|
+
if (!resolvedAgent) {
|
|
222
|
+
throw new Error("No implementer configured. Set the `agent` block in nightshift.config.json.");
|
|
223
|
+
}
|
|
224
|
+
const agent = resolvedAgent;
|
|
225
|
+
const recovery = resolveRecoveryAgent(config);
|
|
226
|
+
const decider = resolveDeciderAgent(config);
|
|
227
|
+
log(`implementer: ${describeAgent(agent)}`);
|
|
228
|
+
log(decider
|
|
229
|
+
? `decider: ${describeAgent(decider)}`
|
|
230
|
+
: "decider: none configured — implementer defaults will stand unratified");
|
|
231
|
+
const cycles = findCycles(manifest.workstreams);
|
|
232
|
+
if (cycles.length > 0) {
|
|
233
|
+
// A cyclic graph cannot be ordered; this is a planning defect, not a
|
|
234
|
+
// decision the runner can take. Terminate with the diagnosis.
|
|
235
|
+
throw new Error(`Dependency cycle(s) in the manifest: ${cycles
|
|
236
|
+
.map((cycle) => cycle.join(" -> "))
|
|
237
|
+
.join("; ")}. Re-plan with /plan-program.`);
|
|
238
|
+
}
|
|
239
|
+
const isRepository = await git.isRepository(root);
|
|
240
|
+
if (!isRepository) {
|
|
241
|
+
log("warning: not a git repository — commits, decision anchors, and replay are unavailable");
|
|
242
|
+
}
|
|
243
|
+
else {
|
|
244
|
+
// The runner commits with `git add -A`, so unrelated work in the tree
|
|
245
|
+
// would be swept into a machine-authored workstream commit. Refuse a
|
|
246
|
+
// dirty start — except when resuming a run that already failed or was
|
|
247
|
+
// interrupted, whose own leftover work is exactly what a resume needs.
|
|
248
|
+
// The runner's own artifacts under docs/programs/ are exempt: they are
|
|
249
|
+
// output, not work in progress.
|
|
250
|
+
const dirty = (await git.dirtyPaths(root)).filter((path) => !path.replaceAll("\\", "/").startsWith("docs/programs/"));
|
|
251
|
+
const resuming = manifest.workstreams.some((workstream) => workstream.status === "failed" || workstream.status === "in_progress");
|
|
252
|
+
if (dirty.length > 0 && !resuming) {
|
|
253
|
+
throw new Error(`The working tree has uncommitted changes the run would sweep into its commits:\n` +
|
|
254
|
+
dirty.map((path) => ` ${path}`).join("\n") +
|
|
255
|
+
`\nCommit or stash them, then re-run.`);
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
const ordered = stableTopologicalOrder(manifest.workstreams);
|
|
259
|
+
const results = [];
|
|
260
|
+
const blocked = new Set();
|
|
261
|
+
for (const workstream of ordered) {
|
|
262
|
+
if (workstream.status === "complete") {
|
|
263
|
+
results.push({
|
|
264
|
+
id: workstream.id,
|
|
265
|
+
name: workstream.name,
|
|
266
|
+
outcome: { status: "skipped", reason: "already complete" },
|
|
267
|
+
decisionIds: [],
|
|
268
|
+
decisionErrors: [],
|
|
269
|
+
});
|
|
270
|
+
continue;
|
|
271
|
+
}
|
|
272
|
+
if (blocked.has(workstream.id)) {
|
|
273
|
+
workstream.status = "parked";
|
|
274
|
+
results.push({
|
|
275
|
+
id: workstream.id,
|
|
276
|
+
name: workstream.name,
|
|
277
|
+
outcome: {
|
|
278
|
+
status: "parked",
|
|
279
|
+
reason: "an upstream dependency failed; parked, not attempted",
|
|
280
|
+
},
|
|
281
|
+
decisionIds: [],
|
|
282
|
+
decisionErrors: [],
|
|
283
|
+
});
|
|
284
|
+
continue;
|
|
285
|
+
}
|
|
286
|
+
const result = await runWorkstream(workstream);
|
|
287
|
+
results.push(result);
|
|
288
|
+
if (result.outcome.status === "failed") {
|
|
289
|
+
// Failure isolation: park the downstream cone, keep building the rest.
|
|
290
|
+
for (const id of downstreamCone(manifest.workstreams, [workstream.id])) {
|
|
291
|
+
blocked.add(id);
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
const ledger = await readDecisionLedger(root, options.programId);
|
|
296
|
+
const escalations = ledger.decisions.filter((decision) => decision.status === "escalated");
|
|
297
|
+
const complete = results.every((result) => result.outcome.status === "complete" ||
|
|
298
|
+
result.outcome.status === "skipped");
|
|
299
|
+
manifest.program.status = complete ? "complete" : "partial";
|
|
300
|
+
await saveManifest(root, options.programId, manifest);
|
|
301
|
+
const reportPath = join(root, "docs", "programs", `${options.programId}-run-report.md`);
|
|
302
|
+
await writeFile(reportPath, renderRunReport(manifest, results, ledger.decisions, escalations, now()), "utf8");
|
|
303
|
+
if (isRepository) {
|
|
304
|
+
await git.commitAll(root, `nightshift(${options.programId}): run report and decision ledger`);
|
|
305
|
+
}
|
|
306
|
+
log(`run report: ${reportPath}`);
|
|
307
|
+
return {
|
|
308
|
+
programId: options.programId,
|
|
309
|
+
complete,
|
|
310
|
+
workstreams: results,
|
|
311
|
+
escalations,
|
|
312
|
+
reportPath,
|
|
313
|
+
};
|
|
314
|
+
async function runWorkstream(workstream) {
|
|
315
|
+
const base = {
|
|
316
|
+
id: workstream.id,
|
|
317
|
+
name: workstream.name,
|
|
318
|
+
outcome: { status: "failed", reason: "not attempted" },
|
|
319
|
+
decisionIds: [],
|
|
320
|
+
decisionErrors: [],
|
|
321
|
+
};
|
|
322
|
+
let spec;
|
|
323
|
+
try {
|
|
324
|
+
spec = await readFile(join(root, workstream.taskFile), "utf8");
|
|
325
|
+
}
|
|
326
|
+
catch {
|
|
327
|
+
base.outcome = {
|
|
328
|
+
status: "parked",
|
|
329
|
+
reason: `spec not found at ${workstream.taskFile}`,
|
|
330
|
+
};
|
|
331
|
+
return base;
|
|
332
|
+
}
|
|
333
|
+
workstream.status = "in_progress";
|
|
334
|
+
await saveManifest(root, options.programId, manifest);
|
|
335
|
+
const baseCommit = isRepository
|
|
336
|
+
? await git.currentCommit(root)
|
|
337
|
+
: undefined;
|
|
338
|
+
let priorFailure;
|
|
339
|
+
const attempts = [
|
|
340
|
+
{ agent, label: "implementer" },
|
|
341
|
+
];
|
|
342
|
+
if (recovery && !recovery.borrowedImplementer) {
|
|
343
|
+
attempts.push({ agent: recovery.agent, label: "recovery" });
|
|
344
|
+
}
|
|
345
|
+
for (const [index, attempt] of attempts.entries()) {
|
|
346
|
+
log(`${workstream.id} ${workstream.name}: ${attempt.label} attempt`);
|
|
347
|
+
const brief = implementerBrief(manifest, workstream, spec, priorFailure);
|
|
348
|
+
const invocation = await invokeAgent(agentRunner, attempt.agent, brief, root);
|
|
349
|
+
const summary = resolveSummary(invocation.output);
|
|
350
|
+
base.summary = summary.text;
|
|
351
|
+
const parsed = extractDecisions(invocation.output);
|
|
352
|
+
base.decisionErrors.push(...parsed.errors);
|
|
353
|
+
await journalDecisions(workstream, parsed.decisions, baseCommit);
|
|
354
|
+
base.decisionIds = parsed.decisions.map((decision) => decisionFingerprint(workstream.id, decision));
|
|
355
|
+
const failure = await verifyAttempt(invocation.exitCode);
|
|
356
|
+
if (failure === undefined) {
|
|
357
|
+
workstream.status = "complete";
|
|
358
|
+
await saveManifest(root, options.programId, manifest);
|
|
359
|
+
let commit;
|
|
360
|
+
if (isRepository) {
|
|
361
|
+
commit = await git.commitAll(root, `nightshift(${options.programId}): ${workstream.id} ${workstream.name}`);
|
|
362
|
+
}
|
|
363
|
+
await reviewDecisions(workstream, parsed.decisions, baseCommit);
|
|
364
|
+
base.outcome = {
|
|
365
|
+
status: "complete",
|
|
366
|
+
...(commit === undefined ? {} : { commit }),
|
|
367
|
+
};
|
|
368
|
+
return base;
|
|
369
|
+
}
|
|
370
|
+
priorFailure = failure;
|
|
371
|
+
log(`${workstream.id}: ${attempt.label} attempt failed — ${failure}`);
|
|
372
|
+
if (index === attempts.length - 1) {
|
|
373
|
+
workstream.status = "failed";
|
|
374
|
+
await saveManifest(root, options.programId, manifest);
|
|
375
|
+
// The work stays in the tree for a resume; decisions made on the way
|
|
376
|
+
// to a failure are still journaled and still reviewable.
|
|
377
|
+
await reviewDecisions(workstream, parsed.decisions, baseCommit);
|
|
378
|
+
base.outcome = { status: "failed", reason: failure };
|
|
379
|
+
return base;
|
|
380
|
+
}
|
|
381
|
+
}
|
|
382
|
+
return base;
|
|
383
|
+
}
|
|
384
|
+
/** Undefined means the attempt verified clean; otherwise the diagnosis. */
|
|
385
|
+
async function verifyAttempt(agentExitCode) {
|
|
386
|
+
if (agentExitCode !== 0) {
|
|
387
|
+
return `agent exited with code ${agentExitCode}`;
|
|
388
|
+
}
|
|
389
|
+
for (const [name, command] of Object.entries(config.verify)) {
|
|
390
|
+
const result = await verifyRunner(command, root);
|
|
391
|
+
if (result.exitCode !== 0) {
|
|
392
|
+
return `verify \`${name}\` (${command}) exited ${result.exitCode}:\n${tail(result.output, 1500)}`;
|
|
393
|
+
}
|
|
394
|
+
}
|
|
395
|
+
return undefined;
|
|
396
|
+
}
|
|
397
|
+
async function journalDecisions(workstream, decisions, baseCommit) {
|
|
398
|
+
const events = decisions.map((decision) => ({
|
|
399
|
+
kind: "decision-recorded",
|
|
400
|
+
at: now().toISOString(),
|
|
401
|
+
id: decisionFingerprint(workstream.id, decision),
|
|
402
|
+
workstream: workstream.id,
|
|
403
|
+
decision,
|
|
404
|
+
...(baseCommit === undefined ? {} : { baseCommit }),
|
|
405
|
+
decidedBy: "implementer",
|
|
406
|
+
}));
|
|
407
|
+
await appendLedgerEvents(root, options.programId, events);
|
|
408
|
+
for (const decision of decisions) {
|
|
409
|
+
log(`${workstream.id} decision: ${decision.title} -> ${decision.chosen}`);
|
|
410
|
+
}
|
|
411
|
+
}
|
|
412
|
+
/**
|
|
413
|
+
* Post-hoc review: the decider sees each decision with the diff it
|
|
414
|
+
* produced. One decision, one invocation, one verdict — a judgment, not a
|
|
415
|
+
* dialogue. No decider configured means defaults stand unratified, which
|
|
416
|
+
* the report says plainly.
|
|
417
|
+
*/
|
|
418
|
+
async function reviewDecisions(workstream, decisions, baseCommit) {
|
|
419
|
+
if (!decider || decisions.length === 0)
|
|
420
|
+
return;
|
|
421
|
+
const diff = isRepository && baseCommit !== undefined
|
|
422
|
+
? await git.diffSince(root, baseCommit)
|
|
423
|
+
: "";
|
|
424
|
+
for (const decision of decisions) {
|
|
425
|
+
const id = decisionFingerprint(workstream.id, decision);
|
|
426
|
+
const brief = deciderBrief(manifest, { workstream: workstream.id, decision }, diff);
|
|
427
|
+
const invocation = await invokeAgent(agentRunner, decider, brief, root);
|
|
428
|
+
const verdict = extractVerdict(invocation.output);
|
|
429
|
+
if (invocation.exitCode !== 0 || verdict === undefined) {
|
|
430
|
+
// Fail open: an unreviewable decision stays unratified and the
|
|
431
|
+
// report says so; it never blocks the run.
|
|
432
|
+
log(`${workstream.id} decision ${id}: decider produced no verdict; left unratified`);
|
|
433
|
+
continue;
|
|
434
|
+
}
|
|
435
|
+
await appendLedgerEvents(root, options.programId, [
|
|
436
|
+
{
|
|
437
|
+
kind: "decision-reviewed",
|
|
438
|
+
at: now().toISOString(),
|
|
439
|
+
id,
|
|
440
|
+
verdict: verdict.verdict,
|
|
441
|
+
rationale: verdict.rationale,
|
|
442
|
+
reviewedBy: "decider",
|
|
443
|
+
},
|
|
444
|
+
]);
|
|
445
|
+
log(`${workstream.id} decision ${id}: ${verdict.verdict}`);
|
|
446
|
+
}
|
|
447
|
+
}
|
|
448
|
+
}
|
|
449
|
+
function renderRunReport(manifest, results, decisions, escalations, at) {
|
|
450
|
+
const built = results.filter((result) => result.outcome.status === "complete" ||
|
|
451
|
+
result.outcome.status === "skipped").length;
|
|
452
|
+
const lines = [
|
|
453
|
+
`# Run report: ${manifest.program.name} (${manifest.program.id})`,
|
|
454
|
+
"",
|
|
455
|
+
`_${at.toISOString()}_`,
|
|
456
|
+
"",
|
|
457
|
+
`**Outcome: ${built} of ${results.length} workstreams built.**`,
|
|
458
|
+
"",
|
|
459
|
+
];
|
|
460
|
+
if (escalations.length > 0) {
|
|
461
|
+
lines.push("## Needs your attention", "", "The decider reviewed these choices and believes you might decide", "differently. Each is anchored to the commit before it was made:", "");
|
|
462
|
+
for (const record of escalations) {
|
|
463
|
+
lines.push(`### ${record.decision.title} (${record.id})`, "", `- **Workstream:** ${record.workstream}`, `- **Chosen:** ${record.decision.chosen}`, `- **Decider says:** ${record.reviewRationale ?? "(no rationale recorded)"}`, ...(record.baseCommit
|
|
464
|
+
? [`- **To revisit:** roll back to \`${record.baseCommit}\` and re-run.`]
|
|
465
|
+
: []), "");
|
|
466
|
+
}
|
|
467
|
+
}
|
|
468
|
+
const failures = results.filter((result) => result.outcome.status === "failed" || result.outcome.status === "parked");
|
|
469
|
+
if (failures.length > 0) {
|
|
470
|
+
lines.push("## Not built", "");
|
|
471
|
+
for (const result of failures) {
|
|
472
|
+
const reason = result.outcome.status === "failed" || result.outcome.status === "parked"
|
|
473
|
+
? result.outcome.reason
|
|
474
|
+
: "";
|
|
475
|
+
lines.push(`### ${result.id} ${result.name} — ${result.outcome.status}`, "", reason, "", `Retry after fixing: \`npx --yes @wildorder/nightshift run ${manifest.program.id}\``, "(completed workstreams are skipped automatically).", "");
|
|
476
|
+
}
|
|
477
|
+
}
|
|
478
|
+
lines.push("## Workstreams", "");
|
|
479
|
+
for (const result of results) {
|
|
480
|
+
lines.push(`- **${result.id} ${result.name}** — ${result.outcome.status}`);
|
|
481
|
+
if (result.summary) {
|
|
482
|
+
lines.push(` - ${result.summary.replace(/\s+/gu, " ").trim()}`);
|
|
483
|
+
}
|
|
484
|
+
}
|
|
485
|
+
lines.push("");
|
|
486
|
+
if (decisions.length > 0) {
|
|
487
|
+
lines.push("## Decisions made along the way", "", "Every judgment call an agent surfaced, with its review status.", "Anything here can be revisited: roll back to the anchor commit and", "re-run, or just say which option you want changed.", "");
|
|
488
|
+
for (const record of decisions) {
|
|
489
|
+
const alternatives = record.decision.options
|
|
490
|
+
.filter((option) => option.label !== record.decision.chosen)
|
|
491
|
+
.map((option) => option.label)
|
|
492
|
+
.join(", ");
|
|
493
|
+
lines.push(`### ${record.decision.title} (${record.id}) — ${record.status}`, "", `- **Workstream:** ${record.workstream}${record.oneWay ? " · **one-way door**" : ""}`, `- **Context:** ${record.decision.context}`, `- **Chosen:** ${record.decision.chosen} — ${record.decision.rationale}`, `- **Alternatives:** ${alternatives === "" ? "(none listed)" : alternatives}`, ...(record.reviewRationale
|
|
494
|
+
? [`- **Decider:** ${record.reviewRationale}`]
|
|
495
|
+
: []), ...(record.baseCommit
|
|
496
|
+
? [`- **Anchor commit:** \`${record.baseCommit}\``]
|
|
497
|
+
: []), "");
|
|
498
|
+
}
|
|
499
|
+
}
|
|
500
|
+
else {
|
|
501
|
+
lines.push("## Decisions made along the way", "", "None surfaced.", "");
|
|
502
|
+
}
|
|
503
|
+
const decisionErrors = results.flatMap((result) => result.decisionErrors);
|
|
504
|
+
if (decisionErrors.length > 0) {
|
|
505
|
+
lines.push("## Decision blocks the runner could not read", "", ...decisionErrors.map((error) => `- ${error}`), "");
|
|
506
|
+
}
|
|
507
|
+
return lines.join("\n");
|
|
508
|
+
}
|
|
509
|
+
//# sourceMappingURL=run-program.js.map
|