@jianxx/dsh-cc-plugin-loader 0.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/LICENSE +201 -0
- package/README.i18n.yaml +6 -0
- package/README.md +45 -0
- package/README.zh.md +45 -0
- package/lib/agents.d.ts +109 -0
- package/lib/agents.d.ts.map +1 -0
- package/lib/agents.js +147 -0
- package/lib/agents.js.map +1 -0
- package/lib/commands.d.ts +56 -0
- package/lib/commands.d.ts.map +1 -0
- package/lib/commands.js +66 -0
- package/lib/commands.js.map +1 -0
- package/lib/hooks.d.ts +44 -0
- package/lib/hooks.d.ts.map +1 -0
- package/lib/hooks.js +89 -0
- package/lib/hooks.js.map +1 -0
- package/lib/index.d.ts +73 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +92 -0
- package/lib/index.js.map +1 -0
- package/lib/manifest.d.ts +23 -0
- package/lib/manifest.d.ts.map +1 -0
- package/lib/manifest.js +117 -0
- package/lib/manifest.js.map +1 -0
- package/lib/mcp.d.ts +41 -0
- package/lib/mcp.d.ts.map +1 -0
- package/lib/mcp.js +64 -0
- package/lib/mcp.js.map +1 -0
- package/lib/seams.d.ts +59 -0
- package/lib/seams.d.ts.map +1 -0
- package/lib/seams.js +56 -0
- package/lib/seams.js.map +1 -0
- package/lib/settings.d.ts +41 -0
- package/lib/settings.d.ts.map +1 -0
- package/lib/settings.js +44 -0
- package/lib/settings.js.map +1 -0
- package/lib/skill-semantics.d.ts +92 -0
- package/lib/skill-semantics.d.ts.map +1 -0
- package/lib/skill-semantics.js +98 -0
- package/lib/skill-semantics.js.map +1 -0
- package/lib/skills.d.ts +49 -0
- package/lib/skills.d.ts.map +1 -0
- package/lib/skills.js +117 -0
- package/lib/skills.js.map +1 -0
- package/lib/types.d.ts +89 -0
- package/lib/types.d.ts.map +1 -0
- package/lib/types.js +12 -0
- package/lib/types.js.map +1 -0
- package/package.json +57 -0
package/lib/mcp.js
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Mount a Claude Code plugin's MCP servers.
|
|
3
|
+
*
|
|
4
|
+
* Collects server definitions from the manifest inline `mcpServers` record or
|
|
5
|
+
* an `.mcp.json` file, then registers each through the optional `mcp` guest
|
|
6
|
+
* seam. Tool naming (`mcp__<server>__<tool>`) is the seam's responsibility.
|
|
7
|
+
* When the seam is absent the component is reported skipped, never failed.
|
|
8
|
+
*
|
|
9
|
+
* @module
|
|
10
|
+
*/
|
|
11
|
+
import { readFileSync } from 'node:fs';
|
|
12
|
+
import { resolve } from 'node:path';
|
|
13
|
+
import { ComponentTally } from "./seams.js";
|
|
14
|
+
/**
|
|
15
|
+
* Collect and register a plugin's MCP servers through the optional seam.
|
|
16
|
+
* @param options - plugin root, manifest, and the mcp seam.
|
|
17
|
+
* @returns mounted disposers and per-component counts.
|
|
18
|
+
*/
|
|
19
|
+
export function mountMcpServers(options) {
|
|
20
|
+
const tally = new ComponentTally('mcpServers');
|
|
21
|
+
const disposers = [];
|
|
22
|
+
if (options.mcp === undefined) {
|
|
23
|
+
tally.addSkipped('mcp seam "mcp" is not mounted');
|
|
24
|
+
return { disposers, tally };
|
|
25
|
+
}
|
|
26
|
+
const servers = collectServers(options.pluginRoot, options.manifest);
|
|
27
|
+
const entries = Object.entries(servers);
|
|
28
|
+
if (entries.length === 0) {
|
|
29
|
+
tally.addSkipped('plugin declares no MCP servers');
|
|
30
|
+
return { disposers, tally };
|
|
31
|
+
}
|
|
32
|
+
for (const [name, config] of entries) {
|
|
33
|
+
disposers.push(options.mcp.registerServer(name, config));
|
|
34
|
+
tally.addLoaded();
|
|
35
|
+
}
|
|
36
|
+
return { disposers, tally };
|
|
37
|
+
}
|
|
38
|
+
/** Combine inline and file-backed MCP server definitions. */
|
|
39
|
+
function collectServers(pluginRoot, manifest) {
|
|
40
|
+
const servers = {};
|
|
41
|
+
if (manifest.mcpServersPath !== undefined) {
|
|
42
|
+
const path = resolve(pluginRoot, manifest.mcpServersPath);
|
|
43
|
+
Object.assign(servers, readMcpJson(path));
|
|
44
|
+
}
|
|
45
|
+
for (const [name, config] of Object.entries(manifest.mcpServers)) {
|
|
46
|
+
servers[name] = config;
|
|
47
|
+
}
|
|
48
|
+
return servers;
|
|
49
|
+
}
|
|
50
|
+
/** Read an `.mcp.json` file's `mcpServers` key (absent/invalid yields none). */
|
|
51
|
+
function readMcpJson(path) {
|
|
52
|
+
try {
|
|
53
|
+
const parsed = JSON.parse(readFileSync(path, 'utf8'));
|
|
54
|
+
const servers = parsed['mcpServers'];
|
|
55
|
+
if (typeof servers === 'object' && servers !== null && !Array.isArray(servers)) {
|
|
56
|
+
return servers;
|
|
57
|
+
}
|
|
58
|
+
return {};
|
|
59
|
+
}
|
|
60
|
+
catch {
|
|
61
|
+
return {};
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
//# sourceMappingURL=mcp.js.map
|
package/lib/mcp.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mcp.js","sourceRoot":"","sources":["../src/mcp.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAA;AACtC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAEnC,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAA;AAuB3C;;;;GAIG;AACH,MAAM,UAAU,eAAe,CAAC,OAA+B;IAC7D,MAAM,KAAK,GAAG,IAAI,cAAc,CAAC,YAAY,CAAC,CAAA;IAC9C,MAAM,SAAS,GAAmB,EAAE,CAAA;IACpC,IAAI,OAAO,CAAC,GAAG,KAAK,SAAS,EAAE,CAAC;QAC9B,KAAK,CAAC,UAAU,CAAC,+BAA+B,CAAC,CAAA;QACjD,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,CAAA;IAC7B,CAAC;IACD,MAAM,OAAO,GAAG,cAAc,CAAC,OAAO,CAAC,UAAU,EAAE,OAAO,CAAC,QAAQ,CAAC,CAAA;IACpE,MAAM,OAAO,GAAG,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,CAAA;IACvC,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACzB,KAAK,CAAC,UAAU,CAAC,gCAAgC,CAAC,CAAA;QAClD,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,CAAA;IAC7B,CAAC;IACD,KAAK,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC,IAAI,OAAO,EAAE,CAAC;QACrC,SAAS,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,cAAc,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC,CAAA;QACxD,KAAK,CAAC,SAAS,EAAE,CAAA;IACnB,CAAC;IACD,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,CAAA;AAC7B,CAAC;AAED,6DAA6D;AAC7D,SAAS,cAAc,CAAC,UAAkB,EAAE,QAA0B;IACpE,MAAM,OAAO,GAA4C,EAAE,CAAA;IAC3D,IAAI,QAAQ,CAAC,cAAc,KAAK,SAAS,EAAE,CAAC;QAC1C,MAAM,IAAI,GAAG,OAAO,CAAC,UAAU,EAAE,QAAQ,CAAC,cAAc,CAAC,CAAA;QACzD,MAAM,CAAC,MAAM,CAAC,OAAO,EAAE,WAAW,CAAC,IAAI,CAAC,CAAC,CAAA;IAC3C,CAAC;IACD,KAAK,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAC,EAAE,CAAC;QACjE,OAAO,CAAC,IAAI,CAAC,GAAG,MAAiC,CAAA;IACnD,CAAC;IACD,OAAO,OAAO,CAAA;AAChB,CAAC;AAED,gFAAgF;AAChF,SAAS,WAAW,CAAC,IAAY;IAC/B,IAAI,CAAC;QACH,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,IAAI,EAAE,MAAM,CAAC,CAA4B,CAAA;QAChF,MAAM,OAAO,GAAG,MAAM,CAAC,YAAY,CAAC,CAAA;QACpC,IAAI,OAAO,OAAO,KAAK,QAAQ,IAAI,OAAO,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC;YAC/E,OAAO,OAAkD,CAAA;QAC3D,CAAC;QACD,OAAO,EAAE,CAAA;IACX,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,EAAE,CAAA;IACX,CAAC;AACH,CAAC"}
|
package/lib/seams.d.ts
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Optional host seams a CC plugin loader mounts onto, plus the structural
|
|
3
|
+
* report accumulator.
|
|
4
|
+
*
|
|
5
|
+
* The loader is deliberately peer-style: it consults each component's host
|
|
6
|
+
* seam through `ctx.get(...)` and skips (with a reason) rather than throwing
|
|
7
|
+
* when a seam is absent, so a deployment can mount a plugin without every
|
|
8
|
+
* extension point present. `mcp` and `hooks` have no harness-owned service
|
|
9
|
+
* today; this module declares their guest contract so a host can satisfy it.
|
|
10
|
+
*
|
|
11
|
+
* @module
|
|
12
|
+
*/
|
|
13
|
+
import type { ComponentKind, ComponentResult } from './types.ts';
|
|
14
|
+
/** A guest MCP seam: registers one named server for tool discovery. */
|
|
15
|
+
export interface McpSeam {
|
|
16
|
+
/**
|
|
17
|
+
* Register one MCP server. The server-qualified public tool names
|
|
18
|
+
* (`mcp__<server>__<tool>`) are the seam's naming responsibility.
|
|
19
|
+
* @param name - unique server name.
|
|
20
|
+
* @param config - server transport configuration.
|
|
21
|
+
* @returns the exact disposer that unregisters the server.
|
|
22
|
+
*/
|
|
23
|
+
registerServer(name: string, config: Record<string, unknown>): () => void;
|
|
24
|
+
}
|
|
25
|
+
/** A guest hooks seam: injects a plugin's Claude Code hooks. */
|
|
26
|
+
export interface HooksSeam {
|
|
27
|
+
/**
|
|
28
|
+
* Merge a plugin's translated hooks into the bridge. The value is the
|
|
29
|
+
* canonical `ClaudeCodeHookConfig` shape the bridge consumes.
|
|
30
|
+
* @param pluginName - the plugin owning the hooks, for namespacing.
|
|
31
|
+
* @param config - the parsed per-event `MatcherGroup[]` map.
|
|
32
|
+
* @returns the exact disposer that removes the injected hooks.
|
|
33
|
+
*/
|
|
34
|
+
mergePluginHooks(pluginName: string, config: unknown): () => void;
|
|
35
|
+
}
|
|
36
|
+
/** Probe a guest seam by key, returning `undefined` when the host lacks it. */
|
|
37
|
+
export declare function probe<X>(value: X | undefined): X | undefined;
|
|
38
|
+
/** Accumulates loaded/skipped/failed counts and reasons for one component. */
|
|
39
|
+
export declare class ComponentTally {
|
|
40
|
+
private readonly kind;
|
|
41
|
+
private loaded;
|
|
42
|
+
private skipped;
|
|
43
|
+
private failed;
|
|
44
|
+
private readonly reasons;
|
|
45
|
+
/**
|
|
46
|
+
* Construct a tally for one component kind.
|
|
47
|
+
* @param kind - the component this tally measures.
|
|
48
|
+
*/
|
|
49
|
+
constructor(kind: ComponentKind);
|
|
50
|
+
/** Record one component as mounted. */
|
|
51
|
+
addLoaded(): void;
|
|
52
|
+
/** Record one component as skipped, with the reason. */
|
|
53
|
+
addSkipped(reason: string): void;
|
|
54
|
+
/** Record one component as failed, with the reason. */
|
|
55
|
+
addFailed(reason: string): void;
|
|
56
|
+
/** Build the final per-component result. */
|
|
57
|
+
result(): ComponentResult;
|
|
58
|
+
}
|
|
59
|
+
//# sourceMappingURL=seams.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"seams.d.ts","sourceRoot":"","sources":["../src/seams.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,YAAY,CAAA;AAEhE,uEAAuE;AACvE,MAAM,WAAW,OAAO;IACtB;;;;;;OAMG;IACH,cAAc,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,IAAI,CAAA;CAC1E;AAED,gEAAgE;AAChE,MAAM,WAAW,SAAS;IACxB;;;;;;OAMG;IACH,gBAAgB,CAAC,UAAU,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,GAAG,MAAM,IAAI,CAAA;CAClE;AAED,+EAA+E;AAC/E,wBAAgB,KAAK,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,GAAG,SAAS,GAAG,CAAC,GAAG,SAAS,CAE5D;AAED,8EAA8E;AAC9E,qBAAa,cAAc;IAUb,OAAO,CAAC,QAAQ,CAAC,IAAI;IATjC,OAAO,CAAC,MAAM,CAAI;IAClB,OAAO,CAAC,OAAO,CAAI;IACnB,OAAO,CAAC,MAAM,CAAI;IAClB,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAe;IAEvC;;;OAGG;gBAC0B,IAAI,EAAE,aAAa;IAEhD,uCAAuC;IACvC,SAAS,IAAI,IAAI;IAIjB,wDAAwD;IACxD,UAAU,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI;IAKhC,uDAAuD;IACvD,SAAS,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI;IAK/B,4CAA4C;IAC5C,MAAM,IAAI,eAAe;CAS1B"}
|
package/lib/seams.js
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Optional host seams a CC plugin loader mounts onto, plus the structural
|
|
3
|
+
* report accumulator.
|
|
4
|
+
*
|
|
5
|
+
* The loader is deliberately peer-style: it consults each component's host
|
|
6
|
+
* seam through `ctx.get(...)` and skips (with a reason) rather than throwing
|
|
7
|
+
* when a seam is absent, so a deployment can mount a plugin without every
|
|
8
|
+
* extension point present. `mcp` and `hooks` have no harness-owned service
|
|
9
|
+
* today; this module declares their guest contract so a host can satisfy it.
|
|
10
|
+
*
|
|
11
|
+
* @module
|
|
12
|
+
*/
|
|
13
|
+
/** Probe a guest seam by key, returning `undefined` when the host lacks it. */
|
|
14
|
+
export function probe(value) {
|
|
15
|
+
return value;
|
|
16
|
+
}
|
|
17
|
+
/** Accumulates loaded/skipped/failed counts and reasons for one component. */
|
|
18
|
+
export class ComponentTally {
|
|
19
|
+
kind;
|
|
20
|
+
loaded = 0;
|
|
21
|
+
skipped = 0;
|
|
22
|
+
failed = 0;
|
|
23
|
+
reasons = [];
|
|
24
|
+
/**
|
|
25
|
+
* Construct a tally for one component kind.
|
|
26
|
+
* @param kind - the component this tally measures.
|
|
27
|
+
*/
|
|
28
|
+
constructor(kind) {
|
|
29
|
+
this.kind = kind;
|
|
30
|
+
}
|
|
31
|
+
/** Record one component as mounted. */
|
|
32
|
+
addLoaded() {
|
|
33
|
+
this.loaded += 1;
|
|
34
|
+
}
|
|
35
|
+
/** Record one component as skipped, with the reason. */
|
|
36
|
+
addSkipped(reason) {
|
|
37
|
+
this.skipped += 1;
|
|
38
|
+
this.reasons.push(reason);
|
|
39
|
+
}
|
|
40
|
+
/** Record one component as failed, with the reason. */
|
|
41
|
+
addFailed(reason) {
|
|
42
|
+
this.failed += 1;
|
|
43
|
+
this.reasons.push(reason);
|
|
44
|
+
}
|
|
45
|
+
/** Build the final per-component result. */
|
|
46
|
+
result() {
|
|
47
|
+
return {
|
|
48
|
+
kind: this.kind,
|
|
49
|
+
loaded: this.loaded,
|
|
50
|
+
skipped: this.skipped,
|
|
51
|
+
failed: this.failed,
|
|
52
|
+
reasons: this.reasons,
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
//# sourceMappingURL=seams.js.map
|
package/lib/seams.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"seams.js","sourceRoot":"","sources":["../src/seams.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AA4BH,+EAA+E;AAC/E,MAAM,UAAU,KAAK,CAAI,KAAoB;IAC3C,OAAO,KAAK,CAAA;AACd,CAAC;AAED,8EAA8E;AAC9E,MAAM,OAAO,cAAc;IAUI;IATrB,MAAM,GAAG,CAAC,CAAA;IACV,OAAO,GAAG,CAAC,CAAA;IACX,MAAM,GAAG,CAAC,CAAA;IACD,OAAO,GAAa,EAAE,CAAA;IAEvC;;;OAGG;IACH,YAA6B,IAAmB;QAAnB,SAAI,GAAJ,IAAI,CAAe;IAAG,CAAC;IAEpD,uCAAuC;IACvC,SAAS;QACP,IAAI,CAAC,MAAM,IAAI,CAAC,CAAA;IAClB,CAAC;IAED,wDAAwD;IACxD,UAAU,CAAC,MAAc;QACvB,IAAI,CAAC,OAAO,IAAI,CAAC,CAAA;QACjB,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;IAC3B,CAAC;IAED,uDAAuD;IACvD,SAAS,CAAC,MAAc;QACtB,IAAI,CAAC,MAAM,IAAI,CAAC,CAAA;QAChB,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;IAC3B,CAAC;IAED,4CAA4C;IAC5C,MAAM;QACJ,OAAO;YACL,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,MAAM,EAAE,IAAI,CAAC,MAAM;YACnB,OAAO,EAAE,IAAI,CAAC,OAAO;YACrB,MAAM,EAAE,IAAI,CAAC,MAAM;YACnB,OAAO,EAAE,IAAI,CAAC,OAAO;SACtB,CAAA;IACH,CAAC;CACF"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Mount a Claude Code plugin's settings.
|
|
3
|
+
*
|
|
4
|
+
* Filters the manifest `settings` record to the allowlisted keys (mirroring
|
|
5
|
+
* Claude Code's keep-list) and writes them through the optional `settings`
|
|
6
|
+
* guest seam under a plugin-scoped namespace. When the seam is absent the
|
|
7
|
+
* component is reported skipped, never failed.
|
|
8
|
+
*
|
|
9
|
+
* @module
|
|
10
|
+
*/
|
|
11
|
+
import type { CcPluginManifest } from './types.ts';
|
|
12
|
+
import { ComponentTally } from './seams.ts';
|
|
13
|
+
/** Settings keys Claude Code keeps when merging a plugin's settings. */
|
|
14
|
+
export declare const SETTINGS_ALLOWLIST: readonly ["agent"];
|
|
15
|
+
/** The settings seam: writes one plugin-scoped namespace of values. */
|
|
16
|
+
export interface SettingsSeam {
|
|
17
|
+
/**
|
|
18
|
+
* Write a plugin's allowlisted settings.
|
|
19
|
+
* @param name - the plugin-scoped namespace.
|
|
20
|
+
* @param value - the allowlisted settings to merge.
|
|
21
|
+
* @returns the exact disposer that removes the written section.
|
|
22
|
+
*/
|
|
23
|
+
set(name: string, value: Record<string, unknown>): () => void;
|
|
24
|
+
}
|
|
25
|
+
/** Options for mounting one plugin's settings. */
|
|
26
|
+
export interface MountSettingsOptions {
|
|
27
|
+
/** The parsed manifest, whose `settings` record is written. */
|
|
28
|
+
readonly manifest: CcPluginManifest;
|
|
29
|
+
/** The settings seam (probed; `undefined` to skip settings). */
|
|
30
|
+
readonly settings: SettingsSeam | undefined;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Filter and write a plugin's settings through the optional seam.
|
|
34
|
+
* @param options - manifest and the settings seam.
|
|
35
|
+
* @returns mounted disposers and per-component counts.
|
|
36
|
+
*/
|
|
37
|
+
export declare function mountSettings(options: MountSettingsOptions): {
|
|
38
|
+
disposers: (() => void)[];
|
|
39
|
+
tally: ComponentTally;
|
|
40
|
+
};
|
|
41
|
+
//# sourceMappingURL=settings.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"settings.d.ts","sourceRoot":"","sources":["../src/settings.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAA;AAClD,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAA;AAE3C,wEAAwE;AACxE,eAAO,MAAM,kBAAkB,oBAAqB,CAAA;AAEpD,uEAAuE;AACvE,MAAM,WAAW,YAAY;IAC3B;;;;;OAKG;IACH,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,IAAI,CAAA;CAC9D;AAED,kDAAkD;AAClD,MAAM,WAAW,oBAAoB;IACnC,+DAA+D;IAC/D,QAAQ,CAAC,QAAQ,EAAE,gBAAgB,CAAA;IACnC,gEAAgE;IAChE,QAAQ,CAAC,QAAQ,EAAE,YAAY,GAAG,SAAS,CAAA;CAC5C;AAED;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,OAAO,EAAE,oBAAoB,GAAG;IAAE,SAAS,EAAE,CAAC,MAAM,IAAI,CAAC,EAAE,CAAC;IAAC,KAAK,EAAE,cAAc,CAAA;CAAE,CAejH"}
|
package/lib/settings.js
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Mount a Claude Code plugin's settings.
|
|
3
|
+
*
|
|
4
|
+
* Filters the manifest `settings` record to the allowlisted keys (mirroring
|
|
5
|
+
* Claude Code's keep-list) and writes them through the optional `settings`
|
|
6
|
+
* guest seam under a plugin-scoped namespace. When the seam is absent the
|
|
7
|
+
* component is reported skipped, never failed.
|
|
8
|
+
*
|
|
9
|
+
* @module
|
|
10
|
+
*/
|
|
11
|
+
import { ComponentTally } from "./seams.js";
|
|
12
|
+
/** Settings keys Claude Code keeps when merging a plugin's settings. */
|
|
13
|
+
export const SETTINGS_ALLOWLIST = ['agent'];
|
|
14
|
+
/**
|
|
15
|
+
* Filter and write a plugin's settings through the optional seam.
|
|
16
|
+
* @param options - manifest and the settings seam.
|
|
17
|
+
* @returns mounted disposers and per-component counts.
|
|
18
|
+
*/
|
|
19
|
+
export function mountSettings(options) {
|
|
20
|
+
const tally = new ComponentTally('settings');
|
|
21
|
+
const disposers = [];
|
|
22
|
+
if (options.settings === undefined) {
|
|
23
|
+
tally.addSkipped('settings seam "settings" is not mounted');
|
|
24
|
+
return { disposers, tally };
|
|
25
|
+
}
|
|
26
|
+
const allowed = allowlist(options.manifest.settings);
|
|
27
|
+
if (Object.keys(allowed).length === 0) {
|
|
28
|
+
tally.addSkipped('plugin declares no allowlisted settings');
|
|
29
|
+
return { disposers, tally };
|
|
30
|
+
}
|
|
31
|
+
disposers.push(options.settings.set(options.manifest.name, allowed));
|
|
32
|
+
tally.addLoaded();
|
|
33
|
+
return { disposers, tally };
|
|
34
|
+
}
|
|
35
|
+
/** Keep only the allowlisted keys from a settings section. */
|
|
36
|
+
function allowlist(settings) {
|
|
37
|
+
const result = {};
|
|
38
|
+
for (const key of SETTINGS_ALLOWLIST) {
|
|
39
|
+
if (settings[key] !== undefined)
|
|
40
|
+
result[key] = settings[key];
|
|
41
|
+
}
|
|
42
|
+
return result;
|
|
43
|
+
}
|
|
44
|
+
//# sourceMappingURL=settings.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"settings.js","sourceRoot":"","sources":["../src/settings.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAGH,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAA;AAE3C,wEAAwE;AACxE,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,OAAO,CAAU,CAAA;AAqBpD;;;;GAIG;AACH,MAAM,UAAU,aAAa,CAAC,OAA6B;IACzD,MAAM,KAAK,GAAG,IAAI,cAAc,CAAC,UAAU,CAAC,CAAA;IAC5C,MAAM,SAAS,GAAmB,EAAE,CAAA;IACpC,IAAI,OAAO,CAAC,QAAQ,KAAK,SAAS,EAAE,CAAC;QACnC,KAAK,CAAC,UAAU,CAAC,yCAAyC,CAAC,CAAA;QAC3D,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,CAAA;IAC7B,CAAC;IACD,MAAM,OAAO,GAAG,SAAS,CAAC,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAA;IACpD,IAAI,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACtC,KAAK,CAAC,UAAU,CAAC,yCAAyC,CAAC,CAAA;QAC3D,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,CAAA;IAC7B,CAAC;IACD,SAAS,CAAC,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAC,OAAO,CAAC,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC,CAAA;IACpE,KAAK,CAAC,SAAS,EAAE,CAAA;IACjB,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,CAAA;AAC7B,CAAC;AAED,8DAA8D;AAC9D,SAAS,SAAS,CAAC,QAA2C;IAC5D,MAAM,MAAM,GAA4B,EAAE,CAAA;IAC1C,KAAK,MAAM,GAAG,IAAI,kBAAkB,EAAE,CAAC;QACrC,IAAI,QAAQ,CAAC,GAAG,CAAC,KAAK,SAAS;YAAE,MAAM,CAAC,GAAG,CAAC,GAAG,QAAQ,CAAC,GAAG,CAAC,CAAA;IAC9D,CAAC;IACD,OAAO,MAAM,CAAA;AACf,CAAC"}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Consumer-side wiring of Claude Code skill semantics onto harness seams.
|
|
3
|
+
*
|
|
4
|
+
* The skill-claude-code package translates frontmatter into pure metadata; this
|
|
5
|
+
* module is the consumer that turns that metadata into actionable registrations
|
|
6
|
+
* at mount time: an `allowed-tools` allow-list into a scoped `tools.restrict()`,
|
|
7
|
+
* `paths` into a path activator, `context: fork` into subagent routing, and a
|
|
8
|
+
* MCP source into a forced-off inline shell. Each piece is effect-scoped and
|
|
9
|
+
* returns a disposer so unmounting the plugin recalls everything.
|
|
10
|
+
*
|
|
11
|
+
* @module
|
|
12
|
+
*/
|
|
13
|
+
import type { Context } from '@deepseek-ai/cordis';
|
|
14
|
+
import { type CcSkillMetadata } from '@jianxx/dsh-cc-skill-loader';
|
|
15
|
+
import type { ToolRestriction } from '@jianxx/dsh-cc-tools';
|
|
16
|
+
import type { SkillDefinition } from '@deepseek-ai/dsh-skill';
|
|
17
|
+
/** The agent-scope surface a skill needs to apply a scoped tool restriction. */
|
|
18
|
+
export interface AgentScope {
|
|
19
|
+
/** Scoped tool registry; `restrict` masks global tools for this agent. */
|
|
20
|
+
tools: {
|
|
21
|
+
/**
|
|
22
|
+
* Restrict the global tools visible to this agent scope.
|
|
23
|
+
* @param filter - the `allow`/`deny` mask to apply.
|
|
24
|
+
* @returns the exact disposer that lifts the restriction.
|
|
25
|
+
*/
|
|
26
|
+
restrict(filter: ToolRestriction): () => void;
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
/** How a skill's body executes when activated. */
|
|
30
|
+
export type SkillExecution = 'inline' | 'fork';
|
|
31
|
+
/** The resolved activation descriptor a host consumes for one skill. */
|
|
32
|
+
export interface SkillActivation {
|
|
33
|
+
/** Scoped tool restriction to apply on activation, or `undefined` when none. */
|
|
34
|
+
readonly restriction: ToolRestriction | undefined;
|
|
35
|
+
/** Whether the skill's body runs in a subagent or inline. */
|
|
36
|
+
readonly execution: SkillExecution;
|
|
37
|
+
/** Whether inline shell substitution is forbidden (MCP-sourced or `shell: false`). */
|
|
38
|
+
readonly forbidInlineShell: boolean;
|
|
39
|
+
}
|
|
40
|
+
/** The provider label RUNTIME skills using this loader carry. */
|
|
41
|
+
export declare const PROVIDER = "cc-plugin-loader";
|
|
42
|
+
/**
|
|
43
|
+
* Resolve the tool restriction for a skill from its `allowed-tools` allow-list.
|
|
44
|
+
* Names are translated leniently; unknown names are dropped with a diagnostic
|
|
45
|
+
* (routed to `console.warn`) rather than crashing the session.
|
|
46
|
+
* @param metadata - the skill's translated CC metadata.
|
|
47
|
+
* @returns an allow-only restriction, or `undefined` when nothing to restrict.
|
|
48
|
+
*/
|
|
49
|
+
export declare function skillToolRestriction(metadata: CcSkillMetadata): ToolRestriction | undefined;
|
|
50
|
+
/**
|
|
51
|
+
* Resolve how a skill executes, honoring `context: fork` and the availability
|
|
52
|
+
* of the subagent seam. A `fork` skill degrades to inline when the subagent
|
|
53
|
+
* seam is absent so it still activates rather than failing.
|
|
54
|
+
* @param metadata - the skill's translated CC metadata.
|
|
55
|
+
* @param subagentsPresent - whether the subagent seam is mounted.
|
|
56
|
+
* @returns `'fork'` when the skill demands fork and the seam exists, else `'inline'`.
|
|
57
|
+
*/
|
|
58
|
+
export declare function resolveSkillExecution(metadata: CcSkillMetadata, subagentsPresent: boolean): SkillExecution;
|
|
59
|
+
/**
|
|
60
|
+
* Whether a skill forbids inline shell substitution. A `shell: false` field, or
|
|
61
|
+
* an MCP-sourced skill (marked `shell: false` by its producer because it cannot
|
|
62
|
+
* run a local shell), must not open an inline shell.
|
|
63
|
+
* @param metadata - the skill's translated CC metadata.
|
|
64
|
+
* @returns whether inline shell is forbidden.
|
|
65
|
+
*/
|
|
66
|
+
export declare function forbidsInlineShell(metadata: CcSkillMetadata): boolean;
|
|
67
|
+
/**
|
|
68
|
+
* Build the full activation descriptor for a skill, mirroring the four
|
|
69
|
+
* consumer-side wires. Pure and deterministic so it is directly testable.
|
|
70
|
+
* @param metadata - the skill's translated CC metadata.
|
|
71
|
+
* @param subagentsPresent - whether the subagent seam is mounted.
|
|
72
|
+
* @returns the resolved activation descriptor.
|
|
73
|
+
*/
|
|
74
|
+
export declare function activationFor(metadata: CcSkillMetadata, subagentsPresent: boolean): SkillActivation;
|
|
75
|
+
/**
|
|
76
|
+
* Register a skill's path-conditional activator on `fs/observed`. The returned
|
|
77
|
+
* disposer is folder-scoped and effect-safe through `ctx.on(...)`.
|
|
78
|
+
* @param ctx - active context carrying the `fs/observed` event.
|
|
79
|
+
* @param skill - the loaded skill definition (carries CC metadata).
|
|
80
|
+
* @param projectRoot - the project/plugin root whose touched files activate the skill.
|
|
81
|
+
* @returns the exact disposer that removes the activator.
|
|
82
|
+
*/
|
|
83
|
+
export declare function registerSkillPathActivator(ctx: Context, skill: SkillDefinition, projectRoot: string): () => void;
|
|
84
|
+
/**
|
|
85
|
+
* Apply a skill's `allowed-tools` restriction to a scoped agent. Returns the
|
|
86
|
+
* restriction disposer, or a no-op when the skill carries no restriction.
|
|
87
|
+
* @param metadata - the skill's translated CC metadata.
|
|
88
|
+
* @param agent - the scoped agent whose tool surface to mask.
|
|
89
|
+
* @returns the disposer that lifts the restriction.
|
|
90
|
+
*/
|
|
91
|
+
export declare function applySkillRestriction(metadata: CcSkillMetadata, agent: AgentScope): () => void;
|
|
92
|
+
//# sourceMappingURL=skill-semantics.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"skill-semantics.d.ts","sourceRoot":"","sources":["../src/skill-semantics.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAA;AAClD,OAAO,EAIL,KAAK,eAAe,EACrB,MAAM,6BAA6B,CAAA;AACpC,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAA;AAC3D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAA;AAE7D,gFAAgF;AAChF,MAAM,WAAW,UAAU;IACzB,0EAA0E;IAC1E,KAAK,EAAE;QACL;;;;WAIG;QACH,QAAQ,CAAC,MAAM,EAAE,eAAe,GAAG,MAAM,IAAI,CAAA;KAC9C,CAAA;CACF;AAED,kDAAkD;AAClD,MAAM,MAAM,cAAc,GAAG,QAAQ,GAAG,MAAM,CAAA;AAE9C,wEAAwE;AACxE,MAAM,WAAW,eAAe;IAC9B,gFAAgF;IAChF,QAAQ,CAAC,WAAW,EAAE,eAAe,GAAG,SAAS,CAAA;IACjD,6DAA6D;IAC7D,QAAQ,CAAC,SAAS,EAAE,cAAc,CAAA;IAClC,sFAAsF;IACtF,QAAQ,CAAC,iBAAiB,EAAE,OAAO,CAAA;CACpC;AAED,iEAAiE;AACjE,eAAO,MAAM,QAAQ,qBAAqB,CAAA;AAE1C;;;;;;GAMG;AACH,wBAAgB,oBAAoB,CAAC,QAAQ,EAAE,eAAe,GAAG,eAAe,GAAG,SAAS,CAK3F;AAED;;;;;;;GAOG;AACH,wBAAgB,qBAAqB,CACnC,QAAQ,EAAE,eAAe,EACzB,gBAAgB,EAAE,OAAO,GACxB,cAAc,CAGhB;AAED;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAAC,QAAQ,EAAE,eAAe,GAAG,OAAO,CAErE;AAED;;;;;;GAMG;AACH,wBAAgB,aAAa,CAAC,QAAQ,EAAE,eAAe,EAAE,gBAAgB,EAAE,OAAO,GAAG,eAAe,CAMnG;AAED;;;;;;;GAOG;AACH,wBAAgB,0BAA0B,CACxC,GAAG,EAAE,OAAO,EACZ,KAAK,EAAE,eAAe,EACtB,WAAW,EAAE,MAAM,GAClB,MAAM,IAAI,CAUZ;AAED;;;;;;GAMG;AACH,wBAAgB,qBAAqB,CACnC,QAAQ,EAAE,eAAe,EACzB,KAAK,EAAE,UAAU,GAChB,MAAM,IAAI,CAIZ"}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Consumer-side wiring of Claude Code skill semantics onto harness seams.
|
|
3
|
+
*
|
|
4
|
+
* The skill-claude-code package translates frontmatter into pure metadata; this
|
|
5
|
+
* module is the consumer that turns that metadata into actionable registrations
|
|
6
|
+
* at mount time: an `allowed-tools` allow-list into a scoped `tools.restrict()`,
|
|
7
|
+
* `paths` into a path activator, `context: fork` into subagent routing, and a
|
|
8
|
+
* MCP source into a forced-off inline shell. Each piece is effect-scoped and
|
|
9
|
+
* returns a disposer so unmounting the plugin recalls everything.
|
|
10
|
+
*
|
|
11
|
+
* @module
|
|
12
|
+
*/
|
|
13
|
+
import { ccPathMatcher, ccRestriction, registerPathActivator, } from '@jianxx/dsh-cc-skill-loader';
|
|
14
|
+
/** The provider label RUNTIME skills using this loader carry. */
|
|
15
|
+
export const PROVIDER = 'cc-plugin-loader';
|
|
16
|
+
/**
|
|
17
|
+
* Resolve the tool restriction for a skill from its `allowed-tools` allow-list.
|
|
18
|
+
* Names are translated leniently; unknown names are dropped with a diagnostic
|
|
19
|
+
* (routed to `console.warn`) rather than crashing the session.
|
|
20
|
+
* @param metadata - the skill's translated CC metadata.
|
|
21
|
+
* @returns an allow-only restriction, or `undefined` when nothing to restrict.
|
|
22
|
+
*/
|
|
23
|
+
export function skillToolRestriction(metadata) {
|
|
24
|
+
return ccRestriction(metadata.allowedTools, (message) => {
|
|
25
|
+
// No logging seam reaches here; surface dropped-name diagnostics on stderr.
|
|
26
|
+
console.warn(`[cc-plugin-loader] ${message}`);
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Resolve how a skill executes, honoring `context: fork` and the availability
|
|
31
|
+
* of the subagent seam. A `fork` skill degrades to inline when the subagent
|
|
32
|
+
* seam is absent so it still activates rather than failing.
|
|
33
|
+
* @param metadata - the skill's translated CC metadata.
|
|
34
|
+
* @param subagentsPresent - whether the subagent seam is mounted.
|
|
35
|
+
* @returns `'fork'` when the skill demands fork and the seam exists, else `'inline'`.
|
|
36
|
+
*/
|
|
37
|
+
export function resolveSkillExecution(metadata, subagentsPresent) {
|
|
38
|
+
if (metadata.executionContext !== 'fork')
|
|
39
|
+
return 'inline';
|
|
40
|
+
return subagentsPresent ? 'fork' : 'inline';
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Whether a skill forbids inline shell substitution. A `shell: false` field, or
|
|
44
|
+
* an MCP-sourced skill (marked `shell: false` by its producer because it cannot
|
|
45
|
+
* run a local shell), must not open an inline shell.
|
|
46
|
+
* @param metadata - the skill's translated CC metadata.
|
|
47
|
+
* @returns whether inline shell is forbidden.
|
|
48
|
+
*/
|
|
49
|
+
export function forbidsInlineShell(metadata) {
|
|
50
|
+
return metadata.shell === false;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Build the full activation descriptor for a skill, mirroring the four
|
|
54
|
+
* consumer-side wires. Pure and deterministic so it is directly testable.
|
|
55
|
+
* @param metadata - the skill's translated CC metadata.
|
|
56
|
+
* @param subagentsPresent - whether the subagent seam is mounted.
|
|
57
|
+
* @returns the resolved activation descriptor.
|
|
58
|
+
*/
|
|
59
|
+
export function activationFor(metadata, subagentsPresent) {
|
|
60
|
+
return {
|
|
61
|
+
restriction: skillToolRestriction(metadata),
|
|
62
|
+
execution: resolveSkillExecution(metadata, subagentsPresent),
|
|
63
|
+
forbidInlineShell: forbidsInlineShell(metadata),
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Register a skill's path-conditional activator on `fs/observed`. The returned
|
|
68
|
+
* disposer is folder-scoped and effect-safe through `ctx.on(...)`.
|
|
69
|
+
* @param ctx - active context carrying the `fs/observed` event.
|
|
70
|
+
* @param skill - the loaded skill definition (carries CC metadata).
|
|
71
|
+
* @param projectRoot - the project/plugin root whose touched files activate the skill.
|
|
72
|
+
* @returns the exact disposer that removes the activator.
|
|
73
|
+
*/
|
|
74
|
+
export function registerSkillPathActivator(ctx, skill, projectRoot) {
|
|
75
|
+
const metadata = skill.metadata;
|
|
76
|
+
const paths = metadata?.paths ?? [];
|
|
77
|
+
if (paths.length === 0) {
|
|
78
|
+
return () => { };
|
|
79
|
+
}
|
|
80
|
+
return registerPathActivator(ctx, {
|
|
81
|
+
projects: [{ root: projectRoot, matcher: ccPathMatcher(paths), skillNames: [skill.name] }],
|
|
82
|
+
onActivate: () => { },
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Apply a skill's `allowed-tools` restriction to a scoped agent. Returns the
|
|
87
|
+
* restriction disposer, or a no-op when the skill carries no restriction.
|
|
88
|
+
* @param metadata - the skill's translated CC metadata.
|
|
89
|
+
* @param agent - the scoped agent whose tool surface to mask.
|
|
90
|
+
* @returns the disposer that lifts the restriction.
|
|
91
|
+
*/
|
|
92
|
+
export function applySkillRestriction(metadata, agent) {
|
|
93
|
+
const restriction = skillToolRestriction(metadata);
|
|
94
|
+
if (restriction === undefined)
|
|
95
|
+
return () => { };
|
|
96
|
+
return agent.tools.restrict(restriction);
|
|
97
|
+
}
|
|
98
|
+
//# sourceMappingURL=skill-semantics.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"skill-semantics.js","sourceRoot":"","sources":["../src/skill-semantics.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAGH,OAAO,EACL,aAAa,EACb,aAAa,EACb,qBAAqB,GAEtB,MAAM,6BAA6B,CAAA;AA8BpC,iEAAiE;AACjE,MAAM,CAAC,MAAM,QAAQ,GAAG,kBAAkB,CAAA;AAE1C;;;;;;GAMG;AACH,MAAM,UAAU,oBAAoB,CAAC,QAAyB;IAC5D,OAAO,aAAa,CAAC,QAAQ,CAAC,YAAY,EAAE,CAAC,OAAe,EAAQ,EAAE;QACpE,4EAA4E;QAC5E,OAAO,CAAC,IAAI,CAAC,sBAAsB,OAAO,EAAE,CAAC,CAAA;IAC/C,CAAC,CAAC,CAAA;AACJ,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,qBAAqB,CACnC,QAAyB,EACzB,gBAAyB;IAEzB,IAAI,QAAQ,CAAC,gBAAgB,KAAK,MAAM;QAAE,OAAO,QAAQ,CAAA;IACzD,OAAO,gBAAgB,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,QAAQ,CAAA;AAC7C,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,kBAAkB,CAAC,QAAyB;IAC1D,OAAO,QAAQ,CAAC,KAAK,KAAK,KAAK,CAAA;AACjC,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,aAAa,CAAC,QAAyB,EAAE,gBAAyB;IAChF,OAAO;QACL,WAAW,EAAE,oBAAoB,CAAC,QAAQ,CAAC;QAC3C,SAAS,EAAE,qBAAqB,CAAC,QAAQ,EAAE,gBAAgB,CAAC;QAC5D,iBAAiB,EAAE,kBAAkB,CAAC,QAAQ,CAAC;KAChD,CAAA;AACH,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,0BAA0B,CACxC,GAAY,EACZ,KAAsB,EACtB,WAAmB;IAEnB,MAAM,QAAQ,GAAG,KAAK,CAAC,QAAuC,CAAA;IAC9D,MAAM,KAAK,GAAG,QAAQ,EAAE,KAAK,IAAI,EAAE,CAAA;IACnC,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACvB,OAAO,GAAG,EAAE,GAAE,CAAC,CAAA;IACjB,CAAC;IACD,OAAO,qBAAqB,CAAC,GAAG,EAAE;QAChC,QAAQ,EAAE,CAAC,EAAE,IAAI,EAAE,WAAW,EAAE,OAAO,EAAE,aAAa,CAAC,KAAK,CAAC,EAAE,UAAU,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC;QAC1F,UAAU,EAAE,GAAG,EAAE,GAAE,CAAC;KACrB,CAAC,CAAA;AACJ,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,qBAAqB,CACnC,QAAyB,EACzB,KAAiB;IAEjB,MAAM,WAAW,GAAG,oBAAoB,CAAC,QAAQ,CAAC,CAAA;IAClD,IAAI,WAAW,KAAK,SAAS;QAAE,OAAO,GAAG,EAAE,GAAE,CAAC,CAAA;IAC9C,OAAO,KAAK,CAAC,KAAK,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAA;AAC1C,CAAC"}
|
package/lib/skills.d.ts
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Mount a Claude Code plugin's skills.
|
|
3
|
+
*
|
|
4
|
+
* Discovers `SKILL.md` skills in the plugin's standard `skills/` directory and
|
|
5
|
+
* any inline manifest `skills` paths, parses each with the skill-claude-code
|
|
6
|
+
* frontmatter translator, registers it on the skill registry as a runtime
|
|
7
|
+
* skill, and wires the consumer-side activation semantics (allowed-tools,
|
|
8
|
+
* `context: fork`, `paths`, MCP-source shell). Every registration is a Cordis
|
|
9
|
+
* effect so unmounting the plugin recalls it.
|
|
10
|
+
*
|
|
11
|
+
* @module
|
|
12
|
+
*/
|
|
13
|
+
import type { Context } from '@deepseek-ai/cordis';
|
|
14
|
+
import type { CcPluginManifest } from './types.ts';
|
|
15
|
+
import { ComponentTally } from './seams.ts';
|
|
16
|
+
/** Skills live under this directory in a plugin root, when present. */
|
|
17
|
+
export declare const STANDARD_SKILLS_DIR = "skills";
|
|
18
|
+
/** The skill registry seam that accepts runtime skill registrations. */
|
|
19
|
+
export interface SkillsSeam {
|
|
20
|
+
/**
|
|
21
|
+
* Register a runtime skill definition.
|
|
22
|
+
* @param skill - the skill definition to register.
|
|
23
|
+
* @returns the exact disposer that unregisters the skill.
|
|
24
|
+
*/
|
|
25
|
+
register(skill: unknown): () => void;
|
|
26
|
+
}
|
|
27
|
+
/** Options for mounting one plugin's skills. */
|
|
28
|
+
export interface MountSkillsOptions {
|
|
29
|
+
/** Active context carrying the `fs/observed` event for path activation. */
|
|
30
|
+
readonly ctx: Context;
|
|
31
|
+
/** The plugin root directory; standard `skills/` resolves against it. */
|
|
32
|
+
readonly pluginRoot: string;
|
|
33
|
+
/** The parsed manifest, whose `skills` paths add extra skill roots. */
|
|
34
|
+
readonly manifest: CcPluginManifest;
|
|
35
|
+
/** The skill registry seam (probed; `undefined` to skip skills). */
|
|
36
|
+
readonly skills: SkillsSeam | undefined;
|
|
37
|
+
/** The subagent seam presence (drives `context: fork` routing). */
|
|
38
|
+
readonly subagentsPresent: boolean;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Discover and register a plugin's skills, wiring activation semantics.
|
|
42
|
+
* @param options - plugin root, manifest, and the skill/subagent seams.
|
|
43
|
+
* @returns mounted disposers and per-component counts.
|
|
44
|
+
*/
|
|
45
|
+
export declare function mountSkills(options: MountSkillsOptions): Promise<{
|
|
46
|
+
disposers: (() => void)[];
|
|
47
|
+
tally: ComponentTally;
|
|
48
|
+
}>;
|
|
49
|
+
//# sourceMappingURL=skills.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"skills.d.ts","sourceRoot":"","sources":["../src/skills.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAIH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAA;AAUlD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAA;AAClD,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAA;AAG3C,uEAAuE;AACvE,eAAO,MAAM,mBAAmB,WAAW,CAAA;AAE3C,wEAAwE;AACxE,MAAM,WAAW,UAAU;IACzB;;;;OAIG;IACH,QAAQ,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,IAAI,CAAA;CACrC;AAED,gDAAgD;AAChD,MAAM,WAAW,kBAAkB;IACjC,2EAA2E;IAC3E,QAAQ,CAAC,GAAG,EAAE,OAAO,CAAA;IACrB,yEAAyE;IACzE,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAA;IAC3B,uEAAuE;IACvE,QAAQ,CAAC,QAAQ,EAAE,gBAAgB,CAAA;IACnC,oEAAoE;IACpE,QAAQ,CAAC,MAAM,EAAE,UAAU,GAAG,SAAS,CAAA;IACvC,mEAAmE;IACnE,QAAQ,CAAC,gBAAgB,EAAE,OAAO,CAAA;CACnC;AAED;;;;GAIG;AACH,wBAAsB,WAAW,CAAC,OAAO,EAAE,kBAAkB,GAAG,OAAO,CAAC;IAAE,SAAS,EAAE,CAAC,MAAM,IAAI,CAAC,EAAE,CAAC;IAAC,KAAK,EAAE,cAAc,CAAA;CAAE,CAAC,CA+C5H"}
|