@emiliosp/pi-maestro 0.18.6 → 0.19.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/ADR.md +22 -1
- package/CHANGELOG.md +9 -0
- package/README.md +2 -2
- package/ROADMAP.md +7 -8
- package/docs/workflow.md +7 -3
- package/extensions/maestro.ts +39 -2
- package/package.json +1 -1
- package/src/delegation/executeTask.ts +1 -2
- package/src/delegation/prepareSubagentEnvironment.ts +18 -30
- package/src/maestro/instructions/getMaestroInstructions.ts +4 -4
- package/src/specs/hasSpecs.ts +25 -0
- package/src/ui/selectSpec.ts +14 -0
- package/src/ui/showSpecMenu.ts +36 -0
- package/src/workflow/state/schema.ts +1 -0
- package/src/workflow/transitions.ts +4 -0
package/ADR.md
CHANGED
|
@@ -280,7 +280,8 @@ Approval can finish at `candidate-ready` without agent execution. Agent and mode
|
|
|
280
280
|
|
|
281
281
|
### Status
|
|
282
282
|
|
|
283
|
-
Design decisions confirmed by the `owner`. Implemented.
|
|
283
|
+
Design decisions confirmed by the `owner`. Implemented. Main-extension pre-load exclusion is superseded by
|
|
284
|
+
[ADR-012](#adr-012-filter-main-maestro-registrations-after-native-discovery).
|
|
284
285
|
|
|
285
286
|
### Context
|
|
286
287
|
|
|
@@ -434,3 +435,23 @@ requirements or phase rules. Initial setup is limited to interactive terminal mo
|
|
|
434
435
|
|
|
435
436
|
[Approved design](.specs/20261108-141712-maestro-19-guide-initial-configuration-with-pi-selectors/design.md) and
|
|
436
437
|
[configuration guidance](docs/configuration.md#initial-setup).
|
|
438
|
+
|
|
439
|
+
## ADR-012: Filter main Maestro registrations after native discovery
|
|
440
|
+
|
|
441
|
+
### Status
|
|
442
|
+
|
|
443
|
+
Accepted in the approved [design](.specs/20261108-222326-simplify-child-extension-loading-with-the-native-pi-filter/design.md). Implemented for review. Supersedes only
|
|
444
|
+
the pre-load exclusion constraint in [ADR-010](#adr-010-use-the-pi-sdk-for-sequential-agent-delegation).
|
|
445
|
+
|
|
446
|
+
### Context
|
|
447
|
+
|
|
448
|
+
Child preparation duplicated Pi's package discovery to exclude the main `Maestro` extension before initialization.
|
|
449
|
+
|
|
450
|
+
### Decision
|
|
451
|
+
|
|
452
|
+
Use Pi's native discovery and configured selection. Filter the loaded main `Maestro` extension through `extensionsOverride` before constructing the child session.
|
|
453
|
+
|
|
454
|
+
### Consequences
|
|
455
|
+
|
|
456
|
+
Main-extension initialization may register tools, commands, and handlers, but must not mutate parent state or start resources before filtering. SDK sessions share a
|
|
457
|
+
process; filtering removes registrations from the child runtime, not initialization side effects.
|
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,15 @@
|
|
|
3
3
|
This file summarizes meaningful changes to the codebase, including behavior, data formats, architecture, and development tools. Git tags identify version boundaries;
|
|
4
4
|
GitHub Releases are not required.
|
|
5
5
|
|
|
6
|
+
## 0.19.1
|
|
7
|
+
|
|
8
|
+
- `/maestro` now lets the `owner` start a new `spec` or restart an existing one, including after an interruption. Restart reopens the same documents for review and
|
|
9
|
+
requires a new `GREEN FLAG` before implementation starts again. Existing code, `handoffs`, and saved decisions are preserved.
|
|
10
|
+
|
|
11
|
+
## 0.18.7
|
|
12
|
+
|
|
13
|
+
- fix: Simplified child agent setup by using Pi's native extension discovery and tool registration.
|
|
14
|
+
|
|
6
15
|
## 0.18.6
|
|
7
16
|
|
|
8
17
|
- Added guided initial configuration through `/maestro`: the `owner` selects models and thinking levels for `builder`, `verifier`, and `simplifier`, then saves the
|
package/README.md
CHANGED
|
@@ -113,8 +113,8 @@ Activate `Maestro`:
|
|
|
113
113
|
/maestro
|
|
114
114
|
```
|
|
115
115
|
|
|
116
|
-
During activation, `Maestro` checks configuration and model availability for enabled agents.
|
|
117
|
-
|
|
116
|
+
During activation, `Maestro` checks configuration and model availability for enabled agents. Model availability comes from Pi's model registry. If a check fails,
|
|
117
|
+
`Maestro` stays disabled and reports the problem.
|
|
118
118
|
|
|
119
119
|
The `owner` follows this workflow:
|
|
120
120
|
|
package/ROADMAP.md
CHANGED
|
@@ -28,7 +28,7 @@ Completed entries preserve recorded outcomes and evidence, which may describe be
|
|
|
28
28
|
| MAESTRO-22 | [Avoid acceptance criteria already covered by tests](#maestro-22-avoid-acceptance-criteria-already-covered-by-tests) | Completed |
|
|
29
29
|
| MAESTRO-23 | [Change agent models before a builder run](#maestro-23-change-agent-models-before-a-builder-run) | Backlog |
|
|
30
30
|
| MAESTRO-24 | [Add a simplifier with one clear purpose per agent](#maestro-24-add-a-simplifier-with-one-clear-purpose-per-agent) | Completed |
|
|
31
|
-
| MAESTRO-25 | [Define workflow reconciliation](#maestro-25-define-workflow-reconciliation) |
|
|
31
|
+
| MAESTRO-25 | [Define workflow reconciliation](#maestro-25-define-workflow-reconciliation) | Completed |
|
|
32
32
|
| MAESTRO-26 | [Exit Maestro mode automatically at workflow completion](#maestro-26-exit-maestro-mode-automatically-at-workflow-completion) | Completed |
|
|
33
33
|
| MAESTRO-27 | [Make all implementation phases optional](#maestro-27-make-all-implementation-phases-optional) | Completed |
|
|
34
34
|
| MAESTRO-28 | [Add Maestro role instructions alongside the other agents](#maestro-28-add-maestro-role-instructions-alongside-the-other-agents) | Backlog |
|
|
@@ -112,13 +112,9 @@ The `owner` can select available models in those phases. `Maestro` uses the sele
|
|
|
112
112
|
|
|
113
113
|
## MAESTRO-25: Define workflow reconciliation
|
|
114
114
|
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
### Completed when
|
|
120
|
-
|
|
121
|
-
Not yet defined. The `owner` must define the intended outcome, recovery boundaries, and completion condition before this item can move forward.
|
|
115
|
+
Implemented for verification under the [approved spec](.specs/20261109-142858-resume-an-interrupted-workflow-from-drafting-spec/spec.md). When existing `specs` are
|
|
116
|
+
available, `/maestro` offers a new `spec` or selection of an existing `spec` to restart. Every restart returns to `drafting-spec` for document review and renewed
|
|
117
|
+
`GREEN FLAG`, regardless of the saved phase. Restart preserves saved `owner` decisions and does not recover an interrupted agent or reconcile partial saves.
|
|
122
118
|
|
|
123
119
|
## MAESTRO-28: Add Maestro role instructions alongside the other agents
|
|
124
120
|
|
|
@@ -289,6 +285,9 @@ The `pi-subagents` integration then in use still received a fixed deadline of 9,
|
|
|
289
285
|
|
|
290
286
|
### Implementation and evidence
|
|
291
287
|
|
|
288
|
+
Registration follow-up: caller-supplied tools use an inline `extensionFactories` entry instead of SDK `customTools`. This `owner`-requested change is implemented for
|
|
289
|
+
review, with role-specific registration checked by the [workflow integration test](extensions/maestro.integration.test.ts).
|
|
290
|
+
|
|
292
291
|
The standalone executor is implemented under `src/delegation/` against the [approved specification](.specs/20261105-212231-implement-internal-pi-sdk-delegation/spec.md).
|
|
293
292
|
Review follow-up consolidated execution orchestration and session lifecycle in `executeTask`; pure reply interpretation remains in `readTaskResult`. Manual verification
|
|
294
293
|
on Pi 1.5.0 exercised fresh context, native and additional tools, MCP through tool search and codemode, sequential waiting, failure, cancellation, cleanup, and native
|
package/docs/workflow.md
CHANGED
|
@@ -367,7 +367,11 @@ Launch errors, execution failures, interruptions, cancellations, and missing or
|
|
|
367
367
|
completed transition, its saved running phase remains unchanged. Partial protocol writes require manual `owner` follow-up. `Maestro` provides no automatic rollback,
|
|
368
368
|
repair, or recovery for these errors. The files that remain are available for `owner` inspection.
|
|
369
369
|
|
|
370
|
-
###
|
|
370
|
+
### Restart an existing spec
|
|
371
371
|
|
|
372
|
-
|
|
373
|
-
|
|
372
|
+
When existing `specs` are available, `/maestro` activation offers "New spec" and "Restart spec". Restart opens a selector of existing `specs` in the configured directory.
|
|
373
|
+
The selected `spec` returns to `drafting-spec` from any saved phase. `Maestro` reads and reviews its proposal, `spec`, and optional design with the `owner` before asking
|
|
374
|
+
for renewed `GREEN FLAG`.
|
|
375
|
+
|
|
376
|
+
Restart preserves the existing files except for the workflow phase. Saved `owner` decisions retain their normal effect for the same approved documents. Restart does not
|
|
377
|
+
recover an interrupted agent or its conversation, reconstruct progress from the previous phase, or reconcile partial saves.
|
package/extensions/maestro.ts
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
* Used: When Pi starts a Maestro main session.
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
+
import { realpath } from 'node:fs/promises';
|
|
6
7
|
import { join } from 'node:path';
|
|
7
8
|
|
|
8
9
|
import type { ExtensionAPI } from '@earendil-works/pi-coding-agent';
|
|
@@ -14,6 +15,9 @@ import { getMaestroInstructions } from '#maestro/instructions/getMaestroInstruct
|
|
|
14
15
|
import maestroSessionState from '#maestro/session/MaestroSessionState.ts';
|
|
15
16
|
import { setupConfiguration } from '#maestro/setupConfiguration.ts';
|
|
16
17
|
import { refreshMaestroStatus } from '#maestro/status/refreshMaestroStatus.ts';
|
|
18
|
+
import { MaestroPaths } from '#MaestroPaths.ts';
|
|
19
|
+
import { hasSpecs } from '#specs/hasSpecs.ts';
|
|
20
|
+
import { showSpecMenu, SPEC_ACTIONS } from '#src/ui/showSpecMenu.ts';
|
|
17
21
|
import { CREATE_SPEC_TOOL, registerCreateSpecTool } from '#tools/main/create-spec.ts';
|
|
18
22
|
import { MARK_SPEC_READY_TOOL, registerMarkSpecReadyTool } from '#tools/main/mark-spec-ready.ts';
|
|
19
23
|
import {
|
|
@@ -28,7 +32,10 @@ import { RUN_BUILDER_TOOL, registerRunBuilderTool } from '#tools/main/run-builde
|
|
|
28
32
|
import { RUN_SIMPLIFIER_TOOL, registerRunSimplifierTool } from '#tools/main/run-simplifier.ts';
|
|
29
33
|
import { RUN_VERIFIER_TOOL, registerRunVerifierTool } from '#tools/main/run-verifier.ts';
|
|
30
34
|
import { pathExists } from '#utils/path-exists.ts';
|
|
31
|
-
import {
|
|
35
|
+
import { readWorkflowState } from '#workflow/state/readWorkflowState.ts';
|
|
36
|
+
import { WORKFLOW_EVENTS, WORKFLOW_PHASES } from '#workflow/state/schema.ts';
|
|
37
|
+
import { writeWorkflowState } from '#workflow/state/writeWorkflowState.ts';
|
|
38
|
+
import { transitionWorkflow } from '#workflow/transitions.ts';
|
|
32
39
|
|
|
33
40
|
const MAIN_TOOL_NAMES: readonly string[] = [
|
|
34
41
|
CREATE_SPEC_TOOL.NAME,
|
|
@@ -101,6 +108,30 @@ export default (pi: ExtensionAPI): void => {
|
|
|
101
108
|
const config = await loadConfiguration(context.cwd);
|
|
102
109
|
const isImplementationEnabled = config.builder.required;
|
|
103
110
|
|
|
111
|
+
const paths = new MaestroPaths({ projectRoot: await realpath(context.cwd), config });
|
|
112
|
+
|
|
113
|
+
if (await hasSpecs(paths.getSpecDirectory())) {
|
|
114
|
+
const specId = await showSpecMenu({
|
|
115
|
+
ui: context.ui,
|
|
116
|
+
specDirectory: paths.getSpecDirectory(),
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
if (specId === undefined) return;
|
|
120
|
+
|
|
121
|
+
if (specId !== SPEC_ACTIONS.NEW) {
|
|
122
|
+
const state = await readWorkflowState(paths.getWorkflowPath(specId));
|
|
123
|
+
|
|
124
|
+
if (state.specId !== specId)
|
|
125
|
+
throw new Error('Workflow spec ID does not match the selected spec.');
|
|
126
|
+
|
|
127
|
+
await writeWorkflowState({
|
|
128
|
+
path: paths.getWorkflowPath(specId),
|
|
129
|
+
state: transitionWorkflow({ state, event: WORKFLOW_EVENTS.RESTART_SPEC, config }),
|
|
130
|
+
});
|
|
131
|
+
maestroSessionState.setActiveSpecId(specId);
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
|
|
104
135
|
maestroSessionState.activate();
|
|
105
136
|
syncMainTools();
|
|
106
137
|
await refreshMaestroStatus(context);
|
|
@@ -142,7 +173,13 @@ export default (pi: ExtensionAPI): void => {
|
|
|
142
173
|
return;
|
|
143
174
|
}
|
|
144
175
|
|
|
145
|
-
|
|
176
|
+
const specId = maestroSessionState.getActiveSpecId();
|
|
177
|
+
event.systemPromptOptions.sections.maestro = [
|
|
178
|
+
getMaestroInstructions(),
|
|
179
|
+
...(specId === null
|
|
180
|
+
? []
|
|
181
|
+
: [`Active spec ID: ${specId}. Resolve its paths in the configured spec directory.`]),
|
|
182
|
+
].join('\n\n');
|
|
146
183
|
await refreshMaestroStatus(context);
|
|
147
184
|
});
|
|
148
185
|
|
package/package.json
CHANGED
|
@@ -88,7 +88,7 @@ export const executeTask = async ({
|
|
|
88
88
|
try {
|
|
89
89
|
try {
|
|
90
90
|
const cwd = await realpath(workingDirectory);
|
|
91
|
-
const services = await prepareSubagentEnvironment({ cwd, roleGuidance });
|
|
91
|
+
const services = await prepareSubagentEnvironment({ cwd, roleGuidance, additionalTools });
|
|
92
92
|
|
|
93
93
|
const model = (await services.modelRuntime.getAvailable()).find(
|
|
94
94
|
(entry) => `${entry.provider}/${entry.id}` === modelId,
|
|
@@ -106,7 +106,6 @@ export const executeTask = async ({
|
|
|
106
106
|
sessionManager,
|
|
107
107
|
model,
|
|
108
108
|
thinkingLevel,
|
|
109
|
-
customTools: additionalTools,
|
|
110
109
|
}));
|
|
111
110
|
|
|
112
111
|
if (onEvent) unsubscribe = session.subscribe(onEvent);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Objective: Discover native Pi resources
|
|
2
|
+
* Objective: Discover native Pi resources and exclude main Maestro registrations from children.
|
|
3
3
|
* Used: During preparation of each standalone child execution.
|
|
4
4
|
*/
|
|
5
5
|
|
|
@@ -12,9 +12,10 @@ import {
|
|
|
12
12
|
createCodemodeExtension,
|
|
13
13
|
createMcpExtension,
|
|
14
14
|
createToolSearchExtension,
|
|
15
|
-
DefaultPackageManager,
|
|
16
15
|
getAgentDir,
|
|
16
|
+
type InlineExtension,
|
|
17
17
|
SettingsManager,
|
|
18
|
+
type ToolDefinition,
|
|
18
19
|
} from '@earendil-works/pi-coding-agent';
|
|
19
20
|
|
|
20
21
|
const MAIN_EXTENSION = fileURLToPath(new URL('../../extensions/maestro.ts', import.meta.url));
|
|
@@ -27,8 +28,8 @@ const isMaestroPackage = (value: unknown): value is MaestroPackage =>
|
|
|
27
28
|
'name' in value &&
|
|
28
29
|
value.name === '@emiliosp/pi-maestro';
|
|
29
30
|
|
|
30
|
-
const
|
|
31
|
-
if (path.startsWith('builtin:')) return false;
|
|
31
|
+
const isMainMaestroExtension = (path: string): boolean => {
|
|
32
|
+
if (path.startsWith('builtin:') || path.startsWith('<inline:')) return false;
|
|
32
33
|
|
|
33
34
|
const canonicalPath = realpathSync(path);
|
|
34
35
|
|
|
@@ -54,52 +55,39 @@ const isMainExtension = (path: string): boolean => {
|
|
|
54
55
|
type PrepareSubagentEnvironmentInput = {
|
|
55
56
|
cwd: string;
|
|
56
57
|
roleGuidance: string;
|
|
58
|
+
additionalTools: ToolDefinition[];
|
|
57
59
|
};
|
|
58
60
|
|
|
59
61
|
export const prepareSubagentEnvironment = async ({
|
|
60
62
|
cwd,
|
|
61
63
|
roleGuidance,
|
|
64
|
+
additionalTools,
|
|
62
65
|
}: PrepareSubagentEnvironmentInput) => {
|
|
63
66
|
const agentDir = getAgentDir();
|
|
64
67
|
const settingsManager = SettingsManager.create(cwd, agentDir);
|
|
65
68
|
|
|
66
|
-
|
|
69
|
+
// SDK sessions need these CLI built-ins supplied explicitly.
|
|
70
|
+
// The inline factory registers the child's additional tools with pi.registerTool.
|
|
71
|
+
const extensionFactories: InlineExtension[] = [
|
|
67
72
|
{ name: 'codemode', factory: createCodemodeExtension(), builtin: true, replaceable: true },
|
|
68
73
|
{ name: 'tool-search', factory: createToolSearchExtension(), builtin: true, replaceable: true },
|
|
69
74
|
{ name: 'mcp', factory: createMcpExtension(), builtin: true, replaceable: true },
|
|
75
|
+
(pi) => {
|
|
76
|
+
for (const tool of additionalTools) pi.registerTool(tool);
|
|
77
|
+
},
|
|
70
78
|
];
|
|
71
79
|
|
|
72
|
-
const packages = new DefaultPackageManager({
|
|
73
|
-
cwd,
|
|
74
|
-
agentDir,
|
|
75
|
-
settingsManager,
|
|
76
|
-
builtinExtensions: extensionFactories.map(({ name }) => name),
|
|
77
|
-
});
|
|
78
|
-
|
|
79
|
-
const resources = await packages.resolve(async () => 'error');
|
|
80
|
-
|
|
81
|
-
if (resources.installFailures?.length) {
|
|
82
|
-
throw new Error(resources.installFailures.map(({ message }) => message).join('\n'));
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
// extensionsOverride filters extensions after Pi has loaded and initialized them.
|
|
86
|
-
// It would exclude Maestro's event handlers, but its initialization code would still run.
|
|
87
|
-
// Use additionalExtensionPaths instead to exclude Maestro before loading it,
|
|
88
|
-
// so none of its code executes in the child session.
|
|
89
|
-
const additionalExtensionPaths = resources.extensions
|
|
90
|
-
.filter(({ enabled, path }) => enabled && !isMainExtension(path))
|
|
91
|
-
.map(({ path }) => path);
|
|
92
|
-
|
|
93
80
|
const services = await createAgentSessionServices({
|
|
94
81
|
cwd,
|
|
95
82
|
agentDir,
|
|
96
83
|
settingsManager,
|
|
97
84
|
resourceLoaderOptions: {
|
|
98
|
-
// Disable automatic extension discovery; load only the filtered paths below
|
|
99
|
-
// and the built-in factories, so discovery cannot add Maestro back.
|
|
100
|
-
noExtensions: true,
|
|
101
|
-
additionalExtensionPaths,
|
|
102
85
|
extensionFactories,
|
|
86
|
+
// Exclude the main Maestro extension from the child session.
|
|
87
|
+
extensionsOverride: (base) => ({
|
|
88
|
+
...base,
|
|
89
|
+
extensions: base.extensions.filter(({ path }) => !isMainMaestroExtension(path)),
|
|
90
|
+
}),
|
|
103
91
|
appendSystemPromptOverride: (base) => [...base, roleGuidance],
|
|
104
92
|
},
|
|
105
93
|
});
|
|
@@ -39,14 +39,14 @@ Use generic tools for project inspection. Use only maestro_* tools for workflow
|
|
|
39
39
|
Do not edit workflow.json or handoffs directly, including through shell commands.
|
|
40
40
|
The spec, prototype, and experiment permissions below are the only exceptions for file changes.
|
|
41
41
|
|
|
42
|
-
Use the specId and paths returned by maestro_create_spec. Read workflow.json before selecting the next action. Its validated phase is the source of truth.
|
|
42
|
+
Use the active spec ID supplied at activation, or the specId and paths returned by maestro_create_spec. Read workflow.json before selecting the next action. Its validated phase is the source of truth.
|
|
43
43
|
Use tool schemas for arguments and tool results for outcomes. Do not infer a completed transition from an agent's final message.
|
|
44
44
|
Builder, verifier, and simplifier runs are foreground operations with fresh contexts. Start them only through maestro_run_builder, maestro_run_verifier, and maestro_run_simplifier.
|
|
45
45
|
Wait for each tool result before taking the next workflow action. Do not launch parallel or background runs.
|
|
46
46
|
|
|
47
47
|
### Prepare and approve the spec
|
|
48
48
|
|
|
49
|
-
1.
|
|
49
|
+
1. If activation supplied an active spec ID, restart review of that same spec in drafting-spec instead of creating a spec. Read its existing proposal.md, spec.md, and design.md when present, and review the document set with the owner before requesting renewed GREEN FLAG. Do not present unanswered escalations for owner discussion or resolution during this restart review. Restart does not invalidate saved handoffs or owner decisions: with the same approved documents, saved decisions retain their normal effect after renewed approval. If no spec is active, call maestro_create_spec with the change title. It creates proposal.md and spec.md from the bundled templates. Use the returned document paths. Create design.md from the installed templates/design.md only when significant technical decisions need to be recorded; do not create an empty design.
|
|
50
50
|
2. Read the repository and applicable AGENTS.md files. Investigate the affected behavior before asking the owner for missing information. Inspect existing tests before writing acceptance criteria.
|
|
51
51
|
3. Ask one focused question at a time. Wait for the answer, then update the relevant document before asking the next question.
|
|
52
52
|
4. Record motivation and scope in proposal.md, required behavior and acceptance criteria in spec.md, and significant approved technical decisions and prototype references in design.md when needed. Link between documents instead of repeating content. Do not invent requirements or silently resolve owner decisions.
|
|
@@ -219,8 +219,8 @@ Do not repeat an unchanged failing call, edit protocol files, or fabricate evide
|
|
|
219
219
|
Launch errors, delegation failures, timeouts, interruptions, cancellations, and missing or invalid handoffs stop the workflow. Do not create synthetic escalations or recovery transitions.
|
|
220
220
|
If a run ends without a valid saved result, report the error and stop. Do not repair product files or force a transition.
|
|
221
221
|
If a run saves no completed transition, its saved running phase remains unchanged.
|
|
222
|
-
Disabling Maestro, restarting Pi, or using /resume clears live state. Do not reconstruct or resume
|
|
223
|
-
The owner
|
|
222
|
+
Disabling Maestro, restarting Pi, or using /resume clears live state. Do not reconstruct or resume the interrupted agent or its conversation.
|
|
223
|
+
The owner can explicitly restart an existing spec through /maestro activation. This returns it to drafting-spec for document review and renewed GREEN FLAG, regardless of its saved phase. Do not infer progress from its old phase or reconcile partial saves. The owner handles execution errors and partial protocol writes.
|
|
224
224
|
|
|
225
225
|
At candidate-ready, the workflow is complete. No final tool call is required.
|
|
226
226
|
Maestro stays active while you deliver the final summary and automatically turns off after the response finishes successfully, including when simplification was skipped.
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Objective: Check for an existing spec without collecting the directory contents.
|
|
3
|
+
* Used: Before offering the new-or-restart menu during Maestro activation.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { opendir } from 'node:fs/promises';
|
|
7
|
+
|
|
8
|
+
import { isValidSpecId } from '#ids/isValidSpecId.ts';
|
|
9
|
+
import { isErrnoException } from '#utils/is-errno-exception.ts';
|
|
10
|
+
|
|
11
|
+
export const hasSpecs = async (specDirectory: string): Promise<boolean> => {
|
|
12
|
+
try {
|
|
13
|
+
for await (const entry of await opendir(specDirectory)) {
|
|
14
|
+
// early return, just check if there is at least 1 spec present in the spec directory
|
|
15
|
+
if (entry.isDirectory() && isValidSpecId(entry.name)) return true;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
// empty dir
|
|
19
|
+
return false;
|
|
20
|
+
} catch (error) {
|
|
21
|
+
if (isErrnoException(error) && error.code === 'ENOENT') return false;
|
|
22
|
+
|
|
23
|
+
throw error;
|
|
24
|
+
}
|
|
25
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Objective: Collect an existing spec selection from the supplied identifiers.
|
|
3
|
+
* Used: When the owner chooses to restart a spec during Maestro activation.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import type { ExtensionContext } from '@earendil-works/pi-coding-agent';
|
|
7
|
+
|
|
8
|
+
type SelectSpecInput = {
|
|
9
|
+
ui: ExtensionContext['ui'];
|
|
10
|
+
choices: string[];
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
export const selectSpec = ({ ui, choices }: SelectSpecInput): Promise<string | undefined> =>
|
|
14
|
+
ui.select('Restart spec', choices);
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Objective: Collect a new spec action or an existing spec identifier.
|
|
3
|
+
* Used: During Maestro activation when existing specs are available.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { readdir } from 'node:fs/promises';
|
|
7
|
+
|
|
8
|
+
import type { ExtensionContext } from '@earendil-works/pi-coding-agent';
|
|
9
|
+
|
|
10
|
+
import { isValidSpecId } from '#ids/isValidSpecId.ts';
|
|
11
|
+
import { selectSpec } from '#src/ui/selectSpec.ts';
|
|
12
|
+
|
|
13
|
+
export const SPEC_ACTIONS = { NEW: 'New spec', RESTART: 'Restart spec' } as const;
|
|
14
|
+
|
|
15
|
+
type ShowSpecMenuInput = {
|
|
16
|
+
ui: ExtensionContext['ui'];
|
|
17
|
+
specDirectory: string;
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export const showSpecMenu = async ({
|
|
21
|
+
ui,
|
|
22
|
+
specDirectory,
|
|
23
|
+
}: ShowSpecMenuInput): Promise<string | undefined> => {
|
|
24
|
+
const choice = await ui.select('Start Maestro workflow', Object.values(SPEC_ACTIONS));
|
|
25
|
+
|
|
26
|
+
if (choice === undefined || choice === SPEC_ACTIONS.NEW) return choice;
|
|
27
|
+
|
|
28
|
+
const entries = await readdir(specDirectory, { withFileTypes: true });
|
|
29
|
+
|
|
30
|
+
const specIds = entries
|
|
31
|
+
.filter((entry) => entry.isDirectory() && isValidSpecId(entry.name))
|
|
32
|
+
.map((entry) => entry.name)
|
|
33
|
+
.sort();
|
|
34
|
+
|
|
35
|
+
return selectSpec({ ui, choices: specIds });
|
|
36
|
+
};
|
|
@@ -32,6 +32,10 @@ const getBuilderDoneDestination = (config: MaestroConfig): WorkflowPhase =>
|
|
|
32
32
|
config.verifier.required ? WORKFLOW_PHASES.READY_FOR_VERIFIER : getSimplifierDestination(config);
|
|
33
33
|
|
|
34
34
|
export const WORKFLOW_TRANSITIONS: Record<WorkflowEvent, WorkflowTransition> = {
|
|
35
|
+
[WORKFLOW_EVENTS.RESTART_SPEC]: {
|
|
36
|
+
from: Object.values(WORKFLOW_PHASES),
|
|
37
|
+
to: WORKFLOW_PHASES.DRAFTING_SPEC,
|
|
38
|
+
},
|
|
35
39
|
[WORKFLOW_EVENTS.MARK_SPEC_READY]: {
|
|
36
40
|
from: [WORKFLOW_PHASES.DRAFTING_SPEC],
|
|
37
41
|
to: getSpecReadyDestination,
|