@kood/claude-code 0.1.1 → 0.1.2
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/dist/index.js +70 -36
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -36,29 +36,51 @@ var getTemplatesDir = () => {
|
|
|
36
36
|
var getTemplatePath = (template) => {
|
|
37
37
|
return path.join(getTemplatesDir(), template);
|
|
38
38
|
};
|
|
39
|
-
var
|
|
39
|
+
var copyRecursive = async (src, dest, counter) => {
|
|
40
|
+
const stat = await fs.stat(src);
|
|
41
|
+
if (stat.isDirectory()) {
|
|
42
|
+
await fs.ensureDir(dest);
|
|
43
|
+
counter.directories++;
|
|
44
|
+
const items = await fs.readdir(src);
|
|
45
|
+
for (const item of items) {
|
|
46
|
+
await copyRecursive(path.join(src, item), path.join(dest, item), counter);
|
|
47
|
+
}
|
|
48
|
+
} else {
|
|
49
|
+
await fs.copy(src, dest);
|
|
50
|
+
counter.files++;
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
var copySingleTemplate = async (template, targetDir) => {
|
|
40
54
|
const templatePath = getTemplatePath(template);
|
|
41
55
|
if (!await fs.pathExists(templatePath)) {
|
|
42
56
|
throw new Error(`Template "${template}" not found at ${templatePath}`);
|
|
43
57
|
}
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
+
const counter = { files: 0, directories: 0 };
|
|
59
|
+
const claudeMdSrc = path.join(templatePath, "CLAUDE.md");
|
|
60
|
+
if (await fs.pathExists(claudeMdSrc)) {
|
|
61
|
+
await fs.copy(claudeMdSrc, path.join(targetDir, "CLAUDE.md"));
|
|
62
|
+
counter.files++;
|
|
63
|
+
}
|
|
64
|
+
const docsSrc = path.join(templatePath, "docs");
|
|
65
|
+
if (await fs.pathExists(docsSrc)) {
|
|
66
|
+
await copyRecursive(docsSrc, path.join(targetDir, "docs"), counter);
|
|
67
|
+
}
|
|
68
|
+
return counter;
|
|
69
|
+
};
|
|
70
|
+
var copyMultipleTemplates = async (templates, targetDir) => {
|
|
71
|
+
const counter = { files: 0, directories: 0 };
|
|
72
|
+
for (const template of templates) {
|
|
73
|
+
const templatePath = getTemplatePath(template);
|
|
74
|
+
if (!await fs.pathExists(templatePath)) {
|
|
75
|
+
throw new Error(`Template "${template}" not found at ${templatePath}`);
|
|
58
76
|
}
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
77
|
+
await copyRecursive(
|
|
78
|
+
templatePath,
|
|
79
|
+
path.join(targetDir, "docs", template),
|
|
80
|
+
counter
|
|
81
|
+
);
|
|
82
|
+
}
|
|
83
|
+
return counter;
|
|
62
84
|
};
|
|
63
85
|
var checkExistingFiles = async (targetDir) => {
|
|
64
86
|
const existingFiles = [];
|
|
@@ -116,14 +138,14 @@ var copySkills = async (template, targetDir) => {
|
|
|
116
138
|
let files = 0;
|
|
117
139
|
let directories = 0;
|
|
118
140
|
const installedSkills = [];
|
|
119
|
-
const
|
|
141
|
+
const copyRecursive2 = async (src, dest) => {
|
|
120
142
|
const stat = await fs.stat(src);
|
|
121
143
|
if (stat.isDirectory()) {
|
|
122
144
|
await fs.ensureDir(dest);
|
|
123
145
|
directories++;
|
|
124
146
|
const items = await fs.readdir(src);
|
|
125
147
|
for (const item of items) {
|
|
126
|
-
await
|
|
148
|
+
await copyRecursive2(path.join(src, item), path.join(dest, item));
|
|
127
149
|
}
|
|
128
150
|
} else {
|
|
129
151
|
await fs.copy(src, dest);
|
|
@@ -136,7 +158,7 @@ var copySkills = async (template, targetDir) => {
|
|
|
136
158
|
const skillDestPath = path.join(targetSkillsDir, skill);
|
|
137
159
|
const stat = await fs.stat(skillSrcPath);
|
|
138
160
|
if (stat.isDirectory()) {
|
|
139
|
-
await
|
|
161
|
+
await copyRecursive2(skillSrcPath, skillDestPath);
|
|
140
162
|
installedSkills.push(skill);
|
|
141
163
|
}
|
|
142
164
|
}
|
|
@@ -210,33 +232,45 @@ var init = async (options) => {
|
|
|
210
232
|
process.exit(0);
|
|
211
233
|
}
|
|
212
234
|
}
|
|
235
|
+
const isSingleTemplate = templates.length === 1;
|
|
213
236
|
let totalFiles = 0;
|
|
214
237
|
let totalDirectories = 0;
|
|
215
238
|
const allSkills = [];
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
239
|
+
logger.blank();
|
|
240
|
+
try {
|
|
241
|
+
if (isSingleTemplate) {
|
|
242
|
+
const template = templates[0];
|
|
243
|
+
logger.info(`Installing ${template} template...`);
|
|
244
|
+
logger.step(`Target: ${targetDir}`);
|
|
245
|
+
logger.blank();
|
|
246
|
+
const result = await copySingleTemplate(template, targetDir);
|
|
247
|
+
totalFiles = result.files;
|
|
248
|
+
totalDirectories = result.directories;
|
|
225
249
|
logger.success(`${template}: ${result.files} files copied`);
|
|
226
250
|
const availableSkills = await listAvailableSkills(template);
|
|
227
|
-
|
|
251
|
+
allSkills.push(...availableSkills);
|
|
252
|
+
} else {
|
|
253
|
+
logger.info(`Installing ${templates.length} templates...`);
|
|
254
|
+
logger.step(`Target: ${targetDir}/docs/`);
|
|
255
|
+
logger.blank();
|
|
256
|
+
const result = await copyMultipleTemplates(templates, targetDir);
|
|
257
|
+
totalFiles = result.files;
|
|
258
|
+
totalDirectories = result.directories;
|
|
259
|
+
for (const template of templates) {
|
|
260
|
+
logger.success(`${template}: installed to docs/${template}/`);
|
|
261
|
+
const availableSkills = await listAvailableSkills(template);
|
|
228
262
|
for (const skill of availableSkills) {
|
|
229
263
|
if (!allSkills.includes(skill)) {
|
|
230
264
|
allSkills.push(skill);
|
|
231
265
|
}
|
|
232
266
|
}
|
|
233
267
|
}
|
|
234
|
-
} catch (error) {
|
|
235
|
-
logger.error(
|
|
236
|
-
`Failed to install ${template}: ${error instanceof Error ? error.message : "Unknown error"}`
|
|
237
|
-
);
|
|
238
|
-
process.exit(1);
|
|
239
268
|
}
|
|
269
|
+
} catch (error) {
|
|
270
|
+
logger.error(
|
|
271
|
+
`Failed to install templates: ${error instanceof Error ? error.message : "Unknown error"}`
|
|
272
|
+
);
|
|
273
|
+
process.exit(1);
|
|
240
274
|
}
|
|
241
275
|
logger.blank();
|
|
242
276
|
logger.success(`Total: ${totalFiles} files, ${totalDirectories} directories`);
|