agents-inc 0.176.0 → 0.177.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 (104) hide show
  1. package/CHANGELOG.md +65 -0
  2. package/README.md +2 -2
  3. package/dist/{chunk-FACDJH6O.js → chunk-2FE4AJNC.js} +20 -26
  4. package/dist/chunk-2FE4AJNC.js.map +1 -0
  5. package/dist/{chunk-U46LYYRA.js → chunk-4SIBDIIO.js} +49 -13
  6. package/dist/chunk-4SIBDIIO.js.map +1 -0
  7. package/dist/chunk-5ZK4IND4.js +30 -0
  8. package/dist/chunk-5ZK4IND4.js.map +1 -0
  9. package/dist/{chunk-MQZNDK5F.js → chunk-77SHXTDD.js} +137 -56
  10. package/dist/chunk-77SHXTDD.js.map +1 -0
  11. package/dist/{chunk-U672FZVC.js → chunk-7OJ2SS4E.js} +10 -86
  12. package/dist/chunk-7OJ2SS4E.js.map +1 -0
  13. package/dist/{chunk-C2BSCEDN.js → chunk-7WN6TUZP.js} +7 -8
  14. package/dist/chunk-7WN6TUZP.js.map +1 -0
  15. package/dist/chunk-AVKX3IXF.js +117 -0
  16. package/dist/chunk-AVKX3IXF.js.map +1 -0
  17. package/dist/{chunk-ENET4IF6.js → chunk-D2PC7NIR.js} +1653 -1734
  18. package/dist/chunk-D2PC7NIR.js.map +1 -0
  19. package/dist/{chunk-JTMSFBCA.js → chunk-E6W3PYGF.js} +823 -72
  20. package/dist/chunk-E6W3PYGF.js.map +1 -0
  21. package/dist/chunk-H33ZAEKH.js +147 -0
  22. package/dist/chunk-H33ZAEKH.js.map +1 -0
  23. package/dist/{chunk-B7AVWSK2.js → chunk-JEFVFZAR.js} +39 -151
  24. package/dist/chunk-JEFVFZAR.js.map +1 -0
  25. package/dist/{chunk-UE4Z3YMB.js → chunk-KKGJH46C.js} +3 -21
  26. package/dist/chunk-KKGJH46C.js.map +1 -0
  27. package/dist/chunk-OIQKRXHH.js +142 -0
  28. package/dist/chunk-OIQKRXHH.js.map +1 -0
  29. package/dist/{chunk-CKBWEWHZ.js → chunk-TNN72UL6.js} +264 -247
  30. package/dist/chunk-TNN72UL6.js.map +1 -0
  31. package/dist/{chunk-XMQIWPIR.js → chunk-V3WJMNBF.js} +45 -18
  32. package/dist/chunk-V3WJMNBF.js.map +1 -0
  33. package/dist/chunk-VFD2XYM7.js +14 -0
  34. package/dist/chunk-VFD2XYM7.js.map +1 -0
  35. package/dist/{chunk-XYBHH3M5.js → chunk-WH7JXGDA.js} +2 -2
  36. package/dist/{chunk-JNRACLNS.js → chunk-XSR4WRXJ.js} +3 -3
  37. package/dist/{chunk-3F5LT433.js → chunk-Y5VMB73R.js} +202 -116
  38. package/dist/chunk-Y5VMB73R.js.map +1 -0
  39. package/dist/chunk-ZIBWVTLN.js +18 -0
  40. package/dist/chunk-ZIBWVTLN.js.map +1 -0
  41. package/dist/commands/build/marketplace.js +6 -10
  42. package/dist/commands/build/marketplace.js.map +1 -1
  43. package/dist/commands/build/plugins.js +10 -39
  44. package/dist/commands/build/plugins.js.map +1 -1
  45. package/dist/commands/compile.js +60 -81
  46. package/dist/commands/compile.js.map +1 -1
  47. package/dist/commands/doctor.js +234 -145
  48. package/dist/commands/doctor.js.map +1 -1
  49. package/dist/commands/edit.js +64 -159
  50. package/dist/commands/edit.js.map +1 -1
  51. package/dist/commands/eject.js +64 -54
  52. package/dist/commands/eject.js.map +1 -1
  53. package/dist/commands/init.js +19 -17
  54. package/dist/commands/list.js +10 -12
  55. package/dist/commands/list.js.map +1 -1
  56. package/dist/commands/new/marketplace.js +5 -5
  57. package/dist/commands/search.js +14 -13
  58. package/dist/commands/search.js.map +1 -1
  59. package/dist/commands/share.js +21 -44
  60. package/dist/commands/share.js.map +1 -1
  61. package/dist/commands/uninstall.js +139 -56
  62. package/dist/commands/uninstall.js.map +1 -1
  63. package/dist/commands/update.js +22 -37
  64. package/dist/commands/update.js.map +1 -1
  65. package/dist/components/common/header-row.js +9 -0
  66. package/dist/components/common/select-list.js +2 -2
  67. package/dist/components/common/skill-agent-summary.js +4 -4
  68. package/dist/components/common/summary-panel.js +6 -5
  69. package/dist/hooks/init.js +35 -22
  70. package/dist/hooks/init.js.map +1 -1
  71. package/dist/load-agent-defs-OCFWOZD2.js +14 -0
  72. package/dist/{recompile-project-agents-U3UGHPWG.js → recompile-project-agents-CXZBPIUS.js} +9 -9
  73. package/dist/{recompile-project-agents-U3UGHPWG.js.map → recompile-project-agents-CXZBPIUS.js.map} +1 -1
  74. package/dist/{source-loader-E2Y5MMN5.js → source-loader-GGDQDMN4.js} +6 -4
  75. package/dist/source-loader-GGDQDMN4.js.map +1 -0
  76. package/package.json +1 -1
  77. package/src/schemas/stacks.schema.json +105 -1
  78. package/dist/chunk-3F5LT433.js.map +0 -1
  79. package/dist/chunk-5CFHP6Z5.js +0 -109
  80. package/dist/chunk-5CFHP6Z5.js.map +0 -1
  81. package/dist/chunk-B7AVWSK2.js.map +0 -1
  82. package/dist/chunk-C2BSCEDN.js.map +0 -1
  83. package/dist/chunk-CKBWEWHZ.js.map +0 -1
  84. package/dist/chunk-EC3JXT23.js +0 -160
  85. package/dist/chunk-EC3JXT23.js.map +0 -1
  86. package/dist/chunk-ENET4IF6.js.map +0 -1
  87. package/dist/chunk-FACDJH6O.js.map +0 -1
  88. package/dist/chunk-H6WUOW5F.js +0 -35
  89. package/dist/chunk-H6WUOW5F.js.map +0 -1
  90. package/dist/chunk-JTMSFBCA.js.map +0 -1
  91. package/dist/chunk-MQZNDK5F.js.map +0 -1
  92. package/dist/chunk-SN64WNWE.js +0 -428
  93. package/dist/chunk-SN64WNWE.js.map +0 -1
  94. package/dist/chunk-U46LYYRA.js.map +0 -1
  95. package/dist/chunk-U672FZVC.js.map +0 -1
  96. package/dist/chunk-UE4Z3YMB.js.map +0 -1
  97. package/dist/chunk-XMQIWPIR.js.map +0 -1
  98. package/dist/chunk-ZBI6GFJD.js +0 -39
  99. package/dist/chunk-ZBI6GFJD.js.map +0 -1
  100. package/dist/load-agent-defs-5BSECHE6.js +0 -14
  101. /package/dist/{chunk-XYBHH3M5.js.map → chunk-WH7JXGDA.js.map} +0 -0
  102. /package/dist/{chunk-JNRACLNS.js.map → chunk-XSR4WRXJ.js.map} +0 -0
  103. /package/dist/{load-agent-defs-5BSECHE6.js.map → components/common/header-row.js.map} +0 -0
  104. /package/dist/{source-loader-E2Y5MMN5.js.map → load-agent-defs-OCFWOZD2.js.map} +0 -0
@@ -1,24 +1,30 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  namedByActiveEntries
4
- } from "./chunk-FACDJH6O.js";
4
+ } from "./chunk-2FE4AJNC.js";
5
5
  import {
6
+ CATALOGUE_SKILL_IDS,
6
7
  ConfigLoadError,
7
8
  FailedLeavingPluginsSwitchedOnError,
8
9
  INFO_MESSAGES,
9
10
  PluginsLeftSwitchedOnError,
10
11
  STATUS_MESSAGES,
11
12
  addedToGlobalSubAgents,
13
+ appliedBackDestinations,
14
+ applySharedConfigHere,
12
15
  buildMarketplacePluginRef,
16
+ carriedSkillsWritten,
13
17
  chooseProviderForThisRun,
14
18
  claimSlug,
15
19
  codexPluginLeftSwitchedOn,
16
20
  completedWithFailures,
17
21
  configDeclaresNothing,
22
+ configsInPlay,
18
23
  copy,
19
24
  defaultUsageGuidance,
20
25
  detectInstallations,
21
26
  directoryExists,
27
+ execCommand,
22
28
  fetchMarketplace,
23
29
  fileExists,
24
30
  findConfigLoadFailures,
@@ -28,15 +34,20 @@ import {
28
34
  getStackSkillIds,
29
35
  glob,
30
36
  holdsAConfigDeclaringNothing,
37
+ holdsItsOwnInstallation,
31
38
  hostAt,
39
+ hostFor,
32
40
  installationConfigsUnreadable,
33
41
  isHomeDirectory,
42
+ isKeyedRecord,
34
43
  isLocalOnlySkill,
44
+ keptAsInstalledGlobally,
35
45
  loadProjectConfigFromDir,
36
46
  loadStackById,
37
47
  parseFrontmatter,
48
+ parseJsonOrUndefined,
49
+ pluginNotSwitchedBackOff,
38
50
  pluginsInstalled,
39
- pluginsLeftSwitchedOn,
40
51
  propagatedRecompileSummary,
41
52
  providerInUse,
42
53
  providerToNameAt,
@@ -54,26 +65,27 @@ import {
54
65
  resolveInstallPaths,
55
66
  savedSkillMetadataUnusableError,
56
67
  scopeBlockedStackAssignment,
68
+ seedToInstallSelection,
69
+ sharedConfigDestinations,
57
70
  sharedConfigProjectScopeAtHome,
58
71
  skillAssignedToNoAgent,
59
72
  skillMetadataUnusableDetail,
60
73
  skippedSkills,
61
74
  skippedUnknownAgents,
75
+ switchItOffIn,
62
76
  validateSkillPath,
63
77
  verbose,
64
78
  warn,
65
79
  writeFile
66
- } from "./chunk-ENET4IF6.js";
80
+ } from "./chunk-D2PC7NIR.js";
67
81
  import {
68
- BUILT_IN_MATRIX,
69
82
  getCategoryDomain,
70
83
  inertLine,
71
84
  matrix,
85
+ plural,
72
86
  stripTerminalControls,
73
- typedEntries,
74
- typedKeys,
75
- typedValues
76
- } from "./chunk-UE4Z3YMB.js";
87
+ truncateText
88
+ } from "./chunk-KKGJH46C.js";
77
89
  import {
78
90
  CLI_COLORS,
79
91
  CLI_INVOKE_COMMAND,
@@ -85,12 +97,17 @@ import {
85
97
  LOCAL_SKILLS_PATH,
86
98
  MIN_TERMINAL_SIZE,
87
99
  PROVIDERS,
100
+ SEED_API_URL,
88
101
  STANDARD_FILES,
89
102
  externalIdsNamingNoDirectory,
90
103
  isActiveAt,
104
+ isExclusiveCategory,
91
105
  orderDomains,
92
- seedExternalSkillSchema
93
- } from "./chunk-U46LYYRA.js";
106
+ seedExternalSkillSchema,
107
+ seedPayloadSchema,
108
+ typedEntries,
109
+ typedValues
110
+ } from "./chunk-4SIBDIIO.js";
94
111
 
95
112
  // src/cli/utils/terminal.ts
96
113
  function clearTerminalScreen() {
@@ -112,8 +129,8 @@ var EXIT_CODES = {
112
129
  NETWORK_ERROR: 3,
113
130
  CANCELLED: 4,
114
131
  /**
115
- * Ran to the end but part of the work failed. Unlike ERROR the work landed, so repeating the run
116
- * is wrong; the output names the remedy. Raised at the end of a command, never mid-flight.
132
+ * Ran to the end but part of the work failed. The rest landed, so repeating the run is wrong;
133
+ * the output names the remedy. Raised at the end of a command, never mid-flight.
117
134
  */
118
135
  COMPLETED_WITH_FAILURES: 5
119
136
  };
@@ -315,7 +332,7 @@ function shippedMetadata(files) {
315
332
  const shipped = files[STANDARD_FILES.METADATA_YAML];
316
333
  if (shipped === void 0) return null;
317
334
  const parsed = parsedYaml(shipped);
318
- return isMapping(parsed) && hasReadableProvenance(parsed) ? parsed : null;
335
+ return isKeyedRecord(parsed) && hasReadableProvenance(parsed) ? parsed : null;
319
336
  }
320
337
  function parsedYaml(text) {
321
338
  try {
@@ -324,13 +341,12 @@ function parsedYaml(text) {
324
341
  return void 0;
325
342
  }
326
343
  }
327
- var isMapping = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
328
344
  var PROVENANCE_REQUIRED = ["skillId", "contentHash", "date"];
329
345
  var PROVENANCE_OPTIONAL = ["source", "path"];
330
346
  function hasReadableProvenance(metadata) {
331
347
  if (!Object.hasOwn(metadata, "forkedFrom")) return true;
332
348
  const provenance = metadata.forkedFrom;
333
- return isMapping(provenance) && PROVENANCE_REQUIRED.every((key) => typeof provenance[key] === "string") && PROVENANCE_OPTIONAL.every(
349
+ return isKeyedRecord(provenance) && PROVENANCE_REQUIRED.every((key) => typeof provenance[key] === "string") && PROVENANCE_OPTIONAL.every(
334
350
  (key) => !Object.hasOwn(provenance, key) || typeof provenance[key] === "string"
335
351
  );
336
352
  }
@@ -355,10 +371,17 @@ var hexOf = (bytes) => Array.from(bytes, (byte) => byte.toString(16).padStart(2,
355
371
 
356
372
  // src/cli/lib/seed/external-skills.ts
357
373
  function pluginInstallError(ids) {
374
+ const [refused, reshared] = ids.length === 1 ? [
375
+ "this skill travels inside it, so no marketplace serves it and it cannot be installed as a plugin",
376
+ "the skill above"
377
+ ] : [
378
+ "these skills travel inside it, so no marketplace serves them and they cannot be installed as plugins",
379
+ "each skill above"
380
+ ];
358
381
  return [
359
- "This configuration cannot be installed: these skills travel inside it, so no marketplace serves them and they cannot be installed as plugins:",
382
+ `This configuration cannot be installed: ${refused}:`,
360
383
  ...ids.map((id) => ` ${id}`),
361
- "Re-share it with each skill above set to eject, which is the only way a carried skill installs."
384
+ `Re-share it with ${reshared} set to eject, which is the only way a carried skill installs.`
362
385
  ].join("\n");
363
386
  }
364
387
  function selectedExternals(payload) {
@@ -373,7 +396,6 @@ function askedForAsPlugin(externals) {
373
396
  function claimingACatalogueId(externals, matrix2) {
374
397
  return externals.filter(({ id }) => heldByEitherCatalogue(id, matrix2)).map(({ id }) => id);
375
398
  }
376
- var CATALOGUE_SKILL_IDS = new Set(typedKeys(BUILT_IN_MATRIX.skills));
377
399
  function heldByEitherCatalogue(id, matrix2) {
378
400
  return heldByLoadedCatalogue(matrix2.skills[id]) || CATALOGUE_SKILL_IDS.has(id);
379
401
  }
@@ -381,10 +403,19 @@ function heldByLoadedCatalogue(incumbent) {
381
403
  return incumbent !== void 0 && incumbent.local !== true;
382
404
  }
383
405
  function catalogueIdCollisionError(ids) {
406
+ const [refused, overwritten, reshared] = ids.length === 1 ? [
407
+ "this skill travels inside it under an id a catalogue already owns",
408
+ "it",
409
+ "the skill above"
410
+ ] : [
411
+ "these skills travel inside it under ids a catalogue already owns",
412
+ "each",
413
+ "each skill above"
414
+ ];
384
415
  return [
385
- "This configuration cannot be installed: these skills travel inside it under ids a catalogue already owns:",
416
+ `This configuration cannot be installed: ${refused}:`,
386
417
  ...ids.map((id) => ` ${id}`),
387
- "A skill id is the directory the skill installs into, so each would be written over the catalogue's own copy of that skill. Re-share it with each skill above added again, which mints an id \u2014 'external-<category>-<name>' \u2014 that no catalogue owns."
418
+ `A skill id is the directory the skill installs into, so ${overwritten} would be written over the catalogue's own copy of that skill. Re-share it with ${reshared} added again, which mints an id \u2014 'external-<category>-<name>' \u2014 that no catalogue owns.`
388
419
  ].join("\n");
389
420
  }
390
421
  function externalSlug(id) {
@@ -427,10 +458,17 @@ function seatExternalSkill({ id, skill, entry }, matrix2, projectDir) {
427
458
  return [install];
428
459
  }
429
460
  function notADirectoryNameError(ids) {
461
+ const [refused, reshared] = ids.length === 1 ? [
462
+ "this skill travels inside it under an id that is not a single directory name",
463
+ "the skill above"
464
+ ] : [
465
+ "these skills travel inside it under ids that are not a single directory name",
466
+ "each skill above"
467
+ ];
430
468
  return [
431
- "This configuration cannot be installed: these skills travel inside it under ids that are not a single directory name:",
469
+ `This configuration cannot be installed: ${refused}:`,
432
470
  ...ids.map((id) => ` ${JSON.stringify(id)}`),
433
- "A skill id is the directory the skill is written into, so an id holding a path separator, or naming '.' or '..', would be written somewhere other than a directory of its own, and one holding a control character would hand it to the terminal wherever that directory is named. Re-share it with each skill above added again, which mints an id \u2014 'external-<category>-<name>' \u2014 that names one directory."
471
+ `A skill id is the directory the skill is written into, so an id holding a path separator, or naming '.' or '..', would be written somewhere other than a directory of its own, and one holding a control character would hand it to the terminal wherever that directory is named. Re-share it with ${reshared} added again, which mints an id \u2014 'external-<category>-<name>' \u2014 that names one directory.`
434
472
  ].join("\n");
435
473
  }
436
474
  var DIRECTORY_NAME_MAX_BYTES = 255;
@@ -441,10 +479,19 @@ function externalIdsTooLongForADirectory(payload) {
441
479
  return Object.keys(payload.external ?? {}).filter(overrunsADirectoryName);
442
480
  }
443
481
  function tooLongForADirectoryError(ids) {
482
+ const [refused, unwritten, reshared] = ids.length === 1 ? [
483
+ "this skill travels inside it under an id longer than a directory name may be",
484
+ "it could not be written",
485
+ "the skill above"
486
+ ] : [
487
+ "these skills travel inside it under ids longer than a directory name may be",
488
+ "none of these could be written",
489
+ "each skill above"
490
+ ];
444
491
  return [
445
- "This configuration cannot be installed: these skills travel inside it under ids longer than a directory name may be:",
492
+ `This configuration cannot be installed: ${refused}:`,
446
493
  ...ids.map((id) => ` ${JSON.stringify(id)}`),
447
- `A skill id is the directory the skill is written into, and a directory name may hold at most ${String(DIRECTORY_NAME_MAX_BYTES)} bytes, so none of these could be written. Re-share it without each skill above.`
494
+ `A skill id is the directory the skill is written into, and a directory name may hold at most ${String(DIRECTORY_NAME_MAX_BYTES)} bytes, so ${unwritten}. Re-share it without ${reshared}.`
448
495
  ].join("\n");
449
496
  }
450
497
  var CARRIED_ID_PREFIX = "external-";
@@ -452,10 +499,17 @@ function externalIdsLackingThePrefix(payload) {
452
499
  return Object.keys(payload.external ?? {}).filter((id) => !id.startsWith(CARRIED_ID_PREFIX));
453
500
  }
454
501
  function lacksThePrefixError(ids) {
502
+ const [refused, reshared] = ids.length === 1 ? [
503
+ "this skill travels inside it under an id that does not start with 'external-'",
504
+ "the skill above"
505
+ ] : [
506
+ "these skills travel inside it under ids that do not start with 'external-'",
507
+ "each skill above"
508
+ ];
455
509
  return [
456
- "This configuration cannot be installed: these skills travel inside it under ids that do not start with 'external-':",
510
+ `This configuration cannot be installed: ${refused}:`,
457
511
  ...ids.map((id) => ` ${id}`),
458
- "A skill id is the directory the skill installs into, and no marketplace may publish under the name 'external', so an id starting 'external-' is the only kind that can never take the place of a marketplace's skill. Re-share it with each skill above added again, which mints such an id \u2014 'external-<category>-<name>'."
512
+ `A skill id is the directory the skill installs into, and no marketplace may publish under the name 'external', so an id starting 'external-' is the only kind that can never take the place of a marketplace's skill. Re-share it with ${reshared} added again, which mints such an id \u2014 'external-<category>-<name>'.`
459
513
  ].join("\n");
460
514
  }
461
515
  function registerExternalSkills(payload, matrix2, projectDir) {
@@ -521,8 +575,10 @@ async function treeToWrite(install) {
521
575
  async function treeAsInstalled(install, shipped) {
522
576
  const recorded = (await readForkedFromMetadata(install.skillDir))?.date;
523
577
  if (recorded === void 0) return null;
524
- const tree = await carriedTree(install, shipped, recorded);
525
- const onDisk = await bytesOnDisk(path.join(install.skillDir, STANDARD_FILES.METADATA_YAML));
578
+ const [tree, onDisk] = await Promise.all([
579
+ carriedTree(install, shipped, recorded),
580
+ metadataOnDisk(install)
581
+ ]);
526
582
  return tree[STANDARD_FILES.METADATA_YAML] === onDisk ? tree : null;
527
583
  }
528
584
  function carriedTree(install, skill, date) {
@@ -536,13 +592,16 @@ function carriedTree(install, skill, date) {
536
592
  }
537
593
  async function withShippedMetadata(install) {
538
594
  if (Object.hasOwn(install.skill.files, STANDARD_FILES.METADATA_YAML)) return install.skill;
539
- const onDisk = await bytesOnDisk(path.join(install.skillDir, STANDARD_FILES.METADATA_YAML));
595
+ const onDisk = await metadataOnDisk(install);
540
596
  if (onDisk === null) return install.skill;
541
597
  return {
542
598
  ...install.skill,
543
599
  files: { ...install.skill.files, [STANDARD_FILES.METADATA_YAML]: onDisk }
544
600
  };
545
601
  }
602
+ function metadataOnDisk(install) {
603
+ return bytesOnDisk(path.join(install.skillDir, STANDARD_FILES.METADATA_YAML));
604
+ }
546
605
  async function bytesOnDisk(filePath) {
547
606
  return await fileExists(filePath) ? readFile(filePath) : null;
548
607
  }
@@ -563,10 +622,21 @@ async function judgeDestination(install) {
563
622
  return { id, skillDir };
564
623
  }
565
624
  function uncarriedDestinationError(blocked) {
625
+ const [refused, overwritten, moved, reshared] = blocked.length === 1 ? [
626
+ "this skill travels inside it under an id this installation already keeps a skill directory for, and no shared configuration put that directory there",
627
+ "it",
628
+ "the directory above",
629
+ "the skill"
630
+ ] : [
631
+ "these skills travel inside it under ids this installation already keeps a skill directory for, and no shared configuration put those directories there",
632
+ "each",
633
+ "each directory above",
634
+ "each skill"
635
+ ];
566
636
  return [
567
- "This configuration cannot be installed: these skills travel inside it under ids this installation already keeps a skill directory for, and no shared configuration put those directories there:",
637
+ `This configuration cannot be installed: ${refused}:`,
568
638
  ...blocked.map(({ id, skillDir }) => ` ${id} -> ${skillDir}`),
569
- "A skill id is the directory the skill installs into, so each would be written over a skill written here by hand or ejected from a marketplace. Move or rename the directory above, or re-share the configuration with each skill added again, which mints an id \u2014 'external-<category>-<name>' \u2014 that nothing here holds."
639
+ `A skill id is the directory the skill installs into, so ${overwritten} would be written over a skill written here by hand or ejected from a marketplace. Move or rename ${moved}, or re-share the configuration with ${reshared} added again, which mints an id \u2014 'external-<category>-<name>' \u2014 that nothing here holds.`
570
640
  ].join("\n");
571
641
  }
572
642
  function unnameableRepoMessage(id) {
@@ -633,10 +703,6 @@ async function readCarriedSkills(owned) {
633
703
  // src/cli/lib/seed/seed-apply.ts
634
704
  import os3 from "os";
635
705
  import { isDeepEqual, omit, partition, pick } from "remeda";
636
- var NOTHING_KEPT = {
637
- authoredSkillIds: [],
638
- unplaceableSkillIds: []
639
- };
640
706
  function reconcileSharedConfig(options) {
641
707
  const { decoded, installed } = options;
642
708
  if (!installed) return nothingToReconcile(decoded);
@@ -646,7 +712,11 @@ function reconcileSharedConfig(options) {
646
712
  return { result, kept: describeKept(options, keptSkills), unassigned };
647
713
  }
648
714
  function nothingToReconcile(decoded) {
649
- return { result: decoded, kept: NOTHING_KEPT, unassigned: [] };
715
+ return {
716
+ result: decoded,
717
+ kept: { authoredSkillIds: [], unplaceableSkillIds: [] },
718
+ unassigned: []
719
+ };
650
720
  }
651
721
  function skillsToKeep(options, installed) {
652
722
  const named = new Set(options.decoded.skills.map((skill) => skill.id));
@@ -711,16 +781,14 @@ async function readInstalledGlobal(projectDir) {
711
781
  const loaded = await loadProjectConfigFromDir(os3.homedir(), providerInUse(projectDir));
712
782
  return loaded?.config ?? null;
713
783
  }
714
- var NO_GLOBAL_ENTRIES = { skillIds: [], agentNames: [] };
784
+ function runFromHomeFor(decoded, id, projectDir) {
785
+ return {
786
+ id: installsAtHome(decoded) ? id : void 0,
787
+ provider: providerToNameAt(os3.homedir(), providerInUse(projectDir))
788
+ };
789
+ }
715
790
  function holdInstalledGlobal(decoded, installed) {
716
- if (!installed) {
717
- return {
718
- result: decoded,
719
- installed: NO_GLOBAL_ENTRIES,
720
- keptAsInstalled: NO_GLOBAL_ENTRIES,
721
- joined: []
722
- };
723
- }
791
+ if (!installed) return nothingHeld(decoded);
724
792
  const heldSkills = activeGlobalById(installed.skills, (skill) => skill.id);
725
793
  const heldAgents = activeGlobalById(installed.agents, (agent) => agent.name);
726
794
  const skills = pairWithHeld(decoded.skills, heldSkills, (skill) => skill.id);
@@ -750,6 +818,14 @@ function holdInstalledGlobal(decoded, installed) {
750
818
  joined
751
819
  };
752
820
  }
821
+ function nothingHeld(decoded) {
822
+ return {
823
+ result: decoded,
824
+ installed: { skillIds: [], agentNames: [] },
825
+ keptAsInstalled: { skillIds: [], agentNames: [] },
826
+ joined: []
827
+ };
828
+ }
753
829
  function skillsKeptAsInstalled(pairs) {
754
830
  return pairs.filter((pair) => !restatesSkill(pair)).map(({ named }) => named.id);
755
831
  }
@@ -833,9 +909,8 @@ function rowIds(agentStack) {
833
909
  );
834
910
  }
835
911
  function filledExclusiveCategories(agentStack) {
836
- const isExclusive = (category) => matrix.categories[category]?.exclusive === true;
837
912
  return new Set(
838
- typedEntries(agentStack ?? {}).filter(([category, rows]) => rows.length > 0 && isExclusive(category)).map(([category]) => category)
913
+ typedEntries(agentStack ?? {}).filter(([category, rows]) => rows.length > 0 && isExclusiveCategory(matrix, category)).map(([category]) => category)
839
914
  );
840
915
  }
841
916
  function withAppendedRows(stack, agentName, added) {
@@ -893,6 +968,20 @@ function joinedStatement(held) {
893
968
  if (held.joined.length === 0) return [];
894
969
  return [addedToGlobalSubAgents(held.joined, panelRowEntries(held))];
895
970
  }
971
+ function keptAsInstalledStatement(held, revisedCarried, runFromHome) {
972
+ const skillIds = [...held.keptAsInstalled.skillIds, ...revisedCarried];
973
+ const { agentNames } = held.keptAsInstalled;
974
+ if (skillIds.length === 0 && agentNames.length === 0) return [];
975
+ return [
976
+ keptAsInstalledGlobally(
977
+ skillIds,
978
+ agentNames,
979
+ runFromHome.id,
980
+ runFromHome.provider,
981
+ panelRowEntries(held)
982
+ )
983
+ ];
984
+ }
896
985
  function projectScopedContent(result) {
897
986
  return entriesActiveAt(result.skills, result.agentConfigs, "project");
898
987
  }
@@ -906,6 +995,573 @@ import { Command } from "@oclif/core";
906
995
  import chalk from "chalk";
907
996
  import { unique } from "remeda";
908
997
 
998
+ // src/cli/utils/open-url.ts
999
+ function browserOpenerCommand(platform, url) {
1000
+ if (platform === "darwin") return { command: "open", args: [url] };
1001
+ if (platform === "win32") return { command: "cmd", args: ["/c", "start", "", url] };
1002
+ return { command: "xdg-open", args: [url] };
1003
+ }
1004
+ function openerRefusedMessage(command, exitCode) {
1005
+ return `Could not open your browser \u2014 '${command}' exited ${exitCode}.`;
1006
+ }
1007
+ function openerUnavailableMessage(command, reason) {
1008
+ return `Could not open your browser \u2014 '${command}' could not be run: ${reason}`;
1009
+ }
1010
+ async function openUrl(url) {
1011
+ const { command, args } = browserOpenerCommand(process.platform, url);
1012
+ try {
1013
+ const result = await execCommand(command, args);
1014
+ if (result.exitCode !== 0) {
1015
+ return { ok: false, error: openerRefusedMessage(command, result.exitCode) };
1016
+ }
1017
+ return { ok: true };
1018
+ } catch (error) {
1019
+ return { ok: false, error: openerUnavailableMessage(command, getErrorMessage(error)) };
1020
+ }
1021
+ }
1022
+
1023
+ // src/cli/lib/hosts/configured-placements.ts
1024
+ async function unofferablePlacementsFound(cwd) {
1025
+ return refusalsAmong(await Promise.all(configsInPlay(cwd).map(placementsAskedIn)));
1026
+ }
1027
+ async function placementsAskedIn(config) {
1028
+ const skills = await configuredSkillsAt(config);
1029
+ if (skills === null) return { skills: [], refusal: null };
1030
+ return { skills, refusal: refusalOf(skills, config.provider) };
1031
+ }
1032
+ function refusalsAmong(asked) {
1033
+ return asked.map(({ refusal }) => refusal).filter((refusal) => refusal !== null);
1034
+ }
1035
+ function refusalOf(skills, provider) {
1036
+ try {
1037
+ refuseUnofferedPlacements(skills, hostFor(provider));
1038
+ return null;
1039
+ } catch (error) {
1040
+ return getErrorMessage(error);
1041
+ }
1042
+ }
1043
+ async function configuredSkillsAt({ dir, provider }) {
1044
+ try {
1045
+ const loaded = await loadProjectConfigFromDir(dir, provider);
1046
+ return loaded?.config.skills ?? null;
1047
+ } catch (error) {
1048
+ if (error instanceof ConfigLoadError) return null;
1049
+ throw error;
1050
+ }
1051
+ }
1052
+
1053
+ // ../../node_modules/hono/dist/utils/cookie.js
1054
+ var validCookieNameRegEx = /^[\w!#$%&'*.^`|~+-]+$/;
1055
+ var _serialize = (name, value, opt = {}) => {
1056
+ if (!validCookieNameRegEx.test(name)) {
1057
+ throw new Error("Invalid cookie name");
1058
+ }
1059
+ let cookie = `${name}=${value}`;
1060
+ if (name.startsWith("__Secure-") && !opt.secure) {
1061
+ throw new Error("__Secure- Cookie must have Secure attributes");
1062
+ }
1063
+ if (name.startsWith("__Host-")) {
1064
+ if (!opt.secure) {
1065
+ throw new Error("__Host- Cookie must have Secure attributes");
1066
+ }
1067
+ if (opt.path !== "/") {
1068
+ throw new Error('__Host- Cookie must have Path attributes with "/"');
1069
+ }
1070
+ if (opt.domain) {
1071
+ throw new Error("__Host- Cookie must not have Domain attributes");
1072
+ }
1073
+ }
1074
+ for (const key of ["domain", "path", "sameSite", "priority"]) {
1075
+ if (opt[key] && /[;\r\n]/.test(opt[key])) {
1076
+ throw new Error(`${key} must not contain ";", "\\r", or "\\n"`);
1077
+ }
1078
+ }
1079
+ if (opt && typeof opt.maxAge === "number" && opt.maxAge >= 0) {
1080
+ if (opt.maxAge > 3456e4) {
1081
+ throw new Error(
1082
+ "Cookies Max-Age SHOULD NOT be greater than 400 days (34560000 seconds) in duration."
1083
+ );
1084
+ }
1085
+ cookie += `; Max-Age=${opt.maxAge | 0}`;
1086
+ }
1087
+ if (opt.domain && opt.prefix !== "host") {
1088
+ cookie += `; Domain=${opt.domain}`;
1089
+ }
1090
+ if (opt.path) {
1091
+ cookie += `; Path=${opt.path}`;
1092
+ }
1093
+ if (opt.expires) {
1094
+ if (opt.expires.getTime() - Date.now() > 3456e7) {
1095
+ throw new Error(
1096
+ "Cookies Expires SHOULD NOT be greater than 400 days (34560000 seconds) in the future."
1097
+ );
1098
+ }
1099
+ cookie += `; Expires=${opt.expires.toUTCString()}`;
1100
+ }
1101
+ if (opt.httpOnly) {
1102
+ cookie += "; HttpOnly";
1103
+ }
1104
+ if (opt.secure) {
1105
+ cookie += "; Secure";
1106
+ }
1107
+ if (opt.sameSite) {
1108
+ cookie += `; SameSite=${opt.sameSite.charAt(0).toUpperCase() + opt.sameSite.slice(1)}`;
1109
+ }
1110
+ if (opt.priority) {
1111
+ cookie += `; Priority=${opt.priority.charAt(0).toUpperCase() + opt.priority.slice(1)}`;
1112
+ }
1113
+ if (opt.partitioned) {
1114
+ if (!opt.secure) {
1115
+ throw new Error("Partitioned Cookie must have Secure attributes");
1116
+ }
1117
+ cookie += "; Partitioned";
1118
+ }
1119
+ return cookie;
1120
+ };
1121
+ var serialize = (name, value, opt) => {
1122
+ value = encodeURIComponent(value);
1123
+ return _serialize(name, value, opt);
1124
+ };
1125
+
1126
+ // ../../node_modules/hono/dist/client/utils.js
1127
+ var mergePath = (base, path2) => {
1128
+ base = base.replace(/\/+$/, "");
1129
+ base = base + "/";
1130
+ path2 = path2.replace(/^\/+/, "");
1131
+ return base + path2;
1132
+ };
1133
+ var replaceUrlParam = (urlString, params) => {
1134
+ for (const [k, v] of Object.entries(params)) {
1135
+ const reg = new RegExp("/:" + k + "(?:{[^/]+})?\\??(?=/|$)");
1136
+ urlString = urlString.replace(reg, v ? `/${v}` : "");
1137
+ }
1138
+ return urlString;
1139
+ };
1140
+ var buildSearchParams = (query) => {
1141
+ const searchParams = new URLSearchParams();
1142
+ for (const [k, v] of Object.entries(query)) {
1143
+ if (v === void 0) {
1144
+ continue;
1145
+ }
1146
+ if (Array.isArray(v)) {
1147
+ for (const v2 of v) {
1148
+ searchParams.append(k, v2);
1149
+ }
1150
+ } else {
1151
+ searchParams.set(k, v);
1152
+ }
1153
+ }
1154
+ return searchParams;
1155
+ };
1156
+ var replaceUrlProtocol = (urlString, protocol) => {
1157
+ switch (protocol) {
1158
+ case "ws":
1159
+ return urlString.replace(/^http/, "ws");
1160
+ case "http":
1161
+ return urlString.replace(/^ws/, "http");
1162
+ }
1163
+ };
1164
+ var removeIndexString = (urlString) => {
1165
+ if (/^https?:\/\/[^\/]+?\/index(?=\?|$)/.test(urlString)) {
1166
+ return urlString.replace(/\/index(?=\?|$)/, "/");
1167
+ }
1168
+ return urlString.replace(/\/index(?=\?|$)/, "");
1169
+ };
1170
+ function isObject(item) {
1171
+ return typeof item === "object" && item !== null && !Array.isArray(item);
1172
+ }
1173
+ function deepMerge(target, source) {
1174
+ if (!isObject(target) && !isObject(source)) {
1175
+ return source;
1176
+ }
1177
+ const merged = { ...target };
1178
+ for (const key in source) {
1179
+ const value = source[key];
1180
+ if (isObject(merged[key]) && isObject(value)) {
1181
+ merged[key] = deepMerge(merged[key], value);
1182
+ } else {
1183
+ merged[key] = value;
1184
+ }
1185
+ }
1186
+ return merged;
1187
+ }
1188
+
1189
+ // ../../node_modules/hono/dist/client/client.js
1190
+ var createProxy = (callback, path2) => {
1191
+ const proxy = new Proxy(() => {
1192
+ }, {
1193
+ get(_obj, key) {
1194
+ if (typeof key !== "string" || key === "then") {
1195
+ return void 0;
1196
+ }
1197
+ return createProxy(callback, [...path2, key]);
1198
+ },
1199
+ apply(_1, _2, args) {
1200
+ return callback({
1201
+ path: path2,
1202
+ args
1203
+ });
1204
+ }
1205
+ });
1206
+ return proxy;
1207
+ };
1208
+ var ClientRequestImpl = class {
1209
+ url;
1210
+ method;
1211
+ buildSearchParams;
1212
+ queryParams = void 0;
1213
+ pathParams = {};
1214
+ rBody;
1215
+ cType = void 0;
1216
+ constructor(url, method, options) {
1217
+ this.url = url;
1218
+ this.method = method;
1219
+ this.buildSearchParams = options.buildSearchParams;
1220
+ }
1221
+ fetch = async (args, opt) => {
1222
+ if (args) {
1223
+ if (args.query) {
1224
+ this.queryParams = this.buildSearchParams(args.query);
1225
+ }
1226
+ if (args.form) {
1227
+ const form = new FormData();
1228
+ for (const [k, v] of Object.entries(args.form)) {
1229
+ if (v === void 0) {
1230
+ continue;
1231
+ }
1232
+ if (Array.isArray(v)) {
1233
+ for (const v2 of v) {
1234
+ form.append(k, v2);
1235
+ }
1236
+ } else {
1237
+ form.append(k, v);
1238
+ }
1239
+ }
1240
+ this.rBody = form;
1241
+ }
1242
+ if (args.json) {
1243
+ this.rBody = JSON.stringify(args.json);
1244
+ this.cType = "application/json";
1245
+ }
1246
+ if (args.param) {
1247
+ this.pathParams = args.param;
1248
+ }
1249
+ }
1250
+ let methodUpperCase = this.method.toUpperCase();
1251
+ const headerValues = {
1252
+ ...args?.header,
1253
+ ...typeof opt?.headers === "function" ? await opt.headers() : opt?.headers
1254
+ };
1255
+ if (args?.cookie) {
1256
+ const cookies = [];
1257
+ for (const [key, value] of Object.entries(args.cookie)) {
1258
+ cookies.push(serialize(key, value, { path: "/" }));
1259
+ }
1260
+ headerValues["Cookie"] = cookies.join(",");
1261
+ }
1262
+ if (this.cType) {
1263
+ headerValues["Content-Type"] = this.cType;
1264
+ }
1265
+ const headers = new Headers(headerValues ?? void 0);
1266
+ let url = this.url;
1267
+ url = removeIndexString(url);
1268
+ url = replaceUrlParam(url, this.pathParams);
1269
+ if (this.queryParams) {
1270
+ url = url + "?" + this.queryParams.toString();
1271
+ }
1272
+ methodUpperCase = this.method.toUpperCase();
1273
+ const setBody = !(methodUpperCase === "GET" || methodUpperCase === "HEAD");
1274
+ return (opt?.fetch || fetch)(url, {
1275
+ body: setBody ? this.rBody : void 0,
1276
+ method: methodUpperCase,
1277
+ headers,
1278
+ ...opt?.init
1279
+ });
1280
+ };
1281
+ };
1282
+ var hc = (baseUrl, options) => createProxy(function proxyCallback(opts) {
1283
+ const buildSearchParamsOption = options?.buildSearchParams ?? buildSearchParams;
1284
+ const parts = [...opts.path];
1285
+ const lastParts = parts.slice(-3).reverse();
1286
+ if (lastParts[0] === "toString") {
1287
+ if (lastParts[1] === "name") {
1288
+ return lastParts[2] || "";
1289
+ }
1290
+ return proxyCallback.toString();
1291
+ }
1292
+ if (lastParts[0] === "valueOf") {
1293
+ if (lastParts[1] === "name") {
1294
+ return lastParts[2] || "";
1295
+ }
1296
+ return proxyCallback;
1297
+ }
1298
+ let method = "";
1299
+ if (/^\$/.test(lastParts[0])) {
1300
+ const last = parts.pop();
1301
+ if (last) {
1302
+ method = last.replace(/^\$/, "");
1303
+ }
1304
+ }
1305
+ const path2 = parts.join("/");
1306
+ const url = mergePath(baseUrl, path2);
1307
+ if (method === "url" || method === "path") {
1308
+ let result = url;
1309
+ if (opts.args[0]) {
1310
+ if (opts.args[0].param) {
1311
+ result = replaceUrlParam(url, opts.args[0].param);
1312
+ }
1313
+ if (opts.args[0].query) {
1314
+ result = result + "?" + buildSearchParamsOption(opts.args[0].query).toString();
1315
+ }
1316
+ }
1317
+ result = removeIndexString(result);
1318
+ if (method === "url") {
1319
+ return new URL(result);
1320
+ }
1321
+ return result.slice(baseUrl.replace(/\/+$/, "").length).replace(/^\/?/, "/");
1322
+ }
1323
+ if (method === "ws") {
1324
+ const webSocketUrl = replaceUrlProtocol(
1325
+ opts.args[0] && opts.args[0].param ? replaceUrlParam(url, opts.args[0].param) : url,
1326
+ "ws"
1327
+ );
1328
+ const targetUrl = new URL(webSocketUrl);
1329
+ const queryParams = opts.args[0]?.query;
1330
+ if (queryParams) {
1331
+ Object.entries(queryParams).forEach(([key, value]) => {
1332
+ if (Array.isArray(value)) {
1333
+ value.forEach((item) => targetUrl.searchParams.append(key, item));
1334
+ } else {
1335
+ targetUrl.searchParams.set(key, value);
1336
+ }
1337
+ });
1338
+ }
1339
+ const establishWebSocket = (...args) => {
1340
+ if (options?.webSocket !== void 0 && typeof options.webSocket === "function") {
1341
+ return options.webSocket(...args);
1342
+ }
1343
+ return new WebSocket(...args);
1344
+ };
1345
+ return establishWebSocket(targetUrl.toString());
1346
+ }
1347
+ const req = new ClientRequestImpl(url, method, {
1348
+ buildSearchParams: buildSearchParamsOption
1349
+ });
1350
+ if (method) {
1351
+ options ??= {};
1352
+ const reqOptions = { ...opts.args[1] };
1353
+ const baseHeaders = options.headers;
1354
+ const reqHeaders = reqOptions.headers;
1355
+ if (baseHeaders && reqHeaders) {
1356
+ reqOptions.headers = async () => ({
1357
+ ...typeof baseHeaders === "function" ? await baseHeaders() : baseHeaders,
1358
+ ...typeof reqHeaders === "function" ? await reqHeaders() : reqHeaders
1359
+ });
1360
+ }
1361
+ const args = deepMerge(options, reqOptions);
1362
+ return req.fetch(opts.args[0], args);
1363
+ }
1364
+ return req;
1365
+ }, []);
1366
+
1367
+ // ../api/src/client.ts
1368
+ var resolvePolicy = ({
1369
+ headers = {},
1370
+ credentials = "include"
1371
+ }) => ({ headers, credentials });
1372
+ var createApiClient = ({
1373
+ baseUrl,
1374
+ fetch: fetch2,
1375
+ ...policy
1376
+ }) => {
1377
+ const { headers, credentials } = resolvePolicy(policy);
1378
+ return hc(baseUrl, {
1379
+ headers,
1380
+ init: { credentials },
1381
+ // `exactOptionalPropertyTypes` rejects an explicit undefined `fetch`.
1382
+ ...fetch2 && { fetch: fetch2 }
1383
+ });
1384
+ };
1385
+ var WHOLE_SECONDS = /^[1-9]\d*$/;
1386
+ var retryAfterSeconds = ({ headers }) => {
1387
+ const stated = headers.get("retry-after");
1388
+ return stated !== null && WHOLE_SECONDS.test(stated) ? Number(stated) : null;
1389
+ };
1390
+
1391
+ // src/cli/lib/seed/fetch-seed.ts
1392
+ var SEED_USER_AGENT = "agents-inc-cli";
1393
+ var store = createApiClient({
1394
+ baseUrl: SEED_API_URL,
1395
+ headers: { accept: "application/json", "user-agent": SEED_USER_AGENT },
1396
+ credentials: "omit"
1397
+ });
1398
+ var EXPLANATION_BUDGET = 120;
1399
+ var QUOTABLE_TYPE = "text/plain";
1400
+ var NO_SUCH_CONFIG = 404;
1401
+ async function fetchSeedConfig(id) {
1402
+ const response = await requestFromStore(id);
1403
+ if (response === null) {
1404
+ return { ok: false, error: `Could not reach ${SEED_API_URL} \u2014 check your connection.` };
1405
+ }
1406
+ if (response.status === NO_SUCH_CONFIG) {
1407
+ return { ok: false, error: `No configuration found for id '${id}'.` };
1408
+ }
1409
+ if (!response.ok) {
1410
+ return { ok: false, error: await refusalMessage(response) };
1411
+ }
1412
+ return payloadIn(await jsonBodyOrUndefined(response), id);
1413
+ }
1414
+ async function requestFromStore(id) {
1415
+ try {
1416
+ return await store.configs[":id"].$get({ param: { id: encodeURIComponent(id) } });
1417
+ } catch {
1418
+ return null;
1419
+ }
1420
+ }
1421
+ async function jsonBodyOrUndefined(response) {
1422
+ try {
1423
+ return await response.json();
1424
+ } catch {
1425
+ return void 0;
1426
+ }
1427
+ }
1428
+ function payloadIn(body, id) {
1429
+ if (body === void 0) {
1430
+ return { ok: false, error: "The configuration store returned something that is not JSON." };
1431
+ }
1432
+ const parsed = seedPayloadSchema.safeParse(body);
1433
+ if (!parsed.success) {
1434
+ return {
1435
+ ok: false,
1436
+ error: `Configuration '${id}' is not in a format this version of the CLI can install. Shared ids are never migrated \u2014 re-share the configuration to mint a current one, or update the CLI if that id came from a newer version.`
1437
+ };
1438
+ }
1439
+ return { ok: true, payload: parsed.data };
1440
+ }
1441
+ async function refusalMessage(response) {
1442
+ const refused = `Fetching configuration failed (HTTP ${response.status}).`;
1443
+ const explanation = explanationOf(await refusalBody(response));
1444
+ return explanation === void 0 ? refused : `${refused} The store said: ${explanation}`;
1445
+ }
1446
+ async function refusalBody(response) {
1447
+ if (!arrivedAsText(response)) return void 0;
1448
+ try {
1449
+ return await response.text();
1450
+ } catch {
1451
+ return void 0;
1452
+ }
1453
+ }
1454
+ function arrivedAsText(response) {
1455
+ return (response.headers.get("content-type") ?? "").startsWith(QUOTABLE_TYPE);
1456
+ }
1457
+ function explanationOf(body) {
1458
+ if (body === void 0) return void 0;
1459
+ const said = body.trim();
1460
+ if (said === "") return void 0;
1461
+ return truncateText(said, EXPLANATION_BUDGET);
1462
+ }
1463
+
1464
+ // src/cli/lib/seed/publish-seed.ts
1465
+ import { STATUS_CODES } from "http";
1466
+ import { z } from "zod";
1467
+ var mintedSchema = z.object({ id: z.string().min(1) });
1468
+ var refusalSchema = z.object({ error: z.object({ message: z.string() }) });
1469
+ var refusedIssuesSchema = z.array(
1470
+ z.object({
1471
+ path: z.array(z.union([z.string(), z.number()])),
1472
+ message: z.string().min(1)
1473
+ })
1474
+ ).min(1);
1475
+ var EXPLANATION_BUDGET2 = 300;
1476
+ var CONTRACT_MISMATCH = 409;
1477
+ var RATE_LIMITED = 429;
1478
+ var LIMIT_REACHED = "rate limit reached \u2014 try again in";
1479
+ var SECONDS_PER_MINUTE = 60;
1480
+ var OUT_OF_DATE_AGAINST_STORE = `This CLI is out of date against the configuration store: it writes a version of the sharing contract the store does not serve, and that version travels inside the CLI rather than with the configuration. Re-run this command through '${CLI_INVOKE_COMMAND}@latest'.`;
1481
+ async function publishSeedConfig(payload) {
1482
+ const response = await postToStore(payload);
1483
+ if (response === null) {
1484
+ return { ok: false, error: `Could not reach ${SEED_API_URL} \u2014 check your connection.` };
1485
+ }
1486
+ if (!response.ok) return { ok: false, error: await refusalMessage2(response) };
1487
+ return mintedIdIn(await jsonBodyOrUndefined(response));
1488
+ }
1489
+ async function postToStore(payload) {
1490
+ try {
1491
+ return await fetch(`${SEED_API_URL}/configs`, {
1492
+ method: "POST",
1493
+ headers: {
1494
+ accept: "application/json",
1495
+ "content-type": "application/json",
1496
+ // Tells the store the configuration came from the CLI rather than a browser.
1497
+ "user-agent": SEED_USER_AGENT
1498
+ },
1499
+ body: JSON.stringify(payload)
1500
+ });
1501
+ } catch {
1502
+ return null;
1503
+ }
1504
+ }
1505
+ function mintedIdIn(body) {
1506
+ if (body === void 0) {
1507
+ return { ok: false, error: "The configuration store returned something that is not JSON." };
1508
+ }
1509
+ const minted = mintedSchema.safeParse(body);
1510
+ if (!minted.success) {
1511
+ return { ok: false, error: "The configuration store did not return an id for this share." };
1512
+ }
1513
+ return { ok: true, id: minted.data.id };
1514
+ }
1515
+ async function refusalMessage2(response) {
1516
+ const failed = `Sharing this configuration failed (HTTP ${response.status})`;
1517
+ const refused = `${failed}.`;
1518
+ if (response.status === CONTRACT_MISMATCH) return `${refused} ${OUT_OF_DATE_AGAINST_STORE}`;
1519
+ const window = rateLimitWindow(response);
1520
+ if (window !== null) return `${failed}: ${LIMIT_REACHED} ${waitOf(window)}.`;
1521
+ const explanation = explanationOf2(response, await refusalBody2(response));
1522
+ return explanation === void 0 ? refused : `${refused} The store said: ${explanation}`;
1523
+ }
1524
+ function rateLimitWindow(response) {
1525
+ return response.status === RATE_LIMITED ? retryAfterSeconds(response) : null;
1526
+ }
1527
+ function waitOf(seconds) {
1528
+ return seconds < SECONDS_PER_MINUTE ? plural(seconds, "second") : plural(Math.ceil(seconds / SECONDS_PER_MINUTE), "minute");
1529
+ }
1530
+ async function refusalBody2(response) {
1531
+ try {
1532
+ return await response.text();
1533
+ } catch {
1534
+ return void 0;
1535
+ }
1536
+ }
1537
+ function explanationOf2(response, body) {
1538
+ if (body === void 0) return void 0;
1539
+ const said = schemaIssuesIn(body) ?? quotableProseIn(response, body);
1540
+ return said === void 0 ? void 0 : truncateText(said, EXPLANATION_BUDGET2);
1541
+ }
1542
+ function schemaIssuesIn(body) {
1543
+ const refusal = refusalSchema.safeParse(parseJsonOrUndefined(body));
1544
+ if (!refusal.success) return void 0;
1545
+ const issues = refusedIssuesSchema.safeParse(parseJsonOrUndefined(refusal.data.error.message));
1546
+ if (!issues.success) return void 0;
1547
+ return issues.data.map(sentenceOf).join("; ");
1548
+ }
1549
+ function quotableProseIn(response, body) {
1550
+ if (!arrivedAsText(response)) return void 0;
1551
+ const said = body.trim();
1552
+ if (said === "") return void 0;
1553
+ if (restatesItsOwnStatus(said, response.status)) return void 0;
1554
+ return said;
1555
+ }
1556
+ function restatesItsOwnStatus(said, status) {
1557
+ const reason = STATUS_CODES[status];
1558
+ return reason !== void 0 && said.toLowerCase() === reason.toLowerCase();
1559
+ }
1560
+ function sentenceOf(issue) {
1561
+ const path2 = issue.path.join(".");
1562
+ return path2 === "" ? issue.message : `${path2}: ${issue.message}`;
1563
+ }
1564
+
909
1565
  // src/cli/lib/operations/source/ensure-marketplace.ts
910
1566
  async function ensureMarketplace(sourceResult, host) {
911
1567
  const marketplace = await resolveMarketplaceName(sourceResult);
@@ -973,13 +1629,14 @@ async function requireMarketplace(sourceResult, purpose, host) {
973
1629
 
974
1630
  // src/cli/lib/operations/skills/install-plugin-skills.ts
975
1631
  function pluginInstallFailureError(failedCount) {
976
- return `Failed to install ${failedCount} plugin skill(s). Plugin install intent could not be honored. Verify the skill id matches the marketplace, run '${CLI_INVOKE_COMMAND} update' to refresh the marketplace, or switch affected skills to eject mode.`;
1632
+ return `Failed to install ${plural(failedCount, "plugin skill")}. Plugin install intent could not be honored. Verify the skill id matches the marketplace, run '${CLI_INVOKE_COMMAND} update' to refresh the marketplace, or switch affected skills to eject mode.`;
977
1633
  }
978
1634
  function unbackedPluginSkillIds(skills, matrix2) {
979
1635
  return skills.filter((skill) => skill.origin !== EJECT_SOURCE).filter((skill) => isLocalOnlySkill(matrix2.skills[skill.id])).map((skill) => skill.id);
980
1636
  }
981
1637
  function unbackedPluginInstallError(ids) {
982
- return `Cannot install ${ids.length} skill(s) as plugins \u2014 no marketplace carries them: ${ids.join(", ")}. A skill that exists only in this project can only be installed as a local copy. Set its Install mode to eject in the editor, or publish it to a marketplace first.`;
1638
+ const [asPlugins, them] = ids.length === 1 ? ["as a plugin", "it"] : ["as plugins", "them"];
1639
+ return `Cannot install ${plural(ids.length, "skill")} ${asPlugins} \u2014 no marketplace carries ${them}: ${ids.join(", ")}. A skill that exists only in this project can only be installed as a local copy. Set its Install mode to eject in the editor, or publish it to a marketplace first.`;
983
1640
  }
984
1641
  async function installPluginSkills(skills, marketplace, projectDir) {
985
1642
  const host = hostAt(projectDir);
@@ -1021,6 +1678,13 @@ function waitForTerminal(isSatisfied) {
1021
1678
  process.stdout.on("resize", check);
1022
1679
  });
1023
1680
  }
1681
+ function switchOwed({ pluginKey, configFile }) {
1682
+ return {
1683
+ what: pluginNotSwitchedBackOff(pluginKey),
1684
+ recovery: switchItOffIn(configFile),
1685
+ pluginSwitch: true
1686
+ };
1687
+ }
1024
1688
  function findUnassignedSkills(config, selected) {
1025
1689
  const assignedIds = new Set(config.stack ? getStackSkillIds(config.stack) : []);
1026
1690
  const selectedIds = new Set(selected.map((skill) => skill.id));
@@ -1039,16 +1703,10 @@ function hasActiveProjectEntry(skills, skillId) {
1039
1703
  var BaseCommand = class extends Command {
1040
1704
  /** Non-empty decides the exit code; see {@link exitIfWorkIncomplete}. */
1041
1705
  incompleteWork = [];
1042
- /** Warned of by the refresh that left them; non-empty fails the run, as in `update`. */
1043
- switchesLeftOn = [];
1044
1706
  async init() {
1045
1707
  await super.init();
1046
1708
  await this.ensureTerminalSize();
1047
1709
  }
1048
- /**
1049
- * Called first where a command starts work on the installation in play, which for a project whose
1050
- * config declares nothing is the global one, or none where HOME holds none the run could work on.
1051
- */
1052
1710
  async sayWhenTheGlobalInstallationStandsIn(named) {
1053
1711
  if (!await holdsOnlyAConfigDeclaringNothing(process.cwd())) return;
1054
1712
  const standsIn = await homeHoldsAnInstallationFor(process.cwd(), named);
@@ -1056,7 +1714,6 @@ var BaseCommand = class extends Command {
1056
1714
  standsIn ? INFO_MESSAGES.GLOBAL_INSTALLATION_STANDS_IN : INFO_MESSAGES.NO_GLOBAL_INSTALLATION_STANDS_IN
1057
1715
  );
1058
1716
  }
1059
- /** For a command that never works on the global installation: `line` says what it does instead. */
1060
1717
  async sayWhenTheProjectsConfigDeclaresNothing(line) {
1061
1718
  if (await holdsOnlyAConfigDeclaringNothing(process.cwd())) sayFirst(line);
1062
1719
  }
@@ -1092,7 +1749,7 @@ var BaseCommand = class extends Command {
1092
1749
  if (!required.ok) {
1093
1750
  this.error(required.error, { exit: EXIT_CODES.ERROR });
1094
1751
  }
1095
- this.switchesLeftOn.push(...required.leftOn);
1752
+ this.recordPluginsLeftSwitchedOn(required.leftOn);
1096
1753
  if (required.registered) {
1097
1754
  onRegistered?.(required.marketplace);
1098
1755
  }
@@ -1164,6 +1821,14 @@ var BaseCommand = class extends Command {
1164
1821
  }
1165
1822
  }
1166
1823
  }
1824
+ async refuseAnAmbiguousInstallation(cwd, command, named) {
1825
+ await refuseAnAmbiguousInstallation(
1826
+ cwd,
1827
+ command,
1828
+ named,
1829
+ (message) => this.error(message, { exit: EXIT_CODES.INVALID_ARGS })
1830
+ );
1831
+ }
1167
1832
  /**
1168
1833
  * Aborts up front when the project or global config exists but cannot be loaded, so nothing is
1169
1834
  * installed before the config write fails. A missing config passes.
@@ -1174,6 +1839,21 @@ var BaseCommand = class extends Command {
1174
1839
  this.error(installationConfigsUnreadable(failures), { exit: EXIT_CODES.ERROR });
1175
1840
  }
1176
1841
  }
1842
+ /**
1843
+ * Over the configs on disk: config.ts names no provider, so a copied installation folder can hold
1844
+ * a configuration its host never vetted at install.
1845
+ */
1846
+ async refuseUnofferablePlacements(cwd) {
1847
+ const [finding] = await unofferablePlacementsFound(cwd);
1848
+ if (finding !== void 0) this.error(finding, { exit: EXIT_CODES.ERROR });
1849
+ }
1850
+ /** Ambiguity is refused first: loading a config already picks a provider by roster order. */
1851
+ async checkTheInstallationBeforeActing(cwd, command, named) {
1852
+ await this.sayWhenTheGlobalInstallationStandsIn(named);
1853
+ await this.refuseAnAmbiguousInstallation(cwd, command, named);
1854
+ await this.ensureConfigReadable(cwd);
1855
+ await this.refuseUnofferablePlacements(cwd);
1856
+ }
1177
1857
  /** Only entries the catalogue lacks are checked; one whose files are gone is not refused. */
1178
1858
  async ensureSavedSkillsReadable(savedSkills, matrix2, projectDir) {
1179
1859
  const unresolved = savedSkills.filter((saved) => !matrix2.skills[saved.id]);
@@ -1186,6 +1866,10 @@ var BaseCommand = class extends Command {
1186
1866
  async refuseUnusableSavedSkillMetadata(savedSkills, projectDir, refusal) {
1187
1867
  const unusable = await findUnusableSavedSkillMetadata(savedSkills, projectDir);
1188
1868
  if (unusable.length === 0) return;
1869
+ this.refuseUnusableSkillMetadata(unusable, refusal);
1870
+ }
1871
+ /** Detail is logged, not raised: oclif hard-wraps error text, which breaks copyable paths. */
1872
+ refuseUnusableSkillMetadata(unusable, refusal) {
1189
1873
  for (const entry of unusable) {
1190
1874
  this.log(skillMetadataUnusableDetail(entry));
1191
1875
  }
@@ -1214,6 +1898,71 @@ var BaseCommand = class extends Command {
1214
1898
  }
1215
1899
  if (skippedAgentNames.length > 0) this.warn(skippedUnknownAgents(skippedAgentNames));
1216
1900
  }
1901
+ async fetchSharedConfigOrFail(id) {
1902
+ this.log(`Fetching configuration ${id}...`);
1903
+ const fetched = await fetchSeedConfig(id);
1904
+ if (!fetched.ok) {
1905
+ this.error(fetched.error, { exit: EXIT_CODES.ERROR });
1906
+ }
1907
+ return fetched.payload;
1908
+ }
1909
+ /** Prints the id it was given, with where to install or open it. */
1910
+ async publishSharedConfigOrFail(payload) {
1911
+ return this.publishOrFail(payload, sharedConfigDestinations);
1912
+ }
1913
+ /** For an id minted from the installation in play, which `edit --from` applies it back to. */
1914
+ async publishToApplyBackOrFail(payload, cwd, named) {
1915
+ const toName = await installationToName(cwd, named);
1916
+ return this.publishOrFail(payload, (id) => appliedBackDestinations(id, toName));
1917
+ }
1918
+ async publishOrFail(payload, destinations) {
1919
+ const published = await publishSeedConfig(payload);
1920
+ if (!published.ok) {
1921
+ this.error(published.error, { exit: EXIT_CODES.ERROR });
1922
+ }
1923
+ this.logSuccess(`Shared as ${published.id}`);
1924
+ for (const destination of destinations(published.id)) {
1925
+ this.log(destination);
1926
+ }
1927
+ return published.id;
1928
+ }
1929
+ /** The line naming the `--from` command that applies a shared configuration here. */
1930
+ async howToApplyItHere(id, dir, named) {
1931
+ const installedHere = await holdsItsOwnInstallation(dir);
1932
+ const toName = installedHere ? await installationToName(dir, named) : named;
1933
+ return applySharedConfigHere(id, installedHere, toName);
1934
+ }
1935
+ /** Extra to the printed link, which works over a pipe, in CI and with no desktop. */
1936
+ async openInBrowserAtATerminal(url) {
1937
+ if (!process.stdin.isTTY) return;
1938
+ const opened = await openUrl(url);
1939
+ if (!opened.ok) this.warn(opened.error);
1940
+ }
1941
+ decodeSeedOrFail(payload, matrix2) {
1942
+ try {
1943
+ return seedToInstallSelection(payload, matrix2);
1944
+ } catch (error) {
1945
+ this.handleError(error);
1946
+ }
1947
+ }
1948
+ registerExternalSkillsOrFail(payload, matrix2, projectDir) {
1949
+ try {
1950
+ return registerExternalSkills(payload, matrix2, projectDir);
1951
+ } catch (error) {
1952
+ this.handleError(error);
1953
+ }
1954
+ }
1955
+ async writeCarriedSkills(carried) {
1956
+ if (carried.length === 0) return;
1957
+ await writeExternalSkills(carried);
1958
+ const recorded = carried.map(({ id, skill }) => ({ id, displayName: skill.displayName }));
1959
+ this.log(
1960
+ carriedSkillsWritten(
1961
+ carried.map(({ id }) => id),
1962
+ namedByActiveEntries(recorded)
1963
+ )
1964
+ );
1965
+ }
1217
1966
  /** For the panel's header; `undefined` for a configuration built from no stack. */
1218
1967
  async stackNameOf(stackId, sourceResult) {
1219
1968
  if (!stackId) return void 0;
@@ -1246,6 +1995,9 @@ var BaseCommand = class extends Command {
1246
1995
  get hasIncompleteWork() {
1247
1996
  return this.incompleteWork.length > 0;
1248
1997
  }
1998
+ get owesWorkBesidesPluginSwitches() {
1999
+ return this.incompleteWork.some(({ pluginSwitch }) => !pluginSwitch);
2000
+ }
1249
2001
  /** Never aborts: every caller is past a mutation that has already landed. */
1250
2002
  reportIncompleteWork(what, recovery) {
1251
2003
  this.warn(what);
@@ -1253,25 +2005,23 @@ var BaseCommand = class extends Command {
1253
2005
  }
1254
2006
  /** For a caller that has already warned. */
1255
2007
  recordIncompleteWork(what, recovery) {
1256
- this.incompleteWork.push({ what, recovery });
2008
+ this.incompleteWork.push({ what, recovery, pluginSwitch: false });
2009
+ }
2010
+ /** For a caller that has already warned. */
2011
+ recordPluginsLeftSwitchedOn(leftOn) {
2012
+ this.incompleteWork.push(...leftOn.map(switchOwed));
1257
2013
  }
1258
2014
  /** Every command that records must call this; `this.exit` skips the `Error:` framing. */
1259
2015
  exitIfWorkIncomplete() {
2016
+ if (!this.hasIncompleteWork) return;
1260
2017
  this.listIncompleteWork();
1261
- this.failIfPluginsLeftSwitchedOn();
1262
- if (this.hasIncompleteWork) this.exit(EXIT_CODES.COMPLETED_WITH_FAILURES);
2018
+ this.exit(EXIT_CODES.COMPLETED_WITH_FAILURES);
1263
2019
  }
1264
2020
  listIncompleteWork() {
1265
- if (!this.hasIncompleteWork) return;
1266
2021
  this.log(`
1267
2022
  ${chalk.hex(CLI_COLORS.WARNING)(completedWithFailures(this.incompleteWork))}
1268
2023
  `);
1269
2024
  }
1270
- failIfPluginsLeftSwitchedOn() {
1271
- if (this.switchesLeftOn.length === 0) return;
1272
- const pluginKeys = this.switchesLeftOn.map(({ pluginKey }) => pluginKey);
1273
- this.error(pluginsLeftSwitchedOn(pluginKeys), { exit: EXIT_CODES.ERROR });
1274
- }
1275
2025
  };
1276
2026
 
1277
2027
  export {
@@ -1281,23 +2031,24 @@ export {
1281
2031
  providerNamedBy,
1282
2032
  providerNamedIn,
1283
2033
  providerNeedsAConfigurationToInstall,
1284
- refuseAnAmbiguousInstallation,
1285
- installationToName,
1286
2034
  ambiguityFinding,
1287
2035
  otherInstallationsInThisScope,
1288
- registerExternalSkills,
1289
- writeExternalSkills,
2036
+ placementsAskedIn,
2037
+ refusalsAmong,
2038
+ externalIdsLackingThePrefix,
2039
+ lacksThePrefixError,
1290
2040
  carriedSkillsThatDiffer,
1291
2041
  readCarriedSkills,
1292
2042
  reconcileSharedConfig,
1293
2043
  readInstalledGlobal,
2044
+ runFromHomeFor,
1294
2045
  holdInstalledGlobal,
1295
2046
  restoreInstalledGlobal,
1296
2047
  sameAssignments,
1297
2048
  notInstalledGlobally,
1298
2049
  panelRowEntries,
1299
2050
  joinedStatement,
1300
- installsAtHome,
2051
+ keptAsInstalledStatement,
1301
2052
  BaseCommand
1302
2053
  };
1303
- //# sourceMappingURL=chunk-JTMSFBCA.js.map
2054
+ //# sourceMappingURL=chunk-E6W3PYGF.js.map