refactor(skill): replace compact protection with TodoWrite-driven compact recovery

Redesign Pattern 9 from "forbid compression" to smart dual-layer approach:
- Layer 1: TodoWrite in_progress phase preserved by compact, completed phases compressible
- Layer 2: Compact sentinel in phase files as fallback re-read trigger

Applied to 6 workflow skills: skill-designer, lite-plan, multi-cli-plan, plan, tdd, test-fix
This commit is contained in:
catlog22
2026-02-27 11:13:50 +08:00
parent 3f25dbb11b
commit 07452e57b7
12 changed files with 219 additions and 79 deletions

View File

@@ -97,6 +97,14 @@ if (autoYes) {
**workflowPreferences** is passed to phase execution as context variable, referenced as `workflowPreferences.autoYes` within phases.
## 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 作为兜底。
> **⚠️ COMPACT DIRECTIVE**: Context compression MUST check TodoWrite phase status.
> The phase currently marked `in_progress` is the active execution phase — preserve its FULL content.
> Only compress phases marked `completed` or `pending`.
## Execution Flow
```
@@ -143,13 +151,18 @@ Phase 5: Test Cycle Execution (test-cycle-execute)
**Phase Reference Documents** (read on-demand when phase executes):
| Phase | Document | Purpose |
|-------|----------|---------|
| 1 | [phases/01-session-start.md](phases/01-session-start.md) | Detect input mode, create test session |
| 2 | [phases/02-test-context-gather.md](phases/02-test-context-gather.md) | Gather test context (coverage/codebase) |
| 3 | [phases/03-test-concept-enhanced.md](phases/03-test-concept-enhanced.md) | Gemini analysis, L0-L3 test requirements |
| 4 | [phases/04-test-task-generate.md](phases/04-test-task-generate.md) | Generate task JSONs and IMPL_PLAN.md |
| 5 | [phases/05-test-cycle-execute.md](phases/05-test-cycle-execute.md) | Execute tasks, iterative fix cycles, completion |
| 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 |
**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

View File

@@ -1,5 +1,10 @@
# Phase 2: Test Cycle Execution (test-cycle-execute)
> **📌 COMPACT SENTINEL [Phase 5: Test-Cycle-Execute]**
> This phase contains 4 execution steps (Step 2.1 — 2.4).
> If you can read this sentinel but cannot find the full Step protocol below, context has been compressed.
> Recovery: `Read("phases/05-test-cycle-execute.md")`
Execute test-fix workflow with dynamic task generation and iterative fix cycles until test pass rate >= 95% or max iterations reached. Uses @cli-planning-agent for failure analysis and task generation.
## Objective