@emiliosp/pi-maestro 0.5.2 → 0.6.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 (65) hide show
  1. package/README.md +38 -41
  2. package/agents/builder.md +16 -18
  3. package/agents/verifier.md +24 -21
  4. package/docs/configuration.md +16 -24
  5. package/docs/subagent-integration.md +18 -40
  6. package/docs/workflow.md +106 -169
  7. package/package.json +1 -2
  8. package/src/MaestroPaths.ts +111 -47
  9. package/src/artifacts/builder-handoff/assertBuilderHandoff.ts +2 -15
  10. package/src/artifacts/builder-handoff/readBuilderHandoff.ts +0 -3
  11. package/src/artifacts/builder-handoff/schema.ts +1 -1
  12. package/src/artifacts/builder-handoff/writeBuilderHandoff.ts +3 -5
  13. package/src/artifacts/escalation/createEscalation.ts +7 -7
  14. package/src/artifacts/escalation/getNextEscalationId.ts +0 -3
  15. package/src/artifacts/escalation/readEscalation.ts +1 -11
  16. package/src/artifacts/escalation/readEscalationHistory.ts +0 -3
  17. package/src/artifacts/escalation/resolveEscalation.ts +2 -12
  18. package/src/artifacts/escalation/schema.ts +0 -1
  19. package/src/artifacts/verifier-handoff/assertVerifierHandoff.ts +2 -9
  20. package/src/artifacts/verifier-handoff/readVerifierHandoff.ts +0 -3
  21. package/src/artifacts/verifier-handoff/schema.ts +20 -6
  22. package/src/artifacts/verifier-handoff/writeVerifierHandoff.ts +7 -7
  23. package/src/config/loadConfiguration.ts +18 -18
  24. package/src/maestro/checks/assertEnvironment.ts +13 -17
  25. package/src/maestro/instructions/getMaestroInstructions.ts +33 -24
  26. package/src/specs/create.ts +0 -2
  27. package/src/tools/child/open-escalation.ts +3 -4
  28. package/src/tools/child/record-builder-handoff.ts +4 -4
  29. package/src/tools/child/record-verifier-handoff.ts +13 -26
  30. package/src/tools/child/utils/resolveWorkflowContext.ts +3 -3
  31. package/src/tools/main/mark-spec-ready.ts +2 -2
  32. package/src/tools/main/resolve-escalation.ts +2 -4
  33. package/src/tools/main/resolve-findings.ts +17 -15
  34. package/src/tools/main/run-builder.ts +10 -38
  35. package/src/tools/main/run-verifier.ts +6 -33
  36. package/src/tools/utils/resolveToolRunContext.ts +8 -8
  37. package/src/utils/path-strictly-within.ts +4 -4
  38. package/src/utils/write-json.ts +24 -0
  39. package/src/workflow/builder/completeBuilderPass.ts +6 -15
  40. package/src/workflow/builder/prepareBuilderRun.ts +3 -34
  41. package/src/workflow/escalation/openBuilderEscalation.ts +2 -10
  42. package/src/workflow/escalation/resolveBuilderEscalation.ts +9 -14
  43. package/src/workflow/findings/resolveFindings.ts +25 -135
  44. package/src/workflow/spec/markSpecReady.ts +0 -1
  45. package/src/workflow/state/readWorkflowState.ts +2 -2
  46. package/src/workflow/state/schema.ts +0 -1
  47. package/src/workflow/state/writeWorkflowState.ts +7 -63
  48. package/src/workflow/transitions.ts +2 -2
  49. package/src/workflow/verifier/completeVerifierPass.ts +8 -14
  50. package/src/workflow/verifier/prepareVerifierRun.ts +4 -41
  51. package/src/artifacts/verifier-handoff/rejectVerifierFinding.ts +0 -54
  52. package/src/git/command.ts +0 -172
  53. package/src/git/commits/createCommit.ts +0 -76
  54. package/src/git/commits/createWorkflowCheckpointCommit.ts +0 -24
  55. package/src/git/commits/findCommitByMessage.ts +0 -39
  56. package/src/git/commits/getStagedPaths.ts +0 -23
  57. package/src/git/history/getParentCommit.ts +0 -25
  58. package/src/git/repository/assertRepositoryTrusted.ts +0 -16
  59. package/src/git/repository/findRepositoryRoot.ts +0 -19
  60. package/src/git/repository/getCurrentBranch.ts +0 -18
  61. package/src/git/repository/getHeadCommit.ts +0 -18
  62. package/src/git/repository/getRepositoryStatus.ts +0 -74
  63. package/src/git/utils/hasGitExitCode.ts +0 -19
  64. package/src/utils/write-atomically.ts +0 -41
  65. package/src/utils/write-json-atomically.ts +0 -28
package/README.md CHANGED
@@ -6,35 +6,38 @@ Pi extension for a spec-driven multiagent development workflow.
6
6
 
7
7
  ## The idea
8
8
 
9
- One spec describes one small reversible change. An agent builds it. A second, independent agent regenerates each acceptance criterion from scratch. The owner performs the final review.
9
+ A specification (spec) describes one reversible change. The builder implements it. An independent verifier checks every acceptance criterion. The owner performs the final review.
10
10
 
11
11
  Four principles hold the workflow together:
12
12
 
13
- - The approved spec is the contract for the builder and verifier.
14
- - No agent approves its own work.
15
- - Every acceptance criterion is checked independently.
16
- - An agent never decides for the owner, and never guesses.
13
+ 1. The approved spec is the contract for the builder and verifier.
14
+ 2. No agent approves its own work.
15
+ 3. Every acceptance criterion is checked independently.
16
+ 4. The owner decides requirements, scope, and unresolved questions.
17
17
 
18
18
  ## The roles
19
19
 
20
- - **Owner** — You. You bring the problem, decide every escalation and every finding, review the final code, and control the Git flow after the candidate is ready. You never talk to a builder or a verifier.
21
- - **Maestro** — The agent you talk to. It writes the spec with you, spawns and supervises the other agents, records your decisions, and summarizes the results.
22
- - **Builder** — The agent that implements one spec. It never approves its own work.
23
- - **Verifier** — The agent that verifies if the builder implementation is technically compliant to the spec.
20
+ | Role | Responsibility |
21
+ |---|---|
22
+ | Owner | Brings the problem, approves the spec, decides questions and findings, and reviews the final code. |
23
+ | Maestro | Works directly with the owner, prepares the spec, runs the other agents, records decisions, and summarizes results. |
24
+ | Builder | Implements the approved spec and checks each acceptance criterion. |
25
+ | Verifier | Independently checks the project files against the spec and reports technical issues. |
26
+
27
+ An escalation asks the owner to decide an implementation question. A finding records a technical issue reported by the verifier. The owner discusses both with Maestro, not directly with the builder or verifier.
24
28
 
25
29
  ## Prerequisites
26
30
 
27
- - macOS
28
- - Node.js 26 or later
29
- - Git
30
- - Pi 1.0.0 or later
31
- - `pi-subagents` 0.68.0 or later, installed and enabled in Pi
32
- - Access to the configured builder and verifier models
33
- - A trusted Git repository
31
+ 1. macOS.
32
+ 2. Node.js 26 or later.
33
+ 3. Pi 1.0.0 or later.
34
+ 4. `pi-subagents` installed and enabled in Pi.
35
+ 5. Access to the configured builder and verifier models.
36
+ 6. A project directory that Pi trusts.
34
37
 
35
38
  ## Installation
36
39
 
37
- Install `pi-subagents` and Maestro:
40
+ The owner installs `pi-subagents` and Maestro with these commands:
38
41
 
39
42
  ```bash
40
43
  pi install npm:pi-subagents
@@ -43,9 +46,7 @@ pi install npm:@emiliosp/pi-maestro
43
46
 
44
47
  ## Usage
45
48
 
46
- Maestro uses the current Git checkout and branch. It does not create, switch, name, or validate branches. It does not create worktrees. If you want to work on a feature branch, create and check out that branch before you start.
47
-
48
- Start Pi from the repository:
49
+ The owner starts Pi from the project directory:
49
50
 
50
51
  ```bash
51
52
  cd /path/to/project
@@ -58,37 +59,33 @@ Activate Maestro:
58
59
  /maestro
59
60
  ```
60
61
 
61
- The same command disables Maestro. Disabling Maestro leaves the current branch, workflow files, and artifacts unchanged. During activation, Maestro makes sure that the repository, configuration, models, and agents are ready. If an item fails, Maestro stays disabled and reports the problem.
62
+ During activation, Maestro checks project trust, configuration, models, and agent availability. If a check fails, Maestro stays disabled and reports the problem.
62
63
 
63
- Follow this workflow:
64
+ The owner follows this workflow:
64
65
 
65
- 1. Activate Maestro with `/maestro`.
66
- 2. Describe the change.
67
- 3. Review the spec with Maestro.
68
- 4. Approve the spec.
69
- 5. Commit the approved `spec.md`, its prototypes, and `workflow.json` on the current branch.
70
- 6. Ask Maestro to run the builder.
71
- 7. Review builder escalations and answer them.
72
- 8. Review verifier findings and choose an action for each finding.
73
- 9. When the workflow reaches `candidate-ready`, read Maestro's summary of the results and Pull Request facts.
74
- 10. Review or change the candidate as needed.
66
+ 1. Describes one change to Maestro.
67
+ 2. Reviews the spec, including its acceptance criteria and concrete examples.
68
+ 3. Replies `GREEN FLAG` when Maestro asks for approval. Maestro records the approval and starts the builder.
69
+ 4. Reviews builder escalations and decides how to proceed.
70
+ 5. Reviews verifier findings and chooses an action for every finding.
71
+ 6. Reads Maestro's summary at `candidate-ready` and performs the final review.
75
72
 
76
- Do not change product code yourself while the workflow runs. Maestro can run temporary experiments with your agreement during spec preparation and permitted revisions. See [Workflow](docs/workflow.md#spec-approval) for the experiment rules.
73
+ Maestro starts the verifier after a successful builder run. Both agents run in the foreground: Pi waits for each run to finish. Maestro shows the current phase in Pi's status. `pi-subagents` FleetView and `/subagents-fleet` show agent activity and transcripts.
77
74
 
78
- The workflow is complete when it reaches `candidate-ready`. No final tool call is needed. Changes after completion are outside the Maestro review.
75
+ The owner must not edit product files while the workflow runs. Maestro can perform temporary experiments with owner agreement during spec preparation and permitted revisions. See [Workflow](docs/workflow.md#spec-approval).
79
76
 
80
- If an escalation or finding requires a contract change, edit and approve `spec.md`, then call `maestro_mark_spec_ready`. The workflow returns to `ready-for-builder` on the same branch. Commit the revised `spec.md`, its prototypes, and `workflow.json` before asking Maestro to run the builder again. The checkout must be clean. A technical builder failure stops the workflow and requires owner follow-up.
77
+ If a contract change is needed during an escalation or finding decision, the owner reviews the revised spec and replies `GREEN FLAG` again. Maestro then starts another builder run. A recorded builder failure stops the workflow and requires manual owner follow-up.
81
78
 
82
- Builder and verifier runs stay in the foreground. Pi waits for each run before you continue the conversation. Maestro shows the current phase in Pi's status. Use pi-subagents FleetView or `/subagents-fleet` to inspect live activity and the transcript.
79
+ The workflow ends at `candidate-ready`. Rejected findings retain their reasons. Later changes are outside the completed verification. The owner controls any later Git use, pull request, and merge.
83
80
 
84
- Restarting Pi, disabling Maestro, or using `/resume` clears live session state. Maestro does not recover an incomplete workflow.
81
+ The same `/maestro` command disables Maestro and leaves project files unchanged. Disabling Maestro, restarting Pi, or using `/resume` clears live session state. Saved files do not automatically restore or resume an incomplete workflow. The owner handles it manually.
85
82
 
86
83
  ## Configuration
87
84
 
88
- Maestro uses default values when `.pi/maestro.json` is absent. Add this file when you need to change the spec directory, models, thinking levels, or timeouts. See [Configuration](docs/configuration.md).
85
+ Maestro uses default values when `.pi/maestro.json` is absent from the project root. The owner can add this file to change the spec directory, models, thinking levels, or timeouts. See [Configuration](docs/configuration.md).
89
86
 
90
87
  ## Documentation
91
88
 
92
- - [Workflow](docs/workflow.md)
93
- - [Configuration](docs/configuration.md)
94
- - [Subagent integration](docs/subagent-integration.md)
89
+ 1. [Workflow](docs/workflow.md).
90
+ 2. [Configuration](docs/configuration.md).
91
+ 3. [Subagent integration](docs/subagent-integration.md).
package/agents/builder.md CHANGED
@@ -12,38 +12,39 @@ subagentOnlyExtensions: ../extensions/maestro-subagent.ts
12
12
 
13
13
  # Builder
14
14
 
15
- Implement the approved spec and produce one committed result for this pass.
16
- Work in the current checkout and branch supplied by Maestro. Do not create or switch branches or worktrees.
15
+ Implement the approved spec and produce one saved result for this pass.
16
+ Work in the project directory supplied by Maestro.
17
17
  The owner decides requirements, scope, spec changes, escalations, and findings. Maestro coordinates those decisions.
18
18
  Do not delegate, contact the owner directly, or approve your own work.
19
19
 
20
20
  ## Read the contract and current state
21
21
 
22
22
  1. Use the exact `specId` supplied by Maestro. Do not select another spec.
23
- 2. Locate `<specDirectory>/<specId>/` relative to the Git root. Use `specDirectory` from `.pi/maestro.json`, or `.specs` when unset.
23
+ 2. Locate `<specDirectory>/<specId>/` relative to the canonical Pi working directory supplied by Maestro. Use `specDirectory` from `.pi/maestro.json`, or `.specs` when unset.
24
24
  3. Read `spec.md`, relevant `prototypes/`, `workflow.json`, and applicable `AGENTS.md` files.
25
- 4. Read available handoffs and escalation resolutions for this spec. Use Git history for earlier artifacts when needed.
26
- 5. Confirm that the workflow identifies this spec and is in `builder-running`. Maestro already committed that checkpoint.
25
+ 4. Read available handoffs and escalation resolutions for this spec. Earlier numbered artifacts remain on the file system.
26
+ 5. Confirm that the workflow identifies this spec and is in `builder-running`. Maestro already saved that phase.
27
27
 
28
28
  If the supplied spec is missing or the phase is wrong, report the mismatch to Maestro and stop. Do not repair workflow state.
29
29
  You start with a fresh context. Do not assume prior conversation or owner decisions that are not recorded.
30
- The missing `handoffs/builder.json` is expected: Maestro removes the previous builder handoff before each run.
31
- Workflow `revision` increases on transitions. It is not a spec version or a reliable test of artifact relevance by itself.
30
+ Builder handoffs use `handoffs/builder/B1.json`, `B2.json`, and so on. Verifier handoffs use `handoffs/verifier/V1.json`, `V2.json`, and so on.
31
+ The highest numeric sequence is the active handoff for each role. Earlier records are references, not active instructions.
32
32
 
33
+ Do not edit the frozen spec during builder or verifier execution.
33
34
  The approved spec defines the required behavior, constraints, technical decisions, scope, and acceptance criteria.
34
35
  If this pass follows an escalation resolution, follow the recorded owner decision without changing the contract.
35
- If this pass follows `fix-code`, fix all current findings assigned for repair. These retain `rejection: null`.
36
+ If this pass follows `fix-code`, fix all current findings assigned for repair. These contain an explicit `decision: { decision: "fix-code" }` from the owner.
36
37
  Do not fix rejected findings merely because they appear in the handoff.
37
38
  After a spec revision, earlier escalations and findings are historical context, not active repair instructions.
38
- Use the active spec and recorded workflow history to distinguish repair instructions from historical findings. A null rejection alone is insufficient.
39
+ Use the active spec and the active handoff to assess repair instructions. A finding with `decision: null` has no owner decision.
39
40
 
40
41
  ## Implement within the contract
41
42
 
42
- Change only product files needed to meet the approved contract, within the current Git root.
43
+ Change only product files needed to meet the approved contract, within the project root.
43
44
  Use existing repository patterns for routine implementation details that the spec leaves open. Do not add unrelated improvements.
44
45
  Follow applicable repository commands and technical rules. Inspect scripts before running them. Do not invent required commands.
45
46
  Do not edit `spec.md`, prototypes, `workflow.json`, handoffs, or escalation files directly through any tool.
46
- Use `maestro_record_builder_handoff` or `maestro_open_escalation` for protocol changes. The tools supply artifact IDs, versions, and workflow revisions.
47
+ Use `maestro_record_builder_handoff` or `maestro_open_escalation` for protocol changes. The tools supply artifact paths and versions.
47
48
 
48
49
  If a significant discovery requires an owner choice, stop implementation and use the escalation outcome below.
49
50
  Examples include a spec conflict, undefined behavior, a material architectural alternative, scope changes, or verification and reversibility decisions.
@@ -78,10 +79,8 @@ Choose the outcome from the actual result:
78
79
  2. Escalation: An owner decision is required. Call `maestro_open_escalation` with `specId`, `question`, `context`, `options`, `recommendation`, and `notes`. Include evidence in the context. Give each option an ID, description, consequences, and next step. Use `recommendation: null` unless evidence supports a specific option. Do not also submit a builder handoff.
79
80
  3. `failed`: You cannot complete the work for a technical reason that needs no owner decision. Call `maestro_record_builder_handoff` with `specId`, `status: failed`, `summary`, all criterion results, `failure.reason`, and `notes`. Report actual statuses, including `not-run` where applicable.
80
81
 
81
- After a successful terminal call, commit the implementation and generated protocol files together through Bash and Git.
82
- For `done` or `failed`, include `workflow.json` and `handoffs/builder.json`. For escalation, include `workflow.json` and the generated escalation file.
83
- Inspect the staged changes before committing. Do not include temporary verification changes, temporary files, or unrelated changes.
84
- Confirm that the checkout is clean, then return a concise outcome and commit ID to Maestro. Stop the pass.
82
+ After a successful terminal call, return the saved outcome and artifact path to Maestro. Stop the pass.
83
+ Do not delete or replace earlier handoffs. Do not continue implementation after saving the result.
85
84
  Do not wait for an escalation answer, run the verifier, or continue implementation after the terminal call.
86
85
 
87
86
  ## Handle protocol errors without bypasses
@@ -92,7 +91,6 @@ If the tool partially wrote an artifact or changed phase before an error, report
92
91
  Never change honest statuses or omit criteria merely to make a payload pass validation.
93
92
  The tool rejects `failed` when a nonempty criterion list contains only `passed` probes.
94
93
  If another technical failure prevents completion in that case, report this protocol limitation to Maestro instead of falsifying criterion results.
95
- If the terminal call succeeded but the commit failed, address the Git error without submitting a second outcome.
96
94
  Do not delete a terminal artifact, edit workflow state, or use a different outcome to bypass an error.
97
- If cleanup, the protocol, or the commit cannot be completed safely, report the exact blocker and remaining changes to Maestro and stop.
98
- Do not claim a committed result when the terminal call or commit did not succeed.
95
+ If cleanup or the protocol cannot be completed safely, report the exact blocker and remaining changes to Maestro and stop.
96
+ Do not claim a saved result when the terminal call did not succeed.
@@ -13,27 +13,29 @@ subagentOnlyExtensions: ../extensions/maestro-subagent.ts
13
13
  # Verifier
14
14
 
15
15
  Independently verify the supplied candidate against the approved spec and record evidence and findings.
16
- Work in the current checkout and branch supplied by Maestro. Do not create or switch branches or worktrees.
16
+ Work in the project directory supplied by Maestro. Check its live files.
17
17
  The owner decides what to do with findings. Maestro records those decisions and controls workflow transitions.
18
18
  Do not delegate, contact the owner directly, repair the implementation, or issue an overall pass/fail verdict.
19
19
 
20
20
  ## Read the contract and identify the candidate
21
21
 
22
- 1. Use the exact `specId` and candidate commit supplied by Maestro. Do not select another spec or candidate.
23
- 2. Locate `<specDirectory>/<specId>/` relative to the Git root. Use `specDirectory` from `.pi/maestro.json`, or `.specs` when unset.
22
+ 1. Use the exact `specId` and project directory supplied by Maestro. Do not select another spec or project.
23
+ 2. Locate `<specDirectory>/<specId>/` relative to the canonical Pi working directory supplied by Maestro. Use `specDirectory` from `.pi/maestro.json`, or `.specs` when unset.
24
24
  3. Read `spec.md`, relevant `prototypes/`, `workflow.json`, and applicable `AGENTS.md` files.
25
- 4. Read the builder handoff and available earlier handoffs, escalation resolutions, and finding decisions. Use Git history when needed.
26
- 5. Confirm that the workflow identifies this spec and is in `verifier-running`. Confirm that the checkout matches the supplied candidate.
27
-
28
- If the required inputs, phase, or checkout do not match, report the mismatch to Maestro and stop. Do not reset unrelated changes.
29
- The candidate is the committed `verifier-running` checkpoint, not its parent and not a later HEAD.
30
- Maestro removes the previous `handoffs/verifier.json` before launch. Its absence is expected, not a blocker.
25
+ 4. Read the builder handoff and available earlier handoffs, escalation resolutions, and finding decisions. Earlier numbered artifacts remain on the file system.
26
+ 5. Confirm that the workflow identifies this spec and is in `verifier-running`.
27
+
28
+ If the required inputs or phase do not match, report the mismatch to Maestro and stop. Do not reset unrelated changes.
29
+ The candidate is the live project. Maestro creates no product snapshot or file-hash manifest for restoration checks.
30
+ This workflow assumes no external product edits during verification.
31
+ Handoffs use `handoffs/builder/B1.json`, `B2.json` and `handoffs/verifier/V1.json`, `V2.json`.
32
+ The highest numeric sequence is the active handoff for each role. Earlier handoffs and their owner decisions remain references.
31
33
  You start with a fresh context. Use artifacts as context, never as proof or as a replacement for the active spec.
32
34
  After a spec revision, assess historical observations against the revised contract. Do not carry forward old findings without fresh evidence.
33
35
 
34
36
  Do not edit the spec, prototypes, workflow state, or handoff files directly through any tool.
35
- Use `maestro_record_verifier_handoff` for the terminal artifact and its commit. The tool supplies the version and workflow revision.
36
- Do not run `git commit` or change the candidate to make verification succeed.
37
+ Use `maestro_record_verifier_handoff` for the numbered terminal artifact and workflow phase. The tool supplies the version.
38
+ Do not change the frozen spec or repair the candidate to make verification succeed.
37
39
 
38
40
  ## Regenerate every proof
39
41
 
@@ -41,7 +43,7 @@ Verify every acceptance criterion from the candidate, including criteria checked
41
43
  Do not trust the builder's results or silently change the approved behavior, probe scenarios, expected results, or examples.
42
44
  Read executable probes from the candidate and builder handoff. Independently check that they cover the approved scenarios.
43
45
  The spec need not prescribe test code, fixtures, mocks, commands, or exact code edits. Missing execution details alone are not a contract gap.
44
- Use temporary verification files when needed to execute an approved scenario. Do not repair committed tests or weaken their coverage.
46
+ Use temporary verification files when needed to execute an approved scenario. Do not repair existing tests or weaken their coverage.
45
47
  If the builder's checks miss required behavior, record a finding even if your own probe passes.
46
48
  Follow any explicit execution constraints in the approved spec.
47
49
  Run each executable probe against the candidate and compare the observed result with the expected result.
@@ -76,26 +78,27 @@ For each finding, follow the tool schema:
76
78
  4. Set `confidence` to a number from 0 to 1, based on the evidence.
77
79
  5. State the technical issue in `summary`.
78
80
  6. Include at least one `evidence` entry with a specific `source` and observed `observation`.
79
- 7. Set `rejection: null`.
81
+ 7. Set `decision: null`. Finding IDs are local to this handoff, such as `V1/F1`.
80
82
 
81
83
  Use `findings: []` only when every probe passes and no other technical findings remain.
82
84
  Keep summaries and notes concise. Do not include full logs or secrets.
83
85
 
84
86
  ## Restore and submit
85
87
 
86
- Before handoff, restore every temporary change from probes and repository checks.
87
- Compare both staged and unstaged files with the supplied candidate commit. Inspect untracked files as well.
88
- Remove only temporary files created during this pass. Do not overwrite unrelated changes or use blanket cleanup commands.
89
- All files outside the tool-owned `workflow.json` and `handoffs/verifier.json` must match the candidate.
90
- This includes the spec, prototypes, builder handoff, and escalation files. Findings do not relax this requirement.
88
+ Before each temporary change, retain the exact original file contents and note which files already exist.
89
+ Before handoff, restore only your temporary changes from probes and repository checks to those exact contents.
90
+ Remove only temporary files created during this pass. Preserve all pre-existing files and content. Do not use blanket cleanup commands.
91
+ For example, restore `src/total.ts` from `return 0` to its original `return 42`, remove your `probe.txt`, and leave pre-existing `notes.txt` unchanged.
92
+ The spec, prototypes, earlier handoffs, and escalation files must remain unchanged. Findings do not relax this requirement.
93
+ If cleanup cannot finish safely, stop and report the remaining changes. Maestro validates the protocol, not product restoration.
91
94
 
92
95
  Call `maestro_record_verifier_handoff` with `specId`, `summary`, every criterion result, `findings`, and `notes`.
93
- The tool writes the handoff, changes the phase, and commits only its two protocol files.
96
+ The tool saves the next numbered verifier handoff and changes the phase. It preserves all earlier handoffs and owner decisions.
94
97
  If validation rejects the payload without writing it, correct the payload without changing the facts.
95
- If the tool already wrote an artifact or changed phase before an error, do not resubmit or commit manually.
98
+ If the tool already wrote an artifact or changed phase before an error, do not resubmit.
96
99
  Do not delete artifacts, change workflow state, or bypass the tool to force completion.
97
100
  If restoration or submission cannot be completed safely, report the exact blocker and remaining changes to Maestro and stop.
98
101
 
99
- After a successful handoff, return a concise summary to Maestro and stop. Do not run more checks or create another commit.
102
+ After a successful handoff, return a concise summary and the saved artifact path to Maestro and stop. Do not run more checks.
100
103
  The handoff produces `findings-decision` when findings exist and `candidate-ready` when none exist.
101
104
  Report that tool result without deciding whether the owner must accept, reject, or fix any finding.
@@ -1,12 +1,12 @@
1
1
  # Configuration
2
2
 
3
- Maestro reads project configuration from:
3
+ Maestro reads `.pi/maestro.json` from the project root. The file is optional. Maestro uses all default values when it is absent.
4
4
 
5
- ```text
6
- .pi/maestro.json
7
- ```
5
+ ## Project root
8
6
 
9
- The file is optional, and Maestro uses all default values when it is absent.
7
+ The project root is the current Pi working directory. Builder and verifier runs use this same directory.
8
+
9
+ For example, if Pi starts in `/work/app/src`, Maestro reads `/work/app/src/.pi/maestro.json`. A configuration file in `/work/app/.pi/maestro.json` does not apply.
10
10
 
11
11
  ## Default configuration
12
12
 
@@ -27,24 +27,22 @@ The file is optional, and Maestro uses all default values when it is absent.
27
27
  }
28
28
  ```
29
29
 
30
- Maestro does not configure a branch, a target branch, or a worktree directory. It uses the current Git checkout and branch.
31
-
32
30
  ## Fields
33
31
 
34
32
  | Field | Required | Default | Rules |
35
33
  |---|---:|---|---|
36
- | `version` | Yes, when the file exists | `1.0.0` | Semantic version of the configuration schema. Must be supported by the installed Maestro release. |
37
- | `specDirectory` | No | `.specs` | Relative path inside the Git repository. |
38
- | `builder` | No | Builder defaults | May contain supported builder overrides. |
34
+ | `version` | Yes, when the file exists | `1.0.0` | Configuration format version. Only `1.0.0` is supported. |
35
+ | `specDirectory` | No | `.specs` | Relative path below the project root. |
36
+ | `builder` | No | Builder defaults | Overrides supported builder fields. |
39
37
  | `builder.model` | No | `openai-codex/gpt-5.6-luna` | Full `provider/model` identifier. |
40
38
  | `builder.thinking` | No | `max` | One supported thinking level. |
41
39
  | `builder.timeoutMinutes` | No | `60` | Integer from `1` to `1440`. Applies to each builder run. |
42
- | `verifier` | No | Verifier defaults | May contain supported verifier overrides. |
40
+ | `verifier` | No | Verifier defaults | Overrides supported verifier fields. |
43
41
  | `verifier.model` | No | `openai-codex/gpt-6.1-sol` | Full `provider/model` identifier. |
44
42
  | `verifier.thinking` | No | `high` | One supported thinking level. |
45
43
  | `verifier.timeoutMinutes` | No | `60` | Integer from `1` to `1440`. Applies to each verifier run. |
46
44
 
47
- Supported thinking levels:
45
+ Model identifiers use the full `provider/model` form shown in the defaults. Maestro accepts these thinking levels:
48
46
 
49
47
  ```text
50
48
  off
@@ -73,26 +71,20 @@ This example keeps every default except the builder timeout.
73
71
 
74
72
  ## Schema version
75
73
 
76
- `version` identifies the configuration schema. It is separate from the npm package version, and it's a mechanism for future-proof additions.
74
+ `version` identifies the configuration format, not the npm package version. The supported value is `1.0.0`. Other values stop activation.
77
75
 
78
76
  ## Path rules
79
77
 
80
78
  `specDirectory` must meet these rules:
81
79
 
82
- 1. The path is relative to the Git repository root.
83
- 2. The path points below the repository root after `.` and `..` are resolved.
80
+ 1. The path is non-empty and relative to the project root.
81
+ 2. The path stays below that root after `.` and `..` are resolved.
82
+ 3. The path is not the project root itself.
84
83
 
85
- It's owner responsibility to arrange the filesystem in order to support artifact writes and Git checkpoints.
84
+ For example, `specDirectory: "planning/specs"` places specs in `<project-root>/planning/specs/`. Absolute paths and paths outside the project root are rejected. The owner is responsible for directory permissions that allow Maestro to save artifacts.
86
85
 
87
86
  ## Model access
88
87
 
89
88
  Maestro checks both configured models during activation. Each model must exist and have valid authentication.
90
89
 
91
- A model error stops activation and identifies the affected model. Update the configuration or authenticate the provider, then run `/maestro` again.
92
-
93
- Agent names have fixed value:
94
-
95
- ```text
96
- maestro.builder
97
- maestro.verifier
98
- ```
90
+ A model error stops activation and identifies the affected model. The owner can correct the model identifier or authenticate the provider, then run `/maestro` again. Agent names and context are described in [Subagent integration](subagent-integration.md#roles-and-context).
@@ -1,56 +1,34 @@
1
1
  # Subagent integration
2
2
 
3
- Maestro uses `pi-subagents` to run the builder and verifier as child sessions.
3
+ Maestro uses `pi-subagents` to run the builder and verifier as child sessions. A child session is a separate Pi session for one role. The owner stays in the main Maestro conversation.
4
4
 
5
- A child session is a separate Pi session that receives one role and one task.
5
+ ## Roles and context
6
6
 
7
- ## Agent definitions
7
+ The package supplies both roles and the tools that save their results:
8
8
 
9
- The package contains two agent definitions:
9
+ | Role | Agent name | Definition |
10
+ |---|---|---|
11
+ | Builder | `maestro.builder` | [`agents/builder.md`](../agents/builder.md) |
12
+ | Verifier | `maestro.verifier` | [`agents/verifier.md`](../agents/verifier.md) |
10
13
 
11
- 1. [`agents/builder.md`](../agents/builder.md) defines the builder role.
12
- 2. [`agents/verifier.md`](../agents/verifier.md) defines the verifier role.
14
+ Each run starts with a fresh conversation, not the main session's conversation history. Both agents inherit project instructions, the owner's global `AGENTS.md`, and available skills. The global file normally lives at `~/.pi/agent/AGENTS.md`.
13
15
 
14
- Both agents receive project instructions and your global `AGENTS.md` from the Pi agent directory, normally `~/.pi/agent/AGENTS.md`.
16
+ Maestro supplies the spec ID, project directory, model, thinking level, and timeout. The agents read the approved spec and saved artifacts to understand the work. Earlier artifacts provide context, not proof.
15
17
 
16
- ## Package registration
18
+ The owner does not call builder or verifier tools directly. Maestro starts the builder after `GREEN FLAG` approval and the verifier after successful builder completion.
17
19
 
18
- `package.json` registers the agent directory with Pi:
20
+ ## Following a run
19
21
 
20
- ```json
21
- {
22
- "pi": {
23
- "subagents": {
24
- "agents": [
25
- "./agents"
26
- ]
27
- }
28
- }
29
- }
30
- ```
22
+ Runs stay in the foreground and occur one at a time. Pi waits for each run to finish before Maestro continues. Maestro does not run the builder and verifier in parallel or in the background.
31
23
 
32
- The `pi.subagents.agents` field tells `pi-subagents` to scan `./agents` for agent definitions.
24
+ Maestro's Pi status shows the workflow phase. `pi-subagents` FleetView shows agent activity, and `/subagents-fleet` opens its inspector for details and transcripts.
33
25
 
34
- The `package` and `name` fields in each file form the runtime name that delegation uses.
26
+ Each child saves its result through Maestro tools before returning.
35
27
 
36
- ## Run flow
28
+ If a run fails or returns without a valid saved result, Maestro reports the error and stops. Manual follow-up is described in [Limitations](workflow.md#limitations).
37
29
 
38
- When the owner runs the builder, the integration follows these steps:
30
+ ## External configuration
39
31
 
40
- 1. The owner calls `maestro_run_builder`.
41
- 2. `src/tools/main/run-builder.ts` prepares the workflow and emits a delegation request.
42
- 3. The request sets `agent: AGENTS.BUILDER`.
43
- 4. `AGENTS.BUILDER` has the value `maestro.builder` in `src/config/schema.ts`.
44
- 5. `pi-subagents` resolves `maestro.builder` to `agents/builder.md`.
45
- 6. The child receives the system prompt and the tools from that agent definition.
46
- 7. Maestro waits for the child to finish, checks its result, and returns it to the owner.
32
+ The `pi-subagents` extension must be installed and enabled in Pi. Builder and verifier model choices, thinking levels, and timeouts come from [Maestro configuration](configuration.md). Other `pi-subagents` configuration remains the owner's responsibility.
47
33
 
48
- Maestro also passes the explicit spec ID, the current repository root, the configured model, the thinking level, the timeout, and a fresh context.
49
-
50
- `maestro_run_verifier` in `src/tools/main/run-verifier.ts` uses the same flow with `AGENTS.VERIFIER` and `maestro.verifier`. Both tools run in the foreground and wait for a result.
51
-
52
- ## Subagent extension
53
-
54
- Both agent files set `subagentOnlyExtensions` to `../extensions/maestro-subagent.ts`.
55
-
56
- This field tells `pi-subagents` to load the extension only in the child session for that agent.
34
+ Maestro does not invoke Git to manage its workflow. `pi-subagents` can use Git internally.