@cmodjs/core 4.3.3 → 5.0.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/README.md +1 -1
  2. package/docs/commands.md +20 -31
  3. package/docs/dependencies.md +7 -5
  4. package/docs/index.md +4 -5
  5. package/docs/install-steps.md +12 -14
  6. package/docs/jobs.md +3 -11
  7. package/docs/mod.md +18 -21
  8. package/docs/session.md +11 -11
  9. package/docs/state.md +1 -1
  10. package/docs/testing.md +3 -5
  11. package/docs/ui.md +4 -4
  12. package/jobs/program.d.ts.map +1 -1
  13. package/jobs/program.js +3 -17
  14. package/mod.d.ts +0 -16
  15. package/mod.d.ts.map +1 -1
  16. package/package.json +1 -1
  17. package/records.d.ts +4 -11
  18. package/records.d.ts.map +1 -1
  19. package/records.js +17 -48
  20. package/runtime/announce.d.ts +1 -1
  21. package/runtime/announce.d.ts.map +1 -1
  22. package/runtime/announce.js +2 -3
  23. package/runtime/conversations.d.ts.map +1 -1
  24. package/runtime/conversations.js +3 -46
  25. package/runtime/engine.d.ts +2 -2
  26. package/runtime/engine.d.ts.map +1 -1
  27. package/runtime/installer.d.ts +0 -9
  28. package/runtime/installer.d.ts.map +1 -1
  29. package/runtime/installer.js +1 -15
  30. package/runtime/lifecycle.d.ts +1 -2
  31. package/runtime/lifecycle.d.ts.map +1 -1
  32. package/runtime/lifecycle.js +37 -191
  33. package/runtime/metadata.d.ts +1 -2
  34. package/runtime/metadata.d.ts.map +1 -1
  35. package/runtime/metadata.js +1 -2
  36. package/runtime/sessions.d.ts +3 -7
  37. package/runtime/sessions.d.ts.map +1 -1
  38. package/runtime/sessions.js +10 -34
  39. package/runtime/toaster.d.ts.map +1 -1
  40. package/runtime/toaster.js +6 -9
  41. package/runtime/ui.d.ts +1 -0
  42. package/runtime/ui.d.ts.map +1 -1
  43. package/runtime/ui.js +31 -12
  44. package/src/jobs/program.ts +3 -17
  45. package/src/mod.ts +0 -18
  46. package/src/records.ts +20 -55
  47. package/src/runtime/announce.ts +2 -3
  48. package/src/runtime/conversations.ts +3 -45
  49. package/src/runtime/engine.ts +2 -2
  50. package/src/runtime/installer.ts +1 -37
  51. package/src/runtime/lifecycle.ts +38 -188
  52. package/src/runtime/metadata.ts +0 -3
  53. package/src/runtime/sessions.ts +10 -39
  54. package/src/runtime/toaster.ts +6 -9
  55. package/src/runtime/ui.ts +32 -13
  56. package/src/testing.ts +11 -16
  57. package/testing.d.ts +0 -1
  58. package/testing.d.ts.map +1 -1
  59. package/testing.js +11 -15
  60. package/docs/permissions.md +0 -97
  61. package/runtime/grants.d.ts +0 -34
  62. package/runtime/grants.d.ts.map +0 -1
  63. package/runtime/grants.js +0 -326
  64. package/src/runtime/grants.ts +0 -348
package/README.md CHANGED
@@ -4,7 +4,7 @@
4
4
 
5
5
  # @cmodjs/core
6
6
 
7
- The library every Claude Mod Manager mod imports. Claude Mod Manager (cmod) installs, tries, builds, checks, and publishes Claude Code mods: plugins with hooks, panes, slash commands, tools, permission rules, and an install step that runs with your consent.
7
+ The library every Claude Mod Manager mod imports. Claude Mod Manager (cmod) installs, tries, builds, checks, and publishes Claude Code mods: plugins with hooks, panes, slash commands, tools, permission rules, and an install step.
8
8
 
9
9
  ```sh
10
10
  npm i -g @cmodjs/cli
package/docs/commands.md CHANGED
@@ -22,7 +22,7 @@ Creates a mod in `./<name>`: a `defineMod` with one listener, a Sidebar page, a
22
22
  ### cmod link
23
23
 
24
24
  ```text
25
- cmod link [path] [--yes] [--option key=value]...
25
+ cmod link [path] [--option key=value]...
26
26
  ```
27
27
 
28
28
  Loads the checkout at `path` (default: the current folder) in every Claude Code session, the running ones too, in place of the installed mod. Installs the cmod plugin when Claude Code lacks it, unless the checkout is cmod itself. Then installs the checkout's packages, builds the program `cli/` declares and links it into cmod's programs folder and `~/.local/bin`, and runs the checkout's install step.
@@ -36,7 +36,6 @@ It loads the checkout through a marketplace cmod keeps in the checkout's parent
36
36
 
37
37
  It refuses a parent folder whose `.claude-plugin/marketplace.json` cmod did not write. `cmod watch` reloads every session once a change builds.
38
38
 
39
- - `--yes` approves the mod's install and uninstall commands without asking.
40
39
  - `--option key=value` sets one of the mod's options through `claude plugin configure`, once per option, under the linked id, such as `my-mod@Developer-linked`. It refuses a key the mod does not declare, and names the keys it does ([options.md](options.md)).
41
40
 
42
41
  ### cmod unlink
@@ -59,10 +58,10 @@ Runs every check this machine can run on the mod at `path` (default: the current
59
58
  2. Checks its layout.
60
59
  3. Checks that each step runs a script.
61
60
  4. Checks that `package.json` `"os"` and `"cpu"` list only machines cmod runs mods on, darwin and linux on arm64 and x64, and that the install step downloads a program for each machine they list.
62
- 5. Prints the permissions the person grants at install and can grant later, as the person reads them ([permissions.md](permissions.md)). It adds `"approve": true` when the mod allows or asks on the permission check and `hooks/register.ts` calls `registerPermissionCheck`. It fails a mod whose `src/` hears permissions while `register.ts` does not call `registerPermissionCheck`.
61
+ 5. Checks the permission check. It adds `"approve": true` to `package.json` `"cmod"` when the mod allows or asks on Claude Code's permission check and `hooks/register.ts` calls `registerPermissionCheck`. It fails a mod whose `src/` hears the permission check while `register.ts` does not call `registerPermissionCheck`, and a mod on `@cmodjs/core` 5.0.0 or later whose `package.json` `"cmod"` still declares `"permissions"`, with the fix `Delete "permissions" from package.json "cmod", and write "approve": true there if the mod approves tool calls.`
63
62
  6. Reads the metadata of every file in the mod, and names each file whose metadata cmod cannot read.
64
63
  7. Writes the options `defineMod` declares into `.claude-plugin/plugin.json` `userConfig`, and its hotkeys into `package.json` `"cmod"` `hotkeys`, keeping each file's own formatting, so Claude Code shows the options in `/config` ([options.md](options.md)). It loads `hooks/register.ts` to read them, without starting the mod.
65
- 8. Writes the `cmod` dependency in `.claude-plugin/plugin.json` as `>=` the version of the `@cmodjs/core` the mod installed, such as `>=4.0.0`, so every newer cmod runs the mod. A mod still on `@cmodjs/core` 3 keeps its own range ([dependencies.md](dependencies.md#call-the-methods-mod-dependencies)).
64
+ 8. Writes the `cmod` dependency in `.claude-plugin/plugin.json` as `>=` the oldest cmod the `@cmodjs/core` the mod installed runs on, `oldestCmodVersion` in its `records.js`, such as `>=5.0.0`, so every newer cmod runs the mod. A `@cmodjs/core` that does not export `oldestCmodVersion` runs on the cmod of its own version, so the range is `>=` that version, such as `>=4.3.4`. A mod still on `@cmodjs/core` 3 keeps its own range ([dependencies.md](dependencies.md#call-the-methods-mod-dependencies)). Claude Code turns a mod off when its cmod is older than that dependency, so `cmod check` first compares it with every cmod plugin Claude Code installed on this machine. When an installed copy is older, it updates them as `cmod update cmod` does. When one is still older, as when your `@cmodjs/core` needs a cmod newer than every published one, the check fails, keeps the old dependency, and names the `@cmodjs/core` to install instead. When a cmod linked from a checkout is older, the check fails the same way and says to pull that checkout, because no update reaches it. On a machine without Claude Code or without a cmod plugin, such as CI, it writes the dependency at once.
66
65
  9. Checks its imports.
67
66
  10. Looks for prebuilt binaries outside `cli/`.
68
67
  11. Builds the release in a temporary folder as `cmod publish` builds it, with its `"files"` list and its bundled hooks module, and validates the release with Claude Code, `claude plugin validate --strict`. So it fails on a path `plugin.json` names that `"files"` leaves out, a `"files"` path that matches no file in the mod, and each reason a bundle fails, and prints every line the validator writes. Then it deletes the folder.
@@ -72,15 +71,15 @@ Runs every check this machine can run on the mod at `path` (default: the current
72
71
  15. Runs, with `claude plugin test`, the test files that import `claude-code/testing`. It skips this when none does.
73
72
  16. Checks its name against other plugins. Only a project plugin, in `.claude/skills/<name>/` of a repository, runs this check: it fails when an installed or linked plugin has the same name and hides the project plugin. Any other mod passes it at once.
74
73
 
75
- `cmod check` fetches `tsc` 7.0.2 and `oxlint` 1.86.0 into the cmod store the first time. It ends with a count of passed, failed, and skipped checks, and exits 1 when one failed.
74
+ `cmod check` fetches `tsc` 7.0.2 and `oxlint` 1.86.0 into the cmod store the first time. A check it cannot run, such as one that needs Claude Code on a machine without it, fails with the reason, and the later checks still run. It ends with a count of passed, failed, and skipped checks, and exits 1 when one failed.
76
75
 
77
76
  ### cmod try
78
77
 
79
78
  ```text
80
- cmod try <owner/repo | path>... [--yes] [--option key=value]... [--home <folder>] [-- claude arguments]
79
+ cmod try <owner/repo | path>... [--option key=value]... [--home <folder>] [-- claude arguments]
81
80
  ```
82
81
 
83
- Starts one throwaway Claude Code session with mods set up, for trying a mod by hand or testing it with an agent. Installs each mod's packages, installs the cmod plugin when Claude Code lacks it, and runs each mod's install step after asking consent. Then starts one Claude Code session that loads every mod with `--plugin-dir`.
82
+ Starts one throwaway Claude Code session with mods set up, for trying a mod by hand or testing it with an agent. Installs each mod's packages, installs the cmod plugin when Claude Code lacks it, and runs each mod's install step. Then starts one Claude Code session that loads every mod with `--plugin-dir`.
84
83
 
85
84
  - `--option key=value` sets one option of the mod. With several mods, write `--option <mod>.key=value`.
86
85
  - The session runs with a new home folder, so it sees only the mods named here and changes none of your Claude Code settings, mods, key bindings, or history. The folder is deleted when the session ends.
@@ -94,7 +93,7 @@ Starts one throwaway Claude Code session with mods set up, for trying a mod by h
94
93
  - When the session ends, even when its terminal closes, it runs each mod's uninstall step and deletes its record, data folder, approval, key bindings, and program, so the mod stays uninstalled. A checkout already set up from the same folder keeps its setup.
95
94
  - A GitHub mod is cloned into a temporary folder, which is deleted too.
96
95
  - A mod another folder has set up in that home is refused, so `cmod try` never replaces an installed copy.
97
- - Arguments after `--` go to `claude`, such as `-- -p "hello"`. An agent tests a mod with one `cmod try <path> --yes -- -p "<prompt>"` run.
96
+ - Arguments after `--` go to `claude`, such as `-- -p "hello"`. An agent tests a mod with one `cmod try <path> -- -p "<prompt>"` run.
98
97
 
99
98
  ### cmod publish
100
99
 
@@ -105,11 +104,11 @@ cmod publish [path] [--dry-run]
105
104
  Releases the mod at `path` (default: the current folder) at the version in its `plugin.json`. It refuses a `plugin.json` whose `userConfig` differs from the options `defineMod` declares, and says to run `cmod check` and commit `.claude-plugin/plugin.json`.
106
105
 
107
106
  1. Builds the release from the files git does not ignore, leaving out `cli/`, `.github/`, and `.claude/`. A `"files"` list in `package.json` limits the release to the paths it lists, plus the folders of the install and uninstall steps, `.claude-plugin/`, `package.json`, `tsconfig.json`, the README, the license, and `CHANGELOG.md`, the way `npm publish` reads it. `tsconfig.json` holds the JSX settings the bundle in step 2 needs. List every folder the hooks module imports from, such as `"files": ["hooks", "src", "skills"]`, because the bundle in step 2 is built from the release.
108
- 2. Bundles the hooks module that `hooks/hooks.json` names, with the mod's source and packages, into one readable `.js` file, writes each control character in it as a `\u` escape, and points `hooks/hooks.json` at it. Anthropic's plugin directory reads a repository without installing its packages, so it can follow a mod only when all its code is in one file. Without `"approve": true` in `package.json` `"cmod".permissions`, the bundle leaves out the code that allows and asks on Claude Code's permission check ([permissions.md](permissions.md)).
107
+ 2. Bundles the hooks module that `hooks/hooks.json` names, with the mod's source and packages, into one readable `.js` file, writes each control character in it as a `\u` escape, and points `hooks/hooks.json` at it. Anthropic's plugin directory reads a repository without installing its packages, so it can follow a mod only when all its code is in one file. Without `"approve": true` in `package.json` `"cmod"`, the bundle leaves out the code that allows and asks on Claude Code's permission check, because Anthropic's plugin directory does not list a mod that can approve Claude's tool calls ([mod.md](mod.md#register-the-mod-with-claude-code)).
109
108
  3. Checks the release's `.claude-plugin/plugin.json`, and its `.claude-plugin/marketplace.json` when it has one, with `claude plugin validate --strict`, and stops with every line the validator writes when it fails. `cmod check` builds and validates the release the same way, so it fails first.
110
109
  4. Commits the release as the `release` branch, and builds the release archive from that commit.
111
110
  5. Builds the program `cli/` declares, and writes `SHA256SUMS` for every file of the release.
112
- 6. Writes `.claude-plugin/marketplace.json`, listing the archive and the cmod plugin. The cmod entry points at the `release` branch of `heyJordanParker/cmod`, so the mod's `"cmod"` dependency resolves in this marketplace and follows each cmod release with no new publish of the mod.
111
+ 6. Writes `.claude-plugin/marketplace.json`, listing the archive, the cmod plugin, and each other mod `plugin.json` depends on. The cmod entry points at the `release` branch of `heyJordanParker/cmod`, so the mod's `"cmod"` dependency resolves in this marketplace and follows each cmod release with no new publish of the mod. Each other dependency's entry points at the `release` branch of the GitHub repository of the marketplace Claude Code added on your computer that lists it ([dependencies.md](dependencies.md#call-the-methods-mod-dependencies)).
113
112
  7. Commits that file, tags `v<version>`, tags the release commit `<name>--v<version>`, which Claude Code installs a version range from when a marketplace lists the mod from its git repository, pushes both tags and the `release` branch, creates the GitHub release with every file, then pushes the branch that holds `marketplace.json`. So Claude Code never updates anyone to a release whose files are not up yet. Its notes are the version's section of the committed `CHANGELOG.md`, above GitHub's compare link ([mod.md](mod.md#release-notes)). `--dry-run` prints them.
114
113
  8. Prints the link to paste as the Repository when you submit the mod at [claude.ai/directory/manage](https://claude.ai/directory/manage), such as `https://github.com/owner/greeter/tree/release`. The portal reads the branch from the link, so the directory follows `release`.
115
114
 
@@ -120,26 +119,27 @@ It needs, and refuses to start without:
120
119
  - the mod's folder as the root of a git repository with at least one commit, because the release is committed as the `release` branch
121
120
  - a `## [<version>]` section with notes in the committed `CHANGELOG.md`
122
121
  - `node_modules` in the mod's folder, from `bun install`, when the hooks module imports a package
122
+ - each mod `plugin.json` depends on, other than cmod, listed in a GitHub marketplace Claude Code added on your computer, so install it from its marketplace first
123
123
  - a `register` declared as a function in the hooks module, as `cmod new` writes it, because the validator refuses a bundled `register` that is not one
124
124
  - the `claude` command, which validates the release
125
125
  - an `origin` remote on GitHub
126
126
  - a `package.json` with no dependency on a `file:` or `link:` path, which no user has
127
127
  - a `"files"` list, when `package.json` has one, whose every path matches a file in the mod
128
128
  - a `"program"` in the `cmod` key of `package.json` that names the program `cli/` declares, when `cli/` declares one
129
- - a `cmod` dependency in `.claude-plugin/plugin.json` of `>=` the `@cmodjs/core` the mod bundles, which `cmod check` writes
129
+ - a `cmod` dependency in `.claude-plugin/plugin.json` of `>=` the oldest cmod the `@cmodjs/core` the mod bundles runs on, which `cmod check` writes
130
130
  - for a real publish, a working tree with no uncommitted changes, no `v<version>` or `<name>--v<version>` tag yet, a `git push` to `origin` that succeeds, and the `gh` command, which creates the GitHub release
131
131
 
132
132
  `--dry-run` builds everything into a temporary folder, and pushes nothing. It writes `marketplace.json` there too, so the working tree stays as it was. It allows uncommitted changes and an existing tag, and builds from the working tree, uncommitted changes included. It prints the folder that holds the release, so you can read what the directory will read.
133
133
 
134
134
  ## Install mods
135
135
 
136
- `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.
136
+ `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>`, and more than 3 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.
137
137
 
138
138
  ### cmod install
139
139
 
140
140
  ```text
141
- cmod install <owner/repo | path> [name] [--yes] [--option key=value]...
142
- cmod install <name | name@marketplace> [--yes] [--option key=value]...
141
+ cmod install <owner/repo | path> [name] [--option key=value]...
142
+ cmod install <name | name@marketplace> [--option key=value]...
143
143
  ```
144
144
 
145
145
  Adds the plugin's marketplace to Claude Code and installs the plugin through Claude Code. A mod also gets the cmod plugin when Claude Code lacks it, and its install step runs. Any other plugin installs through Claude Code alone, and cmod keeps no record of it.
@@ -148,19 +148,16 @@ Adds the plugin's marketplace to Claude Code and installs the plugin through Cla
148
148
  - Given `name@marketplace` of a marketplace Claude Code has added, it installs that plugin.
149
149
  - Given the name of a plugin Claude Code already holds, it runs a mod's install step again.
150
150
  - A path holds a `/`, such as `./my-mod`.
151
- - `--yes` approves the mod's install and uninstall commands without asking.
152
151
  - `--option key=value` sets one of the mod's options through `claude plugin configure`, once per option, so a scripted install needs no visit to `/config`. It refuses a key the mod does not declare, and names the keys it does ([options.md](options.md)).
153
152
 
154
153
  ### cmod update
155
154
 
156
155
  ```text
157
- cmod update [name] [--yes]
156
+ cmod update [name]
158
157
  ```
159
158
 
160
159
  Updates the named plugin, or every plugin Claude Code has installed, through Claude Code, then runs the install step of each mod whose version or scripts changed. A linked plugin is skipped, because saving its files updates it. When Claude Code fails to update a plugin, `cmod update` names it, updates the rest, and exits 1. Every running session then loads the new version.
161
160
 
162
- - `--yes` approves changed install and uninstall commands without asking.
163
-
164
161
  ### cmod remove
165
162
 
166
163
  ```text
@@ -222,7 +219,7 @@ Reads every conversation Claude Code saved, as the sessions, contexts, turns, ta
222
219
  - `state` prints what a running conversation resumes from.
223
220
  - `follow` prints each message, turn, context, task, and goal change of the sessions named as Claude Code saves it, until stopped with Ctrl+C. `--running` follows every running session of the project too, and each one that starts later. The cmod plugin runs it to hear other running sessions.
224
221
  - `--json` prints JSON instead of one line each.
225
- - `index` reads every saved conversation into the index at `~/.local/share/cmod/history-11.sqlite`, which holds where each message is in its transcript, not a copy of it, and each conversation's turns, contexts, and tasks. While a mod other than cmod holds the `conversation` permission, the cmod plugin runs it in the background at each session's start, and a second run while one is running exits at once. The index forgets a conversation whose transcript is deleted.
222
+ - `index` reads every saved conversation into the index at `~/.local/share/cmod/history-11.sqlite`, which holds where each message is in its transcript, not a copy of it, and each conversation's turns, contexts, and tasks. While cmod has set up a mod other than cmod, the cmod plugin runs it in the background at each session's start, and a second run while one is running exits at once. The index forgets a conversation whose transcript is deleted.
226
223
 
227
224
  ## Run in an install script
228
225
 
@@ -246,15 +243,15 @@ Downloads a program for an install script: fetches the download for this machine
246
243
 
247
244
  ## Run by cmod
248
245
 
249
- cmod runs these itself. A person runs them to see a step's whole log, to finish a step, or to grant a permission.
246
+ cmod runs these itself. A person runs them to see a step's whole log, or to finish a step.
250
247
 
251
248
  ### cmod setup
252
249
 
253
250
  ```text
254
- cmod setup <plugin-root> [--events] [--consent <sha256>] [--yes]
251
+ cmod setup <plugin-root> [--events]
255
252
  ```
256
253
 
257
- 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.
254
+ 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, binds its hotkeys, and records the mod as set up, asking nothing first ([install-steps.md](install-steps.md#when-the-steps-run)). 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 setup says so. 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
255
 
259
256
  ### cmod teardown
260
257
 
@@ -262,15 +259,7 @@ Refuses a machine the `os` and `cpu` keys of the mod's `package.json` leave out.
262
259
  cmod teardown <plugin-name> [--events]
263
260
  ```
264
261
 
265
- Runs a removed mod's saved uninstall step, then deletes its install record, the saved step, every version of its program, its data folder, and `instances/<plugin-name>/`, where its `singleInstance` programs keep their addresses, takes out each Claude Code setting it changed that still has the value it set, and forgets the scripts and the permissions the person approved for it. It keeps the mod's config folder, `~/.claude/cmods/<plugin-name>`. A failed uninstall step keeps the record, so `cmod teardown` can run again.
266
-
267
- ### cmod permission
268
-
269
- ```text
270
- cmod permission <mod> <name> [value] on|off
271
- ```
272
-
273
- Turns one permission of a set-up mod on or off, such as `cmod permission ci-watch model off` or `cmod permission ci-watch network api.github.com on`. A toggle in Settings runs it. It refuses a permission the mod's `package.json` `cmod.permissions` does not list, and the mod sees the change before its next call, with no reload ([permissions.md](permissions.md)).
262
+ Runs a removed mod's saved uninstall step, then deletes its install record, the saved step, every version of its program, its data folder, and `instances/<plugin-name>/`, where its `singleInstance` programs keep their addresses, takes out each Claude Code setting it changed that still has the value it set, and deletes its entry in `consent.json`. It keeps the mod's config folder, `~/.claude/cmods/<plugin-name>`. A failed uninstall step keeps the record, so `cmod teardown` can run again.
274
263
 
275
264
  ### cmod hotkey
276
265
 
@@ -52,20 +52,22 @@ declare module 'claude-code' {
52
52
  A mod that calls tracer lists it in its own `.claude-plugin/plugin.json`, and Claude Code installs it with the mod:
53
53
 
54
54
  ```json
55
- "dependencies": [{ "name": "cmod", "version": ">=4.0.0" }, "tracer"]
55
+ "dependencies": [{ "name": "cmod", "version": ">=5.0.0" }, "tracer"]
56
56
  ```
57
57
 
58
+ Write the dependency bare, by its name alone. Claude Code looks for a bare dependency only in the mod's own marketplace, so `cmod publish` lists tracer there, from the `release` branch of the GitHub repository that the `"repository"` of tracer's `plugin.json` names. Install or link tracer before you publish, or `cmod publish` stops and says to. A dependency that names its `"marketplace"` loads for the people who install your mod, but not from the marketplace `cmod link` writes for your checkout.
59
+
58
60
  A provider that changes or removes a method breaks every mod that calls it, and with automatic updates the provider can update first. Name the versions you tested with a range, and Claude Code turns your mod off with a clear error instead of letting its calls fail one by one:
59
61
 
60
62
  ```json
61
- "dependencies": [{ "name": "cmod", "version": ">=4.0.0" }, { "name": "tracer", "version": "^1.0" }]
63
+ "dependencies": [{ "name": "cmod", "version": ">=5.0.0" }, { "name": "tracer", "version": "^1.0" }]
62
64
  ```
63
65
 
64
- Claude Code checks the range against the provider's `version` when it loads your mod. Where a marketplace lists the provider from its git repository, as every mod's marketplace lists cmod, Claude Code also installs it at the highest `<name>--v<version>` tag inside the range, which `cmod publish` pushes for every release ([Claude Code's plugin dependencies](https://code.claude.com/docs/en/plugins/dependencies)).
66
+ Claude Code checks the range against the provider's `version` when it loads your mod. Every mod's marketplace lists cmod and each provider from its git repository, so Claude Code also installs it at the highest `<name>--v<version>` tag inside the range, which `cmod publish` pushes for every release ([Claude Code's plugin dependencies](https://code.claude.com/docs/en/plugins/dependencies)).
65
67
 
66
- cmod is a provider too, with one difference: every newer cmod runs every mod built on an older `@cmodjs/core`. So a mod names only the oldest cmod it runs on, the version of the `@cmodjs/core` it bundles, as `>=4.0.0`. `cmod check` writes that range whenever the mod's `@cmodjs/core` changes, and `cmod publish` refuses a release whose range differs. A caret range such as `^4.0.0` stops Claude Code from updating cmod past 4.x for every mod on the computer, so leave it to `cmod check`.
68
+ cmod is a provider too, with one difference: every newer cmod runs every mod built on an older `@cmodjs/core`. So a mod names only the oldest cmod it runs on, which the `@cmodjs/core` it bundles names as `oldestCmodVersion` in its `records.js`, as `>=5.0.0`. `cmod check` writes that range whenever the mod's `@cmodjs/core` changes, and `cmod publish` refuses a release whose range differs. A caret range such as `^5.0.0` stops Claude Code from updating cmod past 5.x for every mod on the computer, so leave it to `cmod check`.
67
69
 
68
- Each mod's marketplace lists its own copy of cmod, and Claude Code loads only one of them. When a mod needs a newer cmod than a copy Claude Code installed, or two copies differ, the cmod plugin updates every copy and reloads the mods, so a mod never waits for the person to update cmod.
70
+ Each mod's marketplace lists its own copy of cmod and of each provider, and Claude Code loads only one copy of each. When a mod needs a newer cmod than a copy Claude Code installed, the cmod plugin updates every copy of cmod, and when two copies of any plugin differ, it updates every copy of that plugin. Then it reloads the mods, so a mod never waits for the person to update its providers.
69
71
 
70
72
  Claude Code then lays tracer's types file beside the mod's own types, so the call is typed:
71
73
 
package/docs/index.md CHANGED
@@ -4,13 +4,13 @@ These are the docs of the `@cmodjs/core` version installed beside them. Read the
4
4
 
5
5
  ## What a mod is
6
6
 
7
- A mod is a Claude Code plugin built with `@cmodjs/core`. Claude Mod Manager (cmod) installs mods, runs their install and uninstall steps with the person's consent, and builds and publishes new ones. The `cmod` command does that work in a terminal.
7
+ A mod is a Claude Code plugin built with `@cmodjs/core`. Claude Mod Manager (cmod) installs mods, runs their install and uninstall steps, and builds and publishes new ones. The `cmod` command does that work in a terminal.
8
8
 
9
9
  `cmod new my-mod` writes this layout:
10
10
 
11
11
  ```text
12
12
  my-mod/
13
- ├── .claude-plugin/plugin.json name, version, and "dependencies": [{ "name": "cmod", "version": ">=4.0.0" }]
13
+ ├── .claude-plugin/plugin.json name, version, and "dependencies": [{ "name": "cmod", "version": ">=5.0.0" }]
14
14
  ├── .claude/CLAUDE.md facts for coding agents, starting with these docs
15
15
  ├── .gitignore node_modules/ and .claude-plugin/types/
16
16
  ├── .oxlintrc.json leaves .claude-plugin/types/ out of the lint
@@ -24,7 +24,7 @@ my-mod/
24
24
  ├── skills/my-mod/SKILL.md a Skill the mod ships
25
25
  ├── rules/prompt-count.md a rule Claude reads
26
26
  ├── tests/mod.test.ts testMod tests, run with bun test
27
- ├── package.json depends on @cmodjs/core, and lists the permissions and hotkeys
27
+ ├── package.json depends on @cmodjs/core, and lists the hotkeys
28
28
  └── tsconfig.json extends .claude-plugin/types/tsconfig.json, with the JSX options
29
29
  ```
30
30
 
@@ -63,7 +63,6 @@ A program the mod needs lives as source in `cli/`. `cmod publish` builds it and
63
63
  | How does a mod give Claude a prompt on a schedule, like `/loop`? | [jobs.md](jobs.md#schedule) |
64
64
  | How do I keep values across prompts, sessions, and projects? | [state.md](state.md) |
65
65
  | How does a person set a token, a URL, or a setting for my mod, for themselves or their team? | [options.md](options.md) |
66
- | Which hosts, programs, and files may my mod reach, and how does the person grant them? | [permissions.md](permissions.md) |
67
66
  | How does my mod find files and keep its own keys on each one, such as on a Skill? | [mod.md](mod.md#metadata-a-file-s-own-keys) |
68
67
  | How does the person finish a setup step only they can do, such as signing in? | [install-steps.md](install-steps.md#steps-in-claude-code) |
69
68
  | How do I add my mod's own page to Settings, or change Claude Code's settings? | [ui.md](ui.md#settings-pages), [mod.md](mod.md#settings-claude-code-s-settings-files) |
@@ -85,7 +84,7 @@ A mod imports from the files below, and every other file in this package is inte
85
84
 
86
85
  | Import | Exports | Docs |
87
86
  | --- | --- | --- |
88
- | `mod.js` | `defineMod`, `ModDefinition`, `Mod`, `Subscription`, `Timer`, `Reservation`, `Permissions`, `Allowed`, `JobContext`, `Job`, `SlashCommand`, `Tool`, `Step`, `longestMs`, `messageOf` | [mod.md](mod.md), [jobs.md](jobs.md), [install-steps.md](install-steps.md#steps-in-claude-code) |
87
+ | `mod.js` | `defineMod`, `ModDefinition`, `Mod`, `Subscription`, `Timer`, `Reservation`, `JobContext`, `Job`, `SlashCommand`, `Tool`, `Step`, `longestMs`, `messageOf` | [mod.md](mod.md), [jobs.md](jobs.md), [install-steps.md](install-steps.md#steps-in-claude-code) |
89
88
  | `mod.js` | `Hotkey`, `HotkeyInit`, `Combo`, `Key` | [mod.md](mod.md#hotkeys) |
90
89
  | `mod.js` | `settings`, `SettingsFile`, `SettingsFileChange`, `SettingsFileChangeListener`, `config`, `ConfigRow`, `commands`, `CommandInfo`, `CommandRun`, `CommandRunAnswer`, `CommandRunResult`, `model`, `fs`, `Entry`, `Stat`, `FileMatch`, `FileChange`, `metadata`, `Metadata`, `process`, `http`, `clipboard`, `Imports` | [mod.md](mod.md) |
91
90
  | `mod.js` | `sessions`, `Sessions`, `Session`, `CurrentSession`, `TaskOwner`, `RecordPart`, `OnMethods`, `BeforeMethods`, `Listener`, `ListenerTime`, `ReadOptions`, `AnswerOptions`, `Refusal`, `SearchOptions`, `SessionScope`, `SessionSend`, `TaskStartArgs`, `ToolCallArgs`, `Usage`, `RateLimit`, `TaskStatus`, `Surface`, `Matcher` | [session.md](session.md) |
@@ -1,6 +1,6 @@
1
1
  # Install steps
2
2
 
3
- A mod that changes the machine, such as by adding a shell alias or downloading a program, names its install and uninstall steps in its `package.json`. The cmod program of Claude Mod Manager (cmod) runs them with the person's consent, and runs the uninstall step after the person removes the mod. The library never runs them.
3
+ A mod that changes the machine, such as by adding a shell alias or downloading a program, names its install and uninstall steps in its `package.json`. The cmod program of Claude Mod Manager (cmod) runs the install step when the person installs the mod, and the uninstall step after the person removes it. The library never runs them.
4
4
 
5
5
  ## The cmod key
6
6
 
@@ -26,34 +26,32 @@ cmod refuses a `cmod` key that breaks these rules, with the fix in the message:
26
26
 
27
27
  - `cmod` is an object.
28
28
  - `install` and `uninstall` are each one command on one line, with no tab.
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/`.
29
+ - Each names at least one script file inside the mod, and no script at the mod's root. cmod runs the steps again whenever anything in a script's folder changes, 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
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
- ## Consent
35
+ ## When the steps run
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 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.
37
+ cmod runs the install step, installs the program, and binds the hotkeys when the person installs the mod, and again when an update changes a command or a file in a script folder, adds a hotkey, or changes its default combo. It asks nothing first.
38
38
 
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
- - 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.
41
- - In a terminal, `cmod install`, `cmod link`, `cmod try`, and `cmod update` print the commands, the program, the hotkeys, and the permissions, and ask `Set up <mod>? [y/N]`. `--yes` approves without asking.
42
- - `Not now` leaves the mod off with the toast `Not installed` and an `Install` button that asks again.
39
+ - In Claude Code, the mod sets itself up as it loads, and a loading toast above the prompt shows the install with a progress bar.
40
+ - In a terminal, `cmod install`, `cmod link`, `cmod try`, and `cmod update` set the mod up and print each step.
43
41
 
44
42
  The mod starts only once its install step has run ([mod.md](mod.md)).
45
43
 
46
44
  ## Automatic updates
47
45
 
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.
46
+ 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 setup logs `<mod> now updates automatically from the <marketplace> marketplace. Turn it off in /plugin, Marketplaces.` 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
47
 
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.
48
+ 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 runs the install step again.
51
49
 
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.
50
+ 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 oldest cmod the `@cmodjs/core` the mod bundles runs on, `oldestCmodVersion` in its `records.js`. 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
51
 
54
52
  ## Steps in Claude Code
55
53
 
56
- Some setup only the person can do, such as signing in to a service. A mod lists those steps in `installer`, and its install page shows each one after the permissions and the options, once the mod has started:
54
+ Some setup only the person can do, such as signing in to a service. A mod lists those steps in `installer`, and its install page shows each one after the options, once the mod has started:
57
55
 
58
56
  ```tsx
59
57
  import { defineMod, type Step } from '../node_modules/@cmodjs/core/mod.js'
@@ -87,7 +85,7 @@ type Step<State> = {
87
85
 
88
86
  ## Hotkeys
89
87
 
90
- A plugin cannot bind a key in Claude Code: Claude Code reads key bindings only from the person's `keybindings.json`. So cmod writes each hotkey there, with consent, as the setup's last step. A hotkey runs a hidden command of the mod, `<mod>--<hotkey>`, which the mod hears as `onPress` ([mod.md](mod.md#hotkeys)):
88
+ A plugin cannot bind a key in Claude Code: Claude Code reads key bindings only from the person's `keybindings.json`. So cmod writes each hotkey there as the setup's last step. A hotkey runs a hidden command of the mod, `<mod>--<hotkey>`, which the mod hears as `onPress` ([mod.md](mod.md#hotkeys)):
91
89
 
92
90
  ```json
93
91
  { "bindings": [{ "context": "Chat", "bindings": { "shift+tab": "command:modes--cycle" } }] }
@@ -95,7 +93,7 @@ A plugin cannot bind a key in Claude Code: Claude Code reads key bindings only f
95
93
 
96
94
  - 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
95
  - 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`.
96
+ - A hotkey without a default combo binds nothing at setup. Settings lists it as unbound, and the person binds it there or with `cmod hotkey`.
99
97
  - 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)).
100
98
  - 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.
101
99
  - 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
@@ -169,7 +169,7 @@ A `command` pattern is not a glob. cmod splits it into words the way it splits a
169
169
 
170
170
  ## permissions
171
171
 
172
- A `deny` rule needs no permission. An `ask` rule takes effect only with `"approve": true` in `package.json` `"cmod".permissions` ([permissions.md](permissions.md)).
172
+ A `deny` rule works in every mod. An `ask` rule needs `"approve": true` in `package.json` `"cmod"`, because `cmod publish` leaves the code that asks out of the bundle of a mod without it ([commands.md](commands.md#cmod-publish)). `cmod check` adds the line when the mod has an `ask` rule.
173
173
 
174
174
  ```ts
175
175
  permissions<State>(rules: PermissionRules<State> | ((state: State) => PermissionRules<State>)): Job<void, State>
@@ -226,8 +226,6 @@ export const guard = defineMod({
226
226
 
227
227
  ## check
228
228
 
229
- Its command needs `"run"` with the program's name, such as `"run": ["tsc"]` ([permissions.md](permissions.md)).
230
-
231
229
  ```ts
232
230
  check<State>(options: { readonly after: Target | Target[]; readonly run: readonly string[]; readonly timeoutMs?: number }): Job<void, State>
233
231
  ```
@@ -253,8 +251,6 @@ export const lint = defineMod({
253
251
 
254
252
  ## prompt
255
253
 
256
- It needs `"prompt": true`. Without the grant it adds nothing and logs once which line to add ([permissions.md](permissions.md)).
257
-
258
254
  ```ts
259
255
  prompt<State>(options: {
260
256
  name: string
@@ -292,8 +288,6 @@ export const conventions = defineMod({
292
288
 
293
289
  ## schedule
294
290
 
295
- It needs `"prompt": true`, because each cron starts a turn ([permissions.md](permissions.md)).
296
-
297
291
  ```ts
298
292
  schedule<State>(entry: ScheduledPrompt | ((state: State) => ScheduledPrompt | undefined)): Job<void, State>
299
293
 
@@ -323,8 +317,6 @@ export const loop = defineMod({
323
317
 
324
318
  ## program
325
319
 
326
- It needs `"run"` with the program's name. Without the grant the program stops at once and names the line to add ([permissions.md](permissions.md)).
327
-
328
320
  ```ts
329
321
  program(options: { readonly command: readonly string[]; readonly environment?: Record<string, string>; readonly singleInstance?: boolean }): Job<Program>
330
322
 
@@ -337,10 +329,10 @@ type Program = {
337
329
  `program` runs a background program, such as a preview server, and hands the mod its address.
338
330
 
339
331
  - `command` is the program on `PATH` and its arguments. `environment` sets variables for it. An empty `command` throws.
340
- - 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 with no `network` permission while the program runs.
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.
341
333
  - In an interactive session the program starts with the mod. Otherwise it starts at the first `ready()`.
342
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>`.
343
- - `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 and reaches it with no `network` permission. 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. 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`.
344
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>`.
345
337
 
346
338
  ```ts
package/docs/mod.md CHANGED
@@ -23,7 +23,7 @@ type ModDefinition<State, Name, Options, Hotkeys> = {
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
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
- - `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.
26
+ - `installer` lists the steps the person finishes in Claude Code after 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
 
29
29
  ```tsx
@@ -45,11 +45,11 @@ export const greeter = defineMod({
45
45
 
46
46
  ## When setup runs
47
47
 
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.
48
+ Claude Code loads the mod at the start of each session. cmod then checks that the mod is set up, and runs its install step when it is not, with a loading toast above the prompt ([install-steps.md](install-steps.md)). An option with no default and no value is asked on the mod's install page, the `Install <name>` tab of the Sidebar. 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. 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.
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.`, and what its install step set up, 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 ([commands.md](commands.md#install-mods)). A new session and `/reload-plugins` show no toast.
51
51
 
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`.
52
+ When a step fails, 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
 
54
54
  A mod that loads while a session runs, such as after `/reload-plugins` or `/plugin install`, hears no SessionStart from Claude Code. cmod runs its `onSessionStart` and `beforeSessionStart` listeners before the next prompt instead, once, with the source `resume`.
55
55
 
@@ -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)). 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.
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.
66
66
 
67
67
  ## Rules
68
68
 
@@ -75,11 +75,11 @@ my-mod/
75
75
  └── sql.md <- front matter paths: ["**/*.sql"]
76
76
  ```
77
77
 
78
- While the mod is on and has the `prompt` permission, cmod links the folder into Claude Code's rules folder: a mod the person installed links at `<config>/rules/<mod>`, and a mod turned on for one project at `<project>/.claude/rules/<mod>`. A mod turned off for one project keeps its rules out of that project through `claudeMdExcludes` in the project's `.claude/settings.local.json`. A rule the person excluded with `claudeMdExcludes` stays out of the notes too. Turning the mod off, turning `prompt` off, and removing the mod remove the link, and an update links the new version's folder. cmod changes only the links and exclusions it made.
78
+ While the mod is on, cmod links the folder into Claude Code's rules folder: a mod the person installed links at `<config>/rules/<mod>`, and a mod turned on for one project at `<project>/.claude/rules/<mod>`. A mod turned off for one project keeps its rules out of that project through `claudeMdExcludes` in the project's `.claude/settings.local.json`. A rule the person excluded with `claudeMdExcludes` stays out of the notes too. Turning the mod off and removing the mod remove the link, and an update links the new version's folder. cmod changes only the links and exclusions it made.
79
79
 
80
80
  Claude Code reads rules without `paths` only as a session starts. So when cmod links a mod's rules into a running session, it adds them to the conversation as one note, and when it removes the link, one note says the mod's rules no longer apply. A rule taken out of the folder is withdrawn by a note too. When an update changes a rule without `paths`, one note gives its new text. Claude Code loads rules with `paths` itself, at the read that matches.
81
81
 
82
- The `Installed` toast lists the rules, as in `Adds 2 rules: sql and tests.` `cmod check` fails a mod with a `rules/` folder whose `package.json` `"cmod"` does not ask for `"prompt": true`.
82
+ The `Installed` toast lists the rules, as in `Adds 2 rules: sql and tests.`
83
83
 
84
84
  ## Release notes
85
85
 
@@ -135,7 +135,7 @@ export function register(addHook: On, options: PluginOptions): void {
135
135
  }
136
136
  ```
137
137
 
138
- A mod that allows or asks, with a `before` method or an `ask` rule of the `permissions` job, also declares `"approve": true` in its `package.json` `"cmod".permissions`, so the person grants it at install. `cmod check` adds the line when it is missing, and without the grant cmod drops every allow or ask the mod answers, so Claude Code decides those calls itself. A mod that only refuses needs no `approve`, and its bundle holds no code that allows, so Anthropic's plugin directory can list it ([permissions.md](permissions.md)). A mod without `registerPermissionCheck` has no part in Claude Code's permission check, so the plugin directory reads it as one that never answers a permission. Without it, each of those methods and `mod.use(permissions(…))` throws `<mod>: <method> hears Claude Code's permission check, so hooks/register.ts must call registerPermissionCheck(addHook) after registerMod.` where it is called, so a mod that calls one in `setup` does not start. `cmod check` fails a mod whose `src/` uses one while `register.ts` does not call `registerPermissionCheck`.
138
+ A mod that allows or asks, with a `before` method or an `ask` rule of the `permissions` job, also declares `"approve": true` in its `package.json` `"cmod"`. `cmod check` adds the line when it is missing. Anthropic's plugin directory does not list a mod that can approve Claude's tool calls, so `cmod publish` leaves the code that allows and asks out of the bundle of a mod without `"approve": true`, and Claude Code decides those calls itself. A mod that only refuses needs no `approve`, and its bundle holds no code that allows, so the plugin directory can list it. A mod without `registerPermissionCheck` has no part in Claude Code's permission check, so the plugin directory reads it as one that never answers a permission. Without it, each of those methods and `mod.use(permissions(…))` throws `<mod>: <method> hears Claude Code's permission check, so hooks/register.ts must call registerPermissionCheck(addHook) after registerMod.` where it is called, so a mod that calls one in `setup` does not start. `cmod check` fails a mod whose `src/` uses one while `register.ts` does not call `registerPermissionCheck`.
139
139
 
140
140
  Where an organization manages Claude Code, Claude Code passes a mod the person installed over on its classic hooks, the notes it adds to a prompt, its Skill and instruction-file text, and compactions, and runs those only for a plugin the organization lists in managed settings. There, the `on` and `before` methods built on them hear nothing until the organization lists the mod and the cmod plugin. `claude plugin validate` names each such hook.
141
141
 
@@ -143,7 +143,7 @@ Keep `register.ts` this small. Claude Code checks a hooks module before it loads
143
143
 
144
144
  ## mod: this mod
145
145
 
146
- `setup` gets `mod`, of type `Mod<State, Options, Hotkeys>`. Every listener, render, and job gets the same `mod`. `mod` holds what belongs to this mod: its name, its folders, its values, its grants, its hotkeys, and what it adds to Claude Code.
146
+ `setup` gets `mod`, of type `Mod<State, Options, Hotkeys>`. Every listener, render, and job gets the same `mod`. `mod` holds what belongs to this mod: its name, its folders, its values, its hotkeys, and what it adds to Claude Code.
147
147
 
148
148
  ```ts
149
149
  type Mod<State, Options, Hotkeys> = {
@@ -152,7 +152,6 @@ type Mod<State, Options, Hotkeys> = {
152
152
  readonly dataFolder: string
153
153
  readonly state: Readonly<State>
154
154
  readonly options: OptionValues<Options>
155
- readonly permissions: Permissions
156
155
  readonly hotkeys: { readonly [name in keyof Hotkeys]: Hotkey }
157
156
  every(ms, listener): Timer
158
157
  after(ms, listener): Timer
@@ -174,7 +173,6 @@ type Mod<State, Options, Hotkeys> = {
174
173
  - `dataFolder` is the mod's own folder in the cmod store: `$XDG_DATA_HOME/cmod/data/<plugin name>`, or `~/.local/share/cmod/data/<plugin name>` when `XDG_DATA_HOME` is not set. The install step gets the same folder as `CMOD_DATA`. cmod deletes it when the mod is removed ([install-steps.md](install-steps.md)).
175
174
  - `state` holds the mod's values. Assign to a key to change it ([state.md](state.md)).
176
175
  - `options` holds the values a person set for the mod's options, typed from their declaration. Read-only ([options.md](options.md)).
177
- - `permissions` says whether the person granted each permission ([permissions.md](permissions.md)).
178
176
  - `hotkeys` holds each hotkey `defineMod` declared ([Hotkeys](#hotkeys)).
179
177
  - `every` and `after` run a listener on a timer while the session runs.
180
178
  - `use` adds a job, such as a slash command or a tool, and returns its handle ([jobs.md](jobs.md)).
@@ -199,7 +197,7 @@ import { clipboard, commands, config, fs, http, metadata, model, process, sessio
199
197
  - `http` fetches a URL.
200
198
  - `clipboard` puts text on the person's clipboard ([ui.md](ui.md#toasts)).
201
199
 
202
- Each import works once the mod has started, in `setup` and anything it adds. Each one checks the permission it needs, and rejects with the line to add or the grant to turn on when the person has not granted it ([permissions.md](permissions.md)).
200
+ Each import works once the mod has started, in `setup` and anything it adds.
203
201
 
204
202
  ### Take back what the mod added
205
203
 
@@ -293,8 +291,8 @@ type CommandRun = { name: string; args: string; source?: 'builtin' | 'plugin' |
293
291
  ```
294
292
 
295
293
  - `list` answers every command the person can type: Claude Code's own, each plugin's, the person's and the project's, and each MCP server's prompts.
296
- - `run` runs a command, a built-in such as `compact` included, the way the person typing `/<name> <args>` would. It resolves the text the command printed and the note it left Claude. It needs the `prompt` permission.
297
- - `beforeRun` runs just before any command runs, typed or run by a mod, and its answer changes it: `{ args?, note? }` runs it with new arguments and adds a note Claude reads after its output, `{ result, exitCode? }` answers in its place without running it, and `{ refuse }` runs nothing and shows the reason as its output. An answer needs the `prompt` permission. `exitCode` is what a `claude -p "/lint"` run exits with.
294
+ - `run` runs a command, a built-in such as `compact` included, the way the person typing `/<name> <args>` would. It resolves the text the command printed and the note it left Claude.
295
+ - `beforeRun` runs just before any command runs, typed or run by a mod, and its answer changes it: `{ args?, note? }` runs it with new arguments and adds a note Claude reads after its output, `{ result, exitCode? }` answers in its place without running it, and `{ refuse }` runs nothing and shows the reason as its output. `exitCode` is what a `claude -p "/lint"` run exits with.
298
296
  - `onRun` hears each command once it ran.
299
297
  - A command a project or a plugin writes as a Markdown prompt, such as `/review`, also reaches `beforePrompt` after `beforeRun`, as its text goes to Claude ([session.md](session.md#change-what-happens)). A built-in such as `/model` reaches only these two.
300
298
 
@@ -323,9 +321,8 @@ settings.beforeFileChange(matcher?, listener: (change: SettingsFileChange) => {
323
321
  - `update` merges `values` into that file as a JSON Merge Patch ([RFC 7396](https://www.rfc-editor.org/rfc/rfc7396)). `mcpServers` in `settings.project` goes to the project's `.mcp.json`, where Claude Code reads a project's servers.
324
322
  - An object merges into the object already at that key, at every depth, so every key it does not name stays as it was. `null` removes the key at its depth. An array or any other value replaces the value. To replace a whole object, read it and set each key you drop to `null`.
325
323
  - The file's comments and formatting stay as they were.
326
- - Each value needs a `config` permission for its key path or a path above it ([permissions.md](permissions.md)): `"config": ["env.ANTHROPIC_BASE_URL"]` covers that one value, and `"config": ["env"]` covers every key in `env`. `update` rejects with the line to add for a value no grant covers, and changes nothing.
327
324
  - Removing the mod takes out each value it set that still equals what it set, then each object that leaves empty. A value the person changed since stays.
328
- - `fs.write` to a Claude Code settings file rejects and names `update`, because a whole-file write loses the person's own edits and leaves the mod's values behind when it is removed.
325
+ - Change a Claude Code settings file with `update`, never `fs.write`, because a whole-file write loses the person's own edits and leaves the mod's values behind when it is removed.
329
326
 
330
327
  A mod that points Claude Code at its local proxy sets one variable in `env`, and the person's other variables stay:
331
328
 
@@ -357,7 +354,7 @@ type ConfigRow = { key: string; label: string; description?: string; kind: 'bool
357
354
  model.complete(request: ModelCompleteRequest, options?: { signal?: AbortSignal }): Promise<ModelCompleteResult>
358
355
  ```
359
356
 
360
- `complete` asks a model one question through Claude Code's own login, outside the conversation, so the answer costs no context and the person sees no turn. The request names the `model`, such as `'haiku'`, and the `prompt`, and takes `system`, `maxTokens`, `effort`, and `timeoutMs`. `timeoutMs` stops a model that is slow or down, so the listener that waits on it still answers in time. `options.signal` stops the call when its `AbortController` aborts. It needs the `model` permission.
357
+ `complete` asks a model one question through Claude Code's own login, outside the conversation, so the answer costs no context and the person sees no turn. The request names the `model`, such as `'haiku'`, and the `prompt`, and takes `system`, `maxTokens`, `effort`, and `timeoutMs`. `timeoutMs` stops a model that is slow or down, so the listener that waits on it still answers in time. `options.signal` stops the call when its `AbortController` aborts.
361
358
 
362
359
  The call never rejects for what the model did. The result's `isAnswered` is true with the reply's `text`, or false with a `reason`, such as `'api-error'` or `'aborted'`.
363
360
 
@@ -377,7 +374,7 @@ process.run(argv: readonly string[], init?: ProcessRunInit): Promise<ProcessRunR
377
374
  process.spawn(argv: readonly string[], init?: { cwd?, env?, input? }): HookStream<ProcessSpawnChunk, ProcessSpawnResult>
378
375
  ```
379
376
 
380
- Both run a program without a shell. `argv[0]` is the program and the rest are its arguments. A bare name that cmod installed, such as `trace`, runs from cmod's programs folder ([install-steps.md](install-steps.md#run-a-program-by-its-name)), and any other name runs through Claude Code's `PATH`. Each program needs its `run` permission.
377
+ Both run a program without a shell. `argv[0]` is the program and the rest are its arguments. A bare name that cmod installed, such as `trace`, runs from cmod's programs folder ([install-steps.md](install-steps.md#run-a-program-by-its-name)), and any other name runs through Claude Code's `PATH`.
381
378
 
382
379
  - `init.cwd` is the program's folder, absolute or relative to the session's working folder. Without it the program runs in the session's working folder.
383
380
  - `init.env` sets variables over Claude Code's own environment.
@@ -425,7 +422,7 @@ type Stat = { isFile: boolean; isFolder: boolean; isLink: boolean; size: number;
425
422
 
426
423
  - A relative path is under the session's working folder. An absolute path is used as given. `~/.claude` and `$CLAUDE_CONFIG_DIR` are Claude Code's config folder, and `~` and `$HOME` are the home folder. Text is UTF-8.
427
424
  - `read` rejects a missing file and a file over 4 MiB.
428
- - `write` writes the whole file and creates its folders. Writing outside the project and the mod's data folder needs the `files` permission.
425
+ - `write` writes the whole file and creates its folders.
429
426
  - `list` lists a folder, the working folder without a path. A symbolic link is neither a file nor a folder, with `isLink` true. `modifiedAt` is the time it last changed, in milliseconds since 1970.
430
427
  - `exists` answers whether the path leads to a file or a folder.
431
428
  - `stat` answers what the path leads to, following a symbolic link, and rejects a missing path. With `{ resolve: true }` it also answers `realPath`: the absolute path, every symbolic link followed.
@@ -485,7 +482,7 @@ metadata:
485
482
  - A `.sh`, `.py`, `.ts`, `.js`, `.yaml`, or `.toml` file keeps it in a `/// metadata` comment block after any shebang, in the file's own comment, `#` or `//`, the way PEP 723 keeps a Python script's dependencies.
486
483
  - Any other file keeps it in a sidecar, `<file>.meta`.
487
484
 
488
- `update` hands `change` the mod's current keys, and writes what `change` leaves. It changes only the metadata block, keeps other mods' keys, writes nothing when nothing changed, and removes an empty block. It writes through a symbolic link to the file it points at. Writing a file outside the project and the mod's data folder needs the `files` permission, as `fs.write` does ([permissions.md](permissions.md)). A key is letters, digits, `_`, `.`, and `-`, and `update` rejects any other key and a value with a line break.
485
+ `update` hands `change` the mod's current keys, and writes what `change` leaves. It changes only the metadata block, keeps other mods' keys, writes nothing when nothing changed, and removes an empty block. It writes through a symbolic link to the file it points at. A key is letters, digits, `_`, `.`, and `-`, and `update` rejects any other key and a value with a line break.
489
486
 
490
487
  `read` rejects when cmod cannot open the file or read its metadata, with the reason or the line. `update` rejects the same way and writes nothing, so it never overwrites metadata it could not read.
491
488
 
@@ -505,7 +502,7 @@ http.fetch(url: string, init?: HttpInit): Promise<HttpResponse>
505
502
 
506
503
  - `init` takes `method` (`GET` by default), `headers`, `body` as text, and `socketPath`, the absolute path of a Unix socket the request goes over.
507
504
  - The response is `{ status, ok, headers, text }`. `ok` is true for a 2xx status. Header names are lower case.
508
- - Each host needs its `network` permission. A fetch to the address the mod's own `program` job answers on needs none, while that program runs ([jobs.md](jobs.md#program)).
505
+ - A mod reaches the address its own `program` job answers on the same way ([jobs.md](jobs.md#program)).
509
506
 
510
507
  ## messageOf
511
508