Files
Claude-Code-Workflow/.codex/skills/ccw-loop-b/phases/state-schema.md
catlog22 54c3234d84 fix: 为所有 skill 的 .workflow/ 路径添加 projectRoot 前缀
从子目录执行 skill 时,相对路径 .workflow/ 会导致产物落到错误位置。
通过 git rev-parse --show-toplevel || pwd 检测项目根目录,
所有 .workflow/ 路径引用统一加上 {projectRoot} 前缀确保路径正确。

涉及 72 个文件,覆盖 20+ 个 skill。
2026-02-08 13:46:48 +08:00

4.1 KiB

State Schema (CCW Loop-B)

Master State Structure

{
  "loop_id": "loop-b-20260122-abc123",
  "title": "Implement user authentication",
  "description": "Full task description here",
  "mode": "interactive | auto | parallel",
  "status": "running | paused | completed | failed",
  "current_iteration": 3,
  "max_iterations": 10,
  "created_at": "2026-01-22T10:00:00.000Z",
  "updated_at": "2026-01-22T10:30:00.000Z",

  "skill_state": {
    "phase": "develop | debug | validate | complete",
    "action_index": 2,
    "workers_completed": ["init", "develop"],
    "parallel_results": null,
    "pending_tasks": [],
    "completed_tasks": [],
    "findings": []
  }
}

Field Descriptions

Core Fields (API Compatible)

Field Type Description
loop_id string Unique identifier
title string Short title (max 100 chars)
description string Full task description
mode enum Execution mode
status enum Current status
current_iteration number Iteration counter
max_iterations number Safety limit
created_at ISO string Creation timestamp
updated_at ISO string Last update timestamp

Skill State Fields

Field Type Description
phase enum Current execution phase
action_index number Position in action sequence (auto mode)
workers_completed array List of completed worker actions
parallel_results object Merged results from parallel mode
pending_tasks array Tasks waiting to be executed
completed_tasks array Tasks already done
findings array Discoveries during execution

Worker Output Structure

Each worker writes to {projectRoot}/.workflow/.loop/{loopId}.workers/{action}.output.json:

{
  "action": "develop",
  "status": "success",
  "summary": "Implemented 3 functions",
  "files_changed": ["src/auth.ts", "src/utils.ts"],
  "next_suggestion": "validate",
  "loop_back_to": null,
  "timestamp": "2026-01-22T10:15:00.000Z",
  "detailed_output": {
    "tasks_completed": [
      { "id": "T1", "description": "Create auth module" }
    ],
    "metrics": {
      "lines_added": 150,
      "lines_removed": 20
    }
  }
}

Progress File Structure

Human-readable progress in {projectRoot}/.workflow/.loop/{loopId}.progress/{action}.md:

# Develop Progress

## Session: loop-b-20260122-abc123

### Iteration 1 (2026-01-22 10:15)

**Task**: Implement auth module

**Changes**:
- Created `src/auth.ts` with login/logout functions
- Added JWT token handling in `src/utils.ts`

**Status**: Success

---

### Iteration 2 (2026-01-22 10:30)

...

Status Transitions

          +--------+
          | init   |
          +--------+
               |
               v
+------> +---------+
|        | develop |
|        +---------+
|             |
|    +--------+--------+
|    |                 |
|    v                 v
| +-------+       +---------+
| | debug |<------| validate|
| +-------+       +---------+
|    |                 |
|    +--------+--------+
|             |
|             v
|       [needs fix?]
|        yes |  | no
|            v  v
+------------+  +----------+
               | complete  |
               +----------+

Parallel Results Schema

When mode === 'parallel':

{
  "parallel_results": {
    "develop": {
      "status": "success",
      "summary": "...",
      "suggestions": []
    },
    "debug": {
      "status": "success",
      "issues_found": [],
      "suggestions": []
    },
    "validate": {
      "status": "success",
      "test_results": {},
      "coverage": {}
    },
    "merged_at": "2026-01-22T10:45:00.000Z"
  }
}

Directory Structure

{projectRoot}/.workflow/.loop/
+-- loop-b-20260122-abc123.json          # Master state
+-- loop-b-20260122-abc123.workers/
|   +-- init.output.json
|   +-- develop.output.json
|   +-- debug.output.json
|   +-- validate.output.json
|   +-- complete.output.json
+-- loop-b-20260122-abc123.progress/
    +-- develop.md
    +-- debug.md
    +-- validate.md
    +-- summary.md