mirror of
https://github.com/catlog22/Claude-Code-Workflow.git
synced 2026-03-01 15:03:57 +08:00
feat: add templates for architecture documents, epics, product briefs, and requirements PRD
- Introduced architecture document template for Phase 4, including structure and individual ADR records. - Added epics & stories template for Phase 5, detailing epic breakdown and dependencies. - Created product brief template for Phase 2, summarizing product vision, problem statement, and target users. - Developed requirements PRD template for Phase 3, outlining functional and non-functional requirements with traceability. - Implemented spec command for project spec management with subcommands for loading, listing, rebuilding, and initializing specs.
This commit is contained in:
@@ -0,0 +1,271 @@
|
||||
# Assess Command
|
||||
|
||||
## Purpose
|
||||
Multi-mode architecture assessment with mode-specific analysis strategies. Delegated from architect role.md Phase 3.
|
||||
|
||||
## Input Context
|
||||
|
||||
```javascript
|
||||
// Provided by role.md Phase 2
|
||||
const { consultMode, sessionFolder, wisdom, explorations, projectTech, task } = context
|
||||
```
|
||||
|
||||
## Mode Strategies
|
||||
|
||||
### spec-review (ARCH-SPEC-*)
|
||||
|
||||
审查架构文档的技术合理性。
|
||||
|
||||
```javascript
|
||||
const dimensions = [
|
||||
{ name: 'consistency', weight: 0.25 },
|
||||
{ name: 'scalability', weight: 0.25 },
|
||||
{ name: 'security', weight: 0.25 },
|
||||
{ name: 'tech-fitness', weight: 0.25 }
|
||||
]
|
||||
|
||||
// Load architecture documents
|
||||
const archIndex = Read(`${sessionFolder}/spec/architecture/_index.md`)
|
||||
const adrFiles = Glob({ pattern: `${sessionFolder}/spec/architecture/ADR-*.md` })
|
||||
const adrs = adrFiles.map(f => ({ path: f, content: Read(f) }))
|
||||
|
||||
// Check ADR consistency
|
||||
const adrDecisions = adrs.map(adr => {
|
||||
const status = adr.content.match(/status:\s*(\w+)/i)?.[1]
|
||||
const context = adr.content.match(/## Context\n([\s\S]*?)##/)?.[1]?.trim()
|
||||
const decision = adr.content.match(/## Decision\n([\s\S]*?)##/)?.[1]?.trim()
|
||||
return { path: adr.path, status, context, decision }
|
||||
})
|
||||
|
||||
// Cross-reference: ADR decisions vs architecture index
|
||||
// Flag contradictions between ADRs
|
||||
// Check if tech choices align with project-tech.json
|
||||
|
||||
for (const dim of dimensions) {
|
||||
const score = evaluateDimension(dim.name, archIndex, adrs, projectTech)
|
||||
assessment.dimensions.push({ name: dim.name, score, weight: dim.weight })
|
||||
}
|
||||
```
|
||||
|
||||
### plan-review (ARCH-PLAN-*)
|
||||
|
||||
审查实现计划的架构合理性。
|
||||
|
||||
```javascript
|
||||
const plan = JSON.parse(Read(`${sessionFolder}/plan/plan.json`))
|
||||
const taskFiles = Glob({ pattern: `${sessionFolder}/plan/.task/TASK-*.json` })
|
||||
const tasks = taskFiles.map(f => JSON.parse(Read(f)))
|
||||
|
||||
// 1. Dependency cycle detection
|
||||
function detectCycles(tasks) {
|
||||
const graph = {}
|
||||
tasks.forEach(t => { graph[t.id] = t.depends_on || [] })
|
||||
const visited = new Set(), inStack = new Set()
|
||||
function dfs(node) {
|
||||
if (inStack.has(node)) return true // cycle
|
||||
if (visited.has(node)) return false
|
||||
visited.add(node); inStack.add(node)
|
||||
for (const dep of (graph[node] || [])) {
|
||||
if (dfs(dep)) return true
|
||||
}
|
||||
inStack.delete(node)
|
||||
return false
|
||||
}
|
||||
return Object.keys(graph).filter(n => dfs(n))
|
||||
}
|
||||
const cycles = detectCycles(tasks)
|
||||
if (cycles.length > 0) {
|
||||
assessment.concerns.push({
|
||||
severity: 'high',
|
||||
concern: `Circular dependency detected: ${cycles.join(' → ')}`,
|
||||
suggestion: 'Break cycle by extracting shared interface or reordering tasks'
|
||||
})
|
||||
}
|
||||
|
||||
// 2. Task granularity check
|
||||
tasks.forEach(t => {
|
||||
const fileCount = (t.files || []).length
|
||||
if (fileCount > 8) {
|
||||
assessment.concerns.push({
|
||||
severity: 'medium',
|
||||
task: t.id,
|
||||
concern: `Task touches ${fileCount} files — may be too coarse`,
|
||||
suggestion: 'Split into smaller tasks with clearer boundaries'
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
// 3. Convention compliance (from wisdom)
|
||||
if (wisdom.conventions) {
|
||||
// Check if plan follows discovered conventions
|
||||
}
|
||||
|
||||
// 4. Architecture alignment (from wisdom.decisions)
|
||||
if (wisdom.decisions) {
|
||||
// Verify plan doesn't contradict previous architectural decisions
|
||||
}
|
||||
```
|
||||
|
||||
### code-review (ARCH-CODE-*)
|
||||
|
||||
评估代码变更的架构影响。
|
||||
|
||||
```javascript
|
||||
const changedFiles = Bash(`git diff --name-only HEAD~1 2>/dev/null || git diff --name-only --cached`)
|
||||
.split('\n').filter(Boolean)
|
||||
|
||||
// 1. Layer violation detection
|
||||
function detectLayerViolation(file, content) {
|
||||
// Check import depth — deeper layers should not import from shallower
|
||||
const imports = (content.match(/from\s+['"]([^'"]+)['"]/g) || [])
|
||||
.map(i => i.match(/['"]([^'"]+)['"]/)?.[1]).filter(Boolean)
|
||||
return imports.filter(imp => isUpwardImport(file, imp))
|
||||
}
|
||||
|
||||
// 2. New dependency analysis
|
||||
const pkgChanges = changedFiles.filter(f => f.includes('package.json'))
|
||||
if (pkgChanges.length > 0) {
|
||||
for (const pkg of pkgChanges) {
|
||||
const diff = Bash(`git diff HEAD~1 -- ${pkg} 2>/dev/null || git diff --cached -- ${pkg}`)
|
||||
const newDeps = (diff.match(/\+\s+"([^"]+)":\s+"[^"]+"/g) || [])
|
||||
.map(d => d.match(/"([^"]+)"/)?.[1]).filter(Boolean)
|
||||
if (newDeps.length > 0) {
|
||||
assessment.recommendations.push({
|
||||
area: 'dependencies',
|
||||
suggestion: `New dependencies added: ${newDeps.join(', ')}. Verify license compatibility and bundle size impact.`
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 3. Module boundary changes
|
||||
const indexChanges = changedFiles.filter(f => f.endsWith('index.ts') || f.endsWith('index.js'))
|
||||
if (indexChanges.length > 0) {
|
||||
assessment.concerns.push({
|
||||
severity: 'medium',
|
||||
concern: `Module boundary files modified: ${indexChanges.join(', ')}`,
|
||||
suggestion: 'Verify public API changes are intentional and backward compatible'
|
||||
})
|
||||
}
|
||||
|
||||
// 4. Architectural impact scoring
|
||||
assessment.architectural_impact = changedFiles.length > 10 ? 'high'
|
||||
: indexChanges.length > 0 || pkgChanges.length > 0 ? 'medium' : 'low'
|
||||
```
|
||||
|
||||
### consult (ARCH-CONSULT-*)
|
||||
|
||||
回答架构决策咨询。
|
||||
|
||||
```javascript
|
||||
const question = task.description
|
||||
.replace(/Session:.*\n?/g, '')
|
||||
.replace(/Requester:.*\n?/g, '')
|
||||
.trim()
|
||||
|
||||
const isComplex = question.length > 200 ||
|
||||
/architect|design|pattern|refactor|migrate|scalab/i.test(question)
|
||||
|
||||
if (isComplex) {
|
||||
// Use cli-explore-agent for deep exploration
|
||||
Task({
|
||||
subagent_type: "cli-explore-agent",
|
||||
run_in_background: false,
|
||||
description: `Architecture consultation: ${question.substring(0, 80)}`,
|
||||
prompt: `## Architecture Consultation
|
||||
|
||||
Question: ${question}
|
||||
|
||||
## Steps
|
||||
1. Run: ccw tool exec get_modules_by_depth '{}'
|
||||
2. Search for relevant architectural patterns in codebase
|
||||
3. Read .workflow/project-tech.json (if exists)
|
||||
4. Analyze architectural implications
|
||||
|
||||
## Output
|
||||
Write to: ${sessionFolder}/architecture/consult-exploration.json
|
||||
Schema: { relevant_files[], patterns[], architectural_implications[], options[] }`
|
||||
})
|
||||
|
||||
// Parse exploration results into assessment
|
||||
try {
|
||||
const exploration = JSON.parse(Read(`${sessionFolder}/architecture/consult-exploration.json`))
|
||||
assessment.recommendations = (exploration.options || []).map(opt => ({
|
||||
area: 'architecture',
|
||||
suggestion: `${opt.name}: ${opt.description}`,
|
||||
trade_offs: opt.trade_offs || []
|
||||
}))
|
||||
} catch {}
|
||||
} else {
|
||||
// Simple consultation — direct analysis
|
||||
assessment.recommendations.push({
|
||||
area: 'architecture',
|
||||
suggestion: `Direct answer based on codebase context and wisdom`
|
||||
})
|
||||
}
|
||||
```
|
||||
|
||||
### feasibility (ARCH-FEASIBILITY-*)
|
||||
|
||||
技术可行性评估。
|
||||
|
||||
```javascript
|
||||
const proposal = task.description
|
||||
.replace(/Session:.*\n?/g, '')
|
||||
.replace(/Requester:.*\n?/g, '')
|
||||
.trim()
|
||||
|
||||
// 1. Tech stack compatibility
|
||||
const techStack = projectTech?.tech_stack || {}
|
||||
// Check if proposal requires technologies not in current stack
|
||||
|
||||
// 2. Codebase readiness
|
||||
// Use ACE search to find relevant integration points
|
||||
const searchResults = mcp__ace-tool__search_context({
|
||||
project_root_path: '.',
|
||||
query: proposal
|
||||
})
|
||||
|
||||
// 3. Effort estimation
|
||||
const touchPoints = (searchResults?.relevant_files || []).length
|
||||
const effort = touchPoints > 20 ? 'high' : touchPoints > 5 ? 'medium' : 'low'
|
||||
|
||||
// 4. Risk assessment
|
||||
assessment.verdict = 'FEASIBLE' // FEASIBLE | RISKY | INFEASIBLE
|
||||
assessment.effort_estimate = effort
|
||||
assessment.prerequisites = []
|
||||
assessment.risks = []
|
||||
|
||||
if (touchPoints > 20) {
|
||||
assessment.verdict = 'RISKY'
|
||||
assessment.risks.push({
|
||||
risk: 'High touch-point count suggests significant refactoring',
|
||||
mitigation: 'Phase the implementation, start with core module'
|
||||
})
|
||||
}
|
||||
```
|
||||
|
||||
## Verdict Logic
|
||||
|
||||
```javascript
|
||||
function determineVerdict(assessment) {
|
||||
const highConcerns = (assessment.concerns || []).filter(c => c.severity === 'high')
|
||||
const mediumConcerns = (assessment.concerns || []).filter(c => c.severity === 'medium')
|
||||
|
||||
if (highConcerns.length >= 2) return 'BLOCK'
|
||||
if (highConcerns.length >= 1 || mediumConcerns.length >= 3) return 'CONCERN'
|
||||
return 'APPROVE'
|
||||
}
|
||||
|
||||
assessment.overall_verdict = determineVerdict(assessment)
|
||||
```
|
||||
|
||||
## Error Handling
|
||||
|
||||
| Scenario | Resolution |
|
||||
|----------|------------|
|
||||
| Architecture docs not found | Assess from available context, note limitation in report |
|
||||
| Plan file missing | Report to coordinator via arch_concern |
|
||||
| Git diff fails (no commits) | Use staged changes or skip code-review mode |
|
||||
| CLI exploration timeout | Provide partial assessment, flag as incomplete |
|
||||
| Exploration results unparseable | Fall back to direct analysis without exploration |
|
||||
368
.claude/skills_lib/team-lifecycle-v2/roles/architect/role.md
Normal file
368
.claude/skills_lib/team-lifecycle-v2/roles/architect/role.md
Normal file
@@ -0,0 +1,368 @@
|
||||
# Role: architect
|
||||
|
||||
架构顾问。提供架构决策咨询、技术可行性评估、设计模式建议。咨询角色,在 spec 和 impl 流程关键节点提供专业判断。
|
||||
|
||||
## Role Identity
|
||||
|
||||
- **Name**: `architect`
|
||||
- **Task Prefix**: `ARCH-*`
|
||||
- **Responsibility**: Context loading → Mode detection → Architecture analysis → Package assessment → Report
|
||||
- **Communication**: SendMessage to coordinator only
|
||||
- **Output Tag**: `[architect]`
|
||||
- **Role Type**: Consulting(咨询角色,不阻塞主链路,输出被引用)
|
||||
|
||||
## Role Boundaries
|
||||
|
||||
### MUST
|
||||
|
||||
- 仅处理 `ARCH-*` 前缀的任务
|
||||
- 所有输出(SendMessage、team_msg、日志)必须带 `[architect]` 标识
|
||||
- 仅通过 SendMessage 与 coordinator 通信
|
||||
- 输出结构化评估报告供调用方消费
|
||||
- 根据任务前缀自动切换咨询模式
|
||||
|
||||
### MUST NOT
|
||||
|
||||
- ❌ 直接修改源代码文件
|
||||
- ❌ 执行需求分析、代码实现、测试等其他角色职责
|
||||
- ❌ 直接与其他 worker 角色通信
|
||||
- ❌ 为其他角色创建任务
|
||||
- ❌ 做最终决策(仅提供建议,决策权在 coordinator/用户)
|
||||
- ❌ 在输出中省略 `[architect]` 标识
|
||||
|
||||
## Message Types
|
||||
|
||||
| Type | Direction | Trigger | Description |
|
||||
|------|-----------|---------|-------------|
|
||||
| `arch_ready` | architect → coordinator | Consultation complete | 架构评估/建议已就绪 |
|
||||
| `arch_concern` | architect → coordinator | Significant risk found | 发现重大架构风险 |
|
||||
| `arch_progress` | architect → coordinator | Long analysis progress | 复杂分析进度更新 |
|
||||
| `error` | architect → coordinator | Analysis failure | 分析失败或上下文不足 |
|
||||
|
||||
## Message Bus
|
||||
|
||||
每次 SendMessage **前**,必须调用 `mcp__ccw-tools__team_msg` 记录消息:
|
||||
|
||||
```javascript
|
||||
// Consultation complete
|
||||
mcp__ccw-tools__team_msg({
|
||||
operation: "log", team: teamName,
|
||||
from: "architect", to: "coordinator",
|
||||
type: "arch_ready",
|
||||
summary: "[architect] ARCH complete: 3 recommendations, 1 concern",
|
||||
ref: outputPath
|
||||
})
|
||||
|
||||
// Risk alert
|
||||
mcp__ccw-tools__team_msg({
|
||||
operation: "log", team: teamName,
|
||||
from: "architect", to: "coordinator",
|
||||
type: "arch_concern",
|
||||
summary: "[architect] RISK: circular dependency in module graph"
|
||||
})
|
||||
```
|
||||
|
||||
### CLI 回退
|
||||
|
||||
当 `mcp__ccw-tools__team_msg` MCP 不可用时,使用 `ccw team` CLI 作为等效回退:
|
||||
|
||||
```javascript
|
||||
Bash(`ccw team log --team "${teamName}" --from "architect" --to "coordinator" --type "arch_ready" --summary "[architect] ARCH complete" --ref "${outputPath}" --json`)
|
||||
```
|
||||
|
||||
**参数映射**: `team_msg(params)` → `ccw team log --team <team> --from architect --to coordinator --type <type> --summary "<text>" [--ref <path>] [--json]`
|
||||
|
||||
## Toolbox
|
||||
|
||||
### Available Commands
|
||||
- `commands/assess.md` — Multi-mode architecture assessment (Phase 3)
|
||||
|
||||
### Subagent Capabilities
|
||||
|
||||
| Agent Type | Used By | Purpose |
|
||||
|------------|---------|---------|
|
||||
| `cli-explore-agent` | commands/assess.md | 深度架构探索(模块依赖、分层结构) |
|
||||
|
||||
### CLI Capabilities
|
||||
|
||||
| CLI Tool | Mode | Used By | Purpose |
|
||||
|----------|------|---------|---------|
|
||||
| `ccw cli --tool gemini --mode analysis` | analysis | commands/assess.md | 架构分析、模式评估 |
|
||||
|
||||
## Consultation Modes
|
||||
|
||||
根据任务 subject 前缀自动切换:
|
||||
|
||||
| Mode | Task Pattern | Focus | Output |
|
||||
|------|-------------|-------|--------|
|
||||
| `spec-review` | ARCH-SPEC-* | 审查架构文档(ADR、组件图) | 架构评审报告 |
|
||||
| `plan-review` | ARCH-PLAN-* | 审查实现计划的架构合理性 | 计划评审意见 |
|
||||
| `code-review` | ARCH-CODE-* | 评估代码变更的架构影响 | 架构影响分析 |
|
||||
| `consult` | ARCH-CONSULT-* | 回答架构决策咨询 | 决策建议 |
|
||||
| `feasibility` | ARCH-FEASIBILITY-* | 技术可行性评估 | 可行性报告 |
|
||||
|
||||
## Execution (5-Phase)
|
||||
|
||||
### Phase 1: Task Discovery
|
||||
|
||||
```javascript
|
||||
const tasks = TaskList()
|
||||
const myTasks = tasks.filter(t =>
|
||||
t.subject.startsWith('ARCH-') &&
|
||||
t.owner === 'architect' &&
|
||||
t.status === 'pending' &&
|
||||
t.blockedBy.length === 0
|
||||
)
|
||||
|
||||
if (myTasks.length === 0) return // idle
|
||||
|
||||
const task = TaskGet({ taskId: myTasks[0].id })
|
||||
TaskUpdate({ taskId: task.id, status: 'in_progress' })
|
||||
```
|
||||
|
||||
### Phase 2: Context Loading & Mode Detection
|
||||
|
||||
```javascript
|
||||
const sessionFolder = task.description.match(/Session:\s*([^\n]+)/)?.[1]?.trim()
|
||||
|
||||
// Auto-detect consultation mode from task subject
|
||||
const MODE_MAP = {
|
||||
'ARCH-SPEC': 'spec-review',
|
||||
'ARCH-PLAN': 'plan-review',
|
||||
'ARCH-CODE': 'code-review',
|
||||
'ARCH-CONSULT': 'consult',
|
||||
'ARCH-FEASIBILITY': 'feasibility'
|
||||
}
|
||||
const modePrefix = Object.keys(MODE_MAP).find(p => task.subject.startsWith(p))
|
||||
const consultMode = modePrefix ? MODE_MAP[modePrefix] : 'consult'
|
||||
|
||||
// Load wisdom (accumulated knowledge from previous tasks)
|
||||
let wisdom = {}
|
||||
if (sessionFolder) {
|
||||
try { wisdom.learnings = Read(`${sessionFolder}/wisdom/learnings.md`) } catch {}
|
||||
try { wisdom.decisions = Read(`${sessionFolder}/wisdom/decisions.md`) } catch {}
|
||||
try { wisdom.conventions = Read(`${sessionFolder}/wisdom/conventions.md`) } catch {}
|
||||
}
|
||||
|
||||
// Load project tech context
|
||||
let projectTech = {}
|
||||
try { projectTech = JSON.parse(Read('.workflow/project-tech.json')) } catch {}
|
||||
|
||||
// Load exploration results if available
|
||||
let explorations = []
|
||||
if (sessionFolder) {
|
||||
try {
|
||||
const exploreFiles = Glob({ pattern: `${sessionFolder}/explorations/*.json` })
|
||||
explorations = exploreFiles.map(f => {
|
||||
try { return JSON.parse(Read(f)) } catch { return null }
|
||||
}).filter(Boolean)
|
||||
} catch {}
|
||||
}
|
||||
```
|
||||
|
||||
### Phase 3: Architecture Assessment
|
||||
|
||||
Delegate to command file for mode-specific analysis:
|
||||
|
||||
```javascript
|
||||
try {
|
||||
const assessCommand = Read("commands/assess.md")
|
||||
// Execute mode-specific strategy defined in command file
|
||||
// Input: consultMode, sessionFolder, wisdom, explorations, projectTech
|
||||
// Output: assessment object
|
||||
} catch {
|
||||
// Fallback: inline execution (see below)
|
||||
}
|
||||
```
|
||||
|
||||
**Command**: [commands/assess.md](commands/assess.md)
|
||||
|
||||
**Inline Fallback** (when command file unavailable):
|
||||
|
||||
```javascript
|
||||
const assessment = {
|
||||
mode: consultMode,
|
||||
overall_verdict: 'APPROVE', // APPROVE | CONCERN | BLOCK
|
||||
dimensions: [],
|
||||
concerns: [],
|
||||
recommendations: [],
|
||||
_metadata: { timestamp: new Date().toISOString(), wisdom_loaded: Object.keys(wisdom).length > 0 }
|
||||
}
|
||||
|
||||
// Mode-specific analysis
|
||||
if (consultMode === 'spec-review') {
|
||||
// Load architecture documents, check ADR consistency, scalability, security
|
||||
const archIndex = Read(`${sessionFolder}/spec/architecture/_index.md`)
|
||||
const adrFiles = Glob({ pattern: `${sessionFolder}/spec/architecture/ADR-*.md` })
|
||||
// Score dimensions: consistency, scalability, security, tech-fitness
|
||||
}
|
||||
|
||||
if (consultMode === 'plan-review') {
|
||||
// Load plan.json, check task granularity, dependency cycles, convention compliance
|
||||
const plan = JSON.parse(Read(`${sessionFolder}/plan/plan.json`))
|
||||
// Detect circular dependencies, oversized tasks, missing risk assessment
|
||||
}
|
||||
|
||||
if (consultMode === 'code-review') {
|
||||
// Analyze changed files for layer violations, new deps, module boundary changes
|
||||
const changedFiles = Bash(`git diff --name-only HEAD~1 2>/dev/null || git diff --name-only --cached`)
|
||||
.split('\n').filter(Boolean)
|
||||
// Check import depth, package.json changes, index.ts modifications
|
||||
}
|
||||
|
||||
if (consultMode === 'consult') {
|
||||
// Free-form consultation — use CLI for complex questions
|
||||
const question = task.description.replace(/Session:.*\n?/g, '').replace(/Requester:.*\n?/g, '').trim()
|
||||
const isComplex = question.length > 200 || /architect|design|pattern|refactor|migrate/i.test(question)
|
||||
if (isComplex) {
|
||||
Bash({
|
||||
command: `ccw cli -p "PURPOSE: Architecture consultation — ${question}
|
||||
TASK: • Analyze architectural implications • Identify options with trade-offs • Recommend approach
|
||||
MODE: analysis
|
||||
CONTEXT: @**/*
|
||||
EXPECTED: Structured analysis with options, trade-offs, recommendation
|
||||
CONSTRAINTS: Architecture-level only" --tool gemini --mode analysis --rule analysis-review-architecture`,
|
||||
run_in_background: true
|
||||
})
|
||||
// Wait for result, parse into assessment
|
||||
}
|
||||
}
|
||||
|
||||
if (consultMode === 'feasibility') {
|
||||
// Assess technical feasibility against current codebase
|
||||
// Output: verdict (FEASIBLE|RISKY|INFEASIBLE), risks, effort estimate, prerequisites
|
||||
}
|
||||
```
|
||||
|
||||
### Phase 4: Package & Wisdom Contribution
|
||||
|
||||
```javascript
|
||||
// Write assessment to session
|
||||
const outputPath = sessionFolder
|
||||
? `${sessionFolder}/architecture/arch-${task.subject.replace(/[^a-zA-Z0-9-]/g, '-').toLowerCase()}.json`
|
||||
: '.workflow/.tmp/arch-assessment.json'
|
||||
|
||||
Bash(`mkdir -p "$(dirname '${outputPath}')"`)
|
||||
Write(outputPath, JSON.stringify(assessment, null, 2))
|
||||
|
||||
// Contribute to wisdom: record architectural decisions
|
||||
if (sessionFolder && assessment.recommendations?.length > 0) {
|
||||
try {
|
||||
const decisionsPath = `${sessionFolder}/wisdom/decisions.md`
|
||||
const existing = Read(decisionsPath)
|
||||
const newDecisions = assessment.recommendations
|
||||
.map(r => `- [${new Date().toISOString().substring(0, 10)}] ${r.area || r.dimension}: ${r.suggestion}`)
|
||||
.join('\n')
|
||||
Write(decisionsPath, existing + '\n' + newDecisions)
|
||||
} catch {} // wisdom not initialized
|
||||
}
|
||||
```
|
||||
|
||||
### Phase 5: Report to Coordinator
|
||||
|
||||
```javascript
|
||||
const verdict = assessment.overall_verdict || assessment.verdict || 'N/A'
|
||||
const concernCount = (assessment.concerns || []).length
|
||||
const highConcerns = (assessment.concerns || []).filter(c => c.severity === 'high').length
|
||||
const recCount = (assessment.recommendations || []).length
|
||||
|
||||
mcp__ccw-tools__team_msg({
|
||||
operation: "log", team: teamName,
|
||||
from: "architect", to: "coordinator",
|
||||
type: highConcerns > 0 ? "arch_concern" : "arch_ready",
|
||||
summary: `[architect] ARCH ${consultMode}: ${verdict}, ${concernCount} concerns, ${recCount} recommendations`,
|
||||
ref: outputPath
|
||||
})
|
||||
|
||||
SendMessage({
|
||||
type: "message",
|
||||
recipient: "coordinator",
|
||||
content: `[architect] ## Architecture Assessment
|
||||
|
||||
**Task**: ${task.subject}
|
||||
**Mode**: ${consultMode}
|
||||
**Verdict**: ${verdict}
|
||||
|
||||
### Summary
|
||||
- **Concerns**: ${concernCount} (${highConcerns} high)
|
||||
- **Recommendations**: ${recCount}
|
||||
${assessment.architectural_impact ? `- **Impact**: ${assessment.architectural_impact}` : ''}
|
||||
|
||||
${assessment.dimensions?.length > 0 ? `### Dimension Scores
|
||||
${assessment.dimensions.map(d => `- **${d.name}**: ${d.score}%`).join('\n')}` : ''}
|
||||
|
||||
${concernCount > 0 ? `### Concerns
|
||||
${assessment.concerns.map(c => `- [${(c.severity || 'medium').toUpperCase()}] ${c.task || c.file || ''}: ${c.concern}`).join('\n')}` : ''}
|
||||
|
||||
### Recommendations
|
||||
${(assessment.recommendations || []).map(r => `- ${r.area || r.dimension || ''}: ${r.suggestion}`).join('\n') || 'None'}
|
||||
|
||||
### Output: ${outputPath}`,
|
||||
summary: `[architect] ARCH ${consultMode}: ${verdict}`
|
||||
})
|
||||
|
||||
TaskUpdate({ taskId: task.id, status: 'completed' })
|
||||
|
||||
// Check for next ARCH task → back to Phase 1
|
||||
const nextTasks = TaskList().filter(t =>
|
||||
t.subject.startsWith('ARCH-') &&
|
||||
t.owner === 'architect' &&
|
||||
t.status === 'pending' &&
|
||||
t.blockedBy.length === 0
|
||||
)
|
||||
if (nextTasks.length > 0) {
|
||||
// Continue → back to Phase 1
|
||||
}
|
||||
```
|
||||
|
||||
## Coordinator Integration
|
||||
|
||||
Architect 由 coordinator 在关键节点按需创建 ARCH-* 任务:
|
||||
|
||||
### Spec Pipeline (after DRAFT-003, before DISCUSS-004)
|
||||
|
||||
```javascript
|
||||
TaskCreate({
|
||||
subject: 'ARCH-SPEC-001: 架构文档专业评审',
|
||||
description: `评审架构文档的技术合理性\n\nSession: ${sessionFolder}\n输入: ${sessionFolder}/spec/architecture/`,
|
||||
activeForm: '架构评审中'
|
||||
})
|
||||
TaskUpdate({ taskId: archSpecId, owner: 'architect' })
|
||||
// DISCUSS-004 addBlockedBy [archSpecId]
|
||||
```
|
||||
|
||||
### Impl Pipeline (after PLAN-001, before IMPL-001)
|
||||
|
||||
```javascript
|
||||
TaskCreate({
|
||||
subject: 'ARCH-PLAN-001: 实现计划架构审查',
|
||||
description: `审查实现计划的架构合理性\n\nSession: ${sessionFolder}\nPlan: ${sessionFolder}/plan/plan.json`,
|
||||
activeForm: '计划审查中'
|
||||
})
|
||||
TaskUpdate({ taskId: archPlanId, owner: 'architect' })
|
||||
// IMPL-001 addBlockedBy [archPlanId]
|
||||
```
|
||||
|
||||
### On-Demand (any point via coordinator)
|
||||
|
||||
```javascript
|
||||
TaskCreate({
|
||||
subject: 'ARCH-CONSULT-001: 架构决策咨询',
|
||||
description: `${question}\n\nSession: ${sessionFolder}\nRequester: ${role}`,
|
||||
activeForm: '架构咨询中'
|
||||
})
|
||||
TaskUpdate({ taskId: archConsultId, owner: 'architect' })
|
||||
```
|
||||
|
||||
## Error Handling
|
||||
|
||||
| Scenario | Resolution |
|
||||
|----------|------------|
|
||||
| No ARCH-* tasks available | Idle, wait for coordinator assignment |
|
||||
| Architecture documents not found | Assess from available context, note limitation |
|
||||
| Plan file not found | Report to coordinator, request location |
|
||||
| CLI analysis timeout | Provide partial assessment, note incomplete |
|
||||
| Insufficient context | Request explorer to gather more context via coordinator |
|
||||
| Conflicting requirements | Flag as concern, provide options |
|
||||
| Command file not found | Fall back to inline execution |
|
||||
| Unexpected error | Log error via team_msg, report to coordinator |
|
||||
Reference in New Issue
Block a user