@champpaba/claude-agent-kit 1.4.1 → 1.5.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.
package/.claude/CLAUDE.md CHANGED
@@ -52,7 +52,7 @@ Universal, framework-agnostic template for AI-assisted development.
52
52
 
53
53
  **Page Planning (UI Tasks):**
54
54
  - `/pageplan @prd.md @brief.md` - **NEW!** Generate page structure & content plan for UI tasks
55
- - Output: `.changes/{id}/page-plan.md` (component reuse, content draft, asset checklist)
55
+ - Output: `openspec/changes/{id}/page-plan.md` (component reuse, content draft, asset checklist)
56
56
  - Used by: uxui-frontend agent (auto-reads in STEP 0.5)
57
57
 
58
58
  **OpenSpec Multi-Agent Workflow:**
@@ -121,7 +121,7 @@ Universal, framework-agnostic template for AI-assisted development.
121
121
 
122
122
  **Quick Summary:**
123
123
  - **Problem:** Agents duplicate components (Navbar 3x), use random colors, lorem ipsum content
124
- - **Solution:** `/pageplan @prd.md @brief.md` → Generates `.changes/{id}/page-plan.md` with component reuse plan, AI-drafted content, asset checklist
124
+ - **Solution:** `/pageplan @prd.md @brief.md` → Generates `openspec/changes/{id}/page-plan.md` with component reuse plan, AI-drafted content, asset checklist
125
125
  - **Benefits:** Prevents duplicates, ensures design consistency, real content from PRD, 25% faster (search done once upfront)
126
126
  - **Use for:** Landing pages, dashboards, multi-section UI pages (skip for backend/database work)
127
127
 
@@ -78,7 +78,7 @@ After completing standard discovery, check for project-specific resources:
78
78
  Read: design-system/STYLE_GUIDE.md
79
79
 
80
80
  # Check if page plan exists (from /pageplan command)
81
- Read: .changes/{change-id}/page-plan.md
81
+ Read: openspec/changes/{change-id}/page-plan.md
82
82
  ```
83
83
 
84
84
  **If STYLE_GUIDE.md exists:**
@@ -104,6 +104,62 @@ Read: .changes/{change-id}/page-plan.md
104
104
  - **OPTIMIZATION:** Skip STEP 3 (component search) - page-plan already did this!
105
105
  - **CRITICAL:** If Section 2.6 exists, animations are **pre-designed** - follow blueprint exactly
106
106
 
107
+ ---
108
+
109
+ ### 🚨 MANDATORY COMPLIANCE (When page-plan.md exists)
110
+
111
+ **YOU MUST implement ALL sections listed in page-plan.md Section 2 (Page Structure).**
112
+
113
+ **Before writing ANY code:**
114
+
115
+ 1. **Count sections** in page-plan.md Section 2 (Page Structure)
116
+ 2. **Create implementation checklist:**
117
+ ```
118
+ Sections to implement (from page-plan.md):
119
+ - [ ] Section 1: {ComponentName} - {purpose}
120
+ - [ ] Section 2: {ComponentName} - {purpose}
121
+ - [ ] Section 3: {ComponentName} - {purpose}
122
+ ...
123
+ ```
124
+
125
+ **After completing implementation:**
126
+
127
+ 3. **Verify ALL sections** are implemented
128
+ 4. **Report compliance:**
129
+ ```
130
+ ✅ Page Structure Compliance:
131
+ Sections required: {count}
132
+ Sections implemented: {count}
133
+ Status: ✅ COMPLETE (or ❌ INCOMPLETE)
134
+ ```
135
+
136
+ **⚠️ CRITICAL RULES:**
137
+
138
+ - ❌ If you implement LESS than ALL sections → Your work will be **REJECTED**
139
+ - ❌ You CANNOT skip sections (even if tasks.md says "4-5 components")
140
+ - ✅ You MUST implement EVERY section in page-plan.md Section 2
141
+ - ✅ If confused, page-plan.md takes PRIORITY over tasks.md
142
+
143
+ **Example:**
144
+
145
+ If page-plan.md Section 2 lists:
146
+ ```
147
+ <Layout>
148
+ <LandingNavBar /> {/* 1 */}
149
+ <HeroSection /> {/* 2 */}
150
+ <ProblemSection /> {/* 3 */}
151
+ <FeatureGrid /> {/* 4 */}
152
+ <ComparisonTable /> {/* 5 */}
153
+ <TestimonialCards /> {/* 6 */}
154
+ <CTASection /> {/* 7 */}
155
+ <Footer /> {/* 8 */}
156
+ </Layout>
157
+ ```
158
+
159
+ You MUST create ALL 8 sections, NOT just Hero + FeatureGrid + Footer (3/8).
160
+
161
+ ---
162
+
107
163
  **If page-plan.md does NOT exist:**
108
164
  - ℹ️ No page plan - will search for components manually in STEP 3
109
165
  - ⚠️ No animation blueprint - fallback to `.claude/contexts/patterns/animation-patterns.md`
@@ -309,6 +365,63 @@ const TOKENS = {
309
365
  - Bundle size: -30-40% (code splitting)
310
366
  - Image size: -80% (WebP + compression)
311
367
 
368
+ ### 📋 Step 4.6: Page Plan Compliance Checklist (IF page-plan.md exists)
369
+
370
+ **Only complete this step if page-plan.md was loaded in STEP 0.5:**
371
+
372
+ **Purpose:** Ensure you implement ALL sections from page-plan.md, not a subset.
373
+
374
+ **Instructions:**
375
+
376
+ 1. **Re-read** page-plan.md Section 2 (Page Structure)
377
+ 2. **Extract** all components listed in the structure
378
+ 3. **Count** total sections required
379
+ 4. **Create** implementation checklist:
380
+
381
+ ```
382
+ 📋 Page Structure Implementation Checklist
383
+ Total sections: {count}
384
+
385
+ Sections to implement (from page-plan.md Section 2):
386
+ - [ ] {Component 1} - {description/purpose}
387
+ - [ ] {Component 2} - {description/purpose}
388
+ - [ ] {Component 3} - {description/purpose}
389
+ ...
390
+
391
+ Verification:
392
+ - [ ] All sections from page-plan.md are listed above
393
+ - [ ] No sections are skipped
394
+ - [ ] I will implement ALL sections (not a subset)
395
+ ```
396
+
397
+ **Report when complete:**
398
+ ```
399
+ ✅ Page Plan Compliance Checklist Created
400
+ Total sections: {count}
401
+ Ready to implement FULL page structure
402
+
403
+ Example:
404
+ - Section 1: LandingNavBar (sticky navigation)
405
+ - Section 2: HeroSection (above fold)
406
+ - Section 3: ProblemSection (pain points)
407
+ - ...
408
+ - Section 10: Footer (links + social)
409
+
410
+ Status: ✅ Checklist verified - will implement all 10 sections
411
+ ```
412
+
413
+ **⚠️ CRITICAL:**
414
+ - This checklist is MANDATORY - if you skip it, you'll likely implement only 4-5 sections instead of all 10
415
+ - If page-plan.md lists 10 sections, you MUST create 10 components
416
+ - tasks.md may say "create 4-5 components" - IGNORE this if page-plan.md exists
417
+ - page-plan.md takes PRIORITY over tasks.md
418
+
419
+ **If page-plan.md does NOT exist:**
420
+ - Skip this step
421
+ - Proceed to Step 5
422
+
423
+ ---
424
+
312
425
  ### 📋 Step 5: Pre-Implementation Report (REQUIRED)
313
426
 
314
427
  Provide complete analysis covering steps 1-4 BEFORE writing code.
@@ -343,7 +456,7 @@ Provide complete analysis covering steps 1-4 BEFORE writing code.
343
456
  ### Project-Specific (If Exists)
344
457
  - `design-system/STYLE_GUIDE.md` (Priority #1 - loaded in STEP 0.5)
345
458
  - `design-system/STYLE_TOKENS.json` (lightweight tokens)
346
- - `.changes/{change-id}/page-plan.md` (from /pageplan command)
459
+ - `openspec/changes/{change-id}/page-plan.md` (from /pageplan command)
347
460
 
348
461
  ### Framework Docs (Context7)
349
462
  **Topic:** "components, hooks, state management, routing, styling"
@@ -269,6 +269,93 @@ See `.claude/contexts/patterns/validation-framework.md` for complete checklist p
269
269
 
270
270
  ---
271
271
 
272
+ ### Step 4.7: Validate Page Plan Compliance (uxui-frontend only)
273
+
274
+ **Only runs for uxui-frontend agent when page-plan.md exists:**
275
+
276
+ **Purpose:** Verify agent implemented ALL sections from page-plan.md, not a subset.
277
+
278
+ ```typescript
279
+ // Check if page-plan.md exists
280
+ const pagePlanPath = `openspec/changes/${changeId}/page-plan.md`
281
+ const hasPagePlan = fileExists(pagePlanPath)
282
+
283
+ if (phase.agent === 'uxui-frontend' && hasPagePlan) {
284
+ output(`\n🔍 Validating page-plan.md compliance...`)
285
+
286
+ // Extract sections from page-plan.md Section 2 (Page Structure)
287
+ const pagePlan = Read(pagePlanPath)
288
+ const section2Match = pagePlan.match(/## 2\. Page Structure[\s\S]*?(?=## 3\.|## 2\.5|## 2\.6|$)/)
289
+
290
+ if (section2Match) {
291
+ // Count expected sections (extract component names from JSX)
292
+ const componentMatches = section2Match[0].match(/<([A-Z]\w+)/g) || []
293
+ const expectedComponents = componentMatches
294
+ .map(m => m.replace('<', ''))
295
+ .filter(name => name !== 'Layout' && name !== 'div') // Exclude wrappers
296
+
297
+ const uniqueComponents = [...new Set(expectedComponents)] // Remove duplicates
298
+
299
+ output(`\n📋 Page Plan Analysis:`)
300
+ output(` Expected sections: ${uniqueComponents.length}`)
301
+ output(` Components: ${uniqueComponents.join(', ')}`)
302
+
303
+ // Prompt user to verify agent compliance
304
+ output(`\n⚠️ VALIDATION REQUIRED:`)
305
+ output(`\nDid the agent implement ALL ${uniqueComponents.length} sections?`)
306
+ output(`\nPlease verify the implementation includes:`)
307
+ uniqueComponents.forEach(c => output(` - ${c}`))
308
+
309
+ output(`\nOptions:`)
310
+ output(` [yes] - All sections implemented ✓`)
311
+ output(` [retry] - Agent skipped sections, retry with strict enforcement`)
312
+ output(` [skip] - Skip validation (not recommended)`)
313
+
314
+ const answer = await askUser(`\nConfirm all sections implemented?`)
315
+
316
+ if (answer === 'retry') {
317
+ output(`\n🔄 Retrying phase with enhanced enforcement...`)
318
+ output(`Agent will be explicitly instructed to implement all ${uniqueComponents.length} sections`)
319
+
320
+ // Restart phase with enhanced prompt
321
+ return executePhaseAgain(changeId, phase, {
322
+ enforce_page_plan: true,
323
+ required_sections: uniqueComponents
324
+ })
325
+ } else if (answer === 'skip') {
326
+ warn(`\n⚠️ Skipping validation - proceed with caution`)
327
+ warn(` This may result in incomplete implementation`)
328
+ } else {
329
+ output(`\n✅ Page plan compliance confirmed`)
330
+ output(` All ${uniqueComponents.length} sections implemented`)
331
+ }
332
+ } else {
333
+ warn(`\n⚠️ Could not parse page-plan.md Section 2`)
334
+ warn(` Skipping compliance validation`)
335
+ }
336
+ } else {
337
+ // Not uxui-frontend or no page-plan.md - skip validation
338
+ output(`\nℹ️ Page plan validation: N/A (agent: ${phase.agent}, has plan: ${hasPagePlan})`)
339
+ }
340
+ ```
341
+
342
+ **When to use:**
343
+ - ✅ Agent: uxui-frontend
344
+ - ✅ page-plan.md exists
345
+ - ✅ Phase completed successfully
346
+
347
+ **Common issues caught:**
348
+ - Agent implemented 5/10 sections (missing ProblemSection, ComparisonTable, etc.)
349
+ - Agent followed tasks.md ("4-5 components") instead of page-plan.md (10 sections)
350
+ - Agent skipped sections they thought were "optional"
351
+
352
+ **Remediation:**
353
+ - If validation fails → Retry with `enforce_page_plan: true`
354
+ - Agent will receive enhanced prompt with explicit section list
355
+ - Validation runs again after retry
356
+
357
+ ---
358
+
272
359
  ### Step 5: Post-Execution (🆕 MANDATORY FLAGS UPDATE)
273
360
 
274
361
  **⚠️ CRITICAL: Main Claude MUST update flags.json after EVERY phase completion**
@@ -7,7 +7,7 @@
7
7
  # With context files
8
8
  /pageplan @proposal.md @prd.md @project_brief.md
9
9
 
10
- # Current change only (uses proposal.md in .changes/)
10
+ # Current change only (uses proposal.md in openspec/changes/)
11
11
  /pageplan
12
12
 
13
13
  # Specify change ID
@@ -20,7 +20,7 @@
20
20
 
21
21
  1. **Reads User-Specified Context:**
22
22
  - Only reads files that user mentions with `@` prefix
23
- - Always reads `.changes/{change-id}/proposal.md` (if exists)
23
+ - Always reads `openspec/changes/{change-id}/proposal.md` (if exists)
24
24
  - **Always reads `design-system/STYLE_TOKENS.json`** (lightweight, ~500 tokens) ✅
25
25
  - Validates `design-system/STYLE_GUIDE.md` exists (doesn't load full content)
26
26
 
@@ -36,7 +36,7 @@
36
36
  - Asset checklist (user must prepare)
37
37
  - Rationale (why this structure)
38
38
 
39
- 4. **Outputs to:** `.changes/{change-id}/page-plan.md`
39
+ 4. **Outputs to:** `openspec/changes/{change-id}/page-plan.md`
40
40
 
41
41
  ---
42
42
 
@@ -46,7 +46,7 @@
46
46
 
47
47
  ```typescript
48
48
  // Detect current change ID
49
- const changesDir = '.changes/'
49
+ const changesDir = 'openspec/changes/'
50
50
  const changeId = detectCurrentChange() // or from command arg
51
51
 
52
52
  if (!changeId) {
@@ -54,7 +54,7 @@ if (!changeId) {
54
54
  return
55
55
  }
56
56
 
57
- const outputPath = `.changes/${changeId}/page-plan.md`
57
+ const outputPath = `openspec/changes/${changeId}/page-plan.md`
58
58
  ```
59
59
 
60
60
  ### STEP 2: Read Context Files
@@ -64,7 +64,7 @@ const outputPath = `.changes/${changeId}/page-plan.md`
64
64
  const userFiles = extractMentionedFiles(userMessage) // @prd.md, @brief.md
65
65
 
66
66
  // Always read (if exists)
67
- const proposalPath = `.changes/${changeId}/proposal.md`
67
+ const proposalPath = `openspec/changes/${changeId}/proposal.md`
68
68
  const tokensPath = `design-system/STYLE_TOKENS.json` // 🆕 Lightweight tokens
69
69
  const styleGuidePath = `design-system/STYLE_GUIDE.md` // Validate only, don't load
70
70
 
@@ -17,7 +17,7 @@
17
17
  ## 📘 How to Use This File
18
18
 
19
19
  **Priority:**
20
- 1. **Page-specific plan:** `.changes/{id}/page-plan.md` Section 2.6 (if exists)
20
+ 1. **Page-specific plan:** `openspec/changes/{id}/page-plan.md` Section 2.6 (if exists)
21
21
  2. **Project tokens:** `design-system/STYLE_TOKENS.json` (animation tokens)
22
22
  3. **General guidelines:** This file (fallback when above don't exist)
23
23
 
@@ -252,7 +252,7 @@ Each agent loads additional contexts based on their role.
252
252
  **Project-specific (if exists):**
253
253
  - `design-system/STYLE_GUIDE.md` (17 sections, ~5K tokens)
254
254
  - `design-system/STYLE_TOKENS.json` (lightweight, ~500 tokens)
255
- - `.changes/{change-id}/page-plan.md` (from /pageplan command)
255
+ - `openspec/changes/{change-id}/page-plan.md` (from /pageplan command)
256
256
 
257
257
  **Loading strategy:**
258
258
  ```
@@ -334,7 +334,7 @@ Each agent loads additional contexts based on their role.
334
334
  → Loading: design/*.md ✓
335
335
  → Loading: patterns/ui-component-consistency.md ✓
336
336
  → Loading: design-system/STYLE_TOKENS.json ✓
337
- → Loading: .changes/landing-page/page-plan.md ✓
337
+ → Loading: openspec/changes/landing-page/page-plan.md ✓
338
338
  ✅ Design contexts loaded
339
339
 
340
340
  ✅ Context Loading Complete!
@@ -36,7 +36,7 @@ Main Claude:
36
36
  2. Reads proposal.md (technical architecture)
37
37
  3. Reads STYLE_GUIDE.md (visual design)
38
38
  4. Searches existing components (Glob/Grep)
39
- 5. Generates: .changes/{id}/page-plan.md
39
+ 5. Generates: openspec/changes/{id}/page-plan.md
40
40
  - 🔄 Reuse: Navbar, Footer (found)
41
41
  - ✅ New: HeroSection, FeatureGrid (create)
42
42
  - 📝 Content draft (AI-generated from PRD)
@@ -219,7 +219,7 @@ function generateMitigation(risk: RiskLevel, task: Task): string[] {
219
219
  ```typescript
220
220
  function detectResearchNeeds(task: Task, changeContext: any): ResearchRequirement | null {
221
221
  // Check if page-plan.md exists (skip UX/accessibility research)
222
- const hasPagePlan = fileExists(`.changes/${changeContext.changeId}/page-plan.md`)
222
+ const hasPagePlan = fileExists(`openspec/changes/${changeContext.changeId}/page-plan.md`)
223
223
 
224
224
  const researchIndicators = {
225
225
  // Technical research (always check)
package/README.md CHANGED
@@ -110,7 +110,7 @@ Users need secure login functionality...
110
110
  ```bash
111
111
  # Step 1: OpenSpec generates tasks
112
112
  User: "Build landing page for TOEIC app"
113
- → Creates: .changes/landing-page/proposal.md + tasks.md
113
+ → Creates: openspec/changes/landing-page/proposal.md + tasks.md
114
114
 
115
115
  # Step 2: Generate page plan (NEW!)
116
116
  User: /pageplan @prd.md @project_brief.md
@@ -121,7 +121,7 @@ User: /pageplan @prd.md @project_brief.md
121
121
  # 3. Reads STYLE_GUIDE.md (visual design)
122
122
  # 4. Searches existing components (Navbar, Footer, etc.)
123
123
  # 5. AI drafts real content from PRD
124
- # 6. Generates: .changes/landing-page/page-plan.md
124
+ # 6. Generates: openspec/changes/landing-page/page-plan.md
125
125
  ```
126
126
 
127
127
  ### page-plan.md Output
@@ -257,7 +257,7 @@ cd my-app
257
257
 
258
258
  # Draft a change proposal (OpenSpec handles this)
259
259
  "I want to build a landing page for my TOEIC app"
260
- # → Generates: .changes/landing-page/proposal.md + tasks.md
260
+ # → Generates: openspec/changes/landing-page/proposal.md + tasks.md
261
261
  ```
262
262
 
263
263
  ### Step 2: Initialize Claude Agent Kit
@@ -277,7 +277,7 @@ cak init
277
277
  # In Claude Code:
278
278
  /pageplan @prd.md @project_brief.md
279
279
 
280
- # → Generates: .changes/landing-page/page-plan.md
280
+ # → Generates: openspec/changes/landing-page/page-plan.md
281
281
  # → Review content, prepare assets
282
282
  ```
283
283
 
@@ -288,9 +288,9 @@ cak init
288
288
  ```
289
289
 
290
290
  **What happens:**
291
- - Reads `.changes/landing-page/proposal.md` (business context)
292
- - Reads `.changes/landing-page/tasks.md` (implementation checklist)
293
- - Reads `.changes/landing-page/page-plan.md` (if exists - content plan)
291
+ - Reads `openspec/changes/landing-page/proposal.md` (business context)
292
+ - Reads `openspec/changes/landing-page/tasks.md` (implementation checklist)
293
+ - Reads `openspec/changes/landing-page/page-plan.md` (if exists - content plan)
294
294
  - Classifies tasks by agent (database, backend, frontend, etc.)
295
295
  - Generates `workflow.md` (execution plan)
296
296
 
package/lib/helpers.js CHANGED
@@ -28,16 +28,52 @@ async function promptUser(question) {
28
28
  }
29
29
 
30
30
  /**
31
- * Merge template files into target directory
32
- * - Overwrites files with same name
31
+ * Merge template files into target directory with smart comparison
32
+ * - Only overwrites if content actually differs
33
33
  * - Keeps existing files that don't exist in template
34
+ * - Skips identical files (prevents Git showing unnecessary changes)
34
35
  * @param {string} templatePath - Source template directory
35
36
  * @param {string} targetPath - Target directory
36
37
  */
37
38
  async function mergeTemplateFiles(templatePath, targetPath) {
39
+ const crypto = require('crypto');
40
+
41
+ // Helper: Calculate file hash
42
+ function getFileHash(filePath) {
43
+ try {
44
+ const content = fs.readFileSync(filePath);
45
+ return crypto.createHash('md5').update(content).digest('hex');
46
+ } catch (error) {
47
+ return null;
48
+ }
49
+ }
50
+
51
+ // Custom filter function
52
+ const filter = (src, dest) => {
53
+ const srcStat = fs.statSync(src);
54
+
55
+ // Always copy directories
56
+ if (srcStat.isDirectory()) {
57
+ return true;
58
+ }
59
+
60
+ // If destination doesn't exist, copy it
61
+ if (!fs.existsSync(dest)) {
62
+ return true;
63
+ }
64
+
65
+ // Compare file hashes (content-based comparison)
66
+ const srcHash = getFileHash(src);
67
+ const destHash = getFileHash(dest);
68
+
69
+ // Only copy if content differs
70
+ return srcHash !== destHash;
71
+ };
72
+
38
73
  await fs.copy(templatePath, targetPath, {
39
74
  overwrite: true,
40
- errorOnExist: false
75
+ errorOnExist: false,
76
+ filter: filter
41
77
  });
42
78
  }
43
79
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@champpaba/claude-agent-kit",
3
- "version": "1.4.1",
3
+ "version": "1.5.0",
4
4
  "description": "Universal multi-agent template for Claude Code - AI-assisted development with specialized agents",
5
5
  "main": "bin/cli.js",
6
6
  "bin": {