@sk-labs/copilot-kit 3.0.2 → 3.0.4

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.
Files changed (2) hide show
  1. package/lib/commands.js +41 -7
  2. package/package.json +1 -1
package/lib/commands.js CHANGED
@@ -77,7 +77,8 @@ async function init(options) {
77
77
  const vscodeSettingsEntry = entries.find(e => e.entryName === `${rootFolder}/.vscode/settings.json`);
78
78
 
79
79
  if (vscodeSettingsEntry) {
80
- const newSettings = JSON.parse(vscodeSettingsEntry.getData().toString('utf8'));
80
+ const newSettingsContent = vscodeSettingsEntry.getData().toString('utf8');
81
+ const newSettings = parseJsonWithComments(newSettingsContent);
81
82
 
82
83
  if (fs.existsSync(vscodeSettingsPath)) {
83
84
  // .vscode/settings.json already exists
@@ -99,10 +100,19 @@ async function init(options) {
99
100
  console.log(chalk.green('✓ Replaced .vscode/settings.json'));
100
101
  } else if (choice === 'm') {
101
102
  // 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'));
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
+ }
106
116
  } else {
107
117
  // Skip
108
118
  console.log(chalk.yellow('⊘ Skipped .vscode/settings.json'));
@@ -128,6 +138,9 @@ async function init(options) {
128
138
  console.log(chalk.dim(' 2. Test auto-detection: "Create a responsive card component"'));
129
139
  console.log(chalk.dim(' 3. Docs: https://github.com/sk-labs/copilot-kit\n'));
130
140
  }
141
+
142
+ // Ensure process exits cleanly
143
+ process.exit(0);
131
144
  } catch (error) {
132
145
  if (spinner) spinner.fail(chalk.red('Installation failed'));
133
146
  console.error(chalk.red('\n❌ Error:'), error.message);
@@ -182,6 +195,9 @@ async function update(options) {
182
195
  if (!options.quiet) {
183
196
  console.log(chalk.dim(`\n📦 Updated ${fileCount} files\n`));
184
197
  }
198
+
199
+ // Ensure process exits cleanly
200
+ process.exit(0);
185
201
  } catch (error) {
186
202
  if (spinner) spinner.fail(chalk.red('Update failed'));
187
203
  console.error(chalk.red('\n❌ Error:'), error.message);
@@ -200,7 +216,7 @@ async function status(options) {
200
216
  if (!fs.existsSync(githubPath)) {
201
217
  console.log(chalk.red('❌ Not installed'));
202
218
  console.log(chalk.dim(' Run "copilot-kit init" to install\n'));
203
- return;
219
+ process.exit(0);
204
220
  }
205
221
 
206
222
  console.log(chalk.green('✓ Installed'), chalk.dim(`at ${githubPath}`));
@@ -238,7 +254,8 @@ async function status(options) {
238
254
 
239
255
  if (fs.existsSync(vscodeSettingsPath)) {
240
256
  try {
241
- const settings = JSON.parse(fs.readFileSync(vscodeSettingsPath, 'utf8'));
257
+ const settingsContent = fs.readFileSync(vscodeSettingsPath, 'utf8');
258
+ const settings = parseJsonWithComments(settingsContent);
242
259
 
243
260
  // Check critical setting
244
261
  const criticalSetting = settings['chat.customAgentInSubagent.enabled'];
@@ -265,6 +282,7 @@ async function status(options) {
265
282
 
266
283
  } catch (error) {
267
284
  console.log(chalk.yellow('⚠️ settings.json exists but could not be parsed'));
285
+ console.log(chalk.dim(` Error: ${error.message}`));
268
286
  }
269
287
  } else {
270
288
  console.log(chalk.yellow('⚠️ .vscode/settings.json not found'));
@@ -272,6 +290,9 @@ async function status(options) {
272
290
  }
273
291
 
274
292
  console.log();
293
+
294
+ // Ensure process exits cleanly
295
+ process.exit(0);
275
296
  }
276
297
 
277
298
  function downloadRepo(branch = 'main') {
@@ -327,6 +348,19 @@ function askQuestion(question) {
327
348
  });
328
349
  }
329
350
 
351
+ function parseJsonWithComments(jsonString) {
352
+ // Remove single-line comments (// ...)
353
+ let cleaned = jsonString.replace(/\/\/.*$/gm, '');
354
+
355
+ // Remove multi-line comments (/* ... */)
356
+ cleaned = cleaned.replace(/\/\*[\s\S]*?\*\//g, '');
357
+
358
+ // Remove trailing commas before } or ]
359
+ cleaned = cleaned.replace(/,(\s*[}\]])/g, '$1');
360
+
361
+ return JSON.parse(cleaned);
362
+ }
363
+
330
364
  function mergeSettings(existing, newSettings) {
331
365
  // Merge settings, with Copilot Kit settings taking priority
332
366
  const merged = { ...existing };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sk-labs/copilot-kit",
3
- "version": "3.0.2",
3
+ "version": "3.0.4",
4
4
  "description": "CLI tool to install Custom Agents, Skills & Prompt Workflows for GitHub Copilot",
5
5
  "main": "index.js",
6
6
  "bin": {