claude-code-workflow 6.0.5 → 6.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude/agents/action-planning-agent.md +1 -1
- package/.claude/agents/cli-execution-agent.md +269 -269
- package/.claude/agents/cli-explore-agent.md +182 -182
- package/.claude/agents/context-search-agent.md +582 -582
- package/.claude/agents/memory-bridge.md +93 -93
- package/.claude/commands/cli/cli-init.md +1 -1
- package/.claude/commands/memory/docs-full-cli.md +471 -471
- package/.claude/commands/memory/docs-related-cli.md +386 -386
- package/.claude/commands/memory/docs.md +615 -615
- package/.claude/commands/memory/load.md +1 -1
- package/.claude/commands/memory/update-full.md +332 -332
- package/.claude/commands/memory/update-related.md +5 -5
- package/.claude/commands/workflow/init.md +1 -1
- package/.claude/commands/workflow/lite-fix.md +621 -621
- package/.claude/commands/workflow/lite-plan.md +592 -592
- package/.claude/commands/workflow/tools/context-gather.md +434 -434
- package/.claude/commands/workflow/ui-design/generate.md +504 -504
- package/.claude/commands/workflow/ui-design/import-from-code.md +537 -537
- package/.claude/scripts/classify-folders.sh +4 -0
- package/.claude/scripts/convert_tokens_to_css.sh +4 -0
- package/.claude/scripts/detect_changed_modules.sh +5 -1
- package/.claude/scripts/discover-design-files.sh +87 -83
- package/.claude/scripts/generate_module_docs.sh +717 -713
- package/.claude/scripts/get_modules_by_depth.sh +5 -1
- package/.claude/scripts/ui-generate-preview.sh +4 -0
- package/.claude/scripts/ui-instantiate-prototypes.sh +4 -0
- package/.claude/scripts/update_module_claude.sh +4 -0
- package/.claude/skills/command-guide/index/all-commands.json +1 -12
- package/.claude/skills/command-guide/index/by-category.json +1 -12
- package/.claude/skills/command-guide/index/by-use-case.json +1 -12
- package/.claude/skills/command-guide/index/essential-commands.json +1 -12
- package/.claude/skills/command-guide/reference/agents/action-planning-agent.md +127 -71
- package/.claude/skills/command-guide/reference/agents/cli-execution-agent.md +269 -269
- package/.claude/skills/command-guide/reference/agents/cli-explore-agent.md +182 -182
- package/.claude/skills/command-guide/reference/agents/conceptual-planning-agent.md +18 -38
- package/.claude/skills/command-guide/reference/agents/context-search-agent.md +582 -577
- package/.claude/skills/command-guide/reference/agents/memory-bridge.md +93 -93
- package/.claude/skills/command-guide/reference/commands/cli/cli-init.md +1 -1
- package/.claude/skills/command-guide/reference/commands/memory/docs-full-cli.md +471 -471
- package/.claude/skills/command-guide/reference/commands/memory/docs-related-cli.md +386 -386
- package/.claude/skills/command-guide/reference/commands/memory/docs.md +615 -610
- package/.claude/skills/command-guide/reference/commands/memory/load.md +1 -1
- package/.claude/skills/command-guide/reference/commands/memory/update-full.md +332 -332
- package/.claude/skills/command-guide/reference/commands/memory/update-related.md +5 -5
- package/.claude/skills/command-guide/reference/commands/workflow/brainstorm/artifacts.md +299 -451
- package/.claude/skills/command-guide/reference/commands/workflow/brainstorm/auto-parallel.md +14 -37
- package/.claude/skills/command-guide/reference/commands/workflow/brainstorm/synthesis.md +252 -350
- package/.claude/skills/command-guide/reference/commands/workflow/init.md +2 -2
- package/.claude/skills/command-guide/reference/commands/workflow/lite-execute.md +52 -0
- package/.claude/skills/command-guide/reference/commands/workflow/lite-fix.md +621 -602
- package/.claude/skills/command-guide/reference/commands/workflow/lite-plan.md +46 -36
- package/.claude/skills/command-guide/reference/commands/workflow/review-fix.md +18 -58
- package/.claude/skills/command-guide/reference/commands/workflow/review-module-cycle.md +22 -52
- package/.claude/skills/command-guide/reference/commands/workflow/review-session-cycle.md +19 -48
- package/.claude/skills/command-guide/reference/commands/workflow/session/start.md +25 -5
- package/.claude/skills/command-guide/reference/commands/workflow/tdd-plan.md +1 -1
- package/.claude/skills/command-guide/reference/commands/workflow/test-fix-gen.md +7 -7
- package/.claude/skills/command-guide/reference/commands/workflow/tools/context-gather.md +434 -434
- package/.claude/skills/command-guide/reference/commands/workflow/tools/task-generate-agent.md +151 -11
- package/.claude/skills/command-guide/reference/commands/workflow/tools/task-generate-tdd.md +4 -4
- package/.claude/skills/command-guide/reference/commands/workflow/tools/test-task-generate.md +1 -1
- package/.claude/skills/command-guide/reference/commands/workflow/ui-design/generate.md +504 -504
- package/.claude/skills/command-guide/reference/commands/workflow/ui-design/import-from-code.md +537 -537
- package/.claude/workflows/context-search-strategy.md +77 -77
- package/.claude/workflows/tool-strategy.md +90 -71
- package/.claude/workflows/workflow-architecture.md +1 -1
- package/ccw/src/cli.js +7 -0
- package/ccw/src/commands/tool.js +181 -0
- package/ccw/src/core/dashboard-generator.js +18 -3
- package/ccw/src/core/lite-scanner.js +35 -11
- package/ccw/src/core/server.js +531 -46
- package/ccw/src/templates/dashboard-css/01-base.css +161 -0
- package/ccw/src/templates/dashboard-css/02-session.css +726 -0
- package/ccw/src/templates/dashboard-css/03-tasks.css +512 -0
- package/ccw/src/templates/dashboard-css/04-lite-tasks.css +843 -0
- package/ccw/src/templates/dashboard-css/05-context.css +2206 -0
- package/ccw/src/templates/dashboard-css/06-cards.css +1570 -0
- package/ccw/src/templates/dashboard-css/07-managers.css +936 -0
- package/ccw/src/templates/dashboard-css/08-review.css +1266 -0
- package/ccw/src/templates/dashboard-css/09-explorer.css +1397 -0
- package/ccw/src/templates/dashboard-js/components/global-notifications.js +219 -0
- package/ccw/src/templates/dashboard-js/components/hook-manager.js +10 -0
- package/ccw/src/templates/dashboard-js/components/mcp-manager.js +11 -1
- package/ccw/src/templates/dashboard-js/components/navigation.js +11 -5
- package/ccw/src/templates/dashboard-js/components/tabs-context.js +20 -20
- package/ccw/src/templates/dashboard-js/components/tabs-other.js +11 -11
- package/ccw/src/templates/dashboard-js/components/theme.js +29 -1
- package/ccw/src/templates/dashboard-js/main.js +4 -0
- package/ccw/src/templates/dashboard-js/state.js +5 -0
- package/ccw/src/templates/dashboard-js/views/explorer.js +852 -0
- package/ccw/src/templates/dashboard-js/views/home.js +13 -9
- package/ccw/src/templates/dashboard-js/views/hook-manager.js +8 -5
- package/ccw/src/templates/dashboard-js/views/lite-tasks.js +21 -16
- package/ccw/src/templates/dashboard-js/views/mcp-manager.js +90 -19
- package/ccw/src/templates/dashboard-js/views/project-overview.js +15 -11
- package/ccw/src/templates/dashboard-js/views/review-session.js +3 -3
- package/ccw/src/templates/dashboard-js/views/session-detail.js +38 -28
- package/ccw/src/templates/dashboard.html +129 -28
- package/ccw/src/tools/classify-folders.js +204 -0
- package/ccw/src/tools/convert-tokens-to-css.js +250 -0
- package/ccw/src/tools/detect-changed-modules.js +288 -0
- package/ccw/src/tools/discover-design-files.js +134 -0
- package/ccw/src/tools/edit-file.js +266 -0
- package/ccw/src/tools/generate-module-docs.js +416 -0
- package/ccw/src/tools/get-modules-by-depth.js +308 -0
- package/ccw/src/tools/index.js +176 -0
- package/ccw/src/tools/ui-generate-preview.js +327 -0
- package/ccw/src/tools/ui-instantiate-prototypes.js +301 -0
- package/ccw/src/tools/update-module-claude.js +380 -0
- package/package.json +1 -1
- package/.claude/skills/command-guide/reference/commands/workflow/status.md +0 -352
- package/ccw/src/core/server.js.bak +0 -385
- package/ccw/src/core/server_original.bak +0 -385
- package/ccw/src/templates/dashboard.css +0 -8187
- package/ccw/src/templates/dashboard_tailwind.html +0 -42
- package/ccw/src/templates/dashboard_test.html +0 -37
- package/ccw/src/templates/tailwind-base.css +0 -212
|
@@ -1,602 +1,621 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: lite-fix
|
|
3
|
-
description: Lightweight bug diagnosis and fix workflow with intelligent severity assessment and optional hotfix mode for production incidents
|
|
4
|
-
argument-hint: "[--hotfix] \"bug description or issue reference\""
|
|
5
|
-
allowed-tools: TodoWrite(*), Task(*), SlashCommand(*), AskUserQuestion(*)
|
|
6
|
-
---
|
|
7
|
-
|
|
8
|
-
# Workflow Lite-Fix Command (/workflow:lite-fix)
|
|
9
|
-
|
|
10
|
-
## Overview
|
|
11
|
-
|
|
12
|
-
Intelligent lightweight bug fixing command with dynamic workflow adaptation based on severity assessment. Focuses on diagnosis phases (root cause analysis, impact assessment, fix planning, confirmation) and delegates execution to `/workflow:lite-execute`.
|
|
13
|
-
|
|
14
|
-
**Core capabilities:**
|
|
15
|
-
- Intelligent bug analysis with automatic severity detection
|
|
16
|
-
- Dynamic code diagnosis (cli-explore-agent) for root cause identification
|
|
17
|
-
- Interactive clarification after diagnosis to gather missing information
|
|
18
|
-
- Adaptive fix planning strategy (direct Claude vs cli-lite-planning-agent) based on complexity
|
|
19
|
-
- Two-step confirmation: fix-plan display -> multi-dimensional input collection
|
|
20
|
-
- Execution dispatch with complete context handoff to lite-execute
|
|
21
|
-
|
|
22
|
-
## Usage
|
|
23
|
-
|
|
24
|
-
```bash
|
|
25
|
-
/workflow:lite-fix [FLAGS] <BUG_DESCRIPTION>
|
|
26
|
-
|
|
27
|
-
# Flags
|
|
28
|
-
--hotfix, -h Production hotfix mode (minimal diagnosis, fast fix)
|
|
29
|
-
|
|
30
|
-
# Arguments
|
|
31
|
-
<bug-description> Bug description, error message, or path to .md file (required)
|
|
32
|
-
```
|
|
33
|
-
|
|
34
|
-
## Execution Process
|
|
35
|
-
|
|
36
|
-
```
|
|
37
|
-
Phase 1: Bug Analysis & Diagnosis
|
|
38
|
-
|- Parse input (description, error message, or .md file)
|
|
39
|
-
|- Intelligent severity pre-assessment (Low/Medium/High/Critical)
|
|
40
|
-
|- Diagnosis decision (auto-detect or --hotfix flag)
|
|
41
|
-
|- Context protection: If file reading >=50k chars -> force cli-explore-agent
|
|
42
|
-
+- Decision:
|
|
43
|
-
|- needsDiagnosis=true -> Launch parallel cli-explore-agents (1-4 based on severity)
|
|
44
|
-
+- needsDiagnosis=false (hotfix) -> Skip directly to Phase 3 (Fix Planning)
|
|
45
|
-
|
|
46
|
-
Phase 2: Clarification (optional)
|
|
47
|
-
|- Aggregate clarification_needs from all diagnosis angles
|
|
48
|
-
|- Deduplicate similar questions
|
|
49
|
-
+- Decision:
|
|
50
|
-
|- Has clarifications -> AskUserQuestion (max 4 questions)
|
|
51
|
-
+- No clarifications -> Skip to Phase 3
|
|
52
|
-
|
|
53
|
-
Phase 3: Fix Planning (NO CODE EXECUTION - planning only)
|
|
54
|
-
+- Decision (based on Phase 1 severity):
|
|
55
|
-
|- Low/Medium -> Load schema: cat ~/.claude/workflows/cli-templates/schemas/fix-plan-json-schema.json -> Direct Claude planning (following schema) -> fix-plan.json -> MUST proceed to Phase 4
|
|
56
|
-
+- High/Critical -> cli-lite-planning-agent -> fix-plan.json -> MUST proceed to Phase 4
|
|
57
|
-
|
|
58
|
-
Phase 4: Confirmation & Selection
|
|
59
|
-
|- Display fix-plan summary (tasks, severity, estimated time)
|
|
60
|
-
+- AskUserQuestion:
|
|
61
|
-
|- Confirm: Allow / Modify / Cancel
|
|
62
|
-
|- Execution: Agent / Codex / Auto
|
|
63
|
-
+- Review: Gemini / Agent / Skip
|
|
64
|
-
|
|
65
|
-
Phase 5: Dispatch
|
|
66
|
-
|- Build executionContext (fix-plan + diagnoses + clarifications + selections)
|
|
67
|
-
+- SlashCommand("/workflow:lite-execute --in-memory --mode bugfix")
|
|
68
|
-
```
|
|
69
|
-
|
|
70
|
-
## Implementation
|
|
71
|
-
|
|
72
|
-
### Phase 1: Intelligent Multi-Angle Diagnosis
|
|
73
|
-
|
|
74
|
-
**Session Setup
|
|
75
|
-
```javascript
|
|
76
|
-
// Helper: Get UTC+8 (China Standard Time) ISO string
|
|
77
|
-
const getUtc8ISOString = () => new Date(Date.now() + 8 * 60 * 60 * 1000).toISOString()
|
|
78
|
-
|
|
79
|
-
const bugSlug = bug_description.toLowerCase().replace(/[^a-z0-9]+/g, '-').substring(0, 40)
|
|
80
|
-
const
|
|
81
|
-
|
|
82
|
-
const sessionId = `${bugSlug}-${
|
|
83
|
-
const sessionFolder = `.workflow/.lite-fix/${sessionId}`
|
|
84
|
-
|
|
85
|
-
bash(`mkdir -p ${sessionFolder}`)
|
|
86
|
-
```
|
|
87
|
-
|
|
88
|
-
**Diagnosis Decision Logic**:
|
|
89
|
-
```javascript
|
|
90
|
-
const hotfixMode = $ARGUMENTS.includes('--hotfix') || $ARGUMENTS.includes('-h')
|
|
91
|
-
|
|
92
|
-
needsDiagnosis = (
|
|
93
|
-
!hotfixMode &&
|
|
94
|
-
(
|
|
95
|
-
bug.lacks_specific_error_message ||
|
|
96
|
-
bug.requires_codebase_context ||
|
|
97
|
-
bug.needs_execution_tracing ||
|
|
98
|
-
bug.root_cause_unclear
|
|
99
|
-
)
|
|
100
|
-
)
|
|
101
|
-
|
|
102
|
-
if (!needsDiagnosis) {
|
|
103
|
-
// Skip to Phase 2 (Clarification) or Phase 3 (Fix Planning)
|
|
104
|
-
proceed_to_next_phase()
|
|
105
|
-
}
|
|
106
|
-
```
|
|
107
|
-
|
|
108
|
-
**Context Protection**: File reading >=50k chars -> force `needsDiagnosis=true` (delegate to cli-explore-agent)
|
|
109
|
-
|
|
110
|
-
**Severity Pre-Assessment** (Intelligent Analysis):
|
|
111
|
-
```javascript
|
|
112
|
-
// Analyzes bug severity based on:
|
|
113
|
-
// - Symptoms: Error messages, crash reports, user complaints
|
|
114
|
-
// - Scope: How many users/features are affected?
|
|
115
|
-
// - Urgency: Production down vs minor inconvenience
|
|
116
|
-
// - Impact: Data loss, security, business impact
|
|
117
|
-
|
|
118
|
-
const severity = analyzeBugSeverity(bug_description)
|
|
119
|
-
// Returns: 'Low' | 'Medium' | 'High' | 'Critical'
|
|
120
|
-
// Low: Minor UI issue, localized, no data impact
|
|
121
|
-
// Medium: Multiple users affected, degraded functionality
|
|
122
|
-
// High: Significant functionality broken, many users affected
|
|
123
|
-
// Critical: Production down, data loss risk, security issue
|
|
124
|
-
|
|
125
|
-
// Angle assignment based on bug type (orchestrator decides, not agent)
|
|
126
|
-
const DIAGNOSIS_ANGLE_PRESETS = {
|
|
127
|
-
runtime_error: ['error-handling', 'dataflow', 'state-management', 'edge-cases'],
|
|
128
|
-
performance: ['performance', 'bottlenecks', 'caching', 'data-access'],
|
|
129
|
-
security: ['security', 'auth-patterns', 'dataflow', 'validation'],
|
|
130
|
-
data_corruption: ['data-integrity', 'state-management', 'transactions', 'validation'],
|
|
131
|
-
ui_bug: ['state-management', 'event-handling', 'rendering', 'data-binding'],
|
|
132
|
-
integration: ['api-contracts', 'error-handling', 'timeouts', 'fallbacks']
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
function selectDiagnosisAngles(bugDescription, count) {
|
|
136
|
-
const text = bugDescription.toLowerCase()
|
|
137
|
-
let preset = 'runtime_error' // default
|
|
138
|
-
|
|
139
|
-
if (/slow|timeout|performance|lag|hang/.test(text)) preset = 'performance'
|
|
140
|
-
else if (/security|auth|permission|access|token/.test(text)) preset = 'security'
|
|
141
|
-
else if (/corrupt|data|lost|missing|inconsistent/.test(text)) preset = 'data_corruption'
|
|
142
|
-
else if (/ui|display|render|style|click|button/.test(text)) preset = 'ui_bug'
|
|
143
|
-
else if (/api|integration|connect|request|response/.test(text)) preset = 'integration'
|
|
144
|
-
|
|
145
|
-
return DIAGNOSIS_ANGLE_PRESETS[preset].slice(0, count)
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
const selectedAngles = selectDiagnosisAngles(bug_description, severity === 'Critical' ? 4 : (severity === 'High' ? 3 : (severity === 'Medium' ? 2 : 1)))
|
|
149
|
-
|
|
150
|
-
console.log(`
|
|
151
|
-
## Diagnosis Plan
|
|
152
|
-
|
|
153
|
-
Bug Severity: ${severity}
|
|
154
|
-
Selected Angles: ${selectedAngles.join(', ')}
|
|
155
|
-
|
|
156
|
-
Launching ${selectedAngles.length} parallel diagnoses...
|
|
157
|
-
`)
|
|
158
|
-
```
|
|
159
|
-
|
|
160
|
-
**Launch Parallel Diagnoses** - Orchestrator assigns angle to each agent:
|
|
161
|
-
|
|
162
|
-
```javascript
|
|
163
|
-
// Launch agents with pre-assigned diagnosis angles
|
|
164
|
-
const diagnosisTasks = selectedAngles.map((angle, index) =>
|
|
165
|
-
Task(
|
|
166
|
-
subagent_type="cli-explore-agent",
|
|
167
|
-
description=`Diagnose: ${angle}`,
|
|
168
|
-
prompt=`
|
|
169
|
-
## Task Objective
|
|
170
|
-
Execute **${angle}** diagnosis for bug root cause analysis. Analyze codebase from this specific angle to discover root cause, affected paths, and fix hints.
|
|
171
|
-
|
|
172
|
-
## Assigned Context
|
|
173
|
-
- **Diagnosis Angle**: ${angle}
|
|
174
|
-
- **Bug Description**: ${bug_description}
|
|
175
|
-
- **Diagnosis Index**: ${index + 1} of ${selectedAngles.length}
|
|
176
|
-
- **Output File**: ${sessionFolder}/diagnosis-${angle}.json
|
|
177
|
-
|
|
178
|
-
## MANDATORY FIRST STEPS (Execute by Agent)
|
|
179
|
-
**You (cli-explore-agent) MUST execute these steps in order:**
|
|
180
|
-
1. Run:
|
|
181
|
-
2. Run: rg -l "{error_keyword_from_bug}" --type ts (locate relevant files)
|
|
182
|
-
3. Execute: cat ~/.claude/workflows/cli-templates/schemas/diagnosis-json-schema.json (get output schema reference)
|
|
183
|
-
|
|
184
|
-
## Diagnosis Strategy (${angle} focus)
|
|
185
|
-
|
|
186
|
-
**Step 1: Error Tracing** (Bash)
|
|
187
|
-
- rg for error messages, stack traces, log patterns
|
|
188
|
-
- git log --since='2 weeks ago' for recent changes
|
|
189
|
-
- Trace execution path in affected modules
|
|
190
|
-
|
|
191
|
-
**Step 2: Root Cause Analysis** (Gemini CLI)
|
|
192
|
-
- What code paths lead to this ${angle} issue?
|
|
193
|
-
- What edge cases are not handled from ${angle} perspective?
|
|
194
|
-
- What recent changes might have introduced this bug?
|
|
195
|
-
|
|
196
|
-
**Step 3: Write Output**
|
|
197
|
-
- Consolidate ${angle} findings into JSON
|
|
198
|
-
- Identify ${angle}-specific clarification needs
|
|
199
|
-
- Provide fix hints based on ${angle} analysis
|
|
200
|
-
|
|
201
|
-
## Expected Output
|
|
202
|
-
|
|
203
|
-
**File**: ${sessionFolder}/diagnosis-${angle}.json
|
|
204
|
-
|
|
205
|
-
**Schema Reference**: Schema obtained in MANDATORY FIRST STEPS step 3, follow schema exactly
|
|
206
|
-
|
|
207
|
-
**Required Fields** (all ${angle} focused):
|
|
208
|
-
- symptom: Bug symptoms and error messages
|
|
209
|
-
- root_cause: Root cause hypothesis from ${angle} perspective
|
|
210
|
-
**IMPORTANT**: Use structured format:
|
|
211
|
-
\`{file: "src/module/file.ts", line_range: "45-60", issue: "Description", confidence: 0.85}\`
|
|
212
|
-
- affected_files: Files involved from ${angle} perspective
|
|
213
|
-
**IMPORTANT**: Use object format with relevance scores:
|
|
214
|
-
\`[{path: "src/file.ts", relevance: 0.85, rationale: "Contains ${angle} logic"}]\`
|
|
215
|
-
- reproduction_steps: Steps to reproduce the bug
|
|
216
|
-
- fix_hints: Suggested fix approaches from ${angle} viewpoint
|
|
217
|
-
- dependencies: Dependencies relevant to ${angle} diagnosis
|
|
218
|
-
- constraints: ${angle}-specific limitations affecting fix
|
|
219
|
-
- clarification_needs: ${angle}-related ambiguities (
|
|
220
|
-
- _metadata.diagnosis_angle: "${angle}"
|
|
221
|
-
- _metadata.diagnosis_index: ${index + 1}
|
|
222
|
-
|
|
223
|
-
## Success Criteria
|
|
224
|
-
- [ ] Schema obtained via cat diagnosis-json-schema.json
|
|
225
|
-
- [ ] get_modules_by_depth.sh executed
|
|
226
|
-
- [ ] Root cause identified with confidence score
|
|
227
|
-
- [ ] At least 3 affected files identified with ${angle} rationale
|
|
228
|
-
- [ ] Fix hints are actionable (specific code changes, not generic advice)
|
|
229
|
-
- [ ] Reproduction steps are verifiable
|
|
230
|
-
- [ ] JSON output follows schema exactly
|
|
231
|
-
- [ ] clarification_needs includes options
|
|
232
|
-
|
|
233
|
-
## Output
|
|
234
|
-
Write: ${sessionFolder}/diagnosis-${angle}.json
|
|
235
|
-
Return: 2-3 sentence summary of ${angle} diagnosis findings
|
|
236
|
-
`
|
|
237
|
-
)
|
|
238
|
-
)
|
|
239
|
-
|
|
240
|
-
// Execute all diagnosis tasks in parallel
|
|
241
|
-
```
|
|
242
|
-
|
|
243
|
-
**Auto-discover Generated Diagnosis Files**:
|
|
244
|
-
```javascript
|
|
245
|
-
// After diagnoses complete, auto-discover all diagnosis-*.json files
|
|
246
|
-
const diagnosisFiles = bash(`find ${sessionFolder} -name "diagnosis-*.json" -type f`)
|
|
247
|
-
.split('\n')
|
|
248
|
-
.filter(f => f.trim())
|
|
249
|
-
|
|
250
|
-
// Read metadata to build manifest
|
|
251
|
-
const diagnosisManifest = {
|
|
252
|
-
session_id: sessionId,
|
|
253
|
-
bug_description: bug_description,
|
|
254
|
-
timestamp: getUtc8ISOString(),
|
|
255
|
-
severity: severity,
|
|
256
|
-
diagnosis_count: diagnosisFiles.length,
|
|
257
|
-
diagnoses: diagnosisFiles.map(file => {
|
|
258
|
-
const data = JSON.parse(Read(file))
|
|
259
|
-
const filename = path.basename(file)
|
|
260
|
-
return {
|
|
261
|
-
angle: data._metadata.diagnosis_angle,
|
|
262
|
-
file: filename,
|
|
263
|
-
path: file,
|
|
264
|
-
index: data._metadata.diagnosis_index
|
|
265
|
-
}
|
|
266
|
-
})
|
|
267
|
-
}
|
|
268
|
-
|
|
269
|
-
Write(`${sessionFolder}/diagnoses-manifest.json`, JSON.stringify(diagnosisManifest, null, 2))
|
|
270
|
-
|
|
271
|
-
console.log(`
|
|
272
|
-
## Diagnosis Complete
|
|
273
|
-
|
|
274
|
-
Generated diagnosis files in ${sessionFolder}:
|
|
275
|
-
${diagnosisManifest.diagnoses.map(d => `- diagnosis-${d.angle}.json (angle: ${d.angle})`).join('\n')}
|
|
276
|
-
|
|
277
|
-
Manifest: diagnoses-manifest.json
|
|
278
|
-
Angles diagnosed: ${diagnosisManifest.diagnoses.map(d => d.angle).join(', ')}
|
|
279
|
-
`)
|
|
280
|
-
```
|
|
281
|
-
|
|
282
|
-
**Output**:
|
|
283
|
-
- `${sessionFolder}/diagnosis-{angle1}.json`
|
|
284
|
-
- `${sessionFolder}/diagnosis-{angle2}.json`
|
|
285
|
-
- ... (1-4 files based on severity)
|
|
286
|
-
- `${sessionFolder}/diagnoses-manifest.json`
|
|
287
|
-
|
|
288
|
-
---
|
|
289
|
-
|
|
290
|
-
### Phase 2: Clarification (Optional)
|
|
291
|
-
|
|
292
|
-
**Skip if**: No diagnosis or `clarification_needs` is empty across all diagnoses
|
|
293
|
-
|
|
294
|
-
**
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
})
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
}
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
}
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
// Step
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
**
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
{ label: "
|
|
507
|
-
{ label: "
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
.
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
1
|
+
---
|
|
2
|
+
name: lite-fix
|
|
3
|
+
description: Lightweight bug diagnosis and fix workflow with intelligent severity assessment and optional hotfix mode for production incidents
|
|
4
|
+
argument-hint: "[--hotfix] \"bug description or issue reference\""
|
|
5
|
+
allowed-tools: TodoWrite(*), Task(*), SlashCommand(*), AskUserQuestion(*)
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
# Workflow Lite-Fix Command (/workflow:lite-fix)
|
|
9
|
+
|
|
10
|
+
## Overview
|
|
11
|
+
|
|
12
|
+
Intelligent lightweight bug fixing command with dynamic workflow adaptation based on severity assessment. Focuses on diagnosis phases (root cause analysis, impact assessment, fix planning, confirmation) and delegates execution to `/workflow:lite-execute`.
|
|
13
|
+
|
|
14
|
+
**Core capabilities:**
|
|
15
|
+
- Intelligent bug analysis with automatic severity detection
|
|
16
|
+
- Dynamic code diagnosis (cli-explore-agent) for root cause identification
|
|
17
|
+
- Interactive clarification after diagnosis to gather missing information
|
|
18
|
+
- Adaptive fix planning strategy (direct Claude vs cli-lite-planning-agent) based on complexity
|
|
19
|
+
- Two-step confirmation: fix-plan display -> multi-dimensional input collection
|
|
20
|
+
- Execution dispatch with complete context handoff to lite-execute
|
|
21
|
+
|
|
22
|
+
## Usage
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
/workflow:lite-fix [FLAGS] <BUG_DESCRIPTION>
|
|
26
|
+
|
|
27
|
+
# Flags
|
|
28
|
+
--hotfix, -h Production hotfix mode (minimal diagnosis, fast fix)
|
|
29
|
+
|
|
30
|
+
# Arguments
|
|
31
|
+
<bug-description> Bug description, error message, or path to .md file (required)
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
## Execution Process
|
|
35
|
+
|
|
36
|
+
```
|
|
37
|
+
Phase 1: Bug Analysis & Diagnosis
|
|
38
|
+
|- Parse input (description, error message, or .md file)
|
|
39
|
+
|- Intelligent severity pre-assessment (Low/Medium/High/Critical)
|
|
40
|
+
|- Diagnosis decision (auto-detect or --hotfix flag)
|
|
41
|
+
|- Context protection: If file reading >=50k chars -> force cli-explore-agent
|
|
42
|
+
+- Decision:
|
|
43
|
+
|- needsDiagnosis=true -> Launch parallel cli-explore-agents (1-4 based on severity)
|
|
44
|
+
+- needsDiagnosis=false (hotfix) -> Skip directly to Phase 3 (Fix Planning)
|
|
45
|
+
|
|
46
|
+
Phase 2: Clarification (optional, multi-round)
|
|
47
|
+
|- Aggregate clarification_needs from all diagnosis angles
|
|
48
|
+
|- Deduplicate similar questions
|
|
49
|
+
+- Decision:
|
|
50
|
+
|- Has clarifications -> AskUserQuestion (max 4 questions per round, multiple rounds allowed)
|
|
51
|
+
+- No clarifications -> Skip to Phase 3
|
|
52
|
+
|
|
53
|
+
Phase 3: Fix Planning (NO CODE EXECUTION - planning only)
|
|
54
|
+
+- Decision (based on Phase 1 severity):
|
|
55
|
+
|- Low/Medium -> Load schema: cat ~/.claude/workflows/cli-templates/schemas/fix-plan-json-schema.json -> Direct Claude planning (following schema) -> fix-plan.json -> MUST proceed to Phase 4
|
|
56
|
+
+- High/Critical -> cli-lite-planning-agent -> fix-plan.json -> MUST proceed to Phase 4
|
|
57
|
+
|
|
58
|
+
Phase 4: Confirmation & Selection
|
|
59
|
+
|- Display fix-plan summary (tasks, severity, estimated time)
|
|
60
|
+
+- AskUserQuestion:
|
|
61
|
+
|- Confirm: Allow / Modify / Cancel
|
|
62
|
+
|- Execution: Agent / Codex / Auto
|
|
63
|
+
+- Review: Gemini / Agent / Skip
|
|
64
|
+
|
|
65
|
+
Phase 5: Dispatch
|
|
66
|
+
|- Build executionContext (fix-plan + diagnoses + clarifications + selections)
|
|
67
|
+
+- SlashCommand("/workflow:lite-execute --in-memory --mode bugfix")
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
## Implementation
|
|
71
|
+
|
|
72
|
+
### Phase 1: Intelligent Multi-Angle Diagnosis
|
|
73
|
+
|
|
74
|
+
**Session Setup** (MANDATORY - follow exactly):
|
|
75
|
+
```javascript
|
|
76
|
+
// Helper: Get UTC+8 (China Standard Time) ISO string
|
|
77
|
+
const getUtc8ISOString = () => new Date(Date.now() + 8 * 60 * 60 * 1000).toISOString()
|
|
78
|
+
|
|
79
|
+
const bugSlug = bug_description.toLowerCase().replace(/[^a-z0-9]+/g, '-').substring(0, 40)
|
|
80
|
+
const dateStr = getUtc8ISOString().substring(0, 10) // Format: 2025-11-29
|
|
81
|
+
|
|
82
|
+
const sessionId = `${bugSlug}-${dateStr}` // e.g., "user-avatar-upload-fails-2025-11-29"
|
|
83
|
+
const sessionFolder = `.workflow/.lite-fix/${sessionId}`
|
|
84
|
+
|
|
85
|
+
bash(`mkdir -p ${sessionFolder} && test -d ${sessionFolder} && echo "SUCCESS: ${sessionFolder}" || echo "FAILED: ${sessionFolder}"`)
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
**Diagnosis Decision Logic**:
|
|
89
|
+
```javascript
|
|
90
|
+
const hotfixMode = $ARGUMENTS.includes('--hotfix') || $ARGUMENTS.includes('-h')
|
|
91
|
+
|
|
92
|
+
needsDiagnosis = (
|
|
93
|
+
!hotfixMode &&
|
|
94
|
+
(
|
|
95
|
+
bug.lacks_specific_error_message ||
|
|
96
|
+
bug.requires_codebase_context ||
|
|
97
|
+
bug.needs_execution_tracing ||
|
|
98
|
+
bug.root_cause_unclear
|
|
99
|
+
)
|
|
100
|
+
)
|
|
101
|
+
|
|
102
|
+
if (!needsDiagnosis) {
|
|
103
|
+
// Skip to Phase 2 (Clarification) or Phase 3 (Fix Planning)
|
|
104
|
+
proceed_to_next_phase()
|
|
105
|
+
}
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
**Context Protection**: File reading >=50k chars -> force `needsDiagnosis=true` (delegate to cli-explore-agent)
|
|
109
|
+
|
|
110
|
+
**Severity Pre-Assessment** (Intelligent Analysis):
|
|
111
|
+
```javascript
|
|
112
|
+
// Analyzes bug severity based on:
|
|
113
|
+
// - Symptoms: Error messages, crash reports, user complaints
|
|
114
|
+
// - Scope: How many users/features are affected?
|
|
115
|
+
// - Urgency: Production down vs minor inconvenience
|
|
116
|
+
// - Impact: Data loss, security, business impact
|
|
117
|
+
|
|
118
|
+
const severity = analyzeBugSeverity(bug_description)
|
|
119
|
+
// Returns: 'Low' | 'Medium' | 'High' | 'Critical'
|
|
120
|
+
// Low: Minor UI issue, localized, no data impact
|
|
121
|
+
// Medium: Multiple users affected, degraded functionality
|
|
122
|
+
// High: Significant functionality broken, many users affected
|
|
123
|
+
// Critical: Production down, data loss risk, security issue
|
|
124
|
+
|
|
125
|
+
// Angle assignment based on bug type (orchestrator decides, not agent)
|
|
126
|
+
const DIAGNOSIS_ANGLE_PRESETS = {
|
|
127
|
+
runtime_error: ['error-handling', 'dataflow', 'state-management', 'edge-cases'],
|
|
128
|
+
performance: ['performance', 'bottlenecks', 'caching', 'data-access'],
|
|
129
|
+
security: ['security', 'auth-patterns', 'dataflow', 'validation'],
|
|
130
|
+
data_corruption: ['data-integrity', 'state-management', 'transactions', 'validation'],
|
|
131
|
+
ui_bug: ['state-management', 'event-handling', 'rendering', 'data-binding'],
|
|
132
|
+
integration: ['api-contracts', 'error-handling', 'timeouts', 'fallbacks']
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
function selectDiagnosisAngles(bugDescription, count) {
|
|
136
|
+
const text = bugDescription.toLowerCase()
|
|
137
|
+
let preset = 'runtime_error' // default
|
|
138
|
+
|
|
139
|
+
if (/slow|timeout|performance|lag|hang/.test(text)) preset = 'performance'
|
|
140
|
+
else if (/security|auth|permission|access|token/.test(text)) preset = 'security'
|
|
141
|
+
else if (/corrupt|data|lost|missing|inconsistent/.test(text)) preset = 'data_corruption'
|
|
142
|
+
else if (/ui|display|render|style|click|button/.test(text)) preset = 'ui_bug'
|
|
143
|
+
else if (/api|integration|connect|request|response/.test(text)) preset = 'integration'
|
|
144
|
+
|
|
145
|
+
return DIAGNOSIS_ANGLE_PRESETS[preset].slice(0, count)
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
const selectedAngles = selectDiagnosisAngles(bug_description, severity === 'Critical' ? 4 : (severity === 'High' ? 3 : (severity === 'Medium' ? 2 : 1)))
|
|
149
|
+
|
|
150
|
+
console.log(`
|
|
151
|
+
## Diagnosis Plan
|
|
152
|
+
|
|
153
|
+
Bug Severity: ${severity}
|
|
154
|
+
Selected Angles: ${selectedAngles.join(', ')}
|
|
155
|
+
|
|
156
|
+
Launching ${selectedAngles.length} parallel diagnoses...
|
|
157
|
+
`)
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
**Launch Parallel Diagnoses** - Orchestrator assigns angle to each agent:
|
|
161
|
+
|
|
162
|
+
```javascript
|
|
163
|
+
// Launch agents with pre-assigned diagnosis angles
|
|
164
|
+
const diagnosisTasks = selectedAngles.map((angle, index) =>
|
|
165
|
+
Task(
|
|
166
|
+
subagent_type="cli-explore-agent",
|
|
167
|
+
description=`Diagnose: ${angle}`,
|
|
168
|
+
prompt=`
|
|
169
|
+
## Task Objective
|
|
170
|
+
Execute **${angle}** diagnosis for bug root cause analysis. Analyze codebase from this specific angle to discover root cause, affected paths, and fix hints.
|
|
171
|
+
|
|
172
|
+
## Assigned Context
|
|
173
|
+
- **Diagnosis Angle**: ${angle}
|
|
174
|
+
- **Bug Description**: ${bug_description}
|
|
175
|
+
- **Diagnosis Index**: ${index + 1} of ${selectedAngles.length}
|
|
176
|
+
- **Output File**: ${sessionFolder}/diagnosis-${angle}.json
|
|
177
|
+
|
|
178
|
+
## MANDATORY FIRST STEPS (Execute by Agent)
|
|
179
|
+
**You (cli-explore-agent) MUST execute these steps in order:**
|
|
180
|
+
1. Run: ccw tool exec get_modules_by_depth '{}' (project structure)
|
|
181
|
+
2. Run: rg -l "{error_keyword_from_bug}" --type ts (locate relevant files)
|
|
182
|
+
3. Execute: cat ~/.claude/workflows/cli-templates/schemas/diagnosis-json-schema.json (get output schema reference)
|
|
183
|
+
|
|
184
|
+
## Diagnosis Strategy (${angle} focus)
|
|
185
|
+
|
|
186
|
+
**Step 1: Error Tracing** (Bash)
|
|
187
|
+
- rg for error messages, stack traces, log patterns
|
|
188
|
+
- git log --since='2 weeks ago' for recent changes
|
|
189
|
+
- Trace execution path in affected modules
|
|
190
|
+
|
|
191
|
+
**Step 2: Root Cause Analysis** (Gemini CLI)
|
|
192
|
+
- What code paths lead to this ${angle} issue?
|
|
193
|
+
- What edge cases are not handled from ${angle} perspective?
|
|
194
|
+
- What recent changes might have introduced this bug?
|
|
195
|
+
|
|
196
|
+
**Step 3: Write Output**
|
|
197
|
+
- Consolidate ${angle} findings into JSON
|
|
198
|
+
- Identify ${angle}-specific clarification needs
|
|
199
|
+
- Provide fix hints based on ${angle} analysis
|
|
200
|
+
|
|
201
|
+
## Expected Output
|
|
202
|
+
|
|
203
|
+
**File**: ${sessionFolder}/diagnosis-${angle}.json
|
|
204
|
+
|
|
205
|
+
**Schema Reference**: Schema obtained in MANDATORY FIRST STEPS step 3, follow schema exactly
|
|
206
|
+
|
|
207
|
+
**Required Fields** (all ${angle} focused):
|
|
208
|
+
- symptom: Bug symptoms and error messages
|
|
209
|
+
- root_cause: Root cause hypothesis from ${angle} perspective
|
|
210
|
+
**IMPORTANT**: Use structured format:
|
|
211
|
+
\`{file: "src/module/file.ts", line_range: "45-60", issue: "Description", confidence: 0.85}\`
|
|
212
|
+
- affected_files: Files involved from ${angle} perspective
|
|
213
|
+
**IMPORTANT**: Use object format with relevance scores:
|
|
214
|
+
\`[{path: "src/file.ts", relevance: 0.85, rationale: "Contains ${angle} logic"}]\`
|
|
215
|
+
- reproduction_steps: Steps to reproduce the bug
|
|
216
|
+
- fix_hints: Suggested fix approaches from ${angle} viewpoint
|
|
217
|
+
- dependencies: Dependencies relevant to ${angle} diagnosis
|
|
218
|
+
- constraints: ${angle}-specific limitations affecting fix
|
|
219
|
+
- clarification_needs: ${angle}-related ambiguities (options array + recommended index)
|
|
220
|
+
- _metadata.diagnosis_angle: "${angle}"
|
|
221
|
+
- _metadata.diagnosis_index: ${index + 1}
|
|
222
|
+
|
|
223
|
+
## Success Criteria
|
|
224
|
+
- [ ] Schema obtained via cat diagnosis-json-schema.json
|
|
225
|
+
- [ ] get_modules_by_depth.sh executed
|
|
226
|
+
- [ ] Root cause identified with confidence score
|
|
227
|
+
- [ ] At least 3 affected files identified with ${angle} rationale
|
|
228
|
+
- [ ] Fix hints are actionable (specific code changes, not generic advice)
|
|
229
|
+
- [ ] Reproduction steps are verifiable
|
|
230
|
+
- [ ] JSON output follows schema exactly
|
|
231
|
+
- [ ] clarification_needs includes options + recommended
|
|
232
|
+
|
|
233
|
+
## Output
|
|
234
|
+
Write: ${sessionFolder}/diagnosis-${angle}.json
|
|
235
|
+
Return: 2-3 sentence summary of ${angle} diagnosis findings
|
|
236
|
+
`
|
|
237
|
+
)
|
|
238
|
+
)
|
|
239
|
+
|
|
240
|
+
// Execute all diagnosis tasks in parallel
|
|
241
|
+
```
|
|
242
|
+
|
|
243
|
+
**Auto-discover Generated Diagnosis Files**:
|
|
244
|
+
```javascript
|
|
245
|
+
// After diagnoses complete, auto-discover all diagnosis-*.json files
|
|
246
|
+
const diagnosisFiles = bash(`find ${sessionFolder} -name "diagnosis-*.json" -type f`)
|
|
247
|
+
.split('\n')
|
|
248
|
+
.filter(f => f.trim())
|
|
249
|
+
|
|
250
|
+
// Read metadata to build manifest
|
|
251
|
+
const diagnosisManifest = {
|
|
252
|
+
session_id: sessionId,
|
|
253
|
+
bug_description: bug_description,
|
|
254
|
+
timestamp: getUtc8ISOString(),
|
|
255
|
+
severity: severity,
|
|
256
|
+
diagnosis_count: diagnosisFiles.length,
|
|
257
|
+
diagnoses: diagnosisFiles.map(file => {
|
|
258
|
+
const data = JSON.parse(Read(file))
|
|
259
|
+
const filename = path.basename(file)
|
|
260
|
+
return {
|
|
261
|
+
angle: data._metadata.diagnosis_angle,
|
|
262
|
+
file: filename,
|
|
263
|
+
path: file,
|
|
264
|
+
index: data._metadata.diagnosis_index
|
|
265
|
+
}
|
|
266
|
+
})
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
Write(`${sessionFolder}/diagnoses-manifest.json`, JSON.stringify(diagnosisManifest, null, 2))
|
|
270
|
+
|
|
271
|
+
console.log(`
|
|
272
|
+
## Diagnosis Complete
|
|
273
|
+
|
|
274
|
+
Generated diagnosis files in ${sessionFolder}:
|
|
275
|
+
${diagnosisManifest.diagnoses.map(d => `- diagnosis-${d.angle}.json (angle: ${d.angle})`).join('\n')}
|
|
276
|
+
|
|
277
|
+
Manifest: diagnoses-manifest.json
|
|
278
|
+
Angles diagnosed: ${diagnosisManifest.diagnoses.map(d => d.angle).join(', ')}
|
|
279
|
+
`)
|
|
280
|
+
```
|
|
281
|
+
|
|
282
|
+
**Output**:
|
|
283
|
+
- `${sessionFolder}/diagnosis-{angle1}.json`
|
|
284
|
+
- `${sessionFolder}/diagnosis-{angle2}.json`
|
|
285
|
+
- ... (1-4 files based on severity)
|
|
286
|
+
- `${sessionFolder}/diagnoses-manifest.json`
|
|
287
|
+
|
|
288
|
+
---
|
|
289
|
+
|
|
290
|
+
### Phase 2: Clarification (Optional, Multi-Round)
|
|
291
|
+
|
|
292
|
+
**Skip if**: No diagnosis or `clarification_needs` is empty across all diagnoses
|
|
293
|
+
|
|
294
|
+
**⚠️ CRITICAL**: AskUserQuestion tool limits max 4 questions per call. **MUST execute multiple rounds** to exhaust all clarification needs - do NOT stop at round 1.
|
|
295
|
+
|
|
296
|
+
**Aggregate clarification needs from all diagnosis angles**:
|
|
297
|
+
```javascript
|
|
298
|
+
// Load manifest and all diagnosis files
|
|
299
|
+
const manifest = JSON.parse(Read(`${sessionFolder}/diagnoses-manifest.json`))
|
|
300
|
+
const diagnoses = manifest.diagnoses.map(diag => ({
|
|
301
|
+
angle: diag.angle,
|
|
302
|
+
data: JSON.parse(Read(diag.path))
|
|
303
|
+
}))
|
|
304
|
+
|
|
305
|
+
// Aggregate clarification needs from all diagnoses
|
|
306
|
+
const allClarifications = []
|
|
307
|
+
diagnoses.forEach(diag => {
|
|
308
|
+
if (diag.data.clarification_needs?.length > 0) {
|
|
309
|
+
diag.data.clarification_needs.forEach(need => {
|
|
310
|
+
allClarifications.push({
|
|
311
|
+
...need,
|
|
312
|
+
source_angle: diag.angle
|
|
313
|
+
})
|
|
314
|
+
})
|
|
315
|
+
}
|
|
316
|
+
})
|
|
317
|
+
|
|
318
|
+
// Deduplicate by question similarity
|
|
319
|
+
function deduplicateClarifications(clarifications) {
|
|
320
|
+
const unique = []
|
|
321
|
+
clarifications.forEach(c => {
|
|
322
|
+
const isDuplicate = unique.some(u =>
|
|
323
|
+
u.question.toLowerCase() === c.question.toLowerCase()
|
|
324
|
+
)
|
|
325
|
+
if (!isDuplicate) unique.push(c)
|
|
326
|
+
})
|
|
327
|
+
return unique
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
const uniqueClarifications = deduplicateClarifications(allClarifications)
|
|
331
|
+
|
|
332
|
+
// Multi-round clarification: batch questions (max 4 per round)
|
|
333
|
+
// ⚠️ MUST execute ALL rounds until uniqueClarifications exhausted
|
|
334
|
+
if (uniqueClarifications.length > 0) {
|
|
335
|
+
const BATCH_SIZE = 4
|
|
336
|
+
const totalRounds = Math.ceil(uniqueClarifications.length / BATCH_SIZE)
|
|
337
|
+
|
|
338
|
+
for (let i = 0; i < uniqueClarifications.length; i += BATCH_SIZE) {
|
|
339
|
+
const batch = uniqueClarifications.slice(i, i + BATCH_SIZE)
|
|
340
|
+
const currentRound = Math.floor(i / BATCH_SIZE) + 1
|
|
341
|
+
|
|
342
|
+
console.log(`### Clarification Round ${currentRound}/${totalRounds}`)
|
|
343
|
+
|
|
344
|
+
AskUserQuestion({
|
|
345
|
+
questions: batch.map(need => ({
|
|
346
|
+
question: `[${need.source_angle}] ${need.question}\n\nContext: ${need.context}`,
|
|
347
|
+
header: need.source_angle,
|
|
348
|
+
multiSelect: false,
|
|
349
|
+
options: need.options.map((opt, index) => {
|
|
350
|
+
const isRecommended = need.recommended === index
|
|
351
|
+
return {
|
|
352
|
+
label: isRecommended ? `${opt} ★` : opt,
|
|
353
|
+
description: isRecommended ? `Use ${opt} approach (Recommended)` : `Use ${opt} approach`
|
|
354
|
+
}
|
|
355
|
+
})
|
|
356
|
+
}))
|
|
357
|
+
})
|
|
358
|
+
|
|
359
|
+
// Store batch responses in clarificationContext before next round
|
|
360
|
+
}
|
|
361
|
+
}
|
|
362
|
+
```
|
|
363
|
+
|
|
364
|
+
**Output**: `clarificationContext` (in-memory)
|
|
365
|
+
|
|
366
|
+
---
|
|
367
|
+
|
|
368
|
+
### Phase 3: Fix Planning
|
|
369
|
+
|
|
370
|
+
**Planning Strategy Selection** (based on Phase 1 severity):
|
|
371
|
+
|
|
372
|
+
**IMPORTANT**: Phase 3 is **planning only** - NO code execution. All execution happens in Phase 5 via lite-execute.
|
|
373
|
+
|
|
374
|
+
**Low/Medium Severity** - Direct planning by Claude:
|
|
375
|
+
```javascript
|
|
376
|
+
// Step 1: Read schema
|
|
377
|
+
const schema = Bash(`cat ~/.claude/workflows/cli-templates/schemas/fix-plan-json-schema.json`)
|
|
378
|
+
|
|
379
|
+
// Step 2: Generate fix-plan following schema (Claude directly, no agent)
|
|
380
|
+
const fixPlan = {
|
|
381
|
+
summary: "...",
|
|
382
|
+
root_cause: "...",
|
|
383
|
+
strategy: "immediate_patch|comprehensive_fix|refactor",
|
|
384
|
+
tasks: [...], // Each task: { id, title, scope, ..., depends_on, complexity }
|
|
385
|
+
estimated_time: "...",
|
|
386
|
+
recommended_execution: "Agent",
|
|
387
|
+
severity: severity,
|
|
388
|
+
risk_level: "...",
|
|
389
|
+
_metadata: { timestamp: getUtc8ISOString(), source: "direct-planning", planning_mode: "direct" }
|
|
390
|
+
}
|
|
391
|
+
|
|
392
|
+
// Step 3: Write fix-plan to session folder
|
|
393
|
+
Write(`${sessionFolder}/fix-plan.json`, JSON.stringify(fixPlan, null, 2))
|
|
394
|
+
|
|
395
|
+
// Step 4: MUST continue to Phase 4 (Confirmation) - DO NOT execute code here
|
|
396
|
+
```
|
|
397
|
+
|
|
398
|
+
**High/Critical Severity** - Invoke cli-lite-planning-agent:
|
|
399
|
+
|
|
400
|
+
```javascript
|
|
401
|
+
Task(
|
|
402
|
+
subagent_type="cli-lite-planning-agent",
|
|
403
|
+
description="Generate detailed fix plan",
|
|
404
|
+
prompt=`
|
|
405
|
+
Generate fix plan and write fix-plan.json.
|
|
406
|
+
|
|
407
|
+
## Output Schema Reference
|
|
408
|
+
Execute: cat ~/.claude/workflows/cli-templates/schemas/fix-plan-json-schema.json (get schema reference before generating plan)
|
|
409
|
+
|
|
410
|
+
## Bug Description
|
|
411
|
+
${bug_description}
|
|
412
|
+
|
|
413
|
+
## Multi-Angle Diagnosis Context
|
|
414
|
+
|
|
415
|
+
${manifest.diagnoses.map(diag => `### Diagnosis: ${diag.angle} (${diag.file})
|
|
416
|
+
Path: ${diag.path}
|
|
417
|
+
|
|
418
|
+
Read this file for detailed ${diag.angle} analysis.`).join('\n\n')}
|
|
419
|
+
|
|
420
|
+
Total diagnoses: ${manifest.diagnosis_count}
|
|
421
|
+
Angles covered: ${manifest.diagnoses.map(d => d.angle).join(', ')}
|
|
422
|
+
|
|
423
|
+
Manifest: ${sessionFolder}/diagnoses-manifest.json
|
|
424
|
+
|
|
425
|
+
## User Clarifications
|
|
426
|
+
${JSON.stringify(clarificationContext) || "None"}
|
|
427
|
+
|
|
428
|
+
## Severity Level
|
|
429
|
+
${severity}
|
|
430
|
+
|
|
431
|
+
## Requirements
|
|
432
|
+
Generate fix-plan.json with:
|
|
433
|
+
- summary: 2-3 sentence overview of the fix
|
|
434
|
+
- root_cause: Consolidated root cause from all diagnoses
|
|
435
|
+
- strategy: "immediate_patch" | "comprehensive_fix" | "refactor"
|
|
436
|
+
- tasks: 1-5 structured fix tasks (**IMPORTANT: group by fix area, NOT by file**)
|
|
437
|
+
- **Task Granularity Principle**: Each task = one complete fix unit
|
|
438
|
+
- title: action verb + target (e.g., "Fix token validation edge case")
|
|
439
|
+
- scope: module path (src/auth/) or feature name
|
|
440
|
+
- action: "Fix" | "Update" | "Refactor" | "Add" | "Delete"
|
|
441
|
+
- description
|
|
442
|
+
- modification_points: ALL files to modify for this fix (group related changes)
|
|
443
|
+
- implementation (2-5 steps covering all modification_points)
|
|
444
|
+
- verification (test criteria)
|
|
445
|
+
- depends_on: task IDs this task depends on (use sparingly)
|
|
446
|
+
- estimated_time, recommended_execution, severity, risk_level
|
|
447
|
+
- _metadata:
|
|
448
|
+
- timestamp, source, planning_mode
|
|
449
|
+
- diagnosis_angles: ${JSON.stringify(manifest.diagnoses.map(d => d.angle))}
|
|
450
|
+
|
|
451
|
+
## Task Grouping Rules
|
|
452
|
+
1. **Group by fix area**: All changes for one fix = one task (even if 2-3 files)
|
|
453
|
+
2. **Avoid file-per-task**: Do NOT create separate tasks for each file
|
|
454
|
+
3. **Substantial tasks**: Each task should represent 10-45 minutes of work
|
|
455
|
+
4. **True dependencies only**: Only use depends_on when Task B cannot start without Task A's output
|
|
456
|
+
5. **Prefer parallel**: Most tasks should be independent (no depends_on)
|
|
457
|
+
|
|
458
|
+
## Execution
|
|
459
|
+
1. Read ALL diagnosis files for comprehensive context
|
|
460
|
+
2. Execute CLI planning using Gemini (Qwen fallback)
|
|
461
|
+
3. Synthesize findings from multiple diagnosis angles
|
|
462
|
+
4. Parse output and structure fix-plan
|
|
463
|
+
5. Write JSON: Write('${sessionFolder}/fix-plan.json', jsonContent)
|
|
464
|
+
6. Return brief completion summary
|
|
465
|
+
`
|
|
466
|
+
)
|
|
467
|
+
```
|
|
468
|
+
|
|
469
|
+
**Output**: `${sessionFolder}/fix-plan.json`
|
|
470
|
+
|
|
471
|
+
---
|
|
472
|
+
|
|
473
|
+
### Phase 4: Task Confirmation & Execution Selection
|
|
474
|
+
|
|
475
|
+
**Step 4.1: Display Fix Plan**
|
|
476
|
+
```javascript
|
|
477
|
+
const fixPlan = JSON.parse(Read(`${sessionFolder}/fix-plan.json`))
|
|
478
|
+
|
|
479
|
+
console.log(`
|
|
480
|
+
## Fix Plan
|
|
481
|
+
|
|
482
|
+
**Summary**: ${fixPlan.summary}
|
|
483
|
+
**Root Cause**: ${fixPlan.root_cause}
|
|
484
|
+
**Strategy**: ${fixPlan.strategy}
|
|
485
|
+
|
|
486
|
+
**Tasks** (${fixPlan.tasks.length}):
|
|
487
|
+
${fixPlan.tasks.map((t, i) => `${i+1}. ${t.title} (${t.scope})`).join('\n')}
|
|
488
|
+
|
|
489
|
+
**Severity**: ${fixPlan.severity}
|
|
490
|
+
**Risk Level**: ${fixPlan.risk_level}
|
|
491
|
+
**Estimated Time**: ${fixPlan.estimated_time}
|
|
492
|
+
**Recommended**: ${fixPlan.recommended_execution}
|
|
493
|
+
`)
|
|
494
|
+
```
|
|
495
|
+
|
|
496
|
+
**Step 4.2: Collect Confirmation**
|
|
497
|
+
```javascript
|
|
498
|
+
AskUserQuestion({
|
|
499
|
+
questions: [
|
|
500
|
+
{
|
|
501
|
+
question: `Confirm fix plan? (${fixPlan.tasks.length} tasks, ${fixPlan.severity} severity)`,
|
|
502
|
+
header: "Confirm",
|
|
503
|
+
multiSelect: true,
|
|
504
|
+
options: [
|
|
505
|
+
{ label: "Allow", description: "Proceed as-is" },
|
|
506
|
+
{ label: "Modify", description: "Adjust before execution" },
|
|
507
|
+
{ label: "Cancel", description: "Abort workflow" }
|
|
508
|
+
]
|
|
509
|
+
},
|
|
510
|
+
{
|
|
511
|
+
question: "Execution method:",
|
|
512
|
+
header: "Execution",
|
|
513
|
+
multiSelect: false,
|
|
514
|
+
options: [
|
|
515
|
+
{ label: "Agent", description: "@code-developer agent" },
|
|
516
|
+
{ label: "Codex", description: "codex CLI tool" },
|
|
517
|
+
{ label: "Auto", description: `Auto: ${fixPlan.severity === 'Low' ? 'Agent' : 'Codex'}` }
|
|
518
|
+
]
|
|
519
|
+
},
|
|
520
|
+
{
|
|
521
|
+
question: "Code review after fix?",
|
|
522
|
+
header: "Review",
|
|
523
|
+
multiSelect: false,
|
|
524
|
+
options: [
|
|
525
|
+
{ label: "Gemini Review", description: "Gemini CLI" },
|
|
526
|
+
{ label: "Agent Review", description: "@code-reviewer" },
|
|
527
|
+
{ label: "Skip", description: "No review" }
|
|
528
|
+
]
|
|
529
|
+
}
|
|
530
|
+
]
|
|
531
|
+
})
|
|
532
|
+
```
|
|
533
|
+
|
|
534
|
+
---
|
|
535
|
+
|
|
536
|
+
### Phase 5: Dispatch to Execution
|
|
537
|
+
|
|
538
|
+
**CRITICAL**: lite-fix NEVER executes code directly. ALL execution MUST go through lite-execute.
|
|
539
|
+
|
|
540
|
+
**Step 5.1: Build executionContext**
|
|
541
|
+
|
|
542
|
+
```javascript
|
|
543
|
+
// Load manifest and all diagnosis files
|
|
544
|
+
const manifest = JSON.parse(Read(`${sessionFolder}/diagnoses-manifest.json`))
|
|
545
|
+
const diagnoses = {}
|
|
546
|
+
|
|
547
|
+
manifest.diagnoses.forEach(diag => {
|
|
548
|
+
if (file_exists(diag.path)) {
|
|
549
|
+
diagnoses[diag.angle] = JSON.parse(Read(diag.path))
|
|
550
|
+
}
|
|
551
|
+
})
|
|
552
|
+
|
|
553
|
+
const fixPlan = JSON.parse(Read(`${sessionFolder}/fix-plan.json`))
|
|
554
|
+
|
|
555
|
+
executionContext = {
|
|
556
|
+
mode: "bugfix",
|
|
557
|
+
severity: fixPlan.severity,
|
|
558
|
+
planObject: fixPlan,
|
|
559
|
+
diagnosisContext: diagnoses,
|
|
560
|
+
diagnosisAngles: manifest.diagnoses.map(d => d.angle),
|
|
561
|
+
diagnosisManifest: manifest,
|
|
562
|
+
clarificationContext: clarificationContext || null,
|
|
563
|
+
executionMethod: userSelection.execution_method,
|
|
564
|
+
codeReviewTool: userSelection.code_review_tool,
|
|
565
|
+
originalUserInput: bug_description,
|
|
566
|
+
session: {
|
|
567
|
+
id: sessionId,
|
|
568
|
+
folder: sessionFolder,
|
|
569
|
+
artifacts: {
|
|
570
|
+
diagnoses: manifest.diagnoses.map(diag => ({
|
|
571
|
+
angle: diag.angle,
|
|
572
|
+
path: diag.path
|
|
573
|
+
})),
|
|
574
|
+
diagnoses_manifest: `${sessionFolder}/diagnoses-manifest.json`,
|
|
575
|
+
fix_plan: `${sessionFolder}/fix-plan.json`
|
|
576
|
+
}
|
|
577
|
+
}
|
|
578
|
+
}
|
|
579
|
+
```
|
|
580
|
+
|
|
581
|
+
**Step 5.2: Dispatch**
|
|
582
|
+
|
|
583
|
+
```javascript
|
|
584
|
+
SlashCommand(command="/workflow:lite-execute --in-memory --mode bugfix")
|
|
585
|
+
```
|
|
586
|
+
|
|
587
|
+
## Session Folder Structure
|
|
588
|
+
|
|
589
|
+
```
|
|
590
|
+
.workflow/.lite-fix/{bug-slug}-{YYYY-MM-DD}/
|
|
591
|
+
|- diagnosis-{angle1}.json # Diagnosis angle 1
|
|
592
|
+
|- diagnosis-{angle2}.json # Diagnosis angle 2
|
|
593
|
+
|- diagnosis-{angle3}.json # Diagnosis angle 3 (if applicable)
|
|
594
|
+
|- diagnosis-{angle4}.json # Diagnosis angle 4 (if applicable)
|
|
595
|
+
|- diagnoses-manifest.json # Diagnosis index
|
|
596
|
+
+- fix-plan.json # Fix plan
|
|
597
|
+
```
|
|
598
|
+
|
|
599
|
+
**Example**:
|
|
600
|
+
```
|
|
601
|
+
.workflow/.lite-fix/user-avatar-upload-fails-413-2025-11-25-14-30-25/
|
|
602
|
+
|- diagnosis-error-handling.json
|
|
603
|
+
|- diagnosis-dataflow.json
|
|
604
|
+
|- diagnosis-validation.json
|
|
605
|
+
|- diagnoses-manifest.json
|
|
606
|
+
+- fix-plan.json
|
|
607
|
+
```
|
|
608
|
+
|
|
609
|
+
## Error Handling
|
|
610
|
+
|
|
611
|
+
| Error | Resolution |
|
|
612
|
+
|-------|------------|
|
|
613
|
+
| Diagnosis agent failure | Skip diagnosis, continue with bug description only |
|
|
614
|
+
| Planning agent failure | Fallback to direct planning by Claude |
|
|
615
|
+
| Clarification timeout | Use diagnosis findings as-is |
|
|
616
|
+
| Confirmation timeout | Save context, display resume instructions |
|
|
617
|
+
| Modify loop > 3 times | Suggest breaking task or using /workflow:plan |
|
|
618
|
+
| Root cause unclear | Extend diagnosis time or use broader angles |
|
|
619
|
+
| Too complex for lite-fix | Escalate to /workflow:plan --mode bugfix |
|
|
620
|
+
|
|
621
|
+
|