Files
Claude-Code-Workflow/.codex/skills/ccw-loop/phases/actions/action-init.md
catlog22 2fb1d1243c feat: prioritize user config, do not merge default tools
Changed loadClaudeCliTools() to only load tools explicitly defined
in user config. Previously, DEFAULT_TOOLS_CONFIG.tools was spread
before user tools, causing all default tools to be loaded even if
not present in user config.

User config now has complete control over which tools are loaded.
2026-01-22 23:37:42 +08:00

3.2 KiB

Action: INIT

Initialize CCW Loop session, create directory structure and initial state.

Purpose

  • Create session directory structure
  • Initialize state file with skill_state
  • Analyze task description to generate development tasks
  • Prepare execution environment

Preconditions

  • state.status === 'running'
  • state.skill_state === null

Execution Steps

Step 1: Verify Control Signals

const state = JSON.parse(Read(`.workflow/.loop/${loopId}.json`))

if (state.status !== 'running') {
  return {
    action: 'INIT',
    status: 'failed',
    message: `Cannot init: status is ${state.status}`,
    next_action: state.status === 'paused' ? 'PAUSED' : 'STOPPED'
  }
}

Step 2: Create Directory Structure

const progressDir = `.workflow/.loop/${loopId}.progress`

// Directories created by orchestrator, verify they exist
// mkdir -p ${progressDir}

Step 3: Analyze Task and Generate Tasks

// Analyze task description
const taskDescription = state.description

// Generate 3-7 development tasks based on analysis
// Use ACE search or smart_search to find relevant patterns

const tasks = [
  {
    id: 'task-001',
    description: 'Task description based on analysis',
    tool: 'gemini',
    mode: 'write',
    status: 'pending',
    priority: 1,
    files: [],
    created_at: getUtc8ISOString(),
    completed_at: null
  }
  // ... more tasks
]

Step 4: Initialize Progress Document

const progressPath = `${progressDir}/develop.md`

const progressInitial = `# Development Progress

**Loop ID**: ${loopId}
**Task**: ${taskDescription}
**Started**: ${getUtc8ISOString()}

---

## Task List

${tasks.map((t, i) => `${i + 1}. [ ] ${t.description}`).join('\n')}

---

## Progress Timeline

`

Write(progressPath, progressInitial)

Step 5: Update State

const skillState = {
  current_action: 'init',
  last_action: null,
  completed_actions: [],
  mode: mode,

  develop: {
    total: tasks.length,
    completed: 0,
    current_task: null,
    tasks: tasks,
    last_progress_at: null
  },

  debug: {
    active_bug: null,
    hypotheses_count: 0,
    hypotheses: [],
    confirmed_hypothesis: null,
    iteration: 0,
    last_analysis_at: null
  },

  validate: {
    pass_rate: 0,
    coverage: 0,
    test_results: [],
    passed: false,
    failed_tests: [],
    last_run_at: null
  },

  errors: []
}

state.skill_state = skillState
state.updated_at = getUtc8ISOString()
Write(`.workflow/.loop/${loopId}.json`, JSON.stringify(state, null, 2))

Output Format

ACTION_RESULT:
- action: INIT
- status: success
- message: Session initialized with {N} development tasks

FILES_UPDATED:
- .workflow/.loop/{loopId}.json: skill_state initialized
- .workflow/.loop/{loopId}.progress/develop.md: Progress document created

NEXT_ACTION_NEEDED: {DEVELOP (auto) | MENU (interactive)}

Error Handling

Error Type Recovery
Directory creation failed Report error, stop
Task analysis failed Create single generic task
State write failed Retry once, then stop

Next Actions

  • Success (auto mode): DEVELOP
  • Success (interactive): MENU
  • Failed: Report error