@emiliosp/pi-maestro 0.21.0 → 0.23.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/CHANGELOG.md +5 -0
- package/README.md +42 -79
- package/agents/builder.md +7 -7
- package/agents/maestro.md +62 -45
- package/agents/simplifier.md +6 -5
- package/agents/verifier.md +13 -13
- package/docs/adr/0001-keep-the-workflow-independent-of-git.md +25 -0
- package/docs/adr/0002-store-escalation-decisions-in-builder-handoffs.md +24 -0
- package/docs/adr/0003-route-builder-failures-through-owner-escalations.md +23 -0
- package/docs/adr/0004-require-git-only-for-the-simplifier.md +35 -0
- package/docs/adr/0005-approve-a-specification-document-set-as-one-contract.md +32 -0
- package/docs/adr/0006-maintain-the-roadmap-in-linear.md +25 -0
- package/docs/adr/0007-maintain-the-roadmap-in-the-repository.md +27 -0
- package/docs/adr/0008-use-pis-registry-for-model-availability.md +23 -0
- package/docs/adr/0009-select-optional-phases-in-the-transition-table.md +24 -0
- package/docs/adr/0010-use-the-pi-sdk-for-sequential-agent-delegation.md +109 -0
- package/docs/adr/0011-separate-initial-setup-ui-from-configuration-rules.md +25 -0
- package/docs/adr/0012-filter-main-maestro-registrations-after-native-discovery.md +21 -0
- package/docs/adr/README.md +21 -0
- package/docs/configuration.md +33 -12
- package/docs/glossary.md +38 -49
- package/docs/inspiration.md +32 -0
- package/docs/roadmap/README.md +42 -0
- package/docs/roadmap/maestro-10-improve-status-presentation-and-activation-feedback.md +18 -0
- package/docs/roadmap/maestro-11-introduce-maestro-at-activation.md +19 -0
- package/docs/roadmap/maestro-12-verify-code-quality-against-agentsmd-instructions.md +21 -0
- package/docs/roadmap/maestro-13-check-subagent-extensions-at-activation.md +21 -0
- package/docs/roadmap/maestro-14-rename-the-test-support-directory.md +16 -0
- package/docs/roadmap/maestro-15-match-handoff-criteria-to-the-approved-spec.md +19 -0
- package/docs/roadmap/maestro-16-route-finding-driven-spec-revisions-through-drafting-spec.md +19 -0
- package/docs/roadmap/maestro-17-keep-acceptance-criterion-numbering-continuous.md +19 -0
- package/docs/roadmap/maestro-18-record-escalation-resolutions-when-the-spec-changes.md +18 -0
- package/docs/roadmap/maestro-19-guide-initial-configuration.md +22 -0
- package/docs/roadmap/maestro-20-rename-the-npm-package.md +17 -0
- package/docs/roadmap/maestro-21-label-acceptance-criterion-coverage.md +18 -0
- package/docs/roadmap/maestro-22-avoid-acceptance-criteria-already-covered-by-tests.md +16 -0
- package/docs/roadmap/maestro-23-change-agent-models-before-a-builder-run.md +14 -0
- package/docs/roadmap/maestro-24-add-a-simplifier-with-one-clear-purpose-per-agent.md +23 -0
- package/docs/roadmap/maestro-25-define-workflow-reconciliation.md +19 -0
- package/docs/roadmap/maestro-26-exit-maestro-mode-automatically-at-workflow-completion.md +18 -0
- package/docs/roadmap/maestro-27-make-all-implementation-phases-optional.md +26 -0
- package/docs/roadmap/maestro-28-add-maestro-role-instructions-alongside-the-other-agents.md +14 -0
- package/docs/roadmap/maestro-6-display-specs-in-a-browser.md +14 -0
- package/docs/roadmap/maestro-7-route-builder-failures-through-owner-escalations.md +19 -0
- package/docs/roadmap/maestro-8-store-escalations-and-owner-decisions-in-builder-handoffs.md +19 -0
- package/docs/roadmap/maestro-9-format-glossary-terms-consistently.md +14 -0
- package/docs/roadmap/maestro-free-1-require-pi-150.md +16 -0
- package/docs/roadmap/maestro-free-2-remove-maestro-run-timeouts.md +18 -0
- package/docs/roadmap/maestro-free-3-run-the-builder-through-the-pi-sdk.md +31 -0
- package/docs/roadmap/maestro-free-4-run-the-verifier-through-the-pi-sdk.md +22 -0
- package/docs/roadmap/maestro-free-5-run-the-simplifier-through-the-pi-sdk.md +22 -0
- package/docs/roadmap/maestro-free-6-show-sdk-agent-activity-through-pi.md +21 -0
- package/docs/roadmap/maestro-free-7-remove-the-pi-subagents-dependency.md +21 -0
- package/docs/roadmap/maestro-free-pre-3-implement-internal-sdk-delegation.md +37 -0
- package/docs/subagent-integration.md +9 -29
- package/docs/workflow.md +62 -246
- package/extensions/maestro.ts +96 -19
- package/package.json +2 -6
- package/src/MaestroPaths.ts +9 -0
- package/src/config/assertConfiguration.ts +23 -21
- package/src/config/defaults.ts +2 -1
- package/src/config/loadConfiguration.ts +3 -2
- package/src/config/saveConfiguration.ts +38 -14
- package/src/config/schema.ts +13 -0
- package/src/maestro/checks/assertEnvironment.ts +8 -33
- package/src/maestro/selectAgentModels.ts +70 -0
- package/src/maestro/setupInitialConfiguration.ts +26 -0
- package/src/maestro/status/formatMaestroStatus.ts +3 -0
- package/src/score/collectWorkflowEvidence.ts +170 -0
- package/src/score/parseClassifierScores.ts +51 -0
- package/src/score/questions.json +24 -0
- package/src/score/requestEvaluation.ts +54 -0
- package/src/score/scoreWorkflow.ts +100 -0
- package/src/tools/child/record-builder-handoff.ts +1 -0
- package/src/tools/child/record-simplifier-handoff.ts +2 -1
- package/src/tools/child/record-verifier-handoff.ts +1 -0
- package/src/tools/main/create-spec.ts +1 -0
- package/src/tools/main/mark-spec-ready.ts +1 -0
- package/src/tools/main/resolve-escalations.ts +1 -0
- package/src/tools/main/resolve-findings.ts +6 -1
- package/src/tools/main/run-builder.ts +8 -1
- package/src/tools/main/run-simplifier.ts +26 -6
- package/src/tools/main/run-verifier.ts +8 -1
- package/src/tools/main/score-workflow.ts +43 -0
- package/src/ui/selectModel.ts +23 -15
- package/src/ui/showAgentRolesSetupMenu.ts +65 -0
- package/src/workflow/spec/markSpecReady.ts +13 -3
- package/src/workflow/state/schema.ts +3 -0
- package/src/workflow/transitions.ts +9 -2
- package/templates/spec.md +1 -1
- package/ADR.md +0 -457
- package/ROADMAP.md +0 -641
- package/src/maestro/setupConfiguration.ts +0 -50
- package/src/ui/selectSpec.ts +0 -14
- package/src/ui/showSetupMenu.ts +0 -44
- package/src/ui/showSpecMenu.ts +0 -36
- /package/{MISSION.md → docs/MISSION.md} +0 -0
- /package/{TECH_STACK.md → docs/TECH_STACK.md} +0 -0
package/extensions/maestro.ts
CHANGED
|
@@ -10,14 +10,16 @@ import type { ExtensionAPI } from '@earendil-works/pi-coding-agent';
|
|
|
10
10
|
|
|
11
11
|
import { CONFIG_FILE_PATH } from '#config/defaults.ts';
|
|
12
12
|
import { loadConfiguration } from '#config/loadConfiguration.ts';
|
|
13
|
+
import { type AgentModelSelections, saveConfiguration } from '#config/saveConfiguration.ts';
|
|
14
|
+
import type { MaestroConfig, ThinkingLevel } from '#config/schema.ts';
|
|
13
15
|
import { assertEnvironment } from '#maestro/checks/assertEnvironment.ts';
|
|
14
16
|
import { getMaestroInstructions } from '#maestro/instructions/getMaestroInstructions.ts';
|
|
17
|
+
import { selectAgentModels } from '#maestro/selectAgentModels.ts';
|
|
15
18
|
import maestroSessionState from '#maestro/session/MaestroSessionState.ts';
|
|
16
|
-
import {
|
|
19
|
+
import { setupInitialConfiguration } from '#maestro/setupInitialConfiguration.ts';
|
|
17
20
|
import { refreshMaestroStatus } from '#maestro/status/refreshMaestroStatus.ts';
|
|
18
21
|
import { MaestroPaths } from '#MaestroPaths.ts';
|
|
19
22
|
import { hasSpecs } from '#specs/hasSpecs.ts';
|
|
20
|
-
import { showSpecMenu, SPEC_ACTIONS } from '#src/ui/showSpecMenu.ts';
|
|
21
23
|
import { CREATE_SPEC_TOOL, registerCreateSpecTool } from '#tools/main/create-spec.ts';
|
|
22
24
|
import { MARK_SPEC_READY_TOOL, registerMarkSpecReadyTool } from '#tools/main/mark-spec-ready.ts';
|
|
23
25
|
import {
|
|
@@ -31,12 +33,34 @@ import {
|
|
|
31
33
|
import { RUN_BUILDER_TOOL, registerRunBuilderTool } from '#tools/main/run-builder.ts';
|
|
32
34
|
import { RUN_SIMPLIFIER_TOOL, registerRunSimplifierTool } from '#tools/main/run-simplifier.ts';
|
|
33
35
|
import { RUN_VERIFIER_TOOL, registerRunVerifierTool } from '#tools/main/run-verifier.ts';
|
|
36
|
+
import { SCORE_WORKFLOW_TOOL, registerScoreWorkflowTool } from '#tools/main/score-workflow.ts';
|
|
34
37
|
import { pathExists } from '#utils/path-exists.ts';
|
|
35
38
|
import { readWorkflowState } from '#workflow/state/readWorkflowState.ts';
|
|
36
39
|
import { WORKFLOW_EVENTS, WORKFLOW_PHASES } from '#workflow/state/schema.ts';
|
|
37
40
|
import { writeWorkflowState } from '#workflow/state/writeWorkflowState.ts';
|
|
38
41
|
import { transitionWorkflow } from '#workflow/transitions.ts';
|
|
39
42
|
|
|
43
|
+
const ACTIVATION_MENU_ACTIONS = {
|
|
44
|
+
NEW_SPEC: 'New spec',
|
|
45
|
+
RESTART_SPEC: 'Restart spec',
|
|
46
|
+
AGENT_MODELS: 'Agent models',
|
|
47
|
+
} as const;
|
|
48
|
+
|
|
49
|
+
const getCurrentAgentsConfiguration = (config: MaestroConfig): AgentModelSelections => ({
|
|
50
|
+
...(config.builder.required && config.builder.model
|
|
51
|
+
? { builder: { model: config.builder.model, thinking: config.builder.thinking } }
|
|
52
|
+
: {}),
|
|
53
|
+
...(config.verifier.required && config.verifier.model
|
|
54
|
+
? { verifier: { model: config.verifier.model, thinking: config.verifier.thinking } }
|
|
55
|
+
: {}),
|
|
56
|
+
...(config.simplifier.required && config.simplifier.model
|
|
57
|
+
? { simplifier: { model: config.simplifier.model, thinking: config.simplifier.thinking } }
|
|
58
|
+
: {}),
|
|
59
|
+
...(config.scorer.required && config.scorer.model
|
|
60
|
+
? { scorer: { model: config.scorer.model } }
|
|
61
|
+
: {}),
|
|
62
|
+
});
|
|
63
|
+
|
|
40
64
|
const MAIN_TOOL_NAMES: readonly string[] = [
|
|
41
65
|
CREATE_SPEC_TOOL.NAME,
|
|
42
66
|
MARK_SPEC_READY_TOOL.NAME,
|
|
@@ -45,6 +69,7 @@ const MAIN_TOOL_NAMES: readonly string[] = [
|
|
|
45
69
|
RUN_VERIFIER_TOOL.NAME,
|
|
46
70
|
RESOLVE_FINDINGS_TOOL.NAME,
|
|
47
71
|
RUN_SIMPLIFIER_TOOL.NAME,
|
|
72
|
+
SCORE_WORKFLOW_TOOL.NAME,
|
|
48
73
|
];
|
|
49
74
|
|
|
50
75
|
type CompletedWorkflowResult = {
|
|
@@ -52,6 +77,15 @@ type CompletedWorkflowResult = {
|
|
|
52
77
|
phase: typeof WORKFLOW_PHASES.CANDIDATE_READY;
|
|
53
78
|
};
|
|
54
79
|
|
|
80
|
+
type EnabledAgent = {
|
|
81
|
+
label: string;
|
|
82
|
+
model: string;
|
|
83
|
+
thinking?: ThinkingLevel;
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
const formatEnabledAgent = ({ label, model, thinking }: EnabledAgent): string =>
|
|
87
|
+
thinking === undefined ? `${label} (${model})` : `${label} (${model} ${thinking})`;
|
|
88
|
+
|
|
55
89
|
const isCompletedWorkflowResult = (details: unknown): details is CompletedWorkflowResult =>
|
|
56
90
|
typeof details === 'object' &&
|
|
57
91
|
details !== null &&
|
|
@@ -68,6 +102,7 @@ export default (pi: ExtensionAPI): void => {
|
|
|
68
102
|
registerRunVerifierTool(pi);
|
|
69
103
|
registerResolveFindingsTool(pi);
|
|
70
104
|
registerRunSimplifierTool(pi);
|
|
105
|
+
registerScoreWorkflowTool(pi);
|
|
71
106
|
|
|
72
107
|
const syncMainTools = (): void => {
|
|
73
108
|
const foreignTools = pi.getActiveTools().filter((name) => !MAIN_TOOL_NAMES.includes(name));
|
|
@@ -77,9 +112,12 @@ export default (pi: ExtensionAPI): void => {
|
|
|
77
112
|
);
|
|
78
113
|
};
|
|
79
114
|
|
|
115
|
+
let hasSentMaestroInstructions = false;
|
|
116
|
+
|
|
80
117
|
// Pi fires this when a session starts, resumes, forks, or reloads.
|
|
81
118
|
// Reset Maestro to off without activation checks or startup notifications.
|
|
82
119
|
pi.on('session_start', async (_event, context) => {
|
|
120
|
+
hasSentMaestroInstructions = false;
|
|
83
121
|
maestroSessionState.deactivate();
|
|
84
122
|
syncMainTools();
|
|
85
123
|
await refreshMaestroStatus(context);
|
|
@@ -97,28 +135,49 @@ export default (pi: ExtensionAPI): void => {
|
|
|
97
135
|
}
|
|
98
136
|
|
|
99
137
|
try {
|
|
100
|
-
if (
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
return;
|
|
138
|
+
if (!(await pathExists(join(context.cwd, CONFIG_FILE_PATH)))) {
|
|
139
|
+
const isConfigured = await setupInitialConfiguration(context);
|
|
140
|
+
|
|
141
|
+
if (!isConfigured) return;
|
|
105
142
|
}
|
|
106
143
|
|
|
107
|
-
await
|
|
108
|
-
const config = await loadConfiguration(context.cwd);
|
|
109
|
-
const isImplementationEnabled = config.builder.required;
|
|
144
|
+
let config = await loadConfiguration(context.cwd);
|
|
110
145
|
|
|
111
146
|
const paths = new MaestroPaths({ projectRoot: await realpath(context.cwd), config });
|
|
112
147
|
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
148
|
+
const activationMenuActions = (await hasSpecs(paths.getSpecDirectory()))
|
|
149
|
+
? [
|
|
150
|
+
ACTIVATION_MENU_ACTIONS.NEW_SPEC,
|
|
151
|
+
ACTIVATION_MENU_ACTIONS.RESTART_SPEC,
|
|
152
|
+
ACTIVATION_MENU_ACTIONS.AGENT_MODELS,
|
|
153
|
+
]
|
|
154
|
+
: [ACTIVATION_MENU_ACTIONS.NEW_SPEC, ACTIVATION_MENU_ACTIONS.AGENT_MODELS];
|
|
155
|
+
|
|
156
|
+
while (true) {
|
|
157
|
+
const action = await context.ui.select('Start Maestro workflow', activationMenuActions);
|
|
158
|
+
|
|
159
|
+
if (action === undefined) return;
|
|
160
|
+
|
|
161
|
+
if (action === ACTIVATION_MENU_ACTIONS.AGENT_MODELS) {
|
|
162
|
+
const agentModelSelections = await selectAgentModels({
|
|
163
|
+
context,
|
|
164
|
+
currentAgentsConfiguration: getCurrentAgentsConfiguration(config),
|
|
165
|
+
});
|
|
166
|
+
|
|
167
|
+
if (agentModelSelections === undefined) continue;
|
|
118
168
|
|
|
119
|
-
|
|
169
|
+
await saveConfiguration({ cwd: context.cwd, agentModelSelections });
|
|
170
|
+
config = await loadConfiguration(context.cwd);
|
|
171
|
+
continue;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
if (action === ACTIVATION_MENU_ACTIONS.RESTART_SPEC) {
|
|
175
|
+
const specId = await context.ui.select('Restart spec', await paths.listSpecIds());
|
|
176
|
+
|
|
177
|
+
if (specId === undefined) continue;
|
|
178
|
+
|
|
179
|
+
assertEnvironment({ context, config });
|
|
120
180
|
|
|
121
|
-
if (specId !== SPEC_ACTIONS.NEW) {
|
|
122
181
|
const state = await readWorkflowState(paths.getWorkflowPath(specId));
|
|
123
182
|
|
|
124
183
|
if (state.specId !== specId)
|
|
@@ -129,6 +188,14 @@ export default (pi: ExtensionAPI): void => {
|
|
|
129
188
|
state: transitionWorkflow({ state, event: WORKFLOW_EVENTS.RESTART_SPEC, config }),
|
|
130
189
|
});
|
|
131
190
|
maestroSessionState.setActiveSpecId(specId);
|
|
191
|
+
|
|
192
|
+
break;
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
if (action === ACTIVATION_MENU_ACTIONS.NEW_SPEC) {
|
|
196
|
+
assertEnvironment({ context, config });
|
|
197
|
+
|
|
198
|
+
break;
|
|
132
199
|
}
|
|
133
200
|
}
|
|
134
201
|
|
|
@@ -146,10 +213,11 @@ export default (pi: ExtensionAPI): void => {
|
|
|
146
213
|
{ label: 'Builder', settings: config.builder },
|
|
147
214
|
{ label: 'Verifier', settings: config.verifier },
|
|
148
215
|
{ label: 'Simplifier', settings: config.simplifier },
|
|
216
|
+
{ label: 'Scorer', settings: config.scorer },
|
|
149
217
|
]
|
|
150
|
-
.filter(({ settings }) =>
|
|
218
|
+
.filter(({ settings }) => config.builder.required && settings.required)
|
|
151
219
|
.map(({ label, settings }) =>
|
|
152
|
-
context.ui.theme.fg('accent',
|
|
220
|
+
context.ui.theme.fg('accent', formatEnabledAgent({ label, ...settings })),
|
|
153
221
|
),
|
|
154
222
|
].join('\n'),
|
|
155
223
|
'info',
|
|
@@ -170,9 +238,16 @@ export default (pi: ExtensionAPI): void => {
|
|
|
170
238
|
if (!maestroSessionState.isActive()) {
|
|
171
239
|
delete event.systemPromptOptions.sections.maestro;
|
|
172
240
|
|
|
241
|
+
if (hasSentMaestroInstructions) {
|
|
242
|
+
event.systemPromptOptions.sections.maestro_status =
|
|
243
|
+
'IMPORTANT: Maestro is off. Ignore earlier Maestro instructions.';
|
|
244
|
+
}
|
|
245
|
+
|
|
173
246
|
return;
|
|
174
247
|
}
|
|
175
248
|
|
|
249
|
+
delete event.systemPromptOptions.sections.maestro_status;
|
|
250
|
+
|
|
176
251
|
const specId = maestroSessionState.getActiveSpecId();
|
|
177
252
|
event.systemPromptOptions.sections.maestro = [
|
|
178
253
|
await getMaestroInstructions(),
|
|
@@ -180,6 +255,8 @@ export default (pi: ExtensionAPI): void => {
|
|
|
180
255
|
? []
|
|
181
256
|
: [`Active spec ID: ${specId}. Resolve its paths in the configured spec directory.`]),
|
|
182
257
|
].join('\n\n');
|
|
258
|
+
|
|
259
|
+
hasSentMaestroInstructions = true;
|
|
183
260
|
await refreshMaestroStatus(context);
|
|
184
261
|
});
|
|
185
262
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@emiliosp/pi-maestro",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.23.0",
|
|
4
4
|
"description": "A spec-driven multiagent development workflow for Pi.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"orchestration",
|
|
@@ -27,12 +27,8 @@
|
|
|
27
27
|
"src/",
|
|
28
28
|
"!**/*.test.ts",
|
|
29
29
|
"docs/",
|
|
30
|
-
"MISSION.md",
|
|
31
|
-
"TECH_STACK.md",
|
|
32
|
-
"ROADMAP.md",
|
|
33
30
|
"CHANGELOG.md",
|
|
34
31
|
"MANIFESTO.md",
|
|
35
|
-
"ADR.md",
|
|
36
32
|
"README.md",
|
|
37
33
|
"LICENSE"
|
|
38
34
|
],
|
|
@@ -68,7 +64,7 @@
|
|
|
68
64
|
"@vitest/coverage-v8": "5.0.5",
|
|
69
65
|
"oxfmt": "0.73.0",
|
|
70
66
|
"oxlint": "1.87.0",
|
|
71
|
-
"oxlint-anti-slop": "0.
|
|
67
|
+
"oxlint-anti-slop": "0.5.0",
|
|
72
68
|
"typebox": "1.3.35",
|
|
73
69
|
"typescript": "7.0.2",
|
|
74
70
|
"vitest": "5.0.5"
|
package/src/MaestroPaths.ts
CHANGED
|
@@ -92,6 +92,15 @@ export class MaestroPaths {
|
|
|
92
92
|
return this.specDirectory;
|
|
93
93
|
}
|
|
94
94
|
|
|
95
|
+
public async listSpecIds(): Promise<string[]> {
|
|
96
|
+
const entries = await readdir(this.specDirectory, { withFileTypes: true });
|
|
97
|
+
|
|
98
|
+
return entries
|
|
99
|
+
.filter((entry) => entry.isDirectory() && isValidSpecId(entry.name))
|
|
100
|
+
.map((entry) => entry.name)
|
|
101
|
+
.sort();
|
|
102
|
+
}
|
|
103
|
+
|
|
95
104
|
public getSpecPath(specId: string): string {
|
|
96
105
|
assertSpecId(specId);
|
|
97
106
|
|
|
@@ -16,6 +16,7 @@ export const SEMVER_PATTERN =
|
|
|
16
16
|
/^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$/;
|
|
17
17
|
|
|
18
18
|
type SchemaValidationError = {
|
|
19
|
+
keyword: string;
|
|
19
20
|
instancePath: string;
|
|
20
21
|
schemaPath: string;
|
|
21
22
|
message: string;
|
|
@@ -24,6 +25,18 @@ type SchemaValidationError = {
|
|
|
24
25
|
const formatError = (error: SchemaValidationError): string => {
|
|
25
26
|
const path = error.instancePath.replace(/^\//, '').replace(/\//g, '.');
|
|
26
27
|
|
|
28
|
+
if (error.schemaPath === '#' && error.keyword === 'required') {
|
|
29
|
+
return "Missing configuration version. The 'version' field is required.";
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
if (error.schemaPath === '#' && error.keyword === 'type') {
|
|
33
|
+
return 'Configuration must be a JSON object.';
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
if (path === 'version') {
|
|
37
|
+
return 'Invalid configuration version: expected a string.';
|
|
38
|
+
}
|
|
39
|
+
|
|
27
40
|
if (error.schemaPath.includes('additionalProperties')) {
|
|
28
41
|
return `Unknown configuration field: "${path}".`;
|
|
29
42
|
}
|
|
@@ -36,7 +49,7 @@ const formatError = (error: SchemaValidationError): string => {
|
|
|
36
49
|
return `Invalid model at "${path}": expected a string.`;
|
|
37
50
|
}
|
|
38
51
|
|
|
39
|
-
if (path === 'builder' || path === 'verifier' || path === 'simplifier') {
|
|
52
|
+
if (path === 'builder' || path === 'verifier' || path === 'simplifier' || path === 'scorer') {
|
|
40
53
|
return `Invalid ${path} configuration: expected an object.`;
|
|
41
54
|
}
|
|
42
55
|
|
|
@@ -48,25 +61,16 @@ const formatError = (error: SchemaValidationError): string => {
|
|
|
48
61
|
};
|
|
49
62
|
|
|
50
63
|
export function assertConfiguration(input: unknown): asserts input is PartialMaestroConfig {
|
|
51
|
-
if (
|
|
52
|
-
|
|
64
|
+
if (!Value.Check(MaestroConfigInputSchema, input)) {
|
|
65
|
+
const [firstError] = Value.Errors(MaestroConfigInputSchema, input);
|
|
66
|
+
throw new Error(firstError ? formatError(firstError) : 'Invalid configuration.');
|
|
53
67
|
}
|
|
54
68
|
|
|
55
|
-
const
|
|
56
|
-
|
|
57
|
-
if (!('version' in raw) || raw.version === undefined) {
|
|
58
|
-
throw new Error("Missing configuration version. The 'version' field is required.");
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
if (typeof raw.version !== 'string') {
|
|
62
|
-
throw new Error('Invalid configuration version: expected a string.');
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
const semverMatch = raw.version.match(SEMVER_PATTERN);
|
|
69
|
+
const semverMatch = input.version.match(SEMVER_PATTERN);
|
|
66
70
|
|
|
67
71
|
if (!semverMatch) {
|
|
68
72
|
throw new Error(
|
|
69
|
-
`Invalid configuration version: "${
|
|
73
|
+
`Invalid configuration version: "${input.version}". Expected a semantic version (e.g. "1.0.0").`,
|
|
70
74
|
);
|
|
71
75
|
}
|
|
72
76
|
|
|
@@ -78,15 +82,13 @@ export function assertConfiguration(input: unknown): asserts input is PartialMae
|
|
|
78
82
|
);
|
|
79
83
|
}
|
|
80
84
|
|
|
81
|
-
if (
|
|
85
|
+
if (input.version !== SUPPORTED_CONFIG_VERSION) {
|
|
82
86
|
throw new Error(
|
|
83
|
-
`Unsupported configuration version: "${
|
|
87
|
+
`Unsupported configuration version: "${input.version}". Supported version is ${SUPPORTED_CONFIG_VERSION}.`,
|
|
84
88
|
);
|
|
85
89
|
}
|
|
86
90
|
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
if (firstError !== undefined) {
|
|
90
|
-
throw new Error(formatError(firstError));
|
|
91
|
+
if (input.builder?.required !== false && input.scorer?.required && !input.scorer.model?.trim()) {
|
|
92
|
+
throw new Error('Scorer model is required when scorer.required is true.');
|
|
91
93
|
}
|
|
92
94
|
}
|
package/src/config/defaults.ts
CHANGED
|
@@ -20,5 +20,6 @@ export const DEFAULT_CONFIG: MaestroConfig = {
|
|
|
20
20
|
specDirectory: DEFAULT_SPEC_DIRECTORY,
|
|
21
21
|
builder: { required: true, model: '', thinking: THINKING_LEVELS.HIGH },
|
|
22
22
|
verifier: { required: true, model: '', thinking: THINKING_LEVELS.MEDIUM },
|
|
23
|
-
simplifier: { required:
|
|
23
|
+
simplifier: { required: false, model: '', thinking: THINKING_LEVELS.HIGH },
|
|
24
|
+
scorer: { required: false, model: '' },
|
|
24
25
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Objective: Load and validate project configuration.
|
|
3
|
-
* Used: When Maestro initializes for a project.
|
|
3
|
+
* Used: When Maestro initializes for a project, and before patching an existing file.
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
import { readFile, realpath } from 'node:fs/promises';
|
|
@@ -18,6 +18,7 @@ const resolveConfiguration = (input: PartialMaestroConfig): MaestroConfig => ({
|
|
|
18
18
|
builder: { ...DEFAULT_CONFIG.builder, ...input.builder },
|
|
19
19
|
verifier: { ...DEFAULT_CONFIG.verifier, ...input.verifier },
|
|
20
20
|
simplifier: { ...DEFAULT_CONFIG.simplifier, ...input.simplifier },
|
|
21
|
+
scorer: { ...DEFAULT_CONFIG.scorer, ...input.scorer },
|
|
21
22
|
});
|
|
22
23
|
|
|
23
24
|
type ResolveSpecDirectoryInput = {
|
|
@@ -69,7 +70,7 @@ const resolveDirectories = ({ projectRoot, config }: ResolveDirectoriesInput): M
|
|
|
69
70
|
};
|
|
70
71
|
};
|
|
71
72
|
|
|
72
|
-
const readConfigurationFile = async (path: string): Promise<unknown> => {
|
|
73
|
+
export const readConfigurationFile = async (path: string): Promise<unknown> => {
|
|
73
74
|
try {
|
|
74
75
|
const content = await readFile(path, 'utf8');
|
|
75
76
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Objective: Build and persist project configuration from confirmed agent model selections.
|
|
3
|
-
* Used: After setup confirmation
|
|
2
|
+
* Objective: Build or patch and persist project configuration from confirmed agent model selections.
|
|
3
|
+
* Used: After setup confirmation, before activation checks, and when the owner changes agent models.
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
import { mkdir, writeFile } from 'node:fs/promises';
|
|
@@ -12,23 +12,46 @@ import {
|
|
|
12
12
|
CONFIG_FILE_PATH,
|
|
13
13
|
DEFAULT_SPEC_DIRECTORY,
|
|
14
14
|
} from '#config/defaults.ts';
|
|
15
|
+
import { readConfigurationFile } from '#config/loadConfiguration.ts';
|
|
15
16
|
import {
|
|
16
17
|
type PartialMaestroConfig,
|
|
17
18
|
SUPPORTED_CONFIG_VERSION,
|
|
18
19
|
type ThinkingLevel,
|
|
19
20
|
} from '#config/schema.ts';
|
|
21
|
+
import { pathExists } from '#utils/path-exists.ts';
|
|
20
22
|
|
|
21
23
|
export const SETUP_ROLES = {
|
|
22
24
|
BUILDER: 'builder',
|
|
23
25
|
VERIFIER: 'verifier',
|
|
24
26
|
SIMPLIFIER: 'simplifier',
|
|
27
|
+
SCORER: 'scorer',
|
|
25
28
|
} as const;
|
|
26
29
|
|
|
27
30
|
export type SetupRole = (typeof SETUP_ROLES)[keyof typeof SETUP_ROLES];
|
|
28
31
|
|
|
29
32
|
export type RoleSelection = { model: string; thinking: ThinkingLevel };
|
|
30
33
|
|
|
31
|
-
export type AgentModelSelections = Partial<
|
|
34
|
+
export type AgentModelSelections = Partial<
|
|
35
|
+
Record<Exclude<SetupRole, typeof SETUP_ROLES.SCORER>, RoleSelection>
|
|
36
|
+
> & {
|
|
37
|
+
scorer?: { model: string };
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
type AgentSelection = RoleSelection | { model: string };
|
|
41
|
+
|
|
42
|
+
const toAgentSection = (selection?: AgentSelection) =>
|
|
43
|
+
selection ? { required: true, ...selection } : { required: false };
|
|
44
|
+
|
|
45
|
+
const readCurrentConfiguration = async (
|
|
46
|
+
path: string,
|
|
47
|
+
): Promise<PartialMaestroConfig | undefined> => {
|
|
48
|
+
if (!(await pathExists(path))) return undefined;
|
|
49
|
+
|
|
50
|
+
const parsed = await readConfigurationFile(path);
|
|
51
|
+
assertConfiguration(parsed);
|
|
52
|
+
|
|
53
|
+
return parsed;
|
|
54
|
+
};
|
|
32
55
|
|
|
33
56
|
type SaveConfigurationInput = {
|
|
34
57
|
cwd: string;
|
|
@@ -39,21 +62,22 @@ export const saveConfiguration = async ({
|
|
|
39
62
|
cwd,
|
|
40
63
|
agentModelSelections,
|
|
41
64
|
}: SaveConfigurationInput): Promise<void> => {
|
|
65
|
+
const targetPath = join(cwd, CONFIG_FILE_PATH);
|
|
66
|
+
|
|
67
|
+
const currentConfiguration = (await readCurrentConfiguration(targetPath)) ?? {
|
|
68
|
+
specDirectory: DEFAULT_SPEC_DIRECTORY,
|
|
69
|
+
};
|
|
70
|
+
|
|
42
71
|
const config: PartialMaestroConfig = {
|
|
72
|
+
...currentConfiguration,
|
|
43
73
|
version: SUPPORTED_CONFIG_VERSION,
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
verifier: agentModelSelections.verifier
|
|
49
|
-
? { required: true, ...agentModelSelections.verifier }
|
|
50
|
-
: { required: false },
|
|
51
|
-
simplifier: agentModelSelections.simplifier
|
|
52
|
-
? { required: true, ...agentModelSelections.simplifier }
|
|
53
|
-
: { required: false },
|
|
74
|
+
builder: toAgentSection(agentModelSelections.builder),
|
|
75
|
+
verifier: toAgentSection(agentModelSelections.verifier),
|
|
76
|
+
scorer: toAgentSection(agentModelSelections.scorer),
|
|
77
|
+
simplifier: toAgentSection(agentModelSelections.simplifier),
|
|
54
78
|
};
|
|
55
79
|
|
|
56
80
|
assertConfiguration(config);
|
|
57
81
|
await mkdir(join(cwd, CONFIG_DIRECTORY_NAME), { recursive: true });
|
|
58
|
-
await writeFile(
|
|
82
|
+
await writeFile(targetPath, `${JSON.stringify(config, null, 2)}\n`, 'utf8');
|
|
59
83
|
};
|
package/src/config/schema.ts
CHANGED
|
@@ -45,6 +45,15 @@ export const MaestroConfigInputSchema = Type.Object(
|
|
|
45
45
|
builder: Type.Optional(PartialAgentConfigSchema),
|
|
46
46
|
verifier: Type.Optional(PartialAgentConfigSchema),
|
|
47
47
|
simplifier: Type.Optional(PartialAgentConfigSchema),
|
|
48
|
+
scorer: Type.Optional(
|
|
49
|
+
Type.Object(
|
|
50
|
+
{
|
|
51
|
+
required: Type.Optional(Type.Boolean()),
|
|
52
|
+
model: Type.Optional(Type.String()),
|
|
53
|
+
},
|
|
54
|
+
{ additionalProperties: false },
|
|
55
|
+
),
|
|
56
|
+
),
|
|
48
57
|
},
|
|
49
58
|
{ additionalProperties: false },
|
|
50
59
|
);
|
|
@@ -65,6 +74,10 @@ export const ResolvedMaestroConfigSchema = Type.Object(
|
|
|
65
74
|
builder: ResolvedAgentConfigSchema,
|
|
66
75
|
verifier: ResolvedAgentConfigSchema,
|
|
67
76
|
simplifier: ResolvedAgentConfigSchema,
|
|
77
|
+
scorer: Type.Object(
|
|
78
|
+
{ required: Type.Boolean(), model: Type.String() },
|
|
79
|
+
{ additionalProperties: false },
|
|
80
|
+
),
|
|
68
81
|
},
|
|
69
82
|
{ additionalProperties: false },
|
|
70
83
|
);
|
|
@@ -1,41 +1,18 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Objective: Validate the
|
|
3
|
-
* Used:
|
|
2
|
+
* Objective: Validate that the models of enabled agents exist in Pi's registry.
|
|
3
|
+
* Used: After the owner chooses the workflow action and before Maestro activates.
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
import { realpath } from 'node:fs/promises';
|
|
7
|
-
|
|
8
6
|
import type { ExtensionContext } from '@earendil-works/pi-coding-agent';
|
|
9
7
|
|
|
10
|
-
import {
|
|
11
|
-
|
|
12
|
-
const getErrorMessage = (error: unknown): string =>
|
|
13
|
-
error instanceof Error ? error.message : String(error);
|
|
14
|
-
|
|
15
|
-
const getProjectRoot = async (context: ExtensionContext): Promise<string> => {
|
|
16
|
-
try {
|
|
17
|
-
return await realpath(context.cwd);
|
|
18
|
-
} catch (error) {
|
|
19
|
-
throw new Error(`Project check failed: ${getErrorMessage(error)}`);
|
|
20
|
-
}
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
const getActivationConfiguration = async (
|
|
24
|
-
projectRoot: string,
|
|
25
|
-
): Promise<Awaited<ReturnType<typeof loadConfiguration>>> => {
|
|
26
|
-
try {
|
|
27
|
-
return await loadConfiguration(projectRoot);
|
|
28
|
-
} catch (error) {
|
|
29
|
-
throw new Error(`Maestro configuration check failed: ${getErrorMessage(error)}`);
|
|
30
|
-
}
|
|
31
|
-
};
|
|
8
|
+
import type { MaestroConfig } from '#config/schema.ts';
|
|
32
9
|
|
|
33
10
|
type AssertModelsAvailableInput = {
|
|
34
11
|
context: ExtensionContext;
|
|
35
12
|
models: string[];
|
|
36
13
|
};
|
|
37
14
|
|
|
38
|
-
|
|
15
|
+
const assertModelsAvailable = ({ context, models }: AssertModelsAvailableInput): void => {
|
|
39
16
|
const availableModels = context.modelRegistry.getAvailable();
|
|
40
17
|
|
|
41
18
|
for (const model of models) {
|
|
@@ -43,16 +20,14 @@ function assertModelsAvailable({ context, models }: AssertModelsAvailableInput):
|
|
|
43
20
|
throw new Error(`Configured model is not available: "${model}".`);
|
|
44
21
|
}
|
|
45
22
|
}
|
|
46
|
-
}
|
|
23
|
+
};
|
|
47
24
|
|
|
48
25
|
type AssertEnvironmentInput = {
|
|
49
26
|
context: ExtensionContext;
|
|
27
|
+
config: MaestroConfig;
|
|
50
28
|
};
|
|
51
29
|
|
|
52
|
-
export
|
|
53
|
-
const projectRoot = await getProjectRoot(context);
|
|
54
|
-
const config = await getActivationConfiguration(projectRoot);
|
|
55
|
-
|
|
30
|
+
export const assertEnvironment = ({ context, config }: AssertEnvironmentInput): void => {
|
|
56
31
|
if (!config.builder.required) return;
|
|
57
32
|
|
|
58
33
|
const enabledAgents = [config.builder, config.verifier, config.simplifier].filter(
|
|
@@ -60,4 +35,4 @@ export async function assertEnvironment({ context }: AssertEnvironmentInput): Pr
|
|
|
60
35
|
);
|
|
61
36
|
|
|
62
37
|
assertModelsAvailable({ context, models: enabledAgents.map(({ model }) => model) });
|
|
63
|
-
}
|
|
38
|
+
};
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Objective: Collect agent model and thinking choices until the owner confirms the current list.
|
|
3
|
+
* Used: During first-use setup and when the owner changes agent models before activation.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import type { ExtensionContext } from '@earendil-works/pi-coding-agent';
|
|
7
|
+
|
|
8
|
+
import { type AgentModelSelections, SETUP_ROLES } from '#config/saveConfiguration.ts';
|
|
9
|
+
import { setupChoices } from '#config/setupChoices.ts';
|
|
10
|
+
import { selectModel } from '#src/ui/selectModel.ts';
|
|
11
|
+
import { selectThinking } from '#src/ui/selectThinking.ts';
|
|
12
|
+
import { CONFIRM_SETUP, showAgentRolesSetupMenu } from '#src/ui/showAgentRolesSetupMenu.ts';
|
|
13
|
+
|
|
14
|
+
type SelectAgentModelsInput = {
|
|
15
|
+
context: ExtensionContext;
|
|
16
|
+
currentAgentsConfiguration: AgentModelSelections;
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
export const selectAgentModels = async ({
|
|
20
|
+
context,
|
|
21
|
+
currentAgentsConfiguration,
|
|
22
|
+
}: SelectAgentModelsInput): Promise<AgentModelSelections | undefined> => {
|
|
23
|
+
const choices = setupChoices(context.modelRegistry.getAvailable());
|
|
24
|
+
|
|
25
|
+
const classifiers = (await context.modelRegistry.getAvailableOfType('classifier')).map(
|
|
26
|
+
({ provider, id }) => `${provider}/${id}`,
|
|
27
|
+
);
|
|
28
|
+
|
|
29
|
+
const models = choices.map(({ value }) => value);
|
|
30
|
+
const draft: AgentModelSelections = { ...currentAgentsConfiguration };
|
|
31
|
+
|
|
32
|
+
while (true) {
|
|
33
|
+
const action = await showAgentRolesSetupMenu({
|
|
34
|
+
ui: context.ui,
|
|
35
|
+
roles: Object.values(SETUP_ROLES),
|
|
36
|
+
currentAgentsConfiguration: draft,
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
if (action === undefined) return undefined;
|
|
40
|
+
|
|
41
|
+
if (action === CONFIRM_SETUP) return draft;
|
|
42
|
+
|
|
43
|
+
const model = await selectModel({
|
|
44
|
+
ui: context.ui,
|
|
45
|
+
choices: action === SETUP_ROLES.SCORER ? classifiers : models,
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
if (model === undefined) continue;
|
|
49
|
+
|
|
50
|
+
if (model === null) {
|
|
51
|
+
delete draft[action];
|
|
52
|
+
continue;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
if (action === SETUP_ROLES.SCORER) {
|
|
56
|
+
draft.scorer = { model };
|
|
57
|
+
continue;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
const choice = choices.find(({ value }) => value === model);
|
|
61
|
+
|
|
62
|
+
if (!choice) continue;
|
|
63
|
+
|
|
64
|
+
const thinking = await selectThinking({ ui: context.ui, choices: choice.thinkingLevels });
|
|
65
|
+
|
|
66
|
+
if (thinking === undefined) continue;
|
|
67
|
+
|
|
68
|
+
draft[action] = { model: choice.value, thinking };
|
|
69
|
+
}
|
|
70
|
+
};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Objective: Coordinate first-use setup without mixing UI and configuration rules.
|
|
3
|
+
* Used: By /maestro when the project has no configuration file.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import type { ExtensionContext } from '@earendil-works/pi-coding-agent';
|
|
7
|
+
|
|
8
|
+
import { saveConfiguration } from '#config/saveConfiguration.ts';
|
|
9
|
+
import { selectAgentModels } from '#maestro/selectAgentModels.ts';
|
|
10
|
+
|
|
11
|
+
export const setupInitialConfiguration = async (context: ExtensionContext): Promise<boolean> => {
|
|
12
|
+
if (context.mode !== 'tui') {
|
|
13
|
+
throw new Error('Initial Maestro configuration requires interactive Pi.');
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
const agentModelSelections = await selectAgentModels({
|
|
17
|
+
context,
|
|
18
|
+
currentAgentsConfiguration: {},
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
if (agentModelSelections === undefined) return false;
|
|
22
|
+
|
|
23
|
+
await saveConfiguration({ cwd: context.cwd, agentModelSelections });
|
|
24
|
+
|
|
25
|
+
return true;
|
|
26
|
+
};
|