nemu-cli 1.3.2 → 1.4.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 +28 -0
- package/README.md +9 -6
- package/dist/clients/editors.js +17 -3
- package/dist/clients/hooks.js +5 -3
- package/dist/clients/jsonc.js +1 -1
- package/dist/clients/registry.js +1 -1
- package/dist/commands/hook.js +59 -32
- package/dist/commands/login.js +4 -2
- package/dist/commands/mcp.js +5 -1
- package/dist/index.js +2 -2
- package/dist/system.js +22 -7
- package/dist/ui.js +25 -5
- package/dist/version.js +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,33 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 1.4.0
|
|
4
|
+
|
|
5
|
+
`nemu setup opencode` adds the Nemu MCP server to OpenCode's global config,
|
|
6
|
+
`~/.config/opencode/opencode.json` (or `opencode.jsonc` when that is the file you have), as a local
|
|
7
|
+
server that runs `nemu mcp --client opencode`. Like the other editors, only the `nemu` entry is
|
|
8
|
+
written, the previous file is kept with a `.nemu-backup` suffix, `nemu uninstall opencode` removes
|
|
9
|
+
it, `nemu status` lists it and `nemu mcp config opencode` prints it.
|
|
10
|
+
|
|
11
|
+
The Stop hook no longer shows up as "Stop hook error" after every few edits. Claude Code shows any
|
|
12
|
+
Stop request that way, so the reminder to save a handoff now arrives quietly after the third edit,
|
|
13
|
+
as context the agent reads and you do not see. Stop asks at most once per session, and only when the
|
|
14
|
+
work is still unsaved. Saving with `memory_write` resets the count. Only files inside the project
|
|
15
|
+
count, so an agent's scratchpad or a temp folder no longer triggers a request, and the reminder no
|
|
16
|
+
longer tells the agent to hide it from you.
|
|
17
|
+
|
|
18
|
+
On Windows, `git`, editors and every other command the CLI starts are now found on `PATH` only.
|
|
19
|
+
Before, the current folder was searched first, so a `git.cmd` inside a cloned repository ran in
|
|
20
|
+
place of the real git.
|
|
21
|
+
|
|
22
|
+
`nemu setup`, `nemu uninstall` and the update repair keep the permissions of
|
|
23
|
+
`~/.claude/settings.json` and `~/.codex/hooks.json`. A file you locked to `0600` used to come back
|
|
24
|
+
readable by every user on the machine. Files the CLI creates from nothing are now `0600`.
|
|
25
|
+
|
|
26
|
+
`nemu login` opens the sign-in page only when it is on the same server the CLI talks to, over https
|
|
27
|
+
(or http on localhost), and on Windows it opens it without going through `cmd`. It now opens the
|
|
28
|
+
page without the code filled in, matching the device page, so you type the code shown in the
|
|
29
|
+
terminal.
|
|
30
|
+
|
|
3
31
|
## 1.3.2
|
|
4
32
|
|
|
5
33
|
After an update, the CLI checks once whether what setup installed still matches what this version
|
package/README.md
CHANGED
|
@@ -141,14 +141,17 @@ nemu setup claude # or: nemu setup codex (aliases: cc, claude-code)
|
|
|
141
141
|
|
|
142
142
|
Setup registers a `nemu` MCP server with the client through the client's own command
|
|
143
143
|
(`claude mcp add --scope user`, `codex mcp add`) and asks whether to install hooks. Hooks load the
|
|
144
|
-
project's notes when a session starts and
|
|
144
|
+
project's notes when a session starts and, after a few edits inside the project, remind the agent to
|
|
145
|
+
save a handoff when it finishes. If the work is still unsaved when the agent stops, the Stop hook asks
|
|
146
|
+
once per session (Claude Code shows that one request as "Stop hook error"). Codex runs
|
|
145
147
|
hooks only after you trust them once with `/hooks`. Pass `--hooks`, `--no-hooks` or `--yes` to skip
|
|
146
148
|
the question.
|
|
147
149
|
|
|
148
|
-
Editors work the same way without hooks: `nemu setup cursor`, `vscode`, `gemini`, `windsurf`
|
|
149
|
-
`
|
|
150
|
-
`mcp.json` through `code --add-mcp`, `~/.gemini/settings.json`,
|
|
151
|
-
`~/.codeium/windsurf/mcp_config.json`, Zed's `settings.json
|
|
150
|
+
Editors work the same way without hooks: `nemu setup cursor`, `vscode`, `gemini`, `windsurf`, `zed`
|
|
151
|
+
or `opencode` writes only the `nemu` entry into that editor's config (`~/.cursor/mcp.json`, VS Code's
|
|
152
|
+
user `mcp.json` through `code --add-mcp`, `~/.gemini/settings.json`,
|
|
153
|
+
`~/.codeium/windsurf/mcp_config.json`, Zed's `settings.json`, OpenCode's
|
|
154
|
+
`~/.config/opencode/opencode.json` or `opencode.jsonc`). Everything else in the file,
|
|
152
155
|
comments included, stays as it was, the previous file is kept with a `.nemu-backup` suffix, and a
|
|
153
156
|
file that cannot be parsed is never touched.
|
|
154
157
|
|
|
@@ -160,7 +163,7 @@ file that cannot be parsed is never touched.
|
|
|
160
163
|
| `nemu claude load sessions [--limit n]` | Open Claude with your recent sessions and let it save what matters |
|
|
161
164
|
| `nemu codex load sessions [--limit n]` | The same for Codex |
|
|
162
165
|
| `nemu mcp` | The stdio MCP bridge clients start; it uses your login and refreshes it |
|
|
163
|
-
| `nemu mcp config <client>` | Config for `cursor`, `gemini`, `vscode`, `windsurf`, `zed`, `claude`, `codex`, `remote` |
|
|
166
|
+
| `nemu mcp config <client>` | Config for `cursor`, `gemini`, `vscode`, `windsurf`, `zed`, `opencode`, `claude`, `codex`, `remote` |
|
|
164
167
|
| `nemu context` | What an agent sees for this folder |
|
|
165
168
|
| `nemu context search <words>` | Search this project's notes |
|
|
166
169
|
| `nemu context projects` / `export --out file` | List projects, or export everything as JSON |
|
package/dist/clients/editors.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { existsSync } from "node:fs";
|
|
1
2
|
import { access } from "node:fs/promises";
|
|
2
3
|
import { homedir } from "node:os";
|
|
3
4
|
import { basename, join } from "node:path";
|
|
@@ -37,6 +38,13 @@ function vscode_user_dir() {
|
|
|
37
38
|
return join(home(), "Library", "Application Support", "Code", "User");
|
|
38
39
|
return join(config_home(), "Code", "User");
|
|
39
40
|
}
|
|
41
|
+
function opencode_dir() {
|
|
42
|
+
return join(config_home(), "opencode");
|
|
43
|
+
}
|
|
44
|
+
function opencode_config() {
|
|
45
|
+
const jsonc = join(opencode_dir(), "opencode.jsonc");
|
|
46
|
+
return existsSync(jsonc) ? jsonc : join(opencode_dir(), "opencode.json");
|
|
47
|
+
}
|
|
40
48
|
function zed_dir() {
|
|
41
49
|
return on_windows() ? join(app_data(), "Zed") : join(config_home(), "zed");
|
|
42
50
|
}
|
|
@@ -56,10 +64,13 @@ export function is_nemu_entry(value) {
|
|
|
56
64
|
if (typeof value !== "object" || value === null)
|
|
57
65
|
return false;
|
|
58
66
|
const entry = value;
|
|
59
|
-
|
|
67
|
+
const [command, first] = Array.isArray(entry.command)
|
|
68
|
+
? [entry.command[0], entry.command[1]]
|
|
69
|
+
: [entry.command, Array.isArray(entry.args) ? entry.args[0] : undefined];
|
|
70
|
+
if (typeof command !== "string")
|
|
60
71
|
return false;
|
|
61
|
-
const program = basename(
|
|
62
|
-
return program === "nemu" &&
|
|
72
|
+
const program = basename(command.replaceAll("\\", "/")).replace(/\.(cmd|exe|ps1)$/i, "");
|
|
73
|
+
return program === "nemu" && first === "mcp";
|
|
63
74
|
}
|
|
64
75
|
async function guard_foreign(path, keys) {
|
|
65
76
|
const existing = await read_entry(path, keys);
|
|
@@ -120,6 +131,7 @@ export const EDITORS = {
|
|
|
120
131
|
...(on_mac() ? ["/Applications/Windsurf.app"] : []),
|
|
121
132
|
]), (nemu) => bridge(nemu, "windsurf"), ["Restart Windsurf, or refresh the MCP servers in Cascade."]),
|
|
122
133
|
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."]),
|
|
134
|
+
opencode: file_editor("opencode", "OpenCode", opencode_config, () => ["mcp", MCP_NAME], () => any_present(["opencode"], [opencode_dir(), join(home(), ".opencode")]), (nemu) => ({ type: "local", command: [nemu, "mcp", "--client", "opencode"], enabled: true }), ["Start OpenCode and run opencode mcp list to see the nemu server."]),
|
|
123
135
|
};
|
|
124
136
|
const ALIASES = {
|
|
125
137
|
cursor: "cursor",
|
|
@@ -130,6 +142,8 @@ const ALIASES = {
|
|
|
130
142
|
"gemini-cli": "gemini",
|
|
131
143
|
windsurf: "windsurf",
|
|
132
144
|
zed: "zed",
|
|
145
|
+
opencode: "opencode",
|
|
146
|
+
"open-code": "opencode",
|
|
133
147
|
};
|
|
134
148
|
export function editor_from_name(name) {
|
|
135
149
|
const id = ALIASES[(name ?? "").toLowerCase()];
|
package/dist/clients/hooks.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { readFile, writeFile, mkdir, rename, copyFile, access } from "node:fs/promises";
|
|
1
|
+
import { readFile, writeFile, mkdir, rename, copyFile, access, chmod, stat } from "node:fs/promises";
|
|
2
2
|
import { dirname, win32 } from "node:path";
|
|
3
3
|
import { z } from "zod";
|
|
4
4
|
import { CliError } from "../errors.js";
|
|
5
5
|
export const HOOK_SPECS = {
|
|
6
6
|
"claude-code": [
|
|
7
7
|
{ event: "SessionStart", hook: "start", matcher: "startup|resume|clear|compact", timeout: 20 },
|
|
8
|
-
{ event: "PostToolUse", hook: "tool", matcher: "Edit|Write|MultiEdit|NotebookEdit", timeout: 5 },
|
|
8
|
+
{ event: "PostToolUse", hook: "tool", matcher: "Edit|Write|MultiEdit|NotebookEdit|mcp__nemu__memory_write", timeout: 5 },
|
|
9
9
|
{ event: "Stop", hook: "stop", timeout: 10 },
|
|
10
10
|
{ event: "PreCompact", hook: "compact", matcher: "manual|auto", timeout: 5 },
|
|
11
11
|
{ event: "SessionEnd", hook: "end", timeout: 3 },
|
|
@@ -80,8 +80,10 @@ async function write_config(path, config) {
|
|
|
80
80
|
const backup = `${path}.nemu-backup`;
|
|
81
81
|
if ((await exists(path)) && !(await exists(backup)))
|
|
82
82
|
await copyFile(path, backup);
|
|
83
|
+
const mode = (await exists(path)) ? (await stat(path)).mode & 0o777 : 0o600;
|
|
83
84
|
const temporary = `${path}.${process.pid}.tmp`;
|
|
84
|
-
await writeFile(temporary, `${JSON.stringify(config, null, 2)}\n`, "utf-8");
|
|
85
|
+
await writeFile(temporary, `${JSON.stringify(config, null, 2)}\n`, { encoding: "utf-8", mode });
|
|
86
|
+
await chmod(temporary, mode).catch(() => undefined);
|
|
85
87
|
await rename(temporary, path);
|
|
86
88
|
}
|
|
87
89
|
function without_own(config) {
|
package/dist/clients/jsonc.js
CHANGED
|
@@ -47,7 +47,7 @@ function parse_object(path, text) {
|
|
|
47
47
|
}
|
|
48
48
|
async function write_atomic(path, text, original) {
|
|
49
49
|
await mkdir(dirname(path), { recursive: true });
|
|
50
|
-
const mode = original === null ?
|
|
50
|
+
const mode = original === null ? 0o600 : (await stat(path)).mode & 0o777;
|
|
51
51
|
const backup = original === null ? null : `${path}${BACKUP_SUFFIX}`;
|
|
52
52
|
if (backup !== null)
|
|
53
53
|
await copyFile(path, backup);
|
package/dist/clients/registry.js
CHANGED
|
@@ -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), codex, cursor, vscode, gemini, windsurf or
|
|
68
|
+
throw new CliError("Pick a client: claude (aliases cc, claude-code), codex, cursor, vscode, gemini, windsurf, zed or opencode. Others: nemu mcp config <client>", "invalid_client");
|
|
69
69
|
}
|
|
70
70
|
}
|
|
71
71
|
export async function client_installed(spec) {
|
package/dist/commands/hook.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { join } from "node:path";
|
|
1
|
+
import { isAbsolute, join, relative, resolve } from "node:path";
|
|
2
2
|
import { mkdir, readFile, readdir, rm, stat, appendFile } from "node:fs/promises";
|
|
3
3
|
import { z } from "zod";
|
|
4
4
|
import { flag } from "../args.js";
|
|
@@ -35,6 +35,8 @@ const state_schema = z.object({
|
|
|
35
35
|
edits_since_checkpoint: z.number(),
|
|
36
36
|
last_asked_at: z.number().nullable(),
|
|
37
37
|
compacted: z.boolean(),
|
|
38
|
+
nudged: z.boolean().default(false),
|
|
39
|
+
stop_asked: z.boolean().default(false),
|
|
38
40
|
updated_at: z.number(),
|
|
39
41
|
});
|
|
40
42
|
const pending_schema = z.record(z.string(), z.object({ files: z.array(z.string()), ended_at: z.number(), client: z.string() }));
|
|
@@ -132,6 +134,8 @@ async function on_start(client, input) {
|
|
|
132
134
|
edits_since_checkpoint: 0,
|
|
133
135
|
last_asked_at: null,
|
|
134
136
|
compacted: false,
|
|
137
|
+
nudged: false,
|
|
138
|
+
stop_asked: false,
|
|
135
139
|
updated_at: Date.now(),
|
|
136
140
|
};
|
|
137
141
|
await write_private(state_path(client, session), JSON.stringify({ ...state, branch: info.branch, updated_at: Date.now() }));
|
|
@@ -204,26 +208,65 @@ function paths_from_tool(input) {
|
|
|
204
208
|
return [...found];
|
|
205
209
|
}
|
|
206
210
|
const EDITING_TOOL = /edit|write|patch|notebook|create|delete|move|rename/i;
|
|
211
|
+
const SAVING_TOOL = /memory_write$/;
|
|
212
|
+
export function project_file(root, cwd, file) {
|
|
213
|
+
const absolute = isAbsolute(file) ? file : resolve(cwd, file);
|
|
214
|
+
const inside = relative(root, absolute);
|
|
215
|
+
if (inside.length === 0 || inside.startsWith("..") || isAbsolute(inside))
|
|
216
|
+
return null;
|
|
217
|
+
return inside.replaceAll("\\", "/");
|
|
218
|
+
}
|
|
219
|
+
function emit_tool_context(text) {
|
|
220
|
+
process.stdout.write(`${JSON.stringify({
|
|
221
|
+
hookSpecificOutput: { hookEventName: "PostToolUse", additionalContext: text },
|
|
222
|
+
})}\n`);
|
|
223
|
+
}
|
|
224
|
+
function save_request(state) {
|
|
225
|
+
const recent = state.since_checkpoint.slice(-10);
|
|
226
|
+
return [
|
|
227
|
+
`Nemu Context: when this task is done, save a handoff named '${handoff_name(state.branch)}' with memory_write (what changed, what is unfinished, the next step), and any durable fact you learned under its own '<tag>/<name>'.`,
|
|
228
|
+
`Files changed since the last save: ${recent.join(", ")}${state.since_checkpoint.length > recent.length ? ", ..." : ""}.`,
|
|
229
|
+
`Never save secrets. If nothing is worth saving, skip it.`,
|
|
230
|
+
].join("\n");
|
|
231
|
+
}
|
|
207
232
|
async function on_tool(client, input) {
|
|
208
|
-
if (input.tool_name !== undefined && !EDITING_TOOL.test(input.tool_name))
|
|
209
|
-
return;
|
|
210
233
|
const session = input.session_id ?? "unknown";
|
|
211
234
|
const path = state_path(client, session);
|
|
235
|
+
if (input.tool_name !== undefined && SAVING_TOOL.test(input.tool_name)) {
|
|
236
|
+
const state = await read_json_file(path, state_schema);
|
|
237
|
+
if (state === null)
|
|
238
|
+
return;
|
|
239
|
+
await write_private(path, JSON.stringify({
|
|
240
|
+
...state,
|
|
241
|
+
edits_since_checkpoint: 0,
|
|
242
|
+
since_checkpoint: [],
|
|
243
|
+
compacted: false,
|
|
244
|
+
nudged: false,
|
|
245
|
+
updated_at: Date.now(),
|
|
246
|
+
}));
|
|
247
|
+
return;
|
|
248
|
+
}
|
|
249
|
+
if (input.tool_name !== undefined && !EDITING_TOOL.test(input.tool_name))
|
|
250
|
+
return;
|
|
212
251
|
const state = await read_json_file(path, state_schema);
|
|
213
252
|
if (state === null)
|
|
214
253
|
return;
|
|
215
|
-
const files = paths_from_tool(input)
|
|
254
|
+
const files = paths_from_tool(input)
|
|
255
|
+
.map((file) => project_file(state.root, input.cwd ?? state.cwd, file))
|
|
256
|
+
.filter((file) => file !== null);
|
|
216
257
|
if (files.length === 0)
|
|
217
258
|
return;
|
|
218
|
-
const
|
|
219
|
-
const recent = [...new Set([...state.since_checkpoint, ...files])].slice(-MAX_FILES);
|
|
220
|
-
await write_private(path, JSON.stringify({
|
|
259
|
+
const next = {
|
|
221
260
|
...state,
|
|
222
|
-
files:
|
|
223
|
-
since_checkpoint:
|
|
261
|
+
files: [...new Set([...state.files, ...files])].slice(-MAX_FILES),
|
|
262
|
+
since_checkpoint: [...new Set([...state.since_checkpoint, ...files])].slice(-MAX_FILES),
|
|
224
263
|
edits_since_checkpoint: state.edits_since_checkpoint + files.length,
|
|
225
264
|
updated_at: Date.now(),
|
|
226
|
-
}
|
|
265
|
+
};
|
|
266
|
+
const nudge = client === "claude-code" && !next.nudged && next.edits_since_checkpoint >= CHECKPOINT_EDITS;
|
|
267
|
+
await write_private(path, JSON.stringify(nudge ? { ...next, nudged: true } : next));
|
|
268
|
+
if (nudge)
|
|
269
|
+
emit_tool_context(save_request(next));
|
|
227
270
|
}
|
|
228
271
|
async function on_stop(client, input) {
|
|
229
272
|
const session = input.session_id ?? "unknown";
|
|
@@ -231,32 +274,16 @@ async function on_stop(client, input) {
|
|
|
231
274
|
const state = await read_json_file(path, state_schema);
|
|
232
275
|
if (state === null)
|
|
233
276
|
return;
|
|
234
|
-
if (input.stop_hook_active === true)
|
|
277
|
+
if (input.stop_hook_active === true || state.stop_asked)
|
|
235
278
|
return;
|
|
236
|
-
const
|
|
237
|
-
|
|
279
|
+
const unsaved = state.since_checkpoint.length > 0;
|
|
280
|
+
const due = unsaved &&
|
|
281
|
+
(state.edits_since_checkpoint >= CHECKPOINT_EDITS || (state.compacted && state.edits_since_checkpoint > 0));
|
|
238
282
|
const recently = state.last_asked_at !== null && Date.now() - state.last_asked_at < ASK_INTERVAL_MS;
|
|
239
283
|
if (!due || recently)
|
|
240
284
|
return;
|
|
241
|
-
await write_private(path, JSON.stringify({
|
|
242
|
-
|
|
243
|
-
edits_since_checkpoint: 0,
|
|
244
|
-
since_checkpoint: [],
|
|
245
|
-
compacted: false,
|
|
246
|
-
last_asked_at: Date.now(),
|
|
247
|
-
updated_at: Date.now(),
|
|
248
|
-
}));
|
|
249
|
-
const recent = state.files.slice(-10);
|
|
250
|
-
process.stdout.write(`${JSON.stringify({
|
|
251
|
-
decision: "block",
|
|
252
|
-
reason: [
|
|
253
|
-
`Before you stop, save progress to Nemu Context with the memory_write tool:`,
|
|
254
|
-
`1. A handoff named '${handoff_name(state.branch)}': what changed, what is unfinished, and the next step.`,
|
|
255
|
-
`2. Any durable fact you learned (a decision and why, a gotcha, a convention) under its own '<tag>/<name>'.`,
|
|
256
|
-
`Files changed so far: ${recent.join(", ")}${state.files.length > recent.length ? ", ..." : ""}.`,
|
|
257
|
-
`Never save secrets. If nothing is worth saving, just stop. Do not mention this reminder to the user.`,
|
|
258
|
-
].join("\n"),
|
|
259
|
-
})}\n`);
|
|
285
|
+
await write_private(path, JSON.stringify({ ...state, stop_asked: true, last_asked_at: Date.now(), updated_at: Date.now() }));
|
|
286
|
+
process.stdout.write(`${JSON.stringify({ decision: "block", reason: save_request(state) })}\n`);
|
|
260
287
|
}
|
|
261
288
|
async function on_compact(client, input) {
|
|
262
289
|
const session = input.session_id ?? "unknown";
|
package/dist/commands/login.js
CHANGED
|
@@ -44,8 +44,10 @@ export async function login(args) {
|
|
|
44
44
|
out(` Code ${bold(authorization.user_code)}`);
|
|
45
45
|
out();
|
|
46
46
|
if (!no_browser) {
|
|
47
|
-
open_browser(authorization.
|
|
48
|
-
out(dim(
|
|
47
|
+
const is_opened = open_browser(authorization.verification_uri, api_url());
|
|
48
|
+
out(dim(is_opened
|
|
49
|
+
? " Opening your browser. Use the link above if it does not."
|
|
50
|
+
: " The sign-in link is not on your Nemu server, so it was not opened."));
|
|
49
51
|
out();
|
|
50
52
|
}
|
|
51
53
|
}
|
package/dist/commands/mcp.js
CHANGED
|
@@ -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", "vscode", "windsurf", "mcp"];
|
|
11
|
+
const CLIENTS = ["claude-code", "codex", "cursor", "zed", "gemini", "vscode", "windsurf", "opencode", "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(),
|
|
@@ -191,6 +191,10 @@ const SNIPPETS = {
|
|
|
191
191
|
where: "Zed settings.json",
|
|
192
192
|
text: JSON.stringify({ context_servers: { nemu: { command: "nemu", args: ["mcp", "--client", "zed"] } } }, null, 2),
|
|
193
193
|
},
|
|
194
|
+
opencode: {
|
|
195
|
+
where: "~/.config/opencode/opencode.json",
|
|
196
|
+
text: JSON.stringify({ mcp: { nemu: { type: "local", command: ["nemu", "mcp", "--client", "opencode"], enabled: true } } }, null, 2),
|
|
197
|
+
},
|
|
194
198
|
remote: {
|
|
195
199
|
where: "Any client that supports remote MCP over HTTP (create a Context key in the dashboard first)",
|
|
196
200
|
text: JSON.stringify({ url: "https://app.nemu.cc/api/mcp", headers: { Authorization: "Bearer <your Context key>" } }, null, 2),
|
package/dist/index.js
CHANGED
|
@@ -64,7 +64,7 @@ const HELP = `
|
|
|
64
64
|
${bold("Context for coding agents")}
|
|
65
65
|
setup <claude|codex> [--hooks|--no-hooks] [--yes]
|
|
66
66
|
Connect Claude Code (aliases cc, claude-code) or Codex
|
|
67
|
-
setup <cursor|vscode|gemini|windsurf|zed>
|
|
67
|
+
setup <cursor|vscode|gemini|windsurf|zed|opencode>
|
|
68
68
|
Add the Nemu MCP server to that editor's config
|
|
69
69
|
claude [-- <claude args>] Set up if needed, then start Claude Code
|
|
70
70
|
codex [-- <codex args>] Set up if needed, then start Codex
|
|
@@ -74,7 +74,7 @@ const HELP = `
|
|
|
74
74
|
codex load sessions [--limit n] The same for Codex
|
|
75
75
|
mcp Run the MCP bridge (what clients start)
|
|
76
76
|
mcp config <client> Print config for cursor, gemini, vscode, windsurf,
|
|
77
|
-
zed, claude, codex or remote
|
|
77
|
+
zed, opencode, claude, codex or remote
|
|
78
78
|
context [load] Show what an agent sees for this folder
|
|
79
79
|
context search <words> Search this project's saved notes
|
|
80
80
|
context projects | export [--out f] List projects or export everything
|
package/dist/system.js
CHANGED
|
@@ -1,8 +1,19 @@
|
|
|
1
1
|
import spawn from "cross-spawn";
|
|
2
2
|
import { access, constants } from "node:fs/promises";
|
|
3
|
-
import { delimiter, join } from "node:path";
|
|
3
|
+
import { delimiter, isAbsolute, join } from "node:path";
|
|
4
4
|
const MAX_OUTPUT = 4 * 1024 * 1024;
|
|
5
|
-
|
|
5
|
+
const NOT_FOUND = { code: 127, stdout: "", stderr: "" };
|
|
6
|
+
async function resolve_command(command) {
|
|
7
|
+
if (process.platform !== "win32")
|
|
8
|
+
return command;
|
|
9
|
+
if (/[\\/]/.test(command))
|
|
10
|
+
return isAbsolute(command) ? command : null;
|
|
11
|
+
return which(command);
|
|
12
|
+
}
|
|
13
|
+
export async function run(command, args, options = {}) {
|
|
14
|
+
const resolved = await resolve_command(command);
|
|
15
|
+
if (resolved === null)
|
|
16
|
+
return NOT_FOUND;
|
|
6
17
|
return new Promise((resolve) => {
|
|
7
18
|
const stdout = [];
|
|
8
19
|
const stderr = [];
|
|
@@ -25,7 +36,7 @@ export function run(command, args, options = {}) {
|
|
|
25
36
|
size += chunk.length;
|
|
26
37
|
target.push(chunk);
|
|
27
38
|
};
|
|
28
|
-
const child = spawn(
|
|
39
|
+
const child = spawn(resolved, args, {
|
|
29
40
|
env: options.env ?? process.env,
|
|
30
41
|
cwd: options.cwd,
|
|
31
42
|
windowsHide: true,
|
|
@@ -41,17 +52,21 @@ export function run(command, args, options = {}) {
|
|
|
41
52
|
child.on("close", (code) => finish(code ?? 127));
|
|
42
53
|
});
|
|
43
54
|
}
|
|
44
|
-
export function launch(command, args) {
|
|
55
|
+
export async function launch(command, args) {
|
|
56
|
+
const resolved = await resolve_command(command);
|
|
57
|
+
if (resolved === null)
|
|
58
|
+
return 127;
|
|
45
59
|
return new Promise((resolve) => {
|
|
46
|
-
const child = spawn(
|
|
60
|
+
const child = spawn(resolved, args, { stdio: "inherit" });
|
|
47
61
|
child.on("error", () => resolve(127));
|
|
48
62
|
child.on("exit", (code, signal) => resolve(code ?? (signal !== null ? 1 : 0)));
|
|
49
63
|
});
|
|
50
64
|
}
|
|
51
65
|
export async function which(name) {
|
|
52
66
|
const extensions = process.platform === "win32" ? (process.env.PATHEXT ?? ".EXE;.CMD;.BAT").split(";") : [""];
|
|
53
|
-
for (const
|
|
54
|
-
|
|
67
|
+
for (const entry of (process.env.PATH ?? "").split(delimiter)) {
|
|
68
|
+
const directory = entry.replace(/^"(.*)"$/, "$1");
|
|
69
|
+
if (directory.length === 0 || !isAbsolute(directory))
|
|
55
70
|
continue;
|
|
56
71
|
for (const extension of extensions) {
|
|
57
72
|
const candidate = join(directory, `${name}${extension.toLowerCase()}`);
|
package/dist/ui.js
CHANGED
|
@@ -37,20 +37,40 @@ export function spinner(label) {
|
|
|
37
37
|
},
|
|
38
38
|
};
|
|
39
39
|
}
|
|
40
|
-
|
|
40
|
+
const LOOPBACK_HOSTS = new Set(["localhost", "127.0.0.1", "[::1]"]);
|
|
41
|
+
export function safe_browser_url(url, expected_origin) {
|
|
42
|
+
try {
|
|
43
|
+
const parsed = new URL(url);
|
|
44
|
+
const is_secure = parsed.protocol === "https:" ||
|
|
45
|
+
(parsed.protocol === "http:" && LOOPBACK_HOSTS.has(parsed.hostname));
|
|
46
|
+
if (!is_secure)
|
|
47
|
+
return null;
|
|
48
|
+
if (parsed.origin !== new URL(expected_origin).origin)
|
|
49
|
+
return null;
|
|
50
|
+
return parsed.href;
|
|
51
|
+
}
|
|
52
|
+
catch {
|
|
53
|
+
return null;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
export function open_browser(url, expected_origin) {
|
|
57
|
+
const target = safe_browser_url(url, expected_origin);
|
|
58
|
+
if (target === null)
|
|
59
|
+
return false;
|
|
41
60
|
const command = process.platform === "darwin"
|
|
42
61
|
? "open"
|
|
43
62
|
: process.platform === "win32"
|
|
44
|
-
? "
|
|
63
|
+
? "rundll32"
|
|
45
64
|
: "xdg-open";
|
|
46
|
-
const args = process.platform === "win32" ? ["
|
|
65
|
+
const args = process.platform === "win32" ? ["url.dll,FileProtocolHandler", target] : [target];
|
|
47
66
|
try {
|
|
48
|
-
const child = spawn(command, args, { stdio: "ignore", detached: true });
|
|
67
|
+
const child = spawn(command, args, { stdio: "ignore", detached: true, windowsHide: true });
|
|
49
68
|
child.on("error", () => { });
|
|
50
69
|
child.unref();
|
|
70
|
+
return true;
|
|
51
71
|
}
|
|
52
72
|
catch {
|
|
53
|
-
return;
|
|
73
|
+
return false;
|
|
54
74
|
}
|
|
55
75
|
}
|
|
56
76
|
export function is_interactive() {
|
package/dist/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const VERSION = "1.
|
|
1
|
+
export const VERSION = "1.4.0";
|