dsh-prompt-customizer 0.5.0 → 0.9.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/README.en.md +26 -2
- package/README.md +129 -15
- package/build.mjs +219 -0
- package/client/client.js +8160 -3465
- package/client/client.js.map +7 -1
- package/cordis.patch.yml +6 -3
- package/lib/index.js +16360 -905
- package/lib/index.js.map +7 -0
- package/package.json +50 -38
- package/scripts/fixtures/rc2-mode.mjs +12 -0
- package/scripts/fixtures/rc2-preview.snapshot.json +35 -0
- package/scripts/fixtures/rc2-runtime.mjs +85 -0
- package/scripts/fixtures/rc2.cordis.yml +31 -0
- package/scripts/fixtures/rc2.overlay.yml +9 -0
- package/scripts/smoke-client.mjs +382 -0
- package/scripts/smoke-host.mjs +130 -0
- package/scripts/test-mcp-layering.mjs +441 -0
- package/scripts/test-mcp-tool-disable.mjs +420 -0
- package/scripts/test-rc2-runtime.mjs +42 -0
- package/scripts/test-skill-manager.mjs +170 -0
- package/scripts/test-skill-toggles.mjs +100 -0
- package/lib/catalog.js +0 -131
- package/lib/effective.js +0 -161
- package/lib/promotion.js +0 -80
- package/lib/schema.js +0 -125
- package/lib/sectionOps.d.mts +0 -67
- package/lib/sectionOps.mjs +0 -269
- package/lib/store.js +0 -124
- package/lib/vars.js +0 -147
- package/lib/zh/cordis.mjs +0 -110
- package/lib/zh/core.mjs +0 -47
- package/lib/zh/index.d.mts +0 -8
- package/lib/zh/index.mjs +0 -23
- package/lib/zh/sdk.mjs +0 -22
- package/lib/zh/teams.mjs +0 -19
- package/lib/zh/undo.mjs +0 -18
- package/src/client/Panel.tsx +0 -532
- package/src/client/PresetsPane.tsx +0 -298
- package/src/client/PreviewPane.tsx +0 -73
- package/src/client/PreviewTools.tsx +0 -33
- package/src/client/SectionsPane.tsx +0 -331
- package/src/client/ToolsPane.tsx +0 -230
- package/src/client/error-boundary.tsx +0 -48
- package/src/client/index.ts +0 -97
- package/src/client/locales.ts +0 -301
- package/src/client/nav.tsx +0 -284
- package/src/client/preset-io.ts +0 -226
- package/src/client/presets.ts +0 -413
- package/src/client/shell.tsx +0 -179
- package/src/client/styles.ts +0 -59
- package/src/client/types.ts +0 -125
package/package.json
CHANGED
|
@@ -1,10 +1,22 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-prompt-customizer",
|
|
3
|
-
"
|
|
4
|
-
"
|
|
3
|
+
"version": "0.9.2",
|
|
4
|
+
"description": "DeepSeek Harness 的三合一能力台:提示词定制(按名称屏蔽 / 替换 / 注入 / 排序,按会话阶段与 agent 预设分层)+ 技能集合管理(导入 / 分组 / 开关)+ MCP Server 接入(分层遮蔽与工具级启停)。纯插件注入,不动官方源码。",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"dsh",
|
|
7
|
+
"dsh-plugin",
|
|
8
|
+
"deepseek-harness",
|
|
9
|
+
"system-prompt",
|
|
10
|
+
"prompt-engineering",
|
|
11
|
+
"skills",
|
|
12
|
+
"mcp",
|
|
13
|
+
"tool-filter",
|
|
14
|
+
"cordis",
|
|
15
|
+
"plugin",
|
|
16
|
+
"agent"
|
|
17
|
+
],
|
|
5
18
|
"type": "module",
|
|
6
|
-
"
|
|
7
|
-
"main": "lib/index.js",
|
|
19
|
+
"main": "./lib/index.js",
|
|
8
20
|
"author": "DreamsTOF",
|
|
9
21
|
"license": "MIT",
|
|
10
22
|
"homepage": "https://github.com/DreamsTOF/dsh-prompt-customizer#readme",
|
|
@@ -15,68 +27,68 @@
|
|
|
15
27
|
"bugs": {
|
|
16
28
|
"url": "https://github.com/DreamsTOF/dsh-prompt-customizer/issues"
|
|
17
29
|
},
|
|
18
|
-
"keywords": [
|
|
19
|
-
"deepseek",
|
|
20
|
-
"harness",
|
|
21
|
-
"dsh",
|
|
22
|
-
"system-prompt",
|
|
23
|
-
"prompt-engineering",
|
|
24
|
-
"tool-filter",
|
|
25
|
-
"cordis",
|
|
26
|
-
"plugin",
|
|
27
|
-
"agent"
|
|
28
|
-
],
|
|
29
|
-
"scripts": {
|
|
30
|
-
"typecheck": "tsc -p tsconfig.client.json --noEmit",
|
|
31
|
-
"build": "tsdown",
|
|
32
|
-
"test": "node --test",
|
|
33
|
-
"check": "npm run typecheck && npm run build && npm run test",
|
|
34
|
-
"prepack": "npm run build"
|
|
35
|
-
},
|
|
36
30
|
"exports": {
|
|
37
31
|
".": "./lib/index.js",
|
|
38
32
|
"./client": "./client/client.js",
|
|
39
33
|
"./cordis.patch.yml": "./cordis.patch.yml",
|
|
40
34
|
"./package.json": "./package.json"
|
|
41
35
|
},
|
|
36
|
+
"comment:files": "只发运行时需要的部分:lib / client 是构建产物(vendor 的叶子模块与依赖在构建时已内联),scripts 供已安装位置自检;src / vendor / test 只用于重新构建与开发。",
|
|
37
|
+
"files": [
|
|
38
|
+
"lib",
|
|
39
|
+
"client",
|
|
40
|
+
"scripts",
|
|
41
|
+
"build.mjs",
|
|
42
|
+
"cordis.patch.yml",
|
|
43
|
+
"README.md",
|
|
44
|
+
"README.en.md"
|
|
45
|
+
],
|
|
42
46
|
"dsh": {
|
|
43
47
|
"bundle": {
|
|
44
48
|
"patch": "./cordis.patch.yml"
|
|
45
49
|
},
|
|
46
50
|
"client": {
|
|
51
|
+
"platform": "web",
|
|
47
52
|
"inject": [
|
|
48
|
-
"@deepseek-ai/dsh-client-
|
|
49
|
-
"@deepseek-ai/dsh-client-
|
|
50
|
-
"@deepseek-ai/dsh-client-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
+
"@deepseek-ai/dsh-client-ui-renderer",
|
|
54
|
+
"@deepseek-ai/dsh-client-ui-slots",
|
|
55
|
+
"@deepseek-ai/dsh-client-ui-conversation",
|
|
56
|
+
"@deepseek-ai/dsh-client-ui-primitives",
|
|
57
|
+
"@deepseek-ai/dsh-client-locale",
|
|
58
|
+
"@deepseek-ai/dsh-client-ui-input-trigger",
|
|
59
|
+
"@deepseek-ai/dsh-client-ui-tool"
|
|
60
|
+
]
|
|
53
61
|
}
|
|
54
62
|
},
|
|
63
|
+
"scripts": {
|
|
64
|
+
"build": "node build.mjs",
|
|
65
|
+
"test": "node --test",
|
|
66
|
+
"smoke": "node scripts/smoke-host.mjs && node scripts/smoke-client.mjs",
|
|
67
|
+
"check": "npm run build && npm test && npm run smoke",
|
|
68
|
+
"prepack": "npm run build"
|
|
69
|
+
},
|
|
70
|
+
"engines": {
|
|
71
|
+
"node": ">=22"
|
|
72
|
+
},
|
|
55
73
|
"peerDependencies": {
|
|
56
|
-
"@deepseek-ai/cordis": "^4.0.
|
|
57
|
-
"@deepseek-ai/dsh-
|
|
74
|
+
"@deepseek-ai/cordis": "^4.0.4",
|
|
75
|
+
"@deepseek-ai/dsh-client-locale": "^0.2.0-rc.2",
|
|
76
|
+
"@deepseek-ai/dsh-settings": "^0.2.0-rc.2",
|
|
58
77
|
"react": "^18.2.0",
|
|
59
78
|
"react-dom": "^18.2.0"
|
|
60
79
|
},
|
|
61
80
|
"dependencies": {
|
|
62
|
-
"
|
|
81
|
+
"js-yaml": "^4.1.0",
|
|
63
82
|
"yaml": "^2.9.0"
|
|
64
83
|
},
|
|
65
84
|
"devDependencies": {
|
|
66
|
-
"@deepseek-ai/cordis": "4.0.1",
|
|
67
85
|
"@types/react": "~18.3.1",
|
|
68
86
|
"@types/react-dom": "~18.3.1",
|
|
87
|
+
"esbuild": "^0.25.12",
|
|
69
88
|
"react": "^18.3.1",
|
|
70
89
|
"react-dom": "~18.3.1",
|
|
71
|
-
"tsdown": "^0.22.14",
|
|
72
90
|
"typescript": "^5.6.0"
|
|
73
91
|
},
|
|
74
|
-
"files": [
|
|
75
|
-
"lib",
|
|
76
|
-
"client",
|
|
77
|
-
"src",
|
|
78
|
-
"cordis.patch.yml"
|
|
79
|
-
],
|
|
80
92
|
"publishConfig": {
|
|
81
93
|
"access": "public"
|
|
82
94
|
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/** Mode-owned contributions used by the real rc.2 Loader fixture. */
|
|
2
|
+
export const inject = ['tools', 'systemPrompt']
|
|
3
|
+
export function apply(ctx, config) {
|
|
4
|
+
ctx.systemPrompt.section({ name: 'fixture:first', order: config.reverse ? 9000 : 7000, text: `FIRST ${config.mode}` })
|
|
5
|
+
ctx.systemPrompt.section({ name: 'fixture:second', order: config.reverse ? 7000 : 9000, text: () => `SECOND ${config.mode}` })
|
|
6
|
+
ctx.systemPrompt.context({ name: 'fixture:policy', order: 1, text: `POLICY ${config.mode}` })
|
|
7
|
+
for (let i = 0; i < config.count; i++) ctx.tools.register({
|
|
8
|
+
name: `${config.mode}_tool_${i}`, description: `Tool for ${config.mode}`, parameters: { type: 'object', properties: {} },
|
|
9
|
+
output: { schema: { type: 'string' }, render: (_args, value) => [{ type: 'text', text: value }] },
|
|
10
|
+
execute: async () => 'fixture-tool-ok',
|
|
11
|
+
})
|
|
12
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
{
|
|
2
|
+
"requests": 2,
|
|
3
|
+
"modes": [
|
|
4
|
+
{
|
|
5
|
+
"mode": "standard", "count": 85,
|
|
6
|
+
"sections": [
|
|
7
|
+
{ "name": "harness:identity", "text": "You are an AI agent powered by DeepSeek Harness." },
|
|
8
|
+
{ "name": "deployment:persona-prefix", "text": "MODE standard {{model}}" },
|
|
9
|
+
{ "name": "fixture:first", "text": "FIRST standard" },
|
|
10
|
+
{ "name": "fixture:second", "text": "SECOND standard" },
|
|
11
|
+
{ "name": "deployment:persona-suffix", "text": "CWD {{cwd}}" }
|
|
12
|
+
],
|
|
13
|
+
"contexts": [{ "name": "fixture:policy", "text": "POLICY standard" }],
|
|
14
|
+
"diagnostics": [
|
|
15
|
+
{ "name": "deployment:persona-prefix", "variable": "model", "kind": "session-variable" },
|
|
16
|
+
{ "name": "deployment:persona-suffix", "variable": "cwd", "kind": "session-variable" }
|
|
17
|
+
]
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
"mode": "alternate", "count": 3,
|
|
21
|
+
"sections": [
|
|
22
|
+
{ "name": "harness:identity", "text": "You are an AI agent powered by DeepSeek Harness." },
|
|
23
|
+
{ "name": "deployment:persona-prefix", "text": "MODE alternate {{model}}" },
|
|
24
|
+
{ "name": "fixture:second", "text": "SECOND alternate" },
|
|
25
|
+
{ "name": "fixture:first", "text": "FIRST alternate" },
|
|
26
|
+
{ "name": "deployment:persona-suffix", "text": "CWD {{cwd}}" }
|
|
27
|
+
],
|
|
28
|
+
"contexts": [{ "name": "fixture:policy", "text": "POLICY alternate" }],
|
|
29
|
+
"diagnostics": [
|
|
30
|
+
{ "name": "deployment:persona-prefix", "variable": "model", "kind": "session-variable" },
|
|
31
|
+
{ "name": "deployment:persona-suffix", "variable": "cwd", "kind": "session-variable" }
|
|
32
|
+
]
|
|
33
|
+
}
|
|
34
|
+
]
|
|
35
|
+
}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
/** Real rc.2 profile: preview two modes before any conversation exists, then drive one turn. */
|
|
2
|
+
import { createRequire } from 'node:module'
|
|
3
|
+
import { pathToFileURL } from 'node:url'
|
|
4
|
+
import { readFile } from 'node:fs/promises'
|
|
5
|
+
import assert from 'node:assert/strict'
|
|
6
|
+
const runtimeRequire = createRequire(process.env.PC_DSH_MANIFEST)
|
|
7
|
+
const llm = await import(pathToFileURL(runtimeRequire.resolve('@deepseek-ai/dsh-llm')).href)
|
|
8
|
+
const { createUserMessage } = llm
|
|
9
|
+
const { SessionId } = await import(pathToFileURL(runtimeRequire.resolve('@deepseek-ai/dsh-session')).href)
|
|
10
|
+
class OfflineModel extends llm.LlmAdapter {
|
|
11
|
+
requests = []
|
|
12
|
+
async resolveModel(provider, model) { return { provider, id: model, name: model, inputModalities: ['text'] } }
|
|
13
|
+
async *stream(options) {
|
|
14
|
+
this.requests.push(options)
|
|
15
|
+
if (this.requests.length === 1) {
|
|
16
|
+
yield { type: 'block-end', index: 0, block: { type: 'tool-call', id: 'pc-probe', name: 'standard_tool_0', arguments: '{}' } }
|
|
17
|
+
yield { type: 'finish', reason: { kind: 'tool-calls' } }
|
|
18
|
+
} else {
|
|
19
|
+
yield { type: 'block-end', index: 0, block: { type: 'text', text: 'rc2-plugin-ok' } }
|
|
20
|
+
yield { type: 'finish', reason: { kind: 'stop' } }
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
export const inject = ['llm', 'agents', 'tools', 'systemPrompt', 'webServer', 'connection', 'agentPresets', 'sessionProjections']
|
|
25
|
+
export function apply(ctx) {
|
|
26
|
+
const timer = setImmediate(() => run(ctx).then(() => ctx.root.fiber.dispose()).catch(error => {
|
|
27
|
+
console.error(error); process.exitCode = 1; return ctx.root.fiber.dispose()
|
|
28
|
+
}))
|
|
29
|
+
ctx.effect(() => () => clearImmediate(timer))
|
|
30
|
+
}
|
|
31
|
+
async function run(ctx) {
|
|
32
|
+
await ctx.loader.await()
|
|
33
|
+
const model = new OfflineModel()
|
|
34
|
+
ctx.llm.registerAdapter(['pc-offline'], model)
|
|
35
|
+
for (const mode of ['standard', 'alternate']) {
|
|
36
|
+
const dispose = await ctx.agentPresets.register({ id: mode, plugins: [
|
|
37
|
+
{ name: pathToFileURL(runtimeRequire.resolve('@deepseek-ai/dsh-persona')).href, config: { prefix: `MODE ${mode} {{model}}`, suffix: 'CWD {{cwd}}' } },
|
|
38
|
+
{ name: new URL('./rc2-mode.mjs', import.meta.url).href, config: { mode, count: mode === 'standard' ? 85 : 3, reverse: mode === 'alternate' } },
|
|
39
|
+
] })
|
|
40
|
+
ctx.effect(() => dispose)
|
|
41
|
+
}
|
|
42
|
+
ctx.effect(() => ctx.webServer.register({ kind: 'exact', path: '/', handler: (req, res) => {
|
|
43
|
+
if (ctx.connection.authorizeIndex(req, res)) { res.writeHead(200); res.end('fixture') }
|
|
44
|
+
} }))
|
|
45
|
+
const base = `http://127.0.0.1:${ctx.webServer.port}`
|
|
46
|
+
const auth = await fetch(ctx.connection.authenticatedUrl(base), { redirect: 'manual' })
|
|
47
|
+
const cookie = auth.headers.get('set-cookie').split(';')[0]
|
|
48
|
+
async function request(endpoint, body) {
|
|
49
|
+
const response = await fetch(`${base}/api/prompt-customizer/${endpoint}`, { method: body ? 'POST' : 'GET', headers: { cookie, 'content-type': 'application/json' }, ...(body ? { body: JSON.stringify(body) } : {}) })
|
|
50
|
+
const data = await response.json()
|
|
51
|
+
assert.equal(response.status, 200, data.error)
|
|
52
|
+
return data
|
|
53
|
+
}
|
|
54
|
+
const modes = []
|
|
55
|
+
assert.equal(ctx.agents.list().length, 0)
|
|
56
|
+
for (const mode of ['standard', 'alternate']) {
|
|
57
|
+
const first = await request(`preview?scope=${mode}&phase=active`)
|
|
58
|
+
const second = await request(`preview?scope=${mode}&phase=active`)
|
|
59
|
+
assert.deepEqual(second, first)
|
|
60
|
+
assert.equal(first.source, 'preset')
|
|
61
|
+
assert.equal(first.tools.length, mode === 'standard' ? 85 : 3)
|
|
62
|
+
assert.ok(first.tools.every(tool => tool.name.startsWith(`${mode}_`)))
|
|
63
|
+
assert.ok(first.text.includes('{{model}}'))
|
|
64
|
+
assert.ok(first.diagnostics.some(item => item.variable === 'model'))
|
|
65
|
+
const inventory = await request(`inventory?scope=${mode}`)
|
|
66
|
+
assert.ok(inventory.sections.length > 0)
|
|
67
|
+
modes.push({ mode, count: first.tools.length, sections: first.sections, contexts: first.contexts, diagnostics: first.diagnostics })
|
|
68
|
+
}
|
|
69
|
+
const reordered = await request('preview?scope=alternate&phase=active', { target: 'alternate', patch: { inject: [{ name: 'fixture:first', text: '', order: -1, phase: 'active' }] } })
|
|
70
|
+
assert.equal(reordered.sections[0].name, 'fixture:first')
|
|
71
|
+
const standard = await request('preview?scope=standard&phase=active')
|
|
72
|
+
assert.notEqual(standard.sections[0].name, 'fixture:first')
|
|
73
|
+
const handle = await ctx.agents.create({ sessionId: SessionId('pc-rc2-smoke'), agentOptions: { provider: 'pc-offline', model: 'test' }, meta: { cwd: process.cwd() }, setup: async agentCtx => { await ctx.agentPresets.mount(agentCtx, 'standard') } })
|
|
74
|
+
ctx.effect(() => () => handle.dispose())
|
|
75
|
+
handle.agent.followup(createUserMessage({ content: [{ type: 'text', text: 'Run the fixture tool.' }], source: { kind: 'user' } }))
|
|
76
|
+
await handle.agent.whenIdle()
|
|
77
|
+
assert.equal(model.requests.length, 2)
|
|
78
|
+
assert.ok(JSON.stringify(model.requests.at(-1)).includes('fixture-tool-ok'))
|
|
79
|
+
await request('preview?scope=alternate&phase=active')
|
|
80
|
+
assert.equal(ctx.agentPresets.composedPreset(handle.agent.ctx), 'standard')
|
|
81
|
+
const report = { requests: model.requests.length, modes }
|
|
82
|
+
const expected = JSON.parse(await readFile(new URL('./rc2-preview.snapshot.json', import.meta.url), 'utf8'))
|
|
83
|
+
assert.deepEqual(report, expected)
|
|
84
|
+
console.log('PC_RC2_SMOKE ' + JSON.stringify(report))
|
|
85
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
- id: llm
|
|
2
|
+
name: '@deepseek-ai/dsh-llm'
|
|
3
|
+
- id: session
|
|
4
|
+
name: '@deepseek-ai/dsh-session'
|
|
5
|
+
- id: projection
|
|
6
|
+
name: '@deepseek-ai/dsh-session-projection'
|
|
7
|
+
- id: prompt
|
|
8
|
+
name: '@deepseek-ai/dsh-system-prompt'
|
|
9
|
+
- id: tools
|
|
10
|
+
name: '@deepseek-ai/dsh-tools'
|
|
11
|
+
- id: agents
|
|
12
|
+
name: '@deepseek-ai/dsh-agent'
|
|
13
|
+
- id: loop
|
|
14
|
+
name: '@deepseek-ai/dsh-agent-loop'
|
|
15
|
+
config:
|
|
16
|
+
agents: []
|
|
17
|
+
- id: presets
|
|
18
|
+
name: '@deepseek-ai/dsh-agent-preset-registry'
|
|
19
|
+
config:
|
|
20
|
+
default: standard
|
|
21
|
+
- id: credentials
|
|
22
|
+
name: '@deepseek-ai/dsh-credentials-local'
|
|
23
|
+
- id: webserver
|
|
24
|
+
name: '@deepseek-ai/dsh-host-webserver'
|
|
25
|
+
config:
|
|
26
|
+
host: 127.0.0.1
|
|
27
|
+
port: 0
|
|
28
|
+
- id: connection
|
|
29
|
+
name: '@deepseek-ai/dsh-client-connection'
|
|
30
|
+
- id: runtime-fixture
|
|
31
|
+
name: './rc2-runtime.mjs'
|