@linxin666/dsh-liangshen 0.3.23 → 0.4.0
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.i18n.yaml +2 -2
- package/README.md +55 -41
- package/README.zh.md +54 -40
- package/cordis.patch.yml +3 -2
- package/icon.svg +3 -0
- package/lib/client.js +1380 -29
- package/lib/client.js.map +1 -1
- package/lib/index.js +616 -367
- package/lib/types/announce.test.d.ts +10 -0
- package/lib/types/client/LiangShenSettingsCard.d.ts +78 -0
- package/lib/types/client/PluginSettingsCard.d.ts +137 -0
- package/lib/types/client/index.d.ts +57 -4
- package/lib/types/client/lever-controller.d.ts +16 -2
- package/lib/types/client/locales.d.ts +40 -1
- package/lib/types/client/main-session.d.ts +32 -0
- package/lib/types/client/plugin-card-seat.d.ts +103 -0
- package/lib/types/client/settings-form.d.ts +197 -0
- package/lib/types/composition.d.ts +116 -0
- package/lib/types/composition.test.d.ts +7 -0
- package/lib/types/core/lever.d.ts +6 -3
- package/lib/types/index.d.ts +160 -33
- package/lib/types/index.test.d.ts +5 -0
- package/package.json +27 -18
- package/presets/liangshen/NOTICE +4 -4
- package/presets/liangshen/agent.cordis.yml +168 -123
- package/presets/liangshen/fact-ledger.mjs +141 -0
- package/presets/liangshen/guard.mjs +426 -0
- package/presets/liangshen/minimal-prompt.mjs +73 -38
- package/presets/liangshen/paging.mjs +232 -0
- package/presets/liangshen/tool-activate.mjs +176 -0
- package/presets/liangshen/tool-catalog.mjs +615 -219
- package/presets/liangshen/working-context.mjs +222 -0
- package/src/announce.test.ts +248 -55
- package/src/client/LiangShenLever.module.css +2 -0
- package/src/client/LiangShenLever.tsx +41 -10
- package/src/client/LiangShenSettingsCard.tsx +233 -0
- package/src/client/PluginSettingsCard.tsx +555 -0
- package/src/client/index.ts +102 -5
- package/src/client/lever-controller.ts +76 -9
- package/src/client/locales.ts +79 -1
- package/src/client/main-session.ts +43 -0
- package/src/client/plugin-card-seat.ts +192 -0
- package/src/client/settings-card.module.css +418 -0
- package/src/client/settings-form.ts +442 -0
- package/src/composition.test.ts +294 -0
- package/src/composition.ts +554 -0
- package/src/core/lever.ts +7 -4
- package/src/index.test.ts +68 -1
- package/src/index.ts +293 -101
- package/tools/benchmark-live-run.mjs +193 -63
- package/lib/types/schema.d.ts +0 -18
- package/lib/types/schema.test.d.ts +0 -1
- package/lib/types/sync.d.ts +0 -47
- package/lib/types/sync.test.d.ts +0 -1
- package/presets/liangshen/custom-bash.mjs +0 -213
- package/src/schema.test.ts +0 -64
- package/src/schema.ts +0 -110
- package/src/sync.test.ts +0 -224
- package/src/sync.ts +0 -222
package/package.json
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@linxin666/dsh-liangshen",
|
|
3
|
-
"description": "LiangShen (梁神) agent preset plus its composer lever for the dsh web GUI. The
|
|
4
|
-
"version": "0.
|
|
3
|
+
"description": "LiangShen (梁神) agent preset plus its composer lever for the dsh web GUI. The host half declares the bundled preset to the harness's agent-preset registry at activation (declare = enabled), so the preset is selectable for new sessions without writing anything into the harness home; the preset keeps a minimal persona with standing working discipline while the harness's own user-role agent-instructions injection delivers the workspace instructions (the optional `instructionSource: system-prompt` mode lifts them into the prompt instead), and declares one tool presentation for the session's whole lifetime (default `presentation: 'both'`, where the wire collapses to the `run_code` transport and every other tool is reached through the generated SDK; `native` keeps the assembled roster, `ptc` keeps only the transport). High-fan-out tool families (default `mcp__*`) stay paged out of the wire until the preset's own `tool_activate` tool loads their namespace (LRU cap three, state replayed from the durable session event stream), and the tool catalog — exactly the on-wire tools plus paged-out namespace summaries — and a one-line working-context projection travel as durable user messages republished only on change. The browser half adds a slot-machine lever left of the model selector on the new-session screen to toggle the mode. Hot-pluggable via cordis.patch.yml + profile symlink, no dsh source changes.",
|
|
4
|
+
"version": "0.4.0",
|
|
5
|
+
"icon": "icon.svg",
|
|
5
6
|
"type": "module",
|
|
6
7
|
"engines": {
|
|
7
8
|
"node": "^22.19.0 || >=24.0.0"
|
|
@@ -22,7 +23,7 @@
|
|
|
22
23
|
},
|
|
23
24
|
"dsh": {
|
|
24
25
|
"engines": {
|
|
25
|
-
"dsh": ">=0.1.
|
|
26
|
+
"dsh": ">=0.1.7-rc.1"
|
|
26
27
|
},
|
|
27
28
|
"bundle": {
|
|
28
29
|
"patch": "./cordis.patch.yml"
|
|
@@ -31,37 +32,44 @@
|
|
|
31
32
|
"inject": [
|
|
32
33
|
"@deepseek-ai/dsh-client-connection",
|
|
33
34
|
"@deepseek-ai/dsh-client-ui-renderer",
|
|
35
|
+
"@deepseek-ai/dsh-client-ui-settings",
|
|
34
36
|
"@deepseek-ai/dsh-api-remotes",
|
|
35
37
|
"@deepseek-ai/dsh-api-session-controller"
|
|
36
38
|
],
|
|
37
39
|
"platform": "web"
|
|
38
40
|
}
|
|
39
41
|
},
|
|
42
|
+
"peerDependencies": {
|
|
43
|
+
"@deepseek-ai/dsh": ">=0.1.7-rc.1"
|
|
44
|
+
},
|
|
40
45
|
"dependencies": {
|
|
41
|
-
"schemastery": "^3.18.
|
|
46
|
+
"@deepseek-ai/schemastery": "^3.18.4"
|
|
42
47
|
},
|
|
43
48
|
"devDependencies": {
|
|
44
|
-
"@deepseek-ai/cordis": "^4.0.
|
|
45
|
-
"@deepseek-ai/dsh-agent-
|
|
46
|
-
"@deepseek-ai/dsh-api-remotes": "^0.1.
|
|
47
|
-
"@deepseek-ai/dsh-api-session-controller": "^0.1.
|
|
48
|
-
"@deepseek-ai/dsh-client-connection": "^0.1.
|
|
49
|
-
"@deepseek-ai/dsh-client-locale": "^0.1.
|
|
50
|
-
"@deepseek-ai/dsh-client-store": "^0.1.
|
|
51
|
-
"@deepseek-ai/dsh-client-ui-conversation": "^0.1.
|
|
52
|
-
"@deepseek-ai/dsh-client-ui-renderer": "^0.1.
|
|
53
|
-
"@deepseek-ai/dsh-client-ui-
|
|
54
|
-
"@deepseek-ai/dsh-
|
|
55
|
-
"@deepseek-ai/dsh-
|
|
49
|
+
"@deepseek-ai/cordis": "^4.0.4",
|
|
50
|
+
"@deepseek-ai/dsh-agent-preset-registry": "^0.1.7-rc.1",
|
|
51
|
+
"@deepseek-ai/dsh-api-remotes": "^0.1.7-rc.1",
|
|
52
|
+
"@deepseek-ai/dsh-api-session-controller": "^0.1.7-rc.1",
|
|
53
|
+
"@deepseek-ai/dsh-client-connection": "^0.1.7-rc.1",
|
|
54
|
+
"@deepseek-ai/dsh-client-locale": "^0.1.7-rc.1",
|
|
55
|
+
"@deepseek-ai/dsh-client-store": "^0.1.7-rc.1",
|
|
56
|
+
"@deepseek-ai/dsh-client-ui-conversation": "^0.1.7-rc.1",
|
|
57
|
+
"@deepseek-ai/dsh-client-ui-renderer": "^0.1.7-rc.1",
|
|
58
|
+
"@deepseek-ai/dsh-client-ui-settings": "^0.1.7-rc.1",
|
|
59
|
+
"@deepseek-ai/dsh-client-ui-slots": "^0.1.7-rc.1",
|
|
60
|
+
"@deepseek-ai/dsh-settings": "^0.1.7-rc.1",
|
|
61
|
+
"@deepseek-ai/dsh-system-prompt": "^0.1.7-rc.1",
|
|
62
|
+
"@testing-library/react": "^16.1.0",
|
|
56
63
|
"@types/node": "^22.20.0",
|
|
57
64
|
"@types/react": "~18.3.1",
|
|
58
65
|
"@types/react-dom": "~18.3.1",
|
|
66
|
+
"@vitest/coverage-v8": "^4.1.11",
|
|
59
67
|
"jsdom": "^25.0.0",
|
|
60
68
|
"react": "^18.3.1",
|
|
61
69
|
"react-dom": "^18.3.1",
|
|
62
70
|
"tsdown": "0.22.2",
|
|
63
71
|
"typescript": "~5.7.2",
|
|
64
|
-
"vitest": "^
|
|
72
|
+
"vitest": "^4.1.11"
|
|
65
73
|
},
|
|
66
74
|
"files": [
|
|
67
75
|
"lib/**/*.js",
|
|
@@ -74,7 +82,8 @@
|
|
|
74
82
|
"cordis.patch.yml",
|
|
75
83
|
"README.md",
|
|
76
84
|
"README.zh.md",
|
|
77
|
-
"LICENSE"
|
|
85
|
+
"LICENSE",
|
|
86
|
+
"icon.svg"
|
|
78
87
|
],
|
|
79
88
|
"license": "Apache-2.0",
|
|
80
89
|
"repository": {
|
package/presets/liangshen/NOTICE
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
agent.cordis.yml 改编自 DeepSeek Harness 内置 Minimal、Standard 与 PTC preset(MIT
|
|
1
|
+
agent.cordis.yml 改编自 DeepSeek Harness 内置 Minimal、Standard 与 PTC preset(MIT),
|
|
2
|
+
其 shell 段与内置 Minimal 一致:POSIX 挂上游持久 bash,win32 挂上游持久 pwsh
|
|
3
|
+
(dsh-terminal-bash 的 shellDialect: pwsh + dsh-tool-pwsh-persistent),本 preset
|
|
4
|
+
不提供自研 shell 实现。
|
|
2
5
|
minimal-prompt.mjs 与 tool-catalog.mjs 为 dsh-liangshen 自有实现;其中的
|
|
3
6
|
agent-instructions 引用提示沿用 https://github.com/xiaobright/dsh-anchored-standard
|
|
4
7
|
(MIT)的实验结论,消息注入形状参照 DeepSeek Harness 的 skill catalog。
|
|
5
|
-
custom-bash.mjs 移植自同一上游(xiaobright/dsh-anchored-standard,MIT)的
|
|
6
|
-
combo-anchored/custom-bash.mjs,用于 win32 上以跨平台子进程通道提供同名
|
|
7
|
-
`bash` 工具(Git Bash)。
|
|
8
8
|
原始 DeepSeek 版权和 MIT 许可声明见开源仓库。
|
|
@@ -1,29 +1,52 @@
|
|
|
1
1
|
# The `liangshen` (梁神模式) agent preset: the builtin Minimal preset's
|
|
2
|
-
# one-line persona — extended with the mode's standing working discipline
|
|
3
|
-
#
|
|
4
|
-
# session's
|
|
5
|
-
#
|
|
6
|
-
#
|
|
7
|
-
#
|
|
8
|
-
#
|
|
9
|
-
#
|
|
10
|
-
#
|
|
11
|
-
#
|
|
12
|
-
#
|
|
13
|
-
#
|
|
14
|
-
#
|
|
15
|
-
#
|
|
16
|
-
#
|
|
17
|
-
#
|
|
18
|
-
#
|
|
19
|
-
#
|
|
20
|
-
#
|
|
21
|
-
#
|
|
2
|
+
# one-line persona — extended with the mode's standing working discipline
|
|
3
|
+
# (thinking-disruption fuses, action-oriented steps, YAGNI/PDCA) and the
|
|
4
|
+
# session's workspace directory — as the WHOLE system prompt, with one tool
|
|
5
|
+
# presentation declared for the session's whole lifetime instead of a staged
|
|
6
|
+
# turn boundary.
|
|
7
|
+
#
|
|
8
|
+
# The presentation is the SDK's ToolPresentationMode, picked by the
|
|
9
|
+
# tool-catalog row's `presentation` key (default `'ptc'`): `'native'` keeps
|
|
10
|
+
# the assembled roster on the wire, `'ptc'` collapses the wire to the single
|
|
11
|
+
# `run_code` transport, and `'both'` keeps the full native roster AND the
|
|
12
|
+
# `run_code` transport co-resident — native calls carry ordinary work while
|
|
13
|
+
# `run_code` covers programmatic batch computation and wide fan-out. The
|
|
14
|
+
# declaration lands once per agent scope through agent.ctx.tools.presentAs as
|
|
15
|
+
# early as the scope exists, and degrades to the native surface with a
|
|
16
|
+
# one-time warning when the deployment has no code runtime or the host
|
|
17
|
+
# declines. The retired anchor-turn staging is gone: the legacy `anchorTools`
|
|
18
|
+
# and boolean `ptcPresentation` keys are still accepted (the latter mapping
|
|
19
|
+
# true -> 'ptc' and false -> 'native') but only warn once.
|
|
20
|
+
#
|
|
21
|
+
# Gentle tool paging keeps high-fan-out families out of reach until needed:
|
|
22
|
+
# tools matching `pagedToolPatterns` (default `mcp__*`) stay paged out, the
|
|
23
|
+
# durable tool-catalog message summarizes their namespaces with an activation
|
|
24
|
+
# pointer, and the preset's own `tool_activate` tool (the tool-activate row)
|
|
25
|
+
# loads one namespace back — at most three stay active, LRU eviction pages the
|
|
26
|
+
# oldest back out. The activation state replays from the durable session event
|
|
27
|
+
# stream on every assembly, so resume and compaction rebuild it without process
|
|
28
|
+
# memory. Paging is enforced twice, because the wire is not the only surface a
|
|
29
|
+
# tool can be reached through: the assembled tool list loses the paged families,
|
|
30
|
+
# and the agent scope is restricted (agent.ctx.tools.restrict) so the same names
|
|
31
|
+
# vanish from the generated SDK and from every program dispatch. The second half
|
|
32
|
+
# is what makes paging real under the default `ptc` presentation, where the wire
|
|
33
|
+
# has already collapsed to `run_code` and a wire-only filter would withhold
|
|
34
|
+
# nothing the model can observe.
|
|
35
|
+
#
|
|
36
|
+
# The capability facts the Standard system prompt would carry as tool-guidance
|
|
37
|
+
# prose arrive instead as a durable `tool-catalog` message appended after the
|
|
38
|
+
# user's own message, the way the skill catalog is injected: it names exactly
|
|
39
|
+
# the tools the current request's wire carries (each tool's argument signature
|
|
40
|
+
# plus a one-line summary) plus the paged-out namespace summaries, so the
|
|
41
|
+
# declared surface and the request's own wire never disagree. A second durable
|
|
42
|
+
# message, working-context, projects one minimal line of objective session
|
|
43
|
+
# state (plan mode, active namespaces, in-progress todos) folded from the
|
|
44
|
+
# session event stream, republished only when it changes.
|
|
22
45
|
#
|
|
23
46
|
# The persistent shell replaces the Standard ephemeral shell for the whole
|
|
24
|
-
# session
|
|
25
|
-
# file sandbox instead of mounting a bare local
|
|
26
|
-
# filesystem sections below.
|
|
47
|
+
# session — `bash` on POSIX, `pwsh` on win32, exactly one per host — and the
|
|
48
|
+
# editor inherits the host file sandbox instead of mounting a bare local
|
|
49
|
+
# filesystem — see the shell and filesystem sections below.
|
|
27
50
|
#
|
|
28
51
|
# Adapted from the builtin `minimal` and `standard` presets.
|
|
29
52
|
#
|
|
@@ -52,86 +75,144 @@
|
|
|
52
75
|
# appends the session's workspace directory at assembly time, so identity,
|
|
53
76
|
# harness, web-surface, and tool-guidance sections never reach the model.
|
|
54
77
|
# Besides the one-line persona it carries the standing working discipline the
|
|
55
|
-
# mode ships with
|
|
56
|
-
#
|
|
57
|
-
#
|
|
78
|
+
# mode ships with: thinking-disruption fuses (a hypothesis gets at most two
|
|
79
|
+
# reasoning passes before a tool must settle it), action-oriented thinking
|
|
80
|
+
# (decide the next operation, never pre-rehearse implementations in thought),
|
|
81
|
+
# and YAGNI/PDCA with no redundant comments. Runtime context snapshots stay
|
|
82
|
+
# enabled: they are durable user-role messages, not system-prompt text.
|
|
58
83
|
- id: persona
|
|
59
84
|
name: '@deepseek-ai/dsh-persona'
|
|
60
85
|
config:
|
|
61
86
|
prefix: |-
|
|
62
87
|
You are a helpful software engineer assistant.
|
|
63
88
|
|
|
64
|
-
-
|
|
65
|
-
-
|
|
66
|
-
- When
|
|
67
|
-
-
|
|
89
|
+
- Thinking Disruption: Never reason through the same hypothesis more than twice. When a fact is missing, stop thinking and call a native inspection tool (read, grep, bash/pwsh) to settle it — no speculation without new evidence.
|
|
90
|
+
- Action-Oriented: Use thinking only to pick the next concrete operation. Do not pre-rehearse implementations in thought; verify every claim against real tool output during execution.
|
|
91
|
+
- Parallel Inspection: When several independent inspections, searches, or checks are needed, emit all of their tool calls in a single turn rather than across sequential rounds. The harness executes independent read-only calls in parallel.
|
|
92
|
+
- Shell Discipline: Shell processes are ephemeral; directory changes do not persist across tool calls. Use compound commands (e.g. cd <path> && <cmd>) or pass workdir explicitly for operations in subdirectories.
|
|
93
|
+
- Development Standard: Follow YAGNI and the PDCA loop. Each step verifies a single assumption. Do not write redundant comments.
|
|
94
|
+
- Bounded Inspection & Convergence: Do not traverse dependency chains unbounded. Limit pre-action inspection to immediate target files (at most 2-3 inspection turns). Once core context is understood, immediately converge and begin answering or making edits. Verify edge cases during post-edit testing rather than over-reading upfront.
|
|
95
|
+
- Bounded Output: never dump a large or unbounded command output into the conversation. Filter at the source with grep/head/tail/wc and read the narrow range you actually need; the model's long-range attention is a bounded budget and raw logs evict the session's own constraints from it.
|
|
68
96
|
|
|
69
|
-
# The
|
|
97
|
+
# The mode's preset-local plugins:
|
|
70
98
|
#
|
|
71
99
|
# `minimal-prompt` keeps the system prompt on the persona above, plus the
|
|
72
100
|
# session's workspace directory appended at assembly time (`Your working
|
|
73
|
-
# directory is <cwd>.` — the one orientation fact the persona block carries)
|
|
74
|
-
#
|
|
75
|
-
#
|
|
76
|
-
#
|
|
77
|
-
#
|
|
78
|
-
# prefix, re-read on every request so file edits propagate, and drops the
|
|
79
|
-
# harness's own agent-instructions injections (they would duplicate the
|
|
80
|
-
# prompt). Set `instructionSource: hint` to restore the one-time non-imperative
|
|
81
|
-
# pointer to the reference files instead (issue #388, upstream
|
|
82
|
-
# dsh-anchored-standard #49: a full-text dump as context measurably flips the
|
|
83
|
-
# anchored trajectory), or `keepPlanPolicy: false` to drop plan mode's policy
|
|
84
|
-
# section as well.
|
|
101
|
+
# directory is <cwd>.` — the one orientation fact the persona block carries),
|
|
102
|
+
# with no platform-conditional text: both platform shells are persistent, so
|
|
103
|
+
# the persona block is byte-identical on every host. The official `tools:sdk`
|
|
104
|
+
# and `tools:ptc-only` sections are kept exactly when the assembly's wire
|
|
105
|
+
# carries the `run_code` transport.
|
|
85
106
|
#
|
|
86
|
-
# `
|
|
87
|
-
#
|
|
88
|
-
#
|
|
89
|
-
#
|
|
90
|
-
# the
|
|
91
|
-
#
|
|
92
|
-
# the
|
|
93
|
-
#
|
|
94
|
-
#
|
|
107
|
+
# `instructionSource` chooses where the AGENTS.md-style instruction files reach
|
|
108
|
+
# the model. The default, `host`, appends nothing and leaves the pre-step
|
|
109
|
+
# message batch untouched, so the `agent-instructions` row below delivers the
|
|
110
|
+
# baseline and the dynamic subdirectory instructions as the user-role messages
|
|
111
|
+
# the harness itself produces — the prompt stays the bare persona and the
|
|
112
|
+
# preset adds no instruction prose of its own. `system-prompt` instead reads
|
|
113
|
+
# the harness's baseline chain ($DSH_HOME/AGENTS.md, then the project root's
|
|
114
|
+
# ancestors down to the cwd) at assembly time and appends the content as one
|
|
115
|
+
# `workspace-instructions` section after the stable prefix, re-read on every
|
|
116
|
+
# request so file edits propagate, dropping the harness's own injections (they
|
|
117
|
+
# would duplicate the prompt). `hint` restores the one-time non-imperative
|
|
118
|
+
# pointer to the reference files (issue #388, upstream dsh-anchored-standard
|
|
119
|
+
# #49: a full-text dump as context measurably flips the trajectory). Both
|
|
120
|
+
# non-default modes trade the harness's own channel for a preset-owned one; the
|
|
121
|
+
# default keeps the upstream contract. Set `keepPlanPolicy: false` to drop
|
|
122
|
+
# plan mode's policy section as well.
|
|
95
123
|
#
|
|
96
|
-
# `
|
|
97
|
-
#
|
|
98
|
-
#
|
|
99
|
-
#
|
|
100
|
-
#
|
|
101
|
-
# The
|
|
102
|
-
#
|
|
103
|
-
#
|
|
124
|
+
# `tool-catalog` owns the wire presentation and the model-visible catalog.
|
|
125
|
+
# `presentation` selects the SDK ToolPresentationMode for the session's whole
|
|
126
|
+
# lifetime: `'ptc'` (default) collapses the wire to the `run_code` transport
|
|
127
|
+
# and reaches every other tool through the generated SDK, `'native'` keeps the
|
|
128
|
+
# assembled roster alone, and `'both'` keeps the roster and the transport
|
|
129
|
+
# co-resident. The shipped default is a static-context choice, not a measured
|
|
130
|
+
# win: the official scaffold comparison ranks this presentation below the native
|
|
131
|
+
# surface on both code-agent benchmarks, and the bundled benchmark matrix is how
|
|
132
|
+
# that trade would be settled locally. `pagedToolPatterns` (default `['mcp__*']`) names the
|
|
133
|
+
# high-fan-out families that stay paged out of the wire until activated; the
|
|
134
|
+
# active set replays from the session event stream, so resume and compaction
|
|
135
|
+
# rebuild it. `maxResidentTokens` (default 6000, calibrated above the shipped
|
|
136
|
+
# roster so the guard flags real growth rather than the factory configuration)
|
|
137
|
+
# guards the always-on-wire
|
|
138
|
+
# surface: crossing the estimate warns once and points at the patterns, rather
|
|
139
|
+
# than silently dropping a tool the session needs. The catalog itself is a
|
|
140
|
+
# durable user message appended after the
|
|
141
|
+
# user's own message, the way `dsh-tool-skill` injects the skill catalog: it
|
|
142
|
+
# names exactly the tools the current request's wire carries (each tool's
|
|
143
|
+
# argument signature plus a one-line summary capped by
|
|
144
|
+
# `descriptionMaxLength`; the full description stays in the tool schema) and
|
|
145
|
+
# summarizes the paged-out namespaces with their `tool_activate` pointer —
|
|
146
|
+
# including under `ptc`, where those namespaces really are unreachable until
|
|
147
|
+
# activated and the program contract says so. It republishes only when the
|
|
148
|
+
# content changes or the published copy left the visible surface (compaction,
|
|
149
|
+
# resume).
|
|
104
150
|
#
|
|
105
|
-
# `
|
|
106
|
-
#
|
|
107
|
-
#
|
|
108
|
-
# the
|
|
109
|
-
#
|
|
110
|
-
#
|
|
111
|
-
# than a rigid short-summary contract. The declaration is per session
|
|
112
|
-
# (`agent.ctx.tools.presentAs`), needs a mounted code runtime, and degrades to
|
|
113
|
-
# the native surface with a one-time warning when either is missing or fails.
|
|
114
|
-
# Set `false` to restore the pre-PTC behavior: the full native roster on the
|
|
115
|
-
# wire from the second turn.
|
|
151
|
+
# `tool-activate` registers the `tool_activate` tool the catalog points at:
|
|
152
|
+
# it validates the target against the session's paged, inactive namespaces and
|
|
153
|
+
# activates one onto the wire, evicting the least recently used namespace past
|
|
154
|
+
# the cap of three. `working-context` appends the one-line recency projection
|
|
155
|
+
# (`[Working Context: ...]`) folded from the session events, republished only
|
|
156
|
+
# when it changes.
|
|
116
157
|
- id: minimal-prompt
|
|
117
158
|
name: ./minimal-prompt.mjs
|
|
118
159
|
config:
|
|
119
160
|
keepPlanPolicy: true
|
|
120
|
-
instructionSource:
|
|
161
|
+
instructionSource: host
|
|
121
162
|
instructionMaxBytes: 65536
|
|
122
163
|
|
|
123
164
|
- id: tool-catalog
|
|
124
165
|
name: ./tool-catalog.mjs
|
|
125
166
|
config:
|
|
126
167
|
descriptionMaxLength: 200
|
|
127
|
-
|
|
128
|
-
|
|
168
|
+
presentation: 'both'
|
|
169
|
+
pagedToolPatterns: ['mcp__*']
|
|
170
|
+
maxResidentTokens: 8000
|
|
171
|
+
|
|
172
|
+
- id: working-context
|
|
173
|
+
name: ./working-context.mjs
|
|
174
|
+
|
|
175
|
+
# The runtime degeneration circuit breaker: folds a stall (consecutive zero-
|
|
176
|
+
# output long-reasoning steps) or echo (identical-argument tool failures)
|
|
177
|
+
# signal from the durable session event stream and fires once per episode —
|
|
178
|
+
# injecting a breaker message at pre-step and stepping the reasoning effort
|
|
179
|
+
# one notch down for the next few requests. With no signal it never rewrites
|
|
180
|
+
# a request, so the route's explicit effort and the prefix cache stay
|
|
181
|
+
# untouched. This is the outside force the persona's reflection fuse cannot
|
|
182
|
+
# be: see DSH discussion #5976 and the Agent Note that constrains dynamic
|
|
183
|
+
# reasoning effort to this triggered-only form.
|
|
184
|
+
- id: guard
|
|
185
|
+
name: ./guard.mjs
|
|
186
|
+
config:
|
|
187
|
+
enabled: true
|
|
188
|
+
sensitivity: 'balanced'
|
|
189
|
+
stallReasoningChars: 8000
|
|
190
|
+
globalStallCap: 4
|
|
191
|
+
echoFailures: 3
|
|
192
|
+
|
|
193
|
+
# The paging activation handle the catalog points at: with `pagedToolPatterns`
|
|
194
|
+
# non-empty this row is what lets `tool_activate({ namespace })` bring one
|
|
195
|
+
# paged namespace back onto the wire (and the generated SDK) for the session.
|
|
196
|
+
- id: tool-activate
|
|
197
|
+
name: ./tool-activate.mjs
|
|
198
|
+
|
|
199
|
+
# The key-fact register: the model pins a hard constraint / confirmed decision /
|
|
200
|
+
# failed path with `fact_register`, the fold rebuilds the register from the
|
|
201
|
+
# durable event stream, and working-context renders it as one field of the
|
|
202
|
+
# [Working Context: ...] line — the surface that lands inside the guaranteed
|
|
203
|
+
# local attention window every step. The counter to V4.1's long-session
|
|
204
|
+
# forgetting; the fold replays identically after resume and compaction.
|
|
205
|
+
- id: fact-ledger
|
|
206
|
+
name: ./fact-ledger.mjs
|
|
129
207
|
|
|
130
208
|
# The harness's workspace-instruction loader. Under the default
|
|
209
|
+
# `instructionSource: host` this row owns the channel: its baseline and dynamic
|
|
210
|
+
# user-role messages reach the model untouched. Under
|
|
131
211
|
# `instructionSource: system-prompt` the content reaches the model through the
|
|
132
|
-
# system prompt instead
|
|
133
|
-
# `minimal-prompt`; the
|
|
134
|
-
#
|
|
212
|
+
# system prompt instead and these injections are condensed or dropped by
|
|
213
|
+
# `minimal-prompt`; under `hint` the first is replaced by a pointer and the
|
|
214
|
+
# rest dropped. The row stays mounted in every mode: it is the default's whole
|
|
215
|
+
# delivery path, and its `maxBytes` remains the budget the other two consult.
|
|
135
216
|
- id: agent-instructions
|
|
136
217
|
name: '@deepseek-ai/dsh-agent-instructions'
|
|
137
218
|
config:
|
|
@@ -139,50 +220,14 @@
|
|
|
139
220
|
|
|
140
221
|
# ── shell ───────────────────────────────────────────────────────────────────
|
|
141
222
|
|
|
142
|
-
#
|
|
143
|
-
#
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
# session (both tools register the name `bash`), so shell state survives across
|
|
147
|
-
# calls.
|
|
148
|
-
- id: persistent-shell
|
|
149
|
-
name: cordis:group
|
|
150
|
-
group: true
|
|
223
|
+
# Standard Stdio shell tools: fresh subprocess per command with active-voice description
|
|
224
|
+
# cards, structured exit codes, and background job support. Exactly one mounts per host.
|
|
225
|
+
- id: tool-bash
|
|
226
|
+
name: '@deepseek-ai/dsh-tool-bash'
|
|
151
227
|
disabled: !!js process.platform === 'win32'
|
|
152
|
-
isolate:
|
|
153
|
-
terminals: true
|
|
154
|
-
config:
|
|
155
|
-
- id: pty
|
|
156
|
-
name: '@deepseek-ai/dsh-terminal'
|
|
157
228
|
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
config:
|
|
161
|
-
timeoutMs: 300000
|
|
162
|
-
|
|
163
|
-
- id: persistent-bash
|
|
164
|
-
name: '@deepseek-ai/dsh-tool-bash-persistent'
|
|
165
|
-
config:
|
|
166
|
-
timeoutMs: 300000
|
|
167
|
-
description: |-
|
|
168
|
-
Run commands in a bash shell
|
|
169
|
-
* When invoking this tool, the contents of the "command" parameter does NOT need to be XML-escaped.
|
|
170
|
-
* You don't have access to the internet via this tool.
|
|
171
|
-
* You do have access to a mirror of common linux and python packages via apt and pip.
|
|
172
|
-
* State is persistent across command calls and discussions with the user.
|
|
173
|
-
* To inspect a particular line range of a file, e.g. lines 10-25, try 'sed -n 10,25p /path/to/the/file'.
|
|
174
|
-
* Please avoid commands that may produce a very large amount of output.
|
|
175
|
-
* Please run long lived commands in the background, e.g. 'sleep 10 &' or start a server in the background.
|
|
176
|
-
|
|
177
|
-
# Windows-only `bash` tool (custom-bash.mjs): the PTY backend above is
|
|
178
|
-
# linux/darwin-only, so win32 disables the persistent-shell group and
|
|
179
|
-
# registers this `bash` through the ordinary cross-platform subprocess seam
|
|
180
|
-
# (Git Bash). Both platforms end up with exactly one tool named `bash`.
|
|
181
|
-
# Non-zero exit is reported not thrown; state does NOT persist across calls on
|
|
182
|
-
# this path; no OS sandbox confinement on Windows. `bashPath` is optional
|
|
183
|
-
# (defaults to Git Bash inference); set it explicitly when git is not on PATH.
|
|
184
|
-
- id: custom-bash
|
|
185
|
-
name: ./custom-bash.mjs
|
|
229
|
+
- id: tool-pwsh
|
|
230
|
+
name: '@deepseek-ai/dsh-tool-pwsh'
|
|
186
231
|
disabled: !!js process.platform !== 'win32'
|
|
187
232
|
|
|
188
233
|
# ── filesystem ──────────────────────────────────────────────────────────────
|
|
@@ -299,8 +344,8 @@
|
|
|
299
344
|
- id: tool-result-pruner
|
|
300
345
|
name: '@deepseek-ai/dsh-compaction-tool-result-pruner'
|
|
301
346
|
config:
|
|
302
|
-
thresholdChars:
|
|
303
|
-
headChars:
|
|
347
|
+
thresholdChars: 4096
|
|
348
|
+
headChars: 2048
|
|
304
349
|
tailChars: 1024
|
|
305
350
|
|
|
306
351
|
# ── delegation and workflows ────────────────────────────────────────────────
|
|
@@ -367,8 +412,8 @@
|
|
|
367
412
|
enableRunInBackground: false
|
|
368
413
|
maxDepth: provider-managed
|
|
369
414
|
|
|
370
|
-
- id: workflow-
|
|
371
|
-
name: '@deepseek-ai/dsh-workflow-
|
|
415
|
+
- id: workflow-ptc
|
|
416
|
+
name: '@deepseek-ai/dsh-workflow-ptc'
|
|
372
417
|
config:
|
|
373
418
|
provider: spawn
|
|
374
419
|
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* fact-ledger — the LiangShen preset's key-fact register: a lightweight tool
|
|
3
|
+
* the model uses to pin the facts that must survive a long session, and a
|
|
4
|
+
* fold that re-derives the current register from the durable event stream.
|
|
5
|
+
*
|
|
6
|
+
* Why this exists: community feedback on DeepSeek-V4.1 (r/DeepSeek 1wlssvo,
|
|
7
|
+
* and the architecture's own numbers) is that long conversations forget —
|
|
8
|
+
* CSA2's sparse index only guarantees a query the most recent local window,
|
|
9
|
+
* and a hard constraint the user stated eighty turns ago competes for Top-K
|
|
10
|
+
* slots with every tool schema and log line since. The working-context
|
|
11
|
+
* projection is the one surface that lands inside that guaranteed window
|
|
12
|
+
* every step, so the register rides it: the sibling working-context plugin
|
|
13
|
+
* renders the current facts as one of its fields, republished only on change.
|
|
14
|
+
*
|
|
15
|
+
* The register itself is a list of single-line facts, newest last, rebuilt by
|
|
16
|
+
* replaying `tool/call` events for this tool from the session log — exactly
|
|
17
|
+
* the way the paging activation state replays. A fact is a string the model
|
|
18
|
+
* writes; registering a new fact APPENDS, and registering one already present
|
|
19
|
+
* is a no-op report. REVOCATION is append-only too: a `revoke` entry removes
|
|
20
|
+
* every earlier fact carrying the same tag, so the fold stays deterministic
|
|
21
|
+
* after resume and compaction without any process memory.
|
|
22
|
+
*
|
|
23
|
+
* The tool is deliberately small: it validates and reports, it does not edit
|
|
24
|
+
* the context itself. The projection the model sees next step is the fold of
|
|
25
|
+
* the log the runtime appended for this call.
|
|
26
|
+
*/
|
|
27
|
+
|
|
28
|
+
/** Cordis plugin name used by loader diagnostics. */
|
|
29
|
+
export const name = 'liangshen-fact-ledger'
|
|
30
|
+
|
|
31
|
+
/** The tools registry must exist before the ledger tool can register. */
|
|
32
|
+
export const inject = ['tools']
|
|
33
|
+
|
|
34
|
+
/** The model-facing registration tool this plugin mounts. */
|
|
35
|
+
export const FACT_LEDGER_TOOL = 'fact_register'
|
|
36
|
+
|
|
37
|
+
/** Cap one fact so a single entry stays a glance, not a paragraph. */
|
|
38
|
+
export const MAX_FACT_CHARS = 160
|
|
39
|
+
|
|
40
|
+
/** Cap the register so the ledger cannot itself flood the local window. */
|
|
41
|
+
export const MAX_FACTS = 12
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Fold the current fact register from the event stream: every successful
|
|
45
|
+
* `fact_register` call appends its fact (or revokes by tag). Facts carry no
|
|
46
|
+
* ids — revocation matches on the optional `tag`, and an untagged fact can
|
|
47
|
+
* only be revoked by revoking its exact text as the tag of last resort.
|
|
48
|
+
*/
|
|
49
|
+
export function foldFactLedger(events) {
|
|
50
|
+
const facts = []
|
|
51
|
+
for (const event of Array.isArray(events) ? events : []) {
|
|
52
|
+
if (event?.type !== 'tool/call' || event.data?.name !== FACT_LEDGER_TOOL) continue
|
|
53
|
+
let args = event.data?.arguments
|
|
54
|
+
if (typeof args === 'string') {
|
|
55
|
+
try { args = JSON.parse(args) } catch { args = undefined }
|
|
56
|
+
}
|
|
57
|
+
if (args === undefined || args === null) continue
|
|
58
|
+
if (typeof args.revoke === 'string' && args.revoke.trim() !== '') {
|
|
59
|
+
const tag = args.revoke.trim()
|
|
60
|
+
for (let index = facts.length - 1; index >= 0; index -= 1) {
|
|
61
|
+
if (facts[index].tag === tag || facts[index].text === tag) facts.splice(index, 1)
|
|
62
|
+
}
|
|
63
|
+
continue
|
|
64
|
+
}
|
|
65
|
+
if (typeof args.fact !== 'string' || args.fact.trim() === '') continue
|
|
66
|
+
const text = args.fact.trim().slice(0, MAX_FACT_CHARS)
|
|
67
|
+
if (facts.some(entry => entry.text === text)) continue
|
|
68
|
+
const tag = typeof args.tag === 'string' && args.tag.trim() !== '' ? args.tag.trim() : undefined
|
|
69
|
+
facts.push({ text, tag })
|
|
70
|
+
if (facts.length > MAX_FACTS) facts.splice(0, facts.length - MAX_FACTS)
|
|
71
|
+
}
|
|
72
|
+
return facts
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* Render the register as the working-context field value, or undefined when
|
|
77
|
+
* the register is empty. Tags annotate their fact inline.
|
|
78
|
+
*/
|
|
79
|
+
export function renderLedgerField(facts) {
|
|
80
|
+
if (!Array.isArray(facts) || facts.length === 0) return undefined
|
|
81
|
+
const rendered = facts.map(entry => entry.tag === undefined ? entry.text : `${entry.text} [${entry.tag}]`)
|
|
82
|
+
return `key facts: ${rendered.join(' ; ')}`
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/** Register the `fact_register` tool. */
|
|
86
|
+
export function apply(ctx) {
|
|
87
|
+
ctx.tools.register({
|
|
88
|
+
name: FACT_LEDGER_TOOL,
|
|
89
|
+
description: [
|
|
90
|
+
'Pin one key fact into this session working context — the line the runtime projects next to the newest message every step. Use it for the facts a long session must not lose: a hard user constraint, a confirmed architecture decision, a path that already failed.',
|
|
91
|
+
`A fact is one short line (<= ${MAX_FACT_CHARS} chars); at most ${MAX_FACTS} stay pinned, the oldest dropping off. Pass the same text again to no-op; pass the revoke field with a fact tag (or its exact text) to unpin everything under it.`,
|
|
92
|
+
'Pin sparingly: the register rides the guaranteed-attention window, and flooding it dilutes every other fact.',
|
|
93
|
+
].join('\n'),
|
|
94
|
+
parameters: {
|
|
95
|
+
type: 'object',
|
|
96
|
+
properties: {
|
|
97
|
+
fact: {
|
|
98
|
+
type: 'string',
|
|
99
|
+
description: 'The single-line fact to pin (for example "User requires TypeScript strict mode, no any"). Omit when revoking.',
|
|
100
|
+
},
|
|
101
|
+
tag: {
|
|
102
|
+
type: 'string',
|
|
103
|
+
description: 'An optional short tag naming the fact\'s topic (for example "constraints", "auth-decision") so it can be revoked by tag later.',
|
|
104
|
+
},
|
|
105
|
+
revoke: {
|
|
106
|
+
type: 'string',
|
|
107
|
+
description: 'Revoke every pinned fact under this tag (or matching this exact text). When set, the fact field is ignored.',
|
|
108
|
+
},
|
|
109
|
+
},
|
|
110
|
+
additionalProperties: false,
|
|
111
|
+
},
|
|
112
|
+
output: {
|
|
113
|
+
schema: {
|
|
114
|
+
type: 'object',
|
|
115
|
+
additionalProperties: false,
|
|
116
|
+
properties: {
|
|
117
|
+
text: { type: 'string' },
|
|
118
|
+
},
|
|
119
|
+
required: ['text'],
|
|
120
|
+
},
|
|
121
|
+
render: (_args, value) => [{ type: 'text', text: value.text }],
|
|
122
|
+
},
|
|
123
|
+
/**
|
|
124
|
+
* Concurrency-safe: the handler only validates and reports; the register
|
|
125
|
+
* itself is the fold of the durable log the runtime appends for the call,
|
|
126
|
+
* so overlapping registrations cannot corrupt shared state.
|
|
127
|
+
*/
|
|
128
|
+
isConcurrencySafe: () => true,
|
|
129
|
+
async execute(args) {
|
|
130
|
+
if (typeof args?.revoke === 'string' && args.revoke.trim() !== '') {
|
|
131
|
+
return { text: `Revocation recorded for "${args.revoke.trim()}": every pinned fact under that tag (or matching that text) is dropped from the next step\'s working context.` }
|
|
132
|
+
}
|
|
133
|
+
if (typeof args?.fact !== 'string' || args.fact.trim() === '') {
|
|
134
|
+
throw new Error('fact_register requires either a non-empty `fact` to pin or a non-empty `revoke` tag/text to unpin')
|
|
135
|
+
}
|
|
136
|
+
const text = args.fact.trim().slice(0, MAX_FACT_CHARS)
|
|
137
|
+
const tagged = typeof args?.tag === 'string' && args.tag.trim() !== '' ? ` under tag "${args.tag.trim()}"` : ''
|
|
138
|
+
return { text: `Pinned${tagged}: "${text}". It rides the working-context line from the next step on.` }
|
|
139
|
+
},
|
|
140
|
+
})
|
|
141
|
+
}
|