claude-code-workflow 6.3.26 → 6.3.28
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/CLAUDE.md +7 -1
- package/.claude/agents/action-planning-agent.md +1 -0
- package/.claude/agents/cli-discuss-agent.md +391 -0
- package/.claude/agents/cli-execution-agent.md +2 -0
- package/.claude/agents/cli-explore-agent.md +2 -1
- package/.claude/agents/cli-lite-planning-agent.md +1 -0
- package/.claude/agents/cli-planning-agent.md +1 -0
- package/.claude/agents/code-developer.md +1 -0
- package/.claude/agents/conceptual-planning-agent.md +2 -0
- package/.claude/agents/context-search-agent.md +1 -0
- package/.claude/agents/debug-explore-agent.md +2 -0
- package/.claude/agents/doc-generator.md +1 -0
- package/.claude/agents/issue-plan-agent.md +2 -1
- package/.claude/agents/issue-queue-agent.md +2 -1
- package/.claude/agents/memory-bridge.md +2 -0
- package/.claude/agents/test-context-search-agent.md +2 -0
- package/.claude/agents/test-fix-agent.md +1 -0
- package/.claude/agents/ui-design-agent.md +2 -0
- package/.claude/agents/universal-executor.md +1 -0
- package/.claude/commands/issue/execute.md +141 -163
- package/.claude/commands/workflow/lite-lite-lite.md +798 -0
- package/.claude/commands/workflow/multi-cli-plan.md +510 -0
- package/.claude/skills/ccw/SKILL.md +262 -372
- package/.claude/skills/ccw/command.json +547 -0
- package/.claude/skills/ccw-help/SKILL.md +46 -107
- package/.claude/skills/ccw-help/command.json +511 -0
- package/.claude/skills/skill-tuning/SKILL.md +303 -0
- package/.claude/skills/skill-tuning/phases/actions/action-abort.md +164 -0
- package/.claude/skills/skill-tuning/phases/actions/action-analyze-requirements.md +406 -0
- package/.claude/skills/skill-tuning/phases/actions/action-apply-fix.md +206 -0
- package/.claude/skills/skill-tuning/phases/actions/action-complete.md +195 -0
- package/.claude/skills/skill-tuning/phases/actions/action-diagnose-agent.md +317 -0
- package/.claude/skills/skill-tuning/phases/actions/action-diagnose-context.md +243 -0
- package/.claude/skills/skill-tuning/phases/actions/action-diagnose-dataflow.md +318 -0
- package/.claude/skills/skill-tuning/phases/actions/action-diagnose-docs.md +299 -0
- package/.claude/skills/skill-tuning/phases/actions/action-diagnose-memory.md +269 -0
- package/.claude/skills/skill-tuning/phases/actions/action-diagnose-token-consumption.md +200 -0
- package/.claude/skills/skill-tuning/phases/actions/action-gemini-analysis.md +322 -0
- package/.claude/skills/skill-tuning/phases/actions/action-generate-report.md +228 -0
- package/.claude/skills/skill-tuning/phases/actions/action-init.md +149 -0
- package/.claude/skills/skill-tuning/phases/actions/action-propose-fixes.md +317 -0
- package/.claude/skills/skill-tuning/phases/actions/action-verify.md +222 -0
- package/.claude/skills/skill-tuning/phases/orchestrator.md +377 -0
- package/.claude/skills/skill-tuning/phases/state-schema.md +378 -0
- package/.claude/skills/skill-tuning/specs/category-mappings.json +284 -0
- package/.claude/skills/skill-tuning/specs/dimension-mapping.md +212 -0
- package/.claude/skills/skill-tuning/specs/problem-taxonomy.md +318 -0
- package/.claude/skills/skill-tuning/specs/quality-gates.md +263 -0
- package/.claude/skills/skill-tuning/specs/skill-authoring-principles.md +189 -0
- package/.claude/skills/skill-tuning/specs/tuning-strategies.md +1537 -0
- package/.claude/skills/skill-tuning/templates/diagnosis-report.md +153 -0
- package/.claude/skills/skill-tuning/templates/fix-proposal.md +204 -0
- package/.claude/workflows/cli-templates/schemas/multi-cli-discussion-schema.json +421 -0
- package/.claude/workflows/cli-tools-usage.md +0 -41
- package/ccw/dist/core/auth/csrf-middleware.d.ts.map +1 -1
- package/ccw/dist/core/auth/csrf-middleware.js +3 -1
- package/ccw/dist/core/auth/csrf-middleware.js.map +1 -1
- package/ccw/dist/core/data-aggregator.d.ts +2 -0
- package/ccw/dist/core/data-aggregator.d.ts.map +1 -1
- package/ccw/dist/core/data-aggregator.js +5 -2
- package/ccw/dist/core/data-aggregator.js.map +1 -1
- package/ccw/dist/core/lite-scanner.d.ts +2 -1
- package/ccw/dist/core/lite-scanner.d.ts.map +1 -1
- package/ccw/dist/core/lite-scanner.js +295 -6
- package/ccw/dist/core/lite-scanner.js.map +1 -1
- package/ccw/dist/core/routes/codexlens/config-handlers.d.ts.map +1 -1
- package/ccw/dist/core/routes/codexlens/config-handlers.js +5 -5
- package/ccw/dist/core/routes/codexlens/config-handlers.js.map +1 -1
- package/ccw/dist/core/routes/session-routes.d.ts.map +1 -1
- package/ccw/dist/core/routes/session-routes.js +166 -48
- package/ccw/dist/core/routes/session-routes.js.map +1 -1
- package/ccw/dist/core/routes/system-routes.d.ts.map +1 -1
- package/ccw/dist/core/routes/system-routes.js +87 -0
- package/ccw/dist/core/routes/system-routes.js.map +1 -1
- package/ccw/dist/core/server.js +2 -2
- package/ccw/dist/core/server.js.map +1 -1
- package/ccw/scripts/IMPLEMENTATION-SUMMARY.md +226 -0
- package/ccw/scripts/QUICK-REFERENCE.md +135 -0
- package/ccw/scripts/README-memory-embedder.md +157 -0
- package/ccw/scripts/__pycache__/memory_embedder.cpython-313.pyc +0 -0
- package/ccw/scripts/__pycache__/test_memory_embedder.cpython-313-pytest-8.4.2.pyc +0 -0
- package/ccw/scripts/memory-embedder-example.ts +184 -0
- package/ccw/scripts/memory_embedder.py +428 -0
- package/ccw/scripts/test_memory_embedder.py +245 -0
- package/ccw/src/core/auth/csrf-middleware.ts +3 -1
- package/ccw/src/core/data-aggregator.ts +7 -2
- package/ccw/src/core/lite-scanner.ts +440 -6
- package/ccw/src/core/routes/codexlens/config-handlers.ts +12 -9
- package/ccw/src/core/routes/session-routes.ts +201 -48
- package/ccw/src/core/routes/system-routes.ts +102 -0
- package/ccw/src/core/server.ts +2 -2
- package/ccw/src/templates/dashboard-css/01-base.css +8 -0
- package/ccw/src/templates/dashboard-css/02-session.css +81 -0
- package/ccw/src/templates/dashboard-css/04-lite-tasks.css +2442 -0
- package/ccw/src/templates/dashboard-css/21-cli-toolmgmt.css +157 -0
- package/ccw/src/templates/dashboard-css/32-issue-manager.css +23 -0
- package/ccw/src/templates/dashboard-js/components/cli-stream-viewer.js +38 -4
- package/ccw/src/templates/dashboard-js/components/hook-manager.js +38 -13
- package/ccw/src/templates/dashboard-js/components/navigation.js +24 -4
- package/ccw/src/templates/dashboard-js/i18n.js +194 -6
- package/ccw/src/templates/dashboard-js/views/api-settings.js +32 -0
- package/ccw/src/templates/dashboard-js/views/claude-manager.js +44 -3
- package/ccw/src/templates/dashboard-js/views/cli-manager.js +303 -31
- package/ccw/src/templates/dashboard-js/views/history.js +44 -6
- package/ccw/src/templates/dashboard-js/views/home.js +1 -0
- package/ccw/src/templates/dashboard-js/views/issue-manager.js +54 -7
- package/ccw/src/templates/dashboard-js/views/lite-tasks.js +1817 -4
- package/ccw/src/templates/dashboard.html +5 -0
- package/package.json +2 -1
- package/.claude/skills/ccw/index/command-capabilities.json +0 -127
- package/.claude/skills/ccw/index/intent-rules.json +0 -136
- package/.claude/skills/ccw/index/workflow-chains.json +0 -451
- package/.claude/skills/ccw/phases/actions/bugfix.md +0 -218
- package/.claude/skills/ccw/phases/actions/coupled.md +0 -194
- package/.claude/skills/ccw/phases/actions/docs.md +0 -93
- package/.claude/skills/ccw/phases/actions/full.md +0 -154
- package/.claude/skills/ccw/phases/actions/issue.md +0 -201
- package/.claude/skills/ccw/phases/actions/rapid.md +0 -104
- package/.claude/skills/ccw/phases/actions/review-fix.md +0 -84
- package/.claude/skills/ccw/phases/actions/tdd.md +0 -66
- package/.claude/skills/ccw/phases/actions/ui.md +0 -79
- package/.claude/skills/ccw/phases/orchestrator.md +0 -435
- package/.claude/skills/ccw/specs/intent-classification.md +0 -336
- package/.claude/skills/ccw-help/index/all-agents.json +0 -82
- package/.claude/skills/ccw-help/index/all-commands.json +0 -882
- package/.claude/skills/ccw-help/index/by-category.json +0 -914
- package/.claude/skills/ccw-help/index/by-use-case.json +0 -896
- package/.claude/skills/ccw-help/index/command-relationships.json +0 -160
- package/.claude/skills/ccw-help/index/essential-commands.json +0 -112
|
@@ -0,0 +1,228 @@
|
|
|
1
|
+
# Action: Generate Consolidated Report
|
|
2
|
+
|
|
3
|
+
Generate a comprehensive tuning report merging all diagnosis results with prioritized recommendations.
|
|
4
|
+
|
|
5
|
+
## Purpose
|
|
6
|
+
|
|
7
|
+
- Merge all diagnosis results into unified report
|
|
8
|
+
- Prioritize issues by severity and impact
|
|
9
|
+
- Generate actionable recommendations
|
|
10
|
+
- Create human-readable markdown report
|
|
11
|
+
|
|
12
|
+
## Preconditions
|
|
13
|
+
|
|
14
|
+
- [ ] state.status === 'running'
|
|
15
|
+
- [ ] All diagnoses in focus_areas are completed
|
|
16
|
+
- [ ] state.issues.length > 0 OR generate summary report
|
|
17
|
+
|
|
18
|
+
## Execution
|
|
19
|
+
|
|
20
|
+
```javascript
|
|
21
|
+
async function execute(state, workDir) {
|
|
22
|
+
console.log('Generating consolidated tuning report...');
|
|
23
|
+
|
|
24
|
+
const targetSkill = state.target_skill;
|
|
25
|
+
const issues = state.issues;
|
|
26
|
+
|
|
27
|
+
// 1. Group issues by type
|
|
28
|
+
const issuesByType = {
|
|
29
|
+
context_explosion: issues.filter(i => i.type === 'context_explosion'),
|
|
30
|
+
memory_loss: issues.filter(i => i.type === 'memory_loss'),
|
|
31
|
+
dataflow_break: issues.filter(i => i.type === 'dataflow_break'),
|
|
32
|
+
agent_failure: issues.filter(i => i.type === 'agent_failure')
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
// 2. Group issues by severity
|
|
36
|
+
const issuesBySeverity = {
|
|
37
|
+
critical: issues.filter(i => i.severity === 'critical'),
|
|
38
|
+
high: issues.filter(i => i.severity === 'high'),
|
|
39
|
+
medium: issues.filter(i => i.severity === 'medium'),
|
|
40
|
+
low: issues.filter(i => i.severity === 'low')
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
// 3. Calculate overall health score
|
|
44
|
+
const weights = { critical: 25, high: 15, medium: 5, low: 1 };
|
|
45
|
+
const deductions = Object.entries(issuesBySeverity)
|
|
46
|
+
.reduce((sum, [sev, arr]) => sum + arr.length * weights[sev], 0);
|
|
47
|
+
const healthScore = Math.max(0, 100 - deductions);
|
|
48
|
+
|
|
49
|
+
// 4. Generate report content
|
|
50
|
+
const report = `# Skill Tuning Report
|
|
51
|
+
|
|
52
|
+
**Target Skill**: ${targetSkill.name}
|
|
53
|
+
**Path**: ${targetSkill.path}
|
|
54
|
+
**Execution Mode**: ${targetSkill.execution_mode}
|
|
55
|
+
**Generated**: ${new Date().toISOString()}
|
|
56
|
+
|
|
57
|
+
---
|
|
58
|
+
|
|
59
|
+
## Executive Summary
|
|
60
|
+
|
|
61
|
+
| Metric | Value |
|
|
62
|
+
|--------|-------|
|
|
63
|
+
| Health Score | ${healthScore}/100 |
|
|
64
|
+
| Total Issues | ${issues.length} |
|
|
65
|
+
| Critical | ${issuesBySeverity.critical.length} |
|
|
66
|
+
| High | ${issuesBySeverity.high.length} |
|
|
67
|
+
| Medium | ${issuesBySeverity.medium.length} |
|
|
68
|
+
| Low | ${issuesBySeverity.low.length} |
|
|
69
|
+
|
|
70
|
+
### User Reported Issue
|
|
71
|
+
> ${state.user_issue_description}
|
|
72
|
+
|
|
73
|
+
### Overall Assessment
|
|
74
|
+
${healthScore >= 80 ? '✅ Skill is in good health with minor issues.' :
|
|
75
|
+
healthScore >= 60 ? '⚠️ Skill has significant issues requiring attention.' :
|
|
76
|
+
healthScore >= 40 ? '🔶 Skill has serious issues affecting reliability.' :
|
|
77
|
+
'❌ Skill has critical issues requiring immediate fixes.'}
|
|
78
|
+
|
|
79
|
+
---
|
|
80
|
+
|
|
81
|
+
## Diagnosis Results
|
|
82
|
+
|
|
83
|
+
### Context Explosion Analysis
|
|
84
|
+
${state.diagnosis.context ?
|
|
85
|
+
`- **Status**: ${state.diagnosis.context.status}
|
|
86
|
+
- **Severity**: ${state.diagnosis.context.severity}
|
|
87
|
+
- **Issues Found**: ${state.diagnosis.context.issues_found}
|
|
88
|
+
- **Key Findings**: ${state.diagnosis.context.details.recommendations.join('; ') || 'None'}` :
|
|
89
|
+
'_Not analyzed_'}
|
|
90
|
+
|
|
91
|
+
### Long-tail Memory Analysis
|
|
92
|
+
${state.diagnosis.memory ?
|
|
93
|
+
`- **Status**: ${state.diagnosis.memory.status}
|
|
94
|
+
- **Severity**: ${state.diagnosis.memory.severity}
|
|
95
|
+
- **Issues Found**: ${state.diagnosis.memory.issues_found}
|
|
96
|
+
- **Key Findings**: ${state.diagnosis.memory.details.recommendations.join('; ') || 'None'}` :
|
|
97
|
+
'_Not analyzed_'}
|
|
98
|
+
|
|
99
|
+
### Data Flow Analysis
|
|
100
|
+
${state.diagnosis.dataflow ?
|
|
101
|
+
`- **Status**: ${state.diagnosis.dataflow.status}
|
|
102
|
+
- **Severity**: ${state.diagnosis.dataflow.severity}
|
|
103
|
+
- **Issues Found**: ${state.diagnosis.dataflow.issues_found}
|
|
104
|
+
- **Key Findings**: ${state.diagnosis.dataflow.details.recommendations.join('; ') || 'None'}` :
|
|
105
|
+
'_Not analyzed_'}
|
|
106
|
+
|
|
107
|
+
### Agent Coordination Analysis
|
|
108
|
+
${state.diagnosis.agent ?
|
|
109
|
+
`- **Status**: ${state.diagnosis.agent.status}
|
|
110
|
+
- **Severity**: ${state.diagnosis.agent.severity}
|
|
111
|
+
- **Issues Found**: ${state.diagnosis.agent.issues_found}
|
|
112
|
+
- **Key Findings**: ${state.diagnosis.agent.details.recommendations.join('; ') || 'None'}` :
|
|
113
|
+
'_Not analyzed_'}
|
|
114
|
+
|
|
115
|
+
---
|
|
116
|
+
|
|
117
|
+
## Critical & High Priority Issues
|
|
118
|
+
|
|
119
|
+
${issuesBySeverity.critical.length + issuesBySeverity.high.length === 0 ?
|
|
120
|
+
'_No critical or high priority issues found._' :
|
|
121
|
+
[...issuesBySeverity.critical, ...issuesBySeverity.high].map((issue, i) => `
|
|
122
|
+
### ${i + 1}. [${issue.severity.toUpperCase()}] ${issue.description}
|
|
123
|
+
|
|
124
|
+
- **ID**: ${issue.id}
|
|
125
|
+
- **Type**: ${issue.type}
|
|
126
|
+
- **Location**: ${typeof issue.location === 'object' ? issue.location.file : issue.location}
|
|
127
|
+
- **Root Cause**: ${issue.root_cause}
|
|
128
|
+
- **Impact**: ${issue.impact}
|
|
129
|
+
- **Suggested Fix**: ${issue.suggested_fix}
|
|
130
|
+
|
|
131
|
+
**Evidence**:
|
|
132
|
+
${issue.evidence.map(e => `- \`${e}\``).join('\n')}
|
|
133
|
+
`).join('\n')}
|
|
134
|
+
|
|
135
|
+
---
|
|
136
|
+
|
|
137
|
+
## Medium & Low Priority Issues
|
|
138
|
+
|
|
139
|
+
${issuesBySeverity.medium.length + issuesBySeverity.low.length === 0 ?
|
|
140
|
+
'_No medium or low priority issues found._' :
|
|
141
|
+
[...issuesBySeverity.medium, ...issuesBySeverity.low].map((issue, i) => `
|
|
142
|
+
### ${i + 1}. [${issue.severity.toUpperCase()}] ${issue.description}
|
|
143
|
+
|
|
144
|
+
- **ID**: ${issue.id}
|
|
145
|
+
- **Type**: ${issue.type}
|
|
146
|
+
- **Suggested Fix**: ${issue.suggested_fix}
|
|
147
|
+
`).join('\n')}
|
|
148
|
+
|
|
149
|
+
---
|
|
150
|
+
|
|
151
|
+
## Recommended Fix Order
|
|
152
|
+
|
|
153
|
+
Based on severity and dependencies, apply fixes in this order:
|
|
154
|
+
|
|
155
|
+
${[...issuesBySeverity.critical, ...issuesBySeverity.high, ...issuesBySeverity.medium]
|
|
156
|
+
.slice(0, 10)
|
|
157
|
+
.map((issue, i) => `${i + 1}. **${issue.id}**: ${issue.suggested_fix}`)
|
|
158
|
+
.join('\n')}
|
|
159
|
+
|
|
160
|
+
---
|
|
161
|
+
|
|
162
|
+
## Quality Gates
|
|
163
|
+
|
|
164
|
+
| Gate | Threshold | Current | Status |
|
|
165
|
+
|------|-----------|---------|--------|
|
|
166
|
+
| Critical Issues | 0 | ${issuesBySeverity.critical.length} | ${issuesBySeverity.critical.length === 0 ? '✅ PASS' : '❌ FAIL'} |
|
|
167
|
+
| High Issues | ≤ 2 | ${issuesBySeverity.high.length} | ${issuesBySeverity.high.length <= 2 ? '✅ PASS' : '❌ FAIL'} |
|
|
168
|
+
| Health Score | ≥ 60 | ${healthScore} | ${healthScore >= 60 ? '✅ PASS' : '❌ FAIL'} |
|
|
169
|
+
|
|
170
|
+
**Overall Quality Gate**: ${
|
|
171
|
+
issuesBySeverity.critical.length === 0 &&
|
|
172
|
+
issuesBySeverity.high.length <= 2 &&
|
|
173
|
+
healthScore >= 60 ? '✅ PASS' : '❌ FAIL'}
|
|
174
|
+
|
|
175
|
+
---
|
|
176
|
+
|
|
177
|
+
*Report generated by skill-tuning*
|
|
178
|
+
`;
|
|
179
|
+
|
|
180
|
+
// 5. Write report
|
|
181
|
+
Write(`${workDir}/tuning-report.md`, report);
|
|
182
|
+
|
|
183
|
+
// 6. Calculate quality gate
|
|
184
|
+
const qualityGate = issuesBySeverity.critical.length === 0 &&
|
|
185
|
+
issuesBySeverity.high.length <= 2 &&
|
|
186
|
+
healthScore >= 60 ? 'pass' :
|
|
187
|
+
healthScore >= 40 ? 'review' : 'fail';
|
|
188
|
+
|
|
189
|
+
return {
|
|
190
|
+
stateUpdates: {
|
|
191
|
+
quality_score: healthScore,
|
|
192
|
+
quality_gate: qualityGate,
|
|
193
|
+
issues_by_severity: {
|
|
194
|
+
critical: issuesBySeverity.critical.length,
|
|
195
|
+
high: issuesBySeverity.high.length,
|
|
196
|
+
medium: issuesBySeverity.medium.length,
|
|
197
|
+
low: issuesBySeverity.low.length
|
|
198
|
+
}
|
|
199
|
+
},
|
|
200
|
+
outputFiles: [`${workDir}/tuning-report.md`],
|
|
201
|
+
summary: `Report generated: ${issues.length} issues, health score ${healthScore}/100, gate: ${qualityGate}`
|
|
202
|
+
};
|
|
203
|
+
}
|
|
204
|
+
```
|
|
205
|
+
|
|
206
|
+
## State Updates
|
|
207
|
+
|
|
208
|
+
```javascript
|
|
209
|
+
return {
|
|
210
|
+
stateUpdates: {
|
|
211
|
+
quality_score: <0-100>,
|
|
212
|
+
quality_gate: '<pass|review|fail>',
|
|
213
|
+
issues_by_severity: { critical: N, high: N, medium: N, low: N }
|
|
214
|
+
}
|
|
215
|
+
};
|
|
216
|
+
```
|
|
217
|
+
|
|
218
|
+
## Error Handling
|
|
219
|
+
|
|
220
|
+
| Error Type | Recovery |
|
|
221
|
+
|------------|----------|
|
|
222
|
+
| Write error | Retry to alternative path |
|
|
223
|
+
| Empty issues | Generate summary with no issues |
|
|
224
|
+
|
|
225
|
+
## Next Actions
|
|
226
|
+
|
|
227
|
+
- If issues.length > 0: action-propose-fixes
|
|
228
|
+
- If issues.length === 0: action-complete
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
# Action: Initialize Tuning Session
|
|
2
|
+
|
|
3
|
+
Initialize the skill-tuning session by collecting target skill information, creating work directories, and setting up initial state.
|
|
4
|
+
|
|
5
|
+
## Purpose
|
|
6
|
+
|
|
7
|
+
- Identify target skill to tune
|
|
8
|
+
- Collect user's problem description
|
|
9
|
+
- Create work directory structure
|
|
10
|
+
- Backup original skill files
|
|
11
|
+
- Initialize state for orchestrator
|
|
12
|
+
|
|
13
|
+
## Preconditions
|
|
14
|
+
|
|
15
|
+
- [ ] state.status === 'pending'
|
|
16
|
+
|
|
17
|
+
## Execution
|
|
18
|
+
|
|
19
|
+
```javascript
|
|
20
|
+
async function execute(state, workDir) {
|
|
21
|
+
// 1. Ask user for target skill
|
|
22
|
+
const skillInput = await AskUserQuestion({
|
|
23
|
+
questions: [{
|
|
24
|
+
question: "Which skill do you want to tune?",
|
|
25
|
+
header: "Target Skill",
|
|
26
|
+
multiSelect: false,
|
|
27
|
+
options: [
|
|
28
|
+
{ label: "Specify path", description: "Enter skill directory path" }
|
|
29
|
+
]
|
|
30
|
+
}]
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
const skillPath = skillInput["Target Skill"];
|
|
34
|
+
|
|
35
|
+
// 2. Validate skill exists and read structure
|
|
36
|
+
const skillMdPath = `${skillPath}/SKILL.md`;
|
|
37
|
+
if (!Glob(`${skillPath}/SKILL.md`).length) {
|
|
38
|
+
throw new Error(`Invalid skill path: ${skillPath} - SKILL.md not found`);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
// 3. Read skill metadata
|
|
42
|
+
const skillMd = Read(skillMdPath);
|
|
43
|
+
const frontMatterMatch = skillMd.match(/^---\n([\s\S]*?)\n---/);
|
|
44
|
+
const skillName = frontMatterMatch
|
|
45
|
+
? frontMatterMatch[1].match(/name:\s*(.+)/)?.[1]?.trim()
|
|
46
|
+
: skillPath.split('/').pop();
|
|
47
|
+
|
|
48
|
+
// 4. Detect execution mode
|
|
49
|
+
const hasOrchestrator = Glob(`${skillPath}/phases/orchestrator.md`).length > 0;
|
|
50
|
+
const executionMode = hasOrchestrator ? 'autonomous' : 'sequential';
|
|
51
|
+
|
|
52
|
+
// 5. Scan skill structure
|
|
53
|
+
const phases = Glob(`${skillPath}/phases/**/*.md`).map(f => f.replace(skillPath + '/', ''));
|
|
54
|
+
const specs = Glob(`${skillPath}/specs/**/*.md`).map(f => f.replace(skillPath + '/', ''));
|
|
55
|
+
|
|
56
|
+
// 6. Ask for problem description
|
|
57
|
+
const issueInput = await AskUserQuestion({
|
|
58
|
+
questions: [{
|
|
59
|
+
question: "Describe the issue or what you want to optimize:",
|
|
60
|
+
header: "Issue",
|
|
61
|
+
multiSelect: false,
|
|
62
|
+
options: [
|
|
63
|
+
{ label: "Context grows too large", description: "Token explosion over multiple turns" },
|
|
64
|
+
{ label: "Instructions forgotten", description: "Early constraints lost in long execution" },
|
|
65
|
+
{ label: "Data inconsistency", description: "State format changes between phases" },
|
|
66
|
+
{ label: "Agent failures", description: "Sub-agent calls fail or return unexpected results" }
|
|
67
|
+
]
|
|
68
|
+
}]
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
// 7. Ask for focus areas
|
|
72
|
+
const focusInput = await AskUserQuestion({
|
|
73
|
+
questions: [{
|
|
74
|
+
question: "Which areas should be diagnosed? (Select all that apply)",
|
|
75
|
+
header: "Focus",
|
|
76
|
+
multiSelect: true,
|
|
77
|
+
options: [
|
|
78
|
+
{ label: "context", description: "Context explosion analysis" },
|
|
79
|
+
{ label: "memory", description: "Long-tail forgetting analysis" },
|
|
80
|
+
{ label: "dataflow", description: "Data flow analysis" },
|
|
81
|
+
{ label: "agent", description: "Agent coordination analysis" }
|
|
82
|
+
]
|
|
83
|
+
}]
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
const focusAreas = focusInput["Focus"] || ['context', 'memory', 'dataflow', 'agent'];
|
|
87
|
+
|
|
88
|
+
// 8. Create backup
|
|
89
|
+
const backupDir = `${workDir}/backups/${skillName}-backup`;
|
|
90
|
+
Bash(`mkdir -p "${backupDir}"`);
|
|
91
|
+
Bash(`cp -r "${skillPath}"/* "${backupDir}/"`);
|
|
92
|
+
|
|
93
|
+
// 9. Return state updates
|
|
94
|
+
return {
|
|
95
|
+
stateUpdates: {
|
|
96
|
+
status: 'running',
|
|
97
|
+
started_at: new Date().toISOString(),
|
|
98
|
+
target_skill: {
|
|
99
|
+
name: skillName,
|
|
100
|
+
path: skillPath,
|
|
101
|
+
execution_mode: executionMode,
|
|
102
|
+
phases: phases,
|
|
103
|
+
specs: specs
|
|
104
|
+
},
|
|
105
|
+
user_issue_description: issueInput["Issue"],
|
|
106
|
+
focus_areas: Array.isArray(focusAreas) ? focusAreas : [focusAreas],
|
|
107
|
+
work_dir: workDir,
|
|
108
|
+
backup_dir: backupDir
|
|
109
|
+
},
|
|
110
|
+
outputFiles: [],
|
|
111
|
+
summary: `Initialized tuning for "${skillName}" (${executionMode} mode), focus: ${focusAreas.join(', ')}`
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
## State Updates
|
|
117
|
+
|
|
118
|
+
```javascript
|
|
119
|
+
return {
|
|
120
|
+
stateUpdates: {
|
|
121
|
+
status: 'running',
|
|
122
|
+
started_at: '<timestamp>',
|
|
123
|
+
target_skill: {
|
|
124
|
+
name: '<skill-name>',
|
|
125
|
+
path: '<skill-path>',
|
|
126
|
+
execution_mode: '<sequential|autonomous>',
|
|
127
|
+
phases: ['...'],
|
|
128
|
+
specs: ['...']
|
|
129
|
+
},
|
|
130
|
+
user_issue_description: '<user description>',
|
|
131
|
+
focus_areas: ['context', 'memory', ...],
|
|
132
|
+
work_dir: '<work-dir>',
|
|
133
|
+
backup_dir: '<backup-dir>'
|
|
134
|
+
}
|
|
135
|
+
};
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
## Error Handling
|
|
139
|
+
|
|
140
|
+
| Error Type | Recovery |
|
|
141
|
+
|------------|----------|
|
|
142
|
+
| Skill path not found | Ask user to re-enter valid path |
|
|
143
|
+
| SKILL.md missing | Suggest path correction |
|
|
144
|
+
| Backup creation failed | Retry with alternative location |
|
|
145
|
+
|
|
146
|
+
## Next Actions
|
|
147
|
+
|
|
148
|
+
- Success: Continue to first diagnosis action based on focus_areas
|
|
149
|
+
- Failure: action-abort
|
|
@@ -0,0 +1,317 @@
|
|
|
1
|
+
# Action: Propose Fixes
|
|
2
|
+
|
|
3
|
+
Generate fix proposals for identified issues with implementation strategies.
|
|
4
|
+
|
|
5
|
+
## Purpose
|
|
6
|
+
|
|
7
|
+
- Create fix strategies for each issue
|
|
8
|
+
- Generate implementation plans
|
|
9
|
+
- Estimate risk levels
|
|
10
|
+
- Allow user to select fixes to apply
|
|
11
|
+
|
|
12
|
+
## Preconditions
|
|
13
|
+
|
|
14
|
+
- [ ] state.status === 'running'
|
|
15
|
+
- [ ] state.issues.length > 0
|
|
16
|
+
- [ ] action-generate-report completed
|
|
17
|
+
|
|
18
|
+
## Fix Strategy Catalog
|
|
19
|
+
|
|
20
|
+
### Context Explosion Fixes
|
|
21
|
+
|
|
22
|
+
| Strategy | Description | Risk |
|
|
23
|
+
|----------|-------------|------|
|
|
24
|
+
| `context_summarization` | Add summarizer agent between phases | low |
|
|
25
|
+
| `sliding_window` | Keep only last N turns in context | low |
|
|
26
|
+
| `structured_state` | Replace text context with JSON state | medium |
|
|
27
|
+
| `path_reference` | Pass file paths instead of content | low |
|
|
28
|
+
|
|
29
|
+
### Memory Loss Fixes
|
|
30
|
+
|
|
31
|
+
| Strategy | Description | Risk |
|
|
32
|
+
|----------|-------------|------|
|
|
33
|
+
| `constraint_injection` | Add constraints to each phase prompt | low |
|
|
34
|
+
| `checkpoint_restore` | Save state at milestones | low |
|
|
35
|
+
| `goal_embedding` | Track goal similarity throughout | medium |
|
|
36
|
+
| `state_constraints_field` | Add constraints field to state schema | low |
|
|
37
|
+
|
|
38
|
+
### Data Flow Fixes
|
|
39
|
+
|
|
40
|
+
| Strategy | Description | Risk |
|
|
41
|
+
|----------|-------------|------|
|
|
42
|
+
| `state_centralization` | Single state.json for all data | medium |
|
|
43
|
+
| `schema_enforcement` | Add Zod validation | low |
|
|
44
|
+
| `field_normalization` | Normalize field names | low |
|
|
45
|
+
| `transactional_updates` | Atomic state updates | medium |
|
|
46
|
+
|
|
47
|
+
### Agent Coordination Fixes
|
|
48
|
+
|
|
49
|
+
| Strategy | Description | Risk |
|
|
50
|
+
|----------|-------------|------|
|
|
51
|
+
| `error_wrapping` | Add try-catch to all Task calls | low |
|
|
52
|
+
| `result_validation` | Validate agent returns | low |
|
|
53
|
+
| `orchestrator_refactor` | Centralize agent coordination | high |
|
|
54
|
+
| `flatten_nesting` | Remove nested agent calls | medium |
|
|
55
|
+
|
|
56
|
+
## Execution
|
|
57
|
+
|
|
58
|
+
```javascript
|
|
59
|
+
async function execute(state, workDir) {
|
|
60
|
+
console.log('Generating fix proposals...');
|
|
61
|
+
|
|
62
|
+
const issues = state.issues;
|
|
63
|
+
const fixes = [];
|
|
64
|
+
|
|
65
|
+
// Group issues by type for batch fixes
|
|
66
|
+
const issuesByType = {
|
|
67
|
+
context_explosion: issues.filter(i => i.type === 'context_explosion'),
|
|
68
|
+
memory_loss: issues.filter(i => i.type === 'memory_loss'),
|
|
69
|
+
dataflow_break: issues.filter(i => i.type === 'dataflow_break'),
|
|
70
|
+
agent_failure: issues.filter(i => i.type === 'agent_failure')
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
// Generate fixes for context explosion
|
|
74
|
+
if (issuesByType.context_explosion.length > 0) {
|
|
75
|
+
const ctxIssues = issuesByType.context_explosion;
|
|
76
|
+
|
|
77
|
+
if (ctxIssues.some(i => i.description.includes('history accumulation'))) {
|
|
78
|
+
fixes.push({
|
|
79
|
+
id: `FIX-${fixes.length + 1}`,
|
|
80
|
+
issue_ids: ctxIssues.filter(i => i.description.includes('history')).map(i => i.id),
|
|
81
|
+
strategy: 'sliding_window',
|
|
82
|
+
description: 'Implement sliding window for conversation history',
|
|
83
|
+
rationale: 'Prevents unbounded context growth by keeping only recent turns',
|
|
84
|
+
changes: [{
|
|
85
|
+
file: 'phases/orchestrator.md',
|
|
86
|
+
action: 'modify',
|
|
87
|
+
diff: `+ const MAX_HISTORY = 5;
|
|
88
|
+
+ state.history = state.history.slice(-MAX_HISTORY);`
|
|
89
|
+
}],
|
|
90
|
+
risk: 'low',
|
|
91
|
+
estimated_impact: 'Reduces token usage by ~50%',
|
|
92
|
+
verification_steps: ['Run skill with 10+ iterations', 'Verify context size stable']
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
if (ctxIssues.some(i => i.description.includes('full content'))) {
|
|
97
|
+
fixes.push({
|
|
98
|
+
id: `FIX-${fixes.length + 1}`,
|
|
99
|
+
issue_ids: ctxIssues.filter(i => i.description.includes('content')).map(i => i.id),
|
|
100
|
+
strategy: 'path_reference',
|
|
101
|
+
description: 'Pass file paths instead of full content',
|
|
102
|
+
rationale: 'Agents can read files when needed, reducing prompt size',
|
|
103
|
+
changes: [{
|
|
104
|
+
file: 'phases/*.md',
|
|
105
|
+
action: 'modify',
|
|
106
|
+
diff: `- prompt: \${content}
|
|
107
|
+
+ prompt: Read file at: \${filePath}`
|
|
108
|
+
}],
|
|
109
|
+
risk: 'low',
|
|
110
|
+
estimated_impact: 'Significant token reduction',
|
|
111
|
+
verification_steps: ['Verify agents can still access needed content']
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
// Generate fixes for memory loss
|
|
117
|
+
if (issuesByType.memory_loss.length > 0) {
|
|
118
|
+
const memIssues = issuesByType.memory_loss;
|
|
119
|
+
|
|
120
|
+
if (memIssues.some(i => i.description.includes('constraint'))) {
|
|
121
|
+
fixes.push({
|
|
122
|
+
id: `FIX-${fixes.length + 1}`,
|
|
123
|
+
issue_ids: memIssues.filter(i => i.description.includes('constraint')).map(i => i.id),
|
|
124
|
+
strategy: 'constraint_injection',
|
|
125
|
+
description: 'Add constraint injection to all phases',
|
|
126
|
+
rationale: 'Ensures original requirements are visible in every phase',
|
|
127
|
+
changes: [{
|
|
128
|
+
file: 'phases/*.md',
|
|
129
|
+
action: 'modify',
|
|
130
|
+
diff: `+ [CONSTRAINTS]
|
|
131
|
+
+ Original requirements from state.original_requirements:
|
|
132
|
+
+ \${JSON.stringify(state.original_requirements)}`
|
|
133
|
+
}],
|
|
134
|
+
risk: 'low',
|
|
135
|
+
estimated_impact: 'Improves constraint adherence',
|
|
136
|
+
verification_steps: ['Run skill with specific constraints', 'Verify output matches']
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
if (memIssues.some(i => i.description.includes('State schema'))) {
|
|
141
|
+
fixes.push({
|
|
142
|
+
id: `FIX-${fixes.length + 1}`,
|
|
143
|
+
issue_ids: memIssues.filter(i => i.description.includes('schema')).map(i => i.id),
|
|
144
|
+
strategy: 'state_constraints_field',
|
|
145
|
+
description: 'Add original_requirements field to state schema',
|
|
146
|
+
rationale: 'Preserves original intent throughout execution',
|
|
147
|
+
changes: [{
|
|
148
|
+
file: 'phases/state-schema.md',
|
|
149
|
+
action: 'modify',
|
|
150
|
+
diff: `+ original_requirements: string[]; // User's original constraints
|
|
151
|
+
+ goal_summary: string; // One-line goal statement`
|
|
152
|
+
}],
|
|
153
|
+
risk: 'low',
|
|
154
|
+
estimated_impact: 'Enables constraint tracking',
|
|
155
|
+
verification_steps: ['Verify state includes requirements after init']
|
|
156
|
+
});
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
// Generate fixes for data flow
|
|
161
|
+
if (issuesByType.dataflow_break.length > 0) {
|
|
162
|
+
const dfIssues = issuesByType.dataflow_break;
|
|
163
|
+
|
|
164
|
+
if (dfIssues.some(i => i.description.includes('multiple locations'))) {
|
|
165
|
+
fixes.push({
|
|
166
|
+
id: `FIX-${fixes.length + 1}`,
|
|
167
|
+
issue_ids: dfIssues.filter(i => i.description.includes('location')).map(i => i.id),
|
|
168
|
+
strategy: 'state_centralization',
|
|
169
|
+
description: 'Centralize all state to single state.json',
|
|
170
|
+
rationale: 'Single source of truth prevents inconsistencies',
|
|
171
|
+
changes: [{
|
|
172
|
+
file: 'phases/*.md',
|
|
173
|
+
action: 'modify',
|
|
174
|
+
diff: `- Write(\`\${workDir}/config.json\`, ...)
|
|
175
|
+
+ updateState({ config: ... }) // Use state manager`
|
|
176
|
+
}],
|
|
177
|
+
risk: 'medium',
|
|
178
|
+
estimated_impact: 'Eliminates state fragmentation',
|
|
179
|
+
verification_steps: ['Verify all reads come from state.json', 'Test state persistence']
|
|
180
|
+
});
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
if (dfIssues.some(i => i.description.includes('validation'))) {
|
|
184
|
+
fixes.push({
|
|
185
|
+
id: `FIX-${fixes.length + 1}`,
|
|
186
|
+
issue_ids: dfIssues.filter(i => i.description.includes('validation')).map(i => i.id),
|
|
187
|
+
strategy: 'schema_enforcement',
|
|
188
|
+
description: 'Add Zod schema validation',
|
|
189
|
+
rationale: 'Runtime validation catches schema violations',
|
|
190
|
+
changes: [{
|
|
191
|
+
file: 'phases/state-schema.md',
|
|
192
|
+
action: 'modify',
|
|
193
|
+
diff: `+ import { z } from 'zod';
|
|
194
|
+
+ const StateSchema = z.object({...});
|
|
195
|
+
+ function validateState(s) { return StateSchema.parse(s); }`
|
|
196
|
+
}],
|
|
197
|
+
risk: 'low',
|
|
198
|
+
estimated_impact: 'Catches invalid state early',
|
|
199
|
+
verification_steps: ['Test with invalid state input', 'Verify error thrown']
|
|
200
|
+
});
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
// Generate fixes for agent coordination
|
|
205
|
+
if (issuesByType.agent_failure.length > 0) {
|
|
206
|
+
const agentIssues = issuesByType.agent_failure;
|
|
207
|
+
|
|
208
|
+
if (agentIssues.some(i => i.description.includes('error handling'))) {
|
|
209
|
+
fixes.push({
|
|
210
|
+
id: `FIX-${fixes.length + 1}`,
|
|
211
|
+
issue_ids: agentIssues.filter(i => i.description.includes('error')).map(i => i.id),
|
|
212
|
+
strategy: 'error_wrapping',
|
|
213
|
+
description: 'Wrap all Task calls in try-catch',
|
|
214
|
+
rationale: 'Prevents cascading failures from agent errors',
|
|
215
|
+
changes: [{
|
|
216
|
+
file: 'phases/*.md',
|
|
217
|
+
action: 'modify',
|
|
218
|
+
diff: `+ try {
|
|
219
|
+
const result = await Task({...});
|
|
220
|
+
+ if (!result) throw new Error('Empty result');
|
|
221
|
+
+ } catch (e) {
|
|
222
|
+
+ updateState({ errors: [...errors, e.message], error_count: error_count + 1 });
|
|
223
|
+
+ }`
|
|
224
|
+
}],
|
|
225
|
+
risk: 'low',
|
|
226
|
+
estimated_impact: 'Improves error resilience',
|
|
227
|
+
verification_steps: ['Simulate agent failure', 'Verify graceful handling']
|
|
228
|
+
});
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
if (agentIssues.some(i => i.description.includes('nested'))) {
|
|
232
|
+
fixes.push({
|
|
233
|
+
id: `FIX-${fixes.length + 1}`,
|
|
234
|
+
issue_ids: agentIssues.filter(i => i.description.includes('nested')).map(i => i.id),
|
|
235
|
+
strategy: 'flatten_nesting',
|
|
236
|
+
description: 'Flatten nested agent calls',
|
|
237
|
+
rationale: 'Reduces complexity and context explosion',
|
|
238
|
+
changes: [{
|
|
239
|
+
file: 'phases/orchestrator.md',
|
|
240
|
+
action: 'modify',
|
|
241
|
+
diff: `// Instead of agent calling agent:
|
|
242
|
+
// Agent A returns {needs_agent_b: true}
|
|
243
|
+
// Orchestrator sees this and calls Agent B next`
|
|
244
|
+
}],
|
|
245
|
+
risk: 'medium',
|
|
246
|
+
estimated_impact: 'Reduces nesting depth',
|
|
247
|
+
verification_steps: ['Verify no nested Task calls', 'Test agent chaining via orchestrator']
|
|
248
|
+
});
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
// Write fix proposals
|
|
253
|
+
Write(`${workDir}/fixes/fix-proposals.json`, JSON.stringify(fixes, null, 2));
|
|
254
|
+
|
|
255
|
+
// Ask user to select fixes to apply
|
|
256
|
+
const fixOptions = fixes.slice(0, 4).map(f => ({
|
|
257
|
+
label: f.id,
|
|
258
|
+
description: `[${f.risk.toUpperCase()} risk] ${f.description}`
|
|
259
|
+
}));
|
|
260
|
+
|
|
261
|
+
if (fixOptions.length > 0) {
|
|
262
|
+
const selection = await AskUserQuestion({
|
|
263
|
+
questions: [{
|
|
264
|
+
question: 'Which fixes would you like to apply?',
|
|
265
|
+
header: 'Fixes',
|
|
266
|
+
multiSelect: true,
|
|
267
|
+
options: fixOptions
|
|
268
|
+
}]
|
|
269
|
+
});
|
|
270
|
+
|
|
271
|
+
const selectedFixIds = Array.isArray(selection['Fixes'])
|
|
272
|
+
? selection['Fixes']
|
|
273
|
+
: [selection['Fixes']];
|
|
274
|
+
|
|
275
|
+
return {
|
|
276
|
+
stateUpdates: {
|
|
277
|
+
proposed_fixes: fixes,
|
|
278
|
+
pending_fixes: selectedFixIds.filter(id => id && fixes.some(f => f.id === id))
|
|
279
|
+
},
|
|
280
|
+
outputFiles: [`${workDir}/fixes/fix-proposals.json`],
|
|
281
|
+
summary: `Generated ${fixes.length} fix proposals, ${selectedFixIds.length} selected for application`
|
|
282
|
+
};
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
return {
|
|
286
|
+
stateUpdates: {
|
|
287
|
+
proposed_fixes: fixes,
|
|
288
|
+
pending_fixes: []
|
|
289
|
+
},
|
|
290
|
+
outputFiles: [`${workDir}/fixes/fix-proposals.json`],
|
|
291
|
+
summary: `Generated ${fixes.length} fix proposals (none selected)`
|
|
292
|
+
};
|
|
293
|
+
}
|
|
294
|
+
```
|
|
295
|
+
|
|
296
|
+
## State Updates
|
|
297
|
+
|
|
298
|
+
```javascript
|
|
299
|
+
return {
|
|
300
|
+
stateUpdates: {
|
|
301
|
+
proposed_fixes: [...fixes],
|
|
302
|
+
pending_fixes: [...selectedFixIds]
|
|
303
|
+
}
|
|
304
|
+
};
|
|
305
|
+
```
|
|
306
|
+
|
|
307
|
+
## Error Handling
|
|
308
|
+
|
|
309
|
+
| Error Type | Recovery |
|
|
310
|
+
|------------|----------|
|
|
311
|
+
| No issues to fix | Skip to action-complete |
|
|
312
|
+
| User cancels selection | Set pending_fixes to empty |
|
|
313
|
+
|
|
314
|
+
## Next Actions
|
|
315
|
+
|
|
316
|
+
- If pending_fixes.length > 0: action-apply-fix
|
|
317
|
+
- If pending_fixes.length === 0: action-complete
|