@daweifu/capability-menu 0.1.1 → 0.1.2
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/README.en.md +217 -0
- package/README.md +104 -61
- package/cordis.patch.yml +31 -31
- package/lib/client.d.ts +33 -7
- package/lib/client.d.ts.map +1 -1
- package/lib/client.js +315 -97
- package/lib/index.js +2 -2
- package/lib/invoke.js +68 -96
- package/lib/invoke.js.map +1 -1
- package/lib/policy.js +224 -80
- package/lib/policy.js.map +1 -1
- package/lib/registry.js +183 -143
- package/lib/registry.js.map +1 -1
- package/lib/search.js +17 -8
- package/lib/search.js.map +1 -1
- package/lib/server/remote.js +87 -4
- package/lib/server/remote.js.map +1 -1
- package/lib/types/index.d.ts +2 -2
- package/lib/types/invoke.d.ts +7 -13
- package/lib/types/invoke.d.ts.map +1 -1
- package/lib/types/policy.d.ts +78 -55
- package/lib/types/policy.d.ts.map +1 -1
- package/lib/types/registry.d.ts +60 -23
- package/lib/types/registry.d.ts.map +1 -1
- package/lib/types/search.d.ts.map +1 -1
- package/lib/types/server/remote.d.ts +24 -3
- package/lib/types/server/remote.d.ts.map +1 -1
- package/package.json +19 -23
- package/lib/invariant.js +0 -22
- package/lib/invariant.js.map +0 -1
- package/lib/types/invariant.d.ts +0 -16
- package/lib/types/invariant.d.ts.map +0 -1
package/lib/server/remote.js
CHANGED
|
@@ -33,8 +33,11 @@ var __esDecorate = (this && this.__esDecorate) || function (ctor, descriptorIn,
|
|
|
33
33
|
done = true;
|
|
34
34
|
};
|
|
35
35
|
import { TypertRemoteService, Remote } from '@deepseek-ai/dsh-typert-protocol';
|
|
36
|
+
import { readFile } from 'node:fs/promises';
|
|
37
|
+
import yaml from 'js-yaml';
|
|
38
|
+
import { BUILT_IN_SERVER } from "../registry.js";
|
|
36
39
|
/**
|
|
37
|
-
* Host-side remote face for the
|
|
40
|
+
* Host-side remote face for the 能力管理 tab. Every method delegates to the
|
|
38
41
|
* policy service installed by `@daweifu/capability-menu/policy`; the registry
|
|
39
42
|
* sibling (`capability`) must be mounted for `classifyAll` to return anything.
|
|
40
43
|
*
|
|
@@ -53,6 +56,7 @@ let CapabilityPolicyGateway = (() => {
|
|
|
53
56
|
let _getDetail_decorators;
|
|
54
57
|
let _listSkillDir_decorators;
|
|
55
58
|
let _readSkillFile_decorators;
|
|
59
|
+
let _getCatalogDocs_decorators;
|
|
56
60
|
return class CapabilityPolicyGateway extends _classSuper {
|
|
57
61
|
static {
|
|
58
62
|
const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
|
|
@@ -62,12 +66,14 @@ let CapabilityPolicyGateway = (() => {
|
|
|
62
66
|
_getDetail_decorators = [Remote('getDetail')];
|
|
63
67
|
_listSkillDir_decorators = [Remote('listSkillDir')];
|
|
64
68
|
_readSkillFile_decorators = [Remote('readSkillFile')];
|
|
69
|
+
_getCatalogDocs_decorators = [Remote('getCatalogDocs')];
|
|
65
70
|
__esDecorate(this, null, _getConfig_decorators, { kind: "method", name: "getConfig", static: false, private: false, access: { has: obj => "getConfig" in obj, get: obj => obj.getConfig }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
66
71
|
__esDecorate(this, null, _updateConfig_decorators, { kind: "method", name: "updateConfig", static: false, private: false, access: { has: obj => "updateConfig" in obj, get: obj => obj.updateConfig }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
67
72
|
__esDecorate(this, null, _classifyAll_decorators, { kind: "method", name: "classifyAll", static: false, private: false, access: { has: obj => "classifyAll" in obj, get: obj => obj.classifyAll }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
68
73
|
__esDecorate(this, null, _getDetail_decorators, { kind: "method", name: "getDetail", static: false, private: false, access: { has: obj => "getDetail" in obj, get: obj => obj.getDetail }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
69
74
|
__esDecorate(this, null, _listSkillDir_decorators, { kind: "method", name: "listSkillDir", static: false, private: false, access: { has: obj => "listSkillDir" in obj, get: obj => obj.listSkillDir }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
70
75
|
__esDecorate(this, null, _readSkillFile_decorators, { kind: "method", name: "readSkillFile", static: false, private: false, access: { has: obj => "readSkillFile" in obj, get: obj => obj.readSkillFile }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
76
|
+
__esDecorate(this, null, _getCatalogDocs_decorators, { kind: "method", name: "getCatalogDocs", static: false, private: false, access: { has: obj => "getCatalogDocs" in obj, get: obj => obj.getCatalogDocs }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
71
77
|
if (_metadata) Object.defineProperty(this, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
|
72
78
|
}
|
|
73
79
|
static inject = ['capabilityPolicy', 'capability'];
|
|
@@ -79,9 +85,9 @@ let CapabilityPolicyGateway = (() => {
|
|
|
79
85
|
getConfig() {
|
|
80
86
|
return this.ctx.capabilityPolicy.getConfig();
|
|
81
87
|
}
|
|
82
|
-
/** Replace a subset of the policy config (recompile rules). */
|
|
83
|
-
updateConfig(partial) {
|
|
84
|
-
this.ctx.capabilityPolicy.updateConfig(partial);
|
|
88
|
+
/** Replace a subset of the policy config (recompile rules + rewrite catalog). */
|
|
89
|
+
async updateConfig(partial) {
|
|
90
|
+
await this.ctx.capabilityPolicy.updateConfig(partial);
|
|
85
91
|
}
|
|
86
92
|
/** Classify every capability currently indexed by `ctx.capability`. */
|
|
87
93
|
classifyAll() {
|
|
@@ -99,6 +105,83 @@ let CapabilityPolicyGateway = (() => {
|
|
|
99
105
|
async readSkillFile(id, relPath) {
|
|
100
106
|
return this.ctx.capability.readSkillFile(id, relPath);
|
|
101
107
|
}
|
|
108
|
+
/**
|
|
109
|
+
* 能力目录查看:返回「三档策略配置」语义化视图——默认全部常驻,
|
|
110
|
+
* tools.resident 按 server 各显示 '*',例外(on-demand/disabled)按
|
|
111
|
+
* server → 工具短名 分级列出;skills 无 server 维度,resident 恒为 '*',
|
|
112
|
+
* 例外为短名平铺。空例外不渲染 key,避免 []/{} 歧义。
|
|
113
|
+
* 另返回按需能力目录物化文件(~/.dsh/capability-catalog.yaml)的路径和内容。
|
|
114
|
+
* 两者都是只读视图——策略持久化入口仍是 cordis.patch.yml。
|
|
115
|
+
*/
|
|
116
|
+
async getCatalogDocs() {
|
|
117
|
+
const effective = [...this.ctx.capabilityPolicy.classifyAll()];
|
|
118
|
+
const toolRows = effective.filter(row => row.kind === 'tool');
|
|
119
|
+
const skillRows = effective.filter(row => row.kind === 'skill');
|
|
120
|
+
const count = (rows, cls) => rows.filter(row => row.class === cls).length;
|
|
121
|
+
/** 例外档(on-demand/disabled)的生效工具,按 server 分组为 server → 短名列表。 */
|
|
122
|
+
const toolGroups = (cls) => {
|
|
123
|
+
const groups = new Map();
|
|
124
|
+
for (const row of toolRows.filter(r => r.class === cls)) {
|
|
125
|
+
const server = row.server ?? BUILT_IN_SERVER;
|
|
126
|
+
const prefix = row.server === undefined ? undefined : `mcp__${row.server}__`;
|
|
127
|
+
const short = prefix !== undefined && row.name.startsWith(prefix) ? row.name.slice(prefix.length) : row.name;
|
|
128
|
+
const list = groups.get(server);
|
|
129
|
+
if (list === undefined)
|
|
130
|
+
groups.set(server, [short]);
|
|
131
|
+
else
|
|
132
|
+
list.push(short);
|
|
133
|
+
}
|
|
134
|
+
return Object.fromEntries([...groups.entries()]
|
|
135
|
+
.sort(([a], [b]) => a.localeCompare(b))
|
|
136
|
+
.map(([server, names]) => [server, names.sort((a, b) => a.localeCompare(b))]));
|
|
137
|
+
};
|
|
138
|
+
/** 例外档技能的生效短名(技能无 server 维度,平铺列表)。 */
|
|
139
|
+
const skillNames = (cls) => skillRows.filter(row => row.class === cls).map(row => row.name).sort((a, b) => a.localeCompare(b));
|
|
140
|
+
// tools.resident:每个含工具的 server 一个 '*'(该 server 其余工具默认常驻)。
|
|
141
|
+
const servers = [...new Set(toolRows.map(row => row.server ?? BUILT_IN_SERVER))]
|
|
142
|
+
.sort((a, b) => a.localeCompare(b));
|
|
143
|
+
const residentTools = {};
|
|
144
|
+
for (const server of servers)
|
|
145
|
+
residentTools[server] = '*';
|
|
146
|
+
// 例外档仅当实际存在时才写入,避免空的 []/{}。
|
|
147
|
+
const tools = { resident: residentTools };
|
|
148
|
+
const onDemandTools = toolGroups('on-demand');
|
|
149
|
+
const disabledTools = toolGroups('disabled');
|
|
150
|
+
if (Object.keys(onDemandTools).length > 0)
|
|
151
|
+
tools['on-demand'] = onDemandTools;
|
|
152
|
+
if (Object.keys(disabledTools).length > 0)
|
|
153
|
+
tools.disabled = disabledTools;
|
|
154
|
+
const skills = { resident: '*' };
|
|
155
|
+
const onDemandSkills = skillNames('on-demand');
|
|
156
|
+
const disabledSkills = skillNames('disabled');
|
|
157
|
+
if (onDemandSkills.length > 0)
|
|
158
|
+
skills['on-demand'] = onDemandSkills;
|
|
159
|
+
if (disabledSkills.length > 0)
|
|
160
|
+
skills.disabled = disabledSkills;
|
|
161
|
+
const policyYaml = [
|
|
162
|
+
'# 能力管理 · 当前生效策略(只读;持久化入口:cordis.patch.yml)',
|
|
163
|
+
'# 语义:默认全部能力常驻;下方 on-demand / disabled 为按 server → 工具名分级的例外。',
|
|
164
|
+
`# 生效:tools 常驻 ${count(toolRows, 'resident')} · 按需 ${count(toolRows, 'on-demand')} · 禁用 ${count(toolRows, 'disabled')};` +
|
|
165
|
+
`skills 常驻 ${count(skillRows, 'resident')} · 按需 ${count(skillRows, 'on-demand')} · 禁用 ${count(skillRows, 'disabled')}`,
|
|
166
|
+
yaml.dump({
|
|
167
|
+
metaTools: [...this.ctx.capabilityPolicy.metaTools()],
|
|
168
|
+
tools,
|
|
169
|
+
skills,
|
|
170
|
+
}).trimEnd(),
|
|
171
|
+
].join('\n');
|
|
172
|
+
const catalogPath = this.ctx.capability.catalogPath?.();
|
|
173
|
+
if (catalogPath === undefined) {
|
|
174
|
+
return { policyYaml, catalogMissing: 'disabled' };
|
|
175
|
+
}
|
|
176
|
+
try {
|
|
177
|
+
const content = await readFile(catalogPath, 'utf8');
|
|
178
|
+
return { policyYaml, catalog: { path: catalogPath, content } };
|
|
179
|
+
}
|
|
180
|
+
catch (error) {
|
|
181
|
+
this.ctx.logger.warn(`capability-menu-remote: on-demand catalog read failed (${catalogPath}): ${String(error)}`);
|
|
182
|
+
return { policyYaml, catalogMissing: 'read-failed' };
|
|
183
|
+
}
|
|
184
|
+
}
|
|
102
185
|
};
|
|
103
186
|
})();
|
|
104
187
|
export { CapabilityPolicyGateway };
|
package/lib/server/remote.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"remote.js","sourceRoot":"","sources":["../../src/server/remote.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAUA,OAAO,EAAE,mBAAmB,EAAE,MAAM,EAAE,MAAM,kCAAkC,CAAA;
|
|
1
|
+
{"version":3,"file":"remote.js","sourceRoot":"","sources":["../../src/server/remote.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAUA,OAAO,EAAE,mBAAmB,EAAE,MAAM,EAAE,MAAM,kCAAkC,CAAA;AAC9E,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAA;AAC3C,OAAO,IAAI,MAAM,SAAS,CAAA;AAO1B,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAA;AAsBhD;;;;;;;;;;GAUG;IACU,uBAAuB;sBAAS,mBAAmB;;;;;;;;;iBAAnD,uBAAwB,SAAQ,WAAmB;;;qCAQ7D,MAAM,CAAC,WAAW,CAAC;wCAMnB,MAAM,CAAC,cAAc,CAAC;uCAMtB,MAAM,CAAC,aAAa,CAAC;qCAMrB,MAAM,CAAC,WAAW,CAAC;wCAMnB,MAAM,CAAC,cAAc,CAAC;yCAMtB,MAAM,CAAC,eAAe,CAAC;0CAavB,MAAM,CAAC,gBAAgB,CAAC;YA1CzB,8KAAA,SAAS,6DAER;YAID,uLAAM,YAAY,6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
9
|
* - `search` (P1): registers `meta_search`.
|
|
10
10
|
* - `invoke` (P2): registers `meta_invoke`.
|
|
11
|
-
* - `policy` (P3):
|
|
11
|
+
* - `policy` (P3): Resident/On-demand/Disabled projection policy + `ctx.capabilityPolicy`.
|
|
12
12
|
* - the package root entry (`name` + `apply` below): mounts the Typert gateway
|
|
13
13
|
* that exposes `ctx.capabilityPolicy` to the browser as the `capabilityPolicy`
|
|
14
|
-
* remote namespace — the data source of the
|
|
14
|
+
* remote namespace — the data source of the 能力管理 settings tab.
|
|
15
15
|
* - a browser bundle via the `./client` subpath (`src/client`), discovered by
|
|
16
16
|
* `@deepseek-ai/dsh-client-modules` from this package's `dsh.client`
|
|
17
17
|
* declaration and served as `/plugins/<id>/client.js`.
|
package/lib/types/invoke.d.ts
CHANGED
|
@@ -59,22 +59,16 @@ export type MetaInvokeResult = {
|
|
|
59
59
|
/**
|
|
60
60
|
* Register the `meta_invoke` tool.
|
|
61
61
|
*
|
|
62
|
-
* Dispatch is by `
|
|
63
|
-
* kept only as a defensive guard alongside the kind check).
|
|
62
|
+
* Dispatch is by the explicit `kind` argument (no id-prefix parsing).
|
|
64
63
|
*
|
|
65
|
-
* - Tools (`kind: 'tool'`,
|
|
66
|
-
* call via the official
|
|
67
|
-
* `agent`/`signal`/parent lineage.
|
|
68
|
-
* the target schema so the model can
|
|
69
|
-
*
|
|
64
|
+
* - Tools (`kind: 'tool'`, e.g. `mcp__gongfeng__create_issue` or a harness-native
|
|
65
|
+
* tool such as `bash`): forwards to the underlying tool call via the official
|
|
66
|
+
* `ctx.tools.execute` pipeline, preserving `agent`/`signal`/parent lineage.
|
|
67
|
+
* `forwardMode: 'resolve'` instead returns the target schema so the model can
|
|
68
|
+
* call the tool directly.
|
|
69
|
+
* - Skills (`kind: 'skill'`, id is the bare skill name): loads the full skill
|
|
70
70
|
* instructions and returns them as `<skill_content>` — no args, no script
|
|
71
71
|
* execution (matches the existing `skill` tool semantics).
|
|
72
72
|
*/
|
|
73
73
|
export declare function apply(ctx: Context, config?: Config): void;
|
|
74
|
-
/**
|
|
75
|
-
* Strip leading YAML frontmatter (`---\n...\n---`) from a raw SKILL.md body,
|
|
76
|
-
* returning the remaining markdown. Falls back to the raw text when no
|
|
77
|
-
* frontmatter delimiter is present.
|
|
78
|
-
*/
|
|
79
|
-
export declare function stripFrontmatter(markdown: string): string;
|
|
80
74
|
//# sourceMappingURL=invoke.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"invoke.d.ts","sourceRoot":"","sources":["../../src/invoke.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAA;AAClD,OAAO,CAAC,MAAM,0BAA0B,CAAA;AAExC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAA;
|
|
1
|
+
{"version":3,"file":"invoke.d.ts","sourceRoot":"","sources":["../../src/invoke.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAA;AAClD,OAAO,CAAC,MAAM,0BAA0B,CAAA;AAExC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAA;AAIxD,OAAO,EAAwC,KAAK,iBAAiB,EAAE,MAAM,wBAAwB,CAAA;AAGrG,eAAO,MAAM,IAAI,2BAA2B,CAAA;AAC5C,eAAO,MAAM,MAAM,UAAoC,CAAA;AAEvD,0CAA0C;AAC1C,MAAM,MAAM,eAAe,GAAG,QAAQ,GAAG,SAAS,CAAA;AAElD,gDAAgD;AAChD,MAAM,WAAW,MAAM;IACrB,sIAAsI;IACtI,WAAW,CAAC,EAAE,eAAe,CAAA;CAC9B;AAED,mDAAmD;AACnD,eAAO,MAAM,MAAM,EAAE,CAAC,CAAC,MAAM,CAE3B,CAAA;AAEF,kCAAkC;AAClC,MAAM,WAAW,mBAAmB;IAClC,QAAQ,CAAC,SAAS,EAAE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1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* Resident / On-demand / Disabled capability projection policy for the DeepSeek
|
|
3
3
|
* Harness.
|
|
4
4
|
*
|
|
5
5
|
* @module @daweifu/capability-menu (policy plugin)
|
|
@@ -11,19 +11,19 @@ import { type CapabilityKind } from './registry.ts';
|
|
|
11
11
|
/**
|
|
12
12
|
* Canonical policy classes, mirroring the registry's `CapabilityKind`.
|
|
13
13
|
*
|
|
14
|
-
* - `
|
|
14
|
+
* - `resident`: the capability is on the dsh-native exposure surface — tools in
|
|
15
15
|
* `assembly.tools` (the request `tools` payload), skills in the
|
|
16
16
|
* `<available_skills>` catalog — so the model can call/load it single-hop.
|
|
17
|
-
* - `
|
|
17
|
+
* - `on-demand`: absent from the native surface but discoverable in the
|
|
18
18
|
* persistent meta registry; the model reaches it via `meta_search` then
|
|
19
19
|
* `meta_invoke` (catalog-resident, load/execute on demand).
|
|
20
|
-
* - `
|
|
20
|
+
* - `disabled`: neither resident nor discoverable nor executable.
|
|
21
21
|
*/
|
|
22
|
-
export type CapabilityClass = '
|
|
22
|
+
export type CapabilityClass = 'resident' | 'on-demand' | 'disabled';
|
|
23
23
|
/**
|
|
24
24
|
* A single classify rule: an exact name or a `*`-glob pattern.
|
|
25
|
-
* A pattern matches a capability id (`mcp__<server>__<raw
|
|
26
|
-
* or a server name (`server:<name>`).
|
|
25
|
+
* A pattern matches a capability id (`mcp__<server>__<raw>`, a native tool
|
|
26
|
+
* name, or a bare skill name) or a server name (`server:<name>`).
|
|
27
27
|
*/
|
|
28
28
|
export interface PolicyRule {
|
|
29
29
|
/** Whether the rule is a literal exact name (`*` free) or a glob pattern. */
|
|
@@ -36,39 +36,57 @@ export interface PolicyRule {
|
|
|
36
36
|
readonly target: 'id' | 'server';
|
|
37
37
|
}
|
|
38
38
|
/**
|
|
39
|
-
* Per-kind explicit configuration. `
|
|
39
|
+
* Per-kind explicit configuration. `resident`/`on-demand`/`disabled` are
|
|
40
40
|
* ordered lists of exact-name / glob rules. Empty lists mean "nothing
|
|
41
|
-
* explicitly classified", so the default (`
|
|
41
|
+
* explicitly classified", so the default (`resident`) applies.
|
|
42
42
|
*/
|
|
43
43
|
export interface CapabilitySetConfig {
|
|
44
|
-
/** Explicitly-
|
|
44
|
+
/** Explicitly-Resident rule list (exact name or glob). */
|
|
45
|
+
resident?: string[];
|
|
46
|
+
/** Explicitly-On-demand rule list (exact name or glob). */
|
|
47
|
+
'on-demand'?: string[];
|
|
48
|
+
/** Explicitly-Disabled rule list (exact name or glob); wins over everything. */
|
|
49
|
+
disabled?: string[];
|
|
50
|
+
/**
|
|
51
|
+
* @deprecated pre-rename alias of `disabled`; accepted and mapped so legacy
|
|
52
|
+
* profiles written with the `blocked` key keep working without an on-disk
|
|
53
|
+
* rewrite.
|
|
54
|
+
*/
|
|
55
|
+
blocked?: string[];
|
|
56
|
+
/**
|
|
57
|
+
* @deprecated pre-rename alias of `resident`; accepted and mapped so legacy
|
|
58
|
+
* profiles keep working without an on-disk rewrite.
|
|
59
|
+
*/
|
|
45
60
|
exposed?: string[];
|
|
46
|
-
/**
|
|
61
|
+
/**
|
|
62
|
+
* @deprecated pre-rename alias of `on-demand`; accepted and mapped so legacy
|
|
63
|
+
* profiles keep working without an on-disk rewrite.
|
|
64
|
+
*/
|
|
47
65
|
progressive?: string[];
|
|
48
|
-
/** Explicitly-Blocked rule list (exact name or glob); wins over everything. */
|
|
49
|
-
blocked?: string[];
|
|
50
66
|
}
|
|
51
|
-
/**
|
|
67
|
+
/** Resident / On-demand / Disabled projection policy configuration. */
|
|
52
68
|
export interface Config {
|
|
53
|
-
/** Tool classification: `tools.
|
|
69
|
+
/** Tool classification: `tools.resident` / `tools.on-demand` / `tools.disabled`. */
|
|
54
70
|
tools?: CapabilitySetConfig;
|
|
55
|
-
/** Skill classification: `skills.
|
|
71
|
+
/** Skill classification: `skills.resident` / `skills.on-demand` / `skills.disabled`. */
|
|
56
72
|
skills?: CapabilitySetConfig;
|
|
57
73
|
/**
|
|
58
|
-
* Tool names that are ALWAYS kept
|
|
59
|
-
*
|
|
74
|
+
* Tool names that are ALWAYS kept resident and can never be classified
|
|
75
|
+
* On-demand or Disabled. Default `[meta_search, meta_invoke]`.
|
|
60
76
|
*/
|
|
61
77
|
metaTools?: string[];
|
|
62
|
-
/**
|
|
63
|
-
* Optional path to a Progressive-skill catalog YAML (name + description +
|
|
64
|
-
* path). Consumed by the registry as an additional skill index source (see
|
|
65
|
-
* `@daweifu/capability-menu-registry` `progressiveSkillCatalog`).
|
|
66
|
-
*/
|
|
67
|
-
progressiveSkillCatalog?: string;
|
|
68
78
|
}
|
|
69
79
|
/** Validate and default the policy configuration. */
|
|
70
80
|
export declare const Config: z<Config>;
|
|
71
81
|
export declare const DEFAULT_META_TOOLS: readonly ["meta_search", "meta_invoke"];
|
|
82
|
+
/**
|
|
83
|
+
* Map a legacy rule set (old keys `exposed`/`progressive`/`blocked`) onto the
|
|
84
|
+
* current key names (`resident`/`on-demand`/`disabled`), so already-deployed
|
|
85
|
+
* `cordis.patch.yml` profiles keep working without an on-disk rewrite. New
|
|
86
|
+
* keys win when they carry rules; a legacy key fills in when the matching new
|
|
87
|
+
* list is empty.
|
|
88
|
+
*/
|
|
89
|
+
export declare function normalizeSetConfig(set: CapabilitySetConfig | undefined): CapabilitySetConfig | undefined;
|
|
72
90
|
/**
|
|
73
91
|
* Convert a user-facing rule string into a normalized {@link PolicyRule}.
|
|
74
92
|
* - `server:<name>` → server-targeted rule (`target: 'server'`).
|
|
@@ -81,17 +99,17 @@ export declare function parseRule(rule: string): PolicyRule;
|
|
|
81
99
|
export declare function compileGlob(pattern: string): RegExp;
|
|
82
100
|
/** A compiled rule set for one capability kind. */
|
|
83
101
|
export interface CompiledCapabilityRules {
|
|
84
|
-
readonly
|
|
85
|
-
readonly
|
|
86
|
-
readonly
|
|
102
|
+
readonly resident: readonly PolicyRule[];
|
|
103
|
+
readonly onDemand: readonly PolicyRule[];
|
|
104
|
+
readonly disabled: readonly PolicyRule[];
|
|
87
105
|
}
|
|
88
106
|
/** Compile a {@link CapabilitySetConfig} into fast-matchable rules. */
|
|
89
107
|
export declare function compileSet(set?: CapabilitySetConfig): CompiledCapabilityRules;
|
|
90
108
|
/** Candidate fields a rule is matched against. */
|
|
91
109
|
export interface MatchTarget {
|
|
92
|
-
/**
|
|
110
|
+
/** Capability id: `mcp__<server>__<raw>`, a native tool name, or a bare skill name. */
|
|
93
111
|
readonly id: string;
|
|
94
|
-
/**
|
|
112
|
+
/** Model-facing name (for skills it equals the id; for MCP tools the public `mcp__...` name). */
|
|
95
113
|
readonly name: string;
|
|
96
114
|
/** Server name for tools; undefined for skills. */
|
|
97
115
|
readonly server?: string;
|
|
@@ -102,9 +120,13 @@ export interface MatchTarget {
|
|
|
102
120
|
}
|
|
103
121
|
/**
|
|
104
122
|
* Classify a capability against compiled rules. Priority (hit stops the walk):
|
|
105
|
-
*
|
|
106
|
-
*
|
|
107
|
-
*
|
|
123
|
+
* disabled-exact > disabled-wildcard > resident-exact > on-demand-exact >
|
|
124
|
+
* resident-wildcard > on-demand-wildcard > default (resident). `disabled` is a
|
|
125
|
+
* control decision, so it beats an explicit `resident` rule. Within
|
|
126
|
+
* resident/on-demand an exact name beats a wildcard, so the management UI can
|
|
127
|
+
* pin a single capability to a class even when a broader wildcard rule says
|
|
128
|
+
* otherwise (e.g. `tools.resident: ['mcp__gongfeng__*']` must not silently win
|
|
129
|
+
* over an explicit per-tool `on-demand` rule).
|
|
108
130
|
*/
|
|
109
131
|
export declare function classify(compiled: CompiledCapabilityRules, target: MatchTarget, metaTools?: ReadonlySet<string> | readonly string[]): CapabilityClass;
|
|
110
132
|
/**
|
|
@@ -117,12 +139,14 @@ export interface CapabilityClassification {
|
|
|
117
139
|
readonly kind: CapabilityKind;
|
|
118
140
|
/** Model-facing name (tool name or skill bare name). */
|
|
119
141
|
readonly name: string;
|
|
120
|
-
/**
|
|
142
|
+
/** Server namespace for tools (`built-in` for harness-native tools); undefined for skills. */
|
|
121
143
|
readonly server?: string;
|
|
144
|
+
/** Skill source root label, present only for skills. */
|
|
145
|
+
readonly source?: string;
|
|
122
146
|
readonly class: CapabilityClass;
|
|
123
147
|
/** Human-friendly display label for the classification. */
|
|
124
148
|
readonly classLabel: string;
|
|
125
|
-
/** True when this capability is a mandatory meta tool (always
|
|
149
|
+
/** True when this capability is a mandatory meta tool (always Resident). */
|
|
126
150
|
readonly mandatory: boolean;
|
|
127
151
|
}
|
|
128
152
|
/**
|
|
@@ -133,31 +157,30 @@ export interface CapabilityPolicyService {
|
|
|
133
157
|
classifyTool(name: string): CapabilityClass;
|
|
134
158
|
/** Classify a skill by its bare name. */
|
|
135
159
|
classifySkill(name: string): CapabilityClass;
|
|
136
|
-
/** True when a tool is
|
|
137
|
-
|
|
138
|
-
/** True when a skill is
|
|
139
|
-
|
|
140
|
-
/** True when a tool is
|
|
141
|
-
|
|
142
|
-
/** True when a skill is
|
|
143
|
-
|
|
144
|
-
/**
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
/** Tool names that are always kept Exposed. */
|
|
160
|
+
/** True when a tool is Resident (or a mandatory meta tool). */
|
|
161
|
+
isResidentTool(name: string): boolean;
|
|
162
|
+
/** True when a skill is Resident. */
|
|
163
|
+
isResidentSkill(name: string): boolean;
|
|
164
|
+
/** True when a tool is Disabled. */
|
|
165
|
+
isDisabledTool(name: string): boolean;
|
|
166
|
+
/** True when a skill is Disabled. */
|
|
167
|
+
isDisabledSkill(name: string): boolean;
|
|
168
|
+
/**
|
|
169
|
+
* True when a capability (by id and `kind`) is Disabled. `kind` disambiguates
|
|
170
|
+
* a bare name shared by a tool and a skill.
|
|
171
|
+
*/
|
|
172
|
+
isDisabledCapability(id: string, kind?: CapabilityKind): boolean;
|
|
173
|
+
/** Tool names that are always kept Resident. */
|
|
151
174
|
metaTools(): readonly string[];
|
|
152
|
-
/** Resolve a capability's id
|
|
153
|
-
classifyCapability(id: string): CapabilityClass;
|
|
154
|
-
/** Rules
|
|
175
|
+
/** Resolve a capability's id to a class; pass `kind` to disambiguate a bare name. */
|
|
176
|
+
classifyCapability(id: string, kind?: CapabilityKind): CapabilityClass;
|
|
177
|
+
/** Rules resident for the registry/other consumers. */
|
|
155
178
|
toolRules(): CompiledCapabilityRules;
|
|
156
179
|
skillRules(): CompiledCapabilityRules;
|
|
157
180
|
/** Current (resolved) policy config. */
|
|
158
181
|
getConfig(): Config;
|
|
159
182
|
/** Replace a subset of the policy config and recompile rules immediately. */
|
|
160
|
-
updateConfig(partial: Partial<Config>): void
|
|
183
|
+
updateConfig(partial: Partial<Config>): Promise<void>;
|
|
161
184
|
/**
|
|
162
185
|
* Classify every capability currently indexed by `ctx.capability` (the
|
|
163
186
|
* registry sibling). Returns an empty array when the registry is not mounted.
|
|
@@ -170,12 +193,12 @@ declare module '@deepseek-ai/cordis' {
|
|
|
170
193
|
}
|
|
171
194
|
}
|
|
172
195
|
/**
|
|
173
|
-
* Build the projection listener for one assembly: keep only
|
|
196
|
+
* Build the projection listener for one assembly: keep only Resident tools plus
|
|
174
197
|
* the mandatory meta tools.
|
|
175
198
|
*/
|
|
176
199
|
export declare function projectAssemblyTools(assembly: PromptAssembly, service: CapabilityPolicyService): PromptAssembly;
|
|
177
200
|
/** Build the policy plugin. */
|
|
178
201
|
export declare const name = "capability-menu-policy";
|
|
179
202
|
export declare const inject: string[];
|
|
180
|
-
export declare function apply(ctx: Context, config?: Config): void
|
|
203
|
+
export declare function apply(ctx: Context, config?: Config): Promise<void>;
|
|
181
204
|
//# sourceMappingURL=policy.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"policy.d.ts","sourceRoot":"","sources":["../../src/policy.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAA;AAClD,OAAO,CAAC,MAAM,0BAA0B,CAAA;AACxC,OAAO,KAAK,EAAE,cAAc,EAAE,M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c,GAAG,eAAe,CAAA;IACtE,uDAAuD;IACvD,SAAS,IAAI,uBAAuB,CAAA;IACpC,UAAU,IAAI,uBAAuB,CAAA;IAGrC,wCAAwC;IACxC,SAAS,IAAI,MAAM,CAAA;IACnB,6EAA6E;IAC7E,YAAY,CAAC,OAAO,EAAE,OAAO,CAAC,MAAM,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;IACrD;;;OAGG;IACH,WAAW,IAAI,SAAS,wBAAwB,EAAE,CAAA;CACnD;AAED,OAAO,QAAQ,qBAAqB,CAAC;IACnC,UAAU,OAAO;QACf,gBAAgB,EAAE,uBAAuB,CAAA;KAC1C;CACF;AAED;;;GAGG;AACH,wBAAgB,oBAAoB,CAClC,QAAQ,EAAE,cAAc,EACxB,OAAO,EAAE,uBAAuB,GAC/B,cAAc,CAIhB;AAED,+BAA+B;AAC/B,eAAO,MAAM,IAAI,2BAA2B,CAAA;AAK5C,eAAO,MAAM,MAAM,UAAoC,CAAA;AAEvD,wBAAsB,KAAK,CAAC,GAAG,EAAE,OAAO,EAAE,MAAM,GAAE,MAAW,GAAG,OAAO,CAAC,IAAI,CAAC,CAwM5E"}
|
package/lib/types/registry.d.ts
CHANGED
|
@@ -9,7 +9,8 @@ import type { ScopeKey } from '@deepseek-ai/dsh-scope';
|
|
|
9
9
|
import type { JsonSchemaNode } from '@deepseek-ai/dsh-tools';
|
|
10
10
|
/**
|
|
11
11
|
* Kinds of capability the catalog can hold.
|
|
12
|
-
* - `tool`: action capability — executes a concrete action (an MCP tool
|
|
12
|
+
* - `tool`: action capability — executes a concrete action (an MCP tool or a
|
|
13
|
+
* harness-native tool cataloged under the reserved `built-in` server).
|
|
13
14
|
* - `skill`: action capability — loads the method/instructions for a task.
|
|
14
15
|
*/
|
|
15
16
|
export type CapabilityKind = 'tool' | 'skill';
|
|
@@ -17,21 +18,41 @@ export type CapabilityKind = 'tool' | 'skill';
|
|
|
17
18
|
* Stable invocation actions a capability can declare. Each kind maps to one
|
|
18
19
|
* canonical action; a new kind only deserves a new value here when it
|
|
19
20
|
* introduces a new action (not a new flavor of an existing one).
|
|
20
|
-
* `execute` = run the concrete action (
|
|
21
|
+
* `execute` = run the concrete action (a tool — MCP or native — via `ctx.tools.execute`);
|
|
21
22
|
* `load` = load the method/instructions (a skill).
|
|
22
23
|
*/
|
|
23
24
|
export type CapabilityAction = 'execute' | 'load';
|
|
24
|
-
/**
|
|
25
|
-
|
|
25
|
+
/**
|
|
26
|
+
* Tool id prefixes are part of the REAL registered tool name: MCP tools are
|
|
27
|
+
* registered as `mcp__<server>__<raw>` by the harness MCP client and natives
|
|
28
|
+
* keep their bare name (`bash`/`read`/…), so tool records are keyed by that
|
|
29
|
+
* name. Skills have no name-level namespace: a skill's id IS its bare name and
|
|
30
|
+
* `kind` disambiguates it from a same-named tool.
|
|
31
|
+
*/
|
|
26
32
|
export declare const MCP_ID_PREFIX = "mcp__";
|
|
33
|
+
/**
|
|
34
|
+
* Reserved pseudo-server that groups harness-native (non-MCP) tools in the
|
|
35
|
+
* management surface. Native tools (bash/read/write/…) are cataloged like MCP
|
|
36
|
+
* tools — same `server` dimension — so the 能力管理 can group them, classify
|
|
37
|
+
* them Resident/On-demand/Disabled, and `meta_invoke` can dispatch them.
|
|
38
|
+
*/
|
|
39
|
+
export declare const BUILT_IN_SERVER = "built-in";
|
|
40
|
+
/**
|
|
41
|
+
* Tool names that never enter the capability catalog: this plugin's own
|
|
42
|
+
* control plane (`meta_search`/`meta_invoke`, always Resident) and the
|
|
43
|
+
* reserved Code Mode presentation transport (`run_code`).
|
|
44
|
+
*/
|
|
45
|
+
export declare const CATALOG_EXCLUDED_TOOLS: ReadonlySet<string>;
|
|
27
46
|
/** Capability-stable origin metadata used by search filters and detail views. */
|
|
28
47
|
export interface CapabilityOrigin {
|
|
29
|
-
/** Human/namespace label,
|
|
48
|
+
/** Human/namespace label: an MCP server name, the reserved `built-in` for native tools, or a skill provider. */
|
|
30
49
|
readonly provider: string;
|
|
31
|
-
/**
|
|
50
|
+
/** Server namespace, present only for `kind: 'tool'` (`built-in` for native tools). */
|
|
32
51
|
readonly serverName?: string;
|
|
33
52
|
/** Local skill path, present only for `kind: 'skill'`. */
|
|
34
53
|
readonly path?: string;
|
|
54
|
+
/** Skill source root label (`project-dsh`/`user-agents`/…), present only for skills. */
|
|
55
|
+
readonly source?: string;
|
|
35
56
|
}
|
|
36
57
|
/** Objective and subjective usage statistics, written back from `tools/result`. */
|
|
37
58
|
export interface CapabilityStats {
|
|
@@ -43,7 +64,7 @@ export interface CapabilityStats {
|
|
|
43
64
|
}
|
|
44
65
|
/** One indexed capability. */
|
|
45
66
|
export interface CapabilityRecord {
|
|
46
|
-
/** Stable identifier: `mcp__<server>__<raw
|
|
67
|
+
/** Stable identifier: `mcp__<server>__<raw>`, a native tool name, or a bare skill name. */
|
|
47
68
|
readonly id: string;
|
|
48
69
|
readonly kind: CapabilityKind;
|
|
49
70
|
/** The canonical invocation action(s) this capability exposes. */
|
|
@@ -72,6 +93,8 @@ export interface CapabilitySummary {
|
|
|
72
93
|
readonly name: string;
|
|
73
94
|
readonly summary: string;
|
|
74
95
|
readonly server?: string;
|
|
96
|
+
/** Skill source root label, present only for `kind: 'skill'`. */
|
|
97
|
+
readonly source?: string;
|
|
75
98
|
readonly tags: readonly string[];
|
|
76
99
|
readonly success_rate?: number;
|
|
77
100
|
readonly uses: number;
|
|
@@ -99,7 +122,7 @@ export interface MetaSearchOptions {
|
|
|
99
122
|
readonly maxResults?: number;
|
|
100
123
|
/**
|
|
101
124
|
* Viewing scope. Retained for caller ergonomics and optional authorization
|
|
102
|
-
* checks, but the policy does NOT use it to filter visibility —
|
|
125
|
+
* checks, but the policy does NOT use it to filter visibility — On-demand
|
|
103
126
|
* capabilities must remain searchable regardless of the caller's projection.
|
|
104
127
|
*/
|
|
105
128
|
readonly scope?: ScopeKey | undefined;
|
|
@@ -125,10 +148,17 @@ export interface SkillDirEntry {
|
|
|
125
148
|
export interface CapabilityService {
|
|
126
149
|
/** Enumerate the current catalog (optionally filtered). */
|
|
127
150
|
search(options?: MetaSearchOptions): CapabilitySummary[];
|
|
128
|
-
/**
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
151
|
+
/**
|
|
152
|
+
* Resolve one record by id, or undefined. Pass `kind` when the caller knows
|
|
153
|
+
* it (tools and skills may share a bare name, e.g. a skill named `bash`);
|
|
154
|
+
* without `kind` a same-name tool/skill pair resolves to undefined.
|
|
155
|
+
*/
|
|
156
|
+
get(id: string, kind?: CapabilityKind): CapabilityRecord | undefined;
|
|
157
|
+
/**
|
|
158
|
+
* Resolve one record's full detail (schema, output; skill body optional).
|
|
159
|
+
* `kind` has the same disambiguation semantics as {@link get}.
|
|
160
|
+
*/
|
|
161
|
+
getDetail(id: string, kind?: CapabilityKind, context?: MetaLookupContext): Promise<CapabilityDetail | undefined>;
|
|
132
162
|
/**
|
|
133
163
|
* List a skill's directory children (one level deep). The directory is
|
|
134
164
|
* resolved from the skill's own provider path, never from caller input;
|
|
@@ -144,11 +174,23 @@ export interface CapabilityService {
|
|
|
144
174
|
readSkillFile(id: string, relPath: string): Promise<string | undefined>;
|
|
145
175
|
/** Return the current number of indexed capabilities. */
|
|
146
176
|
size(): number;
|
|
177
|
+
/**
|
|
178
|
+
* Absolute path of the on-demand capability catalog YAML, when emission is
|
|
179
|
+
* enabled. The model can browse this file with grep/read instead of only
|
|
180
|
+
* reaching the catalog through `meta_search`.
|
|
181
|
+
*/
|
|
182
|
+
catalogPath(): string | undefined;
|
|
183
|
+
/**
|
|
184
|
+
* Number of On-demand capabilities in the latest catalog emission. Used by
|
|
185
|
+
* the policy's assemble hook to skip the catalog pointer when there is
|
|
186
|
+
* nothing On-demand to browse.
|
|
187
|
+
*/
|
|
188
|
+
onDemandCount(): number;
|
|
147
189
|
/**
|
|
148
190
|
* Rebuild the catalog from the current tool/skill registries; resolves when
|
|
149
191
|
* done. In production the registry rebuilds automatically on `tools/change`
|
|
150
192
|
* / `skills/change`; this public handle is for tests and external orchestrators
|
|
151
|
-
* that want to force a rebuild
|
|
193
|
+
* that want to force a rebuild.
|
|
152
194
|
*/
|
|
153
195
|
refresh(): Promise<void>;
|
|
154
196
|
}
|
|
@@ -168,13 +210,12 @@ export interface Config {
|
|
|
168
210
|
/** Experience-weighting intensity for ranking (0 disables, default 0.1). */
|
|
169
211
|
weighting?: number;
|
|
170
212
|
/**
|
|
171
|
-
* Optional path
|
|
172
|
-
*
|
|
173
|
-
*
|
|
174
|
-
*
|
|
175
|
-
* SKILL.md is loaded on demand by `meta_invoke` (see the invoke package).
|
|
213
|
+
* Optional path for the on-demand capability catalog emitted as a YAML file
|
|
214
|
+
* for model-side grep/read browsing. Defaults to
|
|
215
|
+
* `~/.dsh/capability-catalog.yaml`; set to an empty string to disable
|
|
216
|
+
* emission. Disabled capabilities are never written.
|
|
176
217
|
*/
|
|
177
|
-
|
|
218
|
+
catalogFile?: string;
|
|
178
219
|
}
|
|
179
220
|
/** Validate and default the registry configuration. */
|
|
180
221
|
export declare const Config: z<Config>;
|
|
@@ -184,8 +225,4 @@ export declare const inject: string[];
|
|
|
184
225
|
export declare function apply(ctx: Context, config?: Config): void;
|
|
185
226
|
/** Derive the server namespace from an `mcp__<server>__<raw>` name. */
|
|
186
227
|
export declare function serverNameOf(publicName: string): string;
|
|
187
|
-
/** Build the stable skill identifier `skill:<name>`. */
|
|
188
|
-
export declare function skillId(name: string): string;
|
|
189
|
-
/** Strip the `skill:` prefix from a capability id. */
|
|
190
|
-
export declare function skillNameOf(id: string): string;
|
|
191
228
|
//# sourceMappingURL=registry.d.ts.map
|