nous-token 0.2.1 → 0.3.0
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/cli/setup.ts +13 -24
- package/package.json +1 -1
package/cli/setup.ts
CHANGED
|
@@ -155,29 +155,12 @@ const tools: Tool[] = [
|
|
|
155
155
|
|
|
156
156
|
// ── Shell env helper ──
|
|
157
157
|
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
const rcFile = shell.includes("zsh") ? join(HOME, ".zshrc") : join(HOME, ".bashrc");
|
|
158
|
+
// Collect env vars to set — don't write to shell rc file
|
|
159
|
+
const envCommands: string[] = [];
|
|
161
160
|
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
if (content.includes(`${key}="${value}"`)) {
|
|
166
|
-
return { success: true, message: "already configured" };
|
|
167
|
-
}
|
|
168
|
-
// Remove old nous-token setting if exists, then write new one
|
|
169
|
-
const lines = content.split("\n").filter(l => !(l.includes(`${key}=`) && l.includes("nousai")));
|
|
170
|
-
lines.push(`export ${key}="${value}" # nous-token gateway`);
|
|
171
|
-
writeFileSync(rcFile, lines.join("\n"));
|
|
172
|
-
} else {
|
|
173
|
-
writeFileSync(rcFile, `export ${key}="${value}" # nous-token gateway\n`);
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
// Also set in current process
|
|
177
|
-
process.env[key] = value;
|
|
178
|
-
|
|
179
|
-
const rcName = rcFile.includes("zsh") ? "~/.zshrc" : "~/.bashrc";
|
|
180
|
-
return { success: true, message: `set ${key} in ${rcName}` };
|
|
161
|
+
function setShellEnv(key: string, value: string, toolName: string): ConfigResult {
|
|
162
|
+
envCommands.push(`export ${key}="${value}"`);
|
|
163
|
+
return { success: true, message: `${key}` };
|
|
181
164
|
}
|
|
182
165
|
|
|
183
166
|
|
|
@@ -250,11 +233,17 @@ for (const tool of tools) {
|
|
|
250
233
|
console.log("");
|
|
251
234
|
|
|
252
235
|
if (configured > 0) {
|
|
253
|
-
console.log(` \x1b[32m${configured} tool(s)
|
|
236
|
+
console.log(` \x1b[32m${configured} tool(s) detected.\x1b[0m\n`);
|
|
237
|
+
console.log(" \x1b[1mThis terminal only:\x1b[0m");
|
|
238
|
+
console.log(` \x1b[36m${envCommands.join(" && ")}\x1b[0m\n`);
|
|
239
|
+
console.log(" \x1b[1mAll terminals (permanent):\x1b[0m");
|
|
240
|
+
const shell = process.env.SHELL || "/bin/bash";
|
|
241
|
+
const rcFile = shell.includes("zsh") ? "~/.zshrc" : "~/.bashrc";
|
|
242
|
+
console.log(` \x1b[36mecho '${envCommands.join("\\n")}' >> ${rcFile} && source ${rcFile}\x1b[0m\n`);
|
|
254
243
|
console.log(` See your usage at \x1b[4mhttps://token.nousai.cc\x1b[0m`);
|
|
255
|
-
console.log(` Run \x1b[1msource ~/.zshrc\x1b[0m to apply changes in this terminal.`);
|
|
256
244
|
} else {
|
|
257
245
|
console.log(" No AI tools found. Install Claude Code, Cursor, or any OpenAI-compatible tool.");
|
|
258
246
|
}
|
|
259
247
|
|
|
260
248
|
console.log("");
|
|
249
|
+
process.exit(0);
|