dsh-deep-ptc-mode 1.4.0 → 1.6.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/CHANGELOG.md +19 -0
- package/README.md +32 -8
- package/README.zh.md +38 -11
- package/compatibility.json +3 -2
- package/lib/adapt.mjs +27 -0
- package/lib/ask-user.mjs +13 -0
- package/lib/guard.mjs +15 -0
- package/lib/index.mjs +46 -7
- package/lib/jobs-tool.mjs +15 -0
- package/lib/model.mjs +232 -15
- package/lib/preset.json +9 -12
- package/lib/reachable.mjs +113 -0
- package/lib/rules.mjs +52 -0
- package/lib/sleep-lint.mjs +73 -0
- package/lib/terminal.mjs +30 -35
- package/lib/upstream.mjs +169 -0
- package/package.json +33 -10
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,24 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 1.6.0 — 2026-11-04
|
|
4
|
+
|
|
5
|
+
- Derive the preset from the PTC preset the installed Harness declares (`@deepseek-ai/dsh-web-app/presets/ptc.patch.yml`) instead of freezing a copy. Official rows, settings and additions are inherited; Deep PTC still replaces only its persona, execution environment, reachability guard, and the official job/question wrappers.
|
|
6
|
+
- Fix the failure after the DSH `0.2.2-rc.1` update: the frozen 1.5.0 snapshot still named the `@deepseek-ai/dsh-tool-subagent-control/list-agents` subpath, which `0.2.2-rc.1` removed, so the preset could not mount and existing Deep PTC sessions were reported as unusable. Sessions were never migrated or rewritten; they open again once the preset mounts.
|
|
7
|
+
- Keep `lib/preset.json` only as a fallback snapshot and refresh it to `0.2.2-rc.1`; `npm run sync:snapshot` regenerates it from the installed declaration.
|
|
8
|
+
- Declare every imported host package in `peerDependencies`, including `@deepseek-ai/dsh-web-app`: the host only routes a linked plugin's bare specifier to the installation when the name is peer-declared, so without it a `link:` install silently fell back to the snapshot. `npm run check` now fails if a peer is missing.
|
|
9
|
+
- Match official rows recursively (persona, shell/executor rows, job and question rows may move into a group) and accept only a declaration whose id is `ptc`. Tests cover nested groups, a non-PTC declaration, and the peer-declaration guard.
|
|
10
|
+
- `compatibility.json` now records the checked upstream release plus fixture hash; `scripts/check.mjs` verifies inheritance invariants and fallback/dedaration parity instead of exact-snapshot equality.
|
|
11
|
+
- Add derivation tests for future compositions (unknown rows, reordering, missing shell or wrapped rows) and `scripts/check-preset.cjs`, a live-runtime check that every derived row resolves through the installed module graph.
|
|
12
|
+
|
|
13
|
+
## 1.5.0 — 2026-10-31
|
|
14
|
+
|
|
15
|
+
- Enforce reachability in code. Foreground shell commands move to background jobs after `foregroundSeconds` (default 30, configurable 5–600); a larger requested timeout is capped. Commands still run; only the wait ends.
|
|
16
|
+
- A user message steered into the turn ends the current foreground wait within about 2 s: shell commands move to the background, `job_output` returns, and a timed question becomes pending. Waiting again with job_output while the message is unread is refused.
|
|
17
|
+
- Refuse foreground pauses over 5 s (`sleep`, `Start-Sleep`, `timeout /t`), `run_code` programs that wait on long or non-literal timers, `setInterval` and `Atomics.wait`, and more than 3 polls of one running job inside a program.
|
|
18
|
+
- Run `ask_user_question` in timed mode (120 s default, 300 s cap, `-1` refused) and fix the persona, which named a non-existent `timeoutMs` parameter.
|
|
19
|
+
- Wrap the official bash, pwsh, job and question tools instead of replacing them; the upstream check verifies exactly which rows are wrapped.
|
|
20
|
+
- Add `scripts/check-reachability.mjs`, an integration check on a real DSH runtime, and extend the Windows host check to activate the guard.
|
|
21
|
+
|
|
3
22
|
## 1.4.0 — 2026-10-31
|
|
4
23
|
|
|
5
24
|
- Restore the 1.2.0 intent in the persona while keeping 1.3.0's execution environments: the DeepSeek identity and unlimited-budget contract with anti-padding guardrails; size-based planning (internal up to five minutes, shown without approval up to twenty, approved beyond); asking about meaning instead of searching for it.
|
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Deep PTC mode
|
|
2
2
|
|
|
3
|
-
[中文](README.zh.md) · MIT · **1.
|
|
3
|
+
[中文](README.zh.md) · MIT · **1.5.0**
|
|
4
4
|
|
|
5
5
|
A DeepSeek Harness agent preset with exactly the built-in PTC tool surface and a different way of working: the model uses its full capability, stays interruptible while work runs, asks for approval only when a task is long, asks you instead of guessing, and runs commands in the environment you choose.
|
|
6
6
|
|
|
@@ -11,13 +11,34 @@ Deep PTC targets five common problems with the built-in PTC mode:
|
|
|
11
11
|
| Problem | What Deep PTC does |
|
|
12
12
|
| --- | --- |
|
|
13
13
|
| The model rations tokens, skipping reads and tests, and quality suffers | The persona states that it works at DeepSeek with an unlimited token budget in this mode: never skip a read, search, command or check to save tokens. Guardrails forbid padding, verbosity and context blow-ups |
|
|
14
|
-
| Once work starts, the model sleeps or waits and ignores your messages |
|
|
14
|
+
| Once work starts, the model sleeps or waits and ignores your messages | Enforced in code: foreground commands move to the background after 30 s, a message from you moves the waiting command to the background at once so the model reads it, and long sleeps are refused; job completion wakes the model (see "Enforced reachability" below) |
|
|
15
15
|
| Every task starts the same way regardless of size | Three bands by estimated time: up to 5 minutes, plan internally and act; 5–20 minutes, show the plan and start without approval; over 20 minutes, show the plan and wait for approval |
|
|
16
16
|
| It starts before understanding what you meant, then redoes the work | Meaning belongs to you, facts to the tools: unfamiliar names, competing targets or routes, scope and acceptance criteria are asked about (one to three questions with options), never guessed by searching; file locations and current behavior are looked up |
|
|
17
17
|
| The command environment is fixed | Choose WSL Bash, PowerShell, Zsh (macOS/Linux) or native Bash in settings; the choice applies to this preset only and leaves the global shell alone |
|
|
18
18
|
|
|
19
19
|
Three steps: install the plugin → pick an environment under **Settings → Plugins → Deep PTC** → choose **深度PTC模式** in the mode picker for a new task.
|
|
20
20
|
|
|
21
|
+
## Enforced reachability: no sleeping, always interruptible
|
|
22
|
+
|
|
23
|
+
From 1.5.0, "don't sleep or wait" is enforced by plugin code, not just requested in the prompt:
|
|
24
|
+
|
|
25
|
+
| Situation | What the code does |
|
|
26
|
+
| --- | --- |
|
|
27
|
+
| A foreground command runs long | After **30 s** (configurable, 5–600) it moves to a background job and keeps running; a larger requested `timeoutMs` is capped |
|
|
28
|
+
| You send a message while a command runs | The foreground wait ends within about 2 s, the command continues in the background, and the model reads your message; job completion still wakes it |
|
|
29
|
+
| `job_output` waits on a job | Capped at 30 s, ends early when you send a message, and waiting again while your message is unread is refused |
|
|
30
|
+
| The model writes `sleep 60`, `Start-Sleep 30` or `timeout /t 20` | Foreground pauses over 5 s are refused (`run_in_background` commands are exempt); short readiness loops such as `sleep 1` still work |
|
|
31
|
+
| `setTimeout`, `setInterval` or `time.sleep` in a `run_code` program | Waits over 5 s, or with a non-literal duration, are refused; polling one running job more than 3 times in one program is refused |
|
|
32
|
+
| `ask_user_question` | Runs in timed mode: 120 s by default, at most 300 s, `-1` refused. An unanswered question becomes pending and your later answer arrives as a message; typing a reply instead of using the card ends the wait at once |
|
|
33
|
+
|
|
34
|
+
These rules apply only to Deep PTC sessions. They rely on the desktop "busy Enter" setting being **steer**; with **queue**, messages wait for the whole turn to end.
|
|
35
|
+
|
|
36
|
+
```yaml
|
|
37
|
+
- id: deep-ptc-settings
|
|
38
|
+
config:
|
|
39
|
+
foregroundSeconds: 30 # foreground wait cap in seconds, 5-600
|
|
40
|
+
```
|
|
41
|
+
|
|
21
42
|
## Choose an execution environment
|
|
22
43
|
|
|
23
44
|
Open **Settings → Plugins → Deep PTC**, choose an environment, save, and create a new **深度PTC模式** session.
|
|
@@ -56,10 +77,10 @@ A prompt changes the model's working tendency, not the real token limit or billi
|
|
|
56
77
|
Requires Node `>=24` and DSH `>=0.2.1-rc.5`. Windows desktop rc.5 was used for real WSL/PowerShell command checks. macOS/Zsh configuration, argv and tool mounting were checked; native macOS execution has not been verified on this Windows host.
|
|
57
78
|
|
|
58
79
|
```js
|
|
59
|
-
plugin_manager({ action: "install_bundle", target: "dsh-deep-ptc-mode@1.
|
|
80
|
+
plugin_manager({ action: "install_bundle", target: "dsh-deep-ptc-mode@1.5.0" })
|
|
60
81
|
// Or from a local checkout or archive:
|
|
61
82
|
plugin_manager({ action: "install_bundle", target: "C:\\path\\to\\dsh-deep-ptc-mode" })
|
|
62
|
-
// Or target: "C:\\path\\to\\dsh-deep-ptc-mode-1.
|
|
83
|
+
// Or target: "C:\\path\\to\\dsh-deep-ptc-mode-1.5.0.tgz"
|
|
63
84
|
```
|
|
64
85
|
|
|
65
86
|
Repository locator: `github:lishize20040802-rgb/dsh-deep-ptc-mode`. It installs content actually published there; a local upgrade does not publish to GitHub or npm.
|
|
@@ -79,21 +100,24 @@ Prefer the UI, which uses revisioned, atomic Host form writes.
|
|
|
79
100
|
|
|
80
101
|
## Compatibility and development
|
|
81
102
|
|
|
82
|
-
|
|
103
|
+
Deep PTC is composed at load time from the PTC preset the installed Harness declares (`@deepseek-ai/dsh-web-app/presets/ptc.patch.yml`). Every official row is inherited as-is; Deep PTC replaces only its persona text, swaps the two platform-switched shell tools for one isolated execution group, adds the reachability guard, and wraps the official job and question tools. An official PTC change therefore reaches this mode without a plugin release, and a removed or renamed upstream module cannot leave a stale row behind. If the declaration cannot be resolved, read or parsed, the bundled `lib/preset.json` snapshot is used as a fallback and the fallback is logged.
|
|
83
104
|
|
|
84
|
-
|
|
105
|
+
Because the declaration is resolved through the host runtime, every host package the plugin imports is declared in `peerDependencies` — including `@deepseek-ai/dsh-web-app`. The host routes those names to the installation for a linked plugin; `npm run check` fails if one is missing, which is what keeps a `link:` installation on the live declaration instead of silently using the fallback snapshot. `compatibility.json` records the upstream release the checked fixture was taken from and its hash; `npm run check` verifies that the bundled fallback still derives the same preset as that fixture and that the inheritance invariants hold. The engines range is an installation floor, not proof that every future release was tested, so run `npm run check:upstream -- <path>` against a new release before trusting it.
|
|
85
106
|
|
|
86
107
|
```sh
|
|
87
108
|
npm ci
|
|
88
109
|
npm run check
|
|
89
110
|
npm test
|
|
90
111
|
npm run check:upstream -- /path/to/the/new/upstream/ptc.patch.yml
|
|
112
|
+
npm run sync:snapshot # refresh lib/preset.json from the installed declaration
|
|
113
|
+
PTC_RUNTIME_MODULES=/path/to/dsh/node_modules node scripts/check-preset.cjs # loader-level row resolution on a real runtime
|
|
114
|
+
PTC_RUNTIME_MODULES=/path/to/dsh/node_modules node scripts/check-reachability.mjs # interruptible waits on a real runtime
|
|
91
115
|
npm pack
|
|
92
116
|
```
|
|
93
117
|
|
|
94
|
-
The checker parses `!!js` as data,
|
|
118
|
+
The checker parses `!!js` as data and asserts the derivation invariants: every official row survives unchanged except the persona, the shell rows and the two wrapped tools (including when the official preset nests them in a group); row ids stay unique; derivation is deterministic across nine platform/environment pairs. Tests cover future compositions as well (unknown rows, reordered rows, removed shell or wrapped rows), plus platforms, argv boundaries, confined WSL refusal, atomic settings writes and stale revisions. Real-task evaluations should measure successful completion, unnecessary questions, scope expansion, background-work collection and latency.
|
|
95
119
|
|
|
96
|
-
Main files: `cordis.patch.yml` is the settings entry; `lib/index.mjs` manages revisions; `lib/model.mjs` builds isolated execution configurations; `lib/executor.mjs` adapts WSL/Zsh; `lib/terminal.mjs` provides the Zsh tool; `lib/client.js` owns the bilingual settings card; `lib/preset.json`
|
|
120
|
+
Main files: `cordis.patch.yml` is the settings entry; `lib/index.mjs` manages revisions; `lib/model.mjs` builds isolated execution configurations; `lib/executor.mjs` adapts WSL/Zsh; `lib/terminal.mjs` wraps the official Bash/PowerShell tools with interruptible waits and provides the Zsh tool; `lib/jobs-tool.mjs` and `lib/ask-user.mjs` wrap the official job and question tools; `lib/guard.mjs`, `lib/rules.mjs`, `lib/sleep-lint.mjs` and `lib/reachable.mjs` implement the pause/polling guard and interruptible waits; `lib/client.js` owns the bilingual settings card; `lib/upstream.mjs` locates and parses the installed PTC declaration; `lib/preset.json` holds the persona and the fallback snapshot used only when that declaration is unavailable.
|
|
97
121
|
|
|
98
122
|
Uninstall with `plugin_manager` action `remove_bundle`, target `dsh-deep-ptc-mode`. Local link installations depend on their source directory: uninstall before deleting it.
|
|
99
123
|
|
package/README.zh.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# 深度 PTC 模式
|
|
2
2
|
|
|
3
|
-
[English](README.md) · MIT · 当前版本:**1.
|
|
3
|
+
[English](README.md) · MIT · 当前版本:**1.5.0**
|
|
4
4
|
|
|
5
5
|
DeepSeek Harness 的 Agent 模式(preset),工具面与内置 PTC 完全一致,只换掉「工作方式」:让模型把能力用满、全程可被打断、按任务大小决定要不要你批准、拿不准就问你,并且自己选命令在哪个环境里跑。
|
|
6
6
|
|
|
@@ -11,13 +11,34 @@ DeepSeek Harness 的 Agent 模式(preset),工具面与内置 PTC 完全一
|
|
|
11
11
|
| 你遇到的问题 | 深度PTC模式的做法 |
|
|
12
12
|
| --- | --- |
|
|
13
13
|
| 模型总想帮你省 token,少查、少测,结果质量打折 | 人设写明「在深度求索工作,本模式 token 预算无限,把预算花在工作上」:不为省 token 跳过读取、搜索、命令或验证;同时禁止注水、啰嗦和撑爆上下文 |
|
|
14
|
-
| 任务跑起来后模型在 sleep 或干等,你发消息它不理 |
|
|
14
|
+
| 任务跑起来后模型在 sleep 或干等,你发消息它不理 | 由代码强制:前台命令超过 30 秒自动转后台,你一发消息正在等的命令立即转后台、模型马上看到消息,长 sleep 直接拒绝;job 完成会自动唤醒模型(详见下方「代码层强制」) |
|
|
15
15
|
| 不管大小任务都同一种开工方式 | 按预计耗时分三档:5 分钟内自己计划直接做;5–20 分钟先告诉你计划、不等审批就执行;超过 20 分钟先给计划、等你批准 |
|
|
16
16
|
| 意思没弄懂就开干,最后返工 | 意思归用户,事实归工具:不认识的名称、多个可能目标、技术路线、范围和验收标准不确定时先问你(1–3 个带选项的问题),不靠搜索去猜你的意图;文件位置、当前行为这类事实自己查 |
|
|
17
17
|
| 命令环境固定,Windows 上想用 WSL、Mac 上想用 Zsh 都不方便 | 设置里可选 WSL Bash、PowerShell、Zsh(macOS/Linux)或原生 Bash,只对本模式生效,不改全局 shell |
|
|
18
18
|
|
|
19
19
|
使用三步:安装插件 → 在 **设置 → 插件 → 深度 PTC** 里选执行环境 → 新建任务时在模式选择器里选「深度PTC模式」。
|
|
20
20
|
|
|
21
|
+
## 代码层强制:不休眠、随时可插话
|
|
22
|
+
|
|
23
|
+
「不 sleep、不干等」不只写在提示词里,1.5.0 起由插件代码强制执行,模型不遵守也绕不过去:
|
|
24
|
+
|
|
25
|
+
| 场景 | 代码行为 |
|
|
26
|
+
| --- | --- |
|
|
27
|
+
| 前台命令跑得久 | 超过 **30 秒**(可配置 5–600)自动转为后台 job,命令不会被杀掉;模型请求更长的 `timeoutMs` 也会被压到这个上限 |
|
|
28
|
+
| 命令运行中你发了消息 | 约 2 秒内结束前台等待,命令转入后台继续跑,模型立刻看到你的消息;job 完成后仍会自动唤醒模型 |
|
|
29
|
+
| `job_output` 等待 job | 等待上限同为 30 秒;你一发消息就提前返回;你的消息未读时再次等待会被拒绝 |
|
|
30
|
+
| 模型写 `sleep 60`、`Start-Sleep 30`、`timeout /t 20` | 前台超过 5 秒的暂停直接拒绝(`run_in_background` 的命令不受限);`sleep 1` 这类就绪循环照常 |
|
|
31
|
+
| `run_code` 程序里 `setTimeout`/`setInterval`/`time.sleep` | 超过 5 秒、或时长不是数字字面量的等待直接拒绝;同一程序里轮询同一个运行中 job 超过 3 次也会被拒绝 |
|
|
32
|
+
| `ask_user_question` | 改为限时模式:默认等 120 秒,最多 300 秒,`-1`(无限等)被拒绝;超时后问题变为「待回答」,你之后的回答会作为消息送达;你不点卡片、直接打字回复,也会立刻结束等待 |
|
|
33
|
+
|
|
34
|
+
这些规则只作用于「深度PTC模式」会话,不影响其他模式。前提是桌面端设置里「忙碌时回车」为**插入当前任务(steer)**;若为排队(queue),消息会等整轮结束才送达。
|
|
35
|
+
|
|
36
|
+
```yaml
|
|
37
|
+
- id: deep-ptc-settings
|
|
38
|
+
config:
|
|
39
|
+
foregroundSeconds: 30 # 前台等待上限(秒),5–600
|
|
40
|
+
```
|
|
41
|
+
|
|
21
42
|
## 选择 WSL、PowerShell 或 macOS 工具
|
|
22
43
|
|
|
23
44
|
安装并加载后,打开 **设置 → 插件 → 深度 PTC**,选择执行环境并保存,再新建一个「深度PTC模式」会话。
|
|
@@ -43,7 +64,7 @@ WSL 命令使用 Linux/POSIX 语法;文件工具和 `workdir` 仍用 Windows
|
|
|
43
64
|
## 工作规则
|
|
44
65
|
|
|
45
66
|
- **不为 token 省力:** 人设写明在深度求索工作、本模式 token 预算无限,按问题需要而不是成本决定读取、搜索、命令和验证的深度;同时禁止注水和啰嗦,单次上下文仍有限,靠压缩、裁剪和子代理控制。
|
|
46
|
-
- **任务运行中随时可插话:**
|
|
67
|
+
- **任务运行中随时可插话:** 由代码强制(见上文),提示词同时要求:不 sleep、不轮询、不挂长时间前台调用。构建、测试、安装、服务器等耗时命令放后台 job,期间继续做短步骤,用不阻塞的方式查看进度;没事可做就一句话说明在跑什么并结束回合,job 完成会自动唤醒模型,你的消息会被立即处理。
|
|
47
68
|
- **按任务长短计划:** ≤5 分钟内部计划直接做,不单独告知;5–20 分钟展示计划后立即执行,不等审批;>20 分钟展示计划并等你批准再改动。估计升档时重新说明计划;显式 plan mode 的规则优先。
|
|
48
69
|
- **意图不清先问:** 意思归用户,事实归工具。不认识的名称、多个可能目标、技术路线、权威来源、做事方式、验收标准和范围不确定时先问,不用搜索去猜你的术语;文件位置、当前行为、版本等可检查的事实自己查。每次 1–3 个带选项的问题,推荐项在前;你的回答优先于模型推断。
|
|
49
70
|
- **进度可见:** 每次 `run_code` 前一句话说明要做什么,里程碑稍长汇报,连续两三个工具调用必须出声。
|
|
@@ -58,10 +79,10 @@ WSL 命令使用 Linux/POSIX 语法;文件工具和 `workdir` 仍用 Windows
|
|
|
58
79
|
本地目录或构建产物可通过插件管理器安装:
|
|
59
80
|
|
|
60
81
|
```js
|
|
61
|
-
plugin_manager({ action: "install_bundle", target: "dsh-deep-ptc-mode@1.
|
|
82
|
+
plugin_manager({ action: "install_bundle", target: "dsh-deep-ptc-mode@1.5.0" })
|
|
62
83
|
// 也可从本地目录或安装包安装:
|
|
63
84
|
plugin_manager({ action: "install_bundle", target: "C:\\path\\to\\dsh-deep-ptc-mode" })
|
|
64
|
-
// 或 target: "C:\\path\\to\\dsh-deep-ptc-mode-1.
|
|
85
|
+
// 或 target: "C:\\path\\to\\dsh-deep-ptc-mode-1.5.0.tgz"
|
|
65
86
|
```
|
|
66
87
|
|
|
67
88
|
GitHub 地址:`github:lishize20040802-rgb/dsh-deep-ptc-mode`。该地址安装远端实际内容;本地升级不会自动发布到 GitHub/npm。
|
|
@@ -81,29 +102,35 @@ GitHub 地址:`github:lishize20040802-rgb/dsh-deep-ptc-mode`。该地址安装
|
|
|
81
102
|
|
|
82
103
|
## 兼容性与维护
|
|
83
104
|
|
|
84
|
-
|
|
105
|
+
Deep PTC 在加载时依据已安装 Harness 声明的 PTC 预设(`@deepseek-ai/dsh-web-app/presets/ptc.patch.yml`)现场组合:官方行原样继承,仅替换 persona 文本、把两个互斥 shell 工具换成一个带 `shell` 隔离的执行组、加入可达性守卫,并包装官方 job 与提问工具。官方怎么改 PTC,本模式无需发版即可继承;官方改名或删除的模块也不会留下失效行。只有在该声明无法解析、读取或解析失败时,才退回内置的 `lib/preset.json` 快照,并在日志中说明。
|
|
85
106
|
|
|
86
|
-
|
|
107
|
+
官方声明通过宿主运行时解析,因此插件引用的宿主包都必须声明在 `peerDependencies` 中(包括 `@deepseek-ai/dsh-web-app`):对 `link:` 本地安装,宿主只有看到 peer 声明才会把这些包名路由到已安装运行时。漏声明时 `npm run check` 会失败——这正是避免本地安装静默退回快照的关键。`compatibility.json` 记录 fixture 所取自的上游版本及其哈希;`npm run check` 会验证内置回退快照与 fixture 仍组合出同一预设,并检查继承不变量。`engines` 是安装下限,不能证明之后所有宿主都经过测试,遇到新版本先用 `npm run check:upstream -- <path>` 复核。
|
|
87
108
|
|
|
88
109
|
```sh
|
|
89
110
|
npm ci
|
|
90
111
|
npm run check
|
|
91
112
|
npm test
|
|
92
113
|
npm run check:upstream -- /path/to/ptc.patch.yml
|
|
114
|
+
npm run sync:snapshot # 从已安装声明刷新 lib/preset.json 回退快照
|
|
115
|
+
PTC_RUNTIME_MODULES=/path/to/dsh/node_modules node scripts/check-preset.cjs # 用真实运行时检查每行模块可解析
|
|
116
|
+
PTC_RUNTIME_MODULES=/path/to/dsh/node_modules node scripts/check-reachability.mjs # 用真实运行时验证可打断等待
|
|
93
117
|
npm pack
|
|
94
118
|
```
|
|
95
119
|
|
|
96
|
-
|
|
120
|
+
检查器把 `!!js` 当数据解析,并断言派生不变量:除 persona、shell 行与两个包装行外,官方行必须原样保留(官方把它们嵌进 group 时也同样处理);行 id 唯一;九种平台/环境组合下派生结果确定。测试同时覆盖未来可能出现的组合变化(新增未知行、调整行顺序、删除 shell 行或包装行),以及平台选择、命令边界、受限 WSL 拒绝、设置表单原子保存及并发版本约束。真实任务评测仍应记录成功率、无必要提问、范围控制、后台收尾和耗时。
|
|
97
121
|
|
|
98
122
|
## 文件和卸载
|
|
99
123
|
|
|
100
124
|
- `cordis.patch.yml`:宿主设置入口。
|
|
101
125
|
- `lib/index.mjs`:配置 schema、preset 注册和版本切换。
|
|
102
|
-
- `lib/model.mjs
|
|
126
|
+
- `lib/model.mjs`:平台选择、参数、隔离配置和环境说明,以及从官方声明派生 preset。
|
|
103
127
|
- `lib/executor.mjs`:复用官方进程/沙箱语义的 WSL/Zsh 执行器。
|
|
104
|
-
- `lib/terminal.mjs
|
|
128
|
+
- `lib/terminal.mjs`:复用官方 Bash/PowerShell 终端工具,等待可被用户消息打断,并提供 Zsh 方言与工具名。
|
|
129
|
+
- `lib/jobs-tool.mjs`、`lib/ask-user.mjs`:官方 job 工具与提问工具的包装,等待可被用户消息打断。
|
|
130
|
+
- `lib/guard.mjs`、`lib/rules.mjs`、`lib/sleep-lint.mjs`、`lib/reachable.mjs`:拒绝长暂停与轮询的工具守卫,以及可打断等待的实现。
|
|
105
131
|
- `lib/client.js`:中英文设置卡片。
|
|
106
|
-
- `lib/
|
|
132
|
+
- `lib/upstream.mjs`:定位并解析已安装的 PTC 声明。
|
|
133
|
+
- `lib/preset.json`:persona,以及仅在声明不可用时的回退快照。
|
|
107
134
|
- `test/`、`scripts/check.mjs`、`compatibility.json`:回归与上游差异检查。
|
|
108
135
|
|
|
109
136
|
卸载使用插件管理器的 `remove_bundle`,目标为 `dsh-deep-ptc-mode`。本地 link 安装直接依赖源目录,应先卸载再删除目录。
|
package/compatibility.json
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
{
|
|
2
|
-
"
|
|
2
|
+
"mode": "derived",
|
|
3
3
|
"source": "@deepseek-ai/dsh-web-app/presets/ptc.patch.yml",
|
|
4
|
-
"
|
|
4
|
+
"verifiedUpstream": "0.2.2-rc.1",
|
|
5
|
+
"snapshotSha256": "ce02148b1fd575cc93071744180468cd305bdcd50dbfdd3b9b0605c5281d283d"
|
|
5
6
|
}
|
package/lib/adapt.mjs
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
// Present an official tool plugin with replaced service faces while keeping the real Cordis context
|
|
2
|
+
// for effects, events and injection. `faces` maps a service name to a function of the real service.
|
|
3
|
+
export function adaptContext(ctx, faces) {
|
|
4
|
+
const face = (target, key) => {
|
|
5
|
+
const value = Reflect.get(target, key, target);
|
|
6
|
+
if (Object.hasOwn(faces, key) && value !== undefined) return faces[key](value);
|
|
7
|
+
return typeof value === 'function' ? value.bind(target) : value;
|
|
8
|
+
};
|
|
9
|
+
return new Proxy(ctx, {
|
|
10
|
+
get(target, key) {
|
|
11
|
+
if (key === 'inject') return (dependencies, callback) => target.inject(dependencies,
|
|
12
|
+
child => callback(new Proxy(child, { get: face })));
|
|
13
|
+
return face(target, key);
|
|
14
|
+
},
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
// Wrap each definition an official plugin registers.
|
|
19
|
+
export function registering(tools, wrap) {
|
|
20
|
+
return new Proxy(tools, {
|
|
21
|
+
get(target, key) {
|
|
22
|
+
if (key === 'register') return definition => target.register(wrap(definition));
|
|
23
|
+
const value = Reflect.get(target, key, target);
|
|
24
|
+
return typeof value === 'function' ? value.bind(target) : value;
|
|
25
|
+
},
|
|
26
|
+
});
|
|
27
|
+
}
|
package/lib/ask-user.mjs
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Config, apply as applyAskUser, inject } from '@deepseek-ai/dsh-tool-ask-user';
|
|
2
|
+
import { adaptContext } from './adapt.mjs';
|
|
3
|
+
import { steerableQuestions, steeringWatch } from './reachable.mjs';
|
|
4
|
+
|
|
5
|
+
export const name = 'deep-ptc-tool-ask-user';
|
|
6
|
+
export { Config, inject };
|
|
7
|
+
|
|
8
|
+
// The official question tool. In timed mode a question the user leaves unanswered becomes pending,
|
|
9
|
+
// and a message the user writes instead ends the wait early.
|
|
10
|
+
export function apply(ctx, config) {
|
|
11
|
+
const watch = steeringWatch(ctx);
|
|
12
|
+
applyAskUser(adaptContext(ctx, { userQuestions: questions => steerableQuestions(questions, watch) }), config);
|
|
13
|
+
}
|
package/lib/guard.mjs
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import z from '@deepseek-ai/schemastery';
|
|
2
|
+
import { reachabilityGuard, reachabilityText } from './rules.mjs';
|
|
3
|
+
|
|
4
|
+
export const name = 'deep-ptc-reachability-guard';
|
|
5
|
+
export const inject = ['tools', 'systemPrompt'];
|
|
6
|
+
export const Config = z.object({
|
|
7
|
+
foregroundSeconds: z.number().min(5).max(600).default(30),
|
|
8
|
+
maxQuestionSeconds: z.number().min(10).max(3600).default(300),
|
|
9
|
+
maxPollsPerProgram: z.number().min(1).max(100).default(3),
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
export function apply(ctx, config) {
|
|
13
|
+
ctx.tools.guard(reachabilityGuard(config, () => ctx.get('jobs')));
|
|
14
|
+
ctx.systemPrompt.section({ name: 'deep-ptc:reachability', order: 10195, text: reachabilityText(config) });
|
|
15
|
+
}
|
package/lib/index.mjs
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import z from '@deepseek-ai/schemastery';
|
|
2
|
-
import
|
|
3
|
-
import { availableEnvironments,
|
|
2
|
+
import snapshot from './preset.json' with { type: 'json' };
|
|
3
|
+
import { availableEnvironments, DEFAULT_FOREGROUND_SECONDS, deriveDeepPtc, normalizeDistribution } from './model.mjs';
|
|
4
|
+
import { loadOfficialPreset } from './upstream.mjs';
|
|
4
5
|
import { presetLifecycle } from './lifecycle.mjs';
|
|
5
6
|
|
|
6
7
|
export const name = 'deep-ptc-settings';
|
|
@@ -8,16 +9,52 @@ export const inject = ['agentPresets'];
|
|
|
8
9
|
export const Config = z.object({
|
|
9
10
|
environment: z.union(availableEnvironments(process.platform)).default('auto').volatile(),
|
|
10
11
|
wslDistribution: z.string().pattern(/^(?!\s*-)[^\u0000-\u001f\u007f]*$/u).default('').volatile(),
|
|
12
|
+
foregroundSeconds: z.number().step(1).min(5).max(600).default(DEFAULT_FOREGROUND_SECONDS).volatile(),
|
|
11
13
|
hostPlatform: z.const(process.platform).default(process.platform).volatile(),
|
|
12
14
|
});
|
|
13
15
|
|
|
16
|
+
function settingsOf(config) {
|
|
17
|
+
return {
|
|
18
|
+
environment: config.environment.get(),
|
|
19
|
+
wslDistribution: normalizeDistribution(config.wslDistribution.get()),
|
|
20
|
+
foregroundSeconds: config.foregroundSeconds.get(),
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
// Derive Deep PTC from the PTC preset the installed Harness declares, so an
|
|
25
|
+
// official change is inherited instead of leaving a stale frozen row behind.
|
|
26
|
+
// The bundled snapshot is only a fallback when the installed declaration
|
|
27
|
+
// cannot be read or cannot be composed.
|
|
28
|
+
function buildPreset(ctx, config) {
|
|
29
|
+
const settings = settingsOf(config);
|
|
30
|
+
let upstream = snapshot;
|
|
31
|
+
let source = 'bundled snapshot';
|
|
32
|
+
try {
|
|
33
|
+
const official = loadOfficialPreset();
|
|
34
|
+
upstream = official.preset;
|
|
35
|
+
source = official.source;
|
|
36
|
+
} catch (error) {
|
|
37
|
+
ctx.logger.warn('Deep PTC: official PTC preset unavailable (%s); deriving from the bundled snapshot', error.message);
|
|
38
|
+
}
|
|
39
|
+
try {
|
|
40
|
+
const { preset, report } = deriveDeepPtc(upstream, settings);
|
|
41
|
+
ctx.logger.info(
|
|
42
|
+
'Deep PTC preset derived from %s: %d official rows; persona %s; shell rows [%s]; wrapped [%s]; skipped [%s]',
|
|
43
|
+
source, report.upstreamRows, report.persona,
|
|
44
|
+
report.replacedShellRows.join('; ') || '-', report.wrapped.join(', ') || '-', report.skipped.join('; ') || '-',
|
|
45
|
+
);
|
|
46
|
+
return preset;
|
|
47
|
+
} catch (error) {
|
|
48
|
+
if (upstream === snapshot) throw error;
|
|
49
|
+
ctx.logger.warn('Deep PTC: deriving from %s failed (%s); deriving from the bundled snapshot', source, error.message);
|
|
50
|
+
return deriveDeepPtc(snapshot, settings).preset;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
14
54
|
export async function apply(ctx, config) {
|
|
15
55
|
const lifecycle = presetLifecycle(
|
|
16
56
|
definition => ctx.agentPresets.register(definition),
|
|
17
|
-
() =>
|
|
18
|
-
environment: config.environment.get(),
|
|
19
|
-
wslDistribution: normalizeDistribution(config.wslDistribution.get()),
|
|
20
|
-
}),
|
|
57
|
+
() => buildPreset(ctx, config),
|
|
21
58
|
error => ctx.logger.error('Deep PTC environment update failed: %s', error.message),
|
|
22
59
|
);
|
|
23
60
|
ctx.effect(() => () => lifecycle.dispose());
|
|
@@ -25,5 +62,7 @@ export async function apply(ctx, config) {
|
|
|
25
62
|
ctx.inject(['settings'], child => {
|
|
26
63
|
child.effect(() => child.settings.configure({ auto: false }, ctx.fiber));
|
|
27
64
|
});
|
|
28
|
-
|
|
65
|
+
// A failure to publish the preset is reported above; it must not take the
|
|
66
|
+
// settings service (or the rest of the profile) down with it.
|
|
67
|
+
await lifecycle.refresh().catch(() => {});
|
|
29
68
|
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Config, apply as applyJobs, inject } from '@deepseek-ai/dsh-tool-jobs';
|
|
2
|
+
import { adaptContext, registering } from './adapt.mjs';
|
|
3
|
+
import { steerableJobs, steerableTool, steeringWatch } from './reachable.mjs';
|
|
4
|
+
|
|
5
|
+
export const name = 'deep-ptc-tool-jobs';
|
|
6
|
+
export { Config, inject };
|
|
7
|
+
|
|
8
|
+
// The official job tools, with job_output waits ending when the user sends a message.
|
|
9
|
+
export function apply(ctx, config) {
|
|
10
|
+
const watch = steeringWatch(ctx);
|
|
11
|
+
applyJobs(adaptContext(ctx, {
|
|
12
|
+
tools: tools => registering(tools, definition => definition.name === 'job_output' ? steerableTool(definition) : definition),
|
|
13
|
+
jobs: jobs => steerableJobs(jobs, watch),
|
|
14
|
+
}), config);
|
|
15
|
+
}
|