dsh-deep-ptc-mode 1.7.4 → 1.8.1
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 +24 -0
- package/LICENSE +0 -0
- package/README.md +57 -29
- package/README.zh.md +57 -29
- package/TEST_REPORT.md +0 -0
- package/assets/icon.png +0 -0
- package/compatibility.json +0 -0
- package/cordis.patch.yml +0 -0
- package/lib/adapt.mjs +0 -0
- package/lib/ask-user.mjs +0 -0
- package/lib/base-snapshot.json +0 -0
- package/lib/client.js +0 -0
- package/lib/creative.mjs +0 -0
- package/lib/environment.mjs +0 -0
- package/lib/executor.mjs +0 -0
- package/lib/guard.mjs +0 -0
- package/lib/host.mjs +0 -0
- package/lib/index.mjs +17 -0
- package/lib/jobs-tool.mjs +0 -0
- package/lib/lab.mjs +0 -0
- package/lib/lifecycle.mjs +0 -0
- package/lib/model.mjs +0 -0
- package/lib/official-names.mjs +0 -0
- package/lib/preset-compat.mjs +283 -0
- package/lib/preset.json +0 -0
- package/lib/reachable.mjs +0 -0
- package/lib/resident.mjs +0 -0
- package/lib/rules.mjs +0 -0
- package/lib/shells.mjs +0 -0
- package/lib/sleep-lint.mjs +0 -0
- package/lib/terminal.mjs +0 -0
- package/lib/tool-catalog.mjs +0 -0
- package/lib/tool-compatibility.mjs +0 -0
- package/lib/tool-policy.mjs +0 -0
- package/lib/upstream.mjs +0 -0
- package/package.json +6 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,29 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 1.8.1 — 2026-11-07
|
|
4
|
+
|
|
5
|
+
- 重写简介与 README:以“五个基本问题”为主线,再梳理“一切皆插件”的六项能力(动态预设/工具读取、创造模式、dsh-go 界面控制、多环境、外部插件工具/工作流适配、Skill 与工具读取)。
|
|
6
|
+
- 更新 npm 描述与 GitHub About;不承诺适配所有第三方插件,dsh-ops 为已专门测试的场景,其他插件走同一接口。
|
|
7
|
+
- 仅简介与文档变更,不改变运行时行为。
|
|
8
|
+
|
|
9
|
+
- Rewrite the introduction and README around the five basic problems, followed by the six “everything is a plugin” capabilities (dynamic preset/tool loading, creative mode, dsh-go screen control, multi-shell support, external tool/workflow adaptation, and leaner skill/tool loading).
|
|
10
|
+
- Update the npm description and GitHub About. No promise to fit every third-party plugin: dsh-ops is the specifically tested case and other plugins use the same interface.
|
|
11
|
+
- Documentation and description only; no runtime behavior change.
|
|
12
|
+
|
|
13
|
+
## 1.8.0 — 2026-11-07
|
|
14
|
+
|
|
15
|
+
- 会话级 preset 身份兼容,两次尝试:不限制预设名称的外部插件拿原生 `deep-ptc`(第一层,直接可用);限制预设名称、列表里没有 `deep-ptc` 的插件拿基座 `ptc`(第二层,对包含 `ptc` 的列表必定通过)。显式支持 `deep-ptc` 的插件也拿原生。宿主内部(子代理 header、定时任务、注册表自身)保持精确 id,不影响继承与调度。
|
|
16
|
+
- 兼容层在插件本体内实现(`lib/preset-compat.mjs`),随插件启动安装:不需要改 DSH,也不需要给外部插件写逐插件配置。判定先看调用方插件是否限制预设名称:不限制就返回原生,限制就立即返回基座。宿主没有拒绝回调,因此两次尝试在返回前按调用方决定,不做运行时重试。
|
|
17
|
+
- 普通 PTC 与其他预设原样返回;官方 PTC 预设没有被替换。新增设置:`presetCompat`(默认开)、`presetFallback`(默认 `ptc`)、`presetSupport`(按包名覆盖 `native` / `base`)。
|
|
18
|
+
- 修复调用方识别:跳过 Cordis 服务代理插入的 `Object.apply` 帧,否则真实插件会被当成宿主、dsh-ops 门控被误关。
|
|
19
|
+
- 创造模式/插件实验台安全:加载只读 `agentPresets.list/readDocument`,不调用 `composedPreset`(测试保证);实验台挂入深 PTC 会话的创造模式行若只认 `cordis`,第二层返回 `cordis`,认 `ptc` 的仍返回 `ptc`;普通创造模式会话(`cordis`)原样不变。
|
|
20
|
+
|
|
21
|
+
- 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.
|
|
22
|
+
- 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.
|
|
23
|
+
- 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).
|
|
24
|
+
- 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.
|
|
25
|
+
- 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.
|
|
26
|
+
|
|
3
27
|
## 1.7.4 — 2026-11-07
|
|
4
28
|
|
|
5
29
|
- 支持当前桌面端 DSH RC `>=0.2.2-rc.1`。只声明支持 RC,不支持 alpha。
|
package/LICENSE
CHANGED
|
File without changes
|
package/README.md
CHANGED
|
@@ -1,28 +1,56 @@
|
|
|
1
1
|
# Deep PTC mode
|
|
2
2
|
|
|
3
|
-
[中文](README.zh.md) · MIT · **1.
|
|
3
|
+
[中文](README.zh.md) · MIT · **1.8.1**
|
|
4
4
|
|
|
5
5
|
[1.7.3 实测汇总 / Test summary](TEST_REPORT.md)
|
|
6
|
-
**
|
|
6
|
+
**Reports. Asks. Stays awake. Plans. Stays reachable.**
|
|
7
|
+
**Five basics, one mode; everything is a plugin, with the official preset always as the fallback.**
|
|
7
8
|
|
|
8
|
-
Deep PTC is
|
|
9
|
+
Deep PTC is not another tool bundle. It is a DeepSeek Harness agent preset built around five basic problems in model work: working silently without reporting, guessing instead of asking when intent is ambiguous, sleeping and becoming unreachable during a task, not planning or not showing the plan, and not using the original PTC preset's concise context plus its unlimited-token prompt.
|
|
9
10
|
|
|
10
|
-
|
|
11
|
+
Those five are handled first by prompts and code. On top of that, following DSH's “everything is a plugin” philosophy, the preset adds dynamic preset/tool loading, creative-mode tools for building DSH plugins, dsh-go screen-control adaptation, wider shell support, external plugin tool/workflow adaptation, and a leaner skill/tool loading flow. Deep PTC adds no task tools itself; it provides the interface that lets a plugin's new tools be discovered, loaded and called.
|
|
11
12
|
|
|
12
|
-
|
|
13
|
+
Not every third-party plugin is guaranteed to fit: the interface is verified for dsh-ops and reused by other plugins, but a plugin still has to support the installed host and publish its tools under the expected contract.
|
|
13
14
|
|
|
14
|
-
|
|
15
|
+
## Five basic problems
|
|
15
16
|
|
|
16
|
-
|
|
|
17
|
-
| --- | --- |
|
|
18
|
-
|
|
|
19
|
-
|
|
|
20
|
-
|
|
|
21
|
-
|
|
|
17
|
+
| # | Problem | What Deep PTC does |
|
|
18
|
+
| --- | --- | --- |
|
|
19
|
+
| 1 | **Working silently without reporting** | One sentence before every `run_code`; a longer update at milestones; never more than two or three silent tool calls; a short final result with failed tools and providers. |
|
|
20
|
+
| 2 | **Guessing instead of asking** | Meaning belongs to the user, facts to the tools: ask one to three questions with options when names, targets, routes, scope or acceptance criteria are unclear; look up inspectable facts yourself. The user's answer wins. |
|
|
21
|
+
| 3 | **Sleeping or becoming unreachable** | Enforced in code: foreground waits move to the background after 30 s; a user message hands the waiting command to the background within about 2 s; foreground sleeps over 5 s are refused; job completion wakes the model. |
|
|
22
|
+
| 4 | **No plan, or an invisible plan** | Plan by estimated size: act silently under 5 minutes; show the plan and start without approval for 5–20 minutes; show it and wait for approval over 20 minutes. Re-plan when the estimate moves up; the user can redirect at any step. |
|
|
23
|
+
| 5 | **Not using the concise context and unlimited-token prompt** | Derive from the live official PTC composition, keep the tool catalog compact and load full schemas on demand, and state that this mode spends its token budget on reads, searches, commands and checks rather than rationing them. The prompt does not change billing or the real token limit. |
|
|
24
|
+
|
|
25
|
+
## Built for “everything is a plugin”
|
|
26
|
+
|
|
27
|
+
### 1. Dynamic preset and tool loading
|
|
28
|
+
|
|
29
|
+
Read the running host's official PTC declaration and inherit its rows as they are; only the persona, execution group, reachability guard, job wrapper and question wrapper are replaced. Rebuild only when the declaration or settings change (checked every five seconds); fall back to the bundled snapshot with a warning if it cannot be loaded, parsed or derived. An official upgrade can add tools without a release of this preset; existing sessions are not forcibly switched.
|
|
30
|
+
|
|
31
|
+
### 2. Flexible creative-mode tools
|
|
32
|
+
|
|
33
|
+
The plugin lab is off by default. When enabled, it reads the host's creative preset and appends only the rows that mode adds, specifically for building DSH plugins. Module names stay as declared; skill directories resolve relative to the creative preset file. Lab packages stay in process memory, are not written to the repository, shipped presets, desktop composition or this plugin's source, and run only through the host's existing approval. Loading reads the roster and documents only; it never calls `composedPreset`.
|
|
34
|
+
|
|
35
|
+
### 3. dsh-go screen-control adaptation
|
|
36
|
+
|
|
37
|
+
Screen-control tools stay in the initial PTC SDK, are not moved on demand, and are not quarantined on failure. Recognition uses the tool's own `resident` mark, `dsh-go/view`, its name or its provider mark. Deep PTC does not claim dsh-go's slots or replace its settings form; if the tool-state projection fails, that control stays empty without tearing down the composer or screen-control UI.
|
|
38
|
+
|
|
39
|
+
### 4. Wider execution environments
|
|
40
|
+
|
|
41
|
+
WSL Bash, PowerShell (including discovered 5.1 and 7 executables), Zsh and native Bash are supported. The choice applies to this preset only and does not change the global shell; sandbox, approval and process management stay official. WSL currently requires the host-authorized `danger-full-access` mode.
|
|
22
42
|
|
|
23
|
-
|
|
43
|
+
### 5. External plugin tool/workflow adaptation (dsh-ops tested)
|
|
24
44
|
|
|
25
|
-
|
|
45
|
+
This is the core interface: external plugins publish tools under their own contract; Deep PTC discovers them, loads them on demand, quarantines failures per conversation and falls back to official PTC. Extensions must support the installed host and publish into the `deep-ptc` scope; Deep PTC does not depend on any specific plugin or replace the executor.
|
|
46
|
+
|
|
47
|
+
**dsh-ops is specifically tested.** Its gate recognises only `minimal/standard/ptc/cordis`. Deep PTC first offers the native `deep-ptc`; when it detects that the plugin restricts preset names, it returns the base id the plugin accepts — `ptc` (or `cordis` for a creative row) — while host internals keep the exact `deep-ptc`. dsh-ops therefore needs no change for its new tools to be discovered and called; other plugins use the same interface, judged by their own packages. Unattributed tools are not quarantined; only a positively attributed external provider can be, and official tools are never quarantined.
|
|
48
|
+
|
|
49
|
+
### 6. Leaner skill and tool loading
|
|
50
|
+
|
|
51
|
+
Search summaries first, then load full schemas: six entries per page by default (maximum eight), up to six schemas within a 16 KB budget per load, and up to twelve recent selections. Quarantine persists with the conversation: clear unavailability blocks immediately; temporary failures need three in a row and a success clears the count; wrong arguments, denial and normal business failures are not tool failures; one reset clears only the current conversation. Skills load in two stages: discovery reads metadata and invocation permission only; the official `skill` tool loads the body.
|
|
52
|
+
|
|
53
|
+
Three steps: install the plugin → choose an environment under **Settings → Plugins → Deep PTC** → choose **深度PTC模式** in the mode picker for a new task.
|
|
26
54
|
|
|
27
55
|
## 1.7.2: lightweight, on-demand tool orchestration
|
|
28
56
|
|
|
@@ -47,20 +75,7 @@ Set `compactToolCatalog: false` under `deep-ptc-settings` to retain the full hos
|
|
|
47
75
|
|
|
48
76
|
Compaction only changes an untouched SDK section generated by the installed official renderer. Provider-owned/custom SDKs keep their own loaders. Extensions must support the host and publish into `deep-ptc`; this layer does not override hidden tools, authorization or an unloaded whole executor. Actual OPS/online-model end-to-end integration has not been performed.
|
|
49
77
|
|
|
50
|
-
## Overview
|
|
51
|
-
|
|
52
|
-
Deep PTC targets six common problems in everyday agent work:
|
|
53
78
|
|
|
54
|
-
| Problem | What Deep PTC does |
|
|
55
|
-
| --- | --- |
|
|
56
|
-
| Enhanced tools and presets do not naturally cooperate | Search external plugin capabilities first, combine suitable providers, and recover through the dynamically inherited official PTC baseline |
|
|
57
|
-
| 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 |
|
|
58
|
-
| 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) |
|
|
59
|
-
| 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 |
|
|
60
|
-
| 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 |
|
|
61
|
-
| 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 |
|
|
62
|
-
|
|
63
|
-
Three steps: install the plugin → pick an environment under **Settings → Plugins → Deep PTC** → choose **深度PTC模式** in the mode picker for a new task.
|
|
64
79
|
|
|
65
80
|
## Enforced reachability: no sleeping, always interruptible
|
|
66
81
|
|
|
@@ -127,6 +142,19 @@ External plugins are discovered from what they actually register. Tools and work
|
|
|
127
142
|
|
|
128
143
|
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.
|
|
129
144
|
|
|
145
|
+
## 1.8.0: session-scoped preset identity
|
|
146
|
+
|
|
147
|
+
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:
|
|
148
|
+
|
|
149
|
+
- **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.
|
|
150
|
+
- **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).
|
|
151
|
+
- 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.
|
|
152
|
+
- 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.
|
|
153
|
+
- 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.
|
|
154
|
+
- 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`.
|
|
155
|
+
|
|
156
|
+
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.
|
|
157
|
+
|
|
130
158
|
## Working contract
|
|
131
159
|
|
|
132
160
|
- 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.
|
|
@@ -143,10 +171,10 @@ A prompt changes the model's working tendency, not the real token limit or billi
|
|
|
143
171
|
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.
|
|
144
172
|
|
|
145
173
|
```js
|
|
146
|
-
plugin_manager({ action: "install_bundle", target: "dsh-deep-ptc-mode@1.
|
|
174
|
+
plugin_manager({ action: "install_bundle", target: "dsh-deep-ptc-mode@1.8.1" })
|
|
147
175
|
// Or from a local checkout or archive:
|
|
148
176
|
plugin_manager({ action: "install_bundle", target: "C:\\path\\to\\dsh-deep-ptc-mode" })
|
|
149
|
-
// Or target: "C:\\path\\to\\dsh-deep-ptc-mode-1.
|
|
177
|
+
// Or target: "C:\\path\\to\\dsh-deep-ptc-mode-1.8.1.tgz"
|
|
150
178
|
```
|
|
151
179
|
|
|
152
180
|
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.
|
package/README.zh.md
CHANGED
|
@@ -1,28 +1,56 @@
|
|
|
1
1
|
# 深度 PTC 模式
|
|
2
2
|
|
|
3
|
-
[English](README.md) · MIT · 当前版本:**1.
|
|
3
|
+
[English](README.md) · MIT · 当前版本:**1.8.1**
|
|
4
4
|
|
|
5
5
|
[1.7.3 实测汇总 / Test summary](TEST_REPORT.md)
|
|
6
|
-
|
|
6
|
+
**会汇报,先提问,不休眠,有计划,能插话。**
|
|
7
|
+
**五个基本问题,一套模式;一切皆插件,官方始终兜底。**
|
|
7
8
|
|
|
8
|
-
深度 PTC
|
|
9
|
+
深度 PTC 不是又一个工具包,而是针对模型执行任务时五个基本问题设计的 DeepSeek Harness Agent 模式:闷头干活不汇报、有歧义先猜不问、跑起来就休眠失联、不做计划或计划不可见、以及没有用好原 PTC 的简洁上下文与 unlimited token 提示词。
|
|
9
10
|
|
|
10
|
-
|
|
11
|
+
这五个问题先由提示词和代码一起解决;在此基础上,再按官方“一切皆插件”的理念,把预设与工具动态读取、创造模式、dsh-go 界面控制、多 shell 环境、外部插件工具/工作流适配、Skill 与工具读取流程逐项接进来。深度 PTC 本身不提供新的任务工具,它提供的是让外部插件的新工具能被识别、加载、调用的那层接口。
|
|
11
12
|
|
|
12
|
-
|
|
13
|
+
不承诺适配所有第三方插件:接口对已测试场景(dsh-ops)负责,其他插件走同一接口,具体仍取决于插件自身是否支持当前宿主、是否按契约发布工具。
|
|
13
14
|
|
|
14
|
-
|
|
15
|
+
## 五个基本问题
|
|
15
16
|
|
|
16
|
-
|
|
|
17
|
-
| --- | --- |
|
|
18
|
-
|
|
|
19
|
-
|
|
|
20
|
-
|
|
|
21
|
-
|
|
|
17
|
+
| # | 基本问题 | 深度 PTC 的做法 |
|
|
18
|
+
| --- | --- | --- |
|
|
19
|
+
| 1 | **闷头干活不汇报** | 每次 `run_code` 前一句话说明要做什么;里程碑稍长汇报;连续两三个工具调用必须出声;任务结束简短列出结果、失败工具与来源。 |
|
|
20
|
+
| 2 | **有歧义先猜不问** | 意思归用户、事实归工具:不认识的名称、多个可能目标、技术路线、范围和验收标准不确定时,先问 1–3 个带选项的问题,推荐项在前;可检查的事实自己查。你的回答优先于模型推断。 |
|
|
21
|
+
| 3 | **执行中休眠、失联** | 由代码强制:前台等待超过 30 秒自动转后台且不杀命令;你发消息时正在等待的命令约 2 秒内转后台,模型立刻看到消息;前台超过 5 秒的 sleep/Start-Sleep 直接拒绝;job 完成自动唤醒模型。 |
|
|
22
|
+
| 4 | **不做计划或计划不可见** | 按预计耗时分档:≤5 分钟内部计划直接做;5–20 分钟先展示计划,不等审批就执行;>20 分钟先给计划、等你批准。估计升档时重新说明;你可以在任一步调整方向,显式 plan mode 优先。 |
|
|
23
|
+
| 5 | **没用好简洁上下文与 unlimited token** | 预设从官方 PTC 现场派生,继承官方简洁组合;工具目录精简、完整 schema 按需加载,避免上下文被工具定义撑爆;人设写明本模式 token 预算无限、把预算花在读取/搜索/命令/验证上,同时禁止注水和啰嗦。提示词不改变实际计费或 token 上限。 |
|
|
24
|
+
|
|
25
|
+
## 按“一切皆插件”做的进一步能力
|
|
26
|
+
|
|
27
|
+
### 1. 预设与工具的动态读取
|
|
28
|
+
|
|
29
|
+
运行时读取宿主正在发布的官方 PTC 声明,官方行原样继承;仅替换 persona、执行组、可达性守卫、job 与提问包装。每 5 秒检测声明变化,仅在声明或配置变化时重建;声明读不到/解析失败才用随包快照并记录日志。官方升级后无需为本模式发版即可继承新工具;新建会话使用新版,已有会话不强制切换。
|
|
30
|
+
|
|
31
|
+
### 2. 创造模式工具的灵活加入
|
|
32
|
+
|
|
33
|
+
插件实验台默认关闭;打开后读取宿主正在发布的创造模式,只追加相对 PTC 多出来的行,专门负责 DSH 本身的插件创造。模块名保持创造模式原文,官方改名时跟着宿主走;技能目录按创造模式文件位置解析。实验台包只留在本进程内存,不写仓库、已发布预设、桌面组合或插件源码,经宿主原有批准后运行。加载只读预设清单和文档,不调用 `composedPreset`。
|
|
34
|
+
|
|
35
|
+
### 3. 适配 dsh-go 的界面控制
|
|
36
|
+
|
|
37
|
+
屏幕控制工具留在初始 PTC SDK,不收进按需目录,失败后也不隔离。识别依据是工具自己的 `resident` 标记、`dsh-go/view`、名称或提供者标记;不声明 dsh-go 自己的槽位,也不替换它的设置表单。工具状态控件投影失败时留空,不拆输入区或屏幕控制界面。
|
|
38
|
+
|
|
39
|
+
### 4. 扩展不同环境的适应范围
|
|
40
|
+
|
|
41
|
+
支持 WSL Bash、PowerShell(含 5.1 与 7 的可执行文件选择)、Zsh、原生 Bash。只对本模式生效,不改全局 shell;沙箱、审批和进程管理仍用官方实现。WSL 目前仅支持宿主已授权的 `danger-full-access`。
|
|
42
|
+
|
|
43
|
+
### 5. 增强外部插件工具/工作流的适配(dsh-ops 已专测)
|
|
22
44
|
|
|
23
|
-
|
|
45
|
+
这是深度 PTC 的核心接口:外部插件按自己的契约发布工具,深度 PTC 负责发现、按需加载、隔离故障,并在失败时回到官方 PTC。外部插件需支持当前宿主,并在 `deep-ptc` 作用域中发布工具;深度 PTC 不把任何插件写成依赖,也不替换执行器。
|
|
24
46
|
|
|
25
|
-
|
|
47
|
+
**dsh-ops 专门测试**:它在工具门控里只认 `minimal/standard/ptc/cordis`;深度 PTC 先给原生 `deep-ptc`,识别到它限制预设名后,按它实际接受的基座 id 返回 `ptc`(创造模式行可用 `cordis`);宿主内部仍保持精确 `deep-ptc`。结果是 dsh-ops 不需要改造,它的新工具就能在深度 PTC 会话里被识别和调用;其他外部插件走同一接口,按包内容判断。未归属工具不隔离;只有能明确归属的外部提供者才可能被隔离;官方工具永不禁用。
|
|
48
|
+
|
|
49
|
+
### 6. Skill 与工具的读取流程优化
|
|
50
|
+
|
|
51
|
+
先搜摘要,再加载完整 schema:默认每页 6 项、最多 8 项;完整 schema 每次最多 6 个、总预算 16 KB;最多保留 12 个近期选择。故障按对话隔离:明确不可用立即禁用;临时错误连续 3 次才禁用,成功一次清零;参数错误、权限拒绝、业务失败不算故障;一键重载只清当前对话。Skill 两阶段:目录只查元数据与权限,正文交给官方 `skill` 工具,检索不读正文。
|
|
52
|
+
|
|
53
|
+
使用三步:安装插件 → 在 **设置 → 插件 → 深度 PTC** 里选执行环境 → 新建任务时在模式选择器里选「深度PTC模式」。
|
|
26
54
|
|
|
27
55
|
## 1.7.2:轻量、按需、可恢复的工具调用层
|
|
28
56
|
|
|
@@ -47,20 +75,7 @@ const skills = await tools.deep_ptc_tools({ action: 'skills', query: 'build test
|
|
|
47
75
|
|
|
48
76
|
精简只作用于当前官方渲染器生成且未被其他插件改写的 SDK 段;插件自建 SDK 继续由其自身加载器管理。外部插件仍须支持当前宿主并在 `deep-ptc` 作用域发布工具;本层不会绕过工具隐藏、授权或接管被卸载的整个执行器。未进行实际 OPS/在线模型端到端评测。
|
|
49
77
|
|
|
50
|
-
## 简介
|
|
51
|
-
|
|
52
|
-
日常 Agent 工作中常见六个问题,深度 PTC 模式逐一针对:
|
|
53
|
-
|
|
54
|
-
| 你遇到的问题 | 深度PTC模式的做法 |
|
|
55
|
-
| --- | --- |
|
|
56
|
-
| 增强工具与自定义模式难以自然配合 | 外部插件能力优先,多提供者按功能协作,故障时使用动态继承的官方 PTC 基线恢复任务 |
|
|
57
|
-
| 模型总想帮你省 token,少查、少测,结果质量打折 | 人设写明「在深度求索工作,本模式 token 预算无限,把预算花在工作上」:不为省 token 跳过读取、搜索、命令或验证;同时禁止注水、啰嗦和撑爆上下文 |
|
|
58
|
-
| 任务跑起来后模型在 sleep 或干等,你发消息它不理 | 由代码强制:前台命令超过 30 秒自动转后台,你一发消息正在等的命令立即转后台、模型马上看到消息,长 sleep 直接拒绝;job 完成会自动唤醒模型(详见下方「代码层强制」) |
|
|
59
|
-
| 不管大小任务都同一种开工方式 | 按预计耗时分三档:5 分钟内自己计划直接做;5–20 分钟先告诉你计划、不等审批就执行;超过 20 分钟先给计划、等你批准 |
|
|
60
|
-
| 意思没弄懂就开干,最后返工 | 意思归用户,事实归工具:不认识的名称、多个可能目标、技术路线、范围和验收标准不确定时先问你(1–3 个带选项的问题),不靠搜索去猜你的意图;文件位置、当前行为这类事实自己查 |
|
|
61
|
-
| 命令环境固定,Windows 上想用 WSL、Mac 上想用 Zsh 都不方便 | 设置里可选 WSL Bash、PowerShell、Zsh(macOS/Linux)或原生 Bash,只对本模式生效,不改全局 shell |
|
|
62
78
|
|
|
63
|
-
使用三步:安装插件 → 在 **设置 → 插件 → 深度 PTC** 里选执行环境 → 新建任务时在模式选择器里选「深度PTC模式」。
|
|
64
79
|
|
|
65
80
|
## 代码层强制:不休眠、随时可插话
|
|
66
81
|
|
|
@@ -127,6 +142,19 @@ WSL 命令使用 Linux/POSIX 语法;文件工具和 `workdir` 仍用 Windows
|
|
|
127
142
|
|
|
128
143
|
本版没有在真机上点过手机屏幕控制。上面保证的是 SDK 成员资格、隔离规则,以及界面投影失败时的退让。
|
|
129
144
|
|
|
145
|
+
## 1.8.0:会话级 preset 身份兼容
|
|
146
|
+
|
|
147
|
+
外部插件常把 agent preset id 当能力开关(例如 dsh-ops 只认 minimal/standard/ptc/cordis)。深度 PTC 注册的 id 是 `deep-ptc`。1.8.0 在插件内部做两次尝试:
|
|
148
|
+
|
|
149
|
+
- **第一层(原生)**:不限制预设名称的外部插件拿 `deep-ptc`,直接可用;显式声明支持 `deep-ptc` 的插件也拿原生。
|
|
150
|
+
- **第二层(基座)**:限制预设名称、且列表里没有 `deep-ptc` 的插件拿 `ptc`。对 dsh-ops 这类包含 `ptc` 的列表,这一层必定通过;如果列表连 `ptc` 都没有,两层都不匹配(它本来也不支持 PTC)。
|
|
151
|
+
- 宿主内部必须精确的调用(子代理 header、定时任务、注册表自身)始终拿 `deep-ptc`,不影响继承和调度。
|
|
152
|
+
- 普通 PTC 会话本来就返回 `ptc`,其他预设原样返回;官方 PTC 预设没有被替换,也没有改 DSH。
|
|
153
|
+
- 创造模式/插件实验台:加载只读宿主的预设清单和文档,不调用 `composedPreset`;实验台挂进深 PTC 会话的创造模式行若只认 `cordis`,第二层就返回 `cordis`,普通创造模式会话仍原样。
|
|
154
|
+
- 两次尝试都在返回之前决定:宿主不会在插件拒绝时回调,所以读取调用方插件自己的包,判断它是否限制预设名称;不限制就给原生,限制就立即给基座。设置里可用 `presetCompat`、`presetFallback`、`presetSupport` 调整。
|
|
155
|
+
|
|
156
|
+
局限:这是对 `agentPresets.composedPreset` 的实例包装,依赖宿主内部方法签名;DSH 升级后需要复核。按包内容探测是启发式的,插件如果在代码里用动态拼接的 id,可能识别不到。
|
|
157
|
+
|
|
130
158
|
## 工作规则
|
|
131
159
|
|
|
132
160
|
- **不为 token 省力:** 人设写明在深度求索工作、本模式 token 预算无限,按问题需要而不是成本决定读取、搜索、命令和验证的深度;同时禁止注水和啰嗦,单次上下文仍有限,靠压缩、裁剪和子代理控制。
|
|
@@ -145,10 +173,10 @@ WSL 命令使用 Linux/POSIX 语法;文件工具和 `workdir` 仍用 Windows
|
|
|
145
173
|
本地目录或构建产物可通过插件管理器安装:
|
|
146
174
|
|
|
147
175
|
```js
|
|
148
|
-
plugin_manager({ action: "install_bundle", target: "dsh-deep-ptc-mode@1.
|
|
176
|
+
plugin_manager({ action: "install_bundle", target: "dsh-deep-ptc-mode@1.8.1" })
|
|
149
177
|
// 也可从本地目录或安装包安装:
|
|
150
178
|
plugin_manager({ action: "install_bundle", target: "C:\\path\\to\\dsh-deep-ptc-mode" })
|
|
151
|
-
// 或 target: "C:\\path\\to\\dsh-deep-ptc-mode-1.
|
|
179
|
+
// 或 target: "C:\\path\\to\\dsh-deep-ptc-mode-1.8.1.tgz"
|
|
152
180
|
```
|
|
153
181
|
|
|
154
182
|
GitHub 地址:`github:lishize20040802-rgb/dsh-deep-ptc-mode`。该地址安装远端实际内容;本地升级不会自动发布到 GitHub/npm。
|
package/TEST_REPORT.md
CHANGED
|
File without changes
|
package/assets/icon.png
CHANGED
|
File without changes
|
package/compatibility.json
CHANGED
|
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
|
package/lib/base-snapshot.json
CHANGED
|
File without changes
|
package/lib/client.js
CHANGED
|
File without changes
|
package/lib/creative.mjs
CHANGED
|
File without changes
|
package/lib/environment.mjs
CHANGED
|
File without changes
|
package/lib/executor.mjs
CHANGED
|
File without changes
|
package/lib/guard.mjs
CHANGED
|
File without changes
|
package/lib/host.mjs
CHANGED
|
File without changes
|
package/lib/index.mjs
CHANGED
|
@@ -10,6 +10,7 @@ import { discoverShells, resolveShellExecutable, shellNote } from './shells.mjs'
|
|
|
10
10
|
import { BASE_DECLARATION_SPECIFIER, creativePresetUrl, loadCreativePreset, loadCurrentPreset, officialPresetUrl, parseOfficialExecutors } from './upstream.mjs';
|
|
11
11
|
import { importHost, pluginOf, resolveHost } from './host.mjs';
|
|
12
12
|
import { presetLifecycle } from './lifecycle.mjs';
|
|
13
|
+
import { installPresetCompat } from './preset-compat.mjs';
|
|
13
14
|
|
|
14
15
|
function whereExecutable(name) {
|
|
15
16
|
try {
|
|
@@ -48,6 +49,10 @@ export const Config = z.object({
|
|
|
48
49
|
toolPreferences: z.any().default([]).volatile(),
|
|
49
50
|
compactToolCatalog: z.boolean().default(true).volatile(),
|
|
50
51
|
hostPlatform: z.const(process.platform).default(process.platform).volatile(),
|
|
52
|
+
// Session-scoped preset identity compatibility (native id first, base fallback).
|
|
53
|
+
presetCompat: z.boolean().default(true).volatile(),
|
|
54
|
+
presetFallback: z.string().default('ptc').volatile(),
|
|
55
|
+
presetSupport: z.any().default({}).volatile(),
|
|
51
56
|
});
|
|
52
57
|
|
|
53
58
|
// Tool preferences are advice for the model, so a malformed list must not cost the preset.
|
|
@@ -169,6 +174,18 @@ export async function apply(ctx, config) {
|
|
|
169
174
|
error => ctx.logger.error('Deep PTC environment update failed: %s', error.message),
|
|
170
175
|
);
|
|
171
176
|
ctx.effect(() => () => lifecycle.dispose());
|
|
177
|
+
// Session-scoped preset identity: report the native deep-ptc id first; an external
|
|
178
|
+
// consumer that does not declare support for it gets the base preset id instead.
|
|
179
|
+
const compat = installPresetCompat(ctx, () => {
|
|
180
|
+
if (config.presetCompat.get() === false) return { enabled: false };
|
|
181
|
+
let support = {};
|
|
182
|
+
try {
|
|
183
|
+
const raw = config.presetSupport.get();
|
|
184
|
+
if (raw && typeof raw === 'object' && !Array.isArray(raw)) support = raw;
|
|
185
|
+
} catch { /* keep the empty override list */ }
|
|
186
|
+
return { enabled: true, nativeIds: ['deep-ptc'], fallback: config.presetFallback.get() || 'ptc', support };
|
|
187
|
+
});
|
|
188
|
+
ctx.effect(() => () => compat.dispose(), 'Deep PTC: session-scoped preset identity');
|
|
172
189
|
// A preset the host refuses to mount would leave its sessions unusable, so fall back to the official
|
|
173
190
|
// composition with the persona. Not awaited: reading the diagnosis waits for the host tree.
|
|
174
191
|
const verify = async () => {
|
package/lib/jobs-tool.mjs
CHANGED
|
File without changes
|
package/lib/lab.mjs
CHANGED
|
File without changes
|
package/lib/lifecycle.mjs
CHANGED
|
File without changes
|
package/lib/model.mjs
CHANGED
|
File without changes
|
package/lib/official-names.mjs
CHANGED
|
File without changes
|
|
@@ -0,0 +1,283 @@
|
|
|
1
|
+
// Deep PTC owns a session-scoped preset identity compatibility layer.
|
|
2
|
+
//
|
|
3
|
+
// Two attempts for a session's identity:
|
|
4
|
+
// 1. native deep-ptc -- the plugin may pass if it does not limit preset names;
|
|
5
|
+
// 2. base ptc -- a plugin that limits preset names to the built-in ids passes here.
|
|
6
|
+
//
|
|
7
|
+
// Each external plugin is asked once, so the layer is chosen before returning: inspect
|
|
8
|
+
// the calling plugin's own package. A package that does not gate on preset ids, or
|
|
9
|
+
// that declares deep-ptc, gets the native id. A package that gates on preset ids but
|
|
10
|
+
// does not declare deep-ptc gets the base id immediately. The second layer is the one
|
|
11
|
+
// that is guaranteed to pass for a plugin whose allowlist includes ptc (dsh-ops maps
|
|
12
|
+
// minimal/standard/ptc/cordis). A plugin that excludes ptc can pass neither.
|
|
13
|
+
//
|
|
14
|
+
// Why not retry at runtime: composedPreset() returns one string and the host gives no
|
|
15
|
+
// rejection callback; a plugin whose gate misses simply stays inert. So the two
|
|
16
|
+
// attempts are resolved per caller before the value is returned.
|
|
17
|
+
//
|
|
18
|
+
// Host internals that must keep the exact identity (subagent child headers, scheduled
|
|
19
|
+
// session creation, the registry itself) are recognised from the immediate frames.
|
|
20
|
+
import { appendFileSync, readFileSync, readdirSync, statSync } from 'node:fs';
|
|
21
|
+
import { dirname, join, parse } from 'node:path';
|
|
22
|
+
import { fileURLToPath } from 'node:url';
|
|
23
|
+
|
|
24
|
+
export const name = 'deep-ptc-preset-compat';
|
|
25
|
+
export const inject = ['agentPresets'];
|
|
26
|
+
|
|
27
|
+
const PATCH_MARK = Symbol.for('dsh-deep-ptc-mode.preset-compat.patch');
|
|
28
|
+
const HOST_CALLERS = /(?:dsh-subagent|dsh-tool-schedule|dsh-agent-preset-registry)/u;
|
|
29
|
+
const SELF = 'preset-compat.mjs';
|
|
30
|
+
const CODE_EXTENSIONS = ['.mjs', '.cjs', '.js', '.mts', '.cts', '.ts'];
|
|
31
|
+
const SKIP_DIRS = new Set(['node_modules', '.git', 'dist', 'docs', 'test', 'tests']);
|
|
32
|
+
const MAX_FILES = 800;
|
|
33
|
+
const MAX_FILE_BYTES = 1024 * 1024;
|
|
34
|
+
const MAX_TOTAL_BYTES = 8 * 1024 * 1024;
|
|
35
|
+
const LOG = 'C:/Users/13987/.dsh/tmp/deep-ptc-preset-compat.log';
|
|
36
|
+
|
|
37
|
+
const packageCache = new Map();
|
|
38
|
+
const callerCache = new Map();
|
|
39
|
+
const logged = new Set();
|
|
40
|
+
|
|
41
|
+
function log(line) {
|
|
42
|
+
try { appendFileSync(LOG, line + '\n'); } catch { /* diagnostics only */ }
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
function fileOf(value) {
|
|
46
|
+
try {
|
|
47
|
+
const file = value.startsWith('file:') ? fileURLToPath(value) : value;
|
|
48
|
+
// fileURLToPath yields /C:/... under a POSIX runtime and C:\... on Windows.
|
|
49
|
+
return /^\/[A-Za-z]:[\\/]/u.test(file) ? file.slice(1) : file;
|
|
50
|
+
} catch { return ''; }
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
function isCodeFile(name) {
|
|
54
|
+
return CODE_EXTENSIONS.some(extension => name.endsWith(extension));
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
function isNumber(text) {
|
|
58
|
+
return text.length > 0 && Number.isFinite(Number(text)) && /^[0-9]+$/u.test(text);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/** First stack frame outside this module, as an absolute file path. */
|
|
62
|
+
export function callerFile(stack) {
|
|
63
|
+
for (const raw of String(stack ?? '').split('\n').slice(1)) {
|
|
64
|
+
if (raw.includes(SELF)) continue;
|
|
65
|
+
// Cordis service proxies insert one infrastructure frame (Object.apply in the
|
|
66
|
+
// host's cordis package) between this wrapper and the real caller. Skip it so
|
|
67
|
+
// the caller's own package, not the proxy, decides the layer.
|
|
68
|
+
if (raw.includes('@deepseek-ai/cordis/')) continue;
|
|
69
|
+
let text = raw.trim();
|
|
70
|
+
if (text.startsWith('at ')) text = text.slice(3).trim();
|
|
71
|
+
if (text.startsWith('async ')) text = text.slice(6).trim();
|
|
72
|
+
const open = text.lastIndexOf('(');
|
|
73
|
+
if (open !== -1 && text.endsWith(')')) text = text.slice(open + 1, -1);
|
|
74
|
+
const parts = text.split(':');
|
|
75
|
+
if (parts.length < 3) continue;
|
|
76
|
+
const col = parts.pop();
|
|
77
|
+
const line = parts.pop();
|
|
78
|
+
if (!isNumber(line) || !isNumber(col)) continue;
|
|
79
|
+
const file = fileOf(parts.join(':'));
|
|
80
|
+
if (file) return file;
|
|
81
|
+
}
|
|
82
|
+
return '';
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/** Nearest ancestor package.json carrying a name. */
|
|
86
|
+
export function packageOf(file) {
|
|
87
|
+
let dir = dirname(file);
|
|
88
|
+
const { root } = parse(dir);
|
|
89
|
+
for (let depth = 0; depth < 12 && dir && dir !== root; depth++) {
|
|
90
|
+
try {
|
|
91
|
+
const manifest = JSON.parse(readFileSync(join(dir, 'package.json'), 'utf8'));
|
|
92
|
+
if (manifest && typeof manifest.name === 'string') return { root: dir, name: manifest.name };
|
|
93
|
+
} catch { /* keep walking */ }
|
|
94
|
+
const parent = dirname(dir);
|
|
95
|
+
if (parent === dir) break;
|
|
96
|
+
dir = parent;
|
|
97
|
+
}
|
|
98
|
+
return undefined;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
const GATE_MARKERS = [
|
|
102
|
+
'MODE_PRESET',
|
|
103
|
+
"=== 'ptc'", '=== "ptc"', "!== 'ptc'", '!== "ptc"',
|
|
104
|
+
"=== 'standard'", '=== "standard"', "=== 'cordis'", '=== "cordis"',
|
|
105
|
+
"=== 'minimal'", '=== "minimal"',
|
|
106
|
+
"case 'ptc'", 'case "ptc"',
|
|
107
|
+
".includes('ptc')", '.includes("ptc")',
|
|
108
|
+
];
|
|
109
|
+
|
|
110
|
+
const CREATIVE_PRESET_ID = 'cordis';
|
|
111
|
+
const KNOWN_PRESET_IDS = ['deep-ptc', CREATIVE_PRESET_ID, 'ptc', 'standard', 'minimal'];
|
|
112
|
+
|
|
113
|
+
function presetRestricted(text) {
|
|
114
|
+
return GATE_MARKERS.some(marker => text.includes(marker));
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
/** Quoted preset ids this code mentions; the base id a restricted plugin accepts. */
|
|
118
|
+
function acceptedPresetIds(text) {
|
|
119
|
+
const found = [];
|
|
120
|
+
for (const id of KNOWN_PRESET_IDS) {
|
|
121
|
+
if (text.includes("'" + id + "'") || text.includes('"' + id + '"')) found.push(id);
|
|
122
|
+
}
|
|
123
|
+
return found;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
* Probe one plugin package for the two identity layers. Bounded and cached.
|
|
128
|
+
* @param root - package root.
|
|
129
|
+
* @param nativeId - the native preset id, normally deep-ptc.
|
|
130
|
+
* @returns declares: the package knows the native id; restricted: the package gates on preset ids.
|
|
131
|
+
*/
|
|
132
|
+
export function packageProbe(root, nativeId) {
|
|
133
|
+
const key = root + '|' + nativeId;
|
|
134
|
+
if (packageCache.has(key)) return packageCache.get(key);
|
|
135
|
+
let files = 0;
|
|
136
|
+
let bytes = 0;
|
|
137
|
+
const result = { declares: false, restricted: false, accepts: [] };
|
|
138
|
+
const accepts = new Set();
|
|
139
|
+
const visit = directory => {
|
|
140
|
+
if (result.declares || files >= MAX_FILES || bytes >= MAX_TOTAL_BYTES) return;
|
|
141
|
+
let entries;
|
|
142
|
+
try { entries = readdirSync(directory, { withFileTypes: true }); } catch { return; }
|
|
143
|
+
for (const entry of entries) {
|
|
144
|
+
if (result.declares || files >= MAX_FILES || bytes >= MAX_TOTAL_BYTES) return;
|
|
145
|
+
if (entry.name.startsWith('.')) continue;
|
|
146
|
+
const full = join(directory, entry.name);
|
|
147
|
+
if (entry.isDirectory()) {
|
|
148
|
+
if (!SKIP_DIRS.has(entry.name)) visit(full);
|
|
149
|
+
continue;
|
|
150
|
+
}
|
|
151
|
+
if (!entry.isFile() || !isCodeFile(entry.name)) continue;
|
|
152
|
+
let size = 0;
|
|
153
|
+
try { size = statSync(full).size; } catch { continue; }
|
|
154
|
+
if (size <= 0 || size > MAX_FILE_BYTES) continue;
|
|
155
|
+
let text;
|
|
156
|
+
try { text = readFileSync(full, 'utf8'); } catch { continue; }
|
|
157
|
+
if (text.includes(nativeId)) result.declares = true;
|
|
158
|
+
if (presetRestricted(text)) result.restricted = true;
|
|
159
|
+
for (const id of acceptedPresetIds(text)) accepts.add(id);
|
|
160
|
+
files += 1;
|
|
161
|
+
bytes += size;
|
|
162
|
+
}
|
|
163
|
+
};
|
|
164
|
+
visit(root);
|
|
165
|
+
result.accepts = [...accepts];
|
|
166
|
+
packageCache.set(key, result);
|
|
167
|
+
return result;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
/**
|
|
171
|
+
* Resolve the identity one external consumer should see.
|
|
172
|
+
* @param exact - the live composed preset id.
|
|
173
|
+
* @param options - enabled, nativeIds, fallback, creativeFallback and support overrides.
|
|
174
|
+
* @param info - host flag, package name and declaration probe result.
|
|
175
|
+
* @returns the id to report.
|
|
176
|
+
*/
|
|
177
|
+
export function decidePresetId(exact, options = {}, info = {}) {
|
|
178
|
+
const nativeIds = Array.isArray(options.nativeIds) && options.nativeIds.length > 0
|
|
179
|
+
? options.nativeIds : ['deep-ptc'];
|
|
180
|
+
if (typeof exact !== 'string' || !nativeIds.includes(exact)) return exact;
|
|
181
|
+
if (options.enabled === false) return exact;
|
|
182
|
+
if (info.host === true) return exact;
|
|
183
|
+
const support = options.support && typeof options.support === 'object' && !Array.isArray(options.support)
|
|
184
|
+
? options.support : {};
|
|
185
|
+
const override = info.packageName === undefined ? undefined : support[info.packageName];
|
|
186
|
+
if (override === 'native') return exact;
|
|
187
|
+
const fallback = options.fallback || 'ptc';
|
|
188
|
+
if (override === 'base') return fallback;
|
|
189
|
+
// Layer 1: a plugin that does not limit preset names, or that declares the native
|
|
190
|
+
// id itself, keeps deep-ptc.
|
|
191
|
+
if (info.declares === true) return exact;
|
|
192
|
+
if (info.restricted !== true) return exact;
|
|
193
|
+
// Layer 2: a plugin that limits preset names gets a base id. ptc is the normal
|
|
194
|
+
// base; a creative-mode row mounted by the plugin lab may accept only cordis,
|
|
195
|
+
// so use the id its own code actually mentions.
|
|
196
|
+
const accepts = Array.isArray(info.accepts) ? info.accepts : [];
|
|
197
|
+
if (accepts.includes(fallback)) return fallback;
|
|
198
|
+
if (accepts.includes(CREATIVE_PRESET_ID)) return CREATIVE_PRESET_ID;
|
|
199
|
+
return fallback;
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
/** Inspect one call: host frame, or the calling plugin package and its declaration. */
|
|
203
|
+
export function inspectCaller(stack, nativeId) {
|
|
204
|
+
const head = String(stack ?? '').split('\n').slice(0, 4).join('\n');
|
|
205
|
+
if (HOST_CALLERS.test(head)) return { host: true };
|
|
206
|
+
const file = callerFile(stack);
|
|
207
|
+
if (!file) return { host: true };
|
|
208
|
+
if (file.includes('app.asar')) return { host: true };
|
|
209
|
+
if (callerCache.has(file)) return callerCache.get(file);
|
|
210
|
+
const pkg = packageOf(file);
|
|
211
|
+
if (pkg === undefined) return { host: true };
|
|
212
|
+
if (pkg.name.startsWith('@deepseek-ai/')) return { host: true };
|
|
213
|
+
const probe = packageProbe(pkg.root, nativeId);
|
|
214
|
+
const info = { host: false, packageName: pkg.name, packageRoot: pkg.root, declares: probe.declares, restricted: probe.restricted, accepts: probe.accepts };
|
|
215
|
+
callerCache.set(file, info);
|
|
216
|
+
return info;
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
function logDecision(info, id) {
|
|
220
|
+
if (!info || typeof info.packageName !== 'string') return;
|
|
221
|
+
const key = info.packageName + '|' + id;
|
|
222
|
+
if (logged.has(key)) return;
|
|
223
|
+
logged.add(key);
|
|
224
|
+
log('decision ' + new Date().toISOString() + ' ' + info.packageName + ' -> ' + id + (info.declares ? ' (declares native)' : info.restricted ? ' (preset restricted -> ' + id + ')' : ' (unrestricted -> native)'));
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
/**
|
|
228
|
+
* Install the identity layer on the live registry. Idempotent: a second mount
|
|
229
|
+
* (plugin startup plus an explicit compatibility row) keeps the first owner and
|
|
230
|
+
* becomes a no-op.
|
|
231
|
+
* @param ctx - plugin context carrying agentPresets.
|
|
232
|
+
* @param options - options object or a getter returning one.
|
|
233
|
+
* @returns owner handle; dispose() restores the unpatched method.
|
|
234
|
+
*/
|
|
235
|
+
export function installPresetCompat(ctx, options) {
|
|
236
|
+
const registry = ctx?.agentPresets;
|
|
237
|
+
const current = registry?.composedPreset;
|
|
238
|
+
if (typeof current !== 'function') {
|
|
239
|
+
log('skip ' + new Date().toISOString() + ': agentPresets.composedPreset unavailable');
|
|
240
|
+
return { active: false, owner: false, dispose() {} };
|
|
241
|
+
}
|
|
242
|
+
if (current[PATCH_MARK] === true) return { active: true, owner: false, dispose() {} };
|
|
243
|
+
const hadOwn = Object.hasOwn(registry, 'composedPreset');
|
|
244
|
+
const original = current;
|
|
245
|
+
const patched = function composedPreset(agentCtx) {
|
|
246
|
+
const exact = original.call(registry, agentCtx);
|
|
247
|
+
const now = typeof options === 'function' ? options() : options;
|
|
248
|
+
if (!now || now.enabled === false) return exact;
|
|
249
|
+
const nativeIds = Array.isArray(now.nativeIds) && now.nativeIds.length > 0 ? now.nativeIds : ['deep-ptc'];
|
|
250
|
+
if (typeof exact !== 'string' || !nativeIds.includes(exact)) return exact;
|
|
251
|
+
// A failed probe means 'does not declare the native id', so the consumer still
|
|
252
|
+
// receives the usable base id instead of losing the plugin surface.
|
|
253
|
+
let info = { host: false, declares: false, restricted: true };
|
|
254
|
+
try { info = inspectCaller(new Error().stack ?? '', nativeIds[0]); } catch (error) { log('inspect-error ' + error.message); }
|
|
255
|
+
const id = decidePresetId(exact, now, info);
|
|
256
|
+
logDecision(info, id);
|
|
257
|
+
return id;
|
|
258
|
+
};
|
|
259
|
+
Object.defineProperty(patched, PATCH_MARK, { value: true });
|
|
260
|
+
Object.defineProperty(registry, 'composedPreset', { value: patched, configurable: true, writable: true });
|
|
261
|
+
log('installed ' + new Date().toISOString());
|
|
262
|
+
return {
|
|
263
|
+
active: true,
|
|
264
|
+
owner: true,
|
|
265
|
+
dispose() {
|
|
266
|
+
if (registry.composedPreset !== patched) return;
|
|
267
|
+
if (hadOwn) Object.defineProperty(registry, 'composedPreset', { value: original, configurable: true, writable: true });
|
|
268
|
+
else delete registry.composedPreset;
|
|
269
|
+
log('disposed ' + new Date().toISOString());
|
|
270
|
+
},
|
|
271
|
+
};
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
// Compatibility row entry: mount the same layer explicitly (idempotent).
|
|
275
|
+
export function apply(ctx, config) {
|
|
276
|
+
const compat = installPresetCompat(ctx, {
|
|
277
|
+
enabled: true,
|
|
278
|
+
nativeIds: ['deep-ptc'],
|
|
279
|
+
fallback: config?.fallback ?? 'ptc',
|
|
280
|
+
support: config?.support && typeof config.support === 'object' ? config.support : {},
|
|
281
|
+
});
|
|
282
|
+
ctx.effect(() => () => compat.dispose(), 'Deep PTC: preset identity compatibility');
|
|
283
|
+
}
|
package/lib/preset.json
CHANGED
|
File without changes
|
package/lib/reachable.mjs
CHANGED
|
File without changes
|
package/lib/resident.mjs
CHANGED
|
File without changes
|
package/lib/rules.mjs
CHANGED
|
File without changes
|
package/lib/shells.mjs
CHANGED
|
File without changes
|
package/lib/sleep-lint.mjs
CHANGED
|
File without changes
|
package/lib/terminal.mjs
CHANGED
|
File without changes
|
package/lib/tool-catalog.mjs
CHANGED
|
File without changes
|
|
File without changes
|
package/lib/tool-policy.mjs
CHANGED
|
File without changes
|
package/lib/upstream.mjs
CHANGED
|
File without changes
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-deep-ptc-mode",
|
|
3
|
-
"version": "1.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "1.8.1",
|
|
4
|
+
"description": "Agent mode for DSH fixing five basics: reporting, asking before guessing, staying reachable, planning, and context/token use; plugin-first with official PTC fallback, dynamic preset/tool loading, creative plugin lab, dsh-go screen control, multi-shell and dsh-ops-tested external-tool adaptation. / 面向 DSH 的 Agent 模式:解决汇报、先问、不休眠、做计划、用好上下文与预算五个基本问题;插件优先、官方 PTC 兜底,支持预设/工具动态读取、创造模式实验台、dsh-go 界面控制、多 shell 与外部工具适配(dsh-ops 已专测)。",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"dsh-plugin",
|
|
@@ -13,6 +13,9 @@
|
|
|
13
13
|
"clarification",
|
|
14
14
|
"background-jobs",
|
|
15
15
|
"plugin-compatibility",
|
|
16
|
+
"preset-compatibility",
|
|
17
|
+
"dsh-ops",
|
|
18
|
+
"creative-mode",
|
|
16
19
|
"tool-cooperation",
|
|
17
20
|
"official-ptc-fallback"
|
|
18
21
|
],
|
|
@@ -68,6 +71,7 @@
|
|
|
68
71
|
"./ask-user": "./lib/ask-user.mjs",
|
|
69
72
|
"./guard": "./lib/guard.mjs",
|
|
70
73
|
"./tool-compatibility": "./lib/tool-compatibility.mjs",
|
|
74
|
+
"./preset-compat": "./lib/preset-compat.mjs",
|
|
71
75
|
"./environment": "./lib/environment.mjs",
|
|
72
76
|
"./lab": "./lib/lab.mjs",
|
|
73
77
|
"./client": "./lib/client.js",
|