@linxin666/dsh-liangshen 0.1.13 → 0.1.15
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 +13 -20
- package/README.zh.md +13 -20
- package/lib/index.js +204 -27
- package/lib/types/dsh-home.d.ts +16 -0
- package/lib/types/index.d.ts +5 -6
- package/lib/types/schema.d.ts +18 -0
- package/lib/types/sync.d.ts +18 -2
- package/package.json +2 -2
- package/presets/liangshen/NOTICE +3 -2
- package/presets/liangshen/agent.cordis.yml +81 -47
- package/presets/liangshen/preset.yml +1 -1
- package/presets/liangshen/tool-bootstrap.mjs +46 -3
- package/src/dsh-home.ts +36 -0
- package/src/index.test.ts +6 -0
- package/src/index.ts +15 -21
- package/src/schema.test.ts +64 -0
- package/src/schema.ts +110 -0
- package/src/sync.test.ts +90 -8
- package/src/sync.ts +78 -14
- package/presets/liangshen-exact/NOTICE +0 -4
- package/presets/liangshen-exact/agent.cordis.yml +0 -321
- package/presets/liangshen-exact/preset.yml +0 -3
- package/presets/liangshen-exact/tool-bootstrap.mjs +0 -10
package/src/sync.test.ts
CHANGED
|
@@ -2,14 +2,17 @@ import { describe, expect, it } from 'vitest'
|
|
|
2
2
|
import { existsSync, mkdirSync, mkdtempSync, rmSync, statSync, utimesSync, writeFileSync, readFileSync } from 'node:fs'
|
|
3
3
|
import { tmpdir } from 'node:os'
|
|
4
4
|
import { join } from 'node:path'
|
|
5
|
-
import { syncPresetTrees } from './sync.ts'
|
|
5
|
+
import { syncOnePreset, syncPresetTrees } from './sync.ts'
|
|
6
|
+
|
|
7
|
+
/** Minimal structurally valid agent.cordis.yml used by the sync fixtures. */
|
|
8
|
+
const VALID_AGENT_YAML = "- id: persona\n name: '@deepseek-ai/dsh-persona'\n"
|
|
6
9
|
|
|
7
10
|
function fixture(): { source: string; target: string; dispose: () => void } {
|
|
8
11
|
const base = mkdtempSync(join(tmpdir(), 'dsh-liangshen-'))
|
|
9
12
|
const source = join(base, 'presets')
|
|
10
13
|
const target = join(base, 'agent-presets')
|
|
11
14
|
mkdirSync(join(source, 'liangshen'), { recursive: true })
|
|
12
|
-
writeFileSync(join(source, 'liangshen', 'agent.cordis.yml'),
|
|
15
|
+
writeFileSync(join(source, 'liangshen', 'agent.cordis.yml'), VALID_AGENT_YAML)
|
|
13
16
|
writeFileSync(join(source, 'liangshen', 'tool-bootstrap.mjs'), 'export const name = "x"\n')
|
|
14
17
|
writeFileSync(join(source, 'liangshen', 'preset.yml'), 'name: 梁神模式\n')
|
|
15
18
|
return { source, target, dispose: () => rmSync(base, { recursive: true, force: true }) }
|
|
@@ -45,7 +48,20 @@ describe('syncPresetTrees', () => {
|
|
|
45
48
|
writeFileSync(join(f.target, 'liangshen', 'agent.cordis.yml'), 'changed\n')
|
|
46
49
|
const third = syncPresetTrees(f.source, f.target)
|
|
47
50
|
expect(third.synced).toEqual(['liangshen'])
|
|
48
|
-
expect(readFileSync(join(f.target, 'liangshen', 'agent.cordis.yml'), 'utf8')).toBe(
|
|
51
|
+
expect(readFileSync(join(f.target, 'liangshen', 'agent.cordis.yml'), 'utf8')).toBe(VALID_AGENT_YAML)
|
|
52
|
+
} finally { f.dispose() }
|
|
53
|
+
})
|
|
54
|
+
|
|
55
|
+
it('retires a previously bundled preset directory removed from the source', () => {
|
|
56
|
+
const f = fixture()
|
|
57
|
+
try {
|
|
58
|
+
syncPresetTrees(f.source, f.target)
|
|
59
|
+
mkdirSync(join(f.target, 'liangshen-exact'), { recursive: true })
|
|
60
|
+
writeFileSync(join(f.target, 'liangshen-exact', 'agent.cordis.yml'), VALID_AGENT_YAML)
|
|
61
|
+
const result = syncPresetTrees(f.source, f.target, ['liangshen-exact'])
|
|
62
|
+
expect(result.retired).toEqual(['liangshen-exact'])
|
|
63
|
+
expect(existsSync(join(f.target, 'liangshen-exact'))).toBe(false)
|
|
64
|
+
expect(existsSync(join(f.target, 'liangshen'))).toBe(true)
|
|
49
65
|
} finally { f.dispose() }
|
|
50
66
|
})
|
|
51
67
|
|
|
@@ -69,7 +85,7 @@ describe('syncPresetTrees', () => {
|
|
|
69
85
|
const second = syncPresetTrees(f.source, f.target)
|
|
70
86
|
expect(second.synced).toEqual(['liangshen'])
|
|
71
87
|
expect(existsSync(join(f.target, 'liangshen', 'tool-bootstrap.mjs'))).toBe(false)
|
|
72
|
-
expect(readFileSync(join(f.target, 'liangshen', 'agent.cordis.yml'), 'utf8')).toBe(
|
|
88
|
+
expect(readFileSync(join(f.target, 'liangshen', 'agent.cordis.yml'), 'utf8')).toBe(VALID_AGENT_YAML)
|
|
73
89
|
} finally { f.dispose() }
|
|
74
90
|
})
|
|
75
91
|
|
|
@@ -79,14 +95,16 @@ describe('syncPresetTrees', () => {
|
|
|
79
95
|
syncPresetTrees(f.source, f.target)
|
|
80
96
|
const source = join(f.source, 'liangshen', 'agent.cordis.yml')
|
|
81
97
|
const dest = join(f.target, 'liangshen', 'agent.cordis.yml')
|
|
82
|
-
|
|
98
|
+
// Same byte length, different content, so only the byte compare catches it.
|
|
99
|
+
const sourceText = readFileSync(source, 'utf8')
|
|
100
|
+
writeFileSync(dest, sourceText.replace('persona', 'parsena'))
|
|
83
101
|
const stat = statSync(source)
|
|
84
102
|
utimesSync(dest, stat.atime, stat.mtime)
|
|
85
103
|
expect(statSync(dest).size).toBe(stat.size)
|
|
86
104
|
expect(Math.abs(statSync(dest).mtimeMs - stat.mtimeMs)).toBeLessThan(1)
|
|
87
105
|
const second = syncPresetTrees(f.source, f.target)
|
|
88
106
|
expect(second.synced).toEqual(['liangshen'])
|
|
89
|
-
expect(readFileSync(dest, 'utf8')).toBe(
|
|
107
|
+
expect(readFileSync(dest, 'utf8')).toBe(VALID_AGENT_YAML)
|
|
90
108
|
} finally { f.dispose() }
|
|
91
109
|
})
|
|
92
110
|
|
|
@@ -99,7 +117,7 @@ describe('syncPresetTrees', () => {
|
|
|
99
117
|
const second = syncPresetTrees(f.source, f.target)
|
|
100
118
|
expect(second.synced).toEqual(['liangshen'])
|
|
101
119
|
expect(existsSync(join(f.target, 'liangshen', 'extra'))).toBe(false)
|
|
102
|
-
expect(readFileSync(join(f.target, 'liangshen', 'agent.cordis.yml'), 'utf8')).toBe(
|
|
120
|
+
expect(readFileSync(join(f.target, 'liangshen', 'agent.cordis.yml'), 'utf8')).toBe(VALID_AGENT_YAML)
|
|
103
121
|
} finally { f.dispose() }
|
|
104
122
|
})
|
|
105
123
|
|
|
@@ -119,7 +137,71 @@ describe('syncPresetTrees', () => {
|
|
|
119
137
|
const f = fixture()
|
|
120
138
|
try {
|
|
121
139
|
const result = syncPresetTrees(join(f.source, 'nope'), f.target)
|
|
122
|
-
expect(result).toEqual({ synced: [], current: [], failed: [] })
|
|
140
|
+
expect(result).toEqual({ synced: [], current: [], failed: [], retired: [] })
|
|
141
|
+
} finally { f.dispose() }
|
|
142
|
+
})
|
|
143
|
+
})
|
|
144
|
+
|
|
145
|
+
describe('mtime fast path', () => {
|
|
146
|
+
it('re-syncs a byte-identical file whose mtime drifted beyond tolerance', () => {
|
|
147
|
+
const f = fixture()
|
|
148
|
+
try {
|
|
149
|
+
syncPresetTrees(f.source, f.target)
|
|
150
|
+
const dest = join(f.target, 'liangshen', 'agent.cordis.yml')
|
|
151
|
+
const stat = statSync(dest)
|
|
152
|
+
// Bump mtime a day into the future, keep the bytes identical.
|
|
153
|
+
utimesSync(dest, stat.atime, new Date(stat.mtimeMs + 86400_000))
|
|
154
|
+
const second = syncPresetTrees(f.source, f.target)
|
|
155
|
+
expect(second.synced).toEqual(['liangshen'])
|
|
156
|
+
expect(second.current).toEqual([])
|
|
157
|
+
expect(readFileSync(dest, 'utf8')).toBe(VALID_AGENT_YAML)
|
|
158
|
+
} finally { f.dispose() }
|
|
159
|
+
})
|
|
160
|
+
|
|
161
|
+
it('re-syncs a target file with a different size without reading it twice', () => {
|
|
162
|
+
const f = fixture()
|
|
163
|
+
try {
|
|
164
|
+
syncPresetTrees(f.source, f.target)
|
|
165
|
+
writeFileSync(join(f.target, 'liangshen', 'preset.yml'), 'name: different\n')
|
|
166
|
+
const second = syncPresetTrees(f.source, f.target)
|
|
167
|
+
expect(second.synced).toEqual(['liangshen'])
|
|
168
|
+
} finally { f.dispose() }
|
|
169
|
+
})
|
|
170
|
+
})
|
|
171
|
+
|
|
172
|
+
describe('agent.cordis.yml validation after sync', () => {
|
|
173
|
+
it('reports an invalid bundled preset as failed instead of synced', () => {
|
|
174
|
+
const f = fixture()
|
|
175
|
+
try {
|
|
176
|
+
writeFileSync(join(f.source, 'liangshen', 'agent.cordis.yml'), 'rows: []\n')
|
|
177
|
+
const result = syncPresetTrees(f.source, f.target)
|
|
178
|
+
expect(result.synced).toEqual([])
|
|
179
|
+
expect(result.current).toEqual([])
|
|
180
|
+
expect(result.failed).toHaveLength(1)
|
|
181
|
+
expect(result.failed[0].id).toBe('liangshen')
|
|
182
|
+
expect(result.failed[0].error).toContain('failed validation')
|
|
183
|
+
} finally { f.dispose() }
|
|
184
|
+
})
|
|
185
|
+
|
|
186
|
+
it('validates a preset again on an idempotent run and still reports current', () => {
|
|
187
|
+
const f = fixture()
|
|
188
|
+
try {
|
|
189
|
+
syncPresetTrees(f.source, f.target)
|
|
190
|
+
const second = syncPresetTrees(f.source, f.target)
|
|
191
|
+
expect(second.current).toEqual(['liangshen'])
|
|
192
|
+
expect(second.failed).toEqual([])
|
|
193
|
+
} finally { f.dispose() }
|
|
194
|
+
})
|
|
195
|
+
})
|
|
196
|
+
|
|
197
|
+
describe('syncOnePreset', () => {
|
|
198
|
+
it('copies once and stays current on identical bytes', () => {
|
|
199
|
+
const f = fixture()
|
|
200
|
+
try {
|
|
201
|
+
const source = join(f.source, 'liangshen')
|
|
202
|
+
const target = join(f.target, 'liangshen')
|
|
203
|
+
expect(syncOnePreset(source, target)).toBe('synced')
|
|
204
|
+
expect(syncOnePreset(source, target)).toBe('current')
|
|
123
205
|
} finally { f.dispose() }
|
|
124
206
|
})
|
|
125
207
|
})
|
package/src/sync.ts
CHANGED
|
@@ -8,10 +8,24 @@
|
|
|
8
8
|
* tree is copied and any target files the source does not contain are removed.
|
|
9
9
|
* Directories the plugin does not own (other presets the user authored) are
|
|
10
10
|
* never touched.
|
|
11
|
+
*
|
|
12
|
+
* After a preset is synced its `agent.cordis.yml` is validated against the
|
|
13
|
+
* structural preset schema; a validation failure is reported through the
|
|
14
|
+
* run's `failed` entries instead of being a warn-only side effect, so callers
|
|
15
|
+
* can observe (and surface) a broken preset rather than silently shipping it.
|
|
11
16
|
*/
|
|
12
17
|
|
|
13
18
|
import { cpSync, existsSync, mkdirSync, readdirSync, readFileSync, rmSync, statSync } from 'node:fs'
|
|
14
19
|
import { basename, dirname, join, relative } from 'node:path'
|
|
20
|
+
import { validateAgentCordis } from './schema.ts'
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Clock/coarse-grain tolerance for the mtime fast path. When a source and a
|
|
24
|
+
* target file share a size and a near-identical mtime we still fall through to
|
|
25
|
+
* a byte comparison; a mtime gap beyond this simply proves the pair cannot be
|
|
26
|
+
* byte-identical, so we skip the read.
|
|
27
|
+
*/
|
|
28
|
+
const MTIME_TOLERANCE_MS = 1000
|
|
15
29
|
|
|
16
30
|
/** One sync run's outcome, grouped for diagnostics. */
|
|
17
31
|
export interface SyncResult {
|
|
@@ -21,6 +35,8 @@ export interface SyncResult {
|
|
|
21
35
|
current: string[]
|
|
22
36
|
/** Preset ids that failed, with the underlying error message. */
|
|
23
37
|
failed: { id: string; error: string }[]
|
|
38
|
+
/** Previously bundled preset ids removed from the target root this run. */
|
|
39
|
+
retired: string[]
|
|
24
40
|
}
|
|
25
41
|
|
|
26
42
|
function filesUnder(root: string): string[] {
|
|
@@ -36,8 +52,17 @@ function filesUnder(root: string): string[] {
|
|
|
36
52
|
return out
|
|
37
53
|
}
|
|
38
54
|
|
|
39
|
-
/**
|
|
55
|
+
/**
|
|
56
|
+
* File identity is bytes. Size and mtime are only a fast negative check: a
|
|
57
|
+
* size mismatch or a mtime gap beyond the tolerance proves the pair cannot be
|
|
58
|
+
* byte-identical without reading both, but an equal size and close mtime still
|
|
59
|
+
* fall through to a byte comparison so content differences are never missed.
|
|
60
|
+
*/
|
|
40
61
|
function sameFile(a: string, b: string): boolean {
|
|
62
|
+
const sourceStat = statSync(a)
|
|
63
|
+
const targetStat = statSync(b)
|
|
64
|
+
if (sourceStat.size !== targetStat.size) return false
|
|
65
|
+
if (Math.abs(sourceStat.mtimeMs - targetStat.mtimeMs) > MTIME_TOLERANCE_MS) return false
|
|
41
66
|
return readFileSync(a).equals(readFileSync(b))
|
|
42
67
|
}
|
|
43
68
|
|
|
@@ -67,6 +92,13 @@ function pruneExtras(root: string, keep: ReadonlySet<string>): void {
|
|
|
67
92
|
}
|
|
68
93
|
}
|
|
69
94
|
|
|
95
|
+
/** Validate the synced preset's `agent.cordis.yml` artifact on disk. */
|
|
96
|
+
function validatePresetAgentFile(presetDir: string): string[] {
|
|
97
|
+
const agent = join(presetDir, 'agent.cordis.yml')
|
|
98
|
+
if (!existsSync(agent)) return ['agent.cordis.yml is missing from the preset tree']
|
|
99
|
+
return validateAgentCordis(readFileSync(agent, 'utf8'))
|
|
100
|
+
}
|
|
101
|
+
|
|
70
102
|
/** Copy `sourceRoot/<id>` into `targetRoot/<id>`, idempotently. */
|
|
71
103
|
export function syncOnePreset(sourceDir: string, targetDir: string): 'synced' | 'current' {
|
|
72
104
|
const sourceFiles = filesUnder(sourceDir)
|
|
@@ -108,23 +140,55 @@ export function syncOnePreset(sourceDir: string, targetDir: string): 'synced' |
|
|
|
108
140
|
}
|
|
109
141
|
|
|
110
142
|
/**
|
|
111
|
-
* Sync every preset under `sourceRoot` into `targetRoot
|
|
143
|
+
* Sync every preset under `sourceRoot` into `targetRoot`, then remove
|
|
144
|
+
* target directories named in `retire` that the bundle no longer ships —
|
|
145
|
+
* preset ids the plugin once owned and later dropped. Only those exact ids
|
|
146
|
+
* are removed; every other target directory is left untouched.
|
|
147
|
+
*
|
|
148
|
+
* Each synced (or already-current) preset is validated against the structural
|
|
149
|
+
* `agent.cordis.yml` schema; a validation failure lands in `failed` so the
|
|
150
|
+
* caller can surface a broken preset as a first-class result instead of a
|
|
151
|
+
* warn-only log line.
|
|
112
152
|
* @param sourceRoot - plugin-owned preset tree (bundled in the package).
|
|
113
153
|
* @param targetRoot - dsh agent-presets discovery root (e.g. <home>/.dsh/.agent-presets).
|
|
154
|
+
* @param retire - previously bundled preset ids to remove when absent from the source.
|
|
114
155
|
*/
|
|
115
|
-
export function syncPresetTrees(sourceRoot: string, targetRoot: string): SyncResult {
|
|
116
|
-
const result: SyncResult = { synced: [], current: [], failed: [] }
|
|
117
|
-
if (!existsSync(sourceRoot)) return result
|
|
156
|
+
export function syncPresetTrees(sourceRoot: string, targetRoot: string, retire: string[] = []): SyncResult {
|
|
157
|
+
const result: SyncResult = { synced: [], current: [], failed: [], retired: [] }
|
|
118
158
|
mkdirSync(targetRoot, { recursive: true })
|
|
119
|
-
|
|
120
|
-
const
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
const
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
159
|
+
if (existsSync(sourceRoot)) {
|
|
160
|
+
for (const entry of readdirSync(sourceRoot)) {
|
|
161
|
+
const source = join(sourceRoot, entry)
|
|
162
|
+
if (!statSync(source).isDirectory()) continue
|
|
163
|
+
const id = basename(source)
|
|
164
|
+
const targetDir = join(targetRoot, id)
|
|
165
|
+
let outcome: 'synced' | 'current'
|
|
166
|
+
try {
|
|
167
|
+
outcome = syncOnePreset(source, targetDir)
|
|
168
|
+
} catch (error) {
|
|
169
|
+
result.failed.push({ id, error: error instanceof Error ? error.message : String(error) })
|
|
170
|
+
continue
|
|
171
|
+
}
|
|
172
|
+
try {
|
|
173
|
+
const problems = validatePresetAgentFile(targetDir)
|
|
174
|
+
if (problems.length > 0) {
|
|
175
|
+
result.failed.push({ id, error: `agent.cordis.yml failed validation: ${problems.join('; ')}` })
|
|
176
|
+
} else if (outcome === 'synced') {
|
|
177
|
+
result.synced.push(id)
|
|
178
|
+
} else {
|
|
179
|
+
result.current.push(id)
|
|
180
|
+
}
|
|
181
|
+
} catch (error) {
|
|
182
|
+
result.failed.push({ id, error: error instanceof Error ? error.message : String(error) })
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
for (const id of retire) {
|
|
187
|
+
if (existsSync(join(sourceRoot, id))) continue
|
|
188
|
+
const stale = join(targetRoot, id)
|
|
189
|
+
if (existsSync(stale) && statSync(stale).isDirectory()) {
|
|
190
|
+
rmSync(stale, { recursive: true, force: true })
|
|
191
|
+
result.retired.push(id)
|
|
128
192
|
}
|
|
129
193
|
}
|
|
130
194
|
return result
|
|
@@ -1,321 +0,0 @@
|
|
|
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
|
|
@@ -1,10 +0,0 @@
|
|
|
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'
|