claude-code-workflow 6.3.25 → 6.3.26
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude/commands/issue/discover-by-prompt.md +764 -0
- package/ccw/dist/core/routes/help-routes.d.ts.map +1 -1
- package/ccw/dist/core/routes/help-routes.js +43 -7
- package/ccw/dist/core/routes/help-routes.js.map +1 -1
- package/ccw/dist/core/routes/litellm-api-routes.d.ts.map +1 -1
- package/ccw/dist/core/routes/litellm-api-routes.js +31 -5
- package/ccw/dist/core/routes/litellm-api-routes.js.map +1 -1
- package/ccw/dist/core/routes/memory-routes.d.ts.map +1 -1
- package/ccw/dist/core/routes/memory-routes.js +73 -0
- package/ccw/dist/core/routes/memory-routes.js.map +1 -1
- package/ccw/dist/core/routes/status-routes.d.ts.map +1 -1
- package/ccw/dist/core/routes/status-routes.js +36 -4
- package/ccw/dist/core/routes/status-routes.js.map +1 -1
- package/ccw/dist/core/server.d.ts.map +1 -1
- package/ccw/dist/core/server.js +58 -0
- package/ccw/dist/core/server.js.map +1 -1
- package/ccw/dist/core/services/api-key-tester.d.ts.map +1 -1
- package/ccw/dist/core/services/api-key-tester.js +8 -3
- package/ccw/dist/core/services/api-key-tester.js.map +1 -1
- package/ccw/dist/tools/claude-cli-tools.d.ts +7 -0
- package/ccw/dist/tools/claude-cli-tools.d.ts.map +1 -1
- package/ccw/dist/tools/claude-cli-tools.js +11 -1
- package/ccw/dist/tools/claude-cli-tools.js.map +1 -1
- package/ccw/dist/tools/cli-executor-core.d.ts +11 -0
- package/ccw/dist/tools/cli-executor-core.d.ts.map +1 -1
- package/ccw/dist/tools/cli-executor-core.js +89 -2
- package/ccw/dist/tools/cli-executor-core.js.map +1 -1
- package/ccw/dist/tools/codex-lens.d.ts +2 -1
- package/ccw/dist/tools/codex-lens.d.ts.map +1 -1
- package/ccw/dist/tools/codex-lens.js +51 -8
- package/ccw/dist/tools/codex-lens.js.map +1 -1
- package/ccw/dist/tools/index.d.ts.map +1 -1
- package/ccw/dist/tools/index.js +2 -0
- package/ccw/dist/tools/index.js.map +1 -1
- package/ccw/dist/tools/litellm-client.d.ts +6 -0
- package/ccw/dist/tools/litellm-client.d.ts.map +1 -1
- package/ccw/dist/tools/litellm-client.js +22 -1
- package/ccw/dist/tools/litellm-client.js.map +1 -1
- package/ccw/dist/tools/litellm-executor.js +2 -2
- package/ccw/dist/tools/litellm-executor.js.map +1 -1
- package/ccw/dist/tools/memory-update-queue.d.ts +172 -0
- package/ccw/dist/tools/memory-update-queue.d.ts.map +1 -0
- package/ccw/dist/tools/memory-update-queue.js +431 -0
- package/ccw/dist/tools/memory-update-queue.js.map +1 -0
- package/ccw/src/core/routes/help-routes.ts +46 -7
- package/ccw/src/core/routes/litellm-api-routes.ts +35 -4
- package/ccw/src/core/routes/memory-routes.ts +84 -0
- package/ccw/src/core/routes/status-routes.ts +39 -4
- package/ccw/src/core/server.ts +62 -0
- package/ccw/src/core/services/api-key-tester.ts +9 -3
- package/ccw/src/templates/dashboard-css/21-cli-toolmgmt.css +45 -0
- package/ccw/src/templates/dashboard-js/components/cli-status.js +36 -5
- package/ccw/src/templates/dashboard-js/components/hook-manager.js +42 -81
- package/ccw/src/templates/dashboard-js/components/mcp-manager.js +170 -28
- package/ccw/src/templates/dashboard-js/components/notifications.js +14 -4
- package/ccw/src/templates/dashboard-js/i18n.js +26 -0
- package/ccw/src/templates/dashboard-js/views/cli-manager.js +72 -2
- package/ccw/src/templates/dashboard-js/views/codexlens-manager.js +11 -1
- package/ccw/src/tools/claude-cli-tools.ts +17 -1
- package/ccw/src/tools/cli-executor-core.ts +103 -2
- package/ccw/src/tools/codex-lens.ts +63 -8
- package/ccw/src/tools/index.ts +2 -0
- package/ccw/src/tools/litellm-client.ts +25 -3
- package/ccw/src/tools/litellm-executor.ts +2 -2
- package/ccw/src/tools/memory-update-queue.js +499 -0
- package/package.json +1 -1
|
@@ -0,0 +1,764 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: issue:discover-by-prompt
|
|
3
|
+
description: Discover issues from user prompt with Gemini-planned iterative multi-agent exploration. Uses ACE semantic search for context gathering and supports cross-module comparison (e.g., frontend vs backend API contracts).
|
|
4
|
+
argument-hint: "<prompt> [--scope=src/**] [--depth=standard|deep] [--max-iterations=5]"
|
|
5
|
+
allowed-tools: SlashCommand(*), TodoWrite(*), Read(*), Bash(*), Task(*), AskUserQuestion(*), Glob(*), Grep(*), mcp__ace-tool__search_context(*), mcp__exa__search(*)
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
# Issue Discovery by Prompt
|
|
9
|
+
|
|
10
|
+
## Quick Start
|
|
11
|
+
|
|
12
|
+
```bash
|
|
13
|
+
# Discover issues based on user description
|
|
14
|
+
/issue:discover-by-prompt "Check if frontend API calls match backend implementations"
|
|
15
|
+
|
|
16
|
+
# Compare specific modules
|
|
17
|
+
/issue:discover-by-prompt "Verify auth flow consistency between mobile and web clients" --scope=src/auth/**,src/mobile/**
|
|
18
|
+
|
|
19
|
+
# Deep exploration with more iterations
|
|
20
|
+
/issue:discover-by-prompt "Find all places where error handling is inconsistent" --depth=deep --max-iterations=8
|
|
21
|
+
|
|
22
|
+
# Focused backend-frontend contract check
|
|
23
|
+
/issue:discover-by-prompt "Compare REST API definitions with frontend fetch calls"
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
**Core Difference from `/issue:discover`**:
|
|
27
|
+
- `discover`: Pre-defined perspectives (bug, security, etc.), parallel execution
|
|
28
|
+
- `discover-by-prompt`: User-driven prompt, Gemini-planned strategy, iterative exploration
|
|
29
|
+
|
|
30
|
+
## What & Why
|
|
31
|
+
|
|
32
|
+
### Core Concept
|
|
33
|
+
|
|
34
|
+
Prompt-driven issue discovery with intelligent planning. Instead of fixed perspectives, this command:
|
|
35
|
+
|
|
36
|
+
1. **Analyzes user intent** via Gemini to understand what to find
|
|
37
|
+
2. **Plans exploration strategy** dynamically based on codebase structure
|
|
38
|
+
3. **Executes iterative multi-agent exploration** with feedback loops
|
|
39
|
+
4. **Performs cross-module comparison** when detecting comparison intent
|
|
40
|
+
|
|
41
|
+
### Value Proposition
|
|
42
|
+
|
|
43
|
+
1. **Natural Language Input**: Describe what you want to find, not how to find it
|
|
44
|
+
2. **Intelligent Planning**: Gemini designs optimal exploration strategy
|
|
45
|
+
3. **Iterative Refinement**: Each round builds on previous discoveries
|
|
46
|
+
4. **Cross-Module Analysis**: Compare frontend/backend, mobile/web, old/new implementations
|
|
47
|
+
5. **Adaptive Exploration**: Adjusts direction based on findings
|
|
48
|
+
|
|
49
|
+
### Use Cases
|
|
50
|
+
|
|
51
|
+
| Scenario | Example Prompt |
|
|
52
|
+
|----------|----------------|
|
|
53
|
+
| API Contract | "Check if frontend calls match backend endpoints" |
|
|
54
|
+
| Error Handling | "Find inconsistent error handling patterns" |
|
|
55
|
+
| Migration Gap | "Compare old auth with new auth implementation" |
|
|
56
|
+
| Feature Parity | "Verify mobile has all web features" |
|
|
57
|
+
| Schema Drift | "Check if TypeScript types match API responses" |
|
|
58
|
+
| Integration | "Find mismatches between service A and service B" |
|
|
59
|
+
|
|
60
|
+
## How It Works
|
|
61
|
+
|
|
62
|
+
### Execution Flow
|
|
63
|
+
|
|
64
|
+
```
|
|
65
|
+
Phase 1: Prompt Analysis & Initialization
|
|
66
|
+
├─ Parse user prompt and flags
|
|
67
|
+
├─ Detect exploration intent (comparison/search/verification)
|
|
68
|
+
└─ Initialize discovery session
|
|
69
|
+
|
|
70
|
+
Phase 1.5: ACE Context Gathering
|
|
71
|
+
├─ Use ACE semantic search to understand codebase structure
|
|
72
|
+
├─ Identify relevant modules based on prompt keywords
|
|
73
|
+
├─ Collect architecture context for Gemini planning
|
|
74
|
+
└─ Build initial context package
|
|
75
|
+
|
|
76
|
+
Phase 2: Gemini Strategy Planning
|
|
77
|
+
├─ Feed ACE context + prompt to Gemini CLI
|
|
78
|
+
├─ Gemini analyzes and generates exploration strategy
|
|
79
|
+
├─ Create exploration dimensions with search targets
|
|
80
|
+
├─ Define comparison matrix (if comparison intent)
|
|
81
|
+
└─ Set success criteria and iteration limits
|
|
82
|
+
|
|
83
|
+
Phase 3: Iterative Agent Exploration (with ACE)
|
|
84
|
+
├─ Iteration 1: Initial exploration by assigned agents
|
|
85
|
+
│ ├─ Agent A: ACE search + explore dimension 1
|
|
86
|
+
│ ├─ Agent B: ACE search + explore dimension 2
|
|
87
|
+
│ └─ Collect findings, update shared context
|
|
88
|
+
├─ Iteration 2-N: Refined exploration
|
|
89
|
+
│ ├─ Analyze previous findings
|
|
90
|
+
│ ├─ ACE search for related code paths
|
|
91
|
+
│ ├─ Execute targeted exploration
|
|
92
|
+
│ └─ Update cumulative findings
|
|
93
|
+
└─ Termination: Max iterations or convergence
|
|
94
|
+
|
|
95
|
+
Phase 4: Cross-Analysis & Synthesis
|
|
96
|
+
├─ Compare findings across dimensions
|
|
97
|
+
├─ Identify discrepancies and issues
|
|
98
|
+
├─ Calculate confidence scores
|
|
99
|
+
└─ Generate issue candidates
|
|
100
|
+
|
|
101
|
+
Phase 5: Issue Generation & Summary
|
|
102
|
+
├─ Convert findings to issue format
|
|
103
|
+
├─ Write discovery outputs
|
|
104
|
+
└─ Prompt user for next action
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
### Exploration Dimensions
|
|
108
|
+
|
|
109
|
+
Dimensions are **dynamically generated by Gemini** based on the user prompt. Not limited to predefined categories.
|
|
110
|
+
|
|
111
|
+
**Examples**:
|
|
112
|
+
|
|
113
|
+
| Prompt | Generated Dimensions |
|
|
114
|
+
|--------|---------------------|
|
|
115
|
+
| "Check API contracts" | frontend-calls, backend-handlers |
|
|
116
|
+
| "Find auth issues" | auth-module (single dimension) |
|
|
117
|
+
| "Compare old/new implementations" | legacy-code, new-code |
|
|
118
|
+
| "Audit payment flow" | payment-service, validation, logging |
|
|
119
|
+
| "Find error handling gaps" | error-handlers, error-types, recovery-logic |
|
|
120
|
+
|
|
121
|
+
Gemini analyzes the prompt + ACE context to determine:
|
|
122
|
+
- How many dimensions are needed (1 to N)
|
|
123
|
+
- What each dimension should focus on
|
|
124
|
+
- Whether comparison is needed between dimensions
|
|
125
|
+
|
|
126
|
+
### Iteration Strategy
|
|
127
|
+
|
|
128
|
+
```
|
|
129
|
+
┌─────────────────────────────────────────────────────────────┐
|
|
130
|
+
│ Iteration Loop │
|
|
131
|
+
├─────────────────────────────────────────────────────────────┤
|
|
132
|
+
│ 1. Plan: What to explore this iteration │
|
|
133
|
+
│ └─ Based on: previous findings + unexplored areas │
|
|
134
|
+
│ │
|
|
135
|
+
│ 2. Execute: Launch agents for this iteration │
|
|
136
|
+
│ └─ Each agent: explore → collect → return summary │
|
|
137
|
+
│ │
|
|
138
|
+
│ 3. Analyze: Process iteration results │
|
|
139
|
+
│ └─ New findings? Gaps? Contradictions? │
|
|
140
|
+
│ │
|
|
141
|
+
│ 4. Decide: Continue or terminate │
|
|
142
|
+
│ └─ Terminate if: max iterations OR convergence OR │
|
|
143
|
+
│ high confidence on all questions │
|
|
144
|
+
└─────────────────────────────────────────────────────────────┘
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
## Core Responsibilities
|
|
148
|
+
|
|
149
|
+
### Phase 1: Prompt Analysis & Initialization
|
|
150
|
+
|
|
151
|
+
```javascript
|
|
152
|
+
// Step 1: Parse arguments
|
|
153
|
+
const { prompt, scope, depth, maxIterations } = parseArgs(args);
|
|
154
|
+
|
|
155
|
+
// Step 2: Generate discovery ID
|
|
156
|
+
const discoveryId = `DBP-${formatDate(new Date(), 'YYYYMMDD-HHmmss')}`;
|
|
157
|
+
|
|
158
|
+
// Step 3: Create output directory
|
|
159
|
+
const outputDir = `.workflow/issues/discoveries/${discoveryId}`;
|
|
160
|
+
await mkdir(outputDir, { recursive: true });
|
|
161
|
+
await mkdir(`${outputDir}/iterations`, { recursive: true });
|
|
162
|
+
|
|
163
|
+
// Step 4: Detect intent type from prompt
|
|
164
|
+
const intentType = detectIntent(prompt);
|
|
165
|
+
// Returns: 'comparison' | 'search' | 'verification' | 'audit'
|
|
166
|
+
|
|
167
|
+
// Step 5: Initialize discovery state
|
|
168
|
+
await writeJson(`${outputDir}/discovery-state.json`, {
|
|
169
|
+
discovery_id: discoveryId,
|
|
170
|
+
type: 'prompt-driven',
|
|
171
|
+
prompt: prompt,
|
|
172
|
+
intent_type: intentType,
|
|
173
|
+
scope: scope || '**/*',
|
|
174
|
+
depth: depth || 'standard',
|
|
175
|
+
max_iterations: maxIterations || 5,
|
|
176
|
+
phase: 'initialization',
|
|
177
|
+
created_at: new Date().toISOString(),
|
|
178
|
+
iterations: [],
|
|
179
|
+
cumulative_findings: [],
|
|
180
|
+
comparison_matrix: null // filled for comparison intent
|
|
181
|
+
});
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
### Phase 1.5: ACE Context Gathering
|
|
185
|
+
|
|
186
|
+
**Purpose**: Use ACE semantic search to gather codebase context before Gemini planning.
|
|
187
|
+
|
|
188
|
+
```javascript
|
|
189
|
+
// Step 1: Extract keywords from prompt for semantic search
|
|
190
|
+
const keywords = extractKeywords(prompt);
|
|
191
|
+
// e.g., "frontend API calls match backend" → ["frontend", "API", "backend", "endpoints"]
|
|
192
|
+
|
|
193
|
+
// Step 2: Use ACE to understand codebase structure
|
|
194
|
+
const aceQueries = [
|
|
195
|
+
`Project architecture and module structure for ${keywords.join(', ')}`,
|
|
196
|
+
`Where are ${keywords[0]} implementations located?`,
|
|
197
|
+
`How does ${keywords.slice(0, 2).join(' ')} work in this codebase?`
|
|
198
|
+
];
|
|
199
|
+
|
|
200
|
+
const aceResults = [];
|
|
201
|
+
for (const query of aceQueries) {
|
|
202
|
+
const result = await mcp__ace-tool__search_context({
|
|
203
|
+
project_root_path: process.cwd(),
|
|
204
|
+
query: query
|
|
205
|
+
});
|
|
206
|
+
aceResults.push({ query, result });
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
// Step 3: Build context package for Gemini (kept in memory)
|
|
210
|
+
const aceContext = {
|
|
211
|
+
prompt_keywords: keywords,
|
|
212
|
+
codebase_structure: aceResults[0].result,
|
|
213
|
+
relevant_modules: aceResults.slice(1).map(r => r.result),
|
|
214
|
+
detected_patterns: extractPatterns(aceResults)
|
|
215
|
+
};
|
|
216
|
+
|
|
217
|
+
// Step 4: Update state (no separate file)
|
|
218
|
+
await updateDiscoveryState(outputDir, {
|
|
219
|
+
phase: 'context-gathered',
|
|
220
|
+
ace_context: {
|
|
221
|
+
queries_executed: aceQueries.length,
|
|
222
|
+
modules_identified: aceContext.relevant_modules.length
|
|
223
|
+
}
|
|
224
|
+
});
|
|
225
|
+
|
|
226
|
+
// aceContext passed to Phase 2 in memory
|
|
227
|
+
```
|
|
228
|
+
|
|
229
|
+
**ACE Query Strategy by Intent Type**:
|
|
230
|
+
|
|
231
|
+
| Intent | ACE Queries |
|
|
232
|
+
|--------|-------------|
|
|
233
|
+
| **comparison** | "frontend API calls", "backend API handlers", "API contract definitions" |
|
|
234
|
+
| **search** | "{keyword} implementations", "{keyword} usage patterns" |
|
|
235
|
+
| **verification** | "expected behavior for {feature}", "test coverage for {feature}" |
|
|
236
|
+
| **audit** | "all {category} patterns", "{category} security concerns" |
|
|
237
|
+
|
|
238
|
+
### Phase 2: Gemini Strategy Planning
|
|
239
|
+
|
|
240
|
+
**Purpose**: Gemini analyzes user prompt + ACE context to design optimal exploration strategy.
|
|
241
|
+
|
|
242
|
+
```javascript
|
|
243
|
+
// Step 1: Load ACE context gathered in Phase 1.5
|
|
244
|
+
const aceContext = await readJson(`${outputDir}/ace-context.json`);
|
|
245
|
+
|
|
246
|
+
// Step 2: Build Gemini planning prompt with ACE context
|
|
247
|
+
const planningPrompt = `
|
|
248
|
+
PURPOSE: Analyze discovery prompt and create exploration strategy based on codebase context
|
|
249
|
+
TASK:
|
|
250
|
+
• Parse user intent from prompt: "${prompt}"
|
|
251
|
+
• Use codebase context to identify specific modules and files to explore
|
|
252
|
+
• Create exploration dimensions with precise search targets
|
|
253
|
+
• Define comparison matrix structure (if comparison intent)
|
|
254
|
+
• Set success criteria and iteration strategy
|
|
255
|
+
MODE: analysis
|
|
256
|
+
CONTEXT: @${scope || '**/*'} | Discovery type: ${intentType}
|
|
257
|
+
|
|
258
|
+
## Codebase Context (from ACE semantic search)
|
|
259
|
+
${JSON.stringify(aceContext, null, 2)}
|
|
260
|
+
|
|
261
|
+
EXPECTED: JSON exploration plan following exploration-plan-schema.json:
|
|
262
|
+
{
|
|
263
|
+
"intent_analysis": { "type": "${intentType}", "primary_question": "...", "sub_questions": [...] },
|
|
264
|
+
"dimensions": [{ "name": "...", "description": "...", "search_targets": [...], "focus_areas": [...], "agent_prompt": "..." }],
|
|
265
|
+
"comparison_matrix": { "dimension_a": "...", "dimension_b": "...", "comparison_points": [...] },
|
|
266
|
+
"success_criteria": [...],
|
|
267
|
+
"estimated_iterations": N,
|
|
268
|
+
"termination_conditions": [...]
|
|
269
|
+
}
|
|
270
|
+
RULES: $(cat ~/.claude/workflows/cli-templates/protocols/analysis-protocol.md) | Use ACE context to inform targets | Focus on actionable plan
|
|
271
|
+
`;
|
|
272
|
+
|
|
273
|
+
// Step 3: Execute Gemini planning
|
|
274
|
+
Bash({
|
|
275
|
+
command: `ccw cli -p "${planningPrompt}" --tool gemini --mode analysis`,
|
|
276
|
+
run_in_background: true,
|
|
277
|
+
timeout: 300000
|
|
278
|
+
});
|
|
279
|
+
|
|
280
|
+
// Step 4: Parse Gemini output and validate against schema
|
|
281
|
+
const explorationPlan = await parseGeminiPlanOutput(geminiResult);
|
|
282
|
+
validateAgainstSchema(explorationPlan, 'exploration-plan-schema.json');
|
|
283
|
+
|
|
284
|
+
// Step 5: Enhance plan with ACE-discovered file paths
|
|
285
|
+
explorationPlan.dimensions = explorationPlan.dimensions.map(dim => ({
|
|
286
|
+
...dim,
|
|
287
|
+
ace_suggested_files: aceContext.relevant_modules
|
|
288
|
+
.filter(m => m.relevance_to === dim.name)
|
|
289
|
+
.map(m => m.file_path)
|
|
290
|
+
}));
|
|
291
|
+
|
|
292
|
+
// Step 6: Update state (plan kept in memory, not persisted)
|
|
293
|
+
await updateDiscoveryState(outputDir, {
|
|
294
|
+
phase: 'planned',
|
|
295
|
+
exploration_plan: {
|
|
296
|
+
dimensions_count: explorationPlan.dimensions.length,
|
|
297
|
+
has_comparison_matrix: !!explorationPlan.comparison_matrix,
|
|
298
|
+
estimated_iterations: explorationPlan.estimated_iterations
|
|
299
|
+
}
|
|
300
|
+
});
|
|
301
|
+
|
|
302
|
+
// explorationPlan passed to Phase 3 in memory
|
|
303
|
+
```
|
|
304
|
+
|
|
305
|
+
**Gemini Planning Responsibilities**:
|
|
306
|
+
|
|
307
|
+
| Responsibility | Input | Output |
|
|
308
|
+
|----------------|-------|--------|
|
|
309
|
+
| Intent Analysis | User prompt | type, primary_question, sub_questions |
|
|
310
|
+
| Dimension Design | ACE context + prompt | dimensions with search_targets |
|
|
311
|
+
| Comparison Matrix | Intent type + modules | comparison_points (if applicable) |
|
|
312
|
+
| Iteration Strategy | Depth setting | estimated_iterations, termination_conditions |
|
|
313
|
+
|
|
314
|
+
**Gemini Planning Output Schema**:
|
|
315
|
+
|
|
316
|
+
```json
|
|
317
|
+
{
|
|
318
|
+
"intent_analysis": {
|
|
319
|
+
"type": "comparison|search|verification|audit",
|
|
320
|
+
"primary_question": "string",
|
|
321
|
+
"sub_questions": ["string"]
|
|
322
|
+
},
|
|
323
|
+
"dimensions": [
|
|
324
|
+
{
|
|
325
|
+
"name": "frontend",
|
|
326
|
+
"description": "Client-side API calls and error handling",
|
|
327
|
+
"search_targets": ["src/api/**", "src/hooks/**"],
|
|
328
|
+
"focus_areas": ["fetch calls", "error boundaries", "response parsing"],
|
|
329
|
+
"agent_prompt": "Explore frontend API consumption patterns..."
|
|
330
|
+
},
|
|
331
|
+
{
|
|
332
|
+
"name": "backend",
|
|
333
|
+
"description": "Server-side API implementations",
|
|
334
|
+
"search_targets": ["src/server/**", "src/routes/**"],
|
|
335
|
+
"focus_areas": ["endpoint handlers", "response schemas", "error responses"],
|
|
336
|
+
"agent_prompt": "Explore backend API implementations..."
|
|
337
|
+
}
|
|
338
|
+
],
|
|
339
|
+
"comparison_matrix": {
|
|
340
|
+
"dimension_a": "frontend",
|
|
341
|
+
"dimension_b": "backend",
|
|
342
|
+
"comparison_points": [
|
|
343
|
+
{"aspect": "endpoints", "frontend_check": "fetch URLs", "backend_check": "route paths"},
|
|
344
|
+
{"aspect": "methods", "frontend_check": "HTTP methods used", "backend_check": "methods accepted"},
|
|
345
|
+
{"aspect": "payloads", "frontend_check": "request body structure", "backend_check": "expected schema"},
|
|
346
|
+
{"aspect": "responses", "frontend_check": "response parsing", "backend_check": "response format"},
|
|
347
|
+
{"aspect": "errors", "frontend_check": "error handling", "backend_check": "error responses"}
|
|
348
|
+
]
|
|
349
|
+
},
|
|
350
|
+
"success_criteria": [
|
|
351
|
+
"All API endpoints mapped between frontend and backend",
|
|
352
|
+
"Discrepancies identified with file:line references",
|
|
353
|
+
"Each finding includes remediation suggestion"
|
|
354
|
+
],
|
|
355
|
+
"estimated_iterations": 3,
|
|
356
|
+
"termination_conditions": [
|
|
357
|
+
"All comparison points verified",
|
|
358
|
+
"No new findings in last iteration",
|
|
359
|
+
"Confidence > 0.8 on primary question"
|
|
360
|
+
]
|
|
361
|
+
}
|
|
362
|
+
```
|
|
363
|
+
|
|
364
|
+
### Phase 3: Iterative Agent Exploration (with ACE)
|
|
365
|
+
|
|
366
|
+
**Purpose**: Multi-agent iterative exploration using ACE for semantic search within each iteration.
|
|
367
|
+
|
|
368
|
+
```javascript
|
|
369
|
+
let iteration = 0;
|
|
370
|
+
let cumulativeFindings = [];
|
|
371
|
+
let sharedContext = { aceDiscoveries: [], crossReferences: [] };
|
|
372
|
+
let shouldContinue = true;
|
|
373
|
+
|
|
374
|
+
while (shouldContinue && iteration < maxIterations) {
|
|
375
|
+
iteration++;
|
|
376
|
+
const iterationDir = `${outputDir}/iterations/${iteration}`;
|
|
377
|
+
await mkdir(iterationDir, { recursive: true });
|
|
378
|
+
|
|
379
|
+
// Step 1: ACE-assisted iteration planning
|
|
380
|
+
// Use previous findings to guide ACE queries for this iteration
|
|
381
|
+
const iterationAceQueries = iteration === 1
|
|
382
|
+
? explorationPlan.dimensions.map(d => d.focus_areas[0]) // Initial queries from plan
|
|
383
|
+
: deriveQueriesFromFindings(cumulativeFindings); // Follow-up queries from findings
|
|
384
|
+
|
|
385
|
+
// Execute ACE searches to find related code
|
|
386
|
+
const iterationAceResults = [];
|
|
387
|
+
for (const query of iterationAceQueries) {
|
|
388
|
+
const result = await mcp__ace-tool__search_context({
|
|
389
|
+
project_root_path: process.cwd(),
|
|
390
|
+
query: `${query} in ${explorationPlan.scope}`
|
|
391
|
+
});
|
|
392
|
+
iterationAceResults.push({ query, result });
|
|
393
|
+
}
|
|
394
|
+
|
|
395
|
+
// Update shared context with ACE discoveries
|
|
396
|
+
sharedContext.aceDiscoveries.push(...iterationAceResults);
|
|
397
|
+
|
|
398
|
+
// Step 2: Plan this iteration based on ACE results
|
|
399
|
+
const iterationPlan = planIteration(iteration, explorationPlan, cumulativeFindings, iterationAceResults);
|
|
400
|
+
|
|
401
|
+
// Step 3: Launch dimension agents with ACE context
|
|
402
|
+
const agentPromises = iterationPlan.dimensions.map(dimension =>
|
|
403
|
+
Task({
|
|
404
|
+
subagent_type: "cli-explore-agent",
|
|
405
|
+
run_in_background: false,
|
|
406
|
+
description: `Explore ${dimension.name} (iteration ${iteration})`,
|
|
407
|
+
prompt: buildDimensionPromptWithACE(dimension, iteration, cumulativeFindings, iterationAceResults, iterationDir)
|
|
408
|
+
})
|
|
409
|
+
);
|
|
410
|
+
|
|
411
|
+
// Wait for iteration agents
|
|
412
|
+
const iterationResults = await Promise.all(agentPromises);
|
|
413
|
+
|
|
414
|
+
// Step 4: Collect and analyze iteration findings
|
|
415
|
+
const iterationFindings = await collectIterationFindings(iterationDir, iterationPlan.dimensions);
|
|
416
|
+
|
|
417
|
+
// Step 5: Cross-reference findings between dimensions
|
|
418
|
+
if (iterationPlan.dimensions.length > 1) {
|
|
419
|
+
const crossRefs = findCrossReferences(iterationFindings, iterationPlan.dimensions);
|
|
420
|
+
sharedContext.crossReferences.push(...crossRefs);
|
|
421
|
+
}
|
|
422
|
+
|
|
423
|
+
cumulativeFindings.push(...iterationFindings);
|
|
424
|
+
|
|
425
|
+
// Step 6: Decide whether to continue
|
|
426
|
+
const convergenceCheck = checkConvergence(iterationFindings, cumulativeFindings, explorationPlan);
|
|
427
|
+
shouldContinue = !convergenceCheck.converged;
|
|
428
|
+
|
|
429
|
+
// Step 7: Update state (iteration summary embedded in state)
|
|
430
|
+
await updateDiscoveryState(outputDir, {
|
|
431
|
+
iterations: [...state.iterations, {
|
|
432
|
+
number: iteration,
|
|
433
|
+
findings_count: iterationFindings.length,
|
|
434
|
+
ace_queries: iterationAceQueries.length,
|
|
435
|
+
cross_references: sharedContext.crossReferences.length,
|
|
436
|
+
new_discoveries: convergenceCheck.newDiscoveries,
|
|
437
|
+
confidence: convergenceCheck.confidence,
|
|
438
|
+
continued: shouldContinue
|
|
439
|
+
}],
|
|
440
|
+
cumulative_findings: cumulativeFindings
|
|
441
|
+
});
|
|
442
|
+
}
|
|
443
|
+
```
|
|
444
|
+
|
|
445
|
+
**ACE in Iteration Loop**:
|
|
446
|
+
|
|
447
|
+
```
|
|
448
|
+
Iteration N
|
|
449
|
+
│
|
|
450
|
+
├─→ ACE Search (based on previous findings)
|
|
451
|
+
│ └─ Query: "related code paths for {finding.category}"
|
|
452
|
+
│ └─ Result: Additional files to explore
|
|
453
|
+
│
|
|
454
|
+
├─→ Agent Exploration (with ACE context)
|
|
455
|
+
│ └─ Agent receives: dimension targets + ACE suggestions
|
|
456
|
+
│ └─ Agent can call ACE for deeper search
|
|
457
|
+
│
|
|
458
|
+
├─→ Cross-Reference Analysis
|
|
459
|
+
│ └─ Compare findings between dimensions
|
|
460
|
+
│ └─ Identify discrepancies
|
|
461
|
+
│
|
|
462
|
+
└─→ Convergence Check
|
|
463
|
+
└─ New findings? Continue
|
|
464
|
+
└─ No new findings? Terminate
|
|
465
|
+
```
|
|
466
|
+
|
|
467
|
+
**Dimension Agent Prompt Template (with ACE)**:
|
|
468
|
+
|
|
469
|
+
```javascript
|
|
470
|
+
function buildDimensionPromptWithACE(dimension, iteration, previousFindings, aceResults, outputDir) {
|
|
471
|
+
// Filter ACE results relevant to this dimension
|
|
472
|
+
const relevantAceResults = aceResults.filter(r =>
|
|
473
|
+
r.query.includes(dimension.name) || dimension.focus_areas.some(fa => r.query.includes(fa))
|
|
474
|
+
);
|
|
475
|
+
|
|
476
|
+
return `
|
|
477
|
+
## Task Objective
|
|
478
|
+
Explore ${dimension.name} dimension for issue discovery (Iteration ${iteration})
|
|
479
|
+
|
|
480
|
+
## Context
|
|
481
|
+
- Dimension: ${dimension.name}
|
|
482
|
+
- Description: ${dimension.description}
|
|
483
|
+
- Search Targets: ${dimension.search_targets.join(', ')}
|
|
484
|
+
- Focus Areas: ${dimension.focus_areas.join(', ')}
|
|
485
|
+
|
|
486
|
+
## ACE Semantic Search Results (Pre-gathered)
|
|
487
|
+
The following files/code sections were identified by ACE as relevant to this dimension:
|
|
488
|
+
${JSON.stringify(relevantAceResults.map(r => ({ query: r.query, files: r.result.slice(0, 5) })), null, 2)}
|
|
489
|
+
|
|
490
|
+
**Use ACE for deeper exploration**: You have access to mcp__ace-tool__search_context.
|
|
491
|
+
When you find something interesting, use ACE to find related code:
|
|
492
|
+
- mcp__ace-tool__search_context({ project_root_path: ".", query: "related to {finding}" })
|
|
493
|
+
|
|
494
|
+
${iteration > 1 ? `
|
|
495
|
+
## Previous Findings to Build Upon
|
|
496
|
+
${summarizePreviousFindings(previousFindings, dimension.name)}
|
|
497
|
+
|
|
498
|
+
## This Iteration Focus
|
|
499
|
+
- Explore areas not yet covered (check ACE results for new files)
|
|
500
|
+
- Verify/deepen previous findings
|
|
501
|
+
- Follow leads from previous discoveries
|
|
502
|
+
- Use ACE to find cross-references between dimensions
|
|
503
|
+
` : ''}
|
|
504
|
+
|
|
505
|
+
## MANDATORY FIRST STEPS
|
|
506
|
+
1. Read exploration plan: ${outputDir}/../exploration-plan.json
|
|
507
|
+
2. Read schema: ~/.claude/workflows/cli-templates/schemas/discovery-finding-schema.json
|
|
508
|
+
3. Review ACE results above for starting points
|
|
509
|
+
4. Explore files identified by ACE
|
|
510
|
+
|
|
511
|
+
## Exploration Instructions
|
|
512
|
+
${dimension.agent_prompt}
|
|
513
|
+
|
|
514
|
+
## ACE Usage Guidelines
|
|
515
|
+
- Use ACE when you need to find:
|
|
516
|
+
- Where a function/class is used
|
|
517
|
+
- Related implementations in other modules
|
|
518
|
+
- Cross-module dependencies
|
|
519
|
+
- Similar patterns elsewhere in codebase
|
|
520
|
+
- Query format: Natural language, be specific
|
|
521
|
+
- Example: "Where is UserService.authenticate called from?"
|
|
522
|
+
|
|
523
|
+
## Output Requirements
|
|
524
|
+
|
|
525
|
+
**1. Write JSON file**: ${outputDir}/${dimension.name}.json
|
|
526
|
+
Follow discovery-finding-schema.json:
|
|
527
|
+
- findings: [{id, title, category, description, file, line, snippet, confidence, related_dimension}]
|
|
528
|
+
- coverage: {files_explored, areas_covered, areas_remaining}
|
|
529
|
+
- leads: [{description, suggested_search}] // for next iteration
|
|
530
|
+
- ace_queries_used: [{query, result_count}] // track ACE usage
|
|
531
|
+
|
|
532
|
+
**2. Return summary**:
|
|
533
|
+
- Total findings this iteration
|
|
534
|
+
- Key discoveries
|
|
535
|
+
- ACE queries that revealed important code
|
|
536
|
+
- Recommended next exploration areas
|
|
537
|
+
|
|
538
|
+
## Success Criteria
|
|
539
|
+
- [ ] JSON written to ${outputDir}/${dimension.name}.json
|
|
540
|
+
- [ ] Each finding has file:line reference
|
|
541
|
+
- [ ] ACE used for cross-references where applicable
|
|
542
|
+
- [ ] Coverage report included
|
|
543
|
+
- [ ] Leads for next iteration identified
|
|
544
|
+
`;
|
|
545
|
+
}
|
|
546
|
+
```
|
|
547
|
+
|
|
548
|
+
### Phase 4: Cross-Analysis & Synthesis
|
|
549
|
+
|
|
550
|
+
```javascript
|
|
551
|
+
// For comparison intent, perform cross-analysis
|
|
552
|
+
if (intentType === 'comparison' && explorationPlan.comparison_matrix) {
|
|
553
|
+
const comparisonResults = [];
|
|
554
|
+
|
|
555
|
+
for (const point of explorationPlan.comparison_matrix.comparison_points) {
|
|
556
|
+
const dimensionAFindings = cumulativeFindings.filter(f =>
|
|
557
|
+
f.related_dimension === explorationPlan.comparison_matrix.dimension_a &&
|
|
558
|
+
f.category.includes(point.aspect)
|
|
559
|
+
);
|
|
560
|
+
|
|
561
|
+
const dimensionBFindings = cumulativeFindings.filter(f =>
|
|
562
|
+
f.related_dimension === explorationPlan.comparison_matrix.dimension_b &&
|
|
563
|
+
f.category.includes(point.aspect)
|
|
564
|
+
);
|
|
565
|
+
|
|
566
|
+
// Compare and find discrepancies
|
|
567
|
+
const discrepancies = findDiscrepancies(dimensionAFindings, dimensionBFindings, point);
|
|
568
|
+
|
|
569
|
+
comparisonResults.push({
|
|
570
|
+
aspect: point.aspect,
|
|
571
|
+
dimension_a_count: dimensionAFindings.length,
|
|
572
|
+
dimension_b_count: dimensionBFindings.length,
|
|
573
|
+
discrepancies: discrepancies,
|
|
574
|
+
match_rate: calculateMatchRate(dimensionAFindings, dimensionBFindings)
|
|
575
|
+
});
|
|
576
|
+
}
|
|
577
|
+
|
|
578
|
+
// Write comparison analysis
|
|
579
|
+
await writeJson(`${outputDir}/comparison-analysis.json`, {
|
|
580
|
+
matrix: explorationPlan.comparison_matrix,
|
|
581
|
+
results: comparisonResults,
|
|
582
|
+
summary: {
|
|
583
|
+
total_discrepancies: comparisonResults.reduce((sum, r) => sum + r.discrepancies.length, 0),
|
|
584
|
+
overall_match_rate: average(comparisonResults.map(r => r.match_rate)),
|
|
585
|
+
critical_mismatches: comparisonResults.filter(r => r.match_rate < 0.5)
|
|
586
|
+
}
|
|
587
|
+
});
|
|
588
|
+
}
|
|
589
|
+
|
|
590
|
+
// Prioritize all findings
|
|
591
|
+
const prioritizedFindings = prioritizeFindings(cumulativeFindings, explorationPlan);
|
|
592
|
+
```
|
|
593
|
+
|
|
594
|
+
### Phase 5: Issue Generation & Summary
|
|
595
|
+
|
|
596
|
+
```javascript
|
|
597
|
+
// Convert high-confidence findings to issues
|
|
598
|
+
const issueWorthy = prioritizedFindings.filter(f =>
|
|
599
|
+
f.confidence >= 0.7 || f.priority === 'critical' || f.priority === 'high'
|
|
600
|
+
);
|
|
601
|
+
|
|
602
|
+
const issues = issueWorthy.map(finding => ({
|
|
603
|
+
id: `ISS-${discoveryId}-${finding.id}`,
|
|
604
|
+
title: finding.title,
|
|
605
|
+
description: finding.description,
|
|
606
|
+
source: {
|
|
607
|
+
discovery_id: discoveryId,
|
|
608
|
+
finding_id: finding.id,
|
|
609
|
+
dimension: finding.related_dimension
|
|
610
|
+
},
|
|
611
|
+
file: finding.file,
|
|
612
|
+
line: finding.line,
|
|
613
|
+
priority: finding.priority,
|
|
614
|
+
category: finding.category,
|
|
615
|
+
suggested_fix: finding.suggested_fix,
|
|
616
|
+
confidence: finding.confidence,
|
|
617
|
+
status: 'discovered',
|
|
618
|
+
created_at: new Date().toISOString()
|
|
619
|
+
}));
|
|
620
|
+
|
|
621
|
+
// Write issues
|
|
622
|
+
await writeJsonl(`${outputDir}/discovery-issues.jsonl`, issues);
|
|
623
|
+
|
|
624
|
+
// Update final state (summary embedded in state, no separate file)
|
|
625
|
+
await updateDiscoveryState(outputDir, {
|
|
626
|
+
phase: 'complete',
|
|
627
|
+
updated_at: new Date().toISOString(),
|
|
628
|
+
results: {
|
|
629
|
+
total_iterations: iteration,
|
|
630
|
+
total_findings: cumulativeFindings.length,
|
|
631
|
+
issues_generated: issues.length,
|
|
632
|
+
comparison_match_rate: comparisonResults
|
|
633
|
+
? average(comparisonResults.map(r => r.match_rate))
|
|
634
|
+
: null
|
|
635
|
+
}
|
|
636
|
+
});
|
|
637
|
+
|
|
638
|
+
// Prompt user for next action
|
|
639
|
+
await AskUserQuestion({
|
|
640
|
+
questions: [{
|
|
641
|
+
question: `Discovery complete: ${issues.length} issues from ${cumulativeFindings.length} findings across ${iteration} iterations. What next?`,
|
|
642
|
+
header: "Next Step",
|
|
643
|
+
multiSelect: false,
|
|
644
|
+
options: [
|
|
645
|
+
{ label: "Export to Issues (Recommended)", description: `Export ${issues.length} issues for planning` },
|
|
646
|
+
{ label: "Review Details", description: "View comparison analysis and iteration details" },
|
|
647
|
+
{ label: "Run Deeper", description: "Continue with more iterations" },
|
|
648
|
+
{ label: "Skip", description: "Complete without exporting" }
|
|
649
|
+
]
|
|
650
|
+
}]
|
|
651
|
+
});
|
|
652
|
+
```
|
|
653
|
+
|
|
654
|
+
## Output File Structure
|
|
655
|
+
|
|
656
|
+
```
|
|
657
|
+
.workflow/issues/discoveries/
|
|
658
|
+
└── {DBP-YYYYMMDD-HHmmss}/
|
|
659
|
+
├── discovery-state.json # Session state with iteration tracking
|
|
660
|
+
├── iterations/
|
|
661
|
+
│ ├── 1/
|
|
662
|
+
│ │ └── {dimension}.json # Dimension findings
|
|
663
|
+
│ ├── 2/
|
|
664
|
+
│ │ └── {dimension}.json
|
|
665
|
+
│ └── ...
|
|
666
|
+
├── comparison-analysis.json # Cross-dimension comparison (if applicable)
|
|
667
|
+
└── discovery-issues.jsonl # Generated issue candidates
|
|
668
|
+
```
|
|
669
|
+
|
|
670
|
+
**Simplified Design**:
|
|
671
|
+
- ACE context and Gemini plan kept in memory, not persisted
|
|
672
|
+
- Iteration summaries embedded in state
|
|
673
|
+
- No separate summary.md (state.json contains all needed info)
|
|
674
|
+
|
|
675
|
+
## Schema References
|
|
676
|
+
|
|
677
|
+
| Schema | Path | Used By |
|
|
678
|
+
|--------|------|---------|
|
|
679
|
+
| **Discovery State** | `discovery-state-schema.json` | Orchestrator (state tracking) |
|
|
680
|
+
| **Discovery Finding** | `discovery-finding-schema.json` | Dimension agents (output) |
|
|
681
|
+
| **Exploration Plan** | `exploration-plan-schema.json` | Gemini output validation (memory only) |
|
|
682
|
+
|
|
683
|
+
## Configuration Options
|
|
684
|
+
|
|
685
|
+
| Flag | Default | Description |
|
|
686
|
+
|------|---------|-------------|
|
|
687
|
+
| `--scope` | `**/*` | File pattern to explore |
|
|
688
|
+
| `--depth` | `standard` | `standard` (3 iterations) or `deep` (5+ iterations) |
|
|
689
|
+
| `--max-iterations` | 5 | Maximum exploration iterations |
|
|
690
|
+
| `--tool` | `gemini` | Planning tool (gemini/qwen) |
|
|
691
|
+
| `--plan-only` | `false` | Stop after Phase 2 (Gemini planning), show plan for user review |
|
|
692
|
+
|
|
693
|
+
## Examples
|
|
694
|
+
|
|
695
|
+
### Example 1: Single Module Deep Dive
|
|
696
|
+
|
|
697
|
+
```bash
|
|
698
|
+
/issue:discover-by-prompt "Find all potential issues in the auth module" --scope=src/auth/**
|
|
699
|
+
```
|
|
700
|
+
|
|
701
|
+
**Gemini plans** (single dimension):
|
|
702
|
+
- Dimension: auth-module
|
|
703
|
+
- Focus: security vulnerabilities, edge cases, error handling, test gaps
|
|
704
|
+
|
|
705
|
+
**Iterations**: 2-3 (until no new findings)
|
|
706
|
+
|
|
707
|
+
### Example 2: API Contract Comparison
|
|
708
|
+
|
|
709
|
+
```bash
|
|
710
|
+
/issue:discover-by-prompt "Check if API calls match implementations" --scope=src/**
|
|
711
|
+
```
|
|
712
|
+
|
|
713
|
+
**Gemini plans** (comparison):
|
|
714
|
+
- Dimension 1: api-consumers (fetch calls, hooks, services)
|
|
715
|
+
- Dimension 2: api-providers (handlers, routes, controllers)
|
|
716
|
+
- Comparison matrix: endpoints, methods, payloads, responses
|
|
717
|
+
|
|
718
|
+
### Example 3: Multi-Module Audit
|
|
719
|
+
|
|
720
|
+
```bash
|
|
721
|
+
/issue:discover-by-prompt "Audit the payment flow for issues" --scope=src/payment/**
|
|
722
|
+
```
|
|
723
|
+
|
|
724
|
+
**Gemini plans** (multi-dimension):
|
|
725
|
+
- Dimension 1: payment-logic (calculations, state transitions)
|
|
726
|
+
- Dimension 2: validation (input checks, business rules)
|
|
727
|
+
- Dimension 3: error-handling (failure modes, recovery)
|
|
728
|
+
|
|
729
|
+
### Example 4: Plan Only Mode
|
|
730
|
+
|
|
731
|
+
```bash
|
|
732
|
+
/issue:discover-by-prompt "Find inconsistent patterns" --plan-only
|
|
733
|
+
```
|
|
734
|
+
|
|
735
|
+
Stops after Gemini planning, outputs:
|
|
736
|
+
```
|
|
737
|
+
Gemini Plan:
|
|
738
|
+
- Intent: search
|
|
739
|
+
- Dimensions: 2 (pattern-definitions, pattern-usages)
|
|
740
|
+
- Estimated iterations: 3
|
|
741
|
+
|
|
742
|
+
Continue with exploration? [Y/n]
|
|
743
|
+
```
|
|
744
|
+
|
|
745
|
+
## Related Commands
|
|
746
|
+
|
|
747
|
+
```bash
|
|
748
|
+
# After discovery, plan solutions
|
|
749
|
+
/issue:plan DBP-001-01,DBP-001-02
|
|
750
|
+
|
|
751
|
+
# View all discoveries
|
|
752
|
+
/issue:manage
|
|
753
|
+
|
|
754
|
+
# Standard perspective-based discovery
|
|
755
|
+
/issue:discover src/auth/** --perspectives=security,bug
|
|
756
|
+
```
|
|
757
|
+
|
|
758
|
+
## Best Practices
|
|
759
|
+
|
|
760
|
+
1. **Be Specific in Prompts**: More specific prompts lead to better Gemini planning
|
|
761
|
+
2. **Scope Appropriately**: Narrow scope for focused comparison, wider for audits
|
|
762
|
+
3. **Review Exploration Plan**: Check `exploration-plan.json` before long explorations
|
|
763
|
+
4. **Use Standard Depth First**: Start with standard, go deep only if needed
|
|
764
|
+
5. **Combine with `/issue:discover`**: Use prompt-based for comparisons, perspective-based for audits
|