agents-inc 0.174.0 → 0.176.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.
Files changed (90) hide show
  1. package/CHANGELOG.md +115 -0
  2. package/dist/{chunk-APWMMZOK.js → chunk-3F5LT433.js} +157 -53
  3. package/dist/chunk-3F5LT433.js.map +1 -0
  4. package/dist/chunk-5CFHP6Z5.js +109 -0
  5. package/dist/chunk-5CFHP6Z5.js.map +1 -0
  6. package/dist/{chunk-3PJZ4QNJ.js → chunk-B7AVWSK2.js} +21 -11
  7. package/dist/chunk-B7AVWSK2.js.map +1 -0
  8. package/dist/{chunk-H5E6IO2L.js → chunk-C2BSCEDN.js} +9 -11
  9. package/dist/chunk-C2BSCEDN.js.map +1 -0
  10. package/dist/{chunk-R7GKQBZJ.js → chunk-CKBWEWHZ.js} +96 -52
  11. package/dist/chunk-CKBWEWHZ.js.map +1 -0
  12. package/dist/{chunk-IXVGBUWI.js → chunk-EC3JXT23.js} +5 -5
  13. package/dist/{chunk-E45IT3HC.js → chunk-ENET4IF6.js} +998 -472
  14. package/dist/chunk-ENET4IF6.js.map +1 -0
  15. package/dist/{chunk-FQF6VHO3.js → chunk-FACDJH6O.js} +12 -105
  16. package/dist/chunk-FACDJH6O.js.map +1 -0
  17. package/dist/{chunk-TVEDNGVP.js → chunk-H6WUOW5F.js} +2 -2
  18. package/dist/{chunk-7BHDKEGK.js → chunk-JNRACLNS.js} +3 -3
  19. package/dist/{chunk-IAQFZFWD.js → chunk-JTMSFBCA.js} +231 -24
  20. package/dist/chunk-JTMSFBCA.js.map +1 -0
  21. package/dist/{chunk-EFXVYQGT.js → chunk-MQZNDK5F.js} +39 -40
  22. package/dist/chunk-MQZNDK5F.js.map +1 -0
  23. package/dist/{chunk-QCX66KBM.js → chunk-SN64WNWE.js} +3 -3
  24. package/dist/{chunk-WUSEZFER.js → chunk-U46LYYRA.js} +3 -2
  25. package/dist/{chunk-WUSEZFER.js.map → chunk-U46LYYRA.js.map} +1 -1
  26. package/dist/{chunk-6PGXTLA4.js → chunk-U672FZVC.js} +2 -2
  27. package/dist/{chunk-AIBVAYHS.js → chunk-UE4Z3YMB.js} +2 -2
  28. package/dist/chunk-UE4Z3YMB.js.map +1 -0
  29. package/dist/{chunk-REHVGFJE.js → chunk-XMQIWPIR.js} +84 -32
  30. package/dist/chunk-XMQIWPIR.js.map +1 -0
  31. package/dist/{chunk-I3WF6L43.js → chunk-XYBHH3M5.js} +2 -2
  32. package/dist/{chunk-ECPFYHDX.js → chunk-ZBI6GFJD.js} +11 -11
  33. package/dist/chunk-ZBI6GFJD.js.map +1 -0
  34. package/dist/commands/build/marketplace.js +5 -4
  35. package/dist/commands/build/marketplace.js.map +1 -1
  36. package/dist/commands/build/plugins.js +7 -6
  37. package/dist/commands/build/plugins.js.map +1 -1
  38. package/dist/commands/compile.js +20 -16
  39. package/dist/commands/compile.js.map +1 -1
  40. package/dist/commands/doctor.js +106 -87
  41. package/dist/commands/doctor.js.map +1 -1
  42. package/dist/commands/edit.js +76 -48
  43. package/dist/commands/edit.js.map +1 -1
  44. package/dist/commands/eject.js +31 -18
  45. package/dist/commands/eject.js.map +1 -1
  46. package/dist/commands/init.js +17 -17
  47. package/dist/commands/list.js +10 -9
  48. package/dist/commands/list.js.map +1 -1
  49. package/dist/commands/new/marketplace.js +5 -4
  50. package/dist/commands/new/marketplace.js.map +1 -1
  51. package/dist/commands/search.js +14 -9
  52. package/dist/commands/search.js.map +1 -1
  53. package/dist/commands/share.js +20 -22
  54. package/dist/commands/share.js.map +1 -1
  55. package/dist/commands/uninstall.js +24 -19
  56. package/dist/commands/uninstall.js.map +1 -1
  57. package/dist/commands/update.js +110 -31
  58. package/dist/commands/update.js.map +1 -1
  59. package/dist/components/common/select-list.js +2 -2
  60. package/dist/components/common/skill-agent-summary.js +4 -3
  61. package/dist/components/common/summary-panel.js +5 -4
  62. package/dist/hooks/init.js +24 -25
  63. package/dist/hooks/init.js.map +1 -1
  64. package/dist/load-agent-defs-5BSECHE6.js +14 -0
  65. package/dist/{recompile-project-agents-KYK44C24.js → recompile-project-agents-U3UGHPWG.js} +8 -8
  66. package/dist/{source-loader-G5I4RNUP.js → source-loader-E2Y5MMN5.js} +4 -4
  67. package/package.json +1 -1
  68. package/dist/chunk-3PJZ4QNJ.js.map +0 -1
  69. package/dist/chunk-AIBVAYHS.js.map +0 -1
  70. package/dist/chunk-APWMMZOK.js.map +0 -1
  71. package/dist/chunk-E45IT3HC.js.map +0 -1
  72. package/dist/chunk-ECPFYHDX.js.map +0 -1
  73. package/dist/chunk-EFXVYQGT.js.map +0 -1
  74. package/dist/chunk-FQF6VHO3.js.map +0 -1
  75. package/dist/chunk-H5E6IO2L.js.map +0 -1
  76. package/dist/chunk-IAQFZFWD.js.map +0 -1
  77. package/dist/chunk-ORO2T4K2.js +0 -96
  78. package/dist/chunk-ORO2T4K2.js.map +0 -1
  79. package/dist/chunk-R7GKQBZJ.js.map +0 -1
  80. package/dist/chunk-REHVGFJE.js.map +0 -1
  81. package/dist/load-agent-defs-5U5KAURA.js +0 -14
  82. /package/dist/{chunk-IXVGBUWI.js.map → chunk-EC3JXT23.js.map} +0 -0
  83. /package/dist/{chunk-TVEDNGVP.js.map → chunk-H6WUOW5F.js.map} +0 -0
  84. /package/dist/{chunk-7BHDKEGK.js.map → chunk-JNRACLNS.js.map} +0 -0
  85. /package/dist/{chunk-QCX66KBM.js.map → chunk-SN64WNWE.js.map} +0 -0
  86. /package/dist/{chunk-6PGXTLA4.js.map → chunk-U672FZVC.js.map} +0 -0
  87. /package/dist/{chunk-I3WF6L43.js.map → chunk-XYBHH3M5.js.map} +0 -0
  88. /package/dist/{load-agent-defs-5U5KAURA.js.map → load-agent-defs-5BSECHE6.js.map} +0 -0
  89. /package/dist/{recompile-project-agents-KYK44C24.js.map → recompile-project-agents-U3UGHPWG.js.map} +0 -0
  90. /package/dist/{source-loader-G5I4RNUP.js.map → source-loader-E2Y5MMN5.js.map} +0 -0
@@ -2,20 +2,23 @@
2
2
  import {
3
3
  compileAgents,
4
4
  withCatalogueSeatedFor
5
- } from "./chunk-REHVGFJE.js";
5
+ } from "./chunk-XMQIWPIR.js";
6
6
  import {
7
7
  loadAgentDefs
8
- } from "./chunk-7BHDKEGK.js";
8
+ } from "./chunk-JNRACLNS.js";
9
9
  import {
10
10
  ConfigLoadError,
11
11
  EXTRACTED_FIELDS,
12
12
  GlobalPairWriteViolation,
13
13
  INDENT_STEP,
14
+ agentsDir,
14
15
  assertGateToken,
15
16
  brokenUnionLayout,
16
17
  buildAndMergeConfig,
18
+ declaresNoContent,
17
19
  detectGlobalInstallation,
18
20
  detectInstallation,
21
+ detectInstallations,
19
22
  detectProjectInstallation,
20
23
  disableBuffering,
21
24
  drainBuffer,
@@ -28,6 +31,7 @@ import {
28
31
  getErrorMessage,
29
32
  getInstalledConfigPath,
30
33
  getProjectConfigPath,
34
+ inheritedGlobalProvider,
31
35
  isHomeDirectory,
32
36
  isRecord,
33
37
  loadInstalledConfig,
@@ -39,6 +43,7 @@ import {
39
43
  providerInUse,
40
44
  quoteText,
41
45
  readFile,
46
+ remove,
42
47
  renderKey,
43
48
  renderTypeImportLine,
44
49
  renderUnionBody,
@@ -53,12 +58,12 @@ import {
53
58
  warn,
54
59
  withGateToken,
55
60
  writeFile
56
- } from "./chunk-E45IT3HC.js";
61
+ } from "./chunk-ENET4IF6.js";
57
62
  import {
58
63
  matrix,
59
64
  typedEntries,
60
65
  typedKeys
61
- } from "./chunk-AIBVAYHS.js";
66
+ } from "./chunk-UE4Z3YMB.js";
62
67
  import {
63
68
  CLI_INVOKE_COMMAND,
64
69
  CODEX_MODEL_NAMES,
@@ -66,7 +71,6 @@ import {
66
71
  GLOBAL_CONFIG_NAME,
67
72
  LOCAL_PSEUDO_CATEGORY,
68
73
  MODEL_NAMES,
69
- PROVIDERS,
70
74
  STANDARD_FILES,
71
75
  activeAgentNames,
72
76
  activeProjectAgentNames,
@@ -76,7 +80,7 @@ import {
76
80
  isExclusiveCategory,
77
81
  isGlobalTombstone,
78
82
  skillDomain
79
- } from "./chunk-WUSEZFER.js";
83
+ } from "./chunk-U46LYYRA.js";
80
84
 
81
85
  // src/cli/lib/operations/source/load-source.ts
82
86
  async function loadSource(options) {
@@ -125,7 +129,7 @@ async function detectProject(projectDir) {
125
129
 
126
130
  // src/cli/lib/operations/project/detect-both-installations.ts
127
131
  async function detectBothInstallations(projectDir) {
128
- const global = await detectGlobalInstallation();
132
+ const global = await detectGlobalInstallation(projectDir);
129
133
  const project = isHomeDirectory(projectDir) ? null : await detectProjectInstallation(projectDir);
130
134
  return { global, project, hasBoth: !!global && !!project };
131
135
  }
@@ -672,8 +676,8 @@ function activeEntriesNotIn(incoming, existing, keyOf) {
672
676
  return incoming.filter((entry) => !entry.excluded && !held.has(keyOf(entry)));
673
677
  }
674
678
  function marketplaceIdentityFilledFrom(existing, arriving) {
675
- const marketplaceName = existing.marketplaceName ?? arriving?.marketplaceName;
676
- const marketplace = existing.marketplace ?? arriving?.marketplace;
679
+ const fillsFromArriving = arriving !== null && existing.marketplace === void 0;
680
+ const { marketplace, marketplaceName } = fillsFromArriving ? arriving : existing;
677
681
  return {
678
682
  ...marketplaceName !== void 0 && { marketplaceName },
679
683
  ...marketplace !== void 0 && { marketplace }
@@ -901,9 +905,13 @@ function refuseAWriteOutsideTheInstallation(projectDir, provider) {
901
905
  }
902
906
  return configPath;
903
907
  }
908
+ async function installationToRewrite(projectPath) {
909
+ const loaded = await loadInstalledConfig(projectPath);
910
+ return loaded !== null && !declaresNoContent(loaded.config) ? loaded : null;
911
+ }
904
912
  async function propagateToProject(projectPath, provider, globalConfig, agents, options) {
905
- const existingProject = await loadInstalledConfig(projectPath);
906
- if (!existingProject?.config) return false;
913
+ const existingProject = await installationToRewrite(projectPath);
914
+ if (existingProject === null) return false;
907
915
  return withCatalogueSeatedFor(projectPath, async (catalogue) => {
908
916
  const projectSplit = reconcileAgainstGlobal(existingProject.config, globalConfig, catalogue);
909
917
  await writeProjectConfigPair(
@@ -943,11 +951,12 @@ async function propagateGlobalChangesToProjects(globalConfig, agents, provider,
943
951
  return result;
944
952
  }
945
953
  async function propagateToRegisteredProject(projectPath, provider, globalConfig, agents, options) {
946
- if (!await holdsAnInstallation(projectPath)) {
954
+ const installed = await providersInstalledAt(projectPath);
955
+ if (installed.length === 0) {
947
956
  verbose(`Skipped propagation to ${projectPath} (nothing installed there)`);
948
957
  return "gone";
949
958
  }
950
- const notOurs = await whyThisProjectIsNotOurs(projectPath, provider);
959
+ const notOurs = whyThisProjectIsNotOurs(projectPath, provider, installed);
951
960
  if (notOurs !== null) {
952
961
  verbose(`Skipped propagation to ${projectPath} (${notOurs})`);
953
962
  return "notOurs";
@@ -972,28 +981,26 @@ async function projectsAFanOutReaches(projects, provider) {
972
981
  return reached.flat();
973
982
  }
974
983
  async function wouldBeRewritten(projectPath, provider) {
975
- if (!await holdsAnInstallation(projectPath)) return false;
976
- if (await whyThisProjectIsNotOurs(projectPath, provider) !== null) return false;
984
+ const installed = await providersInstalledAt(projectPath);
985
+ if (whyThisProjectIsNotOurs(projectPath, provider, installed) !== null) return false;
977
986
  try {
978
- return await loadInstalledConfig(projectPath) !== null;
987
+ return await installationToRewrite(projectPath) !== null;
979
988
  } catch {
980
989
  return false;
981
990
  }
982
991
  }
983
- async function holdsAnInstallation(projectPath) {
984
- const configs = await Promise.all(
985
- PROVIDERS.map((installed) => fileExists(getProjectConfigPath(projectPath, installed)))
986
- );
987
- return configs.includes(true);
992
+ async function providersInstalledAt(projectPath) {
993
+ const found = await detectInstallations(projectPath);
994
+ return found.filter((installation) => installation.scope === "project").map((installation) => installation.provider);
988
995
  }
989
- async function whyThisProjectIsNotOurs(projectPath, provider) {
996
+ function whyThisProjectIsNotOurs(projectPath, provider, installed) {
990
997
  const notOurs = `not a ${provider} installation`;
991
998
  try {
992
999
  if (providerInUse(projectPath) !== provider) return notOurs;
993
1000
  } catch (error) {
994
1001
  return getErrorMessage(error);
995
1002
  }
996
- return await fileExists(getProjectConfigPath(projectPath, provider)) ? null : notOurs;
1003
+ return installed.includes(provider) ? null : notOurs;
997
1004
  }
998
1005
  async function pruneGlobalEntriesFromRegisteredProjects(globalConfig, agents, provider) {
999
1006
  const emptiedGlobal = {
@@ -1232,7 +1239,7 @@ var NOTHING_RECOMPILED = {
1232
1239
  };
1233
1240
  async function recompilePropagated(projectDirs, pairsRewritten) {
1234
1241
  if (projectDirs.length === 0) return NOTHING_RECOMPILED;
1235
- const { recompilePropagatedProjectAgents } = await import("./recompile-project-agents-KYK44C24.js");
1242
+ const { recompilePropagatedProjectAgents } = await import("./recompile-project-agents-U3UGHPWG.js");
1236
1243
  return recompilePropagatedProjectAgents(projectDirs, pairsRewritten);
1237
1244
  }
1238
1245
  function pairRewriteSummary(projectDirs, pairsRewritten) {
@@ -1272,6 +1279,21 @@ async function pairsRewrittenSince(before, projectDirs, provider) {
1272
1279
  );
1273
1280
  return new Set(judged.filter(({ rewritten }) => rewritten).map(({ dir }) => dir));
1274
1281
  }
1282
+ async function restoreProjectPairs(before, provider) {
1283
+ await Promise.all([...before].map(([dir, pair]) => restorePair(dir, pair, provider)));
1284
+ }
1285
+ async function restorePair(dir, [config, types], provider) {
1286
+ const configPath = getProjectConfigPath(dir, provider);
1287
+ await Promise.all([
1288
+ restoreHalf(configPath, config),
1289
+ restoreHalf(typesPathFor(configPath), types)
1290
+ ]);
1291
+ }
1292
+ async function restoreHalf(filePath, before) {
1293
+ if (await readHalf(filePath) === before) return;
1294
+ if (before === null) return remove(filePath);
1295
+ if (typeof before === "string") return writeFile(filePath, before);
1296
+ }
1275
1297
  function snapshotOf(before, dir) {
1276
1298
  const pair = before.get(dir);
1277
1299
  if (pair === void 0) throw new Error(`No snapshot of ${dir} was taken before the fan-out`);
@@ -1328,7 +1350,7 @@ async function applyConsequences(globalConfig, changes, deps, provider, currentP
1328
1350
  function lazyGateDeps(projectDir) {
1329
1351
  return {
1330
1352
  loadMatrix: async () => {
1331
- const { loadSkillsMatrixFromSource: loadSkillsMatrixFromSource2 } = await import("./source-loader-G5I4RNUP.js");
1353
+ const { loadSkillsMatrixFromSource: loadSkillsMatrixFromSource2 } = await import("./source-loader-E2Y5MMN5.js");
1332
1354
  const { matrix: matrix2 } = await loadSkillsMatrixFromSource2({
1333
1355
  projectDir,
1334
1356
  skipExtraSources: true,
@@ -1337,7 +1359,7 @@ function lazyGateDeps(projectDir) {
1337
1359
  return matrix2;
1338
1360
  },
1339
1361
  loadAgents: async () => {
1340
- const { loadAgentDefs: loadAgentDefs2 } = await import("./load-agent-defs-5U5KAURA.js");
1362
+ const { loadAgentDefs: loadAgentDefs2 } = await import("./load-agent-defs-5BSECHE6.js");
1341
1363
  return (await loadAgentDefs2()).agents;
1342
1364
  }
1343
1365
  };
@@ -1355,11 +1377,10 @@ async function writeFromHome(args, homeDir, deps) {
1355
1377
  const provider = providerInUse(homeDir);
1356
1378
  const priorGlobal = await loadProjectConfigFromDir(homeDir, provider);
1357
1379
  const changes = classifyGlobalChange(priorGlobal?.config, finalConfig);
1358
- const globalWritten = await writeGlobalPair(
1359
- finalConfig,
1360
- projectConfigPath,
1361
- deps.matrix,
1362
- deps.agents
1380
+ const globalWritten = await restoringThePairsOnFailure(
1381
+ [homeDir],
1382
+ provider,
1383
+ () => writeGlobalPair(finalConfig, projectConfigPath, deps.matrix, deps.agents)
1363
1384
  );
1364
1385
  const { propagated, recompile } = await applyConsequences(finalConfig, changes, deps, provider);
1365
1386
  return report(globalWritten, changes, propagated, recompile);
@@ -1369,6 +1390,7 @@ async function writeFromProjectContext(args, homeDir, deps) {
1369
1390
  const { global: globalConfig, project: projectSplitConfig } = splitConfigByScope(finalConfig);
1370
1391
  const provider = providerInUse(projectDir);
1371
1392
  const globalConfigPath = getProjectConfigPath(homeDir, provider);
1393
+ await ensureBlankPair(provider);
1372
1394
  const existingGlobal = await loadProjectConfigFromDir(homeDir, provider);
1373
1395
  const effective = await resolveEffectiveGlobalConfig(
1374
1396
  globalConfig,
@@ -1378,28 +1400,45 @@ async function writeFromProjectContext(args, homeDir, deps) {
1378
1400
  );
1379
1401
  const effectiveGlobalConfig = effective.config;
1380
1402
  const changes = classifyGlobalChange(existingGlobal?.config, effectiveGlobalConfig);
1381
- const globalWritten = await writeGlobalPairWhenChanged(effective, globalConfigPath, deps);
1382
- const { propagated, recompile } = await applyConsequences(
1383
- effectiveGlobalConfig,
1384
- changes,
1385
- deps,
1386
- provider,
1387
- projectDir
1388
- );
1389
1403
  const reconciledProjectConfig = reconcileProjectSplitAgainstGlobal(
1390
1404
  projectSplitConfig,
1391
1405
  effectiveGlobalConfig,
1392
1406
  deps.matrix
1393
1407
  );
1394
- await writeProjectPairWhenOwed(
1395
- args,
1408
+ const globalWritten = await restoringThePairsOnFailure(
1409
+ [projectDir, homeDir],
1396
1410
  provider,
1397
- reconciledProjectConfig,
1411
+ async () => {
1412
+ await writeProjectPairWhenOwed(
1413
+ args,
1414
+ provider,
1415
+ reconciledProjectConfig,
1416
+ effectiveGlobalConfig,
1417
+ deps
1418
+ );
1419
+ return writeGlobalPairWhenChanged(effective, globalConfigPath, deps);
1420
+ }
1421
+ );
1422
+ const { propagated, recompile } = await applyConsequences(
1398
1423
  effectiveGlobalConfig,
1399
- deps
1424
+ changes,
1425
+ deps,
1426
+ provider,
1427
+ projectDir
1400
1428
  );
1401
1429
  return report(globalWritten, changes, propagated, recompile);
1402
1430
  }
1431
+ async function restoringThePairsOnFailure(dirs, provider, write) {
1432
+ const before = await snapshotProjectPairs(dirs, provider);
1433
+ try {
1434
+ return await write();
1435
+ } catch (error) {
1436
+ await restoreProjectPairs(before, provider).catch((restoreError) => {
1437
+ verbose(`Could not restore a config pair: ${getErrorMessage(restoreError)}`);
1438
+ });
1439
+ throw error;
1440
+ }
1441
+ }
1403
1442
  async function writeGlobalPairWhenChanged(effective, globalConfigPath, deps) {
1404
1443
  if (!effective.changed) {
1405
1444
  verbose("Global config unchanged, skipping write");
@@ -1581,9 +1620,6 @@ async function writeProjectConfig(options) {
1581
1620
  );
1582
1621
  const finalConfig = mergeResult.config;
1583
1622
  const isProjectContext = !isHomeDirectory(projectDir);
1584
- if (isProjectContext) {
1585
- await ensureBlankPair2(providerInUse(projectDir));
1586
- }
1587
1623
  const propagation = await writeConfigByScope({
1588
1624
  finalConfig,
1589
1625
  matrix: sourceResult.matrix,
@@ -1619,14 +1655,22 @@ async function compileAgentsAllScopes(options) {
1619
1655
  outputDir: resolveInstallPaths(projectDir, "project").agentsDir
1620
1656
  });
1621
1657
  }
1622
- const globalResult = await compileAgents({
1623
- ...base,
1658
+ const globalResult = await compileGlobalScope(options);
1659
+ const projectResult = await compileProjectScope(options);
1660
+ return mergeCompilationResults(globalResult, projectResult);
1661
+ }
1662
+ async function compileGlobalScope(options) {
1663
+ const { projectDir, sourcePath, skills, agentScopeMap } = options;
1664
+ const provider = inheritedGlobalProvider(projectDir);
1665
+ return compileAgents({
1666
+ sourcePath,
1667
+ skills,
1668
+ agentScopeMap,
1624
1669
  projectDir: os3.homedir(),
1625
- outputDir: resolveInstallPaths(os3.homedir(), "global").agentsDir,
1670
+ provider,
1671
+ outputDir: agentsDir(provider, "global", projectDir),
1626
1672
  scopeFilter: "global"
1627
1673
  });
1628
- const projectResult = await compileProjectScope(options);
1629
- return mergeCompilationResults(globalResult, projectResult);
1630
1674
  }
1631
1675
  async function compileProjectScope(options) {
1632
1676
  const { projectDir, sourcePath, skills, agentScopeMap } = options;
@@ -1665,4 +1709,4 @@ export {
1665
1709
  compileAgentsAllScopes,
1666
1710
  compileProjectScope
1667
1711
  };
1668
- //# sourceMappingURL=chunk-R7GKQBZJ.js.map
1712
+ //# sourceMappingURL=chunk-CKBWEWHZ.js.map