Introduction

The default PTC mode in DeepSeek Harness (DSH) starts from a fresh environment on every execution, which means the model has to resend setup code. This reduces efficiency in conversational sessions. The dsh-ptc-plus plugin provides a session-bound native drop-in REPL for PTC mode. It preserves variables, functions, imports, and results within a session, allowing subsequent calls to reuse the state directly.

Installation and Enabling

This plugin requires Node.js ^22.19.0 || >=24.0.0 and the official DSH with TypeScript PTC mode support.

After installing the plugin into a specified profile, restart DSH and select PTC mode to start using it:

dsh plugin --profile <profile> add dsh-ptc-plus

Core Features

This plugin mainly addresses repetitive work caused by state isolation in PTC mode, and it also provides code editing and tool extension capabilities.

  1. Cross-call state: Preserves variables, functions, imports, and results within the session, allowing the model to directly reuse the previous computational state in subsequent calls.
  2. Code revision: Through the edit_run_code interface, submit only the changes. The plugin reruns the full cell without requiring the model to resend the entire code block.
  3. Module syntax support: Supports static import and export syntax, allowing module code to be written directly in a cell.
  4. Special value preservation: Preserves values that cannot be fully expressed in JSON, such as undefined, BigInt, and circular references.
  5. Tool lookup and descriptions: Allows looking up available tools in code and viewing their parameter descriptions.
  6. Automatic description completion: Automatically completes the run_code.description summary to avoid validation failures caused by a missing description.
  7. Automatic tool-call conversion: When the model emits a valid top-level tool call, the plugin automatically converts it into run_code execution.
  8. Path resolution: Resolves file paths, modules, and the default child-process directory against the project directory recorded in the session.
  9. Source location mapping: Maps execution errors to cell source locations and provides editing suggestions in specific cases, such as a missing closing delimiter at the end.
  10. UI display: Displays preserved variables, definition origins, and bounded value previews in the REPL tab.
  11. Binding drafts: Use /binding to draft a binding, review it above the input box, and save it. Once enabled, the binding can be used across sessions.
  12. Workbench: Run unsaved source code in the workbench, which has an independent temporary state separate from the Agent session state.
  13. State recovery: Restores verifiable state from session records for continuous development across restarts.

Typical Usage

Reuse computational state

Read a file and parse dependencies in the first call:

import { readFile } from 'node:fs/promises';
const manifest = JSON.parse(await readFile('package.json', 'utf8'));
return manifest.dependencies;

Directly reuse the manifest variable in subsequent calls without resending the file-reading code:

return Object.keys(manifest.dependencies);

Revise code

When fixing an error in one location, submit only the change:

edit_run_code({ edits: [{ old_string: 'deps.length', new_string: 'deps' }] })

Create a binding draft

Use the /binding command to draft a binding, preview it above the input box, and save it:

/binding new 创建 textTools,清理文本首尾空白,保留内部空格

Use Cases and Notes

Use Cases
Suitable for developers who need to write and debug code iteratively, especially in scenarios involving module syntax, handling special JavaScript values, or frequently correcting code.

Notes
1. Permission requirements: This plugin is designed for danger-full-access. Code can directly access Node.js and the operating system, and the plugin does not add an additional sandbox. Use it only in environments where this permission is acceptable.
2. Community nature: This is a community plugin and is not affiliated with or endorsed by DeepSeek or DSH.
3. Recovery limitations: It is not guaranteed that all state can be restored across restarts. Recovery does not redo or roll back past external operations.
4. Preview limitations: Value previews have size and type limits. Objects that cannot be reliably read will be displayed as “unreadable”.
5. Initialization state: Enabling a binding configuration does not guarantee that initialization will succeed. Specific failures are explained in the execution result.

Summary

dsh-ptc-plus significantly improves development continuity and code debugging efficiency in DSH PTC mode by providing a session-bound native drop-in REPL. Developers can maintain state within the same session, use the editing interface to quickly correct errors, and manage reusable code snippets with the binding draft feature.