description = "Assigns tasks to local agents from the .agents/ folder based on .agents/AGENTS.md."
prompt = '''
When the user issues the `/assign` command, follow this strict 5-step process:

## 1. Discovery & Identification
- **MANDATORY**: Read the file `.agents/AGENTS.md` to understand the pool of available agents and their specific purposes.
- Generate a unique plan name based on the current date and task scope (e.g., `ASSIGN_20260109_FEATURE_X`).
- Use this name for ALL files related to this assignment.
- Create a dedicated script directory: `bash/<PLAN_NAME>/`.

## 2. Plan & Task Mapping
- Analyze the user's request and map subtasks to the most appropriate agents identified in `.agents/AGENTS.md`.
- Document the strategy in `<PLAN_NAME>.md` in the project root.
- Create `<PLAN_NAME>.json` to track execution state.
- Include all tasks with their associated local agent path (e.g., `.agents/php-pro.md`), detailed prompt, status ("pending"), and any dependencies.

## 3. Orchestrate & Review
- Create `bash/<PLAN_NAME>/execute.sh`.
- **CRITICAL: SHELL ESCAPING**: Use a quoted heredoc (`<<'EOF'`) to capture the full prompt for each task to ensure safe execution.
- Example structure for `execute.sh`:
  ```bash
  #!/bin/bash
  # Task 1
  (
    PROMPT=$(cat <<'EOF'
  $(cat .agents/<agent-name>.md)
  <detailed_prompt>
  EOF
  )
    gemini --yolo "$PROMPT" 2>&1 | tee -a <PLAN_NAME>.log
    if [ ${PIPESTATUS[0]} -eq 0 ]; then
      python3 -c "import json; f=open('<PLAN_NAME>.json', 'r+'); d=json.load(f); next(t for t in d['tasks'] if t['id']==1)['status']='completed'; f.seek(0); json.dump(d, f, indent=2); f.truncate()"
    fi
  ) &

  wait
  ```
- **CRITICAL**: Before executing, you MUST present a clear list of all tasks to the user, showing:
    - **Agent:** The path to the local expert agent in `.agents/`.
    - **Prompt:** The exact detailed prompt being sent.
- Wait for the user to acknowledge the plan details.

## 4. Execute & Monitor
- After user acknowledgment, run `chmod +x bash/<PLAN_NAME>/execute.sh && ./bash/<PLAN_NAME>/execute.sh`.
- Monitor terminal output, `<PLAN_NAME>.log` and `<PLAN_NAME>.json`.

## 5. Summarize
- Once all tasks are marked "completed" in the JSON file, provide a comprehensive summary of changes and verified statuses.

USER REQUEST:
{{args}}
'''
