|
| 1 | +--- |
| 2 | +name: add |
| 3 | +description: Add IDAW tasks - manual creation or import from ccw issue |
| 4 | +argument-hint: "[-y|--yes] [--from-issue <id>[,<id>,...]] \"description\" [--type <task_type>] [--priority <1-5>]" |
| 5 | +allowed-tools: AskUserQuestion(*), Read(*), Bash(*), Write(*), Glob(*) |
| 6 | +--- |
| 7 | + |
| 8 | +# IDAW Add Command (/idaw:add) |
| 9 | + |
| 10 | +## Auto Mode |
| 11 | + |
| 12 | +When `--yes` or `-y`: Skip clarification questions, create task with inferred details. |
| 13 | + |
| 14 | +## IDAW Task Schema |
| 15 | + |
| 16 | +```json |
| 17 | +{ |
| 18 | + "id": "IDAW-001", |
| 19 | + "title": "string", |
| 20 | + "description": "string", |
| 21 | + "status": "pending", |
| 22 | + "priority": 2, |
| 23 | + "task_type": null, |
| 24 | + "skill_chain": null, |
| 25 | + "context": { |
| 26 | + "affected_files": [], |
| 27 | + "acceptance_criteria": [], |
| 28 | + "constraints": [], |
| 29 | + "references": [] |
| 30 | + }, |
| 31 | + "source": { |
| 32 | + "type": "manual|import-issue", |
| 33 | + "issue_id": null, |
| 34 | + "issue_snapshot": null |
| 35 | + }, |
| 36 | + "execution": { |
| 37 | + "session_id": null, |
| 38 | + "started_at": null, |
| 39 | + "completed_at": null, |
| 40 | + "skill_results": [], |
| 41 | + "git_commit": null, |
| 42 | + "error": null |
| 43 | + }, |
| 44 | + "created_at": "ISO", |
| 45 | + "updated_at": "ISO" |
| 46 | +} |
| 47 | +``` |
| 48 | + |
| 49 | +**Valid task_type values**: `bugfix|bugfix-hotfix|feature|feature-complex|refactor|tdd|test|test-fix|review|docs` |
| 50 | + |
| 51 | +## Implementation |
| 52 | + |
| 53 | +### Phase 1: Parse Arguments |
| 54 | + |
| 55 | +```javascript |
| 56 | +const args = $ARGUMENTS; |
| 57 | +const autoYes = /(-y|--yes)/.test(args); |
| 58 | +const fromIssue = args.match(/--from-issue\s+([\w,-]+)/)?.[1]; |
| 59 | +const typeFlag = args.match(/--type\s+([\w-]+)/)?.[1]; |
| 60 | +const priorityFlag = args.match(/--priority\s+(\d)/)?.[1]; |
| 61 | +const description = args.replace(/(-y|--yes|--from-issue\s+[\w,-]+|--type\s+[\w-]+|--priority\s+\d)/g, '').trim().replace(/^["']|["']$/g, ''); |
| 62 | +``` |
| 63 | +
|
| 64 | +### Phase 2: Route — Import or Manual |
| 65 | +
|
| 66 | +``` |
| 67 | +--from-issue present? |
| 68 | + ├─ YES → Import Mode (Phase 3A) |
| 69 | + └─ NO → Manual Mode (Phase 3B) |
| 70 | +``` |
| 71 | +
|
| 72 | +### Phase 3A: Import Mode (from ccw issue) |
| 73 | +
|
| 74 | +```javascript |
| 75 | +const issueIds = fromIssue.split(','); |
| 76 | + |
| 77 | +for (const issueId of issueIds) { |
| 78 | + // 1. Fetch issue data |
| 79 | + const issueJson = Bash(`ccw issue list --json`); |
| 80 | + const issues = JSON.parse(issueJson).issues; |
| 81 | + const issue = issues.find(i => i.id === issueId.trim()); |
| 82 | + if (!issue) { |
| 83 | + console.log(`Warning: Issue ${issueId} not found, skipping`); |
| 84 | + continue; |
| 85 | + } |
| 86 | + |
| 87 | + // 2. Check duplicate (same issue_id already imported) |
| 88 | + const existing = Glob('.workflow/.idaw/tasks/IDAW-*.json'); |
| 89 | + for (const f of existing) { |
| 90 | + const data = JSON.parse(Read(f)); |
| 91 | + if (data.source?.issue_id === issueId.trim()) { |
| 92 | + console.log(`Warning: Issue ${issueId} already imported as ${data.id}, skipping`); |
| 93 | + continue; // skip to next issue |
| 94 | + } |
| 95 | + } |
| 96 | + |
| 97 | + // 3. Generate next IDAW ID |
| 98 | + const nextId = generateNextId(); |
| 99 | + |
| 100 | + // 4. Map issue → IDAW task |
| 101 | + const task = { |
| 102 | + id: nextId, |
| 103 | + title: issue.title, |
| 104 | + description: issue.context || issue.title, |
| 105 | + status: 'pending', |
| 106 | + priority: parseInt(priorityFlag) || issue.priority || 3, |
| 107 | + task_type: typeFlag || inferTaskType(issue.title, issue.context || ''), |
| 108 | + skill_chain: null, |
| 109 | + context: { |
| 110 | + affected_files: issue.affected_components || [], |
| 111 | + acceptance_criteria: [], |
| 112 | + constraints: [], |
| 113 | + references: issue.source_url ? [issue.source_url] : [] |
| 114 | + }, |
| 115 | + source: { |
| 116 | + type: 'import-issue', |
| 117 | + issue_id: issue.id, |
| 118 | + issue_snapshot: { |
| 119 | + id: issue.id, |
| 120 | + title: issue.title, |
| 121 | + status: issue.status, |
| 122 | + context: issue.context, |
| 123 | + priority: issue.priority, |
| 124 | + created_at: issue.created_at |
| 125 | + } |
| 126 | + }, |
| 127 | + execution: { |
| 128 | + session_id: null, |
| 129 | + started_at: null, |
| 130 | + completed_at: null, |
| 131 | + skill_results: [], |
| 132 | + git_commit: null, |
| 133 | + error: null |
| 134 | + }, |
| 135 | + created_at: new Date().toISOString(), |
| 136 | + updated_at: new Date().toISOString() |
| 137 | + }; |
| 138 | + |
| 139 | + // 5. Write task file |
| 140 | + Bash('mkdir -p .workflow/.idaw/tasks'); |
| 141 | + Write(`.workflow/.idaw/tasks/${nextId}.json`, JSON.stringify(task, null, 2)); |
| 142 | + console.log(`Created ${nextId} from issue ${issueId}: ${issue.title}`); |
| 143 | +} |
| 144 | +``` |
| 145 | +
|
| 146 | +### Phase 3B: Manual Mode |
| 147 | +
|
| 148 | +```javascript |
| 149 | +// 1. Validate description |
| 150 | +if (!description && !autoYes) { |
| 151 | + const answer = AskUserQuestion({ |
| 152 | + questions: [{ |
| 153 | + question: 'Please provide a task description:', |
| 154 | + header: 'Task', |
| 155 | + multiSelect: false, |
| 156 | + options: [ |
| 157 | + { label: 'Provide description', description: 'What needs to be done?' } |
| 158 | + ] |
| 159 | + }] |
| 160 | + }); |
| 161 | + // Use custom text from "Other" |
| 162 | + description = answer.customText || ''; |
| 163 | +} |
| 164 | + |
| 165 | +if (!description) { |
| 166 | + console.log('Error: No description provided. Usage: /idaw:add "task description"'); |
| 167 | + return; |
| 168 | +} |
| 169 | + |
| 170 | +// 2. Generate next IDAW ID |
| 171 | +const nextId = generateNextId(); |
| 172 | + |
| 173 | +// 3. Build title from first sentence |
| 174 | +const title = description.split(/[.\n]/)[0].substring(0, 80).trim(); |
| 175 | + |
| 176 | +// 4. Determine task_type |
| 177 | +const taskType = typeFlag || null; // null → inferred at run time |
| 178 | + |
| 179 | +// 5. Create task |
| 180 | +const task = { |
| 181 | + id: nextId, |
| 182 | + title: title, |
| 183 | + description: description, |
| 184 | + status: 'pending', |
| 185 | + priority: parseInt(priorityFlag) || 3, |
| 186 | + task_type: taskType, |
| 187 | + skill_chain: null, |
| 188 | + context: { |
| 189 | + affected_files: [], |
| 190 | + acceptance_criteria: [], |
| 191 | + constraints: [], |
| 192 | + references: [] |
| 193 | + }, |
| 194 | + source: { |
| 195 | + type: 'manual', |
| 196 | + issue_id: null, |
| 197 | + issue_snapshot: null |
| 198 | + }, |
| 199 | + execution: { |
| 200 | + session_id: null, |
| 201 | + started_at: null, |
| 202 | + completed_at: null, |
| 203 | + skill_results: [], |
| 204 | + git_commit: null, |
| 205 | + error: null |
| 206 | + }, |
| 207 | + created_at: new Date().toISOString(), |
| 208 | + updated_at: new Date().toISOString() |
| 209 | +}; |
| 210 | + |
| 211 | +Bash('mkdir -p .workflow/.idaw/tasks'); |
| 212 | +Write(`.workflow/.idaw/tasks/${nextId}.json`, JSON.stringify(task, null, 2)); |
| 213 | +console.log(`Created ${nextId}: ${title}`); |
| 214 | +``` |
| 215 | +
|
| 216 | +## Helper Functions |
| 217 | +
|
| 218 | +### ID Generation |
| 219 | +
|
| 220 | +```javascript |
| 221 | +function generateNextId() { |
| 222 | + const files = Glob('.workflow/.idaw/tasks/IDAW-*.json') || []; |
| 223 | + if (files.length === 0) return 'IDAW-001'; |
| 224 | + |
| 225 | + const maxNum = files |
| 226 | + .map(f => parseInt(f.match(/IDAW-(\d+)/)?.[1] || '0')) |
| 227 | + .reduce((max, n) => Math.max(max, n), 0); |
| 228 | + |
| 229 | + return `IDAW-${String(maxNum + 1).padStart(3, '0')}`; |
| 230 | +} |
| 231 | +``` |
| 232 | +
|
| 233 | +### Task Type Inference (deferred — used at run time if task_type is null) |
| 234 | +
|
| 235 | +```javascript |
| 236 | +function inferTaskType(title, description) { |
| 237 | + const text = `${title} ${description}`.toLowerCase(); |
| 238 | + if (/urgent|production|critical/.test(text) && /fix|bug/.test(text)) return 'bugfix-hotfix'; |
| 239 | + if (/refactor|重构|tech.*debt/.test(text)) return 'refactor'; |
| 240 | + if (/tdd|test-driven|test first/.test(text)) return 'tdd'; |
| 241 | + if (/test fail|fix test|failing test/.test(text)) return 'test-fix'; |
| 242 | + if (/generate test|写测试|add test/.test(text)) return 'test'; |
| 243 | + if (/review|code review/.test(text)) return 'review'; |
| 244 | + if (/docs|documentation|readme/.test(text)) return 'docs'; |
| 245 | + if (/fix|bug|error|crash|fail/.test(text)) return 'bugfix'; |
| 246 | + if (/complex|multi-module|architecture/.test(text)) return 'feature-complex'; |
| 247 | + return 'feature'; |
| 248 | +} |
| 249 | +``` |
| 250 | +
|
| 251 | +## Examples |
| 252 | +
|
| 253 | +```bash |
| 254 | +# Manual creation |
| 255 | +/idaw:add "Fix login timeout bug" --type bugfix --priority 2 |
| 256 | +/idaw:add "Add rate limiting to API endpoints" --priority 1 |
| 257 | +/idaw:add "Refactor auth module to use strategy pattern" |
| 258 | + |
| 259 | +# Import from ccw issue |
| 260 | +/idaw:add --from-issue ISS-20260128-001 |
| 261 | +/idaw:add --from-issue ISS-20260128-001,ISS-20260128-002 --priority 1 |
| 262 | + |
| 263 | +# Auto mode (skip clarification) |
| 264 | +/idaw:add -y "Quick fix for typo in header" |
| 265 | +``` |
| 266 | +
|
| 267 | +## Output |
| 268 | +
|
| 269 | +``` |
| 270 | +Created IDAW-001: Fix login timeout bug |
| 271 | + Type: bugfix | Priority: 2 | Source: manual |
| 272 | + → Next: /idaw:run or /idaw:status |
| 273 | +``` |
0 commit comments