@emiliosp/pi-maestro 0.14.0 → 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.
Files changed (35) hide show
  1. package/ADR.md +28 -0
  2. package/CHANGELOG.md +8 -0
  3. package/README.md +31 -17
  4. package/ROADMAP.md +25 -17
  5. package/agents/simplifier.md +2 -1
  6. package/agents/verifier.md +2 -1
  7. package/docs/configuration.md +31 -2
  8. package/docs/glossary.md +1 -1
  9. package/docs/subagent-integration.md +6 -4
  10. package/docs/workflow.md +32 -23
  11. package/extensions/maestro.ts +11 -13
  12. package/package.json +1 -1
  13. package/src/config/defaults.ts +3 -0
  14. package/src/config/schema.ts +2 -0
  15. package/src/maestro/checks/assertEnvironment.ts +24 -9
  16. package/src/maestro/instructions/getMaestroInstructions.ts +19 -11
  17. package/src/tools/child/record-builder-handoff.ts +2 -6
  18. package/src/tools/child/record-simplifier-handoff.ts +2 -1
  19. package/src/tools/child/record-verifier-handoff.ts +2 -6
  20. package/src/tools/child/utils/resolveWorkflowContext.ts +2 -2
  21. package/src/tools/main/mark-spec-ready.ts +8 -3
  22. package/src/tools/main/resolve-escalations.ts +2 -1
  23. package/src/tools/main/resolve-findings.ts +6 -6
  24. package/src/tools/main/run-builder.ts +45 -12
  25. package/src/tools/main/run-simplifier.ts +1 -0
  26. package/src/tools/main/run-verifier.ts +17 -5
  27. package/src/workflow/builder/completeBuilderPass.ts +4 -0
  28. package/src/workflow/builder/prepareBuilderRun.ts +7 -1
  29. package/src/workflow/builder/resolveEscalations.ts +4 -0
  30. package/src/workflow/simplifier/completeSimplifierPass.ts +4 -0
  31. package/src/workflow/spec/markSpecReady.ts +4 -0
  32. package/src/workflow/transitions.ts +28 -7
  33. package/src/workflow/verifier/completeVerifierPass.ts +4 -0
  34. package/src/workflow/verifier/prepareVerifierRun.ts +7 -1
  35. package/src/workflow/verifier/resolveFindings.ts +4 -0
@@ -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: WORKFLOW_PHASES.READY_FOR_BUILDER,
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: WORKFLOW_PHASES.READY_FOR_VERIFIER,
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: WORKFLOW_PHASES.SIMPLIFIER_RUNNING,
69
+ to: getSimplifierDestination,
56
70
  },
57
71
  [WORKFLOW_EVENTS.OWNER_REJECT_FINDINGS]: {
58
72
  from: [WORKFLOW_PHASES.FINDING_DECISIONS],
59
- to: WORKFLOW_PHASES.SIMPLIFIER_RUNNING,
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 = ({ state, event }: TransitionWorkflowInput): WorkflowState => {
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
  });