ahead-pi 0.1.1 → 0.2.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/README.md +42 -22
- package/generated/product-change/ai-audit.md +6 -3
- package/generated/product-change/ai-review.md +6 -3
- package/generated/product-change/decision.md +6 -3
- package/generated/product-change/define.md +6 -3
- package/generated/product-change/deploy.md +6 -3
- package/generated/product-change/human-review.md +6 -3
- package/generated/product-change/implement.md +11 -4
- package/generated/product-change/manifest.json +2 -2
- package/generated/product-change/options.md +6 -3
- package/generated/product-change/outcome.md +6 -3
- package/generated/product-change/plan.md +6 -3
- package/generated/product-change/questions.md +6 -3
- package/generated/product-change/research.md +6 -3
- package/generated/product-change/verify.md +6 -3
- package/generated/reference/CONSTITUTION.md +43 -0
- package/generated/reference/docs/acceptable-ai-use.md +217 -0
- package/generated/reference/docs/design/debugging-and-operations.md +119 -0
- package/generated/reference/docs/design/executable-workflows.md +110 -0
- package/generated/reference/docs/design/process-taxonomy.md +144 -0
- package/generated/reference/docs/engineering-practice.md +163 -0
- package/generated/reference/docs/evidence/evidence-standard.md +123 -0
- package/generated/reference/docs/evidence/research-map.md +98 -0
- package/generated/reference/docs/rationale.md +210 -0
- package/generated/reference/docs/references/pragmatic-programmer-page-index.md +113 -0
- package/generated/reference/docs/references/submitted-engineering-notes.md +306 -0
- package/generated/reference/docs/releasing-pi.md +89 -0
- package/generated/reference/docs/workflows/README.md +142 -0
- package/generated/reference/docs/workflows/corrective-debugging.md +203 -0
- package/generated/reference/docs/workflows/decision.md +149 -0
- package/generated/reference/docs/workflows/internal-improvement.md +207 -0
- package/generated/reference/docs/workflows/investigation.md +159 -0
- package/generated/reference/docs/workflows/operational-stabilization.md +185 -0
- package/generated/reference/docs/workflows/product-change.md +205 -0
- package/generated/reference/index.json +180 -0
- package/package.json +4 -2
- package/src/guidance.ts +360 -0
- package/src/index.ts +538 -136
- package/src/reference-viewer.ts +71 -0
- package/src/reference.ts +56 -0
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
{
|
|
2
|
+
"generated_from": [
|
|
3
|
+
"CONSTITUTION.md",
|
|
4
|
+
"docs/acceptable-ai-use.md",
|
|
5
|
+
"docs/design/debugging-and-operations.md",
|
|
6
|
+
"docs/design/executable-workflows.md",
|
|
7
|
+
"docs/design/process-taxonomy.md",
|
|
8
|
+
"docs/engineering-practice.md",
|
|
9
|
+
"docs/evidence/evidence-standard.md",
|
|
10
|
+
"docs/evidence/research-map.md",
|
|
11
|
+
"docs/rationale.md",
|
|
12
|
+
"docs/references/pragmatic-programmer-page-index.md",
|
|
13
|
+
"docs/references/submitted-engineering-notes.md",
|
|
14
|
+
"docs/releasing-pi.md",
|
|
15
|
+
"docs/workflows/README.md",
|
|
16
|
+
"docs/workflows/corrective-debugging.md",
|
|
17
|
+
"docs/workflows/decision.md",
|
|
18
|
+
"docs/workflows/internal-improvement.md",
|
|
19
|
+
"docs/workflows/investigation.md",
|
|
20
|
+
"docs/workflows/operational-stabilization.md",
|
|
21
|
+
"docs/workflows/product-change.md"
|
|
22
|
+
],
|
|
23
|
+
"references": [
|
|
24
|
+
{
|
|
25
|
+
"id": "constitution",
|
|
26
|
+
"path": "CONSTITUTION.md",
|
|
27
|
+
"title": "AHEAD Constitution",
|
|
28
|
+
"summary": "This constitution records the durable principles of **Assisted Human Engineering and Development**. Workflows and tools may evolve. These principles define what makes them AHEAD.",
|
|
29
|
+
"phases": [
|
|
30
|
+
"*"
|
|
31
|
+
]
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
"id": "acceptable-ai-use",
|
|
35
|
+
"path": "docs/acceptable-ai-use.md",
|
|
36
|
+
"title": "Acceptable AI Use in AHEAD",
|
|
37
|
+
"summary": "This policy is binding for AHEAD pilot workflows. The [AHEAD Constitution](../CONSTITUTION.md) is the highest authority; this policy interprets its human-ownership boundaries; workflow profiles apply both and may narrow AI permissions for a",
|
|
38
|
+
"phases": [
|
|
39
|
+
"*"
|
|
40
|
+
]
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
"id": "design:debugging-and-operations",
|
|
44
|
+
"path": "docs/design/debugging-and-operations.md",
|
|
45
|
+
"title": "Debugging and Operational Investigation",
|
|
46
|
+
"summary": "The minimal [corrective-debugging](../workflows/corrective-debugging.md) and [operational-stabilization](../workflows/operational-stabilization.md) profiles translate this discussion into pilotable flows. This document retains the reasoning",
|
|
47
|
+
"phases": []
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
"id": "design:executable-workflows",
|
|
51
|
+
"path": "docs/design/executable-workflows.md",
|
|
52
|
+
"title": "Executable AHEAD Workflows",
|
|
53
|
+
"summary": "The executable layer makes AHEAD workflow state durable and makes selected human/AI boundaries enforceable across integrations. It does not turn judgment into a checklist or make workflow artifacts proof of understanding.",
|
|
54
|
+
"phases": [
|
|
55
|
+
"*"
|
|
56
|
+
]
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
"id": "design:process-taxonomy",
|
|
60
|
+
"path": "docs/design/process-taxonomy.md",
|
|
61
|
+
"title": "AHEAD Process Taxonomy",
|
|
62
|
+
"summary": "AHEAD should not create a workflow for every issue label. “Security,” “performance,” “data,” “incident,” and “technical debt” often describe risk, domain, urgency, or cause—not the kind of reasoning needed to complete the work.",
|
|
63
|
+
"phases": []
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
"id": "engineering-practice",
|
|
67
|
+
"path": "docs/engineering-practice.md",
|
|
68
|
+
"title": "AHEAD Engineering Practice",
|
|
69
|
+
"summary": "AHEAD is not only a sequence of AI gates. It is a way of practicing engineering. This guide distills general habits from the submitted starting list into a smaller set of principles that can be remembered, applied, and evaluated.",
|
|
70
|
+
"phases": [
|
|
71
|
+
"*"
|
|
72
|
+
]
|
|
73
|
+
},
|
|
74
|
+
{
|
|
75
|
+
"id": "evidence:evidence-standard",
|
|
76
|
+
"path": "docs/evidence/evidence-standard.md",
|
|
77
|
+
"title": "AHEAD Evidence Standard",
|
|
78
|
+
"summary": "AHEAD should be supported by the best available evidence without claiming more certainty than software-engineering research can provide. A credible methodology must distinguish evidence for a descriptive claim from evidence that a particula",
|
|
79
|
+
"phases": [
|
|
80
|
+
"research",
|
|
81
|
+
"questions",
|
|
82
|
+
"decision",
|
|
83
|
+
"plan",
|
|
84
|
+
"ai-review",
|
|
85
|
+
"human-review",
|
|
86
|
+
"verify",
|
|
87
|
+
"ai-audit",
|
|
88
|
+
"outcome"
|
|
89
|
+
]
|
|
90
|
+
},
|
|
91
|
+
{
|
|
92
|
+
"id": "evidence:research-map",
|
|
93
|
+
"path": "docs/evidence/research-map.md",
|
|
94
|
+
"title": "AHEAD Research Map",
|
|
95
|
+
"summary": "This document maps current AHEAD design claims to available evidence. It is not a bibliography of everything related to software engineering. It focuses on claims that materially shape the methodology.",
|
|
96
|
+
"phases": []
|
|
97
|
+
},
|
|
98
|
+
{
|
|
99
|
+
"id": "rationale",
|
|
100
|
+
"path": "docs/rationale.md",
|
|
101
|
+
"title": "Why AHEAD",
|
|
102
|
+
"summary": "AI can make software engineering faster. It can search broadly, synthesize information, identify omissions, generate alternatives, produce routine code, explain unfamiliar systems, and review more material than a person can inspect unaided.",
|
|
103
|
+
"phases": [
|
|
104
|
+
"*"
|
|
105
|
+
]
|
|
106
|
+
},
|
|
107
|
+
{
|
|
108
|
+
"id": "references:pragmatic-programmer-page-index",
|
|
109
|
+
"path": "docs/references/pragmatic-programmer-page-index.md",
|
|
110
|
+
"title": "*The Pragmatic Programmer* Page Index",
|
|
111
|
+
"summary": "This index preserves the page-level provenance from the original AHEAD engineering-practice notes for:",
|
|
112
|
+
"phases": []
|
|
113
|
+
},
|
|
114
|
+
{
|
|
115
|
+
"id": "references:submitted-engineering-notes",
|
|
116
|
+
"path": "docs/references/submitted-engineering-notes.md",
|
|
117
|
+
"title": "Submitted Engineering Notes",
|
|
118
|
+
"summary": "This document preserves submitted engineering tips, checklists, and practices that are intentionally condensed in the [AHEAD Engineering Practice](../engineering-practice.md) guide. It is a source record, not a claim that every item is an e",
|
|
119
|
+
"phases": []
|
|
120
|
+
},
|
|
121
|
+
{
|
|
122
|
+
"id": "releasing-pi",
|
|
123
|
+
"path": "docs/releasing-pi.md",
|
|
124
|
+
"title": "Releasing the Pi Extension",
|
|
125
|
+
"summary": "- npm package: `ahead-pi` - package source: `integrations/pi` - release workflow: `.github/workflows/publish-pi.yml` - release tag: `pi-v<package-version>` - stable npm dist-tag: `latest` - prerelease npm dist-tag: `next` - registry: `https",
|
|
126
|
+
"phases": []
|
|
127
|
+
},
|
|
128
|
+
{
|
|
129
|
+
"id": "workflows:readme",
|
|
130
|
+
"path": "docs/workflows/README.md",
|
|
131
|
+
"title": "AHEAD Pilot Workflows",
|
|
132
|
+
"summary": "These six minimal workflow profiles are meant to be used on real engineering work before AHEAD builds a workflow engine, editor extension, or CI enforcement. They are deliberately small. The pilot should reveal which phases, gates, and reco",
|
|
133
|
+
"phases": []
|
|
134
|
+
},
|
|
135
|
+
{
|
|
136
|
+
"id": "workflows:corrective-debugging",
|
|
137
|
+
"path": "docs/workflows/corrective-debugging.md",
|
|
138
|
+
"title": "Corrective Debugging Workflow",
|
|
139
|
+
"summary": "Use this flow when observed behavior conflicts with intended behavior and the dominant work is causal diagnosis plus correction. It ends with a verified correction or an explicit human acceptance of remaining uncertainty.",
|
|
140
|
+
"phases": []
|
|
141
|
+
},
|
|
142
|
+
{
|
|
143
|
+
"id": "workflows:decision",
|
|
144
|
+
"path": "docs/workflows/decision.md",
|
|
145
|
+
"title": "Decision Workflow",
|
|
146
|
+
"summary": "Use this flow when the deliverable is an accountable human choice among alternatives: architecture, buy versus build, technology selection, platform direction, policy, or another consequential course.",
|
|
147
|
+
"phases": []
|
|
148
|
+
},
|
|
149
|
+
{
|
|
150
|
+
"id": "workflows:internal-improvement",
|
|
151
|
+
"path": "docs/workflows/internal-improvement.md",
|
|
152
|
+
"title": "Internal Improvement Workflow",
|
|
153
|
+
"summary": "Use this flow when externally required behavior should remain invariant while an internal quality improves: maintainability, comprehensibility, performance, reliability margin, operability, testability, cost, or preventive risk reduction.",
|
|
154
|
+
"phases": []
|
|
155
|
+
},
|
|
156
|
+
{
|
|
157
|
+
"id": "workflows:investigation",
|
|
158
|
+
"path": "docs/workflows/investigation.md",
|
|
159
|
+
"title": "Investigation Workflow",
|
|
160
|
+
"summary": "Use this flow when the primary deliverable is knowledge or reduced uncertainty and no intervention has yet been selected. It may answer feasibility, causal, capacity, vendor, architectural, or technical questions.",
|
|
161
|
+
"phases": []
|
|
162
|
+
},
|
|
163
|
+
{
|
|
164
|
+
"id": "workflows:operational-stabilization",
|
|
165
|
+
"path": "docs/workflows/operational-stabilization.md",
|
|
166
|
+
"title": "Operational Stabilization Workflow",
|
|
167
|
+
"summary": "Use this flow when a live system is outside an acceptable operating state and the immediate outcome is restoration, stabilization, or demonstrated convergence. It covers code and non-code causes such as reconciliation storms, configuration ",
|
|
168
|
+
"phases": []
|
|
169
|
+
},
|
|
170
|
+
{
|
|
171
|
+
"id": "workflows:product-change",
|
|
172
|
+
"path": "docs/workflows/product-change.md",
|
|
173
|
+
"title": "Product Change Workflow",
|
|
174
|
+
"summary": "Use this flow when the dominant outcome is new, changed, adapted, migrated, or retired externally meaningful behavior. It ends with verified intended behavior and an accountable human outcome decision.",
|
|
175
|
+
"phases": [
|
|
176
|
+
"*"
|
|
177
|
+
]
|
|
178
|
+
}
|
|
179
|
+
]
|
|
180
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ahead-pi",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.1",
|
|
4
4
|
"description": "AHEAD workflow enforcement and context for Pi",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -49,10 +49,12 @@
|
|
|
49
49
|
},
|
|
50
50
|
"peerDependencies": {
|
|
51
51
|
"@earendil-works/pi-coding-agent": "*",
|
|
52
|
+
"@earendil-works/pi-tui": "*",
|
|
52
53
|
"typebox": "*"
|
|
53
54
|
},
|
|
54
55
|
"devDependencies": {
|
|
55
|
-
"@earendil-works/pi-coding-agent": "0.
|
|
56
|
+
"@earendil-works/pi-coding-agent": "^0.84.1",
|
|
57
|
+
"@earendil-works/pi-tui": "^0.84.1",
|
|
56
58
|
"@types/node": "24.12.4",
|
|
57
59
|
"typebox": "1.1.38",
|
|
58
60
|
"typescript": "5.9.3"
|
package/src/guidance.ts
ADDED
|
@@ -0,0 +1,360 @@
|
|
|
1
|
+
import type { ArtifactState, Run, RunState, WorkflowDefinition } from "./types.js";
|
|
2
|
+
|
|
3
|
+
export interface PhaseGuide {
|
|
4
|
+
objective: string;
|
|
5
|
+
human: string;
|
|
6
|
+
ai: string;
|
|
7
|
+
artifactPrompts: Record<string, string[]>;
|
|
8
|
+
handoff?: string;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
const guides: Record<string, PhaseGuide> = {
|
|
12
|
+
define: {
|
|
13
|
+
objective: "Agree on the problem and the observable outcome before solution work begins.",
|
|
14
|
+
human: "Describe the users, current problem, desired outcome, scope, constraints, and success signals.",
|
|
15
|
+
ai: "Explain the prompts. After your first statement, clarify ambiguity and expose assumptions without redefining the problem.",
|
|
16
|
+
artifactPrompts: {
|
|
17
|
+
problem: [
|
|
18
|
+
"Who experiences the problem, and what happens today?",
|
|
19
|
+
"What outcome should change, for whom, and why now?",
|
|
20
|
+
"What is in scope, out of scope, or constrained?",
|
|
21
|
+
"What observable signals would demonstrate success or failure?",
|
|
22
|
+
"Which assumptions or uncertainties should remain visible?",
|
|
23
|
+
],
|
|
24
|
+
},
|
|
25
|
+
},
|
|
26
|
+
research: {
|
|
27
|
+
objective: "Build enough evidence to understand the problem before choosing a solution.",
|
|
28
|
+
human: "Set the research boundary, judge source relevance, and identify what evidence is material.",
|
|
29
|
+
ai: "Inspect authorized sources, organize evidence, surface contradictions, and state confidence and gaps.",
|
|
30
|
+
artifactPrompts: {
|
|
31
|
+
research: [
|
|
32
|
+
"What sources, code, behavior, history, or measurements were examined?",
|
|
33
|
+
"What findings are supported, contradicted, or still uncertain?",
|
|
34
|
+
"How directly does each finding apply to this work?",
|
|
35
|
+
"What important evidence is still missing?",
|
|
36
|
+
],
|
|
37
|
+
},
|
|
38
|
+
},
|
|
39
|
+
questions: {
|
|
40
|
+
objective: "Dispose the unknowns that could materially change the decision or plan.",
|
|
41
|
+
human: "Decide which unknowns must be answered and which uncertainty can be accepted explicitly.",
|
|
42
|
+
ai: "Challenge gaps, perform authorized follow-up research, and distinguish evidence from inference.",
|
|
43
|
+
artifactPrompts: {
|
|
44
|
+
unknowns: [
|
|
45
|
+
"Which questions could materially change the work?",
|
|
46
|
+
"What answer or evidence resolved each question?",
|
|
47
|
+
"Which unknowns remain, and why is proceeding still acceptable?",
|
|
48
|
+
],
|
|
49
|
+
"question-research": [
|
|
50
|
+
"What follow-up question was investigated?",
|
|
51
|
+
"What evidence was found, and what remains uncertain?",
|
|
52
|
+
],
|
|
53
|
+
},
|
|
54
|
+
},
|
|
55
|
+
options: {
|
|
56
|
+
objective: "Understand viable approaches and tradeoffs before committing to one.",
|
|
57
|
+
human: "Produce the first option, then evaluate alternatives and tradeoffs in the system's real context.",
|
|
58
|
+
ai: "After the human first pass, challenge assumptions and add materially different alternatives.",
|
|
59
|
+
artifactPrompts: {
|
|
60
|
+
"human-option": [
|
|
61
|
+
"What is your first workable approach?",
|
|
62
|
+
"Why might it fit the problem and constraints?",
|
|
63
|
+
"What risks, costs, and uncertainties do you already see?",
|
|
64
|
+
],
|
|
65
|
+
"ai-challenge": [
|
|
66
|
+
"Which assumptions or failure modes does the first option overlook?",
|
|
67
|
+
"What materially different alternatives deserve consideration?",
|
|
68
|
+
],
|
|
69
|
+
options: [
|
|
70
|
+
"Which options were considered?",
|
|
71
|
+
"What are their tradeoffs, failure modes, reversibility, and operational consequences?",
|
|
72
|
+
"Which options were rejected, and why?",
|
|
73
|
+
],
|
|
74
|
+
},
|
|
75
|
+
},
|
|
76
|
+
decision: {
|
|
77
|
+
objective: "Make an accountable and explainable choice.",
|
|
78
|
+
human: "Choose the approach and own its rationale, tradeoffs, remaining uncertainty, and reversibility.",
|
|
79
|
+
ai: "Test the recorded decision for contradictions, weak evidence, and hidden consequences.",
|
|
80
|
+
artifactPrompts: {
|
|
81
|
+
decision: [
|
|
82
|
+
"What was decided?",
|
|
83
|
+
"Why does it best fit the evidence and constraints?",
|
|
84
|
+
"What tradeoffs and risks are accepted?",
|
|
85
|
+
"What remains unknown, and how reversible is the decision?",
|
|
86
|
+
],
|
|
87
|
+
},
|
|
88
|
+
},
|
|
89
|
+
plan: {
|
|
90
|
+
objective: "Create an implementable plan with verification, rollout, and recovery.",
|
|
91
|
+
human: "Write the first-pass sequence and approve the final plan after challenges are resolved.",
|
|
92
|
+
ai: "After the human first pass, identify missing dependencies, tests, edge cases, rollout evidence, recovery, and decision points.",
|
|
93
|
+
artifactPrompts: {
|
|
94
|
+
"first-pass-plan": [
|
|
95
|
+
"What sequence of changes do you currently expect?",
|
|
96
|
+
"Which systems, boundaries, and dependencies are involved?",
|
|
97
|
+
"How will you test, release, observe, and recover?",
|
|
98
|
+
],
|
|
99
|
+
"ai-plan-review": [
|
|
100
|
+
"What is missing, risky, ambiguous, or ordered incorrectly?",
|
|
101
|
+
"Which tests, edge cases, rollout checks, and recovery steps should be added?",
|
|
102
|
+
],
|
|
103
|
+
plan: [
|
|
104
|
+
"What is the final ordered implementation sequence?",
|
|
105
|
+
"What tests and observable evidence are required?",
|
|
106
|
+
"How will rollout and recovery work?",
|
|
107
|
+
"Which deviations require returning to decision or plan?",
|
|
108
|
+
],
|
|
109
|
+
},
|
|
110
|
+
},
|
|
111
|
+
implement: {
|
|
112
|
+
objective: "Produce a change the engineer understands and can defend.",
|
|
113
|
+
human: "Make the first attempt, ask questions freely, own the implementation, understand every lasting change, run the planned checks, and record deviations.",
|
|
114
|
+
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
|
+
artifactPrompts: {
|
|
116
|
+
changeset: [
|
|
117
|
+
"What exact commit, branch, pull request, or diff identifies the current change?",
|
|
118
|
+
"Can you explain the important behavior and design choices?",
|
|
119
|
+
],
|
|
120
|
+
tests: [
|
|
121
|
+
"Which planned and additional checks ran?",
|
|
122
|
+
"What passed, failed, or was not run?",
|
|
123
|
+
"What evidence covers boundaries, failures, and regressions?",
|
|
124
|
+
],
|
|
125
|
+
"plan-deviations": [
|
|
126
|
+
"Where did implementation differ from the approved plan?",
|
|
127
|
+
"Why was each deviation acceptable, or state explicitly that there were none?",
|
|
128
|
+
],
|
|
129
|
+
},
|
|
130
|
+
},
|
|
131
|
+
"ai-review": {
|
|
132
|
+
objective: "Add an AI review of the exact current changeset before independent human review.",
|
|
133
|
+
human: "Validate and dispose every material finding. Return to implementation when a change is required.",
|
|
134
|
+
ai: "Review without modifying: correctness, security, tests, architecture, plan compliance, operations, and maintainability.",
|
|
135
|
+
artifactPrompts: {
|
|
136
|
+
"ai-review": [
|
|
137
|
+
"What exact commit or diff was reviewed?",
|
|
138
|
+
"What findings were identified, with evidence and severity?",
|
|
139
|
+
"What disposition is proposed for each finding?",
|
|
140
|
+
"What could not be assessed?",
|
|
141
|
+
],
|
|
142
|
+
},
|
|
143
|
+
},
|
|
144
|
+
"human-review": {
|
|
145
|
+
objective: "Obtain independent final engineering judgment on the current change.",
|
|
146
|
+
human: "A reviewer other than the implementer examines the exact change and material evidence, then accepts or returns it.",
|
|
147
|
+
ai: "Retrieve evidence and answer targeted questions. It cannot approve the change or replace reviewer judgment.",
|
|
148
|
+
handoff: "READY FOR INDEPENDENT HUMAN REVIEW",
|
|
149
|
+
artifactPrompts: {
|
|
150
|
+
"human-review": [
|
|
151
|
+
"Who reviewed the change, and what exact commit or diff was reviewed?",
|
|
152
|
+
"What code, tests, evidence, risks, and operational consequences were examined?",
|
|
153
|
+
"Which findings must be addressed or explicitly accepted?",
|
|
154
|
+
"Does the reviewer understand and accept the current change?",
|
|
155
|
+
],
|
|
156
|
+
},
|
|
157
|
+
},
|
|
158
|
+
deploy: {
|
|
159
|
+
objective: "Authorize and record deployment or explicitly establish that it is not applicable.",
|
|
160
|
+
human: "Own the release decision and production risk. Record the exact version, target, actor, time, authorization, and result.",
|
|
161
|
+
ai: "Analyze readiness evidence. It cannot authorize deployment or claim a version is live.",
|
|
162
|
+
artifactPrompts: {
|
|
163
|
+
deployment: [
|
|
164
|
+
"What exact version was released to which target?",
|
|
165
|
+
"Who authorized and performed it, and when?",
|
|
166
|
+
"What did the deployment system report?",
|
|
167
|
+
"If deployment is not applicable, why?",
|
|
168
|
+
],
|
|
169
|
+
},
|
|
170
|
+
},
|
|
171
|
+
verify: {
|
|
172
|
+
objective: "Demonstrate the intended outcome using observed evidence, not just test or deployment status.",
|
|
173
|
+
human: "Select adequate checks and decide whether the original success signals are demonstrated.",
|
|
174
|
+
ai: "Suggest checks and analyze authorized observations while separating code, deployment, and observed behavior.",
|
|
175
|
+
artifactPrompts: {
|
|
176
|
+
verification: [
|
|
177
|
+
"What pre-change and post-change behavior was compared?",
|
|
178
|
+
"Which tests, deployment facts, runtime observations, and user-visible signals were checked?",
|
|
179
|
+
"Did the original success and failure signals occur?",
|
|
180
|
+
"What remains uncertain or needs continued observation?",
|
|
181
|
+
],
|
|
182
|
+
},
|
|
183
|
+
},
|
|
184
|
+
"ai-audit": {
|
|
185
|
+
objective: "Compare the result with the original intent and expose weak evidence or divergence.",
|
|
186
|
+
human: "Review and dispose material audit findings; reopen work when the evidence demands it.",
|
|
187
|
+
ai: "Audit the full chain from problem through observed outcome without changing or approving the work.",
|
|
188
|
+
artifactPrompts: {
|
|
189
|
+
"ai-audit": [
|
|
190
|
+
"Where did the result diverge from the problem, decision, plan, or reviews?",
|
|
191
|
+
"Which claims have weak or missing evidence?",
|
|
192
|
+
"Which findings require follow-up or reopening?",
|
|
193
|
+
],
|
|
194
|
+
},
|
|
195
|
+
},
|
|
196
|
+
outcome: {
|
|
197
|
+
objective: "Make the accountable outcome decision and preserve learning.",
|
|
198
|
+
human: "Accept, roll back, follow up, abandon, or reopen the work, including remaining uncertainty.",
|
|
199
|
+
ai: "Organize evidence and summarize learning. It cannot choose or accept the outcome.",
|
|
200
|
+
artifactPrompts: {
|
|
201
|
+
outcome: [
|
|
202
|
+
"What outcome decision is being made?",
|
|
203
|
+
"Which evidence supports it?",
|
|
204
|
+
"What uncertainty, debt, monitoring, or follow-up remains?",
|
|
205
|
+
"What should the team or AHEAD process learn from this run?",
|
|
206
|
+
],
|
|
207
|
+
},
|
|
208
|
+
},
|
|
209
|
+
};
|
|
210
|
+
|
|
211
|
+
const fallbackGuide: PhaseGuide = {
|
|
212
|
+
objective: "Complete the active phase using the recorded workflow contract.",
|
|
213
|
+
human: "Own the phase decision, required evidence, and gate.",
|
|
214
|
+
ai: "Assist only within the capabilities and artifact ownership allowed by the active phase.",
|
|
215
|
+
artifactPrompts: {},
|
|
216
|
+
};
|
|
217
|
+
|
|
218
|
+
export function phaseGuide(phaseId: string): PhaseGuide {
|
|
219
|
+
return guides[phaseId] ?? fallbackGuide;
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
export function promptsForArtifact(phaseId: string, kind: string): string[] {
|
|
223
|
+
return phaseGuide(phaseId).artifactPrompts[kind] ?? [
|
|
224
|
+
"What must another engineer understand from this record?",
|
|
225
|
+
"What evidence, uncertainty, and rationale should remain durable?",
|
|
226
|
+
];
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
export function phasePosition(state: RunState, workflow: WorkflowDefinition): { current: number; total: number } {
|
|
230
|
+
const index = workflow.phases.findIndex((phase) => phase.id === state.phase.id);
|
|
231
|
+
return { current: index < 0 ? 0 : index + 1, total: workflow.phases.length };
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
export interface GuidedNextAction {
|
|
235
|
+
actor: "human" | "ai";
|
|
236
|
+
label: string;
|
|
237
|
+
artifactKind?: string;
|
|
238
|
+
optional?: boolean;
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
export function nextAction(state: RunState, workflow: WorkflowDefinition): GuidedNextAction {
|
|
242
|
+
if (state.closed) return { actor: "human", label: "Work complete; start another run only for new work" };
|
|
243
|
+
|
|
244
|
+
const orderedAssist = optionalAssistBeforeFinalHumanRecord(state);
|
|
245
|
+
if (orderedAssist) return orderedAssist;
|
|
246
|
+
|
|
247
|
+
const artifact = state.artifacts.find((candidate) => candidate.required && !candidate.present);
|
|
248
|
+
if (artifact) {
|
|
249
|
+
const actor = artifact.actor === "human"
|
|
250
|
+
? "human"
|
|
251
|
+
: artifact.actor === "ai" || state.phase.id === "research"
|
|
252
|
+
? "ai"
|
|
253
|
+
: "human";
|
|
254
|
+
if (actor === "human") {
|
|
255
|
+
const label = state.phase.id === "implement" && artifact.kind === "changeset"
|
|
256
|
+
? "Implement first, then record the exact changeset"
|
|
257
|
+
: state.phase.id === "human-review"
|
|
258
|
+
? "Independent reviewer records the current human review"
|
|
259
|
+
: `Write ${artifact.title}`;
|
|
260
|
+
return { actor, label, artifactKind: artifact.kind };
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
const label = state.phase.id === "ai-review"
|
|
264
|
+
? "Run AI review of the exact current changeset"
|
|
265
|
+
: state.phase.id === "ai-audit"
|
|
266
|
+
? "Run AI audit across intent, evidence, and outcome"
|
|
267
|
+
: `Ask AI to produce ${artifact.title}`;
|
|
268
|
+
return { actor, label, artifactKind: artifact.kind };
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
if (!state.gate.accepted) return { actor: "human", label: `Review evidence and accept: ${state.gate.title}` };
|
|
272
|
+
|
|
273
|
+
const nextPhase = workflow.phases.find((phase) => phase.id === state.phase.next);
|
|
274
|
+
return {
|
|
275
|
+
actor: "human",
|
|
276
|
+
label: nextPhase ? `Continue to ${nextPhase.title}` : "Accept the outcome and close this AHEAD run",
|
|
277
|
+
};
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
function optionalAssistBeforeFinalHumanRecord(state: RunState): GuidedNextAction | undefined {
|
|
281
|
+
const orderedAssist = state.phase.id === "options"
|
|
282
|
+
? { prerequisite: "human-option", assist: "ai-challenge", final: "options" }
|
|
283
|
+
: state.phase.id === "plan"
|
|
284
|
+
? { prerequisite: "first-pass-plan", assist: "ai-plan-review", final: "plan" }
|
|
285
|
+
: undefined;
|
|
286
|
+
if (!orderedAssist) return undefined;
|
|
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
|
+
};
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
export function buildWidgetLines(run: Run, state: RunState, workflow: WorkflowDefinition): string[] {
|
|
304
|
+
if (state.closed) {
|
|
305
|
+
return [
|
|
306
|
+
`AHEAD COMPLETE · ${run.title}`,
|
|
307
|
+
"The accountable human accepted the outcome and closed this run.",
|
|
308
|
+
"Run /ahead only when new work needs a new workflow.",
|
|
309
|
+
];
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
const guide = phaseGuide(state.phase.id);
|
|
313
|
+
const position = phasePosition(state, workflow);
|
|
314
|
+
const required = state.artifacts.filter((artifact) => artifact.required);
|
|
315
|
+
const checklist = required.length
|
|
316
|
+
? required.map(formatArtifactStatus).join(" · ")
|
|
317
|
+
: "No required artifact";
|
|
318
|
+
const action = nextAction(state, workflow);
|
|
319
|
+
|
|
320
|
+
return [
|
|
321
|
+
`AHEAD MODE · ${workflow.title.toUpperCase()} · ${position.current}/${position.total}`,
|
|
322
|
+
`${guide.handoff ?? state.phase.title.toUpperCase()} · HUMAN LEADS · AI ASSISTS`,
|
|
323
|
+
`Goal: ${guide.objective}`,
|
|
324
|
+
`You: ${guide.human}`,
|
|
325
|
+
`AI: ${guide.ai}`,
|
|
326
|
+
`Required: ${checklist}`,
|
|
327
|
+
`Next (${action.actor === "human" ? "you" : "AI"}): ${action.label}`,
|
|
328
|
+
"Run /ahead for the guided action · /ahead-guide for framework docs.",
|
|
329
|
+
];
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
export function buildArtifactTemplate(
|
|
333
|
+
run: Run,
|
|
334
|
+
state: RunState,
|
|
335
|
+
kind: string,
|
|
336
|
+
title: string,
|
|
337
|
+
): string {
|
|
338
|
+
const prompts = promptsForArtifact(state.phase.id, kind);
|
|
339
|
+
return [
|
|
340
|
+
`# ${title}`,
|
|
341
|
+
"",
|
|
342
|
+
`AHEAD run: ${run.id}`,
|
|
343
|
+
`Phase: ${state.phase.id} (visit ${state.phase.visit})`,
|
|
344
|
+
`Artifact: ${kind}`,
|
|
345
|
+
"",
|
|
346
|
+
"## What to cover",
|
|
347
|
+
"",
|
|
348
|
+
...prompts.map((prompt) => `- ${prompt}`),
|
|
349
|
+
"",
|
|
350
|
+
"## Record",
|
|
351
|
+
"",
|
|
352
|
+
"<!-- Write this human-owned record in your own words. Preserve evidence, uncertainty, and rationale. -->",
|
|
353
|
+
"",
|
|
354
|
+
].join("\n");
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
function formatArtifactStatus(artifact: ArtifactState): string {
|
|
358
|
+
const owner = artifact.actor === "ai" ? "AI" : artifact.actor === "human" ? "you" : "you/AI";
|
|
359
|
+
return `${artifact.present ? "✓" : "○"} ${artifact.title} [${owner}]`;
|
|
360
|
+
}
|