agents-inc 0.167.0 → 0.170.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 +31 -0
- package/README.md +18 -15
- package/dist/{chunk-ZR4YPKXQ.js → chunk-3G7X2WKI.js} +4 -4
- package/dist/{chunk-JOEA52NR.js → chunk-44TE3RKH.js} +46 -2
- package/dist/chunk-44TE3RKH.js.map +1 -0
- package/dist/{chunk-V5WXIM2F.js → chunk-52HDHJ7I.js} +11 -19
- package/dist/chunk-52HDHJ7I.js.map +1 -0
- package/dist/{chunk-V3I7VQ7N.js → chunk-6HNXYYVF.js} +39 -22
- package/dist/chunk-6HNXYYVF.js.map +1 -0
- package/dist/{chunk-MAWNVT2C.js → chunk-6ZRH5RHC.js} +10 -11
- package/dist/chunk-6ZRH5RHC.js.map +1 -0
- package/dist/{chunk-G6UREQ4V.js → chunk-7RDMTR64.js} +14 -34
- package/dist/chunk-7RDMTR64.js.map +1 -0
- package/dist/{chunk-GE3WKJ6Q.js → chunk-BMRUNMPV.js} +4 -4
- package/dist/{chunk-VAPTVR3J.js → chunk-CLPUWOSA.js} +4 -4
- package/dist/{chunk-VAPTVR3J.js.map → chunk-CLPUWOSA.js.map} +1 -1
- package/dist/{chunk-HWEKHVLE.js → chunk-F2BHT5C4.js} +9 -7
- package/dist/chunk-F2BHT5C4.js.map +1 -0
- package/dist/{chunk-ZXKBERQU.js → chunk-F5EBEATU.js} +2 -2
- package/dist/{chunk-PMJWD27C.js → chunk-HED2DAXZ.js} +3 -3
- package/dist/{chunk-SAYZWCH6.js → chunk-KOLDW6SF.js} +3 -3
- package/dist/{chunk-SAYZWCH6.js.map → chunk-KOLDW6SF.js.map} +1 -1
- package/dist/{chunk-A4KDXNOT.js → chunk-MQ6CGZNJ.js} +171 -522
- package/dist/chunk-MQ6CGZNJ.js.map +1 -0
- package/dist/{chunk-G4JK7WVO.js → chunk-NCWDK6L7.js} +115 -196
- package/dist/chunk-NCWDK6L7.js.map +1 -0
- package/dist/{chunk-VRXX4D6K.js → chunk-NEZ4OAOL.js} +1 -1
- package/dist/chunk-NEZ4OAOL.js.map +1 -0
- package/dist/chunk-NIHUOWE4.js +106 -0
- package/dist/chunk-NIHUOWE4.js.map +1 -0
- package/dist/{chunk-OI2H6M5I.js → chunk-NQW25DCF.js} +2 -2
- package/dist/chunk-NQW25DCF.js.map +1 -0
- package/dist/{chunk-25MPBIK3.js → chunk-OYJQUA3D.js} +3 -3
- package/dist/{chunk-25MPBIK3.js.map → chunk-OYJQUA3D.js.map} +1 -1
- package/dist/{chunk-ENGYJCTF.js → chunk-PJWGTNOX.js} +220 -254
- package/dist/chunk-PJWGTNOX.js.map +1 -0
- package/dist/{chunk-NBXXFIIW.js → chunk-RIPSGNLU.js} +3 -3
- package/dist/chunk-RIPSGNLU.js.map +1 -0
- package/dist/{chunk-Y47EV74W.js → chunk-SZYQISA2.js} +10 -13
- package/dist/chunk-SZYQISA2.js.map +1 -0
- package/dist/{chunk-TODCQFRB.js → chunk-USVBYQSQ.js} +2 -2
- package/dist/{chunk-Y3VIRVVE.js → chunk-V3KTSP3Q.js} +50 -42
- package/dist/chunk-V3KTSP3Q.js.map +1 -0
- package/dist/{chunk-PXWG7KFO.js → chunk-WTWMGH2C.js} +2 -2
- package/dist/commands/build/marketplace.js +23 -22
- package/dist/commands/build/marketplace.js.map +1 -1
- package/dist/commands/build/plugins.js +8 -9
- package/dist/commands/build/plugins.js.map +1 -1
- package/dist/commands/compile.js +19 -20
- package/dist/commands/compile.js.map +1 -1
- package/dist/commands/doctor.js +17 -18
- package/dist/commands/doctor.js.map +1 -1
- package/dist/commands/edit.js +138 -488
- package/dist/commands/edit.js.map +1 -1
- package/dist/commands/eject.js +21 -33
- package/dist/commands/eject.js.map +1 -1
- package/dist/commands/init.js +17 -45
- package/dist/commands/list.js +19 -17
- package/dist/commands/list.js.map +1 -1
- package/dist/commands/new/marketplace.js +11 -11
- package/dist/commands/new/marketplace.js.map +1 -1
- package/dist/commands/search.js +12 -13
- package/dist/commands/search.js.map +1 -1
- package/dist/commands/share.js +11 -12
- package/dist/commands/share.js.map +1 -1
- package/dist/commands/uninstall.js +18 -20
- package/dist/commands/uninstall.js.map +1 -1
- package/dist/commands/update.js +8 -9
- package/dist/commands/update.js.map +1 -1
- package/dist/components/common/removal-plan-confirm.js +2 -2
- package/dist/components/common/scroll-affordance.js +9 -0
- package/dist/components/common/select-list.js +2 -3
- package/dist/components/common/skill-agent-summary.js +11 -0
- package/dist/components/common/spinner.js +1 -1
- package/dist/{chunk-2VUYFTUB.js → components/common/summary-panel.js} +57 -31
- package/dist/components/common/summary-panel.js.map +1 -0
- package/dist/config-exports.js +1 -1
- package/dist/hooks/init.js +18 -46
- package/dist/hooks/init.js.map +1 -1
- package/dist/load-agent-defs-YMDWBFDP.js +14 -0
- package/dist/recompile-project-agents-SZ76WNTW.js +18 -0
- package/dist/{source-loader-7KZ3MD5O.js → source-loader-C5SQXZXI.js} +5 -5
- package/dist/src/agents/meta/codex-keeper/playbook.md +2 -3
- package/package.json +6 -4
- package/src/agents/meta/codex-keeper/playbook.md +2 -3
- package/src/schemas/project-config.schema.json +1 -1
- package/assets/demo.tape +0 -266
- package/dist/chunk-2VUYFTUB.js.map +0 -1
- package/dist/chunk-4NDBUJHK.js +0 -237
- package/dist/chunk-4NDBUJHK.js.map +0 -1
- package/dist/chunk-6L75SQZU.js +0 -168
- package/dist/chunk-6L75SQZU.js.map +0 -1
- package/dist/chunk-6LF4CQBY.js +0 -51
- package/dist/chunk-6LF4CQBY.js.map +0 -1
- package/dist/chunk-7JNJ52CD.js +0 -1179
- package/dist/chunk-7JNJ52CD.js.map +0 -1
- package/dist/chunk-A4KDXNOT.js.map +0 -1
- package/dist/chunk-DAIEQJIF.js +0 -48
- package/dist/chunk-DAIEQJIF.js.map +0 -1
- package/dist/chunk-ENGYJCTF.js.map +0 -1
- package/dist/chunk-G4JK7WVO.js.map +0 -1
- package/dist/chunk-G6UREQ4V.js.map +0 -1
- package/dist/chunk-HHIYT3PI.js +0 -53
- package/dist/chunk-HHIYT3PI.js.map +0 -1
- package/dist/chunk-HWEKHVLE.js.map +0 -1
- package/dist/chunk-JOEA52NR.js.map +0 -1
- package/dist/chunk-JQRJQ4SS.js +0 -118
- package/dist/chunk-JQRJQ4SS.js.map +0 -1
- package/dist/chunk-LFWLEDUG.js +0 -59
- package/dist/chunk-LFWLEDUG.js.map +0 -1
- package/dist/chunk-MAWNVT2C.js.map +0 -1
- package/dist/chunk-MPTNC32T.js +0 -92
- package/dist/chunk-MPTNC32T.js.map +0 -1
- package/dist/chunk-NBXXFIIW.js.map +0 -1
- package/dist/chunk-OI2H6M5I.js.map +0 -1
- package/dist/chunk-PNB3524H.js +0 -197
- package/dist/chunk-PNB3524H.js.map +0 -1
- package/dist/chunk-QHDPLLK6.js +0 -35
- package/dist/chunk-QHDPLLK6.js.map +0 -1
- package/dist/chunk-RAHSOJQ2.js +0 -25
- package/dist/chunk-RAHSOJQ2.js.map +0 -1
- package/dist/chunk-RZDXDMT6.js +0 -23
- package/dist/chunk-RZDXDMT6.js.map +0 -1
- package/dist/chunk-SCOQ34YM.js +0 -17
- package/dist/chunk-SCOQ34YM.js.map +0 -1
- package/dist/chunk-SXVHSOTH.js +0 -268
- package/dist/chunk-SXVHSOTH.js.map +0 -1
- package/dist/chunk-T6UWJAB3.js +0 -28
- package/dist/chunk-T6UWJAB3.js.map +0 -1
- package/dist/chunk-TSIU7DME.js +0 -43
- package/dist/chunk-TSIU7DME.js.map +0 -1
- package/dist/chunk-TTY6DPJN.js +0 -27
- package/dist/chunk-TTY6DPJN.js.map +0 -1
- package/dist/chunk-TZ2YJJKK.js +0 -292
- package/dist/chunk-TZ2YJJKK.js.map +0 -1
- package/dist/chunk-V3I7VQ7N.js.map +0 -1
- package/dist/chunk-V5WXIM2F.js.map +0 -1
- package/dist/chunk-VRXX4D6K.js.map +0 -1
- package/dist/chunk-WTJ3AY33.js +0 -31
- package/dist/chunk-WTJ3AY33.js.map +0 -1
- package/dist/chunk-WVUDLKIO.js +0 -121
- package/dist/chunk-WVUDLKIO.js.map +0 -1
- package/dist/chunk-WWIFNPJG.js +0 -317
- package/dist/chunk-WWIFNPJG.js.map +0 -1
- package/dist/chunk-XQHZPINL.js +0 -89
- package/dist/chunk-XQHZPINL.js.map +0 -1
- package/dist/chunk-XZEVWPX6.js +0 -230
- package/dist/chunk-XZEVWPX6.js.map +0 -1
- package/dist/chunk-Y3VIRVVE.js.map +0 -1
- package/dist/chunk-Y47EV74W.js.map +0 -1
- package/dist/components/wizard/category-grid.js +0 -13
- package/dist/components/wizard/checkbox-grid.js +0 -12
- package/dist/components/wizard/domain-selection.js +0 -18
- package/dist/components/wizard/run-wizard-session.js +0 -40
- package/dist/components/wizard/run-wizard-session.js.map +0 -1
- package/dist/components/wizard/scroll-affordance.js +0 -9
- package/dist/components/wizard/skill-agent-summary.js +0 -13
- package/dist/components/wizard/source-grid.js +0 -16
- package/dist/components/wizard/source-grid.js.map +0 -1
- package/dist/components/wizard/stack-selection.js +0 -17
- package/dist/components/wizard/stack-selection.js.map +0 -1
- package/dist/components/wizard/step-agents.js +0 -18
- package/dist/components/wizard/step-agents.js.map +0 -1
- package/dist/components/wizard/step-build.js +0 -18
- package/dist/components/wizard/step-build.js.map +0 -1
- package/dist/components/wizard/step-confirm.js +0 -18
- package/dist/components/wizard/step-confirm.js.map +0 -1
- package/dist/components/wizard/step-sources.js +0 -19
- package/dist/components/wizard/step-sources.js.map +0 -1
- package/dist/components/wizard/step-stack.js +0 -18
- package/dist/components/wizard/step-stack.js.map +0 -1
- package/dist/components/wizard/summary-panel.js +0 -17
- package/dist/components/wizard/summary-panel.js.map +0 -1
- package/dist/components/wizard/toast.js +0 -9
- package/dist/components/wizard/toast.js.map +0 -1
- package/dist/components/wizard/wizard-layout.js +0 -22
- package/dist/components/wizard/wizard-layout.js.map +0 -1
- package/dist/components/wizard/wizard-tabs.js +0 -11
- package/dist/components/wizard/wizard-tabs.js.map +0 -1
- package/dist/components/wizard/wizard.js +0 -39
- package/dist/components/wizard/wizard.js.map +0 -1
- package/dist/load-agent-defs-3C27ENC7.js +0 -14
- package/dist/load-agent-defs-3C27ENC7.js.map +0 -1
- package/dist/recompile-project-agents-DGNBCU3N.js +0 -18
- package/dist/recompile-project-agents-DGNBCU3N.js.map +0 -1
- package/dist/source-loader-7KZ3MD5O.js.map +0 -1
- package/dist/stores/wizard-store.js +0 -24
- package/dist/stores/wizard-store.js.map +0 -1
- /package/assets/{demo.gif → legacy-wizard.gif} +0 -0
- /package/dist/{chunk-ZR4YPKXQ.js.map → chunk-3G7X2WKI.js.map} +0 -0
- /package/dist/{chunk-GE3WKJ6Q.js.map → chunk-BMRUNMPV.js.map} +0 -0
- /package/dist/{chunk-ZXKBERQU.js.map → chunk-F5EBEATU.js.map} +0 -0
- /package/dist/{chunk-PMJWD27C.js.map → chunk-HED2DAXZ.js.map} +0 -0
- /package/dist/{chunk-TODCQFRB.js.map → chunk-USVBYQSQ.js.map} +0 -0
- /package/dist/{chunk-PXWG7KFO.js.map → chunk-WTWMGH2C.js.map} +0 -0
- /package/dist/components/{wizard → common}/scroll-affordance.js.map +0 -0
- /package/dist/components/{wizard → common}/skill-agent-summary.js.map +0 -0
- /package/dist/{components/wizard/category-grid.js.map → load-agent-defs-YMDWBFDP.js.map} +0 -0
- /package/dist/{components/wizard/checkbox-grid.js.map → recompile-project-agents-SZ76WNTW.js.map} +0 -0
- /package/dist/{components/wizard/domain-selection.js.map → source-loader-C5SQXZXI.js.map} +0 -0
package/dist/commands/eject.js
CHANGED
|
@@ -5,22 +5,21 @@ import {
|
|
|
5
5
|
loadSource,
|
|
6
6
|
mutateGlobal,
|
|
7
7
|
writeProjectPartial
|
|
8
|
-
} from "../chunk-
|
|
9
|
-
import "../chunk-
|
|
10
|
-
import "../chunk-
|
|
11
|
-
import "../chunk-
|
|
12
|
-
import "../chunk-
|
|
8
|
+
} from "../chunk-7RDMTR64.js";
|
|
9
|
+
import "../chunk-F2BHT5C4.js";
|
|
10
|
+
import "../chunk-HED2DAXZ.js";
|
|
11
|
+
import "../chunk-3G7X2WKI.js";
|
|
12
|
+
import "../chunk-BMRUNMPV.js";
|
|
13
13
|
import {
|
|
14
14
|
providerFlag,
|
|
15
15
|
providerNamedBy,
|
|
16
16
|
refuseAnAmbiguousInstallation
|
|
17
|
-
} from "../chunk-
|
|
17
|
+
} from "../chunk-RIPSGNLU.js";
|
|
18
18
|
import {
|
|
19
19
|
BaseCommand,
|
|
20
20
|
EXIT_CODES
|
|
21
|
-
} from "../chunk-
|
|
22
|
-
import "../chunk-
|
|
23
|
-
import "../chunk-RZDXDMT6.js";
|
|
21
|
+
} from "../chunk-V3KTSP3Q.js";
|
|
22
|
+
import "../chunk-CLPUWOSA.js";
|
|
24
23
|
import {
|
|
25
24
|
INCOMPLETE_WORK_RECOVERY,
|
|
26
25
|
INFO_MESSAGES,
|
|
@@ -37,18 +36,18 @@ import {
|
|
|
37
36
|
plural,
|
|
38
37
|
providerInUse,
|
|
39
38
|
relativeConfigPath,
|
|
39
|
+
resolveInstallPaths,
|
|
40
40
|
resolveSource,
|
|
41
41
|
sourceFolderInUse
|
|
42
|
-
} from "../chunk-
|
|
42
|
+
} from "../chunk-MQ6CGZNJ.js";
|
|
43
43
|
import {
|
|
44
44
|
matrix
|
|
45
|
-
} from "../chunk-
|
|
45
|
+
} from "../chunk-52HDHJ7I.js";
|
|
46
46
|
import {
|
|
47
47
|
DIRS,
|
|
48
|
-
LOCAL_SKILLS_PATH,
|
|
49
48
|
PROJECT_ROOT
|
|
50
|
-
} from "../chunk-
|
|
51
|
-
import "../chunk-
|
|
49
|
+
} from "../chunk-PJWGTNOX.js";
|
|
50
|
+
import "../chunk-NQW25DCF.js";
|
|
52
51
|
|
|
53
52
|
// src/cli/commands/eject.ts
|
|
54
53
|
import { Args, Flags } from "@oclif/core";
|
|
@@ -264,20 +263,14 @@ var Eject = class _Eject extends BaseCommand {
|
|
|
264
263
|
);
|
|
265
264
|
}
|
|
266
265
|
async handleSkills(projectDir, force, sourceResult, directOutput, outputBase) {
|
|
267
|
-
const
|
|
268
|
-
|
|
269
|
-
force,
|
|
270
|
-
sourceResult,
|
|
271
|
-
matrix,
|
|
272
|
-
directOutput,
|
|
273
|
-
...directOutput && { customOutputBase: outputBase }
|
|
274
|
-
});
|
|
266
|
+
const destDir = directOutput ? outputBase : installedSkillsDir(projectDir);
|
|
267
|
+
const result = await ejectSkills({ destDir, force, sourceResult, matrix });
|
|
275
268
|
if (result.skipped) {
|
|
276
269
|
this.warn(result.skipReason);
|
|
277
270
|
return;
|
|
278
271
|
}
|
|
279
272
|
this.logSuccess(
|
|
280
|
-
`${plural(result.copiedSkills.length, "skill")} ejected to ${
|
|
273
|
+
`${plural(result.copiedSkills.length, "skill")} ejected to ${destDir} from ${result.sourceLabel}`
|
|
281
274
|
);
|
|
282
275
|
this.log("You can now customize skill content locally.");
|
|
283
276
|
}
|
|
@@ -334,15 +327,7 @@ async function ejectAgentPartials(options) {
|
|
|
334
327
|
};
|
|
335
328
|
}
|
|
336
329
|
async function ejectSkills(options) {
|
|
337
|
-
const {
|
|
338
|
-
projectDir,
|
|
339
|
-
force,
|
|
340
|
-
sourceResult,
|
|
341
|
-
matrix: matrix2,
|
|
342
|
-
directOutput = false,
|
|
343
|
-
customOutputBase
|
|
344
|
-
} = options;
|
|
345
|
-
const destDir = directOutput && customOutputBase ? customOutputBase : path.join(projectDir, LOCAL_SKILLS_PATH);
|
|
330
|
+
const { destDir, force, sourceResult, matrix: matrix2 } = options;
|
|
346
331
|
if (await directoryExists(destDir) && !force) {
|
|
347
332
|
return {
|
|
348
333
|
skipped: true,
|
|
@@ -366,10 +351,13 @@ async function ejectSkills(options) {
|
|
|
366
351
|
return {
|
|
367
352
|
skipped: false,
|
|
368
353
|
copiedSkills,
|
|
369
|
-
destDir,
|
|
370
354
|
sourceLabel
|
|
371
355
|
};
|
|
372
356
|
}
|
|
357
|
+
function installedSkillsDir(projectDir) {
|
|
358
|
+
const scope = isHomeDirectory(projectDir) ? "global" : "project";
|
|
359
|
+
return resolveInstallPaths(projectDir, scope).skillsDir;
|
|
360
|
+
}
|
|
373
361
|
async function ensureMinimalConfig(options) {
|
|
374
362
|
const { projectDir, sourceResult } = options;
|
|
375
363
|
const provider = providerInUse(projectDir);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/cli/commands/eject.ts"],"sourcesContent":["import { Args, Flags } from \"@oclif/core\";\nimport path from \"path\";\nimport os from \"os\";\nimport { BaseCommand } from \"../base-command.js\";\nimport { copy, ensureDir, directoryExists, fileExists, listDirectories } from \"../utils/fs.js\";\nimport { DIRS, LOCAL_SKILLS_PATH, PROJECT_ROOT } from \"../consts.js\";\nimport {\n providerInUse,\n relativeConfigPath,\n sourceFolderInUse,\n} from \"../lib/installation/install-layout.js\";\nimport { EXIT_CODES } from \"../lib/exit-codes.js\";\nimport { type SourceLoadResult } from \"../lib/loading/index.js\";\nimport { loadSource } from \"../lib/operations/index.js\";\nimport { matrix } from \"../lib/matrix/matrix-provider\";\nimport {\n resolveSource,\n loadProjectSourceConfig,\n getProjectConfigPath,\n} from \"../lib/configuration/index.js\";\nimport {\n ensureBlankPair,\n lazyGateDeps,\n mutateGlobal,\n writeProjectPartial,\n} from \"../lib/config-gate/index.js\";\nimport { isHomeDirectory } from \"../lib/installation/index.js\";\nimport {\n providerFlag,\n providerNamedBy,\n refuseAnAmbiguousInstallation,\n} from \"../lib/installation/provider-flag.js\";\nimport { copySkillsToLocalFlattened, type CopiedSkill } from \"../lib/skills/index.js\";\nimport { INCOMPLETE_WORK_RECOVERY, INFO_MESSAGES } from \"../utils/messages.js\";\nimport { getErrorMessage } from \"../utils/errors.js\";\nimport { plural } from \"../utils/string.js\";\nimport type { MergedSkillsMatrix } from \"../types/index.js\";\n\nconst EJECT_TYPES = [\"agent-partials\", \"templates\", \"skills\", \"all\"] as const;\ntype EjectType = (typeof EJECT_TYPES)[number];\n\nfunction isEjectType(value: string): value is EjectType {\n return (EJECT_TYPES as readonly string[]).includes(value);\n}\n\nexport default class Eject extends BaseCommand {\n static summary = \"Eject skills, agent partials, or templates for local customization\";\n static description =\n \"Copy agent partials, templates, or skills to your project for customization. \" +\n \"Agent partials and templates are always copied from the CLI. \" +\n \"Skills are copied from the marketplace this installation is configured to read \" +\n \"(the public one by default).\";\n\n static examples = [\n {\n description: \"Eject agent partials for customization\",\n command: \"<%= config.bin %> <%= command.id %> agent-partials\",\n },\n {\n description: \"Eject only agent templates\",\n command: \"<%= config.bin %> <%= command.id %> templates\",\n },\n {\n description: \"Eject skills to local directory\",\n command: \"<%= config.bin %> <%= command.id %> skills\",\n },\n {\n description: \"Eject everything with force overwrite\",\n command: \"<%= config.bin %> <%= command.id %> all --force\",\n },\n {\n description: \"Eject to a custom output directory\",\n command: \"<%= config.bin %> <%= command.id %> skills -o ./custom-dir\",\n },\n ];\n\n static args = {\n type: Args.string({\n description: \"What to eject: agent-partials, templates, skills, all\",\n required: false,\n options: [...EJECT_TYPES],\n }),\n };\n\n static flags = {\n provider: providerFlag(),\n force: Flags.boolean({\n char: \"f\",\n description: \"Overwrite existing files\",\n default: false,\n }),\n output: Flags.string({\n char: \"o\",\n // No `default:`, and no default named here either: each eject type has its own\n // destination and this flag replaces all three at once. The reference page carries\n // the table; a one-line description that picked one of the three would be wrong\n // about the other two, which is what it was.\n description:\n \"Write everything into this directory instead of each eject type's own destination\",\n }),\n };\n\n async run(): Promise<void> {\n const { args, flags } = await this.parse(Eject);\n const projectDir = process.cwd();\n\n // Above the layout settle, because that refusal is about two FOLDER NAMES of one installation\n // and this one is about two installations. Both have to be answered before anything is\n // written, and this one decides which installation the other is even asking about.\n await refuseAnAmbiguousInstallation(\n projectDir,\n \"eject\",\n providerNamedBy(flags.provider),\n (message) => this.error(message, { exit: EXIT_CODES.INVALID_ARGS }),\n );\n\n // Before anything is copied: a config nobody can read is recreated, not ejected over, and a\n // refusal past this point would follow files already written.\n await this.ensureConfigReadable(projectDir);\n const ejectType = this.validateEjectType(args.type);\n const outputBase = await this.resolveOutputBase(flags, projectDir);\n\n this.printHeader(\n await this.resolveBrandingName(projectDir),\n flags.output ? outputBase : undefined,\n );\n\n const sourceResult = await this.loadSourceIfNeeded(ejectType, projectDir);\n await this.executeEject(ejectType, outputBase, flags, projectDir, sourceResult);\n await this.ensureConfig(projectDir, sourceResult);\n\n this.reportEnding();\n }\n\n /**\n * The command's last word.\n *\n * `Eject complete!` claims the whole eject landed, so it is withheld whenever part of it did\n * not — the account {@link BaseCommand.exitIfWorkIncomplete} prints replaces that tick rather\n * than sitting under it, and carries the non-zero exit with it.\n */\n private reportEnding(): void {\n this.log(\"\");\n if (!this.hasIncompleteWork) this.logSuccess(\"Eject complete!\");\n this.log(\"\");\n\n this.exitIfWorkIncomplete();\n }\n\n private validateEjectType(typeArg: string | undefined): EjectType {\n if (!typeArg) {\n this.error(\"Please specify what to eject: agent-partials, templates, skills, or all\", {\n exit: EXIT_CODES.INVALID_ARGS,\n });\n }\n\n if (!isEjectType(typeArg)) {\n this.error(`Unknown eject type: ${typeArg}`, {\n exit: EXIT_CODES.INVALID_ARGS,\n });\n }\n\n return typeArg;\n }\n\n private async resolveOutputBase(\n flags: { output: string | undefined },\n projectDir: string,\n ): Promise<string> {\n if (flags.output) {\n const expandedPath = flags.output.startsWith(\"~\")\n ? path.join(os.homedir(), flags.output.slice(1))\n : flags.output;\n const outputBase = path.resolve(projectDir, expandedPath);\n\n if (await fileExists(outputBase)) {\n this.error(`Output path exists as a file: ${outputBase}`, {\n exit: EXIT_CODES.INVALID_ARGS,\n });\n }\n\n return outputBase;\n }\n\n return sourceFolderInUse(projectDir, providerInUse(projectDir)).dir;\n }\n\n private printHeader(brandingName: string, outputBase?: string): void {\n this.log(\"\");\n this.log(`${brandingName} Eject`);\n this.log(\"\");\n\n if (outputBase) {\n this.log(`Output directory: ${outputBase}`);\n }\n }\n\n private async loadSourceIfNeeded(\n ejectType: EjectType,\n projectDir: string,\n ): Promise<SourceLoadResult | undefined> {\n if (ejectType === \"skills\" || ejectType === \"all\") {\n const loaded = await loadSource({ projectDir });\n return loaded.sourceResult;\n }\n return undefined;\n }\n\n private async executeEject(\n ejectType: EjectType,\n outputBase: string,\n flags: { force: boolean; output: string | undefined },\n projectDir: string,\n sourceResult: SourceLoadResult | undefined,\n ): Promise<void> {\n const directOutput = !!flags.output;\n\n switch (ejectType) {\n case \"agent-partials\":\n await this.handleAgentPartials(outputBase, flags.force, directOutput, false);\n break;\n case \"templates\":\n await this.handleAgentPartials(outputBase, flags.force, directOutput, true);\n break;\n case \"skills\":\n if (!sourceResult) {\n throw new Error(\"The marketplace must be loaded for skills eject\");\n }\n await this.handleSkills(projectDir, flags.force, sourceResult, directOutput, outputBase);\n break;\n case \"all\":\n if (!sourceResult) {\n throw new Error(\"The marketplace must be loaded for full eject\");\n }\n await this.handleAgentPartials(outputBase, flags.force, directOutput, false);\n await this.handleAgentPartials(outputBase, true, directOutput, true);\n await this.handleSkills(projectDir, flags.force, sourceResult, directOutput, outputBase);\n break;\n default: {\n const _exhaustive: never = ejectType;\n return _exhaustive;\n }\n }\n }\n\n /**\n * The convenience step after the eject: a minimal `config.ts` so a later `compile` has\n * something to read.\n *\n * It can refuse, and by the time it does the ejection has already landed — the templates,\n * partials or skills are on disk and stay there. So the throw is caught rather than left to\n * become the process's exit code: an `ERROR` tells the caller nothing landed and the run can\n * be repeated, which is the wrong instruction for a tree that now holds an ejection. What is\n * owed is the account and `EXIT_CODES.COMPLETED_WITH_FAILURES`.\n *\n * The refusal itself is right and is not weakened here: `ensureMinimalConfig` will not invent\n * a config recording a marketplace it read out of a file it could not evaluate.\n */\n private async ensureConfig(\n projectDir: string,\n sourceResult: SourceLoadResult | undefined,\n ): Promise<void> {\n // Named once, before the write, so the success line and the failure line cannot name\n // different files: the provider is read off the disk and the write may create the folder.\n const configTsRel = relativeConfigPath(projectDir, providerInUse(projectDir));\n\n try {\n const configResult = await ensureMinimalConfig({\n projectDir,\n ...(sourceResult !== undefined && { sourceResult }),\n });\n if (configResult.created) {\n this.logSuccess(`Created ${configTsRel}`);\n }\n } catch (error) {\n this.reportIncompleteWork(\n `Could not create ${configTsRel}: ${getErrorMessage(error)}`,\n INCOMPLETE_WORK_RECOVERY.INSPECT_INSTALLATION,\n );\n }\n }\n\n private async handleAgentPartials(\n outputBase: string,\n force: boolean,\n directOutput: boolean,\n templatesOnly: boolean,\n ): Promise<void> {\n const result = await ejectAgentPartials({\n outputBase,\n force,\n directOutput,\n templatesOnly,\n });\n\n if (result.skipped) {\n this.warn(result.skipReason);\n return;\n }\n\n if (result.templatesSkipped) {\n this.warn(\n \"Agent templates already exist — skipping templates, only ejecting agent partials.\",\n );\n }\n\n this.logSuccess(\n `${templatesOnly ? \"Agent templates\" : \"Agent partials\"} ejected to ${result.destDir}`,\n );\n this.log(\n templatesOnly\n ? \"You can now customize agent templates locally.\"\n : INFO_MESSAGES.AGENT_PARTIALS_CUSTOMIZABLE,\n );\n }\n\n private async handleSkills(\n projectDir: string,\n force: boolean,\n sourceResult: SourceLoadResult,\n directOutput: boolean,\n outputBase: string,\n ): Promise<void> {\n const result = await ejectSkills({\n projectDir,\n force,\n sourceResult,\n matrix,\n directOutput,\n ...(directOutput && { customOutputBase: outputBase }),\n });\n\n if (result.skipped) {\n this.warn(result.skipReason);\n return;\n }\n\n this.logSuccess(\n `${plural(result.copiedSkills.length, \"skill\")} ejected to ${result.destDir} from ${result.sourceLabel}`,\n );\n this.log(\"You can now customize skill content locally.\");\n }\n}\n\ntype EjectAgentPartialsOptions = {\n outputBase: string;\n force: boolean;\n /** When true, outputBase is used directly as the destination (no subdirectory nesting). */\n directOutput?: boolean;\n /** When true, ejects only the _templates directory instead of the full agents directory. */\n templatesOnly?: boolean;\n};\n\ntype EjectAgentPartialsResult =\n | {\n skipped: true;\n skipReason: string;\n templatesSkipped: false;\n }\n | {\n skipped: false;\n /** Destination directory that was written to. */\n destDir: string;\n /** Whether templates were skipped during a full agent-partials eject (existing templates preserved). */\n templatesSkipped: boolean;\n };\n\n/** Direct output writes to the base itself; otherwise agents/ (plus templates/ in templates-only mode). */\nfunction resolveEjectDestDir(\n outputBase: string,\n directOutput: boolean,\n templatesOnly: boolean,\n): string {\n if (directOutput) return outputBase;\n const agentsDir = path.join(outputBase, path.basename(DIRS.agents));\n return templatesOnly ? path.join(agentsDir, path.basename(DIRS.templates)) : agentsDir;\n}\n\n/**\n * Copies agent partials or templates from the CLI source to a target directory.\n *\n * When `templatesOnly` is true, copies only the _templates subdirectory.\n * When false, copies the full agents directory (optionally skipping existing templates).\n *\n * Returns structured data — the command decides what to log.\n */\nasync function ejectAgentPartials(\n options: EjectAgentPartialsOptions,\n): Promise<EjectAgentPartialsResult> {\n const { outputBase, force, directOutput = false, templatesOnly = false } = options;\n\n const sourceDir = templatesOnly\n ? path.join(PROJECT_ROOT, DIRS.templates)\n : path.join(PROJECT_ROOT, DIRS.agents);\n\n if (!(await directoryExists(sourceDir))) {\n return {\n skipped: true,\n skipReason: templatesOnly\n ? \"No agent templates found in CLI.\"\n : \"No agent partials found in CLI.\",\n templatesSkipped: false,\n };\n }\n\n const destDir = resolveEjectDestDir(outputBase, directOutput, templatesOnly);\n\n const templatesBasename = path.basename(DIRS.templates);\n\n if ((await directoryExists(destDir)) && !force) {\n if (templatesOnly) {\n return {\n skipped: true,\n skipReason: `Agent templates already exist at ${destDir}. Use --force to overwrite.`,\n templatesSkipped: false,\n };\n }\n\n const hasTemplates = await directoryExists(path.join(destDir, templatesBasename));\n if ((await hasAgentPartialDirs(destDir)) && !hasTemplates) {\n return {\n skipped: true,\n skipReason: `Agent partials already exist at ${destDir}. Use --force to overwrite.`,\n templatesSkipped: false,\n };\n }\n }\n\n await ensureDir(destDir);\n\n const skipTemplates =\n !templatesOnly && !force && (await directoryExists(path.join(destDir, templatesBasename)));\n\n if (skipTemplates) {\n const sourceEntries = await listDirectories(sourceDir);\n const nonTemplateEntries = sourceEntries.filter((entry) => entry !== templatesBasename);\n for (const entry of nonTemplateEntries) {\n await copy(path.join(sourceDir, entry), path.join(destDir, entry));\n }\n } else {\n await copy(sourceDir, destDir);\n }\n\n return {\n skipped: false,\n destDir,\n templatesSkipped: skipTemplates,\n };\n}\n\ntype EjectSkillsOptions = {\n projectDir: string;\n force: boolean;\n sourceResult: SourceLoadResult;\n matrix: MergedSkillsMatrix;\n /** When true, uses customOutputBase as destination instead of LOCAL_SKILLS_PATH. */\n directOutput?: boolean;\n customOutputBase?: string;\n};\n\ntype EjectSkillsResult =\n | {\n skipped: true;\n skipReason: string;\n copiedSkills: [];\n }\n | {\n skipped: false;\n /** Array of skills that were copied. */\n copiedSkills: CopiedSkill[];\n /** Destination directory that was written to. */\n destDir: string;\n /** Label describing the source that skills were copied from. */\n sourceLabel: string;\n };\n\n/**\n * Copies the marketplace's own skills from source to a target directory.\n *\n * Only the skills the loaded marketplace carries, because those are the only ones its folder\n * holds: a global installation's skill seated from another marketplace is in the matrix and not\n * on disk here. Skills already marked as local are filtered out too, then the remaining skills\n * are copied using copySkillsToLocalFlattened.\n *\n * Returns structured data — the command decides what to log.\n */\nasync function ejectSkills(options: EjectSkillsOptions): Promise<EjectSkillsResult> {\n const {\n projectDir,\n force,\n sourceResult,\n matrix,\n directOutput = false,\n customOutputBase,\n } = options;\n\n const destDir =\n directOutput && customOutputBase ? customOutputBase : path.join(projectDir, LOCAL_SKILLS_PATH);\n\n if ((await directoryExists(destDir)) && !force) {\n return {\n skipped: true,\n skipReason: `Skills already exist at ${destDir}. Use --force to overwrite.`,\n copiedSkills: [],\n };\n }\n\n const skillIds = [...sourceResult.marketplaceSkillIds].filter(\n (skillId) => !matrix.skills[skillId]?.local,\n );\n\n if (skillIds.length === 0) {\n return {\n skipped: true,\n skipReason: \"No skills found in the marketplace to eject.\",\n copiedSkills: [],\n };\n }\n\n await ensureDir(destDir);\n\n const copiedSkills = await copySkillsToLocalFlattened(skillIds, destDir, sourceResult);\n\n const sourceLabel = sourceResult.isLocal\n ? sourceResult.sourcePath\n : sourceResult.marketplace || sourceResult.sourceConfig.source;\n\n return {\n skipped: false,\n copiedSkills,\n destDir,\n sourceLabel,\n };\n}\n\ntype EnsureMinimalConfigOptions = {\n projectDir: string;\n sourceResult?: SourceLoadResult;\n};\n\ntype EnsureMinimalConfigResult = {\n /** Path to the config file. */\n configPath: string;\n /** Whether a new config was created. */\n created: boolean;\n};\n\n/**\n * Ensures a minimal config.ts exists so `npx agents-inc compile` works after eject.\n *\n * If the config already exists, returns immediately with `created: false`.\n * Otherwise generates a minimal config from the resolved source and project metadata.\n *\n * Returns structured data — the command decides what to log.\n */\nasync function ensureMinimalConfig(\n options: EnsureMinimalConfigOptions,\n): Promise<EnsureMinimalConfigResult> {\n const { projectDir, sourceResult } = options;\n\n // One read for the whole function: the config it may invent, and the blank global pair it may\n // create beside it, belong to the same installation.\n const provider = providerInUse(projectDir);\n const tsConfigPath = getProjectConfigPath(projectDir, provider);\n\n if (await fileExists(tsConfigPath)) {\n return { configPath: tsConfigPath, created: false };\n }\n\n // ABORT on an unreadable config. The project has none — the guard above returned for that — so\n // what these two can meet is an unreadable GLOBAL config, and the file about to be invented\n // would record a marketplace read from nowhere. The second call is unreachable for the same\n // reason the guard exists: this project's own config is not there to be unreadable.\n const resolvedConfig =\n sourceResult?.sourceConfig ?? (await resolveSource({ caller: \"stored\", projectDir }));\n const existingProjectConfig = await loadProjectSourceConfig(projectDir);\n const source = resolvedConfig.source || undefined;\n\n // At the home directory the invented config IS the global manifest, and the\n // file it opens with `import type { ProjectConfig } from \"./config-types\"`\n // cannot resolve its own types without the sibling. The gate writes the pair.\n if (isHomeDirectory(projectDir)) {\n await ensureBlankPair(provider);\n if (source) await recordSource(projectDir, source);\n return { configPath: tsConfigPath, created: true };\n }\n\n await writeProjectPartial(\n projectDir,\n {\n skills: [],\n agents: [],\n ...(source ? { marketplace: source } : {}),\n ...(resolvedConfig.marketplace ? { marketplaceName: resolvedConfig.marketplace } : {}),\n ...(existingProjectConfig?.author ? { author: existingProjectConfig.author } : {}),\n ...(existingProjectConfig?.agentsSource\n ? { agentsSource: existingProjectConfig.agentsSource }\n : {}),\n },\n { fallbackName: path.basename(projectDir) },\n );\n\n return { configPath: tsConfigPath, created: true };\n}\n\n/**\n * Records the marketplace ref in whichever scope's config `projectDir` names. At the home\n * directory that config is the global manifest every project's generated types\n * import from, so the write goes through the gate: registered projects inline\n * the scalar and follow it.\n */\nasync function recordSource(projectDir: string, source: string): Promise<void> {\n if (isHomeDirectory(projectDir)) {\n await mutateGlobal(\n { kind: \"set-source\", source, fallbackName: path.basename(projectDir) },\n lazyGateDeps(projectDir),\n );\n return;\n }\n\n // ABORT on an unreadable config. The `?? {}` is a fallback for a config that is not THERE; on\n // one that is there and unreadable it would hand the writer an empty partial, and this scalar\n // write would replace the user's whole file with a two-field one under an invented name.\n const existing = (await loadProjectSourceConfig(projectDir)) ?? {};\n await writeProjectPartial(\n projectDir,\n { ...existing, marketplace: source },\n { fallbackName: path.basename(projectDir) },\n );\n}\n\n/** Checks whether the agents directory contains any agent subdirectories (not just _templates). */\nasync function hasAgentPartialDirs(agentsDir: string): Promise<boolean> {\n const subdirs = await listDirectories(agentsDir);\n const templatesBasename = path.basename(DIRS.templates);\n return subdirs.some((dir) => dir !== templatesBasename);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,SAAS,MAAM,aAAa;AAC5B,OAAO,UAAU;AACjB,OAAO,QAAQ;AAoCf,IAAM,cAAc,CAAC,kBAAkB,aAAa,UAAU,KAAK;AAGnE,SAAS,YAAY,OAAmC;AACtD,SAAQ,YAAkC,SAAS,KAAK;AAC1D;AAEA,IAAqB,QAArB,MAAqB,eAAc,YAAY;AAAA,EAC7C,OAAO,UAAU;AAAA,EACjB,OAAO,cACL;AAAA,EAKF,OAAO,WAAW;AAAA,IAChB;AAAA,MACE,aAAa;AAAA,MACb,SAAS;AAAA,IACX;AAAA,IACA;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3,"sources":["../../src/cli/commands/eject.ts"],"sourcesContent":["import { Args, Flags } from \"@oclif/core\";\nimport path from \"path\";\nimport os from \"os\";\nimport { BaseCommand } from \"../base-command.js\";\nimport { copy, ensureDir, directoryExists, fileExists, listDirectories } from \"../utils/fs.js\";\nimport { DIRS, PROJECT_ROOT } from \"../consts.js\";\nimport {\n providerInUse,\n relativeConfigPath,\n sourceFolderInUse,\n} from \"../lib/installation/install-layout.js\";\nimport { EXIT_CODES } from \"../lib/exit-codes.js\";\nimport { type SourceLoadResult } from \"../lib/loading/index.js\";\nimport { loadSource } from \"../lib/operations/index.js\";\nimport { matrix } from \"../lib/matrix/matrix-provider\";\nimport {\n resolveSource,\n loadProjectSourceConfig,\n getProjectConfigPath,\n} from \"../lib/configuration/index.js\";\nimport {\n ensureBlankPair,\n lazyGateDeps,\n mutateGlobal,\n writeProjectPartial,\n} from \"../lib/config-gate/index.js\";\nimport { isHomeDirectory, resolveInstallPaths } from \"../lib/installation/index.js\";\nimport {\n providerFlag,\n providerNamedBy,\n refuseAnAmbiguousInstallation,\n} from \"../lib/installation/provider-flag.js\";\nimport { copySkillsToLocalFlattened, type CopiedSkill } from \"../lib/skills/index.js\";\nimport { INCOMPLETE_WORK_RECOVERY, INFO_MESSAGES } from \"../utils/messages.js\";\nimport { getErrorMessage } from \"../utils/errors.js\";\nimport { plural } from \"../utils/string.js\";\nimport type { MergedSkillsMatrix } from \"../types/index.js\";\n\nconst EJECT_TYPES = [\"agent-partials\", \"templates\", \"skills\", \"all\"] as const;\ntype EjectType = (typeof EJECT_TYPES)[number];\n\nfunction isEjectType(value: string): value is EjectType {\n return (EJECT_TYPES as readonly string[]).includes(value);\n}\n\nexport default class Eject extends BaseCommand {\n static summary = \"Eject skills, agent partials, or templates for local customization\";\n static description =\n \"Copy agent partials, templates, or skills to your project for customization. \" +\n \"Agent partials and templates are always copied from the CLI. \" +\n \"Skills are copied from the marketplace this installation is configured to read \" +\n \"(the public one by default).\";\n\n static examples = [\n {\n description: \"Eject agent partials for customization\",\n command: \"<%= config.bin %> <%= command.id %> agent-partials\",\n },\n {\n description: \"Eject only agent templates\",\n command: \"<%= config.bin %> <%= command.id %> templates\",\n },\n {\n description: \"Eject skills to local directory\",\n command: \"<%= config.bin %> <%= command.id %> skills\",\n },\n {\n description: \"Eject everything with force overwrite\",\n command: \"<%= config.bin %> <%= command.id %> all --force\",\n },\n {\n description: \"Eject to a custom output directory\",\n command: \"<%= config.bin %> <%= command.id %> skills -o ./custom-dir\",\n },\n ];\n\n static args = {\n type: Args.string({\n description: \"What to eject: agent-partials, templates, skills, all\",\n required: false,\n options: [...EJECT_TYPES],\n }),\n };\n\n static flags = {\n provider: providerFlag(),\n force: Flags.boolean({\n char: \"f\",\n description: \"Overwrite existing files\",\n default: false,\n }),\n output: Flags.string({\n char: \"o\",\n // No `default:`, and no default named here either: each eject type has its own\n // destination and this flag replaces all three at once. The reference page carries\n // the table; a one-line description that picked one of the three would be wrong\n // about the other two, which is what it was.\n description:\n \"Write everything into this directory instead of each eject type's own destination\",\n }),\n };\n\n async run(): Promise<void> {\n const { args, flags } = await this.parse(Eject);\n const projectDir = process.cwd();\n\n // Above the layout settle, because that refusal is about two FOLDER NAMES of one installation\n // and this one is about two installations. Both have to be answered before anything is\n // written, and this one decides which installation the other is even asking about.\n await refuseAnAmbiguousInstallation(\n projectDir,\n \"eject\",\n providerNamedBy(flags.provider),\n (message) => this.error(message, { exit: EXIT_CODES.INVALID_ARGS }),\n );\n\n // Before anything is copied: a config nobody can read is recreated, not ejected over, and a\n // refusal past this point would follow files already written.\n await this.ensureConfigReadable(projectDir);\n const ejectType = this.validateEjectType(args.type);\n const outputBase = await this.resolveOutputBase(flags, projectDir);\n\n this.printHeader(\n await this.resolveBrandingName(projectDir),\n flags.output ? outputBase : undefined,\n );\n\n const sourceResult = await this.loadSourceIfNeeded(ejectType, projectDir);\n await this.executeEject(ejectType, outputBase, flags, projectDir, sourceResult);\n await this.ensureConfig(projectDir, sourceResult);\n\n this.reportEnding();\n }\n\n /**\n * The command's last word.\n *\n * `Eject complete!` claims the whole eject landed, so it is withheld whenever part of it did\n * not — the account {@link BaseCommand.exitIfWorkIncomplete} prints replaces that tick rather\n * than sitting under it, and carries the non-zero exit with it.\n */\n private reportEnding(): void {\n this.log(\"\");\n if (!this.hasIncompleteWork) this.logSuccess(\"Eject complete!\");\n this.log(\"\");\n\n this.exitIfWorkIncomplete();\n }\n\n private validateEjectType(typeArg: string | undefined): EjectType {\n if (!typeArg) {\n this.error(\"Please specify what to eject: agent-partials, templates, skills, or all\", {\n exit: EXIT_CODES.INVALID_ARGS,\n });\n }\n\n if (!isEjectType(typeArg)) {\n this.error(`Unknown eject type: ${typeArg}`, {\n exit: EXIT_CODES.INVALID_ARGS,\n });\n }\n\n return typeArg;\n }\n\n private async resolveOutputBase(\n flags: { output: string | undefined },\n projectDir: string,\n ): Promise<string> {\n if (flags.output) {\n const expandedPath = flags.output.startsWith(\"~\")\n ? path.join(os.homedir(), flags.output.slice(1))\n : flags.output;\n const outputBase = path.resolve(projectDir, expandedPath);\n\n if (await fileExists(outputBase)) {\n this.error(`Output path exists as a file: ${outputBase}`, {\n exit: EXIT_CODES.INVALID_ARGS,\n });\n }\n\n return outputBase;\n }\n\n return sourceFolderInUse(projectDir, providerInUse(projectDir)).dir;\n }\n\n private printHeader(brandingName: string, outputBase?: string): void {\n this.log(\"\");\n this.log(`${brandingName} Eject`);\n this.log(\"\");\n\n if (outputBase) {\n this.log(`Output directory: ${outputBase}`);\n }\n }\n\n private async loadSourceIfNeeded(\n ejectType: EjectType,\n projectDir: string,\n ): Promise<SourceLoadResult | undefined> {\n if (ejectType === \"skills\" || ejectType === \"all\") {\n const loaded = await loadSource({ projectDir });\n return loaded.sourceResult;\n }\n return undefined;\n }\n\n private async executeEject(\n ejectType: EjectType,\n outputBase: string,\n flags: { force: boolean; output: string | undefined },\n projectDir: string,\n sourceResult: SourceLoadResult | undefined,\n ): Promise<void> {\n const directOutput = !!flags.output;\n\n switch (ejectType) {\n case \"agent-partials\":\n await this.handleAgentPartials(outputBase, flags.force, directOutput, false);\n break;\n case \"templates\":\n await this.handleAgentPartials(outputBase, flags.force, directOutput, true);\n break;\n case \"skills\":\n if (!sourceResult) {\n throw new Error(\"The marketplace must be loaded for skills eject\");\n }\n await this.handleSkills(projectDir, flags.force, sourceResult, directOutput, outputBase);\n break;\n case \"all\":\n if (!sourceResult) {\n throw new Error(\"The marketplace must be loaded for full eject\");\n }\n await this.handleAgentPartials(outputBase, flags.force, directOutput, false);\n await this.handleAgentPartials(outputBase, true, directOutput, true);\n await this.handleSkills(projectDir, flags.force, sourceResult, directOutput, outputBase);\n break;\n default: {\n const _exhaustive: never = ejectType;\n return _exhaustive;\n }\n }\n }\n\n /**\n * The convenience step after the eject: a minimal `config.ts` so a later `compile` has\n * something to read.\n *\n * It can refuse, and by the time it does the ejection has already landed — the templates,\n * partials or skills are on disk and stay there. So the throw is caught rather than left to\n * become the process's exit code: an `ERROR` tells the caller nothing landed and the run can\n * be repeated, which is the wrong instruction for a tree that now holds an ejection. What is\n * owed is the account and `EXIT_CODES.COMPLETED_WITH_FAILURES`.\n *\n * The refusal itself is right and is not weakened here: `ensureMinimalConfig` will not invent\n * a config recording a marketplace it read out of a file it could not evaluate.\n */\n private async ensureConfig(\n projectDir: string,\n sourceResult: SourceLoadResult | undefined,\n ): Promise<void> {\n // Named once, before the write, so the success line and the failure line cannot name\n // different files: the provider is read off the disk and the write may create the folder.\n const configTsRel = relativeConfigPath(projectDir, providerInUse(projectDir));\n\n try {\n const configResult = await ensureMinimalConfig({\n projectDir,\n ...(sourceResult !== undefined && { sourceResult }),\n });\n if (configResult.created) {\n this.logSuccess(`Created ${configTsRel}`);\n }\n } catch (error) {\n this.reportIncompleteWork(\n `Could not create ${configTsRel}: ${getErrorMessage(error)}`,\n INCOMPLETE_WORK_RECOVERY.INSPECT_INSTALLATION,\n );\n }\n }\n\n private async handleAgentPartials(\n outputBase: string,\n force: boolean,\n directOutput: boolean,\n templatesOnly: boolean,\n ): Promise<void> {\n const result = await ejectAgentPartials({\n outputBase,\n force,\n directOutput,\n templatesOnly,\n });\n\n if (result.skipped) {\n this.warn(result.skipReason);\n return;\n }\n\n if (result.templatesSkipped) {\n this.warn(\n \"Agent templates already exist — skipping templates, only ejecting agent partials.\",\n );\n }\n\n this.logSuccess(\n `${templatesOnly ? \"Agent templates\" : \"Agent partials\"} ejected to ${result.destDir}`,\n );\n this.log(\n templatesOnly\n ? \"You can now customize agent templates locally.\"\n : INFO_MESSAGES.AGENT_PARTIALS_CUSTOMIZABLE,\n );\n }\n\n private async handleSkills(\n projectDir: string,\n force: boolean,\n sourceResult: SourceLoadResult,\n directOutput: boolean,\n outputBase: string,\n ): Promise<void> {\n const destDir = directOutput ? outputBase : installedSkillsDir(projectDir);\n const result = await ejectSkills({ destDir, force, sourceResult, matrix });\n\n if (result.skipped) {\n this.warn(result.skipReason);\n return;\n }\n\n this.logSuccess(\n `${plural(result.copiedSkills.length, \"skill\")} ejected to ${destDir} from ${result.sourceLabel}`,\n );\n this.log(\"You can now customize skill content locally.\");\n }\n}\n\ntype EjectAgentPartialsOptions = {\n outputBase: string;\n force: boolean;\n /** When true, outputBase is used directly as the destination (no subdirectory nesting). */\n directOutput?: boolean;\n /** When true, ejects only the _templates directory instead of the full agents directory. */\n templatesOnly?: boolean;\n};\n\ntype EjectAgentPartialsResult =\n | {\n skipped: true;\n skipReason: string;\n templatesSkipped: false;\n }\n | {\n skipped: false;\n /** Destination directory that was written to. */\n destDir: string;\n /** Whether templates were skipped during a full agent-partials eject (existing templates preserved). */\n templatesSkipped: boolean;\n };\n\n/** Direct output writes to the base itself; otherwise agents/ (plus templates/ in templates-only mode). */\nfunction resolveEjectDestDir(\n outputBase: string,\n directOutput: boolean,\n templatesOnly: boolean,\n): string {\n if (directOutput) return outputBase;\n const agentsDir = path.join(outputBase, path.basename(DIRS.agents));\n return templatesOnly ? path.join(agentsDir, path.basename(DIRS.templates)) : agentsDir;\n}\n\n/**\n * Copies agent partials or templates from the CLI source to a target directory.\n *\n * When `templatesOnly` is true, copies only the _templates subdirectory.\n * When false, copies the full agents directory (optionally skipping existing templates).\n *\n * Returns structured data — the command decides what to log.\n */\nasync function ejectAgentPartials(\n options: EjectAgentPartialsOptions,\n): Promise<EjectAgentPartialsResult> {\n const { outputBase, force, directOutput = false, templatesOnly = false } = options;\n\n const sourceDir = templatesOnly\n ? path.join(PROJECT_ROOT, DIRS.templates)\n : path.join(PROJECT_ROOT, DIRS.agents);\n\n if (!(await directoryExists(sourceDir))) {\n return {\n skipped: true,\n skipReason: templatesOnly\n ? \"No agent templates found in CLI.\"\n : \"No agent partials found in CLI.\",\n templatesSkipped: false,\n };\n }\n\n const destDir = resolveEjectDestDir(outputBase, directOutput, templatesOnly);\n\n const templatesBasename = path.basename(DIRS.templates);\n\n if ((await directoryExists(destDir)) && !force) {\n if (templatesOnly) {\n return {\n skipped: true,\n skipReason: `Agent templates already exist at ${destDir}. Use --force to overwrite.`,\n templatesSkipped: false,\n };\n }\n\n const hasTemplates = await directoryExists(path.join(destDir, templatesBasename));\n if ((await hasAgentPartialDirs(destDir)) && !hasTemplates) {\n return {\n skipped: true,\n skipReason: `Agent partials already exist at ${destDir}. Use --force to overwrite.`,\n templatesSkipped: false,\n };\n }\n }\n\n await ensureDir(destDir);\n\n const skipTemplates =\n !templatesOnly && !force && (await directoryExists(path.join(destDir, templatesBasename)));\n\n if (skipTemplates) {\n const sourceEntries = await listDirectories(sourceDir);\n const nonTemplateEntries = sourceEntries.filter((entry) => entry !== templatesBasename);\n for (const entry of nonTemplateEntries) {\n await copy(path.join(sourceDir, entry), path.join(destDir, entry));\n }\n } else {\n await copy(sourceDir, destDir);\n }\n\n return {\n skipped: false,\n destDir,\n templatesSkipped: skipTemplates,\n };\n}\n\ntype EjectSkillsOptions = {\n destDir: string;\n force: boolean;\n sourceResult: SourceLoadResult;\n matrix: MergedSkillsMatrix;\n};\n\ntype EjectSkillsResult =\n | {\n skipped: true;\n skipReason: string;\n copiedSkills: [];\n }\n | {\n skipped: false;\n /** Array of skills that were copied. */\n copiedSkills: CopiedSkill[];\n /** Label describing the source that skills were copied from. */\n sourceLabel: string;\n };\n\n/**\n * Copies the marketplace's own skills from source to a target directory.\n *\n * Only the skills the loaded marketplace carries, because those are the only ones its folder\n * holds: a global installation's skill seated from another marketplace is in the matrix and not\n * on disk here. Skills already marked as local are filtered out too, then the remaining skills\n * are copied using copySkillsToLocalFlattened.\n *\n * Returns structured data — the command decides what to log.\n */\nasync function ejectSkills(options: EjectSkillsOptions): Promise<EjectSkillsResult> {\n const { destDir, force, sourceResult, matrix } = options;\n\n if ((await directoryExists(destDir)) && !force) {\n return {\n skipped: true,\n skipReason: `Skills already exist at ${destDir}. Use --force to overwrite.`,\n copiedSkills: [],\n };\n }\n\n const skillIds = [...sourceResult.marketplaceSkillIds].filter(\n (skillId) => !matrix.skills[skillId]?.local,\n );\n\n if (skillIds.length === 0) {\n return {\n skipped: true,\n skipReason: \"No skills found in the marketplace to eject.\",\n copiedSkills: [],\n };\n }\n\n await ensureDir(destDir);\n\n const copiedSkills = await copySkillsToLocalFlattened(skillIds, destDir, sourceResult);\n\n const sourceLabel = sourceResult.isLocal\n ? sourceResult.sourcePath\n : sourceResult.marketplace || sourceResult.sourceConfig.source;\n\n return {\n skipped: false,\n copiedSkills,\n sourceLabel,\n };\n}\n\n/**\n * The skills folder the install copies into for the installation `projectDir` roots — at the\n * scope that directory is, on the provider this run is about — so an eject lands where that\n * installation's host reads skills: `.claude/skills`, `<repo>/.agents/skills` or\n * `$CODEX_HOME/skills`.\n */\nfunction installedSkillsDir(projectDir: string): string {\n const scope = isHomeDirectory(projectDir) ? \"global\" : \"project\";\n return resolveInstallPaths(projectDir, scope).skillsDir;\n}\n\ntype EnsureMinimalConfigOptions = {\n projectDir: string;\n sourceResult?: SourceLoadResult;\n};\n\ntype EnsureMinimalConfigResult = {\n /** Path to the config file. */\n configPath: string;\n /** Whether a new config was created. */\n created: boolean;\n};\n\n/**\n * Ensures a minimal config.ts exists so `npx agents-inc compile` works after eject.\n *\n * If the config already exists, returns immediately with `created: false`.\n * Otherwise generates a minimal config from the resolved source and project metadata.\n *\n * Returns structured data — the command decides what to log.\n */\nasync function ensureMinimalConfig(\n options: EnsureMinimalConfigOptions,\n): Promise<EnsureMinimalConfigResult> {\n const { projectDir, sourceResult } = options;\n\n // One read for the whole function: the config it may invent, and the blank global pair it may\n // create beside it, belong to the same installation.\n const provider = providerInUse(projectDir);\n const tsConfigPath = getProjectConfigPath(projectDir, provider);\n\n if (await fileExists(tsConfigPath)) {\n return { configPath: tsConfigPath, created: false };\n }\n\n // ABORT on an unreadable config. The project has none — the guard above returned for that — so\n // what these two can meet is an unreadable GLOBAL config, and the file about to be invented\n // would record a marketplace read from nowhere. The second call is unreachable for the same\n // reason the guard exists: this project's own config is not there to be unreadable.\n const resolvedConfig =\n sourceResult?.sourceConfig ?? (await resolveSource({ caller: \"stored\", projectDir }));\n const existingProjectConfig = await loadProjectSourceConfig(projectDir);\n const source = resolvedConfig.source || undefined;\n\n // At the home directory the invented config IS the global manifest, and the\n // file it opens with `import type { ProjectConfig } from \"./config-types\"`\n // cannot resolve its own types without the sibling. The gate writes the pair.\n if (isHomeDirectory(projectDir)) {\n await ensureBlankPair(provider);\n if (source) await recordSource(projectDir, source);\n return { configPath: tsConfigPath, created: true };\n }\n\n await writeProjectPartial(\n projectDir,\n {\n skills: [],\n agents: [],\n ...(source ? { marketplace: source } : {}),\n ...(resolvedConfig.marketplace ? { marketplaceName: resolvedConfig.marketplace } : {}),\n ...(existingProjectConfig?.author ? { author: existingProjectConfig.author } : {}),\n ...(existingProjectConfig?.agentsSource\n ? { agentsSource: existingProjectConfig.agentsSource }\n : {}),\n },\n { fallbackName: path.basename(projectDir) },\n );\n\n return { configPath: tsConfigPath, created: true };\n}\n\n/**\n * Records the marketplace ref in whichever scope's config `projectDir` names. At the home\n * directory that config is the global manifest every project's generated types\n * import from, so the write goes through the gate: registered projects inline\n * the scalar and follow it.\n */\nasync function recordSource(projectDir: string, source: string): Promise<void> {\n if (isHomeDirectory(projectDir)) {\n await mutateGlobal(\n { kind: \"set-source\", source, fallbackName: path.basename(projectDir) },\n lazyGateDeps(projectDir),\n );\n return;\n }\n\n // ABORT on an unreadable config. The `?? {}` is a fallback for a config that is not THERE; on\n // one that is there and unreadable it would hand the writer an empty partial, and this scalar\n // write would replace the user's whole file with a two-field one under an invented name.\n const existing = (await loadProjectSourceConfig(projectDir)) ?? {};\n await writeProjectPartial(\n projectDir,\n { ...existing, marketplace: source },\n { fallbackName: path.basename(projectDir) },\n );\n}\n\n/** Checks whether the agents directory contains any agent subdirectories (not just _templates). */\nasync function hasAgentPartialDirs(agentsDir: string): Promise<boolean> {\n const subdirs = await listDirectories(agentsDir);\n const templatesBasename = path.basename(DIRS.templates);\n return subdirs.some((dir) => dir !== templatesBasename);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,SAAS,MAAM,aAAa;AAC5B,OAAO,UAAU;AACjB,OAAO,QAAQ;AAoCf,IAAM,cAAc,CAAC,kBAAkB,aAAa,UAAU,KAAK;AAGnE,SAAS,YAAY,OAAmC;AACtD,SAAQ,YAAkC,SAAS,KAAK;AAC1D;AAEA,IAAqB,QAArB,MAAqB,eAAc,YAAY;AAAA,EAC7C,OAAO,UAAU;AAAA,EACjB,OAAO,cACL;AAAA,EAKF,OAAO,WAAW;AAAA,IAChB;AAAA,MACE,aAAa;AAAA,MACb,SAAS;AAAA,IACX;AAAA,IACA;AAAA,MACE,aAAa;AAAA,MACb,SAAS;AAAA,IACX;AAAA,IACA;AAAA,MACE,aAAa;AAAA,MACb,SAAS;AAAA,IACX;AAAA,IACA;AAAA,MACE,aAAa;AAAA,MACb,SAAS;AAAA,IACX;AAAA,IACA;AAAA,MACE,aAAa;AAAA,MACb,SAAS;AAAA,IACX;AAAA,EACF;AAAA,EAEA,OAAO,OA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AAO,IAAI,CAAC;AAAA,MACxC,GAAI,eAAe,cAAc,EAAE,iBAAiB,eAAe,YAAY,IAAI,CAAC;AAAA,MACpF,GAAI,uBAAuB,SAAS,EAAE,QAAQ,sBAAsB,OAAO,IAAI,CAAC;AAAA,MAChF,GAAI,uBAAuB,eACvB,EAAE,cAAc,sBAAsB,aAAa,IACnD,CAAC;AAAA,IACP;AAAA,IACA,EAAE,cAAc,KAAK,SAAS,UAAU,EAAE;AAAA,EAC5C;AAEA,SAAO,EAAE,YAAY,cAAc,SAAS,KAAK;AACnD;AAQA,eAAe,aAAa,YAAoB,QAA+B;AAC7E,MAAI,gBAAgB,UAAU,GAAG;AAC/B,UAAM;AAAA,MACJ,EAAE,MAAM,cAAc,QAAQ,cAAc,KAAK,SAAS,UAAU,EAAE;AAAA,MACtE,aAAa,UAAU;AAAA,IACzB;AACA;AAAA,EACF;AAKA,QAAM,WAAY,MAAM,wBAAwB,UAAU,KAAM,CAAC;AACjE,QAAM;AAAA,IACJ;AAAA,IACA,EAAE,GAAG,UAAU,aAAa,OAAO;AAAA,IACnC,EAAE,cAAc,KAAK,SAAS,UAAU,EAAE;AAAA,EAC5C;AACF;AAGA,eAAe,oBAAoB,WAAqC;AACtE,QAAM,UAAU,MAAM,gBAAgB,SAAS;AAC/C,QAAM,oBAAoB,KAAK,SAAS,KAAK,SAAS;AACtD,SAAO,QAAQ,KAAK,CAAC,QAAQ,QAAQ,iBAAiB;AACxD;","names":["matrix"]}
|
package/dist/commands/init.js
CHANGED
|
@@ -7,54 +7,26 @@ import {
|
|
|
7
7
|
getDashboardData,
|
|
8
8
|
runDashboardFlow,
|
|
9
9
|
showDashboard
|
|
10
|
-
} from "../chunk-
|
|
11
|
-
import "../chunk-
|
|
12
|
-
import "../chunk-
|
|
13
|
-
import "../chunk-
|
|
14
|
-
import "../chunk-WWIFNPJG.js";
|
|
15
|
-
import "../chunk-RAHSOJQ2.js";
|
|
16
|
-
import "../chunk-DAIEQJIF.js";
|
|
17
|
-
import "../chunk-SCOQ34YM.js";
|
|
18
|
-
import "../chunk-4NDBUJHK.js";
|
|
19
|
-
import "../chunk-2VUYFTUB.js";
|
|
20
|
-
import "../chunk-T6UWJAB3.js";
|
|
21
|
-
import "../chunk-6L75SQZU.js";
|
|
22
|
-
import "../chunk-LFWLEDUG.js";
|
|
23
|
-
import "../chunk-TZ2YJJKK.js";
|
|
24
|
-
import "../chunk-SAYZWCH6.js";
|
|
25
|
-
import "../chunk-PNB3524H.js";
|
|
26
|
-
import "../chunk-XZEVWPX6.js";
|
|
27
|
-
import "../chunk-QHDPLLK6.js";
|
|
28
|
-
import "../chunk-MPTNC32T.js";
|
|
29
|
-
import "../chunk-TSIU7DME.js";
|
|
30
|
-
import "../chunk-JOEA52NR.js";
|
|
31
|
-
import "../chunk-VRXX4D6K.js";
|
|
32
|
-
import "../chunk-SXVHSOTH.js";
|
|
33
|
-
import "../chunk-XQHZPINL.js";
|
|
34
|
-
import "../chunk-JQRJQ4SS.js";
|
|
35
|
-
import "../chunk-TTY6DPJN.js";
|
|
36
|
-
import "../chunk-WTJ3AY33.js";
|
|
37
|
-
import "../chunk-WVUDLKIO.js";
|
|
38
|
-
import "../chunk-25MPBIK3.js";
|
|
10
|
+
} from "../chunk-NCWDK6L7.js";
|
|
11
|
+
import "../chunk-44TE3RKH.js";
|
|
12
|
+
import "../chunk-6HNXYYVF.js";
|
|
13
|
+
import "../chunk-OYJQUA3D.js";
|
|
39
14
|
import "../chunk-4AAOOAIN.js";
|
|
40
15
|
import "../chunk-OZXAJNLA.js";
|
|
41
|
-
import "../chunk-
|
|
42
|
-
import "../chunk-
|
|
43
|
-
import "../chunk-
|
|
44
|
-
import "../chunk-
|
|
45
|
-
import "../chunk-
|
|
46
|
-
import "../chunk-
|
|
47
|
-
import "../chunk-MAWNVT2C.js";
|
|
16
|
+
import "../chunk-F5EBEATU.js";
|
|
17
|
+
import "../chunk-7RDMTR64.js";
|
|
18
|
+
import "../chunk-F2BHT5C4.js";
|
|
19
|
+
import "../chunk-HED2DAXZ.js";
|
|
20
|
+
import "../chunk-3G7X2WKI.js";
|
|
21
|
+
import "../chunk-BMRUNMPV.js";
|
|
48
22
|
import "../chunk-JFLVEFFP.js";
|
|
49
|
-
import "../chunk-
|
|
50
|
-
import "../chunk-
|
|
51
|
-
import "../chunk-
|
|
52
|
-
import "../chunk-
|
|
53
|
-
import "../chunk-
|
|
54
|
-
import "../chunk-
|
|
55
|
-
import "../chunk-
|
|
56
|
-
import "../chunk-ENGYJCTF.js";
|
|
57
|
-
import "../chunk-OI2H6M5I.js";
|
|
23
|
+
import "../chunk-RIPSGNLU.js";
|
|
24
|
+
import "../chunk-V3KTSP3Q.js";
|
|
25
|
+
import "../chunk-CLPUWOSA.js";
|
|
26
|
+
import "../chunk-MQ6CGZNJ.js";
|
|
27
|
+
import "../chunk-52HDHJ7I.js";
|
|
28
|
+
import "../chunk-PJWGTNOX.js";
|
|
29
|
+
import "../chunk-NQW25DCF.js";
|
|
58
30
|
export {
|
|
59
31
|
Dashboard,
|
|
60
32
|
dashboardCountLines,
|
package/dist/commands/list.js
CHANGED
|
@@ -1,23 +1,20 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import {
|
|
3
3
|
SkillAgentSummary
|
|
4
|
-
} from "../chunk-
|
|
4
|
+
} from "../chunk-6ZRH5RHC.js";
|
|
5
|
+
import "../chunk-NIHUOWE4.js";
|
|
5
6
|
import {
|
|
6
7
|
render
|
|
7
8
|
} from "../chunk-JFLVEFFP.js";
|
|
8
|
-
import {
|
|
9
|
-
hydrateWizardStore
|
|
10
|
-
} from "../chunk-7JNJ52CD.js";
|
|
11
9
|
import {
|
|
12
10
|
otherInstallationsInThisScope,
|
|
13
11
|
providerFlag,
|
|
14
12
|
providerNamedBy
|
|
15
|
-
} from "../chunk-
|
|
13
|
+
} from "../chunk-RIPSGNLU.js";
|
|
16
14
|
import {
|
|
17
15
|
BaseCommand
|
|
18
|
-
} from "../chunk-
|
|
19
|
-
import "../chunk-
|
|
20
|
-
import "../chunk-RZDXDMT6.js";
|
|
16
|
+
} from "../chunk-V3KTSP3Q.js";
|
|
17
|
+
import "../chunk-CLPUWOSA.js";
|
|
21
18
|
import {
|
|
22
19
|
INSTALL_MODE_LABELS,
|
|
23
20
|
chooseProviderForThisRun,
|
|
@@ -26,14 +23,14 @@ import {
|
|
|
26
23
|
getInstallationInfo,
|
|
27
24
|
loadProjectConfig,
|
|
28
25
|
providerInUse
|
|
29
|
-
} from "../chunk-
|
|
30
|
-
import "../chunk-
|
|
26
|
+
} from "../chunk-MQ6CGZNJ.js";
|
|
27
|
+
import "../chunk-52HDHJ7I.js";
|
|
31
28
|
import {
|
|
32
29
|
CLI_COLORS,
|
|
33
30
|
CLI_INVOKE_COMMAND,
|
|
34
31
|
DEFAULT_BRANDING
|
|
35
|
-
} from "../chunk-
|
|
36
|
-
import "../chunk-
|
|
32
|
+
} from "../chunk-PJWGTNOX.js";
|
|
33
|
+
import "../chunk-NQW25DCF.js";
|
|
37
34
|
|
|
38
35
|
// src/cli/commands/list.tsx
|
|
39
36
|
import { useEffect } from "react";
|
|
@@ -56,7 +53,16 @@ var ListView = ({ mode, source, skillConfigs, agentConfigs }) => {
|
|
|
56
53
|
/* @__PURE__ */ jsx(Text, { color: CLI_COLORS.NEUTRAL, children: source })
|
|
57
54
|
] })
|
|
58
55
|
] }),
|
|
59
|
-
/* @__PURE__ */ jsx(
|
|
56
|
+
/* @__PURE__ */ jsx(
|
|
57
|
+
SkillAgentSummary,
|
|
58
|
+
{
|
|
59
|
+
skillConfigs,
|
|
60
|
+
agentConfigs,
|
|
61
|
+
installedSkillConfigs: skillConfigs,
|
|
62
|
+
installedAgentConfigs: agentConfigs,
|
|
63
|
+
isInitMode: false
|
|
64
|
+
}
|
|
65
|
+
)
|
|
60
66
|
] });
|
|
61
67
|
};
|
|
62
68
|
var List = class _List extends BaseCommand {
|
|
@@ -118,10 +124,6 @@ var List = class _List extends BaseCommand {
|
|
|
118
124
|
const modeLabel = INSTALL_MODE_LABELS[installation.mode];
|
|
119
125
|
const activeSkills = config.skills.filter((s) => !s.excluded);
|
|
120
126
|
const activeAgents = config.agents.filter((a) => !a.excluded);
|
|
121
|
-
hydrateWizardStore({
|
|
122
|
-
installedSkillConfigs: activeSkills,
|
|
123
|
-
installedAgentConfigs: activeAgents
|
|
124
|
-
});
|
|
125
127
|
const { waitUntilExit, clear } = render(
|
|
126
128
|
/* @__PURE__ */ jsx(
|
|
127
129
|
ListView,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/cli/commands/list.tsx"],"sourcesContent":["import React, { useEffect } from \"react\";\n\nimport { Box, Text, useApp } from \"ink\";\nimport { render } from \"../components/render.js\";\n\nimport { BaseCommand } from \"../base-command.js\";\nimport { CLI_INVOKE_COMMAND, CLI_COLORS, DEFAULT_BRANDING } from \"../consts.js\";\nimport { chooseProviderForThisRun, providerInUse } from \"../lib/installation/install-layout.js\";\nimport {\n otherInstallationsInThisScope,\n providerFlag,\n providerNamedBy,\n} from \"../lib/installation/provider-flag.js\";\nimport { getInstallationInfo, formatInstallationDisplay } from \"../lib/plugins/index.js\";\nimport { detectInstallation, INSTALL_MODE_LABELS } from \"../lib/installation/installation.js\";\nimport { loadProjectConfig } from \"../lib/configuration/project-config.js\";\nimport { SkillAgentSummary } from \"../components/
|
|
1
|
+
{"version":3,"sources":["../../src/cli/commands/list.tsx"],"sourcesContent":["import React, { useEffect } from \"react\";\n\nimport { Box, Text, useApp } from \"ink\";\nimport { render } from \"../components/render.js\";\n\nimport { BaseCommand } from \"../base-command.js\";\nimport { CLI_INVOKE_COMMAND, CLI_COLORS, DEFAULT_BRANDING } from \"../consts.js\";\nimport { chooseProviderForThisRun, providerInUse } from \"../lib/installation/install-layout.js\";\nimport {\n otherInstallationsInThisScope,\n providerFlag,\n providerNamedBy,\n} from \"../lib/installation/provider-flag.js\";\nimport { getInstallationInfo, formatInstallationDisplay } from \"../lib/plugins/index.js\";\nimport { detectInstallation, INSTALL_MODE_LABELS } from \"../lib/installation/installation.js\";\nimport { loadProjectConfig } from \"../lib/configuration/project-config.js\";\nimport { SkillAgentSummary } from \"../components/common/skill-agent-summary.js\";\nimport type { AgentScopeConfig, SkillConfig } from \"../types/config.js\";\n\ntype ListViewProps = {\n mode: string;\n source?: string | undefined;\n skillConfigs: SkillConfig[];\n agentConfigs: AgentScopeConfig[];\n};\n\nconst ListView: React.FC<ListViewProps> = ({ mode, source, skillConfigs, agentConfigs }) => {\n const { exit } = useApp();\n\n useEffect(() => {\n const timer = setTimeout(() => exit(), 0);\n return () => clearTimeout(timer);\n }, [exit]);\n\n return (\n <Box flexDirection=\"column\" paddingX={1} paddingY={1}>\n <Box flexDirection=\"column\" marginBottom={1}>\n <Box flexDirection=\"row\" columnGap={1}>\n <Text color={CLI_COLORS.WARNING} bold>\n Mode\n </Text>\n <Text color={CLI_COLORS.NEUTRAL}>{mode}</Text>\n </Box>\n {source && (\n <Box flexDirection=\"row\" columnGap={1}>\n <Text color={CLI_COLORS.WARNING} bold>\n Marketplace\n </Text>\n <Text color={CLI_COLORS.NEUTRAL}>{source}</Text>\n </Box>\n )}\n </Box>\n\n {/* Installed and current are one configuration, so every row reads unchanged. */}\n <SkillAgentSummary\n skillConfigs={skillConfigs}\n agentConfigs={agentConfigs}\n installedSkillConfigs={skillConfigs}\n installedAgentConfigs={agentConfigs}\n isInitMode={false}\n />\n </Box>\n );\n};\n\nexport default class List extends BaseCommand {\n static summary = \"Show installation information\";\n static description = `Display details about the ${DEFAULT_BRANDING.NAME} installation (local or plugin mode)`;\n static aliases = [\"ls\"];\n\n static flags = { provider: providerFlag() };\n\n static examples = [\n {\n description: \"Show current installation details\",\n command: \"<%= config.bin %> <%= command.id %>\",\n },\n ];\n\n /**\n * Which of the scope's installations this report is about, said out loud where there are two.\n *\n * **`list` reported one of two and nothing anywhere said so.** Everything below resolves the\n * provider through `providerInUse`, which answers by ROSTER ORDER for a scope holding one\n * installation of each — so the report named one installation, its mode, its counts and its\n * config path, all correct, about the half of the directory the user was not asking after. Every\n * command that WRITES refuses this state by name and `doctor` reports it as a finding; the one\n * command whose whole job is to say what is installed was silent about it.\n *\n * It reports rather than refusing, for the reason `doctor` does: a read-only command that\n * refused would leave a user whose scope holds two installations unable to look at either,\n * which is the one state they most need to see.\n */\n private async sayWhichInstallationThisIs(providerFlagValue: string | undefined): Promise<void> {\n const named = providerNamedBy(providerFlagValue);\n if (named !== undefined) {\n chooseProviderForThisRun(named);\n return;\n }\n\n const cwd = process.cwd();\n const line = await otherInstallationsInThisScope(cwd, providerInUse(cwd));\n if (line !== null) this.log(line);\n }\n\n async run(): Promise<void> {\n const { flags } = await this.parse(List);\n await this.sayWhichInstallationThisIs(flags.provider);\n await this.ensureConfigReadable(process.cwd());\n\n const installation = await detectInstallation();\n\n if (!installation) {\n this.log(\"No installation found.\");\n this.log(`Run '${CLI_INVOKE_COMMAND} init' to create one.`);\n return;\n }\n\n const loaded = await loadProjectConfig(installation.projectDir);\n\n if (!loaded?.config || !process.stdin.isTTY) {\n const info = await getInstallationInfo();\n if (info) {\n this.log(\"\");\n this.log(formatInstallationDisplay(info));\n this.log(\"\");\n }\n return;\n }\n\n const { config } = loaded;\n const modeLabel = INSTALL_MODE_LABELS[installation.mode];\n const activeSkills = config.skills.filter((s) => !s.excluded);\n const activeAgents = config.agents.filter((a) => !a.excluded);\n\n const { waitUntilExit, clear } = render(\n <ListView\n mode={modeLabel}\n source={config.marketplace}\n skillConfigs={activeSkills}\n agentConfigs={activeAgents}\n />,\n );\n\n await waitUntilExit();\n clear();\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,SAAgB,iBAAiB;AAEjC,SAAS,KAAK,MAAM,cAAc;AAmC1B,SACE,KADF;AAXR,IAAM,WAAoC,CAAC,EAAE,MAAM,QAAQ,cAAc,aAAa,MAAM;AAC1F,QAAM,EAAE,KAAK,IAAI,OAAO;AAExB,YAAU,MAAM;AACd,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from "../../chunk-
|
|
6
|
-
import "../../chunk-
|
|
7
|
-
import "../../chunk-RZDXDMT6.js";
|
|
5
|
+
} from "../../chunk-V3KTSP3Q.js";
|
|
6
|
+
import "../../chunk-CLPUWOSA.js";
|
|
8
7
|
import {
|
|
9
8
|
isDirectoryEmpty,
|
|
10
9
|
validateKebabCaseName,
|
|
11
10
|
validateMarketplaceName,
|
|
12
11
|
writeFile
|
|
13
|
-
} from "../../chunk-
|
|
14
|
-
import "../../chunk-
|
|
12
|
+
} from "../../chunk-MQ6CGZNJ.js";
|
|
13
|
+
import "../../chunk-52HDHJ7I.js";
|
|
15
14
|
import {
|
|
16
15
|
CLI_INVOKE_COMMAND,
|
|
17
16
|
DEFAULT_VERSION,
|
|
17
|
+
EDITOR_URL,
|
|
18
18
|
SKILLS_DIR_PATH,
|
|
19
19
|
SKILL_CATEGORIES_PATH,
|
|
20
20
|
SKILL_RULES_PATH,
|
|
21
21
|
STACKS_FILE_PATH,
|
|
22
22
|
STANDARD_FILES
|
|
23
|
-
} from "../../chunk-
|
|
24
|
-
import "../../chunk-
|
|
23
|
+
} from "../../chunk-PJWGTNOX.js";
|
|
24
|
+
import "../../chunk-NQW25DCF.js";
|
|
25
25
|
|
|
26
26
|
// src/cli/commands/new/marketplace.ts
|
|
27
27
|
import { Args } from "@oclif/core";
|
|
@@ -103,14 +103,13 @@ function skillRulesModule() {
|
|
|
103
103
|
"// Relationships between skills \u2014 conflicts, requires, alternatives.",
|
|
104
104
|
"//",
|
|
105
105
|
"// Rules may only name skills the public catalogue carries; this marketplace's own",
|
|
106
|
-
"// skills cannot be named here yet, and a rule that names one will not load.
|
|
107
|
-
"// file still has to exist, so it ships with a version and no relationships."
|
|
106
|
+
"// skills cannot be named here yet, and a rule that names one will not load."
|
|
108
107
|
].join("\n"),
|
|
109
108
|
{ version: DEFAULT_VERSION }
|
|
110
109
|
);
|
|
111
110
|
}
|
|
112
111
|
function stacksModule(marketplaceName, skillId) {
|
|
113
|
-
return configModule("// The stacks this marketplace offers
|
|
112
|
+
return configModule("// The stacks this marketplace offers.", {
|
|
114
113
|
stacks: [
|
|
115
114
|
{
|
|
116
115
|
id: `${marketplaceName}-starter`,
|
|
@@ -226,7 +225,8 @@ var NewMarketplace = class _NewMarketplace extends BaseCommand {
|
|
|
226
225
|
`Replace ${skillDir}/ with a skill of your own. Every skill id must begin with '${marketplaceName}-'`,
|
|
227
226
|
`${CLI_INVOKE_COMMAND} build plugins`,
|
|
228
227
|
`${CLI_INVOKE_COMMAND} build marketplace`,
|
|
229
|
-
|
|
228
|
+
`Push it to GitHub, then add it from the Marketplace button at ${EDITOR_URL}`,
|
|
229
|
+
`${CLI_INVOKE_COMMAND} init --from <id> --marketplace ${marketplaceDir} (from a project \u2014 tests your local changes against a configuration built there)`
|
|
230
230
|
];
|
|
231
231
|
this.log("");
|
|
232
232
|
this.log("Next steps:");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/cli/commands/new/marketplace.ts","../../../src/cli/lib/marketplace-scaffold.ts"],"sourcesContent":["import { Args } from \"@oclif/core\";\nimport path from \"path\";\n\nimport { BaseCommand } from \"../../base-command.js\";\nimport { CLI_INVOKE_COMMAND, SKILLS_DIR_PATH } from \"../../consts.js\";\nimport { EXIT_CODES } from \"../../lib/exit-codes.js\";\nimport { validateMarketplaceName } from \"../../lib/marketplace-generator.js\";\nimport { exampleSkillId, writeMarketplaceScaffold } from \"../../lib/marketplace-scaffold.js\";\nimport { validateKebabCaseName } from \"../../lib/validate-kebab-name.js\";\nimport { isDirectoryEmpty } from \"../../utils/fs.js\";\n\n/**\n * How a reserved name is replaced here. The name is this command's argument, and nothing it could\n * be read from exists yet — no package.json, and no `--name` — so another argument is the way out.\n */\nconst RESERVED_NAME_WAY_OUT = `run '${CLI_INVOKE_COMMAND} new marketplace <other-name>'`;\n\n/**\n * The refusal over a target directory that already holds something.\n *\n * A scaffold writes a whole marketplace, so writing into an occupied directory\n * would mean merging with — or overwriting — work this command did not author.\n * Both ways out are one step, which is why there is no `--force`: a flag that\n * overwrites an author's own files is the destructive half of a silent fallback.\n */\nfunction occupiedDirectoryError(marketplaceDir: string): string {\n return (\n `${marketplaceDir} already holds files. A scaffold writes a whole marketplace, ` +\n `so it will not write into a directory that already has contents. Choose another ` +\n `name, or empty that directory first.`\n );\n}\n\nexport default class NewMarketplace extends BaseCommand {\n static summary = \"Scaffold a marketplace of your own\";\n\n static description =\n \"Create a directory holding everything the CLI needs to read a marketplace: a package.json \" +\n \"carrying its identity, the three config files, and one example skill already named in the \" +\n \"marketplace's own namespace. It scaffolds only — run 'build plugins' and 'build marketplace' \" +\n \"to publish what you have written.\";\n\n static examples = [\n {\n description: \"Scaffold a marketplace named acme into ./acme\",\n command: \"<%= config.bin %> <%= command.id %> acme\",\n },\n ];\n\n static args = {\n name: Args.string({\n description:\n \"Name of the marketplace (kebab-case). Becomes the directory, the package.json name, \" +\n \"and the prefix every skill id must carry.\",\n required: true,\n }),\n };\n\n async run(): Promise<void> {\n const { args } = await this.parse(NewMarketplace);\n const marketplaceName = args.name;\n const marketplaceDir = path.join(process.cwd(), marketplaceName);\n\n this.refuseUnusableName(marketplaceName);\n await this.refuseOccupiedDirectory(marketplaceDir);\n\n try {\n const written = await writeMarketplaceScaffold(marketplaceDir, marketplaceName);\n this.reportCreated(marketplaceName, marketplaceDir, written);\n this.reportNextSteps(marketplaceName, marketplaceDir);\n } catch (error) {\n this.handleError(error);\n }\n }\n\n /**\n * Both name rules `build marketplace` enforces, enforced here instead — failing\n * at creation beats failing at publish, when the name is already the directory,\n * the package name and the prefix on every id.\n */\n private refuseUnusableName(marketplaceName: string): void {\n const kebabError = validateKebabCaseName(marketplaceName, \"Marketplace\");\n if (kebabError) {\n this.error(kebabError, { exit: EXIT_CODES.INVALID_ARGS });\n }\n\n // The package.json this command is about to write names the marketplace after\n // itself, so the marketplace name IS the package name. That is what keeps the\n // public catalogue's exemption out of reach: it belongs to one npm package, and\n // nobody scaffolds that package from here.\n const reservedError = validateMarketplaceName(\n marketplaceName,\n marketplaceName,\n RESERVED_NAME_WAY_OUT,\n );\n if (reservedError) {\n this.error(reservedError, { exit: EXIT_CODES.ERROR });\n }\n }\n\n private async refuseOccupiedDirectory(marketplaceDir: string): Promise<void> {\n if (await isDirectoryEmpty(marketplaceDir)) return;\n\n this.error(occupiedDirectoryError(marketplaceDir), { exit: EXIT_CODES.ERROR });\n }\n\n private reportCreated(\n marketplaceName: string,\n marketplaceDir: string,\n written: readonly string[],\n ): void {\n this.log(\"\");\n this.logSuccess(`Created marketplace '${marketplaceName}' at ${marketplaceDir}`);\n for (const relPath of written) {\n this.log(` ${relPath}`);\n }\n }\n\n private reportNextSteps(marketplaceName: string, marketplaceDir: string): void {\n const skillDir = path.join(SKILLS_DIR_PATH, exampleSkillId(marketplaceName));\n const steps = [\n `cd ${marketplaceName}`,\n \"Replace the placeholder 'author' in package.json with your own handle — it is what 'build marketplace' records as this marketplace's owner\",\n `Replace ${skillDir}/ with a skill of your own. Every skill id must begin with '${marketplaceName}-'`,\n `${CLI_INVOKE_COMMAND} build plugins`,\n `${CLI_INVOKE_COMMAND} build marketplace`,\n `${CLI_INVOKE_COMMAND} init --marketplace ${marketplaceDir} (from a project)`,\n ];\n\n this.log(\"\");\n this.log(\"Next steps:\");\n for (const [index, step] of steps.entries()) {\n this.log(` ${index + 1}. ${step}`);\n }\n this.log(\"\");\n }\n}\n","import path from \"path\";\n\nimport {\n DEFAULT_VERSION,\n SKILL_CATEGORIES_PATH,\n SKILL_RULES_PATH,\n SKILLS_DIR_PATH,\n STACKS_FILE_PATH,\n STANDARD_FILES,\n} from \"../consts.js\";\nimport { writeFile } from \"../utils/fs.js\";\n\n/** One file of a scaffolded marketplace: where it goes, and what it holds. */\ntype ScaffoldFile = {\n /** Path relative to the marketplace root. */\n relPath: string;\n contents: string;\n};\n\n/**\n * The bare id of the one skill a scaffold ships. The marketplace's own name is\n * prefixed onto it by {@link exampleSkillId} — this half is the same for every\n * marketplace, and on its own it belongs to none of them.\n */\nconst EXAMPLE_SKILL_SUFFIX = \"example-skill\";\n\n/**\n * The domain the scaffolded category sits under.\n *\n * `web` rather than a placeholder of its own: a domain is a member of a generated\n * union, and one invented for the scaffold appears in no wizard domain view and\n * reaches no sub-agent. It is also one of the domains a from-scratch selection\n * opens with, so the example skill is visible without the author choosing anything.\n */\nconst EXAMPLE_DOMAIN = \"web\";\n\n/**\n * The category the scaffold declares and places its example skill in, named by the\n * `<domain>-<name>` convention every category in the public catalogue follows. No\n * built-in category holds this key, so declaring it adds one rather than redefining\n * somebody else's.\n */\nconst EXAMPLE_CATEGORY = `${EXAMPLE_DOMAIN}-example`;\n\n/**\n * The slug the example skill answers to.\n *\n * Deliberately NOT namespaced: the marketplace-namespace rule governs skill ids,\n * and a marketplace's matrix is built from its own skills alone, so nothing in it\n * can collide with this. Prefixing it would settle a question nobody has ruled on.\n */\nconst EXAMPLE_SLUG = \"example-skill\";\n\n/** Where the scaffolded category sorts among the categories a marketplace grows later. */\nconst EXAMPLE_CATEGORY_ORDER = 1;\n\n/** The version a marketplace starts at — pre-release, because nothing is published yet. */\nconst INITIAL_PACKAGE_VERSION = \"0.1.0\";\n\n/** The sub-agent the scaffolded stack hands its skill to. */\nconst EXAMPLE_STACK_AGENT = \"web-developer\";\n\n/**\n * Composes the id of a scaffolded marketplace's example skill.\n *\n * Every skill id a marketplace publishes begins with that marketplace's name, so an\n * author who edits the scaffold rather than starting from a blank directory falls\n * into the namespace instead of having to remember it — `build marketplace` refuses\n * an id that lacks the prefix, and so does the load side.\n */\nexport function exampleSkillId(marketplaceName: string): string {\n return `${marketplaceName}-${EXAMPLE_SKILL_SUFFIX}`;\n}\n\n/**\n * Writes a complete marketplace into `marketplaceDir` and returns every path it\n * wrote, relative to that directory.\n *\n * What it writes is exactly what `docs/guides/creating-a-marketplace.md` promises a\n * marketplace holds — no more. It deliberately writes no config pair: a\n * marketplace is a repository of skills, and a config manifest there would make\n * `doctor` diagnose an installation that does not exist.\n */\nexport async function writeMarketplaceScaffold(\n marketplaceDir: string,\n marketplaceName: string,\n): Promise<string[]> {\n const files = scaffoldFiles(marketplaceName);\n\n await Promise.all(\n files.map((file) => writeFile(path.join(marketplaceDir, file.relPath), file.contents)),\n );\n\n return files.map((file) => file.relPath);\n}\n\nfunction scaffoldFiles(marketplaceName: string): ScaffoldFile[] {\n const skillId = exampleSkillId(marketplaceName);\n const skillDir = path.join(SKILLS_DIR_PATH, skillId);\n\n return [\n { relPath: STANDARD_FILES.PACKAGE_JSON, contents: packageJson(marketplaceName) },\n { relPath: SKILL_CATEGORIES_PATH, contents: skillCategoriesModule() },\n { relPath: SKILL_RULES_PATH, contents: skillRulesModule() },\n { relPath: STACKS_FILE_PATH, contents: stacksModule(marketplaceName, skillId) },\n { relPath: path.join(skillDir, STANDARD_FILES.SKILL_MD), contents: skillMd(skillId) },\n {\n relPath: path.join(skillDir, STANDARD_FILES.METADATA_YAML),\n contents: metadataYaml(marketplaceName),\n },\n ];\n}\n\n/**\n * A `config/*.ts` module the CLI's loader can read.\n *\n * The loader unwraps a DEFAULT export and treats a module without one as no config\n * at all, so the export form here is load-bearing rather than stylistic.\n */\nfunction configModule(comment: string, data: unknown): string {\n return `${comment}\\nexport default ${JSON.stringify(data, null, 2)};\\n`;\n}\n\n/**\n * `build marketplace` reads a marketplace's whole identity out of package.json and\n * refuses a file missing any of name, version or description.\n *\n * `author` is the field this command cannot know, and it is written anyway —\n * omitting it is not the neutral choice it looks like. The build turns an absent\n * author into `owner: { name: \"\" }`, and the schema the CLI parses a\n * `marketplace.json` back with requires a non-empty owner name, so a scaffold with\n * no author builds a marketplace that then loads as no marketplace at all. The\n * marketplace's own handle is the least-wrong default: it is derived from what the\n * author typed rather than invented, and the next steps say to replace it.\n */\nfunction packageJson(marketplaceName: string): string {\n return `${JSON.stringify(\n {\n name: marketplaceName,\n version: INITIAL_PACKAGE_VERSION,\n description: `Skills curated for ${marketplaceName}'s conventions`,\n author: { name: authorHandle(marketplaceName) },\n },\n null,\n 2,\n )}\\n`;\n}\n\n/** The placeholder handle the marketplace publishes itself and its example skill under. */\nfunction authorHandle(marketplaceName: string): string {\n return `@${marketplaceName}`;\n}\n\nfunction skillCategoriesModule(): string {\n return configModule(\"// The categories this marketplace's skills fall into.\", {\n version: DEFAULT_VERSION,\n categories: {\n [EXAMPLE_CATEGORY]: {\n id: EXAMPLE_CATEGORY,\n displayName: \"Example\",\n description: \"Replace this with a category of your own\",\n domain: EXAMPLE_DOMAIN,\n exclusive: false,\n order: EXAMPLE_CATEGORY_ORDER,\n },\n },\n });\n}\n\n/**\n * A rules file with a version and nothing else.\n *\n * Relationship rules name skills by slug, and that slug reference is the CLI's own\n * generated union — so a marketplace cannot yet name its OWN skills in a rule, and\n * one that tries fails to load. A marketplace works fully without them; what it\n * loses is the wizard's incompatibility hints between its own skills.\n */\nfunction skillRulesModule(): string {\n return configModule(\n [\n \"// Relationships between skills — conflicts, requires, alternatives.\",\n \"//\",\n \"// Rules may only name skills the public catalogue carries; this marketplace's own\",\n \"// skills cannot be named here yet, and a rule that names one will not load. The\",\n \"// file still has to exist, so it ships with a version and no relationships.\",\n ].join(\"\\n\"),\n { version: DEFAULT_VERSION },\n );\n}\n\nfunction stacksModule(marketplaceName: string, skillId: string): string {\n return configModule(\"// The stacks this marketplace offers the wizard.\", {\n stacks: [\n {\n id: `${marketplaceName}-starter`,\n name: `${marketplaceName} starter`,\n description: `Every skill ${marketplaceName} ships`,\n agents: {\n [EXAMPLE_STACK_AGENT]: {\n [EXAMPLE_CATEGORY]: [{ id: skillId }],\n },\n },\n },\n ],\n });\n}\n\n/**\n * The skill's content, headed by the frontmatter the loader reads its machine id\n * out of. That id is also the directory name — `doctor` compares the two — so both\n * come from {@link exampleSkillId} rather than being spelled twice.\n */\nfunction skillMd(skillId: string): string {\n return `---\nname: ${skillId}\ndescription: A placeholder skill — replace it with one of your own\n---\n\n# Example Skill\n\nThis is where a skill's content goes: the conventions, patterns and rules you want\nevery sub-agent carrying it to follow.\n\nReplace this file and the \\`${STANDARD_FILES.METADATA_YAML}\\` beside it, and rename the\ndirectory to the id your skill should publish under.\n`;\n}\n\nfunction metadataYaml(marketplaceName: string): string {\n return [\n \"custom: true\",\n `domain: ${EXAMPLE_DOMAIN}`,\n `author: \"${authorHandle(marketplaceName)}\"`,\n \"displayName: Example Skill\",\n `category: ${EXAMPLE_CATEGORY}`,\n `slug: ${EXAMPLE_SLUG}`,\n 'cliDescription: \"A placeholder skill to replace with your own\"',\n 'usageGuidance: \"Use when you need a worked example of this marketplace\\'s skill shape\"',\n \"\",\n ].join(\"\\n\");\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,SAAS,YAAY;AACrB,OAAOA,WAAU;;;ACDjB,OAAO,UAAU;AAwBjB,IAAM,uBAAuB;AAU7B,IAAM,iBAAiB;AAQvB,IAAM,mBAAmB,GAAG,cAAc;AAS1C,IAAM,eAAe;AAGrB,IAAM,yBAAyB;AAG/B,IAAM,0BAA0B;AAGhC,IAAM,sBAAsB;AAUrB,SAAS,eAAe,iBAAiC;AAC9D,SAAO,GAAG,eAAe,IAAI,oBAAoB;AACnD;AAWA,eAAsB,yBACpB,gBACA,iBACmB;AACnB,QAAM,QAAQ,cAAc,eAAe;AAE3C,QAAM,QAAQ;AAAA,IACZ,MAAM,IAAI,CAAC,SAAS,UAAU,KAAK,KAAK,gBAAgB,KAAK,OAAO,GAAG,KAAK,QAAQ,CAAC;AAAA,EACvF;AAEA,SAAO,MAAM,IAAI,CAAC,SAAS,KAAK,OAAO;AACzC;AAEA,SAAS,cAAc,iBAAyC;AAC9D,QAAM,UAAU,eAAe,eAAe;AAC9C,QAAM,WAAW,KAAK,KAAK,iBAAiB,OAAO;AAEnD,SAAO;AAAA,IACL,EAAE,SAAS,eAAe,cAAc,UAAU,YAAY,eAAe,EAAE;AAAA,IAC/E,EAAE,SAAS,uBAAuB,UAAU,sBAAsB,EAAE;AAAA,IACpE,EAAE,SAAS,kBAAkB,UAAU,i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c;AAAA,IAC5D;AAEA,SAAK,IAAI,EAAE;AACX,SAAK,IAAI,aAAa;AACtB,eAAW,CAAC,OAAO,IAAI,KAAK,MAAM,QAAQ,GAAG;AAC3C,WAAK,IAAI,KAAK,QAAQ,CAAC,KAAK,IAAI,EAAE;AAAA,IACpC;AACA,SAAK,IAAI,EAAE;AAAA,EACb;AACF;","names":["path","path"]}
|
|
1
|
+
{"version":3,"sources":["../../../src/cli/commands/new/marketplace.ts","../../../src/cli/lib/marketplace-scaffold.ts"],"sourcesContent":["import { Args } from \"@oclif/core\";\nimport path from \"path\";\n\nimport { BaseCommand } from \"../../base-command.js\";\nimport { CLI_INVOKE_COMMAND, EDITOR_URL, SKILLS_DIR_PATH } from \"../../consts.js\";\nimport { EXIT_CODES } from \"../../lib/exit-codes.js\";\nimport { validateMarketplaceName } from \"../../lib/marketplace-generator.js\";\nimport { exampleSkillId, writeMarketplaceScaffold } from \"../../lib/marketplace-scaffold.js\";\nimport { validateKebabCaseName } from \"../../lib/validate-kebab-name.js\";\nimport { isDirectoryEmpty } from \"../../utils/fs.js\";\n\n/**\n * How a reserved name is replaced here. The name is this command's argument, and nothing it could\n * be read from exists yet — no package.json, and no `--name` — so another argument is the way out.\n */\nconst RESERVED_NAME_WAY_OUT = `run '${CLI_INVOKE_COMMAND} new marketplace <other-name>'`;\n\n/**\n * The refusal over a target directory that already holds something.\n *\n * A scaffold writes a whole marketplace, so writing into an occupied directory\n * would mean merging with — or overwriting — work this command did not author.\n * Both ways out are one step, which is why there is no `--force`: a flag that\n * overwrites an author's own files is the destructive half of a silent fallback.\n */\nfunction occupiedDirectoryError(marketplaceDir: string): string {\n return (\n `${marketplaceDir} already holds files. A scaffold writes a whole marketplace, ` +\n `so it will not write into a directory that already has contents. Choose another ` +\n `name, or empty that directory first.`\n );\n}\n\nexport default class NewMarketplace extends BaseCommand {\n static summary = \"Scaffold a marketplace of your own\";\n\n static description =\n \"Create a directory holding everything the CLI needs to read a marketplace: a package.json \" +\n \"carrying its identity, the three config files, and one example skill already named in the \" +\n \"marketplace's own namespace. It scaffolds only — run 'build plugins' and 'build marketplace' \" +\n \"to publish what you have written.\";\n\n static examples = [\n {\n description: \"Scaffold a marketplace named acme into ./acme\",\n command: \"<%= config.bin %> <%= command.id %> acme\",\n },\n ];\n\n static args = {\n name: Args.string({\n description:\n \"Name of the marketplace (kebab-case). Becomes the directory, the package.json name, \" +\n \"and the prefix every skill id must carry.\",\n required: true,\n }),\n };\n\n async run(): Promise<void> {\n const { args } = await this.parse(NewMarketplace);\n const marketplaceName = args.name;\n const marketplaceDir = path.join(process.cwd(), marketplaceName);\n\n this.refuseUnusableName(marketplaceName);\n await this.refuseOccupiedDirectory(marketplaceDir);\n\n try {\n const written = await writeMarketplaceScaffold(marketplaceDir, marketplaceName);\n this.reportCreated(marketplaceName, marketplaceDir, written);\n this.reportNextSteps(marketplaceName, marketplaceDir);\n } catch (error) {\n this.handleError(error);\n }\n }\n\n /**\n * Both name rules `build marketplace` enforces, enforced here instead — failing\n * at creation beats failing at publish, when the name is already the directory,\n * the package name and the prefix on every id.\n */\n private refuseUnusableName(marketplaceName: string): void {\n const kebabError = validateKebabCaseName(marketplaceName, \"Marketplace\");\n if (kebabError) {\n this.error(kebabError, { exit: EXIT_CODES.INVALID_ARGS });\n }\n\n // The package.json this command is about to write names the marketplace after\n // itself, so the marketplace name IS the package name. That is what keeps the\n // public catalogue's exemption out of reach: it belongs to one npm package, and\n // nobody scaffolds that package from here.\n const reservedError = validateMarketplaceName(\n marketplaceName,\n marketplaceName,\n RESERVED_NAME_WAY_OUT,\n );\n if (reservedError) {\n this.error(reservedError, { exit: EXIT_CODES.ERROR });\n }\n }\n\n private async refuseOccupiedDirectory(marketplaceDir: string): Promise<void> {\n if (await isDirectoryEmpty(marketplaceDir)) return;\n\n this.error(occupiedDirectoryError(marketplaceDir), { exit: EXIT_CODES.ERROR });\n }\n\n private reportCreated(\n marketplaceName: string,\n marketplaceDir: string,\n written: readonly string[],\n ): void {\n this.log(\"\");\n this.logSuccess(`Created marketplace '${marketplaceName}' at ${marketplaceDir}`);\n for (const relPath of written) {\n this.log(` ${relPath}`);\n }\n }\n\n private reportNextSteps(marketplaceName: string, marketplaceDir: string): void {\n const skillDir = path.join(SKILLS_DIR_PATH, exampleSkillId(marketplaceName));\n const steps = [\n `cd ${marketplaceName}`,\n \"Replace the placeholder 'author' in package.json with your own handle — it is what 'build marketplace' records as this marketplace's owner\",\n `Replace ${skillDir}/ with a skill of your own. Every skill id must begin with '${marketplaceName}-'`,\n `${CLI_INVOKE_COMMAND} build plugins`,\n `${CLI_INVOKE_COMMAND} build marketplace`,\n `Push it to GitHub, then add it from the Marketplace button at ${EDITOR_URL}`,\n `${CLI_INVOKE_COMMAND} init --from <id> --marketplace ${marketplaceDir} (from a project — tests your local changes against a configuration built there)`,\n ];\n\n this.log(\"\");\n this.log(\"Next steps:\");\n for (const [index, step] of steps.entries()) {\n this.log(` ${index + 1}. ${step}`);\n }\n this.log(\"\");\n }\n}\n","import path from \"path\";\n\nimport {\n DEFAULT_VERSION,\n SKILL_CATEGORIES_PATH,\n SKILL_RULES_PATH,\n SKILLS_DIR_PATH,\n STACKS_FILE_PATH,\n STANDARD_FILES,\n} from \"../consts.js\";\nimport { writeFile } from \"../utils/fs.js\";\n\n/** One file of a scaffolded marketplace: where it goes, and what it holds. */\ntype ScaffoldFile = {\n /** Path relative to the marketplace root. */\n relPath: string;\n contents: string;\n};\n\n/**\n * The bare id of the one skill a scaffold ships. The marketplace's own name is\n * prefixed onto it by {@link exampleSkillId} — this half is the same for every\n * marketplace, and on its own it belongs to none of them.\n */\nconst EXAMPLE_SKILL_SUFFIX = \"example-skill\";\n\n/**\n * The domain the scaffolded category sits under.\n *\n * `web` rather than a placeholder of its own: a domain is a member of a generated\n * union, and one invented for the scaffold reaches no sub-agent.\n */\nconst EXAMPLE_DOMAIN = \"web\";\n\n/**\n * The category the scaffold declares and places its example skill in, named by the\n * `<domain>-<name>` convention every category in the public catalogue follows. No\n * built-in category holds this key, so declaring it adds one rather than redefining\n * somebody else's.\n */\nconst EXAMPLE_CATEGORY = `${EXAMPLE_DOMAIN}-example`;\n\n/**\n * The slug the example skill answers to.\n *\n * Deliberately NOT namespaced: the marketplace-namespace rule governs skill ids,\n * not slugs.\n */\nconst EXAMPLE_SLUG = \"example-skill\";\n\n/** Where the scaffolded category sorts among the categories a marketplace grows later. */\nconst EXAMPLE_CATEGORY_ORDER = 1;\n\n/** The version a marketplace starts at — pre-release, because nothing is published yet. */\nconst INITIAL_PACKAGE_VERSION = \"0.1.0\";\n\n/** The sub-agent the scaffolded stack hands its skill to. */\nconst EXAMPLE_STACK_AGENT = \"web-developer\";\n\n/**\n * Composes the id of a scaffolded marketplace's example skill.\n *\n * Every skill id a marketplace publishes begins with that marketplace's name, so an\n * author who edits the scaffold rather than starting from a blank directory falls\n * into the namespace instead of having to remember it — `build marketplace` refuses\n * an id that lacks the prefix.\n */\nexport function exampleSkillId(marketplaceName: string): string {\n return `${marketplaceName}-${EXAMPLE_SKILL_SUFFIX}`;\n}\n\n/**\n * Writes a complete marketplace into `marketplaceDir` and returns every path it\n * wrote, relative to that directory.\n *\n * What it writes is exactly what\n * `apps/www/src/content/docs/docs/guides/creating-a-marketplace.md` promises a\n * marketplace holds — no more. It deliberately writes no config pair: a\n * marketplace is a repository of skills, and a config manifest there would make\n * `doctor` diagnose an installation that does not exist.\n */\nexport async function writeMarketplaceScaffold(\n marketplaceDir: string,\n marketplaceName: string,\n): Promise<string[]> {\n const files = scaffoldFiles(marketplaceName);\n\n await Promise.all(\n files.map((file) => writeFile(path.join(marketplaceDir, file.relPath), file.contents)),\n );\n\n return files.map((file) => file.relPath);\n}\n\nfunction scaffoldFiles(marketplaceName: string): ScaffoldFile[] {\n const skillId = exampleSkillId(marketplaceName);\n const skillDir = path.join(SKILLS_DIR_PATH, skillId);\n\n return [\n { relPath: STANDARD_FILES.PACKAGE_JSON, contents: packageJson(marketplaceName) },\n { relPath: SKILL_CATEGORIES_PATH, contents: skillCategoriesModule() },\n { relPath: SKILL_RULES_PATH, contents: skillRulesModule() },\n { relPath: STACKS_FILE_PATH, contents: stacksModule(marketplaceName, skillId) },\n { relPath: path.join(skillDir, STANDARD_FILES.SKILL_MD), contents: skillMd(skillId) },\n {\n relPath: path.join(skillDir, STANDARD_FILES.METADATA_YAML),\n contents: metadataYaml(marketplaceName),\n },\n ];\n}\n\n/**\n * A `config/*.ts` module the CLI's loader can read.\n *\n * The loader reads only a DEFAULT export, so the export form here is load-bearing\n * rather than stylistic.\n */\nfunction configModule(comment: string, data: unknown): string {\n return `${comment}\\nexport default ${JSON.stringify(data, null, 2)};\\n`;\n}\n\n/**\n * `build marketplace` reads a marketplace's whole identity out of package.json and\n * refuses a file missing any of name, version, description or author.\n *\n * `author` is the field this command cannot know, so it is written as the\n * marketplace's own handle — the least-wrong default: it is derived from what the\n * author typed rather than invented, and the next steps say to replace it.\n */\nfunction packageJson(marketplaceName: string): string {\n return `${JSON.stringify(\n {\n name: marketplaceName,\n version: INITIAL_PACKAGE_VERSION,\n description: `Skills curated for ${marketplaceName}'s conventions`,\n author: { name: authorHandle(marketplaceName) },\n },\n null,\n 2,\n )}\\n`;\n}\n\n/** The placeholder handle the marketplace publishes itself and its example skill under. */\nfunction authorHandle(marketplaceName: string): string {\n return `@${marketplaceName}`;\n}\n\nfunction skillCategoriesModule(): string {\n return configModule(\"// The categories this marketplace's skills fall into.\", {\n version: DEFAULT_VERSION,\n categories: {\n [EXAMPLE_CATEGORY]: {\n id: EXAMPLE_CATEGORY,\n displayName: \"Example\",\n description: \"Replace this with a category of your own\",\n domain: EXAMPLE_DOMAIN,\n exclusive: false,\n order: EXAMPLE_CATEGORY_ORDER,\n },\n },\n });\n}\n\n/**\n * A rules file with a version and nothing else.\n *\n * Relationship rules name skills by slug, and that slug reference is the CLI's own\n * generated union — so a marketplace cannot yet name its OWN skills in a rule, and\n * one that tries fails to load. A marketplace works fully without them; what it\n * loses is the incompatibility hints between its own skills.\n */\nfunction skillRulesModule(): string {\n return configModule(\n [\n \"// Relationships between skills — conflicts, requires, alternatives.\",\n \"//\",\n \"// Rules may only name skills the public catalogue carries; this marketplace's own\",\n \"// skills cannot be named here yet, and a rule that names one will not load.\",\n ].join(\"\\n\"),\n { version: DEFAULT_VERSION },\n );\n}\n\nfunction stacksModule(marketplaceName: string, skillId: string): string {\n return configModule(\"// The stacks this marketplace offers.\", {\n stacks: [\n {\n id: `${marketplaceName}-starter`,\n name: `${marketplaceName} starter`,\n description: `Every skill ${marketplaceName} ships`,\n agents: {\n [EXAMPLE_STACK_AGENT]: {\n [EXAMPLE_CATEGORY]: [{ id: skillId }],\n },\n },\n },\n ],\n });\n}\n\n/**\n * The skill's content, headed by the frontmatter the loader reads its machine id\n * out of. That id is also the directory name — `doctor` compares the two — so both\n * come from {@link exampleSkillId} rather than being spelled twice.\n */\nfunction skillMd(skillId: string): string {\n return `---\nname: ${skillId}\ndescription: A placeholder skill — replace it with one of your own\n---\n\n# Example Skill\n\nThis is where a skill's content goes: the conventions, patterns and rules you want\nevery sub-agent carrying it to follow.\n\nReplace this file and the \\`${STANDARD_FILES.METADATA_YAML}\\` beside it, and rename the\ndirectory to the id your skill should publish under.\n`;\n}\n\nfunction metadataYaml(marketplaceName: string): string {\n return [\n \"custom: true\",\n `domain: ${EXAMPLE_DOMAIN}`,\n `author: \"${authorHandle(marketplaceName)}\"`,\n \"displayName: Example Skill\",\n `category: ${EXAMPLE_CATEGORY}`,\n `slug: ${EXAMPLE_SLUG}`,\n 'cliDescription: \"A placeholder skill to replace with your own\"',\n 'usageGuidance: \"Use when you need a worked example of this marketplace\\'s skill shape\"',\n \"\",\n ].join(\"\\n\");\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,SAAS,YAAY;AACrB,OAAOA,WAAU;;;ACDjB,OAAO,UAAU;AAwBjB,IAAM,uBAAuB;AAQ7B,IAAM,iBAAiB;AAQvB,IAAM,mBAAmB,GAAG,cAAc;AAQ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