Enhance search functionality and indexing pipeline

- Updated `cmd_search` to include line numbers and content in search results.
- Modified `IndexingPipeline` to handle start and end line numbers for chunks.
- Enhanced `FTSEngine` to support storing line metadata in the database.
- Improved `SearchPipeline` to return line numbers and full content in search results.
- Added unit tests for bridge, FTS delete operations, metadata store, and watcher functionality.
- Introduced a `.gitignore` file to exclude specific directories.
This commit is contained in:
catlog22
2026-03-17 14:55:27 +08:00
parent bfe5426b7e
commit 0f02b75be1
25 changed files with 2014 additions and 1482 deletions

View File

@@ -1,19 +1,20 @@
---
name: prompt-generator
description: Generate or convert Claude Code prompt files — command orchestrators, agent role definitions, or style conversion of existing files. Follows GSD-style content separation with built-in quality gates. Triggers on "create command", "new command", "create agent", "new agent", "convert command", "convert agent", "prompt generator".
description: Generate or convert Claude Code prompt files — command orchestrators, skill files, agent role definitions, or style conversion of existing files. Follows GSD-style content separation with built-in quality gates. Triggers on "create command", "new command", "create skill", "new skill", "create agent", "new agent", "convert command", "convert skill", "convert agent", "prompt generator", "优化".
allowed-tools: Read, Write, Edit, Bash, Glob, AskUserQuestion
---
<purpose>
Generate or convert Claude Code prompt files with concrete, domain-specific content. Three modes:
Generate or convert Claude Code prompt files with concrete, domain-specific content. Four modes:
- **Create command** — new orchestration workflow at `.claude/commands/` or `~/.claude/commands/`
- **Create skill** — new skill file at `.claude/skills/*/SKILL.md` (progressive loading, no @ refs)
- **Create agent** — new role + expertise file at `.claude/agents/`
- **Convert** — restyle existing command/agent to GSD conventions with zero content loss
- **Convert** — restyle existing command/skill/agent to GSD conventions with zero content loss
Content separation principle (from GSD): commands own orchestration flow; agents own domain knowledge.
Content separation principle (from GSD): commands/skills own orchestration flow; agents own domain knowledge. Skills are a variant of commands but loaded progressively inline — they CANNOT use `@` file references.
Invoked when user requests "create command", "new command", "create agent", "new agent", "convert command", "convert agent", or "prompt generator".
Invoked when user requests "create command", "new command", "create skill", "new skill", "create agent", "new agent", "convert command", "convert skill", "convert agent", "prompt generator", or "优化".
</purpose>
<required_reading>
@@ -33,11 +34,17 @@ Parse `$ARGUMENTS` to determine what to generate.
| Signal | Type |
|--------|------|
| "command", "workflow", "orchestrator" in args | `command` |
| "skill", "SKILL.md" in args, or path contains `.claude/skills/` | `skill` |
| "agent", "role", "worker" in args | `agent` |
| "convert", "restyle", "refactor" + file path in args | `convert` |
| "convert", "restyle", "refactor", "optimize", "优化" + file path in args | `convert` |
| Ambiguous or missing | Ask user |
**Convert mode detection:** If args contain a file path (`.md` extension) + conversion keywords, enter convert mode. Extract `$SOURCE_PATH` from args.
**Convert mode detection:** If args contain a file path (`.md` extension) + conversion keywords, enter convert mode. Extract `$SOURCE_PATH` from args. Auto-detect source type from path:
- `.claude/commands/` → command
- `.claude/skills/*/SKILL.md` → skill
- `.claude/agents/` → agent
**Skill vs Command distinction:** Skills (`.claude/skills/*/SKILL.md`) are loaded **progressively inline** into the conversation context. They CANNOT use `@` file references — only `Read()` tool calls within process steps. See `@specs/command-design-spec.md` → "Skill Variant" section.
If ambiguous:
@@ -47,13 +54,14 @@ AskUserQuestion(
question: "What type of prompt file do you want to generate?",
options: [
{ label: "Command", description: "New orchestration workflow — process steps, user interaction, agent spawning" },
{ label: "Skill", description: "New skill file — progressive loading, no @ refs, inline Read() for external files" },
{ label: "Agent", description: "New role definition — identity, domain expertise, behavioral rules" },
{ label: "Convert", description: "Restyle existing command/agent to GSD conventions (zero content loss)" }
{ label: "Convert", description: "Restyle existing command/agent/skill to GSD conventions (zero content loss)" }
]
)
```
Store as `$ARTIFACT_TYPE` (`command` | `agent` | `convert`).
Store as `$ARTIFACT_TYPE` (`command` | `skill` | `agent` | `convert`).
## 2. Validate Parameters
@@ -101,6 +109,12 @@ Else:
$TARGET_PATH = {base}/{$NAME}.md
```
**Skill:**
```
$TARGET_PATH = .claude/skills/{$NAME}/SKILL.md
```
**Agent:**
```
@@ -179,6 +193,31 @@ Generate a complete command file with:
- Shell blocks use heredoc for multi-line, quote all variables
- Include `<auto_mode>` section if command supports `--auto` flag
### 5a-skill. Skill Generation (variant of command)
Follow `@specs/command-design-spec.md` → "Skill Variant" section.
Skills are command-like orchestrators but loaded **progressively inline** — they CANNOT use `@` file references.
Generate a complete skill file with:
1. **`<purpose>`** — 2-3 sentences: what + when + what it produces
2. **NO `<required_reading>`** — skills cannot use `@` refs. External files loaded via `Read()` within process steps.
3. **`<process>`** — numbered steps (GSD workflow style):
- Step 1: Initialize / parse arguments / set workflow preferences
- Steps 2-N: Domain-specific orchestration logic with inline `Read("phases/...")` for phase files
- Each step: validation, agent spawning via `Agent()`, error handling
- Final step: completion status or handoff to next skill via `Skill()`
4. **`<success_criteria>`** — checkbox list of verifiable conditions
**Skill-specific writing rules:**
- **NO `<required_reading>` tag** — `@` syntax not supported in skills
- **NO `@path` references** anywhere in the file — use `Read("path")` within `<process>` steps
- Phase files loaded on-demand: `Read("phases/01-xxx.md")` within the step that needs it
- Frontmatter uses `allowed-tools:` (not `argument-hint:`)
- `<offer_next>` is optional — skills often chain via `Skill()` calls
- `<auto_mode>` can be inline within `<process>` step 1 or as standalone section
### 5b. Agent Generation
Follow `@specs/agent-design-spec.md` and `@templates/agent-md.md`.
@@ -225,11 +264,20 @@ $INVENTORY = {
| Signal | Type |
|--------|------|
| Path in `.claude/skills/*/SKILL.md` | skill |
| `allowed-tools:` in frontmatter + path in `.claude/skills/` | skill |
| Contains `<process>`, `<step>`, numbered `## N.` steps | command |
| Contains `<role>`, `tools:` in frontmatter, domain sections | agent |
| Flat markdown with `## Implementation`, `## Phase N` | command (unstructured) |
| Flat markdown with `## Implementation`, `## Phase N` + in skills dir | skill (unstructured) |
| Flat markdown with `## Implementation`, `## Phase N` + in commands dir | command (unstructured) |
| Flat prose with role description, no process steps | agent (unstructured) |
**Skill-specific conversion rules:**
- **NO `<required_reading>`** — skills cannot use `@` file references (progressive loading)
- **NO `@path` references** anywhere — replace with `Read("path")` within `<process>` steps
- If source has `@specs/...` or `@phases/...` refs, convert to `Read("specs/...")` / `Read("phases/...")`
- Follow `@specs/conversion-spec.md` → "Skill Conversion Rules" section
**Step 5c.3: Build conversion map.**
Map every source section to its target location. Follow `@specs/conversion-spec.md` transformation rules.
@@ -293,6 +341,20 @@ Set `$TARGET_PATH = $SOURCE_PATH` (in-place conversion) unless user specifies ou
| `<success_criteria>` | 4+ checkbox items, all verifiable |
| Content separation | No domain expertise embedded — only orchestration |
### 6b-skill. Skill-Specific Checks
| Check | Pass Condition |
|-------|---------------|
| `<purpose>` | 2-3 sentences, no placeholders |
| **NO `<required_reading>`** | Must NOT contain `<required_reading>` tag |
| **NO `@` file references** | Zero `@specs/`, `@phases/`, `@./` patterns in prose |
| `<process>` with numbered steps | At least 3 `## N.` headers |
| Step 1 is initialization | Parses args, sets workflow preferences |
| Phase file loading | Uses `Read("phases/...")` within process steps (if has phases) |
| `<success_criteria>` | 4+ checkbox items, all verifiable |
| Frontmatter `allowed-tools` | Present and lists required tools |
| Content separation | No domain expertise embedded — only orchestration |
### 6c. Agent-Specific Checks
| Check | Pass Condition |

View File

@@ -36,6 +36,7 @@ allowed-tools: Tool1, Tool2 # Optional: restricted tool set
.claude/commands/deploy.md # Top-level command
.claude/commands/issue/create.md # Grouped command
~/.claude/commands/global-status.md # User-level command
.claude/skills/my-skill/SKILL.md # Skill file (see Skill Variant below)
```
## Content Structure
@@ -45,12 +46,60 @@ Commands use XML semantic tags with process steps inside `<process>`:
| Tag | Required | Purpose |
|-----|----------|---------|
| `<purpose>` | Yes | What + when + what it produces (2-3 sentences) |
| `<required_reading>` | Yes | @ file references loaded before execution |
| `<required_reading>` | Commands only | @ file references loaded before execution |
| `<process>` | Yes | Steps — numbered or named (see Step Styles below) |
| `<auto_mode>` | Optional | Behavior when `--auto` flag present |
| `<offer_next>` | Recommended | Formatted completion status + next actions |
| `<success_criteria>` | Yes | Checkbox list of verifiable conditions |
## Skill Variant
Skills (`.claude/skills/*/SKILL.md`) follow command structure with critical differences due to **progressive loading** — skills are loaded inline into the conversation context, NOT via file resolution.
### Key Differences: Skill vs Command
| Aspect | Command | Skill |
|--------|---------|-------|
| Location | `.claude/commands/` | `.claude/skills/*/SKILL.md` |
| Loading | Slash-command invocation, `@` refs resolved | Progressive inline loading into conversation |
| `<required_reading>` | Yes — `@path` refs auto-resolved | **NO**`@` refs do NOT work in skills |
| External file access | `@` references | `Read()` tool calls within `<process>` steps |
| Phase files | N/A | `Read("phases/01-xxx.md")` within process steps |
| Frontmatter | `name`, `description`, `argument-hint` | `name`, `description`, `allowed-tools` |
### Skill-Specific Rules
1. **NO `<required_reading>` tag** — Skills cannot use `@` file references. All external context must be loaded via `Read()` tool calls within `<process>` steps.
2. **Progressive phase loading** — For multi-phase skills with phase files in `phases/` subdirectory, use inline `Read()`:
```javascript
// Within process step: Load phase doc on-demand
Read("phases/01-session-discovery.md")
// Execute phase logic...
```
3. **Self-contained content** — All instructions, rules, and logic must be directly in the SKILL.md or loaded via `Read()` at runtime. No implicit file dependencies.
4. **Frontmatter uses `allowed-tools:`** instead of `argument-hint:`:
```yaml
---
name: my-skill
description: What this skill does
allowed-tools: Agent, Read, Write, Bash, Glob, Grep
---
```
### Skill Content Structure
| Tag | Required | Purpose |
|-----|----------|---------|
| `<purpose>` | Yes | What + when + what it produces (2-3 sentences) |
| `<process>` | Yes | Steps with inline `Read()` for external files |
| `<auto_mode>` | Optional | Behavior when `-y`/`--yes` flag present |
| `<success_criteria>` | Yes | Checkbox list of verifiable conditions |
**Note**: `<offer_next>` is less common in skills since skills often chain to other skills via `Skill()` calls.
## Step Styles
GSD uses two step styles. Choose based on command nature:

View File

@@ -36,6 +36,62 @@ Conversion Summary:
New sections added: {list of TODO sections}
```
## Artifact Type Detection
Before applying conversion rules, determine the source type:
| Source Location | Type |
|----------------|------|
| `.claude/commands/**/*.md` | command |
| `.claude/skills/*/SKILL.md` | skill |
| `.claude/agents/*.md` | agent |
**Skill detection signals**: `allowed-tools:` in frontmatter, located in `.claude/skills/` directory, progressive phase loading pattern (`Read("phases/...")`)
## Skill Conversion Rules
### Critical: No @ References
Skills are loaded **progressively inline** into the conversation context. They CANNOT use `@` file references — these only work in commands.
### Source Pattern → Target Pattern (Skill)
| Source Style | Target Style |
|-------------|-------------|
| `# Title` + flat markdown overview | `<purpose>` (2-3 sentences) |
| `## Implementation` / `## Execution Flow` / `## Phase Summary` | `<process>` with numbered `## N.` steps |
| Phase file references as prose | `Read("phases/...")` calls within process steps |
| `## Success Criteria` / `## Coordinator Checklist` | `<success_criteria>` with checkbox list |
| `## Auto Mode` / `## Auto Mode Defaults` | `<auto_mode>` section |
| `## Error Handling` | Preserve as-is within `<process>` or as standalone section |
| Code blocks, tables, ASCII diagrams | **Preserve exactly** |
### What NOT to Add (Skill-Specific)
| Element | Why NOT |
|---------|---------|
| `<required_reading>` | Skills cannot use `@` refs — progressive loading |
| `@specs/...` or `@phases/...` | `@` syntax not supported in skills |
| `<offer_next>` | Skills chain via `Skill()` calls, not offer menus |
### What to ADD (Skill-Specific)
| Missing Element | Add |
|----------------|-----|
| `<purpose>` | Extract from overview/description |
| `<process>` wrapper | Wrap implementation steps |
| `<success_criteria>` | Generate from coordinator checklist or existing content |
| `<auto_mode>` | If auto mode behavior exists, wrap in tag |
### Frontmatter Conversion (Skill)
| Source Field | Target Field | Transformation |
|-------------|-------------|----------------|
| `name` | `name` | Keep as-is |
| `description` | `description` | Keep as-is |
| `allowed-tools` | `allowed-tools` | Keep as-is |
| Missing `allowed-tools` | `allowed-tools` | Infer from content |
## Command Conversion Rules
### Source Pattern → Target Pattern

View File

@@ -4,17 +4,18 @@ description: Lightweight planning skill - task analysis, multi-angle exploration
allowed-tools: Skill, Agent, AskUserQuestion, TodoWrite, Read, Write, Edit, Bash, Glob, Grep
---
# Workflow-Lite-Plan
<purpose>
Planning pipeline: explore → clarify → plan → confirm → handoff to lite-execute.
Produces exploration results, a structured plan (plan.json), independent task files (.task/TASK-*.json), and hands off to lite-execute for implementation.
</purpose>
---
<process>
## Context Isolation
## 1. Context Isolation
> **CRITICAL**: If invoked from analyze-with-file (via "执行任务"), the analyze-with-file session is **COMPLETE** and all its phase instructions are FINISHED and MUST NOT be referenced. Only follow LP-Phase 1-5 defined in THIS document. Phase numbers are INDEPENDENT of any prior workflow.
## Input
## 2. Input
```
<task-description> Task description or path to .md file (required)
@@ -27,7 +28,7 @@ Planning pipeline: explore → clarify → plan → confirm → handoff to lite-
**Note**: Workflow preferences (`autoYes`, `forceExplore`) must be initialized at skill start. If not provided by caller, skill will prompt user for workflow mode selection.
## Output Artifacts
## 3. Output Artifacts
| Artifact | Description |
|----------|-------------|
@@ -43,14 +44,7 @@ Planning pipeline: explore → clarify → plan → confirm → handoff to lite-
**Schema Reference**: `~/.ccw/workflows/cli-templates/schemas/plan-overview-base-schema.json`
## Auto Mode Defaults
When `workflowPreferences.autoYes === true` (entire plan+execute workflow):
- **Clarification**: Skipped | **Plan Confirmation**: Allow & Execute | **Execution**: Auto | **Review**: Skip
Auto mode authorizes the complete plan-and-execute workflow with a single confirmation. No further prompts.
## Phase Summary
## 4. Phase Summary
| Phase | Core Action | Output |
|-------|-------------|--------|
@@ -61,9 +55,7 @@ Auto mode authorizes the complete plan-and-execute workflow with a single confir
| LP-4 | Display plan → AskUserQuestion (Confirm + Execution + Review) | userSelection |
| LP-5 | Build executionContext → Skill("lite-execute") | handoff (Mode 1) |
## Implementation
### LP-Phase 0: Workflow Preferences Initialization
## 5. LP-Phase 0: Workflow Preferences Initialization
```javascript
if (typeof workflowPreferences === 'undefined' || workflowPreferences === null) {
@@ -74,7 +66,7 @@ if (typeof workflowPreferences === 'undefined' || workflowPreferences === null)
}
```
### LP-Phase 1: Intelligent Multi-Angle Exploration
## 6. LP-Phase 1: Intelligent Multi-Angle Exploration
**Session Setup** (MANDATORY):
```javascript
@@ -248,9 +240,7 @@ console.log(`Exploration complete: ${explorationManifest.explorations.map(e => e
**Output**: `exploration-{angle}.json` (1-4 files) + `explorations-manifest.json`
---
### LP-Phase 2: Clarification (Optional, Multi-Round)
## 7. LP-Phase 2: Clarification (Optional, Multi-Round)
**Skip if**: No exploration or `clarification_needs` is empty across all explorations
@@ -307,9 +297,7 @@ if (workflowPreferences.autoYes) {
**Output**: `clarificationContext` (in-memory)
---
### LP-Phase 3: Planning
## 8. LP-Phase 3: Planning
**IMPORTANT**: LP-Phase 3 is **planning only** — NO code execution. All execution happens in LP-Phase 5 via lite-execute.
@@ -431,9 +419,7 @@ ${complexity}
// TodoWrite: Phase 3 → completed, Phase 4 → in_progress
---
### LP-Phase 4: Task Confirmation & Execution Selection
## 9. LP-Phase 4: Task Confirmation & Execution Selection
**Display Plan**:
```javascript
@@ -499,9 +485,7 @@ if (workflowPreferences.autoYes) {
// TodoWrite: Phase 4 → completed `[${userSelection.execution_method} + ${userSelection.code_review_tool}]`, Phase 5 → in_progress
---
### LP-Phase 5: Handoff to Execution
## 10. LP-Phase 5: Handoff to Execution
**CRITICAL**: lite-plan NEVER executes code directly. ALL execution goes through lite-execute.
@@ -562,7 +546,7 @@ Skill("lite-execute")
// executionContext passed as global variable (Mode 1: In-Memory Plan)
```
## Session Folder Structure
## 11. Session Folder Structure
```
.workflow/.lite-plan/{task-slug}-{YYYY-MM-DD}/
@@ -576,7 +560,7 @@ Skill("lite-execute")
└── ...
```
## Error Handling
## 12. Error Handling
| Error | Resolution |
|-------|------------|
@@ -585,3 +569,26 @@ Skill("lite-execute")
| Clarification timeout | Use exploration findings as-is |
| Confirmation timeout | Save context, display resume instructions |
| Modify loop > 3 times | Suggest breaking task or using /workflow-plan |
</process>
<auto_mode>
When `workflowPreferences.autoYes === true` (entire plan+execute workflow):
- **Clarification**: Skipped | **Plan Confirmation**: Allow & Execute | **Execution**: Auto | **Review**: Skip
Auto mode authorizes the complete plan-and-execute workflow with a single confirmation. No further prompts.
</auto_mode>
<success_criteria>
- [ ] Workflow preferences (autoYes, forceExplore) initialized at LP-Phase 0
- [ ] Complexity assessed and exploration angles selected appropriately
- [ ] Parallel exploration agents launched with run_in_background=false
- [ ] Explorations manifest built from auto-discovered files
- [ ] Clarification needs aggregated, deduped, and presented in batches of 4
- [ ] Plan generated via direct Claude (Low) or cli-lite-planning-agent (Medium/High)
- [ ] Plan output as two-layer: plan.json (task_ids[]) + .task/TASK-*.json
- [ ] User confirmation collected (or auto-approved in auto mode)
- [ ] executionContext fully built with all artifacts and session references
- [ ] Handoff to lite-execute via Skill("lite-execute") with executionContext
- [ ] No code execution in planning phases -- all execution deferred to lite-execute
</success_criteria>

View File

@@ -4,18 +4,20 @@ description: Unified planning skill - 4-phase planning workflow, plan verificati
allowed-tools: Skill, Agent, AskUserQuestion, TodoWrite, Read, Write, Edit, Bash, Glob, Grep
---
# Workflow Plan
<purpose>
Unified planning skill combining 4-phase planning workflow, plan quality verification, and interactive replanning. Produces IMPL_PLAN.md, task JSONs, verification reports, and manages plan lifecycle through session-level artifact updates. Routes by mode (plan | verify | replan) and acts as a pure orchestrator: executes phases, parses outputs, and passes context.
</purpose>
Unified planning skill combining 4-phase planning workflow, plan quality verification, and interactive replanning. Produces IMPL_PLAN.md, task JSONs, verification reports, and manages plan lifecycle through session-level artifact updates.
<process>
## Architecture Overview
## 1. Architecture Overview
```
┌──────────────────────────────────────────────────────────────────┐
│ Workflow Plan Orchestrator (SKILL.md) │
│ → Route by mode: plan | verify | replan │
│ → Pure coordinator: Execute phases, parse outputs, pass context │
└─────────────────────────────────────────────────────────────────┘
└─────────────────────────────────────────────────────────────────┘
┌───────────────────────┼───────────────────────┐
↓ ↓ ↓
@@ -38,7 +40,7 @@ Unified planning skill combining 4-phase planning workflow, plan quality verific
└───────────┘─── Review ──→ Display session status inline
```
## Key Design Principles
## 2. Key Design Principles
1. **Pure Orchestrator**: SKILL.md routes and coordinates only; execution detail lives in phase files
2. **Progressive Phase Loading**: Read phase docs ONLY when that phase is about to execute
@@ -47,7 +49,7 @@ Unified planning skill combining 4-phase planning workflow, plan quality verific
5. **Auto-Continue**: After each phase completes, automatically execute next pending phase
6. **Accumulated State**: planning-notes.md carries context across phases for N+1 decisions
## Interactive Preference Collection
## 3. Interactive Preference Collection
Before dispatching to phase execution, collect workflow preferences via AskUserQuestion:
@@ -99,7 +101,7 @@ if (autoYes) {
**workflowPreferences** is passed to phase execution as context variable, referenced as `workflowPreferences.autoYes`, `workflowPreferences.interactive` within phases.
## Mode Detection
## 4. Mode Detection
```javascript
const args = $ARGUMENTS
@@ -113,7 +115,7 @@ function detectMode(args) {
}
```
## Compact Recovery (Phase Persistence)
## 5. Compact Recovery (Phase Persistence)
Multi-phase planning (Phase 1-4/5/6) spans long conversations. Uses **双重保险**: TodoWrite 跟踪 active phase 保护其不被压缩sentinel 作为兜底。
@@ -121,7 +123,7 @@ Multi-phase planning (Phase 1-4/5/6) spans long conversations. Uses **双重保
> The phase currently marked `in_progress` is the active execution phase — preserve its FULL content.
> Only compress phases marked `completed` or `pending`.
## Execution Flow
## 6. Execution Flow
### Plan Mode (default)
@@ -130,23 +132,23 @@ Input Parsing:
└─ Convert user input to structured format (GOAL/SCOPE/CONTEXT)
Phase 1: Session Discovery
└─ Ref: phases/01-session-discovery.md
└─ Ref: Read("phases/01-session-discovery.md")
└─ Output: sessionId (WFS-xxx), planning-notes.md
Phase 2: Context Gathering
└─ Ref: phases/02-context-gathering.md
└─ Ref: Read("phases/02-context-gathering.md")
├─ Tasks attached: Analyze structure → Identify integration → Generate package
└─ Output: contextPath + conflictRisk
Phase 3: Conflict Resolution (conditional: conflictRisk ≥ medium)
└─ Decision (conflictRisk check):
├─ conflictRisk ≥ medium → Ref: phases/03-conflict-resolution.md
├─ conflictRisk ≥ medium → Ref: Read("phases/03-conflict-resolution.md")
│ ├─ Tasks attached: Detect conflicts → Present to user → Apply strategies
│ └─ Output: Modified brainstorm artifacts
└─ conflictRisk < medium → Skip to Phase 4
Phase 4: Task Generation
└─ Ref: phases/04-task-generation.md
└─ Ref: Read("phases/04-task-generation.md")
└─ Output: IMPL_PLAN.md, task JSONs, TODO_LIST.md
Plan Confirmation (User Decision Gate):
@@ -160,7 +162,7 @@ Plan Confirmation (User Decision Gate):
```
Phase 5: Plan Verification
└─ Ref: phases/05-plan-verify.md
└─ Ref: Read("phases/05-plan-verify.md")
└─ Output: PLAN_VERIFICATION.md with quality gate recommendation
```
@@ -168,7 +170,7 @@ Phase 5: Plan Verification
```
Phase 6: Interactive Replan
└─ Ref: phases/06-replan.md
└─ Ref: Read("phases/06-replan.md")
└─ Output: Updated IMPL_PLAN.md, task JSONs, TODO_LIST.md
```
@@ -176,19 +178,19 @@ Phase 6: Interactive Replan
| Phase | Document | Purpose | Mode | Compact |
|-------|----------|---------|------|---------|
| 1 | [phases/01-session-discovery.md](phases/01-session-discovery.md) | Create or discover workflow session | plan | TodoWrite 驱动 |
| 2 | [phases/02-context-gathering.md](phases/02-context-gathering.md) | Gather project context and analyze codebase | plan | TodoWrite 驱动 |
| 3 | [phases/03-conflict-resolution.md](phases/03-conflict-resolution.md) | Detect and resolve conflicts (conditional) | plan | TodoWrite 驱动 |
| 4 | [phases/04-task-generation.md](phases/04-task-generation.md) | Generate implementation plan and task JSONs | plan | TodoWrite 驱动 + 🔄 sentinel |
| 5 | [phases/05-plan-verify.md](phases/05-plan-verify.md) | Read-only verification with quality gate | verify | TodoWrite 驱动 |
| 6 | [phases/06-replan.md](phases/06-replan.md) | Interactive replanning with boundary clarification | replan | TodoWrite 驱动 |
| 1 | phases/01-session-discovery.md | Create or discover workflow session | plan | TodoWrite 驱动 |
| 2 | phases/02-context-gathering.md | Gather project context and analyze codebase | plan | TodoWrite 驱动 |
| 3 | phases/03-conflict-resolution.md | Detect and resolve conflicts (conditional) | plan | TodoWrite 驱动 |
| 4 | phases/04-task-generation.md | Generate implementation plan and task JSONs | plan | TodoWrite 驱动 + 🔄 sentinel |
| 5 | phases/05-plan-verify.md | Read-only verification with quality gate | verify | TodoWrite 驱动 |
| 6 | phases/06-replan.md | Interactive replanning with boundary clarification | replan | TodoWrite 驱动 |
**Compact Rules**:
1. **TodoWrite `in_progress`** → 保留完整内容,禁止压缩
2. **TodoWrite `completed`** → 可压缩为摘要
3. **🔄 sentinel fallback** → Phase 4 包含 compact sentinel若 compact 后仅存 sentinel 而无完整 Step 协议,必须立即 `Read("phases/04-task-generation.md")` 恢复
## Core Rules
## 7. Core Rules
1. **Start Immediately**: First action is mode detection + TodoWrite initialization, second action is phase execution
2. **No Preliminary Analysis**: Do not read files, analyze structure, or gather context before Phase 1
@@ -199,7 +201,7 @@ Phase 6: Interactive Replan
7. **Progressive Phase Loading**: Read phase docs ONLY when that phase is about to execute
8. **DO NOT STOP**: Continuous multi-phase workflow. After executing all attached tasks, immediately collapse them and execute next phase
## Input Processing
## 8. Input Processing
**Convert User Input to Structured Format**:
@@ -228,7 +230,7 @@ Phase 6: Interactive Replan
- Extract goal, scope, requirements
- Format into structured description
## Data Flow
## 9. Data Flow
### Plan Mode
@@ -290,7 +292,7 @@ Phase 6: Mode detection → Clarification → Impact analysis → Backup → App
↓ Output: Updated artifacts + change summary
```
## TodoWrite Pattern
## 10. TodoWrite Pattern
**Core Concept**: Dynamic task attachment and collapse for real-time visibility into workflow execution.
@@ -349,7 +351,7 @@ Phase 6: Mode detection → Clarification → Impact analysis → Backup → App
**Note**: See individual Phase descriptions for detailed TodoWrite Update examples.
## Post-Phase Updates
## 11. Post-Phase Updates
After each phase completes, update planning-notes.md:
@@ -360,7 +362,7 @@ After each phase completes, update planning-notes.md:
See phase files for detailed update code.
## Error Handling
## 12. Error Handling
- **Parsing Failure**: If output parsing fails, retry command once, then report error
- **Validation Failure**: If validation fails, report which file/data is missing
@@ -368,7 +370,7 @@ See phase files for detailed update code.
- **Session Not Found** (verify/replan): Report error with available sessions list
- **Task Not Found** (replan): Report error with available tasks list
## Coordinator Checklist
## 13. Coordinator Checklist
### Plan Mode
- **Pre-Phase**: Convert user input to structured format (GOAL/SCOPE/CONTEXT)
@@ -403,7 +405,7 @@ See phase files for detailed update code.
- Initialize TodoWrite with replan-specific tasks
- Execute Phase 6 through all sub-phases (clarification → impact → backup → apply → verify)
## Structure Template Reference
## 14. Structure Template Reference
**Minimal Structure**:
```
@@ -421,7 +423,7 @@ REQUIREMENTS: [Specific technical requirements]
CONSTRAINTS: [Limitations or boundaries]
```
## Related Skills
## 15. Related Skills
**Prerequisite Skills**:
- `brainstorm` skill - Optional: Generate role-based analyses before planning
@@ -439,3 +441,26 @@ CONSTRAINTS: [Limitations or boundaries]
- Display session status inline - Review task breakdown and current progress
- `Skill(skill="workflow-execute")` - Begin implementation of generated tasks (skill: workflow-execute)
- `workflow-plan` skill (replan phase) - Modify plan (can also invoke via replan mode)
</process>
<auto_mode>
When `workflowPreferences.autoYes` is true (triggered by `-y` or `--yes` flag, or user selecting "Auto" mode):
- Skip all confirmation prompts, use default values
- Auto-select "Verify Plan Quality" at Plan Confirmation Gate
- Auto-continue to execution if verification returns PROCEED
- Skip interactive clarification in replan mode (use safe defaults)
</auto_mode>
<success_criteria>
- [ ] Mode correctly detected from skill trigger (plan / verify / replan)
- [ ] TodoWrite initialized and updated after each phase with attachment/collapse pattern
- [ ] All phases executed in sequence with proper data passing between phases
- [ ] Phase documents loaded progressively via Read() only when phase is about to execute
- [ ] planning-notes.md updated after each phase with accumulated context
- [ ] Phase 3 conditionally executed based on conflictRisk assessment
- [ ] Plan Confirmation Gate presented with correct options after Phase 4
- [ ] All output artifacts generated: IMPL_PLAN.md, task JSONs, TODO_LIST.md
- [ ] Compact recovery works: in_progress phases preserved, completed phases compressible
- [ ] Error handling covers parsing failures, validation failures, and missing sessions/tasks
</success_criteria>

View File

@@ -4,18 +4,20 @@ description: Unified TDD workflow skill combining 6-phase TDD planning with Red-
allowed-tools: Skill, Agent, AskUserQuestion, TaskCreate, TaskUpdate, TaskList, Read, Write, Edit, Bash, Glob, Grep
---
# Workflow TDD
<purpose>
Unified TDD workflow skill combining TDD planning (Red-Green-Refactor task chain generation with test-first development structure) and TDD verification (compliance validation with quality gate reporting). Produces IMPL_PLAN.md, task JSONs with internal TDD cycles, and TDD_COMPLIANCE_REPORT.md. Triggers on "workflow-tdd-plan" (plan mode) or "workflow-tdd-verify" (verify mode).
</purpose>
Unified TDD workflow skill combining TDD planning (Red-Green-Refactor task chain generation with test-first development structure) and TDD verification (compliance validation with quality gate reporting). Produces IMPL_PLAN.md, task JSONs with internal TDD cycles, and TDD_COMPLIANCE_REPORT.md.
<process>
## Architecture Overview
## 1. Architecture Overview
```
┌──────────────────────────────────────────────────────────────────┐
│ Workflow TDD Orchestrator (SKILL.md) │
│ → Route by mode: plan | verify │
│ → Pure coordinator: Execute phases, parse outputs, pass context │
└─────────────────────────────────────────────────────────────────┘
└─────────────────────────────────────────────────────────────────┘
┌───────────────────────┴───────────────────────┐
↓ ↓
@@ -38,7 +40,7 @@ Unified TDD workflow skill combining TDD planning (Red-Green-Refactor task chain
└───────────┘─── Review ──→ Display session status inline
```
## Key Design Principles
## 2. Key Design Principles
1. **Pure Orchestrator**: SKILL.md routes and coordinates only; execution detail lives in phase files
2. **Progressive Phase Loading**: Read phase docs ONLY when that phase is about to execute
@@ -47,7 +49,7 @@ Unified TDD workflow skill combining TDD planning (Red-Green-Refactor task chain
5. **Auto-Continue**: After each phase completes, automatically execute next pending phase
6. **TDD Iron Law**: NO PRODUCTION CODE WITHOUT A FAILING TEST FIRST - enforced in task structure
## Interactive Preference Collection
## 3. Interactive Preference Collection
Before dispatching to phase execution, collect workflow preferences via AskUserQuestion:
@@ -81,7 +83,7 @@ if (autoYes) {
**workflowPreferences** is passed to phase execution as context variable, referenced as `workflowPreferences.autoYes` within phases.
## Mode Detection
## 4. Mode Detection
```javascript
const args = $ARGUMENTS
@@ -94,7 +96,7 @@ function detectMode(args) {
}
```
## Compact Recovery (Phase Persistence)
## 5. Compact Recovery (Phase Persistence)
Multi-phase TDD planning (Phase 1-6/7) spans long conversations. Uses **双重保险**: TodoWrite 跟踪 active phase 保护其不被压缩sentinel 作为兜底。
@@ -102,42 +104,40 @@ Multi-phase TDD planning (Phase 1-6/7) spans long conversations. Uses **双重
> The phase currently marked `in_progress` is the active execution phase — preserve its FULL content.
> Only compress phases marked `completed` or `pending`.
## Execution Flow
### Plan Mode (default)
## 6. Execution Flow — Plan Mode (default)
```
Input Parsing:
└─ Convert user input to TDD structured format (GOAL/SCOPE/CONTEXT/TEST_FOCUS)
Phase 1: Session Discovery
└─ Ref: phases/01-session-discovery.md
└─ Read("phases/01-session-discovery.md")
└─ Output: sessionId (WFS-xxx)
Phase 2: Context Gathering
└─ Ref: phases/02-context-gathering.md
└─ Read("phases/02-context-gathering.md")
├─ Tasks attached: Analyze structure → Identify integration → Generate package
└─ Output: contextPath + conflictRisk
Phase 3: Test Coverage Analysis
└─ Ref: phases/03-test-coverage-analysis.md
└─ Read("phases/03-test-coverage-analysis.md")
├─ Tasks attached: Detect framework → Analyze coverage → Identify gaps
└─ Output: testContextPath
Phase 4: Conflict Resolution (conditional: conflictRisk ≥ medium)
└─ Decision (conflictRisk check):
├─ conflictRisk ≥ medium → Ref: phases/04-conflict-resolution.md
├─ conflictRisk ≥ medium → Read("phases/04-conflict-resolution.md")
│ ├─ Tasks attached: Detect conflicts → Log analysis → Apply strategies
│ └─ Output: conflict-resolution.json
└─ conflictRisk < medium → Skip to Phase 5
Phase 5: TDD Task Generation
└─ Ref: phases/05-tdd-task-generation.md
└─ Read("phases/05-tdd-task-generation.md")
├─ Tasks attached: Discovery → Planning → Output
└─ Output: IMPL_PLAN.md, IMPL-*.json, TODO_LIST.md
Phase 6: TDD Structure Validation
└─ Ref: phases/06-tdd-structure-validation.md
└─ Read("phases/06-tdd-structure-validation.md")
└─ Output: Validation report + Plan Confirmation Gate
Plan Confirmation (User Decision Gate):
@@ -147,32 +147,34 @@ Plan Confirmation (User Decision Gate):
└─ "Review Status Only" → Display session status inline
```
### Verify Mode
## 7. Execution Flow — Verify Mode
```
Phase 7: TDD Verification
└─ Ref: phases/07-tdd-verify.md
└─ Read("phases/07-tdd-verify.md")
└─ Output: TDD_COMPLIANCE_REPORT.md with quality gate recommendation
```
**Phase Reference Documents** (read on-demand when phase executes):
## 8. Phase Reference Documents
Read on-demand when phase executes using `Read("phases/...")`:
| Phase | Document | Purpose | Mode | Compact |
|-------|----------|---------|------|---------|
| 1 | [phases/01-session-discovery.md](phases/01-session-discovery.md) | Create or discover TDD workflow session | plan | TodoWrite 驱动 |
| 2 | [phases/02-context-gathering.md](phases/02-context-gathering.md) | Gather project context and analyze codebase | plan | TodoWrite 驱动 |
| 3 | [phases/03-test-coverage-analysis.md](phases/03-test-coverage-analysis.md) | Analyze test coverage and framework detection | plan | TodoWrite 驱动 |
| 4 | [phases/04-conflict-resolution.md](phases/04-conflict-resolution.md) | Detect and resolve conflicts (conditional) | plan | TodoWrite 驱动 |
| 5 | [phases/05-tdd-task-generation.md](phases/05-tdd-task-generation.md) | Generate TDD tasks with Red-Green-Refactor cycles | plan | TodoWrite 驱动 + 🔄 sentinel |
| 6 | [phases/06-tdd-structure-validation.md](phases/06-tdd-structure-validation.md) | Validate TDD structure and present confirmation gate | plan | TodoWrite 驱动 + 🔄 sentinel |
| 7 | [phases/07-tdd-verify.md](phases/07-tdd-verify.md) | Full TDD compliance verification with quality gate | verify | TodoWrite 驱动 |
| 1 | phases/01-session-discovery.md | Create or discover TDD workflow session | plan | TodoWrite 驱动 |
| 2 | phases/02-context-gathering.md | Gather project context and analyze codebase | plan | TodoWrite 驱动 |
| 3 | phases/03-test-coverage-analysis.md | Analyze test coverage and framework detection | plan | TodoWrite 驱动 |
| 4 | phases/04-conflict-resolution.md | Detect and resolve conflicts (conditional) | plan | TodoWrite 驱动 |
| 5 | phases/05-tdd-task-generation.md | Generate TDD tasks with Red-Green-Refactor cycles | plan | TodoWrite 驱动 + sentinel |
| 6 | phases/06-tdd-structure-validation.md | Validate TDD structure and present confirmation gate | plan | TodoWrite 驱动 + sentinel |
| 7 | phases/07-tdd-verify.md | Full TDD compliance verification with quality gate | verify | TodoWrite 驱动 |
**Compact Rules**:
1. **TodoWrite `in_progress`** → 保留完整内容,禁止压缩
2. **TodoWrite `completed`** → 可压缩为摘要
3. **🔄 sentinel fallback** → Phase 5/6 包含 compact sentinel若 compact 后仅存 sentinel 而无完整 Step 协议,必须立即 `Read()` 恢复对应 phase 文件
3. **sentinel fallback** → Phase 5/6 包含 compact sentinel若 compact 后仅存 sentinel 而无完整 Step 协议,必须立即 `Read()` 恢复对应 phase 文件
## Core Rules
## 9. Core Rules
1. **Start Immediately**: First action is mode detection + TaskCreate initialization, second action is phase execution
2. **No Preliminary Analysis**: Do not read files, analyze structure, or gather context before Phase 1
@@ -184,7 +186,7 @@ Phase 7: TDD Verification
8. **DO NOT STOP**: Continuous multi-phase workflow. After executing all attached tasks, immediately collapse them and execute next phase
9. **TDD Context**: All descriptions include "TDD:" prefix
## TDD Compliance Requirements
## 10. TDD Compliance Requirements
### The Iron Law
@@ -222,7 +224,7 @@ NO PRODUCTION CODE WITHOUT A FAILING TEST FIRST
- Test-first forces edge case discovery before implementation
- Tests-after verify what was built, not what's required
## Input Processing
## 11. Input Processing
**Convert User Input to TDD Structured Format**:
@@ -252,9 +254,7 @@ NO PRODUCTION CODE WITHOUT A FAILING TEST FIRST
3. **File/Issue** → Read and structure with TDD
## Data Flow
### Plan Mode
## 12. Data Flow — Plan Mode
```
User Input (task description)
@@ -297,7 +297,7 @@ Plan Confirmation (User Decision Gate):
└─ "Review Status Only" → Display session status inline
```
### Verify Mode
## 13. Data Flow — Verify Mode
```
Input: --session sessionId (or auto-detect)
@@ -311,7 +311,7 @@ Phase 7: Session discovery → Chain validation → Coverage analysis → Report
- Existing context and analysis
- Session-specific configuration
## TodoWrite Pattern
## 14. TodoWrite Pattern
**Core Concept**: Dynamic task attachment and collapse for real-time visibility into TDD workflow execution.
@@ -394,7 +394,7 @@ Phase 7: Session discovery → Chain validation → Coverage analysis → Report
**Note**: See individual Phase descriptions for detailed TodoWrite Update examples.
## Post-Phase Updates
## 15. Post-Phase Updates
### Memory State Check
@@ -409,7 +409,7 @@ After heavy phases (Phase 2-3), evaluate context window usage:
Similar to workflow-plan, a `planning-notes.md` can accumulate context across phases if needed. See Phase 1 for initialization.
## Error Handling
## 16. Error Handling
- **Parsing Failure**: If output parsing fails, retry command once, then report error
- **Validation Failure**: Report which file/data is missing or invalid
@@ -447,9 +447,8 @@ Similar to workflow-plan, a `planning-notes.md` can accumulate context across ph
2. Summary displayed in Phase 6 output
3. User decides whether to address before `workflow-execute` skill
## Coordinator Checklist
## 17. Coordinator Checklist — Plan Mode
### Plan Mode
- **Pre-Phase**: Convert user input to TDD structured format (TDD/GOAL/SCOPE/CONTEXT/TEST_FOCUS)
- Initialize TaskCreate before any command (Phase 4 added dynamically after Phase 2)
- Execute Phase 1 immediately with structured description
@@ -466,20 +465,21 @@ Similar to workflow-plan, a `planning-notes.md` can accumulate context across ph
- Verify all Phase 5 outputs (IMPL_PLAN.md, IMPL-*.json, TODO_LIST.md)
- Execute Phase 6 (internal TDD structure validation)
- **Plan Confirmation Gate**: Present user with choice (Verify → Phase 7 / Execute / Review Status)
- **If user selects Verify**: Read phases/07-tdd-verify.md, execute Phase 7 in-process
- **If user selects Verify**: Read("phases/07-tdd-verify.md"), execute Phase 7 in-process
- **If user selects Execute**: Skill(skill="workflow-execute")
- **If user selects Review**: Display session status inline
- **Auto mode (workflowPreferences.autoYes)**: Auto-select "Verify TDD Compliance", then auto-continue to execute if APPROVED
- Update TaskCreate/TaskUpdate after each phase
- After each phase, automatically continue to next phase based on TaskList status
### Verify Mode
## 18. Coordinator Checklist — Verify Mode
- Detect/validate session (from --session flag or auto-detect)
- Initialize TaskCreate with verification tasks
- Execute Phase 7 through all sub-phases (session validation → chain validation → coverage analysis → report generation)
- Present quality gate result and next step options
## Related Skills
## 19. Related Skills
**Prerequisite Skills**:
- None - TDD planning is self-contained (can optionally run brainstorm commands before)
@@ -500,3 +500,28 @@ Similar to workflow-plan, a `planning-notes.md` can accumulate context across ph
- `workflow-plan` skill (plan-verify phase) - Verify plan quality and dependencies
- Display session status inline - Review TDD task breakdown
- `Skill(skill="workflow-execute")` - Begin TDD implementation
</process>
<auto_mode>
When `workflowPreferences.autoYes` is true (triggered by `-y`/`--yes` flag):
- Skip all interactive confirmation prompts
- Use default values for all preference questions
- At Plan Confirmation Gate: Auto-select "Verify TDD Compliance"
- After verification: Auto-continue to execute if quality gate returns APPROVED
- All phases execute continuously without user intervention
</auto_mode>
<success_criteria>
- [ ] Mode correctly detected from skill trigger name (plan vs verify)
- [ ] All 6 plan phases execute sequentially with proper data flow between them
- [ ] Phase files loaded progressively via Read() only when phase is about to execute
- [ ] TaskCreate/TaskUpdate tracks all phases with attachment/collapse pattern
- [ ] TDD Iron Law enforced: every task has Red-Green-Refactor structure
- [ ] Phase 4 (Conflict Resolution) conditionally executes based on conflictRisk level
- [ ] Plan Confirmation Gate presents three choices after Phase 6
- [ ] Verify mode (Phase 7) produces TDD_COMPLIANCE_REPORT.md with quality gate
- [ ] All outputs generated: IMPL_PLAN.md, IMPL-*.json, TODO_LIST.md
- [ ] Compact recovery preserves active phase content via TodoWrite status
- [ ] Error handling retries once on parsing failure, reports on persistent errors
</success_criteria>

View File

@@ -4,11 +4,13 @@ description: Unified test-fix pipeline combining test generation (session, conte
allowed-tools: Skill, Agent, AskUserQuestion, TaskCreate, TaskUpdate, TaskList, Read, Write, Edit, Bash, Glob, Grep
---
# Workflow Test Fix
<purpose>
Unified test-fix orchestrator that combines **test planning generation** (Phase 1-4) with **iterative test-cycle execution** (Phase 5) into a single end-to-end pipeline. Creates test sessions with progressive L0-L3 test layers, generates test tasks, then executes them with adaptive fix cycles until pass rate >= 95% or max iterations reached. Triggered via skill name routing for full pipeline or execute-only modes.
</purpose>
Unified test-fix orchestrator that combines **test planning generation** (Phase 1-4) with **iterative test-cycle execution** (Phase 5) into a single end-to-end pipeline. Creates test sessions with progressive L0-L3 test layers, generates test tasks, then executes them with adaptive fix cycles until pass rate >= 95% or max iterations reached.
<process>
## Architecture Overview
## 1. Architecture Overview
```
┌───────────────────────────────────────────────────────────────────────────┐
@@ -45,7 +47,7 @@ Task Pipeline (generated in Phase 4, executed in Phase 5):
└──────────────┘ └─────────────────┘ └─────────────────┘ └──────────────┘
```
## Key Design Principles
## 2. Key Design Principles
1. **Unified Pipeline**: Generation and execution are one continuous workflow - no manual handoff
2. **Pure Orchestrator**: SKILL.md coordinates only - delegates all execution detail to phase files
@@ -56,14 +58,14 @@ Task Pipeline (generated in Phase 4, executed in Phase 5):
7. **Quality Gate**: Pass rate >= 95% (criticality-aware) terminates the fix loop
8. **Phase File Hygiene**: Phase files reference `workflowPreferences.*` for preferences, no CLI flag parsing
## Usage
## 3. Usage
Full pipeline and execute-only modes are triggered by skill name routing (see Mode Detection). Workflow preferences (auto mode) are collected interactively via AskUserQuestion before dispatching to phases.
**Full pipeline** (workflow-test-fix): Task description or session ID as arguments → interactive preference collection → generate + execute pipeline
**Execute only** (workflow-test-fix): Auto-discovers active session → interactive preference collection → execution loop
## Interactive Preference Collection
## 4. Interactive Preference Collection
Before dispatching to phase execution, collect workflow preferences via AskUserQuestion:
@@ -97,7 +99,7 @@ if (autoYes) {
**workflowPreferences** is passed to phase execution as context variable, referenced as `workflowPreferences.autoYes` within phases.
## Compact Recovery (Phase Persistence)
## 5. Compact Recovery (Phase Persistence)
Multi-phase test-fix pipeline (Phase 1-5) spans long conversations, especially Phase 5 fix loops. Uses **双重保险**: TodoWrite 跟踪 active phase 保护其不被压缩sentinel 作为兜底。
@@ -105,7 +107,7 @@ Multi-phase test-fix pipeline (Phase 1-5) spans long conversations, especially P
> The phase currently marked `in_progress` is the active execution phase — preserve its FULL content.
> Only compress phases marked `completed` or `pending`.
## Execution Flow
## 6. Execution Flow
```
Entry Point Detection:
@@ -113,23 +115,23 @@ Entry Point Detection:
└─ /workflow-test-fix → Execution Only (Phase 5)
Phase 1: Session Start (session-start)
└─ Ref: phases/01-session-start.md
└─ Read("phases/01-session-start.md")
├─ Step 1.0: Detect input mode (session | prompt)
├─ Step 1.1: Create test session → testSessionId
└─ Output: testSessionId, MODE
Phase 2: Test Context Gather (test-context-gather)
└─ Ref: phases/02-test-context-gather.md
└─ Read("phases/02-test-context-gather.md")
├─ Step 1.2: Gather test context → contextPath
└─ Output: contextPath
Phase 3: Test Concept Enhanced (test-concept-enhanced)
└─ Ref: phases/03-test-concept-enhanced.md
└─ Read("phases/03-test-concept-enhanced.md")
├─ Step 1.3: Test analysis (Gemini) → TEST_ANALYSIS_RESULTS.md
└─ Output: TEST_ANALYSIS_RESULTS.md
Phase 4: Test Task Generate (test-task-generate)
└─ Ref: phases/04-test-task-generate.md
└─ Read("phases/04-test-task-generate.md")
├─ Step 1.4: Generate test tasks → IMPL_PLAN.md, IMPL-*.json, TODO_LIST.md
└─ Output: testSessionId, 4+ task JSONs
@@ -137,7 +139,7 @@ Summary Output (inline after Phase 4):
└─ Display summary, auto-continue to Phase 5
Phase 5: Test Cycle Execution (test-cycle-execute)
└─ Ref: phases/05-test-cycle-execute.md
└─ Read("phases/05-test-cycle-execute.md")
├─ Step 2.1: Discovery (load session, tasks, iteration state)
├─ Step 2.2: Execute initial tasks (IMPL-001 → 001.3 → 001.5 → 002)
├─ Step 2.3: Fix loop (if pass_rate < 95%)
@@ -153,18 +155,18 @@ Phase 5: Test Cycle Execution (test-cycle-execute)
| Phase | Document | Purpose | Compact |
|-------|----------|---------|---------|
| 1 | [phases/01-session-start.md](phases/01-session-start.md) | Detect input mode, create test session | TodoWrite 驱动 |
| 2 | [phases/02-test-context-gather.md](phases/02-test-context-gather.md) | Gather test context (coverage/codebase) | TodoWrite 驱动 |
| 3 | [phases/03-test-concept-enhanced.md](phases/03-test-concept-enhanced.md) | Gemini analysis, L0-L3 test requirements | TodoWrite 驱动 |
| 4 | [phases/04-test-task-generate.md](phases/04-test-task-generate.md) | Generate task JSONs and IMPL_PLAN.md | TodoWrite 驱动 |
| 5 | [phases/05-test-cycle-execute.md](phases/05-test-cycle-execute.md) | Execute tasks, iterative fix cycles, completion | TodoWrite 驱动 + 🔄 sentinel |
| 1 | phases/01-session-start.md | Detect input mode, create test session | TodoWrite 驱动 |
| 2 | phases/02-test-context-gather.md | Gather test context (coverage/codebase) | TodoWrite 驱动 |
| 3 | phases/03-test-concept-enhanced.md | Gemini analysis, L0-L3 test requirements | TodoWrite 驱动 |
| 4 | phases/04-test-task-generate.md | Generate task JSONs and IMPL_PLAN.md | TodoWrite 驱动 |
| 5 | phases/05-test-cycle-execute.md | Execute tasks, iterative fix cycles, completion | TodoWrite 驱动 + 🔄 sentinel |
**Compact Rules**:
1. **TodoWrite `in_progress`** → 保留完整内容,禁止压缩
2. **TodoWrite `completed`** → 可压缩为摘要
3. **🔄 sentinel fallback** → Phase 5 包含 compact sentinel若 compact 后仅存 sentinel 而无完整 Step 协议,必须立即 `Read("phases/05-test-cycle-execute.md")` 恢复
## Core Rules
## 7. Core Rules
1. **Start Immediately**: First action is TaskCreate initialization, second action is Phase 1 (or Phase 5 for execute-only entry)
2. **No Preliminary Analysis**: Do not read files or gather context before starting the phase
@@ -176,7 +178,7 @@ Phase 5: Test Cycle Execution (test-cycle-execute)
8. **Progressive Loading**: Read phase doc ONLY when that phase is about to execute
9. **Entry Point Routing**: `workflow-test-fix` skill → Phase 1-5; `workflow-test-fix` skill → Phase 5 only
## Input Processing
## 8. Input Processing
### test-fix-gen Entry (Full Pipeline)
```
@@ -194,7 +196,7 @@ Arguments → Parse flags:
└─ (no args) → auto-discover active test session
```
## Data Flow
## 9. Data Flow
```
User Input (session ID | description | file path)
@@ -223,7 +225,7 @@ Phase 5: Test Cycle Execution ────────────────
↓ 2.4: Completion → summary → session archive
```
## Summary Output (after Phase 4)
## 10. Summary Output (after Phase 4)
After Phase 4 completes, display the following summary before auto-continuing to Phase 5:
@@ -255,7 +257,7 @@ Review artifacts:
**CRITICAL - Next Step**: Auto-continue to Phase 5: Test Cycle Execution.
Pass `testSessionId` to Phase 5 for test execution pipeline. Do NOT wait for user confirmation — the unified pipeline continues automatically.
## Test Strategy Overview
## 11. Test Strategy Overview
Progressive Test Layers (L0-L3):
@@ -273,7 +275,7 @@ Progressive Test Layers (L0-L3):
- Pass Rate Gate: >= 95% (criticality-aware) or 100%
- Max Fix Iterations: 10 (default, adjustable)
## Strategy Engine (Phase 5)
## 12. Strategy Engine (Phase 5)
| Strategy | Trigger | Behavior |
|----------|---------|----------|
@@ -283,7 +285,7 @@ Progressive Test Layers (L0-L3):
Selection logic and CLI fallback chain (Gemini → Qwen → Codex) are detailed in Phase 5.
## Agent Roles
## 13. Agent Roles
| Agent | Used In | Responsibility |
|-------|---------|---------------|
@@ -292,7 +294,7 @@ Selection logic and CLI fallback chain (Gemini → Qwen → Codex) are detailed
| **@test-fix-agent** | Phase 5 | Test execution, code fixes, criticality assignment |
| **@cli-planning-agent** | Phase 5 (fix loop) | CLI analysis, root cause extraction, fix task generation |
## TodoWrite Pattern
## 14. TodoWrite Pattern
**Core Concept**: Dynamic task tracking with attachment/collapse for real-time visibility.
@@ -344,7 +346,7 @@ Selection logic and CLI fallback chain (Gemini → Qwen → Codex) are detailed
]
```
## Session File Structure
## 15. Session File Structure
```
.workflow/active/WFS-test-{session}/
@@ -370,7 +372,7 @@ Selection logic and CLI fallback chain (Gemini → Qwen → Codex) are detailed
└── iteration-summaries/
```
## Error Handling
## 16. Error Handling
### Phase 1-4 (Generation)
@@ -393,13 +395,13 @@ Selection logic and CLI fallback chain (Gemini → Qwen → Codex) are detailed
| Regression detected | Rollback last fix, switch to surgical strategy |
| Stuck tests detected | Continue with alternative strategy, document |
## Commit Strategy (Phase 5)
## 17. Commit Strategy (Phase 5)
Automatic commits at key checkpoints:
1. **After successful iteration** (pass rate increased): `test-cycle: iteration N - strategy (pass: old% → new%)`
2. **Before rollback** (regression detected): `test-cycle: rollback iteration N - regression detected`
## Completion Conditions
## 18. Completion Conditions
| Condition | Pass Rate | Action |
|-----------|-----------|--------|
@@ -407,36 +409,36 @@ Automatic commits at key checkpoints:
| **Partial Success** | >= 95%, all failures low criticality | Auto-approve with review note |
| **Failure** | < 95% after max iterations | Failure report, mark blocked |
## Post-Completion Expansion
## 19. Post-Completion Expansion
**Auto-sync**: Execute `/workflow:session:sync -y "{summary}"` to update specs/*.md + project-tech.
After completion, ask user if they want to expand into issues (test/enhance/refactor/doc). Selected items call `/issue:new "{summary} - {dimension}"`.
## Coordinator Checklist
## 20. Coordinator Checklist
### Phase 1 (session-start)
- [ ] Detect input type (session ID / description / file path)
- [ ] Initialize TaskCreate before any execution
- [ ] Read Phase 1 doc, execute Steps 1.0 + 1.1
- [ ] Read("phases/01-session-start.md"), execute Steps 1.0 + 1.1
- [ ] Parse testSessionId from step output, store in memory
### Phase 2 (test-context-gather)
- [ ] Read Phase 2 doc, execute Step 1.2
- [ ] Read("phases/02-test-context-gather.md"), execute Step 1.2
- [ ] Parse contextPath from step output, store in memory
### Phase 3 (test-concept-enhanced)
- [ ] Read Phase 3 doc, execute Step 1.3
- [ ] Read("phases/03-test-concept-enhanced.md"), execute Step 1.3
- [ ] Verify TEST_ANALYSIS_RESULTS.md created
### Phase 4 (test-task-generate)
- [ ] Read Phase 4 doc, execute Step 1.4
- [ ] Read("phases/04-test-task-generate.md"), execute Step 1.4
- [ ] Verify all Phase 1-4 outputs (4 task JSONs, IMPL_PLAN.md, TODO_LIST.md)
- [ ] Display Summary output (inline)
- [ ] Collapse Phase 1-4 tasks, auto-continue to Phase 5
### Phase 5 (test-cycle-execute)
- [ ] Read Phase 5 doc
- [ ] Read("phases/05-test-cycle-execute.md")
- [ ] Load session, tasks, iteration state
- [ ] Execute initial tasks sequentially
- [ ] Calculate pass rate from test-results.json
@@ -446,7 +448,7 @@ After completion, ask user if they want to expand into issues (test/enhance/refa
- [ ] Generate completion summary
- [ ] Offer post-completion expansion
## Related Skills
## 21. Related Skills
**Prerequisite Skills**:
- `workflow-plan` skill or `workflow-execute` skill - Complete implementation (Session Mode source)
@@ -456,3 +458,25 @@ After completion, ask user if they want to expand into issues (test/enhance/refa
- Display session status inline - Review workflow state
- `review-cycle` skill - Post-implementation review
- `/issue:new` - Create follow-up issues
</process>
<auto_mode>
When `-y` or `--yes` is detected in $ARGUMENTS or propagated via ccw:
- Skip all AskUserQuestion confirmations
- Use default values for all workflow preferences (`workflowPreferences = { autoYes: true }`)
- Auto-continue through all phases without user interaction
- Phase 1→2→3→4→Summary→5 executes as a fully automatic pipeline
</auto_mode>
<success_criteria>
- [ ] Input type correctly detected (session ID / description / file path)
- [ ] All 5 phases execute in sequence (full pipeline) or Phase 5 only (execute-only)
- [ ] Phase documents loaded progressively via Read() only when phase executes
- [ ] TaskCreate/TaskUpdate tracking maintained throughout with attachment/collapse pattern
- [ ] All phase outputs parsed and passed to subsequent phases (testSessionId, contextPath, etc.)
- [ ] Summary displayed after Phase 4 with all task and threshold details
- [ ] Phase 5 fix loop iterates with adaptive strategy until pass rate >= 95% or max iterations
- [ ] Completion summary generated with final pass rate and session archived
- [ ] Post-completion expansion offered to user
</success_criteria>