@cmodjs/core 5.2.0 → 5.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.
Files changed (71) hide show
  1. package/docs/commands.md +4 -4
  2. package/docs/dependencies.md +2 -2
  3. package/docs/install-steps.md +2 -0
  4. package/docs/jobs.md +1 -1
  5. package/docs/state.md +1 -1
  6. package/docs/testing.md +1 -1
  7. package/docs/ui.md +1 -1
  8. package/jobs/program.d.ts.map +1 -1
  9. package/jobs/program.js +55 -4
  10. package/package.json +1 -1
  11. package/records.d.ts +2 -2
  12. package/records.js +2 -2
  13. package/register.d.ts.map +1 -1
  14. package/register.js +23 -3
  15. package/runtime/claude.d.ts +2 -0
  16. package/runtime/claude.d.ts.map +1 -1
  17. package/runtime/conversations.js +8 -8
  18. package/runtime/deadline.d.ts +2 -0
  19. package/runtime/deadline.d.ts.map +1 -1
  20. package/runtime/deadline.js +17 -0
  21. package/runtime/engine.d.ts +2 -0
  22. package/runtime/engine.d.ts.map +1 -1
  23. package/runtime/hooks.js +2 -2
  24. package/runtime/hotkeys.js +1 -1
  25. package/runtime/installer.js +1 -1
  26. package/runtime/lifecycle.d.ts.map +1 -1
  27. package/runtime/lifecycle.js +107 -74
  28. package/runtime/metadata.js +1 -1
  29. package/runtime/options.js +1 -1
  30. package/runtime/pages.js +3 -3
  31. package/runtime/programs.d.ts +1 -0
  32. package/runtime/programs.d.ts.map +1 -1
  33. package/runtime/programs.js +6 -0
  34. package/runtime/sessions.d.ts.map +1 -1
  35. package/runtime/sessions.js +46 -23
  36. package/runtime/state.d.ts +1 -0
  37. package/runtime/state.d.ts.map +1 -1
  38. package/runtime/state.js +6 -3
  39. package/runtime/toaster.d.ts +5 -0
  40. package/runtime/toaster.d.ts.map +1 -1
  41. package/runtime/toaster.js +27 -11
  42. package/runtime/ui.d.ts +1 -0
  43. package/runtime/ui.d.ts.map +1 -1
  44. package/runtime/ui.js +6 -6
  45. package/runtime/widgets.js +1 -1
  46. package/src/jobs/program.ts +60 -4
  47. package/src/records.ts +2 -2
  48. package/src/register.ts +25 -3
  49. package/src/runtime/claude.ts +2 -0
  50. package/src/runtime/conversations.ts +8 -8
  51. package/src/runtime/deadline.ts +16 -0
  52. package/src/runtime/engine.ts +2 -0
  53. package/src/runtime/hooks.ts +2 -2
  54. package/src/runtime/hotkeys.ts +1 -1
  55. package/src/runtime/installer.ts +1 -1
  56. package/src/runtime/lifecycle.ts +99 -66
  57. package/src/runtime/metadata.ts +1 -1
  58. package/src/runtime/options.ts +1 -1
  59. package/src/runtime/pages.ts +3 -3
  60. package/src/runtime/programs.ts +7 -0
  61. package/src/runtime/sessions.ts +46 -18
  62. package/src/runtime/state.ts +7 -3
  63. package/src/runtime/toaster.ts +47 -12
  64. package/src/runtime/ui.ts +6 -6
  65. package/src/runtime/widgets.ts +1 -1
  66. package/src/testing/fake-claude.ts +2 -0
  67. package/src/testing.ts +6 -2
  68. package/testing/fake-claude.d.ts.map +1 -1
  69. package/testing/fake-claude.js +2 -0
  70. package/testing.d.ts.map +1 -1
  71. package/testing.js +7 -2
package/docs/commands.md CHANGED
@@ -264,10 +264,10 @@ Runs a removed mod's saved uninstall step, then deletes its install record, the
264
264
  ### cmod hotkey
265
265
 
266
266
  ```text
267
- cmod hotkey <mod> <hotkey> <combo>
267
+ cmod hotkey <mod | plugin-root> <hotkey> <combo>
268
268
  ```
269
269
 
270
- Binds one hotkey of a mod to a new combo in Claude Code's `keybindings.json`, such as `cmod hotkey notes toggle ctrl+shift+n`, and removes the combo it had. It binds a hotkey without a default combo the same way. A combo in Settings, under the mod, Hotkeys, runs it, and so does the cmod plugin for its own two hotkeys at its first start. It refuses a combo that is not one, and a combo the person already bound to something else, with `<combo> already runs something else in ~/.claude/keybindings.json. Pick another combo.` The mod's next update keeps the combo ([mod.md](mod.md#hotkeys)).
270
+ Binds one hotkey of a mod to a new combo in Claude Code's `keybindings.json`, such as `cmod hotkey notes toggle ctrl+shift+n`, and removes the combo it had. It binds a hotkey without a default combo the same way. A plugin root holds a `/`, such as `./notes`, so a mod Claude Code loads with `--plugin-dir`, which has no install record, binds its hotkeys too. A combo in Settings, under the mod, Hotkeys, runs it, and so does the cmod plugin for its own two hotkeys at its first start, with its own plugin folder. It refuses a combo that is not one, and a combo the person already bound to something else, with `<combo> already runs something else in ~/.claude/keybindings.json. Pick another combo.` The mod's next update keeps the combo ([mod.md](mod.md#hotkeys)).
271
271
 
272
272
  ### cmod secret
273
273
 
@@ -308,10 +308,10 @@ Starts a task in a new background Claude Code session, for a mod's `startTask` w
308
308
  ### cmod program
309
309
 
310
310
  ```text
311
- cmod program <mod> -- <command…>
311
+ cmod program <mod> [--no-wait] -- <command…>
312
312
  ```
313
313
 
314
- Runs one copy of a mod's program for the whole computer, for a `program` job with `singleInstance` ([jobs.md](jobs.md#program)), which every session of the mod runs it for. The first one takes `instances/<mod>/<program>.json.lock` in the cmod store, runs the command without `CLAUDE_CODE_SESSION_ID`, because the copy serves every session, writes its first line on standard output, its address, with the copy's process to `instances/<mod>/<program>.json`, and prints it. Every other one prints the address in that file, then each new one as it changes, and tries the lock again whenever that folder changes and every 5 seconds, so it takes over once the holder exits. A lock whose process is gone counts as free. The holder stops its copy and gives up the lock on SIGTERM, SIGINT, or SIGHUP, and when the session that started it exits, which it checks every 5 seconds. When the copy exits on its own, the holder exits with the copy's exit code, and the copy's standard error passes through. A new holder that finds a copy an earlier holder left running sends it SIGTERM, then SIGKILL after 5 seconds, and starts its own copy only once that one is gone, so two copies never run at once.
314
+ Runs one copy of a mod's program for the whole computer, for a `program` job with `singleInstance` ([jobs.md](jobs.md#program)). The first one takes `instances/<mod>/<program>.json.lock` in the cmod store, runs the command without `CLAUDE_CODE_SESSION_ID`, because the copy serves every session, writes its first line on standard output, its address, with the copy's process to `instances/<mod>/<program>.json`, and prints it. It touches its file in the lock every 5 seconds. With `--no-wait`, which a mod's session passes, another one touches the holder's file, prints `held`, and exits 0, and the session reads the address from `instances/<mod>/<program>.json` and runs `cmod program` again once that file is gone or the holder's file is 15 seconds old. Without it, as a mod built on `@cmodjs/core` before 5.3.0 runs it, another one prints the address in that file, then each new one as it changes, and tries the lock again whenever that folder changes and every 5 seconds, so it takes over once the holder exits. A lock whose process is gone counts as free. The holder stops its copy and gives up the lock on SIGTERM, SIGINT, or SIGHUP, and when the session that started it exits, which it checks every 5 seconds. When the copy exits on its own, the holder exits with the copy's exit code, and the copy's standard error passes through. A new holder that finds a copy an earlier holder left running sends it SIGTERM, then SIGKILL after 5 seconds, and starts its own copy only once that one is gone, so two copies never run at once.
315
315
 
316
316
  ### cmod option
317
317
 
@@ -98,14 +98,14 @@ A call that cannot answer rejects with one of these reasons:
98
98
 
99
99
  ```text
100
100
  tracer is not installed. Install it in Plugins.
101
- tracer is not set up. Its toast says why.
101
+ tracer is not set up: <why its setup failed>
102
102
  tracer is installing. Try again when it's ready.
103
103
  tracer has no method signatures.
104
104
  tracer: <the message of the error the method threw>
105
105
  ```
106
106
 
107
107
  - `tracer is not installed` covers a provider whose code did not load. The caller's error toast shows a `Plugins` button, which opens Claude Code's `/plugin`.
108
- - `tracer is not set up` covers a provider the person declined to install and one whose install failed. Its own toast shows why, with `Retry` or `Install`.
108
+ - `tracer is not set up` covers a provider the person declined to install and one whose install failed, and names why. The provider's own toast shows the same reason, with `Retry` or `Install`.
109
109
  - `tracer is installing` covers a provider that is still running its install step. A provider that is only starting makes the call wait for it, up to 9 seconds.
110
110
  - When tracer is disabled, Claude Code unloads the mod that lists it, with its own error: `Dependency "tracer" is disabled — enable it or remove the dependency`.
111
111
  - A call fails with `mod.dependencies.tracer.signatures passed its 30 s deadline` when the other mod takes longer than 30 seconds. A job bounds the whole function that makes the call by its own deadline ([jobs.md](jobs.md)), so a slow call inside `slashCommand` can fail the command first, with `/outline passed the 30 s deadline of slashCommand`.
@@ -233,3 +233,5 @@ A mod runs on macOS and Linux, on arm64 and x64, unless the `os` and `cpu` keys
233
233
  Claude Code itself has no field for this, and installs the mod on any machine.
234
234
 
235
235
  The cmod repository ships the `cmod` program this way. Its `package.json` holds `"cmod": { "program": "cmod" }`, and its `cli/package.json` holds `"cmod": { "build": "bun run build", "output": "dist" }`.
236
+
237
+ Its `build` script passes `--no-compile-autoload-dotenv --no-compile-autoload-bunfig` to `bun build --compile`, because a compiled Bun program otherwise loads the `.env` and `bunfig.toml` of the folder it runs in, and runs that `bunfig.toml`'s `preload` scripts inside itself. It starts with `trap 'rm -f .*.bun-build' EXIT;`, because Bun 1.4.4 leaves an 89 MB `.<hash>-00000000.bun-build` file beside every compile.
package/docs/jobs.md CHANGED
@@ -332,7 +332,7 @@ type Program = {
332
332
  - The program's first line on standard output must be its address: `127.0.0.1:<port>`, or `unix:<absolute socket path>`. `ready()` then resolves `{ url: 'http://127.0.0.1:<port>' }`, or `{ url: 'http://localhost', socketPath }`. Pass both to `http.fetch`, which reaches that address.
333
333
  - In an interactive session the program starts with the mod. Otherwise it starts at the first `ready()`.
334
334
  - When the program exits, cmod starts it again after 1, 2, 4, 8, and 16 seconds. After 5 failed tries, or a first line that is not an address, the state is `fatal`, `ready()` rejects, and cmod logs `<mod>: the <program> program stopped: <reason>`.
335
- - `singleInstance: true` runs one copy on the computer, however many sessions load the mod, such as a server that is the only writer of its data. Each session runs it through [`cmod program`](commands.md#cmod-program): the first session starts the copy, and every session's `ready()` resolves that copy's address. When the session running the copy ends, another open session starts a new copy, and from then on `ready()` resolves the new address in every session, so ask `ready()` before each use rather than keeping its answer. A copy a killed session left running is stopped before the new one starts. Two `singleInstance` programs with the same program name in one mod throw at `mod.use`.
335
+ - `singleInstance: true` runs one copy on the computer, however many sessions load the mod, such as a server that is the only writer of its data. The first session starts the copy through [`cmod program`](commands.md#cmod-program), every other session reads the copy's address from the cmod store and runs no process of its own, and every session's `ready()` resolves that copy's address. When the session running the copy ends, another open session starts a new copy within a few seconds, or within 20 seconds when the copy's session was killed with its `cmod program`, and from then on `ready()` resolves the new address in every session, so ask `ready()` before each use rather than keeping its answer. A copy a killed session left running is stopped before the new one starts. Two `singleInstance` programs with the same program name in one mod throw at `mod.use`.
336
336
  - A program that ships with the mod gets onto `PATH` through the `program` key of the mod's `package.json` ([install-steps.md](install-steps.md)). A program an install step fetched with `cmod download` is not on `PATH`, so `command` names it by its full path, `${mod.dataFolder}/bin/<program>`.
337
337
 
338
338
  ```ts
package/docs/state.md CHANGED
@@ -79,7 +79,7 @@ export const reads = defineMod({
79
79
  })
80
80
  ```
81
81
 
82
- - Keep only JSON data in a saved group. A value cmod cannot save logs `<mod> could not keep state.<group>.<key>: <error>. Keep only JSON data in mod.state.`
82
+ - Keep only JSON data in a saved group. A value cmod cannot save, such as one that is not JSON, fails as `Could not keep state.<group>.<key>`, with Claude Code's reason under it.
83
83
  - cmod saves values one at a time in the order they were assigned.
84
84
 
85
85
  ## Where the values come from
package/docs/testing.md CHANGED
@@ -310,7 +310,7 @@ Set a fake to answer a call:
310
310
  - `device.read` answers `{ id: '5f0e8c2a9b7d4e31a6c4d2b0e8f71a93', name: 'test-computer', os: 'linux', arch: 'x64' }` unless set, so `device.read()` and each turn's `device` answer the same in every test on every computer. Set it to test the mod on another computer, or to reject to test a computer cmod cannot read, where the cmod plugin's note is left out and turns have no `device`.
311
311
  - A call with no fake throws `<call>(<args>) has no fake answer. Set fakes.<call> on the tested mod.` So set `fakes.process.run` before a test runs a program, and `fakes.ui.ask` before the mod asks a question.
312
312
  - A `program` job is the exception: it catches the `process.spawn` error and retries after 1, 2, 4, 8 and 16 seconds on real timers, so its `ready()` waits past `bun test`'s 5-second timeout. Set `fakes.process.spawn` before a test starts a `program` job.
313
- - A `program` job with `singleInstance` spawns `/test/home/.local/share/cmod/programs/cmod program <mod> -- <command…>`, so `fakes.process.spawn` gets that `argv`. Each line the fake writes to standard output is the address of the copy that runs now, so a test fakes another session's copy taking over by writing a second line, and `ready()` resolves the new address.
313
+ - A `program` job with `singleInstance` spawns `/test/home/.local/share/cmod/programs/cmod program <mod> --no-wait -- <command…>`, so `fakes.process.spawn` gets that `argv`, and the first line the fake writes to standard output is the address of the copy this session runs. A fake that writes `held` and ends tests a session another session runs the copy for: `ready()` resolves the address in `/test/home/.local/share/cmod/instances/<mod>/<program>.json`, which the test gives as `{"address":"unix:/tmp/x.sock"}` in `files`.
314
314
  - `files` already fills the `fs` fakes: a write is read back, and `list` lists the given files. The fake file system resolves a relative path against `/`, not against the session's working folder, so a mod under test reads `${sessions.current.project}/<file>` rather than a relative path. `fs.list()` with no path rejects.
315
315
  - `ui.open` places every pane by default. A fake that answers `{ isPlaced: false }` holds a pane back.
316
316
  - `ui.scroll` answers `{}` by default, as when the window moved. A fake that answers `{ deny }` refuses the scroll.
package/docs/ui.md CHANGED
@@ -440,7 +440,7 @@ type ToastOptions = {
440
440
  - `✕` closes the toast. The band shows the newest 3, and `+N more` shows every toast.
441
441
  - `promise` shows `loading` while `task` runs, then `success` or `error` in the same row. `unwrap()` resolves or rejects as `task` does.
442
442
 
443
- Every error cmod catches for a mod, such as a listener that throws, goes to the Log, in Settings on cmod's page. The Log keeps the newest 100 failures of every session, each with the mod, the time, the message, `Copy`, and `Report`, and the same failure again updates its entry.
443
+ Every error cmod catches for a mod, such as a listener that throws, goes to the Log, in Settings on cmod's page, and so does every warning cmod has for a mod, such as a session that did not hear of its listener. A warning never shows a toast. The Log keeps the newest 100 failures of every session, each with the mod, the time, the message, the versions of the mod, its `@cmodjs/core`, cmod, and Claude Code, `Copy`, and `Report`, and the same failure again updates its entry and counts the repeat.
444
444
 
445
445
  An error also shows as a toast when any of these holds:
446
446
 
@@ -1 +1 @@
1
- {"version":3,"file":"program.d.ts","sourceRoot":"","sources":["../src/jobs/program.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,WAAW,CAAA;AAKpC,MAAM,MAAM,OAAO,GAAG;IACpB,QAAQ,CAAC,KAAK,EAAE,SAAS,GAAG,UAAU,GAAG,SAAS,GAAG,SAAS,GAAG,OAAO,CAAA;IACxE,KAAK,IAAI,OAAO,CAAC;QAAE,GAAG,EAAE,MAAM,CAAC;QAAC,UAAU,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC,CAAA;CACvD,CAAA;AAMD,wBAAgB,OAAO,CAAC,OAAO,EAAE;IAAE,QAAQ,CAAC,OAAO,EAAE,SAAS,MAAM,EAAE,CAAC;IAAC,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAAC,QAAQ,CAAC,cAAc,CAAC,EAAE,OAAO,CAAA;CAAE,GAAG,GAAG,CAAC,OAAO,CAAC,CAyFxK"}
1
+ {"version":3,"file":"program.d.ts","sourceRoot":"","sources":["../src/jobs/program.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,WAAW,CAAA;AAQpC,MAAM,MAAM,OAAO,GAAG;IACpB,QAAQ,CAAC,KAAK,EAAE,SAAS,GAAG,UAAU,GAAG,SAAS,GAAG,SAAS,GAAG,OAAO,CAAA;IACxE,KAAK,IAAI,OAAO,CAAC;QAAE,GAAG,EAAE,MAAM,CAAC;QAAC,UAAU,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC,CAAA;CACvD,CAAA;AAYD,wBAAgB,OAAO,CAAC,OAAO,EAAE;IAAE,QAAQ,CAAC,OAAO,EAAE,SAAS,MAAM,EAAE,CAAC;IAAC,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAAC,QAAQ,CAAC,cAAc,CAAC,EAAE,OAAO,CAAA;CAAE,GAAG,GAAG,CAAC,OAAO,CAAC,CAwIxK"}
package/jobs/program.js CHANGED
@@ -1,11 +1,17 @@
1
+ import { instancePath, storeFolder } from '../records.js';
1
2
  import { engineOf } from '../runtime/engine.js';
3
+ import { isHeld } from '../runtime/programs.js';
4
+ import { ifMissing } from '../utils/paths.js';
2
5
  import { messageOf } from '../utils/text.js';
3
6
  import { basename } from '../vendor.js';
4
7
  const backoffSeconds = [1, 2, 4, 8, 16];
8
+ const leaseCheckMs = 5000;
9
+ const staleMs = 15_000;
10
+ const retryWithinMs = 1000;
5
11
  export function program(options) {
6
12
  const { command, environment, singleInstance = false } = options;
7
13
  return ({ mod, announce, reserveName }) => {
8
- const { claude, report, spawnCmod } = engineOf(mod);
14
+ const { claude, report, spawnCmod, watches } = engineOf(mod);
9
15
  const [executable] = command;
10
16
  if (executable === undefined)
11
17
  throw new Error(`${mod.name}: the program has no command. Name the program on PATH and its arguments, such as ['preview-server', '--port', '0'].`);
@@ -17,7 +23,13 @@ export function program(options) {
17
23
  let failure;
18
24
  let exits = 0;
19
25
  const waiting = [];
20
- const spawn = () => (singleInstance ? spawnCmod(['program', mod.name, '--', ...command], environment) : claude.process.spawn(request));
26
+ let isFollowing = false;
27
+ let isWatching = false;
28
+ let instance;
29
+ let leaseCheck;
30
+ const spawn = () => (singleInstance ? spawnCmod(['program', mod.name, '--no-wait', '--', ...command], environment) : claude.process.spawn(request));
31
+ const instanceFile = () => (instance ??= Promise.all([claude.env.home(), claude.env.dataHome()]).then(([home, dataHome]) => instancePath(storeFolder({ HOME: home, XDG_DATA_HOME: dataHome }), mod.name, basename(executable))));
32
+ const following = (run) => void run.catch((error) => report({ id: `program:${executable}:follow`, message: `Could not follow the ${executable} program`, error }));
21
33
  const stop = (reason) => {
22
34
  address = undefined;
23
35
  state = 'fatal';
@@ -38,27 +50,66 @@ export function program(options) {
38
50
  for (const waiter of waiting.splice(0))
39
51
  waiter.resolve(next);
40
52
  };
53
+ const checkLease = (file) => (leaseCheck ??= (async () => {
54
+ if (!isFollowing || (await isHeld(claude, `${file}.lock`, staleMs)))
55
+ return;
56
+ isFollowing = false;
57
+ void start();
58
+ })().finally(() => {
59
+ leaseCheck = undefined;
60
+ }));
61
+ const track = async (file) => {
62
+ if (!isFollowing)
63
+ return;
64
+ const recorded = await claude.fs.read(file).catch(ifMissing(undefined));
65
+ const next = recorded === undefined ? undefined : addressOf(String(JSON.parse(recorded).address).trim());
66
+ if (next !== undefined)
67
+ return show(next);
68
+ address = undefined;
69
+ state = 'starting';
70
+ claude.clock.after(Math.random() * retryWithinMs, () => following(checkLease(file)));
71
+ };
72
+ const follow = async (file) => {
73
+ isFollowing = true;
74
+ if (!isWatching) {
75
+ isWatching = true;
76
+ watches.add([file], () => following(track(file)));
77
+ claude.clock.every(leaseCheckMs, () => following(checkLease(file)));
78
+ }
79
+ await track(file);
80
+ };
41
81
  const start = async () => {
82
+ isFollowing = false;
83
+ address = undefined;
42
84
  state = 'starting';
43
85
  let pending = '';
44
86
  let lastError = '';
87
+ let isShown = false;
45
88
  try {
89
+ if (singleInstance) {
90
+ const file = await instanceFile();
91
+ if (await isHeld(claude, `${file}.lock`, staleMs))
92
+ return await follow(file);
93
+ }
46
94
  for await (const piece of await spawn()) {
47
95
  if (piece.stream === 'stderr') {
48
96
  lastError = piece.text.trim().split('\n').at(-1) ?? lastError;
49
97
  continue;
50
98
  }
51
- if (address !== undefined && !singleInstance)
99
+ if (isShown)
52
100
  continue;
53
101
  const lines = `${pending}${piece.text}`.split('\n');
54
102
  pending = lines.pop() ?? '';
55
- for (const line of singleInstance ? lines : lines.slice(0, 1)) {
103
+ for (const line of lines.slice(0, 1)) {
104
+ if (singleInstance && line.trim() === 'held')
105
+ return await follow(await instanceFile());
56
106
  const next = addressOf(line.trim());
57
107
  if (next === undefined) {
58
108
  stop(`its first line is "${line.trim()}". Write 127.0.0.1:<port> or unix:<socket path> as the first line on standard output.`);
59
109
  return;
60
110
  }
61
111
  show(next);
112
+ isShown = true;
62
113
  }
63
114
  }
64
115
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cmodjs/core",
3
- "version": "5.2.0",
3
+ "version": "5.3.0",
4
4
  "description": "Build Claude Code mods: hooks, panes, checks, and an install that just works.",
5
5
  "license": "MIT",
6
6
  "type": "module",
package/records.d.ts CHANGED
@@ -96,8 +96,8 @@ export type Preferences = {
96
96
  };
97
97
  export declare function parsePreferences(value: unknown, path: string): Preferences;
98
98
  export declare function parseConsent(value: unknown, path: string): Record<string, string[]>;
99
- export declare const coreVersion = "5.2.0";
100
- export declare const oldestCmodVersion = "5.2.0";
99
+ export declare const coreVersion = "5.3.0";
100
+ export declare const oldestCmodVersion = "5.3.0";
101
101
  export declare function hotkeyCommand(mod: string, hotkey: string): string;
102
102
  export declare function hotkeyBindings(mod: string, hotkeys: Hotkeys | undefined): Record<string, string>;
103
103
  export declare function boundCombos(keybindings: unknown): Map<string, string>;
package/records.js CHANGED
@@ -266,8 +266,8 @@ function readHotkeys(hotkeys) {
266
266
  throw new Error(`package.json "cmod.hotkeys" is not a map of hotkeys to their title and optional default combo. ${fix}`);
267
267
  return { hotkeys: checkHotkeys('package.json "cmod"', hotkeys) };
268
268
  }
269
- export const coreVersion = '5.2.0';
270
- export const oldestCmodVersion = '5.2.0';
269
+ export const coreVersion = '5.3.0';
270
+ export const oldestCmodVersion = '5.3.0';
271
271
  export function hotkeyCommand(mod, hotkey) {
272
272
  return `${mod}--${hotkey}`;
273
273
  }
package/register.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"register.d.ts","sourceRoot":"","sources":["src/register.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAA4D,EAAE,EAAE,aAAa,EAAgB,MAAM,aAAa,CAAA;AAC5H,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,UAAU,CAAA;AAC7C,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AAc3C,wBAAgB,aAAa,IAAI,aAAa,CAAC,MAAM,CAAC,GAAG,SAAS,CAEjE;AAkGD,wBAAgB,WAAW,CAAC,KAAK,SAAS,MAAM,EAAE,QAAQ,SAAS,OAAO,EAAE,OAAO,EAAE,EAAE,EAAE,UAAU,EAAE,aAAa,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,OAAO,EAAE,aAAa,GAAG,IAAI,CAsDzK;AAED,wBAAgB,uBAAuB,CAAC,OAAO,EAAE,EAAE,GAAG,IAAI,CAIzD"}
1
+ {"version":3,"file":"register.d.ts","sourceRoot":"","sources":["src/register.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAA4D,EAAE,EAAE,aAAa,EAAgB,MAAM,aAAa,CAAA;AAC5H,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,UAAU,CAAA;AAC7C,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AAgB3C,wBAAgB,aAAa,IAAI,aAAa,CAAC,MAAM,CAAC,GAAG,SAAS,CAEjE;AAsHD,wBAAgB,WAAW,CAAC,KAAK,SAAS,MAAM,EAAE,QAAQ,SAAS,OAAO,EAAE,OAAO,EAAE,EAAE,EAAE,UAAU,EAAE,aAAa,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,OAAO,EAAE,aAAa,GAAG,IAAI,CAsDzK;AAED,wBAAgB,uBAAuB,CAAC,OAAO,EAAE,EAAE,GAAG,IAAI,CAIzD"}
package/register.js CHANGED
@@ -1,18 +1,37 @@
1
+ import { settledAfterAbort } from './runtime/deadline.js';
1
2
  import { cmodPluginName } from './runtime/dependencies.js';
2
3
  import { readDevice } from './runtime/device.js';
3
4
  import { createLifecycle, readPlugin } from './runtime/lifecycle.js';
4
5
  import { permissionRoutes } from './runtime/permission-check.js';
6
+ import { messageOf } from './utils/text.js';
5
7
  let lifecycle;
6
8
  let permissionCheck;
7
9
  let registered;
8
10
  export function registeredMod() {
9
11
  return registered;
10
12
  }
13
+ const lockedRetryMs = [100, 300, 600];
14
+ const heldLock = 'Lock file is already being held';
15
+ const timers = globalThis;
16
+ async function whenUnlocked(write) {
17
+ for (const waitMs of lockedRetryMs) {
18
+ try {
19
+ return await write();
20
+ }
21
+ catch (error) {
22
+ if (!messageOf(error).includes(heldLock))
23
+ throw error;
24
+ await new Promise((resolve) => void timers.setTimeout(resolve, waitMs));
25
+ }
26
+ }
27
+ return write();
28
+ }
11
29
  async function startMod($, eventInput, passOn) {
12
30
  const claude = {
13
31
  plugin: { name: $.plugin.name, root: $.plugin.root },
14
32
  ui: {
15
33
  log: (text, options) => $.ui.log(text, options),
34
+ warn: (_id, text) => $.ui.log(text, { to: 'debug' }),
16
35
  notice: (toolUseId, text) => $.ui.notice(toolUseId, text),
17
36
  toast: (text, options) => $.ui.toast(text, options),
18
37
  invalidate: (event) => $.ui.invalidate(event),
@@ -41,8 +60,8 @@ async function startMod($, eventInput, passOn) {
41
60
  config: { list: () => $.config.list() },
42
61
  store: {
43
62
  get: (key) => $.store.get(key),
44
- set: (key, value) => $.store.set(key, value),
45
- delete: (key) => $.store.delete(key),
63
+ set: (key, value) => whenUnlocked(() => $.store.set(key, value)),
64
+ delete: (key) => whenUnlocked(() => $.store.delete(key)),
46
65
  keys: () => $.store.keys(),
47
66
  },
48
67
  clock: {
@@ -57,6 +76,7 @@ async function startMod($, eventInput, passOn) {
57
76
  model: () => $.session.model(),
58
77
  usage: () => $.session.usage(),
59
78
  surfaces: () => $.session.surfaces(),
79
+ version: async () => (await $.session.version()).version,
60
80
  messages: ((args) => (args === undefined ? $.session.messages() : $.session.messages(args))),
61
81
  append: (args) => $.session.append(args),
62
82
  send: (args) => $.session.send(args),
@@ -78,7 +98,7 @@ async function startMod($, eventInput, passOn) {
78
98
  device: { read: () => readDevice(claude) },
79
99
  cmod: { call: (input) => $.cmod.call(input) },
80
100
  };
81
- const [, answer] = await Promise.all([lifecycle.start(claude, readPlugin), passOn(eventInput)]);
101
+ const [, answer] = await settledAfterAbort(Promise.all([lifecycle.start(claude, readPlugin), passOn(eventInput)]), passOn.signal);
82
102
  return answer;
83
103
  }
84
104
  function routeToMod(_$, eventInput, passOn) {
@@ -7,6 +7,7 @@ export type Claude = {
7
7
  };
8
8
  readonly ui: {
9
9
  log(text: string, options?: UiLogOptions): void;
10
+ warn(id: string, text: string): void;
10
11
  notice(toolUseId: string, text: string | undefined): void;
11
12
  toast(text: string, options?: ToastOptions): void;
12
13
  invalidate(event: InvalidatableEventName): void;
@@ -57,6 +58,7 @@ export type Claude = {
57
58
  model(): Promise<string>;
58
59
  usage(): Promise<SessionUsage>;
59
60
  surfaces(): Promise<readonly RenderSurface[]>;
61
+ version(): Promise<string>;
60
62
  messages: EngineInterface['session']['messages'];
61
63
  append: EngineInterface['session']['append'];
62
64
  send: EngineInterface['session']['send'];
@@ -1 +1 @@
1
- {"version":3,"file":"claude.d.ts","sourceRoot":"","sources":["../src/runtime/claude.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,SAAS,EACT,cAAc,EACd,gBAAgB,EAChB,IAAI,EACJ,eAAe,EACf,UAAU,EACV,WAAW,EACX,cAAc,EACd,gBAAgB,EAChB,WAAW,EACX,SAAS,EACT,YAAY,EACZ,OAAO,EACP,MAAM,EACN,aAAa,EACb,UAAU,EACV,QAAQ,EACR,YAAY,EACZ,sBAAsB,EACtB,aAAa,EACb,YAAY,EACZ,cAAc,EACd,gBAAgB,EAChB,iBAAiB,EACjB,mBAAmB,EACnB,kBAAkB,EAClB,aAAa,EACb,YAAY,EACZ,YAAY,EACZ,QAAQ,EACR,gBAAgB,EAChB,KAAK,EACL,YAAY,EACZ,QAAQ,EACR,UAAU,EACV,WAAW,EACX,aAAa,EACb,YAAY,EACZ,YAAY,EACZ,YAAY,EACZ,MAAM,EACN,YAAY,EACZ,cAAc,EACf,MAAM,aAAa,CAAA;AACpB,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,mCAAmC,CAAA;AAE/D,MAAM,MAAM,MAAM,GAAG;IACnB,QAAQ,CAAC,MAAM,EAAE;QAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAA;IACjE,QAAQ,CAAC,EAAE,EAAE;QACX,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,YAAY,GAAG,IAAI,CAAA;QAC/C,MAAM,CAAC,SAAS,EAAE,MA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AAG,SAAS,CAAC,CAAA;QACvC,UAAU,IAAI,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAAA;KAC1C,CAAA;IACD,QAAQ,CAAC,MAAM,EAAE;QAAE,IAAI,IAAI,OAAO,CAAC,MAAM,CAAC,CAAA;KAAE,CAAA;IAC5C,QAAQ,CAAC,IAAI,EAAE;QAAE,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,WAAW,CAAC,GAAG,OAAO,CAAC,OAAO,CAAC,CAAA;KAAE,CAAA;CACpE,CAAA"}
@@ -206,7 +206,7 @@ export function serveConversations({ claude, router, store, project, report, cle
206
206
  });
207
207
  const publishWatches = (isEnding = false) => {
208
208
  const next = publishing.then(() => publishNow(isEnding));
209
- publishing = next.catch((error) => claude.ui.log(`cmod: publishing before listeners failed: ${messageOf(error)}`, { to: 'debug' }));
209
+ publishing = next.catch((error) => claude.ui.warn('before:publish', `cmod: publishing before listeners failed: ${messageOf(error)}`));
210
210
  return next;
211
211
  };
212
212
  const publishNow = async (isEnding) => {
@@ -222,7 +222,7 @@ export function serveConversations({ claude, router, store, project, report, cle
222
222
  published = new Set(list.map((watch) => watch.target));
223
223
  const running = targets.has(everySession) ? (await json(['history', 'sessions', '--running'])).map((each) => each.id) : [];
224
224
  const told = new Set([...running, ...targets].filter((id) => id !== everySession && id !== session));
225
- await Promise.all([...told].map((id) => post(id, { kind: 'watch' }).catch((error) => claude.ui.log(`cmod: session ${id} did not hear of a before listener: ${messageOf(error)}`, { to: 'debug' }))));
225
+ await Promise.all([...told].map((id) => post(id, { kind: 'watch' }).catch((error) => claude.ui.warn('before:tell', `cmod: session ${id} did not hear of a before listener: ${messageOf(error)}`))));
226
226
  };
227
227
  const hear = (caller, id, list) => {
228
228
  const sessions = heard.get(caller) ?? new Map();
@@ -234,7 +234,7 @@ export function serveConversations({ claude, router, store, project, report, cle
234
234
  };
235
235
  const onListenerFiles = (work) => {
236
236
  const next = listenerFiles.then(work);
237
- listenerFiles = next.catch((error) => claude.ui.log(`cmod: reading or writing the mods' listeners failed: ${messageOf(error)}`, { to: 'debug' }));
237
+ listenerFiles = next.catch((error) => claude.ui.warn('listeners:files', `cmod: reading or writing the mods' listeners failed: ${messageOf(error)}`));
238
238
  return next;
239
239
  };
240
240
  const clearListeners = (at) => onListenerFiles(() => claude.fs.write(`${listeners}/${at}.json`, '{}'));
@@ -272,7 +272,7 @@ export function serveConversations({ claude, router, store, project, report, cle
272
272
  catch (error) {
273
273
  if (from === session || !(error instanceof SyntaxError))
274
274
  throw error;
275
- claude.ui.log(`cmod: session ${from} was writing its before listeners, so it keeps the ones from before until it relays that it changed them`, { to: 'debug' });
275
+ claude.ui.warn('before:read', `cmod: session ${from} was writing its before listeners, so it keeps the ones from before until it relays that it changed them`);
276
276
  found.push(...watchers.filter((watch) => watch.from === from));
277
277
  continue;
278
278
  }
@@ -320,7 +320,7 @@ export function serveConversations({ claude, router, store, project, report, cle
320
320
  throw error;
321
321
  }
322
322
  watchers = watchers.filter((each) => each.from !== watcher.from);
323
- claude.ui.log(`cmod: session ${watcher.from} ended without clearing its before listeners, so they are cleared now`, { to: 'debug' });
323
+ claude.ui.warn('before:ended', `cmod: session ${watcher.from} ended without clearing its before listeners, so they are cleared now`);
324
324
  await clearWatches(watcher.from);
325
325
  return undefined;
326
326
  }
@@ -606,7 +606,7 @@ export function serveConversations({ claude, router, store, project, report, cle
606
606
  const { session: from, ...task } = JSON.parse(asked);
607
607
  const ended = { ...task, id: session, closedAt: new Date().toISOString() };
608
608
  await claude.fs.write(`${backgroundTasks}/${from}/${session}.json`, JSON.stringify(ended));
609
- await post(from, { kind: 'taskEnd', task: ended }).catch((error) => claude.ui.log(`cmod: session ${from} did not hear that its task ${session} answered: ${messageOf(error)}`, { to: 'debug' }));
609
+ await post(from, { kind: 'taskEnd', task: ended }).catch((error) => claude.ui.warn('task:answered', `cmod: session ${from} did not hear that its task ${session} answered: ${messageOf(error)}`));
610
610
  };
611
611
  const actElsewhere = async (caller, target, action, input, task) => {
612
612
  const isLive = await isRunning(target);
@@ -709,7 +709,7 @@ export function serveConversations({ claude, router, store, project, report, cle
709
709
  return saved;
710
710
  await starting;
711
711
  const kept = liveTasks().filter((task) => isNested || task.parent === request['task']);
712
- const running = await claude.agent.list().catch((error) => (claude.ui.log(`cmod: the tasks show no status, because Claude Code listed no agents: ${messageOf(error)}`, { to: 'debug' }), []));
712
+ const running = await claude.agent.list().catch((error) => (claude.ui.warn('tasks:status', `cmod: the tasks show no status, because Claude Code listed no agents: ${messageOf(error)}`), []));
713
713
  const background = saved.flatMap(({ id, status }) => (status === undefined ? [] : [{ id, status }]));
714
714
  return tasksWithAgents(merged(saved, kept, (task) => task.id), [...running, ...background]);
715
715
  },
@@ -734,7 +734,7 @@ export function serveConversations({ claude, router, store, project, report, cle
734
734
  changeGoal(task, text);
735
735
  else {
736
736
  dispatch(id, [{ type: GoalChange, goal: { text, ...(task === undefined ? {} : { task }) } }]);
737
- await post(id, { kind: 'goal', ...(task === undefined ? {} : { task }), text }).catch((error) => claude.ui.log(`cmod: session ${id} keeps its goal until it starts again: ${messageOf(error)}`, { to: 'debug' }));
737
+ await post(id, { kind: 'goal', ...(task === undefined ? {} : { task }), text }).catch((error) => claude.ui.warn('goal:tell', `cmod: session ${id} keeps its goal until it starts again: ${messageOf(error)}`));
738
738
  }
739
739
  return null;
740
740
  },
@@ -22,5 +22,7 @@ export declare function listenerOf(name: string, method: string, args: readonly
22
22
  readonly options: ListenOptions;
23
23
  };
24
24
  export declare function withinTime<Value>(clock: Pick<Claude['clock'], 'now'>, method: string, { timeoutMs }: ListenOptions, cancel: AbortSignal, run: (time: ListenTime) => Value | Promise<Value>): Promise<Value>;
25
+ export declare const abortGraceMs = 1000;
26
+ export declare function settledAfterAbort<Value>(work: Promise<Value>, signal: AbortSignal | undefined): Promise<Value>;
25
27
  export declare function beforeDeadline<Value>(claude: Claude, { ms, job }: Deadline, call: string, task: Promise<Value>): Promise<Value>;
26
28
  //# sourceMappingURL=deadline.d.ts.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O,EAAE,KAAK,EAAE,IAAI,EAAE,UAAU,KAAK,OAAO,CAAC;IAAC,QAAQ,CAAC,OAAO,EAAE,aAAa,CAAA;CAAE,CASnN;AAED,wBAAsB,UAAU,CAAC,KAAK,EAAE,KAAK,EAAE,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,EAAE,KAAK,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,EAAE,SAAsB,EAAE,EAAE,aAAa,EAAE,MAAM,EAAE,WAAW,EAAE,GAAG,EAAE,CAAC,IAAI,EAAE,UAAU,KAAK,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC,GAAG,OAAO,CAAC,KAAK,CAAC,CAoB9N;AAED,eAAO,MAAM,YAAY,OAAO,CAAA;AAEhC,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,IAAI,EAAE,OAAO,CAAC,KAAK,CAAC,EAAE,MAAM,EAAE,WAAW,GAAG,SAAS,GAAG,OAAO,CAAC,KAAK,CAAC,CAY9G;AAED,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,GAAG,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,CAAC,KAAK,CAAC,GAAG,OAAO,CAAC,KAAK,CAAC,CAe/H"}
@@ -39,6 +39,23 @@ export async function withinTime(clock, method, { timeoutMs = listenerMs }, canc
39
39
  cancel.removeEventListener('abort', cancelled);
40
40
  }
41
41
  }
42
+ export const abortGraceMs = 1000;
43
+ export function settledAfterAbort(work, signal) {
44
+ if (signal === undefined)
45
+ return work;
46
+ return new Promise((resolve, reject) => {
47
+ let timer;
48
+ const giveUp = () => void (timer = timers.setTimeout(() => reject(signal.reason), abortGraceMs));
49
+ if (signal.aborted)
50
+ giveUp();
51
+ else
52
+ signal.addEventListener('abort', giveUp, { once: true });
53
+ work.then(resolve, reject).finally(() => {
54
+ timers.clearTimeout(timer);
55
+ signal.removeEventListener('abort', giveUp);
56
+ });
57
+ });
58
+ }
42
59
  export function beforeDeadline(claude, { ms, job }, call, task) {
43
60
  return new Promise((resolve, reject) => {
44
61
  const passed = job === undefined ? `its ${ms / 1000} s deadline` : `the ${ms / 1000} s deadline of ${job}`;
@@ -4,6 +4,7 @@ import type { Pages } from './pages.js';
4
4
  import type { Router } from './router.js';
5
5
  import type { Failure } from './toaster.js';
6
6
  import type { ToolCalls } from './tool-calls.js';
7
+ import type { Watches } from './watches.js';
7
8
  import type { Widgets } from './widgets.js';
8
9
  export type Engine = {
9
10
  readonly claude: Claude;
@@ -13,6 +14,7 @@ export type Engine = {
13
14
  readonly hasPermissionCheck: () => boolean;
14
15
  readonly answerInput: <Answer>(run: () => Promise<Answer>, passOn: () => Promise<unknown>) => Promise<Answer>;
15
16
  readonly spawnCmod: (args: readonly string[], env?: Readonly<Record<string, string>>) => HookStream<ProcessSpawnChunk, ProcessSpawnResult>;
17
+ readonly watches: Watches;
16
18
  readonly widgets?: Widgets;
17
19
  readonly pages?: Pages;
18
20
  };
@@ -1 +1 @@
1
- {"version":3,"file":"engine.d.ts","sourceRoot":"","sources":["../src/runtime/engine.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAA;AACpF,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AACzC,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,YAAY,CAAA;AACvC,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AACzC,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AAC3C,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAA;AAChD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AAE3C,MAAM,MAAM,MAAM,GAAG;IACnB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;IACvB,QAAQ,CAAC,MA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,SAAS,EAAE,MAAM,iBAAiB,CAAA;AAChD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AAC3C,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AAE3C,MAAM,MAAM,MAAM,GAAG;IACnB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;IACvB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;IACvB,QAAQ,CAAC,SAAS,EAAE,SAAS,CAAA;IAC7B,QAAQ,CAAC,MAAM,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,IAAI,CAAA;IAC3C,QAAQ,CAAC,kBAAkB,EAAE,MAAM,OAAO,CAAA;IAC1C,QAAQ,CAAC,WAAW,EAAE,CAAC,MAAM,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC,MAAM,CAAC,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC,OAAO,CAAC,KAAK,OAAO,CAAC,MAAM,CAAC,CAAA;IAC7G,QAAQ,CAAC,SAAS,EAAE,CAAC,IAAI,EAAE,SAAS,MAAM,EAAE,EAAE,GAAG,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,KAAK,UAAU,CAAC,iBAAiB,EAAE,kBAAkB,CAAC,CAAA;IAC1I,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAA;IACzB,QAAQ,CAAC,OAAO,CAAC,EAAE,OAAO,CAAA;IAC1B,QAAQ,CAAC,KAAK,CAAC,EAAE,KAAK,CAAA;CACvB,CAAA;AAID,wBAAgB,UAAU,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,IAAI,CAE5D;AAED,wBAAgB,QAAQ,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAI5C"}
package/runtime/hooks.js CHANGED
@@ -55,14 +55,14 @@ export async function callFiles(name, claude, folders, use, cwd) {
55
55
  const known = (accesses) => accesses.map(({ path }) => path).filter((path) => shell === undefined || !dynamicPattern.test(path));
56
56
  const unchecked = (path) => (error) => {
57
57
  if (!isMissing(error))
58
- claude.ui.log(`${name}: the ${use.tool} call reads ${path}, which could not be checked: ${messageOf(error)}`, { to: 'debug' });
58
+ claude.ui.warn('call:files', `${name}: the ${use.tool} call reads ${path}, which could not be checked: ${messageOf(error)}`);
59
59
  return undefined;
60
60
  };
61
61
  const read = await Promise.all(known(reads).map(async (path) => ((await claude.fs.stat(path).catch(unchecked(path)))?.kind === 'file' ? [path] : [])));
62
62
  return { read: read.flat(), changed: known(writes) };
63
63
  }
64
64
  catch (error) {
65
- claude.ui.log(`${name}: the ${use.tool} call lists no files: ${messageOf(error)}`, { to: 'debug' });
65
+ claude.ui.warn('call:files', `${name}: the ${use.tool} call lists no files: ${messageOf(error)}`);
66
66
  return { read: [], changed: [] };
67
67
  }
68
68
  }
@@ -10,7 +10,7 @@ export async function readCombos(claude, configRoot) {
10
10
  return boundCombos(JSON.parse(text));
11
11
  }
12
12
  catch (error) {
13
- claude.ui.log(`${configRoot}/keybindings.json is not JSON, so cmod reads no combos from it: ${messageOf(error)}`, { to: 'debug' });
13
+ claude.ui.warn('hotkeys:read', `${configRoot}/keybindings.json is not JSON, so cmod reads no combos from it: ${messageOf(error)}`);
14
14
  return new Map();
15
15
  }
16
16
  }
@@ -18,7 +18,7 @@ export function createInstaller(name, claude, waiting, nextDraw) {
18
18
  return void collected.push(update);
19
19
  await withBareRefusals(claude()).cmod.call({ to: cmodPluginName, method: partMethods.changed, input: update });
20
20
  };
21
- const log = (what) => (error) => claude().ui.log(`${name}: ${what}: ${messageOf(error)}`, { to: 'debug' });
21
+ const log = (what) => (error) => claude().ui.warn('installer:page', `${name}: ${what}: ${messageOf(error)}`);
22
22
  const open = (isAsked) => send({ requests: [{ open: installPage, focus: true }], ...(isAsked ? { isAsked: true } : {}) });
23
23
  const show = async (build, cancelled) => {
24
24
  question?.cancel();
@@ -1 +1 @@
1
- {"version":3,"file":"lifecycle.d.ts","sourceRoot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