@emiliosp/pi-maestro 0.18.7 → 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/CHANGELOG.md CHANGED
@@ -3,6 +3,11 @@
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
+
6
11
  ## 0.18.7
7
12
 
8
13
  - fix: Simplified child agent setup by using Pi's native extension discovery and tool registration.
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. With `builder` disabled, only configuration is checked. Model availability
117
- comes from Pi's model registry. If a check fails, `Maestro` stays disabled and reports the problem.
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) | Backlog |
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
- ### Objective
116
-
117
- Explore how `Maestro` can reconcile saved `artifacts` and workflow state. The recovery scope is not yet defined.
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
 
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
- ### No reconciliation
370
+ ### Restart an existing spec
371
371
 
372
- Disabling `Maestro`, restarting Pi, or using `/resume` clears live `Maestro` session state and leaves project files unchanged. `Maestro` starts disabled in a new or
373
- resumed session. Reactivating it does not reconstruct or resume a saved workflow.
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.
@@ -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 { WORKFLOW_PHASES } from '#workflow/state/schema.ts';
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
- event.systemPromptOptions.sections.maestro = getMaestroInstructions();
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@emiliosp/pi-maestro",
3
- "version": "0.18.7",
3
+ "version": "0.19.1",
4
4
  "description": "A spec-driven multiagent development workflow for Pi.",
5
5
  "keywords": [
6
6
  "orchestration",
@@ -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. 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.
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 an incomplete workflow.
223
- The owner handles execution errors, protocol errors, and interrupted workflows manually.
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
+ };
@@ -23,6 +23,7 @@ export const WORKFLOW_PHASES = {
23
23
  } as const;
24
24
 
25
25
  export const WORKFLOW_EVENTS = {
26
+ RESTART_SPEC: 'restart-spec',
26
27
  MARK_SPEC_READY: 'mark-spec-ready',
27
28
  RUN_BUILDER: 'run-builder',
28
29
  BUILDER_OPEN_ESCALATIONS: 'builder-open-escalations',
@@ -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,