@wildorder/nightshift 0.3.1 → 0.5.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 +48 -1
- package/dist/agent-runner.d.ts +18 -0
- package/dist/agent-runner.d.ts.map +1 -1
- package/dist/agent-runner.js +26 -0
- package/dist/agent-runner.js.map +1 -1
- package/dist/author.d.ts +64 -0
- package/dist/author.d.ts.map +1 -0
- package/dist/author.js +627 -0
- package/dist/author.js.map +1 -0
- package/dist/cli.js +110 -1
- package/dist/cli.js.map +1 -1
- package/dist/config.d.ts +14 -1
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +7 -1
- package/dist/config.js.map +1 -1
- package/dist/decide.d.ts +49 -0
- package/dist/decide.d.ts.map +1 -0
- package/dist/decide.js +178 -0
- package/dist/decide.js.map +1 -0
- package/dist/decider-review.d.ts +21 -0
- package/dist/decider-review.d.ts.map +1 -0
- package/dist/decider-review.js +98 -0
- package/dist/decider-review.js.map +1 -0
- package/dist/findings.d.ts +3 -21
- package/dist/findings.d.ts.map +1 -1
- package/dist/findings.js +0 -7
- package/dist/findings.js.map +1 -1
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -1
- package/dist/manifest.d.ts +2 -0
- package/dist/manifest.d.ts.map +1 -1
- package/dist/manifest.js +2 -0
- package/dist/manifest.js.map +1 -1
- package/dist/review-pass.d.ts +64 -0
- package/dist/review-pass.d.ts.map +1 -0
- package/dist/review-pass.js +370 -0
- package/dist/review-pass.js.map +1 -0
- package/dist/run-program.d.ts +20 -0
- package/dist/run-program.d.ts.map +1 -1
- package/dist/run-program.js +445 -131
- package/dist/run-program.js.map +1 -1
- package/package.json +2 -2
package/dist/author.js
ADDED
|
@@ -0,0 +1,627 @@
|
|
|
1
|
+
import { readFile, writeFile } from "node:fs/promises";
|
|
2
|
+
import { join, resolve } from "node:path";
|
|
3
|
+
import { defaultAgentRunner, describeAgent, invokeAgent, resolveAuthorAgent, resolveDeciderAgent, resolveReviewerAgent, } from "./agent-runner.js";
|
|
4
|
+
import { resolveSummary, summaryContract } from "./agent-summary.js";
|
|
5
|
+
import { decisionContract, decisionFingerprint, extractDecisions, } from "./decision.js";
|
|
6
|
+
import { appendLedgerEvents } from "./decision-ledger.js";
|
|
7
|
+
import { reviewDecisions } from "./decider-review.js";
|
|
8
|
+
import { findCycles, topologicalLevels } from "./graph.js";
|
|
9
|
+
import { loadManifest, saveManifest, } from "./manifest.js";
|
|
10
|
+
import { extractFindings, findingsContract, findingsToLedgerEvents, reviewerAbsentOutcome, runReviewPass, } from "./review-pass.js";
|
|
11
|
+
import { defaultGitOps, downstreamCone } from "./run-program.js";
|
|
12
|
+
/**
|
|
13
|
+
* The authoring stage: for every workstream whose spec does not exist, a
|
|
14
|
+
* clean agent writes it — human-first, grounded in the repository,
|
|
15
|
+
* accounting for the manifest's success criteria — before the build stage
|
|
16
|
+
* runs. Decisions authors surface flow through the same ledger and decider
|
|
17
|
+
* review as build decisions, and dependencies an author discovers merge into
|
|
18
|
+
* the manifest rather than stopping the run. Only an unorderable graph (a
|
|
19
|
+
* merge that creates a cycle) terminates it.
|
|
20
|
+
*/
|
|
21
|
+
/** Total character budget for dependency specs included in one brief. */
|
|
22
|
+
const DEPENDENCY_SPEC_BUDGET = 100_000;
|
|
23
|
+
/** A finished spec's content, or undefined when missing or whitespace-only. */
|
|
24
|
+
async function readFinishedSpec(root, workstream) {
|
|
25
|
+
try {
|
|
26
|
+
const content = await readFile(join(root, workstream.taskFile), "utf8");
|
|
27
|
+
return content.trim() === "" ? undefined : content;
|
|
28
|
+
}
|
|
29
|
+
catch {
|
|
30
|
+
return undefined;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
async function programDocumentSection(root, manifest) {
|
|
34
|
+
const relPath = join("docs", "programs", `${manifest.program.id}-program.md`);
|
|
35
|
+
let content;
|
|
36
|
+
try {
|
|
37
|
+
content = await readFile(join(root, relPath), "utf8");
|
|
38
|
+
}
|
|
39
|
+
catch {
|
|
40
|
+
return [
|
|
41
|
+
"## Program document",
|
|
42
|
+
"",
|
|
43
|
+
`No program document exists at ${relPath.replaceAll("\\", "/")}.`,
|
|
44
|
+
"",
|
|
45
|
+
];
|
|
46
|
+
}
|
|
47
|
+
return ["## Program document", "", content.trim(), ""];
|
|
48
|
+
}
|
|
49
|
+
function successCriteriaSection(manifest) {
|
|
50
|
+
if (manifest.successCriteria.length === 0) {
|
|
51
|
+
return ["## Success criteria", "", "None recorded in the manifest.", ""];
|
|
52
|
+
}
|
|
53
|
+
const lines = [
|
|
54
|
+
"## Success criteria",
|
|
55
|
+
"",
|
|
56
|
+
"Account in the spec for every criterion relevant to this workstream's",
|
|
57
|
+
"scope, referring to each by its id below. This list is canonical in the",
|
|
58
|
+
"manifest — refer to ids in the spec, never restate the text as a second",
|
|
59
|
+
"copy.",
|
|
60
|
+
"",
|
|
61
|
+
];
|
|
62
|
+
for (const criterion of manifest.successCriteria) {
|
|
63
|
+
lines.push(`- **${criterion.id}**: ${criterion.description}`);
|
|
64
|
+
}
|
|
65
|
+
lines.push("");
|
|
66
|
+
return lines;
|
|
67
|
+
}
|
|
68
|
+
function scopeSection(workstream) {
|
|
69
|
+
const scope = workstream.scope;
|
|
70
|
+
if (!scope)
|
|
71
|
+
return ["## Scope", "", "No scope recorded in the manifest.", ""];
|
|
72
|
+
const lines = ["## Scope", "", scope.summary, ""];
|
|
73
|
+
if (scope.includes.length > 0) {
|
|
74
|
+
lines.push("Includes:", "", ...scope.includes.map((entry) => `- ${entry}`), "");
|
|
75
|
+
}
|
|
76
|
+
if (scope.excludes.length > 0) {
|
|
77
|
+
lines.push("Excludes:", "", ...scope.excludes.map((entry) => `- ${entry}`), "");
|
|
78
|
+
}
|
|
79
|
+
return lines;
|
|
80
|
+
}
|
|
81
|
+
function rosterSection(manifest) {
|
|
82
|
+
return [
|
|
83
|
+
"## Roster",
|
|
84
|
+
"",
|
|
85
|
+
"Every workstream in the program, so you know what exists and never",
|
|
86
|
+
"write a spec that quietly absorbs a neighbor's job — it says what",
|
|
87
|
+
"exists, not how it works:",
|
|
88
|
+
"",
|
|
89
|
+
...manifest.workstreams.map((entry) => `- ${entry.id} ${entry.name}: ${entry.scope?.summary ?? entry.name}`),
|
|
90
|
+
"",
|
|
91
|
+
];
|
|
92
|
+
}
|
|
93
|
+
async function dependencySpecsSection(root, workstream, rosterById) {
|
|
94
|
+
if (workstream.dependencies.length === 0) {
|
|
95
|
+
return {
|
|
96
|
+
section: ["## Dependency specs", "", "No dependencies declared.", ""],
|
|
97
|
+
demoted: [],
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
const entries = await Promise.all(workstream.dependencies
|
|
101
|
+
.map((id) => rosterById.get(id))
|
|
102
|
+
.filter((entry) => entry !== undefined)
|
|
103
|
+
.map(async (entry) => ({
|
|
104
|
+
entry,
|
|
105
|
+
content: await readFinishedSpec(root, entry),
|
|
106
|
+
})));
|
|
107
|
+
let total = entries.reduce((sum, e) => sum + (e.content?.length ?? 0), 0);
|
|
108
|
+
const demoted = new Set();
|
|
109
|
+
const bySizeDesc = entries
|
|
110
|
+
.filter((e) => e.content !== undefined)
|
|
111
|
+
.sort((a, b) => (b.content?.length ?? 0) - (a.content?.length ?? 0));
|
|
112
|
+
for (const e of bySizeDesc) {
|
|
113
|
+
if (total <= DEPENDENCY_SPEC_BUDGET)
|
|
114
|
+
break;
|
|
115
|
+
demoted.add(e.entry.id);
|
|
116
|
+
total -= e.content?.length ?? 0;
|
|
117
|
+
}
|
|
118
|
+
const lines = ["## Dependency specs", ""];
|
|
119
|
+
for (const { entry, content } of entries) {
|
|
120
|
+
const scopeSummary = entry.scope?.summary ?? entry.name;
|
|
121
|
+
if (content === undefined) {
|
|
122
|
+
lines.push(`- ${entry.id} ${entry.name}: ${scopeSummary} — no finished spec yet.`);
|
|
123
|
+
continue;
|
|
124
|
+
}
|
|
125
|
+
if (demoted.has(entry.id)) {
|
|
126
|
+
lines.push(`- ${entry.id} ${entry.name}: ${scopeSummary} — its spec was too large ` +
|
|
127
|
+
"to include in full; ask for what you need in your dependencies " +
|
|
128
|
+
"declaration rather than guessing.");
|
|
129
|
+
continue;
|
|
130
|
+
}
|
|
131
|
+
lines.push(`### ${entry.id} ${entry.name}`, "", content.trim(), "");
|
|
132
|
+
}
|
|
133
|
+
lines.push("");
|
|
134
|
+
return { section: lines, demoted: [...demoted] };
|
|
135
|
+
}
|
|
136
|
+
const SPEC_CONTRACT = [
|
|
137
|
+
"## Write a spec for a human",
|
|
138
|
+
"",
|
|
139
|
+
"Write a narrative document for a human reader first — what this",
|
|
140
|
+
"workstream is, why it exists, how it fits the program, and the tricky",
|
|
141
|
+
"parts spelled out plainly. A suggested skeleton, offered as a",
|
|
142
|
+
"convenience and not a contract — use these headings, different ones, or",
|
|
143
|
+
"none at all, whatever serves the reader best:",
|
|
144
|
+
"",
|
|
145
|
+
"- Objective and context",
|
|
146
|
+
"- Design",
|
|
147
|
+
"- Files to create or modify",
|
|
148
|
+
"- Testing",
|
|
149
|
+
"- Definition of done",
|
|
150
|
+
"",
|
|
151
|
+
].join("\n");
|
|
152
|
+
const GROUNDING_CONTRACT = [
|
|
153
|
+
"## Ground the spec in the repository",
|
|
154
|
+
"",
|
|
155
|
+
"Explore the actual codebase before writing — entry points, signatures,",
|
|
156
|
+
"existing patterns — so the spec checks the plan's assumptions instead of",
|
|
157
|
+
"inheriting them unexamined.",
|
|
158
|
+
"",
|
|
159
|
+
].join("\n");
|
|
160
|
+
const DEPENDENCIES_CONTRACT = `
|
|
161
|
+
## Dependencies you discover (when you find one)
|
|
162
|
+
|
|
163
|
+
While grounding this spec in the repository you may find that this
|
|
164
|
+
workstream actually consumes another workstream's output, beyond what the
|
|
165
|
+
roster above already declares as a dependency. Report every such id in one
|
|
166
|
+
fenced block, anywhere in your reply before the summary:
|
|
167
|
+
|
|
168
|
+
\`\`\`dependencies
|
|
169
|
+
["WS-02", "WS-05"]
|
|
170
|
+
\`\`\`
|
|
171
|
+
|
|
172
|
+
A JSON array of workstream ids this spec depends on. Use only ids that
|
|
173
|
+
already appear in the roster — never invent a new workstream. Omit the
|
|
174
|
+
block entirely when you have nothing to add.
|
|
175
|
+
`.trim();
|
|
176
|
+
function dependenciesContract() {
|
|
177
|
+
return DEPENDENCIES_CONTRACT;
|
|
178
|
+
}
|
|
179
|
+
async function authorBrief(root, manifest, workstream, rosterById, reauthorNote) {
|
|
180
|
+
const programDoc = await programDocumentSection(root, manifest);
|
|
181
|
+
const deps = await dependencySpecsSection(root, workstream, rosterById);
|
|
182
|
+
const brief = [
|
|
183
|
+
`# Workstream ${workstream.id}: ${workstream.name}`,
|
|
184
|
+
"",
|
|
185
|
+
`Program: ${manifest.program.id} — ${manifest.program.name}`,
|
|
186
|
+
"",
|
|
187
|
+
"Write this workstream's specification document — the narrative file a",
|
|
188
|
+
"human and a later implementing agent will both read to build it.",
|
|
189
|
+
"",
|
|
190
|
+
...programDoc,
|
|
191
|
+
...successCriteriaSection(manifest),
|
|
192
|
+
...scopeSection(workstream),
|
|
193
|
+
...rosterSection(manifest),
|
|
194
|
+
...deps.section,
|
|
195
|
+
...(reauthorNote ? [reauthorNote, ""] : []),
|
|
196
|
+
SPEC_CONTRACT,
|
|
197
|
+
GROUNDING_CONTRACT,
|
|
198
|
+
dependenciesContract(),
|
|
199
|
+
"",
|
|
200
|
+
"## Rules",
|
|
201
|
+
"",
|
|
202
|
+
"- Write exactly one file: this workstream's taskFile (create parent",
|
|
203
|
+
" directories as needed). Do not write or edit any other file.",
|
|
204
|
+
"- Never commit; the runner owns commits.",
|
|
205
|
+
"",
|
|
206
|
+
decisionContract(),
|
|
207
|
+
"",
|
|
208
|
+
summaryContract(),
|
|
209
|
+
].join("\n");
|
|
210
|
+
return { brief, demoted: deps.demoted };
|
|
211
|
+
}
|
|
212
|
+
const SPEC_CRITIQUE_FRAMING = [
|
|
213
|
+
"## Critique this spec",
|
|
214
|
+
"",
|
|
215
|
+
"Another agent authored the spec below for this workstream. Read it the",
|
|
216
|
+
"way a skeptical reviewer would before it ships: report what is wrong with",
|
|
217
|
+
"it, not what is right. In particular, consider —",
|
|
218
|
+
"",
|
|
219
|
+
"- **Coverage:** does the spec account for every success criterion in this",
|
|
220
|
+
" workstream's scope, by id? A criterion the spec never mentions is a",
|
|
221
|
+
" finding.",
|
|
222
|
+
"- **Consistency:** does it contradict the program document, the",
|
|
223
|
+
" manifest, or the roster above?",
|
|
224
|
+
"- **Scope creep:** does it quietly absorb a neighboring workstream's job,",
|
|
225
|
+
" per the roster?",
|
|
226
|
+
"- **Buildability:** are its interfaces and design internally consistent",
|
|
227
|
+
" and actually buildable, not just narratively plausible?",
|
|
228
|
+
"- **Legibility:** is this a spec a human and a later implementing agent",
|
|
229
|
+
" can both follow?",
|
|
230
|
+
"",
|
|
231
|
+
"A clean spec is a fine answer — if you have no objection, say so and emit",
|
|
232
|
+
"an empty findings array. Severity is a routing hint for where a finding",
|
|
233
|
+
"goes, never a verdict on the spec as a whole. A genuinely structural",
|
|
234
|
+
"objection — this workstream should not exist in this shape — is a",
|
|
235
|
+
"**blocker**; it routes to a decision a human re-plans from, not a gate",
|
|
236
|
+
"that stops anything here.",
|
|
237
|
+
"",
|
|
238
|
+
"Always end your reply with a findings block, using an empty array `[]`",
|
|
239
|
+
"when you have no objection, so a clean read and a skipped read stay",
|
|
240
|
+
"distinguishable.",
|
|
241
|
+
"",
|
|
242
|
+
].join("\n");
|
|
243
|
+
function specCritiqueReviewerBrief(root, manifest, workstream, rosterById, spec, priorOpen) {
|
|
244
|
+
return (async () => {
|
|
245
|
+
const programDoc = await programDocumentSection(root, manifest);
|
|
246
|
+
const priorSection = priorOpen.length > 0
|
|
247
|
+
? [
|
|
248
|
+
"## Findings from the last round",
|
|
249
|
+
"",
|
|
250
|
+
"Last round, another reviewer raised the following; check whether",
|
|
251
|
+
"the revised spec below addresses them:",
|
|
252
|
+
"",
|
|
253
|
+
...priorOpen.map((finding) => `- **${finding.severity}** (${finding.category}) ${finding.subject}: ${finding.message}`),
|
|
254
|
+
"",
|
|
255
|
+
]
|
|
256
|
+
: [];
|
|
257
|
+
return [
|
|
258
|
+
`# Critique the spec for ${workstream.id}: ${workstream.name}`,
|
|
259
|
+
"",
|
|
260
|
+
`Program: ${manifest.program.id} — ${manifest.program.name}`,
|
|
261
|
+
"",
|
|
262
|
+
...programDoc,
|
|
263
|
+
...successCriteriaSection(manifest),
|
|
264
|
+
...scopeSection(workstream),
|
|
265
|
+
...rosterSection(manifest),
|
|
266
|
+
"## The authored spec",
|
|
267
|
+
"",
|
|
268
|
+
spec,
|
|
269
|
+
"",
|
|
270
|
+
...priorSection,
|
|
271
|
+
SPEC_CRITIQUE_FRAMING,
|
|
272
|
+
findingsContract(),
|
|
273
|
+
].join("\n");
|
|
274
|
+
})();
|
|
275
|
+
}
|
|
276
|
+
function specCritiqueWriterBrief(workstream, spec, findings) {
|
|
277
|
+
const findingsList = findings.length === 0
|
|
278
|
+
? ["(no findings — this should not happen; treat as a clean read.)"]
|
|
279
|
+
: findings.map((finding) => {
|
|
280
|
+
const evidence = finding.evidence
|
|
281
|
+
.map((entry) => {
|
|
282
|
+
if (entry.kind === "location") {
|
|
283
|
+
return `${entry.file}:${entry.startLine}${entry.excerpt ? ` — ${entry.excerpt}` : ""}`;
|
|
284
|
+
}
|
|
285
|
+
if (entry.kind === "concern") {
|
|
286
|
+
return entry.detail ? `${entry.named} — ${entry.detail}` : entry.named;
|
|
287
|
+
}
|
|
288
|
+
return `${entry.metric}: ${entry.value}`;
|
|
289
|
+
})
|
|
290
|
+
.join("; ");
|
|
291
|
+
return [
|
|
292
|
+
`- **${finding.severity}** (${finding.category}) ${finding.subject}: ${finding.message}`,
|
|
293
|
+
evidence ? ` Evidence: ${evidence}` : undefined,
|
|
294
|
+
]
|
|
295
|
+
.filter((line) => line !== undefined)
|
|
296
|
+
.join("\n");
|
|
297
|
+
});
|
|
298
|
+
return [
|
|
299
|
+
`# Your spec for ${workstream.id}: ${workstream.name} was reviewed`,
|
|
300
|
+
"",
|
|
301
|
+
"An independent reviewer read the spec you wrote and raised the",
|
|
302
|
+
"following:",
|
|
303
|
+
"",
|
|
304
|
+
...findingsList,
|
|
305
|
+
"",
|
|
306
|
+
"Here is the spec as it currently stands:",
|
|
307
|
+
"",
|
|
308
|
+
"## Current spec",
|
|
309
|
+
"",
|
|
310
|
+
spec,
|
|
311
|
+
"",
|
|
312
|
+
`Revise ${workstream.taskFile} for what you agree with. State plainly`,
|
|
313
|
+
"what you decline and why — declines are recorded and reported, never",
|
|
314
|
+
"argued with. Write the revised spec to the same file, then reply in",
|
|
315
|
+
"prose (not a block): what you fixed, what you declined, and why.",
|
|
316
|
+
"",
|
|
317
|
+
summaryContract(),
|
|
318
|
+
].join("\n");
|
|
319
|
+
}
|
|
320
|
+
/** Presence of at least one fenced findings block, distinguishing "clean" from "no read at all". */
|
|
321
|
+
function hasFindingsBlock(output) {
|
|
322
|
+
return /```findings/u.test(output);
|
|
323
|
+
}
|
|
324
|
+
async function runSpecCritique(options) {
|
|
325
|
+
const reviewer = resolveReviewerAgent(options.config);
|
|
326
|
+
if (!reviewer)
|
|
327
|
+
return reviewerAbsentOutcome();
|
|
328
|
+
const review = async (_round, priorOpen) => {
|
|
329
|
+
const currentSpec = (await readFinishedSpec(options.root, options.workstream)) ?? options.spec;
|
|
330
|
+
const brief = await specCritiqueReviewerBrief(options.root, options.manifest, options.workstream, options.rosterById, currentSpec, priorOpen);
|
|
331
|
+
const invocation = await invokeAgent(options.agentRunner, reviewer, brief, options.root);
|
|
332
|
+
const parsed = extractFindings(invocation.output);
|
|
333
|
+
const ran = invocation.exitCode === 0 && hasFindingsBlock(invocation.output);
|
|
334
|
+
return { findings: parsed.findings, errors: parsed.errors, ran };
|
|
335
|
+
};
|
|
336
|
+
const respond = async (_round, findings) => {
|
|
337
|
+
const currentSpec = (await readFinishedSpec(options.root, options.workstream)) ?? options.spec;
|
|
338
|
+
const brief = specCritiqueWriterBrief(options.workstream, currentSpec, findings);
|
|
339
|
+
const invocation = await invokeAgent(options.agentRunner, options.author, brief, options.root);
|
|
340
|
+
return { note: resolveSummary(invocation.output).text };
|
|
341
|
+
};
|
|
342
|
+
return runReviewPass({ review, respond });
|
|
343
|
+
}
|
|
344
|
+
function mergeDependencies(workstream, rosterIds, declaredIds) {
|
|
345
|
+
const merged = [];
|
|
346
|
+
const unknown = [];
|
|
347
|
+
for (const id of declaredIds) {
|
|
348
|
+
if (!rosterIds.has(id)) {
|
|
349
|
+
unknown.push(id);
|
|
350
|
+
continue;
|
|
351
|
+
}
|
|
352
|
+
if (workstream.dependencies.includes(id))
|
|
353
|
+
continue;
|
|
354
|
+
workstream.dependencies.push(id);
|
|
355
|
+
merged.push(id);
|
|
356
|
+
}
|
|
357
|
+
return { merged, unknown };
|
|
358
|
+
}
|
|
359
|
+
const DEPENDENCIES_BLOCK_PATTERN = /```dependencies[^\S\r\n]*\r?\n([\s\S]*?)```/gu;
|
|
360
|
+
/** The last ```dependencies block in an agent's reply; tolerates garbage. */
|
|
361
|
+
function extractDependenciesDeclaration(output) {
|
|
362
|
+
const matches = [...output.matchAll(DEPENDENCIES_BLOCK_PATTERN)];
|
|
363
|
+
if (matches.length === 0)
|
|
364
|
+
return { ids: [] };
|
|
365
|
+
const body = matches[matches.length - 1]?.[1]?.trim() ?? "";
|
|
366
|
+
if (body === "")
|
|
367
|
+
return { ids: [] };
|
|
368
|
+
let json;
|
|
369
|
+
try {
|
|
370
|
+
json = JSON.parse(body);
|
|
371
|
+
}
|
|
372
|
+
catch (error) {
|
|
373
|
+
return {
|
|
374
|
+
ids: [],
|
|
375
|
+
error: `dependencies block is not valid JSON: ${error.message}`,
|
|
376
|
+
};
|
|
377
|
+
}
|
|
378
|
+
if (!Array.isArray(json) || !json.every((item) => typeof item === "string")) {
|
|
379
|
+
return {
|
|
380
|
+
ids: [],
|
|
381
|
+
error: "dependencies block must be a JSON array of workstream id strings",
|
|
382
|
+
};
|
|
383
|
+
}
|
|
384
|
+
return { ids: json };
|
|
385
|
+
}
|
|
386
|
+
/**
|
|
387
|
+
* The authoring stage: writes every missing workstream spec, one clean agent
|
|
388
|
+
* at a time, in dependency-level order. Shaped like `runProgram` — plain
|
|
389
|
+
* inputs, injected boundaries, a structured result the CLI and `run` both
|
|
390
|
+
* consume.
|
|
391
|
+
*/
|
|
392
|
+
export async function authorProgram(options) {
|
|
393
|
+
const root = resolve(options.cwd);
|
|
394
|
+
const config = options.config;
|
|
395
|
+
const agentRunner = options.agentRunner ?? defaultAgentRunner;
|
|
396
|
+
const git = options.git ?? defaultGitOps;
|
|
397
|
+
const log = options.log ?? ((line) => console.log(line));
|
|
398
|
+
const now = options.now ?? (() => new Date());
|
|
399
|
+
const only = options.only;
|
|
400
|
+
const force = options.force === true;
|
|
401
|
+
const manifest = await loadManifest(root, options.programId);
|
|
402
|
+
const resolvedAuthor = resolveAuthorAgent(config);
|
|
403
|
+
if (!resolvedAuthor) {
|
|
404
|
+
throw new Error("No author agent configured, and no implementer to fall back to. Set " +
|
|
405
|
+
"the `authorAgent` or `agent` block in nightshift.config.json.");
|
|
406
|
+
}
|
|
407
|
+
const author = resolvedAuthor.agent;
|
|
408
|
+
const borrowedImplementer = resolvedAuthor.borrowedImplementer;
|
|
409
|
+
log(borrowedImplementer
|
|
410
|
+
? `author: ${describeAgent(author)} (borrowed from the implementer — ` +
|
|
411
|
+
"configure `authorAgent` for a dedicated model)"
|
|
412
|
+
: `author: ${describeAgent(author)}`);
|
|
413
|
+
const decider = resolveDeciderAgent(config);
|
|
414
|
+
const reviewer = resolveReviewerAgent(config);
|
|
415
|
+
log(reviewer
|
|
416
|
+
? `spec critique reviewer: ${describeAgent(reviewer)}`
|
|
417
|
+
: "spec critique reviewer: none configured — spec critique disabled");
|
|
418
|
+
const cycles = findCycles(manifest.workstreams);
|
|
419
|
+
if (cycles.length > 0) {
|
|
420
|
+
throw new Error(`Dependency cycle(s) in the manifest: ${cycles
|
|
421
|
+
.map((cycle) => cycle.join(" -> "))
|
|
422
|
+
.join("; ")}. Re-plan with /plan-program.`);
|
|
423
|
+
}
|
|
424
|
+
const isRepository = await git.isRepository(root);
|
|
425
|
+
if (!isRepository) {
|
|
426
|
+
log("warning: not a git repository — commits and decision anchors are unavailable");
|
|
427
|
+
}
|
|
428
|
+
const results = [];
|
|
429
|
+
const processed = new Set();
|
|
430
|
+
const blockedCone = new Set();
|
|
431
|
+
while (processed.size < manifest.workstreams.length) {
|
|
432
|
+
const remaining = manifest.workstreams.filter((w) => !processed.has(w.id));
|
|
433
|
+
const levels = topologicalLevels(remaining);
|
|
434
|
+
const next = levels[0]?.[0];
|
|
435
|
+
if (!next)
|
|
436
|
+
break;
|
|
437
|
+
processed.add(next.id);
|
|
438
|
+
results.push(await handle(next));
|
|
439
|
+
}
|
|
440
|
+
const complete = results.every((result) => result.outcome.status === "authored" || result.outcome.status === "kept");
|
|
441
|
+
return {
|
|
442
|
+
programId: options.programId,
|
|
443
|
+
complete,
|
|
444
|
+
results,
|
|
445
|
+
borrowedImplementer,
|
|
446
|
+
};
|
|
447
|
+
async function handle(workstream) {
|
|
448
|
+
const base = {
|
|
449
|
+
id: workstream.id,
|
|
450
|
+
name: workstream.name,
|
|
451
|
+
outcome: { status: "kept" },
|
|
452
|
+
decisionIds: [],
|
|
453
|
+
decisionErrors: [],
|
|
454
|
+
mergedDependencies: [],
|
|
455
|
+
unknownDependencyIds: [],
|
|
456
|
+
demotedDependencies: [],
|
|
457
|
+
reauthored: false,
|
|
458
|
+
};
|
|
459
|
+
if (blockedCone.has(workstream.id)) {
|
|
460
|
+
workstream.status = "parked";
|
|
461
|
+
await saveManifest(root, options.programId, manifest);
|
|
462
|
+
base.outcome = {
|
|
463
|
+
status: "parked",
|
|
464
|
+
reason: "an upstream dependency's authoring failed; parked, not attempted",
|
|
465
|
+
};
|
|
466
|
+
return base;
|
|
467
|
+
}
|
|
468
|
+
const existing = await readFinishedSpec(root, workstream);
|
|
469
|
+
const shouldAuthor = existing === undefined || (force && only !== undefined && only.includes(workstream.id));
|
|
470
|
+
if (!shouldAuthor)
|
|
471
|
+
return base;
|
|
472
|
+
log(`${workstream.id} ${workstream.name}: authoring`);
|
|
473
|
+
const rosterById = new Map(manifest.workstreams.map((w) => [w.id, w]));
|
|
474
|
+
const rosterIds = new Set(rosterById.keys());
|
|
475
|
+
const baseCommit = isRepository ? await git.currentCommit(root) : undefined;
|
|
476
|
+
const allDecisions = [];
|
|
477
|
+
const first = await authorBrief(root, manifest, workstream, rosterById);
|
|
478
|
+
base.demotedDependencies = first.demoted;
|
|
479
|
+
let invocation = await invokeAgent(agentRunner, author, first.brief, root);
|
|
480
|
+
base.summary = resolveSummary(invocation.output).text;
|
|
481
|
+
let parsed = extractDecisions(invocation.output);
|
|
482
|
+
base.decisionErrors.push(...parsed.errors);
|
|
483
|
+
allDecisions.push(...parsed.decisions);
|
|
484
|
+
await journalDecisions(workstream, parsed.decisions, baseCommit);
|
|
485
|
+
base.decisionIds.push(...parsed.decisions.map((decision) => decisionFingerprint(workstream.id, decision)));
|
|
486
|
+
const declaration = extractDependenciesDeclaration(invocation.output);
|
|
487
|
+
if (declaration.error)
|
|
488
|
+
log(`${workstream.id}: ${declaration.error}`);
|
|
489
|
+
const merge = mergeDependencies(workstream, rosterIds, declaration.ids);
|
|
490
|
+
base.unknownDependencyIds = merge.unknown;
|
|
491
|
+
if (merge.unknown.length > 0) {
|
|
492
|
+
log(`${workstream.id}: unknown dependency id(s) declared, ignored: ${merge.unknown.join(", ")}`);
|
|
493
|
+
}
|
|
494
|
+
if (merge.merged.length > 0) {
|
|
495
|
+
const originalDependencies = workstream.dependencies.filter((id) => !merge.merged.includes(id));
|
|
496
|
+
base.mergedDependencies = merge.merged;
|
|
497
|
+
await saveManifest(root, options.programId, manifest);
|
|
498
|
+
log(`${workstream.id}: merged new dependency edge(s): ${merge.merged.join(", ")}`);
|
|
499
|
+
const cyclesNow = findCycles(manifest.workstreams);
|
|
500
|
+
if (cyclesNow.length > 0) {
|
|
501
|
+
workstream.dependencies = originalDependencies;
|
|
502
|
+
await saveManifest(root, options.programId, manifest);
|
|
503
|
+
throw new Error(`Dependency cycle(s) created by a discovered edge from ${workstream.id}: ` +
|
|
504
|
+
`${cyclesNow.map((cycle) => cycle.join(" -> ")).join("; ")}. Re-plan with /plan-program.`);
|
|
505
|
+
}
|
|
506
|
+
const needsReauthor = [];
|
|
507
|
+
for (const id of merge.merged) {
|
|
508
|
+
const dep = rosterById.get(id);
|
|
509
|
+
if (!dep)
|
|
510
|
+
continue;
|
|
511
|
+
if ((await readFinishedSpec(root, dep)) !== undefined)
|
|
512
|
+
needsReauthor.push(id);
|
|
513
|
+
}
|
|
514
|
+
if (needsReauthor.length > 0) {
|
|
515
|
+
base.reauthored = true;
|
|
516
|
+
log(`${workstream.id}: re-authoring once with newly discovered dependency spec(s): ` +
|
|
517
|
+
needsReauthor.join(", "));
|
|
518
|
+
const note = [
|
|
519
|
+
"## You are being re-authored",
|
|
520
|
+
"",
|
|
521
|
+
"Your previous pass declared a new dependency whose finished spec is",
|
|
522
|
+
"now included below, in the dependency specs section. Revise your",
|
|
523
|
+
"spec to account for it. Any further dependency declaration in this",
|
|
524
|
+
"pass will be logged but not acted on — this workstream gets one",
|
|
525
|
+
"re-author pass.",
|
|
526
|
+
"",
|
|
527
|
+
].join("\n");
|
|
528
|
+
const second = await authorBrief(root, manifest, workstream, rosterById, note);
|
|
529
|
+
base.demotedDependencies = second.demoted;
|
|
530
|
+
invocation = await invokeAgent(agentRunner, author, second.brief, root);
|
|
531
|
+
base.summary = resolveSummary(invocation.output).text;
|
|
532
|
+
parsed = extractDecisions(invocation.output);
|
|
533
|
+
base.decisionErrors.push(...parsed.errors);
|
|
534
|
+
allDecisions.push(...parsed.decisions);
|
|
535
|
+
await journalDecisions(workstream, parsed.decisions, baseCommit);
|
|
536
|
+
base.decisionIds.push(...parsed.decisions.map((decision) => decisionFingerprint(workstream.id, decision)));
|
|
537
|
+
const secondDeclaration = extractDependenciesDeclaration(invocation.output);
|
|
538
|
+
if (secondDeclaration.ids.length > 0) {
|
|
539
|
+
log(`${workstream.id}: additional dependency declaration after the ` +
|
|
540
|
+
`re-author pass was not honored: ${secondDeclaration.ids.join(", ")}`);
|
|
541
|
+
}
|
|
542
|
+
}
|
|
543
|
+
}
|
|
544
|
+
const final = await readFinishedSpec(root, workstream);
|
|
545
|
+
if (final === undefined) {
|
|
546
|
+
workstream.status = "parked";
|
|
547
|
+
await saveManifest(root, options.programId, manifest);
|
|
548
|
+
for (const id of downstreamCone(manifest.workstreams, [workstream.id])) {
|
|
549
|
+
blockedCone.add(id);
|
|
550
|
+
}
|
|
551
|
+
base.outcome = {
|
|
552
|
+
status: "failed",
|
|
553
|
+
reason: `no spec was written to ${workstream.taskFile} (or it was left empty)`,
|
|
554
|
+
};
|
|
555
|
+
await reviewWorkstreamDecisions(workstream.id, allDecisions, baseCommit);
|
|
556
|
+
return base;
|
|
557
|
+
}
|
|
558
|
+
const critique = await runSpecCritique({
|
|
559
|
+
root,
|
|
560
|
+
manifest,
|
|
561
|
+
workstream,
|
|
562
|
+
rosterById,
|
|
563
|
+
spec: final,
|
|
564
|
+
config,
|
|
565
|
+
agentRunner,
|
|
566
|
+
author,
|
|
567
|
+
log,
|
|
568
|
+
});
|
|
569
|
+
base.specCritique = critique;
|
|
570
|
+
const postCritique = await readFinishedSpec(root, workstream);
|
|
571
|
+
if (postCritique === undefined) {
|
|
572
|
+
await writeFile(join(root, workstream.taskFile), final, "utf8");
|
|
573
|
+
log(`${workstream.id}: a critique round left the spec empty or missing; ` +
|
|
574
|
+
"the pre-critique spec was restored");
|
|
575
|
+
}
|
|
576
|
+
const critiqueEvents = findingsToLedgerEvents({
|
|
577
|
+
workstreamId: workstream.id,
|
|
578
|
+
findings: critique.open,
|
|
579
|
+
...(baseCommit === undefined ? {} : { baseCommit }),
|
|
580
|
+
now,
|
|
581
|
+
});
|
|
582
|
+
await appendLedgerEvents(root, options.programId, critiqueEvents);
|
|
583
|
+
for (const event of critiqueEvents) {
|
|
584
|
+
if (event.kind === "decision-recorded")
|
|
585
|
+
allDecisions.push(event.decision);
|
|
586
|
+
}
|
|
587
|
+
let commit;
|
|
588
|
+
if (isRepository) {
|
|
589
|
+
commit = await git.commitPaths(root, `nightshift(${options.programId}): author ${workstream.id} ${workstream.name}`, [workstream.taskFile, "docs/programs"]);
|
|
590
|
+
}
|
|
591
|
+
await reviewWorkstreamDecisions(workstream.id, allDecisions, baseCommit);
|
|
592
|
+
base.outcome = { status: "authored", ...(commit === undefined ? {} : { commit }) };
|
|
593
|
+
return base;
|
|
594
|
+
}
|
|
595
|
+
async function journalDecisions(workstream, decisions, baseCommit) {
|
|
596
|
+
const events = decisions.map((decision) => ({
|
|
597
|
+
kind: "decision-recorded",
|
|
598
|
+
at: now().toISOString(),
|
|
599
|
+
id: decisionFingerprint(workstream.id, decision),
|
|
600
|
+
workstream: workstream.id,
|
|
601
|
+
decision,
|
|
602
|
+
...(baseCommit === undefined ? {} : { baseCommit }),
|
|
603
|
+
decidedBy: "implementer",
|
|
604
|
+
}));
|
|
605
|
+
await appendLedgerEvents(root, options.programId, events);
|
|
606
|
+
for (const decision of decisions) {
|
|
607
|
+
log(`${workstream.id} decision: ${decision.title} -> ${decision.chosen}`);
|
|
608
|
+
}
|
|
609
|
+
}
|
|
610
|
+
function reviewWorkstreamDecisions(workstreamId, decisions, baseCommit) {
|
|
611
|
+
return reviewDecisions({
|
|
612
|
+
root,
|
|
613
|
+
programId: options.programId,
|
|
614
|
+
manifest,
|
|
615
|
+
workstreamId,
|
|
616
|
+
decisions,
|
|
617
|
+
baseCommit,
|
|
618
|
+
decider,
|
|
619
|
+
agentRunner,
|
|
620
|
+
git,
|
|
621
|
+
isRepository,
|
|
622
|
+
now,
|
|
623
|
+
log,
|
|
624
|
+
});
|
|
625
|
+
}
|
|
626
|
+
}
|
|
627
|
+
//# sourceMappingURL=author.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
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