agents-inc 0.166.0 → 0.168.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 +18 -0
- package/dist/{chunk-TZ2YJJKK.js → chunk-23DNVNFP.js} +5 -5
- package/dist/{chunk-ZXKBERQU.js → chunk-27AVGFXH.js} +2 -2
- package/dist/{chunk-SXVHSOTH.js → chunk-3DIDV6H3.js} +4 -4
- package/dist/{chunk-GE3WKJ6Q.js → chunk-3LZNY46H.js} +4 -4
- package/dist/{chunk-Y47EV74W.js → chunk-4DRFEYCE.js} +10 -13
- package/dist/chunk-4DRFEYCE.js.map +1 -0
- package/dist/{chunk-MPTNC32T.js → chunk-4HWOYYY7.js} +3 -3
- package/dist/{chunk-MAWNVT2C.js → chunk-4UKMQUAU.js} +4 -4
- package/dist/{chunk-G6UREQ4V.js → chunk-5JUQKGCP.js} +9 -9
- package/dist/{chunk-T6UWJAB3.js → chunk-6WGXTB2L.js} +2 -2
- package/dist/{chunk-SAYZWCH6.js → chunk-7PYXS2QU.js} +2 -2
- package/dist/{chunk-ENGYJCTF.js → chunk-AG3ZVM3B.js} +35 -45
- package/dist/{chunk-ENGYJCTF.js.map → chunk-AG3ZVM3B.js.map} +1 -1
- package/dist/{chunk-A4KDXNOT.js → chunk-C2UISKIM.js} +66 -104
- package/dist/chunk-C2UISKIM.js.map +1 -0
- package/dist/{chunk-RZDXDMT6.js → chunk-CMJBKQUH.js} +2 -2
- package/dist/{chunk-XZEVWPX6.js → chunk-DJEO3F2H.js} +7 -7
- package/dist/{chunk-V3I7VQ7N.js → chunk-EH2PGPLP.js} +5 -5
- package/dist/chunk-EH2PGPLP.js.map +1 -0
- package/dist/{chunk-PMJWD27C.js → chunk-GE7NUPMI.js} +3 -3
- package/dist/{chunk-PNB3524H.js → chunk-GRL73YPF.js} +5 -5
- package/dist/{chunk-Y3VIRVVE.js → chunk-H4ZKGGTE.js} +6 -6
- package/dist/{chunk-LFWLEDUG.js → chunk-HI6YB7XP.js} +6 -6
- package/dist/{chunk-SCOQ34YM.js → chunk-HL3GYRMR.js} +2 -2
- package/dist/{chunk-NBXXFIIW.js → chunk-HR7TK2XW.js} +3 -3
- package/dist/{chunk-ZR4YPKXQ.js → chunk-JIBCVXXL.js} +4 -4
- package/dist/{chunk-JQRJQ4SS.js → chunk-JPMV4E4E.js} +3 -3
- package/dist/{chunk-4NDBUJHK.js → chunk-JVUN6AOO.js} +8 -8
- package/dist/{chunk-RAHSOJQ2.js → chunk-KQ3PDARZ.js} +2 -2
- package/dist/{chunk-PXWG7KFO.js → chunk-KTLKR4YY.js} +2 -2
- package/dist/{chunk-6L75SQZU.js → chunk-L3W2JWBA.js} +2 -2
- package/dist/{chunk-TTY6DPJN.js → chunk-LFUJCRCT.js} +3 -3
- package/dist/{chunk-V5WXIM2F.js → chunk-NU2K5G54.js} +2 -2
- package/dist/{chunk-G4JK7WVO.js → chunk-P6I72PR3.js} +15 -15
- package/dist/{chunk-WWIFNPJG.js → chunk-PCFUXQJA.js} +12 -12
- package/dist/{chunk-DAIEQJIF.js → chunk-PLX2FLEQ.js} +3 -3
- package/dist/{chunk-2VUYFTUB.js → chunk-QWFG7Y3R.js} +6 -6
- package/dist/{chunk-WVUDLKIO.js → chunk-SLBL3WIP.js} +2 -2
- package/dist/{chunk-HWEKHVLE.js → chunk-TW35AEB4.js} +6 -6
- package/dist/{chunk-VAPTVR3J.js → chunk-VVRI35SK.js} +3 -3
- package/dist/{chunk-6LF4CQBY.js → chunk-W5KEYSOL.js} +2 -2
- package/dist/{chunk-TODCQFRB.js → chunk-W6GO2CYX.js} +2 -2
- package/dist/{chunk-7JNJ52CD.js → chunk-WNLF5EDZ.js} +7 -16
- package/dist/chunk-WNLF5EDZ.js.map +1 -0
- package/dist/{chunk-HHIYT3PI.js → chunk-X6ZZEYO3.js} +4 -4
- package/dist/{chunk-QHDPLLK6.js → chunk-YN3SWF53.js} +3 -3
- package/dist/{chunk-25MPBIK3.js → chunk-ZUGH4MQG.js} +3 -3
- package/dist/commands/build/marketplace.js +6 -6
- package/dist/commands/build/plugins.js +8 -8
- package/dist/commands/compile.js +14 -14
- package/dist/commands/doctor.js +13 -13
- package/dist/commands/edit.js +71 -242
- package/dist/commands/edit.js.map +1 -1
- package/dist/commands/eject.js +12 -12
- package/dist/commands/init.js +39 -39
- package/dist/commands/list.js +9 -9
- package/dist/commands/new/marketplace.js +6 -6
- package/dist/commands/search.js +11 -11
- package/dist/commands/share.js +11 -11
- package/dist/commands/uninstall.js +13 -13
- package/dist/commands/update.js +8 -8
- package/dist/components/common/removal-plan-confirm.js +2 -2
- package/dist/components/common/select-list.js +2 -2
- package/dist/components/wizard/category-grid.js +4 -4
- 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 +26 -26
- 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 +5 -5
- package/dist/components/wizard/stack-selection.js +7 -7
- package/dist/components/wizard/step-agents.js +8 -8
- package/dist/components/wizard/step-build.js +7 -7
- package/dist/components/wizard/step-confirm.js +9 -9
- package/dist/components/wizard/step-sources.js +8 -8
- package/dist/components/wizard/step-stack.js +8 -8
- 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 +25 -25
- package/dist/hooks/init.js +39 -39
- package/dist/load-agent-defs-5XMVB3MU.js +14 -0
- package/dist/recompile-project-agents-7PQWYQ6B.js +18 -0
- package/dist/{source-loader-7KZ3MD5O.js → source-loader-FRJTCSDL.js} +4 -4
- package/dist/stores/wizard-store.js +4 -4
- package/package.json +5 -2
- package/dist/chunk-7JNJ52CD.js.map +0 -1
- package/dist/chunk-A4KDXNOT.js.map +0 -1
- package/dist/chunk-V3I7VQ7N.js.map +0 -1
- package/dist/chunk-Y47EV74W.js.map +0 -1
- package/dist/load-agent-defs-3C27ENC7.js +0 -14
- package/dist/recompile-project-agents-DGNBCU3N.js +0 -18
- /package/dist/{chunk-TZ2YJJKK.js.map → chunk-23DNVNFP.js.map} +0 -0
- /package/dist/{chunk-ZXKBERQU.js.map → chunk-27AVGFXH.js.map} +0 -0
- /package/dist/{chunk-SXVHSOTH.js.map → chunk-3DIDV6H3.js.map} +0 -0
- /package/dist/{chunk-GE3WKJ6Q.js.map → chunk-3LZNY46H.js.map} +0 -0
- /package/dist/{chunk-MPTNC32T.js.map → chunk-4HWOYYY7.js.map} +0 -0
- /package/dist/{chunk-MAWNVT2C.js.map → chunk-4UKMQUAU.js.map} +0 -0
- /package/dist/{chunk-G6UREQ4V.js.map → chunk-5JUQKGCP.js.map} +0 -0
- /package/dist/{chunk-T6UWJAB3.js.map → chunk-6WGXTB2L.js.map} +0 -0
- /package/dist/{chunk-SAYZWCH6.js.map → chunk-7PYXS2QU.js.map} +0 -0
- /package/dist/{chunk-RZDXDMT6.js.map → chunk-CMJBKQUH.js.map} +0 -0
- /package/dist/{chunk-XZEVWPX6.js.map → chunk-DJEO3F2H.js.map} +0 -0
- /package/dist/{chunk-PMJWD27C.js.map → chunk-GE7NUPMI.js.map} +0 -0
- /package/dist/{chunk-PNB3524H.js.map → chunk-GRL73YPF.js.map} +0 -0
- /package/dist/{chunk-Y3VIRVVE.js.map → chunk-H4ZKGGTE.js.map} +0 -0
- /package/dist/{chunk-LFWLEDUG.js.map → chunk-HI6YB7XP.js.map} +0 -0
- /package/dist/{chunk-SCOQ34YM.js.map → chunk-HL3GYRMR.js.map} +0 -0
- /package/dist/{chunk-NBXXFIIW.js.map → chunk-HR7TK2XW.js.map} +0 -0
- /package/dist/{chunk-ZR4YPKXQ.js.map → chunk-JIBCVXXL.js.map} +0 -0
- /package/dist/{chunk-JQRJQ4SS.js.map → chunk-JPMV4E4E.js.map} +0 -0
- /package/dist/{chunk-4NDBUJHK.js.map → chunk-JVUN6AOO.js.map} +0 -0
- /package/dist/{chunk-RAHSOJQ2.js.map → chunk-KQ3PDARZ.js.map} +0 -0
- /package/dist/{chunk-PXWG7KFO.js.map → chunk-KTLKR4YY.js.map} +0 -0
- /package/dist/{chunk-6L75SQZU.js.map → chunk-L3W2JWBA.js.map} +0 -0
- /package/dist/{chunk-TTY6DPJN.js.map → chunk-LFUJCRCT.js.map} +0 -0
- /package/dist/{chunk-V5WXIM2F.js.map → chunk-NU2K5G54.js.map} +0 -0
- /package/dist/{chunk-G4JK7WVO.js.map → chunk-P6I72PR3.js.map} +0 -0
- /package/dist/{chunk-WWIFNPJG.js.map → chunk-PCFUXQJA.js.map} +0 -0
- /package/dist/{chunk-DAIEQJIF.js.map → chunk-PLX2FLEQ.js.map} +0 -0
- /package/dist/{chunk-2VUYFTUB.js.map → chunk-QWFG7Y3R.js.map} +0 -0
- /package/dist/{chunk-WVUDLKIO.js.map → chunk-SLBL3WIP.js.map} +0 -0
- /package/dist/{chunk-HWEKHVLE.js.map → chunk-TW35AEB4.js.map} +0 -0
- /package/dist/{chunk-VAPTVR3J.js.map → chunk-VVRI35SK.js.map} +0 -0
- /package/dist/{chunk-6LF4CQBY.js.map → chunk-W5KEYSOL.js.map} +0 -0
- /package/dist/{chunk-TODCQFRB.js.map → chunk-W6GO2CYX.js.map} +0 -0
- /package/dist/{chunk-HHIYT3PI.js.map → chunk-X6ZZEYO3.js.map} +0 -0
- /package/dist/{chunk-QHDPLLK6.js.map → chunk-YN3SWF53.js.map} +0 -0
- /package/dist/{chunk-25MPBIK3.js.map → chunk-ZUGH4MQG.js.map} +0 -0
- /package/dist/{load-agent-defs-3C27ENC7.js.map → load-agent-defs-5XMVB3MU.js.map} +0 -0
- /package/dist/{recompile-project-agents-DGNBCU3N.js.map → recompile-project-agents-7PQWYQ6B.js.map} +0 -0
- /package/dist/{source-loader-7KZ3MD5O.js.map → source-loader-FRJTCSDL.js.map} +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/cli/commands/edit.tsx"],"sourcesContent":["import path from \"path\";\n\nimport chalk from \"chalk\";\nimport { Flags } from \"@oclif/core\";\n\nimport { difference, indexBy, partition } from \"remeda\";\n\nimport { BaseCommand } from \"../base-command.js\";\nimport { type WizardResultV2 } from \"../components/wizard/wizard.js\";\nimport { runWizardSession } from \"../components/wizard/run-wizard-session.js\";\nimport {\n CLI_INVOKE_COMMAND,\n CLI_COLORS,\n EDIT_PROJECT_SETUP_FLAG,\n EDIT_PROJECT_SETUP_MARKETPLACE_FLAG,\n EJECT_SOURCE,\n editorConfigUrl,\n formatSourceDisplayName,\n} from \"../consts.js\";\nimport {\n detectProject,\n loadSource,\n sayCapturedWarnings,\n copyLocalSkills,\n uninstallPluginSkills,\n loadAgentDefs,\n type AgentDefs,\n writeProjectConfig,\n type ConfigWriteResult,\n compileAgentsAllScopes,\n compileProjectScope,\n discoverInstalledSkills,\n removeCompiledAgents,\n type RemoveCompiledAgentsOptions,\n} from \"../lib/operations/index.js\";\nimport { awaitUnderSpinner } from \"../components/common/spinner.js\";\nimport { EXIT_CODES } from \"../lib/exit-codes.js\";\nimport {\n type EjectCopyResult,\n type Installation,\n detectMigrations,\n ejectCopyFailureError,\n executeMigration,\n holdsItsOwnInstallation,\n isHomeDirectory,\n resolveInstallPaths,\n INSTALL_MODE_DESCRIPTIONS,\n} from \"../lib/installation/index.js\";\nimport {\n applyMigratedGlobalSources,\n movedGlobalAgentInputs,\n mutateGlobal,\n type GateReport,\n} from \"../lib/config-gate/index.js\";\nimport { matrix, getSkillById, getSkillDisplayName } from \"../lib/matrix/matrix-provider\";\nimport { type AuthoritativeScope } from \"../lib/configuration/index.js\";\nimport {\n activeAgentNames,\n activeAgentScopeMap,\n isActiveAt,\n isGlobalTombstone,\n} from \"../lib/configuration/scope-predicates.js\";\nimport type { SourceLoadResult } from \"../lib/loading/index.js\";\nimport { discoverAllPluginSkills, buildMarketplacePluginRef } from \"../lib/plugins/index.js\";\nimport {\n deleteLocalSkill,\n foldLocalSkillIntoGlobal,\n migrateLocalSkillScope,\n unresolvedSkillRemovalReasons,\n} from \"../lib/skills/index.js\";\nimport type {\n SkillId,\n SkillConfig,\n AgentName,\n AgentScopeConfig,\n MergedSkillsMatrix,\n ProjectConfig,\n SkillScope,\n} from \"../types/index.js\";\nimport {\n seedPayloadForInstallation,\n skillsAuthoredHere,\n} from \"../lib/seed/installation-payload.js\";\nimport { publishSeedConfig } from \"../lib/seed/publish-seed.js\";\nimport { fetchSeedConfig } from \"../lib/seed/fetch-seed.js\";\nimport {\n carriedSkillsThatDiffer,\n registerExternalSkills,\n writeExternalSkills,\n type ExternalSkillInstall,\n} from \"../lib/seed/external-skills.js\";\nimport { seedToWizardResult, type SeedMapping } from \"../lib/seed/seed-to-wizard.js\";\nimport {\n arrivalLines,\n arrivalsByScope,\n notInstalledGlobally,\n readInstalledGlobal,\n reconcileSharedConfig,\n restoreInstalledGlobal,\n sameAssignments,\n skillLabel,\n withUnplaceableAssignees,\n type Arrivals,\n type HeldGlobal,\n type KeptFromRoundTrip,\n type UnassignedRow,\n} from \"../lib/seed/seed-apply.js\";\nimport {\n RemovalPlanConfirm,\n type RemovalPlanSection,\n} from \"../components/common/removal-plan-confirm.js\";\nimport { promptConfirm } from \"../components/common/prompt-confirm.js\";\nimport { hostAt } from \"../lib/hosts/host-for.js\";\nimport { hostCompileNotices } from \"../lib/hosts/host-compile-notices.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 { openUrl } from \"../utils/open-url.js\";\nimport { plural } from \"../utils/string.js\";\nimport { getErrorMessage } from \"../utils/errors.js\";\nimport { type StartupMessage } from \"../utils/logger.js\";\nimport {\n INCOMPLETE_WORK_RECOVERY,\n ERROR_MESSAGES,\n INFO_MESSAGES,\n SHARED_CONFIG_APPLY,\n STATUS_MESSAGES,\n agentsNotCompiled,\n applySharedConfigHere,\n authoredHereKept,\n carriedSkillsWritten,\n keptAsInstalledGlobally,\n keptUnassigned,\n localSkillsCopied,\n nothingInstalledToApplyTo,\n projectCopyRemoved,\n recompileSummary,\n sharedConfigDestinations,\n sharedConfigNeedsTerminal,\n skippedUnknownAgents,\n skippedUnknownSkills,\n unplaceableKept,\n wizardNeedsTerminal,\n} from \"../utils/messages.js\";\nimport { formatScopeTag } from \"../lib/wizard/index.js\";\nimport { typedKeys } from \"../utils/typed-object.js\";\nimport type { SeedPayload } from \"@workspace/matrix/seed\";\n\n/** A scope transition (`from` → `to`) for a re-scoped skill or agent. */\ntype ScopeChange = { from: SkillScope; to: SkillScope };\n\n/**\n * The noun `edit`'s recompile summary counts in, singular as `recompileSummary` takes it. `edit`\n * recompiles every scope this context owns in one pass, so it has no scope word to qualify with —\n * `compile`, which runs one scope at a time, does.\n */\nconst RECOMPILE_SUBJECT = \"agent\";\n\n/**\n * Dual-scope add/remove: the project half of a [P][G] pair was toggled while the\n * global half persists. Reported as a project-scope addition/removal; a\n * scope-change arrow line would falsely claim the global install moved.\n */\nfunction formatDualScopeTransition(displayName: string, to: SkillScope): string {\n const isAdd = to === \"project\";\n const prefix = isAdd ? \"+\" : \"-\";\n const color = isAdd ? CLI_COLORS.SUCCESS : CLI_COLORS.ERROR;\n return chalk.hex(color)(` ${prefix} ${displayName} [P]`);\n}\n\n/**\n * One re-scoped skill's line. A dual-scope toggle is the transition above rather than a\n * migration; a genuine `[G] → [P]` reads as an addition because the skill arrives in this\n * project, and every other direction is the amber `~` a move is written with.\n */\nfunction formatSkillScopeChangeLine(\n skillId: SkillId,\n change: ScopeChange,\n dualScopeSkillTransitions: ReadonlySet<SkillId>,\n): string {\n const displayName = getSkillDisplayName(skillId);\n if (dualScopeSkillTransitions.has(skillId)) {\n return formatDualScopeTransition(displayName, change.to);\n }\n\n const isGlobalToProject = change.from === \"global\" && change.to === \"project\";\n const prefix = isGlobalToProject ? \"+\" : \"~\";\n const color = isGlobalToProject ? CLI_COLORS.SUCCESS : CLI_COLORS.WARNING;\n return (\n chalk.hex(color)(` ${prefix} ${displayName}`) +\n chalk.hex(CLI_COLORS.NEUTRAL)(scopeArrow(change))\n );\n}\n\n/**\n * The agent mirror of the line above, with two differences preserved from how this summary has\n * always read: there is no `[G] → [P]`-reads-as-addition arm — an agent that moves is a move —\n * and only the dual-scope arm carries the `(agent)` suffix, since a `~` line names no skill it\n * could be confused with.\n */\nfunction formatAgentScopeChangeLine(\n agentName: AgentName,\n change: ScopeChange,\n dualScopeAgentTransitions: ReadonlySet<AgentName>,\n): string {\n const agentSuffix = chalk.hex(CLI_COLORS.NEUTRAL)(\" (agent)\");\n if (dualScopeAgentTransitions.has(agentName)) {\n return formatDualScopeTransition(agentName, change.to) + agentSuffix;\n }\n\n return (\n chalk.hex(CLI_COLORS.WARNING)(` ~ ${agentName}`) +\n chalk.hex(CLI_COLORS.NEUTRAL)(scopeArrow(change))\n );\n}\n\n/** The ` ([P] → [G])` half both lines above end with, in the tags the wizard writes scopes as. */\nfunction scopeArrow(change: ScopeChange): string {\n return ` (${formatScopeTag(change.from)} \\u2192 ${formatScopeTag(change.to)})`;\n}\n\n/**\n * A `~ subject (kind: before \\u2192 after)` line, for the changes that rewrite a setting rather than\n * move a file.\n *\n * Both halves are spelled out rather than only the new one: a retune leaves nothing on disk for\n * the person reading this to compare against, so the line is the only account there is of what it\n * replaced.\n */\nfunction formatValueChangeLine(subject: string, change: ValueChange, kind: string): string {\n return (\n chalk.hex(CLI_COLORS.WARNING)(` ~ ${subject}`) +\n chalk.hex(CLI_COLORS.NEUTRAL)(` (${kind}: ${change.from} \\u2192 ${change.to})`)\n );\n}\n\n/**\n * The name this session's catalogue answers to — what a marketplace-dropped entry's removal\n * reason says the skill is not present in. The resolved marketplace where there is one,\n * otherwise the source string itself, which is what an installation pointed at a source that\n * never carried the skill has to be named by.\n */\nfunction loadedSourceLabel(sourceResult: SourceLoadResult): string {\n return sourceResult.marketplace ?? sourceResult.sourceConfig.source;\n}\n\n/** @internal Re-exported for testing — the transform itself lives inside the gate. */\nexport { applyMigratedGlobalSources };\n\ntype EditContext = {\n installation: Installation;\n projectConfig: ProjectConfig | null;\n /** The detected installation's root — where this run READS its saved skills from. */\n projectDir: string;\n sourceResult: SourceLoadResult;\n startupMessages: StartupMessage[];\n currentSkillIds: SkillId[];\n /**\n * The name of the marketplace `init --marketplace` named for the project setup this run\n * continues. Absent on every other run, where the marketplace is the one the installation stored.\n */\n setupMarketplace?: string;\n};\n\n/**\n * The one directory an `edit` run acts on, and everything every layer needs to know about it.\n *\n * Six layers used to answer \"am I editing the global installation?\" for themselves, three of\n * them off the working directory, and they disagreed the moment the command was started\n * outside an install. Passing this value instead of a bare path is what makes them one\n * answer: a layer that wants a different one has to reach past the parameter it was handed.\n */\ntype EditRoot = {\n /** Where this run writes, registers plugins and compiles into. */\n dir: string;\n /**\n * True when {@link EditRoot.dir} IS the global installation, so there is no project scope to\n * offer.\n */\n isGlobal: boolean;\n /**\n * True when this run must materialise {@link EditRoot.dir} as a project even with nothing to\n * change.\n */\n isProjectSetup: boolean;\n};\n\n/**\n * Which installation this run is editing, decided once.\n *\n * `edit` names no directory. It edits the installation `detectProject` found, and that\n * installation's root is the only root that HAS a config to edit — so it is the only root\n * this run may write to. Reading the working directory instead made a project out of\n * whichever directory the command was started in: over a global-only install the wizard\n * offered the project/global scope toggle for a project that did not exist, and saving\n * wrote a config pair into an unrelated checkout.\n *\n * `--project-setup` is an instance of that rule rather than an exception to it. It means the\n * user ran `cc init` HERE, which declares this directory the installation being set up, so\n * the config this run writes is what makes the claim true. At the home root there is nothing\n * to set up and both spellings name the same directory anyway, which is why the flag alone\n * picks the root and the resolved criterion decides whether anything is materialised.\n */\nfunction resolveEditRoot(\n installation: Installation,\n cwd: string,\n setupRequested: boolean,\n): EditRoot {\n const dir = setupRequested ? cwd : installation.projectDir;\n const isGlobal = isHomeDirectory(dir);\n return { dir, isGlobal, isProjectSetup: setupRequested && !isGlobal };\n}\n\n/**\n * What this run is about to apply, and which producer said so.\n *\n * The two produce the same `WizardResultV2` and are applied by the same sequence — that is what\n * stops `edit` growing a second copy of its own pipeline. They differ in what has to happen\n * between the diff and the first mutation: a wizard result was authored keystroke by keystroke\n * and needs no permission, while a shared configuration arrived whole and destroys whatever it\n * left out, so its removals are shown and confirmed there.\n */\ntype EditSelection =\n | { producer: \"wizard\"; result: WizardResultV2 }\n | {\n producer: \"shared\";\n result: WizardResultV2;\n /** Statements naming what this run may not remove — rendered in the confirm. */\n kept: string[];\n /** Skills the configuration carries rather than names, written once it is approved. */\n carried: ExternalSkillInstall[];\n };\n\n/** What a shared apply is confirmed against: one heading, the lists, and the prose under them. */\ntype SharedConfigPlan = {\n heading: string;\n sections: RemovalPlanSection[];\n statements: string[];\n};\n\n/**\n * The plan a shared apply is confirmed against: what it removes, and what stays and why.\n *\n * It is one plan wherever the run was started. Inside the global installation the removals are\n * global ones, and the person chose that scope by running the command there. Inside a project\n * the global install is put back whole before the diff (see `restoreInstalledGlobal`), so every\n * removal listed is the project's own and nothing reaches past it — including the project's half\n * of a `[P][G]` pair, whose id survives at global scope and so is not in the removed lists.\n */\nfunction sharedConfigPlan(changes: ConfigChanges, kept: string[]): SharedConfigPlan {\n const dropped = droppedProjectHalves(changes);\n const skillLines = [\n ...changes.removedSkills.map(skillLabel),\n ...dropped.skillIds.map(droppedSkillLine),\n ];\n const agentLines = [...changes.removedAgents, ...dropped.agentNames.map(projectCopyRemoved)];\n\n const sections = removalSections(skillLines, agentLines);\n return { heading: planHeading(sections), sections, statements: kept };\n}\n\n/** A dropped project half of a skill, as the plan prints it. */\nfunction droppedSkillLine(skillId: SkillId): string {\n return projectCopyRemoved(skillLabel(skillId));\n}\n\n/** The removals a shared configuration makes here, grouped as the plan prints them. */\nfunction removalSections(skills: string[], agents: string[]): RemovalPlanSection[] {\n return [\n { label: SHARED_CONFIG_APPLY.SKILLS_HEADING, items: skills },\n { label: SHARED_CONFIG_APPLY.AGENTS_HEADING, items: agents },\n ].filter((section) => section.items.length > 0);\n}\n\n/** The project halves of `[P][G]` pairs a run drops. */\ntype DroppedHalves = { skillIds: SkillId[]; agentNames: AgentName[] };\n\n/**\n * The `[P][G]` pairs whose project half this run drops, leaving the global install's copy to take\n * over. The diff records each as a project-to-global scope change rather than a removal, because\n * the id survives at global scope. A pair `s` folded is not one: its copy moves rather than goes.\n */\nfunction droppedProjectHalves(changes: ConfigChanges): DroppedHalves {\n const droppedSkills = changes.collapsedPairs.filter((pair) => !pair.folded);\n const droppedAgents = [...changes.agentScopeChanges].filter(\n ([name, change]) => change.to === \"global\" && changes.dualScopeAgentTransitions.has(name),\n );\n\n return {\n skillIds: droppedSkills.map(({ projectHalf }) => projectHalf.id),\n agentNames: droppedAgents.map(([name]) => name),\n };\n}\n\n/**\n * The plan's opening line. A heading is a promise about the lines beneath it, so one promising\n * removals over an empty list would be a lie — a configuration that only adds says so instead,\n * and is still confirmed, because it is still applied whole.\n */\nfunction planHeading(sections: RemovalPlanSection[]): string {\n if (sections.length === 0) return SHARED_CONFIG_APPLY.NOTHING_REMOVED;\n return SHARED_CONFIG_APPLY.PREVIEW_HEADING;\n}\n\n/**\n * Whether this run's compile covers the global install as well as the project.\n *\n * A shared configuration applied from a project holds the global install as installed, so the\n * global pass is owed only when the write added something the global sub-agents derive from. Run\n * anyway, it would write nothing but the drift between the global config and its compiled files —\n * a missing or hand-edited agent — which no project run was asked to repair. The wizard keeps\n * both passes: a mode switch it carries to global scope is recorded before this write, so the\n * write alone cannot say whether the global agents moved.\n */\nfunction compilesGlobalScope(\n producer: EditSelection[\"producer\"],\n editRoot: EditRoot,\n written: GateReport,\n): boolean {\n if (editRoot.isGlobal || producer === \"wizard\") return true;\n return movedGlobalAgentInputs(written);\n}\n\n/**\n * The diff a run plans: the roster's, plus the sub-agents whose skill rows change while the roster\n * does not — a change {@link detectConfigChanges} has no field for, because it diffs entries and a\n * re-assignment adds or removes none.\n */\ntype PlannedChanges = ConfigChanges & { reassignedAgents: AgentName[] };\n\n/**\n * The diff an apply acts on: the plan, plus the carried skills already installed here whose files\n * the apply rewrote with different bytes — the other change no config entry records.\n */\ntype AppliedChanges = PlannedChanges & { rewrittenSkills: SkillId[] };\n\n/**\n * The diff, with the sub-agents this run owns whose rows the result changes. Only a producer that\n * states rows has any: the wizard leaves `assignedStack` undefined and the ownership rules derive\n * the stack, while a shared configuration states every row it means.\n *\n * In a project that is the project's own sub-agents only — a global one keeps every row it is\n * installed with (see `restoreInstalledGlobal`), and gains one only beside a skill the diff already\n * counts as added. A sub-agent the diff already counts as added is not counted twice.\n */\nfunction withReassignments(\n changes: ConfigChanges,\n result: WizardResultV2,\n installedStack: ProjectConfig[\"stack\"],\n editRoot: EditRoot,\n): PlannedChanges {\n const { assignedStack } = result;\n if (assignedStack === undefined) return { ...changes, reassignedAgents: [] };\n\n const ownedHere = (agent: AgentScopeConfig): boolean =>\n editRoot.isGlobal || isActiveAt(agent, \"project\");\n const countedAsAdded = (agent: AgentScopeConfig): boolean =>\n changes.addedAgents.includes(agent.name);\n const rowsMoved = (agent: AgentScopeConfig): boolean =>\n !sameAssignments(assignedStack[agent.name], installedStack?.[agent.name]);\n\n const reassigned = result.agentConfigs.filter(\n (agent) => ownedHere(agent) && !countedAsAdded(agent) && rowsMoved(agent),\n );\n return { ...changes, reassignedAgents: reassigned.map((agent) => agent.name) };\n}\n\n/**\n * What the apply adds or changes, by the scope each entry lands at — the two lists printed above\n * the confirm. Not the whole configuration: what is already installed as the configuration states\n * it is not arriving anywhere, and neither is the global copy a dropped project half leaves — the\n * plan lists that drop as a removal.\n */\nfunction applyArrivals(changes: PlannedChanges, result: WizardResultV2): Arrivals {\n const changedSkills = new Set<SkillId>([\n ...changes.addedSkills,\n ...changes.sourceChanges.keys(),\n ...changes.scopeChanges.keys(),\n ]);\n const changedAgents = new Set<AgentName>([\n ...changes.addedAgents,\n ...changes.agentScopeChanges.keys(),\n ...changes.tuningChanges.keys(),\n ...changes.reassignedAgents,\n ]);\n const dropped = droppedProjectHalves(changes);\n const skillArrives = (skill: SkillConfig): boolean =>\n changedSkills.has(skill.id) && !dropped.skillIds.includes(skill.id);\n const agentArrives = (agent: AgentScopeConfig): boolean =>\n changedAgents.has(agent.name) && !dropped.agentNames.includes(agent.name);\n\n return arrivalsByScope(\n result.skills.filter(skillArrives),\n result.agentConfigs.filter(agentArrives),\n );\n}\n\n/**\n * The plan's kept half, one statement per reason.\n *\n * Both reasons are disclosed rather than acted on, which is the point: no configuration ever\n * carried a skill written here, and an id this catalogue cannot place is one this run had an\n * instruction about and could not honour — so an apply that silently left them behind would\n * recreate exactly the defect the destructive ruling exists to kill, nobody able to tell why an\n * agent still carries a skill they never picked.\n */\nfunction keptStatements(kept: KeptFromRoundTrip): string[] {\n return [...authorshipStatement(kept), ...catalogueStatement(kept)];\n}\n\n/** The ownership half, whose remedy is the wizard rather than another configuration. */\nfunction authorshipStatement(kept: KeptFromRoundTrip): string[] {\n if (kept.authoredSkillIds.length === 0) return [];\n return [authoredHereKept(kept.authoredSkillIds)];\n}\n\n/** The catalogue's own limit, whose remedy is the catalogue rather than anything installed. */\nfunction catalogueStatement(kept: KeptFromRoundTrip): string[] {\n if (kept.unplaceableSkillIds.length === 0) return [];\n return [unplaceableKept(kept.unplaceableSkillIds)];\n}\n\n/** The kept skills that lose a slot to the configuration's own skill, one bare line each. */\nfunction unassignedStatement(unassigned: UnassignedRow[]): string[] {\n if (unassigned.length === 0) return [];\n return [\n unassigned\n .map(({ skillId, agentName, category }) => keptUnassigned(skillId, agentName, category))\n .join(\"\\n\"),\n ];\n}\n\n/**\n * The global entries a project run holds as installed though the configuration differs — with\n * the carried skills whose global copy reads otherwise than the configuration's, which no config\n * entry can show.\n */\nfunction keptAsInstalledStatement(held: HeldGlobal, revisedCarried: SkillId[]): string[] {\n const skillIds = [...held.keptAsInstalled.skillIds, ...revisedCarried];\n const { agentNames } = held.keptAsInstalled;\n if (skillIds.length === 0 && agentNames.length === 0) return [];\n return [keptAsInstalledGlobally(skillIds, agentNames)];\n}\n\n/**\n * How much of what it can see a run owns — the word the merger takes, and the same word the\n * global config the project write commits is resolved under.\n *\n * At the home root, everything: the session loaded the whole global config, so an absent entry\n * was deselected. In a project, only what the project owns, whichever producer said so. The\n * wizard's store refuses to deselect a live global entry at all, and a shared configuration only\n * ADDS to the global install from a project (owner ruling 2026-10-02) — so an inherited row absent\n * from either result is one nobody dropped, and the global config is added to, never matched.\n */\nfunction applyAuthority(editRoot: EditRoot): AuthoritativeScope {\n return editRoot.isGlobal ? \"all\" : \"owned\";\n}\n\nexport default class Edit extends BaseCommand {\n static summary = \"Edit skills in the plugin\";\n static description = \"Modify the currently installed skills via interactive wizard\";\n\n static examples = [\n {\n description: \"Open the edit wizard\",\n command: \"<%= config.bin %> <%= command.id %>\",\n },\n {\n description: \"Open this installation in the editor instead of the wizard\",\n command: \"<%= config.bin %> <%= command.id %> --ui\",\n },\n {\n description: \"Apply a configuration built in the editor, by its id\",\n command: \"<%= config.bin %> <%= command.id %> --from <id>\",\n },\n ];\n\n static flags = {\n ui: Flags.boolean({\n description:\n \"Open agentsinc.sh/editor instead of the wizard — the id --from names, or this installation\",\n default: false,\n }),\n from: Flags.string({\n description:\n \"Apply a configuration shared from agentsinc.sh by its id, removing whatever it leaves out — from a project, only the project's own entries\",\n helpValue: \"<id>\",\n }),\n [EDIT_PROJECT_SETUP_FLAG]: Flags.boolean({\n description: \"Internal: this run continues an `init` project setup\",\n default: false,\n hidden: true,\n }),\n [EDIT_PROJECT_SETUP_MARKETPLACE_FLAG]: Flags.string({\n description: \"Internal: the marketplace `init --marketplace` named for that project setup\",\n hidden: true,\n dependsOn: [EDIT_PROJECT_SETUP_FLAG],\n }),\n provider: providerFlag(),\n };\n\n /**\n * The command in two statements: do the work, then answer for it.\n *\n * `applyEdit` owns every path through the edit and returns however it likes; the exit code is\n * decided once, here, after the last of them. Deciding it inside `applyEdit` would mean\n * deciding it at each of that method's three endings, and an ending added later would inherit\n * the exit-0 default silently — which is the defect this pair exists to close.\n */\n async run(): Promise<void> {\n await this.applyEdit();\n this.exitIfWorkIncomplete();\n }\n\n private async applyEdit(): Promise<void> {\n const { flags } = await this.parse(Edit);\n const cwd = process.cwd();\n\n // ABOVE `ensureConfigReadable`, and above `edit`'s own requirement that something be installed\n // here at all. Opening an id somebody shared needs no local state — no config, no catalogue,\n // no marketplace — so a directory's condition cannot decide whether you may look at it, and\n // the id already IS a stored configuration so nothing is minted either. That exemption is the\n // owner's ruling of 2026-08-24 rather than an oversight, and `edit-ui-from.e2e.test.ts` is\n // what says so: `edit` refuses an empty directory on every other path.\n if (flags.ui && flags.from !== undefined) return this.openSharedInEditor(flags.from, cwd);\n\n // Beside the config-readability refusal and for the same reason: past this point the wizard\n // has copied skills and installed plugins, so a run that cannot tell WHICH installation it is\n // editing has to stop while the answer still costs nothing.\n await refuseAnAmbiguousInstallation(cwd, \"edit\", providerNamedBy(flags.provider), (message) =>\n this.error(message, { exit: EXIT_CODES.INVALID_ARGS }),\n );\n\n // Before anything renders: a config that cannot be read is recreated, not edited, and\n // refusing here is what keeps the refusal clean — past this point the wizard has already\n // copied skills and installed plugins by the time a config read fails.\n await this.ensureConfigReadable(cwd);\n await this.refuseUnofferablePlacements(cwd);\n\n // The browser is the other editor, so it replaces the wizard rather than preceding it —\n // above the source load, which exists to fill screens this run will never paint.\n if (flags.ui) return this.openInEditor(cwd);\n\n // The inbound half is destructive, so it is confirmed — and a confirm nobody can answer must\n // never become a yes. Refusing here, above the fetch and above the catalogue load, is what\n // keeps a run that cannot finish from spending either.\n const payload =\n flags.from === undefined ? null : await this.fetchSharedConfigOrFail(flags.from);\n\n const context = await this.loadContextUnderSpinner(flags[EDIT_PROJECT_SETUP_MARKETPLACE_FLAG]);\n\n // Which installation this run is editing, resolved once and read by every layer below.\n const editRoot = resolveEditRoot(context.installation, cwd, flags[EDIT_PROJECT_SETUP_FLAG]);\n\n // Still before anything renders, one layer below the config itself: an entry whose skill\n // IS installed and whose metadata.yaml describes it no longer would otherwise be dropped\n // from config.ts on the way out, over a file this refusal asks to be repaired instead.\n await this.ensureSavedSkillsReadable(\n context.projectConfig?.skills ?? [],\n context.sourceResult.matrix,\n context.projectDir,\n );\n\n const selection = payload\n ? await this.selectionFromSharedConfig(payload, context, editRoot)\n : await this.selectionFromWizard(context, editRoot);\n if (!selection) this.error(\"Cancelled\", { exit: EXIT_CODES.CANCELLED });\n\n const { result } = selection;\n this.reportValidationErrors(result.validation);\n\n // Filter excluded entries ONCE — downstream methods receive only active entries\n const activeNewSkills = result.skills.filter((s) => !s.excluded);\n const activeNewAgents = result.agentConfigs.filter((a) => !a.excluded);\n const activeOldSkills = (context.projectConfig?.skills ?? []).filter((s) => !s.excluded);\n const activeOldAgents = (context.projectConfig?.agents ?? []).filter((a) => !a.excluded);\n\n const filteredResult: WizardResultV2 = {\n ...result,\n skills: activeNewSkills,\n agentConfigs: activeNewAgents,\n };\n const filteredOldConfig: ProjectConfig | null = context.projectConfig\n ? { ...context.projectConfig, skills: activeOldSkills, agents: activeOldAgents }\n : null;\n\n const planned = withReassignments(\n detectConfigChanges(filteredOldConfig, filteredResult, {\n newSkills: result.skills,\n oldSkills: context.projectConfig?.skills ?? [],\n newAgents: result.agentConfigs,\n oldAgents: context.projectConfig?.agents ?? [],\n }),\n filteredResult,\n context.projectConfig?.stack,\n editRoot,\n );\n // The gate, at the one point where the removals are known and none has been made: after the\n // diff, above every mutation, and above the no-change return — a configuration that carries\n // its own skills still has bytes to land when the roster is unchanged.\n const rewritten =\n selection.producer === \"shared\"\n ? await this.confirmAndWriteCarried(selection, planned, filteredResult)\n : [];\n const changes: AppliedChanges = {\n ...planned,\n rewrittenSkills: difference(rewritten, planned.addedSkills),\n };\n\n // One word for both halves of the write, decided once from where the run is: the merger reads\n // it for the config ROW, and the gate reads it for the global config a project write commits.\n // Deriving it twice is how the row and the disk come to disagree.\n const authority = applyAuthority(editRoot);\n\n if (!hasAnyChanges(changes)) {\n this.log(chalk.hex(CLI_COLORS.NEUTRAL)(\"No changes made.\"));\n // `cc init` inside a project means \"set this project up\", so the project must be\n // materialised — the project's `config.ts` + `config-types.ts` written and the\n // path registered in the global `projects[]` — even when the wizard produced no roster\n // change. At the home root there is no project to set up: the global install is what the\n // dashboard was shown for, so a no-change pass there stays an inspection, as does every\n // bare `cc edit`.\n if (!editRoot.isProjectSetup) return;\n await this.writeConfigAndCompile(result, context, editRoot, authority, selection.producer);\n await this.reportWhatThisHostCannotCarry(editRoot);\n this.logCompletionSummary(changes);\n return;\n }\n\n const removalReasons = await unresolvedSkillRemovalReasons(\n result.unresolvableSkillIds,\n activeOldSkills,\n context.projectDir,\n loadedSourceLabel(context.sourceResult),\n );\n this.logChangeSummary(\n changes,\n filteredResult.skills,\n filteredOldConfig?.skills ?? [],\n removalReasons,\n );\n const migratedSkillIds = await this.applyMigrations(\n changes,\n filteredResult,\n activeOldSkills,\n context,\n editRoot,\n );\n await this.recordGlobalSourceMigrations(\n migratedSkillIds,\n filteredResult.skills,\n editRoot,\n context,\n );\n await this.applyScopeChanges(changes, filteredResult, context, editRoot);\n await this.applyCollapsedPairs(changes, filteredResult, context, editRoot);\n await this.applySourceChanges(changes, activeOldSkills, editRoot, migratedSkillIds);\n await this.applyPluginChanges(changes, filteredResult, activeOldSkills, context, editRoot);\n await this.copyNewLocalSkills(changes, filteredResult, context, editRoot);\n await this.removeDeletedLocalSkills(changes, activeOldSkills, editRoot);\n await this.writeConfigAndCompile(result, context, editRoot, authority, selection.producer);\n await this.cleanupStaleAgentFiles(changes, activeOldAgents, editRoot);\n await this.reportWhatThisHostCannotCarry(editRoot);\n this.logCompletionSummary(changes);\n }\n\n /** The interactive producer: open the wizard on what is installed, return what was chosen. */\n private async selectionFromWizard(\n context: EditContext,\n editRoot: EditRoot,\n ): Promise<EditSelection | null> {\n // Here rather than above the load: every refusal about the installation — there is none, its\n // config will not load, a saved skill's metadata.yaml no longer describes it — still speaks for\n // itself over a pipe, and the mount below is the first thing that needs a terminal.\n if (!process.stdin.isTTY) {\n this.error(wizardNeedsTerminal(\"edit\"), { exit: EXIT_CODES.ERROR });\n }\n\n const result = await this.runEditWizard(context, editRoot);\n if (!result) return null;\n\n return { producer: \"wizard\", result };\n }\n\n /**\n * The `--from <id>` producer: fetch, seat what the configuration carries, decode, and put back\n * what this run has no authority to remove.\n *\n * Everything a shared configuration says is a statement about the whole roster, so the apply\n * that follows is destructive — the project is made to MATCH it. Two exceptions come back into\n * the result: a skill written here, which the producer drops on the way out because\n * `forkedFrom` says the CLI never wrote it, and an id the configuration NAMES that this\n * catalogue cannot place, because a destructive apply removes on intent and never on its own\n * inability. Both are disclosed in the confirm rather than silently excused.\n *\n * From a project the global install comes back too, whole: it is one installation every project\n * on the machine reads, so a project run only ADDS to it (owner ruling 2026-10-02). Every global\n * entry the configuration leaves out is put back as installed, every one it states otherwise is\n * held as installed and named in the confirm, and only the global entries the global install\n * lacks arrive — a skill with its rows, on a global sub-agent already there too. At the home\n * directory the run IS the global install, so nothing is held there.\n */\n private async selectionFromSharedConfig(\n payload: SeedPayload,\n context: EditContext,\n editRoot: EditRoot,\n ): Promise<EditSelection> {\n const { matrix: sourceMatrix } = context.sourceResult;\n // Before the decode, because a skill the payload CARRIES answers to no catalogue: unseated,\n // its id is skipped like any other unknown one and its content is never read.\n const carried = this.registerExternalSkillsOrFail(payload, sourceMatrix, editRoot.dir);\n const { result, skippedSkillIds, skippedAgentNames } = this.decodeSeedOrFail(\n payload,\n sourceMatrix,\n );\n\n // The first moment this can be asked, and above everything this run would say or do: an\n // all-global configuration is exactly what a global installation is for, so only the decode\n // says whether THIS one has anywhere to be written here. `init --from` asks it at the same\n // point of the same value, and a run about to be refused must not first narrate its skips.\n this.refuseProjectScopedContentAtHome(result, editRoot.dir);\n\n // The ids the decode above could not place. They are the skips reported below, read as what\n // STAYS rather than as what did not arrive: the payload named them, so their absence from the\n // decode is this catalogue's limit and not an instruction to delete anything — and neither is\n // the absence of a sub-agent only they carried in.\n const unplaceable = new Set(skippedSkillIds);\n const reconciled = reconcileSharedConfig({\n decoded: withUnplaceableAssignees(result, context.projectConfig, payload, unplaceable),\n installed: context.projectConfig,\n authoredHere: await this.readAuthoredHere(context.projectConfig, editRoot.dir),\n unplaceable,\n });\n const held = restoreInstalledGlobal(\n reconciled.result,\n editRoot.isGlobal ? null : await readInstalledGlobal(editRoot.dir),\n );\n const arrivingCarried = notInstalledGlobally(carried, held);\n\n // The last refusals, asked of what the apply would install and write, and above the skips,\n // the plan and the question for the reason the location refusal is above the skips.\n await this.refuseSharedConfigBeforeAsking(\n held.result,\n arrivingCarried,\n editRoot.dir,\n context.sourceResult,\n );\n\n // A carried skill the global install already holds is not written from a project, so a\n // revision of it does not arrive — and is named in the plan rather than dropped in silence.\n const heldGlobally = difference(carried, arrivingCarried);\n const revisedGlobally = await carriedSkillsThatDiffer(heldGlobally);\n\n // What the load held back for a wizard this run never mounts, above the skips it may explain.\n sayCapturedWarnings(context.startupMessages);\n if (skippedSkillIds.length > 0) this.warn(skippedUnknownSkills(skippedSkillIds));\n if (skippedAgentNames.length > 0) this.warn(skippedUnknownAgents(skippedAgentNames));\n\n return {\n producer: \"shared\",\n result: held.result,\n kept: [\n ...keptStatements(reconciled.kept),\n ...unassignedStatement(reconciled.unassigned),\n ...keptAsInstalledStatement(held, revisedGlobally),\n ],\n carried: arrivingCarried,\n };\n }\n\n /**\n * Which installed skills the round trip does not own, asked of the disk exactly as the\n * producing half asks it.\n *\n * Best-effort by nature and never fatal: the question is only ever asked to PROTECT a skill,\n * so a directory that cannot be read protects nothing and must not fail an apply. The\n * consequence of an unanswered question is that the entry is treated as the CLI's own, which\n * is what every other command already assumes about it.\n */\n private async readAuthoredHere(\n projectConfig: ProjectConfig | null,\n editRoot: string,\n ): Promise<Set<SkillId>> {\n if (!projectConfig) return new Set();\n\n try {\n return await skillsAuthoredHere(projectConfig, editRoot);\n } catch (error) {\n this.warn(`Could not tell which skills were written here: ${getErrorMessage(error)}`);\n return new Set();\n }\n }\n\n /**\n * The id, fetched — or the run refused before it is.\n *\n * Two questions are answered first, because nothing in the payload can change either answer:\n * an apply with nothing to apply to, or that cannot be confirmed, is over before the store is\n * asked, and a refusal that had already spent a round trip would be describing work it never\n * intended to do. Whether anything is installed comes before the terminal: the terminal\n * refusal's way on is this same command from a terminal, which in a folder with nothing\n * installed would only refuse again.\n */\n private async fetchSharedConfigOrFail(id: string): Promise<SeedPayload> {\n if (!(await detectProject())) {\n this.error(nothingInstalledToApplyTo(id), { exit: EXIT_CODES.ERROR });\n }\n if (!process.stdin.isTTY) {\n this.error(sharedConfigNeedsTerminal(id), { exit: EXIT_CODES.ERROR });\n }\n\n this.log(`Fetching configuration ${id}...`);\n const fetched = await fetchSeedConfig(id);\n if (!fetched.ok) {\n this.error(fetched.error, { exit: EXIT_CODES.ERROR });\n }\n\n return fetched.payload;\n }\n\n /**\n * The decode refuses a payload the config model has nowhere to write (see `seedToWizardResult`).\n * That is a failure of this command, reported with this command's exit code rather than left to\n * surface as an unhandled throw.\n */\n private decodeSeedOrFail(payload: SeedPayload, sourceMatrix: MergedSkillsMatrix): SeedMapping {\n try {\n return seedToWizardResult(payload, sourceMatrix);\n } catch (error) {\n this.handleError(error);\n }\n }\n\n /**\n * Seats the catalogue entries the payload carries with it, or refuses the run. The refusals are\n * `registerExternalSkills`' own — a carried skill asked for as a plugin, which no marketplace\n * serves, and a carried skill claiming an id the loaded catalogue already owns, whose bytes would\n * be written over that catalogue's own copy — reported with this command's exit code for the same\n * reason the decode's is.\n */\n private registerExternalSkillsOrFail(\n payload: SeedPayload,\n sourceMatrix: MergedSkillsMatrix,\n projectDir: string,\n ): ExternalSkillInstall[] {\n try {\n return registerExternalSkills(payload, sourceMatrix, projectDir);\n } catch (error) {\n this.handleError(error);\n }\n }\n\n /**\n * Confirms a shared configuration, then writes the skills it brought with it — answering with\n * those whose files now read differently.\n */\n private async confirmAndWriteCarried(\n selection: Extract<EditSelection, { producer: \"shared\" }>,\n planned: PlannedChanges,\n result: WizardResultV2,\n ): Promise<SkillId[]> {\n await this.confirmSharedConfigOrCancel(planned, selection.kept, applyArrivals(planned, result));\n return this.writeCarriedSkills(selection.carried);\n }\n\n /** Writes the skills the configuration brought with it, and says which they were. */\n private async writeCarriedSkills(carried: ExternalSkillInstall[]): Promise<SkillId[]> {\n if (carried.length === 0) return [];\n\n const rewritten = await writeExternalSkills(carried);\n this.log(carriedSkillsWritten(carried.map((skill) => skill.id)));\n return rewritten;\n }\n\n /**\n * Shows what applying this configuration takes away, and stops the run unless a person says\n * yes.\n *\n * The plan is built from the SAME `ConfigChanges` the apply below acts on, so what is approved\n * and what is removed are one value read twice. Its kept half is the other side of the same\n * honesty: nothing is refused over an entry this run cannot remove, and nothing is silent\n * about one either.\n *\n * Above it go the two lists every `--from` install prints — what the apply adds or changes in\n * this project, and in the global install — so the question is asked about the whole of what a\n * yes does, not only about what it takes away.\n */\n private async confirmSharedConfigOrCancel(\n changes: ConfigChanges,\n kept: string[],\n arrivals: Arrivals,\n ): Promise<void> {\n const plan = sharedConfigPlan(changes, kept);\n for (const line of arrivalLines(arrivals)) {\n this.log(line);\n }\n\n const outcome = await promptConfirm(({ onConfirm, onCancel }) => (\n <RemovalPlanConfirm\n heading={plan.heading}\n sections={plan.sections}\n statements={plan.statements}\n message={SHARED_CONFIG_APPLY.CONFIRM}\n onConfirm={onConfirm}\n onCancel={onCancel}\n />\n ));\n if (outcome === \"confirmed\") return;\n\n this.log(\"\\nEdit cancelled\");\n this.error(\"Cancelled\", { exit: EXIT_CODES.CANCELLED });\n }\n\n /**\n * Refuses a configuration whose own host cannot place what it asks for, before the wizard runs.\n *\n * `compile` asks the same question of the same roster and `update` asks it too. `edit` is the\n * command that REWRITES the file, so letting it through would mean a user curating a\n * configuration no command will act on — and then saving it back, with the unofferable row\n * carried forward because nothing on the edit path had any reason to drop it.\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 * The outbound half of the editor round trip: this installation, minted as a configuration\n * the editor opens, and handed to a browser.\n *\n * It is the same mint `share` performs — same reader, same mapping, same refusals, through\n * `seedPayloadForInstallation` — because an id is the whole of what either command produces\n * and two spellings of \"the installation in this directory\" would mint two different ids for\n * one project. What differs is only the ending: `share` reports the id, this opens it.\n *\n * Nothing on disk is touched. A configuration is read, not rewritten, so a run that changed\n * anything here would be editing the project on the way to offering to edit it.\n */\n private async openInEditor(projectDir: string): Promise<void> {\n const prepared = await seedPayloadForInstallation(projectDir);\n if (!prepared.ok) {\n this.error(prepared.error, { exit: EXIT_CODES.ERROR });\n }\n\n this.log(`Opening ${prepared.skills} skill(s) across ${prepared.agents} sub-agent(s)...`);\n\n const published = await publishSeedConfig(prepared.payload);\n if (!published.ok) {\n this.error(published.error, { exit: EXIT_CODES.ERROR });\n }\n\n await this.handToBrowser(published.id);\n }\n\n /**\n * An id somebody shared, opened rather than applied.\n *\n * The counterpart of `openInEditor` above and deliberately not a variant of it: that one MINTS,\n * because an installation is not yet a configuration the store holds. An id already is one, so\n * there is nothing to publish, and no way for this to fail except the browser refusing to launch\n * — which is a warning beside a link that still works.\n *\n * `--from` without `--ui` remains the destructive apply. Looking and applying are the two\n * things a recipient can do with an id, and this is the one that changes nothing.\n */\n private async openSharedInEditor(id: string, cwd: string): Promise<void> {\n const url = editorConfigUrl(id);\n\n this.log(`Open it at ${url}`);\n this.log(applySharedConfigHere(id, await holdsItsOwnInstallation(cwd)));\n\n if (!process.stdin.isTTY) return;\n\n const opened = await openUrl(url);\n if (!opened.ok) this.warn(opened.error);\n }\n\n /**\n * The link, printed first and opened second.\n *\n * Printed first because it is the only part of this that works everywhere: over a pipe, in CI\n * and on a machine with no desktop session there is no browser to be anybody's, and a link\n * nobody can copy is the whole loss. Opening one is the convenience on top, so a failure to\n * open is a warning beside a link that still works rather than a failed command.\n *\n * `process.stdin.isTTY` is the same question `init`'s dashboard asks before it offers a\n * prompt — is there a person here — because that is exactly what \"whose browser is this\"\n * means.\n */\n private async handToBrowser(id: string): Promise<void> {\n this.logSuccess(`Shared as ${id}`);\n for (const destination of sharedConfigDestinations(id)) {\n this.log(destination);\n }\n\n if (!process.stdin.isTTY) return;\n\n const opened = await openUrl(editorConfigUrl(id));\n if (!opened.ok) this.warn(opened.error);\n }\n\n /**\n * The load below, behind a spinner that comes down whichever way the await ends — all\n * three of `loadContext`'s refusals are raised while it is mounted.\n */\n private async loadContextUnderSpinner(setupMarketplace?: string): Promise<EditContext> {\n return awaitUnderSpinner(STATUS_MESSAGES.LOADING_SKILLS, () =>\n this.loadContext(setupMarketplace),\n );\n }\n\n /**\n * @param setupMarketplace - What `init --marketplace` named for the project setup this run\n * continues. Absent, the catalogue is the one the installation stored.\n */\n private async loadContext(setupMarketplace?: string): Promise<EditContext> {\n const detected = await detectProject();\n if (!detected) {\n this.error(ERROR_MESSAGES.NO_INSTALLATION, {\n exit: EXIT_CODES.ERROR,\n });\n }\n const { installation, config: projectConfig } = detected;\n\n // The detected installation's own root, which is what this run READS: the source it stored,\n // and the plugins registered against it. Every WRITE goes to `EditRoot.dir` instead, and the\n // two are the same directory unless `--project-setup` is promoting this one to a project.\n const projectDir = installation.projectDir;\n\n let sourceResult: SourceLoadResult;\n let startupMessages: StartupMessage[] = [];\n try {\n // `edit` reads the marketplace the installation stored, unless this run is the project setup\n // an `init --marketplace` routed here — a new installation, made from what that named.\n const loaded = await loadSource({\n projectDir,\n ...(setupMarketplace !== undefined && { sourceFlag: setupMarketplace }),\n captureStartupMessages: true,\n });\n sourceResult = loaded.sourceResult;\n startupMessages = loaded.startupMessages;\n\n const sourceInfo = sourceResult.isLocal ? \"local\" : sourceResult.sourceConfig.sourceOrigin;\n startupMessages.push({\n level: \"info\",\n text: `Loaded ${plural(Object.keys(matrix.skills).length, \"skill\")} (${sourceInfo})`,\n });\n } catch (error) {\n this.handleError(error);\n }\n\n let currentSkillIds: SkillId[];\n try {\n const discoveredSkills = await discoverAllPluginSkills(projectDir);\n const pluginSkillIds = typedKeys(discoveredSkills);\n\n // Merge plugin-discovered skills with config skills (catches local skills and\n // global-scoped plugins that discoverAllPluginSkills doesn't find).\n // Exclude skills marked as excluded — they should not appear as selected in the build step.\n // They are still preserved in skillConfigs via installedSkillConfigs for info panel/confirm step.\n const excludedConfigIds = new Set(\n projectConfig?.skills.filter((s) => s.excluded).map((s) => s.id) ?? [],\n );\n const configSkillIds =\n projectConfig?.skills.filter((s) => !s.excluded).map((s) => s.id) ?? [];\n const filteredPluginSkillIds = pluginSkillIds.filter((id) => !excludedConfigIds.has(id));\n const mergedIds = new Set<SkillId>([...filteredPluginSkillIds, ...configSkillIds]);\n currentSkillIds = [...mergedIds];\n\n startupMessages.push({\n level: \"info\",\n text: `Found ${plural(currentSkillIds.length, \"installed skill\")}`,\n });\n } catch (error) {\n this.handleError(error);\n }\n\n return {\n installation,\n projectConfig,\n projectDir,\n sourceResult,\n startupMessages,\n currentSkillIds,\n ...(setupMarketplace !== undefined &&\n sourceResult.marketplace !== undefined && { setupMarketplace: sourceResult.marketplace }),\n };\n }\n\n private async runEditWizard(\n context: EditContext,\n editRoot: EditRoot,\n ): Promise<WizardResultV2 | null> {\n const { projectConfig, currentSkillIds } = context;\n const selectedAgents = projectConfig?.agents && activeAgentNames(projectConfig.agents);\n\n return runWizardSession({\n hydrate: {\n initialStep: \"build\",\n ...(projectConfig?.selectedDomains !== undefined && {\n initialDomains: projectConfig.selectedDomains,\n }),\n ...(selectedAgents !== undefined && { initialAgents: selectedAgents }),\n installedSkillIds: currentSkillIds,\n ...(projectConfig?.skills !== undefined && { installedSkillConfigs: projectConfig.skills }),\n ...(projectConfig?.agents !== undefined && { installedAgentConfigs: projectConfig.agents }),\n isEditingFromGlobalScope: editRoot.isGlobal,\n ...(context.setupMarketplace !== undefined && {\n setupMarketplace: context.setupMarketplace,\n }),\n },\n props: {\n version: this.config.version,\n initialAgents: selectedAgents,\n installedSkillIds: currentSkillIds,\n startupMessages: context.startupMessages,\n },\n onCancel: () => this.log(\"\\nEdit cancelled\"),\n clearTerminal: () => this.clearTerminal(),\n });\n }\n\n /**\n * Records, in the GLOBAL config, the install-mode migrations this run already performed\n * under `$HOME`.\n *\n * A project-context edit otherwise never writes global config (commit 403df46, \"never\n * modify global config from project-level operations\"), and `authoritativeScope: \"owned\"`\n * enforces that for the roster — an inherited global-active entry is read-only, so\n * `mergeGlobalConfigs` preserves it verbatim. That protection is correct for selection and\n * scope, but `executeMigration` resolves each skill's paths from ITS OWN scope: switching a\n * global-scoped skill's source has already copied it under `$HOME` (or deleted it) and\n * added/removed its user-scope plugin registration by the time the config is written.\n * Leaving the global config alone there protects nothing — it only makes the recorded\n * source contradict the filesystem and the plugin registry.\n *\n * So authority follows the work actually performed, and no further: only ids\n * `executeMigration` acted on this run are rewritten, and only their `origin` field. Global\n * entries this session merely displayed, re-scoped or deselected are untouched, as are\n * `marketplace`, `stack`, `agents` and every other registered project's view of them.\n *\n * Driving a global-scope migration from a project directory is NOT a supported flow, and this\n * method is no longer the thing that permits it. The wizard now refuses it at source: the two\n * bulk install-mode keys are withdrawn, and `setInstallMode` ignores a project-context call\n * against a global slot the hydration snapshot owns — the same authority the Sources grid\n * already enforced by rendering that row inert. What still reaches here is the residue that\n * authority leaves legitimate: a mode change committed on the project half of a `[P][G]` pair\n * and then carried to global scope by a P->G collapse (`s`) in the same session. The entry is\n * the project's own to configure at the moment it is configured, and global at the moment it\n * is written — so the migration is real, and the global config must record it.\n *\n * Runs BEFORE `writeConfigAndCompile`, so the global config written here is the one\n * the wizard write reloads, keeps (existing wins in `mergeGlobalConfigs`) and inlines\n * into the project config — both files then tell the same story. That second write\n * classifies as a no-op against what this one left on disk, so the fan-out below\n * happens once.\n *\n * The migrated `origin` decides the reference form a compiled agent emits, so every\n * OTHER registered project's config and agents are stale until this write fans out —\n * which is why it goes through the gate rather than straight to the file.\n */\n private async recordGlobalSourceMigrations(\n migratedSkillIds: Set<SkillId>,\n newSkills: SkillConfig[],\n editRoot: EditRoot,\n context: EditContext,\n ): Promise<void> {\n // A global-context edit writes the whole global config from the wizard result already.\n if (editRoot.isGlobal) return;\n\n const migratedSources = new Map(\n newSkills\n .filter((s) => migratedSkillIds.has(s.id) && isActiveAt(s, \"global\"))\n .map((s) => [s.id, s.origin] as const),\n );\n if (migratedSources.size === 0) return;\n\n try {\n const report = await mutateGlobal(\n { kind: \"migrate-skill-sources\", sources: migratedSources },\n {\n // The deps contract in config-gate/deps.ts declares\n // `() => Promise<MergedSkillsMatrix>`; this caller happens to have its\n // matrix in hand already.\n // eslint-disable-next-line @typescript-eslint/require-await -- deps contract\n loadMatrix: async () => context.sourceResult.matrix,\n loadAgents: async () => (await loadAgentDefs()).agents,\n },\n );\n this.reportFanOut(report);\n } catch (error) {\n // The migration itself already happened — the skill has been copied under $HOME or had\n // its user-scope registration moved. Only the record of it failed, so the disk and the\n // global config now describe different installations and nothing downstream will notice.\n this.reportIncompleteWork(\n `Could not record global origin change: ${getErrorMessage(error)}`,\n INCOMPLETE_WORK_RECOVERY.INSPECT_INSTALLATION,\n );\n }\n }\n\n private logChangeSummary(\n changes: AppliedChanges,\n newSkills: SkillConfig[],\n oldSkills: SkillConfig[],\n removalReasons: ReadonlyMap<SkillId, string>,\n ): void {\n const {\n addedSkills,\n removedSkills,\n addedAgents,\n removedAgents,\n sourceChanges,\n scopeChanges,\n agentScopeChanges,\n dualScopeSkillTransitions,\n dualScopeAgentTransitions,\n tuningChanges,\n reassignedAgents,\n rewrittenSkills,\n } = changes;\n\n this.log(`\\n${chalk.hex(CLI_COLORS.WHITE).bold(\"Changes:\")}`);\n for (const skillId of addedSkills) {\n const scope = newSkills.find((s) => s.id === skillId)?.scope;\n const scopeLabel = scope ? ` ${formatScopeTag(scope)}` : \"\";\n this.log(\n chalk.hex(CLI_COLORS.SUCCESS)(` + ${getSkillById(skillId).displayName}${scopeLabel}`),\n );\n }\n for (const skillId of removedSkills) {\n const scope = oldSkills.find((s) => s.id === skillId)?.scope;\n const scopeLabel = scope ? ` ${formatScopeTag(scope)}` : \"\";\n const reason = removalReasons.get(skillId);\n this.log(\n chalk.hex(CLI_COLORS.ERROR)(` - ${getSkillDisplayName(skillId)}${scopeLabel}`) +\n (reason ? chalk.hex(CLI_COLORS.NEUTRAL)(` (${reason})`) : \"\"),\n );\n }\n for (const agentName of addedAgents) {\n this.log(\n chalk.hex(CLI_COLORS.SUCCESS)(` + ${agentName}`) +\n chalk.hex(CLI_COLORS.NEUTRAL)(\" (agent)\"),\n );\n }\n for (const agentName of removedAgents) {\n this.log(\n chalk.hex(CLI_COLORS.ERROR)(` - ${agentName}`) + chalk.hex(CLI_COLORS.NEUTRAL)(\" (agent)\"),\n );\n }\n for (const [skillId, change] of sourceChanges) {\n const displayName = getSkillDisplayName(skillId);\n const fromLabel = formatSourceDisplayName(change.from);\n const toLabel = formatSourceDisplayName(change.to);\n this.log(\n chalk.hex(CLI_COLORS.WARNING)(` ~ ${displayName}`) +\n chalk.hex(CLI_COLORS.NEUTRAL)(` (${fromLabel} \\u2192 ${toLabel})`),\n );\n }\n for (const [skillId, change] of scopeChanges) {\n this.log(formatSkillScopeChangeLine(skillId, change, dualScopeSkillTransitions));\n }\n for (const [agentName, change] of agentScopeChanges) {\n this.log(formatAgentScopeChangeLine(agentName, change, dualScopeAgentTransitions));\n }\n // A retune moves no file, so without a line of its own it is a run that reports a heading and\n // nothing under it — which reads as the command having found nothing to do.\n for (const [agentName, change] of tuningChanges) {\n this.log(formatValueChangeLine(agentName, change, \"agent\"));\n }\n // A re-assignment moves no file either, and is the whole of a configuration that only gives a\n // sub-agent different skills.\n for (const agentName of reassignedAgents) {\n this.log(\n chalk.hex(CLI_COLORS.WARNING)(` ~ ${agentName}`) +\n chalk.hex(CLI_COLORS.NEUTRAL)(\" (agent: skills reassigned)\"),\n );\n }\n for (const skillId of rewrittenSkills) {\n this.log(\n chalk.hex(CLI_COLORS.WARNING)(` ~ ${getSkillDisplayName(skillId)}`) +\n chalk.hex(CLI_COLORS.NEUTRAL)(\" (skill: files rewritten)\"),\n );\n }\n this.log(\"\");\n }\n\n private async applyMigrations(\n changes: ConfigChanges,\n filteredResult: WizardResultV2,\n activeOldSkills: SkillConfig[],\n context: EditContext,\n editRoot: EditRoot,\n ): Promise<Set<SkillId>> {\n const migrationPlan = detectMigrations(\n withMaskedGlobalsRestored(activeOldSkills, changes.collapsedPairs),\n filteredResult.skills,\n );\n const migratedSkillIds = new Set([\n ...migrationPlan.toEject.map((m) => m.id),\n ...migrationPlan.toPlugin.map((m) => m.id),\n ]);\n if (migratedSkillIds.size === 0) return migratedSkillIds;\n\n if (migrationPlan.toEject.length > 0) {\n this.logModeSwitch(migrationPlan.toEject.length, INSTALL_MODE_DESCRIPTIONS.eject);\n }\n if (migrationPlan.toPlugin.length > 0) {\n this.logModeSwitch(migrationPlan.toPlugin.length, INSTALL_MODE_DESCRIPTIONS.plugin);\n // Installing a plugin needs the marketplace REGISTERED and up to date with the\n // Claude CLI — the same precondition `applyPluginChanges` and `applyScopeChanges`\n // establish. Without it `claude plugin install` rejects every ref against a stale\n // local copy. Runs before `executeMigration` so an unresolvable marketplace exits\n // while the ejected working copies are still intact. Eject-side plugin uninstalls\n // are diagnostic-only, so only plugin-install work demands this.\n await this.requireMarketplaceOrExit(\n context.sourceResult,\n \"migrate skills to plugin mode\",\n hostAt(editRoot.dir),\n );\n // The install itself happens inside `executeMigration`, which deletes each skill's\n // working copy the moment that skill's plugin is registered — so the banner is\n // announced here and the outcome reported below, through the same surface `init`\n // and the newly-added-skill path narrate an install with.\n this.announcePluginInstall();\n }\n\n const migrationResult = await executeMigration(\n migrationPlan,\n editRoot.dir,\n context.sourceResult,\n );\n\n for (const warning of migrationResult.warnings) {\n this.warn(warning);\n }\n\n // Reports what was copied and hard-errors on any failure, for the reason the plugin\n // direction does below: a skill whose local copy could not be written must not reach\n // `recordGlobalSourceMigrations` or `writeConfigAndCompile`, either of which would\n // persist `origin: \"eject\"` for a skill that has no copy on disk.\n if (migrationPlan.toEject.length > 0) {\n this.reportEjectCopies(migrationResult.ejectCopies);\n }\n\n // Reports what was installed and hard-errors on any failure: a migration whose\n // plugin could not be installed must not reach `recordGlobalSourceMigrations` or\n // `writeConfigAndCompile`, either of which would persist a marketplace `origin`\n // for a skill with no plugin registration.\n if (migrationPlan.toPlugin.length > 0) {\n this.reportPluginInstalls(migrationResult.pluginInstalls);\n }\n\n return migratedSkillIds;\n }\n\n /**\n * What the plugin→eject half copied, what it could not, and the refusal to continue past\n * a failure.\n *\n * The shape of `BaseCommand.reportPluginInstalls`, deliberately: the two directions of one\n * mode switch owe the user the same account, and the eject half having no structured\n * failure at all is what let a config record `origin: \"eject\"` for a skill whose copy was\n * refused. It stays private because `edit` is the only command that migrates a mode —\n * `init` installs, and has no old state to move.\n *\n * The count line is the same one `copyNewLocalSkills` prints, and names no destination:\n * the migration splits its copies between the project and $HOME by each skill's own scope,\n * so one directory would misname the other half.\n */\n private reportEjectCopies(result: EjectCopyResult): void {\n for (const item of result.failed) {\n this.warn(`Failed to copy ${item.id} for eject: ${item.error}`);\n }\n if (result.failed.length > 0) {\n this.error(ejectCopyFailureError(result.failed.length), { exit: EXIT_CODES.ERROR });\n }\n this.log(chalk.hex(CLI_COLORS.NEUTRAL)(localSkillsCopied(result.copied.length)));\n }\n\n /** Names what this run is switching, in the words `init` describes an install mode with. */\n private logModeSwitch(count: number, modeDescription: string): void {\n this.log(chalk.hex(CLI_COLORS.NEUTRAL)(`Switching ${count} skill(s) to ${modeDescription}`));\n }\n\n /**\n * The scope moves this edit made, on disk. A collapsed `[P][G]` pair is not one of them: its\n * project half is dropped or folded ({@link applyCollapsedPairs}), and moving every collapse is\n * what wrote a dropped copy over the global install.\n */\n private async applyScopeChanges(\n changes: ConfigChanges,\n filteredResult: WizardResultV2,\n context: EditContext,\n editRoot: EditRoot,\n ): Promise<void> {\n const scopeChanges = scopeMovesOf(changes);\n\n // Handle scope migrations (P->G or G->P) for eject-mode skills\n for (const [skillId, change] of scopeChanges) {\n const skillConfig = filteredResult.skills.find((s) => s.id === skillId);\n if (skillConfig?.origin === EJECT_SOURCE) {\n await migrateLocalSkillScope(skillId, change.from, editRoot.dir);\n }\n }\n\n // Plugin scope migrations require a marketplace.\n // Compute eligible migrations first; only resolve/demand marketplace when there are any.\n const hasPluginScopeChanges = [...scopeChanges.keys()].some((skillId) => {\n const skillConfig = filteredResult.skills.find((s) => s.id === skillId);\n return skillConfig && skillConfig.origin !== EJECT_SOURCE;\n });\n if (!hasPluginScopeChanges) return;\n\n const marketplace = await this.requireMarketplaceOrExit(\n context.sourceResult,\n \"migrate plugin skill scopes\",\n hostAt(editRoot.dir),\n );\n\n const pluginScopeResult = await migratePluginSkillScopes(\n scopeChanges,\n filteredResult.skills,\n marketplace,\n editRoot.dir,\n );\n // A scope migration INSTALLS the plugin at its new scope, so a failure here is not the\n // diagnostic an uninstall failure is: the skill is registered at neither scope while the\n // config is about to record the new one.\n for (const item of pluginScopeResult.failed) {\n this.reportIncompleteWork(\n `Failed to migrate plugin scope for ${item.id}: ${item.error}`,\n INCOMPLETE_WORK_RECOVERY.INSPECT_INSTALLATION,\n );\n }\n }\n\n /**\n * The project's own half of each `[P][G]` pair this edit collapsed. A Local copy `s` folded into\n * a Local global install moves there, edits included, replacing the global copy every project\n * reads. Every other half is removed at project scope and nowhere else: its ejected copy deleted,\n * or its project-scope plugin registration uninstalled.\n *\n * The global install's MODE is {@link applyMigrations}' to change, and it changes only when the\n * collapse carried a new install mode with it — a fold into a plugin installs the plugin there.\n *\n * The uninstall is diagnostic, as every plugin uninstall here is: the config no longer names the\n * registration, so one left behind is untidy rather than wrong.\n */\n private async applyCollapsedPairs(\n changes: ConfigChanges,\n filteredResult: WizardResultV2,\n context: EditContext,\n editRoot: EditRoot,\n ): Promise<void> {\n const [foldedCopies, removedPairs] = partition(changes.collapsedPairs, (pair) =>\n foldsItsCopyIntoGlobal(pair, filteredResult.skills),\n );\n const [ejectedHalves, pluginHalves] = partition(\n removedPairs.map(({ projectHalf }) => projectHalf),\n (half) => half.origin === EJECT_SOURCE,\n );\n\n for (const { projectHalf } of foldedCopies) {\n await foldLocalSkillIntoGlobal(editRoot.dir, projectHalf.id);\n }\n for (const half of ejectedHalves) {\n await deleteLocalSkill(editRoot.dir, half.id, half.scope);\n }\n await this.uninstallProjectPluginHalves(\n pluginHalves,\n context.sourceResult.marketplace,\n editRoot,\n );\n }\n\n /** The project-scope registrations of collapsed pairs' plugin halves, uninstalled and reported. */\n private async uninstallProjectPluginHalves(\n pluginHalves: SkillConfig[],\n marketplace: string | undefined,\n editRoot: EditRoot,\n ): Promise<void> {\n if (pluginHalves.length === 0) return;\n if (marketplace === undefined) {\n for (const half of pluginHalves) {\n this.warn(`Could not uninstall this project's plugin for ${half.id}: no marketplace`);\n }\n return;\n }\n\n const uninstallResult = await uninstallPluginSkills(\n pluginHalves.map((half) => half.id),\n pluginHalves,\n marketplace,\n editRoot.dir,\n );\n if (uninstallResult.uninstalled.length > 0) {\n this.log(\n chalk.hex(CLI_COLORS.NEUTRAL)(`Removed ${uninstallResult.uninstalled.length} plugin(s)`),\n );\n }\n for (const item of uninstallResult.failed) {\n this.warn(`Failed to uninstall plugin ${item.id}: ${item.error}`);\n }\n }\n\n private async applySourceChanges(\n changes: ConfigChanges,\n activeOldSkills: SkillConfig[],\n editRoot: EditRoot,\n migratedSkillIds: Set<SkillId>,\n ): Promise<void> {\n const { sourceChanges } = changes;\n\n // Handle remaining non-migration source changes (e.g., marketplace A -> marketplace B)\n for (const [skillId, change] of sourceChanges) {\n // Skip skills already handled by mode migration\n if (migratedSkillIds.has(skillId)) {\n continue;\n }\n if (change.from === EJECT_SOURCE) {\n const oldSkill = activeOldSkills.find((s) => s.id === skillId);\n await deleteLocalSkill(editRoot.dir, skillId, oldSkill?.scope);\n }\n }\n }\n\n private async applyPluginChanges(\n changes: ConfigChanges,\n filteredResult: WizardResultV2,\n activeOldSkills: SkillConfig[],\n context: EditContext,\n editRoot: EditRoot,\n ): Promise<void> {\n const { addedSkills, removedSkills } = changes;\n\n // Compute plugin-intent lists per-skill (ungated) — per-skill `origin` drives install mode.\n const addedPluginSkills = filteredResult.skills.filter(\n (s) => addedSkills.includes(s.id) && s.origin !== EJECT_SOURCE,\n );\n const removedPluginSkills = removedSkills.filter(\n (id) => activeOldSkills.find((s) => s.id === id)?.origin !== EJECT_SOURCE,\n );\n\n if (addedPluginSkills.length === 0 && removedPluginSkills.length === 0) return;\n\n const marketplace = await this.requireMarketplaceOrExit(\n context.sourceResult,\n \"install or uninstall plugin skills\",\n hostAt(editRoot.dir),\n );\n\n if (addedPluginSkills.length > 0) {\n await this.installPluginSkillsReported(\n addedPluginSkills,\n marketplace,\n editRoot.dir,\n context.sourceResult.matrix,\n );\n }\n\n if (removedPluginSkills.length > 0) {\n const uninstallResult = await uninstallPluginSkills(\n removedPluginSkills,\n activeOldSkills,\n marketplace,\n editRoot.dir,\n );\n if (uninstallResult.uninstalled.length > 0) {\n this.log(\n chalk.hex(CLI_COLORS.NEUTRAL)(`Removed ${uninstallResult.uninstalled.length} plugin(s)`),\n );\n }\n for (const item of uninstallResult.failed) {\n this.warn(`Failed to uninstall plugin ${item.id}: ${item.error}`);\n }\n }\n }\n\n private async copyNewLocalSkills(\n changes: ConfigChanges,\n filteredResult: WizardResultV2,\n context: EditContext,\n editRoot: EditRoot,\n ): Promise<void> {\n const { addedSkills } = changes;\n\n // Copy newly added local-source skills to .claude/skills/ (split by scope)\n const addedLocalSkills = filteredResult.skills.filter(\n (s) => addedSkills.includes(s.id) && s.origin === EJECT_SOURCE,\n );\n\n if (addedLocalSkills.length > 0) {\n const copyResult = await copyLocalSkills(\n addedLocalSkills,\n editRoot.dir,\n context.sourceResult,\n );\n this.log(chalk.hex(CLI_COLORS.NEUTRAL)(localSkillsCopied(copyResult.totalCopied)));\n }\n }\n\n private async removeDeletedLocalSkills(\n changes: ConfigChanges,\n activeOldSkills: SkillConfig[],\n editRoot: EditRoot,\n ): Promise<void> {\n const { removedSkills } = changes;\n\n // A fully-deselected eject-mode skill is a genuine uninstall — its copied directory under\n // the host's skills directory must be removed from the scope it was installed at. Plugin\n // removals are handled by applyPluginChanges; source-change (eject->marketplace) deletions by\n // applySourceChanges. deleteLocalSkill is a no-op when the directory is absent.\n for (const skillId of removedSkills) {\n const oldSkill = activeOldSkills.find((s) => s.id === skillId);\n if (oldSkill?.origin !== EJECT_SOURCE) continue;\n\n await deleteLocalSkill(editRoot.dir, skillId, oldSkill.scope);\n }\n }\n\n private async writeConfigAndCompile(\n result: WizardResultV2,\n context: EditContext,\n editRoot: EditRoot,\n authority: AuthoritativeScope,\n producer: EditSelection[\"producer\"],\n ): Promise<void> {\n // Load agent definitions — needed for both config-types.ts and recompilation\n let agentDefsResult: AgentDefs;\n try {\n agentDefsResult = await loadAgentDefs();\n } catch (error) {\n this.handleError(error);\n }\n\n // Persist wizard result to config.ts and config-types.ts (split by scope when in project context)\n //\n // A failed write is fatal, not a warning. Every mutation this run made — plugin\n // registrations, ejected copies, deleted working copies — has already landed on disk,\n // and config.ts is the only record of what they were for. Continuing past it into the\n // agent recompile left the registry, the config and `.claude/agents/` mutually\n // inconsistent and still reported success, which is the same silent-substitution defect\n // the plugin install path refuses.\n let configResult: ConfigWriteResult;\n try {\n configResult = await writeProjectConfig({\n wizardResult: result,\n sourceResult: context.sourceResult,\n projectDir: editRoot.dir,\n agentDefs: agentDefsResult,\n // A full `cc edit` pass is authoritative over the roster it owns, so deselected entries\n // are removed rather than union-preserved. `applyAuthority` decides\n // how much that is from the producer and the directory, and hands the same word to the\n // merger and to the global config the project branch of the gate commits.\n authoritativeScope: authority,\n });\n } catch (error) {\n this.error(`Could not update config: ${getErrorMessage(error)}`, {\n exit: EXIT_CODES.ERROR,\n });\n }\n\n this.reportUnassignedSkills(configResult.config, result.skills);\n\n try {\n const agentScopeMap = activeAgentScopeMap(result.agentConfigs);\n const { allSkills } = await discoverInstalledSkills(editRoot.dir);\n const compile = compilesGlobalScope(producer, editRoot, configResult.propagation)\n ? compileAgentsAllScopes\n : compileProjectScope;\n const compilationResult = await compile({\n projectDir: editRoot.dir,\n sourcePath: agentDefsResult.sourcePath,\n skills: allSkills,\n agentScopeMap,\n });\n\n const { compiled, rewritten, failed, warnings } = compilationResult;\n const summary = recompileSummary(\n rewritten.length,\n compiled.length - rewritten.length,\n RECOMPILE_SUBJECT,\n );\n\n if (failed.length > 0) {\n this.log(\n chalk.hex(CLI_COLORS.NEUTRAL)(summary) +\n chalk.hex(CLI_COLORS.WARNING)(` (${failed.length} failed)`),\n );\n for (const warning of warnings) {\n this.warn(warning);\n }\n // Recorded off `failed` rather than off the warnings just printed: `warnings` also\n // carries entries that are not failures, and the ending must not file those as work owed.\n this.recordIncompleteWork(agentsNotCompiled(failed), INCOMPLETE_WORK_RECOVERY.RECOMPILE);\n } else if (compiled.length > 0) {\n this.log(chalk.hex(CLI_COLORS.NEUTRAL)(summary));\n } else {\n this.log(chalk.hex(CLI_COLORS.NEUTRAL)(INFO_MESSAGES.NO_AGENTS_TO_RECOMPILE));\n }\n } catch (error) {\n // The config write above has already landed, and the recompile is the last step — so\n // there is nothing left to abort into. What is wrong is the silence: `.claude/agents/`\n // now describes the roster this edit replaced, and the run used to report success over it.\n this.reportIncompleteWork(\n `Agent recompilation failed: ${getErrorMessage(error)}`,\n INCOMPLETE_WORK_RECOVERY.RECOMPILE,\n );\n this.log(`You can manually recompile with '${CLI_INVOKE_COMMAND} compile'.`);\n }\n\n this.reportFanOut(configResult.propagation);\n }\n\n private async cleanupStaleAgentFiles(\n changes: ConfigChanges,\n oldAgents: AgentScopeConfig[],\n editRoot: EditRoot,\n ): Promise<void> {\n for (const removal of planStaleAgentRemovals(changes, oldAgents, editRoot.dir)) {\n const { failed } = await removeCompiledAgents(removal);\n\n // A compiled sub-agent this project no longer configures is still a sub-agent Claude Code\n // loads, so a removal that did not happen is a roster the edit did not actually change.\n for (const { name, error } of failed) {\n const agentPath = path.join(removal.agentsDir, `${name}.md`);\n this.reportIncompleteWork(\n `Could not remove agent file ${agentPath}: ${error}`,\n INCOMPLETE_WORK_RECOVERY.DELETE_AGENT_FILE,\n );\n }\n }\n }\n\n /**\n * What this host could not carry, once per run and after the last write: the lines `init` and\n * `compile` print, from {@link hostCompileNotices}, so `edit` cannot say something different\n * about the tree it just compiled.\n *\n * After {@link cleanupStaleAgentFiles}, because the question is about the tree as it now stands:\n * an edit that removed the project's last gated sub-agent must not count the file it deleted.\n *\n * Not on a run that owes work, which ends on that account instead: such a run may have left\n * nothing here to read, and a notice that threw over it would turn the run's\n * `COMPLETED_WITH_FAILURES` exit into an `ERROR`.\n */\n private async reportWhatThisHostCannotCarry(editRoot: EditRoot): Promise<void> {\n if (this.hasIncompleteWork) return;\n\n for (const notice of await hostCompileNotices(providerInUse(editRoot.dir), editRoot.dir)) {\n this.log(notice);\n }\n }\n\n private logCompletionSummary(_changes: ConfigChanges): void {\n // A run with work owed ends on the account below instead \\u2014 a tick over a partial apply is\n // the claim being withdrawn here, not an extra line beside it.\n if (this.hasIncompleteWork) return;\n\n this.log(`\\n${chalk.hex(CLI_COLORS.SUCCESS)(\"\\u2713 Done\")}\\n`);\n }\n}\n\n/** @internal Exported for testing */\nexport type ConfigChanges = {\n addedSkills: SkillId[];\n removedSkills: SkillId[];\n addedAgents: AgentName[];\n removedAgents: AgentName[];\n sourceChanges: Map<SkillId, { from: string; to: string }>;\n scopeChanges: Map<SkillId, ScopeChange>;\n agentScopeChanges: Map<AgentName, ScopeChange>;\n /**\n * Skill ids whose `scopeChanges` entry is a dual-scope add/remove — the project\n * half of a `[P][G]` pair was toggled while the global half persists — NOT a true\n * single-entry migration. It steers the completion summary, so a dual-scope addition\n * is not misreported as a `[G] → [P]` migration; the disk side of a removal is\n * `collapsedPairs`.\n */\n dualScopeSkillTransitions: Set<SkillId>;\n /**\n * The `[P][G]` pairs this edit collapsed — the removal half of `dualScopeSkillTransitions` —\n * each half as it stood before the edit.\n *\n * SPACE on the pair's row and `s` both collapse it, into an entry the config cannot tell apart,\n * and they mean different things, which the wizard result tells apart instead. SPACE DROPS the\n * project's own install, at project scope, and leaves the global one it masked as it is. `s`\n * FOLDS it into the global install for every project: a Local copy replaces the global copy, and\n * a half in another mode than the global install carries that mode to it. So `sourceChanges` and\n * the mode migrations measure a collapsed skill against `maskedGlobal`, never against the half.\n */\n collapsedPairs: CollapsedPair[];\n /** Agent equivalent of `dualScopeSkillTransitions`. */\n dualScopeAgentTransitions: Set<AgentName>;\n /**\n * Sub-agents whose TUNING changed — the model it runs on and the effort it reasons at — where\n * the roster itself is unchanged.\n *\n * Its own field rather than folded into `addedAgents`, because nothing downstream acts on it:\n * a retuned sub-agent installs nothing, uninstalls nothing and moves no file. It is recompiled,\n * which `writeConfigAndCompile` already does for the whole roster. What it changes is whether\n * this run believes it has anything to do at all — and a shared configuration whose entire\n * content is a retune used to read as no change, so the command reported none, wrote nothing,\n * and left both ends believing the retune had travelled.\n */\n tuningChanges: Map<AgentName, ValueChange>;\n};\n\n/** One field's before and after, as the summary prints them. */\ntype ValueChange = { from: string; to: string };\n\n/** A collapsed `[P][G]` pair, as the config held it before the edit. */\ntype CollapsedPair = {\n /** The project's own install: the half the collapse drops or folds. */\n projectHalf: SkillConfig;\n /** The global install the project half masked, as its tombstone recorded it. */\n maskedGlobal: SkillConfig;\n /** Whether `s` folded the half into the global install, rather than SPACE dropping it. */\n folded: boolean;\n};\n\n/** Full (tombstone-inclusive) entry lists used to classify dual-scope transitions. */\ntype FullScopeEntries = {\n newSkills: SkillConfig[];\n oldSkills: SkillConfig[];\n newAgents: AgentScopeConfig[];\n oldAgents: AgentScopeConfig[];\n};\n\n/**\n * @internal Exported for testing\n *\n * `oldConfig` / `wizardResult` carry the ACTIVE (tombstone-filtered) entries used\n * for add/remove/source/scope diffing. `fullEntries`, when provided, carries the\n * unfiltered lists (including excluded tombstones) used ONLY to tell a genuine\n * scope migration apart from a dual-scope add/remove. When omitted, every scope\n * change is treated as a migration (the pre-dual-scope behaviour).\n */\nexport function detectConfigChanges(\n oldConfig: ProjectConfig | null,\n wizardResult: WizardResultV2,\n fullEntries?: FullScopeEntries,\n): ConfigChanges {\n const oldSkillIds = oldConfig?.skills.map((s) => s.id) ?? [];\n const newSkillIds = wizardResult.skills.map((s) => s.id);\n const oldAgentNames = oldConfig?.agents.map((a) => a.name) ?? [];\n const newAgentNames = wizardResult.agentConfigs.map((a) => a.name);\n\n const oldSkillsById = indexBy(oldConfig?.skills ?? [], (s) => s.id);\n const oldAgentsByName = indexBy(oldConfig?.agents ?? [], (a) => a.name);\n\n const scopeChanges = detectPropertyChanges(\n wizardResult.skills,\n oldSkillsById,\n (s) => s.id,\n (s) => s.scope,\n );\n const agentScopeChanges = detectPropertyChanges(\n wizardResult.agentConfigs,\n oldAgentsByName,\n (a) => a.name,\n (a) => a.scope,\n );\n const dualScopeSkillTransitions = detectDualScopeTransitions(\n scopeChanges,\n fullEntries?.newSkills ?? [],\n fullEntries?.oldSkills ?? [],\n (s) => s.id,\n );\n const collapsedPairs = collapsedPairsOf(\n scopeChanges,\n dualScopeSkillTransitions,\n fullEntries?.oldSkills ?? [],\n wizardResult.foldedSkillIds ?? [],\n );\n\n return {\n addedSkills: difference(newSkillIds, oldSkillIds),\n removedSkills: difference(oldSkillIds, newSkillIds),\n addedAgents: difference(newAgentNames, oldAgentNames),\n removedAgents: difference(oldAgentNames, newAgentNames),\n sourceChanges: detectPropertyChanges(\n wizardResult.skills,\n indexBy(withMaskedGlobalsRestored(oldConfig?.skills ?? [], collapsedPairs), (s) => s.id),\n (s) => s.id,\n (s) => s.origin,\n ),\n scopeChanges,\n agentScopeChanges,\n dualScopeSkillTransitions,\n collapsedPairs,\n dualScopeAgentTransitions: detectDualScopeTransitions(\n agentScopeChanges,\n fullEntries?.newAgents ?? [],\n fullEntries?.oldAgents ?? [],\n (a) => a.name,\n ),\n tuningChanges: detectPropertyChanges(\n wizardResult.agentConfigs,\n oldAgentsByName,\n (a) => a.name,\n describeTuning,\n ),\n };\n}\n\n/** A sub-agent that names no model and no effort, which is most of them. */\nconst RESTING_TUNING = \"defaults\";\n\n/**\n * One sub-agent's tuning as a single line: everything about it that is neither its identity nor\n * its scope, in the order a reader meets it.\n *\n * Rendered to a sentence and compared as one, rather than field by field, because the diff and\n * the summary want the same answer — and a diff that can see a change it has no words for is a\n * change the person applying it is told nothing about.\n */\nfunction describeTuning(agent: AgentScopeConfig): string {\n const settings = [\n agent.model === undefined ? undefined : `model ${agent.model}`,\n agent.effort === undefined ? undefined : `effort ${agent.effort}`,\n ].filter((setting) => setting !== undefined);\n\n return settings.length === 0 ? RESTING_TUNING : settings.join(\", \");\n}\n\nfunction detectPropertyChanges<T, K extends string, V>(\n newItems: T[],\n oldByKey: Record<string, T>,\n getKey: (item: T) => K,\n getValue: (item: T) => V,\n): Map<K, { from: V; to: V }> {\n const changes = new Map<K, { from: V; to: V }>();\n for (const item of newItems) {\n const key = getKey(item);\n const old = oldByKey[key];\n if (old && getValue(old) !== getValue(item)) {\n changes.set(key, { from: getValue(old), to: getValue(item) });\n }\n }\n return changes;\n}\n\n/**\n * A scope change is a dual-scope transition (not a migration) when the canonical\n * dual-scope tombstone — an excluded global entry — sits alongside it:\n * - G→P add: the NEW state keeps a global tombstone, so the global install\n * survives and the project half was merely added.\n * - P→G remove: the OLD state held a global tombstone, so the pair was already\n * dual-scope and the project half was merely removed.\n * Either way the item occupied both scopes, so `[X] → [Y]` would misdescribe it.\n */\nfunction detectDualScopeTransitions<\n K extends string,\n T extends { scope: SkillScope; excluded?: boolean },\n>(scopeChanges: Map<K, ScopeChange>, fullNew: T[], fullOld: T[], getKey: (item: T) => K): Set<K> {\n const hasGlobalTombstone = (items: T[], key: K): boolean =>\n items.some((item) => getKey(item) === key && item.scope === \"global\" && item.excluded === true);\n\n const result = new Set<K>();\n for (const [key, change] of scopeChanges) {\n if (change.from === \"global\" && change.to === \"project\" && hasGlobalTombstone(fullNew, key)) {\n result.add(key);\n } else if (\n change.from === \"project\" &&\n change.to === \"global\" &&\n hasGlobalTombstone(fullOld, key)\n ) {\n result.add(key);\n }\n }\n return result;\n}\n\n/**\n * The removal half of the dual-scope transitions, as the pairs they collapsed: each P→G change\n * the old state's tombstone classified, with both halves read back out of that old state, and\n * whether `s` folded it.\n */\nfunction collapsedPairsOf(\n scopeChanges: Map<SkillId, ScopeChange>,\n dualScopeSkillTransitions: ReadonlySet<SkillId>,\n fullOldSkills: SkillConfig[],\n foldedSkillIds: readonly SkillId[],\n): CollapsedPair[] {\n return [...scopeChanges]\n .filter(([id, change]) => change.to === \"global\" && dualScopeSkillTransitions.has(id))\n .map(([id]) => ({\n projectHalf: oldHalfOf(fullOldSkills, id, (skill) => isActiveAt(skill, \"project\")),\n maskedGlobal: oldHalfOf(fullOldSkills, id, isGlobalTombstone),\n folded: foldedSkillIds.includes(id),\n }));\n}\n\n/**\n * Whether a collapse moves the project's copy into the global install: `s` folded a Local half,\n * and the global entry it became is Local too. A fold into a plugin installs the plugin instead,\n * and a drop removes the copy.\n */\nfunction foldsItsCopyIntoGlobal(pair: CollapsedPair, newSkills: SkillConfig[]): boolean {\n const { projectHalf, folded } = pair;\n const globalEntry = newSkills.find(\n (skill) => skill.id === projectHalf.id && isActiveAt(skill, \"global\"),\n );\n return folded && projectHalf.origin === EJECT_SOURCE && globalEntry?.origin === EJECT_SOURCE;\n}\n\n/** One half of a pair the old state held — present by construction, so a miss is a defect. */\nfunction oldHalfOf(\n fullOldSkills: SkillConfig[],\n id: SkillId,\n isHalf: (skill: SkillConfig) => boolean,\n): SkillConfig {\n const half = fullOldSkills.find((skill) => skill.id === id && isHalf(skill));\n if (half === undefined) {\n throw new Error(`The config before this edit holds no such half of the pair for '${id}'`);\n }\n return half;\n}\n\n/**\n * The pre-edit roster with each collapsed pair's project half replaced by the global install it\n * masked — what a collapsed skill's origin is measured against. The project half is removed, not\n * migrated, so the only install whose mode a collapse can change is the global one.\n */\nfunction withMaskedGlobalsRestored(\n oldSkills: SkillConfig[],\n collapsedPairs: CollapsedPair[],\n): SkillConfig[] {\n const maskedById = indexBy(\n collapsedPairs.map(({ maskedGlobal }) => maskedGlobal),\n (skill) => skill.id,\n );\n return oldSkills.map((skill) => {\n const masked = maskedById[skill.id];\n if (masked === undefined || skill.scope !== \"project\") return skill;\n return installRecordedBy(masked);\n });\n}\n\n/** The global install a tombstone masks, as the active entry it records. */\nfunction installRecordedBy(tombstone: SkillConfig): SkillConfig {\n const { excluded: _masked, ...install } = tombstone;\n return install;\n}\n\n/**\n * The scope changes that moved an install. A collapsed pair's change is not one: its project half\n * is dropped or folded into the global install it masked, which stays where it is.\n */\nfunction scopeMovesOf(changes: ConfigChanges): Map<SkillId, ScopeChange> {\n const collapsed = new Set(changes.collapsedPairs.map(({ projectHalf }) => projectHalf.id));\n return new Map([...changes.scopeChanges].filter(([id]) => !collapsed.has(id)));\n}\n\ntype StaleAgent = { name: AgentName; scope: SkillScope };\n\n/** Every scope a stale compiled agent can be sitting at. */\nconst STALE_AGENT_SCOPES = [\"project\", \"global\"] as const satisfies readonly SkillScope[];\n\n/** The scope a deselected agent was installed at, for one absent from the old roster. */\nconst UNRECORDED_AGENT_SCOPE: SkillScope = \"project\";\n\nfunction installedScope(name: AgentName, oldAgents: AgentScopeConfig[]): SkillScope {\n return oldAgents.find((agent) => agent.name === name)?.scope ?? UNRECORDED_AGENT_SCOPE;\n}\n\n/**\n * The compiled files an edit leaves stale, one removal per scope directory that\n * holds any: the project copy a P→G move superseded, plus every deselected agent\n * at the scope it was installed at.\n *\n * G→P moves are absent deliberately — that direction is an override, so the global\n * installation stays untouched and the project copy shadows it. A scope with\n * nothing to remove is absent too: only a directory this edit actually removed\n * from is a directory this edit may tidy.\n */\nfunction planStaleAgentRemovals(\n changes: ConfigChanges,\n oldAgents: AgentScopeConfig[],\n editRoot: string,\n): RemoveCompiledAgentsOptions[] {\n const supersededByGlobal = [...changes.agentScopeChanges]\n .filter(([, change]) => change.from !== \"global\")\n .map(([name]): StaleAgent => ({ name, scope: \"project\" }));\n\n const deselected = changes.removedAgents.map((name): StaleAgent => ({\n name,\n scope: installedScope(name, oldAgents),\n }));\n\n const stale = [...supersededByGlobal, ...deselected];\n const removalAtScope = (scope: SkillScope): RemoveCompiledAgentsOptions => ({\n agentsDir: resolveInstallPaths(editRoot, scope).agentsDir,\n agents: stale.filter((agent) => agent.scope === scope).map((agent) => agent.name),\n });\n\n return STALE_AGENT_SCOPES.map(removalAtScope).filter((removal) => removal.agents.length > 0);\n}\n\nfunction hasAnyChanges(changes: AppliedChanges): boolean {\n return (\n changes.reassignedAgents.length > 0 ||\n changes.rewrittenSkills.length > 0 ||\n changes.addedSkills.length > 0 ||\n changes.removedSkills.length > 0 ||\n changes.addedAgents.length > 0 ||\n changes.removedAgents.length > 0 ||\n changes.sourceChanges.size > 0 ||\n changes.scopeChanges.size > 0 ||\n changes.agentScopeChanges.size > 0 ||\n changes.tuningChanges.size > 0\n );\n}\n\n/** @internal Exported for testing */\nexport type PluginScopeMigrationResult = {\n migrated: SkillId[];\n failed: Array<{ id: SkillId; error: string }>;\n};\n\n/** @internal Exported for testing */\nexport async function migratePluginSkillScopes(\n scopeChanges: Map<SkillId, ScopeChange>,\n skills: Pick<SkillConfig, \"id\" | \"origin\">[],\n marketplace: string,\n projectDir: string,\n): Promise<PluginScopeMigrationResult> {\n const host = hostAt(projectDir);\n const migrated: SkillId[] = [];\n const failed: PluginScopeMigrationResult[\"failed\"] = [];\n\n for (const [skillId, change] of scopeChanges) {\n const skillConfig = skills.find((s) => s.id === skillId);\n if (!skillConfig || skillConfig.origin === EJECT_SOURCE) {\n continue;\n }\n\n const pluginRef = buildMarketplacePluginRef(skillId, marketplace);\n\n try {\n // global→project: keep the global registration, just add project scope.\n // The global plugin must remain for other projects.\n // project→global: uninstall the project-scope registration, install global.\n if (change.from === \"project\") {\n await host.uninstallPlugin(pluginRef, \"project\", projectDir);\n }\n await host.installPlugin(pluginRef, change.to, projectDir);\n migrated.push(skillId);\n } catch (error) {\n failed.push({ id: skillId, error: getErrorMessage(error) });\n }\n }\n\n return { migrated, failed };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,UAAU;AAEjB,OAAO,WAAW;AAClB,SAAS,aAAa;AAEtB,SAAS,YAAY,SAAS,iBAAiB;AAq+BzC;AA10BN,IAAM,oBAAoB;AAO1B,SAAS,0BAA0B,aAAqB,IAAwB;AAC9E,QAAM,QAAQ,OAAO;AACrB,QAAM,SAAS,QAAQ,MAAM;AAC7B,QAAM,QAAQ,QAAQ,WAAW,UAAU,WAAW;AACtD,SAAO,MAAM,IAAI,KAAK,EAAE,KAAK,MAAM,IAAI,WAAW,MAAM;AAC1D;AAOA,SAAS,2BACP,SACA,QACA,2BACQ;AACR,QAAM,cAAc,oBAAoB,OAAO;AAC/C,MAAI,0BAA0B,IAAI,OAAO,GAAG;AAC1C,WAAO,0BAA0B,aAAa,OAAO,EAAE;AAAA,EACzD;AAEA,QAAM,oBAAoB,OAAO,SAAS,YAAY,OAAO,OAAO;AACpE,QAAM,SAAS,oBAAoB,MAAM;AACzC,QAAM,QAAQ,oBAAoB,WAAW,UAAU,WAAW;AAClE,SACE,MAAM,IAAI,KAAK,EAAE,KAAK,MAAM,IAAI,WAAW,EAAE,IAC7C,MAAM,IAAI,WAAW,OAAO,EAAE,WAAW,MAAM,CAAC;AAEpD;AAQA,SAAS,2BACP,WACA,QACA,2BACQ;AACR,QAAM,cAAc,MAAM,IAAI,WAAW,OAAO,EAAE,UAAU;AAC5D,MAAI,0BAA0B,IAAI,SAAS,GAAG;AAC5C,WAAO,0BAA0B,WAAW,OAAO,EAAE,IAAI;AAAA,EAC3D;AA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K,EAAE,IAAI,SAAS,OAAO,gBAAgB,KAAK,EAAE,CAAC;AAAA,IAC5D;AAAA,EACF;AAEA,SAAO,EAAE,UAAU,OAAO;AAC5B;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../src/cli/commands/edit.tsx"],"sourcesContent":["import path from \"path\";\n\nimport chalk from \"chalk\";\nimport { Flags } from \"@oclif/core\";\n\nimport { difference, indexBy, partition } from \"remeda\";\n\nimport { BaseCommand } from \"../base-command.js\";\nimport { type WizardResultV2 } from \"../components/wizard/wizard.js\";\nimport { runWizardSession } from \"../components/wizard/run-wizard-session.js\";\nimport {\n CLI_INVOKE_COMMAND,\n CLI_COLORS,\n EDIT_PROJECT_SETUP_FLAG,\n EDIT_PROJECT_SETUP_MARKETPLACE_FLAG,\n EJECT_SOURCE,\n editorConfigUrl,\n formatSourceDisplayName,\n} from \"../consts.js\";\nimport {\n detectProject,\n loadSource,\n sayCapturedWarnings,\n copyLocalSkills,\n uninstallPluginSkills,\n loadAgentDefs,\n type AgentDefs,\n writeProjectConfig,\n type ConfigWriteResult,\n compileAgentsAllScopes,\n compileProjectScope,\n discoverInstalledSkills,\n removeCompiledAgents,\n type RemoveCompiledAgentsOptions,\n} from \"../lib/operations/index.js\";\nimport { awaitUnderSpinner } from \"../components/common/spinner.js\";\nimport { EXIT_CODES } from \"../lib/exit-codes.js\";\nimport {\n type EjectCopyResult,\n type Installation,\n detectMigrations,\n ejectCopyFailureError,\n executeMigration,\n holdsItsOwnInstallation,\n isHomeDirectory,\n resolveInstallPaths,\n INSTALL_MODE_DESCRIPTIONS,\n} from \"../lib/installation/index.js\";\nimport {\n applyMigratedGlobalSources,\n movedGlobalAgentInputs,\n mutateGlobal,\n type GateReport,\n} from \"../lib/config-gate/index.js\";\nimport { matrix, getSkillById, getSkillDisplayName } from \"../lib/matrix/matrix-provider\";\nimport { type AuthoritativeScope } from \"../lib/configuration/index.js\";\nimport {\n activeAgentNames,\n activeAgentScopeMap,\n isActiveAt,\n isGlobalTombstone,\n} from \"../lib/configuration/scope-predicates.js\";\nimport type { SourceLoadResult } from \"../lib/loading/index.js\";\nimport { discoverAllPluginSkills, buildMarketplacePluginRef } from \"../lib/plugins/index.js\";\nimport {\n deleteLocalSkill,\n foldLocalSkillIntoGlobal,\n migrateLocalSkillScope,\n unresolvedSkillRemovalReasons,\n} from \"../lib/skills/index.js\";\nimport type {\n SkillId,\n SkillConfig,\n AgentName,\n AgentScopeConfig,\n MergedSkillsMatrix,\n ProjectConfig,\n SkillScope,\n} from \"../types/index.js\";\nimport {\n seedPayloadForInstallation,\n skillsAuthoredHere,\n} from \"../lib/seed/installation-payload.js\";\nimport { publishSeedConfig } from \"../lib/seed/publish-seed.js\";\nimport { fetchSeedConfig } from \"../lib/seed/fetch-seed.js\";\nimport {\n carriedSkillsThatDiffer,\n registerExternalSkills,\n writeExternalSkills,\n type ExternalSkillInstall,\n} from \"../lib/seed/external-skills.js\";\nimport { seedToWizardResult, type SeedMapping } from \"../lib/seed/seed-to-wizard.js\";\nimport {\n arrivalLines,\n arrivalsByScope,\n notInstalledGlobally,\n readInstalledGlobal,\n reconcileSharedConfig,\n restoreInstalledGlobal,\n sameAssignments,\n skillLabel,\n withUnplaceableAssignees,\n type Arrivals,\n type HeldGlobal,\n type KeptFromRoundTrip,\n type UnassignedRow,\n} from \"../lib/seed/seed-apply.js\";\nimport {\n RemovalPlanConfirm,\n type RemovalPlanSection,\n} from \"../components/common/removal-plan-confirm.js\";\nimport { promptConfirm } from \"../components/common/prompt-confirm.js\";\nimport { hostAt } from \"../lib/hosts/host-for.js\";\nimport { hostCompileNotices } from \"../lib/hosts/host-compile-notices.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 { openUrl } from \"../utils/open-url.js\";\nimport { plural } from \"../utils/string.js\";\nimport { getErrorMessage } from \"../utils/errors.js\";\nimport { type StartupMessage } from \"../utils/logger.js\";\nimport {\n INCOMPLETE_WORK_RECOVERY,\n ERROR_MESSAGES,\n INFO_MESSAGES,\n SHARED_CONFIG_APPLY,\n STATUS_MESSAGES,\n agentsNotCompiled,\n applySharedConfigHere,\n authoredHereKept,\n carriedSkillsWritten,\n keptAsInstalledGlobally,\n keptUnassigned,\n localSkillsCopied,\n nothingInstalledToApplyTo,\n projectCopyRemoved,\n recompileSummary,\n sharedConfigDestinations,\n sharedConfigNeedsTerminal,\n skippedUnknownAgents,\n skippedUnknownSkills,\n unplaceableKept,\n wizardNeedsTerminal,\n} from \"../utils/messages.js\";\nimport { formatScopeTag } from \"../lib/wizard/index.js\";\nimport { typedKeys } from \"../utils/typed-object.js\";\nimport type { SeedPayload } from \"@workspace/matrix/seed\";\n\ntype ScopeChange = { from: SkillScope; to: SkillScope };\n\n/** `edit` recompiles every scope it owns in one pass, so its summary has no scope word. */\nconst RECOMPILE_SUBJECT = \"agent\";\n\n/** A `[P][G]` pair's project half toggled: an arrow line would claim the global install moved. */\nfunction formatDualScopeTransition(displayName: string, to: SkillScope): string {\n const isAdd = to === \"project\";\n const prefix = isAdd ? \"+\" : \"-\";\n const color = isAdd ? CLI_COLORS.SUCCESS : CLI_COLORS.ERROR;\n return chalk.hex(color)(` ${prefix} ${displayName} [P]`);\n}\n\n/** A genuine `[G] → [P]` reads as an addition: the skill arrives in this project. */\nfunction formatSkillScopeChangeLine(\n skillId: SkillId,\n change: ScopeChange,\n dualScopeSkillTransitions: ReadonlySet<SkillId>,\n): string {\n const displayName = getSkillDisplayName(skillId);\n if (dualScopeSkillTransitions.has(skillId)) {\n return formatDualScopeTransition(displayName, change.to);\n }\n\n const isGlobalToProject = change.from === \"global\" && change.to === \"project\";\n const prefix = isGlobalToProject ? \"+\" : \"~\";\n const color = isGlobalToProject ? CLI_COLORS.SUCCESS : CLI_COLORS.WARNING;\n return (\n chalk.hex(color)(` ${prefix} ${displayName}`) +\n chalk.hex(CLI_COLORS.NEUTRAL)(scopeArrow(change))\n );\n}\n\n/** Unlike a skill, a moved agent is always a move, and only the dual-scope arm says `(agent)`. */\nfunction formatAgentScopeChangeLine(\n agentName: AgentName,\n change: ScopeChange,\n dualScopeAgentTransitions: ReadonlySet<AgentName>,\n): string {\n const agentSuffix = chalk.hex(CLI_COLORS.NEUTRAL)(\" (agent)\");\n if (dualScopeAgentTransitions.has(agentName)) {\n return formatDualScopeTransition(agentName, change.to) + agentSuffix;\n }\n\n return (\n chalk.hex(CLI_COLORS.WARNING)(` ~ ${agentName}`) +\n chalk.hex(CLI_COLORS.NEUTRAL)(scopeArrow(change))\n );\n}\n\nfunction scopeArrow(change: ScopeChange): string {\n return ` (${formatScopeTag(change.from)} \\u2192 ${formatScopeTag(change.to)})`;\n}\n\n/** Prints both values: a retune leaves nothing on disk to compare against. */\nfunction formatValueChangeLine(subject: string, change: ValueChange, kind: string): string {\n return (\n chalk.hex(CLI_COLORS.WARNING)(` ~ ${subject}`) +\n chalk.hex(CLI_COLORS.NEUTRAL)(` (${kind}: ${change.from} \\u2192 ${change.to})`)\n );\n}\n\n/** The resolved marketplace, or the source string when there is none. */\nfunction loadedSourceLabel(sourceResult: SourceLoadResult): string {\n return sourceResult.marketplace ?? sourceResult.sourceConfig.source;\n}\n\n/** @internal Re-exported for testing — the transform itself lives inside the gate. */\nexport { applyMigratedGlobalSources };\n\ntype EditContext = {\n installation: Installation;\n projectConfig: ProjectConfig | null;\n /** The detected installation's root — where this run READS its saved skills from. */\n projectDir: string;\n sourceResult: SourceLoadResult;\n startupMessages: StartupMessage[];\n currentSkillIds: SkillId[];\n /** What `init --marketplace` named for the project setup this run continues. */\n setupMarketplace?: string;\n};\n\n/** The one directory an `edit` run acts on, decided once and handed to every layer. */\ntype EditRoot = {\n /** Where this run writes, registers plugins and compiles into. */\n dir: string;\n /** {@link EditRoot.dir} IS the global installation: no project scope to offer. */\n isGlobal: boolean;\n /** Materialise {@link EditRoot.dir} as a project even with nothing to change. */\n isProjectSetup: boolean;\n};\n\n/**\n * The installation `detectProject` found is the only root with a config, so the only one this run\n * may write to. `--project-setup` (`cc init` here) declares this directory the one being set up.\n */\nfunction resolveEditRoot(\n installation: Installation,\n cwd: string,\n setupRequested: boolean,\n): EditRoot {\n const dir = setupRequested ? cwd : installation.projectDir;\n const isGlobal = isHomeDirectory(dir);\n return { dir, isGlobal, isProjectSetup: setupRequested && !isGlobal };\n}\n\n/**\n * Both producers yield one `WizardResultV2`, applied by one sequence. A shared configuration\n * destroys whatever it leaves out, so its removals are confirmed first.\n */\ntype EditSelection =\n | { producer: \"wizard\"; result: WizardResultV2 }\n | {\n producer: \"shared\";\n result: WizardResultV2;\n /** Statements naming what this run may not remove — rendered in the confirm. */\n kept: string[];\n /** Skills the configuration carries rather than names, written once it is approved. */\n carried: ExternalSkillInstall[];\n };\n\ntype SharedConfigPlan = {\n heading: string;\n sections: RemovalPlanSection[];\n statements: string[];\n};\n\n/**\n * From a project the global install is restored before the diff (`restoreInstalledGlobal`), so\n * every listed removal is the project's own; a `[P][G]` pair's id survives at global scope and is\n * not listed.\n */\nfunction sharedConfigPlan(changes: ConfigChanges, kept: string[]): SharedConfigPlan {\n const dropped = droppedProjectHalves(changes);\n const skillLines = [\n ...changes.removedSkills.map(skillLabel),\n ...dropped.skillIds.map(droppedSkillLine),\n ];\n const agentLines = [...changes.removedAgents, ...dropped.agentNames.map(projectCopyRemoved)];\n\n const sections = removalSections(skillLines, agentLines);\n return { heading: planHeading(sections), sections, statements: kept };\n}\n\nfunction droppedSkillLine(skillId: SkillId): string {\n return projectCopyRemoved(skillLabel(skillId));\n}\n\nfunction removalSections(skills: string[], agents: string[]): RemovalPlanSection[] {\n return [\n { label: SHARED_CONFIG_APPLY.SKILLS_HEADING, items: skills },\n { label: SHARED_CONFIG_APPLY.AGENTS_HEADING, items: agents },\n ].filter((section) => section.items.length > 0);\n}\n\ntype DroppedHalves = { skillIds: SkillId[]; agentNames: AgentName[] };\n\n/**\n * The diff records these as project-to-global scope changes, since the id survives at global\n * scope. A pair `s` folded is excluded: its copy moves rather than goes.\n */\nfunction droppedProjectHalves(changes: ConfigChanges): DroppedHalves {\n const droppedSkills = changes.collapsedPairs.filter((pair) => !pair.folded);\n const droppedAgents = [...changes.agentScopeChanges].filter(\n ([name, change]) => change.to === \"global\" && changes.dualScopeAgentTransitions.has(name),\n );\n\n return {\n skillIds: droppedSkills.map(({ projectHalf }) => projectHalf.id),\n agentNames: droppedAgents.map(([name]) => name),\n };\n}\n\n/** A configuration that only adds says so, and is still confirmed: it is applied whole. */\nfunction planHeading(sections: RemovalPlanSection[]): string {\n if (sections.length === 0) return SHARED_CONFIG_APPLY.NOTHING_REMOVED;\n return SHARED_CONFIG_APPLY.PREVIEW_HEADING;\n}\n\n/**\n * From a project a shared configuration holds the global install as installed, so the global pass\n * runs only when the write added something global sub-agents derive from. The wizard keeps both:\n * a mode switch it carried to global scope is recorded before this write.\n */\nfunction compilesGlobalScope(\n producer: EditSelection[\"producer\"],\n editRoot: EditRoot,\n written: GateReport,\n): boolean {\n if (editRoot.isGlobal || producer === \"wizard\") return true;\n return movedGlobalAgentInputs(written);\n}\n\n/**\n * Adds sub-agents whose skill rows change while the roster does not, which\n * {@link detectConfigChanges} cannot see.\n */\ntype PlannedChanges = ConfigChanges & { reassignedAgents: AgentName[] };\n\n/** Adds carried skills already installed here whose files the apply rewrote. */\ntype AppliedChanges = PlannedChanges & { rewrittenSkills: SkillId[] };\n\n/**\n * Only a producer that states rows has any: the wizard leaves `assignedStack` undefined. In a\n * project only the project's own sub-agents count; a global one keeps its installed rows\n * (`restoreInstalledGlobal`). A sub-agent already counted as added is not counted twice.\n */\nfunction withReassignments(\n changes: ConfigChanges,\n result: WizardResultV2,\n installedStack: ProjectConfig[\"stack\"],\n editRoot: EditRoot,\n): PlannedChanges {\n const { assignedStack } = result;\n if (assignedStack === undefined) return { ...changes, reassignedAgents: [] };\n\n const ownedHere = (agent: AgentScopeConfig): boolean =>\n editRoot.isGlobal || isActiveAt(agent, \"project\");\n const countedAsAdded = (agent: AgentScopeConfig): boolean =>\n changes.addedAgents.includes(agent.name);\n const rowsMoved = (agent: AgentScopeConfig): boolean =>\n !sameAssignments(assignedStack[agent.name], installedStack?.[agent.name]);\n\n const reassigned = result.agentConfigs.filter(\n (agent) => ownedHere(agent) && !countedAsAdded(agent) && rowsMoved(agent),\n );\n return { ...changes, reassignedAgents: reassigned.map((agent) => agent.name) };\n}\n\n/**\n * What the apply adds or changes, by landing scope. Excludes what is already installed as stated,\n * and the global copy a dropped project half leaves, which the plan lists as a removal.\n */\nfunction applyArrivals(changes: PlannedChanges, result: WizardResultV2): Arrivals {\n const changedSkills = new Set<SkillId>([\n ...changes.addedSkills,\n ...changes.sourceChanges.keys(),\n ...changes.scopeChanges.keys(),\n ]);\n const changedAgents = new Set<AgentName>([\n ...changes.addedAgents,\n ...changes.agentScopeChanges.keys(),\n ...changes.tuningChanges.keys(),\n ...changes.reassignedAgents,\n ]);\n const dropped = droppedProjectHalves(changes);\n const skillArrives = (skill: SkillConfig): boolean =>\n changedSkills.has(skill.id) && !dropped.skillIds.includes(skill.id);\n const agentArrives = (agent: AgentScopeConfig): boolean =>\n changedAgents.has(agent.name) && !dropped.agentNames.includes(agent.name);\n\n return arrivalsByScope(\n result.skills.filter(skillArrives),\n result.agentConfigs.filter(agentArrives),\n );\n}\n\n/** Disclosed rather than acted on, so nobody is left wondering why an agent kept a skill. */\nfunction keptStatements(kept: KeptFromRoundTrip): string[] {\n return [...authorshipStatement(kept), ...catalogueStatement(kept)];\n}\n\nfunction authorshipStatement(kept: KeptFromRoundTrip): string[] {\n if (kept.authoredSkillIds.length === 0) return [];\n return [authoredHereKept(kept.authoredSkillIds)];\n}\n\nfunction catalogueStatement(kept: KeptFromRoundTrip): string[] {\n if (kept.unplaceableSkillIds.length === 0) return [];\n return [unplaceableKept(kept.unplaceableSkillIds)];\n}\n\nfunction unassignedStatement(unassigned: UnassignedRow[]): string[] {\n if (unassigned.length === 0) return [];\n return [\n unassigned\n .map(({ skillId, agentName, category }) => keptUnassigned(skillId, agentName, category))\n .join(\"\\n\"),\n ];\n}\n\nfunction keptAsInstalledStatement(held: HeldGlobal, revisedCarried: SkillId[]): string[] {\n const skillIds = [...held.keptAsInstalled.skillIds, ...revisedCarried];\n const { agentNames } = held.keptAsInstalled;\n if (skillIds.length === 0 && agentNames.length === 0) return [];\n return [keptAsInstalledGlobally(skillIds, agentNames)];\n}\n\n/**\n * At the home root the run owns everything it loaded. In a project it owns only the project's\n * entries: the wizard cannot deselect a live global entry, and a shared configuration only adds to\n * the global install from a project (owner ruling 2026-10-02).\n */\nfunction applyAuthority(editRoot: EditRoot): AuthoritativeScope {\n return editRoot.isGlobal ? \"all\" : \"owned\";\n}\n\nexport default class Edit extends BaseCommand {\n static summary = \"Edit skills in the plugin\";\n static description = \"Modify the currently installed skills via interactive wizard\";\n\n static examples = [\n {\n description: \"Open the edit wizard\",\n command: \"<%= config.bin %> <%= command.id %>\",\n },\n {\n description: \"Open this installation in the editor instead of the wizard\",\n command: \"<%= config.bin %> <%= command.id %> --ui\",\n },\n {\n description: \"Apply a configuration built in the editor, by its id\",\n command: \"<%= config.bin %> <%= command.id %> --from <id>\",\n },\n ];\n\n static flags = {\n ui: Flags.boolean({\n description:\n \"Open agentsinc.sh/editor instead of the wizard — the id --from names, or this installation\",\n default: false,\n }),\n from: Flags.string({\n description:\n \"Apply a configuration shared from agentsinc.sh by its id, removing whatever it leaves out — from a project, only the project's own entries\",\n helpValue: \"<id>\",\n }),\n [EDIT_PROJECT_SETUP_FLAG]: Flags.boolean({\n description: \"Internal: this run continues an `init` project setup\",\n default: false,\n hidden: true,\n }),\n [EDIT_PROJECT_SETUP_MARKETPLACE_FLAG]: Flags.string({\n description: \"Internal: the marketplace `init --marketplace` named for that project setup\",\n hidden: true,\n dependsOn: [EDIT_PROJECT_SETUP_FLAG],\n }),\n provider: providerFlag(),\n };\n\n /** The exit code is decided once, after every path through `applyEdit`. */\n async run(): Promise<void> {\n await this.applyEdit();\n this.exitIfWorkIncomplete();\n }\n\n private async applyEdit(): Promise<void> {\n const { flags } = await this.parse(Edit);\n const cwd = process.cwd();\n\n // Above every installation check: opening a shared id needs no local state (owner ruling\n // 2026-08-24, pinned by `edit-ui-from.e2e.test.ts`).\n if (flags.ui && flags.from !== undefined) return this.openSharedInEditor(flags.from, cwd);\n\n // Before the wizard copies or installs anything.\n await refuseAnAmbiguousInstallation(cwd, \"edit\", providerNamedBy(flags.provider), (message) =>\n this.error(message, { exit: EXIT_CODES.INVALID_ARGS }),\n );\n\n // Before anything renders: an unreadable config is recreated, not edited.\n await this.ensureConfigReadable(cwd);\n await this.refuseUnofferablePlacements(cwd);\n\n // Replaces the wizard, so it runs above the source load.\n if (flags.ui) return this.openInEditor(cwd);\n\n // A destructive apply nobody can confirm must never become a yes; refused before the fetch.\n const payload =\n flags.from === undefined ? null : await this.fetchSharedConfigOrFail(flags.from);\n\n const context = await this.loadContextUnderSpinner(flags[EDIT_PROJECT_SETUP_MARKETPLACE_FLAG]);\n\n const editRoot = resolveEditRoot(context.installation, cwd, flags[EDIT_PROJECT_SETUP_FLAG]);\n\n // A skill whose metadata.yaml no longer describes it would be dropped from config.ts.\n await this.ensureSavedSkillsReadable(\n context.projectConfig?.skills ?? [],\n context.sourceResult.matrix,\n context.projectDir,\n );\n\n const selection = payload\n ? await this.selectionFromSharedConfig(payload, context, editRoot)\n : await this.selectionFromWizard(context, editRoot);\n if (!selection) this.error(\"Cancelled\", { exit: EXIT_CODES.CANCELLED });\n\n const { result } = selection;\n this.reportValidationErrors(result.validation);\n\n const activeNewSkills = result.skills.filter((s) => !s.excluded);\n const activeNewAgents = result.agentConfigs.filter((a) => !a.excluded);\n const activeOldSkills = (context.projectConfig?.skills ?? []).filter((s) => !s.excluded);\n const activeOldAgents = (context.projectConfig?.agents ?? []).filter((a) => !a.excluded);\n\n const filteredResult: WizardResultV2 = {\n ...result,\n skills: activeNewSkills,\n agentConfigs: activeNewAgents,\n };\n const filteredOldConfig: ProjectConfig | null = context.projectConfig\n ? { ...context.projectConfig, skills: activeOldSkills, agents: activeOldAgents }\n : null;\n\n const planned = withReassignments(\n detectConfigChanges(filteredOldConfig, filteredResult, {\n newSkills: result.skills,\n oldSkills: context.projectConfig?.skills ?? [],\n newAgents: result.agentConfigs,\n oldAgents: context.projectConfig?.agents ?? [],\n }),\n filteredResult,\n context.projectConfig?.stack,\n editRoot,\n );\n // After the diff, above every mutation and the no-change return: carried skills may still have\n // bytes to land when the roster is unchanged.\n const rewritten =\n selection.producer === \"shared\"\n ? await this.confirmAndWriteCarried(selection, planned, filteredResult)\n : [];\n const changes: AppliedChanges = {\n ...planned,\n rewrittenSkills: difference(rewritten, planned.addedSkills),\n };\n\n // One authority for the merger's config row and the global config the gate commits.\n const authority = applyAuthority(editRoot);\n\n if (!hasAnyChanges(changes)) {\n this.log(chalk.hex(CLI_COLORS.NEUTRAL)(\"No changes made.\"));\n // `cc init` in a project materialises it (config pair written, path registered) even with no\n // change; a bare `cc edit`, or a home-root setup, stays an inspection.\n if (!editRoot.isProjectSetup) return;\n await this.writeConfigAndCompile(result, context, editRoot, authority, selection.producer);\n await this.reportWhatThisHostCannotCarry(editRoot);\n this.logCompletionSummary(changes);\n return;\n }\n\n const removalReasons = await unresolvedSkillRemovalReasons(\n result.unresolvableSkillIds,\n activeOldSkills,\n context.projectDir,\n loadedSourceLabel(context.sourceResult),\n );\n this.logChangeSummary(\n changes,\n filteredResult.skills,\n filteredOldConfig?.skills ?? [],\n removalReasons,\n );\n const migratedSkillIds = await this.applyMigrations(\n changes,\n filteredResult,\n activeOldSkills,\n context,\n editRoot,\n );\n await this.recordGlobalSourceMigrations(\n migratedSkillIds,\n filteredResult.skills,\n editRoot,\n context,\n );\n await this.applyScopeChanges(changes, filteredResult, context, editRoot);\n await this.applyCollapsedPairs(changes, filteredResult, context, editRoot);\n await this.applySourceChanges(changes, activeOldSkills, editRoot, migratedSkillIds);\n await this.applyPluginChanges(changes, filteredResult, activeOldSkills, context, editRoot);\n await this.copyNewLocalSkills(changes, filteredResult, context, editRoot);\n await this.removeDeletedLocalSkills(changes, activeOldSkills, editRoot);\n await this.writeConfigAndCompile(result, context, editRoot, authority, selection.producer);\n await this.cleanupStaleAgentFiles(changes, activeOldAgents, editRoot);\n await this.reportWhatThisHostCannotCarry(editRoot);\n this.logCompletionSummary(changes);\n }\n\n private async selectionFromWizard(\n context: EditContext,\n editRoot: EditRoot,\n ): Promise<EditSelection | null> {\n // The installation refusals above work over a pipe; the mount is the first thing needing a TTY.\n if (!process.stdin.isTTY) {\n this.error(wizardNeedsTerminal(\"edit\"), { exit: EXIT_CODES.ERROR });\n }\n\n const result = await this.runEditWizard(context, editRoot);\n if (!result) return null;\n\n return { producer: \"wizard\", result };\n }\n\n /**\n * A shared configuration applies destructively, except for a skill written here (`forkedFrom`)\n * and an id this catalogue cannot place — both disclosed in the confirm. From a project the\n * global install is only added to (owner ruling 2026-10-02): entries the configuration omits or\n * states otherwise are held as installed, and only what it lacks arrives.\n */\n private async selectionFromSharedConfig(\n payload: SeedPayload,\n context: EditContext,\n editRoot: EditRoot,\n ): Promise<EditSelection> {\n const { matrix: sourceMatrix } = context.sourceResult;\n // Before the decode: a carried skill answers to no catalogue until it is seated.\n const carried = this.registerExternalSkillsOrFail(payload, sourceMatrix, editRoot.dir);\n const { result, skippedSkillIds, skippedAgentNames } = this.decodeSeedOrFail(\n payload,\n sourceMatrix,\n );\n\n // Before any skip is narrated; `init --from` asks the same at the same point.\n this.refuseProjectScopedContentAtHome(result, editRoot.dir);\n\n // Ids the decode could not place stay, as does a sub-agent only they carried in: a catalogue\n // limit is not an instruction to delete.\n const unplaceable = new Set(skippedSkillIds);\n const reconciled = reconcileSharedConfig({\n decoded: withUnplaceableAssignees(result, context.projectConfig, payload, unplaceable),\n installed: context.projectConfig,\n authoredHere: await this.readAuthoredHere(context.projectConfig, editRoot.dir),\n unplaceable,\n });\n const held = restoreInstalledGlobal(\n reconciled.result,\n editRoot.isGlobal ? null : await readInstalledGlobal(editRoot.dir),\n );\n const arrivingCarried = notInstalledGlobally(carried, held);\n\n await this.refuseSharedConfigBeforeAsking(\n held.result,\n arrivingCarried,\n editRoot.dir,\n context.sourceResult,\n );\n\n // Held globally, so not written from a project; named in the plan instead.\n const heldGlobally = difference(carried, arrivingCarried);\n const revisedGlobally = await carriedSkillsThatDiffer(heldGlobally);\n\n // Warnings the load buffered for a wizard this run never mounts.\n sayCapturedWarnings(context.startupMessages);\n if (skippedSkillIds.length > 0) this.warn(skippedUnknownSkills(skippedSkillIds));\n if (skippedAgentNames.length > 0) this.warn(skippedUnknownAgents(skippedAgentNames));\n\n return {\n producer: \"shared\",\n result: held.result,\n kept: [\n ...keptStatements(reconciled.kept),\n ...unassignedStatement(reconciled.unassigned),\n ...keptAsInstalledStatement(held, revisedGlobally),\n ],\n carried: arrivingCarried,\n };\n }\n\n /** Best-effort: an unreadable directory protects nothing and must not fail an apply. */\n private async readAuthoredHere(\n projectConfig: ProjectConfig | null,\n editRoot: string,\n ): Promise<Set<SkillId>> {\n if (!projectConfig) return new Set();\n\n try {\n return await skillsAuthoredHere(projectConfig, editRoot);\n } catch (error) {\n this.warn(`Could not tell which skills were written here: ${getErrorMessage(error)}`);\n return new Set();\n }\n }\n\n /** Refuses an empty directory or a missing terminal before spending a round trip. */\n private async fetchSharedConfigOrFail(id: string): Promise<SeedPayload> {\n if (!(await detectProject())) {\n this.error(nothingInstalledToApplyTo(id), { exit: EXIT_CODES.ERROR });\n }\n if (!process.stdin.isTTY) {\n this.error(sharedConfigNeedsTerminal(id), { exit: EXIT_CODES.ERROR });\n }\n\n this.log(`Fetching configuration ${id}...`);\n const fetched = await fetchSeedConfig(id);\n if (!fetched.ok) {\n this.error(fetched.error, { exit: EXIT_CODES.ERROR });\n }\n\n return fetched.payload;\n }\n\n private decodeSeedOrFail(payload: SeedPayload, sourceMatrix: MergedSkillsMatrix): SeedMapping {\n try {\n return seedToWizardResult(payload, sourceMatrix);\n } catch (error) {\n this.handleError(error);\n }\n }\n\n private registerExternalSkillsOrFail(\n payload: SeedPayload,\n sourceMatrix: MergedSkillsMatrix,\n projectDir: string,\n ): ExternalSkillInstall[] {\n try {\n return registerExternalSkills(payload, sourceMatrix, projectDir);\n } catch (error) {\n this.handleError(error);\n }\n }\n\n private async confirmAndWriteCarried(\n selection: Extract<EditSelection, { producer: \"shared\" }>,\n planned: PlannedChanges,\n result: WizardResultV2,\n ): Promise<SkillId[]> {\n await this.confirmSharedConfigOrCancel(planned, selection.kept, applyArrivals(planned, result));\n return this.writeCarriedSkills(selection.carried);\n }\n\n private async writeCarriedSkills(carried: ExternalSkillInstall[]): Promise<SkillId[]> {\n if (carried.length === 0) return [];\n\n const rewritten = await writeExternalSkills(carried);\n this.log(carriedSkillsWritten(carried.map((skill) => skill.id)));\n return rewritten;\n }\n\n /**\n * The plan and the apply read the same `ConfigChanges`, so what is approved is what is removed.\n * The arrivals print above it, so the question covers the whole of what a yes does.\n */\n private async confirmSharedConfigOrCancel(\n changes: ConfigChanges,\n kept: string[],\n arrivals: Arrivals,\n ): Promise<void> {\n const plan = sharedConfigPlan(changes, kept);\n for (const line of arrivalLines(arrivals)) {\n this.log(line);\n }\n\n const outcome = await promptConfirm(({ onConfirm, onCancel }) => (\n <RemovalPlanConfirm\n heading={plan.heading}\n sections={plan.sections}\n statements={plan.statements}\n message={SHARED_CONFIG_APPLY.CONFIRM}\n onConfirm={onConfirm}\n onCancel={onCancel}\n />\n ));\n if (outcome === \"confirmed\") return;\n\n this.log(\"\\nEdit cancelled\");\n this.error(\"Cancelled\", { exit: EXIT_CODES.CANCELLED });\n }\n\n /** `edit` rewrites the file, so it must not let a user curate a roster no command acts on. */\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 * Mints through `seedPayloadForInstallation`, as `share` does, so one project has one id. Touches\n * nothing on disk.\n */\n private async openInEditor(projectDir: string): Promise<void> {\n const prepared = await seedPayloadForInstallation(projectDir);\n if (!prepared.ok) {\n this.error(prepared.error, { exit: EXIT_CODES.ERROR });\n }\n\n this.log(`Opening ${prepared.skills} skill(s) across ${prepared.agents} sub-agent(s)...`);\n\n const published = await publishSeedConfig(prepared.payload);\n if (!published.ok) {\n this.error(published.error, { exit: EXIT_CODES.ERROR });\n }\n\n await this.handToBrowser(published.id);\n }\n\n /** Opens an id rather than applying it; `--from` without `--ui` is the destructive apply. */\n private async openSharedInEditor(id: string, cwd: string): Promise<void> {\n const url = editorConfigUrl(id);\n\n this.log(`Open it at ${url}`);\n this.log(applySharedConfigHere(id, await holdsItsOwnInstallation(cwd)));\n\n if (!process.stdin.isTTY) return;\n\n const opened = await openUrl(url);\n if (!opened.ok) this.warn(opened.error);\n }\n\n /** The link prints first: it works over a pipe, in CI and with no desktop. Opening is extra. */\n private async handToBrowser(id: string): Promise<void> {\n this.logSuccess(`Shared as ${id}`);\n for (const destination of sharedConfigDestinations(id)) {\n this.log(destination);\n }\n\n if (!process.stdin.isTTY) return;\n\n const opened = await openUrl(editorConfigUrl(id));\n if (!opened.ok) this.warn(opened.error);\n }\n\n private async loadContextUnderSpinner(setupMarketplace?: string): Promise<EditContext> {\n return awaitUnderSpinner(STATUS_MESSAGES.LOADING_SKILLS, () =>\n this.loadContext(setupMarketplace),\n );\n }\n\n private async loadContext(setupMarketplace?: string): Promise<EditContext> {\n const detected = await detectProject();\n if (!detected) {\n this.error(ERROR_MESSAGES.NO_INSTALLATION, {\n exit: EXIT_CODES.ERROR,\n });\n }\n const { installation, config: projectConfig } = detected;\n\n // The installation's own root, which this run READS; writes go to `EditRoot.dir`.\n const projectDir = installation.projectDir;\n\n let sourceResult: SourceLoadResult;\n let startupMessages: StartupMessage[] = [];\n try {\n const loaded = await loadSource({\n projectDir,\n ...(setupMarketplace !== undefined && { sourceFlag: setupMarketplace }),\n captureStartupMessages: true,\n });\n sourceResult = loaded.sourceResult;\n startupMessages = loaded.startupMessages;\n\n const sourceInfo = sourceResult.isLocal ? \"local\" : sourceResult.sourceConfig.sourceOrigin;\n startupMessages.push({\n level: \"info\",\n text: `Loaded ${plural(Object.keys(matrix.skills).length, \"skill\")} (${sourceInfo})`,\n });\n } catch (error) {\n this.handleError(error);\n }\n\n let currentSkillIds: SkillId[];\n try {\n const discoveredSkills = await discoverAllPluginSkills(projectDir);\n const pluginSkillIds = typedKeys(discoveredSkills);\n\n // Config skills catch local and global-scoped plugin skills discoverAllPluginSkills misses.\n // Excluded entries stay out of the selection; installedSkillConfigs still carries them.\n const excludedConfigIds = new Set(\n projectConfig?.skills.filter((s) => s.excluded).map((s) => s.id) ?? [],\n );\n const configSkillIds =\n projectConfig?.skills.filter((s) => !s.excluded).map((s) => s.id) ?? [];\n const filteredPluginSkillIds = pluginSkillIds.filter((id) => !excludedConfigIds.has(id));\n const mergedIds = new Set<SkillId>([...filteredPluginSkillIds, ...configSkillIds]);\n currentSkillIds = [...mergedIds];\n\n startupMessages.push({\n level: \"info\",\n text: `Found ${plural(currentSkillIds.length, \"installed skill\")}`,\n });\n } catch (error) {\n this.handleError(error);\n }\n\n return {\n installation,\n projectConfig,\n projectDir,\n sourceResult,\n startupMessages,\n currentSkillIds,\n ...(setupMarketplace !== undefined &&\n sourceResult.marketplace !== undefined && { setupMarketplace: sourceResult.marketplace }),\n };\n }\n\n private async runEditWizard(\n context: EditContext,\n editRoot: EditRoot,\n ): Promise<WizardResultV2 | null> {\n const { projectConfig, currentSkillIds } = context;\n const selectedAgents = projectConfig?.agents && activeAgentNames(projectConfig.agents);\n\n return runWizardSession({\n hydrate: {\n initialStep: \"build\",\n ...(projectConfig?.selectedDomains !== undefined && {\n initialDomains: projectConfig.selectedDomains,\n }),\n ...(selectedAgents !== undefined && { initialAgents: selectedAgents }),\n installedSkillIds: currentSkillIds,\n ...(projectConfig?.skills !== undefined && { installedSkillConfigs: projectConfig.skills }),\n ...(projectConfig?.agents !== undefined && { installedAgentConfigs: projectConfig.agents }),\n isEditingFromGlobalScope: editRoot.isGlobal,\n ...(context.setupMarketplace !== undefined && {\n setupMarketplace: context.setupMarketplace,\n }),\n },\n props: {\n version: this.config.version,\n initialAgents: selectedAgents,\n installedSkillIds: currentSkillIds,\n startupMessages: context.startupMessages,\n },\n onCancel: () => this.log(\"\\nEdit cancelled\"),\n clearTerminal: () => this.clearTerminal(),\n });\n }\n\n /**\n * Records in the GLOBAL config the install-mode migrations this run already performed under\n * `$HOME`, and only their `origin`: `executeMigration` resolves paths from each skill's own\n * scope, so leaving the record alone would contradict the disk and the plugin registry. The\n * reachable case is a mode change on a `[P][G]` pair's project half, carried to global by `s`.\n * Runs before `writeConfigAndCompile`, through the gate so every other project is refreshed.\n */\n private async recordGlobalSourceMigrations(\n migratedSkillIds: Set<SkillId>,\n newSkills: SkillConfig[],\n editRoot: EditRoot,\n context: EditContext,\n ): Promise<void> {\n // The wizard write already covers the global config.\n if (editRoot.isGlobal) return;\n\n const migratedSources = new Map(\n newSkills\n .filter((s) => migratedSkillIds.has(s.id) && isActiveAt(s, \"global\"))\n .map((s) => [s.id, s.origin] as const),\n );\n if (migratedSources.size === 0) return;\n\n try {\n const report = await mutateGlobal(\n { kind: \"migrate-skill-sources\", sources: migratedSources },\n {\n // config-gate/deps.ts declares `loadMatrix` async; the matrix is already in hand.\n // eslint-disable-next-line @typescript-eslint/require-await -- deps contract\n loadMatrix: async () => context.sourceResult.matrix,\n loadAgents: async () => (await loadAgentDefs()).agents,\n },\n );\n this.reportFanOut(report);\n } catch (error) {\n // The migration happened; only its record failed, so disk and global config now disagree.\n this.reportIncompleteWork(\n `Could not record global origin change: ${getErrorMessage(error)}`,\n INCOMPLETE_WORK_RECOVERY.INSPECT_INSTALLATION,\n );\n }\n }\n\n private logChangeSummary(\n changes: AppliedChanges,\n newSkills: SkillConfig[],\n oldSkills: SkillConfig[],\n removalReasons: ReadonlyMap<SkillId, string>,\n ): void {\n const {\n addedSkills,\n removedSkills,\n addedAgents,\n removedAgents,\n sourceChanges,\n scopeChanges,\n agentScopeChanges,\n dualScopeSkillTransitions,\n dualScopeAgentTransitions,\n tuningChanges,\n reassignedAgents,\n rewrittenSkills,\n } = changes;\n\n this.log(`\\n${chalk.hex(CLI_COLORS.WHITE).bold(\"Changes:\")}`);\n for (const skillId of addedSkills) {\n const scope = newSkills.find((s) => s.id === skillId)?.scope;\n const scopeLabel = scope ? ` ${formatScopeTag(scope)}` : \"\";\n this.log(\n chalk.hex(CLI_COLORS.SUCCESS)(` + ${getSkillById(skillId).displayName}${scopeLabel}`),\n );\n }\n for (const skillId of removedSkills) {\n const scope = oldSkills.find((s) => s.id === skillId)?.scope;\n const scopeLabel = scope ? ` ${formatScopeTag(scope)}` : \"\";\n const reason = removalReasons.get(skillId);\n this.log(\n chalk.hex(CLI_COLORS.ERROR)(` - ${getSkillDisplayName(skillId)}${scopeLabel}`) +\n (reason ? chalk.hex(CLI_COLORS.NEUTRAL)(` (${reason})`) : \"\"),\n );\n }\n for (const agentName of addedAgents) {\n this.log(\n chalk.hex(CLI_COLORS.SUCCESS)(` + ${agentName}`) +\n chalk.hex(CLI_COLORS.NEUTRAL)(\" (agent)\"),\n );\n }\n for (const agentName of removedAgents) {\n this.log(\n chalk.hex(CLI_COLORS.ERROR)(` - ${agentName}`) + chalk.hex(CLI_COLORS.NEUTRAL)(\" (agent)\"),\n );\n }\n for (const [skillId, change] of sourceChanges) {\n const displayName = getSkillDisplayName(skillId);\n const fromLabel = formatSourceDisplayName(change.from);\n const toLabel = formatSourceDisplayName(change.to);\n this.log(\n chalk.hex(CLI_COLORS.WARNING)(` ~ ${displayName}`) +\n chalk.hex(CLI_COLORS.NEUTRAL)(` (${fromLabel} \\u2192 ${toLabel})`),\n );\n }\n for (const [skillId, change] of scopeChanges) {\n this.log(formatSkillScopeChangeLine(skillId, change, dualScopeSkillTransitions));\n }\n for (const [agentName, change] of agentScopeChanges) {\n this.log(formatAgentScopeChangeLine(agentName, change, dualScopeAgentTransitions));\n }\n // A retune moves no file, so it needs its own line or the run reads as a no-op.\n for (const [agentName, change] of tuningChanges) {\n this.log(formatValueChangeLine(agentName, change, \"agent\"));\n }\n // Neither does a re-assignment.\n for (const agentName of reassignedAgents) {\n this.log(\n chalk.hex(CLI_COLORS.WARNING)(` ~ ${agentName}`) +\n chalk.hex(CLI_COLORS.NEUTRAL)(\" (agent: skills reassigned)\"),\n );\n }\n for (const skillId of rewrittenSkills) {\n this.log(\n chalk.hex(CLI_COLORS.WARNING)(` ~ ${getSkillDisplayName(skillId)}`) +\n chalk.hex(CLI_COLORS.NEUTRAL)(\" (skill: files rewritten)\"),\n );\n }\n this.log(\"\");\n }\n\n private async applyMigrations(\n changes: ConfigChanges,\n filteredResult: WizardResultV2,\n activeOldSkills: SkillConfig[],\n context: EditContext,\n editRoot: EditRoot,\n ): Promise<Set<SkillId>> {\n const migrationPlan = detectMigrations(\n withMaskedGlobalsRestored(activeOldSkills, changes.collapsedPairs),\n filteredResult.skills,\n );\n const migratedSkillIds = new Set([\n ...migrationPlan.toEject.map((m) => m.id),\n ...migrationPlan.toPlugin.map((m) => m.id),\n ]);\n if (migratedSkillIds.size === 0) return migratedSkillIds;\n\n if (migrationPlan.toEject.length > 0) {\n this.logModeSwitch(migrationPlan.toEject.length, INSTALL_MODE_DESCRIPTIONS.eject);\n }\n if (migrationPlan.toPlugin.length > 0) {\n this.logModeSwitch(migrationPlan.toPlugin.length, INSTALL_MODE_DESCRIPTIONS.plugin);\n // `claude plugin install` needs the marketplace registered and current. Before\n // `executeMigration`, so an unresolvable marketplace exits with the ejected copies intact.\n await this.requireMarketplaceOrExit(\n context.sourceResult,\n \"migrate skills to plugin mode\",\n hostAt(editRoot.dir),\n );\n // `executeMigration` installs, deleting each working copy as its plugin registers, so the\n // banner is announced here.\n this.announcePluginInstall();\n }\n\n const migrationResult = await executeMigration(\n migrationPlan,\n editRoot.dir,\n context.sourceResult,\n );\n\n for (const warning of migrationResult.warnings) {\n this.warn(warning);\n }\n\n // Hard-errors before anything records `origin: \"eject\"` for a skill with no copy on disk.\n if (migrationPlan.toEject.length > 0) {\n this.reportEjectCopies(migrationResult.ejectCopies);\n }\n\n // Hard-errors before anything records a marketplace `origin` for an unregistered skill.\n if (migrationPlan.toPlugin.length > 0) {\n this.reportPluginInstalls(migrationResult.pluginInstalls);\n }\n\n return migratedSkillIds;\n }\n\n /**\n * Mirrors `BaseCommand.reportPluginInstalls` for the plugin→eject half. The count line names no\n * destination: copies split between the project and $HOME by each skill's scope.\n */\n private reportEjectCopies(result: EjectCopyResult): void {\n for (const item of result.failed) {\n this.warn(`Failed to copy ${item.id} for eject: ${item.error}`);\n }\n if (result.failed.length > 0) {\n this.error(ejectCopyFailureError(result.failed.length), { exit: EXIT_CODES.ERROR });\n }\n this.log(chalk.hex(CLI_COLORS.NEUTRAL)(localSkillsCopied(result.copied.length)));\n }\n\n private logModeSwitch(count: number, modeDescription: string): void {\n this.log(chalk.hex(CLI_COLORS.NEUTRAL)(`Switching ${count} skill(s) to ${modeDescription}`));\n }\n\n /**\n * A collapsed `[P][G]` pair is not a move: its project half is dropped or folded\n * ({@link applyCollapsedPairs}).\n */\n private async applyScopeChanges(\n changes: ConfigChanges,\n filteredResult: WizardResultV2,\n context: EditContext,\n editRoot: EditRoot,\n ): Promise<void> {\n const scopeChanges = scopeMovesOf(changes);\n\n for (const [skillId, change] of scopeChanges) {\n const skillConfig = filteredResult.skills.find((s) => s.id === skillId);\n if (skillConfig?.origin === EJECT_SOURCE) {\n await migrateLocalSkillScope(skillId, change.from, editRoot.dir);\n }\n }\n\n // Only resolve the marketplace when a plugin scope migration exists.\n const hasPluginScopeChanges = [...scopeChanges.keys()].some((skillId) => {\n const skillConfig = filteredResult.skills.find((s) => s.id === skillId);\n return skillConfig && skillConfig.origin !== EJECT_SOURCE;\n });\n if (!hasPluginScopeChanges) return;\n\n const marketplace = await this.requireMarketplaceOrExit(\n context.sourceResult,\n \"migrate plugin skill scopes\",\n hostAt(editRoot.dir),\n );\n\n const pluginScopeResult = await migratePluginSkillScopes(\n scopeChanges,\n filteredResult.skills,\n marketplace,\n editRoot.dir,\n );\n // A migration installs at the new scope, so unlike an uninstall a failure is not diagnostic:\n // the skill is registered at neither scope.\n for (const item of pluginScopeResult.failed) {\n this.reportIncompleteWork(\n `Failed to migrate plugin scope for ${item.id}: ${item.error}`,\n INCOMPLETE_WORK_RECOVERY.INSPECT_INSTALLATION,\n );\n }\n }\n\n /**\n * A Local half `s` folded into a Local global install moves there, replacing the global copy.\n * Every other half is removed at project scope only. The global install's mode is\n * {@link applyMigrations}' to change. The uninstall is diagnostic, as every one here is.\n */\n private async applyCollapsedPairs(\n changes: ConfigChanges,\n filteredResult: WizardResultV2,\n context: EditContext,\n editRoot: EditRoot,\n ): Promise<void> {\n const [foldedCopies, removedPairs] = partition(changes.collapsedPairs, (pair) =>\n foldsItsCopyIntoGlobal(pair, filteredResult.skills),\n );\n const [ejectedHalves, pluginHalves] = partition(\n removedPairs.map(({ projectHalf }) => projectHalf),\n (half) => half.origin === EJECT_SOURCE,\n );\n\n for (const { projectHalf } of foldedCopies) {\n await foldLocalSkillIntoGlobal(editRoot.dir, projectHalf.id);\n }\n for (const half of ejectedHalves) {\n await deleteLocalSkill(editRoot.dir, half.id, half.scope);\n }\n await this.uninstallProjectPluginHalves(\n pluginHalves,\n context.sourceResult.marketplace,\n editRoot,\n );\n }\n\n private async uninstallProjectPluginHalves(\n pluginHalves: SkillConfig[],\n marketplace: string | undefined,\n editRoot: EditRoot,\n ): Promise<void> {\n if (pluginHalves.length === 0) return;\n if (marketplace === undefined) {\n for (const half of pluginHalves) {\n this.warn(`Could not uninstall this project's plugin for ${half.id}: no marketplace`);\n }\n return;\n }\n\n const uninstallResult = await uninstallPluginSkills(\n pluginHalves.map((half) => half.id),\n pluginHalves,\n marketplace,\n editRoot.dir,\n );\n if (uninstallResult.uninstalled.length > 0) {\n this.log(\n chalk.hex(CLI_COLORS.NEUTRAL)(`Removed ${uninstallResult.uninstalled.length} plugin(s)`),\n );\n }\n for (const item of uninstallResult.failed) {\n this.warn(`Failed to uninstall plugin ${item.id}: ${item.error}`);\n }\n }\n\n private async applySourceChanges(\n changes: ConfigChanges,\n activeOldSkills: SkillConfig[],\n editRoot: EditRoot,\n migratedSkillIds: Set<SkillId>,\n ): Promise<void> {\n const { sourceChanges } = changes;\n\n // Non-migration source changes, e.g. marketplace A -> marketplace B.\n for (const [skillId, change] of sourceChanges) {\n if (migratedSkillIds.has(skillId)) {\n continue;\n }\n if (change.from === EJECT_SOURCE) {\n const oldSkill = activeOldSkills.find((s) => s.id === skillId);\n await deleteLocalSkill(editRoot.dir, skillId, oldSkill?.scope);\n }\n }\n }\n\n private async applyPluginChanges(\n changes: ConfigChanges,\n filteredResult: WizardResultV2,\n activeOldSkills: SkillConfig[],\n context: EditContext,\n editRoot: EditRoot,\n ): Promise<void> {\n const { addedSkills, removedSkills } = changes;\n\n const addedPluginSkills = filteredResult.skills.filter(\n (s) => addedSkills.includes(s.id) && s.origin !== EJECT_SOURCE,\n );\n const removedPluginSkills = removedSkills.filter(\n (id) => activeOldSkills.find((s) => s.id === id)?.origin !== EJECT_SOURCE,\n );\n\n if (addedPluginSkills.length === 0 && removedPluginSkills.length === 0) return;\n\n const marketplace = await this.requireMarketplaceOrExit(\n context.sourceResult,\n \"install or uninstall plugin skills\",\n hostAt(editRoot.dir),\n );\n\n if (addedPluginSkills.length > 0) {\n await this.installPluginSkillsReported(\n addedPluginSkills,\n marketplace,\n editRoot.dir,\n context.sourceResult.matrix,\n );\n }\n\n if (removedPluginSkills.length > 0) {\n const uninstallResult = await uninstallPluginSkills(\n removedPluginSkills,\n activeOldSkills,\n marketplace,\n editRoot.dir,\n );\n if (uninstallResult.uninstalled.length > 0) {\n this.log(\n chalk.hex(CLI_COLORS.NEUTRAL)(`Removed ${uninstallResult.uninstalled.length} plugin(s)`),\n );\n }\n for (const item of uninstallResult.failed) {\n this.warn(`Failed to uninstall plugin ${item.id}: ${item.error}`);\n }\n }\n }\n\n private async copyNewLocalSkills(\n changes: ConfigChanges,\n filteredResult: WizardResultV2,\n context: EditContext,\n editRoot: EditRoot,\n ): Promise<void> {\n const { addedSkills } = changes;\n\n const addedLocalSkills = filteredResult.skills.filter(\n (s) => addedSkills.includes(s.id) && s.origin === EJECT_SOURCE,\n );\n\n if (addedLocalSkills.length > 0) {\n const copyResult = await copyLocalSkills(\n addedLocalSkills,\n editRoot.dir,\n context.sourceResult,\n );\n this.log(chalk.hex(CLI_COLORS.NEUTRAL)(localSkillsCopied(copyResult.totalCopied)));\n }\n }\n\n private async removeDeletedLocalSkills(\n changes: ConfigChanges,\n activeOldSkills: SkillConfig[],\n editRoot: EditRoot,\n ): Promise<void> {\n const { removedSkills } = changes;\n\n // A deselected eject skill is uninstalled at its scope; plugin removals and eject->marketplace\n // deletions belong to applyPluginChanges and applySourceChanges.\n for (const skillId of removedSkills) {\n const oldSkill = activeOldSkills.find((s) => s.id === skillId);\n if (oldSkill?.origin !== EJECT_SOURCE) continue;\n\n await deleteLocalSkill(editRoot.dir, skillId, oldSkill.scope);\n }\n }\n\n private async writeConfigAndCompile(\n result: WizardResultV2,\n context: EditContext,\n editRoot: EditRoot,\n authority: AuthoritativeScope,\n producer: EditSelection[\"producer\"],\n ): Promise<void> {\n let agentDefsResult: AgentDefs;\n try {\n agentDefsResult = await loadAgentDefs();\n } catch (error) {\n this.handleError(error);\n }\n\n // A failed write is fatal: every mutation has landed and config.ts is their only record.\n let configResult: ConfigWriteResult;\n try {\n configResult = await writeProjectConfig({\n wizardResult: result,\n sourceResult: context.sourceResult,\n projectDir: editRoot.dir,\n agentDefs: agentDefsResult,\n authoritativeScope: authority,\n });\n } catch (error) {\n this.error(`Could not update config: ${getErrorMessage(error)}`, {\n exit: EXIT_CODES.ERROR,\n });\n }\n\n this.reportUnassignedSkills(configResult.config, result.skills);\n\n try {\n const agentScopeMap = activeAgentScopeMap(result.agentConfigs);\n const { allSkills } = await discoverInstalledSkills(editRoot.dir);\n const compile = compilesGlobalScope(producer, editRoot, configResult.propagation)\n ? compileAgentsAllScopes\n : compileProjectScope;\n const compilationResult = await compile({\n projectDir: editRoot.dir,\n sourcePath: agentDefsResult.sourcePath,\n skills: allSkills,\n agentScopeMap,\n });\n\n const { compiled, rewritten, failed, warnings } = compilationResult;\n const summary = recompileSummary(\n rewritten.length,\n compiled.length - rewritten.length,\n RECOMPILE_SUBJECT,\n );\n\n if (failed.length > 0) {\n this.log(\n chalk.hex(CLI_COLORS.NEUTRAL)(summary) +\n chalk.hex(CLI_COLORS.WARNING)(` (${failed.length} failed)`),\n );\n for (const warning of warnings) {\n this.warn(warning);\n }\n // Off `failed`: `warnings` also carries non-failures.\n this.recordIncompleteWork(agentsNotCompiled(failed), INCOMPLETE_WORK_RECOVERY.RECOMPILE);\n } else if (compiled.length > 0) {\n this.log(chalk.hex(CLI_COLORS.NEUTRAL)(summary));\n } else {\n this.log(chalk.hex(CLI_COLORS.NEUTRAL)(INFO_MESSAGES.NO_AGENTS_TO_RECOMPILE));\n }\n } catch (error) {\n // The config already landed; a failed recompile must not end in silence.\n this.reportIncompleteWork(\n `Agent recompilation failed: ${getErrorMessage(error)}`,\n INCOMPLETE_WORK_RECOVERY.RECOMPILE,\n );\n this.log(`You can manually recompile with '${CLI_INVOKE_COMMAND} compile'.`);\n }\n\n this.reportFanOut(configResult.propagation);\n }\n\n private async cleanupStaleAgentFiles(\n changes: ConfigChanges,\n oldAgents: AgentScopeConfig[],\n editRoot: EditRoot,\n ): Promise<void> {\n for (const removal of planStaleAgentRemovals(changes, oldAgents, editRoot.dir)) {\n const { failed } = await removeCompiledAgents(removal);\n\n // A compiled sub-agent left behind is still loaded by Claude Code.\n for (const { name, error } of failed) {\n const agentPath = path.join(removal.agentsDir, `${name}.md`);\n this.reportIncompleteWork(\n `Could not remove agent file ${agentPath}: ${error}`,\n INCOMPLETE_WORK_RECOVERY.DELETE_AGENT_FILE,\n );\n }\n }\n }\n\n /**\n * The host notices `init` and `compile` print ({@link hostCompileNotices}), after\n * {@link cleanupStaleAgentFiles} so a deleted file is not counted. Skipped on a run that owes\n * work, whose tree may not be readable.\n */\n private async reportWhatThisHostCannotCarry(editRoot: EditRoot): Promise<void> {\n if (this.hasIncompleteWork) return;\n\n for (const notice of await hostCompileNotices(providerInUse(editRoot.dir), editRoot.dir)) {\n this.log(notice);\n }\n }\n\n private logCompletionSummary(_changes: ConfigChanges): void {\n if (this.hasIncompleteWork) return;\n\n this.log(`\\n${chalk.hex(CLI_COLORS.SUCCESS)(\"\\u2713 Done\")}\\n`);\n }\n}\n\n/** @internal Exported for testing */\nexport type ConfigChanges = {\n addedSkills: SkillId[];\n removedSkills: SkillId[];\n addedAgents: AgentName[];\n removedAgents: AgentName[];\n sourceChanges: Map<SkillId, { from: string; to: string }>;\n scopeChanges: Map<SkillId, ScopeChange>;\n agentScopeChanges: Map<AgentName, ScopeChange>;\n /** Dual-scope add/removes in `scopeChanges`, which the summary must not report as migrations. */\n dualScopeSkillTransitions: Set<SkillId>;\n /**\n * The `[P][G]` pairs this edit collapsed, as they stood before it. SPACE drops the project's own\n * install; `s` folds it into the global install. The config cannot tell them apart, so\n * `sourceChanges` and the mode migrations measure a collapsed skill against `maskedGlobal`.\n */\n collapsedPairs: CollapsedPair[];\n /** Agent equivalent of `dualScopeSkillTransitions`. */\n dualScopeAgentTransitions: Set<AgentName>;\n /** Retuned sub-agents (model, effort) with an unchanged roster: nothing moves, yet it changed. */\n tuningChanges: Map<AgentName, ValueChange>;\n};\n\ntype ValueChange = { from: string; to: string };\n\n/** A collapsed `[P][G]` pair, as the config held it before the edit. */\ntype CollapsedPair = {\n /** The project's own install: the half the collapse drops or folds. */\n projectHalf: SkillConfig;\n /** The global install the project half masked, as its tombstone recorded it. */\n maskedGlobal: SkillConfig;\n /** Whether `s` folded the half into the global install, rather than SPACE dropping it. */\n folded: boolean;\n};\n\n/** Full (tombstone-inclusive) entry lists used to classify dual-scope transitions. */\ntype FullScopeEntries = {\n newSkills: SkillConfig[];\n oldSkills: SkillConfig[];\n newAgents: AgentScopeConfig[];\n oldAgents: AgentScopeConfig[];\n};\n\n/**\n * @internal Exported for testing\n *\n * `fullEntries` carries the tombstone-inclusive lists, used only to tell a scope migration from a\n * dual-scope add/remove; without it every scope change is a migration.\n */\nexport function detectConfigChanges(\n oldConfig: ProjectConfig | null,\n wizardResult: WizardResultV2,\n fullEntries?: FullScopeEntries,\n): ConfigChanges {\n const oldSkillIds = oldConfig?.skills.map((s) => s.id) ?? [];\n const newSkillIds = wizardResult.skills.map((s) => s.id);\n const oldAgentNames = oldConfig?.agents.map((a) => a.name) ?? [];\n const newAgentNames = wizardResult.agentConfigs.map((a) => a.name);\n\n const oldSkillsById = indexBy(oldConfig?.skills ?? [], (s) => s.id);\n const oldAgentsByName = indexBy(oldConfig?.agents ?? [], (a) => a.name);\n\n const scopeChanges = detectPropertyChanges(\n wizardResult.skills,\n oldSkillsById,\n (s) => s.id,\n (s) => s.scope,\n );\n const agentScopeChanges = detectPropertyChanges(\n wizardResult.agentConfigs,\n oldAgentsByName,\n (a) => a.name,\n (a) => a.scope,\n );\n const dualScopeSkillTransitions = detectDualScopeTransitions(\n scopeChanges,\n fullEntries?.newSkills ?? [],\n fullEntries?.oldSkills ?? [],\n (s) => s.id,\n );\n const collapsedPairs = collapsedPairsOf(\n scopeChanges,\n dualScopeSkillTransitions,\n fullEntries?.oldSkills ?? [],\n wizardResult.foldedSkillIds ?? [],\n );\n\n return {\n addedSkills: difference(newSkillIds, oldSkillIds),\n removedSkills: difference(oldSkillIds, newSkillIds),\n addedAgents: difference(newAgentNames, oldAgentNames),\n removedAgents: difference(oldAgentNames, newAgentNames),\n sourceChanges: detectPropertyChanges(\n wizardResult.skills,\n indexBy(withMaskedGlobalsRestored(oldConfig?.skills ?? [], collapsedPairs), (s) => s.id),\n (s) => s.id,\n (s) => s.origin,\n ),\n scopeChanges,\n agentScopeChanges,\n dualScopeSkillTransitions,\n collapsedPairs,\n dualScopeAgentTransitions: detectDualScopeTransitions(\n agentScopeChanges,\n fullEntries?.newAgents ?? [],\n fullEntries?.oldAgents ?? [],\n (a) => a.name,\n ),\n tuningChanges: detectPropertyChanges(\n wizardResult.agentConfigs,\n oldAgentsByName,\n (a) => a.name,\n describeTuning,\n ),\n };\n}\n\nconst RESTING_TUNING = \"defaults\";\n\n/** Compared as a sentence, so the diff sees no change the summary has no words for. */\nfunction describeTuning(agent: AgentScopeConfig): string {\n const settings = [\n agent.model === undefined ? undefined : `model ${agent.model}`,\n agent.codexModel === undefined ? undefined : `codex model ${agent.codexModel}`,\n agent.effort === undefined ? undefined : `effort ${agent.effort}`,\n ].filter((setting) => setting !== undefined);\n\n return settings.length === 0 ? RESTING_TUNING : settings.join(\", \");\n}\n\nfunction detectPropertyChanges<T, K extends string, V>(\n newItems: T[],\n oldByKey: Record<string, T>,\n getKey: (item: T) => K,\n getValue: (item: T) => V,\n): Map<K, { from: V; to: V }> {\n const changes = new Map<K, { from: V; to: V }>();\n for (const item of newItems) {\n const key = getKey(item);\n const old = oldByKey[key];\n if (old && getValue(old) !== getValue(item)) {\n changes.set(key, { from: getValue(old), to: getValue(item) });\n }\n }\n return changes;\n}\n\n/**\n * A dual-scope transition, not a migration, when a global tombstone sits beside the change: G→P\n * keeps one in the new state, P→G had one in the old.\n */\nfunction detectDualScopeTransitions<\n K extends string,\n T extends { scope: SkillScope; excluded?: boolean },\n>(scopeChanges: Map<K, ScopeChange>, fullNew: T[], fullOld: T[], getKey: (item: T) => K): Set<K> {\n const hasGlobalTombstone = (items: T[], key: K): boolean =>\n items.some((item) => getKey(item) === key && item.scope === \"global\" && item.excluded === true);\n\n const result = new Set<K>();\n for (const [key, change] of scopeChanges) {\n if (change.from === \"global\" && change.to === \"project\" && hasGlobalTombstone(fullNew, key)) {\n result.add(key);\n } else if (\n change.from === \"project\" &&\n change.to === \"global\" &&\n hasGlobalTombstone(fullOld, key)\n ) {\n result.add(key);\n }\n }\n return result;\n}\n\n/** P→G dual-scope transitions as the pairs they collapsed, read from the old state. */\nfunction collapsedPairsOf(\n scopeChanges: Map<SkillId, ScopeChange>,\n dualScopeSkillTransitions: ReadonlySet<SkillId>,\n fullOldSkills: SkillConfig[],\n foldedSkillIds: readonly SkillId[],\n): CollapsedPair[] {\n return [...scopeChanges]\n .filter(([id, change]) => change.to === \"global\" && dualScopeSkillTransitions.has(id))\n .map(([id]) => ({\n projectHalf: oldHalfOf(fullOldSkills, id, (skill) => isActiveAt(skill, \"project\")),\n maskedGlobal: oldHalfOf(fullOldSkills, id, isGlobalTombstone),\n folded: foldedSkillIds.includes(id),\n }));\n}\n\n/** `s` folded a Local half into a Local global entry; a fold into a plugin installs it instead. */\nfunction foldsItsCopyIntoGlobal(pair: CollapsedPair, newSkills: SkillConfig[]): boolean {\n const { projectHalf, folded } = pair;\n const globalEntry = newSkills.find(\n (skill) => skill.id === projectHalf.id && isActiveAt(skill, \"global\"),\n );\n return folded && projectHalf.origin === EJECT_SOURCE && globalEntry?.origin === EJECT_SOURCE;\n}\n\n/** Present by construction, so a miss is a defect. */\nfunction oldHalfOf(\n fullOldSkills: SkillConfig[],\n id: SkillId,\n isHalf: (skill: SkillConfig) => boolean,\n): SkillConfig {\n const half = fullOldSkills.find((skill) => skill.id === id && isHalf(skill));\n if (half === undefined) {\n throw new Error(`The config before this edit holds no such half of the pair for '${id}'`);\n }\n return half;\n}\n\n/**\n * The pre-edit roster with each collapsed pair's project half replaced by the global install it\n * masked: the only install whose mode a collapse can change.\n */\nfunction withMaskedGlobalsRestored(\n oldSkills: SkillConfig[],\n collapsedPairs: CollapsedPair[],\n): SkillConfig[] {\n const maskedById = indexBy(\n collapsedPairs.map(({ maskedGlobal }) => maskedGlobal),\n (skill) => skill.id,\n );\n return oldSkills.map((skill) => {\n const masked = maskedById[skill.id];\n if (masked === undefined || skill.scope !== \"project\") return skill;\n return installRecordedBy(masked);\n });\n}\n\nfunction installRecordedBy(tombstone: SkillConfig): SkillConfig {\n const { excluded: _masked, ...install } = tombstone;\n return install;\n}\n\n/** Excludes collapsed pairs, whose global install stays where it is. */\nfunction scopeMovesOf(changes: ConfigChanges): Map<SkillId, ScopeChange> {\n const collapsed = new Set(changes.collapsedPairs.map(({ projectHalf }) => projectHalf.id));\n return new Map([...changes.scopeChanges].filter(([id]) => !collapsed.has(id)));\n}\n\ntype StaleAgent = { name: AgentName; scope: SkillScope };\n\nconst STALE_AGENT_SCOPES = [\"project\", \"global\"] as const satisfies readonly SkillScope[];\n\n/** For a deselected agent absent from the old roster. */\nconst UNRECORDED_AGENT_SCOPE: SkillScope = \"project\";\n\nfunction installedScope(name: AgentName, oldAgents: AgentScopeConfig[]): SkillScope {\n return oldAgents.find((agent) => agent.name === name)?.scope ?? UNRECORDED_AGENT_SCOPE;\n}\n\n/**\n * The project copy a P→G move superseded, plus every deselected agent at its installed scope. G→P\n * is an override, so the global install stays. Only scopes this edit removed from are tidied.\n */\nfunction planStaleAgentRemovals(\n changes: ConfigChanges,\n oldAgents: AgentScopeConfig[],\n editRoot: string,\n): RemoveCompiledAgentsOptions[] {\n const supersededByGlobal = [...changes.agentScopeChanges]\n .filter(([, change]) => change.from !== \"global\")\n .map(([name]): StaleAgent => ({ name, scope: \"project\" }));\n\n const deselected = changes.removedAgents.map((name): StaleAgent => ({\n name,\n scope: installedScope(name, oldAgents),\n }));\n\n const stale = [...supersededByGlobal, ...deselected];\n const removalAtScope = (scope: SkillScope): RemoveCompiledAgentsOptions => ({\n agentsDir: resolveInstallPaths(editRoot, scope).agentsDir,\n agents: stale.filter((agent) => agent.scope === scope).map((agent) => agent.name),\n });\n\n return STALE_AGENT_SCOPES.map(removalAtScope).filter((removal) => removal.agents.length > 0);\n}\n\nfunction hasAnyChanges(changes: AppliedChanges): boolean {\n return (\n changes.reassignedAgents.length > 0 ||\n changes.rewrittenSkills.length > 0 ||\n changes.addedSkills.length > 0 ||\n changes.removedSkills.length > 0 ||\n changes.addedAgents.length > 0 ||\n changes.removedAgents.length > 0 ||\n changes.sourceChanges.size > 0 ||\n changes.scopeChanges.size > 0 ||\n changes.agentScopeChanges.size > 0 ||\n changes.tuningChanges.size > 0\n );\n}\n\n/** @internal Exported for testing */\nexport type PluginScopeMigrationResult = {\n migrated: SkillId[];\n failed: Array<{ id: SkillId; error: string }>;\n};\n\n/** @internal Exported for testing */\nexport async function migratePluginSkillScopes(\n scopeChanges: Map<SkillId, ScopeChange>,\n skills: Pick<SkillConfig, \"id\" | \"origin\">[],\n marketplace: string,\n projectDir: string,\n): Promise<PluginScopeMigrationResult> {\n const host = hostAt(projectDir);\n const migrated: SkillId[] = [];\n const failed: PluginScopeMigrationResult[\"failed\"] = [];\n\n for (const [skillId, change] of scopeChanges) {\n const skillConfig = skills.find((s) => s.id === skillId);\n if (!skillConfig || skillConfig.origin === EJECT_SOURCE) {\n continue;\n }\n\n const pluginRef = buildMarketplacePluginRef(skillId, marketplace);\n\n try {\n // global→project: keep the global registration, just add project scope.\n // The global plugin must remain for other projects.\n // project→global: uninstall the project-scope registration, install global.\n if (change.from === \"project\") {\n await host.uninstallPlugin(pluginRef, \"project\", projectDir);\n }\n await host.installPlugin(pluginRef, change.to, projectDir);\n migrated.push(skillId);\n } catch (error) {\n failed.push({ id: skillId, error: getErrorMessage(error) });\n }\n }\n\n return { migrated, failed };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,UAAU;AAEjB,OAAO,WAAW;AAClB,SAAS,aAAa;AAEtB,SAAS,YAAY,SAAS,iBAAiB;AAoxBzC;AA9nBN,IAAM,oBAAoB;AAG1B,SAAS,0BAA0B,aAAqB,IAAwB;AAC9E,QAAM,QAAQ,OAAO;AACrB,QAAM,SAAS,QAAQ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"../chunk-
|
|
9
|
-
import "../chunk-
|
|
10
|
-
import "../chunk-
|
|
11
|
-
import "../chunk-
|
|
12
|
-
import "../chunk-
|
|
8
|
+
} from "../chunk-5JUQKGCP.js";
|
|
9
|
+
import "../chunk-TW35AEB4.js";
|
|
10
|
+
import "../chunk-GE7NUPMI.js";
|
|
11
|
+
import "../chunk-JIBCVXXL.js";
|
|
12
|
+
import "../chunk-3LZNY46H.js";
|
|
13
13
|
import {
|
|
14
14
|
providerFlag,
|
|
15
15
|
providerNamedBy,
|
|
16
16
|
refuseAnAmbiguousInstallation
|
|
17
|
-
} from "../chunk-
|
|
17
|
+
} from "../chunk-HR7TK2XW.js";
|
|
18
18
|
import {
|
|
19
19
|
BaseCommand,
|
|
20
20
|
EXIT_CODES
|
|
21
|
-
} from "../chunk-
|
|
22
|
-
import "../chunk-
|
|
23
|
-
import "../chunk-
|
|
21
|
+
} from "../chunk-H4ZKGGTE.js";
|
|
22
|
+
import "../chunk-VVRI35SK.js";
|
|
23
|
+
import "../chunk-CMJBKQUH.js";
|
|
24
24
|
import {
|
|
25
25
|
INCOMPLETE_WORK_RECOVERY,
|
|
26
26
|
INFO_MESSAGES,
|
|
@@ -39,15 +39,15 @@ import {
|
|
|
39
39
|
relativeConfigPath,
|
|
40
40
|
resolveSource,
|
|
41
41
|
sourceFolderInUse
|
|
42
|
-
} from "../chunk-
|
|
42
|
+
} from "../chunk-C2UISKIM.js";
|
|
43
43
|
import {
|
|
44
44
|
matrix
|
|
45
|
-
} from "../chunk-
|
|
45
|
+
} from "../chunk-NU2K5G54.js";
|
|
46
46
|
import {
|
|
47
47
|
DIRS,
|
|
48
48
|
LOCAL_SKILLS_PATH,
|
|
49
49
|
PROJECT_ROOT
|
|
50
|
-
} from "../chunk-
|
|
50
|
+
} from "../chunk-AG3ZVM3B.js";
|
|
51
51
|
import "../chunk-OI2H6M5I.js";
|
|
52
52
|
|
|
53
53
|
// src/cli/commands/eject.ts
|