@cmodjs/core 4.3.0 → 4.3.1
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/package.json +1 -1
- package/records.d.ts +5 -1
- package/records.d.ts.map +1 -1
- package/records.js +11 -1
- package/runtime/lifecycle.d.ts.map +1 -1
- package/runtime/lifecycle.js +5 -11
- package/src/records.ts +9 -1
- package/src/runtime/lifecycle.ts +8 -9
package/docs/commands.md
CHANGED
|
@@ -233,7 +233,7 @@ Reads every conversation Claude Code saved, as the sessions, contexts, turns, ta
|
|
|
233
233
|
cmod watch
|
|
234
234
|
```
|
|
235
235
|
|
|
236
|
-
Tells every running session once a checkout `cmod link` linked builds after a change. 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 bundle that builds marks `plugins-changed`, so every session reloads its plugins, and shows no toast, because the version stays the same. A bundle that still fails 10 seconds after the last change shows `<mod> does not build` with the error as one toast in every session, and the toast goes once the mod builds. So an agent's half-written file reloads nothing and shows nothing. 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 15 seconds old, so a machine runs one watcher however many sessions it has open.
|
|
236
|
+
Tells every running session once a checkout `cmod link` linked builds after a change. 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 bundle that builds marks `plugins-changed`, so every session reloads its plugins, and shows no toast, because the version stays the same. A bundle that still fails 10 seconds after the last change shows `<mod> does not build` with the error as one toast in every session, 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.
|
|
237
237
|
|
|
238
238
|
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.
|
|
239
239
|
|
package/package.json
CHANGED
package/records.d.ts
CHANGED
|
@@ -58,6 +58,10 @@ export declare function storeFolder(env: Record<string, string | undefined>): st
|
|
|
58
58
|
export declare function recordPath(store: string, name: string): string;
|
|
59
59
|
export declare function programPath(store: string, program: string, version: string): string;
|
|
60
60
|
export declare function isProgramNewer(record: InstallRecord, programModifiedMs: number | undefined): boolean;
|
|
61
|
+
export declare function readCmodVersion(files: {
|
|
62
|
+
list: (folder: string) => Promise<readonly string[]>;
|
|
63
|
+
exists: (path: string) => Promise<boolean>;
|
|
64
|
+
}, store: string): Promise<string | undefined>;
|
|
61
65
|
export declare function dataFolder(store: string, name: string): string;
|
|
62
66
|
export declare function configFolder(env: Record<string, string | undefined>, name: string): string;
|
|
63
67
|
export declare function configFolders(env: Record<string, string | undefined>, name: string, root: string): {
|
|
@@ -99,7 +103,7 @@ export type Preferences = {
|
|
|
99
103
|
};
|
|
100
104
|
export declare function parsePreferences(value: unknown, path: string): Preferences;
|
|
101
105
|
export declare function parseConsent(value: unknown, path: string): Record<string, string[]>;
|
|
102
|
-
export declare const coreVersion = "4.3.
|
|
106
|
+
export declare const coreVersion = "4.3.1";
|
|
103
107
|
export declare function hotkeyCommand(mod: string, hotkey: string): string;
|
|
104
108
|
export declare function hotkeyBindings(mod: string, hotkeys: Hotkeys | undefined): Record<string, string>;
|
|
105
109
|
export declare function boundCombos(keybindings: unknown): Map<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;CACnC,CAAA;AAED,MAAM,MAAM,KAAK,GAAG;IAClB,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,WAAW,CAAC,EAAE,SAAS,MAAM,EAAE,CAAA;CAChC,CAAA;AAED,eAAO,MAAM,eAAe,YAAI,SAAS,EAAE,KAAK,EAAE,OAAO,EAAE,QAAQ,CAAU,CAAA;AAC7E,eAAO,MAAM,eAAe,YAAI,cAAc,EAAE,QAAQ,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,SAAS,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const permissionNames = [...listPermissions, ...flagPermissions];
|
|
6
6
|
const hostName = /^[A-Za-z0-9]([A-Za-z0-9-]*[A-Za-z0-9])?(\.[A-Za-z0-9]([A-Za-z0-9-]*[A-Za-z0-9])?)*$/;
|
|
7
7
|
const programName = /^[A-Za-z0-9][A-Za-z0-9._+-]*$/;
|
|
8
|
+
const releaseVersion = /^\d+\.\d+\.\d+$/;
|
|
8
9
|
const settingPath = /^[A-Za-z][A-Za-z0-9]*(\.[A-Za-z0-9_@-]+)*$/;
|
|
9
10
|
const listItemHint = {
|
|
10
11
|
network: 'a host alone, such as "api.github.com", or a socket path, such as "/var/run/docker.sock"',
|
|
@@ -31,6 +32,15 @@ export function programPath(store, program, version) {
|
|
|
31
32
|
export function isProgramNewer(record, programModifiedMs) {
|
|
32
33
|
return record.program !== null && (programModifiedMs === undefined || programModifiedMs > Date.parse(record.installedAt));
|
|
33
34
|
}
|
|
35
|
+
export async function readCmodVersion(files, store) {
|
|
36
|
+
if (!(await files.exists(`${store}/programs/cmod`)))
|
|
37
|
+
return undefined;
|
|
38
|
+
const newestFirst = (await files.list(`${store}/bin/cmod`)).filter((name) => releaseVersion.test(name)).toSorted((one, other) => (isAtLeast(one, other) ? -1 : 1));
|
|
39
|
+
for (const version of newestFirst)
|
|
40
|
+
if (await files.exists(programPath(store, 'cmod', version)))
|
|
41
|
+
return version;
|
|
42
|
+
return undefined;
|
|
43
|
+
}
|
|
34
44
|
export function dataFolder(store, name) {
|
|
35
45
|
return `${store}/data/${checkedName(name)}`;
|
|
36
46
|
}
|
|
@@ -284,7 +294,7 @@ function readHotkeys(hotkeys) {
|
|
|
284
294
|
throw new Error(`package.json "cmod.hotkeys" is not a map of hotkeys to their title and optional default combo. ${fix}`);
|
|
285
295
|
return { hotkeys: checkHotkeys('package.json "cmod"', hotkeys) };
|
|
286
296
|
}
|
|
287
|
-
export const coreVersion = '4.3.
|
|
297
|
+
export const coreVersion = '4.3.1';
|
|
288
298
|
export function hotkeyCommand(mod, hotkey) {
|
|
289
299
|
return `${mod}--${hotkey}`;
|
|
290
300
|
}
|
|
@@ -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,EAAoB,GAAG,EAAE,aAAa,EAA8G,MAAM,WAAW,CAAA;AACjL,OAAO,KAAK,EAAE,OAAO,EAAgB,MAAM,eAAe,CAAA;AAC1D,OAAO,
|
|
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,EAAoB,GAAG,EAAE,aAAa,EAA8G,MAAM,WAAW,CAAA;AACjL,OAAO,KAAK,EAAE,OAAO,EAAgB,MAAM,eAAe,CAAA;AAC1D,OAAO,EAA6T,KAAK,KAAK,EAAE,MAAM,eAAe,CAAA;AAGrW,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AAOzC,OAAO,EAA6F,KAAK,WAAW,EAAE,MAAM,YAAY,CAAA;AACxI,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAA;AAO7D,OAAO,EAA6B,KAAK,UAAU,EAAE,MAAM,aAAa,CAAA;AAMxE,OAAO,EAA+B,KAAK,UAAU,EAAgB,MAAM,cAAc,CAAA;AAWzF,MAAM,MAAM,MAAM,GAAG;IACnB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IACrB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IACrB,QAAQ,CAAC,OAAO,EAAE,MAAM,GAAG,SAAS,C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CAAA;IAC1H,KAAK,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,GAAG,OAAO,CAAC,OAAO,CAAC,CAAA;CACpF,CAAA;AAuDD,wBAAsB,UAAU,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CA2BhE;AAmCD,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,GAChB,SAAS,CAAC,KAAK,CAAC,CAqkBlB"}
|
package/runtime/lifecycle.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { consentPath, dataFolder, finishStepsMethod, grantFix, coreVersion, isAtLeast, isProgramNewer, marketplaceOf, parseConsent, pendingStepsMethod, parseEvent, permissionWords, programPath, readRecord, readSteps, recordPath, scriptsSha256, storeFolder, updatesToTurnOn } from '../records.js';
|
|
1
|
+
import { consentPath, dataFolder, finishStepsMethod, grantFix, coreVersion, isAtLeast, isProgramNewer, marketplaceOf, parseConsent, pendingStepsMethod, parseEvent, permissionWords, programPath, readCmodVersion, readRecord, readSteps, recordPath, scriptsSha256, storeFolder, updatesToTurnOn } from '../records.js';
|
|
2
2
|
import { homePrefix, ifMissing, relativePath } from '../utils/paths.js';
|
|
3
3
|
import { firstLine, formatExit, messageOf } from '../utils/text.js';
|
|
4
4
|
import { beforeDeadline } from './deadline.js';
|
|
@@ -97,17 +97,11 @@ async function readJson(read, path) {
|
|
|
97
97
|
}
|
|
98
98
|
async function cmodVersion(claude) {
|
|
99
99
|
const store = storeFolder({ HOME: await claude.env.home(), XDG_DATA_HOME: await claude.env.dataHome() });
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
const newestFirst = versions.toSorted((one, other) => (isAtLeast(one, other) ? -1 : 1));
|
|
105
|
-
for (const version of newestFirst)
|
|
106
|
-
if (await exists(`${store}/bin/cmod/${version}/cmod`))
|
|
107
|
-
return version;
|
|
108
|
-
return undefined;
|
|
100
|
+
return readCmodVersion({
|
|
101
|
+
list: async (folder) => (await claude.fs.list(folder).catch(ifMissing([]))).map((entry) => entry.name),
|
|
102
|
+
exists: async (path) => (await claude.fs.stat(path).catch(ifMissing(undefined))) !== undefined,
|
|
103
|
+
}, store);
|
|
109
104
|
}
|
|
110
|
-
const releaseVersion = /^\d+\.\d+\.\d+$/;
|
|
111
105
|
export function createLifecycle(definition, permissionRoutes = () => undefined, options = {}, asksPerson = true) {
|
|
112
106
|
let router = createRouter();
|
|
113
107
|
let phase = 'starting';
|
package/src/records.ts
CHANGED
|
@@ -29,6 +29,7 @@ export type FlagPermission = (typeof flagPermissions)[number]
|
|
|
29
29
|
const permissionNames: readonly string[] = [...listPermissions, ...flagPermissions]
|
|
30
30
|
const hostName = /^[A-Za-z0-9]([A-Za-z0-9-]*[A-Za-z0-9])?(\.[A-Za-z0-9]([A-Za-z0-9-]*[A-Za-z0-9])?)*$/
|
|
31
31
|
const programName = /^[A-Za-z0-9][A-Za-z0-9._+-]*$/
|
|
32
|
+
const releaseVersion = /^\d+\.\d+\.\d+$/
|
|
32
33
|
const settingPath = /^[A-Za-z][A-Za-z0-9]*(\.[A-Za-z0-9_@-]+)*$/
|
|
33
34
|
const listItemHint: Readonly<Record<ListPermission, string>> = {
|
|
34
35
|
network: 'a host alone, such as "api.github.com", or a socket path, such as "/var/run/docker.sock"',
|
|
@@ -70,6 +71,13 @@ export function isProgramNewer(record: InstallRecord, programModifiedMs: number
|
|
|
70
71
|
return record.program !== null && (programModifiedMs === undefined || programModifiedMs > Date.parse(record.installedAt))
|
|
71
72
|
}
|
|
72
73
|
|
|
74
|
+
export async function readCmodVersion(files: { list: (folder: string) => Promise<readonly string[]>; exists: (path: string) => Promise<boolean> }, store: string): Promise<string | undefined> {
|
|
75
|
+
if (!(await files.exists(`${store}/programs/cmod`))) return undefined
|
|
76
|
+
const newestFirst = (await files.list(`${store}/bin/cmod`)).filter((name) => releaseVersion.test(name)).toSorted((one, other) => (isAtLeast(one, other) ? -1 : 1))
|
|
77
|
+
for (const version of newestFirst) if (await files.exists(programPath(store, 'cmod', version))) return version
|
|
78
|
+
return undefined
|
|
79
|
+
}
|
|
80
|
+
|
|
73
81
|
export function dataFolder(store: string, name: string): string {
|
|
74
82
|
return `${store}/data/${checkedName(name)}`
|
|
75
83
|
}
|
|
@@ -331,7 +339,7 @@ function readHotkeys(hotkeys: unknown): Steps {
|
|
|
331
339
|
return { hotkeys: checkHotkeys('package.json "cmod"', hotkeys as Record<string, HotkeyInit>) }
|
|
332
340
|
}
|
|
333
341
|
|
|
334
|
-
export const coreVersion = '4.3.
|
|
342
|
+
export const coreVersion = '4.3.1'
|
|
335
343
|
|
|
336
344
|
export function hotkeyCommand(mod: string, hotkey: string): string {
|
|
337
345
|
return `${mod}--${hotkey}`
|
package/src/runtime/lifecycle.ts
CHANGED
|
@@ -3,7 +3,7 @@ import type { Step } from '../installer.js'
|
|
|
3
3
|
|
|
4
4
|
import type { Allowed, Imports, Mod, ModDefinition, Reservation, SettingsFile, SettingsFileChange, SettingsFileChangeListener, Subscription, Timer as ModTimer } from '../mod.js'
|
|
5
5
|
import type { Options, OptionValues } from '../options.js'
|
|
6
|
-
import { consentPath, dataFolder, finishStepsMethod, grantFix, coreVersion, isAtLeast, isProgramNewer, marketplaceOf, parseConsent, pendingStepsMethod, parseEvent, permissionWords, programPath, readRecord, readSteps, recordPath, scriptsSha256, storeFolder, updatesToTurnOn, type ReadFile, type RunnerEvent, type Steps } from '../records.js'
|
|
6
|
+
import { consentPath, dataFolder, finishStepsMethod, grantFix, coreVersion, isAtLeast, isProgramNewer, marketplaceOf, parseConsent, pendingStepsMethod, parseEvent, permissionWords, programPath, readCmodVersion, readRecord, readSteps, recordPath, scriptsSha256, storeFolder, updatesToTurnOn, type ReadFile, type RunnerEvent, type Steps } from '../records.js'
|
|
7
7
|
import { homePrefix, ifMissing, relativePath } from '../utils/paths.js'
|
|
8
8
|
import { firstLine, formatExit, messageOf } from '../utils/text.js'
|
|
9
9
|
import type { Claude } from './claude.js'
|
|
@@ -168,16 +168,15 @@ async function readJson(read: ReadFile, path: string): Promise<unknown> {
|
|
|
168
168
|
|
|
169
169
|
async function cmodVersion(claude: Claude): Promise<string | undefined> {
|
|
170
170
|
const store = storeFolder({ HOME: await claude.env.home(), XDG_DATA_HOME: await claude.env.dataHome() })
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
171
|
+
return readCmodVersion(
|
|
172
|
+
{
|
|
173
|
+
list: async (folder) => (await claude.fs.list(folder).catch(ifMissing([]))).map((entry) => entry.name),
|
|
174
|
+
exists: async (path) => (await claude.fs.stat(path).catch(ifMissing(undefined))) !== undefined,
|
|
175
|
+
},
|
|
176
|
+
store,
|
|
177
|
+
)
|
|
177
178
|
}
|
|
178
179
|
|
|
179
|
-
const releaseVersion = /^\d+\.\d+\.\d+$/
|
|
180
|
-
|
|
181
180
|
export function createLifecycle<State extends object, Declared extends Options = Options>(
|
|
182
181
|
definition: ModDefinition<State, string, Declared>,
|
|
183
182
|
permissionRoutes: () => PermissionRoutes | undefined = () => undefined,
|