@cmodjs/core 5.7.0 → 5.8.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 +1 -1
- package/docs/install-steps.md +1 -1
- package/docs/ui.md +2 -1
- package/package.json +1 -1
- package/records.d.ts +13 -2
- package/records.d.ts.map +1 -1
- package/records.js +9 -3
- 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/records.ts +9 -3
- 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
|
@@ -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
|
|
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/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/package.json
CHANGED
package/records.d.ts
CHANGED
|
@@ -133,12 +133,23 @@ export declare function newestLog(entries: readonly LogEntry[]): LogEntry[];
|
|
|
133
133
|
export declare function versionsLine({ mod, core, cmod, program, claudeCode }: LogVersions): string;
|
|
134
134
|
export declare function logReport(entry: LogEntry): string;
|
|
135
135
|
export declare function parseConsent(value: unknown, path: string): Record<string, string[]>;
|
|
136
|
-
export declare const coreVersion = "5.
|
|
136
|
+
export declare const coreVersion = "5.8.0";
|
|
137
137
|
export declare const oldestCmodVersion = "5.4.0";
|
|
138
138
|
export declare function hotkeyCommand(mod: string, hotkey: string): string;
|
|
139
139
|
export declare function hotkeyBindings(mod: string, hotkeys: Hotkeys | undefined): Record<string, string>;
|
|
140
140
|
export declare function boundCombos(keybindings: unknown): Map<string, string>;
|
|
141
|
-
export declare function
|
|
141
|
+
export declare function bundleOptions(steps: Steps): {
|
|
142
|
+
format: 'esm';
|
|
143
|
+
target: 'browser';
|
|
144
|
+
external: string[];
|
|
145
|
+
define: {} | {
|
|
146
|
+
'globalThis.cmodWithoutApprove': string;
|
|
147
|
+
};
|
|
148
|
+
minify: {
|
|
149
|
+
whitespace: boolean;
|
|
150
|
+
identifiers: boolean;
|
|
151
|
+
};
|
|
152
|
+
};
|
|
142
153
|
export declare function scriptPaths(command: string): string[];
|
|
143
154
|
export declare function scriptsSha256(steps: Steps, files: {
|
|
144
155
|
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,CA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,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
|
@@ -302,7 +302,7 @@ function readHotkeys(hotkeys) {
|
|
|
302
302
|
throw new Error(`package.json "cmod.hotkeys" is not a map of hotkeys to their title and optional default combo. ${fix}`);
|
|
303
303
|
return { hotkeys: checkHotkeys('package.json "cmod"', hotkeys) };
|
|
304
304
|
}
|
|
305
|
-
export const coreVersion = '5.
|
|
305
|
+
export const coreVersion = '5.8.0';
|
|
306
306
|
export const oldestCmodVersion = '5.4.0';
|
|
307
307
|
export function hotkeyCommand(mod, hotkey) {
|
|
308
308
|
return `${mod}--${hotkey}`;
|
|
@@ -335,8 +335,14 @@ function readCommand(steps, key) {
|
|
|
335
335
|
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
336
|
return { [key]: command };
|
|
337
337
|
}
|
|
338
|
-
export function
|
|
339
|
-
return
|
|
338
|
+
export function bundleOptions(steps) {
|
|
339
|
+
return {
|
|
340
|
+
format: 'esm',
|
|
341
|
+
target: 'browser',
|
|
342
|
+
external: ['claude-code'],
|
|
343
|
+
define: steps.approve === true ? {} : { 'globalThis.cmodWithoutApprove': 'true' },
|
|
344
|
+
minify: { whitespace: true, identifiers: true },
|
|
345
|
+
};
|
|
340
346
|
}
|
|
341
347
|
export function scriptPaths(command) {
|
|
342
348
|
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,EAA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GED
|
@@ -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":"","s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AAK,CAAC,QAAQ,EAAE,SAAS,GAAG,IAAI,CAAA;CACjC,CAAA;AAED,wBAAgB,OAAO,CAAC,KAAK,EAAE,OAAO,GAAG,eAAe,EAAE,CAGzD;AAED,wBAAgB,UAAU,CAAC,EACzB,MAAM,EACN,MAAM,EACN,MAAM,EACN,gBAAgB,EAChB,OAAO,EACP,KAAK,EACL,WAAW,GACZ,EAAE;IACD,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;IACvB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;IACvB,QAAQ,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,KAAK,IAAI,CAAA;IACtE,QAAQ,CAAC,gBAAgB,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,KAAK,IAAI,CAAA;IAChE,QAAQ,CAAC,OAAO,EAAE,IAAI,CAAC,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,KA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,CAAC,KAAK,CAAC,CAAA;IAC/D,WAAW,CAAC,MAAM,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC,MAAM,CAAC,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC,MAAM,CAAC,CAAA;IAChG,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC;QAAE,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAA;KAAE,CAAC,GAAG,SAAS,CAAA;IACxG,UAAU,CAAC,KAAK,EAAE,YAAY,EAAE,EAAE,EAAE,QAAQ,GAAG,CAAC,CAAC,KAAK,EAAE,aAAa,KAAK,aAAa,CAAC,GAAG,SAAS,CAAA;IACpG,QAAQ,CAAC,OAAO,EAAE,SAAS,MAAM,EAAE,GAAG,IAAI,CAAA;IAC1C,OAAO,IAAI,IAAI,CAAA;IACf,OAAO,IAAI,IAAI,CAAA;IACf,YAAY,IAAI,OAAO,CAAC,IAAI,CAAC,CAAA;CAC9B,CAAA;AAED,eAAO,MAAM,cAAc,MAAM,CAAA;AAEjC,wBAAgB,QAAQ,CAAC,KAAK,SAAS,MAAM,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,GAAG,EAAE,QAAQ,EAAE,QAAQ,EAAE,EAAE,SAAS,CAAC,KAAK,CAAC,GAAG,MAAM,CAAC,KAAK,CAAC,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/records.ts
CHANGED
|
@@ -369,7 +369,7 @@ function readHotkeys(hotkeys: unknown): Steps {
|
|
|
369
369
|
return { hotkeys: checkHotkeys('package.json "cmod"', hotkeys as Record<string, HotkeyInit>) }
|
|
370
370
|
}
|
|
371
371
|
|
|
372
|
-
export const coreVersion = '5.
|
|
372
|
+
export const coreVersion = '5.8.0'
|
|
373
373
|
|
|
374
374
|
export const oldestCmodVersion = '5.4.0'
|
|
375
375
|
|
|
@@ -401,8 +401,14 @@ function readCommand(steps: Record<string, unknown>, key: 'install' | 'uninstall
|
|
|
401
401
|
return { [key]: command }
|
|
402
402
|
}
|
|
403
403
|
|
|
404
|
-
export function
|
|
405
|
-
return
|
|
404
|
+
export function bundleOptions(steps: Steps) {
|
|
405
|
+
return {
|
|
406
|
+
format: 'esm' as const,
|
|
407
|
+
target: 'browser' as const,
|
|
408
|
+
external: ['claude-code'],
|
|
409
|
+
define: steps.approve === true ? {} : { 'globalThis.cmodWithoutApprove': 'true' },
|
|
410
|
+
minify: { whitespace: true, identifiers: true },
|
|
411
|
+
}
|
|
406
412
|
}
|
|
407
413
|
|
|
408
414
|
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,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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;
|