@noirhare/dsh-agent-presets 0.0.1 → 0.0.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/lib/index.d.ts +2 -3
- package/lib/index.js +17 -8
- package/package.json +3 -3
package/lib/index.d.ts
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import { AgentPreset, AgentPresets } from "@deepseek-ai/dsh-agent-presets";
|
|
2
2
|
//#region src/index.d.ts
|
|
3
3
|
declare class NRAgentPresets extends AgentPresets {
|
|
4
|
-
|
|
5
|
-
registerRoot(
|
|
6
|
-
unregisterRoot(path: string): void;
|
|
4
|
+
readonly extraRoots: Map<string, string>;
|
|
5
|
+
registerRoot(id: string, dir: string): () => void;
|
|
7
6
|
list(): Promise<AgentPreset[]>;
|
|
8
7
|
}
|
|
9
8
|
//#endregion
|
package/lib/index.js
CHANGED
|
@@ -1,19 +1,28 @@
|
|
|
1
1
|
import { AgentPresets, discoverPresets } from "@deepseek-ai/dsh-agent-presets";
|
|
2
|
+
import Path from "node:path";
|
|
3
|
+
import FS from "node:fs";
|
|
2
4
|
//#region src/index.ts
|
|
3
5
|
var NRAgentPresets = class extends AgentPresets {
|
|
4
|
-
extraRoots = /* @__PURE__ */ new
|
|
5
|
-
registerRoot(
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
6
|
+
extraRoots = /* @__PURE__ */ new Map();
|
|
7
|
+
registerRoot(id, dir) {
|
|
8
|
+
const path = Path.resolve(dir);
|
|
9
|
+
try {
|
|
10
|
+
if (!FS.statSync(path).isDirectory()) throw new Error(`root "${id}" is not a directory: ${path}`);
|
|
11
|
+
} catch (e) {
|
|
12
|
+
throw new Error(`root "${id}": path not accessible: ${path}`, { cause: e });
|
|
13
|
+
}
|
|
14
|
+
if (this.extraRoots.has(id)) throw new Error(`duplicate root id: ${id}`);
|
|
15
|
+
this.extraRoots.set(id, path);
|
|
16
|
+
return () => {
|
|
17
|
+
this.extraRoots.delete(id);
|
|
18
|
+
};
|
|
10
19
|
}
|
|
11
20
|
async list() {
|
|
12
21
|
const base = await super.list();
|
|
13
22
|
if (this.extraRoots.size === 0) return base;
|
|
14
23
|
const seen = new Set(base.map((preset) => preset.id));
|
|
15
|
-
const extra = await discoverPresets([...this.extraRoots].map((
|
|
16
|
-
path,
|
|
24
|
+
const extra = await discoverPresets([...new Set(this.extraRoots.values())].map((root) => ({
|
|
25
|
+
path: root,
|
|
17
26
|
trust: "system"
|
|
18
27
|
})));
|
|
19
28
|
return [...base, ...extra.filter((preset) => !seen.has(preset.id))];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@noirhare/dsh-agent-presets",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.2",
|
|
4
4
|
"author": "NoirHare",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
},
|
|
27
27
|
"scripts": {
|
|
28
28
|
"build": "tsdown",
|
|
29
|
-
"
|
|
30
|
-
"
|
|
29
|
+
"typecheck": "tsc --noEmit",
|
|
30
|
+
"prepublish": "pnpm typecheck && pnpm build"
|
|
31
31
|
}
|
|
32
32
|
}
|