dsh-ptc-plus 0.3.2 → 0.4.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/README.en.md +65 -78
- package/README.md +65 -78
- 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 +30596 -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 +554 -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 +6 -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 +73 -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 +25 -10
- package/docs/evaluation.md +78 -6
- package/docs/installation.md +41 -6
- package/docs/publishing.md +5 -3
- package/docs/runtime-reference.md +72 -25
- package/docs/semantic-validation.md +29 -0
- package/docs/stateful-binding-updates-proposal.md +755 -0
- package/docs/user-bindings.en.md +64 -0
- package/docs/user-bindings.md +64 -0
- package/docs/value-wire.md +3 -3
- package/docs/verification.md +57 -0
- package/index.js +369 -92
- package/internal/ast-traversal.js +5 -2
- 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 +391 -0
- package/internal/binding-update-policy.js +66 -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 +240 -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 +84 -0
- package/internal/compiler-module-links.js +34 -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 +87 -0
- package/internal/dynamic-environment-runtime.js +362 -0
- package/internal/dynamic-native-calls.js +150 -0
- package/internal/dynamic-native-runtime.js +248 -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 +118 -18
- package/internal/host-rpc.js +66 -0
- package/internal/isolated-worker.js +548 -0
- package/internal/kernel-child.js +139 -0
- package/internal/kernel-worker.js +904 -120
- 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 +321 -0
- package/internal/module-runtime-platform.js +19 -0
- package/internal/module-transform-contract.js +12 -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/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 +114 -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-messages.js +111 -0
- package/internal/session-cell-executor.js +401 -87
- package/internal/session-journal-recovery.js +684 -0
- package/internal/session-journal-schema.js +106 -0
- package/internal/session-journal.js +184 -654
- package/internal/session-log-view.js +42 -9
- package/internal/session-runtime.js +256 -95
- package/internal/session-state.js +247 -71
- package/internal/source-position-map.js +211 -71
- package/internal/stateful-module-compiler.js +154 -0
- package/internal/stateful-module-runtime.js +303 -0
- package/internal/stateful-root-compiler.js +598 -0
- package/internal/stateful-root-runtime.js +340 -0
- package/internal/typert-codec-compat.js +28 -0
- package/internal/typescript-transform.js +29 -0
- package/internal/user-binding-authoring.js +70 -0
- package/internal/user-binding-console-worker.js +184 -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 +353 -0
- package/internal/value-wire-schema.js +28 -0
- package/internal/value-wire.js +29 -20
- package/internal/worker-client.js +57 -67
- package/internal/worker-environment.js +45 -0
- package/internal/worker-output-relay.js +29 -0
- package/internal/worker-shutdown.js +14 -0
- package/package.json +75 -7
- package/src/client-activity.js +88 -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,83 @@ 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
|
-
|
|
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.
|
|
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.
|
|
94
102
|
|
|
95
|
-
|
|
103
|
+

|
|
96
104
|
|
|
97
|
-
|
|
105
|
+
### Have the Agent author a reusable helper
|
|
98
106
|
|
|
99
|
-
|
|
107
|
+
Enable **Global User Bindings** in settings, then enter:
|
|
100
108
|
|
|
101
|
-
```
|
|
102
|
-
|
|
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 |
|
|
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.
|
|
117
115
|
|
|
118
|
-
The
|
|
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.
|
|
119
117
|
|
|
120
|
-
|
|
118
|
+
Before the first message, hover over or click the sparkle button to view and toggle global bindings. These choices apply to all sessions, while the entry itself is registered 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 from static references in later cells' compiled source, and a redeclaration never resets them.
|
|
121
119
|
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
*A real session: the long code and the truthful `edit_run_code` repair call. The repair never resends the source.*
|
|
120
|
+
Enabled binding interfaces are supplied to the model in new sessions and updated at the next permitted request in an existing session. 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
|
-
|
|
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.
|
|
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: on the current release, find the plugin's entry on the side-bar **Plugins** page and choose **Configure**; on the preceding release, open **Settings → Plugin configuration → PTC Plus**. The main switch controls the plugin; other settings are grouped by purpose:
|
|
131
125
|
|
|
132
|
-
|
|
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. The five legacy switches apply only while migrating an old configuration; the settings page identifies that state and lets you choose either unified policy directly. Module syntax is enabled by default. `tools` and the injected error classes are request-reserved program bindings that can be neither redeclared nor written: a declaration collision reports `PTC-N001` in preflight, and an assignment fails during execution with an error that names the binding instead of being discarded silently.
|
|
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.
|
|
133
133
|
|
|
134
|
-
|
|
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.
|
|
135
135
|
|
|
136
|
-
|
|
136
|
+
PTC Plus uses a shared stateful computation contract for `run_code`, `edit_run_code`, plugin-owned child computation, and user binding entry points. Source passed to `eval`, `Function`, `node:vm`, or other external engines retains the corresponding native syntax rules and results. Direct `eval` must still access its caller's logical scope; indirect `eval` and `Function` use their owning realm's logical root. Internal name rewriting must not change which state they read. The module interface and native interoperability boundary are described in [ADR 0025](docs/adr/0025-use-versioned-logical-binding-identities.md#managed-module-interface).
|
|
137
137
|
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-

|
|
138
|
+
Indirect `eval` and all four `Function` constructors use their owning realm's root, including when passed as native callbacks: after `const value=41`, `["typeof value"].map(eval)` returns `["number"]`. Function source observations retain original JavaScript source and its actual dependencies, so self-contained functions can be recompiled with `Function`. Function values, user overrides, and separately created realms retain their respective semantics.
|
|
141
139
|
|
|
142
|
-
|
|
140
|
+
Switching computation modes preserves existing closures' execution environments and saved function identities, including direct `eval` in asynchronous continuations and `Function.prototype.toString`. Each source generation selects stable callback interfaces while global and prototype properties retain their original values. Legacy code reuses established logical bindings through its native REPL environment, with existing native declarations retaining precedence, and reads modules through PTC-managed namespaces.
|
|
143
141
|
|
|
144
|
-
|
|
142
|
+

|
|
145
143
|
|
|
146
|
-
|
|
144
|
+
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
145
|
|
|
148
|
-
|
|
146
|
+

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

|
|
153
151
|
|
|
154
152
|
## Scope
|
|
155
153
|
|
|
156
|
-
|
|
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).
|
|
154
|
+
DSH continues to own tool permissions, approvals, cancellation, and sandbox policy. Session evaluation runs in a plugin-owned helper process; a stuck or unresponsive helper is reclaimed there, and DSH does not perform an in-host worker kill. 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
155
|
|
|
169
|
-
|
|
156
|
+
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
157
|
|
|
171
|
-
|
|
158
|
+
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
159
|
|
|
173
160
|
## Documentation
|
|
174
161
|
|
|
175
|
-
[Installation](docs/installation.md) · [Runtime reference](docs/runtime-reference.md) · [
|
|
162
|
+
[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
163
|
|
|
177
|
-
MIT
|
|
164
|
+
[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
|
+
```
|
|
45
47
|
|
|
46
|
-
DSH
|
|
48
|
+
无需修改 DSH 或使用定制版本。其他安装方式、升级和故障排查见[安装指南](docs/installation.md)。
|
|
49
|
+
|
|
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,83 @@ 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
|
-
|
|
92
|
-
|
|
93
|
-
当被拒 cell 的末尾可唯一验证为缺少一个闭合符时,诊断会直接给出应用该修正并重运行所需的完整 `edit_run_code(...)` 调用。生成的调用带有 `expected_target_call_seq` 前置条件;如果另一个 cell 已先成为 edit 目标,它会拒绝且不执行。PTC Plus 不会自动应用这项建议;有歧义或没有持久目标身份的修复仍需提交修正后的源码。
|
|
101
|
+
编辑会重新执行完整 cell。已经写文件或调用外部服务的代码,仍需确认可以安全重试。语法错误会指出位置;能够明确定位的末尾缺符号错误还会给出修正建议。
|
|
94
102
|
|
|
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
|
-
|
|
106
|
-
|
|
107
|
-
## 一次配对实测
|
|
114
|
+
Agent 可以在会话 REPL 中用内存样例逐步测试和修正,再交出草稿;编写时的测试不得修改外部文件或服务。草稿在输入框上方展开,你可以检查源码和模型提示词,选择“保存为停用”“保存并启用”或“丢弃草稿”。测试和提交本身不会保存全局绑定。
|
|
108
115
|
|
|
109
|
-
|
|
116
|
+
草稿面板可折叠或关闭,输入框星光按钮上的角标可重新打开。保存或丢弃成功后自动关闭,历史请求保留当时的源码和结果。
|
|
110
117
|
|
|
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 个百分点 |
|
|
118
|
+
会话开始前也可以悬停或点击星光按钮,查看并启停全局绑定;这些选择对所有会话生效,但该入口只在当前会话使用 `ptc` 或兼容 `code` preset 时注册。菜单同时提供编写新绑定、修改已有绑定、完整管理入口和 PTC Plus 设置快捷入口;设置快捷入口直接打开包含全部插件配置的应用内窗口,悬浮提示仍标明宿主原生设置页的路径。REPL 可复用绑定列表按后续 cell 源码中的静态引用显示每项复用次数和总复用次数,重定义或重声明不会清零。
|
|
117
119
|
|
|
118
|
-
|
|
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 原生工具卡片;这个开关只影响显示。
|
|
124
|
+
可以从输入框旁的星光菜单选择 **PTC Plus 设置**,直接打开完整设置窗口。宿主原生入口也保留:当前 DSH 在侧栏 **Plugins** 页面里找到本插件的条目并点 **Configure**,旧版 DSH 在 **设置 → 插件配置 → PTC Plus**。总开关控制插件,其余设置按用途分组:
|
|
133
125
|
|
|
134
|
-
|
|
126
|
+
- **调用容错**:允许缺少摘要的 `run_code`,修复可以准确识别的顶层工具误调用。
|
|
127
|
+
- **REPL 语法**:`bindingUpdates` 默认是 `stateful`,允许跨 cell 更新变量、函数、类和 import alias,也允许同一 cell 内同一逻辑 scope 的重复声明更新同一身份;`protected` 可选择名称保护。`tools` 与注入的错误类是请求保留的程序绑定,既不能重声明也不能写入:冲突在 preflight 报 `PTC-N001`,赋值在执行时以指明该名称的错误失败,不会静默丢弃。旧版五个细分开关仅在迁移旧配置时生效;设置页明确显示尚未迁移的状态,可直接选择任一种统一策略。模块语法默认可用。
|
|
128
|
+
- **模块互操作**:PTC 管理的 namespace 支持实时读取和局部覆盖,传给外部函数后仍保留这些语义。外部代码自行原生导入编译模块不承诺同一 namespace 或可写导出语义,详见[运行时说明](docs/runtime-reference.md#cell-semantics)。
|
|
129
|
+
- **状态与恢复**:控制重启恢复和按需错误提示。
|
|
130
|
+
- **工具扩展**:开启全局绑定,或供高级用户使用的官方 Cordis 工具。
|
|
131
|
+
- **界面显示**:控制增强工具卡片、REPL 页签和绑定编写快捷入口。
|
|
132
|
+
- **资源限制**:调整执行时间、内存和输出上限。
|
|
135
133
|
|
|
136
|
-
|
|
134
|
+
全局绑定与 Cordis 工具默认关闭。设置通常即时生效;活动 worker 存在时不能更改其内存上限。字段、默认值和限制见[配置参考](docs/runtime-reference.md#configuration)。
|
|
137
135
|
|
|
138
|
-
|
|
136
|
+
PTC Plus 对 `run_code`、`edit_run_code`、插件自有子计算及用户绑定入口使用共同的有状态计算契约。用户主动调用 `eval`、`Function`、`node:vm` 或其他外部引擎时,动态源码保留对应的原生语法规则与结果;直接 `eval` 仍须访问调用处的逻辑作用域,间接 `eval` 和 `Function` 使用所属 realm 的逻辑根环境,不能因内部名称改写而读错状态。模块接口与原生互操作边界见 [ADR 0025](docs/adr/0025-use-versioned-logical-binding-identities.md#managed-module-interface)。
|
|
139
137
|
|
|
140
|
-
|
|
138
|
+
间接 `eval` 和四种 `Function` 构造器使用所属 realm 的 root,作为原生回调传递时也一样,例如 `const value=41` 后的 `["typeof value"].map(eval)` 返回 `["number"]`。函数源码观察保留原始 JavaScript 源码及其真实依赖,自包含函数可用 `Function` 重新编译;函数值本身、用户改写和另外创建的 realm 保持各自语义。
|
|
141
139
|
|
|
142
|
-
|
|
140
|
+
切换计算模式时,旧闭包仍保留原有执行环境和已保存的函数身份,包括异步继续执行中的直接 `eval` 与 `Function.prototype.toString`。各代源码取得稳定的回调接口,全局和原型属性保持原值;兼容模式通过原生 REPL 环境复用已有逻辑绑定,原有原生声明仍优先,其模块导入也通过 PTC 管理的 namespace 读取。
|
|
143
141
|
|
|
144
|
-
|
|
142
|
+

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

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

|
|
153
151
|
|
|
154
152
|
## 范围
|
|
155
153
|
|
|
156
|
-
|
|
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)。
|
|
154
|
+
DSH 继续负责工具权限、审批、取消和沙箱策略。会话求值运行在插件自有的 helper 进程内;卡住或无响应的 helper 会被回收,DSH 宿主进程不执行 in-host worker 强杀。PTC Plus 不保证所有状态都能跨重启恢复;外部输入、无法验证的历史或上下文压缩都可能缩小恢复范围。恢复不会重做或撤销历史外部操作。
|
|
168
155
|
|
|
169
|
-
|
|
156
|
+
值预览有大小和类型限制,无法可靠读取的对象会显示“不可读取”。绑定的启用配置也不等于初始化一定成功,具体失败会在执行结果中说明。更多行为见[运行时参考](docs/runtime-reference.md)。
|
|
170
157
|
|
|
171
|
-
|
|
158
|
+
模型调用和 token 用量取决于任务与模型;已有配对观测及其限制见[评测说明](docs/evaluation.md#recorded-paired-observation)。
|
|
172
159
|
|
|
173
160
|
## 文档
|
|
174
161
|
|
|
175
|
-
[
|
|
162
|
+
[全局绑定使用指南](docs/user-bindings.md) · [安装与升级](docs/installation.md) · [运行时参考](docs/runtime-reference.md) · [开发与架构](docs/architecture.md) · [验证与测试并发](docs/verification.md) · [全部文档](docs/README.md)
|
|
176
163
|
|
|
177
164
|
使用 [MIT License](LICENSE)。
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|