@emiliosp/pi-maestro 0.1.1 → 0.1.2
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 +5 -5
- package/agents/verifier.md +1 -1
- package/docs/configuration.md +7 -18
- package/docs/subagent-integration.md +15 -14
- package/docs/workflow.md +64 -83
- package/extensions/maestro.ts +12 -12
- package/package.json +1 -1
- package/src/config/loadConfiguration.ts +11 -76
- package/src/maestro/instructions/getMaestroInstructions.ts +2 -2
- package/src/maestro/session/MaestroSessionState.ts +13 -0
- package/src/maestro/status/refreshMaestroStatus.ts +2 -2
- package/src/tools/child/record-verifier-handoff.ts +11 -7
- package/src/tools/child/utils/resolveWorkflowContext.ts +2 -2
- package/src/tools/main/create-spec.ts +2 -2
- package/src/tools/main/mark-spec-ready.ts +4 -4
- package/src/tools/main/resolve-escalation.ts +4 -4
- package/src/tools/main/resolve-findings.ts +3 -3
- package/src/tools/main/{launch-builder.ts → run-builder.ts} +26 -26
- package/src/tools/main/{launch-verifier.ts → run-verifier.ts} +67 -62
- package/src/tools/utils/pi-subagent-delegation.ts +1 -1
- package/src/tools/utils/{resolveToolLaunchContext.ts → resolveToolRunContext.ts} +3 -3
- package/src/workflow/builder/assertBuilderProtocolUnchanged.ts +3 -1
- package/src/workflow/builder/{prepareBuilderLauncher.ts → prepareBuilderRun.ts} +14 -14
- package/src/workflow/state/schema.ts +2 -3
- package/src/workflow/transitions.ts +2 -6
- package/src/workflow/verifier/{prepareVerifierLaunch.ts → prepareVerifierRun.ts} +11 -23
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Objective: Prepare a committed builder
|
|
3
|
-
* Used: Before Maestro
|
|
2
|
+
* Objective: Prepare a committed builder run checkpoint in the current checkout.
|
|
3
|
+
* Used: Before Maestro runs a builder pass.
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
import { rm } from 'node:fs/promises';
|
|
@@ -14,22 +14,22 @@ import { WORKFLOW_EVENTS, WORKFLOW_PHASES } from '#workflow/state/schema.ts';
|
|
|
14
14
|
import { writeWorkflowState } from '#workflow/state/writeWorkflowState.ts';
|
|
15
15
|
import { transitionWorkflow } from '#workflow/transitions.ts';
|
|
16
16
|
|
|
17
|
-
export type
|
|
17
|
+
export type BuilderRun = {
|
|
18
18
|
specId: string;
|
|
19
19
|
revision: number;
|
|
20
20
|
repositoryRoot: string;
|
|
21
21
|
checkpointCommit: string;
|
|
22
22
|
};
|
|
23
23
|
|
|
24
|
-
type
|
|
24
|
+
type AssertBuilderRunBaseInput = {
|
|
25
25
|
paths: MaestroPaths;
|
|
26
26
|
specId: string;
|
|
27
27
|
};
|
|
28
28
|
|
|
29
|
-
async function
|
|
29
|
+
async function assertBuilderRunBase({
|
|
30
30
|
paths,
|
|
31
31
|
specId,
|
|
32
|
-
}:
|
|
32
|
+
}: AssertBuilderRunBaseInput): Promise<void> {
|
|
33
33
|
const state = await readWorkflowState(paths.getWorkflowPath(specId));
|
|
34
34
|
|
|
35
35
|
if (state.specId !== specId) {
|
|
@@ -39,13 +39,13 @@ async function assertBuilderLaunchBase({
|
|
|
39
39
|
}
|
|
40
40
|
|
|
41
41
|
if (state.phase !== WORKFLOW_PHASES.READY_FOR_BUILDER) {
|
|
42
|
-
throw new Error(`Builder
|
|
42
|
+
throw new Error(`Builder run is not valid from phase "${state.phase}".`);
|
|
43
43
|
}
|
|
44
44
|
|
|
45
45
|
const status = await getRepositoryStatus(paths.getRepositoryRoot());
|
|
46
46
|
|
|
47
47
|
if (!status.clean) {
|
|
48
|
-
throw new Error('Builder
|
|
48
|
+
throw new Error('Builder run requires a clean current checkout.');
|
|
49
49
|
}
|
|
50
50
|
|
|
51
51
|
if (!(await pathExists(paths.getSpecFilePath(specId)))) {
|
|
@@ -53,24 +53,24 @@ async function assertBuilderLaunchBase({
|
|
|
53
53
|
}
|
|
54
54
|
}
|
|
55
55
|
|
|
56
|
-
type
|
|
56
|
+
type PrepareBuilderRunInput = {
|
|
57
57
|
paths: MaestroPaths;
|
|
58
58
|
specId: string;
|
|
59
59
|
};
|
|
60
60
|
|
|
61
|
-
export const
|
|
61
|
+
export const prepareBuilderRun = async ({
|
|
62
62
|
paths,
|
|
63
63
|
specId,
|
|
64
|
-
}:
|
|
64
|
+
}: PrepareBuilderRunInput): Promise<BuilderRun> => {
|
|
65
65
|
const activeSpecId = maestroSessionState.getActiveSpecId();
|
|
66
66
|
|
|
67
67
|
if (activeSpecId !== specId) {
|
|
68
68
|
throw new Error(
|
|
69
|
-
`Builder
|
|
69
|
+
`Builder run requires active Maestro spec "${specId}", found "${activeSpecId ?? 'none'}".`,
|
|
70
70
|
);
|
|
71
71
|
}
|
|
72
72
|
|
|
73
|
-
await
|
|
73
|
+
await assertBuilderRunBase({ paths, specId });
|
|
74
74
|
|
|
75
75
|
const workflowPath = paths.getWorkflowPath(specId);
|
|
76
76
|
const handoffPath = paths.getBuilderHandoffPath(specId);
|
|
@@ -83,7 +83,7 @@ export const prepareBuilderLaunch = async ({
|
|
|
83
83
|
|
|
84
84
|
const nextState = transitionWorkflow({
|
|
85
85
|
state: currentState,
|
|
86
|
-
event: WORKFLOW_EVENTS.
|
|
86
|
+
event: WORKFLOW_EVENTS.RUN_BUILDER,
|
|
87
87
|
});
|
|
88
88
|
|
|
89
89
|
await writeWorkflowState({
|
|
@@ -23,13 +23,12 @@ export const WORKFLOW_PHASES = {
|
|
|
23
23
|
|
|
24
24
|
export const WORKFLOW_EVENTS = {
|
|
25
25
|
MARK_SPEC_READY: 'mark-spec-ready',
|
|
26
|
-
|
|
26
|
+
RUN_BUILDER: 'run-builder',
|
|
27
27
|
OPEN_ESCALATION: 'open-escalation',
|
|
28
28
|
RESOLVE_ESCALATION: 'resolve-escalation',
|
|
29
29
|
BUILDER_FAILED: 'builder-failed',
|
|
30
30
|
BUILDER_DONE: 'builder-done',
|
|
31
|
-
|
|
32
|
-
RETRY_VERIFIER: 'retry-verifier',
|
|
31
|
+
RUN_VERIFIER: 'run-verifier',
|
|
33
32
|
VERIFIER_FOUND_FINDINGS: 'verifier-found-findings',
|
|
34
33
|
VERIFIER_APPROVED: 'verifier-approved',
|
|
35
34
|
REJECT_FINDINGS: 'reject-findings',
|
|
@@ -26,7 +26,7 @@ export const WORKFLOW_TRANSITIONS: Record<WorkflowEvent, WorkflowTransition> = {
|
|
|
26
26
|
],
|
|
27
27
|
to: WORKFLOW_PHASES.READY_FOR_BUILDER,
|
|
28
28
|
},
|
|
29
|
-
[WORKFLOW_EVENTS.
|
|
29
|
+
[WORKFLOW_EVENTS.RUN_BUILDER]: {
|
|
30
30
|
from: [WORKFLOW_PHASES.READY_FOR_BUILDER],
|
|
31
31
|
to: WORKFLOW_PHASES.BUILDER_RUNNING,
|
|
32
32
|
},
|
|
@@ -46,14 +46,10 @@ export const WORKFLOW_TRANSITIONS: Record<WorkflowEvent, WorkflowTransition> = {
|
|
|
46
46
|
from: [WORKFLOW_PHASES.BUILDER_RUNNING],
|
|
47
47
|
to: WORKFLOW_PHASES.READY_FOR_VERIFIER,
|
|
48
48
|
},
|
|
49
|
-
[WORKFLOW_EVENTS.
|
|
49
|
+
[WORKFLOW_EVENTS.RUN_VERIFIER]: {
|
|
50
50
|
from: [WORKFLOW_PHASES.READY_FOR_VERIFIER],
|
|
51
51
|
to: WORKFLOW_PHASES.VERIFIER_RUNNING,
|
|
52
52
|
},
|
|
53
|
-
[WORKFLOW_EVENTS.RETRY_VERIFIER]: {
|
|
54
|
-
from: [WORKFLOW_PHASES.VERIFIER_RUNNING],
|
|
55
|
-
to: WORKFLOW_PHASES.VERIFIER_RUNNING,
|
|
56
|
-
},
|
|
57
53
|
[WORKFLOW_EVENTS.VERIFIER_FOUND_FINDINGS]: {
|
|
58
54
|
from: [WORKFLOW_PHASES.VERIFIER_RUNNING],
|
|
59
55
|
to: WORKFLOW_PHASES.FINDINGS_DECISION,
|
|
@@ -1,21 +1,20 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Objective: Prepare a committed verifier
|
|
2
|
+
* Objective: Prepare a committed verifier run checkpoint in the current checkout.
|
|
3
3
|
* Used: When Maestro starts a verifier pass.
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
import { rm } from 'node:fs/promises';
|
|
7
7
|
import { createWorkflowCheckpointCommit } from '#git/commits/createWorkflowCheckpointCommit.ts';
|
|
8
|
-
import { getParentCommit } from '#git/history/getParentCommit.ts';
|
|
9
|
-
import { getHeadCommit } from '#git/repository/getHeadCommit.ts';
|
|
10
8
|
import { getRepositoryStatus } from '#git/repository/getRepositoryStatus.ts';
|
|
11
9
|
import type { MaestroPaths } from '#MaestroPaths.ts';
|
|
10
|
+
import maestroSessionState from '#maestro/session/MaestroSessionState.ts';
|
|
12
11
|
import { pathExists } from '#utils/path-exists.ts';
|
|
13
12
|
import { readWorkflowState } from '#workflow/state/readWorkflowState.ts';
|
|
14
13
|
import { WORKFLOW_EVENTS, WORKFLOW_PHASES } from '#workflow/state/schema.ts';
|
|
15
14
|
import { writeWorkflowState } from '#workflow/state/writeWorkflowState.ts';
|
|
16
15
|
import { transitionWorkflow } from '#workflow/transitions.ts';
|
|
17
16
|
|
|
18
|
-
export type
|
|
17
|
+
export type VerifierRun = {
|
|
19
18
|
specId: string;
|
|
20
19
|
repositoryRoot: string;
|
|
21
20
|
candidateCommit: string;
|
|
@@ -23,15 +22,15 @@ export type VerifierLaunch = {
|
|
|
23
22
|
revision: number;
|
|
24
23
|
};
|
|
25
24
|
|
|
26
|
-
type
|
|
25
|
+
type PrepareVerifierRunInput = {
|
|
27
26
|
paths: MaestroPaths;
|
|
28
27
|
specId: string;
|
|
29
28
|
};
|
|
30
29
|
|
|
31
|
-
export const
|
|
30
|
+
export const prepareVerifierRun = async ({
|
|
32
31
|
paths,
|
|
33
32
|
specId,
|
|
34
|
-
}:
|
|
33
|
+
}: PrepareVerifierRunInput): Promise<VerifierRun> => {
|
|
35
34
|
const repositoryRoot = paths.getRepositoryRoot();
|
|
36
35
|
const workflowPath = paths.getWorkflowPath(specId);
|
|
37
36
|
const handoffPath = paths.getVerifierHandoffPath(specId);
|
|
@@ -45,7 +44,7 @@ export const prepareVerifierLaunch = async ({
|
|
|
45
44
|
|
|
46
45
|
if (currentState.phase !== WORKFLOW_PHASES.READY_FOR_VERIFIER) {
|
|
47
46
|
throw new Error(
|
|
48
|
-
`Verifier
|
|
47
|
+
`Verifier run requires ready-for-verifier state, found "${currentState.phase}".`,
|
|
49
48
|
);
|
|
50
49
|
}
|
|
51
50
|
|
|
@@ -53,13 +52,13 @@ export const prepareVerifierLaunch = async ({
|
|
|
53
52
|
|
|
54
53
|
if (!status.clean) {
|
|
55
54
|
throw new Error(
|
|
56
|
-
'Verifier
|
|
55
|
+
'Verifier run requires a committed ready-for-verifier candidate.',
|
|
57
56
|
);
|
|
58
57
|
}
|
|
59
58
|
|
|
60
59
|
const nextState = transitionWorkflow({
|
|
61
60
|
state: currentState,
|
|
62
|
-
event: WORKFLOW_EVENTS.
|
|
61
|
+
event: WORKFLOW_EVENTS.RUN_VERIFIER,
|
|
63
62
|
});
|
|
64
63
|
|
|
65
64
|
const handoffExists = await pathExists(handoffPath);
|
|
@@ -80,28 +79,17 @@ export const prepareVerifierLaunch = async ({
|
|
|
80
79
|
expectedPaths.push(handoffPath);
|
|
81
80
|
}
|
|
82
81
|
|
|
83
|
-
const previousHead = await getHeadCommit(repositoryRoot);
|
|
84
|
-
|
|
85
82
|
const checkpointCommit = await createWorkflowCheckpointCommit({
|
|
86
83
|
repositoryRoot,
|
|
87
84
|
expectedPaths,
|
|
88
85
|
});
|
|
89
86
|
|
|
90
|
-
|
|
91
|
-
repositoryRoot,
|
|
92
|
-
commit: checkpointCommit,
|
|
93
|
-
});
|
|
94
|
-
|
|
95
|
-
if (candidateCommit !== previousHead) {
|
|
96
|
-
throw new Error(
|
|
97
|
-
'Verifier candidate changed while creating its checkpoint.',
|
|
98
|
-
);
|
|
99
|
-
}
|
|
87
|
+
maestroSessionState.setVerifierCheckpointCommit(checkpointCommit);
|
|
100
88
|
|
|
101
89
|
return {
|
|
102
90
|
specId,
|
|
103
91
|
repositoryRoot,
|
|
104
|
-
candidateCommit,
|
|
92
|
+
candidateCommit: checkpointCommit,
|
|
105
93
|
checkpointCommit,
|
|
106
94
|
revision: nextState.revision,
|
|
107
95
|
};
|