dsh-minimal-ptc 0.4.5 → 0.5.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/LICENSE +21 -21
- package/README.en.md +38 -51
- package/README.md +38 -64
- package/cordis.patch.yml +8 -8
- package/lib/index.js +172 -67
- package/package.json +9 -4
- package/presets/ptc-minimal/agent.cordis.yml +297 -284
- package/presets/ptc-minimal/gitbash-executor.mjs +340 -340
- package/presets/ptc-minimal/preset.yml +2 -2
- package/ptc-minimal.patch.yml +307 -0
package/LICENSE
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2026 stardustlc
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 stardustlc
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.en.md
CHANGED
|
@@ -1,77 +1,64 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
   
|
|
4
|
-
|
|
5
|
-
> Minimal prompt x full PTC capabilities — a cleaner coding agent.
|
|
6
|
-
> Installing gives you a new agent mode: **Minimal PTC**, with Git Bash and persistent PowerShell on Windows, aligned with `dsh-v0.1.5-rc.1`.
|
|
1
|
+
[中文](README.md)
|
|
7
2
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
- **RL-aligned**: the whole system prompt is one sentence — `You are a helpful software engineer assistant.` — close to the compact instruction distribution used during RL fine-tuning, without long-prompt format bias or context noise.
|
|
11
|
-
- **Complete PTC surface**: provides `run_code` SDK orchestration, files and search, Shell, Skills, plan mode, goals, subagents, Ralph, and web search/fetch; the general-purpose workflow tool stays hidden as in alpha.4.
|
|
12
|
-
- **We / Let's reasoning**: the PTC SDK packs thinking and doing into one TypeScript program, orchestrating multi-step operations before executing them once. This matches the high-scoring Minimal trajectory in DeepSeek's official Project2 V4.1b runs (99/96), where reasoning is dominated by `we` / `let's` instead of the standard-like `let me` / `I` blocks seen at 91/92.
|
|
13
|
-
- **Git Bash on Windows**: ships a preset-local Git Bash executor (GIT_BASH -> Program Files\Git -> LOCALAPPDATA\Git -> PATH). The bash tool is no longer disabled on Windows.
|
|
14
|
-
- **Persistent PowerShell on Windows**: mirrors the `dsh-v0.1.5-rc.1` minimal preset; `pwsh` runs as a persistent PTY session, so cwd, variables, and functions survive across calls.
|
|
3
|
+
# dsh-minimal-ptc
|
|
15
4
|
|
|
16
|
-
|
|
5
|
+
Adds **Minimal PTC** to DeepSeek Harness: a concise system prompt with files, terminals, search, skills and installed plugin tools, orchestrated through `run_code`. Windows includes Git Bash and persistent PowerShell.
|
|
17
6
|
|
|
18
|
-
|
|
7
|
+
## Install and use
|
|
19
8
|
|
|
20
|
-
|
|
9
|
+
Version 0.5.0 requires **Harness 0.1.7 or later**. Use `dsh-minimal-ptc@0.4.7` on Harness 0.1.5/0.1.6.
|
|
21
10
|
|
|
22
|
-
|
|
11
|
+
```bash
|
|
12
|
+
dsh plugin --profile web add dsh-minimal-ptc
|
|
13
|
+
```
|
|
23
14
|
|
|
24
|
-
|
|
15
|
+
Restart `dsh web`, start a new session and choose **极简 PTC 模式** (Minimal PTC) from the mode picker above the message box. Describe your task normally; no preset directory or YAML editing is required.
|
|
25
16
|
|
|
26
|
-
|
|
27
|
-
"dependencies": { "dsh-minimal-ptc": "^0.4.0" },
|
|
28
|
-
"dsh": { "profile": { "bundles": [..., "dsh-minimal-ptc"] } }
|
|
29
|
-
```
|
|
17
|
+
For example: “Run this project’s tests, find the failures and fix them.” Existing email, calendar and other plugin tools remain available.
|
|
30
18
|
|
|
31
|
-
|
|
19
|
+
## Changes in 0.5.0
|
|
32
20
|
|
|
33
|
-
|
|
21
|
+
- Registers through the official Harness 0.1.7 declarative Agent preset service, fixing the missing mode after a host upgrade.
|
|
22
|
+
- Installs and updates the preset with the plugin. Existing user content in `.agent-presets/ptc-minimal` is preserved.
|
|
23
|
+
- Checks for conflicting runtime packages without flagging supported helpers such as `schemastery` and `cosmokit`.
|
|
24
|
+
- Uses `workflow-ptc` and retains plugin tools, Git Bash, persistent PowerShell, search, plans, goals and subagents.
|
|
34
25
|
|
|
35
|
-
|
|
26
|
+
## Compatibility and validation
|
|
36
27
|
|
|
37
|
-
|
|
28
|
+
Tested on 2026-09-23 with official-source **Harness 0.1.7-alpha.2**, including a local `Symbol.for` tool-scheduler fix. All 18 plugins load together with passing tool contracts and skill registration. The real Web mode picker lists and selects the preset; a real agent mounts it with `run_code` as its model entry point while retaining plugin tools and the shell.
|
|
38
29
|
|
|
39
|
-
|
|
30
|
+
A real `run_code` call to the RSS plugin passed in a sandboxed Windows workspace and again after restart. The fixture owner has full control of the disposable directory so the host can apply sandbox permissions. External mail, databases and other services still require their own valid configuration.
|
|
40
31
|
|
|
41
|
-
|
|
42
|
-
dsh plugin --profile web remove dsh-minimal-ptc
|
|
43
|
-
```
|
|
32
|
+
Requires Node 22.19 or later within 22.x, or 24 or later.
|
|
44
33
|
|
|
45
|
-
|
|
34
|
+
## Windows terminals
|
|
46
35
|
|
|
36
|
+
A standard Git for Windows installation is detected automatically. For a custom location, set `GIT_BASH` to the full path of `bash.exe` before starting DSH. PowerShell sessions preserve their current directory, variables and functions.
|
|
47
37
|
|
|
48
|
-
|
|
38
|
+
Developers creating their own preset can use the bundled `ptc-minimal.patch.yml` as a reference; the executor module is `dsh-minimal-ptc/gitbash-executor`.
|
|
49
39
|
|
|
50
|
-
|
|
51
|
-
- Subagents and Ralph are enabled; the general-purpose workflow tool remains hidden in PTC mode.
|
|
52
|
-
- `subagent_codex` and `subagent_claude_code` providers are disabled by default; remove their `disabled: true` lines to expose them.
|
|
53
|
-
|
|
54
|
-
## Windows Git Bash configuration
|
|
55
|
-
|
|
56
|
-
The preset-local Git Bash executor can be overridden in `agent.cordis.yml` under `gitbash-executor`:
|
|
57
|
-
|
|
58
|
-
| Option | Default | Meaning |
|
|
40
|
+
| Executor option | Default | Purpose |
|
|
59
41
|
| :-- | :-- | :-- |
|
|
60
|
-
| `shellPath` | auto-detected |
|
|
61
|
-
| `timeoutMs` | 120000 | Per-command timeout
|
|
62
|
-
| `maxTimeoutMs` | 600000 | Maximum timeout
|
|
63
|
-
| `maxOutputBytes` | 64000 |
|
|
42
|
+
| `shellPath` | auto-detected | Git Bash path |
|
|
43
|
+
| `timeoutMs` | 120000 | Per-command timeout in ms |
|
|
44
|
+
| `maxTimeoutMs` | 600000 | Maximum requested timeout |
|
|
45
|
+
| `maxOutputBytes` | 64000 | Output cap per call |
|
|
64
46
|
| `maxSpillBytes` | 67108864 | Output spill-to-disk cap |
|
|
65
47
|
| `graceMs` | 3000 | Grace period after timeout |
|
|
66
48
|
|
|
67
|
-
|
|
49
|
+
## Troubleshooting
|
|
50
|
+
|
|
51
|
+
If the mode is missing, confirm Harness is 0.1.7 or later and restart after installation. Recreating a retired preset directory will not help: the new host does not discover presets there.
|
|
52
|
+
|
|
53
|
+
If every tool fails with `Cannot read properties of undefined (reading 'prepare')`, check startup logs for duplicate runtime packages. Update the plugin bringing in extra `dsh-tools` / `cordis` copies and reinstall dependencies. Do not remove the entire `@deepseek-ai` directory: public helpers are supported dependencies. Another confirmed cause is the host loading two tool build outputs with a module-local scheduler `Symbol`; source builds can use `Symbol.for('@deepseek-ai/dsh-tools.scheduler')` and rebuild.
|
|
68
54
|
|
|
69
|
-
##
|
|
55
|
+
## Uninstall
|
|
56
|
+
|
|
57
|
+
```bash
|
|
58
|
+
dsh plugin --profile web remove dsh-minimal-ptc
|
|
59
|
+
```
|
|
70
60
|
|
|
71
|
-
|
|
72
|
-
- Marker version lower than the plugin version -> refresh from the bundled files.
|
|
73
|
-
- Directory exists without a marker (treated as user-created) -> leave it untouched.
|
|
74
|
-
- Upgrading: bump `version` in `package.json` and the `VERSION` constant in `lib/index.js`.
|
|
61
|
+
Restart the Web service afterward.
|
|
75
62
|
|
|
76
63
|
## License
|
|
77
64
|
|
package/README.md
CHANGED
|
@@ -1,91 +1,65 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
   
|
|
4
|
-
|
|
5
|
-
> 极简提示词 × PTC 全能力 —— 一个更"干净"的编码 Agent。
|
|
6
|
-
> 安装即获得新的 Agent 模式:**极简 PTC 模式**;Windows 自动启用 Git Bash 与持久 PowerShell(对齐 dsh-v0.1.5-rc.1)。
|
|
1
|
+
[English](README.en.md)
|
|
7
2
|
|
|
8
|
-
|
|
3
|
+
# dsh-minimal-ptc
|
|
9
4
|
|
|
10
|
-
|
|
11
|
-
贴近 RL 微调时的简洁指令分布,没有长提示词带来的格式偏置与上下文噪音,
|
|
12
|
-
让模型按训练时的节奏干活。
|
|
13
|
-
- **PTC 工具面完整**:提供 `run_code` SDK 多步编排、文件读写与检索、Shell、
|
|
14
|
-
Skills、计划、目标、子代理、Ralph 与网页搜索/抓取;按 alpha.4 默认隐藏通用 workflow 工具。
|
|
15
|
-
- **We / Let's 思维链**:PTC SDK 把"想"和"做"装进一个 TypeScript 程序,
|
|
16
|
-
多步操作先编排、再一次执行。这与 DeepSeek 官方跑分环境(Project2 V4.1b)中
|
|
17
|
-
Minimal 高分轨迹一致:99/96 的两跑以 `we` / `let's` 为主,而不是
|
|
18
|
-
Standard/PTC 常见的 `let me` / `I` 长块。
|
|
19
|
-
- **Windows 保持 bash**:预设内置 Git Bash executor(自动探测 GIT_BASH → Program Files\Git → LOCALAPPDATA\Git → PATH),`bash` 工具不再在 Windows 上被禁用。
|
|
20
|
-
- **Windows 持久 PowerShell**:对齐 `dsh-v0.1.5-rc.1` 的 minimal 预设,`pwsh` 使用持久 PTY 会话,cwd、变量、函数跨调用保留。
|
|
5
|
+
给 DeepSeek Harness 添加「极简 PTC 模式」:使用简短的系统提示词,保留文件、终端、搜索、技能与已安装插件,通过 `run_code` 编排多步操作。Windows 支持 Git Bash 和持久 PowerShell。
|
|
21
6
|
|
|
22
|
-
##
|
|
7
|
+
## 安装和使用
|
|
23
8
|
|
|
24
|
-
|
|
9
|
+
0.5.0 需要 **Harness 0.1.7 及以上**。仍使用 Harness 0.1.5/0.1.6 时,请安装 `dsh-minimal-ptc@0.4.7`。
|
|
25
10
|
|
|
26
|
-
|
|
11
|
+
```bash
|
|
12
|
+
dsh plugin --profile web add dsh-minimal-ptc
|
|
13
|
+
```
|
|
27
14
|
|
|
28
|
-
|
|
15
|
+
重启 `dsh web`,新建会话,在输入框上方的模式列表中选择 **极简 PTC 模式**,然后像平时一样描述任务。无需创建预设目录或修改 YAML。
|
|
29
16
|
|
|
30
|
-
|
|
17
|
+
例如:「检查这个项目的测试,找出失败原因并修复。」已有的邮件、日历等插件也可按原来的方式使用。
|
|
31
18
|
|
|
32
|
-
|
|
33
|
-
"dependencies": { "dsh-minimal-ptc": "^0.4.0" },
|
|
34
|
-
"dsh": { "profile": { "bundles": [..., "dsh-minimal-ptc"] } }
|
|
35
|
-
```
|
|
19
|
+
## 0.5.0 的变化
|
|
36
20
|
|
|
37
|
-
|
|
21
|
+
- 使用 Harness 0.1.7 官方的声明式 Agent 预设注册方式,修复升级后模式消失的问题。
|
|
22
|
+
- 预设随插件安装和更新;保留用户旧的 `.agent-presets/ptc-minimal` 目录,不覆盖其中的自定义内容。
|
|
23
|
+
- 启动检查只提示会影响工具运行的核心包副本,不再把 `schemastery`、`cosmokit` 等正常依赖误报为冲突。
|
|
24
|
+
- 使用新版 `workflow-ptc`,保留插件工具、Git Bash、持久 PowerShell、搜索、计划、目标与子代理能力。
|
|
38
25
|
|
|
39
|
-
|
|
26
|
+
## 兼容性与验证
|
|
40
27
|
|
|
41
|
-
|
|
42
|
-
`$DSH_HOME/.agent-presets/ptc-minimal`。
|
|
28
|
+
2026-09-23 在官方源码构建的 **Harness 0.1.7-alpha.2** 上验证(含本地工具调度器 `Symbol.for` 修复):18 个插件同载,工具契约与技能注册通过;极简 PTC 出现在实际网页模式列表中并可选择,真实 Agent 挂载后以 `run_code` 为模型入口,保留插件工具与 Shell。
|
|
43
29
|
|
|
44
|
-
|
|
30
|
+
已在沙箱开启的 Windows 隔离工作区通过 `run_code` 实际调用 RSS 插件,重启后再次通过。测试工作区由当前用户拥有完整管理权限,以便宿主设置沙箱权限;外部邮箱、数据库等业务仍需各插件的有效配置。
|
|
45
31
|
|
|
46
|
-
|
|
32
|
+
Node 要求为 22.19 及以上的 22.x,或 24 及以上。
|
|
47
33
|
|
|
48
|
-
|
|
49
|
-
dsh plugin --profile web remove dsh-minimal-ptc
|
|
50
|
-
```
|
|
34
|
+
## Windows 终端
|
|
51
35
|
|
|
52
|
-
|
|
36
|
+
安装常规版 Git for Windows 后会自动找到 Git Bash。若安装在自定义位置,可设置 `GIT_BASH` 为 `bash.exe` 的完整路径,再启动 DSH。PowerShell 会话会保留当前目录、变量和函数。
|
|
53
37
|
|
|
38
|
+
开发者如需自建预设,可参考包内的 `ptc-minimal.patch.yml`,执行器模块为 `dsh-minimal-ptc/gitbash-executor`。
|
|
54
39
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
预设内置的 Git Bash executor 可在 `agent.cordis.yml` 的 `gitbash-executor` 行覆盖:
|
|
58
|
-
|
|
59
|
-
| 配置 | 默认 | 说明 |
|
|
40
|
+
| 执行器选项 | 默认值 | 作用 |
|
|
60
41
|
| :-- | :-- | :-- |
|
|
61
|
-
| `shellPath` | 自动探测 |
|
|
62
|
-
| `timeoutMs` | 120000 |
|
|
63
|
-
| `maxTimeoutMs` | 600000 |
|
|
42
|
+
| `shellPath` | 自动探测 | 指定 Git Bash 路径 |
|
|
43
|
+
| `timeoutMs` | 120000 | 单次命令超时,毫秒 |
|
|
44
|
+
| `maxTimeoutMs` | 600000 | 允许请求的最长超时 |
|
|
64
45
|
| `maxOutputBytes` | 64000 | 单次输出上限 |
|
|
65
|
-
| `maxSpillBytes` | 67108864 |
|
|
66
|
-
| `graceMs` | 3000 |
|
|
46
|
+
| `maxSpillBytes` | 67108864 | 输出落盘上限 |
|
|
47
|
+
| `graceMs` | 3000 | 超时后的退出宽限时间 |
|
|
67
48
|
|
|
68
|
-
|
|
49
|
+
## 排错
|
|
69
50
|
|
|
70
|
-
|
|
51
|
+
模式未出现时,先确认 DSH 为 0.1.7 及以上且安装后已重启。不要通过重建旧预设目录解决,新宿主不再从该目录发现预设。
|
|
71
52
|
|
|
72
|
-
|
|
73
|
-
dsh-minimal-ptc/
|
|
74
|
-
├── cordis.patch.yml # 插入宿主行(物化预设)
|
|
75
|
-
├── lib/index.js # 宿主插件:物化 ptc-minimal 预设到用户预设根目录
|
|
76
|
-
└── presets/ptc-minimal/ # 内置 Agent 模式(极简提示词 + PTC 全能力)
|
|
77
|
-
├── agent.cordis.yml
|
|
78
|
-
├── gitbash-executor.mjs # Windows Git Bash 探测与执行器(零依赖)
|
|
79
|
-
└── preset.yml
|
|
80
|
-
```
|
|
53
|
+
若每个工具都报 `Cannot read properties of undefined (reading 'prepare')`,查看启动日志中的核心包冲突提示。应升级带入额外 `dsh-tools` / `cordis` 副本的插件并重新安装依赖;不要删除整个 `@deepseek-ai` 目录,官方的公共辅助包属于正常依赖。另一个已确认原因是宿主同时加载两份工具构建产物且调度器键使用模块局部 `Symbol`;源码构建可将其改为 `Symbol.for('@deepseek-ai/dsh-tools.scheduler')` 后重新构建。
|
|
81
54
|
|
|
82
|
-
##
|
|
55
|
+
## 卸载
|
|
56
|
+
|
|
57
|
+
```bash
|
|
58
|
+
dsh plugin --profile web remove dsh-minimal-ptc
|
|
59
|
+
```
|
|
83
60
|
|
|
84
|
-
|
|
85
|
-
版本 → 刷新;目录存在但无标记(用户自建)→ 不覆盖。
|
|
86
|
-
- 升级插件:改 `version` 并同步 `lib/index.js` 里的 `VERSION` 常量即可刷新
|
|
87
|
-
用户根目录里的预设文件。
|
|
61
|
+
重启 Web 服务后生效。
|
|
88
62
|
|
|
89
|
-
##
|
|
63
|
+
## License
|
|
90
64
|
|
|
91
65
|
MIT
|
package/cordis.patch.yml
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
# dsh-minimal-ptc 组合包补丁:向 profile 插入本插件的宿主行。
|
|
2
|
-
#
|
|
3
|
-
# 宿主行(name: dsh-minimal-ptc)在启动时把内置的 ptc-minimal 预设
|
|
4
|
-
# 物化到用户预设根目录($DSH_HOME/.agent-presets/ptc-minimal),
|
|
5
|
-
# 安装即获得「极简 PTC 模式」Agent 模式。
|
|
6
|
-
- insert:
|
|
7
|
-
- id: ptc-minimal-preset
|
|
8
|
-
name: 'dsh-minimal-ptc'
|
|
1
|
+
# dsh-minimal-ptc 组合包补丁:向 profile 插入本插件的宿主行。
|
|
2
|
+
#
|
|
3
|
+
# 宿主行(name: dsh-minimal-ptc)在启动时把内置的 ptc-minimal 预设
|
|
4
|
+
# 物化到用户预设根目录($DSH_HOME/.agent-presets/ptc-minimal),
|
|
5
|
+
# 安装即获得「极简 PTC 模式」Agent 模式。
|
|
6
|
+
- insert:
|
|
7
|
+
- id: ptc-minimal-preset
|
|
8
|
+
name: 'dsh-minimal-ptc'
|
package/lib/index.js
CHANGED
|
@@ -1,67 +1,172 @@
|
|
|
1
|
-
// dsh-minimal-ptc 宿主行:把内置的 ptc-minimal 预设物化到用户预设根目录。
|
|
2
|
-
//
|
|
3
|
-
// 预设发现是实时重读的,因此安装完成后重启一次 web profile 进程,
|
|
4
|
-
// 选择器里就会出现「极简 PTC 模式」。
|
|
5
|
-
//
|
|
6
|
-
// 物化策略:目标目录不存在 → 写入全部文件并留版本标记;
|
|
7
|
-
// 版本标记低于当前版本 → 用插件自带文件刷新;
|
|
8
|
-
// 目录存在但无标记(视为用户自建)→ 不覆盖。
|
|
9
|
-
//
|
|
10
|
-
// 零运行时依赖:harness home 的解析逻辑内置(DSH_HOME 环境变量优先,
|
|
11
|
-
// 否则 ~/.dsh),与 dsh 官方规则一致。
|
|
12
|
-
import { mkdirSync, readFileSync, writeFileSync, existsSync } from 'node:fs'
|
|
13
|
-
import { homedir } from 'node:os'
|
|
14
|
-
import { join, resolve } from 'node:path'
|
|
15
|
-
import { fileURLToPath } from 'node:url'
|
|
16
|
-
import pkg from '../package.json' with { type: 'json' }
|
|
17
|
-
|
|
18
|
-
export const name = 'ptc-minimal-preset'
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
const
|
|
22
|
-
const
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
const
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
1
|
+
// dsh-minimal-ptc 宿主行:把内置的 ptc-minimal 预设物化到用户预设根目录。
|
|
2
|
+
//
|
|
3
|
+
// 预设发现是实时重读的,因此安装完成后重启一次 web profile 进程,
|
|
4
|
+
// 选择器里就会出现「极简 PTC 模式」。
|
|
5
|
+
//
|
|
6
|
+
// 物化策略:目标目录不存在 → 写入全部文件并留版本标记;
|
|
7
|
+
// 版本标记低于当前版本 → 用插件自带文件刷新;
|
|
8
|
+
// 目录存在但无标记(视为用户自建)→ 不覆盖。
|
|
9
|
+
//
|
|
10
|
+
// 零运行时依赖:harness home 的解析逻辑内置(DSH_HOME 环境变量优先,
|
|
11
|
+
// 否则 ~/.dsh),与 dsh 官方规则一致。
|
|
12
|
+
import { mkdirSync, readFileSync, writeFileSync, existsSync, readdirSync } from 'node:fs'
|
|
13
|
+
import { homedir } from 'node:os'
|
|
14
|
+
import { join, resolve } from 'node:path'
|
|
15
|
+
import { fileURLToPath } from 'node:url'
|
|
16
|
+
import pkg from '../package.json' with { type: 'json' }
|
|
17
|
+
|
|
18
|
+
export const name = 'ptc-minimal-preset'
|
|
19
|
+
export const inject = ['appReady']
|
|
20
|
+
|
|
21
|
+
const VERSION = pkg.version
|
|
22
|
+
const PRESET_ID = 'ptc-minimal'
|
|
23
|
+
const MARKER = '.dsh-ptc-minimal.version'
|
|
24
|
+
|
|
25
|
+
// dsh-tools keys its tool scheduler with this symbol description. On stock
|
|
26
|
+
// hosts it is a module-local Symbol(), so any second dsh-tools instance
|
|
27
|
+
// (duplicate profile copy, or the package's own dual build outputs on
|
|
28
|
+
// 0.1.6-alpha) breaks the agent-loop lookup: every tool call then fails with
|
|
29
|
+
// "Cannot read properties of undefined (reading 'prepare')".
|
|
30
|
+
const SCHEDULER_SYMBOL_DESC = '@deepseek-ai/dsh-tools.scheduler'
|
|
31
|
+
|
|
32
|
+
const packageDir = fileURLToPath(new URL('..', import.meta.url))
|
|
33
|
+
const presetSourceDir = join(packageDir, 'presets', PRESET_ID)
|
|
34
|
+
|
|
35
|
+
/** 与 @deepseek-ai/dsh-home-paths 相同的解析规则:DSH_HOME > ~/.dsh。 */
|
|
36
|
+
function dshHomePath(...segments) {
|
|
37
|
+
const env = process.env.DSH_HOME
|
|
38
|
+
const fromEnv = typeof env === 'string' && env.trim().length > 0 ? env : null
|
|
39
|
+
let base = fromEnv ?? join(homedir(), '.dsh')
|
|
40
|
+
if (base === '~') base = homedir()
|
|
41
|
+
if (base.startsWith('~/') || base.startsWith('~\\')) base = join(homedir(), base.slice(2))
|
|
42
|
+
return resolve(base, ...segments)
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
function materialize(logger, modernRuntime) {
|
|
46
|
+
const dir = dshHomePath('.agent-presets', PRESET_ID)
|
|
47
|
+
mkdirSync(dir, { recursive: true })
|
|
48
|
+
const revision = modernRuntime ? `${VERSION}:ptc-runtime` : VERSION
|
|
49
|
+
|
|
50
|
+
let marker = null
|
|
51
|
+
try {
|
|
52
|
+
marker = readFileSync(join(dir, MARKER), 'utf8').trim()
|
|
53
|
+
} catch {
|
|
54
|
+
// 无标记:可能是首次安装,也可能是用户自建目录
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
if (marker === revision) return
|
|
58
|
+
if (marker === null && existsSync(join(dir, 'agent.cordis.yml'))) {
|
|
59
|
+
logger?.warn(`dsh-minimal-ptc: ${dir} exists without our marker; leaving it alone`)
|
|
60
|
+
return
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
for (const file of ['agent.cordis.yml', 'preset.yml', 'gitbash-executor.mjs']) {
|
|
64
|
+
let content = readFileSync(join(presetSourceDir, file), 'utf8')
|
|
65
|
+
if (modernRuntime && file === 'agent.cordis.yml') {
|
|
66
|
+
content = content.replaceAll('workflow-worker-thread', 'workflow-ptc')
|
|
67
|
+
.replaceAll('`codeRuntime`', '`ptcRuntime`')
|
|
68
|
+
}
|
|
69
|
+
writeFileSync(join(dir, file), content)
|
|
70
|
+
}
|
|
71
|
+
writeFileSync(join(dir, MARKER), revision + '\n')
|
|
72
|
+
logger?.info(`dsh-minimal-ptc: materialized agent preset "${PRESET_ID}" into ${dir}`)
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
export function apply(ctx) {
|
|
76
|
+
ctx.effect(() => ctx.appReady.onReady(() => {
|
|
77
|
+
try {
|
|
78
|
+
// 0.1.7 discovers the declarative row shipped by this bundle. Never
|
|
79
|
+
// rewrite a user's retired directory while running on that host.
|
|
80
|
+
if (typeof ctx.get('agentPresets')?.register !== 'function') {
|
|
81
|
+
materialize(ctx.logger, ctx.get('ptcRuntime') !== undefined)
|
|
82
|
+
}
|
|
83
|
+
} catch (error) {
|
|
84
|
+
ctx.logger?.warn(`dsh-minimal-ptc: preset materialization failed: ${String(error)}`)
|
|
85
|
+
}
|
|
86
|
+
try {
|
|
87
|
+
healthCheck(ctx)
|
|
88
|
+
} catch (error) {
|
|
89
|
+
ctx.logger?.warn(`dsh-minimal-ptc: health check failed: ${String(error)}`)
|
|
90
|
+
}
|
|
91
|
+
}))
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* Warn about the two known causes of "Cannot read properties of undefined
|
|
96
|
+
* (reading 'prepare')" before the first session hits them. Warnings only —
|
|
97
|
+
* nothing here blocks startup.
|
|
98
|
+
*/
|
|
99
|
+
function healthCheck(ctx) {
|
|
100
|
+
const logger = ctx.logger
|
|
101
|
+
|
|
102
|
+
// Cause 1 (most common in the wild): a plugin or stale install left a
|
|
103
|
+
// physical copy of @deepseek-ai/* inside some profile's node_modules. The
|
|
104
|
+
// core must come from the CLI's own dependency tree only.
|
|
105
|
+
for (const hit of findProfileCoreCopies()) {
|
|
106
|
+
logger?.warn(
|
|
107
|
+
`dsh-minimal-ptc: duplicate core package in profile: ${hit}\n`
|
|
108
|
+
+ ' A second @deepseek-ai copy breaks the tool scheduler key (module-local Symbol) '
|
|
109
|
+
+ 'and every tool call fails with "reading \'prepare\'".\n'
|
|
110
|
+
+ ' Fix: update the plugin that brings in this runtime package, reinstall profile dependencies, '
|
|
111
|
+
+ 'then restart. Shared helpers such as schemastery and cosmokit are supported dependencies.',
|
|
112
|
+
)
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
// Cause 2 (seen on stock 0.1.6-alpha): the host itself can load two dsh-tools
|
|
116
|
+
// instances (bundled lib/index.js vs per-module lib/types/*.js). It is safe
|
|
117
|
+
// only when the scheduler key survives multiple instances, i.e. the host was
|
|
118
|
+
// built with Symbol.for. Probe exactly that.
|
|
119
|
+
const status = schedulerKeyStatus(ctx.tools)
|
|
120
|
+
if (status === 'module-local') {
|
|
121
|
+
logger?.warn(
|
|
122
|
+
'dsh-minimal-ptc: this host keys the tool scheduler with a module-local Symbol '
|
|
123
|
+
+ '(unpatched dsh-tools). PTC sessions break with "reading \'prepare\'" '
|
|
124
|
+
+ 'whenever a second dsh-tools instance loads in this process.\n'
|
|
125
|
+
+ ' Fix: rebuild dsh-tools with `Symbol.for(\'@deepseek-ai/dsh-tools.scheduler\')` '
|
|
126
|
+
+ 'in packages/core/tools/src/index.ts, or keep a single dsh-tools copy.',
|
|
127
|
+
)
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
/**
|
|
132
|
+
* Physical @deepseek-ai copies under any profile's node_modules.
|
|
133
|
+
* @returns {string[]} paths like "<profile>/node_modules/@deepseek-ai/<pkg>"
|
|
134
|
+
*/
|
|
135
|
+
export function findProfileCoreCopies(home = dshHomePath('profiles')) {
|
|
136
|
+
const hits = []
|
|
137
|
+
let profiles = []
|
|
138
|
+
try {
|
|
139
|
+
profiles = readdirSync(home, { withFileTypes: true })
|
|
140
|
+
} catch {
|
|
141
|
+
return hits
|
|
142
|
+
}
|
|
143
|
+
for (const profile of profiles) {
|
|
144
|
+
if (!profile.isDirectory()) continue
|
|
145
|
+
const scopeDir = join(home, profile.name, 'node_modules', '@deepseek-ai')
|
|
146
|
+
let entries = []
|
|
147
|
+
try {
|
|
148
|
+
entries = readdirSync(scopeDir, { withFileTypes: true })
|
|
149
|
+
} catch {
|
|
150
|
+
continue
|
|
151
|
+
}
|
|
152
|
+
for (const entry of entries) {
|
|
153
|
+
// Schema helpers are ordinary published dependencies, not another host.
|
|
154
|
+
if (entry.isDirectory() && (entry.name === 'dsh-tools' || entry.name === 'cordis')) hits.push(join(scopeDir, entry.name))
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
return hits
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
/**
|
|
161
|
+
* How the host's tool registry exposes the scheduler key:
|
|
162
|
+
* - 'global' — Symbol.for key works; safe across duplicate instances.
|
|
163
|
+
* - 'module-local' — registry carries a same-description local Symbol; the
|
|
164
|
+
* agent loop breaks if a second dsh-tools instance loads.
|
|
165
|
+
* - 'absent' — no tools registry / no scheduler mounted (nothing to say).
|
|
166
|
+
*/
|
|
167
|
+
export function schedulerKeyStatus(tools) {
|
|
168
|
+
if (tools == null || (typeof tools !== 'object' && typeof tools !== 'function')) return 'absent'
|
|
169
|
+
if (tools[Symbol.for(SCHEDULER_SYMBOL_DESC)] !== undefined) return 'global'
|
|
170
|
+
const local = Object.getOwnPropertySymbols(tools).some(s => s.description === SCHEDULER_SYMBOL_DESC)
|
|
171
|
+
return local ? 'module-local' : 'absent'
|
|
172
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-minimal-ptc",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0",
|
|
4
4
|
"description": "DeepSeek Harness 极简 PTC 预设:简洁提示词、run_code 工具编排、完整插件工具,以及 Windows Git Bash 和持久 PowerShell。",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "lib/index.js",
|
|
@@ -9,7 +9,8 @@
|
|
|
9
9
|
"default": "./lib/index.js"
|
|
10
10
|
},
|
|
11
11
|
"./cordis.patch.yml": "./cordis.patch.yml",
|
|
12
|
-
"./package.json": "./package.json"
|
|
12
|
+
"./package.json": "./package.json",
|
|
13
|
+
"./gitbash-executor": "./presets/ptc-minimal/gitbash-executor.mjs"
|
|
13
14
|
},
|
|
14
15
|
"files": [
|
|
15
16
|
"lib",
|
|
@@ -17,11 +18,15 @@
|
|
|
17
18
|
"cordis.patch.yml",
|
|
18
19
|
"README.md",
|
|
19
20
|
"README.en.md",
|
|
20
|
-
"LICENSE"
|
|
21
|
+
"LICENSE",
|
|
22
|
+
"ptc-minimal.patch.yml"
|
|
21
23
|
],
|
|
22
24
|
"dsh": {
|
|
23
25
|
"bundle": {
|
|
24
|
-
"patch":
|
|
26
|
+
"patch": [
|
|
27
|
+
"./cordis.patch.yml",
|
|
28
|
+
"./ptc-minimal.patch.yml"
|
|
29
|
+
]
|
|
25
30
|
}
|
|
26
31
|
},
|
|
27
32
|
"keywords": [
|