@daweifu/capability-menu 0.1.0 → 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.
@@ -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 (an MCP tool, via `ctx.tools.execute`);
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
- /** Stable identifier prefixes: MCP tools keep `mcp__...`, skills use `skill:<name>`. */
25
- export declare const SKILL_ID_PREFIX = "skill:";
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, e.g. `gongfeng` or `filesystem`. */
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
- /** MCP server name, present only for `kind: 'tool'`. */
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>` or `skill:<name>`. */
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 — Progressive
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;
@@ -121,14 +144,21 @@ export interface SkillDirEntry {
121
144
  readonly name: string;
122
145
  readonly type: 'file' | 'directory';
123
146
  }
124
- /** The `ctx.meta` service surface. */
125
- export interface MetaService {
147
+ /** The `ctx.capability` service surface. */
148
+ export interface CapabilityService {
126
149
  /** Enumerate the current catalog (optionally filtered). */
127
150
  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>;
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,17 +174,29 @@ export interface MetaService {
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 (e.g. after a `progressiveSkillCatalog` change).
193
+ * that want to force a rebuild.
152
194
  */
153
195
  refresh(): Promise<void>;
154
196
  }
155
197
  declare module '@deepseek-ai/cordis' {
156
198
  interface Context {
157
- meta: MetaService;
199
+ capability: CapabilityService;
158
200
  }
159
201
  }
160
202
  /** Registry configuration. */
@@ -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 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).
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
- progressiveSkillCatalog?: string;
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
@@ -0,0 +1 @@
1
+ {"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../src/registry.ts"],"names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,CAAC,OAAO,EAAE,iBAAiB,EAAE,CAAA;IACrC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;CACtB;AAED,oCAAoC;AACpC,MAAM,WAAW,sBAAsB;IACrC,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAA;IACvB,QAAQ,CAAC,MAAM,EAAE,gBAAgB,CAAA;CAClC;AAED,mDAAmD;AACnD,MAAM,MAAM,gBAAgB,GAAG,oBAAoB,GAAG,sBAAsB,CAAA;AAE5E;;;;;;;;;GASG;AACH,wBAAgB,KAAK,CAAC,GAAG,EAAE,OAAO,EAAE,MAAM,GAAE,MAAW,GAAG,IAAI,CA8H7D"}
@@ -0,0 +1,72 @@
1
+ /**
2
+ * Host-side Typert gateway exposing the server-side `ctx.capabilityPolicy`
3
+ * management surface (see `src/policy.ts`) to the browser. Built as
4
+ * `lib/server/remote.js` and mounted by the package root entry (`src/index.ts`).
5
+ *
6
+ * Consumed by the browser bundle under `src/client` via
7
+ * `ctx.remote.capabilityPolicy.classifyAll()` / `getConfig()` /
8
+ * `updateConfig()`.
9
+ */
10
+ import type { Context } from '@deepseek-ai/cordis';
11
+ import { TypertRemoteService } from '@deepseek-ai/dsh-typert-protocol';
12
+ import type { CapabilityClassification, CapabilityPolicyService, Config as CapabilityPolicyConfig } from '../policy.ts';
13
+ import type { CapabilityDetail, SkillDirEntry, CapabilityService } from '../registry.ts';
14
+ declare module '@deepseek-ai/cordis' {
15
+ interface Context {
16
+ capabilityPolicy: CapabilityPolicyService;
17
+ capability: CapabilityService;
18
+ }
19
+ }
20
+ /** 能力目录查看负载:两份只读「文件」+ 缺失原因。 */
21
+ export interface CatalogDocs {
22
+ /** 当前生效的三档策略配置(getConfig() + metaTools()),YAML 文本。 */
23
+ readonly policyYaml: string;
24
+ /** 按需能力目录物化文件(capability.catalogPath())。 */
25
+ readonly catalog?: {
26
+ readonly path: string;
27
+ readonly content: string;
28
+ };
29
+ /** catalog 不可用原因:'disabled' = catalogFile 为空(未启用物化);'read-failed' = 读盘失败。 */
30
+ readonly catalogMissing?: 'disabled' | 'read-failed';
31
+ }
32
+ /**
33
+ * Host-side remote face for the 能力管理 tab. Every method delegates to the
34
+ * policy service installed by `@daweifu/capability-menu/policy`; the registry
35
+ * sibling (`capability`) must be mounted for `classifyAll` to return anything.
36
+ *
37
+ * The service registers under a distinct key (`capabilityPolicyGateway`) so it
38
+ * does not collide with the `capabilityPolicy` service the policy plugin
39
+ * provides; the Typert wire namespace is still `capabilityPolicy` (matching
40
+ * the client remote descriptors), and the gateway reads the real policy
41
+ * service through `this.ctx.capabilityPolicy`.
42
+ */
43
+ export declare class CapabilityPolicyGateway extends TypertRemoteService {
44
+ static inject: string[];
45
+ constructor(ctx: Context);
46
+ /** Current (resolved) policy config. */
47
+ getConfig(): CapabilityPolicyConfig;
48
+ /** Replace a subset of the policy config (recompile rules + rewrite catalog). */
49
+ updateConfig(partial: Partial<CapabilityPolicyConfig>): Promise<void>;
50
+ /** Classify every capability currently indexed by `ctx.capability`. */
51
+ classifyAll(): CapabilityClassification[];
52
+ /** Resolve one capability's full detail (schema, description; skill body optional). */
53
+ getDetail(id: string): Promise<CapabilityDetail | undefined>;
54
+ /** List a skill's directory children (one level deep; optional subpath). */
55
+ listSkillDir(id: string, relPath?: string): Promise<SkillDirEntry[] | undefined>;
56
+ /** Read a text file inside a skill's directory. */
57
+ readSkillFile(id: string, relPath: string): Promise<string | undefined>;
58
+ /**
59
+ * 能力目录查看:返回「三档策略配置」语义化视图——默认全部常驻,
60
+ * tools.resident 按 server 各显示 '*',例外(on-demand/disabled)按
61
+ * server → 工具短名 分级列出;skills 无 server 维度,resident 恒为 '*',
62
+ * 例外为短名平铺。空例外不渲染 key,避免 []/{} 歧义。
63
+ * 另返回按需能力目录物化文件(~/.dsh/capability-catalog.yaml)的路径和内容。
64
+ * 两者都是只读视图——策略持久化入口仍是 cordis.patch.yml。
65
+ */
66
+ getCatalogDocs(): Promise<CatalogDocs>;
67
+ }
68
+ /** Register the remote gateway on a context. */
69
+ export declare const name = "capability-menu-remote";
70
+ export declare const inject: string[];
71
+ export declare function apply(ctx: Context): void;
72
+ //# sourceMappingURL=remote.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"remote.d.ts","sourceRoot":"","sources":["../../../src/server/remote.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAA;AAClD,OAAO,EAAE,mBAAmB,EAAU,MAAM,kCAAkC,CAAA;AAG9E,OAAO,KAAK,EACV,wBAAwB,EACxB,uBAAuB,EACvB,MAAM,IAAI,sBAAsB,EACjC,MAAM,cAAc,CAAA;AACrB,OAAO,KAAK,EAAE,gBAAgB,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAA;AAMxF,OAAO,QAAQ,qBAAqB,CAAC;IACnC,UAAU,OAAO;QACf,gBAAgB,EAAE,uBAAuB,CAAA;QACzC,UAAU,EAAE,iBAAiB,CAAA;KAC9B;CACF;AAED,+BAA+B;AAC/B,MAAM,WAAW,WAAW;IAC1B,sDAAsD;IACtD,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAA;IAC3B,4CAA4C;IAC5C,QAAQ,CAAC,OAAO,CAAC,EAAE;QAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;KAAE,CAAA;IACtE,6EAA6E;IAC7E,QAAQ,CAAC,cAAc,CAAC,EAAE,UAAU,GAAG,aAAa,CAAA;CACrD;AAED;;;;;;;;;;GAUG;AACH,qBAAa,uBAAwB,SAAQ,mBAAmB;IAC9D,MAAM,CAAC,MAAM,WAAqC;gBAEtC,GAAG,EAAE,OAAO;IAIxB,wCAAwC;IAExC,SAAS,IAAI,sBAAsB;IAInC,iFAAiF;IAE3E,YAAY,CAAC,OAAO,EAAE,OAAO,CAAC,sBAAsB,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC;IAI3E,uEAAuE;IAEvE,WAAW,IAAI,wBAAwB,EAAE;IAIzC,uFAAuF;IAEjF,SAAS,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,gBAAgB,GAAG,SAAS,CAAC;IAIlE,4EAA4E;IAEtE,YAAY,CAAC,EAAE,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,EAAE,GAAG,SAAS,CAAC;IAItF,mDAAmD;IAE7C,aAAa,CAAC,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC;IAI7E;;;;;;;OAOG;IAEG,cAAc,IAAI,OAAO,CAAC,WAAW,CAAC;CAqE7C;AAED,gDAAgD;AAChD,eAAO,MAAM,IAAI,2BAA2B,CAAA;AAC5C,eAAO,MAAM,MAAM,UAAqC,CAAA;AACxD,wBAAgB,KAAK,CAAC,GAAG,EAAE,OAAO,GAAG,IAAI,CAExC"}
package/package.json CHANGED
@@ -1,17 +1,24 @@
1
1
  {
2
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.",
3
+ "version": "0.1.2",
4
+ "description": "Unified capability management for the DeepSeek Harness: catalog (ctx.capability) + meta_search/meta_invoke + Resident/On-demand/Disabled projection policy + 能力管理 settings tab, in one installable bundle (server + browser).",
5
5
  "license": "Apache-2.0",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "git+https://github.com/PKUfudawei/dsh-capability-menu.git"
9
+ },
6
10
  "publishConfig": {
7
- "access": "public"
11
+ "access": "public",
12
+ "registry": "https://registry.npmjs.org/"
8
13
  },
9
14
  "type": "module",
10
15
  "main": "lib/index.js",
11
16
  "types": "lib/types/index.d.ts",
12
17
  "scripts": {
13
- "build": "tsc -p tsconfig.json",
14
- "typecheck": "tsc -p tsconfig.json --noEmit",
18
+ "build": "tsc -p tsconfig.json && tsdown",
19
+ "bundle": "tsdown",
20
+ "bridge": "node scripts/bridge-runtime.mjs",
21
+ "typecheck": "tsc -p tsconfig.json --noEmit && tsc -p tsconfig.client.json --noEmit",
15
22
  "test": "vitest run",
16
23
  "prepare": "npm run build"
17
24
  },
@@ -36,50 +43,71 @@
36
43
  "types": "./lib/types/policy.d.ts",
37
44
  "default": "./lib/policy.js"
38
45
  },
39
- "./invariant": {
40
- "types": "./lib/types/invariant.d.ts",
41
- "default": "./lib/invariant.js"
46
+ "./client": {
47
+ "types": "./lib/client.d.ts",
48
+ "default": "./lib/client.js"
42
49
  },
43
50
  "./cordis.patch.yml": "./cordis.patch.yml",
44
51
  "./src/*": "./src/*",
45
52
  "./package.json": "./package.json"
46
53
  },
47
54
  "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"
55
+ "lib",
56
+ "cordis.patch.yml"
56
57
  ],
57
58
  "dsh": {
58
59
  "bundle": {
59
60
  "patch": "./cordis.patch.yml"
61
+ },
62
+ "client": {
63
+ "inject": [
64
+ "@deepseek-ai/dsh-client-runtime",
65
+ "@deepseek-ai/dsh-client-ui-settings",
66
+ "@deepseek-ai/dsh-client-locale",
67
+ "@deepseek-ai/dsh-api-remotes"
68
+ ],
69
+ "external": [
70
+ "react",
71
+ "react/jsx-runtime"
72
+ ],
73
+ "platform": "web"
60
74
  }
61
75
  },
62
76
  "peerDependencies": {
63
77
  "@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"
78
+ "@deepseek-ai/dsh-agent": "^0.1.2-rc.1",
79
+ "@deepseek-ai/dsh-llm": "^0.1.2-rc.1",
80
+ "@deepseek-ai/dsh-scope": "^0.1.2-rc.1",
81
+ "@deepseek-ai/dsh-session": "^0.1.2-rc.1",
82
+ "@deepseek-ai/dsh-skill": "^0.1.2-rc.1",
83
+ "@deepseek-ai/dsh-system-prompt": "^0.1.2-rc.1",
84
+ "@deepseek-ai/dsh-tools": "^0.1.2-rc.1",
85
+ "@deepseek-ai/dsh-api-remotes": "^0.1.2-rc.1",
86
+ "@deepseek-ai/dsh-client-connection": "^0.1.2-rc.1",
87
+ "@deepseek-ai/dsh-client-locale": "^0.1.2-rc.1",
88
+ "@deepseek-ai/dsh-client-runtime": "^0.1.1-rc.1",
89
+ "@deepseek-ai/dsh-client-schema-form": "^0.1.0-rc.7",
90
+ "@deepseek-ai/dsh-client-ui-primitives": "^0.1.2-rc.1",
91
+ "@deepseek-ai/dsh-client-ui-settings": "^0.1.2-rc.1",
92
+ "@deepseek-ai/dsh-client-ui-slots": "^0.1.2-rc.1",
93
+ "@deepseek-ai/dsh-client-web-react": "^0.1.0-rc.7",
94
+ "@deepseek-ai/dsh-typert-protocol": "^0.1.2-rc.1",
95
+ "@deepseek-ai/schemastery": "^3.18.1",
96
+ "react": "^18.2.0"
73
97
  },
74
98
  "dependencies": {
75
99
  "@deepseek-ai/schemastery": "^3.18.1",
76
100
  "js-yaml": "^4.1.0"
77
101
  },
78
102
  "devDependencies": {
79
- "@deepseek-ai/dsh-skill-filesystem": "^0.1.0-rc.7",
103
+ "@deepseek-ai/dsh-skill-filesystem": "^0.1.2-rc.1",
80
104
  "@types/js-yaml": "^4.0.9",
81
105
  "@types/node": "^22.0.0",
106
+ "@types/react": "^18.2.0",
107
+ "tsdown": "^0.22.2",
82
108
  "typescript": "^6.0.3",
83
- "vitest": "^4.1.8"
109
+ "vitest": "^4.1.8",
110
+ "zod": "^4.4.3",
111
+ "@deepseek-ai/dsh-util-values": "^0.1.2-rc.1"
84
112
  }
85
113
  }
package/lib/invariant.js DELETED
@@ -1,22 +0,0 @@
1
- /**
2
- * Package-owned invariant companion for `@daweifu/capability-menu`.
3
- * @module @daweifu/capability-menu/invariant
4
- */
5
- const PACKAGE_NAME = '@daweifu/capability-menu';
6
- /** Cordis companion plugin name. */
7
- export const name = 'capability-menu-invariant';
8
- /** Service required before the companion can reserve package ownership. */
9
- export const inject = ['invariants'];
10
- /**
11
- * No runtime invariant: the capability catalog has no independent lifecycle
12
- * stream; its index mirrors the tools/skills registries it observes.
13
- */
14
- const install = () => { };
15
- /**
16
- * Register this package's invariant companion.
17
- * @param ctx - Cordis context carrying the invariant service.
18
- * @returns the installed registration's disposer after setup succeeds.
19
- */
20
- export const apply = (ctx) => Promise.resolve(ctx.invariants.register(PACKAGE_NAME, install));
21
- /* jscpd:ignore-end */
22
- //# sourceMappingURL=invariant.js.map
@@ -1,16 +0,0 @@
1
- /**
2
- * Package-owned invariant companion for `@daweifu/capability-menu`.
3
- * @module @daweifu/capability-menu/invariant
4
- */
5
- import type { Context } from '@deepseek-ai/cordis';
6
- /** Cordis companion plugin name. */
7
- export declare const name = "capability-menu-invariant";
8
- /** Service required before the companion can reserve package ownership. */
9
- export declare const inject: string[];
10
- /**
11
- * Register this package's invariant companion.
12
- * @param ctx - Cordis context carrying the invariant service.
13
- * @returns the installed registration's disposer after setup succeeds.
14
- */
15
- export declare const apply: (ctx: Context) => Promise<() => void>;
16
- //# sourceMappingURL=invariant.d.ts.map