nemu-cli 1.10.0 → 1.10.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 CHANGED
@@ -1,5 +1,11 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.10.1
4
+
5
+ Updating no longer skips hooks that a newer release added. A setup made before 1.10.1 gets the
6
+ prompt hook that shows other agents' unread messages the next time the CLI runs; hooks you removed
7
+ yourself stay removed.
8
+
3
9
  ## 1.10.0
4
10
 
5
11
  `nemu studio` builds 3D models with Nemu Studio from the terminal: `create` starts a cloud job and
@@ -2,10 +2,11 @@ import { readFile, writeFile, mkdir, rename, copyFile, access, chmod, stat } fro
2
2
  import { dirname, win32 } from "node:path";
3
3
  import { z } from "zod";
4
4
  import { CliError } from "../errors.js";
5
+ import { is_newer } from "../update.js";
5
6
  export const HOOK_SPECS = {
6
7
  "claude-code": [
7
8
  { event: "SessionStart", hook: "start", matcher: "startup|resume|clear|compact", timeout: 20 },
8
- { event: "UserPromptSubmit", hook: "prompt", timeout: 5 },
9
+ { event: "UserPromptSubmit", hook: "prompt", timeout: 5, since: "1.10.1" },
9
10
  { event: "PostToolUse", hook: "tool", matcher: "Edit|Write|MultiEdit|NotebookEdit|mcp__nemu__memory_write", timeout: 5 },
10
11
  { event: "Stop", hook: "stop", timeout: 10 },
11
12
  { event: "PreCompact", hook: "compact", matcher: "manual|auto", timeout: 5 },
@@ -13,7 +14,7 @@ export const HOOK_SPECS = {
13
14
  ],
14
15
  codex: [
15
16
  { event: "SessionStart", hook: "start", matcher: "^(startup|resume|clear|compact)$", timeout: 20 },
16
- { event: "UserPromptSubmit", hook: "prompt", timeout: 5 },
17
+ { event: "UserPromptSubmit", hook: "prompt", timeout: 5, since: "1.10.1" },
17
18
  { event: "PostToolUse", hook: "tool", timeout: 5 },
18
19
  { event: "Stop", hook: "stop", timeout: 10 },
19
20
  { event: "PreCompact", hook: "compact", timeout: 5 },
@@ -110,15 +111,20 @@ export async function needs_repair(path, platform = process.platform) {
110
111
  const config = await read_config(path).catch(() => ({}));
111
112
  return Object.values(config.hooks ?? {}).some((groups) => groups.some((group) => (group.hooks ?? []).some((handler) => has_quoted_program(handler.command))));
112
113
  }
114
+ function own_group(spec, nemu, client, platform) {
115
+ return {
116
+ ...(spec.matcher !== undefined ? { matcher: spec.matcher } : {}),
117
+ hooks: [{ type: "command", command: hook_command(nemu, spec.hook, client, platform), timeout: spec.timeout }],
118
+ };
119
+ }
120
+ function is_introduced_since(spec, setup_version) {
121
+ return spec.since !== undefined && setup_version !== undefined && is_newer(spec.since, setup_version);
122
+ }
113
123
  export async function install_hooks(path, nemu, client, platform = process.platform) {
114
124
  const config = without_own(await read_config(path));
115
125
  const hooks = { ...(config.hooks ?? {}) };
116
126
  for (const spec of HOOK_SPECS[client]) {
117
- const group = {
118
- ...(spec.matcher !== undefined ? { matcher: spec.matcher } : {}),
119
- hooks: [{ type: "command", command: hook_command(nemu, spec.hook, client, platform), timeout: spec.timeout }],
120
- };
121
- hooks[spec.event] = [...(hooks[spec.event] ?? []), group];
127
+ hooks[spec.event] = [...(hooks[spec.event] ?? []), own_group(spec, nemu, client, platform)];
122
128
  }
123
129
  await write_config(path, { ...config, hooks });
124
130
  }
@@ -149,7 +155,7 @@ export async function installed_hooks(path) {
149
155
  .filter(([, groups]) => groups.some((group) => (group.hooks ?? []).some((handler) => is_own_command(handler.command))))
150
156
  .map(([event]) => event);
151
157
  }
152
- function refreshed(config, nemu, client, platform) {
158
+ function refreshed(config, nemu, client, platform, setup_version) {
153
159
  const specs = HOOK_SPECS[client];
154
160
  const hooks = {};
155
161
  for (const [event, groups] of Object.entries(config.hooks ?? {})) {
@@ -175,18 +181,24 @@ function refreshed(config, nemu, client, platform) {
175
181
  if (kept.length > 0)
176
182
  hooks[event] = kept;
177
183
  }
184
+ for (const spec of specs.filter((candidate) => is_introduced_since(candidate, setup_version))) {
185
+ const groups = hooks[spec.event] ?? [];
186
+ const has_own = groups.some((group) => (group.hooks ?? []).some((handler) => is_own_command(handler.command)));
187
+ if (!has_own)
188
+ hooks[spec.event] = [...groups, own_group(spec, nemu, client, platform)];
189
+ }
178
190
  const { hooks: _previous, ...rest } = config;
179
191
  return Object.keys(hooks).length > 0 ? { ...rest, hooks } : rest;
180
192
  }
181
- export async function hooks_outdated(path, nemu, client, platform = process.platform) {
193
+ export async function hooks_outdated(path, nemu, client, platform = process.platform, setup_version) {
182
194
  if ((await installed_hooks(path)).length === 0)
183
195
  return false;
184
196
  const config = await read_config(path);
185
- return stable(refreshed(config, nemu, client, platform)) !== stable(config);
197
+ return stable(refreshed(config, nemu, client, platform, setup_version)) !== stable(config);
186
198
  }
187
- export async function refresh_hooks(path, nemu, client, platform = process.platform) {
188
- if (!(await hooks_outdated(path, nemu, client, platform)))
199
+ export async function refresh_hooks(path, nemu, client, platform = process.platform, setup_version) {
200
+ if (!(await hooks_outdated(path, nemu, client, platform, setup_version)))
189
201
  return false;
190
- await write_config(path, refreshed(await read_config(path), nemu, client, platform));
202
+ await write_config(path, refreshed(await read_config(path), nemu, client, platform, setup_version));
191
203
  return true;
192
204
  }
@@ -11,8 +11,8 @@ export const MIGRATIONS = [
11
11
  ...Object.values(CLIENTS).map((spec) => ({
12
12
  id: `hooks:${spec.id}`,
13
13
  label: `${spec.label}: updated the Nemu hooks`,
14
- needed: (nemu) => hooks_outdated(spec.hooks_path(), nemu, spec.id),
15
- apply: (nemu) => refresh_hooks(spec.hooks_path(), nemu, spec.id),
14
+ needed: (nemu, setup_version) => hooks_outdated(spec.hooks_path(), nemu, spec.id, process.platform, setup_version),
15
+ apply: (nemu, setup_version) => refresh_hooks(spec.hooks_path(), nemu, spec.id, process.platform, setup_version),
16
16
  })),
17
17
  ...Object.values(EDITORS).map((editor) => ({
18
18
  id: `mcp:${editor.id}`,
@@ -31,11 +31,12 @@ export async function run_migrations(migrations = MIGRATIONS) {
31
31
  const nemu = await resolve_nemu_binary(false).catch(() => null);
32
32
  if (nemu === null)
33
33
  return report;
34
+ const setup_version = (await read_settings().catch(() => null))?.setup_version;
34
35
  for (const migration of migrations) {
35
36
  try {
36
- if (!(await migration.needed(nemu)))
37
+ if (!(await migration.needed(nemu, setup_version)))
37
38
  continue;
38
- if (await migration.apply(nemu))
39
+ if (await migration.apply(nemu, setup_version))
39
40
  report.applied.push(migration.label);
40
41
  }
41
42
  catch (error) {
package/dist/version.js CHANGED
@@ -1 +1 @@
1
- export const VERSION = "1.10.0";
1
+ export const VERSION = "1.10.1";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nemu-cli",
3
- "version": "1.10.0",
3
+ "version": "1.10.1",
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"
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nemu",
3
- "version": "1.10.0",
3
+ "version": "1.10.1",
4
4
  "description": "Project memory and vaults that follow you across machines and agents, with /remember and /inspo",
5
5
  "author": { "name": "Nemu" },
6
6
  "homepage": "https://docs.nemu.cc/context/claude-code",