ahead-pi 0.2.1 → 0.3.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 +17 -7
- package/dist/ahead_wasm.wasm +0 -0
- package/generated/corrective-debugging/ai-audit.md +39 -0
- package/generated/corrective-debugging/ai-review.md +46 -0
- package/generated/corrective-debugging/characterize.md +53 -0
- package/generated/corrective-debugging/conclude.md +59 -0
- package/generated/corrective-debugging/correction.md +53 -0
- package/generated/corrective-debugging/deploy.md +38 -0
- package/generated/corrective-debugging/human-review.md +45 -0
- package/generated/corrective-debugging/implement.md +42 -0
- package/generated/corrective-debugging/investigate.md +59 -0
- package/generated/corrective-debugging/manifest.json +30 -0
- package/generated/corrective-debugging/model.md +53 -0
- package/generated/corrective-debugging/outcome.md +38 -0
- package/generated/corrective-debugging/plan.md +53 -0
- package/generated/corrective-debugging/verify.md +47 -0
- package/generated/decision/compare.md +45 -0
- package/generated/decision/criteria.md +45 -0
- package/generated/decision/decide.md +45 -0
- package/generated/decision/frame.md +45 -0
- package/generated/decision/manifest.json +21 -0
- package/generated/decision/options.md +47 -0
- package/generated/decision/publish.md +38 -0
- package/generated/decision/research.md +45 -0
- package/generated/internal-improvement/ai-audit.md +39 -0
- package/generated/internal-improvement/ai-review.md +46 -0
- package/generated/internal-improvement/baseline.md +46 -0
- package/generated/internal-improvement/decision.md +45 -0
- package/generated/internal-improvement/deploy.md +38 -0
- package/generated/internal-improvement/human-review.md +45 -0
- package/generated/internal-improvement/implement.md +42 -0
- package/generated/internal-improvement/invariants.md +38 -0
- package/generated/internal-improvement/manifest.json +29 -0
- package/generated/internal-improvement/options.md +47 -0
- package/generated/internal-improvement/outcome.md +38 -0
- package/generated/internal-improvement/plan.md +53 -0
- package/generated/internal-improvement/target.md +45 -0
- package/generated/internal-improvement/verify.md +45 -0
- package/generated/investigation/bound.md +45 -0
- package/generated/investigation/conclude.md +45 -0
- package/generated/investigation/explore.md +60 -0
- package/generated/investigation/frame.md +45 -0
- package/generated/investigation/gather.md +45 -0
- package/generated/investigation/manifest.json +21 -0
- package/generated/investigation/synthesize.md +51 -0
- package/generated/operational-stabilization/assess.md +46 -0
- package/generated/operational-stabilization/execute-observe.md +45 -0
- package/generated/operational-stabilization/manifest.json +19 -0
- package/generated/operational-stabilization/monitor.md +45 -0
- package/generated/operational-stabilization/outcome.md +38 -0
- package/generated/operational-stabilization/respond.md +40 -0
- package/generated/operational-stabilization/verify-recovery.md +45 -0
- package/generated/product-change/ai-audit.md +7 -4
- package/generated/product-change/ai-review.md +15 -5
- package/generated/product-change/decision.md +11 -2
- package/generated/product-change/define.md +4 -2
- package/generated/product-change/deploy.md +4 -2
- package/generated/product-change/human-review.md +11 -2
- package/generated/product-change/implement.md +4 -2
- package/generated/product-change/manifest.json +8 -3
- package/generated/product-change/options.md +11 -2
- package/generated/product-change/outcome.md +4 -2
- package/generated/product-change/plan.md +17 -2
- package/generated/product-change/questions.md +17 -2
- package/generated/product-change/research.md +11 -2
- package/generated/product-change/verify.md +4 -2
- package/generated/recommended-skills.json +24 -0
- package/generated/reference/docs/design/adapted-skill-guidance.md +27 -0
- package/generated/reference/docs/design/executable-workflows.md +20 -8
- package/generated/reference/docs/design/instruction-authoring.md +28 -0
- package/generated/reference/docs/design/review-workbench.md +37 -0
- package/generated/reference/docs/recommended-skills.md +19 -0
- package/generated/reference/docs/workflows/README.md +3 -3
- package/generated/reference/docs/workflows/corrective-debugging.md +37 -19
- package/generated/reference/docs/workflows/decision.md +2 -2
- package/generated/reference/docs/workflows/internal-improvement.md +35 -23
- package/generated/reference/docs/workflows/investigation.md +3 -1
- package/generated/reference/docs/workflows/operational-stabilization.md +14 -12
- package/generated/reference/docs/workflows/product-change.md +14 -3
- package/generated/reference/index.json +131 -13
- package/package.json +34 -25
- package/src/engine.ts +26 -7
- package/src/flow-guides.ts +168 -0
- package/src/guidance.ts +218 -72
- package/src/index.ts +603 -175
- package/src/reference-viewer.ts +20 -18
- package/src/reference.ts +65 -14
- package/src/review.ts +360 -0
- package/src/skills.ts +133 -0
- package/src/storage.ts +77 -13
- package/src/types.ts +1 -0
package/src/guidance.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { ArtifactState, Run, RunState, WorkflowDefinition } from "./types.js";
|
|
2
|
+
import { flowGuides } from "./flow-guides.ts";
|
|
2
3
|
|
|
3
4
|
export interface PhaseGuide {
|
|
4
5
|
objective: string;
|
|
@@ -11,7 +12,8 @@ export interface PhaseGuide {
|
|
|
11
12
|
const guides: Record<string, PhaseGuide> = {
|
|
12
13
|
define: {
|
|
13
14
|
objective: "Agree on the problem and the observable outcome before solution work begins.",
|
|
14
|
-
human:
|
|
15
|
+
human:
|
|
16
|
+
"Describe the users, current problem, desired outcome, scope, constraints, and success signals.",
|
|
15
17
|
ai: "Explain the prompts. After your first statement, clarify ambiguity and expose assumptions without redefining the problem.",
|
|
16
18
|
artifactPrompts: {
|
|
17
19
|
problem: [
|
|
@@ -25,7 +27,8 @@ const guides: Record<string, PhaseGuide> = {
|
|
|
25
27
|
},
|
|
26
28
|
research: {
|
|
27
29
|
objective: "Build enough evidence to understand the problem before choosing a solution.",
|
|
28
|
-
human:
|
|
30
|
+
human:
|
|
31
|
+
"Set the research boundary, judge source relevance, and identify what evidence is material.",
|
|
29
32
|
ai: "Inspect authorized sources, organize evidence, surface contradictions, and state confidence and gaps.",
|
|
30
33
|
artifactPrompts: {
|
|
31
34
|
research: [
|
|
@@ -38,7 +41,8 @@ const guides: Record<string, PhaseGuide> = {
|
|
|
38
41
|
},
|
|
39
42
|
questions: {
|
|
40
43
|
objective: "Dispose the unknowns that could materially change the decision or plan.",
|
|
41
|
-
human:
|
|
44
|
+
human:
|
|
45
|
+
"Decide which unknowns must be answered and which uncertainty can be accepted explicitly.",
|
|
42
46
|
ai: "Challenge gaps, perform authorized follow-up research, and distinguish evidence from inference.",
|
|
43
47
|
artifactPrompts: {
|
|
44
48
|
unknowns: [
|
|
@@ -54,7 +58,8 @@ const guides: Record<string, PhaseGuide> = {
|
|
|
54
58
|
},
|
|
55
59
|
options: {
|
|
56
60
|
objective: "Understand viable approaches and tradeoffs before committing to one.",
|
|
57
|
-
human:
|
|
61
|
+
human:
|
|
62
|
+
"Produce the first option, then evaluate alternatives and tradeoffs in the system's real context.",
|
|
58
63
|
ai: "After the human first pass, challenge assumptions and add materially different alternatives.",
|
|
59
64
|
artifactPrompts: {
|
|
60
65
|
"human-option": [
|
|
@@ -75,7 +80,8 @@ const guides: Record<string, PhaseGuide> = {
|
|
|
75
80
|
},
|
|
76
81
|
decision: {
|
|
77
82
|
objective: "Make an accountable and explainable choice.",
|
|
78
|
-
human:
|
|
83
|
+
human:
|
|
84
|
+
"Choose the approach and own its rationale, tradeoffs, remaining uncertainty, and reversibility.",
|
|
79
85
|
ai: "Test the recorded decision for contradictions, weak evidence, and hidden consequences.",
|
|
80
86
|
artifactPrompts: {
|
|
81
87
|
decision: [
|
|
@@ -88,7 +94,8 @@ const guides: Record<string, PhaseGuide> = {
|
|
|
88
94
|
},
|
|
89
95
|
plan: {
|
|
90
96
|
objective: "Create an implementable plan with verification, rollout, and recovery.",
|
|
91
|
-
human:
|
|
97
|
+
human:
|
|
98
|
+
"Write the first-pass sequence and approve the final plan after challenges are resolved.",
|
|
92
99
|
ai: "After the human first pass, identify missing dependencies, tests, edge cases, rollout evidence, recovery, and decision points.",
|
|
93
100
|
artifactPrompts: {
|
|
94
101
|
"first-pass-plan": [
|
|
@@ -110,7 +117,8 @@ const guides: Record<string, PhaseGuide> = {
|
|
|
110
117
|
},
|
|
111
118
|
implement: {
|
|
112
119
|
objective: "Produce a change the engineer understands and can defend.",
|
|
113
|
-
human:
|
|
120
|
+
human:
|
|
121
|
+
"Make the first attempt, ask questions freely, own the implementation, understand every lasting change, run the planned checks, and record deviations.",
|
|
114
122
|
ai: "Coach, explain, help diagnose, and suggest bounded next steps within the approved plan. Do not turn a question into taking over the implementation.",
|
|
115
123
|
artifactPrompts: {
|
|
116
124
|
changeset: [
|
|
@@ -130,20 +138,26 @@ const guides: Record<string, PhaseGuide> = {
|
|
|
130
138
|
},
|
|
131
139
|
"ai-review": {
|
|
132
140
|
objective: "Add an AI review of the exact current changeset before independent human review.",
|
|
133
|
-
human:
|
|
141
|
+
human:
|
|
142
|
+
"Validate and dispose every material finding. Return to implementation when a change is required.",
|
|
134
143
|
ai: "Review without modifying: correctness, security, tests, architecture, plan compliance, operations, and maintainability.",
|
|
135
144
|
artifactPrompts: {
|
|
136
145
|
"ai-review": [
|
|
137
|
-
"What exact
|
|
138
|
-
"What findings were identified, with evidence and
|
|
139
|
-
"What disposition is proposed for each finding?",
|
|
146
|
+
"What exact AHEAD review snapshot was reviewed?",
|
|
147
|
+
"What stable AR findings were identified, with severity, category, location, evidence, impact, and a falsifiable explanation?",
|
|
140
148
|
"What could not be assessed?",
|
|
141
149
|
],
|
|
150
|
+
"review-disposition": [
|
|
151
|
+
"Does the snapshot still match the AI review?",
|
|
152
|
+
"For every material AR finding, is it fixed, invalid, accepted risk, or follow-up?",
|
|
153
|
+
"What human rationale and evidence support each disposition?",
|
|
154
|
+
],
|
|
142
155
|
},
|
|
143
156
|
},
|
|
144
157
|
"human-review": {
|
|
145
158
|
objective: "Obtain independent final engineering judgment on the current change.",
|
|
146
|
-
human:
|
|
159
|
+
human:
|
|
160
|
+
"A reviewer other than the implementer examines the exact change and material evidence, then accepts or returns it.",
|
|
147
161
|
ai: "Retrieve evidence and answer targeted questions. It cannot approve the change or replace reviewer judgment.",
|
|
148
162
|
handoff: "READY FOR INDEPENDENT HUMAN REVIEW",
|
|
149
163
|
artifactPrompts: {
|
|
@@ -157,7 +171,8 @@ const guides: Record<string, PhaseGuide> = {
|
|
|
157
171
|
},
|
|
158
172
|
deploy: {
|
|
159
173
|
objective: "Authorize and record deployment or explicitly establish that it is not applicable.",
|
|
160
|
-
human:
|
|
174
|
+
human:
|
|
175
|
+
"Own the release decision and production risk. Record the exact version, target, actor, time, authorization, and result.",
|
|
161
176
|
ai: "Analyze readiness evidence. It cannot authorize deployment or claim a version is live.",
|
|
162
177
|
artifactPrompts: {
|
|
163
178
|
deployment: [
|
|
@@ -169,8 +184,10 @@ const guides: Record<string, PhaseGuide> = {
|
|
|
169
184
|
},
|
|
170
185
|
},
|
|
171
186
|
verify: {
|
|
172
|
-
objective:
|
|
173
|
-
|
|
187
|
+
objective:
|
|
188
|
+
"Demonstrate the intended outcome using observed evidence, not just test or deployment status.",
|
|
189
|
+
human:
|
|
190
|
+
"Select adequate checks and decide whether the original success signals are demonstrated.",
|
|
174
191
|
ai: "Suggest checks and analyze authorized observations while separating code, deployment, and observed behavior.",
|
|
175
192
|
artifactPrompts: {
|
|
176
193
|
verification: [
|
|
@@ -182,7 +199,8 @@ const guides: Record<string, PhaseGuide> = {
|
|
|
182
199
|
},
|
|
183
200
|
},
|
|
184
201
|
"ai-audit": {
|
|
185
|
-
objective:
|
|
202
|
+
objective:
|
|
203
|
+
"Compare the result with the original intent and expose weak evidence or divergence.",
|
|
186
204
|
human: "Review and dispose material audit findings; reopen work when the evidence demands it.",
|
|
187
205
|
ai: "Audit the full chain from problem through observed outcome without changing or approving the work.",
|
|
188
206
|
artifactPrompts: {
|
|
@@ -191,11 +209,17 @@ const guides: Record<string, PhaseGuide> = {
|
|
|
191
209
|
"Which claims have weak or missing evidence?",
|
|
192
210
|
"Which findings require follow-up or reopening?",
|
|
193
211
|
],
|
|
212
|
+
"audit-disposition": [
|
|
213
|
+
"Which audit findings are accepted, rejected, resolved, or routed to follow-up?",
|
|
214
|
+
"What human rationale and evidence support each disposition?",
|
|
215
|
+
"Does any finding require reopening an earlier phase rather than closing the work?",
|
|
216
|
+
],
|
|
194
217
|
},
|
|
195
218
|
},
|
|
196
219
|
outcome: {
|
|
197
220
|
objective: "Make the accountable outcome decision and preserve learning.",
|
|
198
|
-
human:
|
|
221
|
+
human:
|
|
222
|
+
"Accept, roll back, follow up, abandon, or reopen the work, including remaining uncertainty.",
|
|
199
223
|
ai: "Organize evidence and summarize learning. It cannot choose or accept the outcome.",
|
|
200
224
|
artifactPrompts: {
|
|
201
225
|
outcome: [
|
|
@@ -215,18 +239,137 @@ const fallbackGuide: PhaseGuide = {
|
|
|
215
239
|
artifactPrompts: {},
|
|
216
240
|
};
|
|
217
241
|
|
|
218
|
-
|
|
219
|
-
|
|
242
|
+
const artifactPromptCatalog: Record<string, string[]> = {
|
|
243
|
+
"failure-characterization": [
|
|
244
|
+
"What was observed, and what was expected instead?",
|
|
245
|
+
"How can it be reproduced, and when, where, or for whom does it occur?",
|
|
246
|
+
"What does not fail, and what does that boundary rule out?",
|
|
247
|
+
],
|
|
248
|
+
"human-model": [
|
|
249
|
+
"What do you currently believe is happening, and why?",
|
|
250
|
+
"What predictions would distinguish this model from alternatives?",
|
|
251
|
+
"Which parts are observed facts, inferences, or assumptions?",
|
|
252
|
+
],
|
|
253
|
+
"investigation-ledger": [
|
|
254
|
+
"Which facts, inferences, hypotheses, and confidence levels are current?",
|
|
255
|
+
"What did each hypothesis predict, what was tested, and what happened?",
|
|
256
|
+
"What evidence supports or contradicts each live explanation?",
|
|
257
|
+
],
|
|
258
|
+
diagnosis: [
|
|
259
|
+
"What diagnosis is supported, or why does the cause remain unknown?",
|
|
260
|
+
"Which evidence and counterevidence determine the confidence?",
|
|
261
|
+
"What risk and uncertainty remain if work proceeds?",
|
|
262
|
+
],
|
|
263
|
+
correction: [
|
|
264
|
+
"What correction is selected, and how does it follow from the diagnosis?",
|
|
265
|
+
"What blast radius, regressions, and reversibility matter?",
|
|
266
|
+
"How will the original failure and side effects be verified?",
|
|
267
|
+
],
|
|
268
|
+
assessment: [
|
|
269
|
+
"What symptoms, impact, scope, urgency, and known facts define the situation?",
|
|
270
|
+
"Which signals would demonstrate recovery or worsening?",
|
|
271
|
+
],
|
|
272
|
+
"response-mode": [
|
|
273
|
+
"Who owns the response and communication?",
|
|
274
|
+
"What authority boundaries, escalation path, and stop conditions apply?",
|
|
275
|
+
],
|
|
276
|
+
"system-model": [
|
|
277
|
+
"What is the human's current model of the system and failure mode?",
|
|
278
|
+
"What is known, inferred, and still uncertain?",
|
|
279
|
+
],
|
|
280
|
+
intervention: [
|
|
281
|
+
"What bounded action is proposed, who may execute it, and what is its scope?",
|
|
282
|
+
"What are the blast radius, rollback, expected signals, uncertainty, and stop conditions?",
|
|
283
|
+
],
|
|
284
|
+
"action-record": [
|
|
285
|
+
"What authorized action actually occurred, who performed it, and when?",
|
|
286
|
+
"What immediate effects, stop decisions, and rollback status were observed?",
|
|
287
|
+
],
|
|
288
|
+
"recovery-evidence": [
|
|
289
|
+
"Which system and user-visible recovery signals were checked?",
|
|
290
|
+
"What regressions, residual risk, and uncertainty remain?",
|
|
291
|
+
],
|
|
292
|
+
monitoring: [
|
|
293
|
+
"What observation window and signals were selected?",
|
|
294
|
+
"Was there recurrence or delayed degradation, and what residual risk remains?",
|
|
295
|
+
],
|
|
296
|
+
"decision-frame": [
|
|
297
|
+
"What exact choice must be made, by whom, and for whom?",
|
|
298
|
+
"What are its scope, deadline, consequences, and reversibility?",
|
|
299
|
+
],
|
|
300
|
+
criteria: [
|
|
301
|
+
"Which priorities and constraints govern the choice?",
|
|
302
|
+
"What evidence standard and remaining uncertainty are acceptable?",
|
|
303
|
+
],
|
|
304
|
+
comparison: [
|
|
305
|
+
"How does each option perform against the recorded criteria?",
|
|
306
|
+
"What tradeoffs, risks, sensitivity, confidence, and disagreement remain?",
|
|
307
|
+
],
|
|
308
|
+
"published-decision": [
|
|
309
|
+
"Where is the durable decision and rationale recorded?",
|
|
310
|
+
"Who is affected, what downstream work is linked, and how will it be communicated?",
|
|
311
|
+
"What event or date should trigger review?",
|
|
312
|
+
],
|
|
313
|
+
question: [
|
|
314
|
+
"What exact question is being investigated, and why does it matter?",
|
|
315
|
+
"Who owns it, how will findings be used, and what would count as an answer?",
|
|
316
|
+
],
|
|
317
|
+
bounds: [
|
|
318
|
+
"What is in scope and explicitly out of scope?",
|
|
319
|
+
"What evidence standard, time or cost box, risks, and stop conditions apply?",
|
|
320
|
+
],
|
|
321
|
+
evidence: [
|
|
322
|
+
"Which sources, observations, or measurements were gathered, with what provenance?",
|
|
323
|
+
"What is supported, contradicted, uncertain, or still missing?",
|
|
324
|
+
],
|
|
325
|
+
"exploration-ledger": [
|
|
326
|
+
"Which models or paths were considered and what did each predict?",
|
|
327
|
+
"Which tests or prototypes ran, what happened, and how did confidence change?",
|
|
328
|
+
],
|
|
329
|
+
"prototype-disposition": [
|
|
330
|
+
"What disposable prototype was created and what was learned, or was no prototype used?",
|
|
331
|
+
"How was the prototype isolated, retained, or discarded so it cannot silently become production code?",
|
|
332
|
+
],
|
|
333
|
+
synthesis: [
|
|
334
|
+
"What findings follow from the evidence?",
|
|
335
|
+
"What contradictions, limitations, uncertainty, and confidence remain?",
|
|
336
|
+
],
|
|
337
|
+
conclusion: [
|
|
338
|
+
"What answer or defensible non-answer follows from the investigation?",
|
|
339
|
+
"What remains unresolved, what evidence is reusable, and does consequential choice route to Decision?",
|
|
340
|
+
],
|
|
341
|
+
invariants: [
|
|
342
|
+
"Which behavior, compatibility, safety, and operability properties must not regress?",
|
|
343
|
+
"How will each invariant be observed or tested?",
|
|
344
|
+
],
|
|
345
|
+
baseline: [
|
|
346
|
+
"What is the current measurement and exact method?",
|
|
347
|
+
"What sample, noise, confounders, uncertainty, and reproducibility limitations apply?",
|
|
348
|
+
],
|
|
349
|
+
target: [
|
|
350
|
+
"What measurable improvement and threshold are desired?",
|
|
351
|
+
"What guardrails, scope, acceptable tradeoffs, and stop conditions apply?",
|
|
352
|
+
],
|
|
353
|
+
};
|
|
354
|
+
|
|
355
|
+
export function phaseGuide(workflowId: string, phaseId: string): PhaseGuide {
|
|
356
|
+
return flowGuides[`${workflowId}:${phaseId}`] ?? guides[phaseId] ?? fallbackGuide;
|
|
220
357
|
}
|
|
221
358
|
|
|
222
|
-
export function promptsForArtifact(phaseId: string, kind: string): string[] {
|
|
223
|
-
return
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
359
|
+
export function promptsForArtifact(workflowId: string, phaseId: string, kind: string): string[] {
|
|
360
|
+
return (
|
|
361
|
+
phaseGuide(workflowId, phaseId).artifactPrompts[kind] ??
|
|
362
|
+
artifactPromptCatalog[kind] ?? [
|
|
363
|
+
"What must another engineer understand from this record?",
|
|
364
|
+
"What evidence, uncertainty, and rationale should remain durable?",
|
|
365
|
+
]
|
|
366
|
+
);
|
|
227
367
|
}
|
|
228
368
|
|
|
229
|
-
export function phasePosition(
|
|
369
|
+
export function phasePosition(
|
|
370
|
+
state: RunState,
|
|
371
|
+
workflow: WorkflowDefinition,
|
|
372
|
+
): { current: number; total: number } {
|
|
230
373
|
const index = workflow.phases.findIndex((phase) => phase.id === state.phase.id);
|
|
231
374
|
return { current: index < 0 ? 0 : index + 1, total: workflow.phases.length };
|
|
232
375
|
}
|
|
@@ -239,68 +382,71 @@ export interface GuidedNextAction {
|
|
|
239
382
|
}
|
|
240
383
|
|
|
241
384
|
export function nextAction(state: RunState, workflow: WorkflowDefinition): GuidedNextAction {
|
|
242
|
-
if (state.closed)
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
if (orderedAssist) return orderedAssist;
|
|
385
|
+
if (state.closed) {
|
|
386
|
+
return { actor: "human", label: "Work complete; start another run only for new work" };
|
|
387
|
+
}
|
|
246
388
|
|
|
247
|
-
const artifact = state
|
|
389
|
+
const artifact = nextPendingArtifact(state);
|
|
248
390
|
if (artifact) {
|
|
249
|
-
const actor =
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
391
|
+
const actor =
|
|
392
|
+
artifact.actor === "human"
|
|
393
|
+
? "human"
|
|
394
|
+
: artifact.actor === "ai" || state.allowed_ai_capabilities.includes("record")
|
|
395
|
+
? "ai"
|
|
396
|
+
: "human";
|
|
254
397
|
if (actor === "human") {
|
|
255
|
-
const label =
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
398
|
+
const label =
|
|
399
|
+
state.phase.id === "implement" && artifact.kind === "changeset"
|
|
400
|
+
? "Implement first, then record the exact changeset"
|
|
401
|
+
: state.phase.id === "human-review"
|
|
402
|
+
? "Independent reviewer records the current human review"
|
|
403
|
+
: `Write ${artifact.title}`;
|
|
260
404
|
return { actor, label, artifactKind: artifact.kind };
|
|
261
405
|
}
|
|
262
406
|
|
|
263
|
-
const label =
|
|
264
|
-
?
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
407
|
+
const label = artifact.required
|
|
408
|
+
? state.phase.id === "ai-review"
|
|
409
|
+
? "Run AI review of the exact current changeset"
|
|
410
|
+
: state.phase.id === "ai-audit"
|
|
411
|
+
? "Run AI audit across intent, evidence, and outcome"
|
|
412
|
+
: `Ask AI to produce ${artifact.title}`
|
|
413
|
+
: state.phase.id === "options"
|
|
414
|
+
? "Ask AI to challenge the human option and expand alternatives"
|
|
415
|
+
: state.phase.id === "plan"
|
|
416
|
+
? "Ask AI to challenge the human first-pass plan"
|
|
417
|
+
: `Ask AI to contribute ${artifact.title}`;
|
|
418
|
+
return artifact.required
|
|
419
|
+
? { actor, label, artifactKind: artifact.kind }
|
|
420
|
+
: { actor, label, artifactKind: artifact.kind, optional: true };
|
|
269
421
|
}
|
|
270
422
|
|
|
271
|
-
if (!state.gate.accepted)
|
|
423
|
+
if (!state.gate.accepted) {
|
|
424
|
+
return { actor: "human", label: `Review evidence and accept: ${state.gate.title}` };
|
|
425
|
+
}
|
|
272
426
|
|
|
273
427
|
const nextPhase = workflow.phases.find((phase) => phase.id === state.phase.next);
|
|
274
428
|
return {
|
|
275
429
|
actor: "human",
|
|
276
|
-
label: nextPhase
|
|
430
|
+
label: nextPhase
|
|
431
|
+
? `Continue to ${nextPhase.title}`
|
|
432
|
+
: "Accept the outcome and close this AHEAD run",
|
|
277
433
|
};
|
|
278
434
|
}
|
|
279
435
|
|
|
280
|
-
function
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
const prerequisite = state.artifacts.find((artifact) => artifact.kind === orderedAssist.prerequisite);
|
|
289
|
-
const assist = state.artifacts.find((artifact) => artifact.kind === orderedAssist.assist);
|
|
290
|
-
const final = state.artifacts.find((artifact) => artifact.kind === orderedAssist.final);
|
|
291
|
-
if (!prerequisite?.present || assist?.present || final?.present) return undefined;
|
|
292
|
-
|
|
293
|
-
return {
|
|
294
|
-
actor: "ai",
|
|
295
|
-
artifactKind: assist?.kind,
|
|
296
|
-
label: state.phase.id === "options"
|
|
297
|
-
? "Ask AI to challenge the human option and expand alternatives"
|
|
298
|
-
: "Ask AI to challenge the human first-pass plan",
|
|
299
|
-
optional: true,
|
|
300
|
-
};
|
|
436
|
+
function nextPendingArtifact(state: RunState): ArtifactState | undefined {
|
|
437
|
+
return state.artifacts.find(
|
|
438
|
+
(artifact) =>
|
|
439
|
+
!artifact.present &&
|
|
440
|
+
(artifact.required ||
|
|
441
|
+
(artifact.actor !== "human" && state.allowed_ai_capabilities.includes("record"))),
|
|
442
|
+
);
|
|
301
443
|
}
|
|
302
444
|
|
|
303
|
-
export function buildWidgetLines(
|
|
445
|
+
export function buildWidgetLines(
|
|
446
|
+
run: Run,
|
|
447
|
+
state: RunState,
|
|
448
|
+
workflow: WorkflowDefinition,
|
|
449
|
+
): string[] {
|
|
304
450
|
if (state.closed) {
|
|
305
451
|
return [
|
|
306
452
|
`AHEAD COMPLETE · ${run.title}`,
|
|
@@ -309,7 +455,7 @@ export function buildWidgetLines(run: Run, state: RunState, workflow: WorkflowDe
|
|
|
309
455
|
];
|
|
310
456
|
}
|
|
311
457
|
|
|
312
|
-
const guide = phaseGuide(state.phase.id);
|
|
458
|
+
const guide = phaseGuide(state.workflow_id, state.phase.id);
|
|
313
459
|
const position = phasePosition(state, workflow);
|
|
314
460
|
const required = state.artifacts.filter((artifact) => artifact.required);
|
|
315
461
|
const checklist = required.length
|
|
@@ -335,7 +481,7 @@ export function buildArtifactTemplate(
|
|
|
335
481
|
kind: string,
|
|
336
482
|
title: string,
|
|
337
483
|
): string {
|
|
338
|
-
const prompts = promptsForArtifact(state.phase.id, kind);
|
|
484
|
+
const prompts = promptsForArtifact(state.workflow_id, state.phase.id, kind);
|
|
339
485
|
return [
|
|
340
486
|
`# ${title}`,
|
|
341
487
|
"",
|