maestro-flow 0.3.42 → 0.3.44

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 (172) hide show
  1. package/.claude/commands/learn-decompose.md +10 -15
  2. package/.claude/commands/learn-follow.md +11 -16
  3. package/.claude/commands/learn-investigate.md +18 -22
  4. package/.claude/commands/learn-retro.md +23 -26
  5. package/.claude/commands/learn-second-opinion.md +11 -16
  6. package/.claude/commands/maestro-analyze.md +8 -0
  7. package/.claude/commands/maestro-brainstorm.md +8 -0
  8. package/.claude/commands/maestro-execute.md +11 -3
  9. package/.claude/commands/maestro-learn.md +4 -4
  10. package/.claude/commands/maestro-milestone-complete.md +6 -6
  11. package/.claude/commands/maestro-plan.md +8 -0
  12. package/.claude/commands/maestro-ralph-execute.md +52 -80
  13. package/.claude/commands/maestro-ralph.md +2 -2
  14. package/.claude/commands/maestro-tools-execute.md +117 -0
  15. package/.claude/commands/maestro-tools-register.md +137 -0
  16. package/.claude/commands/maestro-ui-codify.md +67 -0
  17. package/.claude/commands/manage-harvest.md +1 -1
  18. package/.claude/commands/manage-learn.md +5 -7
  19. package/.claude/commands/manage-wiki.md +1 -1
  20. package/.claude/commands/quality-auto-test.md +1 -1
  21. package/.claude/commands/quality-debug.md +8 -0
  22. package/.claude/commands/quality-retrospective.md +4 -5
  23. package/.claude/commands/quality-review.md +8 -0
  24. package/.claude/commands/spec-add.md +25 -4
  25. package/.claude/commands/spec-load.md +26 -6
  26. package/.claude/commands/spec-setup.md +2 -2
  27. package/.claude/commands/wiki-connect.md +1 -1
  28. package/.claude/commands/wiki-digest.md +5 -6
  29. package/.claude/skills/codify-to-knowhow/SKILL.md +167 -0
  30. package/.claude/skills/codify-to-knowhow/phases/01-load-manifest.md +101 -0
  31. package/.claude/skills/codify-to-knowhow/phases/02-generate-knowhow.md +97 -0
  32. package/.claude/skills/codify-to-knowhow/phases/03-generate-specs.md +92 -0
  33. package/.claude/skills/codify-to-knowhow/phases/04-index-verify.md +119 -0
  34. package/.codex/skills/codify-to-knowhow/SKILL.md +427 -0
  35. package/.codex/skills/learn-decompose/SKILL.md +8 -8
  36. package/.codex/skills/learn-follow/SKILL.md +6 -6
  37. package/.codex/skills/learn-investigate/SKILL.md +4 -4
  38. package/.codex/skills/learn-retro/SKILL.md +7 -7
  39. package/.codex/skills/learn-second-opinion/SKILL.md +6 -6
  40. package/.codex/skills/maestro-analyze/SKILL.md +491 -491
  41. package/.codex/skills/maestro-collab/SKILL.md +1 -1
  42. package/.codex/skills/maestro-learn/SKILL.md +1 -1
  43. package/.codex/skills/maestro-milestone-complete/SKILL.md +122 -122
  44. package/.codex/skills/maestro-plan/SKILL.md +485 -485
  45. package/.codex/skills/maestro-tools-execute/SKILL.md +105 -0
  46. package/.codex/skills/maestro-tools-register/SKILL.md +144 -0
  47. package/.codex/skills/maestro-ui-codify/SKILL.md +398 -0
  48. package/.codex/skills/maestro-verify/SKILL.md +486 -486
  49. package/.codex/skills/manage-harvest/SKILL.md +3 -3
  50. package/.codex/skills/manage-issue-discover/SKILL.md +431 -431
  51. package/.codex/skills/manage-learn/SKILL.md +13 -13
  52. package/.codex/skills/manage-wiki/SKILL.md +1 -1
  53. package/.codex/skills/quality-auto-test/SKILL.md +553 -553
  54. package/.codex/skills/quality-refactor/SKILL.md +151 -151
  55. package/.codex/skills/quality-retrospective/SKILL.md +6 -6
  56. package/.codex/skills/spec-add/SKILL.md +17 -4
  57. package/.codex/skills/spec-load/SKILL.md +24 -28
  58. package/.codex/skills/team-quality-assurance/roles/executor/role.md +1 -1
  59. package/.codex/skills/team-review/roles/reviewer/role.md +1 -1
  60. package/.codex/skills/team-tech-debt/roles/scanner/role.md +1 -1
  61. package/.codex/skills/team-testing/roles/executor/role.md +1 -1
  62. package/.codex/skills/team-testing/roles/generator/role.md +1 -1
  63. package/.codex/skills/wiki-connect/SKILL.md +5 -5
  64. package/.codex/skills/wiki-digest/SKILL.md +8 -8
  65. package/dashboard/dist-server/dashboard/src/server/agents/claude-code-adapter.js +4 -2
  66. package/dashboard/dist-server/dashboard/src/server/agents/claude-code-adapter.js.map +1 -1
  67. package/dashboard/dist-server/dashboard/src/server/routes/specs.js +1 -1
  68. package/dashboard/dist-server/dashboard/src/server/routes/specs.js.map +1 -1
  69. package/dashboard/dist-server/dashboard/src/server/routes/wiki.js +2 -1
  70. package/dashboard/dist-server/dashboard/src/server/routes/wiki.js.map +1 -1
  71. package/dashboard/dist-server/dashboard/src/server/state/fs-watcher.js +2 -2
  72. package/dashboard/dist-server/dashboard/src/server/state/fs-watcher.js.map +1 -1
  73. package/dashboard/dist-server/dashboard/src/server/supervisor/self-learning-service.d.ts +1 -1
  74. package/dashboard/dist-server/dashboard/src/server/supervisor/self-learning-service.js +1 -1
  75. package/dashboard/dist-server/dashboard/src/server/supervisor/self-learning-service.js.map +1 -1
  76. package/dashboard/dist-server/dashboard/src/server/wiki/search.js +2 -2
  77. package/dashboard/dist-server/dashboard/src/server/wiki/search.js.map +1 -1
  78. package/dashboard/dist-server/dashboard/src/server/wiki/spec-entry-parser.d.ts +7 -3
  79. package/dashboard/dist-server/dashboard/src/server/wiki/spec-entry-parser.js +47 -15
  80. package/dashboard/dist-server/dashboard/src/server/wiki/spec-entry-parser.js.map +1 -1
  81. package/dashboard/dist-server/dashboard/src/server/wiki/stress.test.js +1 -1
  82. package/dashboard/dist-server/dashboard/src/server/wiki/stress.test.js.map +1 -1
  83. package/dashboard/dist-server/dashboard/src/server/wiki/virtual-wiki-adapters.d.ts +1 -2
  84. package/dashboard/dist-server/dashboard/src/server/wiki/virtual-wiki-adapters.js +3 -52
  85. package/dashboard/dist-server/dashboard/src/server/wiki/virtual-wiki-adapters.js.map +1 -1
  86. package/dashboard/dist-server/dashboard/src/server/wiki/wiki-indexer.js +67 -21
  87. package/dashboard/dist-server/dashboard/src/server/wiki/wiki-indexer.js.map +1 -1
  88. package/dashboard/dist-server/dashboard/src/server/wiki/wiki-types.d.ts +6 -1
  89. package/dashboard/dist-server/dashboard/src/server/wiki/writer-stress.test.js +1 -11
  90. package/dashboard/dist-server/dashboard/src/server/wiki/writer-stress.test.js.map +1 -1
  91. package/dashboard/dist-server/dashboard/src/server/wiki/writer.d.ts +7 -4
  92. package/dashboard/dist-server/dashboard/src/server/wiki/writer.js +27 -12
  93. package/dashboard/dist-server/dashboard/src/server/wiki/writer.js.map +1 -1
  94. package/dashboard/dist-server/src/tools/spec-entry-parser.d.ts +10 -2
  95. package/dashboard/dist-server/src/tools/spec-entry-parser.js +46 -12
  96. package/dashboard/dist-server/src/tools/spec-entry-parser.js.map +1 -1
  97. package/dashboard/dist-server/src/tools/spec-loader.d.ts +6 -2
  98. package/dashboard/dist-server/src/tools/spec-loader.js +119 -23
  99. package/dashboard/dist-server/src/tools/spec-loader.js.map +1 -1
  100. package/dist/src/commands/knowhow.d.ts.map +1 -1
  101. package/dist/src/commands/knowhow.js +21 -2
  102. package/dist/src/commands/knowhow.js.map +1 -1
  103. package/dist/src/commands/spec.d.ts +1 -1
  104. package/dist/src/commands/spec.d.ts.map +1 -1
  105. package/dist/src/commands/spec.js +78 -4
  106. package/dist/src/commands/spec.js.map +1 -1
  107. package/dist/src/commands/wiki.d.ts.map +1 -1
  108. package/dist/src/commands/wiki.js +51 -3
  109. package/dist/src/commands/wiki.js.map +1 -1
  110. package/dist/src/hooks/keyword-spec-injector.js +1 -1
  111. package/dist/src/hooks/keyword-spec-injector.js.map +1 -1
  112. package/dist/src/hooks/plugins/spec-injection-plugin.js +11 -11
  113. package/dist/src/hooks/plugins/spec-injection-plugin.js.map +1 -1
  114. package/dist/src/hooks/spec-injector.d.ts +1 -0
  115. package/dist/src/hooks/spec-injector.d.ts.map +1 -1
  116. package/dist/src/hooks/spec-injector.js +55 -22
  117. package/dist/src/hooks/spec-injector.js.map +1 -1
  118. package/dist/src/hooks/wiki-role-loader.d.ts +18 -0
  119. package/dist/src/hooks/wiki-role-loader.d.ts.map +1 -0
  120. package/dist/src/hooks/wiki-role-loader.js +43 -0
  121. package/dist/src/hooks/wiki-role-loader.js.map +1 -0
  122. package/dist/src/tools/spec-entry-parser.d.ts +10 -2
  123. package/dist/src/tools/spec-entry-parser.d.ts.map +1 -1
  124. package/dist/src/tools/spec-entry-parser.js +46 -12
  125. package/dist/src/tools/spec-entry-parser.js.map +1 -1
  126. package/dist/src/tools/spec-init.d.ts.map +1 -1
  127. package/dist/src/tools/spec-init.js +19 -0
  128. package/dist/src/tools/spec-init.js.map +1 -1
  129. package/dist/src/tools/spec-loader.d.ts +6 -2
  130. package/dist/src/tools/spec-loader.d.ts.map +1 -1
  131. package/dist/src/tools/spec-loader.js +119 -23
  132. package/dist/src/tools/spec-loader.js.map +1 -1
  133. package/dist/src/tools/spec-writer.d.ts +6 -1
  134. package/dist/src/tools/spec-writer.d.ts.map +1 -1
  135. package/dist/src/tools/spec-writer.js +29 -2
  136. package/dist/src/tools/spec-writer.js.map +1 -1
  137. package/dist/src/tools/store-knowhow.d.ts.map +1 -1
  138. package/dist/src/tools/store-knowhow.js +56 -27
  139. package/dist/src/tools/store-knowhow.js.map +1 -1
  140. package/package.json +1 -1
  141. package/workflows/analyze.md +2 -2
  142. package/workflows/auto-test.md +2 -2
  143. package/workflows/brainstorm.md +1 -1
  144. package/workflows/codebase-rebuild.md +1 -1
  145. package/workflows/codebase-refresh.md +1 -1
  146. package/workflows/debug.md +1 -1
  147. package/workflows/execute.md +3 -3
  148. package/workflows/harvest.md +13 -13
  149. package/workflows/integration-test.md +2 -2
  150. package/workflows/issue-discover.md +1 -1
  151. package/workflows/knowhow.md +72 -11
  152. package/workflows/learn.md +70 -58
  153. package/workflows/map.md +1 -1
  154. package/workflows/milestone-complete.md +2 -2
  155. package/workflows/plan.md +1 -1
  156. package/workflows/quick.md +1 -1
  157. package/workflows/refactor.md +1 -1
  158. package/workflows/retrospective.md +51 -57
  159. package/workflows/review.md +1 -1
  160. package/workflows/roadmap-common.md +1 -1
  161. package/workflows/specs-add.md +11 -2
  162. package/workflows/specs-load.md +17 -15
  163. package/workflows/test-gen.md +1 -1
  164. package/workflows/tools-spec.md +98 -0
  165. package/workflows/ui-codify-extract.md +373 -0
  166. package/workflows/ui-codify-knowhow.md +258 -0
  167. package/workflows/ui-codify-package.md +161 -0
  168. package/workflows/ui-codify.md +225 -0
  169. package/workflows/verify.md +1 -1
  170. package/workflows/wiki-connect.md +7 -7
  171. package/workflows/wiki-digest.md +13 -13
  172. package/workflows/wiki-manage.md +1 -1
@@ -1,431 +1,431 @@
1
- ---
2
- name: manage-issue-discover
3
- description: Discover issues via multi-perspective analysis
4
- argument-hint: "[-y|--yes] [-c|--concurrency N] [--continue] \"[by-prompt 'what to look for']\""
5
- allowed-tools: spawn_agents_on_csv, Read, Write, Edit, Bash, Glob, Grep, AskUserQuestion
6
- ---
7
-
8
- <purpose>
9
- Wave-based multi-perspective issue discovery using `spawn_agents_on_csv`. In default mode, 8 independent perspective agents scan the codebase in parallel (Wave 1), then a single dedup + issue creation agent aggregates all findings (Wave 2). In by-prompt mode, user-defined exploration dimensions replace the 8 fixed perspectives.
10
-
11
- **Core workflow**: Parse Mode -> Define Perspectives -> Parallel Scan -> Dedup + Issue Creation
12
-
13
- **Dual mode**:
14
- - **Default (no args)**: 8-perspective scan (security, performance, reliability, maintainability, scalability, ux, accessibility, compliance)
15
- - **`by-prompt "..."`**: User-driven exploration decomposed into 3-5 search dimensions
16
-
17
- ```
18
- +-------------------------------------------------------------------------+
19
- | ISSUE DISCOVERY CSV WAVE WORKFLOW |
20
- +-------------------------------------------------------------------------+
21
- | |
22
- | Phase 1: Mode Resolution -> CSV |
23
- | +-- Parse mode from arguments (multi-perspective or by-prompt) |
24
- | +-- Validate environment (.workflow/ exists) |
25
- | +-- Initialize discovery session directory |
26
- | +-- [multi] Generate 8 perspective rows + 1 dedup row |
27
- | +-- [by-prompt] Decompose prompt into 3-5 dimensions + 1 dedup row |
28
- | +-- Determine scope globs per perspective/dimension |
29
- | +-- Generate tasks.csv |
30
- | +-- User validates perspective breakdown (skip if -y) |
31
- | |
32
- | Phase 2: Wave Execution Engine |
33
- | +-- Wave 1: Perspective/Dimension Scan (parallel) |
34
- | | +-- Each agent scans codebase from its perspective |
35
- | | +-- Agent identifies concrete issues with file:line evidence |
36
- | | +-- Agent rates findings by severity (critical/high/medium/low) |
37
- | | +-- Discoveries shared via board (cross-perspective patterns) |
38
- | | +-- Results: issues_found + severity_distribution per agent |
39
- | +-- Wave 2: Dedup + Issue Creation (single agent) |
40
- | | +-- Aggregates all perspective findings |
41
- | | +-- Deduplicates by file path + description similarity |
42
- | | +-- Keeps higher-severity duplicate |
43
- | | +-- Creates issue records (ISS-YYYYMMDD-NNN) |
44
- | | +-- Appends to issues.jsonl |
45
- | +-- discoveries.ndjson shared across all waves (append-only) |
46
- | |
47
- | Phase 3: Results Aggregation |
48
- | +-- Export results.csv |
49
- | +-- Generate context.md with all findings |
50
- | +-- Update discovery-state.json |
51
- | +-- Display summary with breakdown by perspective + severity |
52
- | +-- Suggest next steps |
53
- | |
54
- +-------------------------------------------------------------------------+
55
- ```
56
- </purpose>
57
-
58
- <context>
59
- ```bash
60
- $manage-issue-discover
61
- $manage-issue-discover -c 8 ""
62
- $manage-issue-discover -y "by-prompt 'error handling gaps in auth module'"
63
- $manage-issue-discover --continue "20260318-discover-multi"
64
- ```
65
-
66
- **Flags**:
67
- - `-y, --yes`: Skip all confirmations (auto mode)
68
- - `-c, --concurrency N`: Max concurrent agents within each wave (default: 8)
69
- - `--continue`: Resume existing session
70
-
71
- When `--yes` or `-y`: Auto-confirm perspective selection, skip interactive validation, use defaults for scope detection.
72
-
73
- **Output Directory**: `.workflow/.csv-wave/{session-id}/`
74
- **Core Output**: `tasks.csv` (master state) + `results.csv` (final) + `discoveries.ndjson` (shared exploration) + `context.md` (human-readable report) + issues appended to `.workflow/issues/issues.jsonl`
75
- </context>
76
-
77
- <csv_schema>
78
- ### tasks.csv (Master State)
79
-
80
- ```csv
81
- id,title,description,perspective,scope_glob,deps,context_from,wave,status,findings,issues_found,severity_distribution,error
82
- "1","Security Scan","Scan codebase for security vulnerabilities: authentication bypass, injection flaws, XSS, CSRF, sensitive data exposure, insecure crypto, secrets in code. Rate each finding critical/high/medium/low with file:line references.","security","src/**/*.{ts,tsx,js,jsx}","","","1","","","","",""
83
- "2","Performance Scan","Scan codebase for performance issues: N+1 queries, unbounded loops, missing caching, memory leaks, large payloads, blocking operations, unoptimized algorithms.","performance","src/**/*.{ts,tsx,js,jsx}","","","1","","","","",""
84
- "3","Reliability Scan","Scan codebase for reliability issues: unhandled errors, missing retry logic, race conditions, data integrity gaps, missing graceful degradation, silent failures.","reliability","src/**/*.{ts,tsx,js,jsx}","","","1","","","","",""
85
- "4","Maintainability Scan","Scan codebase for maintainability issues: code duplication, tight coupling, missing abstractions, unclear naming, dead code, overly complex functions.","maintainability","src/**/*.{ts,tsx,js,jsx}","","","1","","","","",""
86
- "5","Scalability Scan","Scan codebase for scalability issues: hardcoded limits, single-threaded bottlenecks, stateful assumptions, schema rigidity, missing pagination.","scalability","src/**/*.{ts,tsx,js,jsx}","","","1","","","","",""
87
- "6","UX Scan","Scan codebase for UX issues: confusing flows, missing user feedback, inconsistent behavior, missing loading states, poor error messages.","ux","src/**/*.{ts,tsx,js,jsx}","","","1","","","","",""
88
- "7","Accessibility Scan","Scan codebase for accessibility issues: missing ARIA labels, keyboard navigation gaps, color contrast problems, missing alt text, focus management issues.","accessibility","src/**/*.{ts,tsx,js,jsx}","","","1","","","","",""
89
- "8","Compliance Scan","Scan codebase for compliance issues: logging gaps, missing audit trails, data retention violations, privacy control gaps, regulatory requirement gaps.","compliance","src/**/*.{ts,tsx,js,jsx}","","","1","","","","",""
90
- "9","Dedup + Issue Creation","Aggregate all perspective findings. Deduplicate by file path + description similarity (keep higher severity). Generate ISS-YYYYMMDD-NNN issue records. Append to .workflow/issues/issues.jsonl.","dedup","","1;2;3;4;5;6;7;8","1;2;3;4;5;6;7;8","2","","","","",""
91
- ```
92
-
93
- **Columns**:
94
-
95
- | Column | Phase | Description |
96
- |--------|-------|-------------|
97
- | `id` | Input | Unique task identifier (string) |
98
- | `title` | Input | Short task title |
99
- | `description` | Input | Detailed scan instructions for this perspective |
100
- | `perspective` | Input | Scan perspective: security/performance/reliability/maintainability/scalability/ux/accessibility/compliance/dedup |
101
- | `scope_glob` | Input | File scope glob for analysis (e.g., `src/**/*.{ts,tsx}`) |
102
- | `deps` | Input | Semicolon-separated dependency task IDs |
103
- | `context_from` | Input | Semicolon-separated task IDs whose findings this task needs |
104
- | `wave` | Computed | Wave number (1 = perspective scans, 2 = dedup + issue creation) |
105
- | `status` | Output | `pending` -> `completed` / `failed` / `skipped` |
106
- | `findings` | Output | Key scan findings summary (max 500 chars) |
107
- | `issues_found` | Output | JSON array of discovered issues: `[{"title":"...","severity":"critical","description":"...","location":"file:line","fix_direction":"...","affected_components":["..."]}]` |
108
- | `severity_distribution` | Output | JSON: `{"critical":N,"high":N,"medium":N,"low":N}` |
109
- | `error` | Output | Error message if failed |
110
-
111
- ### Per-Wave CSV (Temporary)
112
-
113
- Each wave generates `wave-{N}.csv` with extra `prev_context` column.
114
-
115
- ### Output Artifacts
116
-
117
- | File | Purpose | Lifecycle |
118
- |------|---------|-----------|
119
- | `tasks.csv` | Master state -- all tasks with status/findings | Updated after each wave |
120
- | `wave-{N}.csv` | Per-wave input (temporary) | Created before wave, deleted after |
121
- | `results.csv` | Final export of all task results | Created in Phase 3 |
122
- | `discoveries.ndjson` | Shared exploration board | Append-only, carries across waves |
123
- | `context.md` | Human-readable discovery report | Created in Phase 3 |
124
- | `discovery-state.json` | Session metadata and progress | Updated throughout |
125
- | `.workflow/issues/issues.jsonl` | Issues appended here | Append-only |
126
-
127
- ### Session Structure
128
-
129
- ```
130
- .workflow/.csv-wave/{YYYYMMDD}-discover-{mode}/
131
- +-- tasks.csv
132
- +-- results.csv
133
- +-- discoveries.ndjson
134
- +-- context.md
135
- +-- discovery-state.json
136
- +-- wave-{N}.csv (temporary)
137
- ```
138
-
139
- Also writes to:
140
- ```
141
- .workflow/issues/discoveries/{SESSION_ID}/
142
- +-- discovery-state.json (copy)
143
- +-- discovery-issues.jsonl
144
- +-- {perspective}-findings.json (per perspective raw output)
145
- ```
146
- </csv_schema>
147
-
148
- <invariants>
149
- 1. **Start Immediately**: First action is session initialization, then Phase 1
150
- 2. **Wave Order is Sacred**: Never execute wave 2 before wave 1 completes and results are merged
151
- 3. **CSV is Source of Truth**: Master tasks.csv holds all state
152
- 4. **Context Propagation**: prev_context built from master CSV, not from memory
153
- 5. **Discovery Board is Append-Only**: Never clear, modify, or recreate discoveries.ndjson
154
- 6. **Skip on Failure**: If all perspective agents failed, skip dedup
155
- 7. **Evidence Required**: Every finding must have file:line reference -- no speculative issues
156
- 8. **Dedup Before Create**: Never append to issues.jsonl without deduplication
157
- 9. **Cleanup Temp Files**: Remove wave-{N}.csv after results are merged
158
- 10. **DO NOT STOP**: Continuous execution until all waves complete
159
- </invariants>
160
-
161
- <execution>
162
-
163
- ### Session Initialization
164
-
165
- ```javascript
166
- // Parse from $ARGUMENTS:
167
- // AUTO_YES <- --yes | -y
168
- // continueMode <- --continue
169
- // maxConcurrency <- --concurrency N | -c N (default: 8)
170
- // mode <- "by-prompt" if clean args start with "by-prompt", else "multi"
171
- // userPrompt <- text after "by-prompt" (stripped of quotes)
172
-
173
- // Session IDs (UTC+8):
174
- // sessionId = DBP-{YYYYMMDD}-{HHmmss}
175
- // csvSessionId = {YYYYMMDD}-discover-{mode}
176
- // sessionFolder = .workflow/.csv-wave/{csvSessionId}
177
- // discoveryDir = .workflow/issues/discoveries/{sessionId}
178
-
179
- // Create: sessionFolder, discoveryDir, .workflow/issues/
180
- // Touch: .workflow/issues/issues.jsonl
181
- ```
182
-
183
- Initialize `discovery-state.json`:
184
- ```json
185
- {
186
- "id": "{sessionId}",
187
- "mode": "{mode}",
188
- "status": "in_progress",
189
- "started_at": "{ISO}",
190
- "completed_at": null,
191
- "perspectives_completed": [],
192
- "issues_found": 0,
193
- "issues_deduplicated": 0
194
- }
195
- ```
196
-
197
- ### Phase 1: Mode Resolution -> CSV
198
-
199
- **Objective**: Determine mode, define perspectives/dimensions, determine scope, generate tasks.csv.
200
-
201
- #### Multi-Perspective Mode (default)
202
-
203
- **8 fixed perspectives**:
204
-
205
- | # | Perspective | Focus | Guiding Question |
206
- |---|-------------|-------|------------------|
207
- | 1 | security | Auth, authz, input validation, secrets, injection | What security vulnerabilities or unsafe patterns exist? |
208
- | 2 | performance | N+1 queries, loops, caching, memory, payloads | What performance bottlenecks or inefficiencies exist? |
209
- | 3 | reliability | Error handling, retry, race conditions, data integrity | What failure modes are unhandled or could cause data loss? |
210
- | 4 | maintainability | Duplication, coupling, abstractions, naming, dead code | What makes this codebase harder to understand or change? |
211
- | 5 | scalability | Hardcoded limits, single-thread, stateful, schema rigidity | What will break or degrade as load/data/users increase? |
212
- | 6 | ux | Confusing flows, feedback, consistency, loading states | What creates friction or confusion for end users? |
213
- | 7 | accessibility | Screen reader, keyboard nav, contrast, ARIA, focus | What barriers exist for users with disabilities? |
214
- | 8 | compliance | Logging, audit trails, retention, privacy, regulatory | What regulatory or policy requirements are not met? |
215
-
216
- **CSV generation**: 8 perspective rows (wave 1) + 1 dedup row (wave 2).
217
-
218
- **Scope detection**: Default `src/**/*.{ts,tsx,js,jsx}`. Refine by reading `.workflow/project.md` for tech stack hints.
219
-
220
- #### By-Prompt Mode
221
-
222
- 1. Parse `userPrompt` -- if empty, ask user interactively
223
- 2. Decompose prompt into 3-5 exploration dimensions (use analysis to break down the user's intent into searchable dimensions)
224
- 3. For each dimension: define name, description, search patterns, file patterns, finding criteria
225
- 4. Store dimensions in `{discoveryDir}/exploration-plan.json`
226
- 5. Generate N dimension rows (wave 1) + 1 dedup row (wave 2)
227
-
228
- **Specs loading**: `specs_content = maestro spec load --category coding` -- pass to agents for severity calibration.
229
-
230
- **User validation**: Display perspective/dimension breakdown (skip if AUTO_YES).
231
-
232
- ### Phase 2: Wave Execution Engine
233
-
234
- **Objective**: Execute perspective scans wave-by-wave via spawn_agents_on_csv.
235
-
236
- #### Wave 1: Perspective/Dimension Scans (Parallel)
237
-
238
- 1. Read master `tasks.csv`
239
- 2. Filter rows where `wave == 1` AND `status == pending`
240
- 3. No prev_context needed (wave 1 has no predecessors)
241
- 4. Write `wave-1.csv`
242
- 5. Execute:
243
-
244
- ```javascript
245
- spawn_agents_on_csv({
246
- csv_path: `${sessionFolder}/wave-1.csv`,
247
- id_column: "id",
248
- instruction: buildDiscoverInstruction(sessionFolder, discoveryDir, mode),
249
- max_concurrency: maxConcurrency,
250
- max_runtime_seconds: 3600,
251
- output_csv_path: `${sessionFolder}/wave-1-results.csv`,
252
- output_schema: { // required: id, status, findings
253
- id: "string", status: "completed|failed",
254
- findings: "string", issues_found: "string",
255
- severity_distribution: "string", error: "string"
256
- }
257
- })
258
- ```
259
-
260
- 6. Merge `wave-1-results.csv` into master `tasks.csv`
261
- 7. Save per-perspective findings to `{discoveryDir}/{perspective}-findings.json`
262
- 8. Update `discovery-state.json` with completed perspectives
263
- 9. Delete `wave-1.csv`
264
-
265
- **Perspective scan agent protocol**:
266
- - Scan all source files matching scope_glob
267
- - Identify concrete issues with file:line references
268
- - Rate each finding: critical / high / medium / low
269
- - Provide brief fix direction for each finding
270
- - Report affected_components[]
271
- - Share cross-cutting discoveries via discovery board
272
- - Output issues_found as JSON array + severity_distribution as JSON object
273
-
274
- #### Wave 2: Dedup + Issue Creation (Single Agent)
275
-
276
- 1. Read master `tasks.csv`
277
- 2. Filter rows where `wave == 2` AND `status == pending`
278
- 3. Check deps -- if all wave 1 agents failed, skip dedup
279
- 4. Build `prev_context` from wave 1 findings:
280
- ```
281
- [Task 1: Security Scan] Found 3 issues: SQL injection in query builder (critical), missing CSRF token (high)...
282
- [Task 2: Performance Scan] Found 5 issues: N+1 query in user listing (high), missing pagination (medium)...
283
- ...
284
- ```
285
- 5. Write `wave-2.csv` with `prev_context` column
286
- 6. Execute `spawn_agents_on_csv` for dedup agent
287
- 7. Merge results into master `tasks.csv`
288
- 8. Delete `wave-2.csv`
289
-
290
- **Dedup agent protocol**:
291
- - Merge all perspective findings from prev_context into single list
292
- - Deduplicate: group by file path, compare descriptions (>80% overlap or same file:line → keep higher severity)
293
- - For each unique finding: generate `ISS-YYYYMMDD-NNN` ID (collision-safe), build full issue record
294
- - Severity-to-priority: critical→1, high→2, medium→3, low→4; source = "discovery", tags = ["{perspective}"]
295
- - Append to `.workflow/issues/issues.jsonl` and `{discoveryDir}/discovery-issues.jsonl`
296
- - Report: pre-dedup count, post-dedup count, severity_distribution
297
-
298
- ### Phase 3: Results Aggregation
299
-
300
- **Objective**: Generate final results and human-readable report.
301
-
302
- 1. Read final master `tasks.csv`
303
- 2. Export as `results.csv`
304
- 3. **Update discovery-state.json**:
305
-
306
- ```json
307
- {
308
- "id": "{sessionId}",
309
- "mode": "{mode}",
310
- "status": "completed",
311
- "started_at": "{ISO}",
312
- "completed_at": "{ISO}",
313
- "perspectives_completed": ["security", "performance", "..."],
314
- "issues_found": 42,
315
- "issues_deduplicated": 31
316
- }
317
- ```
318
-
319
- 4. Copy `discovery-state.json` to `{discoveryDir}/discovery-state.json`
320
-
321
- 5. **Generate context.md**:
322
-
323
- ```markdown
324
- # Issue Discovery Report
325
-
326
- ## Summary
327
- - Session: {sessionId}
328
- - Mode: {mode}
329
- - Perspectives: {perspective_count}
330
- - Raw findings: {issues_found}
331
- - Unique issues: {issues_deduplicated}
332
-
333
- ## Breakdown by Perspective
334
- | Perspective | Findings | Critical | High | Medium | Low |
335
- |-------------|----------|----------|------|--------|-----|
336
- | Security | {N} | {N} | {N} | {N} | {N} |
337
- | Performance | {N} | {N} | {N} | {N} | {N} |
338
- | ... | | | | | |
339
-
340
- ## Severity Distribution
341
- | Severity | Count |
342
- |----------|-------|
343
- | Critical | {N} |
344
- | High | {N} |
345
- | Medium | {N} |
346
- | Low | {N} |
347
-
348
- ## Perspective Details
349
- ### {perspective_name}
350
- {findings_summary}
351
-
352
- **Top Issues:**
353
- {top_issues_list}
354
-
355
- ## Issues Created
356
- {list of ISS-YYYYMMDD-NNN IDs with titles}
357
- ```
358
-
359
- 6. **Display summary**: Session ID, mode, perspective count, raw vs unique finding counts, per-perspective breakdown, severity breakdown, and output file paths.
360
-
361
- 7. **Next step routing**:
362
-
363
- | Result | Suggestion |
364
- |--------|------------|
365
- | Critical issues found | `$manage-issue "list --severity critical"` |
366
- | Issues created | `$manage-issue "list"` |
367
- | Specific area needs deeper look | `$manage-issue-discover "by-prompt '...'"` |
368
- | Full scan complete | `$manage-issue "list --source discovery"` |
369
-
370
- ### Shared Discovery Board Protocol
371
-
372
- #### Standard Discovery Types
373
-
374
- | Type | Dedup Key | Data Schema | Description |
375
- |------|-----------|-------------|-------------|
376
- | `code_pattern` | `data.name` | `{name, file, description}` | Reusable code pattern found |
377
- | `integration_point` | `data.file` | `{file, description, exports[]}` | Module connection point |
378
- | `convention` | singleton | `{naming, imports, formatting}` | Project code conventions |
379
- | `blocker` | `data.issue` | `{issue, severity, impact}` | Blocking issue found |
380
- | `tech_stack` | singleton | `{framework, language, tools[]}` | Technology stack info |
381
-
382
- #### Domain Discovery Types
383
-
384
- | Type | Dedup Key | Data Schema | Description |
385
- |------|-----------|-------------|-------------|
386
- | `vulnerability` | `data.location` | `{location, type, severity, cwe}` | Security vulnerability |
387
- | `code_smell` | `data.location` | `{location, type, severity, description}` | Code quality issue |
388
- | `performance_hotspot` | `data.location` | `{location, type, impact}` | Performance issue |
389
- | `reliability_risk` | `data.location` | `{location, failure_mode, impact}` | Reliability concern |
390
- | `scalability_limit` | `data.location` | `{location, constraint, threshold}` | Scalability bottleneck |
391
-
392
- #### Protocol
393
-
394
- 1. **Read** `{session_folder}/discoveries.ndjson` before own scan
395
- 2. **Skip covered**: If discovery of same type + dedup key exists, skip
396
- 3. **Write immediately**: Append findings as found
397
- 4. **Append-only**: Never modify or delete
398
- 5. **Deduplicate**: Check before writing
399
-
400
- ```bash
401
- echo '{"ts":"<ISO>","worker":"{id}","type":"vulnerability","data":{"location":"src/auth/login.ts:42","type":"sql_injection","severity":"critical","cwe":"CWE-89"}}' >> {session_folder}/discoveries.ndjson
402
- ```
403
- </execution>
404
-
405
- <error_codes>
406
-
407
- | Error | Resolution |
408
- |-------|------------|
409
- | `.workflow/` does not exist | Abort: "No project initialized. Run maestro-init first." |
410
- | `by-prompt` with empty prompt | Interactive prompt with suggested options |
411
- | Perspective agent timeout | Mark as failed, continue remaining perspectives |
412
- | All perspective agents failed | Skip dedup, report no findings |
413
- | Dedup agent failed | Use wave 1 results directly, create issues from raw findings |
414
- | issues.jsonl write failure | Retry once, then report error with findings in context.md |
415
- | CSV parse error | Validate format, show line number |
416
- | discoveries.ndjson corrupt | Ignore malformed lines |
417
- | Continue mode: no session found | List available sessions |
418
- | ID collision in issues.jsonl | Re-read file, recalculate next sequence number |
419
- </error_codes>
420
-
421
- <success_criteria>
422
- - [ ] Session initialized with discovery-state.json
423
- - [ ] tasks.csv generated with correct perspective/wave assignments
424
- - [ ] All perspective agents executed in parallel (wave 1)
425
- - [ ] Dedup agent aggregates and deduplicates findings (wave 2)
426
- - [ ] Issues appended to .workflow/issues/issues.jsonl with unique IDs
427
- - [ ] results.csv and context.md generated with full breakdown
428
- - [ ] Temporary wave-{N}.csv files cleaned up after merge
429
- - [ ] discoveries.ndjson maintained as append-only
430
- - [ ] Per-perspective findings saved to discovery directory
431
- </success_criteria>
1
+ ---
2
+ name: manage-issue-discover
3
+ description: Discover issues via multi-perspective analysis
4
+ argument-hint: "[-y|--yes] [-c|--concurrency N] [--continue] \"[by-prompt 'what to look for']\""
5
+ allowed-tools: spawn_agents_on_csv, Read, Write, Edit, Bash, Glob, Grep, AskUserQuestion
6
+ ---
7
+
8
+ <purpose>
9
+ Wave-based multi-perspective issue discovery using `spawn_agents_on_csv`. In default mode, 8 independent perspective agents scan the codebase in parallel (Wave 1), then a single dedup + issue creation agent aggregates all findings (Wave 2). In by-prompt mode, user-defined exploration dimensions replace the 8 fixed perspectives.
10
+
11
+ **Core workflow**: Parse Mode -> Define Perspectives -> Parallel Scan -> Dedup + Issue Creation
12
+
13
+ **Dual mode**:
14
+ - **Default (no args)**: 8-perspective scan (security, performance, reliability, maintainability, scalability, ux, accessibility, compliance)
15
+ - **`by-prompt "..."`**: User-driven exploration decomposed into 3-5 search dimensions
16
+
17
+ ```
18
+ +-------------------------------------------------------------------------+
19
+ | ISSUE DISCOVERY CSV WAVE WORKFLOW |
20
+ +-------------------------------------------------------------------------+
21
+ | |
22
+ | Phase 1: Mode Resolution -> CSV |
23
+ | +-- Parse mode from arguments (multi-perspective or by-prompt) |
24
+ | +-- Validate environment (.workflow/ exists) |
25
+ | +-- Initialize discovery session directory |
26
+ | +-- [multi] Generate 8 perspective rows + 1 dedup row |
27
+ | +-- [by-prompt] Decompose prompt into 3-5 dimensions + 1 dedup row |
28
+ | +-- Determine scope globs per perspective/dimension |
29
+ | +-- Generate tasks.csv |
30
+ | +-- User validates perspective breakdown (skip if -y) |
31
+ | |
32
+ | Phase 2: Wave Execution Engine |
33
+ | +-- Wave 1: Perspective/Dimension Scan (parallel) |
34
+ | | +-- Each agent scans codebase from its perspective |
35
+ | | +-- Agent identifies concrete issues with file:line evidence |
36
+ | | +-- Agent rates findings by severity (critical/high/medium/low) |
37
+ | | +-- Discoveries shared via board (cross-perspective patterns) |
38
+ | | +-- Results: issues_found + severity_distribution per agent |
39
+ | +-- Wave 2: Dedup + Issue Creation (single agent) |
40
+ | | +-- Aggregates all perspective findings |
41
+ | | +-- Deduplicates by file path + description similarity |
42
+ | | +-- Keeps higher-severity duplicate |
43
+ | | +-- Creates issue records (ISS-YYYYMMDD-NNN) |
44
+ | | +-- Appends to issues.jsonl |
45
+ | +-- discoveries.ndjson shared across all waves (append-only) |
46
+ | |
47
+ | Phase 3: Results Aggregation |
48
+ | +-- Export results.csv |
49
+ | +-- Generate context.md with all findings |
50
+ | +-- Update discovery-state.json |
51
+ | +-- Display summary with breakdown by perspective + severity |
52
+ | +-- Suggest next steps |
53
+ | |
54
+ +-------------------------------------------------------------------------+
55
+ ```
56
+ </purpose>
57
+
58
+ <context>
59
+ ```bash
60
+ $manage-issue-discover
61
+ $manage-issue-discover -c 8 ""
62
+ $manage-issue-discover -y "by-prompt 'error handling gaps in auth module'"
63
+ $manage-issue-discover --continue "20260318-discover-multi"
64
+ ```
65
+
66
+ **Flags**:
67
+ - `-y, --yes`: Skip all confirmations (auto mode)
68
+ - `-c, --concurrency N`: Max concurrent agents within each wave (default: 8)
69
+ - `--continue`: Resume existing session
70
+
71
+ When `--yes` or `-y`: Auto-confirm perspective selection, skip interactive validation, use defaults for scope detection.
72
+
73
+ **Output Directory**: `.workflow/.csv-wave/{session-id}/`
74
+ **Core Output**: `tasks.csv` (master state) + `results.csv` (final) + `discoveries.ndjson` (shared exploration) + `context.md` (human-readable report) + issues appended to `.workflow/issues/issues.jsonl`
75
+ </context>
76
+
77
+ <csv_schema>
78
+ ### tasks.csv (Master State)
79
+
80
+ ```csv
81
+ id,title,description,perspective,scope_glob,deps,context_from,wave,status,findings,issues_found,severity_distribution,error
82
+ "1","Security Scan","Scan codebase for security vulnerabilities: authentication bypass, injection flaws, XSS, CSRF, sensitive data exposure, insecure crypto, secrets in code. Rate each finding critical/high/medium/low with file:line references.","security","src/**/*.{ts,tsx,js,jsx}","","","1","","","","",""
83
+ "2","Performance Scan","Scan codebase for performance issues: N+1 queries, unbounded loops, missing caching, memory leaks, large payloads, blocking operations, unoptimized algorithms.","performance","src/**/*.{ts,tsx,js,jsx}","","","1","","","","",""
84
+ "3","Reliability Scan","Scan codebase for reliability issues: unhandled errors, missing retry logic, race conditions, data integrity gaps, missing graceful degradation, silent failures.","reliability","src/**/*.{ts,tsx,js,jsx}","","","1","","","","",""
85
+ "4","Maintainability Scan","Scan codebase for maintainability issues: code duplication, tight coupling, missing abstractions, unclear naming, dead code, overly complex functions.","maintainability","src/**/*.{ts,tsx,js,jsx}","","","1","","","","",""
86
+ "5","Scalability Scan","Scan codebase for scalability issues: hardcoded limits, single-threaded bottlenecks, stateful assumptions, schema rigidity, missing pagination.","scalability","src/**/*.{ts,tsx,js,jsx}","","","1","","","","",""
87
+ "6","UX Scan","Scan codebase for UX issues: confusing flows, missing user feedback, inconsistent behavior, missing loading states, poor error messages.","ux","src/**/*.{ts,tsx,js,jsx}","","","1","","","","",""
88
+ "7","Accessibility Scan","Scan codebase for accessibility issues: missing ARIA labels, keyboard navigation gaps, color contrast problems, missing alt text, focus management issues.","accessibility","src/**/*.{ts,tsx,js,jsx}","","","1","","","","",""
89
+ "8","Compliance Scan","Scan codebase for compliance issues: logging gaps, missing audit trails, data retention violations, privacy control gaps, regulatory requirement gaps.","compliance","src/**/*.{ts,tsx,js,jsx}","","","1","","","","",""
90
+ "9","Dedup + Issue Creation","Aggregate all perspective findings. Deduplicate by file path + description similarity (keep higher severity). Generate ISS-YYYYMMDD-NNN issue records. Append to .workflow/issues/issues.jsonl.","dedup","","1;2;3;4;5;6;7;8","1;2;3;4;5;6;7;8","2","","","","",""
91
+ ```
92
+
93
+ **Columns**:
94
+
95
+ | Column | Phase | Description |
96
+ |--------|-------|-------------|
97
+ | `id` | Input | Unique task identifier (string) |
98
+ | `title` | Input | Short task title |
99
+ | `description` | Input | Detailed scan instructions for this perspective |
100
+ | `perspective` | Input | Scan perspective: security/performance/reliability/maintainability/scalability/ux/accessibility/compliance/dedup |
101
+ | `scope_glob` | Input | File scope glob for analysis (e.g., `src/**/*.{ts,tsx}`) |
102
+ | `deps` | Input | Semicolon-separated dependency task IDs |
103
+ | `context_from` | Input | Semicolon-separated task IDs whose findings this task needs |
104
+ | `wave` | Computed | Wave number (1 = perspective scans, 2 = dedup + issue creation) |
105
+ | `status` | Output | `pending` -> `completed` / `failed` / `skipped` |
106
+ | `findings` | Output | Key scan findings summary (max 500 chars) |
107
+ | `issues_found` | Output | JSON array of discovered issues: `[{"title":"...","severity":"critical","description":"...","location":"file:line","fix_direction":"...","affected_components":["..."]}]` |
108
+ | `severity_distribution` | Output | JSON: `{"critical":N,"high":N,"medium":N,"low":N}` |
109
+ | `error` | Output | Error message if failed |
110
+
111
+ ### Per-Wave CSV (Temporary)
112
+
113
+ Each wave generates `wave-{N}.csv` with extra `prev_context` column.
114
+
115
+ ### Output Artifacts
116
+
117
+ | File | Purpose | Lifecycle |
118
+ |------|---------|-----------|
119
+ | `tasks.csv` | Master state -- all tasks with status/findings | Updated after each wave |
120
+ | `wave-{N}.csv` | Per-wave input (temporary) | Created before wave, deleted after |
121
+ | `results.csv` | Final export of all task results | Created in Phase 3 |
122
+ | `discoveries.ndjson` | Shared exploration board | Append-only, carries across waves |
123
+ | `context.md` | Human-readable discovery report | Created in Phase 3 |
124
+ | `discovery-state.json` | Session metadata and progress | Updated throughout |
125
+ | `.workflow/issues/issues.jsonl` | Issues appended here | Append-only |
126
+
127
+ ### Session Structure
128
+
129
+ ```
130
+ .workflow/.csv-wave/{YYYYMMDD}-discover-{mode}/
131
+ +-- tasks.csv
132
+ +-- results.csv
133
+ +-- discoveries.ndjson
134
+ +-- context.md
135
+ +-- discovery-state.json
136
+ +-- wave-{N}.csv (temporary)
137
+ ```
138
+
139
+ Also writes to:
140
+ ```
141
+ .workflow/issues/discoveries/{SESSION_ID}/
142
+ +-- discovery-state.json (copy)
143
+ +-- discovery-issues.jsonl
144
+ +-- {perspective}-findings.json (per perspective raw output)
145
+ ```
146
+ </csv_schema>
147
+
148
+ <invariants>
149
+ 1. **Start Immediately**: First action is session initialization, then Phase 1
150
+ 2. **Wave Order is Sacred**: Never execute wave 2 before wave 1 completes and results are merged
151
+ 3. **CSV is Source of Truth**: Master tasks.csv holds all state
152
+ 4. **Context Propagation**: prev_context built from master CSV, not from memory
153
+ 5. **Discovery Board is Append-Only**: Never clear, modify, or recreate discoveries.ndjson
154
+ 6. **Skip on Failure**: If all perspective agents failed, skip dedup
155
+ 7. **Evidence Required**: Every finding must have file:line reference -- no speculative issues
156
+ 8. **Dedup Before Create**: Never append to issues.jsonl without deduplication
157
+ 9. **Cleanup Temp Files**: Remove wave-{N}.csv after results are merged
158
+ 10. **DO NOT STOP**: Continuous execution until all waves complete
159
+ </invariants>
160
+
161
+ <execution>
162
+
163
+ ### Session Initialization
164
+
165
+ ```javascript
166
+ // Parse from $ARGUMENTS:
167
+ // AUTO_YES <- --yes | -y
168
+ // continueMode <- --continue
169
+ // maxConcurrency <- --concurrency N | -c N (default: 8)
170
+ // mode <- "by-prompt" if clean args start with "by-prompt", else "multi"
171
+ // userPrompt <- text after "by-prompt" (stripped of quotes)
172
+
173
+ // Session IDs (UTC+8):
174
+ // sessionId = DBP-{YYYYMMDD}-{HHmmss}
175
+ // csvSessionId = {YYYYMMDD}-discover-{mode}
176
+ // sessionFolder = .workflow/.csv-wave/{csvSessionId}
177
+ // discoveryDir = .workflow/issues/discoveries/{sessionId}
178
+
179
+ // Create: sessionFolder, discoveryDir, .workflow/issues/
180
+ // Touch: .workflow/issues/issues.jsonl
181
+ ```
182
+
183
+ Initialize `discovery-state.json`:
184
+ ```json
185
+ {
186
+ "id": "{sessionId}",
187
+ "mode": "{mode}",
188
+ "status": "in_progress",
189
+ "started_at": "{ISO}",
190
+ "completed_at": null,
191
+ "perspectives_completed": [],
192
+ "issues_found": 0,
193
+ "issues_deduplicated": 0
194
+ }
195
+ ```
196
+
197
+ ### Phase 1: Mode Resolution -> CSV
198
+
199
+ **Objective**: Determine mode, define perspectives/dimensions, determine scope, generate tasks.csv.
200
+
201
+ #### Multi-Perspective Mode (default)
202
+
203
+ **8 fixed perspectives**:
204
+
205
+ | # | Perspective | Focus | Guiding Question |
206
+ |---|-------------|-------|------------------|
207
+ | 1 | security | Auth, authz, input validation, secrets, injection | What security vulnerabilities or unsafe patterns exist? |
208
+ | 2 | performance | N+1 queries, loops, caching, memory, payloads | What performance bottlenecks or inefficiencies exist? |
209
+ | 3 | reliability | Error handling, retry, race conditions, data integrity | What failure modes are unhandled or could cause data loss? |
210
+ | 4 | maintainability | Duplication, coupling, abstractions, naming, dead code | What makes this codebase harder to understand or change? |
211
+ | 5 | scalability | Hardcoded limits, single-thread, stateful, schema rigidity | What will break or degrade as load/data/users increase? |
212
+ | 6 | ux | Confusing flows, feedback, consistency, loading states | What creates friction or confusion for end users? |
213
+ | 7 | accessibility | Screen reader, keyboard nav, contrast, ARIA, focus | What barriers exist for users with disabilities? |
214
+ | 8 | compliance | Logging, audit trails, retention, privacy, regulatory | What regulatory or policy requirements are not met? |
215
+
216
+ **CSV generation**: 8 perspective rows (wave 1) + 1 dedup row (wave 2).
217
+
218
+ **Scope detection**: Default `src/**/*.{ts,tsx,js,jsx}`. Refine by reading `.workflow/project.md` for tech stack hints.
219
+
220
+ #### By-Prompt Mode
221
+
222
+ 1. Parse `userPrompt` -- if empty, ask user interactively
223
+ 2. Decompose prompt into 3-5 exploration dimensions (use analysis to break down the user's intent into searchable dimensions)
224
+ 3. For each dimension: define name, description, search patterns, file patterns, finding criteria
225
+ 4. Store dimensions in `{discoveryDir}/exploration-plan.json`
226
+ 5. Generate N dimension rows (wave 1) + 1 dedup row (wave 2)
227
+
228
+ **Specs loading**: `specs_content = maestro spec load --role implement` -- pass to agents for severity calibration.
229
+
230
+ **User validation**: Display perspective/dimension breakdown (skip if AUTO_YES).
231
+
232
+ ### Phase 2: Wave Execution Engine
233
+
234
+ **Objective**: Execute perspective scans wave-by-wave via spawn_agents_on_csv.
235
+
236
+ #### Wave 1: Perspective/Dimension Scans (Parallel)
237
+
238
+ 1. Read master `tasks.csv`
239
+ 2. Filter rows where `wave == 1` AND `status == pending`
240
+ 3. No prev_context needed (wave 1 has no predecessors)
241
+ 4. Write `wave-1.csv`
242
+ 5. Execute:
243
+
244
+ ```javascript
245
+ spawn_agents_on_csv({
246
+ csv_path: `${sessionFolder}/wave-1.csv`,
247
+ id_column: "id",
248
+ instruction: buildDiscoverInstruction(sessionFolder, discoveryDir, mode),
249
+ max_concurrency: maxConcurrency,
250
+ max_runtime_seconds: 3600,
251
+ output_csv_path: `${sessionFolder}/wave-1-results.csv`,
252
+ output_schema: { // required: id, status, findings
253
+ id: "string", status: "completed|failed",
254
+ findings: "string", issues_found: "string",
255
+ severity_distribution: "string", error: "string"
256
+ }
257
+ })
258
+ ```
259
+
260
+ 6. Merge `wave-1-results.csv` into master `tasks.csv`
261
+ 7. Save per-perspective findings to `{discoveryDir}/{perspective}-findings.json`
262
+ 8. Update `discovery-state.json` with completed perspectives
263
+ 9. Delete `wave-1.csv`
264
+
265
+ **Perspective scan agent protocol**:
266
+ - Scan all source files matching scope_glob
267
+ - Identify concrete issues with file:line references
268
+ - Rate each finding: critical / high / medium / low
269
+ - Provide brief fix direction for each finding
270
+ - Report affected_components[]
271
+ - Share cross-cutting discoveries via discovery board
272
+ - Output issues_found as JSON array + severity_distribution as JSON object
273
+
274
+ #### Wave 2: Dedup + Issue Creation (Single Agent)
275
+
276
+ 1. Read master `tasks.csv`
277
+ 2. Filter rows where `wave == 2` AND `status == pending`
278
+ 3. Check deps -- if all wave 1 agents failed, skip dedup
279
+ 4. Build `prev_context` from wave 1 findings:
280
+ ```
281
+ [Task 1: Security Scan] Found 3 issues: SQL injection in query builder (critical), missing CSRF token (high)...
282
+ [Task 2: Performance Scan] Found 5 issues: N+1 query in user listing (high), missing pagination (medium)...
283
+ ...
284
+ ```
285
+ 5. Write `wave-2.csv` with `prev_context` column
286
+ 6. Execute `spawn_agents_on_csv` for dedup agent
287
+ 7. Merge results into master `tasks.csv`
288
+ 8. Delete `wave-2.csv`
289
+
290
+ **Dedup agent protocol**:
291
+ - Merge all perspective findings from prev_context into single list
292
+ - Deduplicate: group by file path, compare descriptions (>80% overlap or same file:line → keep higher severity)
293
+ - For each unique finding: generate `ISS-YYYYMMDD-NNN` ID (collision-safe), build full issue record
294
+ - Severity-to-priority: critical→1, high→2, medium→3, low→4; source = "discovery", tags = ["{perspective}"]
295
+ - Append to `.workflow/issues/issues.jsonl` and `{discoveryDir}/discovery-issues.jsonl`
296
+ - Report: pre-dedup count, post-dedup count, severity_distribution
297
+
298
+ ### Phase 3: Results Aggregation
299
+
300
+ **Objective**: Generate final results and human-readable report.
301
+
302
+ 1. Read final master `tasks.csv`
303
+ 2. Export as `results.csv`
304
+ 3. **Update discovery-state.json**:
305
+
306
+ ```json
307
+ {
308
+ "id": "{sessionId}",
309
+ "mode": "{mode}",
310
+ "status": "completed",
311
+ "started_at": "{ISO}",
312
+ "completed_at": "{ISO}",
313
+ "perspectives_completed": ["security", "performance", "..."],
314
+ "issues_found": 42,
315
+ "issues_deduplicated": 31
316
+ }
317
+ ```
318
+
319
+ 4. Copy `discovery-state.json` to `{discoveryDir}/discovery-state.json`
320
+
321
+ 5. **Generate context.md**:
322
+
323
+ ```markdown
324
+ # Issue Discovery Report
325
+
326
+ ## Summary
327
+ - Session: {sessionId}
328
+ - Mode: {mode}
329
+ - Perspectives: {perspective_count}
330
+ - Raw findings: {issues_found}
331
+ - Unique issues: {issues_deduplicated}
332
+
333
+ ## Breakdown by Perspective
334
+ | Perspective | Findings | Critical | High | Medium | Low |
335
+ |-------------|----------|----------|------|--------|-----|
336
+ | Security | {N} | {N} | {N} | {N} | {N} |
337
+ | Performance | {N} | {N} | {N} | {N} | {N} |
338
+ | ... | | | | | |
339
+
340
+ ## Severity Distribution
341
+ | Severity | Count |
342
+ |----------|-------|
343
+ | Critical | {N} |
344
+ | High | {N} |
345
+ | Medium | {N} |
346
+ | Low | {N} |
347
+
348
+ ## Perspective Details
349
+ ### {perspective_name}
350
+ {findings_summary}
351
+
352
+ **Top Issues:**
353
+ {top_issues_list}
354
+
355
+ ## Issues Created
356
+ {list of ISS-YYYYMMDD-NNN IDs with titles}
357
+ ```
358
+
359
+ 6. **Display summary**: Session ID, mode, perspective count, raw vs unique finding counts, per-perspective breakdown, severity breakdown, and output file paths.
360
+
361
+ 7. **Next step routing**:
362
+
363
+ | Result | Suggestion |
364
+ |--------|------------|
365
+ | Critical issues found | `$manage-issue "list --severity critical"` |
366
+ | Issues created | `$manage-issue "list"` |
367
+ | Specific area needs deeper look | `$manage-issue-discover "by-prompt '...'"` |
368
+ | Full scan complete | `$manage-issue "list --source discovery"` |
369
+
370
+ ### Shared Discovery Board Protocol
371
+
372
+ #### Standard Discovery Types
373
+
374
+ | Type | Dedup Key | Data Schema | Description |
375
+ |------|-----------|-------------|-------------|
376
+ | `code_pattern` | `data.name` | `{name, file, description}` | Reusable code pattern found |
377
+ | `integration_point` | `data.file` | `{file, description, exports[]}` | Module connection point |
378
+ | `convention` | singleton | `{naming, imports, formatting}` | Project code conventions |
379
+ | `blocker` | `data.issue` | `{issue, severity, impact}` | Blocking issue found |
380
+ | `tech_stack` | singleton | `{framework, language, tools[]}` | Technology stack info |
381
+
382
+ #### Domain Discovery Types
383
+
384
+ | Type | Dedup Key | Data Schema | Description |
385
+ |------|-----------|-------------|-------------|
386
+ | `vulnerability` | `data.location` | `{location, type, severity, cwe}` | Security vulnerability |
387
+ | `code_smell` | `data.location` | `{location, type, severity, description}` | Code quality issue |
388
+ | `performance_hotspot` | `data.location` | `{location, type, impact}` | Performance issue |
389
+ | `reliability_risk` | `data.location` | `{location, failure_mode, impact}` | Reliability concern |
390
+ | `scalability_limit` | `data.location` | `{location, constraint, threshold}` | Scalability bottleneck |
391
+
392
+ #### Protocol
393
+
394
+ 1. **Read** `{session_folder}/discoveries.ndjson` before own scan
395
+ 2. **Skip covered**: If discovery of same type + dedup key exists, skip
396
+ 3. **Write immediately**: Append findings as found
397
+ 4. **Append-only**: Never modify or delete
398
+ 5. **Deduplicate**: Check before writing
399
+
400
+ ```bash
401
+ echo '{"ts":"<ISO>","worker":"{id}","type":"vulnerability","data":{"location":"src/auth/login.ts:42","type":"sql_injection","severity":"critical","cwe":"CWE-89"}}' >> {session_folder}/discoveries.ndjson
402
+ ```
403
+ </execution>
404
+
405
+ <error_codes>
406
+
407
+ | Error | Resolution |
408
+ |-------|------------|
409
+ | `.workflow/` does not exist | Abort: "No project initialized. Run maestro-init first." |
410
+ | `by-prompt` with empty prompt | Interactive prompt with suggested options |
411
+ | Perspective agent timeout | Mark as failed, continue remaining perspectives |
412
+ | All perspective agents failed | Skip dedup, report no findings |
413
+ | Dedup agent failed | Use wave 1 results directly, create issues from raw findings |
414
+ | issues.jsonl write failure | Retry once, then report error with findings in context.md |
415
+ | CSV parse error | Validate format, show line number |
416
+ | discoveries.ndjson corrupt | Ignore malformed lines |
417
+ | Continue mode: no session found | List available sessions |
418
+ | ID collision in issues.jsonl | Re-read file, recalculate next sequence number |
419
+ </error_codes>
420
+
421
+ <success_criteria>
422
+ - [ ] Session initialized with discovery-state.json
423
+ - [ ] tasks.csv generated with correct perspective/wave assignments
424
+ - [ ] All perspective agents executed in parallel (wave 1)
425
+ - [ ] Dedup agent aggregates and deduplicates findings (wave 2)
426
+ - [ ] Issues appended to .workflow/issues/issues.jsonl with unique IDs
427
+ - [ ] results.csv and context.md generated with full breakdown
428
+ - [ ] Temporary wave-{N}.csv files cleaned up after merge
429
+ - [ ] discoveries.ndjson maintained as append-only
430
+ - [ ] Per-perspective findings saved to discovery directory
431
+ </success_criteria>