dsh-ptc-plus 0.4.1 → 0.4.3

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.
Files changed (103) hide show
  1. package/README.en.md +164 -78
  2. package/README.md +165 -79
  3. package/assets/dsh-ptc-plus-banner-en.webp +0 -0
  4. package/assets/dsh-ptc-plus-banner-zh.webp +0 -0
  5. package/assets/ptc-plus-icon.svg +5 -0
  6. package/client.js +854 -336
  7. package/compiler-core.cjs +161 -157
  8. package/compiler-core.cjs.map +3 -3
  9. package/docs/README.md +4 -1
  10. package/docs/adr/0005-temporary-rejected-cell-edit-transport.md +8 -7
  11. package/docs/adr/0008-define-agent-operating-contract.md +2 -2
  12. package/docs/adr/0010-session-log-derived-recovery-tips.md +7 -0
  13. package/docs/adr/0016-archive-resolved-review-findings.md +3 -3
  14. package/docs/adr/0019-plugin-settings-and-kill-switch.md +3 -3
  15. package/docs/adr/0020-optional-cordis-tools-in-ptc-mode.md +2 -0
  16. package/docs/adr/0021-separate-host-bootstrap-from-session-runtime.md +14 -3
  17. package/docs/adr/0023-global-user-bindings.md +7 -7
  18. package/docs/adr/0025-use-versioned-logical-binding-identities.md +3 -3
  19. package/docs/adr/0026-persist-the-delivery-verdict-against-the-verified-candidate.md +23 -7
  20. package/docs/adr/0027-run-the-session-kernel-in-a-killable-helper-process.md +9 -5
  21. package/docs/adr/0028-attach-to-the-host-ptc-execution-seam.md +26 -6
  22. package/docs/adr/0031-close-semantic-obligations-by-owner.md +29 -0
  23. package/docs/adr/README.md +4 -4
  24. package/docs/architecture.md +15 -10
  25. package/docs/binding-review-placement-design.md +1 -1
  26. package/docs/client-ui.md +9 -5
  27. package/docs/durability-design.md +12 -9
  28. package/docs/installation.md +27 -9
  29. package/docs/runtime-reference.md +23 -12
  30. package/docs/semantic-validation.md +7 -3
  31. package/docs/stateful-binding-updates-proposal.md +8 -4
  32. package/docs/user-bindings.en.md +10 -7
  33. package/docs/user-bindings.md +9 -6
  34. package/docs/value-wire.md +1 -1
  35. package/docs/verification-optimization-work.md +41 -0
  36. package/docs/verification.md +53 -2
  37. package/index.js +39 -34
  38. package/internal/async-local-storage-intrinsics.js +43 -0
  39. package/internal/binding-declaration-contract.js +8 -0
  40. package/internal/binding-source-analysis.js +381 -64
  41. package/internal/binding-update-policy.js +7 -1
  42. package/internal/callable-source-facts.js +37 -1
  43. package/internal/cell-analysis.js +85 -17
  44. package/internal/compiler-intrinsics.js +9 -43
  45. package/internal/compiler-module-links.js +7 -4
  46. package/internal/config-spec.js +1 -1
  47. package/internal/cordis-tools-owner.js +20 -10
  48. package/internal/dynamic-environment-integration.js +8 -4
  49. package/internal/dynamic-environment-runtime.js +24 -3
  50. package/internal/dynamic-native-calls.js +4 -1
  51. package/internal/dynamic-native-runtime.js +15 -1
  52. package/internal/edit-transport-owner.js +80 -20
  53. package/internal/execution-seam-compat.js +192 -30
  54. package/internal/failure-reporting.js +38 -30
  55. package/internal/isolated-worker.js +17 -10
  56. package/internal/kernel-worker.js +645 -393
  57. package/internal/message-sources.js +14 -0
  58. package/internal/module-compilation.js +7 -5
  59. package/internal/module-transform-contract.js +32 -2
  60. package/internal/record-utils.js +24 -15
  61. package/internal/repl-memory-projection.js +10 -0
  62. package/internal/repl-scope-normalizer.js +72 -35
  63. package/internal/repl-value-observer.js +145 -46
  64. package/internal/runtime-config.js +62 -2
  65. package/internal/runtime-intrinsics.js +104 -0
  66. package/internal/runtime-messages.js +6 -4
  67. package/internal/session-cell-executor.js +26 -2
  68. package/internal/session-journal-recovery.js +267 -67
  69. package/internal/session-journal-schema.js +30 -13
  70. package/internal/session-journal.js +485 -44
  71. package/internal/session-log-view.js +5 -4
  72. package/internal/session-runtime.js +46 -21
  73. package/internal/session-state.js +7 -29
  74. package/internal/settings-compat.js +66 -1
  75. package/internal/source-position-map.js +38 -0
  76. package/internal/stateful-root-compiler.js +3 -1
  77. package/internal/typescript-transform.js +4 -2
  78. package/internal/user-binding-console-worker.js +115 -41
  79. package/internal/user-binding-draft-projection.js +3 -2
  80. package/internal/user-bindings-owner.js +2 -1
  81. package/internal/user-bindings.js +16 -3
  82. package/internal/validated-parse-repair.js +6 -2
  83. package/internal/value-wire.js +189 -94
  84. package/internal/worker-client.js +99 -8
  85. package/internal/worker-cwd-virtualization.js +82 -54
  86. package/internal/worker-environment.js +20 -0
  87. package/internal/worker-output-capture.js +187 -0
  88. package/internal/worker-output-fence.js +26 -0
  89. package/internal/worker-realm-surfaces.js +197 -0
  90. package/internal/worker-repl-realm.js +140 -0
  91. package/package.json +37 -4
  92. package/src/client-activity.js +12 -2
  93. package/src/client-authoring-view.js +121 -62
  94. package/src/client-console.js +4 -2
  95. package/src/client-copy.js +4 -2
  96. package/src/client-feature-gates.js +7 -9
  97. package/src/client-host-compat.js +104 -27
  98. package/src/client-repl-view.js +3 -1
  99. package/src/client-styles.js +12 -1
  100. package/src/client-tool-view.js +3 -1
  101. package/src/client-transport.js +2 -2
  102. package/src/client-workbench.js +4 -3
  103. package/src/client.js +56 -17
package/README.en.md CHANGED
@@ -1,24 +1,13 @@
1
1
  <p align="center">
2
- <img src="assets/dsh-ptc-plus-banner-en.webp" width="100%" alt="dsh-ptc-plus banner">
2
+ <img src="assets/dsh-ptc-plus-banner-en.webp" width="100%" alt="PTC Plus: No need to start over! Update it. Keep computing!">
3
3
  </p>
4
4
 
5
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>
6
+ <a href="README.md">简体中文</a> · <strong>English</strong>
17
7
  </p>
18
8
 
19
9
  <p align="center">
20
10
  <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
11
  <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
12
  <a href="LICENSE"><img alt="License: MIT" src="https://img.shields.io/badge/License-MIT-yellow.svg"></a>
24
13
  </p>
@@ -27,53 +16,132 @@
27
16
  <a href="https://awesome-dsh-plugin.com/"><img alt="Awesome DSH Plugin" src="https://awesome-dsh-plugin.com/badge.svg"></a>
28
17
  </p>
29
18
 
30
- ---
19
+ **Let the model keep computing and revise its work within a session, with less repeated setup and fewer avoidable tool-call errors.**
31
20
 
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.
21
+ PTC Plus provides a stateful TypeScript computation environment for DSH's **PTC mode**. Built on a REPL, it keeps variables, functions, imports, and intermediate results available across tool calls. It extends declaration update rules and adapts module syntax, with call tolerance and code editing designed for models that repeatedly write and revise code.
33
22
 
34
- > [!NOTE]
35
- > Community plugin, with no affiliation with or endorsement from DeepSeek or DSH.
23
+ - **Keep computing**: reuse data already loaded and processed in the session.
24
+ - **Revise directly**: update a variable or function under the same name; existing closures read the updated binding. Small changes can be sent as code deltas.
25
+ - **Avoid routine call failures**: use familiar module syntax, recover from identifiable call omissions, and receive correction suggestions for verifiable syntax errors.
26
+ - **Reuse common capabilities**: save functions as global bindings, provide their interfaces and usage notes to the model, and use them across sessions.
36
27
 
37
- > [!IMPORTANT]
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.
28
+ [Quick start](#quick-start) · [Feature overview](#feature-overview) · [Continuous computation](#continuous-computation-and-language-extensions) · [Editing and call tolerance](#code-editing-and-call-tolerance) · [Global bindings](#global-bindings-reuse-functions-across-sessions) · [Interface and settings](#interface-and-settings) · [Values and recovery](#value-transfer-and-state-recovery)
39
29
 
40
- ## Install
30
+ ## Quick start
41
31
 
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:
32
+ Requires Node.js `^22.19.0 || >=24.0.0` and the latest available official DSH release. Install into the profile you actually use:
43
33
 
44
34
  ```sh
45
35
  dsh plugin --profile <profile> add dsh-ptc-plus
46
36
  ```
47
37
 
48
- No DSH modifications or custom build are required. See the [installation guide](docs/installation.md) for other installation methods, upgrades, and troubleshooting.
38
+ Replace `<profile>` with your profile name. Restart DSH and select **PTC mode** in the session. Continuous computation, call tolerance, and global bindings default to on. Explicitly disabled options in an existing configuration stay disabled.
49
39
 
50
- ## What default PTC mode gets wrong
40
+ With the default interface settings, the session has a **REPL** tab; wide screens also show a green **PTC Plus** header indicator. The sparkle button beside the composer opens the global binding menu and **PTC Plus settings**. You can also open **Plugins → Installed → dsh-ptc-plus → Configure** in the sidebar to check the main switch and all plugin settings.
51
41
 
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.
42
+ Once installed, describe your task to the model as usual. The `run_code` and `edit_run_code` examples below show how the model uses these features. See the [installation guide](docs/installation.md) for other installation methods, Desktop, the local development launcher, upgrades, and troubleshooting.
43
+
44
+ ## Feature overview
45
+
46
+ Default PTC mode starts every execution in a fresh environment: variables from the previous call are gone, and a change that depends on earlier results means resending the setup code. PTC Plus turns `run_code` into a session-bound TypeScript REPL and closes the gaps below.
53
47
 
54
48
  | Scenario | Default PTC mode | With PTC Plus |
55
49
  | --- | --- | --- |
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 |
50
+ | Continue processing data | Each call starts fresh, so setup code must be sent again | Variables, functions, imports, and intermediate results stay in the session for the next call |
51
+ | Revise an existing name | No established binding can be updated, so the whole cell has to be resent | Revise variables, functions, classes, and import bindings under the same names; existing closures read updated bindings |
52
+ | Change a small part of the code | A one-line change means resending the complete source | Submit a delta through `edit_run_code`, then execute the complete revised cell |
53
+ | Use module syntax | Static `import` and `export` are invalid inside the function body | Write them directly in a cell; the plugin adapts the module syntax |
54
+ | Omit a call summary | Missing `run_code.description` fails validation | Supply a display summary automatically so otherwise valid code proceeds |
55
+ | Recover a misplaced top-level tool call | Undeclared top-level calls are rejected in PTC mode | Convert the call to `run_code` when the live tool definitions uniquely identify the target and validate its arguments |
56
+ | Locate a code error | Return the native error and stack | Map the error to the cell source; suggest an edit when a missing trailing delimiter has one verified correction |
57
+ | Work with the current project | Relative Node paths depend on the host process directory | Resolve file paths, session module imports, and default child-process directories from the session project directory |
58
+ | Find tools and parameters | Read through the tool interfaces already supplied to the model | List and search current capabilities in code, then inspect relevant interfaces on demand |
59
+ | Transfer data beyond plain JSON | JSON cannot fully represent `undefined`, BigInt, cycles, and similar values | Preserve supported special values and reference relationships for further computation and recovery |
60
+ | Inspect computation state | No reusable session variables remain after a call | View retained names, source definitions, reuse counts, and bounded value previews in the REPL tab |
61
+ | Reuse functions across sessions | Save the code yourself and reload it in later calls | Save TypeScript global bindings and supply their interfaces and usage notes to the model |
62
+ | Author and test global bindings | No dedicated workbench for global bindings | Ask the model for a draft to review, or run unsaved source in the workbench |
63
+ | Continue after a restart | No computation state spans calls, so there is nothing to recover | Recover verifiable state from session records and report what cannot be recovered |
64
+
65
+ The following sections explain usage and limits. See the [runtime reference](docs/runtime-reference.md) for complete language rules, configuration fields, and diagnostics.
66
+
67
+ ## Continuous computation and language extensions
68
+
69
+ The model executes the following code through `run_code`. Each call's code is a **cell**.
70
+
71
+ First, define the data and a calculation:
72
+
73
+ ```ts
74
+ const amounts: number[] = [12, 8, 5]
75
+ function total() {
76
+ return amounts.reduce((sum, value) => sum + value, 0)
77
+ }
78
+ return total() // 25
79
+ ```
80
+
81
+ In the next call, revise the data and reuse the function:
82
+
83
+ ```ts
84
+ const amounts = amounts.filter(value => value >= 8)
85
+ return total() // 20
86
+ ```
87
+
88
+ There is no need to redefine `total` or invent another variable name to avoid a redeclaration error. `total()` reads the updated `amounts`.
89
+
90
+ The default **stateful semantics** (`bindingUpdates: 'stateful'`) extend JavaScript/TypeScript binding rules for continued revision:
91
+
92
+ - Variables, functions, classes, and import bindings in the same scope can be updated, including bindings declared with `const`. Same-name revisions also work within a single cell.
93
+ - Existing closures read updated bindings; a previously saved function value remains the original function.
94
+ - Blocks, functions, and loop iterations retain their separate scopes.
95
+ - Failed initialization does not permanently reserve a name that was never successfully established. Other changes made before the failure are not rolled back.
96
+
97
+ Cells support TypeScript, top-level `await` / `return`, and static `import` / `export`. To detect name overwrites instead, disable **Allow redeclarations and overrides** to select the `protected` policy. Protected runtime names such as `tools` remain unavailable for overwriting.
98
+
99
+ <details>
100
+ <summary>When static imports and local overrides take effect</summary>
69
101
 
70
- Global bindings must be enabled in settings. See [Settings](#settings) and [Scope](#scope) below for optional behavior and recovery limits.
102
+ Static imports take effect **before the entire cell body executes**. Assignments and ordinary declarations in the body can then override them. A static import in a later cell restores the binding's live module source. Writing an import below an ordinary declaration in the same cell does not restore it at that textual position. To retrieve the current exported value at a particular step, assign it explicitly:
71
103
 
72
- ## Three scenes that matter most
104
+ ```ts
105
+ join = (await import('node:path')).join
106
+ ```
107
+
108
+ This captures the function value at that moment; a static import follows its module source. See the [runtime reference](docs/runtime-reference.md#cell-semantics) for more language rules.
109
+
110
+ </details>
111
+
112
+ `run_code`, edited code, and the global binding workbench follow the same language policy; the workbench's temporary state is separate from the model's session. Explicit `eval`, `Function`, `node:vm`, and independent runtimes retain their corresponding native boundaries. See the [language reference](docs/runtime-reference.md#cell-semantics) for scope, module interoperability, and historical session rules.
113
+
114
+ ## Code editing and call tolerance
115
+
116
+ ### Send only the change
117
+
118
+ The model can use `edit_run_code` to change the most recent editable cell in the current model turn without resending its complete source. If the second cell above has just completed and the same turn is still running, its filter can be changed to `value >= 10`:
119
+
120
+ ```js
121
+ edit_run_code({
122
+ edits: [{ old_string: 'value >= 8', new_string: 'value >= 10' }]
123
+ })
124
+ ```
125
+
126
+ An edit **reruns the entire cell**; this example returns `12`. Earlier state changes are not rolled back. If the code writes files or calls external services, rerunning still requires considering duplicate effects. Edits can repair failed code or refine a successful computation.
73
127
 
74
- ### State carries over
128
+ ### Recover from identifiable call problems
75
129
 
76
- The model first executes:
130
+ | Situation | PTC Plus behavior |
131
+ | --- | --- |
132
+ | `run_code` omits its outer `description` | Supply a display summary so code with otherwise valid arguments can execute |
133
+ | The model calls a native tool outside the PTC direct-tool list | Convert it to the corresponding `run_code` when current tool definitions uniquely identify the target and validate the arguments |
134
+ | Code fails to parse | Identify the source position; at EOF, suggest a target-bound edit if appending one or two closing delimiters has exactly one validated correction |
135
+
136
+ The first two behaviors default to on and can be disabled in settings. Syntax suggestions do not execute automatically or establish that the code matches the task's intent.
137
+
138
+ ## Project files and tool capabilities
139
+
140
+ ### Start from the session project directory
141
+
142
+ The model can use Node.js directly to read files, process data, and run programs. Relative file paths and imports in session code resolve from the recorded session project directory. Child processes use that directory when `cwd` is omitted; an explicit directory still takes precedence.
143
+
144
+ For example, in a project containing `package.json`, the first call reads its dependencies:
77
145
 
78
146
  ```ts
79
147
  import { readFile } from 'node:fs/promises'
@@ -82,83 +150,101 @@ const deps = Object.keys(manifest.dependencies ?? {})
82
150
  return deps.length
83
151
  ```
84
152
 
85
- The next call continues directly:
153
+ The next call works directly with the loaded data:
86
154
 
87
155
  ```ts
88
156
  return deps.map(dep => dep + '@' + manifest.dependencies[dep])
89
157
  ```
90
158
 
91
- `deps` and `manifest` remain in the current session. No repeated setup is needed.
159
+ This does not reread the file: it uses `manifest` already in the session. Direct file, network, and other external inputs can remain usable in the live environment without being guaranteed recoverable after a restart.
92
160
 
93
- ### Fix without resending
161
+ ### Discover tools as needed
94
162
 
95
- The model can submit just the replacement:
163
+ The model can still use DSH's current native tools through `tools.*`. To discover available capabilities, `capabilities.tree()` lists the catalog, `find()` searches names and descriptions, and `inspect()` provides parameter information for selected interfaces:
96
164
 
97
165
  ```ts
98
- edit_run_code({ edits: [{ old_string: 'deps.length', new_string: 'deps' }] })
166
+ const matches = await capabilities.find('read')
167
+ return capabilities.inspect({
168
+ symbols: matches.slice(0, 4).map(item => item.symbol),
169
+ budget: 4,
170
+ })
99
171
  ```
100
172
 
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.
173
+ Search uses lexical matching, so short keywords such as `read` or `session` work best. A miss does not prove that a tool is unavailable. Discovery grants no additional authority; DSH still validates and schedules calls. See [capability discovery](docs/runtime-reference.md#capability-discovery).
102
174
 
103
- ![Rejected run_code followed by an edit_run_code correction](assets/ptc-plus-repair-en.png)
175
+ ## Global bindings: reuse functions across sessions
104
176
 
105
- ### Have the Agent author a reusable helper
177
+ Session variables serve the current task. **Global bindings** save common TypeScript functions for multiple sessions to load. For example, after saving a binding named `textTools`, the model can call `textTools.clean(text)`.
106
178
 
107
- Enable **Global User Bindings** in settings, then enter:
179
+ Global bindings and the sparkle shortcut default to on. Create entries manually, import `.ts` files, or ask the model to write and revise them:
108
180
 
109
181
  ```text
110
182
  /binding new Create textTools to trim outer whitespace while preserving interior spaces
111
183
  /binding edit <id> Add line-by-line trimming
112
184
  ```
113
185
 
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.
186
+ `<id>` is the entry's identifier in the workbench. You can also select the binding to revise from the sparkle menu.
115
187
 
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.
188
+ ### Author, review, and enable
117
189
 
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.
190
+ The model can test with in-memory examples before submitting a draft. The draft appears above the composer, where you review its source, interface, and model instructions, then choose **Save and enable**, **Save disabled**, or **Discard draft**. Submission alone neither saves nor enables a binding. If you close the panel, the sparkle button's draft badge lets you reopen it.
119
191
 
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.
192
+ The sparkle menu lists and toggles entries even before the first message; these choices apply across sessions. Enabled entries' interfaces and usage notes are provided to the model in new sessions. Changes during a session are delivered on its next allowed request.
121
193
 
122
- ## Settings
194
+ ### Interface guidance and independent trial runs
123
195
 
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:
196
+ Each entry can derive its public interface from source and include purpose, input constraints, or examples. Editing only its instructions does not reset its loaded runtime state. Assignment or redeclaration in a session overrides only the corresponding name and does not rewrite the saved global entry.
125
197
 
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.
198
+ The workbench can run unsaved source and retain temporary variables across executions. Its computation state is separate from the model's session, making it useful for manual function checks; file and network operations still have real effects. Entries can be managed without an active PTC session. See the [global binding guide](docs/user-bindings.en.md) for source format, interface generation, storage, and the full workflow.
133
199
 
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.
200
+ ## Interface and settings
135
201
 
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).
202
+ The **REPL tab** lets you search retained names, inspect definitions, see reuse counts and bounded value previews, and open the global binding workbench. Previews have type and size limits; missing, incomplete, or unreadable previews are identified explicitly, and display does not invoke user getters. The green **PTC Plus** header indicator offers a quick binding list on wide screens; use the REPL tab on narrow screens.
137
203
 
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.
204
+ ![Session state and the global binding workbench in the REPL tab](assets/ptc-plus-repl-workspace-en.png)
139
205
 
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.
206
+ The sparkle menu beside the composer groups binding authoring, entry management, and **PTC Plus settings**. Its settings dialog and the sidebar plugin configuration page share the same configuration:
207
+
208
+ | Group | What you can adjust |
209
+ | --- | --- |
210
+ | Plugin switch | Enable or disable PTC Plus |
211
+ | Tool call tolerance | Missing call summaries and identifiable misplaced native-tool calls |
212
+ | REPL syntax | Allow same-name revisions or choose name protection |
213
+ | State and recovery | Restart recovery, contextual tips, and their frequency |
214
+ | Tool extensions | Global bindings and their management entry, official Cordis tool integration |
215
+ | Interface display | Enhanced tool cards, the REPL tab, and the sparkle shortcut |
216
+ | Resource limits | Execution time, memory, and output budgets |
217
+
218
+ Everyday computation features default to on. **Cordis development tools default to off** and can be enabled when inspecting or developing DSH plugins; see the [integration notes](docs/adr/0020-optional-cordis-tools-in-ptc-mode.md). Explicitly disabled options stay disabled, and each saved binding keeps its own enabled state.
219
+
220
+ Settings usually apply immediately. A worker's memory limit cannot be changed while that worker is active. See the [configuration reference](docs/runtime-reference.md#configuration) for fields, defaults, and full limits.
141
221
 
142
222
  ![PTC Plus settings card](assets/ptc-plus-settings-en.png)
143
223
 
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.
224
+ ## Value transfer and state recovery
225
+
226
+ ### Preserve values beyond plain JSON
227
+
228
+ Within the supported value domain, tool arguments, results, and recovery records preserve `undefined`, BigInt, `NaN`, infinities, sparse arrays, cycles, and shared references. Ordinary JSON results remain structured values; special values are displayed as readable text to the model, separately from their program values.
145
229
 
146
- ![REPL workspace with session inspection and global binding management](assets/ptc-plus-repl-workspace-en.png)
230
+ This does not make every JavaScript object transferable or persistent: functions, Promises, class instances, Date, Map, and Set are outside the value-transfer domain. Keeping a function in the REPL for later calls is different from returning that function as a tool result. Reuse session variables for continued computation; see the [value-transfer specification](docs/value-wire.md) for the complete supported domain.
147
231
 
148
- On wide screens, the green **PTC Plus** header indicator offers a quick binding list. On narrow screens, use the **REPL** tab:
232
+ ### Recover state with verifiable history
149
233
 
150
- ![Reusable REPL bindings](assets/ptc-plus-bindings-en.png)
234
+ Session state is not permanent memory. After a restart, runtime reset, or context compaction, only state verifiable from session records whose provenance remains in the model's context can be retained. Direct file or network inputs, damaged history, and compacted source provenance can reduce what remains available.
151
235
 
152
- ## Scope
236
+ Unverifiable state is discarded with a diagnostic; if necessary, the current computation continues in an empty environment. Recovery neither redispatches recorded native-tool calls nor reverses historical external effects. See the [runtime reference](docs/runtime-reference.md) for recovery evidence and limits.
153
237
 
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.
238
+ ## Boundaries
155
239
 
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.
240
+ - **Execution permissions**: primarily designed for `danger-full-access`. Code can access Node.js and the operating system directly; the plugin adds no security sandbox. DSH continues to own native-tool permissions, approvals, cancellation, and sandbox policy.
241
+ - **Failures and reruns**: a failed execution does not mean earlier statements had no effect. Process isolation, editing, and recovery do not guarantee that external operations are safe to repeat. Timeouts or output overflow can also release the computation environment.
242
+ - **Errors and cost**: language adaptation and call tolerance do not guarantee that every program succeeds. Actual call counts and token usage depend on the task and model; see the [evaluation notes](docs/evaluation.md#recorded-paired-observation) for a recorded comparison and its limitations.
157
243
 
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).
244
+ PTC Plus is a community plugin, with no affiliation with or endorsement from DeepSeek or DSH.
159
245
 
160
- ## Documentation
246
+ ## Further reading
161
247
 
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)
248
+ [Installation and upgrades](docs/installation.md) · [Global bindings](docs/user-bindings.en.md) · [Runtime reference](docs/runtime-reference.md) · [Architecture and development](docs/architecture.md) · [Verification](docs/verification.md) · [All documentation](docs/README.md)
163
249
 
164
- [MIT License](LICENSE).
250
+ [MIT License](LICENSE)