dsh-ptc-plus 0.2.4 → 0.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.en.md +177 -0
- package/README.md +85 -69
- package/assets/ptc-plus-bindings-en.png +0 -0
- package/assets/ptc-plus-bindings-zh.png +0 -0
- package/assets/ptc-plus-repair-en.png +0 -0
- package/assets/ptc-plus-settings-en.png +0 -0
- package/assets/ptc-plus-settings-zh.png +0 -0
- package/client.js +1168 -144
- package/docs/adr/0006-rewrite-module-syntax-with-an-ast.md +1 -1
- package/docs/adr/0007-separate-worker-transport-from-session-semantics.md +15 -3
- package/docs/adr/0013-isolate-repl-redeclaration-convenience.md +7 -3
- package/docs/adr/0014-persist-cell-rewrite-policy.md +7 -5
- package/docs/adr/0019-plugin-settings-and-kill-switch.md +19 -4
- package/docs/adr/0020-optional-cordis-tools-in-ptc-mode.md +2 -2
- package/docs/adr/0021-separate-host-bootstrap-from-session-runtime.md +5 -3
- package/docs/adr/0022-stage-npm-releases-with-oidc.md +2 -2
- package/docs/architecture.md +23 -14
- package/docs/client-ui.md +29 -11
- package/docs/durability-design.md +42 -20
- package/docs/installation.md +11 -3
- package/docs/program-data-plane.md +6 -0
- package/docs/runtime-reference.md +27 -14
- package/docs/value-wire.md +1 -1
- package/index.js +38 -4
- package/internal/cell-analysis.js +89 -12
- package/internal/cell-rewriter.js +162 -4
- package/internal/config-spec.js +192 -117
- package/internal/direct-surface-owner.js +56 -5
- package/internal/edit-transport-owner.js +11 -2
- package/internal/failure-reporting.js +15 -0
- package/internal/kernel-worker.js +11 -0
- package/internal/rejected-cell-editor.js +21 -12
- package/internal/repl-convenience.js +94 -6
- package/internal/repl-memory-projection.js +277 -0
- package/internal/repl-rewrite-contract.js +15 -0
- package/internal/run-code-description.js +34 -0
- package/internal/runtime-bridge-owner.js +63 -15
- package/internal/runtime-config.js +3 -0
- package/internal/session-cell-executor.js +74 -14
- package/internal/session-events.js +7 -0
- package/internal/session-journal.js +331 -63
- package/internal/session-log-view.js +2 -1
- package/internal/session-runtime.js +110 -9
- package/internal/session-state.js +116 -4
- package/package.json +10 -7
- package/src/client-activity.js +501 -0
- package/src/client.js +456 -20
- package/README.zh.md +0 -161
- /package/assets/{ptc-plus-repair.png → ptc-plus-repair-zh.png} +0 -0
package/README.en.md
ADDED
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
<p align="center">
|
|
2
|
+
<img src="assets/dsh-ptc-plus-banner-en.webp" width="100%" alt="dsh-ptc-plus banner">
|
|
3
|
+
</p>
|
|
4
|
+
|
|
5
|
+
<p align="center">
|
|
6
|
+
<a href="README.md">简体中文</a> ·
|
|
7
|
+
<strong>English</strong>
|
|
8
|
+
</p>
|
|
9
|
+
|
|
10
|
+
<p align="center">
|
|
11
|
+
<a href="#what-default-ptc-mode-gets-wrong">Problems</a> ·
|
|
12
|
+
<a href="#three-scenes-that-matter-most">Scenes</a> ·
|
|
13
|
+
<a href="#settings">Settings</a> ·
|
|
14
|
+
<a href="#scope">Scope</a> ·
|
|
15
|
+
<a href="#install">Install</a> ·
|
|
16
|
+
<a href="#documentation">Docs</a>
|
|
17
|
+
</p>
|
|
18
|
+
|
|
19
|
+
<p align="center">
|
|
20
|
+
<a href="https://github.com/deepseek-ai/deepseek-harness"><img alt="DeepSeek Harness PTC mode" src="https://img.shields.io/badge/DeepSeek%20Harness-PTC%20mode-4b6bfb"></a>
|
|
21
|
+
<a href="package.json"><img alt="Node.js ^22.19.0 || >=24.0.0" src="https://img.shields.io/badge/Node.js-%5E22.19.0%20%7C%7C%20%3E%3D24.0.0-5fa04e?logo=nodedotjs&logoColor=white"></a>
|
|
22
|
+
<a href="https://www.npmjs.com/package/dsh-ptc-plus"><img alt="npm version" src="https://img.shields.io/npm/v/dsh-ptc-plus?logo=npm"></a>
|
|
23
|
+
<a href="LICENSE"><img alt="License: MIT" src="https://img.shields.io/badge/License-MIT-yellow.svg"></a>
|
|
24
|
+
</p>
|
|
25
|
+
|
|
26
|
+
<p align="center">
|
|
27
|
+
<a href="https://awesome-dsh-plugin.com/"><img alt="Awesome DSH Plugin" src="https://awesome-dsh-plugin.com/badge.svg"></a>
|
|
28
|
+
</p>
|
|
29
|
+
|
|
30
|
+
---
|
|
31
|
+
|
|
32
|
+
**PTC Plus gives DSH PTC mode a session-bound persistent TypeScript REPL.** Every `run_code` continues in the same session. Variables, imports, and results from one `run_code` are still available in the next one.
|
|
33
|
+
|
|
34
|
+
> [!NOTE]
|
|
35
|
+
> Community plugin, no affiliation with or endorsement from DeepSeek or DSH.
|
|
36
|
+
|
|
37
|
+
> [!IMPORTANT]
|
|
38
|
+
> Built for `danger-full-access`: direct Node.js and OS access with no extra sandbox. Use it only where that permission scope is acceptable.
|
|
39
|
+
|
|
40
|
+

|
|
41
|
+
|
|
42
|
+
*The settings card exposes live configuration and the `enabled` kill switch.*
|
|
43
|
+
|
|
44
|
+
## What default PTC mode gets wrong
|
|
45
|
+
|
|
46
|
+
DSH PTC mode starts every `run_code` in a fresh environment. The model computes something, then has to send the same setup code again. One bad line means the whole thing is resent. This plugin attaches `run_code` to a session-backed environment, so later calls reuse what was already there.
|
|
47
|
+
|
|
48
|
+
| Situation | Default PTC mode | With PTC Plus |
|
|
49
|
+
| --- | --- | --- |
|
|
50
|
+
| State | starts from zero, setup resent ❌ | previous `run_code` results stay ✅ |
|
|
51
|
+
| Fixing | wrong result resends the code ❌ | one diff ✅ |
|
|
52
|
+
| Modules | `import` / `export` cannot be written ❌ | written normally, AST handles it ✅ |
|
|
53
|
+
| Values | JSON changes or loses special values ❌ | those values stay intact ✅ |
|
|
54
|
+
| Restart | everything is lost ❌ | recoverable parts come back ✅ |
|
|
55
|
+
| Output and errors | printing floods, errors point elsewhere ❌ | output trimmed, errors map to your line ✅ |
|
|
56
|
+
| Tools | list invisible, miscalls fail ❌ | can inspect; known miscalls become `run_code` ✅ |
|
|
57
|
+
| Paths | relative paths can drift ❌ | session remembers the project directory ✅ |
|
|
58
|
+
| Agent tools | tools needing the agent are rejected ❌ | context restored, goal works ✅ |
|
|
59
|
+
|
|
60
|
+
## Three scenes that matter most
|
|
61
|
+
|
|
62
|
+
### State carries over
|
|
63
|
+
|
|
64
|
+
First `run_code`:
|
|
65
|
+
|
|
66
|
+
```ts
|
|
67
|
+
import { readFile } from 'node:fs/promises'
|
|
68
|
+
const manifest = JSON.parse(await readFile('package.json', 'utf8'))
|
|
69
|
+
const deps = Object.keys(manifest.dependencies ?? {})
|
|
70
|
+
return deps.length
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
The next one keeps going:
|
|
74
|
+
|
|
75
|
+
```ts
|
|
76
|
+
return deps.map(dep => dep + '@' + manifest.dependencies[dep])
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
`deps` and `manifest` are still there. The setup code is sent only once.
|
|
80
|
+
|
|
81
|
+
### Fix without resending
|
|
82
|
+
|
|
83
|
+
By default, a wrong result or a failure sends the whole code block again.
|
|
84
|
+
|
|
85
|
+
With PTC Plus, it sends one line:
|
|
86
|
+
|
|
87
|
+
```ts
|
|
88
|
+
edit_run_code({ edits: [{ old_string: 'deps.length', new_string: 'deps' }] })
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
Only the diff goes in. The full source stays out of the conversation. Exact replacements and regular expressions both have limits, so a bad pattern cannot hang.
|
|
92
|
+
|
|
93
|
+
When a rejected cell has exactly one validated missing closing token at the end, its diagnostic includes the complete `edit_run_code(...)` call needed to apply that correction and rerun the cell. That generated call carries an `expected_target_call_seq` precondition, so it is rejected without execution if another cell becomes the edit target first. PTC Plus never applies the suggestion automatically; ambiguous repairs or repairs without a persistent target identity still require corrected source.
|
|
94
|
+
|
|
95
|
+
### Module syntax
|
|
96
|
+
|
|
97
|
+
DSH PTC mode executes each `run_code` as an async function body, where static `import` and `export` declarations are invalid. PTC Plus adapts those forms before execution with AST analysis.
|
|
98
|
+
|
|
99
|
+
The model writes normally:
|
|
100
|
+
|
|
101
|
+
```ts
|
|
102
|
+
import { readFile } from 'node:fs/promises'
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
Imports resolve from your project, and named/default imports stay live and read-only. The model never has to know that a `run_code` is really a function body.
|
|
106
|
+
|
|
107
|
+
## One measured A/B
|
|
108
|
+
|
|
109
|
+
One identity-blind paired run used `opencode-go/deepseek-v4-flash`. Both arms used the same versioned fixture, task prompts, permissions, and two replicates per task, so 18 sessions per arm.
|
|
110
|
+
|
|
111
|
+
| Across all 9 tasks | PTC Plus | DSH PTC mode (PTC Plus disabled) | Observed change |
|
|
112
|
+
| --- | ---: | ---: | ---: |
|
|
113
|
+
| Model requests | 66 | 88 | 25.0% fewer |
|
|
114
|
+
| Tool calls | 50 | 79 | 36.7% fewer |
|
|
115
|
+
| Token traffic | 729,642 | 942,901 | 22.6% fewer |
|
|
116
|
+
| Identity-blind rubric score | 138 / 162 | 118 / 162 | +12.3 percentage points |
|
|
117
|
+
|
|
118
|
+
The module-syntax task separated the two arms most clearly. PTC Plus finished both replicates with one `run_code` each. DSH PTC mode without PTC Plus finished neither static-import requirement and used eight tool calls across its attempts.
|
|
119
|
+
|
|
120
|
+
This is one stochastic paired observation, not a performance guarantee. Machine budgets were exceeded in 2 of the 18 PTC Plus sessions and 5 of the 18 sessions without PTC Plus, so the matrix as a whole did not pass machine acceptance. Token traffic includes input, cache-read, cache-write, and output tokens. The fixture, pairing rules, metrics, and blind-review protocol are documented in [Evaluation](docs/evaluation.md).
|
|
121
|
+
|
|
122
|
+

|
|
123
|
+
|
|
124
|
+
*A real session: the long code and the truthful `edit_run_code` repair call. The repair never resends the source.*
|
|
125
|
+
|
|
126
|
+
## Settings
|
|
127
|
+
|
|
128
|
+
Open **Settings → Plugin configuration** to use the card shown above. The card follows the DSH UI language: it renders in English when the harness is set to English, and in Chinese when set to Chinese. The `enabled` switch is live: turning it off leaves only the card and that switch, while turning it on restores the session runtime and `run_code`/`edit_run_code`.
|
|
129
|
+
|
|
130
|
+
Settings are separated into common and compatibility controls, optional capabilities, advanced behavior, and resource limits. Decisions that need user attention appear before resource limits.
|
|
131
|
+
|
|
132
|
+
“Use enhanced PTC Plus tool cards” is on by default and provides expandable source, results, execution state, and feature markers. When disabled, `run_code` and `edit_run_code` use DSH's native tool cards. This setting affects presentation only.
|
|
133
|
+
|
|
134
|
+
“Allow `run_code` execution without a summary” is on by default. Code still executes when the model omits the outer `description`; with enhanced tool cards enabled, the UI shows a fallback summary. When this setting is disabled, DSH validates the field normally. This setting does not change model requests or original call arguments.
|
|
135
|
+
|
|
136
|
+
“Allow top-level function/class redeclarations” is independent from the existing variable-redeclaration switch and defaults to off. When enabled, a later cell can use an ordinary named `function` or `class` declaration to replace an existing writable binding. Replacement takes effect at the declaration position and does not emulate function hoisting. Imports, immutable `const` bindings, reserved names, and bindings with unknown provenance are still rejected before execution. Live changes affect subsequently submitted cells; cold recovery always uses the policy recorded for each cell.
|
|
137
|
+
|
|
138
|
+
In an enabled `ptc` session, the header shows a green `PTC Plus` indicator. Hover, focus, or click it to inspect the variables, functions, classes, and imports available to the next cell and expand their bounded definition source. The card reads submitted source only; it does not inspect runtime values, trigger getters, or execute code. `run_code` and `edit_run_code` remain expandable in the conversation body. A feature marker appears only when result metadata proves that the feature affected that execution.
|
|
139
|
+
|
|
140
|
+

|
|
141
|
+
|
|
142
|
+
*A real session: “Reusable REPL bindings” shows the bindings available to the next cell.*
|
|
143
|
+
|
|
144
|
+
Every setting applies live and keeps existing bindings. A submitted cell uses one configuration for its complete execution; changes made while it runs apply to cells submitted afterward. A failed change rolls back. Node fixes a worker's V8 old-generation limit when the worker starts, so that one setting is rejected while a session worker is active and can be changed after the session is disposed. A failed enable is rolled back and persisted as disabled.
|
|
145
|
+
|
|
146
|
+
`cordisToolsEnabled` is off by default. Turning it on atomically adds DSH's official Cordis tools, owner guidance, and exactly the `cordis-plugin-development` companion Skill to PTC agents; sibling Skills in the shipped preset are not exposed. Turning it off removes all three. It neither switches presets nor changes the direct `run_code`/`edit_run_code` surface. Cordis runs model-written plugins against the live DSH runtime, so enabling it requires shell-level trust.
|
|
147
|
+
|
|
148
|
+
When a Cordis call rejects after a cell has assigned a large host or client source string, that top-level binding remains live. Retry only the Cordis call from a short later cell and reuse the binding instead of resending the source.
|
|
149
|
+
|
|
150
|
+
After cold recovery or re-enabling Cordis, recorded Cordis values remain journal data but do not prove that process-local Plugins, Runs, approvals, or earlier Inspect observations are still live. PTC Plus adds a bounded recovery context until a new successful Cordis Inspect call validates the current process.
|
|
151
|
+
|
|
152
|
+
See [Client UI](docs/client-ui.md), [ADR 0019](docs/adr/0019-plugin-settings-and-kill-switch.md), and [ADR 0020](docs/adr/0020-optional-cordis-tools-in-ptc-mode.md).
|
|
153
|
+
|
|
154
|
+
## Scope
|
|
155
|
+
|
|
156
|
+
PTC Plus provides the session-bound persistent `run_code` layer. DSH and the operating system continue to own native-tool authority, policy, approval, cancellation, sandboxing and process governance.
|
|
157
|
+
|
|
158
|
+
## Install
|
|
159
|
+
|
|
160
|
+
Requires Node.js `^22.19.0 || >=24.0.0` and DSH with TypeScript PTC mode. Install the published package from npm into the profile you use:
|
|
161
|
+
|
|
162
|
+
```sh
|
|
163
|
+
dsh plugin --profile <profile> add dsh-ptc-plus
|
|
164
|
+
dsh --profile <profile> --dump-config
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
Restart that DSH profile after installation. Version-pinned npm, GitHub, local-checkout, and tarball installs are covered in the [installation guide](docs/installation.md).
|
|
168
|
+
|
|
169
|
+
For Windows development, double-click `scripts\run-dev-dsh.cmd` to launch an isolated DSH installation from the latest `alpha` dist-tag with only this plugin installed. DSH, plugin snapshots, and the pnpm store are cached and old entries are pruned automatically. The launcher de-duplicates Windows `PATH` in the current process only; it creates no drive mappings or junction trees and does not change the system environment. If a genuinely unique PATH remains too long for `cmd.exe`, it stops before npm or DSH runs and asks you to shorten PATH. When no Web port is supplied, the launcher selects a free loopback port so an existing service on 3080 cannot block the test instance. The default cache is `%LOCALAPPDATA%\dsh-ptc-plus-dev`, outside this repository. See the [installation guide](docs/installation.md) for overrides.
|
|
170
|
+
|
|
171
|
+
`danger-full-access` is the primary supported experience. The worker isolates lifecycle, not malicious code.
|
|
172
|
+
|
|
173
|
+
## Documentation
|
|
174
|
+
|
|
175
|
+
[Installation](docs/installation.md) · [Runtime reference](docs/runtime-reference.md) · [Architecture](docs/architecture.md) · [Publishing](docs/publishing.md) · [All docs](docs/README.md)
|
|
176
|
+
|
|
177
|
+
MIT licensed. See [LICENSE](LICENSE).
|
package/README.md
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
<p align="center">
|
|
2
|
-
<img src="assets/dsh-ptc-plus-banner-
|
|
2
|
+
<img src="assets/dsh-ptc-plus-banner-zh.webp" width="100%" alt="dsh-ptc-plus 横幅">
|
|
3
3
|
</p>
|
|
4
4
|
|
|
5
5
|
<p align="center">
|
|
6
|
-
<strong
|
|
7
|
-
<a href="README.
|
|
6
|
+
<strong>简体中文</strong> ·
|
|
7
|
+
<a href="README.en.md">English</a>
|
|
8
8
|
</p>
|
|
9
9
|
|
|
10
10
|
<p align="center">
|
|
11
|
-
<a href="
|
|
12
|
-
<a href="
|
|
13
|
-
<a href="
|
|
14
|
-
<a href="
|
|
15
|
-
<a href="
|
|
16
|
-
<a href="
|
|
11
|
+
<a href="#%E9%BB%98%E8%AE%A4-ptc-%E6%A8%A1%E5%BC%8F%E7%9A%84%E9%97%AE%E9%A2%98">问题</a> ·
|
|
12
|
+
<a href="#%E4%B8%89%E4%B8%AA%E6%9C%80%E7%9B%B4%E6%8E%A5%E7%9A%84%E5%9C%BA%E6%99%AF">场景</a> ·
|
|
13
|
+
<a href="#%E8%AE%BE%E7%BD%AE">设置</a> ·
|
|
14
|
+
<a href="#%E8%8C%83%E5%9B%B4">范围</a> ·
|
|
15
|
+
<a href="#%E5%AE%89%E8%A3%85">安装</a> ·
|
|
16
|
+
<a href="#%E6%96%87%E6%A1%A3">文档</a>
|
|
17
17
|
</p>
|
|
18
18
|
|
|
19
19
|
<p align="center">
|
|
@@ -24,44 +24,44 @@
|
|
|
24
24
|
</p>
|
|
25
25
|
|
|
26
26
|
<p align="center">
|
|
27
|
-
<a href="https://awesome-dsh-plugin.com/"><img alt="Awesome DSH Plugin" src="https://awesome-dsh-plugin.com/badge.svg"></a>
|
|
27
|
+
<a href="https://awesome-dsh-plugin.com/zh/"><img alt="Awesome DSH Plugin" src="https://awesome-dsh-plugin.com/badge.svg"></a>
|
|
28
28
|
</p>
|
|
29
29
|
|
|
30
30
|
---
|
|
31
31
|
|
|
32
|
-
**PTC Plus
|
|
32
|
+
**PTC Plus 给 DSH 的 PTC 模式一个会话绑定的持久 TypeScript REPL。** 每次 `run_code` 都在同一个会话里继续。上一次 `run_code` 的变量、导入和结果,下一次还能直接用。
|
|
33
33
|
|
|
34
34
|
> [!NOTE]
|
|
35
|
-
>
|
|
35
|
+
> 社区插件,与 DeepSeek 或 DSH 无隶属、无背书。
|
|
36
36
|
|
|
37
37
|
> [!IMPORTANT]
|
|
38
|
-
>
|
|
38
|
+
> 面向 `danger-full-access` 设计:可直接访问 Node.js 与操作系统,不另加沙箱。仅在可接受此权限的环境使用。
|
|
39
39
|
|
|
40
|
-

|
|
41
41
|
|
|
42
|
-
|
|
42
|
+
*设置卡片展示即时配置和 `enabled` 开关。*
|
|
43
43
|
|
|
44
|
-
##
|
|
44
|
+
## 默认 PTC 模式的问题
|
|
45
45
|
|
|
46
|
-
DSH PTC
|
|
46
|
+
DSH 的 PTC 模式让每次 `run_code` 都从新环境开始。模型算过的东西,下一次还要重发。写错一行,整段代码重发。这个插件把 `run_code` 接到一个会话级环境里,后面的调用直接复用之前的东西。
|
|
47
47
|
|
|
48
|
-
|
|
|
49
|
-
| --- | ---
|
|
50
|
-
|
|
|
51
|
-
|
|
|
52
|
-
|
|
|
53
|
-
|
|
|
54
|
-
|
|
|
55
|
-
|
|
|
56
|
-
|
|
|
57
|
-
|
|
|
58
|
-
|
|
|
48
|
+
| 场景 | 默认 PTC 模式 | 使用 PTC Plus |
|
|
49
|
+
| --- | --- |----------------------------|
|
|
50
|
+
| 状态 | 每次从零开始,setup 重发 ❌ | 上一次 `run_code` 的结果直接能用 ✅ |
|
|
51
|
+
| 修错 | 结果不对或失败,整段重发 ❌ | 只发一行 diff ✅ |
|
|
52
|
+
| 模块 | `import` / `export` 不能写 ❌ | 照常写,后台 AST 重写 ✅ |
|
|
53
|
+
| 值 | JSON 改掉或丢失特殊值 ❌ | 这些值原样保留 ✅ |
|
|
54
|
+
| 重启 | 重启后一切丢失 ❌ | 能恢复的会回来 ✅ |
|
|
55
|
+
| 输出报错 | 大打印刷屏,报错指到别处 ❌ | 输出裁剪,报错回错的行 ✅ |
|
|
56
|
+
| 工具 | 列表看不见,顶层误发失败 ❌ | 可查看;可确定的误发自动转 `run_code` ✅ |
|
|
57
|
+
| 路径 | 相对路径可能跑偏 ❌ | session 记住项目目录 ✅ |
|
|
58
|
+
| agent 工具 | 需要当前 agent 的工具被拒绝 ❌ | 恢复上下文,goal 等可调 ✅ |
|
|
59
59
|
|
|
60
|
-
##
|
|
60
|
+
## 三个最直接的场景
|
|
61
61
|
|
|
62
|
-
###
|
|
62
|
+
### 状态跨调用
|
|
63
63
|
|
|
64
|
-
|
|
64
|
+
第一个 `run_code` 算完:
|
|
65
65
|
|
|
66
66
|
```ts
|
|
67
67
|
import { readFile } from 'node:fs/promises'
|
|
@@ -70,92 +70,108 @@ const deps = Object.keys(manifest.dependencies ?? {})
|
|
|
70
70
|
return deps.length
|
|
71
71
|
```
|
|
72
72
|
|
|
73
|
-
|
|
73
|
+
第二个直接接着用:
|
|
74
74
|
|
|
75
75
|
```ts
|
|
76
76
|
return deps.map(dep => dep + '@' + manifest.dependencies[dep])
|
|
77
77
|
```
|
|
78
78
|
|
|
79
|
-
`deps`
|
|
79
|
+
`deps` 和 `manifest` 还在。setup 代码只发一次。
|
|
80
80
|
|
|
81
|
-
###
|
|
81
|
+
### 修错不重发
|
|
82
82
|
|
|
83
|
-
|
|
83
|
+
默认情况下,结果不对或执行失败,模型只能把整个代码块再发一遍。
|
|
84
84
|
|
|
85
|
-
|
|
85
|
+
PTC Plus 下它只发这一行:
|
|
86
86
|
|
|
87
87
|
```ts
|
|
88
88
|
edit_run_code({ edits: [{ old_string: 'deps.length', new_string: 'deps' }] })
|
|
89
89
|
```
|
|
90
90
|
|
|
91
|
-
|
|
91
|
+
模型只发改动,完整源码留在对话之外。精确文本替换和正则替换都有限制,坏的正则不会卡住。
|
|
92
92
|
|
|
93
|
-
|
|
93
|
+
当被拒 cell 的末尾可唯一验证为缺少一个闭合符时,诊断会直接给出应用该修正并重运行所需的完整 `edit_run_code(...)` 调用。生成的调用带有 `expected_target_call_seq` 前置条件;如果另一个 cell 已先成为 edit 目标,它会拒绝且不执行。PTC Plus 不会自动应用这项建议;有歧义或没有持久目标身份的修复仍需提交修正后的源码。
|
|
94
94
|
|
|
95
|
-
###
|
|
95
|
+
### 模块语法
|
|
96
96
|
|
|
97
|
-
DSH PTC
|
|
97
|
+
DSH 的 PTC 模式把每个 `run_code` 当作 async function body 执行,静态 `import` 和 `export` 声明在这个函数体里无效。PTC Plus 会在执行前用 AST 分析适配这些形式。
|
|
98
98
|
|
|
99
|
-
|
|
99
|
+
模型照常写:
|
|
100
100
|
|
|
101
101
|
```ts
|
|
102
102
|
import { readFile } from 'node:fs/promises'
|
|
103
103
|
```
|
|
104
104
|
|
|
105
|
-
|
|
105
|
+
依赖从项目解析,具名和默认导入保持 live 且只读。模型不需要知道 `run_code` 其实是一个函数体。
|
|
106
106
|
|
|
107
|
-
##
|
|
107
|
+
## 一次配对实测
|
|
108
108
|
|
|
109
|
-
|
|
109
|
+
一次身份盲化的配对实验使用了 `opencode-go/deepseek-v4-flash`。两个 arm 使用同一版本夹具、任务 prompt、权限,每个任务重复两次,每个 arm 共 18 个 session。
|
|
110
110
|
|
|
111
|
-
|
|
|
111
|
+
| 9 个任务合计 | PTC Plus | DSH PTC 模式(未启用 PTC Plus) | 本次观测变化 |
|
|
112
112
|
| --- | ---: | ---: | ---: |
|
|
113
|
-
|
|
|
114
|
-
|
|
|
115
|
-
| Token
|
|
116
|
-
|
|
|
113
|
+
| 模型请求 | 66 | 88 | 减少 25.0% |
|
|
114
|
+
| 工具调用 | 50 | 79 | 减少 36.7% |
|
|
115
|
+
| Token 流量 | 729,642 | 942,901 | 减少 22.6% |
|
|
116
|
+
| 身份盲评量表得分 | 138 / 162 | 118 / 162 | 提高 12.3 个百分点 |
|
|
117
117
|
|
|
118
|
-
|
|
118
|
+
模块语法任务的区分最清楚:PTC Plus 两次都只用一次 `run_code` 完成;未启用 PTC Plus 的 DSH PTC 模式两次都未满足静态 import 要求,尝试过程合计用了 8 次工具调用。
|
|
119
119
|
|
|
120
|
-
|
|
120
|
+
这是一次有随机性的配对观测,不是性能保证。预设机器预算在 PTC Plus 的 18 个 session 中有 2 个超限,未启用 PTC Plus 的 18 个 session 中有 5 个超限,因此整组矩阵没有通过 machine acceptance。Token 流量包含 input、cache-read、cache-write 和 output token。夹具、配对规则、指标与盲评流程见[评测说明](docs/evaluation.md)。
|
|
121
121
|
|
|
122
|
-

|
|
123
123
|
|
|
124
|
-
|
|
124
|
+
*真实会话:长代码与真实的 `edit_run_code` 修复调用;修复从未重发源码。*
|
|
125
125
|
|
|
126
|
-
##
|
|
126
|
+
## 设置
|
|
127
127
|
|
|
128
|
-
|
|
128
|
+
打开 **设置 → 插件配置** 使用上面的设置卡片。卡片跟随 DSH 界面语言:界面设为 English 时显示英文,设为中文时显示中文。`enabled` 是即时生效的总开关:关闭后只保留卡片和这个开关,开启后恢复 session runtime 以及 `run_code`/`edit_run_code`。
|
|
129
129
|
|
|
130
|
-
|
|
130
|
+
设置按常用与兼容性、可选能力、高级行为和资源限制分区;需要主动决策的选项位于前面,资源限制位于后面。
|
|
131
131
|
|
|
132
|
-
|
|
132
|
+
“使用 PTC Plus 增强工具卡片”默认开启,提供可展开的源码、结果、执行状态和功能标记。关闭后,`run_code` 与 `edit_run_code` 使用 DSH 原生工具卡片;这个开关只影响显示。
|
|
133
133
|
|
|
134
|
-
|
|
134
|
+
“允许执行缺少摘要的 `run_code`”默认开启。模型没有提供外层 `description` 时,代码仍会执行;启用增强工具卡片时,界面显示备用摘要。关闭本设置后按 DSH 原生规则校验。这个开关不改变模型请求或原始调用参数。
|
|
135
135
|
|
|
136
|
-
|
|
136
|
+
“允许顶层函数/类重声明”与已有的变量重声明开关相互独立,默认关闭。开启后,后续 cell 可以用普通 named `function` / `class` 声明替换已有的可写 binding;替换在声明所在位置生效,不模拟函数提升。import、不可写 `const`、保留名称和来源不明的 binding 仍会在执行前拒绝。开关变化只影响随后提交的 cell,cold recovery 始终按每个 cell 已记录的策略重放。
|
|
137
137
|
|
|
138
|
-
|
|
138
|
+
插件启用且会话使用 `ptc` preset 时,会话头部显示绿色 `PTC Plus` 标识。悬浮、聚焦或点击后可以查看下一 cell 可复用的变量、函数、类和 import,并展开其有界定义源码。卡片只读取已提交的源码,不读取运行时值、不触发 getter,也不执行代码。正文中的 `run_code` 与 `edit_run_code` 仍可展开查看源码和结果;只有结果 metadata 能证明某项功能确实生效时,预览才显示对应标记。
|
|
139
139
|
|
|
140
|
-
|
|
140
|
+

|
|
141
141
|
|
|
142
|
-
|
|
142
|
+
*真实会话:“REPL 可复用绑定”卡片展示下一 cell 可直接复用的 binding。*
|
|
143
143
|
|
|
144
|
-
|
|
144
|
+
所有设置都会实时应用,并保留已有 binding。已提交的 cell 在完整执行期间使用同一份配置;执行期间发生的更新用于随后提交的 cell。更新失败会回滚。Node 在 worker 创建时固定 V8 old-generation 上限,因此活动 session worker 存在时修改这一项会被拒绝,释放 session 后才能修改。启用失败时,运行时会回滚并把设置保持为停用。
|
|
145
145
|
|
|
146
|
-
|
|
146
|
+
`cordisToolsEnabled` 默认关闭。打开后,DSH 官方 Cordis 工具、owner guidance 与精确的 `cordis-plugin-development` companion Skill 会作为一个整体加入 PTC agent;同一 shipped preset 目录中的其他 Skill 不会随之暴露。关闭时这三项也会一起移除;它不切换 preset,也不改变 `run_code`/`edit_run_code` 的直接调用面。Cordis 能在实时 DSH runtime 中运行模型编写的插件,开启它需要接受 shell 级信任。
|
|
147
|
+
|
|
148
|
+
如果 Cordis 调用在 cell 已经赋值大段 host 或 client 源码之后才失败,这些顶层 binding 仍会保留。后续只需在短 cell 中重试 Cordis 调用并复用该 binding,无需再次传输源码。
|
|
149
|
+
|
|
150
|
+
cold recovery 或重新启用 Cordis 后,已记录的 Cordis value 仍是历史数据,但不能证明进程内 Plugin、Run、approval 或先前 Inspect observation 仍然存活。PTC Plus 会提供有界恢复 context,直到一次新的成功 Cordis Inspect 调用验证当前进程。
|
|
151
|
+
|
|
152
|
+
详见 [客户端 UI](docs/client-ui.md)、[ADR 0019](docs/adr/0019-plugin-settings-and-kill-switch.md) 与 [ADR 0020](docs/adr/0020-optional-cordis-tools-in-ptc-mode.md)。
|
|
153
|
+
|
|
154
|
+
## 范围
|
|
155
|
+
|
|
156
|
+
PTC Plus 提供会话绑定的持久 `run_code` 层。原生工具的权限、策略、审批、取消、sandbox 和进程治理仍由 DSH 与操作系统负责。
|
|
157
|
+
|
|
158
|
+
## 安装
|
|
159
|
+
|
|
160
|
+
要求 Node.js `^22.19.0 || >=24.0.0`,并已安装带 TypeScript PTC 模式的 DSH。把 npm 正式包安装到你实际使用的 profile:
|
|
147
161
|
|
|
148
162
|
```sh
|
|
149
163
|
dsh plugin --profile <profile> add dsh-ptc-plus
|
|
150
164
|
dsh --profile <profile> --dump-config
|
|
151
165
|
```
|
|
152
166
|
|
|
153
|
-
|
|
167
|
+
安装后重启对应的 DSH profile。固定 npm 版本、GitHub、本地 checkout 和 tarball 安装方式见[安装指南](docs/installation.md)。
|
|
168
|
+
|
|
169
|
+
Windows 开发时可双击 `scripts\run-dev-dsh.cmd` 启动一个独立的 DSH alpha 最新版并只安装本插件。脚本会缓存 DSH、插件快照和 pnpm 依赖,仅在版本或源码内容变化时更新,并自动清理旧缓存;它会在当前进程内去重 Windows `PATH`,不会创建盘符映射、目录联接或修改系统环境;如果去重后仍超过 `cmd.exe` 限制,会在运行 npm/DSH 前直接提示缩短 PATH。Web 未指定端口时会自动选择空闲回环端口,不会因 3080 被占用而失败。缓存默认位于 `%LOCALAPPDATA%\dsh-ptc-plus-dev`,不会写入本仓库。详细选项见[安装指南](docs/installation.md)。
|
|
154
170
|
|
|
155
|
-
`danger-full-access`
|
|
171
|
+
`danger-full-access` 是首要支持方式。worker 只隔离生命周期,不隔离恶意代码。
|
|
156
172
|
|
|
157
|
-
##
|
|
173
|
+
## 文档
|
|
158
174
|
|
|
159
|
-
[
|
|
175
|
+
[安装指南](docs/installation.md) · [运行时参考](docs/runtime-reference.md) · [架构](docs/architecture.md) · [发布](docs/publishing.md) · [全部文档](docs/README.md)
|
|
160
176
|
|
|
161
|
-
MIT
|
|
177
|
+
使用 [MIT License](LICENSE)。
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|