nemu-cli 1.2.0 → 1.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/CHANGELOG.md CHANGED
@@ -1,5 +1,16 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.3.0
4
+
5
+ `nemu setup cursor`, `nemu setup vscode`, `nemu setup gemini`, `nemu setup windsurf` and
6
+ `nemu setup zed` add the Nemu MCP server to that editor's own config. Only the `nemu` entry is
7
+ written: every other server, setting, comment and the file's indentation stay exactly as they
8
+ were, the previous file is kept next to it with a `.nemu-backup` suffix, a file that cannot be
9
+ parsed is left alone, and a different server already called `nemu` is never overwritten. VS Code
10
+ uses its own `code --add-mcp` when it is on the PATH. `nemu uninstall <editor>` removes only
11
+ that entry, and `nemu status` lists the editors it finds. Hooks remain Claude Code and Codex
12
+ only.
13
+
3
14
  ## 1.2.0
4
15
 
5
16
  The CLI tells you when a newer version is out: "There is a new version available (1.2.0 -> 1.3.0).
package/README.md CHANGED
@@ -145,6 +145,13 @@ project's notes when a session starts and ask the agent to save a handoff before
145
145
  hooks only after you trust them once with `/hooks`. Pass `--hooks`, `--no-hooks` or `--yes` to skip
146
146
  the question.
147
147
 
148
+ Editors work the same way without hooks: `nemu setup cursor`, `vscode`, `gemini`, `windsurf` or
149
+ `zed` writes only the `nemu` entry into that editor's config (`~/.cursor/mcp.json`, VS Code's user
150
+ `mcp.json` through `code --add-mcp`, `~/.gemini/settings.json`,
151
+ `~/.codeium/windsurf/mcp_config.json`, Zed's `settings.json`). Everything else in the file,
152
+ comments included, stays as it was, the previous file is kept with a `.nemu-backup` suffix, and a
153
+ file that cannot be parsed is never touched.
154
+
148
155
  | Command | Does |
149
156
  | --- | --- |
150
157
  | `nemu claude [-- args]` | Set up if needed, then start Claude Code with the args after `--` |
@@ -158,7 +165,7 @@ the question.
158
165
  | `nemu context search <words>` | Search this project's notes |
159
166
  | `nemu context projects` / `export --out file` | List projects, or export everything as JSON |
160
167
  | `nemu status` | Sign in, this device, global install, and each client's setup |
161
- | `nemu uninstall [claude\|codex\|all]` | Remove exactly what setup added |
168
+ | `nemu uninstall [client\|all]` | Remove exactly what setup added, for any client or editor |
162
169
  | `nemu update [--yes]` | Check for a newer version and install it. The CLI also asks by itself, at most once a day; `NEMU_NO_UPDATE_CHECK=1` turns that off |
163
170
  | `nemu token [--header]` | Print a fresh access token |
164
171
 
@@ -0,0 +1,146 @@
1
+ import { access } from "node:fs/promises";
2
+ import { homedir } from "node:os";
3
+ import { basename, join } from "node:path";
4
+ import { CliError } from "../errors.js";
5
+ import { run, which } from "../system.js";
6
+ import { MCP_NAME } from "./registry.js";
7
+ import { read_entry, remove_entry, set_entry } from "./jsonc.js";
8
+ async function exists(path) {
9
+ try {
10
+ await access(path);
11
+ return true;
12
+ }
13
+ catch {
14
+ return false;
15
+ }
16
+ }
17
+ function home() {
18
+ const value = process.env.HOME;
19
+ return process.platform !== "win32" && value !== undefined && value.length > 0 ? value : homedir();
20
+ }
21
+ function config_home() {
22
+ return process.env.XDG_CONFIG_HOME ?? join(home(), ".config");
23
+ }
24
+ function app_data() {
25
+ return process.env.APPDATA ?? join(home(), "AppData", "Roaming");
26
+ }
27
+ function on_mac() {
28
+ return process.platform === "darwin";
29
+ }
30
+ function on_windows() {
31
+ return process.platform === "win32";
32
+ }
33
+ function vscode_user_dir() {
34
+ if (on_windows())
35
+ return join(app_data(), "Code", "User");
36
+ if (on_mac())
37
+ return join(home(), "Library", "Application Support", "Code", "User");
38
+ return join(config_home(), "Code", "User");
39
+ }
40
+ function zed_dir() {
41
+ return on_windows() ? join(app_data(), "Zed") : join(config_home(), "zed");
42
+ }
43
+ async function any_present(binaries, paths) {
44
+ for (const binary of binaries)
45
+ if ((await which(binary)) !== null)
46
+ return true;
47
+ for (const path of paths)
48
+ if (await exists(path))
49
+ return true;
50
+ return false;
51
+ }
52
+ function bridge(nemu, client) {
53
+ return { command: nemu, args: ["mcp", "--client", client] };
54
+ }
55
+ export function is_nemu_entry(value) {
56
+ if (typeof value !== "object" || value === null)
57
+ return false;
58
+ const entry = value;
59
+ if (typeof entry.command !== "string" || !Array.isArray(entry.args))
60
+ return false;
61
+ const program = basename(entry.command.replaceAll("\\", "/")).replace(/\.(cmd|exe|ps1)$/i, "");
62
+ return program === "nemu" && entry.args[0] === "mcp";
63
+ }
64
+ async function guard_foreign(path, keys) {
65
+ const existing = await read_entry(path, keys);
66
+ if (existing !== undefined && !is_nemu_entry(existing)) {
67
+ throw new CliError(`${path} already has a different server named "${MCP_NAME}", so nothing was changed. Rename or remove it, then run setup again.`, "config_conflict");
68
+ }
69
+ return existing;
70
+ }
71
+ function file_editor(id, label, config_path, keys, detect, value, after_setup) {
72
+ return {
73
+ id,
74
+ label,
75
+ config_path,
76
+ keys,
77
+ detect,
78
+ add: async (nemu) => {
79
+ await guard_foreign(config_path(), keys());
80
+ return set_entry(config_path(), keys(), value(nemu));
81
+ },
82
+ after_setup,
83
+ };
84
+ }
85
+ export const EDITORS = {
86
+ cursor: file_editor("cursor", "Cursor", () => join(home(), ".cursor", "mcp.json"), () => ["mcpServers", MCP_NAME], () => any_present(["cursor"], [
87
+ join(home(), ".cursor"),
88
+ ...(on_mac() ? ["/Applications/Cursor.app"] : []),
89
+ ]), (nemu) => bridge(nemu, "cursor"), ["Restart Cursor, or open Cursor Settings, MCP, to see the nemu server."]),
90
+ vscode: {
91
+ id: "vscode",
92
+ label: "VS Code",
93
+ config_path: () => join(vscode_user_dir(), "mcp.json"),
94
+ keys: () => ["servers", MCP_NAME],
95
+ detect: () => any_present(["code"], [vscode_user_dir()]),
96
+ add: async (nemu) => {
97
+ const entry = { type: "stdio", ...bridge(nemu, "vscode") };
98
+ const path = join(vscode_user_dir(), "mcp.json");
99
+ const before = await guard_foreign(path, ["servers", MCP_NAME]);
100
+ if (JSON.stringify(before) === JSON.stringify(entry))
101
+ return { change: "unchanged", backup: null };
102
+ if ((await which("code")) !== null) {
103
+ const result = await run("code", ["--add-mcp", JSON.stringify({ name: MCP_NAME, ...entry })], {
104
+ timeout_ms: 60_000,
105
+ });
106
+ if (result.code === 0)
107
+ return { change: before === undefined ? "added" : "updated", backup: null };
108
+ }
109
+ return set_entry(path, ["servers", MCP_NAME], entry);
110
+ },
111
+ after_setup: [
112
+ "In VS Code, run MCP: List Servers and start nemu. VS Code asks you to trust it the first time.",
113
+ ],
114
+ },
115
+ gemini: file_editor("gemini", "Gemini CLI", () => join(home(), ".gemini", "settings.json"), () => ["mcpServers", MCP_NAME], () => any_present(["gemini"], [join(home(), ".gemini")]), (nemu) => bridge(nemu, "gemini"), ["Start Gemini CLI and run /mcp to see the nemu server."]),
116
+ windsurf: file_editor("windsurf", "Windsurf", () => join(home(), ".codeium", "windsurf", "mcp_config.json"), () => ["mcpServers", MCP_NAME], () => any_present(["windsurf"], [
117
+ join(home(), ".codeium", "windsurf"),
118
+ ...(on_mac() ? ["/Applications/Windsurf.app"] : []),
119
+ ]), (nemu) => bridge(nemu, "windsurf"), ["Restart Windsurf, or refresh the MCP servers in Cascade."]),
120
+ zed: file_editor("zed", "Zed", () => join(zed_dir(), "settings.json"), () => ["context_servers", MCP_NAME], () => any_present(["zed"], [zed_dir(), ...(on_mac() ? ["/Applications/Zed.app"] : [])]), (nemu) => ({ ...bridge(nemu, "zed"), env: {} }), ["Zed picks the server up by itself. Open the Agent panel settings to check it is running."]),
121
+ };
122
+ const ALIASES = {
123
+ cursor: "cursor",
124
+ vscode: "vscode",
125
+ "vs-code": "vscode",
126
+ code: "vscode",
127
+ gemini: "gemini",
128
+ "gemini-cli": "gemini",
129
+ windsurf: "windsurf",
130
+ zed: "zed",
131
+ };
132
+ export function editor_from_name(name) {
133
+ const id = ALIASES[(name ?? "").toLowerCase()];
134
+ return id === undefined ? null : EDITORS[id];
135
+ }
136
+ export async function editor_has_nemu(spec) {
137
+ return is_nemu_entry(await read_entry(spec.config_path(), spec.keys()));
138
+ }
139
+ export async function remove_from_editor(spec) {
140
+ return (await remove_entry(spec.config_path(), spec.keys(), is_nemu_entry)) === "removed";
141
+ }
142
+ export async function require_editor(spec) {
143
+ if (!(await spec.detect())) {
144
+ throw new CliError(`${spec.label} was not found on this computer. Install it first, or print the config with: nemu mcp config ${spec.id}`, "client_missing");
145
+ }
146
+ }
@@ -0,0 +1,136 @@
1
+ import { copyFile, mkdir, readFile, rename, stat, writeFile, chmod } from "node:fs/promises";
2
+ import { dirname } from "node:path";
3
+ import { applyEdits, findNodeAtLocation, getNodeValue, modify, parseTree } from "jsonc-parser";
4
+ import { CliError } from "../errors.js";
5
+ export const BACKUP_SUFFIX = ".nemu-backup";
6
+ async function read_text(path) {
7
+ try {
8
+ return await readFile(path, "utf-8");
9
+ }
10
+ catch (error) {
11
+ if (error.code === "ENOENT")
12
+ return null;
13
+ throw error;
14
+ }
15
+ }
16
+ function indentation(text) {
17
+ const eol = text.includes("\r\n") ? "\r\n" : "\n";
18
+ const indented = text.split(/\r?\n/).find((line) => /^[ \t]+\S/.test(line));
19
+ if (indented === undefined)
20
+ return { insertSpaces: true, tabSize: 2, eol };
21
+ if (indented.startsWith("\t"))
22
+ return { insertSpaces: false, tabSize: 1, eol };
23
+ const width = indented.length - indented.trimStart().length;
24
+ return { insertSpaces: true, tabSize: width === 4 ? 4 : 2, eol };
25
+ }
26
+ function parse_object(path, text) {
27
+ const errors = [];
28
+ const tree = parseTree(text, errors, { allowTrailingComma: true, disallowComments: false });
29
+ if (errors.length > 0 || tree === undefined || tree.type !== "object") {
30
+ throw new CliError(`${path} could not be read safely, so nothing was changed. Fix the file or add Nemu by hand: nemu mcp config`, "config_unreadable");
31
+ }
32
+ return tree;
33
+ }
34
+ async function write_atomic(path, text, original) {
35
+ await mkdir(dirname(path), { recursive: true });
36
+ const mode = original === null ? 0o644 : (await stat(path)).mode & 0o777;
37
+ const backup = original === null ? null : `${path}${BACKUP_SUFFIX}`;
38
+ if (backup !== null)
39
+ await copyFile(path, backup);
40
+ const temporary = `${path}.${process.pid}.nemu-tmp`;
41
+ await writeFile(temporary, text, { encoding: "utf-8", mode });
42
+ await chmod(temporary, mode).catch(() => undefined);
43
+ await rename(temporary, path);
44
+ return backup;
45
+ }
46
+ export async function read_entry(path, keys) {
47
+ const text = await read_text(path);
48
+ if (text === null)
49
+ return undefined;
50
+ const errors = [];
51
+ const tree = parseTree(text, errors, { allowTrailingComma: true, disallowComments: false });
52
+ if (errors.length > 0 || tree === undefined)
53
+ return undefined;
54
+ const node = findNodeAtLocation(tree, keys);
55
+ return node === undefined ? undefined : getNodeValue(node);
56
+ }
57
+ function line_indent(text, offset) {
58
+ const start = text.lastIndexOf("\n", offset - 1) + 1;
59
+ const match = /^[ \t]*/.exec(text.slice(start));
60
+ return match === null ? "" : match[0];
61
+ }
62
+ function pretty(value, indent, unit) {
63
+ return JSON.stringify(value, null, unit).replaceAll("\n", `\n${indent}`);
64
+ }
65
+ function splice(text, offset, length, content) {
66
+ return `${text.slice(0, offset)}${content}${text.slice(offset + length)}`;
67
+ }
68
+ function insert_entry(text, keys, value) {
69
+ const tree = parse_object("", text);
70
+ const style = indentation(text);
71
+ const unit = style.insertSpaces ? " ".repeat(style.tabSize) : "\t";
72
+ const existing = findNodeAtLocation(tree, keys);
73
+ if (existing !== undefined) {
74
+ const indent = line_indent(text, existing.offset);
75
+ return splice(text, existing.offset, existing.length, pretty(value, indent, unit));
76
+ }
77
+ let depth = keys.length - 1;
78
+ while (depth > 0 && findNodeAtLocation(tree, keys.slice(0, depth))?.type !== "object")
79
+ depth -= 1;
80
+ const parent = depth === 0 ? tree : findNodeAtLocation(tree, keys.slice(0, depth));
81
+ if (parent === undefined || parent.type !== "object") {
82
+ throw new CliError("The config has an unexpected shape, so nothing was changed.", "config_unreadable");
83
+ }
84
+ const missing = keys.slice(depth);
85
+ const nested = missing.slice(1).reduceRight((inner, key) => ({ [key]: inner }), value);
86
+ const parent_indent = line_indent(text, parent.offset);
87
+ const child_indent = `${parent_indent}${unit}`;
88
+ const property = `${JSON.stringify(missing[0])}: ${pretty(nested, child_indent, unit)}`;
89
+ const children = parent.children ?? [];
90
+ const last = children[children.length - 1];
91
+ if (last !== undefined) {
92
+ return splice(text, last.offset + last.length, 0, `,${style.eol}${child_indent}${property}`);
93
+ }
94
+ const inner_start = parent.offset + 1;
95
+ const inner_end = parent.offset + parent.length - 1;
96
+ const inner = text.slice(inner_start, inner_end);
97
+ const content = inner.trim().length === 0
98
+ ? `${style.eol}${child_indent}${property}${style.eol}${parent_indent}`
99
+ : `${inner.replace(/\s+$/, "")}${style.eol}${child_indent}${property}${style.eol}${parent_indent}`;
100
+ return splice(text, inner_start, inner_end - inner_start, content);
101
+ }
102
+ export async function set_entry(path, keys, value) {
103
+ const original = await read_text(path);
104
+ const text = original === null || original.trim().length === 0 ? "{}" : original;
105
+ const tree = parse_object(path, text);
106
+ const existing = findNodeAtLocation(tree, keys);
107
+ if (existing !== undefined && JSON.stringify(getNodeValue(existing)) === JSON.stringify(value)) {
108
+ return { change: "unchanged", backup: null };
109
+ }
110
+ const next = insert_entry(text, keys, value);
111
+ const written = findNodeAtLocation(parse_object(path, next), keys);
112
+ if (written === undefined || JSON.stringify(getNodeValue(written)) !== JSON.stringify(value)) {
113
+ throw new CliError(`${path} could not be updated safely, so nothing was changed.`, "config_unreadable");
114
+ }
115
+ const backup = await write_atomic(path, next.endsWith("\n") ? next : `${next}\n`, original);
116
+ return { change: existing === undefined ? "added" : "updated", backup };
117
+ }
118
+ export async function remove_entry(path, keys, is_ours) {
119
+ const original = await read_text(path);
120
+ if (original === null)
121
+ return "absent";
122
+ const tree = parse_object(path, original);
123
+ const existing = findNodeAtLocation(tree, keys);
124
+ if (existing === undefined || !is_ours(getNodeValue(existing)))
125
+ return "absent";
126
+ let next = applyEdits(original, modify(original, keys, undefined, {}));
127
+ for (let depth = keys.length - 1; depth >= 1; depth -= 1) {
128
+ const parent = findNodeAtLocation(parse_object(path, next), keys.slice(0, depth));
129
+ if (parent === undefined || parent.type !== "object" || (parent.children ?? []).length > 0)
130
+ break;
131
+ next = applyEdits(next, modify(next, keys.slice(0, depth), undefined, {}));
132
+ }
133
+ parse_object(path, next);
134
+ await write_atomic(path, next, original);
135
+ return "removed";
136
+ }
@@ -65,7 +65,7 @@ export function client_from_name(name) {
65
65
  case "codex":
66
66
  return CLIENTS.codex;
67
67
  default:
68
- throw new CliError("Pick a client: claude (aliases cc, claude-code) or codex. Other clients: nemu mcp config <client>", "invalid_client");
68
+ throw new CliError("Pick a client: claude (aliases cc, claude-code), codex, cursor, vscode, gemini, windsurf or zed. Others: nemu mcp config <client>", "invalid_client");
69
69
  }
70
70
  }
71
71
  export async function client_installed(spec) {
@@ -8,7 +8,7 @@ import { current_project } from "../context/project.js";
8
8
  import { repository } from "../git.js";
9
9
  import { VERSION } from "../version.js";
10
10
  import { out } from "../ui.js";
11
- const CLIENTS = ["claude-code", "codex", "cursor", "zed", "gemini", "mcp"];
11
+ const CLIENTS = ["claude-code", "codex", "cursor", "zed", "gemini", "vscode", "windsurf", "mcp"];
12
12
  const rpc_schema = z.object({
13
13
  jsonrpc: z.literal("2.0"),
14
14
  id: z.union([z.string(), z.number()]).optional(),
@@ -180,12 +180,12 @@ const SNIPPETS = {
180
180
  text: JSON.stringify({ mcpServers: { nemu: { command: "nemu", args: ["mcp", "--client", "gemini"] } } }, null, 2),
181
181
  },
182
182
  vscode: {
183
- where: ".vscode/mcp.json in your project",
184
- text: JSON.stringify({ servers: { nemu: { type: "stdio", command: "nemu", args: ["mcp"] } } }, null, 2),
183
+ where: "VS Code user mcp.json (MCP: Open User Configuration), or .vscode/mcp.json in a project",
184
+ text: JSON.stringify({ servers: { nemu: { type: "stdio", command: "nemu", args: ["mcp", "--client", "vscode"] } } }, null, 2),
185
185
  },
186
186
  windsurf: {
187
187
  where: "~/.codeium/windsurf/mcp_config.json",
188
- text: JSON.stringify({ mcpServers: { nemu: { command: "nemu", args: ["mcp"] } } }, null, 2),
188
+ text: JSON.stringify({ mcpServers: { nemu: { command: "nemu", args: ["mcp", "--client", "windsurf"] } } }, null, 2),
189
189
  },
190
190
  zed: {
191
191
  where: "Zed settings.json",
@@ -8,6 +8,7 @@ import { bold, confirm, dim, is_interactive, out, success } from "../ui.js";
8
8
  import { emit, is_json_mode } from "../output.js";
9
9
  import { install_hooks } from "../clients/hooks.js";
10
10
  import { client_from_name, client_installed } from "../clients/registry.js";
11
+ import { editor_from_name, require_editor } from "../clients/editors.js";
11
12
  import { login } from "./login.js";
12
13
  function newer_or_equal(found, wanted) {
13
14
  const parse = (value) => value.split(/[.-]/).slice(0, 3).map((part) => Number.parseInt(part, 10) || 0);
@@ -30,7 +31,7 @@ export async function resolve_nemu_binary(interactive_install) {
30
31
  }
31
32
  const verb = found === null ? "install" : "update";
32
33
  const accepted = interactive_install &&
33
- (await confirm(`Claude and Codex start nemu on every session, so it needs a global install. ${verb === "install" ? "Install" : "Update"} it now with npm i -g nemu-cli@${VERSION}?`, true));
34
+ (await confirm(`Your agents start nemu on every session, so it needs a global install. ${verb === "install" ? "Install" : "Update"} it now with npm i -g nemu-cli@${VERSION}?`, true));
34
35
  if (!accepted) {
35
36
  throw new CliError(`Install the CLI globally first: npm i -g nemu-cli@${VERSION} (or bun add -g nemu-cli@${VERSION})`, "global_install_required");
36
37
  }
@@ -85,7 +86,34 @@ export async function run_setup(spec, args) {
85
86
  await install_hooks(spec.hooks_path(), nemu, spec.id);
86
87
  return { client: spec.id, hooks, nemu, device_id };
87
88
  }
89
+ async function setup_editor(editor, args) {
90
+ await require_editor(editor);
91
+ await ensure_signed_in();
92
+ const device_id = await ensure_device(bool_flag(args, "new-device"));
93
+ const nemu = await resolve_nemu_binary(is_interactive() && !bool_flag(args, "no-install"));
94
+ const { change, backup } = await editor.add(nemu);
95
+ if (is_json_mode()) {
96
+ emit({ ok: true, client: editor.id, change, config: editor.config_path(), backup, nemu, device_id });
97
+ return 0;
98
+ }
99
+ out();
100
+ success(`${editor.label} is connected to Nemu Context`);
101
+ out(dim(change === "unchanged"
102
+ ? ` The nemu server was already in ${editor.config_path()}`
103
+ : ` MCP server "nemu" ${change === "added" ? "added to" : "updated in"} ${editor.config_path()}`));
104
+ if (backup !== null)
105
+ out(dim(` The file as it was before is saved at ${backup}`));
106
+ for (const line of editor.after_setup)
107
+ out(` ${line}`);
108
+ if (bool_flag(args, "hooks"))
109
+ out(dim(` Hooks are only available for Claude Code and Codex.`));
110
+ out(dim(` Check it any time with: ${bold("nemu status")}`));
111
+ return 0;
112
+ }
88
113
  export async function setup(args) {
114
+ const editor = editor_from_name(args.positional[0]);
115
+ if (editor !== null)
116
+ return setup_editor(editor, args);
89
117
  const spec = client_from_name(args.positional[0]);
90
118
  const result = await run_setup(spec, args);
91
119
  if (is_json_mode()) {
@@ -1,6 +1,7 @@
1
1
  import { has_scope, read_credentials, read_settings, api_url } from "../config.js";
2
2
  import { installed_hooks, HOOK_SPECS } from "../clients/hooks.js";
3
3
  import { CLIENTS, client_installed } from "../clients/registry.js";
4
+ import { EDITORS, editor_has_nemu } from "../clients/editors.js";
4
5
  import { run, which } from "../system.js";
5
6
  import { VERSION } from "../version.js";
6
7
  import { bold, dim, green, out, red } from "../ui.js";
@@ -27,6 +28,16 @@ export async function status() {
27
28
  hooks_path: spec.hooks_path(),
28
29
  };
29
30
  }));
31
+ const editors = await Promise.all(Object.values(EDITORS).map(async (editor) => {
32
+ const installed = await editor.detect();
33
+ return {
34
+ id: editor.id,
35
+ label: editor.label,
36
+ installed,
37
+ mcp: installed ? await editor_has_nemu(editor) : false,
38
+ config: editor.config_path(),
39
+ };
40
+ }));
30
41
  const report = {
31
42
  version: VERSION,
32
43
  api_url: credentials?.api_url ?? api_url(),
@@ -38,6 +49,7 @@ export async function status() {
38
49
  global_install: global,
39
50
  global_version,
40
51
  clients,
52
+ editors,
41
53
  };
42
54
  if (is_json_mode()) {
43
55
  emit(report);
@@ -58,6 +70,14 @@ export async function status() {
58
70
  out(` MCP server ${mark(client.mcp)}${client.mcp ? "" : dim(` nemu setup ${client.id === "codex" ? "codex" : "claude"}`)}`);
59
71
  out(` Hooks ${client.hooks.length === 0 ? dim("none") : client.hooks_complete ? green("all") : `${client.hooks.join(", ")}`}`);
60
72
  }
73
+ const found = editors.filter((editor) => editor.installed);
74
+ if (found.length > 0) {
75
+ out();
76
+ out(` ${bold("Editors")}`);
77
+ for (const editor of found) {
78
+ out(` ${editor.label.padEnd(15)}${mark(editor.mcp)}${editor.mcp ? "" : dim(` nemu setup ${editor.id}`)}`);
79
+ }
80
+ }
61
81
  out();
62
82
  return 0;
63
83
  }
@@ -1,6 +1,7 @@
1
1
  import { remove_hooks } from "../clients/hooks.js";
2
2
  import { CLIENTS, client_from_name, client_installed } from "../clients/registry.js";
3
3
  import { CliError } from "../errors.js";
4
+ import { EDITORS, editor_from_name, remove_from_editor } from "../clients/editors.js";
4
5
  import { dim, out, success } from "../ui.js";
5
6
  import { emit, is_json_mode } from "../output.js";
6
7
  async function remove_from(spec) {
@@ -9,18 +10,34 @@ async function remove_from(spec) {
9
10
  const hooks = await remove_hooks(spec.hooks_path());
10
11
  return { client: spec.id, mcp_removed: mcp, hooks_removed: hooks };
11
12
  }
13
+ async function remove_editor(editor) {
14
+ return { client: editor.id, label: editor.label, mcp_removed: await remove_from_editor(editor) };
15
+ }
12
16
  export async function uninstall(args) {
13
17
  const target = args.positional[0] ?? "all";
14
- const specs = target === "all" ? Object.values(CLIENTS) : [client_from_name(target)];
15
- if (specs.length === 0)
18
+ const editor = target === "all" ? null : editor_from_name(target);
19
+ const specs = target === "all" ? Object.values(CLIENTS) : editor !== null ? [] : [client_from_name(target)];
20
+ const editors = target === "all" ? Object.values(EDITORS) : editor !== null ? [editor] : [];
21
+ if (specs.length === 0 && editors.length === 0)
16
22
  throw new CliError("Nothing to uninstall.", "invalid_arguments");
17
23
  const results = [];
18
24
  for (const spec of specs)
19
25
  results.push(await remove_from(spec));
26
+ const editor_results = [];
27
+ for (const item of editors)
28
+ editor_results.push(await remove_editor(item));
20
29
  if (is_json_mode()) {
21
- emit({ ok: true, results });
30
+ emit({ ok: true, results, editors: editor_results });
22
31
  return 0;
23
32
  }
33
+ for (const result of editor_results) {
34
+ if (!result.mcp_removed) {
35
+ if (target !== "all")
36
+ out(dim(` ${result.label}: nothing from Nemu was installed`));
37
+ continue;
38
+ }
39
+ success(`${result.label}: removed the MCP server`);
40
+ }
24
41
  for (const result of results) {
25
42
  const label = CLIENTS[result.client].label;
26
43
  if (!result.mcp_removed && !result.hooks_removed) {
package/dist/index.js CHANGED
@@ -61,6 +61,8 @@ const HELP = `
61
61
  ${bold("Context for coding agents")}
62
62
  setup <claude|codex> [--hooks|--no-hooks] [--yes]
63
63
  Connect Claude Code (aliases cc, claude-code) or Codex
64
+ setup <cursor|vscode|gemini|windsurf|zed>
65
+ Add the Nemu MCP server to that editor's config
64
66
  claude [-- <claude args>] Set up if needed, then start Claude Code
65
67
  codex [-- <codex args>] Set up if needed, then start Codex
66
68
  claude load memories [--all] [--yes]
@@ -74,7 +76,7 @@ const HELP = `
74
76
  context search <words> Search this project's saved notes
75
77
  context projects | export [--out f] List projects or export everything
76
78
  status Sign in, device, global install, client setup
77
- uninstall [claude|codex|all] Remove what setup added
79
+ uninstall [client|all] Remove what setup added
78
80
  token [--header] Print a fresh access token
79
81
  config get | set reports on|off Error reports sent after a failure
80
82
  update [--yes] Check for a new version and install it
package/dist/version.js CHANGED
@@ -1 +1 @@
1
- export const VERSION = "1.2.0";
1
+ export const VERSION = "1.3.0";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nemu-cli",
3
- "version": "1.2.0",
3
+ "version": "1.3.0",
4
4
  "description": "Command line access to Nemu, and portable project memory for Claude Code, Codex and any MCP client.",
5
5
  "bin": {
6
6
  "nemu": "./dist/index.js"
@@ -40,6 +40,7 @@
40
40
  "homepage": "https://docs.nemu.cc",
41
41
  "dependencies": {
42
42
  "@nemu-ai/sdk": "^1.1.0",
43
+ "jsonc-parser": "3.3.1",
43
44
  "zod": "^4.1.0"
44
45
  }
45
46
  }