nemu-cli 1.3.0 → 1.3.1
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 +9 -0
- package/dist/clients/hooks.js +21 -5
- package/dist/commands/client.js +9 -1
- package/dist/commands/status.js +4 -1
- package/dist/version.js +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 1.3.1
|
|
4
|
+
|
|
5
|
+
Fixes "hook failed, exited with code 1" for Codex on Windows. Codex starts hooks through a Windows
|
|
6
|
+
shell that cannot launch a command whose program path is quoted, and setup wrote the path to
|
|
7
|
+
`nemu.cmd` in quotes. The Codex hooks now name the program unquoted (or as `nemu.cmd` when its
|
|
8
|
+
path has spaces). `nemu codex` repairs hooks written by an earlier version before it starts Codex,
|
|
9
|
+
`nemu setup codex --hooks` does the same, and `nemu status` says when a repair is needed. Claude
|
|
10
|
+
Code runs hooks through Git Bash on Windows and is unchanged.
|
|
11
|
+
|
|
3
12
|
## 1.3.0
|
|
4
13
|
|
|
5
14
|
`nemu setup cursor`, `nemu setup vscode`, `nemu setup gemini`, `nemu setup windsurf` and
|
package/dist/clients/hooks.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { readFile, writeFile, mkdir, rename, copyFile, access } from "node:fs/promises";
|
|
2
|
-
import { dirname } from "node:path";
|
|
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 = {
|
|
@@ -34,8 +34,18 @@ export function is_own_command(command) {
|
|
|
34
34
|
function quote(path) {
|
|
35
35
|
return /[\s"'$`\\]/.test(path) ? `"${path.replace(/(["\\$`])/g, "\\$1")}"` : path;
|
|
36
36
|
}
|
|
37
|
-
|
|
38
|
-
|
|
37
|
+
const WINDOWS_UNSAFE = /[\s"'&|<>^%()!`]/;
|
|
38
|
+
function windows_program(nemu) {
|
|
39
|
+
return WINDOWS_UNSAFE.test(nemu) ? win32.basename(nemu) : nemu;
|
|
40
|
+
}
|
|
41
|
+
export function hook_command(nemu, hook, client, platform = process.platform) {
|
|
42
|
+
const rest = `hook ${hook} --client ${client}`;
|
|
43
|
+
if (client === "codex" && platform === "win32")
|
|
44
|
+
return `${windows_program(nemu)} ${rest}`;
|
|
45
|
+
return `${quote(nemu)} ${rest}`;
|
|
46
|
+
}
|
|
47
|
+
export function has_quoted_program(command) {
|
|
48
|
+
return command !== undefined && /^\s*["']/.test(command) && is_own_command(command);
|
|
39
49
|
}
|
|
40
50
|
async function exists(path) {
|
|
41
51
|
try {
|
|
@@ -90,13 +100,19 @@ function without_own(config) {
|
|
|
90
100
|
const { hooks: _previous, ...rest } = config;
|
|
91
101
|
return Object.keys(cleaned).length > 0 ? { ...rest, hooks: cleaned } : rest;
|
|
92
102
|
}
|
|
93
|
-
export async function
|
|
103
|
+
export async function needs_repair(path, platform = process.platform) {
|
|
104
|
+
if (platform !== "win32")
|
|
105
|
+
return false;
|
|
106
|
+
const config = await read_config(path).catch(() => ({}));
|
|
107
|
+
return Object.values(config.hooks ?? {}).some((groups) => groups.some((group) => (group.hooks ?? []).some((handler) => has_quoted_program(handler.command))));
|
|
108
|
+
}
|
|
109
|
+
export async function install_hooks(path, nemu, client, platform = process.platform) {
|
|
94
110
|
const config = without_own(await read_config(path));
|
|
95
111
|
const hooks = { ...(config.hooks ?? {}) };
|
|
96
112
|
for (const spec of HOOK_SPECS[client]) {
|
|
97
113
|
const group = {
|
|
98
114
|
...(spec.matcher !== undefined ? { matcher: spec.matcher } : {}),
|
|
99
|
-
hooks: [{ type: "command", command: hook_command(nemu, spec.hook, client), timeout: spec.timeout }],
|
|
115
|
+
hooks: [{ type: "command", command: hook_command(nemu, spec.hook, client, platform), timeout: spec.timeout }],
|
|
100
116
|
};
|
|
101
117
|
hooks[spec.event] = [...(hooks[spec.event] ?? []), group];
|
|
102
118
|
}
|
package/dist/commands/client.js
CHANGED
|
@@ -2,7 +2,8 @@ import { client_from_name } from "../clients/registry.js";
|
|
|
2
2
|
import { launch } from "../system.js";
|
|
3
3
|
import { out, dim } from "../ui.js";
|
|
4
4
|
import { load } from "./load.js";
|
|
5
|
-
import { run_setup } from "./setup.js";
|
|
5
|
+
import { resolve_nemu_binary, run_setup } from "./setup.js";
|
|
6
|
+
import { install_hooks, needs_repair } from "../clients/hooks.js";
|
|
6
7
|
export function client_command(name) {
|
|
7
8
|
return async (args) => {
|
|
8
9
|
const spec = client_from_name(name);
|
|
@@ -14,6 +15,13 @@ export function client_command(name) {
|
|
|
14
15
|
out(dim(` Connecting ${spec.label} to Nemu Context first.`));
|
|
15
16
|
await run_setup(spec, args);
|
|
16
17
|
}
|
|
18
|
+
else if (spec.id === "codex" && (await needs_repair(spec.hooks_path()))) {
|
|
19
|
+
const nemu = await resolve_nemu_binary(false).catch(() => null);
|
|
20
|
+
if (nemu !== null) {
|
|
21
|
+
await install_hooks(spec.hooks_path(), nemu, spec.id);
|
|
22
|
+
out(dim(" Repaired the Nemu hooks so Codex on Windows can run them."));
|
|
23
|
+
}
|
|
24
|
+
}
|
|
17
25
|
return launch(spec.binary, args.positional);
|
|
18
26
|
};
|
|
19
27
|
}
|
package/dist/commands/status.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { has_scope, read_credentials, read_settings, api_url } from "../config.js";
|
|
2
|
-
import { installed_hooks, HOOK_SPECS } from "../clients/hooks.js";
|
|
2
|
+
import { installed_hooks, needs_repair, HOOK_SPECS } from "../clients/hooks.js";
|
|
3
3
|
import { CLIENTS, client_installed } from "../clients/registry.js";
|
|
4
4
|
import { EDITORS, editor_has_nemu } from "../clients/editors.js";
|
|
5
5
|
import { run, which } from "../system.js";
|
|
@@ -25,6 +25,7 @@ export async function status() {
|
|
|
25
25
|
mcp,
|
|
26
26
|
hooks,
|
|
27
27
|
hooks_complete: hooks.length === HOOK_SPECS[spec.id].length,
|
|
28
|
+
hooks_need_repair: spec.id === "codex" && installed ? await needs_repair(spec.hooks_path()) : false,
|
|
28
29
|
hooks_path: spec.hooks_path(),
|
|
29
30
|
};
|
|
30
31
|
}));
|
|
@@ -69,6 +70,8 @@ export async function status() {
|
|
|
69
70
|
continue;
|
|
70
71
|
out(` MCP server ${mark(client.mcp)}${client.mcp ? "" : dim(` nemu setup ${client.id === "codex" ? "codex" : "claude"}`)}`);
|
|
71
72
|
out(` Hooks ${client.hooks.length === 0 ? dim("none") : client.hooks_complete ? green("all") : `${client.hooks.join(", ")}`}`);
|
|
73
|
+
if (client.hooks_need_repair)
|
|
74
|
+
out(` ${red("Hooks cannot start on Windows.")} ${dim("Repair with: nemu setup codex --hooks")}`);
|
|
72
75
|
}
|
|
73
76
|
const found = editors.filter((editor) => editor.installed);
|
|
74
77
|
if (found.length > 0) {
|
package/dist/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const VERSION = "1.3.
|
|
1
|
+
export const VERSION = "1.3.1";
|