feat: add workflow-tune skill for multi-step workflow pipeline optimization

New skill that executes workflow step chains sequentially, inspects artifacts,
analyzes quality via ccw cli resume chain (Gemini), and generates optimization
reports. Supports 4 input formats: pipe-separated commands, comma-separated
skills, JSON file, and natural language with semantic decomposition.

Key features:
- Orchestrator + 5-phase progressive loading architecture
- Intent-to-tool mapping with ambiguity resolution for NL input
- Command document generation with pre-execution confirmation loop
- Per-step analysis + cross-step synthesis via resume chain
- Auto-fix with user confirmation safety gate

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
catlog22
2026-03-20 14:55:47 +08:00
parent 26a7371a20
commit d5b6480528
9 changed files with 2187 additions and 0 deletions

View File

@@ -0,0 +1,88 @@
# Step Analysis Prompt Template
Phase 03 使用此模板构造 ccw cli 提示词,让 Gemini 分析单个步骤的执行结果和产物质量。
## Template
```
PURPOSE: Analyze the output of workflow step "${stepName}" (step ${stepIndex}/${totalSteps}) to assess quality, identify issues, and evaluate handoff readiness for the next step.
WORKFLOW CONTEXT:
Name: ${workflowName}
Goal: ${workflowContext}
Step Chain:
${stepChainContext}
CURRENT STEP:
Name: ${stepName}
Type: ${stepType}
Command: ${stepCommand}
${successCriteria}
EXECUTION RESULT:
${execSummary}
${handoffContext}
STEP ARTIFACTS:
${artifactSummary}
ANALYSIS DEPTH: ${analysisDepth}
${depthInstructions}
TASK:
1. Assess step execution quality (did it succeed? complete output?)
2. Evaluate artifact quality (content correctness, completeness, format)
3. Check handoff readiness (can the next step consume this output?)
4. Identify issues, risks, or optimization opportunities
5. Rate overall step quality 0-100
EXPECTED OUTPUT (strict JSON, no markdown):
{
"quality_score": <0-100>,
"execution_assessment": {
"success": <true|false>,
"completeness": "<complete|partial|failed>",
"notes": "<brief assessment>"
},
"artifact_assessment": {
"count": <number>,
"quality": "<high|medium|low>",
"key_outputs": ["<main output 1>", "<main output 2>"],
"missing_outputs": ["<expected but missing>"]
},
"handoff_assessment": {
"ready": <true|false>,
"next_step_compatible": <true|false|null>,
"handoff_notes": "<what next step should know>"
},
"issues": [
{ "severity": "high|medium|low", "description": "<issue>", "suggestion": "<fix>" }
],
"optimization_opportunities": [
{ "area": "<area>", "description": "<opportunity>", "impact": "high|medium|low" }
],
"step_summary": "<1-2 sentence summary for process log>"
}
CONSTRAINTS: Be specific, reference artifact content where possible, output ONLY JSON
```
## Variable Substitution
| Variable | Source | Description |
|----------|--------|-------------|
| `${stepName}` | workflow-state.json | 当前步骤名称 |
| `${stepIndex}` | orchestrator loop | 当前步骤序号 (1-based) |
| `${totalSteps}` | workflow-state.json | 总步骤数 |
| `${workflowName}` | workflow-state.json | Workflow 名称 |
| `${workflowContext}` | workflow-state.json | Workflow 目标描述 |
| `${stepChainContext}` | Phase 03 builds | 所有步骤状态概览 |
| `${stepType}` | workflow-state.json | 步骤类型 (skill/ccw-cli/command) |
| `${stepCommand}` | workflow-state.json | 步骤命令 |
| `${successCriteria}` | workflow-state.json | 成功标准 (如有) |
| `${execSummary}` | Phase 03 builds | 执行结果摘要 |
| `${handoffContext}` | Phase 03 builds | 上一步的产出摘要 (非首步) |
| `${artifactSummary}` | Phase 03 builds | 产物内容摘要 |
| `${analysisDepth}` | workflow-state.json | 分析深度 (quick/standard/deep) |
| `${depthInstructions}` | Phase 03 maps | 对应深度的分析指令 |

View File

@@ -0,0 +1,90 @@
# Synthesis Prompt Template
Phase 04 使用此模板构造 ccw cli 提示词,让 Gemini 综合所有步骤分析,产出跨步骤优化建议。
## Template
```
PURPOSE: Synthesize all step analyses into a holistic workflow optimization assessment. Evaluate cross-step concerns: ordering, handoff quality, redundancy, bottlenecks, and overall workflow coherence.
WORKFLOW OVERVIEW:
Name: ${workflowName}
Goal: ${workflowContext}
Steps: ${stepCount}
Average Quality: ${avgScore}/100
Weakest Step: ${minScore}/100
Total Issues: ${totalIssues} (${totalHighIssues} high severity)
SCORE SUMMARY:
${scoreSummary}
COMPLETE PROCESS LOG:
${processLog}
DETAILED STEP ANALYSES:
${stepAnalyses}
TASK:
1. **Workflow Coherence**: Do steps form a logical sequence? Any missing steps?
2. **Handoff Quality**: Are step outputs well-consumed by subsequent steps? Data format mismatches?
3. **Redundancy Detection**: Do any steps duplicate work? Overlapping concerns?
4. **Bottleneck Identification**: Which steps are bottlenecks (lowest quality, longest duration)?
5. **Step Ordering**: Would reordering steps improve outcomes?
6. **Missing Steps**: Are there gaps in the pipeline that need additional steps?
7. **Per-Step Optimization**: Top 3 improvements per underperforming step
8. **Workflow-Level Optimization**: Structural changes to the overall pipeline
EXPECTED OUTPUT (strict JSON, no markdown):
{
"workflow_score": <0-100>,
"coherence": {
"score": <0-100>,
"assessment": "<logical flow evaluation>",
"gaps": ["<missing step or transition>"]
},
"handoff_quality": {
"score": <0-100>,
"issues": [
{ "from_step": "<step name>", "to_step": "<step name>", "issue": "<description>", "fix": "<suggestion>" }
]
},
"redundancy": {
"found": <true|false>,
"items": [
{ "steps": ["<step1>", "<step2>"], "description": "<what overlaps>", "recommendation": "<merge or remove>" }
]
},
"bottlenecks": [
{ "step": "<step name>", "reason": "<why it's a bottleneck>", "impact": "high|medium|low", "fix": "<suggestion>" }
],
"ordering_suggestions": [
{ "current": "<current order description>", "proposed": "<new order>", "rationale": "<why>" }
],
"per_step_improvements": [
{ "step": "<step name>", "improvements": [
{ "priority": "high|medium|low", "description": "<what to change>", "rationale": "<why>" }
]}
],
"workflow_improvements": [
{ "priority": "high|medium|low", "category": "structure|handoff|performance|quality", "description": "<change>", "rationale": "<why>", "affected_steps": ["<step names>"] }
],
"summary": "<2-3 sentence executive summary of workflow health and top recommendations>"
}
CONSTRAINTS: Be specific, reference step names and artifact details, output ONLY JSON
```
## Variable Substitution
| Variable | Source | Description |
|----------|--------|-------------|
| `${workflowName}` | workflow-state.json | Workflow 名称 |
| `${workflowContext}` | workflow-state.json | Workflow 目标 |
| `${stepCount}` | workflow-state.json | 总步骤数 |
| `${avgScore}` | Phase 04 computes | 所有步骤平均分 |
| `${minScore}` | Phase 04 computes | 最低步骤分 |
| `${totalIssues}` | Phase 04 computes | 总问题数 |
| `${totalHighIssues}` | Phase 04 computes | 高优先级问题数 |
| `${scoreSummary}` | Phase 04 builds | 每步分数一行 |
| `${processLog}` | process-log.md | 完整过程日志 |
| `${stepAnalyses}` | Phase 04 reads | 所有 step-N-analysis.md 内容 |