@sk-labs/copilot-kit 3.0.0 ā 3.0.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/lib/commands.js +170 -9
- package/package.json +1 -1
package/lib/commands.js
CHANGED
|
@@ -4,6 +4,7 @@ const https = require('https');
|
|
|
4
4
|
const chalk = require('chalk');
|
|
5
5
|
const ora = require('ora');
|
|
6
6
|
const AdmZip = require('adm-zip');
|
|
7
|
+
const readline = require('readline');
|
|
7
8
|
|
|
8
9
|
const GITHUB_REPO = 'sk-labs/copilot-kit';
|
|
9
10
|
const GITHUB_API = 'https://api.github.com';
|
|
@@ -11,6 +12,8 @@ const GITHUB_API = 'https://api.github.com';
|
|
|
11
12
|
async function init(options) {
|
|
12
13
|
const targetPath = path.resolve(options.path || '.');
|
|
13
14
|
const githubPath = path.join(targetPath, '.github');
|
|
15
|
+
const vscodePath = path.join(targetPath, '.vscode');
|
|
16
|
+
const vscodeSettingsPath = path.join(vscodePath, 'settings.json');
|
|
14
17
|
|
|
15
18
|
if (!options.quiet) {
|
|
16
19
|
console.log(chalk.bold.blue('\nš Copilot Kit Installer\n'));
|
|
@@ -19,14 +22,20 @@ async function init(options) {
|
|
|
19
22
|
// Check if .github exists
|
|
20
23
|
if (fs.existsSync(githubPath) && !options.force && !options.dryRun) {
|
|
21
24
|
console.log(chalk.yellow('ā ļø .github folder already exists!'));
|
|
22
|
-
|
|
23
|
-
|
|
25
|
+
|
|
26
|
+
const shouldOverwrite = await askConfirmation(chalk.bold('Do you want to overwrite it? (y/N) '));
|
|
27
|
+
|
|
28
|
+
if (!shouldOverwrite) {
|
|
29
|
+
console.log(chalk.yellow('Aborted.\n'));
|
|
30
|
+
process.exit(0);
|
|
31
|
+
}
|
|
24
32
|
}
|
|
25
33
|
|
|
26
34
|
if (options.dryRun) {
|
|
27
35
|
console.log(chalk.cyan('š Dry run - no changes will be made\n'));
|
|
28
36
|
console.log(chalk.dim('Would download from:'), `https://github.com/${GITHUB_REPO}/archive/${options.branch}.zip`);
|
|
29
37
|
console.log(chalk.dim('Would install to:'), githubPath);
|
|
38
|
+
console.log(chalk.dim('Would install to:'), vscodePath);
|
|
30
39
|
return;
|
|
31
40
|
}
|
|
32
41
|
|
|
@@ -38,15 +47,15 @@ async function init(options) {
|
|
|
38
47
|
|
|
39
48
|
if (spinner) spinner.text = 'Extracting files...';
|
|
40
49
|
|
|
41
|
-
// Extract .github
|
|
50
|
+
// Extract .github and .vscode folders
|
|
42
51
|
const zip = new AdmZip(zipBuffer);
|
|
43
52
|
const entries = zip.getEntries();
|
|
44
53
|
|
|
45
54
|
// Find the root folder name (copilot-kit-main or similar)
|
|
46
55
|
const rootFolder = entries[0].entryName.split('/')[0];
|
|
47
56
|
|
|
48
|
-
// Extract
|
|
49
|
-
let
|
|
57
|
+
// Extract .github folder
|
|
58
|
+
let githubFileCount = 0;
|
|
50
59
|
entries.forEach(entry => {
|
|
51
60
|
if (entry.entryName.startsWith(`${rootFolder}/.github/`)) {
|
|
52
61
|
const relativePath = entry.entryName.replace(`${rootFolder}/`, '');
|
|
@@ -57,18 +66,66 @@ async function init(options) {
|
|
|
57
66
|
} else {
|
|
58
67
|
fs.mkdirSync(path.dirname(targetFile), { recursive: true });
|
|
59
68
|
fs.writeFileSync(targetFile, entry.getData());
|
|
60
|
-
|
|
69
|
+
githubFileCount++;
|
|
61
70
|
}
|
|
62
71
|
}
|
|
63
72
|
});
|
|
64
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 newSettings = JSON.parse(vscodeSettingsEntry.getData().toString('utf8'));
|
|
81
|
+
|
|
82
|
+
if (fs.existsSync(vscodeSettingsPath)) {
|
|
83
|
+
// .vscode/settings.json already exists
|
|
84
|
+
if (spinner) spinner.stop();
|
|
85
|
+
|
|
86
|
+
console.log(chalk.yellow('\nā ļø .vscode/settings.json already exists!'));
|
|
87
|
+
console.log(chalk.dim('Choose an option:'));
|
|
88
|
+
console.log(chalk.dim(' [R] Replace - Overwrite with Copilot Kit settings'));
|
|
89
|
+
console.log(chalk.dim(' [M] Merge - Add Copilot Kit settings to existing (recommended)'));
|
|
90
|
+
console.log(chalk.dim(' [S] Skip - Keep existing settings'));
|
|
91
|
+
|
|
92
|
+
const answer = await askQuestion(chalk.bold('\nYour choice (R/M/S): '));
|
|
93
|
+
const choice = answer.trim().toLowerCase();
|
|
94
|
+
|
|
95
|
+
if (choice === 'r') {
|
|
96
|
+
// Replace
|
|
97
|
+
fs.mkdirSync(vscodePath, { recursive: true });
|
|
98
|
+
fs.writeFileSync(vscodeSettingsPath, JSON.stringify(newSettings, null, 2));
|
|
99
|
+
console.log(chalk.green('ā Replaced .vscode/settings.json'));
|
|
100
|
+
} else if (choice === 'm') {
|
|
101
|
+
// Merge
|
|
102
|
+
const existingSettings = JSON.parse(fs.readFileSync(vscodeSettingsPath, 'utf8'));
|
|
103
|
+
const mergedSettings = mergeSettings(existingSettings, newSettings);
|
|
104
|
+
fs.writeFileSync(vscodeSettingsPath, JSON.stringify(mergedSettings, null, 2));
|
|
105
|
+
console.log(chalk.green('ā Merged Copilot Kit settings into existing settings.json'));
|
|
106
|
+
} else {
|
|
107
|
+
// Skip
|
|
108
|
+
console.log(chalk.yellow('ā Skipped .vscode/settings.json'));
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
if (spinner) spinner.start();
|
|
112
|
+
} else {
|
|
113
|
+
// No existing settings.json, create new
|
|
114
|
+
fs.mkdirSync(vscodePath, { recursive: true });
|
|
115
|
+
fs.writeFileSync(vscodeSettingsPath, JSON.stringify(newSettings, null, 2));
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
|
|
65
119
|
if (spinner) spinner.succeed(chalk.green('ā Copilot Kit installed successfully!'));
|
|
66
120
|
|
|
67
121
|
if (!options.quiet) {
|
|
68
|
-
console.log(chalk.dim(`\nš¦ Installed ${
|
|
122
|
+
console.log(chalk.dim(`\nš¦ Installed ${githubFileCount} files to ${githubPath}`));
|
|
123
|
+
console.log(chalk.dim(`š¦ Configured VS Code settings at ${vscodeSettingsPath}\n`));
|
|
124
|
+
console.log(chalk.bold('š“ CRITICAL: Reload VS Code for settings to take effect!'));
|
|
125
|
+
console.log(chalk.dim(' Press Ctrl+Shift+P ā "Developer: Reload Window"\n'));
|
|
69
126
|
console.log(chalk.bold('Next steps:'));
|
|
70
|
-
console.log(chalk.dim(' 1.
|
|
71
|
-
console.log(chalk.dim(' 2.
|
|
127
|
+
console.log(chalk.dim(' 1. Reload VS Code (Ctrl+Shift+P ā Reload Window)'));
|
|
128
|
+
console.log(chalk.dim(' 2. Test auto-detection: "Create a responsive card component"'));
|
|
72
129
|
console.log(chalk.dim(' 3. Docs: https://github.com/sk-labs/copilot-kit\n'));
|
|
73
130
|
}
|
|
74
131
|
} catch (error) {
|
|
@@ -135,6 +192,8 @@ async function update(options) {
|
|
|
135
192
|
async function status(options) {
|
|
136
193
|
const targetPath = path.resolve(options.path || '.');
|
|
137
194
|
const githubPath = path.join(targetPath, '.github');
|
|
195
|
+
const vscodePath = path.join(targetPath, '.vscode');
|
|
196
|
+
const vscodeSettingsPath = path.join(vscodePath, 'settings.json');
|
|
138
197
|
|
|
139
198
|
console.log(chalk.bold.blue('\nš Copilot Kit Status\n'));
|
|
140
199
|
|
|
@@ -173,6 +232,45 @@ async function status(options) {
|
|
|
173
232
|
}
|
|
174
233
|
});
|
|
175
234
|
|
|
235
|
+
// Check VS Code settings
|
|
236
|
+
console.log();
|
|
237
|
+
console.log(chalk.bold('VS Code Configuration:'));
|
|
238
|
+
|
|
239
|
+
if (fs.existsSync(vscodeSettingsPath)) {
|
|
240
|
+
try {
|
|
241
|
+
const settings = JSON.parse(fs.readFileSync(vscodeSettingsPath, 'utf8'));
|
|
242
|
+
|
|
243
|
+
// Check critical setting
|
|
244
|
+
const criticalSetting = settings['chat.customAgentInSubagent.enabled'];
|
|
245
|
+
if (criticalSetting === true) {
|
|
246
|
+
console.log(chalk.green('ā Auto-detection enabled'), chalk.dim('(chat.customAgentInSubagent.enabled)'));
|
|
247
|
+
} else {
|
|
248
|
+
console.log(chalk.red('ā Auto-detection disabled'), chalk.dim('(chat.customAgentInSubagent.enabled)'));
|
|
249
|
+
console.log(chalk.yellow(' ā ļø Run "copilot-kit init" to configure settings'));
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
// Check other important settings
|
|
253
|
+
const importantSettings = [
|
|
254
|
+
'chat.agentFilesLocations',
|
|
255
|
+
'chat.useAgentSkills',
|
|
256
|
+
'chat.agentSkillsLocations'
|
|
257
|
+
];
|
|
258
|
+
|
|
259
|
+
let configuredCount = 0;
|
|
260
|
+
importantSettings.forEach(key => {
|
|
261
|
+
if (settings[key] !== undefined) configuredCount++;
|
|
262
|
+
});
|
|
263
|
+
|
|
264
|
+
console.log(chalk.dim(` ${configuredCount}/${importantSettings.length} important settings configured`));
|
|
265
|
+
|
|
266
|
+
} catch (error) {
|
|
267
|
+
console.log(chalk.yellow('ā ļø settings.json exists but could not be parsed'));
|
|
268
|
+
}
|
|
269
|
+
} else {
|
|
270
|
+
console.log(chalk.yellow('ā ļø .vscode/settings.json not found'));
|
|
271
|
+
console.log(chalk.dim(' Run "copilot-kit init" to create it'));
|
|
272
|
+
}
|
|
273
|
+
|
|
176
274
|
console.log();
|
|
177
275
|
}
|
|
178
276
|
|
|
@@ -201,4 +299,67 @@ function downloadRepo(branch = 'main') {
|
|
|
201
299
|
});
|
|
202
300
|
}
|
|
203
301
|
|
|
302
|
+
function askConfirmation(question) {
|
|
303
|
+
const rl = readline.createInterface({
|
|
304
|
+
input: process.stdin,
|
|
305
|
+
output: process.stdout
|
|
306
|
+
});
|
|
307
|
+
|
|
308
|
+
return new Promise(resolve => {
|
|
309
|
+
rl.question(question, (answer) => {
|
|
310
|
+
rl.close();
|
|
311
|
+
resolve(answer.trim().toLowerCase().startsWith('y'));
|
|
312
|
+
});
|
|
313
|
+
});
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
function askQuestion(question) {
|
|
317
|
+
const rl = readline.createInterface({
|
|
318
|
+
input: process.stdin,
|
|
319
|
+
output: process.stdout
|
|
320
|
+
});
|
|
321
|
+
|
|
322
|
+
return new Promise(resolve => {
|
|
323
|
+
rl.question(question, (answer) => {
|
|
324
|
+
rl.close();
|
|
325
|
+
resolve(answer);
|
|
326
|
+
});
|
|
327
|
+
});
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
function mergeSettings(existing, newSettings) {
|
|
331
|
+
// Merge settings, with Copilot Kit settings taking priority
|
|
332
|
+
const merged = { ...existing };
|
|
333
|
+
|
|
334
|
+
// Copilot Kit critical settings (always override)
|
|
335
|
+
const criticalSettings = [
|
|
336
|
+
'chat.customAgentInSubagent.enabled',
|
|
337
|
+
'chat.agentFilesLocations',
|
|
338
|
+
'chat.agent.enabled',
|
|
339
|
+
'chat.useAgentSkills',
|
|
340
|
+
'chat.agentSkillsLocations',
|
|
341
|
+
'github.copilot.chat.codeGeneration.useInstructionFiles',
|
|
342
|
+
'chat.instructionsFilesLocations',
|
|
343
|
+
'chat.includeApplyingInstructions',
|
|
344
|
+
'chat.promptFilesLocations',
|
|
345
|
+
'chat.useAgentsMdFile'
|
|
346
|
+
];
|
|
347
|
+
|
|
348
|
+
// Override critical settings
|
|
349
|
+
criticalSettings.forEach(key => {
|
|
350
|
+
if (newSettings[key] !== undefined) {
|
|
351
|
+
merged[key] = newSettings[key];
|
|
352
|
+
}
|
|
353
|
+
});
|
|
354
|
+
|
|
355
|
+
// Add other Copilot Kit settings if not present
|
|
356
|
+
Object.keys(newSettings).forEach(key => {
|
|
357
|
+
if (merged[key] === undefined) {
|
|
358
|
+
merged[key] = newSettings[key];
|
|
359
|
+
}
|
|
360
|
+
});
|
|
361
|
+
|
|
362
|
+
return merged;
|
|
363
|
+
}
|
|
364
|
+
|
|
204
365
|
module.exports = { init, update, status };
|