dsh-deep-ptc-mode 1.7.3 → 1.8.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 CHANGED
@@ -1,5 +1,33 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.8.0 — 2026-11-07
4
+
5
+ - 会话级 preset 身份兼容,两次尝试:不限制预设名称的外部插件拿原生 `deep-ptc`(第一层,直接可用);限制预设名称、列表里没有 `deep-ptc` 的插件拿基座 `ptc`(第二层,对包含 `ptc` 的列表必定通过)。显式支持 `deep-ptc` 的插件也拿原生。宿主内部(子代理 header、定时任务、注册表自身)保持精确 id,不影响继承与调度。
6
+ - 兼容层在插件本体内实现(`lib/preset-compat.mjs`),随插件启动安装:不需要改 DSH,也不需要给外部插件写逐插件配置。判定先看调用方插件是否限制预设名称:不限制就返回原生,限制就立即返回基座。宿主没有拒绝回调,因此两次尝试在返回前按调用方决定,不做运行时重试。
7
+ - 普通 PTC 与其他预设原样返回;官方 PTC 预设没有被替换。新增设置:`presetCompat`(默认开)、`presetFallback`(默认 `ptc`)、`presetSupport`(按包名覆盖 `native` / `base`)。
8
+ - 修复调用方识别:跳过 Cordis 服务代理插入的 `Object.apply` 帧,否则真实插件会被当成宿主、dsh-ops 门控被误关。
9
+ - 创造模式/插件实验台安全:加载只读 `agentPresets.list/readDocument`,不调用 `composedPreset`(测试保证);实验台挂入深 PTC 会话的创造模式行若只认 `cordis`,第二层返回 `cordis`,认 `ptc` 的仍返回 `ptc`;普通创造模式会话(`cordis`)原样不变。
10
+
11
+ - Session-scoped preset identity compatibility as two attempts: an external plugin that does not limit preset names receives the native `deep-ptc` (layer 1, usable as-is); a plugin that limits preset names and does not list `deep-ptc` receives the base `ptc` (layer 2, guaranteed for an allowlist that includes `ptc`). A plugin that explicitly supports `deep-ptc` also receives the native id. Host internals (subagent child headers, scheduled session creation, the registry itself) keep the exact id, so inheritance and scheduling are unaffected.
12
+ - Implemented inside the plugin (`lib/preset-compat.mjs`) and installed at plugin startup: no DSH change and no per-plugin configuration. The decision first checks whether the calling plugin limits preset names: no limit keeps the native id; a limit falls back immediately. The host offers no rejection callback, so both attempts are decided per caller before returning, with no runtime retry.
13
+ - Normal PTC and other presets are returned unchanged; the official PTC preset is not replaced. New settings: `presetCompat` (on by default), `presetFallback` (default `ptc`), `presetSupport` (per-package `native` / `base` override).
14
+ - Caller detection now skips the `Object.apply` frame inserted by the Cordis service proxy; before this, a real plugin looked like the host and dsh-ops stayed inert.
15
+ - Creative mode and the plugin lab stay safe: loading reads `agentPresets.list/readDocument` only and never calls `composedPreset` (covered by a test). A creative row mounted into a Deep PTC session that accepts only `cordis` receives `cordis`; one that accepts `ptc` still receives `ptc`. A normal creative session (preset `cordis`) is unchanged.
16
+
17
+ ## 1.7.4 — 2026-11-07
18
+
19
+ - 支持当前桌面端 DSH RC `>=0.2.2-rc.1`。只声明支持 RC,不支持 alpha。
20
+ - PowerShell、Bash、Zsh 可以选择本机已发现的可执行文件。未选择或文件消失时仍走官方自动查找。WSL 仍只选择发行版。PowerShell 写入官方执行器的 `pwshPath`;Bash 和 Zsh 只替换启动参数,沙箱与批准仍用官方执行器。
21
+ - 新增插件实验台,默认关闭。打开后按读取 PTC 的同一方式,动态读取宿主正在发布的官方创造模式,只追加相对 PTC 多出来的行,模块名以该预设原文为准。实验在内存中检查、定义并经宿主批准后运行,不写仓库、已发布预设、桌面组合或本插件源码。预设读不到时继续使用官方 PTC 工具。
22
+ - 适配 dsh-go 的屏幕控制:这类工具留在初始 SDK,失败不隔离。识别依据是工具自己的常驻标记、`dsh-go/view`、屏幕控制工具名,或提供者标记,不把 dsh-go 写成依赖,也不占用它的槽位和设置表单。其他外部工具仍是能力优先、官方兜底,普通扩展按需加载。
23
+ - 工具状态按钮在界面投影失败时留空,输入区和屏幕控制界面保持原位。
24
+
25
+ - Declare support for the installed desktop DSH release candidate, `>=0.2.2-rc.1`. Alpha builds are not supported.
26
+ - PowerShell, Bash and Zsh can use a discovered executable. An empty or missing choice keeps the official lookup. WSL still selects a distribution only. PowerShell writes the official `pwshPath`; Bash and Zsh change argv only, and sandbox plus approval stay on the official executor.
27
+ - Add plugin lab, off by default. When on, load the official creative mode the same way PTC is loaded and append only the extra rows, using the module names in that document. Lab packages stay in memory: inspect, define, then run through host approval. They do not write the repository, shipped presets, the desktop composition, or this plugin. If that preset cannot be read, official PTC tools remain.
28
+ - Adapt dsh-go screen control: those tools stay in the initial SDK and are not quarantined. Recognition uses the tool's own resident flag, `dsh-go/view`, screen-control names, or the provider mark. dsh-go is not a dependency, and its slots and settings forms stay its own. Other external tools stay capability-first, with official tools as the fallback. Ordinary extensions stay on demand.
29
+ - The tool-state control renders nothing when the composer projection fails, leaving the input row and the screen-control chrome in place.
30
+
3
31
  ## 1.7.3 — 2026-11-05
4
32
 
5
33
  - 优先读取运行宿主的官方预设注册表并自动检测更新;修复官方工具误隔离、暂停误判和桌面重载按钮的依赖/返回值处理。保留后台运行与插话。
package/LICENSE CHANGED
File without changes
package/README.md CHANGED
@@ -1,12 +1,14 @@
1
1
  # Deep PTC mode
2
2
 
3
- [中文](README.zh.md) · MIT · **1.7.3**
3
+ [中文](README.zh.md) · MIT · **1.8.0**
4
4
 
5
5
  [1.7.3 实测汇总 / Test summary](TEST_REPORT.md)
6
6
  **Let plugins cooperate. Keep current official PTC tools as the fallback. Stay interruptible while work runs.**
7
7
 
8
8
  Deep PTC is a DeepSeek Harness agent preset built for a plugin ecosystem. It first looks for a suitable tool among the available external plugins, then continues with the running host’s dynamically discovered official PTC capability when no enhancement fits or a provider fails. Multiple plugins can contribute different parts of a task, each using its own schemas, discovery and result contracts. Deep PTC adds no task tools of its own.
9
9
 
10
+ Deep PTC 1.8.0 adds **session-scoped preset identity**: an external plugin that does not restrict preset names sees the native `deep-ptc`, a plugin that restricts them gets the base `ptc` (or `cordis` for a creative-mode row mounted by the plugin lab), and host internals keep the exact id. Normal PTC and creative sessions are untouched.
11
+
10
12
  The same working rules remain: use the model's capability thoroughly, move long commands into managed background jobs, respond to your messages while work runs, plan by task size, clarify intent, and execute in your selected WSL / PowerShell / Zsh / Bash environment.
11
13
 
12
14
  ## A mode for “everything is a plugin”
@@ -22,7 +24,7 @@ Compatibility has two directions: follow the installed official PTC composition
22
24
 
23
25
  An extension must publish into the `deep-ptc` scope and support the installed host. Keep official fallbacks visible in the provider's own configuration where supported. This is cooperative task-level selection, not a guarantee that every plugin or replacement executor is interchangeable. OPS is one possible provider, not a bundled dependency or a completed integration claim.
24
26
 
25
- The official fallback retains the 1.6.1 derivation mechanism: the plugin reads the running host’s PTC declaration and checks for changes every five seconds; only changed declarations or this plugin’s settings rebuild the preset and follows its module names and configuration. The bundled snapshot is used only if loading, parsing or derivation fails, with a warning. Reload after an official upgrade and use a new preset revision; existing sessions are not forcibly switched. DSH support starts at `>=0.2.2-rc.1` with no upper bound; future host APIs still require verification.
27
+ The official fallback retains the 1.6.1 derivation mechanism: the plugin reads the running host’s PTC declaration and checks for changes every five seconds; only changed declarations or this plugin’s settings rebuild the preset and follows its module names and configuration. The bundled snapshot is used only if loading, parsing or derivation fails, with a warning. Reload after an official upgrade and use a new preset revision; existing sessions are not forcibly switched. DSH support starts at the installed desktop release candidate, `>=0.2.2-rc.1`. Only RC builds are supported; alpha builds are not. There is no upper bound on later release candidates, and a newer RC still needs a host-interface check.
26
28
 
27
29
  ## 1.7.2: lightweight, on-demand tool orchestration
28
30
 
@@ -105,6 +107,41 @@ WSL source uses Linux/POSIX syntax, while file tools and `workdir` use Windows h
105
107
 
106
108
  Native PowerShell, Bash and Zsh use Harness sandbox, approval and process management. WSL currently supports only execution already authorized as `danger-full-access`. Confined Windows policies are refused before execution, without fallback or permission changes. The plugin does not authorize escalation.
107
109
 
110
+ PowerShell, Bash and Zsh can use a common executable discovered on this machine. Leaving it empty keeps the official lookup. WSL still selects a distribution only. A missing file logs a warning and falls back to automatic. PowerShell writes the official executor's `pwshPath`. Bash and Zsh change only the startup argv.
111
+
112
+ ## Plugin lab: official creative mode, in memory
113
+
114
+ Deep PTC is often used for programming, and it can also be used to design a DSH plugin. **Plugin lab** (设置里的「插件实验台」) is off by default. Turn it on under **Settings → Plugins → Deep PTC**, then start a new session. `pluginLab: true` in the Cordis settings is the same switch.
115
+
116
+ When the lab is on, Deep PTC loads the official **creative mode** (创造模式) the same way it loads PTC: from the preset the running host publishes (`agentPresets.readDocument`, preferring the preset named 创造模式, otherwise the shipped id `cordis`). It appends only the rows that creative mode adds beyond the current PTC composition. Module names stay exactly as that document declares them, so an official rename follows the host instead of a name baked into this plugin. Skill directories that the creative preset expresses relative to its own file are resolved against that preset's directory. The desktop already mounts the host runner, so those rows are left to the host and are not copied a second time.
117
+
118
+ The lab is an environment for designing and trying a plugin in this process: inspect the live composition, define a syntax-checked package, then run it only through the host's existing approval. Packages stay in memory for this process. They do not write the repository, shipped presets, the desktop composition, or this plugin's source. Host approval stays as the host defined it. If the creative preset cannot be read, or a lab tool is missing or fails, the session continues with the official PTC tools.
119
+
120
+ ## dsh-go and other external tools
121
+
122
+ External plugins are discovered from what they actually register. Tools and workflows are chosen by capability first. Official PTC tools stay available and are the fallback when a third-party tool fails. No external plugin, including dsh-go, is a dependency of this package.
123
+
124
+ **dsh-go** (the phone app and its screen-control surface) stays usable inside a Deep PTC session:
125
+
126
+ - Screen-control tools remain in the initial PTC SDK. They are not folded into the on-demand catalog and they are not quarantined after a failure. A tool qualifies when it sets `resident` (or `deepPtc.resident`), when its presentation carries the `dsh-go/view` key, when its name is `intent`, `collect`, `tap_xy`, or starts with `screen_`, or when its provider is marked as dsh-go, screen control, computer use, or phone control. Any other plugin can use the same `resident` flag. Ordinary extensions stay on demand.
127
+ - Deep PTC does not declare dsh-go's own slots and does not replace its settings. Those forms still come from the Cordis schema, so the app renders them itself.
128
+ - The tool-state control under the composer reads its own state first. If the projection is missing, belongs to another preset, or throws, that control renders nothing. A failure there leaves the input row and the screen-control chrome in place.
129
+
130
+ Phone screen control was not clicked on a device for this release. The guarantee above is the SDK membership, the quarantine rule, and the composer failure path.
131
+
132
+ ## 1.8.0: session-scoped preset identity
133
+
134
+ External plugins often treat an agent-preset id as a capability switch (dsh-ops recognises only minimal/standard/ptc/cordis). Deep PTC registers `deep-ptc`. 1.8.0 makes two attempts inside the plugin:
135
+
136
+ - **Layer 1 (native)**: an external plugin that does not limit preset names receives `deep-ptc` and works as-is; a plugin that explicitly declares support for `deep-ptc` also receives the native id.
137
+ - **Layer 2 (base)**: a plugin that limits preset names and does not list `deep-ptc` receives `ptc`. For an allowlist that includes `ptc` (dsh-ops), this layer is guaranteed; if the list does not contain `ptc` either, neither attempt matches (such a plugin does not support PTC at all).
138
+ - Host calls that must stay exact (subagent child headers, scheduled session creation, the registry itself) always receive `deep-ptc`, so inheritance and scheduling are unaffected.
139
+ - A normal PTC session already returns `ptc`; every other preset is returned unchanged. The official PTC preset is not replaced, and DSH is not modified.
140
+ - Creative mode and the plugin lab: loading reads the host roster and documents only, never `composedPreset`. A creative row mounted into a Deep PTC session that accepts only `cordis` gets `cordis`; a normal creative session is unchanged.
141
+ - Both attempts are decided before returning: the host provides no rejection callback, so the layer inspects the calling plugin's own package to see whether it limits preset names. No limit keeps the native id; a limit falls back immediately. Settings: `presetCompat`, `presetFallback`, `presetSupport`.
142
+
143
+ Limitation: this wraps the host's `agentPresets.composedPreset` instance and depends on its internal signature, so re-check after a DSH upgrade. The per-package probe is heuristic; dynamically assembled ids may not be recognised.
144
+
108
145
  ## Working contract
109
146
 
110
147
  - Spend the budget on the work: the persona states that the model works at DeepSeek with an unlimited token budget in this mode, so it does not skip reads, searches, commands or checks to save tokens. Guardrails forbid padding, and compaction, pruning and subagents keep each request inside its finite context window.
@@ -118,13 +155,13 @@ A prompt changes the model's working tendency, not the real token limit or billi
118
155
 
119
156
  ## Install or upgrade
120
157
 
121
- Requires Node `>=24` and DSH `>=0.2.2-rc.1`. 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.
158
+ Requires Node `>=24` and DSH RC `>=0.2.2-rc.1` (the installed desktop). Alpha builds are not supported. 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.
122
159
 
123
160
  ```js
124
- plugin_manager({ action: "install_bundle", target: "dsh-deep-ptc-mode@1.7.3" })
161
+ plugin_manager({ action: "install_bundle", target: "dsh-deep-ptc-mode@1.8.0" })
125
162
  // Or from a local checkout or archive:
126
163
  plugin_manager({ action: "install_bundle", target: "C:\\path\\to\\dsh-deep-ptc-mode" })
127
- // Or target: "C:\\path\\to\\dsh-deep-ptc-mode-1.7.3.tgz"
164
+ // Or target: "C:\\path\\to\\dsh-deep-ptc-mode-1.8.0.tgz"
128
165
  ```
129
166
 
130
167
  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.
@@ -138,6 +175,8 @@ Settings persist through the active profile's Cordis patch:
138
175
  config:
139
176
  environment: auto # auto | wsl | powershell | zsh | bash
140
177
  wslDistribution: '' # blank uses the Windows default
178
+ shellExecutable: '' # blank keeps the official lookup
179
+ pluginLab: false # true loads the host's creative-mode rows
141
180
  ```
142
181
 
143
182
  Prefer the UI, which uses revisioned, atomic Host form writes.
package/README.zh.md CHANGED
@@ -1,12 +1,14 @@
1
1
  # 深度 PTC 模式
2
2
 
3
- [English](README.md) · MIT · 当前版本:**1.7.3**
3
+ [English](README.md) · MIT · 当前版本:**1.8.0**
4
4
 
5
5
  [1.7.3 实测汇总 / Test summary](TEST_REPORT.md)
6
6
  **让插件协作,让当前官方 PTC 工具兜底,让任务始终可沟通。**
7
7
 
8
8
  深度 PTC 是面向插件生态的 DeepSeek Harness Agent 模式(preset):优先在当前可用的外部插件中寻找同功能工具,没有合适能力或插件工具故障时,再用当前官方 PTC 的工具继续完成任务。多个插件可以分工完成同一个任务,各自保留原有参数、发现方式和结果契约;深度 PTC 本身不提供新的任务工具。
9
9
 
10
+ 1.8.0 增加**会话级预设身份兼容**:不限制预设名称的外部插件看到原生 `deep-ptc`,限制预设名称的插件拿到基座 `ptc`(实验台挂入的创造模式行可拿到 `cordis`),宿主内部保持精确 id。普通 PTC 会话与创造模式会话不受影响。
11
+
10
12
  原有的工作特点完整保留:把模型能力用满,长命令交给后台 job,运行中随时回应你的插话,按任务大小规划,意图不清先问,并在你选择的 WSL / PowerShell / Zsh / Bash 环境执行。
11
13
 
12
14
  ## 为「一切皆插件」的协作方式而设计
@@ -22,7 +24,7 @@
22
24
 
23
25
  外部插件需支持当前宿主,并在 `deep-ptc` 的作用域中发布工具;支持保留官方工具的插件,应在自身配置中保留兜底能力。这是任务级的合作选择机制,不代表所有插件或整个替换执行器都能直接互换。OPS 可以作为其中一个提供者,不是内置依赖,也不表示已经完成 OPS 的实际联调。
24
26
 
25
- 官方兜底沿用 1.6.1 的动态派生机制:自动读取实际运行宿主的官方 PTC 声明;每 5 秒检测声明变化,仅在声明或本插件配置变化时重建预设,工具模块和配置跟随该声明;仅在声明无法读取、解析或派生时使用随包快照并记录日志。官方升级后需重载并创建使用新版预设的会话,既有会话不被强制切换。最低支持 DSH `>=0.2.2-rc.1`,不设上限;更高版本仍需验证宿主接口。
27
+ 官方兜底沿用 1.6.1 的动态派生机制:自动读取实际运行宿主的官方 PTC 声明;每 5 秒检测声明变化,仅在声明或本插件配置变化时重建预设,工具模块和配置跟随该声明;仅在声明无法读取、解析或派生时使用随包快照并记录日志。官方升级后需重载并创建使用新版预设的会话,既有会话不被强制切换。最低支持当前桌面端 DSH RC `>=0.2.2-rc.1`。只支持 RC,不支持 alpha。不设 RC 上限;更高的 RC 仍需验证宿主接口。
26
28
 
27
29
  ## 1.7.2:轻量、按需、可恢复的工具调用层
28
30
 
@@ -105,6 +107,41 @@ WSL 命令使用 Linux/POSIX 语法;文件工具和 `workdir` 仍用 Windows
105
107
 
106
108
  原生 PowerShell、Bash 和 Zsh 继续使用 Harness 的沙箱、审批和进程管理。WSL 跨越 Windows/Linux 边界,目前仅支持宿主已经授权的 `danger-full-access` 执行;`read-only` 或 `workspace-write` 调用在启动命令前失败。插件不会自行升权、改变默认权限或悄悄换 shell。
107
109
 
110
+ 选择 PowerShell、Bash 或 Zsh 时,可以指定本机已经发现的常见可执行文件。留空则沿用官方查找顺序。WSL 仍只选择发行版。所选文件不存在时记一条警告并回到自动。PowerShell 的选择写入官方执行器的 `pwshPath`。Bash 和 Zsh 只改启动参数。
111
+
112
+ ## 插件实验台:官方创造模式,只在内存里试
113
+
114
+ 深度 PTC 经常用来编程,也可以用来设计和试写 DSH 插件。**插件实验台**默认关闭。在 **设置 → 插件 → 深度 PTC** 里勾选,然后新建会话。Cordis 配置里的 `pluginLab: true` 是同一个开关。
115
+
116
+ 打开后,深度 PTC 用和官方 PTC 相同的方式读取宿主正在发布的**创造模式**:走 `agentPresets.readDocument`,优先名称正好是「创造模式」的预设,否则用已随宿主发布的 id `cordis`。只追加创造模式相对当前 PTC 多出来的那些行。模块名保持该预设原文,官方以后改名时跟着宿主走,不把包名写死在本插件里。创造模式技能目录如果写成相对它自己文件的位置,就按那个预设所在目录解析。桌面端已经挂了宿主运行器,这些行留给宿主,不在深度 PTC 里再挂一份。
117
+
118
+ 实验台用来在当前进程里设计和试运行插件:检查当前组合,定义一个通过语法检查的包,再经宿主原有的批准后运行。包只留在本进程内存里,不写入仓库、已发布预设、桌面端组合或本插件源码。宿主的批准保持原样。创造模式预设读不到,或实验工具缺失、失败时,会话继续使用官方 PTC 工具。
119
+
120
+ ## dsh-go 与其他外部工具
121
+
122
+ 外部插件按它们实际注册出来的工具和工作流接入。先按能力选用,第三方工具失败时官方 PTC 工具仍在,并作为兜底。本包不把任何外部插件(包括 dsh-go)写成依赖。
123
+
124
+ **dsh-go**(手机端,以及手机屏幕控制)在深度 PTC 会话里保持可用:
125
+
126
+ - 屏幕控制工具留在初始 PTC SDK 里,不收进按需目录,失败后也不隔离。满足下面任一条件即可:工具自己标了 `resident`(或 `deepPtc.resident`);展示信息带有 `dsh-go/view`;名称是 `intent`、`collect`、`tap_xy`,或以 `screen_` 开头;提供者标记为 dsh-go、屏幕控制、computer use 或手机控制。其他插件也可以用同一个 `resident` 标记把自己留在初始列表。普通扩展仍按需加载。
127
+ - 深度 PTC 不声明 dsh-go 自己的槽位,也不替换它的设置表单。表单仍来自 Cordis schema,由应用自己渲染。
128
+ - 输入框下方的工具状态控件先读自己的状态。投影缺失、不属于本预设或抛错时,这块控件留空。这里失败不会拆掉输入区,也不会拆掉屏幕控制界面。
129
+
130
+ 本版没有在真机上点过手机屏幕控制。上面保证的是 SDK 成员资格、隔离规则,以及界面投影失败时的退让。
131
+
132
+ ## 1.8.0:会话级 preset 身份兼容
133
+
134
+ 外部插件常把 agent preset id 当能力开关(例如 dsh-ops 只认 minimal/standard/ptc/cordis)。深度 PTC 注册的 id 是 `deep-ptc`。1.8.0 在插件内部做两次尝试:
135
+
136
+ - **第一层(原生)**:不限制预设名称的外部插件拿 `deep-ptc`,直接可用;显式声明支持 `deep-ptc` 的插件也拿原生。
137
+ - **第二层(基座)**:限制预设名称、且列表里没有 `deep-ptc` 的插件拿 `ptc`。对 dsh-ops 这类包含 `ptc` 的列表,这一层必定通过;如果列表连 `ptc` 都没有,两层都不匹配(它本来也不支持 PTC)。
138
+ - 宿主内部必须精确的调用(子代理 header、定时任务、注册表自身)始终拿 `deep-ptc`,不影响继承和调度。
139
+ - 普通 PTC 会话本来就返回 `ptc`,其他预设原样返回;官方 PTC 预设没有被替换,也没有改 DSH。
140
+ - 创造模式/插件实验台:加载只读宿主的预设清单和文档,不调用 `composedPreset`;实验台挂进深 PTC 会话的创造模式行若只认 `cordis`,第二层就返回 `cordis`,普通创造模式会话仍原样。
141
+ - 两次尝试都在返回之前决定:宿主不会在插件拒绝时回调,所以读取调用方插件自己的包,判断它是否限制预设名称;不限制就给原生,限制就立即给基座。设置里可用 `presetCompat`、`presetFallback`、`presetSupport` 调整。
142
+
143
+ 局限:这是对 `agentPresets.composedPreset` 的实例包装,依赖宿主内部方法签名;DSH 升级后需要复核。按包内容探测是启发式的,插件如果在代码里用动态拼接的 id,可能识别不到。
144
+
108
145
  ## 工作规则
109
146
 
110
147
  - **不为 token 省力:** 人设写明在深度求索工作、本模式 token 预算无限,按问题需要而不是成本决定读取、搜索、命令和验证的深度;同时禁止注水和啰嗦,单次上下文仍有限,靠压缩、裁剪和子代理控制。
@@ -118,15 +155,15 @@ WSL 命令使用 Linux/POSIX 语法;文件工具和 `workdir` 仍用 Windows
118
155
 
119
156
  ## 安装和升级
120
157
 
121
- 要求 Node `>=24`、DSH `>=0.2.2-rc.1`。1.3.0 已用 Windows 桌面端 rc.5 做 WSL/PowerShell 命令验证。macOS/Zsh 分支做了配置、工具挂载与参数测试,尚未在 macOS 真机执行。
158
+ 要求 Node `>=24`、DSH RC `>=0.2.2-rc.1`(当前桌面端)。不支持 alpha 版本。1.3.0 已用 Windows 桌面端 rc.5 做 WSL/PowerShell 命令验证。macOS/Zsh 分支做了配置、工具挂载与参数测试,尚未在 macOS 真机执行。
122
159
 
123
160
  本地目录或构建产物可通过插件管理器安装:
124
161
 
125
162
  ```js
126
- plugin_manager({ action: "install_bundle", target: "dsh-deep-ptc-mode@1.7.3" })
163
+ plugin_manager({ action: "install_bundle", target: "dsh-deep-ptc-mode@1.8.0" })
127
164
  // 也可从本地目录或安装包安装:
128
165
  plugin_manager({ action: "install_bundle", target: "C:\\path\\to\\dsh-deep-ptc-mode" })
129
- // 或 target: "C:\\path\\to\\dsh-deep-ptc-mode-1.7.3.tgz"
166
+ // 或 target: "C:\\path\\to\\dsh-deep-ptc-mode-1.8.0.tgz"
130
167
  ```
131
168
 
132
169
  GitHub 地址:`github:lishize20040802-rgb/dsh-deep-ptc-mode`。该地址安装远端实际内容;本地升级不会自动发布到 GitHub/npm。
@@ -140,6 +177,8 @@ GitHub 地址:`github:lishize20040802-rgb/dsh-deep-ptc-mode`。该地址安装
140
177
  config:
141
178
  environment: wsl # auto | wsl | powershell | zsh | bash
142
179
  wslDistribution: Ubuntu # 留空为 Windows 默认发行版
180
+ shellExecutable: '' # 留空沿用官方查找
181
+ pluginLab: false # true 时加载宿主创造模式多出来的行
143
182
  ```
144
183
 
145
184
  优先使用界面保存,宿主会处理版本冲突和原子配置写入。
package/TEST_REPORT.md CHANGED
File without changes
package/assets/icon.png CHANGED
File without changes
File without changes
package/cordis.patch.yml CHANGED
File without changes
package/lib/adapt.mjs CHANGED
File without changes
package/lib/ask-user.mjs CHANGED
File without changes
File without changes
package/lib/client.js CHANGED
@@ -10,6 +10,9 @@ window.__ModuleLoader__.load({ id: 'dsh-deep-ptc-mode', factory: require => {
10
10
  wsl: 'WSL Bash(Windows)', powershell: 'PowerShell(Windows)',
11
11
  zsh: 'Zsh(macOS / Linux)', bash: '原生 Bash(macOS / Linux)',
12
12
  distribution: 'WSL 发行版', distributionHint: '留空使用 Windows 的默认发行版,例如 Ubuntu。',
13
+ shell: 'Shell 版本', shellAuto: '自动(沿用官方查找顺序)',
14
+ shellHint: '只列出本机已发现的常见版本。文件消失后自动回退。WSL 仍只选择发行版。',
15
+ pluginLab: '插件实验台', pluginLabHint: '默认关闭。打开后在内存中检查、定义并经宿主批准后运行插件,不改已发布预设,也不绕过批准。',
13
16
  sessions: '保存后请新建一个“深度PTC模式”会话。已有会话与后台任务保留原环境。',
14
17
  wslHint: 'WSL 暂不支持 Windows 的受限沙箱;受限调用会明确失败,不会自动切换或绕过限制。',
15
18
  save: '保存', saving: '保存中…', saved: '已保存,新会话将使用所选环境。',
@@ -22,6 +25,9 @@ window.__ModuleLoader__.load({ id: 'dsh-deep-ptc-mode', factory: require => {
22
25
  wsl: 'WSL Bash (Windows)', powershell: 'PowerShell (Windows)',
23
26
  zsh: 'Zsh (macOS / Linux)', bash: 'Native Bash (macOS / Linux)',
24
27
  distribution: 'WSL distribution', distributionHint: 'Leave blank for the Windows default distribution, for example Ubuntu.',
28
+ shell: 'Shell version', shellAuto: 'Automatic (official lookup)',
29
+ shellHint: 'Lists common executables found on this machine. A missing file falls back to automatic. WSL still selects a distribution only.',
30
+ pluginLab: 'Plugin lab', pluginLabHint: 'Off by default. When on, inspect, define and run plugins in memory through host approval. Shipped presets stay unchanged.',
25
31
  sessions: 'After saving, create a new Deep PTC session. Existing sessions and background jobs keep their environment.',
26
32
  wslHint: 'WSL does not support the confined Windows sandbox. Confined calls fail without execution or fallback.',
27
33
  save: 'Save', saving: 'Saving…', saved: 'Saved. New sessions will use this environment.',
@@ -36,6 +42,8 @@ window.__ModuleLoader__.load({ id: 'dsh-deep-ptc-mode', factory: require => {
36
42
  const state = React.useSyncExternalStore(subscribe, read, read);
37
43
  const [environment, setEnvironment] = React.useState('auto');
38
44
  const [distribution, setDistribution] = React.useState('');
45
+ const [shellExecutable, setShellExecutable] = React.useState('');
46
+ const [pluginLab, setPluginLab] = React.useState(false);
39
47
  const [saving, setSaving] = React.useState(false);
40
48
  const [message, setMessage] = React.useState('');
41
49
  const [failed, setFailed] = React.useState(false);
@@ -45,6 +53,8 @@ window.__ModuleLoader__.load({ id: 'dsh-deep-ptc-mode', factory: require => {
45
53
  if (!state.value || dirty.current) return;
46
54
  setEnvironment(state.value.environment);
47
55
  setDistribution(state.value.wslDistribution ?? '');
56
+ setShellExecutable(state.value.shellExecutable ?? '');
57
+ setPluginLab(state.value.pluginLab === true);
48
58
  draftRevision.current = state.revision;
49
59
  }, [state.value, state.revision]);
50
60
  if (view === 'summary') return t('summary');
@@ -64,6 +74,8 @@ window.__ModuleLoader__.load({ id: 'dsh-deep-ptc-mode', factory: require => {
64
74
  const ok = await form.mutate([
65
75
  { op: 'set', path: ['environment'], value: environment },
66
76
  { op: 'set', path: ['wslDistribution'], value: distribution.trim() },
77
+ { op: 'set', path: ['shellExecutable'], value: shellExecutable },
78
+ { op: 'set', path: ['pluginLab'], value: pluginLab },
67
79
  ], draftRevision.current);
68
80
  if (!ok) throw new Error('Configuration was rejected');
69
81
  dirty.current = false;
@@ -71,12 +83,20 @@ window.__ModuleLoader__.load({ id: 'dsh-deep-ptc-mode', factory: require => {
71
83
  draftRevision.current = latest.revision;
72
84
  setEnvironment(latest.value?.environment ?? environment);
73
85
  setDistribution(latest.value?.wslDistribution ?? distribution.trim());
86
+ setShellExecutable(latest.value?.shellExecutable ?? shellExecutable);
87
+ setPluginLab(latest.value?.pluginLab === true);
74
88
  setMessage(t('saved'));
75
89
  } catch {
76
90
  draftRevision.current = form.getSnapshot().revision;
77
91
  setFailed(true); setMessage(t('failed'));
78
92
  } finally { setSaving(false); }
79
93
  }
94
+ const effective = environment === 'auto'
95
+ ? (state.value.hostPlatform === 'win32' ? 'powershell' : state.value.hostPlatform === 'darwin' ? 'zsh' : 'bash')
96
+ : environment;
97
+ const choices = (Array.isArray(state.value.shellChoices) ? state.value.shellChoices : [])
98
+ .filter(item => item && item.family === effective && typeof item.id === 'string');
99
+ const showShell = effective !== 'wsl' && choices.length > 0;
80
100
  const control = { width: '100%', padding: '8px 10px', borderRadius: '6px',
81
101
  color: 'inherit', background: 'var(--dsw-alias-bg-base)', border: '1px solid var(--dsw-alias-border-l1)' };
82
102
  return h('form', { onSubmit: save, style: { display: 'grid', gap: '12px', maxWidth: '600px' } },
@@ -90,6 +110,18 @@ window.__ModuleLoader__.load({ id: 'dsh-deep-ptc-mode', factory: require => {
90
110
  h('input', { id: 'deep-ptc-distribution', value: distribution, disabled, style: control,
91
111
  onChange: event => { changed(); setDistribution(event.target.value); } }),
92
112
  h('p', null, t('distributionHint')), h('p', null, t('wslHint'))) : null,
113
+ showShell ? h(React.Fragment, null,
114
+ h('label', { htmlFor: 'deep-ptc-shell' }, t('shell')),
115
+ h('select', { id: 'deep-ptc-shell', value: shellExecutable, disabled, style: control,
116
+ onChange: event => { changed(); setShellExecutable(event.target.value); } },
117
+ h('option', { value: '' }, t('shellAuto')),
118
+ ...choices.map(item => h('option', { key: item.id, value: item.id }, item.label))),
119
+ h('p', null, t('shellHint'))) : null,
120
+ h('label', { htmlFor: 'deep-ptc-plugin-lab' },
121
+ h('input', { id: 'deep-ptc-plugin-lab', type: 'checkbox', checked: pluginLab, disabled,
122
+ onChange: event => { changed(); setPluginLab(event.target.checked); } }),
123
+ ' ', t('pluginLab')),
124
+ h('p', null, t('pluginLabHint')),
93
125
  h('p', null, t('sessions')),
94
126
  !state.writable ? h('p', { role: 'status' }, t('readOnly')) : null,
95
127
  message ? h('p', { role: failed ? 'alert' : 'status' }, message) : null,
@@ -98,13 +130,17 @@ window.__ModuleLoader__.load({ id: 'dsh-deep-ptc-mode', factory: require => {
98
130
  }
99
131
 
100
132
  function ToolStateControls({ useProjection, reset, t }) {
101
- const preset = useProjection('agentPreset');
102
- const state = useProjection('deepPtcTools');
103
133
  const [busy, setBusy] = React.useState(false);
104
134
  const [message, setMessage] = React.useState('');
105
135
  const generation = React.useRef(0);
106
136
  React.useEffect(() => { generation.current++; setBusy(false); setMessage(''); return () => { generation.current++; }; }, [reset]);
107
- if (preset !== 'deep-ptc' || !state) return null;
137
+ let preset, state;
138
+ try {
139
+ if (typeof useProjection !== 'function') return null;
140
+ preset = useProjection('agentPreset');
141
+ state = useProjection('deepPtcTools');
142
+ } catch { return null; }
143
+ if (preset !== 'deep-ptc' || !state || typeof state !== 'object') return null;
108
144
  const failed = state?.report?.tools ?? [];
109
145
  async function reload() {
110
146
  const current = generation.current;
@@ -148,10 +184,22 @@ window.__ModuleLoader__.load({ id: 'dsh-deep-ptc-mode', factory: require => {
148
184
  name: 'plugins.item', id: 'deep-ptc', order: 41,
149
185
  label: () => t('title'), locale: 'deep-ptc',
150
186
  }, props => h(Card, { ...props, form, t })))));
151
- ctx.inject?.(['remote', 'remote.commands'], child => child.slots.inject('conversation.composer.dock', () => child.slots.register({
152
- name: 'conversation.composer.dock', id: 'deep-ptc-tool-states', order: 90,
153
- inject: sessionId => ({ reset: () => child.remote.commands.execute(sessionId, '/deep-ptc-reset-tools', []) }),
154
- }, props => h(ToolStateControls, { ...props, t }))));
187
+ try {
188
+ ctx.inject?.(['remote', 'remote.commands'], child => {
189
+ try {
190
+ child.slots.inject('conversation.composer.dock', () => child.slots.register({
191
+ name: 'conversation.composer.dock', id: 'deep-ptc-tool-states', order: 90,
192
+ inject: sessionId => ({
193
+ reset: () => {
194
+ const execute = child.remote?.commands?.execute;
195
+ if (typeof execute !== 'function') return Promise.resolve({ ok: false, error: { message: 'unavailable' } });
196
+ return execute(sessionId, '/deep-ptc-reset-tools', []);
197
+ },
198
+ }),
199
+ }, props => h(ToolStateControls, { ...props, t })));
200
+ } catch { /* a broken dock must not take the composer with it */ }
201
+ });
202
+ } catch { /* the composer stays usable when this slot cannot register */ }
155
203
  }
156
204
  return { apply, inject };
157
205
  } });
@@ -0,0 +1,127 @@
1
+ // Rows the official creative-mode preset adds beyond the preset Deep PTC is
2
+ // derived from. Module names are copied from that declaration. A renamed
3
+ // official package is followed because this file never names one.
4
+ import { join } from 'node:path';
5
+
6
+ /** Shipped preset id, the same kind of lookup key as `ptc`. Not a module name. */
7
+ export const CREATIVE_PRESET_ID = 'cordis';
8
+
9
+ function text(value) {
10
+ return typeof value === 'string' ? value : '';
11
+ }
12
+
13
+ /**
14
+ * Pick the creative preset from a live roster.
15
+ * The published name wins, then the shipped id, then a description that says so.
16
+ * @param {Array<{ id?: string, name?: string, description?: string }>} roster
17
+ */
18
+ export function selectCreativePreset(roster) {
19
+ const rows = Array.isArray(roster) ? roster.filter(row => row && typeof row === 'object') : [];
20
+ return rows.find(row => row.name === '创造模式')
21
+ ?? rows.find(row => row.id === CREATIVE_PRESET_ID)
22
+ ?? rows.find(row => text(row.description).includes('创造'));
23
+ }
24
+
25
+ function isPersona(row) {
26
+ return row?.id === 'persona' || (typeof row?.name === 'string' && row.name.includes('dsh-persona'));
27
+ }
28
+
29
+ function walk(rows, visit) {
30
+ if (!Array.isArray(rows)) return;
31
+ for (const row of rows) {
32
+ if (!row || typeof row !== 'object') continue;
33
+ visit(row);
34
+ if (row.group === true && Array.isArray(row.config)) walk(row.config, visit);
35
+ }
36
+ }
37
+
38
+ function idsOf(rows) {
39
+ const ids = new Set();
40
+ walk(rows, row => { if (typeof row.id === 'string') ids.add(row.id); });
41
+ return ids;
42
+ }
43
+
44
+ function rowById(rows, id) {
45
+ let found;
46
+ walk(rows, row => { if (found === undefined && row.id === id) found = row; });
47
+ return found;
48
+ }
49
+
50
+ function pinDir(entry, root) {
51
+ if (!root || !entry || typeof entry !== 'object' || typeof entry.__jsExpr !== 'string') return entry;
52
+ if (!entry.__jsExpr.includes('baseUrl') || !entry.__jsExpr.includes('skills')) return entry;
53
+ return join(root, 'skills');
54
+ }
55
+
56
+ function pinDirs(dirs, root) {
57
+ return Array.isArray(dirs) ? dirs.map(entry => pinDir(entry, root)) : dirs;
58
+ }
59
+
60
+ function sameDir(left, right) {
61
+ return JSON.stringify(left) === JSON.stringify(right);
62
+ }
63
+
64
+ function withPinnedSkillDirs(row, root) {
65
+ const copy = structuredClone(row);
66
+ const dirs = copy?.config?.customSkillDirs;
67
+ if (Array.isArray(dirs)) copy.config = { ...copy.config, customSkillDirs: pinDirs(dirs, root) };
68
+ return copy;
69
+ }
70
+
71
+ /**
72
+ * Rows to append when the creative preset is enabled.
73
+ * Baseline rows stay as they are: official PTC remains the fallback.
74
+ * @param {object[]} creativePlugins
75
+ * @param {object[]} baselinePlugins
76
+ * @param {{ root?: string }} [options] directory of the creative preset, used to pin skill paths
77
+ */
78
+ export function creativeAdditions(creativePlugins, baselinePlugins, options = {}) {
79
+ const root = typeof options.root === 'string' ? options.root : '';
80
+ const baselineIds = idsOf(baselinePlugins);
81
+ const additions = [];
82
+ const seen = new Set();
83
+
84
+ const uniqueId = preferred => {
85
+ if (!baselineIds.has(preferred) && !seen.has(preferred)) return preferred;
86
+ for (let suffix = 2; ; suffix += 1) {
87
+ const candidate = `${preferred}-${suffix}`;
88
+ if (!baselineIds.has(candidate) && !seen.has(candidate)) return candidate;
89
+ }
90
+ };
91
+
92
+ const push = row => {
93
+ if (!row || seen.has(row.id)) return;
94
+ seen.add(row.id);
95
+ additions.push(row);
96
+ };
97
+
98
+ const consider = row => {
99
+ if (!row || typeof row !== 'object' || isPersona(row)) return;
100
+ if (row.group === true) {
101
+ if (typeof row.id === 'string' && baselineIds.has(row.id)) {
102
+ if (Array.isArray(row.config)) for (const child of row.config) consider(child);
103
+ return;
104
+ }
105
+ push(withPinnedSkillDirs(row, root));
106
+ return;
107
+ }
108
+ if (typeof row.id === 'string' && baselineIds.has(row.id)) {
109
+ const baseline = rowById(baselinePlugins, row.id);
110
+ const creativeDirs = row.config?.customSkillDirs;
111
+ const baselineDirs = baseline?.config?.customSkillDirs ?? [];
112
+ if (!Array.isArray(creativeDirs) || creativeDirs.length === 0) return;
113
+ const pinned = pinDirs(creativeDirs, root);
114
+ const extra = pinned.filter(entry => !baselineDirs.some(existing => sameDir(existing, entry)));
115
+ if (extra.length === 0) return;
116
+ const id = uniqueId(`${row.id}-creative`);
117
+ push({ id, name: row.name, config: { customSkillDirs: extra } });
118
+ return;
119
+ }
120
+ push(withPinnedSkillDirs(row, root));
121
+ };
122
+
123
+ if (Array.isArray(creativePlugins)) {
124
+ for (const row of creativePlugins) consider(row);
125
+ }
126
+ return additions;
127
+ }
@@ -5,10 +5,11 @@ export const inject = ['systemPrompt'];
5
5
  export const Config = z.object({
6
6
  environment: z.union(['wsl', 'powershell', 'zsh', 'bash']).required(),
7
7
  wslDistribution: z.string().default(''),
8
+ shellNote: z.string().default(''),
8
9
  });
9
10
  export function apply(ctx, config) {
10
11
  ctx.systemPrompt.section({
11
12
  name: 'deep-ptc:execution-environment', order: 10190,
12
- text: environmentText(config.environment, config.wslDistribution),
13
+ text: environmentText(config.environment, config.wslDistribution, config.shellNote),
13
14
  });
14
15
  }
package/lib/executor.mjs CHANGED
@@ -5,30 +5,55 @@ import { assertExecutionPolicy, shellArgv } from './model.mjs';
5
5
  export const name = 'deep-ptc-mapped-executor';
6
6
  export const inject = [];
7
7
  export const Config = z.object({
8
- environment: z.union(['wsl', 'zsh']).required(),
8
+ environment: z.union(['wsl', 'zsh', 'bash']).required(),
9
9
  wslDistribution: z.string().default(''),
10
+ shellExecutable: z.string().default(''),
10
11
  // The official bash executor module and its options, as the installed base declaration names them.
11
12
  base: z.string().required(),
12
13
  options: z.any(),
13
14
  });
14
15
 
16
+ function argvOf(environment, spec, distribution, executable) {
17
+ return shellArgv(environment, spec, distribution, process.platform, executable);
18
+ }
19
+
15
20
  // Extend the official bash executor: its process handles, output retention, cancellation, jobs,
16
21
  // sandbox and Config stay official; only the argv that starts the shell changes.
17
- export function mappedExecutor(Base, environment, distribution = '') {
22
+ export function mappedExecutor(Base, environment, distribution = '', executable = '') {
23
+ const explicit = typeof executable === 'string' && executable !== '';
18
24
  return class MappedShellExecutor extends Base {
19
25
  async execute(spec) {
20
26
  assertExecutionPolicy(environment, spec.sandboxPolicy);
21
27
  if (spec.sandboxPolicy.mode !== 'danger-full-access') return super.execute(spec);
22
- const process = await super.executeArgv(spec, shellArgv(environment, spec, distribution));
28
+ const process = await super.executeArgv(spec, argvOf(environment, spec, distribution, executable));
23
29
  return Base.decorateResult(process, result => ({
24
30
  ...result, sandbox: { mode: spec.sandboxPolicy.mode, denied: false },
25
31
  }));
26
32
  }
27
33
 
34
+ // Current sandboxes enter through run/start. Confined calls use confine, so the chosen
35
+ // binary stays inside the official sandbox. Full access keeps the same denial stamp as before.
36
+ async run(spec) {
37
+ if (!explicit || typeof super.run !== 'function') return super.run?.call(this, spec) ?? this.execute(spec);
38
+ assertExecutionPolicy(environment, spec.sandboxPolicy);
39
+ if (spec.sandboxPolicy?.mode !== 'danger-full-access') return super.run(spec);
40
+ if (typeof super.runArgv !== 'function') return this.execute(spec);
41
+ const result = await super.runArgv(spec, argvOf(environment, spec, distribution, executable));
42
+ return { ...result, sandbox: { mode: spec.sandboxPolicy.mode, denied: false } };
43
+ }
44
+
45
+ start(spec) {
46
+ if (!explicit || typeof super.start !== 'function') return super.start?.call(this, spec);
47
+ assertExecutionPolicy(environment, spec.sandboxPolicy);
48
+ if (spec.sandboxPolicy?.mode !== 'danger-full-access') return super.start(spec);
49
+ if (typeof this.startArgv !== 'function') return super.start(spec);
50
+ return this.startArgv(spec, argvOf(environment, spec, distribution, executable));
51
+ }
52
+
28
53
  confine(command, policy, signal) {
29
54
  assertExecutionPolicy(environment, policy);
30
- return this.ctx.sandbox.confine(shellArgv(environment,
31
- { command, workdir: policy.workspaceRoot }, distribution), policy, signal);
55
+ return this.ctx.sandbox.confine(argvOf(environment,
56
+ { command, workdir: policy.workspaceRoot }, distribution, executable), policy, signal);
32
57
  }
33
58
  };
34
59
  }
@@ -37,5 +62,5 @@ export async function apply(ctx, config) {
37
62
  const Base = pluginOf(await importHost(config.base));
38
63
  if (typeof Base !== 'function' || typeof Base.decorateResult !== 'function' || typeof Base.prototype.executeArgv !== 'function')
39
64
  throw new Error(`${config.base} no longer exposes the executor API Deep PTC extends; choose PowerShell or native Bash`);
40
- ctx.plugin(mappedExecutor(Base, config.environment, config.wslDistribution), config.options);
65
+ ctx.plugin(mappedExecutor(Base, config.environment, config.wslDistribution, config.shellExecutable), config.options);
41
66
  }
package/lib/guard.mjs CHANGED
File without changes
package/lib/host.mjs CHANGED
File without changes