@sk-labs/copilot-kit 3.0.1 ā 3.0.3
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/lib/commands.js +174 -8
- package/package.json +1 -1
package/lib/commands.js
CHANGED
|
@@ -12,6 +12,8 @@ const GITHUB_API = 'https://api.github.com';
|
|
|
12
12
|
async function init(options) {
|
|
13
13
|
const targetPath = path.resolve(options.path || '.');
|
|
14
14
|
const githubPath = path.join(targetPath, '.github');
|
|
15
|
+
const vscodePath = path.join(targetPath, '.vscode');
|
|
16
|
+
const vscodeSettingsPath = path.join(vscodePath, 'settings.json');
|
|
15
17
|
|
|
16
18
|
if (!options.quiet) {
|
|
17
19
|
console.log(chalk.bold.blue('\nš Copilot Kit Installer\n'));
|
|
@@ -25,7 +27,7 @@ async function init(options) {
|
|
|
25
27
|
|
|
26
28
|
if (!shouldOverwrite) {
|
|
27
29
|
console.log(chalk.yellow('Aborted.\n'));
|
|
28
|
-
process.exit(0);
|
|
30
|
+
process.exit(0);
|
|
29
31
|
}
|
|
30
32
|
}
|
|
31
33
|
|
|
@@ -33,6 +35,7 @@ async function init(options) {
|
|
|
33
35
|
console.log(chalk.cyan('š Dry run - no changes will be made\n'));
|
|
34
36
|
console.log(chalk.dim('Would download from:'), `https://github.com/${GITHUB_REPO}/archive/${options.branch}.zip`);
|
|
35
37
|
console.log(chalk.dim('Would install to:'), githubPath);
|
|
38
|
+
console.log(chalk.dim('Would install to:'), vscodePath);
|
|
36
39
|
return;
|
|
37
40
|
}
|
|
38
41
|
|
|
@@ -44,15 +47,15 @@ async function init(options) {
|
|
|
44
47
|
|
|
45
48
|
if (spinner) spinner.text = 'Extracting files...';
|
|
46
49
|
|
|
47
|
-
// Extract .github
|
|
50
|
+
// Extract .github and .vscode folders
|
|
48
51
|
const zip = new AdmZip(zipBuffer);
|
|
49
52
|
const entries = zip.getEntries();
|
|
50
53
|
|
|
51
54
|
// Find the root folder name (copilot-kit-main or similar)
|
|
52
55
|
const rootFolder = entries[0].entryName.split('/')[0];
|
|
53
56
|
|
|
54
|
-
// Extract
|
|
55
|
-
let
|
|
57
|
+
// Extract .github folder
|
|
58
|
+
let githubFileCount = 0;
|
|
56
59
|
entries.forEach(entry => {
|
|
57
60
|
if (entry.entryName.startsWith(`${rootFolder}/.github/`)) {
|
|
58
61
|
const relativePath = entry.entryName.replace(`${rootFolder}/`, '');
|
|
@@ -63,18 +66,76 @@ async function init(options) {
|
|
|
63
66
|
} else {
|
|
64
67
|
fs.mkdirSync(path.dirname(targetFile), { recursive: true });
|
|
65
68
|
fs.writeFileSync(targetFile, entry.getData());
|
|
66
|
-
|
|
69
|
+
githubFileCount++;
|
|
67
70
|
}
|
|
68
71
|
}
|
|
69
72
|
});
|
|
70
73
|
|
|
74
|
+
// Handle .vscode/settings.json
|
|
75
|
+
if (spinner) spinner.text = 'Configuring VS Code settings...';
|
|
76
|
+
|
|
77
|
+
const vscodeSettingsEntry = entries.find(e => e.entryName === `${rootFolder}/.vscode/settings.json`);
|
|
78
|
+
|
|
79
|
+
if (vscodeSettingsEntry) {
|
|
80
|
+
const newSettingsContent = vscodeSettingsEntry.getData().toString('utf8');
|
|
81
|
+
const newSettings = parseJsonWithComments(newSettingsContent);
|
|
82
|
+
|
|
83
|
+
if (fs.existsSync(vscodeSettingsPath)) {
|
|
84
|
+
// .vscode/settings.json already exists
|
|
85
|
+
if (spinner) spinner.stop();
|
|
86
|
+
|
|
87
|
+
console.log(chalk.yellow('\nā ļø .vscode/settings.json already exists!'));
|
|
88
|
+
console.log(chalk.dim('Choose an option:'));
|
|
89
|
+
console.log(chalk.dim(' [R] Replace - Overwrite with Copilot Kit settings'));
|
|
90
|
+
console.log(chalk.dim(' [M] Merge - Add Copilot Kit settings to existing (recommended)'));
|
|
91
|
+
console.log(chalk.dim(' [S] Skip - Keep existing settings'));
|
|
92
|
+
|
|
93
|
+
const answer = await askQuestion(chalk.bold('\nYour choice (R/M/S): '));
|
|
94
|
+
const choice = answer.trim().toLowerCase();
|
|
95
|
+
|
|
96
|
+
if (choice === 'r') {
|
|
97
|
+
// Replace
|
|
98
|
+
fs.mkdirSync(vscodePath, { recursive: true });
|
|
99
|
+
fs.writeFileSync(vscodeSettingsPath, JSON.stringify(newSettings, null, 2));
|
|
100
|
+
console.log(chalk.green('ā Replaced .vscode/settings.json'));
|
|
101
|
+
} else if (choice === 'm') {
|
|
102
|
+
// Merge
|
|
103
|
+
try {
|
|
104
|
+
const existingContent = fs.readFileSync(vscodeSettingsPath, 'utf8');
|
|
105
|
+
const existingSettings = parseJsonWithComments(existingContent);
|
|
106
|
+
const mergedSettings = mergeSettings(existingSettings, newSettings);
|
|
107
|
+
fs.writeFileSync(vscodeSettingsPath, JSON.stringify(mergedSettings, null, 2));
|
|
108
|
+
console.log(chalk.green('ā Merged Copilot Kit settings into existing settings.json'));
|
|
109
|
+
} catch (error) {
|
|
110
|
+
console.log(chalk.red('ā Failed to merge settings:'), error.message);
|
|
111
|
+
console.log(chalk.yellow(' Creating backup and replacing...'));
|
|
112
|
+
fs.copyFileSync(vscodeSettingsPath, `${vscodeSettingsPath}.backup`);
|
|
113
|
+
fs.writeFileSync(vscodeSettingsPath, JSON.stringify(newSettings, null, 2));
|
|
114
|
+
console.log(chalk.green('ā Replaced settings (backup saved)'));
|
|
115
|
+
}
|
|
116
|
+
} else {
|
|
117
|
+
// Skip
|
|
118
|
+
console.log(chalk.yellow('ā Skipped .vscode/settings.json'));
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
if (spinner) spinner.start();
|
|
122
|
+
} else {
|
|
123
|
+
// No existing settings.json, create new
|
|
124
|
+
fs.mkdirSync(vscodePath, { recursive: true });
|
|
125
|
+
fs.writeFileSync(vscodeSettingsPath, JSON.stringify(newSettings, null, 2));
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
|
|
71
129
|
if (spinner) spinner.succeed(chalk.green('ā Copilot Kit installed successfully!'));
|
|
72
130
|
|
|
73
131
|
if (!options.quiet) {
|
|
74
|
-
console.log(chalk.dim(`\nš¦ Installed ${
|
|
132
|
+
console.log(chalk.dim(`\nš¦ Installed ${githubFileCount} files to ${githubPath}`));
|
|
133
|
+
console.log(chalk.dim(`š¦ Configured VS Code settings at ${vscodeSettingsPath}\n`));
|
|
134
|
+
console.log(chalk.bold('š“ CRITICAL: Reload VS Code for settings to take effect!'));
|
|
135
|
+
console.log(chalk.dim(' Press Ctrl+Shift+P ā "Developer: Reload Window"\n'));
|
|
75
136
|
console.log(chalk.bold('Next steps:'));
|
|
76
|
-
console.log(chalk.dim(' 1.
|
|
77
|
-
console.log(chalk.dim(' 2.
|
|
137
|
+
console.log(chalk.dim(' 1. Reload VS Code (Ctrl+Shift+P ā Reload Window)'));
|
|
138
|
+
console.log(chalk.dim(' 2. Test auto-detection: "Create a responsive card component"'));
|
|
78
139
|
console.log(chalk.dim(' 3. Docs: https://github.com/sk-labs/copilot-kit\n'));
|
|
79
140
|
}
|
|
80
141
|
} catch (error) {
|
|
@@ -141,6 +202,8 @@ async function update(options) {
|
|
|
141
202
|
async function status(options) {
|
|
142
203
|
const targetPath = path.resolve(options.path || '.');
|
|
143
204
|
const githubPath = path.join(targetPath, '.github');
|
|
205
|
+
const vscodePath = path.join(targetPath, '.vscode');
|
|
206
|
+
const vscodeSettingsPath = path.join(vscodePath, 'settings.json');
|
|
144
207
|
|
|
145
208
|
console.log(chalk.bold.blue('\nš Copilot Kit Status\n'));
|
|
146
209
|
|
|
@@ -179,6 +242,47 @@ async function status(options) {
|
|
|
179
242
|
}
|
|
180
243
|
});
|
|
181
244
|
|
|
245
|
+
// Check VS Code settings
|
|
246
|
+
console.log();
|
|
247
|
+
console.log(chalk.bold('VS Code Configuration:'));
|
|
248
|
+
|
|
249
|
+
if (fs.existsSync(vscodeSettingsPath)) {
|
|
250
|
+
try {
|
|
251
|
+
const settingsContent = fs.readFileSync(vscodeSettingsPath, 'utf8');
|
|
252
|
+
const settings = parseJsonWithComments(settingsContent);
|
|
253
|
+
|
|
254
|
+
// Check critical setting
|
|
255
|
+
const criticalSetting = settings['chat.customAgentInSubagent.enabled'];
|
|
256
|
+
if (criticalSetting === true) {
|
|
257
|
+
console.log(chalk.green('ā Auto-detection enabled'), chalk.dim('(chat.customAgentInSubagent.enabled)'));
|
|
258
|
+
} else {
|
|
259
|
+
console.log(chalk.red('ā Auto-detection disabled'), chalk.dim('(chat.customAgentInSubagent.enabled)'));
|
|
260
|
+
console.log(chalk.yellow(' ā ļø Run "copilot-kit init" to configure settings'));
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
// Check other important settings
|
|
264
|
+
const importantSettings = [
|
|
265
|
+
'chat.agentFilesLocations',
|
|
266
|
+
'chat.useAgentSkills',
|
|
267
|
+
'chat.agentSkillsLocations'
|
|
268
|
+
];
|
|
269
|
+
|
|
270
|
+
let configuredCount = 0;
|
|
271
|
+
importantSettings.forEach(key => {
|
|
272
|
+
if (settings[key] !== undefined) configuredCount++;
|
|
273
|
+
});
|
|
274
|
+
|
|
275
|
+
console.log(chalk.dim(` ${configuredCount}/${importantSettings.length} important settings configured`));
|
|
276
|
+
|
|
277
|
+
} catch (error) {
|
|
278
|
+
console.log(chalk.yellow('ā ļø settings.json exists but could not be parsed'));
|
|
279
|
+
console.log(chalk.dim(` Error: ${error.message}`));
|
|
280
|
+
}
|
|
281
|
+
} else {
|
|
282
|
+
console.log(chalk.yellow('ā ļø .vscode/settings.json not found'));
|
|
283
|
+
console.log(chalk.dim(' Run "copilot-kit init" to create it'));
|
|
284
|
+
}
|
|
285
|
+
|
|
182
286
|
console.log();
|
|
183
287
|
}
|
|
184
288
|
|
|
@@ -221,4 +325,66 @@ function askConfirmation(question) {
|
|
|
221
325
|
});
|
|
222
326
|
}
|
|
223
327
|
|
|
328
|
+
function askQuestion(question) {
|
|
329
|
+
const rl = readline.createInterface({
|
|
330
|
+
input: process.stdin,
|
|
331
|
+
output: process.stdout
|
|
332
|
+
});
|
|
333
|
+
|
|
334
|
+
return new Promise(resolve => {
|
|
335
|
+
rl.question(question, (answer) => {
|
|
336
|
+
rl.close();
|
|
337
|
+
resolve(answer);
|
|
338
|
+
});
|
|
339
|
+
});
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
function parseJsonWithComments(jsonString) {
|
|
343
|
+
// Remove single-line comments (// ...)
|
|
344
|
+
let cleaned = jsonString.replace(/\/\/.*$/gm, '');
|
|
345
|
+
|
|
346
|
+
// Remove multi-line comments (/* ... */)
|
|
347
|
+
cleaned = cleaned.replace(/\/\*[\s\S]*?\*\//g, '');
|
|
348
|
+
|
|
349
|
+
// Remove trailing commas before } or ]
|
|
350
|
+
cleaned = cleaned.replace(/,(\s*[}\]])/g, '$1');
|
|
351
|
+
|
|
352
|
+
return JSON.parse(cleaned);
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
function mergeSettings(existing, newSettings) {
|
|
356
|
+
// Merge settings, with Copilot Kit settings taking priority
|
|
357
|
+
const merged = { ...existing };
|
|
358
|
+
|
|
359
|
+
// Copilot Kit critical settings (always override)
|
|
360
|
+
const criticalSettings = [
|
|
361
|
+
'chat.customAgentInSubagent.enabled',
|
|
362
|
+
'chat.agentFilesLocations',
|
|
363
|
+
'chat.agent.enabled',
|
|
364
|
+
'chat.useAgentSkills',
|
|
365
|
+
'chat.agentSkillsLocations',
|
|
366
|
+
'github.copilot.chat.codeGeneration.useInstructionFiles',
|
|
367
|
+
'chat.instructionsFilesLocations',
|
|
368
|
+
'chat.includeApplyingInstructions',
|
|
369
|
+
'chat.promptFilesLocations',
|
|
370
|
+
'chat.useAgentsMdFile'
|
|
371
|
+
];
|
|
372
|
+
|
|
373
|
+
// Override critical settings
|
|
374
|
+
criticalSettings.forEach(key => {
|
|
375
|
+
if (newSettings[key] !== undefined) {
|
|
376
|
+
merged[key] = newSettings[key];
|
|
377
|
+
}
|
|
378
|
+
});
|
|
379
|
+
|
|
380
|
+
// Add other Copilot Kit settings if not present
|
|
381
|
+
Object.keys(newSettings).forEach(key => {
|
|
382
|
+
if (merged[key] === undefined) {
|
|
383
|
+
merged[key] = newSettings[key];
|
|
384
|
+
}
|
|
385
|
+
});
|
|
386
|
+
|
|
387
|
+
return merged;
|
|
388
|
+
}
|
|
389
|
+
|
|
224
390
|
module.exports = { init, update, status };
|