@linxin666/dsh-liangshen 0.1.13
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/LICENSE +202 -0
- package/README.i18n.yaml +6 -0
- package/README.md +85 -0
- package/README.zh.md +85 -0
- package/cordis.patch.yml +11 -0
- package/lib/index.js +212 -0
- package/lib/types/index.d.ts +42 -0
- package/lib/types/sync.d.ts +31 -0
- package/package.json +61 -0
- package/presets/liangshen/NOTICE +3 -0
- package/presets/liangshen/agent.cordis.yml +289 -0
- package/presets/liangshen/preset.yml +3 -0
- package/presets/liangshen/tool-bootstrap.mjs +293 -0
- package/presets/liangshen-exact/NOTICE +4 -0
- package/presets/liangshen-exact/agent.cordis.yml +321 -0
- package/presets/liangshen-exact/preset.yml +3 -0
- package/presets/liangshen-exact/tool-bootstrap.mjs +10 -0
- package/src/index.test.ts +61 -0
- package/src/index.ts +119 -0
- package/src/sync.test.ts +125 -0
- package/src/sync.ts +131 -0
- package/tools/analyze-session.mjs +289 -0
|
@@ -0,0 +1,293 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Keep the first model request on a minimal-shaped input surface, then expose
|
|
3
|
+
* the full preset catalog once the session is safely anchored.
|
|
4
|
+
*
|
|
5
|
+
* Phase 1 (no persisted `tool/call` yet):
|
|
6
|
+
* - tool catalog: one platform shell plus `commonTools`
|
|
7
|
+
* - prompt sections: only the `persona` section (all other sections,
|
|
8
|
+
* including plan-mode's `plan:policy`, return after promotion)
|
|
9
|
+
* - runtime contexts: emptied (no sandbox/approval snapshot)
|
|
10
|
+
* - pre-step messages: only explicit user messages pass
|
|
11
|
+
*
|
|
12
|
+
* Promotion opens the full tool catalog and restores runtime contexts and all
|
|
13
|
+
* prompt sections. With `anchorGate` the promotion after the first tool call
|
|
14
|
+
* also requires one minimal-like reasoning block (a first block containing
|
|
15
|
+
* `we` and no `let me`) or the `maxBootstrapSteps` fallback.
|
|
16
|
+
* `promoteAfterFirstResponse` promotes a tool-less first response once it has
|
|
17
|
+
* responded, and also releases an anchor-gated session when its first turn
|
|
18
|
+
* ends (`turn/end`). With `promotedPresentation: code` the promoted catalog
|
|
19
|
+
* is presented as Code Mode (PTC): the wire shows a single `run_code` tool
|
|
20
|
+
* backed by the generated SDK, switched at the step boundary so the current
|
|
21
|
+
* step's native calls are never interrupted. `deferredSources` and
|
|
22
|
+
* `deferredGraceSteps` delay selected injected message kinds (workspace
|
|
23
|
+
* instructions, skill catalog) for a few steps after promotion.
|
|
24
|
+
*
|
|
25
|
+
* Source: https://github.com/xiaobright/dsh-anchored-standard (MIT), extended
|
|
26
|
+
* with the phase-1 quarantine and the stabilization controls above.
|
|
27
|
+
*/
|
|
28
|
+
|
|
29
|
+
/** Cordis plugin name used by loader diagnostics. */
|
|
30
|
+
export const name = 'anchored-tool-bootstrap'
|
|
31
|
+
|
|
32
|
+
/** Prompt assembly and the tool registry must exist before this filter runs. */
|
|
33
|
+
export const inject = ['systemPrompt', 'tools']
|
|
34
|
+
|
|
35
|
+
/** Message-source kinds the model may see during phase 1. */
|
|
36
|
+
const DEFAULT_MESSAGE_SOURCES = ['user']
|
|
37
|
+
|
|
38
|
+
/** Message-source kinds delayed after promotion. */
|
|
39
|
+
const DEFAULT_DEFERRED_SOURCES = []
|
|
40
|
+
|
|
41
|
+
function stringList(value, field, fallback) {
|
|
42
|
+
if (value === undefined) return [...fallback]
|
|
43
|
+
if (!Array.isArray(value) || value.length === 0 || value.some(item => typeof item !== 'string' || item.length === 0)) {
|
|
44
|
+
throw new TypeError(`${name}: ${field} must be a non-empty array of non-empty strings`)
|
|
45
|
+
}
|
|
46
|
+
return [...new Set(value)]
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
function stringListOrEmpty(value, field) {
|
|
50
|
+
if (value === undefined) return []
|
|
51
|
+
if (!Array.isArray(value) || value.some(item => typeof item !== 'string' || item.length === 0)) {
|
|
52
|
+
throw new TypeError(`${name}: ${field} must be an array of non-empty strings`)
|
|
53
|
+
}
|
|
54
|
+
return [...new Set(value)]
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
function integerAtLeast(value, field, minimum) {
|
|
58
|
+
if (!Number.isInteger(value) || value < minimum) {
|
|
59
|
+
throw new TypeError(`${name}: ${field} must be an integer >= ${minimum}`)
|
|
60
|
+
}
|
|
61
|
+
return value
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
function countWord(text, regex) {
|
|
65
|
+
return [...text.matchAll(regex)].length
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Anchor classifier for promotion gating. A reasoning block counts as
|
|
70
|
+
* minimal-like when it contains `we` and no `let me`; a block with any
|
|
71
|
+
* `let me` is standard-like; everything else is ambiguous. This is a
|
|
72
|
+
* deliberate relaxation of the modeltest identity probe: the gate decides
|
|
73
|
+
* trajectory surface, not model identity, and `we` presence without
|
|
74
|
+
* first-person execution phrases is the stable surface marker.
|
|
75
|
+
*/
|
|
76
|
+
export function classifyReasoning(text) {
|
|
77
|
+
const trimmed = String(text ?? '').trim()
|
|
78
|
+
const we = countWord(trimmed, /\bwe\b/gi)
|
|
79
|
+
const letMe = countWord(trimmed, /\blet me\b/gi)
|
|
80
|
+
const metrics = { we, letMe }
|
|
81
|
+
if (we > 0 && letMe === 0) return { label: 'minimal-like', score: 4, metrics }
|
|
82
|
+
if (letMe > 0) return { label: 'standard-like', score: -4, metrics }
|
|
83
|
+
return { label: 'ambiguous', score: 0, metrics }
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* Whether the FIRST reasoning block of an assistant message classifies as
|
|
88
|
+
* minimal-like. Later blocks do not override an earlier standard-like first
|
|
89
|
+
* block.
|
|
90
|
+
*/
|
|
91
|
+
export function hasAnchoredReasoning(content) {
|
|
92
|
+
if (!Array.isArray(content)) return false
|
|
93
|
+
const first = content.find(block => block?.type === 'reasoning')
|
|
94
|
+
return first !== undefined && classifyReasoning(first.text).label === 'minimal-like'
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* Whether one pre-step message is an explicit user message. Only `kind:
|
|
99
|
+
* 'user'` passes; injected kinds and source-less seed messages never pass.
|
|
100
|
+
*/
|
|
101
|
+
function isAllowedMessage(message, allowedSources) {
|
|
102
|
+
const kind = message.source?.kind
|
|
103
|
+
return kind === 'user' && allowedSources.has(kind)
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
/** Whether one pre-step message belongs to a deferred injection kind. */
|
|
107
|
+
function isDeferredMessage(message, deferredSources) {
|
|
108
|
+
const kind = message.source?.kind
|
|
109
|
+
return kind !== undefined && deferredSources.has(kind)
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* Phase-2 promotion state per session. Sessions append events only, so the
|
|
114
|
+
* scan resumes from the first event it has not inspected yet.
|
|
115
|
+
*/
|
|
116
|
+
const promotionBySession = new WeakMap()
|
|
117
|
+
|
|
118
|
+
/** Live agents observed by the assemble/pre-step listeners, keyed by session. */
|
|
119
|
+
const agentBySession = new WeakMap()
|
|
120
|
+
|
|
121
|
+
function stateFor(session) {
|
|
122
|
+
let state = promotionBySession.get(session)
|
|
123
|
+
if (state === undefined) {
|
|
124
|
+
state = {
|
|
125
|
+
next: 0,
|
|
126
|
+
promoted: false,
|
|
127
|
+
toolCalled: false,
|
|
128
|
+
responded: false,
|
|
129
|
+
anchored: false,
|
|
130
|
+
turnEnded: false,
|
|
131
|
+
steps: 0,
|
|
132
|
+
deferredSteps: 0,
|
|
133
|
+
presentationApplied: false,
|
|
134
|
+
}
|
|
135
|
+
promotionBySession.set(session, state)
|
|
136
|
+
}
|
|
137
|
+
return state
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
/**
|
|
141
|
+
* Switch one agent's wire presentation to Code Mode (PTC: a single `run_code`
|
|
142
|
+
* tool backed by the generated SDK) after promotion. `agent.ctx.tools` is the
|
|
143
|
+
* per-agent view of the host registry, so the switch affects this session only.
|
|
144
|
+
*/
|
|
145
|
+
function applyPresentation(agent, state, policy) {
|
|
146
|
+
if (state.presentationApplied || policy.promotedPresentation !== 'code') return
|
|
147
|
+
state.presentationApplied = true
|
|
148
|
+
const tools = agent.ctx.tools
|
|
149
|
+
if (tools === undefined) return
|
|
150
|
+
tools.presentAs('code')
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
/**
|
|
154
|
+
* a) first tool call, no anchor gate — promote immediately;
|
|
155
|
+
* b) first tool call, anchored or `maxBootstrapSteps` fallback — promote;
|
|
156
|
+
* c) first tool call, still gated, but the first turn ended and
|
|
157
|
+
* `promoteAfterFirstResponse` is set — release on the new user turn (the
|
|
158
|
+
* release happens during prompt assembly, so that turn already gets the
|
|
159
|
+
* full catalog);
|
|
160
|
+
* d) tool-less first response with `promoteAfterFirstResponse` — promote.
|
|
161
|
+
*/
|
|
162
|
+
function decidePromotion(state, config) {
|
|
163
|
+
if (state.toolCalled && config.anchorGate !== true) return true
|
|
164
|
+
if (state.toolCalled && config.anchorGate === true && (state.anchored || state.steps >= config.maxBootstrapSteps)) return true
|
|
165
|
+
if (state.toolCalled && config.anchorGate === true && config.promoteAfterFirstResponse === true && state.turnEnded) return true
|
|
166
|
+
if (!state.toolCalled && state.responded && config.promoteAfterFirstResponse === true) return true
|
|
167
|
+
return false
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
/** Scan newly appended session events and update promotion state. */
|
|
171
|
+
function scanEvents(state, session) {
|
|
172
|
+
const events = session.events
|
|
173
|
+
for (; state.next < events.length; state.next += 1) {
|
|
174
|
+
const event = events[state.next]
|
|
175
|
+
if (event === undefined) continue
|
|
176
|
+
if (event.type === 'tool/call') {
|
|
177
|
+
state.toolCalled = true
|
|
178
|
+
} else if (event.type === 'step/start') {
|
|
179
|
+
state.steps += 1
|
|
180
|
+
} else if (event.type === 'turn/end') {
|
|
181
|
+
state.turnEnded = true
|
|
182
|
+
} else if (event.type === 'assistant/message') {
|
|
183
|
+
state.responded = true
|
|
184
|
+
if (!state.anchored) state.anchored = hasAnchoredReasoning(event.data?.message?.content)
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
/** Update one agent's promotion state and apply its post-promotion presentation. */
|
|
190
|
+
function refresh(agent, policy) {
|
|
191
|
+
const session = agent?.session
|
|
192
|
+
if (session === undefined) return undefined
|
|
193
|
+
const state = stateFor(session)
|
|
194
|
+
agentBySession.set(session, agent)
|
|
195
|
+
if (!state.promoted) {
|
|
196
|
+
scanEvents(state, session)
|
|
197
|
+
if (decidePromotion(state, policy)) state.promoted = true
|
|
198
|
+
}
|
|
199
|
+
if (state.promoted) applyPresentation(agent, state, policy)
|
|
200
|
+
return state
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
/** Register the per-session bootstrap quarantine and promotion policy. */
|
|
204
|
+
export function apply(ctx, config) {
|
|
205
|
+
const commonTools = stringList(config.commonTools, 'commonTools')
|
|
206
|
+
const shellTools = stringList(config.shellTools, 'shellTools')
|
|
207
|
+
const messageSources = new Set(stringList(config.messageSources, 'messageSources', DEFAULT_MESSAGE_SOURCES))
|
|
208
|
+
const deferredSources = new Set(stringListOrEmpty(config.deferredSources, 'deferredSources'))
|
|
209
|
+
const presentation = config.promotedPresentation ?? 'native'
|
|
210
|
+
if (presentation !== 'native' && presentation !== 'code') {
|
|
211
|
+
throw new TypeError(`${name}: promotedPresentation must be "native" or "code"`)
|
|
212
|
+
}
|
|
213
|
+
const policy = {
|
|
214
|
+
anchorGate: config.anchorGate === true,
|
|
215
|
+
promoteAfterFirstResponse: config.promoteAfterFirstResponse === true,
|
|
216
|
+
maxBootstrapSteps: integerAtLeast(config.maxBootstrapSteps ?? 4, 'maxBootstrapSteps', 1),
|
|
217
|
+
deferredGraceSteps: integerAtLeast(config.deferredGraceSteps ?? 0, 'deferredGraceSteps', 0),
|
|
218
|
+
promotedPresentation: presentation,
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
// Promotion is applied at step/turn boundaries, never while a step is still
|
|
222
|
+
// executing tools: switching the presentation mid-step would collapse the
|
|
223
|
+
// native calls that step already planned. By `step/end` the tool-call and
|
|
224
|
+
// reasoning events are durable, so the NEXT prompt assembly already sees
|
|
225
|
+
// Code Mode with its generated SDK section.
|
|
226
|
+
ctx.on('session/event', (session, event) => {
|
|
227
|
+
if (event.type !== 'step/end' && event.type !== 'turn/end') return
|
|
228
|
+
const state = stateFor(session)
|
|
229
|
+
if (!state.promoted) {
|
|
230
|
+
scanEvents(state, session)
|
|
231
|
+
if (decidePromotion(state, policy)) state.promoted = true
|
|
232
|
+
}
|
|
233
|
+
if (state.promoted) {
|
|
234
|
+
const agent = agentBySession.get(session)
|
|
235
|
+
if (agent !== undefined) applyPresentation(agent, state, policy)
|
|
236
|
+
}
|
|
237
|
+
})
|
|
238
|
+
|
|
239
|
+
// `prepend: true` puts both filters at the outermost position of their
|
|
240
|
+
// waterfall, so `await next()` always observes the complete downstream
|
|
241
|
+
// result (including messages appended by listener order, not row order)
|
|
242
|
+
// before the quarantine strips it.
|
|
243
|
+
ctx.on('system-prompt/assemble', async (_assembly, context, next) => {
|
|
244
|
+
const assembled = await next()
|
|
245
|
+
const agent = context.agent
|
|
246
|
+
if (agent === undefined) return assembled
|
|
247
|
+
const state = refresh(agent, policy)
|
|
248
|
+
if (state.promoted) return assembled
|
|
249
|
+
|
|
250
|
+
const available = new Set(assembled.tools.map(tool => tool.name))
|
|
251
|
+
const selectedShells = shellTools.filter(toolName => available.has(toolName))
|
|
252
|
+
const missingCommon = commonTools.filter(toolName => !available.has(toolName))
|
|
253
|
+
if (selectedShells.length !== 1 || missingCommon.length > 0) {
|
|
254
|
+
throw new Error(
|
|
255
|
+
`${name}: expected exactly one bootstrap shell and every common tool; `
|
|
256
|
+
+ `shells=${JSON.stringify(selectedShells)}, missing=${JSON.stringify(missingCommon)}`,
|
|
257
|
+
)
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
const bootstrap = new Set([...selectedShells, ...commonTools])
|
|
261
|
+
return {
|
|
262
|
+
...assembled,
|
|
263
|
+
tools: assembled.tools.filter(tool => bootstrap.has(tool.name)),
|
|
264
|
+
contexts: [],
|
|
265
|
+
...(Array.isArray(assembled.sections)
|
|
266
|
+
? { sections: assembled.sections.filter(section => section?.name === 'persona') }
|
|
267
|
+
: {}),
|
|
268
|
+
}
|
|
269
|
+
}, { prepend: true })
|
|
270
|
+
|
|
271
|
+
ctx.on('agent/pre-step', async (payload, next) => {
|
|
272
|
+
const decision = await next()
|
|
273
|
+
const agent = payload.agent
|
|
274
|
+
if (agent === undefined || decision.kind !== 'enter') return decision
|
|
275
|
+
const state = refresh(agent, policy)
|
|
276
|
+
if (state === undefined) return decision
|
|
277
|
+
|
|
278
|
+
if (!state.promoted) {
|
|
279
|
+
return {
|
|
280
|
+
...decision,
|
|
281
|
+
messages: decision.messages.filter(message => isAllowedMessage(message, messageSources)),
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
if (state.deferredSteps < policy.deferredGraceSteps) {
|
|
285
|
+
state.deferredSteps += 1
|
|
286
|
+
return {
|
|
287
|
+
...decision,
|
|
288
|
+
messages: decision.messages.filter(message => !isDeferredMessage(message, deferredSources)),
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
return decision
|
|
292
|
+
}, { prepend: true })
|
|
293
|
+
}
|
|
@@ -0,0 +1,321 @@
|
|
|
1
|
+
# The `liangshen-exact` (梁神模式-精确实验) agent preset: phase 1 exposes the
|
|
2
|
+
# builtin Minimal preset's exact two tools (persistent `bash` plus
|
|
3
|
+
# `str_replace_editor`) and the same one-line persona, with no runtime contexts
|
|
4
|
+
# and no injected pre-step messages; after a stabilized anchor the full
|
|
5
|
+
# Standard catalog and the ordinary injections open. This is the A/B variant of
|
|
6
|
+
# `liangshen`: the phase-1 surface matches the official "exact RL prompt and
|
|
7
|
+
# schemas" snapshot byte-for-byte on the model-visible wire shape, at the cost
|
|
8
|
+
# of keeping the persistent shell for the whole session. Unlike the builtin
|
|
9
|
+
# Minimal preset, the phase-1 editor inherits the host file sandbox instead of
|
|
10
|
+
# mounting a bare local filesystem (see the filesystem section below).
|
|
11
|
+
#
|
|
12
|
+
# Adapted from the builtin `minimal` and `standard` presets.
|
|
13
|
+
#
|
|
14
|
+
# This file is an AGENT-PLANE composition. The roster mounts it ONCE under a
|
|
15
|
+
# standing scope; every session naming it joins by scope parentage, so the
|
|
16
|
+
# tools and prompt sections registered here cover each joined agent while a
|
|
17
|
+
# session's own state stays keyed per Session/Agent inside the plugins. The
|
|
18
|
+
# host composition (`base.cordis.yml` + `web.cordis.yml`) keeps everything a
|
|
19
|
+
# preset must not own: the registries themselves, the sandbox and approval
|
|
20
|
+
# stack, persistence, and the model route.
|
|
21
|
+
#
|
|
22
|
+
# A service row here MUST sit inside a group carrying an `isolate` realm.
|
|
23
|
+
# Without one it publishes into the root realm, where it is process-global —
|
|
24
|
+
# another preset publishing the same name collides, and a host reader would
|
|
25
|
+
# resolve one preset's instance for every session; `dsh-agent-presets` rejects
|
|
26
|
+
# that at mount. `true` means an entry-local realm: this standing mount's own
|
|
27
|
+
# private instance, apart from every other preset's. (A shared label does NOT
|
|
28
|
+
# pool instances — `provide()` throws on the second registration under the
|
|
29
|
+
# same realm symbol; labels join REALMS, and are not what this file needs.)
|
|
30
|
+
|
|
31
|
+
# ── identity ────────────────────────────────────────────────────────────────
|
|
32
|
+
|
|
33
|
+
# Phase 1 shows only this one-line persona: `tool-bootstrap` filters the
|
|
34
|
+
# assembled sections down to `persona` during phase 1 and restores every
|
|
35
|
+
# section after promotion, so plan-mode's `plan:policy` takes effect instead
|
|
36
|
+
# of being permanently shadowed by a `complete` persona.
|
|
37
|
+
- id: persona
|
|
38
|
+
name: '@deepseek-ai/dsh-persona'
|
|
39
|
+
config:
|
|
40
|
+
text: You are a helpful software engineer assistant.
|
|
41
|
+
|
|
42
|
+
# Two-phase input bootstrap with the exact Minimal phase-1 tools. Before the
|
|
43
|
+
# first durable tool/call event the model sees only persistent `bash` plus
|
|
44
|
+
# `str_replace_editor`, only the `persona` prompt section, no runtime
|
|
45
|
+
# contexts, and only direct user messages. `anchorGate` holds the promotion
|
|
46
|
+
# open until the first reasoning block is minimal-like (four-step fallback);
|
|
47
|
+
# `promoteAfterFirstResponse` avoids a permanent two-tool session after a
|
|
48
|
+
# tool-less first response, and releases an anchor-gated session once its
|
|
49
|
+
# first turn ends (`turn/end`). After promotion the catalog is presented as
|
|
50
|
+
# Code Mode (PTC): a single `run_code` tool on the wire, switched at the step
|
|
51
|
+
# boundary; workspace instructions and the skill catalog are deferred one
|
|
52
|
+
# step after promotion. This preset shares the main preset's
|
|
53
|
+
# `tool-bootstrap.mjs` implementation; only this config differs.
|
|
54
|
+
- id: tool-bootstrap
|
|
55
|
+
name: ./tool-bootstrap.mjs
|
|
56
|
+
config:
|
|
57
|
+
shellTools: [bash]
|
|
58
|
+
commonTools: [str_replace_editor]
|
|
59
|
+
messageSources: [user]
|
|
60
|
+
anchorGate: true
|
|
61
|
+
maxBootstrapSteps: 4
|
|
62
|
+
promoteAfterFirstResponse: true
|
|
63
|
+
deferredSources: [agent-instructions, skill-catalog]
|
|
64
|
+
deferredGraceSteps: 1
|
|
65
|
+
promotedPresentation: code
|
|
66
|
+
|
|
67
|
+
# Workspace instructions are quarantined by `tool-bootstrap` during phase 1
|
|
68
|
+
# and deferred one step after promotion, then stay current.
|
|
69
|
+
- id: agent-instructions
|
|
70
|
+
name: '@deepseek-ai/dsh-agent-instructions'
|
|
71
|
+
config:
|
|
72
|
+
maxBytes: 65536
|
|
73
|
+
|
|
74
|
+
# ── minimal phase-1 shell ───────────────────────────────────────────────────
|
|
75
|
+
|
|
76
|
+
# The PTY registry is an agent-owned service, so it lives in an entry-local
|
|
77
|
+
# realm. The backend still consumes the host sandbox policy and subprocess
|
|
78
|
+
# implementation, while the tool registers into this agent's scoped catalog.
|
|
79
|
+
# This persistent `bash` replaces the Standard ephemeral shell for the WHOLE
|
|
80
|
+
# session (both tools register the name `bash`), which is the exact-Minimal
|
|
81
|
+
# tradeoff this experimental preset evaluates.
|
|
82
|
+
- id: persistent-shell
|
|
83
|
+
name: cordis:group
|
|
84
|
+
group: true
|
|
85
|
+
isolate:
|
|
86
|
+
terminals: true
|
|
87
|
+
config:
|
|
88
|
+
- id: pty
|
|
89
|
+
name: '@deepseek-ai/dsh-terminal'
|
|
90
|
+
|
|
91
|
+
- id: terminal-bash
|
|
92
|
+
name: '@deepseek-ai/dsh-terminal-bash'
|
|
93
|
+
config:
|
|
94
|
+
timeoutMs: 300000
|
|
95
|
+
|
|
96
|
+
- id: persistent-bash
|
|
97
|
+
name: '@deepseek-ai/dsh-tool-bash-persistent'
|
|
98
|
+
config:
|
|
99
|
+
timeoutMs: 300000
|
|
100
|
+
description: |-
|
|
101
|
+
Run commands in a bash shell
|
|
102
|
+
* When invoking this tool, the contents of the "command" parameter does NOT need to be XML-escaped.
|
|
103
|
+
* You don't have access to the internet via this tool.
|
|
104
|
+
* You do have access to a mirror of common linux and python packages via apt and pip.
|
|
105
|
+
* State is persistent across command calls and discussions with the user.
|
|
106
|
+
* To inspect a particular line range of a file, e.g. lines 10-25, try 'sed -n 10,25p /path/to/the/file'.
|
|
107
|
+
* Please avoid commands that may produce a very large amount of output.
|
|
108
|
+
* Please run long lived commands in the background, e.g. 'sleep 10 &' or start a server in the background.
|
|
109
|
+
|
|
110
|
+
# ── minimal phase-1 filesystem ──────────────────────────────────────────────
|
|
111
|
+
|
|
112
|
+
# Phase-1 editor as a direct top-level row: it reuses the host's sandboxed
|
|
113
|
+
# `ctx.fs`, not a bare local filesystem. No `dsh-fs-local` realm is mounted, so
|
|
114
|
+
# the phase-1 editor inherits the host file sandbox exactly like every
|
|
115
|
+
# Standard file tool, and the model-facing schema stays the builtin Minimal
|
|
116
|
+
# `str_replace_editor`.
|
|
117
|
+
- id: str-replace-editor
|
|
118
|
+
name: '@deepseek-ai/dsh-tool-str-replace-editor'
|
|
119
|
+
config:
|
|
120
|
+
maxOutputChars: 16000
|
|
121
|
+
|
|
122
|
+
# ── standard filesystem tools ───────────────────────────────────────────────
|
|
123
|
+
|
|
124
|
+
# Both register into the host `tools` registry and provide nothing, so
|
|
125
|
+
# they need no realm. The `fs` service and its policy stay in the host.
|
|
126
|
+
- id: tool-fs
|
|
127
|
+
name: '@deepseek-ai/dsh-tool-fs'
|
|
128
|
+
|
|
129
|
+
- id: tool-fs-search
|
|
130
|
+
name: '@deepseek-ai/dsh-tool-fs-search'
|
|
131
|
+
config:
|
|
132
|
+
sampleOverCapGlobResults: false
|
|
133
|
+
|
|
134
|
+
# ── background jobs ────────────────────────────────────────────────────────
|
|
135
|
+
|
|
136
|
+
# Only the model-facing controls. The task REGISTRY stays on the host plane:
|
|
137
|
+
# its producers sit outside any realm this file could put it in, and the
|
|
138
|
+
# registry is keyed by owning agent anyway. With the persistent shell, long
|
|
139
|
+
# commands run through `&`; these controls still expose whatever the host
|
|
140
|
+
# registry tracks.
|
|
141
|
+
- id: tool-jobs
|
|
142
|
+
name: '@deepseek-ai/dsh-tool-jobs'
|
|
143
|
+
|
|
144
|
+
# ── skills ──────────────────────────────────────────────────────────────────
|
|
145
|
+
|
|
146
|
+
# The skill REGISTRY lives in the host composition and is layered per scope:
|
|
147
|
+
# these rows register into THIS preset's layer of it, so they need no realm.
|
|
148
|
+
# `skill-filesystem` contributes local-root discovery for agents on this preset, and
|
|
149
|
+
# `tool-skill` gives them the catalog and loader; the merged catalog also
|
|
150
|
+
# carries whatever the deployment registered globally (repository plugins).
|
|
151
|
+
# The `skill-catalog` pre-step message is quarantined by `tool-bootstrap`
|
|
152
|
+
# during phase 1 and deferred one step after promotion, then stays current.
|
|
153
|
+
- id: skill-filesystem
|
|
154
|
+
name: '@deepseek-ai/dsh-skill-filesystem'
|
|
155
|
+
|
|
156
|
+
- id: tool-skill
|
|
157
|
+
name: '@deepseek-ai/dsh-tool-skill'
|
|
158
|
+
|
|
159
|
+
# ── goals ───────────────────────────────────────────────────────────────────
|
|
160
|
+
|
|
161
|
+
# Only the model-facing tool. The goal SERVICE, its session driver, and the
|
|
162
|
+
# `/goal` command stay on the host plane: the Gateway serves the goal domain as
|
|
163
|
+
# Remote endpoints whose receiver comes from a generated descriptor, so it
|
|
164
|
+
# resolves `goals` on the host and an entry-local realm here would hide it. The
|
|
165
|
+
# registry is keyed by session anyway, so one host instance serves every
|
|
166
|
+
# session. What a preset chooses is whether its agent can call the goal tool.
|
|
167
|
+
- id: tool-goal
|
|
168
|
+
name: '@deepseek-ai/dsh-tool-goal'
|
|
169
|
+
|
|
170
|
+
# ── plan mode ───────────────────────────────────────────────────────────────
|
|
171
|
+
|
|
172
|
+
# Plan state is per-agent by nature, so an entry-local realm is not a
|
|
173
|
+
# workaround here — it is the correct lifetime.
|
|
174
|
+
- id: planning
|
|
175
|
+
name: cordis:group
|
|
176
|
+
group: true
|
|
177
|
+
isolate:
|
|
178
|
+
planMode: true
|
|
179
|
+
config:
|
|
180
|
+
- id: plan-mode
|
|
181
|
+
name: '@deepseek-ai/dsh-plan-mode'
|
|
182
|
+
config:
|
|
183
|
+
section: |
|
|
184
|
+
You are in plan mode. Stay in plan mode until exit_plan_mode succeeds or the user switches the session mode. Imperative language to implement changes means plan the implementation, not execute it. A user's conversational agreement — including an answer confirming something you asked — approves nothing and does not end plan mode; fold the confirmed decision into the plan and submit it through exit_plan_mode.
|
|
185
|
+
|
|
186
|
+
Explore first. Use non-mutating reads, searches, static analysis, and checks to ground the plan in the actual repository. Do not edit or write files, change configuration, run formatters or code generation that rewrites tracked files, commit, or otherwise carry out the plan. Prefer existing functions and patterns over new machinery.
|
|
187
|
+
|
|
188
|
+
The tool catalog stays the same across modes for request-cache stability. These plan-mode rules override any later tool description or guidance that suggests using mutation tools; those tools remain listed to keep the tool catalog unchanged. Do not use todo_write to track this planning phase: it tracks implementation after an approved plan, while the plan itself belongs in exit_plan_mode.
|
|
189
|
+
|
|
190
|
+
Resolve discoverable facts by inspection. Use ask_user_question only for user-owned choices or material ambiguity that inspection cannot answer. Do not ask the user where code lives or how current behavior works when you can find out.
|
|
191
|
+
|
|
192
|
+
Make the plan decision-complete: state the goal and success criteria; group implementation changes by subsystem; identify public API, schema, and data-flow changes; cover edge cases, failure modes, tests, acceptance criteria, and explicit assumptions. Keep it concise enough to review but detailed enough that another engineer can implement it without making design decisions.
|
|
193
|
+
|
|
194
|
+
When ready, call exit_plan_mode with the complete plan markdown, starting with a # title. Make exit_plan_mode the only and final tool call in that assistant response: it presents the plan for approval, and implementation begins only in a later step after approval. Do not paste the final plan as a plain reply or ask "should I proceed?" through prose or ask_user_question. If review rejects it, incorporate the feedback and present again. If the review channel is unavailable or aborted, stay in plan mode and ask the user to switch modes manually; do not proceed with implementation.
|
|
195
|
+
|
|
196
|
+
# ── compaction ──────────────────────────────────────────────────────────────
|
|
197
|
+
|
|
198
|
+
# `compaction-basic` reads `toolResultPrune` through `ctx.get`, so the pruner must
|
|
199
|
+
# share this realm rather than sit outside it.
|
|
200
|
+
#
|
|
201
|
+
# `tokenMeter` is deliberately NOT in this realm: the meter stays on the HOST
|
|
202
|
+
# plane, and the rows here resolve that one instance. It takes no configuration,
|
|
203
|
+
# keys every fold by Session, and owns the context-meter projection units the
|
|
204
|
+
# browser reads for every session — behind a realm those units would come and go
|
|
205
|
+
# with whichever presets happen to be mounted. What a preset chooses is whether
|
|
206
|
+
# its agent compacts at all, which is `compaction-basic` below.
|
|
207
|
+
- id: compaction
|
|
208
|
+
name: cordis:group
|
|
209
|
+
group: true
|
|
210
|
+
isolate:
|
|
211
|
+
compaction: true
|
|
212
|
+
toolResultPruner: true
|
|
213
|
+
config:
|
|
214
|
+
- id: compaction-basic
|
|
215
|
+
name: '@deepseek-ai/dsh-compaction-basic'
|
|
216
|
+
|
|
217
|
+
- id: command-compact
|
|
218
|
+
name: '@deepseek-ai/dsh-command-compact'
|
|
219
|
+
|
|
220
|
+
- id: tool-result-pruner
|
|
221
|
+
name: '@deepseek-ai/dsh-compaction-tool-result-pruner'
|
|
222
|
+
config:
|
|
223
|
+
thresholdChars: 8192
|
|
224
|
+
headChars: 4096
|
|
225
|
+
tailChars: 1024
|
|
226
|
+
|
|
227
|
+
# ── delegation and workflows ────────────────────────────────────────────────
|
|
228
|
+
|
|
229
|
+
# The `subagents` registry and its spawn/fork backends live in the HOST
|
|
230
|
+
# composition: the registry is a process singleton whose cross-session queries
|
|
231
|
+
# the api-proxy serves to the browser, and a provider name may only be
|
|
232
|
+
# registered once. This preset contributes the delegation TOOLS, which resolve
|
|
233
|
+
# that host registry.
|
|
234
|
+
#
|
|
235
|
+
# `workflows` is different — nothing outside an agent reads it — so every row
|
|
236
|
+
# that reaches it shares one entry-local realm here, and a consumer left
|
|
237
|
+
# outside would resolve a host registry this preset does not populate.
|
|
238
|
+
#
|
|
239
|
+
# `tool-subagent-report` is host-plane for the same reason as the registry,
|
|
240
|
+
# not because a preset may not want it: it registers a CONTINUABLE SETUP on
|
|
241
|
+
# that singleton rather than a tool this agent calls, and the setup list is
|
|
242
|
+
# not scope-aware — one copy per mounted preset means every child gets
|
|
243
|
+
# `report` registered once per live session, which throws on the second.
|
|
244
|
+
- id: delegation
|
|
245
|
+
name: cordis:group
|
|
246
|
+
group: true
|
|
247
|
+
isolate:
|
|
248
|
+
workflowEngine: true
|
|
249
|
+
config:
|
|
250
|
+
- id: tool-subagent-control
|
|
251
|
+
name: '@deepseek-ai/dsh-tool-subagent-control'
|
|
252
|
+
|
|
253
|
+
- id: tool-subagent-list-agents
|
|
254
|
+
name: '@deepseek-ai/dsh-tool-subagent-control/list-agents'
|
|
255
|
+
|
|
256
|
+
- id: tool-subagent
|
|
257
|
+
name: '@deepseek-ai/dsh-tool-subagent'
|
|
258
|
+
config:
|
|
259
|
+
provider: spawn
|
|
260
|
+
toolName: subagent
|
|
261
|
+
backgroundMode: continuable
|
|
262
|
+
|
|
263
|
+
- id: tool-subagent-fork
|
|
264
|
+
name: '@deepseek-ai/dsh-tool-subagent'
|
|
265
|
+
config:
|
|
266
|
+
provider: fork
|
|
267
|
+
toolName: subagent_fork
|
|
268
|
+
backgroundMode: continuable
|
|
269
|
+
|
|
270
|
+
# Product providers are host-plane singletons. Copy this preset, then
|
|
271
|
+
# remove `disabled` from either ordinary tool row to expose that product
|
|
272
|
+
# only to agents composed from the copy.
|
|
273
|
+
- id: tool-subagent-codex
|
|
274
|
+
name: '@deepseek-ai/dsh-tool-subagent'
|
|
275
|
+
disabled: true
|
|
276
|
+
config:
|
|
277
|
+
provider: codex
|
|
278
|
+
toolName: subagent_codex
|
|
279
|
+
enableRunInBackground: false
|
|
280
|
+
maxDepth: provider-managed
|
|
281
|
+
|
|
282
|
+
- id: tool-subagent-claude-code
|
|
283
|
+
name: '@deepseek-ai/dsh-tool-subagent'
|
|
284
|
+
disabled: true
|
|
285
|
+
config:
|
|
286
|
+
provider: claude-code
|
|
287
|
+
toolName: subagent_claude_code
|
|
288
|
+
enableRunInBackground: false
|
|
289
|
+
maxDepth: provider-managed
|
|
290
|
+
|
|
291
|
+
- id: workflow-worker-thread
|
|
292
|
+
name: '@deepseek-ai/dsh-workflow-worker-thread'
|
|
293
|
+
config:
|
|
294
|
+
provider: spawn
|
|
295
|
+
|
|
296
|
+
- id: tool-workflow
|
|
297
|
+
name: '@deepseek-ai/dsh-tool-workflow'
|
|
298
|
+
|
|
299
|
+
- id: tool-ralph
|
|
300
|
+
name: '@deepseek-ai/dsh-tool-ralph'
|
|
301
|
+
config:
|
|
302
|
+
subagentProvider: spawn
|
|
303
|
+
maxRounds: 64
|
|
304
|
+
|
|
305
|
+
# ── remaining model-facing rows ─────────────────────────────────────────────
|
|
306
|
+
|
|
307
|
+
- id: tool-ask-user
|
|
308
|
+
name: '@deepseek-ai/dsh-tool-ask-user'
|
|
309
|
+
|
|
310
|
+
- id: tool-todo
|
|
311
|
+
name: '@deepseek-ai/dsh-tool-todo'
|
|
312
|
+
config:
|
|
313
|
+
allowParallelInProgress: true
|
|
314
|
+
|
|
315
|
+
# The `web` service and its search provider stay in the host composition; only
|
|
316
|
+
# the model-facing tool is per-session.
|
|
317
|
+
- id: tool-web
|
|
318
|
+
name: '@deepseek-ai/dsh-tool-web'
|
|
319
|
+
config:
|
|
320
|
+
fetch: false
|
|
321
|
+
searchTimeoutMs: 60000
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `liangshen-exact` shares its bootstrap implementation with the main
|
|
3
|
+
* `liangshen` preset (与主 preset 共用实现,仅 `tool-bootstrap` config 不同):
|
|
4
|
+
* the only difference between the two presets is this row's configuration in
|
|
5
|
+
* `agent.cordis.yml` (`shellTools`/`commonTools`), so the plugin logic below
|
|
6
|
+
* is re-exported rather than copied. Keep it that way to prevent the two
|
|
7
|
+
* copies from drifting.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
export { name, apply, classifyReasoning, hasAnchoredReasoning } from '../liangshen/tool-bootstrap.mjs'
|