@agents-inc/cli 0.86.0 → 0.88.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 (129) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/dist/{chunk-GED2F75H.js → chunk-23M3SPXX.js} +180 -124
  3. package/dist/chunk-23M3SPXX.js.map +1 -0
  4. package/dist/{chunk-ZOWRO7UQ.js → chunk-2DRPZXXK.js} +3 -3
  5. package/dist/{chunk-5M6Q5UQO.js → chunk-57KI55GJ.js} +2 -2
  6. package/dist/{chunk-HH3AWXF4.js → chunk-5IYZGJDW.js} +3 -3
  7. package/dist/{chunk-Q4DMIPZB.js → chunk-6YR2NEW3.js} +2 -2
  8. package/dist/{chunk-HU6XQVZL.js → chunk-AP4DLJDP.js} +1 -1
  9. package/dist/{chunk-HU6XQVZL.js.map → chunk-AP4DLJDP.js.map} +1 -1
  10. package/dist/{chunk-SGZOFIFF.js → chunk-ATPHV3MD.js} +2 -2
  11. package/dist/{chunk-HSLVCKVQ.js → chunk-DDCW4SKN.js} +3 -3
  12. package/dist/{chunk-TMTUTUEV.js → chunk-EADZIYQW.js} +12 -7
  13. package/dist/chunk-EADZIYQW.js.map +1 -0
  14. package/dist/{chunk-BV2MIQ3O.js → chunk-I5AZKNNL.js} +1 -1
  15. package/dist/chunk-I5AZKNNL.js.map +1 -0
  16. package/dist/{chunk-HZ2IBXVQ.js → chunk-ITBSJNIC.js} +3 -3
  17. package/dist/chunk-J6PI73YV.js +68 -0
  18. package/dist/chunk-J6PI73YV.js.map +1 -0
  19. package/dist/{chunk-BEFYAFGV.js → chunk-JNUFQBXX.js} +2 -2
  20. package/dist/chunk-LHUK5L6P.js +564 -0
  21. package/dist/chunk-LHUK5L6P.js.map +1 -0
  22. package/dist/{chunk-LZ7XQ3IU.js → chunk-MY4TVLRB.js} +2 -2
  23. package/dist/{chunk-I44YG6VI.js → chunk-PZBLGD7O.js} +5 -19
  24. package/dist/chunk-PZBLGD7O.js.map +1 -0
  25. package/dist/{chunk-HZQOFFKA.js → chunk-REZZSDXG.js} +10 -10
  26. package/dist/{chunk-O27WJ5KS.js → chunk-RWVF6DQE.js} +3 -3
  27. package/dist/{chunk-B6MYECV6.js → chunk-STMRDPGZ.js} +2 -2
  28. package/dist/{chunk-MMTMXLI4.js → chunk-TAPEVEET.js} +2 -2
  29. package/dist/{chunk-CXWBVBDM.js → chunk-VWTZOBBQ.js} +2 -2
  30. package/dist/{chunk-UNEJKTLP.js → chunk-WTPPVXJP.js} +3 -3
  31. package/dist/{chunk-FBZR46GC.js → chunk-YM3V4Q3W.js} +4 -4
  32. package/dist/{chunk-C5IYJ42F.js → chunk-ZFQTKY2S.js} +2 -2
  33. package/dist/{chunk-NUU3U43A.js → chunk-ZTRQO5CX.js} +2 -2
  34. package/dist/chunk-ZTRQO5CX.js.map +1 -0
  35. package/dist/commands/build/marketplace.js +3 -3
  36. package/dist/commands/build/plugins.js +5 -5
  37. package/dist/commands/build/stack.js +5 -5
  38. package/dist/commands/compile.js +31 -25
  39. package/dist/commands/compile.js.map +1 -1
  40. package/dist/commands/config/index.js +5 -5
  41. package/dist/commands/config/path.js +4 -4
  42. package/dist/commands/config/show.js +5 -5
  43. package/dist/commands/diff.js +685 -86
  44. package/dist/commands/diff.js.map +1 -1
  45. package/dist/commands/doctor.js +35 -63
  46. package/dist/commands/doctor.js.map +1 -1
  47. package/dist/commands/edit.js +180 -48
  48. package/dist/commands/edit.js.map +1 -1
  49. package/dist/commands/eject.js +182 -32
  50. package/dist/commands/eject.js.map +1 -1
  51. package/dist/commands/import/skill.js +200 -36
  52. package/dist/commands/import/skill.js.map +1 -1
  53. package/dist/commands/info.js +46 -39
  54. package/dist/commands/info.js.map +1 -1
  55. package/dist/commands/init.js +19 -22
  56. package/dist/commands/list.js +4 -4
  57. package/dist/commands/new/agent.js +144 -48
  58. package/dist/commands/new/agent.js.map +1 -1
  59. package/dist/commands/new/marketplace.js +9 -9
  60. package/dist/commands/new/marketplace.js.map +1 -1
  61. package/dist/commands/new/skill.js +198 -34
  62. package/dist/commands/new/skill.js.map +1 -1
  63. package/dist/commands/outdated.js +6 -8
  64. package/dist/commands/outdated.js.map +1 -1
  65. package/dist/commands/search.js +165 -68
  66. package/dist/commands/search.js.map +1 -1
  67. package/dist/commands/uninstall.js +263 -65
  68. package/dist/commands/uninstall.js.map +1 -1
  69. package/dist/commands/update.js +236 -167
  70. package/dist/commands/update.js.map +1 -1
  71. package/dist/commands/validate.js +4 -4
  72. package/dist/components/skill-search/skill-search.js +1 -1
  73. package/dist/components/wizard/category-grid.test.js +7 -7
  74. package/dist/components/wizard/domain-selection.js +5 -5
  75. package/dist/components/wizard/help-modal.js +5 -5
  76. package/dist/components/wizard/source-grid.test.js +7 -7
  77. package/dist/components/wizard/stack-selection.js +5 -5
  78. package/dist/components/wizard/step-agents.js +5 -5
  79. package/dist/components/wizard/step-agents.test.js +8 -8
  80. package/dist/components/wizard/step-build.js +5 -5
  81. package/dist/components/wizard/step-build.test.js +7 -7
  82. package/dist/components/wizard/step-confirm.test.js +5 -5
  83. package/dist/components/wizard/step-settings.js +4 -4
  84. package/dist/components/wizard/step-settings.test.js +7 -7
  85. package/dist/components/wizard/step-sources.js +5 -5
  86. package/dist/components/wizard/step-sources.test.js +8 -8
  87. package/dist/components/wizard/step-stack.js +6 -6
  88. package/dist/components/wizard/step-stack.test.js +7 -7
  89. package/dist/components/wizard/wizard-layout.js +6 -6
  90. package/dist/components/wizard/wizard.js +14 -14
  91. package/dist/hooks/init.js +18 -20
  92. package/dist/hooks/init.js.map +1 -1
  93. package/dist/{loader-GSEGPK64.js → loader-SQOK2BF7.js} +3 -3
  94. package/dist/{source-loader-OGFTIRIX.js → source-loader-CCECAU5L.js} +4 -4
  95. package/dist/{source-manager-FMMDDVZA.js → source-manager-4P7MTZRR.js} +4 -4
  96. package/dist/stores/wizard-store.js +4 -4
  97. package/dist/stores/wizard-store.test.js +7 -7
  98. package/package.json +1 -1
  99. package/dist/chunk-BV2MIQ3O.js.map +0 -1
  100. package/dist/chunk-DCVCFBQ7.js +0 -1800
  101. package/dist/chunk-DCVCFBQ7.js.map +0 -1
  102. package/dist/chunk-GED2F75H.js.map +0 -1
  103. package/dist/chunk-I44YG6VI.js.map +0 -1
  104. package/dist/chunk-NUU3U43A.js.map +0 -1
  105. package/dist/chunk-O5ZWS26C.js +0 -166
  106. package/dist/chunk-O5ZWS26C.js.map +0 -1
  107. package/dist/chunk-TMTUTUEV.js.map +0 -1
  108. package/dist/chunk-XQK4S22C.js +0 -202
  109. package/dist/chunk-XQK4S22C.js.map +0 -1
  110. /package/dist/{chunk-ZOWRO7UQ.js.map → chunk-2DRPZXXK.js.map} +0 -0
  111. /package/dist/{chunk-5M6Q5UQO.js.map → chunk-57KI55GJ.js.map} +0 -0
  112. /package/dist/{chunk-HH3AWXF4.js.map → chunk-5IYZGJDW.js.map} +0 -0
  113. /package/dist/{chunk-Q4DMIPZB.js.map → chunk-6YR2NEW3.js.map} +0 -0
  114. /package/dist/{chunk-SGZOFIFF.js.map → chunk-ATPHV3MD.js.map} +0 -0
  115. /package/dist/{chunk-HSLVCKVQ.js.map → chunk-DDCW4SKN.js.map} +0 -0
  116. /package/dist/{chunk-HZ2IBXVQ.js.map → chunk-ITBSJNIC.js.map} +0 -0
  117. /package/dist/{chunk-BEFYAFGV.js.map → chunk-JNUFQBXX.js.map} +0 -0
  118. /package/dist/{chunk-LZ7XQ3IU.js.map → chunk-MY4TVLRB.js.map} +0 -0
  119. /package/dist/{chunk-HZQOFFKA.js.map → chunk-REZZSDXG.js.map} +0 -0
  120. /package/dist/{chunk-O27WJ5KS.js.map → chunk-RWVF6DQE.js.map} +0 -0
  121. /package/dist/{chunk-B6MYECV6.js.map → chunk-STMRDPGZ.js.map} +0 -0
  122. /package/dist/{chunk-MMTMXLI4.js.map → chunk-TAPEVEET.js.map} +0 -0
  123. /package/dist/{chunk-CXWBVBDM.js.map → chunk-VWTZOBBQ.js.map} +0 -0
  124. /package/dist/{chunk-UNEJKTLP.js.map → chunk-WTPPVXJP.js.map} +0 -0
  125. /package/dist/{chunk-FBZR46GC.js.map → chunk-YM3V4Q3W.js.map} +0 -0
  126. /package/dist/{chunk-C5IYJ42F.js.map → chunk-ZFQTKY2S.js.map} +0 -0
  127. /package/dist/{loader-GSEGPK64.js.map → loader-SQOK2BF7.js.map} +0 -0
  128. /package/dist/{source-loader-OGFTIRIX.js.map → source-loader-CCECAU5L.js.map} +0 -0
  129. /package/dist/{source-manager-FMMDDVZA.js.map → source-manager-4P7MTZRR.js.map} +0 -0
@@ -0,0 +1,564 @@
1
+ #!/usr/bin/env node
2
+ import {
3
+ truncateText
4
+ } from "./chunk-N6A7A4RA.js";
5
+ import {
6
+ getAgentDefinitions,
7
+ recompileAgents
8
+ } from "./chunk-YM3V4Q3W.js";
9
+ import {
10
+ buildAgentScopeMap,
11
+ buildAndMergeConfig,
12
+ claudePluginInstall,
13
+ claudePluginMarketplaceAdd,
14
+ claudePluginMarketplaceExists,
15
+ claudePluginMarketplaceUpdate,
16
+ claudePluginUninstall,
17
+ compareLocalSkillsWithSource,
18
+ copySkillsToLocalFlattened,
19
+ detectGlobalInstallation,
20
+ detectInstallation,
21
+ detectProjectInstallation,
22
+ discoverAllPluginSkills,
23
+ discoverLocalSkills,
24
+ ensureBlankGlobalConfig,
25
+ fetchMarketplace,
26
+ loadProjectConfig,
27
+ loadProjectConfigFromDir,
28
+ loadSkillsMatrixFromSource,
29
+ resolveInstallPaths,
30
+ writeScopedConfigs
31
+ } from "./chunk-EADZIYQW.js";
32
+ import {
33
+ loadAllAgents,
34
+ parseFrontmatter
35
+ } from "./chunk-STMRDPGZ.js";
36
+ import {
37
+ typedEntries,
38
+ typedKeys
39
+ } from "./chunk-ANXHMG32.js";
40
+ import {
41
+ directoryExists,
42
+ disableBuffering,
43
+ drainBuffer,
44
+ enableBuffering,
45
+ ensureDir,
46
+ fileExists,
47
+ getErrorMessage,
48
+ glob,
49
+ listDirectories,
50
+ readFile,
51
+ verbose,
52
+ warn
53
+ } from "./chunk-ZTRQO5CX.js";
54
+ import {
55
+ GLOBAL_INSTALL_ROOT,
56
+ LOCAL_SKILLS_PATH,
57
+ PROJECT_ROOT,
58
+ STANDARD_FILES
59
+ } from "./chunk-6PGL2XMY.js";
60
+ import {
61
+ init_esm_shims
62
+ } from "./chunk-DHET7RCE.js";
63
+
64
+ // src/cli/lib/operations/detect-both-installations.ts
65
+ init_esm_shims();
66
+ import os from "os";
67
+ async function detectBothInstallations(projectDir) {
68
+ const global = await detectGlobalInstallation();
69
+ const project = projectDir === os.homedir() ? null : await detectProjectInstallation(projectDir);
70
+ return { global, project, hasBoth: !!global && !!project };
71
+ }
72
+
73
+ // src/cli/lib/operations/load-source.ts
74
+ init_esm_shims();
75
+ async function loadSource(options) {
76
+ const { sourceFlag, projectDir, forceRefresh, captureStartupMessages } = options;
77
+ if (captureStartupMessages) {
78
+ enableBuffering();
79
+ }
80
+ let sourceResult;
81
+ try {
82
+ sourceResult = await loadSkillsMatrixFromSource({
83
+ sourceFlag,
84
+ projectDir,
85
+ forceRefresh
86
+ });
87
+ } catch (error) {
88
+ if (captureStartupMessages) {
89
+ disableBuffering();
90
+ }
91
+ throw error;
92
+ }
93
+ let startupMessages = [];
94
+ if (captureStartupMessages) {
95
+ startupMessages = drainBuffer();
96
+ disableBuffering();
97
+ }
98
+ return { sourceResult, startupMessages };
99
+ }
100
+
101
+ // src/cli/lib/operations/detect-project.ts
102
+ init_esm_shims();
103
+ async function detectProject(projectDir) {
104
+ const resolvedDir = projectDir ?? process.cwd();
105
+ const installation = await detectInstallation(resolvedDir);
106
+ if (!installation) {
107
+ return null;
108
+ }
109
+ const loaded = await loadProjectConfig(installation.projectDir);
110
+ return {
111
+ installation,
112
+ config: loaded?.config ?? null,
113
+ configPath: loaded?.configPath ?? null
114
+ };
115
+ }
116
+
117
+ // src/cli/lib/operations/load-agent-defs.ts
118
+ init_esm_shims();
119
+ async function loadAgentDefs(agentSource, options) {
120
+ const agentSourcePaths = await getAgentDefinitions(agentSource, options);
121
+ const cliAgents = await loadAllAgents(PROJECT_ROOT);
122
+ const sourceAgents = await loadAllAgents(agentSourcePaths.sourcePath);
123
+ const agents = { ...cliAgents, ...sourceAgents };
124
+ return {
125
+ agents,
126
+ sourcePath: agentSourcePaths.sourcePath,
127
+ agentSourcePaths
128
+ };
129
+ }
130
+
131
+ // src/cli/lib/operations/copy-local-skills.ts
132
+ init_esm_shims();
133
+ async function copyLocalSkills(skills, projectDir, sourceResult) {
134
+ const projectLocalSkills = skills.filter((s) => s.scope !== "global");
135
+ const globalLocalSkills = skills.filter((s) => s.scope === "global");
136
+ const projectPaths = resolveInstallPaths(projectDir, "project");
137
+ const globalPaths = resolveInstallPaths(projectDir, "global");
138
+ let projectCopied = [];
139
+ if (projectLocalSkills.length > 0) {
140
+ await ensureDir(projectPaths.skillsDir);
141
+ projectCopied = await copySkillsToLocalFlattened(
142
+ projectLocalSkills.map((s) => s.id),
143
+ projectPaths.skillsDir,
144
+ sourceResult.matrix,
145
+ sourceResult
146
+ );
147
+ }
148
+ let globalCopied = [];
149
+ if (globalLocalSkills.length > 0) {
150
+ await ensureDir(globalPaths.skillsDir);
151
+ globalCopied = await copySkillsToLocalFlattened(
152
+ globalLocalSkills.map((s) => s.id),
153
+ globalPaths.skillsDir,
154
+ sourceResult.matrix,
155
+ sourceResult
156
+ );
157
+ }
158
+ return {
159
+ projectCopied,
160
+ globalCopied,
161
+ totalCopied: projectCopied.length + globalCopied.length
162
+ };
163
+ }
164
+
165
+ // src/cli/lib/operations/install-plugin-skills.ts
166
+ init_esm_shims();
167
+ async function installPluginSkills(skills, marketplace, projectDir) {
168
+ const pluginSkills = skills.filter((s) => s.source !== "local");
169
+ const installed = [];
170
+ const failed = [];
171
+ for (const skill of pluginSkills) {
172
+ const pluginRef = `${skill.id}@${marketplace}`;
173
+ const pluginScope = skill.scope === "global" ? "user" : "project";
174
+ try {
175
+ await claudePluginInstall(pluginRef, pluginScope, projectDir);
176
+ installed.push({ id: skill.id, ref: pluginRef });
177
+ } catch (error) {
178
+ failed.push({ id: skill.id, error: getErrorMessage(error) });
179
+ }
180
+ }
181
+ return { installed, failed };
182
+ }
183
+
184
+ // src/cli/lib/operations/uninstall-plugin-skills.ts
185
+ init_esm_shims();
186
+ async function uninstallPluginSkills(skillIds, oldSkills, projectDir) {
187
+ const uninstalled = [];
188
+ const failed = [];
189
+ for (const skillId of skillIds) {
190
+ const oldSkill = oldSkills.find((s) => s.id === skillId);
191
+ const pluginScope = oldSkill?.scope === "global" ? "user" : "project";
192
+ try {
193
+ await claudePluginUninstall(skillId, pluginScope, projectDir);
194
+ uninstalled.push(skillId);
195
+ } catch (error) {
196
+ failed.push({ id: skillId, error: getErrorMessage(error) });
197
+ }
198
+ }
199
+ return { uninstalled, failed };
200
+ }
201
+
202
+ // src/cli/lib/operations/collect-scoped-skill-dirs.ts
203
+ init_esm_shims();
204
+ import os2 from "os";
205
+ import path from "path";
206
+ async function collectScopedSkillDirs(projectDir) {
207
+ const homeDir = os2.homedir();
208
+ const projectLocalPath = path.join(projectDir, LOCAL_SKILLS_PATH);
209
+ const globalLocalPath = path.join(homeDir, LOCAL_SKILLS_PATH);
210
+ const hasProject = await fileExists(projectLocalPath);
211
+ const hasGlobal = projectDir !== homeDir && await fileExists(globalLocalPath);
212
+ const dirs = [];
213
+ if (hasProject) {
214
+ for (const dirName of await listDirectories(projectLocalPath)) {
215
+ dirs.push({ dirName, localSkillsPath: projectLocalPath, scope: "project" });
216
+ }
217
+ }
218
+ if (hasGlobal) {
219
+ const projectDirNames = new Set(dirs.map((d) => d.dirName));
220
+ for (const dirName of await listDirectories(globalLocalPath)) {
221
+ if (!projectDirNames.has(dirName)) {
222
+ dirs.push({ dirName, localSkillsPath: globalLocalPath, scope: "global" });
223
+ }
224
+ }
225
+ }
226
+ return { dirs, hasProject, hasGlobal, projectLocalPath, globalLocalPath };
227
+ }
228
+
229
+ // src/cli/lib/operations/compare-skills.ts
230
+ init_esm_shims();
231
+ import os3 from "os";
232
+ function buildSourceSkillsMap(matrix) {
233
+ const sourceSkills = {};
234
+ for (const [skillId, skill] of typedEntries(matrix.skills)) {
235
+ if (!skill) continue;
236
+ if (!skill.local) {
237
+ sourceSkills[skillId] = { path: skill.path };
238
+ }
239
+ }
240
+ return sourceSkills;
241
+ }
242
+ async function compareSkillsWithSource(projectDir, sourcePath, matrix) {
243
+ const sourceSkills = buildSourceSkillsMap(matrix);
244
+ const { hasProject, hasGlobal } = await collectScopedSkillDirs(projectDir);
245
+ const homeDir = os3.homedir();
246
+ const projectResults = hasProject ? await compareLocalSkillsWithSource(projectDir, sourcePath, sourceSkills) : [];
247
+ const globalResults = hasGlobal ? await compareLocalSkillsWithSource(homeDir, sourcePath, sourceSkills) : [];
248
+ const seenIds = new Set(projectResults.map((r) => r.id));
249
+ const merged = [...projectResults, ...globalResults.filter((r) => !seenIds.has(r.id))];
250
+ return { projectResults, globalResults, merged };
251
+ }
252
+
253
+ // src/cli/lib/operations/ensure-marketplace.ts
254
+ init_esm_shims();
255
+ async function ensureMarketplace(sourceResult) {
256
+ if (!sourceResult.marketplace) {
257
+ try {
258
+ const marketplaceResult = await fetchMarketplace(sourceResult.sourceConfig.source, {});
259
+ sourceResult.marketplace = marketplaceResult.marketplace.name;
260
+ } catch {
261
+ return { marketplace: null, registered: false };
262
+ }
263
+ }
264
+ const marketplace = sourceResult.marketplace;
265
+ const exists = await claudePluginMarketplaceExists(marketplace);
266
+ if (!exists) {
267
+ const marketplaceSource = sourceResult.sourceConfig.source.replace(/^github:/, "");
268
+ await claudePluginMarketplaceAdd(marketplaceSource);
269
+ return { marketplace, registered: true };
270
+ }
271
+ try {
272
+ await claudePluginMarketplaceUpdate(marketplace);
273
+ } catch {
274
+ warn("Could not update marketplace \u2014 continuing with cached version");
275
+ }
276
+ return { marketplace, registered: false };
277
+ }
278
+
279
+ // src/cli/lib/operations/write-project-config.ts
280
+ init_esm_shims();
281
+ import fs from "fs";
282
+ import os4 from "os";
283
+ import path2 from "path";
284
+ async function writeProjectConfig(options) {
285
+ const { wizardResult, sourceResult, projectDir, sourceFlag } = options;
286
+ const projectPaths = resolveInstallPaths(projectDir, "project");
287
+ await ensureDir(path2.dirname(projectPaths.configPath));
288
+ let agents;
289
+ if (options.agents) {
290
+ agents = options.agents;
291
+ } else {
292
+ const cliAgents = await loadAllAgents(PROJECT_ROOT);
293
+ const sourceAgents = await loadAllAgents(sourceResult.sourcePath);
294
+ agents = { ...cliAgents, ...sourceAgents };
295
+ }
296
+ const mergeResult = await buildAndMergeConfig(wizardResult, sourceResult, projectDir, sourceFlag);
297
+ const finalConfig = mergeResult.config;
298
+ const isProjectContext = fs.realpathSync(projectDir) !== fs.realpathSync(os4.homedir());
299
+ if (isProjectContext) {
300
+ await ensureBlankGlobalConfig();
301
+ }
302
+ await writeScopedConfigs(
303
+ finalConfig,
304
+ sourceResult.matrix,
305
+ agents,
306
+ projectDir,
307
+ projectPaths.configPath,
308
+ isProjectContext
309
+ );
310
+ return {
311
+ config: finalConfig,
312
+ configPath: projectPaths.configPath,
313
+ wasMerged: mergeResult.merged,
314
+ existingConfigPath: mergeResult.existingConfigPath,
315
+ filesWritten: isProjectContext ? 4 : 2
316
+ };
317
+ }
318
+
319
+ // src/cli/lib/operations/compile-agents.ts
320
+ init_esm_shims();
321
+ async function compileAgents(options) {
322
+ let resolvedAgents = options.agents;
323
+ let resolvedAgentScopeMap = options.agentScopeMap;
324
+ if (options.scopeFilter) {
325
+ const loadedConfig = await loadProjectConfigFromDir(options.projectDir);
326
+ if (!resolvedAgentScopeMap && loadedConfig?.config) {
327
+ resolvedAgentScopeMap = buildAgentScopeMap(loadedConfig.config);
328
+ }
329
+ const filteredAgents = loadedConfig?.config?.agents?.filter((a) => a.scope === options.scopeFilter).map((a) => a.name);
330
+ if (resolvedAgents && filteredAgents) {
331
+ const filterSet = new Set(filteredAgents);
332
+ resolvedAgents = resolvedAgents.filter((a) => filterSet.has(a));
333
+ } else if (filteredAgents) {
334
+ resolvedAgents = filteredAgents;
335
+ }
336
+ }
337
+ const recompileResult = await recompileAgents({
338
+ pluginDir: options.pluginDir ?? options.projectDir,
339
+ sourcePath: options.sourcePath,
340
+ agents: resolvedAgents,
341
+ skills: options.skills,
342
+ projectDir: options.projectDir,
343
+ outputDir: options.outputDir,
344
+ installMode: options.installMode,
345
+ agentScopeMap: resolvedAgentScopeMap
346
+ });
347
+ return {
348
+ compiled: recompileResult.compiled,
349
+ failed: recompileResult.failed,
350
+ warnings: recompileResult.warnings
351
+ };
352
+ }
353
+
354
+ // src/cli/lib/operations/discover-skills.ts
355
+ init_esm_shims();
356
+ import os5 from "os";
357
+ import path3 from "path";
358
+ async function loadSkillsFromDir(skillsDir, pathPrefix = "") {
359
+ const skills = {};
360
+ if (!await directoryExists(skillsDir)) {
361
+ return skills;
362
+ }
363
+ const skillFiles = await glob("**/SKILL.md", skillsDir);
364
+ for (const skillFile of skillFiles) {
365
+ const skillPath = path3.join(skillsDir, skillFile);
366
+ const skillDir = path3.dirname(skillPath);
367
+ const relativePath = path3.relative(skillsDir, skillDir);
368
+ const skillDirName = path3.basename(skillDir);
369
+ const metadataPath = path3.join(skillDir, STANDARD_FILES.METADATA_YAML);
370
+ if (!await fileExists(metadataPath)) {
371
+ const displayPath = pathPrefix ? `${pathPrefix}/${relativePath}/` : `${relativePath}/`;
372
+ warn(
373
+ `Skill '${skillDirName}' in '${displayPath}' is missing ${STANDARD_FILES.METADATA_YAML} \u2014 skipped. Add ${STANDARD_FILES.METADATA_YAML} to register it with the CLI.`
374
+ );
375
+ continue;
376
+ }
377
+ try {
378
+ const content = await readFile(skillPath);
379
+ const frontmatter = parseFrontmatter(content, skillPath);
380
+ if (!frontmatter?.name) {
381
+ warn(`Skipping skill in '${skillDirName}': missing or invalid frontmatter name`);
382
+ continue;
383
+ }
384
+ const canonicalId = frontmatter.name;
385
+ const skill = {
386
+ id: canonicalId,
387
+ path: pathPrefix ? `${pathPrefix}/${relativePath}/` : `${relativePath}/`,
388
+ description: frontmatter?.description || ""
389
+ };
390
+ skills[canonicalId] = skill;
391
+ verbose(` Loaded skill: ${canonicalId}`);
392
+ } catch (error) {
393
+ verbose(` Failed to load skill: ${skillFile} - ${error}`);
394
+ }
395
+ }
396
+ return skills;
397
+ }
398
+ async function discoverLocalProjectSkills(projectDir) {
399
+ const localSkillsDir = path3.join(projectDir, LOCAL_SKILLS_PATH);
400
+ return loadSkillsFromDir(localSkillsDir, LOCAL_SKILLS_PATH);
401
+ }
402
+ function mergeSkills(...skillSources) {
403
+ const merged = {};
404
+ for (const source of skillSources) {
405
+ for (const [id, skill] of typedEntries(source)) {
406
+ if (skill) {
407
+ merged[id] = skill;
408
+ }
409
+ }
410
+ }
411
+ return merged;
412
+ }
413
+ async function discoverInstalledSkills(projectDir) {
414
+ const isGlobalProject = projectDir === os5.homedir();
415
+ const globalPluginSkills = isGlobalProject ? {} : await discoverAllPluginSkills(os5.homedir());
416
+ const globalPluginSkillCount = typedKeys(globalPluginSkills).length;
417
+ if (globalPluginSkillCount > 0) {
418
+ verbose(` Found ${globalPluginSkillCount} skills from global plugins`);
419
+ }
420
+ const globalLocalSkillsDir = path3.join(GLOBAL_INSTALL_ROOT, LOCAL_SKILLS_PATH);
421
+ const globalLocalSkills = isGlobalProject ? {} : await loadSkillsFromDir(globalLocalSkillsDir, LOCAL_SKILLS_PATH);
422
+ const globalLocalSkillCount = typedKeys(globalLocalSkills).length;
423
+ if (globalLocalSkillCount > 0) {
424
+ verbose(` Found ${globalLocalSkillCount} global local skills from ~/.claude/skills/`);
425
+ }
426
+ const pluginSkills = await discoverAllPluginSkills(projectDir);
427
+ const pluginSkillCount = typedKeys(pluginSkills).length;
428
+ verbose(` Found ${pluginSkillCount} skills from installed plugins`);
429
+ const localSkills = await discoverLocalProjectSkills(projectDir);
430
+ const localSkillCount = typedKeys(localSkills).length;
431
+ verbose(` Found ${localSkillCount} local skills from .claude/skills/`);
432
+ const allSkills = mergeSkills(globalPluginSkills, globalLocalSkills, pluginSkills, localSkills);
433
+ const totalSkillCount = typedKeys(allSkills).length;
434
+ return {
435
+ allSkills,
436
+ totalSkillCount,
437
+ pluginSkillCount: globalPluginSkillCount + pluginSkillCount,
438
+ localSkillCount: globalLocalSkillCount + localSkillCount,
439
+ globalPluginSkillCount,
440
+ globalLocalSkillCount
441
+ };
442
+ }
443
+
444
+ // src/cli/lib/operations/find-skill-match.ts
445
+ init_esm_shims();
446
+ function findSkillMatch(skillName, results) {
447
+ const exact = results.find((r) => r.id === skillName);
448
+ if (exact) return { match: exact, similar: [] };
449
+ const partial = results.find((r) => {
450
+ const nameWithoutAuthor = r.id.replace(/\s*\(@\w+\)$/, "").toLowerCase();
451
+ return nameWithoutAuthor === skillName.toLowerCase();
452
+ });
453
+ if (partial) return { match: partial, similar: [] };
454
+ const byDir = results.find((r) => r.dirName.toLowerCase() === skillName.toLowerCase());
455
+ if (byDir) return { match: byDir, similar: [] };
456
+ const lowered = skillName.toLowerCase();
457
+ const similar = results.filter((r) => {
458
+ const name = r.id.toLowerCase();
459
+ const dir = r.dirName.toLowerCase();
460
+ return name.includes(lowered) || dir.includes(lowered) || lowered.includes(name.split(" ")[0]);
461
+ }).map((r) => r.id).slice(0, 3);
462
+ return { match: null, similar };
463
+ }
464
+
465
+ // src/cli/lib/operations/resolve-skill-info.ts
466
+ init_esm_shims();
467
+ import path4 from "path";
468
+ var CONTENT_PREVIEW_LINES = 10;
469
+ var MAX_LINE_LENGTH = 80;
470
+ var MAX_SUGGESTIONS = 5;
471
+ function stripFrontmatter(content) {
472
+ const lines = content.split("\n");
473
+ let inFrontmatter = false;
474
+ let frontmatterEndIndex = 0;
475
+ for (let i = 0; i < lines.length; i++) {
476
+ const line = lines[i].trim();
477
+ if (line === "---") {
478
+ if (!inFrontmatter) {
479
+ inFrontmatter = true;
480
+ } else {
481
+ frontmatterEndIndex = i + 1;
482
+ break;
483
+ }
484
+ }
485
+ }
486
+ return lines.slice(frontmatterEndIndex).join("\n");
487
+ }
488
+ function getPreviewLines(content, maxLines) {
489
+ const body = stripFrontmatter(content);
490
+ const lines = body.split("\n");
491
+ const result = [];
492
+ for (const line of lines) {
493
+ if (result.length >= maxLines) break;
494
+ if (line.trim() || result.length > 0) {
495
+ result.push(truncateText(line, MAX_LINE_LENGTH));
496
+ }
497
+ }
498
+ return result;
499
+ }
500
+ function findSuggestions(skills, query, maxSuggestions) {
501
+ const lowerQuery = query.toLowerCase();
502
+ const matches = [];
503
+ for (const skill of Object.values(skills)) {
504
+ if (!skill) continue;
505
+ if (matches.length >= maxSuggestions) break;
506
+ if (skill.id.toLowerCase().includes(lowerQuery) || skill.displayName.toLowerCase().includes(lowerQuery) || skill.slug.toLowerCase().includes(lowerQuery)) {
507
+ matches.push(skill.id);
508
+ }
509
+ }
510
+ return matches;
511
+ }
512
+ async function resolveSkillInfo(options) {
513
+ const { query, skills, slugToId, projectDir, sourcePath, isLocal, includePreview } = options;
514
+ const slugResolvedId = slugToId[query];
515
+ const skill = skills[query] ?? (slugResolvedId ? skills[slugResolvedId] : void 0);
516
+ if (!skill) {
517
+ const suggestions = findSuggestions(skills, query, MAX_SUGGESTIONS);
518
+ return { resolved: null, suggestions };
519
+ }
520
+ const localSkillsResult = await discoverLocalSkills(projectDir);
521
+ const localSkillIds = localSkillsResult?.skills.map((s) => s.id) || [];
522
+ const isInstalled = localSkillIds.includes(skill.id);
523
+ let preview = [];
524
+ if (includePreview) {
525
+ let skillMdPath;
526
+ if (skill.local && skill.localPath) {
527
+ skillMdPath = path4.join(projectDir, skill.localPath, STANDARD_FILES.SKILL_MD);
528
+ } else {
529
+ const sourceDir = isLocal ? sourcePath : path4.dirname(sourcePath);
530
+ skillMdPath = path4.join(sourceDir, skill.path, STANDARD_FILES.SKILL_MD);
531
+ }
532
+ if (await fileExists(skillMdPath)) {
533
+ const content = await readFile(skillMdPath);
534
+ preview = getPreviewLines(content, CONTENT_PREVIEW_LINES);
535
+ }
536
+ }
537
+ return {
538
+ resolved: { skill, isInstalled, preview },
539
+ suggestions: []
540
+ };
541
+ }
542
+
543
+ // src/cli/lib/operations/index.ts
544
+ init_esm_shims();
545
+
546
+ export {
547
+ detectBothInstallations,
548
+ loadSource,
549
+ detectProject,
550
+ loadAgentDefs,
551
+ copyLocalSkills,
552
+ installPluginSkills,
553
+ uninstallPluginSkills,
554
+ collectScopedSkillDirs,
555
+ buildSourceSkillsMap,
556
+ compareSkillsWithSource,
557
+ ensureMarketplace,
558
+ writeProjectConfig,
559
+ compileAgents,
560
+ discoverInstalledSkills,
561
+ findSkillMatch,
562
+ resolveSkillInfo
563
+ };
564
+ //# sourceMappingURL=chunk-LHUK5L6P.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/cli/lib/operations/detect-both-installations.ts","../src/cli/lib/operations/load-source.ts","../src/cli/lib/operations/detect-project.ts","../src/cli/lib/operations/load-agent-defs.ts","../src/cli/lib/operations/copy-local-skills.ts","../src/cli/lib/operations/install-plugin-skills.ts","../src/cli/lib/operations/uninstall-plugin-skills.ts","../src/cli/lib/operations/collect-scoped-skill-dirs.ts","../src/cli/lib/operations/compare-skills.ts","../src/cli/lib/operations/ensure-marketplace.ts","../src/cli/lib/operations/write-project-config.ts","../src/cli/lib/operations/compile-agents.ts","../src/cli/lib/operations/discover-skills.ts","../src/cli/lib/operations/find-skill-match.ts","../src/cli/lib/operations/resolve-skill-info.ts","../src/cli/lib/operations/index.ts"],"sourcesContent":["import os from \"os\";\nimport {\n detectGlobalInstallation,\n detectProjectInstallation,\n type Installation,\n} from \"../installation/index.js\";\n\nexport type BothInstallations = {\n global: Installation | null;\n project: Installation | null;\n hasBoth: boolean;\n};\n\n/**\n * Detects both global and project installations.\n *\n * Skips project detection when projectDir is the home directory\n * to avoid double-compile. Returns a convenience `hasBoth` flag\n * used by callers to set scopeFilter on compile passes.\n */\nexport async function detectBothInstallations(projectDir: string): Promise<BothInstallations> {\n const global = await detectGlobalInstallation();\n const project = projectDir === os.homedir() ? null : await detectProjectInstallation(projectDir);\n return { global, project, hasBoth: !!global && !!project };\n}\n","import { loadSkillsMatrixFromSource, type SourceLoadResult } from \"../loading/index.js\";\nimport {\n enableBuffering,\n drainBuffer,\n disableBuffering,\n type StartupMessage,\n} from \"../../utils/logger.js\";\n\nexport type LoadSourceOptions = {\n sourceFlag?: string;\n projectDir: string;\n forceRefresh?: boolean;\n /** When true, enables message buffering and captures startup messages. Default: false. */\n captureStartupMessages?: boolean;\n};\n\nexport type LoadedSource = {\n sourceResult: SourceLoadResult;\n /** Empty array when captureStartupMessages is false. */\n startupMessages: StartupMessage[];\n};\n\n/**\n * Loads the skills matrix from a resolved source.\n *\n * When `captureStartupMessages` is true, wraps the load in buffer mode so\n * warn() calls during loading are captured instead of written to stderr.\n * The caller (init/edit) passes these messages to the Wizard's <Static> block.\n *\n * @throws {Error} If source resolution or fetching fails.\n */\nexport async function loadSource(options: LoadSourceOptions): Promise<LoadedSource> {\n const { sourceFlag, projectDir, forceRefresh, captureStartupMessages } = options;\n\n if (captureStartupMessages) {\n enableBuffering();\n }\n\n let sourceResult: SourceLoadResult;\n try {\n sourceResult = await loadSkillsMatrixFromSource({\n sourceFlag,\n projectDir,\n forceRefresh,\n });\n } catch (error) {\n if (captureStartupMessages) {\n disableBuffering();\n }\n throw error;\n }\n\n let startupMessages: StartupMessage[] = [];\n if (captureStartupMessages) {\n startupMessages = drainBuffer();\n disableBuffering();\n }\n\n return { sourceResult, startupMessages };\n}\n","import { detectInstallation, type Installation } from \"../installation/index.js\";\nimport { loadProjectConfig } from \"../configuration/index.js\";\nimport type { ProjectConfig } from \"../../types/index.js\";\n\nexport type DetectedProject = {\n installation: Installation;\n config: ProjectConfig | null;\n configPath: string | null;\n};\n\n/**\n * Detects an existing CLI installation and loads its project config.\n *\n * Uses detectInstallation() which checks project-level first, then falls back\n * to global. Returns the installation metadata plus the loaded config.\n *\n * Does NOT throw. Returns null if no installation found.\n * Commands decide how to handle null (error out, warn, etc.).\n */\nexport async function detectProject(projectDir?: string): Promise<DetectedProject | null> {\n const resolvedDir = projectDir ?? process.cwd();\n const installation = await detectInstallation(resolvedDir);\n\n if (!installation) {\n return null;\n }\n\n const loaded = await loadProjectConfig(installation.projectDir);\n\n return {\n installation,\n config: loaded?.config ?? null,\n configPath: loaded?.configPath ?? null,\n };\n}\n","import { getAgentDefinitions } from \"../agents/index.js\";\nimport { loadAllAgents } from \"../loading/index.js\";\nimport { PROJECT_ROOT } from \"../../consts.js\";\nimport type { AgentDefinition, AgentName, AgentSourcePaths } from \"../../types/index.js\";\n\nexport type AgentDefs = {\n /** Merged agent definitions (CLI defaults + source overrides). Source takes precedence. */\n agents: Record<AgentName, AgentDefinition>;\n /** The sourcePath used to load agent partials (for compilation). */\n sourcePath: string;\n /** Full agent source paths (agentsDir, templatesDir, sourcePath). */\n agentSourcePaths: AgentSourcePaths;\n};\n\n/**\n * Loads agent definitions from the CLI and optionally from a remote source.\n *\n * Merges CLI built-in agents with source repository agents (source overrides CLI).\n * Returns the merged definitions plus the source path for compilation.\n */\nexport async function loadAgentDefs(\n agentSource?: string,\n options?: { projectDir?: string; forceRefresh?: boolean },\n): Promise<AgentDefs> {\n const agentSourcePaths = await getAgentDefinitions(agentSource, options);\n const cliAgents = await loadAllAgents(PROJECT_ROOT);\n const sourceAgents = await loadAllAgents(agentSourcePaths.sourcePath);\n const agents: Record<AgentName, AgentDefinition> = { ...cliAgents, ...sourceAgents };\n\n return {\n agents,\n sourcePath: agentSourcePaths.sourcePath,\n agentSourcePaths,\n };\n}\n","import { resolveInstallPaths } from \"../installation/index.js\";\nimport { copySkillsToLocalFlattened, type CopiedSkill } from \"../skills/index.js\";\nimport { ensureDir } from \"../../utils/fs.js\";\nimport type { SkillConfig } from \"../../types/config.js\";\nimport type { SourceLoadResult } from \"../loading/source-loader.js\";\n\nexport type SkillCopyResult = {\n projectCopied: CopiedSkill[];\n globalCopied: CopiedSkill[];\n totalCopied: number;\n};\n\n/**\n * Copies local-source skills to their scope-appropriate directories.\n *\n * Splits skills by scope (project vs global), resolves install paths,\n * ensures directories exist, and copies from source.\n */\nexport async function copyLocalSkills(\n skills: SkillConfig[],\n projectDir: string,\n sourceResult: SourceLoadResult,\n): Promise<SkillCopyResult> {\n const projectLocalSkills = skills.filter((s) => s.scope !== \"global\");\n const globalLocalSkills = skills.filter((s) => s.scope === \"global\");\n\n const projectPaths = resolveInstallPaths(projectDir, \"project\");\n const globalPaths = resolveInstallPaths(projectDir, \"global\");\n\n let projectCopied: CopiedSkill[] = [];\n if (projectLocalSkills.length > 0) {\n await ensureDir(projectPaths.skillsDir);\n projectCopied = await copySkillsToLocalFlattened(\n projectLocalSkills.map((s) => s.id),\n projectPaths.skillsDir,\n sourceResult.matrix,\n sourceResult,\n );\n }\n\n let globalCopied: CopiedSkill[] = [];\n if (globalLocalSkills.length > 0) {\n await ensureDir(globalPaths.skillsDir);\n globalCopied = await copySkillsToLocalFlattened(\n globalLocalSkills.map((s) => s.id),\n globalPaths.skillsDir,\n sourceResult.matrix,\n sourceResult,\n );\n }\n\n return {\n projectCopied,\n globalCopied,\n totalCopied: projectCopied.length + globalCopied.length,\n };\n}\n","import { claudePluginInstall } from \"../../utils/exec.js\";\nimport { getErrorMessage } from \"../../utils/errors.js\";\nimport type { SkillId } from \"../../types/index.js\";\nimport type { SkillConfig } from \"../../types/config.js\";\n\nexport type PluginInstallResult = {\n installed: Array<{ id: SkillId; ref: string }>;\n failed: Array<{ id: SkillId; error: string }>;\n};\n\n/**\n * Installs skill plugins via the Claude CLI, routing by scope.\n *\n * For each skill, constructs the plugin ref as `{skillId}@{marketplace}`\n * and invokes `claudePluginInstall` with the correct scope.\n */\nexport async function installPluginSkills(\n skills: SkillConfig[],\n marketplace: string,\n projectDir: string,\n): Promise<PluginInstallResult> {\n const pluginSkills = skills.filter((s) => s.source !== \"local\");\n const installed: PluginInstallResult[\"installed\"] = [];\n const failed: PluginInstallResult[\"failed\"] = [];\n\n for (const skill of pluginSkills) {\n const pluginRef = `${skill.id}@${marketplace}`;\n const pluginScope = skill.scope === \"global\" ? \"user\" : \"project\";\n try {\n await claudePluginInstall(pluginRef, pluginScope, projectDir);\n installed.push({ id: skill.id, ref: pluginRef });\n } catch (error) {\n failed.push({ id: skill.id, error: getErrorMessage(error) });\n }\n }\n\n return { installed, failed };\n}\n","import { claudePluginUninstall } from \"../../utils/exec.js\";\nimport { getErrorMessage } from \"../../utils/errors.js\";\nimport type { SkillId } from \"../../types/index.js\";\nimport type { SkillConfig } from \"../../types/config.js\";\n\nexport type PluginUninstallResult = {\n uninstalled: SkillId[];\n failed: Array<{ id: SkillId; error: string }>;\n};\n\n/**\n * Uninstalls skill plugins via the Claude CLI, using scope from old config.\n */\nexport async function uninstallPluginSkills(\n skillIds: SkillId[],\n oldSkills: SkillConfig[],\n projectDir: string,\n): Promise<PluginUninstallResult> {\n const uninstalled: SkillId[] = [];\n const failed: PluginUninstallResult[\"failed\"] = [];\n\n for (const skillId of skillIds) {\n const oldSkill = oldSkills.find((s) => s.id === skillId);\n const pluginScope = oldSkill?.scope === \"global\" ? \"user\" : \"project\";\n try {\n await claudePluginUninstall(skillId, pluginScope, projectDir);\n uninstalled.push(skillId);\n } catch (error) {\n failed.push({ id: skillId, error: getErrorMessage(error) });\n }\n }\n\n return { uninstalled, failed };\n}\n","import os from \"os\";\nimport path from \"path\";\nimport { fileExists, listDirectories } from \"../../utils/fs.js\";\nimport { LOCAL_SKILLS_PATH } from \"../../consts.js\";\n\nexport type ScopedSkillDir = {\n dirName: string;\n localSkillsPath: string;\n scope: \"project\" | \"global\";\n};\n\nexport type ScopedSkillDirsResult = {\n dirs: ScopedSkillDir[];\n hasProject: boolean;\n hasGlobal: boolean;\n projectLocalPath: string;\n globalLocalPath: string;\n};\n\n/**\n * Collects local skill directories from both project and global scopes.\n * Project-scoped dirs take precedence over global on name conflict.\n *\n * @returns directories with scope annotations, plus path/existence metadata\n */\nexport async function collectScopedSkillDirs(projectDir: string): Promise<ScopedSkillDirsResult> {\n const homeDir = os.homedir();\n const projectLocalPath = path.join(projectDir, LOCAL_SKILLS_PATH);\n const globalLocalPath = path.join(homeDir, LOCAL_SKILLS_PATH);\n const hasProject = await fileExists(projectLocalPath);\n const hasGlobal = projectDir !== homeDir && (await fileExists(globalLocalPath));\n\n const dirs: ScopedSkillDir[] = [];\n\n if (hasProject) {\n for (const dirName of await listDirectories(projectLocalPath)) {\n dirs.push({ dirName, localSkillsPath: projectLocalPath, scope: \"project\" });\n }\n }\n\n if (hasGlobal) {\n const projectDirNames = new Set(dirs.map((d) => d.dirName));\n for (const dirName of await listDirectories(globalLocalPath)) {\n if (!projectDirNames.has(dirName)) {\n dirs.push({ dirName, localSkillsPath: globalLocalPath, scope: \"global\" });\n }\n }\n }\n\n return { dirs, hasProject, hasGlobal, projectLocalPath, globalLocalPath };\n}\n","import os from \"os\";\nimport { compareLocalSkillsWithSource, type SkillComparisonResult } from \"../skills/index.js\";\nimport { typedEntries } from \"../../utils/typed-object.js\";\nimport { collectScopedSkillDirs } from \"./collect-scoped-skill-dirs.js\";\nimport type { MergedSkillsMatrix } from \"../../types/index.js\";\n\nexport type SkillComparisonResults = {\n projectResults: SkillComparisonResult[];\n globalResults: SkillComparisonResult[];\n /** Merged results with project taking precedence over global. */\n merged: SkillComparisonResult[];\n};\n\n/**\n * Builds a map of source skill IDs to their paths, excluding local-only skills.\n * Used by both compareSkillsWithSource and diff command.\n */\nexport function buildSourceSkillsMap(matrix: MergedSkillsMatrix): Record<string, { path: string }> {\n const sourceSkills: Record<string, { path: string }> = {};\n for (const [skillId, skill] of typedEntries(matrix.skills)) {\n if (!skill) continue;\n if (!skill.local) {\n sourceSkills[skillId] = { path: skill.path };\n }\n }\n return sourceSkills;\n}\n\n/**\n * Compares local skills (project + global scope) against their source versions.\n *\n * Builds a source skills map from the matrix (excluding local-only skills),\n * runs compareLocalSkillsWithSource for both project and global scopes,\n * and merges results with project taking precedence.\n */\nexport async function compareSkillsWithSource(\n projectDir: string,\n sourcePath: string,\n matrix: MergedSkillsMatrix,\n): Promise<SkillComparisonResults> {\n const sourceSkills = buildSourceSkillsMap(matrix);\n\n const { hasProject, hasGlobal } = await collectScopedSkillDirs(projectDir);\n const homeDir = os.homedir();\n\n const projectResults = hasProject\n ? await compareLocalSkillsWithSource(projectDir, sourcePath, sourceSkills)\n : [];\n\n const globalResults = hasGlobal\n ? await compareLocalSkillsWithSource(homeDir, sourcePath, sourceSkills)\n : [];\n\n const seenIds = new Set(projectResults.map((r) => r.id));\n const merged = [...projectResults, ...globalResults.filter((r) => !seenIds.has(r.id))];\n\n return { projectResults, globalResults, merged };\n}\n","import {\n claudePluginMarketplaceExists,\n claudePluginMarketplaceAdd,\n claudePluginMarketplaceUpdate,\n} from \"../../utils/exec.js\";\nimport { fetchMarketplace } from \"../loading/index.js\";\nimport { warn } from \"../../utils/logger.js\";\nimport type { SourceLoadResult } from \"../loading/source-loader.js\";\n\nexport type MarketplaceResult = {\n /** The resolved marketplace name, or null if no marketplace is configured. */\n marketplace: string | null;\n /** Whether a new marketplace was registered (vs. updated or already existed). */\n registered: boolean;\n};\n\n/**\n * Ensures the marketplace is registered with the Claude CLI.\n *\n * If the marketplace does not exist, registers it. If it exists, updates it.\n * Handles lazy marketplace name resolution when sourceResult.marketplace is undefined.\n *\n * Operation is intentionally SILENT — commands decide what to log based on the\n * `registered` flag.\n */\nexport async function ensureMarketplace(\n sourceResult: SourceLoadResult,\n): Promise<MarketplaceResult> {\n if (!sourceResult.marketplace) {\n try {\n const marketplaceResult = await fetchMarketplace(sourceResult.sourceConfig.source, {});\n sourceResult.marketplace = marketplaceResult.marketplace.name;\n } catch {\n return { marketplace: null, registered: false };\n }\n }\n\n const marketplace = sourceResult.marketplace;\n const exists = await claudePluginMarketplaceExists(marketplace);\n\n if (!exists) {\n const marketplaceSource = sourceResult.sourceConfig.source.replace(/^github:/, \"\");\n await claudePluginMarketplaceAdd(marketplaceSource);\n return { marketplace, registered: true };\n }\n\n try {\n await claudePluginMarketplaceUpdate(marketplace);\n } catch {\n warn(\"Could not update marketplace — continuing with cached version\");\n }\n\n return { marketplace, registered: false };\n}\n","import fs from \"fs\";\nimport os from \"os\";\nimport path from \"path\";\nimport {\n buildAndMergeConfig,\n writeScopedConfigs,\n resolveInstallPaths,\n} from \"../installation/index.js\";\nimport { loadAllAgents, type SourceLoadResult } from \"../loading/index.js\";\nimport { ensureBlankGlobalConfig } from \"../configuration/config-writer.js\";\nimport { ensureDir } from \"../../utils/fs.js\";\nimport { PROJECT_ROOT } from \"../../consts.js\";\nimport type { ProjectConfig, AgentDefinition, AgentName } from \"../../types/index.js\";\nimport type { WizardResultV2 } from \"../../components/wizard/wizard.js\";\n\nexport type ConfigWriteOptions = {\n wizardResult: WizardResultV2;\n sourceResult: SourceLoadResult;\n projectDir: string;\n sourceFlag?: string;\n /** Pre-loaded agent definitions. If omitted, loads from CLI + source. */\n agents?: Record<AgentName, AgentDefinition>;\n};\n\nexport type ConfigWriteResult = {\n config: ProjectConfig;\n configPath: string;\n globalConfigPath?: string;\n wasMerged: boolean;\n existingConfigPath?: string;\n filesWritten: number;\n};\n\n/**\n * Builds, merges, and writes project configuration files.\n *\n * Handles the full config pipeline:\n * 1. buildAndMergeConfig() — generates config from wizard result, merges with existing\n * 2. loadAllAgents() — loads agent definitions for config-types generation\n * 3. ensureBlankGlobalConfig() — ensures global config exists (when in project context)\n * 4. writeScopedConfigs() — writes config.ts and config-types.ts split by scope\n */\nexport async function writeProjectConfig(options: ConfigWriteOptions): Promise<ConfigWriteResult> {\n const { wizardResult, sourceResult, projectDir, sourceFlag } = options;\n const projectPaths = resolveInstallPaths(projectDir, \"project\");\n\n await ensureDir(path.dirname(projectPaths.configPath));\n\n let agents: Record<AgentName, AgentDefinition>;\n if (options.agents) {\n agents = options.agents;\n } else {\n const cliAgents = await loadAllAgents(PROJECT_ROOT);\n const sourceAgents = await loadAllAgents(sourceResult.sourcePath);\n agents = { ...cliAgents, ...sourceAgents };\n }\n\n const mergeResult = await buildAndMergeConfig(wizardResult, sourceResult, projectDir, sourceFlag);\n const finalConfig = mergeResult.config;\n\n const isProjectContext = fs.realpathSync(projectDir) !== fs.realpathSync(os.homedir());\n\n if (isProjectContext) {\n await ensureBlankGlobalConfig();\n }\n\n await writeScopedConfigs(\n finalConfig,\n sourceResult.matrix,\n agents,\n projectDir,\n projectPaths.configPath,\n isProjectContext,\n );\n\n return {\n config: finalConfig,\n configPath: projectPaths.configPath,\n wasMerged: mergeResult.merged,\n existingConfigPath: mergeResult.existingConfigPath,\n filesWritten: isProjectContext ? 4 : 2,\n };\n}\n","import { recompileAgents } from \"../agents/index.js\";\nimport { loadProjectConfigFromDir } from \"../configuration/index.js\";\nimport { buildAgentScopeMap } from \"../installation/index.js\";\nimport type { AgentName, SkillDefinitionMap } from \"../../types/index.js\";\nimport type { InstallMode } from \"../installation/index.js\";\n\nexport type CompileAgentsOptions = {\n projectDir: string;\n sourcePath: string;\n pluginDir?: string;\n skills?: SkillDefinitionMap;\n agentScopeMap?: Map<AgentName, \"project\" | \"global\">;\n agents?: AgentName[];\n /** When set, loads config and filters agents to only those matching this scope. */\n scopeFilter?: \"project\" | \"global\";\n outputDir?: string;\n installMode?: InstallMode;\n};\n\nexport type CompilationResult = {\n compiled: AgentName[];\n failed: AgentName[];\n warnings: string[];\n};\n\n/**\n * Compiles agent markdown files from templates + skill content.\n *\n * Thin wrapper around recompileAgents() that standardizes options.\n * The caller invokes this once (edit, update) or twice with scopeFilter (compile).\n */\nexport async function compileAgents(options: CompileAgentsOptions): Promise<CompilationResult> {\n let resolvedAgents = options.agents;\n let resolvedAgentScopeMap = options.agentScopeMap;\n\n if (options.scopeFilter) {\n const loadedConfig = await loadProjectConfigFromDir(options.projectDir);\n\n // Auto-build agentScopeMap from config if not provided\n if (!resolvedAgentScopeMap && loadedConfig?.config) {\n resolvedAgentScopeMap = buildAgentScopeMap(loadedConfig.config);\n }\n\n const filteredAgents = loadedConfig?.config?.agents\n ?.filter((a) => a.scope === options.scopeFilter)\n .map((a) => a.name);\n\n if (resolvedAgents && filteredAgents) {\n const filterSet = new Set(filteredAgents);\n resolvedAgents = resolvedAgents.filter((a) => filterSet.has(a));\n } else if (filteredAgents) {\n resolvedAgents = filteredAgents;\n }\n }\n\n const recompileResult = await recompileAgents({\n pluginDir: options.pluginDir ?? options.projectDir,\n sourcePath: options.sourcePath,\n agents: resolvedAgents,\n skills: options.skills,\n projectDir: options.projectDir,\n outputDir: options.outputDir,\n installMode: options.installMode,\n agentScopeMap: resolvedAgentScopeMap,\n });\n\n return {\n compiled: recompileResult.compiled,\n failed: recompileResult.failed,\n warnings: recompileResult.warnings,\n };\n}\n","import os from \"os\";\nimport path from \"path\";\nimport { discoverAllPluginSkills } from \"../plugins/index.js\";\nimport { directoryExists, glob, readFile, fileExists } from \"../../utils/fs.js\";\nimport { parseFrontmatter } from \"../loading/index.js\";\nimport { verbose, warn } from \"../../utils/logger.js\";\nimport { GLOBAL_INSTALL_ROOT, LOCAL_SKILLS_PATH, STANDARD_FILES } from \"../../consts.js\";\nimport { typedEntries, typedKeys } from \"../../utils/typed-object.js\";\nimport type { SkillDefinition, SkillDefinitionMap, SkillId } from \"../../types/index.js\";\n\nexport type DiscoveredSkills = {\n allSkills: SkillDefinitionMap;\n totalSkillCount: number;\n pluginSkillCount: number;\n localSkillCount: number;\n globalPluginSkillCount: number;\n globalLocalSkillCount: number;\n};\n\n/**\n * Loads SKILL.md files from a directory, parsing frontmatter for skill metadata.\n * Returns a map of skillId -> SkillDefinition.\n */\nexport async function loadSkillsFromDir(\n skillsDir: string,\n pathPrefix = \"\",\n): Promise<SkillDefinitionMap> {\n const skills: SkillDefinitionMap = {};\n\n if (!(await directoryExists(skillsDir))) {\n return skills;\n }\n\n const skillFiles = await glob(\"**/SKILL.md\", skillsDir);\n\n for (const skillFile of skillFiles) {\n const skillPath = path.join(skillsDir, skillFile);\n const skillDir = path.dirname(skillPath);\n const relativePath = path.relative(skillsDir, skillDir);\n const skillDirName = path.basename(skillDir);\n\n const metadataPath = path.join(skillDir, STANDARD_FILES.METADATA_YAML);\n if (!(await fileExists(metadataPath))) {\n const displayPath = pathPrefix ? `${pathPrefix}/${relativePath}/` : `${relativePath}/`;\n warn(\n `Skill '${skillDirName}' in '${displayPath}' is missing ${STANDARD_FILES.METADATA_YAML} — skipped. Add ${STANDARD_FILES.METADATA_YAML} to register it with the CLI.`,\n );\n continue;\n }\n\n try {\n const content = await readFile(skillPath);\n const frontmatter = parseFrontmatter(content, skillPath);\n\n if (!frontmatter?.name) {\n warn(`Skipping skill in '${skillDirName}': missing or invalid frontmatter name`);\n continue;\n }\n\n const canonicalId = frontmatter.name;\n\n const skill: SkillDefinition = {\n id: canonicalId,\n path: pathPrefix ? `${pathPrefix}/${relativePath}/` : `${relativePath}/`,\n description: frontmatter?.description || \"\",\n };\n\n skills[canonicalId] = skill;\n verbose(` Loaded skill: ${canonicalId}`);\n } catch (error) {\n verbose(` Failed to load skill: ${skillFile} - ${error}`);\n }\n }\n\n return skills;\n}\n\n/**\n * Discovers local project skills from the .claude/skills/ directory.\n */\nexport async function discoverLocalProjectSkills(projectDir: string): Promise<SkillDefinitionMap> {\n const localSkillsDir = path.join(projectDir, LOCAL_SKILLS_PATH);\n return loadSkillsFromDir(localSkillsDir, LOCAL_SKILLS_PATH);\n}\n\n/** Merges skill maps — later sources take precedence over earlier ones. */\nexport function mergeSkills(...skillSources: SkillDefinitionMap[]): SkillDefinitionMap {\n const merged: SkillDefinitionMap = {};\n\n for (const source of skillSources) {\n for (const [id, skill] of typedEntries<SkillId, SkillDefinition | undefined>(source)) {\n if (skill) {\n merged[id] = skill;\n }\n }\n }\n\n return merged;\n}\n\n/**\n * Discovers all installed skills for a project directory using 4-way merge:\n * 1. Global plugins (from ~/.claude/plugins/)\n * 2. Global local (from ~/.claude/skills/)\n * 3. Project plugins (from <projectDir>/.claude/plugins/)\n * 4. Project local (from <projectDir>/.claude/skills/)\n *\n * Pure function — no user-facing logging. Callers add their own log messages.\n * Uses verbose() for diagnostic output only.\n */\nexport async function discoverInstalledSkills(projectDir: string): Promise<DiscoveredSkills> {\n const isGlobalProject = projectDir === os.homedir();\n\n // 1. Global plugins\n const globalPluginSkills = isGlobalProject ? {} : await discoverAllPluginSkills(os.homedir());\n const globalPluginSkillCount = typedKeys<SkillId>(globalPluginSkills).length;\n if (globalPluginSkillCount > 0) {\n verbose(` Found ${globalPluginSkillCount} skills from global plugins`);\n }\n\n // 2. Global local skills\n const globalLocalSkillsDir = path.join(GLOBAL_INSTALL_ROOT, LOCAL_SKILLS_PATH);\n const globalLocalSkills = isGlobalProject\n ? {}\n : await loadSkillsFromDir(globalLocalSkillsDir, LOCAL_SKILLS_PATH);\n const globalLocalSkillCount = typedKeys<SkillId>(globalLocalSkills).length;\n if (globalLocalSkillCount > 0) {\n verbose(` Found ${globalLocalSkillCount} global local skills from ~/.claude/skills/`);\n }\n\n // 3. Project plugins\n const pluginSkills = await discoverAllPluginSkills(projectDir);\n const pluginSkillCount = typedKeys<SkillId>(pluginSkills).length;\n verbose(` Found ${pluginSkillCount} skills from installed plugins`);\n\n // 4. Project local skills\n const localSkills = await discoverLocalProjectSkills(projectDir);\n const localSkillCount = typedKeys<SkillId>(localSkills).length;\n verbose(` Found ${localSkillCount} local skills from .claude/skills/`);\n\n // Merge: global first, project second — project wins on conflict\n const allSkills = mergeSkills(globalPluginSkills, globalLocalSkills, pluginSkills, localSkills);\n const totalSkillCount = typedKeys<SkillId>(allSkills).length;\n\n return {\n allSkills,\n totalSkillCount,\n pluginSkillCount: globalPluginSkillCount + pluginSkillCount,\n localSkillCount: globalLocalSkillCount + localSkillCount,\n globalPluginSkillCount,\n globalLocalSkillCount,\n };\n}\n","import type { SkillComparisonResult } from \"../skills/index.js\";\n\nexport type SkillMatchResult = {\n match: SkillComparisonResult | null;\n similar: string[];\n};\n\n/**\n * Finds a skill by exact ID, partial name, or directory name.\n * Falls back to fuzzy matching and returns similar suggestions.\n */\nexport function findSkillMatch(\n skillName: string,\n results: SkillComparisonResult[],\n): SkillMatchResult {\n // Exact match by ID\n const exact = results.find((r) => r.id === skillName);\n if (exact) return { match: exact, similar: [] };\n\n // Partial match (without author suffix)\n const partial = results.find((r) => {\n const nameWithoutAuthor = r.id.replace(/\\s*\\(@\\w+\\)$/, \"\").toLowerCase();\n return nameWithoutAuthor === skillName.toLowerCase();\n });\n if (partial) return { match: partial, similar: [] };\n\n // Match by directory name\n const byDir = results.find((r) => r.dirName.toLowerCase() === skillName.toLowerCase());\n if (byDir) return { match: byDir, similar: [] };\n\n // No match — find similar suggestions\n const lowered = skillName.toLowerCase();\n const similar = results\n .filter((r) => {\n const name = r.id.toLowerCase();\n const dir = r.dirName.toLowerCase();\n return (\n name.includes(lowered) || dir.includes(lowered) || lowered.includes(name.split(\" \")[0])\n );\n })\n .map((r) => r.id)\n .slice(0, 3);\n\n return { match: null, similar };\n}\n","import path from \"path\";\nimport { fileExists, readFile } from \"../../utils/fs.js\";\nimport { discoverLocalSkills } from \"../skills/index.js\";\nimport { STANDARD_FILES } from \"../../consts.js\";\nimport type { ResolvedSkill, SkillId, SkillSlug } from \"../../types/index.js\";\nimport { truncateText } from \"../../utils/string.js\";\n\nconst CONTENT_PREVIEW_LINES = 10;\nconst MAX_LINE_LENGTH = 80;\nconst MAX_SUGGESTIONS = 5;\n\nexport type ResolvedSkillInfo = {\n skill: ResolvedSkill;\n isInstalled: boolean;\n preview: string[];\n};\n\nexport type SkillInfoResult = {\n resolved: ResolvedSkillInfo | null;\n suggestions: string[];\n};\n\nexport type ResolveSkillInfoOptions = {\n /** The skill ID, slug, or search query from user input */\n query: string;\n /** Full skills map from the loaded matrix */\n skills: Partial<Record<SkillId, ResolvedSkill>>;\n /** Slug-to-ID lookup map from the loaded matrix */\n slugToId: Partial<Record<SkillSlug, SkillId>>;\n /** Project directory for local skill discovery */\n projectDir: string;\n /** Resolved source path from loadSource */\n sourcePath: string;\n /** Whether the source is local */\n isLocal: boolean;\n /** Whether to load the content preview */\n includePreview: boolean;\n};\n\n/**\n * Strips YAML frontmatter delimiters and content from markdown.\n */\nfunction stripFrontmatter(content: string): string {\n const lines = content.split(\"\\n\");\n let inFrontmatter = false;\n let frontmatterEndIndex = 0;\n\n for (let i = 0; i < lines.length; i++) {\n const line = lines[i].trim();\n if (line === \"---\") {\n if (!inFrontmatter) {\n inFrontmatter = true;\n } else {\n frontmatterEndIndex = i + 1;\n break;\n }\n }\n }\n\n return lines.slice(frontmatterEndIndex).join(\"\\n\");\n}\n\n/**\n * Extracts the first N non-empty lines from markdown content (after frontmatter).\n */\nfunction getPreviewLines(content: string, maxLines: number): string[] {\n const body = stripFrontmatter(content);\n const lines = body.split(\"\\n\");\n const result: string[] = [];\n\n for (const line of lines) {\n if (result.length >= maxLines) break;\n if (line.trim() || result.length > 0) {\n result.push(truncateText(line, MAX_LINE_LENGTH));\n }\n }\n\n return result;\n}\n\n/**\n * Finds similar skill names for \"did you mean\" suggestions.\n */\nfunction findSuggestions(\n skills: Partial<Record<SkillId, ResolvedSkill>>,\n query: string,\n maxSuggestions: number,\n): string[] {\n const lowerQuery = query.toLowerCase();\n const matches: string[] = [];\n\n for (const skill of Object.values(skills)) {\n if (!skill) continue;\n if (matches.length >= maxSuggestions) break;\n if (\n skill.id.toLowerCase().includes(lowerQuery) ||\n skill.displayName.toLowerCase().includes(lowerQuery) ||\n skill.slug.toLowerCase().includes(lowerQuery)\n ) {\n matches.push(skill.id);\n }\n }\n\n return matches;\n}\n\n/**\n * Resolves complete skill information for display.\n *\n * Looks up the skill by ID or slug, discovers local installation status,\n * and optionally loads a content preview from SKILL.md.\n */\nexport async function resolveSkillInfo(options: ResolveSkillInfoOptions): Promise<SkillInfoResult> {\n const { query, skills, slugToId, projectDir, sourcePath, isLocal, includePreview } = options;\n\n // CLI arg is an untyped string — try as skill ID first, then as slug\n const slugResolvedId = slugToId[query as SkillSlug];\n const skill = skills[query as SkillId] ?? (slugResolvedId ? skills[slugResolvedId] : undefined);\n\n if (!skill) {\n const suggestions = findSuggestions(skills, query, MAX_SUGGESTIONS);\n return { resolved: null, suggestions };\n }\n\n const localSkillsResult = await discoverLocalSkills(projectDir);\n const localSkillIds = localSkillsResult?.skills.map((s) => s.id) || [];\n const isInstalled = localSkillIds.includes(skill.id);\n\n let preview: string[] = [];\n if (includePreview) {\n let skillMdPath: string;\n\n if (skill.local && skill.localPath) {\n skillMdPath = path.join(projectDir, skill.localPath, STANDARD_FILES.SKILL_MD);\n } else {\n const sourceDir = isLocal ? sourcePath : path.dirname(sourcePath);\n skillMdPath = path.join(sourceDir, skill.path, STANDARD_FILES.SKILL_MD);\n }\n\n if (await fileExists(skillMdPath)) {\n const content = await readFile(skillMdPath);\n preview = getPreviewLines(content, CONTENT_PREVIEW_LINES);\n }\n }\n\n return {\n resolved: { skill, isInstalled, preview },\n suggestions: [],\n };\n}\n","// Operations — composable building blocks for CLI commands.\n// Each operation wraps lower-level lib functions into a single typed call.\n\nexport { detectBothInstallations, type BothInstallations } from \"./detect-both-installations.js\";\nexport { loadSource, type LoadSourceOptions, type LoadedSource } from \"./load-source.js\";\nexport { detectProject, type DetectedProject } from \"./detect-project.js\";\nexport { loadAgentDefs, type AgentDefs } from \"./load-agent-defs.js\";\nexport { copyLocalSkills, type SkillCopyResult } from \"./copy-local-skills.js\";\nexport { installPluginSkills, type PluginInstallResult } from \"./install-plugin-skills.js\";\nexport { uninstallPluginSkills, type PluginUninstallResult } from \"./uninstall-plugin-skills.js\";\nexport {\n compareSkillsWithSource,\n buildSourceSkillsMap,\n type SkillComparisonResults,\n} from \"./compare-skills.js\";\nexport { ensureMarketplace, type MarketplaceResult } from \"./ensure-marketplace.js\";\nexport {\n writeProjectConfig,\n type ConfigWriteOptions,\n type ConfigWriteResult,\n} from \"./write-project-config.js\";\nexport {\n compileAgents,\n type CompileAgentsOptions,\n type CompilationResult,\n} from \"./compile-agents.js\";\nexport {\n executeInstallation,\n type ExecuteInstallationOptions,\n type ExecuteInstallationResult,\n} from \"./execute-installation.js\";\nexport {\n recompileProject,\n type RecompileProjectOptions,\n type RecompileProjectResult,\n} from \"./recompile-project.js\";\nexport {\n discoverInstalledSkills,\n loadSkillsFromDir,\n discoverLocalProjectSkills,\n mergeSkills,\n type DiscoveredSkills,\n} from \"./discover-skills.js\";\nexport {\n collectScopedSkillDirs,\n type ScopedSkillDir,\n type ScopedSkillDirsResult,\n} from \"./collect-scoped-skill-dirs.js\";\nexport { findSkillMatch, type SkillMatchResult } from \"./find-skill-match.js\";\nexport {\n resolveSkillInfo,\n type ResolveSkillInfoOptions,\n type ResolvedSkillInfo,\n type SkillInfoResult,\n} from \"./resolve-skill-info.js\";\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA,OAAO,QAAQ;AAoBf,eAAsB,wBAAwB,YAAgD;AAC5F,QAAM,SAAS,MAAM,yBAAyB;AAC9C,QAAM,UAAU,eAAe,GAAG,QAAQ,IAAI,OAAO,MAAM,0BAA0B,UAAU;AAC/F,SAAO,EAAE,QAAQ,SAAS,SAAS,CAAC,CAAC,UAAU,CAAC,CAAC,QAAQ;AAC3D;;;ACxBA;AA+BA,eAAsB,WAAW,SAAmD;AAClF,QAAM,EAAE,YAAY,YAAY,cAAc,uBAAuB,IAAI;AAEzE,MAAI,wBAAwB;AAC1B,oBAAgB;AAAA,EAClB;AAEA,MAAI;AACJ,MAAI;AACF,mBAAe,MAAM,2BAA2B;AAAA,MAC9C;AAAA,MACA;AAAA,MACA;AAAA,IACF,CAAC;AAAA,EACH,SAAS,OAAO;AACd,QAAI,wBAAwB;AAC1B,uBAAiB;AAAA,IACnB;AACA,UAAM;AAAA,EACR;AAEA,MAAI,kBAAoC,CAAC;AACzC,MAAI,wBAAwB;AAC1B,sBAAkB,YAAY;AAC9B,qBAAiB;AAAA,EACnB;AAEA,SAAO,EAAE,cAAc,gBAAgB;AACzC;;;AC3DA;AAmBA,eAAsB,cAAc,YAAsD;AACxF,QAAM,cAAc,cAAc,QAAQ,IAAI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