nia-opencode 0.1.4 → 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 +11 -8
- 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 || {};
|
|
@@ -234,13 +236,14 @@ async function install(options) {
|
|
|
234
236
|
console.log("Step 1: Configure API Key");
|
|
235
237
|
let apiKey = options.apiKey || process.env.NIA_API_KEY || "";
|
|
236
238
|
if (!apiKey && options.tui && rl) {
|
|
237
|
-
console.log(
|
|
239
|
+
console.log("Get your API key from: https://app.trynia.ai");
|
|
240
|
+
console.log(`New user? Run: curl -fsSL https://app.trynia.ai/cli | sh
|
|
238
241
|
`);
|
|
239
242
|
apiKey = await prompt(rl, "Enter your Nia API key (nk_...): ");
|
|
240
243
|
}
|
|
241
244
|
if (!apiKey) {
|
|
242
245
|
console.log(" No API key provided. You can set NIA_API_KEY environment variable later.");
|
|
243
|
-
console.log(` Get your API key at: https://trynia.ai
|
|
246
|
+
console.log(` Get your API key at: https://app.trynia.ai
|
|
244
247
|
`);
|
|
245
248
|
} else if (!apiKey.startsWith("nk_")) {
|
|
246
249
|
console.log(" Warning: API key should start with 'nk_'");
|