summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--package-lock.json2
-rw-r--r--packages/cli/package.json1
-rw-r--r--packages/cli/src/config/settings.ts5
3 files changed, 5 insertions, 3 deletions
diff --git a/package-lock.json b/package-lock.json
index 4cc3325f..3797ec58 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -7067,7 +7067,6 @@
"version": "3.1.1",
"resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-3.1.1.tgz",
"integrity": "sha512-6fPc+R4ihwqP6N/aIv2f1gMH8lOVtWQHoqC4yK6oSDVVocumAsfCqjkXnqiYMhmMwS/mEHLp7Vehlt3ql6lEig==",
- "dev": true,
"license": "MIT",
"engines": {
"node": ">=8"
@@ -8163,6 +8162,7 @@
"shell-quote": "^1.8.2",
"string-width": "^7.1.0",
"strip-ansi": "^7.1.0",
+ "strip-json-comments": "^3.1.1",
"yargs": "^17.7.2"
},
"bin": {
diff --git a/packages/cli/package.json b/packages/cli/package.json
index 433b9a58..0c088dc6 100644
--- a/packages/cli/package.json
+++ b/packages/cli/package.json
@@ -45,6 +45,7 @@
"shell-quote": "^1.8.2",
"string-width": "^7.1.0",
"strip-ansi": "^7.1.0",
+ "strip-json-comments": "^3.1.1",
"yargs": "^17.7.2"
},
"devDependencies": {
diff --git a/packages/cli/src/config/settings.ts b/packages/cli/src/config/settings.ts
index 1689a2f4..25ec5cb4 100644
--- a/packages/cli/src/config/settings.ts
+++ b/packages/cli/src/config/settings.ts
@@ -8,6 +8,7 @@ import * as fs from 'fs';
import * as path from 'path';
import { homedir } from 'os';
import { MCPServerConfig } from '@gemini-code/server/src/config/config.js';
+import stripJsonComments from 'strip-json-comments';
export const SETTINGS_DIRECTORY_NAME = '.gemini';
export const USER_SETTINGS_DIR = path.join(homedir(), SETTINGS_DIRECTORY_NAME);
@@ -92,7 +93,7 @@ export function loadSettings(workspaceDir: string): LoadedSettings {
try {
if (fs.existsSync(USER_SETTINGS_PATH)) {
const userContent = fs.readFileSync(USER_SETTINGS_PATH, 'utf-8');
- userSettings = JSON.parse(userContent);
+ userSettings = JSON.parse(stripJsonComments(userContent));
}
} catch (error) {
console.error('Error reading user settings file:', error);
@@ -108,7 +109,7 @@ export function loadSettings(workspaceDir: string): LoadedSettings {
try {
if (fs.existsSync(workspaceSettingsPath)) {
const projectContent = fs.readFileSync(workspaceSettingsPath, 'utf-8');
- workspaceSettings = JSON.parse(projectContent);
+ workspaceSettings = JSON.parse(stripJsonComments(projectContent));
}
} catch (error) {
console.error('Error reading workspace settings file:', error);