@cmodjs/core 6.3.0 → 8.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/docs/commands.md +123 -65
- package/docs/dependencies.md +189 -4
- package/docs/index.md +56 -12
- package/docs/install-steps.md +20 -17
- package/docs/jobs.md +43 -16
- package/docs/mod.md +43 -27
- package/docs/options.md +2 -2
- package/docs/session.md +58 -32
- package/docs/testing.md +88 -24
- package/docs/ui.md +128 -58
- package/installer.d.ts +2 -2
- package/jobs/context.js +1 -1
- package/jobs/program.d.ts +4 -1
- package/jobs/program.d.ts.map +1 -1
- package/jobs/program.js +79 -20
- package/mod.d.ts +59 -9
- package/mod.d.ts.map +1 -1
- package/mod.js +5 -3
- package/package.json +1 -1
- package/records.d.ts +15 -2
- package/records.d.ts.map +1 -1
- package/records.js +24 -10
- package/register.d.ts.map +1 -1
- package/register.js +7 -4
- package/rpc.d.ts +7 -0
- package/rpc.d.ts.map +1 -0
- package/rpc.js +59 -0
- package/runtime/bound.d.ts +1 -0
- package/runtime/bound.d.ts.map +1 -1
- package/runtime/bound.js +10 -0
- package/runtime/bun.d.ts +20 -0
- package/runtime/bun.d.ts.map +1 -0
- package/runtime/bun.js +20 -0
- package/runtime/claude.d.ts +1 -0
- package/runtime/claude.d.ts.map +1 -1
- package/runtime/conversations.d.ts +12 -1
- package/runtime/conversations.d.ts.map +1 -1
- package/runtime/conversations.js +472 -362
- package/runtime/deadline.d.ts +4 -3
- package/runtime/deadline.d.ts.map +1 -1
- package/runtime/deadline.js +10 -4
- package/runtime/engine.d.ts +5 -4
- package/runtime/engine.d.ts.map +1 -1
- package/runtime/installer.d.ts +3 -3
- package/runtime/installer.d.ts.map +1 -1
- package/runtime/installer.js +10 -9
- package/runtime/interfaces.d.ts +262 -0
- package/runtime/interfaces.d.ts.map +1 -0
- package/runtime/interfaces.js +935 -0
- package/runtime/lifecycle.d.ts +3 -3
- package/runtime/lifecycle.d.ts.map +1 -1
- package/runtime/lifecycle.js +83 -52
- package/runtime/options.d.ts.map +1 -1
- package/runtime/options.js +2 -6
- package/runtime/parts.d.ts +64 -1
- package/runtime/parts.d.ts.map +1 -1
- package/runtime/parts.js +311 -4
- package/runtime/programs.d.ts +1 -0
- package/runtime/programs.d.ts.map +1 -1
- package/runtime/programs.js +5 -3
- package/runtime/rpc.d.ts +111 -0
- package/runtime/rpc.d.ts.map +1 -0
- package/runtime/rpc.js +387 -0
- package/runtime/sessions.d.ts +6 -4
- package/runtime/sessions.d.ts.map +1 -1
- package/runtime/sessions.js +59 -80
- package/runtime/toaster.js +1 -1
- package/runtime/ui.d.ts +23 -10
- package/runtime/ui.d.ts.map +1 -1
- package/runtime/ui.js +63 -52
- package/runtime/web.d.ts +0 -73
- package/runtime/web.d.ts.map +1 -1
- package/runtime/web.js +9 -5
- package/runtime/widgets.d.ts +4 -2
- package/runtime/widgets.d.ts.map +1 -1
- package/runtime/widgets.js +17 -16
- package/session/conversation.d.ts +7 -1
- package/session/conversation.d.ts.map +1 -1
- package/session/session.d.ts +31 -7
- package/session/session.d.ts.map +1 -1
- package/session/session.js +1 -0
- package/src/installer.ts +2 -2
- package/src/jobs/context.ts +1 -1
- package/src/jobs/program.ts +76 -21
- package/src/mod.ts +51 -10
- package/src/records.ts +33 -9
- package/src/register.ts +7 -4
- package/src/rpc.ts +67 -0
- package/src/runtime/bound.ts +10 -0
- package/src/runtime/bun.ts +40 -0
- package/src/runtime/claude.ts +1 -0
- package/src/runtime/conversations.ts +470 -352
- package/src/runtime/deadline.ts +13 -6
- package/src/runtime/engine.ts +5 -4
- package/src/runtime/installer.ts +13 -12
- package/src/runtime/interfaces.ts +1161 -0
- package/src/runtime/lifecycle.ts +102 -59
- package/src/runtime/options.ts +2 -5
- package/src/runtime/parts.ts +364 -5
- package/src/runtime/programs.ts +6 -3
- package/src/runtime/rpc.ts +457 -0
- package/src/runtime/sessions.ts +63 -83
- package/src/runtime/toaster.ts +1 -1
- package/src/runtime/ui.ts +82 -61
- package/src/runtime/web.ts +10 -39
- package/src/runtime/widgets.ts +20 -18
- package/src/session/conversation.ts +7 -1
- package/src/session/session.ts +22 -7
- package/src/testing/fake-claude.ts +38 -7
- package/src/testing/fake-serve.ts +144 -0
- package/src/testing/fake-sessions.ts +21 -6
- package/src/testing.ts +156 -68
- package/src/ui/areas.ts +2 -2
- package/src/ui/elements.ts +21 -16
- package/src/ui/panes.ts +14 -7
- package/testing/fake-claude.d.ts +6 -0
- package/testing/fake-claude.d.ts.map +1 -1
- package/testing/fake-claude.js +34 -7
- package/testing/fake-serve.d.ts +39 -0
- package/testing/fake-serve.d.ts.map +1 -0
- package/testing/fake-serve.js +110 -0
- package/testing/fake-sessions.d.ts.map +1 -1
- package/testing/fake-sessions.js +22 -6
- package/testing.d.ts +21 -4
- package/testing.d.ts.map +1 -1
- package/testing.js +138 -56
- package/ui/areas.d.ts +3 -1
- package/ui/areas.d.ts.map +1 -1
- package/ui/elements.d.ts +18 -9
- package/ui/elements.d.ts.map +1 -1
- package/ui/elements.js +9 -8
- package/ui/panes.d.ts +10 -6
- package/ui/panes.d.ts.map +1 -1
- package/ui/panes.js +5 -3
- package/runtime/pages.d.ts +0 -32
- package/runtime/pages.d.ts.map +0 -1
- package/runtime/pages.js +0 -142
- package/src/runtime/pages.ts +0 -183
package/docs/jobs.md
CHANGED
|
@@ -8,7 +8,7 @@ mod.use<Handle>(job: Job<Handle, State>): Handle
|
|
|
8
8
|
type Job<Handle, State> = (context: JobContext<State>) => Handle
|
|
9
9
|
```
|
|
10
10
|
|
|
11
|
-
Each job function, such as `slashCommand(options)`, returns a `Job`. `mod.use` runs the job and returns its handle.
|
|
11
|
+
Each job function, such as `slashCommand(options)`, returns a `Job`. `mod.use` runs the job and returns its handle. `permissions`, `check`, `prompt`, and `schedule` hand back a `Subscription`, whose `remove()` takes the job's feature away.
|
|
12
12
|
|
|
13
13
|
A job's bad options throw at one of two times. `check`, `permissions`, `prompt`, and `schedule` check their options when the job function is called. `slashCommand`, `tool`, and `program` check theirs when the job runs, at `mod.use`, so the error surfaces as `its setup function threw: …`.
|
|
14
14
|
|
|
@@ -51,7 +51,7 @@ slashCommand<State>(options: {
|
|
|
51
51
|
readonly reply: (input: { args: string; positionals: string[] }, mod: Mod<State>) => CommandReply | void | Promise<CommandReply | void>
|
|
52
52
|
}): Job<SlashCommand, State>
|
|
53
53
|
|
|
54
|
-
type CommandReply = string | { text?: string;
|
|
54
|
+
type CommandReply = string | { text?: string; note?: string } | undefined
|
|
55
55
|
type SlashCommand = { readonly name: string; remove(): void }
|
|
56
56
|
```
|
|
57
57
|
|
|
@@ -60,10 +60,10 @@ type SlashCommand = { readonly name: string; remove(): void }
|
|
|
60
60
|
- `argumentHint` is drawn dim after the name, such as `[path]`.
|
|
61
61
|
- `immediate: true` runs the command at once while Claude is still working. Without it, the command waits for the turn to end.
|
|
62
62
|
- A command lasts for the session. Adding a command with a name the session already has replaces it, and Claude Code has no call that removes one, so a command whose source is gone answers that it no longer applies. `remove()` on the handle stops the mod answering the command.
|
|
63
|
-
- A command's `reply` runs inside the person's own input, so a page or pane it opens shows at any width ([ui.md](ui.md#
|
|
63
|
+
- A command's `reply` runs inside the person's own input, so a view, page, or pane it opens shows at any width ([ui.md](ui.md#views-and-pages)).
|
|
64
64
|
- A key combo is a hotkey, not a command ([mod.md](mod.md#hotkeys)).
|
|
65
65
|
- `reply` gets `args` and `positionals`. `args` is everything after the name as Claude Code passes it, and `''` for a bare `/<name>`. cmod hands it on unchanged. `positionals` is that text split into words the way a shell splits them, so extra spaces never reach it. `tested.type('/todo milk')` drops the spaces after the name.
|
|
66
|
-
- A `string` reply, or `text`, shows as the command's output. `
|
|
66
|
+
- A `string` reply, or `text`, shows as the command's output. `note` is text Claude reads after the output, inside the mod's tag, and the person never sees. `undefined` shows nothing.
|
|
67
67
|
- A `reply` that throws shows `/<name> failed: <error>`.
|
|
68
68
|
- Two commands with one name in a mod throw `<mod>: the slash command /<name> is already added. Give each slashCommand its own name.`
|
|
69
69
|
- When Claude Code refuses to add the command, cmod logs `<mod>: /<name> is not added: <error>`.
|
|
@@ -83,7 +83,7 @@ export const myMod = defineMod({
|
|
|
83
83
|
argumentHint: '<item>',
|
|
84
84
|
reply: ({ args }, mod) => {
|
|
85
85
|
mod.state.project.items = [...mod.state.project.items, args]
|
|
86
|
-
return { text: `Added: ${args}`,
|
|
86
|
+
return { text: `Added: ${args}`, note: `The to-do list is now: ${mod.state.project.items.join(', ')}` }
|
|
87
87
|
},
|
|
88
88
|
}),
|
|
89
89
|
)
|
|
@@ -172,7 +172,7 @@ A `command` pattern is not a glob. cmod splits it into words the way it splits a
|
|
|
172
172
|
A `deny` rule works in every mod. An `ask` rule needs `"approve": true` in `package.json` `"cmod"`, because `cmod publish` leaves the code that asks out of the bundle of a mod without it ([commands.md](commands.md#cmod-publish)). `cmod check` adds the line when the mod has an `ask` rule.
|
|
173
173
|
|
|
174
174
|
```ts
|
|
175
|
-
permissions<State>(rules: PermissionRules<State> | ((state: State) => PermissionRules<State>)): Job<
|
|
175
|
+
permissions<State>(rules: PermissionRules<State> | ((state: State) => PermissionRules<State>)): Job<Subscription, State>
|
|
176
176
|
|
|
177
177
|
type PermissionRules<State> = { deny?: Rule<State>[]; ask?: Rule<State>[] }
|
|
178
178
|
|
|
@@ -227,7 +227,7 @@ export const myMod = defineMod({
|
|
|
227
227
|
## check
|
|
228
228
|
|
|
229
229
|
```ts
|
|
230
|
-
check<State>(options: { readonly after: Target | Target[]; readonly run: readonly string[]; readonly timeoutMs?: number }): Job<
|
|
230
|
+
check<State>(options: { readonly after: Target | Target[]; readonly run: readonly string[]; readonly timeoutMs?: number }): Job<Subscription, State>
|
|
231
231
|
```
|
|
232
232
|
|
|
233
233
|
- After each call that matches `after` and succeeds, cmod runs `run`. A call that was denied or failed runs nothing.
|
|
@@ -256,7 +256,7 @@ prompt<State>(options: {
|
|
|
256
256
|
name: string
|
|
257
257
|
prompt: string | ((input: { call?: Call & { folder: string } }, mod: Mod<State>) => string | undefined | Promise<string | undefined>)
|
|
258
258
|
after?: Target | Target[]
|
|
259
|
-
}): Job<
|
|
259
|
+
}): Job<Subscription, State>
|
|
260
260
|
```
|
|
261
261
|
|
|
262
262
|
`prompt` adds text that Claude reads. `after` picks when:
|
|
@@ -289,7 +289,7 @@ export const myMod = defineMod({
|
|
|
289
289
|
## schedule
|
|
290
290
|
|
|
291
291
|
```ts
|
|
292
|
-
schedule<State>(entry: ScheduledPrompt | ((state: State) => ScheduledPrompt | undefined)): Job<
|
|
292
|
+
schedule<State>(entry: ScheduledPrompt | ((state: State) => ScheduledPrompt | undefined)): Job<Subscription, State>
|
|
293
293
|
|
|
294
294
|
type ScheduledPrompt = { readonly cron: string; readonly prompt: string }
|
|
295
295
|
```
|
|
@@ -318,24 +318,29 @@ export const myMod = defineMod({
|
|
|
318
318
|
## program
|
|
319
319
|
|
|
320
320
|
```ts
|
|
321
|
-
program(options: { readonly command: readonly string[]; readonly environment?: Record<string, string>; readonly singleInstance?: boolean; readonly isService?: boolean; readonly isWebApp?: boolean }): Job<Program>
|
|
321
|
+
program(options: { readonly command: readonly string[]; readonly environment?: Record<string, string>; readonly singleInstance?: boolean; readonly isService?: boolean; readonly isWebApp?: boolean; readonly processType?: 'Interactive' | 'Background' }): Job<Program>
|
|
322
322
|
|
|
323
323
|
type Program = {
|
|
324
324
|
readonly state: 'stopped' | 'starting' | 'running' | 'backoff' | 'fatal'
|
|
325
325
|
ready(): Promise<{ url: string; socketPath?: string; tailnetUrl?: string }>
|
|
326
|
+
provider<Name extends InterfaceName>(name: Name): Promise<InterfaceProvider<Name>>
|
|
326
327
|
}
|
|
327
328
|
```
|
|
328
329
|
|
|
329
|
-
`program` runs a background program, such as a preview server, and hands the mod its address.
|
|
330
|
+
`program` runs a background program, such as a preview server, and hands the mod its address, or its provider of an interface.
|
|
330
331
|
|
|
331
332
|
- `command` is the program on `PATH` and its arguments. `environment` sets variables for it. An empty `command` throws.
|
|
332
333
|
- The program's first line on standard output must be its address: `127.0.0.1:<port>`, or `unix:<absolute socket path>`. `ready()` then resolves `{ url: 'http://127.0.0.1:<port>' }`, or `{ url: 'http://localhost', socketPath }`. Pass both to `http.fetch`, which reaches that address.
|
|
333
|
-
- In an interactive session the program starts with the mod. Otherwise it starts at the first `ready()`.
|
|
334
|
+
- In an interactive session the program starts with the mod. Otherwise it starts at the first `ready()` or `provider(name)`.
|
|
335
|
+
- The program has started once it prints its address, or, with `singleInstance` or `isService`, once it provides any interface through `connect()`. `state` is `'starting'` until then, and `'running'` after. Only an address resolves `ready()`, so once a program that only provides is running, `ready()` rejects with `<mod>: the <program> program printed no address, because it only provides interfaces. Reach them through provider(name).`
|
|
334
336
|
- When the program exits, cmod starts it again after 1, 2, 4, 8, and 16 seconds. After 5 failed tries, or a first line that is not an address, the state is `fatal`, `ready()` rejects, and cmod logs `<mod>: the <program> program stopped: <reason>`, which shows `The <program> program stopped` with `Retry` where the mod's errors toast ([ui.md](ui.md#toasts)).
|
|
335
|
-
- `singleInstance: true` runs one copy on the computer, however many sessions load the mod, such as a server that is the only writer of its data. The first session starts the copy through [`cmod program`](commands.md#cmod-program), every other session reads the copy's address from the cmod store and runs no process of its own, and every session's `ready()` resolves that copy's address. When the session running the copy ends, another open session starts a new copy within a few seconds, or within 20 seconds when the copy's session was killed with its `cmod program`, and from then on `ready()` resolves the new address in every session, so ask `ready()` before each use rather than keeping its answer. A copy a killed session left running is stopped before the new one starts. When cmod installs a new version of the mod, or builds a new program from its linked checkout, it stops the copy, whichever cmod started it, so the copy restarts on the new program a few seconds later, and `ready()` resolves the new copy's address. Two `singleInstance` programs with the same program name in one mod throw at `mod.use`.
|
|
336
|
-
- `isService: true` makes the program a service of the computer, so it runs whenever the person is logged in, with no Claude Code open, such as a program that records sessions Claude Code never sees. The first session that starts the mod has [`cmod program`](commands.md#cmod-program) write a launchd agent on macOS, or a systemd user service on Linux, which starts the program at login and again whenever it exits, with `environment`. The service's `PATH` is cmod's programs folder, `/usr/local/bin`, `/opt/homebrew/bin`, and the system folders, unless `environment` sets `PATH`, and its `CLAUDE_CODE_EXECPATH` names the session's Claude Code by the path its updates keep, so a `cmod` command the program runs, such as `cmod options`, finds Claude Code. Every session reads the service's address from the cmod store, as a `singleInstance` program's sessions do, and `ready()` resolves it. The service runs one copy, so `isService` needs no `singleInstance` beside it. The mod writes no service file: the service restarts on the new program when cmod installs a new version of the mod or builds a new program from its linked checkout, and cmod stops and deletes it when the mod is removed. When a new version's setup no longer adds the `isService` program, because it dropped `isService` or renamed the program, the first session that starts that version stops and deletes the old service, so the computer stops running a program the mod no longer ships. Settings shows `Runs as a service of this computer`
|
|
337
|
-
- `isWebApp: true` puts a program the person opens in a browser on their tailnet, so it opens from each of their
|
|
338
|
-
-
|
|
337
|
+
- `singleInstance: true` runs one copy on the computer, however many sessions load the mod, such as a server that is the only writer of its data. The first session starts the copy through [`cmod program`](commands.md#cmod-program), every other session reads the copy's address from the cmod store and runs no process of its own, and every session's `ready()` resolves that copy's address. When the session running the copy ends, another open session starts a new copy within a few seconds, or within 20 seconds when the copy's session was killed with its `cmod program`, and from then on `ready()` resolves the new address in every session, so ask `ready()` before each use rather than keeping its answer. The cmod store records the running copy's pid and start time, with its address once it prints one, or with no address once it provides an interface, for a program that only provides. A copy a killed session left running is stopped before the new one starts. When cmod installs a new version of the mod, or builds a new program from its linked checkout, it stops the recorded copy, whichever cmod started it, so the copy restarts on the new program a few seconds later, and `ready()` resolves the new copy's address, or `provider(name)` its provider. Two `singleInstance` programs with the same program name in one mod throw at `mod.use`.
|
|
338
|
+
- `isService: true` makes the program a service of the computer, so it runs whenever the person is logged in, with no Claude Code open, such as a program that records sessions Claude Code never sees. The first session that starts the mod has [`cmod program`](commands.md#cmod-program) write a launchd agent on macOS, or a systemd user service on Linux, which starts the program at login and again whenever it exits, with `environment`. The service's `PATH` is cmod's programs folder, `/usr/local/bin`, `/opt/homebrew/bin`, and the system folders, unless `environment` sets `PATH`, and its `CLAUDE_CODE_EXECPATH` names the session's Claude Code by the path its updates keep, so a `cmod` command the program runs, such as `cmod options get`, finds Claude Code. Every session reads the service's address from the cmod store, as a `singleInstance` program's sessions do, and `ready()` resolves it. The service runs one copy, so `isService` needs no `singleInstance` beside it. The mod writes no service file: the service restarts on the new program when cmod installs a new version of the mod or builds a new program from its linked checkout, and cmod stops and deletes it when the mod is removed. When a new version's setup no longer adds the `isService` program, because it dropped `isService` or renamed the program, the first session that starts that version stops and deletes the old service, so the computer stops running a program the mod no longer ships. Settings shows `Runs as a service of this computer` in the mod's entry, and [`cmod list`](commands.md#cmod-list) names the program. On a computer that does not take the service, such as a Linux device without a systemd user session, the program runs as a `singleInstance` program does. A service the computer took but could not start is removed, and the program fails with the service manager's error, as an exiting program does. A service whose program has not started within 15 seconds and no longer runs is removed the same way. On macOS the program's standard error goes to `services/<mod>/<program>.log` in the cmod store, which that error names, and on Linux to the systemd journal. Two `isService` programs with the same program name in one mod throw at `mod.use`.
|
|
339
|
+
- `isWebApp: true` puts a program the person opens in a browser on their tailnet, so it opens from each of their devices, with `singleInstance` or `isService` beside it, because the tailnet reaches one copy per computer. A web app with neither throws at `mod.use`. While Tailscale is signed in on the computer with HTTPS on, the program runs with `CMOD_TAILNET_NAME`, the computer's tailnet name, such as `my-computer.my-tailnet.ts.net`, and `CMOD_TAILNET_LOGIN`, the person's Tailscale login, and once it prints `127.0.0.1:<port>`, cmod runs `tailscale serve`, so `https://<CMOD_TAILNET_NAME>:<port>/` reaches it, and `ready()` resolves that address as `tailnetUrl`. The tailnet port stays the first port the program listened on, so the address stays the same when it listens on another port later. Tailscale forwards each request with its own `Host` and sets `Tailscale-User-Login` to the login of the person who sent it, replacing any the request carried. So the program answers a request through the tailnet only when the host name of its `Host` is `CMOD_TAILNET_NAME` and its `Tailscale-User-Login` is `CMOD_TAILNET_LOGIN`, because a work tailnet or a device someone shared reaches other people's devices. The program keeps listening on `127.0.0.1` only. cmod takes the program off the tailnet when it exits, stops and starts it again when the person turns `Open web apps from your other devices` in Settings, under cmod, Preferences, off or on, or when Tailscale becomes ready, which it checks every minute, and takes it off when the mod is removed. Without Tailscale, the program runs on `127.0.0.1` alone, and Settings shows the reason in the mod's entry, or its tailnet address when it is on the tailnet. A program that listens on a `unix:` socket stays off the tailnet.
|
|
340
|
+
- Every program runs with `CMOD_DATA` and `CMOD_CACHE`, the folders `mod.dataFolder` and `mod.cacheFolder` name, as an install step gets them ([install-steps.md](install-steps.md#how-a-step-runs)), so it keeps its files where its mod does without asking `cmod data`. A service gets the folders of the session that wrote it. A program with `singleInstance` or `isService` also runs with `CMOD_MOD`, the mod's name, and `CMOD_PROGRAM`, the program's, so it provides interfaces for every session on the computer: it calls `connect()` from `rpc.js`, then `provide` from `mod.js` ([dependencies.md](dependencies.md#interfaces-several-mods-answer-one-name)).
|
|
341
|
+
- `provider(name)` starts the program as `ready()` does, and resolves with this program's provider of `name` on this computer once the program provides it, typed from the interface as `providers` types it ([dependencies.md](dependencies.md#interfaces-several-mods-answer-one-name)). Another mod's program that provides the same name never answers it. It rejects as `ready()` rejects once the program is `fatal`. A program with neither `singleInstance` nor `isService` runs a copy per session, and only one copy of a program can provide an interface, so its `provider(name)` rejects at once with `<mod>: provider(<name>) needs the <program> program to run as singleInstance or isService, because only one copy of a program can provide an interface.` A program that only provides prints no address, so its mod waits for it with `provider(name)` instead of `ready()`. A provider that stops and provides again, such as a restarted service, is a new provider: a call on the old one fails with `<mod>'s <program> program does not run, so it answers no <interface>.`, and the mod asks `provider(name)` again, so ask it before each use rather than keeping its answer.
|
|
342
|
+
- `processType` gives a service its launchd class on macOS, with `isService` beside it. launchd throttles a service with none on a loaded Mac, so `'Interactive'` runs one a session waits on at the priority of an app, and `'Background'` runs one nobody waits on at the lowest. systemd has no such class, so a Linux service takes none. A `processType` without `isService`, or another value, throws at `mod.use`.
|
|
343
|
+
- A program that ships with the mod gets onto `PATH` through the `program` key of the mod's `package.json` ([install-steps.md](install-steps.md)). A program an install step fetched with `cmod download` runs by its name too, from cmod's programs folder ([install-steps.md](install-steps.md#run-a-program-by-its-name)).
|
|
339
344
|
|
|
340
345
|
```ts
|
|
341
346
|
import { defineMod, http } from '../node_modules/@cmodjs/core/mod.js'
|
|
@@ -361,6 +366,28 @@ export const myMod = defineMod({
|
|
|
361
366
|
})
|
|
362
367
|
```
|
|
363
368
|
|
|
369
|
+
A mod whose service only provides `demo/Platform` calls it through `provider`:
|
|
370
|
+
|
|
371
|
+
```ts
|
|
372
|
+
import { defineMod } from '../node_modules/@cmodjs/core/mod.js'
|
|
373
|
+
import { program } from '../node_modules/@cmodjs/core/jobs/program.js'
|
|
374
|
+
import { slashCommand } from '../node_modules/@cmodjs/core/jobs/slash-command.js'
|
|
375
|
+
|
|
376
|
+
export const myMod = defineMod({
|
|
377
|
+
name: 'my-mod',
|
|
378
|
+
setup(mod) {
|
|
379
|
+
const platform = mod.use(program({ command: ['platform-server'], isService: true }))
|
|
380
|
+
mod.use(
|
|
381
|
+
slashCommand({
|
|
382
|
+
name: 'machines',
|
|
383
|
+
description: 'List the machines in a region',
|
|
384
|
+
reply: async ({ args }) => (await (await platform.provider('demo/Platform')).machines(args)).join(', '),
|
|
385
|
+
}),
|
|
386
|
+
)
|
|
387
|
+
},
|
|
388
|
+
})
|
|
389
|
+
```
|
|
390
|
+
|
|
364
391
|
## Write a job of your own
|
|
365
392
|
|
|
366
393
|
A `Job` is a function. `mod.use` calls it with a `JobContext` and returns what it returns:
|
package/docs/mod.md
CHANGED
|
@@ -24,7 +24,7 @@ type ModDefinition<State, Name, Options, Hotkeys> = {
|
|
|
24
24
|
- `options` declares what a person sets, such as a token, and types `mod.options`. [options.md](options.md) explains them.
|
|
25
25
|
- `hotkeys` declares the key combos the mod listens for, each with a title and an optional default combo the person can change ([Hotkeys](#hotkeys)).
|
|
26
26
|
- `installer` lists the steps the person finishes in Claude Code after the options, such as signing in. [install-steps.md](install-steps.md#steps-in-claude-code) explains them.
|
|
27
|
-
- `setup` runs once when the mod starts. It adds listeners, pages, panes,
|
|
27
|
+
- `setup` runs once when the mod starts. It adds listeners, widgets, views, pages, panes, styles, and jobs. It may be `async`. What it returns is the mod's API: an object of methods other mods call. Return nothing for a mod that offers none. [dependencies.md](dependencies.md) explains it.
|
|
28
28
|
|
|
29
29
|
```tsx
|
|
30
30
|
import { defineMod, sessions } from '../node_modules/@cmodjs/core/mod.js'
|
|
@@ -45,9 +45,9 @@ export const myMod = defineMod({
|
|
|
45
45
|
|
|
46
46
|
## When setup runs
|
|
47
47
|
|
|
48
|
-
Claude Code loads the mod at the start of each session. cmod then checks that the mod is set up, and runs its install step when it is not, with a loading toast above the prompt ([install-steps.md](install-steps.md)). An option with no default and no value is asked on the mod's install
|
|
48
|
+
Claude Code loads the mod at the start of each session. cmod then checks that the mod is set up, and runs its install step when it is not, with a loading toast above the prompt ([install-steps.md](install-steps.md)). An option with no default and no value is asked on the mod's install view, the `Install <name>` tab of the Sidebar. Then cmod loads the saved state, runs `setup`, marks as open each of the mod's panes that Claude Code already shows, and opens the install view again for each `installer` step the mod declares that is not done.
|
|
49
49
|
|
|
50
|
-
The first time a mod starts on a
|
|
50
|
+
The first time a mod starts on a device, cmod shows the toast `Installed` under its name. Opened, it lists the mod's `plugin.json` `description`, what setup added, such as `Adds the my-mod pane, the Branch widget and /deploy.`, and what its install step set up, with a Settings button that opens Settings at the mod. A new version shows no toast of the mod's own: each running session keeps the version it loaded, and the cmod plugin's `Plugins changed` toast names `<mod> updated to <version>` with a Reload button ([commands.md](commands.md#install-mods)). A new session and `/reload-plugins` show no toast.
|
|
51
51
|
|
|
52
52
|
When a step fails, the mod stays stopped. Once another session sets it up, the mod starts at the next prompt of every session it stopped in, with no `/reload-plugins`.
|
|
53
53
|
|
|
@@ -151,6 +151,7 @@ type Mod<State, Options, Hotkeys> = {
|
|
|
151
151
|
readonly name: string
|
|
152
152
|
readonly folder: string
|
|
153
153
|
readonly dataFolder: string
|
|
154
|
+
readonly cacheFolder: string
|
|
154
155
|
readonly secrets: { get(key): Promise<string | undefined>; store(key, value): Promise<void>; delete(key): Promise<void> }
|
|
155
156
|
readonly state: Readonly<State>
|
|
156
157
|
readonly options: OptionValues<Options>
|
|
@@ -159,10 +160,11 @@ type Mod<State, Options, Hotkeys> = {
|
|
|
159
160
|
after(ms, listener): Timer
|
|
160
161
|
use(job): Handle
|
|
161
162
|
log(text, options?): void
|
|
162
|
-
readonly sidebar: { add(page): Page }
|
|
163
|
-
readonly settings: { add(page): Page; open(): Promise<void> }
|
|
164
|
-
readonly panes: { add(pane): Pane }
|
|
165
163
|
readonly widgets: { add(widget): Widget }
|
|
164
|
+
readonly views: { add(view): View }
|
|
165
|
+
readonly pages: { add(page): Page }
|
|
166
|
+
readonly settings: { add(view): View; open(): Promise<void> }
|
|
167
|
+
readonly panes: { add(pane): Pane }
|
|
166
168
|
readonly styles: { add(style): Style }
|
|
167
169
|
readonly toast: Toast
|
|
168
170
|
ask(question, options?): Promise<string>
|
|
@@ -172,7 +174,8 @@ type Mod<State, Options, Hotkeys> = {
|
|
|
172
174
|
|
|
173
175
|
- `name` is the mod's name from `defineMod`.
|
|
174
176
|
- `folder` is the plugin's own folder, where the files the mod ships live.
|
|
175
|
-
- `dataFolder` is the mod's own folder in the cmod store: `$XDG_DATA_HOME/cmod/data/<plugin name>`, or `~/.local/share/cmod/data/<plugin name>` when `XDG_DATA_HOME` is not set. The install step
|
|
177
|
+
- `dataFolder` is the mod's own folder in the cmod store: `$XDG_DATA_HOME/cmod/data/<plugin name>`, or `~/.local/share/cmod/data/<plugin name>` when `XDG_DATA_HOME` is not set. The install step and each `program` job's program get the same folder as `CMOD_DATA`. cmod deletes it when the mod is removed ([install-steps.md](install-steps.md)). It holds what the mod cannot rebuild, such as a chat history, and `cmod data` lists it so a person can move it to another computer ([commands.md](commands.md#cmod-data)).
|
|
178
|
+
- `cacheFolder` holds what the mod can rebuild, such as an index or a download: `$XDG_CACHE_HOME/cmod/<plugin name>`, or `~/.cache/cmod/<plugin name>` when `XDG_CACHE_HOME` is not set. The install step and each `program` job's program get the same folder as `CMOD_CACHE`, and `cmod download` puts each program it fetches in its `bin/`. cmod creates it with `dataFolder` before the install step, and deletes it with `dataFolder` when the mod is removed. Nothing copies it to another computer, so the mod builds it again wherever it is missing.
|
|
176
179
|
- `secrets` keeps the mod's own keys, such as a token it got from a sign-in, out of its files ([mod.secrets](#mod-secrets)).
|
|
177
180
|
- `state` holds the mod's values. Assign to a key to change it ([state.md](state.md)).
|
|
178
181
|
- `options` holds the values a person set for the mod's options, typed from their declaration. Read-only ([options.md](options.md)).
|
|
@@ -180,13 +183,13 @@ type Mod<State, Options, Hotkeys> = {
|
|
|
180
183
|
- `every` and `after` run a listener on a timer while the session runs.
|
|
181
184
|
- `use` adds a job, such as a slash command or a tool, and returns its handle ([jobs.md](jobs.md)).
|
|
182
185
|
- `log` writes a line, under the mod's name, to Claude Code's debug log.
|
|
183
|
-
- `
|
|
186
|
+
- `widgets`, `views`, `pages`, `settings`, `panes`, and `styles` add the mod's widgets, views, pages, views in Settings, panes, and styles. `toast` shows a short message and `ask` asks a question ([ui.md](ui.md)).
|
|
184
187
|
- `dependencies` calls the methods of other mods ([dependencies.md](dependencies.md)).
|
|
185
188
|
|
|
186
189
|
Everything that is Claude Code's or the computer's rather than the mod's is an import from `mod.js`, so a function in any file calls it without being handed `mod`:
|
|
187
190
|
|
|
188
191
|
```ts
|
|
189
|
-
import { clipboard, commands, config, device, fs, http, metadata, model, process, sessions, settings } from '../node_modules/@cmodjs/core/mod.js'
|
|
192
|
+
import { clipboard, commands, config, device, fs, http, metadata, model, process, providers, sessions, settings } from '../node_modules/@cmodjs/core/mod.js'
|
|
190
193
|
```
|
|
191
194
|
|
|
192
195
|
- `sessions` is the conversations: the one the mod runs in, every other one, and search across them. Everything that happens in a session, from a prompt to a permission dialog, is a method on it ([session.md](session.md)).
|
|
@@ -205,7 +208,7 @@ Each import works once the mod has started, in `setup` and anything it adds.
|
|
|
205
208
|
|
|
206
209
|
### Take back what the mod added
|
|
207
210
|
|
|
208
|
-
Every `add` call, every `on` and `before` method, `fs.onChange`, `settings.
|
|
211
|
+
Every `add` call, every `on` and `before` method, `fs.onChange`, `settings.beforeChange`, `settings.onChange`, and `hotkey.onPress` return a part or a `Subscription`, and each has `remove()`, which takes back what the call added. So a mod turns a feature off and on while it runs. Everything a mod adds is taken back when the mod stops, so a mod that keeps a feature for the whole session ignores what the call returns.
|
|
209
212
|
|
|
210
213
|
```ts
|
|
211
214
|
type Subscription = { remove(): void }
|
|
@@ -231,9 +234,9 @@ const token = (await mod.secrets.get('token')) ?? (await signIn())
|
|
|
231
234
|
await mod.secrets.store('token', token)
|
|
232
235
|
```
|
|
233
236
|
|
|
234
|
-
- Every mod's secrets live in `secrets.json`
|
|
235
|
-
- Each mod gets only its own secrets. They are kept apart, not locked away: any program you run can read your
|
|
236
|
-
- A value never goes in a command's arguments, a log, a toast, or an error. `mod.secrets` hands it to `cmod
|
|
237
|
+
- Every mod's secrets live as plain values in `secrets.json` at the root of the cmod store, such as `~/.local/share/cmod/secrets.json`, which only you can read and write, on every platform and with no keychain, so a Mac nobody sits at never waits on a keychain prompt. The file sits outside every mod's data folder, so copying a mod's data never copies its secrets.
|
|
238
|
+
- Each mod gets only its own secrets. They are kept apart, not locked away: any program you run can read your files.
|
|
239
|
+
- A value never goes in a command's arguments, a log, a toast, or an error. `mod.secrets` hands it to `cmod secrets` on stdin, and a mod's own program reads it from stdout of `cmod secrets get <mod> <key>`, run as `programs/cmod` in the cmod store, such as `~/.local/share/cmod/programs/cmod` ([commands.md](commands.md#cmod-secrets)).
|
|
237
240
|
- `store` of an empty value fails, because `delete` removes a secret.
|
|
238
241
|
- cmod deletes the mod's secrets with its data folder when the mod is removed.
|
|
239
242
|
|
|
@@ -275,7 +278,7 @@ mod.log(`The rule ${name} did not load, so ${mod.name} skips it: ${messageOf(err
|
|
|
275
278
|
|
|
276
279
|
### Hotkeys
|
|
277
280
|
|
|
278
|
-
A hotkey is a key combo the mod listens for, such as `alt+shift+p` to show a
|
|
281
|
+
A hotkey is a key combo the mod listens for, such as `alt+shift+p` to show a view. The mod declares each one with a title and an optional default combo, and the person changes the combo in Settings, under the mod, Hotkeys, the way VS Code handles an extension's keybindings.
|
|
279
282
|
|
|
280
283
|
```ts
|
|
281
284
|
hotkeys?: { readonly [name: string]: { readonly title: string; readonly default?: Combo } }
|
|
@@ -291,20 +294,20 @@ type Hotkey = {
|
|
|
291
294
|
- A combo is one or two of `ctrl`, `alt`, `shift`, and `meta`, in that order, then a key: a letter, a digit, `f1` to `f12`, `tab`, `enter`, `escape`, `space`, `backspace`, `delete`, an arrow, `home`, `end`, `pageup`, `pagedown`, or a mark such as `/`. `ctrl+q`, `alt+shift+p`, and `ctrl+shift+k` are combos.
|
|
292
295
|
- `defineMod` throws for a name, a title, or a combo that is not one, and for two hotkeys with one default.
|
|
293
296
|
- `cmod check` writes the hotkeys into `package.json` `"cmod".hotkeys`, and `cmod publish` refuses a mod whose `package.json` differs from `defineMod`. The install question lists each default combo, and `cmod setup` binds it in Claude Code's `keybindings.json`. A combo the person already bound to something else keeps their binding, and the hotkey has no combo until they pick one in Settings.
|
|
294
|
-
- A hotkey without a `default` starts unbound. The install question and the Installed toast leave it out, and Settings lists it as unbound until the person binds it there or with `cmod
|
|
297
|
+
- A hotkey without a `default` starts unbound. The install question and the Installed toast leave it out, and Settings lists it as unbound until the person binds it there or with `cmod hotkeys set` ([commands.md](commands.md#cmod-hotkeys)). Leave out `default` when the person should choose the key, such as for an action few people press.
|
|
295
298
|
- `combo` is the combo bound when the mod started, or `undefined` when `keybindings.json` binds none to the hotkey, such as when another binding kept the default or the hotkey has no default.
|
|
296
|
-
- `onPress` runs `listener` each time the person presses the combo. A page or pane the listener opens shows at any width, because the press is the person's own ([ui.md](ui.md#
|
|
299
|
+
- `onPress` runs `listener` each time the person presses the combo. A view, page, or pane the listener opens shows at any width, because the press is the person's own ([ui.md](ui.md#views-and-pages)).
|
|
297
300
|
- `tested.hotkey(name)` presses a hotkey in a test ([testing.md](testing.md)).
|
|
298
301
|
|
|
299
302
|
```tsx
|
|
300
303
|
export const myMod = defineMod({
|
|
301
304
|
name: 'my-mod',
|
|
302
305
|
hotkeys: {
|
|
303
|
-
toggle: { title: 'Show or hide the
|
|
306
|
+
toggle: { title: 'Show or hide the view', default: 'alt+shift+n' },
|
|
304
307
|
},
|
|
305
308
|
setup(mod) {
|
|
306
|
-
const
|
|
307
|
-
mod.hotkeys.toggle.onPress(() =>
|
|
309
|
+
const view = mod.views.add(myView)
|
|
310
|
+
mod.hotkeys.toggle.onPress(() => view.toggle({ focus: true }))
|
|
308
311
|
},
|
|
309
312
|
})
|
|
310
313
|
```
|
|
@@ -343,7 +346,8 @@ settings.project.read(): Promise<Settings>
|
|
|
343
346
|
settings.project.update(values: Readonly<Record<string, unknown>>): Promise<void>
|
|
344
347
|
settings.local.read(): Promise<Settings>
|
|
345
348
|
settings.local.update(values: Readonly<Record<string, unknown>>): Promise<void>
|
|
346
|
-
settings.
|
|
349
|
+
settings.beforeChange(matcher?, listener: (change: SettingsFileChange) => { refuse: string } | void): Subscription
|
|
350
|
+
settings.onChange(matcher?, listener: (change: SettingsFileChange) => unknown): Subscription
|
|
347
351
|
```
|
|
348
352
|
|
|
349
353
|
`settings.user` is the person's own `~/.claude/settings.json`, `settings.project` is the project's `.claude/settings.json`, and `settings.local` is the project's `.claude/settings.local.json`.
|
|
@@ -361,12 +365,13 @@ A mod that points Claude Code at its local proxy sets one variable in `env`, and
|
|
|
361
365
|
await settings.user.update({ env: { ANTHROPIC_BASE_URL: 'http://127.0.0.1:8317' } })
|
|
362
366
|
```
|
|
363
367
|
|
|
364
|
-
`
|
|
368
|
+
`beforeChange` hears each settings file Claude Code sees edited while the session runs, and a Skill file edited, before Claude Code loads it, and `{ refuse }` keeps Claude Code on the values it had. `onChange` hears the same change once Claude Code loaded it, so `read` answers the new values there, and never hears a change a `beforeChange` refused. `source` is `'user'`, `'project'`, `'local'`, `'policy'`, or `'skills'`, and `path` is the file, when Claude Code names it:
|
|
365
369
|
|
|
366
370
|
```ts
|
|
367
371
|
type SettingsFileChange = { source: 'user' | 'project' | 'local' | 'policy' | 'skills'; path?: string }
|
|
368
372
|
|
|
369
|
-
settings.
|
|
373
|
+
settings.beforeChange({ source: /^(user|project)$/ }, () => ({ refuse: 'Settings are locked while the deploy runs.' }))
|
|
374
|
+
settings.onChange({ source: 'user' }, async () => mod.log(`The theme is ${String((await settings.user.read())['theme'])}.`))
|
|
370
375
|
```
|
|
371
376
|
|
|
372
377
|
## config: the /config menu
|
|
@@ -405,7 +410,7 @@ process.run(argv: readonly string[], options?: ProcessRunOptions): Promise<Proce
|
|
|
405
410
|
process.spawn(argv: readonly string[], options?: ProcessSpawnOptions): Subprocess
|
|
406
411
|
```
|
|
407
412
|
|
|
408
|
-
Both run a program without a shell. `argv[0]` is the program and the rest are its arguments. A bare name that cmod installed, such as `
|
|
413
|
+
Both run a program without a shell. `argv[0]` is the program and the rest are its arguments. A bare name that cmod installed, such as `hello`, runs from cmod's programs folder ([install-steps.md](install-steps.md#run-a-program-by-its-name)), and any other name runs through Claude Code's `PATH`.
|
|
409
414
|
|
|
410
415
|
- `options.cwd` is the program's folder, absolute or relative to the session's working folder. Without it the program runs in the session's working folder.
|
|
411
416
|
- `options.env` sets variables over Claude Code's own environment.
|
|
@@ -463,7 +468,7 @@ type Stat = { isFile: boolean; isFolder: boolean; isLink: boolean; size: number;
|
|
|
463
468
|
fs.onChange({ path: `${mod.dataFolder}/history` }, ({ path, type }) => mod.toast(`${path}: ${type}`))
|
|
464
469
|
```
|
|
465
470
|
|
|
466
|
-
A file the mod ships is under `mod.folder`. A file the mod keeps for itself belongs in `mod.dataFolder
|
|
471
|
+
A file the mod ships is under `mod.folder`. A file the mod keeps for itself belongs in `mod.dataFolder`, or in `mod.cacheFolder` when the mod can build it again.
|
|
467
472
|
|
|
468
473
|
`find` answers every file a glob matches, each with its metadata, so a mod finds the Skills, agents, scripts, or notes it acts on in one call:
|
|
469
474
|
|
|
@@ -561,7 +566,18 @@ const elsewhere = (await sessions.current.turns()).filter((turn) => turn.device
|
|
|
561
566
|
mods.isLoaded(name: string): Promise<boolean>
|
|
562
567
|
```
|
|
563
568
|
|
|
564
|
-
Answers whether a mod runs in this Claude Code process, so a mod calls another mod it does not list only when the person has it ([dependencies.md](dependencies.md#call-a-mod-only-when-it-runs-
|
|
569
|
+
Answers whether a mod runs in this Claude Code process, so a mod calls another mod it does not list only when the person has it ([dependencies.md](dependencies.md#call-a-mod-only-when-it-runs-mods-isloaded)).
|
|
570
|
+
|
|
571
|
+
## provide and providers: the mods that answer an interface
|
|
572
|
+
|
|
573
|
+
```ts
|
|
574
|
+
provide<Name extends InterfaceName>(name: Name, methods: InterfaceMethods<Name>): Provided<Name>
|
|
575
|
+
providers<Name extends InterfaceName>(name: Name): Promise<InterfaceProvider<Name>[]>
|
|
576
|
+
|
|
577
|
+
type Provided<Name> = Subscription & { tell(event, payload): void; ask(event, payload): Promise<unknown[]> }
|
|
578
|
+
```
|
|
579
|
+
|
|
580
|
+
`provide` answers the interface's methods while the mod runs in this session, for callers in this session, until `remove()` on the `Provided` it returns. From a program, after `connect()` from `rpc.js`, it answers them for every session on the computer. `tell` tells one of the interface's events, typed from its `events`, to every `on` listener that hears this provider, and `ask` asks every `before` listener of the event and resolves their answers. `providers` answers each mod and program that provides the interface now, with its methods and its events ([dependencies.md](dependencies.md#interfaces-several-mods-answer-one-name)).
|
|
565
581
|
|
|
566
582
|
## messageOf
|
|
567
583
|
|
|
@@ -602,7 +618,7 @@ extname(path): string relative(from, to): string isAbsolute(path): bool
|
|
|
602
618
|
|
|
603
619
|
- `commands` lists every command the line runs, those inside `sudo`, `bash -c`, `$(…)`, and heredocs included, with flags such as `-rf` split into `-r` and `-f`.
|
|
604
620
|
- `folder` is where a command runs, as the line wrote it: `''` for the folder the line starts in, `src` after `cd src`, `/tmp` after `cd /tmp`, and `~/p` after `cd ~/p`. `resolve(call.cwd, folder)` makes it absolute.
|
|
605
|
-
- `input` is the index in `commands` of the command whose output this one reads through `|` or `|&`, and is absent for a command that reads no pipe. `
|
|
621
|
+
- `input` is the index in `commands` of the command whose output this one reads through `|` or `|&`, and is absent for a command that reads no pipe. `cat a.ts | head -5` gives `head` the `input` `0`. A wrapper such as `timeout 5 cat a.ts` writes the output of the command it runs, so `input` names `cat`, not `timeout`.
|
|
606
622
|
- `runner` is the index in `commands` of the command that runs this one, such as `sudo`, `xargs`, `find -exec`, or `bash -c`, and is absent for a command the line's own shell runs, `$(…)` and `( … )` included. `sudo rm x` gives `rm` the `runner` `0`, and in `sudo bash -c 'rm x'` the runners chain from `rm` to `bash` to `sudo`.
|
|
607
623
|
- `reads`, `writes`, and `fetches` are the paths and URLs the commands name, as written. A `{}` in a `find -exec` action stands for each start path of the `find`, so `find build -exec rm {} +` writes `build`, as `find build -delete` does, while its `argv` keeps `{}`. A path that holds a shell expansion makes `isFullyParsed` false, and so does a line the parser cannot read.
|
|
608
624
|
- `resolve` has no working folder to start from in Claude Code, so pass an absolute folder first, such as `resolve(sessions.current.cwd, path)`.
|
|
@@ -614,7 +630,7 @@ import { sessions } from '../node_modules/@cmodjs/core/mod.js'
|
|
|
614
630
|
|
|
615
631
|
sessions.current.onToolCall({ name: 'Bash' }, (call) => {
|
|
616
632
|
for (const { argv, folder } of parseShell(String(call.input['command'])).commands) {
|
|
617
|
-
if (basename(argv[0]) === '
|
|
633
|
+
if (basename(argv[0]) === 'git') mod.toast(`git runs in ${resolve(call.cwd, folder)}`)
|
|
618
634
|
}
|
|
619
635
|
})
|
|
620
636
|
```
|
package/docs/options.md
CHANGED
|
@@ -49,13 +49,13 @@ Each value is, in order of precedence:
|
|
|
49
49
|
3. The value the person set in `/config`.
|
|
50
50
|
4. The `default` in the declaration.
|
|
51
51
|
|
|
52
|
-
An option with no default and no value is asked before `setup` runs, on the mod's install
|
|
52
|
+
An option with no default and no value is asked before `setup` runs, on the mod's install view in the Sidebar: one field per option, each saved to `/config` through `cmod options set` as the person submits it. A secret is set in `/config` itself, where Claude Code keeps it in the keychain, and the view says so. When the person chooses Not now, or no one can answer, as in `claude -p`, the mod does not start: its error toast says `it needs <title>` and `Retry asks for it.`, and `Retry` opens the question again. A secret has an `Open /config` button, because Claude Code keeps secrets in /config and the keychain.
|
|
53
53
|
|
|
54
54
|
`cmod install`, `cmod link`, and `cmod try` set options from the terminal with `--option key=value`, once per option ([commands.md](commands.md)).
|
|
55
55
|
|
|
56
56
|
`mod.options` follows the values while the session runs. Read an option where you use it, as in `mod.options.branch`, so a change applies at once. A change in `/config` reloads the mod, and a `/cd` reads the new project's `options.json`.
|
|
57
57
|
|
|
58
|
-
A mod that needs both levels at once, such as one that syncs the person's folders and every project's, reads them with `cmod options <mod> --json`. It prints the person's values and each project's, for every project the computer has had sessions in ([commands.md](commands.md#cmod-options)).
|
|
58
|
+
A mod that needs both levels at once, such as one that syncs the person's folders and every project's, reads them with `cmod options get <mod> --json`. It prints the person's values and each project's, for every project the computer has had sessions in ([commands.md](commands.md#cmod-options)).
|
|
59
59
|
|
|
60
60
|
## Set options for a team
|
|
61
61
|
|