dsh-ptc-plus 0.3.2 → 0.4.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 +63 -80
- package/README.md +63 -80
- 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-repair-zh.png +0 -0
- package/assets/ptc-plus-repl-workspace-en.png +0 -0
- package/assets/ptc-plus-repl-workspace-zh.png +0 -0
- package/assets/ptc-plus-settings-en.png +0 -0
- package/assets/ptc-plus-settings-zh.png +0 -0
- package/client.js +30827 -742
- package/compiler-amaro.cjs +5 -0
- package/compiler-amaro.cjs.map +6 -0
- package/compiler-asset-124f80c1bba92ff5fe79cfec6e8ad518f476de4a42514cae3919538887f510e8.txt +1 -0
- package/compiler-assets.json +3 -0
- package/compiler-core.cjs +556 -0
- package/compiler-core.cjs.map +6 -0
- package/compiler-platform.cjs +2 -0
- package/compiler-platform.cjs.map +6 -0
- package/compiler-typescript.cjs +388 -0
- package/compiler-typescript.cjs.map +6 -0
- package/docs/README.md +7 -0
- package/docs/adr/0004-declare-program-bindings-at-the-host.md +1 -1
- package/docs/adr/0006-rewrite-module-syntax-with-an-ast.md +5 -3
- package/docs/adr/0007-separate-worker-transport-from-session-semantics.md +1 -1
- package/docs/adr/0009-bound-expensive-acceptance-default.md +2 -0
- package/docs/adr/0010-session-log-derived-recovery-tips.md +59 -5
- package/docs/adr/0011-isolate-the-local-recovery-tip-provider.md +1 -1
- package/docs/adr/0012-preserve-mixed-destructuring-initialization.md +3 -1
- package/docs/adr/0013-isolate-repl-redeclaration-convenience.md +3 -1
- package/docs/adr/0014-persist-cell-rewrite-policy.md +6 -2
- package/docs/adr/0015-preserve-source-positions-through-rewrites.md +1 -1
- package/docs/adr/0016-archive-resolved-review-findings.md +1 -1
- package/docs/adr/0017-track-the-latest-dsh-public-surface.md +49 -0
- package/docs/adr/0018-use-versioned-fixture-for-ab-benchmark.md +3 -3
- package/docs/adr/0019-plugin-settings-and-kill-switch.md +5 -3
- package/docs/adr/0020-optional-cordis-tools-in-ptc-mode.md +2 -2
- package/docs/adr/0021-separate-host-bootstrap-from-session-runtime.md +12 -0
- package/docs/adr/0023-global-user-bindings.md +104 -0
- package/docs/adr/0024-repl-console-observation.md +33 -0
- package/docs/adr/0025-use-versioned-logical-binding-identities.md +119 -0
- package/docs/adr/0026-persist-the-delivery-verdict-against-the-verified-candidate.md +21 -0
- package/docs/adr/0027-run-the-session-kernel-in-a-killable-helper-process.md +37 -0
- package/docs/adr/0028-attach-to-the-host-ptc-execution-seam.md +103 -0
- package/docs/adr/0029-keep-plugin-unavailability-out-of-the-host-agent-lifecycle.md +27 -0
- package/docs/adr/0030-serve-both-typert-codec-generations-from-one-codec.md +27 -0
- package/docs/architecture.md +77 -21
- package/docs/binding-review-placement-design.md +200 -0
- package/docs/capability-projection.md +1 -1
- package/docs/client-ui.md +95 -19
- package/docs/durability-design.md +28 -10
- package/docs/evaluation.md +78 -6
- package/docs/installation.md +41 -6
- package/docs/publishing.md +5 -3
- package/docs/runtime-reference.md +76 -25
- package/docs/semantic-validation.md +29 -0
- package/docs/stateful-binding-updates-proposal.md +759 -0
- package/docs/user-bindings.en.md +66 -0
- package/docs/user-bindings.md +66 -0
- package/docs/value-wire.md +3 -3
- package/docs/verification-optimization-work.md +41 -0
- package/docs/verification.md +71 -0
- package/index.js +369 -92
- package/internal/ast-traversal.js +5 -2
- package/internal/async-local-storage-intrinsics.js +38 -0
- package/internal/binding-declaration-contract.js +8 -0
- package/internal/binding-descriptors.js +1 -0
- package/internal/binding-pattern-traversal.js +25 -0
- package/internal/binding-pattern.js +26 -29
- package/internal/binding-source-analysis.js +708 -0
- package/internal/binding-update-policy.js +72 -0
- package/internal/bounded-worker-round.js +56 -0
- package/internal/callable-definition-environment.js +42 -0
- package/internal/callable-source-catalog.js +129 -0
- package/internal/callable-source-encoding.js +47 -0
- package/internal/callable-source-facts.js +459 -0
- package/internal/callable-source-format.js +2 -0
- package/internal/callable-source-lowering.js +123 -0
- package/internal/cell-analysis-contract.js +25 -0
- package/internal/cell-analysis.js +253 -290
- package/internal/cell-completion.js +15 -0
- package/internal/cell-error.js +7 -0
- package/internal/cell-parser.js +66 -0
- package/internal/cell-rewriter.js +3 -677
- package/internal/commonjs-export-evidence.js +63 -0
- package/internal/commonjs-source-evidence.js +72 -0
- package/internal/compiler-amaro.cjs +2 -0
- package/internal/compiler-compression.js +12 -0
- package/internal/compiler-data.js +58 -0
- package/internal/compiler-descriptors.js +54 -0
- package/internal/compiler-dynamic-cache.js +48 -0
- package/internal/compiler-entry.js +35 -0
- package/internal/compiler-generated-names.js +17 -0
- package/internal/compiler-intrinsics.js +50 -0
- package/internal/compiler-module-links.js +37 -0
- package/internal/compiler-operations.js +61 -0
- package/internal/compiler-platform-factory.js +84 -0
- package/internal/compiler-platform.js +136 -0
- package/internal/compiler-record-roles.js +53 -0
- package/internal/compiler-region-output.js +259 -0
- package/internal/compiler-resource-lowering.js +103 -0
- package/internal/compiler-scope-facts.js +115 -0
- package/internal/compiler-service.js +109 -0
- package/internal/compiler-source-cache.js +32 -0
- package/internal/compiler-source-pieces.js +93 -0
- package/internal/compiler-source-regions.js +132 -0
- package/internal/compiler-storage-source.js +54 -0
- package/internal/compiler-text.js +15 -0
- package/internal/compiler-typescript.cjs +2 -0
- package/internal/config-spec.js +83 -27
- package/internal/cordis-tools-owner.js +130 -21
- package/internal/diagnostic.js +27 -1
- package/internal/direct-surface-owner.js +76 -23
- package/internal/dynamic-binding-evidence.js +16 -0
- package/internal/dynamic-environment-compiler.js +779 -0
- package/internal/dynamic-environment-integration.js +91 -0
- package/internal/dynamic-environment-runtime.js +383 -0
- package/internal/dynamic-native-calls.js +153 -0
- package/internal/dynamic-native-runtime.js +262 -0
- package/internal/dynamic-scope-analysis.js +90 -0
- package/internal/edit-transport-owner.js +27 -2
- package/internal/execution-seam-compat.js +193 -0
- package/internal/failure-reporting.js +136 -28
- package/internal/host-rpc.js +66 -0
- package/internal/isolated-worker.js +555 -0
- package/internal/kernel-child.js +139 -0
- package/internal/kernel-worker.js +1179 -233
- package/internal/language-semantics.js +14 -0
- package/internal/legacy-binding-catalog.js +48 -0
- package/internal/legacy-cell-analysis.js +600 -0
- package/internal/legacy-cell-parser.js +50 -0
- package/internal/legacy-cell-rewriter.js +631 -0
- package/internal/legacy-repl-convenience.js +291 -0
- package/internal/managed-module-operations.js +170 -0
- package/internal/module-compilation.js +322 -0
- package/internal/module-runtime-platform.js +19 -0
- package/internal/module-transform-contract.js +42 -0
- package/internal/native-await-declarations.js +68 -0
- package/internal/native-root-compilation.js +54 -0
- package/internal/native-root-dynamic.js +67 -0
- package/internal/record-utils.js +24 -15
- package/internal/recovery-tips.js +27 -15
- package/internal/rejected-cell-editor.js +13 -8
- package/internal/repl-convenience.js +2 -289
- package/internal/repl-memory-projection.js +81 -12
- package/internal/repl-observation-interest.js +70 -0
- package/internal/repl-rewrite-contract.js +6 -0
- package/internal/repl-scope-normalizer.js +2091 -0
- package/internal/repl-value-observer.js +117 -0
- package/internal/rpc-contract.js +52 -0
- package/internal/runtime-bridge-owner.js +172 -28
- package/internal/runtime-config.js +48 -52
- package/internal/runtime-contexts.js +82 -10
- package/internal/runtime-intrinsics.js +101 -0
- package/internal/runtime-messages.js +111 -0
- package/internal/session-cell-executor.js +402 -87
- package/internal/session-journal-recovery.js +684 -0
- package/internal/session-journal-schema.js +123 -0
- package/internal/session-journal.js +199 -654
- package/internal/session-log-view.js +42 -9
- package/internal/session-runtime.js +257 -95
- package/internal/session-state.js +247 -71
- package/internal/source-position-map.js +230 -71
- package/internal/stateful-module-compiler.js +154 -0
- package/internal/stateful-module-runtime.js +303 -0
- package/internal/stateful-root-compiler.js +600 -0
- package/internal/stateful-root-runtime.js +340 -0
- package/internal/typert-codec-compat.js +28 -0
- package/internal/typescript-transform.js +31 -0
- package/internal/user-binding-authoring.js +70 -0
- package/internal/user-binding-console-worker.js +244 -0
- package/internal/user-binding-console.js +148 -0
- package/internal/user-binding-draft-projection.js +335 -0
- package/internal/user-binding-model-context.js +31 -0
- package/internal/user-binding-runner.js +56 -0
- package/internal/user-bindings-owner.js +1065 -0
- package/internal/user-bindings-store.js +293 -0
- package/internal/user-bindings.js +361 -0
- package/internal/value-wire-schema.js +28 -0
- package/internal/value-wire.js +130 -91
- package/internal/worker-client.js +57 -67
- package/internal/worker-cwd-virtualization.js +80 -53
- package/internal/worker-environment.js +65 -0
- package/internal/worker-output-relay.js +29 -0
- package/internal/worker-repl-realm.js +134 -0
- package/internal/worker-shutdown.js +14 -0
- package/package.json +76 -7
- package/src/client-activity.js +95 -53
- package/src/client-authoring-view.js +580 -0
- package/src/client-binding-review.js +230 -0
- package/src/client-bindings-data.js +29 -0
- package/src/client-catalog.js +127 -0
- package/src/client-code-editor.js +84 -0
- package/src/client-console.js +112 -0
- package/src/client-copy.js +370 -0
- package/src/client-feature-gates.js +62 -0
- package/src/client-host-compat.js +150 -0
- package/src/client-indicator-view.js +267 -0
- package/src/client-repl-view.js +292 -0
- package/src/client-rpc.js +20 -0
- package/src/client-settings-view.js +221 -0
- package/src/client-styles.js +106 -0
- package/src/client-tool-view.js +108 -0
- package/src/client-transport.js +159 -0
- package/src/client-workbench.js +521 -0
- package/src/client.js +233 -615
package/README.en.md
CHANGED
|
@@ -29,39 +29,51 @@
|
|
|
29
29
|
|
|
30
30
|
---
|
|
31
31
|
|
|
32
|
-
**PTC Plus gives DSH PTC mode a
|
|
32
|
+
**PTC Plus gives DSH PTC mode a persistent TypeScript REPL.** Variables, imports, and computed results from one `run_code` remain available to the next. By default, revise names directly: existing closures observe updated bindings, imports can be overridden and re-imported, and failed declarations do not permanently occupy a name.
|
|
33
33
|
|
|
34
34
|
> [!NOTE]
|
|
35
|
-
> Community plugin, no affiliation with or endorsement from DeepSeek or DSH.
|
|
35
|
+
> Community plugin, with no affiliation with or endorsement from DeepSeek or DSH.
|
|
36
36
|
|
|
37
37
|
> [!IMPORTANT]
|
|
38
|
-
> Built for `danger-full-access`:
|
|
38
|
+
> Built for `danger-full-access`: code can access Node.js and the operating system directly. The plugin adds no sandbox. Use it where that permission scope is acceptable.
|
|
39
39
|
|
|
40
|
-
|
|
40
|
+
## Install
|
|
41
|
+
|
|
42
|
+
Requires Node.js `^22.19.0 || >=24.0.0` and official DSH with TypeScript PTC mode. Install into your profile, restart DSH, and select PTC mode:
|
|
43
|
+
|
|
44
|
+
```sh
|
|
45
|
+
dsh plugin --profile <profile> add dsh-ptc-plus
|
|
46
|
+
```
|
|
41
47
|
|
|
42
|
-
|
|
48
|
+
No DSH modifications or custom build are required. See the [installation guide](docs/installation.md) for other installation methods, upgrades, and troubleshooting.
|
|
43
49
|
|
|
44
50
|
## What default PTC mode gets wrong
|
|
45
51
|
|
|
46
|
-
|
|
52
|
+
Default PTC mode starts each execution in a fresh environment, so the model must resend setup code. PTC Plus keeps the session's computation state available for subsequent calls.
|
|
47
53
|
|
|
48
|
-
|
|
|
54
|
+
| Scenario | Default PTC mode | With PTC Plus |
|
|
49
55
|
| --- | --- | --- |
|
|
50
|
-
|
|
|
51
|
-
|
|
|
52
|
-
|
|
|
53
|
-
|
|
|
54
|
-
|
|
|
55
|
-
|
|
|
56
|
-
|
|
|
57
|
-
|
|
|
58
|
-
|
|
|
56
|
+
| Continue a calculation | Each call starts fresh and needs the setup code again | Reuse existing variables, functions, imports, and results directly |
|
|
57
|
+
| Fix one mistake | Resend the complete corrected code | Send only the changes with `edit_run_code`, then execute the complete corrected cell |
|
|
58
|
+
| Use module syntax | Static `import` and `export` are invalid inside the function body | Write them directly in cells; the plugin adapts them |
|
|
59
|
+
| Pass special values | JSON cannot fully represent `undefined`, BigInt, cycles, and similar values | Preserve supported special values and reference relationships for further computation and recovery |
|
|
60
|
+
| Find an available tool | Look through the tool interfaces supplied to the model | List and search tools from code, then inspect their parameters as needed |
|
|
61
|
+
| Omit a call summary | Missing `run_code.description` fails validation | Supply a display summary automatically so valid code can proceed |
|
|
62
|
+
| Recover a top-level tool miscall | Undeclared top-level calls are rejected in PTC mode | Convert a miscall to `run_code` when current tool definitions uniquely identify its target and validate the arguments |
|
|
63
|
+
| Access project files | Relative Node paths depend on the host process directory | Resolve file paths, modules, and the default child-process directory from the recorded session project |
|
|
64
|
+
| Locate a code error | Return the native error and stack | Map errors to cell source positions; suggest an edit when a single missing closing delimiter has one verified correction |
|
|
65
|
+
| Inspect computation state | No reusable session variables remain after execution | Inspect retained variables, definitions, and bounded value previews in the REPL tab |
|
|
66
|
+
| Author and reuse helpers | Save the code yourself and load it again in later calls | Author drafts with `/binding`, review them above the composer, and save; enabled bindings work across sessions and supply their interfaces to the model |
|
|
67
|
+
| Try a helper manually | No dedicated code workbench for global bindings | Run unsaved source, test it across successive inputs, and inspect results in a workbench with temporary state separate from the Agent session |
|
|
68
|
+
| Continue after a restart | No computation state spans calls for recovery | Restore verifiable state from the session record and report what could not be recovered |
|
|
69
|
+
|
|
70
|
+
Global bindings must be enabled in settings. See [Settings](#settings) and [Scope](#scope) below for optional behavior and recovery limits.
|
|
59
71
|
|
|
60
72
|
## Three scenes that matter most
|
|
61
73
|
|
|
62
74
|
### State carries over
|
|
63
75
|
|
|
64
|
-
|
|
76
|
+
The model first executes:
|
|
65
77
|
|
|
66
78
|
```ts
|
|
67
79
|
import { readFile } from 'node:fs/promises'
|
|
@@ -70,108 +82,79 @@ const deps = Object.keys(manifest.dependencies ?? {})
|
|
|
70
82
|
return deps.length
|
|
71
83
|
```
|
|
72
84
|
|
|
73
|
-
The next
|
|
85
|
+
The next call continues directly:
|
|
74
86
|
|
|
75
87
|
```ts
|
|
76
88
|
return deps.map(dep => dep + '@' + manifest.dependencies[dep])
|
|
77
89
|
```
|
|
78
90
|
|
|
79
|
-
`deps` and `manifest`
|
|
91
|
+
`deps` and `manifest` remain in the current session. No repeated setup is needed.
|
|
80
92
|
|
|
81
93
|
### Fix without resending
|
|
82
94
|
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
With PTC Plus, it sends one line:
|
|
95
|
+
The model can submit just the replacement:
|
|
86
96
|
|
|
87
97
|
```ts
|
|
88
98
|
edit_run_code({ edits: [{ old_string: 'deps.length', new_string: 'deps' }] })
|
|
89
99
|
```
|
|
90
100
|
|
|
91
|
-
|
|
101
|
+
Editing reruns the entire cell. Code that has written files or called external services still requires a safe retry. Syntax errors identify the location; an unambiguous missing closing delimiter can also receive a correction suggestion.
|
|
92
102
|
|
|
93
|
-
|
|
103
|
+

|
|
94
104
|
|
|
95
|
-
###
|
|
105
|
+
### Have the Agent author a reusable helper
|
|
96
106
|
|
|
97
|
-
|
|
107
|
+
Enable **Global User Bindings** in settings, then enter:
|
|
98
108
|
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
import { readFile } from 'node:fs/promises'
|
|
109
|
+
```text
|
|
110
|
+
/binding new Create textTools to trim outer whitespace while preserving interior spaces
|
|
111
|
+
/binding edit <id> Add line-by-line trimming
|
|
103
112
|
```
|
|
104
113
|
|
|
105
|
-
|
|
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.
|
|
114
|
+
The Agent can test and revise the helper incrementally with in-memory REPL examples before submitting a draft. Authoring tests must not modify external files or services. The draft opens above the composer, where you can inspect its source and model prompt, then choose **Save as disabled**, **Save and enable**, or **Discard draft**. Testing and submission do not save a global binding.
|
|
119
115
|
|
|
120
|
-
|
|
116
|
+
The panel can be collapsed or closed; the sparkle button's badge reopens it. A successful save or discard closes the panel automatically. The original request retains its source and outcome in history.
|
|
121
117
|
|
|
122
|
-
|
|
118
|
+
Before the first message, hover over or click the sparkle button to view and toggle global bindings. These choices apply to all sessions. The shortcut appears only while the current session uses the `ptc` or compatible `code` preset. The menu also provides new-binding authoring, existing-binding revision, full management, and a PTC Plus settings shortcut. The settings shortcut opens an in-app dialog containing every plugin setting, while its hover hint still names the host's native settings path. The reusable REPL binding list shows per-binding and total reuse counts, and a redeclaration never resets them.
|
|
123
119
|
|
|
124
|
-
|
|
120
|
+
Enabled binding interfaces are supplied to the model in new sessions and updated at the next permitted request in an existing session. A source-derived interface retains standard global types, referenced local types, representable class heritage, and class instance fields used by its public signatures; abstract classes remain non-constructable, and an imported type that cannot form a self-contained interface produces an explicit error before save. Each binding can include a separate usage prompt or omit its interface. Changing only the prompt preserves the helper's runtime state. Assigning or redeclaring one name in a session overrides only that name; the entry's other names keep working, and the session-local override never writes back to the saved entry. See the [global binding guide](docs/user-bindings.en.md) for details.
|
|
125
121
|
|
|
126
122
|
## Settings
|
|
127
123
|
|
|
128
|
-
|
|
124
|
+
Choose **PTC Plus settings** in the sparkle menu beside the composer to open the complete settings dialog directly. The host's native entry remains available. Depending on the DSH interface, find the plugin on the side-bar **Plugins** page and choose **Configure**, or open **Settings → Plugin configuration → PTC Plus**. The main switch controls the plugin; other settings are grouped by purpose:
|
|
129
125
|
|
|
130
|
-
|
|
126
|
+
- **Tool call tolerance**: accept `run_code` without a summary and repair uniquely identifiable top-level native-tool miscalls.
|
|
127
|
+
- **REPL syntax**: `bindingUpdates` defaults to `stateful`, allowing cross-cell updates of variables, functions, classes, and import aliases, and letting a repeated declaration in one logical scope of one cell update the same identity; choose `protected` to keep name protection. `tools` and the injected error classes can be neither redeclared nor written: a declaration collision reports `PTC-N001`, and a failed assignment names the affected binding. Existing configurations that still contain five separate switches appear as pending migration, and the settings page lets you choose either unified policy directly. Module syntax is enabled by default.
|
|
128
|
+
- **Module interoperability**: PTC-managed namespaces support live reads and local overrides, including when passed to external functions. External code independently importing a compiled module through native APIs does not receive the same namespace or writable-export guarantee. See the [runtime reference](docs/runtime-reference.md#cell-semantics).
|
|
129
|
+
- **State and recovery**: control restart recovery and contextual error tips.
|
|
130
|
+
- **Tool extensions**: enable global bindings or official Cordis tools for advanced use.
|
|
131
|
+
- **Interface display**: control enhanced tool cards, the REPL tab, and the binding authoring shortcut.
|
|
132
|
+
- **Resource limits**: adjust execution time, memory, and output limits.
|
|
131
133
|
|
|
132
|
-
|
|
134
|
+
Global bindings and Cordis tools default to off. Settings generally apply immediately; a worker's memory limit cannot change while it is active. See the [configuration reference](docs/runtime-reference.md#configuration) for fields, defaults, and limits.
|
|
133
135
|
|
|
134
|
-
|
|
136
|
+
`run_code`, `edit_run_code`, binding workbench runs, and user binding execution follow the same stateful semantics. Within each computation environment, cells, PTC-managed modules, `require`, and binding modules share the worker's Node realm, so `Error` subclass checks and `globalThis` writes retain Node behavior. Explicit use of `eval`, `Function`, `node:vm`, or an independent runtime retains its native boundary. Changing the binding update policy does not rewrite the execution environment of existing closures and functions. See the [runtime reference](docs/runtime-reference.md#cell-semantics) for scope, source observation, module interoperability, and recorded-session compatibility rules.
|
|
135
137
|
|
|
136
|
-
|
|
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.
|
|
138
|
+

|
|
145
139
|
|
|
146
|
-
|
|
140
|
+
The **REPL** tab lets you search session bindings, inspect definitions, and manage global bindings. The global binding workbench's code console can run unsaved source with independent temporary state. File and network operations performed there still have real effects.
|
|
147
141
|
|
|
148
|
-
|
|
142
|
+

|
|
149
143
|
|
|
150
|
-
|
|
144
|
+
On wide screens, the green **PTC Plus** header indicator offers a quick binding list. On narrow screens, use the **REPL** tab:
|
|
151
145
|
|
|
152
|
-
|
|
146
|
+

|
|
153
147
|
|
|
154
148
|
## Scope
|
|
155
149
|
|
|
156
|
-
PTC Plus
|
|
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).
|
|
150
|
+
DSH continues to own tool permissions, approvals, cancellation, and sandbox policy. PTC Plus evaluates session code in a reclaimable helper process, so stuck or unresponsive computation can be terminated without ending DSH; this process boundary is not a security sandbox. Electron Desktop compatibility does not change the environment visible to evaluated code or its child processes. PTC Plus cannot recover every state across restarts: external inputs, unverifiable history, and context compaction can reduce the recovered state. Recovery neither repeats nor reverses historical external operations.
|
|
168
151
|
|
|
169
|
-
|
|
152
|
+
Value previews have size and type limits; objects that cannot be read reliably appear as unavailable. An enabled binding can also fail initialization, with failures reported in execution results. See the [runtime reference](docs/runtime-reference.md) for details.
|
|
170
153
|
|
|
171
|
-
|
|
154
|
+
Model calls and token usage depend on the task and model. A recorded paired observation and its limitations are in the [evaluation guide](docs/evaluation.md#recorded-paired-observation).
|
|
172
155
|
|
|
173
156
|
## Documentation
|
|
174
157
|
|
|
175
|
-
[Installation](docs/installation.md) · [Runtime reference](docs/runtime-reference.md) · [
|
|
158
|
+
[Global binding guide](docs/user-bindings.en.md) · [Installation and upgrades](docs/installation.md) · [Runtime reference](docs/runtime-reference.md) · [Development and architecture](docs/architecture.md) · [Verification and test concurrency](docs/verification.md) · [All documentation](docs/README.md)
|
|
176
159
|
|
|
177
|
-
MIT
|
|
160
|
+
[MIT License](LICENSE).
|
package/README.md
CHANGED
|
@@ -29,39 +29,51 @@
|
|
|
29
29
|
|
|
30
30
|
---
|
|
31
31
|
|
|
32
|
-
**PTC Plus
|
|
32
|
+
**PTC Plus 让 DSH 的 PTC 模式拥有连续的 TypeScript REPL。** 上一次 `run_code` 的变量、导入和计算结果,下一次可以直接复用。默认允许直接同名修订:已有闭包读取更新后的绑定,导入可被局部覆盖再重新导入,失败的声明不会永久占住名称。
|
|
33
33
|
|
|
34
34
|
> [!NOTE]
|
|
35
35
|
> 社区插件,与 DeepSeek 或 DSH 无隶属、无背书。
|
|
36
36
|
|
|
37
37
|
> [!IMPORTANT]
|
|
38
|
-
> 面向 `danger-full-access`
|
|
38
|
+
> 面向 `danger-full-access` 设计:代码可直接访问 Node.js 与操作系统,插件不另加沙箱。仅在可接受此权限的环境使用。
|
|
39
39
|
|
|
40
|
-
|
|
40
|
+
## 安装
|
|
41
41
|
|
|
42
|
-
|
|
42
|
+
需要 Node.js `^22.19.0 || >=24.0.0` 和支持 TypeScript PTC 模式的官方 DSH。安装到你使用的 profile,然后重启 DSH 并选择 PTC 模式:
|
|
43
43
|
|
|
44
|
-
|
|
44
|
+
```sh
|
|
45
|
+
dsh plugin --profile <profile> add dsh-ptc-plus
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
无需修改 DSH 或使用定制版本。其他安装方式、升级和故障排查见[安装指南](docs/installation.md)。
|
|
45
49
|
|
|
46
|
-
|
|
50
|
+
## 默认 PTC 模式的问题
|
|
47
51
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
|
51
|
-
|
|
|
52
|
-
|
|
|
53
|
-
|
|
|
54
|
-
|
|
|
55
|
-
|
|
|
56
|
-
|
|
|
57
|
-
|
|
|
58
|
-
|
|
|
52
|
+
默认 PTC 模式每次执行都从新环境开始,模型需要重新发送准备代码。PTC Plus 保留会话中的计算状态,让后续调用可以接着完成任务。
|
|
53
|
+
|
|
54
|
+
| 场景 | 默认 PTC 模式 | 使用 PTC Plus |
|
|
55
|
+
| --- | --- | --- |
|
|
56
|
+
| 接着上次计算 | 每次从新环境开始,需重发准备代码 | 直接复用已有变量、函数、导入和结果 |
|
|
57
|
+
| 修改一处错误 | 修正后重新发送整段代码 | 用 `edit_run_code` 只发修改内容,再执行修正后的完整代码 |
|
|
58
|
+
| 使用模块语法 | 函数体内不能直接写静态 `import`、`export` | 在 cell 中直接写,插件自动适配 |
|
|
59
|
+
| 传递特殊值 | JSON 无法完整表达 `undefined`、BigInt、循环引用等 | 在支持的值范围内保留特殊值及引用关系,供后续计算与恢复 |
|
|
60
|
+
| 查找可用工具 | 从提供给模型的工具接口说明中查找 | 可在代码中列出、搜索工具,并按需查看参数说明 |
|
|
61
|
+
| 调用漏填摘要 | 缺少 `run_code.description` 时校验失败 | 自动补充显示摘要,合法代码可继续执行 |
|
|
62
|
+
| 误发顶层工具调用 | PTC 模式下未声明的顶层调用被拒绝 | 当前工具定义能唯一确认目标且参数合法时,自动转为 `run_code` |
|
|
63
|
+
| 访问项目文件 | Node 相对路径依赖宿主进程目录 | 按会话记录的项目目录解析文件路径、模块和默认子进程目录 |
|
|
64
|
+
| 定位代码错误 | 返回原生错误与堆栈 | 对应到 cell 源码位置;末尾缺少单个闭合符且修正可唯一验证时,给出编辑建议 |
|
|
65
|
+
| 查看计算状态 | 执行结束后不保留可继续使用的会话变量 | REPL 页签展示保留的变量、定义来源和有界值预览 |
|
|
66
|
+
| 编写并复用 helper | 需自行保存代码,并在后续执行中重新加载 | 用 `/binding` 编写草稿,在输入框上方审阅后保存;启用后跨会话使用,并向模型提供接口说明 |
|
|
67
|
+
| 手动试运行 helper | 没有全局绑定的专用代码工作台 | 在工作台运行未保存源码,连续测试并查看结果,临时状态与 Agent 会话分开 |
|
|
68
|
+
| 重启后继续 | 没有跨调用的计算状态可恢复 | 从会话记录恢复可验证的状态,无法恢复的部分明确提示 |
|
|
69
|
+
|
|
70
|
+
全局绑定需在设置中开启;其余可选行为和恢复范围见下方[设置](#设置)与[范围](#范围)。
|
|
59
71
|
|
|
60
72
|
## 三个最直接的场景
|
|
61
73
|
|
|
62
74
|
### 状态跨调用
|
|
63
75
|
|
|
64
|
-
|
|
76
|
+
模型第一次执行:
|
|
65
77
|
|
|
66
78
|
```ts
|
|
67
79
|
import { readFile } from 'node:fs/promises'
|
|
@@ -70,108 +82,79 @@ const deps = Object.keys(manifest.dependencies ?? {})
|
|
|
70
82
|
return deps.length
|
|
71
83
|
```
|
|
72
84
|
|
|
73
|
-
|
|
85
|
+
下一次直接接着用:
|
|
74
86
|
|
|
75
87
|
```ts
|
|
76
88
|
return deps.map(dep => dep + '@' + manifest.dependencies[dep])
|
|
77
89
|
```
|
|
78
90
|
|
|
79
|
-
`deps` 和 `manifest`
|
|
91
|
+
`deps` 和 `manifest` 仍在当前会话里,无需重发准备代码。
|
|
80
92
|
|
|
81
93
|
### 修错不重发
|
|
82
94
|
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
PTC Plus 下它只发这一行:
|
|
95
|
+
模型可以只提交替换内容:
|
|
86
96
|
|
|
87
97
|
```ts
|
|
88
98
|
edit_run_code({ edits: [{ old_string: 'deps.length', new_string: 'deps' }] })
|
|
89
99
|
```
|
|
90
100
|
|
|
91
|
-
|
|
101
|
+
编辑会重新执行完整 cell。已经写文件或调用外部服务的代码,仍需确认可以安全重试。语法错误会指出位置;能够明确定位的末尾缺符号错误还会给出修正建议。
|
|
92
102
|
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
### 模块语法
|
|
103
|
+

|
|
96
104
|
|
|
97
|
-
|
|
105
|
+
### 让 Agent 编写可复用 helper
|
|
98
106
|
|
|
99
|
-
|
|
107
|
+
在设置中开启“全局用户绑定”,然后输入:
|
|
100
108
|
|
|
101
|
-
```
|
|
102
|
-
|
|
109
|
+
```text
|
|
110
|
+
/binding new 创建 textTools,清理文本首尾空白,保留内部空格
|
|
111
|
+
/binding edit <id> 增加逐行清理功能
|
|
103
112
|
```
|
|
104
113
|
|
|
105
|
-
|
|
114
|
+
Agent 可以在会话 REPL 中用内存样例逐步测试和修正,再交出草稿;编写时的测试不得修改外部文件或服务。草稿在输入框上方展开,你可以检查源码和模型提示词,选择“保存为停用”“保存并启用”或“丢弃草稿”。测试和提交本身不会保存全局绑定。
|
|
106
115
|
|
|
107
|
-
|
|
116
|
+
草稿面板可折叠或关闭,输入框星光按钮上的角标可重新打开。保存或丢弃成功后自动关闭,历史请求保留当时的源码和结果。
|
|
108
117
|
|
|
109
|
-
|
|
118
|
+
会话开始前也可以悬停或点击星光按钮,查看并启停全局绑定;这些选择对所有会话生效。快捷入口只在当前会话使用 `ptc` 或兼容 `code` preset 时显示。菜单同时提供编写新绑定、修改已有绑定、完整管理入口和 PTC Plus 设置快捷入口;设置快捷入口直接打开包含全部插件配置的应用内窗口,悬浮提示仍标明宿主原生设置页的路径。REPL 可复用绑定列表显示每项复用次数和总复用次数,重定义或重声明不会清零。
|
|
110
119
|
|
|
111
|
-
|
|
112
|
-
| --- | ---: | ---: | ---: |
|
|
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
|
-
|
|
118
|
-
模块语法任务的区分最清楚:PTC Plus 两次都只用一次 `run_code` 完成;未启用 PTC Plus 的 DSH PTC 模式两次都未满足静态 import 要求,尝试过程合计用了 8 次工具调用。
|
|
119
|
-
|
|
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
|
-
|
|
122
|
-

|
|
123
|
-
|
|
124
|
-
*真实会话:长代码与真实的 `edit_run_code` 修复调用;修复从未重发源码。*
|
|
120
|
+
已启用绑定的接口会提供给新会话中的模型,也会在现有会话的下一次允许请求中更新。接口从源码保留公开签名引用的标准全局类型、本地类型、可表示的类继承链和类实例字段;抽象类仍不可直接构造,无法生成自足接口的导入类型会在保存前明确报错。每个绑定可以另写使用提示词,或关闭接口展示;仅改提示词不会重置 helper 的运行状态。在会话中给某个名字赋值或重声明只覆盖该名字,同一条目的其他名字继续可用,会话内的覆盖也不会写回保存的条目。详细操作见[全局绑定使用指南](docs/user-bindings.md)。
|
|
125
121
|
|
|
126
122
|
## 设置
|
|
127
123
|
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
设置按常用与兼容性、可选能力、高级行为和资源限制分区;需要主动决策的选项位于前面,资源限制位于后面。
|
|
131
|
-
|
|
132
|
-
“使用 PTC Plus 增强工具卡片”默认开启,提供可展开的源码、结果、执行状态和功能标记。关闭后,`run_code` 与 `edit_run_code` 使用 DSH 原生工具卡片;这个开关只影响显示。
|
|
133
|
-
|
|
134
|
-
“允许执行缺少摘要的 `run_code`”默认开启。模型没有提供外层 `description` 时,代码仍会执行;启用增强工具卡片时,界面显示备用摘要。关闭本设置后按 DSH 原生规则校验。这个开关不改变模型请求或原始调用参数。
|
|
124
|
+
可以从输入框旁的星光菜单选择 **PTC Plus 设置**,直接打开完整设置窗口。宿主原生入口也保留;根据 DSH 界面,可在侧栏 **Plugins** 页面找到本插件并点 **Configure**,或打开 **设置 → 插件配置 → PTC Plus**。总开关控制插件,其余设置按用途分组:
|
|
135
125
|
|
|
136
|
-
|
|
126
|
+
- **调用容错**:允许缺少摘要的 `run_code`,修复可以准确识别的顶层工具误调用。
|
|
127
|
+
- **REPL 语法**:`bindingUpdates` 默认是 `stateful`,允许跨 cell 更新变量、函数、类和 import alias,也允许同一 cell 内同一逻辑 scope 的重复声明更新同一身份;`protected` 可选择名称保护。`tools` 与注入的错误类不能重声明或写入:声明冲突报 `PTC-N001`,赋值失败时会指出对应名称。已有配置若仍含五个细分开关,设置页会显示待迁移状态,可直接选择任一种统一策略。模块语法默认可用。
|
|
128
|
+
- **模块互操作**:PTC 管理的 namespace 支持实时读取和局部覆盖,传给外部函数后仍保留这些语义。外部代码自行原生导入编译模块不承诺同一 namespace 或可写导出语义,详见[运行时说明](docs/runtime-reference.md#cell-semantics)。
|
|
129
|
+
- **状态与恢复**:控制重启恢复和按需错误提示。
|
|
130
|
+
- **工具扩展**:开启全局绑定,或供高级用户使用的官方 Cordis 工具。
|
|
131
|
+
- **界面显示**:控制增强工具卡片、REPL 页签和绑定编写快捷入口。
|
|
132
|
+
- **资源限制**:调整执行时间、内存和输出上限。
|
|
137
133
|
|
|
138
|
-
|
|
134
|
+
全局绑定与 Cordis 工具默认关闭。设置通常即时生效;活动 worker 存在时不能更改其内存上限。字段、默认值和限制见[配置参考](docs/runtime-reference.md#configuration)。
|
|
139
135
|
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
*真实会话:“REPL 可复用绑定”卡片展示下一 cell 可直接复用的 binding。*
|
|
136
|
+
`run_code`、`edit_run_code`、绑定试运行和用户绑定执行遵循同一套有状态语义。每个计算环境中的 cell、PTC 管理模块、`require` 和绑定模块共享该 worker 的 Node realm,因此 `Error` 子类判断与 `globalThis` 写入保持 Node 语义。显式使用 `eval`、`Function`、`node:vm` 或独立运行时仍遵循对应的原生边界;切换绑定更新策略不会改写已有闭包和函数的执行环境。完整的作用域、源码观察、模块互操作和已记录会话兼容规则见[运行时参考](docs/runtime-reference.md#cell-semantics)。
|
|
143
137
|
|
|
144
|
-
|
|
138
|
+

|
|
145
139
|
|
|
146
|
-
|
|
140
|
+
在 **REPL** 页签查看会话绑定、搜索名称和检查定义,也可以管理全局绑定。全局绑定工作台中的代码控制台支持试运行未保存的源码,拥有独立的临时状态;执行的文件或网络操作仍会产生真实效果。
|
|
147
141
|
|
|
148
|
-
|
|
142
|
+

|
|
149
143
|
|
|
150
|
-
|
|
144
|
+
宽屏下,会话头部的绿色 **PTC Plus** 标识提供快捷绑定清单;窄屏可从 **REPL** 页签查看:
|
|
151
145
|
|
|
152
|
-
|
|
146
|
+

|
|
153
147
|
|
|
154
148
|
## 范围
|
|
155
149
|
|
|
156
|
-
PTC Plus
|
|
157
|
-
|
|
158
|
-
## 安装
|
|
159
|
-
|
|
160
|
-
要求 Node.js `^22.19.0 || >=24.0.0`,并已安装带 TypeScript PTC 模式的 DSH。把 npm 正式包安装到你实际使用的 profile:
|
|
161
|
-
|
|
162
|
-
```sh
|
|
163
|
-
dsh plugin --profile <profile> add dsh-ptc-plus
|
|
164
|
-
dsh --profile <profile> --dump-config
|
|
165
|
-
```
|
|
166
|
-
|
|
167
|
-
安装后重启对应的 DSH profile。固定 npm 版本、GitHub、本地 checkout 和 tarball 安装方式见[安装指南](docs/installation.md)。
|
|
150
|
+
DSH 继续负责工具权限、审批、取消和沙箱策略。PTC Plus 在可回收的 helper 进程中执行会话代码,因此卡住或无响应的计算可以在不结束 DSH 的情况下终止;这一进程边界不是安全沙箱。Electron Desktop 兼容处理不会改变求值代码及其子进程看到的环境。PTC Plus 不保证所有状态都能跨重启恢复;外部输入、无法验证的历史或上下文压缩都可能缩小恢复范围。恢复不会重做或撤销历史外部操作。
|
|
168
151
|
|
|
169
|
-
|
|
152
|
+
值预览有大小和类型限制,无法可靠读取的对象会显示“不可读取”。绑定的启用配置也不等于初始化一定成功,具体失败会在执行结果中说明。更多行为见[运行时参考](docs/runtime-reference.md)。
|
|
170
153
|
|
|
171
|
-
|
|
154
|
+
模型调用和 token 用量取决于任务与模型;已有配对观测及其限制见[评测说明](docs/evaluation.md#recorded-paired-observation)。
|
|
172
155
|
|
|
173
156
|
## 文档
|
|
174
157
|
|
|
175
|
-
[
|
|
158
|
+
[全局绑定使用指南](docs/user-bindings.md) · [安装与升级](docs/installation.md) · [运行时参考](docs/runtime-reference.md) · [开发与架构](docs/architecture.md) · [验证与测试并发](docs/verification.md) · [全部文档](docs/README.md)
|
|
176
159
|
|
|
177
160
|
使用 [MIT License](LICENSE)。
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|