dsh-agent-skills 0.1.2 → 0.1.4

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.md CHANGED
@@ -49,7 +49,7 @@ dsh plugin --profile web add github:minivv/dsh-agent-skills
49
49
  2. 点击 **开启接管 DSH 技能**。
50
50
  3. 看到“已开启”提示后重启 DSH Web。
51
51
 
52
- 开启后,页面中的目录和技能开关会接入 `standard` 与 `code` preset,真正控制 Agent 可见的技能。这个操作只添加 `dsh-agent-skills/preset` provider,不会创建第二个 `agentSkills` host 服务。
52
+ 开启后,页面会在 `standard` 与 `code` preset 中用 `dsh-agent-skills/preset` 替换原来的 `skill-filesystem` provider,让目录和技能开关真正控制 Agent 可见的技能。它不会创建第二个 `agentSkills` host 服务;卸载脚本会恢复官方 provider。
53
53
 
54
54
  如果页面无法定位 DSH 安装位置,可以使用备用命令:
55
55
 
@@ -97,7 +97,7 @@ description: Explain when this skill should be used.
97
97
 
98
98
  ## 卸载
99
99
 
100
- 如果安装过 preset-only 行,请先清理它,再卸载 npm 包:
100
+ 先恢复 DSH 官方的 `skill-filesystem` provider,再卸载 npm 包:
101
101
 
102
102
  ```bash
103
103
  DSH_INSTALL_ROOT="$(npm root -g)/@deepseek-ai/dsh" \
package/cordis.patch.yml CHANGED
@@ -5,8 +5,7 @@
5
5
  # which provide `loader` (base) and the web settings shell; the plugin's own
6
6
  # `inject` resolves against those.
7
7
  #
8
- # The per-agent PRESET row (which registers the skill provider into the
9
- # agent-preset layer of the skill registry) is appended by
8
+ # The per-agent PRESET provider replaces the shipped skill-filesystem row via
10
9
  # scripts/install-preset.mjs — see README.
11
10
  - insert:
12
11
  - id: agent-skills
package/lib/index.d.ts CHANGED
@@ -8,12 +8,12 @@
8
8
  * the `agentSkills` typert namespace for the browser half, and publishes
9
9
  * catalog invalidations so toggles reach the model on the next agent step.
10
10
  *
11
- * 2. PRESET row (appended to the shipped agent presets by
11
+ * 2. PRESET row (replaces the shipped `skill-filesystem` provider through
12
12
  * scripts/install-preset.mjs): registers the `agent-skills` provider into
13
13
  * the preset layer of the skill registry, where it re-emits every
14
14
  * candidate with the user's enable/disable policy and scans the custom
15
15
  * directories. The preset layer outranks the global layer, which is what
16
- * lets the toggles shadow the preset's own skill-filesystem provider.
16
+ * makes the toggles authoritative for built-in filesystem skills.
17
17
  *
18
18
  * @module dsh-agent-skills
19
19
  */
@@ -27,8 +27,8 @@ export declare const inject: string[];
27
27
  * - the HOST row registers into the global layer (covers host-level
28
28
  * compositions such as the headless profile, where skill-filesystem is a
29
29
  * host row);
30
- * - a PRESET row registers into its preset layer, which outranks the
31
- * global layer for agent-visible skills (the web profile's arrangement).
30
+ * - the PRESET row replaces the official filesystem provider in its preset
31
+ * layer, while still scanning the same built-in roots itself.
32
32
  * The host row additionally provides the settings-page service and the
33
33
  * `agentSkills` typert namespace.
34
34
  */
package/lib/index.js CHANGED
@@ -10,8 +10,8 @@ export const inject = ["skills"];
10
10
  * - the HOST row registers into the global layer (covers host-level
11
11
  * compositions such as the headless profile, where skill-filesystem is a
12
12
  * host row);
13
- * - a PRESET row registers into its preset layer, which outranks the
14
- * global layer for agent-visible skills (the web profile's arrangement).
13
+ * - the PRESET row replaces the official filesystem provider in its preset
14
+ * layer, while still scanning the same built-in roots itself.
15
15
  * The host row additionally provides the settings-page service and the
16
16
  * `agentSkills` typert namespace.
17
17
  */
@@ -9,5 +9,7 @@ export interface PresetManagerOptions {
9
9
  export declare function resolveDshPackageRoot(options?: PresetManagerOptions): string | undefined;
10
10
  /** Inspect whether every shipped standard/code preset already mounts the provider. */
11
11
  export declare function inspectPresetTakeover(options?: PresetManagerOptions): PresetTakeoverStatus;
12
- /** Idempotently mount the preset-only provider in every available shipped preset. */
12
+ /** Idempotently replace the shipped filesystem provider in every supported preset. */
13
13
  export declare function enablePresetTakeover(options?: PresetManagerOptions): PresetTakeoverStatus;
14
+ /** Restore the official filesystem provider and remove legacy appended rows. */
15
+ export declare function disablePresetTakeover(options?: PresetManagerOptions): PresetTakeoverStatus;
@@ -10,17 +10,12 @@ import { randomUUID } from "node:crypto";
10
10
  import { basename, dirname, join, parse } from "node:path";
11
11
  const DSH_PACKAGE = "@deepseek-ai/dsh";
12
12
  const PRESET_IDS = ["standard", "code"];
13
- const PRESET_ROW = [
14
- "",
15
- "# ── dsh-agent-skills ───────────────────────────────────────────────────────",
16
- "# Registered by dsh-agent-skills: provides per-skill/per-source toggles and",
17
- "# custom scan directories for THIS preset layer of the skill registry.",
18
- "- id: agent-skills",
19
- " name: dsh-agent-skills/preset",
20
- ""
21
- ].join("\n");
22
- const CURRENT_ROW = /(?:^|\n)- id: agent-skills\r?\n name: dsh-agent-skills\/preset(?:\r?\n|$)/m;
23
- const MANAGED_BLOCK = /\n?# ── dsh-agent-skills ─+\r?\n# Registered by dsh-agent-skills:[\s\S]*?- id: agent-skills\r?\n name: dsh-agent-skills(?:\/preset)?\r?\n?\s*$/m;
13
+ const OFFICIAL_PROVIDER = "@deepseek-ai/dsh-skill-filesystem";
14
+ const TAKEOVER_PROVIDER = "dsh-agent-skills/preset";
15
+ const CURRENT_ROW = /((?:^|\n)[ \t]*- id: skill-filesystem[ \t]*\r?\n[ \t]+name:[ \t]*)['"]?dsh-agent-skills\/preset['"]?(?=\r?\n|$)/m;
16
+ const OFFICIAL_ROW = /((?:^|\n)[ \t]*- id: skill-filesystem[ \t]*\r?\n[ \t]+name:[ \t]*)['"]?@deepseek-ai\/dsh-skill-filesystem['"]?(?=\r?\n|$)/m;
17
+ const LEGACY_OVERRIDE_ROW = /((?:^|\n)[ \t]*- id: skill-filesystem[ \t]*\r?\n[ \t]+name:[ \t]*)['"]?dsh-agent-skills['"]?(?=\r?\n|$)/m;
18
+ const LEGACY_MANAGED_BLOCK = /\n?# ── dsh-agent-skills ─+\r?\n# Registered by dsh-agent-skills:[\s\S]*?- id: agent-skills\r?\n name: dsh-agent-skills(?:\/preset)?\r?\n?\s*$/m;
24
19
  function verifiedPackageRoot(start) {
25
20
  if (start === undefined || start === "" || !existsSync(start))
26
21
  return undefined;
@@ -72,7 +67,10 @@ function statusFor(root) {
72
67
  if (root === undefined)
73
68
  return { available: false, enabled: false, configured: 0, total: 0 };
74
69
  const files = presetFiles(root);
75
- const configured = files.filter((file) => CURRENT_ROW.test(readFileSync(file, "utf8"))).length;
70
+ const configured = files.filter((file) => {
71
+ const text = readFileSync(file, "utf8");
72
+ return CURRENT_ROW.test(text) && !OFFICIAL_ROW.test(text) && !LEGACY_MANAGED_BLOCK.test(text);
73
+ }).length;
76
74
  return {
77
75
  available: files.length > 0,
78
76
  enabled: files.length > 0 && configured === files.length,
@@ -99,20 +97,59 @@ function replaceAtomically(file, content) {
99
97
  unlinkSync(temporary);
100
98
  }
101
99
  }
102
- /** Idempotently mount the preset-only provider in every available shipped preset. */
100
+ function replaceProvider(text, matcher, provider) {
101
+ const yamlScalar = provider.startsWith("@") ? `'${provider}'` : provider;
102
+ return text.replace(matcher, `$1${yamlScalar}`);
103
+ }
104
+ function takeoverContent(file, text) {
105
+ const cleaned = text.replace(LEGACY_MANAGED_BLOCK, "").replace(/\s*$/, "\n");
106
+ if (CURRENT_ROW.test(cleaned) && !OFFICIAL_ROW.test(cleaned))
107
+ return cleaned;
108
+ if (OFFICIAL_ROW.test(cleaned))
109
+ return replaceProvider(cleaned, OFFICIAL_ROW, TAKEOVER_PROVIDER);
110
+ if (LEGACY_OVERRIDE_ROW.test(cleaned))
111
+ return replaceProvider(cleaned, LEGACY_OVERRIDE_ROW, TAKEOVER_PROVIDER);
112
+ throw new Error(`预设 ${file} 中没有可接管的 skill-filesystem provider`);
113
+ }
114
+ function restoreContent(text) {
115
+ const cleaned = text.replace(LEGACY_MANAGED_BLOCK, "").replace(/\s*$/, "\n");
116
+ if (CURRENT_ROW.test(cleaned))
117
+ return replaceProvider(cleaned, CURRENT_ROW, OFFICIAL_PROVIDER);
118
+ if (LEGACY_OVERRIDE_ROW.test(cleaned))
119
+ return replaceProvider(cleaned, LEGACY_OVERRIDE_ROW, OFFICIAL_PROVIDER);
120
+ return cleaned;
121
+ }
122
+ /** Idempotently replace the shipped filesystem provider in every supported preset. */
103
123
  export function enablePresetTakeover(options = {}) {
104
124
  const root = resolveDshPackageRoot(options);
105
125
  if (root === undefined)
106
126
  throw new Error("未找到 DSH 安装位置,请确认当前页面由 DSH 启动后重试");
107
127
  const files = presetFiles(root);
128
+ if (files.length === 0)
129
+ throw new Error("当前 DSH 安装中没有 standard 或 code Agent 预设");
130
+ const updates = files.map((file) => {
131
+ const current = readFileSync(file, "utf8");
132
+ return { file, current, next: takeoverContent(file, current) };
133
+ });
134
+ for (const update of updates) {
135
+ if (update.next !== update.current)
136
+ replaceAtomically(update.file, update.next);
137
+ }
138
+ return statusFor(root);
139
+ }
140
+ /** Restore the official filesystem provider and remove legacy appended rows. */
141
+ export function disablePresetTakeover(options = {}) {
142
+ const root = resolveDshPackageRoot(options);
143
+ if (root === undefined)
144
+ throw new Error("未找到 DSH 安装位置,请确认 DSH_INSTALL_ROOT 是否正确");
145
+ const files = presetFiles(root);
108
146
  if (files.length === 0)
109
147
  throw new Error("当前 DSH 安装中没有 standard 或 code Agent 预设");
110
148
  for (const file of files) {
111
- const text = readFileSync(file, "utf8");
112
- if (CURRENT_ROW.test(text))
113
- continue;
114
- const cleaned = text.replace(MANAGED_BLOCK, "").replace(/\s*$/, "");
115
- replaceAtomically(file, cleaned + PRESET_ROW);
149
+ const current = readFileSync(file, "utf8");
150
+ const next = restoreContent(current);
151
+ if (next !== current)
152
+ replaceAtomically(file, next);
116
153
  }
117
154
  return statusFor(root);
118
155
  }
@@ -1 +1 @@
1
- {"version":3,"file":"preset-manager.js","sourceRoot":"","sources":["../src/preset-manager.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,EACL,UAAU,EACV,YAAY,EACZ,YAAY,EACZ,UAAU,EACV,QAAQ,EACR,UAAU,EACV,aAAa,EACd,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,UAAU,E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AAM,IAAI,GAAG,cAAc,CAAC,OAAO,CAAC,CAAC;QACrC,IAAI,IAAI,KAAK,OAAO;YAAE,iBAAiB,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;IACtD,CAAC;IACD,OAAO,SAAS,CAAC,IAAI,CAAC,CAAC;AACzB,CAAC"}
package/lib/provider.d.ts CHANGED
@@ -4,10 +4,10 @@
4
4
  * that outranks the global layer for agent-visible skills.
5
5
  *
6
6
  * Responsibilities:
7
- * - re-emit every candidate from the layers' other providers (the preset's
8
- * own skill-filesystem, global providers, runtime registrations) at
9
- * rank - 1, so this provider's copies win the per-name dedupe and can
10
- * carry the user's enable/disable policy;
7
+ * - re-emit candidates from other providers and runtime registrations with
8
+ * the user's enable/disable policy;
9
+ * - scan the built-in filesystem roots previously owned by the replaced
10
+ * `skill-filesystem` preset row;
11
11
  * - discover user-configured custom scan directories itself;
12
12
  * - delegate `get()` to the original provider / file so skill bodies are
13
13
  * always loaded by the same code that owns them.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-agent-skills",
3
- "version": "0.1.2",
3
+ "version": "0.1.4",
4
4
  "author": "Wei <minivv@users.noreply.github.com>",
5
5
  "description": "Discover and manage Claude Code, Codex, Gemini CLI, and other Agent Skills inside DeepSeek Harness.",
6
6
  "type": "module",
@@ -74,6 +74,7 @@
74
74
  },
75
75
  "scripts": {
76
76
  "build": "node scripts/build.mjs",
77
+ "test": "node test-preset-manager.mjs && node test-takeover-provider.mjs",
77
78
  "typecheck": "tsc -p tsconfig.json --noEmit && tsc -p tsconfig.client.json --noEmit",
78
79
  "prepare": "npm run build",
79
80
  "prepublishOnly": "npm run typecheck && npm run build",
@@ -1,49 +1,17 @@
1
- // Idempotently append the dsh-agent-skills row to the shipped agent preset
2
- // compositions (standard / code) that mount skill-filesystem, so the plugin's
3
- // provider registers into the PRESET layer of the skill registry — the layer
4
- // that wins for agent-visible skills. Without this row the settings page and
5
- // custom directories still work, but per-skill toggles cannot shadow the
6
- // preset's own filesystem provider.
7
- //
1
+ // Replace the shipped skill-filesystem provider with dsh-agent-skills.
8
2
  // Usage: DSH_INSTALL_ROOT=<dsh package dir> node scripts/install-preset.mjs
9
- import { readFileSync, writeFileSync, existsSync } from "node:fs";
10
- import { join } from "node:path";
3
+ import { enablePresetTakeover } from "../lib/preset-manager.js";
11
4
 
12
5
  const dshPkg = process.env.DSH_INSTALL_ROOT;
13
6
  if (!dshPkg) {
14
- console.error("DSH_INSTALL_ROOT must point at the @deepseek-ai/dsh package directory (e.g. .../lib/node_modules/@deepseek-ai/dsh)");
15
- process.exit(1);
16
- }
17
- const presetRoot = join(dshPkg, "config/agent-presets");
18
- if (!existsSync(join(presetRoot, "standard", "agent.cordis.yml"))) {
19
- console.error("agent-presets root not found under", presetRoot);
7
+ console.error("DSH_INSTALL_ROOT must point at the @deepseek-ai/dsh package directory");
20
8
  process.exit(1);
21
9
  }
22
10
 
23
- const ROW = [
24
- "",
25
- "# ── dsh-agent-skills ───────────────────────────────────────────────────────",
26
- "# Registered by dsh-agent-skills: provides per-skill/per-source toggles and",
27
- "# custom scan directories for THIS preset layer of the skill registry.",
28
- "- id: agent-skills",
29
- " name: dsh-agent-skills/preset",
30
- ""
31
- ].join("\n");
32
-
33
- let patched = 0;
34
- for (const id of ["standard", "code"]) {
35
- const file = join(presetRoot, id, "agent.cordis.yml");
36
- if (!existsSync(file)) continue;
37
- const text = readFileSync(file, "utf8");
38
- const legacy = /\n?# ── dsh-agent-skills ─+\n# Registered by dsh-agent-skills:[\s\S]*?- id: agent-skills\n name: dsh-agent-skills\n?\s*$/m;
39
- const current = /\n?# ── dsh-agent-skills ─+\n# Registered by dsh-agent-skills:[\s\S]*?- id: agent-skills\n name: dsh-agent-skills\/preset\n?\s*$/m;
40
- if (current.test(text)) {
41
- console.log("already patched:", file);
42
- continue;
43
- }
44
- const cleaned = text.replace(legacy, "").replace(/\s*$/, "");
45
- writeFileSync(file, cleaned + ROW);
46
- patched += 1;
47
- console.log(legacy.test(text) ? "migrated:" : "patched:", file);
11
+ try {
12
+ const status = enablePresetTakeover({ dshRoot: dshPkg });
13
+ console.log(`dsh-agent-skills now controls ${status.configured}/${status.total} presets`);
14
+ } catch (error) {
15
+ console.error(error instanceof Error ? error.message : String(error));
16
+ process.exit(1);
48
17
  }
49
- if (patched === 0) console.log("no preset needed patching");
@@ -1,22 +1,16 @@
1
- // Remove only the block previously installed by dsh-agent-skills.
2
- import { readFileSync, writeFileSync, existsSync } from "node:fs";
3
- import { join } from "node:path";
1
+ // Restore the official skill-filesystem provider and remove legacy rows.
2
+ import { disablePresetTakeover } from "../lib/preset-manager.js";
4
3
 
5
4
  const dshPkg = process.env.DSH_INSTALL_ROOT;
6
5
  if (!dshPkg) {
7
6
  console.error("DSH_INSTALL_ROOT must point at the @deepseek-ai/dsh package directory");
8
7
  process.exit(1);
9
8
  }
10
- const presetRoot = join(dshPkg, "config/agent-presets");
11
- let removed = 0;
12
- for (const id of ["standard", "code"]) {
13
- const file = join(presetRoot, id, "agent.cordis.yml");
14
- if (!existsSync(file)) continue;
15
- const text = readFileSync(file, "utf8");
16
- const block = /\n?# ── dsh-agent-skills ─+\n# Registered by dsh-agent-skills:[\s\S]*?- id: agent-skills\n name: dsh-agent-skills(?:\/preset)?\n?\s*$/m;
17
- if (!block.test(text)) continue;
18
- writeFileSync(file, text.replace(block, "").replace(/\s*$/, "\n"));
19
- removed += 1;
20
- console.log("removed:", file);
9
+
10
+ try {
11
+ const status = disablePresetTakeover({ dshRoot: dshPkg });
12
+ console.log(`restored official skill-filesystem provider in ${status.total} presets`);
13
+ } catch (error) {
14
+ console.error(error instanceof Error ? error.message : String(error));
15
+ process.exit(1);
21
16
  }
22
- if (removed === 0) console.log("no dsh-agent-skills preset rows found");