agents-inc 0.170.1 → 0.170.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (163) hide show
  1. package/CHANGELOG.md +9 -0
  2. package/dist/{chunk-BMRUNMPV.js → chunk-2YA4DDRM.js} +35 -35
  3. package/dist/chunk-2YA4DDRM.js.map +1 -0
  4. package/dist/{chunk-44TE3RKH.js → chunk-3ED3KHHD.js} +5 -4
  5. package/dist/chunk-3ED3KHHD.js.map +1 -0
  6. package/dist/{chunk-3G7X2WKI.js → chunk-5BNX73OU.js} +18 -38
  7. package/dist/chunk-5BNX73OU.js.map +1 -0
  8. package/dist/{chunk-7RDMTR64.js → chunk-66AEVERM.js} +785 -256
  9. package/dist/chunk-66AEVERM.js.map +1 -0
  10. package/dist/{chunk-PJWGTNOX.js → chunk-7C3PFRBU.js} +144 -186
  11. package/dist/chunk-7C3PFRBU.js.map +1 -0
  12. package/dist/{chunk-52HDHJ7I.js → chunk-AUNRHWH4.js} +32 -21
  13. package/dist/chunk-AUNRHWH4.js.map +1 -0
  14. package/dist/{chunk-KOLDW6SF.js → chunk-BBDGYJHX.js} +2 -2
  15. package/dist/chunk-BBDGYJHX.js.map +1 -0
  16. package/dist/{chunk-SZYQISA2.js → chunk-ELV5WDS3.js} +43 -29
  17. package/dist/chunk-ELV5WDS3.js.map +1 -0
  18. package/dist/{chunk-MQ6CGZNJ.js → chunk-GAKVZNTX.js} +1879 -2019
  19. package/dist/chunk-GAKVZNTX.js.map +1 -0
  20. package/dist/chunk-GEMW5RQ2.js +1169 -0
  21. package/dist/chunk-GEMW5RQ2.js.map +1 -0
  22. package/dist/{chunk-NQW25DCF.js → chunk-GHHJYNAN.js} +1 -7
  23. package/dist/chunk-GHHJYNAN.js.map +1 -0
  24. package/dist/{chunk-WTWMGH2C.js → chunk-HACRR422.js} +2 -2
  25. package/dist/chunk-HACRR422.js.map +1 -0
  26. package/dist/{chunk-F2BHT5C4.js → chunk-IWY5IR4F.js} +129 -151
  27. package/dist/chunk-IWY5IR4F.js.map +1 -0
  28. package/dist/{chunk-JFLVEFFP.js → chunk-KIK5EZYD.js} +1 -1
  29. package/dist/chunk-KIK5EZYD.js.map +1 -0
  30. package/dist/{chunk-USVBYQSQ.js → chunk-O4LN3HFI.js} +16 -6
  31. package/dist/chunk-O4LN3HFI.js.map +1 -0
  32. package/dist/{chunk-RIPSGNLU.js → chunk-OCAVW6N5.js} +3 -3
  33. package/dist/chunk-OCAVW6N5.js.map +1 -0
  34. package/dist/{chunk-4AAOOAIN.js → chunk-P6CYS4JK.js} +2 -2
  35. package/dist/chunk-P6CYS4JK.js.map +1 -0
  36. package/dist/chunk-PLFANHRZ.js +35 -0
  37. package/dist/chunk-PLFANHRZ.js.map +1 -0
  38. package/dist/{chunk-6ZRH5RHC.js → chunk-PMUZR4XO.js} +4 -4
  39. package/dist/chunk-PMUZR4XO.js.map +1 -0
  40. package/dist/{chunk-F5EBEATU.js → chunk-PSUTNOQ2.js} +34 -46
  41. package/dist/chunk-PSUTNOQ2.js.map +1 -0
  42. package/dist/chunk-RIK45Q4I.js +103 -0
  43. package/dist/chunk-RIK45Q4I.js.map +1 -0
  44. package/dist/{chunk-HED2DAXZ.js → chunk-THO7LO5B.js} +5 -5
  45. package/dist/chunk-THO7LO5B.js.map +1 -0
  46. package/dist/{chunk-OYJQUA3D.js → chunk-YGDWHDOY.js} +31 -13
  47. package/dist/chunk-YGDWHDOY.js.map +1 -0
  48. package/dist/{chunk-NCWDK6L7.js → chunk-YXKTY5WM.js} +254 -379
  49. package/dist/chunk-YXKTY5WM.js.map +1 -0
  50. package/dist/{chunk-NEZ4OAOL.js → chunk-ZEGM3MVR.js} +3 -5
  51. package/dist/chunk-ZEGM3MVR.js.map +1 -0
  52. package/dist/commands/build/marketplace.js +46 -46
  53. package/dist/commands/build/marketplace.js.map +1 -1
  54. package/dist/commands/build/plugins.js +25 -28
  55. package/dist/commands/build/plugins.js.map +1 -1
  56. package/dist/commands/compile.js +87 -178
  57. package/dist/commands/compile.js.map +1 -1
  58. package/dist/commands/doctor.js +510 -360
  59. package/dist/commands/doctor.js.map +1 -1
  60. package/dist/commands/edit.js +451 -357
  61. package/dist/commands/edit.js.map +1 -1
  62. package/dist/commands/eject.js +144 -125
  63. package/dist/commands/eject.js.map +1 -1
  64. package/dist/commands/init.js +20 -27
  65. package/dist/commands/list.js +39 -55
  66. package/dist/commands/list.js.map +1 -1
  67. package/dist/commands/new/marketplace.js +6 -11
  68. package/dist/commands/new/marketplace.js.map +1 -1
  69. package/dist/commands/search.js +35 -32
  70. package/dist/commands/search.js.map +1 -1
  71. package/dist/commands/share.js +17 -77
  72. package/dist/commands/share.js.map +1 -1
  73. package/dist/commands/uninstall.js +159 -222
  74. package/dist/commands/uninstall.js.map +1 -1
  75. package/dist/commands/update.js +9 -32
  76. package/dist/commands/update.js.map +1 -1
  77. package/dist/components/common/prompt-confirm.js +2 -2
  78. package/dist/components/common/removal-plan-confirm.js +2 -2
  79. package/dist/components/common/scroll-affordance.js +2 -2
  80. package/dist/components/common/select-list.js +2 -2
  81. package/dist/components/common/skill-agent-summary.js +4 -4
  82. package/dist/components/common/spinner.js +2 -4
  83. package/dist/components/common/summary-panel.js +5 -5
  84. package/dist/components/common/summary-panel.js.map +1 -1
  85. package/dist/config-exports.js +7 -3
  86. package/dist/config-exports.js.map +1 -1
  87. package/dist/hooks/init.js +18 -19
  88. package/dist/hooks/init.js.map +1 -1
  89. package/dist/index.js.map +1 -1
  90. package/dist/load-agent-defs-6QUUMGHK.js +14 -0
  91. package/dist/recompile-project-agents-I33KQJFB.js +65 -0
  92. package/dist/recompile-project-agents-I33KQJFB.js.map +1 -0
  93. package/dist/{source-loader-C5SQXZXI.js → source-loader-TTJVW2ER.js} +5 -5
  94. package/dist/src/agents/developer/ai-developer/playbook.md +2 -5
  95. package/dist/src/agents/developer/api-developer/playbook.md +2 -5
  96. package/dist/src/agents/developer/cli-developer/playbook.md +2 -5
  97. package/dist/src/agents/developer/web-developer/playbook.md +2 -5
  98. package/dist/src/agents/meta/agent-summoner/output.md +2 -2
  99. package/dist/src/agents/meta/agent-summoner/playbook.md +1 -13
  100. package/dist/src/agents/meta/codex-keeper/critical-requirements.md +2 -5
  101. package/dist/src/agents/meta/convention-keeper/critical-requirements.md +2 -4
  102. package/dist/src/agents/tester/ai-tester/critical-requirements.md +1 -2
  103. package/dist/src/agents/tester/ai-tester/playbook.md +2 -0
  104. package/dist/src/agents/tester/api-tester/critical-requirements.md +1 -2
  105. package/dist/src/agents/tester/api-tester/playbook.md +2 -0
  106. package/dist/src/agents/tester/cli-tester/critical-requirements.md +1 -2
  107. package/dist/src/agents/tester/cli-tester/playbook.md +2 -0
  108. package/dist/src/agents/tester/web-tester/critical-requirements.md +1 -2
  109. package/dist/src/agents/tester/web-tester/playbook.md +2 -0
  110. package/package.json +9 -8
  111. package/src/agents/developer/ai-developer/playbook.md +2 -5
  112. package/src/agents/developer/api-developer/playbook.md +2 -5
  113. package/src/agents/developer/cli-developer/playbook.md +2 -5
  114. package/src/agents/developer/web-developer/playbook.md +2 -5
  115. package/src/agents/meta/agent-summoner/output.md +2 -2
  116. package/src/agents/meta/agent-summoner/playbook.md +1 -13
  117. package/src/agents/meta/codex-keeper/critical-requirements.md +2 -5
  118. package/src/agents/meta/convention-keeper/critical-requirements.md +2 -4
  119. package/src/agents/tester/ai-tester/critical-requirements.md +1 -2
  120. package/src/agents/tester/ai-tester/playbook.md +2 -0
  121. package/src/agents/tester/api-tester/critical-requirements.md +1 -2
  122. package/src/agents/tester/api-tester/playbook.md +2 -0
  123. package/src/agents/tester/cli-tester/critical-requirements.md +1 -2
  124. package/src/agents/tester/cli-tester/playbook.md +2 -0
  125. package/src/agents/tester/web-tester/critical-requirements.md +1 -2
  126. package/src/agents/tester/web-tester/playbook.md +2 -0
  127. package/src/schemas/project-config.schema.json +0 -3
  128. package/src/schemas/project-source-config.schema.json +0 -6
  129. package/dist/chunk-3G7X2WKI.js.map +0 -1
  130. package/dist/chunk-44TE3RKH.js.map +0 -1
  131. package/dist/chunk-4AAOOAIN.js.map +0 -1
  132. package/dist/chunk-52HDHJ7I.js.map +0 -1
  133. package/dist/chunk-6HNXYYVF.js +0 -373
  134. package/dist/chunk-6HNXYYVF.js.map +0 -1
  135. package/dist/chunk-6ZRH5RHC.js.map +0 -1
  136. package/dist/chunk-7RDMTR64.js.map +0 -1
  137. package/dist/chunk-BMRUNMPV.js.map +0 -1
  138. package/dist/chunk-CLPUWOSA.js +0 -46
  139. package/dist/chunk-CLPUWOSA.js.map +0 -1
  140. package/dist/chunk-F2BHT5C4.js.map +0 -1
  141. package/dist/chunk-F5EBEATU.js.map +0 -1
  142. package/dist/chunk-HED2DAXZ.js.map +0 -1
  143. package/dist/chunk-JFLVEFFP.js.map +0 -1
  144. package/dist/chunk-KOLDW6SF.js.map +0 -1
  145. package/dist/chunk-MQ6CGZNJ.js.map +0 -1
  146. package/dist/chunk-NCWDK6L7.js.map +0 -1
  147. package/dist/chunk-NEZ4OAOL.js.map +0 -1
  148. package/dist/chunk-NIHUOWE4.js +0 -106
  149. package/dist/chunk-NIHUOWE4.js.map +0 -1
  150. package/dist/chunk-NQW25DCF.js.map +0 -1
  151. package/dist/chunk-OYJQUA3D.js.map +0 -1
  152. package/dist/chunk-PJWGTNOX.js.map +0 -1
  153. package/dist/chunk-RIPSGNLU.js.map +0 -1
  154. package/dist/chunk-SZYQISA2.js.map +0 -1
  155. package/dist/chunk-USVBYQSQ.js.map +0 -1
  156. package/dist/chunk-V3KTSP3Q.js +0 -940
  157. package/dist/chunk-V3KTSP3Q.js.map +0 -1
  158. package/dist/chunk-WTWMGH2C.js.map +0 -1
  159. package/dist/load-agent-defs-YMDWBFDP.js +0 -14
  160. package/dist/recompile-project-agents-SZ76WNTW.js +0 -18
  161. package/dist/source-loader-C5SQXZXI.js.map +0 -1
  162. /package/dist/{load-agent-defs-YMDWBFDP.js.map → load-agent-defs-6QUUMGHK.js.map} +0 -0
  163. /package/dist/{recompile-project-agents-SZ76WNTW.js.map → source-loader-TTJVW2ER.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 { InstallSelection } from \"@workspace/compile/seed-to-config\";\nimport {\n CLI_INVOKE_COMMAND,\n CLI_COLORS,\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 { movedGlobalAgentInputs, type GateReport } from \"../lib/config-gate/index.js\";\nimport { getSkillById, getSkillDisplayName } from \"../lib/matrix/matrix-provider\";\nimport { type AuthoritativeScope, loadProjectConfig } from \"../lib/configuration/index.js\";\nimport {\n activeAgentScopeMap,\n isActiveAt,\n isGlobalTombstone,\n} from \"../lib/configuration/scope-predicates.js\";\nimport type { SourceLoadResult } from \"../lib/loading/index.js\";\nimport { buildMarketplacePluginRef } from \"../lib/plugins/index.js\";\nimport { deleteLocalSkill, migrateLocalSkillScope } 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 { seedToInstallSelection, type SeedMapping } from \"../lib/seed/seed-to-selection.js\";\nimport {\n arrivalLines,\n arrivalsByScope,\n joinedStatement,\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 { 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 editorSkillMetadataUnusableError,\n keptAsInstalledGlobally,\n keptUnassigned,\n localSkillsCopied,\n nothingInstalledToApplyTo,\n projectCopyRemoved,\n recompileSummary,\n sharedConfigDestinations,\n sharedConfigNeedsTerminal,\n skippedUnknownAgents,\n skippedUnknownSkills,\n unplaceableKept,\n} from \"../utils/messages.js\";\nimport { formatScopeTag } from \"../lib/configuration/scope-diff.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\ntype EditContext = {\n installation: Installation;\n projectConfig: ProjectConfig | null;\n sourceResult: SourceLoadResult;\n startupMessages: StartupMessage[];\n};\n\n/** The one directory an `edit` run acts on, decided once and handed to every layer. */\ntype EditRoot = {\n /** Where this run reads its saved skills from, writes, registers plugins and compiles into. */\n dir: string;\n /** {@link EditRoot.dir} IS the global installation. */\n isGlobal: 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.\n */\nfunction resolveEditRoot(installation: Installation): EditRoot {\n const dir = installation.projectDir;\n return { dir, isGlobal: isHomeDirectory(dir) };\n}\n\n/**\n * A shared configuration, as one sequence applies it. It destroys whatever it leaves out, so its\n * removals are confirmed first.\n */\ntype EditSelection = {\n result: InstallSelection;\n /**\n * Statements naming what this run may not remove, and the held global sub-agents it adds to —\n * rendered in the confirm.\n */\n kept: string[];\n /** Skills the configuration carries rather than names, written once it is approved. */\n carried: ExternalSkillInstall[];\n /** From a project, the held global sub-agents an arriving skill's row joins. */\n joinedGlobalAgents: AgentName[];\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.\n */\nfunction droppedProjectHalves(changes: ConfigChanges): DroppedHalves {\n const droppedAgents = [...changes.agentScopeChanges].filter(\n ([name, change]) => change.to === \"global\" && changes.dualScopeAgentTransitions.has(name),\n );\n\n return {\n skillIds: changes.collapsedPairs.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.\n */\nfunction compilesGlobalScope(editRoot: EditRoot, written: GateReport): boolean {\n return editRoot.isGlobal || 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 ReassignedChanges = ConfigChanges & { reassignedAgents: AgentName[] };\n\n/** Adds the held global sub-agents a project run adds rows to (`HeldGlobal.joined`). */\ntype PlannedChanges = ReassignedChanges & { joinedGlobalAgents: AgentName[] };\n\n/** Adds carried skills already installed here whose files the apply rewrote. */\ntype AppliedChanges = PlannedChanges & { rewrittenSkills: SkillId[] };\n\n/**\n * In a project only the project's own sub-agents count; a global one keeps its installed rows and\n * gains only an arriving skill's (`restoreInstalledGlobal`), which `HeldGlobal.joined` names. A\n * sub-agent already counted as added is not counted twice.\n */\nfunction withReassignments(\n changes: ConfigChanges,\n result: InstallSelection,\n installedStack: ProjectConfig[\"stack\"],\n editRoot: EditRoot,\n): ReassignedChanges {\n const { assignedStack } = result;\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 * the global copy a dropped project half leaves, which the plan lists as a removal, and the held\n * global sub-agents a row joins, which {@link joinedStatement} names.\n */\nfunction applyArrivals(changes: PlannedChanges, result: InstallSelection): 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: a shared configuration only adds to the global install from a project (owner ruling\n * 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 = \"Open this installation in the editor, or apply a configuration with --from\";\n static description =\n \"Open this installation in agentsinc.sh/editor, or apply a configuration built there with --from\";\n\n static examples = [\n {\n description: \"Open this installation in the editor\",\n command: \"<%= config.bin %> <%= command.id %>\",\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 description: \"Look at a shared configuration without applying it\",\n command: \"<%= config.bin %> <%= command.id %> --ui --from <id>\",\n },\n ];\n\n static flags = {\n ui: Flags.boolean({\n description:\n \"Open agentsinc.sh/editor on this installation, or on the id --from names without applying it — what a bare edit does\",\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 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 anything is copied or installed.\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 // A bare `edit` is `edit --ui`, and needs no source load.\n if (flags.from === undefined) return this.openInEditor(cwd);\n\n // A destructive apply nobody can confirm must never become a yes; refused before the fetch.\n const payload = await this.fetchSharedConfigOrFail(flags.from);\n\n const context = await this.loadContextUnderSpinner();\n\n const editRoot = resolveEditRoot(context.installation);\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 editRoot.dir,\n );\n\n const selection = await this.selectionFromSharedConfig(payload, context, editRoot);\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: InstallSelection = {\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: PlannedChanges = {\n ...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 joinedGlobalAgents: selection.joinedGlobalAgents,\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 = await this.confirmAndWriteCarried(selection, planned, filteredResult);\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 return;\n }\n\n this.logChangeSummary(changes, filteredResult.skills, filteredOldConfig?.skills ?? []);\n const migratedSkillIds = await this.applyMigrations(\n changes,\n filteredResult,\n activeOldSkills,\n context,\n editRoot,\n );\n await this.applyScopeChanges(changes, filteredResult, context, editRoot);\n await this.applyCollapsedPairs(changes, 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);\n await this.cleanupStaleAgentFiles(changes, activeOldAgents, editRoot);\n await this.reportWhatThisHostCannotCarry(editRoot);\n this.logCompletionSummary(changes);\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.\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 result: held.result,\n kept: [\n ...keptStatements(reconciled.kept),\n ...unassignedStatement(reconciled.unassigned),\n ...joinedStatement(held),\n ...keptAsInstalledStatement(held, revisedGlobally),\n ],\n carried: arrivingCarried,\n joinedGlobalAgents: held.joined.map(({ agentName }) => agentName),\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 seedToInstallSelection(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: EditSelection,\n planned: PlannedChanges,\n result: InstallSelection,\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 await this.ensureInstalledSkillsReadable(projectDir);\n\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 * The payload reads every ejected skill's metadata.yaml for its provenance, and no catalogue is\n * loaded here to resolve a skill around it, so every installed entry is asked about — not only\n * those a catalogue lacks, as `edit --from` asks. The config read is the one the payload reads.\n */\n private async ensureInstalledSkillsReadable(projectDir: string): Promise<void> {\n const loaded = await loadProjectConfig(projectDir);\n // Nothing installed is `seedPayloadForInstallation`'s to report.\n if (!loaded) return;\n\n await this.refuseUnusableSavedSkillMetadata(\n loaded.config.skills,\n projectDir,\n editorSkillMetadataUnusableError,\n );\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(): Promise<EditContext> {\n return awaitUnderSpinner(STATUS_MESSAGES.LOADING_SKILLS, () => this.loadContext());\n }\n\n private async loadContext(): 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 try {\n const { sourceResult, startupMessages } = await loadSource({\n projectDir: installation.projectDir,\n captureStartupMessages: true,\n });\n return { installation, projectConfig, sourceResult, startupMessages };\n } catch (error) {\n this.handleError(error);\n }\n }\n\n private logChangeSummary(\n changes: AppliedChanges,\n newSkills: SkillConfig[],\n oldSkills: SkillConfig[],\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 joinedGlobalAgents,\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 this.log(chalk.hex(CLI_COLORS.ERROR)(` - ${getSkillDisplayName(skillId)}${scopeLabel}`));\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 // Nor rows joining a held global sub-agent, which keeps everything else.\n for (const agentName of joinedGlobalAgents) {\n this.log(\n chalk.hex(CLI_COLORS.WARNING)(` ~ ${agentName}`) +\n chalk.hex(CLI_COLORS.NEUTRAL)(` ${formatScopeTag(\"global\")} (agent: skills added)`),\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: InstallSelection,\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\n * ({@link applyCollapsedPairs}).\n */\n private async applyScopeChanges(\n changes: ConfigChanges,\n filteredResult: InstallSelection,\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 * Each project 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 context: EditContext,\n editRoot: EditRoot,\n ): Promise<void> {\n const [ejectedHalves, pluginHalves] = partition(\n changes.collapsedPairs.map(({ projectHalf }) => projectHalf),\n (half) => half.origin === EJECT_SOURCE,\n );\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: InstallSelection,\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: InstallSelection,\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: InstallSelection,\n context: EditContext,\n editRoot: EditRoot,\n authority: AuthoritativeScope,\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 selection: 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(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. The project's own install is\n * dropped, so `sourceChanges` and the mode migrations measure a collapsed skill against\n * `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. */\n projectHalf: SkillConfig;\n /** The global install the project half masked, as its tombstone recorded it. */\n maskedGlobal: SkillConfig;\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 selection: InstallSelection,\n fullEntries?: FullScopeEntries,\n): ConfigChanges {\n const oldSkillIds = oldConfig?.skills.map((s) => s.id) ?? [];\n const newSkillIds = selection.skills.map((s) => s.id);\n const oldAgentNames = oldConfig?.agents.map((a) => a.name) ?? [];\n const newAgentNames = selection.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 selection.skills,\n oldSkillsById,\n (s) => s.id,\n (s) => s.scope,\n );\n const agentScopeChanges = detectPropertyChanges(\n selection.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 );\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 selection.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 selection.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): 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 }));\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.joinedGlobalAgents.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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,mBAAmB,IAAI,cAAc,EAAE,OAAO,CAAC,YAAY,QAAQ,OAAO,SAAS,CAAC;AAC7F;AAEA,SAAS,cAAc,SAAkC;AACvD,SACE,QAAQ,iBAAiB,SAAS,KAClC,QAAQ,mBAAmB,SAAS,KACpC,QAAQ,gBAAgB,SAAS,KACjC,QAAQ,YAAY,SAAS,KAC7B,QAAQ,cAAc,SAAS,KAC/B,QAAQ,YAAY,SAAS,KAC7B,QAAQ,cAAc,SAAS,KAC/B,QAAQ,cAAc,OAAO,KAC7B,QAAQ,aAAa,OAAO,KAC5B,QAAQ,kBAAkB,OAAO,KACjC,QAAQ,cAAc,OAAO;AAEjC;AASA,eAAsB,yBACpB,cACA,QACA,aACA,YACqC;AACrC,QAAM,OAAO,OAAO,UAAU;AAC9B,QAAM,WAAsB,CAAC;AAC7B,QAAM,SAA+C,CAAC;AAEtD,aAAW,CAAC,SAAS,MAAM,KAAK,cAAc;AAC5C,UAAM,cAAc,OAAO,KAAK,CAAC,MAAM,EAAE,OAAO,OAAO;AACvD,QAAI,CAAC,eAAe,YAAY,WAAW,cAAc;AACvD;AAAA,IACF;AAEA,UAAM,YAAY,0BAA0B,SAAS,WAAW;AAEhE,QAAI;AAIF,UAAI,OAAO,SAAS,WAAW;AAC7B,cAAM,KAAK,gBAAgB,WAAW,WAAW,UAAU;AAAA,MAC7D;AACA,YAAM,KAAK,cAAc,WAAW,OAAO,IAAI,UAAU;AACzD,eAAS,KAAK,OAAO;AAAA,IACvB,SAAS,OAAO;AACd,aAAO,KAAK,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, unique } from \"remeda\";\n\nimport { BaseCommand } from \"../base-command.js\";\nimport type { InstallSelection } from \"@workspace/compile/seed-to-config\";\nimport {\n CLI_INVOKE_COMMAND,\n CLI_COLORS,\n EJECT_SOURCE,\n editorConfigUrl,\n formatSourceDisplayName,\n type Provider,\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 type CompilationResult,\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 type MigrationPlan,\n detectMigrations,\n ejectCopyFailureError,\n executeMigration,\n holdsItsOwnInstallation,\n isHomeDirectory,\n resolveInstallPaths,\n INSTALL_MODE_DESCRIPTIONS,\n} from \"../lib/installation/index.js\";\nimport {\n movedGlobalAgentInputs,\n projectsAFanOutReaches,\n type GateReport,\n} from \"../lib/config-gate/index.js\";\nimport {\n copyingBesideGlobalPlugins,\n installingBesideGlobalCopies,\n keepsGlobalInstall,\n} from \"../lib/installation/mode-migrator.js\";\nimport { getSkillById, getSkillDisplayName } from \"../lib/matrix/matrix-provider\";\nimport { type AuthoritativeScope, loadProjectConfig } from \"../lib/configuration/index.js\";\nimport {\n activeAgentScopeMap,\n isActiveAt,\n isGlobalTombstone,\n} from \"../lib/configuration/scope-predicates.js\";\nimport type { SourceLoadResult } from \"../lib/loading/index.js\";\nimport { buildMarketplacePluginRef } from \"../lib/plugins/index.js\";\nimport { deleteLocalSkill, migrateLocalSkillScope } 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 { seedToInstallSelection, type SeedMapping } from \"../lib/seed/seed-to-selection.js\";\nimport {\n arrivalLines,\n arrivalsByScope,\n installsAtHome,\n joinedStatement,\n notInstalledGlobally,\n readInstalledGlobal,\n reconcileSharedConfig,\n restoreInstalledGlobal,\n sameAssignments,\n skillLabel,\n withUnplaceableAssignees,\n type Arrivals,\n type HeldGlobal,\n type InstalledGlobal,\n type KeptFromRoundTrip,\n type ReconciledSharedConfig,\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 { getErrorMessage } from \"../utils/errors.js\";\nimport { stripTerminalControls } from \"../utils/string.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 editorSkillMetadataUnusableError,\n keptAsInstalledGlobally,\n keptUnassigned,\n localSkillsCopied,\n nothingInstalledToApplyTo,\n projectCopyMovedToGlobal,\n projectCopyRemoved,\n recompileSummary,\n registeredProjectsRewritten,\n sharedConfigDestinations,\n sharedConfigNeedsTerminal,\n unplaceableKept,\n} from \"../utils/messages.js\";\nimport { formatScopeTag } from \"../lib/configuration/scope-diff.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\nconst CHANGE_MARKER_COLORS = {\n \"+\": CLI_COLORS.SUCCESS,\n \"-\": CLI_COLORS.ERROR,\n \"~\": CLI_COLORS.WARNING,\n} as const;\n\ntype ChangeMarker = keyof typeof CHANGE_MARKER_COLORS;\n\nconst AGENT_DETAIL = \" (agent)\";\n\n/** The marker and subject take the marker's colour; the detail after them is neutral. */\nfunction changeLine(marker: ChangeMarker, subject: string, detail?: string): string {\n const head = chalk.hex(CHANGE_MARKER_COLORS[marker])(` ${marker} ${subject}`);\n return detail === undefined ? head : head + chalk.hex(CLI_COLORS.NEUTRAL)(detail);\n}\n\n/** A `[P][G]` pair's project half toggled: an arrow line would claim the global install moved. */\nfunction dualScopeTransitionLine(subject: string, to: SkillScope, detail?: string): string {\n return changeLine(to === \"project\" ? \"+\" : \"-\", `${subject} [P]`, detail);\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 dualScopeTransitionLine(displayName, change.to);\n }\n\n const isGlobalToProject = change.from === \"global\" && change.to === \"project\";\n return changeLine(isGlobalToProject ? \"+\" : \"~\", displayName, scopeArrow(change));\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 if (dualScopeAgentTransitions.has(agentName)) {\n return dualScopeTransitionLine(agentName, change.to, AGENT_DETAIL);\n }\n\n return changeLine(\"~\", agentName, scopeArrow(change));\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 changeLine(\"~\", subject, ` (${kind}: ${change.from} \\u2192 ${change.to})`);\n}\n\nfunction sourceChangeLine(skillId: SkillId, change: ValueChange): string {\n const from = formatSourceDisplayName(change.from);\n const to = formatSourceDisplayName(change.to);\n return changeLine(\"~\", getSkillDisplayName(skillId), ` (${from} \\u2192 ${to})`);\n}\n\n/** Empty for an id the list does not hold. */\nfunction scopeLabelOf(skillId: SkillId, skills: SkillConfig[]): string {\n const skill = skills.find((s) => s.id === skillId);\n return skill === undefined ? \"\" : ` ${formatScopeTag(skill.scope)}`;\n}\n\n/**\n * A retune, a re-assignment, rows joining a held global sub-agent and rewritten files move no\n * entry, so each needs its own line or the run reads as a no-op.\n */\nfunction changeSummaryLines(\n changes: AppliedChanges,\n newSkills: SkillConfig[],\n oldSkills: SkillConfig[],\n): string[] {\n const addedSkill = (id: SkillId): string =>\n changeLine(\n \"+\",\n `${stripTerminalControls(getSkillById(id).displayName)}${scopeLabelOf(id, newSkills)}`,\n );\n const removedSkill = (id: SkillId): string =>\n changeLine(\"-\", `${getSkillDisplayName(id)}${scopeLabelOf(id, oldSkills)}`);\n const joinedGlobalDetail = ` ${formatScopeTag(\"global\")} (agent: skills added)`;\n\n return [\n ...changes.addedSkills.map(addedSkill),\n ...changes.removedSkills.map(removedSkill),\n ...changes.addedAgents.map((name) => changeLine(\"+\", name, AGENT_DETAIL)),\n ...changes.removedAgents.map((name) => changeLine(\"-\", name, AGENT_DETAIL)),\n ...[...changes.sourceChanges].map(([id, change]) => sourceChangeLine(id, change)),\n ...[...changes.scopeChanges].map(([id, change]) =>\n formatSkillScopeChangeLine(id, change, changes.dualScopeSkillTransitions),\n ),\n ...[...changes.agentScopeChanges].map(([name, change]) =>\n formatAgentScopeChangeLine(name, change, changes.dualScopeAgentTransitions),\n ),\n ...[...changes.tuningChanges].map(([name, change]) =>\n formatValueChangeLine(name, change, \"agent\"),\n ),\n ...changes.reassignedAgents.map((name) => changeLine(\"~\", name, \" (agent: skills reassigned)\")),\n ...changes.joinedGlobalAgents.map((name) => changeLine(\"~\", name, joinedGlobalDetail)),\n ...changes.rewrittenSkills.map((id) =>\n changeLine(\"~\", getSkillDisplayName(id), \" (skill: files rewritten)\"),\n ),\n ];\n}\n\ntype EditContext = {\n installation: Installation;\n projectConfig: ProjectConfig | null;\n sourceResult: SourceLoadResult;\n startupMessages: StartupMessage[];\n};\n\n/** The one directory an `edit` run acts on, decided once and handed to every layer. */\ntype EditRoot = {\n dir: string;\n isGlobal: 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.\n */\nfunction resolveEditRoot(installation: Installation): EditRoot {\n const dir = installation.projectDir;\n return { dir, isGlobal: isHomeDirectory(dir) };\n}\n\ntype EditSelection = {\n result: InstallSelection;\n /**\n * Statements naming what this run may not remove, and the held global sub-agents it adds to —\n * rendered in the confirm.\n */\n kept: string[];\n /** Skills the configuration carries rather than names, written once it is approved. */\n carried: ExternalSkillInstall[];\n /** From a project, the held global sub-agents an arriving skill's row joins. */\n joinedGlobalAgents: AgentName[];\n /** The global config itself, read from a project; `null` at home or with no global install. */\n installedGlobal: InstalledGlobal | null;\n};\n\ntype SharedConfigPlan = {\n heading?: string;\n sections: RemovalPlanSection[];\n overwritten: RemovalPlanSection;\n statements: string[];\n};\n\n/**\n * Names every change that deletes files. From a project the global install is restored before the\n * diff (`restoreInstalledGlobal`), so every listed removal is the project's own: a dropped `[P][G]`\n * half, whose id survives at global scope, or an entry moved to the global install. Files written\n * over in place are named apart, under their own heading.\n */\nfunction sharedConfigPlan(\n changes: ConfigChanges,\n overwrittenSkillIds: SkillId[],\n statements: string[],\n): SharedConfigPlan {\n const dropped = droppedProjectHalves(changes);\n const moved = movedToGlobal(changes);\n const skillLines = [\n ...changes.removedSkills.map(skillLabel),\n ...dropped.skillIds.map((id) => projectCopyRemoved(skillLabel(id))),\n ...moved.skillIds.map((id) => projectCopyMovedToGlobal(skillLabel(id))),\n ];\n const agentLines = [\n ...changes.removedAgents,\n ...dropped.agentNames.map(projectCopyRemoved),\n ...moved.agentNames.map(projectCopyMovedToGlobal),\n ];\n\n const sections = removalSections(skillLines, agentLines);\n const overwritten = {\n label: SHARED_CONFIG_APPLY.OVERWRITTEN_HEADING,\n items: overwrittenSkillIds.map(skillLabel),\n };\n return { ...planHeading(sections, overwritten), sections, overwritten, statements };\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\n/** Entries whose project copy an apply deletes. */\ntype ProjectCopies = { 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.\n */\nfunction droppedProjectHalves(changes: ConfigChanges): ProjectCopies {\n const droppedAgents = [...changes.agentScopeChanges].filter(\n ([name, change]) => change.to === \"global\" && changes.dualScopeAgentTransitions.has(name),\n );\n\n return {\n skillIds: changes.collapsedPairs.map(({ projectHalf }) => projectHalf.id),\n agentNames: droppedAgents.map(([name]) => name),\n };\n}\n\n/** A genuine move, not a collapsed pair: the copy goes from the project, the entry lives on. */\nfunction movedToGlobal(changes: ConfigChanges): ProjectCopies {\n const skillMoves = [...scopeMovesOf(changes)].filter(([, change]) => change.to === \"global\");\n const agentMoves = [...changes.agentScopeChanges].filter(\n ([name, change]) => change.to === \"global\" && !changes.dualScopeAgentTransitions.has(name),\n );\n\n return {\n skillIds: skillMoves.map(([id]) => id),\n agentNames: agentMoves.map(([name]) => name),\n };\n}\n\n/**\n * A configuration that only adds says so, and is still confirmed: it is applied whole. One that\n * removes nothing but overwrites opens on what it overwrites, since it does not only add.\n */\nfunction planHeading(\n sections: RemovalPlanSection[],\n overwritten: RemovalPlanSection,\n): Pick<SharedConfigPlan, \"heading\"> {\n if (sections.length > 0) return { heading: SHARED_CONFIG_APPLY.PREVIEW_HEADING };\n if (overwritten.items.length > 0) return {};\n return { heading: SHARED_CONFIG_APPLY.NOTHING_REMOVED };\n}\n\n/**\n * Written over in place, the user's own edits with them: carried skills whose files change, and\n * the ejected copies a switch to plugins deletes. One already named as moving is not named again.\n */\nfunction overwrittenSkillIds(changes: AppliedChanges, active: ActiveEntries): SkillId[] {\n const leaving = new Set(movedToGlobal(changes).skillIds);\n const switched = ejectedCopiesSwitchedToPlugins(migrationPlanOf(changes, active));\n return unique([...changes.rewrittenSkills, ...switched]).filter((id) => !leaving.has(id));\n}\n\n/** A copy beside a global install it keeps is not deleted (`keepsGlobalInstall`). */\nfunction ejectedCopiesSwitchedToPlugins(plan: MigrationPlan): SkillId[] {\n return plan.toPlugin.filter((migration) => !keepsGlobalInstall(migration)).map(({ id }) => id);\n}\n\n/** Measured against each collapsed pair's global install: the only one a collapse can switch. */\nfunction migrationPlanOf(changes: ConfigChanges, active: ActiveEntries): MigrationPlan {\n return detectMigrations(\n withMaskedGlobalsRestored(active.oldSkills, changes.collapsedPairs),\n active.selection.skills,\n );\n}\n\n/** Only carried skills whose files would change: identical bytes written again change nothing. */\nasync function carriedThatChange(carried: ExternalSkillInstall[]): Promise<ExternalSkillInstall[]> {\n const changing = new Set(await carriedSkillsThatDiffer(carried));\n return carried.filter((skill) => changing.has(skill.id));\n}\n\n/** A carried skill new here is an addition, already counted; the rest are rewritten in place. */\nfunction withRewrittenCarried(\n planned: PlannedChanges,\n carriedToWrite: ExternalSkillInstall[],\n): AppliedChanges {\n const writtenIds = carriedToWrite.map((skill) => skill.id);\n return { ...planned, rewrittenSkills: difference(writtenIds, skillsNewHere(planned)) };\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.\n */\nfunction compilesGlobalScope(editRoot: EditRoot, written: GateReport): boolean {\n return editRoot.isGlobal || 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 ReassignedChanges = ConfigChanges & { reassignedAgents: AgentName[] };\n\n/** Adds the held global sub-agents a project run adds rows to (`HeldGlobal.joined`). */\ntype PlannedChanges = ReassignedChanges & { joinedGlobalAgents: AgentName[] };\n\n/** Adds carried skills already installed here whose files the apply rewrites. */\ntype AppliedChanges = PlannedChanges & { rewrittenSkills: SkillId[] };\n\n/**\n * In a project only the project's own sub-agents count; a global one keeps its installed rows and\n * gains only an arriving skill's (`restoreInstalledGlobal`), which `HeldGlobal.joined` names. A\n * sub-agent already counted as added, or whose project copy arrives beside the global one, is not\n * counted twice.\n */\nfunction withReassignments(\n changes: ConfigChanges,\n result: InstallSelection,\n installedStack: ProjectConfig[\"stack\"],\n editRoot: EditRoot,\n): ReassignedChanges {\n const { assignedStack } = result;\n const arrivingCopies = arrivingProjectHalves(\n changes.agentScopeChanges,\n changes.dualScopeAgentTransitions,\n );\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) || arrivingCopies.has(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 * the global copy a dropped project half leaves, which the plan lists as a removal, and the held\n * global sub-agents a row joins, which {@link joinedStatement} names.\n */\nfunction applyArrivals(changes: PlannedChanges, result: InstallSelection): 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\n/** What the confirm says the run keeps, and the held global sub-agents it adds to. */\nfunction keptOnApply(\n reconciled: ReconciledSharedConfig,\n held: HeldGlobal,\n revisedCarried: SkillId[],\n idAppliedAtHome: string | undefined,\n): string[] {\n return [\n ...keptStatements(reconciled.kept),\n ...unassignedStatement(reconciled.unassigned),\n ...joinedStatement(held),\n ...keptAsInstalledStatement(held, revisedCarried, idAppliedAtHome),\n ];\n}\n\nfunction keptAsInstalledStatement(\n held: HeldGlobal,\n revisedCarried: SkillId[],\n idAppliedAtHome: string | undefined,\n): 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, idAppliedAtHome)];\n}\n\n/** From a project, a shared configuration only adds to the global install. */\nfunction applyAuthority(editRoot: EditRoot): AuthoritativeScope {\n return editRoot.isGlobal ? \"all\" : \"owned\";\n}\n\n/** Both sides of the diff without their excluded entries. */\ntype ActiveEntries = {\n selection: InstallSelection;\n oldConfig: ProjectConfig | null;\n oldSkills: SkillConfig[];\n oldAgents: AgentScopeConfig[];\n};\n\nfunction activeEntriesOf(\n result: InstallSelection,\n projectConfig: ProjectConfig | null,\n): ActiveEntries {\n const oldSkills = (projectConfig?.skills ?? []).filter((s) => !s.excluded);\n const oldAgents = (projectConfig?.agents ?? []).filter((a) => !a.excluded);\n\n return {\n selection: {\n ...result,\n skills: result.skills.filter((s) => !s.excluded),\n agentConfigs: result.agentConfigs.filter((a) => !a.excluded),\n },\n oldConfig: projectConfig ? { ...projectConfig, skills: oldSkills, agents: oldAgents } : null,\n oldSkills,\n oldAgents,\n };\n}\n\nfunction planChanges(\n selection: EditSelection,\n active: ActiveEntries,\n projectConfig: ProjectConfig | null,\n editRoot: EditRoot,\n): PlannedChanges {\n const keptInstalled = globalHalvesKeptInstalled(selection.installedGlobal);\n const changes = detectConfigChanges(active.oldConfig, active.selection, {\n newSkills: [...selection.result.skills, ...keptInstalled.skills],\n oldSkills: projectConfig?.skills ?? [],\n newAgents: [...selection.result.agentConfigs, ...keptInstalled.agents],\n oldAgents: projectConfig?.agents ?? [],\n });\n\n return {\n ...withReassignments(changes, active.selection, projectConfig?.stack, editRoot),\n joinedGlobalAgents: selection.joinedGlobalAgents,\n };\n}\n\nexport default class Edit extends BaseCommand {\n static summary = \"Open this installation in the editor, or apply a configuration with --from\";\n static description =\n \"Open this installation in agentsinc.sh/editor, or apply a configuration built there with --from\";\n\n static examples = [\n {\n description: \"Open this installation in the editor\",\n command: \"<%= config.bin %> <%= command.id %>\",\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 description: \"Look at a shared configuration without applying it\",\n command: \"<%= config.bin %> <%= command.id %> --ui --from <id>\",\n },\n ];\n\n static flags = {\n ui: Flags.boolean({\n description:\n \"Open agentsinc.sh/editor on this installation, or on the id --from names without applying it — what a bare edit does\",\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 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 const namedProvider = providerNamedBy(flags.provider);\n\n // Above every installation check: opening a shared id needs no local state.\n if (flags.ui && flags.from !== undefined) {\n return this.openSharedInEditor(flags.from, cwd, namedProvider);\n }\n\n // Before anything is copied or installed.\n await refuseAnAmbiguousInstallation(cwd, \"edit\", namedProvider, (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 // A bare `edit` is `edit --ui`, and needs no source load.\n if (flags.from === undefined) return this.openInEditor(cwd);\n\n return this.applySharedConfig(flags.from, namedProvider);\n }\n\n private async applySharedConfig(id: string, namedProvider: Provider | undefined): Promise<void> {\n const payload = await this.fetchSharedConfigOrFail(id, namedProvider);\n const context = await this.loadContextUnderSpinner();\n const editRoot = resolveEditRoot(context.installation);\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 editRoot.dir,\n );\n\n const selection = await this.selectionFromSharedConfig(id, payload, context, editRoot);\n this.reportValidationErrors(selection.result.validation);\n\n const active = activeEntriesOf(selection.result, context.projectConfig);\n const planned = planChanges(selection, active, context.projectConfig, editRoot);\n // Before asking: a rewrite is named in the plan, and a run that changes nothing asks nothing.\n const carriedToWrite = await carriedThatChange(selection.carried);\n const changes = withRewrittenCarried(planned, carriedToWrite);\n\n if (!hasAnyChanges(changes)) return this.sayNothingChanged(selection.kept);\n\n const plan = await this.planToConfirm(changes, active, selection.kept, context, editRoot);\n await this.confirmSharedConfigOrCancel(plan, applyArrivals(changes, active.selection));\n await this.writeCarriedSkills(carriedToWrite);\n await this.applyApprovedChanges(changes, active, selection.result, context, editRoot);\n }\n\n private async applyApprovedChanges(\n changes: AppliedChanges,\n active: ActiveEntries,\n result: InstallSelection,\n context: EditContext,\n editRoot: EditRoot,\n ): Promise<void> {\n const { selection: activeSelection, oldSkills, oldAgents } = active;\n this.logChangeSummary(changes, activeSelection.skills, oldSkills);\n await this.applyMigrations(changes, active, context, editRoot);\n await this.applyScopeChanges(changes, activeSelection, context, editRoot);\n await this.applyCollapsedPairs(changes, context, editRoot);\n await this.applyPluginChanges(changes, activeSelection, oldSkills, context, editRoot);\n await this.copyNewLocalSkills(changes, activeSelection, context, editRoot);\n await this.removeDeletedLocalSkills(changes, oldSkills, editRoot);\n // Unfiltered: the config records the excluded entries too.\n await this.writeConfigAndCompile(result, context, editRoot);\n await this.cleanupStaleAgentFiles(changes, oldAgents, editRoot);\n await this.reportWhatThisHostCannotCarry(editRoot);\n this.logCompletionSummary();\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.\n */\n private async selectionFromSharedConfig(\n id: string,\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 mapping = this.decodeSeedOrFail(payload, sourceMatrix);\n const { result } = mapping;\n\n // Before any skip is narrated; `init --from` asks the same at the same point.\n this.refuseProjectScopedContentAtHome(result, editRoot.dir);\n\n const reconciled = await this.reconcileWithInstallation(mapping, payload, context, editRoot);\n const installedGlobal = editRoot.isGlobal ? null : await readInstalledGlobal(editRoot.dir);\n const held = restoreInstalledGlobal(reconciled.result, installedGlobal);\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 revisedGlobally = await carriedSkillsThatDiffer(difference(carried, arrivingCarried));\n\n sayCapturedWarnings(context.startupMessages);\n this.warnOfSkippedEntries(mapping, held.result.selectedAgents);\n\n return {\n result: held.result,\n kept: keptOnApply(reconciled, held, revisedGlobally, installsAtHome(result) ? id : undefined),\n carried: arrivingCarried,\n joinedGlobalAgents: held.joined.map(({ agentName }) => agentName),\n installedGlobal,\n };\n }\n\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 */\n private async reconcileWithInstallation(\n { result, skippedSkillIds }: SeedMapping,\n payload: SeedPayload,\n { projectConfig }: EditContext,\n editRoot: EditRoot,\n ): Promise<ReconciledSharedConfig> {\n const unplaceable = new Set(skippedSkillIds);\n return reconcileSharedConfig({\n decoded: withUnplaceableAssignees(result, projectConfig, payload, unplaceable),\n installed: projectConfig,\n authoredHere: await this.readAuthoredHere(projectConfig, editRoot.dir),\n unplaceable,\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 /**\n * Refuses an empty directory, or a missing terminal, before spending a round trip: a destructive\n * apply nobody can confirm must never become a yes.\n */\n private async fetchSharedConfigOrFail(\n id: string,\n namedProvider: Provider | undefined,\n ): Promise<SeedPayload> {\n if (!(await detectProject())) {\n this.error(nothingInstalledToApplyTo(id, namedProvider), { exit: EXIT_CODES.ERROR });\n }\n if (!process.stdin.isTTY) {\n this.error(sharedConfigNeedsTerminal(id, namedProvider), { 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 seedToInstallSelection(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 writeCarriedSkills(carried: ExternalSkillInstall[]): Promise<void> {\n if (carried.length === 0) return;\n\n await writeExternalSkills(carried);\n this.log(carriedSkillsWritten(carried.map((skill) => skill.id)));\n }\n\n /** What the run removes and overwrites, then what it keeps and what else it rewrites. */\n private async planToConfirm(\n changes: AppliedChanges,\n active: ActiveEntries,\n kept: string[],\n context: EditContext,\n editRoot: EditRoot,\n ): Promise<SharedConfigPlan> {\n const reachedProjects = await this.registeredProjectsStatement(changes, context, editRoot);\n return sharedConfigPlan(changes, overwrittenSkillIds(changes, active), [\n ...kept,\n ...reachedProjects,\n ]);\n }\n\n /** Nothing to confirm; what the run keeps still says why nothing changed. */\n private sayNothingChanged(kept: string[]): void {\n for (const statement of kept) {\n this.log(statement);\n }\n this.log(chalk.hex(CLI_COLORS.NEUTRAL)(INFO_MESSAGES.NO_CHANGES_MADE));\n }\n\n /**\n * At home every registered project inlines the global config, so a change to it rewrites each\n * one the fan-out reaches. Rewritten carried files alone leave the config as it was.\n */\n private async registeredProjectsStatement(\n changes: AppliedChanges,\n context: EditContext,\n editRoot: EditRoot,\n ): Promise<string[]> {\n if (!editRoot.isGlobal || !changesTheConfig(changes)) return [];\n\n const reached = await projectsAFanOutReaches(\n context.projectConfig?.projects ?? [],\n providerInUse(editRoot.dir),\n );\n return reached.length === 0 ? [] : [registeredProjectsRewritten(reached)];\n }\n\n /**\n * The plan and the apply read the same changes, so what is approved is what is removed. The\n * arrivals print above it, so the question covers the whole of what a yes does.\n */\n private async confirmSharedConfigOrCancel(\n plan: SharedConfigPlan,\n arrivals: Arrivals,\n ): Promise<void> {\n for (const line of arrivalLines(arrivals)) {\n this.log(line);\n }\n\n const outcome = await promptConfirm(({ onConfirm, onCancel }) => (\n <RemovalPlanConfirm\n {...plan}\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 await this.ensureInstalledSkillsReadable(projectDir);\n\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 * The payload reads every ejected skill's metadata.yaml for its provenance, and no catalogue is\n * loaded here to resolve a skill around it, so every installed entry is asked about — not only\n * those a catalogue lacks, as `edit --from` asks. The config read is the one the payload reads.\n */\n private async ensureInstalledSkillsReadable(projectDir: string): Promise<void> {\n const loaded = await loadProjectConfig(projectDir);\n // Nothing installed is `seedPayloadForInstallation`'s to report.\n if (!loaded) return;\n\n await this.refuseUnusableSavedSkillMetadata(\n loaded.config.skills,\n projectDir,\n editorSkillMetadataUnusableError,\n );\n }\n\n /** Opens an id rather than applying it; `--from` without `--ui` is the destructive apply. */\n private async openSharedInEditor(\n id: string,\n cwd: string,\n namedProvider: Provider | undefined,\n ): Promise<void> {\n const url = editorConfigUrl(id);\n\n this.log(`Open it at ${url}`);\n this.log(applySharedConfigHere(id, await holdsItsOwnInstallation(cwd), namedProvider));\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(): Promise<EditContext> {\n return awaitUnderSpinner(STATUS_MESSAGES.LOADING_SKILLS, () => this.loadContext());\n }\n\n private async loadContext(): 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 try {\n const { sourceResult, startupMessages } = await loadSource({\n projectDir: installation.projectDir,\n captureStartupMessages: true,\n });\n return { installation, projectConfig, sourceResult, startupMessages };\n } catch (error) {\n this.handleError(error);\n }\n }\n\n private logChangeSummary(\n changes: AppliedChanges,\n newSkills: SkillConfig[],\n oldSkills: SkillConfig[],\n ): void {\n this.log(`\\n${chalk.hex(CLI_COLORS.WHITE).bold(\"Changes:\")}`);\n for (const line of changeSummaryLines(changes, newSkills, oldSkills)) {\n this.log(line);\n }\n this.log(\"\");\n }\n\n private async applyMigrations(\n changes: ConfigChanges,\n active: ActiveEntries,\n context: EditContext,\n editRoot: EditRoot,\n ): Promise<void> {\n const migrationPlan = migrationPlanOf(changes, active);\n if (migrationPlan.toEject.length === 0 && migrationPlan.toPlugin.length === 0) return;\n\n this.announceMigrations(migrationPlan);\n if (migrationPlan.toPlugin.length > 0) {\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\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 /**\n * One line per kind, each counting its own: a mode switch, then a skill added in the project\n * beside the global install it keeps (`keepsGlobalInstall` decides both the keep and the line).\n */\n private announceMigrations(plan: MigrationPlan): void {\n const [copiesBesideGlobalPlugin, switchesToEject] = partition(plan.toEject, keepsGlobalInstall);\n const [installsBesideGlobalCopy, switchesToPlugin] = partition(\n plan.toPlugin,\n keepsGlobalInstall,\n );\n\n if (switchesToEject.length > 0) {\n this.logModeSwitch(switchesToEject.length, INSTALL_MODE_DESCRIPTIONS.eject);\n }\n if (copiesBesideGlobalPlugin.length > 0) {\n this.logCopiesBesideGlobalPlugins(copiesBesideGlobalPlugin.length);\n }\n if (switchesToPlugin.length > 0) {\n this.logModeSwitch(switchesToPlugin.length, INSTALL_MODE_DESCRIPTIONS.plugin);\n }\n if (installsBesideGlobalCopy.length > 0) {\n this.logInstallsBesideGlobalCopies(installsBesideGlobalCopy.length);\n }\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 private logCopiesBesideGlobalPlugins(count: number): void {\n this.log(chalk.hex(CLI_COLORS.NEUTRAL)(copyingBesideGlobalPlugins(count)));\n }\n\n private logInstallsBesideGlobalCopies(count: number): void {\n this.log(chalk.hex(CLI_COLORS.NEUTRAL)(installingBesideGlobalCopies(count)));\n }\n\n /**\n * A collapsed `[P][G]` pair is not a move: its project half is dropped\n * ({@link applyCollapsedPairs}).\n */\n private async applyScopeChanges(\n changes: ConfigChanges,\n filteredResult: InstallSelection,\n context: EditContext,\n editRoot: EditRoot,\n ): Promise<void> {\n const scopeChanges = scopeMovesOf(changes);\n await moveEjectedSkillCopies(scopeChanges, filteredResult.skills, editRoot.dir);\n\n if (!movesAPluginSkill(scopeChanges, filteredResult.skills)) 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 * Each project 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 context: EditContext,\n editRoot: EditRoot,\n ): Promise<void> {\n const [ejectedHalves, pluginHalves] = partition(\n changes.collapsedPairs.map(({ projectHalf }) => projectHalf),\n (half) => half.origin === EJECT_SOURCE,\n );\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 await this.uninstallPluginSkillsReported(\n pluginHalves.map((half) => half.id),\n pluginHalves,\n marketplace,\n editRoot.dir,\n );\n }\n\n private async uninstallPluginSkillsReported(\n skillIds: SkillId[],\n oldSkills: SkillConfig[],\n marketplace: string,\n projectDir: string,\n ): Promise<void> {\n const { uninstalled, failed } = await uninstallPluginSkills(\n skillIds,\n oldSkills,\n marketplace,\n projectDir,\n );\n if (uninstalled.length > 0) {\n this.log(chalk.hex(CLI_COLORS.NEUTRAL)(`Removed ${uninstalled.length} plugin(s)`));\n }\n for (const item of failed) {\n this.warn(`Failed to uninstall plugin ${item.id}: ${item.error}`);\n }\n }\n\n private async applyPluginChanges(\n changes: ConfigChanges,\n filteredResult: InstallSelection,\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 await this.uninstallPluginSkillsReported(\n removedPluginSkills,\n activeOldSkills,\n marketplace,\n editRoot.dir,\n );\n }\n }\n\n private async copyNewLocalSkills(\n changes: ConfigChanges,\n filteredResult: InstallSelection,\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 belong to\n // applyPluginChanges.\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: InstallSelection,\n context: EditContext,\n editRoot: EditRoot,\n ): Promise<void> {\n const agentDefs = await this.loadAgentDefsOrFail();\n const configResult = await this.writeConfigOrFail(result, context, editRoot, agentDefs);\n this.reportUnassignedSkills(configResult.config, result.skills);\n await this.recompileAgents(result, editRoot, configResult.propagation, agentDefs.sourcePath);\n this.reportFanOut(configResult.propagation);\n }\n\n private async loadAgentDefsOrFail(): Promise<AgentDefs> {\n try {\n return await loadAgentDefs();\n } catch (error) {\n this.handleError(error);\n }\n }\n\n /** Fatal: every mutation has landed and config.ts is their only record. */\n private async writeConfigOrFail(\n result: InstallSelection,\n context: EditContext,\n editRoot: EditRoot,\n agentDefs: AgentDefs,\n ): Promise<ConfigWriteResult> {\n try {\n return await writeProjectConfig({\n selection: result,\n sourceResult: context.sourceResult,\n projectDir: editRoot.dir,\n agentDefs,\n authoritativeScope: applyAuthority(editRoot),\n });\n } catch (error) {\n this.error(`Could not update config: ${getErrorMessage(error)}`, {\n exit: EXIT_CODES.ERROR,\n });\n }\n }\n\n private async recompileAgents(\n result: InstallSelection,\n editRoot: EditRoot,\n propagation: GateReport,\n sourcePath: string,\n ): Promise<void> {\n try {\n const agentScopeMap = activeAgentScopeMap(result.agentConfigs);\n const { allSkills } = await discoverInstalledSkills(editRoot.dir);\n const compile = compilesGlobalScope(editRoot, propagation)\n ? compileAgentsAllScopes\n : compileProjectScope;\n const compilation = await compile({\n projectDir: editRoot.dir,\n sourcePath,\n skills: allSkills,\n agentScopeMap,\n });\n this.reportRecompile(compilation);\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\n private reportRecompile({ compiled, rewritten, failed, warnings }: CompilationResult): void {\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 }\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(): void {\n if (this.hasIncompleteWork) return;\n\n this.log(`\\n${chalk.hex(CLI_COLORS.SUCCESS)(\"\\u2713 Done\")}\\n`);\n }\n}\n\ntype 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. The project's own install is\n * dropped, so `sourceChanges` and the mode migrations measure a collapsed skill against\n * `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. */\n projectHalf: SkillConfig;\n /** The global install the project half masked, as its tombstone recorded it. */\n maskedGlobal: SkillConfig;\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 * `fullEntries` carries the tombstone-inclusive lists, used only to tell a scope migration from a\n * dual-scope add/remove.\n */\nfunction detectConfigChanges(\n oldConfig: ProjectConfig | null,\n selection: InstallSelection,\n fullEntries: FullScopeEntries,\n): ConfigChanges {\n const oldSkillIds = oldConfig?.skills.map((s) => s.id) ?? [];\n const newSkillIds = selection.skills.map((s) => s.id);\n const oldAgentNames = oldConfig?.agents.map((a) => a.name) ?? [];\n const newAgentNames = selection.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 selection.skills,\n oldSkillsById,\n (s) => s.id,\n (s) => s.scope,\n );\n const agentScopeChanges = detectPropertyChanges(\n selection.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 );\n const dualScopeAgentTransitions = detectDualScopeTransitions(\n agentScopeChanges,\n fullEntries.newAgents,\n fullEntries.oldAgents,\n (a) => a.name,\n );\n const arrivingSkills = arrivingProjectHalves(scopeChanges, dualScopeSkillTransitions);\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: withoutKeys(\n detectPropertyChanges(\n selection.skills,\n indexBy(withMaskedGlobalsRestored(oldConfig?.skills ?? [], collapsedPairs), (s) => s.id),\n (s) => s.id,\n (s) => s.origin,\n ),\n arrivingSkills,\n ),\n scopeChanges,\n agentScopeChanges,\n dualScopeSkillTransitions,\n collapsedPairs,\n dualScopeAgentTransitions,\n // Either half of a pair is measured against the other install, which this edit never retunes.\n tuningChanges: withoutKeys(\n detectPropertyChanges(selection.agentConfigs, oldAgentsByName, (a) => a.name, describeTuning),\n dualScopeAgentTransitions,\n ),\n };\n}\n\n/** Added, or a project copy arriving beside the global install: files written, not rewritten. */\nfunction skillsNewHere(changes: ConfigChanges): SkillId[] {\n return [\n ...changes.addedSkills,\n ...arrivingProjectHalves(changes.scopeChanges, changes.dualScopeSkillTransitions),\n ];\n}\n\n/**\n * The `[P][G]` pairs this edit opens: the project's own copy arrives beside the global install,\n * so the diff, which measures it against that install, records a change nothing made.\n */\nfunction arrivingProjectHalves<K extends string>(\n scopeChanges: ReadonlyMap<K, ScopeChange>,\n dualScopeTransitions: ReadonlySet<K>,\n): Set<K> {\n const arriving = [...scopeChanges].filter(\n ([key, change]) => change.to === \"project\" && dualScopeTransitions.has(key),\n );\n return new Set(arriving.map(([key]) => key));\n}\n\nfunction withoutKeys<K, V>(changes: ReadonlyMap<K, V>, keys: ReadonlySet<K>): Map<K, V> {\n return new Map([...changes].filter(([key]) => !keys.has(key)));\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 * The global install's entries as the tombstones a project half arriving beside one leaves: the\n * write masks the global entry rather than moving it (`reconcileProjectSplitAgainstGlobal`). No\n * decoded selection carries these, so without them a project add over a global install reads as\n * the global install moving. Only a key that moves from global to project is looked up in them.\n */\nfunction globalHalvesKeptInstalled(installedGlobal: InstalledGlobal | null): {\n skills: SkillConfig[];\n agents: AgentScopeConfig[];\n} {\n if (installedGlobal === null) return { skills: [], agents: [] };\n\n return {\n skills: installedGlobal.skills.map(asTombstone),\n agents: installedGlobal.agents.map(asTombstone),\n };\n}\n\nfunction asTombstone<T extends { excluded?: boolean }>(entry: T): T {\n return { ...entry, excluded: true };\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 && isGlobalTombstone(item));\n const isDualScope = ([key, { from, to }]: [K, ScopeChange]): boolean =>\n (from === \"global\" && to === \"project\" && hasGlobalTombstone(fullNew, key)) ||\n (from === \"project\" && to === \"global\" && hasGlobalTombstone(fullOld, key));\n\n return new Set([...scopeChanges].filter(isDualScope).map(([key]) => key));\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): 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 }));\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\nasync function moveEjectedSkillCopies(\n scopeMoves: ReadonlyMap<SkillId, ScopeChange>,\n skills: SkillConfig[],\n projectDir: string,\n): Promise<void> {\n for (const [skillId, change] of scopeMoves) {\n const skillConfig = skills.find((s) => s.id === skillId);\n if (skillConfig?.origin === EJECT_SOURCE) {\n await migrateLocalSkillScope(skillId, change.from, projectDir);\n }\n }\n}\n\n/** An ejected skill moves as files; a plugin one needs the marketplace to re-register it. */\nfunction movesAPluginSkill(\n scopeMoves: ReadonlyMap<SkillId, ScopeChange>,\n skills: SkillConfig[],\n): boolean {\n return [...scopeMoves.keys()].some((skillId) => {\n const skill = skills.find((s) => s.id === skillId);\n return skill !== undefined && skill.origin !== EJECT_SOURCE;\n });\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 changes.rewrittenSkills.length > 0 || changesTheConfig(changes);\n}\n\n/** Every change but rewritten carried files, which leave config.ts as it was. */\nfunction changesTheConfig(changes: PlannedChanges): boolean {\n return (\n changes.reassignedAgents.length > 0 ||\n changes.joinedGlobalAgents.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\ntype PluginScopeMigrationResult = {\n failed: Array<{ id: SkillId; error: string }>;\n};\n\nasync 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 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 keeps the global registration, which other projects still use.\n if (change.from === \"project\") {\n await host.uninstallPlugin(pluginRef, \"project\", projectDir);\n }\n await host.installPlugin(pluginRef, change.to, projectDir);\n } catch (error) {\n failed.push({ id: skillId, error: getErrorMessage(error) });\n }\n }\n\n return { failed };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,UAAU;AAEjB,OAAO,WAAW;AAClB,SAAS,aAAa;AAEtB,SAAS,YAAY,SAAS,WAAW,cAAc;AAi5BjD;AA1vBN,IAAM,oBAAoB;AAE1B,IAAM,uBAAuB;AAAA,EAC3B,KAAK,WAAW;AAAA,EAChB,KAAK,WAAW;AAAA,EAChB,KAAK,WAAW;AAClB;AAIA,IAAM,eAAe;AAGrB,SAAS,WAAW,QAAsB,SAAiB,QAAyB;AAClF,QAAM,OAAO,MAAM,IAAI,qBAAqB,MAAM,CAAC,EAAE,KAAK,MAAM,IAAI,OAAO,EAAE;AAC7E,SAAO,WAAW,SAAY,OAAO,OAAO,MAAM,IAAI,WAAW,OAAO,EAAE,MAAM;AAClF;AAGA,SAAS,wBAAwB,SAAiB,IAAgB,QAAyB;AACzF,SAAO,WAAW,OAAO,YAAY,MAAM,KAAK,GAAG,OAAO,QAAQ,MAAM;AAC1E;AAGA,SAAS,2BACP,SACA,QACA,2BACQ;AACR,QAAM,cAAc,oBAAoB,OAAO;AAC/C,MAAI,0BAA0B,IAAI,OAAO,GAAG;AAC1C,WAAO,wBAAwB,aAAa,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