fix: switch to jsonc-parser for config file parsing in vscode extension

This commit is contained in:
Bohdan Triapitsyn
2026-01-03 15:02:50 +02:00
parent b97399a5af
commit d971836962
3 changed files with 9 additions and 7 deletions
+5 -4
View File
@@ -74,7 +74,7 @@
},
"packages/desktop": {
"name": "@openchamber/desktop",
"version": "1.4.0",
"version": "1.4.2",
"dependencies": {
"@openchamber/ui": "workspace:*",
"@tauri-apps/plugin-notification": "^2.3.3",
@@ -97,7 +97,7 @@
},
"packages/ui": {
"name": "@openchamber/ui",
"version": "1.4.0",
"version": "1.4.2",
"dependencies": {
"@fontsource/ibm-plex-mono": "^5.2.7",
"@fontsource/ibm-plex-sans": "^5.1.1",
@@ -164,10 +164,11 @@
},
"packages/vscode": {
"name": "openchamber",
"version": "1.4.0",
"version": "1.4.2",
"dependencies": {
"@openchamber/ui": "workspace:*",
"@opencode-ai/sdk": "^1.0.209",
"jsonc-parser": "^3.3.1",
"react": "^19.1.1",
"react-dom": "^19.1.1",
"yaml": "^2.8.1",
@@ -184,7 +185,7 @@
},
"packages/web": {
"name": "@openchamber/web",
"version": "1.4.0",
"version": "1.4.2",
"bin": {
"openchamber": "./bin/cli.js",
},
+1
View File
@@ -175,6 +175,7 @@
"dependencies": {
"@openchamber/ui": "workspace:*",
"@opencode-ai/sdk": "^1.0.209",
"jsonc-parser": "^3.3.1",
"react": "^19.1.1",
"react-dom": "^19.1.1",
"yaml": "^2.8.1"
+3 -3
View File
@@ -2,7 +2,7 @@ import fs from 'node:fs';
import path from 'node:path';
import os from 'node:os';
import yaml from 'yaml';
import stripJsonComments from 'strip-json-comments';
import { parse as parseJsonc } from 'jsonc-parser';
const OPENCODE_CONFIG_DIR = path.join(os.homedir(), '.config', 'opencode');
const AGENT_DIR = path.join(OPENCODE_CONFIG_DIR, 'agent');
@@ -186,9 +186,9 @@ const getConfigPaths = (workingDirectory?: string) => ({
const readConfigFile = (filePath?: string | null): Record<string, unknown> => {
if (!filePath || !fs.existsSync(filePath)) return {};
const content = fs.readFileSync(filePath, 'utf8');
const normalized = stripJsonComments(content).trim();
const normalized = content.trim();
if (!normalized) return {};
return JSON.parse(normalized) as Record<string, unknown>;
return parseJsonc(normalized, [], { allowTrailingComma: true }) as Record<string, unknown>;
};
const isPlainObject = (value: unknown): value is Record<string, unknown> =>