mirror of
https://github.com/catlog22/Claude-Code-Workflow.git
synced 2026-02-28 09:23:08 +08:00
feat: Implement recursive core-memory database discovery and project listing
- Added `findAllCoreMemoryDatabases` function to recursively locate core-memory databases in nested project structures. - Updated `listAllProjects` to utilize the new recursive function for improved project listing. - Enhanced `getMemoriesFromProject` and `findMemoryAcrossProjects` to support nested project structures. feat: Introduce spec context injection in hooks configuration - Added a new hook configuration for "Spec Context Injection" to load project specs based on prompt keywords. chore: Add gray-matter dependency for YAML frontmatter parsing - Included `gray-matter` package in `package.json` for parsing YAML frontmatter in markdown files. feat: Create Spec Index Builder tool for managing project specs - Implemented `spec-index-builder.ts` to scan markdown files, extract YAML frontmatter, and generate index cache files for different spec dimensions. feat: Develop Spec Init tool for initializing spec directories and seed documents - Created `spec-init.ts` to set up the directory structure and seed documents for the spec system. feat: Build Spec Keyword Extractor for keyword extraction from prompts - Added `spec-keyword-extractor.ts` to extract keywords from user prompts, supporting both English and Chinese text. feat: Implement Spec Loader for loading and filtering specs based on keywords - Developed `spec-loader.ts` to handle loading of specs, filtering by read mode and keyword matches, and formatting output for CLI or hooks.
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
# Dispatch Command - Task Chain Creation
|
||||
|
||||
**Purpose**: Create task chains based on execution mode (spec-only, impl-only, full-lifecycle)
|
||||
**Purpose**: Create task chains based on execution mode, aligned with SKILL.md Three-Mode Pipeline
|
||||
|
||||
**Invoked by**: Coordinator role.md Phase 3
|
||||
|
||||
@@ -10,151 +10,141 @@
|
||||
|
||||
## Task Chain Strategies
|
||||
|
||||
### Role-Task Mapping (Source of Truth: SKILL.md VALID_ROLES)
|
||||
|
||||
| Task Prefix | Role | VALID_ROLES Key |
|
||||
|-------------|------|-----------------|
|
||||
| RESEARCH-* | analyst | `analyst` |
|
||||
| DISCUSS-* | discussant | `discussant` |
|
||||
| DRAFT-* | writer | `writer` |
|
||||
| QUALITY-* | reviewer | `reviewer` |
|
||||
| PLAN-* | planner | `planner` |
|
||||
| IMPL-* | executor | `executor` |
|
||||
| TEST-* | tester | `tester` |
|
||||
| REVIEW-* | reviewer | `reviewer` |
|
||||
| DEV-FE-* | fe-developer | `fe-developer` |
|
||||
| QA-FE-* | fe-qa | `fe-qa` |
|
||||
|
||||
---
|
||||
|
||||
### Strategy 1: Spec-Only Mode (12 tasks)
|
||||
|
||||
Pipeline: `RESEARCH → DISCUSS → DRAFT → DISCUSS → DRAFT → DISCUSS → DRAFT → DISCUSS → DRAFT → DISCUSS → QUALITY → DISCUSS`
|
||||
|
||||
```javascript
|
||||
if (requirements.mode === "spec-only") {
|
||||
Output("[coordinator] Creating spec-only task chain (12 tasks)")
|
||||
|
||||
// Task 1: Requirements Analysis
|
||||
// Task 1: Seed Analysis
|
||||
TaskCreate({
|
||||
team_id: teamId,
|
||||
task_id: "req-analysis",
|
||||
assigned_to: "spec-writer",
|
||||
phase: "spec",
|
||||
description: "Analyze requirements and extract key features",
|
||||
dependencies: [],
|
||||
input: {
|
||||
scope: requirements.scope,
|
||||
focus: requirements.focus,
|
||||
depth: requirements.depth
|
||||
},
|
||||
status: "active" // First task starts immediately
|
||||
subject: "RESEARCH-001",
|
||||
owner: "analyst",
|
||||
description: `Seed analysis: codebase exploration and context gathering\nSession: ${sessionFolder}\nScope: ${requirements.scope}\nFocus: ${requirements.focus.join(", ")}\nDepth: ${requirements.depth}`,
|
||||
blockedBy: [],
|
||||
status: "pending"
|
||||
})
|
||||
|
||||
// Task 2: Architecture Design
|
||||
// Task 2: Critique Research
|
||||
TaskCreate({
|
||||
team_id: teamId,
|
||||
task_id: "arch-design",
|
||||
assigned_to: "spec-writer",
|
||||
phase: "spec",
|
||||
description: "Design system architecture",
|
||||
dependencies: ["req-analysis"],
|
||||
status: "blocked"
|
||||
subject: "DISCUSS-001",
|
||||
owner: "discussant",
|
||||
description: `Critique research findings from RESEARCH-001, identify gaps and clarify scope\nSession: ${sessionFolder}`,
|
||||
blockedBy: ["RESEARCH-001"],
|
||||
status: "pending"
|
||||
})
|
||||
|
||||
// Task 3: API Design
|
||||
// Task 3: Product Brief
|
||||
TaskCreate({
|
||||
team_id: teamId,
|
||||
task_id: "api-design",
|
||||
assigned_to: "spec-writer",
|
||||
phase: "spec",
|
||||
description: "Design API contracts and endpoints",
|
||||
dependencies: ["arch-design"],
|
||||
status: "blocked"
|
||||
subject: "DRAFT-001",
|
||||
owner: "writer",
|
||||
description: `Generate Product Brief based on RESEARCH-001 findings and DISCUSS-001 feedback\nSession: ${sessionFolder}`,
|
||||
blockedBy: ["DISCUSS-001"],
|
||||
status: "pending"
|
||||
})
|
||||
|
||||
// Task 4: Data Model Design
|
||||
// Task 4: Critique Product Brief
|
||||
TaskCreate({
|
||||
team_id: teamId,
|
||||
task_id: "data-model",
|
||||
assigned_to: "spec-writer",
|
||||
phase: "spec",
|
||||
description: "Design data models and schemas",
|
||||
dependencies: ["arch-design"],
|
||||
status: "blocked"
|
||||
subject: "DISCUSS-002",
|
||||
owner: "discussant",
|
||||
description: `Critique Product Brief (DRAFT-001), evaluate completeness and clarity\nSession: ${sessionFolder}`,
|
||||
blockedBy: ["DRAFT-001"],
|
||||
status: "pending"
|
||||
})
|
||||
|
||||
// Task 5: UI Specification
|
||||
// Task 5: Requirements/PRD
|
||||
TaskCreate({
|
||||
team_id: teamId,
|
||||
task_id: "ui-spec",
|
||||
assigned_to: "spec-writer",
|
||||
phase: "spec",
|
||||
description: "Design UI components and user flows",
|
||||
dependencies: ["arch-design"],
|
||||
status: "blocked"
|
||||
subject: "DRAFT-002",
|
||||
owner: "writer",
|
||||
description: `Generate Requirements/PRD incorporating DISCUSS-002 feedback\nSession: ${sessionFolder}`,
|
||||
blockedBy: ["DISCUSS-002"],
|
||||
status: "pending"
|
||||
})
|
||||
|
||||
// Task 6: Test Strategy
|
||||
// Task 6: Critique Requirements
|
||||
TaskCreate({
|
||||
team_id: teamId,
|
||||
task_id: "test-strategy",
|
||||
assigned_to: "spec-writer",
|
||||
phase: "spec",
|
||||
description: "Define testing strategy and test cases",
|
||||
dependencies: ["api-design", "data-model"],
|
||||
status: "blocked"
|
||||
subject: "DISCUSS-003",
|
||||
owner: "discussant",
|
||||
description: `Critique Requirements/PRD (DRAFT-002), validate coverage and feasibility\nSession: ${sessionFolder}`,
|
||||
blockedBy: ["DRAFT-002"],
|
||||
status: "pending"
|
||||
})
|
||||
|
||||
// Task 7: Error Handling Design
|
||||
// Task 7: Architecture Document
|
||||
TaskCreate({
|
||||
team_id: teamId,
|
||||
task_id: "error-handling",
|
||||
assigned_to: "spec-writer",
|
||||
phase: "spec",
|
||||
description: "Design error handling and recovery mechanisms",
|
||||
dependencies: ["api-design"],
|
||||
status: "blocked"
|
||||
subject: "DRAFT-003",
|
||||
owner: "writer",
|
||||
description: `Generate Architecture Document incorporating DISCUSS-003 feedback\nSession: ${sessionFolder}`,
|
||||
blockedBy: ["DISCUSS-003"],
|
||||
status: "pending"
|
||||
})
|
||||
|
||||
// Task 8: Security Review
|
||||
// Task 8: Critique Architecture
|
||||
TaskCreate({
|
||||
team_id: teamId,
|
||||
task_id: "security-review",
|
||||
assigned_to: "spec-writer",
|
||||
phase: "spec",
|
||||
description: "Review security considerations and vulnerabilities",
|
||||
dependencies: ["api-design", "data-model"],
|
||||
status: "blocked"
|
||||
subject: "DISCUSS-004",
|
||||
owner: "discussant",
|
||||
description: `Critique Architecture Document (DRAFT-003), evaluate design decisions\nSession: ${sessionFolder}`,
|
||||
blockedBy: ["DRAFT-003"],
|
||||
status: "pending"
|
||||
})
|
||||
|
||||
// Task 9: Performance Requirements
|
||||
// Task 9: Epics
|
||||
TaskCreate({
|
||||
team_id: teamId,
|
||||
task_id: "perf-requirements",
|
||||
assigned_to: "spec-writer",
|
||||
phase: "spec",
|
||||
description: "Define performance requirements and benchmarks",
|
||||
dependencies: ["arch-design"],
|
||||
status: "blocked"
|
||||
subject: "DRAFT-004",
|
||||
owner: "writer",
|
||||
description: `Generate Epics document incorporating DISCUSS-004 feedback\nSession: ${sessionFolder}`,
|
||||
blockedBy: ["DISCUSS-004"],
|
||||
status: "pending"
|
||||
})
|
||||
|
||||
// Task 10: Documentation Outline
|
||||
// Task 10: Critique Epics
|
||||
TaskCreate({
|
||||
team_id: teamId,
|
||||
task_id: "doc-outline",
|
||||
assigned_to: "spec-writer",
|
||||
phase: "spec",
|
||||
description: "Create documentation structure and outline",
|
||||
dependencies: ["api-design"],
|
||||
status: "blocked"
|
||||
subject: "DISCUSS-005",
|
||||
owner: "discussant",
|
||||
description: `Critique Epics (DRAFT-004), validate task decomposition and priorities\nSession: ${sessionFolder}`,
|
||||
blockedBy: ["DRAFT-004"],
|
||||
status: "pending"
|
||||
})
|
||||
|
||||
// Task 11: Review Specifications
|
||||
// Task 11: Spec Quality Check
|
||||
TaskCreate({
|
||||
team_id: teamId,
|
||||
task_id: "review-spec",
|
||||
assigned_to: "spec-writer",
|
||||
phase: "spec",
|
||||
description: "Review all specifications for consistency",
|
||||
dependencies: ["test-strategy", "error-handling", "security-review", "perf-requirements", "doc-outline"],
|
||||
status: "blocked"
|
||||
subject: "QUALITY-001",
|
||||
owner: "reviewer",
|
||||
description: `5-dimension spec quality validation across all spec artifacts\nSession: ${sessionFolder}`,
|
||||
blockedBy: ["DISCUSS-005"],
|
||||
status: "pending"
|
||||
})
|
||||
|
||||
// Task 12: Finalize Specifications
|
||||
// Task 12: Final Review Discussion
|
||||
TaskCreate({
|
||||
team_id: teamId,
|
||||
task_id: "finalize-spec",
|
||||
assigned_to: "spec-writer",
|
||||
phase: "spec",
|
||||
description: "Finalize and package all specifications",
|
||||
dependencies: ["review-spec"],
|
||||
status: "blocked"
|
||||
subject: "DISCUSS-006",
|
||||
owner: "discussant",
|
||||
description: `Final review discussion: address QUALITY-001 findings, sign-off\nSession: ${sessionFolder}`,
|
||||
blockedBy: ["QUALITY-001"],
|
||||
status: "pending"
|
||||
})
|
||||
|
||||
Output("[coordinator] Spec-only task chain created (12 tasks)")
|
||||
Output("[coordinator] Starting with: req-analysis")
|
||||
Output("[coordinator] Starting with: RESEARCH-001 (analyst)")
|
||||
}
|
||||
```
|
||||
|
||||
@@ -162,6 +152,8 @@ if (requirements.mode === "spec-only") {
|
||||
|
||||
### Strategy 2: Impl-Only Mode (4 tasks)
|
||||
|
||||
Pipeline: `PLAN → IMPL → TEST + REVIEW`
|
||||
|
||||
```javascript
|
||||
if (requirements.mode === "impl-only") {
|
||||
Output("[coordinator] Creating impl-only task chain (4 tasks)")
|
||||
@@ -183,7 +175,6 @@ if (requirements.mode === "impl-only") {
|
||||
type: "text"
|
||||
})
|
||||
|
||||
// Validate spec file exists
|
||||
const specContent = Read(specFile)
|
||||
if (!specContent) {
|
||||
throw new Error(`Specification file not found: ${specFile}`)
|
||||
@@ -191,65 +182,44 @@ if (requirements.mode === "impl-only") {
|
||||
|
||||
Output(`[coordinator] Using specification: ${specFile}`)
|
||||
|
||||
// Task 1: Setup Scaffold
|
||||
// Task 1: Planning
|
||||
TaskCreate({
|
||||
team_id: teamId,
|
||||
task_id: "setup-scaffold",
|
||||
assigned_to: "implementer",
|
||||
phase: "impl",
|
||||
description: "Setup project scaffold and dependencies",
|
||||
dependencies: [],
|
||||
input: {
|
||||
spec_file: specFile,
|
||||
scope: requirements.scope
|
||||
},
|
||||
status: "active" // First task starts immediately
|
||||
subject: "PLAN-001",
|
||||
owner: "planner",
|
||||
description: `Multi-angle codebase exploration and structured planning\nSession: ${sessionFolder}\nSpec: ${specFile}\nScope: ${requirements.scope}`,
|
||||
blockedBy: [],
|
||||
status: "pending"
|
||||
})
|
||||
|
||||
// Task 2: Core Implementation
|
||||
// Task 2: Implementation
|
||||
TaskCreate({
|
||||
team_id: teamId,
|
||||
task_id: "core-impl",
|
||||
assigned_to: "implementer",
|
||||
phase: "impl",
|
||||
description: "Implement core functionality",
|
||||
dependencies: ["setup-scaffold"],
|
||||
input: {
|
||||
spec_file: specFile
|
||||
},
|
||||
status: "blocked"
|
||||
subject: "IMPL-001",
|
||||
owner: "executor",
|
||||
description: `Code implementation following PLAN-001\nSession: ${sessionFolder}\nSpec: ${specFile}`,
|
||||
blockedBy: ["PLAN-001"],
|
||||
status: "pending"
|
||||
})
|
||||
|
||||
// Task 3: Integration
|
||||
// Task 3: Testing (parallel with REVIEW-001)
|
||||
TaskCreate({
|
||||
team_id: teamId,
|
||||
task_id: "integration",
|
||||
assigned_to: "implementer",
|
||||
phase: "impl",
|
||||
description: "Integrate components and test",
|
||||
dependencies: ["core-impl"],
|
||||
input: {
|
||||
spec_file: specFile
|
||||
},
|
||||
status: "blocked"
|
||||
subject: "TEST-001",
|
||||
owner: "tester",
|
||||
description: `Adaptive test-fix cycles and quality gates\nSession: ${sessionFolder}`,
|
||||
blockedBy: ["IMPL-001"],
|
||||
status: "pending"
|
||||
})
|
||||
|
||||
// Task 4: Finalize Implementation
|
||||
// Task 4: Code Review (parallel with TEST-001)
|
||||
TaskCreate({
|
||||
team_id: teamId,
|
||||
task_id: "finalize-impl",
|
||||
assigned_to: "implementer",
|
||||
phase: "impl",
|
||||
description: "Finalize implementation and documentation",
|
||||
dependencies: ["integration"],
|
||||
input: {
|
||||
spec_file: specFile
|
||||
},
|
||||
status: "blocked"
|
||||
subject: "REVIEW-001",
|
||||
owner: "reviewer",
|
||||
description: `4-dimension code review of IMPL-001 output\nSession: ${sessionFolder}`,
|
||||
blockedBy: ["IMPL-001"],
|
||||
status: "pending"
|
||||
})
|
||||
|
||||
Output("[coordinator] Impl-only task chain created (4 tasks)")
|
||||
Output("[coordinator] Starting with: setup-scaffold")
|
||||
Output("[coordinator] Starting with: PLAN-001 (planner)")
|
||||
}
|
||||
```
|
||||
|
||||
@@ -257,206 +227,267 @@ if (requirements.mode === "impl-only") {
|
||||
|
||||
### Strategy 3: Full-Lifecycle Mode (16 tasks)
|
||||
|
||||
Pipeline: `[Spec pipeline 12] → PLAN(blockedBy: DISCUSS-006) → IMPL → TEST + REVIEW`
|
||||
|
||||
```javascript
|
||||
if (requirements.mode === "full-lifecycle") {
|
||||
Output("[coordinator] Creating full-lifecycle task chain (16 tasks)")
|
||||
|
||||
// ========================================
|
||||
// SPEC PHASE (12 tasks)
|
||||
// SPEC PHASE (12 tasks) — same as spec-only
|
||||
// ========================================
|
||||
|
||||
// Task 1: Requirements Analysis
|
||||
TaskCreate({
|
||||
team_id: teamId,
|
||||
task_id: "req-analysis",
|
||||
assigned_to: "spec-writer",
|
||||
phase: "spec",
|
||||
description: "Analyze requirements and extract key features",
|
||||
dependencies: [],
|
||||
input: {
|
||||
scope: requirements.scope,
|
||||
focus: requirements.focus,
|
||||
depth: requirements.depth
|
||||
},
|
||||
status: "active" // First task starts immediately
|
||||
})
|
||||
|
||||
// Task 2: Architecture Design
|
||||
TaskCreate({
|
||||
team_id: teamId,
|
||||
task_id: "arch-design",
|
||||
assigned_to: "spec-writer",
|
||||
phase: "spec",
|
||||
description: "Design system architecture",
|
||||
dependencies: ["req-analysis"],
|
||||
status: "blocked"
|
||||
})
|
||||
|
||||
// Task 3: API Design
|
||||
TaskCreate({
|
||||
team_id: teamId,
|
||||
task_id: "api-design",
|
||||
assigned_to: "spec-writer",
|
||||
phase: "spec",
|
||||
description: "Design API contracts and endpoints",
|
||||
dependencies: ["arch-design"],
|
||||
status: "blocked"
|
||||
})
|
||||
|
||||
// Task 4: Data Model Design
|
||||
TaskCreate({
|
||||
team_id: teamId,
|
||||
task_id: "data-model",
|
||||
assigned_to: "spec-writer",
|
||||
phase: "spec",
|
||||
description: "Design data models and schemas",
|
||||
dependencies: ["arch-design"],
|
||||
status: "blocked"
|
||||
})
|
||||
|
||||
// Task 5: UI Specification
|
||||
TaskCreate({
|
||||
team_id: teamId,
|
||||
task_id: "ui-spec",
|
||||
assigned_to: "spec-writer",
|
||||
phase: "spec",
|
||||
description: "Design UI components and user flows",
|
||||
dependencies: ["arch-design"],
|
||||
status: "blocked"
|
||||
})
|
||||
|
||||
// Task 6: Test Strategy
|
||||
TaskCreate({
|
||||
team_id: teamId,
|
||||
task_id: "test-strategy",
|
||||
assigned_to: "spec-writer",
|
||||
phase: "spec",
|
||||
description: "Define testing strategy and test cases",
|
||||
dependencies: ["api-design", "data-model"],
|
||||
status: "blocked"
|
||||
})
|
||||
|
||||
// Task 7: Error Handling Design
|
||||
TaskCreate({
|
||||
team_id: teamId,
|
||||
task_id: "error-handling",
|
||||
assigned_to: "spec-writer",
|
||||
phase: "spec",
|
||||
description: "Design error handling and recovery mechanisms",
|
||||
dependencies: ["api-design"],
|
||||
status: "blocked"
|
||||
})
|
||||
|
||||
// Task 8: Security Review
|
||||
TaskCreate({
|
||||
team_id: teamId,
|
||||
task_id: "security-review",
|
||||
assigned_to: "spec-writer",
|
||||
phase: "spec",
|
||||
description: "Review security considerations and vulnerabilities",
|
||||
dependencies: ["api-design", "data-model"],
|
||||
status: "blocked"
|
||||
})
|
||||
|
||||
// Task 9: Performance Requirements
|
||||
TaskCreate({
|
||||
team_id: teamId,
|
||||
task_id: "perf-requirements",
|
||||
assigned_to: "spec-writer",
|
||||
phase: "spec",
|
||||
description: "Define performance requirements and benchmarks",
|
||||
dependencies: ["arch-design"],
|
||||
status: "blocked"
|
||||
})
|
||||
|
||||
// Task 10: Documentation Outline
|
||||
TaskCreate({
|
||||
team_id: teamId,
|
||||
task_id: "doc-outline",
|
||||
assigned_to: "spec-writer",
|
||||
phase: "spec",
|
||||
description: "Create documentation structure and outline",
|
||||
dependencies: ["api-design"],
|
||||
status: "blocked"
|
||||
})
|
||||
|
||||
// Task 11: Review Specifications
|
||||
TaskCreate({
|
||||
team_id: teamId,
|
||||
task_id: "review-spec",
|
||||
assigned_to: "spec-writer",
|
||||
phase: "spec",
|
||||
description: "Review all specifications for consistency",
|
||||
dependencies: ["test-strategy", "error-handling", "security-review", "perf-requirements", "doc-outline"],
|
||||
status: "blocked"
|
||||
})
|
||||
|
||||
// Task 12: Finalize Specifications
|
||||
TaskCreate({
|
||||
team_id: teamId,
|
||||
task_id: "finalize-spec",
|
||||
assigned_to: "spec-writer",
|
||||
phase: "spec",
|
||||
description: "Finalize and package all specifications",
|
||||
dependencies: ["review-spec"],
|
||||
status: "blocked"
|
||||
})
|
||||
TaskCreate({ subject: "RESEARCH-001", owner: "analyst", description: `Seed analysis: codebase exploration and context gathering\nSession: ${sessionFolder}\nScope: ${requirements.scope}\nFocus: ${requirements.focus.join(", ")}\nDepth: ${requirements.depth}`, blockedBy: [], status: "pending" })
|
||||
TaskCreate({ subject: "DISCUSS-001", owner: "discussant", description: `Critique research findings from RESEARCH-001\nSession: ${sessionFolder}`, blockedBy: ["RESEARCH-001"], status: "pending" })
|
||||
TaskCreate({ subject: "DRAFT-001", owner: "writer", description: `Generate Product Brief\nSession: ${sessionFolder}`, blockedBy: ["DISCUSS-001"], status: "pending" })
|
||||
TaskCreate({ subject: "DISCUSS-002", owner: "discussant", description: `Critique Product Brief (DRAFT-001)\nSession: ${sessionFolder}`, blockedBy: ["DRAFT-001"], status: "pending" })
|
||||
TaskCreate({ subject: "DRAFT-002", owner: "writer", description: `Generate Requirements/PRD\nSession: ${sessionFolder}`, blockedBy: ["DISCUSS-002"], status: "pending" })
|
||||
TaskCreate({ subject: "DISCUSS-003", owner: "discussant", description: `Critique Requirements/PRD (DRAFT-002)\nSession: ${sessionFolder}`, blockedBy: ["DRAFT-002"], status: "pending" })
|
||||
TaskCreate({ subject: "DRAFT-003", owner: "writer", description: `Generate Architecture Document\nSession: ${sessionFolder}`, blockedBy: ["DISCUSS-003"], status: "pending" })
|
||||
TaskCreate({ subject: "DISCUSS-004", owner: "discussant", description: `Critique Architecture Document (DRAFT-003)\nSession: ${sessionFolder}`, blockedBy: ["DRAFT-003"], status: "pending" })
|
||||
TaskCreate({ subject: "DRAFT-004", owner: "writer", description: `Generate Epics\nSession: ${sessionFolder}`, blockedBy: ["DISCUSS-004"], status: "pending" })
|
||||
TaskCreate({ subject: "DISCUSS-005", owner: "discussant", description: `Critique Epics (DRAFT-004)\nSession: ${sessionFolder}`, blockedBy: ["DRAFT-004"], status: "pending" })
|
||||
TaskCreate({ subject: "QUALITY-001", owner: "reviewer", description: `5-dimension spec quality validation\nSession: ${sessionFolder}`, blockedBy: ["DISCUSS-005"], status: "pending" })
|
||||
TaskCreate({ subject: "DISCUSS-006", owner: "discussant", description: `Final review discussion and sign-off\nSession: ${sessionFolder}`, blockedBy: ["QUALITY-001"], status: "pending" })
|
||||
|
||||
// ========================================
|
||||
// IMPL PHASE (4 tasks)
|
||||
// IMPL PHASE (4 tasks) — blocked by spec completion
|
||||
// ========================================
|
||||
|
||||
// Task 13: Setup Scaffold
|
||||
TaskCreate({
|
||||
team_id: teamId,
|
||||
task_id: "setup-scaffold",
|
||||
assigned_to: "implementer",
|
||||
phase: "impl",
|
||||
description: "Setup project scaffold and dependencies",
|
||||
dependencies: ["finalize-spec"], // Blocked until spec phase completes
|
||||
status: "blocked"
|
||||
subject: "PLAN-001",
|
||||
owner: "planner",
|
||||
description: `Multi-angle codebase exploration and structured planning\nSession: ${sessionFolder}\nScope: ${requirements.scope}`,
|
||||
blockedBy: ["DISCUSS-006"], // Blocked until spec phase completes
|
||||
status: "pending"
|
||||
})
|
||||
|
||||
// Task 14: Core Implementation
|
||||
TaskCreate({
|
||||
team_id: teamId,
|
||||
task_id: "core-impl",
|
||||
assigned_to: "implementer",
|
||||
phase: "impl",
|
||||
description: "Implement core functionality",
|
||||
dependencies: ["setup-scaffold"],
|
||||
status: "blocked"
|
||||
subject: "IMPL-001",
|
||||
owner: "executor",
|
||||
description: `Code implementation following PLAN-001\nSession: ${sessionFolder}`,
|
||||
blockedBy: ["PLAN-001"],
|
||||
status: "pending"
|
||||
})
|
||||
|
||||
// Task 15: Integration
|
||||
TaskCreate({
|
||||
team_id: teamId,
|
||||
task_id: "integration",
|
||||
assigned_to: "implementer",
|
||||
phase: "impl",
|
||||
description: "Integrate components and test",
|
||||
dependencies: ["core-impl"],
|
||||
status: "blocked"
|
||||
subject: "TEST-001",
|
||||
owner: "tester",
|
||||
description: `Adaptive test-fix cycles and quality gates\nSession: ${sessionFolder}`,
|
||||
blockedBy: ["IMPL-001"],
|
||||
status: "pending"
|
||||
})
|
||||
|
||||
// Task 16: Finalize Implementation
|
||||
TaskCreate({
|
||||
team_id: teamId,
|
||||
task_id: "finalize-impl",
|
||||
assigned_to: "implementer",
|
||||
phase: "impl",
|
||||
description: "Finalize implementation and documentation",
|
||||
dependencies: ["integration"],
|
||||
status: "blocked"
|
||||
subject: "REVIEW-001",
|
||||
owner: "reviewer",
|
||||
description: `4-dimension code review of IMPL-001 output\nSession: ${sessionFolder}`,
|
||||
blockedBy: ["IMPL-001"],
|
||||
status: "pending"
|
||||
})
|
||||
|
||||
Output("[coordinator] Full-lifecycle task chain created (16 tasks)")
|
||||
Output("[coordinator] Starting with: req-analysis")
|
||||
Output("[coordinator] Starting with: RESEARCH-001 (analyst)")
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### Strategy 4: FE-Only Mode (3 tasks)
|
||||
|
||||
Pipeline: `PLAN → DEV-FE → QA-FE` (with GC loop: max 2 rounds)
|
||||
|
||||
```javascript
|
||||
if (requirements.mode === "fe-only") {
|
||||
Output("[coordinator] Creating fe-only task chain (3 tasks)")
|
||||
|
||||
TaskCreate({
|
||||
subject: "PLAN-001",
|
||||
owner: "planner",
|
||||
description: `Multi-angle codebase exploration and structured planning (frontend focus)\nSession: ${sessionFolder}\nScope: ${requirements.scope}`,
|
||||
blockedBy: [],
|
||||
status: "pending"
|
||||
})
|
||||
|
||||
TaskCreate({
|
||||
subject: "DEV-FE-001",
|
||||
owner: "fe-developer",
|
||||
description: `Frontend component/page implementation following PLAN-001\nSession: ${sessionFolder}`,
|
||||
blockedBy: ["PLAN-001"],
|
||||
status: "pending"
|
||||
})
|
||||
|
||||
TaskCreate({
|
||||
subject: "QA-FE-001",
|
||||
owner: "fe-qa",
|
||||
description: `5-dimension frontend QA for DEV-FE-001 output\nSession: ${sessionFolder}`,
|
||||
blockedBy: ["DEV-FE-001"],
|
||||
status: "pending"
|
||||
})
|
||||
|
||||
// Note: GC loop (DEV-FE-002 → QA-FE-002) created dynamically by coordinator
|
||||
// when QA-FE-001 verdict = NEEDS_FIX (max 2 rounds)
|
||||
|
||||
Output("[coordinator] FE-only task chain created (3 tasks)")
|
||||
Output("[coordinator] Starting with: PLAN-001 (planner)")
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### Strategy 5: Fullstack Mode (6 tasks)
|
||||
|
||||
Pipeline: `PLAN → IMPL ∥ DEV-FE → TEST ∥ QA-FE → REVIEW`
|
||||
|
||||
```javascript
|
||||
if (requirements.mode === "fullstack") {
|
||||
Output("[coordinator] Creating fullstack task chain (6 tasks)")
|
||||
|
||||
TaskCreate({
|
||||
subject: "PLAN-001",
|
||||
owner: "planner",
|
||||
description: `Multi-angle codebase exploration and structured planning (fullstack)\nSession: ${sessionFolder}\nScope: ${requirements.scope}`,
|
||||
blockedBy: [],
|
||||
status: "pending"
|
||||
})
|
||||
|
||||
// Backend + Frontend in parallel
|
||||
TaskCreate({
|
||||
subject: "IMPL-001",
|
||||
owner: "executor",
|
||||
description: `Backend implementation following PLAN-001\nSession: ${sessionFolder}`,
|
||||
blockedBy: ["PLAN-001"],
|
||||
status: "pending"
|
||||
})
|
||||
|
||||
TaskCreate({
|
||||
subject: "DEV-FE-001",
|
||||
owner: "fe-developer",
|
||||
description: `Frontend implementation following PLAN-001\nSession: ${sessionFolder}`,
|
||||
blockedBy: ["PLAN-001"],
|
||||
status: "pending"
|
||||
})
|
||||
|
||||
// Testing + QA in parallel
|
||||
TaskCreate({
|
||||
subject: "TEST-001",
|
||||
owner: "tester",
|
||||
description: `Backend test-fix cycles\nSession: ${sessionFolder}`,
|
||||
blockedBy: ["IMPL-001"],
|
||||
status: "pending"
|
||||
})
|
||||
|
||||
TaskCreate({
|
||||
subject: "QA-FE-001",
|
||||
owner: "fe-qa",
|
||||
description: `Frontend QA for DEV-FE-001\nSession: ${sessionFolder}`,
|
||||
blockedBy: ["DEV-FE-001"],
|
||||
status: "pending"
|
||||
})
|
||||
|
||||
// Final review after all testing
|
||||
TaskCreate({
|
||||
subject: "REVIEW-001",
|
||||
owner: "reviewer",
|
||||
description: `Full code review (backend + frontend)\nSession: ${sessionFolder}`,
|
||||
blockedBy: ["TEST-001", "QA-FE-001"],
|
||||
status: "pending"
|
||||
})
|
||||
|
||||
Output("[coordinator] Fullstack task chain created (6 tasks)")
|
||||
Output("[coordinator] Starting with: PLAN-001 (planner)")
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### Strategy 6: Full-Lifecycle-FE Mode (18 tasks)
|
||||
|
||||
Pipeline: `[Spec 12] → PLAN(blockedBy: DISCUSS-006) → IMPL ∥ DEV-FE → TEST ∥ QA-FE → REVIEW`
|
||||
|
||||
```javascript
|
||||
if (requirements.mode === "full-lifecycle-fe") {
|
||||
Output("[coordinator] Creating full-lifecycle-fe task chain (18 tasks)")
|
||||
|
||||
// SPEC PHASE (12 tasks) — same as spec-only
|
||||
TaskCreate({ subject: "RESEARCH-001", owner: "analyst", description: `Seed analysis\nSession: ${sessionFolder}\nScope: ${requirements.scope}`, blockedBy: [], status: "pending" })
|
||||
TaskCreate({ subject: "DISCUSS-001", owner: "discussant", description: `Critique research findings\nSession: ${sessionFolder}`, blockedBy: ["RESEARCH-001"], status: "pending" })
|
||||
TaskCreate({ subject: "DRAFT-001", owner: "writer", description: `Generate Product Brief\nSession: ${sessionFolder}`, blockedBy: ["DISCUSS-001"], status: "pending" })
|
||||
TaskCreate({ subject: "DISCUSS-002", owner: "discussant", description: `Critique Product Brief\nSession: ${sessionFolder}`, blockedBy: ["DRAFT-001"], status: "pending" })
|
||||
TaskCreate({ subject: "DRAFT-002", owner: "writer", description: `Generate Requirements/PRD\nSession: ${sessionFolder}`, blockedBy: ["DISCUSS-002"], status: "pending" })
|
||||
TaskCreate({ subject: "DISCUSS-003", owner: "discussant", description: `Critique Requirements\nSession: ${sessionFolder}`, blockedBy: ["DRAFT-002"], status: "pending" })
|
||||
TaskCreate({ subject: "DRAFT-003", owner: "writer", description: `Generate Architecture Document\nSession: ${sessionFolder}`, blockedBy: ["DISCUSS-003"], status: "pending" })
|
||||
TaskCreate({ subject: "DISCUSS-004", owner: "discussant", description: `Critique Architecture\nSession: ${sessionFolder}`, blockedBy: ["DRAFT-003"], status: "pending" })
|
||||
TaskCreate({ subject: "DRAFT-004", owner: "writer", description: `Generate Epics\nSession: ${sessionFolder}`, blockedBy: ["DISCUSS-004"], status: "pending" })
|
||||
TaskCreate({ subject: "DISCUSS-005", owner: "discussant", description: `Critique Epics\nSession: ${sessionFolder}`, blockedBy: ["DRAFT-004"], status: "pending" })
|
||||
TaskCreate({ subject: "QUALITY-001", owner: "reviewer", description: `Spec quality validation\nSession: ${sessionFolder}`, blockedBy: ["DISCUSS-005"], status: "pending" })
|
||||
TaskCreate({ subject: "DISCUSS-006", owner: "discussant", description: `Final review and sign-off\nSession: ${sessionFolder}`, blockedBy: ["QUALITY-001"], status: "pending" })
|
||||
|
||||
// IMPL PHASE (6 tasks) — fullstack, blocked by spec
|
||||
TaskCreate({ subject: "PLAN-001", owner: "planner", description: `Fullstack planning\nSession: ${sessionFolder}`, blockedBy: ["DISCUSS-006"], status: "pending" })
|
||||
TaskCreate({ subject: "IMPL-001", owner: "executor", description: `Backend implementation\nSession: ${sessionFolder}`, blockedBy: ["PLAN-001"], status: "pending" })
|
||||
TaskCreate({ subject: "DEV-FE-001", owner: "fe-developer", description: `Frontend implementation\nSession: ${sessionFolder}`, blockedBy: ["PLAN-001"], status: "pending" })
|
||||
TaskCreate({ subject: "TEST-001", owner: "tester", description: `Backend test-fix cycles\nSession: ${sessionFolder}`, blockedBy: ["IMPL-001"], status: "pending" })
|
||||
TaskCreate({ subject: "QA-FE-001", owner: "fe-qa", description: `Frontend QA\nSession: ${sessionFolder}`, blockedBy: ["DEV-FE-001"], status: "pending" })
|
||||
TaskCreate({ subject: "REVIEW-001", owner: "reviewer", description: `Full code review\nSession: ${sessionFolder}`, blockedBy: ["TEST-001", "QA-FE-001"], status: "pending" })
|
||||
|
||||
Output("[coordinator] Full-lifecycle-fe task chain created (18 tasks)")
|
||||
Output("[coordinator] Starting with: RESEARCH-001 (analyst)")
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Task Metadata Reference
|
||||
|
||||
```javascript
|
||||
// Unified metadata for all pipelines (used by Session Resume)
|
||||
const TASK_METADATA = {
|
||||
// Spec pipeline (12 tasks)
|
||||
"RESEARCH-001": { role: "analyst", deps: [], description: "Seed analysis: codebase exploration and context gathering" },
|
||||
"DISCUSS-001": { role: "discussant", deps: ["RESEARCH-001"], description: "Critique research findings, identify gaps" },
|
||||
"DRAFT-001": { role: "writer", deps: ["DISCUSS-001"], description: "Generate Product Brief" },
|
||||
"DISCUSS-002": { role: "discussant", deps: ["DRAFT-001"], description: "Critique Product Brief" },
|
||||
"DRAFT-002": { role: "writer", deps: ["DISCUSS-002"], description: "Generate Requirements/PRD" },
|
||||
"DISCUSS-003": { role: "discussant", deps: ["DRAFT-002"], description: "Critique Requirements/PRD" },
|
||||
"DRAFT-003": { role: "writer", deps: ["DISCUSS-003"], description: "Generate Architecture Document" },
|
||||
"DISCUSS-004": { role: "discussant", deps: ["DRAFT-003"], description: "Critique Architecture Document" },
|
||||
"DRAFT-004": { role: "writer", deps: ["DISCUSS-004"], description: "Generate Epics" },
|
||||
"DISCUSS-005": { role: "discussant", deps: ["DRAFT-004"], description: "Critique Epics" },
|
||||
"QUALITY-001": { role: "reviewer", deps: ["DISCUSS-005"], description: "5-dimension spec quality validation" },
|
||||
"DISCUSS-006": { role: "discussant", deps: ["QUALITY-001"], description: "Final review discussion and sign-off" },
|
||||
|
||||
// Impl pipeline (4 tasks) — deps shown for impl-only mode
|
||||
// In full-lifecycle, PLAN-001 deps = ["DISCUSS-006"]
|
||||
"PLAN-001": { role: "planner", deps: [], description: "Multi-angle codebase exploration and structured planning" },
|
||||
"IMPL-001": { role: "executor", deps: ["PLAN-001"], description: "Code implementation following plan" },
|
||||
"TEST-001": { role: "tester", deps: ["IMPL-001"], description: "Adaptive test-fix cycles and quality gates" },
|
||||
"REVIEW-001": { role: "reviewer", deps: ["IMPL-001"], description: "4-dimension code review" },
|
||||
|
||||
// Frontend pipeline tasks
|
||||
"DEV-FE-001": { role: "fe-developer", deps: ["PLAN-001"], description: "Frontend component/page implementation" },
|
||||
"QA-FE-001": { role: "fe-qa", deps: ["DEV-FE-001"], description: "5-dimension frontend QA" },
|
||||
// GC loop tasks (created dynamically)
|
||||
"DEV-FE-002": { role: "fe-developer", deps: ["QA-FE-001"], description: "Frontend fixes (GC round 2)" },
|
||||
"QA-FE-002": { role: "fe-qa", deps: ["DEV-FE-002"], description: "Frontend QA re-check (GC round 2)" }
|
||||
}
|
||||
|
||||
// Pipeline chain constants
|
||||
const SPEC_CHAIN = [
|
||||
"RESEARCH-001", "DISCUSS-001", "DRAFT-001", "DISCUSS-002",
|
||||
"DRAFT-002", "DISCUSS-003", "DRAFT-003", "DISCUSS-004",
|
||||
"DRAFT-004", "DISCUSS-005", "QUALITY-001", "DISCUSS-006"
|
||||
]
|
||||
|
||||
const IMPL_CHAIN = ["PLAN-001", "IMPL-001", "TEST-001", "REVIEW-001"]
|
||||
|
||||
const FE_CHAIN = ["DEV-FE-001", "QA-FE-001"]
|
||||
|
||||
const FULLSTACK_CHAIN = ["PLAN-001", "IMPL-001", "DEV-FE-001", "TEST-001", "QA-FE-001", "REVIEW-001"]
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Execution Method Handling
|
||||
|
||||
### Sequential Execution
|
||||
@@ -464,7 +495,7 @@ if (requirements.mode === "full-lifecycle") {
|
||||
```javascript
|
||||
if (requirements.executionMethod === "sequential") {
|
||||
Output("[coordinator] Sequential execution: tasks will run one at a time")
|
||||
// Only one task marked as "active" at a time
|
||||
// Only one task active at a time
|
||||
// Next task activated only after predecessor completes
|
||||
}
|
||||
```
|
||||
@@ -474,44 +505,9 @@ if (requirements.executionMethod === "sequential") {
|
||||
```javascript
|
||||
if (requirements.executionMethod === "parallel") {
|
||||
Output("[coordinator] Parallel execution: independent tasks will run concurrently")
|
||||
|
||||
// Activate all tasks with no dependencies
|
||||
const independentTasks = allTasks.filter(t => t.dependencies.length === 0)
|
||||
for (const task of independentTasks) {
|
||||
TaskUpdate(task.task_id, { status: "active" })
|
||||
Output(`[coordinator] Activated parallel task: ${task.task_id}`)
|
||||
}
|
||||
|
||||
// As tasks complete, activate all tasks whose dependencies are met
|
||||
// (Handled in coordination loop)
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Task Metadata Reference
|
||||
|
||||
```javascript
|
||||
const TASK_METADATA = {
|
||||
// Spec tasks
|
||||
"req-analysis": { phase: "spec", deps: [], description: "Analyze requirements" },
|
||||
"arch-design": { phase: "spec", deps: ["req-analysis"], description: "Design architecture" },
|
||||
"api-design": { phase: "spec", deps: ["arch-design"], description: "Design API contracts" },
|
||||
"data-model": { phase: "spec", deps: ["arch-design"], description: "Design data models" },
|
||||
"ui-spec": { phase: "spec", deps: ["arch-design"], description: "Design UI specifications" },
|
||||
"test-strategy": { phase: "spec", deps: ["api-design", "data-model"], description: "Define test strategy" },
|
||||
"error-handling": { phase: "spec", deps: ["api-design"], description: "Design error handling" },
|
||||
"security-review": { phase: "spec", deps: ["api-design", "data-model"], description: "Security review" },
|
||||
"perf-requirements": { phase: "spec", deps: ["arch-design"], description: "Performance requirements" },
|
||||
"doc-outline": { phase: "spec", deps: ["api-design"], description: "Documentation outline" },
|
||||
"review-spec": { phase: "spec", deps: ["test-strategy", "error-handling", "security-review", "perf-requirements", "doc-outline"], description: "Review specifications" },
|
||||
"finalize-spec": { phase: "spec", deps: ["review-spec"], description: "Finalize specifications" },
|
||||
|
||||
// Impl tasks
|
||||
"setup-scaffold": { phase: "impl", deps: ["finalize-spec"], description: "Setup project scaffold" },
|
||||
"core-impl": { phase: "impl", deps: ["setup-scaffold"], description: "Core implementation" },
|
||||
"integration": { phase: "impl", deps: ["core-impl"], description: "Integration work" },
|
||||
"finalize-impl": { phase: "impl", deps: ["integration"], description: "Finalize implementation" }
|
||||
// Tasks with all deps met can run in parallel
|
||||
// e.g., TEST-001 and REVIEW-001 both depend on IMPL-001 → run together
|
||||
// e.g., IMPL-001 and DEV-FE-001 both depend on PLAN-001 → run together
|
||||
}
|
||||
```
|
||||
|
||||
@@ -523,8 +519,5 @@ All outputs from this command use the `[coordinator]` tag:
|
||||
|
||||
```
|
||||
[coordinator] Creating spec-only task chain (12 tasks)
|
||||
[coordinator] Task created: req-analysis
|
||||
[coordinator] Task created: arch-design
|
||||
...
|
||||
[coordinator] Starting with: req-analysis
|
||||
[coordinator] Starting with: RESEARCH-001 (analyst)
|
||||
```
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -30,7 +30,7 @@
|
||||
| `task_complete` | Worker | Task finished | Update session, check dependencies, kick next task |
|
||||
| `task_blocked` | Worker | Dependency missing | Log block reason, wait for predecessor |
|
||||
| `discussion_needed` | Worker | Ambiguity found | Route to user via AskUserQuestion |
|
||||
| `research_complete` | Researcher | Research done | Checkpoint with user before impl |
|
||||
| `research_ready` | analyst | Research done | Checkpoint with user before impl |
|
||||
|
||||
## Toolbox
|
||||
|
||||
@@ -40,7 +40,7 @@
|
||||
|
||||
### Subagent Capabilities
|
||||
- `TeamCreate` - Initialize team with session metadata
|
||||
- `TeamSpawn` - Spawn worker subagents (spec-writer, implementer, researcher)
|
||||
- `TeamSpawn` - Spawn worker subagents (analyst, writer, discussant, planner, executor, tester, reviewer, etc.)
|
||||
- `TaskCreate` - Create tasks with dependencies
|
||||
- `TaskUpdate` - Update task status/metadata
|
||||
- `TaskGet` - Retrieve task details
|
||||
@@ -55,6 +55,66 @@
|
||||
|
||||
## Execution Flow
|
||||
|
||||
### Entry Router: Command Detection
|
||||
|
||||
**Purpose**: Detect invocation type and route to appropriate handler. Coordinator 有三种唤醒源:worker 回调、用户命令、初始调用。
|
||||
|
||||
```javascript
|
||||
const args = $ARGUMENTS
|
||||
|
||||
// ─── 1. Worker callback detection ───
|
||||
// Worker 完成后 SendMessage 到 coordinator,消息含 [role] 标识
|
||||
const callbackMatch = args.match(/\[(\w[\w-]*)\]/)
|
||||
const WORKER_ROLES = ['analyst','writer','discussant','planner','executor','tester','reviewer','explorer','architect','fe-developer','fe-qa']
|
||||
const isCallback = callbackMatch && WORKER_ROLES.includes(callbackMatch[1])
|
||||
|
||||
// ─── 2. User command detection ───
|
||||
const isCheck = /\b(check|status|--check)\b/i.test(args)
|
||||
const isResume = /\b(resume|continue|next|--resume|--continue)\b/i.test(args)
|
||||
|
||||
// ─── 3. Route ───
|
||||
if (isCallback || isCheck || isResume) {
|
||||
// Need active session
|
||||
const sessionFile = findActiveSession()
|
||||
if (!sessionFile) {
|
||||
Output("[coordinator] No active session found. Start a new session by providing a task description.")
|
||||
return
|
||||
}
|
||||
|
||||
// Load monitor command and execute
|
||||
Read("commands/monitor.md")
|
||||
|
||||
if (isCallback) {
|
||||
// Worker 回调 → 自动推进
|
||||
handleCallback(callbackMatch[1], args)
|
||||
} else if (isCheck) {
|
||||
// 状态报告 → 输出执行状态图
|
||||
handleCheck()
|
||||
} else if (isResume) {
|
||||
// 手动推进 → 检查成员状态并推进
|
||||
handleResume()
|
||||
}
|
||||
|
||||
// STOP — 所有命令执行完后立即停止
|
||||
return
|
||||
}
|
||||
|
||||
// ─── 4. Normal invoke → check for session resume or new session ───
|
||||
goto Phase0
|
||||
|
||||
// Helper: find active session file
|
||||
function findActiveSession() {
|
||||
const sessionFiles = Glob("D:/Claude_dms3/.workflow/.sessions/team-lifecycle-*.json")
|
||||
for (const f of sessionFiles) {
|
||||
const s = Read(f)
|
||||
if (s.status === "active") return f
|
||||
}
|
||||
return null
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### Phase 0: Session Resume Check
|
||||
|
||||
**Purpose**: Detect and resume interrupted sessions
|
||||
@@ -101,38 +161,44 @@ if (sessionFiles.length > 1) {
|
||||
SessionReconciliation: {
|
||||
Output("[coordinator] Reconciling session state...")
|
||||
|
||||
// Pipeline constants
|
||||
// Pipeline constants (aligned with SKILL.md Three-Mode Pipeline)
|
||||
const SPEC_CHAIN = [
|
||||
"req-analysis", "arch-design", "api-design", "data-model",
|
||||
"ui-spec", "test-strategy", "error-handling", "security-review",
|
||||
"perf-requirements", "doc-outline", "review-spec", "finalize-spec"
|
||||
"RESEARCH-001", "DISCUSS-001", "DRAFT-001", "DISCUSS-002",
|
||||
"DRAFT-002", "DISCUSS-003", "DRAFT-003", "DISCUSS-004",
|
||||
"DRAFT-004", "DISCUSS-005", "QUALITY-001", "DISCUSS-006"
|
||||
]
|
||||
|
||||
const IMPL_CHAIN = [
|
||||
"setup-scaffold", "core-impl", "integration", "finalize-impl"
|
||||
]
|
||||
const IMPL_CHAIN = ["PLAN-001", "IMPL-001", "TEST-001", "REVIEW-001"]
|
||||
|
||||
// Task metadata with dependencies
|
||||
const FE_CHAIN = ["DEV-FE-001", "QA-FE-001"]
|
||||
|
||||
const FULLSTACK_CHAIN = ["PLAN-001", "IMPL-001", "DEV-FE-001", "TEST-001", "QA-FE-001", "REVIEW-001"]
|
||||
|
||||
// Task metadata — role must match VALID_ROLES in SKILL.md
|
||||
const TASK_METADATA = {
|
||||
// Spec tasks
|
||||
"req-analysis": { phase: "spec", deps: [], description: "Analyze requirements" },
|
||||
"arch-design": { phase: "spec", deps: ["req-analysis"], description: "Design architecture" },
|
||||
"api-design": { phase: "spec", deps: ["arch-design"], description: "Design API contracts" },
|
||||
"data-model": { phase: "spec", deps: ["arch-design"], description: "Design data models" },
|
||||
"ui-spec": { phase: "spec", deps: ["arch-design"], description: "Design UI specifications" },
|
||||
"test-strategy": { phase: "spec", deps: ["api-design", "data-model"], description: "Define test strategy" },
|
||||
"error-handling": { phase: "spec", deps: ["api-design"], description: "Design error handling" },
|
||||
"security-review": { phase: "spec", deps: ["api-design", "data-model"], description: "Security review" },
|
||||
"perf-requirements": { phase: "spec", deps: ["arch-design"], description: "Performance requirements" },
|
||||
"doc-outline": { phase: "spec", deps: ["api-design"], description: "Documentation outline" },
|
||||
"review-spec": { phase: "spec", deps: ["test-strategy", "error-handling", "security-review", "perf-requirements", "doc-outline"], description: "Review specifications" },
|
||||
"finalize-spec": { phase: "spec", deps: ["review-spec"], description: "Finalize specifications" },
|
||||
// Spec pipeline (12 tasks)
|
||||
"RESEARCH-001": { role: "analyst", phase: "spec", deps: [], description: "Seed analysis: codebase exploration and context gathering" },
|
||||
"DISCUSS-001": { role: "discussant", phase: "spec", deps: ["RESEARCH-001"], description: "Critique research findings" },
|
||||
"DRAFT-001": { role: "writer", phase: "spec", deps: ["DISCUSS-001"], description: "Generate Product Brief" },
|
||||
"DISCUSS-002": { role: "discussant", phase: "spec", deps: ["DRAFT-001"], description: "Critique Product Brief" },
|
||||
"DRAFT-002": { role: "writer", phase: "spec", deps: ["DISCUSS-002"], description: "Generate Requirements/PRD" },
|
||||
"DISCUSS-003": { role: "discussant", phase: "spec", deps: ["DRAFT-002"], description: "Critique Requirements/PRD" },
|
||||
"DRAFT-003": { role: "writer", phase: "spec", deps: ["DISCUSS-003"], description: "Generate Architecture Document" },
|
||||
"DISCUSS-004": { role: "discussant", phase: "spec", deps: ["DRAFT-003"], description: "Critique Architecture Document" },
|
||||
"DRAFT-004": { role: "writer", phase: "spec", deps: ["DISCUSS-004"], description: "Generate Epics" },
|
||||
"DISCUSS-005": { role: "discussant", phase: "spec", deps: ["DRAFT-004"], description: "Critique Epics" },
|
||||
"QUALITY-001": { role: "reviewer", phase: "spec", deps: ["DISCUSS-005"], description: "5-dimension spec quality validation" },
|
||||
"DISCUSS-006": { role: "discussant", phase: "spec", deps: ["QUALITY-001"], description: "Final review discussion and sign-off" },
|
||||
|
||||
// Impl tasks
|
||||
"setup-scaffold": { phase: "impl", deps: ["finalize-spec"], description: "Setup project scaffold" },
|
||||
"core-impl": { phase: "impl", deps: ["setup-scaffold"], description: "Core implementation" },
|
||||
"integration": { phase: "impl", deps: ["core-impl"], description: "Integration work" },
|
||||
"finalize-impl": { phase: "impl", deps: ["integration"], description: "Finalize implementation" }
|
||||
// Impl pipeline (deps shown for impl-only; full-lifecycle adds PLAN-001 → ["DISCUSS-006"])
|
||||
"PLAN-001": { role: "planner", phase: "impl", deps: [], description: "Multi-angle codebase exploration and structured planning" },
|
||||
"IMPL-001": { role: "executor", phase: "impl", deps: ["PLAN-001"], description: "Code implementation following plan" },
|
||||
"TEST-001": { role: "tester", phase: "impl", deps: ["IMPL-001"], description: "Adaptive test-fix cycles and quality gates" },
|
||||
"REVIEW-001": { role: "reviewer", phase: "impl", deps: ["IMPL-001"], description: "4-dimension code review" },
|
||||
|
||||
// Frontend pipeline tasks
|
||||
"DEV-FE-001": { role: "fe-developer", phase: "impl", deps: ["PLAN-001"], description: "Frontend component/page implementation" },
|
||||
"QA-FE-001": { role: "fe-qa", phase: "impl", deps: ["DEV-FE-001"], description: "5-dimension frontend QA" }
|
||||
}
|
||||
|
||||
// Helper: Get predecessor task
|
||||
@@ -164,12 +230,16 @@ SessionReconciliation: {
|
||||
Output(` Pending: ${pendingTasks.length}`)
|
||||
|
||||
// Step 3: Determine remaining work
|
||||
const expectedChain = session.mode === "spec-only" ? SPEC_CHAIN :
|
||||
session.mode === "impl-only" ? IMPL_CHAIN :
|
||||
[...SPEC_CHAIN, ...IMPL_CHAIN]
|
||||
const expectedChain =
|
||||
session.mode === "spec-only" ? SPEC_CHAIN :
|
||||
session.mode === "impl-only" ? IMPL_CHAIN :
|
||||
session.mode === "fe-only" ? ["PLAN-001", ...FE_CHAIN] :
|
||||
session.mode === "fullstack" ? FULLSTACK_CHAIN :
|
||||
session.mode === "full-lifecycle-fe" ? [...SPEC_CHAIN, ...FULLSTACK_CHAIN] :
|
||||
[...SPEC_CHAIN, ...IMPL_CHAIN] // full-lifecycle default
|
||||
|
||||
const remainingTaskIds = expectedChain.filter(id =>
|
||||
!completedTasks.some(t => t.task_id === id)
|
||||
!completedTasks.some(t => t.subject === id)
|
||||
)
|
||||
|
||||
Output(`[coordinator] Remaining tasks: ${remainingTaskIds.join(", ")}`)
|
||||
@@ -186,32 +256,31 @@ SessionReconciliation: {
|
||||
|
||||
// Step 5: Create missing tasks
|
||||
for (const taskId of remainingTaskIds) {
|
||||
const existingTask = allTasks.find(t => t.task_id === taskId)
|
||||
const existingTask = allTasks.find(t => t.subject === taskId)
|
||||
if (!existingTask) {
|
||||
const metadata = TASK_METADATA[taskId]
|
||||
TaskCreate({
|
||||
team_id: session.team_id,
|
||||
task_id: taskId,
|
||||
phase: metadata.phase,
|
||||
description: metadata.description,
|
||||
dependencies: metadata.deps,
|
||||
subject: taskId,
|
||||
owner: metadata.role,
|
||||
description: `${metadata.description}\nSession: ${sessionFolder}`,
|
||||
blockedBy: metadata.deps,
|
||||
status: "pending"
|
||||
})
|
||||
Output(`[coordinator] Created missing task: ${taskId}`)
|
||||
Output(`[coordinator] Created missing task: ${taskId} (${metadata.role})`)
|
||||
}
|
||||
}
|
||||
|
||||
// Step 6: Verify dependencies
|
||||
for (const taskId of remainingTaskIds) {
|
||||
const task = TaskGet(taskId)
|
||||
const task = allTasks.find(t => t.subject === taskId)
|
||||
if (!task) continue
|
||||
const metadata = TASK_METADATA[taskId]
|
||||
const allDepsMet = metadata.deps.every(depId =>
|
||||
completedTasks.some(t => t.task_id === depId)
|
||||
completedTasks.some(t => t.subject === depId)
|
||||
)
|
||||
|
||||
if (allDepsMet && task.status === "blocked") {
|
||||
TaskUpdate(taskId, { status: "pending" })
|
||||
Output(`[coordinator] Unblocked task: ${taskId}`)
|
||||
if (allDepsMet && task.status !== "completed") {
|
||||
Output(`[coordinator] Unblocked task: ${taskId} (${metadata.role})`)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -231,7 +300,7 @@ SessionReconciliation: {
|
||||
const nextTask = TaskGet(nextTaskId)
|
||||
const metadata = TASK_METADATA[nextTaskId]
|
||||
|
||||
if (metadata.deps.every(depId => completedTasks.some(t => t.task_id === depId))) {
|
||||
if (metadata.deps.every(depId => completedTasks.some(t => t.subject === depId))) {
|
||||
TaskUpdate(nextTaskId, { status: "active" })
|
||||
Output(`[coordinator] Kicking task: ${nextTaskId}`)
|
||||
goto Phase4_CoordinationLoop
|
||||
@@ -422,7 +491,10 @@ const sessionData = {
|
||||
status: "active",
|
||||
created_at: new Date().toISOString(),
|
||||
tasks_total: requirements.mode === "spec-only" ? 12 :
|
||||
requirements.mode === "impl-only" ? 4 : 16,
|
||||
requirements.mode === "impl-only" ? 4 :
|
||||
requirements.mode === "fe-only" ? 3 :
|
||||
requirements.mode === "fullstack" ? 6 :
|
||||
requirements.mode === "full-lifecycle-fe" ? 18 : 16,
|
||||
tasks_completed: 0,
|
||||
current_phase: requirements.mode === "impl-only" ? "impl" : "spec"
|
||||
}
|
||||
@@ -431,16 +503,18 @@ Write(sessionFile, sessionData)
|
||||
Output(`[coordinator] Session file created: ${sessionFile}`)
|
||||
|
||||
// ⚠️ Workers are NOT pre-spawned here.
|
||||
// Workers are spawned per-stage in Phase 4 via Stop-Wait Task(run_in_background: false).
|
||||
// Workers are spawned on-demand in Phase 4 via Task(run_in_background: true).
|
||||
// Coordinator spawns → STOPS → worker 回调或用户 check/resume 唤醒 coordinator.
|
||||
// See SKILL.md Coordinator Spawn Template for worker prompt templates.
|
||||
//
|
||||
// Worker roles by mode (spawned on-demand):
|
||||
// spec-only: spec-writer
|
||||
// impl-only: implementer
|
||||
// fe-only: fe-developer, fe-qa
|
||||
// fullstack: implementer, fe-developer, fe-qa
|
||||
// full-lifecycle / full-lifecycle-fe: spec-writer + relevant impl roles
|
||||
// Always available: researcher (for ambiguity resolution)
|
||||
// Worker roles by mode (spawned on-demand, must match VALID_ROLES in SKILL.md):
|
||||
// spec-only: analyst, discussant, writer, reviewer
|
||||
// impl-only: planner, executor, tester, reviewer
|
||||
// fe-only: planner, fe-developer, fe-qa
|
||||
// fullstack: planner, executor, fe-developer, tester, fe-qa, reviewer
|
||||
// full-lifecycle: analyst, discussant, writer, reviewer, planner, executor, tester
|
||||
// full-lifecycle-fe: all of the above + fe-developer, fe-qa
|
||||
// On-demand (ambiguity): analyst or explorer
|
||||
|
||||
goto Phase3
|
||||
```
|
||||
@@ -465,27 +539,43 @@ goto Phase4
|
||||
|
||||
---
|
||||
|
||||
### Phase 4: Coordination Loop
|
||||
### Phase 4: Spawn-and-Stop
|
||||
|
||||
**Purpose**: Monitor task progress and route messages
|
||||
**Purpose**: Spawn first batch of ready workers, then STOP. 后续推进由 worker 回调或用户命令驱动。
|
||||
|
||||
> **设计原则(Stop-Wait)**: 模型执行没有时间概念,禁止任何形式的轮询等待。
|
||||
> - ❌ 禁止: `while` 循环 + `sleep` + 检查状态
|
||||
> - ✅ 采用: 同步 `Task(run_in_background: false)` 调用,Worker 返回 = 阶段完成信号
|
||||
> **设计原则(Spawn-and-Stop + Callback)**:
|
||||
> - ❌ 禁止: 阻塞循环 `Task(run_in_background: false)` 串行等待所有 worker
|
||||
> - ❌ 禁止: `while` + `sleep` + 轮询
|
||||
> - ✅ 采用: `Task(run_in_background: true)` 后台 spawn,立即返回
|
||||
> - ✅ 采用: Worker SendMessage 回调自动唤醒 coordinator
|
||||
> - ✅ 采用: 用户 `check` / `resume` 命令辅助推进
|
||||
>
|
||||
> 按 Phase 3 创建的任务链顺序,逐阶段 spawn worker 同步执行。
|
||||
> Worker prompt 使用 SKILL.md Coordinator Spawn Template。
|
||||
> Coordinator 每次只做一步操作,然后 STOP 交还控制权。
|
||||
> 流水线通过三种唤醒源推进:worker 回调(自动)、用户 resume(手动)、用户 check(状态)。
|
||||
|
||||
```javascript
|
||||
Output("[coordinator] Phase 4: Coordination Loop")
|
||||
Output("[coordinator] Phase 4: Spawning first batch...")
|
||||
|
||||
// Delegate to command file
|
||||
const monitorStrategy = Read("commands/monitor.md")
|
||||
// Load monitor command logic
|
||||
Read("commands/monitor.md")
|
||||
|
||||
// Execute strategy defined in command file
|
||||
// (monitor.md contains the complete message routing and checkpoint logic)
|
||||
// Spawn first batch of ready tasks → STOP
|
||||
const result = handleSpawnNext()
|
||||
|
||||
goto Phase5
|
||||
if (result === "PIPELINE_COMPLETE") {
|
||||
goto Phase5
|
||||
}
|
||||
|
||||
// STOP — coordinator 完成输出,控制权交还给用户
|
||||
// 后续推进方式:
|
||||
// 1. Worker 完成 → SendMessage 回调 → Entry Router → handleCallback → 自动推进
|
||||
// 2. User 输入 "check" → Entry Router → handleCheck → 状态报告
|
||||
// 3. User 输入 "resume" → Entry Router → handleResume → 手动推进
|
||||
Output("")
|
||||
Output("[coordinator] Coordinator paused. Pipeline will advance via:")
|
||||
Output(" • Worker callbacks (automatic)")
|
||||
Output(" • 'check' — view execution status graph")
|
||||
Output(" • 'resume' — manually advance pipeline")
|
||||
```
|
||||
|
||||
---
|
||||
@@ -514,7 +604,7 @@ Output(`[coordinator] Duration: ${calculateDuration(session.created_at, new Date
|
||||
const completedTasks = teamState.tasks.filter(t => t.status === "completed")
|
||||
Output("[coordinator] Deliverables:")
|
||||
for (const task of completedTasks) {
|
||||
Output(` ✓ ${task.task_id}: ${task.description}`)
|
||||
Output(` ✓ ${task.subject}: ${task.description}`)
|
||||
if (task.output_file) {
|
||||
Output(` Output: ${task.output_file}`)
|
||||
}
|
||||
@@ -547,12 +637,12 @@ switch (nextAction) {
|
||||
case "review":
|
||||
const taskToReview = AskUserQuestion({
|
||||
question: "Which task output to review?",
|
||||
choices: completedTasks.map(t => t.task_id)
|
||||
choices: completedTasks.map(t => t.subject)
|
||||
})
|
||||
const reviewTask = completedTasks.find(t => t.task_id === taskToReview)
|
||||
const reviewTask = completedTasks.find(t => t.subject === taskToReview)
|
||||
if (reviewTask.output_file) {
|
||||
const content = Read(reviewTask.output_file)
|
||||
Output(`[coordinator] Task: ${reviewTask.task_id}`)
|
||||
Output(`[coordinator] Task: ${reviewTask.subject}`)
|
||||
Output(content)
|
||||
}
|
||||
goto Phase5 // Loop back for more actions
|
||||
@@ -569,8 +659,8 @@ switch (nextAction) {
|
||||
|
||||
case "handoff-lite-plan":
|
||||
Output("[coordinator] Generating lite-plan from specifications...")
|
||||
// Read finalize-spec output
|
||||
const specOutput = Read(getTaskOutput("finalize-spec"))
|
||||
// Read spec completion output (DISCUSS-006 = final sign-off)
|
||||
const specOutput = Read(getTaskOutput("DISCUSS-006"))
|
||||
// Create lite-plan format
|
||||
const litePlan = generateLitePlan(specOutput)
|
||||
const litePlanFile = `D:/Claude_dms3/.workflow/.sessions/${session.session_id}-lite-plan.md`
|
||||
@@ -580,7 +670,7 @@ switch (nextAction) {
|
||||
|
||||
case "handoff-full-plan":
|
||||
Output("[coordinator] Generating full-plan from specifications...")
|
||||
const fullSpecOutput = Read(getTaskOutput("finalize-spec"))
|
||||
const fullSpecOutput = Read(getTaskOutput("DISCUSS-006"))
|
||||
const fullPlan = generateFullPlan(fullSpecOutput)
|
||||
const fullPlanFile = `D:/Claude_dms3/.workflow/.sessions/${session.session_id}-full-plan.md`
|
||||
Write(fullPlanFile, fullPlan)
|
||||
@@ -589,7 +679,7 @@ switch (nextAction) {
|
||||
|
||||
case "handoff-req-plan":
|
||||
Output("[coordinator] Generating req-plan from requirements...")
|
||||
const reqAnalysis = Read(getTaskOutput("req-analysis"))
|
||||
const reqAnalysis = Read(getTaskOutput("RESEARCH-001"))
|
||||
const reqPlan = generateReqPlan(reqAnalysis)
|
||||
const reqPlanFile = `D:/Claude_dms3/.workflow/.sessions/${session.session_id}-req-plan.md`
|
||||
Write(reqPlanFile, reqPlan)
|
||||
@@ -598,7 +688,7 @@ switch (nextAction) {
|
||||
|
||||
case "handoff-create-issues":
|
||||
Output("[coordinator] Generating GitHub issues...")
|
||||
const issuesSpec = Read(getTaskOutput("finalize-spec"))
|
||||
const issuesSpec = Read(getTaskOutput("DISCUSS-006"))
|
||||
const issues = generateGitHubIssues(issuesSpec)
|
||||
const issuesFile = `D:/Claude_dms3/.workflow/.sessions/${session.session_id}-issues.json`
|
||||
Write(issuesFile, issues)
|
||||
@@ -665,7 +755,14 @@ function generateGitHubIssues(specOutput) {
|
||||
"resumed_at": null,
|
||||
"tasks_total": 16,
|
||||
"tasks_completed": 5,
|
||||
"current_phase": "spec"
|
||||
"current_phase": "spec",
|
||||
"active_workers": [
|
||||
{
|
||||
"task_subject": "DISCUSS-003",
|
||||
"role": "discussant",
|
||||
"spawned_at": "2026-02-18T10:15:00Z"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
Reference in New Issue
Block a user