@sk-labs/copilot-kit 3.0.2 → 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.
Files changed (2) hide show
  1. package/lib/commands.js +31 -6
  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'));
@@ -238,7 +248,8 @@ async function status(options) {
238
248
 
239
249
  if (fs.existsSync(vscodeSettingsPath)) {
240
250
  try {
241
- const settings = JSON.parse(fs.readFileSync(vscodeSettingsPath, 'utf8'));
251
+ const settingsContent = fs.readFileSync(vscodeSettingsPath, 'utf8');
252
+ const settings = parseJsonWithComments(settingsContent);
242
253
 
243
254
  // Check critical setting
244
255
  const criticalSetting = settings['chat.customAgentInSubagent.enabled'];
@@ -265,6 +276,7 @@ async function status(options) {
265
276
 
266
277
  } catch (error) {
267
278
  console.log(chalk.yellow('⚠️ settings.json exists but could not be parsed'));
279
+ console.log(chalk.dim(` Error: ${error.message}`));
268
280
  }
269
281
  } else {
270
282
  console.log(chalk.yellow('⚠️ .vscode/settings.json not found'));
@@ -327,6 +339,19 @@ function askQuestion(question) {
327
339
  });
328
340
  }
329
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
+
330
355
  function mergeSettings(existing, newSettings) {
331
356
  // Merge settings, with Copilot Kit settings taking priority
332
357
  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.3",
4
4
  "description": "CLI tool to install Custom Agents, Skills & Prompt Workflows for GitHub Copilot",
5
5
  "main": "index.js",
6
6
  "bin": {