@cmodjs/core 3.0.0 → 3.1.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/mod.md +1 -1
- package/docs/permissions.md +3 -1
- package/package.json +1 -1
- package/records.d.ts +2 -1
- package/records.d.ts.map +1 -1
- package/records.js +4 -1
- package/runtime/permission-check.d.ts.map +1 -1
- package/runtime/permission-check.js +12 -4
- package/src/records.ts +5 -1
- package/src/runtime/permission-check.ts +11 -3
package/docs/commands.md
CHANGED
|
@@ -93,7 +93,7 @@ cmod publish [path] [--dry-run]
|
|
|
93
93
|
Releases the mod at `path` (default: the current folder) at the version in its `plugin.json`. It refuses a `plugin.json` whose `userConfig` differs from the options `defineMod` declares, and says to run `cmod check` and commit `.claude-plugin/plugin.json`.
|
|
94
94
|
|
|
95
95
|
1. Builds the release from the committed files, leaving out `cli/`, `.github/`, and `.claude/`. A `"files"` list in `package.json` limits the release to the paths it lists, 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 2 needs. List every folder the hooks module imports from, such as `"files": ["hooks", "src", "skills"]`, because the bundle in step 2 is built from the release.
|
|
96
|
-
2. 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.
|
|
96
|
+
2. 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".permissions`, the bundle leaves out the code that allows and asks on Claude Code's permission check ([permissions.md](permissions.md)).
|
|
97
97
|
3. Checks the release with `claude plugin validate --strict`, and stops with the validator's message when it fails.
|
|
98
98
|
4. Commits the release as the `release` branch, and builds the release archive from that commit.
|
|
99
99
|
5. Builds the program `cli/` declares, and writes `SHA256SUMS` for every file of the release.
|
package/docs/mod.md
CHANGED
|
@@ -133,7 +133,7 @@ export function register(addHook: On, options: PluginOptions): void {
|
|
|
133
133
|
}
|
|
134
134
|
```
|
|
135
135
|
|
|
136
|
-
A mod that
|
|
136
|
+
A mod that allows or asks, with a `before` method or an `ask` rule of the `permissions` job, also declares `"approve": true` in its `package.json` `"cmod".permissions`, so the person grants it at install. `cmod check` adds the line when it is missing, and without the grant cmod drops every allow or ask the mod answers, so Claude Code decides those calls itself. A mod that only refuses needs no `approve`, and its bundle holds no code that allows, so Anthropic's plugin directory can list it ([permissions.md](permissions.md)). A mod without `registerPermissionCheck` has no part in Claude Code's permission check, so the plugin directory reads it as one that never answers a permission. Without it, each of those methods and `mod.use(permissions(…))` throws `<mod>: <method> hears Claude Code's permission check, so hooks/register.ts must call registerPermissionCheck(addHook) after registerMod.` where it is called, so a mod that calls one in `setup` does not start. `cmod check` fails a mod whose `src/` uses one while `register.ts` does not call `registerPermissionCheck`.
|
|
137
137
|
|
|
138
138
|
Where an organization manages Claude Code, Claude Code passes a mod the person installed over on its classic hooks, the notes it adds to a prompt, its Skill and instruction-file text, and compactions, and runs those only for a plugin the organization lists in managed settings. There, the `on` and `before` methods built on them hear nothing until the organization lists the mod and the cmod plugin. `claude plugin validate` names each such hook.
|
|
139
139
|
|
package/docs/permissions.md
CHANGED
|
@@ -29,7 +29,9 @@ They sit in the `package.json` `cmod` key, beside `install` and `keys`, because
|
|
|
29
29
|
|
|
30
30
|
Reading files, drawing panes and renders, toasts, slash commands, tools of the mod's own, listeners on the mod's own session, and a `refuse` answer need no permission. Writing a Claude Code settings file with `fs.write` is refused with every permission, and names the `settings` call to use instead ([mod.md](mod.md#settings-claude-code-s-settings-files)).
|
|
31
31
|
|
|
32
|
-
`cmod check` adds `"approve": true` to `package.json` when the mod
|
|
32
|
+
`cmod check` adds `"approve": true` to `package.json` when the mod allows or asks, with a `beforePermissionCheck` or `beforePermissionRequest` answer or an `ask` rule of the `permissions` job, and the line is missing, and says so. A mod that only refuses, or only listens with `onPermissionCheck` or `onPermissionRequest`, needs no `approve`.
|
|
33
|
+
|
|
34
|
+
Anthropic's plugin directory does not list a mod that can approve Claude's tool calls. So `cmod publish` leaves the code that allows and asks out of the bundle of a mod that does not declare `"approve": true`, and that mod can be listed. A mod that declares it installs through cmod and the [Mods page](https://claudemodmanager.com/mods), and `cmod check` says the directory does not list it.
|
|
33
35
|
|
|
34
36
|
## What the person sees
|
|
35
37
|
|
package/package.json
CHANGED
package/records.d.ts
CHANGED
|
@@ -74,9 +74,10 @@ export declare function marketplaceOf(root: string, name: string): string | unde
|
|
|
74
74
|
export declare function updatesToTurnOn(marketplace: string | undefined, settings: unknown, known: unknown): string | undefined;
|
|
75
75
|
export declare function consentPath(store: string): string;
|
|
76
76
|
export declare function parseConsent(value: unknown, path: string): Record<string, string[]>;
|
|
77
|
-
export declare const coreVersion = "3.
|
|
77
|
+
export declare const coreVersion = "3.1.0";
|
|
78
78
|
export declare function oldestCmodFor(steps: Steps): string;
|
|
79
79
|
export declare function keyWords(keys: Readonly<Record<string, string>> | undefined): string;
|
|
80
|
+
export declare function bundleDefines(permissions: readonly string[]): Record<string, string>;
|
|
80
81
|
export declare function scriptPaths(command: string): string[];
|
|
81
82
|
export declare function scriptsSha256(steps: Steps, files: {
|
|
82
83
|
read: ReadFile;
|
package/records.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"records.d.ts","sourceRoot":"","sources":["src/records.ts"],"names":[],"mappings":"AAEA,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;IAC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AMnF;AAcD,eAAO,MAAM,WAAW,UAAU,CAAA;AAElC,wBAAgB,aAAa,CAAC,KAAK,EAAE,KAAK,GAAG,MAAM,CAKlD;AAED,wBAAgB,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,GAAG,SAAS,GAAG,MAAM,CAEnF;AAYD,wBAAgB,aAAa,CAAC,WAAW,EAAE,SAAS,MAAM,EAAE,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAEpF;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
|
@@ -227,7 +227,7 @@ function readKeys(keys) {
|
|
|
227
227
|
}
|
|
228
228
|
return { keys: commands };
|
|
229
229
|
}
|
|
230
|
-
export const coreVersion = '3.
|
|
230
|
+
export const coreVersion = '3.1.0';
|
|
231
231
|
export function oldestCmodFor(steps) {
|
|
232
232
|
if (steps.permissions?.some((item) => item.startsWith('config:')) === true)
|
|
233
233
|
return '1.6.0';
|
|
@@ -253,6 +253,9 @@ function readCommand(steps, key) {
|
|
|
253
253
|
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 asks consent for the whole folder of each script.`);
|
|
254
254
|
return { [key]: command };
|
|
255
255
|
}
|
|
256
|
+
export function bundleDefines(permissions) {
|
|
257
|
+
return permissions.includes('approve') ? {} : { 'globalThis.cmodWithoutApprove': 'true' };
|
|
258
|
+
}
|
|
256
259
|
export function scriptPaths(command) {
|
|
257
260
|
const words = command
|
|
258
261
|
.split(/[\s;&|()<>]+/)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"permission-check.d.ts","sourceRoot":"","sources":["../src/runtime/permission-check.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,WAAW,CAAA;AAC3C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAA;AAC5C,OAAO,EAAuC,KAAK,MAAM,EAAE,KAAK,OAAO,EAAkB,MAAM,eAAe,CAAA;AAE9G,MAAM,MAAM,aAAa,GAAG;IAC1B,QAAQ,CAAC,KAAK,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,UAAU,KAAK,OAAO,CAAC,UAAU,GAAG,SAAS,CAAC,CAAA;IACxF,QAAQ,CAAC,UAAU,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,UAAU,EAAE,KAAK,EAAE,KAAK,KAAK;QAAE,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;KAAE,GAAG,SAAS,CAAA;IACnH,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;IACvB,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAA;IACzB,QAAQ,CAAC,OAAO,EAAE,MAAM;QAAE,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAA;KAAE,CAAA;CACtE,CAAA;AAED,MAAM,MAAM,gBAAgB,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,aAAa,KAAK,UAAU,CAAA;
|
|
1
|
+
{"version":3,"file":"permission-check.d.ts","sourceRoot":"","sources":["../src/runtime/permission-check.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,WAAW,CAAA;AAC3C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAA;AAC5C,OAAO,EAAuC,KAAK,MAAM,EAAE,KAAK,OAAO,EAAkB,MAAM,eAAe,CAAA;AAE9G,MAAM,MAAM,aAAa,GAAG;IAC1B,QAAQ,CAAC,KAAK,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,UAAU,KAAK,OAAO,CAAC,UAAU,GAAG,SAAS,CAAC,CAAA;IACxF,QAAQ,CAAC,UAAU,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,UAAU,EAAE,KAAK,EAAE,KAAK,KAAK;QAAE,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;KAAE,GAAG,SAAS,CAAA;IACnH,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;IACvB,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAA;IACzB,QAAQ,CAAC,OAAO,EAAE,MAAM;QAAE,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAA;KAAE,CAAA;CACtE,CAAA;AAED,MAAM,MAAM,gBAAgB,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,aAAa,KAAK,UAAU,CAAA;AAQjF,eAAO,MAAM,gBAAgB,EAAE,gBAwD9B,CAAA"}
|
|
@@ -23,9 +23,13 @@ export const permissionRoutes = (method, { raise, refusalFor, hookOn, routeOn, c
|
|
|
23
23
|
return below;
|
|
24
24
|
if (typeof answer['refuse'] === 'string')
|
|
25
25
|
return { decision: 'deny', reason: answer['refuse'] };
|
|
26
|
-
if (
|
|
27
|
-
|
|
28
|
-
|
|
26
|
+
if (!globalThis.cmodWithoutApprove) {
|
|
27
|
+
if (typeof answer['ask'] === 'string')
|
|
28
|
+
return { decision: 'ask', reason: answer['ask'] };
|
|
29
|
+
if (answer['allow'] === true)
|
|
30
|
+
return { decision: 'allow' };
|
|
31
|
+
}
|
|
32
|
+
return below;
|
|
29
33
|
}, isBefore ? failed : undefined);
|
|
30
34
|
}
|
|
31
35
|
const refused = (refuse, interrupt) => ({ decision: defined({ behavior: 'deny', message: refuse, interrupt }) });
|
|
@@ -40,7 +44,11 @@ export const permissionRoutes = (method, { raise, refusalFor, hookOn, routeOn, c
|
|
|
40
44
|
return undefined;
|
|
41
45
|
if (typeof answer['refuse'] === 'string')
|
|
42
46
|
return refused(answer['refuse'], answer['interrupt']);
|
|
43
|
-
|
|
47
|
+
if (!globalThis.cmodWithoutApprove) {
|
|
48
|
+
if (answer['allow'] === true)
|
|
49
|
+
return { decision: defined({ behavior: 'allow', updatedInput: answer['input'], updatedPermissions: answer['updates'] }) };
|
|
50
|
+
}
|
|
51
|
+
return undefined;
|
|
44
52
|
}, isBefore
|
|
45
53
|
? (input, error) => {
|
|
46
54
|
const refusal = refusalFor(method, processPayloadOf('PermissionRequest', input), error);
|
package/src/records.ts
CHANGED
|
@@ -259,7 +259,7 @@ function readKeys(keys: unknown): Steps {
|
|
|
259
259
|
return { keys: commands }
|
|
260
260
|
}
|
|
261
261
|
|
|
262
|
-
export const coreVersion = '3.
|
|
262
|
+
export const coreVersion = '3.1.0'
|
|
263
263
|
|
|
264
264
|
export function oldestCmodFor(steps: Steps): string {
|
|
265
265
|
if (steps.permissions?.some((item) => item.startsWith('config:')) === true) return '1.6.0'
|
|
@@ -282,6 +282,10 @@ function readCommand(steps: Record<string, unknown>, key: 'install' | 'uninstall
|
|
|
282
282
|
return { [key]: command }
|
|
283
283
|
}
|
|
284
284
|
|
|
285
|
+
export function bundleDefines(permissions: readonly string[]): Record<string, string> {
|
|
286
|
+
return permissions.includes('approve') ? {} : { 'globalThis.cmodWithoutApprove': 'true' }
|
|
287
|
+
}
|
|
288
|
+
|
|
285
289
|
export function scriptPaths(command: string): string[] {
|
|
286
290
|
const words = command
|
|
287
291
|
.split(/[\s;&|()<>]+/)
|
|
@@ -16,6 +16,8 @@ type Verdict = { readonly decision: 'allow' | 'ask' | 'deny'; readonly reason?:
|
|
|
16
16
|
|
|
17
17
|
const verdictName = (decision: Verdict['decision']) => (decision === 'deny' ? 'refuse' : decision)
|
|
18
18
|
|
|
19
|
+
type BuildFlags = { readonly cmodWithoutApprove?: true }
|
|
20
|
+
|
|
19
21
|
export const permissionRoutes: PermissionRoutes = (method, { raise, refusalFor, hookOn, routeOn, current }) => {
|
|
20
22
|
const isBefore = method.startsWith('before')
|
|
21
23
|
if (method.endsWith('PermissionCheck')) {
|
|
@@ -39,8 +41,11 @@ export const permissionRoutes: PermissionRoutes = (method, { raise, refusalFor,
|
|
|
39
41
|
const answer = await raise(method, payload)
|
|
40
42
|
if (answer === undefined || below.decision === 'deny') return below
|
|
41
43
|
if (typeof answer['refuse'] === 'string') return { decision: 'deny', reason: answer['refuse'] }
|
|
42
|
-
if (
|
|
43
|
-
|
|
44
|
+
if (!(globalThis as BuildFlags).cmodWithoutApprove) {
|
|
45
|
+
if (typeof answer['ask'] === 'string') return { decision: 'ask', reason: answer['ask'] }
|
|
46
|
+
if (answer['allow'] === true) return { decision: 'allow' }
|
|
47
|
+
}
|
|
48
|
+
return below
|
|
44
49
|
},
|
|
45
50
|
isBefore ? failed : undefined,
|
|
46
51
|
)
|
|
@@ -57,7 +62,10 @@ export const permissionRoutes: PermissionRoutes = (method, { raise, refusalFor,
|
|
|
57
62
|
const answer = await raise(method, payload)
|
|
58
63
|
if (answer === undefined) return undefined
|
|
59
64
|
if (typeof answer['refuse'] === 'string') return refused(answer['refuse'], answer['interrupt'])
|
|
60
|
-
|
|
65
|
+
if (!(globalThis as BuildFlags).cmodWithoutApprove) {
|
|
66
|
+
if (answer['allow'] === true) return { decision: defined({ behavior: 'allow', updatedInput: answer['input'], updatedPermissions: answer['updates'] }) }
|
|
67
|
+
}
|
|
68
|
+
return undefined
|
|
61
69
|
},
|
|
62
70
|
isBefore
|
|
63
71
|
? (input, error) => {
|