@emiliosp/pi-maestro 0.13.1 → 0.15.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/ADR.md +56 -0
- package/CHANGELOG.md +14 -0
- package/README.md +31 -16
- package/ROADMAP.md +50 -16
- package/agents/simplifier.md +2 -1
- package/agents/verifier.md +2 -1
- package/docs/configuration.md +40 -7
- package/docs/glossary.md +1 -1
- package/docs/subagent-integration.md +6 -4
- package/docs/workflow.md +32 -23
- package/extensions/maestro.ts +11 -13
- package/package.json +1 -1
- package/src/config/assertConfiguration.ts +1 -1
- package/src/config/defaults.ts +3 -0
- package/src/config/schema.ts +4 -4
- package/src/maestro/checks/assertEnvironment.ts +25 -12
- package/src/maestro/instructions/getMaestroInstructions.ts +19 -11
- package/src/tools/child/record-builder-handoff.ts +2 -6
- package/src/tools/child/record-simplifier-handoff.ts +2 -1
- package/src/tools/child/record-verifier-handoff.ts +2 -6
- package/src/tools/child/utils/resolveWorkflowContext.ts +2 -2
- package/src/tools/main/mark-spec-ready.ts +8 -3
- package/src/tools/main/resolve-escalations.ts +2 -1
- package/src/tools/main/resolve-findings.ts +6 -6
- package/src/tools/main/run-builder.ts +45 -12
- package/src/tools/main/run-simplifier.ts +1 -0
- package/src/tools/main/run-verifier.ts +17 -5
- package/src/workflow/builder/completeBuilderPass.ts +4 -0
- package/src/workflow/builder/prepareBuilderRun.ts +7 -1
- package/src/workflow/builder/resolveEscalations.ts +4 -0
- package/src/workflow/simplifier/completeSimplifierPass.ts +4 -0
- package/src/workflow/spec/markSpecReady.ts +4 -0
- package/src/workflow/transitions.ts +28 -7
- package/src/workflow/verifier/completeVerifierPass.ts +4 -0
- package/src/workflow/verifier/prepareVerifierRun.ts +7 -1
- package/src/workflow/verifier/resolveFindings.ts +4 -0
|
@@ -3,15 +3,17 @@
|
|
|
3
3
|
* Used: Before Maestro runs a builder pass.
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
+
import type { MaestroConfig } from '#config/schema.ts';
|
|
6
7
|
import maestroSessionState from '#maestro/session/MaestroSessionState.ts';
|
|
7
8
|
import type { MaestroPaths } from '#MaestroPaths.ts';
|
|
8
9
|
import { pathExists } from '#utils/path-exists.ts';
|
|
9
10
|
import { readWorkflowState } from '#workflow/state/readWorkflowState.ts';
|
|
10
|
-
import { WORKFLOW_EVENTS, WORKFLOW_PHASES } from '#workflow/state/schema.ts';
|
|
11
|
+
import { WORKFLOW_EVENTS, WORKFLOW_PHASES, type WorkflowState } from '#workflow/state/schema.ts';
|
|
11
12
|
import { writeWorkflowState } from '#workflow/state/writeWorkflowState.ts';
|
|
12
13
|
import { transitionWorkflow } from '#workflow/transitions.ts';
|
|
13
14
|
|
|
14
15
|
export type BuilderRun = {
|
|
16
|
+
state: WorkflowState;
|
|
15
17
|
specId: string;
|
|
16
18
|
projectRoot: string;
|
|
17
19
|
};
|
|
@@ -38,11 +40,13 @@ async function assertBuilderRunBase({ paths, specId }: AssertBuilderRunBaseInput
|
|
|
38
40
|
}
|
|
39
41
|
|
|
40
42
|
type PrepareBuilderRunInput = {
|
|
43
|
+
config: MaestroConfig;
|
|
41
44
|
paths: MaestroPaths;
|
|
42
45
|
specId: string;
|
|
43
46
|
};
|
|
44
47
|
|
|
45
48
|
export const prepareBuilderRun = async ({
|
|
49
|
+
config,
|
|
46
50
|
paths,
|
|
47
51
|
specId,
|
|
48
52
|
}: PrepareBuilderRunInput): Promise<BuilderRun> => {
|
|
@@ -60,6 +64,7 @@ export const prepareBuilderRun = async ({
|
|
|
60
64
|
const currentState = await readWorkflowState(workflowPath);
|
|
61
65
|
|
|
62
66
|
const nextState = transitionWorkflow({
|
|
67
|
+
config,
|
|
63
68
|
state: currentState,
|
|
64
69
|
event: WORKFLOW_EVENTS.RUN_BUILDER,
|
|
65
70
|
});
|
|
@@ -70,6 +75,7 @@ export const prepareBuilderRun = async ({
|
|
|
70
75
|
});
|
|
71
76
|
|
|
72
77
|
return {
|
|
78
|
+
state: nextState,
|
|
73
79
|
specId,
|
|
74
80
|
projectRoot: paths.getProjectRoot(),
|
|
75
81
|
};
|
|
@@ -10,6 +10,7 @@ import {
|
|
|
10
10
|
type EscalationResolution,
|
|
11
11
|
} from '#artifacts/builder-handoff/schema.ts';
|
|
12
12
|
import { writeBuilderHandoff } from '#artifacts/builder-handoff/writeBuilderHandoff.ts';
|
|
13
|
+
import type { MaestroConfig } from '#config/schema.ts';
|
|
13
14
|
import type { MaestroPaths } from '#MaestroPaths.ts';
|
|
14
15
|
import { getWorkflowEventBySpecChangeRequired } from '#workflow/builder/utils/getWorkflowEventBySpecChangeRequired.ts';
|
|
15
16
|
import { readWorkflowState } from '#workflow/state/readWorkflowState.ts';
|
|
@@ -57,6 +58,7 @@ const applyEscalationDecisions = ({ escalations, decisions }: ApplyEscalationDec
|
|
|
57
58
|
};
|
|
58
59
|
|
|
59
60
|
type ResolveEscalationsInput = {
|
|
61
|
+
config: MaestroConfig;
|
|
60
62
|
paths: MaestroPaths;
|
|
61
63
|
specId: string;
|
|
62
64
|
specChangeRequired: boolean;
|
|
@@ -64,6 +66,7 @@ type ResolveEscalationsInput = {
|
|
|
64
66
|
};
|
|
65
67
|
|
|
66
68
|
export const resolveEscalations = async ({
|
|
69
|
+
config,
|
|
67
70
|
paths,
|
|
68
71
|
specId,
|
|
69
72
|
specChangeRequired,
|
|
@@ -95,6 +98,7 @@ export const resolveEscalations = async ({
|
|
|
95
98
|
const nextHandoff = { ...handoff, escalations };
|
|
96
99
|
|
|
97
100
|
const nextState = transitionWorkflow({
|
|
101
|
+
config,
|
|
98
102
|
state,
|
|
99
103
|
event: getWorkflowEventBySpecChangeRequired(specChangeRequired),
|
|
100
104
|
});
|
|
@@ -7,6 +7,7 @@ import { mkdir } from 'node:fs/promises';
|
|
|
7
7
|
import { dirname } from 'node:path';
|
|
8
8
|
|
|
9
9
|
import { assertSimplifierHandoff } from '#artifacts/simplifier-handoff/assertSimplifierHandoff.ts';
|
|
10
|
+
import type { MaestroConfig } from '#config/schema.ts';
|
|
10
11
|
import type { MaestroPaths } from '#MaestroPaths.ts';
|
|
11
12
|
import { writeJson } from '#utils/write-json.ts';
|
|
12
13
|
import { readWorkflowState } from '#workflow/state/readWorkflowState.ts';
|
|
@@ -15,12 +16,14 @@ import { writeWorkflowState } from '#workflow/state/writeWorkflowState.ts';
|
|
|
15
16
|
import { transitionWorkflow } from '#workflow/transitions.ts';
|
|
16
17
|
|
|
17
18
|
type CompleteSimplifierPassInput = {
|
|
19
|
+
config: MaestroConfig;
|
|
18
20
|
paths: MaestroPaths;
|
|
19
21
|
specId: string;
|
|
20
22
|
handoff: unknown;
|
|
21
23
|
};
|
|
22
24
|
|
|
23
25
|
export const completeSimplifierPass = async ({
|
|
26
|
+
config,
|
|
24
27
|
paths,
|
|
25
28
|
specId,
|
|
26
29
|
handoff,
|
|
@@ -46,6 +49,7 @@ export const completeSimplifierPass = async ({
|
|
|
46
49
|
await writeJson({ path: handoffPath, data: input.handoff });
|
|
47
50
|
|
|
48
51
|
const nextState = transitionWorkflow({
|
|
52
|
+
config,
|
|
49
53
|
state,
|
|
50
54
|
event: WORKFLOW_EVENTS.SIMPLIFIER_DONE,
|
|
51
55
|
});
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
|
|
6
6
|
import { readFile } from 'node:fs/promises';
|
|
7
7
|
|
|
8
|
+
import type { MaestroConfig } from '#config/schema.ts';
|
|
8
9
|
import type { MaestroPaths } from '#MaestroPaths.ts';
|
|
9
10
|
import { pathExists } from '#utils/path-exists.ts';
|
|
10
11
|
import { readWorkflowState } from '#workflow/state/readWorkflowState.ts';
|
|
@@ -22,12 +23,14 @@ function assertAcceptanceCriterionOrdering(markdown: string): void {
|
|
|
22
23
|
}
|
|
23
24
|
|
|
24
25
|
type MarkSpecReadyInput = {
|
|
26
|
+
config: MaestroConfig;
|
|
25
27
|
paths: MaestroPaths;
|
|
26
28
|
specId: string;
|
|
27
29
|
activeWorkflowSpecId: string | null;
|
|
28
30
|
};
|
|
29
31
|
|
|
30
32
|
export const markSpecReady = async ({
|
|
33
|
+
config,
|
|
31
34
|
paths,
|
|
32
35
|
specId,
|
|
33
36
|
activeWorkflowSpecId,
|
|
@@ -62,6 +65,7 @@ export const markSpecReady = async ({
|
|
|
62
65
|
}
|
|
63
66
|
|
|
64
67
|
const state = transitionWorkflow({
|
|
68
|
+
config,
|
|
65
69
|
state: current,
|
|
66
70
|
event: WORKFLOW_EVENTS.MARK_SPEC_READY,
|
|
67
71
|
});
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
* Used: When a workflow event moves Maestro to its next phase.
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
+
import type { MaestroConfig } from '#config/schema.ts';
|
|
6
7
|
import {
|
|
7
8
|
assertWorkflowState,
|
|
8
9
|
WORKFLOW_EVENTS,
|
|
@@ -14,13 +15,26 @@ import {
|
|
|
14
15
|
|
|
15
16
|
type WorkflowTransition = {
|
|
16
17
|
from: WorkflowPhase[];
|
|
17
|
-
to: WorkflowPhase;
|
|
18
|
+
to: WorkflowPhase | ((config: MaestroConfig) => WorkflowPhase);
|
|
18
19
|
};
|
|
19
20
|
|
|
21
|
+
const hasDynamicDestinationBasedOnConfig = (
|
|
22
|
+
destination: WorkflowTransition['to'],
|
|
23
|
+
): destination is (config: MaestroConfig) => WorkflowPhase => typeof destination === 'function';
|
|
24
|
+
|
|
25
|
+
const getSimplifierDestination = (config: MaestroConfig): WorkflowPhase =>
|
|
26
|
+
config.simplifier.required ? WORKFLOW_PHASES.SIMPLIFIER_RUNNING : WORKFLOW_PHASES.CANDIDATE_READY;
|
|
27
|
+
|
|
28
|
+
const getSpecReadyDestination = (config: MaestroConfig): WorkflowPhase =>
|
|
29
|
+
config.builder.required ? WORKFLOW_PHASES.READY_FOR_BUILDER : WORKFLOW_PHASES.CANDIDATE_READY;
|
|
30
|
+
|
|
31
|
+
const getBuilderDoneDestination = (config: MaestroConfig): WorkflowPhase =>
|
|
32
|
+
config.verifier.required ? WORKFLOW_PHASES.READY_FOR_VERIFIER : getSimplifierDestination(config);
|
|
33
|
+
|
|
20
34
|
export const WORKFLOW_TRANSITIONS: Record<WorkflowEvent, WorkflowTransition> = {
|
|
21
35
|
[WORKFLOW_EVENTS.MARK_SPEC_READY]: {
|
|
22
36
|
from: [WORKFLOW_PHASES.DRAFTING_SPEC],
|
|
23
|
-
to:
|
|
37
|
+
to: getSpecReadyDestination,
|
|
24
38
|
},
|
|
25
39
|
[WORKFLOW_EVENTS.RUN_BUILDER]: {
|
|
26
40
|
from: [WORKFLOW_PHASES.READY_FOR_BUILDER],
|
|
@@ -40,7 +54,7 @@ export const WORKFLOW_TRANSITIONS: Record<WorkflowEvent, WorkflowTransition> = {
|
|
|
40
54
|
},
|
|
41
55
|
[WORKFLOW_EVENTS.BUILDER_DONE]: {
|
|
42
56
|
from: [WORKFLOW_PHASES.BUILDER_RUNNING],
|
|
43
|
-
to:
|
|
57
|
+
to: getBuilderDoneDestination,
|
|
44
58
|
},
|
|
45
59
|
[WORKFLOW_EVENTS.RUN_VERIFIER]: {
|
|
46
60
|
from: [WORKFLOW_PHASES.READY_FOR_VERIFIER],
|
|
@@ -52,11 +66,11 @@ export const WORKFLOW_TRANSITIONS: Record<WorkflowEvent, WorkflowTransition> = {
|
|
|
52
66
|
},
|
|
53
67
|
[WORKFLOW_EVENTS.VERIFIER_DONE]: {
|
|
54
68
|
from: [WORKFLOW_PHASES.VERIFIER_RUNNING],
|
|
55
|
-
to:
|
|
69
|
+
to: getSimplifierDestination,
|
|
56
70
|
},
|
|
57
71
|
[WORKFLOW_EVENTS.OWNER_REJECT_FINDINGS]: {
|
|
58
72
|
from: [WORKFLOW_PHASES.FINDING_DECISIONS],
|
|
59
|
-
to:
|
|
73
|
+
to: getSimplifierDestination,
|
|
60
74
|
},
|
|
61
75
|
[WORKFLOW_EVENTS.SIMPLIFIER_DONE]: {
|
|
62
76
|
from: [WORKFLOW_PHASES.SIMPLIFIER_RUNNING],
|
|
@@ -75,9 +89,14 @@ export const WORKFLOW_TRANSITIONS: Record<WorkflowEvent, WorkflowTransition> = {
|
|
|
75
89
|
type TransitionWorkflowInput = {
|
|
76
90
|
state: WorkflowState;
|
|
77
91
|
event: WorkflowEvent;
|
|
92
|
+
config: MaestroConfig;
|
|
78
93
|
};
|
|
79
94
|
|
|
80
|
-
export const transitionWorkflow = ({
|
|
95
|
+
export const transitionWorkflow = ({
|
|
96
|
+
state,
|
|
97
|
+
event,
|
|
98
|
+
config,
|
|
99
|
+
}: TransitionWorkflowInput): WorkflowState => {
|
|
81
100
|
assertWorkflowState(state);
|
|
82
101
|
const transition = WORKFLOW_TRANSITIONS[event];
|
|
83
102
|
|
|
@@ -92,6 +111,8 @@ export const transitionWorkflow = ({ state, event }: TransitionWorkflowInput): W
|
|
|
92
111
|
return {
|
|
93
112
|
version: state.version,
|
|
94
113
|
specId: state.specId,
|
|
95
|
-
phase: transition.to
|
|
114
|
+
phase: hasDynamicDestinationBasedOnConfig(transition.to)
|
|
115
|
+
? transition.to(config)
|
|
116
|
+
: transition.to,
|
|
96
117
|
};
|
|
97
118
|
};
|
|
@@ -8,6 +8,7 @@ import { mkdir, readFile } from 'node:fs/promises';
|
|
|
8
8
|
import { assertVerifierHandoff } from '#artifacts/verifier-handoff/assertVerifierHandoff.ts';
|
|
9
9
|
import type { VerifierHandoff } from '#artifacts/verifier-handoff/schema.ts';
|
|
10
10
|
import { writeVerifierHandoff } from '#artifacts/verifier-handoff/writeVerifierHandoff.ts';
|
|
11
|
+
import type { MaestroConfig } from '#config/schema.ts';
|
|
11
12
|
import type { MaestroPaths } from '#MaestroPaths.ts';
|
|
12
13
|
import { readWorkflowState } from '#workflow/state/readWorkflowState.ts';
|
|
13
14
|
import { WORKFLOW_PHASES, type WorkflowState } from '#workflow/state/schema.ts';
|
|
@@ -24,12 +25,14 @@ export type CompletedVerifierPass = {
|
|
|
24
25
|
};
|
|
25
26
|
|
|
26
27
|
type CompleteVerifierPassInput = {
|
|
28
|
+
config: MaestroConfig;
|
|
27
29
|
paths: MaestroPaths;
|
|
28
30
|
specId: string;
|
|
29
31
|
handoff: unknown;
|
|
30
32
|
};
|
|
31
33
|
|
|
32
34
|
export const completeVerifierPass = async ({
|
|
35
|
+
config,
|
|
33
36
|
paths,
|
|
34
37
|
specId,
|
|
35
38
|
handoff: draftHandoff,
|
|
@@ -64,6 +67,7 @@ export const completeVerifierPass = async ({
|
|
|
64
67
|
});
|
|
65
68
|
|
|
66
69
|
const nextState = transitionWorkflow({
|
|
70
|
+
config,
|
|
67
71
|
state: currentState,
|
|
68
72
|
event: getWorkflowEventByVerifierHandoff(handoff),
|
|
69
73
|
});
|
|
@@ -3,23 +3,27 @@
|
|
|
3
3
|
* Used: When Maestro starts a verifier pass.
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
+
import type { MaestroConfig } from '#config/schema.ts';
|
|
6
7
|
import type { MaestroPaths } from '#MaestroPaths.ts';
|
|
7
8
|
import { readWorkflowState } from '#workflow/state/readWorkflowState.ts';
|
|
8
|
-
import { WORKFLOW_EVENTS, WORKFLOW_PHASES } from '#workflow/state/schema.ts';
|
|
9
|
+
import { WORKFLOW_EVENTS, WORKFLOW_PHASES, type WorkflowState } from '#workflow/state/schema.ts';
|
|
9
10
|
import { writeWorkflowState } from '#workflow/state/writeWorkflowState.ts';
|
|
10
11
|
import { transitionWorkflow } from '#workflow/transitions.ts';
|
|
11
12
|
|
|
12
13
|
export type VerifierRun = {
|
|
14
|
+
state: WorkflowState;
|
|
13
15
|
specId: string;
|
|
14
16
|
projectRoot: string;
|
|
15
17
|
};
|
|
16
18
|
|
|
17
19
|
type PrepareVerifierRunInput = {
|
|
20
|
+
config: MaestroConfig;
|
|
18
21
|
paths: MaestroPaths;
|
|
19
22
|
specId: string;
|
|
20
23
|
};
|
|
21
24
|
|
|
22
25
|
export const prepareVerifierRun = async ({
|
|
26
|
+
config,
|
|
23
27
|
paths,
|
|
24
28
|
specId,
|
|
25
29
|
}: PrepareVerifierRunInput): Promise<VerifierRun> => {
|
|
@@ -40,6 +44,7 @@ export const prepareVerifierRun = async ({
|
|
|
40
44
|
}
|
|
41
45
|
|
|
42
46
|
const nextState = transitionWorkflow({
|
|
47
|
+
config,
|
|
43
48
|
state: currentState,
|
|
44
49
|
event: WORKFLOW_EVENTS.RUN_VERIFIER,
|
|
45
50
|
});
|
|
@@ -50,6 +55,7 @@ export const prepareVerifierRun = async ({
|
|
|
50
55
|
});
|
|
51
56
|
|
|
52
57
|
return {
|
|
58
|
+
state: nextState,
|
|
53
59
|
specId,
|
|
54
60
|
projectRoot,
|
|
55
61
|
};
|
|
@@ -7,6 +7,7 @@ import { assertVerifierHandoff } from '#artifacts/verifier-handoff/assertVerifie
|
|
|
7
7
|
import { readVerifierHandoff } from '#artifacts/verifier-handoff/readVerifierHandoff.ts';
|
|
8
8
|
import type { VerifierFinding, VerifierHandoff } from '#artifacts/verifier-handoff/schema.ts';
|
|
9
9
|
import { FINDING_DECISIONS } from '#artifacts/verifier-handoff/schema.ts';
|
|
10
|
+
import type { MaestroConfig } from '#config/schema.ts';
|
|
10
11
|
import type { MaestroPaths } from '#MaestroPaths.ts';
|
|
11
12
|
import { writeJson } from '#utils/write-json.ts';
|
|
12
13
|
import { readWorkflowState } from '#workflow/state/readWorkflowState.ts';
|
|
@@ -127,12 +128,14 @@ const getSavedFindingDecision = (decision: FindingDecision | undefined): SavedFi
|
|
|
127
128
|
};
|
|
128
129
|
|
|
129
130
|
type ResolveFindingsInput = {
|
|
131
|
+
config: MaestroConfig;
|
|
130
132
|
paths: MaestroPaths;
|
|
131
133
|
specId: string;
|
|
132
134
|
decisions: FindingDecision[];
|
|
133
135
|
};
|
|
134
136
|
|
|
135
137
|
export const resolveFindings = async ({
|
|
138
|
+
config,
|
|
136
139
|
paths,
|
|
137
140
|
specId,
|
|
138
141
|
decisions,
|
|
@@ -147,6 +150,7 @@ export const resolveFindings = async ({
|
|
|
147
150
|
const nextHandoff = { ...handoff, findings };
|
|
148
151
|
|
|
149
152
|
const nextState = transitionWorkflow({
|
|
153
|
+
config,
|
|
150
154
|
state,
|
|
151
155
|
event: getWorkflowEventByVerifierHandoff(nextHandoff),
|
|
152
156
|
});
|