pi-maestro-flow 0.2.0 → 0.3.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.
Files changed (235) hide show
  1. package/README.md +44 -72
  2. package/agents/cross-role-reviewer.md +1 -1
  3. package/agents/impeccable-agent.md +1 -1
  4. package/agents/ralph-executor.md +1 -1
  5. package/agents/team-worker.md +1 -1
  6. package/agents/workflow-analyzer.md +1 -1
  7. package/agents/workflow-codebase-mapper.md +1 -1
  8. package/agents/workflow-collab-planner.md +1 -1
  9. package/agents/workflow-debugger.md +1 -1
  10. package/agents/workflow-executor.md +1 -1
  11. package/agents/workflow-integration-checker.md +1 -1
  12. package/agents/workflow-nyquist-auditor.md +1 -1
  13. package/agents/workflow-phase-researcher.md +1 -1
  14. package/agents/workflow-planner.md +1 -1
  15. package/agents/workflow-project-researcher.md +1 -1
  16. package/agents/workflow-reviewer.md +1 -1
  17. package/agents/workflow-verifier.md +1 -1
  18. package/package.json +18 -4
  19. package/skills/codify-to-knowhow/SKILL.md +1 -1
  20. package/skills/delegation-check/SKILL.md +1 -1
  21. package/skills/domain-add/SKILL.md +5 -5
  22. package/skills/insight-challenge/SKILL.md +1 -1
  23. package/skills/learn-decompose/SKILL.md +4 -4
  24. package/skills/learn-follow/SKILL.md +5 -5
  25. package/skills/learn-investigate/SKILL.md +5 -5
  26. package/skills/learn-second-opinion/SKILL.md +5 -5
  27. package/skills/maestro/SKILL.md +8 -8
  28. package/skills/maestro-amend/SKILL.md +4 -4
  29. package/skills/maestro-analyze/SKILL.md +9 -9
  30. package/skills/maestro-blueprint/SKILL.md +7 -7
  31. package/skills/maestro-brainstorm/SKILL.md +10 -10
  32. package/skills/maestro-collab/SKILL.md +4 -4
  33. package/skills/maestro-companion/SKILL.md +3 -3
  34. package/skills/maestro-composer/SKILL.md +10 -10
  35. package/skills/maestro-execute/SKILL.md +8 -8
  36. package/skills/maestro-fork/SKILL.md +7 -7
  37. package/skills/maestro-grill/SKILL.md +12 -12
  38. package/skills/maestro-guard/SKILL.md +5 -5
  39. package/skills/maestro-help/SKILL.md +3 -3
  40. package/skills/maestro-impeccable/SKILL.md +7 -7
  41. package/skills/maestro-init/SKILL.md +8 -8
  42. package/skills/maestro-merge/SKILL.md +6 -6
  43. package/skills/maestro-milestone-audit/SKILL.md +3 -3
  44. package/skills/maestro-milestone-complete/SKILL.md +8 -8
  45. package/skills/maestro-milestone-release/SKILL.md +9 -9
  46. package/skills/maestro-next/SKILL.md +5 -5
  47. package/skills/maestro-overlay/SKILL.md +19 -19
  48. package/skills/maestro-plan/SKILL.md +8 -8
  49. package/skills/maestro-player/SKILL.md +5 -5
  50. package/skills/maestro-quick/SKILL.md +5 -5
  51. package/skills/maestro-ralph/SKILL.md +15 -15
  52. package/skills/maestro-ralph-cli/SKILL.md +6 -6
  53. package/skills/maestro-ralph-cli-execute/SKILL.md +2 -2
  54. package/skills/maestro-ralph-execute/SKILL.md +4 -4
  55. package/skills/maestro-ralph-v2/SKILL.md +17 -17
  56. package/skills/maestro-roadmap/SKILL.md +7 -7
  57. package/skills/maestro-swarm-workflow/SKILL.md +9 -9
  58. package/skills/maestro-tools-execute/SKILL.md +5 -5
  59. package/skills/maestro-tools-register/SKILL.md +7 -7
  60. package/skills/maestro-ui-codify/SKILL.md +8 -8
  61. package/skills/maestro-universal-workflow/SKILL.md +15 -15
  62. package/skills/maestro-update/SKILL.md +10 -10
  63. package/skills/manage-codebase-rebuild/SKILL.md +4 -4
  64. package/skills/manage-drift-realign/SKILL.md +7 -7
  65. package/skills/manage-harvest/SKILL.md +5 -5
  66. package/skills/manage-issue/SKILL.md +4 -4
  67. package/skills/manage-issue-discover/SKILL.md +7 -7
  68. package/skills/manage-kg-extractors/SKILL.md +3 -3
  69. package/skills/manage-knowhow/SKILL.md +3 -3
  70. package/skills/manage-knowhow-capture/SKILL.md +4 -4
  71. package/skills/manage-knowledge-audit/SKILL.md +5 -5
  72. package/skills/manage-status/SKILL.md +3 -3
  73. package/skills/manage-wiki/SKILL.md +5 -5
  74. package/skills/odyssey-debug/SKILL.md +13 -13
  75. package/skills/odyssey-improve/SKILL.md +15 -15
  76. package/skills/odyssey-planex/SKILL.md +16 -16
  77. package/skills/odyssey-review-test-fix/SKILL.md +11 -11
  78. package/skills/odyssey-ui/SKILL.md +10 -10
  79. package/skills/prompt-generator/SKILL.md +5 -5
  80. package/skills/quality-auto-test/SKILL.md +3 -3
  81. package/skills/quality-debug/SKILL.md +3 -3
  82. package/skills/quality-refactor/SKILL.md +3 -3
  83. package/skills/quality-retrospective/SKILL.md +9 -9
  84. package/skills/quality-review/SKILL.md +4 -4
  85. package/skills/quality-sync/SKILL.md +3 -3
  86. package/skills/quality-test/SKILL.md +4 -4
  87. package/skills/scholar-anti-ai-writing/SKILL.md +1 -1
  88. package/skills/scholar-citation-verify/SKILL.md +1 -1
  89. package/skills/scholar-experiment/SKILL.md +2 -2
  90. package/skills/scholar-ideation/SKILL.md +7 -7
  91. package/skills/scholar-latex-organizer/SKILL.md +1 -1
  92. package/skills/scholar-publish/SKILL.md +3 -3
  93. package/skills/scholar-rebuttal-pro/SKILL.md +3 -3
  94. package/skills/scholar-review/SKILL.md +1 -1
  95. package/skills/scholar-writing/SKILL.md +1 -1
  96. package/skills/security-audit/SKILL.md +2 -2
  97. package/skills/skill-generator/SKILL.md +3 -3
  98. package/skills/skill-iter-tune/SKILL.md +3 -3
  99. package/skills/skill-simplify/SKILL.md +1 -1
  100. package/skills/skill-tuning/SKILL.md +1 -1
  101. package/skills/spec-add/SKILL.md +5 -5
  102. package/skills/spec-load/SKILL.md +3 -3
  103. package/skills/spec-remove/SKILL.md +4 -4
  104. package/skills/spec-setup/SKILL.md +6 -6
  105. package/skills/team-adversarial-swarm/SKILL.md +5 -5
  106. package/skills/team-arch-opt/SKILL.md +2 -2
  107. package/skills/team-brainstorm/SKILL.md +3 -3
  108. package/skills/team-coordinate/SKILL.md +4 -4
  109. package/skills/team-designer/SKILL.md +1 -1
  110. package/skills/team-executor/SKILL.md +3 -3
  111. package/skills/team-frontend/SKILL.md +2 -2
  112. package/skills/team-frontend-debug/SKILL.md +3 -3
  113. package/skills/team-interactive-craft/SKILL.md +2 -2
  114. package/skills/team-issue/SKILL.md +3 -3
  115. package/skills/team-lifecycle-v4/SKILL.md +4 -4
  116. package/skills/team-motion-design/SKILL.md +2 -2
  117. package/skills/team-perf-opt/SKILL.md +3 -3
  118. package/skills/team-planex/SKILL.md +2 -2
  119. package/skills/team-quality-assurance/SKILL.md +3 -3
  120. package/skills/team-review/SKILL.md +3 -3
  121. package/skills/team-roadmap-dev/SKILL.md +3 -3
  122. package/skills/team-swarm/SKILL.md +4 -4
  123. package/skills/team-tech-debt/SKILL.md +2 -2
  124. package/skills/team-testing/SKILL.md +3 -3
  125. package/skills/team-ui-polish/SKILL.md +2 -2
  126. package/skills/team-uidesign/SKILL.md +2 -2
  127. package/skills/team-ultra-analyze/SKILL.md +4 -4
  128. package/skills/team-ux-improve/SKILL.md +3 -3
  129. package/skills/team-visual-a11y/SKILL.md +2 -2
  130. package/skills/workflow-skill-designer/SKILL.md +8 -8
  131. package/templates/business-test-report.json +68 -0
  132. package/templates/config.json +48 -0
  133. package/templates/context.md +16 -0
  134. package/templates/doc-index.json +11 -0
  135. package/templates/index.json +68 -0
  136. package/templates/issue.json +36 -0
  137. package/templates/plan.json +38 -0
  138. package/templates/project.md +60 -0
  139. package/templates/reflection-log.md +20 -0
  140. package/templates/roadmap.md +45 -0
  141. package/templates/scratch-index.json +19 -0
  142. package/templates/search-tool.json +1 -0
  143. package/templates/search-tools.md +47 -0
  144. package/templates/state.json +18 -0
  145. package/templates/task-summary.md +21 -0
  146. package/templates/task.json +89 -0
  147. package/templates/terminology-template.json +22 -0
  148. package/templates/uat.md +21 -0
  149. package/templates/validation.json +31 -0
  150. package/templates/verification.json +37 -0
  151. package/templates/workflow.md +14 -0
  152. package/templates/worktree-scope.json +9 -0
  153. package/templates/worktrees.json +26 -0
  154. package/workflows/agy-instructions.md +156 -0
  155. package/workflows/analyze.md +768 -0
  156. package/workflows/auto-test.md +705 -0
  157. package/workflows/blueprint.md +406 -0
  158. package/workflows/boundary-grill.md +50 -0
  159. package/workflows/brainstorm.md +508 -0
  160. package/workflows/business-test.md +574 -0
  161. package/workflows/chinese-response.md +25 -0
  162. package/workflows/claude-instructions.md +167 -0
  163. package/workflows/codebase-rebuild.md +267 -0
  164. package/workflows/codebase-refresh.md +168 -0
  165. package/workflows/codex-instructions.md +156 -0
  166. package/workflows/coding-philosophy.md +70 -0
  167. package/workflows/command-authoring.md +823 -0
  168. package/workflows/debug.md +409 -0
  169. package/workflows/delegate-usage.md +99 -0
  170. package/workflows/domain-add.md +121 -0
  171. package/workflows/drift-realign.md +396 -0
  172. package/workflows/execute.md +631 -0
  173. package/workflows/explore-usage.md +93 -0
  174. package/workflows/finish-work.md +124 -0
  175. package/workflows/fork.md +162 -0
  176. package/workflows/grill.md +494 -0
  177. package/workflows/harvest.md +478 -0
  178. package/workflows/impeccable.md +168 -0
  179. package/workflows/init.md +157 -0
  180. package/workflows/instruction-authoring-guide.md +97 -0
  181. package/workflows/integration-test.md +186 -0
  182. package/workflows/interview-mechanics.md +8 -0
  183. package/workflows/issue-analyze.md +20 -0
  184. package/workflows/issue-discover.md +238 -0
  185. package/workflows/issue-execute.md +110 -0
  186. package/workflows/issue-gaps-analyze.codex.md +256 -0
  187. package/workflows/issue-gaps-analyze.md +215 -0
  188. package/workflows/issue-plan.md +110 -0
  189. package/workflows/issue.md +338 -0
  190. package/workflows/knowhow.md +429 -0
  191. package/workflows/knowledge-audit.md +355 -0
  192. package/workflows/learn.md +271 -0
  193. package/workflows/maestro-chain-execute.md +20 -0
  194. package/workflows/maestro-link-coordinate.md +114 -0
  195. package/workflows/maestro-super.md +120 -0
  196. package/workflows/maestro.md +501 -0
  197. package/workflows/map.md +74 -0
  198. package/workflows/merge.md +122 -0
  199. package/workflows/milestone-audit.md +155 -0
  200. package/workflows/milestone-complete.md +167 -0
  201. package/workflows/milestone-release.md +82 -0
  202. package/workflows/odyssey-base-codex.md +305 -0
  203. package/workflows/odyssey-base.md +256 -0
  204. package/workflows/overlays.md +109 -0
  205. package/workflows/plan.md +520 -0
  206. package/workflows/quick.md +350 -0
  207. package/workflows/ralph-amend-goal.md +177 -0
  208. package/workflows/refactor.md +87 -0
  209. package/workflows/retrospective.md +471 -0
  210. package/workflows/review.md +448 -0
  211. package/workflows/roadmap-common.md +193 -0
  212. package/workflows/roadmap.md +106 -0
  213. package/workflows/shell-exec-protocol.md +30 -0
  214. package/workflows/skill-authoring.md +265 -0
  215. package/workflows/spec-generate.md +475 -0
  216. package/workflows/specs-add.md +123 -0
  217. package/workflows/specs-load.md +76 -0
  218. package/workflows/specs-remove.md +104 -0
  219. package/workflows/specs-setup.md +316 -0
  220. package/workflows/status.md +149 -0
  221. package/workflows/sync.md +116 -0
  222. package/workflows/tdd.md +255 -0
  223. package/workflows/test-gen.md +226 -0
  224. package/workflows/test.md +385 -0
  225. package/workflows/tools-spec.md +70 -0
  226. package/workflows/ui-codify-extract.md +372 -0
  227. package/workflows/ui-codify-knowhow.md +258 -0
  228. package/workflows/ui-codify-package.md +159 -0
  229. package/workflows/ui-codify.md +227 -0
  230. package/workflows/ui-design.md +393 -0
  231. package/workflows/ui-style.md +201 -0
  232. package/workflows/verify.md +557 -0
  233. package/workflows/wiki-connect.md +153 -0
  234. package/workflows/wiki-digest.md +180 -0
  235. package/workflows/wiki-manage.md +113 -0
@@ -0,0 +1,93 @@
1
+ # Explore Usage
2
+
3
+ ```bash
4
+ maestro explore "FIND: <target + condition>\nSCOPE: <paths>" [more prompts...] [options]
5
+ ```
6
+
7
+ Lightweight read-only codebase search. 1 prompt = 1 agent.
8
+ **Not for**: write-mode, long sessions, follow-ups — use `delegate`.
9
+
10
+ ## Options
11
+
12
+ | Option | Description | Default |
13
+ |--------|-------------|---------|
14
+ | `-e, --endpoint <names>` | Endpoint name(s), comma-separated | First available |
15
+ | `--all` | Fan out each prompt to all endpoints | — |
16
+ | `--max-turns <n>` | Max agent turns per job | Config or `6` |
17
+ | `-f, --file <path>` | Load prompts from JSON or text file | — |
18
+ | `--cd <dir>` | Working directory | Current |
19
+ | `--json` | Output results as JSON | — |
20
+
21
+ Endpoint resolution: `--endpoint` > `--all` > first available.
22
+
23
+ ## Prompt Rules
24
+
25
+ **FIND + SCOPE is minimum standard.** Bare FIND produces unfocused results.
26
+
27
+ | Field | Required | Purpose |
28
+ |-------|----------|---------|
29
+ | `FIND` | **Yes** | Precise target — what exactly + condition |
30
+ | `SCOPE` | **Yes** | File patterns or directories to search |
31
+ | `EXCLUDE` | No | What to skip |
32
+ | `ATTENTION` | No | Edge cases to watch |
33
+ | `EXPECTED` | Recommended | Output format (`file:line` list, summary, JSON) |
34
+
35
+ ### Bad vs Good
36
+
37
+ ```
38
+ # ❌ Vague — no actionable target
39
+ FIND: database patterns
40
+ FIND: error handling
41
+
42
+ # ✅ Specific target + condition + scope
43
+ FIND: Functions that execute SQL queries without parameterized inputs
44
+ SCOPE: src/db/**/*.ts, src/api/**/*.ts
45
+
46
+ FIND: catch blocks that swallow errors silently (empty catch or catch-and-log-only)
47
+ SCOPE: src/services/
48
+ EXPECTED: file:line list with severity
49
+ ```
50
+
51
+ ### Multi-Prompt
52
+
53
+ **Decompose by angle, not by keyword.** Each prompt gets one focused question + scope.
54
+
55
+ ```
56
+ # ❌ Keyword dump in one prompt
57
+ "database error handling auth patterns"
58
+
59
+ # ✅ One angle per prompt
60
+ maestro explore \
61
+ "FIND: N+1 query patterns\nSCOPE: src/db/" \
62
+ "FIND: Unparameterized SQL\nSCOPE: src/db/, src/api/" \
63
+ "FIND: Missing error propagation\nSCOPE: src/services/"
64
+ ```
65
+
66
+ Input formats: inline strings, JSON file (`-f`), text file (`-f`), or mixed.
67
+ JSON supports per-prompt endpoint override:
68
+
69
+ ```json
70
+ [{ "prompt": "FIND: auth bypass\nSCOPE: src/api/", "endpoint": "deepseek" }]
71
+ ```
72
+
73
+ ## Session
74
+
75
+ ```bash
76
+ maestro explore show # list sessions
77
+ maestro explore output <id> # view results
78
+ maestro explore output <id> --json # JSON output
79
+ ```
80
+
81
+ ## Execution Rules
82
+
83
+ Multi-prompt — **background**:
84
+
85
+ ```
86
+ Bash({ command: "maestro explore \"p1\" \"p2\" --json", run_in_background: true })
87
+ ```
88
+
89
+ Single quick lookup — foreground:
90
+
91
+ ```
92
+ Bash({ command: "maestro explore \"Where is X defined?\"" })
93
+ ```
@@ -0,0 +1,124 @@
1
+ # Workflow: finish-work
2
+
3
+ ## Inputs
4
+
5
+ `SESSION_DIR`, `SESSION_TYPE` (grill | brainstorm | analyze | blueprint | plan | execute | verify), `SESSION_ID`, `LINKED_MILESTONE` (optional).
6
+
7
+ ## Steps
8
+
9
+ ### 1. Detect outputs
10
+
11
+ Scan `SESSION_DIR` for known files. Missing file → log W0xx, flag [LOW CONFIDENCE]. None found → skip to Step 4 with `extraction.harvested = false`.
12
+
13
+ | File | Session types | Yields |
14
+ |------|---------------|--------|
15
+ | `context-package.json` | grill/brainstorm/analyze/blueprint | constraints + insights |
16
+ | `terminology.md` | grill | domain terms |
17
+ | `grill-report.md` | grill | decisions + risk register |
18
+ | `conclusions.json` | analyze | decisions + recommendations |
19
+ | `reflection-log.md` | execute | lessons + pitfalls |
20
+ | `{role}/analysis.md` | brainstorm | role decisions |
21
+
22
+ ### 2. Extract fragments
23
+
24
+ Build `fragments[]` from detected files. Each: `{ kind, category, title, content, keywords[], confidence, ref }`.
25
+
26
+ **Routing table** — `locked` status or `priority ≥ medium` required unless noted:
27
+
28
+ | Source | → Store | Category |
29
+ |--------|---------|----------|
30
+ | `context-package.json#constraints[locked]` | spec (rule) | `arch` if module/layer/boundary, else `coding` |
31
+ | `context-package.json#insights[]` | knowhow (`DCS`/`RCP`) | `arch` for decisions, `coding` for patterns |
32
+ | `conclusions.json#decisions[locked]` | spec (rule) | `arch` |
33
+ | `conclusions.json#recommendations[≥medium]` | knowhow (`REF`) | area-derived |
34
+ | `reflection-log.md` §Lessons/§Pitfalls | < 200 chars → spec (`learning`), else knowhow (`KNW`) | `learning` |
35
+ | `{role}/analysis.md` §Decisions[locked] | spec (rule) | role-derived |
36
+ | `grill-report.md` §Synthesis[locked] | spec (rule) | `arch` if scope/integration/security, else `coding` |
37
+ | `grill-report.md` §Risk Register[≥medium] | knowhow (`REF`) | `debug` |
38
+ | `terminology.md` locked terms | knowhow (`REF`) | `coding` |
39
+
40
+ **Confidence** (drop if < 0.5): locked/decisions heading +0.3 · ≥3 keywords +0.2 · has rationale +0.2 · length 50-2000 +0.2 · has ref +0.1
41
+
42
+ **Keywords**: 3-5 lowercased domain terms, frequency-ranked nouns/identifiers, stop words filtered.
43
+
44
+ **Dedup**: hash `(kind, content[:100])` — skip if existing entry matches. MANDATORY via `maestro spec list --json` + `maestro knowhow list --json`.
45
+
46
+ **Relationship to existing knowledge**: for `kind == "rule"` fragments, search existing spec in the same category (`maestro search "<keywords>" --type spec --json`, note each hit's `sid`). Classify against the closest existing entry — the two outcomes are distinct, do NOT conflate:
47
+ - **supersedes** (evolution): the new rule replaces the old on the same topic — the old is now outdated, not merely disputed. Attach `supersedes = <old-sid>`.
48
+ - **conflicts** (contradiction): both rules are plausible and a human must adjudicate which wins. Attach `conflicting_entry = { file, line }` + `conflict_note`.
49
+ - **independent**: no strong overlap → no metadata.
50
+
51
+ Never drop — proceed with whatever metadata attached.
52
+
53
+ ### 3. Route fragments
54
+
55
+ Prompt once (unless `-y` auto mode):
56
+ ```
57
+ Found {N} fragments — {S_spec} spec / {S_knowhow} knowhow. Apply? (auto | spec-only | knowhow-only | skip)
58
+ ```
59
+
60
+ Routing — all CLI calls MANDATORY, NOT SUBSTITUTABLE:
61
+
62
+ - **spec**: `maestro spec add <category> "<title>" "<content>" --keywords {csv} --description "<summary>" --source finish-work --json` → capture returned `sid` + id into `spec_ids[]` (the `--json` output carries the new entry's `sid`, needed for supersession).
63
+ - **spec that supersedes** (evolution): after adding the new entry, retire the old one: `maestro spec supersede <old-sid> --by <new-sid>`. Old entry → `status="deprecated"` (excluded from search + agent injection), chain preserved and inspectable via `maestro spec history <sid>`. Record into `supersede_marks[]`.
64
+ - **spec that conflicts** (contradiction): after adding, mark the old entry for human review: `maestro spec conflict mark <file> <line> --note "<note>"` → `confidence="contested"` (search ×0.5, `[CONTESTED]` badge, still injected). Resolution deferred to `/manage-knowledge-audit`. Record into `conflict_marks[]`.
65
+ - **knowhow**: `maestro knowhow add --type {DCS|RCP|REF|KNW} --title "<title>" --body "<content>" --keywords {csv}` → capture id into `knowhow_ids[]`
66
+ - **below threshold**: increment `skipped_count`
67
+ - **CLI failure**: log W002, continue; flag [LOW CONFIDENCE]
68
+
69
+ ### 3.5 Domain term extraction
70
+
71
+ Skip if `.workflow/domain/` absent or no term sources or all candidates already registered.
72
+
73
+ Sources (priority order): `terminology.md` → `context-package.json#domain.terminology[]` → `conclusions.json#recommendations` with domain keywords.
74
+
75
+ Process: collect candidates → filter registered terms → interactive confirm (always, `-y` does NOT bypass) → MANDATORY `maestro domain add` → record in `extraction.domain_ids[]`.
76
+
77
+ ### 4. Write archive.json
78
+
79
+ Idempotent overwrite. Schema `session-archive/1.0`:
80
+
81
+ ```jsonc
82
+ {
83
+ "$schema": "session-archive/1.0",
84
+ "session_id": "", "session_type": "", "session_path": "",
85
+ "lifecycle": { "status": "sealed", "sealed_at": "", "archived_at": null, "linked_milestone": null },
86
+ "content_refs": [/* { type, path } per detected file */],
87
+ "extraction": {
88
+ "harvested": true, "harvested_at": "",
89
+ "spec_ids": [], "knowhow_ids": [], "domain_ids": [],
90
+ "supersede_marks": [/* { old_sid, new_sid } — old entry deprecated, chain preserved */],
91
+ "conflict_marks": [/* { file, line, note } — old entry contested, pending audit */],
92
+ "skipped_count": 0
93
+ },
94
+ "pruned": null
95
+ }
96
+ // No fragments or user skip: "extraction": { "harvested": false, "reason": "no-signal | user-skip | harvest-failed" }
97
+ ```
98
+
99
+ ### 5. Report
100
+
101
+ ```
102
+ === SESSION SEALED ===
103
+ Session: {SESSION_ID} ({SESSION_TYPE})
104
+ Knowledge: {spec} spec / {knowhow} knowhow extracted, {skipped} skipped
105
+ Superseded: {supersede_count} old entries deprecated (chain preserved — maestro spec history <sid>)
106
+ Conflicts: {conflict_count} entries marked [CONTESTED] — resolve via /manage-knowledge-audit
107
+ Next: /maestro-milestone-complete → archive + prune
108
+ ```
109
+
110
+ ## Boundary
111
+
112
+ - Does NOT flip `archived_at` or move files (milestone-complete Step 2.3)
113
+ - Does NOT prune `context-package.json` (milestone-complete only)
114
+ - Does NOT touch `state.json` (caller handles)
115
+ - Does NOT create issues (use `/manage-harvest` or `/manage-issue-discover`)
116
+
117
+ ## Errors
118
+
119
+ | Code | Condition |
120
+ |------|-----------|
121
+ | E001 | SESSION_DIR missing |
122
+ | E002 | SESSION_TYPE unknown |
123
+ | W001 | No substantive outputs (seals with empty content_refs) |
124
+ | W002 | CLI invocation failed (continue with remaining) |
@@ -0,0 +1,162 @@
1
+ # Workflow: fork
2
+
3
+ ---
4
+
5
+ ## Step 1: Parse Arguments and Flags
6
+
7
+ ```
8
+ Timestamps use UTC+8 ISO format throughout.
9
+
10
+ Parse from $ARGUMENTS:
11
+ --sync → syncMode (sync existing worktree instead of forking)
12
+ --base <ref> → baseBranch (default: HEAD)
13
+ -m <N> or bare <N> → milestoneNum (1-based)
14
+ ```
15
+
16
+ ---
17
+
18
+ ## Step 2: Validate Prerequisites
19
+
20
+ ```
21
+ Require: .workflow/state.json (E001), .workflow/roadmap.md (E002), milestoneNum (E004).
22
+ Reject: .workflow/worktree-scope.json present (E003 — cannot fork from inside a worktree).
23
+
24
+ Read projectState from state.json, config from config.json (defaults if missing).
25
+ worktreeRoot = config.worktree?.root ?? ".worktrees"
26
+ branchPrefix = config.worktree?.branch_prefix ?? "milestone/"
27
+ ```
28
+
29
+ ---
30
+
31
+ ## Step 3: Resolve Milestone
32
+
33
+ ```
34
+ Lookup milestoneEntry from projectState.milestones[milestoneNum - 1] (1-based).
35
+ E005 if no milestones array; E006 if index out of range (list available milestones).
36
+
37
+ Extract: milestoneName (.name), milestoneTitle (.title), milestonePhases (.phases).
38
+ milestoneSlug = kebab-case of milestoneName, max 40 chars.
39
+ ```
40
+
41
+ ---
42
+
43
+ ## Step 4: Sync Mode (--sync)
44
+
45
+ If `syncMode` is true, treat as sync operation on existing worktree, not a fork.
46
+
47
+ ```
48
+ IF syncMode:
49
+ Find active worktree entry for milestoneNum in worktrees.json → E007 if not found.
50
+ Git merge main into worktree → warn and exit on conflict.
51
+ Re-copy shared context: project.md, roadmap.md, config.json (if exists), specs/ (if exists).
52
+ Display sync confirmation. EXIT.
53
+ ```
54
+
55
+ ---
56
+
57
+ ## Step 5: Validate & Confirm
58
+
59
+ ```
60
+ Derive phase statuses from artifact registry (execute artifacts → completed/in_progress/pending).
61
+ Reject if all phases completed (nothing to fork).
62
+ Reject if milestone already has active worktree (E008).
63
+
64
+ Display milestone info and phase list with statuses.
65
+ Confirm with user → exit if declined.
66
+ ```
67
+
68
+ ---
69
+
70
+ ## Step 6: Create Worktree
71
+
72
+ ```
73
+ forkSessionId = "fork-{UTC8_compact_timestamp}"
74
+ baseCommit = git rev-parse HEAD
75
+ branch = {branchPrefix}{milestoneSlug}
76
+ wtPath = {worktreeRoot}/m{milestoneNum}-{milestoneSlug}
77
+
78
+ 6a: Clean up stale worktree/branch at wtPath if exists (ignore errors).
79
+ 6b: git worktree add -b {branch} {wtPath} {baseBranch}
80
+ 6c: mkdir -p {wtPath}/.workflow/scratch
81
+
82
+ 6d: Copy shared context → wtPath/.workflow/:
83
+ project.md, roadmap.md, config.json (if exists), specs/ (if exists)
84
+
85
+ 6e: Copy milestone artifacts — all artifacts matching milestoneName.
86
+ 6f: Copy dependency artifacts — phases from milestoneEntry.depends_on not in owned phases.
87
+
88
+ 6g: Build phase_dependencies map (external deps per owned phase).
89
+ ```
90
+
91
+ Write `{wtPath}/.workflow/worktree-scope.json`:
92
+
93
+ ```json
94
+ {
95
+ "worktree": true,
96
+ "milestone_num": "{milestoneNum}",
97
+ "milestone": "{milestoneName}",
98
+ "owned_phases": ["{ownedPhaseNumbers}"],
99
+ "phase_dependencies": "{phaseDeps}",
100
+ "main_worktree": "{resolve(cwd)}",
101
+ "branch": "{branch}",
102
+ "base_commit": "{baseCommit}",
103
+ "created_at": "{UTC8_ISO}"
104
+ }
105
+ ```
106
+
107
+ ```
108
+ 6i: Write scoped state.json — clone mainState with current_milestone set,
109
+ artifacts filtered to milestone-owned phases only.
110
+ ```
111
+
112
+ ---
113
+
114
+ ## Step 7: Update Main Registry
115
+
116
+ ```
117
+ Load or initialize .workflow/worktrees.json (default: { version:"1.0", worktrees:[], fork_sessions:[] }).
118
+
119
+ Append to worktrees[]:
120
+ { milestone_num, milestone, slug, branch, path:wtPath, base_commit, status:"active",
121
+ created_at, owned_phases, fork_session:forkSessionId }
122
+
123
+ Append to fork_sessions[]:
124
+ { session_id:forkSessionId, created_at, milestone_num, milestone, base_branch, base_commit }
125
+
126
+ Write worktrees.json. Update mainState.last_updated, write state.json.
127
+ Note: worktrees.json owned_phases tracks forked state — no per-phase marking needed.
128
+ ```
129
+
130
+ ---
131
+
132
+ ## Step 8: Display Summary
133
+
134
+ ```
135
+ Display:
136
+ === FORK COMPLETE ===
137
+ Session: {forkSessionId}
138
+ Base: {baseBranch} ({baseCommit.substring(0, 7)})
139
+ Milestone: M{milestoneNum} — {milestoneName} ({milestoneTitle})
140
+ Branch: {branch}
141
+ Path: {wtPath}
142
+ Phases: {ownedPhaseNumbers.join(', ')}
143
+
144
+ Next steps (run in the worktree):
145
+ cd {wtPath}
146
+
147
+ # Sequential lifecycle for each phase:
148
+ /maestro-analyze {firstPending.phase}
149
+ /maestro-plan {firstPending.phase}
150
+ /maestro-execute {firstPending.phase}
151
+ /quality-review {firstPending.phase}
152
+ # ... repeat for next phases in milestone
153
+
154
+ Or delegate (automated):
155
+ maestro delegate "run full lifecycle for milestone" --cd {wtPath} --mode write
156
+
157
+ Sync worktree with main (REQUIRED before merge):
158
+ /maestro-fork -m {milestoneNum} --sync
159
+
160
+ When all phases in milestone complete:
161
+ /maestro-merge -m {milestoneNum}
162
+ ```