Lines 116-156javascript
116 lines.push(`export NEXUSMIND_BASE_URL="${baseUrl}"`);
119 writeFileSync(rc, text + `\n# NexusMind\n${lines.join('\n')}\n`);
120 success(`Env vars → ${rc}`);
124// Windows persistent env vars via setx, which writes HKCU\Environment (User
125// scope) so every future process inherits them. Without this, setup wrote only
126// to shell rc files that don't exist on Windows, leaving NEXUSMIND_BASE_URL
127// unset — so clients failed with "Missing environment variables:
128// NEXUSMIND_BASE_URL" when expanding the ${...} placeholders in their MCP
129// config. setx only affects processes started AFTER it runs, so the user must
130// restart their client (already the documented post-setup step); we also mirror
131// the values into process.env so any same-run check sees them. Values here (an
132// API key + a URL) are far under setx's ~1024-char limit.
133function writeWindowsEnv(apiKey, baseUrl) {
134 const setVar = (name, value) => {
137 const res = spawnSync('setx', [name, value], { stdio: 'ignore', shell: true });
138 if (!res.error && res.status === 0) {
139 process.env[name] = value;
140 success(`Env var ${name} → Windows user environment`);
143 warn(`Could not set ${name} automatically — run this yourself: setx ${name} "${value}"`);
146 setVar('NEXUSMIND_API_KEY', apiKey);
147 setVar('NEXUSMIND_BASE_URL', baseUrl);
149// ── Install helpers ───────────────────────────────────────────────────────────
150// The Claude plugin is the canonical registration path for Claude Code — it owns
151// the MCP server entry and hooks. Setup no longer writes a user-level MCP server
152// registration (~/.claude.json or ~/.claude/settings.json) for Claude Code; it only
153// detects the plugin and guides the user to install it if missing.
154function isNexusmindPluginInstalled() {
155 const data = readJson(INSTALLED_PLUGINS_JSON);
156 if (existsSync(INSTALLED_PLUGINS_JSON) && !('plugins' in data)) {