agents-inc 0.164.0 → 0.165.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (191) hide show
  1. package/CHANGELOG.md +48 -0
  2. package/README.md +8 -9
  3. package/dist/{chunk-B6FSLXYN.js → chunk-42TNV2TK.js} +3 -3
  4. package/dist/chunk-4AAOOAIN.js +49 -0
  5. package/dist/chunk-4AAOOAIN.js.map +1 -0
  6. package/dist/{chunk-NQXO4LR3.js → chunk-4C7GL4F7.js} +16 -11
  7. package/dist/chunk-4C7GL4F7.js.map +1 -0
  8. package/dist/{chunk-Q4IRRVXK.js → chunk-57KU6SPH.js} +3 -3
  9. package/dist/{chunk-S63LXWMC.js → chunk-5M3PQNXI.js} +2 -2
  10. package/dist/{chunk-3WVH2CTK.js → chunk-5P26XBZO.js} +15 -8
  11. package/dist/chunk-5P26XBZO.js.map +1 -0
  12. package/dist/{chunk-G2JJ5BO5.js → chunk-6AIZPSEI.js} +337 -140
  13. package/dist/chunk-6AIZPSEI.js.map +1 -0
  14. package/dist/{chunk-NKGYKOB7.js → chunk-6CY6PW5X.js} +7 -8
  15. package/dist/chunk-6CY6PW5X.js.map +1 -0
  16. package/dist/{chunk-XHPWTL4I.js → chunk-6SW6SB7H.js} +3 -3
  17. package/dist/chunk-AAWZED5M.js +980 -0
  18. package/dist/chunk-AAWZED5M.js.map +1 -0
  19. package/dist/{chunk-UITEKY2R.js → chunk-AQXKAPCD.js} +30 -4
  20. package/dist/chunk-AQXKAPCD.js.map +1 -0
  21. package/dist/{chunk-X4SSJZLY.js → chunk-B5UUHBAM.js} +12 -261
  22. package/dist/chunk-B5UUHBAM.js.map +1 -0
  23. package/dist/{chunk-ARYNOWKF.js → chunk-BGU25XAY.js} +8 -8
  24. package/dist/{chunk-QGUP3QJF.js → chunk-CBMAO6OP.js} +22 -18
  25. package/dist/{chunk-QGUP3QJF.js.map → chunk-CBMAO6OP.js.map} +1 -1
  26. package/dist/{chunk-YRS3QZP2.js → chunk-CEBDGZID.js} +3 -3
  27. package/dist/{chunk-ABAZMMG4.js → chunk-CK5RM3DJ.js} +2 -2
  28. package/dist/{chunk-PHCPUQVR.js → chunk-CTUJO23Z.js} +2 -2
  29. package/dist/{chunk-QZX7SYKU.js → chunk-E6CHHXGY.js} +2 -2
  30. package/dist/{chunk-ZVXGW2IC.js → chunk-F2ZWFWTP.js} +4 -6
  31. package/dist/chunk-F2ZWFWTP.js.map +1 -0
  32. package/dist/{chunk-AVK2HEKB.js → chunk-GKPW33FP.js} +2 -6
  33. package/dist/{chunk-AVK2HEKB.js.map → chunk-GKPW33FP.js.map} +1 -1
  34. package/dist/{chunk-ECURHW3T.js → chunk-HR4YDSJK.js} +13 -12
  35. package/dist/chunk-HR4YDSJK.js.map +1 -0
  36. package/dist/{chunk-XPDVAJDH.js → chunk-IM45LLQX.js} +3599 -1558
  37. package/dist/chunk-IM45LLQX.js.map +1 -0
  38. package/dist/chunk-IVNKU4DM.js +39 -0
  39. package/dist/chunk-IVNKU4DM.js.map +1 -0
  40. package/dist/{chunk-XVAQG2CV.js → chunk-JOEA52NR.js} +10 -8
  41. package/dist/chunk-JOEA52NR.js.map +1 -0
  42. package/dist/{chunk-RGYDFBCT.js → chunk-JV4TKXEN.js} +5 -5
  43. package/dist/{chunk-4VL3CEOS.js → chunk-LXXGZAD3.js} +3 -3
  44. package/dist/chunk-MBUGQI2M.js +73 -0
  45. package/dist/chunk-MBUGQI2M.js.map +1 -0
  46. package/dist/{chunk-URXIQE7I.js → chunk-MWDY76MT.js} +2 -2
  47. package/dist/{chunk-V5GLL2JB.js → chunk-P3KJCYSR.js} +7 -7
  48. package/dist/{chunk-6MV4JOCL.js → chunk-PSX7CT6V.js} +2 -2
  49. package/dist/{chunk-B3Y3QMWI.js → chunk-TRTVOVHR.js} +4 -4
  50. package/dist/{chunk-AOTCIUGX.js → chunk-TV5Y53R2.js} +2 -2
  51. package/dist/{chunk-K5ITEA3I.js → chunk-UBSSIIWD.js} +34 -17
  52. package/dist/chunk-UBSSIIWD.js.map +1 -0
  53. package/dist/chunk-UCORXS4D.js +250 -0
  54. package/dist/chunk-UCORXS4D.js.map +1 -0
  55. package/dist/chunk-UR3RRTPO.js +159 -0
  56. package/dist/chunk-UR3RRTPO.js.map +1 -0
  57. package/dist/chunk-V5CWACR5.js +375 -0
  58. package/dist/chunk-V5CWACR5.js.map +1 -0
  59. package/dist/{chunk-LT5GXEB2.js → chunk-VPJUCVU7.js} +8 -7
  60. package/dist/chunk-VPJUCVU7.js.map +1 -0
  61. package/dist/chunk-VRXX4D6K.js +31 -0
  62. package/dist/chunk-VRXX4D6K.js.map +1 -0
  63. package/dist/{chunk-2CQNPLVF.js → chunk-WIFIAQZU.js} +63 -42
  64. package/dist/chunk-WIFIAQZU.js.map +1 -0
  65. package/dist/chunk-WSGX4IWC.js +356 -0
  66. package/dist/chunk-WSGX4IWC.js.map +1 -0
  67. package/dist/{chunk-X37UYIE3.js → chunk-WTANOSXK.js} +436 -739
  68. package/dist/chunk-WTANOSXK.js.map +1 -0
  69. package/dist/{chunk-XATLUKXK.js → chunk-X2KUI7V3.js} +6 -6
  70. package/dist/{chunk-NTF4UXGK.js → chunk-XATIKM3P.js} +73 -30
  71. package/dist/chunk-XATIKM3P.js.map +1 -0
  72. package/dist/{chunk-J27W6TXS.js → chunk-XQHZPINL.js} +8 -4
  73. package/dist/chunk-XQHZPINL.js.map +1 -0
  74. package/dist/{chunk-DSL66I4N.js → chunk-Y5SNGMB7.js} +6 -6
  75. package/dist/{chunk-7REKOTKG.js → chunk-YNOOZFIB.js} +3 -3
  76. package/dist/commands/build/marketplace.js +17 -17
  77. package/dist/commands/build/marketplace.js.map +1 -1
  78. package/dist/commands/build/plugins.js +11 -9
  79. package/dist/commands/build/plugins.js.map +1 -1
  80. package/dist/commands/compile.js +106 -27
  81. package/dist/commands/compile.js.map +1 -1
  82. package/dist/commands/doctor.js +427 -192
  83. package/dist/commands/doctor.js.map +1 -1
  84. package/dist/commands/edit.js +504 -314
  85. package/dist/commands/edit.js.map +1 -1
  86. package/dist/commands/eject.js +41 -23
  87. package/dist/commands/eject.js.map +1 -1
  88. package/dist/commands/init.js +44 -40
  89. package/dist/commands/list.js +44 -10
  90. package/dist/commands/list.js.map +1 -1
  91. package/dist/commands/new/marketplace.js +13 -10
  92. package/dist/commands/new/marketplace.js.map +1 -1
  93. package/dist/commands/search.js +12 -10
  94. package/dist/commands/search.js.map +1 -1
  95. package/dist/commands/share.js +103 -15
  96. package/dist/commands/share.js.map +1 -1
  97. package/dist/commands/uninstall.js +264 -106
  98. package/dist/commands/uninstall.js.map +1 -1
  99. package/dist/commands/update.js +50 -20
  100. package/dist/commands/update.js.map +1 -1
  101. package/dist/components/common/prompt-confirm.js +1 -1
  102. package/dist/components/common/removal-plan-confirm.js +2 -2
  103. package/dist/components/common/select-list.js +3 -3
  104. package/dist/components/common/spinner.js +6 -3
  105. package/dist/components/wizard/category-grid.js +5 -5
  106. package/dist/components/wizard/checkbox-grid.js +4 -4
  107. package/dist/components/wizard/domain-selection.js +9 -9
  108. package/dist/components/wizard/run-wizard-session.js +29 -29
  109. package/dist/components/wizard/scroll-affordance.js +2 -2
  110. package/dist/components/wizard/skill-agent-summary.js +5 -5
  111. package/dist/components/wizard/source-grid.js +6 -6
  112. package/dist/components/wizard/stack-selection.js +8 -8
  113. package/dist/components/wizard/step-agents.js +8 -8
  114. package/dist/components/wizard/step-build.js +8 -8
  115. package/dist/components/wizard/step-confirm.js +9 -9
  116. package/dist/components/wizard/step-sources.js +9 -9
  117. package/dist/components/wizard/step-stack.js +9 -9
  118. package/dist/components/wizard/summary-panel.js +8 -8
  119. package/dist/components/wizard/toast.js +2 -2
  120. package/dist/components/wizard/wizard-layout.js +12 -12
  121. package/dist/components/wizard/wizard-tabs.js +2 -2
  122. package/dist/components/wizard/wizard.js +27 -27
  123. package/dist/hooks/init.js +59 -43
  124. package/dist/hooks/init.js.map +1 -1
  125. package/dist/load-agent-defs-JHLE6MAE.js +14 -0
  126. package/dist/recompile-project-agents-ZPP5NOLZ.js +18 -0
  127. package/dist/{source-loader-GRBVNRAW.js → source-loader-RWZAYJ7E.js} +6 -4
  128. package/dist/src/agents/_templates/agent-body.liquid +55 -0
  129. package/dist/src/agents/_templates/agent.liquid +1 -55
  130. package/dist/src/agents/meta/agent-summoner/output.md +1 -1
  131. package/dist/src/agents/meta/agent-summoner/playbook.md +15 -7
  132. package/dist/stores/wizard-store.js +4 -4
  133. package/package.json +10 -9
  134. package/src/agents/_templates/agent-body.liquid +55 -0
  135. package/src/agents/_templates/agent.liquid +1 -55
  136. package/src/agents/meta/agent-summoner/output.md +1 -1
  137. package/src/agents/meta/agent-summoner/playbook.md +15 -7
  138. package/src/schemas/project-config.schema.json +1 -1
  139. package/src/schemas/project-source-config.schema.json +1 -1
  140. package/dist/chunk-2CQNPLVF.js.map +0 -1
  141. package/dist/chunk-3WVH2CTK.js.map +0 -1
  142. package/dist/chunk-7ANJQLPJ.js +0 -35
  143. package/dist/chunk-7ANJQLPJ.js.map +0 -1
  144. package/dist/chunk-ECURHW3T.js.map +0 -1
  145. package/dist/chunk-FLW25ORT.js +0 -130
  146. package/dist/chunk-FLW25ORT.js.map +0 -1
  147. package/dist/chunk-G2JJ5BO5.js.map +0 -1
  148. package/dist/chunk-J27W6TXS.js.map +0 -1
  149. package/dist/chunk-JCPANDNR.js +0 -35
  150. package/dist/chunk-JCPANDNR.js.map +0 -1
  151. package/dist/chunk-JIERYE6B.js +0 -480
  152. package/dist/chunk-JIERYE6B.js.map +0 -1
  153. package/dist/chunk-JU4ZGJ7A.js +0 -668
  154. package/dist/chunk-JU4ZGJ7A.js.map +0 -1
  155. package/dist/chunk-K5ITEA3I.js.map +0 -1
  156. package/dist/chunk-LT5GXEB2.js.map +0 -1
  157. package/dist/chunk-NKGYKOB7.js.map +0 -1
  158. package/dist/chunk-NQXO4LR3.js.map +0 -1
  159. package/dist/chunk-NTF4UXGK.js.map +0 -1
  160. package/dist/chunk-UITEKY2R.js.map +0 -1
  161. package/dist/chunk-X37UYIE3.js.map +0 -1
  162. package/dist/chunk-X4SSJZLY.js.map +0 -1
  163. package/dist/chunk-XPDVAJDH.js.map +0 -1
  164. package/dist/chunk-XVAQG2CV.js.map +0 -1
  165. package/dist/chunk-ZBPEFQ4G.js +0 -12
  166. package/dist/chunk-ZBPEFQ4G.js.map +0 -1
  167. package/dist/chunk-ZVXGW2IC.js.map +0 -1
  168. package/dist/load-agent-defs-7IM3GBEQ.js +0 -13
  169. package/dist/recompile-project-agents-VR4NLGOU.js +0 -17
  170. /package/dist/{chunk-B6FSLXYN.js.map → chunk-42TNV2TK.js.map} +0 -0
  171. /package/dist/{chunk-Q4IRRVXK.js.map → chunk-57KU6SPH.js.map} +0 -0
  172. /package/dist/{chunk-S63LXWMC.js.map → chunk-5M3PQNXI.js.map} +0 -0
  173. /package/dist/{chunk-XHPWTL4I.js.map → chunk-6SW6SB7H.js.map} +0 -0
  174. /package/dist/{chunk-ARYNOWKF.js.map → chunk-BGU25XAY.js.map} +0 -0
  175. /package/dist/{chunk-YRS3QZP2.js.map → chunk-CEBDGZID.js.map} +0 -0
  176. /package/dist/{chunk-ABAZMMG4.js.map → chunk-CK5RM3DJ.js.map} +0 -0
  177. /package/dist/{chunk-PHCPUQVR.js.map → chunk-CTUJO23Z.js.map} +0 -0
  178. /package/dist/{chunk-QZX7SYKU.js.map → chunk-E6CHHXGY.js.map} +0 -0
  179. /package/dist/{chunk-RGYDFBCT.js.map → chunk-JV4TKXEN.js.map} +0 -0
  180. /package/dist/{chunk-4VL3CEOS.js.map → chunk-LXXGZAD3.js.map} +0 -0
  181. /package/dist/{chunk-URXIQE7I.js.map → chunk-MWDY76MT.js.map} +0 -0
  182. /package/dist/{chunk-V5GLL2JB.js.map → chunk-P3KJCYSR.js.map} +0 -0
  183. /package/dist/{chunk-6MV4JOCL.js.map → chunk-PSX7CT6V.js.map} +0 -0
  184. /package/dist/{chunk-B3Y3QMWI.js.map → chunk-TRTVOVHR.js.map} +0 -0
  185. /package/dist/{chunk-AOTCIUGX.js.map → chunk-TV5Y53R2.js.map} +0 -0
  186. /package/dist/{chunk-XATLUKXK.js.map → chunk-X2KUI7V3.js.map} +0 -0
  187. /package/dist/{chunk-DSL66I4N.js.map → chunk-Y5SNGMB7.js.map} +0 -0
  188. /package/dist/{chunk-7REKOTKG.js.map → chunk-YNOOZFIB.js.map} +0 -0
  189. /package/dist/{load-agent-defs-7IM3GBEQ.js.map → load-agent-defs-JHLE6MAE.js.map} +0 -0
  190. /package/dist/{recompile-project-agents-VR4NLGOU.js.map → recompile-project-agents-ZPP5NOLZ.js.map} +0 -0
  191. /package/dist/{source-loader-GRBVNRAW.js.map → source-loader-RWZAYJ7E.js.map} +0 -0
@@ -3,83 +3,105 @@ import {
3
3
  publishSeedConfig,
4
4
  seedPayloadForInstallation,
5
5
  skillsAuthoredHere
6
- } from "../chunk-NTF4UXGK.js";
6
+ } from "../chunk-XATIKM3P.js";
7
7
  import {
8
8
  RemovalPlanConfirm
9
- } from "../chunk-ZVXGW2IC.js";
10
- import "../chunk-OZXAJNLA.js";
9
+ } from "../chunk-F2ZWFWTP.js";
10
+ import {
11
+ unofferablePlacementsFound
12
+ } from "../chunk-IVNKU4DM.js";
11
13
  import {
12
- openUrl
13
- } from "../chunk-7ANJQLPJ.js";
14
+ arrivalLines,
15
+ arrivalsByScope,
16
+ notInstalledGlobally,
17
+ openUrl,
18
+ readInstalledGlobal,
19
+ reconcileSharedConfig,
20
+ restoreInstalledGlobal,
21
+ sameAssignments,
22
+ skillLabel,
23
+ withUnplaceableAssignees
24
+ } from "../chunk-WSGX4IWC.js";
14
25
  import {
15
26
  runWizardSession
16
- } from "../chunk-RGYDFBCT.js";
17
- import "../chunk-ECURHW3T.js";
18
- import "../chunk-AOTCIUGX.js";
19
- import "../chunk-XHPWTL4I.js";
20
- import "../chunk-URXIQE7I.js";
21
- import "../chunk-ARYNOWKF.js";
22
- import "../chunk-LT5GXEB2.js";
23
- import "../chunk-QZX7SYKU.js";
24
- import "../chunk-S63LXWMC.js";
25
- import "../chunk-DSL66I4N.js";
26
- import "../chunk-QGUP3QJF.js";
27
- import "../chunk-6MV4JOCL.js";
28
- import "../chunk-XATLUKXK.js";
29
- import "../chunk-V5GLL2JB.js";
30
- import "../chunk-4VL3CEOS.js";
31
- import "../chunk-Q4IRRVXK.js";
27
+ } from "../chunk-JV4TKXEN.js";
28
+ import "../chunk-HR4YDSJK.js";
29
+ import "../chunk-TV5Y53R2.js";
30
+ import "../chunk-6SW6SB7H.js";
31
+ import "../chunk-MWDY76MT.js";
32
+ import "../chunk-BGU25XAY.js";
33
+ import "../chunk-VPJUCVU7.js";
34
+ import "../chunk-E6CHHXGY.js";
35
+ import "../chunk-5M3PQNXI.js";
36
+ import "../chunk-Y5SNGMB7.js";
37
+ import "../chunk-CBMAO6OP.js";
38
+ import "../chunk-PSX7CT6V.js";
39
+ import "../chunk-X2KUI7V3.js";
40
+ import "../chunk-P3KJCYSR.js";
41
+ import "../chunk-LXXGZAD3.js";
42
+ import "../chunk-57KU6SPH.js";
32
43
  import "../chunk-TSIU7DME.js";
33
- import "../chunk-XVAQG2CV.js";
44
+ import "../chunk-JOEA52NR.js";
34
45
  import {
35
- Spinner
36
- } from "../chunk-ZBPEFQ4G.js";
37
- import "../chunk-NQXO4LR3.js";
38
- import "../chunk-J27W6TXS.js";
39
- import "../chunk-3WVH2CTK.js";
40
- import "../chunk-YRS3QZP2.js";
46
+ awaitUnderSpinner
47
+ } from "../chunk-VRXX4D6K.js";
48
+ import "../chunk-4C7GL4F7.js";
49
+ import "../chunk-XQHZPINL.js";
50
+ import "../chunk-5P26XBZO.js";
51
+ import "../chunk-CEBDGZID.js";
41
52
  import "../chunk-WTJ3AY33.js";
42
- import "../chunk-ABAZMMG4.js";
53
+ import "../chunk-CK5RM3DJ.js";
43
54
  import {
44
- fetchSeedConfig,
45
- registerExternalSkills,
46
- writeExternalSkills
47
- } from "../chunk-X4SSJZLY.js";
55
+ fetchSeedConfig
56
+ } from "../chunk-B5UUHBAM.js";
48
57
  import {
49
58
  promptConfirm
50
- } from "../chunk-JCPANDNR.js";
59
+ } from "../chunk-4AAOOAIN.js";
60
+ import "../chunk-OZXAJNLA.js";
61
+ import {
62
+ hostCompileNotices
63
+ } from "../chunk-UCORXS4D.js";
51
64
  import {
52
65
  applyMigratedGlobalSources,
53
66
  compileAgentsAllScopes,
67
+ compileProjectScope,
54
68
  detectProject,
55
69
  loadSource,
70
+ movedGlobalAgentInputs,
56
71
  mutateGlobal,
57
- normalizeProjectPath,
72
+ sayCapturedWarnings,
58
73
  writeProjectConfig
59
- } from "../chunk-X37UYIE3.js";
74
+ } from "../chunk-WTANOSXK.js";
60
75
  import {
61
76
  copyLocalSkills,
62
77
  discoverInstalledSkills,
63
78
  removeCompiledAgents,
64
79
  uninstallPluginSkills
65
- } from "../chunk-2CQNPLVF.js";
80
+ } from "../chunk-WIFIAQZU.js";
66
81
  import {
67
82
  loadAgentDefs
68
- } from "../chunk-B6FSLXYN.js";
69
- import "../chunk-JU4ZGJ7A.js";
70
- import "../chunk-B3Y3QMWI.js";
71
- import {
72
- render
73
- } from "../chunk-JFLVEFFP.js";
83
+ } from "../chunk-42TNV2TK.js";
84
+ import "../chunk-UR3RRTPO.js";
85
+ import "../chunk-V5CWACR5.js";
86
+ import "../chunk-TRTVOVHR.js";
87
+ import "../chunk-JFLVEFFP.js";
74
88
  import {
75
89
  formatScopeTag
76
- } from "../chunk-K5ITEA3I.js";
90
+ } from "../chunk-UBSSIIWD.js";
91
+ import {
92
+ providerFlag,
93
+ providerNamedBy,
94
+ refuseAnAmbiguousInstallation
95
+ } from "../chunk-MBUGQI2M.js";
77
96
  import {
78
97
  BaseCommand,
79
- EXIT_CODES
80
- } from "../chunk-JIERYE6B.js";
81
- import "../chunk-NKGYKOB7.js";
82
- import "../chunk-PHCPUQVR.js";
98
+ EXIT_CODES,
99
+ carriedSkillsThatDiffer,
100
+ registerExternalSkills,
101
+ writeExternalSkills
102
+ } from "../chunk-AAWZED5M.js";
103
+ import "../chunk-6CY6PW5X.js";
104
+ import "../chunk-CTUJO23Z.js";
83
105
  import {
84
106
  ERROR_MESSAGES,
85
107
  INCOMPLETE_WORK_RECOVERY,
@@ -88,23 +110,28 @@ import {
88
110
  SHARED_CONFIG_APPLY,
89
111
  STATUS_MESSAGES,
90
112
  agentsNotCompiled,
113
+ applySharedConfigHere,
91
114
  authoredHereKept,
92
115
  buildMarketplacePluginRef,
93
116
  carriedSkillsWritten,
94
- claudePluginInstall,
95
- claudePluginUninstall,
96
117
  deleteLocalSkill,
97
118
  detectMigrations,
98
119
  discoverAllPluginSkills,
99
120
  ejectCopyFailureError,
100
121
  executeMigration,
122
+ foldLocalSkillIntoGlobal,
101
123
  getErrorMessage,
102
- globallyInstalledRemoved,
103
- installBaseDir,
124
+ holdsItsOwnInstallation,
125
+ hostAt,
104
126
  isHomeDirectory,
105
- loadProjectConfigFromDir,
127
+ keptAsInstalledGlobally,
128
+ keptUnassigned,
106
129
  localSkillsCopied,
107
130
  migrateLocalSkillScope,
131
+ nothingInstalledToApplyTo,
132
+ plural,
133
+ projectCopyRemoved,
134
+ providerInUse,
108
135
  recompileSummary,
109
136
  resolveInstallPaths,
110
137
  seedToWizardResult,
@@ -112,119 +139,38 @@ import {
112
139
  sharedConfigNeedsTerminal,
113
140
  skippedUnknownAgents,
114
141
  skippedUnknownSkills,
115
- toClaudePluginScope,
116
142
  unplaceableKept,
117
- unresolvedSkillRemovalReasons
118
- } from "../chunk-XPDVAJDH.js";
143
+ unresolvedSkillRemovalReasons,
144
+ wizardNeedsTerminal
145
+ } from "../chunk-IM45LLQX.js";
119
146
  import {
120
- getCategoryDomain,
121
147
  getSkillById,
122
148
  getSkillDisplayName,
123
149
  matrix,
124
- typedEntries,
125
150
  typedKeys
126
- } from "../chunk-AVK2HEKB.js";
151
+ } from "../chunk-GKPW33FP.js";
127
152
  import {
128
153
  CLI_COLORS,
129
154
  CLI_INVOKE_COMMAND,
130
155
  EDIT_PROJECT_SETUP_FLAG,
156
+ EDIT_PROJECT_SETUP_MARKETPLACE_FLAG,
131
157
  EJECT_SOURCE,
132
158
  activeAgentNames,
133
159
  activeAgentScopeMap,
134
160
  editorConfigUrl,
135
161
  formatSourceDisplayName,
136
162
  isActiveAt,
137
- orderDomains
138
- } from "../chunk-UITEKY2R.js";
163
+ isGlobalTombstone
164
+ } from "../chunk-AQXKAPCD.js";
139
165
  import "../chunk-OI2H6M5I.js";
140
166
 
141
167
  // src/cli/commands/edit.tsx
142
- import os from "os";
143
168
  import path from "path";
144
169
  import chalk from "chalk";
145
170
  import { Flags } from "@oclif/core";
146
171
  import { difference, indexBy, partition } from "remeda";
147
-
148
- // src/cli/lib/seed/seed-apply.ts
149
- var NOTHING_KEPT = {
150
- authoredSkillIds: [],
151
- unplaceableSkillIds: []
152
- };
153
- function reconcileSharedConfig(options) {
154
- const { decoded, installed } = options;
155
- if (!installed) return { result: decoded, kept: NOTHING_KEPT };
156
- const keptSkills = skillsToKeep(options, installed);
157
- if (keptSkills.length === 0) return { result: decoded, kept: NOTHING_KEPT };
158
- return {
159
- result: withKeptEntries(decoded, installed, keptSkills),
160
- kept: describeKept(options, keptSkills)
161
- };
162
- }
163
- function skillsToKeep(options, installed) {
164
- const named = new Set(options.decoded.skills.map((skill) => skill.id));
165
- return installed.skills.filter(
166
- (skill) => !skill.excluded && !named.has(skill.id) && mayNotRemove(skill, options)
167
- );
168
- }
169
- function mayNotRemove(skill, options) {
170
- return options.authoredHere.has(skill.id) || options.unplaceable.has(skill.id);
171
- }
172
- function describeKept(options, keptSkills) {
173
- const idsKeptFor = (reason) => keptSkills.filter((skill) => reasonKept(skill, options) === reason).map((skill) => skill.id);
174
- return {
175
- authoredSkillIds: idsKeptFor("authored"),
176
- unplaceableSkillIds: idsKeptFor("unplaceable")
177
- };
178
- }
179
- function reasonKept(skill, options) {
180
- return options.authoredHere.has(skill.id) ? "authored" : "unplaceable";
181
- }
182
- function withKeptEntries(decoded, installed, keptSkills) {
183
- return {
184
- ...decoded,
185
- skills: [...decoded.skills, ...keptSkills],
186
- selectedDomains: withKeptDomains(decoded.selectedDomains, keptSkills),
187
- ...decoded.assignedStack !== void 0 && {
188
- assignedStack: withKeptStackRows(decoded.assignedStack, installed.stack, {
189
- keptSkillIds: new Set(keptSkills.map((skill) => skill.id)),
190
- survivingAgents: new Set(decoded.selectedAgents)
191
- })
192
- }
193
- };
194
- }
195
- function withKeptDomains(selected, keptSkills) {
196
- const keptDomains = keptSkills.flatMap((skill) => domainOfSkill(skill.id) ?? []);
197
- const missing = keptDomains.filter((domain) => !selected.includes(domain));
198
- if (missing.length === 0) return selected;
199
- return orderDomains([...selected, ...new Set(missing)]);
200
- }
201
- function domainOfSkill(skillId) {
202
- const category = matrix.skills[skillId]?.category;
203
- return category === void 0 ? void 0 : getCategoryDomain(category);
204
- }
205
- function withKeptStackRows(assigned, installedStack, filter) {
206
- if (!installedStack) return assigned;
207
- const carried = { ...assigned };
208
- for (const [agent, agentStack] of typedEntries(installedStack)) {
209
- if (!filter.survivingAgents.has(agent)) continue;
210
- const rows = keptRowsFor(agentStack, filter.keptSkillIds);
211
- if (typedKeys(rows).length === 0) continue;
212
- carried[agent] = { ...carried[agent], ...rows };
213
- }
214
- return carried;
215
- }
216
- function keptRowsFor(agentStack, keptSkillIds) {
217
- const rows = {};
218
- for (const [category, assignments] of typedEntries(agentStack)) {
219
- const carried = assignments.filter((assignment) => keptSkillIds.has(assignment.id));
220
- if (carried.length > 0) rows[category] = carried;
221
- }
222
- return rows;
223
- }
224
-
225
- // src/cli/commands/edit.tsx
226
172
  import { jsx } from "react/jsx-runtime";
227
- var RECOMPILE_SUBJECT = "agents";
173
+ var RECOMPILE_SUBJECT = "agent";
228
174
  function formatDualScopeTransition(displayName, to) {
229
175
  const isAdd = to === "project";
230
176
  const prefix = isAdd ? "+" : "-";
@@ -251,6 +197,9 @@ function formatAgentScopeChangeLine(agentName, change, dualScopeAgentTransitions
251
197
  function scopeArrow(change) {
252
198
  return ` (${formatScopeTag(change.from)} \u2192 ${formatScopeTag(change.to)})`;
253
199
  }
200
+ function formatValueChangeLine(subject, change, kind) {
201
+ return chalk.hex(CLI_COLORS.WARNING)(` ~ ${subject}`) + chalk.hex(CLI_COLORS.NEUTRAL)(` (${kind}: ${change.from} \u2192 ${change.to})`);
202
+ }
254
203
  function loadedSourceLabel(sourceResult) {
255
204
  return sourceResult.marketplace ?? sourceResult.sourceConfig.source;
256
205
  }
@@ -259,55 +208,73 @@ function resolveEditRoot(installation, cwd, setupRequested) {
259
208
  const isGlobal = isHomeDirectory(dir);
260
209
  return { dir, isGlobal, isProjectSetup: setupRequested && !isGlobal };
261
210
  }
262
- function globalScopePlan(changes, kept) {
263
- const sections = removalSections(changes.removedSkills, changes.removedAgents);
211
+ function sharedConfigPlan(changes, kept) {
212
+ const dropped = droppedProjectHalves(changes);
213
+ const skillLines = [
214
+ ...changes.removedSkills.map(skillLabel),
215
+ ...dropped.skillIds.map(droppedSkillLine)
216
+ ];
217
+ const agentLines = [...changes.removedAgents, ...dropped.agentNames.map(projectCopyRemoved)];
218
+ const sections = removalSections(skillLines, agentLines);
264
219
  return { heading: planHeading(sections), sections, statements: kept };
265
220
  }
266
- function projectScopePlan(changes, kept, installed, otherProjects) {
267
- const { here, global } = splitRemovalsByScope(changes, installed);
268
- const sections = [
269
- ...removalSections(here.skills, here.agents),
270
- ...globalRemovalSections(global.skills, global.agents)
271
- ];
272
- return {
273
- heading: planHeading(sections),
274
- sections,
275
- statements: [...globalReachStatement(global, otherProjects), ...kept]
276
- };
277
- }
278
- function splitRemovalsByScope(changes, installed) {
279
- const isGlobalSkill = (id) => installed.skills.some((skill) => skill.id === id && isActiveAt(skill, "global"));
280
- const isGlobalAgent = (name) => installed.agents.some((agent) => agent.name === name && isActiveAt(agent, "global"));
281
- const [globalSkills, projectSkills] = partition(changes.removedSkills, isGlobalSkill);
282
- const [globalAgents, projectAgents] = partition(changes.removedAgents, isGlobalAgent);
283
- return {
284
- here: { skills: projectSkills, agents: projectAgents },
285
- global: { skills: globalSkills, agents: globalAgents }
286
- };
221
+ function droppedSkillLine(skillId) {
222
+ return projectCopyRemoved(skillLabel(skillId));
287
223
  }
288
224
  function removalSections(skills, agents) {
289
225
  return [
290
- { label: SHARED_CONFIG_APPLY.SKILLS_HEADING, items: skills.map(skillLabel) },
291
- { label: SHARED_CONFIG_APPLY.AGENTS_HEADING, items: [...agents] }
292
- ].filter((section) => section.items.length > 0);
293
- }
294
- function globalRemovalSections(skills, agents) {
295
- return [
296
- { label: SHARED_CONFIG_APPLY.GLOBAL_SKILLS_HEADING, items: skills.map(skillLabel) },
297
- { label: SHARED_CONFIG_APPLY.GLOBAL_AGENTS_HEADING, items: [...agents] }
226
+ { label: SHARED_CONFIG_APPLY.SKILLS_HEADING, items: skills },
227
+ { label: SHARED_CONFIG_APPLY.AGENTS_HEADING, items: agents }
298
228
  ].filter((section) => section.items.length > 0);
299
229
  }
300
- function globalReachStatement(global, otherProjects) {
301
- if (global.skills.length === 0 && global.agents.length === 0) return [];
302
- return [globallyInstalledRemoved(otherProjects)];
230
+ function droppedProjectHalves(changes) {
231
+ const droppedSkills = changes.collapsedPairs.filter((pair) => !pair.folded);
232
+ const droppedAgents = [...changes.agentScopeChanges].filter(
233
+ ([name, change]) => change.to === "global" && changes.dualScopeAgentTransitions.has(name)
234
+ );
235
+ return {
236
+ skillIds: droppedSkills.map(({ projectHalf }) => projectHalf.id),
237
+ agentNames: droppedAgents.map(([name]) => name)
238
+ };
303
239
  }
304
240
  function planHeading(sections) {
305
241
  if (sections.length === 0) return SHARED_CONFIG_APPLY.NOTHING_REMOVED;
306
242
  return SHARED_CONFIG_APPLY.PREVIEW_HEADING;
307
243
  }
308
- function skillLabel(skillId) {
309
- const displayName = getSkillDisplayName(skillId);
310
- return displayName === skillId ? skillId : `${displayName} (${skillId})`;
244
+ function compilesGlobalScope(producer, editRoot, written) {
245
+ if (editRoot.isGlobal || producer === "wizard") return true;
246
+ return movedGlobalAgentInputs(written);
247
+ }
248
+ function withReassignments(changes, result, installedStack, editRoot) {
249
+ const { assignedStack } = result;
250
+ if (assignedStack === void 0) return { ...changes, reassignedAgents: [] };
251
+ const ownedHere = (agent) => editRoot.isGlobal || isActiveAt(agent, "project");
252
+ const countedAsAdded = (agent) => changes.addedAgents.includes(agent.name);
253
+ const rowsMoved = (agent) => !sameAssignments(assignedStack[agent.name], installedStack?.[agent.name]);
254
+ const reassigned = result.agentConfigs.filter(
255
+ (agent) => ownedHere(agent) && !countedAsAdded(agent) && rowsMoved(agent)
256
+ );
257
+ return { ...changes, reassignedAgents: reassigned.map((agent) => agent.name) };
258
+ }
259
+ function applyArrivals(changes, result) {
260
+ const changedSkills = /* @__PURE__ */ new Set([
261
+ ...changes.addedSkills,
262
+ ...changes.sourceChanges.keys(),
263
+ ...changes.scopeChanges.keys()
264
+ ]);
265
+ const changedAgents = /* @__PURE__ */ new Set([
266
+ ...changes.addedAgents,
267
+ ...changes.agentScopeChanges.keys(),
268
+ ...changes.tuningChanges.keys(),
269
+ ...changes.reassignedAgents
270
+ ]);
271
+ const dropped = droppedProjectHalves(changes);
272
+ const skillArrives = (skill) => changedSkills.has(skill.id) && !dropped.skillIds.includes(skill.id);
273
+ const agentArrives = (agent) => changedAgents.has(agent.name) && !dropped.agentNames.includes(agent.name);
274
+ return arrivalsByScope(
275
+ result.skills.filter(skillArrives),
276
+ result.agentConfigs.filter(agentArrives)
277
+ );
311
278
  }
312
279
  function keptStatements(kept) {
313
280
  return [...authorshipStatement(kept), ...catalogueStatement(kept)];
@@ -320,9 +287,20 @@ function catalogueStatement(kept) {
320
287
  if (kept.unplaceableSkillIds.length === 0) return [];
321
288
  return [unplaceableKept(kept.unplaceableSkillIds)];
322
289
  }
323
- function applyAuthority(producer, editRoot) {
324
- if (editRoot.isGlobal) return "all";
325
- return producer === "shared" ? "all" : "owned";
290
+ function unassignedStatement(unassigned) {
291
+ if (unassigned.length === 0) return [];
292
+ return [
293
+ unassigned.map(({ skillId, agentName, category }) => keptUnassigned(skillId, agentName, category)).join("\n")
294
+ ];
295
+ }
296
+ function keptAsInstalledStatement(held, revisedCarried) {
297
+ const skillIds = [...held.keptAsInstalled.skillIds, ...revisedCarried];
298
+ const { agentNames } = held.keptAsInstalled;
299
+ if (skillIds.length === 0 && agentNames.length === 0) return [];
300
+ return [keptAsInstalledGlobally(skillIds, agentNames)];
301
+ }
302
+ function applyAuthority(editRoot) {
303
+ return editRoot.isGlobal ? "all" : "owned";
326
304
  }
327
305
  var Edit = class _Edit extends BaseCommand {
328
306
  static summary = "Edit skills in the plugin";
@@ -347,14 +325,20 @@ var Edit = class _Edit extends BaseCommand {
347
325
  default: false
348
326
  }),
349
327
  from: Flags.string({
350
- description: "Apply a configuration shared from agentsinc.sh by its id, removing whatever it leaves out",
328
+ description: "Apply a configuration shared from agentsinc.sh by its id, removing whatever it leaves out \u2014 from a project, only the project's own entries",
351
329
  helpValue: "<id>"
352
330
  }),
353
331
  [EDIT_PROJECT_SETUP_FLAG]: Flags.boolean({
354
332
  description: "Internal: this run continues an `init` project setup",
355
333
  default: false,
356
334
  hidden: true
357
- })
335
+ }),
336
+ [EDIT_PROJECT_SETUP_MARKETPLACE_FLAG]: Flags.string({
337
+ description: "Internal: the marketplace `init --marketplace` named for that project setup",
338
+ hidden: true,
339
+ dependsOn: [EDIT_PROJECT_SETUP_FLAG]
340
+ }),
341
+ provider: providerFlag()
358
342
  };
359
343
  /**
360
344
  * The command in two statements: do the work, then answer for it.
@@ -371,11 +355,19 @@ var Edit = class _Edit extends BaseCommand {
371
355
  async applyEdit() {
372
356
  const { flags } = await this.parse(_Edit);
373
357
  const cwd = process.cwd();
374
- if (flags.ui && flags.from !== void 0) return this.openSharedInEditor(flags.from);
358
+ if (flags.ui && flags.from !== void 0) return this.openSharedInEditor(flags.from, cwd);
359
+ await refuseAnAmbiguousInstallation(
360
+ cwd,
361
+ "edit",
362
+ providerNamedBy(flags.provider),
363
+ (message) => this.error(message, { exit: EXIT_CODES.INVALID_ARGS })
364
+ );
375
365
  await this.ensureConfigReadable(cwd);
366
+ await this.refuseUnofferablePlacements(cwd);
367
+ await this.settleSourceLayoutBeforeWriting(cwd);
376
368
  if (flags.ui) return this.openInEditor(cwd);
377
369
  const payload = flags.from === void 0 ? null : await this.fetchSharedConfigOrFail(flags.from);
378
- const context = await this.loadContextUnderSpinner();
370
+ const context = await this.loadContextUnderSpinner(flags[EDIT_PROJECT_SETUP_MARKETPLACE_FLAG]);
379
371
  const editRoot = resolveEditRoot(context.installation, cwd, flags[EDIT_PROJECT_SETUP_FLAG]);
380
372
  await this.ensureSavedSkillsReadable(
381
373
  context.projectConfig?.skills ?? [],
@@ -396,26 +388,28 @@ var Edit = class _Edit extends BaseCommand {
396
388
  agentConfigs: activeNewAgents
397
389
  };
398
390
  const filteredOldConfig = context.projectConfig ? { ...context.projectConfig, skills: activeOldSkills, agents: activeOldAgents } : null;
399
- const changes = detectConfigChanges(filteredOldConfig, filteredResult, {
400
- newSkills: result.skills,
401
- oldSkills: context.projectConfig?.skills ?? [],
402
- newAgents: result.agentConfigs,
403
- oldAgents: context.projectConfig?.agents ?? []
404
- });
405
- if (selection.producer === "shared") {
406
- await this.confirmSharedConfigOrCancel(
407
- changes,
408
- selection.kept,
409
- { skills: activeOldSkills, agents: activeOldAgents },
410
- editRoot
411
- );
412
- await this.writeCarriedSkills(selection.carried);
413
- }
414
- const authority = applyAuthority(selection.producer, editRoot);
391
+ const planned = withReassignments(
392
+ detectConfigChanges(filteredOldConfig, filteredResult, {
393
+ newSkills: result.skills,
394
+ oldSkills: context.projectConfig?.skills ?? [],
395
+ newAgents: result.agentConfigs,
396
+ oldAgents: context.projectConfig?.agents ?? []
397
+ }),
398
+ filteredResult,
399
+ context.projectConfig?.stack,
400
+ editRoot
401
+ );
402
+ const rewritten = selection.producer === "shared" ? await this.confirmAndWriteCarried(selection, planned, filteredResult) : [];
403
+ const changes = {
404
+ ...planned,
405
+ rewrittenSkills: difference(rewritten, planned.addedSkills)
406
+ };
407
+ const authority = applyAuthority(editRoot);
415
408
  if (!hasAnyChanges(changes)) {
416
409
  this.log(chalk.hex(CLI_COLORS.NEUTRAL)("No changes made."));
417
410
  if (!editRoot.isProjectSetup) return;
418
- await this.writeConfigAndCompile(result, context, editRoot, authority);
411
+ await this.writeConfigAndCompile(result, context, editRoot, authority, selection.producer);
412
+ await this.reportWhatThisHostCannotCarry(editRoot);
419
413
  this.logCompletionSummary(changes);
420
414
  return;
421
415
  }
@@ -445,16 +439,21 @@ var Edit = class _Edit extends BaseCommand {
445
439
  context
446
440
  );
447
441
  await this.applyScopeChanges(changes, filteredResult, context, editRoot);
442
+ await this.applyCollapsedPairs(changes, filteredResult, context, editRoot);
448
443
  await this.applySourceChanges(changes, activeOldSkills, editRoot, migratedSkillIds);
449
444
  await this.applyPluginChanges(changes, filteredResult, activeOldSkills, context, editRoot);
450
445
  await this.copyNewLocalSkills(changes, filteredResult, context, editRoot);
451
446
  await this.removeDeletedLocalSkills(changes, activeOldSkills, editRoot);
452
- await this.writeConfigAndCompile(result, context, editRoot, authority);
447
+ await this.writeConfigAndCompile(result, context, editRoot, authority, selection.producer);
453
448
  await this.cleanupStaleAgentFiles(changes, activeOldAgents, editRoot);
449
+ await this.reportWhatThisHostCannotCarry(editRoot);
454
450
  this.logCompletionSummary(changes);
455
451
  }
456
452
  /** The interactive producer: open the wizard on what is installed, return what was chosen. */
457
453
  async selectionFromWizard(context, editRoot) {
454
+ if (!process.stdin.isTTY) {
455
+ this.error(wizardNeedsTerminal("edit"), { exit: EXIT_CODES.ERROR });
456
+ }
458
457
  const result = await this.runEditWizard(context, editRoot);
459
458
  if (!result) return null;
460
459
  return { producer: "wizard", result };
@@ -470,9 +469,12 @@ var Edit = class _Edit extends BaseCommand {
470
469
  * catalogue cannot place, because a destructive apply removes on intent and never on its own
471
470
  * inability. Both are disclosed in the confirm rather than silently excused.
472
471
  *
473
- * A globally installed entry is NOT one of them. It is removable from here, and what its scope
474
- * changes is who the removal reaches — which the confirm names, rather than this putting the
475
- * entry back and calling the reach impossible.
472
+ * From a project the global install comes back too, whole: it is one installation every project
473
+ * on the machine reads, so a project run only ADDS to it (owner ruling 2026-10-02). Every global
474
+ * entry the configuration leaves out is put back as installed, every one it states otherwise is
475
+ * held as installed and named in the confirm, and only the global entries the global install
476
+ * lacks arrive — a skill with its rows, on a global sub-agent already there too. At the home
477
+ * directory the run IS the global install, so nothing is held there.
476
478
  */
477
479
  async selectionFromSharedConfig(payload, context, editRoot) {
478
480
  const { matrix: sourceMatrix } = context.sourceResult;
@@ -482,22 +484,38 @@ var Edit = class _Edit extends BaseCommand {
482
484
  sourceMatrix
483
485
  );
484
486
  this.refuseProjectScopedContentAtHome(result, editRoot.dir);
485
- if (skippedSkillIds.length > 0) this.warn(skippedUnknownSkills(skippedSkillIds));
486
- if (skippedAgentNames.length > 0) this.warn(skippedUnknownAgents(skippedAgentNames));
487
+ const unplaceable = new Set(skippedSkillIds);
487
488
  const reconciled = reconcileSharedConfig({
488
- decoded: result,
489
+ decoded: withUnplaceableAssignees(result, context.projectConfig, payload, unplaceable),
489
490
  installed: context.projectConfig,
490
491
  authoredHere: await this.readAuthoredHere(context.projectConfig, editRoot.dir),
491
- // The ids the decode above could not place. They are the skips just reported, read as
492
- // what STAYS rather than as what did not arrive: the payload named them, so their absence
493
- // from the decode is this catalogue's limit and not an instruction to delete anything.
494
- unplaceable: new Set(skippedSkillIds)
492
+ unplaceable
495
493
  });
494
+ const held = restoreInstalledGlobal(
495
+ reconciled.result,
496
+ editRoot.isGlobal ? null : await readInstalledGlobal(editRoot.dir)
497
+ );
498
+ const arrivingCarried = notInstalledGlobally(carried, held);
499
+ await this.refuseSharedConfigBeforeAsking(
500
+ held.result,
501
+ arrivingCarried,
502
+ editRoot.dir,
503
+ context.sourceResult
504
+ );
505
+ const heldGlobally = difference(carried, arrivingCarried);
506
+ const revisedGlobally = await carriedSkillsThatDiffer(heldGlobally);
507
+ sayCapturedWarnings(context.startupMessages);
508
+ if (skippedSkillIds.length > 0) this.warn(skippedUnknownSkills(skippedSkillIds));
509
+ if (skippedAgentNames.length > 0) this.warn(skippedUnknownAgents(skippedAgentNames));
496
510
  return {
497
511
  producer: "shared",
498
- result: reconciled.result,
499
- kept: keptStatements(reconciled.kept),
500
- carried
512
+ result: held.result,
513
+ kept: [
514
+ ...keptStatements(reconciled.kept),
515
+ ...unassignedStatement(reconciled.unassigned),
516
+ ...keptAsInstalledStatement(held, revisedGlobally)
517
+ ],
518
+ carried: arrivingCarried
501
519
  };
502
520
  }
503
521
  /**
@@ -521,11 +539,17 @@ var Edit = class _Edit extends BaseCommand {
521
539
  /**
522
540
  * The id, fetched — or the run refused before it is.
523
541
  *
524
- * The terminal question is answered first because nothing in the payload can change its
525
- * answer: an apply that cannot be confirmed is over before the store is asked, and a refusal
526
- * that had already spent a round trip would be describing work it never intended to do.
542
+ * Two questions are answered first, because nothing in the payload can change either answer:
543
+ * an apply with nothing to apply to, or that cannot be confirmed, is over before the store is
544
+ * asked, and a refusal that had already spent a round trip would be describing work it never
545
+ * intended to do. Whether anything is installed comes before the terminal: the terminal
546
+ * refusal's way on is this same command from a terminal, which in a folder with nothing
547
+ * installed would only refuse again.
527
548
  */
528
549
  async fetchSharedConfigOrFail(id) {
550
+ if (!await detectProject()) {
551
+ this.error(nothingInstalledToApplyTo(id), { exit: EXIT_CODES.ERROR });
552
+ }
529
553
  if (!process.stdin.isTTY) {
530
554
  this.error(sharedConfigNeedsTerminal(id), { exit: EXIT_CODES.ERROR });
531
555
  }
@@ -562,11 +586,20 @@ var Edit = class _Edit extends BaseCommand {
562
586
  this.handleError(error);
563
587
  }
564
588
  }
589
+ /**
590
+ * Confirms a shared configuration, then writes the skills it brought with it — answering with
591
+ * those whose files now read differently.
592
+ */
593
+ async confirmAndWriteCarried(selection, planned, result) {
594
+ await this.confirmSharedConfigOrCancel(planned, selection.kept, applyArrivals(planned, result));
595
+ return this.writeCarriedSkills(selection.carried);
596
+ }
565
597
  /** Writes the skills the configuration brought with it, and says which they were. */
566
598
  async writeCarriedSkills(carried) {
567
- if (carried.length === 0) return;
568
- await writeExternalSkills(carried);
599
+ if (carried.length === 0) return [];
600
+ const rewritten = await writeExternalSkills(carried);
569
601
  this.log(carriedSkillsWritten(carried.map((skill) => skill.id)));
602
+ return rewritten;
570
603
  }
571
604
  /**
572
605
  * Shows what applying this configuration takes away, and stops the run unless a person says
@@ -577,18 +610,15 @@ var Edit = class _Edit extends BaseCommand {
577
610
  * honesty: nothing is refused over an entry this run cannot remove, and nothing is silent
578
611
  * about one either.
579
612
  *
580
- * WHICH plan is built is decided here and only here, on the directory the run was started in.
581
- * Inside the global installation the scope was chosen and is obvious, so the ordinary confirm
582
- * is the whole of the gate; inside a project a global removal reaches projects nobody here is
583
- * looking at, so it is shown apart and the reach is named.
613
+ * Above it go the two lists every `--from` install prints — what the apply adds or changes in
614
+ * this project, and in the global install — so the question is asked about the whole of what a
615
+ * yes does, not only about what it takes away.
584
616
  */
585
- async confirmSharedConfigOrCancel(changes, kept, installed, editRoot) {
586
- const plan = editRoot.isGlobal ? globalScopePlan(changes, kept) : projectScopePlan(
587
- changes,
588
- kept,
589
- installed,
590
- await this.otherRegisteredProjects(editRoot.dir)
591
- );
617
+ async confirmSharedConfigOrCancel(changes, kept, arrivals) {
618
+ const plan = sharedConfigPlan(changes, kept);
619
+ for (const line of arrivalLines(arrivals)) {
620
+ this.log(line);
621
+ }
592
622
  const outcome = await promptConfirm(({ onConfirm, onCancel }) => /* @__PURE__ */ jsx(
593
623
  RemovalPlanConfirm,
594
624
  {
@@ -605,25 +635,16 @@ var Edit = class _Edit extends BaseCommand {
605
635
  this.error("Cancelled", { exit: EXIT_CODES.CANCELLED });
606
636
  }
607
637
  /**
608
- * Every registered project but this one — the blast radius a global removal actually has.
638
+ * Refuses a configuration whose own host cannot place what it asks for, before the wizard runs.
609
639
  *
610
- * Read from the GLOBAL config rather than from `context.projectConfig`: `projects[]` is the
611
- * registry the fan-out itself walks, and a project's own config never carries it, so taking
612
- * the list from anywhere else would let the confirm name a set the propagation does not.
613
- *
614
- * Best-effort by nature. The list exists to be DISCLOSED, so a home directory that cannot be
615
- * read leaves the disclosure counting nobody rather than failing an apply — and the statement
616
- * it produces then is the one that says no other project is registered.
640
+ * `compile` asks the same question of the same roster and `update` asks it too. `edit` is the
641
+ * command that REWRITES the file, so letting it through would mean a user curating a
642
+ * configuration no command will act on — and then saving it back, with the unofferable row
643
+ * carried forward because nothing on the edit path had any reason to drop it.
617
644
  */
618
- async otherRegisteredProjects(editRoot) {
619
- try {
620
- const global = await loadProjectConfigFromDir(os.homedir());
621
- const here = normalizeProjectPath(editRoot);
622
- return (global?.config.projects ?? []).filter((projectDir) => projectDir !== here);
623
- } catch (error) {
624
- this.warn(`Could not tell which projects share this install: ${getErrorMessage(error)}`);
625
- return [];
626
- }
645
+ async refuseUnofferablePlacements(cwd) {
646
+ const [finding] = await unofferablePlacementsFound(cwd);
647
+ if (finding !== void 0) this.error(finding, { exit: EXIT_CODES.ERROR });
627
648
  }
628
649
  /**
629
650
  * The outbound half of the editor round trip: this installation, minted as a configuration
@@ -637,37 +658,37 @@ var Edit = class _Edit extends BaseCommand {
637
658
  * Nothing on disk is touched. A configuration is read, not rewritten, so a run that changed
638
659
  * anything here would be editing the project on the way to offering to edit it.
639
660
  */
661
+ async openInEditor(projectDir) {
662
+ const prepared = await seedPayloadForInstallation(projectDir);
663
+ if (!prepared.ok) {
664
+ this.error(prepared.error, { exit: EXIT_CODES.ERROR });
665
+ }
666
+ this.log(`Opening ${prepared.skills} skill(s) across ${prepared.agents} sub-agent(s)...`);
667
+ const published = await publishSeedConfig(prepared.payload);
668
+ if (!published.ok) {
669
+ this.error(published.error, { exit: EXIT_CODES.ERROR });
670
+ }
671
+ await this.handToBrowser(published.id);
672
+ }
640
673
  /**
641
674
  * An id somebody shared, opened rather than applied.
642
675
  *
643
676
  * The counterpart of `openInEditor` above and deliberately not a variant of it: that one MINTS,
644
677
  * because an installation is not yet a configuration the store holds. An id already is one, so
645
- * there is nothing to publish, nothing to read off disk, and no way for this to fail except the
646
- * browser refusing to launch — which is a warning beside a link that still works.
678
+ * there is nothing to publish, and no way for this to fail except the browser refusing to launch
679
+ * — which is a warning beside a link that still works.
647
680
  *
648
681
  * `--from` without `--ui` remains the destructive apply. Looking and applying are the two
649
682
  * things a recipient can do with an id, and this is the one that changes nothing.
650
683
  */
651
- async openSharedInEditor(id) {
684
+ async openSharedInEditor(id, cwd) {
652
685
  const url = editorConfigUrl(id);
653
686
  this.log(`Open it at ${url}`);
654
- this.log(`To apply it here instead, run '${CLI_INVOKE_COMMAND} edit --from ${id}'.`);
687
+ this.log(applySharedConfigHere(id, await holdsItsOwnInstallation(cwd)));
655
688
  if (!process.stdin.isTTY) return;
656
689
  const opened = await openUrl(url);
657
690
  if (!opened.ok) this.warn(opened.error);
658
691
  }
659
- async openInEditor(projectDir) {
660
- const prepared = await seedPayloadForInstallation(projectDir);
661
- if (!prepared.ok) {
662
- this.error(prepared.error, { exit: EXIT_CODES.ERROR });
663
- }
664
- this.log(`Opening ${prepared.skills} skill(s) across ${prepared.agents} sub-agent(s)...`);
665
- const published = await publishSeedConfig(prepared.payload);
666
- if (!published.ok) {
667
- this.error(published.error, { exit: EXIT_CODES.ERROR });
668
- }
669
- await this.handToBrowser(published.id);
670
- }
671
692
  /**
672
693
  * The link, printed first and opened second.
673
694
  *
@@ -690,25 +711,20 @@ var Edit = class _Edit extends BaseCommand {
690
711
  if (!opened.ok) this.warn(opened.error);
691
712
  }
692
713
  /**
693
- * The load below, behind a spinner that comes down whichever way the await ends.
694
- *
695
- * The cleanup is a `finally` because all three of `loadContext`'s refusals are raised
696
- * while this spinner is mounted, and oclif would otherwise paint its error under an Ink
697
- * tree still repainting over it. Never a `catch`: the throw reaches oclif untouched, or
698
- * both the error rendering and the pinned exit codes change with it.
714
+ * The load below, behind a spinner that comes down whichever way the await ends — all
715
+ * three of `loadContext`'s refusals are raised while it is mounted.
699
716
  */
700
- async loadContextUnderSpinner() {
701
- const { unmount, clear: clearSpinner } = render(
702
- /* @__PURE__ */ jsx(Spinner, { label: STATUS_MESSAGES.LOADING_SKILLS })
717
+ async loadContextUnderSpinner(setupMarketplace) {
718
+ return awaitUnderSpinner(
719
+ STATUS_MESSAGES.LOADING_SKILLS,
720
+ () => this.loadContext(setupMarketplace)
703
721
  );
704
- try {
705
- return await this.loadContext();
706
- } finally {
707
- clearSpinner();
708
- unmount();
709
- }
710
722
  }
711
- async loadContext() {
723
+ /**
724
+ * @param setupMarketplace - What `init --marketplace` named for the project setup this run
725
+ * continues. Absent, the catalogue is the one the installation stored.
726
+ */
727
+ async loadContext(setupMarketplace) {
712
728
  const detected = await detectProject();
713
729
  if (!detected) {
714
730
  this.error(ERROR_MESSAGES.NO_INSTALLATION, {
@@ -720,13 +736,17 @@ var Edit = class _Edit extends BaseCommand {
720
736
  let sourceResult;
721
737
  let startupMessages = [];
722
738
  try {
723
- const loaded = await loadSource({ projectDir, captureStartupMessages: true });
739
+ const loaded = await loadSource({
740
+ projectDir,
741
+ ...setupMarketplace !== void 0 && { sourceFlag: setupMarketplace },
742
+ captureStartupMessages: true
743
+ });
724
744
  sourceResult = loaded.sourceResult;
725
745
  startupMessages = loaded.startupMessages;
726
746
  const sourceInfo = sourceResult.isLocal ? "local" : sourceResult.sourceConfig.sourceOrigin;
727
747
  startupMessages.push({
728
748
  level: "info",
729
- text: `Loaded ${Object.keys(matrix.skills).length} skills (${sourceInfo})`
749
+ text: `Loaded ${plural(Object.keys(matrix.skills).length, "skill")} (${sourceInfo})`
730
750
  });
731
751
  } catch (error) {
732
752
  this.handleError(error);
@@ -744,7 +764,7 @@ var Edit = class _Edit extends BaseCommand {
744
764
  currentSkillIds = [...mergedIds];
745
765
  startupMessages.push({
746
766
  level: "info",
747
- text: `Found ${currentSkillIds.length} installed skills`
767
+ text: `Found ${plural(currentSkillIds.length, "installed skill")}`
748
768
  });
749
769
  } catch (error) {
750
770
  this.handleError(error);
@@ -755,7 +775,8 @@ var Edit = class _Edit extends BaseCommand {
755
775
  projectDir,
756
776
  sourceResult,
757
777
  startupMessages,
758
- currentSkillIds
778
+ currentSkillIds,
779
+ ...setupMarketplace !== void 0 && sourceResult.marketplace !== void 0 && { setupMarketplace: sourceResult.marketplace }
759
780
  };
760
781
  }
761
782
  async runEditWizard(context, editRoot) {
@@ -771,7 +792,10 @@ var Edit = class _Edit extends BaseCommand {
771
792
  installedSkillIds: currentSkillIds,
772
793
  ...projectConfig?.skills !== void 0 && { installedSkillConfigs: projectConfig.skills },
773
794
  ...projectConfig?.agents !== void 0 && { installedAgentConfigs: projectConfig.agents },
774
- isEditingFromGlobalScope: editRoot.isGlobal
795
+ isEditingFromGlobalScope: editRoot.isGlobal,
796
+ ...context.setupMarketplace !== void 0 && {
797
+ setupMarketplace: context.setupMarketplace
798
+ }
775
799
  },
776
800
  props: {
777
801
  version: this.config.version,
@@ -840,7 +864,7 @@ var Edit = class _Edit extends BaseCommand {
840
864
  loadAgents: async () => (await loadAgentDefs()).agents
841
865
  }
842
866
  );
843
- this.reportPropagatedRecompile(report);
867
+ this.reportFanOut(report);
844
868
  } catch (error) {
845
869
  this.reportIncompleteWork(
846
870
  `Could not record global origin change: ${getErrorMessage(error)}`,
@@ -858,7 +882,10 @@ var Edit = class _Edit extends BaseCommand {
858
882
  scopeChanges,
859
883
  agentScopeChanges,
860
884
  dualScopeSkillTransitions,
861
- dualScopeAgentTransitions
885
+ dualScopeAgentTransitions,
886
+ tuningChanges,
887
+ reassignedAgents,
888
+ rewrittenSkills
862
889
  } = changes;
863
890
  this.log(`
864
891
  ${chalk.hex(CLI_COLORS.WHITE).bold("Changes:")}`);
@@ -901,10 +928,26 @@ ${chalk.hex(CLI_COLORS.WHITE).bold("Changes:")}`);
901
928
  for (const [agentName, change] of agentScopeChanges) {
902
929
  this.log(formatAgentScopeChangeLine(agentName, change, dualScopeAgentTransitions));
903
930
  }
931
+ for (const [agentName, change] of tuningChanges) {
932
+ this.log(formatValueChangeLine(agentName, change, "agent"));
933
+ }
934
+ for (const agentName of reassignedAgents) {
935
+ this.log(
936
+ chalk.hex(CLI_COLORS.WARNING)(` ~ ${agentName}`) + chalk.hex(CLI_COLORS.NEUTRAL)(" (agent: skills reassigned)")
937
+ );
938
+ }
939
+ for (const skillId of rewrittenSkills) {
940
+ this.log(
941
+ chalk.hex(CLI_COLORS.WARNING)(` ~ ${getSkillDisplayName(skillId)}`) + chalk.hex(CLI_COLORS.NEUTRAL)(" (skill: files rewritten)")
942
+ );
943
+ }
904
944
  this.log("");
905
945
  }
906
- async applyMigrations(_changes, filteredResult, activeOldSkills, context, editRoot) {
907
- const migrationPlan = detectMigrations(activeOldSkills, filteredResult.skills);
946
+ async applyMigrations(changes, filteredResult, activeOldSkills, context, editRoot) {
947
+ const migrationPlan = detectMigrations(
948
+ withMaskedGlobalsRestored(activeOldSkills, changes.collapsedPairs),
949
+ filteredResult.skills
950
+ );
908
951
  const migratedSkillIds = /* @__PURE__ */ new Set([
909
952
  ...migrationPlan.toEject.map((m) => m.id),
910
953
  ...migrationPlan.toPlugin.map((m) => m.id)
@@ -915,7 +958,11 @@ ${chalk.hex(CLI_COLORS.WHITE).bold("Changes:")}`);
915
958
  }
916
959
  if (migrationPlan.toPlugin.length > 0) {
917
960
  this.logModeSwitch(migrationPlan.toPlugin.length, INSTALL_MODE_DESCRIPTIONS.plugin);
918
- await this.requireMarketplaceOrExit(context.sourceResult, "migrate skills to plugin mode");
961
+ await this.requireMarketplaceOrExit(
962
+ context.sourceResult,
963
+ "migrate skills to plugin mode",
964
+ hostAt(editRoot.dir)
965
+ );
919
966
  this.announcePluginInstall();
920
967
  }
921
968
  const migrationResult = await executeMigration(
@@ -961,8 +1008,13 @@ ${chalk.hex(CLI_COLORS.WHITE).bold("Changes:")}`);
961
1008
  logModeSwitch(count, modeDescription) {
962
1009
  this.log(chalk.hex(CLI_COLORS.NEUTRAL)(`Switching ${count} skill(s) to ${modeDescription}`));
963
1010
  }
1011
+ /**
1012
+ * The scope moves this edit made, on disk. A collapsed `[P][G]` pair is not one of them: its
1013
+ * project half is dropped or folded ({@link applyCollapsedPairs}), and moving every collapse is
1014
+ * what wrote a dropped copy over the global install.
1015
+ */
964
1016
  async applyScopeChanges(changes, filteredResult, context, editRoot) {
965
- const { scopeChanges } = changes;
1017
+ const scopeChanges = scopeMovesOf(changes);
966
1018
  for (const [skillId, change] of scopeChanges) {
967
1019
  const skillConfig = filteredResult.skills.find((s) => s.id === skillId);
968
1020
  if (skillConfig?.origin === EJECT_SOURCE) {
@@ -976,7 +1028,8 @@ ${chalk.hex(CLI_COLORS.WHITE).bold("Changes:")}`);
976
1028
  if (!hasPluginScopeChanges) return;
977
1029
  const marketplace = await this.requireMarketplaceOrExit(
978
1030
  context.sourceResult,
979
- "migrate plugin skill scopes"
1031
+ "migrate plugin skill scopes",
1032
+ hostAt(editRoot.dir)
980
1033
  );
981
1034
  const pluginScopeResult = await migratePluginSkillScopes(
982
1035
  scopeChanges,
@@ -991,6 +1044,63 @@ ${chalk.hex(CLI_COLORS.WHITE).bold("Changes:")}`);
991
1044
  );
992
1045
  }
993
1046
  }
1047
+ /**
1048
+ * The project's own half of each `[P][G]` pair this edit collapsed. A Local copy `s` folded into
1049
+ * a Local global install moves there, edits included, replacing the global copy every project
1050
+ * reads. Every other half is removed at project scope and nowhere else: its ejected copy deleted,
1051
+ * or its project-scope plugin registration uninstalled.
1052
+ *
1053
+ * The global install's MODE is {@link applyMigrations}' to change, and it changes only when the
1054
+ * collapse carried a new install mode with it — a fold into a plugin installs the plugin there.
1055
+ *
1056
+ * The uninstall is diagnostic, as every plugin uninstall here is: the config no longer names the
1057
+ * registration, so one left behind is untidy rather than wrong.
1058
+ */
1059
+ async applyCollapsedPairs(changes, filteredResult, context, editRoot) {
1060
+ const [foldedCopies, removedPairs] = partition(
1061
+ changes.collapsedPairs,
1062
+ (pair) => foldsItsCopyIntoGlobal(pair, filteredResult.skills)
1063
+ );
1064
+ const [ejectedHalves, pluginHalves] = partition(
1065
+ removedPairs.map(({ projectHalf }) => projectHalf),
1066
+ (half) => half.origin === EJECT_SOURCE
1067
+ );
1068
+ for (const { projectHalf } of foldedCopies) {
1069
+ await foldLocalSkillIntoGlobal(editRoot.dir, projectHalf.id);
1070
+ }
1071
+ for (const half of ejectedHalves) {
1072
+ await deleteLocalSkill(editRoot.dir, half.id, half.scope);
1073
+ }
1074
+ await this.uninstallProjectPluginHalves(
1075
+ pluginHalves,
1076
+ context.sourceResult.marketplace,
1077
+ editRoot
1078
+ );
1079
+ }
1080
+ /** The project-scope registrations of collapsed pairs' plugin halves, uninstalled and reported. */
1081
+ async uninstallProjectPluginHalves(pluginHalves, marketplace, editRoot) {
1082
+ if (pluginHalves.length === 0) return;
1083
+ if (marketplace === void 0) {
1084
+ for (const half of pluginHalves) {
1085
+ this.warn(`Could not uninstall this project's plugin for ${half.id}: no marketplace`);
1086
+ }
1087
+ return;
1088
+ }
1089
+ const uninstallResult = await uninstallPluginSkills(
1090
+ pluginHalves.map((half) => half.id),
1091
+ pluginHalves,
1092
+ marketplace,
1093
+ editRoot.dir
1094
+ );
1095
+ if (uninstallResult.uninstalled.length > 0) {
1096
+ this.log(
1097
+ chalk.hex(CLI_COLORS.NEUTRAL)(`Removed ${uninstallResult.uninstalled.length} plugin(s)`)
1098
+ );
1099
+ }
1100
+ for (const item of uninstallResult.failed) {
1101
+ this.warn(`Failed to uninstall plugin ${item.id}: ${item.error}`);
1102
+ }
1103
+ }
994
1104
  async applySourceChanges(changes, activeOldSkills, editRoot, migratedSkillIds) {
995
1105
  const { sourceChanges } = changes;
996
1106
  for (const [skillId, change] of sourceChanges) {
@@ -999,8 +1109,7 @@ ${chalk.hex(CLI_COLORS.WHITE).bold("Changes:")}`);
999
1109
  }
1000
1110
  if (change.from === EJECT_SOURCE) {
1001
1111
  const oldSkill = activeOldSkills.find((s) => s.id === skillId);
1002
- const deleteDir = installBaseDir(editRoot.dir, oldSkill?.scope);
1003
- await deleteLocalSkill(deleteDir, skillId);
1112
+ await deleteLocalSkill(editRoot.dir, skillId, oldSkill?.scope);
1004
1113
  }
1005
1114
  }
1006
1115
  }
@@ -1015,7 +1124,8 @@ ${chalk.hex(CLI_COLORS.WHITE).bold("Changes:")}`);
1015
1124
  if (addedPluginSkills.length === 0 && removedPluginSkills.length === 0) return;
1016
1125
  const marketplace = await this.requireMarketplaceOrExit(
1017
1126
  context.sourceResult,
1018
- "install or uninstall plugin skills"
1127
+ "install or uninstall plugin skills",
1128
+ hostAt(editRoot.dir)
1019
1129
  );
1020
1130
  if (addedPluginSkills.length > 0) {
1021
1131
  await this.installPluginSkillsReported(
@@ -1061,11 +1171,10 @@ ${chalk.hex(CLI_COLORS.WHITE).bold("Changes:")}`);
1061
1171
  for (const skillId of removedSkills) {
1062
1172
  const oldSkill = activeOldSkills.find((s) => s.id === skillId);
1063
1173
  if (oldSkill?.origin !== EJECT_SOURCE) continue;
1064
- const deleteDir = installBaseDir(editRoot.dir, oldSkill.scope);
1065
- await deleteLocalSkill(deleteDir, skillId);
1174
+ await deleteLocalSkill(editRoot.dir, skillId, oldSkill.scope);
1066
1175
  }
1067
1176
  }
1068
- async writeConfigAndCompile(result, context, editRoot, authority) {
1177
+ async writeConfigAndCompile(result, context, editRoot, authority, producer) {
1069
1178
  let agentDefsResult;
1070
1179
  try {
1071
1180
  agentDefsResult = await loadAgentDefs();
@@ -1090,11 +1199,12 @@ ${chalk.hex(CLI_COLORS.WHITE).bold("Changes:")}`);
1090
1199
  exit: EXIT_CODES.ERROR
1091
1200
  });
1092
1201
  }
1093
- this.reportUnassignedSkills(configResult.config);
1202
+ this.reportUnassignedSkills(configResult.config, result.skills);
1094
1203
  try {
1095
1204
  const agentScopeMap = activeAgentScopeMap(result.agentConfigs);
1096
1205
  const { allSkills } = await discoverInstalledSkills(editRoot.dir);
1097
- const compilationResult = await compileAgentsAllScopes({
1206
+ const compile = compilesGlobalScope(producer, editRoot, configResult.propagation) ? compileAgentsAllScopes : compileProjectScope;
1207
+ const compilationResult = await compile({
1098
1208
  projectDir: editRoot.dir,
1099
1209
  sourcePath: agentDefsResult.sourcePath,
1100
1210
  skills: allSkills,
@@ -1126,7 +1236,7 @@ ${chalk.hex(CLI_COLORS.WHITE).bold("Changes:")}`);
1126
1236
  );
1127
1237
  this.log(`You can manually recompile with '${CLI_INVOKE_COMMAND} compile'.`);
1128
1238
  }
1129
- this.reportPropagatedRecompile(configResult.propagation);
1239
+ this.reportFanOut(configResult.propagation);
1130
1240
  }
1131
1241
  async cleanupStaleAgentFiles(changes, oldAgents, editRoot) {
1132
1242
  for (const removal of planStaleAgentRemovals(changes, oldAgents, editRoot.dir)) {
@@ -1140,6 +1250,24 @@ ${chalk.hex(CLI_COLORS.WHITE).bold("Changes:")}`);
1140
1250
  }
1141
1251
  }
1142
1252
  }
1253
+ /**
1254
+ * What this host could not carry, once per run and after the last write: the lines `init` and
1255
+ * `compile` print, from {@link hostCompileNotices}, so `edit` cannot say something different
1256
+ * about the tree it just compiled.
1257
+ *
1258
+ * After {@link cleanupStaleAgentFiles}, because the question is about the tree as it now stands:
1259
+ * an edit that removed the project's last gated sub-agent must not count the file it deleted.
1260
+ *
1261
+ * Not on a run that owes work, which ends on that account instead: such a run may have left
1262
+ * nothing here to read, and a notice that threw over it would turn the run's
1263
+ * `COMPLETED_WITH_FAILURES` exit into an `ERROR`.
1264
+ */
1265
+ async reportWhatThisHostCannotCarry(editRoot) {
1266
+ if (this.hasIncompleteWork) return;
1267
+ for (const notice of await hostCompileNotices(providerInUse(editRoot.dir), editRoot.dir)) {
1268
+ this.log(notice);
1269
+ }
1270
+ }
1143
1271
  logCompletionSummary(_changes) {
1144
1272
  if (this.hasIncompleteWork) return;
1145
1273
  this.log(`
@@ -1166,6 +1294,18 @@ function detectConfigChanges(oldConfig, wizardResult, fullEntries) {
1166
1294
  (a) => a.name,
1167
1295
  (a) => a.scope
1168
1296
  );
1297
+ const dualScopeSkillTransitions = detectDualScopeTransitions(
1298
+ scopeChanges,
1299
+ fullEntries?.newSkills ?? [],
1300
+ fullEntries?.oldSkills ?? [],
1301
+ (s) => s.id
1302
+ );
1303
+ const collapsedPairs = collapsedPairsOf(
1304
+ scopeChanges,
1305
+ dualScopeSkillTransitions,
1306
+ fullEntries?.oldSkills ?? [],
1307
+ wizardResult.foldedSkillIds ?? []
1308
+ );
1169
1309
  return {
1170
1310
  addedSkills: difference(newSkillIds, oldSkillIds),
1171
1311
  removedSkills: difference(oldSkillIds, newSkillIds),
@@ -1173,26 +1313,36 @@ function detectConfigChanges(oldConfig, wizardResult, fullEntries) {
1173
1313
  removedAgents: difference(oldAgentNames, newAgentNames),
1174
1314
  sourceChanges: detectPropertyChanges(
1175
1315
  wizardResult.skills,
1176
- oldSkillsById,
1316
+ indexBy(withMaskedGlobalsRestored(oldConfig?.skills ?? [], collapsedPairs), (s) => s.id),
1177
1317
  (s) => s.id,
1178
1318
  (s) => s.origin
1179
1319
  ),
1180
1320
  scopeChanges,
1181
1321
  agentScopeChanges,
1182
- dualScopeSkillTransitions: detectDualScopeTransitions(
1183
- scopeChanges,
1184
- fullEntries?.newSkills ?? [],
1185
- fullEntries?.oldSkills ?? [],
1186
- (s) => s.id
1187
- ),
1322
+ dualScopeSkillTransitions,
1323
+ collapsedPairs,
1188
1324
  dualScopeAgentTransitions: detectDualScopeTransitions(
1189
1325
  agentScopeChanges,
1190
1326
  fullEntries?.newAgents ?? [],
1191
1327
  fullEntries?.oldAgents ?? [],
1192
1328
  (a) => a.name
1329
+ ),
1330
+ tuningChanges: detectPropertyChanges(
1331
+ wizardResult.agentConfigs,
1332
+ oldAgentsByName,
1333
+ (a) => a.name,
1334
+ describeTuning
1193
1335
  )
1194
1336
  };
1195
1337
  }
1338
+ var RESTING_TUNING = "defaults";
1339
+ function describeTuning(agent) {
1340
+ const settings = [
1341
+ agent.model === void 0 ? void 0 : `model ${agent.model}`,
1342
+ agent.effort === void 0 ? void 0 : `effort ${agent.effort}`
1343
+ ].filter((setting) => setting !== void 0);
1344
+ return settings.length === 0 ? RESTING_TUNING : settings.join(", ");
1345
+ }
1196
1346
  function detectPropertyChanges(newItems, oldByKey, getKey, getValue) {
1197
1347
  const changes = /* @__PURE__ */ new Map();
1198
1348
  for (const item of newItems) {
@@ -1216,6 +1366,46 @@ function detectDualScopeTransitions(scopeChanges, fullNew, fullOld, getKey) {
1216
1366
  }
1217
1367
  return result;
1218
1368
  }
1369
+ function collapsedPairsOf(scopeChanges, dualScopeSkillTransitions, fullOldSkills, foldedSkillIds) {
1370
+ return [...scopeChanges].filter(([id, change]) => change.to === "global" && dualScopeSkillTransitions.has(id)).map(([id]) => ({
1371
+ projectHalf: oldHalfOf(fullOldSkills, id, (skill) => isActiveAt(skill, "project")),
1372
+ maskedGlobal: oldHalfOf(fullOldSkills, id, isGlobalTombstone),
1373
+ folded: foldedSkillIds.includes(id)
1374
+ }));
1375
+ }
1376
+ function foldsItsCopyIntoGlobal(pair, newSkills) {
1377
+ const { projectHalf, folded } = pair;
1378
+ const globalEntry = newSkills.find(
1379
+ (skill) => skill.id === projectHalf.id && isActiveAt(skill, "global")
1380
+ );
1381
+ return folded && projectHalf.origin === EJECT_SOURCE && globalEntry?.origin === EJECT_SOURCE;
1382
+ }
1383
+ function oldHalfOf(fullOldSkills, id, isHalf) {
1384
+ const half = fullOldSkills.find((skill) => skill.id === id && isHalf(skill));
1385
+ if (half === void 0) {
1386
+ throw new Error(`The config before this edit holds no such half of the pair for '${id}'`);
1387
+ }
1388
+ return half;
1389
+ }
1390
+ function withMaskedGlobalsRestored(oldSkills, collapsedPairs) {
1391
+ const maskedById = indexBy(
1392
+ collapsedPairs.map(({ maskedGlobal }) => maskedGlobal),
1393
+ (skill) => skill.id
1394
+ );
1395
+ return oldSkills.map((skill) => {
1396
+ const masked = maskedById[skill.id];
1397
+ if (masked === void 0 || skill.scope !== "project") return skill;
1398
+ return installRecordedBy(masked);
1399
+ });
1400
+ }
1401
+ function installRecordedBy(tombstone) {
1402
+ const { excluded: _masked, ...install } = tombstone;
1403
+ return install;
1404
+ }
1405
+ function scopeMovesOf(changes) {
1406
+ const collapsed = new Set(changes.collapsedPairs.map(({ projectHalf }) => projectHalf.id));
1407
+ return new Map([...changes.scopeChanges].filter(([id]) => !collapsed.has(id)));
1408
+ }
1219
1409
  var STALE_AGENT_SCOPES = ["project", "global"];
1220
1410
  var UNRECORDED_AGENT_SCOPE = "project";
1221
1411
  function installedScope(name, oldAgents) {
@@ -1235,9 +1425,10 @@ function planStaleAgentRemovals(changes, oldAgents, editRoot) {
1235
1425
  return STALE_AGENT_SCOPES.map(removalAtScope).filter((removal) => removal.agents.length > 0);
1236
1426
  }
1237
1427
  function hasAnyChanges(changes) {
1238
- return changes.addedSkills.length > 0 || changes.removedSkills.length > 0 || changes.addedAgents.length > 0 || changes.removedAgents.length > 0 || changes.sourceChanges.size > 0 || changes.scopeChanges.size > 0 || changes.agentScopeChanges.size > 0;
1428
+ return changes.reassignedAgents.length > 0 || changes.rewrittenSkills.length > 0 || changes.addedSkills.length > 0 || changes.removedSkills.length > 0 || changes.addedAgents.length > 0 || changes.removedAgents.length > 0 || changes.sourceChanges.size > 0 || changes.scopeChanges.size > 0 || changes.agentScopeChanges.size > 0 || changes.tuningChanges.size > 0;
1239
1429
  }
1240
1430
  async function migratePluginSkillScopes(scopeChanges, skills, marketplace, projectDir) {
1431
+ const host = hostAt(projectDir);
1241
1432
  const migrated = [];
1242
1433
  const failed = [];
1243
1434
  for (const [skillId, change] of scopeChanges) {
@@ -1245,13 +1436,12 @@ async function migratePluginSkillScopes(scopeChanges, skills, marketplace, proje
1245
1436
  if (!skillConfig || skillConfig.origin === EJECT_SOURCE) {
1246
1437
  continue;
1247
1438
  }
1248
- const newPluginScope = toClaudePluginScope(change.to);
1249
1439
  const pluginRef = buildMarketplacePluginRef(skillId, marketplace);
1250
1440
  try {
1251
1441
  if (change.from === "project") {
1252
- await claudePluginUninstall(pluginRef, "project", projectDir);
1442
+ await host.uninstallPlugin(pluginRef, "project", projectDir);
1253
1443
  }
1254
- await claudePluginInstall(pluginRef, newPluginScope, projectDir);
1444
+ await host.installPlugin(pluginRef, change.to, projectDir);
1255
1445
  migrated.push(skillId);
1256
1446
  } catch (error) {
1257
1447
  failed.push({ id: skillId, error: getErrorMessage(error) });