@cmodjs/core 5.13.4 → 6.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/docs/commands.md +11 -11
- package/docs/dependencies.md +32 -57
- package/docs/index.md +7 -5
- package/docs/install-steps.md +3 -3
- package/docs/jobs.md +18 -18
- package/docs/mod.md +36 -35
- package/docs/options.md +3 -3
- package/docs/session.md +1 -1
- package/docs/state.md +4 -4
- package/docs/testing.md +21 -21
- package/docs/ui.md +37 -26
- package/installer.d.ts +1 -2
- package/installer.d.ts.map +1 -1
- package/mod.d.ts +13 -7
- package/mod.d.ts.map +1 -1
- package/mod.js +3 -3
- package/package.json +1 -1
- package/records.d.ts +10 -2
- package/records.d.ts.map +1 -1
- package/records.js +13 -2
- package/register.d.ts +5 -3
- package/register.d.ts.map +1 -1
- package/register.js +4 -0
- package/runtime/claude.d.ts +4 -0
- package/runtime/claude.d.ts.map +1 -1
- package/runtime/lifecycle.d.ts.map +1 -1
- package/runtime/lifecycle.js +8 -3
- package/runtime/toaster.d.ts +1 -1
- package/runtime/toaster.d.ts.map +1 -1
- package/runtime/toaster.js +4 -4
- package/runtime/ui.d.ts +2 -1
- package/runtime/ui.d.ts.map +1 -1
- package/runtime/ui.js +14 -1
- package/runtime/web.js +3 -0
- package/src/installer.ts +1 -2
- package/src/mod.ts +21 -10
- package/src/records.ts +12 -2
- package/src/register.ts +11 -3
- package/src/runtime/claude.ts +4 -0
- package/src/runtime/lifecycle.ts +12 -3
- package/src/runtime/toaster.ts +4 -4
- package/src/runtime/ui.ts +14 -2
- package/src/runtime/web.ts +2 -0
- package/src/testing/fake-claude.ts +4 -0
- package/src/testing.ts +11 -5
- package/src/ui/areas.ts +1 -2
- package/src/ui/components.ts +10 -11
- package/src/ui/elements.ts +51 -3
- package/src/ui/panes.ts +9 -5
- package/src/ui/styles.ts +3 -3
- package/testing/fake-claude.d.ts.map +1 -1
- package/testing/fake-claude.js +4 -0
- package/testing.d.ts +2 -2
- package/testing.d.ts.map +1 -1
- package/testing.js +10 -4
- package/ui/areas.d.ts +1 -2
- package/ui/areas.d.ts.map +1 -1
- package/ui/components.d.ts +15 -16
- package/ui/components.d.ts.map +1 -1
- package/ui/elements.d.ts +32 -13
- package/ui/elements.d.ts.map +1 -1
- package/ui/elements.js +15 -1
- package/ui/panes.d.ts +7 -5
- package/ui/panes.d.ts.map +1 -1
- package/ui/styles.d.ts +3 -3
- package/ui/styles.d.ts.map +1 -1
package/docs/commands.md
CHANGED
|
@@ -36,7 +36,7 @@ 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. Once a change builds, `cmod watch` tells every session, and each one still running the old build offers Reload, 35 seconds after the last change and between turns. To test your edits without pressing Reload, start the session with `claude --plugin-dir <checkout>`: Claude Code then reloads the checkout by itself between turns, in that session only, and that session offers nothing for it.
|
|
38
38
|
|
|
39
|
-
- `--option key=value` sets one of the mod's options through `claude plugin configure`, once per option, under the linked id,
|
|
39
|
+
- `--option key=value` sets one of the mod's options through `claude plugin configure`, once per option, under the linked id, `<mod>@<parent folder>-linked`. It refuses a key the mod does not declare, and names the keys it does ([options.md](options.md)).
|
|
40
40
|
|
|
41
41
|
### cmod unlink
|
|
42
42
|
|
|
@@ -62,7 +62,7 @@ Runs every check this machine can run on the mod at `path` (default: the current
|
|
|
62
62
|
6. Reads the metadata of every file in the mod, and names each file whose metadata cmod cannot read.
|
|
63
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.
|
|
64
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.2.0`, so every newer cmod runs the mod. When the mod needs a newer cmod than that, such as one whose cmod plugin carries out a call the mod makes, write that minimum yourself as `>=` its version, such as `>=5.6.0`, and `cmod check` keeps it. It raises only a minimum below that oldest cmod, and writes any other range as `>=` that oldest cmod. 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.
|
|
65
|
-
9. Checks its imports.
|
|
65
|
+
9. Checks its imports. It fails a file that imports the `claude-code` module, because every type a mod writes comes from `@cmodjs/core` ([index.md](index.md#what-a-mod-is)). A provider's types file adds to that module with `declare module 'claude-code'`, which imports nothing, so the check keeps it.
|
|
66
66
|
10. Looks for prebuilt binaries outside `cli/`.
|
|
67
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.
|
|
68
68
|
12. Compiles it against Claude Code's API with `tsc`, with `tsconfig.json`, and then with `tests/tsconfig.json` when it exists. `cmod new` writes both: the root config leaves Bun out of `src/`, which runs inside Claude Code, and the tests config adds `bun-types`, so a test can run a real program with `Bun.spawn` or read files with `node:fs`. When `.claude-plugin/types/` is missing, as in a fresh clone or in CI, Claude Code writes it first: cmod loads the mod in one `claude -p` run with a config folder of its own and no model to reach, so the run sends nothing.
|
|
@@ -120,7 +120,7 @@ Releases the mod at `path` (default: the current folder) at the version in its `
|
|
|
120
120
|
5. Builds the program `cli/` declares, and writes `SHA256SUMS` for every file of the release.
|
|
121
121
|
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)).
|
|
122
122
|
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.
|
|
123
|
-
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/
|
|
123
|
+
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/my-mod/tree/release`. The portal reads the branch from the link, so the directory follows `release`.
|
|
124
124
|
|
|
125
125
|
The release keeps `package.json`, so Claude Code still installs the mod's packages for its install and uninstall steps. It keeps `bun.lock` too, unless a `"files"` list leaves it out. `main` keeps the source only.
|
|
126
126
|
|
|
@@ -143,7 +143,7 @@ It needs, and refuses to start without:
|
|
|
143
143
|
|
|
144
144
|
## Install mods
|
|
145
145
|
|
|
146
|
-
`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`, and reads the `enabledPlugins` of the user's `settings.json` each time Claude Code reports that file changed and at each prompt, whether a `cmod` command, `/plugin`, `claude plugin`, or Claude Code's automatic update changed them. While `plugins-changed`, `installed_plugins.json`, or `enabledPlugins` differs from what the session loaded, the session keeps running the plugins it loaded and shows one `Plugins changed` toast with a Reload button. It names each change, such as `
|
|
146
|
+
`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`, and reads the `enabledPlugins` of the user's `settings.json` each time Claude Code reports that file changed and at each prompt, whether a `cmod` command, `/plugin`, `claude plugin`, or Claude Code's automatic update changed them. While `plugins-changed`, `installed_plugins.json`, or `enabledPlugins` differs from what the session loaded, the session keeps running the plugins it loaded and shows one `Plugins changed` toast with a Reload button. It names each change, such as `my-mod updated to 1.3.0` or `my-mod turned on`, or counts them past 3, and each further change updates the same toast. The person presses Reload, which runs `/reload-plugins`, or when the turn ends if Claude is working, and the prompt the person is typing stays. A change back to what the session loaded, or the person's own `/reload-plugins`, takes the toast away. A session no app shows, such as `claude -p`, shows nothing. 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.
|
|
147
147
|
|
|
148
148
|
### cmod install
|
|
149
149
|
|
|
@@ -191,7 +191,7 @@ Turns the plugin on or off through Claude Code, as `/plugin` does, and every run
|
|
|
191
191
|
cmod list [--json]
|
|
192
192
|
```
|
|
193
193
|
|
|
194
|
-
Lists every plugin Claude Code has installed or linked, with its version. A mod shows whether cmod set it up, and any other plugin shows whether Claude Code enabled it. A plugin Claude Code turned off shows Claude Code's reason, such as `Requires "cmod@market" >=4.2.0, installed 4.0.0`. It also lists every mod Claude Code removed whose uninstall step has not run yet. A mod that runs a program as a service of this computer, for a `program` job with `isService` ([jobs.md](jobs.md#program)), names it, as in `ready, runs
|
|
194
|
+
Lists every plugin Claude Code has installed or linked, with its version. A mod shows whether cmod set it up, and any other plugin shows whether Claude Code enabled it. A plugin Claude Code turned off shows Claude Code's reason, such as `Requires "cmod@market" >=4.2.0, installed 4.0.0`. It also lists every mod Claude Code removed whose uninstall step has not run yet. A mod that runs a program as a service of this computer, for a `program` job with `isService` ([jobs.md](jobs.md#program)), names it, as in `ready, runs <program> as a service of this computer`.
|
|
195
195
|
|
|
196
196
|
- `--json` prints the list as JSON: one object per row with its `name`, `version`, `state`, and `unsatisfied`, the dependencies Claude Code turned the plugin off for because they are older than the plugin needs. A plugin whose folder exists also has `folder`, the folder it runs from: the checkout for a linked mod, and Claude Code's copy for any other. A mod also has `dataFolder`, and the two are the folders its `mod.folder` and `mod.dataFolder` name. A mod that runs programs as services of this computer also has `services`, their names. A removed mod has only `dataFolder`, because its data stays until `cmod teardown` deletes it.
|
|
197
197
|
|
|
@@ -237,7 +237,7 @@ Reads every conversation Claude Code saved, as the sessions, contexts, turns, ta
|
|
|
237
237
|
cmod web
|
|
238
238
|
```
|
|
239
239
|
|
|
240
|
-
Opens the browser app at `http://127.0.0.1:<port>/` and prints that address. The browser app lists every Claude Code session that runs on the computer, in every project, in four groups: Needs you (a permission prompt, a question, or a turn that failed or was stopped), Replied (an answer the person has not opened), Working, and Idle. A session opens its conversation with a prompt box under it, which sends the text as the person's own prompt in that session, a Stop button while it works, and a tab for each Sidebar page its cmod plugin draws, where a press, a text, or a pick runs the mod's handler in that session. `j` and `k` move between sessions, `Enter` opens one and puts the cursor in its prompt box, `Esc` returns to the list, `e` marks a reply done, and `u` marks it unread. A permission prompt or a question is answered in the session's terminal. The browser app runs while `Show the Sidebar in your browser` is on in Settings, under cmod, Preferences, which `open in browser` on the Sidebar's key bar turns on and runs this command. When it does not run, `cmod web` exits 1 and says so.
|
|
240
|
+
Opens the browser app at `http://127.0.0.1:<port>/` and prints that address. The browser app lists every Claude Code session that runs on the computer, in every project, in four groups: Needs you (a permission prompt, a question, or a turn that failed or was stopped), Replied (an answer the person has not opened), Working, and Idle. A session opens its conversation with a prompt box under it, which sends the text as the person's own prompt in that session, a Stop button while it works, and a tab for each Sidebar page its cmod plugin draws, where a press, a text, or a pick runs the mod's handler in that session. `j` and `k` move between sessions, `Enter` opens one and puts the cursor in its prompt box, `Esc` returns to the list, `e` marks a reply done, and `u` marks it unread. A permission prompt or a question is answered in the session's terminal. The browser app runs while `Show the Sidebar in your browser` is on in Settings, under cmod, Preferences, which `open in browser` on the Sidebar's key bar turns on and runs this command. When it does not run, `cmod web` exits 1 and says so. It opens the address by the rule a `Button` with `href` follows ([ui.md](ui.md#a-button-opens-a-web-page-with-href)): with the program `BROWSER` names, else `open` on macOS and `xdg-open` on Linux. Over ssh, on Linux with no display, or with `BROWSER` set to `true`, it opens nothing, prints the address, and exits 1 with `this computer has no browser to open, so open the address above yourself.` When the opener fails, it exits 1 after it printed the address.
|
|
241
241
|
|
|
242
242
|
## Run in an install script
|
|
243
243
|
|
|
@@ -272,7 +272,7 @@ cmod options <mod> [--project <folder>]... [--json]
|
|
|
272
272
|
Prints a mod's option values in two levels. `person` holds the values the person set in `/config`. `projects` holds the values each project's committed `.claude/cmods/<mod>/options.json` sets, keyed by the project's git root as `git rev-parse --show-toplevel` prints it, or by the project's own folder outside git. With no `--project`, it reads every project cmod's conversation index holds a session of, and lists only those whose `options.json` exists. It leaves out secrets, and the entries a session would ignore, and names each of those on stderr. A session uses a project's value over the person's, and a value the person's organization locks over both, which this command cannot read outside Claude Code. `--json` prints `{ person, projects }`:
|
|
273
273
|
|
|
274
274
|
```json
|
|
275
|
-
{ "person": { "
|
|
275
|
+
{ "person": { "<option>": "<value>" }, "projects": { "<project>": { "<option>": "<value>" } } }
|
|
276
276
|
```
|
|
277
277
|
|
|
278
278
|
### cmod device
|
|
@@ -309,7 +309,7 @@ Runs a removed mod's saved uninstall step, then deletes its install record, the
|
|
|
309
309
|
cmod hotkey <mod | plugin-root> <hotkey> <combo>
|
|
310
310
|
```
|
|
311
311
|
|
|
312
|
-
Binds one hotkey of a mod to a new combo in Claude Code's `keybindings.json`, such as `cmod hotkey
|
|
312
|
+
Binds one hotkey of a mod to a new combo in Claude Code's `keybindings.json`, such as `cmod hotkey my-mod toggle ctrl+shift+n`, and removes the combo it had. It binds a hotkey without a default combo the same way. A plugin root holds a `/`, such as `./my-mod`, so a mod Claude Code loads with `--plugin-dir`, which has no install record, binds its hotkeys too. A combo in Settings, under the mod, Hotkeys, runs it, and so does the cmod plugin for its own two hotkeys at its first start, with its own plugin folder. It refuses a combo that is not one, and a combo the person already bound to something else, with `<combo> already runs something else in ~/.claude/keybindings.json. Pick another combo.` The mod's next update keeps the combo ([mod.md](mod.md#hotkeys)).
|
|
313
313
|
|
|
314
314
|
### cmod secret
|
|
315
315
|
|
|
@@ -319,7 +319,7 @@ cmod secret get <mod> <key>
|
|
|
319
319
|
cmod secret delete <mod> <key>
|
|
320
320
|
```
|
|
321
321
|
|
|
322
|
-
Keeps a mod's secrets, for `mod.secrets` and the mod's own programs ([mod.md](mod.md#mod-secrets)). `store` reads the value from stdin, such as `printf '%s' "$TOKEN" | cmod secret store
|
|
322
|
+
Keeps a mod's secrets, for `mod.secrets` and the mod's own programs ([mod.md](mod.md#mod-secrets)). `store` reads the value from stdin, such as `printf '%s' "$TOKEN" | cmod secret store my-mod token`, and refuses a terminal, where the value would show, and an empty value. `get` prints the value to stdout as it was stored, with no newline added, and prints nothing for a secret the mod does not have. `delete` removes one secret. A value never goes in the arguments, where every process on the computer can read it.
|
|
323
323
|
|
|
324
324
|
Every mod's secrets live in `secrets.json` in the cmod store, mode 600, as `{ "<mod>": { "<key>": "<value>" } }`. On macOS each value is sealed as Chromium's `os_crypt` seals Chrome's and VS Code's: one random 32-byte key for cmod lives in the login keychain at `~/Library/Keychains/login.keychain-db`, as the generic password `cmod Safe Storage` with account `cmod`, and each value is `v10`, a fresh 12-byte nonce, the AES-256-GCM ciphertext, and its 16-byte tag, in base64. cmod makes the key once through `/usr/bin/security -i`, with the key hex-encoded on stdin, and reads it with `security find-generic-password -w`, so `security` is the one program the item trusts, and an update of cmod asks nothing. Only the key crosses `security`, so a secret has no size limit. A home with no login keychain keeps nothing, because `security` writes to the default keychain when the one it names does not exist. On Linux the values are plain, as Claude Code keeps its own login in `~/.claude/.credentials.json`. `cmod teardown` deletes the secrets of a removed mod, and the key stays for the other mods.
|
|
325
325
|
|
|
@@ -329,7 +329,7 @@ Every mod's secrets live in `secrets.json` in the cmod store, mode 600, as `{ "<
|
|
|
329
329
|
cmod settings <mod> <user|project|local> <json> [--project <folder>]
|
|
330
330
|
```
|
|
331
331
|
|
|
332
|
-
Changes Claude Code settings for a set-up mod, as its `settings.user.update`, `settings.project.update`, and `settings.local.update` do ([mod.md](mod.md#settings-claude-code-s-settings-files)), such as `cmod settings
|
|
332
|
+
Changes Claude Code settings for a set-up mod, as its `settings.user.update`, `settings.project.update`, and `settings.local.update` do ([mod.md](mod.md#settings-claude-code-s-settings-files)), such as `cmod settings my-mod user '{"env":{"EDITOR":"vim"}}'`. It merges the JSON object into the user, project, or local settings as a JSON Merge Patch: an object merges into the object already there, `null` removes the key, and an array or any other value replaces it. The project and local settings are those of `--project`, the current folder when it is left out, and `mcpServers` in the project settings goes to `.mcp.json`. Each value needs the mod's `config` permission for its key path or a path above it. cmod keeps every other key and the file's formatting, and `cmod teardown` takes out each value the mod set that is still the same, then each object that leaves empty.
|
|
333
333
|
|
|
334
334
|
### cmod rules
|
|
335
335
|
|
|
@@ -373,4 +373,4 @@ Serves the browser app that [`cmod web`](#cmod-web) opens, on 127.0.0.1 only. Th
|
|
|
373
373
|
cmod option <name> <key> <value>
|
|
374
374
|
```
|
|
375
375
|
|
|
376
|
-
Sets one option of an installed plugin through `claude plugin configure`, the way `/config` sets it, such as `cmod option
|
|
376
|
+
Sets one option of an installed plugin through `claude plugin configure`, the way `/config` sets it, such as `cmod option my-mod branch main`. A list option takes its items separated by commas. It refuses a key the plugin's `plugin.json` `userConfig` does not declare. A field in Settings and the option questions a mod asks at its first start run it, and the mod reads the new value at its next start ([options.md](options.md)).
|
package/docs/dependencies.md
CHANGED
|
@@ -9,15 +9,11 @@ What `setup` returns is the mod's API: an object whose every value is a method.
|
|
|
9
9
|
```ts
|
|
10
10
|
import { defineMod, fs } from '../node_modules/@cmodjs/core/mod.js'
|
|
11
11
|
|
|
12
|
-
export const
|
|
13
|
-
name: '
|
|
12
|
+
export const provider = defineMod({
|
|
13
|
+
name: 'provider',
|
|
14
14
|
setup() {
|
|
15
15
|
return {
|
|
16
|
-
|
|
17
|
-
(await fs.read(path)).split('\n').flatMap((text, index) => {
|
|
18
|
-
const name = /^export function (\w+)/.exec(text)?.[1]
|
|
19
|
-
return name === undefined ? [] : [{ name, line: index + 1 }]
|
|
20
|
-
}),
|
|
16
|
+
lines: async ({ path }: { path: string }) => (await fs.read(path)).split('\n').length,
|
|
21
17
|
}
|
|
22
18
|
},
|
|
23
19
|
})
|
|
@@ -30,15 +26,13 @@ A call that reaches the mod while it is still starting waits for `setup` to retu
|
|
|
30
26
|
The provider types the methods its `setup` returns in `types/index.d.ts`, and its `.claude-plugin/plugin.json` names that file as `"types": "./types/index.d.ts"`. The file adds the mod to `CmodDependencies`, which the Claude Mod Manager (cmod) plugin declares on the `claude-code` module:
|
|
31
27
|
|
|
32
28
|
```ts
|
|
33
|
-
export type
|
|
34
|
-
|
|
35
|
-
export type Tracer = {
|
|
36
|
-
signatures(input: { path: string }): Promise<TracerSignature[]>
|
|
29
|
+
export type Provider = {
|
|
30
|
+
lines(input: { path: string }): Promise<number>
|
|
37
31
|
}
|
|
38
32
|
|
|
39
33
|
declare module 'claude-code' {
|
|
40
34
|
interface CmodDependencies {
|
|
41
|
-
|
|
35
|
+
provider: Provider
|
|
42
36
|
}
|
|
43
37
|
}
|
|
44
38
|
```
|
|
@@ -49,18 +43,18 @@ declare module 'claude-code' {
|
|
|
49
43
|
|
|
50
44
|
## Call the methods: mod.dependencies
|
|
51
45
|
|
|
52
|
-
A mod that calls
|
|
46
|
+
A mod that calls the provider lists it in its own `.claude-plugin/plugin.json`, and Claude Code installs it with the mod:
|
|
53
47
|
|
|
54
48
|
```json
|
|
55
|
-
"dependencies": [{ "name": "cmod", "version": ">=5.2.0" }, "
|
|
49
|
+
"dependencies": [{ "name": "cmod", "version": ">=5.2.0" }, "provider"]
|
|
56
50
|
```
|
|
57
51
|
|
|
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
|
|
52
|
+
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 the provider there, from the `release` branch of the GitHub repository that the `"repository"` of the provider's `plugin.json` names. Install or link the provider 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
53
|
|
|
60
54
|
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:
|
|
61
55
|
|
|
62
56
|
```json
|
|
63
|
-
"dependencies": [{ "name": "cmod", "version": ">=5.2.0" }, { "name": "
|
|
57
|
+
"dependencies": [{ "name": "cmod", "version": ">=5.2.0" }, { "name": "provider", "version": "^1.0" }]
|
|
64
58
|
```
|
|
65
59
|
|
|
66
60
|
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)).
|
|
@@ -69,25 +63,17 @@ cmod is a provider too, with one difference: every newer cmod runs every mod bui
|
|
|
69
63
|
|
|
70
64
|
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 each session offers Reload, so a mod never waits for the person to update its providers, only to press Reload.
|
|
71
65
|
|
|
72
|
-
Claude Code then lays
|
|
66
|
+
Claude Code then lays the provider's types file beside the mod's own types, so the call is typed:
|
|
73
67
|
|
|
74
68
|
```ts
|
|
75
|
-
import { defineMod } from '../node_modules/@cmodjs/core/mod.js'
|
|
76
|
-
import { slashCommand } from '../node_modules/@cmodjs/core/jobs/slash-command.js'
|
|
69
|
+
import { defineMod, sessions } from '../node_modules/@cmodjs/core/mod.js'
|
|
77
70
|
|
|
78
|
-
export const
|
|
79
|
-
name: '
|
|
71
|
+
export const myMod = defineMod({
|
|
72
|
+
name: 'my-mod',
|
|
80
73
|
setup(mod) {
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
description: 'List the functions a file exports',
|
|
85
|
-
reply: async ({ args }, mod) => {
|
|
86
|
-
const signatures = await mod.dependencies.tracer.signatures({ path: args })
|
|
87
|
-
return signatures.map(({ name, line }) => `${name}:${line}`).join('\n')
|
|
88
|
-
},
|
|
89
|
-
}),
|
|
90
|
-
)
|
|
74
|
+
sessions.current.onToolResult(async ({ files }) => {
|
|
75
|
+
for (const path of files.changed) mod.log(`${path}: ${await mod.dependencies.provider.lines({ path })} lines`)
|
|
76
|
+
})
|
|
91
77
|
},
|
|
92
78
|
})
|
|
93
79
|
```
|
|
@@ -97,18 +83,7 @@ export const outline = defineMod({
|
|
|
97
83
|
A mod that works without another mod, and only uses it when the person has it, does not list it, because Claude Code installs every listed dependency for everyone who installs your mod. Ask whether it runs first, then call it through `mod.dependencies` as usual:
|
|
98
84
|
|
|
99
85
|
```ts
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
export const inbox = defineMod({
|
|
103
|
-
name: 'inbox',
|
|
104
|
-
setup(mod) {
|
|
105
|
-
return {
|
|
106
|
-
save: async () => {
|
|
107
|
-
if (await mods.isLoaded('anyhost')) await mod.dependencies.anyhost.sync({ folder: mod.dataFolder })
|
|
108
|
-
},
|
|
109
|
-
}
|
|
110
|
-
},
|
|
111
|
-
})
|
|
86
|
+
if (await mods.isLoaded('provider')) await mod.dependencies.provider.lines({ path })
|
|
112
87
|
```
|
|
113
88
|
|
|
114
89
|
```ts
|
|
@@ -116,7 +91,7 @@ isLoaded(name: string): Promise<boolean>
|
|
|
116
91
|
```
|
|
117
92
|
|
|
118
93
|
- `isLoaded` answers true when the mod runs in this Claude Code process, as one Claude Code loaded or one run from its checkout with `--plugin-dir`. A mod the person installed but turned off answers false.
|
|
119
|
-
- Claude Code lays a provider's types file beside your mod's only for a listed dependency, so type the methods you call in your own `types/index.d.ts`, with the shape the provider's types file exports, such as `interface CmodDependencies {
|
|
94
|
+
- Claude Code lays a provider's types file beside your mod's only for a listed dependency, so type the methods you call in your own `types/index.d.ts`, with the shape the provider's types file exports, such as `interface CmodDependencies { provider: Provider }`.
|
|
120
95
|
- A mod that calls `mods.isLoaded` runs on cmod 5.4.0 or later, which the `cmod` range `cmod check` writes says.
|
|
121
96
|
|
|
122
97
|
## When a call fails
|
|
@@ -124,18 +99,18 @@ isLoaded(name: string): Promise<boolean>
|
|
|
124
99
|
A call that cannot answer rejects with one of these reasons:
|
|
125
100
|
|
|
126
101
|
```text
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
102
|
+
<provider> is not installed. Install it in Plugins.
|
|
103
|
+
<provider> is not set up: <why its setup failed>
|
|
104
|
+
<provider> is installing. Try again when it's ready.
|
|
105
|
+
<provider> has no method <method>.
|
|
106
|
+
<provider>: <the message of the error the method threw>
|
|
132
107
|
```
|
|
133
108
|
|
|
134
|
-
-
|
|
135
|
-
-
|
|
136
|
-
-
|
|
137
|
-
- When
|
|
138
|
-
- A call fails with `mod.dependencies
|
|
109
|
+
- `<provider> is not installed` covers a provider whose code did not load. The caller's error toast shows a `Plugins` button, which opens Claude Code's `/plugin`.
|
|
110
|
+
- `<provider> is not set up` covers a provider the person declined to install and one whose install failed, and names why. The provider's own toast shows the same reason, with `Retry` or `Install`.
|
|
111
|
+
- `<provider> is installing` covers a provider whose install step still runs 5 seconds after the call. A provider that is installing or only starting makes the call wait for it, up to 5 seconds.
|
|
112
|
+
- When the provider is disabled, Claude Code unloads the mod that lists it, with its own error, which starts `Dependency "<provider>" is disabled`.
|
|
113
|
+
- A call fails with `mod.dependencies.<provider>.<method> passed its 30 s deadline` when the other mod takes longer than 30 seconds. A job bounds the whole function that makes the call by its own deadline ([jobs.md](jobs.md)), so a slow call inside `slashCommand` can fail the command first, with `/<command> passed the 30 s deadline of slashCommand`.
|
|
139
114
|
|
|
140
115
|
```ts
|
|
141
116
|
notInstalled(name: string): string
|
|
@@ -145,12 +120,12 @@ notInstalled(name: string): string
|
|
|
145
120
|
|
|
146
121
|
## Test the calls
|
|
147
122
|
|
|
148
|
-
`testMod(
|
|
123
|
+
`testMod(myMod, { dependencies: { provider: { lines: async () => 3 } } })` answers the provider's methods with the functions given. A call to a mod the test does not fake fails with `<provider> is not installed. Install it in Plugins.`, as in Claude Code. [testing.md](testing.md) covers it.
|
|
149
124
|
|
|
150
125
|
A test of the provider's own methods fires `cmod.call`, as a caller's `mod.dependencies` does. The answer is `{ value }` with what the method returned, or `{ deny }` with the reason it failed:
|
|
151
126
|
|
|
152
127
|
```ts
|
|
153
|
-
const tested = testMod(
|
|
128
|
+
const tested = testMod(provider, { files: { '/work/a.ts': 'a\nb\nc' } })
|
|
154
129
|
|
|
155
|
-
expect(await tested.fire('cmod.call', { to: '
|
|
130
|
+
expect(await tested.fire('cmod.call', { to: 'provider', method: 'lines', input: { path: '/work/a.ts' } })).toEqual({ value: 3 })
|
|
156
131
|
```
|
package/docs/index.md
CHANGED
|
@@ -32,7 +32,7 @@ my-mod/
|
|
|
32
32
|
|
|
33
33
|
The template is a working example to replace. It counts the prompts of the session in `state.session.prompts`, shows the count below the prompt and in a Sidebar page that the `alt+shift+p` hotkey shows or hides, and tests all three. Replace the counter, the page, the widget, the component, the Skill, the rule, and the tests with the mod's own.
|
|
34
34
|
|
|
35
|
-
A mod imports `@cmodjs/core` by path, such as `../node_modules/@cmodjs/core/mod.js`, because Claude Code loads a plugin's own files only.
|
|
35
|
+
A mod imports `@cmodjs/core` by path, such as `../node_modules/@cmodjs/core/mod.js`, because Claude Code loads a plugin's own files only. Every type a mod writes comes from `@cmodjs/core` too, never from the `claude-code` module. A component returns `JSX.Element` and takes `JSX.Children`, which need no import. Element props, such as `BoxProps` and `Color`, come from `ui/elements.js`. The two types of `register`'s parameters, `AddHook` and `PluginOptions`, come from `register.js`, and the rest from `mod.js`.
|
|
36
36
|
|
|
37
37
|
## Claude Code's API description
|
|
38
38
|
|
|
@@ -48,6 +48,7 @@ Mod code runs inside Claude Code's hooks environment, not in Node or Bun. It has
|
|
|
48
48
|
|
|
49
49
|
- a file in `src/` that imports a Node module, `bun`, or a `bun:` module. Tests in `tests/` run under `bun test` and may import `bun:test`.
|
|
50
50
|
- a file that imports from `cli/`, which the release leaves out
|
|
51
|
+
- a file that imports the `claude-code` module. A provider's types file adds to that module with `declare module 'claude-code'` ([dependencies.md](dependencies.md)), which imports nothing.
|
|
51
52
|
- `devDependencies` in `package.json`. Claude Code installs them for every person, so move each into `dependencies` or drop it.
|
|
52
53
|
- a `bin/` or `target/` folder at the mod's root
|
|
53
54
|
- a prebuilt binary in the mod, outside `cli/`, `node_modules/`, `.git/`, `target/`, `.target/`, and `.claude-plugin/types/`
|
|
@@ -87,22 +88,23 @@ A mod imports from the files below, and every other file in this package is inte
|
|
|
87
88
|
| --- | --- | --- |
|
|
88
89
|
| `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
90
|
| `mod.js` | `Hotkey`, `HotkeyInit`, `Combo`, `Key` | [mod.md](mod.md#hotkeys) |
|
|
90
|
-
| `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
|
+
| `mod.js` | `settings`, `Settings`, `SettingsFile`, `SettingsFileChange`, `SettingsFileChangeListener`, `config`, `ConfigRow`, `commands`, `CommandInfo`, `CommandRun`, `CommandRunAnswer`, `CommandRunResult`, `model`, `ModelCompleteRequest`, `ModelCompleteOptions`, `ModelCompleteResult`, `fs`, `Entry`, `Stat`, `StatOptions`, `FileMatch`, `FileChange`, `metadata`, `Metadata`, `process`, `ProcessRunOptions`, `ProcessRunResult`, `ProcessSpawnOptions`, `Subprocess`, `http`, `HttpOptions`, `HttpResponse`, `clipboard`, `AskOptions`, `Imports` | [mod.md](mod.md) |
|
|
91
92
|
| `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) |
|
|
92
93
|
| `mod.js` | `Placement`, `ProjectSetup`, `SessionStartAsked`, `SessionStarted`, `SessionEnded`, `ModelChange`, `CwdChange`, `DirectoryAdd`, `Worktree`, `Notification`, `Elicitation`, `ElicitationResponse`, `McpServer`, `PermissionUpdate`, `PermissionCheck`, `PermissionRequest`, `PermissionDenial`, `BatchedCall`, `ToolBatch`, `Todo`, `ReplyDisplay` | [session.md](session.md#the-session-s-own-events) |
|
|
93
94
|
| `mod.js` | `Message`, `MessageType`, `Prompt`, `Note`, `Reply`, `ToolCall`, `ToolResult`, `Skill`, `InstructionFile`, `AttachedFile`, `AttachmentType`, `Notice`, `Sender`, `SenderType`, `Person`, `Mod`, `Schedule`, `Channel`, `Sdk`, `Engine` | [session.md](session.md#message) |
|
|
94
95
|
| `mod.js` | `Context`, `Turn`, `Goal`, `Task` | [session.md](session.md#turn-context-goal-and-task) |
|
|
95
96
|
| `mod.js` | `Toast`, `ToastId`, `ToastType`, `ToastOptions` | [ui.md](ui.md#toasts) |
|
|
96
|
-
| `mod.js` | `PageInit`, `Page`, `PageProps`, `PaneInit`, `Pane`, `PaneProps`, `OpenOptions`, `ScrollTarget`, `ScrollOptions` | [ui.md](ui.md#the-sidebar-and-its-pages) |
|
|
97
|
+
| `mod.js` | `PageInit`, `Page`, `PageProps`, `PaneInit`, `Pane`, `PaneProps`, `PaneScroll`, `PaneClose`, `OpenOptions`, `ScrollTarget`, `ScrollOptions` | [ui.md](ui.md#the-sidebar-and-its-pages) |
|
|
97
98
|
| `mod.js` | `WidgetInit`, `Widget`, `WidgetContext`, `Area`, `AbovePrompt`, `BelowPrompt`, `Working`, `TurnEnd`, `Dashboard` | [ui.md](ui.md#widgets) |
|
|
98
99
|
| `mod.js` | `StyleInit`, `Style`, `StyleProps`, `Kind`, `Row`, `Block`, `ToolGroup`, `ToolProgress`, `CommandOutput`, `AskUserQuestion` | [ui.md](ui.md#styles-change-how-claude-code-draws) |
|
|
99
100
|
| `mod.js` | `notInstalled` | [dependencies.md](dependencies.md) |
|
|
100
|
-
| `register.js` | `registerMod`, `registerPermissionCheck`, `registeredMod` | [mod.md](mod.md) |
|
|
101
|
+
| `register.js` | `registerMod`, `registerPermissionCheck`, `registeredMod`, `AddHook`, `PluginOptions` | [mod.md](mod.md) |
|
|
101
102
|
| `options.js` | `option`, `Option`, `Options`, `OptionValues`, `OptionValue`, `OptionType`, `UserConfigField`, `userConfigOf` | [options.md](options.md) |
|
|
102
103
|
| `shell.js` | `parseShell`, `ParsedShell`, `ShellCommand` | [mod.md](mod.md#shell-js-and-path-js-read-a-command-line) |
|
|
103
104
|
| `path.js` | `resolve`, `join`, `dirname`, `basename`, `extname`, `relative`, `isAbsolute`, `normalize` | [mod.md](mod.md#shell-js-and-path-js-read-a-command-line) |
|
|
104
105
|
| `testing.js` | `testMod`, `TestOptions`, `TestedMod`, `Raise`, `Fakes`, `Shown`, `ShownToast`, `TestCall`, `FakeSession`, `MessageDraft`, `RoutedEvent` | [testing.md](testing.md) |
|
|
105
|
-
| `ui/elements.js` | `Box`, `Text`, `Button`, `
|
|
106
|
+
| `ui/elements.js` | `Box`, `Text`, `Button`, `Code`, `Markdown`, `Input`, `Select`, `Image`, `Raster`, `Svg`, `Client`, `drawWith` | [ui.md](ui.md) |
|
|
107
|
+
| `ui/elements.js` | `BoxProps`, `TextProps`, `ButtonProps`, `CodeProps`, `MarkdownProps`, `InputProps`, `SelectProps`, `ImageProps`, `RasterProps`, `SvgProps`, `ClientProps`, `Color`, `Press` | [ui.md](ui.md#elements) |
|
|
106
108
|
| `ui/components.js` | `Tabs`, `Tab`, `Split`, `Panel`, `Toggle`, `Tooltip`, `Help`, `Dialog`, `Pagination`, `Progress` | [ui.md](ui.md) |
|
|
107
109
|
| `ui/markdown.js` | `Heading`, `Paragraph`, `CodeBlock`, `BlockQuote`, `List`, `Table`, `ThematicBreak`, `HtmlBlock`, `Block`, `markdownBlocks`, `BlockProps`, `MarkdownReader`, `MarkdownPiece` | [ui.md](ui.md#markdown-blocks) |
|
|
108
110
|
| `jobs/slash-command.js` | `slashCommand`, `CommandReply` | [jobs.md](jobs.md) |
|
package/docs/install-steps.md
CHANGED
|
@@ -65,14 +65,14 @@ const signIn: Step = {
|
|
|
65
65
|
isDone: () => isSignedIn(),
|
|
66
66
|
}
|
|
67
67
|
|
|
68
|
-
export const
|
|
68
|
+
export const myMod = defineMod({ name: 'my-mod', installer: [signIn], setup(mod) { … } })
|
|
69
69
|
```
|
|
70
70
|
|
|
71
71
|
```ts
|
|
72
72
|
type Step<State> = {
|
|
73
73
|
readonly id: string
|
|
74
74
|
readonly title: string
|
|
75
|
-
render(mod: Mod<State>, props: PageProps):
|
|
75
|
+
render(mod: Mod<State>, props: PageProps): JSX.Element
|
|
76
76
|
isDone(mod: Mod<State>): boolean | Promise<boolean>
|
|
77
77
|
}
|
|
78
78
|
```
|
|
@@ -88,7 +88,7 @@ type Step<State> = {
|
|
|
88
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)):
|
|
89
89
|
|
|
90
90
|
```json
|
|
91
|
-
{ "bindings": [{ "context": "Chat", "bindings": { "shift+tab": "command:
|
|
91
|
+
{ "bindings": [{ "context": "Chat", "bindings": { "shift+tab": "command:my-mod--toggle" } }] }
|
|
92
92
|
```
|
|
93
93
|
|
|
94
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.
|
package/docs/jobs.md
CHANGED
|
@@ -72,8 +72,8 @@ type SlashCommand = { readonly name: string; remove(): void }
|
|
|
72
72
|
import { defineMod } from '../node_modules/@cmodjs/core/mod.js'
|
|
73
73
|
import { slashCommand } from '../node_modules/@cmodjs/core/jobs/slash-command.js'
|
|
74
74
|
|
|
75
|
-
export const
|
|
76
|
-
name: '
|
|
75
|
+
export const myMod = defineMod({
|
|
76
|
+
name: 'my-mod',
|
|
77
77
|
state: { project: { items: [] as readonly string[] } },
|
|
78
78
|
setup(mod) {
|
|
79
79
|
mod.use(
|
|
@@ -118,8 +118,8 @@ type Tool = { readonly name: string; remove(): void }
|
|
|
118
118
|
import { defineMod } from '../node_modules/@cmodjs/core/mod.js'
|
|
119
119
|
import { tool } from '../node_modules/@cmodjs/core/jobs/tool.js'
|
|
120
120
|
|
|
121
|
-
export const
|
|
122
|
-
name: '
|
|
121
|
+
export const myMod = defineMod({
|
|
122
|
+
name: 'my-mod',
|
|
123
123
|
state: { project: { opened: [] as readonly string[] } },
|
|
124
124
|
setup(mod) {
|
|
125
125
|
mod.use(
|
|
@@ -187,7 +187,7 @@ type Rule<State> = Target & {
|
|
|
187
187
|
- The strictest answer wins: a mod's `ask` or `deny` beats Claude Code's `allow`, and Claude Code's `deny` beats a mod's `ask`.
|
|
188
188
|
- `when` narrows a rule. The rule matches only when `when` resolves true. A `when` that throws makes the rule match, and the reason adds `Its when check failed: <error>`.
|
|
189
189
|
- When cmod cannot read the call or the session, it denies the call with the reason.
|
|
190
|
-
- For a PowerShell command, or a Bash command cmod cannot fully parse, a `command` rule matches when every word of its pattern appears in the command line. A `read` or `write` rule matches when the command line holds the last segment of its pattern, after the last `/`, and only when that segment holds none of `*?[]{}`. So `{ write: '
|
|
190
|
+
- For a PowerShell command, or a Bash command cmod cannot fully parse, a `command` rule matches when every word of its pattern appears in the command line. A `read` or `write` rule matches when the command line holds the last segment of its pattern, after the last `/`, and only when that segment holds none of `*?[]{}`. So `{ write: 'CHANGELOG.md' }` matches such a command that names `CHANGELOG.md`, and `{ write: '**/.env*' }` never matches one. A `!` pattern leaves nothing out of such a line, so the rule errs toward matching.
|
|
191
191
|
- `permissions({})` throws `permissions: give it a deny or an ask rule, or remove it from setup.`
|
|
192
192
|
- A mod that uses `permissions` calls `registerPermissionCheck(addHook)` after `registerMod` in `hooks/register.ts` ([mod.md](mod.md)). Without it `mod.use(permissions(…))` throws, so a mod that uses it in `setup` does not start.
|
|
193
193
|
|
|
@@ -206,8 +206,8 @@ type Rule<State> = Target & {
|
|
|
206
206
|
import { defineMod } from '../node_modules/@cmodjs/core/mod.js'
|
|
207
207
|
import { permissions } from '../node_modules/@cmodjs/core/jobs/permissions.js'
|
|
208
208
|
|
|
209
|
-
export const
|
|
210
|
-
name: '
|
|
209
|
+
export const myMod = defineMod({
|
|
210
|
+
name: 'my-mod',
|
|
211
211
|
state: { project: { isFrozen: false } },
|
|
212
212
|
setup(mod) {
|
|
213
213
|
mod.use(
|
|
@@ -217,7 +217,7 @@ export const guard = defineMod({
|
|
|
217
217
|
{ command: 'git push', when: (_call, mod) => mod.state.project.isFrozen, reason: 'The branch is frozen.' },
|
|
218
218
|
{ write: '**/.env*', reason: 'Edit .env files by hand.' },
|
|
219
219
|
],
|
|
220
|
-
ask: [{ write: '
|
|
220
|
+
ask: [{ write: 'CHANGELOG.md', when: (call) => call.content?.includes('Avoid') === true, reason: 'CHANGELOG.md changes need a review.' }],
|
|
221
221
|
}),
|
|
222
222
|
)
|
|
223
223
|
},
|
|
@@ -241,8 +241,8 @@ check<State>(options: { readonly after: Target | Target[]; readonly run: readonl
|
|
|
241
241
|
import { defineMod } from '../node_modules/@cmodjs/core/mod.js'
|
|
242
242
|
import { check } from '../node_modules/@cmodjs/core/jobs/check.js'
|
|
243
243
|
|
|
244
|
-
export const
|
|
245
|
-
name: '
|
|
244
|
+
export const myMod = defineMod({
|
|
245
|
+
name: 'my-mod',
|
|
246
246
|
setup(mod) {
|
|
247
247
|
mod.use(check({ after: { write: '**/*.ts' }, run: ['bun', 'x', 'oxlint'] }))
|
|
248
248
|
},
|
|
@@ -275,8 +275,8 @@ prompt<State>(options: {
|
|
|
275
275
|
import { defineMod, fs, sessions } from '../node_modules/@cmodjs/core/mod.js'
|
|
276
276
|
import { prompt } from '../node_modules/@cmodjs/core/jobs/prompt.js'
|
|
277
277
|
|
|
278
|
-
export const
|
|
279
|
-
name: '
|
|
278
|
+
export const myMod = defineMod({
|
|
279
|
+
name: 'my-mod',
|
|
280
280
|
state: { session: { mode: 'build' } },
|
|
281
281
|
setup(mod) {
|
|
282
282
|
mod.use(prompt({ name: 'Commit messages', prompt: 'Write commit messages in the imperative mood.' }))
|
|
@@ -306,8 +306,8 @@ type ScheduledPrompt = { readonly cron: string; readonly prompt: string }
|
|
|
306
306
|
import { defineMod } from '../node_modules/@cmodjs/core/mod.js'
|
|
307
307
|
import { schedule } from '../node_modules/@cmodjs/core/jobs/schedule.js'
|
|
308
308
|
|
|
309
|
-
export const
|
|
310
|
-
name: '
|
|
309
|
+
export const myMod = defineMod({
|
|
310
|
+
name: 'my-mod',
|
|
311
311
|
state: { project: { isOn: false, cron: '*/10 * * * *', prompt: 'Check the CI and fix what failed.' } },
|
|
312
312
|
setup(mod) {
|
|
313
313
|
mod.use(schedule((state) => (state.project.isOn ? { cron: state.project.cron, prompt: state.project.prompt } : undefined)))
|
|
@@ -341,8 +341,8 @@ import { defineMod, http } from '../node_modules/@cmodjs/core/mod.js'
|
|
|
341
341
|
import { program } from '../node_modules/@cmodjs/core/jobs/program.js'
|
|
342
342
|
import { slashCommand } from '../node_modules/@cmodjs/core/jobs/slash-command.js'
|
|
343
343
|
|
|
344
|
-
export const
|
|
345
|
-
name: '
|
|
344
|
+
export const myMod = defineMod({
|
|
345
|
+
name: 'my-mod',
|
|
346
346
|
setup(mod) {
|
|
347
347
|
const server = mod.use(program({ command: ['preview-server', '--port', '0'] }))
|
|
348
348
|
mod.use(
|
|
@@ -399,8 +399,8 @@ const editCounter = (tool: string): Job<EditCounter> => ({ mod, announce, reserv
|
|
|
399
399
|
}
|
|
400
400
|
}
|
|
401
401
|
|
|
402
|
-
export const
|
|
403
|
-
name: '
|
|
402
|
+
export const myMod = defineMod({
|
|
403
|
+
name: 'my-mod',
|
|
404
404
|
setup(mod) {
|
|
405
405
|
const writes = mod.use(editCounter('Write'))
|
|
406
406
|
sessions.current.onTurnEnd(() => mod.toast(`${writes.count()} files written so far`))
|