@cmodjs/core 4.1.1 → 4.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 (64) hide show
  1. package/docs/commands.md +4 -4
  2. package/docs/install-steps.md +4 -3
  3. package/docs/jobs.md +2 -0
  4. package/docs/mod.md +9 -8
  5. package/docs/permissions.md +3 -3
  6. package/docs/testing.md +2 -0
  7. package/docs/ui.md +12 -3
  8. package/hotkeys.d.ts +1 -1
  9. package/hotkeys.d.ts.map +1 -1
  10. package/hotkeys.js +2 -0
  11. package/jobs/program.js +1 -1
  12. package/jobs/tool.d.ts +1 -0
  13. package/jobs/tool.d.ts.map +1 -1
  14. package/jobs/tool.js +2 -2
  15. package/package.json +1 -1
  16. package/records.d.ts +9 -1
  17. package/records.d.ts.map +1 -1
  18. package/records.js +27 -6
  19. package/register.d.ts.map +1 -1
  20. package/register.js +1 -0
  21. package/runtime/announce.d.ts +2 -7
  22. package/runtime/announce.d.ts.map +1 -1
  23. package/runtime/announce.js +13 -52
  24. package/runtime/claude.d.ts +2 -1
  25. package/runtime/claude.d.ts.map +1 -1
  26. package/runtime/conversations.d.ts.map +1 -1
  27. package/runtime/conversations.js +24 -4
  28. package/runtime/grants.d.ts +1 -0
  29. package/runtime/grants.d.ts.map +1 -1
  30. package/runtime/grants.js +1 -1
  31. package/runtime/hotkeys.js +1 -1
  32. package/runtime/lifecycle.d.ts.map +1 -1
  33. package/runtime/lifecycle.js +27 -20
  34. package/runtime/sessions.d.ts +2 -1
  35. package/runtime/sessions.d.ts.map +1 -1
  36. package/runtime/sessions.js +5 -6
  37. package/runtime/toaster.d.ts +22 -1
  38. package/runtime/toaster.d.ts.map +1 -1
  39. package/runtime/toaster.js +69 -24
  40. package/runtime/ui.js +1 -1
  41. package/src/hotkeys.ts +2 -1
  42. package/src/jobs/program.ts +1 -1
  43. package/src/jobs/tool.ts +3 -2
  44. package/src/records.ts +29 -5
  45. package/src/register.ts +1 -0
  46. package/src/runtime/announce.ts +14 -56
  47. package/src/runtime/claude.ts +2 -0
  48. package/src/runtime/conversations.ts +25 -4
  49. package/src/runtime/grants.ts +1 -1
  50. package/src/runtime/hotkeys.ts +1 -1
  51. package/src/runtime/lifecycle.ts +27 -21
  52. package/src/runtime/sessions.ts +4 -5
  53. package/src/runtime/toaster.ts +68 -25
  54. package/src/runtime/ui.ts +1 -1
  55. package/src/testing/fake-claude.ts +3 -1
  56. package/src/testing.ts +7 -2
  57. package/src/utils/changelog.ts +0 -15
  58. package/testing/fake-claude.d.ts.map +1 -1
  59. package/testing/fake-claude.js +3 -1
  60. package/testing.d.ts.map +1 -1
  61. package/testing.js +7 -2
  62. package/utils/changelog.d.ts +0 -1
  63. package/utils/changelog.d.ts.map +1 -1
  64. package/utils/changelog.js +0 -15
package/docs/commands.md CHANGED
@@ -134,7 +134,7 @@ It needs, and refuses to start without:
134
134
 
135
135
  ## Install mods
136
136
 
137
- `cmod install`, `cmod update`, `cmod remove`, `cmod enable`, `cmod disable`, `cmod link`, `cmod unlink`, and `cmod try` write the time to `plugins-changed` in the cmod store, then write `store-changed` beside it, when they finish, also when they fail partway, such as an update that updated some mods. The cmod plugin of every running session watches `store-changed` and Claude Code's `installed_plugins.json`, reads the `enabledPlugins` of the user's `settings.json` each time Claude Code reports that file changed and at each prompt, and shows a `Plugins changed` toast when `plugins-changed`, `installed_plugins.json`, or `enabledPlugins` changed, whether a `cmod` command, `/plugin`, `claude plugin`, or Claude Code's automatic update changed them. Its `Reload` button runs `/reload-plugins` in that session, and cmod runs it in no session on its own. A reload keeps the prompt cache: the next request reads the whole conversation from the cache and pays only for the plugins' new content. A reload clears each mod's `memory` state. A machine where cmod set up no mod has no store, and these commands write nothing there. `cmod permission` needs no reload, because a mod sees its grants change before its next call.
137
+ `cmod install`, `cmod update`, `cmod remove`, `cmod enable`, `cmod disable`, `cmod link`, `cmod unlink`, and `cmod try` write the time to `plugins-changed` in the cmod store, then write `store-changed` beside it, when they finish, also when they fail partway, such as an update that updated some mods. The cmod plugin of every running session watches `store-changed` and Claude Code's `installed_plugins.json`, reads the `enabledPlugins` of the user's `settings.json` each time Claude Code reports that file changed and at each prompt, and runs `/reload-plugins` in its session once `plugins-changed`, `installed_plugins.json`, or `enabledPlugins` changed and then stayed the same for 2 seconds, whether a `cmod` command, `/plugin`, `claude plugin`, or Claude Code's automatic update changed them, so an update of several plugins reloads once. A session in the middle of a turn reloads when the turn ends, a session no app shows, such as `claude -p`, never reloads, and the prompt the person is typing stays. After the reload, each plugin whose version changed shows a corner toast, `<plugin> updated to <version>`. An update that granted a permission always has its own toast, followed by each permission it granted, and more than 3 others show one toast, `<n> plugins updated`. A reload keeps the prompt cache: the next request reads the whole conversation from the cache and pays only for the plugins' new content. A reload clears each mod's `memory` state. A machine where cmod set up no mod has no store, and these commands write nothing there. `cmod permission` needs no reload, because a mod sees its grants change before its next call.
138
138
 
139
139
  ### cmod install
140
140
 
@@ -233,7 +233,7 @@ Reads every conversation Claude Code saved, as the sessions, contexts, turns, ta
233
233
  cmod watch
234
234
  ```
235
235
 
236
- Tells every running session once a checkout `cmod link` linked builds after a change. It watches each linked folder, outside `node_modules` and `.git`, and skips a change to a file git ignores, such as the `.claude-plugin/types/` Claude Code writes each time it loads the mod. Once a folder has had no change for 2 seconds, it bundles the mod's hooks module as `cmod publish` does. A bundle that builds marks `plugins-changed`, so every session shows the `Plugins changed` toast. A bundle that still fails 10 seconds after the last change shows `<mod> does not build` with the error as one toast in every session, and the toast goes once the mod builds. So an agent's half-written file reloads nothing and shows nothing. The cmod plugin starts one only in a session that an app shows, once a mod is linked, at the session's start or later, so a machine with no linked mod runs none. The first holds `watch.lock` in the cmod store, watches, and touches its file there every 5 seconds. Another one exits at once while it runs, and the cmod plugin of each such session starts one again once that file is 15 seconds old, so a machine runs one watcher however many sessions it has open.
236
+ Tells every running session once a checkout `cmod link` linked builds after a change. It watches each linked folder, outside `node_modules` and `.git`, and skips a change to a file git ignores, such as the `.claude-plugin/types/` Claude Code writes each time it loads the mod. Once a folder has had no change for 2 seconds, it bundles the mod's hooks module as `cmod publish` does. A bundle that builds marks `plugins-changed`, so every session reloads its plugins, and shows no toast, because the version stays the same. A bundle that still fails 10 seconds after the last change shows `<mod> does not build` with the error as one toast in every session, and the toast goes once the mod builds. So an agent's half-written file reloads nothing and shows nothing. The cmod plugin starts one only in a session that an app shows, once a mod is linked, at the session's start or later, so a machine with no linked mod runs none. The first holds `watch.lock` in the cmod store, watches, and touches its file there every 5 seconds. Another one exits at once while it runs, and the cmod plugin of each such session starts one again once that file is 15 seconds old, so a machine runs one watcher however many sessions it has open.
237
237
 
238
238
  A cmod before 4.1.0 linked a checkout by writing it into `CLAUDE_CODE_PLUGIN_DIRS` in the `env` block of Claude Code's `settings.json`. `cmod watch` at its start, and `cmod setup`, link each folder still in that list as `cmod link` does now and take it out of the list. A folder that fails to link stays in the list, and its error prints on stderr.
239
239
 
@@ -255,7 +255,7 @@ cmod runs these itself. A person runs them to see a step's whole log, to finish
255
255
  cmod setup <plugin-root> [--events] [--consent <sha256>] [--yes]
256
256
  ```
257
257
 
258
- Refuses a machine the `os` and `cpu` keys of the mod's `package.json` leave out. Downloads the program its `cmod.program` names, or builds it from the checkout's `cli/` when `cmod link` loaded the mod, so a linked checkout whose version has no release yet still sets up, and links it into cmod's programs folder, which Claude Code runs it from by its name, and into `~/.local/bin` unless a file there is not cmod's. Runs the mod's install step, saves its uninstall step, grants the permissions its `cmod.permissions` lists, and records the mod as set up. A mod installed from a marketplace whose automatic updates the person has not turned on or off gets them turned on, through `"autoUpdate": true` on the marketplace's `extraKnownMarketplaces` entry in Claude Code's `settings.json`, and the consent question says so. The consent covers the scripts, the program, the hotkeys, and the permissions together, and an update asks again only for what changed. An unchanged mod runs nothing. `--events` prints one event per line for a program to read, and the mod's install toast in Claude Code reads them. Before all of that, it links each folder a cmod before 4.1.0 left in `CLAUDE_CODE_PLUGIN_DIRS`, as [`cmod watch`](#cmod-watch) does.
258
+ Refuses a machine the `os` and `cpu` keys of the mod's `package.json` leave out. Downloads the program its `cmod.program` names, or builds it from the checkout's `cli/` when `cmod link` loaded the mod, so a linked checkout whose version has no release yet still sets up, and links it into cmod's programs folder, which Claude Code runs it from by its name, and into `~/.local/bin` unless a file there is not cmod's. Runs the mod's install step, saves its uninstall step, grants the permissions its `cmod.permissions` lists, and records the mod as set up. A mod installed from a marketplace whose automatic updates the person has not turned on or off gets them turned on, through `"autoUpdate": true` on the marketplace's `extraKnownMarketplaces` entry in Claude Code's `settings.json`, and the consent question says so. The consent covers the scripts, the program, the hotkeys, and the permissions together, and an update asks again only for what changed. A permission an update adds is granted without asking, unless `preferences.json` in the cmod store holds `"asksBeforeUpdatePermissions": true`, and a permission the person turned off stays off ([install-steps.md](install-steps.md#consent)). An unchanged mod runs nothing. `--events` prints one event per line for a program to read, and the mod's install toast in Claude Code reads them. Before all of that, it links each folder a cmod before 4.1.0 left in `CLAUDE_CODE_PLUGIN_DIRS`, as [`cmod watch`](#cmod-watch) does.
259
259
 
260
260
  ### cmod teardown
261
261
 
@@ -279,7 +279,7 @@ Turns one permission of a set-up mod on or off, such as `cmod permission ci-watc
279
279
  cmod hotkey <mod> <hotkey> <combo>
280
280
  ```
281
281
 
282
- 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. 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)).
282
+ 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)).
283
283
 
284
284
  ### cmod settings
285
285
 
@@ -29,12 +29,12 @@ cmod refuses a `cmod` key that breaks these rules, with the fix in the message:
29
29
  - Each names at least one script file inside the mod, and no script at the mod's root. cmod asks consent for the whole folder of each script, so put the scripts in a folder, such as `setup/`.
30
30
  - A symbolic link in a script folder points at a file.
31
31
  - `program` is a command name: letters, digits, `.`, `_`, and `-`, starting with a letter or digit.
32
- - Each hotkey has a title and a default combo, as `defineMod` takes them ([mod.md](mod.md#hotkeys)).
32
+ - Each hotkey has a title and an optional default combo, as `defineMod` takes them ([mod.md](mod.md#hotkeys)).
33
33
  - `.claude-plugin/plugin.json` has a `version`.
34
34
 
35
35
  ## Consent
36
36
 
37
- Before a step runs for the first time, cmod shows the person the commands, the hotkeys, and the permissions, and asks to run them. cmod remembers what the person approved in three parts: each permission, each hotkey with its default combo, and one hash of the commands, the program, and every file in each script folder. An update asks again only for what it adds: a changed command or script file, a new hotkey or a new default combo, or a new permission, and it lists only the new hotkeys and permissions ([permissions.md](permissions.md)). An update that only drops a hotkey or a permission sets the mod up without asking.
37
+ Before a step runs for the first time, cmod shows the person the commands, the hotkeys, and the permissions, and asks to run them. cmod remembers what the person approved in three parts: each permission, each hotkey that has a default combo with that combo, and one hash of the commands, the program, and every file in each script folder. An update asks again only for what it adds: a changed command or script file, or a new hotkey or a new default combo, and it lists only the new hotkeys. A permission an update adds is granted without asking, and the `<mod> updated to <version>` toast names it ([permissions.md](permissions.md)). With `Ask before an update adds a permission` on, in Settings on cmod's page under Preferences, the update asks for each new permission too, and lists only the new ones. The switch is off at first, and it is `"asksBeforeUpdatePermissions": true` in `preferences.json` in the cmod store. A permission the person turned off stays off across updates, and no update asks for it again. A mod set up by a cmod before 4.3.0 asks for a permission its next update adds, because its install record does not name the permissions it had. An update that only drops a hotkey or a permission sets the mod up without asking.
38
38
 
39
39
  - In Claude Code, the mod opens its install page, the `Install <mod>` tab of the Sidebar. Claude Code gives the Sidebar the keys when the prompt is empty and nothing else holds them. Otherwise a click on the page does. A Sidebar opened this way shows only on a terminal 144 columns wide, so below that the toast `Installing`, with `Waiting for your answer` and an `Answer` button, opens it. The page asks `Install <mod>?` and lists `<mod> wants to:`, each permission as one sentence, then `and change your computer:` with `Run <install> now, and <uninstall> when you remove it`, `Install <program>, which Claude runs by its name`, and `Bind shift+tab to Cycle the mode`, naming only what the mod has. `Accept` (a) runs the setup, and a loading toast above the prompt shows the install with a progress bar. `Not now` (n) and the `×` on the tab decline. Escape hides the Sidebar, and the question waits in its tab and its toast.
40
40
  - In a session with no screen, such as `claude -p`, the mod waits and logs `<mod> waits for consent to run <install>. Run cmod install <mod> in a terminal.` That person is already in a terminal, and no screen exists to draw a button on.
@@ -47,7 +47,7 @@ The mod starts only once its install step has run ([mod.md](mod.md)).
47
47
 
48
48
  Claude Code updates a plugin by itself only when its marketplace has automatic updates on, and they are off for every marketplace that is not Anthropic's. So the setup of a mod installed from a marketplace turns them on, through `"autoUpdate": true` on that marketplace's `extraKnownMarketplaces` entry in `settings.json`. The consent lists it as `Update <mod> automatically from the <marketplace> marketplace`, and a mod with nothing to consent to logs it. The setup never changes a choice the person made, in `settings.json` or with the toggle under `/plugin` Marketplaces, and leaves a linked mod alone. The cmod plugin's own `cmod` marketplace gets the same entry whenever a `cmod` command installs the cmod plugin or `cmod update` updates it.
49
49
 
50
- Claude Code downloads an update in the background and loads it at the next launch or `/reload-plugins`. An update that changes a command or a script file, adds a hotkey or changes its default combo, or adds a permission waits for consent again, so an update never runs a new install step unasked.
50
+ Claude Code downloads an update in the background and loads it at the next launch or `/reload-plugins`. An update that changes a command or a script file, or adds a hotkey or changes its default combo, waits for consent again, so an update never runs a new install step unasked. An update that adds a permission waits for consent only while `Ask before an update adds a permission` is on.
51
51
 
52
52
  In Claude Code, the mod sets itself up through the `cmod` program the cmod plugin installed, never one elsewhere on PATH, and only once that program is at least the version of the `@cmodjs/core` the mod bundles. Until then its toast says `Waiting for cmod`. After a minute it says `<mod> needs cmod <version> or later, and this computer has cmod <version>, so cmod is updating itself.` and runs `cmod update cmod` once. The mod sets up as soon as a new enough cmod is installed. When the update leaves cmod older, the next wait shows `<mod> needs cmod <version> or later, and the newest cmod is <version>.` with a Retry button instead of updating again.
53
53
 
@@ -95,6 +95,7 @@ A plugin cannot bind a key in Claude Code: Claude Code reads key bindings only f
95
95
 
96
96
  - cmod writes each combo into the `Chat` bindings of `~/.claude/keybindings.json`, or of `$CLAUDE_CONFIG_DIR/keybindings.json` when that variable is set. When the file is a symbolic link, cmod writes the file it points to. Claude Code reads the change at once, with no restart.
97
97
  - A combo the person already bound to something else stays theirs, and the hotkey has no combo. The person picks one in Settings, under the mod, Hotkeys.
98
+ - A hotkey without a default combo binds nothing at setup and needs no consent. Settings lists it as unbound, and the person binds it there or with `cmod hotkey`.
98
99
  - The combo the person picks in Settings runs `cmod hotkey <mod> <hotkey> <combo>`. An update keeps the combo each hotkey has in `keybindings.json`, whether Settings or the person's own edit bound it ([commands.md](commands.md#cmod-hotkey)).
99
100
  - An upgrade that drops a hotkey removes its binding. Removing the mod removes every binding that runs one of its hotkeys, and a `Chat` block that leaves empty. A binding the person moved to another action stays.
100
101
  - A hotkey bound to `shift+tab` replaces Claude Code's own mode switch, and Claude Code then drops its `shift+tab` hint.
package/docs/jobs.md CHANGED
@@ -98,6 +98,7 @@ tool<Schema, State>(options: {
98
98
  readonly name: string
99
99
  readonly description: string
100
100
  readonly inputSchema?: Schema
101
+ readonly isDeferred?: boolean
101
102
  readonly execute: (input: FromSchema<Schema>, mod: Mod<State>) => unknown
102
103
  }): Job<Tool, State>
103
104
 
@@ -107,6 +108,7 @@ type Tool = { readonly name: string; remove(): void }
107
108
  - `name` is 1 to 64 letters, digits, `_`, or `-`. Claude sees the tool as `mcp__<plugin name>__<name>`, and the handle's `name` is that full name. `remove()` on the handle stops the mod answering the tool.
108
109
  - `description` tells Claude what the tool does.
109
110
  - `inputSchema` is a JSON Schema with `type: 'object'`. It types `execute`'s `input`, so write it inline. cmod checks each call's input against it, draft 2020-12, and denies an input that does not fit with the list of its errors. Its properties cannot be named `tool`, `tool_use_id`, `consent`, or `agentId`, which Claude Code keeps for itself.
111
+ - `isDeferred: false` puts the tool's schema in Claude's tool list from the first turn, for a tool Claude calls in most turns. `true`, or leaving it out, keeps the tool behind Claude Code's ToolSearch, so Claude searches for it before its first call. Each tool kept in the list adds its schema to every turn's context.
110
112
  - `execute` returns the result Claude reads. A `string` and an array of content blocks go to Claude as they are. Any other value goes as JSON. `undefined` returns nothing.
111
113
  - An input that does not fit the schema is denied with one line per error under a heading, such as `The open_ticket tool input is not valid:` followed by `- #: Instance does not have required property "title".` The text after `- ` is the location in the input, `#` for its root, and the validator's message.
112
114
  - An `execute` that throws denies the call with `The <name> tool failed: <error>`.
package/docs/mod.md CHANGED
@@ -22,7 +22,7 @@ type ModDefinition<State, Name, Options, Hotkeys> = {
22
22
  - `name` is the mod's name. Use the `name` in `.claude-plugin/plugin.json`. Claude Mod Manager (cmod) keys the saved state and the options by this name, and the data folder and the Skill overrides by the plugin's name, so the two must match. `defineMod` throws `defineMod: the mod needs a name, such as the name in .claude-plugin/plugin.json.` for a blank name.
23
23
  - `state` holds the starting values, grouped by how long they last. [state.md](state.md) explains the groups.
24
24
  - `options` declares what a person sets, such as a token, and types `mod.options`. [options.md](options.md) explains them.
25
- - `hotkeys` declares the key combos the mod listens for, each with a title and a default combo the person can change ([Hotkeys](#hotkeys)).
25
+ - `hotkeys` declares the key combos the mod listens for, each with a title and an optional default combo the person can change ([Hotkeys](#hotkeys)).
26
26
  - `installer` lists the steps the person finishes in Claude Code after the permissions and the options, such as signing in. [install-steps.md](install-steps.md#steps-in-claude-code) explains them.
27
27
  - `setup` runs once when the mod starts. It adds listeners, pages, panes, widgets, styles, and jobs. It may be `async`. What it returns is the mod's API: an object of methods other mods call. Return nothing for a mod that offers none. [dependencies.md](dependencies.md) explains it.
28
28
 
@@ -47,7 +47,7 @@ export const greeter = defineMod({
47
47
 
48
48
  Claude Code loads the mod at the start of each session. cmod then checks that the mod is set up. A mod the person has not accepted yet opens its install page, the `Install <name>` tab of the Sidebar, which lists its permissions and the changes it makes to the computer, and waits for Accept ([install-steps.md](install-steps.md)). An option with no default and no value is asked next on the same page. Then cmod loads the saved state, runs `setup`, marks as open each of the mod's panes that Claude Code already shows, and opens the install page again for each `installer` step the mod declares that is not done.
49
49
 
50
- The first time a mod starts on a machine, cmod shows the toast `Installed` under its name. Opened, it lists the mod's `plugin.json` `description`, what setup added, such as `Adds the my-mod pane, the Branch widget and /deploy.`, what its install step set up, and each permission the person allowed, with a Settings button that opens Settings at the mod. The first time a new version starts, the toast is `Updated to <version>`: the first three changes of that version's `CHANGELOG.md` section, the version the machine ran before, and a Changelog button ([Release notes](#release-notes)). A mod with no changelog lists what it adds now and no longer adds instead. A new session, `/reload-plugins`, and a version the machine already ran show no toast.
50
+ The first time a mod starts on a machine, cmod shows the toast `Installed` under its name. Opened, it lists the mod's `plugin.json` `description`, what setup added, such as `Adds the my-mod pane, the Branch widget and /deploy.`, what its install step set up, and each permission the person allowed, with a Settings button that opens Settings at the mod. A new version shows no toast of the mod's own: after the reload that loads it, the cmod plugin shows `<mod> updated to <version>` in the corner, followed by each permission the update granted ([commands.md](commands.md#install-mods)). A new session and `/reload-plugins` show no toast.
51
51
 
52
52
  When a step fails, or the person declines the install, the mod stays stopped. Once another session sets it up, the mod starts at the next prompt of every session it stopped in, with no `/reload-plugins`.
53
53
 
@@ -62,7 +62,7 @@ When a step fails, the mod does not start. An error toast above the prompt names
62
62
  - `its open panes did not load: <error>` when Claude Code cannot list the open panes.
63
63
  - `the details of its session did not load: <error>` when Claude Code cannot name the session's id, model, or start time.
64
64
 
65
- Each of these has `Retry`, which starts the mod again, and `Report` and `Hide` ([ui.md](ui.md#toasts)).
65
+ Each of these has `Retry`, which starts the mod again, and `Report` and `Hide` ([ui.md](ui.md#toasts)). A failed step is critical, so its toast shows for an installed mod too, unless the failure is a refusal for a permission the person turned off, which goes only to the Log.
66
66
 
67
67
  ## Rules
68
68
 
@@ -100,7 +100,7 @@ A mod's `CHANGELOG.md`, at its root, holds what changed in each version, written
100
100
  ```
101
101
 
102
102
  - `cmod publish` releases the version's section as the GitHub release's notes, and refuses a version with no section ([commands.md](commands.md#cmod-publish)). Every release ships the file.
103
- - The Updated toast shows the first three changes of the new version's section, and its Changelog button opens the mod's Changelog in Settings, the whole file with the installed version at the top of the view.
103
+ - Settings shows the mod's Changelog, the whole file with the installed version at the top of the view.
104
104
  - A linked checkout whose version has no section yet shows its `[Unreleased]` section, so the notes show as soon as the version moves.
105
105
  - `cmod new` writes the file with an `[Unreleased]` and a `[0.1.0]` section.
106
106
 
@@ -246,10 +246,10 @@ With `{ to: 'transcript' }`, the line shows dim in the conversation, where the p
246
246
 
247
247
  ### Hotkeys
248
248
 
249
- A hotkey is a key combo the mod listens for, such as `alt+shift+p` to show a page. The mod declares each one with a title and a default combo, and the person changes the combo in Settings, under the mod, Hotkeys, the way VS Code handles an extension's keybindings.
249
+ A hotkey is a key combo the mod listens for, such as `alt+shift+p` to show a page. The mod declares each one with a title and an optional default combo, and the person changes the combo in Settings, under the mod, Hotkeys, the way VS Code handles an extension's keybindings.
250
250
 
251
251
  ```ts
252
- hotkeys?: { readonly [name: string]: { readonly title: string; readonly default: Combo } }
252
+ hotkeys?: { readonly [name: string]: { readonly title: string; readonly default?: Combo } }
253
253
 
254
254
  type Hotkey = {
255
255
  readonly title: string
@@ -261,8 +261,9 @@ type Hotkey = {
261
261
  - A name is letters, digits, and `_`, starting with a letter. `title` is the label Settings shows beside the combo.
262
262
  - A combo is one or two of `ctrl`, `alt`, `shift`, and `meta`, in that order, then a key: a letter, a digit, `f1` to `f12`, `tab`, `enter`, `escape`, `space`, `backspace`, `delete`, an arrow, `home`, `end`, `pageup`, `pagedown`, or a mark such as `/`. `ctrl+q`, `alt+shift+p`, and `ctrl+shift+k` are combos.
263
263
  - `defineMod` throws for a name, a title, or a combo that is not one, and for two hotkeys with one default.
264
- - `cmod check` writes the hotkeys into `package.json` `"cmod".hotkeys`, and `cmod publish` refuses a mod whose `package.json` differs from `defineMod`. The install question lists each combo, and `cmod setup` binds it in Claude Code's `keybindings.json`. A combo the person already bound to something else keeps their binding, and the hotkey has no combo until they pick one in Settings.
265
- - `combo` is the combo bound when the mod started, or `undefined` when `keybindings.json` binds none to the hotkey, such as when another binding kept the default.
264
+ - `cmod check` writes the hotkeys into `package.json` `"cmod".hotkeys`, and `cmod publish` refuses a mod whose `package.json` differs from `defineMod`. The install question lists each default combo, and `cmod setup` binds it in Claude Code's `keybindings.json`. A combo the person already bound to something else keeps their binding, and the hotkey has no combo until they pick one in Settings.
265
+ - A hotkey without a `default` starts unbound. The install question and the Installed toast leave it out, and Settings lists it as unbound until the person binds it there or with `cmod hotkey` ([commands.md](commands.md#cmod-hotkey)). Leave out `default` when the person should choose the key, such as for an action few people press.
266
+ - `combo` is the combo bound when the mod started, or `undefined` when `keybindings.json` binds none to the hotkey, such as when another binding kept the default or the hotkey has no default.
266
267
  - `onPress` runs `listener` each time the person presses the combo. A page or pane the listener opens shows at any width, because the press is the person's own ([ui.md](ui.md#the-sidebar-and-its-pages)).
267
268
  - `tested.hotkey(name)` presses a hotkey in a test ([testing.md](testing.md)).
268
269
 
@@ -35,7 +35,7 @@ Anthropic's plugin directory does not list a mod that can approve Claude's tool
35
35
 
36
36
  ## What the person sees
37
37
 
38
- The install opens the mod's install page in the Sidebar of Claude Code and lists every permission in `permissions`, with the install step, the program, and the hotkeys. An update asks again only when it adds a permission, and lists only the new ones. Removing the mod revokes everything it was granted.
38
+ The install opens the mod's install page in the Sidebar of Claude Code and lists every permission in `permissions`, with the install step, the program, and the hotkeys. An update grants a permission it adds without asking, and the `<mod> updated to <version>` toast names it. With `Ask before an update adds a permission` on, in Settings on cmod's page under Preferences, the update asks instead, and lists only the new permissions ([install-steps.md](install-steps.md#consent)). A permission the person turned off stays off across updates. Removing the mod revokes everything it was granted.
39
39
 
40
40
  Settings lists the same permissions as toggles, under the mod, Permissions. A toggle runs `cmod permission <mod> <name> [value] on|off`, and the mod sees the change before its next call, with no reload.
41
41
 
@@ -76,12 +76,12 @@ if (mod.permissions.run.allows('gh')) mod.every(60_000, refreshRuns)
76
76
  The call rejects, and the error names the fix:
77
77
 
78
78
  - An undeclared call names the line to add: `ci-watch calls http.fetch(https://api.github.com/repos), which needs "permissions": { "network": ["api.github.com"] } in package.json "cmod".`
79
- - A declared call the person turned off names where to turn it on: `ci-watch calls model.complete without your grant to "Ask a model, which uses your plan". Turn it on in Settings.` The error toast that shows it has a `Settings` button that opens the mod's Permissions.
79
+ - A declared call the person turned off names where to turn it on: `ci-watch calls model.complete without your grant to "Ask a model, which uses your plan". Turn it on in Settings.` The person chose this, so the failure goes to the Log in Settings and to Claude Code's debug log, with no toast, unless the cmod running it is older than 4.3.0 ([ui.md](ui.md#toasts)).
80
80
  - A `program` job without its grant stops at once with the same line, with no restarts.
81
81
 
82
82
  ## When a before answer has no grant
83
83
 
84
- cmod checks the answer each `before` listener returns, part by part. A part without its grant changes nothing, and cmod shows the error toast `The <method> listener failed` or logs once which part it dropped and the permission to turn on.
84
+ cmod checks the answer each `before` listener returns, part by part. A part without its grant changes nothing, and cmod reports the failure `The <method> listener failed`, or once which part it dropped and the permission to turn on, where errors go ([ui.md](ui.md#toasts)).
85
85
 
86
86
  | Answer part | Permission |
87
87
  | --- | --- |
package/docs/testing.md CHANGED
@@ -373,6 +373,8 @@ type ShownToast = { readonly type: ToastType; readonly message: string; readonly
373
373
 
374
374
  What the person and Claude would see: the toasts shown now, with a text description, the notes the mod added for Claude with `sessions.current.send` or a `prompt` that follows the state, and the `beforePrompt` notes a subagent reads as it starts from a spawn the test fires, the prompts it sent to the current session, the messages it sent to other sessions in `sent`, the log lines, the debug log lines, the open panes, the slash commands and tools the mod added, and the crons its `schedule` keeps now.
375
375
 
376
+ The test kit keeps no Log, as a cmod older than 4.3.0 keeps none, so every error cmod catches for the mod shows in `toasts`, a refusal for a permission the test turned off with `permissions` included ([ui.md](ui.md#toasts)).
377
+
376
378
  ```ts
377
379
  test('the Mode prompt follows the mode', async () => {
378
380
  const tested = testMod(modes)
package/docs/ui.md CHANGED
@@ -19,7 +19,7 @@ Claude Mod Manager (cmod) draws the mod again whenever a value in `mod.state` ch
19
19
 
20
20
  ## Every message the person acts on carries a button
21
21
 
22
- A mod never asks the person to type a command. When a toast, a page, or a pane needs the person to do something, it draws a `Button` that does it, or that opens the place where they do it, such as `mod.settings.open()` or a page's `open()`. cmod follows the same rule: a failure caused by a permission the person turned off carries a `Settings` button that opens the mod's Permissions, and a secret option carries an `Open /config` button.
22
+ A mod never asks the person to type a command. When a toast, a page, or a pane needs the person to do something, it draws a `Button` that does it, or that opens the place where they do it, such as `mod.settings.open()` or a page's `open()`. cmod follows the same rule: a failure caused by a provider that is not installed carries a `Plugins` button, and a secret option carries an `Open /config` button. A failure caused by a permission the person turned off shows no toast, because the person chose it, and goes to the Log in Settings.
23
23
 
24
24
  ## Elements
25
25
 
@@ -438,9 +438,18 @@ type ToastOptions = {
438
438
  - `✕` closes the toast. The band shows the newest 3, and `+N more` shows every toast.
439
439
  - `promise` shows `loading` while `task` runs, then `success` or `error` in the same row. `unwrap()` resolves or rejects as `task` does.
440
440
 
441
- An error cmod catches for a mod, such as a listener that throws, shows as an error toast that stays, with its buttons on a line under the message:
441
+ 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.
442
+
443
+ An error also shows as a toast when any of these holds:
444
+
445
+ - it is critical: the mod's install or setup failed, its program stopped, or a button or hotkey the person pressed failed
446
+ - the mod runs from its checkout, linked with [`cmod link`](commands.md#cmod-link) or loaded with `--plugin-dir`, because the person is its author
447
+ - `Show errors from installed mods` is on, in Settings on cmod's page under Preferences
448
+
449
+ A refusal for a permission the mod declared and the person turned off, whose text ends in `Turn it on in Settings.`, shows no toast. It goes to the Log and to Claude Code's debug log. A cmod older than 4.3.0 keeps no Log, so there every error shows its toast, this one included.
450
+
451
+ The error toast stays, with its buttons on a line under the message:
442
452
 
443
- - `Settings` opens the mod's Permissions in Settings, when the failure came from a permission the person turned off.
444
453
  - `Retry` runs the failed step again, where running it again can work: an install, the mod's setup, or a program that stopped.
445
454
  - `Report` replaces the toast's buttons with the ways to tell the mod's author. `Ask Claude to report it` sends this session a prompt to file the report with the person's own tools. `Report it on GitHub (opens your browser)` opens a filled-in issue on the mod's `supportUrl` or `repository` in its `plugin.json`, or `Email the author (opens your mail app)` writes to its `author.email`. `Copy the error` copies the mod's name and version, the `@cmodjs/core` version, the message, the whole cause, and the stack.
446
455
  - `Hide` closes the toast and keeps the same failure hidden in later sessions. A new version of the mod, or a different failure, shows again.
package/hotkeys.d.ts CHANGED
@@ -8,7 +8,7 @@ type Modifiers = 'ctrl' | 'alt' | 'shift' | 'meta' | 'ctrl+alt' | 'ctrl+shift' |
8
8
  export type Combo = `${Modifiers}+${Key}`;
9
9
  export type HotkeyInit = {
10
10
  readonly title: string;
11
- readonly default: Combo;
11
+ readonly default?: Combo;
12
12
  };
13
13
  export type Hotkeys = Readonly<Record<string, HotkeyInit>>;
14
14
  export type Hotkey = {
package/hotkeys.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"hotkeys.d.ts","sourceRoot":"","sources":["src/hotkeys.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAA;AAE3D,KAAK,MAAM,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,G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letter.`);
16
16
  if (declared.title.trim() === '')
17
17
  throw new Error(`${at} needs a title, the label Settings shows beside its combo.`);
18
+ if (declared.default === undefined)
19
+ continue;
18
20
  if (!isCombo(declared.default))
19
21
  throw new Error(`${at} defaults to "${String(declared.default)}", which is not a combo. Give one or two of ctrl, alt, shift, meta in that order, then a key, such as "ctrl+q" or "ctrl+shift+k".`);
20
22
  const taken = combos.get(declared.default);
package/jobs/program.js CHANGED
@@ -34,7 +34,7 @@ export function program(options) {
34
34
  failure = undefined;
35
35
  void start();
36
36
  };
37
- report({ id: `program:${executable}`, message: `The ${executable} program stopped`, description: reason, retry });
37
+ report({ id: `program:${executable}`, message: `The ${executable} program stopped`, description: reason, retry, isCritical: true });
38
38
  for (const waiter of waiting.splice(0))
39
39
  waiter.reject(failure);
40
40
  };
package/jobs/tool.d.ts CHANGED
@@ -10,6 +10,7 @@ export declare function tool<const Schema extends object = {
10
10
  readonly name: string;
11
11
  readonly description: string;
12
12
  readonly inputSchema?: Schema;
13
+ readonly isDeferred?: boolean;
13
14
  readonly execute: (input: Schema extends JSONSchema ? FromSchema<Schema> : never, mod: Mod<State>) => unknown;
14
15
  }): Job<Tool, State>;
15
16
  //# sourceMappingURL=tool.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"tool.d.ts","sourceRoot":"","sources":["../src/jobs/tool.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAA;AAC/D,OAAO,KAAK,EAAE,GAAG,EAAE,GAAG,EAAE,MAAM,WAAW,CAAA;AAUzC,MAAM,MAAM,IAAI,GAAG;IAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAAC,MAAM,IAAI,IAAI,CAAA;CAAE,CAAA;AAE5D,wBAAgB,IAAI,CAAC,KAAK,CAAC,MAAM,SAAS,MAAM,GAAG;IAAE,IAAI,EAAE,QAAQ,CAAA;CAAE,EAAE,KAAK,SAAS,MAAM,GAAG,M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EAAE,GAAG,EAAE,GAAG,CAAC,KAAK,CAAC,KAAK,OAAO,CAAA;CAC9G,GAAG,GAAG,CAAC,IAAI,EAAE,KAAK,CAAC,CA0CnB"}
package/jobs/tool.js CHANGED
@@ -6,7 +6,7 @@ import { messageOf } from '../utils/text.js';
6
6
  import { withinDeadline } from './context.js';
7
7
  const toolName = /^[A-Za-z0-9_-]{1,64}$/;
8
8
  export function tool(options) {
9
- const { name, description, inputSchema, execute } = options;
9
+ const { name, description, inputSchema, isDeferred, execute } = options;
10
10
  return (job) => {
11
11
  const { mod, announce, reserveName } = job;
12
12
  const { claude, router, report } = engineOf(mod);
@@ -19,7 +19,7 @@ export function tool(options) {
19
19
  const named = reserveName('tool', name, `${mod.name}: the tool ${name} is already added. Give each tool its own name.`);
20
20
  const validator = new Validator(inputSchema ?? { type: 'object' }, '2020-12', false);
21
21
  let registered;
22
- claude.tool.register({ name, description, ...(inputSchema === undefined ? {} : { inputSchema: inputSchema }) }).then((answer) => {
22
+ claude.tool.register({ name, description, ...(inputSchema === undefined ? {} : { inputSchema: inputSchema }), ...(isDeferred === undefined ? {} : { isDeferred }) }).then((answer) => {
23
23
  registered = answer.tool;
24
24
  }, (error) => {
25
25
  report({ id: `tool:${name}`, message: `The ${name} tool is not added`, error });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cmodjs/core",
3
- "version": "4.1.1",
3
+ "version": "4.3.0",
4
4
  "description": "Build Claude Code mods: hooks, panes, permissions, checks, and an install that just works.",
5
5
  "license": "MIT",
6
6
  "type": "module",
package/records.d.ts CHANGED
@@ -8,6 +8,8 @@ export type InstallRecord = {
8
8
  uninstall: string | null;
9
9
  program: string | null;
10
10
  keys: Readonly<Record<string, string>>;
11
+ permissions: readonly string[] | null;
12
+ grantedOnUpdate: readonly string[];
11
13
  };
12
14
  export type Steps = {
13
15
  install?: string;
@@ -90,8 +92,14 @@ export declare function parseLinks(value: unknown, path: string): Links;
90
92
  export declare function linkedMarketplacesOf(knownMarketplaces: unknown, links: Links): [name: string, folder: string][];
91
93
  export declare function hasLinkedMods(knownMarketplaces: unknown, links: Links): boolean;
92
94
  export declare function widgetsPath(store: string): string;
95
+ export declare function preferencesPath(store: string): string;
96
+ export type Preferences = {
97
+ readonly asksBeforeUpdatePermissions: boolean;
98
+ readonly showsInstalledModErrors: boolean;
99
+ };
100
+ export declare function parsePreferences(value: unknown, path: string): Preferences;
93
101
  export declare function parseConsent(value: unknown, path: string): Record<string, string[]>;
94
- export declare const coreVersion = "4.1.1";
102
+ export declare const coreVersion = "4.3.0";
95
103
  export declare function hotkeyCommand(mod: string, hotkey: string): string;
96
104
  export declare function hotkeyBindings(mod: string, hotkeys: Hotkeys | undefined): Record<string, string>;
97
105
  export declare function boundCombos(keybindings: unknown): Map<string, string>;
package/records.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"records.d.ts","sourceRoot":"","sources":["src/records.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiC,KAAK,OAAO,EAAE,MAAM,cAAc,CAAA;AAG1E,MAAM,MAAM,aAAa,GAAG;IAC1B,IAAI,EAAE,MAAM,CAAA;IACZ,OAAO,EAAE,MAAM,CAAA;IACf,IAAI,EAAE,MAAM,CAAA;IACZ,WAAW,EAAE,MAAM,CAAA;IACnB,aAAa,EAAE,MAAM,CAAA;IACrB,SAAS,EAAE,MAAM,GAAG,IAAI,CAAA;IACxB,OAAO,EAAE,MAAM,GAAG,IAAI,CAAA;IACtB,IAAI,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAA;CACvC,CAAA;AAED,MAAM,MAAM,KAAK,GAAG;IAClB,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,WAAW,CAAC,EAAE,SAAS,MAAM,EAAE,CAAA;CA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AiBtD;AAED,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,WAAW,CAiBpD;AAED,wBAAgB,SAAS,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAQnE;AAED,wBAAgB,QAAQ,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAEzE"}
package/records.js CHANGED
@@ -89,6 +89,12 @@ function parseRecord(text, path) {
89
89
  const keys = value['keys'] ?? {};
90
90
  if (!isObject(keys) || Object.values(keys).some((command) => typeof command !== 'string'))
91
91
  throw new Error(`${path} has "keys" that are not key bindings. ${fix}`);
92
+ const permissions = value['permissions'] ?? null;
93
+ if (permissions !== null && !isTextList(permissions))
94
+ throw new Error(`${path} has "permissions" that are not a list of permissions. ${fix}`);
95
+ const grantedOnUpdate = value['grantedOnUpdate'] ?? [];
96
+ if (!isTextList(grantedOnUpdate))
97
+ throw new Error(`${path} has a "grantedOnUpdate" that is not a list of permissions. ${fix}`);
92
98
  return {
93
99
  name: value['name'],
94
100
  version: value['version'],
@@ -98,6 +104,8 @@ function parseRecord(text, path) {
98
104
  uninstall,
99
105
  program,
100
106
  keys: keys,
107
+ permissions,
108
+ grantedOnUpdate,
101
109
  };
102
110
  }
103
111
  export function readSteps(pkg) {
@@ -250,10 +258,20 @@ export function hasLinkedMods(knownMarketplaces, links) {
250
258
  export function widgetsPath(store) {
251
259
  return `${store}/widgets.json`;
252
260
  }
261
+ export function preferencesPath(store) {
262
+ return `${store}/preferences.json`;
263
+ }
264
+ export function parsePreferences(value, path) {
265
+ if (value === undefined)
266
+ return { asksBeforeUpdatePermissions: false, showsInstalledModErrors: false };
267
+ if (!isObject(value) || ['asksBeforeUpdatePermissions', 'showsInstalledModErrors'].some((key) => value[key] !== undefined && typeof value[key] !== 'boolean'))
268
+ throw new Error(`${path} is not a map of cmod's preferences to true or false. Delete it, and cmod uses its defaults.`);
269
+ return { asksBeforeUpdatePermissions: value['asksBeforeUpdatePermissions'] === true, showsInstalledModErrors: value['showsInstalledModErrors'] === true };
270
+ }
253
271
  export function parseConsent(value, path) {
254
272
  if (value === undefined)
255
273
  return Object.create(null);
256
- if (!isObject(value) || Object.values(value).some((items) => !Array.isArray(items) || items.some((item) => typeof item !== 'string'))) {
274
+ if (!isObject(value) || !Object.values(value).every(isTextList)) {
257
275
  throw new Error(`${path} is not a map of plugin names to what each was approved for. Delete it, and cmod asks again.`);
258
276
  }
259
277
  return Object.assign(Object.create(null), value);
@@ -262,16 +280,16 @@ function readHotkeys(hotkeys) {
262
280
  if (hotkeys === undefined)
263
281
  return {};
264
282
  const fix = 'cmod check writes it from the hotkeys defineMod declares, so run cmod check.';
265
- if (!isObject(hotkeys) || !Object.values(hotkeys).every((each) => isObject(each) && typeof each['title'] === 'string' && typeof each['default'] === 'string'))
266
- throw new Error(`package.json "cmod.hotkeys" is not a map of hotkeys to their title and default combo. ${fix}`);
283
+ if (!isObject(hotkeys) || !Object.values(hotkeys).every((each) => isObject(each) && typeof each['title'] === 'string' && (each['default'] === undefined || typeof each['default'] === 'string')))
284
+ throw new Error(`package.json "cmod.hotkeys" is not a map of hotkeys to their title and optional default combo. ${fix}`);
267
285
  return { hotkeys: checkHotkeys('package.json "cmod"', hotkeys) };
268
286
  }
269
- export const coreVersion = '4.1.1';
287
+ export const coreVersion = '4.3.0';
270
288
  export function hotkeyCommand(mod, hotkey) {
271
289
  return `${mod}--${hotkey}`;
272
290
  }
273
291
  export function hotkeyBindings(mod, hotkeys) {
274
- return Object.fromEntries(Object.entries(hotkeys ?? {}).map(([name, { default: combo }]) => [combo, hotkeyCommand(mod, name)]));
292
+ return Object.fromEntries(Object.entries(hotkeys ?? {}).flatMap(([name, { default: combo }]) => (combo === undefined ? [] : [[combo, hotkeyCommand(mod, name)]])));
275
293
  }
276
294
  export function boundCombos(keybindings) {
277
295
  const blocks = isObject(keybindings) && Array.isArray(keybindings['bindings']) ? keybindings['bindings'] : [];
@@ -286,7 +304,7 @@ export function boundCombos(keybindings) {
286
304
  return combos;
287
305
  }
288
306
  export function hotkeyWords(hotkeys) {
289
- return listed(Object.values(hotkeys ?? {}).map(({ title, default: combo }) => `${combo} to ${title}`));
307
+ return listed(Object.values(hotkeys ?? {}).flatMap(({ title, default: combo }) => (combo === undefined ? [] : [`${combo} to ${title}`])));
290
308
  }
291
309
  function readCommand(steps, key) {
292
310
  const command = steps[key];
@@ -403,3 +421,6 @@ export function isAtLeast(version, minimum) {
403
421
  export function isObject(value) {
404
422
  return typeof value === 'object' && value !== null && !Array.isArray(value);
405
423
  }
424
+ function isTextList(value) {
425
+ return Array.isArray(value) && value.every((item) => typeof item === 'string');
426
+ }
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;AAa3C,wBAAgB,aAAa,IAAI,aAAa,CAAC,MAAM,CAAC,GAAG,SAAS,CAEjE;AAgGD,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;AAa3C,wBAAgB,aAAa,IAAI,aAAa,CAAC,MAAM,CAAC,GAAG,SAAS,CAEjE;AAiGD,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
@@ -13,6 +13,7 @@ async function startMod($, eventInput, passOn) {
13
13
  ui: {
14
14
  log: (text, options) => $.ui.log(text, options),
15
15
  notice: (toolUseId, text) => $.ui.notice(toolUseId, text),
16
+ toast: (text, options) => $.ui.toast(text, options),
16
17
  invalidate: (event) => $.ui.invalidate(event),
17
18
  ask: (question, options) => $.ui.ask(question, options),
18
19
  open: (pane) => $.ui.open(pane),
@@ -1,18 +1,13 @@
1
1
  import type { Claude } from './claude.js';
2
2
  import type { Plugin } from './lifecycle.js';
3
- export type Announced = {
4
- readonly version: string;
5
- readonly added: readonly string[];
6
- };
7
3
  export type Announcement = {
8
4
  readonly message: string;
9
5
  readonly description?: string;
10
- readonly action?: {
6
+ readonly action: {
11
7
  readonly label: string;
12
8
  readonly onClick: () => unknown;
13
9
  };
14
10
  };
15
11
  export declare const announcementMs = 10000;
16
- export declare function announcedOf(saved: unknown): Announced | undefined;
17
- export declare function announcementOf(claude: Claude, plugin: Plugin, granted: ReadonlySet<string>, added: readonly string[], previous: Announced | undefined, openSettings: (tab?: 'changelog') => Promise<void>): Promise<Announcement>;
12
+ export declare function announcementOf(claude: Claude, plugin: Plugin, granted: ReadonlySet<string>, added: readonly string[], openSettings: () => Promise<void>): Promise<Announcement>;
18
13
  //# sourceMappingURL=announce.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"announce.d.ts","sourceRoot":"","sources":["../src/runtime/announce.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AACzC,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAA;AAE5C,MAAM,MAAM,SAAS,GAAG;IAAE,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,SAAS,MAAM,EAAE,CAAA;CAAE,CAAA;AAEvF,MAAM,MAAM,YAAY,GAAG;IAAE,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,MAAM,CAAC,EAAE;QAAE,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,OAAO,EAAE,MAAM,OAAO,CAAA;KAAE,CAAA;CAAE,CAAA;AAErK,eAAO,MAAM,cAAc,QAAS,CAAA;AAIpC,wBAAgB,WAAW,CAAC,KAAK,EAAE,OAAO,GAAG,SAAS,GAAG,SAAS,CAIjE;AAED,wBAAsB,cAAc,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,WAAW,CAAC,MAAM,CAAC,EAAE,KAAK,EAAE,SAAS,MAAM,EAAE,EAAE,QAAQ,EAAE,SAAS,GAAG,SAAS,EAAE,YAAY,EAAE,CAAC,GAAG,CAAC,EAAE,WAAW,KAAK,OAAO,CAAC,IAAI,CAAC,GAAG,OAAO,CAAC,YAAY,CAAC,CAuCvO"}
1
+ {"version":3,"file":"announce.d.ts","sourceRoot":"","sources":["../src/runtime/announce.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AACzC,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAA;AAE5C,MAAM,MAAM,YAAY,GAAG;IAAE,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,MAAM,EAAE;QAAE,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,OAAO,EAAE,MAAM,OAAO,CAAA;KAAE,CAAA;CAAE,CAAA;AAEpK,eAAO,MAAM,cAAc,QAAS,CAAA;AAEpC,wBAAsB,cAAc,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,WAAW,CAAC,MAAM,CAAC,EAAE,KAAK,EAAE,SAAS,MAAM,EAAE,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,GAAG,OAAO,CAAC,YAAY,CAAC,CAarL"}
@@ -1,55 +1,20 @@
1
- import { isObject, marketplaceOf, permissionWords } from '../records.js';
2
- import { changeLines, changelogSections, unreleased } from '../utils/changelog.js';
1
+ import { isObject, permissionWords } from '../records.js';
3
2
  import { ifMissing } from '../utils/paths.js';
4
3
  import { listed } from '../utils/text.js';
5
4
  export const announcementMs = 10_000;
6
- const shownChanges = 3;
7
- export function announcedOf(saved) {
8
- if (typeof saved === 'string')
9
- return { version: saved, added: [] };
10
- if (!isObject(saved) || typeof saved['version'] !== 'string')
11
- return undefined;
12
- return { version: saved['version'], added: Array.isArray(saved['added']) ? saved['added'].map(String) : [] };
13
- }
14
- export async function announcementOf(claude, plugin, granted, added, previous, openSettings) {
15
- const read = (path) => claude.fs.read(`${plugin.root}/${path}`).catch(ifMissing(undefined));
16
- const manifest = jsonOf(await read('.claude-plugin/plugin.json'));
17
- const field = (key) => (isObject(manifest) && typeof manifest[key] === 'string' ? manifest[key] : undefined);
18
- const open = (tab) => () => openSettings(tab);
19
- if (previous === undefined) {
20
- const { program, hotkeys } = plugin.steps;
21
- const rules = (await claude.fs.list(`${plugin.root}/rules`).catch(ifMissing([]))).filter((entry) => entry.kind === 'file' && entry.name.endsWith('.md')).map((entry) => entry.name.slice(0, -'.md'.length)).toSorted();
22
- const lines = [
23
- field('description'),
24
- added.length > 0 ? `Adds ${listed(added)}.` : undefined,
25
- rules.length > 0 ? `Adds ${rules.length} ${rules.length === 1 ? 'rule' : 'rules'}: ${listed(rules)}.` : undefined,
26
- program === undefined ? undefined : `Installed the ${program} program.`,
27
- ...Object.values(hotkeys ?? {}).map(({ title, default: combo }) => `Binds ${combo} to ${title}.`),
28
- ...[...granted].map((item) => `${permissionWords(item)}.`),
29
- ];
30
- return { message: 'Installed', ...described(lines), action: { label: 'Settings', onClick: open() } };
31
- }
32
- const version = plugin.version ?? '';
33
- const isCheckout = marketplaceOf(plugin.root, plugin.name) === undefined;
34
- const sections = changelogSections((await read('CHANGELOG.md')) ?? '');
35
- const section = sections.find((each) => each.version === version) ?? (isCheckout ? sections.find((each) => each.version === unreleased) : undefined);
36
- const changes = section === undefined ? [] : changeLines(section.text);
37
- const nowAdded = added.filter((each) => !previous.added.includes(each));
38
- const gone = previous.added.filter((each) => !added.includes(each));
39
- const fallback = previous.added.length === 0 ? [] : [nowAdded.length > 0 ? `Now adds ${listed(nowAdded)}.` : undefined, gone.length > 0 ? `No longer adds ${listed(gone)}.` : undefined];
40
- const home = await claude.env.home();
41
- const folder = home !== undefined && plugin.root.startsWith(`${home}/`) ? `~${plugin.root.slice(home.length)}` : plugin.root;
42
- const repository = field('repository');
5
+ export async function announcementOf(claude, plugin, granted, added, openSettings) {
6
+ const manifest = jsonOf(await claude.fs.read(`${plugin.root}/.claude-plugin/plugin.json`).catch(ifMissing(undefined)));
7
+ const { program, hotkeys } = plugin.steps;
8
+ const rules = (await claude.fs.list(`${plugin.root}/rules`).catch(ifMissing([]))).filter((entry) => entry.kind === 'file' && entry.name.endsWith('.md')).map((entry) => entry.name.slice(0, -'.md'.length)).toSorted();
43
9
  const lines = [
44
- ...(changes.length === 0 ? fallback : changes.length > shownChanges ? [...changes.slice(0, shownChanges), '…'] : changes),
45
- `From ${previous.version}${isCheckout ? `, loaded from ${folder}` : ''}.`,
46
- repository === undefined || isCheckout ? undefined : `Release notes: ${repository.replace(/\/$/, '')}/releases/tag/v${version}`,
47
- ];
48
- return {
49
- message: `Updated to ${version}`,
50
- ...described(lines),
51
- ...(sections.length > 0 ? { action: { label: 'Changelog', onClick: open('changelog') } } : {}),
52
- };
10
+ isObject(manifest) && typeof manifest['description'] === 'string' ? manifest['description'] : undefined,
11
+ added.length > 0 ? `Adds ${listed(added)}.` : undefined,
12
+ rules.length > 0 ? `Adds ${rules.length} ${rules.length === 1 ? 'rule' : 'rules'}: ${listed(rules)}.` : undefined,
13
+ program === undefined ? undefined : `Installed the ${program} program.`,
14
+ ...Object.values(hotkeys ?? {}).flatMap(({ title, default: combo }) => (combo === undefined ? [] : [`Binds ${combo} to ${title}.`])),
15
+ ...[...granted].map((item) => `${permissionWords(item)}.`),
16
+ ].filter((line) => line !== undefined);
17
+ return { message: 'Installed', ...(lines.length === 0 ? {} : { description: lines.join('\n') }), action: { label: 'Settings', onClick: () => openSettings() } };
53
18
  }
54
19
  function jsonOf(text) {
55
20
  try {
@@ -61,7 +26,3 @@ function jsonOf(text) {
61
26
  throw error;
62
27
  }
63
28
  }
64
- function described(lines) {
65
- const kept = lines.filter((line) => line !== undefined);
66
- return kept.length === 0 ? {} : { description: kept.join('\n') };
67
- }