@champpaba/claude-agent-kit 1.1.1 → 1.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -42,6 +42,60 @@ Read in order:
42
42
  2. `openspec/changes/{change-id}/tasks.md`
43
43
  3. `openspec/changes/{change-id}/design.md` (if exists)
44
44
 
45
+ ---
46
+
47
+ ### Step 2.5: Validate Design System (Context Optimization v1.2.0)
48
+
49
+ > **New:** Validate design files exist for UI work
50
+
51
+ ```typescript
52
+ // Detect if change involves UI/frontend work
53
+ const tasksContent = Read('openspec/changes/{change-id}/tasks.md')
54
+ const hasFrontend = tasksContent.toLowerCase().match(/(ui|component|page|frontend|design|responsive)/i)
55
+
56
+ if (hasFrontend) {
57
+ output(`\nšŸŽØ UI work detected - validating design system...`)
58
+
59
+ const tokensPath = 'design-system/STYLE_TOKENS.json'
60
+ const styleGuidePath = 'design-system/STYLE_GUIDE.md'
61
+
62
+ const hasTokens = fileExists(tokensPath)
63
+ const hasStyleGuide = fileExists(styleGuidePath)
64
+
65
+ if (!hasTokens || !hasStyleGuide) {
66
+ warn(`
67
+ āš ļø WARNING: UI work detected but design system incomplete!
68
+
69
+ Found:
70
+ ${hasStyleGuide ? 'āœ…' : 'āŒ'} STYLE_GUIDE.md
71
+ ${hasTokens ? 'āœ…' : 'āŒ'} STYLE_TOKENS.json
72
+
73
+ This may result in:
74
+ - Inconsistent colors (random hex codes)
75
+ - Arbitrary spacing (p-5, gap-7)
76
+ - Duplicate components
77
+
78
+ Recommendation:
79
+ 1. Run: /designsetup
80
+ 2. Then: /csetup ${changeId}
81
+
82
+ Continue anyway? (yes/no)
83
+ `)
84
+
85
+ const answer = await askUser()
86
+ if (answer === 'no') {
87
+ return error('Setup cancelled. Run /designsetup first.')
88
+ }
89
+ } else {
90
+ output(`āœ… Design System Ready`)
91
+ output(` - STYLE_GUIDE.md āœ“`)
92
+ output(` - STYLE_TOKENS.json āœ“`)
93
+ }
94
+ }
95
+ ```
96
+
97
+ ---
98
+
45
99
  ### Step 3: Analyze Tasks
46
100
 
47
101
  **Parse tasks.md content and detect keywords:**
@@ -79,6 +133,133 @@ Detected:
79
133
  Change type: feature
80
134
  ```
81
135
 
136
+ ---
137
+
138
+ ### Step 3.5: Analyze Tasks (TaskMaster-style - v1.3.0)
139
+
140
+ > **NEW:** Enhanced task analysis with complexity, dependencies, risk assessment
141
+
142
+ **See:** `.claude/lib/task-analyzer.md` for complete analysis logic
143
+
144
+ ```typescript
145
+ import { analyzeTask } from '.claude/lib/task-analyzer.md'
146
+
147
+ // Parse tasks from tasks.md
148
+ const tasks = parseTasksFromMd(tasksContent)
149
+ const analyzedTasks = []
150
+
151
+ output(`\nšŸ“Š Analyzing ${tasks.length} tasks...`)
152
+
153
+ for (const task of tasks) {
154
+ // 1. Complexity scoring (1-10)
155
+ const complexity = calculateComplexity(task)
156
+
157
+ // 2. Dependency detection
158
+ const dependencies = detectDependencies(task, tasks)
159
+
160
+ // 3. Risk assessment
161
+ const risk = assessRisk(task, complexity)
162
+ risk.mitigation = generateMitigation(risk, task)
163
+
164
+ // 4. Research requirements
165
+ const research = detectResearchNeeds(task)
166
+
167
+ // 5. Subtask breakdown (if needed)
168
+ const needsBreakdown = needsSubtaskBreakdown(task, complexity)
169
+ const subtasks = needsBreakdown ? generateSubtasks(task) : []
170
+
171
+ // 6. Priority ranking
172
+ const priority = calculatePriority(task, { complexity, dependencies, risk })
173
+
174
+ analyzedTasks.push({
175
+ ...task,
176
+ complexity: {
177
+ score: complexity,
178
+ level: getComplexityLevel(complexity),
179
+ factors: explainComplexity(task, complexity)
180
+ },
181
+ dependencies,
182
+ risk: {
183
+ ...risk,
184
+ mitigation
185
+ },
186
+ research,
187
+ subtasks,
188
+ priority: {
189
+ score: priority,
190
+ label: getPriorityLabel(priority),
191
+ reason: explainPriority(task, priority)
192
+ },
193
+ estimatedTime: {
194
+ original: task.estimatedTime,
195
+ adjusted: adjustTimeForComplexity(task.estimatedTime, complexity, risk),
196
+ buffer: calculateBuffer(complexity, risk)
197
+ }
198
+ })
199
+ }
200
+
201
+ // Sort by priority (CRITICAL → HIGH → MEDIUM → LOW)
202
+ analyzedTasks.sort((a, b) => b.priority.score - a.priority.score)
203
+
204
+ // Store for phases.md generation
205
+ const taskAnalysis = {
206
+ tasks: analyzedTasks,
207
+ summary: {
208
+ total: analyzedTasks.length,
209
+ priority: {
210
+ critical: analyzedTasks.filter(t => t.priority.label === 'CRITICAL').length,
211
+ high: analyzedTasks.filter(t => t.priority.label === 'HIGH').length,
212
+ medium: analyzedTasks.filter(t => t.priority.label === 'MEDIUM').length,
213
+ low: analyzedTasks.filter(t => t.priority.label === 'LOW').length
214
+ },
215
+ risk: {
216
+ high: analyzedTasks.filter(t => t.risk.level === 'HIGH').length,
217
+ medium: analyzedTasks.filter(t => t.risk.level === 'MEDIUM').length,
218
+ low: analyzedTasks.filter(t => t.risk.level === 'LOW').length
219
+ },
220
+ researchRequired: analyzedTasks.filter(t => t.research?.required).length,
221
+ subtasksExpanded: analyzedTasks.filter(t => t.subtasks.length > 0).length,
222
+ averageComplexity: (analyzedTasks.reduce((sum, t) => sum + t.complexity.score, 0) / analyzedTasks.length).toFixed(1)
223
+ }
224
+ }
225
+ ```
226
+
227
+ **Output analysis report:**
228
+ ```
229
+ āœ… Task Analysis Complete
230
+
231
+ šŸ“Š Summary:
232
+ Total tasks: 8
233
+ Expanded to: 15 subtasks
234
+
235
+ šŸ“ˆ Priority Distribution:
236
+ šŸ”“ CRITICAL: 2 tasks (Login, Payment)
237
+ 🟠 HIGH: 3 tasks (User Profile, API endpoints)
238
+ 🟔 MEDIUM: 2 tasks (Email notifications)
239
+ 🟢 LOW: 1 task (Documentation)
240
+
241
+ āš ļø Risk Assessment:
242
+ 🚨 HIGH risk: 2 tasks (Payment integration, Auth system)
243
+ → Mitigation: TDD required, security checklist
244
+ āš ļø MEDIUM risk: 3 tasks
245
+ āœ… LOW risk: 3 tasks
246
+
247
+ šŸ”¬ Research Required: 2 tasks
248
+ - React Query v5 migration (15 min)
249
+ - Stripe payment best practices (15 min)
250
+
251
+ šŸ“¦ Subtask Breakdown: 3 tasks expanded
252
+ - Login system → 3 subtasks (UI, API, Integration)
253
+ - User CRUD → 4 subtasks (Create, Read, Update, Delete)
254
+
255
+ ā±ļø Time Estimates:
256
+ Original: 6.5 hours
257
+ Adjusted: 9.2 hours (+41% buffer for complexity/risk)
258
+ Average complexity: 5.8/10
259
+ ```
260
+
261
+ ---
262
+
82
263
  ### Step 4: Select Template
83
264
 
84
265
  **Selection logic:**
@@ -145,18 +326,66 @@ For each phase, add TDD metadata:
145
326
 
146
327
  ---
147
328
 
148
- **Generate phases.md:**
329
+ **šŸ†• ENHANCED v1.3.0: Inject Task Analysis Metadata**
330
+
331
+ ```typescript
332
+ // Add research phases (if needed)
333
+ const researchPhases = []
334
+ analyzedTasks.filter(t => t.research?.required).forEach((task, i) => {
335
+ researchPhases.push({
336
+ id: `research-${i + 1}`,
337
+ phaseNumber: `0.${i + 1}`, // Before implementation
338
+ name: `Research: ${task.research.category}`,
339
+ agent: 'integration',
340
+ estimatedMinutes: task.research.estimatedTime,
341
+ task: task,
342
+ queries: task.research.queries,
343
+ reason: task.research.reason
344
+ })
345
+ })
346
+
347
+ // Merge with existing phases (research goes first)
348
+ const allPhases = [...researchPhases, ...phaseSections]
349
+ ```
350
+
351
+ **Generate enhanced phases.md:**
149
352
  ```markdown
150
353
  # Agent Workflow: {CHANGE_ID} {Change Title}
151
354
 
152
355
  > **Auto-generated by `/csetup {change-id}`**
153
356
  > **Template:** {template-name} ({total-phases} phases)
154
357
  > **Reason:** {detection-reason}
155
- > **Source:** proposal.md + tasks.md + design.md
358
+ > **Source:** proposal.md + tasks.md (TaskMaster-analyzed)
156
359
  > **Last updated:** {current-datetime}
157
360
 
158
361
  ---
159
362
 
363
+ ## šŸ“Š Task Analysis Summary (v1.3.0 - TaskMaster-style)
364
+
365
+ **Analyzed Tasks:** {taskAnalysis.summary.total}
366
+ **Average Complexity:** {taskAnalysis.summary.averageComplexity}/10
367
+
368
+ **Priority Distribution:**
369
+ - šŸ”“ CRITICAL: {taskAnalysis.summary.priority.critical}
370
+ - 🟠 HIGH: {taskAnalysis.summary.priority.high}
371
+ - 🟔 MEDIUM: {taskAnalysis.summary.priority.medium}
372
+ - 🟢 LOW: {taskAnalysis.summary.priority.low}
373
+
374
+ **Risk Assessment:**
375
+ - 🚨 HIGH risk: {taskAnalysis.summary.risk.high} tasks
376
+ - āš ļø MEDIUM risk: {taskAnalysis.summary.risk.medium} tasks
377
+ - āœ… LOW risk: {taskAnalysis.summary.risk.low} tasks
378
+
379
+ **Research Phases:** {taskAnalysis.summary.researchRequired} added
380
+ **Subtasks Expanded:** {taskAnalysis.summary.subtasksExpanded} tasks
381
+
382
+ **Time Estimates:**
383
+ - Original: {calculateOriginalTime(analyzedTasks)} hours
384
+ - Adjusted: {calculateAdjustedTime(analyzedTasks)} hours
385
+ - Buffer: +{calculateTotalBuffer(analyzedTasks)}%
386
+
387
+ ---
388
+
160
389
  ## šŸ“Š Workflow Overview
161
390
 
162
391
  | Phase | Agent | Type | Est. Time | Status |
@@ -170,15 +399,63 @@ For each phase, add TDD metadata:
170
399
 
171
400
  ---
172
401
 
173
- {phase-section-1}
174
-
175
402
  ---
176
403
 
177
- {phase-section-2}
404
+ ## šŸ”¬ Research Phases (if applicable)
405
+
406
+ ${researchPhases.map((phase, i) => `
407
+ ### Phase 0.${i + 1}: ${phase.name}
408
+
409
+ **Agent:** integration
410
+ **Estimated Time:** ${phase.estimatedMinutes} min
411
+ **Type:** Research
412
+
413
+ **Reason:** ${phase.reason}
414
+
415
+ **Research Queries:**
416
+ ${phase.queries.map(q => `- ${q}`).join('\n')}
417
+
418
+ **Instructions:**
419
+ 1. Use WebSearch or Context7 to gather information
420
+ 2. Summarize findings in research notes
421
+ 3. Update task context with relevant insights
422
+ 4. Proceed to implementation with informed decisions
423
+
424
+ ---
425
+ `).join('')}
178
426
 
179
427
  ---
180
428
 
181
- ... (all phases)
429
+ ## šŸš€ Implementation Phases
430
+
431
+ ${allPhases.map((phaseSection, index) => {
432
+ // Find matching task from analyzedTasks
433
+ const matchingTask = analyzedTasks.find(t =>
434
+ phaseSection.toLowerCase().includes(t.description.toLowerCase().split(' ')[0])
435
+ )
436
+
437
+ let metadata = ''
438
+ if (matchingTask) {
439
+ metadata = `
440
+ **Task Metadata (TaskMaster Analysis):**
441
+ - **Complexity:** ${matchingTask.complexity.score}/10 (${matchingTask.complexity.level})
442
+ - Factors: ${matchingTask.complexity.factors.join(', ')}
443
+ - **Priority:** ${matchingTask.priority.label} (${matchingTask.priority.score}/100)
444
+ - ${matchingTask.priority.reason}
445
+ - **Risk:** ${matchingTask.risk.level}
446
+ ${matchingTask.risk.mitigation.length > 0 ? ` - Mitigation:\n${matchingTask.risk.mitigation.map(m => ` - ${m}`).join('\n')}` : ''}
447
+ - **Dependencies:**
448
+ - Blocked by: ${matchingTask.dependencies.blockedBy.length > 0 ? matchingTask.dependencies.blockedBy.join(', ') : 'None'}
449
+ - Blocks: ${matchingTask.dependencies.blocks.length > 0 ? matchingTask.dependencies.blocks.join(', ') : 'None'}
450
+ - Can parallelize with: ${matchingTask.dependencies.parallelizable.length > 0 ? matchingTask.dependencies.parallelizable.slice(0, 3).join(', ') : 'None'}
451
+ - **Time Estimate:** ${matchingTask.estimatedTime.original} min → ${matchingTask.estimatedTime.adjusted} min (+${matchingTask.estimatedTime.buffer}% buffer)
452
+
453
+ ${matchingTask.subtasks.length > 0 ? `**Subtasks:**\n${matchingTask.subtasks.map(st => ` - ${st.id}: ${st.description} (${st.estimatedTime} min)`).join('\n')}\n` : ''}
454
+ `
455
+ }
456
+
457
+ return `${phaseSection}\n${metadata}`
458
+ }).join('\n---\n\n')}
182
459
 
183
460
  ---
184
461
 
@@ -237,6 +514,41 @@ const projectTech = Read('.claude/contexts/domain/project/tech-stack.md')
237
514
  // Detect additional tech from proposal/tasks
238
515
  const additionalTech = detectAdditionalTech(proposalContent, tasksContent)
239
516
 
517
+ // šŸ†• Load design info (if UI work)
518
+ let designInfo = ''
519
+ if (hasFrontend) {
520
+ const tokensPath = 'design-system/STYLE_TOKENS.json'
521
+
522
+ if (fileExists(tokensPath)) {
523
+ const tokens = JSON.parse(Read(tokensPath))
524
+
525
+ designInfo = `
526
+ ## šŸŽØ Design System (Context Optimization v1.2.0)
527
+
528
+ **Design Files (Token-Efficient):**
529
+ - STYLE_TOKENS.json: \`design-system/STYLE_TOKENS.json\` (~500 tokens)
530
+ - STYLE_GUIDE.md: \`design-system/STYLE_GUIDE.md\` (~5000 tokens, load selectively)
531
+
532
+ **Key Design Tokens:**
533
+ - Primary Color: ${tokens.tokens.colors.primary.DEFAULT}
534
+ - Component Library: ${tokens.component_library.name}
535
+ - Spacing Scale: ${tokens.tokens.spacing.scale.join(', ')}px
536
+ - Shadows: ${Object.keys(tokens.tokens.shadows).slice(0, 5).join(', ')}
537
+
538
+ **Agent Loading (STEP 0.5 for uxui-frontend):**
539
+ 1. Read: STYLE_TOKENS.json (~500 tokens) āœ…
540
+ 2. Optional: STYLE_GUIDE.md (selective sections ~2K tokens)
541
+ 3. Report: Design tokens extracted
542
+
543
+ **Critical Rules:**
544
+ - āŒ NO hardcoded colors (text-gray-500)
545
+ - āœ… USE theme tokens (text-foreground/70)
546
+ - āŒ NO arbitrary spacing (p-5)
547
+ - āœ… USE spacing scale (p-4, p-6)
548
+ `
549
+ }
550
+ }
551
+
240
552
  // Replace placeholders
241
553
  contextTemplate = contextTemplate
242
554
  .replace('{CHANGE_ID}', changeId)
@@ -249,6 +561,7 @@ contextTemplate = contextTemplate
249
561
  .replace('{ADDITIONAL_TECH_LIST}', generateAdditionalTechList(additionalTech))
250
562
  .replace('{CURRENT_PHASE}', templateData.phases[0])
251
563
  .replace('{STATUS}', 'pending')
564
+ .replace('{DESIGN_SYSTEM}', designInfo) // šŸ†• Add design section
252
565
  ```
253
566
 
254
567
  Write to: `openspec/changes/{change-id}/.claude/context.md`