claude-code-workflow 7.2.11 → 7.2.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude/commands/workflow/analyze-with-file.md +108 -54
- package/.claude/commands/workflow-tune.md +811 -0
- package/.claude/skills/workflow-lite-execute/SKILL.md +106 -14
- package/.claude/skills/workflow-lite-plan/SKILL.md +34 -72
- package/.claude/skills/workflow-lite-test-review/SKILL.md +39 -26
- package/package.json +1 -1
- package/.claude/commands/ddd/auto.md +0 -359
- package/.claude/commands/ddd/doc-generate.md +0 -222
- package/.claude/commands/ddd/doc-refresh.md +0 -218
- package/.claude/commands/ddd/execute.md +0 -416
- package/.claude/commands/ddd/index-build.md +0 -212
- package/.claude/commands/ddd/plan.md +0 -611
- package/.claude/commands/ddd/scan.md +0 -365
- package/.claude/commands/ddd/sync.md +0 -353
- package/.claude/commands/ddd/update.md +0 -160
- package/.claude/commands/idaw/add.md +0 -287
- package/.claude/commands/idaw/resume.md +0 -442
- package/.claude/commands/idaw/run-coordinate.md +0 -648
- package/.claude/commands/idaw/run.md +0 -539
- package/.claude/commands/idaw/status.md +0 -182
- package/.claude/skills/workflow-tune/SKILL.md +0 -487
- package/.claude/skills/workflow-tune/phases/01-setup.md +0 -548
- package/.claude/skills/workflow-tune/phases/02-step-execute.md +0 -197
- package/.claude/skills/workflow-tune/phases/03-step-analyze.md +0 -386
- package/.claude/skills/workflow-tune/phases/04-synthesize.md +0 -257
- package/.claude/skills/workflow-tune/phases/05-optimize-report.md +0 -246
- package/.claude/skills/workflow-tune/specs/workflow-eval-criteria.md +0 -57
- package/.claude/skills/workflow-tune/templates/step-analysis-prompt.md +0 -88
- package/.claude/skills/workflow-tune/templates/synthesis-prompt.md +0 -90
|
@@ -1,257 +0,0 @@
|
|
|
1
|
-
# Phase 4: Synthesize
|
|
2
|
-
|
|
3
|
-
> **COMPACT SENTINEL [Phase 4: Synthesize]**
|
|
4
|
-
> This phase contains 4 execution steps (Step 4.1 -- 4.4).
|
|
5
|
-
> If you can read this sentinel but cannot find the full Step protocol below, context has been compressed.
|
|
6
|
-
> Recovery: `Read("phases/04-synthesize.md")`
|
|
7
|
-
|
|
8
|
-
Synthesize all step analyses into cross-step insights. Evaluates the workflow as a whole: step ordering, handoff quality, redundancy, bottlenecks, and overall coherence.
|
|
9
|
-
|
|
10
|
-
## Objective
|
|
11
|
-
|
|
12
|
-
- Read complete process-log.md and all step analyses
|
|
13
|
-
- Build synthesis prompt with full workflow context
|
|
14
|
-
- Execute via ccw cli Gemini with resume chain
|
|
15
|
-
- Generate cross-step optimization insights
|
|
16
|
-
- Write synthesis.md
|
|
17
|
-
|
|
18
|
-
## Execution
|
|
19
|
-
|
|
20
|
-
### Step 4.1: Gather All Analyses
|
|
21
|
-
|
|
22
|
-
```javascript
|
|
23
|
-
// Read process log
|
|
24
|
-
const processLog = Read(`${state.work_dir}/process-log.md`);
|
|
25
|
-
|
|
26
|
-
// Read all step analysis files
|
|
27
|
-
const stepAnalyses = state.steps.map((step, i) => {
|
|
28
|
-
const analysisFile = `${state.work_dir}/steps/step-${i + 1}/step-${i + 1}-analysis.md`;
|
|
29
|
-
try {
|
|
30
|
-
return { step: step.name, index: i, content: Read(analysisFile) };
|
|
31
|
-
} catch {
|
|
32
|
-
return { step: step.name, index: i, content: '[Analysis not available]' };
|
|
33
|
-
}
|
|
34
|
-
});
|
|
35
|
-
|
|
36
|
-
// Build score summary
|
|
37
|
-
const scoreSummary = state.steps.map((s, i) =>
|
|
38
|
-
`Step ${i + 1} (${s.name}): ${s.analysis?.quality_score || '-'}/100 | Issues: ${s.analysis?.issue_count || 0} (${s.analysis?.high_issues || 0} high)`
|
|
39
|
-
).join('\n');
|
|
40
|
-
|
|
41
|
-
// Compute aggregate stats
|
|
42
|
-
const scores = state.steps.map(s => s.analysis?.quality_score).filter(Boolean);
|
|
43
|
-
const avgScore = scores.length > 0 ? Math.round(scores.reduce((a, b) => a + b, 0) / scores.length) : 0;
|
|
44
|
-
const minScore = scores.length > 0 ? Math.min(...scores) : 0;
|
|
45
|
-
const totalIssues = state.steps.reduce((sum, s) => sum + (s.analysis?.issue_count || 0), 0);
|
|
46
|
-
const totalHighIssues = state.steps.reduce((sum, s) => sum + (s.analysis?.high_issues || 0), 0);
|
|
47
|
-
```
|
|
48
|
-
|
|
49
|
-
### Step 4.2: Construct Synthesis Prompt
|
|
50
|
-
|
|
51
|
-
```javascript
|
|
52
|
-
// Ref: templates/synthesis-prompt.md
|
|
53
|
-
|
|
54
|
-
const synthesisPrompt = `PURPOSE: Synthesize all step analyses into a holistic workflow optimization assessment. Evaluate cross-step concerns: ordering, handoff quality, redundancy, bottlenecks, and overall workflow coherence.
|
|
55
|
-
|
|
56
|
-
WORKFLOW OVERVIEW:
|
|
57
|
-
Name: ${state.workflow_name}
|
|
58
|
-
Goal: ${state.workflow_context}
|
|
59
|
-
Steps: ${state.steps.length}
|
|
60
|
-
Average Quality: ${avgScore}/100
|
|
61
|
-
Weakest Step: ${minScore}/100
|
|
62
|
-
Total Issues: ${totalIssues} (${totalHighIssues} high severity)
|
|
63
|
-
|
|
64
|
-
SCORE SUMMARY:
|
|
65
|
-
${scoreSummary}
|
|
66
|
-
|
|
67
|
-
COMPLETE PROCESS LOG:
|
|
68
|
-
${processLog}
|
|
69
|
-
|
|
70
|
-
DETAILED STEP ANALYSES:
|
|
71
|
-
${stepAnalyses.map(a => `### ${a.step} (Step ${a.index + 1})\n${a.content}`).join('\n\n---\n\n')}
|
|
72
|
-
|
|
73
|
-
TASK:
|
|
74
|
-
1. **Workflow Coherence**: Do steps form a logical sequence? Any missing steps?
|
|
75
|
-
2. **Handoff Quality**: Are step outputs well-consumed by subsequent steps? Data format mismatches?
|
|
76
|
-
3. **Redundancy Detection**: Do any steps duplicate work? Overlapping concerns?
|
|
77
|
-
4. **Bottleneck Identification**: Which steps are bottlenecks (lowest quality, longest duration)?
|
|
78
|
-
5. **Step Ordering**: Would reordering steps improve outcomes?
|
|
79
|
-
6. **Missing Steps**: Are there gaps in the pipeline that need additional steps?
|
|
80
|
-
7. **Per-Step Optimization**: Top 3 improvements per underperforming step
|
|
81
|
-
8. **Workflow-Level Optimization**: Structural changes to the overall pipeline
|
|
82
|
-
|
|
83
|
-
EXPECTED OUTPUT (strict JSON, no markdown):
|
|
84
|
-
{
|
|
85
|
-
"workflow_score": <0-100>,
|
|
86
|
-
"coherence": {
|
|
87
|
-
"score": <0-100>,
|
|
88
|
-
"assessment": "<logical flow evaluation>",
|
|
89
|
-
"gaps": ["<missing step or transition>"]
|
|
90
|
-
},
|
|
91
|
-
"handoff_quality": {
|
|
92
|
-
"score": <0-100>,
|
|
93
|
-
"issues": [
|
|
94
|
-
{ "from_step": "<step name>", "to_step": "<step name>", "issue": "<description>", "fix": "<suggestion>" }
|
|
95
|
-
]
|
|
96
|
-
},
|
|
97
|
-
"redundancy": {
|
|
98
|
-
"found": <true|false>,
|
|
99
|
-
"items": [
|
|
100
|
-
{ "steps": ["<step1>", "<step2>"], "description": "<what overlaps>", "recommendation": "<merge or remove>" }
|
|
101
|
-
]
|
|
102
|
-
},
|
|
103
|
-
"bottlenecks": [
|
|
104
|
-
{ "step": "<step name>", "reason": "<why it's a bottleneck>", "impact": "high|medium|low", "fix": "<suggestion>" }
|
|
105
|
-
],
|
|
106
|
-
"ordering_suggestions": [
|
|
107
|
-
{ "current": "<current order description>", "proposed": "<new order>", "rationale": "<why>" }
|
|
108
|
-
],
|
|
109
|
-
"per_step_improvements": [
|
|
110
|
-
{ "step": "<step name>", "improvements": [
|
|
111
|
-
{ "priority": "high|medium|low", "description": "<what to change>", "rationale": "<why>" }
|
|
112
|
-
]}
|
|
113
|
-
],
|
|
114
|
-
"workflow_improvements": [
|
|
115
|
-
{ "priority": "high|medium|low", "category": "structure|handoff|performance|quality", "description": "<change>", "rationale": "<why>", "affected_steps": ["<step names>"] }
|
|
116
|
-
],
|
|
117
|
-
"summary": "<2-3 sentence executive summary of workflow health and top recommendations>"
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
CONSTRAINTS: Be specific, reference step names and artifact details, output ONLY JSON`;
|
|
121
|
-
```
|
|
122
|
-
|
|
123
|
-
### Step 4.3: Execute via ccw cli Gemini with Resume
|
|
124
|
-
|
|
125
|
-
```javascript
|
|
126
|
-
function escapeForShell(str) {
|
|
127
|
-
return str.replace(/"/g, '\\"').replace(/\$/g, '\\$').replace(/`/g, '\\`');
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
let cliCommand = `ccw cli -p "${escapeForShell(synthesisPrompt)}" --tool gemini --mode analysis`;
|
|
131
|
-
|
|
132
|
-
// Resume from the last step's analysis session
|
|
133
|
-
if (state.analysis_session_id) {
|
|
134
|
-
cliCommand += ` --resume ${state.analysis_session_id}`;
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
Bash({
|
|
138
|
-
command: cliCommand,
|
|
139
|
-
run_in_background: true,
|
|
140
|
-
timeout: 300000
|
|
141
|
-
});
|
|
142
|
-
|
|
143
|
-
// STOP — wait for hook callback
|
|
144
|
-
```
|
|
145
|
-
|
|
146
|
-
### Step 4.4: Parse Results and Write Synthesis
|
|
147
|
-
|
|
148
|
-
After CLI completes:
|
|
149
|
-
|
|
150
|
-
```javascript
|
|
151
|
-
const rawOutput = /* CLI output from callback */;
|
|
152
|
-
const jsonMatch = rawOutput.match(/\{[\s\S]*\}/);
|
|
153
|
-
let synthesis;
|
|
154
|
-
|
|
155
|
-
if (jsonMatch) {
|
|
156
|
-
try {
|
|
157
|
-
synthesis = JSON.parse(jsonMatch[0]);
|
|
158
|
-
} catch {
|
|
159
|
-
synthesis = {
|
|
160
|
-
workflow_score: avgScore,
|
|
161
|
-
summary: 'Synthesis parsing failed — individual step analyses available',
|
|
162
|
-
workflow_improvements: [],
|
|
163
|
-
per_step_improvements: [],
|
|
164
|
-
bottlenecks: [],
|
|
165
|
-
handoff_quality: { score: 0, issues: [] },
|
|
166
|
-
coherence: { score: 0, assessment: 'Parse error' },
|
|
167
|
-
redundancy: { found: false, items: [] },
|
|
168
|
-
ordering_suggestions: []
|
|
169
|
-
};
|
|
170
|
-
}
|
|
171
|
-
} else {
|
|
172
|
-
synthesis = {
|
|
173
|
-
workflow_score: avgScore,
|
|
174
|
-
summary: 'No synthesis output received',
|
|
175
|
-
workflow_improvements: [],
|
|
176
|
-
per_step_improvements: []
|
|
177
|
-
};
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
// Write synthesis report
|
|
181
|
-
const synthesisReport = `# Workflow Synthesis
|
|
182
|
-
|
|
183
|
-
**Workflow Score**: ${synthesis.workflow_score}/100
|
|
184
|
-
**Date**: ${new Date().toISOString()}
|
|
185
|
-
|
|
186
|
-
## Executive Summary
|
|
187
|
-
${synthesis.summary}
|
|
188
|
-
|
|
189
|
-
## Coherence (${synthesis.coherence?.score || '-'}/100)
|
|
190
|
-
${synthesis.coherence?.assessment || 'N/A'}
|
|
191
|
-
${(synthesis.coherence?.gaps || []).length > 0 ? '\n### Gaps\n' + synthesis.coherence.gaps.map(g => `- ${g}`).join('\n') : ''}
|
|
192
|
-
|
|
193
|
-
## Handoff Quality (${synthesis.handoff_quality?.score || '-'}/100)
|
|
194
|
-
${(synthesis.handoff_quality?.issues || []).map(i =>
|
|
195
|
-
`- **${i.from_step} → ${i.to_step}**: ${i.issue}\n Fix: ${i.fix}`
|
|
196
|
-
).join('\n') || 'No handoff issues'}
|
|
197
|
-
|
|
198
|
-
## Redundancy
|
|
199
|
-
${synthesis.redundancy?.found ? (synthesis.redundancy.items || []).map(r =>
|
|
200
|
-
`- Steps ${r.steps.join(', ')}: ${r.description} → ${r.recommendation}`
|
|
201
|
-
).join('\n') : 'No redundancy detected'}
|
|
202
|
-
|
|
203
|
-
## Bottlenecks
|
|
204
|
-
${(synthesis.bottlenecks || []).map(b =>
|
|
205
|
-
`- **${b.step}** [${b.impact}]: ${b.reason}\n Fix: ${b.fix}`
|
|
206
|
-
).join('\n') || 'No bottlenecks'}
|
|
207
|
-
|
|
208
|
-
## Ordering Suggestions
|
|
209
|
-
${(synthesis.ordering_suggestions || []).map(o =>
|
|
210
|
-
`- Current: ${o.current}\n Proposed: ${o.proposed}\n Rationale: ${o.rationale}`
|
|
211
|
-
).join('\n') || 'Current ordering is optimal'}
|
|
212
|
-
|
|
213
|
-
## Per-Step Improvements
|
|
214
|
-
${(synthesis.per_step_improvements || []).map(s =>
|
|
215
|
-
`### ${s.step}\n` + (s.improvements || []).map(i =>
|
|
216
|
-
`- [${i.priority}] ${i.description} — ${i.rationale}`
|
|
217
|
-
).join('\n')
|
|
218
|
-
).join('\n\n') || 'No per-step improvements'}
|
|
219
|
-
|
|
220
|
-
## Workflow-Level Improvements
|
|
221
|
-
${(synthesis.workflow_improvements || []).map((w, i) =>
|
|
222
|
-
`### ${i + 1}. [${w.priority}] ${w.description}\n- Category: ${w.category}\n- Rationale: ${w.rationale}\n- Affected: ${(w.affected_steps || []).join(', ')}`
|
|
223
|
-
).join('\n\n') || 'No workflow-level improvements'}
|
|
224
|
-
`;
|
|
225
|
-
|
|
226
|
-
Write(`${state.work_dir}/synthesis.md`, synthesisReport);
|
|
227
|
-
|
|
228
|
-
// Update state
|
|
229
|
-
state.synthesis = {
|
|
230
|
-
workflow_score: synthesis.workflow_score,
|
|
231
|
-
summary: synthesis.summary,
|
|
232
|
-
improvement_count: (synthesis.workflow_improvements || []).length +
|
|
233
|
-
(synthesis.per_step_improvements || []).reduce((sum, s) => sum + (s.improvements || []).length, 0),
|
|
234
|
-
high_priority_count: (synthesis.workflow_improvements || []).filter(w => w.priority === 'high').length,
|
|
235
|
-
bottleneck_count: (synthesis.bottlenecks || []).length,
|
|
236
|
-
handoff_issue_count: (synthesis.handoff_quality?.issues || []).length,
|
|
237
|
-
synthesis_file: `${state.work_dir}/synthesis.md`,
|
|
238
|
-
raw_data: synthesis
|
|
239
|
-
};
|
|
240
|
-
|
|
241
|
-
state.updated_at = new Date().toISOString();
|
|
242
|
-
Write(`${state.work_dir}/workflow-state.json`, JSON.stringify(state, null, 2));
|
|
243
|
-
```
|
|
244
|
-
|
|
245
|
-
## Error Handling
|
|
246
|
-
|
|
247
|
-
| Error | Recovery |
|
|
248
|
-
|-------|----------|
|
|
249
|
-
| CLI timeout | Generate synthesis from individual step analyses only (no cross-step) |
|
|
250
|
-
| Resume fails | Start fresh analysis session |
|
|
251
|
-
| JSON parse fails | Use step-level data to construct minimal synthesis |
|
|
252
|
-
|
|
253
|
-
## Output
|
|
254
|
-
|
|
255
|
-
- **Files**: `synthesis.md`
|
|
256
|
-
- **State**: `state.synthesis` updated
|
|
257
|
-
- **Next**: Phase 5 (Optimization Report)
|
|
@@ -1,246 +0,0 @@
|
|
|
1
|
-
# Phase 5: Optimization Report
|
|
2
|
-
|
|
3
|
-
> **COMPACT SENTINEL [Phase 5: Report]**
|
|
4
|
-
> This phase contains 4 execution steps (Step 5.1 -- 5.4).
|
|
5
|
-
> If you can read this sentinel but cannot find the full Step protocol below, context has been compressed.
|
|
6
|
-
> Recovery: `Read("phases/05-optimize-report.md")`
|
|
7
|
-
|
|
8
|
-
Generate the final optimization report and optionally apply high-priority fixes.
|
|
9
|
-
|
|
10
|
-
## Objective
|
|
11
|
-
|
|
12
|
-
- Read complete state, process log, synthesis
|
|
13
|
-
- Generate structured final report
|
|
14
|
-
- Optionally apply auto-fix (if enabled)
|
|
15
|
-
- Write final-report.md
|
|
16
|
-
- Display summary to user
|
|
17
|
-
|
|
18
|
-
## Execution
|
|
19
|
-
|
|
20
|
-
### Step 5.1: Read Complete State
|
|
21
|
-
|
|
22
|
-
```javascript
|
|
23
|
-
const state = JSON.parse(Read(`${state.work_dir}/workflow-state.json`));
|
|
24
|
-
const processLog = Read(`${state.work_dir}/process-log.md`);
|
|
25
|
-
const synthesis = state.synthesis;
|
|
26
|
-
state.status = 'completed';
|
|
27
|
-
state.updated_at = new Date().toISOString();
|
|
28
|
-
```
|
|
29
|
-
|
|
30
|
-
### Step 5.2: Generate Report
|
|
31
|
-
|
|
32
|
-
```javascript
|
|
33
|
-
// Compute stats
|
|
34
|
-
const scores = state.steps.map(s => s.analysis?.quality_score).filter(Boolean);
|
|
35
|
-
const avgScore = scores.length > 0 ? Math.round(scores.reduce((a, b) => a + b, 0) / scores.length) : 0;
|
|
36
|
-
const minStep = state.steps.reduce((min, s) =>
|
|
37
|
-
(s.analysis?.quality_score || 100) < (min.analysis?.quality_score || 100) ? s : min
|
|
38
|
-
, state.steps[0]);
|
|
39
|
-
|
|
40
|
-
const totalIssues = state.steps.reduce((sum, s) => sum + (s.analysis?.issue_count || 0), 0);
|
|
41
|
-
const totalHighIssues = state.steps.reduce((sum, s) => sum + (s.analysis?.high_issues || 0), 0);
|
|
42
|
-
|
|
43
|
-
// Step quality table (with requirement match)
|
|
44
|
-
const stepTable = state.steps.map((s, i) => {
|
|
45
|
-
const reqPass = s.analysis?.requirement_pass;
|
|
46
|
-
const reqStr = reqPass === true ? 'PASS' : reqPass === false ? 'FAIL' : '-';
|
|
47
|
-
return `| ${i + 1} | ${s.name} | ${s.type} | ${s.execution?.success ? 'OK' : 'FAIL'} | ${reqStr} | ${s.analysis?.quality_score || '-'} | ${s.analysis?.issue_count || 0} | ${s.analysis?.high_issues || 0} |`;
|
|
48
|
-
}).join('\n');
|
|
49
|
-
|
|
50
|
-
// Collect all improvements (workflow-level + per-step)
|
|
51
|
-
const allImprovements = [];
|
|
52
|
-
if (synthesis?.raw_data?.workflow_improvements) {
|
|
53
|
-
synthesis.raw_data.workflow_improvements.forEach(w => {
|
|
54
|
-
allImprovements.push({
|
|
55
|
-
scope: 'workflow',
|
|
56
|
-
priority: w.priority,
|
|
57
|
-
description: w.description,
|
|
58
|
-
rationale: w.rationale,
|
|
59
|
-
category: w.category,
|
|
60
|
-
affected: w.affected_steps || []
|
|
61
|
-
});
|
|
62
|
-
});
|
|
63
|
-
}
|
|
64
|
-
if (synthesis?.raw_data?.per_step_improvements) {
|
|
65
|
-
synthesis.raw_data.per_step_improvements.forEach(s => {
|
|
66
|
-
(s.improvements || []).forEach(imp => {
|
|
67
|
-
allImprovements.push({
|
|
68
|
-
scope: s.step,
|
|
69
|
-
priority: imp.priority,
|
|
70
|
-
description: imp.description,
|
|
71
|
-
rationale: imp.rationale,
|
|
72
|
-
category: 'step',
|
|
73
|
-
affected: [s.step]
|
|
74
|
-
});
|
|
75
|
-
});
|
|
76
|
-
});
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
// Sort by priority
|
|
80
|
-
const priorityOrder = { high: 0, medium: 1, low: 2 };
|
|
81
|
-
allImprovements.sort((a, b) => (priorityOrder[a.priority] || 2) - (priorityOrder[b.priority] || 2));
|
|
82
|
-
|
|
83
|
-
const report = `# Workflow Tune — Final Report
|
|
84
|
-
|
|
85
|
-
## Summary
|
|
86
|
-
|
|
87
|
-
| Field | Value |
|
|
88
|
-
|-------|-------|
|
|
89
|
-
| **Workflow** | ${state.workflow_name} |
|
|
90
|
-
| **Goal** | ${state.workflow_context} |
|
|
91
|
-
| **Steps** | ${state.steps.length} |
|
|
92
|
-
| **Workflow Score** | ${synthesis?.workflow_score || avgScore}/100 |
|
|
93
|
-
| **Average Step Quality** | ${avgScore}/100 |
|
|
94
|
-
| **Weakest Step** | ${minStep.name} (${minStep.analysis?.quality_score || '-'}/100) |
|
|
95
|
-
| **Total Issues** | ${totalIssues} (${totalHighIssues} high severity) |
|
|
96
|
-
| **Analysis Depth** | ${state.analysis_depth} |
|
|
97
|
-
| **Started** | ${state.started_at} |
|
|
98
|
-
| **Completed** | ${state.updated_at} |
|
|
99
|
-
|
|
100
|
-
## Step Quality Matrix
|
|
101
|
-
|
|
102
|
-
| # | Step | Type | Exec | Req Match | Quality | Issues | High |
|
|
103
|
-
|---|------|------|------|-----------|---------|--------|------|
|
|
104
|
-
${stepTable}
|
|
105
|
-
|
|
106
|
-
## Workflow Flow Assessment
|
|
107
|
-
|
|
108
|
-
### Coherence: ${synthesis?.raw_data?.coherence?.score || '-'}/100
|
|
109
|
-
${synthesis?.raw_data?.coherence?.assessment || 'Not evaluated'}
|
|
110
|
-
|
|
111
|
-
### Handoff Quality: ${synthesis?.raw_data?.handoff_quality?.score || '-'}/100
|
|
112
|
-
${(synthesis?.raw_data?.handoff_quality?.issues || []).map(i =>
|
|
113
|
-
`- **${i.from_step} → ${i.to_step}**: ${i.issue}`
|
|
114
|
-
).join('\n') || 'No handoff issues'}
|
|
115
|
-
|
|
116
|
-
### Bottlenecks
|
|
117
|
-
${(synthesis?.raw_data?.bottlenecks || []).map(b =>
|
|
118
|
-
`- **${b.step}** [${b.impact}]: ${b.reason}`
|
|
119
|
-
).join('\n') || 'No bottlenecks identified'}
|
|
120
|
-
|
|
121
|
-
## Optimization Recommendations
|
|
122
|
-
|
|
123
|
-
### Priority: HIGH
|
|
124
|
-
${allImprovements.filter(i => i.priority === 'high').map((i, idx) =>
|
|
125
|
-
`${idx + 1}. **[${i.scope}]** ${i.description}\n - Rationale: ${i.rationale}\n - Affected: ${i.affected.join(', ')}`
|
|
126
|
-
).join('\n') || 'None'}
|
|
127
|
-
|
|
128
|
-
### Priority: MEDIUM
|
|
129
|
-
${allImprovements.filter(i => i.priority === 'medium').map((i, idx) =>
|
|
130
|
-
`${idx + 1}. **[${i.scope}]** ${i.description}\n - Rationale: ${i.rationale}`
|
|
131
|
-
).join('\n') || 'None'}
|
|
132
|
-
|
|
133
|
-
### Priority: LOW
|
|
134
|
-
${allImprovements.filter(i => i.priority === 'low').map((i, idx) =>
|
|
135
|
-
`${idx + 1}. **[${i.scope}]** ${i.description}`
|
|
136
|
-
).join('\n') || 'None'}
|
|
137
|
-
|
|
138
|
-
## Process Documentation
|
|
139
|
-
|
|
140
|
-
Full process log: \`${state.work_dir}/process-log.md\`
|
|
141
|
-
Synthesis: \`${state.work_dir}/synthesis.md\`
|
|
142
|
-
|
|
143
|
-
### Per-Step Analysis Files
|
|
144
|
-
|
|
145
|
-
| Step | Analysis File |
|
|
146
|
-
|------|---------------|
|
|
147
|
-
${state.steps.map((s, i) =>
|
|
148
|
-
`| ${s.name} | \`${state.work_dir}/steps/step-${i + 1}/step-${i + 1}-analysis.md\` |`
|
|
149
|
-
).join('\n')}
|
|
150
|
-
|
|
151
|
-
## Artifact Locations
|
|
152
|
-
|
|
153
|
-
| Path | Description |
|
|
154
|
-
|------|-------------|
|
|
155
|
-
| \`${state.work_dir}/workflow-state.json\` | Complete state |
|
|
156
|
-
| \`${state.work_dir}/process-log.md\` | Accumulated process log |
|
|
157
|
-
| \`${state.work_dir}/synthesis.md\` | Cross-step synthesis |
|
|
158
|
-
| \`${state.work_dir}/final-report.md\` | This report |
|
|
159
|
-
`;
|
|
160
|
-
|
|
161
|
-
Write(`${state.work_dir}/final-report.md`, report);
|
|
162
|
-
```
|
|
163
|
-
|
|
164
|
-
### Step 5.3: Optional Auto-Fix
|
|
165
|
-
|
|
166
|
-
```javascript
|
|
167
|
-
if (state.auto_fix && allImprovements.filter(i => i.priority === 'high').length > 0) {
|
|
168
|
-
const highPriorityFixes = allImprovements.filter(i => i.priority === 'high');
|
|
169
|
-
|
|
170
|
-
// ★ Safety: confirm with user before applying auto-fixes
|
|
171
|
-
const fixList = highPriorityFixes.map((f, i) =>
|
|
172
|
-
`${i + 1}. [${f.scope}] ${f.description}\n Affected: ${f.affected.join(', ')}`
|
|
173
|
-
).join('\n');
|
|
174
|
-
|
|
175
|
-
const autoFixConfirm = AskUserQuestion({
|
|
176
|
-
questions: [{
|
|
177
|
-
question: `以下 ${highPriorityFixes.length} 项高优先级优化将被自动应用:\n\n${fixList}\n\n确认应用?`,
|
|
178
|
-
header: "Auto-Fix Confirmation",
|
|
179
|
-
multiSelect: false,
|
|
180
|
-
options: [
|
|
181
|
-
{ label: "Apply (应用)", description: "自动应用以上高优先级修复" },
|
|
182
|
-
{ label: "Skip (跳过)", description: "跳过自动修复,仅保留报告" }
|
|
183
|
-
]
|
|
184
|
-
}]
|
|
185
|
-
});
|
|
186
|
-
|
|
187
|
-
if (autoFixConfirm["Auto-Fix Confirmation"].startsWith("Skip")) {
|
|
188
|
-
// Skip auto-fix, just log it
|
|
189
|
-
state.auto_fix_skipped = true;
|
|
190
|
-
} else {
|
|
191
|
-
|
|
192
|
-
Agent({
|
|
193
|
-
subagent_type: 'general-purpose',
|
|
194
|
-
run_in_background: false,
|
|
195
|
-
description: 'Apply high-priority workflow optimizations',
|
|
196
|
-
prompt: `## Task: Apply High-Priority Workflow Optimizations
|
|
197
|
-
|
|
198
|
-
You are applying the top optimization suggestions from a workflow analysis.
|
|
199
|
-
|
|
200
|
-
## Improvements to Apply (HIGH priority only)
|
|
201
|
-
${highPriorityFixes.map((f, i) =>
|
|
202
|
-
`${i + 1}. [${f.scope}] ${f.description}\n Rationale: ${f.rationale}\n Affected: ${f.affected.join(', ')}`
|
|
203
|
-
).join('\n')}
|
|
204
|
-
|
|
205
|
-
## Workflow Steps
|
|
206
|
-
${state.steps.map((s, i) => `${i + 1}. ${s.name} (${s.type}): ${s.command}`).join('\n')}
|
|
207
|
-
|
|
208
|
-
## Rules
|
|
209
|
-
1. Read each affected file BEFORE modifying
|
|
210
|
-
2. Apply ONLY the high-priority suggestions
|
|
211
|
-
3. Preserve existing code style
|
|
212
|
-
4. Write a changes summary to: ${state.work_dir}/auto-fix-changes.md
|
|
213
|
-
`
|
|
214
|
-
});
|
|
215
|
-
|
|
216
|
-
} // end Apply branch
|
|
217
|
-
}
|
|
218
|
-
```
|
|
219
|
-
|
|
220
|
-
### Step 5.4: Display Summary
|
|
221
|
-
|
|
222
|
-
Output to user:
|
|
223
|
-
|
|
224
|
-
```
|
|
225
|
-
Workflow Tune Complete!
|
|
226
|
-
|
|
227
|
-
Workflow: {name}
|
|
228
|
-
Steps: {count}
|
|
229
|
-
Workflow Score: {score}/100
|
|
230
|
-
Average Step Quality: {avgScore}/100
|
|
231
|
-
Weakest Step: {name} ({score}/100)
|
|
232
|
-
|
|
233
|
-
Step Scores: {step1}={score1} → {step2}={score2} → ... → {stepN}={scoreN}
|
|
234
|
-
|
|
235
|
-
Issues: {total} ({high} high priority)
|
|
236
|
-
Improvements: {count} ({highCount} high priority)
|
|
237
|
-
|
|
238
|
-
Full report: {workDir}/final-report.md
|
|
239
|
-
Process log: {workDir}/process-log.md
|
|
240
|
-
```
|
|
241
|
-
|
|
242
|
-
## Output
|
|
243
|
-
|
|
244
|
-
- **Files**: `final-report.md`, optionally `auto-fix-changes.md`
|
|
245
|
-
- **State**: `status = completed`
|
|
246
|
-
- **Next**: Workflow complete. Return control to user.
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
# Workflow Evaluation Criteria
|
|
2
|
-
|
|
3
|
-
Workflow 调优评估标准,由 Phase 03 (Analyze Step) 和 Phase 04 (Synthesize) 引用。
|
|
4
|
-
|
|
5
|
-
## Per-Step Dimensions
|
|
6
|
-
|
|
7
|
-
| Dimension | Description |
|
|
8
|
-
|-----------|-------------|
|
|
9
|
-
| Execution Success | 命令是否成功执行,退出码是否正确 |
|
|
10
|
-
| Output Completeness | 产物是否齐全,预期文件是否生成 |
|
|
11
|
-
| Artifact Quality | 产物内容质量 — 非空、格式正确、内容有意义 |
|
|
12
|
-
| Handoff Readiness | 产物是否满足下一步的输入要求,格式兼容性 |
|
|
13
|
-
|
|
14
|
-
## Per-Step Scoring Guide
|
|
15
|
-
|
|
16
|
-
| Range | Level | Description |
|
|
17
|
-
|-------|-------|-------------|
|
|
18
|
-
| 90-100 | Excellent | 执行完美,产物高质量,下游可直接消费 |
|
|
19
|
-
| 80-89 | Good | 执行成功,产物基本完整,微调即可衔接 |
|
|
20
|
-
| 70-79 | Adequate | 执行成功但产物有缺失或质量一般 |
|
|
21
|
-
| 60-69 | Needs Work | 部分失败或产物质量差,衔接困难 |
|
|
22
|
-
| 0-59 | Poor | 执行失败或产物无法使用 |
|
|
23
|
-
|
|
24
|
-
## Workflow-Level Dimensions
|
|
25
|
-
|
|
26
|
-
| Dimension | Description |
|
|
27
|
-
|-----------|-------------|
|
|
28
|
-
| Coherence | 步骤间的逻辑顺序是否合理,是否形成完整流程 |
|
|
29
|
-
| Handoff Quality | 步骤间的数据传递是否顺畅,格式是否匹配 |
|
|
30
|
-
| Redundancy | 是否存在步骤间的工作重叠或重复 |
|
|
31
|
-
| Efficiency | 整体流程是否高效,有无不必要的步骤 |
|
|
32
|
-
| Completeness | 是否覆盖所有必要环节,有无遗漏 |
|
|
33
|
-
|
|
34
|
-
## Analysis Depth Profiles
|
|
35
|
-
|
|
36
|
-
### Quick
|
|
37
|
-
- 每步 3-5 要点
|
|
38
|
-
- 关注: 执行成功、产出完整、明显问题
|
|
39
|
-
- 跨步骤: 基本衔接检查
|
|
40
|
-
|
|
41
|
-
### Standard
|
|
42
|
-
- 每步详细评估
|
|
43
|
-
- 关注: 执行质量、产出完整性、产物质量、衔接就绪度、潜在问题
|
|
44
|
-
- 跨步骤: 衔接质量、冗余检测、瓶颈识别
|
|
45
|
-
|
|
46
|
-
### Deep
|
|
47
|
-
- 每步深度审查
|
|
48
|
-
- 关注: 执行质量、产出正确性、结构质量、衔接完整性、错误处理、性能信号、架构影响、边界情况
|
|
49
|
-
- 跨步骤: 全面流程优化、重排建议、缺失步骤检测、架构改进
|
|
50
|
-
|
|
51
|
-
## Issue Severity Guide
|
|
52
|
-
|
|
53
|
-
| Severity | Description | Example |
|
|
54
|
-
|----------|-------------|---------|
|
|
55
|
-
| High | 阻断流程或导致错误结果 | 步骤执行失败、产物格式不兼容、关键数据丢失 |
|
|
56
|
-
| Medium | 影响质量但不阻断 | 产物不完整、衔接需手动调整、冗余步骤 |
|
|
57
|
-
| Low | 可改进但不影响功能 | 输出格式不一致、可优化的步骤顺序 |
|
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
# Step Analysis Prompt Template
|
|
2
|
-
|
|
3
|
-
Phase 03 使用此模板构造 ccw cli 提示词,让 Gemini 分析单个步骤的执行结果和产物质量。
|
|
4
|
-
|
|
5
|
-
## Template
|
|
6
|
-
|
|
7
|
-
```
|
|
8
|
-
PURPOSE: Analyze the output of workflow step "${stepName}" (step ${stepIndex}/${totalSteps}) to assess quality, identify issues, and evaluate handoff readiness for the next step.
|
|
9
|
-
|
|
10
|
-
WORKFLOW CONTEXT:
|
|
11
|
-
Name: ${workflowName}
|
|
12
|
-
Goal: ${workflowContext}
|
|
13
|
-
Step Chain:
|
|
14
|
-
${stepChainContext}
|
|
15
|
-
|
|
16
|
-
CURRENT STEP:
|
|
17
|
-
Name: ${stepName}
|
|
18
|
-
Type: ${stepType}
|
|
19
|
-
Command: ${stepCommand}
|
|
20
|
-
${successCriteria}
|
|
21
|
-
|
|
22
|
-
EXECUTION RESULT:
|
|
23
|
-
${execSummary}
|
|
24
|
-
|
|
25
|
-
${handoffContext}
|
|
26
|
-
|
|
27
|
-
STEP ARTIFACTS:
|
|
28
|
-
${artifactSummary}
|
|
29
|
-
|
|
30
|
-
ANALYSIS DEPTH: ${analysisDepth}
|
|
31
|
-
${depthInstructions}
|
|
32
|
-
|
|
33
|
-
TASK:
|
|
34
|
-
1. Assess step execution quality (did it succeed? complete output?)
|
|
35
|
-
2. Evaluate artifact quality (content correctness, completeness, format)
|
|
36
|
-
3. Check handoff readiness (can the next step consume this output?)
|
|
37
|
-
4. Identify issues, risks, or optimization opportunities
|
|
38
|
-
5. Rate overall step quality 0-100
|
|
39
|
-
|
|
40
|
-
EXPECTED OUTPUT (strict JSON, no markdown):
|
|
41
|
-
{
|
|
42
|
-
"quality_score": <0-100>,
|
|
43
|
-
"execution_assessment": {
|
|
44
|
-
"success": <true|false>,
|
|
45
|
-
"completeness": "<complete|partial|failed>",
|
|
46
|
-
"notes": "<brief assessment>"
|
|
47
|
-
},
|
|
48
|
-
"artifact_assessment": {
|
|
49
|
-
"count": <number>,
|
|
50
|
-
"quality": "<high|medium|low>",
|
|
51
|
-
"key_outputs": ["<main output 1>", "<main output 2>"],
|
|
52
|
-
"missing_outputs": ["<expected but missing>"]
|
|
53
|
-
},
|
|
54
|
-
"handoff_assessment": {
|
|
55
|
-
"ready": <true|false>,
|
|
56
|
-
"next_step_compatible": <true|false|null>,
|
|
57
|
-
"handoff_notes": "<what next step should know>"
|
|
58
|
-
},
|
|
59
|
-
"issues": [
|
|
60
|
-
{ "severity": "high|medium|low", "description": "<issue>", "suggestion": "<fix>" }
|
|
61
|
-
],
|
|
62
|
-
"optimization_opportunities": [
|
|
63
|
-
{ "area": "<area>", "description": "<opportunity>", "impact": "high|medium|low" }
|
|
64
|
-
],
|
|
65
|
-
"step_summary": "<1-2 sentence summary for process log>"
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
CONSTRAINTS: Be specific, reference artifact content where possible, output ONLY JSON
|
|
69
|
-
```
|
|
70
|
-
|
|
71
|
-
## Variable Substitution
|
|
72
|
-
|
|
73
|
-
| Variable | Source | Description |
|
|
74
|
-
|----------|--------|-------------|
|
|
75
|
-
| `${stepName}` | workflow-state.json | 当前步骤名称 |
|
|
76
|
-
| `${stepIndex}` | orchestrator loop | 当前步骤序号 (1-based) |
|
|
77
|
-
| `${totalSteps}` | workflow-state.json | 总步骤数 |
|
|
78
|
-
| `${workflowName}` | workflow-state.json | Workflow 名称 |
|
|
79
|
-
| `${workflowContext}` | workflow-state.json | Workflow 目标描述 |
|
|
80
|
-
| `${stepChainContext}` | Phase 03 builds | 所有步骤状态概览 |
|
|
81
|
-
| `${stepType}` | workflow-state.json | 步骤类型 (skill/ccw-cli/command) |
|
|
82
|
-
| `${stepCommand}` | workflow-state.json | 步骤命令 |
|
|
83
|
-
| `${successCriteria}` | workflow-state.json | 成功标准 (如有) |
|
|
84
|
-
| `${execSummary}` | Phase 03 builds | 执行结果摘要 |
|
|
85
|
-
| `${handoffContext}` | Phase 03 builds | 上一步的产出摘要 (非首步) |
|
|
86
|
-
| `${artifactSummary}` | Phase 03 builds | 产物内容摘要 |
|
|
87
|
-
| `${analysisDepth}` | workflow-state.json | 分析深度 (quick/standard/deep) |
|
|
88
|
-
| `${depthInstructions}` | Phase 03 maps | 对应深度的分析指令 |
|