start-vibing 2.0.12 → 2.0.13
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/dist/cli.js +19 -2
- package/package.json +1 -1
- package/template/.claude/hooks/stop-validator.ts +62 -0
package/dist/cli.js
CHANGED
|
@@ -12,7 +12,14 @@ import { join, dirname } from "path";
|
|
|
12
12
|
import { fileURLToPath } from "url";
|
|
13
13
|
var __filename2 = fileURLToPath(import.meta.url);
|
|
14
14
|
var __dirname2 = dirname(__filename2);
|
|
15
|
-
var ALWAYS_OVERWRITE = [
|
|
15
|
+
var ALWAYS_OVERWRITE = [
|
|
16
|
+
"agents/",
|
|
17
|
+
"hooks/",
|
|
18
|
+
"settings.json",
|
|
19
|
+
"commands/",
|
|
20
|
+
"CLAUDE.md",
|
|
21
|
+
"README.md"
|
|
22
|
+
];
|
|
16
23
|
var NEVER_OVERWRITE = [
|
|
17
24
|
"skills/codebase-knowledge/domains/",
|
|
18
25
|
"skills/research-cache/cache/",
|
|
@@ -103,9 +110,19 @@ async function copyClaudeSetup(targetDir, options = {}) {
|
|
|
103
110
|
}
|
|
104
111
|
const claudeMdTemplate = join(templateDir, "CLAUDE.md");
|
|
105
112
|
const claudeMdDest = join(targetDir, "CLAUDE.md");
|
|
113
|
+
const claudeTemplateDest = join(destDir, "CLAUDE.template.md");
|
|
106
114
|
if (existsSync(claudeMdTemplate)) {
|
|
107
|
-
if (!existsSync(claudeMdDest)
|
|
115
|
+
if (!existsSync(claudeMdDest)) {
|
|
116
|
+
copyFileSync(claudeMdTemplate, claudeMdDest);
|
|
117
|
+
console.log(" \u2713 Created CLAUDE.md from template");
|
|
118
|
+
} else if (options.force) {
|
|
108
119
|
copyFileSync(claudeMdTemplate, claudeMdDest);
|
|
120
|
+
console.log(" \u2713 Overwrote CLAUDE.md (force mode)");
|
|
121
|
+
} else {
|
|
122
|
+
copyFileSync(claudeMdTemplate, claudeTemplateDest);
|
|
123
|
+
console.log(" \u2713 Preserved your CLAUDE.md");
|
|
124
|
+
console.log(" \u2713 Created .claude/CLAUDE.template.md for smart merge");
|
|
125
|
+
console.log(" \u2192 The stop hook will help merge new rules on first run");
|
|
109
126
|
}
|
|
110
127
|
}
|
|
111
128
|
return result;
|
package/package.json
CHANGED
|
@@ -437,6 +437,64 @@ After editing, verify: wc -m CLAUDE.md
|
|
|
437
437
|
};
|
|
438
438
|
}
|
|
439
439
|
|
|
440
|
+
function validateClaudeMdTemplateMerge(): ValidationError | null {
|
|
441
|
+
const templatePath = join(PROJECT_DIR, '.claude', 'CLAUDE.template.md');
|
|
442
|
+
|
|
443
|
+
// Only check if template exists (created by start-vibing when user has existing CLAUDE.md)
|
|
444
|
+
if (!existsSync(templatePath)) return null;
|
|
445
|
+
if (!existsSync(CLAUDE_MD_PATH)) return null;
|
|
446
|
+
|
|
447
|
+
const userContent = readFileSync(CLAUDE_MD_PATH, 'utf8');
|
|
448
|
+
const templateContent = readFileSync(templatePath, 'utf8');
|
|
449
|
+
|
|
450
|
+
// Check if user's CLAUDE.md is missing required sections
|
|
451
|
+
const missingSections: string[] = [];
|
|
452
|
+
for (const section of REQUIRED_SECTIONS) {
|
|
453
|
+
if (!section.pattern.test(userContent)) {
|
|
454
|
+
missingSections.push(section.name);
|
|
455
|
+
}
|
|
456
|
+
}
|
|
457
|
+
|
|
458
|
+
// If user has all required sections, they're probably fine - skip merge suggestion
|
|
459
|
+
if (missingSections.length === 0) {
|
|
460
|
+
return null; // User's CLAUDE.md is well-structured, no merge needed
|
|
461
|
+
}
|
|
462
|
+
|
|
463
|
+
return {
|
|
464
|
+
type: 'CLAUDE_MD_TEMPLATE_MERGE_NEEDED',
|
|
465
|
+
message: `Your CLAUDE.md is missing ${missingSections.length} required section(s). A template with recommended structure is available.`,
|
|
466
|
+
action: `
|
|
467
|
+
================================================================================
|
|
468
|
+
SMART MERGE: COMBINE YOUR CLAUDE.MD WITH NEW TEMPLATE
|
|
469
|
+
================================================================================
|
|
470
|
+
|
|
471
|
+
Your CLAUDE.md is missing these sections:
|
|
472
|
+
${missingSections.map((s) => ` - ${s}`).join('\n')}
|
|
473
|
+
|
|
474
|
+
A template file exists at: .claude/CLAUDE.template.md
|
|
475
|
+
|
|
476
|
+
REQUIRED ACTION:
|
|
477
|
+
Perform a smart merge that:
|
|
478
|
+
1. KEEPS all your existing project-specific content
|
|
479
|
+
2. ADDS the missing required sections from the template
|
|
480
|
+
3. PRESERVES your custom rules and configurations
|
|
481
|
+
|
|
482
|
+
MERGE STEPS:
|
|
483
|
+
1. Read your current CLAUDE.md content
|
|
484
|
+
2. Read .claude/CLAUDE.template.md for structure reference
|
|
485
|
+
3. Create a merged version that:
|
|
486
|
+
- Keeps your project title, overview, and custom rules
|
|
487
|
+
- Adds missing sections (${missingSections.join(', ')})
|
|
488
|
+
- Follows the template structure
|
|
489
|
+
4. Write the merged content to CLAUDE.md
|
|
490
|
+
5. Delete .claude/CLAUDE.template.md after successful merge
|
|
491
|
+
|
|
492
|
+
IMPORTANT: Do NOT just overwrite - intelligently MERGE the content!
|
|
493
|
+
After merging, delete the template file to mark merge as complete.
|
|
494
|
+
================================================================================`,
|
|
495
|
+
};
|
|
496
|
+
}
|
|
497
|
+
|
|
440
498
|
function validateClaudeMdStructure(): ValidationError | null {
|
|
441
499
|
if (!existsSync(CLAUDE_MD_PATH)) return null;
|
|
442
500
|
|
|
@@ -762,6 +820,10 @@ async function main(): Promise<void> {
|
|
|
762
820
|
if (claudeMdExistsError) errors.push(claudeMdExistsError);
|
|
763
821
|
|
|
764
822
|
if (!claudeMdExistsError) {
|
|
823
|
+
// Check if there's a template pending merge (from start-vibing install)
|
|
824
|
+
const templateMergeError = validateClaudeMdTemplateMerge();
|
|
825
|
+
if (templateMergeError) errors.push(templateMergeError);
|
|
826
|
+
|
|
765
827
|
const sizeError = validateClaudeMdSize();
|
|
766
828
|
if (sizeError) errors.push(sizeError);
|
|
767
829
|
|