@claude-collective/cli 0.2.0 → 0.8.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 +178 -0
- package/README.md +1 -1
- package/dist/chunk-3HBTELJN.js +114 -0
- package/dist/chunk-3HBTELJN.js.map +1 -0
- package/dist/chunk-3ZCB5K33.js +54 -0
- package/dist/chunk-3ZCB5K33.js.map +1 -0
- package/dist/chunk-66UDJBF6.js +96 -0
- package/dist/chunk-66UDJBF6.js.map +1 -0
- package/dist/chunk-6LS7XO3H.js +31 -0
- package/dist/chunk-6LS7XO3H.js.map +1 -0
- package/dist/chunk-A3J6IAXK.js +57 -0
- package/dist/chunk-A3J6IAXK.js.map +1 -0
- package/dist/chunk-A65SBAAJ.js +69 -0
- package/dist/chunk-A65SBAAJ.js.map +1 -0
- package/dist/chunk-ALEPJ6YN.js +80 -0
- package/dist/chunk-ALEPJ6YN.js.map +1 -0
- package/dist/chunk-C4ZTIYFR.js +84 -0
- package/dist/chunk-C4ZTIYFR.js.map +1 -0
- package/dist/chunk-CIY5UBRB.js +453 -0
- package/dist/chunk-CIY5UBRB.js.map +1 -0
- package/dist/chunk-DHET7RCE.js +50 -0
- package/dist/chunk-DHET7RCE.js.map +1 -0
- package/dist/chunk-DHFFRMF6.js +31 -0
- package/dist/chunk-DHFFRMF6.js.map +1 -0
- package/dist/chunk-DKGL77IY.js +307 -0
- package/dist/chunk-DKGL77IY.js.map +1 -0
- package/dist/chunk-ED73HCW2.js +315 -0
- package/dist/chunk-ED73HCW2.js.map +1 -0
- package/dist/chunk-FNOYEXUE.js +308 -0
- package/dist/chunk-FNOYEXUE.js.map +1 -0
- package/dist/chunk-G2FBJOZG.js +141 -0
- package/dist/chunk-G2FBJOZG.js.map +1 -0
- package/dist/chunk-HNDT5QRB.js +120 -0
- package/dist/chunk-HNDT5QRB.js.map +1 -0
- package/dist/chunk-K7PTOVX4.js +158 -0
- package/dist/chunk-K7PTOVX4.js.map +1 -0
- package/dist/chunk-LQTST4WY.js +91 -0
- package/dist/chunk-LQTST4WY.js.map +1 -0
- package/dist/chunk-LVKRVFYR.js +54 -0
- package/dist/chunk-LVKRVFYR.js.map +1 -0
- package/dist/chunk-M7YCPFIX.js +108 -0
- package/dist/chunk-M7YCPFIX.js.map +1 -0
- package/dist/chunk-MJSFR562.js +57 -0
- package/dist/chunk-MJSFR562.js.map +1 -0
- package/dist/chunk-MMDXNZPF.js +69 -0
- package/dist/chunk-MMDXNZPF.js.map +1 -0
- package/dist/chunk-MYAVQ23U.js +356 -0
- package/dist/chunk-MYAVQ23U.js.map +1 -0
- package/dist/chunk-NGBFJJ7Q.js +124 -0
- package/dist/chunk-NGBFJJ7Q.js.map +1 -0
- package/dist/chunk-OLBOTK3O.js +64 -0
- package/dist/chunk-OLBOTK3O.js.map +1 -0
- package/dist/chunk-PPNTD5LO.js +330 -0
- package/dist/chunk-PPNTD5LO.js.map +1 -0
- package/dist/chunk-Q2LH2DAB.js +392 -0
- package/dist/chunk-Q2LH2DAB.js.map +1 -0
- package/dist/chunk-Q6DR5QUH.js +547 -0
- package/dist/chunk-Q6DR5QUH.js.map +1 -0
- package/dist/chunk-QESUUPOE.js +241 -0
- package/dist/chunk-QESUUPOE.js.map +1 -0
- package/dist/chunk-QGGSLMO3.js +607 -0
- package/dist/chunk-QGGSLMO3.js.map +1 -0
- package/dist/chunk-SEBPPFUW.js +478 -0
- package/dist/chunk-SEBPPFUW.js.map +1 -0
- package/dist/chunk-SYQ7R2JO.js +95 -0
- package/dist/chunk-SYQ7R2JO.js.map +1 -0
- package/dist/chunk-TOPAIL5W.js +22 -0
- package/dist/chunk-TOPAIL5W.js.map +1 -0
- package/dist/chunk-U4VYHKPM.js +110 -0
- package/dist/chunk-U4VYHKPM.js.map +1 -0
- package/dist/chunk-UOWHJ6BE.js +83 -0
- package/dist/chunk-UOWHJ6BE.js.map +1 -0
- package/dist/chunk-XKEG3SCV.js +86 -0
- package/dist/chunk-XKEG3SCV.js.map +1 -0
- package/dist/chunk-XY3XDVMI.js +15599 -0
- package/dist/chunk-XY3XDVMI.js.map +1 -0
- package/dist/chunk-Y3V43XCU.js +76 -0
- package/dist/chunk-Y3V43XCU.js.map +1 -0
- package/dist/chunk-YKXBGCFD.js +129 -0
- package/dist/chunk-YKXBGCFD.js.map +1 -0
- package/dist/cli-v2/defaults/agent-mappings.yaml +185 -0
- package/dist/commands/build/marketplace.js +254 -0
- package/dist/commands/build/marketplace.js.map +1 -0
- package/dist/commands/build/plugins.js +324 -0
- package/dist/commands/build/plugins.js.map +1 -0
- package/dist/commands/build/stack.js +169 -0
- package/dist/commands/build/stack.js.map +1 -0
- package/dist/commands/compile.js +461 -0
- package/dist/commands/compile.js.map +1 -0
- package/dist/commands/config/get.js +60 -0
- package/dist/commands/config/get.js.map +1 -0
- package/dist/commands/config/index.js +22 -0
- package/dist/commands/config/index.js.map +1 -0
- package/dist/commands/config/path.js +35 -0
- package/dist/commands/config/path.js.map +1 -0
- package/dist/commands/config/set-project.js +61 -0
- package/dist/commands/config/set-project.js.map +1 -0
- package/dist/commands/config/set.js +60 -0
- package/dist/commands/config/set.js.map +1 -0
- package/dist/commands/config/show.js +13 -0
- package/dist/commands/config/show.js.map +1 -0
- package/dist/commands/config/unset-project.js +57 -0
- package/dist/commands/config/unset-project.js.map +1 -0
- package/dist/commands/config/unset.js +56 -0
- package/dist/commands/config/unset.js.map +1 -0
- package/dist/commands/diff.js +755 -0
- package/dist/commands/diff.js.map +1 -0
- package/dist/commands/doctor.js +413 -0
- package/dist/commands/doctor.js.map +1 -0
- package/dist/commands/edit.js +254 -0
- package/dist/commands/edit.js.map +1 -0
- package/dist/commands/eject.js +208 -0
- package/dist/commands/eject.js.map +1 -0
- package/dist/commands/info.js +205 -0
- package/dist/commands/info.js.map +1 -0
- package/dist/commands/init.js +915 -0
- package/dist/commands/init.js.map +1 -0
- package/dist/commands/list.js +44 -0
- package/dist/commands/list.js.map +1 -0
- package/dist/commands/new/agent.js +230 -0
- package/dist/commands/new/agent.js.map +1 -0
- package/dist/commands/new/skill.js +204 -0
- package/dist/commands/new/skill.js.map +1 -0
- package/dist/commands/outdated.js +242 -0
- package/dist/commands/outdated.js.map +1 -0
- package/dist/commands/search.js +115 -0
- package/dist/commands/search.js.map +1 -0
- package/dist/commands/test-imports.js +92 -0
- package/dist/commands/test-imports.js.map +1 -0
- package/dist/commands/uninstall.js +309 -0
- package/dist/commands/uninstall.js.map +1 -0
- package/dist/commands/update.js +428 -0
- package/dist/commands/update.js.map +1 -0
- package/dist/commands/validate.js +375 -0
- package/dist/commands/validate.js.map +1 -0
- package/dist/commands/version/bump.js +95 -0
- package/dist/commands/version/bump.js.map +1 -0
- package/dist/commands/version/index.js +70 -0
- package/dist/commands/version/index.js.map +1 -0
- package/dist/commands/version/set.js +101 -0
- package/dist/commands/version/set.js.map +1 -0
- package/dist/commands/version/show.js +70 -0
- package/dist/commands/version/show.js.map +1 -0
- package/dist/components/common/confirm.js +9 -0
- package/dist/components/common/confirm.js.map +1 -0
- package/dist/components/common/message.js +24 -0
- package/dist/components/common/message.js.map +1 -0
- package/dist/components/common/spinner.js +14 -0
- package/dist/components/common/spinner.js.map +1 -0
- package/dist/components/wizard/category-grid.js +9 -0
- package/dist/components/wizard/category-grid.js.map +1 -0
- package/dist/components/wizard/category-grid.test.js +728 -0
- package/dist/components/wizard/category-grid.test.js.map +1 -0
- package/dist/components/wizard/section-progress.js +9 -0
- package/dist/components/wizard/section-progress.js.map +1 -0
- package/dist/components/wizard/section-progress.test.js +281 -0
- package/dist/components/wizard/section-progress.test.js.map +1 -0
- package/dist/components/wizard/step-approach.js +11 -0
- package/dist/components/wizard/step-approach.js.map +1 -0
- package/dist/components/wizard/step-build.js +15 -0
- package/dist/components/wizard/step-build.js.map +1 -0
- package/dist/components/wizard/step-build.test.js +729 -0
- package/dist/components/wizard/step-build.test.js.map +1 -0
- package/dist/components/wizard/step-confirm.js +9 -0
- package/dist/components/wizard/step-confirm.js.map +1 -0
- package/dist/components/wizard/step-refine.js +9 -0
- package/dist/components/wizard/step-refine.js.map +1 -0
- package/dist/components/wizard/step-refine.test.js +235 -0
- package/dist/components/wizard/step-refine.test.js.map +1 -0
- package/dist/components/wizard/step-stack-options.js +11 -0
- package/dist/components/wizard/step-stack-options.js.map +1 -0
- package/dist/components/wizard/step-stack.js +11 -0
- package/dist/components/wizard/step-stack.js.map +1 -0
- package/dist/components/wizard/wizard-tabs.js +11 -0
- package/dist/components/wizard/wizard-tabs.js.map +1 -0
- package/dist/components/wizard/wizard.js +20 -0
- package/dist/components/wizard/wizard.js.map +1 -0
- package/dist/hooks/init.js +41 -0
- package/dist/hooks/init.js.map +1 -0
- package/dist/index.js +10 -0
- package/dist/index.js.map +1 -0
- package/dist/magic-string.es-RGXYGAW3.js +1316 -0
- package/dist/magic-string.es-RGXYGAW3.js.map +1 -0
- package/dist/stores/wizard-store.js +10 -0
- package/dist/stores/wizard-store.js.map +1 -0
- package/dist/stores/wizard-store.test.js +405 -0
- package/dist/stores/wizard-store.test.js.map +1 -0
- package/package.json +44 -25
- package/dist/cli/index.js +0 -6314
- package/dist/cli/index.js.map +0 -1
|
@@ -0,0 +1,254 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import {
|
|
3
|
+
bumpPluginVersion
|
|
4
|
+
} from "../chunk-OLBOTK3O.js";
|
|
5
|
+
import {
|
|
6
|
+
getAgentDefinitions
|
|
7
|
+
} from "../chunk-C4ZTIYFR.js";
|
|
8
|
+
import {
|
|
9
|
+
detectInstallation
|
|
10
|
+
} from "../chunk-3ZCB5K33.js";
|
|
11
|
+
import {
|
|
12
|
+
recompileAgents
|
|
13
|
+
} from "../chunk-FNOYEXUE.js";
|
|
14
|
+
import "../chunk-MYAVQ23U.js";
|
|
15
|
+
import {
|
|
16
|
+
copySkillsToPluginFromSource
|
|
17
|
+
} from "../chunk-G2FBJOZG.js";
|
|
18
|
+
import {
|
|
19
|
+
Wizard
|
|
20
|
+
} from "../chunk-ED73HCW2.js";
|
|
21
|
+
import "../chunk-A65SBAAJ.js";
|
|
22
|
+
import "../chunk-HNDT5QRB.js";
|
|
23
|
+
import "../chunk-ALEPJ6YN.js";
|
|
24
|
+
import "../chunk-XKEG3SCV.js";
|
|
25
|
+
import "../chunk-Q6DR5QUH.js";
|
|
26
|
+
import "../chunk-LVKRVFYR.js";
|
|
27
|
+
import "../chunk-UOWHJ6BE.js";
|
|
28
|
+
import "../chunk-Y3V43XCU.js";
|
|
29
|
+
import "../chunk-PPNTD5LO.js";
|
|
30
|
+
import "../chunk-K7PTOVX4.js";
|
|
31
|
+
import "../chunk-Q2LH2DAB.js";
|
|
32
|
+
import "../chunk-LQTST4WY.js";
|
|
33
|
+
import "../chunk-MJSFR562.js";
|
|
34
|
+
import "../chunk-SEBPPFUW.js";
|
|
35
|
+
import {
|
|
36
|
+
getCollectivePluginDir,
|
|
37
|
+
getPluginSkillIds,
|
|
38
|
+
getPluginSkillsDir
|
|
39
|
+
} from "../chunk-3HBTELJN.js";
|
|
40
|
+
import {
|
|
41
|
+
loadSkillsMatrixFromSource
|
|
42
|
+
} from "../chunk-DKGL77IY.js";
|
|
43
|
+
import "../chunk-QGGSLMO3.js";
|
|
44
|
+
import "../chunk-NGBFJJ7Q.js";
|
|
45
|
+
import "../chunk-QESUUPOE.js";
|
|
46
|
+
import "../chunk-A3J6IAXK.js";
|
|
47
|
+
import {
|
|
48
|
+
BaseCommand,
|
|
49
|
+
EXIT_CODES
|
|
50
|
+
} from "../chunk-SYQ7R2JO.js";
|
|
51
|
+
import "../chunk-TOPAIL5W.js";
|
|
52
|
+
import {
|
|
53
|
+
directoryExists,
|
|
54
|
+
ensureDir,
|
|
55
|
+
remove
|
|
56
|
+
} from "../chunk-MMDXNZPF.js";
|
|
57
|
+
import {
|
|
58
|
+
init_esm_shims
|
|
59
|
+
} from "../chunk-DHET7RCE.js";
|
|
60
|
+
|
|
61
|
+
// src/cli-v2/commands/edit.tsx
|
|
62
|
+
init_esm_shims();
|
|
63
|
+
import { Flags } from "@oclif/core";
|
|
64
|
+
import { render } from "ink";
|
|
65
|
+
import { jsx } from "react/jsx-runtime";
|
|
66
|
+
var Edit = class _Edit extends BaseCommand {
|
|
67
|
+
static summary = "Edit skills in the plugin";
|
|
68
|
+
static description = "Modify the currently installed skills via interactive wizard";
|
|
69
|
+
static flags = {
|
|
70
|
+
...BaseCommand.baseFlags,
|
|
71
|
+
refresh: Flags.boolean({
|
|
72
|
+
description: "Force refresh from remote sources",
|
|
73
|
+
default: false
|
|
74
|
+
}),
|
|
75
|
+
"agent-source": Flags.string({
|
|
76
|
+
description: "Remote agent partials source (default: local CLI)"
|
|
77
|
+
})
|
|
78
|
+
};
|
|
79
|
+
async run() {
|
|
80
|
+
const { flags } = await this.parse(_Edit);
|
|
81
|
+
const installation = await detectInstallation();
|
|
82
|
+
if (!installation) {
|
|
83
|
+
this.error(
|
|
84
|
+
"No installation found. Run 'cc init' first to set up Claude Collective.",
|
|
85
|
+
{ exit: EXIT_CODES.ERROR }
|
|
86
|
+
);
|
|
87
|
+
}
|
|
88
|
+
const pluginDir = getCollectivePluginDir();
|
|
89
|
+
const pluginSkillsDir = installation.mode === "local" ? installation.skillsDir : getPluginSkillsDir(pluginDir);
|
|
90
|
+
const modeLabel = installation.mode === "local" ? "Local" : "Plugin";
|
|
91
|
+
this.log(`Edit ${modeLabel} Skills
|
|
92
|
+
`);
|
|
93
|
+
this.log("Resolving marketplace source...");
|
|
94
|
+
let sourceResult;
|
|
95
|
+
try {
|
|
96
|
+
sourceResult = await loadSkillsMatrixFromSource({
|
|
97
|
+
sourceFlag: flags.source,
|
|
98
|
+
projectDir: process.cwd(),
|
|
99
|
+
forceRefresh: flags.refresh
|
|
100
|
+
});
|
|
101
|
+
const sourceInfo = sourceResult.isLocal ? "local" : sourceResult.sourceConfig.sourceOrigin;
|
|
102
|
+
this.log(
|
|
103
|
+
`\u2713 Loaded ${Object.keys(sourceResult.matrix.skills).length} skills (${sourceInfo})
|
|
104
|
+
`
|
|
105
|
+
);
|
|
106
|
+
} catch (error) {
|
|
107
|
+
this.handleError(error);
|
|
108
|
+
}
|
|
109
|
+
this.log("Reading current skills...");
|
|
110
|
+
let currentSkillIds;
|
|
111
|
+
try {
|
|
112
|
+
currentSkillIds = await getPluginSkillIds(
|
|
113
|
+
pluginSkillsDir,
|
|
114
|
+
sourceResult.matrix
|
|
115
|
+
);
|
|
116
|
+
this.log(`\u2713 Current plugin has ${currentSkillIds.length} skills
|
|
117
|
+
`);
|
|
118
|
+
} catch (error) {
|
|
119
|
+
this.handleError(error);
|
|
120
|
+
}
|
|
121
|
+
let wizardResult = null;
|
|
122
|
+
const { waitUntilExit } = render(
|
|
123
|
+
/* @__PURE__ */ jsx(
|
|
124
|
+
Wizard,
|
|
125
|
+
{
|
|
126
|
+
matrix: sourceResult.matrix,
|
|
127
|
+
initialSkills: currentSkillIds,
|
|
128
|
+
onComplete: (result) => {
|
|
129
|
+
wizardResult = result;
|
|
130
|
+
},
|
|
131
|
+
onCancel: () => {
|
|
132
|
+
this.log("\nEdit cancelled");
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
)
|
|
136
|
+
);
|
|
137
|
+
await waitUntilExit();
|
|
138
|
+
if (!wizardResult || wizardResult.cancelled) {
|
|
139
|
+
this.exit(EXIT_CODES.CANCELLED);
|
|
140
|
+
}
|
|
141
|
+
if (!wizardResult.validation.valid) {
|
|
142
|
+
this.error("Selection has validation errors:");
|
|
143
|
+
for (const error of wizardResult.validation.errors) {
|
|
144
|
+
this.log(` ${error.message}`);
|
|
145
|
+
}
|
|
146
|
+
this.exit(EXIT_CODES.ERROR);
|
|
147
|
+
}
|
|
148
|
+
const addedSkills = wizardResult.selectedSkills.filter(
|
|
149
|
+
(id) => !currentSkillIds.includes(id)
|
|
150
|
+
);
|
|
151
|
+
const removedSkills = currentSkillIds.filter(
|
|
152
|
+
(id) => !wizardResult.selectedSkills.includes(id)
|
|
153
|
+
);
|
|
154
|
+
if (wizardResult.validation.warnings.length > 0) {
|
|
155
|
+
this.log("\nWarnings:");
|
|
156
|
+
for (const warning of wizardResult.validation.warnings) {
|
|
157
|
+
this.warn(` ! ${warning.message}`);
|
|
158
|
+
}
|
|
159
|
+
this.log("");
|
|
160
|
+
}
|
|
161
|
+
if (addedSkills.length === 0 && removedSkills.length === 0) {
|
|
162
|
+
this.log("No changes made.");
|
|
163
|
+
this.log("Plugin unchanged\n");
|
|
164
|
+
return;
|
|
165
|
+
}
|
|
166
|
+
this.log("\nChanges:");
|
|
167
|
+
for (const skillId of addedSkills) {
|
|
168
|
+
const skill = sourceResult.matrix.skills[skillId];
|
|
169
|
+
this.log(` + ${skill?.name || skillId}`);
|
|
170
|
+
}
|
|
171
|
+
for (const skillId of removedSkills) {
|
|
172
|
+
const skill = sourceResult.matrix.skills[skillId];
|
|
173
|
+
this.log(` - ${skill?.name || skillId}`);
|
|
174
|
+
}
|
|
175
|
+
this.log("");
|
|
176
|
+
this.log("Updating plugin skills...");
|
|
177
|
+
try {
|
|
178
|
+
if (await directoryExists(pluginSkillsDir)) {
|
|
179
|
+
await remove(pluginSkillsDir);
|
|
180
|
+
}
|
|
181
|
+
await ensureDir(pluginSkillsDir);
|
|
182
|
+
await copySkillsToPluginFromSource(
|
|
183
|
+
wizardResult.selectedSkills,
|
|
184
|
+
pluginDir,
|
|
185
|
+
sourceResult.matrix,
|
|
186
|
+
sourceResult
|
|
187
|
+
);
|
|
188
|
+
this.log(
|
|
189
|
+
`\u2713 Plugin updated with ${wizardResult.selectedSkills.length} skills
|
|
190
|
+
`
|
|
191
|
+
);
|
|
192
|
+
} catch (error) {
|
|
193
|
+
this.handleError(error);
|
|
194
|
+
}
|
|
195
|
+
let sourcePath;
|
|
196
|
+
this.log(
|
|
197
|
+
flags["agent-source"] ? "Fetching agent partials..." : "Loading agent partials..."
|
|
198
|
+
);
|
|
199
|
+
try {
|
|
200
|
+
const agentDefs = await getAgentDefinitions(flags["agent-source"], {
|
|
201
|
+
forceRefresh: flags.refresh
|
|
202
|
+
});
|
|
203
|
+
sourcePath = agentDefs.sourcePath;
|
|
204
|
+
this.log(
|
|
205
|
+
flags["agent-source"] ? "\u2713 Agent partials fetched\n" : "\u2713 Agent partials loaded\n"
|
|
206
|
+
);
|
|
207
|
+
} catch (error) {
|
|
208
|
+
this.handleError(error);
|
|
209
|
+
}
|
|
210
|
+
this.log("Recompiling agents...");
|
|
211
|
+
try {
|
|
212
|
+
const recompileResult = await recompileAgents({
|
|
213
|
+
pluginDir,
|
|
214
|
+
sourcePath
|
|
215
|
+
});
|
|
216
|
+
if (recompileResult.failed.length > 0) {
|
|
217
|
+
this.log(
|
|
218
|
+
`\u2713 Recompiled ${recompileResult.compiled.length} agents (${recompileResult.failed.length} failed)
|
|
219
|
+
`
|
|
220
|
+
);
|
|
221
|
+
for (const warning of recompileResult.warnings) {
|
|
222
|
+
this.warn(warning);
|
|
223
|
+
}
|
|
224
|
+
} else if (recompileResult.compiled.length > 0) {
|
|
225
|
+
this.log(`\u2713 Recompiled ${recompileResult.compiled.length} agents
|
|
226
|
+
`);
|
|
227
|
+
} else {
|
|
228
|
+
this.log("\u2713 No agents to recompile\n");
|
|
229
|
+
}
|
|
230
|
+
} catch (error) {
|
|
231
|
+
this.warn(
|
|
232
|
+
`Agent recompilation failed: ${error instanceof Error ? error.message : String(error)}`
|
|
233
|
+
);
|
|
234
|
+
this.log("You can manually recompile with 'cc compile'.\n");
|
|
235
|
+
}
|
|
236
|
+
this.log("Updating plugin version...");
|
|
237
|
+
try {
|
|
238
|
+
const newVersion = await bumpPluginVersion(pluginDir, "patch");
|
|
239
|
+
this.log(`\u2713 Version bumped to ${newVersion}
|
|
240
|
+
`);
|
|
241
|
+
} catch (error) {
|
|
242
|
+
this.handleError(error);
|
|
243
|
+
}
|
|
244
|
+
this.log(
|
|
245
|
+
`
|
|
246
|
+
\u2713 Plugin updated! (${addedSkills.length} added, ${removedSkills.length} removed)
|
|
247
|
+
`
|
|
248
|
+
);
|
|
249
|
+
}
|
|
250
|
+
};
|
|
251
|
+
export {
|
|
252
|
+
Edit as default
|
|
253
|
+
};
|
|
254
|
+
//# sourceMappingURL=edit.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/cli-v2/commands/edit.tsx"],"sourcesContent":["import { Flags } from \"@oclif/core\";\nimport { render } from \"ink\";\nimport React from \"react\";\nimport { BaseCommand } from \"../base-command.js\";\nimport { Wizard, WizardResult } from \"../components/wizard/wizard.js\";\nimport { loadSkillsMatrixFromSource } from \"../lib/source-loader.js\";\nimport { directoryExists, ensureDir, remove } from \"../utils/fs.js\";\nimport {\n getCollectivePluginDir,\n getPluginSkillsDir,\n getPluginSkillIds,\n} from \"../lib/plugin-finder.js\";\nimport { copySkillsToPluginFromSource } from \"../lib/skill-copier.js\";\nimport { recompileAgents } from \"../lib/agent-recompiler.js\";\nimport { bumpPluginVersion } from \"../lib/plugin-version.js\";\nimport { getAgentDefinitions } from \"../lib/agent-fetcher.js\";\nimport { EXIT_CODES } from \"../lib/exit-codes.js\";\nimport { detectInstallation } from \"../lib/installation.js\";\n\nexport default class Edit extends BaseCommand {\n static summary = \"Edit skills in the plugin\";\n static description =\n \"Modify the currently installed skills via interactive wizard\";\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\n // Detect installation mode\n const installation = await detectInstallation();\n\n if (!installation) {\n this.error(\n \"No installation found. Run 'cc init' first to set up Claude Collective.\",\n { exit: EXIT_CODES.ERROR },\n );\n }\n\n const pluginDir = getCollectivePluginDir();\n const pluginSkillsDir =\n installation.mode === \"local\"\n ? installation.skillsDir\n : getPluginSkillsDir(pluginDir);\n\n const modeLabel = installation.mode === \"local\" ? \"Local\" : \"Plugin\";\n this.log(`Edit ${modeLabel} Skills\\n`);\n\n // Load skills matrix\n this.log(\"Resolving marketplace source...\");\n let sourceResult;\n try {\n sourceResult = await loadSkillsMatrixFromSource({\n sourceFlag: flags.source,\n projectDir: process.cwd(),\n forceRefresh: flags.refresh,\n });\n\n const sourceInfo = sourceResult.isLocal\n ? \"local\"\n : sourceResult.sourceConfig.sourceOrigin;\n this.log(\n `✓ Loaded ${Object.keys(sourceResult.matrix.skills).length} skills (${sourceInfo})\\n`,\n );\n } catch (error) {\n this.handleError(error);\n }\n\n // Load current skills\n this.log(\"Reading current skills...\");\n let currentSkillIds: string[];\n try {\n currentSkillIds = await getPluginSkillIds(\n pluginSkillsDir,\n sourceResult.matrix,\n );\n this.log(`✓ Current plugin has ${currentSkillIds.length} skills\\n`);\n } catch (error) {\n this.handleError(error);\n }\n\n // Run wizard with initial skills\n let wizardResult: WizardResult | null = null;\n\n const { waitUntilExit } = render(\n <Wizard\n matrix={sourceResult.matrix}\n initialSkills={currentSkillIds}\n onComplete={(result) => {\n wizardResult = result;\n }}\n onCancel={() => {\n this.log(\"\\nEdit cancelled\");\n }}\n />,\n );\n\n await waitUntilExit();\n\n // Handle cancellation\n if (!wizardResult || wizardResult.cancelled) {\n this.exit(EXIT_CODES.CANCELLED);\n }\n\n // Validate selection\n if (!wizardResult.validation.valid) {\n this.error(\"Selection has validation errors:\");\n for (const error of wizardResult.validation.errors) {\n this.log(` ${error.message}`);\n }\n this.exit(EXIT_CODES.ERROR);\n }\n\n // Calculate changes\n const addedSkills = wizardResult.selectedSkills.filter(\n (id) => !currentSkillIds.includes(id),\n );\n const removedSkills = currentSkillIds.filter(\n (id) => !wizardResult.selectedSkills.includes(id),\n );\n\n // Show warnings if any\n if (wizardResult.validation.warnings.length > 0) {\n this.log(\"\\nWarnings:\");\n for (const warning of wizardResult.validation.warnings) {\n this.warn(` ! ${warning.message}`);\n }\n this.log(\"\");\n }\n\n // Check if there are no changes\n if (addedSkills.length === 0 && removedSkills.length === 0) {\n this.log(\"No changes made.\");\n this.log(\"Plugin unchanged\\n\");\n return;\n }\n\n // Show changes\n this.log(\"\\nChanges:\");\n for (const skillId of addedSkills) {\n const skill = sourceResult.matrix.skills[skillId];\n this.log(` + ${skill?.name || skillId}`);\n }\n for (const skillId of removedSkills) {\n const skill = sourceResult.matrix.skills[skillId];\n this.log(` - ${skill?.name || skillId}`);\n }\n this.log(\"\");\n\n // Update plugin skills\n this.log(\"Updating plugin skills...\");\n try {\n if (await directoryExists(pluginSkillsDir)) {\n await remove(pluginSkillsDir);\n }\n await ensureDir(pluginSkillsDir);\n\n await copySkillsToPluginFromSource(\n wizardResult.selectedSkills,\n pluginDir,\n sourceResult.matrix,\n sourceResult,\n );\n this.log(\n `✓ Plugin updated with ${wizardResult.selectedSkills.length} skills\\n`,\n );\n } catch (error) {\n this.handleError(error);\n }\n\n // Fetch agent partials\n let sourcePath: string;\n this.log(\n flags[\"agent-source\"]\n ? \"Fetching agent partials...\"\n : \"Loading agent partials...\",\n );\n try {\n const agentDefs = await getAgentDefinitions(flags[\"agent-source\"], {\n forceRefresh: flags.refresh,\n });\n sourcePath = agentDefs.sourcePath;\n this.log(\n flags[\"agent-source\"]\n ? \"✓ Agent partials fetched\\n\"\n : \"✓ Agent partials loaded\\n\",\n );\n } catch (error) {\n this.handleError(error);\n }\n\n // Recompile agents\n this.log(\"Recompiling agents...\");\n try {\n const recompileResult = await recompileAgents({\n pluginDir,\n sourcePath,\n });\n\n if (recompileResult.failed.length > 0) {\n this.log(\n `✓ Recompiled ${recompileResult.compiled.length} agents (${recompileResult.failed.length} failed)\\n`,\n );\n for (const warning of recompileResult.warnings) {\n this.warn(warning);\n }\n } else if (recompileResult.compiled.length > 0) {\n this.log(`✓ Recompiled ${recompileResult.compiled.length} agents\\n`);\n } else {\n this.log(\"✓ No agents to recompile\\n\");\n }\n } catch (error) {\n this.warn(\n `Agent recompilation failed: ${error instanceof Error ? error.message : String(error)}`,\n );\n this.log(\"You can manually recompile with 'cc compile'.\\n\");\n }\n\n // Update plugin version\n this.log(\"Updating plugin version...\");\n try {\n const newVersion = await bumpPluginVersion(pluginDir, \"patch\");\n this.log(`✓ Version bumped to ${newVersion}\\n`);\n } catch (error) {\n this.handleError(error);\n }\n\n this.log(\n `\\n✓ Plugin updated! (${addedSkills.length} added, ${removedSkills.length} removed)\\n`,\n );\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA,SAAS,aAAa;AACtB,SAAS,cAAc;AA6FjB;AA3EN,IAAqB,OAArB,MAAqB,cAAa,YAAY;AAAA,EAC5C,OAAO,UAAU;AAAA,EACjB,OAAO,cACL;AAAA,EAEF,OAAO,QAAQ;AAAA,IACb,GAAG,YAAY;AAAA,IACf,SAAS,MAAM,QAAQ;AAAA,MACrB,aAAa;AAAA,MACb,SAAS;AAAA,IACX,CAAC;AAAA,IACD,gBAAgB,MAAM,OAAO;AAAA,MAC3B,aAAa;AAAA,IACf,CAAC;AAAA,EACH;AAAA,EAEA,MAAM,MAAqB;AACzB,UAAM,EAAE,MAAM,IAAI,MAAM,KAAK,MAAM,KAAI;AAGvC,UAAM,eAAe,MAAM,mBAAmB;AAE9C,QAAI,CAAC,cAAc;AACjB,WAAK;AAAA,QACH;AAAA,QACA,EAAE,MAAM,WAAW,MAAM;AAAA,MAC3B;AAAA,IACF;AAEA,UAAM,YAAY,uBAAuB;AACzC,UAAM,kBACJ,aAAa,SAAS,UAClB,aAAa,YACb,mBAAmB,SAAS;AAElC,UAAM,YAAY,aAAa,SAAS,UAAU,UAAU;AAC5D,SAAK,IAAI,QAAQ,SAAS;AAAA,CAAW;AAGrC,SAAK,IAAI,iCAAiC;AAC1C,QAAI;AACJ,QAAI;AACF,qBAAe,MAAM,2BAA2B;AAAA,QAC9C,YAAY,MAAM;AAAA,QAClB,YAAY,QAAQ,IAAI;AAAA,QACxB,cAAc,MAAM;AAAA,MACtB,CAAC;AAED,YAAM,aAAa,a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C,QAAI;AACF,YAAM,kBAAkB,MAAM,gBAAgB;AAAA,QAC5C;AAAA,QACA;AAAA,MACF,CAAC;AAED,UAAI,gBAAgB,OAAO,SAAS,GAAG;AACrC,aAAK;AAAA,UACH,qBAAgB,gBAAgB,SAAS,MAAM,YAAY,gBAAgB,OAAO,MAAM;AAAA;AAAA,QAC1F;AACA,mBAAW,WAAW,gBAAgB,UAAU;AAC9C,eAAK,KAAK,OAAO;AAAA,QACnB;AAAA,MACF,WAAW,gBAAgB,SAAS,SAAS,GAAG;AAC9C,aAAK,IAAI,qBAAgB,gBAAgB,SAAS,MAAM;AAAA,CAAW;AAAA,MACrE,OAAO;AACL,aAAK,IAAI,iCAA4B;AAAA,MACvC;AAAA,IACF,SAAS,OAAO;AACd,WAAK;AAAA,QACH,+BAA+B,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK,CAAC;AAAA,MACvF;AACA,WAAK,IAAI,iDAAiD;AAAA,IAC5D;AAGA,SAAK,IAAI,4BAA4B;AACrC,QAAI;AACF,YAAM,aAAa,MAAM,kBAAkB,WAAW,OAAO;AAC7D,WAAK,IAAI,4BAAuB,UAAU;AAAA,CAAI;AAAA,IAChD,SAAS,OAAO;AACd,WAAK,YAAY,KAAK;AAAA,IACxB;AAEA,SAAK;AAAA,MACH;AAAA,0BAAwB,YAAY,MAAM,WAAW,cAAc,MAAM;AAAA;AAAA,IAC3E;AAAA,EACF;AACF;","names":[]}
|
|
@@ -0,0 +1,208 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import {
|
|
3
|
+
getCollectivePluginDir,
|
|
4
|
+
getPluginSkillsDir
|
|
5
|
+
} from "../chunk-3HBTELJN.js";
|
|
6
|
+
import {
|
|
7
|
+
DIRS,
|
|
8
|
+
PROJECT_ROOT
|
|
9
|
+
} from "../chunk-A3J6IAXK.js";
|
|
10
|
+
import {
|
|
11
|
+
BaseCommand,
|
|
12
|
+
EXIT_CODES
|
|
13
|
+
} from "../chunk-SYQ7R2JO.js";
|
|
14
|
+
import "../chunk-TOPAIL5W.js";
|
|
15
|
+
import {
|
|
16
|
+
copy,
|
|
17
|
+
directoryExists,
|
|
18
|
+
ensureDir,
|
|
19
|
+
fileExists,
|
|
20
|
+
writeFile
|
|
21
|
+
} from "../chunk-MMDXNZPF.js";
|
|
22
|
+
import {
|
|
23
|
+
init_esm_shims
|
|
24
|
+
} from "../chunk-DHET7RCE.js";
|
|
25
|
+
|
|
26
|
+
// src/cli-v2/commands/eject.ts
|
|
27
|
+
init_esm_shims();
|
|
28
|
+
import { Args, Flags } from "@oclif/core";
|
|
29
|
+
import path from "path";
|
|
30
|
+
import os from "os";
|
|
31
|
+
var EJECT_TYPES = ["templates", "config", "skills", "agents", "all"];
|
|
32
|
+
var DEFAULT_CONFIG_CONTENT = `# Claude Collective Configuration
|
|
33
|
+
# Agent-skill mappings for this project
|
|
34
|
+
|
|
35
|
+
name: my-project
|
|
36
|
+
description: Project description
|
|
37
|
+
|
|
38
|
+
# Agents to compile
|
|
39
|
+
agents:
|
|
40
|
+
- web-developer
|
|
41
|
+
- api-developer
|
|
42
|
+
- web-tester
|
|
43
|
+
- web-pm
|
|
44
|
+
|
|
45
|
+
# Agent-specific skill assignments (optional)
|
|
46
|
+
# If not specified, all available skills are given to all agents
|
|
47
|
+
agent_skills:
|
|
48
|
+
web-developer:
|
|
49
|
+
- react
|
|
50
|
+
- zustand
|
|
51
|
+
- scss-modules
|
|
52
|
+
api-developer:
|
|
53
|
+
- hono
|
|
54
|
+
- drizzle
|
|
55
|
+
- better-auth
|
|
56
|
+
`;
|
|
57
|
+
var Eject = class _Eject extends BaseCommand {
|
|
58
|
+
static summary = "Eject bundled content for local customization";
|
|
59
|
+
static description = "Copy templates, config, skills, or agent partials to your project for customization";
|
|
60
|
+
static args = {
|
|
61
|
+
type: Args.string({
|
|
62
|
+
description: "What to eject: templates, config, skills, agents, all",
|
|
63
|
+
required: false,
|
|
64
|
+
options: EJECT_TYPES
|
|
65
|
+
})
|
|
66
|
+
};
|
|
67
|
+
static flags = {
|
|
68
|
+
...BaseCommand.baseFlags,
|
|
69
|
+
force: Flags.boolean({
|
|
70
|
+
char: "f",
|
|
71
|
+
description: "Overwrite existing files",
|
|
72
|
+
default: false
|
|
73
|
+
}),
|
|
74
|
+
output: Flags.string({
|
|
75
|
+
char: "o",
|
|
76
|
+
description: "Output directory (default: .claude/ in current directory)"
|
|
77
|
+
})
|
|
78
|
+
};
|
|
79
|
+
async run() {
|
|
80
|
+
const { args, flags } = await this.parse(_Eject);
|
|
81
|
+
const projectDir = process.cwd();
|
|
82
|
+
if (!args.type) {
|
|
83
|
+
this.error(
|
|
84
|
+
"Please specify what to eject: templates, config, skills, agents, or all",
|
|
85
|
+
{ exit: EXIT_CODES.INVALID_ARGS }
|
|
86
|
+
);
|
|
87
|
+
}
|
|
88
|
+
if (!EJECT_TYPES.includes(args.type)) {
|
|
89
|
+
this.error(`Unknown eject type: ${args.type}`, {
|
|
90
|
+
exit: EXIT_CODES.INVALID_ARGS
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
let outputBase;
|
|
94
|
+
if (flags.output) {
|
|
95
|
+
const expandedPath = flags.output.startsWith("~") ? path.join(os.homedir(), flags.output.slice(1)) : flags.output;
|
|
96
|
+
outputBase = path.resolve(projectDir, expandedPath);
|
|
97
|
+
if (await fileExists(outputBase)) {
|
|
98
|
+
this.error(`Output path exists as a file: ${outputBase}`, {
|
|
99
|
+
exit: EXIT_CODES.INVALID_ARGS
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
} else {
|
|
103
|
+
outputBase = path.join(projectDir, ".claude");
|
|
104
|
+
}
|
|
105
|
+
this.log("");
|
|
106
|
+
this.log("Claude Collective Eject");
|
|
107
|
+
this.log("");
|
|
108
|
+
if (flags.output) {
|
|
109
|
+
this.log(`Output directory: ${outputBase}`);
|
|
110
|
+
}
|
|
111
|
+
const ejectType = args.type;
|
|
112
|
+
const directOutput = !!flags.output;
|
|
113
|
+
switch (ejectType) {
|
|
114
|
+
case "templates":
|
|
115
|
+
await this.ejectTemplates(outputBase, flags.force, directOutput);
|
|
116
|
+
break;
|
|
117
|
+
case "config":
|
|
118
|
+
await this.ejectConfig(outputBase, flags.force, directOutput);
|
|
119
|
+
break;
|
|
120
|
+
case "skills":
|
|
121
|
+
await this.ejectSkills(outputBase, flags.force, directOutput);
|
|
122
|
+
break;
|
|
123
|
+
case "agents":
|
|
124
|
+
await this.ejectAgents(outputBase, flags.force, directOutput);
|
|
125
|
+
break;
|
|
126
|
+
case "all":
|
|
127
|
+
await this.ejectTemplates(outputBase, flags.force, directOutput);
|
|
128
|
+
await this.ejectConfig(outputBase, flags.force, directOutput);
|
|
129
|
+
await this.ejectSkills(outputBase, flags.force, directOutput);
|
|
130
|
+
await this.ejectAgents(outputBase, flags.force, directOutput);
|
|
131
|
+
break;
|
|
132
|
+
}
|
|
133
|
+
this.log("");
|
|
134
|
+
this.logSuccess("Eject complete!");
|
|
135
|
+
this.log("");
|
|
136
|
+
}
|
|
137
|
+
async ejectTemplates(outputBase, force, directOutput = false) {
|
|
138
|
+
const sourceDir = path.join(PROJECT_ROOT, DIRS.templates);
|
|
139
|
+
const destDir = directOutput ? outputBase : path.join(outputBase, "templates");
|
|
140
|
+
if (await directoryExists(destDir) && !force) {
|
|
141
|
+
this.warn(
|
|
142
|
+
`Templates already exist at ${destDir}. Use --force to overwrite.`
|
|
143
|
+
);
|
|
144
|
+
return;
|
|
145
|
+
}
|
|
146
|
+
await ensureDir(destDir);
|
|
147
|
+
await copy(sourceDir, destDir);
|
|
148
|
+
this.logSuccess(`Templates ejected to ${destDir}`);
|
|
149
|
+
this.log("You can now customize agent.liquid and partials locally.");
|
|
150
|
+
}
|
|
151
|
+
async ejectConfig(outputBase, force, directOutput = false) {
|
|
152
|
+
const destPath = path.join(outputBase, "config.yaml");
|
|
153
|
+
if (await fileExists(destPath) && !force) {
|
|
154
|
+
this.warn(
|
|
155
|
+
`Config already exists at ${destPath}. Use --force to overwrite.`
|
|
156
|
+
);
|
|
157
|
+
return;
|
|
158
|
+
}
|
|
159
|
+
await ensureDir(path.dirname(destPath));
|
|
160
|
+
await writeFile(destPath, DEFAULT_CONFIG_CONTENT);
|
|
161
|
+
this.logSuccess(`Config template ejected to ${destPath}`);
|
|
162
|
+
this.log("Customize agent-skill mappings for your project.");
|
|
163
|
+
}
|
|
164
|
+
async ejectSkills(outputBase, force, directOutput = false) {
|
|
165
|
+
const pluginDir = getCollectivePluginDir();
|
|
166
|
+
const sourceDir = getPluginSkillsDir(pluginDir);
|
|
167
|
+
if (!await directoryExists(sourceDir)) {
|
|
168
|
+
this.warn("No skills found in installed plugin.");
|
|
169
|
+
this.log("Install skills with 'cc init' first, then try again.");
|
|
170
|
+
return;
|
|
171
|
+
}
|
|
172
|
+
const destDir = directOutput ? outputBase : path.join(outputBase, "skills");
|
|
173
|
+
if (await directoryExists(destDir) && !force) {
|
|
174
|
+
this.warn(
|
|
175
|
+
`Skills already exist at ${destDir}. Use --force to overwrite.`
|
|
176
|
+
);
|
|
177
|
+
return;
|
|
178
|
+
}
|
|
179
|
+
await ensureDir(destDir);
|
|
180
|
+
await copy(sourceDir, destDir);
|
|
181
|
+
this.logSuccess(`Skills ejected to ${destDir}`);
|
|
182
|
+
this.log("You can now customize skill content locally.");
|
|
183
|
+
}
|
|
184
|
+
async ejectAgents(outputBase, force, directOutput = false) {
|
|
185
|
+
const sourceDir = path.join(PROJECT_ROOT, DIRS.agents);
|
|
186
|
+
if (!await directoryExists(sourceDir)) {
|
|
187
|
+
this.warn("No agent partials found.");
|
|
188
|
+
return;
|
|
189
|
+
}
|
|
190
|
+
const destDir = directOutput ? outputBase : path.join(outputBase, "agents", "_partials");
|
|
191
|
+
if (await directoryExists(destDir) && !force) {
|
|
192
|
+
this.warn(
|
|
193
|
+
`Agent partials already exist at ${destDir}. Use --force to overwrite.`
|
|
194
|
+
);
|
|
195
|
+
return;
|
|
196
|
+
}
|
|
197
|
+
await ensureDir(destDir);
|
|
198
|
+
await copy(sourceDir, destDir);
|
|
199
|
+
this.logSuccess(`Agent partials ejected to ${destDir}`);
|
|
200
|
+
this.log(
|
|
201
|
+
"You can now customize agent intro, workflow, and examples locally."
|
|
202
|
+
);
|
|
203
|
+
}
|
|
204
|
+
};
|
|
205
|
+
export {
|
|
206
|
+
Eject as default
|
|
207
|
+
};
|
|
208
|
+
//# sourceMappingURL=eject.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/cli-v2/commands/eject.ts"],"sourcesContent":["import { Args, Flags } from \"@oclif/core\";\nimport path from \"path\";\nimport os from \"os\";\nimport { BaseCommand } from \"../base-command.js\";\nimport {\n copy,\n ensureDir,\n directoryExists,\n fileExists,\n writeFile,\n} from \"../utils/fs.js\";\nimport { DIRS, PROJECT_ROOT } from \"../consts.js\";\nimport {\n getCollectivePluginDir,\n getPluginSkillsDir,\n} from \"../lib/plugin-finder.js\";\nimport { EXIT_CODES } from \"../lib/exit-codes.js\";\n\nconst EJECT_TYPES = [\"templates\", \"config\", \"skills\", \"agents\", \"all\"] as const;\ntype EjectType = (typeof EJECT_TYPES)[number];\n\nconst DEFAULT_CONFIG_CONTENT = `# Claude Collective Configuration\n# Agent-skill mappings for this project\n\nname: my-project\ndescription: Project description\n\n# Agents to compile\nagents:\n - web-developer\n - api-developer\n - web-tester\n - web-pm\n\n# Agent-specific skill assignments (optional)\n# If not specified, all available skills are given to all agents\nagent_skills:\n web-developer:\n - react\n - zustand\n - scss-modules\n api-developer:\n - hono\n - drizzle\n - better-auth\n`;\n\nexport default class Eject extends BaseCommand {\n static summary = \"Eject bundled content for local customization\";\n static description =\n \"Copy templates, config, skills, or agent partials to your project for customization\";\n\n static args = {\n type: Args.string({\n description: \"What to eject: templates, config, skills, agents, all\",\n required: false,\n options: EJECT_TYPES as unknown as string[],\n }),\n };\n\n static flags = {\n ...BaseCommand.baseFlags,\n force: Flags.boolean({\n char: \"f\",\n description: \"Overwrite existing files\",\n default: false,\n }),\n output: Flags.string({\n char: \"o\",\n description: \"Output directory (default: .claude/ in current directory)\",\n }),\n };\n\n async run(): Promise<void> {\n const { args, flags } = await this.parse(Eject);\n const projectDir = process.cwd();\n\n if (!args.type) {\n this.error(\n \"Please specify what to eject: templates, config, skills, agents, or all\",\n { exit: EXIT_CODES.INVALID_ARGS },\n );\n }\n\n if (!EJECT_TYPES.includes(args.type as EjectType)) {\n this.error(`Unknown eject type: ${args.type}`, {\n exit: EXIT_CODES.INVALID_ARGS,\n });\n }\n\n // Resolve output base directory\n let outputBase: string;\n if (flags.output) {\n // Expand ~ to home directory if present\n const expandedPath = flags.output.startsWith(\"~\")\n ? path.join(os.homedir(), flags.output.slice(1))\n : flags.output;\n outputBase = path.resolve(projectDir, expandedPath);\n\n // Validate output path is not an existing file\n if (await fileExists(outputBase)) {\n this.error(`Output path exists as a file: ${outputBase}`, {\n exit: EXIT_CODES.INVALID_ARGS,\n });\n }\n } else {\n outputBase = path.join(projectDir, \".claude\");\n }\n\n this.log(\"\");\n this.log(\"Claude Collective Eject\");\n this.log(\"\");\n\n // Show output directory when using custom path\n if (flags.output) {\n this.log(`Output directory: ${outputBase}`);\n }\n\n const ejectType = args.type as EjectType;\n const directOutput = !!flags.output;\n\n switch (ejectType) {\n case \"templates\":\n await this.ejectTemplates(outputBase, flags.force, directOutput);\n break;\n case \"config\":\n await this.ejectConfig(outputBase, flags.force, directOutput);\n break;\n case \"skills\":\n await this.ejectSkills(outputBase, flags.force, directOutput);\n break;\n case \"agents\":\n await this.ejectAgents(outputBase, flags.force, directOutput);\n break;\n case \"all\":\n await this.ejectTemplates(outputBase, flags.force, directOutput);\n await this.ejectConfig(outputBase, flags.force, directOutput);\n await this.ejectSkills(outputBase, flags.force, directOutput);\n await this.ejectAgents(outputBase, flags.force, directOutput);\n break;\n }\n\n this.log(\"\");\n this.logSuccess(\"Eject complete!\");\n this.log(\"\");\n }\n\n private async ejectTemplates(\n outputBase: string,\n force: boolean,\n directOutput: boolean = false,\n ): Promise<void> {\n const sourceDir = path.join(PROJECT_ROOT, DIRS.templates);\n // When directOutput is true (--output used), write directly to outputBase\n // When false (default), add \"templates\" subdirectory for backward compatibility\n const destDir = directOutput\n ? outputBase\n : path.join(outputBase, \"templates\");\n\n if ((await directoryExists(destDir)) && !force) {\n this.warn(\n `Templates already exist at ${destDir}. Use --force to overwrite.`,\n );\n return;\n }\n\n await ensureDir(destDir);\n await copy(sourceDir, destDir);\n\n this.logSuccess(`Templates ejected to ${destDir}`);\n this.log(\"You can now customize agent.liquid and partials locally.\");\n }\n\n private async ejectConfig(\n outputBase: string,\n force: boolean,\n directOutput: boolean = false,\n ): Promise<void> {\n // Config always outputs to config.yaml in the specified location\n const destPath = path.join(outputBase, \"config.yaml\");\n\n if ((await fileExists(destPath)) && !force) {\n this.warn(\n `Config already exists at ${destPath}. Use --force to overwrite.`,\n );\n return;\n }\n\n await ensureDir(path.dirname(destPath));\n await writeFile(destPath, DEFAULT_CONFIG_CONTENT);\n\n this.logSuccess(`Config template ejected to ${destPath}`);\n this.log(\"Customize agent-skill mappings for your project.\");\n }\n\n private async ejectSkills(\n outputBase: string,\n force: boolean,\n directOutput: boolean = false,\n ): Promise<void> {\n // Find skills from installed plugin\n const pluginDir = getCollectivePluginDir();\n const sourceDir = getPluginSkillsDir(pluginDir);\n\n if (!(await directoryExists(sourceDir))) {\n this.warn(\"No skills found in installed plugin.\");\n this.log(\"Install skills with 'cc init' first, then try again.\");\n return;\n }\n\n // When directOutput is true (--output used), write directly to outputBase\n // When false (default), add \"skills\" subdirectory\n const destDir = directOutput ? outputBase : path.join(outputBase, \"skills\");\n\n if ((await directoryExists(destDir)) && !force) {\n this.warn(\n `Skills already exist at ${destDir}. Use --force to overwrite.`,\n );\n return;\n }\n\n await ensureDir(destDir);\n await copy(sourceDir, destDir);\n\n this.logSuccess(`Skills ejected to ${destDir}`);\n this.log(\"You can now customize skill content locally.\");\n }\n\n private async ejectAgents(\n outputBase: string,\n force: boolean,\n directOutput: boolean = false,\n ): Promise<void> {\n // Source is the agents directory from PROJECT_ROOT (excluding _templates)\n const sourceDir = path.join(PROJECT_ROOT, DIRS.agents);\n\n if (!(await directoryExists(sourceDir))) {\n this.warn(\"No agent partials found.\");\n return;\n }\n\n // When directOutput is true (--output used), write directly to outputBase\n // When false (default), add \"agents/_partials\" subdirectory\n const destDir = directOutput\n ? outputBase\n : path.join(outputBase, \"agents\", \"_partials\");\n\n if ((await directoryExists(destDir)) && !force) {\n this.warn(\n `Agent partials already exist at ${destDir}. Use --force to overwrite.`,\n );\n return;\n }\n\n await ensureDir(destDir);\n await copy(sourceDir, destDir);\n\n this.logSuccess(`Agent partials ejected to ${destDir}`);\n this.log(\n \"You can now customize agent intro, workflow, and examples locally.\",\n );\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA,SAAS,MAAM,aAAa;AAC5B,OAAO,UAAU;AACjB,OAAO,QAAQ;AAgBf,IAAM,cAAc,CAAC,aAAa,UAAU,UAAU,UAAU,KAAK;AAGrE,IAAM,yBAAyB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AA0B/B,IAAqB,QAArB,MAAqB,eAAc,YAAY;AAAA,EAC7C,OAAO,UAAU;AAAA,EACjB,OAAO,cACL;AAAA,EAEF,OAAO,OAAO;AAAA,IACZ,MAAM,KAAK,OAAO;AAAA,MAChB,aAAa;AAAA,MACb,UAAU;AAAA,MACV,SAAS;AAAA,IACX,CAAC;AAAA,EACH;AAAA,EAEA,OAAO,QAAQ;AAAA,IACb,GAAG,YAAY;AAAA,IACf,OAAO,MAAM,QAAQ;AAAA,MACnB,MAAM;AAAA,MACN,aAAa;AAAA,MACb,SAAS;AAAA,IACX,CAAC;AAAA,IACD,QAAQ,MAAM,OAAO;AAAA,MACnB,MAAM;AAAA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