# Phase 0: Prep Package Schema & Integration Schema reference for `prep-package.json` consumed by ccw-loop Phase 1. Generated by interactive prompt `/prompts:prep-loop`. ## prep-package.json Schema ```json { "version": "1.0.0", "generated_at": "ISO8601 (UTC+8)", "prep_status": "ready | cancelled | needs_refinement", "target_skill": "ccw-loop", "environment": { "project_root": "absolute path", "tech_stack": "string", "test_framework": "string" }, "source": { "tool": "collaborative-plan-with-file | analyze-with-file | brainstorm-to-cycle | manual", "session_id": "string", "task_dir": "absolute path to source .task/ directory", "task_count": "number", "tasks_with_convergence": "number" }, "tasks": { "total": "number", "by_priority": { "high": 0, "medium": 0, "low": 0 }, "by_type": { "feature": 0, "fix": 0, "refactor": 0, "enhancement": 0, "testing": 0 } }, "auto_loop": { "enabled": true, "no_confirmation": true, "max_iterations": 10, "timeout_per_action_ms": 600000 } } ``` ## .task/*.json Schema (task-schema.json) One task per file in `.task/` directory, each following `task-schema.json` with ccw-loop extended fields: ```json { "id": "task-001", "description": "Title: detailed description", "tool": "gemini", "mode": "write", "status": "pending", "priority": 1, "files_changed": ["path/to/file.ts"], "created_at": "ISO8601", "completed_at": null, "_source": { "tool": "collaborative-plan-with-file", "session_id": "...", "original_id": "TASK-001" }, "_convergence": { "criteria": ["..."], "verification": "...", "definition_of_done": "..." }, "_type": "feature", "_effort": "medium", "_depends_on": [] } ``` ## Validation Rules | # | Check | Condition | On Failure | |---|-------|-----------|------------| | 1 | prep_status | `=== "ready"` | Skip prep, use default INIT | | 2 | target_skill | `=== "ccw-loop"` | Skip prep, use default INIT | | 3 | project_root | Matches current `projectRoot` | Skip prep, warn mismatch | | 4 | freshness | `generated_at` within 24h | Skip prep, warn stale | | 5 | tasks dir | `.task/` directory exists with *.json files | Skip prep, use default INIT | | 6 | tasks content | At least 1 valid task JSON in `.task/` | Skip prep, use default INIT | ## Integration Points ### Phase 1: Session Initialization ```javascript // Load prep-package.json (generated by /prompts:prep-loop) let prepPackage = null const prepPath = `${projectRoot}/.workflow/.loop/prep-package.json` if (fs.existsSync(prepPath)) { const raw = JSON.parse(Read(prepPath)) const checks = validateLoopPrepPackage(raw, projectRoot) if (checks.valid) { prepPackage = raw // Load pre-built tasks from .task/*.json const taskDir = `${projectRoot}/.workflow/.loop/.task` const prepTasks = loadPrepTasks(taskDir) // → Inject into state.skill_state.develop.tasks // → Set max_iterations from auto_loop config } else { console.warn(`⚠ Prep package failed validation, using default INIT`) prepPackage = null } } ``` ### INIT Action (action-init.md) When prep tasks are loaded: - **Skip** Step 3 (Analyze Task and Generate Tasks) — tasks already provided - **Use** prep tasks directly in Step 5 (Update State) - **Preserve** `_convergence` fields for VALIDATE action reference ### VALIDATE Action When `_convergence` exists on a task: - Use `convergence.verification` as validation command/steps - Use `convergence.criteria` as pass/fail conditions - Fall back to default test validation if `_convergence` is null