agents-inc 0.164.0 → 0.166.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 +63 -0
- package/README.md +8 -9
- package/dist/{chunk-X4SSJZLY.js → chunk-25MPBIK3.js} +12 -261
- package/dist/chunk-25MPBIK3.js.map +1 -0
- package/dist/{chunk-LT5GXEB2.js → chunk-2VUYFTUB.js} +8 -7
- package/dist/chunk-2VUYFTUB.js.map +1 -0
- package/dist/chunk-4AAOOAIN.js +49 -0
- package/dist/chunk-4AAOOAIN.js.map +1 -0
- package/dist/{chunk-ARYNOWKF.js → chunk-4NDBUJHK.js} +8 -8
- package/dist/{chunk-S63LXWMC.js → chunk-6L75SQZU.js} +2 -2
- package/dist/{chunk-7REKOTKG.js → chunk-6LF4CQBY.js} +3 -3
- package/dist/{chunk-K5ITEA3I.js → chunk-7JNJ52CD.js} +34 -17
- package/dist/chunk-7JNJ52CD.js.map +1 -0
- package/dist/{chunk-XPDVAJDH.js → chunk-A4KDXNOT.js} +3519 -1568
- package/dist/chunk-A4KDXNOT.js.map +1 -0
- package/dist/{chunk-XHPWTL4I.js → chunk-DAIEQJIF.js} +3 -3
- package/dist/{chunk-UITEKY2R.js → chunk-ENGYJCTF.js} +28 -4
- package/dist/chunk-ENGYJCTF.js.map +1 -0
- package/dist/{chunk-G2JJ5BO5.js → chunk-G4JK7WVO.js} +336 -140
- package/dist/chunk-G4JK7WVO.js.map +1 -0
- package/dist/{chunk-X37UYIE3.js → chunk-G6UREQ4V.js} +436 -739
- package/dist/chunk-G6UREQ4V.js.map +1 -0
- package/dist/chunk-GE3WKJ6Q.js +375 -0
- package/dist/chunk-GE3WKJ6Q.js.map +1 -0
- package/dist/{chunk-RGYDFBCT.js → chunk-HHIYT3PI.js} +5 -5
- package/dist/{chunk-2CQNPLVF.js → chunk-HWEKHVLE.js} +63 -42
- package/dist/chunk-HWEKHVLE.js.map +1 -0
- package/dist/{chunk-XVAQG2CV.js → chunk-JOEA52NR.js} +10 -8
- package/dist/chunk-JOEA52NR.js.map +1 -0
- package/dist/{chunk-3WVH2CTK.js → chunk-JQRJQ4SS.js} +15 -8
- package/dist/chunk-JQRJQ4SS.js.map +1 -0
- package/dist/{chunk-DSL66I4N.js → chunk-LFWLEDUG.js} +6 -6
- package/dist/{chunk-B3Y3QMWI.js → chunk-MAWNVT2C.js} +4 -4
- package/dist/{chunk-Q4IRRVXK.js → chunk-MPTNC32T.js} +3 -3
- package/dist/chunk-NBXXFIIW.js +73 -0
- package/dist/chunk-NBXXFIIW.js.map +1 -0
- package/dist/{chunk-B6FSLXYN.js → chunk-PMJWD27C.js} +3 -3
- package/dist/{chunk-XATLUKXK.js → chunk-PNB3524H.js} +6 -6
- package/dist/chunk-PXWG7KFO.js +39 -0
- package/dist/chunk-PXWG7KFO.js.map +1 -0
- package/dist/{chunk-4VL3CEOS.js → chunk-QHDPLLK6.js} +3 -3
- package/dist/{chunk-AOTCIUGX.js → chunk-RAHSOJQ2.js} +2 -2
- package/dist/{chunk-PHCPUQVR.js → chunk-RZDXDMT6.js} +2 -2
- package/dist/{chunk-6MV4JOCL.js → chunk-SAYZWCH6.js} +2 -2
- package/dist/{chunk-URXIQE7I.js → chunk-SCOQ34YM.js} +2 -2
- package/dist/{chunk-NQXO4LR3.js → chunk-SXVHSOTH.js} +16 -11
- package/dist/chunk-SXVHSOTH.js.map +1 -0
- package/dist/{chunk-QZX7SYKU.js → chunk-T6UWJAB3.js} +2 -2
- package/dist/{chunk-ZVXGW2IC.js → chunk-TODCQFRB.js} +4 -6
- package/dist/chunk-TODCQFRB.js.map +1 -0
- package/dist/{chunk-YRS3QZP2.js → chunk-TTY6DPJN.js} +3 -3
- package/dist/{chunk-QGUP3QJF.js → chunk-TZ2YJJKK.js} +22 -18
- package/dist/{chunk-QGUP3QJF.js.map → chunk-TZ2YJJKK.js.map} +1 -1
- package/dist/chunk-V3I7VQ7N.js +356 -0
- package/dist/chunk-V3I7VQ7N.js.map +1 -0
- package/dist/{chunk-AVK2HEKB.js → chunk-V5WXIM2F.js} +2 -6
- package/dist/{chunk-AVK2HEKB.js.map → chunk-V5WXIM2F.js.map} +1 -1
- package/dist/{chunk-NKGYKOB7.js → chunk-VAPTVR3J.js} +7 -8
- package/dist/chunk-VAPTVR3J.js.map +1 -0
- package/dist/chunk-VRXX4D6K.js +31 -0
- package/dist/chunk-VRXX4D6K.js.map +1 -0
- package/dist/{chunk-ABAZMMG4.js → chunk-WVUDLKIO.js} +2 -2
- package/dist/{chunk-ECURHW3T.js → chunk-WWIFNPJG.js} +13 -12
- package/dist/chunk-WWIFNPJG.js.map +1 -0
- package/dist/{chunk-J27W6TXS.js → chunk-XQHZPINL.js} +8 -4
- package/dist/chunk-XQHZPINL.js.map +1 -0
- package/dist/{chunk-V5GLL2JB.js → chunk-XZEVWPX6.js} +7 -7
- package/dist/chunk-Y3VIRVVE.js +932 -0
- package/dist/chunk-Y3VIRVVE.js.map +1 -0
- package/dist/{chunk-NTF4UXGK.js → chunk-Y47EV74W.js} +73 -30
- package/dist/chunk-Y47EV74W.js.map +1 -0
- package/dist/chunk-ZR4YPKXQ.js +159 -0
- package/dist/chunk-ZR4YPKXQ.js.map +1 -0
- package/dist/chunk-ZXKBERQU.js +250 -0
- package/dist/chunk-ZXKBERQU.js.map +1 -0
- package/dist/commands/build/marketplace.js +17 -17
- package/dist/commands/build/marketplace.js.map +1 -1
- package/dist/commands/build/plugins.js +11 -9
- package/dist/commands/build/plugins.js.map +1 -1
- package/dist/commands/compile.js +105 -27
- package/dist/commands/compile.js.map +1 -1
- package/dist/commands/doctor.js +309 -171
- package/dist/commands/doctor.js.map +1 -1
- package/dist/commands/edit.js +503 -314
- package/dist/commands/edit.js.map +1 -1
- package/dist/commands/eject.js +40 -23
- package/dist/commands/eject.js.map +1 -1
- package/dist/commands/init.js +44 -40
- package/dist/commands/list.js +44 -10
- package/dist/commands/list.js.map +1 -1
- package/dist/commands/new/marketplace.js +13 -10
- package/dist/commands/new/marketplace.js.map +1 -1
- package/dist/commands/search.js +12 -10
- package/dist/commands/search.js.map +1 -1
- package/dist/commands/share.js +102 -15
- package/dist/commands/share.js.map +1 -1
- package/dist/commands/uninstall.js +231 -103
- package/dist/commands/uninstall.js.map +1 -1
- package/dist/commands/update.js +49 -20
- package/dist/commands/update.js.map +1 -1
- package/dist/components/common/prompt-confirm.js +1 -1
- package/dist/components/common/removal-plan-confirm.js +2 -2
- package/dist/components/common/select-list.js +3 -3
- package/dist/components/common/spinner.js +6 -3
- package/dist/components/wizard/category-grid.js +5 -5
- package/dist/components/wizard/checkbox-grid.js +4 -4
- package/dist/components/wizard/domain-selection.js +9 -9
- package/dist/components/wizard/run-wizard-session.js +29 -29
- package/dist/components/wizard/scroll-affordance.js +2 -2
- package/dist/components/wizard/skill-agent-summary.js +5 -5
- package/dist/components/wizard/source-grid.js +6 -6
- package/dist/components/wizard/stack-selection.js +8 -8
- package/dist/components/wizard/step-agents.js +8 -8
- package/dist/components/wizard/step-build.js +8 -8
- package/dist/components/wizard/step-confirm.js +9 -9
- package/dist/components/wizard/step-sources.js +9 -9
- package/dist/components/wizard/step-stack.js +9 -9
- package/dist/components/wizard/summary-panel.js +8 -8
- package/dist/components/wizard/toast.js +2 -2
- package/dist/components/wizard/wizard-layout.js +12 -12
- package/dist/components/wizard/wizard-tabs.js +2 -2
- package/dist/components/wizard/wizard.js +27 -27
- package/dist/hooks/init.js +69 -43
- package/dist/hooks/init.js.map +1 -1
- package/dist/load-agent-defs-3C27ENC7.js +14 -0
- package/dist/recompile-project-agents-DGNBCU3N.js +18 -0
- package/dist/{source-loader-GRBVNRAW.js → source-loader-7KZ3MD5O.js} +6 -4
- package/dist/src/agents/_templates/agent-body.liquid +55 -0
- package/dist/src/agents/_templates/agent.liquid +1 -55
- package/dist/src/agents/meta/agent-summoner/output.md +1 -1
- package/dist/src/agents/meta/agent-summoner/playbook.md +15 -7
- package/dist/stores/wizard-store.js +4 -4
- package/package.json +10 -9
- package/src/agents/_templates/agent-body.liquid +55 -0
- package/src/agents/_templates/agent.liquid +1 -55
- package/src/agents/meta/agent-summoner/output.md +1 -1
- package/src/agents/meta/agent-summoner/playbook.md +15 -7
- package/src/schemas/project-config.schema.json +1 -1
- package/src/schemas/project-source-config.schema.json +1 -1
- package/dist/chunk-2CQNPLVF.js.map +0 -1
- package/dist/chunk-3WVH2CTK.js.map +0 -1
- package/dist/chunk-7ANJQLPJ.js +0 -35
- package/dist/chunk-7ANJQLPJ.js.map +0 -1
- package/dist/chunk-ECURHW3T.js.map +0 -1
- package/dist/chunk-FLW25ORT.js +0 -130
- package/dist/chunk-FLW25ORT.js.map +0 -1
- package/dist/chunk-G2JJ5BO5.js.map +0 -1
- package/dist/chunk-J27W6TXS.js.map +0 -1
- package/dist/chunk-JCPANDNR.js +0 -35
- package/dist/chunk-JCPANDNR.js.map +0 -1
- package/dist/chunk-JIERYE6B.js +0 -480
- package/dist/chunk-JIERYE6B.js.map +0 -1
- package/dist/chunk-JU4ZGJ7A.js +0 -668
- package/dist/chunk-JU4ZGJ7A.js.map +0 -1
- package/dist/chunk-K5ITEA3I.js.map +0 -1
- package/dist/chunk-LT5GXEB2.js.map +0 -1
- package/dist/chunk-NKGYKOB7.js.map +0 -1
- package/dist/chunk-NQXO4LR3.js.map +0 -1
- package/dist/chunk-NTF4UXGK.js.map +0 -1
- package/dist/chunk-UITEKY2R.js.map +0 -1
- package/dist/chunk-X37UYIE3.js.map +0 -1
- package/dist/chunk-X4SSJZLY.js.map +0 -1
- package/dist/chunk-XPDVAJDH.js.map +0 -1
- package/dist/chunk-XVAQG2CV.js.map +0 -1
- package/dist/chunk-ZBPEFQ4G.js +0 -12
- package/dist/chunk-ZBPEFQ4G.js.map +0 -1
- package/dist/chunk-ZVXGW2IC.js.map +0 -1
- package/dist/load-agent-defs-7IM3GBEQ.js +0 -13
- package/dist/recompile-project-agents-VR4NLGOU.js +0 -17
- /package/dist/{chunk-ARYNOWKF.js.map → chunk-4NDBUJHK.js.map} +0 -0
- /package/dist/{chunk-S63LXWMC.js.map → chunk-6L75SQZU.js.map} +0 -0
- /package/dist/{chunk-7REKOTKG.js.map → chunk-6LF4CQBY.js.map} +0 -0
- /package/dist/{chunk-XHPWTL4I.js.map → chunk-DAIEQJIF.js.map} +0 -0
- /package/dist/{chunk-RGYDFBCT.js.map → chunk-HHIYT3PI.js.map} +0 -0
- /package/dist/{chunk-DSL66I4N.js.map → chunk-LFWLEDUG.js.map} +0 -0
- /package/dist/{chunk-B3Y3QMWI.js.map → chunk-MAWNVT2C.js.map} +0 -0
- /package/dist/{chunk-Q4IRRVXK.js.map → chunk-MPTNC32T.js.map} +0 -0
- /package/dist/{chunk-B6FSLXYN.js.map → chunk-PMJWD27C.js.map} +0 -0
- /package/dist/{chunk-XATLUKXK.js.map → chunk-PNB3524H.js.map} +0 -0
- /package/dist/{chunk-4VL3CEOS.js.map → chunk-QHDPLLK6.js.map} +0 -0
- /package/dist/{chunk-AOTCIUGX.js.map → chunk-RAHSOJQ2.js.map} +0 -0
- /package/dist/{chunk-PHCPUQVR.js.map → chunk-RZDXDMT6.js.map} +0 -0
- /package/dist/{chunk-6MV4JOCL.js.map → chunk-SAYZWCH6.js.map} +0 -0
- /package/dist/{chunk-URXIQE7I.js.map → chunk-SCOQ34YM.js.map} +0 -0
- /package/dist/{chunk-QZX7SYKU.js.map → chunk-T6UWJAB3.js.map} +0 -0
- /package/dist/{chunk-YRS3QZP2.js.map → chunk-TTY6DPJN.js.map} +0 -0
- /package/dist/{chunk-ABAZMMG4.js.map → chunk-WVUDLKIO.js.map} +0 -0
- /package/dist/{chunk-V5GLL2JB.js.map → chunk-XZEVWPX6.js.map} +0 -0
- /package/dist/{load-agent-defs-7IM3GBEQ.js.map → load-agent-defs-3C27ENC7.js.map} +0 -0
- /package/dist/{recompile-project-agents-VR4NLGOU.js.map → recompile-project-agents-DGNBCU3N.js.map} +0 -0
- /package/dist/{source-loader-GRBVNRAW.js.map → source-loader-7KZ3MD5O.js.map} +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/cli/commands/build/marketplace.ts"],"sourcesContent":["import { Flags } from \"@oclif/core\";\nimport path from \"path\";\nimport { sortBy } from \"remeda\";\nimport { z } from \"zod\";\n\nimport { BaseCommand } from \"../../base-command\";\nimport { setVerbose, warn } from \"../../utils/logger\";\nimport {\n marketplaceHasNoVersion,\n marketplaceNameNotPublishable,\n marketplaceOwnerHasNoName,\n} from \"../../utils/messages\";\nimport { readFile, writeFile } from \"../../utils/fs\";\nimport { getErrorMessage } from \"../../utils/errors\";\nimport { EXIT_CODES } from \"../../lib/exit-codes\";\nimport { loadMarketplaceMatrix } from \"../../lib/loading\";\nimport {\n generateMarketplace,\n writeMarketplace,\n getMarketplaceStats,\n validateMarketplaceName,\n validateSkillIdNamespace,\n} from \"../../lib/marketplace-generator\";\nimport {\n CATALOG_JSON,\n CLI_INVOKE_COMMAND,\n GENERATED_AT_BUILD,\n MARKETPLACE_JSON,\n PLUGIN_MANIFEST_DIR,\n PLUGINS_DIST_PATH,\n STANDARD_FILES,\n} from \"../../consts\";\nimport type { Marketplace } from \"../../types/plugins\";\nimport { validateKebabCaseName } from \"../../lib/validate-kebab-name.js\";\n\nconst DEFAULT_OUTPUT_FILE = `${PLUGIN_MANIFEST_DIR}/${MARKETPLACE_JSON}`;\n\nconst AUTHOR_STRING_PATTERN = /^(.*?)\\s*<([^>]+)>\\s*(?:\\(([^)]+)\\))?\\s*$/;\n\n/** The entity {@link validateKebabCaseName} names in this command's refusals. */\nconst MARKETPLACE_NOUN = \"Marketplace\";\n\nconst packageAuthorObjectSchema = z.object({\n name: z.string(),\n email: z.string().exactOptional(),\n url: z.string().exactOptional(),\n});\n\nconst packageJsonSchema = z\n .object({\n name: z.string(),\n version: z.string(),\n description: z.string(),\n author: z.union([z.string(), packageAuthorObjectSchema]).exactOptional(),\n })\n .passthrough();\n\ntype PackageJson = z.infer<typeof packageJsonSchema>;\ntype MarketplaceIdentity = Pick<PackageJson, \"name\" | \"version\" | \"description\"> & {\n ownerName: string;\n ownerEmail?: string;\n};\n\nexport default class BuildMarketplace extends BaseCommand {\n static summary = \"Generate marketplace.json from built plugins (requires skills repo)\";\n\n static description =\n \"Generate marketplace.json from built plugins. This command scans the plugins directory and generates a marketplace manifest file. Reads marketplace identity (name, version, description, author) from package.json in the current working directory. Use --name to override the marketplace name when package.json uses an npm scoped name (e.g. @scope/pkg), which is not a valid marketplace name.\";\n\n static examples = [\n {\n description: \"Generate marketplace.json from the default plugins directory\",\n command: \"<%= config.bin %> <%= command.id %>\",\n },\n {\n description: \"Generate marketplace.json from a custom plugins directory\",\n command: \"<%= config.bin %> <%= command.id %> --plugins-dir dist/stacks\",\n },\n {\n description: \"Write marketplace.json to a custom output path\",\n command: \"<%= config.bin %> <%= command.id %> --output .claude-plugin/market.json\",\n },\n {\n description:\n \"Override the marketplace name (use when package.json has an npm scoped name like @scope/pkg)\",\n command: \"<%= config.bin %> <%= command.id %> --name my-marketplace\",\n },\n ];\n\n static flags = {\n name: Flags.string({\n description:\n \"Override the marketplace name (defaults to package.json 'name'). Must be kebab-case.\",\n }),\n \"plugins-dir\": Flags.string({\n char: \"p\",\n description: \"Plugins directory\",\n default: PLUGINS_DIST_PATH,\n }),\n output: Flags.string({\n char: \"o\",\n description: \"Output file\",\n default: DEFAULT_OUTPUT_FILE,\n }),\n verbose: Flags.boolean({\n char: \"v\",\n description: \"Enable verbose logging\",\n default: false,\n }),\n };\n\n async run(): Promise<void> {\n const { flags } = await this.parse(BuildMarketplace);\n setVerbose(flags.verbose);\n\n const projectRoot = process.cwd();\n const pluginsDir = path.resolve(projectRoot, flags[\"plugins-dir\"]);\n const outputPath = path.resolve(projectRoot, flags.output);\n const identity = await this.loadMarketplaceIdentity(projectRoot, flags.name);\n\n this.printHeader(pluginsDir, outputPath);\n\n try {\n const marketplace = await this.generateAndWrite(\n pluginsDir,\n outputPath,\n flags[\"plugins-dir\"],\n identity,\n );\n await this.writeCatalog(projectRoot, outputPath);\n this.printStats(marketplace);\n this.printSample(marketplace);\n\n this.log(\"\");\n this.logSuccess(\n `Marketplace generated with ${getMarketplaceStats(marketplace).total} plugins!`,\n );\n this.log(\"\");\n } catch (error) {\n this.log(\"Generation failed\");\n this.handleError(error);\n }\n }\n\n private async loadMarketplaceIdentity(\n projectRoot: string,\n nameOverride?: string,\n ): Promise<MarketplaceIdentity> {\n const packageJsonPath = path.join(projectRoot, STANDARD_FILES.PACKAGE_JSON);\n\n let rawContent: string;\n try {\n rawContent = await readFile(packageJsonPath);\n } catch {\n this.error(\n `Missing package.json at ${projectRoot}. build marketplace reads marketplace identity from package.json.`,\n { exit: EXIT_CODES.ERROR },\n );\n }\n\n let parsedJson: unknown;\n try {\n parsedJson = JSON.parse(rawContent);\n } catch (error) {\n this.error(`Failed to parse package.json at ${packageJsonPath}: ${getErrorMessage(error)}`, {\n exit: EXIT_CODES.ERROR,\n });\n }\n\n const parseResult = packageJsonSchema.safeParse(parsedJson);\n if (!parseResult.success) {\n const missingFields = parseResult.error.issues.map((i) => i.path.join(\".\")).join(\", \");\n this.error(\n `package.json at ${packageJsonPath} is missing required fields: ${missingFields}. build marketplace reads marketplace identity from package.json.`,\n { exit: EXIT_CODES.ERROR },\n );\n }\n\n const { name, version, description, author } = parseResult.data;\n\n if (version.trim() === \"\") {\n this.error(marketplaceHasNoVersion(packageJsonPath), { exit: EXIT_CODES.ERROR });\n }\n\n const owner = parseAuthor(author);\n if (owner.name.trim() === \"\") {\n this.error(marketplaceOwnerHasNoName(packageJsonPath), { exit: EXIT_CODES.ERROR });\n }\n\n const resolvedName = this.resolvePublishableName(name, nameOverride, packageJsonPath);\n\n const reservedError = validateMarketplaceName(resolvedName, name);\n if (reservedError) {\n this.error(reservedError, { exit: EXIT_CODES.ERROR });\n }\n\n return {\n name: resolvedName,\n version,\n description,\n ownerName: owner.name,\n ...(owner.email !== undefined && { ownerEmail: owner.email }),\n };\n }\n\n /**\n * The name this marketplace publishes under, refused before anything is written when\n * it is not one `claude plugin marketplace add` will accept.\n *\n * Both halves are judged by the same rule and refused with different sentences: a\n * `--name` the author typed is an argument they can retype, while a name derived from\n * package.json is a fact about their package — an npm scoped name is legitimate there\n * and illegitimate here — so its way out is the flag rather than a package rename.\n */\n private resolvePublishableName(\n packageName: string,\n nameOverride: string | undefined,\n packageJsonPath: string,\n ): string {\n if (nameOverride !== undefined) {\n const invalidOverride = validateKebabCaseName(nameOverride, MARKETPLACE_NOUN);\n if (invalidOverride) {\n this.error(`Invalid --name '${nameOverride}': ${invalidOverride}`, {\n exit: EXIT_CODES.INVALID_ARGS,\n });\n }\n return nameOverride;\n }\n\n if (validateKebabCaseName(packageName, MARKETPLACE_NOUN)) {\n this.error(marketplaceNameNotPublishable(packageName, packageJsonPath), {\n exit: EXIT_CODES.ERROR,\n });\n }\n return packageName;\n }\n\n private printHeader(pluginsDir: string, outputPath: string): void {\n this.log(\"\");\n this.log(\"Generating marketplace.json\");\n this.log(` Plugins directory: ${pluginsDir}`);\n this.log(` Output file: ${outputPath}`);\n this.log(\"\");\n }\n\n private async generateAndWrite(\n pluginsDir: string,\n outputPath: string,\n pluginsDirFlag: string,\n identity: MarketplaceIdentity,\n ): Promise<Marketplace> {\n this.log(\"Scanning plugins...\");\n\n const marketplace = await generateMarketplace(pluginsDir, {\n name: identity.name,\n version: identity.version,\n description: identity.description,\n ownerName: identity.ownerName,\n ...(identity.ownerEmail !== undefined && { ownerEmail: identity.ownerEmail }),\n pluginRoot: `./${pluginsDirFlag}`,\n });\n\n const stats = getMarketplaceStats(marketplace);\n this.log(`Found ${stats.total} plugins`);\n\n if (marketplace.plugins.length === 0) {\n this.error(noPluginsToPublish(pluginsDir, pluginsDirFlag), { exit: EXIT_CODES.ERROR });\n }\n\n const namespaceError = validateSkillIdNamespace(marketplace);\n if (namespaceError) {\n this.error(namespaceError, { exit: EXIT_CODES.ERROR });\n }\n\n this.log(\"Writing marketplace.json...\");\n await writeMarketplace(outputPath, marketplace);\n this.log(`Wrote ${outputPath}`);\n\n return marketplace;\n }\n\n /**\n * Writes the marketplace's catalogue beside its manifest.\n *\n * Unconditional, and there is no flag to make it otherwise: a consumer\n * fetching a marketplace cannot tell an author who omitted a flag from a\n * marketplace that is broken, so an absent catalogue has to mean the second.\n *\n * `generatedAt` is stamped rather than carried: see {@link GENERATED_AT_BUILD}\n * for why a published artefact records a build and not a moment.\n */\n private async writeCatalog(projectRoot: string, outputPath: string): Promise<void> {\n const catalogPath = path.join(path.dirname(outputPath), CATALOG_JSON);\n\n this.log(`Writing ${CATALOG_JSON}...`);\n const matrix = await loadMarketplaceMatrix(projectRoot);\n const catalog = { ...matrix, generatedAt: GENERATED_AT_BUILD };\n await writeFile(catalogPath, `${JSON.stringify(catalog, null, 2)}\\n`);\n this.log(`Wrote ${catalogPath}`);\n }\n\n private printStats(marketplace: Marketplace): void {\n this.log(\"\");\n this.log(\"Category breakdown:\");\n const sortedCategories = sortBy(\n Object.entries(getMarketplaceStats(marketplace).byCategory),\n ([, count]) => -count,\n );\n for (const [category, count] of sortedCategories) {\n this.log(` ${category}: ${count}`);\n }\n }\n\n private printSample(marketplace: Marketplace): void {\n this.log(\"\");\n this.log(\"Sample plugins:\");\n const sampleSize = 5;\n for (const plugin of marketplace.plugins.slice(0, sampleSize)) {\n const version = plugin.version ? `v${plugin.version}` : \"\";\n const category = plugin.category ? `[${plugin.category}]` : \"\";\n this.log(` ${plugin.name} ${version} ${category}`);\n if (plugin.description) {\n this.log(` ${plugin.description}`);\n }\n }\n if (marketplace.plugins.length > sampleSize) {\n this.log(` ... and ${marketplace.plugins.length - sampleSize} more`);\n }\n }\n}\n\ntype ParsedAuthor = {\n name: string;\n email?: string;\n};\n\n/**\n * Refuses a manifest with no plugins in it, which the reader in this same package will not accept:\n * `marketplaceSchema.plugins` is `z.array(...).min(1)`, so `fetchMarketplace` throws\n * `plugins: Too small` on a file this command wrote and called a success. Every field that schema\n * constrains is a condition this command refuses before writing — `name`, `version` and\n * `owner.name` are the other three, all guarded off package.json. `version` was the one this\n * sentence claimed and did not have: `packageJsonSchema` types it as a bare string and the\n * generator defaults it with `??`, so `\"\"` reached the manifest untouched. This one is only\n * knowable after the scan, which is why it sits here rather than beside them.\n *\n * The two ways in are running before `build plugins` and pointing `--plugins-dir` somewhere else, so\n * the sentence names the directory it scanned and both ways out. Written here rather than in\n * `utils/messages.ts` for the reason the `Missing package.json` refusal above it is: it has one\n * caller and composes nothing another surface has to agree with.\n */\nfunction noPluginsToPublish(pluginsDir: string, pluginsDirFlag: string): string {\n return (\n `No plugins found in ${pluginsDir}. A marketplace with no plugins is refused when it is read ` +\n `back, so none was written. Run '${CLI_INVOKE_COMMAND} build plugins' first, or point ` +\n `--plugins-dir at the directory holding them (it is '${pluginsDirFlag}' for this run).`\n );\n}\n\n/**\n * Parses a package.json `author` field into name + optional email.\n *\n * npm supports both shorthand strings `\"Name <email> (url)\"` and object form\n * `{ name, email, url }`. An absent author and one that yields no name both come back\n * with an empty `name`, and the caller refuses on that — one condition, one sentence,\n * written where the refusal is. A missing EMAIL is warned about and carried on from,\n * because `owner.email` is the half the manifest schema leaves optional.\n */\nfunction parseAuthor(author: string | { name: string; email?: string } | undefined): ParsedAuthor {\n if (!author) return { name: \"\" };\n\n if (typeof author === \"object\") {\n return { name: author.name, ...(author.email !== undefined && { email: author.email }) };\n }\n\n const [, matchedName, matchedEmail] = author.match(AUTHOR_STRING_PATTERN) ?? [];\n if (matchedName !== undefined && matchedEmail !== undefined) {\n return { name: matchedName.trim(), email: matchedEmail.trim() };\n }\n\n warn(\n `package.json 'author' field \"${author}\" has no parseable email — marketplace owner.email will be empty`,\n );\n return { name: author.trim() };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,SAAS,aAAa;AACtB,OAAO,UAAU;AACjB,SAAS,cAAc;AACvB,SAAS,SAAS;AAgClB,IAAM,sBAAsB,GAAG,mBAAmB,IAAI,gBAAgB;AAEtE,IAAM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AAO,EAAE,MAAM,GAAG;AAE/B,MAAI,OAAO,WAAW,UAAU;AAC9B,WAAO,EAAE,MAAM,OAAO,MAAM,GAAI,OAAO,UAAU,UAAa,EAAE,OAAO,OAAO,MAAM,EAAG;AAAA,EACzF;AAEA,QAAM,CAAC,EAAE,aAAa,YAAY,IAAI,OAAO,MAAM,qBAAqB,KAAK,CAAC;AAC9E,MAAI,gBAAgB,UAAa,iBAAiB,QAAW;AAC3D,WAAO,EAAE,MAAM,YAAY,KAAK,GAAG,OAAO,aAAa,KAAK,EAAE;AAAA,EAChE;AAEA;AAAA,IACE,gCAAgC,MAAM;AAAA,EACxC;AACA,SAAO,EAAE,MAAM,OAAO,KAAK,EAAE;AAC/B;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../../src/cli/commands/build/marketplace.ts"],"sourcesContent":["import { Flags } from \"@oclif/core\";\nimport path from \"path\";\nimport { sortBy } from \"remeda\";\nimport { z } from \"zod\";\n\nimport { BaseCommand } from \"../../base-command\";\nimport { setVerbose, warn } from \"../../utils/logger\";\nimport {\n marketplaceHasNoVersion,\n marketplaceNameNotPublishable,\n marketplaceOwnerHasNoName,\n} from \"../../utils/messages\";\nimport { readFile, writeFile } from \"../../utils/fs\";\nimport { getErrorMessage } from \"../../utils/errors\";\nimport { EXIT_CODES } from \"../../lib/exit-codes\";\nimport { loadMarketplaceMatrix } from \"../../lib/loading\";\nimport {\n generateMarketplace,\n writeMarketplace,\n getMarketplaceStats,\n validateMarketplaceName,\n validateSkillIdNamespace,\n} from \"../../lib/marketplace-generator\";\nimport {\n CATALOG_JSON,\n CLI_INVOKE_COMMAND,\n GENERATED_AT_BUILD,\n MARKETPLACE_JSON,\n PLUGIN_MANIFEST_DIR,\n PLUGINS_DIST_PATH,\n STANDARD_FILES,\n} from \"../../consts\";\nimport type { Marketplace } from \"../../types/plugins\";\nimport { validateKebabCaseName } from \"../../lib/validate-kebab-name.js\";\nimport { plural } from \"../../utils/string.js\";\n\nconst DEFAULT_OUTPUT_FILE = `${PLUGIN_MANIFEST_DIR}/${MARKETPLACE_JSON}`;\n\nconst AUTHOR_STRING_PATTERN = /^(.*?)\\s*<([^>]+)>\\s*(?:\\(([^)]+)\\))?\\s*$/;\n\n/** The entity {@link validateKebabCaseName} names in this command's refusals. */\nconst MARKETPLACE_NOUN = \"Marketplace\";\n\n/** How a reserved name is replaced here: it is read off package.json, and `--name` overrides it. */\nconst RESERVED_NAME_WAY_OUT = \"set package.json 'name', or pass --name\";\n\nconst packageAuthorObjectSchema = z.object({\n name: z.string(),\n email: z.string().exactOptional(),\n url: z.string().exactOptional(),\n});\n\nconst packageJsonSchema = z\n .object({\n name: z.string(),\n version: z.string(),\n description: z.string(),\n author: z.union([z.string(), packageAuthorObjectSchema]).exactOptional(),\n })\n .passthrough();\n\ntype PackageJson = z.infer<typeof packageJsonSchema>;\ntype MarketplaceIdentity = Pick<PackageJson, \"name\" | \"version\" | \"description\"> & {\n ownerName: string;\n ownerEmail?: string;\n};\n\nexport default class BuildMarketplace extends BaseCommand {\n static summary = \"Generate marketplace.json from built plugins (requires skills repo)\";\n\n static description =\n \"Generate marketplace.json from built plugins. This command scans the plugins directory and generates a marketplace manifest file. Reads marketplace identity (name, version, description, author) from package.json in the current working directory. Use --name to override the marketplace name when package.json uses an npm scoped name (e.g. @scope/pkg), which is not a valid marketplace name.\";\n\n static examples = [\n {\n description: \"Generate marketplace.json from the default plugins directory\",\n command: \"<%= config.bin %> <%= command.id %>\",\n },\n {\n description: \"Generate marketplace.json from a custom plugins directory\",\n command: \"<%= config.bin %> <%= command.id %> --plugins-dir dist/stacks\",\n },\n {\n description: \"Write marketplace.json to a custom output path\",\n command: \"<%= config.bin %> <%= command.id %> --output .claude-plugin/market.json\",\n },\n {\n description:\n \"Override the marketplace name (use when package.json has an npm scoped name like @scope/pkg)\",\n command: \"<%= config.bin %> <%= command.id %> --name my-marketplace\",\n },\n ];\n\n static flags = {\n name: Flags.string({\n description:\n \"Override the marketplace name (defaults to package.json 'name'). Must be kebab-case.\",\n }),\n \"plugins-dir\": Flags.string({\n char: \"p\",\n description: \"Plugins directory\",\n default: PLUGINS_DIST_PATH,\n }),\n output: Flags.string({\n char: \"o\",\n description: \"Output file\",\n default: DEFAULT_OUTPUT_FILE,\n }),\n verbose: Flags.boolean({\n char: \"v\",\n description: \"Enable verbose logging\",\n default: false,\n }),\n };\n\n async run(): Promise<void> {\n const { flags } = await this.parse(BuildMarketplace);\n setVerbose(flags.verbose);\n\n const projectRoot = process.cwd();\n const pluginsDir = path.resolve(projectRoot, flags[\"plugins-dir\"]);\n const outputPath = path.resolve(projectRoot, flags.output);\n const identity = await this.loadMarketplaceIdentity(projectRoot, flags.name);\n\n this.printHeader(pluginsDir, outputPath);\n\n try {\n const marketplace = await this.generateAndWrite(\n pluginsDir,\n outputPath,\n flags[\"plugins-dir\"],\n identity,\n );\n await this.writeCatalog(projectRoot, outputPath);\n this.printStats(marketplace);\n this.printSample(marketplace);\n\n this.log(\"\");\n this.logSuccess(\n `Marketplace generated with ${plural(getMarketplaceStats(marketplace).total, \"plugin\")}!`,\n );\n this.log(\"\");\n } catch (error) {\n this.log(\"Generation failed\");\n this.handleError(error);\n }\n }\n\n private async loadMarketplaceIdentity(\n projectRoot: string,\n nameOverride?: string,\n ): Promise<MarketplaceIdentity> {\n const packageJsonPath = path.join(projectRoot, STANDARD_FILES.PACKAGE_JSON);\n\n let rawContent: string;\n try {\n rawContent = await readFile(packageJsonPath);\n } catch {\n this.error(\n `Missing package.json at ${projectRoot}. build marketplace reads marketplace identity from package.json.`,\n { exit: EXIT_CODES.ERROR },\n );\n }\n\n let parsedJson: unknown;\n try {\n parsedJson = JSON.parse(rawContent);\n } catch (error) {\n this.error(`Failed to parse package.json at ${packageJsonPath}: ${getErrorMessage(error)}`, {\n exit: EXIT_CODES.ERROR,\n });\n }\n\n const parseResult = packageJsonSchema.safeParse(parsedJson);\n if (!parseResult.success) {\n const missingFields = parseResult.error.issues.map((i) => i.path.join(\".\")).join(\", \");\n this.error(\n `package.json at ${packageJsonPath} is missing required fields: ${missingFields}. build marketplace reads marketplace identity from package.json.`,\n { exit: EXIT_CODES.ERROR },\n );\n }\n\n const { name, version, description, author } = parseResult.data;\n\n if (version.trim() === \"\") {\n this.error(marketplaceHasNoVersion(packageJsonPath), { exit: EXIT_CODES.ERROR });\n }\n\n const owner = parseAuthor(author);\n if (owner.name.trim() === \"\") {\n this.error(marketplaceOwnerHasNoName(packageJsonPath), { exit: EXIT_CODES.ERROR });\n }\n\n const resolvedName = this.resolvePublishableName(name, nameOverride, packageJsonPath);\n\n const reservedError = validateMarketplaceName(resolvedName, name, RESERVED_NAME_WAY_OUT);\n if (reservedError) {\n this.error(reservedError, { exit: EXIT_CODES.ERROR });\n }\n\n return {\n name: resolvedName,\n version,\n description,\n ownerName: owner.name,\n ...(owner.email !== undefined && { ownerEmail: owner.email }),\n };\n }\n\n /**\n * The name this marketplace publishes under, refused before anything is written when\n * it is not one `claude plugin marketplace add` will accept.\n *\n * Both halves are judged by the same rule and refused with different sentences: a\n * `--name` the author typed is an argument they can retype, while a name derived from\n * package.json is a fact about their package — an npm scoped name is legitimate there\n * and illegitimate here — so its way out is the flag rather than a package rename.\n */\n private resolvePublishableName(\n packageName: string,\n nameOverride: string | undefined,\n packageJsonPath: string,\n ): string {\n if (nameOverride !== undefined) {\n const invalidOverride = validateKebabCaseName(nameOverride, MARKETPLACE_NOUN);\n if (invalidOverride) {\n this.error(`Invalid --name '${nameOverride}': ${invalidOverride}`, {\n exit: EXIT_CODES.INVALID_ARGS,\n });\n }\n return nameOverride;\n }\n\n if (validateKebabCaseName(packageName, MARKETPLACE_NOUN)) {\n this.error(marketplaceNameNotPublishable(packageName, packageJsonPath), {\n exit: EXIT_CODES.ERROR,\n });\n }\n return packageName;\n }\n\n private printHeader(pluginsDir: string, outputPath: string): void {\n this.log(\"\");\n this.log(\"Generating marketplace.json\");\n this.log(` Plugins directory: ${pluginsDir}`);\n this.log(` Output file: ${outputPath}`);\n this.log(\"\");\n }\n\n private async generateAndWrite(\n pluginsDir: string,\n outputPath: string,\n pluginsDirFlag: string,\n identity: MarketplaceIdentity,\n ): Promise<Marketplace> {\n this.log(\"Scanning plugins...\");\n\n const marketplace = await generateMarketplace(pluginsDir, {\n name: identity.name,\n version: identity.version,\n description: identity.description,\n ownerName: identity.ownerName,\n ...(identity.ownerEmail !== undefined && { ownerEmail: identity.ownerEmail }),\n pluginRoot: `./${pluginsDirFlag}`,\n });\n\n const stats = getMarketplaceStats(marketplace);\n this.log(`Found ${plural(stats.total, \"plugin\")}`);\n\n if (marketplace.plugins.length === 0) {\n this.error(noPluginsToPublish(pluginsDir, pluginsDirFlag), { exit: EXIT_CODES.ERROR });\n }\n\n const namespaceError = validateSkillIdNamespace(marketplace);\n if (namespaceError) {\n this.error(namespaceError, { exit: EXIT_CODES.ERROR });\n }\n\n this.log(\"Writing marketplace.json...\");\n await writeMarketplace(outputPath, marketplace);\n this.log(`Wrote ${outputPath}`);\n\n return marketplace;\n }\n\n /**\n * Writes the marketplace's catalogue beside its manifest.\n *\n * Unconditional, and there is no flag to make it otherwise: a consumer\n * fetching a marketplace cannot tell an author who omitted a flag from a\n * marketplace that is broken, so an absent catalogue has to mean the second.\n *\n * `generatedAt` is stamped rather than carried: see {@link GENERATED_AT_BUILD}\n * for why a published artefact records a build and not a moment.\n */\n private async writeCatalog(projectRoot: string, outputPath: string): Promise<void> {\n const catalogPath = path.join(path.dirname(outputPath), CATALOG_JSON);\n\n this.log(`Writing ${CATALOG_JSON}...`);\n const matrix = await loadMarketplaceMatrix(projectRoot);\n const catalog = { ...matrix, generatedAt: GENERATED_AT_BUILD };\n await writeFile(catalogPath, `${JSON.stringify(catalog, null, 2)}\\n`);\n this.log(`Wrote ${catalogPath}`);\n }\n\n private printStats(marketplace: Marketplace): void {\n this.log(\"\");\n this.log(\"Category breakdown:\");\n const sortedCategories = sortBy(\n Object.entries(getMarketplaceStats(marketplace).byCategory),\n ([, count]) => -count,\n );\n for (const [category, count] of sortedCategories) {\n this.log(` ${category}: ${count}`);\n }\n }\n\n private printSample(marketplace: Marketplace): void {\n this.log(\"\");\n this.log(\"Sample plugins:\");\n const sampleSize = 5;\n for (const plugin of marketplace.plugins.slice(0, sampleSize)) {\n const version = plugin.version ? `v${plugin.version}` : \"\";\n const category = plugin.category ? `[${plugin.category}]` : \"\";\n this.log(` ${plugin.name} ${version} ${category}`);\n if (plugin.description) {\n this.log(` ${plugin.description}`);\n }\n }\n if (marketplace.plugins.length > sampleSize) {\n this.log(` ... and ${marketplace.plugins.length - sampleSize} more`);\n }\n }\n}\n\ntype ParsedAuthor = {\n name: string;\n email?: string;\n};\n\n/**\n * Refuses a manifest with no plugins in it, which the reader in this same package will not accept:\n * `marketplaceSchema.plugins` is `z.array(...).min(1)`, so `fetchMarketplace` throws\n * `plugins: Too small` on a file this command wrote and called a success. Every field that schema\n * constrains is a condition this command refuses before writing — `name`, `version` and\n * `owner.name` are the other three, all guarded off package.json. `version` was the one this\n * sentence claimed and did not have: `packageJsonSchema` types it as a bare string and the\n * generator defaults it with `??`, so `\"\"` reached the manifest untouched. This one is only\n * knowable after the scan, which is why it sits here rather than beside them.\n *\n * The two ways in are running before `build plugins` and pointing `--plugins-dir` somewhere else, so\n * the sentence names the directory it scanned and both ways out. Written here rather than in\n * `utils/messages.ts` for the reason the `Missing package.json` refusal above it is: it has one\n * caller and composes nothing another surface has to agree with.\n */\nfunction noPluginsToPublish(pluginsDir: string, pluginsDirFlag: string): string {\n return (\n `No plugins found in ${pluginsDir}. A marketplace with no plugins is refused when it is read ` +\n `back, so none was written. Run '${CLI_INVOKE_COMMAND} build plugins' first, or point ` +\n `--plugins-dir at the directory holding them (it is '${pluginsDirFlag}' for this run).`\n );\n}\n\n/**\n * Parses a package.json `author` field into name + optional email.\n *\n * npm supports both shorthand strings `\"Name <email> (url)\"` and object form\n * `{ name, email, url }`. An absent author and one that yields no name both come back\n * with an empty `name`, and the caller refuses on that — one condition, one sentence,\n * written where the refusal is. A missing EMAIL is warned about and carried on from,\n * because `owner.email` is the half the manifest schema leaves optional.\n */\nfunction parseAuthor(author: string | { name: string; email?: string } | undefined): ParsedAuthor {\n if (!author) return { name: \"\" };\n\n if (typeof author === \"object\") {\n return { name: author.name, ...(author.email !== undefined && { email: author.email }) };\n }\n\n const [, matchedName, matchedEmail] = author.match(AUTHOR_STRING_PATTERN) ?? [];\n if (matchedName !== undefined && matchedEmail !== undefined) {\n return { name: matchedName.trim(), email: matchedEmail.trim() };\n }\n\n warn(\n `package.json 'author' field \"${author}\" has no parseable email — marketplace owner.email will be empty`,\n );\n return { name: author.trim() };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,SAAS,aAAa;AACtB,OAAO,UAAU;AACjB,SAAS,cAAc;AACvB,SAAS,SAAS;AAiClB,IAAM,sBAAsB,GAAG,mBAAmB,IAAI,gBAAgB;AAEtE,IAAM,wBAAwB;AAG9B,IAAM,mBAAmB;AAGzB,IAAM,wBAAwB;AAE9B,IAAM,4BAA4B,EAAE,OAAO;AAAA,EACzC,MAAM,EAAE,OAAO;AAAA,EACf,OAAO,EAAE,OAAO,EAAE,cAAc;AAAA,EAChC,KAAK,EAAE,OAAO,EAAE,cAAc;AAChC,CAAC;AAED,IAAM,oBAAoB,EACvB,OAAO;AAAA,EACN,MAAM,EAAE,OAAO;AAAA,EACf,SAAS,EAAE,OAAO;AAAA,EAClB,aAAa,EAAE,OAAO;AAAA,EACtB,QAAQ,EAAE,MAAM,CAAC,EAAE,OAAO,GAAG,yBAAyB,CAAC,EAAE,cAAc;AACzE,CAAC,EACA,YAAY;AAQf,IAAqB,mBAArB,MAAqB,0BAAyB,YAAY;AAAA,EACxD,OAAO,UAAU;AAAA,EAEjB,OAAO,cACL;AAAA,EAEF,OAAO,WAAW;AAAA,IAChB;AAAA,MACE,aAAa;AAAA,MACb,SAAS;AAAA,IACX;AAAA,IACA;AAAA,MACE,aAAa;AAAA,MACb,SAAS;AAAA,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"../../chunk-ZR4YPKXQ.js";
|
|
6
|
+
import "../../chunk-GE3WKJ6Q.js";
|
|
6
7
|
import {
|
|
7
8
|
BaseCommand
|
|
8
|
-
} from "../../chunk-
|
|
9
|
-
import "../../chunk-
|
|
10
|
-
import "../../chunk-
|
|
9
|
+
} from "../../chunk-Y3VIRVVE.js";
|
|
10
|
+
import "../../chunk-VAPTVR3J.js";
|
|
11
|
+
import "../../chunk-RZDXDMT6.js";
|
|
11
12
|
import {
|
|
12
13
|
compileAllSkillPlugins,
|
|
13
14
|
compileSkillPlugin,
|
|
14
15
|
listDirectories,
|
|
16
|
+
plural,
|
|
15
17
|
printCompilationSummary,
|
|
16
18
|
readPluginManifest,
|
|
17
19
|
remove,
|
|
18
20
|
setVerbose
|
|
19
|
-
} from "../../chunk-
|
|
20
|
-
import "../../chunk-
|
|
21
|
+
} from "../../chunk-A4KDXNOT.js";
|
|
22
|
+
import "../../chunk-V5WXIM2F.js";
|
|
21
23
|
import {
|
|
22
24
|
DIRS,
|
|
23
25
|
PLUGINS_DIST_PATH
|
|
24
|
-
} from "../../chunk-
|
|
26
|
+
} from "../../chunk-ENGYJCTF.js";
|
|
25
27
|
import "../../chunk-OI2H6M5I.js";
|
|
26
28
|
|
|
27
29
|
// src/cli/commands/build/plugins.ts
|
|
@@ -121,7 +123,7 @@ var BuildPlugins = class _BuildPlugins extends BaseCommand {
|
|
|
121
123
|
}
|
|
122
124
|
this.log("Finding and compiling all skills...");
|
|
123
125
|
const { compiled, failed } = await compileAllSkillPlugins(skillsDir, outputDir);
|
|
124
|
-
this.log(`Compiled ${compiled.length
|
|
126
|
+
this.log(`Compiled ${plural(compiled.length, "skill plugin")}`);
|
|
125
127
|
printCompilationSummary(compiled);
|
|
126
128
|
if (failed.length > 0) {
|
|
127
129
|
this.warn(
|
|
@@ -139,7 +141,7 @@ var BuildPlugins = class _BuildPlugins extends BaseCommand {
|
|
|
139
141
|
this.log("");
|
|
140
142
|
this.log("Finding and compiling all agents...");
|
|
141
143
|
const agentResults = await compileAllAgentPlugins(resolvedAgentsDir, outputDir);
|
|
142
|
-
this.log(`Compiled ${agentResults.length
|
|
144
|
+
this.log(`Compiled ${plural(agentResults.length, "agent plugin")}`);
|
|
143
145
|
printAgentCompilationSummary(agentResults);
|
|
144
146
|
}
|
|
145
147
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/cli/commands/build/plugins.ts"],"sourcesContent":["import { Flags } from \"@oclif/core\";\nimport path from \"path\";\n\nimport { BaseCommand } from \"../../base-command\";\nimport { setVerbose } from \"../../utils/logger\";\nimport { listDirectories, remove } from \"../../utils/fs\";\nimport { DIRS, PLUGINS_DIST_PATH } from \"../../consts\";\nimport {\n compileAllSkillPlugins,\n compileSkillPlugin,\n printCompilationSummary,\n} from \"../../lib/skills\";\nimport { compileAllAgentPlugins, printAgentCompilationSummary } from \"../../lib/agents\";\nimport { readPluginManifest } from \"../../lib/plugins\";\n\nexport default class BuildPlugins extends BaseCommand {\n static summary = \"Build skills and agents into standalone plugins\";\n\n static description =\n \"Build skills and agents into standalone plugins. By default, compiles all skills. Use --skill to compile a specific skill only. Use --agents-dir to also compile agents.\";\n\n static examples = [\n {\n description: \"Compile every skill into plugins\",\n command: \"<%= config.bin %> <%= command.id %>\",\n },\n {\n description: \"Compile a single skill by name\",\n command: \"<%= config.bin %> <%= command.id %> --skill cli-commander\",\n },\n {\n description: \"Write plugins to a custom output directory\",\n command: \"<%= config.bin %> <%= command.id %> --output-dir ./plugins\",\n },\n {\n description: \"Also compile agents from a directory\",\n command: \"<%= config.bin %> <%= command.id %> --agents-dir ./agents\",\n },\n {\n description: \"Compile with verbose logging\",\n command: \"<%= config.bin %> <%= command.id %> --verbose\",\n },\n ];\n\n static flags = {\n \"agents-dir\": Flags.string({\n char: \"a\",\n description: \"Agents source directory (builds one plugin per agent)\",\n }),\n \"output-dir\": Flags.string({\n char: \"o\",\n description: \"Output directory\",\n default: PLUGINS_DIST_PATH,\n }),\n skill: Flags.string({\n description: \"Compile only a specific skill (path to skill directory)\",\n }),\n verbose: Flags.boolean({\n char: \"v\",\n description: \"Enable verbose logging\",\n default: false,\n }),\n };\n\n async run(): Promise<void> {\n const { flags } = await this.parse(BuildPlugins);\n setVerbose(flags.verbose);\n\n const projectRoot = process.cwd();\n const skillsDir = path.resolve(projectRoot, DIRS.skills);\n const outputDir = path.resolve(projectRoot, flags[\"output-dir\"]);\n\n this.printHeader(skillsDir, outputDir);\n\n try {\n const expectedSkillPlugins = await this.compileSkills(flags.skill, skillsDir, outputDir);\n\n if (flags[\"agents-dir\"]) {\n await this.compileAgents(projectRoot, flags[\"agents-dir\"], outputDir);\n }\n\n if (expectedSkillPlugins) {\n await this.pruneStaleSkillPlugins(outputDir, expectedSkillPlugins);\n }\n\n this.log(\"\");\n this.logSuccess(\"Plugin compilation complete!\");\n } catch (error) {\n this.log(\"Compilation failed\");\n this.handleError(error);\n }\n }\n\n private printHeader(skillsDir: string, outputDir: string): void {\n this.log(\"\");\n this.log(\"Compiling skill plugins\");\n this.log(` Skills directory: ${skillsDir}`);\n this.log(` Output directory: ${outputDir}`);\n this.log(\"\");\n }\n\n /**\n * Compiles skills and returns the set of plugin directory names that should\n * exist afterward — used to prune stale plugins. Returns `null` when pruning\n * must be skipped: single-skill mode (would wipe every other plugin) or a\n * partial compile failure (a failed skill is indistinguishable from a removed\n * one, so deleting it would be a worse bug than the stale entry).\n */\n private async compileSkills(\n skillFlag: string | undefined,\n skillsDir: string,\n outputDir: string,\n ): Promise<Set<string> | null> {\n if (skillFlag) {\n const skillPath = path.resolve(skillsDir, skillFlag);\n this.log(`Compiling skill at ${skillPath}...`);\n\n const result = await compileSkillPlugin({\n skillPath,\n outputDir,\n });\n\n this.log(`Compiled ${result.skillName}`);\n this.log(` Plugin path: ${result.pluginPath}`);\n return null;\n }\n\n this.log(\"Finding and compiling all skills...\");\n\n const { compiled, failed } = await compileAllSkillPlugins(skillsDir, outputDir);\n\n this.log(`Compiled ${compiled.length
|
|
1
|
+
{"version":3,"sources":["../../../src/cli/commands/build/plugins.ts"],"sourcesContent":["import { Flags } from \"@oclif/core\";\nimport path from \"path\";\n\nimport { BaseCommand } from \"../../base-command\";\nimport { setVerbose } from \"../../utils/logger\";\nimport { listDirectories, remove } from \"../../utils/fs\";\nimport { DIRS, PLUGINS_DIST_PATH } from \"../../consts\";\nimport {\n compileAllSkillPlugins,\n compileSkillPlugin,\n printCompilationSummary,\n} from \"../../lib/skills\";\nimport { compileAllAgentPlugins, printAgentCompilationSummary } from \"../../lib/agents\";\nimport { readPluginManifest } from \"../../lib/plugins\";\nimport { plural } from \"../../utils/string\";\n\nexport default class BuildPlugins extends BaseCommand {\n static summary = \"Build skills and agents into standalone plugins\";\n\n static description =\n \"Build skills and agents into standalone plugins. By default, compiles all skills. Use --skill to compile a specific skill only. Use --agents-dir to also compile agents.\";\n\n static examples = [\n {\n description: \"Compile every skill into plugins\",\n command: \"<%= config.bin %> <%= command.id %>\",\n },\n {\n description: \"Compile a single skill by name\",\n command: \"<%= config.bin %> <%= command.id %> --skill cli-commander\",\n },\n {\n description: \"Write plugins to a custom output directory\",\n command: \"<%= config.bin %> <%= command.id %> --output-dir ./plugins\",\n },\n {\n description: \"Also compile agents from a directory\",\n command: \"<%= config.bin %> <%= command.id %> --agents-dir ./agents\",\n },\n {\n description: \"Compile with verbose logging\",\n command: \"<%= config.bin %> <%= command.id %> --verbose\",\n },\n ];\n\n static flags = {\n \"agents-dir\": Flags.string({\n char: \"a\",\n description: \"Agents source directory (builds one plugin per agent)\",\n }),\n \"output-dir\": Flags.string({\n char: \"o\",\n description: \"Output directory\",\n default: PLUGINS_DIST_PATH,\n }),\n skill: Flags.string({\n description: \"Compile only a specific skill (path to skill directory)\",\n }),\n verbose: Flags.boolean({\n char: \"v\",\n description: \"Enable verbose logging\",\n default: false,\n }),\n };\n\n async run(): Promise<void> {\n const { flags } = await this.parse(BuildPlugins);\n setVerbose(flags.verbose);\n\n const projectRoot = process.cwd();\n const skillsDir = path.resolve(projectRoot, DIRS.skills);\n const outputDir = path.resolve(projectRoot, flags[\"output-dir\"]);\n\n this.printHeader(skillsDir, outputDir);\n\n try {\n const expectedSkillPlugins = await this.compileSkills(flags.skill, skillsDir, outputDir);\n\n if (flags[\"agents-dir\"]) {\n await this.compileAgents(projectRoot, flags[\"agents-dir\"], outputDir);\n }\n\n if (expectedSkillPlugins) {\n await this.pruneStaleSkillPlugins(outputDir, expectedSkillPlugins);\n }\n\n this.log(\"\");\n this.logSuccess(\"Plugin compilation complete!\");\n } catch (error) {\n this.log(\"Compilation failed\");\n this.handleError(error);\n }\n }\n\n private printHeader(skillsDir: string, outputDir: string): void {\n this.log(\"\");\n this.log(\"Compiling skill plugins\");\n this.log(` Skills directory: ${skillsDir}`);\n this.log(` Output directory: ${outputDir}`);\n this.log(\"\");\n }\n\n /**\n * Compiles skills and returns the set of plugin directory names that should\n * exist afterward — used to prune stale plugins. Returns `null` when pruning\n * must be skipped: single-skill mode (would wipe every other plugin) or a\n * partial compile failure (a failed skill is indistinguishable from a removed\n * one, so deleting it would be a worse bug than the stale entry).\n */\n private async compileSkills(\n skillFlag: string | undefined,\n skillsDir: string,\n outputDir: string,\n ): Promise<Set<string> | null> {\n if (skillFlag) {\n const skillPath = path.resolve(skillsDir, skillFlag);\n this.log(`Compiling skill at ${skillPath}...`);\n\n const result = await compileSkillPlugin({\n skillPath,\n outputDir,\n });\n\n this.log(`Compiled ${result.skillName}`);\n this.log(` Plugin path: ${result.pluginPath}`);\n return null;\n }\n\n this.log(\"Finding and compiling all skills...\");\n\n const { compiled, failed } = await compileAllSkillPlugins(skillsDir, outputDir);\n\n this.log(`Compiled ${plural(compiled.length, \"skill plugin\")}`);\n printCompilationSummary(compiled);\n\n if (failed.length > 0) {\n this.warn(\n `Skipping stale-plugin pruning: ${failed.length} skill(s) failed to compile ` +\n `(${failed.join(\", \")}). A failed skill is indistinguishable from a removed one.`,\n );\n return null;\n }\n\n return new Set(compiled.map((result) => result.skillName));\n }\n\n private async compileAgents(\n projectRoot: string,\n agentsDir: string,\n outputDir: string,\n ): Promise<void> {\n const resolvedAgentsDir = path.resolve(projectRoot, agentsDir);\n\n this.log(\"\");\n this.log(\"Compiling agent plugins\");\n this.log(` Agents directory: ${resolvedAgentsDir}`);\n this.log(\"\");\n\n this.log(\"Finding and compiling all agents...\");\n\n const agentResults = await compileAllAgentPlugins(resolvedAgentsDir, outputDir);\n\n this.log(`Compiled ${plural(agentResults.length, \"agent plugin\")}`);\n printAgentCompilationSummary(agentResults);\n }\n\n /**\n * Removes skill-plugin directories in `outputDir` that no longer correspond to\n * a compiled skill. Only skill plugins are pruned: agent plugins are preserved\n * (this run has no authority over them) and non-plugin directories are left\n * untouched. Callers must only invoke this after a clean full-scan compile.\n */\n private async pruneStaleSkillPlugins(\n outputDir: string,\n expectedSkillPlugins: ReadonlySet<string>,\n ): Promise<void> {\n const dirNames = await listDirectories(outputDir);\n\n for (const dirName of dirNames) {\n if (expectedSkillPlugins.has(dirName)) continue;\n\n const pluginDir = path.join(outputDir, dirName);\n const manifest = await readPluginManifest(pluginDir);\n if (!manifest) continue;\n if (manifest.agents !== undefined) continue;\n\n await remove(pluginDir);\n this.log(` Pruned stale plugin: ${dirName}`);\n }\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,SAAS,aAAa;AACtB,OAAO,UAAU;AAejB,IAAqB,eAArB,MAAqB,sBAAqB,YAAY;AAAA,EACpD,OAAO,UAAU;AAAA,EAEjB,OAAO,cACL;AAAA,EAEF,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,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,sBACe;AACf,UAAM,WAAW,MAAM,gBAAgB,SAAS;AAEhD,eAAW,WAAW,UAAU;AAC9B,UAAI,qBAAqB,IAAI,OAAO,EAAG;AAEvC,YAAM,YAAY,KAAK,KAAK,WAAW,OAAO;AAC9C,YAAM,WAAW,MAAM,mBAAmB,SAAS;AACnD,UAAI,CAAC,SAAU;AACf,UAAI,SAAS,WAAW,OAAW;AAEnC,YAAM,OAAO,SAAS;AACtB,WAAK,IAAI,0BAA0B,OAAO,EAAE;AAAA,IAC9C;AAAA,EACF;AACF;","names":[]}
|
package/dist/commands/compile.js
CHANGED
|
@@ -1,22 +1,34 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
+
import {
|
|
3
|
+
unofferablePlacementsFound
|
|
4
|
+
} from "../chunk-PXWG7KFO.js";
|
|
5
|
+
import {
|
|
6
|
+
hostCompileNotices
|
|
7
|
+
} from "../chunk-ZXKBERQU.js";
|
|
2
8
|
import {
|
|
3
9
|
detectBothInstallations,
|
|
4
10
|
reconcileTypesFromDisk
|
|
5
|
-
} from "../chunk-
|
|
11
|
+
} from "../chunk-G6UREQ4V.js";
|
|
6
12
|
import {
|
|
7
13
|
compileAgents,
|
|
8
14
|
discoverInstalledSkills
|
|
9
|
-
} from "../chunk-
|
|
15
|
+
} from "../chunk-HWEKHVLE.js";
|
|
10
16
|
import {
|
|
11
17
|
loadAgentDefs
|
|
12
|
-
} from "../chunk-
|
|
13
|
-
import "../chunk-
|
|
18
|
+
} from "../chunk-PMJWD27C.js";
|
|
19
|
+
import "../chunk-ZR4YPKXQ.js";
|
|
20
|
+
import "../chunk-GE3WKJ6Q.js";
|
|
21
|
+
import {
|
|
22
|
+
providerFlag,
|
|
23
|
+
providerNamedBy,
|
|
24
|
+
refuseAnAmbiguousInstallation
|
|
25
|
+
} from "../chunk-NBXXFIIW.js";
|
|
14
26
|
import {
|
|
15
27
|
BaseCommand,
|
|
16
28
|
EXIT_CODES
|
|
17
|
-
} from "../chunk-
|
|
18
|
-
import "../chunk-
|
|
19
|
-
import "../chunk-
|
|
29
|
+
} from "../chunk-Y3VIRVVE.js";
|
|
30
|
+
import "../chunk-VAPTVR3J.js";
|
|
31
|
+
import "../chunk-RZDXDMT6.js";
|
|
20
32
|
import {
|
|
21
33
|
ConfigLoadError,
|
|
22
34
|
ERROR_MESSAGES,
|
|
@@ -26,11 +38,13 @@ import {
|
|
|
26
38
|
getErrorMessage,
|
|
27
39
|
getStackSkillIds,
|
|
28
40
|
globalScopedAgentsHint,
|
|
41
|
+
loadInstalledConfig,
|
|
29
42
|
loadProjectConfig,
|
|
30
|
-
loadProjectConfigFromDir,
|
|
31
43
|
loadSkillsMatrixFromSource,
|
|
44
|
+
plural,
|
|
45
|
+
providerInUse,
|
|
32
46
|
recompileSummary,
|
|
33
|
-
|
|
47
|
+
registeredProjectUpdateFailed,
|
|
34
48
|
resolveAgentConfigToSkills,
|
|
35
49
|
resolveSource,
|
|
36
50
|
scopeBlockedStackAssignment,
|
|
@@ -38,13 +52,13 @@ import {
|
|
|
38
52
|
skillMetadataUnusableDetail,
|
|
39
53
|
skillMetadataUnusableError,
|
|
40
54
|
verbose
|
|
41
|
-
} from "../chunk-
|
|
42
|
-
import "../chunk-
|
|
55
|
+
} from "../chunk-A4KDXNOT.js";
|
|
56
|
+
import "../chunk-V5WXIM2F.js";
|
|
43
57
|
import {
|
|
44
58
|
STANDARD_FILES,
|
|
45
59
|
effectivelyExcludedSkillIds,
|
|
46
60
|
isActiveAt
|
|
47
|
-
} from "../chunk-
|
|
61
|
+
} from "../chunk-ENGYJCTF.js";
|
|
48
62
|
import "../chunk-OI2H6M5I.js";
|
|
49
63
|
|
|
50
64
|
// src/cli/commands/compile.ts
|
|
@@ -63,16 +77,43 @@ var Compile = class _Compile extends BaseCommand {
|
|
|
63
77
|
char: "v",
|
|
64
78
|
description: "Enable verbose logging",
|
|
65
79
|
default: false
|
|
66
|
-
})
|
|
80
|
+
}),
|
|
81
|
+
provider: providerFlag()
|
|
67
82
|
};
|
|
68
83
|
async run() {
|
|
69
84
|
const { flags } = await this.parse(_Compile);
|
|
70
85
|
setVerbose(flags.verbose);
|
|
71
86
|
const cwd = process.cwd();
|
|
87
|
+
await refuseAnAmbiguousInstallation(
|
|
88
|
+
cwd,
|
|
89
|
+
"compile",
|
|
90
|
+
providerNamedBy(flags.provider),
|
|
91
|
+
(message) => this.error(message, { exit: EXIT_CODES.INVALID_ARGS })
|
|
92
|
+
);
|
|
93
|
+
await this.ensureConfigReadable(cwd);
|
|
72
94
|
const installations = await this.detectInstallations(cwd);
|
|
95
|
+
await this.refuseUnofferablePlacements(cwd);
|
|
73
96
|
await this.resolveAndLogSource(cwd);
|
|
74
97
|
const agentDefs = await this.loadAgentDefsOrFail();
|
|
75
98
|
await this.runCompilePasses(installations, agentDefs, cwd);
|
|
99
|
+
await this.reportWhatThisHostCannotCarry(installations, cwd);
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* What this host could not carry, once per run and after the passes.
|
|
103
|
+
*
|
|
104
|
+
* AFTER, because the trust half of it is a question about the tree as it now stands: a project
|
|
105
|
+
* whose role files this run just wrote is exactly the one whose user has to trust it, and asking
|
|
106
|
+
* before the write would answer about the previous state.
|
|
107
|
+
*
|
|
108
|
+
* `init` prints the same lines in the same order — {@link hostCompileNotices} is the one place
|
|
109
|
+
* either of them gets them from, so the two commands cannot drift into saying different things
|
|
110
|
+
* about one tree.
|
|
111
|
+
*/
|
|
112
|
+
async reportWhatThisHostCannotCarry(installations, cwd) {
|
|
113
|
+
const root = rootThisRunCompiled(installations, cwd);
|
|
114
|
+
for (const notice of await hostCompileNotices(providerInUse(root), cwd)) {
|
|
115
|
+
this.log(notice);
|
|
116
|
+
}
|
|
76
117
|
}
|
|
77
118
|
async detectInstallations(cwd) {
|
|
78
119
|
let installations;
|
|
@@ -91,6 +132,26 @@ var Compile = class _Compile extends BaseCommand {
|
|
|
91
132
|
}
|
|
92
133
|
return installations;
|
|
93
134
|
}
|
|
135
|
+
/**
|
|
136
|
+
* Refuses a configuration asking for a mode/scope cell its own host does not offer, BEFORE
|
|
137
|
+
* anything is discovered, compiled or written.
|
|
138
|
+
*
|
|
139
|
+
* **The install path's pre-flight cannot cover this, and nothing ties a folder's contents to
|
|
140
|
+
* its name.** `config.ts` carries no provider field — the ruling forbids one, so that a saved
|
|
141
|
+
* configuration installs onto either provider — which means a user who copies
|
|
142
|
+
* `.agents-inc/claude/` to `.agents-inc/codex/` has a Codex installation holding a
|
|
143
|
+
* configuration that never met `init --from --provider codex`'s refusal. This is the command
|
|
144
|
+
* that turns a configuration into files on disk, so it is the one that has to ask again.
|
|
145
|
+
*
|
|
146
|
+
* Both scopes, because a project inherits its global's rows and an unofferable row in either
|
|
147
|
+
* file is a row this run would act on. Each installation is asked about its OWN host: the two
|
|
148
|
+
* scopes can be on different providers, and asking one host about the other's configuration is
|
|
149
|
+
* how a refusal fires on a cell that is offered where the skill actually lives.
|
|
150
|
+
*/
|
|
151
|
+
async refuseUnofferablePlacements(cwd) {
|
|
152
|
+
const [finding] = await unofferablePlacementsFound(cwd);
|
|
153
|
+
if (finding !== void 0) this.error(finding, { exit: EXIT_CODES.ERROR });
|
|
154
|
+
}
|
|
94
155
|
/**
|
|
95
156
|
* Names where the marketplace came from — the project's own config first, then the global
|
|
96
157
|
* one, then the default. `compile` takes no `--marketplace`: it recompiles an installation
|
|
@@ -121,12 +182,12 @@ var Compile = class _Compile extends BaseCommand {
|
|
|
121
182
|
}
|
|
122
183
|
async runCompilePasses(installations, agentDefs, cwd) {
|
|
123
184
|
const passes = buildCompilePasses(installations, cwd, agentDefs);
|
|
124
|
-
let
|
|
185
|
+
let passesCompiled = 0;
|
|
125
186
|
for (const pass of passes) {
|
|
126
|
-
const
|
|
127
|
-
if (
|
|
187
|
+
const compiled = await this.runCompilePass(pass, cwd);
|
|
188
|
+
if (compiled) passesCompiled++;
|
|
128
189
|
}
|
|
129
|
-
if (
|
|
190
|
+
if (passesCompiled === 0) {
|
|
130
191
|
this.error(ERROR_MESSAGES.NO_SKILLS_TO_COMPILE, { exit: EXIT_CODES.ERROR });
|
|
131
192
|
}
|
|
132
193
|
}
|
|
@@ -202,7 +263,7 @@ var Compile = class _Compile extends BaseCommand {
|
|
|
202
263
|
* change, so name the global context and the count.
|
|
203
264
|
*/
|
|
204
265
|
async hintGlobalScopedAgents(projectDir) {
|
|
205
|
-
const loaded = await
|
|
266
|
+
const loaded = await loadInstalledConfig(projectDir);
|
|
206
267
|
if (!loaded) return;
|
|
207
268
|
const globalAgentCount = loaded.config.agents.filter(
|
|
208
269
|
(agent) => !agent.excluded && agent.scope === "global"
|
|
@@ -288,7 +349,7 @@ var Compile = class _Compile extends BaseCommand {
|
|
|
288
349
|
}
|
|
289
350
|
let report;
|
|
290
351
|
try {
|
|
291
|
-
const loaded = await
|
|
352
|
+
const loaded = await loadInstalledConfig(pass.projectDir);
|
|
292
353
|
if (!loaded) {
|
|
293
354
|
verbose(
|
|
294
355
|
`No config found at ${pass.projectDir} \u2014 skipping ${STANDARD_FILES.CONFIG_TYPES_TS} refresh`
|
|
@@ -314,11 +375,13 @@ var Compile = class _Compile extends BaseCommand {
|
|
|
314
375
|
* not as a failure to refresh the type unions — which did succeed.
|
|
315
376
|
*/
|
|
316
377
|
reportPropagation(report) {
|
|
317
|
-
|
|
318
|
-
|
|
378
|
+
this.reportProjectsOutOfReach(report.propagated);
|
|
379
|
+
for (const projectPath of report.propagated.failed) {
|
|
380
|
+
this.warn(registeredProjectUpdateFailed(projectPath));
|
|
319
381
|
}
|
|
320
|
-
this.
|
|
382
|
+
this.reportFanOut(report);
|
|
321
383
|
}
|
|
384
|
+
/** Runs one pass, and answers whether it compiled rather than skipping for want of anything to. */
|
|
322
385
|
async runCompilePass(params, cwd) {
|
|
323
386
|
const { label, projectDir, installation, sourcePath, scopeFilter } = params;
|
|
324
387
|
this.log("");
|
|
@@ -328,9 +391,11 @@ var Compile = class _Compile extends BaseCommand {
|
|
|
328
391
|
verbose(` Agents: ${installation.agentsDir}`);
|
|
329
392
|
const seatedMatrix = await this.seatMatrixForPass(projectDir);
|
|
330
393
|
const { allSkills, totalSkillCount } = await this.discoverAllSkills(projectDir);
|
|
331
|
-
|
|
394
|
+
const compilesBaseAgents = totalSkillCount === 0 && await declaresOnlyBaseAgents(params);
|
|
395
|
+
if (compilesBaseAgents) {
|
|
396
|
+
this.log(`No skills configured for ${label.toLowerCase()} pass, compiling base agents`);
|
|
397
|
+
} else if (totalSkillCount === 0) {
|
|
332
398
|
this.log(`No skills found for ${label.toLowerCase()} pass, skipping`);
|
|
333
|
-
await this.refreshConfigTypes(params, cwd, seatedMatrix);
|
|
334
399
|
return false;
|
|
335
400
|
}
|
|
336
401
|
await this.warnUnresolvedStackSkills(projectDir, allSkills);
|
|
@@ -349,7 +414,7 @@ var Compile = class _Compile extends BaseCommand {
|
|
|
349
414
|
const summary = recompileSummary(
|
|
350
415
|
rewritten.length,
|
|
351
416
|
compiled.length - rewritten.length,
|
|
352
|
-
`${label.toLowerCase()}
|
|
417
|
+
`${label.toLowerCase()} agent`
|
|
353
418
|
);
|
|
354
419
|
if (failed.length > 0) {
|
|
355
420
|
this.log(`${summary} (${failed.length} failed)`);
|
|
@@ -405,6 +470,19 @@ function buildCompilePasses(installations, cwd, agentDefs) {
|
|
|
405
470
|
}
|
|
406
471
|
return [];
|
|
407
472
|
}
|
|
473
|
+
function rootThisRunCompiled(installations, cwd) {
|
|
474
|
+
return installations.project ? cwd : os.homedir();
|
|
475
|
+
}
|
|
476
|
+
async function declaresOnlyBaseAgents(pass) {
|
|
477
|
+
const loaded = await loadInstalledConfig(pass.projectDir);
|
|
478
|
+
if (!loaded) return false;
|
|
479
|
+
const { skills, agents } = loaded.config;
|
|
480
|
+
const declaresASkill = skills.some((skill) => !skill.excluded);
|
|
481
|
+
const compilesAnAgent = agents.some(
|
|
482
|
+
(agent) => pass.scopeFilter === void 0 ? !agent.excluded : isActiveAt(agent, pass.scopeFilter)
|
|
483
|
+
);
|
|
484
|
+
return !declaresASkill && compilesAnAgent;
|
|
485
|
+
}
|
|
408
486
|
function findScopeDroppedStackPairs(config) {
|
|
409
487
|
const stack = config.stack ?? {};
|
|
410
488
|
const globalAgentNames = config.agents.filter((agent) => isActiveAt(agent, "global")).map((agent) => agent.name);
|
|
@@ -424,9 +502,9 @@ function formatDiscoveryMessage(result) {
|
|
|
424
502
|
const { totalSkillCount, pluginSkillCount } = result;
|
|
425
503
|
const localCount = totalSkillCount - pluginSkillCount;
|
|
426
504
|
if (pluginSkillCount > 0 && localCount > 0) {
|
|
427
|
-
return `Discovered ${totalSkillCount}
|
|
505
|
+
return `Discovered ${plural(totalSkillCount, "skill")} (${pluginSkillCount} from plugins, ${localCount} local)`;
|
|
428
506
|
}
|
|
429
|
-
return pluginSkillCount > 0 ? `Discovered ${pluginSkillCount}
|
|
507
|
+
return pluginSkillCount > 0 ? `Discovered ${plural(pluginSkillCount, "skill")} from plugins` : `Discovered ${plural(totalSkillCount, "local skill")}`;
|
|
430
508
|
}
|
|
431
509
|
export {
|
|
432
510
|
Compile as default
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/cli/commands/compile.ts"],"sourcesContent":["import { Flags } from \"@oclif/core\";\nimport os from \"os\";\nimport { unique } from \"remeda\";\nimport { BaseCommand } from \"../base-command\";\nimport { setVerbose, verbose } from \"../utils/logger\";\nimport {\n detectBothInstallations,\n type BothInstallations,\n loadAgentDefs,\n type AgentDefs,\n compileAgents,\n discoverInstalledSkills,\n type DiscoveredSkills,\n} from \"../lib/operations\";\nimport {\n ConfigLoadError,\n effectivelyExcludedSkillIds,\n isActiveAt,\n loadProjectConfig,\n loadProjectConfigFromDir,\n resolveSource,\n} from \"../lib/configuration\";\nimport { getStackSkillIds, resolveAgentConfigToSkills } from \"../lib/stacks\";\nimport { loadSkillsMatrixFromSource, type UnusableSkillMetadata } from \"../lib/loading\";\nimport { STANDARD_FILES } from \"../consts\";\nimport { EXIT_CODES } from \"../lib/exit-codes\";\nimport { getErrorMessage } from \"../utils/errors\";\nimport {\n ERROR_MESSAGES,\n STATUS_MESSAGES,\n INFO_MESSAGES,\n configTypesRefreshFailed,\n globalScopedAgentsHint,\n recompileSummary,\n registeredProjectUpdateSkipped,\n scopeBlockedStackAssignment,\n skillMetadataUnusableDetail,\n skillMetadataUnusableError,\n} from \"../utils/messages\";\nimport { reconcileTypesFromDisk, type GateReport } from \"../lib/config-gate/index.js\";\nimport type { Installation } from \"../lib/installation\";\nimport type { SkillScope } from \"../types/config\";\nimport type {\n AgentDefinition,\n AgentName,\n MergedSkillsMatrix,\n ProjectConfig,\n SkillDefinitionMap,\n SkillId,\n StackAgentConfig,\n} from \"../types\";\n\nexport default class Compile extends BaseCommand {\n static summary = \"Compile agents using local skills and agent definitions\";\n\n static description =\n \"Compile agents with resolved skill references. Compiles to the Claude plugin directory.\";\n\n static examples = [\n \"<%= config.bin %> <%= command.id %>\",\n \"<%= config.bin %> <%= command.id %> --verbose\",\n ];\n\n static flags = {\n verbose: Flags.boolean({\n char: \"v\",\n description: \"Enable verbose logging\",\n default: false,\n }),\n };\n\n async run(): Promise<void> {\n const { flags } = await this.parse(Compile);\n setVerbose(flags.verbose);\n const cwd = process.cwd();\n\n const installations = await this.detectInstallations(cwd);\n await this.resolveAndLogSource(cwd);\n const agentDefs = await this.loadAgentDefsOrFail();\n await this.runCompilePasses(installations, agentDefs, cwd);\n }\n\n private async detectInstallations(cwd: string): Promise<BothInstallations> {\n let installations: BothInstallations;\n try {\n installations = await detectBothInstallations(cwd);\n } catch (error) {\n // A corrupt config (file present but unparseable) must not let compile run\n // config-less — that resurrects every deselected agent. Hard-error naming\n // the offending file before any compilation happens.\n if (error instanceof ConfigLoadError) {\n this.error(error.message, { exit: EXIT_CODES.ERROR });\n }\n throw error;\n }\n\n if (!installations.global && !installations.project) {\n this.error(ERROR_MESSAGES.NO_INSTALLATION, {\n exit: EXIT_CODES.ERROR,\n });\n }\n\n return installations;\n }\n\n /**\n * Names where the marketplace came from — the project's own config first, then the global\n * one, then the default. `compile` takes no `--marketplace`: it recompiles an installation\n * that already recorded which marketplace its skill references answer to, and reading\n * a different one would write agents against a catalogue config.ts does not name.\n */\n private async resolveAndLogSource(projectDir: string): Promise<void> {\n this.log(STATUS_MESSAGES.RESOLVING_SOURCE);\n try {\n // ABORT on an unreadable config, and unreachable with one: `detectInstallation` reads the\n // same file first and already hard-errors, at both scopes — verified by hand at both.\n // The posture is recorded anyway, because what makes it unreachable is a guard in another\n // command's private helper rather than anything visible from here.\n const sourceConfig = await resolveSource({ caller: \"stored\", projectDir });\n this.log(`Marketplace: ${sourceConfig.sourceOrigin}`);\n } catch (error) {\n this.log(ERROR_MESSAGES.FAILED_RESOLVE_SOURCE);\n this.handleError(error);\n }\n }\n\n private async loadAgentDefsOrFail(): Promise<AgentDefs> {\n this.log(STATUS_MESSAGES.LOADING_AGENT_PARTIALS);\n try {\n const defs = await loadAgentDefs();\n this.log(\"Agent partials loaded\");\n verbose(` Agents: ${defs.agentSourcePaths.agentsDir}`);\n return defs;\n } catch (error) {\n this.log(ERROR_MESSAGES.FAILED_LOAD_AGENT_PARTIALS);\n this.handleError(error);\n }\n }\n\n private async runCompilePasses(\n installations: BothInstallations,\n agentDefs: AgentDefs,\n cwd: string,\n ): Promise<void> {\n const passes = buildCompilePasses(installations, cwd, agentDefs);\n\n let totalPassesWithSkills = 0;\n for (const pass of passes) {\n const hadSkills = await this.runCompilePass(pass, cwd);\n if (hadSkills) totalPassesWithSkills++;\n }\n\n if (totalPassesWithSkills === 0) {\n this.error(ERROR_MESSAGES.NO_SKILLS_TO_COMPILE, { exit: EXIT_CODES.ERROR });\n }\n }\n\n /**\n * Discovers what this pass compiles from, and refuses the run when any installed\n * skill's metadata.yaml exists but describes no skill — before a count is printed,\n * an agent is written or the type unions are regenerated. Skipping such a skill is\n * what the config-types pass already does; loading it anyway is what this pass\n * used to do, so a single run both loaded and skipped the same file.\n */\n private async discoverAllSkills(projectDir: string): Promise<DiscoveredSkills> {\n this.log(STATUS_MESSAGES.DISCOVERING_SKILLS);\n const result = await discoverInstalledSkills(projectDir);\n if (result.unusableMetadata.length > 0) {\n this.refuseUnusableSkillMetadata(result.unusableMetadata);\n }\n if (result.totalSkillCount === 0) return result;\n this.log(formatDiscoveryMessage(result));\n return result;\n }\n\n /**\n * Names each offending file and its reason, then exits. The detail is LOGGED and\n * only the refusal is raised: oclif hard-wraps error text at the terminal width,\n * and a path broken across two lines is one nobody can copy.\n */\n private refuseUnusableSkillMetadata(entries: UnusableSkillMetadata[]): never {\n for (const entry of entries) {\n this.log(skillMetadataUnusableDetail(entry));\n }\n this.error(skillMetadataUnusableError(entries), { exit: EXIT_CODES.ERROR });\n }\n\n /**\n * A stack skill that is not among the discovered skills is dropped from every\n * agent that references it. The resolver only records that at verbose level, so\n * the default output would claim a successful recompile of an agent that no\n * longer matches config.ts. Name each dropped skill instead.\n */\n private async warnUnresolvedStackSkills(\n projectDir: string,\n allSkills: SkillDefinitionMap,\n ): Promise<void> {\n const loaded = await loadProjectConfig(projectDir);\n if (!loaded?.config.stack) return;\n\n const excludedIds = effectivelyExcludedSkillIds(loaded.config.skills);\n const unresolved = getStackSkillIds(loaded.config.stack).filter(\n (id) => !excludedIds.has(id) && !(id in allSkills),\n );\n\n for (const id of unresolved) {\n this.warn(\n `Skill '${id}' is configured but was not found — agents will be compiled without it.`,\n );\n }\n }\n\n /**\n * `config.ts` is the hand-editable half of the pair, so it can declare a pair the scope\n * rule forbids: a GLOBAL sub-agent whose stack carries a PROJECT-scoped skill. The\n * compile-time filter in `buildCompileAgents` drops that reference on the way to the\n * resolver and `compile` rewrites nothing in `config.ts`, so the row survives and is\n * dropped again on every future run — while the recompile summary reports a clean pass\n * over an agent that no longer carries what its own config says it does.\n *\n * The sibling of {@link warnUnresolvedStackSkills} one layer over: there the skill is\n * missing from disk, here it is present and unreachable from that sub-agent.\n */\n private async warnScopeDroppedStackPairs(projectDir: string): Promise<void> {\n const loaded = await loadProjectConfig(projectDir);\n if (!loaded?.config.stack) return;\n\n for (const [skillId, agentNames] of findScopeDroppedStackPairs(loaded.config)) {\n this.warn(scopeBlockedStackAssignment(agentNames, skillId));\n }\n }\n\n /**\n * The project pass compiled no agents, but the project config may still declare\n * global-scope agents whose stack lives in the global config. Without a pointer\n * the \"No agents to recompile\" line reads as a silent no-op after a global stack\n * change, so name the global context and the count.\n */\n private async hintGlobalScopedAgents(projectDir: string): Promise<void> {\n const loaded = await loadProjectConfigFromDir(projectDir);\n if (!loaded) return;\n\n const globalAgentCount = loaded.config.agents.filter(\n (agent) => !agent.excluded && agent.scope === \"global\",\n ).length;\n if (globalAgentCount === 0) return;\n\n this.log(globalScopedAgentsHint(globalAgentCount));\n }\n\n /**\n * Loads this pass's skills catalogue and returns it, seating the module-level\n * singleton (`matrix` in `matrix-provider.ts`) on the way — which is what the\n * RENDER needs, because `compileAgents` reaches the catalogue through\n * `stacks-loader.ts`'s `statedUsageFor`/`liveCategoryOf` and those read the\n * singleton directly rather than any value a caller threads through. Called\n * first, before anything in the pass renders. Left unseated, the singleton stays\n * at its process-start default (`BUILT_IN_MATRIX`, which never carries a local\n * skill), so a locally-installed skill's stated `usageGuidance` silently falls\n * back to the generic per-category placeholder — different bytes from what\n * `install` last wrote, so a following `compile` rewrites every agent that\n * carries one.\n *\n * Scoped to `pass.projectDir`, never the invoking `cwd`: a global pass must seat\n * the global installation's own local skills, not the invoking directory's.\n *\n * `skipExtraSources: true` is NOT a divergence from the wizard's full\n * multi-source load: extra-source loading only annotates each skill's\n * `availableSources`/`activeSource` for wizard UI tagging — it never adds skills\n * or categories to the matrix, and neither the render path nor the config-types\n * writer ever reads those annotations, so the emitted output is byte-identical\n * either way (pinned by the skipExtraSources parity test in\n * local-installer.test.ts). Skipping avoids fetching every registered extra\n * source (network on a cold cache, plus unreachable-remote warnings) on this\n * offline compile path. `matrixOnly` keeps the default-source path itself\n * offline too.\n *\n * The seated matrix is RETURNED as well as seated, and `null` on a failure, so\n * the two halves can take the postures they each need. The RENDER degrades: it\n * reads the singleton whatever happens, and falls back to the same\n * category-placeholder behavior compile had before this seat existed. The type\n * refresh ABORTS on `null` — it derives every union from the catalogue, so with\n * none loaded it would narrow them to whatever the built-in catalogue happens\n * to carry, dropping every marketplace-only and local category and, at global\n * scope, propagating that into every registered project.\n */\n private async seatMatrixForPass(projectDir: string): Promise<MergedSkillsMatrix | null> {\n try {\n const { matrix: seated } = await loadSkillsMatrixFromSource({\n projectDir,\n skipExtraSources: true,\n matrixOnly: true,\n });\n return seated;\n } catch (error) {\n this.warn(`Failed to load skills matrix for ${projectDir}: ${getErrorMessage(error)}`);\n return null;\n }\n }\n\n /**\n * The documented hand-edit workflow is \"edit config.ts, then run compile\", and\n * the type unions in config-types.ts are derived from config.ts — so a compile\n * pass that leaves them untouched strands stale unions after a hand-edit.\n * Regenerates them from the scope's persisted config exactly as the wizard\n * write path would: standalone narrowed unions at global scope, import-and-\n * extend at project scope. A failed refresh downgrades to a warning — the\n * compiled agents are already written and remain valid; only the type unions\n * may still be stale.\n *\n * Takes the catalogue {@link seatMatrixForPass} returned rather than reading the\n * singleton it seated, so this refresh cannot run against a seat that is not the\n * one this pass asked for. `null` means the seat failed, and the refresh is\n * skipped whole: every union here is DERIVED from the catalogue, so writing them\n * without one is not a degraded answer but a wrong one — the unions narrow to\n * the built-in catalogue's own categories, and `config.ts` beside them still\n * keys its `stack` under the ones that just vanished, so the pair stops\n * type-checking. Skipping falls under the same warning as any other failed\n * refresh, for the same reason.\n */\n private async refreshConfigTypes(\n pass: CompilePass,\n cwd: string,\n seatedMatrix: MergedSkillsMatrix | null,\n ): Promise<void> {\n if (!seatedMatrix) {\n this.warn(\n configTypesRefreshFailed(`no skills catalogue could be loaded for ${pass.projectDir}`),\n );\n return;\n }\n\n let report: GateReport;\n try {\n const loaded = await loadProjectConfigFromDir(pass.projectDir);\n if (!loaded) {\n verbose(\n `No config found at ${pass.projectDir} — skipping ${STANDARD_FILES.CONFIG_TYPES_TS} refresh`,\n );\n return;\n }\n\n // `cwd` is excluded from the fan-out, which only a global pass can perform:\n // whatever this invocation was run from is this command's own subject, so a\n // fan-out must never reach back into it.\n report = await reconcileTypesFromDisk(\n pass.projectDir,\n loaded.config,\n { matrix: seatedMatrix, agents: pass.agents },\n { currentProjectDir: cwd },\n );\n this.log(INFO_MESSAGES.CONFIG_TYPES_REFRESHED);\n } catch (error) {\n this.warn(configTypesRefreshFailed(getErrorMessage(error)));\n return;\n }\n\n this.reportPropagation(report);\n }\n\n /**\n * Renders the fan-out the refresh above performed. Kept out of the refresh's\n * catch on purpose: a project the fan-out could not reach is reported as that,\n * not as a failure to refresh the type unions — which did succeed.\n */\n private reportPropagation(report: GateReport): void {\n for (const skippedPath of report.propagated.skipped) {\n this.warn(registeredProjectUpdateSkipped(skippedPath));\n }\n this.reportPropagatedRecompile(report);\n }\n\n private async runCompilePass(params: CompilePass, cwd: string): Promise<boolean> {\n const { label, projectDir, installation, sourcePath, scopeFilter } = params;\n\n this.log(\"\");\n this.log(`Compiling ${label.toLowerCase()} agents...`);\n this.log(\"\");\n\n verbose(` Project: ${projectDir}`);\n verbose(` Agents: ${installation.agentsDir}`);\n\n // Before anything below reads the matrix — including the early return just\n // past skill discovery, which still calls refreshConfigTypes.\n const seatedMatrix = await this.seatMatrixForPass(projectDir);\n\n const { allSkills, totalSkillCount } = await this.discoverAllSkills(projectDir);\n\n if (totalSkillCount === 0) {\n this.log(`No skills found for ${label.toLowerCase()} pass, skipping`);\n // The config loads independently of discovered skills: a hand-edited\n // config.ts can list skills while nothing is installed for this scope,\n // and its type unions must follow the config rather than stay stale.\n await this.refreshConfigTypes(params, cwd, seatedMatrix);\n return false;\n }\n\n await this.warnUnresolvedStackSkills(projectDir, allSkills);\n await this.warnScopeDroppedStackPairs(projectDir);\n\n this.log(STATUS_MESSAGES.RECOMPILING_AGENTS);\n try {\n const recompileResult = await compileAgents({\n projectDir,\n sourcePath,\n skills: allSkills,\n pluginDir: projectDir,\n outputDir: installation.agentsDir,\n ...(scopeFilter !== undefined && { scopeFilter }),\n });\n\n const { compiled, rewritten, failed, warnings } = recompileResult;\n const summary = recompileSummary(\n rewritten.length,\n compiled.length - rewritten.length,\n `${label.toLowerCase()} agents`,\n );\n\n if (failed.length > 0) {\n this.log(`${summary} (${failed.length} failed)`);\n for (const warning of warnings) {\n this.warn(warning);\n }\n } else if (compiled.length > 0) {\n this.log(summary);\n } else {\n this.log(INFO_MESSAGES.NO_AGENTS_TO_RECOMPILE);\n if (label === \"Project\") {\n await this.hintGlobalScopedAgents(projectDir);\n }\n }\n\n if (compiled.length > 0) {\n verbose(` Compiled: ${compiled.join(\", \")}`);\n }\n } catch (error) {\n this.log(ERROR_MESSAGES.FAILED_COMPILE_AGENTS);\n this.handleError(error);\n }\n\n await this.refreshConfigTypes(params, cwd, seatedMatrix);\n\n this.log(\"\");\n this.logSuccess(`${label} compile complete!`);\n this.log(\"\");\n\n return true;\n }\n}\n\ntype CompilePass = {\n label: \"Global\" | \"Project\";\n projectDir: string;\n installation: Installation;\n sourcePath: string;\n agents: Partial<Record<AgentName, AgentDefinition>>;\n scopeFilter?: SkillScope;\n};\n\n/**\n * The single pass this invocation owns.\n *\n * A compile run inside a project is a PROJECT-scope operation and writes nothing\n * outside that project: it compiles the project's own agents and refreshes the\n * project's own type unions, and never the global install's or another\n * registered project's. Propagation is a global operation's consequence — the\n * global config is what every project's config inlines — and a project compile\n * is not one.\n *\n * The global pass is therefore reached only where no project installation is in\n * play: at the home directory (where `detectBothInstallations` returns no\n * project by construction), or in a directory that has no config of its own, so\n * the global install is the only thing there is to compile.\n *\n * `scopeFilter` still narrows the project pass whenever both installations\n * exist: the project's config inlines the global entries, so an unfiltered pass\n * would compile global-scoped agents into the project's own agents directory.\n */\nfunction buildCompilePasses(\n installations: BothInstallations,\n cwd: string,\n agentDefs: AgentDefs,\n): CompilePass[] {\n const { sourcePath, agents } = agentDefs;\n\n if (installations.project) {\n return [\n {\n label: \"Project\",\n projectDir: cwd,\n installation: installations.project,\n sourcePath,\n agents,\n ...(installations.hasBoth && { scopeFilter: \"project\" as const }),\n },\n ];\n }\n\n if (installations.global) {\n return [\n {\n label: \"Global\",\n projectDir: os.homedir(),\n installation: installations.global,\n sourcePath,\n agents,\n },\n ];\n }\n\n return [];\n}\n\n/**\n * Every project-scoped skill that a GLOBAL sub-agent's stack assigns to itself, with the\n * sub-agents that assign it — exactly the pairs `buildCompileAgents`' scope filter drops on\n * the way to the resolver.\n *\n * Grouped by skill rather than emitted per pair, so one sentence accounts for every\n * sub-agent one skill was kept away from.\n */\nfunction findScopeDroppedStackPairs(config: ProjectConfig): [SkillId, AgentName[]][] {\n const stack = config.stack ?? {};\n const globalAgentNames = config.agents\n .filter((agent) => isActiveAt(agent, \"global\"))\n .map((agent) => agent.name);\n const projectScopedIds = unique(\n config.skills.filter((skill) => isActiveAt(skill, \"project\")).map((skill) => skill.id),\n );\n\n return projectScopedIds\n .map((skillId): [SkillId, AgentName[]] => [\n skillId,\n globalAgentNames.filter((agentName) => stackAssignsSkill(stack[agentName], skillId)),\n ])\n .filter(([, agentNames]) => agentNames.length > 0);\n}\n\n/** True when this sub-agent's stack names the skill, in any of its categories. */\nfunction stackAssignsSkill(agentStack: StackAgentConfig | undefined, skillId: SkillId): boolean {\n if (!agentStack) return false;\n return resolveAgentConfigToSkills(agentStack).some((ref) => ref.id === skillId);\n}\n\nfunction formatDiscoveryMessage(result: DiscoveredSkills): string {\n const { totalSkillCount, pluginSkillCount } = result;\n const localCount = totalSkillCount - pluginSkillCount;\n\n if (pluginSkillCount > 0 && localCount > 0) {\n return `Discovered ${totalSkillCount} skills (${pluginSkillCount} from plugins, ${localCount} local)`;\n }\n\n return pluginSkillCount > 0\n ? `Discovered ${pluginSkillCount} skills from plugins`\n : `Discovered ${totalSkillCount} local skills`;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,SAAS,aAAa;AACtB,OAAO,QAAQ;AACf,SAAS,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O,SAAS,CAAC,EAAE,IAAI,CAAC,UAAU,MAAM,EAAE;AAAA,EACvF;AAEA,SAAO,iBACJ,IAAI,CAAC,YAAoC;AAAA,IACxC;AAAA,IACA,iBAAiB,OAAO,CAAC,cAAc,kBAAkB,MAAM,SAAS,GAAG,OAAO,CAAC;AAAA,EACrF,CAAC,EACA,OAAO,CAAC,CAAC,EAAE,UAAU,MAAM,WAAW,SAAS,CAAC;AACrD;AAGA,SAAS,kBAAkB,YAA0C,SAA2B;AAC9F,MAAI,CAAC,WAAY,QAAO;AACxB,SAAO,2BAA2B,UAAU,EAAE,KAAK,CAAC,QAAQ,IAAI,OAAO,OAAO;AAChF;AAEA,SAAS,uBAAuB,QAAkC;AAChE,QAAM,EAAE,iBAAiB,iBAAiB,IAAI;AAC9C,QAAM,aAAa,kBAAkB;AAErC,MAAI,mBAAmB,KAAK,aAAa,GAAG;AAC1C,WAAO,cAAc,eAAe,YAAY,gBAAgB,kBAAkB,UAAU;AAAA,EAC9F;AAEA,SAAO,mBAAmB,IACtB,cAAc,gBAAgB,yBAC9B,cAAc,eAAe;AACnC;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../src/cli/commands/compile.ts"],"sourcesContent":["import { Flags } from \"@oclif/core\";\nimport os from \"os\";\nimport { unique } from \"remeda\";\nimport { BaseCommand } from \"../base-command\";\nimport { setVerbose, verbose } from \"../utils/logger\";\nimport {\n detectBothInstallations,\n type BothInstallations,\n loadAgentDefs,\n type AgentDefs,\n compileAgents,\n discoverInstalledSkills,\n type DiscoveredSkills,\n} from \"../lib/operations\";\nimport {\n ConfigLoadError,\n effectivelyExcludedSkillIds,\n isActiveAt,\n loadProjectConfig,\n loadInstalledConfig,\n resolveSource,\n} from \"../lib/configuration\";\nimport { getStackSkillIds, resolveAgentConfigToSkills } from \"../lib/stacks\";\nimport { loadSkillsMatrixFromSource, type UnusableSkillMetadata } from \"../lib/loading\";\nimport { STANDARD_FILES } from \"../consts\";\nimport { EXIT_CODES } from \"../lib/exit-codes\";\nimport { getErrorMessage } from \"../utils/errors\";\nimport { plural } from \"../utils/string\";\nimport {\n ERROR_MESSAGES,\n STATUS_MESSAGES,\n INFO_MESSAGES,\n configTypesRefreshFailed,\n globalScopedAgentsHint,\n recompileSummary,\n registeredProjectUpdateFailed,\n scopeBlockedStackAssignment,\n skillMetadataUnusableDetail,\n skillMetadataUnusableError,\n} from \"../utils/messages\";\nimport { reconcileTypesFromDisk, type GateReport } from \"../lib/config-gate/index.js\";\nimport { unofferablePlacementsFound } from \"../lib/hosts/configured-placements.js\";\nimport { providerInUse } from \"../lib/installation/install-layout.js\";\nimport {\n providerFlag,\n providerNamedBy,\n refuseAnAmbiguousInstallation,\n} from \"../lib/installation/provider-flag.js\";\nimport { hostCompileNotices } from \"../lib/hosts/host-compile-notices.js\";\nimport type { Installation } from \"../lib/installation\";\nimport type { SkillScope } from \"../types/config\";\nimport type {\n AgentDefinition,\n AgentName,\n MergedSkillsMatrix,\n ProjectConfig,\n SkillDefinitionMap,\n SkillId,\n StackAgentConfig,\n} from \"../types\";\n\nexport default class Compile extends BaseCommand {\n static summary = \"Compile agents using local skills and agent definitions\";\n\n static description =\n \"Compile agents with resolved skill references. Compiles to the Claude plugin directory.\";\n\n static examples = [\n \"<%= config.bin %> <%= command.id %>\",\n \"<%= config.bin %> <%= command.id %> --verbose\",\n ];\n\n static flags = {\n verbose: Flags.boolean({\n char: \"v\",\n description: \"Enable verbose logging\",\n default: false,\n }),\n provider: providerFlag(),\n };\n\n async run(): Promise<void> {\n const { flags } = await this.parse(Compile);\n setVerbose(flags.verbose);\n const cwd = process.cwd();\n\n // First, and before anything reads a folder: every path below resolves its provider through\n // `providerInUse`, which answers by ROSTER ORDER when a scope holds one installation of each —\n // so a compile with no flag rewrote the Claude one of a project that also has a Codex one, and\n // said nothing anywhere about which it had been about. `edit`, `uninstall`, `share` and\n // `eject` have refused this since C7b and `doctor` reports it as a finding; these two were the\n // hole, and they are the two that WRITE.\n await refuseAnAmbiguousInstallation(\n cwd,\n \"compile\",\n providerNamedBy(flags.provider),\n (message) => this.error(message, { exit: EXIT_CODES.INVALID_ARGS }),\n );\n await this.ensureConfigReadable(cwd);\n const installations = await this.detectInstallations(cwd);\n await this.refuseUnofferablePlacements(cwd);\n await this.resolveAndLogSource(cwd);\n const agentDefs = await this.loadAgentDefsOrFail();\n await this.runCompilePasses(installations, agentDefs, cwd);\n await this.reportWhatThisHostCannotCarry(installations, cwd);\n }\n\n /**\n * What this host could not carry, once per run and after the passes.\n *\n * AFTER, because the trust half of it is a question about the tree as it now stands: a project\n * whose role files this run just wrote is exactly the one whose user has to trust it, and asking\n * before the write would answer about the previous state.\n *\n * `init` prints the same lines in the same order — {@link hostCompileNotices} is the one place\n * either of them gets them from, so the two commands cannot drift into saying different things\n * about one tree.\n */\n private async reportWhatThisHostCannotCarry(\n installations: BothInstallations,\n cwd: string,\n ): Promise<void> {\n const root = rootThisRunCompiled(installations, cwd);\n\n for (const notice of await hostCompileNotices(providerInUse(root), cwd)) {\n this.log(notice);\n }\n }\n\n private async detectInstallations(cwd: string): Promise<BothInstallations> {\n let installations: BothInstallations;\n try {\n installations = await detectBothInstallations(cwd);\n } catch (error) {\n // A corrupt config (file present but unparseable) must not let compile run\n // config-less — that resurrects every deselected agent. Hard-error naming\n // the offending file before any compilation happens.\n if (error instanceof ConfigLoadError) {\n this.error(error.message, { exit: EXIT_CODES.ERROR });\n }\n throw error;\n }\n\n if (!installations.global && !installations.project) {\n this.error(ERROR_MESSAGES.NO_INSTALLATION, {\n exit: EXIT_CODES.ERROR,\n });\n }\n\n return installations;\n }\n\n /**\n * Refuses a configuration asking for a mode/scope cell its own host does not offer, BEFORE\n * anything is discovered, compiled or written.\n *\n * **The install path's pre-flight cannot cover this, and nothing ties a folder's contents to\n * its name.** `config.ts` carries no provider field — the ruling forbids one, so that a saved\n * configuration installs onto either provider — which means a user who copies\n * `.agents-inc/claude/` to `.agents-inc/codex/` has a Codex installation holding a\n * configuration that never met `init --from --provider codex`'s refusal. This is the command\n * that turns a configuration into files on disk, so it is the one that has to ask again.\n *\n * Both scopes, because a project inherits its global's rows and an unofferable row in either\n * file is a row this run would act on. Each installation is asked about its OWN host: the two\n * scopes can be on different providers, and asking one host about the other's configuration is\n * how a refusal fires on a cell that is offered where the skill actually lives.\n */\n private async refuseUnofferablePlacements(cwd: string): Promise<void> {\n const [finding] = await unofferablePlacementsFound(cwd);\n if (finding !== undefined) this.error(finding, { exit: EXIT_CODES.ERROR });\n }\n\n /**\n * Names where the marketplace came from — the project's own config first, then the global\n * one, then the default. `compile` takes no `--marketplace`: it recompiles an installation\n * that already recorded which marketplace its skill references answer to, and reading\n * a different one would write agents against a catalogue config.ts does not name.\n */\n private async resolveAndLogSource(projectDir: string): Promise<void> {\n this.log(STATUS_MESSAGES.RESOLVING_SOURCE);\n try {\n // ABORT on an unreadable config, and unreachable with one: `detectInstallation` reads the\n // same file first and already hard-errors, at both scopes — verified by hand at both.\n // The posture is recorded anyway, because what makes it unreachable is a guard in another\n // command's private helper rather than anything visible from here.\n const sourceConfig = await resolveSource({ caller: \"stored\", projectDir });\n this.log(`Marketplace: ${sourceConfig.sourceOrigin}`);\n } catch (error) {\n this.log(ERROR_MESSAGES.FAILED_RESOLVE_SOURCE);\n this.handleError(error);\n }\n }\n\n private async loadAgentDefsOrFail(): Promise<AgentDefs> {\n this.log(STATUS_MESSAGES.LOADING_AGENT_PARTIALS);\n try {\n const defs = await loadAgentDefs();\n this.log(\"Agent partials loaded\");\n verbose(` Agents: ${defs.agentSourcePaths.agentsDir}`);\n return defs;\n } catch (error) {\n this.log(ERROR_MESSAGES.FAILED_LOAD_AGENT_PARTIALS);\n this.handleError(error);\n }\n }\n\n private async runCompilePasses(\n installations: BothInstallations,\n agentDefs: AgentDefs,\n cwd: string,\n ): Promise<void> {\n const passes = buildCompilePasses(installations, cwd, agentDefs);\n\n let passesCompiled = 0;\n for (const pass of passes) {\n const compiled = await this.runCompilePass(pass, cwd);\n if (compiled) passesCompiled++;\n }\n\n if (passesCompiled === 0) {\n this.error(ERROR_MESSAGES.NO_SKILLS_TO_COMPILE, { exit: EXIT_CODES.ERROR });\n }\n }\n\n /**\n * Discovers what this pass compiles from, and refuses the run when any installed\n * skill's metadata.yaml exists but describes no skill — before a count is printed,\n * an agent is written or the type unions are regenerated. Skipping such a skill is\n * what the config-types pass already does; loading it anyway is what this pass\n * used to do, so a single run both loaded and skipped the same file.\n */\n private async discoverAllSkills(projectDir: string): Promise<DiscoveredSkills> {\n this.log(STATUS_MESSAGES.DISCOVERING_SKILLS);\n const result = await discoverInstalledSkills(projectDir);\n if (result.unusableMetadata.length > 0) {\n this.refuseUnusableSkillMetadata(result.unusableMetadata);\n }\n if (result.totalSkillCount === 0) return result;\n this.log(formatDiscoveryMessage(result));\n return result;\n }\n\n /**\n * Names each offending file and its reason, then exits. The detail is LOGGED and\n * only the refusal is raised: oclif hard-wraps error text at the terminal width,\n * and a path broken across two lines is one nobody can copy.\n */\n private refuseUnusableSkillMetadata(entries: UnusableSkillMetadata[]): never {\n for (const entry of entries) {\n this.log(skillMetadataUnusableDetail(entry));\n }\n this.error(skillMetadataUnusableError(entries), { exit: EXIT_CODES.ERROR });\n }\n\n /**\n * A stack skill that is not among the discovered skills is dropped from every\n * agent that references it. The resolver only records that at verbose level, so\n * the default output would claim a successful recompile of an agent that no\n * longer matches config.ts. Name each dropped skill instead.\n */\n private async warnUnresolvedStackSkills(\n projectDir: string,\n allSkills: SkillDefinitionMap,\n ): Promise<void> {\n const loaded = await loadProjectConfig(projectDir);\n if (!loaded?.config.stack) return;\n\n const excludedIds = effectivelyExcludedSkillIds(loaded.config.skills);\n const unresolved = getStackSkillIds(loaded.config.stack).filter(\n (id) => !excludedIds.has(id) && !(id in allSkills),\n );\n\n for (const id of unresolved) {\n this.warn(\n `Skill '${id}' is configured but was not found — agents will be compiled without it.`,\n );\n }\n }\n\n /**\n * `config.ts` is the hand-editable half of the pair, so it can declare a pair the scope\n * rule forbids: a GLOBAL sub-agent whose stack carries a PROJECT-scoped skill. The\n * compile-time filter in `buildCompileAgents` drops that reference on the way to the\n * resolver and `compile` rewrites nothing in `config.ts`, so the row survives and is\n * dropped again on every future run — while the recompile summary reports a clean pass\n * over an agent that no longer carries what its own config says it does.\n *\n * The sibling of {@link warnUnresolvedStackSkills} one layer over: there the skill is\n * missing from disk, here it is present and unreachable from that sub-agent.\n */\n private async warnScopeDroppedStackPairs(projectDir: string): Promise<void> {\n const loaded = await loadProjectConfig(projectDir);\n if (!loaded?.config.stack) return;\n\n for (const [skillId, agentNames] of findScopeDroppedStackPairs(loaded.config)) {\n this.warn(scopeBlockedStackAssignment(agentNames, skillId));\n }\n }\n\n /**\n * The project pass compiled no agents, but the project config may still declare\n * global-scope agents whose stack lives in the global config. Without a pointer\n * the \"No agents to recompile\" line reads as a silent no-op after a global stack\n * change, so name the global context and the count.\n */\n private async hintGlobalScopedAgents(projectDir: string): Promise<void> {\n const loaded = await loadInstalledConfig(projectDir);\n if (!loaded) return;\n\n const globalAgentCount = loaded.config.agents.filter(\n (agent) => !agent.excluded && agent.scope === \"global\",\n ).length;\n if (globalAgentCount === 0) return;\n\n this.log(globalScopedAgentsHint(globalAgentCount));\n }\n\n /**\n * Loads this pass's skills catalogue and returns it, seating the module-level\n * singleton (`matrix` in `matrix-provider.ts`) on the way — which is what the\n * RENDER needs, because `compileAgents` reaches the catalogue through\n * `stacks-loader.ts`'s `statedUsageFor`/`liveCategoryOf` and those read the\n * singleton directly rather than any value a caller threads through. Called\n * first, before anything in the pass renders. Left unseated, the singleton stays\n * at its process-start default (`BUILT_IN_MATRIX`, which never carries a local\n * skill), so a locally-installed skill's stated `usageGuidance` silently falls\n * back to the generic per-category placeholder — different bytes from what\n * `install` last wrote, so a following `compile` rewrites every agent that\n * carries one.\n *\n * Scoped to `pass.projectDir`, never the invoking `cwd`: a global pass must seat\n * the global installation's own local skills, not the invoking directory's.\n *\n * `skipExtraSources: true` is NOT a divergence from the wizard's full\n * multi-source load: extra-source loading only annotates each skill's\n * `availableSources`/`activeSource` for wizard UI tagging — it never adds skills\n * or categories to the matrix, and neither the render path nor the config-types\n * writer ever reads those annotations, so the emitted output is byte-identical\n * either way (pinned by the skipExtraSources parity test in\n * local-installer.test.ts). Skipping avoids fetching every registered extra\n * source (network on a cold cache, plus unreachable-remote warnings) on this\n * offline compile path. `matrixOnly` keeps the default-source path itself\n * offline too.\n *\n * The seated matrix is RETURNED as well as seated, and `null` on a failure, so\n * the two halves can take the postures they each need. The RENDER degrades: it\n * reads the singleton whatever happens, and falls back to the same\n * category-placeholder behavior compile had before this seat existed. The type\n * refresh ABORTS on `null` — it derives every union from the catalogue, so with\n * none loaded it would narrow them to whatever the built-in catalogue happens\n * to carry, dropping every marketplace-only and local category and, at global\n * scope, propagating that into every registered project.\n */\n private async seatMatrixForPass(projectDir: string): Promise<MergedSkillsMatrix | null> {\n try {\n const { matrix: seated } = await loadSkillsMatrixFromSource({\n projectDir,\n skipExtraSources: true,\n matrixOnly: true,\n });\n return seated;\n } catch (error) {\n this.warn(`Failed to load skills matrix for ${projectDir}: ${getErrorMessage(error)}`);\n return null;\n }\n }\n\n /**\n * The documented hand-edit workflow is \"edit config.ts, then run compile\", and\n * the type unions in config-types.ts are derived from config.ts — so a compile\n * pass that leaves them untouched strands stale unions after a hand-edit.\n * Regenerates them from the scope's persisted config exactly as the wizard\n * write path would: standalone narrowed unions at global scope, import-and-\n * extend at project scope. A failed refresh downgrades to a warning — the\n * compiled agents are already written and remain valid; only the type unions\n * may still be stale.\n *\n * Takes the catalogue {@link seatMatrixForPass} returned rather than reading the\n * singleton it seated, so this refresh cannot run against a seat that is not the\n * one this pass asked for. `null` means the seat failed, and the refresh is\n * skipped whole: every union here is DERIVED from the catalogue, so writing them\n * without one is not a degraded answer but a wrong one — the unions narrow to\n * the built-in catalogue's own categories, and `config.ts` beside them still\n * keys its `stack` under the ones that just vanished, so the pair stops\n * type-checking. Skipping falls under the same warning as any other failed\n * refresh, for the same reason.\n */\n private async refreshConfigTypes(\n pass: CompilePass,\n cwd: string,\n seatedMatrix: MergedSkillsMatrix | null,\n ): Promise<void> {\n if (!seatedMatrix) {\n this.warn(\n configTypesRefreshFailed(`no skills catalogue could be loaded for ${pass.projectDir}`),\n );\n return;\n }\n\n let report: GateReport;\n try {\n const loaded = await loadInstalledConfig(pass.projectDir);\n if (!loaded) {\n verbose(\n `No config found at ${pass.projectDir} — skipping ${STANDARD_FILES.CONFIG_TYPES_TS} refresh`,\n );\n return;\n }\n\n // `cwd` is excluded from the fan-out, which only a global pass can perform:\n // whatever this invocation was run from is this command's own subject, so a\n // fan-out must never reach back into it.\n report = await reconcileTypesFromDisk(\n pass.projectDir,\n loaded.config,\n { matrix: seatedMatrix, agents: pass.agents },\n { currentProjectDir: cwd },\n );\n this.log(INFO_MESSAGES.CONFIG_TYPES_REFRESHED);\n } catch (error) {\n this.warn(configTypesRefreshFailed(getErrorMessage(error)));\n return;\n }\n\n this.reportPropagation(report);\n }\n\n /**\n * Renders the fan-out the refresh above performed. Kept out of the refresh's\n * catch on purpose: a project the fan-out could not reach is reported as that,\n * not as a failure to refresh the type unions — which did succeed.\n */\n private reportPropagation(report: GateReport): void {\n this.reportProjectsOutOfReach(report.propagated);\n for (const projectPath of report.propagated.failed) {\n this.warn(registeredProjectUpdateFailed(projectPath));\n }\n this.reportFanOut(report);\n }\n\n /** Runs one pass, and answers whether it compiled rather than skipping for want of anything to. */\n private async runCompilePass(params: CompilePass, cwd: string): Promise<boolean> {\n const { label, projectDir, installation, sourcePath, scopeFilter } = params;\n\n this.log(\"\");\n this.log(`Compiling ${label.toLowerCase()} agents...`);\n this.log(\"\");\n\n verbose(` Project: ${projectDir}`);\n verbose(` Agents: ${installation.agentsDir}`);\n\n // Before anything below reads the matrix.\n const seatedMatrix = await this.seatMatrixForPass(projectDir);\n\n const { allSkills, totalSkillCount } = await this.discoverAllSkills(projectDir);\n const compilesBaseAgents = totalSkillCount === 0 && (await declaresOnlyBaseAgents(params));\n\n if (compilesBaseAgents) {\n this.log(`No skills configured for ${label.toLowerCase()} pass, compiling base agents`);\n } else if (totalSkillCount === 0) {\n // A run is one pass, so a skipped pass is a refused run — and a refused run writes nothing,\n // config-types.ts included (owner ruling).\n this.log(`No skills found for ${label.toLowerCase()} pass, skipping`);\n return false;\n }\n\n await this.warnUnresolvedStackSkills(projectDir, allSkills);\n await this.warnScopeDroppedStackPairs(projectDir);\n\n this.log(STATUS_MESSAGES.RECOMPILING_AGENTS);\n try {\n const recompileResult = await compileAgents({\n projectDir,\n sourcePath,\n skills: allSkills,\n pluginDir: projectDir,\n outputDir: installation.agentsDir,\n ...(scopeFilter !== undefined && { scopeFilter }),\n });\n\n const { compiled, rewritten, failed, warnings } = recompileResult;\n const summary = recompileSummary(\n rewritten.length,\n compiled.length - rewritten.length,\n `${label.toLowerCase()} agent`,\n );\n\n if (failed.length > 0) {\n this.log(`${summary} (${failed.length} failed)`);\n for (const warning of warnings) {\n this.warn(warning);\n }\n } else if (compiled.length > 0) {\n this.log(summary);\n } else {\n this.log(INFO_MESSAGES.NO_AGENTS_TO_RECOMPILE);\n if (label === \"Project\") {\n await this.hintGlobalScopedAgents(projectDir);\n }\n }\n\n if (compiled.length > 0) {\n verbose(` Compiled: ${compiled.join(\", \")}`);\n }\n } catch (error) {\n this.log(ERROR_MESSAGES.FAILED_COMPILE_AGENTS);\n this.handleError(error);\n }\n\n await this.refreshConfigTypes(params, cwd, seatedMatrix);\n\n this.log(\"\");\n this.logSuccess(`${label} compile complete!`);\n this.log(\"\");\n\n return true;\n }\n}\n\ntype CompilePass = {\n label: \"Global\" | \"Project\";\n projectDir: string;\n installation: Installation;\n sourcePath: string;\n agents: Partial<Record<AgentName, AgentDefinition>>;\n scopeFilter?: SkillScope;\n};\n\n/**\n * The single pass this invocation owns.\n *\n * A compile run inside a project is a PROJECT-scope operation and writes nothing\n * outside that project: it compiles the project's own agents and refreshes the\n * project's own type unions, and never the global install's or another\n * registered project's. Propagation is a global operation's consequence — the\n * global config is what every project's config inlines — and a project compile\n * is not one.\n *\n * The global pass is therefore reached only where no project installation is in\n * play: at the home directory (where `detectBothInstallations` returns no\n * project by construction), or in a directory that has no config of its own, so\n * the global install is the only thing there is to compile.\n *\n * `scopeFilter` still narrows the project pass whenever both installations\n * exist: the project's config inlines the global entries, so an unfiltered pass\n * would compile global-scoped agents into the project's own agents directory.\n */\nfunction buildCompilePasses(\n installations: BothInstallations,\n cwd: string,\n agentDefs: AgentDefs,\n): CompilePass[] {\n const { sourcePath, agents } = agentDefs;\n\n if (installations.project) {\n return [\n {\n label: \"Project\",\n projectDir: cwd,\n installation: installations.project,\n sourcePath,\n agents,\n ...(installations.hasBoth && { scopeFilter: \"project\" as const }),\n },\n ];\n }\n\n if (installations.global) {\n return [\n {\n label: \"Global\",\n projectDir: os.homedir(),\n installation: installations.global,\n sourcePath,\n agents,\n },\n ];\n }\n\n return [];\n}\n\n/**\n * The install root this run compiled, which the reports after the passes read the provider off.\n *\n * The root {@link buildCompilePasses} picks, read the same way it picks it: a project installation\n * is this run's subject and the global one is what a directory with none is about. Asking `cwd`\n * alone would answer Claude for a project that has no installation of its own under a Codex\n * global.\n */\nfunction rootThisRunCompiled(installations: BothInstallations, cwd: string): string {\n return installations.project ? cwd : os.homedir();\n}\n\n/**\n * Whether a pass that discovered no skill still has something to compile: sub-agents its config\n * pins on with no skill at all, which the editor produces (\"no skills — base agent\") and `init`\n * compiles like any other roster — `compileAgentsAllScopes` asks nothing about skills. The roster\n * is read the way `compileAgents` reads it: active rows, narrowed to the pass's scope when it has\n * one.\n *\n * A config that DECLARES a skill, none of which is on disk, is not this. It is an installation\n * whose skills were lost, and compiling it would rewrite every sub-agent without them — so that\n * pass is still skipped and, with no other pass compiling, still refused.\n */\nasync function declaresOnlyBaseAgents(pass: CompilePass): Promise<boolean> {\n const loaded = await loadInstalledConfig(pass.projectDir);\n if (!loaded) return false;\n\n const { skills, agents } = loaded.config;\n const declaresASkill = skills.some((skill) => !skill.excluded);\n const compilesAnAgent = agents.some((agent) =>\n pass.scopeFilter === undefined ? !agent.excluded : isActiveAt(agent, pass.scopeFilter),\n );\n return !declaresASkill && compilesAnAgent;\n}\n\n/**\n * Every project-scoped skill that a GLOBAL sub-agent's stack assigns to itself, with the\n * sub-agents that assign it — exactly the pairs `buildCompileAgents`' scope filter drops on\n * the way to the resolver.\n *\n * Grouped by skill rather than emitted per pair, so one sentence accounts for every\n * sub-agent one skill was kept away from.\n */\nfunction findScopeDroppedStackPairs(config: ProjectConfig): [SkillId, AgentName[]][] {\n const stack = config.stack ?? {};\n const globalAgentNames = config.agents\n .filter((agent) => isActiveAt(agent, \"global\"))\n .map((agent) => agent.name);\n const projectScopedIds = unique(\n config.skills.filter((skill) => isActiveAt(skill, \"project\")).map((skill) => skill.id),\n );\n\n return projectScopedIds\n .map((skillId): [SkillId, AgentName[]] => [\n skillId,\n globalAgentNames.filter((agentName) => stackAssignsSkill(stack[agentName], skillId)),\n ])\n .filter(([, agentNames]) => agentNames.length > 0);\n}\n\n/** True when this sub-agent's stack names the skill, in any of its categories. */\nfunction stackAssignsSkill(agentStack: StackAgentConfig | undefined, skillId: SkillId): boolean {\n if (!agentStack) return false;\n return resolveAgentConfigToSkills(agentStack).some((ref) => ref.id === skillId);\n}\n\nfunction formatDiscoveryMessage(result: DiscoveredSkills): string {\n const { totalSkillCount, pluginSkillCount } = result;\n const localCount = totalSkillCount - pluginSkillCount;\n\n if (pluginSkillCount > 0 && localCount > 0) {\n return `Discovered ${plural(totalSkillCount, \"skill\")} (${pluginSkillCount} from plugins, ${localCount} local)`;\n }\n\n return pluginSkillCount > 0\n ? `Discovered ${plural(pluginSkillCount, \"skill\")} from plugins`\n : `Discovered ${plural(totalSkillCount, \"local skill\")}`;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,SAAS,aAAa;AACtB,OAAO,QAAQ;AACf,SAAS,cAAc;AA2DvB,IAAqB,U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