delimit-cli 3.11.3 → 3.11.4

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.
@@ -338,40 +338,36 @@ Run full governance compliance checks. Verify security, policy compliance, evide
338
338
  }
339
339
  log(` ${green('✓')} ${installed} agents installed (${Object.keys(agents).length - installed} already existed)`);
340
340
 
341
- // Step 5: Create CLAUDE.md for first-run guidance
342
- step(5, 'Setting up first-run guidance...');
341
+ // Step 5: Create/update CLAUDE.md and platform instruction files
342
+ step(5, 'Setting up AI instruction files...');
343
343
 
344
344
  const claudeMd = path.join(os.homedir(), 'CLAUDE.md');
345
- if (!fs.existsSync(claudeMd)) {
346
- fs.writeFileSync(claudeMd, getClaudeMdContent());
347
- log(` ${green('✓')} Created ${claudeMd} with first-run guidance`);
345
+ const claudeResult = upsertDelimitSection(claudeMd);
346
+ if (claudeResult.action === 'created') {
347
+ log(` ${green('✓')} Created ${claudeMd} with governance triggers`);
348
+ } else if (claudeResult.action === 'updated') {
349
+ log(` ${green('✓')} Updated Delimit section in ${claudeMd} (version changed)`);
350
+ } else if (claudeResult.action === 'appended') {
351
+ log(` ${green('✓')} Appended Delimit section to ${claudeMd} (user content preserved)`);
348
352
  } else {
349
- // Check if existing CLAUDE.md is an older Delimit version that should be upgraded
350
- const existing = fs.readFileSync(claudeMd, 'utf-8');
351
- if (existing.includes('# Delimit AI Guardrails') || existing.includes('delimit_init') || existing.includes('delimit_lint') || existing.includes('persistent memory, verified execution')) {
352
- fs.writeFileSync(claudeMd, getClaudeMdContent());
353
- log(` ${green('✓')} Updated ${claudeMd} with improved onboarding`);
354
- } else {
355
- log(` ${dim(' CLAUDE.md already exists with custom content — skipped')}`);
356
- }
353
+ log(` ${dim(' CLAUDE.md already up to date')}`);
357
354
  }
358
355
 
359
- // Create instruction files for other platforms
360
- const instructionContent = getClaudeMdContent();
361
-
362
356
  // Codex instructions
363
357
  const codexInstructions = path.join(os.homedir(), '.codex', 'instructions.md');
364
358
  if (fs.existsSync(path.join(os.homedir(), '.codex'))) {
365
- if (!fs.existsSync(codexInstructions) || fs.readFileSync(codexInstructions, 'utf-8').includes('# Delimit')) {
366
- fs.writeFileSync(codexInstructions, instructionContent);
359
+ const codexResult = upsertDelimitSection(codexInstructions);
360
+ if (codexResult.action !== 'unchanged') {
361
+ log(` ${green('✓')} ${codexResult.action === 'created' ? 'Created' : 'Updated'} ${codexInstructions}`);
367
362
  }
368
363
  }
369
364
 
370
365
  // Cursor rules
371
366
  const cursorRules = path.join(os.homedir(), '.cursorrules');
372
367
  if (fs.existsSync(path.join(os.homedir(), '.cursor'))) {
373
- if (!fs.existsSync(cursorRules) || fs.readFileSync(cursorRules, 'utf-8').includes('# Delimit')) {
374
- fs.writeFileSync(cursorRules, instructionContent);
368
+ const cursorResult = upsertDelimitSection(cursorRules);
369
+ if (cursorResult.action !== 'unchanged') {
370
+ log(` ${green('✓')} ${cursorResult.action === 'created' ? 'Created' : 'Updated'} ${cursorRules}`);
375
371
  }
376
372
  }
377
373
 
@@ -540,8 +536,11 @@ echo "[Delimit] ${toolName} not found" >&2; exit 127
540
536
  log('');
541
537
  }
542
538
 
543
- function getClaudeMdContent() {
544
- return `# Delimit
539
+ function getDelimitSection() {
540
+ const pkg = JSON.parse(fs.readFileSync(path.join(__dirname, '..', 'package.json'), 'utf-8'));
541
+ const version = pkg.version || '0.0.0';
542
+ return `<!-- delimit:start v${version} -->
543
+ # Delimit
545
544
 
546
545
  One workspace for every AI coding assistant.
547
546
 
@@ -577,7 +576,67 @@ Add breaking change detection to any repo:
577
576
  - Docs: https://delimit.ai/docs
578
577
  - GitHub: https://github.com/delimit-ai/delimit
579
578
  - Action: https://github.com/marketplace/actions/delimit-api-governance
580
- `;
579
+ <!-- delimit:end -->`;
580
+ }
581
+
582
+ function getClaudeMdContent() {
583
+ return getDelimitSection() + '\n';
584
+ }
585
+
586
+ /**
587
+ * Upsert the Delimit section in a file using <!-- delimit:start --> / <!-- delimit:end --> markers.
588
+ * If markers exist, replaces only that region (preserving user content above/below).
589
+ * If no markers exist but old Delimit content is detected, replaces the whole file.
590
+ * If no Delimit content at all, appends the section.
591
+ * Returns { action: 'created' | 'updated' | 'unchanged' | 'appended' }
592
+ */
593
+ function upsertDelimitSection(filePath) {
594
+ const newSection = getDelimitSection();
595
+ const pkg = JSON.parse(fs.readFileSync(path.join(__dirname, '..', 'package.json'), 'utf-8'));
596
+ const version = pkg.version || '0.0.0';
597
+
598
+ if (!fs.existsSync(filePath)) {
599
+ fs.writeFileSync(filePath, newSection + '\n');
600
+ return { action: 'created' };
601
+ }
602
+
603
+ const existing = fs.readFileSync(filePath, 'utf-8');
604
+
605
+ // Check if markers already exist
606
+ const startMarkerRe = /<!-- delimit:start[^>]*-->/;
607
+ const endMarker = '<!-- delimit:end -->';
608
+ const hasStart = startMarkerRe.test(existing);
609
+ const hasEnd = existing.includes(endMarker);
610
+
611
+ if (hasStart && hasEnd) {
612
+ // Extract current version from the marker
613
+ const versionMatch = existing.match(/<!-- delimit:start v([^ ]+) -->/);
614
+ const currentVersion = versionMatch ? versionMatch[1] : '';
615
+ if (currentVersion === version) {
616
+ return { action: 'unchanged' };
617
+ }
618
+ // Replace only the delimit section
619
+ const before = existing.substring(0, existing.search(startMarkerRe));
620
+ const after = existing.substring(existing.indexOf(endMarker) + endMarker.length);
621
+ fs.writeFileSync(filePath, before + newSection + after);
622
+ return { action: 'updated' };
623
+ }
624
+
625
+ // No markers — check for old Delimit content that should be replaced
626
+ const isOldDelimit = existing.includes('# Delimit AI Guardrails') ||
627
+ existing.includes('delimit_init') ||
628
+ existing.includes('persistent memory, verified execution') ||
629
+ (existing.includes('# Delimit') && existing.includes('delimit_ledger_context'));
630
+
631
+ if (isOldDelimit) {
632
+ fs.writeFileSync(filePath, newSection + '\n');
633
+ return { action: 'updated' };
634
+ }
635
+
636
+ // File exists with user content but no Delimit section — append
637
+ const separator = existing.endsWith('\n') ? '\n' : '\n\n';
638
+ fs.writeFileSync(filePath, existing + separator + newSection + '\n');
639
+ return { action: 'appended' };
581
640
  }
582
641
 
583
642
  function copyDir(src, dest) {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "delimit-cli",
3
3
  "mcpName": "io.github.delimit-ai/delimit",
4
- "version": "3.11.3",
4
+ "version": "3.11.4",
5
5
  "description": "One workspace for every AI coding assistant. Tasks, memory, and governance carry between Claude Code, Codex, and Gemini CLI.",
6
6
  "main": "index.js",
7
7
  "files": [
package/server.json CHANGED
@@ -7,13 +7,13 @@
7
7
  "url": "https://github.com/delimit-ai/delimit",
8
8
  "source": "github"
9
9
  },
10
- "version": "3.11.3",
10
+ "version": "3.11.4",
11
11
  "websiteUrl": "https://delimit.ai",
12
12
  "packages": [
13
13
  {
14
14
  "registryType": "npm",
15
15
  "identifier": "delimit-cli",
16
- "version": "3.11.3",
16
+ "version": "3.11.4",
17
17
  "transport": {
18
18
  "type": "stdio"
19
19
  }