@jterrats/open-orchestra 0.3.1 → 0.4.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/CHANGELOG.md +50 -0
- package/dist/autonomous-phase-lifecycle.d.ts +25 -0
- package/dist/autonomous-phase-lifecycle.js +194 -0
- package/dist/autonomous-phase-lifecycle.js.map +1 -0
- package/dist/autonomous-run-state.d.ts +6 -0
- package/dist/autonomous-run-state.js +91 -0
- package/dist/autonomous-run-state.js.map +1 -0
- package/dist/autonomous-run-store.d.ts +12 -0
- package/dist/autonomous-run-store.js +64 -0
- package/dist/autonomous-run-store.js.map +1 -0
- package/dist/autonomous-workflow-constants.d.ts +6 -0
- package/dist/autonomous-workflow-constants.js +36 -0
- package/dist/autonomous-workflow-constants.js.map +1 -0
- package/dist/autonomous-workflow.d.ts +6 -45
- package/dist/autonomous-workflow.js +4 -385
- package/dist/autonomous-workflow.js.map +1 -1
- package/dist/benchmark.d.ts +2 -1
- package/dist/benchmark.js +70 -0
- package/dist/benchmark.js.map +1 -1
- package/dist/cli.js +31 -2
- package/dist/cli.js.map +1 -1
- package/dist/command-utils.d.ts +6 -0
- package/dist/command-utils.js +19 -0
- package/dist/command-utils.js.map +1 -0
- package/dist/commands.d.ts +8 -40
- package/dist/commands.js +59 -803
- package/dist/commands.js.map +1 -1
- package/dist/constants.js +14 -0
- package/dist/constants.js.map +1 -1
- package/dist/defaults.d.ts +17 -0
- package/dist/defaults.js +17 -0
- package/dist/defaults.js.map +1 -1
- package/dist/instruction-commands.d.ts +5 -0
- package/dist/instruction-commands.js +98 -0
- package/dist/instruction-commands.js.map +1 -0
- package/dist/metrics-commands.d.ts +3 -0
- package/dist/metrics-commands.js +114 -0
- package/dist/metrics-commands.js.map +1 -0
- package/dist/model-commands.d.ts +13 -0
- package/dist/model-commands.js +199 -0
- package/dist/model-commands.js.map +1 -0
- package/dist/model-providers.d.ts +26 -1
- package/dist/model-providers.js +257 -1
- package/dist/model-providers.js.map +1 -1
- package/dist/notifications.d.ts +31 -0
- package/dist/notifications.js +165 -0
- package/dist/notifications.js.map +1 -0
- package/dist/phase-executor.d.ts +18 -0
- package/dist/phase-executor.js +218 -0
- package/dist/phase-executor.js.map +1 -0
- package/dist/release-commands.d.ts +10 -0
- package/dist/release-commands.js +116 -0
- package/dist/release-commands.js.map +1 -1
- package/dist/runtime-adapters.d.ts +5 -1
- package/dist/runtime-adapters.js +27 -0
- package/dist/runtime-adapters.js.map +1 -1
- package/dist/runtime-commands.d.ts +9 -0
- package/dist/runtime-commands.js +156 -0
- package/dist/runtime-commands.js.map +1 -0
- package/dist/runtime-execution-adapters.d.ts +2 -0
- package/dist/runtime-execution-adapters.js +163 -0
- package/dist/runtime-execution-adapters.js.map +1 -0
- package/dist/runtime-execution-renderer.d.ts +10 -0
- package/dist/runtime-execution-renderer.js +110 -0
- package/dist/runtime-execution-renderer.js.map +1 -0
- package/dist/runtime-execution.d.ts +27 -0
- package/dist/runtime-execution.js +147 -0
- package/dist/runtime-execution.js.map +1 -0
- package/dist/skills-commands.d.ts +9 -0
- package/dist/skills-commands.js +130 -0
- package/dist/skills-commands.js.map +1 -0
- package/dist/sprint-commands.d.ts +5 -0
- package/dist/sprint-commands.js +120 -0
- package/dist/sprint-commands.js.map +1 -0
- package/dist/sprint-metrics.d.ts +9 -0
- package/dist/sprint-metrics.js +203 -0
- package/dist/sprint-metrics.js.map +1 -0
- package/dist/telemetry-commands.d.ts +7 -0
- package/dist/telemetry-commands.js +82 -0
- package/dist/telemetry-commands.js.map +1 -0
- package/dist/tool-commands.d.ts +3 -0
- package/dist/tool-commands.js +67 -0
- package/dist/tool-commands.js.map +1 -0
- package/dist/types.d.ts +177 -0
- package/dist/types.js.map +1 -1
- package/dist/workflow-services.d.ts +3 -1
- package/dist/workflow-services.js +16 -6
- package/dist/workflow-services.js.map +1 -1
- package/docs/autonomous-workflow.md +28 -1
- package/docs/benchmark.md +18 -0
- package/docs/runtime-llm-flow.md +80 -9
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,56 @@
|
|
|
2
2
|
|
|
3
3
|
## Unreleased
|
|
4
4
|
|
|
5
|
+
## 0.4.1 - 2026-05-07
|
|
6
|
+
|
|
7
|
+
### Added
|
|
8
|
+
|
|
9
|
+
- Added runtime execution commands for CLI and IDE-hosted agents:
|
|
10
|
+
`runtime brief`, `runtime delegate-plan`, `runtime handoff`, and
|
|
11
|
+
`runtime bootstrap`.
|
|
12
|
+
|
|
13
|
+
### Changed
|
|
14
|
+
|
|
15
|
+
- Split CLI command handlers into focused domain modules while keeping the
|
|
16
|
+
existing command facade stable.
|
|
17
|
+
- Split large autonomous workflow and benchmark test suites into
|
|
18
|
+
behavior-focused files with shared helpers.
|
|
19
|
+
- Runtime documentation now clarifies local CLI/IDE delegation flows that do not
|
|
20
|
+
require direct provider API calls.
|
|
21
|
+
|
|
22
|
+
### Validation
|
|
23
|
+
|
|
24
|
+
- `npm run precommit` passed after the release bump.
|
|
25
|
+
|
|
26
|
+
## 0.4.0 - 2026-05-07
|
|
27
|
+
|
|
28
|
+
### Added
|
|
29
|
+
|
|
30
|
+
- Provider-backed autonomous workflow phases can now execute through the shared
|
|
31
|
+
`ModelProvider` contract instead of deterministic fake-only responses.
|
|
32
|
+
- Added OpenAI Responses API provider routing with `provider=openai`,
|
|
33
|
+
`OPENAI_API_KEY`, optional HTTPS `OPENAI_BASE_URL`, JSON schema response
|
|
34
|
+
formatting, usage normalization, and opt-in smoke coverage.
|
|
35
|
+
- Added Anthropic Claude Messages API provider routing with
|
|
36
|
+
`provider=anthropic`, `ANTHROPIC_API_KEY`, optional HTTPS
|
|
37
|
+
`ANTHROPIC_BASE_URL`, optional `ANTHROPIC_VERSION`, usage normalization, stop
|
|
38
|
+
reason mapping, and opt-in smoke coverage.
|
|
39
|
+
- Added provider policy controls for allowed providers, blocked providers, and
|
|
40
|
+
explicit cross-vendor fallback approval.
|
|
41
|
+
- Autonomous phase execution now records provider provenance and creates
|
|
42
|
+
phase artifacts for provider-backed runs.
|
|
43
|
+
|
|
44
|
+
### Changed
|
|
45
|
+
|
|
46
|
+
- Runtime LLM documentation now covers OpenAI and Anthropic setup, env vars,
|
|
47
|
+
JSON-mode behavior, and fallback policy limits.
|
|
48
|
+
- VS Code extension package version aligned with the CLI package.
|
|
49
|
+
|
|
50
|
+
### Validation
|
|
51
|
+
|
|
52
|
+
- `npm run precommit` passed with OpenAI and Anthropic mocked provider coverage;
|
|
53
|
+
real provider smoke tests remain opt-in through env vars.
|
|
54
|
+
|
|
5
55
|
## 0.3.1 - 2026-05-06
|
|
6
56
|
|
|
7
57
|
### Fixed
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { AutonomousPhase, AutonomousRun, SizingLabel } from "./types.js";
|
|
2
|
+
export type SizingCheckResult = {
|
|
3
|
+
found: true;
|
|
4
|
+
sizing: SizingLabel;
|
|
5
|
+
points?: number;
|
|
6
|
+
} | {
|
|
7
|
+
found: false;
|
|
8
|
+
};
|
|
9
|
+
export declare function checkArchitectSizing(root: string, taskId: string): Promise<SizingCheckResult>;
|
|
10
|
+
export type PhaseOutcome = {
|
|
11
|
+
kind: "done";
|
|
12
|
+
notes: string;
|
|
13
|
+
} | {
|
|
14
|
+
kind: "gate_pause";
|
|
15
|
+
reviewArtifact: string;
|
|
16
|
+
} | {
|
|
17
|
+
kind: "qa_fail";
|
|
18
|
+
notes: string;
|
|
19
|
+
};
|
|
20
|
+
export declare function initPhase(root: string, run: AutonomousRun, phaseIndex: number, retryContext?: string): Promise<AutonomousPhase>;
|
|
21
|
+
export declare function closePhase(root: string, run: AutonomousRun, phaseIndex: number, outcome: PhaseOutcome): Promise<{
|
|
22
|
+
run: AutonomousRun;
|
|
23
|
+
handoffArtifact?: string;
|
|
24
|
+
reviewArtifact?: string;
|
|
25
|
+
}>;
|
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
import { appendEvent, readEvents, writeArtifact } from "./workspace.js";
|
|
2
|
+
import { addTask, createHandoff, updateTask } from "./workflow-services.js";
|
|
3
|
+
import { notifyGatePaused } from "./notifications.js";
|
|
4
|
+
import { AUTONOMOUS_PHASE_SEQUENCE, PHASE_GATES, } from "./autonomous-workflow-constants.js";
|
|
5
|
+
import { persistRun } from "./autonomous-run-store.js";
|
|
6
|
+
import { SIZING_LABELS } from "./types.js";
|
|
7
|
+
export async function checkArchitectSizing(root, taskId) {
|
|
8
|
+
const events = await readEvents(root);
|
|
9
|
+
for (const event of events) {
|
|
10
|
+
if (event.type === "DECISION_RECORDED" &&
|
|
11
|
+
event.taskId === taskId &&
|
|
12
|
+
event.actor === "architect") {
|
|
13
|
+
const sizing = event.metadata.sizing;
|
|
14
|
+
if (typeof sizing === "string" &&
|
|
15
|
+
SIZING_LABELS.includes(sizing)) {
|
|
16
|
+
const points = typeof event.metadata.points === "number"
|
|
17
|
+
? event.metadata.points
|
|
18
|
+
: undefined;
|
|
19
|
+
return {
|
|
20
|
+
found: true,
|
|
21
|
+
sizing: sizing,
|
|
22
|
+
...(points !== undefined ? { points } : {}),
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
return { found: false };
|
|
28
|
+
}
|
|
29
|
+
export async function initPhase(root, run, phaseIndex, retryContext) {
|
|
30
|
+
const def = AUTONOMOUS_PHASE_SEQUENCE[phaseIndex];
|
|
31
|
+
if (!def)
|
|
32
|
+
throw new Error(`invalid phase index: ${phaseIndex}`);
|
|
33
|
+
const now = new Date().toISOString();
|
|
34
|
+
const runSuffix = run.id.slice(-6);
|
|
35
|
+
const iteration = run.phases.filter((p) => p.phase === def.phase).length;
|
|
36
|
+
const phaseTaskId = iteration === 0
|
|
37
|
+
? `${run.taskId}-${def.phase}-${runSuffix}`
|
|
38
|
+
: `${run.taskId}-${def.phase}-${runSuffix}-retry${iteration}`;
|
|
39
|
+
const prevDef = phaseIndex > 0 ? AUTONOMOUS_PHASE_SEQUENCE[phaseIndex - 1] : undefined;
|
|
40
|
+
const prevPhaseTaskId = prevDef
|
|
41
|
+
? `${run.taskId}-${prevDef.phase}-${runSuffix}`
|
|
42
|
+
: undefined;
|
|
43
|
+
await addTask({
|
|
44
|
+
id: phaseTaskId,
|
|
45
|
+
title: `[${def.phase.toUpperCase()}] ${run.taskId}${iteration > 0 ? ` (retry ${iteration})` : ""}`,
|
|
46
|
+
ownerRole: def.role,
|
|
47
|
+
dependencies: prevPhaseTaskId ? [prevPhaseTaskId] : [],
|
|
48
|
+
...(retryContext ? { blockedReason: retryContext } : {}),
|
|
49
|
+
}, root);
|
|
50
|
+
return {
|
|
51
|
+
phase: def.phase,
|
|
52
|
+
role: def.role,
|
|
53
|
+
status: "running",
|
|
54
|
+
taskId: phaseTaskId,
|
|
55
|
+
startedAt: now,
|
|
56
|
+
...(retryContext ? { notes: retryContext } : {}),
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
export async function closePhase(root, run, phaseIndex, outcome) {
|
|
60
|
+
let resolvedOutcome = outcome;
|
|
61
|
+
const now = new Date().toISOString();
|
|
62
|
+
const def = AUTONOMOUS_PHASE_SEQUENCE[phaseIndex];
|
|
63
|
+
const nextDef = AUTONOMOUS_PHASE_SEQUENCE[phaseIndex + 1];
|
|
64
|
+
if (!def)
|
|
65
|
+
throw new Error(`invalid phase index: ${phaseIndex}`);
|
|
66
|
+
const phase = run.phases.find((p) => p.phase === def.phase);
|
|
67
|
+
if (!phase)
|
|
68
|
+
throw new Error(`phase not found in run: ${def.phase}`);
|
|
69
|
+
let handoffArtifact;
|
|
70
|
+
let reviewArtifact;
|
|
71
|
+
if (outcome.kind === "done" && nextDef) {
|
|
72
|
+
const handoffResult = await createHandoff({
|
|
73
|
+
task: run.taskId,
|
|
74
|
+
from: def.role,
|
|
75
|
+
to: nextDef.role,
|
|
76
|
+
changed: `Phase ${def.phase} completed`,
|
|
77
|
+
behavior: def.summary,
|
|
78
|
+
tests: "See phase task evidence",
|
|
79
|
+
commands: "See phase task evidence",
|
|
80
|
+
status: "ready_for_review",
|
|
81
|
+
}, root);
|
|
82
|
+
handoffArtifact = handoffResult.artifact;
|
|
83
|
+
const transitionKey = `${def.phase}→${nextDef.phase}`;
|
|
84
|
+
const needsGate = run.gates === "all" ||
|
|
85
|
+
(run.gates === "phase" && PHASE_GATES.has(transitionKey));
|
|
86
|
+
if (needsGate) {
|
|
87
|
+
const reviewResult = await createGateReview(root, run, def, nextDef, transitionKey);
|
|
88
|
+
reviewArtifact = reviewResult.artifact;
|
|
89
|
+
resolvedOutcome = {
|
|
90
|
+
kind: "gate_pause",
|
|
91
|
+
reviewArtifact: reviewResult.artifact,
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
const updatedPhase = {
|
|
96
|
+
...phase,
|
|
97
|
+
status: outcomeToPhaseStatus(resolvedOutcome),
|
|
98
|
+
...(handoffArtifact !== undefined ? { handoffArtifact } : {}),
|
|
99
|
+
...(reviewArtifact !== undefined ? { reviewArtifact } : {}),
|
|
100
|
+
notes: resolvedOutcome.kind !== "gate_pause"
|
|
101
|
+
? resolvedOutcome.notes
|
|
102
|
+
: `Gate pause — review pending`,
|
|
103
|
+
completedAt: now,
|
|
104
|
+
};
|
|
105
|
+
const updatedPhases = run.phases.map((p) => p.phase === def.phase ? updatedPhase : p);
|
|
106
|
+
const allDone = resolvedOutcome.kind === "done" &&
|
|
107
|
+
!nextDef &&
|
|
108
|
+
updatedPhases.every((p) => p.status === "done");
|
|
109
|
+
const updatedRun = {
|
|
110
|
+
...run,
|
|
111
|
+
phases: updatedPhases,
|
|
112
|
+
qaIterations: def.phase === "qa" && resolvedOutcome.kind === "qa_fail"
|
|
113
|
+
? run.qaIterations + 1
|
|
114
|
+
: run.qaIterations,
|
|
115
|
+
status: resolvedOutcome.kind === "gate_pause"
|
|
116
|
+
? "paused"
|
|
117
|
+
: allDone
|
|
118
|
+
? "done"
|
|
119
|
+
: "running",
|
|
120
|
+
updatedAt: now,
|
|
121
|
+
};
|
|
122
|
+
await persistRun(root, updatedRun);
|
|
123
|
+
if (resolvedOutcome.kind === "gate_pause") {
|
|
124
|
+
await appendEvent(root, {
|
|
125
|
+
type: "AUTONOMOUS_GATE_PAUSED",
|
|
126
|
+
taskId: run.taskId,
|
|
127
|
+
actor: def.role,
|
|
128
|
+
summary: `Gate pause at ${def.phase}→${nextDef?.phase ?? "end"}`,
|
|
129
|
+
metadata: { runId: run.id, phase: def.phase, reviewArtifact },
|
|
130
|
+
});
|
|
131
|
+
if (reviewArtifact) {
|
|
132
|
+
await notifyGatePaused({
|
|
133
|
+
root,
|
|
134
|
+
run: updatedRun,
|
|
135
|
+
transitionKey: `${def.phase}→${nextDef?.phase ?? "end"}`,
|
|
136
|
+
reviewArtifact,
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
else if (resolvedOutcome.kind === "done") {
|
|
141
|
+
await appendEvent(root, {
|
|
142
|
+
type: "AUTONOMOUS_PHASE_DONE",
|
|
143
|
+
taskId: run.taskId,
|
|
144
|
+
actor: def.role,
|
|
145
|
+
summary: `Phase ${def.phase} completed`,
|
|
146
|
+
metadata: { runId: run.id, phase: def.phase, handoffArtifact },
|
|
147
|
+
});
|
|
148
|
+
await updateTask({ id: phase.taskId, status: "done" }, root);
|
|
149
|
+
}
|
|
150
|
+
return {
|
|
151
|
+
run: updatedRun,
|
|
152
|
+
...(handoffArtifact !== undefined ? { handoffArtifact } : {}),
|
|
153
|
+
...(reviewArtifact !== undefined ? { reviewArtifact } : {}),
|
|
154
|
+
};
|
|
155
|
+
}
|
|
156
|
+
async function createGateReview(root, run, from, to, transitionKey) {
|
|
157
|
+
const fileName = `${run.taskId}-gate-${transitionKey.replace("→", "-to-")}-${Date.now()}.md`;
|
|
158
|
+
const content = [
|
|
159
|
+
`# Gate Review: ${transitionKey}`,
|
|
160
|
+
"",
|
|
161
|
+
`- Run: ${run.id}`,
|
|
162
|
+
`- Task: ${run.taskId}`,
|
|
163
|
+
`- Transition: ${from.phase} → ${to.phase}`,
|
|
164
|
+
`- From role: ${from.role}`,
|
|
165
|
+
`- To role: ${to.role}`,
|
|
166
|
+
"",
|
|
167
|
+
"## Checklist",
|
|
168
|
+
`- [ ] ${from.summary}`,
|
|
169
|
+
`- [ ] Acceptance criteria verified`,
|
|
170
|
+
`- [ ] No open blockers`,
|
|
171
|
+
"",
|
|
172
|
+
"## Approval",
|
|
173
|
+
`Approve: orchestra workflow run --task ${run.taskId} --resume ${run.id}`,
|
|
174
|
+
"",
|
|
175
|
+
].join("\n");
|
|
176
|
+
const artifact = await writeArtifact(root, "approvals", fileName, content);
|
|
177
|
+
await appendEvent(root, {
|
|
178
|
+
type: "AUTONOMOUS_GATE_REQUESTED",
|
|
179
|
+
taskId: run.taskId,
|
|
180
|
+
actor: from.role,
|
|
181
|
+
summary: `Gate review requested: ${transitionKey}`,
|
|
182
|
+
artifacts: [artifact],
|
|
183
|
+
metadata: { runId: run.id, transitionKey },
|
|
184
|
+
});
|
|
185
|
+
return { artifact };
|
|
186
|
+
}
|
|
187
|
+
function outcomeToPhaseStatus(outcome) {
|
|
188
|
+
if (outcome.kind === "done")
|
|
189
|
+
return "done";
|
|
190
|
+
if (outcome.kind === "gate_pause")
|
|
191
|
+
return "gate_paused";
|
|
192
|
+
return "qa_failed";
|
|
193
|
+
}
|
|
194
|
+
//# sourceMappingURL=autonomous-phase-lifecycle.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"autonomous-phase-lifecycle.js","sourceRoot":"","sources":["../src/autonomous-phase-lifecycle.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AACxE,OAAO,EAAE,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAC5E,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EACL,yBAAyB,EACzB,WAAW,GACZ,M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string, run: AutonomousRun, reason: string): Promise<AutonomousRun>;
|
|
3
|
+
export declare function markRunDone(root: string, run: AutonomousRun): Promise<AutonomousRun>;
|
|
4
|
+
export declare function resumePhaseIndex(run: AutonomousRun): number;
|
|
5
|
+
export declare function suspendPhaseForClarification(root: string, run: AutonomousRun, phaseIndex: number): Promise<AutonomousRun>;
|
|
6
|
+
export declare function resumePhaseFromClarification(root: string, run: AutonomousRun, phaseIndex: number): Promise<AutonomousRun>;
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { appendEvent } from "./workspace.js";
|
|
2
|
+
import { updateTask } from "./workflow-services.js";
|
|
3
|
+
import { AUTONOMOUS_PHASE_SEQUENCE } from "./autonomous-workflow-constants.js";
|
|
4
|
+
import { persistRun } from "./autonomous-run-store.js";
|
|
5
|
+
export async function markRunFailed(root, run, reason) {
|
|
6
|
+
const now = new Date().toISOString();
|
|
7
|
+
const updated = { ...run, status: "failed", updatedAt: now };
|
|
8
|
+
await persistRun(root, updated);
|
|
9
|
+
await appendEvent(root, {
|
|
10
|
+
type: "AUTONOMOUS_RUN_FAILED",
|
|
11
|
+
taskId: run.taskId,
|
|
12
|
+
actor: "parent",
|
|
13
|
+
summary: reason,
|
|
14
|
+
metadata: { runId: run.id },
|
|
15
|
+
});
|
|
16
|
+
for (const phase of run.phases) {
|
|
17
|
+
if (phase.status === "running" || phase.status === "pending") {
|
|
18
|
+
await updateTask({ id: phase.taskId, status: "canceled" }, root).catch(() => undefined);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
return updated;
|
|
22
|
+
}
|
|
23
|
+
export async function markRunDone(root, run) {
|
|
24
|
+
const now = new Date().toISOString();
|
|
25
|
+
const updated = { ...run, status: "done", updatedAt: now };
|
|
26
|
+
await persistRun(root, updated);
|
|
27
|
+
await appendEvent(root, {
|
|
28
|
+
type: "AUTONOMOUS_RUN_DONE",
|
|
29
|
+
taskId: run.taskId,
|
|
30
|
+
actor: "parent",
|
|
31
|
+
summary: `Autonomous workflow complete`,
|
|
32
|
+
metadata: { runId: run.id },
|
|
33
|
+
});
|
|
34
|
+
return updated;
|
|
35
|
+
}
|
|
36
|
+
export function resumePhaseIndex(run) {
|
|
37
|
+
for (let i = 0; i < AUTONOMOUS_PHASE_SEQUENCE.length; i++) {
|
|
38
|
+
const def = AUTONOMOUS_PHASE_SEQUENCE[i];
|
|
39
|
+
const phase = run.phases.find((p) => p.phase === def.phase);
|
|
40
|
+
if (!phase || phase.status === "running" || phase.status === "pending") {
|
|
41
|
+
return i;
|
|
42
|
+
}
|
|
43
|
+
if (phase.status === "qa_failed")
|
|
44
|
+
return i;
|
|
45
|
+
if (phase.status === "awaiting_clarification")
|
|
46
|
+
return i;
|
|
47
|
+
if (phase.status === "done" || phase.status === "gate_paused")
|
|
48
|
+
continue;
|
|
49
|
+
}
|
|
50
|
+
return -1;
|
|
51
|
+
}
|
|
52
|
+
export async function suspendPhaseForClarification(root, run, phaseIndex) {
|
|
53
|
+
const def = AUTONOMOUS_PHASE_SEQUENCE[phaseIndex];
|
|
54
|
+
if (!def)
|
|
55
|
+
throw new Error(`invalid phase index: ${phaseIndex}`);
|
|
56
|
+
const phase = run.phases.find((p) => p.phase === def.phase);
|
|
57
|
+
if (!phase)
|
|
58
|
+
throw new Error(`phase not found in run: ${def.phase}`);
|
|
59
|
+
const updatedPhases = run.phases.map((p) => p.phase === def.phase
|
|
60
|
+
? { ...p, status: "awaiting_clarification" }
|
|
61
|
+
: p);
|
|
62
|
+
const updated = {
|
|
63
|
+
...run,
|
|
64
|
+
phases: updatedPhases,
|
|
65
|
+
status: "paused",
|
|
66
|
+
updatedAt: new Date().toISOString(),
|
|
67
|
+
};
|
|
68
|
+
await persistRun(root, updated);
|
|
69
|
+
return updated;
|
|
70
|
+
}
|
|
71
|
+
export async function resumePhaseFromClarification(root, run, phaseIndex) {
|
|
72
|
+
const def = AUTONOMOUS_PHASE_SEQUENCE[phaseIndex];
|
|
73
|
+
if (!def)
|
|
74
|
+
throw new Error(`invalid phase index: ${phaseIndex}`);
|
|
75
|
+
const phase = run.phases.find((p) => p.phase === def.phase);
|
|
76
|
+
if (!phase)
|
|
77
|
+
throw new Error(`phase not found in run: ${def.phase}`);
|
|
78
|
+
if (phase.status !== "awaiting_clarification") {
|
|
79
|
+
throw new Error(`phase ${def.phase} is not awaiting clarification (status: ${phase.status})`);
|
|
80
|
+
}
|
|
81
|
+
const updatedPhases = run.phases.map((p) => p.phase === def.phase ? { ...p, status: "running" } : p);
|
|
82
|
+
const updated = {
|
|
83
|
+
...run,
|
|
84
|
+
phases: updatedPhases,
|
|
85
|
+
status: "running",
|
|
86
|
+
updatedAt: new Date().toISOString(),
|
|
87
|
+
};
|
|
88
|
+
await persistRun(root, updated);
|
|
89
|
+
return updated;
|
|
90
|
+
}
|
|
91
|
+
//# sourceMappingURL=autonomous-run-state.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"autonomous-run-state.js","sourceRoot":"","sources":["../src/autonomous-run-state.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AACpD,OAAO,EAAE,yBAAyB,EAAE,MAAM,oCAAoC,CAAC;AAC/E,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AAGvD,MAAM,CAAC,KAAK,UAAU,aAAa,CACjC,IAAY,EACZ,GAAkB,EAClB,MAAc;IAEd,MAAM,GAAG,GAAG,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;IACrC,MAAM,OAAO,GAAkB,EAAE,GAAG,GAAG,EAAE,MAAM,EAAE,QAAQ,EAAE,SAAS,EAAE,GAAG,EAAE,CAAC;IAC5E,MAAM,UAAU,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;IAChC,MAAM,WAAW,CAAC,IAAI,EAAE;QACtB,IAAI,EAAE,uBAAuB;QAC7B,MAAM,EAAE,GAAG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MAAM,EAAE,aAAa;QACrB,MAAM,EAAE,SAAS;QACjB,SAAS,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;KACpC,CAAC;IACF,MAAM,UAAU,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;IAChC,OAAO,OAAO,CAAC;AACjB,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { AutonomousGateMode, AutonomousRun } from "./types.js";
|
|
2
|
+
export declare const AUTONOMOUS_RUNS_FILE = "workflow-runs.jsonl";
|
|
3
|
+
export declare function autonomousRunsPath(root: string): string;
|
|
4
|
+
export type AutonomousRunOptions = {
|
|
5
|
+
taskId: string;
|
|
6
|
+
gates: AutonomousGateMode;
|
|
7
|
+
maxIterations: number;
|
|
8
|
+
};
|
|
9
|
+
export declare function createAutonomousRun(root: string, opts: AutonomousRunOptions): Promise<AutonomousRun>;
|
|
10
|
+
export declare function readAutonomousRun(root: string, id: string): Promise<AutonomousRun | undefined>;
|
|
11
|
+
export declare function listAutonomousRuns(root: string): Promise<AutonomousRun[]>;
|
|
12
|
+
export declare function persistRun(root: string, run: AutonomousRun): Promise<void>;
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { existsSync } from "node:fs";
|
|
2
|
+
import { appendFile, readFile } from "node:fs/promises";
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
import { ensureDir, resolveWorkflowPath } from "./fs-utils.js";
|
|
5
|
+
import { appendEvent } from "./workspace.js";
|
|
6
|
+
export const AUTONOMOUS_RUNS_FILE = "workflow-runs.jsonl";
|
|
7
|
+
export function autonomousRunsPath(root) {
|
|
8
|
+
return resolveWorkflowPath(root, AUTONOMOUS_RUNS_FILE);
|
|
9
|
+
}
|
|
10
|
+
export async function createAutonomousRun(root, opts) {
|
|
11
|
+
const now = new Date().toISOString();
|
|
12
|
+
const run = {
|
|
13
|
+
id: `wfrun-${Date.now()}-${Math.random().toString(36).slice(2, 6)}`,
|
|
14
|
+
taskId: opts.taskId,
|
|
15
|
+
gates: opts.gates,
|
|
16
|
+
maxIterations: opts.maxIterations,
|
|
17
|
+
qaIterations: 0,
|
|
18
|
+
phases: [],
|
|
19
|
+
status: "running",
|
|
20
|
+
createdAt: now,
|
|
21
|
+
updatedAt: now,
|
|
22
|
+
};
|
|
23
|
+
await persistRun(root, run);
|
|
24
|
+
await appendEvent(root, {
|
|
25
|
+
type: "AUTONOMOUS_RUN_STARTED",
|
|
26
|
+
taskId: opts.taskId,
|
|
27
|
+
actor: "parent",
|
|
28
|
+
summary: `Autonomous workflow started [gates=${opts.gates}]`,
|
|
29
|
+
metadata: {
|
|
30
|
+
runId: run.id,
|
|
31
|
+
gates: opts.gates,
|
|
32
|
+
maxIterations: opts.maxIterations,
|
|
33
|
+
},
|
|
34
|
+
});
|
|
35
|
+
return run;
|
|
36
|
+
}
|
|
37
|
+
export async function readAutonomousRun(root, id) {
|
|
38
|
+
const runs = await latestRuns(root);
|
|
39
|
+
return runs.get(id);
|
|
40
|
+
}
|
|
41
|
+
export async function listAutonomousRuns(root) {
|
|
42
|
+
return [...(await latestRuns(root)).values()];
|
|
43
|
+
}
|
|
44
|
+
export async function persistRun(root, run) {
|
|
45
|
+
const file = autonomousRunsPath(root);
|
|
46
|
+
await ensureDir(path.dirname(file));
|
|
47
|
+
await appendFile(file, `${JSON.stringify(run)}\n`, "utf8");
|
|
48
|
+
}
|
|
49
|
+
async function latestRuns(root) {
|
|
50
|
+
const file = autonomousRunsPath(root);
|
|
51
|
+
const latest = new Map();
|
|
52
|
+
if (!existsSync(file))
|
|
53
|
+
return latest;
|
|
54
|
+
const lines = (await readFile(file, "utf8"))
|
|
55
|
+
.trim()
|
|
56
|
+
.split("\n")
|
|
57
|
+
.filter(Boolean);
|
|
58
|
+
for (const line of lines) {
|
|
59
|
+
const run = JSON.parse(line);
|
|
60
|
+
latest.set(run.id, run);
|
|
61
|
+
}
|
|
62
|
+
return latest;
|
|
63
|
+
}
|
|
64
|
+
//# sourceMappingURL=autonomous-run-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EAAE;SACN,KAAK,CAAC,IAAI,CAAC;SACX,MAAM,CAAC,OAAO,CAAC,CAAC;IACnB,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QACzB,MAAM,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAkB,CAAC;QAC9C,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,EAAE,GAAG,CAAC,CAAC;IAC1B,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
// Phase graph: ordered list of [phase-id, role-id, summary]
|
|
2
|
+
export const AUTONOMOUS_PHASE_SEQUENCE = [
|
|
3
|
+
{
|
|
4
|
+
phase: "pm",
|
|
5
|
+
role: "product_manager",
|
|
6
|
+
summary: "Product framing, prioritization, and success metrics",
|
|
7
|
+
},
|
|
8
|
+
{
|
|
9
|
+
phase: "po",
|
|
10
|
+
role: "product_owner",
|
|
11
|
+
summary: "Backlog refinement, story sizing, and acceptance criteria",
|
|
12
|
+
},
|
|
13
|
+
{
|
|
14
|
+
phase: "architect",
|
|
15
|
+
role: "architect",
|
|
16
|
+
summary: "Technical tasking, design decisions, and size estimation",
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
phase: "developer",
|
|
20
|
+
role: "developer",
|
|
21
|
+
summary: "Implementation against acceptance criteria",
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
phase: "qa",
|
|
25
|
+
role: "qa",
|
|
26
|
+
summary: "Verification against acceptance criteria and edge cases",
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
phase: "release",
|
|
30
|
+
role: "release_manager",
|
|
31
|
+
summary: "Release candidate validation and PR creation",
|
|
32
|
+
},
|
|
33
|
+
];
|
|
34
|
+
// Gate transitions that require human approval in 'phase' mode.
|
|
35
|
+
export const PHASE_GATES = new Set(["po→architect", "qa→release"]);
|
|
36
|
+
//# sourceMappingURL=autonomous-workflow-constants.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"autonomous-workflow-constants.js","sourceRoot":"","sources":["../src/autonomous-workflow-constants.ts"],"names":[],"mappings":"AAAA,4DAA4D;AAC5D,MAAM,CAAC,MAAM,yBAAyB,GAIjC;IACH;QACE,KAAK,EAAE,IAAI;QACX,IAAI,EAAE,iBAAiB;QACvB,OAAO,EAAE,sDAAsD;KAChE;IACD;QACE,KAAK,EAAE,IAAI;QACX,IAAI,EAAE,eAAe;QACrB,OAAO,EAAE,2DAA2D;KACrE;IACD;QACE,KAAK,EAAE,WAAW;QAClB,IAAI,EAAE,WAAW;QACjB,OAAO,EAAE,0DAA0D;KACpE;IACD;QACE,KAAK,EAAE,WAAW;QAClB,IAAI,EAAE,WAAW;QACjB,OAAO,EAAE,4CAA4C;KACtD;IACD;QACE,KAAK,EAAE,IAAI;QACX,IAAI,EAAE,IAAI;QACV,OAAO,EAAE,yDAAyD;KACnE;IACD;QACE,KAAK,EAAE,SAAS;QAChB,IAAI,EAAE,iBAAiB;QACvB,OAAO,EAAE,8CAA8C;KACxD;CACF,CAAC;AAEF,gEAAgE;AAChE,MAAM,CAAC,MAAM,WAAW,GAAG,IAAI,GAAG,CAAS,CAAC,cAAc,EAAE,YAAY,CAAC,CAAC,CAAC"}
|
|
@@ -1,45 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
export
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
}
|
|
7
|
-
export declare const AUTONOMOUS_RUNS_FILE = "workflow-runs.jsonl";
|
|
8
|
-
export declare function autonomousRunsPath(root: string): string;
|
|
9
|
-
export type SizingCheckResult = {
|
|
10
|
-
found: true;
|
|
11
|
-
sizing: SizingLabel;
|
|
12
|
-
points?: number;
|
|
13
|
-
} | {
|
|
14
|
-
found: false;
|
|
15
|
-
};
|
|
16
|
-
export declare function checkArchitectSizing(root: string, taskId: string): Promise<SizingCheckResult>;
|
|
17
|
-
export type AutonomousRunOptions = {
|
|
18
|
-
taskId: string;
|
|
19
|
-
gates: AutonomousGateMode;
|
|
20
|
-
maxIterations: number;
|
|
21
|
-
};
|
|
22
|
-
export declare function createAutonomousRun(root: string, opts: AutonomousRunOptions): Promise<AutonomousRun>;
|
|
23
|
-
export declare function readAutonomousRun(root: string, id: string): Promise<AutonomousRun | undefined>;
|
|
24
|
-
export declare function listAutonomousRuns(root: string): Promise<AutonomousRun[]>;
|
|
25
|
-
export type PhaseOutcome = {
|
|
26
|
-
kind: "done";
|
|
27
|
-
notes: string;
|
|
28
|
-
} | {
|
|
29
|
-
kind: "gate_pause";
|
|
30
|
-
reviewArtifact: string;
|
|
31
|
-
} | {
|
|
32
|
-
kind: "qa_fail";
|
|
33
|
-
notes: string;
|
|
34
|
-
};
|
|
35
|
-
export declare function initPhase(root: string, run: AutonomousRun, phaseIndex: number, retryContext?: string): Promise<AutonomousPhase>;
|
|
36
|
-
export declare function closePhase(root: string, run: AutonomousRun, phaseIndex: number, outcome: PhaseOutcome): Promise<{
|
|
37
|
-
run: AutonomousRun;
|
|
38
|
-
handoffArtifact?: string;
|
|
39
|
-
reviewArtifact?: string;
|
|
40
|
-
}>;
|
|
41
|
-
export declare function markRunFailed(root: string, run: AutonomousRun, reason: string): Promise<AutonomousRun>;
|
|
42
|
-
export declare function markRunDone(root: string, run: AutonomousRun): Promise<AutonomousRun>;
|
|
43
|
-
export declare function resumePhaseIndex(run: AutonomousRun): number;
|
|
44
|
-
export declare function suspendPhaseForClarification(root: string, run: AutonomousRun, phaseIndex: number): Promise<AutonomousRun>;
|
|
45
|
-
export declare function resumePhaseFromClarification(root: string, run: AutonomousRun, phaseIndex: number): Promise<AutonomousRun>;
|
|
1
|
+
export { AUTONOMOUS_PHASE_SEQUENCE, PHASE_GATES, } from "./autonomous-workflow-constants.js";
|
|
2
|
+
export { AUTONOMOUS_RUNS_FILE, autonomousRunsPath, createAutonomousRun, listAutonomousRuns, persistRun, readAutonomousRun, } from "./autonomous-run-store.js";
|
|
3
|
+
export { checkArchitectSizing, closePhase, initPhase, } from "./autonomous-phase-lifecycle.js";
|
|
4
|
+
export { markRunDone, markRunFailed, resumePhaseFromClarification, resumePhaseIndex, suspendPhaseForClarification, } from "./autonomous-run-state.js";
|
|
5
|
+
export type { AutonomousRunOptions } from "./autonomous-run-store.js";
|
|
6
|
+
export type { PhaseOutcome, SizingCheckResult, } from "./autonomous-phase-lifecycle.js";
|