@agents-inc/cli 0.86.0 → 0.87.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +10 -0
- package/dist/chunk-5UJJQFET.js +564 -0
- package/dist/chunk-5UJJQFET.js.map +1 -0
- package/dist/{chunk-GED2F75H.js → chunk-7FFNNDJQ.js} +176 -120
- package/dist/chunk-7FFNNDJQ.js.map +1 -0
- package/dist/{chunk-BV2MIQ3O.js → chunk-I5AZKNNL.js} +1 -1
- package/dist/chunk-I5AZKNNL.js.map +1 -0
- package/dist/chunk-J6PI73YV.js +68 -0
- package/dist/chunk-J6PI73YV.js.map +1 -0
- package/dist/commands/compile.js +26 -20
- package/dist/commands/compile.js.map +1 -1
- package/dist/commands/diff.js +681 -82
- package/dist/commands/diff.js.map +1 -1
- package/dist/commands/doctor.js +30 -58
- package/dist/commands/doctor.js.map +1 -1
- package/dist/commands/edit.js +164 -32
- package/dist/commands/edit.js.map +1 -1
- package/dist/commands/eject.js +177 -27
- package/dist/commands/eject.js.map +1 -1
- package/dist/commands/import/skill.js +197 -33
- package/dist/commands/import/skill.js.map +1 -1
- package/dist/commands/info.js +41 -34
- package/dist/commands/info.js.map +1 -1
- package/dist/commands/init.js +3 -6
- package/dist/commands/new/agent.js +140 -44
- package/dist/commands/new/agent.js.map +1 -1
- package/dist/commands/new/marketplace.js +4 -4
- package/dist/commands/new/marketplace.js.map +1 -1
- package/dist/commands/new/skill.js +194 -30
- package/dist/commands/new/skill.js.map +1 -1
- package/dist/commands/outdated.js +1 -3
- package/dist/commands/outdated.js.map +1 -1
- package/dist/commands/search.js +162 -65
- package/dist/commands/search.js.map +1 -1
- package/dist/commands/uninstall.js +259 -62
- package/dist/commands/uninstall.js.map +1 -1
- package/dist/commands/update.js +232 -163
- package/dist/commands/update.js.map +1 -1
- package/dist/components/skill-search/skill-search.js +1 -1
- package/dist/hooks/init.js +2 -4
- package/dist/hooks/init.js.map +1 -1
- package/package.json +1 -1
- package/dist/chunk-BV2MIQ3O.js.map +0 -1
- package/dist/chunk-DCVCFBQ7.js +0 -1800
- package/dist/chunk-DCVCFBQ7.js.map +0 -1
- package/dist/chunk-GED2F75H.js.map +0 -1
- package/dist/chunk-O5ZWS26C.js +0 -166
- package/dist/chunk-O5ZWS26C.js.map +0 -1
- package/dist/chunk-XQK4S22C.js +0 -202
- package/dist/chunk-XQK4S22C.js.map +0 -1
package/dist/commands/edit.js
CHANGED
|
@@ -40,21 +40,20 @@ import {
|
|
|
40
40
|
import {
|
|
41
41
|
compileAgents,
|
|
42
42
|
copyLocalSkills,
|
|
43
|
-
detectConfigChanges,
|
|
44
43
|
detectProject,
|
|
44
|
+
discoverInstalledSkills,
|
|
45
45
|
ensureMarketplace,
|
|
46
46
|
installPluginSkills,
|
|
47
47
|
loadAgentDefs,
|
|
48
48
|
loadSource,
|
|
49
|
-
migratePluginSkillScopes,
|
|
50
49
|
uninstallPluginSkills,
|
|
51
50
|
writeProjectConfig
|
|
52
|
-
} from "../chunk-
|
|
51
|
+
} from "../chunk-5UJJQFET.js";
|
|
53
52
|
import "../chunk-N6A7A4RA.js";
|
|
54
|
-
import "../chunk-O5ZWS26C.js";
|
|
55
|
-
import "../chunk-XQK4S22C.js";
|
|
56
53
|
import "../chunk-FBZR46GC.js";
|
|
57
54
|
import {
|
|
55
|
+
claudePluginInstall,
|
|
56
|
+
claudePluginUninstall,
|
|
58
57
|
deleteLocalSkill,
|
|
59
58
|
deriveInstallMode,
|
|
60
59
|
detectMigrations,
|
|
@@ -127,6 +126,27 @@ var Edit = class _Edit extends BaseCommand {
|
|
|
127
126
|
async run() {
|
|
128
127
|
const { flags } = await this.parse(_Edit);
|
|
129
128
|
const cwd = process.cwd();
|
|
129
|
+
const context = await this.loadContext(flags);
|
|
130
|
+
const result = await this.runEditWizard(context, cwd);
|
|
131
|
+
if (!result) this.error("Cancelled", { exit: EXIT_CODES.CANCELLED });
|
|
132
|
+
this.reportValidationErrors(result);
|
|
133
|
+
const changes = detectConfigChanges(context.projectConfig, result, context.currentSkillIds);
|
|
134
|
+
if (!hasAnyChanges(changes)) {
|
|
135
|
+
this.log(INFO_MESSAGES.NO_CHANGES_MADE);
|
|
136
|
+
this.log("Plugin unchanged\n");
|
|
137
|
+
return;
|
|
138
|
+
}
|
|
139
|
+
this.logChangeSummary(changes);
|
|
140
|
+
const migratedSkillIds = await this.applyMigrations(changes, result, context, cwd);
|
|
141
|
+
await this.applyScopeChanges(changes, result, context, cwd);
|
|
142
|
+
await this.applySourceChanges(changes, result, context, cwd, migratedSkillIds);
|
|
143
|
+
await this.applyPluginChanges(changes, result, context, cwd);
|
|
144
|
+
await this.copyNewLocalSkills(changes, result, context, cwd);
|
|
145
|
+
await this.writeConfigAndCompile(result, context, flags, cwd);
|
|
146
|
+
await this.cleanupStaleAgentFiles(changes, cwd);
|
|
147
|
+
this.logCompletionSummary(changes);
|
|
148
|
+
}
|
|
149
|
+
async loadContext(flags) {
|
|
130
150
|
const detected = await detectProject();
|
|
131
151
|
if (!detected) {
|
|
132
152
|
this.error(ERROR_MESSAGES.NO_INSTALLATION, {
|
|
@@ -168,6 +188,17 @@ var Edit = class _Edit extends BaseCommand {
|
|
|
168
188
|
} catch (error) {
|
|
169
189
|
this.handleError(error);
|
|
170
190
|
}
|
|
191
|
+
return {
|
|
192
|
+
installation,
|
|
193
|
+
projectConfig,
|
|
194
|
+
projectDir,
|
|
195
|
+
sourceResult,
|
|
196
|
+
startupMessages,
|
|
197
|
+
currentSkillIds
|
|
198
|
+
};
|
|
199
|
+
}
|
|
200
|
+
async runEditWizard(context, cwd) {
|
|
201
|
+
const { projectConfig, projectDir, currentSkillIds } = context;
|
|
171
202
|
let wizardResult = null;
|
|
172
203
|
const isGlobalDir = cwd === GLOBAL_INSTALL_ROOT;
|
|
173
204
|
const lockedSkillIds = isGlobalDir ? void 0 : projectConfig?.skills?.filter((s) => s.scope === "global").map((s) => s.id);
|
|
@@ -187,7 +218,7 @@ var Edit = class _Edit extends BaseCommand {
|
|
|
187
218
|
lockedAgentNames,
|
|
188
219
|
isEditingFromGlobalScope: isGlobalDir,
|
|
189
220
|
projectDir,
|
|
190
|
-
startupMessages,
|
|
221
|
+
startupMessages: context.startupMessages,
|
|
191
222
|
onComplete: (result2) => {
|
|
192
223
|
wizardResult = result2;
|
|
193
224
|
},
|
|
@@ -199,15 +230,17 @@ var Edit = class _Edit extends BaseCommand {
|
|
|
199
230
|
);
|
|
200
231
|
await waitUntilExit();
|
|
201
232
|
const result = wizardResult;
|
|
202
|
-
if (!result || result.cancelled)
|
|
203
|
-
|
|
204
|
-
|
|
233
|
+
if (!result || result.cancelled) return null;
|
|
234
|
+
return result;
|
|
235
|
+
}
|
|
236
|
+
reportValidationErrors(result) {
|
|
205
237
|
if (result.validation.errors.length > 0) {
|
|
206
238
|
for (const err of result.validation.errors) {
|
|
207
239
|
this.warn(err.message);
|
|
208
240
|
}
|
|
209
241
|
}
|
|
210
|
-
|
|
242
|
+
}
|
|
243
|
+
logChangeSummary(changes) {
|
|
211
244
|
const {
|
|
212
245
|
addedSkills,
|
|
213
246
|
removedSkills,
|
|
@@ -217,16 +250,6 @@ var Edit = class _Edit extends BaseCommand {
|
|
|
217
250
|
scopeChanges,
|
|
218
251
|
agentScopeChanges
|
|
219
252
|
} = changes;
|
|
220
|
-
const hasSourceChanges = sourceChanges.size > 0;
|
|
221
|
-
const hasScopeChanges = scopeChanges.size > 0;
|
|
222
|
-
const hasAgentScopeChanges = agentScopeChanges.size > 0;
|
|
223
|
-
const hasSkillChanges = addedSkills.length > 0 || removedSkills.length > 0;
|
|
224
|
-
const hasAgentChanges = addedAgents.length > 0 || removedAgents.length > 0;
|
|
225
|
-
if (!hasSkillChanges && !hasAgentChanges && !hasSourceChanges && !hasScopeChanges && !hasAgentScopeChanges) {
|
|
226
|
-
this.log(INFO_MESSAGES.NO_CHANGES_MADE);
|
|
227
|
-
this.log("Plugin unchanged\n");
|
|
228
|
-
return;
|
|
229
|
-
}
|
|
230
253
|
this.log("\nChanges:");
|
|
231
254
|
for (const skillId of addedSkills) {
|
|
232
255
|
this.log(` + ${getSkillById(skillId).displayName}`);
|
|
@@ -257,7 +280,9 @@ var Edit = class _Edit extends BaseCommand {
|
|
|
257
280
|
this.log(` ~ ${agentName} (${fromLabel} \u2192 ${toLabel})`);
|
|
258
281
|
}
|
|
259
282
|
this.log("");
|
|
260
|
-
|
|
283
|
+
}
|
|
284
|
+
async applyMigrations(_changes, result, context, cwd) {
|
|
285
|
+
const oldSkills = context.projectConfig?.skills ?? [];
|
|
261
286
|
const migrationPlan = detectMigrations(oldSkills, result.skills);
|
|
262
287
|
const hasMigrations = migrationPlan.toLocal.length > 0 || migrationPlan.toPlugin.length > 0;
|
|
263
288
|
if (hasMigrations) {
|
|
@@ -273,44 +298,53 @@ var Edit = class _Edit extends BaseCommand {
|
|
|
273
298
|
this.log(` - ${migration.id}`);
|
|
274
299
|
}
|
|
275
300
|
}
|
|
276
|
-
const migrationResult = await executeMigration(migrationPlan, cwd, sourceResult);
|
|
301
|
+
const migrationResult = await executeMigration(migrationPlan, cwd, context.sourceResult);
|
|
277
302
|
for (const warning of migrationResult.warnings) {
|
|
278
303
|
this.warn(warning);
|
|
279
304
|
}
|
|
280
305
|
}
|
|
281
|
-
|
|
306
|
+
return /* @__PURE__ */ new Set([
|
|
282
307
|
...migrationPlan.toLocal.map((m) => m.id),
|
|
283
308
|
...migrationPlan.toPlugin.map((m) => m.id)
|
|
284
309
|
]);
|
|
310
|
+
}
|
|
311
|
+
async applyScopeChanges(changes, result, context, cwd) {
|
|
312
|
+
const { scopeChanges } = changes;
|
|
285
313
|
for (const [skillId, change] of scopeChanges) {
|
|
286
314
|
const skillConfig = result.skills.find((s) => s.id === skillId);
|
|
287
315
|
if (skillConfig?.source === "local") {
|
|
288
316
|
await migrateLocalSkillScope(skillId, change.from, cwd);
|
|
289
317
|
}
|
|
290
318
|
}
|
|
291
|
-
if (sourceResult.marketplace && scopeChanges.size > 0) {
|
|
319
|
+
if (context.sourceResult.marketplace && scopeChanges.size > 0) {
|
|
292
320
|
const pluginScopeResult = await migratePluginSkillScopes(
|
|
293
321
|
scopeChanges,
|
|
294
322
|
result.skills,
|
|
295
|
-
sourceResult.marketplace,
|
|
323
|
+
context.sourceResult.marketplace,
|
|
296
324
|
cwd
|
|
297
325
|
);
|
|
298
326
|
for (const item of pluginScopeResult.failed) {
|
|
299
327
|
this.warn(`Failed to migrate plugin scope for ${item.id}: ${item.error}`);
|
|
300
328
|
}
|
|
301
329
|
}
|
|
330
|
+
}
|
|
331
|
+
async applySourceChanges(changes, _result, context, cwd, migratedSkillIds) {
|
|
332
|
+
const { sourceChanges } = changes;
|
|
302
333
|
for (const [skillId, change] of sourceChanges) {
|
|
303
334
|
if (migratedSkillIds.has(skillId)) {
|
|
304
335
|
continue;
|
|
305
336
|
}
|
|
306
337
|
if (change.from === "local") {
|
|
307
|
-
const oldSkill = projectConfig?.skills?.find((s) => s.id === skillId);
|
|
338
|
+
const oldSkill = context.projectConfig?.skills?.find((s) => s.id === skillId);
|
|
308
339
|
const deleteDir = oldSkill?.scope === "global" ? os.homedir() : cwd;
|
|
309
340
|
await deleteLocalSkill(deleteDir, skillId);
|
|
310
341
|
}
|
|
311
342
|
}
|
|
312
|
-
|
|
313
|
-
|
|
343
|
+
}
|
|
344
|
+
async applyPluginChanges(changes, result, context, cwd) {
|
|
345
|
+
const { addedSkills, removedSkills } = changes;
|
|
346
|
+
if (context.sourceResult.marketplace) {
|
|
347
|
+
const mpResult = await ensureMarketplace(context.sourceResult);
|
|
314
348
|
if (mpResult.registered) {
|
|
315
349
|
this.log(`Registered marketplace: ${mpResult.marketplace}`);
|
|
316
350
|
}
|
|
@@ -320,7 +354,7 @@ var Edit = class _Edit extends BaseCommand {
|
|
|
320
354
|
if (addedPluginSkills.length > 0) {
|
|
321
355
|
const pluginResult = await installPluginSkills(
|
|
322
356
|
addedPluginSkills,
|
|
323
|
-
sourceResult.marketplace,
|
|
357
|
+
context.sourceResult.marketplace,
|
|
324
358
|
cwd
|
|
325
359
|
);
|
|
326
360
|
for (const item of pluginResult.installed) {
|
|
@@ -333,7 +367,7 @@ var Edit = class _Edit extends BaseCommand {
|
|
|
333
367
|
if (removedSkills.length > 0) {
|
|
334
368
|
const uninstallResult = await uninstallPluginSkills(
|
|
335
369
|
removedSkills,
|
|
336
|
-
projectConfig?.skills ?? [],
|
|
370
|
+
context.projectConfig?.skills ?? [],
|
|
337
371
|
cwd
|
|
338
372
|
);
|
|
339
373
|
for (const id of uninstallResult.uninstalled) {
|
|
@@ -344,13 +378,18 @@ var Edit = class _Edit extends BaseCommand {
|
|
|
344
378
|
}
|
|
345
379
|
}
|
|
346
380
|
}
|
|
381
|
+
}
|
|
382
|
+
async copyNewLocalSkills(changes, result, context, cwd) {
|
|
383
|
+
const { addedSkills } = changes;
|
|
347
384
|
const addedLocalSkills = result.skills.filter(
|
|
348
385
|
(s) => addedSkills.includes(s.id) && s.source === "local"
|
|
349
386
|
);
|
|
350
387
|
if (addedLocalSkills.length > 0) {
|
|
351
|
-
const copyResult = await copyLocalSkills(addedLocalSkills, cwd, sourceResult);
|
|
388
|
+
const copyResult = await copyLocalSkills(addedLocalSkills, cwd, context.sourceResult);
|
|
352
389
|
this.log(`Copied ${copyResult.totalCopied} local skill(s) to .claude/skills/`);
|
|
353
390
|
}
|
|
391
|
+
}
|
|
392
|
+
async writeConfigAndCompile(result, context, flags, cwd) {
|
|
354
393
|
let agentDefsResult;
|
|
355
394
|
this.log(
|
|
356
395
|
flags["agent-source"] ? STATUS_MESSAGES.FETCHING_AGENT_PARTIALS : STATUS_MESSAGES.LOADING_AGENT_PARTIALS
|
|
@@ -366,7 +405,7 @@ var Edit = class _Edit extends BaseCommand {
|
|
|
366
405
|
try {
|
|
367
406
|
await writeProjectConfig({
|
|
368
407
|
wizardResult: result,
|
|
369
|
-
sourceResult,
|
|
408
|
+
sourceResult: context.sourceResult,
|
|
370
409
|
projectDir: cwd,
|
|
371
410
|
sourceFlag: flags.source,
|
|
372
411
|
agents: agentDefsResult.agents
|
|
@@ -377,9 +416,11 @@ var Edit = class _Edit extends BaseCommand {
|
|
|
377
416
|
this.log(STATUS_MESSAGES.RECOMPILING_AGENTS);
|
|
378
417
|
try {
|
|
379
418
|
const agentScopeMap = new Map(result.agentConfigs.map((a) => [a.name, a.scope]));
|
|
419
|
+
const { allSkills } = await discoverInstalledSkills(cwd);
|
|
380
420
|
const compilationResult = await compileAgents({
|
|
381
421
|
projectDir: cwd,
|
|
382
422
|
sourcePath: agentDefsResult.sourcePath,
|
|
423
|
+
skills: allSkills,
|
|
383
424
|
pluginDir: cwd,
|
|
384
425
|
outputDir: path.join(cwd, CLAUDE_DIR, "agents"),
|
|
385
426
|
installMode: deriveInstallMode(result.skills),
|
|
@@ -404,6 +445,9 @@ var Edit = class _Edit extends BaseCommand {
|
|
|
404
445
|
this.log(`You can manually recompile with '${CLI_BIN_NAME} compile'.
|
|
405
446
|
`);
|
|
406
447
|
}
|
|
448
|
+
}
|
|
449
|
+
async cleanupStaleAgentFiles(changes, cwd) {
|
|
450
|
+
const { agentScopeChanges } = changes;
|
|
407
451
|
for (const [agentName, change] of agentScopeChanges) {
|
|
408
452
|
const oldBaseDir = change.from === "global" ? os.homedir() : cwd;
|
|
409
453
|
const oldAgentPath = path.join(oldBaseDir, CLAUDE_DIR, "agents", `${agentName}.md`);
|
|
@@ -413,6 +457,21 @@ var Edit = class _Edit extends BaseCommand {
|
|
|
413
457
|
this.warn(`Could not remove old agent file ${oldAgentPath}: ${getErrorMessage(error)}`);
|
|
414
458
|
}
|
|
415
459
|
}
|
|
460
|
+
}
|
|
461
|
+
logCompletionSummary(changes) {
|
|
462
|
+
const {
|
|
463
|
+
addedSkills,
|
|
464
|
+
removedSkills,
|
|
465
|
+
addedAgents,
|
|
466
|
+
removedAgents,
|
|
467
|
+
sourceChanges,
|
|
468
|
+
scopeChanges,
|
|
469
|
+
agentScopeChanges
|
|
470
|
+
} = changes;
|
|
471
|
+
const hasAgentChanges = addedAgents.length > 0 || removedAgents.length > 0;
|
|
472
|
+
const hasSourceChanges = sourceChanges.size > 0;
|
|
473
|
+
const hasScopeChanges = scopeChanges.size > 0;
|
|
474
|
+
const hasAgentScopeChanges = agentScopeChanges.size > 0;
|
|
416
475
|
const summaryParts = [`${addedSkills.length} added`, `${removedSkills.length} removed`];
|
|
417
476
|
if (hasAgentChanges) {
|
|
418
477
|
summaryParts.push(
|
|
@@ -431,6 +490,79 @@ var Edit = class _Edit extends BaseCommand {
|
|
|
431
490
|
`);
|
|
432
491
|
}
|
|
433
492
|
};
|
|
493
|
+
function detectConfigChanges(oldConfig, wizardResult, currentSkillIds) {
|
|
494
|
+
const newSkillIds = wizardResult.skills.map((s) => s.id);
|
|
495
|
+
const addedSkills = newSkillIds.filter((id) => !currentSkillIds.includes(id));
|
|
496
|
+
const removedSkills = currentSkillIds.filter((id) => !newSkillIds.includes(id));
|
|
497
|
+
const oldAgentNames = oldConfig?.agents?.map((a) => a.name) ?? [];
|
|
498
|
+
const newAgentNames = wizardResult.agentConfigs.map((a) => a.name);
|
|
499
|
+
const addedAgents = newAgentNames.filter((name) => !oldAgentNames.includes(name));
|
|
500
|
+
const removedAgents = oldAgentNames.filter((name) => !newAgentNames.includes(name));
|
|
501
|
+
const sourceChanges = /* @__PURE__ */ new Map();
|
|
502
|
+
const scopeChanges = /* @__PURE__ */ new Map();
|
|
503
|
+
if (oldConfig?.skills) {
|
|
504
|
+
for (const newSkill of wizardResult.skills) {
|
|
505
|
+
const oldSkill = oldConfig.skills.find((s) => s.id === newSkill.id);
|
|
506
|
+
if (oldSkill && oldSkill.source !== newSkill.source) {
|
|
507
|
+
sourceChanges.set(newSkill.id, {
|
|
508
|
+
from: oldSkill.source,
|
|
509
|
+
to: newSkill.source
|
|
510
|
+
});
|
|
511
|
+
}
|
|
512
|
+
if (oldSkill && oldSkill.scope !== newSkill.scope) {
|
|
513
|
+
scopeChanges.set(newSkill.id, {
|
|
514
|
+
from: oldSkill.scope,
|
|
515
|
+
to: newSkill.scope
|
|
516
|
+
});
|
|
517
|
+
}
|
|
518
|
+
}
|
|
519
|
+
}
|
|
520
|
+
const agentScopeChanges = /* @__PURE__ */ new Map();
|
|
521
|
+
if (oldConfig?.agents) {
|
|
522
|
+
for (const newAgent of wizardResult.agentConfigs) {
|
|
523
|
+
const oldAgent = oldConfig.agents.find((a) => a.name === newAgent.name);
|
|
524
|
+
if (oldAgent && oldAgent.scope !== newAgent.scope) {
|
|
525
|
+
agentScopeChanges.set(newAgent.name, {
|
|
526
|
+
from: oldAgent.scope,
|
|
527
|
+
to: newAgent.scope
|
|
528
|
+
});
|
|
529
|
+
}
|
|
530
|
+
}
|
|
531
|
+
}
|
|
532
|
+
return {
|
|
533
|
+
addedSkills,
|
|
534
|
+
removedSkills,
|
|
535
|
+
addedAgents,
|
|
536
|
+
removedAgents,
|
|
537
|
+
sourceChanges,
|
|
538
|
+
scopeChanges,
|
|
539
|
+
agentScopeChanges
|
|
540
|
+
};
|
|
541
|
+
}
|
|
542
|
+
function hasAnyChanges(changes) {
|
|
543
|
+
return changes.addedSkills.length > 0 || changes.removedSkills.length > 0 || changes.addedAgents.length > 0 || changes.removedAgents.length > 0 || changes.sourceChanges.size > 0 || changes.scopeChanges.size > 0 || changes.agentScopeChanges.size > 0;
|
|
544
|
+
}
|
|
545
|
+
async function migratePluginSkillScopes(scopeChanges, skills, marketplace, projectDir) {
|
|
546
|
+
const migrated = [];
|
|
547
|
+
const failed = [];
|
|
548
|
+
for (const [skillId, change] of scopeChanges) {
|
|
549
|
+
const skillConfig = skills.find((s) => s.id === skillId);
|
|
550
|
+
if (!skillConfig || skillConfig.source === "local") {
|
|
551
|
+
continue;
|
|
552
|
+
}
|
|
553
|
+
const oldPluginScope = change.from === "global" ? "user" : "project";
|
|
554
|
+
const newPluginScope = change.to === "global" ? "user" : "project";
|
|
555
|
+
const pluginRef = `${skillId}@${marketplace}`;
|
|
556
|
+
try {
|
|
557
|
+
await claudePluginUninstall(skillId, oldPluginScope, projectDir);
|
|
558
|
+
await claudePluginInstall(pluginRef, newPluginScope, projectDir);
|
|
559
|
+
migrated.push(skillId);
|
|
560
|
+
} catch (error) {
|
|
561
|
+
failed.push({ id: skillId, error: getErrorMessage(error) });
|
|
562
|
+
}
|
|
563
|
+
}
|
|
564
|
+
return { migrated, failed };
|
|
565
|
+
}
|
|
434
566
|
export {
|
|
435
567
|
Edit as default
|
|
436
568
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/cli/commands/edit.tsx"],"sourcesContent":["import os from \"os\";\nimport path from \"path\";\n\nimport { Flags } from \"@oclif/core\";\nimport { render } from \"ink\";\n\nimport { BaseCommand } from \"../base-command.js\";\nimport { Wizard, type WizardResultV2 } from \"../components/wizard/wizard.js\";\nimport { CLAUDE_DIR, CLI_BIN_NAME, GLOBAL_INSTALL_ROOT, SOURCE_DISPLAY_NAMES } from \"../consts.js\";\nimport {\n detectProject,\n loadSource,\n copyLocalSkills,\n ensureMarketplace,\n installPluginSkills,\n uninstallPluginSkills,\n migratePluginSkillScopes,\n loadAgentDefs,\n type AgentDefs,\n writeProjectConfig,\n compileAgents,\n detectConfigChanges,\n} from \"../lib/operations/index.js\";\nimport { EXIT_CODES } from \"../lib/exit-codes.js\";\nimport {\n detectMigrations,\n executeMigration,\n deriveInstallMode,\n} from \"../lib/installation/index.js\";\nimport { matrix, getSkillById } from \"../lib/matrix/matrix-provider\";\nimport { discoverAllPluginSkills } from \"../lib/plugins/index.js\";\nimport { deleteLocalSkill, migrateLocalSkillScope } from \"../lib/skills/index.js\";\nimport type { SkillId } from \"../types/index.js\";\nimport { getErrorMessage } from \"../utils/errors.js\";\nimport { remove } from \"../utils/fs.js\";\nimport { type StartupMessage } from \"../utils/logger.js\";\nimport { ERROR_MESSAGES, INFO_MESSAGES, STATUS_MESSAGES } from \"../utils/messages.js\";\n\nfunction formatSourceDisplayName(sourceName: string): string {\n return SOURCE_DISPLAY_NAMES[sourceName] ?? sourceName;\n}\n\nexport default class Edit extends BaseCommand {\n static summary = \"Edit skills in the plugin\";\n static description = \"Modify the currently installed skills via interactive wizard\";\n\n static examples = [\n {\n description: \"Open the edit wizard\",\n command: \"<%= config.bin %> <%= command.id %>\",\n },\n {\n description: \"Edit with a custom source\",\n command: \"<%= config.bin %> <%= command.id %> --source github:org/marketplace\",\n },\n {\n description: \"Force refresh skills from remote\",\n command: \"<%= config.bin %> <%= command.id %> --refresh\",\n },\n ];\n\n static flags = {\n ...BaseCommand.baseFlags,\n refresh: Flags.boolean({\n description: \"Force refresh from remote sources\",\n default: false,\n }),\n \"agent-source\": Flags.string({\n description: \"Remote agent partials source (default: local CLI)\",\n }),\n };\n\n async run(): Promise<void> {\n const { flags } = await this.parse(Edit);\n const cwd = process.cwd();\n\n const detected = await detectProject();\n if (!detected) {\n this.error(ERROR_MESSAGES.NO_INSTALLATION, {\n exit: EXIT_CODES.ERROR,\n });\n }\n const { installation, config: projectConfig } = detected;\n\n // Use installation.projectDir for reads (loading config, discovering installed skills).\n // Use cwd for writes (config saves, plugin installs, scope migrations, recompilation output)\n // and for the locked-items check (determining whether global items are read-only).\n const projectDir = installation.projectDir;\n\n let sourceResult;\n let startupMessages: StartupMessage[] = [];\n try {\n const loaded = await loadSource({\n sourceFlag: flags.source,\n projectDir,\n forceRefresh: flags.refresh,\n captureStartupMessages: true,\n });\n sourceResult = loaded.sourceResult;\n startupMessages = loaded.startupMessages;\n\n const sourceInfo = sourceResult.isLocal ? \"local\" : sourceResult.sourceConfig.sourceOrigin;\n startupMessages.push({\n level: \"info\",\n text: `Loaded ${Object.keys(matrix.skills).length} skills (${sourceInfo})`,\n });\n } catch (error) {\n this.handleError(error);\n }\n\n let currentSkillIds: SkillId[];\n try {\n const discoveredSkills = await discoverAllPluginSkills(projectDir);\n // Boundary cast: discoverAllPluginSkills keys are skill IDs from frontmatter\n const pluginSkillIds = Object.keys(discoveredSkills) as SkillId[];\n\n // Merge plugin-discovered skills with config skills (catches local skills and\n // global-scoped plugins that discoverAllPluginSkills doesn't find).\n const configSkillIds = projectConfig?.skills?.map((s) => s.id) ?? [];\n const mergedIds = new Set<SkillId>([...pluginSkillIds, ...configSkillIds]);\n currentSkillIds = [...mergedIds];\n\n startupMessages.push({\n level: \"info\",\n text: `Found ${currentSkillIds.length} installed skills`,\n });\n } catch (error) {\n this.handleError(error);\n }\n\n let wizardResult: WizardResultV2 | null = null;\n\n // D9: In project context, existing global items are read-only (locked).\n // When editing from ~/ (global context), nothing is locked.\n // Uses cwd (not projectDir) so that global items are correctly locked\n // even when detectInstallation() fell back to the global installation.\n const isGlobalDir = cwd === GLOBAL_INSTALL_ROOT;\n const lockedSkillIds = isGlobalDir\n ? undefined\n : projectConfig?.skills?.filter((s) => s.scope === \"global\").map((s) => s.id);\n const lockedAgentNames = isGlobalDir\n ? undefined\n : projectConfig?.agents?.filter((a) => a.scope === \"global\").map((a) => a.name);\n\n const { waitUntilExit } = render(\n <Wizard\n version={this.config.version}\n initialStep=\"build\"\n initialDomains={projectConfig?.domains}\n initialAgents={projectConfig?.selectedAgents}\n installedSkillIds={currentSkillIds}\n installedSkillConfigs={projectConfig?.skills}\n lockedSkillIds={lockedSkillIds}\n installedAgentConfigs={projectConfig?.agents}\n lockedAgentNames={lockedAgentNames}\n isEditingFromGlobalScope={isGlobalDir}\n projectDir={projectDir}\n startupMessages={startupMessages}\n onComplete={(result) => {\n wizardResult = result;\n }}\n onCancel={() => {\n this.log(\"\\nEdit cancelled\");\n }}\n />,\n );\n\n await waitUntilExit();\n\n // TypeScript can't track that onComplete callback mutates wizardResult before waitUntilExit resolves\n const result = wizardResult as WizardResultV2 | null;\n\n if (!result || result.cancelled) {\n this.error(\"Cancelled\", { exit: EXIT_CODES.CANCELLED });\n }\n\n if (result.validation.errors.length > 0) {\n for (const err of result.validation.errors) {\n this.warn(err.message);\n }\n }\n\n const changes = detectConfigChanges(projectConfig, result, currentSkillIds);\n const {\n addedSkills,\n removedSkills,\n addedAgents,\n removedAgents,\n sourceChanges,\n scopeChanges,\n agentScopeChanges,\n } = changes;\n\n const hasSourceChanges = sourceChanges.size > 0;\n const hasScopeChanges = scopeChanges.size > 0;\n const hasAgentScopeChanges = agentScopeChanges.size > 0;\n const hasSkillChanges = addedSkills.length > 0 || removedSkills.length > 0;\n const hasAgentChanges = addedAgents.length > 0 || removedAgents.length > 0;\n\n if (\n !hasSkillChanges &&\n !hasAgentChanges &&\n !hasSourceChanges &&\n !hasScopeChanges &&\n !hasAgentScopeChanges\n ) {\n this.log(INFO_MESSAGES.NO_CHANGES_MADE);\n this.log(\"Plugin unchanged\\n\");\n return;\n }\n\n this.log(\"\\nChanges:\");\n for (const skillId of addedSkills) {\n this.log(` + ${getSkillById(skillId).displayName}`);\n }\n for (const skillId of removedSkills) {\n const skill = matrix.skills[skillId];\n this.log(` - ${skill?.displayName ?? skillId}`);\n }\n for (const agentName of addedAgents) {\n this.log(` + ${agentName} (agent)`);\n }\n for (const agentName of removedAgents) {\n this.log(` - ${agentName} (agent)`);\n }\n for (const [skillId, change] of sourceChanges) {\n const fromLabel = formatSourceDisplayName(change.from);\n const toLabel = formatSourceDisplayName(change.to);\n this.log(` ~ ${skillId} (${fromLabel} \\u2192 ${toLabel})`);\n }\n for (const [skillId, change] of scopeChanges) {\n const fromLabel = change.from === \"global\" ? \"[G]\" : \"[P]\";\n const toLabel = change.to === \"global\" ? \"[G]\" : \"[P]\";\n this.log(` ~ ${skillId} (${fromLabel} \\u2192 ${toLabel})`);\n }\n for (const [agentName, change] of agentScopeChanges) {\n const fromLabel = change.from === \"global\" ? \"[G]\" : \"[P]\";\n const toLabel = change.to === \"global\" ? \"[G]\" : \"[P]\";\n this.log(` ~ ${agentName} (${fromLabel} \\u2192 ${toLabel})`);\n }\n this.log(\"\");\n\n // Handle per-skill mode migrations (local <-> plugin)\n const oldSkills = projectConfig?.skills ?? [];\n const migrationPlan = detectMigrations(oldSkills, result.skills);\n const hasMigrations = migrationPlan.toLocal.length > 0 || migrationPlan.toPlugin.length > 0;\n\n if (hasMigrations) {\n if (migrationPlan.toLocal.length > 0) {\n this.log(`Switching ${migrationPlan.toLocal.length} skill(s) to local:`);\n for (const migration of migrationPlan.toLocal) {\n this.log(` - ${migration.id}`);\n }\n }\n if (migrationPlan.toPlugin.length > 0) {\n this.log(`Switching ${migrationPlan.toPlugin.length} skill(s) to plugin:`);\n for (const migration of migrationPlan.toPlugin) {\n this.log(` - ${migration.id}`);\n }\n }\n\n const migrationResult = await executeMigration(migrationPlan, cwd, sourceResult);\n\n for (const warning of migrationResult.warnings) {\n this.warn(warning);\n }\n }\n\n const migratedSkillIds = new Set([\n ...migrationPlan.toLocal.map((m) => m.id),\n ...migrationPlan.toPlugin.map((m) => m.id),\n ]);\n\n // Handle scope migrations (P→G or G→P) for local-mode skills\n for (const [skillId, change] of scopeChanges) {\n const skillConfig = result.skills.find((s) => s.id === skillId);\n if (skillConfig?.source === \"local\") {\n await migrateLocalSkillScope(skillId, change.from, cwd);\n }\n }\n\n // Handle scope migrations for plugin-mode skills\n if (sourceResult.marketplace && scopeChanges.size > 0) {\n const pluginScopeResult = await migratePluginSkillScopes(\n scopeChanges,\n result.skills,\n sourceResult.marketplace,\n cwd,\n );\n for (const item of pluginScopeResult.failed) {\n this.warn(`Failed to migrate plugin scope for ${item.id}: ${item.error}`);\n }\n }\n\n // Handle remaining non-migration source changes (e.g., marketplace A -> marketplace B)\n for (const [skillId, change] of sourceChanges) {\n // Skip skills already handled by mode migration\n if (migratedSkillIds.has(skillId)) {\n continue;\n }\n if (change.from === \"local\") {\n const oldSkill = projectConfig?.skills?.find((s) => s.id === skillId);\n const deleteDir = oldSkill?.scope === \"global\" ? os.homedir() : cwd;\n await deleteLocalSkill(deleteDir, skillId);\n }\n }\n\n if (sourceResult.marketplace) {\n const mpResult = await ensureMarketplace(sourceResult);\n if (mpResult.registered) {\n this.log(`Registered marketplace: ${mpResult.marketplace}`);\n }\n\n const addedPluginSkills = result.skills.filter(\n (s) => addedSkills.includes(s.id) && s.source !== \"local\",\n );\n if (addedPluginSkills.length > 0) {\n const pluginResult = await installPluginSkills(\n addedPluginSkills,\n sourceResult.marketplace,\n cwd,\n );\n for (const item of pluginResult.installed) {\n this.log(`Installing plugin: ${item.ref}...`);\n }\n for (const item of pluginResult.failed) {\n this.warn(`Failed to install plugin ${item.id}: ${item.error}`);\n }\n }\n\n if (removedSkills.length > 0) {\n const uninstallResult = await uninstallPluginSkills(\n removedSkills,\n projectConfig?.skills ?? [],\n cwd,\n );\n for (const id of uninstallResult.uninstalled) {\n this.log(`Uninstalling plugin: ${id}...`);\n }\n for (const item of uninstallResult.failed) {\n this.warn(`Failed to uninstall plugin ${item.id}: ${item.error}`);\n }\n }\n }\n\n // Copy newly added local-source skills to .claude/skills/ (split by scope)\n const addedLocalSkills = result.skills.filter(\n (s) => addedSkills.includes(s.id) && s.source === \"local\",\n );\n\n if (addedLocalSkills.length > 0) {\n const copyResult = await copyLocalSkills(addedLocalSkills, cwd, sourceResult);\n this.log(`Copied ${copyResult.totalCopied} local skill(s) to .claude/skills/`);\n }\n\n // Load agent definitions — needed for both config-types.ts and recompilation\n let agentDefsResult: AgentDefs;\n this.log(\n flags[\"agent-source\"]\n ? STATUS_MESSAGES.FETCHING_AGENT_PARTIALS\n : STATUS_MESSAGES.LOADING_AGENT_PARTIALS,\n );\n try {\n agentDefsResult = await loadAgentDefs(flags[\"agent-source\"], {\n forceRefresh: flags.refresh,\n });\n this.log(flags[\"agent-source\"] ? \"✓ Agent partials fetched\\n\" : \"✓ Agent partials loaded\\n\");\n } catch (error) {\n this.handleError(error);\n }\n\n // Persist wizard result to config.ts and config-types.ts (split by scope when in project context)\n try {\n await writeProjectConfig({\n wizardResult: result,\n sourceResult,\n projectDir: cwd,\n sourceFlag: flags.source,\n agents: agentDefsResult.agents,\n });\n } catch (error) {\n this.warn(`Could not update config: ${getErrorMessage(error)}`);\n }\n\n this.log(STATUS_MESSAGES.RECOMPILING_AGENTS);\n try {\n const agentScopeMap = new Map(result.agentConfigs.map((a) => [a.name, a.scope] as const));\n const compilationResult = await compileAgents({\n projectDir: cwd,\n sourcePath: agentDefsResult.sourcePath,\n pluginDir: cwd,\n outputDir: path.join(cwd, CLAUDE_DIR, \"agents\"),\n installMode: deriveInstallMode(result.skills),\n agentScopeMap,\n });\n\n if (compilationResult.failed.length > 0) {\n this.log(\n `✓ Recompiled ${compilationResult.compiled.length} agents (${compilationResult.failed.length} failed)\\n`,\n );\n for (const warning of compilationResult.warnings) {\n this.warn(warning);\n }\n } else if (compilationResult.compiled.length > 0) {\n this.log(`✓ Recompiled ${compilationResult.compiled.length} agents\\n`);\n } else {\n this.log(\"✓ No agents to recompile\\n\");\n }\n } catch (error) {\n this.warn(`Agent recompilation failed: ${getErrorMessage(error)}`);\n this.log(`You can manually recompile with '${CLI_BIN_NAME} compile'.\\n`);\n }\n\n // Clean up old agent .md files after scope changes.\n // Recompilation wrote the new file to the correct scope directory;\n // now delete the stale copy from the old scope directory.\n for (const [agentName, change] of agentScopeChanges) {\n const oldBaseDir = change.from === \"global\" ? os.homedir() : cwd;\n const oldAgentPath = path.join(oldBaseDir, CLAUDE_DIR, \"agents\", `${agentName}.md`);\n try {\n await remove(oldAgentPath);\n } catch (error) {\n this.warn(`Could not remove old agent file ${oldAgentPath}: ${getErrorMessage(error)}`);\n }\n }\n\n const summaryParts = [`${addedSkills.length} added`, `${removedSkills.length} removed`];\n if (hasAgentChanges) {\n summaryParts.push(\n `${addedAgents.length} agent${addedAgents.length !== 1 ? \"s\" : \"\"} added, ${removedAgents.length} agent${removedAgents.length !== 1 ? \"s\" : \"\"} removed`,\n );\n }\n if (hasSourceChanges) {\n summaryParts.push(`${sourceChanges.size} source${sourceChanges.size > 1 ? \"s\" : \"\"} changed`);\n }\n if (hasScopeChanges || hasAgentScopeChanges) {\n const totalScopeChanges = scopeChanges.size + agentScopeChanges.size;\n summaryParts.push(`${totalScopeChanges} scope${totalScopeChanges > 1 ? \"s\" : \"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AAS,OAAO;AACd,WAAK,KAAK,+BAA+B,gBAAgB,KAAK,CAAC,EAAE;AACjE,WAAK,IAAI,oCAAoC,YAAY;AAAA,CAAc;AAAA,IACzE;AAKA,eAAW,CAAC,WAAW,MAAM,KAAK,mBAAmB;AACnD,YAAM,aAAa,OAAO,SAAS,WAAW,GAAG,QAAQ,IAAI;AAC7D,YAAM,eAAe,KAAK,KAAK,YAAY,YAAY,UAAU,GAAG,SAAS,KAAK;AAClF,UAAI;AACF,cAAM,OAAO,YAAY;AAAA,MAC3B,SAAS,OAAO;AACd,aAAK,KAAK,mCAAmC,YAAY,KAAK,gBAAgB,KAAK,CAAC,EAAE;AAAA,MACxF;AAAA,IACF;AAEA,UAAM,eAAe,CAAC,GAAG,YAAY,MAAM,UAAU,GAAG,cAAc,MAAM,UAAU;AACtF,QAAI,iBAAiB;AACnB,mBAAa;AAAA,QACX,GAAG,YAAY,MAAM,SAAS,YAAY,WAAW,IAAI,MAAM,EAAE,WAAW,cAAc,MAAM,SAAS,cAAc,WAAW,IAAI,MAAM,EAAE;AAAA,MAChJ;AAAA,IACF;AACA,QAAI,kBAAkB;AACpB,mBAAa,KAAK,GAAG,cAAc,IAAI,UAAU,cAAc,OAAO,IAAI,MAAM,EAAE,UAAU;AAAA,IAC9F;AACA,QAAI,mBAAmB,sBAAsB;AAC3C,YAAM,oBAAoB,aAAa,OAAO,kBAAkB;AAChE,mBAAa,KAAK,GAAG,iBAAiB,SAAS,oBAAoB,IAAI,MAAM,EAAE,UAAU;AAAA,IAC3F;AACA,SAAK,IAAI;AAAA,0BAA6B,aAAa,KAAK,IAAI,CAAC;AAAA,CAAK;AAAA,EACpE;AACF;","names":["result"]}
|
|
1
|
+
{"version":3,"sources":["../../src/cli/commands/edit.tsx"],"sourcesContent":["import os from \"os\";\nimport path from \"path\";\n\nimport { Flags } from \"@oclif/core\";\nimport { render } from \"ink\";\n\nimport { BaseCommand } from \"../base-command.js\";\nimport { Wizard, type WizardResultV2 } from \"../components/wizard/wizard.js\";\nimport { CLAUDE_DIR, CLI_BIN_NAME, GLOBAL_INSTALL_ROOT, SOURCE_DISPLAY_NAMES } from \"../consts.js\";\nimport {\n detectProject,\n loadSource,\n copyLocalSkills,\n ensureMarketplace,\n installPluginSkills,\n uninstallPluginSkills,\n loadAgentDefs,\n type AgentDefs,\n writeProjectConfig,\n compileAgents,\n discoverInstalledSkills,\n} from \"../lib/operations/index.js\";\nimport { EXIT_CODES } from \"../lib/exit-codes.js\";\nimport {\n type Installation,\n detectMigrations,\n executeMigration,\n deriveInstallMode,\n} from \"../lib/installation/index.js\";\nimport { matrix, getSkillById } from \"../lib/matrix/matrix-provider\";\nimport type { SourceLoadResult } from \"../lib/loading/index.js\";\nimport { discoverAllPluginSkills } from \"../lib/plugins/index.js\";\nimport { deleteLocalSkill, migrateLocalSkillScope } from \"../lib/skills/index.js\";\nimport type { SkillId, AgentName, ProjectConfig } from \"../types/index.js\";\nimport { claudePluginInstall, claudePluginUninstall } from \"../utils/exec.js\";\nimport { getErrorMessage } from \"../utils/errors.js\";\nimport { remove } from \"../utils/fs.js\";\nimport { type StartupMessage } from \"../utils/logger.js\";\nimport { ERROR_MESSAGES, INFO_MESSAGES, STATUS_MESSAGES } from \"../utils/messages.js\";\n\nfunction formatSourceDisplayName(sourceName: string): string {\n return SOURCE_DISPLAY_NAMES[sourceName] ?? sourceName;\n}\n\ntype EditContext = {\n installation: Installation;\n projectConfig: ProjectConfig | null;\n projectDir: string;\n sourceResult: SourceLoadResult;\n startupMessages: StartupMessage[];\n currentSkillIds: SkillId[];\n};\n\nexport default class Edit extends BaseCommand {\n static summary = \"Edit skills in the plugin\";\n static description = \"Modify the currently installed skills via interactive wizard\";\n\n static examples = [\n {\n description: \"Open the edit wizard\",\n command: \"<%= config.bin %> <%= command.id %>\",\n },\n {\n description: \"Edit with a custom source\",\n command: \"<%= config.bin %> <%= command.id %> --source github:org/marketplace\",\n },\n {\n description: \"Force refresh skills from remote\",\n command: \"<%= config.bin %> <%= command.id %> --refresh\",\n },\n ];\n\n static flags = {\n ...BaseCommand.baseFlags,\n refresh: Flags.boolean({\n description: \"Force refresh from remote sources\",\n default: false,\n }),\n \"agent-source\": Flags.string({\n description: \"Remote agent partials source (default: local CLI)\",\n }),\n };\n\n async run(): Promise<void> {\n const { flags } = await this.parse(Edit);\n const cwd = process.cwd();\n\n const context = await this.loadContext(flags);\n const result = await this.runEditWizard(context, cwd);\n if (!result) this.error(\"Cancelled\", { exit: EXIT_CODES.CANCELLED });\n\n this.reportValidationErrors(result);\n\n const changes = detectConfigChanges(context.projectConfig, result, context.currentSkillIds);\n if (!hasAnyChanges(changes)) {\n this.log(INFO_MESSAGES.NO_CHANGES_MADE);\n this.log(\"Plugin unchanged\\n\");\n return;\n }\n\n this.logChangeSummary(changes);\n const migratedSkillIds = await this.applyMigrations(changes, result, context, cwd);\n await this.applyScopeChanges(changes, result, context, cwd);\n await this.applySourceChanges(changes, result, context, cwd, migratedSkillIds);\n await this.applyPluginChanges(changes, result, context, cwd);\n await this.copyNewLocalSkills(changes, result, context, cwd);\n await this.writeConfigAndCompile(result, context, flags, cwd);\n await this.cleanupStaleAgentFiles(changes, cwd);\n this.logCompletionSummary(changes);\n }\n\n private async loadContext(flags: { source?: string; refresh: boolean }): Promise<EditContext> {\n const detected = await detectProject();\n if (!detected) {\n this.error(ERROR_MESSAGES.NO_INSTALLATION, {\n exit: EXIT_CODES.ERROR,\n });\n }\n const { installation, config: projectConfig } = detected;\n\n // Use installation.projectDir for reads (loading config, discovering installed skills).\n // Use cwd for writes (config saves, plugin installs, scope migrations, recompilation output)\n // and for the locked-items check (determining whether global items are read-only).\n const projectDir = installation.projectDir;\n\n let sourceResult: SourceLoadResult;\n let startupMessages: StartupMessage[] = [];\n try {\n const loaded = await loadSource({\n sourceFlag: flags.source,\n projectDir,\n forceRefresh: flags.refresh,\n captureStartupMessages: true,\n });\n sourceResult = loaded.sourceResult;\n startupMessages = loaded.startupMessages;\n\n const sourceInfo = sourceResult.isLocal ? \"local\" : sourceResult.sourceConfig.sourceOrigin;\n startupMessages.push({\n level: \"info\",\n text: `Loaded ${Object.keys(matrix.skills).length} skills (${sourceInfo})`,\n });\n } catch (error) {\n this.handleError(error);\n }\n\n let currentSkillIds: SkillId[];\n try {\n const discoveredSkills = await discoverAllPluginSkills(projectDir);\n // Boundary cast: discoverAllPluginSkills keys are skill IDs from frontmatter\n const pluginSkillIds = Object.keys(discoveredSkills) as SkillId[];\n\n // Merge plugin-discovered skills with config skills (catches local skills and\n // global-scoped plugins that discoverAllPluginSkills doesn't find).\n const configSkillIds = projectConfig?.skills?.map((s) => s.id) ?? [];\n const mergedIds = new Set<SkillId>([...pluginSkillIds, ...configSkillIds]);\n currentSkillIds = [...mergedIds];\n\n startupMessages.push({\n level: \"info\",\n text: `Found ${currentSkillIds.length} installed skills`,\n });\n } catch (error) {\n this.handleError(error);\n }\n\n return {\n installation,\n projectConfig,\n projectDir,\n sourceResult,\n startupMessages,\n currentSkillIds,\n };\n }\n\n private async runEditWizard(context: EditContext, cwd: string): Promise<WizardResultV2 | null> {\n const { projectConfig, projectDir, currentSkillIds } = context;\n\n let wizardResult: WizardResultV2 | null = null;\n\n // D9: In project context, existing global items are read-only (locked).\n // When editing from ~/ (global context), nothing is locked.\n // Uses cwd (not projectDir) so that global items are correctly locked\n // even when detectInstallation() fell back to the global installation.\n const isGlobalDir = cwd === GLOBAL_INSTALL_ROOT;\n const lockedSkillIds = isGlobalDir\n ? undefined\n : projectConfig?.skills?.filter((s) => s.scope === \"global\").map((s) => s.id);\n const lockedAgentNames = isGlobalDir\n ? undefined\n : projectConfig?.agents?.filter((a) => a.scope === \"global\").map((a) => a.name);\n\n const { waitUntilExit } = render(\n <Wizard\n version={this.config.version}\n initialStep=\"build\"\n initialDomains={projectConfig?.domains}\n initialAgents={projectConfig?.selectedAgents}\n installedSkillIds={currentSkillIds}\n installedSkillConfigs={projectConfig?.skills}\n lockedSkillIds={lockedSkillIds}\n installedAgentConfigs={projectConfig?.agents}\n lockedAgentNames={lockedAgentNames}\n isEditingFromGlobalScope={isGlobalDir}\n projectDir={projectDir}\n startupMessages={context.startupMessages}\n onComplete={(result) => {\n wizardResult = result;\n }}\n onCancel={() => {\n this.log(\"\\nEdit cancelled\");\n }}\n />,\n );\n\n await waitUntilExit();\n\n // TypeScript can't track that onComplete callback mutates wizardResult before waitUntilExit resolves\n const result = wizardResult as WizardResultV2 | null;\n\n if (!result || result.cancelled) return null;\n return result;\n }\n\n private reportValidationErrors(result: WizardResultV2): void {\n if (result.validation.errors.length > 0) {\n for (const err of result.validation.errors) {\n this.warn(err.message);\n }\n }\n }\n\n private logChangeSummary(changes: ConfigChanges): void {\n const {\n addedSkills,\n removedSkills,\n addedAgents,\n removedAgents,\n sourceChanges,\n scopeChanges,\n agentScopeChanges,\n } = changes;\n\n this.log(\"\\nChanges:\");\n for (const skillId of addedSkills) {\n this.log(` + ${getSkillById(skillId).displayName}`);\n }\n for (const skillId of removedSkills) {\n const skill = matrix.skills[skillId];\n this.log(` - ${skill?.displayName ?? skillId}`);\n }\n for (const agentName of addedAgents) {\n this.log(` + ${agentName} (agent)`);\n }\n for (const agentName of removedAgents) {\n this.log(` - ${agentName} (agent)`);\n }\n for (const [skillId, change] of sourceChanges) {\n const fromLabel = formatSourceDisplayName(change.from);\n const toLabel = formatSourceDisplayName(change.to);\n this.log(` ~ ${skillId} (${fromLabel} \\u2192 ${toLabel})`);\n }\n for (const [skillId, change] of scopeChanges) {\n const fromLabel = change.from === \"global\" ? \"[G]\" : \"[P]\";\n const toLabel = change.to === \"global\" ? \"[G]\" : \"[P]\";\n this.log(` ~ ${skillId} (${fromLabel} \\u2192 ${toLabel})`);\n }\n for (const [agentName, change] of agentScopeChanges) {\n const fromLabel = change.from === \"global\" ? \"[G]\" : \"[P]\";\n const toLabel = change.to === \"global\" ? \"[G]\" : \"[P]\";\n this.log(` ~ ${agentName} (${fromLabel} \\u2192 ${toLabel})`);\n }\n this.log(\"\");\n }\n\n private async applyMigrations(\n _changes: ConfigChanges,\n result: WizardResultV2,\n context: EditContext,\n cwd: string,\n ): Promise<Set<SkillId>> {\n const oldSkills = context.projectConfig?.skills ?? [];\n const migrationPlan = detectMigrations(oldSkills, result.skills);\n const hasMigrations = migrationPlan.toLocal.length > 0 || migrationPlan.toPlugin.length > 0;\n\n if (hasMigrations) {\n if (migrationPlan.toLocal.length > 0) {\n this.log(`Switching ${migrationPlan.toLocal.length} skill(s) to local:`);\n for (const migration of migrationPlan.toLocal) {\n this.log(` - ${migration.id}`);\n }\n }\n if (migrationPlan.toPlugin.length > 0) {\n this.log(`Switching ${migrationPlan.toPlugin.length} skill(s) to plugin:`);\n for (const migration of migrationPlan.toPlugin) {\n this.log(` - ${migration.id}`);\n }\n }\n\n const migrationResult = await executeMigration(migrationPlan, cwd, context.sourceResult);\n\n for (const warning of migrationResult.warnings) {\n this.warn(warning);\n }\n }\n\n return new Set([\n ...migrationPlan.toLocal.map((m) => m.id),\n ...migrationPlan.toPlugin.map((m) => m.id),\n ]);\n }\n\n private async applyScopeChanges(\n changes: ConfigChanges,\n result: WizardResultV2,\n context: EditContext,\n cwd: string,\n ): Promise<void> {\n const { scopeChanges } = changes;\n\n // Handle scope migrations (P->G or G->P) for local-mode skills\n for (const [skillId, change] of scopeChanges) {\n const skillConfig = result.skills.find((s) => s.id === skillId);\n if (skillConfig?.source === \"local\") {\n await migrateLocalSkillScope(skillId, change.from, cwd);\n }\n }\n\n // Handle scope migrations for plugin-mode skills\n if (context.sourceResult.marketplace && scopeChanges.size > 0) {\n const pluginScopeResult = await migratePluginSkillScopes(\n scopeChanges,\n result.skills,\n context.sourceResult.marketplace,\n cwd,\n );\n for (const item of pluginScopeResult.failed) {\n this.warn(`Failed to migrate plugin scope for ${item.id}: ${item.error}`);\n }\n }\n }\n\n private async applySourceChanges(\n changes: ConfigChanges,\n _result: WizardResultV2,\n context: EditContext,\n cwd: string,\n migratedSkillIds: Set<SkillId>,\n ): Promise<void> {\n const { sourceChanges } = changes;\n\n // Handle remaining non-migration source changes (e.g., marketplace A -> marketplace B)\n for (const [skillId, change] of sourceChanges) {\n // Skip skills already handled by mode migration\n if (migratedSkillIds.has(skillId)) {\n continue;\n }\n if (change.from === \"local\") {\n const oldSkill = context.projectConfig?.skills?.find((s) => s.id === skillId);\n const deleteDir = oldSkill?.scope === \"global\" ? os.homedir() : cwd;\n await deleteLocalSkill(deleteDir, skillId);\n }\n }\n }\n\n private async applyPluginChanges(\n changes: ConfigChanges,\n result: WizardResultV2,\n context: EditContext,\n cwd: string,\n ): Promise<void> {\n const { addedSkills, removedSkills } = changes;\n\n if (context.sourceResult.marketplace) {\n const mpResult = await ensureMarketplace(context.sourceResult);\n if (mpResult.registered) {\n this.log(`Registered marketplace: ${mpResult.marketplace}`);\n }\n\n const addedPluginSkills = result.skills.filter(\n (s) => addedSkills.includes(s.id) && s.source !== \"local\",\n );\n if (addedPluginSkills.length > 0) {\n const pluginResult = await installPluginSkills(\n addedPluginSkills,\n context.sourceResult.marketplace,\n cwd,\n );\n for (const item of pluginResult.installed) {\n this.log(`Installing plugin: ${item.ref}...`);\n }\n for (const item of pluginResult.failed) {\n this.warn(`Failed to install plugin ${item.id}: ${item.error}`);\n }\n }\n\n if (removedSkills.length > 0) {\n const uninstallResult = await uninstallPluginSkills(\n removedSkills,\n context.projectConfig?.skills ?? [],\n cwd,\n );\n for (const id of uninstallResult.uninstalled) {\n this.log(`Uninstalling plugin: ${id}...`);\n }\n for (const item of uninstallResult.failed) {\n this.warn(`Failed to uninstall plugin ${item.id}: ${item.error}`);\n }\n }\n }\n }\n\n private async copyNewLocalSkills(\n changes: ConfigChanges,\n result: WizardResultV2,\n context: EditContext,\n cwd: string,\n ): Promise<void> {\n const { addedSkills } = changes;\n\n // Copy newly added local-source skills to .claude/skills/ (split by scope)\n const addedLocalSkills = result.skills.filter(\n (s) => addedSkills.includes(s.id) && s.source === \"local\",\n );\n\n if (addedLocalSkills.length > 0) {\n const copyResult = await copyLocalSkills(addedLocalSkills, cwd, context.sourceResult);\n this.log(`Copied ${copyResult.totalCopied} local skill(s) to .claude/skills/`);\n }\n }\n\n private async writeConfigAndCompile(\n result: WizardResultV2,\n context: EditContext,\n flags: { source?: string; refresh: boolean; \"agent-source\"?: string },\n cwd: string,\n ): Promise<void> {\n // Load agent definitions — needed for both config-types.ts and recompilation\n let agentDefsResult: AgentDefs;\n this.log(\n flags[\"agent-source\"]\n ? STATUS_MESSAGES.FETCHING_AGENT_PARTIALS\n : STATUS_MESSAGES.LOADING_AGENT_PARTIALS,\n );\n try {\n agentDefsResult = await loadAgentDefs(flags[\"agent-source\"], {\n forceRefresh: flags.refresh,\n });\n this.log(flags[\"agent-source\"] ? \"✓ Agent partials fetched\\n\" : \"✓ Agent partials loaded\\n\");\n } catch (error) {\n this.handleError(error);\n }\n\n // Persist wizard result to config.ts and config-types.ts (split by scope when in project context)\n try {\n await writeProjectConfig({\n wizardResult: result,\n sourceResult: context.sourceResult,\n projectDir: cwd,\n sourceFlag: flags.source,\n agents: agentDefsResult.agents,\n });\n } catch (error) {\n this.warn(`Could not update config: ${getErrorMessage(error)}`);\n }\n\n this.log(STATUS_MESSAGES.RECOMPILING_AGENTS);\n try {\n const agentScopeMap = new Map(result.agentConfigs.map((a) => [a.name, a.scope] as const));\n const { allSkills } = await discoverInstalledSkills(cwd);\n const compilationResult = await compileAgents({\n projectDir: cwd,\n sourcePath: agentDefsResult.sourcePath,\n skills: allSkills,\n pluginDir: cwd,\n outputDir: path.join(cwd, CLAUDE_DIR, \"agents\"),\n installMode: deriveInstallMode(result.skills),\n agentScopeMap,\n });\n\n if (compilationResult.failed.length > 0) {\n this.log(\n `✓ Recompiled ${compilationResult.compiled.length} agents (${compilationResult.failed.length} failed)\\n`,\n );\n for (const warning of compilationResult.warnings) {\n this.warn(warning);\n }\n } else if (compilationResult.compiled.length > 0) {\n this.log(`✓ Recompiled ${compilationResult.compiled.length} agents\\n`);\n } else {\n this.log(\"✓ No agents to recompile\\n\");\n }\n } catch (error) {\n this.warn(`Agent recompilation failed: ${getErrorMessage(error)}`);\n this.log(`You can manually recompile with '${CLI_BIN_NAME} compile'.\\n`);\n }\n }\n\n private async cleanupStaleAgentFiles(changes: ConfigChanges, cwd: string): Promise<void> {\n const { agentScopeChanges } = changes;\n\n // Clean up old agent .md files after scope changes.\n // Recompilation wrote the new file to the correct scope directory;\n // now delete the stale copy from the old scope directory.\n for (const [agentName, change] of agentScopeChanges) {\n const oldBaseDir = change.from === \"global\" ? os.homedir() : cwd;\n const oldAgentPath = path.join(oldBaseDir, CLAUDE_DIR, \"agents\", `${agentName}.md`);\n try {\n await remove(oldAgentPath);\n } catch (error) {\n this.warn(`Could not remove old agent file ${oldAgentPath}: ${getErrorMessage(error)}`);\n }\n }\n }\n\n private logCompletionSummary(changes: ConfigChanges): void {\n const {\n addedSkills,\n removedSkills,\n addedAgents,\n removedAgents,\n sourceChanges,\n scopeChanges,\n agentScopeChanges,\n } = changes;\n\n const hasAgentChanges = addedAgents.length > 0 || removedAgents.length > 0;\n const hasSourceChanges = sourceChanges.size > 0;\n const hasScopeChanges = scopeChanges.size > 0;\n const hasAgentScopeChanges = agentScopeChanges.size > 0;\n\n const summaryParts = [`${addedSkills.length} added`, `${removedSkills.length} removed`];\n if (hasAgentChanges) {\n summaryParts.push(\n `${addedAgents.length} agent${addedAgents.length !== 1 ? \"s\" : \"\"} added, ${removedAgents.length} agent${removedAgents.length !== 1 ? \"s\" : \"\"} removed`,\n );\n }\n if (hasSourceChanges) {\n summaryParts.push(`${sourceChanges.size} source${sourceChanges.size > 1 ? \"s\" : \"\"} changed`);\n }\n if (hasScopeChanges || hasAgentScopeChanges) {\n const totalScopeChanges = scopeChanges.size + agentScopeChanges.size;\n summaryParts.push(`${totalScopeChanges} scope${totalScopeChanges > 1 ? \"s\" : \"\"} changed`);\n }\n this.log(`\\n\\u2713 Plugin updated! (${summaryParts.join(\", \")})\\n`);\n }\n}\n\ntype ConfigChanges = {\n addedSkills: SkillId[];\n removedSkills: SkillId[];\n addedAgents: AgentName[];\n removedAgents: AgentName[];\n sourceChanges: Map<SkillId, { from: string; to: string }>;\n scopeChanges: Map<SkillId, { from: \"project\" | \"global\"; to: \"project\" | \"global\" }>;\n agentScopeChanges: Map<AgentName, { from: \"project\" | \"global\"; to: \"project\" | \"global\" }>;\n};\n\nfunction detectConfigChanges(\n oldConfig: ProjectConfig | null,\n wizardResult: WizardResultV2,\n currentSkillIds: SkillId[],\n): ConfigChanges {\n const newSkillIds = wizardResult.skills.map((s) => s.id);\n const addedSkills = newSkillIds.filter((id) => !currentSkillIds.includes(id));\n const removedSkills = currentSkillIds.filter((id) => !newSkillIds.includes(id));\n\n const oldAgentNames = oldConfig?.agents?.map((a) => a.name) ?? [];\n const newAgentNames = wizardResult.agentConfigs.map((a) => a.name);\n const addedAgents = newAgentNames.filter((name) => !oldAgentNames.includes(name));\n const removedAgents = oldAgentNames.filter((name) => !newAgentNames.includes(name));\n\n const sourceChanges = new Map<SkillId, { from: string; to: string }>();\n const scopeChanges = new Map<SkillId, { from: \"project\" | \"global\"; to: \"project\" | \"global\" }>();\n if (oldConfig?.skills) {\n for (const newSkill of wizardResult.skills) {\n const oldSkill = oldConfig.skills.find((s) => s.id === newSkill.id);\n if (oldSkill && oldSkill.source !== newSkill.source) {\n sourceChanges.set(newSkill.id, {\n from: oldSkill.source,\n to: newSkill.source,\n });\n }\n if (oldSkill && oldSkill.scope !== newSkill.scope) {\n scopeChanges.set(newSkill.id, {\n from: oldSkill.scope,\n to: newSkill.scope,\n });\n }\n }\n }\n\n const agentScopeChanges = new Map<\n AgentName,\n { from: \"project\" | \"global\"; to: \"project\" | \"global\" }\n >();\n if (oldConfig?.agents) {\n for (const newAgent of wizardResult.agentConfigs) {\n const oldAgent = oldConfig.agents.find((a) => a.name === newAgent.name);\n if (oldAgent && oldAgent.scope !== newAgent.scope) {\n agentScopeChanges.set(newAgent.name, {\n from: oldAgent.scope,\n to: newAgent.scope,\n });\n }\n }\n }\n\n return {\n addedSkills,\n removedSkills,\n addedAgents,\n removedAgents,\n sourceChanges,\n scopeChanges,\n agentScopeChanges,\n };\n}\n\nfunction hasAnyChanges(changes: ConfigChanges): boolean {\n return (\n changes.addedSkills.length > 0 ||\n changes.removedSkills.length > 0 ||\n changes.addedAgents.length > 0 ||\n changes.removedAgents.length > 0 ||\n changes.sourceChanges.size > 0 ||\n changes.scopeChanges.size > 0 ||\n changes.agentScopeChanges.size > 0\n );\n}\n\ntype PluginScopeMigrationResult = {\n migrated: SkillId[];\n failed: Array<{ id: SkillId; error: string }>;\n};\n\nasync function migratePluginSkillScopes(\n scopeChanges: Map<SkillId, { from: \"project\" | \"global\"; to: \"project\" | \"global\" }>,\n skills: Array<{ id: SkillId; source: string }>,\n marketplace: string,\n projectDir: string,\n): Promise<PluginScopeMigrationResult> {\n const migrated: SkillId[] = [];\n const failed: PluginScopeMigrationResult[\"failed\"] = [];\n\n for (const [skillId, change] of scopeChanges) {\n const skillConfig = skills.find((s) => s.id === skillId);\n if (!skillConfig || skillConfig.source === \"local\") {\n continue;\n }\n\n const oldPluginScope = change.from === \"global\" ? \"user\" : \"project\";\n const newPluginScope = change.to === \"global\" ? \"user\" : \"project\";\n const pluginRef = `${skillId}@${marketplace}`;\n\n try {\n await claudePluginUninstall(skillId, oldPluginScope, projectDir);\n await claudePluginInstall(pluginRef, newPluginScope, projectDir);\n migrated.push(skillId);\n } catch (error) {\n failed.push({ id: skillId, error: getErrorMessage(error) });\n }\n }\n\n return { migrated, failed };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA,OAAO,QAAQ;AACf,OAAO,UAAU;AAEjB,SAAS,aAAa;AACtB,SAAS,cAAc;AA8LjB;AA1JN,SAAS,wBAAwB,YAA4B;AAC3D,SAAO,qBAAqB,UAAU,KAAK;AAC7C;AAWA,IAAqB,OAArB,MAAqB,c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