@cmodjs/core 6.0.0 → 6.0.2
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 +9 -9
- package/docs/dependencies.md +32 -57
- package/docs/install-steps.md +2 -2
- package/docs/jobs.md +18 -18
- package/docs/mod.md +19 -19
- package/docs/options.md +3 -3
- package/docs/session.md +1 -1
- package/docs/state.md +4 -4
- package/docs/testing.md +20 -20
- package/docs/ui.md +10 -10
- package/package.json +1 -1
- package/records.d.ts +1 -1
- package/records.js +1 -1
- package/runtime/ui.d.ts.map +1 -1
- package/runtime/ui.js +5 -2
- package/src/records.ts +1 -1
- package/src/runtime/ui.ts +4 -2
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
|
|
|
@@ -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
|
|
|
@@ -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/install-steps.md
CHANGED
|
@@ -65,7 +65,7 @@ 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
|
|
@@ -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`))
|
package/docs/mod.md
CHANGED
|
@@ -29,8 +29,8 @@ type ModDefinition<State, Name, Options, Hotkeys> = {
|
|
|
29
29
|
```tsx
|
|
30
30
|
import { defineMod, sessions } from '../node_modules/@cmodjs/core/mod.js'
|
|
31
31
|
|
|
32
|
-
export const
|
|
33
|
-
name: '
|
|
32
|
+
export const myMod = defineMod({
|
|
33
|
+
name: 'my-mod',
|
|
34
34
|
state: { session: { isGreeted: false } },
|
|
35
35
|
|
|
36
36
|
setup(mod) {
|
|
@@ -110,10 +110,10 @@ A mod's `CHANGELOG.md`, at its root, holds what changed in each version, written
|
|
|
110
110
|
|
|
111
111
|
```ts
|
|
112
112
|
import { registerMod, type AddHook, type PluginOptions } from '../node_modules/@cmodjs/core/register.js'
|
|
113
|
-
import {
|
|
113
|
+
import { myMod } from '../src/mod.js'
|
|
114
114
|
|
|
115
115
|
export function register(addHook: AddHook, options: PluginOptions): void {
|
|
116
|
-
registerMod(addHook,
|
|
116
|
+
registerMod(addHook, myMod, options)
|
|
117
117
|
}
|
|
118
118
|
```
|
|
119
119
|
|
|
@@ -131,7 +131,7 @@ A mod that hears permissions calls `registerPermissionCheck` after `registerMod`
|
|
|
131
131
|
|
|
132
132
|
```ts
|
|
133
133
|
export function register(addHook: AddHook, options: PluginOptions): void {
|
|
134
|
-
registerMod(addHook,
|
|
134
|
+
registerMod(addHook, myMod, options)
|
|
135
135
|
registerPermissionCheck(addHook)
|
|
136
136
|
}
|
|
137
137
|
```
|
|
@@ -270,7 +270,7 @@ With `{ to: 'transcript' }`, the line shows dim in the conversation, where the p
|
|
|
270
270
|
With a `level`, the line is a failure the mod works around and goes on past, and it goes to the Log in Settings and `cmod log` too, which counts each repeat with the versions it happened on. An `error` shows a toast only where cmod shows a failure the mod throws: for a mod run from its checkout, in a session working inside it ([ui.md](ui.md#toasts)). A `warning` never shows one. Throw instead when the listener or handler cannot go on.
|
|
271
271
|
|
|
272
272
|
```ts
|
|
273
|
-
mod.log(`The rule ${name} did not load, so
|
|
273
|
+
mod.log(`The rule ${name} did not load, so ${mod.name} skips it: ${messageOf(error)}`, { level: 'error' })
|
|
274
274
|
```
|
|
275
275
|
|
|
276
276
|
### Hotkeys
|
|
@@ -297,13 +297,13 @@ type Hotkey = {
|
|
|
297
297
|
- `tested.hotkey(name)` presses a hotkey in a test ([testing.md](testing.md)).
|
|
298
298
|
|
|
299
299
|
```tsx
|
|
300
|
-
export const
|
|
301
|
-
name: '
|
|
300
|
+
export const myMod = defineMod({
|
|
301
|
+
name: 'my-mod',
|
|
302
302
|
hotkeys: {
|
|
303
|
-
toggle: { title: 'Show or hide the
|
|
303
|
+
toggle: { title: 'Show or hide the page', default: 'alt+shift+n' },
|
|
304
304
|
},
|
|
305
305
|
setup(mod) {
|
|
306
|
-
const page = mod.sidebar.add(
|
|
306
|
+
const page = mod.sidebar.add(myPage)
|
|
307
307
|
mod.hotkeys.toggle.onPress(() => page.toggle({ focus: true }))
|
|
308
308
|
},
|
|
309
309
|
})
|
|
@@ -421,8 +421,8 @@ A job's deadline bounds the whole callback that makes these calls ([jobs.md](job
|
|
|
421
421
|
```ts
|
|
422
422
|
import { defineMod, process, sessions } from '../node_modules/@cmodjs/core/mod.js'
|
|
423
423
|
|
|
424
|
-
export const
|
|
425
|
-
name: '
|
|
424
|
+
export const myMod = defineMod({
|
|
425
|
+
name: 'my-mod',
|
|
426
426
|
setup() {
|
|
427
427
|
sessions.current.beforeSessionStart(async () => {
|
|
428
428
|
const { exitCode, stdout } = await process.run(['git', 'branch', '--show-current'], { cwd: sessions.current.project })
|
|
@@ -480,7 +480,7 @@ type FileMatch = { readonly path: string; readonly name?: string; readonly metad
|
|
|
480
480
|
|
|
481
481
|
```ts
|
|
482
482
|
const skills = await fs.find(['~/.claude/skills/*/SKILL.md', '.claude/skills/*/SKILL.md'])
|
|
483
|
-
const planning = skills.filter((skill) => skill.metadata['
|
|
483
|
+
const planning = skills.filter((skill) => skill.metadata['tags']?.split(' ').includes('plan'))
|
|
484
484
|
```
|
|
485
485
|
|
|
486
486
|
## metadata: a file's own keys
|
|
@@ -498,14 +498,14 @@ Where a file keeps its metadata depends on its type:
|
|
|
498
498
|
---
|
|
499
499
|
name: plan
|
|
500
500
|
metadata:
|
|
501
|
-
|
|
501
|
+
my-mod.tags: plan build
|
|
502
502
|
---
|
|
503
503
|
```
|
|
504
504
|
|
|
505
505
|
```sh
|
|
506
506
|
#!/bin/sh
|
|
507
507
|
# /// metadata
|
|
508
|
-
#
|
|
508
|
+
# my-mod.tags: plan build
|
|
509
509
|
# ///
|
|
510
510
|
```
|
|
511
511
|
|
|
@@ -519,7 +519,7 @@ metadata:
|
|
|
519
519
|
|
|
520
520
|
```ts
|
|
521
521
|
await metadata.update('.claude/skills/plan/SKILL.md', (keys) => {
|
|
522
|
-
keys['
|
|
522
|
+
keys['tags'] = 'plan build'
|
|
523
523
|
})
|
|
524
524
|
```
|
|
525
525
|
|
|
@@ -544,7 +544,7 @@ type Device = { id: string; name: string; os: 'darwin' | 'linux'; arch: 'arm64'
|
|
|
544
544
|
```
|
|
545
545
|
|
|
546
546
|
- `id` is the same on one computer for every session, mod, and reinstall, and differs between computers. cmod reads it from the operating system and stores nothing: the IOPlatformUUID on macOS, and on Linux `/etc/machine-id`, or `/var/lib/dbus/machine-id` when that holds none, as systemd and D-Bus read them, hashed for cmod the way systemd's `sd_id128_get_machine_app_specific` hashes a machine id for an app, so the id never shows the computer's own.
|
|
547
|
-
- `name` is the name the computer goes by on its network: its LocalHostName on macOS, such as `
|
|
547
|
+
- `name` is the name the computer goes by on its network: its LocalHostName on macOS, such as `Mac-mini`, and its hostname on Linux.
|
|
548
548
|
- `os` and `arch` are the names cmod's builds use, such as `darwin` and `arm64`.
|
|
549
549
|
- `read` reads the computer the first time the mod calls it, and answers the same device after that. It rejects on a computer other than macOS or Linux on arm64 or x64. It also rejects on a Linux computer where neither `/etc/machine-id` nor `/var/lib/dbus/machine-id` holds a machine id, as in many containers, with a sentence that names both files.
|
|
550
550
|
- A mod's program that runs with no session, such as over `ssh`, reads the same device with `cmod device --json` ([commands.md](commands.md#cmod-device)).
|
|
@@ -574,8 +574,8 @@ Returns an `Error`'s `message`, or the value as text. Use it in a `catch`, where
|
|
|
574
574
|
```ts
|
|
575
575
|
import { defineMod, fs, messageOf, sessions } from '../node_modules/@cmodjs/core/mod.js'
|
|
576
576
|
|
|
577
|
-
export const
|
|
578
|
-
name: '
|
|
577
|
+
export const myMod = defineMod({
|
|
578
|
+
name: 'my-mod',
|
|
579
579
|
setup(mod) {
|
|
580
580
|
sessions.current.onTurnEnd(async () => {
|
|
581
581
|
await fs.write(`${mod.dataFolder}/last-stop.txt`, new Date().toISOString()).catch((error: unknown) => {
|
package/docs/options.md
CHANGED
|
@@ -10,8 +10,8 @@ An option is a value a person sets for a mod and the mod reads, such as a token,
|
|
|
10
10
|
import { defineMod } from '../node_modules/@cmodjs/core/mod.js'
|
|
11
11
|
import { option } from '../node_modules/@cmodjs/core/options.js'
|
|
12
12
|
|
|
13
|
-
export const
|
|
14
|
-
name: '
|
|
13
|
+
export const myMod = defineMod({
|
|
14
|
+
name: 'my-mod',
|
|
15
15
|
options: {
|
|
16
16
|
githubToken: option.secret({ title: 'GitHub token', description: 'Reads your CI runs' }),
|
|
17
17
|
every: option.number({ title: 'Check every', description: 'Minutes between checks', default: 10, min: 1 }),
|
|
@@ -89,7 +89,7 @@ Claude Code reads a plugin's options from `userConfig` in `.claude-plugin/plugin
|
|
|
89
89
|
`testMod(mod, { options: { githubToken: 'ghp_test' } })` starts the tested mod with those values, as Claude Code passes them. Each option left out gets its default. A test that leaves out an option with no default fails with `<mod> needs <title>, which a person sets in /config. Give it to the tested mod: testMod(mod, { options: { <key>: … } }).` `fakes.config.list` answers the `/config` rows, so a test can lock a value as managed settings do ([testing.md](testing.md)).
|
|
90
90
|
|
|
91
91
|
```ts
|
|
92
|
-
const tested = testMod(
|
|
92
|
+
const tested = testMod(myMod, { options: { githubToken: 'ghp_test', branch: 'develop' } })
|
|
93
93
|
await tested.start()
|
|
94
94
|
expect(tested.shown.toasts).toContainEqual({ type: 'default', message: 'Watching develop every 10 minutes' })
|
|
95
95
|
```
|
package/docs/session.md
CHANGED
|
@@ -206,7 +206,7 @@ sessions.current.beforeTurnEnd(async () => ((await testsPass()) ? undefined : {
|
|
|
206
206
|
|
|
207
207
|
When several listeners answer, each sees what the one before it changed, and the first `refuse` or `result` decides.
|
|
208
208
|
|
|
209
|
-
Claude reads each mod's `note` inside the mod's own tag, such as `<
|
|
209
|
+
Claude reads each mod's `note` inside the mod's own tag, such as `<my-mod_mod>…</my-mod_mod>` for the mod `my-mod`. Every note Claude received becomes a `Note` whose `from` is `{ type: 'mod', name }`, so `onNote({ from: { type: 'mod', name: 'my-mod' } })` hears each note from my-mod that Claude got, and never one Claude Code dropped.
|
|
210
210
|
|
|
211
211
|
### The session's own events
|
|
212
212
|
|
package/docs/state.md
CHANGED
|
@@ -45,8 +45,8 @@ Then pass it to `defineMod`:
|
|
|
45
45
|
import { defineMod, sessions } from '../node_modules/@cmodjs/core/mod.js'
|
|
46
46
|
import { initialState } from './state.js'
|
|
47
47
|
|
|
48
|
-
export const
|
|
49
|
-
name: '
|
|
48
|
+
export const myMod = defineMod({
|
|
49
|
+
name: 'my-mod',
|
|
50
50
|
state: initialState,
|
|
51
51
|
setup(mod) {
|
|
52
52
|
sessions.current.onPrompt(() => {
|
|
@@ -68,8 +68,8 @@ Assign to a key. cmod saves the new value and redraws the mod.
|
|
|
68
68
|
```ts
|
|
69
69
|
import { defineMod, sessions } from '../node_modules/@cmodjs/core/mod.js'
|
|
70
70
|
|
|
71
|
-
export const
|
|
72
|
-
name: '
|
|
71
|
+
export const myMod = defineMod({
|
|
72
|
+
name: 'my-mod',
|
|
73
73
|
state: { memory: { readFiles: [] as readonly string[] } },
|
|
74
74
|
setup(mod) {
|
|
75
75
|
sessions.current.onToolResult(({ files }) => {
|
package/docs/testing.md
CHANGED
|
@@ -9,10 +9,10 @@ testMod<State, Options>(definition: ModDefinition<State, string, Options>, optio
|
|
|
9
9
|
```ts
|
|
10
10
|
import { expect, test } from 'bun:test'
|
|
11
11
|
import { testMod } from '../node_modules/@cmodjs/core/testing.js'
|
|
12
|
-
import {
|
|
12
|
+
import { myMod } from '../src/mod.js'
|
|
13
13
|
|
|
14
14
|
test('/todo adds the item to the project list', async () => {
|
|
15
|
-
const tested = testMod(
|
|
15
|
+
const tested = testMod(myMod)
|
|
16
16
|
|
|
17
17
|
expect(await tested.type('/todo buy milk')).toEqual({ text: 'Added: buy milk', note: 'The to-do list is now: buy milk' })
|
|
18
18
|
expect(tested.state.project.items).toEqual(['buy milk'])
|
|
@@ -98,11 +98,11 @@ Starts the mod: loads its state, runs `setup`, and adds its listeners, pages, pa
|
|
|
98
98
|
- `raise.beforeTurnEnd({ answer?, failure? })` asks about the open turn ending. It rejects when no turn is open: add a `Prompt` first.
|
|
99
99
|
- `raise.beforeContextEnd()` asks about a compaction of the open context, and resolves with the mod's answer, such as `{ summary }`. `{ task }` asks about the compaction of a task's context, a task `tested.startTask` started.
|
|
100
100
|
- `raise.beforeSessionStart({ source: 'compact' })` asks about the main agent's compaction. `{ source: 'compact', task }` asks about a subagent's, which only `sessions.current.goal.beforeSessionStart` hears.
|
|
101
|
-
- A `note` that `raise` returns is the mod's own text. What Claude Code receives, as `claudeCodeOf(tested).fire` shows it, holds the note inside the mod's tag, such as `<
|
|
101
|
+
- A `note` that `raise` returns is the mod's own text. What Claude Code receives, as `claudeCodeOf(tested).fire` shows it, holds the note inside the mod's tag, such as `<my-mod_mod>…</my-mod_mod>`.
|
|
102
102
|
|
|
103
103
|
```ts
|
|
104
104
|
test('a force push is refused', async () => {
|
|
105
|
-
const tested = testMod(
|
|
105
|
+
const tested = testMod(myMod)
|
|
106
106
|
await tested.add({ type: Prompt, text: 'Push it' })
|
|
107
107
|
|
|
108
108
|
expect(await tested.raise.beforeToolCall({ name: 'Bash', input: { command: 'git push --force' } })).toEqual({ refuse: 'Force pushes rewrite shared history.' })
|
|
@@ -133,10 +133,10 @@ expect(await tested.fire('cmod.call', { to: 'safe-delete', method: 'restore', in
|
|
|
133
133
|
```ts
|
|
134
134
|
import { expect, test } from 'bun:test'
|
|
135
135
|
import { testMod } from '../node_modules/@cmodjs/core/testing.js'
|
|
136
|
-
import {
|
|
136
|
+
import { myMod } from '../src/mod.js'
|
|
137
137
|
|
|
138
138
|
test('a force push is denied with the reason', async () => {
|
|
139
|
-
const tested = testMod(
|
|
139
|
+
const tested = testMod(myMod)
|
|
140
140
|
|
|
141
141
|
const answer = await tested.fire('tool.check', { tool: 'Bash', input: { command: 'git push --force' }, tool_use_id: 'toolu_1' }, { decision: 'allow' })
|
|
142
142
|
|
|
@@ -151,8 +151,8 @@ A mod that adds a note to the prompts about a release answers `beforePrompt`, an
|
|
|
151
151
|
```ts
|
|
152
152
|
import { defineMod, sessions } from '../node_modules/@cmodjs/core/mod.js'
|
|
153
153
|
|
|
154
|
-
export const
|
|
155
|
-
name: '
|
|
154
|
+
export const myMod = defineMod({
|
|
155
|
+
name: 'my-mod',
|
|
156
156
|
setup() {
|
|
157
157
|
sessions.current.beforePrompt({ text: /\brelease\b/i }, () => ({ note: 'Run bun run release, then push the tag.' }))
|
|
158
158
|
},
|
|
@@ -162,10 +162,10 @@ export const release = defineMod({
|
|
|
162
162
|
```ts
|
|
163
163
|
import { expect, test } from 'bun:test'
|
|
164
164
|
import { testMod } from '../node_modules/@cmodjs/core/testing.js'
|
|
165
|
-
import {
|
|
165
|
+
import { myMod } from '../src/mod.js'
|
|
166
166
|
|
|
167
167
|
test('a prompt about a release gets the release steps, and another prompt gets nothing', async () => {
|
|
168
|
-
const tested = testMod(
|
|
168
|
+
const tested = testMod(myMod)
|
|
169
169
|
|
|
170
170
|
expect(await tested.raise.beforePrompt({ text: 'Cut a release' })).toEqual({ note: 'Run bun run release, then push the tag.' })
|
|
171
171
|
expect(await tested.raise.beforePrompt({ text: 'Fix the bug' })).toBeUndefined()
|
|
@@ -194,10 +194,10 @@ The `sessions` option gives the earlier conversations, each a `FakeSession`: an
|
|
|
194
194
|
import { expect, test } from 'bun:test'
|
|
195
195
|
import { Prompt, Reply } from '../node_modules/@cmodjs/core/mod.js'
|
|
196
196
|
import { testMod } from '../node_modules/@cmodjs/core/testing.js'
|
|
197
|
-
import {
|
|
197
|
+
import { myMod } from '../src/mod.js'
|
|
198
198
|
|
|
199
199
|
test('/recall finds the earlier session about the deploy', async () => {
|
|
200
|
-
const tested = testMod(
|
|
200
|
+
const tested = testMod(myMod, { sessions: [{ id: 'older', title: 'Fix the deploy', messages: [{ type: Prompt, text: 'Why did the deploy fail?' }] }] })
|
|
201
201
|
await tested.add({ type: Prompt, text: 'Recall the deploy' })
|
|
202
202
|
await tested.add({ type: Reply, text: 'Looking.' })
|
|
203
203
|
await tested.endTurn()
|
|
@@ -212,10 +212,10 @@ A `before` listener on the current session answers what `raise` asks, such as `t
|
|
|
212
212
|
|
|
213
213
|
### lines
|
|
214
214
|
|
|
215
|
-
- `shown.page.lines()` draws the page the mod shows in the Sidebar now, and `shown.pane.lines()` the pane it shows now, and each returns its rows of text. Each rejects when the mod shows none, such as `No pane of
|
|
215
|
+
- `shown.page.lines()` draws the page the mod shows in the Sidebar now, and `shown.pane.lines()` the pane it shows now, and each returns its rows of text. Each rejects when the mod shows none, such as `No pane of my-mod shows. Open one with pane.open(), from a slash command, a hotkey, or setup.` A page gets `params`, `isFocused`, and `columns`, 80 unless `lines({ columns })` gives another. A pane gets `params`, `title`, `isFocused`, true once an `open` or `toggle` with `{ focus: true }` opened it, `bodyColumns`, which is the `columns` that `lines({ columns })` gives, else the pane's own `columns`, else 80, `placement: 'dock'`, `scroll: { offset: 0, bodyRows: 24 }`, and `view: {}`. `shown.page.id` and `shown.pane.id` name what shows, and `params` holds its params.
|
|
216
216
|
- A `Markdown` element in the mod's pages, panes, and widgets draws through the mod's own markdown styles, as it does in a session. Other mods' styles are not drawn.
|
|
217
217
|
- A key in a page or widget draws as the cmod plugin gives it to Claude Code: `<mod>/<page>:<key>` in a page, `<mod>/<widget>:<key>` in a widget, and `<mod>/markdown:<scope>:<block>:<key>` in what a markdown style draws, where `<scope>` is the drawn key of the `Markdown` element that holds the block, or its place among the `Markdown` elements without a key, and `<block>` is the block's number in that element's markdown, each from `0`. In the mod's own pane, a style's key draws as `<scope>:<block>:<key>`, and in a reply as `<block>:<key>`. `press`, `input`, and `select` take the key the mod wrote, and a key two blocks share reaches the first.
|
|
218
|
-
- Claude Code refuses a whole tree in which two `Input`, `Select`, `Markdown`, `Client`, `Raster`, or `Image` elements have one key, anywhere in it, and a refused Sidebar draws blank for the session. So drawing a page, a pane, a widget area, or a style that does it rejects with Claude Code's own text, such as `cmod: returned a tree Pane refuses: Markdown "
|
|
218
|
+
- Claude Code refuses a whole tree in which two `Input`, `Select`, `Markdown`, `Client`, `Raster`, or `Image` elements have one key, anywhere in it, and a refused Sidebar draws blank for the session. So drawing a page, a pane, a widget area, or a style that does it rejects with Claude Code's own text, such as `cmod: returned a tree Pane refuses: Markdown "my-mod/all:item-text:0" is drawn twice; each takes its own key`. Elements of different types, such as a `Box` and a `Markdown`, may share a key. Claude Code also refuses a `Box`, `Text`, or `Button` whose `hover` names no `scope` and has no `Box` with a key around it, the `Box` itself included, so drawing one rejects with `cmod: returned a tree Pane refuses: Button "my-mod/all:archive" hover has no Box with a key around it; the nearest keyed Box is what the pointer hovers, or a scope names its group`.
|
|
219
219
|
- A `Button` draws as Claude Code draws it: `[ Save ]`, or `1: Save` when it is `plain` with a `hotkey`, or `Save` when it is `plain` alone. Borders and colors are not drawn.
|
|
220
220
|
- `lines(area)` draws the mod's widgets in that area, in the rows the person would see, and returns them. A new widget is in the first row of its first area. A layout given in `files` as `/test/home/.local/share/cmod/widgets.json` places the widgets another way. `{ columns }` sets the row's width, 80 by default. `lines(TurnEnd)` draws under the last turn that ended, and rejects when none has: end one with `tested.endTurn()` first.
|
|
221
221
|
- `lines(kind, props, requestId?)` draws the mod's style of that kind with `props` and returns its rows. `Default` draws a plain listing of the props it gets, so a test sees what the style changed. Draw `Reply` with a reply's `text` to test a markdown style. Draws that pass one `requestId` grow one streamed reply.
|
|
@@ -224,10 +224,10 @@ A `before` listener on the current session answers what `raise` asks, such as `t
|
|
|
224
224
|
import { expect, test } from 'bun:test'
|
|
225
225
|
import { BelowPrompt, Prompt } from '../node_modules/@cmodjs/core/mod.js'
|
|
226
226
|
import { testMod } from '../node_modules/@cmodjs/core/testing.js'
|
|
227
|
-
import {
|
|
227
|
+
import { myMod } from '../src/mod.js'
|
|
228
228
|
|
|
229
229
|
test('the prompt count shows below the prompt', async () => {
|
|
230
|
-
const tested = testMod(
|
|
230
|
+
const tested = testMod(myMod)
|
|
231
231
|
await tested.add({ type: Prompt, text: 'hello' })
|
|
232
232
|
|
|
233
233
|
expect(await tested.lines(BelowPrompt)).toEqual(['Prompts: 1'])
|
|
@@ -333,16 +333,16 @@ Set a fake to answer a call:
|
|
|
333
333
|
- `tool.call` answers `CronCreate`, `CronDelete`, and `CronList` by default, keeping the crons a `schedule` makes in `shown.schedules`. A call to any other tool needs a fake.
|
|
334
334
|
- `files` takes symbolic links too: `testMod(mod, { files, links: { '/work/skills': '/shared/skills' } })` makes `/work/skills` a link to `/shared/skills`, so a test of `fs.find` or `metadata.update` follows it as a real file system does.
|
|
335
335
|
- `testMod` opens no install page: an option with no default and no value fails `start()` with its fix, and the `installer` steps are not shown. Test a step's `render` and `isDone` by calling them with the started `mod`.
|
|
336
|
-
- The
|
|
336
|
+
- The mod below runs `git`, and the `process.run` fake answers in its place.
|
|
337
337
|
|
|
338
338
|
```ts
|
|
339
339
|
import { expect, test } from 'bun:test'
|
|
340
340
|
import { Prompt } from '../node_modules/@cmodjs/core/mod.js'
|
|
341
341
|
import { testMod } from '../node_modules/@cmodjs/core/testing.js'
|
|
342
|
-
import {
|
|
342
|
+
import { myMod } from '../src/mod.js'
|
|
343
343
|
|
|
344
344
|
test('a Commit answer commits', async () => {
|
|
345
|
-
const tested = testMod(
|
|
345
|
+
const tested = testMod(myMod)
|
|
346
346
|
tested.fakes.ui.ask = async () => 'Commit'
|
|
347
347
|
tested.fakes.process.run = async () => ({ exitCode: 0, stdout: '', stderr: '', isStdoutTruncated: false, isStderrTruncated: false })
|
|
348
348
|
|
|
@@ -390,7 +390,7 @@ The test kit keeps no Log, as a cmod older than 4.3.0 keeps none, so every error
|
|
|
390
390
|
|
|
391
391
|
```ts
|
|
392
392
|
test('the Mode prompt follows the mode', async () => {
|
|
393
|
-
const tested = testMod(
|
|
393
|
+
const tested = testMod(myMod)
|
|
394
394
|
await tested.fire('prompt.context', { blocks: [] }, { blocks: [] })
|
|
395
395
|
|
|
396
396
|
tested.state.session.mode = 'build'
|
package/docs/ui.md
CHANGED
|
@@ -167,8 +167,8 @@ import { notesPage, type NotesState } from './pages/notes.js'
|
|
|
167
167
|
|
|
168
168
|
const initialState: NotesState = { global: { notes: [] } }
|
|
169
169
|
|
|
170
|
-
export const
|
|
171
|
-
name: '
|
|
170
|
+
export const myMod = defineMod({
|
|
171
|
+
name: 'my-mod',
|
|
172
172
|
state: initialState,
|
|
173
173
|
hotkeys: {
|
|
174
174
|
toggle: { title: 'Show or hide the notes', default: 'alt+shift+n' },
|
|
@@ -312,8 +312,8 @@ This mod places a path on the left of the row below the prompt, and its usage, b
|
|
|
312
312
|
import { BelowPrompt, defineMod } from '../node_modules/@cmodjs/core/mod.js'
|
|
313
313
|
import { Text } from '../node_modules/@cmodjs/core/ui/elements.js'
|
|
314
314
|
|
|
315
|
-
export const
|
|
316
|
-
name: '
|
|
315
|
+
export const myMod = defineMod({
|
|
316
|
+
name: 'my-mod',
|
|
317
317
|
state: { session: { path: '', usage: '', branch: '', time: '', date: '' } },
|
|
318
318
|
setup(mod) {
|
|
319
319
|
mod.widgets.add({ id: 'path', title: 'Path', areas: [BelowPrompt], place: { size: 'fill' }, render: (current) => <Text wrap="truncate-end">{current.state.session.path}</Text> })
|
|
@@ -367,8 +367,8 @@ The rows a style changes:
|
|
|
367
367
|
import { defineMod, sessions, TurnEnd } from '../node_modules/@cmodjs/core/mod.js'
|
|
368
368
|
import { Box, Text } from '../node_modules/@cmodjs/core/ui/elements.js'
|
|
369
369
|
|
|
370
|
-
export const
|
|
371
|
-
name: '
|
|
370
|
+
export const myMod = defineMod({
|
|
371
|
+
name: 'my-mod',
|
|
372
372
|
state: { session: { turns: 0 } },
|
|
373
373
|
setup(mod) {
|
|
374
374
|
mod.styles.add({
|
|
@@ -415,8 +415,8 @@ function MermaidBlock({ lang, value, Default }: StyleProps<typeof CodeBlock>): J
|
|
|
415
415
|
return lang === 'mermaid' ? <Text>{`diagram: ${value}`}</Text> : <Default />
|
|
416
416
|
}
|
|
417
417
|
|
|
418
|
-
export const
|
|
419
|
-
name: '
|
|
418
|
+
export const myMod = defineMod({
|
|
419
|
+
name: 'my-mod',
|
|
420
420
|
setup(mod) {
|
|
421
421
|
mod.styles.add({ kind: CodeBlock, render: (_mod, props) => <MermaidBlock {...props} /> })
|
|
422
422
|
},
|
|
@@ -496,8 +496,8 @@ type AskOptions = { options?: readonly string[]; header?: string; multiSelect?:
|
|
|
496
496
|
```ts
|
|
497
497
|
import { defineMod, process, sessions } from '../node_modules/@cmodjs/core/mod.js'
|
|
498
498
|
|
|
499
|
-
export const
|
|
500
|
-
name: '
|
|
499
|
+
export const myMod = defineMod({
|
|
500
|
+
name: 'my-mod',
|
|
501
501
|
setup(mod) {
|
|
502
502
|
sessions.current.onTurnEnd(async () => {
|
|
503
503
|
const answer = await mod.ask('Commit the changes?', { options: ['Commit', 'Wait'], header: 'Commit' })
|
package/package.json
CHANGED
package/records.d.ts
CHANGED
|
@@ -160,7 +160,7 @@ export declare function newestLog(entries: readonly LogEntry[]): LogEntry[];
|
|
|
160
160
|
export declare function versionsLine({ mod, core, cmod, program, claudeCode }: LogVersions): string;
|
|
161
161
|
export declare function logReport(entry: LogEntry): string;
|
|
162
162
|
export declare function parseConsent(value: unknown, path: string): Record<string, string[]>;
|
|
163
|
-
export declare const coreVersion = "6.0.
|
|
163
|
+
export declare const coreVersion = "6.0.2";
|
|
164
164
|
export declare const oldestCmodVersion = "6.0.0";
|
|
165
165
|
export declare function hotkeyCommand(mod: string, hotkey: string): string;
|
|
166
166
|
export declare function hotkeyBindings(mod: string, hotkeys: Hotkeys | undefined): Record<string, string>;
|
package/records.js
CHANGED
|
@@ -360,7 +360,7 @@ function readHotkeys(hotkeys) {
|
|
|
360
360
|
throw new Error(`package.json "cmod.hotkeys" is not a map of hotkeys to their title and optional default combo. ${fix}`);
|
|
361
361
|
return { hotkeys: checkHotkeys('package.json "cmod"', hotkeys) };
|
|
362
362
|
}
|
|
363
|
-
export const coreVersion = '6.0.
|
|
363
|
+
export const coreVersion = '6.0.2';
|
|
364
364
|
export const oldestCmodVersion = '6.0.0';
|
|
365
365
|
export function hotkeyCommand(mod, hotkey) {
|
|
366
366
|
return `${mod}--${hotkey}`;
|
package/runtime/ui.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ui.d.ts","sourceRoot":"","sources":["../src/runtime/ui.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,YAAY,E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E,QAAQ,GAAG,CAAC,CAAC,KAAK,EAAE,aAAa,KAAK,aAAa,CAAC,GAAG,SAAS,CAAA;IACpG,QAAQ,CAAC,OAAO,EAAE,SAAS,MAAM,EAAE,GAAG,IAAI,CAAA;IAC1C,OAAO,IAAI,IAAI,CAAA;IACf,OAAO,IAAI,IAAI,CAAA;IACf,YAAY,IAAI,OAAO,CAAC,IAAI,CAAC,CAAA;CAC9B,CAAA;AAED,eAAO,MAAM,cAAc,MAAM,CAAA;AAEjC,wBAAgB,QAAQ,CAAC,KAAK,SAAS,MAAM,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,GAAG,EAAE,QAAQ,EAAE,QAAQ,EAAE,EAAE,SAAS,CAAC,KAAK,CAAC,GAAG,MAAM,CAAC,KAAK,CAAC,CA8jBnJ"}
|
package/runtime/ui.js
CHANGED
|
@@ -4,7 +4,7 @@ import { Box, drawKeyed, drawsFocusable, drawWith, elementData, Markdown, Text }
|
|
|
4
4
|
import { checkPane, checkPart, sizeKeys } from '../ui/panes.js';
|
|
5
5
|
import { componentOf, nameOf } from '../ui/styles.js';
|
|
6
6
|
import { messageOf } from '../utils/text.js';
|
|
7
|
-
import { cmodPluginName } from './dependencies.js';
|
|
7
|
+
import { cmodPluginName, isStillInstalling } from './dependencies.js';
|
|
8
8
|
export const partMethods = {
|
|
9
9
|
list: 'cmod:parts',
|
|
10
10
|
draw: 'cmod:draw',
|
|
@@ -233,7 +233,10 @@ export function createUi({ name, claude, router, report, announce, mod, borrowed
|
|
|
233
233
|
unheldRequests += 1;
|
|
234
234
|
if (isObject(answer) && name !== cmodPluginName)
|
|
235
235
|
hear(answer['stylers'], false);
|
|
236
|
-
}, (error) =>
|
|
236
|
+
}, (error) => {
|
|
237
|
+
if (!isStillInstalling(cmodPluginName, error))
|
|
238
|
+
claude.ui.warn('parts:tell', `${name}: the cmod plugin did not hear about its pages and widgets: ${messageOf(error)}`);
|
|
239
|
+
});
|
|
237
240
|
};
|
|
238
241
|
if (!isAsked)
|
|
239
242
|
return Promise.resolve().then(tell);
|
package/src/records.ts
CHANGED
|
@@ -435,7 +435,7 @@ function readHotkeys(hotkeys: unknown): Steps {
|
|
|
435
435
|
return { hotkeys: checkHotkeys('package.json "cmod"', hotkeys as Record<string, HotkeyInit>) }
|
|
436
436
|
}
|
|
437
437
|
|
|
438
|
-
export const coreVersion = '6.0.
|
|
438
|
+
export const coreVersion = '6.0.2'
|
|
439
439
|
|
|
440
440
|
export const oldestCmodVersion = '6.0.0'
|
|
441
441
|
|
package/src/runtime/ui.ts
CHANGED
|
@@ -9,7 +9,7 @@ import { componentOf, nameOf, type Kind, type Style, type StyledAt, type StyleIn
|
|
|
9
9
|
import type { Subscription } from '../utils/subscription.js'
|
|
10
10
|
import { messageOf } from '../utils/text.js'
|
|
11
11
|
import type { Claude } from './claude.js'
|
|
12
|
-
import { cmodPluginName } from './dependencies.js'
|
|
12
|
+
import { cmodPluginName, isStillInstalling } from './dependencies.js'
|
|
13
13
|
import type { Router } from './router.js'
|
|
14
14
|
import type { Failure } from './toaster.js'
|
|
15
15
|
|
|
@@ -316,7 +316,9 @@ export function createUi<State extends object>({ name, claude, router, report, a
|
|
|
316
316
|
if (isAsked && input.requests !== undefined && !(isObject(answer) && answer['isHeld'] === true)) unheldRequests += 1
|
|
317
317
|
if (isObject(answer) && name !== cmodPluginName) hear(answer['stylers'], false)
|
|
318
318
|
},
|
|
319
|
-
(error: unknown) =>
|
|
319
|
+
(error: unknown) => {
|
|
320
|
+
if (!isStillInstalling(cmodPluginName, error)) claude.ui.warn('parts:tell', `${name}: the cmod plugin did not hear about its pages and widgets: ${messageOf(error)}`)
|
|
321
|
+
},
|
|
320
322
|
)
|
|
321
323
|
}
|
|
322
324
|
if (!isAsked) return Promise.resolve().then(tell)
|