feat: add CLI fallback for MCP calls in team commands

- Implemented CLI fallback using `ccw team` for various team command operations in `execute.md`, `plan.md`, `review.md`, `spec-analyst.md`, `spec-coordinate.md`, `spec-discuss.md`, `spec-reviewer.md`, `spec-writer.md`, and `test.md`.
- Updated command generation templates to include CLI fallback examples.
- Enhanced validation checks to ensure CLI fallback sections are present.
- Added quality standards for CLI fallback in team command design.
- Introduced a new `GlobalGraphExpander` class for expanding search results with cross-directory relationships.
- Added tests for `GlobalGraphExpander` to verify functionality and score decay factors.
This commit is contained in:
catlog22
2026-02-13 12:05:48 +08:00
parent ac32b28c7b
commit 6054a01b8f
19 changed files with 804 additions and 7 deletions

View File

@@ -68,7 +68,18 @@ ${config.message_types.filter(mt => mt.type !== 'error').map(mt =>
`// ${mt.trigger}
mcp__ccw-tools__team_msg({ operation: "log", team: teamName, from: "${config.role_name}", to: "coordinator", type: "${mt.type}", summary: "${mt.trigger}" })`
).join('\n\n')}
\`\`\``
\`\`\`
### CLI 回退
\`mcp__ccw-tools__team_msg\` MCP 不可用时,使用 \`ccw team\` CLI 作为等效回退:
\\\`\\\`\\\`javascript
// 回退: 将 MCP 调用替换为 Bash CLI参数一一对应
Bash(\\\`ccw team log --team "\${teamName}" --from "${config.role_name}" --to "coordinator" --type "${config.message_types[0]?.type || 'result'}" --summary "<摘要>" --json\\\`)
\\\`\\\`\\\`
**参数映射**: \`team_msg(params)\`\`ccw team log --team <team> --from ${config.role_name} --to coordinator --type <type> --summary "<text>" [--ref <path>] [--data '<json>'] [--json]\``
```
### Step 4: Generate Phase Implementations

View File

@@ -42,6 +42,8 @@ const requiredSections = [
{ name: "TaskGet Usage", pattern: /TaskGet/ },
{ name: "TaskUpdate Usage", pattern: /TaskUpdate/ },
{ name: "SendMessage to Coordinator", pattern: /SendMessage.*coordinator/i },
{ name: "CLI Fallback Section", pattern: /CLI 回退|CLI Fallback/ },
{ name: "ccw team CLI Example", pattern: /ccw team log/ },
{ name: "Error Handling Table", pattern: /## Error Handling/ },
{ name: "Implementation Section", pattern: /## Implementation/ }
]
@@ -110,6 +112,14 @@ const patternChecks = [
return command.includes('idle') || command.includes('return')
},
severity: "medium"
},
{
name: "CLI Fallback Present",
check: () => {
return (command.includes('CLI 回退') || command.includes('CLI Fallback')) &&
command.includes('ccw team log')
},
severity: "high"
}
]

View File

@@ -50,6 +50,7 @@ Quality assessment criteria for generated team command .md files.
**Infrastructure Pattern Checklist:**
- [ ] Pattern 1: Message bus - team_msg before every SendMessage
- [ ] Pattern 1b: CLI fallback - `ccw team` CLI fallback section with parameter mapping
- [ ] Pattern 2: YAML front matter - all fields present, group: team
- [ ] Pattern 3: Task lifecycle - TaskList/Get/Update flow
- [ ] Pattern 4: Five-phase structure - all 5 phases present
@@ -114,6 +115,7 @@ Quality assessment criteria for generated team command .md files.
- Missing error handling table
- Incomplete Phase implementation (skeleton only)
- Missing team_msg before some SendMessage calls
- Missing CLI fallback section (`### CLI 回退` with `ccw team` examples)
- No complexity-adaptive routing when role is complex
### Info (Nice to Have)

View File

@@ -105,22 +105,47 @@ When designing a new role, define role-specific message types following the conv
- `{action}_complete` - Work phase finished
- `{action}_progress` - Intermediate progress update
### CLI Fallback
When `mcp__ccw-tools__team_msg` MCP is unavailable, use `ccw team` CLI as equivalent fallback:
```javascript
// Fallback: Replace MCP call with Bash CLI (parameters map 1:1)
Bash(`ccw team log --team "${teamName}" --from "<role>" --to "coordinator" --type "<type>" --summary "<summary>" [--ref <path>] [--data '<json>'] --json`)
```
**Parameter mapping**: `team_msg(params)``ccw team <operation> --team <team> [--from/--to/--type/--summary/--ref/--data/--id/--last] [--json]`
**Coordinator** uses all 4 operations: `log`, `list`, `status`, `read`
**Teammates** primarily use: `log`
### Message Bus Section Template
```markdown
## Message Bus
## 消息总线
Every SendMessage **before**, must call `mcp__ccw-tools__team_msg` to log:
每次 SendMessage ****,必须调用 `mcp__ccw-tools__team_msg` 记录消息:
\`\`\`javascript
mcp__ccw-tools__team_msg({ operation: "log", team: teamName, from: "<role>", to: "coordinator", type: "<type>", summary: "<summary>" })
\`\`\`
### Supported Message Types
### 支持的 Message Types
| Type | Direction | Trigger | Description |
|------|-----------|---------|-------------|
| `<type>` | <role> -> coordinator | <when> | <what> |
| Type | 方向 | 触发时机 | 说明 |
|------|------|----------|------|
| `<type>` | <role> coordinator | <when> | <what> |
### CLI 回退
`mcp__ccw-tools__team_msg` MCP 不可用时,使用 `ccw team` CLI 作为等效回退:
\`\`\`javascript
// 回退: 将 MCP 调用替换为 Bash CLI参数一一对应
Bash(\`ccw team log --team "${teamName}" --from "<role>" --to "coordinator" --type "<type>" --summary "<summary>" --json\`)
\`\`\`
**参数映射**: `team_msg(params)``ccw team log --team <team> --from <role> --to coordinator --type <type> --summary "<text>" [--ref <path>] [--data '<json>'] [--json]`
```
---

View File

@@ -71,6 +71,17 @@ mcp__ccw-tools__team_msg({ operation: "log", team: teamName, from: "{{../role_na
{{/each}}
\`\`\`
### CLI 回退
`mcp__ccw-tools__team_msg` MCP 不可用时,使用 `ccw team` CLI 作为等效回退:
\`\`\`javascript
// 回退: 将 MCP 调用替换为 Bash CLI参数一一对应
Bash(\`ccw team log --team "${teamName}" --from "{{role_name}}" --to "coordinator" --type "{{primary_message_type}}" --summary "<摘要>" --json\`)
\`\`\`
**参数映射**: `team_msg(params)``ccw team log --team <team> --from {{role_name}} --to coordinator --type <type> --summary "<text>" [--ref <path>] [--data '<json>'] [--json]`
## Execution Process
\`\`\`