agents-inc 0.175.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.
- package/CHANGELOG.md +132 -0
- package/README.md +2 -2
- package/dist/chunk-2FE4AJNC.js +164 -0
- package/dist/chunk-2FE4AJNC.js.map +1 -0
- package/dist/{chunk-U46LYYRA.js → chunk-4SIBDIIO.js} +49 -13
- package/dist/chunk-4SIBDIIO.js.map +1 -0
- package/dist/chunk-5ZK4IND4.js +30 -0
- package/dist/chunk-5ZK4IND4.js.map +1 -0
- package/dist/{chunk-GNMRXXRY.js → chunk-77SHXTDD.js} +137 -56
- package/dist/chunk-77SHXTDD.js.map +1 -0
- package/dist/{chunk-EHEBN4NB.js → chunk-7OJ2SS4E.js} +10 -86
- package/dist/chunk-7OJ2SS4E.js.map +1 -0
- package/dist/{chunk-6HJVH27C.js → chunk-7WN6TUZP.js} +7 -8
- package/dist/chunk-7WN6TUZP.js.map +1 -0
- package/dist/chunk-AVKX3IXF.js +117 -0
- package/dist/chunk-AVKX3IXF.js.map +1 -0
- package/dist/{chunk-YM3VEDAP.js → chunk-D2PC7NIR.js} +2042 -1875
- package/dist/chunk-D2PC7NIR.js.map +1 -0
- package/dist/{chunk-37QFHJUW.js → chunk-E6W3PYGF.js} +909 -80
- package/dist/chunk-E6W3PYGF.js.map +1 -0
- package/dist/chunk-H33ZAEKH.js +147 -0
- package/dist/chunk-H33ZAEKH.js.map +1 -0
- package/dist/{chunk-MFCZARV2.js → chunk-JEFVFZAR.js} +50 -152
- package/dist/chunk-JEFVFZAR.js.map +1 -0
- package/dist/{chunk-TG3SPPZY.js → chunk-KKGJH46C.js} +3 -21
- package/dist/chunk-KKGJH46C.js.map +1 -0
- package/dist/chunk-OIQKRXHH.js +142 -0
- package/dist/chunk-OIQKRXHH.js.map +1 -0
- package/dist/{chunk-SNXEYAFP.js → chunk-TNN72UL6.js} +294 -247
- package/dist/chunk-TNN72UL6.js.map +1 -0
- package/dist/{chunk-Q4NWATGH.js → chunk-V3WJMNBF.js} +98 -23
- package/dist/chunk-V3WJMNBF.js.map +1 -0
- package/dist/chunk-VFD2XYM7.js +14 -0
- package/dist/chunk-VFD2XYM7.js.map +1 -0
- package/dist/{chunk-XYBHH3M5.js → chunk-WH7JXGDA.js} +2 -2
- package/dist/{chunk-DQB3E2SX.js → chunk-XSR4WRXJ.js} +3 -3
- package/dist/{chunk-EGC7PNDI.js → chunk-Y5VMB73R.js} +302 -119
- package/dist/chunk-Y5VMB73R.js.map +1 -0
- package/dist/chunk-ZIBWVTLN.js +18 -0
- package/dist/chunk-ZIBWVTLN.js.map +1 -0
- package/dist/commands/build/marketplace.js +6 -9
- package/dist/commands/build/marketplace.js.map +1 -1
- package/dist/commands/build/plugins.js +10 -38
- package/dist/commands/build/plugins.js.map +1 -1
- package/dist/commands/compile.js +64 -81
- package/dist/commands/compile.js.map +1 -1
- package/dist/commands/doctor.js +266 -153
- package/dist/commands/doctor.js.map +1 -1
- package/dist/commands/edit.js +84 -158
- package/dist/commands/edit.js.map +1 -1
- package/dist/commands/eject.js +66 -52
- package/dist/commands/eject.js.map +1 -1
- package/dist/commands/init.js +19 -16
- package/dist/commands/list.js +13 -13
- package/dist/commands/list.js.map +1 -1
- package/dist/commands/new/marketplace.js +5 -4
- package/dist/commands/new/marketplace.js.map +1 -1
- package/dist/commands/search.js +18 -12
- package/dist/commands/search.js.map +1 -1
- package/dist/commands/share.js +27 -52
- package/dist/commands/share.js.map +1 -1
- package/dist/commands/uninstall.js +145 -58
- package/dist/commands/uninstall.js.map +1 -1
- package/dist/commands/update.js +101 -36
- package/dist/commands/update.js.map +1 -1
- package/dist/components/common/header-row.js +9 -0
- package/dist/components/common/select-list.js +2 -2
- package/dist/components/common/skill-agent-summary.js +4 -3
- package/dist/components/common/summary-panel.js +6 -4
- package/dist/hooks/init.js +35 -21
- package/dist/hooks/init.js.map +1 -1
- package/dist/load-agent-defs-OCFWOZD2.js +14 -0
- package/dist/{recompile-project-agents-2QTFMYDC.js → recompile-project-agents-CXZBPIUS.js} +9 -9
- package/dist/{recompile-project-agents-2QTFMYDC.js.map → recompile-project-agents-CXZBPIUS.js.map} +1 -1
- package/dist/{source-loader-I6SWWDUF.js → source-loader-GGDQDMN4.js} +6 -4
- package/dist/source-loader-GGDQDMN4.js.map +1 -0
- package/package.json +1 -1
- package/src/schemas/stacks.schema.json +105 -1
- package/dist/chunk-37QFHJUW.js.map +0 -1
- package/dist/chunk-6HJVH27C.js.map +0 -1
- package/dist/chunk-EGC7PNDI.js.map +0 -1
- package/dist/chunk-EHEBN4NB.js.map +0 -1
- package/dist/chunk-GNMRXXRY.js.map +0 -1
- package/dist/chunk-ICHWAFAC.js +0 -263
- package/dist/chunk-ICHWAFAC.js.map +0 -1
- package/dist/chunk-MFCZARV2.js.map +0 -1
- package/dist/chunk-P5XEK7HC.js +0 -35
- package/dist/chunk-P5XEK7HC.js.map +0 -1
- package/dist/chunk-Q4NWATGH.js.map +0 -1
- package/dist/chunk-SI2LLEIR.js +0 -160
- package/dist/chunk-SI2LLEIR.js.map +0 -1
- package/dist/chunk-SNXEYAFP.js.map +0 -1
- package/dist/chunk-SRII2GMF.js +0 -428
- package/dist/chunk-SRII2GMF.js.map +0 -1
- package/dist/chunk-TG3SPPZY.js.map +0 -1
- package/dist/chunk-U46LYYRA.js.map +0 -1
- package/dist/chunk-YLFKFVQP.js +0 -39
- package/dist/chunk-YLFKFVQP.js.map +0 -1
- package/dist/chunk-YM3VEDAP.js.map +0 -1
- package/dist/load-agent-defs-BJ4KBKBA.js +0 -14
- /package/dist/{chunk-XYBHH3M5.js.map → chunk-WH7JXGDA.js.map} +0 -0
- /package/dist/{chunk-DQB3E2SX.js.map → chunk-XSR4WRXJ.js.map} +0 -0
- /package/dist/{load-agent-defs-BJ4KBKBA.js.map → components/common/header-row.js.map} +0 -0
- /package/dist/{source-loader-I6SWWDUF.js.map → load-agent-defs-OCFWOZD2.js.map} +0 -0
|
@@ -1,16 +1,30 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import {
|
|
3
|
+
namedByActiveEntries
|
|
4
|
+
} from "./chunk-2FE4AJNC.js";
|
|
5
|
+
import {
|
|
6
|
+
CATALOGUE_SKILL_IDS,
|
|
7
|
+
ConfigLoadError,
|
|
8
|
+
FailedLeavingPluginsSwitchedOnError,
|
|
3
9
|
INFO_MESSAGES,
|
|
10
|
+
PluginsLeftSwitchedOnError,
|
|
4
11
|
STATUS_MESSAGES,
|
|
5
12
|
addedToGlobalSubAgents,
|
|
13
|
+
appliedBackDestinations,
|
|
14
|
+
applySharedConfigHere,
|
|
6
15
|
buildMarketplacePluginRef,
|
|
16
|
+
carriedSkillsWritten,
|
|
7
17
|
chooseProviderForThisRun,
|
|
8
18
|
claimSlug,
|
|
19
|
+
codexPluginLeftSwitchedOn,
|
|
9
20
|
completedWithFailures,
|
|
21
|
+
configDeclaresNothing,
|
|
22
|
+
configsInPlay,
|
|
10
23
|
copy,
|
|
11
24
|
defaultUsageGuidance,
|
|
12
25
|
detectInstallations,
|
|
13
26
|
directoryExists,
|
|
27
|
+
execCommand,
|
|
14
28
|
fetchMarketplace,
|
|
15
29
|
fileExists,
|
|
16
30
|
findConfigLoadFailures,
|
|
@@ -20,13 +34,19 @@ import {
|
|
|
20
34
|
getStackSkillIds,
|
|
21
35
|
glob,
|
|
22
36
|
holdsAConfigDeclaringNothing,
|
|
37
|
+
holdsItsOwnInstallation,
|
|
23
38
|
hostAt,
|
|
39
|
+
hostFor,
|
|
24
40
|
installationConfigsUnreadable,
|
|
25
41
|
isHomeDirectory,
|
|
42
|
+
isKeyedRecord,
|
|
26
43
|
isLocalOnlySkill,
|
|
44
|
+
keptAsInstalledGlobally,
|
|
27
45
|
loadProjectConfigFromDir,
|
|
28
46
|
loadStackById,
|
|
29
47
|
parseFrontmatter,
|
|
48
|
+
parseJsonOrUndefined,
|
|
49
|
+
pluginNotSwitchedBackOff,
|
|
30
50
|
pluginsInstalled,
|
|
31
51
|
propagatedRecompileSummary,
|
|
32
52
|
providerInUse,
|
|
@@ -45,26 +65,27 @@ import {
|
|
|
45
65
|
resolveInstallPaths,
|
|
46
66
|
savedSkillMetadataUnusableError,
|
|
47
67
|
scopeBlockedStackAssignment,
|
|
68
|
+
seedToInstallSelection,
|
|
69
|
+
sharedConfigDestinations,
|
|
48
70
|
sharedConfigProjectScopeAtHome,
|
|
49
71
|
skillAssignedToNoAgent,
|
|
50
72
|
skillMetadataUnusableDetail,
|
|
51
73
|
skippedSkills,
|
|
52
74
|
skippedUnknownAgents,
|
|
75
|
+
switchItOffIn,
|
|
53
76
|
validateSkillPath,
|
|
54
77
|
verbose,
|
|
55
78
|
warn,
|
|
56
79
|
writeFile
|
|
57
|
-
} from "./chunk-
|
|
80
|
+
} from "./chunk-D2PC7NIR.js";
|
|
58
81
|
import {
|
|
59
|
-
BUILT_IN_MATRIX,
|
|
60
82
|
getCategoryDomain,
|
|
61
83
|
inertLine,
|
|
62
84
|
matrix,
|
|
85
|
+
plural,
|
|
63
86
|
stripTerminalControls,
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
typedValues
|
|
67
|
-
} from "./chunk-TG3SPPZY.js";
|
|
87
|
+
truncateText
|
|
88
|
+
} from "./chunk-KKGJH46C.js";
|
|
68
89
|
import {
|
|
69
90
|
CLI_COLORS,
|
|
70
91
|
CLI_INVOKE_COMMAND,
|
|
@@ -76,12 +97,17 @@ import {
|
|
|
76
97
|
LOCAL_SKILLS_PATH,
|
|
77
98
|
MIN_TERMINAL_SIZE,
|
|
78
99
|
PROVIDERS,
|
|
100
|
+
SEED_API_URL,
|
|
79
101
|
STANDARD_FILES,
|
|
80
102
|
externalIdsNamingNoDirectory,
|
|
81
103
|
isActiveAt,
|
|
104
|
+
isExclusiveCategory,
|
|
82
105
|
orderDomains,
|
|
83
|
-
seedExternalSkillSchema
|
|
84
|
-
|
|
106
|
+
seedExternalSkillSchema,
|
|
107
|
+
seedPayloadSchema,
|
|
108
|
+
typedEntries,
|
|
109
|
+
typedValues
|
|
110
|
+
} from "./chunk-4SIBDIIO.js";
|
|
85
111
|
|
|
86
112
|
// src/cli/utils/terminal.ts
|
|
87
113
|
function clearTerminalScreen() {
|
|
@@ -103,8 +129,8 @@ var EXIT_CODES = {
|
|
|
103
129
|
NETWORK_ERROR: 3,
|
|
104
130
|
CANCELLED: 4,
|
|
105
131
|
/**
|
|
106
|
-
* Ran to the end but part of the work failed.
|
|
107
|
-
*
|
|
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.
|
|
108
134
|
*/
|
|
109
135
|
COMPLETED_WITH_FAILURES: 5
|
|
110
136
|
};
|
|
@@ -161,14 +187,24 @@ async function refuseAnAmbiguousInstallation(cwd, subject, named, onAmbiguous) {
|
|
|
161
187
|
if (providers.length <= 1) return;
|
|
162
188
|
onAmbiguous(ambiguousInstallation(subject, providers, scopeRoot));
|
|
163
189
|
}
|
|
164
|
-
async function
|
|
190
|
+
async function holdsOnlyAConfigDeclaringNothing(cwd) {
|
|
165
191
|
if (!await holdsAConfigDeclaringNothing(cwd)) return false;
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
192
|
+
return atScope(await detectInstallations(cwd), "project").length === 0;
|
|
193
|
+
}
|
|
194
|
+
async function homeHoldsAnInstallationFor(cwd, named) {
|
|
195
|
+
const atHome = providersOf(atScope(await detectInstallations(cwd), "global")).filter(
|
|
169
196
|
(provider) => named === void 0 || provider === named
|
|
170
197
|
);
|
|
171
|
-
|
|
198
|
+
const declaringContent = await Promise.all(atHome.map(homeConfigDeclaresContent));
|
|
199
|
+
return declaringContent.includes(true);
|
|
200
|
+
}
|
|
201
|
+
async function homeConfigDeclaresContent(provider) {
|
|
202
|
+
try {
|
|
203
|
+
return !await configDeclaresNothing(os.homedir(), provider);
|
|
204
|
+
} catch (error) {
|
|
205
|
+
if (error instanceof ConfigLoadError) return true;
|
|
206
|
+
throw error;
|
|
207
|
+
}
|
|
172
208
|
}
|
|
173
209
|
async function providersInPlay(cwd) {
|
|
174
210
|
return (await installationsInPlay(cwd)).providers;
|
|
@@ -296,7 +332,7 @@ function shippedMetadata(files) {
|
|
|
296
332
|
const shipped = files[STANDARD_FILES.METADATA_YAML];
|
|
297
333
|
if (shipped === void 0) return null;
|
|
298
334
|
const parsed = parsedYaml(shipped);
|
|
299
|
-
return
|
|
335
|
+
return isKeyedRecord(parsed) && hasReadableProvenance(parsed) ? parsed : null;
|
|
300
336
|
}
|
|
301
337
|
function parsedYaml(text) {
|
|
302
338
|
try {
|
|
@@ -305,13 +341,12 @@ function parsedYaml(text) {
|
|
|
305
341
|
return void 0;
|
|
306
342
|
}
|
|
307
343
|
}
|
|
308
|
-
var isMapping = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
309
344
|
var PROVENANCE_REQUIRED = ["skillId", "contentHash", "date"];
|
|
310
345
|
var PROVENANCE_OPTIONAL = ["source", "path"];
|
|
311
346
|
function hasReadableProvenance(metadata) {
|
|
312
347
|
if (!Object.hasOwn(metadata, "forkedFrom")) return true;
|
|
313
348
|
const provenance = metadata.forkedFrom;
|
|
314
|
-
return
|
|
349
|
+
return isKeyedRecord(provenance) && PROVENANCE_REQUIRED.every((key) => typeof provenance[key] === "string") && PROVENANCE_OPTIONAL.every(
|
|
315
350
|
(key) => !Object.hasOwn(provenance, key) || typeof provenance[key] === "string"
|
|
316
351
|
);
|
|
317
352
|
}
|
|
@@ -336,10 +371,17 @@ var hexOf = (bytes) => Array.from(bytes, (byte) => byte.toString(16).padStart(2,
|
|
|
336
371
|
|
|
337
372
|
// src/cli/lib/seed/external-skills.ts
|
|
338
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
|
+
];
|
|
339
381
|
return [
|
|
340
|
-
|
|
382
|
+
`This configuration cannot be installed: ${refused}:`,
|
|
341
383
|
...ids.map((id) => ` ${id}`),
|
|
342
|
-
|
|
384
|
+
`Re-share it with ${reshared} set to eject, which is the only way a carried skill installs.`
|
|
343
385
|
].join("\n");
|
|
344
386
|
}
|
|
345
387
|
function selectedExternals(payload) {
|
|
@@ -354,7 +396,6 @@ function askedForAsPlugin(externals) {
|
|
|
354
396
|
function claimingACatalogueId(externals, matrix2) {
|
|
355
397
|
return externals.filter(({ id }) => heldByEitherCatalogue(id, matrix2)).map(({ id }) => id);
|
|
356
398
|
}
|
|
357
|
-
var CATALOGUE_SKILL_IDS = new Set(typedKeys(BUILT_IN_MATRIX.skills));
|
|
358
399
|
function heldByEitherCatalogue(id, matrix2) {
|
|
359
400
|
return heldByLoadedCatalogue(matrix2.skills[id]) || CATALOGUE_SKILL_IDS.has(id);
|
|
360
401
|
}
|
|
@@ -362,10 +403,19 @@ function heldByLoadedCatalogue(incumbent) {
|
|
|
362
403
|
return incumbent !== void 0 && incumbent.local !== true;
|
|
363
404
|
}
|
|
364
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
|
+
];
|
|
365
415
|
return [
|
|
366
|
-
|
|
416
|
+
`This configuration cannot be installed: ${refused}:`,
|
|
367
417
|
...ids.map((id) => ` ${id}`),
|
|
368
|
-
|
|
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.`
|
|
369
419
|
].join("\n");
|
|
370
420
|
}
|
|
371
421
|
function externalSlug(id) {
|
|
@@ -408,10 +458,17 @@ function seatExternalSkill({ id, skill, entry }, matrix2, projectDir) {
|
|
|
408
458
|
return [install];
|
|
409
459
|
}
|
|
410
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
|
+
];
|
|
411
468
|
return [
|
|
412
|
-
|
|
469
|
+
`This configuration cannot be installed: ${refused}:`,
|
|
413
470
|
...ids.map((id) => ` ${JSON.stringify(id)}`),
|
|
414
|
-
|
|
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.`
|
|
415
472
|
].join("\n");
|
|
416
473
|
}
|
|
417
474
|
var DIRECTORY_NAME_MAX_BYTES = 255;
|
|
@@ -422,10 +479,37 @@ function externalIdsTooLongForADirectory(payload) {
|
|
|
422
479
|
return Object.keys(payload.external ?? {}).filter(overrunsADirectoryName);
|
|
423
480
|
}
|
|
424
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
|
+
];
|
|
425
491
|
return [
|
|
426
|
-
|
|
492
|
+
`This configuration cannot be installed: ${refused}:`,
|
|
427
493
|
...ids.map((id) => ` ${JSON.stringify(id)}`),
|
|
428
|
-
`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
|
|
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}.`
|
|
495
|
+
].join("\n");
|
|
496
|
+
}
|
|
497
|
+
var CARRIED_ID_PREFIX = "external-";
|
|
498
|
+
function externalIdsLackingThePrefix(payload) {
|
|
499
|
+
return Object.keys(payload.external ?? {}).filter((id) => !id.startsWith(CARRIED_ID_PREFIX));
|
|
500
|
+
}
|
|
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
|
+
];
|
|
509
|
+
return [
|
|
510
|
+
`This configuration cannot be installed: ${refused}:`,
|
|
511
|
+
...ids.map((id) => ` ${id}`),
|
|
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>'.`
|
|
429
513
|
].join("\n");
|
|
430
514
|
}
|
|
431
515
|
function registerExternalSkills(payload, matrix2, projectDir) {
|
|
@@ -433,6 +517,8 @@ function registerExternalSkills(payload, matrix2, projectDir) {
|
|
|
433
517
|
if (notDirectoryNames.length > 0) throw new Error(notADirectoryNameError(notDirectoryNames));
|
|
434
518
|
const tooLong = externalIdsTooLongForADirectory(payload);
|
|
435
519
|
if (tooLong.length > 0) throw new Error(tooLongForADirectoryError(tooLong));
|
|
520
|
+
const unprefixed = externalIdsLackingThePrefix(payload);
|
|
521
|
+
if (unprefixed.length > 0) throw new Error(lacksThePrefixError(unprefixed));
|
|
436
522
|
const externals = selectedExternals(payload);
|
|
437
523
|
const asPlugin = askedForAsPlugin(externals);
|
|
438
524
|
const colliding = claimingACatalogueId(externals, matrix2);
|
|
@@ -489,8 +575,10 @@ async function treeToWrite(install) {
|
|
|
489
575
|
async function treeAsInstalled(install, shipped) {
|
|
490
576
|
const recorded = (await readForkedFromMetadata(install.skillDir))?.date;
|
|
491
577
|
if (recorded === void 0) return null;
|
|
492
|
-
const tree = await
|
|
493
|
-
|
|
578
|
+
const [tree, onDisk] = await Promise.all([
|
|
579
|
+
carriedTree(install, shipped, recorded),
|
|
580
|
+
metadataOnDisk(install)
|
|
581
|
+
]);
|
|
494
582
|
return tree[STANDARD_FILES.METADATA_YAML] === onDisk ? tree : null;
|
|
495
583
|
}
|
|
496
584
|
function carriedTree(install, skill, date) {
|
|
@@ -504,13 +592,16 @@ function carriedTree(install, skill, date) {
|
|
|
504
592
|
}
|
|
505
593
|
async function withShippedMetadata(install) {
|
|
506
594
|
if (Object.hasOwn(install.skill.files, STANDARD_FILES.METADATA_YAML)) return install.skill;
|
|
507
|
-
const onDisk = await
|
|
595
|
+
const onDisk = await metadataOnDisk(install);
|
|
508
596
|
if (onDisk === null) return install.skill;
|
|
509
597
|
return {
|
|
510
598
|
...install.skill,
|
|
511
599
|
files: { ...install.skill.files, [STANDARD_FILES.METADATA_YAML]: onDisk }
|
|
512
600
|
};
|
|
513
601
|
}
|
|
602
|
+
function metadataOnDisk(install) {
|
|
603
|
+
return bytesOnDisk(path.join(install.skillDir, STANDARD_FILES.METADATA_YAML));
|
|
604
|
+
}
|
|
514
605
|
async function bytesOnDisk(filePath) {
|
|
515
606
|
return await fileExists(filePath) ? readFile(filePath) : null;
|
|
516
607
|
}
|
|
@@ -531,10 +622,21 @@ async function judgeDestination(install) {
|
|
|
531
622
|
return { id, skillDir };
|
|
532
623
|
}
|
|
533
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
|
+
];
|
|
534
636
|
return [
|
|
535
|
-
|
|
637
|
+
`This configuration cannot be installed: ${refused}:`,
|
|
536
638
|
...blocked.map(({ id, skillDir }) => ` ${id} -> ${skillDir}`),
|
|
537
|
-
|
|
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.`
|
|
538
640
|
].join("\n");
|
|
539
641
|
}
|
|
540
642
|
function unnameableRepoMessage(id) {
|
|
@@ -600,11 +702,7 @@ async function readCarriedSkills(owned) {
|
|
|
600
702
|
|
|
601
703
|
// src/cli/lib/seed/seed-apply.ts
|
|
602
704
|
import os3 from "os";
|
|
603
|
-
import {
|
|
604
|
-
var NOTHING_KEPT = {
|
|
605
|
-
authoredSkillIds: [],
|
|
606
|
-
unplaceableSkillIds: []
|
|
607
|
-
};
|
|
705
|
+
import { isDeepEqual, omit, partition, pick } from "remeda";
|
|
608
706
|
function reconcileSharedConfig(options) {
|
|
609
707
|
const { decoded, installed } = options;
|
|
610
708
|
if (!installed) return nothingToReconcile(decoded);
|
|
@@ -614,7 +712,11 @@ function reconcileSharedConfig(options) {
|
|
|
614
712
|
return { result, kept: describeKept(options, keptSkills), unassigned };
|
|
615
713
|
}
|
|
616
714
|
function nothingToReconcile(decoded) {
|
|
617
|
-
return {
|
|
715
|
+
return {
|
|
716
|
+
result: decoded,
|
|
717
|
+
kept: { authoredSkillIds: [], unplaceableSkillIds: [] },
|
|
718
|
+
unassigned: []
|
|
719
|
+
};
|
|
618
720
|
}
|
|
619
721
|
function skillsToKeep(options, installed) {
|
|
620
722
|
const named = new Set(options.decoded.skills.map((skill) => skill.id));
|
|
@@ -679,16 +781,14 @@ async function readInstalledGlobal(projectDir) {
|
|
|
679
781
|
const loaded = await loadProjectConfigFromDir(os3.homedir(), providerInUse(projectDir));
|
|
680
782
|
return loaded?.config ?? null;
|
|
681
783
|
}
|
|
682
|
-
|
|
784
|
+
function runFromHomeFor(decoded, id, projectDir) {
|
|
785
|
+
return {
|
|
786
|
+
id: installsAtHome(decoded) ? id : void 0,
|
|
787
|
+
provider: providerToNameAt(os3.homedir(), providerInUse(projectDir))
|
|
788
|
+
};
|
|
789
|
+
}
|
|
683
790
|
function holdInstalledGlobal(decoded, installed) {
|
|
684
|
-
if (!installed)
|
|
685
|
-
return {
|
|
686
|
-
result: decoded,
|
|
687
|
-
installed: NO_GLOBAL_ENTRIES,
|
|
688
|
-
keptAsInstalled: NO_GLOBAL_ENTRIES,
|
|
689
|
-
joined: []
|
|
690
|
-
};
|
|
691
|
-
}
|
|
791
|
+
if (!installed) return nothingHeld(decoded);
|
|
692
792
|
const heldSkills = activeGlobalById(installed.skills, (skill) => skill.id);
|
|
693
793
|
const heldAgents = activeGlobalById(installed.agents, (agent) => agent.name);
|
|
694
794
|
const skills = pairWithHeld(decoded.skills, heldSkills, (skill) => skill.id);
|
|
@@ -718,6 +818,14 @@ function holdInstalledGlobal(decoded, installed) {
|
|
|
718
818
|
joined
|
|
719
819
|
};
|
|
720
820
|
}
|
|
821
|
+
function nothingHeld(decoded) {
|
|
822
|
+
return {
|
|
823
|
+
result: decoded,
|
|
824
|
+
installed: { skillIds: [], agentNames: [] },
|
|
825
|
+
keptAsInstalled: { skillIds: [], agentNames: [] },
|
|
826
|
+
joined: []
|
|
827
|
+
};
|
|
828
|
+
}
|
|
721
829
|
function skillsKeptAsInstalled(pairs) {
|
|
722
830
|
return pairs.filter((pair) => !restatesSkill(pair)).map(({ named }) => named.id);
|
|
723
831
|
}
|
|
@@ -801,9 +909,8 @@ function rowIds(agentStack) {
|
|
|
801
909
|
);
|
|
802
910
|
}
|
|
803
911
|
function filledExclusiveCategories(agentStack) {
|
|
804
|
-
const isExclusive = (category) => matrix.categories[category]?.exclusive === true;
|
|
805
912
|
return new Set(
|
|
806
|
-
typedEntries(agentStack ?? {}).filter(([category, rows]) => rows.length > 0 &&
|
|
913
|
+
typedEntries(agentStack ?? {}).filter(([category, rows]) => rows.length > 0 && isExclusiveCategory(matrix, category)).map(([category]) => category)
|
|
807
914
|
);
|
|
808
915
|
}
|
|
809
916
|
function withAppendedRows(stack, agentName, added) {
|
|
@@ -855,13 +962,26 @@ function entriesActiveAt(skills, agents, scope) {
|
|
|
855
962
|
};
|
|
856
963
|
}
|
|
857
964
|
function panelRowEntries(held) {
|
|
858
|
-
|
|
859
|
-
return indexBy(active, (skill) => skill.id);
|
|
965
|
+
return namedByActiveEntries(held.result.skills);
|
|
860
966
|
}
|
|
861
967
|
function joinedStatement(held) {
|
|
862
968
|
if (held.joined.length === 0) return [];
|
|
863
969
|
return [addedToGlobalSubAgents(held.joined, panelRowEntries(held))];
|
|
864
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
|
+
}
|
|
865
985
|
function projectScopedContent(result) {
|
|
866
986
|
return entriesActiveAt(result.skills, result.agentConfigs, "project");
|
|
867
987
|
}
|
|
@@ -875,22 +995,607 @@ import { Command } from "@oclif/core";
|
|
|
875
995
|
import chalk from "chalk";
|
|
876
996
|
import { unique } from "remeda";
|
|
877
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
|
+
|
|
878
1565
|
// src/cli/lib/operations/source/ensure-marketplace.ts
|
|
879
1566
|
async function ensureMarketplace(sourceResult, host) {
|
|
880
1567
|
const marketplace = await resolveMarketplaceName(sourceResult);
|
|
881
|
-
if (marketplace === null) return { marketplace: null, registered: false };
|
|
1568
|
+
if (marketplace === null) return { marketplace: null, registered: false, leftOn: [] };
|
|
882
1569
|
const exists = await host.marketplaceExists(marketplace);
|
|
883
1570
|
if (!exists) {
|
|
884
1571
|
const marketplaceSource = sourceResult.sourceConfig.source.replace(/^github:/, "");
|
|
885
1572
|
await host.addMarketplace(marketplaceSource);
|
|
886
|
-
return { marketplace, registered: true };
|
|
1573
|
+
return { marketplace, registered: true, leftOn: [] };
|
|
887
1574
|
}
|
|
1575
|
+
const outcome = await refreshOutcome(marketplace, host);
|
|
1576
|
+
warnOfShortfalls(outcome);
|
|
1577
|
+
return { marketplace, registered: false, leftOn: outcome.leftOn };
|
|
1578
|
+
}
|
|
1579
|
+
async function refreshOutcome(marketplace, host) {
|
|
888
1580
|
try {
|
|
889
1581
|
await host.refreshMarketplace(marketplace);
|
|
890
|
-
|
|
891
|
-
|
|
1582
|
+
return { refreshed: true, leftOn: [] };
|
|
1583
|
+
} catch (error) {
|
|
1584
|
+
return outcomeOfRefusal(error);
|
|
1585
|
+
}
|
|
1586
|
+
}
|
|
1587
|
+
function outcomeOfRefusal(error) {
|
|
1588
|
+
if (error instanceof PluginsLeftSwitchedOnError) return { refreshed: true, leftOn: error.leftOn };
|
|
1589
|
+
if (error instanceof FailedLeavingPluginsSwitchedOnError) {
|
|
1590
|
+
return { refreshed: false, leftOn: error.leftOn };
|
|
1591
|
+
}
|
|
1592
|
+
return { refreshed: false, leftOn: [] };
|
|
1593
|
+
}
|
|
1594
|
+
function warnOfShortfalls({ refreshed, leftOn }) {
|
|
1595
|
+
if (!refreshed) warn("Could not update marketplace \u2014 continuing with cached version");
|
|
1596
|
+
for (const { pluginKey, configFile, reason } of leftOn) {
|
|
1597
|
+
warn(codexPluginLeftSwitchedOn(pluginKey, configFile, reason));
|
|
892
1598
|
}
|
|
893
|
-
return { marketplace, registered: false };
|
|
894
1599
|
}
|
|
895
1600
|
async function resolveMarketplaceName(sourceResult) {
|
|
896
1601
|
if (sourceResult.marketplace) return sourceResult.marketplace;
|
|
@@ -914,18 +1619,24 @@ async function requireMarketplace(sourceResult, purpose, host) {
|
|
|
914
1619
|
error: `Cannot ${purpose}: marketplace could not be resolved from '${sourceResult.sourceConfig.source}'. Plugin install mode requires a marketplace \u2014 fix the marketplace or switch the affected skills to eject mode.`
|
|
915
1620
|
};
|
|
916
1621
|
}
|
|
917
|
-
return {
|
|
1622
|
+
return {
|
|
1623
|
+
ok: true,
|
|
1624
|
+
marketplace: mpResult.marketplace,
|
|
1625
|
+
registered: mpResult.registered,
|
|
1626
|
+
leftOn: mpResult.leftOn
|
|
1627
|
+
};
|
|
918
1628
|
}
|
|
919
1629
|
|
|
920
1630
|
// src/cli/lib/operations/skills/install-plugin-skills.ts
|
|
921
1631
|
function pluginInstallFailureError(failedCount) {
|
|
922
|
-
return `Failed to install ${failedCount
|
|
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.`;
|
|
923
1633
|
}
|
|
924
1634
|
function unbackedPluginSkillIds(skills, matrix2) {
|
|
925
1635
|
return skills.filter((skill) => skill.origin !== EJECT_SOURCE).filter((skill) => isLocalOnlySkill(matrix2.skills[skill.id])).map((skill) => skill.id);
|
|
926
1636
|
}
|
|
927
1637
|
function unbackedPluginInstallError(ids) {
|
|
928
|
-
|
|
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.`;
|
|
929
1640
|
}
|
|
930
1641
|
async function installPluginSkills(skills, marketplace, projectDir) {
|
|
931
1642
|
const host = hostAt(projectDir);
|
|
@@ -948,6 +1659,10 @@ async function installPluginSkills(skills, marketplace, projectDir) {
|
|
|
948
1659
|
var TERMINAL_RESIZE_POLL_MS = 500;
|
|
949
1660
|
var terminalColumns = () => process.stdout.columns ?? MIN_TERMINAL_SIZE.COLS;
|
|
950
1661
|
var terminalRows = () => process.stdout.rows ?? MIN_TERMINAL_SIZE.ROWS;
|
|
1662
|
+
function sayFirst(line) {
|
|
1663
|
+
process.stderr.write(`${line}
|
|
1664
|
+
`);
|
|
1665
|
+
}
|
|
951
1666
|
function isTerminalBigEnough() {
|
|
952
1667
|
return isTerminalLargeEnough(terminalColumns(), terminalRows());
|
|
953
1668
|
}
|
|
@@ -963,6 +1678,13 @@ function waitForTerminal(isSatisfied) {
|
|
|
963
1678
|
process.stdout.on("resize", check);
|
|
964
1679
|
});
|
|
965
1680
|
}
|
|
1681
|
+
function switchOwed({ pluginKey, configFile }) {
|
|
1682
|
+
return {
|
|
1683
|
+
what: pluginNotSwitchedBackOff(pluginKey),
|
|
1684
|
+
recovery: switchItOffIn(configFile),
|
|
1685
|
+
pluginSwitch: true
|
|
1686
|
+
};
|
|
1687
|
+
}
|
|
966
1688
|
function findUnassignedSkills(config, selected) {
|
|
967
1689
|
const assignedIds = new Set(config.stack ? getStackSkillIds(config.stack) : []);
|
|
968
1690
|
const selectedIds = new Set(selected.map((skill) => skill.id));
|
|
@@ -985,15 +1707,15 @@ var BaseCommand = class extends Command {
|
|
|
985
1707
|
await super.init();
|
|
986
1708
|
await this.ensureTerminalSize();
|
|
987
1709
|
}
|
|
988
|
-
/**
|
|
989
|
-
* Called first where a command starts work on the installation in play, which for a project whose
|
|
990
|
-
* config declares nothing is the global one. On stderr, as the init hook's old-folder lines are,
|
|
991
|
-
* so piped output is unchanged.
|
|
992
|
-
*/
|
|
993
1710
|
async sayWhenTheGlobalInstallationStandsIn(named) {
|
|
994
|
-
if (!await
|
|
995
|
-
process.
|
|
996
|
-
|
|
1711
|
+
if (!await holdsOnlyAConfigDeclaringNothing(process.cwd())) return;
|
|
1712
|
+
const standsIn = await homeHoldsAnInstallationFor(process.cwd(), named);
|
|
1713
|
+
sayFirst(
|
|
1714
|
+
standsIn ? INFO_MESSAGES.GLOBAL_INSTALLATION_STANDS_IN : INFO_MESSAGES.NO_GLOBAL_INSTALLATION_STANDS_IN
|
|
1715
|
+
);
|
|
1716
|
+
}
|
|
1717
|
+
async sayWhenTheProjectsConfigDeclaresNothing(line) {
|
|
1718
|
+
if (await holdsOnlyAConfigDeclaringNothing(process.cwd())) sayFirst(line);
|
|
997
1719
|
}
|
|
998
1720
|
async ensureTerminalSize() {
|
|
999
1721
|
if (isTerminalBigEnough()) return;
|
|
@@ -1027,6 +1749,7 @@ var BaseCommand = class extends Command {
|
|
|
1027
1749
|
if (!required.ok) {
|
|
1028
1750
|
this.error(required.error, { exit: EXIT_CODES.ERROR });
|
|
1029
1751
|
}
|
|
1752
|
+
this.recordPluginsLeftSwitchedOn(required.leftOn);
|
|
1030
1753
|
if (required.registered) {
|
|
1031
1754
|
onRegistered?.(required.marketplace);
|
|
1032
1755
|
}
|
|
@@ -1090,13 +1813,22 @@ var BaseCommand = class extends Command {
|
|
|
1090
1813
|
this.log(propagatedRecompileSummary(rewrittenCount + unchangedCount, failedCount));
|
|
1091
1814
|
}
|
|
1092
1815
|
reportUnassignedSkills(config, selected) {
|
|
1816
|
+
const namedBy = namedByActiveEntries(selected);
|
|
1093
1817
|
for (const { skillId, blockedBy } of findUnassignedSkills(config, selected)) {
|
|
1094
|
-
this.warn(skillAssignedToNoAgent(skillId));
|
|
1818
|
+
this.warn(skillAssignedToNoAgent(skillId, namedBy));
|
|
1095
1819
|
if (blockedBy.length > 0) {
|
|
1096
|
-
this.warn(scopeBlockedStackAssignment(blockedBy, skillId));
|
|
1820
|
+
this.warn(scopeBlockedStackAssignment(blockedBy, skillId, namedBy));
|
|
1097
1821
|
}
|
|
1098
1822
|
}
|
|
1099
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
|
+
}
|
|
1100
1832
|
/**
|
|
1101
1833
|
* Aborts up front when the project or global config exists but cannot be loaded, so nothing is
|
|
1102
1834
|
* installed before the config write fails. A missing config passes.
|
|
@@ -1107,6 +1839,21 @@ var BaseCommand = class extends Command {
|
|
|
1107
1839
|
this.error(installationConfigsUnreadable(failures), { exit: EXIT_CODES.ERROR });
|
|
1108
1840
|
}
|
|
1109
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
|
+
}
|
|
1110
1857
|
/** Only entries the catalogue lacks are checked; one whose files are gone is not refused. */
|
|
1111
1858
|
async ensureSavedSkillsReadable(savedSkills, matrix2, projectDir) {
|
|
1112
1859
|
const unresolved = savedSkills.filter((saved) => !matrix2.skills[saved.id]);
|
|
@@ -1119,6 +1866,10 @@ var BaseCommand = class extends Command {
|
|
|
1119
1866
|
async refuseUnusableSavedSkillMetadata(savedSkills, projectDir, refusal) {
|
|
1120
1867
|
const unusable = await findUnusableSavedSkillMetadata(savedSkills, projectDir);
|
|
1121
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) {
|
|
1122
1873
|
for (const entry of unusable) {
|
|
1123
1874
|
this.log(skillMetadataUnusableDetail(entry));
|
|
1124
1875
|
}
|
|
@@ -1133,9 +1884,11 @@ var BaseCommand = class extends Command {
|
|
|
1133
1884
|
if (!isHomeDirectory(projectDir) || installsAtHome(result)) return;
|
|
1134
1885
|
const { skillIds, agentNames } = projectScopedContent(result);
|
|
1135
1886
|
const provider = providerToNameAt(projectDir, providerInUse(projectDir));
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1887
|
+
const namedBy = namedByActiveEntries(result.skills);
|
|
1888
|
+
this.error(
|
|
1889
|
+
sharedConfigProjectScopeAtHome(skillIds, agentNames, installedHere, provider, namedBy),
|
|
1890
|
+
{ exit: EXIT_CODES.ERROR }
|
|
1891
|
+
);
|
|
1139
1892
|
}
|
|
1140
1893
|
/** `unloadedSkillIds`: skills the marketplace ships and could not load, never unknown ones. */
|
|
1141
1894
|
warnOfSkippedEntries(mapping, unloadedSkillIds) {
|
|
@@ -1145,6 +1898,71 @@ var BaseCommand = class extends Command {
|
|
|
1145
1898
|
}
|
|
1146
1899
|
if (skippedAgentNames.length > 0) this.warn(skippedUnknownAgents(skippedAgentNames));
|
|
1147
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
|
+
}
|
|
1148
1966
|
/** For the panel's header; `undefined` for a configuration built from no stack. */
|
|
1149
1967
|
async stackNameOf(stackId, sourceResult) {
|
|
1150
1968
|
if (!stackId) return void 0;
|
|
@@ -1177,6 +1995,9 @@ var BaseCommand = class extends Command {
|
|
|
1177
1995
|
get hasIncompleteWork() {
|
|
1178
1996
|
return this.incompleteWork.length > 0;
|
|
1179
1997
|
}
|
|
1998
|
+
get owesWorkBesidesPluginSwitches() {
|
|
1999
|
+
return this.incompleteWork.some(({ pluginSwitch }) => !pluginSwitch);
|
|
2000
|
+
}
|
|
1180
2001
|
/** Never aborts: every caller is past a mutation that has already landed. */
|
|
1181
2002
|
reportIncompleteWork(what, recovery) {
|
|
1182
2003
|
this.warn(what);
|
|
@@ -1184,15 +2005,22 @@ var BaseCommand = class extends Command {
|
|
|
1184
2005
|
}
|
|
1185
2006
|
/** For a caller that has already warned. */
|
|
1186
2007
|
recordIncompleteWork(what, recovery) {
|
|
1187
|
-
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));
|
|
1188
2013
|
}
|
|
1189
2014
|
/** Every command that records must call this; `this.exit` skips the `Error:` framing. */
|
|
1190
2015
|
exitIfWorkIncomplete() {
|
|
1191
2016
|
if (!this.hasIncompleteWork) return;
|
|
2017
|
+
this.listIncompleteWork();
|
|
2018
|
+
this.exit(EXIT_CODES.COMPLETED_WITH_FAILURES);
|
|
2019
|
+
}
|
|
2020
|
+
listIncompleteWork() {
|
|
1192
2021
|
this.log(`
|
|
1193
2022
|
${chalk.hex(CLI_COLORS.WARNING)(completedWithFailures(this.incompleteWork))}
|
|
1194
2023
|
`);
|
|
1195
|
-
this.exit(EXIT_CODES.COMPLETED_WITH_FAILURES);
|
|
1196
2024
|
}
|
|
1197
2025
|
};
|
|
1198
2026
|
|
|
@@ -1203,23 +2031,24 @@ export {
|
|
|
1203
2031
|
providerNamedBy,
|
|
1204
2032
|
providerNamedIn,
|
|
1205
2033
|
providerNeedsAConfigurationToInstall,
|
|
1206
|
-
refuseAnAmbiguousInstallation,
|
|
1207
|
-
installationToName,
|
|
1208
2034
|
ambiguityFinding,
|
|
1209
2035
|
otherInstallationsInThisScope,
|
|
1210
|
-
|
|
1211
|
-
|
|
2036
|
+
placementsAskedIn,
|
|
2037
|
+
refusalsAmong,
|
|
2038
|
+
externalIdsLackingThePrefix,
|
|
2039
|
+
lacksThePrefixError,
|
|
1212
2040
|
carriedSkillsThatDiffer,
|
|
1213
2041
|
readCarriedSkills,
|
|
1214
2042
|
reconcileSharedConfig,
|
|
1215
2043
|
readInstalledGlobal,
|
|
2044
|
+
runFromHomeFor,
|
|
1216
2045
|
holdInstalledGlobal,
|
|
1217
2046
|
restoreInstalledGlobal,
|
|
1218
2047
|
sameAssignments,
|
|
1219
2048
|
notInstalledGlobally,
|
|
1220
2049
|
panelRowEntries,
|
|
1221
2050
|
joinedStatement,
|
|
1222
|
-
|
|
2051
|
+
keptAsInstalledStatement,
|
|
1223
2052
|
BaseCommand
|
|
1224
2053
|
};
|
|
1225
|
-
//# sourceMappingURL=chunk-
|
|
2054
|
+
//# sourceMappingURL=chunk-E6W3PYGF.js.map
|