Enhance CCW Orchestrator with Requirement Analysis Features

- Updated SKILL.md to reflect new requirement analysis capabilities, including input analysis and clarity scoring.
- Expanded issue workflow in issue.md to include discovery and creation phases, along with detailed command references.
- Introduced requirement analysis specification in requirement-analysis.md, outlining clarity scoring, dimension extraction, and validation processes.
- Added output templates specification in output-templates.md for consistent user experience across classification, planning, clarification, execution, and summary outputs.
This commit is contained in:
catlog22
2026-01-14 20:15:42 +08:00
parent 959d60b31f
commit 1f5ce9c03a
5 changed files with 1015 additions and 157 deletions

View File

@@ -0,0 +1,258 @@
# Output Templates Specification
CCW 标准输出格式模板,确保一致的用户体验。
## Template Categories
| Category | Usage | Key Elements |
|----------|-------|--------------|
| Classification | Intent/complexity output | Intent, Complexity, Source |
| Planning | Chain selection output | Chain, Steps, Estimated time |
| Clarification | User interaction | Questions, Options, Context |
| Execution | Progress updates | Step, Status, Progress bar |
| Summary | Final results | Completed, Duration, Artifacts |
## Classification Output Template
```markdown
### Classification Summary
- **Source**: [Rule-Based|CLI-Assisted] ([confidence]% confidence)
- **Intent**: [intent_type] ([variant])
- **Complexity**: [low|medium|high]
- **Reasoning**: [brief explanation]
**Recommended Workflow**: [chain_name]
```
### Example
```markdown
### Classification Summary
- **Source**: CLI-Assisted (85% confidence)
- **Intent**: feature (implementation)
- **Complexity**: medium
- **Reasoning**: Request involves creating new functionality with moderate scope
**Recommended Workflow**: lite-plan → lite-execute
```
## Requirement Analysis Template
```markdown
### Requirement Analysis
**Input**: [truncated user input...]
| Dimension | Value | Status |
|-----------|-------|--------|
| WHAT | [action] [target] | ✓ extracted |
| WHERE | [scope]: [paths] | ✓ extracted |
| WHY | [goal] | ⚠ inferred |
| HOW | [constraints] | ✗ missing |
**Clarity Score**: [score]/3 ([level])
**Action**: [proceed|clarify|confirm]
```
## Planning Output Template
```markdown
### Workflow Planning
**Selected Chain**: [chain_name] ([chain_id])
**Description**: [chain_description]
**Complexity**: [chain_complexity]
**Estimated Time**: [estimated_time]
**Execution Steps**:
| # | Command | Auto | Description |
|---|---------|------|-------------|
| 1 | [command] | [Y/N] | [step description] |
| 2 | [command] | [Y/N] | [step description] |
**Risks**: [identified risks or "None identified"]
**Suggestions**: [optimization suggestions or "N/A"]
```
## Clarification Output Template
```markdown
### Clarification Needed
Your request needs more detail. Please help me understand:
**Missing Information**:
- [ ] [dimension]: [what's needed]
**Questions**:
[AskUserQuestion widget renders here]
```
## Execution Progress Template
```markdown
### Execution Progress
**Workflow**: [chain_name]
**Status**: [step N of M]
[████████░░░░░░░░] 50% (2/4 steps)
**Current Step**: [current command]
**Completed**:
- ✓ [step 1 command]
- ✓ [step 2 command]
**Pending**:
- ○ [step 3 command]
- ○ [step 4 command]
```
## Summary Output Template
```markdown
### Workflow Complete
**Chain**: [chain_name]
**Duration**: [elapsed time]
**Steps**: [completed]/[total]
**Results**:
| Step | Status | Notes |
|------|--------|-------|
| [command] | ✓ | [result notes] |
**Artifacts Generated**:
- [artifact path]
**Next Actions** (optional):
- [suggested follow-up]
```
## Error Output Template
```markdown
### Workflow Error
**Step**: [failed step command]
**Error**: [error message]
**Possible Causes**:
- [cause 1]
- [cause 2]
**Suggested Actions**:
1. [action 1]
2. [action 2]
Type `retry` to retry or `abort` to stop.
```
## Issue Workflow Templates
### Issue Discovery Output
```markdown
### Issue Discovery
**Perspectives Analyzed**: [list of perspectives]
**Issues Found**: [count]
| ID | Type | Severity | Location | Description |
|----|------|----------|----------|-------------|
| [ISS-xxx] | [type] | [severity] | [file:line] | [brief] |
**Recommended Next Step**: `/issue:new` or `/issue:plan`
```
### Issue Queue Output
```markdown
### Execution Queue
**Queue ID**: [QUE-xxx]
**Total Solutions**: [count]
**Execution Groups**: [count]
**Queue Structure**:
```
[P1] Parallel Group (2 solutions)
├─ SOL-001: [description]
└─ SOL-002: [description]
[S1] Sequential (depends on P1)
└─ SOL-003: [description]
```
**Conflicts Detected**: [count] ([severity level])
```
### Issue Execution Progress
```markdown
### Issue Execution
**Queue**: [QUE-xxx]
**Progress**: [completed]/[total] solutions
[████████░░░░░░░░] 50%
**Current Group**: [P1|S1|...]
**Executing**: [SOL-xxx] - [description]
**Completed**:
- ✓ SOL-001: [result]
- ✓ SOL-002: [result]
**ETA**: [estimated time remaining]
```
## Implementation Guide
```javascript
// Template rendering function
function renderTemplate(templateType, data) {
const templates = {
classification: renderClassification,
requirement: renderRequirement,
planning: renderPlanning,
clarification: renderClarification,
execution: renderExecution,
summary: renderSummary,
error: renderError
}
return templates[templateType](data)
}
// Example: Classification template
function renderClassification(data) {
return `### Classification Summary
- **Source**: ${data.source} ${data.confidence ? `(${Math.round(data.confidence * 100)}% confidence)` : ''}
- **Intent**: ${data.intent.type}${data.intent.variant ? ` (${data.intent.variant})` : ''}
- **Complexity**: ${data.complexity}
${data.reasoning ? `- **Reasoning**: ${data.reasoning}` : ''}
**Recommended Workflow**: ${data.workflow}`
}
// Progress bar helper
function renderProgressBar(completed, total, width = 16) {
const filled = Math.round((completed / total) * width)
const empty = width - filled
const percentage = Math.round((completed / total) * 100)
return `[${'█'.repeat(filled)}${'░'.repeat(empty)}] ${percentage}% (${completed}/${total})`
}
```
## Consistency Rules
1. **Headers**: Always use `###` for section headers
2. **Tables**: Use markdown tables for structured data
3. **Status Icons**: ✓ (done), ○ (pending), ⚠ (warning), ✗ (error)
4. **Progress**: Always show percentage and fraction
5. **Timing**: Show elapsed time in human-readable format
6. **Paths**: Show relative paths when possible

View File

@@ -0,0 +1,237 @@
# Requirement Analysis Specification
结构化需求分析规范:将用户输入分解为可操作的维度。
## Overview
```
┌─────────────────────────────────────────────────────────────────┐
│ Requirement Analysis Pipeline │
├─────────────────────────────────────────────────────────────────┤
│ │
│ Step 1: Clarity Assessment │
│ ├─ Score: 0-3 (0=模糊, 1=基本, 2=清晰, 3=详细) │
│ ├─ Missing dimensions detection │
│ └─ Trigger clarification if score < 2 │
│ │
│ Step 2: Dimension Extraction │
│ ├─ WHAT: 要做什么 (功能/修复/优化) │
│ ├─ WHERE: 在哪里做 (文件/模块/系统) │
│ ├─ WHY: 为什么做 (目标/动机) │
│ ├─ HOW: 怎么做 (约束/偏好) │
│ └─ WHEN: 时间/优先级约束 │
│ │
│ Step 3: Validation │
│ ├─ Check dimension completeness │
│ ├─ Detect conflicts │
│ └─ Generate structured requirement object │
│ │
└─────────────────────────────────────────────────────────────────┘
```
## Clarity Scoring
| Score | Level | Description | Action |
|-------|-------|-------------|--------|
| 0 | 模糊 | 无法理解用户意图 | 必须澄清 |
| 1 | 基本 | 知道做什么,缺少细节 | 建议澄清 |
| 2 | 清晰 | 意图和范围明确 | 可直接执行 |
| 3 | 详细 | 所有维度都已指定 | 直接执行 |
### Clarity Indicators
```javascript
const clarityIndicators = {
// Score +1 for each present
positive: [
/具体|specific|明确/i, // Explicit intent
/在\s*[\w\/]+\s*(文件|模块|目录)/i, // Location specified
/使用|用|采用|通过/i, // Method specified
/因为|为了|目的是/i, // Reason given
/不要|避免|禁止/i, // Constraints given
],
// Score -1 for each present
negative: [
/不知道|不确定|maybe|可能/i, // Uncertainty
/怎么办|如何|what should/i, // Seeking guidance
/帮我|help me/i, // Generic help
]
}
```
## Dimension Schema
```typescript
interface RequirementDimensions {
// WHAT dimension
what: {
action: 'create' | 'fix' | 'refactor' | 'optimize' | 'analyze' | 'review';
target: string; // What to act on
description: string; // Brief description
};
// WHERE dimension
where: {
scope: 'file' | 'module' | 'system' | 'unknown';
paths?: string[]; // Specific paths mentioned
patterns?: string[]; // File patterns mentioned
};
// WHY dimension
why: {
goal?: string; // End goal
motivation?: string; // Why now
success_criteria?: string; // How to know done
};
// HOW dimension
how: {
constraints?: string[]; // Must/Must not
preferences?: string[]; // Should/Should not
approach?: string; // Suggested approach
};
// Metadata
clarity_score: 0 | 1 | 2 | 3;
missing_dimensions: string[];
confidence: number; // 0.0 - 1.0
}
```
## Extraction Rules
### WHAT Extraction
```javascript
const whatPatterns = {
create: /创建|新增|添加|实现|生成|create|add|implement|generate/i,
fix: /修复|修正|解决|fix|repair|resolve|debug/i,
refactor: /重构|优化结构|重写|refactor|restructure|rewrite/i,
optimize: /优化|提升|改进|性能|optimize|improve|enhance|performance/i,
analyze: /分析|理解|探索|研究|analyze|understand|explore|research/i,
review: /审查|检查|评估|review|check|assess|audit/i
}
```
### WHERE Extraction
```javascript
const wherePatterns = {
file: /(\S+\.(ts|js|py|md|json|yaml|yml))/g,
module: /(src\/\S+|lib\/\S+|packages\/\S+)/g,
directory: /(\/[\w\-\.\/]+)/g
}
```
### Constraint Extraction
```javascript
const constraintPatterns = {
must: /必须|一定要|需要|must|required|need to/i,
must_not: /不要|禁止|不能|避免|must not|don't|avoid/i,
should: /应该|最好|建议|should|prefer|recommend/i,
should_not: /不应该|不建议|尽量不|should not|better not/i
}
```
## Clarification Flow
当 clarity_score < 2 时触发澄清流程:
```javascript
function generateClarificationQuestions(dimensions) {
const questions = []
if (!dimensions.what.target) {
questions.push({
question: "你想要对什么进行操作?",
header: "目标",
options: [
{ label: "文件/代码", description: "修改特定文件或代码" },
{ label: "功能/模块", description: "处理整个功能模块" },
{ label: "系统/架构", description: "系统级变更" }
]
})
}
if (!dimensions.where.paths?.length && dimensions.where.scope === 'unknown') {
questions.push({
question: "你想在哪里进行这个操作?",
header: "位置",
options: [
{ label: "让我指定", description: "我会提供具体路径" },
{ label: "自动发现", description: "分析代码库后推荐" },
{ label: "全局", description: "整个项目范围" }
]
})
}
if (!dimensions.why.goal) {
questions.push({
question: "这个操作的目标是什么?",
header: "目标",
options: [
{ label: "修复问题", description: "解决已知Bug或错误" },
{ label: "新增功能", description: "添加新的能力" },
{ label: "改进质量", description: "提升性能/可维护性" },
{ label: "其他", description: "其他目标" }
]
})
}
return questions
}
```
## Integration with Orchestrator
```javascript
// In orchestrator.md Phase 1: Input Analysis
function analyzeRequirement(userInput) {
// Step 1: Extract dimensions
const dimensions = extractDimensions(userInput)
// Step 2: Calculate clarity score
dimensions.clarity_score = calculateClarityScore(userInput, dimensions)
// Step 3: Identify missing dimensions
dimensions.missing_dimensions = identifyMissing(dimensions)
return dimensions
}
// In Phase 1.5: After CLI Classification
function shouldClarify(dimensions, intent) {
// Clarify if:
// 1. Clarity score < 2
// 2. High complexity with missing dimensions
// 3. Ambiguous intent
return (
dimensions.clarity_score < 2 ||
(intent.complexity === 'high' && dimensions.missing_dimensions.length > 0)
)
}
```
## Output Format
分析完成后输出结构化需求摘要:
```markdown
### Requirement Analysis
**Input**: [Original user input]
**Dimensions**:
| Dimension | Value | Source |
|-----------|-------|--------|
| WHAT | [action] [target] | extracted/inferred |
| WHERE | [scope]: [paths] | extracted/unknown |
| WHY | [goal] | extracted/missing |
| HOW | [constraints] | extracted/none |
**Clarity**: [score]/3 - [level description]
**Missing**: [list of missing dimensions]
**Action**: [proceed/clarify/confirm]
```