nia-opencode 0.1.5 → 0.1.6
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/dist/cli.js +8 -6
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -95,12 +95,13 @@ function addPluginToConfig(configPath) {
|
|
|
95
95
|
console.log(" Plugin already registered in config");
|
|
96
96
|
return true;
|
|
97
97
|
}
|
|
98
|
-
const jsonContent = stripJsoncComments(content);
|
|
98
|
+
const jsonContent = stripJsoncComments(content).trim();
|
|
99
99
|
let config;
|
|
100
100
|
try {
|
|
101
|
-
config = JSON.parse(jsonContent);
|
|
101
|
+
config = jsonContent ? JSON.parse(jsonContent) : {};
|
|
102
102
|
} catch {
|
|
103
|
-
console.error(" Failed to parse config file");
|
|
103
|
+
console.error(" Failed to parse config file. Is it valid JSON?");
|
|
104
|
+
console.error(" Try: echo '{}' > " + configPath);
|
|
104
105
|
return false;
|
|
105
106
|
}
|
|
106
107
|
const plugins = config.plugin || [];
|
|
@@ -138,12 +139,13 @@ function addPluginToConfig(configPath) {
|
|
|
138
139
|
function addMcpServerToConfig(configPath, apiKey) {
|
|
139
140
|
try {
|
|
140
141
|
const content = readFileSync(configPath, "utf-8");
|
|
141
|
-
const jsonContent = stripJsoncComments(content);
|
|
142
|
+
const jsonContent = stripJsoncComments(content).trim();
|
|
142
143
|
let config;
|
|
143
144
|
try {
|
|
144
|
-
config = JSON.parse(jsonContent);
|
|
145
|
+
config = jsonContent ? JSON.parse(jsonContent) : {};
|
|
145
146
|
} catch {
|
|
146
|
-
console.error(" Failed to parse config file");
|
|
147
|
+
console.error(" Failed to parse config file. Is it valid JSON?");
|
|
148
|
+
console.error(" Try: echo '{}' > " + configPath);
|
|
147
149
|
return false;
|
|
148
150
|
}
|
|
149
151
|
const mcp = config.mcp || {};
|