@cmodjs/core 5.7.0 → 5.9.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 +8 -6
- package/docs/install-steps.md +1 -1
- package/docs/jobs.md +2 -1
- package/docs/testing.md +1 -0
- package/docs/ui.md +2 -1
- package/jobs/program.d.ts +1 -0
- package/jobs/program.d.ts.map +1 -1
- package/jobs/program.js +11 -4
- package/package.json +1 -1
- package/records.d.ts +16 -3
- package/records.d.ts.map +1 -1
- package/records.js +16 -4
- package/register.d.ts +3 -0
- package/register.d.ts.map +1 -1
- package/register.js +25 -15
- package/runtime/lifecycle.d.ts +24 -2
- package/runtime/lifecycle.d.ts.map +1 -1
- package/runtime/lifecycle.js +14 -10
- package/runtime/pages.d.ts +2 -1
- package/runtime/pages.d.ts.map +1 -1
- package/runtime/pages.js +3 -6
- package/runtime/ui.d.ts.map +1 -1
- package/runtime/ui.js +27 -24
- package/src/jobs/program.ts +10 -5
- package/src/records.ts +18 -4
- package/src/register.ts +29 -13
- package/src/runtime/lifecycle.ts +31 -9
- package/src/runtime/pages.ts +4 -3
- package/src/runtime/ui.ts +24 -21
- package/src/testing.ts +5 -3
- package/testing.d.ts.map +1 -1
- package/testing.js +5 -3
package/docs/commands.md
CHANGED
|
@@ -191,9 +191,9 @@ 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.
|
|
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 anyhost as a service of this computer`.
|
|
195
195
|
|
|
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 removed mod has only `dataFolder`, because its data stays until `cmod teardown` deletes it.
|
|
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
|
|
|
198
198
|
- The `cmod` commands count a plugin as a mod only when its `package.json` has a `cmod` step key or cmod holds an install record for it. A mod made with `cmod new` has neither until its first Claude Code session sets it up, so until then `cmod list` shows it as `enabled`, like any other plugin.
|
|
199
199
|
|
|
@@ -239,7 +239,7 @@ Reads every conversation Claude Code saved, as the sessions, contexts, turns, ta
|
|
|
239
239
|
cmod watch
|
|
240
240
|
```
|
|
241
241
|
|
|
242
|
-
Reloads the sessions working inside a checkout `cmod link` linked once it builds after a change, and tells every other running session. It watches each linked folder, outside `node_modules` and `.git`, and skips a change to a file git ignores, such as the `.claude-plugin/types/` Claude Code writes each time it loads the mod. Once a folder has had no change for 2 seconds, it bundles the mod's hooks module as `cmod publish` does. A
|
|
242
|
+
Reloads the sessions working inside a checkout `cmod link` linked once it builds after a change, and tells every other running session. It watches each linked folder, outside `node_modules` and `.git`, and skips a change to a file git ignores, such as the `.claude-plugin/types/` Claude Code writes each time it loads the mod, a change inside the program's `output` folder, and a change to a file that is gone again and git does not track, such as a build's temporary file. Once a folder has had no change for 2 seconds, it bundles the mod's hooks module as `cmod publish` does. When a changed file is one the program's build reads, a file in `cli/` or one the JavaScript or TypeScript file `cli/package.json` `bin` names imports, such as the mod's own `src/`, it also builds the program `cli/` declares and links it as `cmod link` does, so the program in cmod's programs folder is never older than the mod. A change no program build reads builds no program. A program whose build failed builds again at the next change, whatever it changed. A program that stops when its file changes then restarts on the new build, and a build that writes the same program leaves the file as it is. A mod that builds marks `plugins-changed` with the checkout's folder, so each session whose project is that folder or inside it reloads by itself once the change has been quiet for 2 seconds, after its turn ends, and every other session shows the `Plugins changed` toast. A bundle or program build that still fails 10 seconds after the last change shows `<mod> does not build` with the error as one toast in every session, the last program that built keeps running, and the toast goes once the mod builds. So an agent's half-written file reloads nothing and shows nothing. At its start it bundles again each mod whose failure it finds in `build-failures.json`, so a failure an older cmod wrote goes once the mod builds. The cmod plugin starts one only in a session that an app shows, once a mod is linked, at the session's start or later, so a machine with no linked mod runs none. The first holds `watch.lock` in the cmod store, watches, and touches its file there every 5 seconds. Another one exits at once while it runs, and the cmod plugin of each such session starts one again once that file is gone or 15 seconds old, so a machine runs one watcher however many sessions it has open. Before each touch it reads the newest cmod in the cmod store, the newest version folder of `bin/cmod` that the launcher runs. A `cmod watch` older than that exits and lets go of `watch.lock`, so after a cmod update the new cmod's watcher judges the linked mods by its own rules within 15 seconds.
|
|
243
243
|
|
|
244
244
|
A cmod before 4.1.0 linked a checkout by writing it into `CLAUDE_CODE_PLUGIN_DIRS` in the `env` block of Claude Code's `settings.json`. `cmod watch` at its start, and `cmod setup`, link each folder still in that list as `cmod link` does now and take it out of the list. A folder that fails to link stays in the list, and its error prints on stderr.
|
|
245
245
|
|
|
@@ -285,7 +285,7 @@ cmod runs these itself. A person runs them to see a step's whole log, or to fini
|
|
|
285
285
|
cmod setup <plugin-root> [--events]
|
|
286
286
|
```
|
|
287
287
|
|
|
288
|
-
Refuses a machine the `os` and `cpu` keys of the mod's `package.json` leave out. Downloads the program its `cmod.program` names, or builds it from the checkout's `cli/` when `cmod link` loaded the mod, so a linked checkout whose version has no release yet still sets up, and links it into cmod's programs folder, which Claude Code runs it from by its name, and into `~/.local/bin` unless a file there is not cmod's. Runs the mod's install step, saves its uninstall step, binds its hotkeys,
|
|
288
|
+
Refuses a machine the `os` and `cpu` keys of the mod's `package.json` leave out. Downloads the program its `cmod.program` names, or builds it from the checkout's `cli/` when `cmod link` loaded the mod, so a linked checkout whose version has no release yet still sets up, and links it into cmod's programs folder, which Claude Code runs it from by its name, and into `~/.local/bin` unless a file there is not cmod's. Runs the mod's install step, saves its uninstall step, binds its hotkeys, records the mod as set up, and restarts each service of the computer the mod runs a program as ([cmod program](#cmod-program)), so the service runs the new program, asking nothing first ([install-steps.md](install-steps.md#when-the-steps-run)). A mod installed from a marketplace whose automatic updates the person has not turned on or off gets them turned on, unless the marketplace is a folder, which Claude Code reads in place, through `"autoUpdate": true` on the marketplace's `extraKnownMarketplaces` entry in Claude Code's `settings.json`, and the setup says so. An unchanged mod runs nothing. `--events` prints one event per line for a program to read, and the mod's install toast in Claude Code reads them. Before all of that, it links each folder a cmod before 4.1.0 left in `CLAUDE_CODE_PLUGIN_DIRS`, as [`cmod watch`](#cmod-watch) does.
|
|
289
289
|
|
|
290
290
|
### cmod teardown
|
|
291
291
|
|
|
@@ -293,7 +293,7 @@ Refuses a machine the `os` and `cpu` keys of the mod's `package.json` leave out.
|
|
|
293
293
|
cmod teardown <plugin-name> [--events]
|
|
294
294
|
```
|
|
295
295
|
|
|
296
|
-
Runs a removed mod's saved uninstall step, then deletes its install record, the saved step, every version of its program, its data folder, and `instances/<plugin-name>/`, where its `singleInstance` programs keep their addresses, takes out each Claude Code setting it changed that still has the value it set, deletes its secrets ([cmod secret](#cmod-secret)), and deletes its entry in `consent.json`. It keeps the mod's config folder, `~/.claude/cmods/<plugin-name>`. A failed uninstall step keeps the record, so `cmod teardown` can run again.
|
|
296
|
+
Runs a removed mod's saved uninstall step, then deletes its install record, the saved step, every version of its program, its data folder, and `instances/<plugin-name>/`, where its `singleInstance` and `isService` programs keep their addresses, stops and deletes each service of the computer it runs a program as, with its record in `services/<plugin-name>/` ([cmod program](#cmod-program)), takes out each Claude Code setting it changed that still has the value it set, deletes its secrets ([cmod secret](#cmod-secret)), and deletes its entry in `consent.json`. It keeps the mod's config folder, `~/.claude/cmods/<plugin-name>`. A failed uninstall step keeps the record, so `cmod teardown` can run again.
|
|
297
297
|
|
|
298
298
|
### cmod hotkey
|
|
299
299
|
|
|
@@ -342,11 +342,13 @@ Starts a task in a new background Claude Code session, for a mod's `startTask` w
|
|
|
342
342
|
### cmod program
|
|
343
343
|
|
|
344
344
|
```text
|
|
345
|
-
cmod program <mod> [--no-wait] -- <command…>
|
|
345
|
+
cmod program <mod> [--no-wait | --service [--env <name>]...] -- <command…>
|
|
346
346
|
```
|
|
347
347
|
|
|
348
348
|
Runs one copy of a mod's program for the whole computer, for a `program` job with `singleInstance` ([jobs.md](jobs.md#program)). The first one takes `instances/<mod>/<program>.json.lock` in the cmod store, runs the command without `CLAUDE_CODE_SESSION_ID`, because the copy serves every session, writes its first line on standard output, its address, with the copy's process to `instances/<mod>/<program>.json`, and prints it. It touches its file in the lock every 5 seconds. With `--no-wait`, which a mod's session passes, another one touches the holder's file, prints `held`, and exits 0, and the session reads the address from `instances/<mod>/<program>.json` and runs `cmod program` again once that file is gone or the holder's file is 15 seconds old. Without it, as a mod built on `@cmodjs/core` before 5.3.0 runs it, another one prints the address in that file, then each new one as it changes, and tries the lock again whenever that folder changes and every 5 seconds, so it takes over once the holder exits. A lock whose process is gone counts as free. The holder stops its copy and gives up the lock on SIGTERM, SIGINT, or SIGHUP, and when the session that started it exits, which it checks every 5 seconds. When the copy exits on its own, the holder exits with the copy's exit code, and the copy's standard error passes through. A new holder that finds a copy an earlier holder left running sends it SIGTERM, then SIGKILL after 5 seconds, and starts its own copy only once that one is gone, so two copies never run at once.
|
|
349
349
|
|
|
350
|
+
With `--service`, which a session passes for a `program` job with `isService`, it makes the holder a service of the computer named `com.claudemodmanager.<mod>.<program>`: a launchd agent in `~/Library/LaunchAgents` on macOS, loaded into the person's login session, and a systemd user service in `~/.config/systemd/user` on Linux, enabled for `default.target`. Its file is mode 600, because it holds the program's environment. The service runs `cmod program <mod> -- <command…>` through the cmod store's `programs/cmod` at login and again whenever it exits, launchd at most once every 10 seconds and systemd 10 seconds after the exit, with `HOME`, `XDG_DATA_HOME`, and `CLAUDE_CONFIG_DIR` as the session has them, a `PATH` of the cmod store's `programs` folder, `/usr/local/bin`, `/opt/homebrew/bin`, `/usr/bin`, `/bin`, `/usr/sbin`, and `/sbin`, and each `--env` variable, which the job passes for each key of its `environment`, `PATH` included. The `PATH` is fixed, because sessions started from different shells hold different ones, and a service rewritten for each would restart at every session start. cmod records it in `services/<mod>/<program>.json` in the cmod store. It loads the service when it is new, changed, or not loaded, waits up to 15 seconds for a holder of `instances/<mod>/<program>.json.lock`, prints `held`, and exits 0, so the session follows the instance file as with `--no-wait`. A service that holds nothing after 15 seconds fails with the command that shows why, `launchctl print gui/<uid>/<label>` or `journalctl --user -u <label>.service`. When the computer does not take the service, such as a Linux machine without a systemd user session, it deletes what it wrote, says why on standard error, and runs as `--no-wait` does. `cmod setup` restarts each service of a mod it sets up, so the service runs the new program, and `cmod teardown` stops and deletes each one.
|
|
351
|
+
|
|
350
352
|
### cmod option
|
|
351
353
|
|
|
352
354
|
```text
|
package/docs/install-steps.md
CHANGED
|
@@ -203,7 +203,7 @@ A mod that builds its own command-line program keeps its source in `cli/`, and c
|
|
|
203
203
|
|
|
204
204
|
Then:
|
|
205
205
|
|
|
206
|
-
- `cmod link` builds the program and links this machine's build into cmod's programs folder and `~/.local/bin`. When the linked checkout's version changes, the next session's setup builds it again from the checkout, so a version with no release yet still sets up.
|
|
206
|
+
- `cmod link` builds the program and links this machine's build into cmod's programs folder and `~/.local/bin`. `cmod watch` builds it again, at the same version too, after each change to a file in `cli/` or a file the `bin` entry imports, so the program never runs older code than the mod. When the linked checkout's version changes, the next session's setup builds it again from the checkout, so a version with no release yet still sets up.
|
|
207
207
|
- `cmod publish` builds every machine's file and attaches each to the GitHub release `v<version>`, with a `SHA256SUMS` file. It refuses a `cli/` program that the `package.json` `program` key does not name.
|
|
208
208
|
- On install, cmod downloads `<repository>/releases/download/v<version>/<program>-<machine>`, checks it against `SHA256SUMS`, runs `<program> --version`, and links it into cmod's programs folder and `~/.local/bin`.
|
|
209
209
|
- `cmod unlink` and the uninstall remove the program and both links.
|
package/docs/jobs.md
CHANGED
|
@@ -318,7 +318,7 @@ export const loop = defineMod({
|
|
|
318
318
|
## program
|
|
319
319
|
|
|
320
320
|
```ts
|
|
321
|
-
program(options: { readonly command: readonly string[]; readonly environment?: Record<string, string>; readonly singleInstance?: boolean }): Job<Program>
|
|
321
|
+
program(options: { readonly command: readonly string[]; readonly environment?: Record<string, string>; readonly singleInstance?: boolean; readonly isService?: boolean }): Job<Program>
|
|
322
322
|
|
|
323
323
|
type Program = {
|
|
324
324
|
readonly state: 'stopped' | 'starting' | 'running' | 'backoff' | 'fatal'
|
|
@@ -333,6 +333,7 @@ type Program = {
|
|
|
333
333
|
- In an interactive session the program starts with the mod. Otherwise it starts at the first `ready()`.
|
|
334
334
|
- When the program exits, cmod starts it again after 1, 2, 4, 8, and 16 seconds. After 5 failed tries, or a first line that is not an address, the state is `fatal`, `ready()` rejects, and cmod logs `<mod>: the <program> program stopped: <reason>`.
|
|
335
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. 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`. 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: cmod restarts the service when it sets up a new version of the mod, and stops and deletes it when the mod is removed. Settings shows `Runs as a service of this computer` on the mod's page, and [`cmod list`](commands.md#cmod-list) names the program. On a computer that does not take the service, such as a Linux machine without a systemd user session, the program runs as a `singleInstance` program does. Two `isService` programs with the same program name in one mod throw at `mod.use`.
|
|
336
337
|
- A program that ships with the mod gets onto `PATH` through the `program` key of the mod's `package.json` ([install-steps.md](install-steps.md)). A program an install step fetched with `cmod download` is not on `PATH`, so `command` names it by its full path, `${mod.dataFolder}/bin/<program>`.
|
|
337
338
|
|
|
338
339
|
```ts
|
package/docs/testing.md
CHANGED
|
@@ -319,6 +319,7 @@ Set a fake to answer a call:
|
|
|
319
319
|
- A call with no fake throws `<call>(<args>) has no fake answer. Set fakes.<call> on the tested mod.` So set `fakes.process.run` before a test runs a program, and `fakes.ui.ask` before the mod asks a question.
|
|
320
320
|
- A `program` job is the exception: it catches the `process.spawn` error and retries after 1, 2, 4, 8 and 16 seconds on real timers, so its `ready()` waits past `bun test`'s 5-second timeout. Set `fakes.process.spawn` before a test starts a `program` job.
|
|
321
321
|
- A `program` job with `singleInstance` spawns `/test/home/.local/share/cmod/programs/cmod program <mod> --no-wait -- <command…>`, so `fakes.process.spawn` gets that `argv`, and the first line the fake writes to standard output is the address of the copy this session runs. A fake that writes `held` and ends tests a session another session runs the copy for: `ready()` resolves the address in `/test/home/.local/share/cmod/instances/<mod>/<program>.json`, which the test gives as `{"address":"unix:/tmp/x.sock"}` in `files`.
|
|
322
|
+
- A `program` job with `isService` spawns `/test/home/.local/share/cmod/programs/cmod program <mod> --service --env <name> -- <command…>`, with one `--env` for each key of its `environment`, every time it starts, and a fake that writes `held` and ends stands for the service: `ready()` resolves the address in the instance file, as above.
|
|
322
323
|
- `files` already fills the `fs` fakes: a write is read back, and `list` lists the given files. The fake file system resolves a relative path against `/`, not against the session's working folder, so a mod under test reads `${sessions.current.project}/<file>` rather than a relative path. `fs.list()` with no path rejects.
|
|
323
324
|
- `ui.open` places every pane by default. A fake that answers `{ isPlaced: false }` holds a pane back.
|
|
324
325
|
- `ui.scroll` answers `{}` by default, as when the window moved. A fake that answers `{ deny }` refuses the scroll.
|
package/docs/ui.md
CHANGED
|
@@ -142,7 +142,8 @@ type Page<Params = undefined> = {
|
|
|
142
142
|
- `props.columns` is the width the page draws in. The Sidebar draws the page in a panel titled with the mod's name, under its tab bar and above its key bar, so `columns` is the Sidebar's width less 6: its padding of one column on each side, and the panel's border and padding.
|
|
143
143
|
- A page opened from what the person did, such as a slash command they typed, a hotkey, or a `Button` they pressed, shows at any terminal width. A page opened from anything else, such as `setup`, a timer, or a listener, shows only on a terminal 144 columns wide. Below that it waits until the person opens the Sidebar.
|
|
144
144
|
- A page draws only the elements of `ui/elements.js` and `ui/components.js`, text, numbers, and plain objects, because the cmod plugin draws it. A `Button`'s `onPress` runs in the mod.
|
|
145
|
-
- A `render` that throws draws
|
|
145
|
+
- A `render` that throws draws `The <title> page could not draw: <error>` in the page, and cmod shows the error toast `The <title> page could not draw` once, until the page draws again.
|
|
146
|
+
- A press on a `Button` from an older drawing, such as one drawn before the mod reloaded, runs nothing. cmod shows the toast `The <mod> button was from an older drawing, so nothing ran` and draws the page again.
|
|
146
147
|
|
|
147
148
|
A hotkey is the usual way in:
|
|
148
149
|
|
package/jobs/program.d.ts
CHANGED
|
@@ -10,5 +10,6 @@ export declare function program(options: {
|
|
|
10
10
|
readonly command: readonly string[];
|
|
11
11
|
readonly environment?: Record<string, string>;
|
|
12
12
|
readonly singleInstance?: boolean;
|
|
13
|
+
readonly isService?: boolean;
|
|
13
14
|
}): Job<Program>;
|
|
14
15
|
//# sourceMappingURL=program.d.ts.map
|
package/jobs/program.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"program.d.ts","sourceRoot":"","sources":["../src/jobs/program.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,WAAW,CAAA;AAQpC,MAAM,MAAM,OAAO,GAAG;IACpB,QAAQ,CAAC,KAAK,EAAE,SAAS,GAAG,UAAU,GAAG,SAAS,GAAG,SAAS,GAAG,OAAO,CAAA;IACxE,KAAK,IAAI,OAAO,CAAC;QAAE,GAAG,EAAE,MAAM,CAAC;QAAC,UAAU,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC,CAAA;CACvD,CAAA;AAYD,wBAAgB,OAAO,CAAC,OAAO,EAAE;IAAE,QAAQ,CAAC,OAAO,EAAE,SAAS,MAAM,EAAE,CAAC;IAAC,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAAC,QAAQ,CAAC,cAAc,CAAC,EAAE,OAAO,CAAA;CAAE,GAAG,GAAG,CAAC,OAAO,CAAC,
|
|
1
|
+
{"version":3,"file":"program.d.ts","sourceRoot":"","sources":["../src/jobs/program.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,WAAW,CAAA;AAQpC,MAAM,MAAM,OAAO,GAAG;IACpB,QAAQ,CAAC,KAAK,EAAE,SAAS,GAAG,UAAU,GAAG,SAAS,GAAG,SAAS,GAAG,OAAO,CAAA;IACxE,KAAK,IAAI,OAAO,CAAC;QAAE,GAAG,EAAE,MAAM,CAAC;QAAC,UAAU,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC,CAAA;CACvD,CAAA;AAYD,wBAAgB,OAAO,CAAC,OAAO,EAAE;IAAE,QAAQ,CAAC,OAAO,EAAE,SAAS,MAAM,EAAE,CAAC;IAAC,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAAC,QAAQ,CAAC,cAAc,CAAC,EAAE,OAAO,CAAC;IAAC,QAAQ,CAAC,SAAS,CAAC,EAAE,OAAO,CAAA;CAAE,GAAG,GAAG,CAAC,OAAO,CAAC,CA6ItM"}
|
package/jobs/program.js
CHANGED
|
@@ -9,14 +9,17 @@ const leaseCheckMs = 5000;
|
|
|
9
9
|
const staleMs = 15_000;
|
|
10
10
|
const retryWithinMs = 1000;
|
|
11
11
|
export function program(options) {
|
|
12
|
-
const { command, environment, singleInstance = false } = options;
|
|
12
|
+
const { command, environment, singleInstance = false, isService = false } = options;
|
|
13
13
|
return ({ mod, announce, reserveName }) => {
|
|
14
14
|
const { claude, report, spawnCmod, watches } = engineOf(mod);
|
|
15
15
|
const [executable] = command;
|
|
16
16
|
if (executable === undefined)
|
|
17
17
|
throw new Error(`${mod.name}: the program has no command. Name the program on PATH and its arguments, such as ['preview-server', '--port', '0'].`);
|
|
18
|
-
if (
|
|
18
|
+
if (isService)
|
|
19
|
+
reserveName('program', basename(executable), `${mod.name}: the service ${executable} is already added. Give each isService program its own executable.`);
|
|
20
|
+
else if (singleInstance)
|
|
19
21
|
reserveName('program', basename(executable), `${mod.name}: the single instance of ${executable} is already added. Give each singleInstance program its own executable.`);
|
|
22
|
+
const isElected = singleInstance || isService;
|
|
20
23
|
const request = { argv: command, ...(environment === undefined ? {} : { env: environment }) };
|
|
21
24
|
let state = 'stopped';
|
|
22
25
|
let address;
|
|
@@ -27,7 +30,11 @@ export function program(options) {
|
|
|
27
30
|
let isWatching = false;
|
|
28
31
|
let instance;
|
|
29
32
|
let leaseCheck;
|
|
30
|
-
const spawn = () =>
|
|
33
|
+
const spawn = () => {
|
|
34
|
+
if (isService)
|
|
35
|
+
return spawnCmod(['program', mod.name, '--service', ...Object.keys(environment ?? {}).flatMap((name) => ['--env', name]), '--', ...command], environment);
|
|
36
|
+
return singleInstance ? spawnCmod(['program', mod.name, '--no-wait', '--', ...command], environment) : claude.process.spawn(request);
|
|
37
|
+
};
|
|
31
38
|
const instanceFile = () => (instance ??= Promise.all([claude.env.home(), claude.env.dataHome()]).then(([home, dataHome]) => instancePath(storeFolder({ HOME: home, XDG_DATA_HOME: dataHome }), mod.name, basename(executable))));
|
|
32
39
|
const following = (run) => void run.catch((error) => report({ id: `program:${executable}:follow`, message: `Could not follow the ${executable} program`, error }));
|
|
33
40
|
const stop = (reason) => {
|
|
@@ -101,7 +108,7 @@ export function program(options) {
|
|
|
101
108
|
const lines = `${pending}${piece.text}`.split('\n');
|
|
102
109
|
pending = lines.pop() ?? '';
|
|
103
110
|
for (const line of lines.slice(0, 1)) {
|
|
104
|
-
if (
|
|
111
|
+
if (isElected && line.trim() === 'held')
|
|
105
112
|
return await follow(await instanceFile());
|
|
106
113
|
const next = addressOf(line.trim());
|
|
107
114
|
if (next === undefined) {
|
package/package.json
CHANGED
package/records.d.ts
CHANGED
|
@@ -84,6 +84,8 @@ export declare function buildFailuresPath(store: string): string;
|
|
|
84
84
|
export declare function linksPath(store: string): string;
|
|
85
85
|
export declare function instanceFolder(store: string, mod: string): string;
|
|
86
86
|
export declare function instancePath(store: string, mod: string, executable: string): string;
|
|
87
|
+
export declare function serviceFolder(store: string, mod: string): string;
|
|
88
|
+
export declare function servicePath(store: string, mod: string, executable: string): string;
|
|
87
89
|
export type Links = {
|
|
88
90
|
readonly marketplaces: Readonly<Record<string, string>>;
|
|
89
91
|
readonly turnedOff: Readonly<Record<string, readonly string[]>>;
|
|
@@ -133,12 +135,23 @@ export declare function newestLog(entries: readonly LogEntry[]): LogEntry[];
|
|
|
133
135
|
export declare function versionsLine({ mod, core, cmod, program, claudeCode }: LogVersions): string;
|
|
134
136
|
export declare function logReport(entry: LogEntry): string;
|
|
135
137
|
export declare function parseConsent(value: unknown, path: string): Record<string, string[]>;
|
|
136
|
-
export declare const coreVersion = "5.
|
|
137
|
-
export declare const oldestCmodVersion = "5.
|
|
138
|
+
export declare const coreVersion = "5.9.0";
|
|
139
|
+
export declare const oldestCmodVersion = "5.9.0";
|
|
138
140
|
export declare function hotkeyCommand(mod: string, hotkey: string): string;
|
|
139
141
|
export declare function hotkeyBindings(mod: string, hotkeys: Hotkeys | undefined): Record<string, string>;
|
|
140
142
|
export declare function boundCombos(keybindings: unknown): Map<string, string>;
|
|
141
|
-
export declare function
|
|
143
|
+
export declare function bundleOptions(steps: Steps): {
|
|
144
|
+
format: 'esm';
|
|
145
|
+
target: 'browser';
|
|
146
|
+
external: string[];
|
|
147
|
+
define: {} | {
|
|
148
|
+
'globalThis.cmodWithoutApprove': string;
|
|
149
|
+
};
|
|
150
|
+
minify: {
|
|
151
|
+
whitespace: boolean;
|
|
152
|
+
identifiers: boolean;
|
|
153
|
+
};
|
|
154
|
+
};
|
|
142
155
|
export declare function scriptPaths(command: string): string[];
|
|
143
156
|
export declare function scriptsSha256(steps: Steps, files: {
|
|
144
157
|
read: ReadFile;
|
package/records.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"records.d.ts","sourceRoot":"","sources":["src/records.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiC,KAAK,OAAO,EAAE,MAAM,cAAc,CAAA;AAG1E,MAAM,MAAM,aAAa,GAAG;IAC1B,IAAI,EAAE,MAAM,CAAA;IACZ,OAAO,EAAE,MAAM,CAAA;IACf,IAAI,EAAE,MAAM,CAAA;IACZ,WAAW,EAAE,MAAM,CAAA;IACnB,aAAa,EAAE,MAAM,CAAA;IACrB,SAAS,EAAE,MAAM,GAAG,IAAI,CAAA;IACxB,OAAO,EAAE,MAAM,GAAG,IAAI,CAAA;IACtB,IAAI,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,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AAa,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAEjE;AAED,wBAAgB,cAAc,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,GAAG,SAAS,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAEhG;AAED,wBAAgB,WAAW,CAAC,WAAW,EAAE,OAAO,GAAG,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAQrE;AAYD,wBAAgB,aAAa,CAAC,KAAK,EAAE,KAAK;IAEtC,MAAM,EAAE,KAAK;IACb,MAAM,EAAE,SAAS;IACjB,QAAQ;IACR,MAAM;;;IACN,MAAM;QAAI,UAAU;QAAQ,WAAW;;EAE1C;AAED,wBAAgB,WAAW,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,EAAE,CAMrD;AAMD,wBAAsB,aAAa,CAAC,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE;IAAE,IAAI,EAAE,QAAQ,CAAC;IAAC,IAAI,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,EAAE,CAAC,CAAA;CAAE,GAAG,OAAO,CAAC,MAAM,CAAC,CA6BzI;AAED,wBAAgB,WAAW,CAAC,KAAK,EAAE,WAAW,GAAG,MAAM,CAiBtD;AAED,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,WAAW,CAiBpD;AAED,wBAAgB,SAAS,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAQnE;AAED,wBAAgB,QAAQ,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAEzE"}
|
package/records.js
CHANGED
|
@@ -226,6 +226,12 @@ export function instanceFolder(store, mod) {
|
|
|
226
226
|
export function instancePath(store, mod, executable) {
|
|
227
227
|
return `${instanceFolder(store, mod)}/${executable}.json`;
|
|
228
228
|
}
|
|
229
|
+
export function serviceFolder(store, mod) {
|
|
230
|
+
return `${store}/services/${checkedName(mod)}`;
|
|
231
|
+
}
|
|
232
|
+
export function servicePath(store, mod, executable) {
|
|
233
|
+
return `${serviceFolder(store, mod)}/${checkedName(executable)}.json`;
|
|
234
|
+
}
|
|
229
235
|
export function parseLinks(value, path) {
|
|
230
236
|
if (value === undefined)
|
|
231
237
|
return { marketplaces: {}, turnedOff: {} };
|
|
@@ -302,8 +308,8 @@ function readHotkeys(hotkeys) {
|
|
|
302
308
|
throw new Error(`package.json "cmod.hotkeys" is not a map of hotkeys to their title and optional default combo. ${fix}`);
|
|
303
309
|
return { hotkeys: checkHotkeys('package.json "cmod"', hotkeys) };
|
|
304
310
|
}
|
|
305
|
-
export const coreVersion = '5.
|
|
306
|
-
export const oldestCmodVersion = '5.
|
|
311
|
+
export const coreVersion = '5.9.0';
|
|
312
|
+
export const oldestCmodVersion = '5.9.0';
|
|
307
313
|
export function hotkeyCommand(mod, hotkey) {
|
|
308
314
|
return `${mod}--${hotkey}`;
|
|
309
315
|
}
|
|
@@ -335,8 +341,14 @@ function readCommand(steps, key) {
|
|
|
335
341
|
throw new Error(`package.json "cmod.${key}" names ${atRoot}, a script at the plugin root. Move it into a folder, such as ./setup/${key}.sh: cmod runs the steps again whenever anything in a script's folder changes.`);
|
|
336
342
|
return { [key]: command };
|
|
337
343
|
}
|
|
338
|
-
export function
|
|
339
|
-
return
|
|
344
|
+
export function bundleOptions(steps) {
|
|
345
|
+
return {
|
|
346
|
+
format: 'esm',
|
|
347
|
+
target: 'browser',
|
|
348
|
+
external: ['claude-code'],
|
|
349
|
+
define: steps.approve === true ? {} : { 'globalThis.cmodWithoutApprove': 'true' },
|
|
350
|
+
minify: { whitespace: true, identifiers: true },
|
|
351
|
+
};
|
|
340
352
|
}
|
|
341
353
|
export function scriptPaths(command) {
|
|
342
354
|
const words = command
|
package/register.d.ts
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import type { On, PluginOptions } from 'claude-code';
|
|
2
2
|
import type { ModDefinition } from './mod.js';
|
|
3
3
|
import type { Options } from './options.js';
|
|
4
|
+
import { type ServeCmodPlugin } from './runtime/lifecycle.js';
|
|
4
5
|
export declare function registeredMod(): ModDefinition<object> | undefined;
|
|
6
|
+
export declare const serveCmodPlugin: ServeCmodPlugin;
|
|
5
7
|
export declare function registerMod<State extends object, Declared extends Options>(addHook: On, definition: ModDefinition<State, string, Declared>, options: PluginOptions): void;
|
|
8
|
+
export declare function registerCmodPlugin<State extends object, Declared extends Options>(addHook: On, definition: ModDefinition<State, string, Declared>, options: PluginOptions): void;
|
|
6
9
|
export declare function registerPermissionCheck(addHook: On): void;
|
|
7
10
|
//# sourceMappingURL=register.d.ts.map
|
package/register.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"register.d.ts","sourceRoot":"","sources":["src/register.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAA4D,EAAE,EAAE,aAAa,EAAgB,MAAM,aAAa,CAAA;AAC5H,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,UAAU,CAAA;AAC7C,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;
|
|
1
|
+
{"version":3,"file":"register.d.ts","sourceRoot":"","sources":["src/register.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAA4D,EAAE,EAAE,aAAa,EAAgB,MAAM,aAAa,CAAA;AAC5H,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,UAAU,CAAA;AAC7C,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AAM3C,OAAO,EAA+C,KAAK,eAAe,EAAE,MAAM,wBAAwB,CAAA;AAY1G,wBAAgB,aAAa,IAAI,aAAa,CAAC,MAAM,CAAC,GAAG,SAAS,CAEjE;AAsHD,eAAO,MAAM,eAAe,EAAE,eAK7B,CAAA;AAED,wBAAgB,WAAW,CAAC,KAAK,SAAS,MAAM,EAAE,QAAQ,SAAS,OAAO,EAAE,OAAO,EAAE,EAAE,EAAE,UAAU,EAAE,aAAa,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,OAAO,EAAE,aAAa,GAAG,IAAI,CAGzK;AAED,wBAAgB,kBAAkB,CAAC,KAAK,SAAS,MAAM,EAAE,QAAQ,SAAS,OAAO,EAAE,OAAO,EAAE,EAAE,EAAE,UAAU,EAAE,aAAa,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,OAAO,EAAE,aAAa,GAAG,IAAI,CAUhL;AAiDD,wBAAgB,uBAAuB,CAAC,OAAO,EAAE,EAAE,GAAG,IAAI,CAIzD"}
|
package/register.js
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
|
+
import { serveConversations } from './runtime/conversations.js';
|
|
1
2
|
import { settledAfterAbort } from './runtime/deadline.js';
|
|
2
|
-
import { cmodPluginName } from './runtime/dependencies.js';
|
|
3
3
|
import { readDevice } from './runtime/device.js';
|
|
4
4
|
import { createLifecycle, readPlugin } from './runtime/lifecycle.js';
|
|
5
|
+
import { servePages } from './runtime/pages.js';
|
|
5
6
|
import { permissionRoutes } from './runtime/permission-check.js';
|
|
7
|
+
import { serveWidgets } from './runtime/widgets.js';
|
|
6
8
|
import { messageOf } from './utils/text.js';
|
|
7
9
|
let lifecycle;
|
|
8
10
|
let permissionCheck;
|
|
@@ -115,10 +117,31 @@ function routeCallToMod(_$, eventInput, passOn) {
|
|
|
115
117
|
function routeCallFailure(_$, eventInput, passOn) {
|
|
116
118
|
return lifecycle.caught('cmod.call', withCaller(eventInput, passOn), withoutCaller(passOn), passOn);
|
|
117
119
|
}
|
|
120
|
+
export const serveCmodPlugin = ({ claude, router, store, project, report, clear, tellRefusedPress, parts, markdownIn, tellStylers }) => {
|
|
121
|
+
const conversations = serveConversations({ claude, router, store, project, report, clear });
|
|
122
|
+
const widgets = serveWidgets({ claude, router, store, report, turnClosedBy: (rowId) => conversations.turnClosedBy(rowId), parts, markdownIn });
|
|
123
|
+
const pages = servePages({ claude, router, report, tellRefusedPress, widgets, parts, tellStylers });
|
|
124
|
+
return { conversations, widgets, pages };
|
|
125
|
+
};
|
|
118
126
|
export function registerMod(addHook, definition, options) {
|
|
127
|
+
registerHooks(addHook, definition, options);
|
|
128
|
+
addHook('ui.render', routeToMod).catch(routeFailure);
|
|
129
|
+
}
|
|
130
|
+
export function registerCmodPlugin(addHook, definition, options) {
|
|
131
|
+
registerHooks(addHook, definition, options, serveCmodPlugin);
|
|
132
|
+
addHook('ui.render', { component: ['AbovePrompt', 'PromptHint', 'SessionMode', 'Spinner', 'TurnDuration', 'Pane'] }, routeToMod).catch(routeFailure);
|
|
133
|
+
addHook('command.describe', { command: /--/ }, routeToMod).catch(routeFailure);
|
|
134
|
+
addHook('session.append', routeToMod).catch(routeFailure);
|
|
135
|
+
addHook('session.receive', routeToMod).catch(routeFailure);
|
|
136
|
+
addHook('agent.spawn', routeToMod).catch(routeFailure);
|
|
137
|
+
addHook('prompt.attachment', routeToMod).catch(routeFailure);
|
|
138
|
+
addHook('turn.start', routeToMod).catch(routeFailure);
|
|
139
|
+
addHook('turn.complete', routeToMod).catch(routeFailure);
|
|
140
|
+
}
|
|
141
|
+
function registerHooks(addHook, definition, options, serve) {
|
|
119
142
|
permissionCheck = undefined;
|
|
120
143
|
registered = definition;
|
|
121
|
-
lifecycle = createLifecycle(definition, () => permissionCheck, options);
|
|
144
|
+
lifecycle = createLifecycle(definition, () => permissionCheck, options, true, serve);
|
|
122
145
|
addHook('session.start', startMod);
|
|
123
146
|
addHook('classic.Setup', routeToMod).catch(routeFailure);
|
|
124
147
|
addHook('classic.SessionStart', routeToMod).catch(routeFailure);
|
|
@@ -155,24 +178,11 @@ export function registerMod(addHook, definition, options) {
|
|
|
155
178
|
addHook('command.run', routeToMod).catch(routeFailure);
|
|
156
179
|
addHook('session.measure', routeToMod).catch(routeFailure);
|
|
157
180
|
addHook('skill.prompt', routeToMod).catch(routeFailure);
|
|
158
|
-
if (definition.name === cmodPluginName)
|
|
159
|
-
addHook('ui.render', { component: ['AbovePrompt', 'PromptHint', 'SessionMode', 'Spinner', 'TurnDuration', 'Pane'] }, routeToMod).catch(routeFailure);
|
|
160
|
-
else
|
|
161
|
-
addHook('ui.render', routeToMod).catch(routeFailure);
|
|
162
181
|
addHook('ui.press', routeToMod).catch(routeFailure);
|
|
163
182
|
addHook('ui.scroll', routeToMod).catch(routeFailure);
|
|
164
183
|
addHook('ui.close', routeToMod).catch(routeFailure);
|
|
165
184
|
addHook('cmod.call', { to: definition.name }, routeCallToMod).catch(routeCallFailure);
|
|
166
185
|
addHook('session.compact', routeToMod).catch(routeFailure);
|
|
167
|
-
if (definition.name !== cmodPluginName)
|
|
168
|
-
return;
|
|
169
|
-
addHook('command.describe', { command: /--/ }, routeToMod).catch(routeFailure);
|
|
170
|
-
addHook('session.append', routeToMod).catch(routeFailure);
|
|
171
|
-
addHook('session.receive', routeToMod).catch(routeFailure);
|
|
172
|
-
addHook('agent.spawn', routeToMod).catch(routeFailure);
|
|
173
|
-
addHook('prompt.attachment', routeToMod).catch(routeFailure);
|
|
174
|
-
addHook('turn.start', routeToMod).catch(routeFailure);
|
|
175
|
-
addHook('turn.complete', routeToMod).catch(routeFailure);
|
|
176
186
|
}
|
|
177
187
|
export function registerPermissionCheck(addHook) {
|
|
178
188
|
permissionCheck = permissionRoutes;
|
package/runtime/lifecycle.d.ts
CHANGED
|
@@ -3,10 +3,15 @@ import type { Mod, ModDefinition } from '../mod.js';
|
|
|
3
3
|
import type { Options } from '../options.js';
|
|
4
4
|
import { type Steps } from '../records.js';
|
|
5
5
|
import type { Claude } from './claude.js';
|
|
6
|
+
import type { Conversations } from './conversations.js';
|
|
6
7
|
import { type RoutedEvent } from './hooks.js';
|
|
7
8
|
import type { PermissionRoutes } from './permission-check.js';
|
|
8
|
-
import { type RouterNext } from './router.js';
|
|
9
|
+
import { type Router, type RouterNext } from './router.js';
|
|
9
10
|
import { type ShownToast } from './toaster.js';
|
|
11
|
+
import type { Pages } from './pages.js';
|
|
12
|
+
import { type DrawnParts } from './parts.js';
|
|
13
|
+
import { type UiArea } from './ui.js';
|
|
14
|
+
import type { Widgets } from './widgets.js';
|
|
10
15
|
export type Plugin = {
|
|
11
16
|
readonly name: string;
|
|
12
17
|
readonly root: string;
|
|
@@ -27,6 +32,23 @@ export type Lifecycle<State extends object> = {
|
|
|
27
32
|
caught<N extends RoutedEvent>(event: N, e: Frozen<Args<N>>, next: RouterNext<N>, failure: Caught): Promise<EventResult<N>>;
|
|
28
33
|
raise(method: string, payload: Readonly<Record<string, unknown>>): Promise<unknown>;
|
|
29
34
|
};
|
|
35
|
+
export type CmodPlugin = {
|
|
36
|
+
readonly conversations: Conversations;
|
|
37
|
+
readonly widgets: Widgets;
|
|
38
|
+
readonly pages: Pages;
|
|
39
|
+
};
|
|
40
|
+
export type ServeCmodPlugin = (served: {
|
|
41
|
+
readonly claude: Claude;
|
|
42
|
+
readonly router: Router;
|
|
43
|
+
readonly store: string;
|
|
44
|
+
readonly project: () => string;
|
|
45
|
+
readonly report: (id: string, message: string, error: unknown) => void;
|
|
46
|
+
readonly clear: (id: string) => void;
|
|
47
|
+
readonly tellRefusedPress: (mod: string, error: unknown) => void;
|
|
48
|
+
readonly parts: DrawnParts;
|
|
49
|
+
readonly markdownIn: UiArea<object>['markdownIn'];
|
|
50
|
+
readonly tellStylers: UiArea<object>['restyled'];
|
|
51
|
+
}) => CmodPlugin;
|
|
30
52
|
export declare function readPlugin(claude: Claude): Promise<Plugin>;
|
|
31
|
-
export declare function createLifecycle<State extends object, Declared extends Options = Options>(definition: ModDefinition<State, string, Declared>, permissionRoutes?: () => PermissionRoutes | undefined, options?: PluginOptions, asksPerson?: boolean): Lifecycle<State>;
|
|
53
|
+
export declare function createLifecycle<State extends object, Declared extends Options = Options>(definition: ModDefinition<State, string, Declared>, permissionRoutes?: () => PermissionRoutes | undefined, options?: PluginOptions, asksPerson?: boolean, serveCmodPlugin?: ServeCmodPlugin): Lifecycle<State>;
|
|
32
54
|
//# sourceMappingURL=lifecycle.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lifecycle.d.ts","sourceRoot":"","sources":["../src/runtime/lifecycle.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,EAAqB,WAAW,EAAE,MAAM,EAAc,aAAa,EAAwB,MAAM,aAAa,CAAA;AAGxI,OAAO,KAAK,EAAW,GAAG,EAAE,aAAa,EAA8G,MAAM,WAAW,CAAA;AACxK,OAAO,KAAK,EAAE,OAAO,EAAgB,MAAM,eAAe,CAAA;AAC1D,OAAO,EAA4N,KAAK,KAAK,EAAE,MAAM,eAAe,CAAA;AAGpQ,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;
|
|
1
|
+
{"version":3,"file":"lifecycle.d.ts","sourceRoot":"","sources":["../src/runtime/lifecycle.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,EAAqB,WAAW,EAAE,MAAM,EAAc,aAAa,EAAwB,MAAM,aAAa,CAAA;AAGxI,OAAO,KAAK,EAAW,GAAG,EAAE,aAAa,EAA8G,MAAM,WAAW,CAAA;AACxK,OAAO,KAAK,EAAE,OAAO,EAAgB,MAAM,eAAe,CAAA;AAC1D,OAAO,EAA4N,KAAK,KAAK,EAAE,MAAM,eAAe,CAAA;AAGpQ,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AAIzC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAIvD,OAAO,EAA6F,KAAK,WAAW,EAAE,MAAM,YAAY,CAAA;AACxI,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAA;AAM7D,OAAO,EAA2B,KAAK,MAAM,EAAE,KAAK,UAAU,EAAE,MAAM,aAAa,CAAA;AAMnF,OAAO,EAA+B,KAAK,UAAU,EAAgB,MAAM,cAAc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CAAC,KAAK,EAAE,UAAU,CAAA;IAC1B,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC,YAAY,CAAC,CAAA;IACjD,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC,UAAU,CAAC,CAAA;CACjD,KAAK,UAAU,CAAA;AAyDhB,wBAAsB,UAAU,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAyBhE;AAwBD,wBAAgB,eAAe,CAAC,KAAK,SAAS,MAAM,EAAE,QAAQ,SAAS,OAAO,GAAG,OAAO,EACtF,UAAU,EAAE,aAAa,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,CAAC,EAClD,gBAAgB,GAAE,MAAM,gBAAgB,GAAG,SAA2B,EACtE,OAAO,GAAE,aAAkB,EAC3B,UAAU,UAAO,EACjB,eAAe,CAAC,EAAE,eAAe,GAChC,SAAS,CAAC,KAAK,CAAC,CA4hBlB"}
|
package/runtime/lifecycle.js
CHANGED
|
@@ -4,7 +4,6 @@ import { firstLine, formatExit, messageOf } from '../utils/text.js';
|
|
|
4
4
|
import { beforeDeadline, settledAfterAbort } from './deadline.js';
|
|
5
5
|
import { announcementMs, announcementOf } from './announce.js';
|
|
6
6
|
import { bind } from './bound.js';
|
|
7
|
-
import { serveConversations } from './conversations.js';
|
|
8
7
|
import { answerCall, answeringOwnCalls, cmodPluginName, dependencyCalls, loadedMethod, withBareRefusals } from './dependencies.js';
|
|
9
8
|
import { keepEngine } from './engine.js';
|
|
10
9
|
import { classicFailure, classicHook, userSkillHook } from './hooks.js';
|
|
@@ -20,11 +19,9 @@ import { createState } from './state.js';
|
|
|
20
19
|
import { createToaster } from './toaster.js';
|
|
21
20
|
import { toolCalls } from './tool-calls.js';
|
|
22
21
|
import { createHotkeys } from './hotkeys.js';
|
|
23
|
-
import { servePages } from './pages.js';
|
|
24
22
|
import { drawnParts } from './parts.js';
|
|
25
23
|
import { createWatches } from './watches.js';
|
|
26
|
-
import { createUi, partMethods } from './ui.js';
|
|
27
|
-
import { serveWidgets } from './widgets.js';
|
|
24
|
+
import { createUi, partMethods, stalePress } from './ui.js';
|
|
28
25
|
import { Progress } from '../ui/components.js';
|
|
29
26
|
import { Box, Text } from '../ui/elements.js';
|
|
30
27
|
const listenMethods = [conversationMethods.subscribe, conversationMethods.watchBefore];
|
|
@@ -95,7 +92,7 @@ async function readJson(read, path) {
|
|
|
95
92
|
throw new Error(`${path} is not JSON (${messageOf(error)}). Fix it, then press Retry.`);
|
|
96
93
|
}
|
|
97
94
|
}
|
|
98
|
-
export function createLifecycle(definition, permissionRoutes = () => undefined, options = {}, asksPerson = true) {
|
|
95
|
+
export function createLifecycle(definition, permissionRoutes = () => undefined, options = {}, asksPerson = true, serveCmodPlugin) {
|
|
99
96
|
let router = createRouter();
|
|
100
97
|
let startingRouter;
|
|
101
98
|
let phase = 'starting';
|
|
@@ -278,7 +275,7 @@ export function createLifecycle(definition, permissionRoutes = () => undefined,
|
|
|
278
275
|
return;
|
|
279
276
|
const activeRouter = createRouter();
|
|
280
277
|
startingRouter = activeRouter;
|
|
281
|
-
const active = await createMod(definition, { ...runtime, router: activeRouter, dataFolder: dataFolder(plugin.store, plugin.name), store: plugin.store, permissionRoutes, options: pluginOptions, nextDraw })
|
|
278
|
+
const active = await createMod(definition, { ...runtime, router: activeRouter, dataFolder: dataFolder(plugin.store, plugin.name), store: plugin.store, permissionRoutes, options: pluginOptions, nextDraw, serveCmodPlugin })
|
|
282
279
|
.catch(async (error) => {
|
|
283
280
|
if (error instanceof MissingOptions && (await askOptions(error)))
|
|
284
281
|
return undefined;
|
|
@@ -965,17 +962,24 @@ async function createMod(definition, runtime) {
|
|
|
965
962
|
router.add('skill.prompt', userSkillHook(claude));
|
|
966
963
|
router.add('ui.press', (e, next) => area.asked(() => next(e)));
|
|
967
964
|
let api = {};
|
|
968
|
-
const conversations = definition.name === cmodPluginName ? serveConversations({ claude, router, store: runtime.store, project: () => modState.root, report: (id, message, error) => report({ id, message, error }), clear: (id) => toaster.toast.dismiss(id) }) : undefined;
|
|
969
965
|
let pages;
|
|
970
966
|
const reportPart = (id, message, error) => report({ id, message, error });
|
|
967
|
+
const tellRefusedPress = (to, error) => {
|
|
968
|
+
if (messageOf(error).includes(stalePress))
|
|
969
|
+
toaster.toast.warning(`The ${to} button was from an older drawing, so nothing ran`, { id: `press:${to}`, description: 'Press the button it shows now.' });
|
|
970
|
+
else
|
|
971
|
+
report({ id: `press:${to}`, message: `${to} did not take the press`, error, isCritical: true });
|
|
972
|
+
};
|
|
971
973
|
const pressElsewhere = (to, input) => void claude.cmod.call({ to, method: partMethods.press, input }).catch((error) => {
|
|
972
974
|
parts?.forget(to);
|
|
973
975
|
claude.ui.invalidate('ui.render');
|
|
974
|
-
|
|
976
|
+
tellRefusedPress(to, error);
|
|
975
977
|
});
|
|
976
978
|
parts = drawnParts({ claude, report: reportPart, press: (to, input) => (pages === undefined ? pressElsewhere(to, input) : pages.press(to, input)) });
|
|
977
|
-
const
|
|
978
|
-
|
|
979
|
+
const served = runtime.serveCmodPlugin?.({ claude, router, store: runtime.store, project: () => modState.root, report: reportPart, clear: (id) => toaster.toast.dismiss(id), tellRefusedPress, parts, markdownIn: area.markdownIn, tellStylers: area.restyled });
|
|
980
|
+
const conversations = served?.conversations;
|
|
981
|
+
const widgets = served?.widgets;
|
|
982
|
+
pages = served?.pages;
|
|
979
983
|
const tellColor = (to, told) => {
|
|
980
984
|
if (told.session === '' || to === cmodPluginName)
|
|
981
985
|
return;
|
package/runtime/pages.d.ts
CHANGED
|
@@ -19,10 +19,11 @@ export type Pages = {
|
|
|
19
19
|
apply(listener: PageApply): void;
|
|
20
20
|
};
|
|
21
21
|
export declare function pagesOf(input: unknown): PageDeclaration[];
|
|
22
|
-
export declare function servePages({ claude, router, report, widgets, parts, tellStylers, }: {
|
|
22
|
+
export declare function servePages({ claude, router, report, tellRefusedPress, widgets, parts, tellStylers, }: {
|
|
23
23
|
readonly claude: Claude;
|
|
24
24
|
readonly router: Router;
|
|
25
25
|
readonly report: (id: string, message: string, error: unknown) => void;
|
|
26
|
+
readonly tellRefusedPress: (mod: string, error: unknown) => void;
|
|
26
27
|
readonly widgets: Pick<Widgets, 'update'>;
|
|
27
28
|
readonly parts: DrawnParts;
|
|
28
29
|
readonly tellStylers: (stylers: readonly string[]) => void;
|
package/runtime/pages.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pages.d.ts","sourceRoot":"","sources":["../src/runtime/pages.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAIhD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AAEzC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAA;AAC5C,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AACzC,OAAO,
|
|
1
|
+
{"version":3,"file":"pages.d.ts","sourceRoot":"","sources":["../src/runtime/pages.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAIhD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AAEzC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAA;AAC5C,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AACzC,OAAO,EAAe,KAAK,eAAe,EAAE,KAAK,WAAW,EAAE,KAAK,SAAS,EAAE,KAAK,WAAW,EAAE,KAAK,UAAU,EAAE,MAAM,SAAS,CAAA;AAChI,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AAI3C,MAAM,MAAM,QAAQ,GAAG;IAAE,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,SAAS,eAAe,EAAE,CAAA;CAAE,CAAA;AAE3F,MAAM,MAA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C,OAAO,EAAE,QAAQ,CAAC,CAAA;IACzC,QAAQ,CAAC,KAAK,EAAE,UAAU,CAAA;IAC1B,QAAQ,CAAC,WAAW,EAAE,CAAC,OAAO,EAAE,SAAS,MAAM,EAAE,KAAK,IAAI,CAAA;CAC3D,GAAG,KAAK,CA6HR"}
|
package/runtime/pages.js
CHANGED
|
@@ -2,13 +2,13 @@ import { isObject } from '../records.js';
|
|
|
2
2
|
import { Text } from '../ui/elements.js';
|
|
3
3
|
import { messageOf } from '../utils/text.js';
|
|
4
4
|
import { cmodPluginName, isNotInstalled } from './dependencies.js';
|
|
5
|
-
import { partMethods
|
|
5
|
+
import { partMethods } from './ui.js';
|
|
6
6
|
const askedWaitMs = 1000;
|
|
7
7
|
export function pagesOf(input) {
|
|
8
8
|
const listed = isObject(input) && Array.isArray(input['pages']) ? input['pages'] : [];
|
|
9
9
|
return listed.filter(isObject).flatMap((each) => (typeof each['id'] === 'string' && typeof each['title'] === 'string' && (each['place'] === 'sidebar' || each['place'] === 'settings') ? [{ id: each['id'], title: each['title'], place: each['place'] }] : []));
|
|
10
10
|
}
|
|
11
|
-
export function servePages({ claude, router, report, widgets, parts, tellStylers, }) {
|
|
11
|
+
export function servePages({ claude, router, report, tellRefusedPress, widgets, parts, tellStylers, }) {
|
|
12
12
|
const declared = new Map();
|
|
13
13
|
const stylers = new Set();
|
|
14
14
|
const asking = new Map();
|
|
@@ -92,10 +92,7 @@ export function servePages({ claude, router, report, widgets, parts, tellStylers
|
|
|
92
92
|
.then((answer) => void update(mod, (isObject(answer) ? answer : {})), (error) => {
|
|
93
93
|
parts.forget(mod);
|
|
94
94
|
claude.ui.invalidate('ui.render');
|
|
95
|
-
|
|
96
|
-
claude.ui.log(`cmod: ${mod} draws its page again, because the button pressed was from an older drawing:${messageOf(error)}`, { to: 'debug' });
|
|
97
|
-
else
|
|
98
|
-
report(`press:${mod}`, `${mod} did not take the press`, error);
|
|
95
|
+
tellRefusedPress(mod, error);
|
|
99
96
|
})
|
|
100
97
|
.finally(() => pressing.delete(pending));
|
|
101
98
|
pressing.add(pending);
|
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,EAAE,MAAM,EAAE,aAAa,EAAgB,aAAa,EAAE,MAAM,aAAa,CAAA;AACzG,OAAO,KAAK,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAE1C,OAAO,EAAW,KAAK,IAAI,EAAmC,KAAK,UAAU,EAAE,MAAM,gBAAgB,CAAA;AAGrG,OAAO,EAAwG,KAAK,aAAa,EAAE,KAAK,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAC5K,OAAO,EAA8C,KAAK,QAAQ,EAAkB,MAAM,iBAAiB,CAAA;AAG3G,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AAEzC,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AACzC,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AAE3C,eAAO,MAAM,WAAW;aACtB,IAAI,EAAE,YAAY;aAClB,IAAI,EAAE,WAAW;aACjB,KAAK,EAAE,YAAY;aACnB,KAAK,EAAE,YAAY;aACnB,OAAO,EAAE,mBAAmB;aAC5B,OAAO,EAAE,sBAAsB;CACvB,CAAA;AAEV,eAAO,MAAM,UAAU,yEAAyE,CAAA;AAEhG,MAAM,MAAM,SAAS,GAAG,SAAS,GAAG,UAAU,CAAA;AAE9C,MAAM,MAAM,iBAAiB,GAAG;IAAE,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,SAAS,IAAI,EAAE,CAAC;IAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,WAAW,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,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,CA4jBnJ"}
|
package/runtime/ui.js
CHANGED
|
@@ -586,37 +586,39 @@ export function createUi({ name, claude, router, report, announce, mod, borrowed
|
|
|
586
586
|
draws.delete(draw);
|
|
587
587
|
latestDraws.delete(key);
|
|
588
588
|
};
|
|
589
|
-
const drawPart = (key, title, input, render) => {
|
|
589
|
+
const drawPart = (key, title, input, render, drawFailure = () => undefined) => {
|
|
590
|
+
let handlers = [];
|
|
591
|
+
let tree;
|
|
590
592
|
try {
|
|
591
|
-
|
|
592
|
-
const tree = treeOf(render, pressed);
|
|
593
|
+
tree = treeOf(render, handlers);
|
|
593
594
|
failedDraws.delete(key);
|
|
594
|
-
const number = nextDraw();
|
|
595
|
-
const inputs = latestDraws.get(key) ?? new Map();
|
|
596
|
-
latestDraws.set(key, inputs);
|
|
597
|
-
const drawnFor = JSON.stringify('turn' in input ? { ...input, turn: input.turn.prompt.id } : input);
|
|
598
|
-
const earlier = inputs.get(drawnFor)?.draws ?? [];
|
|
599
|
-
const kept = [...earlier, number].slice(-2);
|
|
600
|
-
for (const draw of earlier)
|
|
601
|
-
if (!kept.includes(draw))
|
|
602
|
-
draws.delete(draw);
|
|
603
|
-
inputs.delete(drawnFor);
|
|
604
|
-
inputs.set(drawnFor, { draws: kept, tree: JSON.stringify(tree), render });
|
|
605
|
-
const [oldest] = inputs;
|
|
606
|
-
if (inputs.size > keptDrawInputs && oldest !== undefined) {
|
|
607
|
-
for (const draw of oldest[1].draws)
|
|
608
|
-
draws.delete(draw);
|
|
609
|
-
inputs.delete(oldest[0]);
|
|
610
|
-
}
|
|
611
|
-
draws.set(number, { id: key, handlers: pressed });
|
|
612
|
-
return { draw: number, tree };
|
|
613
595
|
}
|
|
614
596
|
catch (error) {
|
|
615
597
|
if (!failedDraws.has(key))
|
|
616
598
|
report({ id: key, message: `The ${title} could not draw`, error });
|
|
617
599
|
failedDraws.add(key);
|
|
618
|
-
|
|
600
|
+
handlers = [];
|
|
601
|
+
tree = treeOf(() => drawFailure(error), handlers);
|
|
602
|
+
}
|
|
603
|
+
const number = nextDraw();
|
|
604
|
+
const inputs = latestDraws.get(key) ?? new Map();
|
|
605
|
+
latestDraws.set(key, inputs);
|
|
606
|
+
const drawnFor = JSON.stringify('turn' in input ? { ...input, turn: input.turn.prompt.id } : input);
|
|
607
|
+
const earlier = inputs.get(drawnFor)?.draws ?? [];
|
|
608
|
+
const kept = [...earlier, number].slice(-2);
|
|
609
|
+
for (const draw of earlier)
|
|
610
|
+
if (!kept.includes(draw))
|
|
611
|
+
draws.delete(draw);
|
|
612
|
+
inputs.delete(drawnFor);
|
|
613
|
+
inputs.set(drawnFor, { draws: kept, tree: JSON.stringify(tree), render });
|
|
614
|
+
const [oldest] = inputs;
|
|
615
|
+
if (inputs.size > keptDrawInputs && oldest !== undefined) {
|
|
616
|
+
for (const draw of oldest[1].draws)
|
|
617
|
+
draws.delete(draw);
|
|
618
|
+
inputs.delete(oldest[0]);
|
|
619
619
|
}
|
|
620
|
+
draws.set(number, { id: key, handlers });
|
|
621
|
+
return { draw: number, tree };
|
|
620
622
|
};
|
|
621
623
|
const draw = (input) => {
|
|
622
624
|
if ('markdown' in input)
|
|
@@ -625,7 +627,8 @@ export function createUi({ name, claude, router, report, announce, mod, borrowed
|
|
|
625
627
|
const added = pages.get(input.page);
|
|
626
628
|
if (added === undefined)
|
|
627
629
|
throw new Error(`${name} has no ${input.page} page.`);
|
|
628
|
-
|
|
630
|
+
const title = `${added.init.title} page`;
|
|
631
|
+
return drawPart(`page:${input.page}`, title, input, () => added.init.render(mod(), { params: input.params, isFocused: input.isFocused, columns: input.columns }), (error) => Text({ color: 'error', children: `The ${title} could not draw: ${messageOf(error)}` }));
|
|
629
632
|
}
|
|
630
633
|
const widget = widgets.get(input.widget);
|
|
631
634
|
if (widget === undefined || !widget.areas.includes(input.area))
|
package/src/jobs/program.ts
CHANGED
|
@@ -21,13 +21,15 @@ const staleMs = 15_000
|
|
|
21
21
|
|
|
22
22
|
const retryWithinMs = 1000
|
|
23
23
|
|
|
24
|
-
export function program(options: { readonly command: readonly string[]; readonly environment?: Record<string, string>; readonly singleInstance?: boolean }): Job<Program> {
|
|
25
|
-
const { command, environment, singleInstance = false } = options
|
|
24
|
+
export function program(options: { readonly command: readonly string[]; readonly environment?: Record<string, string>; readonly singleInstance?: boolean; readonly isService?: boolean }): Job<Program> {
|
|
25
|
+
const { command, environment, singleInstance = false, isService = false } = options
|
|
26
26
|
return ({ mod, announce, reserveName }) => {
|
|
27
27
|
const { claude, report, spawnCmod, watches } = engineOf(mod)
|
|
28
28
|
const [executable] = command
|
|
29
29
|
if (executable === undefined) throw new Error(`${mod.name}: the program has no command. Name the program on PATH and its arguments, such as ['preview-server', '--port', '0'].`)
|
|
30
|
-
if (
|
|
30
|
+
if (isService) reserveName('program', basename(executable), `${mod.name}: the service ${executable} is already added. Give each isService program its own executable.`)
|
|
31
|
+
else if (singleInstance) reserveName('program', basename(executable), `${mod.name}: the single instance of ${executable} is already added. Give each singleInstance program its own executable.`)
|
|
32
|
+
const isElected = singleInstance || isService
|
|
31
33
|
const request = { argv: command, ...(environment === undefined ? {} : { env: environment }) }
|
|
32
34
|
let state: Program['state'] = 'stopped'
|
|
33
35
|
let address: Address | undefined
|
|
@@ -39,7 +41,10 @@ export function program(options: { readonly command: readonly string[]; readonly
|
|
|
39
41
|
let instance: Promise<string> | undefined
|
|
40
42
|
let leaseCheck: Promise<void> | undefined
|
|
41
43
|
|
|
42
|
-
const spawn = () =>
|
|
44
|
+
const spawn = () => {
|
|
45
|
+
if (isService) return spawnCmod(['program', mod.name, '--service', ...Object.keys(environment ?? {}).flatMap((name) => ['--env', name]), '--', ...command], environment)
|
|
46
|
+
return singleInstance ? spawnCmod(['program', mod.name, '--no-wait', '--', ...command], environment) : claude.process.spawn(request)
|
|
47
|
+
}
|
|
43
48
|
|
|
44
49
|
const instanceFile = () =>
|
|
45
50
|
(instance ??= Promise.all([claude.env.home(), claude.env.dataHome()]).then(([home, dataHome]) => instancePath(storeFolder({ HOME: home, XDG_DATA_HOME: dataHome }), mod.name, basename(executable))))
|
|
@@ -116,7 +121,7 @@ export function program(options: { readonly command: readonly string[]; readonly
|
|
|
116
121
|
const lines = `${pending}${piece.text}`.split('\n')
|
|
117
122
|
pending = lines.pop() ?? ''
|
|
118
123
|
for (const line of lines.slice(0, 1)) {
|
|
119
|
-
if (
|
|
124
|
+
if (isElected && line.trim() === 'held') return await follow(await instanceFile())
|
|
120
125
|
const next = addressOf(line.trim())
|
|
121
126
|
if (next === undefined) {
|
|
122
127
|
stop(`its first line is "${line.trim()}". Write 127.0.0.1:<port> or unix:<socket path> as the first line on standard output.`)
|
package/src/records.ts
CHANGED
|
@@ -264,6 +264,14 @@ export function instancePath(store: string, mod: string, executable: string): st
|
|
|
264
264
|
return `${instanceFolder(store, mod)}/${executable}.json`
|
|
265
265
|
}
|
|
266
266
|
|
|
267
|
+
export function serviceFolder(store: string, mod: string): string {
|
|
268
|
+
return `${store}/services/${checkedName(mod)}`
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
export function servicePath(store: string, mod: string, executable: string): string {
|
|
272
|
+
return `${serviceFolder(store, mod)}/${checkedName(executable)}.json`
|
|
273
|
+
}
|
|
274
|
+
|
|
267
275
|
export type Links = { readonly marketplaces: Readonly<Record<string, string>>; readonly turnedOff: Readonly<Record<string, readonly string[]>> }
|
|
268
276
|
|
|
269
277
|
export function parseLinks(value: unknown, path: string): Links {
|
|
@@ -369,9 +377,9 @@ function readHotkeys(hotkeys: unknown): Steps {
|
|
|
369
377
|
return { hotkeys: checkHotkeys('package.json "cmod"', hotkeys as Record<string, HotkeyInit>) }
|
|
370
378
|
}
|
|
371
379
|
|
|
372
|
-
export const coreVersion = '5.
|
|
380
|
+
export const coreVersion = '5.9.0'
|
|
373
381
|
|
|
374
|
-
export const oldestCmodVersion = '5.
|
|
382
|
+
export const oldestCmodVersion = '5.9.0'
|
|
375
383
|
|
|
376
384
|
export function hotkeyCommand(mod: string, hotkey: string): string {
|
|
377
385
|
return `${mod}--${hotkey}`
|
|
@@ -401,8 +409,14 @@ function readCommand(steps: Record<string, unknown>, key: 'install' | 'uninstall
|
|
|
401
409
|
return { [key]: command }
|
|
402
410
|
}
|
|
403
411
|
|
|
404
|
-
export function
|
|
405
|
-
return
|
|
412
|
+
export function bundleOptions(steps: Steps) {
|
|
413
|
+
return {
|
|
414
|
+
format: 'esm' as const,
|
|
415
|
+
target: 'browser' as const,
|
|
416
|
+
external: ['claude-code'],
|
|
417
|
+
define: steps.approve === true ? {} : { 'globalThis.cmodWithoutApprove': 'true' },
|
|
418
|
+
minify: { whitespace: true, identifiers: true },
|
|
419
|
+
}
|
|
406
420
|
}
|
|
407
421
|
|
|
408
422
|
export function scriptPaths(command: string): string[] {
|
package/src/register.ts
CHANGED
|
@@ -3,11 +3,13 @@ import type { ModDefinition } from './mod.js'
|
|
|
3
3
|
import type { Options } from './options.js'
|
|
4
4
|
import type { Claude } from './runtime/claude.js'
|
|
5
5
|
import type { RoutedEvent } from './runtime/hooks.js'
|
|
6
|
+
import { serveConversations } from './runtime/conversations.js'
|
|
6
7
|
import { settledAfterAbort } from './runtime/deadline.js'
|
|
7
|
-
import { cmodPluginName } from './runtime/dependencies.js'
|
|
8
8
|
import { readDevice } from './runtime/device.js'
|
|
9
|
-
import { createLifecycle, readPlugin, type Lifecycle } from './runtime/lifecycle.js'
|
|
9
|
+
import { createLifecycle, readPlugin, type Lifecycle, type ServeCmodPlugin } from './runtime/lifecycle.js'
|
|
10
|
+
import { servePages } from './runtime/pages.js'
|
|
10
11
|
import { permissionRoutes, type PermissionRoutes } from './runtime/permission-check.js'
|
|
12
|
+
import { serveWidgets } from './runtime/widgets.js'
|
|
11
13
|
import { messageOf } from './utils/text.js'
|
|
12
14
|
|
|
13
15
|
let lifecycle: Lifecycle<object>
|
|
@@ -136,10 +138,34 @@ function routeCallFailure(_$: EngineInterface, eventInput: Frozen<Args<'cmod.cal
|
|
|
136
138
|
return lifecycle.caught('cmod.call', withCaller(eventInput, passOn), withoutCaller(passOn), passOn)
|
|
137
139
|
}
|
|
138
140
|
|
|
141
|
+
export const serveCmodPlugin: ServeCmodPlugin = ({ claude, router, store, project, report, clear, tellRefusedPress, parts, markdownIn, tellStylers }) => {
|
|
142
|
+
const conversations = serveConversations({ claude, router, store, project, report, clear })
|
|
143
|
+
const widgets = serveWidgets({ claude, router, store, report, turnClosedBy: (rowId) => conversations.turnClosedBy(rowId), parts, markdownIn })
|
|
144
|
+
const pages = servePages({ claude, router, report, tellRefusedPress, widgets, parts, tellStylers })
|
|
145
|
+
return { conversations, widgets, pages }
|
|
146
|
+
}
|
|
147
|
+
|
|
139
148
|
export function registerMod<State extends object, Declared extends Options>(addHook: On, definition: ModDefinition<State, string, Declared>, options: PluginOptions): void {
|
|
149
|
+
registerHooks(addHook, definition, options)
|
|
150
|
+
addHook('ui.render', routeToMod).catch(routeFailure)
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
export function registerCmodPlugin<State extends object, Declared extends Options>(addHook: On, definition: ModDefinition<State, string, Declared>, options: PluginOptions): void {
|
|
154
|
+
registerHooks(addHook, definition, options, serveCmodPlugin)
|
|
155
|
+
addHook('ui.render', { component: ['AbovePrompt', 'PromptHint', 'SessionMode', 'Spinner', 'TurnDuration', 'Pane'] }, routeToMod).catch(routeFailure)
|
|
156
|
+
addHook('command.describe', { command: /--/ }, routeToMod).catch(routeFailure)
|
|
157
|
+
addHook('session.append', routeToMod).catch(routeFailure)
|
|
158
|
+
addHook('session.receive', routeToMod).catch(routeFailure)
|
|
159
|
+
addHook('agent.spawn', routeToMod).catch(routeFailure)
|
|
160
|
+
addHook('prompt.attachment', routeToMod).catch(routeFailure)
|
|
161
|
+
addHook('turn.start', routeToMod).catch(routeFailure)
|
|
162
|
+
addHook('turn.complete', routeToMod).catch(routeFailure)
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
function registerHooks<State extends object, Declared extends Options>(addHook: On, definition: ModDefinition<State, string, Declared>, options: PluginOptions, serve?: ServeCmodPlugin): void {
|
|
140
166
|
permissionCheck = undefined
|
|
141
167
|
registered = definition
|
|
142
|
-
lifecycle = createLifecycle(definition, () => permissionCheck, options)
|
|
168
|
+
lifecycle = createLifecycle(definition, () => permissionCheck, options, true, serve)
|
|
143
169
|
addHook('session.start', startMod)
|
|
144
170
|
addHook('classic.Setup', routeToMod).catch(routeFailure)
|
|
145
171
|
addHook('classic.SessionStart', routeToMod).catch(routeFailure)
|
|
@@ -176,21 +202,11 @@ export function registerMod<State extends object, Declared extends Options>(addH
|
|
|
176
202
|
addHook('command.run', routeToMod).catch(routeFailure)
|
|
177
203
|
addHook('session.measure', routeToMod).catch(routeFailure)
|
|
178
204
|
addHook('skill.prompt', routeToMod).catch(routeFailure)
|
|
179
|
-
if (definition.name === cmodPluginName) addHook('ui.render', { component: ['AbovePrompt', 'PromptHint', 'SessionMode', 'Spinner', 'TurnDuration', 'Pane'] }, routeToMod).catch(routeFailure)
|
|
180
|
-
else addHook('ui.render', routeToMod).catch(routeFailure)
|
|
181
205
|
addHook('ui.press', routeToMod).catch(routeFailure)
|
|
182
206
|
addHook('ui.scroll', routeToMod).catch(routeFailure)
|
|
183
207
|
addHook('ui.close', routeToMod).catch(routeFailure)
|
|
184
208
|
addHook('cmod.call', { to: definition.name }, routeCallToMod).catch(routeCallFailure)
|
|
185
209
|
addHook('session.compact', routeToMod).catch(routeFailure)
|
|
186
|
-
if (definition.name !== cmodPluginName) return
|
|
187
|
-
addHook('command.describe', { command: /--/ }, routeToMod).catch(routeFailure)
|
|
188
|
-
addHook('session.append', routeToMod).catch(routeFailure)
|
|
189
|
-
addHook('session.receive', routeToMod).catch(routeFailure)
|
|
190
|
-
addHook('agent.spawn', routeToMod).catch(routeFailure)
|
|
191
|
-
addHook('prompt.attachment', routeToMod).catch(routeFailure)
|
|
192
|
-
addHook('turn.start', routeToMod).catch(routeFailure)
|
|
193
|
-
addHook('turn.complete', routeToMod).catch(routeFailure)
|
|
194
210
|
}
|
|
195
211
|
|
|
196
212
|
export function registerPermissionCheck(addHook: On): void {
|
package/src/runtime/lifecycle.ts
CHANGED
|
@@ -10,7 +10,7 @@ import type { Claude } from './claude.js'
|
|
|
10
10
|
import { beforeDeadline, settledAfterAbort } from './deadline.js'
|
|
11
11
|
import { announcementMs, announcementOf } from './announce.js'
|
|
12
12
|
import { bind } from './bound.js'
|
|
13
|
-
import {
|
|
13
|
+
import type { Conversations } from './conversations.js'
|
|
14
14
|
import { answerCall, answeringOwnCalls, cmodPluginName, dependencyCalls, loadedMethod, withBareRefusals } from './dependencies.js'
|
|
15
15
|
import type { Device } from '../session/context/turn/device.js'
|
|
16
16
|
import { keepEngine } from './engine.js'
|
|
@@ -30,11 +30,11 @@ import { createState } from './state.js'
|
|
|
30
30
|
import { createToaster, type Failure, type ShownToast, type Toaster } from './toaster.js'
|
|
31
31
|
import { toolCalls } from './tool-calls.js'
|
|
32
32
|
import { createHotkeys } from './hotkeys.js'
|
|
33
|
-
import {
|
|
33
|
+
import type { Pages } from './pages.js'
|
|
34
34
|
import { drawnParts, type DrawnParts } from './parts.js'
|
|
35
35
|
import { createWatches } from './watches.js'
|
|
36
|
-
import { createUi, partMethods, type BorrowedMarkdown, type PartDraw, type PartPress, type PartsUpdate, type ShownPages, type UiArea } from './ui.js'
|
|
37
|
-
import {
|
|
36
|
+
import { createUi, partMethods, stalePress, type BorrowedMarkdown, type PartDraw, type PartPress, type PartsUpdate, type ShownPages, type UiArea } from './ui.js'
|
|
37
|
+
import type { Widgets } from './widgets.js'
|
|
38
38
|
import { Progress } from '../ui/components.js'
|
|
39
39
|
import { Box, Text } from '../ui/elements.js'
|
|
40
40
|
|
|
@@ -63,6 +63,21 @@ export type Lifecycle<State extends object> = {
|
|
|
63
63
|
raise(method: string, payload: Readonly<Record<string, unknown>>): Promise<unknown>
|
|
64
64
|
}
|
|
65
65
|
|
|
66
|
+
export type CmodPlugin = { readonly conversations: Conversations; readonly widgets: Widgets; readonly pages: Pages }
|
|
67
|
+
|
|
68
|
+
export type ServeCmodPlugin = (served: {
|
|
69
|
+
readonly claude: Claude
|
|
70
|
+
readonly router: Router
|
|
71
|
+
readonly store: string
|
|
72
|
+
readonly project: () => string
|
|
73
|
+
readonly report: (id: string, message: string, error: unknown) => void
|
|
74
|
+
readonly clear: (id: string) => void
|
|
75
|
+
readonly tellRefusedPress: (mod: string, error: unknown) => void
|
|
76
|
+
readonly parts: DrawnParts
|
|
77
|
+
readonly markdownIn: UiArea<object>['markdownIn']
|
|
78
|
+
readonly tellStylers: UiArea<object>['restyled']
|
|
79
|
+
}) => CmodPlugin
|
|
80
|
+
|
|
66
81
|
type ModRuntime = {
|
|
67
82
|
readonly claude: Claude
|
|
68
83
|
readonly router: Router
|
|
@@ -72,6 +87,7 @@ type ModRuntime = {
|
|
|
72
87
|
readonly permissionRoutes: () => PermissionRoutes | undefined
|
|
73
88
|
readonly options: PluginOptions
|
|
74
89
|
readonly nextDraw: () => number
|
|
90
|
+
readonly serveCmodPlugin: ServeCmodPlugin | undefined
|
|
75
91
|
}
|
|
76
92
|
|
|
77
93
|
type ActiveMod<State extends object, Declared extends Options> = {
|
|
@@ -171,6 +187,7 @@ export function createLifecycle<State extends object, Declared extends Options =
|
|
|
171
187
|
permissionRoutes: () => PermissionRoutes | undefined = () => undefined,
|
|
172
188
|
options: PluginOptions = {},
|
|
173
189
|
asksPerson = true,
|
|
190
|
+
serveCmodPlugin?: ServeCmodPlugin,
|
|
174
191
|
): Lifecycle<State> {
|
|
175
192
|
let router: Router = createRouter()
|
|
176
193
|
let startingRouter: Router | undefined
|
|
@@ -363,7 +380,7 @@ export function createLifecycle<State extends object, Declared extends Options =
|
|
|
363
380
|
if (runtime === undefined || plugin === undefined) return
|
|
364
381
|
const activeRouter = createRouter()
|
|
365
382
|
startingRouter = activeRouter
|
|
366
|
-
const active = await createMod(definition, { ...runtime, router: activeRouter, dataFolder: dataFolder(plugin.store, plugin.name), store: plugin.store, permissionRoutes, options: pluginOptions, nextDraw })
|
|
383
|
+
const active = await createMod(definition, { ...runtime, router: activeRouter, dataFolder: dataFolder(plugin.store, plugin.name), store: plugin.store, permissionRoutes, options: pluginOptions, nextDraw, serveCmodPlugin })
|
|
367
384
|
.catch(async (error: unknown) => {
|
|
368
385
|
if (error instanceof MissingOptions && (await askOptions(error))) return undefined
|
|
369
386
|
await installer.close()
|
|
@@ -1007,18 +1024,23 @@ async function createMod<State extends object, Declared extends Options>(definit
|
|
|
1007
1024
|
router.add('skill.prompt', userSkillHook(claude))
|
|
1008
1025
|
router.add('ui.press', (e, next) => area.asked(() => next(e)))
|
|
1009
1026
|
let api: Readonly<Record<string, (input: never) => unknown>> = {}
|
|
1010
|
-
const conversations = definition.name === cmodPluginName ? serveConversations({ claude, router, store: runtime.store, project: () => modState.root, report: (id, message, error) => report({ id, message, error }), clear: (id) => toaster.toast.dismiss(id) }) : undefined
|
|
1011
1027
|
let pages: Pages | undefined
|
|
1012
1028
|
const reportPart = (id: string, message: string, error: unknown) => report({ id, message, error })
|
|
1029
|
+
const tellRefusedPress = (to: string, error: unknown) => {
|
|
1030
|
+
if (messageOf(error).includes(stalePress)) toaster.toast.warning(`The ${to} button was from an older drawing, so nothing ran`, { id: `press:${to}`, description: 'Press the button it shows now.' })
|
|
1031
|
+
else report({ id: `press:${to}`, message: `${to} did not take the press`, error, isCritical: true })
|
|
1032
|
+
}
|
|
1013
1033
|
const pressElsewhere = (to: string, input: PartPress) =>
|
|
1014
1034
|
void claude.cmod.call({ to, method: partMethods.press, input }).catch((error: unknown) => {
|
|
1015
1035
|
parts?.forget(to)
|
|
1016
1036
|
claude.ui.invalidate('ui.render')
|
|
1017
|
-
|
|
1037
|
+
tellRefusedPress(to, error)
|
|
1018
1038
|
})
|
|
1019
1039
|
parts = drawnParts({ claude, report: reportPart, press: (to, input) => (pages === undefined ? pressElsewhere(to, input) : pages.press(to, input)) })
|
|
1020
|
-
const
|
|
1021
|
-
|
|
1040
|
+
const served = runtime.serveCmodPlugin?.({ claude, router, store: runtime.store, project: () => modState.root, report: reportPart, clear: (id) => toaster.toast.dismiss(id), tellRefusedPress, parts, markdownIn: area.markdownIn, tellStylers: area.restyled })
|
|
1041
|
+
const conversations = served?.conversations
|
|
1042
|
+
const widgets = served?.widgets
|
|
1043
|
+
pages = served?.pages
|
|
1022
1044
|
const tellColor = (to: string, told: SessionColor) => {
|
|
1023
1045
|
if (told.session === '' || to === cmodPluginName) return
|
|
1024
1046
|
claude.clock.after(0, () => void claude.cmod.call({ to, method: conversationMethods.sessionColor, input: told }).catch((error: unknown) => claude.ui.warn('color:tell', `cmod: ${to} did not hear the session's color: ${messageOf(error)}`)))
|
package/src/runtime/pages.ts
CHANGED
|
@@ -6,7 +6,7 @@ import type { Claude } from './claude.js'
|
|
|
6
6
|
import { cmodPluginName, isNotInstalled } from './dependencies.js'
|
|
7
7
|
import type { DrawnParts } from './parts.js'
|
|
8
8
|
import type { Router } from './router.js'
|
|
9
|
-
import { partMethods,
|
|
9
|
+
import { partMethods, type PageDeclaration, type PageRequest, type PartPress, type PartsUpdate, type ShownPages } from './ui.js'
|
|
10
10
|
import type { Widgets } from './widgets.js'
|
|
11
11
|
|
|
12
12
|
const askedWaitMs = 1000
|
|
@@ -34,6 +34,7 @@ export function servePages({
|
|
|
34
34
|
claude,
|
|
35
35
|
router,
|
|
36
36
|
report,
|
|
37
|
+
tellRefusedPress,
|
|
37
38
|
widgets,
|
|
38
39
|
parts,
|
|
39
40
|
tellStylers,
|
|
@@ -41,6 +42,7 @@ export function servePages({
|
|
|
41
42
|
readonly claude: Claude
|
|
42
43
|
readonly router: Router
|
|
43
44
|
readonly report: (id: string, message: string, error: unknown) => void
|
|
45
|
+
readonly tellRefusedPress: (mod: string, error: unknown) => void
|
|
44
46
|
readonly widgets: Pick<Widgets, 'update'>
|
|
45
47
|
readonly parts: DrawnParts
|
|
46
48
|
readonly tellStylers: (stylers: readonly string[]) => void
|
|
@@ -131,8 +133,7 @@ export function servePages({
|
|
|
131
133
|
(error: unknown) => {
|
|
132
134
|
parts.forget(mod)
|
|
133
135
|
claude.ui.invalidate('ui.render')
|
|
134
|
-
|
|
135
|
-
else report(`press:${mod}`, `${mod} did not take the press`, error)
|
|
136
|
+
tellRefusedPress(mod, error)
|
|
136
137
|
},
|
|
137
138
|
)
|
|
138
139
|
.finally(() => pressing.delete(pending))
|
package/src/runtime/ui.ts
CHANGED
|
@@ -659,32 +659,34 @@ export function createUi<State extends object>({ name, claude, router, report, a
|
|
|
659
659
|
latestDraws.delete(key)
|
|
660
660
|
}
|
|
661
661
|
|
|
662
|
-
const drawPart = (key: string, title: string, input: PartDraw, render: () => RenderElement | undefined
|
|
662
|
+
const drawPart = (key: string, title: string, input: PartDraw, render: () => RenderElement | undefined, drawFailure: (error: unknown) => RenderElement | undefined = () => undefined): DrawnPart => {
|
|
663
|
+
let handlers: Handler[] = []
|
|
664
|
+
let tree: unknown
|
|
663
665
|
try {
|
|
664
|
-
|
|
665
|
-
const tree = treeOf(render, pressed)
|
|
666
|
+
tree = treeOf(render, handlers)
|
|
666
667
|
failedDraws.delete(key)
|
|
667
|
-
const number = nextDraw()
|
|
668
|
-
const inputs = latestDraws.get(key) ?? new Map<string, SentDrawing>()
|
|
669
|
-
latestDraws.set(key, inputs)
|
|
670
|
-
const drawnFor = JSON.stringify('turn' in input ? { ...input, turn: input.turn.prompt.id } : input)
|
|
671
|
-
const earlier = inputs.get(drawnFor)?.draws ?? []
|
|
672
|
-
const kept = [...earlier, number].slice(-2)
|
|
673
|
-
for (const draw of earlier) if (!kept.includes(draw)) draws.delete(draw)
|
|
674
|
-
inputs.delete(drawnFor)
|
|
675
|
-
inputs.set(drawnFor, { draws: kept, tree: JSON.stringify(tree), render })
|
|
676
|
-
const [oldest] = inputs
|
|
677
|
-
if (inputs.size > keptDrawInputs && oldest !== undefined) {
|
|
678
|
-
for (const draw of oldest[1].draws) draws.delete(draw)
|
|
679
|
-
inputs.delete(oldest[0])
|
|
680
|
-
}
|
|
681
|
-
draws.set(number, { id: key, handlers: pressed })
|
|
682
|
-
return { draw: number, tree }
|
|
683
668
|
} catch (error) {
|
|
684
669
|
if (!failedDraws.has(key)) report({ id: key, message: `The ${title} could not draw`, error })
|
|
685
670
|
failedDraws.add(key)
|
|
686
|
-
|
|
671
|
+
handlers = []
|
|
672
|
+
tree = treeOf(() => drawFailure(error), handlers)
|
|
673
|
+
}
|
|
674
|
+
const number = nextDraw()
|
|
675
|
+
const inputs = latestDraws.get(key) ?? new Map<string, SentDrawing>()
|
|
676
|
+
latestDraws.set(key, inputs)
|
|
677
|
+
const drawnFor = JSON.stringify('turn' in input ? { ...input, turn: input.turn.prompt.id } : input)
|
|
678
|
+
const earlier = inputs.get(drawnFor)?.draws ?? []
|
|
679
|
+
const kept = [...earlier, number].slice(-2)
|
|
680
|
+
for (const draw of earlier) if (!kept.includes(draw)) draws.delete(draw)
|
|
681
|
+
inputs.delete(drawnFor)
|
|
682
|
+
inputs.set(drawnFor, { draws: kept, tree: JSON.stringify(tree), render })
|
|
683
|
+
const [oldest] = inputs
|
|
684
|
+
if (inputs.size > keptDrawInputs && oldest !== undefined) {
|
|
685
|
+
for (const draw of oldest[1].draws) draws.delete(draw)
|
|
686
|
+
inputs.delete(oldest[0])
|
|
687
687
|
}
|
|
688
|
+
draws.set(number, { id: key, handlers })
|
|
689
|
+
return { draw: number, tree }
|
|
688
690
|
}
|
|
689
691
|
|
|
690
692
|
const draw = (input: PartDraw): DrawnPart | null => {
|
|
@@ -692,7 +694,8 @@ export function createUi<State extends object>({ name, claude, router, report, a
|
|
|
692
694
|
if ('page' in input) {
|
|
693
695
|
const added = pages.get(input.page)
|
|
694
696
|
if (added === undefined) throw new Error(`${name} has no ${input.page} page.`)
|
|
695
|
-
|
|
697
|
+
const title = `${added.init.title} page`
|
|
698
|
+
return drawPart(`page:${input.page}`, title, input, () => added.init.render(mod(), { params: input.params, isFocused: input.isFocused, columns: input.columns }), (error) => Text({ color: 'error', children: `The ${title} could not draw: ${messageOf(error)}` }))
|
|
696
699
|
}
|
|
697
700
|
const widget = widgets.get(input.widget)
|
|
698
701
|
if (widget === undefined || !widget.areas.includes(input.area)) return null
|
package/src/testing.ts
CHANGED
|
@@ -32,6 +32,7 @@ import { keepClaudeCode, type ClaudeCode } from './testing/claude-code.js'
|
|
|
32
32
|
import { createRouter } from './runtime/router.js'
|
|
33
33
|
import { toolInputOf } from './runtime/tool-calls.js'
|
|
34
34
|
import { createLifecycle } from './runtime/lifecycle.js'
|
|
35
|
+
import { serveCmodPlugin } from './register.js'
|
|
35
36
|
import { MissingOptions } from './runtime/options.js'
|
|
36
37
|
import { conversationMethods, pickedColor, type SessionColor } from './runtime/sessions.js'
|
|
37
38
|
import type { ShownToast } from './runtime/toaster.js'
|
|
@@ -282,7 +283,8 @@ export function testMod<State extends object, Declared extends Options = Options
|
|
|
282
283
|
}
|
|
283
284
|
const cmodClaude: Claude = { ...fake.claude, cmod: { call: async (input) => (input.to === name ? callMod(input.method, input.input) : fake.claude.cmod.call(input)) } }
|
|
284
285
|
const reportPart = (_id: string, message: string, error: unknown) => fake.claude.ui.log(`cmod: ${message}: ${messageOf(error)}`, { to: 'debug' })
|
|
285
|
-
const
|
|
286
|
+
const tellRefusedPress = (_mod: string, error: unknown) => fake.claude.ui.log(`cmod: ${name} did not take the press: ${messageOf(error)}`, { to: 'debug' })
|
|
287
|
+
const parts = drawnParts({ claude: cmodClaude, report: reportPart, press: (mod: string, input: PartPress) => void pressPart(input).catch((error: unknown) => tellRefusedPress(mod, error)) })
|
|
286
288
|
const servedWidgets = async (): Promise<Widgets> => {
|
|
287
289
|
const own = name === cmodPluginName && lifecycle.mod !== undefined ? engineOf(lifecycle.mod).widgets : undefined
|
|
288
290
|
if (own !== undefined) return own
|
|
@@ -298,7 +300,7 @@ export function testMod<State extends object, Declared extends Options = Options
|
|
|
298
300
|
}
|
|
299
301
|
const widgetsOf = () => (widgets ??= servedWidgets())
|
|
300
302
|
const cmodBeneath = createRouter()
|
|
301
|
-
const pages = servePages({ claude: cmodClaude, router: cmodBeneath, report: reportPart, widgets: { update: (mod, update) => void widgetsOf().then((served) => served.update(mod, update)) }, parts, tellStylers: () => undefined })
|
|
303
|
+
const pages = servePages({ claude: cmodClaude, router: cmodBeneath, report: reportPart, tellRefusedPress, widgets: { update: (mod, update) => void widgetsOf().then((served) => served.update(mod, update)) }, parts, tellStylers: () => undefined })
|
|
302
304
|
pages.apply((_mod, requests) => applyRequests(requests))
|
|
303
305
|
const dependencies = fakeDependencies(name, options.dependencies ?? {}, conversations)
|
|
304
306
|
fake.fakes.cmod.call = async (call) => {
|
|
@@ -366,7 +368,7 @@ export function testMod<State extends object, Declared extends Options = Options
|
|
|
366
368
|
const starting = options.state as Record<string, object> | undefined
|
|
367
369
|
const declared = Object.entries(definition.state ?? {}) as [string, object][]
|
|
368
370
|
const state = Object.fromEntries(declared.map(([lifetime, values]) => [lifetime, { ...values, ...starting?.[lifetime] }])) as State
|
|
369
|
-
const lifecycle = createLifecycle<State, Declared>({ ...definition, state }, () => permissionRoutes,(options.options ?? {}) as PluginOptions, false)
|
|
371
|
+
const lifecycle = createLifecycle<State, Declared>({ ...definition, state }, () => permissionRoutes, (options.options ?? {}) as PluginOptions, false, definition.name === cmodPluginName ? serveCmodPlugin : undefined)
|
|
370
372
|
let started: Promise<void> | undefined
|
|
371
373
|
let isColorTold = false
|
|
372
374
|
let deviceNoted: Promise<void> | undefined
|
package/testing.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"testing.d.ts","sourceRoot":"","sources":["src/testing.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,IAAI,EAEJ,gBAAgB,EAIhB,WAAW,EAUX,eAAe,EAGhB,MAAM,aAAa,CAAA;AACpB,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAA;AAC3D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,UAAU,CAAA;AAC7C,OAAO,KAAK,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAA;
|
|
1
|
+
{"version":3,"file":"testing.d.ts","sourceRoot":"","sources":["src/testing.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,IAAI,EAEJ,gBAAgB,EAIhB,WAAW,EAUX,eAAe,EAGhB,MAAM,aAAa,CAAA;AACpB,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAA;AAC3D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,UAAU,CAAA;AAC7C,OAAO,KAAK,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAA;AAczD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAA;AAEtD,OAAO,EAAE,OAAO,EAAE,MAAM,2CAA2C,CAAA;AAKnE,OAAO,EAAW,KAAK,IAAI,EAAE,MAAM,gCAAgC,CAAA;AACnE,OAAO,EAA+B,aAAa,EAAE,KAAK,QAAQ,EAAoB,KAAK,UAAU,EAAE,KAAK,UAAU,EAAE,KAAK,gBAAgB,EAAE,KAAK,SAAS,EAAE,KAAK,aAAa,EAAE,KAAK,YAAY,EAAE,KAAK,WAAW,EAAE,KAAK,cAAc,EAAE,MAAM,sBAAsB,CAAA;AAGzQ,OAAO,EAA4B,KAAK,KAAK,EAAE,KAAK,KAAK,IAAI,aAAa,EAAE,KAAK,QAAQ,EAAE,MAAM,0BAA0B,CAAA;AAG3H,OAAO,EAAgB,KAAK,WAAW,EAAE,KAAK,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EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,OAAO,CAAC,WAAW,CAAC,WAAW,CAAC,CAAC,CAAA;IACzF,KAAK,CAAC,IAAI,EAAE,IAAI,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;IAC7C,MAAM,CAAC,WAAW,EAAE,MAAM,EAAE,GAAG,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;IACxD,QAAQ,CAAC,GAAG,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC,KAAK,CAAC,EAAE,OAAO,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,CAAA;IAC7E,QAAQ,CAAC,KAAK,EAAE,QAAQ,CAAC,KAAK,CAAC,CAAA;IAC/B,QAAQ,CAAC,KAAK,EAAE,SAAS,QAAQ,EAAE,CAAA;IACnC,QAAQ,CAAC,KAAK,EAAE,KAAK,CAAA;IACrB,QAAQ,CAAC,KAAK,EAAE,KAAK,CAAA;CACtB,CAAA;AAqBD,wBAAgB,OAAO,CAAC,KAAK,SAAS,MAAM,EAAE,QAAQ,SAAS,OAAO,GAAG,OAAO,EAAE,UAAU,EAAE,aAAa,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,OAAO,GAAE,WAAW,CAAC,KAAK,EAAE,QAAQ,CAAM,GAAG,SAAS,CAAC,KAAK,CAAC,CA4oBlM"}
|
package/testing.js
CHANGED
|
@@ -7,6 +7,7 @@ import { keepClaudeCode } from './testing/claude-code.js';
|
|
|
7
7
|
import { createRouter } from './runtime/router.js';
|
|
8
8
|
import { toolInputOf } from './runtime/tool-calls.js';
|
|
9
9
|
import { createLifecycle } from './runtime/lifecycle.js';
|
|
10
|
+
import { serveCmodPlugin } from './register.js';
|
|
10
11
|
import { MissingOptions } from './runtime/options.js';
|
|
11
12
|
import { conversationMethods, pickedColor } from './runtime/sessions.js';
|
|
12
13
|
import { deviceNote } from './session/context/turn/device.js';
|
|
@@ -192,7 +193,8 @@ export function testMod(definition, options = {}) {
|
|
|
192
193
|
};
|
|
193
194
|
const cmodClaude = { ...fake.claude, cmod: { call: async (input) => (input.to === name ? callMod(input.method, input.input) : fake.claude.cmod.call(input)) } };
|
|
194
195
|
const reportPart = (_id, message, error) => fake.claude.ui.log(`cmod: ${message}: ${messageOf(error)}`, { to: 'debug' });
|
|
195
|
-
const
|
|
196
|
+
const tellRefusedPress = (_mod, error) => fake.claude.ui.log(`cmod: ${name} did not take the press: ${messageOf(error)}`, { to: 'debug' });
|
|
197
|
+
const parts = drawnParts({ claude: cmodClaude, report: reportPart, press: (mod, input) => void pressPart(input).catch((error) => tellRefusedPress(mod, error)) });
|
|
196
198
|
const servedWidgets = async () => {
|
|
197
199
|
const own = name === cmodPluginName && lifecycle.mod !== undefined ? engineOf(lifecycle.mod).widgets : undefined;
|
|
198
200
|
if (own !== undefined)
|
|
@@ -209,7 +211,7 @@ export function testMod(definition, options = {}) {
|
|
|
209
211
|
};
|
|
210
212
|
const widgetsOf = () => (widgets ??= servedWidgets());
|
|
211
213
|
const cmodBeneath = createRouter();
|
|
212
|
-
const pages = servePages({ claude: cmodClaude, router: cmodBeneath, report: reportPart, widgets: { update: (mod, update) => void widgetsOf().then((served) => served.update(mod, update)) }, parts, tellStylers: () => undefined });
|
|
214
|
+
const pages = servePages({ claude: cmodClaude, router: cmodBeneath, report: reportPart, tellRefusedPress, widgets: { update: (mod, update) => void widgetsOf().then((served) => served.update(mod, update)) }, parts, tellStylers: () => undefined });
|
|
213
215
|
pages.apply((_mod, requests) => applyRequests(requests));
|
|
214
216
|
const dependencies = fakeDependencies(name, options.dependencies ?? {}, conversations);
|
|
215
217
|
fake.fakes.cmod.call = async (call) => {
|
|
@@ -286,7 +288,7 @@ export function testMod(definition, options = {}) {
|
|
|
286
288
|
const starting = options.state;
|
|
287
289
|
const declared = Object.entries(definition.state ?? {});
|
|
288
290
|
const state = Object.fromEntries(declared.map(([lifetime, values]) => [lifetime, { ...values, ...starting?.[lifetime] }]));
|
|
289
|
-
const lifecycle = createLifecycle({ ...definition, state }, () => permissionRoutes, (options.options ?? {}), false);
|
|
291
|
+
const lifecycle = createLifecycle({ ...definition, state }, () => permissionRoutes, (options.options ?? {}), false, definition.name === cmodPluginName ? serveCmodPlugin : undefined);
|
|
290
292
|
let started;
|
|
291
293
|
let isColorTold = false;
|
|
292
294
|
let deviceNoted;
|