dsh-code 1.0.4 → 1.0.5

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.md CHANGED
@@ -25,21 +25,23 @@ DeepSeek Harness 将模型、工具、存储、策略和界面作为插件,通
25
25
 
26
26
  ## 二、快速开始
27
27
 
28
- 需要 Node `^22.19 || >=24` 和预览版 `dsh` CLI(当前版本线:`@deepseek-ai/dsh@0.1.1-rc.2`)。未配置模型时仍可进入 TUI、查看会话和使用非模型功能;在 `/model` 中按 `a` 可管理 API key、OAuth 与设备码登录。
28
+ 需要 Node `^22.19 || >=24` 和预览版 `dsh` CLI(当前版本线:`@deepseek-ai/dsh@0.1.2-rc.1`)。未配置模型时仍可进入 TUI、查看会话和使用非模型功能;在 `/model` 中按 Tab 进入供应商管理,配置 API key、OAuth 与设备码登录。
29
29
 
30
30
  ### 1. 安装与更新
31
31
 
32
32
  初次安装和更新使用同一组指令:
33
33
 
34
34
  ```sh
35
- npm install -g @deepseek-ai/dsh@0.1.1-rc.2 dsh-code@1.0.3
35
+ npm install -g @deepseek-ai/dsh@0.1.2-rc.1 dsh-code@1.0.5
36
36
  npm install -g pnpm
37
- dsh plugin --profile cli add dsh-code@1.0.3
37
+ dsh plugin --profile cli add dsh-code@1.0.5
38
38
  ```
39
39
 
40
- > 提示:pnpm 会忽略发布不足 24 小时的包,因此发布首日请使用精确版本 `dsh-code@1.0.3`;24 小时后可省略版本号。npm 安装不受此限制。
40
+ > 提示:pnpm 会忽略发布不足 24 小时的包,因此发布首日请使用精确版本 `dsh-code@1.0.5`;24 小时后可省略版本号。npm 安装不受此限制。
41
41
  >
42
- > 版本对齐:dsh-code 1.0.3 面向 dsh `0.1.1-rc.2` 构建,全部 Harness 依赖均精确锁定为 `0.1.1-rc.2`。请保持全局 dsh dsh-code 同步,避免宿主与插件混用候选版本。rc.2 已删除旧的 DeepSeek 配置项 `maxRequestImageBytes`。
42
+ > 版本对齐:dsh-code 1.0.5 面向 dsh `0.1.2-rc.1` 构建,全部 Harness 依赖均精确锁定为 `0.1.2-rc.1`。已安装的用户运行 `deepseek update --apply` 即可按同一条版本线一起升级全局宿主与 cli profile 中的插件,本地开发挂载(`link:`)不受影响。
43
+ >
44
+ > 升级说明:上游从本版本起将内置 `code` 预设更名为 `ptc`;旧会话与旧参数中记录的 `code` 会自动映射到 `ptc`,无需手动迁移。
43
45
 
44
46
  ### 2. 启动指令
45
47
 
@@ -121,7 +123,7 @@ DSH-Code 的重点是让 DSH 的 Agent、模型、工具和持久会话可以直
121
123
 
122
124
  ```sh
123
125
  dsh --profile cli # 新建 standard 会话
124
- dsh --profile cli --mode code # 使用指定 Agent Preset 启动
126
+ dsh --profile cli --mode ptc # 使用指定 Agent Preset 启动(standard/minimal/cordis/ptc)
125
127
  dsh --profile cli --continue # 恢复当前目录最新会话
126
128
  dsh --profile cli --resume abc123 # 按 id 或唯一前缀恢复会话
127
129
  dsh --profile cli --session my-id # 使用指定 id 新建会话
@@ -158,7 +160,7 @@ dsh --profile cli --session my-id # 使用指定 id 新建会话
158
160
  | 命令 | 用途 |
159
161
  | --- | --- |
160
162
  | `/diff [--staged\|ref]` | 按文件查看工作区、暂存区或指定 ref 的 Git diff |
161
- | `/review [--staged\|ref]` | 使用只读权限审查 Git 改动 |
163
+ | `/review [--staged\|ref]` | 使用只读权限审查 Git 改动;新会话中可直接使用,审查提示词作为首条消息建立会话 |
162
164
  | `/todos` | 查看当前会话的完整 todo 列表 |
163
165
  | `/agents` | 查看当前会话创建的 subagent 会话 |
164
166
  | `/jobs` | 查看后台任务及其运行状态 |
package/bin/deepseek.mjs CHANGED
@@ -4,7 +4,7 @@ import { spawn, spawnSync } from 'node:child_process'
4
4
  import { existsSync, readFileSync, realpathSync } from 'node:fs'
5
5
  import { createRequire } from 'node:module'
6
6
  import { homedir } from 'node:os'
7
- import { join, resolve } from 'node:path'
7
+ import { dirname, join, resolve } from 'node:path'
8
8
  import { fileURLToPath, pathToFileURL } from 'node:url'
9
9
 
10
10
  const packageRequire = createRequire(import.meta.url)
@@ -49,6 +49,81 @@ export function profileHasDshCode(profileDir = cliProfileDir(), fileExists = exi
49
49
  }
50
50
  }
51
51
 
52
+ /** The dsh-code dependency the cli profile declares (e.g. '1.0.5' or 'link:C:/repo'). */
53
+ export function profileDependencySpec(profileDir = cliProfileDir(), fileExists = existsSync, readFile = readFileSync) {
54
+ const manifest = join(profileDir, 'package.json')
55
+ if (!fileExists(manifest)) return undefined
56
+ try {
57
+ const raw = JSON.parse(readFile(manifest, 'utf8'))
58
+ const spec = raw?.dependencies?.['dsh-code']
59
+ return typeof spec === 'string' ? spec : undefined
60
+ } catch {
61
+ return undefined
62
+ }
63
+ }
64
+
65
+ /** The dsh-code version the cli profile actually resolves and boots. */
66
+ export function profileMountedVersion(profileDir = cliProfileDir(), fileExists = existsSync, readFile = readFileSync) {
67
+ const manifest = join(profileDir, 'node_modules', 'dsh-code', 'package.json')
68
+ if (!fileExists(manifest)) return undefined
69
+ try {
70
+ return JSON.parse(readFile(manifest, 'utf8'))?.version ?? undefined
71
+ } catch {
72
+ return undefined
73
+ }
74
+ }
75
+
76
+ /** The harness release line a dsh-code release expects, read from its peers. */
77
+ export function harnessLineFromPeers(peers) {
78
+ if (typeof peers !== 'object' || peers === null) return undefined
79
+ const anchor = peers['@deepseek-ai/dsh-session']
80
+ if (typeof anchor === 'string' && anchor !== '') return anchor
81
+ for (const [name, spec] of Object.entries(peers)) {
82
+ if (name.startsWith('@deepseek-ai/dsh-') && typeof spec === 'string' && spec !== '') return spec
83
+ }
84
+ return undefined
85
+ }
86
+
87
+ /**
88
+ * Decide what `update --apply` installs. The global DSH launcher is pinned
89
+ * to the harness line the target dsh-code release declares in its peers,
90
+ * so the launcher can never move ahead of the plugin it must boot. A
91
+ * profile that mounts a local checkout (link:/file:) keeps its mount.
92
+ */
93
+ export function updatePlan({ latestCode, peers, profileSpec }) {
94
+ const line = harnessLineFromPeers(peers)
95
+ return {
96
+ dshSpec: line === undefined ? '@deepseek-ai/dsh@latest' : `@deepseek-ai/dsh@${line}`,
97
+ lineLocked: line !== undefined,
98
+ codeSpec: `dsh-code@${latestCode}`,
99
+ profileStep: !(typeof profileSpec === 'string' && /^(link|file):/iu.test(profileSpec)),
100
+ }
101
+ }
102
+
103
+ /** Run wrapper-owned child steps in order, stopping at the first failure. */
104
+ export function runSequence(steps, spawnProcess = spawn) {
105
+ return new Promise(resolve => {
106
+ const run = index => {
107
+ const step = steps[index]
108
+ if (step === undefined) {
109
+ resolve(0)
110
+ return
111
+ }
112
+ const needsShell = process.platform === 'win32' && /\.(cmd|bat)$/iu.test(step.command)
113
+ const child = spawnProcess(step.command, step.args, { stdio: 'inherit', ...(needsShell ? { shell: true } : {}) })
114
+ child.once('error', error => {
115
+ console.error(`dsh-code: ${step.label} failed: ${error.message}`)
116
+ resolve(1)
117
+ })
118
+ child.once('exit', (code, signal) => {
119
+ if (code === 0) run(index + 1)
120
+ else resolve(code ?? 1)
121
+ })
122
+ }
123
+ run(0)
124
+ })
125
+ }
126
+
52
127
  /** Npm global-prefix roots that may contain DSH when this launcher is globally linked to a checkout. */
53
128
  export function globalDshRoots() {
54
129
  return [...new Set([
@@ -133,6 +208,144 @@ function launchChild(command, args) {
133
208
  return child
134
209
  }
135
210
 
211
+ /**
212
+ * How to invoke npm. The JavaScript entrypoint is preferred: running it
213
+ * with this process's node avoids the Windows .cmd shim, whose shell
214
+ * workaround draws a Node deprecation warning on every call.
215
+ */
216
+ export function npmInvocation({
217
+ fileExists = existsSync,
218
+ roots = globalDshRoots(),
219
+ resolvePackage = packageRequire.resolve,
220
+ } = {}) {
221
+ const besideNode = join(dirname(process.execPath), 'node_modules', 'npm', 'bin', 'npm-cli.js')
222
+ if (fileExists(besideNode)) return { command: process.execPath, args: [besideNode] }
223
+ for (const root of roots) {
224
+ try {
225
+ const cli = resolvePackage('npm/bin/npm-cli.js', { paths: [root] })
226
+ return { command: process.execPath, args: [cli] }
227
+ } catch {
228
+ // The next configured global prefix may own npm instead.
229
+ }
230
+ }
231
+ return { command: process.platform === 'win32' ? 'npm.cmd' : 'npm', args: [] }
232
+ }
233
+
234
+ /**
235
+ * Read one `npm view` field as JSON, or undefined when the query fails.
236
+ * The subject arrives as argument parts: without a shell, a space inside
237
+ * one argument would reach npm as a single selector and fail.
238
+ */
239
+ function viewJson(subjectParts, spawnCommand = spawnSync, invocation = npmInvocation()) {
240
+ const needsShell = process.platform === 'win32' && /\.(cmd|bat)$/iu.test(invocation.command)
241
+ const result = spawnCommand(invocation.command, [...invocation.args, 'view', ...subjectParts, '--json'], { encoding: 'utf8', windowsHide: true, ...(needsShell ? { shell: true } : {}) })
242
+ if (result.status !== 0) return undefined
243
+ try {
244
+ return JSON.parse(result.stdout)
245
+ } catch {
246
+ return undefined
247
+ }
248
+ }
249
+
250
+ /**
251
+ * The version of @deepseek-ai/dsh this launcher would boot, when present.
252
+ * Probes the same surfaces rawDshCommand resolves: the adjacent global
253
+ * install first, then every configured npm global prefix.
254
+ */
255
+ function installedDshVersion({
256
+ platform = process.platform,
257
+ moduleUrl = import.meta.url,
258
+ fileExists = existsSync,
259
+ roots = globalDshRoots(),
260
+ resolvePackage = packageRequire.resolve,
261
+ } = {}) {
262
+ const readVersion = path => {
263
+ try {
264
+ return JSON.parse(readFileSync(path, 'utf8')).version
265
+ } catch {
266
+ return undefined
267
+ }
268
+ }
269
+ if (platform === 'win32') {
270
+ const adjacent = fileUrlToWindowsPath(new URL('../../@deepseek-ai/dsh/package.json', moduleUrl))
271
+ if (fileExists(adjacent)) return readVersion(adjacent)
272
+ } else {
273
+ try {
274
+ const adjacent = fileURLToPath(new URL('../../@deepseek-ai/dsh/package.json', moduleUrl))
275
+ if (fileExists(adjacent)) return readVersion(adjacent)
276
+ } catch {
277
+ // A non-file URL or an unreadable sibling falls through to the roots.
278
+ }
279
+ }
280
+ for (const root of roots) {
281
+ try {
282
+ return readVersion(resolvePackage('@deepseek-ai/dsh/package.json', { paths: [root] }))
283
+ } catch {
284
+ // The next configured global prefix may own DSH instead.
285
+ }
286
+ }
287
+ return undefined
288
+ }
289
+
290
+ /** Show what is installed, what is latest, and what the cli profile boots. */
291
+ function printUpdateStatus() {
292
+ const codeLatest = viewJson(['dsh-code', 'version'])
293
+ const dshLatest = viewJson(['@deepseek-ai/dsh', 'version'])
294
+ const dshInstalled = installedDshVersion()
295
+ const spec = profileDependencySpec()
296
+ const mounted = profileMountedVersion()
297
+ console.log(`dsh-code: ${packageVersion} (this launcher), latest ${codeLatest ?? 'unknown'}`)
298
+ console.log(`@deepseek-ai/dsh: ${dshInstalled ?? 'not found'} (global), latest ${dshLatest ?? 'unknown'}`)
299
+ console.log(`cli profile: ${mounted !== undefined ? `dsh-code ${mounted}` : spec ?? 'not mounted'}`)
300
+ console.log('Run `deepseek update --apply` to upgrade the global packages and the cli profile together.')
301
+ }
302
+
303
+ /**
304
+ * Upgrade the global launcher and the cli profile plugin together. The
305
+ * global install is pinned to the harness line the new dsh-code release
306
+ * declares, the profile follows through `dsh plugin add` with the same
307
+ * pinned spec, and the mounted version is verified at the end.
308
+ */
309
+ async function applyUpdate({
310
+ view = viewJson,
311
+ resolveCommand = rawDshCommand,
312
+ spawnProcess = spawn,
313
+ } = {}) {
314
+ const npm = npmInvocation()
315
+ const latestCode = view(['dsh-code', 'version'], undefined, npm)
316
+ if (latestCode === undefined) {
317
+ console.error('dsh-code: could not read the latest dsh-code version from npm')
318
+ process.exitCode = 1
319
+ return
320
+ }
321
+ const peers = view([`dsh-code@${latestCode}`, 'peerDependencies'], undefined, npm)
322
+ const plan = updatePlan({ latestCode, peers, profileSpec: profileDependencySpec() })
323
+ if (!plan.lineLocked) {
324
+ console.log('dsh-code: could not read the compatible harness line; installing @deepseek-ai/dsh@latest')
325
+ }
326
+ const steps = [{ command: npm.command, args: [...npm.args, 'install', '-g', plan.dshSpec, plan.codeSpec], label: 'npm install' }]
327
+ if (plan.profileStep) {
328
+ const command = resolveCommand(['plugin', '--profile', 'cli', 'add', plan.codeSpec])
329
+ if (command === undefined) {
330
+ console.error('dsh-code: could not resolve the dsh command for the profile update')
331
+ process.exitCode = 1
332
+ return
333
+ }
334
+ steps.push({ command: command.command, args: command.args, label: 'dsh plugin add' })
335
+ } else {
336
+ console.log('cli profile mounts a local checkout; leaving the profile untouched')
337
+ }
338
+ const code = await runSequence(steps, spawnProcess)
339
+ const mounted = profileMountedVersion()
340
+ if (mounted !== undefined) console.log(`cli profile now mounts dsh-code ${mounted}`)
341
+ if (code === 0 && plan.profileStep && mounted !== latestCode) {
342
+ console.error(`dsh-code: the cli profile still mounts ${mounted ?? 'nothing'}; run: dsh plugin --profile cli add ${plan.codeSpec}`)
343
+ process.exitCode = 1
344
+ return
345
+ }
346
+ process.exitCode = code
347
+ }
348
+
136
349
  /** Run one wrapper-owned operational command. */
137
350
  export function launchOperation(args = process.argv.slice(2)) {
138
351
  const operation = operationName(args)
@@ -161,17 +374,14 @@ export function launchOperation(args = process.argv.slice(2)) {
161
374
  }
162
375
  return launchChild(command.command, command.args)
163
376
  }
164
- if (args.includes('--apply')) {
165
- return launchChild(process.platform === 'win32' ? 'npm.cmd' : 'npm', ['install', '-g', '@deepseek-ai/dsh', 'dsh-code'])
166
- }
167
- const npm = process.platform === 'win32' ? 'npm.cmd' : 'npm'
168
- const needsShell = process.platform === 'win32' && /\.(cmd|bat)$/iu.test(npm)
169
- for (const name of ['@deepseek-ai/dsh', 'dsh-code']) {
170
- const result = spawnSync(npm, ['view', name, 'version'], { encoding: 'utf8', windowsHide: true, ...(needsShell ? { shell: true } : {}) })
171
- console.log(`${name}: ${result.status === 0 ? String(result.stdout).trim() : 'version check failed'}`)
377
+ if (operation === 'update') {
378
+ if (args.includes('--apply')) {
379
+ void applyUpdate()
380
+ return true
381
+ }
382
+ printUpdateStatus()
383
+ return true
172
384
  }
173
- console.log('Run `deepseek update --apply` to install the latest versions.')
174
- return true
175
385
  }
176
386
 
177
387
  /** Launch the installed DSH CLI while preserving its exit status and stdio. */
package/cordis.patch.yml CHANGED
@@ -40,6 +40,8 @@
40
40
  disabled: true
41
41
  - id: tool-skill
42
42
  disabled: true
43
+ - id: command-goal
44
+ disabled: true
43
45
  - id: tool-goal
44
46
  disabled: true
45
47
  - id: plan-mode
@@ -68,15 +70,9 @@
68
70
  disabled: true
69
71
  - id: tool-todo
70
72
  disabled: true
71
- - id: tool-web
72
- config:
73
- # web_fetch is a core TUI capability, not an opt-in: the fetch provider
74
- # (web-fetch-http below) needs no API key. The per-preset tool-web rows
75
- # keep `fetch: false` on the agent plane; through the scope-layered tool
76
- # registry the preset's web_search shadows the host's same-name tool while
77
- # the host's web_fetch stays visible, so every model still sees both.
78
- fetch: true
79
- searchTimeoutMs: 60000
73
+ # tool-web keeps the 0.1.2-rc.1 base default (web_fetch enabled over the
74
+ # bundled web-fetch-http provider): the host row exposes web_fetch while the
75
+ # per-preset agent-plane rows keep their own fetch stance.
80
76
 
81
77
  - insert:
82
78
  # Code Mode is a core execution capability, not a Web component.
@@ -111,11 +107,13 @@
111
107
  - id: cordis-host-runner
112
108
  name: '@deepseek-ai/dsh-cordis-host-runner'
113
109
 
114
- # Anonymous public HTTP(S) fetch provider for web_fetch (no key): the web
115
- # service and its search provider stay on the host plane (dsh-base), and
116
- # this row is what makes fetching real URLs work out of the box.
117
- - id: web-fetch-http
118
- name: '@deepseek-ai/dsh-web-fetch-http'
110
+ # Host-owned opt-in the preset delegation tools sample: standard/ptc's
111
+ # tool-subagent rows set `modelSelectionSettings: true`, whose start
112
+ # resolves this service and fails the whole preset mount when absent
113
+ # ("failed to apply loader entry delegation (cordis:group)"). The upstream
114
+ # web-app bundle adds this host row in 0.1.2-rc.1; dsh-base does not ship it.
115
+ - id: subagent-model-selection-settings
116
+ name: '@deepseek-ai/dsh-tool-subagent/model-selection-settings'
119
117
 
120
118
  # Interactive provider authorization. The base bundle supplies the
121
119
  # credential store; mounting the neutral authorization seam wakes the