dsh-prompt-inject: Inject configurable prompt variables into the complete preset

Introduction

In DeepSeek Harness (DSH), system prompts are assembled from multiple sections. If an agent preset uses a persona with complete: true (e.g., @deepseek-ai/dsh-persona occupying the entire personality segment), assemble() will retain only this single section, and all other paragraphs registered via ctx.systemPrompt.section() will be discarded. A common workaround is to stack more sections, but this path is blocked in complete scenarios. However, complete sections still undergo interpolate() via renderPrompt(), allowing you to write {{variable_name}} within the persona text, which will be expanded using values returned by prompt variable providers. Below is an introduction to dsh-prompt-inject, maintained by MacilyDots: it registers “an additional prompt segment” within the workflow as a variable for reference in preset prefixes. The plugin itself does not contain fixed text; the content is provided by you in the configuration or external files.

What is this

dsh-prompt-inject (npm package name @macily.dots/dsh-prompt-inject, version 0.1.2 in current documentation) is a DSH workflow plugin. It registers a configurable prompt variable with DSH, allowing agent presets using a complete: true persona to insert a block of custom text into the system prompt. It is maintained by MacilyDots; source code and documentation can be found in the GitHub repository, and the community directory page is the SkillHub Plugin Page. The license is MIT.

Why prompt variables are needed instead of adding more sections

The entry point for DSH system prompt registration is ctx.systemPrompt.section() from @deepseek-ai/dsh-system-prompt. There is a hard rule during assembly: as long as a section with complete: true exists, only that section remains in the final list. The only entry point that still works in this case is prompt variable interpolation—the complete section is not a concatenation target, but it still participates in interpolate(). Writing {{inject}} (the name is configurable) in the prefix or persona will allow it to be expanded.

Note that interpolate() throws an error for unregistered variables (e.g., unknown prompt variable "{{x}}" in section "..."). This error occurs during the system prompt rendering stage, causing the entire session chain under that preset to fail. Therefore, if {{x}} is written in the prefix, you must ensure the plugin registering x is loaded; use tools/disable.mjs to remove references before uninstallation; tools/check.mjs can verify pairing, and tools/uninstall.mjs will refuse to execute if references still exist.

Core Features

  1. Register Prompt Variable: The default variable name is inject, which can be changed to a name matching [a-z][a-z0-9_]* in cordis.patch.yml; the prefix of the preset persona is appended with {{variable}} via a tool script (idempotent).
  2. Content Source: Supports textFile (absolute path in UTF-8, auto-reloads based on mtime) or inline text; textFile takes precedence; if both are empty, no content is injected.
  3. Scope: Optional whitelists for presets, sessions, and cwds; an enabled master switch; optional stateFile / stateKey to follow external JSON switches (injection occurs only if the key is strictly equal to true).
  4. Companion Scripts: install.mjs / uninstall.mjs manage the profile’s dsh.profile.bundles; enable.mjs / disable.mjs manage preset references; check.mjs lists all variable references within the profile and exits with code 1 on danger.
  5. Fault Tolerance: The provider is called synchronously within assemble(), and throwing an error will kill the session; the plugin internally uses try/catch for file reading and state reading, returning an empty string in the worst case (equivalent to no injection).

The plugin does not register a system-prompt section, so it does not participate in “multiple complete section” conflicts; however, registering the same variable name multiple times will still result in an error. You must change the variable configuration to avoid name collisions with other plugins.

Installation and Enablement

Below, %DSH_HOME% refers to the DSH home directory (Windows default is %USERPROFILE%\.dsh, other platforms use ~/.dsh), and the profile name defaults to desktop. The plugin requires Node >= 22.5.

Install from npm (official command):

dsh plugin --profile desktop add @macily.dots/dsh-prompt-inject

Note: The scoped package name @macily.dots/dsh-prompt-inject must be used on npm; the unscoped dsh-prompt-inject is already taken by another package.

Manual installation is equivalent to: copying the repository to the profile’s node_modules/@macily.dots/dsh-prompt-inject, and then running node tools/install.mjs to write into bundles. Whether DSH loads the plugin is determined by package.json’s dsh.profile.bundles, not just by modifying cordis.patch.yml (the GUI may rewrite the patch, while the bundles list is relatively stable).

Enablement process overview:

  1. Configure the plugin in the profile’s cordis.patch.yml (see next section).
  2. Hook up the variable reference for the target preset:
    node tools/install.mjs
    node tools/enable.mjs --preset preset-<your-preset-id>
    node tools/check.mjs
  1. Restart DSH.

All write operation scripts will leave a .bak-prompt-inject-<timestamp> backup in the same directory; add --dry to preview without writing to disk.

Configuration Example

Override plugin items in the profile’s cordis.patch.yml:

- id: prompt-inject
  config:
    variable: inject
    textFile: '<absolute path to text file>'
Field Default Description
variable inject The registered variable name; write {{<this-name>}} in the preset
textFile '' Text file path (UTF-8), reloads based on mtime after changes
text '' Inline text; textFile takes precedence
presets [] Agent preset id whitelist; empty means no restriction
sessions [] Session id whitelist
cwds [] Working directory whitelist (header.cwd)
enabled true Master switch
stateFile '' External JSON switch file
stateKey enabled Key read from JSON, must be strictly true for injection
debug false Write to %DSH_HOME%/prompt-inject.log

variable and presets are two independent gates: the reference determines which presets expand this variable; the provider and whitelists/switches determine when to return an empty string.

Typical Usage

  1. Prepare a set of rules or context intended only for a specific complete persona, save it as a UTF-8 file, and fill in textFile in the configuration.
  2. Run node tools/enable.mjs --preset preset-<id> for the target agent preset to append {{inject}} (or your configured variable) to the end of the persona prefix.
  3. Use node tools/check.mjs to confirm that references and bundles are paired correctly before restarting DSH.
  4. To temporarily disable injection, you can set enabled: false, narrow the whitelist, or link with other plugins via stateFile; changing file content does not require a restart (textFile reloads based on mtime).

Use Cases and Notes

Suitable for: DSH users who have adopted complete: true personas but need to stably insert team specifications, project descriptions, or variable instruction blocks into the system prompt; cases where you want to decouple injected content from the persona repository and control it via external files or switches.

Important Notes:

  • The plugin runs with the current DSH process privileges. Before installation, you should read the source code and the MIT license to confirm that the textFile path and content are trustworthy.
  • Referencing an unregistered variable will cause the entire preset session to fail; you must disable and check before changing bundles or uninstalling.
  • Uninstallation sequence: node tools/disable.mjs --preset <preset-id> → node tools/uninstall.mjs → Restart DSH → Manually delete the plugin directory in node_modules.

Conclusion

dsh-prompt-inject does not attempt to bypass the assembly rules of complete sections but utilizes prompt variable interpolation to append configurable text blocks to complete persona presets. Combined with bundles installation, enable/check scripts, and cordis.patch.yml configuration, it separates the management of “references” from “when to inject”. Please refer to the repository README for more details.

羽毛球分组比赛记分
小程序二维码

欢迎使用《羽毛球分组比赛记分》微信小程序

Xiaoye