aiblueprint-cli 1.4.61 → 1.4.63

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.
Files changed (2) hide show
  1. package/dist/cli.js +145 -1
  2. package/package.json +1 -1
package/dist/cli.js CHANGED
@@ -35077,6 +35077,26 @@ function getContainerCandidates(options) {
35077
35077
  }
35078
35078
  ]);
35079
35079
  }
35080
+ function getInstructionFileCandidates(options) {
35081
+ const folders = resolveFolders(options);
35082
+ return uniqueByPath([
35083
+ {
35084
+ label: "agents-instructions",
35085
+ path: path16.join(folders.agentsDir, "AGENTS.md"),
35086
+ isDestination: true
35087
+ },
35088
+ {
35089
+ label: "claude-instructions",
35090
+ path: path16.join(folders.claudeDir, "CLAUDE.md"),
35091
+ linkWhenMissing: true
35092
+ },
35093
+ {
35094
+ label: "codex-instructions",
35095
+ path: path16.join(folders.codexDir, "AGENTS.md"),
35096
+ linkWhenMissing: true
35097
+ }
35098
+ ]);
35099
+ }
35080
35100
  function shouldCollectEntry(category, entry) {
35081
35101
  if (IGNORED_ENTRY_NAMES2.has(entry.name))
35082
35102
  return false;
@@ -35255,6 +35275,14 @@ async function createDirectorySymlink(source, target) {
35255
35275
  }
35256
35276
  await import_fs_extra12.default.symlink(source, target, "dir");
35257
35277
  }
35278
+ async function createFileSymlink(source, target) {
35279
+ await import_fs_extra12.default.ensureDir(path16.dirname(target));
35280
+ if (os13.platform() === "win32") {
35281
+ await import_fs_extra12.default.symlink(source, target, "file");
35282
+ return;
35283
+ }
35284
+ await import_fs_extra12.default.symlink(source, target);
35285
+ }
35258
35286
  async function shouldLinkMissingContainer(candidate) {
35259
35287
  if (candidate.linkWhenMissing)
35260
35288
  return true;
@@ -35310,9 +35338,119 @@ async function linkContainer(candidate, destinationDir, result) {
35310
35338
  movedToBackup: backupTarget
35311
35339
  });
35312
35340
  }
35341
+ async function importInstructionFiles(candidates, destinationPath, result) {
35342
+ await import_fs_extra12.default.ensureDir(path16.dirname(destinationPath));
35343
+ const destinationRealPath = await realPathIfPossible(destinationPath);
35344
+ let destinationHash = await pathExistsOrSymlink(destinationPath) ? await hashPath(destinationPath) : null;
35345
+ for (const candidate of candidates) {
35346
+ if (candidate.isDestination)
35347
+ continue;
35348
+ const sourceStat = await import_fs_extra12.default.lstat(candidate.path).catch(() => null);
35349
+ if (!sourceStat)
35350
+ continue;
35351
+ const sourceRealPath = await realPathIfPossible(candidate.path);
35352
+ if (destinationRealPath && sourceRealPath && samePath(destinationRealPath, sourceRealPath)) {
35353
+ continue;
35354
+ }
35355
+ const sourceHash = await hashPath(candidate.path);
35356
+ if (!destinationHash) {
35357
+ await import_fs_extra12.default.copy(candidate.path, destinationPath, {
35358
+ dereference: false,
35359
+ overwrite: false
35360
+ });
35361
+ destinationHash = sourceHash;
35362
+ result.imported.push({
35363
+ category: "instructions",
35364
+ name: path16.basename(candidate.path),
35365
+ from: candidate.path,
35366
+ to: destinationPath
35367
+ });
35368
+ continue;
35369
+ }
35370
+ if (sourceHash === destinationHash) {
35371
+ result.duplicates.push({
35372
+ category: "instructions",
35373
+ name: path16.basename(candidate.path),
35374
+ from: candidate.path,
35375
+ keptAs: destinationPath
35376
+ });
35377
+ continue;
35378
+ }
35379
+ const targetName = await findTargetName(path16.dirname(destinationPath), path16.basename(destinationPath), candidate.label);
35380
+ const targetPath = path16.join(path16.dirname(destinationPath), targetName);
35381
+ await import_fs_extra12.default.copy(candidate.path, targetPath, {
35382
+ dereference: false,
35383
+ overwrite: false
35384
+ });
35385
+ result.renamed.push({
35386
+ category: "instructions",
35387
+ name: path16.basename(candidate.path),
35388
+ from: candidate.path,
35389
+ to: targetPath,
35390
+ reason: "Shared instruction file already exists with different content"
35391
+ });
35392
+ }
35393
+ }
35394
+ async function shouldLinkMissingInstruction(candidate) {
35395
+ if (candidate.linkWhenMissing)
35396
+ return true;
35397
+ return false;
35398
+ }
35399
+ async function linkInstructionFile(candidate, destinationPath, result) {
35400
+ if (candidate.isDestination || samePath(candidate.path, destinationPath)) {
35401
+ return;
35402
+ }
35403
+ if (!await pathExistsOrSymlink(destinationPath)) {
35404
+ return;
35405
+ }
35406
+ const destinationRealPath = await realPathIfPossible(destinationPath);
35407
+ const stat = await import_fs_extra12.default.lstat(candidate.path).catch(() => null);
35408
+ if (!stat) {
35409
+ if (!await shouldLinkMissingInstruction(candidate))
35410
+ return;
35411
+ await createFileSymlink(destinationPath, candidate.path);
35412
+ result.linked.push({
35413
+ category: "instructions",
35414
+ from: candidate.path,
35415
+ to: destinationPath
35416
+ });
35417
+ return;
35418
+ }
35419
+ if (stat.isSymbolicLink()) {
35420
+ const existingRealPath = await realPathIfPossible(candidate.path);
35421
+ if (destinationRealPath && existingRealPath && samePath(destinationRealPath, existingRealPath)) {
35422
+ result.alreadyLinked.push({
35423
+ category: "instructions",
35424
+ from: candidate.path,
35425
+ to: destinationPath
35426
+ });
35427
+ return;
35428
+ }
35429
+ await import_fs_extra12.default.remove(candidate.path);
35430
+ await createFileSymlink(destinationPath, candidate.path);
35431
+ result.linked.push({
35432
+ category: "instructions",
35433
+ from: candidate.path,
35434
+ to: destinationPath
35435
+ });
35436
+ return;
35437
+ }
35438
+ const backupRoot = await ensureBackupPath(result);
35439
+ const backupTarget = path16.join(backupRoot, safeRelativePath(result.rootDir, candidate.path));
35440
+ await import_fs_extra12.default.ensureDir(path16.dirname(backupTarget));
35441
+ await import_fs_extra12.default.move(candidate.path, backupTarget, { overwrite: false });
35442
+ await createFileSymlink(destinationPath, candidate.path);
35443
+ result.linked.push({
35444
+ category: "instructions",
35445
+ from: candidate.path,
35446
+ to: destinationPath,
35447
+ movedToBackup: backupTarget
35448
+ });
35449
+ }
35313
35450
  async function unifyAgentsConfiguration(options = {}) {
35314
35451
  const folders = resolveFolders(options);
35315
35452
  const candidates = getContainerCandidates(options);
35453
+ const instructionCandidates = getInstructionFileCandidates(options);
35316
35454
  const result = {
35317
35455
  rootDir: folders.rootDir,
35318
35456
  agentsDir: folders.agentsDir,
@@ -35326,15 +35464,20 @@ async function unifyAgentsConfiguration(options = {}) {
35326
35464
  };
35327
35465
  const destinationByCategory = {
35328
35466
  skills: path16.join(folders.agentsDir, "skills"),
35329
- agents: path16.join(folders.agentsDir, "agents")
35467
+ agents: path16.join(folders.agentsDir, "agents"),
35468
+ instructions: path16.join(folders.agentsDir, "AGENTS.md")
35330
35469
  };
35331
35470
  await import_fs_extra12.default.ensureDir(folders.agentsDir);
35471
+ await importInstructionFiles(instructionCandidates, destinationByCategory.instructions, result);
35332
35472
  for (const category of ["skills", "agents"]) {
35333
35473
  await importCategoryEntries(category, candidates, destinationByCategory[category], result);
35334
35474
  }
35335
35475
  for (const candidate of candidates) {
35336
35476
  await linkContainer(candidate, destinationByCategory[candidate.category], result);
35337
35477
  }
35478
+ for (const candidate of instructionCandidates) {
35479
+ await linkInstructionFile(candidate, destinationByCategory.instructions, result);
35480
+ }
35338
35481
  return result;
35339
35482
  }
35340
35483
 
@@ -35361,6 +35504,7 @@ AIBlueprint agents unify ${source_default.gray(`v${getVersion()}`)}
35361
35504
  console.log(source_default.green(`
35362
35505
  Unify complete`));
35363
35506
  console.log(source_default.gray(` Shared folder: ${result.agentsDir}`));
35507
+ printCategorySummary(result, "instructions");
35364
35508
  printCategorySummary(result, "skills");
35365
35509
  printCategorySummary(result, "agents");
35366
35510
  console.log(source_default.gray(` codex agents: ${codexResult.rendered.length} rendered, ${codexResult.skipped.length} skipped`));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "aiblueprint-cli",
3
- "version": "1.4.61",
3
+ "version": "1.4.63",
4
4
  "description": "AIBlueprint CLI for setting up AI coding configurations",
5
5
  "author": "AIBlueprint",
6
6
  "license": "MIT",