@cmodjs/core 6.0.2 → 6.0.4
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 +12 -11
- package/docs/install-steps.md +1 -1
- package/jobs/program.d.ts.map +1 -1
- package/jobs/program.js +7 -6
- package/package.json +1 -1
- package/records.d.ts +6 -1
- package/records.d.ts.map +1 -1
- package/records.js +5 -1
- package/runtime/engine.d.ts +1 -0
- package/runtime/engine.d.ts.map +1 -1
- package/runtime/installer.d.ts +1 -1
- package/runtime/installer.d.ts.map +1 -1
- package/runtime/installer.js +4 -4
- package/runtime/lifecycle.d.ts.map +1 -1
- package/runtime/lifecycle.js +36 -18
- package/runtime/programs.d.ts +1 -0
- package/runtime/programs.d.ts.map +1 -1
- package/runtime/programs.js +40 -2
- package/runtime/sessions.js +2 -3
- package/runtime/ui.js +2 -3
- package/src/jobs/program.ts +7 -6
- package/src/records.ts +7 -1
- package/src/runtime/engine.ts +1 -0
- package/src/runtime/installer.ts +5 -3
- package/src/runtime/lifecycle.ts +39 -17
- package/src/runtime/programs.ts +40 -3
- package/src/runtime/sessions.ts +2 -2
- package/src/runtime/ui.ts +2 -2
package/docs/commands.md
CHANGED
|
@@ -62,7 +62,7 @@ Runs every check this machine can run on the mod at `path` (default: the current
|
|
|
62
62
|
6. Reads the metadata of every file in the mod, and names each file whose metadata cmod cannot read.
|
|
63
63
|
7. Writes the options `defineMod` declares into `.claude-plugin/plugin.json` `userConfig`, and its hotkeys into `package.json` `"cmod"` `hotkeys`, keeping each file's own formatting, so Claude Code shows the options in `/config` ([options.md](options.md)). It loads `hooks/register.ts` to read them, without starting the mod.
|
|
64
64
|
8. Writes the `cmod` dependency in `.claude-plugin/plugin.json` as `>=` the oldest cmod the `@cmodjs/core` the mod installed runs on, `oldestCmodVersion` in its `records.js`, such as `>=5.2.0`, so every newer cmod runs the mod. When the mod needs a newer cmod than that, such as one whose cmod plugin carries out a call the mod makes, write that minimum yourself as `>=` its version, such as `>=5.6.0`, and `cmod check` keeps it. It raises only a minimum below that oldest cmod, and writes any other range as `>=` that oldest cmod. A `@cmodjs/core` that does not export `oldestCmodVersion` runs on the cmod of its own version, so the range is `>=` that version, such as `>=4.3.4`. A mod still on `@cmodjs/core` 3 keeps its own range ([dependencies.md](dependencies.md#call-the-methods-mod-dependencies)). Claude Code turns a mod off when its cmod is older than that dependency, so `cmod check` first compares it with every cmod plugin Claude Code installed on this machine. When an installed copy is older, it updates them as `cmod update cmod` does. When one is still older, as when your `@cmodjs/core` needs a cmod newer than every published one, the check fails, keeps the old dependency, and names the `@cmodjs/core` to install instead. When a cmod linked from a checkout is older, the check fails the same way and says to pull that checkout, because no update reaches it. On a machine without Claude Code or without a cmod plugin, such as CI, it writes the dependency at once.
|
|
65
|
-
9. Checks
|
|
65
|
+
9. Checks the imports of every file the release ships, the files `cmod publish` would release. It fails a file that imports the `claude-code` module, because every type a mod writes comes from `@cmodjs/core` ([index.md](index.md#what-a-mod-is)). A provider's types file adds to that module with `declare module 'claude-code'`, which imports nothing, so the check keeps it. A folder the release leaves out, such as a library its `"files"` list does not name, may import anything.
|
|
66
66
|
10. Looks for prebuilt binaries outside `cli/`.
|
|
67
67
|
11. Builds the release in a temporary folder as `cmod publish` builds it, with its `"files"` list and its bundled hooks module, and validates the release with Claude Code, `claude plugin validate --strict`. So it fails on a path `plugin.json` names that `"files"` leaves out, a `"files"` path that matches no file in the mod, and each reason a bundle fails, and prints every line the validator writes. Then it deletes the folder.
|
|
68
68
|
12. Compiles it against Claude Code's API with `tsc`, with `tsconfig.json`, and then with `tests/tsconfig.json` when it exists. `cmod new` writes both: the root config leaves Bun out of `src/`, which runs inside Claude Code, and the tests config adds `bun-types`, so a test can run a real program with `Bun.spawn` or read files with `node:fs`. When `.claude-plugin/types/` is missing, as in a fresh clone or in CI, Claude Code writes it first: cmod loads the mod in one `claude -p` run with a config folder of its own and no model to reach, so the run sends nothing.
|
|
@@ -111,16 +111,17 @@ Prints the Log that Settings shows on cmod's page, newest first: each failure an
|
|
|
111
111
|
cmod publish [path] [--dry-run]
|
|
112
112
|
```
|
|
113
113
|
|
|
114
|
-
Releases the mod at `path` (default: the current folder) at the version in its `plugin.json`.
|
|
115
|
-
|
|
116
|
-
1.
|
|
117
|
-
2.
|
|
118
|
-
3.
|
|
119
|
-
4.
|
|
120
|
-
5.
|
|
121
|
-
6.
|
|
122
|
-
7.
|
|
123
|
-
8.
|
|
114
|
+
Releases the mod at `path` (default: the current folder) at the version in its `plugin.json`.
|
|
115
|
+
|
|
116
|
+
1. Runs every check of `cmod check` but its package install and its release build, which steps 2 to 4 do, and releases nothing when one fails, as `cargo publish` builds a crate before it uploads it. So a mod whose types, lint, tests, or imports fail never reaches the people who install it. Where `cmod check` writes a fix, such as the options `defineMod` declares into `userConfig`, its hotkeys, or the `cmod` dependency, `cmod publish` fails that check instead and leaves the file as it is, with the fix `Run cmod check, which writes it, commit <file>, then run the command again.` So `--dry-run` changes no file either.
|
|
117
|
+
2. Builds the release from the files git does not ignore, leaving out `cli/`, `.github/`, and `.claude/`. A `"files"` list in `package.json` limits the release to the paths it lists, a path in those three folders included, such as `cli/bin/<launcher>`, plus the folders of the install and uninstall steps, `.claude-plugin/`, `package.json`, `tsconfig.json`, the README, the license, and `CHANGELOG.md`, the way `npm publish` reads it. `tsconfig.json` holds the JSX settings the bundle in step 3 needs. List every folder the hooks module imports from, such as `"files": ["hooks", "src", "skills"]`, because the bundle in step 3 is built from the release.
|
|
118
|
+
3. Bundles the hooks module that `hooks/hooks.json` names, with the mod's source and packages, into one readable `.js` file, writes each control character in it as a `\u` escape, and points `hooks/hooks.json` at it. Anthropic's plugin directory reads a repository without installing its packages, so it can follow a mod only when all its code is in one file. Without `"approve": true` in `package.json` `"cmod"`, the bundle leaves out the code that allows and asks on Claude Code's permission check, because Anthropic's plugin directory does not list a mod that can approve Claude's tool calls ([mod.md](mod.md#register-the-mod-with-claude-code)).
|
|
119
|
+
4. Checks the release's `.claude-plugin/plugin.json`, and its `.claude-plugin/marketplace.json` when it has one, with `claude plugin validate --strict`, and stops with every line the validator writes when it fails. `cmod check` builds and validates the release the same way, so it fails first.
|
|
120
|
+
5. Commits the release as the `release` branch, and builds the release archive from that commit.
|
|
121
|
+
6. Builds the program `cli/` declares, and writes `SHA256SUMS` for every file of the release.
|
|
122
|
+
7. Writes `.claude-plugin/marketplace.json`, listing the archive, the cmod plugin, and each other mod `plugin.json` depends on. The cmod entry points at the `release` branch of `heyJordanParker/cmod`, so the mod's `"cmod"` dependency resolves in this marketplace and follows each cmod release with no new publish of the mod. Each other dependency's entry points at the `release` branch of the GitHub repository of the marketplace Claude Code added on your computer that lists it ([dependencies.md](dependencies.md#call-the-methods-mod-dependencies)).
|
|
123
|
+
8. Commits that file, tags `v<version>`, tags the release commit `<name>--v<version>`, which Claude Code installs a version range from when a marketplace lists the mod from its git repository, pushes both tags and the `release` branch, creates the GitHub release with every file, then pushes the branch that holds `marketplace.json`. So Claude Code never updates anyone to a release whose files are not up yet. Its notes are the version's section of the committed `CHANGELOG.md`, above GitHub's compare link ([mod.md](mod.md#release-notes)). `--dry-run` prints them.
|
|
124
|
+
9. Prints the link to paste as the Repository when you submit the mod at [claude.ai/directory/manage](https://claude.ai/directory/manage), such as `https://github.com/owner/my-mod/tree/release`. The portal reads the branch from the link, so the directory follows `release`.
|
|
124
125
|
|
|
125
126
|
The release keeps `package.json`, so Claude Code still installs the mod's packages for its install and uninstall steps. It keeps `bun.lock` too, unless a `"files"` list leaves it out. `main` keeps the source only.
|
|
126
127
|
|
package/docs/install-steps.md
CHANGED
|
@@ -80,7 +80,7 @@ type Step<State> = {
|
|
|
80
80
|
- `id` is 1 to 64 letters, digits, `_`, or `-`, unique among the steps. `title` is the line above the step, with `(1 of 2)`. `defineMod` throws for an id that is not one, a blank title, or two steps with one id.
|
|
81
81
|
- `render` draws the step's body, the way a page's `render` does, with the elements a page draws ([ui.md](ui.md#the-sidebar-and-its-pages)). Give the step a `Button` that does the work or opens the place to do it, never a command to type.
|
|
82
82
|
- `isDone` says whether the step is finished. A step that is done is skipped, so the page opens only for what is left. `Next` checks `isDone`, and shows `Finish <title> first.` while it is false. The last step's button says `Finish`.
|
|
83
|
-
- An `isDone` that throws or rejects
|
|
83
|
+
- An `isDone` that throws or rejects opens no step: the mod shows `The <title> step's isDone failed` with the error, and the step stays listed as left to do. Pressed on a step already open, `Next` shows `The <title> step's isDone failed: <error>`.
|
|
84
84
|
- `Not now` closes the page, and the mod keeps running. A toast stays above the prompt, `Needs one more step` with `Starting with <title>.` under it, and its `Finish` button opens the page on the first step left. Settings shows `Needs setup: <title>` with a `Finish setup` button too.
|
|
85
85
|
|
|
86
86
|
## Hotkeys
|
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,CAAC;IAAC,QAAQ,CAAC,SAAS,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,CA8ItM"}
|
package/jobs/program.js
CHANGED
|
@@ -11,7 +11,7 @@ const retryWithinMs = 1000;
|
|
|
11
11
|
export function program(options) {
|
|
12
12
|
const { command, environment, singleInstance = false, isService = false } = options;
|
|
13
13
|
return ({ mod, announce, reserveName }) => {
|
|
14
|
-
const { claude, report, spawnCmod, watches } = engineOf(mod);
|
|
14
|
+
const { claude, report, spawnCmod, isInstalledCopy, 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'].`);
|
|
@@ -31,10 +31,10 @@ export function program(options) {
|
|
|
31
31
|
let isWatching = false;
|
|
32
32
|
let instance;
|
|
33
33
|
let leaseCheck;
|
|
34
|
-
const spawn = () => {
|
|
35
|
-
if (
|
|
34
|
+
const spawn = (isOwnService) => {
|
|
35
|
+
if (isOwnService)
|
|
36
36
|
return spawnCmod(['program', mod.name, '--service', ...Object.keys(environment ?? {}).flatMap((name) => ['--env', name]), '--', ...command], environment);
|
|
37
|
-
return
|
|
37
|
+
return isElected ? spawnCmod(['program', mod.name, '--no-wait', '--', ...command], environment) : claude.process.spawn(request);
|
|
38
38
|
};
|
|
39
39
|
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))));
|
|
40
40
|
const following = (run) => void run.catch((error) => report({ id: `program:${executable}:follow`, message: `Could not follow the ${executable} program`, error }));
|
|
@@ -94,12 +94,13 @@ export function program(options) {
|
|
|
94
94
|
let lastError = '';
|
|
95
95
|
let isShown = false;
|
|
96
96
|
try {
|
|
97
|
-
|
|
97
|
+
const isOwnService = isService && (await isInstalledCopy());
|
|
98
|
+
if (isElected && !isOwnService) {
|
|
98
99
|
const file = await instanceFile();
|
|
99
100
|
if (await isHeld(claude, `${file}.lock`, staleMs))
|
|
100
101
|
return await follow(file);
|
|
101
102
|
}
|
|
102
|
-
for await (const piece of
|
|
103
|
+
for await (const piece of spawn(isOwnService)) {
|
|
103
104
|
if (piece.stream === 'stderr') {
|
|
104
105
|
lastError = piece.text.trim().split('\n').at(-1) ?? lastError;
|
|
105
106
|
continue;
|
package/package.json
CHANGED
package/records.d.ts
CHANGED
|
@@ -10,6 +10,11 @@ export type InstallRecord = {
|
|
|
10
10
|
keys: Readonly<Record<string, string>>;
|
|
11
11
|
permissions: readonly string[] | null;
|
|
12
12
|
grantedOnUpdate: readonly string[];
|
|
13
|
+
installedBy: InstalledBy | null;
|
|
14
|
+
};
|
|
15
|
+
export type InstalledBy = {
|
|
16
|
+
readonly session: string | null;
|
|
17
|
+
readonly pid: number;
|
|
13
18
|
};
|
|
14
19
|
export type Steps = {
|
|
15
20
|
install?: string;
|
|
@@ -160,7 +165,7 @@ export declare function newestLog(entries: readonly LogEntry[]): LogEntry[];
|
|
|
160
165
|
export declare function versionsLine({ mod, core, cmod, program, claudeCode }: LogVersions): string;
|
|
161
166
|
export declare function logReport(entry: LogEntry): string;
|
|
162
167
|
export declare function parseConsent(value: unknown, path: string): Record<string, string[]>;
|
|
163
|
-
export declare const coreVersion = "6.0.
|
|
168
|
+
export declare const coreVersion = "6.0.4";
|
|
164
169
|
export declare const oldestCmodVersion = "6.0.0";
|
|
165
170
|
export declare function hotkeyCommand(mod: string, hotkey: string): string;
|
|
166
171
|
export declare function hotkeyBindings(mod: string, hotkeys: Hotkeys | undefined): Record<string, string>;
|
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,CAAA;IACtC,WAAW,EAAE,SAAS,MAAM,EAAE,GAAG,IAAI,CAAA;IACrC,eAAe,EAAE,SAAS,MAAM,EAAE,CAAA;
|
|
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,CA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ord(text, path) {
|
|
|
105
105
|
const grantedOnUpdate = value['grantedOnUpdate'] ?? [];
|
|
106
106
|
if (!isTextList(grantedOnUpdate))
|
|
107
107
|
throw new Error(`${path} has a "grantedOnUpdate" that is not a list of permissions. ${fix}`);
|
|
108
|
+
const installedBy = value['installedBy'] ?? null;
|
|
109
|
+
if (installedBy !== null && !(isObject(installedBy) && (installedBy['session'] === null || typeof installedBy['session'] === 'string') && typeof installedBy['pid'] === 'number'))
|
|
110
|
+
throw new Error(`${path} has an "installedBy" that names no session and process. ${fix}`);
|
|
108
111
|
return {
|
|
109
112
|
name: value['name'],
|
|
110
113
|
version: value['version'],
|
|
@@ -116,6 +119,7 @@ function parseRecord(text, path) {
|
|
|
116
119
|
keys: keys,
|
|
117
120
|
permissions,
|
|
118
121
|
grantedOnUpdate,
|
|
122
|
+
installedBy: installedBy,
|
|
119
123
|
};
|
|
120
124
|
}
|
|
121
125
|
export function readSteps(pkg) {
|
|
@@ -360,7 +364,7 @@ function readHotkeys(hotkeys) {
|
|
|
360
364
|
throw new Error(`package.json "cmod.hotkeys" is not a map of hotkeys to their title and optional default combo. ${fix}`);
|
|
361
365
|
return { hotkeys: checkHotkeys('package.json "cmod"', hotkeys) };
|
|
362
366
|
}
|
|
363
|
-
export const coreVersion = '6.0.
|
|
367
|
+
export const coreVersion = '6.0.4';
|
|
364
368
|
export const oldestCmodVersion = '6.0.0';
|
|
365
369
|
export function hotkeyCommand(mod, hotkey) {
|
|
366
370
|
return `${mod}--${hotkey}`;
|
package/runtime/engine.d.ts
CHANGED
|
@@ -15,6 +15,7 @@ export type Engine = {
|
|
|
15
15
|
readonly hasPermissionCheck: () => boolean;
|
|
16
16
|
readonly answerInput: <Answer>(run: () => Promise<Answer>, passOn: () => Promise<unknown>) => Promise<Answer>;
|
|
17
17
|
readonly spawnCmod: (args: readonly string[], env?: Readonly<Record<string, string>>) => HookStream<ProcessSpawnChunk, ProcessSpawnResult>;
|
|
18
|
+
readonly isInstalledCopy: () => Promise<boolean>;
|
|
18
19
|
readonly watches: Watches;
|
|
19
20
|
readonly onRedraw: (listener: () => void) => Subscription;
|
|
20
21
|
readonly widgets?: Widgets;
|
package/runtime/engine.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"engine.d.ts","sourceRoot":"","sources":["../src/runtime/engine.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAA;AACpF,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AACzC,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,YAAY,CAAA;AACvC,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AACzC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAA;AAC5D,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AAC3C,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAA;AAChD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AAC3C,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AAE3C,MAAM,MAAM,MAAM,GAAG;IACnB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;IACvB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;IACvB,QAAQ,CAAC,SAAS,EAAE,SAAS,CAAA;IAC7B,QAAQ,CAAC,MAAM,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,IAAI,CAAA;IAC3C,QAAQ,CAAC,kBAAkB,EAAE,MAAM,OAAO,CAAA;IAC1C,QAAQ,CAAC,WAAW,EAAE,CAAC,MAAM,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC,MAAM,CAAC,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC,OAAO,CAAC,KAAK,OAAO,CAAC,MAAM,CAAC,CAAA;IAC7G,QAA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AC,MAAM,EAAE,MAAM,CAAA;IACvB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;IACvB,QAAQ,CAAC,SAAS,EAAE,SAAS,CAAA;IAC7B,QAAQ,CAAC,MAAM,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,IAAI,CAAA;IAC3C,QAAQ,CAAC,kBAAkB,EAAE,MAAM,OAAO,CAAA;IAC1C,QAAQ,CAAC,WAAW,EAAE,CAAC,MAAM,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC,MAAM,CAAC,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC,OAAO,CAAC,KAAK,OAAO,CAAC,MAAM,CAAC,CAAA;IAC7G,QAAQ,CAAC,SAAS,EAAE,CAAC,IAAI,EAAE,SAAS,MAAM,EAAE,EAAE,GAAG,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,KAAK,UAAU,CAAC,iBAAiB,EAAE,kBAAkB,CAAC,CAAA;IAC1I,QAAQ,CAAC,eAAe,EAAE,MAAM,OAAO,CAAC,OAAO,CAAC,CAAA;IAChD,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAA;IACzB,QAAQ,CAAC,QAAQ,EAAE,CAAC,QAAQ,EAAE,MAAM,IAAI,KAAK,YAAY,CAAA;IACzD,QAAQ,CAAC,OAAO,CAAC,EAAE,OAAO,CAAA;IAC1B,QAAQ,CAAC,KAAK,CAAC,EAAE,KAAK,CAAA;CACvB,CAAA;AAID,wBAAgB,UAAU,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,IAAI,CAE5D;AAED,wBAAgB,QAAQ,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAI5C"}
|
package/runtime/installer.d.ts
CHANGED
|
@@ -17,7 +17,7 @@ export type Installer = {
|
|
|
17
17
|
collect(run: () => Promise<unknown>): Promise<PartsUpdate>;
|
|
18
18
|
};
|
|
19
19
|
export declare function createInstaller(name: string, claude: () => Claude, waiting: {
|
|
20
|
-
show(open: () => Promise<void
|
|
20
|
+
show(open: () => Promise<void>, next: string): void;
|
|
21
21
|
hide(): void;
|
|
22
22
|
}, nextDraw: () => number): Installer;
|
|
23
23
|
//# sourceMappingURL=installer.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"installer.d.ts","sourceRoot":"","sources":["../src/runtime/installer.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAA;AAC3C,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,WAAW,CAAA;AACpC,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,eAAe,CAAA;AAM3C,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AAEzC,OAAO,EAAmE,KAAK,WAAW,EAAE,KAAK,UAAU,EAAE,MAAM,SAAS,CAAA;AAE5H,eAAO,MAAM,WAAW,iBAAiB,CAAA;AAOzC,MAAM,MAAM,SAAS,GAAG;IACtB,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,GAAG,OAAO,CAAC;QAAE,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAA;KAAE,CAAC,GAAG,SAAS,CAAA;IACxF,IAAI,CAAC,KAAK,EAAE,UAAU,GAAG,IAAI,CAAA;IAC7B,OAAO,CAAC,OAAO,EAAE,SAAS,CAAC,SAAS,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,EAAE,EAAE,IAAI,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,GAAG,OAAO,CAAC,OAAO,CAAC,CAAA;IAC7I,IAAI,CAAC,KAAK,SAAS,MAAM,EAAE,GAAG,EAAE,GAAG,CAAC,KAAK,CAAC,EAAE,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,KAA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AAS,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,EAAE,EAAE,IAAI,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,GAAG,OAAO,CAAC,OAAO,CAAC,CAAA;IAC7I,IAAI,CAAC,KAAK,SAAS,MAAM,EAAE,GAAG,EAAE,GAAG,CAAC,KAAK,CAAC,EAAE,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAAA;IAC9G,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAA;IACtB,OAAO,IAAI,IAAI,CAAA;IACf,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAA;IACtB,OAAO,CAAC,GAAG,EAAE,MAAM,OAAO,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC,WAAW,CAAC,CAAA;CAC3D,CAAA;AAID,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,MAAM,EAAE,OAAO,EAAE;IAAE,IAAI,CAAC,IAAI,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IAAC,IAAI,IAAI,IAAI,CAAA;CAAE,EAAE,QAAQ,EAAE,MAAM,MAAM,GAAG,SAAS,CAuLrL"}
|
package/runtime/installer.js
CHANGED
|
@@ -20,7 +20,7 @@ export function createInstaller(name, claude, waiting, nextDraw) {
|
|
|
20
20
|
};
|
|
21
21
|
const log = (what) => (error) => claude().ui.warn('installer:page', `${name}: ${what}: ${messageOf(error)}`);
|
|
22
22
|
const open = (isAsked) => send({ requests: [{ open: installPage, focus: true }], ...(isAsked ? { isAsked: true } : {}) });
|
|
23
|
-
const show = async (build, cancelled) => {
|
|
23
|
+
const show = async (next, build, cancelled) => {
|
|
24
24
|
question?.cancel();
|
|
25
25
|
const answer = new Promise((resolve) => {
|
|
26
26
|
let isAnswered = false;
|
|
@@ -33,7 +33,7 @@ export function createInstaller(name, claude, waiting, nextDraw) {
|
|
|
33
33
|
};
|
|
34
34
|
question = { ...build(done), cancel: () => done(cancelled) };
|
|
35
35
|
});
|
|
36
|
-
waiting.show(() => open(true));
|
|
36
|
+
waiting.show(() => open(true), next);
|
|
37
37
|
if (isOpen) {
|
|
38
38
|
await send({ redraw: true }).catch(log('the installer did not redraw'));
|
|
39
39
|
}
|
|
@@ -105,7 +105,7 @@ export function createInstaller(name, claude, waiting, nextDraw) {
|
|
|
105
105
|
options(missing, save) {
|
|
106
106
|
const saved = new Map();
|
|
107
107
|
const failures = new Map();
|
|
108
|
-
return show((answer) => ({
|
|
108
|
+
return show(`Enter ${missing.length === 1 ? 'one setting' : `${missing.length} settings`}`, (answer) => ({
|
|
109
109
|
draw: () => dialog(Text({ bold: true, children: `Set up ${name}` }), Text({ children: `${name} needs ${missing.length === 1 ? 'one setting' : `${missing.length} settings`}:` }), ...missing.map(([key, option]) => {
|
|
110
110
|
const label = Box({ flexDirection: 'column', children: [Text({ bold: true, children: option.title }), ...(option.description === '' ? [] : [Text({ dimColor: true, wrap: 'wrap', children: option.description })])] });
|
|
111
111
|
if (option.type === 'secret') {
|
|
@@ -137,7 +137,7 @@ export function createInstaller(name, claude, waiting, nextDraw) {
|
|
|
137
137
|
},
|
|
138
138
|
step(mod, step, index, total) {
|
|
139
139
|
let notice;
|
|
140
|
-
return show((answer) => ({
|
|
140
|
+
return show(`Step ${index} of ${total}: ${step.title}`, (answer) => ({
|
|
141
141
|
draw: (props) => {
|
|
142
142
|
let body;
|
|
143
143
|
try {
|
|
@@ -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,E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AAE,CAAC,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,KAAK,IAAI,CAAA;IACtE,QAAQ,CAAC,KAAK,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,IAAI,CAAA;IACpC,QAAQ,CAAC,gBAAgB,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,KAAK,IAAI,CAAA;IAChE,QAAQ,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;AA2DhB,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,CAskBlB"}
|
package/runtime/lifecycle.js
CHANGED
|
@@ -31,6 +31,7 @@ const cmodUpdatedKey = 'cmod:cmod-updated-for';
|
|
|
31
31
|
const installId = 'cmod:install';
|
|
32
32
|
const askingId = 'cmod:asking';
|
|
33
33
|
const recordId = 'cmod:record';
|
|
34
|
+
const downloadId = 'cmod:download';
|
|
34
35
|
const installRetrySeconds = [2, 4, 8, 16, 32, 64, 128];
|
|
35
36
|
const cmodCheckMs = 1000;
|
|
36
37
|
const recordCheckMs = 1000;
|
|
@@ -111,10 +112,10 @@ export function createLifecycle(definition, permissionRoutes = () => undefined,
|
|
|
111
112
|
let drawCount = 0;
|
|
112
113
|
const nextDraw = () => (drawCount += 1);
|
|
113
114
|
const installer = createInstaller(definition.name, () => claude(), {
|
|
114
|
-
show: (open) => {
|
|
115
|
+
show: (open, next) => {
|
|
115
116
|
if (phase !== 'active')
|
|
116
117
|
runtime?.toaster.toast.dismiss(installId);
|
|
117
|
-
runtime?.toaster.toast.info('
|
|
118
|
+
runtime?.toaster.toast.info('Finish setting up', { id: askingId, description: next, duration: Infinity, action: { label: 'Continue', onClick: open } });
|
|
118
119
|
},
|
|
119
120
|
hide: () => runtime?.toaster.toast.dismiss(askingId),
|
|
120
121
|
}, nextDraw);
|
|
@@ -196,7 +197,7 @@ export function createLifecycle(definition, permissionRoutes = () => undefined,
|
|
|
196
197
|
if (plugin === undefined || (await newestCmodVersion(claude())) === undefined)
|
|
197
198
|
return;
|
|
198
199
|
let failed;
|
|
199
|
-
const { code, lastError } = await readLines(claude().process.spawn({ argv: ['cmod', 'setup', plugin.root, '--events'] }), (text) => {
|
|
200
|
+
const { code, lastError } = await readLines(claude().process.spawn({ argv: ['cmod', 'setup', plugin.root, '--events'], env: { CLAUDE_CODE_SESSION_ID: await claude().session.id() } }), (text) => {
|
|
200
201
|
const event = parseEvent(text);
|
|
201
202
|
if (event.type === 'done')
|
|
202
203
|
shouldRecord = false;
|
|
@@ -211,6 +212,13 @@ export function createLifecycle(definition, permissionRoutes = () => undefined,
|
|
|
211
212
|
return void toastFailure({ id: recordId, message: failed, retry: record, isCritical: true });
|
|
212
213
|
throw new Error(`cmod setup ${formatExit(code, lastError)}`);
|
|
213
214
|
};
|
|
215
|
+
const isInstalledCopy = async () => {
|
|
216
|
+
await recording;
|
|
217
|
+
if (plugin === undefined)
|
|
218
|
+
return true;
|
|
219
|
+
const recorded = await readRecord((path) => claude().fs.read(path).catch(ifMissing(undefined)), plugin.store, plugin.name);
|
|
220
|
+
return recorded === undefined || recorded.root === plugin.root;
|
|
221
|
+
};
|
|
214
222
|
const record = () => {
|
|
215
223
|
recording ??= recordThroughCmod()
|
|
216
224
|
.catch((error) => claude().ui.warn('record', `${definition.name} has no cmod record yet: ${messageOf(error)}`))
|
|
@@ -250,13 +258,13 @@ export function createLifecycle(definition, permissionRoutes = () => undefined,
|
|
|
250
258
|
}
|
|
251
259
|
catch (error) {
|
|
252
260
|
toastFailure({ id: `step:${step.title}`, message: `The ${step.title} step's isDone failed`, error });
|
|
253
|
-
return
|
|
261
|
+
return undefined;
|
|
254
262
|
}
|
|
255
263
|
};
|
|
256
264
|
const pendingSteps = async (active) => {
|
|
257
265
|
const pending = [];
|
|
258
266
|
for (const step of definition.installer ?? [])
|
|
259
|
-
if (
|
|
267
|
+
if ((await isStepDone(active, step)) !== true)
|
|
260
268
|
pending.push(step.title);
|
|
261
269
|
return pending;
|
|
262
270
|
};
|
|
@@ -264,7 +272,10 @@ export function createLifecycle(definition, permissionRoutes = () => undefined,
|
|
|
264
272
|
const steps = asksPerson ? (definition.installer ?? []) : [];
|
|
265
273
|
try {
|
|
266
274
|
for (const [index, step] of steps.entries()) {
|
|
267
|
-
|
|
275
|
+
const isDone = await isStepDone(active, step);
|
|
276
|
+
if (isDone === undefined)
|
|
277
|
+
break;
|
|
278
|
+
if (isDone)
|
|
268
279
|
continue;
|
|
269
280
|
const isAnswered = (await claude().session.surfaces()).length > 0 && (await installer.step(active, step, index + 1, steps.length));
|
|
270
281
|
if (!isAnswered) {
|
|
@@ -287,7 +298,7 @@ export function createLifecycle(definition, permissionRoutes = () => undefined,
|
|
|
287
298
|
return;
|
|
288
299
|
const activeRouter = createRouter();
|
|
289
300
|
startingRouter = activeRouter;
|
|
290
|
-
const active = await createMod(definition, { ...runtime, router: activeRouter, dataFolder: dataFolder(plugin.store, plugin.name), store: plugin.store, permissionRoutes, options: pluginOptions, nextDraw, installer, serveCmodPlugin })
|
|
301
|
+
const active = await createMod(definition, { ...runtime, router: activeRouter, dataFolder: dataFolder(plugin.store, plugin.name), store: plugin.store, permissionRoutes, options: pluginOptions, nextDraw, installer, serveCmodPlugin, isInstalledCopy })
|
|
291
302
|
.catch(async (error) => {
|
|
292
303
|
if (error instanceof MissingOptions && (await askOptions(error)))
|
|
293
304
|
return undefined;
|
|
@@ -350,9 +361,11 @@ export function createLifecycle(definition, permissionRoutes = () => undefined,
|
|
|
350
361
|
const install = async (isQuiet = false) => {
|
|
351
362
|
if (plugin === undefined)
|
|
352
363
|
return;
|
|
353
|
-
if (plugin.name === cmodPluginName)
|
|
354
|
-
return bootstrap(plugin.root);
|
|
355
364
|
phase = 'installing';
|
|
365
|
+
if (plugin.name === cmodPluginName) {
|
|
366
|
+
download(plugin.root);
|
|
367
|
+
return finish();
|
|
368
|
+
}
|
|
356
369
|
const found = await newestCmodVersion(claude());
|
|
357
370
|
if (!fits(found))
|
|
358
371
|
return waitForcmod(found);
|
|
@@ -360,7 +373,7 @@ export function createLifecycle(definition, permissionRoutes = () => undefined,
|
|
|
360
373
|
installing();
|
|
361
374
|
let outcome;
|
|
362
375
|
let retries;
|
|
363
|
-
const { code, lastError } = await readLines(claude().process.spawn({ argv: ['cmod', 'setup', plugin.root, '--events'] }), (text) => {
|
|
376
|
+
const { code, lastError } = await readLines(claude().process.spawn({ argv: ['cmod', 'setup', plugin.root, '--events'], env: { CLAUDE_CODE_SESSION_ID: await claude().session.id() } }), (text) => {
|
|
364
377
|
const event = parseEvent(text);
|
|
365
378
|
if (event.type === 'progress' && !isQuiet)
|
|
366
379
|
installing(progressOf(event));
|
|
@@ -426,17 +439,19 @@ export function createLifecycle(definition, permissionRoutes = () => undefined,
|
|
|
426
439
|
.catch(report);
|
|
427
440
|
});
|
|
428
441
|
};
|
|
429
|
-
const
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
const
|
|
442
|
+
const download = (root) => {
|
|
443
|
+
const downloading = (description) => runtime?.toaster.toast.loading('Downloading the cmod program', { id: downloadId, ...(description === undefined ? {} : { description }) });
|
|
444
|
+
downloading();
|
|
445
|
+
const downloaded = readLines(claude().process.spawn({ argv: ['sh', '-c', './setup/bootstrap.sh'], cwd: root }), (text) => {
|
|
433
446
|
const event = parseEvent(text);
|
|
434
447
|
if (event.type === 'progress')
|
|
435
|
-
|
|
448
|
+
downloading(progressOf(event));
|
|
449
|
+
}).then(({ code, lastError }) => {
|
|
450
|
+
if (code !== 0)
|
|
451
|
+
throw new Error(`bootstrap ${formatExit(code, lastError)}`);
|
|
436
452
|
});
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
fail(`bootstrap ${formatExit(code, lastError)}`, undefined, () => bootstrap(root));
|
|
453
|
+
programs?.waitFor(downloaded);
|
|
454
|
+
void downloaded.then(() => runtime?.toaster.toast.dismiss(downloadId), (error) => toastFailure({ id: downloadId, message: messageOf(error), retry: async () => download(root), isCritical: true }));
|
|
440
455
|
};
|
|
441
456
|
const begin = async () => {
|
|
442
457
|
if (readStarted === undefined)
|
|
@@ -1077,6 +1092,7 @@ async function createMod(definition, runtime) {
|
|
|
1077
1092
|
hasPermissionCheck: () => runtime.permissionRoutes() !== undefined,
|
|
1078
1093
|
answerInput: area.answerInput,
|
|
1079
1094
|
spawnCmod: (args, env) => spawnCmod(claude, args, session, env),
|
|
1095
|
+
isInstalledCopy: runtime.isInstalledCopy,
|
|
1080
1096
|
watches,
|
|
1081
1097
|
onRedraw(listener) {
|
|
1082
1098
|
redraws.add(listener);
|
|
@@ -1094,6 +1110,8 @@ async function createMod(definition, runtime) {
|
|
|
1094
1110
|
return { remove: () => void names.delete(key) };
|
|
1095
1111
|
};
|
|
1096
1112
|
const removeUndeclaredServices = async () => {
|
|
1113
|
+
if (!(await runtime.isInstalledCopy()))
|
|
1114
|
+
return;
|
|
1097
1115
|
for (const { name } of await claude.fs.list(serviceFolder(runtime.store, definition.name)).catch(ifMissing([]))) {
|
|
1098
1116
|
const program = name.endsWith('.json') ? name.slice(0, -'.json'.length) : undefined;
|
|
1099
1117
|
if (program !== undefined && !names.has(`service:${program}`))
|
package/runtime/programs.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ import type { Claude } from './claude.js';
|
|
|
3
3
|
export type Programs = {
|
|
4
4
|
readonly claude: Claude;
|
|
5
5
|
refresh(): Promise<void>;
|
|
6
|
+
waitFor(download: Promise<void>): void;
|
|
6
7
|
};
|
|
7
8
|
export declare function lastLineOf(text: string): string | undefined;
|
|
8
9
|
export declare function cmodError(stderr: string, command: string | undefined): string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"programs.d.ts","sourceRoot":"","sources":["../src/runtime/programs.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAA;AAIpF,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AAEzC,MAAM,MAAM,QAAQ,GAAG;IAAE,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IAAC,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC,CAAA;CAAE,CAAA;
|
|
1
|
+
{"version":3,"file":"programs.d.ts","sourceRoot":"","sources":["../src/runtime/programs.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAA;AAIpF,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AAEzC,MAAM,MAAM,QAAQ,GAAG;IAAE,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IAAC,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IAAC,OAAO,CAAC,QAAQ,EAAE,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAA;CAAE,CAAA;AAEpH,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAG3D;AAED,wBAAgB,SAAS,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,CAI7E;AAED,wBAAsB,SAAS,CAAC,MAAM,EAAE,UAAU,CAAC,iBAAiB,EAAE,kBAAkB,CAAC,EAAE,MAAM,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,GAAG,OAAO,CAAC;IAAE,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IAAC,SAAS,EAAE,MAAM,CAAA;CAAE,CAAC,CAgB9K;AAED,wBAAgB,SAAS,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,SAAS,MAAM,EAAE,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,GAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAM,GAAG,UAAU,CAAC,iBAAiB,EAAE,kBAAkB,CAAC,CAEjL;AAED,wBAAsB,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAK5F;AAED,wBAAsB,iBAAiB,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CASnF;AAED,wBAAsB,OAAO,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,SAAS,MAAM,EAAE,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAKvG;AAuBD,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,MAAM,GAAG,QAAQ,CAsCzD"}
|
package/runtime/programs.js
CHANGED
|
@@ -53,21 +53,59 @@ export async function runCmod(claude, args, session) {
|
|
|
53
53
|
throw new Error(cmodError(lastError, args[0]) || `cmod ${args.slice(0, 2).join(' ')} ${formatExit(code, '')}.`);
|
|
54
54
|
return lines.join('\n');
|
|
55
55
|
}
|
|
56
|
+
function spawnedAfter(ready, spawn) {
|
|
57
|
+
let resolve = () => undefined;
|
|
58
|
+
let reject = () => undefined;
|
|
59
|
+
const result = new Promise((resolved, rejected) => {
|
|
60
|
+
resolve = resolved;
|
|
61
|
+
reject = rejected;
|
|
62
|
+
});
|
|
63
|
+
result.catch(() => undefined);
|
|
64
|
+
const stream = (async function* () {
|
|
65
|
+
try {
|
|
66
|
+
await ready;
|
|
67
|
+
const ended = yield* spawn();
|
|
68
|
+
resolve(ended);
|
|
69
|
+
return ended;
|
|
70
|
+
}
|
|
71
|
+
finally {
|
|
72
|
+
reject(new Error('cmod: the stream closed before the program ended.'));
|
|
73
|
+
}
|
|
74
|
+
})();
|
|
75
|
+
return Object.assign(stream, { result });
|
|
76
|
+
}
|
|
56
77
|
export function locatingPrograms(claude) {
|
|
57
78
|
let folder;
|
|
58
79
|
let names = new Set();
|
|
80
|
+
let downloading;
|
|
59
81
|
const located = (argv) => {
|
|
60
82
|
const [name, ...rest] = argv;
|
|
61
83
|
return folder !== undefined && name !== undefined && (name === 'cmod' || names.has(name)) ? [`${folder}/${name}`, ...rest] : argv;
|
|
62
84
|
};
|
|
85
|
+
const waiting = (argv) => (argv[0] === 'cmod' ? downloading : undefined);
|
|
63
86
|
return {
|
|
64
87
|
claude: {
|
|
65
88
|
...claude,
|
|
66
89
|
process: {
|
|
67
|
-
run: (argv, init) =>
|
|
68
|
-
|
|
90
|
+
run: (argv, init) => {
|
|
91
|
+
const ready = waiting(argv);
|
|
92
|
+
return ready === undefined ? claude.process.run(located(argv), init) : ready.then(() => claude.process.run(located(argv), init));
|
|
93
|
+
},
|
|
94
|
+
spawn: (request) => {
|
|
95
|
+
const ready = waiting(request.argv);
|
|
96
|
+
const spawn = () => claude.process.spawn({ ...request, argv: located(request.argv) });
|
|
97
|
+
return ready === undefined ? spawn() : spawnedAfter(ready, spawn);
|
|
98
|
+
},
|
|
69
99
|
},
|
|
70
100
|
},
|
|
101
|
+
waitFor(download) {
|
|
102
|
+
const current = download.then(() => {
|
|
103
|
+
if (downloading === current)
|
|
104
|
+
downloading = undefined;
|
|
105
|
+
});
|
|
106
|
+
current.catch(() => undefined);
|
|
107
|
+
downloading = current;
|
|
108
|
+
},
|
|
71
109
|
async refresh() {
|
|
72
110
|
const [home, dataHome] = await Promise.all([claude.env.home(), claude.env.dataHome()]);
|
|
73
111
|
const programs = `${storeFolder({ HOME: home, XDG_DATA_HOME: dataHome })}/programs`;
|
package/runtime/sessions.js
CHANGED
|
@@ -11,7 +11,7 @@ import { TaskEnd, TaskStart } from '../session/goal/task.js';
|
|
|
11
11
|
import { beforeEvents, processEvents, Session, sessionEvents } from '../session/session.js';
|
|
12
12
|
import { matches, sentMatcher } from '../utils/matcher.js';
|
|
13
13
|
import { beforeAnswerKeys, foldAnswers, foldBefore, methodOf, takenAnswer } from './before.js';
|
|
14
|
-
import { cmodPluginName
|
|
14
|
+
import { cmodPluginName } from './dependencies.js';
|
|
15
15
|
import { messageOf } from '../utils/text.js';
|
|
16
16
|
import { listenerOf, PassedTimeout, withinTime } from './deadline.js';
|
|
17
17
|
import { callFiles } from './hooks.js';
|
|
@@ -168,8 +168,7 @@ export function createSessionsClient({ name, claude, report, hookOn, routeOn, pe
|
|
|
168
168
|
if (tree instanceof Map)
|
|
169
169
|
return isInScope(scope, session, change, isUnderIn(tree));
|
|
170
170
|
return tree.then((read) => isInScope(scope, session, change, isUnderIn(read)), (error) => {
|
|
171
|
-
|
|
172
|
-
report(`tasks:${session}`, 'Could not read the tasks it listens under', error);
|
|
171
|
+
report(`tasks:${session}`, 'Could not read the tasks it listens under', error);
|
|
173
172
|
return false;
|
|
174
173
|
});
|
|
175
174
|
};
|
package/runtime/ui.js
CHANGED
|
@@ -4,7 +4,7 @@ import { Box, drawKeyed, drawsFocusable, drawWith, elementData, Markdown, Text }
|
|
|
4
4
|
import { checkPane, checkPart, sizeKeys } from '../ui/panes.js';
|
|
5
5
|
import { componentOf, nameOf } from '../ui/styles.js';
|
|
6
6
|
import { messageOf } from '../utils/text.js';
|
|
7
|
-
import { cmodPluginName
|
|
7
|
+
import { cmodPluginName } from './dependencies.js';
|
|
8
8
|
export const partMethods = {
|
|
9
9
|
list: 'cmod:parts',
|
|
10
10
|
draw: 'cmod:draw',
|
|
@@ -234,8 +234,7 @@ export function createUi({ name, claude, router, report, announce, mod, borrowed
|
|
|
234
234
|
if (isObject(answer) && name !== cmodPluginName)
|
|
235
235
|
hear(answer['stylers'], false);
|
|
236
236
|
}, (error) => {
|
|
237
|
-
|
|
238
|
-
claude.ui.warn('parts:tell', `${name}: the cmod plugin did not hear about its pages and widgets: ${messageOf(error)}`);
|
|
237
|
+
claude.ui.warn('parts:tell', `${name}: the cmod plugin did not hear about its pages and widgets: ${messageOf(error)}`);
|
|
239
238
|
});
|
|
240
239
|
};
|
|
241
240
|
if (!isAsked)
|
package/src/jobs/program.ts
CHANGED
|
@@ -24,7 +24,7 @@ const retryWithinMs = 1000
|
|
|
24
24
|
export function program(options: { readonly command: readonly string[]; readonly environment?: Record<string, string>; readonly singleInstance?: boolean; readonly isService?: boolean }): Job<Program> {
|
|
25
25
|
const { command, environment, singleInstance = false, isService = false } = options
|
|
26
26
|
return ({ mod, announce, reserveName }) => {
|
|
27
|
-
const { claude, report, spawnCmod, watches } = engineOf(mod)
|
|
27
|
+
const { claude, report, spawnCmod, isInstalledCopy, 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
30
|
if (isService) for (const type of ['program', 'service']) reserveName(type, basename(executable), `${mod.name}: the service ${executable} is already added. Give each isService program its own executable.`)
|
|
@@ -41,9 +41,9 @@ export function program(options: { readonly command: readonly string[]; readonly
|
|
|
41
41
|
let instance: Promise<string> | undefined
|
|
42
42
|
let leaseCheck: Promise<void> | undefined
|
|
43
43
|
|
|
44
|
-
const spawn = () => {
|
|
45
|
-
if (
|
|
46
|
-
return
|
|
44
|
+
const spawn = (isOwnService: boolean) => {
|
|
45
|
+
if (isOwnService) return spawnCmod(['program', mod.name, '--service', ...Object.keys(environment ?? {}).flatMap((name) => ['--env', name]), '--', ...command], environment)
|
|
46
|
+
return isElected ? spawnCmod(['program', mod.name, '--no-wait', '--', ...command], environment) : claude.process.spawn(request)
|
|
47
47
|
}
|
|
48
48
|
|
|
49
49
|
const instanceFile = () =>
|
|
@@ -108,11 +108,12 @@ export function program(options: { readonly command: readonly string[]; readonly
|
|
|
108
108
|
let lastError = ''
|
|
109
109
|
let isShown = false
|
|
110
110
|
try {
|
|
111
|
-
|
|
111
|
+
const isOwnService = isService && (await isInstalledCopy())
|
|
112
|
+
if (isElected && !isOwnService) {
|
|
112
113
|
const file = await instanceFile()
|
|
113
114
|
if (await isHeld(claude, `${file}.lock`, staleMs)) return await follow(file)
|
|
114
115
|
}
|
|
115
|
-
for await (const piece of
|
|
116
|
+
for await (const piece of spawn(isOwnService)) {
|
|
116
117
|
if (piece.stream === 'stderr') {
|
|
117
118
|
lastError = piece.text.trim().split('\n').at(-1) ?? lastError
|
|
118
119
|
continue
|
package/src/records.ts
CHANGED
|
@@ -12,8 +12,11 @@ export type InstallRecord = {
|
|
|
12
12
|
keys: Readonly<Record<string, string>>
|
|
13
13
|
permissions: readonly string[] | null
|
|
14
14
|
grantedOnUpdate: readonly string[]
|
|
15
|
+
installedBy: InstalledBy | null
|
|
15
16
|
}
|
|
16
17
|
|
|
18
|
+
export type InstalledBy = { readonly session: string | null; readonly pid: number }
|
|
19
|
+
|
|
17
20
|
export type Steps = {
|
|
18
21
|
install?: string
|
|
19
22
|
uninstall?: string
|
|
@@ -137,6 +140,8 @@ function parseRecord(text: string, path: string): InstallRecord {
|
|
|
137
140
|
if (permissions !== null && !isTextList(permissions)) throw new Error(`${path} has "permissions" that are not a list of permissions. ${fix}`)
|
|
138
141
|
const grantedOnUpdate = value['grantedOnUpdate'] ?? []
|
|
139
142
|
if (!isTextList(grantedOnUpdate)) throw new Error(`${path} has a "grantedOnUpdate" that is not a list of permissions. ${fix}`)
|
|
143
|
+
const installedBy = value['installedBy'] ?? null
|
|
144
|
+
if (installedBy !== null && !(isObject(installedBy) && (installedBy['session'] === null || typeof installedBy['session'] === 'string') && typeof installedBy['pid'] === 'number')) throw new Error(`${path} has an "installedBy" that names no session and process. ${fix}`)
|
|
140
145
|
return {
|
|
141
146
|
name: value['name'] as string,
|
|
142
147
|
version: value['version'] as string,
|
|
@@ -148,6 +153,7 @@ function parseRecord(text: string, path: string): InstallRecord {
|
|
|
148
153
|
keys: keys as Record<string, string>,
|
|
149
154
|
permissions,
|
|
150
155
|
grantedOnUpdate,
|
|
156
|
+
installedBy: installedBy as InstalledBy | null,
|
|
151
157
|
}
|
|
152
158
|
}
|
|
153
159
|
|
|
@@ -435,7 +441,7 @@ function readHotkeys(hotkeys: unknown): Steps {
|
|
|
435
441
|
return { hotkeys: checkHotkeys('package.json "cmod"', hotkeys as Record<string, HotkeyInit>) }
|
|
436
442
|
}
|
|
437
443
|
|
|
438
|
-
export const coreVersion = '6.0.
|
|
444
|
+
export const coreVersion = '6.0.4'
|
|
439
445
|
|
|
440
446
|
export const oldestCmodVersion = '6.0.0'
|
|
441
447
|
|
package/src/runtime/engine.ts
CHANGED
|
@@ -16,6 +16,7 @@ export type Engine = {
|
|
|
16
16
|
readonly hasPermissionCheck: () => boolean
|
|
17
17
|
readonly answerInput: <Answer>(run: () => Promise<Answer>, passOn: () => Promise<unknown>) => Promise<Answer>
|
|
18
18
|
readonly spawnCmod: (args: readonly string[], env?: Readonly<Record<string, string>>) => HookStream<ProcessSpawnChunk, ProcessSpawnResult>
|
|
19
|
+
readonly isInstalledCopy: () => Promise<boolean>
|
|
19
20
|
readonly watches: Watches
|
|
20
21
|
readonly onRedraw: (listener: () => void) => Subscription
|
|
21
22
|
readonly widgets?: Widgets
|
package/src/runtime/installer.ts
CHANGED
|
@@ -31,7 +31,7 @@ export type Installer = {
|
|
|
31
31
|
|
|
32
32
|
const keptDraws = 8
|
|
33
33
|
|
|
34
|
-
export function createInstaller(name: string, claude: () => Claude, waiting: { show(open: () => Promise<void
|
|
34
|
+
export function createInstaller(name: string, claude: () => Claude, waiting: { show(open: () => Promise<void>, next: string): void; hide(): void }, nextDraw: () => number): Installer {
|
|
35
35
|
let question: Question | undefined
|
|
36
36
|
let isOpen = false
|
|
37
37
|
let isSeen = false
|
|
@@ -48,7 +48,7 @@ export function createInstaller(name: string, claude: () => Claude, waiting: { s
|
|
|
48
48
|
|
|
49
49
|
const open = (isAsked: boolean) => send({ requests: [{ open: installPage, focus: true }], ...(isAsked ? { isAsked: true } : {}) })
|
|
50
50
|
|
|
51
|
-
const show = async <Answer>(build: (answer: (value: Answer) => void) => Omit<Question, 'cancel'>, cancelled: Answer): Promise<Answer> => {
|
|
51
|
+
const show = async <Answer>(next: string, build: (answer: (value: Answer) => void) => Omit<Question, 'cancel'>, cancelled: Answer): Promise<Answer> => {
|
|
52
52
|
question?.cancel()
|
|
53
53
|
const answer = new Promise<Answer>((resolve) => {
|
|
54
54
|
let isAnswered = false
|
|
@@ -60,7 +60,7 @@ export function createInstaller(name: string, claude: () => Claude, waiting: { s
|
|
|
60
60
|
}
|
|
61
61
|
question = { ...build(done), cancel: () => done(cancelled) }
|
|
62
62
|
})
|
|
63
|
-
waiting.show(() => open(true))
|
|
63
|
+
waiting.show(() => open(true), next)
|
|
64
64
|
if (isOpen) {
|
|
65
65
|
await send({ redraw: true }).catch(log('the installer did not redraw'))
|
|
66
66
|
} else {
|
|
@@ -130,6 +130,7 @@ export function createInstaller(name: string, claude: () => Claude, waiting: { s
|
|
|
130
130
|
const saved = new Map<string, string>()
|
|
131
131
|
const failures = new Map<string, string>()
|
|
132
132
|
return show<boolean>(
|
|
133
|
+
`Enter ${missing.length === 1 ? 'one setting' : `${missing.length} settings`}`,
|
|
133
134
|
(answer) => ({
|
|
134
135
|
draw: () =>
|
|
135
136
|
dialog(
|
|
@@ -170,6 +171,7 @@ export function createInstaller(name: string, claude: () => Claude, waiting: { s
|
|
|
170
171
|
step(mod, step, index, total) {
|
|
171
172
|
let notice: { readonly color: 'warning' | 'error'; readonly text: string } | undefined
|
|
172
173
|
return show<boolean>(
|
|
174
|
+
`Step ${index} of ${total}: ${step.title}`,
|
|
173
175
|
(answer) => ({
|
|
174
176
|
draw: (props) => {
|
|
175
177
|
let body: RenderElement
|
package/src/runtime/lifecycle.ts
CHANGED
|
@@ -91,6 +91,7 @@ type ModRuntime = {
|
|
|
91
91
|
readonly nextDraw: () => number
|
|
92
92
|
readonly installer: Pick<Installer, 'changed'>
|
|
93
93
|
readonly serveCmodPlugin: ServeCmodPlugin | undefined
|
|
94
|
+
readonly isInstalledCopy: () => Promise<boolean>
|
|
94
95
|
}
|
|
95
96
|
|
|
96
97
|
type ActiveMod<State extends object, Declared extends Options> = {
|
|
@@ -111,6 +112,8 @@ const askingId = 'cmod:asking'
|
|
|
111
112
|
|
|
112
113
|
const recordId = 'cmod:record'
|
|
113
114
|
|
|
115
|
+
const downloadId = 'cmod:download'
|
|
116
|
+
|
|
114
117
|
const installRetrySeconds = [2, 4, 8, 16, 32, 64, 128] as const
|
|
115
118
|
|
|
116
119
|
const cmodCheckMs = 1000
|
|
@@ -211,9 +214,9 @@ export function createLifecycle<State extends object, Declared extends Options =
|
|
|
211
214
|
definition.name,
|
|
212
215
|
() => claude(),
|
|
213
216
|
{
|
|
214
|
-
show: (open) => {
|
|
217
|
+
show: (open, next) => {
|
|
215
218
|
if (phase !== 'active') runtime?.toaster.toast.dismiss(installId)
|
|
216
|
-
runtime?.toaster.toast.info('
|
|
219
|
+
runtime?.toaster.toast.info('Finish setting up', { id: askingId, description: next, duration: Infinity, action: { label: 'Continue', onClick: open } })
|
|
217
220
|
},
|
|
218
221
|
hide: () => runtime?.toaster.toast.dismiss(askingId),
|
|
219
222
|
},
|
|
@@ -309,7 +312,7 @@ export function createLifecycle<State extends object, Declared extends Options =
|
|
|
309
312
|
const recordThroughCmod = async () => {
|
|
310
313
|
if (plugin === undefined || (await newestCmodVersion(claude())) === undefined) return
|
|
311
314
|
let failed: string | undefined
|
|
312
|
-
const { code, lastError } = await readLines(claude().process.spawn({ argv: ['cmod', 'setup', plugin.root, '--events'] }), (text) => {
|
|
315
|
+
const { code, lastError } = await readLines(claude().process.spawn({ argv: ['cmod', 'setup', plugin.root, '--events'], env: { CLAUDE_CODE_SESSION_ID: await claude().session.id() } }), (text) => {
|
|
313
316
|
const event = parseEvent(text)
|
|
314
317
|
if (event.type === 'done') shouldRecord = false
|
|
315
318
|
if (event.type === 'failed') failed = event.message
|
|
@@ -322,6 +325,13 @@ export function createLifecycle<State extends object, Declared extends Options =
|
|
|
322
325
|
throw new Error(`cmod setup ${formatExit(code, lastError)}`)
|
|
323
326
|
}
|
|
324
327
|
|
|
328
|
+
const isInstalledCopy = async () => {
|
|
329
|
+
await recording
|
|
330
|
+
if (plugin === undefined) return true
|
|
331
|
+
const recorded = await readRecord((path) => claude().fs.read(path).catch(ifMissing(undefined)), plugin.store, plugin.name)
|
|
332
|
+
return recorded === undefined || recorded.root === plugin.root
|
|
333
|
+
}
|
|
334
|
+
|
|
325
335
|
const record = () => {
|
|
326
336
|
recording ??= recordThroughCmod()
|
|
327
337
|
.catch((error: unknown) => claude().ui.warn('record', `${definition.name} has no cmod record yet: ${messageOf(error)}`))
|
|
@@ -354,18 +364,18 @@ export function createLifecycle<State extends object, Declared extends Options =
|
|
|
354
364
|
return true
|
|
355
365
|
}
|
|
356
366
|
|
|
357
|
-
const isStepDone = async (active: Mod<State>, step: Step<State>) => {
|
|
367
|
+
const isStepDone = async (active: Mod<State>, step: Step<State>): Promise<boolean | undefined> => {
|
|
358
368
|
try {
|
|
359
369
|
return await step.isDone(active)
|
|
360
370
|
} catch (error) {
|
|
361
371
|
toastFailure({ id: `step:${step.title}`, message: `The ${step.title} step's isDone failed`, error })
|
|
362
|
-
return
|
|
372
|
+
return undefined
|
|
363
373
|
}
|
|
364
374
|
}
|
|
365
375
|
|
|
366
376
|
const pendingSteps = async (active: Mod<State>) => {
|
|
367
377
|
const pending: string[] = []
|
|
368
|
-
for (const step of definition.installer ?? []) if (
|
|
378
|
+
for (const step of definition.installer ?? []) if ((await isStepDone(active, step)) !== true) pending.push(step.title)
|
|
369
379
|
return pending
|
|
370
380
|
}
|
|
371
381
|
|
|
@@ -373,7 +383,9 @@ export function createLifecycle<State extends object, Declared extends Options =
|
|
|
373
383
|
const steps = asksPerson ? (definition.installer ?? []) : []
|
|
374
384
|
try {
|
|
375
385
|
for (const [index, step] of steps.entries()) {
|
|
376
|
-
|
|
386
|
+
const isDone = await isStepDone(active, step)
|
|
387
|
+
if (isDone === undefined) break
|
|
388
|
+
if (isDone) continue
|
|
377
389
|
const isAnswered = (await claude().session.surfaces()).length > 0 && (await installer.step(active, step, index + 1, steps.length))
|
|
378
390
|
if (!isAnswered) {
|
|
379
391
|
runtime?.toaster.toast.warning(steps.length - index === 1 ? 'Needs one more step' : `Needs ${steps.length - index} more steps`, {
|
|
@@ -394,7 +406,7 @@ export function createLifecycle<State extends object, Declared extends Options =
|
|
|
394
406
|
if (runtime === undefined || plugin === undefined) return
|
|
395
407
|
const activeRouter = createRouter()
|
|
396
408
|
startingRouter = activeRouter
|
|
397
|
-
const active = await createMod(definition, { ...runtime, router: activeRouter, dataFolder: dataFolder(plugin.store, plugin.name), store: plugin.store, permissionRoutes, options: pluginOptions, nextDraw, installer, serveCmodPlugin })
|
|
409
|
+
const active = await createMod(definition, { ...runtime, router: activeRouter, dataFolder: dataFolder(plugin.store, plugin.name), store: plugin.store, permissionRoutes, options: pluginOptions, nextDraw, installer, serveCmodPlugin, isInstalledCopy })
|
|
398
410
|
.catch(async (error: unknown) => {
|
|
399
411
|
if (error instanceof MissingOptions && (await askOptions(error))) return undefined
|
|
400
412
|
await installer.close()
|
|
@@ -453,14 +465,17 @@ export function createLifecycle<State extends object, Declared extends Options =
|
|
|
453
465
|
|
|
454
466
|
const install = async (isQuiet = false): Promise<void> => {
|
|
455
467
|
if (plugin === undefined) return
|
|
456
|
-
if (plugin.name === cmodPluginName) return bootstrap(plugin.root)
|
|
457
468
|
phase = 'installing'
|
|
469
|
+
if (plugin.name === cmodPluginName) {
|
|
470
|
+
download(plugin.root)
|
|
471
|
+
return finish()
|
|
472
|
+
}
|
|
458
473
|
const found = await newestCmodVersion(claude())
|
|
459
474
|
if (!fits(found)) return waitForcmod(found)
|
|
460
475
|
if (!isQuiet) installing()
|
|
461
476
|
let outcome: RunnerEvent | undefined
|
|
462
477
|
let retries: 'changed' | 'later' | undefined
|
|
463
|
-
const { code, lastError } = await readLines(claude().process.spawn({ argv: ['cmod', 'setup', plugin.root, '--events'] }), (text) => {
|
|
478
|
+
const { code, lastError } = await readLines(claude().process.spawn({ argv: ['cmod', 'setup', plugin.root, '--events'], env: { CLAUDE_CODE_SESSION_ID: await claude().session.id() } }), (text) => {
|
|
464
479
|
const event = parseEvent(text)
|
|
465
480
|
if (event.type === 'progress' && !isQuiet) installing(progressOf(event))
|
|
466
481
|
if (event.type === 'retries') retries = event.when
|
|
@@ -524,15 +539,20 @@ export function createLifecycle<State extends object, Declared extends Options =
|
|
|
524
539
|
})
|
|
525
540
|
}
|
|
526
541
|
|
|
527
|
-
const
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
const
|
|
542
|
+
const download = (root: string) => {
|
|
543
|
+
const downloading = (description?: RenderElement) => runtime?.toaster.toast.loading('Downloading the cmod program', { id: downloadId, ...(description === undefined ? {} : { description }) })
|
|
544
|
+
downloading()
|
|
545
|
+
const downloaded = readLines(claude().process.spawn({ argv: ['sh', '-c', './setup/bootstrap.sh'], cwd: root }), (text) => {
|
|
531
546
|
const event = parseEvent(text)
|
|
532
|
-
if (event.type === 'progress')
|
|
547
|
+
if (event.type === 'progress') downloading(progressOf(event))
|
|
548
|
+
}).then(({ code, lastError }) => {
|
|
549
|
+
if (code !== 0) throw new Error(`bootstrap ${formatExit(code, lastError)}`)
|
|
533
550
|
})
|
|
534
|
-
|
|
535
|
-
|
|
551
|
+
programs?.waitFor(downloaded)
|
|
552
|
+
void downloaded.then(
|
|
553
|
+
() => runtime?.toaster.toast.dismiss(downloadId),
|
|
554
|
+
(error: unknown) => toastFailure({ id: downloadId, message: messageOf(error), retry: async () => download(root), isCritical: true }),
|
|
555
|
+
)
|
|
536
556
|
}
|
|
537
557
|
|
|
538
558
|
const begin = async (): Promise<void> => {
|
|
@@ -1133,6 +1153,7 @@ async function createMod<State extends object, Declared extends Options>(definit
|
|
|
1133
1153
|
hasPermissionCheck: () => runtime.permissionRoutes() !== undefined,
|
|
1134
1154
|
answerInput: area.answerInput,
|
|
1135
1155
|
spawnCmod: (args, env) => spawnCmod(claude, args, session, env),
|
|
1156
|
+
isInstalledCopy: runtime.isInstalledCopy,
|
|
1136
1157
|
watches,
|
|
1137
1158
|
onRedraw(listener) {
|
|
1138
1159
|
redraws.add(listener)
|
|
@@ -1149,6 +1170,7 @@ async function createMod<State extends object, Declared extends Options>(definit
|
|
|
1149
1170
|
return { remove: () => void names.delete(key) }
|
|
1150
1171
|
}
|
|
1151
1172
|
const removeUndeclaredServices = async () => {
|
|
1173
|
+
if (!(await runtime.isInstalledCopy())) return
|
|
1152
1174
|
for (const { name } of await claude.fs.list(serviceFolder(runtime.store, definition.name)).catch(ifMissing([]))) {
|
|
1153
1175
|
const program = name.endsWith('.json') ? name.slice(0, -'.json'.length) : undefined
|
|
1154
1176
|
if (program !== undefined && !names.has(`service:${program}`)) await runCmod(claude, ['program', definition.name, '--remove-service', '--', program], session)
|
package/src/runtime/programs.ts
CHANGED
|
@@ -4,7 +4,7 @@ import { ifMissing } from '../utils/paths.js'
|
|
|
4
4
|
import { formatExit } from '../utils/text.js'
|
|
5
5
|
import type { Claude } from './claude.js'
|
|
6
6
|
|
|
7
|
-
export type Programs = { readonly claude: Claude; refresh(): Promise<void> }
|
|
7
|
+
export type Programs = { readonly claude: Claude; refresh(): Promise<void>; waitFor(download: Promise<void>): void }
|
|
8
8
|
|
|
9
9
|
export function lastLineOf(text: string): string | undefined {
|
|
10
10
|
const trimmed = text.trim()
|
|
@@ -64,21 +64,58 @@ export async function runCmod(claude: Claude, args: readonly string[], session:
|
|
|
64
64
|
return lines.join('\n')
|
|
65
65
|
}
|
|
66
66
|
|
|
67
|
+
function spawnedAfter(ready: Promise<void>, spawn: () => HookStream<ProcessSpawnChunk, ProcessSpawnResult>): HookStream<ProcessSpawnChunk, ProcessSpawnResult> {
|
|
68
|
+
let resolve: (ended: ProcessSpawnResult) => void = () => undefined
|
|
69
|
+
let reject: (error: Error) => void = () => undefined
|
|
70
|
+
const result = new Promise<ProcessSpawnResult>((resolved, rejected) => {
|
|
71
|
+
resolve = resolved
|
|
72
|
+
reject = rejected
|
|
73
|
+
})
|
|
74
|
+
result.catch(() => undefined)
|
|
75
|
+
const stream = (async function* () {
|
|
76
|
+
try {
|
|
77
|
+
await ready
|
|
78
|
+
const ended = yield* spawn()
|
|
79
|
+
resolve(ended)
|
|
80
|
+
return ended
|
|
81
|
+
} finally {
|
|
82
|
+
reject(new Error('cmod: the stream closed before the program ended.'))
|
|
83
|
+
}
|
|
84
|
+
})()
|
|
85
|
+
return Object.assign(stream, { result })
|
|
86
|
+
}
|
|
87
|
+
|
|
67
88
|
export function locatingPrograms(claude: Claude): Programs {
|
|
68
89
|
let folder: string | undefined
|
|
69
90
|
let names: ReadonlySet<string> = new Set()
|
|
91
|
+
let downloading: Promise<void> | undefined
|
|
70
92
|
const located = (argv: readonly string[]): readonly string[] => {
|
|
71
93
|
const [name, ...rest] = argv
|
|
72
94
|
return folder !== undefined && name !== undefined && (name === 'cmod' || names.has(name)) ? [`${folder}/${name}`, ...rest] : argv
|
|
73
95
|
}
|
|
96
|
+
const waiting = (argv: readonly string[]) => (argv[0] === 'cmod' ? downloading : undefined)
|
|
74
97
|
return {
|
|
75
98
|
claude: {
|
|
76
99
|
...claude,
|
|
77
100
|
process: {
|
|
78
|
-
run: (argv, init) =>
|
|
79
|
-
|
|
101
|
+
run: (argv, init) => {
|
|
102
|
+
const ready = waiting(argv)
|
|
103
|
+
return ready === undefined ? claude.process.run(located(argv), init) : ready.then(() => claude.process.run(located(argv), init))
|
|
104
|
+
},
|
|
105
|
+
spawn: (request) => {
|
|
106
|
+
const ready = waiting(request.argv)
|
|
107
|
+
const spawn = () => claude.process.spawn({ ...request, argv: located(request.argv) })
|
|
108
|
+
return ready === undefined ? spawn() : spawnedAfter(ready, spawn)
|
|
109
|
+
},
|
|
80
110
|
},
|
|
81
111
|
},
|
|
112
|
+
waitFor(download) {
|
|
113
|
+
const current = download.then(() => {
|
|
114
|
+
if (downloading === current) downloading = undefined
|
|
115
|
+
})
|
|
116
|
+
current.catch(() => undefined)
|
|
117
|
+
downloading = current
|
|
118
|
+
},
|
|
82
119
|
async refresh() {
|
|
83
120
|
const [home, dataHome] = await Promise.all([claude.env.home(), claude.env.dataHome()])
|
|
84
121
|
const programs = `${storeFolder({ HOME: home, XDG_DATA_HOME: dataHome })}/programs`
|
package/src/runtime/sessions.ts
CHANGED
|
@@ -14,7 +14,7 @@ import { beforeEvents, processEvents, Session, sessionEvents, type BeforeEvent,
|
|
|
14
14
|
import { matches, sentMatcher, type Matcher, type SentMatcher } from '../utils/matcher.js'
|
|
15
15
|
import { beforeAnswerKeys, foldAnswers, foldBefore, methodOf, takenAnswer, type Answers, type Place } from './before.js'
|
|
16
16
|
import type { Claude } from './claude.js'
|
|
17
|
-
import { cmodPluginName
|
|
17
|
+
import { cmodPluginName } from './dependencies.js'
|
|
18
18
|
import { messageOf } from '../utils/text.js'
|
|
19
19
|
import { listenerOf, PassedTimeout, withinTime, type ListenOptions, type ListenTime } from './deadline.js'
|
|
20
20
|
import { callFiles, type HomeFolders, type HookFields } from './hooks.js'
|
|
@@ -196,7 +196,7 @@ export function createSessionsClient({ name, claude, report, hookOn, routeOn, pe
|
|
|
196
196
|
return tree.then(
|
|
197
197
|
(read) => isInScope(scope, session, change, isUnderIn(read)),
|
|
198
198
|
(error: unknown) => {
|
|
199
|
-
|
|
199
|
+
report(`tasks:${session}`, 'Could not read the tasks it listens under', error)
|
|
200
200
|
return false
|
|
201
201
|
},
|
|
202
202
|
)
|
package/src/runtime/ui.ts
CHANGED
|
@@ -9,7 +9,7 @@ import { componentOf, nameOf, type Kind, type Style, type StyledAt, type StyleIn
|
|
|
9
9
|
import type { Subscription } from '../utils/subscription.js'
|
|
10
10
|
import { messageOf } from '../utils/text.js'
|
|
11
11
|
import type { Claude } from './claude.js'
|
|
12
|
-
import { cmodPluginName
|
|
12
|
+
import { cmodPluginName } from './dependencies.js'
|
|
13
13
|
import type { Router } from './router.js'
|
|
14
14
|
import type { Failure } from './toaster.js'
|
|
15
15
|
|
|
@@ -317,7 +317,7 @@ export function createUi<State extends object>({ name, claude, router, report, a
|
|
|
317
317
|
if (isObject(answer) && name !== cmodPluginName) hear(answer['stylers'], false)
|
|
318
318
|
},
|
|
319
319
|
(error: unknown) => {
|
|
320
|
-
|
|
320
|
+
claude.ui.warn('parts:tell', `${name}: the cmod plugin did not hear about its pages and widgets: ${messageOf(error)}`)
|
|
321
321
|
},
|
|
322
322
|
)
|
|
323
323
|
}
|