agents-inc 0.168.0 → 0.170.1

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 (200) hide show
  1. package/CHANGELOG.md +29 -0
  2. package/README.md +18 -15
  3. package/dist/{chunk-JIBCVXXL.js → chunk-3G7X2WKI.js} +4 -4
  4. package/dist/{chunk-JOEA52NR.js → chunk-44TE3RKH.js} +46 -2
  5. package/dist/chunk-44TE3RKH.js.map +1 -0
  6. package/dist/{chunk-NU2K5G54.js → chunk-52HDHJ7I.js} +11 -19
  7. package/dist/chunk-52HDHJ7I.js.map +1 -0
  8. package/dist/{chunk-EH2PGPLP.js → chunk-6HNXYYVF.js} +39 -22
  9. package/dist/chunk-6HNXYYVF.js.map +1 -0
  10. package/dist/{chunk-4UKMQUAU.js → chunk-6ZRH5RHC.js} +10 -11
  11. package/dist/chunk-6ZRH5RHC.js.map +1 -0
  12. package/dist/{chunk-5JUQKGCP.js → chunk-7RDMTR64.js} +14 -34
  13. package/dist/chunk-7RDMTR64.js.map +1 -0
  14. package/dist/{chunk-3LZNY46H.js → chunk-BMRUNMPV.js} +4 -4
  15. package/dist/{chunk-VVRI35SK.js → chunk-CLPUWOSA.js} +4 -4
  16. package/dist/{chunk-VVRI35SK.js.map → chunk-CLPUWOSA.js.map} +1 -1
  17. package/dist/{chunk-TW35AEB4.js → chunk-F2BHT5C4.js} +9 -7
  18. package/dist/chunk-F2BHT5C4.js.map +1 -0
  19. package/dist/{chunk-27AVGFXH.js → chunk-F5EBEATU.js} +2 -2
  20. package/dist/{chunk-GE7NUPMI.js → chunk-HED2DAXZ.js} +3 -3
  21. package/dist/{chunk-7PYXS2QU.js → chunk-KOLDW6SF.js} +3 -3
  22. package/dist/{chunk-7PYXS2QU.js.map → chunk-KOLDW6SF.js.map} +1 -1
  23. package/dist/{chunk-C2UISKIM.js → chunk-MQ6CGZNJ.js} +109 -422
  24. package/dist/chunk-MQ6CGZNJ.js.map +1 -0
  25. package/dist/{chunk-P6I72PR3.js → chunk-NCWDK6L7.js} +115 -196
  26. package/dist/chunk-NCWDK6L7.js.map +1 -0
  27. package/dist/{chunk-VRXX4D6K.js → chunk-NEZ4OAOL.js} +1 -1
  28. package/dist/chunk-NEZ4OAOL.js.map +1 -0
  29. package/dist/chunk-NIHUOWE4.js +106 -0
  30. package/dist/chunk-NIHUOWE4.js.map +1 -0
  31. package/dist/{chunk-OI2H6M5I.js → chunk-NQW25DCF.js} +2 -2
  32. package/dist/chunk-NQW25DCF.js.map +1 -0
  33. package/dist/{chunk-ZUGH4MQG.js → chunk-OYJQUA3D.js} +3 -3
  34. package/dist/{chunk-ZUGH4MQG.js.map → chunk-OYJQUA3D.js.map} +1 -1
  35. package/dist/{chunk-AG3ZVM3B.js → chunk-PJWGTNOX.js} +186 -210
  36. package/dist/chunk-PJWGTNOX.js.map +1 -0
  37. package/dist/{chunk-HR7TK2XW.js → chunk-RIPSGNLU.js} +3 -3
  38. package/dist/chunk-RIPSGNLU.js.map +1 -0
  39. package/dist/{chunk-4DRFEYCE.js → chunk-SZYQISA2.js} +7 -7
  40. package/dist/chunk-SZYQISA2.js.map +1 -0
  41. package/dist/{chunk-W6GO2CYX.js → chunk-USVBYQSQ.js} +2 -2
  42. package/dist/{chunk-H4ZKGGTE.js → chunk-V3KTSP3Q.js} +50 -42
  43. package/dist/chunk-V3KTSP3Q.js.map +1 -0
  44. package/dist/{chunk-KTLKR4YY.js → chunk-WTWMGH2C.js} +2 -2
  45. package/dist/commands/build/marketplace.js +23 -22
  46. package/dist/commands/build/marketplace.js.map +1 -1
  47. package/dist/commands/build/plugins.js +8 -9
  48. package/dist/commands/build/plugins.js.map +1 -1
  49. package/dist/commands/compile.js +19 -20
  50. package/dist/commands/compile.js.map +1 -1
  51. package/dist/commands/doctor.js +17 -18
  52. package/dist/commands/doctor.js.map +1 -1
  53. package/dist/commands/edit.js +118 -297
  54. package/dist/commands/edit.js.map +1 -1
  55. package/dist/commands/eject.js +21 -33
  56. package/dist/commands/eject.js.map +1 -1
  57. package/dist/commands/init.js +17 -45
  58. package/dist/commands/list.js +19 -17
  59. package/dist/commands/list.js.map +1 -1
  60. package/dist/commands/new/marketplace.js +11 -11
  61. package/dist/commands/new/marketplace.js.map +1 -1
  62. package/dist/commands/search.js +12 -13
  63. package/dist/commands/search.js.map +1 -1
  64. package/dist/commands/share.js +11 -12
  65. package/dist/commands/share.js.map +1 -1
  66. package/dist/commands/uninstall.js +18 -20
  67. package/dist/commands/uninstall.js.map +1 -1
  68. package/dist/commands/update.js +8 -9
  69. package/dist/commands/update.js.map +1 -1
  70. package/dist/components/common/removal-plan-confirm.js +2 -2
  71. package/dist/components/common/scroll-affordance.js +9 -0
  72. package/dist/components/common/select-list.js +2 -3
  73. package/dist/components/common/skill-agent-summary.js +11 -0
  74. package/dist/components/common/spinner.js +1 -1
  75. package/dist/{chunk-QWFG7Y3R.js → components/common/summary-panel.js} +57 -31
  76. package/dist/components/common/summary-panel.js.map +1 -0
  77. package/dist/config-exports.js +1 -1
  78. package/dist/hooks/init.js +18 -46
  79. package/dist/hooks/init.js.map +1 -1
  80. package/dist/load-agent-defs-YMDWBFDP.js +14 -0
  81. package/dist/recompile-project-agents-SZ76WNTW.js +18 -0
  82. package/dist/{source-loader-FRJTCSDL.js → source-loader-C5SQXZXI.js} +5 -5
  83. package/dist/src/agents/meta/codex-keeper/playbook.md +2 -3
  84. package/package.json +2 -3
  85. package/src/agents/meta/codex-keeper/playbook.md +2 -3
  86. package/src/schemas/project-config.schema.json +1 -1
  87. package/assets/demo.tape +0 -266
  88. package/dist/chunk-23DNVNFP.js +0 -292
  89. package/dist/chunk-23DNVNFP.js.map +0 -1
  90. package/dist/chunk-3DIDV6H3.js +0 -268
  91. package/dist/chunk-3DIDV6H3.js.map +0 -1
  92. package/dist/chunk-4DRFEYCE.js.map +0 -1
  93. package/dist/chunk-4HWOYYY7.js +0 -92
  94. package/dist/chunk-4HWOYYY7.js.map +0 -1
  95. package/dist/chunk-4UKMQUAU.js.map +0 -1
  96. package/dist/chunk-5JUQKGCP.js.map +0 -1
  97. package/dist/chunk-6WGXTB2L.js +0 -28
  98. package/dist/chunk-6WGXTB2L.js.map +0 -1
  99. package/dist/chunk-AG3ZVM3B.js.map +0 -1
  100. package/dist/chunk-C2UISKIM.js.map +0 -1
  101. package/dist/chunk-CMJBKQUH.js +0 -23
  102. package/dist/chunk-CMJBKQUH.js.map +0 -1
  103. package/dist/chunk-DJEO3F2H.js +0 -230
  104. package/dist/chunk-DJEO3F2H.js.map +0 -1
  105. package/dist/chunk-EH2PGPLP.js.map +0 -1
  106. package/dist/chunk-GRL73YPF.js +0 -197
  107. package/dist/chunk-GRL73YPF.js.map +0 -1
  108. package/dist/chunk-H4ZKGGTE.js.map +0 -1
  109. package/dist/chunk-HI6YB7XP.js +0 -59
  110. package/dist/chunk-HI6YB7XP.js.map +0 -1
  111. package/dist/chunk-HL3GYRMR.js +0 -17
  112. package/dist/chunk-HL3GYRMR.js.map +0 -1
  113. package/dist/chunk-HR7TK2XW.js.map +0 -1
  114. package/dist/chunk-JOEA52NR.js.map +0 -1
  115. package/dist/chunk-JPMV4E4E.js +0 -118
  116. package/dist/chunk-JPMV4E4E.js.map +0 -1
  117. package/dist/chunk-JVUN6AOO.js +0 -237
  118. package/dist/chunk-JVUN6AOO.js.map +0 -1
  119. package/dist/chunk-KQ3PDARZ.js +0 -25
  120. package/dist/chunk-KQ3PDARZ.js.map +0 -1
  121. package/dist/chunk-L3W2JWBA.js +0 -168
  122. package/dist/chunk-L3W2JWBA.js.map +0 -1
  123. package/dist/chunk-LFUJCRCT.js +0 -27
  124. package/dist/chunk-LFUJCRCT.js.map +0 -1
  125. package/dist/chunk-NU2K5G54.js.map +0 -1
  126. package/dist/chunk-OI2H6M5I.js.map +0 -1
  127. package/dist/chunk-P6I72PR3.js.map +0 -1
  128. package/dist/chunk-PCFUXQJA.js +0 -317
  129. package/dist/chunk-PCFUXQJA.js.map +0 -1
  130. package/dist/chunk-PLX2FLEQ.js +0 -48
  131. package/dist/chunk-PLX2FLEQ.js.map +0 -1
  132. package/dist/chunk-QWFG7Y3R.js.map +0 -1
  133. package/dist/chunk-SLBL3WIP.js +0 -121
  134. package/dist/chunk-SLBL3WIP.js.map +0 -1
  135. package/dist/chunk-TSIU7DME.js +0 -43
  136. package/dist/chunk-TSIU7DME.js.map +0 -1
  137. package/dist/chunk-TW35AEB4.js.map +0 -1
  138. package/dist/chunk-VRXX4D6K.js.map +0 -1
  139. package/dist/chunk-W5KEYSOL.js +0 -51
  140. package/dist/chunk-W5KEYSOL.js.map +0 -1
  141. package/dist/chunk-WNLF5EDZ.js +0 -1170
  142. package/dist/chunk-WNLF5EDZ.js.map +0 -1
  143. package/dist/chunk-WTJ3AY33.js +0 -31
  144. package/dist/chunk-WTJ3AY33.js.map +0 -1
  145. package/dist/chunk-X6ZZEYO3.js +0 -53
  146. package/dist/chunk-X6ZZEYO3.js.map +0 -1
  147. package/dist/chunk-XQHZPINL.js +0 -89
  148. package/dist/chunk-XQHZPINL.js.map +0 -1
  149. package/dist/chunk-YN3SWF53.js +0 -35
  150. package/dist/chunk-YN3SWF53.js.map +0 -1
  151. package/dist/components/wizard/category-grid.js +0 -13
  152. package/dist/components/wizard/checkbox-grid.js +0 -12
  153. package/dist/components/wizard/domain-selection.js +0 -18
  154. package/dist/components/wizard/run-wizard-session.js +0 -40
  155. package/dist/components/wizard/run-wizard-session.js.map +0 -1
  156. package/dist/components/wizard/scroll-affordance.js +0 -9
  157. package/dist/components/wizard/skill-agent-summary.js +0 -13
  158. package/dist/components/wizard/source-grid.js +0 -16
  159. package/dist/components/wizard/source-grid.js.map +0 -1
  160. package/dist/components/wizard/stack-selection.js +0 -17
  161. package/dist/components/wizard/stack-selection.js.map +0 -1
  162. package/dist/components/wizard/step-agents.js +0 -18
  163. package/dist/components/wizard/step-agents.js.map +0 -1
  164. package/dist/components/wizard/step-build.js +0 -18
  165. package/dist/components/wizard/step-build.js.map +0 -1
  166. package/dist/components/wizard/step-confirm.js +0 -18
  167. package/dist/components/wizard/step-confirm.js.map +0 -1
  168. package/dist/components/wizard/step-sources.js +0 -19
  169. package/dist/components/wizard/step-sources.js.map +0 -1
  170. package/dist/components/wizard/step-stack.js +0 -18
  171. package/dist/components/wizard/step-stack.js.map +0 -1
  172. package/dist/components/wizard/summary-panel.js +0 -17
  173. package/dist/components/wizard/summary-panel.js.map +0 -1
  174. package/dist/components/wizard/toast.js +0 -9
  175. package/dist/components/wizard/toast.js.map +0 -1
  176. package/dist/components/wizard/wizard-layout.js +0 -22
  177. package/dist/components/wizard/wizard-layout.js.map +0 -1
  178. package/dist/components/wizard/wizard-tabs.js +0 -11
  179. package/dist/components/wizard/wizard-tabs.js.map +0 -1
  180. package/dist/components/wizard/wizard.js +0 -39
  181. package/dist/components/wizard/wizard.js.map +0 -1
  182. package/dist/load-agent-defs-5XMVB3MU.js +0 -14
  183. package/dist/load-agent-defs-5XMVB3MU.js.map +0 -1
  184. package/dist/recompile-project-agents-7PQWYQ6B.js +0 -18
  185. package/dist/recompile-project-agents-7PQWYQ6B.js.map +0 -1
  186. package/dist/source-loader-FRJTCSDL.js.map +0 -1
  187. package/dist/stores/wizard-store.js +0 -24
  188. package/dist/stores/wizard-store.js.map +0 -1
  189. /package/assets/{demo.gif → legacy-wizard.gif} +0 -0
  190. /package/dist/{chunk-JIBCVXXL.js.map → chunk-3G7X2WKI.js.map} +0 -0
  191. /package/dist/{chunk-3LZNY46H.js.map → chunk-BMRUNMPV.js.map} +0 -0
  192. /package/dist/{chunk-27AVGFXH.js.map → chunk-F5EBEATU.js.map} +0 -0
  193. /package/dist/{chunk-GE7NUPMI.js.map → chunk-HED2DAXZ.js.map} +0 -0
  194. /package/dist/{chunk-W6GO2CYX.js.map → chunk-USVBYQSQ.js.map} +0 -0
  195. /package/dist/{chunk-KTLKR4YY.js.map → chunk-WTWMGH2C.js.map} +0 -0
  196. /package/dist/components/{wizard → common}/scroll-affordance.js.map +0 -0
  197. /package/dist/components/{wizard → common}/skill-agent-summary.js.map +0 -0
  198. /package/dist/{components/wizard/category-grid.js.map → load-agent-defs-YMDWBFDP.js.map} +0 -0
  199. /package/dist/{components/wizard/checkbox-grid.js.map → recompile-project-agents-SZ76WNTW.js.map} +0 -0
  200. /package/dist/{components/wizard/domain-selection.js.map → source-loader-C5SQXZXI.js.map} +0 -0
@@ -1,1170 +0,0 @@
1
- #!/usr/bin/env node
2
- import {
3
- deriveInstallMode,
4
- disableBuffering,
5
- drainBuffer,
6
- enableBuffering,
7
- getAvailableSkills,
8
- getCellState,
9
- getUnmetRequiredBy,
10
- isLocalOnlySkill,
11
- warn
12
- } from "./chunk-C2UISKIM.js";
13
- import {
14
- getCategoryDomain,
15
- getSkillById,
16
- matrix,
17
- typedEntries,
18
- typedFromEntries,
19
- typedKeys,
20
- typedValues
21
- } from "./chunk-NU2K5G54.js";
22
- import {
23
- CLI_INVOKE_COMMAND,
24
- DEFAULT_PUBLIC_SOURCE_NAME,
25
- DEFAULT_SCRATCH_DOMAINS,
26
- EJECT_SOURCE,
27
- FALLBACK_DOMAIN,
28
- INSTALL_MODES,
29
- SKILL_CATEGORIES_PATH,
30
- isActiveAt,
31
- isGlobalTombstone,
32
- isProjectOwned,
33
- orderDomains
34
- } from "./chunk-AG3ZVM3B.js";
35
-
36
- // src/cli/stores/wizard-store.ts
37
- import { create } from "zustand";
38
-
39
- // src/cli/lib/wizard/build-step-logic.ts
40
- import { sortBy } from "remeda";
41
-
42
- // src/cli/lib/wizard/scope-diff.ts
43
- function computeScopeDiff(input) {
44
- const { currentSkills, currentAgents, installedSkillConfigs, installedAgentConfigs, isInitMode } = input;
45
- const projectSkills = currentSkills.filter((s) => s.scope === "project" && !s.excluded);
46
- const globalSkills = currentSkills.filter((s) => s.scope === "global" && !s.excluded);
47
- const projectAgents = currentAgents.filter((a) => a.scope === "project" && !a.excluded);
48
- const globalAgents = currentAgents.filter((a) => a.scope === "global" && !a.excluded);
49
- const excludedGlobalSkills = currentSkills.filter((s) => s.scope === "global" && !!s.excluded);
50
- const excludedGlobalAgents = currentAgents.filter((a) => a.scope === "global" && !!a.excluded);
51
- const prevSkillKeySet = installedSkillConfigs ? new Set(installedSkillConfigs.map((s) => skillSlotKey(s.id, s.scope))) : null;
52
- const prevSourceMap = installedSkillConfigs ? new Map(
53
- installedSkillConfigs.filter((s) => !s.excluded).map((s) => [skillSlotKey(s.id, s.scope), s.origin])
54
- ) : null;
55
- const prevAgentKeySet = installedAgentConfigs ? new Set(installedAgentConfigs.map((a) => agentSlotKey(a.name, a.scope))) : null;
56
- const activeSkillBaseline = installedSkillConfigs ? installedSkillConfigs.filter((s) => !s.excluded) : [];
57
- const activeAgentBaseline = installedAgentConfigs ? installedAgentConfigs.filter((a) => !a.excluded) : [];
58
- const inheritedGlobalSkills = activeSkillBaseline.filter(
59
- (s) => s.scope === "global" && !globalSkills.some((g) => g.id === s.id) && !excludedGlobalSkills.some((e) => e.id === s.id) && projectSkills.some((p) => p.id === s.id)
60
- );
61
- const inheritedGlobalAgents = activeAgentBaseline.filter(
62
- (a) => a.scope === "global" && !globalAgents.some((g) => g.name === a.name) && !excludedGlobalAgents.some((e) => e.name === a.name) && projectAgents.some((p) => p.name === a.name)
63
- );
64
- const removedSkills = activeSkillBaseline.filter(
65
- (s) => !currentSkills.some((c) => c.id === s.id && c.scope === s.scope)
66
- );
67
- const removedAgents = activeAgentBaseline.filter(
68
- (a) => !currentAgents.some((c) => c.name === a.name && c.scope === a.scope)
69
- );
70
- const inheritedSkillIdSet = new Set(inheritedGlobalSkills.map((s) => s.id));
71
- const uniqueExcludedGlobalSkills = excludedGlobalSkills.filter(
72
- (s) => !inheritedSkillIdSet.has(s.id)
73
- );
74
- const allGlobalSkills = [
75
- ...globalSkills,
76
- ...inheritedGlobalSkills,
77
- ...uniqueExcludedGlobalSkills
78
- ];
79
- const inheritedAgentNameSet = new Set(inheritedGlobalAgents.map((a) => a.name));
80
- const uniqueExcludedGlobalAgents = excludedGlobalAgents.filter(
81
- (a) => !inheritedAgentNameSet.has(a.name)
82
- );
83
- const allGlobalAgents = [
84
- ...globalAgents,
85
- ...inheritedGlobalAgents,
86
- ...uniqueExcludedGlobalAgents
87
- ];
88
- const removedGlobalSkills = isInitMode ? [] : removedSkills.filter((s) => s.scope === "global" && !inheritedSkillIdSet.has(s.id));
89
- const removedProjectSkills = removedSkills.filter((s) => s.scope === "project");
90
- const removedGlobalAgents = isInitMode ? [] : removedAgents.filter((a) => a.scope === "global" && !inheritedAgentNameSet.has(a.name));
91
- const removedProjectAgents = removedAgents.filter((a) => a.scope === "project");
92
- const projectSkillRows = [
93
- ...projectSkills.map((s) => classifyDiffRow(s, prevSkillKeySet, prevSourceMap)),
94
- ...removedProjectSkills.map(toRemovedSkillRow)
95
- ];
96
- const globalSkillRows = [
97
- ...allGlobalSkills.map((s) => classifyDiffRow(s, prevSkillKeySet, prevSourceMap)),
98
- ...removedGlobalSkills.map(toRemovedSkillRow)
99
- ];
100
- const projectAgentRows = [
101
- ...projectAgents.map((a) => classifyAgentDiffRow(a, prevAgentKeySet)),
102
- ...removedProjectAgents.map(toRemovedAgentRow)
103
- ];
104
- const globalAgentRows = [
105
- ...allGlobalAgents.map((a) => classifyAgentDiffRow(a, prevAgentKeySet)),
106
- ...removedGlobalAgents.map(toRemovedAgentRow)
107
- ];
108
- const hasContent = projectSkillRows.length > 0 || globalSkillRows.length > 0 || projectAgentRows.length > 0 || globalAgentRows.length > 0;
109
- return { projectSkillRows, globalSkillRows, projectAgentRows, globalAgentRows, hasContent };
110
- }
111
- function skillSlotKey(id, scope) {
112
- return `${id}:${scope}`;
113
- }
114
- function agentSlotKey(name, scope) {
115
- return `${name}:${scope}`;
116
- }
117
- function formatScopeTag(scope) {
118
- return scope === "global" ? "[G]" : "[P]";
119
- }
120
- function deriveScopeBadges(activeConfig, excludedConfig) {
121
- const secondaryScope = excludedConfig && activeConfig && excludedConfig.scope !== activeConfig.scope ? excludedConfig.scope : void 0;
122
- return { scope: activeConfig?.scope, secondaryScope };
123
- }
124
- function classifyDiffRow(skill, prevKeySet, prevSourceMap) {
125
- const key = skillSlotKey(skill.id, skill.scope);
126
- const isNew = prevKeySet === null || !prevKeySet.has(key);
127
- const prevSource = prevSourceMap?.get(key);
128
- const modeChanged = !isNew && prevSource != null && prevSource !== skill.origin;
129
- if (modeChanged) {
130
- return { id: skill.id, source: skill.origin, status: "mode-changed" };
131
- }
132
- return { id: skill.id, source: skill.origin, status: isNew ? "added" : "unchanged" };
133
- }
134
- function classifyAgentDiffRow(agent, prevKeySet) {
135
- const isNew = prevKeySet === null || !prevKeySet.has(agentSlotKey(agent.name, agent.scope));
136
- return { name: agent.name, status: isNew ? "added" : "unchanged" };
137
- }
138
- function toRemovedSkillRow(skill) {
139
- return { id: skill.id, source: skill.origin, status: "removed" };
140
- }
141
- function toRemovedAgentRow(agent) {
142
- return { name: agent.name, status: "removed" };
143
- }
144
-
145
- // src/cli/lib/wizard/build-step-logic.ts
146
- function buildCategoriesForDomain(domain, allSelections, installedSkillIds, skillConfigs) {
147
- const categories = sortBy(
148
- typedValues(matrix.categories).filter((cat) => cat.domain === domain),
149
- (cat) => cat.order
150
- );
151
- const categoryRows = categories.map((cat) => {
152
- const skillOptions = getAvailableSkills(cat.id, allSelections);
153
- const sortedOptions = sortBy(
154
- skillOptions,
155
- (skill) => getSkillById(skill.id).displayName.toLowerCase()
156
- );
157
- const options = sortedOptions.map((skill) => {
158
- const activeConfig = skillConfigs?.find((sc) => sc.id === skill.id && !sc.excluded);
159
- const excludedConfig = skillConfigs?.find((sc) => sc.id === skill.id && sc.excluded);
160
- const { secondaryScope } = deriveScopeBadges(activeConfig, excludedConfig);
161
- const local = getSkillById(skill.id).local;
162
- const requiredBy = skill.selected ? void 0 : getUnmetRequiredBy(skill.id, allSelections);
163
- return {
164
- id: skill.id,
165
- // The cell verdict, not the raw advisory: inside a pick-one category
166
- // the shared semantics forgive what the swap resolves.
167
- state: getCellState(skill.id, allSelections),
168
- selected: skill.selected,
169
- ...local !== void 0 && { local },
170
- installed: installedSkillIds?.includes(skill.id) || false,
171
- ...activeConfig?.scope !== void 0 && { scope: activeConfig.scope },
172
- ...secondaryScope !== void 0 && { secondaryScope },
173
- ...activeConfig?.origin !== void 0 && { source: activeConfig.origin },
174
- hasUnmetRequirements: skill.hasUnmetRequirements,
175
- ...skill.unmetRequirementsReason !== void 0 && {
176
- unmetRequirementsReason: skill.unmetRequirementsReason
177
- },
178
- ...requiredBy !== void 0 && { requiredBy }
179
- };
180
- });
181
- return {
182
- id: cat.id,
183
- displayName: cat.displayName,
184
- exclusive: cat.exclusive,
185
- options
186
- };
187
- });
188
- return categoryRows.filter((row) => row.options.length > 0);
189
- }
190
-
191
- // src/cli/lib/wizard/agent-roster.ts
192
- var BUILT_IN_AGENT_GROUPS = [
193
- {
194
- label: "Web",
195
- items: [
196
- {
197
- id: "web-developer",
198
- label: "Web Developer",
199
- description: "Frontend features, components, TypeScript"
200
- },
201
- { id: "web-researcher", label: "Web Researcher", description: "Frontend pattern discovery" },
202
- {
203
- id: "web-tester",
204
- label: "Web Tester",
205
- description: "Frontend tests, E2E, component tests"
206
- }
207
- ]
208
- },
209
- {
210
- label: "API",
211
- items: [
212
- {
213
- id: "api-developer",
214
- label: "API Developer",
215
- description: "Backend routes, database, middleware"
216
- },
217
- { id: "api-researcher", label: "API Researcher", description: "Backend pattern discovery" },
218
- {
219
- id: "api-tester",
220
- label: "API Tester",
221
- description: "Endpoint, database, and auth flow tests"
222
- }
223
- ]
224
- },
225
- {
226
- label: "AI",
227
- items: [
228
- {
229
- id: "ai-developer",
230
- label: "AI Developer",
231
- description: "RAG pipelines, agent loops, tool calling"
232
- },
233
- {
234
- id: "ai-researcher",
235
- label: "AI Researcher",
236
- description: "Prompt, model, and RAG pipeline discovery"
237
- },
238
- {
239
- id: "ai-tester",
240
- label: "AI Tester",
241
- description: "LLM mocking, prompt regression, eval harnesses"
242
- }
243
- ]
244
- },
245
- {
246
- label: "CLI",
247
- items: [
248
- {
249
- id: "cli-developer",
250
- label: "CLI Developer",
251
- description: "CLI commands, interactive prompts"
252
- },
253
- { id: "cli-tester", label: "CLI Tester", description: "CLI application tests" },
254
- {
255
- id: "cli-researcher",
256
- label: "CLI Researcher",
257
- description: "CLI command and config pattern discovery"
258
- }
259
- ]
260
- },
261
- {
262
- label: "Meta",
263
- items: [
264
- {
265
- id: "pm",
266
- label: "PM",
267
- description: "Cross-domain implementation specs; domain frameworks via skills"
268
- },
269
- {
270
- id: "reviewer",
271
- label: "Reviewer",
272
- description: "Cross-domain code review; domain knowledge via skills"
273
- },
274
- { id: "agent-summoner", label: "Agent Summoner", description: "Create and improve agents" },
275
- {
276
- id: "skill-summoner",
277
- label: "Skill Summoner",
278
- description: "Create technology-specific skills"
279
- },
280
- { id: "codex-keeper", label: "Codex Keeper", description: "AI-focused documentation" }
281
- ]
282
- }
283
- ];
284
- var BUILT_IN_AGENT_IDS = new Set(
285
- BUILT_IN_AGENT_GROUPS.flatMap((group) => group.items.map((agent) => agent.id))
286
- );
287
- function firstFocusableAgent() {
288
- const first = BUILT_IN_AGENT_GROUPS[0]?.items[0];
289
- if (first === void 0) throw new Error("The built-in agent roster is empty");
290
- return first.id;
291
- }
292
-
293
- // src/cli/stores/wizard-store.ts
294
- var LOCAL_ONLY_INSTALL_MODES = ["eject"];
295
- var TOAST_MESSAGES = {
296
- GLOBAL_SKILLS_LOCKED: "Global skills cannot be changed from project scope",
297
- ALREADY_EJECTED_AT_GLOBAL: "Already exists as ejected skill at global scope",
298
- GLOBAL_AGENTS_LOCKED: "Global agents cannot be changed from project scope"
299
- };
300
- function skillsLeftOutToast(count) {
301
- return count === 1 ? "1 skill was left out \u2014 this source cannot place it" : `${count} skills were left out \u2014 this source cannot place them`;
302
- }
303
- function resolveEffectiveSource(...candidates) {
304
- return candidates.find((source) => source !== void 0) ?? DEFAULT_PUBLIC_SOURCE_NAME;
305
- }
306
- function primarySourceName(skill) {
307
- return skill?.availableSources?.find((s) => s.primary)?.name;
308
- }
309
- function marketplaceSourceName(skill) {
310
- return skill?.availableSources?.find((source) => source.type !== "local")?.name;
311
- }
312
- function defaultOriginFor(skill) {
313
- if (isLocalOnlySkill(skill)) return EJECT_SOURCE;
314
- return primarySourceName(skill) ?? DEFAULT_PUBLIC_SOURCE_NAME;
315
- }
316
- function createDefaultSkillConfig(id) {
317
- return { id, scope: "global", origin: defaultOriginFor(matrix.skills[id]) };
318
- }
319
- function hasProjectActive(configs, id) {
320
- return configs.some((sc) => sc.id === id && isActiveAt(sc, "project"));
321
- }
322
- function findGlobalActive(configs, id) {
323
- return configs.find((sc) => sc.id === id && isActiveAt(sc, "global"));
324
- }
325
- function hasGlobalActive(configs, id) {
326
- return findGlobalActive(configs, id) !== void 0;
327
- }
328
- function hasGlobalTombstone(configs, id) {
329
- return configs.some((sc) => sc.id === id && isGlobalTombstone(sc));
330
- }
331
- function isDualScopePair(configs, id) {
332
- return hasProjectActive(configs, id) && hasGlobalTombstone(configs, id);
333
- }
334
- function isGloballyLockedSkill(installed, liveConfigs, id) {
335
- return hasGlobalActive(installed, id) || hasGlobalTombstone(installed, id) && hasGlobalActive(liveConfigs, id);
336
- }
337
- function blocksExclusiveSwap(installed, liveConfigs, id) {
338
- return isGloballyLockedSkill(installed, liveConfigs, id) || isDualScopePair(liveConfigs, id);
339
- }
340
- function wouldOverwriteGlobalEject(config, liveConfigs, installedSkillConfigs) {
341
- if (config.scope !== "project" || config.origin !== EJECT_SOURCE) return false;
342
- const globalEjectInstalled = installedSkillConfigs?.some(
343
- (sc) => sc.id === config.id && sc.scope === "global" && sc.origin === EJECT_SOURCE && !sc.excluded
344
- );
345
- if (!globalEjectInstalled) return false;
346
- return !liveConfigs.some((sc) => sc.id === config.id && sc.excluded);
347
- }
348
- function isInheritedGlobalSlot(installed, id, scope) {
349
- if (installed === null) return false;
350
- return scope === "global" && (hasGlobalActive(installed, id) || hasGlobalTombstone(installed, id));
351
- }
352
- function withActiveEntryOrigin(configs, id, scope, origin) {
353
- return configs.map(
354
- (sc) => sc.id === id && !sc.excluded && sc.scope === scope ? { ...sc, origin } : sc
355
- );
356
- }
357
- function applySkillRemoval(configs, removedIds, installedSkillConfigs) {
358
- const removed = removedIds instanceof Set ? removedIds : new Set(removedIds);
359
- const installedIds = new Set((installedSkillConfigs ?? []).map((s) => s.id));
360
- const survivesRemoval = (entry) => !isDualScopePair(configs, entry.id) && !isProjectOwned(entry) && installedIds.has(entry.id);
361
- const retained = configs.filter((sc) => !removed.has(sc.id) || survivesRemoval(sc));
362
- const resurfacedInheritedGlobals = [...removed].filter((id) => isDualScopePair(configs, id)).map((id) => ({
363
- id,
364
- scope: "global",
365
- origin: configs.find((sc) => sc.id === id && sc.scope === "global")?.origin ?? DEFAULT_PUBLIC_SOURCE_NAME
366
- }));
367
- return [...retained, ...resurfacedInheritedGlobals];
368
- }
369
- function flattenCategorySelections(selections) {
370
- return typedValues(selections).flat();
371
- }
372
- function collectSkillIdsFromSelections(selections) {
373
- return new Set(flattenCategorySelections(selections));
374
- }
375
- function reconcileSkillConfigs(configs, added, removed, installedSkillConfigs, isEditingFromGlobalScope) {
376
- const effectiveInstalled = isEditingFromGlobalScope ? null : installedSkillConfigs;
377
- let result = applySkillRemoval(configs, removed, effectiveInstalled);
378
- for (const id of added) {
379
- if (!isEditingFromGlobalScope && hasGlobalTombstone(installedSkillConfigs ?? [], id) && !hasProjectActive(result, id)) {
380
- const globalEntry = (installedSkillConfigs ?? []).find((sc) => sc.id === id && sc.scope === "global") ?? result.find((sc) => sc.id === id && sc.scope === "global");
381
- const origin = globalEntry?.origin ?? DEFAULT_PUBLIC_SOURCE_NAME;
382
- result = [
383
- ...result.filter((sc) => sc.id !== id),
384
- { id, scope: "project", origin },
385
- { id, scope: "global", excluded: true, origin }
386
- ];
387
- continue;
388
- }
389
- const existingExcluded = result.find((sc) => sc.id === id && sc.excluded);
390
- if (existingExcluded) {
391
- result = result.map((sc) => {
392
- if (sc.id !== id || !sc.excluded) return sc;
393
- const { excluded: _excluded, ...active } = sc;
394
- return active;
395
- });
396
- } else if (!result.some((sc) => sc.id === id)) {
397
- result = [...result, buildSkillConfigForId(id, installedSkillConfigs)];
398
- }
399
- }
400
- return result;
401
- }
402
- function agentHasProjectActive(configs, name) {
403
- return configs.some((ac) => ac.name === name && isActiveAt(ac, "project"));
404
- }
405
- function agentHasGlobalActive(configs, name) {
406
- return configs.some((ac) => ac.name === name && isActiveAt(ac, "global"));
407
- }
408
- function agentHasGlobalTombstone(configs, name) {
409
- return configs.some((ac) => ac.name === name && isGlobalTombstone(ac));
410
- }
411
- function isDualScopeAgentPair(configs, name) {
412
- return agentHasProjectActive(configs, name) && agentHasGlobalTombstone(configs, name);
413
- }
414
- function collectTombstones(configs) {
415
- return configs.filter((entry) => entry.excluded);
416
- }
417
- function filledAgentSlots(configs) {
418
- return new Set(configs.map((ac) => agentSlotKey(ac.name, ac.scope)));
419
- }
420
- function agentTombstonesOutsideRebuild(saved, rebuilt) {
421
- const filled = filledAgentSlots(rebuilt);
422
- return collectTombstones(saved).filter((ac) => !filled.has(agentSlotKey(ac.name, ac.scope)));
423
- }
424
- function skillTombstonesOutsideRebuild(saved, rebuilt) {
425
- const filled = new Set(rebuilt.map((sc) => skillSlotKey(sc.id, sc.scope)));
426
- return collectTombstones(saved).filter((sc) => !filled.has(skillSlotKey(sc.id, sc.scope)));
427
- }
428
- function applyAgentToggle(configs, agent, isSelected) {
429
- if (isSelected) {
430
- return configs.filter((ac) => ac.name !== agent);
431
- }
432
- const existingExcluded = configs.find((ac) => ac.name === agent && ac.excluded);
433
- if (existingExcluded) {
434
- return configs.map((ac) => {
435
- if (ac.name !== agent || !ac.excluded) return ac;
436
- const { excluded: _excluded, ...active } = ac;
437
- return active;
438
- });
439
- }
440
- return [...configs, { name: agent, scope: "global" }];
441
- }
442
- function survivesRosterRebuild(agentConfig, roster, rebuiltSlots) {
443
- if (agentConfig.excluded) {
444
- return !rebuiltSlots.has(agentSlotKey(agentConfig.name, agentConfig.scope));
445
- }
446
- return !isProjectOwned(agentConfig) && !roster.has(agentConfig.name);
447
- }
448
- function tuningOf(agentConfig) {
449
- return {
450
- ...agentConfig?.model !== void 0 && { model: agentConfig.model },
451
- ...agentConfig?.codexModel !== void 0 && { codexModel: agentConfig.codexModel },
452
- ...agentConfig?.effort !== void 0 && { effort: agentConfig.effort }
453
- };
454
- }
455
- function tunedEntryFor(agentConfigs, agent) {
456
- return agentConfigs?.find((ac) => ac.name === agent && !ac.excluded && ac.scope === "project") ?? agentConfigs?.find((ac) => ac.name === agent && !ac.excluded);
457
- }
458
- function restoreDualScopeAgent(selectedAgents, agentConfigs, agent) {
459
- const tuning = tuningOf(tunedEntryFor(agentConfigs, agent));
460
- return {
461
- selectedAgents: [...selectedAgents, agent],
462
- agentConfigs: [
463
- ...agentConfigs.filter((ac) => ac.name !== agent),
464
- { name: agent, scope: "project", ...tuning },
465
- { name: agent, scope: "global", ...tuning, excluded: true }
466
- ]
467
- };
468
- }
469
- function nextSelectedAgents(selectedAgents, agent, flags) {
470
- if (flags.isSelected) return selectedAgents.filter((a) => a !== agent);
471
- if (flags.isInList) return selectedAgents;
472
- return [...selectedAgents, agent];
473
- }
474
- function buildSkillConfigForId(id, savedConfigs) {
475
- const saved = savedConfigs?.find((sc) => sc.id === id && !sc.excluded && sc.scope === "project") ?? savedConfigs?.find((sc) => sc.id === id && !sc.excluded);
476
- return {
477
- id,
478
- scope: saved?.scope ?? "global",
479
- origin: saved?.origin ?? defaultOriginFor(matrix.skills[id])
480
- };
481
- }
482
- function buildAgentConfigForName(name, savedConfigs) {
483
- const saved = tunedEntryFor(savedConfigs, name);
484
- return {
485
- name,
486
- scope: saved?.scope ?? "global",
487
- ...tuningOf(saved)
488
- };
489
- }
490
- function restoreSkillConfigs(existingConfigs, restoredIds) {
491
- const restoredSet = new Set(restoredIds);
492
- const existingIds = new Set(existingConfigs.map((sc) => sc.id));
493
- const updated = existingConfigs.map((sc) => {
494
- if (!restoredSet.has(sc.id) || !sc.excluded) return sc;
495
- const { excluded: _excluded, ...active } = sc;
496
- return active;
497
- });
498
- const newConfigs = restoredIds.filter((id) => !existingIds.has(id)).map(createDefaultSkillConfig);
499
- return [...updated, ...newConfigs];
500
- }
501
- var DOMAIN_AGENTS = {
502
- web: ["web-developer", "web-researcher", "web-tester", "pm", "reviewer"],
503
- api: ["api-developer", "api-researcher", "api-tester", "pm", "reviewer"],
504
- cli: ["cli-developer", "cli-tester", "cli-researcher", "pm", "reviewer"],
505
- ai: ["ai-developer", "ai-researcher", "ai-tester", "pm", "reviewer"]
506
- };
507
- function absentFromSourceWarning(skillId) {
508
- return `Installed skill '${skillId}' is not present in the loaded source \u2014 it may have been removed or renamed. It is left out of this session's selection. Run '${CLI_INVOKE_COMMAND} update' to refresh the marketplace if you expect it to still be carried there.`;
509
- }
510
- function unplaceableCategoryWarning(skillId, category) {
511
- return `Installed skill '${skillId}' has unknown category '${category}' \u2014 skipping. No domain in this source claims that category, so the wizard has no screen to place the skill on. Declare it with a 'domain' in the source's '${SKILL_CATEGORIES_PATH}', or run '${CLI_INVOKE_COMMAND} update' to refresh the marketplace.`;
512
- }
513
- function resolveSkillForPopulation(skillId) {
514
- const { skills } = matrix;
515
- const skill = skills[skillId];
516
- if (!skill?.category) {
517
- warn(absentFromSourceWarning(skillId));
518
- return null;
519
- }
520
- const domain = getCategoryDomain(skill.category);
521
- if (!domain) {
522
- warn(unplaceableCategoryWarning(skillId, skill.category));
523
- return null;
524
- }
525
- const subcat = skill.category;
526
- return { domain, subcat, techId: skillId };
527
- }
528
- function addToDomainSelections(selections, domain, category, skillId) {
529
- const categorySelections = selections[domain] ??= {};
530
- const skillList = categorySelections[category] ??= [];
531
- if (skillList.includes(skillId)) return false;
532
- skillList.push(skillId);
533
- return true;
534
- }
535
- function sourceForInstallMode(skill, mode) {
536
- if (mode === "eject") return EJECT_SOURCE;
537
- return marketplaceSourceName(skill) ?? DEFAULT_PUBLIC_SOURCE_NAME;
538
- }
539
- function installModeOfSource(origin) {
540
- return origin === EJECT_SOURCE ? "eject" : "plugin";
541
- }
542
- function buildInstallModeOptions(skill, selectedMode) {
543
- const modes = isLocalOnlySkill(skill) ? LOCAL_ONLY_INSTALL_MODES : INSTALL_MODES;
544
- return modes.map((mode) => ({ mode, selected: mode === selectedMode }));
545
- }
546
- function collectRemovedInstalledEntries(installedSkillConfigs, skillConfigs) {
547
- if (!installedSkillConfigs) return [];
548
- const occupiedSlots = new Set(skillConfigs.map((sc) => skillSlotKey(sc.id, sc.scope)));
549
- return installedSkillConfigs.filter(
550
- (sc) => !sc.excluded && !occupiedSlots.has(skillSlotKey(sc.id, sc.scope)) && // Hydration already moved it to unresolvableSkillIds, and getSkillById would throw on it.
551
- !!matrix.skills[sc.id]
552
- );
553
- }
554
- function collectInstalledSkillSlots(installedSkillConfigs) {
555
- if (!installedSkillConfigs) return /* @__PURE__ */ new Set();
556
- return new Set(installedSkillConfigs.map((sc) => skillSlotKey(sc.id, sc.scope)));
557
- }
558
- function addedSlotFlag(installedSkillSlots, id, scope) {
559
- return installedSkillSlots.has(skillSlotKey(id, scope)) ? {} : { added: true };
560
- }
561
- function withSelectedMode(options, source) {
562
- const mode = installModeOfSource(source);
563
- return options.map((option) => ({ ...option, selected: option.mode === mode }));
564
- }
565
- function resolveSkillRowInputs(id, skillConfigs) {
566
- const skill = getSkillById(id);
567
- const configEntry = skillConfigs.find((sc) => sc.id === skill.id);
568
- const selectedSource = resolveEffectiveSource(
569
- configEntry?.origin,
570
- skill.activeSource?.name,
571
- primarySourceName(skill)
572
- );
573
- return {
574
- skillId: skill.id,
575
- configEntry,
576
- options: buildInstallModeOptions(skill, installModeOfSource(selectedSource))
577
- };
578
- }
579
- function toPendingRemovalRow(skillId, options, removedInstalledEntry) {
580
- return {
581
- skillId,
582
- options: withSelectedMode(options, removedInstalledEntry.origin),
583
- scope: removedInstalledEntry.scope,
584
- disabled: true
585
- };
586
- }
587
- function isSlotAlreadyRendered(rows, removedInstalledEntry) {
588
- const slot = skillSlotKey(removedInstalledEntry.id, removedInstalledEntry.scope);
589
- return rows.some((row) => skillSlotKey(row.skillId, row.scope) === slot);
590
- }
591
- function toLockedGlobalRow(skillId, options, installedSource, installedSkillSlots) {
592
- return {
593
- skillId,
594
- options: withSelectedMode(options, installedSource),
595
- scope: "global",
596
- readOnly: true,
597
- ...addedSlotFlag(installedSkillSlots, skillId, "global")
598
- };
599
- }
600
- function classifySkillSourceRows(skillId, options, context) {
601
- const { configEntry, installedSkillConfigs, isEditingFromGlobalScope, installedSkillSlots } = context;
602
- const installedGlobalConfig = findGlobalActive(installedSkillConfigs ?? [], skillId);
603
- const isExcludedGlobal = configEntry?.excluded && configEntry.scope === "global";
604
- if (isExcludedGlobal && !isEditingFromGlobalScope) {
605
- return [
606
- toLockedGlobalRow(
607
- skillId,
608
- options,
609
- installedGlobalConfig?.origin ?? configEntry.origin,
610
- installedSkillSlots
611
- )
612
- ];
613
- }
614
- if (!isEditingFromGlobalScope && installedGlobalConfig && configEntry?.scope === "project") {
615
- return [
616
- toLockedGlobalRow(skillId, options, installedGlobalConfig.origin, installedSkillSlots),
617
- {
618
- skillId,
619
- options,
620
- scope: "project",
621
- ...addedSlotFlag(installedSkillSlots, skillId, "project")
622
- }
623
- ];
624
- }
625
- const readOnly = !isEditingFromGlobalScope && (!!installedGlobalConfig || isInheritedGlobalSlot(installedSkillConfigs, skillId, configEntry?.scope));
626
- return [
627
- {
628
- skillId,
629
- options,
630
- ...configEntry?.scope !== void 0 && { scope: configEntry.scope },
631
- ...readOnly ? { readOnly: true } : {},
632
- ...addedSlotFlag(installedSkillSlots, skillId, configEntry?.scope)
633
- }
634
- ];
635
- }
636
- function sourceRowSortTier(row) {
637
- if (row.scope === "global" && row.readOnly) return 0;
638
- if (row.scope === "global") return 1;
639
- return 2;
640
- }
641
- var WIZARD_STEP_ORDER = [
642
- "stack",
643
- "domains",
644
- "build",
645
- "sources",
646
- "agents",
647
- "confirm"
648
- ];
649
- function offersStacks() {
650
- return matrix.suggestedStacks.length > 0;
651
- }
652
- function getActiveStepFlow() {
653
- if (offersStacks()) return [...WIZARD_STEP_ORDER];
654
- return WIZARD_STEP_ORDER.filter((step) => step !== "stack");
655
- }
656
- function stepsBefore(flow, step) {
657
- const index = flow.indexOf(step);
658
- return index < 0 ? [] : flow.slice(0, index);
659
- }
660
- var createInitialState = (overrides) => ({
661
- step: "stack",
662
- approach: null,
663
- selectedStackId: null,
664
- stackAction: null,
665
- selectedDomains: [],
666
- currentDomainIndex: 0,
667
- domainSelections: {},
668
- _stackDomainSelections: null,
669
- showLabels: false,
670
- skillConfigs: [],
671
- focusedSkillId: null,
672
- unresolvableSkillIds: [],
673
- foldedSkillIds: [],
674
- setupMarketplace: null,
675
- showInfo: false,
676
- selectedAgents: [],
677
- agentConfigs: [],
678
- focusedAgentId: null,
679
- installedSkillConfigs: null,
680
- installedAgentConfigs: null,
681
- isInitMode: false,
682
- isEditingFromGlobalScope: false,
683
- toastMessage: null,
684
- globalPreselections: null,
685
- globalAgentPreselections: null,
686
- history: [],
687
- ...overrides
688
- });
689
- function seedFocusForStep(step, actions) {
690
- if (step === "build") actions.seedFocusedSkillForActiveDomain();
691
- if (step === "agents") actions.seedFocusedAgent();
692
- }
693
- var useWizardStore = create((set, get) => ({
694
- ...createInitialState(),
695
- setStep: (step) => {
696
- set((state) => ({
697
- step,
698
- history: [...state.history, state.step]
699
- }));
700
- seedFocusForStep(step, get());
701
- },
702
- setApproach: (approach) => set({ approach }),
703
- selectStack: (stackId) => set({
704
- selectedStackId: stackId,
705
- domainSelections: {},
706
- _stackDomainSelections: null,
707
- selectedDomains: [],
708
- skillConfigs: [],
709
- selectedAgents: [],
710
- agentConfigs: [],
711
- currentDomainIndex: 0,
712
- stackAction: null
713
- }),
714
- setStackAction: (action) => set({ stackAction: action }),
715
- startFromScratch: () => {
716
- get().selectStack(null);
717
- get().setApproach("scratch");
718
- const { globalAgentPreselections, globalPreselections } = get();
719
- if (globalAgentPreselections) {
720
- set({
721
- selectedAgents: globalAgentPreselections.agents,
722
- agentConfigs: globalAgentPreselections.configs
723
- });
724
- }
725
- if (globalPreselections?.length) {
726
- get().populateFromSkillIds(
727
- globalPreselections.map((skill) => skill.id),
728
- globalPreselections
729
- );
730
- }
731
- for (const domain of DEFAULT_SCRATCH_DOMAINS) {
732
- if (!get().selectedDomains.includes(domain)) get().toggleDomain(domain);
733
- }
734
- },
735
- populateFromSkillIds: (skillIds, savedConfigs) => set(() => {
736
- const domainSelections = {};
737
- const resolvedSkillIds = [];
738
- const unresolvableSkillIds = [];
739
- for (const skillId of skillIds) {
740
- const resolved = resolveSkillForPopulation(skillId);
741
- if (!resolved) {
742
- unresolvableSkillIds.push(skillId);
743
- continue;
744
- }
745
- const { domain, subcat, techId } = resolved;
746
- if (addToDomainSelections(domainSelections, domain, subcat, techId)) {
747
- resolvedSkillIds.push(techId);
748
- }
749
- }
750
- const selectedDomains = orderDomains(typedKeys(domainSelections));
751
- const skillConfigs = resolvedSkillIds.map(
752
- (id) => buildSkillConfigForId(id, savedConfigs)
753
- );
754
- const excludedConfigs = skillTombstonesOutsideRebuild(savedConfigs ?? [], skillConfigs);
755
- return {
756
- domainSelections,
757
- _stackDomainSelections: structuredClone(domainSelections),
758
- selectedDomains,
759
- skillConfigs: [...skillConfigs, ...excludedConfigs],
760
- unresolvableSkillIds
761
- };
762
- }),
763
- toggleDomain: (domain) => set((state) => {
764
- const isSelected = state.selectedDomains.includes(domain);
765
- if (isSelected) {
766
- const { [domain]: _removed, ...remainingSelections } = state.domainSelections;
767
- const removedSkillIds = _removed ? collectSkillIdsFromSelections(_removed) : /* @__PURE__ */ new Set();
768
- return {
769
- selectedDomains: state.selectedDomains.filter((d) => d !== domain),
770
- domainSelections: remainingSelections,
771
- // Global-scope edit: deselecting a domain uninstalls its skills instead of tombstoning.
772
- skillConfigs: applySkillRemoval(
773
- state.skillConfigs,
774
- removedSkillIds,
775
- state.isEditingFromGlobalScope ? null : state.installedSkillConfigs
776
- )
777
- };
778
- }
779
- const stackSelections = state._stackDomainSelections?.[domain];
780
- if (stackSelections) {
781
- const restoredSkillIds = [...collectSkillIdsFromSelections(stackSelections)];
782
- return {
783
- selectedDomains: orderDomains([...state.selectedDomains, domain]),
784
- domainSelections: {
785
- ...state.domainSelections,
786
- [domain]: structuredClone(stackSelections)
787
- },
788
- skillConfigs: restoreSkillConfigs(state.skillConfigs, restoredSkillIds)
789
- };
790
- }
791
- return {
792
- selectedDomains: orderDomains([...state.selectedDomains, domain])
793
- };
794
- }),
795
- toggleTechnology: (domain, category, technology, exclusive) => set((state) => {
796
- const installed = state.installedSkillConfigs ?? [];
797
- const currentSelections = state.domainSelections[domain]?.[category] || [];
798
- const isSelected = currentSelections.includes(technology);
799
- const isGlobalLocked = isSelected ? isGloballyLockedSkill(installed, state.skillConfigs, technology) : hasGlobalActive(installed, technology);
800
- if (isGlobalLocked && !state.isEditingFromGlobalScope) {
801
- return { toastMessage: TOAST_MESSAGES.GLOBAL_SKILLS_LOCKED };
802
- }
803
- if (exclusive && !isSelected) {
804
- const wouldDropLockedSkill = currentSelections.some(
805
- (selectedId) => blocksExclusiveSwap(installed, state.skillConfigs, selectedId)
806
- );
807
- if (wouldDropLockedSkill && !state.isEditingFromGlobalScope) {
808
- return { toastMessage: TOAST_MESSAGES.GLOBAL_SKILLS_LOCKED };
809
- }
810
- }
811
- let newSelections;
812
- if (exclusive) {
813
- newSelections = isSelected ? [] : [technology];
814
- } else {
815
- newSelections = isSelected ? currentSelections.filter((t) => t !== technology) : [...currentSelections, technology];
816
- }
817
- const removed = currentSelections.filter((id) => !newSelections.includes(id));
818
- const added = newSelections.filter((id) => !currentSelections.includes(id));
819
- const skillConfigs = reconcileSkillConfigs(
820
- state.skillConfigs,
821
- added,
822
- removed,
823
- state.installedSkillConfigs,
824
- state.isEditingFromGlobalScope
825
- );
826
- const stillActiveAfterRemoval = isSelected && !newSelections.includes(technology) && (hasProjectActive(skillConfigs, technology) || hasGlobalActive(skillConfigs, technology));
827
- const resolvedSelections = stillActiveAfterRemoval ? [...newSelections, technology] : newSelections;
828
- return {
829
- skillConfigs,
830
- domainSelections: {
831
- ...state.domainSelections,
832
- [domain]: {
833
- ...state.domainSelections[domain],
834
- [category]: resolvedSelections
835
- }
836
- }
837
- };
838
- }),
839
- nextDomain: () => {
840
- const state = get();
841
- if (state.currentDomainIndex < state.selectedDomains.length - 1) {
842
- set({
843
- currentDomainIndex: state.currentDomainIndex + 1
844
- });
845
- get().seedFocusedSkillForActiveDomain();
846
- return true;
847
- }
848
- return false;
849
- },
850
- prevDomain: () => {
851
- const state = get();
852
- if (state.currentDomainIndex > 0) {
853
- set({
854
- currentDomainIndex: state.currentDomainIndex - 1
855
- });
856
- get().seedFocusedSkillForActiveDomain();
857
- return true;
858
- }
859
- return false;
860
- },
861
- setCurrentDomainIndex: (index) => {
862
- const state = get();
863
- if (index >= 0 && index < state.selectedDomains.length) {
864
- set({ currentDomainIndex: index });
865
- get().seedFocusedSkillForActiveDomain();
866
- }
867
- },
868
- toggleShowLabels: () => set((state) => ({ showLabels: !state.showLabels })),
869
- deriveInstallMode: () => {
870
- const { skillConfigs } = get();
871
- return deriveInstallMode(skillConfigs);
872
- },
873
- toggleSkillScope: (skillId) => set((state) => {
874
- if (state.isEditingFromGlobalScope) return state;
875
- const config = state.skillConfigs.find((sc) => sc.id === skillId && !sc.excluded);
876
- if (!config) return state;
877
- if (wouldOverwriteGlobalEject(config, state.skillConfigs, state.installedSkillConfigs)) {
878
- return { toastMessage: TOAST_MESSAGES.ALREADY_EJECTED_AT_GLOBAL };
879
- }
880
- const wasInstalledGlobally = state.installedSkillConfigs?.some((sc) => sc.id === skillId && sc.scope === "global") ?? false;
881
- const newScope = config.scope === "project" ? "global" : "project";
882
- const rescoped = state.skillConfigs.map(
883
- (sc) => sc.id === skillId && !sc.excluded ? { ...sc, scope: newScope } : sc
884
- );
885
- if (newScope === "project") {
886
- const needsTombstone = wasInstalledGlobally && !rescoped.some((sc) => sc.id === skillId && sc.excluded);
887
- return {
888
- skillConfigs: needsTombstone ? [
889
- ...rescoped,
890
- { id: skillId, scope: "global", excluded: true, origin: config.origin }
891
- ] : rescoped,
892
- foldedSkillIds: state.foldedSkillIds.filter((id) => id !== skillId)
893
- };
894
- }
895
- return {
896
- skillConfigs: rescoped.filter((sc) => !(sc.id === skillId && sc.excluded)),
897
- foldedSkillIds: isDualScopePair(state.skillConfigs, skillId) ? [...state.foldedSkillIds, skillId] : state.foldedSkillIds
898
- };
899
- }),
900
- setFocusedSkillId: (id) => set({ focusedSkillId: id }),
901
- seedFocusedSkillForActiveDomain: () => {
902
- const state = get();
903
- const domain = state.getCurrentDomain() ?? FALLBACK_DOMAIN;
904
- const categories = buildCategoriesForDomain(
905
- domain,
906
- state.getAllSelectedTechnologies(),
907
- void 0,
908
- state.skillConfigs
909
- );
910
- set({ focusedSkillId: categories[0]?.options[0]?.id ?? null });
911
- },
912
- setInstallMode: (skillId, mode, scope) => set((state) => {
913
- if (!skillId) {
914
- warn("Ignoring setInstallMode call with empty skillId");
915
- return state;
916
- }
917
- if (isInheritedGlobalSlot(state.installedSkillConfigs, skillId, scope) && !state.isEditingFromGlobalScope) {
918
- return state;
919
- }
920
- const origin = sourceForInstallMode(getSkillById(skillId), mode);
921
- return {
922
- skillConfigs: withActiveEntryOrigin(state.skillConfigs, skillId, scope, origin)
923
- };
924
- }),
925
- toggleInfo: () => set((state) => ({ showInfo: !state.showInfo })),
926
- setToastMessage: (message) => set({ toastMessage: message }),
927
- goBack: () => {
928
- const previousStep = get().history.at(-1);
929
- if (previousStep === void 0) return;
930
- set((state) => ({ step: previousStep, history: state.history.slice(0, -1) }));
931
- seedFocusForStep(previousStep, get());
932
- },
933
- toggleAgent: (agent) => set((state) => {
934
- const installed = state.installedAgentConfigs ?? [];
935
- const isDualScopePairRow = !state.isEditingFromGlobalScope && isDualScopeAgentPair(state.agentConfigs, agent);
936
- if (isDualScopePairRow) {
937
- return { toastMessage: TOAST_MESSAGES.GLOBAL_AGENTS_LOCKED };
938
- }
939
- const isInheritedGlobalReselect = !state.isEditingFromGlobalScope && agentHasGlobalActive(state.agentConfigs, agent) && !agentHasProjectActive(state.agentConfigs, agent) && !state.selectedAgents.includes(agent) && agentHasGlobalTombstone(installed, agent);
940
- if (isInheritedGlobalReselect) {
941
- return restoreDualScopeAgent(state.selectedAgents, state.agentConfigs, agent);
942
- }
943
- const isActiveGlobal = agentHasGlobalActive(installed, agent) || agentHasGlobalTombstone(installed, agent) && agentHasGlobalActive(state.agentConfigs, agent);
944
- if (isActiveGlobal && !state.isEditingFromGlobalScope) {
945
- return { toastMessage: TOAST_MESSAGES.GLOBAL_AGENTS_LOCKED };
946
- }
947
- const isInList = state.selectedAgents.includes(agent);
948
- const hasExcludedTombstone = state.agentConfigs.some(
949
- (ac) => ac.name === agent && ac.excluded
950
- );
951
- const isSelected = isInList && !hasExcludedTombstone;
952
- return {
953
- selectedAgents: nextSelectedAgents(state.selectedAgents, agent, { isSelected, isInList }),
954
- agentConfigs: applyAgentToggle(state.agentConfigs, agent, isSelected)
955
- };
956
- }),
957
- toggleAgentScope: (agentName) => set((state) => {
958
- if (state.isEditingFromGlobalScope) return state;
959
- const config = state.agentConfigs.find((ac) => ac.name === agentName && !ac.excluded);
960
- if (!config) return state;
961
- const wasInstalledGlobally = state.installedAgentConfigs?.some((ac) => ac.name === agentName && ac.scope === "global") ?? false;
962
- const newScope = config.scope === "project" ? "global" : "project";
963
- const rescoped = state.agentConfigs.map(
964
- (ac) => ac.name === agentName && !ac.excluded ? { ...ac, scope: newScope } : ac
965
- );
966
- if (newScope === "project") {
967
- const needsTombstone = wasInstalledGlobally && !rescoped.some((ac) => ac.name === agentName && ac.excluded);
968
- return {
969
- agentConfigs: needsTombstone ? [...rescoped, { name: agentName, scope: "global", excluded: true }] : rescoped
970
- };
971
- }
972
- return { agentConfigs: rescoped.filter((ac) => !(ac.name === agentName && ac.excluded)) };
973
- }),
974
- setFocusedAgentId: (id) => set({ focusedAgentId: id }),
975
- seedFocusedAgent: () => {
976
- if (get().focusedAgentId !== null) return;
977
- set({ focusedAgentId: firstFocusableAgent() });
978
- },
979
- preselectAgentsFromDomains: () => set((state) => {
980
- if (state.selectedStackId) return state;
981
- const sorted = [
982
- ...new Set(state.selectedDomains.flatMap((domain) => DOMAIN_AGENTS[domain] ?? []))
983
- ].sort();
984
- const roster = new Set(sorted);
985
- const merged = sorted.map((name) => buildAgentConfigForName(name, state.agentConfigs));
986
- const rebuiltSlots = filledAgentSlots(merged);
987
- const retained = state.agentConfigs.filter(
988
- (ac) => survivesRosterRebuild(ac, roster, rebuiltSlots)
989
- );
990
- return {
991
- selectedAgents: sorted,
992
- agentConfigs: [...merged, ...retained]
993
- };
994
- }),
995
- preselectAgentsFromStack: (stackAgents) => set((state) => {
996
- const savedConfigs = state.globalAgentPreselections?.configs ?? [];
997
- const globalAgents = state.globalAgentPreselections?.agents ?? [];
998
- const mergedAgents = [.../* @__PURE__ */ new Set([...stackAgents, ...globalAgents])].sort();
999
- const merged = mergedAgents.map((name) => buildAgentConfigForName(name, savedConfigs));
1000
- const excludedConfigs = agentTombstonesOutsideRebuild(savedConfigs, merged);
1001
- return {
1002
- selectedAgents: mergedAgents,
1003
- agentConfigs: [...merged, ...excludedConfigs]
1004
- };
1005
- }),
1006
- reset: () => set(createInitialState()),
1007
- getAllSelectedTechnologies: () => {
1008
- return typedValues(get().domainSelections).flatMap(flattenCategorySelections);
1009
- },
1010
- getSelectedTechnologiesPerDomain: () => {
1011
- const entries = typedEntries(get().domainSelections).map(([domain, domainSel]) => [domain, flattenCategorySelections(domainSel)]).filter(([, techs]) => techs.length > 0);
1012
- return typedFromEntries(entries);
1013
- },
1014
- getCurrentDomain: () => {
1015
- const state = get();
1016
- return state.selectedDomains[state.currentDomainIndex] || null;
1017
- },
1018
- getTechnologyCount: () => {
1019
- return get().getAllSelectedTechnologies().length;
1020
- },
1021
- getStepProgress: () => {
1022
- const state = get();
1023
- const isStackDefaults = state.approach === "stack" && !!state.selectedStackId && state.stackAction === "defaults";
1024
- const skippedSteps = isStackDefaults ? ["build", "sources", "agents"] : [];
1025
- const precedingSteps = stepsBefore(getActiveStepFlow(), state.step);
1026
- const completedSteps = precedingSteps.filter((step) => !skippedSteps.includes(step));
1027
- return { completedSteps, skippedSteps };
1028
- },
1029
- canGoToNextDomain: () => {
1030
- const state = get();
1031
- return state.currentDomainIndex < state.selectedDomains.length - 1;
1032
- },
1033
- canGoToPreviousDomain: () => {
1034
- const state = get();
1035
- return state.currentDomainIndex > 0;
1036
- },
1037
- buildSourceRows: () => {
1038
- const state = get();
1039
- const selectedTechnologies = get().getAllSelectedTechnologies();
1040
- const { skillConfigs } = state;
1041
- const selectedSet = new Set(selectedTechnologies);
1042
- const inheritedSkillIds = skillConfigs.filter((sc) => !sc.excluded && !selectedSet.has(sc.id)).map((sc) => sc.id);
1043
- const allActiveIds = /* @__PURE__ */ new Set([...inheritedSkillIds, ...selectedTechnologies]);
1044
- const excludedGlobalIds = skillConfigs.filter((sc) => isGlobalTombstone(sc) && !allActiveIds.has(sc.id)).map((sc) => sc.id);
1045
- const liveSkillIds = [...inheritedSkillIds, ...selectedTechnologies, ...excludedGlobalIds];
1046
- const installedSkillSlots = collectInstalledSkillSlots(state.installedSkillConfigs);
1047
- const resolveRowInputs = (id) => resolveSkillRowInputs(id, skillConfigs);
1048
- const liveRows = liveSkillIds.flatMap((id) => {
1049
- const { skillId, configEntry, options } = resolveRowInputs(id);
1050
- return classifySkillSourceRows(skillId, options, {
1051
- configEntry,
1052
- installedSkillConfigs: state.installedSkillConfigs,
1053
- isEditingFromGlobalScope: state.isEditingFromGlobalScope,
1054
- installedSkillSlots
1055
- });
1056
- });
1057
- const pendingRemovalRows = collectRemovedInstalledEntries(
1058
- state.installedSkillConfigs,
1059
- skillConfigs
1060
- ).filter((entry) => !isSlotAlreadyRendered(liveRows, entry)).map((entry) => {
1061
- const { skillId, options } = resolveRowInputs(entry.id);
1062
- return toPendingRemovalRow(skillId, options, entry);
1063
- });
1064
- const rows = [...liveRows, ...pendingRemovalRows];
1065
- rows.sort((a, b) => sourceRowSortTier(a) - sourceRowSortTier(b));
1066
- return rows;
1067
- }
1068
- }));
1069
- function showWarningsAsToast(change) {
1070
- enableBuffering();
1071
- try {
1072
- change();
1073
- const warnings = drainBuffer();
1074
- if (warnings.length > 0) {
1075
- useWizardStore.getState().setToastMessage(skillsLeftOutToast(warnings.length));
1076
- }
1077
- } finally {
1078
- disableBuffering();
1079
- }
1080
- }
1081
- function hydrateWizardStore(options) {
1082
- useWizardStore.setState(createInitialState());
1083
- const { initialStep } = options;
1084
- const isEditFlow = initialStep !== void 0;
1085
- if (isEditFlow) {
1086
- hydrateForEdit(initialStep, options);
1087
- } else {
1088
- hydrateForInit(options);
1089
- }
1090
- }
1091
- function hydrateForEdit(initialStep, options) {
1092
- const {
1093
- initialDomains,
1094
- initialAgents,
1095
- installedSkillIds,
1096
- installedSkillConfigs,
1097
- installedAgentConfigs,
1098
- isEditingFromGlobalScope,
1099
- setupMarketplace
1100
- } = options;
1101
- if (installedSkillIds?.length) {
1102
- useWizardStore.getState().populateFromSkillIds(installedSkillIds, installedSkillConfigs);
1103
- }
1104
- useWizardStore.setState({
1105
- isInitMode: false,
1106
- step: initialStep,
1107
- history: [],
1108
- approach: "scratch",
1109
- ...initialDomains?.length ? { selectedDomains: initialDomains, currentDomainIndex: 0 } : {},
1110
- ...initialAgents?.length ? { selectedAgents: initialAgents } : {},
1111
- ...initialAgents?.length && installedAgentConfigs?.length ? { agentConfigs: installedAgentConfigs } : {},
1112
- ...installedSkillConfigs?.length || installedAgentConfigs?.length ? {
1113
- installedSkillConfigs: installedSkillConfigs ?? null,
1114
- installedAgentConfigs: installedAgentConfigs ?? null
1115
- } : {},
1116
- ...isEditingFromGlobalScope ? { isEditingFromGlobalScope: true } : {},
1117
- ...setupMarketplace !== void 0 && { setupMarketplace }
1118
- });
1119
- useWizardStore.getState().seedFocusedSkillForActiveDomain();
1120
- }
1121
- var FIRST_STEP_WITHOUT_STACKS = "domains";
1122
- function hydrateForInit(options) {
1123
- const {
1124
- initialDomains,
1125
- initialAgents,
1126
- installedSkillConfigs,
1127
- installedAgentConfigs,
1128
- isEditingFromGlobalScope
1129
- } = options;
1130
- useWizardStore.setState({
1131
- isInitMode: true,
1132
- ...initialDomains?.length ? { selectedDomains: initialDomains, currentDomainIndex: 0 } : {},
1133
- ...initialAgents?.length ? { selectedAgents: initialAgents } : {},
1134
- ...initialAgents?.length && installedAgentConfigs?.length ? { agentConfigs: installedAgentConfigs } : {},
1135
- ...installedSkillConfigs?.length || installedAgentConfigs?.length ? {
1136
- installedSkillConfigs: installedSkillConfigs ?? null,
1137
- installedAgentConfigs: installedAgentConfigs ?? null
1138
- } : {},
1139
- ...isEditingFromGlobalScope ? { isEditingFromGlobalScope: true } : {},
1140
- ...installedSkillConfigs?.length ? { globalPreselections: installedSkillConfigs } : {},
1141
- ...initialAgents?.length || installedAgentConfigs?.length ? {
1142
- globalAgentPreselections: {
1143
- agents: initialAgents ?? [],
1144
- configs: installedAgentConfigs ?? []
1145
- }
1146
- } : {}
1147
- });
1148
- if (!offersStacks()) {
1149
- useWizardStore.getState().startFromScratch();
1150
- useWizardStore.setState({ step: FIRST_STEP_WITHOUT_STACKS, history: [] });
1151
- }
1152
- useWizardStore.getState().seedFocusedSkillForActiveDomain();
1153
- }
1154
-
1155
- export {
1156
- computeScopeDiff,
1157
- formatScopeTag,
1158
- deriveScopeBadges,
1159
- buildCategoriesForDomain,
1160
- BUILT_IN_AGENT_GROUPS,
1161
- BUILT_IN_AGENT_IDS,
1162
- DOMAIN_AGENTS,
1163
- WIZARD_STEP_ORDER,
1164
- getActiveStepFlow,
1165
- createInitialState,
1166
- useWizardStore,
1167
- showWarningsAsToast,
1168
- hydrateWizardStore
1169
- };
1170
- //# sourceMappingURL=chunk-WNLF5EDZ.js.map