中文EN

dsh-prompt-balance

aginpmMIT

先按字节与占比量出组装后的系统提示词到底由什么构成——规则、身份、工作区策略、工具描述各占多少,再把操作规程提到规则块之前,让模型先读到「在为难干活」再读到一堆禁令。通过 ~/.dsh/prompt-balance.json 配置;两个钩子、无需构建、无依赖。

下载量 / Downloads
503

安装

dsh plugin --profile web add dsh-prompt-balance

沙箱测试

这个插件还没测过。提交测试 →

README

dsh-prompt-balance

Measure what your system prompt is actually made of — then make sure the model reads the

operating protocol before it reads the prohibitions.

Works on DeepSeek Harness (DSH). Two hooks, no build step, no dependencies.


The problem

Long-running agents accumulate rules: an AGENTS.md that grew to 65 KB, a workspace

policy, a template guide, a data-security annex. Nobody measures the result. In one real

case the breakdown was 65% rules / 10.7% identity — the model's first screen of text was

fourteen kilobytes of "don't", almost nothing about who it was working for or what good work

looked like.

Two consequences follow:

1. You cannot argue about prompt quality without numbers. "My prompt feels bloated" is not

actionable; "rules are 42,331 bytes of 64,902, and they sit first" is.

2. Order matters. Instructions near the front of the assembly carry more weight than the

same instructions buried after a wall of constraints.

What it does

Hook · Effect

system-prompt/assemble · Writes every section's byte size to ~/.dsh/prompt-balance.log, then prepends one short <operator-protocol> block before all rule sections. Idempotent: it will not stack a second gate.

agent/pre-step · AGENTS.md arrives as an ordinary message, so context compression treats it as history and can summarize the specifics away. This hook prefixes a ~250-byte identity digest so the "who am I serving" frame survives the fold.

Install

dsh plugin --profile desktop add dsh-prompt-balance
# or, to try a local checkout first:
dsh plugin --profile desktop add link:/absolute/path/to/dsh-prompt-balance

Restart the app. The plugin logs one line at install and one line per assembly, so you can

verify it is live:

tail -f ~/.dsh/prompt-balance.log

Configure — this is the part that matters

Out of the box the identity block is a placeholder. The gate only earns its keep when it

names a real person doing real work. Create ~/.dsh/prompt-balance.json:

{
  "identity": [
    "I am the assistant to one person: a regional manager running a multi-city store network",
    "Their output is analysis, slide decks, and operating ledgers.",
    "",
    "Their five recurring failures: claiming done without verifying, coarse self-review,",
    "pasting parts without classifying them, skipping workflow steps, acting before review.",
    "",
    "So: concrete things first, structure second; every conclusion carries its source;",
    "find the flaws yourself before shipping."
  ],
  "gate": [
    "You serve one person, not a ticket queue. Six checks before you answer:",
    "1. Enumerate before you abstract...",
    "2. Specific beats categorical..."
  ]
}

Both keys are optional and independent:

  • identity — a string array, joined with newlines. Used in the gate and in the pre-step digest.
  • gate — a string array. First line is the framing sentence, the rest are the numbered checks.

Delete the file to return to defaults. Nothing else in the plugin is configurable, and it

never writes to your config.

What you get in the log

[2026-10-30T07:12:44.118Z] installed: system-prompt/assemble hook active (gate prepend + composition log; config C:\Users\you\.dsh\prompt-balance.json)
[2026-10-30T07:12:51.902Z] assemble: sections=30 in=19805B out=20862B gate=1057B rules=12943B (65.4%) top=genui:fence:5068 dsh-taste-skill:2949 identity:2402
[2026-10-30T07:12:51.905Z] pre-step: instructions 14289B -> 14539B (changed=true)

in/out/gate are byte counts, so you can prove the cost of the gate itself. rules is

the sum of sections whose names match instruction|agents|workspace|memory|rule; if your

host names its sections differently, that number is meaningless — read the top= list instead.

Compatibility

  • DSH kernel 0.2.1-rc.* and later. Verified against @deepseek-ai/dsh-system-prompt

lib/index.js:398 — the waterfall passes (assembly, context, next), three parameters.

A handler declared with four parameters throws next is not a function and takes every

tool call down with it; this plugin declares three.

  • Node 20+. No runtime dependencies.
  • Nothing throws at import time: a failed loader entry makes the desktop app show its

recovery dialog, so every step is wrapped and reported to the log instead.

Uninstall

dsh plugin --profile desktop remove dsh-prompt-balance

The log file stays at ~/.dsh/prompt-balance.log; delete it yourself if you want it gone.

License

MIT.

以上内容来自 npm 上的 README,我们只做格式化,不改内容。

版本

npm 上共发布:3,最后更新 2026-11-02

链接

GitHub · Homepage · npm

同类插件