dsh-skill-pool 0.0.0-stage → 0.3.8
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/CONTRACTS-v3.md +406 -0
- package/LICENSE +21 -0
- package/README.md +357 -2
- package/client.js +4715 -0
- package/cordis.patch.yml +6 -0
- package/icon.svg +21 -0
- package/index.js +220 -0
- package/locale/en.json +6 -0
- package/locale/zh.json +6 -0
- package/package.json +68 -4
- package/src/activation.js +854 -0
- package/src/inventory.js +452 -0
- package/src/library.js +1168 -0
- package/src/mount.js +78 -0
- package/src/provider.js +309 -0
- package/src/remount.js +78 -0
- package/src/rules.js +272 -0
- package/src/skill-content.js +78 -0
- package/src/store.js +1233 -0
- package/src/uploads.js +222 -0
- package/src/web-api.js +1381 -0
package/cordis.patch.yml
ADDED
package/icon.svg
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64" width="64" height="64" role="img" aria-label="Resource Pool">
|
|
2
|
+
<defs>
|
|
3
|
+
<linearGradient id="rp-bg" x1="0" y1="0" x2="64" y2="64" gradientUnits="userSpaceOnUse">
|
|
4
|
+
<stop offset="0" stop-color="#2f6df6"/>
|
|
5
|
+
<stop offset="1" stop-color="#16b3a3"/>
|
|
6
|
+
</linearGradient>
|
|
7
|
+
</defs>
|
|
8
|
+
<rect x="2" y="2" width="60" height="60" rx="16" fill="url(#rp-bg)"/>
|
|
9
|
+
<g fill="none" stroke="#ffffff" stroke-width="3.2" stroke-linejoin="round" stroke-linecap="round">
|
|
10
|
+
<path d="M18 15h28"/>
|
|
11
|
+
<path d="M21 24h22"/>
|
|
12
|
+
<path d="M25 33h14"/>
|
|
13
|
+
</g>
|
|
14
|
+
<path d="M20 43h24l-6 8h-6l-6-8z" fill="#ffffff" opacity="0.92"/>
|
|
15
|
+
<g fill="#ffffff">
|
|
16
|
+
<circle cx="18" cy="15" r="3.1"/>
|
|
17
|
+
<circle cx="43" cy="24" r="3.1"/>
|
|
18
|
+
<circle cx="25" cy="33" r="3.1"/>
|
|
19
|
+
<circle cx="32" cy="55" r="2.6"/>
|
|
20
|
+
</g>
|
|
21
|
+
</svg>
|
package/index.js
ADDED
|
@@ -0,0 +1,220 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Resource pool for DeepSeek Harness (single global pool).
|
|
3
|
+
*
|
|
4
|
+
* One Host plugin owns:
|
|
5
|
+
* - a durable document (`$DSH_HOME/resource-pool/state.json`) holding the pool
|
|
6
|
+
* members (skills / MCP servers with per-item mode+workspace scopes) and the
|
|
7
|
+
* skill-library sources;
|
|
8
|
+
* - the per-Agent gate that applies the pool to a live session by restricting
|
|
9
|
+
* tools, replacing the native `skill` loader with a filtered one, and stating
|
|
10
|
+
* the active pool in the system prompt;
|
|
11
|
+
* - the HTTP surface the settings page calls, plus a `resource_pool_status`
|
|
12
|
+
* tool so an Agent can explain why a resource is missing.
|
|
13
|
+
*
|
|
14
|
+
* The settings page is the browser half (`./client`); no sidebar entry.
|
|
15
|
+
*
|
|
16
|
+
* @module dsh-skill-pool
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
import { createRequire } from 'node:module'
|
|
20
|
+
|
|
21
|
+
import { defineTool } from '@deepseek-ai/dsh-tools'
|
|
22
|
+
import z from '@deepseek-ai/schemastery'
|
|
23
|
+
|
|
24
|
+
import { StateReadError, StateStore, defaultState, statePath } from './src/store.js'
|
|
25
|
+
import { registerWebApi } from './src/web-api.js'
|
|
26
|
+
import { createActivation, modeOf, workspaceOf } from './src/activation.js'
|
|
27
|
+
import { createMountTracker } from './src/uploads.js'
|
|
28
|
+
import { remountPoolServers } from './src/remount.js'
|
|
29
|
+
import { resolvePool } from './src/rules.js'
|
|
30
|
+
|
|
31
|
+
/** Loader plugin name. */
|
|
32
|
+
export const name = 'skill-pool'
|
|
33
|
+
|
|
34
|
+
/** Required services; everything else is discovered through `ctx.get`. */
|
|
35
|
+
export const inject = ['tools']
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Package version reported to the panel.
|
|
39
|
+
*
|
|
40
|
+
* Read from package.json instead of a literal: a duplicated version string is
|
|
41
|
+
* exactly how the panel ended up claiming 0.3.0 while 0.3.1 was installed. Node
|
|
42
|
+
* resolves `./package.json` because it is in this package's `exports`.
|
|
43
|
+
*/
|
|
44
|
+
const VERSION = (() => {
|
|
45
|
+
try {
|
|
46
|
+
return createRequire(import.meta.url)('./package.json').version
|
|
47
|
+
} catch {
|
|
48
|
+
return 'unknown'
|
|
49
|
+
}
|
|
50
|
+
})()
|
|
51
|
+
|
|
52
|
+
/** Schemastery schema surfaced by `Config.listConfigs` and the profile patch. */
|
|
53
|
+
export const Config = z.object({
|
|
54
|
+
file: z.string().default('').description('Absolute state file path; empty uses $DSH_HOME/resource-pool/state.json.'),
|
|
55
|
+
promptLanguage: z.string().default('zh').description("Language of the injected pool summary: 'zh' | 'en'."),
|
|
56
|
+
enabled: z.boolean().default(true).description('Master switch; false keeps the panel but never gates a session.'),
|
|
57
|
+
})
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Mount the plugin.
|
|
61
|
+
* @param {import('@deepseek-ai/cordis').Context} ctx - plugin context.
|
|
62
|
+
* @param {{ file?: string, promptLanguage?: string, enabled?: boolean }} [config] - validated configuration.
|
|
63
|
+
*/
|
|
64
|
+
export function apply(ctx, config = {}) {
|
|
65
|
+
const logger = ctx.logger ?? undefined
|
|
66
|
+
const file = typeof config.file === 'string' && config.file.trim().length > 0 ? config.file.trim() : statePath()
|
|
67
|
+
const store = new StateStore({ file, logger, version: VERSION })
|
|
68
|
+
const promptLanguage = config.promptLanguage === 'en' ? 'en' : 'zh'
|
|
69
|
+
const masterEnabled = config.enabled !== false
|
|
70
|
+
|
|
71
|
+
/** Read the stored document with fail-closed validation (diagnostics too). */
|
|
72
|
+
const readStoredState = () => store.read({ fresh: true })
|
|
73
|
+
|
|
74
|
+
/** Effective document: the profile's master switch wins over the stored one. */
|
|
75
|
+
const getState = async () => {
|
|
76
|
+
if (!masterEnabled) {
|
|
77
|
+
// A deliberately disabled plugin never gates a session, so a corrupt file
|
|
78
|
+
// must not turn into a creation failure. Keep the panel/status diagnostic
|
|
79
|
+
// path (which reads the store directly) intact and fall back to an empty,
|
|
80
|
+
// ungated document. Nothing is written.
|
|
81
|
+
try {
|
|
82
|
+
const state = await readStoredState()
|
|
83
|
+
return { ...state, settings: { ...state.settings, enabled: false } }
|
|
84
|
+
} catch (error) {
|
|
85
|
+
// Only a state-reader failure is expected here; anything else is a bug
|
|
86
|
+
// and must not be turned into a silent "ungated" answer.
|
|
87
|
+
if (!(error instanceof StateReadError)) throw error
|
|
88
|
+
logger?.warn?.(`[skill-pool] plugin disabled; ignoring unreadable state: ${error.message}`)
|
|
89
|
+
const state = defaultState()
|
|
90
|
+
return { ...state, settings: { ...state.settings, enabled: false } }
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
return readStoredState()
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
const activation = createActivation({ ctx, getState, logger, promptLanguage: () => promptLanguage })
|
|
97
|
+
|
|
98
|
+
const meta = { version: VERSION, file, pluginName: 'dsh-skill-pool', promptLanguage }
|
|
99
|
+
|
|
100
|
+
// Apply to existing Agents too: a plugin reload must not leave live sessions
|
|
101
|
+
// ungated until they are recreated.
|
|
102
|
+
ctx.inject(['agents'], () => {
|
|
103
|
+
void activation.reapplyAll()
|
|
104
|
+
})
|
|
105
|
+
|
|
106
|
+
ctx.on('agent/created', async ({ agent }) => {
|
|
107
|
+
// Listeners are awaited before creation resolves and before the Agent may
|
|
108
|
+
// assemble its first request. If the state file cannot be read safely and
|
|
109
|
+
// this Agent has no previous gate, `applyToAgent` rejects: letting creation
|
|
110
|
+
// continue would publish an Agent with no MCP restriction (fail-open).
|
|
111
|
+
await activation.applyToAgent(agent)
|
|
112
|
+
})
|
|
113
|
+
|
|
114
|
+
ctx.on('agent/disposed', ({ agent }) => {
|
|
115
|
+
activation.disposeAgent(agent)
|
|
116
|
+
})
|
|
117
|
+
|
|
118
|
+
// A preset switch changes which modes are in effect without touching the pool
|
|
119
|
+
// document, so the session header alone would keep the old mode forever.
|
|
120
|
+
// `agent-preset/selected` is emitted with (sessionId, presetId) after the Agent
|
|
121
|
+
// has been rebound, which is exactly when the gate has to be recomputed.
|
|
122
|
+
ctx.on('agent-preset/selected', (sessionId) => {
|
|
123
|
+
const registry = ctx.get('agents')
|
|
124
|
+
const live = typeof registry?.list === 'function' ? registry.list() : []
|
|
125
|
+
const agent = live.find((candidate) => candidate?.session?.id === sessionId || candidate?.id === sessionId)
|
|
126
|
+
if (agent === undefined) return
|
|
127
|
+
void activation.applyToAgent(agent, { force: true, conservative: true }).catch((error) => {
|
|
128
|
+
logger?.warn?.(`[skill-pool] preset re-apply failed: ${error instanceof Error ? error.message : String(error)}`)
|
|
129
|
+
})
|
|
130
|
+
})
|
|
131
|
+
|
|
132
|
+
// Registrations live on each Agent's context; release them when the plugin
|
|
133
|
+
// unloads instead of waiting for Agent disposal.
|
|
134
|
+
ctx.effect(() => () => activation.disposeAll(), 'resource-pool.activation')
|
|
135
|
+
|
|
136
|
+
const mounts = createMountTracker()
|
|
137
|
+
|
|
138
|
+
registerWebApi({
|
|
139
|
+
ctx,
|
|
140
|
+
store,
|
|
141
|
+
mounts,
|
|
142
|
+
meta,
|
|
143
|
+
logger,
|
|
144
|
+
onChanged: () => activation.reapplyAll(),
|
|
145
|
+
})
|
|
146
|
+
|
|
147
|
+
// Storage keeps each MCP member's connection definition precisely so this
|
|
148
|
+
// activation can restore it: a Host restart drops every Loader row, and
|
|
149
|
+
// without this the pool would come back listing servers with zero tools.
|
|
150
|
+
// Waiting for `loader` means the rows are created as soon as the service that
|
|
151
|
+
// owns them exists, and the remount itself stays in the background.
|
|
152
|
+
let remounted = false
|
|
153
|
+
ctx.inject(['loader'], () => {
|
|
154
|
+
if (remounted) return
|
|
155
|
+
remounted = true
|
|
156
|
+
void remountPoolServers({ ctx, getState, mounts, logger }).catch((error) => {
|
|
157
|
+
logger?.warn?.(`[skill-pool] remount failed: ${error instanceof Error ? error.message : String(error)}`)
|
|
158
|
+
})
|
|
159
|
+
})
|
|
160
|
+
|
|
161
|
+
// Read-only self-report: answers "why is this skill/MCP tool missing?" for the
|
|
162
|
+
// calling Agent and doubles as the plugin's own health probe.
|
|
163
|
+
const statusTool = defineTool({
|
|
164
|
+
name: 'resource_pool_status',
|
|
165
|
+
description:
|
|
166
|
+
'Report the resource pool state for the current session: resolved Agent mode/workspace, which skills and MCP servers the pool activates here, and the pool size. Use it when a skill or MCP tool you expected is missing.',
|
|
167
|
+
parameters: {},
|
|
168
|
+
output: {
|
|
169
|
+
schema: { type: 'object', additionalProperties: true, properties: {} },
|
|
170
|
+
render: (_args, value) => [{ type: 'text', text: JSON.stringify(value, null, 2) }],
|
|
171
|
+
},
|
|
172
|
+
async execute(_args, exec) {
|
|
173
|
+
let state
|
|
174
|
+
try {
|
|
175
|
+
const stored = await readStoredState()
|
|
176
|
+
state = masterEnabled ? stored : { ...stored, settings: { ...stored.settings, enabled: false } }
|
|
177
|
+
} catch (error) {
|
|
178
|
+
// A status call must stay answerable precisely when the pool is
|
|
179
|
+
// degraded, so the Agent can explain why resources are unavailable.
|
|
180
|
+
const expected = error instanceof StateReadError
|
|
181
|
+
const code = expected ? error.code : 'resource-pool/state-unavailable'
|
|
182
|
+
const message = expected ? error.message : 'resource-pool state is unavailable'
|
|
183
|
+
return {
|
|
184
|
+
plugin: 'dsh-skill-pool',
|
|
185
|
+
version: VERSION,
|
|
186
|
+
stateFile: file,
|
|
187
|
+
promptLanguage,
|
|
188
|
+
masterEnabled,
|
|
189
|
+
stateStatus: {
|
|
190
|
+
ok: false,
|
|
191
|
+
code,
|
|
192
|
+
message,
|
|
193
|
+
recovery:
|
|
194
|
+
'No pool was applied from the unreadable document. Existing Agents keep their previous gate; new Agents are refused. Back up state.json, repair or restore it, then retry.',
|
|
195
|
+
},
|
|
196
|
+
pool: null,
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
const agent = exec?.agent
|
|
200
|
+
const mode = agent === undefined ? '' : modeOf(ctx, agent)
|
|
201
|
+
const cwd = agent === undefined ? '' : workspaceOf(agent)
|
|
202
|
+
const pool = resolvePool(state, { mode, cwd })
|
|
203
|
+
return {
|
|
204
|
+
plugin: 'dsh-skill-pool',
|
|
205
|
+
version: VERSION,
|
|
206
|
+
stateFile: file,
|
|
207
|
+
promptLanguage,
|
|
208
|
+
masterEnabled,
|
|
209
|
+
stateStatus: { ok: true },
|
|
210
|
+
mode,
|
|
211
|
+
cwd,
|
|
212
|
+
...pool,
|
|
213
|
+
counts: { skills: Object.keys(state.skills).length, mcp: Object.keys(state.mcp).length, sources: Object.keys(state.sources).length },
|
|
214
|
+
settings: state.settings,
|
|
215
|
+
}
|
|
216
|
+
},
|
|
217
|
+
})
|
|
218
|
+
|
|
219
|
+
ctx.effect(() => ctx.tools.register(statusTool), 'resource-pool.status-tool')
|
|
220
|
+
}
|
package/locale/en.json
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
{
|
|
2
|
+
"meta": {
|
|
3
|
+
"title": "Skill Pool",
|
|
4
|
+
"description": "One global pool where importing a skill adds it immediately; every skill and MCP server activates by its own Agent-mode and workspace conditions. Imports from files, ZIP or Git, mounts MCP from JSON, and Git sources can check for updates."
|
|
5
|
+
}
|
|
6
|
+
}
|
package/locale/zh.json
ADDED
package/package.json
CHANGED
|
@@ -1,6 +1,70 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-skill-pool",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"description": "
|
|
6
|
-
|
|
3
|
+
"version": "0.3.8",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"description": "One pool for all your DSH skills: import from files, ZIP, GitHub or GitLab, then scope each skill to Agent modes and workspaces from the Settings panel — no code editing required.",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"keywords": [
|
|
8
|
+
"dsh",
|
|
9
|
+
"deepseek-harness",
|
|
10
|
+
"plugin",
|
|
11
|
+
"skill",
|
|
12
|
+
"skills",
|
|
13
|
+
"skill-pool",
|
|
14
|
+
"skill-manager",
|
|
15
|
+
"mcp",
|
|
16
|
+
"agent-preset",
|
|
17
|
+
"workspace"
|
|
18
|
+
],
|
|
19
|
+
"repository": {
|
|
20
|
+
"type": "git",
|
|
21
|
+
"url": "git+https://github.com/rj-yejianping/dsh-skill-pool.git"
|
|
22
|
+
},
|
|
23
|
+
"homepage": "https://github.com/rj-yejianping/dsh-skill-pool#readme",
|
|
24
|
+
"bugs": {
|
|
25
|
+
"url": "https://github.com/rj-yejianping/dsh-skill-pool/issues"
|
|
26
|
+
},
|
|
27
|
+
"exports": {
|
|
28
|
+
".": "./index.js",
|
|
29
|
+
"./client": "./client.js",
|
|
30
|
+
"./locale/*.json": "./locale/*.json",
|
|
31
|
+
"./icon": "./icon.svg",
|
|
32
|
+
"./package.json": "./package.json"
|
|
33
|
+
},
|
|
34
|
+
"files": [
|
|
35
|
+
"index.js",
|
|
36
|
+
"client.js",
|
|
37
|
+
"src/**/*.js",
|
|
38
|
+
"cordis.patch.yml",
|
|
39
|
+
"locale/*.json",
|
|
40
|
+
"icon.svg",
|
|
41
|
+
"README.md",
|
|
42
|
+
"LICENSE",
|
|
43
|
+
"CONTRACTS-v3.md"
|
|
44
|
+
],
|
|
45
|
+
"scripts": {
|
|
46
|
+
"test": "node --test test/*.test.mjs",
|
|
47
|
+
"lint": "node --check index.js && node --check client.js && node --check src/store.js && node --check src/rules.js && node --check src/inventory.js && node --check src/activation.js && node --check src/provider.js && node --check src/skill-content.js && node --check src/web-api.js && node --check src/uploads.js && node --check src/mount.js && node --check src/remount.js && node --check src/library.js",
|
|
48
|
+
"test:feasibility": "node --test test/mcp-feasibility.probe.mjs",
|
|
49
|
+
"test:lifecycle": "node --test test/plugin-lifecycle.probe.mjs",
|
|
50
|
+
"test:naming": "node --test test/mcp-naming.probe.mjs",
|
|
51
|
+
"test:restrict": "node --test test/restrict-lifecycle.probe.mjs",
|
|
52
|
+
"test:activation": "node --test test/activation-restrict.probe.mjs",
|
|
53
|
+
"verify:feasibility": "node test/verify-feasibility.mjs"
|
|
54
|
+
},
|
|
55
|
+
"dsh": {
|
|
56
|
+
"bundle": {
|
|
57
|
+
"patch": "./cordis.patch.yml"
|
|
58
|
+
},
|
|
59
|
+
"client": {
|
|
60
|
+
"platform": "web",
|
|
61
|
+
"immediately": true,
|
|
62
|
+
"inject": [
|
|
63
|
+
"@deepseek-ai/dsh-client-ui-settings"
|
|
64
|
+
]
|
|
65
|
+
}
|
|
66
|
+
},
|
|
67
|
+
"publishConfig": {
|
|
68
|
+
"access": "public"
|
|
69
|
+
}
|
|
70
|
+
}
|