claude-code-workflow 6.3.10 → 6.3.12

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 (88) hide show
  1. package/.claude/CLAUDE.md +33 -33
  2. package/.claude/agents/issue-plan-agent.md +18 -5
  3. package/.claude/agents/issue-queue-agent.md +12 -5
  4. package/.claude/commands/issue/discover.md +427 -0
  5. package/.claude/commands/issue/new.md +13 -1
  6. package/.claude/commands/issue/plan.md +48 -32
  7. package/.claude/commands/issue/queue.md +99 -7
  8. package/.claude/skills/software-manual/SKILL.md +184 -0
  9. package/.claude/skills/software-manual/phases/01-requirements-discovery.md +162 -0
  10. package/.claude/skills/software-manual/phases/02-project-exploration.md +101 -0
  11. package/.claude/skills/software-manual/phases/02.5-api-extraction.md +161 -0
  12. package/.claude/skills/software-manual/phases/03-parallel-analysis.md +183 -0
  13. package/.claude/skills/software-manual/phases/03.5-consolidation.md +82 -0
  14. package/.claude/skills/software-manual/phases/04-screenshot-capture.md +89 -0
  15. package/.claude/skills/software-manual/phases/05-html-assembly.md +132 -0
  16. package/.claude/skills/software-manual/phases/06-iterative-refinement.md +259 -0
  17. package/.claude/skills/software-manual/scripts/api-extractor.md +245 -0
  18. package/.claude/skills/software-manual/scripts/assemble_docsify.py +584 -0
  19. package/.claude/skills/software-manual/scripts/bundle-libraries.md +85 -0
  20. package/.claude/skills/software-manual/scripts/extract_apis.py +270 -0
  21. package/.claude/skills/software-manual/scripts/screenshot-helper.md +447 -0
  22. package/.claude/skills/software-manual/scripts/swagger-runner.md +419 -0
  23. package/.claude/skills/software-manual/scripts/typedoc-runner.md +357 -0
  24. package/.claude/skills/software-manual/specs/html-template.md +325 -0
  25. package/.claude/skills/software-manual/specs/quality-standards.md +253 -0
  26. package/.claude/skills/software-manual/specs/writing-style.md +298 -0
  27. package/.claude/skills/software-manual/templates/css/docsify-base.css +984 -0
  28. package/.claude/skills/software-manual/templates/css/wiki-base.css +788 -0
  29. package/.claude/skills/software-manual/templates/css/wiki-dark.css +278 -0
  30. package/.claude/skills/software-manual/templates/docsify-shell.html +466 -0
  31. package/.claude/skills/software-manual/templates/tiddlywiki-shell.html +327 -0
  32. package/.claude/workflows/cli-templates/schemas/discovery-finding-schema.json +219 -0
  33. package/.claude/workflows/cli-templates/schemas/discovery-state-schema.json +125 -0
  34. package/.claude/workflows/cli-templates/schemas/issues-jsonl-schema.json +168 -74
  35. package/.codex/prompts/issue-execute.md +174 -84
  36. package/.codex/prompts/issue-plan.md +106 -0
  37. package/.codex/prompts/issue-queue.md +225 -0
  38. package/ccw/dist/cli.d.ts.map +1 -1
  39. package/ccw/dist/cli.js +1 -0
  40. package/ccw/dist/cli.js.map +1 -1
  41. package/ccw/dist/commands/issue.d.ts.map +1 -1
  42. package/ccw/dist/commands/issue.js +97 -9
  43. package/ccw/dist/commands/issue.js.map +1 -1
  44. package/ccw/dist/core/dashboard-generator.d.ts.map +1 -1
  45. package/ccw/dist/core/dashboard-generator.js +4 -1
  46. package/ccw/dist/core/dashboard-generator.js.map +1 -1
  47. package/ccw/dist/core/data-aggregator.d.ts +32 -0
  48. package/ccw/dist/core/data-aggregator.d.ts.map +1 -1
  49. package/ccw/dist/core/data-aggregator.js +55 -11
  50. package/ccw/dist/core/data-aggregator.js.map +1 -1
  51. package/ccw/dist/core/routes/discovery-routes.d.ts +37 -0
  52. package/ccw/dist/core/routes/discovery-routes.d.ts.map +1 -0
  53. package/ccw/dist/core/routes/discovery-routes.js +514 -0
  54. package/ccw/dist/core/routes/discovery-routes.js.map +1 -0
  55. package/ccw/dist/core/server.d.ts.map +1 -1
  56. package/ccw/dist/core/server.js +9 -1
  57. package/ccw/dist/core/server.js.map +1 -1
  58. package/ccw/dist/tools/codex-lens.d.ts +12 -1
  59. package/ccw/dist/tools/codex-lens.d.ts.map +1 -1
  60. package/ccw/dist/tools/codex-lens.js +56 -7
  61. package/ccw/dist/tools/codex-lens.js.map +1 -1
  62. package/ccw/src/cli.ts +1 -0
  63. package/ccw/src/commands/issue.ts +108 -10
  64. package/ccw/src/core/dashboard-generator.ts +4 -1
  65. package/ccw/src/core/data-aggregator.ts +94 -11
  66. package/ccw/src/core/routes/discovery-routes.ts +607 -0
  67. package/ccw/src/core/server.ts +9 -1
  68. package/ccw/src/templates/dashboard-css/33-cli-stream-viewer.css +580 -467
  69. package/ccw/src/templates/dashboard-css/34-discovery.css +783 -0
  70. package/ccw/src/templates/dashboard-js/components/cli-stream-viewer.js +532 -461
  71. package/ccw/src/templates/dashboard-js/components/navigation.js +8 -0
  72. package/ccw/src/templates/dashboard-js/components/notifications.js +774 -774
  73. package/ccw/src/templates/dashboard-js/i18n.js +144 -0
  74. package/ccw/src/templates/dashboard-js/views/codexlens-manager.js +13 -3
  75. package/ccw/src/templates/dashboard-js/views/issue-discovery.js +730 -0
  76. package/ccw/src/templates/dashboard-js/views/project-overview.js +153 -0
  77. package/ccw/src/templates/dashboard.html +15 -0
  78. package/ccw/src/tools/claude-cli-tools.ts +388 -388
  79. package/ccw/src/tools/codex-lens.ts +75 -9
  80. package/codex-lens/src/codexlens/__pycache__/config.cpython-313.pyc +0 -0
  81. package/codex-lens/src/codexlens/config.py +19 -3
  82. package/codex-lens/src/codexlens/search/__pycache__/ranking.cpython-313.pyc +0 -0
  83. package/codex-lens/src/codexlens/search/ranking.py +15 -4
  84. package/codex-lens/src/codexlens/semantic/__pycache__/vector_store.cpython-313.pyc +0 -0
  85. package/codex-lens/src/codexlens/semantic/vector_store.py +57 -47
  86. package/codex-lens/src/codexlens/storage/__pycache__/registry.cpython-313.pyc +0 -0
  87. package/codex-lens/src/codexlens/storage/registry.py +114 -101
  88. package/package.json +2 -2
package/.claude/CLAUDE.md CHANGED
@@ -1,33 +1,33 @@
1
- # Claude Instructions
2
-
3
- - **CLI Tools Usage**: @~/.claude/workflows/cli-tools-usage.md
4
- - **Coding Philosophy**: @~/.claude/workflows/coding-philosophy.md
5
- - **Context Requirements**: @~/.claude/workflows/context-tools.md
6
- - **File Modification**: @~/.claude/workflows/file-modification.md
7
- - **CLI Endpoints Config**: @.claude/cli-tools.json
8
-
9
- ## CLI Endpoints
10
-
11
- **Strictly follow the @.claude/cli-tools.json configuration**
12
-
13
- Available CLI endpoints are dynamically defined by the config file:
14
- - Built-in tools and their enable/disable status
15
- - Custom API endpoints registered via the Dashboard
16
- - Managed through the CCW Dashboard Status page
17
-
18
- ## Tool Execution
19
-
20
- ### Agent Calls
21
- - **Always use `run_in_background: false`** for Task tool agent calls: `Task({ subagent_type: "xxx", prompt: "...", run_in_background: false })` to ensure synchronous execution and immediate result visibility
22
- - **TaskOutput usage**: Only use `TaskOutput({ task_id: "xxx", block: false })` + sleep loop to poll completion status. NEVER read intermediate output during agent/CLI execution - wait for final result only
23
-
24
- ### CLI Tool Calls (ccw cli)
25
- - **Always use `run_in_background: true`** for Bash tool when calling ccw cli:
26
- ```
27
- Bash({ command: "ccw cli -p '...' --tool gemini", run_in_background: true })
28
- ```
29
- - **After CLI call**: If no other tasks, stop immediately - let CLI execute in background, do NOT poll with TaskOutput
30
-
31
- ## Code Diagnostics
32
-
33
- - **Prefer `mcp__ide__getDiagnostics`** for code error checking over shell-based TypeScript compilation
1
+ # Claude Instructions
2
+
3
+ - **CLI Tools Usage**: @~/.claude/workflows/cli-tools-usage.md
4
+ - **Coding Philosophy**: @~/.claude/workflows/coding-philosophy.md
5
+ - **Context Requirements**: @~/.claude/workflows/context-tools.md
6
+ - **File Modification**: @~/.claude/workflows/file-modification.md
7
+ - **CLI Endpoints Config**: @.claude/cli-tools.json
8
+
9
+ ## CLI Endpoints
10
+
11
+ **Strictly follow the @.claude/cli-tools.json configuration**
12
+
13
+ Available CLI endpoints are dynamically defined by the config file:
14
+ - Built-in tools and their enable/disable status
15
+ - Custom API endpoints registered via the Dashboard
16
+ - Managed through the CCW Dashboard Status page
17
+
18
+ ## Tool Execution
19
+
20
+ ### Agent Calls
21
+ - **Always use `run_in_background: false`** for Task tool agent calls: `Task({ subagent_type: "xxx", prompt: "...", run_in_background: false })` to ensure synchronous execution and immediate result visibility
22
+ - **TaskOutput usage**: Only use `TaskOutput({ task_id: "xxx", block: false })` + sleep loop to poll completion status. NEVER read intermediate output during agent/CLI execution - wait for final result only
23
+
24
+ ### CLI Tool Calls (ccw cli)
25
+ - **Always use `run_in_background: true`** for Bash tool when calling ccw cli:
26
+ ```
27
+ Bash({ command: "ccw cli -p '...' --tool gemini", run_in_background: true })
28
+ ```
29
+ - **After CLI call**: If no other tasks, stop immediately - let CLI execute in background, do NOT poll with TaskOutput
30
+
31
+ ## Code Diagnostics
32
+
33
+ - **Prefer `mcp__ide__getDiagnostics`** for code error checking over shell-based TypeScript compilation
@@ -180,10 +180,23 @@ function decomposeTasks(issue, exploration) {
180
180
  - Task validation (all 5 phases present)
181
181
  - Conflict detection (cross-issue file modifications)
182
182
 
183
- **Solution Registration**:
184
- ```bash
185
- # Write solution and register via CLI
186
- ccw issue bind <issue-id> --solution /tmp/sol.json
183
+ **Solution Registration** (CRITICAL: check solution count first):
184
+ ```javascript
185
+ for (const issue of issues) {
186
+ const solutions = generatedSolutions[issue.id];
187
+
188
+ if (solutions.length === 1) {
189
+ // Single solution → auto-bind
190
+ Bash(`ccw issue bind ${issue.id} --solution ${solutions[0].file}`);
191
+ bound.push({ issue_id: issue.id, solution_id: solutions[0].id, task_count: solutions[0].tasks.length });
192
+ } else {
193
+ // Multiple solutions → DO NOT BIND, return for user selection
194
+ pending_selection.push({
195
+ issue_id: issue.id,
196
+ solutions: solutions.map(s => ({ id: s.id, description: s.description, task_count: s.tasks.length }))
197
+ });
198
+ }
199
+ }
187
200
  ```
188
201
 
189
202
  ---
@@ -255,7 +268,7 @@ Each line is a solution JSON containing tasks. Schema: `cat .claude/workflows/cl
255
268
  2. Use vague criteria ("works correctly", "good performance")
256
269
  3. Create circular dependencies
257
270
  4. Generate more than 10 tasks per issue
258
- 5. Bind when multiple solutions exist
271
+ 5. **Bind when multiple solutions exist** - MUST check `solutions.length === 1` before calling `ccw issue bind`
259
272
 
260
273
  **OUTPUT**:
261
274
  1. Register solutions via `ccw issue bind <id> --solution <file>`
@@ -148,7 +148,7 @@ function detectConflicts(fileModifications, graph) {
148
148
  .workflow/issues/queues/index.json # Update with new queue entry
149
149
  ```
150
150
 
151
- Queue ID format: `QUE-YYYYMMDD-HHMMSS` (UTC timestamp)
151
+ Queue ID: Use the Queue ID provided in prompt (do NOT generate new one)
152
152
  Queue Item ID format: `S-N` (S-1, S-2, S-3, ...)
153
153
 
154
154
  ### 3.2 Queue File Schema
@@ -241,7 +241,14 @@ Queue Item ID format: `S-N` (S-1, S-2, S-3, ...)
241
241
  5. Merge conflicting solutions in parallel group
242
242
  6. Split tasks from their solution
243
243
 
244
- **OUTPUT**:
245
- 1. Write `.workflow/issues/queues/{queue-id}.json`
246
- 2. Update `.workflow/issues/queues/index.json`
247
- 3. Return summary with `queue_id`, `total_solutions`, `total_tasks`, `execution_groups`, `conflicts_resolved`, `issues_queued`
244
+ **OUTPUT** (STRICT - only these 2 files):
245
+ ```
246
+ .workflow/issues/queues/{Queue ID}.json # Use Queue ID from prompt
247
+ .workflow/issues/queues/index.json # Update existing index
248
+ ```
249
+ - Use the Queue ID provided in prompt, do NOT generate new one
250
+ - Write ONLY the 2 files listed above, NO other files
251
+ - Final return: PURE JSON summary (no markdown, no prose):
252
+ ```json
253
+ {"queue_id":"QUE-xxx","total_solutions":N,"total_tasks":N,"execution_groups":[...],"conflicts_resolved":N,"issues_queued":["ISS-xxx"]}
254
+ ```
@@ -0,0 +1,427 @@
1
+ ---
2
+ name: issue:discover
3
+ description: Discover potential issues from multiple perspectives (bug, UX, test, quality, security, performance, maintainability, best-practices) using CLI explore. Supports Exa external research for security and best-practices perspectives.
4
+ argument-hint: "<path-pattern> [--perspectives=bug,ux,...] [--external]"
5
+ allowed-tools: SlashCommand(*), TodoWrite(*), Read(*), Bash(*), Task(*), AskUserQuestion(*), Glob(*), Grep(*)
6
+ ---
7
+
8
+ # Issue Discovery Command
9
+
10
+ ## Quick Start
11
+
12
+ ```bash
13
+ # Discover issues in specific module (interactive perspective selection)
14
+ /issue:discover src/auth/**
15
+
16
+ # Discover with specific perspectives
17
+ /issue:discover src/payment/** --perspectives=bug,security,test
18
+
19
+ # Discover with external research for all perspectives
20
+ /issue:discover src/api/** --external
21
+
22
+ # Discover in multiple modules
23
+ /issue:discover src/auth/**,src/payment/**
24
+ ```
25
+
26
+ **Discovery Scope**: Specified modules/files only
27
+ **Output Directory**: `.workflow/issues/discoveries/{discovery-id}/`
28
+ **Available Perspectives**: bug, ux, test, quality, security, performance, maintainability, best-practices
29
+ **Exa Integration**: Auto-enabled for security and best-practices perspectives
30
+ **CLI Tools**: Gemini → Qwen → Codex (fallback chain)
31
+
32
+ ## What & Why
33
+
34
+ ### Core Concept
35
+ Multi-perspective issue discovery orchestrator that explores code from different angles to identify potential bugs, UX improvements, test gaps, and other actionable items. Unlike code review (which assesses existing code quality), discovery focuses on **finding opportunities for improvement and potential problems**.
36
+
37
+ **vs Code Review**:
38
+ - **Code Review** (`review-module-cycle`): Evaluates code quality against standards
39
+ - **Issue Discovery** (`issue:discover`): Finds actionable issues, bugs, and improvement opportunities
40
+
41
+ ### Value Proposition
42
+ 1. **Proactive Issue Detection**: Find problems before they become bugs
43
+ 2. **Multi-Perspective Analysis**: Each perspective surfaces different types of issues
44
+ 3. **External Benchmarking**: Compare against industry best practices via Exa
45
+ 4. **Direct Issue Integration**: Discoveries can be exported to issue tracker
46
+ 5. **Dashboard Management**: View, filter, and export discoveries via CCW dashboard
47
+
48
+ ## How It Works
49
+
50
+ ### Execution Flow
51
+
52
+ ```
53
+ Phase 1: Discovery & Initialization
54
+ └─ Parse target pattern, create session, initialize output structure
55
+
56
+ Phase 2: Interactive Perspective Selection
57
+ └─ AskUserQuestion for perspective selection (or use --perspectives)
58
+
59
+ Phase 3: Parallel Perspective Analysis
60
+ ├─ Launch N @cli-explore-agent instances (one per perspective)
61
+ ├─ Security & Best-Practices auto-trigger Exa research
62
+ ├─ Agent writes perspective JSON, returns summary
63
+ └─ Update discovery-progress.json
64
+
65
+ Phase 4: Aggregation & Prioritization
66
+ ├─ Collect agent return summaries
67
+ ├─ Load perspective JSON files
68
+ ├─ Merge findings, deduplicate by file+line
69
+ └─ Calculate priority scores
70
+
71
+ Phase 5: Issue Generation & Summary
72
+ ├─ Convert high-priority discoveries to issue format
73
+ ├─ Write to discovery-issues.jsonl
74
+ ├─ Generate single summary.md from agent returns
75
+ └─ Update discovery-state.json to complete
76
+ ```
77
+
78
+ ## Perspectives
79
+
80
+ ### Available Perspectives
81
+
82
+ | Perspective | Focus | Categories | Exa |
83
+ |-------------|-------|------------|-----|
84
+ | **bug** | Potential Bugs | edge-case, null-check, resource-leak, race-condition, boundary, exception-handling | - |
85
+ | **ux** | User Experience | error-message, loading-state, feedback, accessibility, interaction, consistency | - |
86
+ | **test** | Test Coverage | missing-test, edge-case-test, integration-gap, coverage-hole, assertion-quality | - |
87
+ | **quality** | Code Quality | complexity, duplication, naming, documentation, code-smell, readability | - |
88
+ | **security** | Security Issues | injection, auth, encryption, input-validation, data-exposure, access-control | ✓ |
89
+ | **performance** | Performance | n-plus-one, memory-usage, caching, algorithm, blocking-operation, resource | - |
90
+ | **maintainability** | Maintainability | coupling, cohesion, tech-debt, extensibility, module-boundary, interface-design | - |
91
+ | **best-practices** | Best Practices | convention, pattern, framework-usage, anti-pattern, industry-standard | ✓ |
92
+
93
+ ### Interactive Perspective Selection
94
+
95
+ When no `--perspectives` flag is provided, the command uses AskUserQuestion:
96
+
97
+ ```javascript
98
+ AskUserQuestion({
99
+ questions: [{
100
+ question: "Select primary discovery focus:",
101
+ header: "Focus",
102
+ multiSelect: false,
103
+ options: [
104
+ { label: "Bug + Test + Quality", description: "Quick scan: potential bugs, test gaps, code quality (Recommended)" },
105
+ { label: "Security + Performance", description: "System audit: security issues, performance bottlenecks" },
106
+ { label: "Maintainability + Best-practices", description: "Long-term health: coupling, tech debt, conventions" },
107
+ { label: "Full analysis", description: "All 7 perspectives (comprehensive, takes longer)" }
108
+ ]
109
+ }]
110
+ })
111
+ ```
112
+
113
+ **Recommended Combinations**:
114
+ - Quick scan: bug, test, quality
115
+ - Full analysis: all perspectives
116
+ - Security audit: security, bug, quality
117
+
118
+ ## Core Responsibilities
119
+
120
+ ### Orchestrator
121
+
122
+ **Phase 1: Discovery & Initialization**
123
+
124
+ ```javascript
125
+ // Step 1: Parse target pattern and resolve files
126
+ const resolvedFiles = await expandGlobPattern(targetPattern);
127
+ if (resolvedFiles.length === 0) {
128
+ throw new Error(`No files matched pattern: ${targetPattern}`);
129
+ }
130
+
131
+ // Step 2: Generate discovery ID
132
+ const discoveryId = `DSC-${formatDate(new Date(), 'YYYYMMDD-HHmmss')}`;
133
+
134
+ // Step 3: Create output directory
135
+ const outputDir = `.workflow/issues/discoveries/${discoveryId}`;
136
+ await mkdir(outputDir, { recursive: true });
137
+ await mkdir(`${outputDir}/perspectives`, { recursive: true });
138
+
139
+ // Step 4: Initialize unified discovery state (merged state+progress)
140
+ await writeJson(`${outputDir}/discovery-state.json`, {
141
+ discovery_id: discoveryId,
142
+ target_pattern: targetPattern,
143
+ phase: "initialization",
144
+ created_at: new Date().toISOString(),
145
+ updated_at: new Date().toISOString(),
146
+ target: { files_count: { total: resolvedFiles.length }, project: {} },
147
+ perspectives: [], // filled after selection: [{name, status, findings}]
148
+ external_research: { enabled: false, completed: false },
149
+ results: { total_findings: 0, issues_generated: 0, priority_distribution: {} }
150
+ });
151
+ ```
152
+
153
+ **Phase 2: Perspective Selection**
154
+
155
+ ```javascript
156
+ // Check for --perspectives flag
157
+ let selectedPerspectives = [];
158
+
159
+ if (args.perspectives) {
160
+ selectedPerspectives = args.perspectives.split(',').map(p => p.trim());
161
+ } else {
162
+ // Interactive selection via AskUserQuestion
163
+ const response = await AskUserQuestion({...});
164
+ selectedPerspectives = parseSelectedPerspectives(response);
165
+ }
166
+
167
+ // Validate and update state
168
+ await updateDiscoveryState(outputDir, {
169
+ 'metadata.perspectives': selectedPerspectives,
170
+ phase: 'parallel'
171
+ });
172
+ ```
173
+
174
+ **Phase 3: Parallel Perspective Analysis**
175
+
176
+ Launch N agents in parallel (one per selected perspective):
177
+
178
+ ```javascript
179
+ // Launch agents in parallel - agents write JSON and return summary
180
+ const agentPromises = selectedPerspectives.map(perspective =>
181
+ Task({
182
+ subagent_type: "cli-explore-agent",
183
+ run_in_background: false,
184
+ description: `Discover ${perspective} issues`,
185
+ prompt: buildPerspectivePrompt(perspective, discoveryId, resolvedFiles, outputDir)
186
+ })
187
+ );
188
+
189
+ // Wait for all agents - collect their return summaries
190
+ const results = await Promise.all(agentPromises);
191
+ // results contain agent summaries for final report
192
+ ```
193
+
194
+ **Phase 4: Aggregation & Prioritization**
195
+
196
+ ```javascript
197
+ // Load all perspective JSON files written by agents
198
+ const allFindings = [];
199
+ for (const perspective of selectedPerspectives) {
200
+ const jsonPath = `${outputDir}/perspectives/${perspective}.json`;
201
+ if (await fileExists(jsonPath)) {
202
+ const data = await readJson(jsonPath);
203
+ allFindings.push(...data.findings.map(f => ({ ...f, perspective })));
204
+ }
205
+ }
206
+
207
+ // Deduplicate and prioritize
208
+ const prioritizedFindings = deduplicateAndPrioritize(allFindings);
209
+
210
+ // Update unified state
211
+ await updateDiscoveryState(outputDir, {
212
+ phase: 'aggregation',
213
+ 'results.total_findings': prioritizedFindings.length,
214
+ 'results.priority_distribution': countByPriority(prioritizedFindings)
215
+ });
216
+ ```
217
+
218
+ **Phase 5: Issue Generation & Summary**
219
+
220
+ ```javascript
221
+ // Convert high-priority findings to issues
222
+ const issueWorthy = prioritizedFindings.filter(f =>
223
+ f.priority === 'critical' || f.priority === 'high' || f.priority_score >= 0.7
224
+ );
225
+
226
+ // Write discovery-issues.jsonl
227
+ await writeJsonl(`${outputDir}/discovery-issues.jsonl`, issues);
228
+
229
+ // Generate single summary.md from agent return summaries
230
+ // Orchestrator briefly summarizes what agents returned (NO detailed reports)
231
+ await writeSummaryFromAgentReturns(outputDir, results, prioritizedFindings, issues);
232
+
233
+ // Update final state
234
+ await updateDiscoveryState(outputDir, {
235
+ phase: 'complete',
236
+ updated_at: new Date().toISOString(),
237
+ 'results.issues_generated': issues.length
238
+ });
239
+ ```
240
+
241
+ ### Output File Structure
242
+
243
+ ```
244
+ .workflow/issues/discoveries/
245
+ ├── index.json # Discovery session index
246
+ └── {discovery-id}/
247
+ ├── discovery-state.json # Unified state (merged state+progress)
248
+ ├── perspectives/
249
+ │ └── {perspective}.json # Per-perspective findings
250
+ ├── external-research.json # Exa research results (if enabled)
251
+ ├── discovery-issues.jsonl # Generated candidate issues
252
+ └── summary.md # Single summary (from agent returns)
253
+ ```
254
+
255
+ ### Schema References
256
+
257
+ **External Schema Files** (agent MUST read and follow exactly):
258
+
259
+ | Schema | Path | Purpose |
260
+ |--------|------|---------|
261
+ | **Discovery State** | `~/.claude/workflows/cli-templates/schemas/discovery-state-schema.json` | Session state machine |
262
+ | **Discovery Finding** | `~/.claude/workflows/cli-templates/schemas/discovery-finding-schema.json` | Perspective analysis results |
263
+
264
+ ### Agent Invocation Template
265
+
266
+ **Perspective Analysis Agent**:
267
+
268
+ ```javascript
269
+ Task({
270
+ subagent_type: "cli-explore-agent",
271
+ run_in_background: false,
272
+ description: `Discover ${perspective} issues`,
273
+ prompt: `
274
+ ## Task Objective
275
+ Discover potential ${perspective} issues in specified module files.
276
+
277
+ ## Discovery Context
278
+ - Discovery ID: ${discoveryId}
279
+ - Perspective: ${perspective}
280
+ - Target Pattern: ${targetPattern}
281
+ - Resolved Files: ${resolvedFiles.length} files
282
+ - Output Directory: ${outputDir}
283
+
284
+ ## MANDATORY FIRST STEPS
285
+ 1. Read discovery state: ${outputDir}/discovery-state.json
286
+ 2. Read schema: ~/.claude/workflows/cli-templates/schemas/discovery-finding-schema.json
287
+ 3. Analyze target files for ${perspective} concerns
288
+
289
+ ## Output Requirements
290
+
291
+ **1. Write JSON file**: ${outputDir}/perspectives/${perspective}.json
292
+ - Follow discovery-finding-schema.json exactly
293
+ - Each finding: id, title, priority, category, description, file, line, snippet, suggested_issue, confidence
294
+
295
+ **2. Return summary** (DO NOT write report file):
296
+ - Return a brief text summary of findings
297
+ - Include: total findings, priority breakdown, key issues
298
+ - This summary will be used by orchestrator for final report
299
+
300
+ ## Perspective-Specific Guidance
301
+ ${getPerspectiveGuidance(perspective)}
302
+
303
+ ## Success Criteria
304
+ - [ ] JSON written to ${outputDir}/perspectives/${perspective}.json
305
+ - [ ] Summary returned with findings count and key issues
306
+ - [ ] Each finding includes actionable suggested_issue
307
+ - [ ] Priority uses lowercase enum: critical/high/medium/low
308
+ `
309
+ })
310
+ ```
311
+
312
+ **Exa Research Agent** (for security and best-practices):
313
+
314
+ ```javascript
315
+ Task({
316
+ subagent_type: "cli-explore-agent",
317
+ run_in_background: false,
318
+ description: `External research for ${perspective} via Exa`,
319
+ prompt: `
320
+ ## Task Objective
321
+ Research industry best practices for ${perspective} using Exa search
322
+
323
+ ## Research Steps
324
+ 1. Read project tech stack: .workflow/project-tech.json
325
+ 2. Use Exa to search for best practices
326
+ 3. Synthesize findings relevant to this project
327
+
328
+ ## Output Requirements
329
+
330
+ **1. Write JSON file**: ${outputDir}/external-research.json
331
+ - Include sources, key_findings, gap_analysis, recommendations
332
+
333
+ **2. Return summary** (DO NOT write report file):
334
+ - Brief summary of external research findings
335
+ - Key recommendations for the project
336
+
337
+ ## Success Criteria
338
+ - [ ] JSON written to ${outputDir}/external-research.json
339
+ - [ ] Summary returned with key recommendations
340
+ - [ ] Findings are relevant to project's tech stack
341
+ `
342
+ })
343
+ ```
344
+
345
+ ### Perspective Guidance Reference
346
+
347
+ ```javascript
348
+ function getPerspectiveGuidance(perspective) {
349
+ const guidance = {
350
+ bug: `
351
+ Focus: Null checks, edge cases, resource leaks, race conditions, boundary conditions, exception handling
352
+ Priority: Critical=data corruption/crash, High=malfunction, Medium=edge case issues, Low=minor
353
+ `,
354
+ ux: `
355
+ Focus: Error messages, loading states, feedback, accessibility, interaction patterns, form validation
356
+ Priority: Critical=inaccessible, High=confusing, Medium=inconsistent, Low=cosmetic
357
+ `,
358
+ test: `
359
+ Focus: Missing unit tests, edge case coverage, integration gaps, assertion quality, test isolation
360
+ Priority: Critical=no security tests, High=no core logic tests, Medium=weak coverage, Low=minor gaps
361
+ `,
362
+ quality: `
363
+ Focus: Complexity, duplication, naming, documentation, code smells, readability
364
+ Priority: Critical=unmaintainable, High=significant issues, Medium=naming/docs, Low=minor refactoring
365
+ `,
366
+ security: `
367
+ Focus: Input validation, auth/authz, injection, XSS/CSRF, data exposure, access control
368
+ Priority: Critical=auth bypass/injection, High=missing authz, Medium=weak validation, Low=headers
369
+ `,
370
+ performance: `
371
+ Focus: N+1 queries, memory leaks, caching, algorithm efficiency, blocking operations
372
+ Priority: Critical=memory leaks, High=N+1/inefficient, Medium=missing cache, Low=minor optimization
373
+ `,
374
+ maintainability: `
375
+ Focus: Coupling, interface design, tech debt, extensibility, module boundaries, configuration
376
+ Priority: Critical=unrelated code changes, High=unclear boundaries, Medium=coupling, Low=refactoring
377
+ `,
378
+ 'best-practices': `
379
+ Focus: Framework conventions, language patterns, anti-patterns, deprecated APIs, coding standards
380
+ Priority: Critical=anti-patterns causing bugs, High=convention violations, Medium=style, Low=cosmetic
381
+ `
382
+ };
383
+ return guidance[perspective] || 'General code discovery analysis';
384
+ }
385
+ ```
386
+
387
+ ## Dashboard Integration
388
+
389
+ ### Viewing Discoveries
390
+
391
+ Open CCW dashboard to manage discoveries:
392
+
393
+ ```bash
394
+ ccw view
395
+ ```
396
+
397
+ Navigate to **Issues > Discovery** to:
398
+ - View all discovery sessions
399
+ - Filter findings by perspective and priority
400
+ - Preview finding details
401
+ - Select and export findings as issues
402
+
403
+ ### Exporting to Issues
404
+
405
+ From the dashboard, select findings and click "Export as Issues" to:
406
+ 1. Convert discoveries to standard issue format
407
+ 2. Append to `.workflow/issues/issues.jsonl`
408
+ 3. Set status to `registered`
409
+ 4. Continue with `/issue:plan` workflow
410
+
411
+ ## Related Commands
412
+
413
+ ```bash
414
+ # After discovery, plan solutions for exported issues
415
+ /issue:plan DSC-001,DSC-002,DSC-003
416
+
417
+ # Or use interactive management
418
+ /issue:manage
419
+ ```
420
+
421
+ ## Best Practices
422
+
423
+ 1. **Start Focused**: Begin with specific modules rather than entire codebase
424
+ 2. **Use Quick Scan First**: Start with bug, test, quality for fast results
425
+ 3. **Review Before Export**: Not all discoveries warrant issues - use dashboard to filter
426
+ 4. **Combine Perspectives**: Run related perspectives together (e.g., security + bug)
427
+ 5. **Enable Exa for New Tech**: When using unfamiliar frameworks, enable external research
@@ -24,7 +24,7 @@ interface Issue {
24
24
  status: 'registered'; // Initial status
25
25
  priority: number; // 1 (critical) to 5 (low)
26
26
  context: string; // Problem description
27
- source: 'github' | 'text'; // Input source type
27
+ source: 'github' | 'text' | 'discovery'; // Input source type
28
28
  source_url?: string; // GitHub URL if applicable
29
29
  labels?: string[]; // Categorization labels
30
30
 
@@ -35,6 +35,18 @@ interface Issue {
35
35
  affected_components?: string[];// Files/modules affected
36
36
  reproduction_steps?: string[]; // Steps to reproduce
37
37
 
38
+ // Discovery context (when source='discovery')
39
+ discovery_context?: {
40
+ discovery_id: string; // Source discovery session
41
+ perspective: string; // bug, test, quality, etc.
42
+ category: string; // Finding category
43
+ file: string; // Primary affected file
44
+ line: number; // Line number
45
+ snippet?: string; // Code snippet
46
+ confidence: number; // Agent confidence (0-1)
47
+ suggested_fix?: string; // Suggested remediation
48
+ };
49
+
38
50
  // Closed-loop requirements (guide plan generation)
39
51
  lifecycle_requirements: {
40
52
  test_strategy: 'unit' | 'integration' | 'e2e' | 'manual' | 'auto';