@daweifu/capability-menu 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.md +206 -0
- package/cordis.patch.yml +87 -0
- package/lib/index.js +20 -0
- package/lib/invariant.js +22 -0
- package/lib/invoke.js +299 -0
- package/lib/policy.js +264 -0
- package/lib/registry.js +509 -0
- package/lib/search.js +127 -0
- package/lib/types/index.d.ts +20 -0
- package/lib/types/invariant.d.ts +16 -0
- package/lib/types/invoke.d.ts +80 -0
- package/lib/types/policy.d.ts +181 -0
- package/lib/types/registry.d.ts +191 -0
- package/lib/types/search.d.ts +43 -0
- package/package.json +85 -0
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Model-facing `meta_invoke` tool: unified execution/loading of capabilities.
|
|
3
|
+
*
|
|
4
|
+
* @module @daweifu/capability-menu (invoke plugin)
|
|
5
|
+
*/
|
|
6
|
+
import type { Context } from '@deepseek-ai/cordis';
|
|
7
|
+
import z from '@deepseek-ai/schemastery';
|
|
8
|
+
import type { ContentBlock } from '@deepseek-ai/dsh-llm';
|
|
9
|
+
import { type SkillResourceBase } from '@deepseek-ai/dsh-skill';
|
|
10
|
+
export declare const name = "capability-menu-invoke";
|
|
11
|
+
export declare const inject: string[];
|
|
12
|
+
/** Forwarding mode for the MCP branch. */
|
|
13
|
+
export type MetaForwardMode = 'direct' | 'resolve';
|
|
14
|
+
/** Model-facing `meta_invoke` configuration. */
|
|
15
|
+
export interface Config {
|
|
16
|
+
/** How to forward MCP calls: `direct` executes via the tool pipeline; `resolve` returns the schema for the model to call directly. */
|
|
17
|
+
forwardMode?: MetaForwardMode;
|
|
18
|
+
}
|
|
19
|
+
/** Validate and default the tool configuration. */
|
|
20
|
+
export declare const Config: z<Config>;
|
|
21
|
+
/** Canonical MCP result shape. */
|
|
22
|
+
export interface MetaInvokeMcpDetail {
|
|
23
|
+
readonly forwarded: true;
|
|
24
|
+
readonly target: string;
|
|
25
|
+
readonly content: ContentBlock[];
|
|
26
|
+
}
|
|
27
|
+
/** Canonical skill result shape (matches the `skill` tool output). */
|
|
28
|
+
export interface MetaInvokeSkillDetail {
|
|
29
|
+
readonly name: string;
|
|
30
|
+
readonly provider: string;
|
|
31
|
+
readonly resourceBase?: SkillResourceBase;
|
|
32
|
+
readonly content: string;
|
|
33
|
+
}
|
|
34
|
+
/** Canonical resolve-mode result shape (forwardMode: 'resolve'). */
|
|
35
|
+
export interface MetaInvokeResolveDetail {
|
|
36
|
+
readonly target: string;
|
|
37
|
+
readonly kind: string;
|
|
38
|
+
readonly name: string;
|
|
39
|
+
readonly description: string;
|
|
40
|
+
readonly parameters: unknown;
|
|
41
|
+
}
|
|
42
|
+
/** Discriminated canonical result. */
|
|
43
|
+
export type MetaInvokeResult = {
|
|
44
|
+
ok: true;
|
|
45
|
+
kind: 'mcp';
|
|
46
|
+
id: string;
|
|
47
|
+
detail: MetaInvokeMcpDetail;
|
|
48
|
+
} | {
|
|
49
|
+
ok: true;
|
|
50
|
+
kind: 'skill';
|
|
51
|
+
id: string;
|
|
52
|
+
detail: MetaInvokeSkillDetail;
|
|
53
|
+
} | {
|
|
54
|
+
ok: true;
|
|
55
|
+
kind: 'resolve';
|
|
56
|
+
id: string;
|
|
57
|
+
detail: MetaInvokeResolveDetail;
|
|
58
|
+
};
|
|
59
|
+
/**
|
|
60
|
+
* Register the `meta_invoke` tool.
|
|
61
|
+
*
|
|
62
|
+
* Dispatch is by `capability.kind`, not by id prefix (the id-prefix check is
|
|
63
|
+
* kept only as a defensive guard alongside the kind check).
|
|
64
|
+
*
|
|
65
|
+
* - Tools (`kind: 'tool'`, id `mcp__...`): forwards to the underlying server
|
|
66
|
+
* call via the official `ctx.tools.execute` pipeline, preserving
|
|
67
|
+
* `agent`/`signal`/parent lineage. `forwardMode: 'resolve'` instead returns
|
|
68
|
+
* the target schema so the model can call the tool directly.
|
|
69
|
+
* - Skills (`kind: 'skill'`, id `skill:<name>`): loads the full skill
|
|
70
|
+
* instructions and returns them as `<skill_content>` — no args, no script
|
|
71
|
+
* execution (matches the existing `skill` tool semantics).
|
|
72
|
+
*/
|
|
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
|
+
//# sourceMappingURL=invoke.d.ts.map
|
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Exposed / Progressive / Blocked capability projection policy for the DeepSeek
|
|
3
|
+
* Harness.
|
|
4
|
+
*
|
|
5
|
+
* @module @daweifu/capability-menu (policy plugin)
|
|
6
|
+
*/
|
|
7
|
+
import type { Context } from '@deepseek-ai/cordis';
|
|
8
|
+
import z from '@deepseek-ai/schemastery';
|
|
9
|
+
import type { PromptAssembly } from '@deepseek-ai/dsh-system-prompt';
|
|
10
|
+
import { type CapabilityKind } from './registry.ts';
|
|
11
|
+
/**
|
|
12
|
+
* Canonical policy classes, mirroring the registry's `CapabilityKind`.
|
|
13
|
+
*
|
|
14
|
+
* - `exposed`: the capability is on the dsh-native exposure surface — tools in
|
|
15
|
+
* `assembly.tools` (the request `tools` payload), skills in the
|
|
16
|
+
* `<available_skills>` catalog — so the model can call/load it single-hop.
|
|
17
|
+
* - `progressive`: absent from the native surface but discoverable in the
|
|
18
|
+
* persistent meta registry; the model reaches it via `meta_search` then
|
|
19
|
+
* `meta_invoke` (catalog-resident, load/execute on demand).
|
|
20
|
+
* - `blocked`: neither exposed nor discoverable nor executable.
|
|
21
|
+
*/
|
|
22
|
+
export type CapabilityClass = 'exposed' | 'progressive' | 'blocked';
|
|
23
|
+
/**
|
|
24
|
+
* A single classify rule: an exact name or a `*`-glob pattern.
|
|
25
|
+
* A pattern matches a capability id (`mcp__<server>__<raw>` / `skill:<name>`)
|
|
26
|
+
* or a server name (`server:<name>`).
|
|
27
|
+
*/
|
|
28
|
+
export interface PolicyRule {
|
|
29
|
+
/** Whether the rule is a literal exact name (`*` free) or a glob pattern. */
|
|
30
|
+
readonly wildcard: boolean;
|
|
31
|
+
/** The normalized pattern/literal this rule represents. */
|
|
32
|
+
readonly pattern: string;
|
|
33
|
+
/** When non-empty, this rule only applies to the given capability kind. */
|
|
34
|
+
readonly kind?: CapabilityKind;
|
|
35
|
+
/** When `'server'`, the pattern is matched against the server name only. */
|
|
36
|
+
readonly target: 'id' | 'server';
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Per-kind explicit configuration. `exposed`/`progressive`/`blocked` are
|
|
40
|
+
* ordered lists of exact-name / glob rules. Empty lists mean "nothing
|
|
41
|
+
* explicitly classified", so the default (`exposed`) applies.
|
|
42
|
+
*/
|
|
43
|
+
export interface CapabilitySetConfig {
|
|
44
|
+
/** Explicitly-Exposed rule list (exact name or glob). */
|
|
45
|
+
exposed?: string[];
|
|
46
|
+
/** Explicitly-Progressive rule list (exact name or glob). */
|
|
47
|
+
progressive?: string[];
|
|
48
|
+
/** Explicitly-Blocked rule list (exact name or glob); wins over everything. */
|
|
49
|
+
blocked?: string[];
|
|
50
|
+
}
|
|
51
|
+
/** Exposed / Progressive / Blocked projection policy configuration. */
|
|
52
|
+
export interface Config {
|
|
53
|
+
/** Tool classification: `tools.exposed` / `tools.progressive` / `tools.blocked`. */
|
|
54
|
+
tools?: CapabilitySetConfig;
|
|
55
|
+
/** Skill classification: `skills.exposed` / `skills.progressive` / `skills.blocked`. */
|
|
56
|
+
skills?: CapabilitySetConfig;
|
|
57
|
+
/**
|
|
58
|
+
* Tool names that are ALWAYS kept exposed and can never be classified
|
|
59
|
+
* Progressive or Blocked. Default `[meta_search, meta_invoke]`.
|
|
60
|
+
*/
|
|
61
|
+
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
|
+
}
|
|
69
|
+
/** Validate and default the policy configuration. */
|
|
70
|
+
export declare const Config: z<Config>;
|
|
71
|
+
export declare const DEFAULT_META_TOOLS: readonly ["meta_search", "meta_invoke"];
|
|
72
|
+
/**
|
|
73
|
+
* Convert a user-facing rule string into a normalized {@link PolicyRule}.
|
|
74
|
+
* - `server:<name>` → server-targeted rule (`target: 'server'`).
|
|
75
|
+
* - `server:<name>:*` → server-targeted glob over that server's tools.
|
|
76
|
+
* - contains `*` → glob (target `id`).
|
|
77
|
+
* - otherwise → literal exact name.
|
|
78
|
+
*/
|
|
79
|
+
export declare function parseRule(rule: string): PolicyRule;
|
|
80
|
+
/** Compile a `*`-glob into a RegExp (escaped, `*` → `.*`). */
|
|
81
|
+
export declare function compileGlob(pattern: string): RegExp;
|
|
82
|
+
/** A compiled rule set for one capability kind. */
|
|
83
|
+
export interface CompiledCapabilityRules {
|
|
84
|
+
readonly exposed: readonly PolicyRule[];
|
|
85
|
+
readonly progressive: readonly PolicyRule[];
|
|
86
|
+
readonly blocked: readonly PolicyRule[];
|
|
87
|
+
}
|
|
88
|
+
/** Compile a {@link CapabilitySetConfig} into fast-matchable rules. */
|
|
89
|
+
export declare function compileSet(set?: CapabilitySetConfig): CompiledCapabilityRules;
|
|
90
|
+
/** Candidate fields a rule is matched against. */
|
|
91
|
+
export interface MatchTarget {
|
|
92
|
+
/** Full capability id: `mcp__<server>__<raw>` or `skill:<name>`. */
|
|
93
|
+
readonly id: string;
|
|
94
|
+
/** Bare model-facing name (tool name or skill name without `skill:` prefix). */
|
|
95
|
+
readonly name: string;
|
|
96
|
+
/** Server name for tools; undefined for skills. */
|
|
97
|
+
readonly server?: string;
|
|
98
|
+
/** Capability kind. */
|
|
99
|
+
readonly kind: CapabilityKind;
|
|
100
|
+
/** Rule kind the candidates belong to (mirrors `kind` for tool/skill rule sets). */
|
|
101
|
+
readonly ruleKind: CapabilityKind;
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Classify a capability against compiled rules. Priority (hit stops the walk):
|
|
105
|
+
* blocked-exact > blocked-wildcard > exposed-exact > exposed-wildcard >
|
|
106
|
+
* progressive-exact > progressive-wildcard > default (exposed). `blocked`
|
|
107
|
+
* is a control decision, so it beats an explicit `exposed` rule.
|
|
108
|
+
*/
|
|
109
|
+
export declare function classify(compiled: CompiledCapabilityRules, target: MatchTarget, metaTools?: ReadonlySet<string> | readonly string[]): CapabilityClass;
|
|
110
|
+
/**
|
|
111
|
+
* One capability's classification, as surfaced to a management UI.
|
|
112
|
+
* `class` is the machine-facing value; `classLabel` is a human-friendly
|
|
113
|
+
* display that ties the residency strategy to the model-facing relationship.
|
|
114
|
+
*/
|
|
115
|
+
export interface CapabilityClassification {
|
|
116
|
+
readonly id: string;
|
|
117
|
+
readonly kind: CapabilityKind;
|
|
118
|
+
/** Model-facing name (tool name or skill bare name). */
|
|
119
|
+
readonly name: string;
|
|
120
|
+
/** MCP server for tools; undefined for skills. */
|
|
121
|
+
readonly server?: string;
|
|
122
|
+
readonly class: CapabilityClass;
|
|
123
|
+
/** Human-friendly display label for the classification. */
|
|
124
|
+
readonly classLabel: string;
|
|
125
|
+
/** True when this capability is a mandatory meta tool (always Exposed). */
|
|
126
|
+
readonly mandatory: boolean;
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* The `ctx.capabilityPolicy` service surface.
|
|
130
|
+
*/
|
|
131
|
+
export interface CapabilityPolicyService {
|
|
132
|
+
/** Classify a tool by its public name (`mcp__<server>__<raw>` or meta tool). */
|
|
133
|
+
classifyTool(name: string): CapabilityClass;
|
|
134
|
+
/** Classify a skill by its bare name. */
|
|
135
|
+
classifySkill(name: string): CapabilityClass;
|
|
136
|
+
/** True when a tool is Exposed (or a mandatory meta tool). */
|
|
137
|
+
isExposedTool(name: string): boolean;
|
|
138
|
+
/** True when a skill is Exposed. */
|
|
139
|
+
isExposedSkill(name: string): boolean;
|
|
140
|
+
/** True when a tool is Progressive. */
|
|
141
|
+
isProgressiveTool(name: string): boolean;
|
|
142
|
+
/** True when a skill is Progressive. */
|
|
143
|
+
isProgressiveSkill(name: string): boolean;
|
|
144
|
+
/** True when a tool is Blocked. */
|
|
145
|
+
isBlockedTool(name: string): boolean;
|
|
146
|
+
/** True when a skill is Blocked. */
|
|
147
|
+
isBlockedSkill(name: string): boolean;
|
|
148
|
+
/** True when a capability id (`mcp__...` / `skill:...`) is Blocked. */
|
|
149
|
+
isBlockedCapability(id: string): boolean;
|
|
150
|
+
/** Tool names that are always kept Exposed. */
|
|
151
|
+
metaTools(): readonly string[];
|
|
152
|
+
/** Resolve a capability's id (e.g. `skill:<name>`) to a class. */
|
|
153
|
+
classifyCapability(id: string): CapabilityClass;
|
|
154
|
+
/** Rules exposed for the registry/other consumers. */
|
|
155
|
+
toolRules(): CompiledCapabilityRules;
|
|
156
|
+
skillRules(): CompiledCapabilityRules;
|
|
157
|
+
/** Current (resolved) policy config. */
|
|
158
|
+
getConfig(): Config;
|
|
159
|
+
/** Replace a subset of the policy config and recompile rules immediately. */
|
|
160
|
+
updateConfig(partial: Partial<Config>): void;
|
|
161
|
+
/**
|
|
162
|
+
* Classify every capability currently indexed by `ctx.meta` (the registry
|
|
163
|
+
* sibling). Returns an empty array when the registry is not mounted.
|
|
164
|
+
*/
|
|
165
|
+
classifyAll(): readonly CapabilityClassification[];
|
|
166
|
+
}
|
|
167
|
+
declare module '@deepseek-ai/cordis' {
|
|
168
|
+
interface Context {
|
|
169
|
+
capabilityPolicy: CapabilityPolicyService;
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
/**
|
|
173
|
+
* Build the projection listener for one assembly: keep only Exposed tools plus
|
|
174
|
+
* the mandatory meta tools.
|
|
175
|
+
*/
|
|
176
|
+
export declare function projectAssemblyTools(assembly: PromptAssembly, service: CapabilityPolicyService): PromptAssembly;
|
|
177
|
+
/** Build the policy plugin. */
|
|
178
|
+
export declare const name = "capability-menu-policy";
|
|
179
|
+
export declare const inject: string[];
|
|
180
|
+
export declare function apply(ctx: Context, config?: Config): void;
|
|
181
|
+
//# sourceMappingURL=policy.d.ts.map
|
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Unified capability catalog for the DeepSeek Harness.
|
|
3
|
+
*
|
|
4
|
+
* @module @daweifu/capability-menu (registry plugin)
|
|
5
|
+
*/
|
|
6
|
+
import type { Context } from '@deepseek-ai/cordis';
|
|
7
|
+
import z from '@deepseek-ai/schemastery';
|
|
8
|
+
import type { ScopeKey } from '@deepseek-ai/dsh-scope';
|
|
9
|
+
import type { JsonSchemaNode } from '@deepseek-ai/dsh-tools';
|
|
10
|
+
/**
|
|
11
|
+
* Kinds of capability the catalog can hold.
|
|
12
|
+
* - `tool`: action capability — executes a concrete action (an MCP tool).
|
|
13
|
+
* - `skill`: action capability — loads the method/instructions for a task.
|
|
14
|
+
*/
|
|
15
|
+
export type CapabilityKind = 'tool' | 'skill';
|
|
16
|
+
/**
|
|
17
|
+
* Stable invocation actions a capability can declare. Each kind maps to one
|
|
18
|
+
* canonical action; a new kind only deserves a new value here when it
|
|
19
|
+
* introduces a new action (not a new flavor of an existing one).
|
|
20
|
+
* `execute` = run the concrete action (an MCP tool, via `ctx.tools.execute`);
|
|
21
|
+
* `load` = load the method/instructions (a skill).
|
|
22
|
+
*/
|
|
23
|
+
export type CapabilityAction = 'execute' | 'load';
|
|
24
|
+
/** Stable identifier prefixes: MCP tools keep `mcp__...`, skills use `skill:<name>`. */
|
|
25
|
+
export declare const SKILL_ID_PREFIX = "skill:";
|
|
26
|
+
export declare const MCP_ID_PREFIX = "mcp__";
|
|
27
|
+
/** Capability-stable origin metadata used by search filters and detail views. */
|
|
28
|
+
export interface CapabilityOrigin {
|
|
29
|
+
/** Human/namespace label, e.g. `gongfeng` or `filesystem`. */
|
|
30
|
+
readonly provider: string;
|
|
31
|
+
/** MCP server name, present only for `kind: 'tool'`. */
|
|
32
|
+
readonly serverName?: string;
|
|
33
|
+
/** Local skill path, present only for `kind: 'skill'`. */
|
|
34
|
+
readonly path?: string;
|
|
35
|
+
}
|
|
36
|
+
/** Objective and subjective usage statistics, written back from `tools/result`. */
|
|
37
|
+
export interface CapabilityStats {
|
|
38
|
+
readonly uses: number;
|
|
39
|
+
readonly successes: number;
|
|
40
|
+
readonly failures: number;
|
|
41
|
+
readonly totalMs: number;
|
|
42
|
+
readonly lastUsedAt?: number;
|
|
43
|
+
}
|
|
44
|
+
/** One indexed capability. */
|
|
45
|
+
export interface CapabilityRecord {
|
|
46
|
+
/** Stable identifier: `mcp__<server>__<raw>` or `skill:<name>`. */
|
|
47
|
+
readonly id: string;
|
|
48
|
+
readonly kind: CapabilityKind;
|
|
49
|
+
/** The canonical invocation action(s) this capability exposes. */
|
|
50
|
+
readonly actions: readonly CapabilityAction[];
|
|
51
|
+
/** Model-facing name (the tool name or skill name without prefix). */
|
|
52
|
+
readonly name: string;
|
|
53
|
+
readonly description: string;
|
|
54
|
+
/** Skill-only extra routing guidance. */
|
|
55
|
+
readonly whenToUse?: string;
|
|
56
|
+
readonly origin: CapabilityOrigin;
|
|
57
|
+
/** Full parameter schema (MCP inputSchema / empty object for skills). */
|
|
58
|
+
readonly parameters: JsonSchemaNode;
|
|
59
|
+
readonly invocation: {
|
|
60
|
+
modelInvocable: boolean;
|
|
61
|
+
userInvocable: boolean;
|
|
62
|
+
};
|
|
63
|
+
readonly tags: readonly string[];
|
|
64
|
+
readonly stats: CapabilityStats;
|
|
65
|
+
/** Token-trimmed short description used by `meta_search` list mode. */
|
|
66
|
+
readonly summary: string;
|
|
67
|
+
}
|
|
68
|
+
/** Lightweight list-mode projection of one capability (no full schema). */
|
|
69
|
+
export interface CapabilitySummary {
|
|
70
|
+
readonly id: string;
|
|
71
|
+
readonly kind: CapabilityKind;
|
|
72
|
+
readonly name: string;
|
|
73
|
+
readonly summary: string;
|
|
74
|
+
readonly server?: string;
|
|
75
|
+
readonly tags: readonly string[];
|
|
76
|
+
readonly success_rate?: number;
|
|
77
|
+
readonly uses: number;
|
|
78
|
+
}
|
|
79
|
+
/** Full detail projection, including the parameter schema. */
|
|
80
|
+
export interface CapabilityDetail {
|
|
81
|
+
readonly id: string;
|
|
82
|
+
readonly kind: CapabilityKind;
|
|
83
|
+
readonly actions: readonly CapabilityAction[];
|
|
84
|
+
readonly name: string;
|
|
85
|
+
readonly description: string;
|
|
86
|
+
readonly whenToUse?: string;
|
|
87
|
+
readonly parameters: JsonSchemaNode;
|
|
88
|
+
readonly output?: JsonSchemaNode;
|
|
89
|
+
readonly origin: CapabilityOrigin;
|
|
90
|
+
readonly tags: readonly string[];
|
|
91
|
+
readonly stats: CapabilityStats;
|
|
92
|
+
}
|
|
93
|
+
/** Search filter options. */
|
|
94
|
+
export interface MetaSearchOptions {
|
|
95
|
+
readonly kind?: CapabilityKind | 'all';
|
|
96
|
+
readonly server?: string | undefined;
|
|
97
|
+
readonly tag?: string | undefined;
|
|
98
|
+
/** Maximum number of results to return. */
|
|
99
|
+
readonly maxResults?: number;
|
|
100
|
+
/**
|
|
101
|
+
* Viewing scope. Retained for caller ergonomics and optional authorization
|
|
102
|
+
* checks, but the policy does NOT use it to filter visibility — Progressive
|
|
103
|
+
* capabilities must remain searchable regardless of the caller's projection.
|
|
104
|
+
*/
|
|
105
|
+
readonly scope?: ScopeKey | undefined;
|
|
106
|
+
/** Query string for keyword matching; exact id/name match wins. */
|
|
107
|
+
readonly query?: string;
|
|
108
|
+
/** Exact capability id. */
|
|
109
|
+
readonly id?: string;
|
|
110
|
+
/** Whether to include the full body for skills in `getDetail` (default false). */
|
|
111
|
+
readonly detailIncludesBody?: boolean;
|
|
112
|
+
}
|
|
113
|
+
/** Runtime detail resolution context. */
|
|
114
|
+
export interface MetaLookupContext {
|
|
115
|
+
readonly cwd?: string | undefined;
|
|
116
|
+
readonly signal?: AbortSignal | undefined;
|
|
117
|
+
readonly scope?: ScopeKey | undefined;
|
|
118
|
+
}
|
|
119
|
+
/** One direct child in a skill directory listing. */
|
|
120
|
+
export interface SkillDirEntry {
|
|
121
|
+
readonly name: string;
|
|
122
|
+
readonly type: 'file' | 'directory';
|
|
123
|
+
}
|
|
124
|
+
/** The `ctx.meta` service surface. */
|
|
125
|
+
export interface MetaService {
|
|
126
|
+
/** Enumerate the current catalog (optionally filtered). */
|
|
127
|
+
search(options?: MetaSearchOptions): CapabilitySummary[];
|
|
128
|
+
/** Resolve one record by id, or undefined. */
|
|
129
|
+
get(id: string): CapabilityRecord | undefined;
|
|
130
|
+
/** Resolve one record's full detail (schema, output; skill body optional). */
|
|
131
|
+
getDetail(id: string, context?: MetaLookupContext): Promise<CapabilityDetail | undefined>;
|
|
132
|
+
/**
|
|
133
|
+
* List a skill's directory children (one level deep). The directory is
|
|
134
|
+
* resolved from the skill's own provider path, never from caller input;
|
|
135
|
+
* `relPath` (optional, relative to the skill root) descends into a child
|
|
136
|
+
* directory.
|
|
137
|
+
*/
|
|
138
|
+
listSkillDir(id: string, relPath?: string): Promise<SkillDirEntry[] | undefined>;
|
|
139
|
+
/**
|
|
140
|
+
* Read a text file inside a skill's directory, addressed by a relative path
|
|
141
|
+
* that is resolved against and confined to the skill root. Binary files
|
|
142
|
+
* (content containing NUL) return undefined.
|
|
143
|
+
*/
|
|
144
|
+
readSkillFile(id: string, relPath: string): Promise<string | undefined>;
|
|
145
|
+
/** Return the current number of indexed capabilities. */
|
|
146
|
+
size(): number;
|
|
147
|
+
/**
|
|
148
|
+
* Rebuild the catalog from the current tool/skill registries; resolves when
|
|
149
|
+
* done. In production the registry rebuilds automatically on `tools/change`
|
|
150
|
+
* / `skills/change`; this public handle is for tests and external orchestrators
|
|
151
|
+
* that want to force a rebuild (e.g. after a `progressiveSkillCatalog` change).
|
|
152
|
+
*/
|
|
153
|
+
refresh(): Promise<void>;
|
|
154
|
+
}
|
|
155
|
+
declare module '@deepseek-ai/cordis' {
|
|
156
|
+
interface Context {
|
|
157
|
+
meta: MetaService;
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
/** Registry configuration. */
|
|
161
|
+
export interface Config {
|
|
162
|
+
/** Maximum summary length in characters (min 20). */
|
|
163
|
+
summaryMaxChars?: number;
|
|
164
|
+
/** Whether to include the skill body in `getDetail` results (default false). */
|
|
165
|
+
detailIncludesBody?: boolean;
|
|
166
|
+
/** Maximum search results returned (default 20, max 100). */
|
|
167
|
+
maxResults?: number;
|
|
168
|
+
/** Experience-weighting intensity for ranking (0 disables, default 0.1). */
|
|
169
|
+
weighting?: number;
|
|
170
|
+
/**
|
|
171
|
+
* Optional path to a Progressive-skill catalog YAML (see §7.2). Each entry
|
|
172
|
+
* `{ name, description, whenToUse?, path? }` is indexed as a `skill`
|
|
173
|
+
* CapabilityRecord so `meta_search(kind=skill)` can find Progressive skills
|
|
174
|
+
* that are not otherwise registered in the session skill registry. The full
|
|
175
|
+
* SKILL.md is loaded on demand by `meta_invoke` (see the invoke package).
|
|
176
|
+
*/
|
|
177
|
+
progressiveSkillCatalog?: string;
|
|
178
|
+
}
|
|
179
|
+
/** Validate and default the registry configuration. */
|
|
180
|
+
export declare const Config: z<Config>;
|
|
181
|
+
/** Build the registry plugin. */
|
|
182
|
+
export declare const name = "capability-menu-registry";
|
|
183
|
+
export declare const inject: string[];
|
|
184
|
+
export declare function apply(ctx: Context, config?: Config): void;
|
|
185
|
+
/** Derive the server namespace from an `mcp__<server>__<raw>` name. */
|
|
186
|
+
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
|
+
//# sourceMappingURL=registry.d.ts.map
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Model-facing `meta_search` tool: capability catalog search + detail.
|
|
3
|
+
*
|
|
4
|
+
* @module @daweifu/capability-menu (search plugin)
|
|
5
|
+
*/
|
|
6
|
+
import type { Context } from '@deepseek-ai/cordis';
|
|
7
|
+
import z from '@deepseek-ai/schemastery';
|
|
8
|
+
import type { CapabilityDetail, CapabilitySummary } from './registry.ts';
|
|
9
|
+
export declare const name = "capability-menu-search";
|
|
10
|
+
export declare const inject: string[];
|
|
11
|
+
/** Model-facing `meta_search` configuration. */
|
|
12
|
+
export interface Config {
|
|
13
|
+
/** Maximum results returned in list mode (default 20). */
|
|
14
|
+
maxResults?: number;
|
|
15
|
+
}
|
|
16
|
+
/** Validate and default the tool configuration. */
|
|
17
|
+
export declare const Config: z<Config>;
|
|
18
|
+
/** Canonical list-mode result. */
|
|
19
|
+
export interface MetaSearchListResult {
|
|
20
|
+
readonly mode: 'list';
|
|
21
|
+
readonly total: number;
|
|
22
|
+
readonly results: CapabilitySummary[];
|
|
23
|
+
readonly hint: string;
|
|
24
|
+
}
|
|
25
|
+
/** Canonical detail-mode result. */
|
|
26
|
+
export interface MetaSearchDetailResult {
|
|
27
|
+
readonly mode: 'detail';
|
|
28
|
+
readonly result: CapabilityDetail;
|
|
29
|
+
}
|
|
30
|
+
/** Canonical tool result: one of the two modes. */
|
|
31
|
+
export type MetaSearchResult = MetaSearchListResult | MetaSearchDetailResult;
|
|
32
|
+
/**
|
|
33
|
+
* Register the `meta_search` tool.
|
|
34
|
+
*
|
|
35
|
+
* - Mode A (list, default): query by keyword/tag/server, returns id + short summary.
|
|
36
|
+
* - Mode B (detail): pass an exact id (optionally `detail: true`) to get the full schema.
|
|
37
|
+
*
|
|
38
|
+
* Validation rules enforced here:
|
|
39
|
+
* - `query` and `id` are mutually exclusive.
|
|
40
|
+
* - `detail: true` with a fuzzy query (no exact id) is rejected.
|
|
41
|
+
*/
|
|
42
|
+
export declare function apply(ctx: Context, config?: Config): void;
|
|
43
|
+
//# sourceMappingURL=search.d.ts.map
|
package/package.json
ADDED
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@daweifu/capability-menu",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Unified capability management for the DeepSeek Harness: catalog (registry) + meta_search/meta_invoke + Exposed/Progressive/Blocked projection policy + 能力管理 surface, in one installable bundle.",
|
|
5
|
+
"license": "Apache-2.0",
|
|
6
|
+
"publishConfig": {
|
|
7
|
+
"access": "public"
|
|
8
|
+
},
|
|
9
|
+
"type": "module",
|
|
10
|
+
"main": "lib/index.js",
|
|
11
|
+
"types": "lib/types/index.d.ts",
|
|
12
|
+
"scripts": {
|
|
13
|
+
"build": "tsc -p tsconfig.json",
|
|
14
|
+
"typecheck": "tsc -p tsconfig.json --noEmit",
|
|
15
|
+
"test": "vitest run",
|
|
16
|
+
"prepare": "npm run build"
|
|
17
|
+
},
|
|
18
|
+
"exports": {
|
|
19
|
+
".": {
|
|
20
|
+
"types": "./lib/types/index.d.ts",
|
|
21
|
+
"default": "./lib/index.js"
|
|
22
|
+
},
|
|
23
|
+
"./registry": {
|
|
24
|
+
"types": "./lib/types/registry.d.ts",
|
|
25
|
+
"default": "./lib/registry.js"
|
|
26
|
+
},
|
|
27
|
+
"./search": {
|
|
28
|
+
"types": "./lib/types/search.d.ts",
|
|
29
|
+
"default": "./lib/search.js"
|
|
30
|
+
},
|
|
31
|
+
"./invoke": {
|
|
32
|
+
"types": "./lib/types/invoke.d.ts",
|
|
33
|
+
"default": "./lib/invoke.js"
|
|
34
|
+
},
|
|
35
|
+
"./policy": {
|
|
36
|
+
"types": "./lib/types/policy.d.ts",
|
|
37
|
+
"default": "./lib/policy.js"
|
|
38
|
+
},
|
|
39
|
+
"./invariant": {
|
|
40
|
+
"types": "./lib/types/invariant.d.ts",
|
|
41
|
+
"default": "./lib/invariant.js"
|
|
42
|
+
},
|
|
43
|
+
"./cordis.patch.yml": "./cordis.patch.yml",
|
|
44
|
+
"./src/*": "./src/*",
|
|
45
|
+
"./package.json": "./package.json"
|
|
46
|
+
},
|
|
47
|
+
"files": [
|
|
48
|
+
"lib/index.js",
|
|
49
|
+
"lib/registry.js",
|
|
50
|
+
"lib/search.js",
|
|
51
|
+
"lib/invoke.js",
|
|
52
|
+
"lib/policy.js",
|
|
53
|
+
"lib/invariant.js",
|
|
54
|
+
"cordis.patch.yml",
|
|
55
|
+
"lib/types/**/*.d.ts"
|
|
56
|
+
],
|
|
57
|
+
"dsh": {
|
|
58
|
+
"bundle": {
|
|
59
|
+
"patch": "./cordis.patch.yml"
|
|
60
|
+
}
|
|
61
|
+
},
|
|
62
|
+
"peerDependencies": {
|
|
63
|
+
"@deepseek-ai/cordis": "^4.0.1",
|
|
64
|
+
"@deepseek-ai/dsh-agent": "^0.1.0-rc.7",
|
|
65
|
+
"@deepseek-ai/dsh-invariants": "^0.1.0-rc.7",
|
|
66
|
+
"@deepseek-ai/dsh-llm": "^0.1.0-rc.7",
|
|
67
|
+
"@deepseek-ai/dsh-scope": "^0.1.0-rc.7",
|
|
68
|
+
"@deepseek-ai/dsh-session": "^0.1.0-rc.7",
|
|
69
|
+
"@deepseek-ai/dsh-skill": "^0.1.0-rc.7",
|
|
70
|
+
"@deepseek-ai/dsh-system-prompt": "^0.1.0-rc.7",
|
|
71
|
+
"@deepseek-ai/dsh-tools": "^0.1.0-rc.7",
|
|
72
|
+
"@deepseek-ai/schemastery": "^3.18.1"
|
|
73
|
+
},
|
|
74
|
+
"dependencies": {
|
|
75
|
+
"@deepseek-ai/schemastery": "^3.18.1",
|
|
76
|
+
"js-yaml": "^4.1.0"
|
|
77
|
+
},
|
|
78
|
+
"devDependencies": {
|
|
79
|
+
"@deepseek-ai/dsh-skill-filesystem": "^0.1.0-rc.7",
|
|
80
|
+
"@types/js-yaml": "^4.0.9",
|
|
81
|
+
"@types/node": "^22.0.0",
|
|
82
|
+
"typescript": "^6.0.3",
|
|
83
|
+
"vitest": "^4.1.8"
|
|
84
|
+
}
|
|
85
|
+
}
|