dsh-max-compact
DeepSeek Harness plugin: compact model input via a lazy tool surface (mc_discover), deployment-level prompt layer with persona shadow, and an agent-preset composer. For DSH 0.2.x.
- Stars
- 1
- Language
- JavaScript
- Created
- Oct 23, 2026
- Updated
- Oct 23, 2026
Introduction
dsh-max-compact
Compact model input for DeepSeek Harness (DSH >= 0.2): shrink what the model sees — tool definitions, prompt sections, preset compositions — without shrinking what the deployment can do.
Five mechanisms, one plugin — all config-gated (ponytail ships an opt-out
lite default; everything else is inert until configured):
- Lazy tool surface. Most tools hide behind
mc_discover: the model sees a small resident surface (fs + shell + messaging) and activates anything else on demand — the dsh-ops discovery pattern, generalized to every plugin's tools, not just one catalog. - Editable prompt layer + persona shadow. A trailing system-prompt
section the deployment owns — inline text, an external
prompt.md-style file (re-read every step, mtime-cached), or named profiles — plus a per-agentdeployment:persona-prefixoverride that shadows whatever the preset's persona row declared, without touching the preset. - Preset composer.
agentPresets.list()shows the whole roster — official, foreign, managed.readDocument+registerclone any preset under a new id with per-rowdisabledtoggles (the dsh-custom-mode capability, but for all presets, since foreign declarations are read-only but clonable). - Managed prompt sections.
/mc sectionpins hide/shadow/trim rules to named prompt sections, scoped per agent (all|subagents| preset ids); the assemble waterfall applies them every step, independent of the lazy switch. - Ponytail minimal-code mode. A baseline-frozen
maxcompact:ponytailsection renders per session while/mc ptswitches ride as tagged<system-reminder>messages — the prompt prefix never re-hashes. Vendored review/audit/debt skills ride the host'sskills.registerProviderseam.
Everything is capability-probed: a missing seam disables the feature with an
honest /mc status line, never a crash.
Install
npm install dsh-max-compact
# or straight from GitHub:
npm install github:20genesis14-sys/dsh-max-compact
# or add the plugin directory to the profile's plugin list
The bundle mounts one global row (id: max-compact) — intentionally not
inside a preset, so every mechanism covers every agent and every preset,
including foreign ones. With the default config only ponytail's lite
baseline is active (everything else is inert); ponytailDefault: off or
/mc pt default off silences it too.
Commands
/mc # status: seams, lazy stats, layer, persona, presets
/mc lazy on|off # enable/disable the compact surface
/mc lazy keep|hide|default <tool> # adjust the resident/lazy policy
/mc lazy release <tool> | reset # re-mask activated tool(s) on this session
/mc lazy list # hidden vs activated for this session
/mc sections # last assembled system-prompt sections (chars each)
/mc prompt # show the active layer
/mc prompt set <text...> # inline layer text
/mc prompt file <path|off> # external prompt file (re-read each step)
/mc prompt clear # drop the layer from the prompt
/mc prompt profile save|use|rm|list # named layer profiles
/mc persona set <text...> | off # per-agent persona shadow
/mc persona scope all|subagents|<id> # limit the shadow to delegated/selected agents
/mc prompt scope all|subagents|<id> # limit the prompt layer the same way
/mc section # managed sections list
/mc section diet # apply the whole recommended set at once
/mc section hide <name>[,<name>…] [scope] # drop section(s) (waterfall, scoped)
/mc section set <name> <text...> # shadow: replace text in agent's own scope
/mc section trim <name> <keep…> # keep only lines containing a substring
/mc section scope <name> all|subagents|<id>[,<id>…] # retarget managed rules
/mc section off <name>|all [mode] [scope] # release rule(s) — original returns
/mc presets # roster: foreign + managed, incl. broken
/mc preset show <id> # row tree with [disabled]/[group] flags
/mc preset clone <src> <newId> [name] # clone any preset -> managed
/mc preset toggle <id> <row> [on|off] # flip a row's disabled flag, re-register
/mc preset rm <id> # unmount + forget a managed preset
/mc pt # ponytail status: baseline, effective, seams
/mc pt lite|full|ultra|off # switch THIS session (reminder, no cache miss)
/mc pt default <mode> # persist the baseline for new sessions
/mc pt skills # vendored skills served to the model catalog
/mc output also lands on an expanded transcript card plus a floating result
panel (the bundled client/ web half), so it stays visible on a fresh
session's hero screen.
Bundled skills (skills/ dir, vendored MIT from @wenaixi/dsh-ponytail):
ponytail-review (diff review for over-engineering), ponytail-audit
(whole-repo), ponytail-debt (ponytail:-marker ledger). The model calls
the skill tool by name, or you invoke a skill directly.
stop ponytail or normal mode as a whole message also flips the session off.
In-session the model gets mc_discover:
mc_discover({query: "web"}) -> "Selected web_search, web_fetch. They become
callable on the next model step; nothing was executed."
How it works
Lazy surface (lib/dsh/lazy-tools.js, lib/core/lazy-catalog.js)
agent.ctx.tools.registerputsmc_discoverin the agent's own layer — restrictions never cover own-layer registrations, so the activation path can never mask itself. Its disposer lives inownLifts, separate from the restrict masks thatreconcilelifts on every recompute.agent.ctx.tools.restrict({deny})masks the lazy set per agent. Reconcile follows the official-tool-hiding discipline: a public-surface snapshot diff guards against publication feedback loops, all masks lift before recompute, a failed plan hides nothing, anddenynarrows on scope-local or unknown names (restrictthrows naming the offender — that tool is honestly reported as unmaskable rather than silently kept).- Activations queue into
pendingand commit at the next step boundary (agent/pre-step,session/eventstep/endas fallback) — republishing mid-step would invalidate the in-flight request's tool list. Activated tools stay visible for the agent's lifetime (/mc lazy release <tool>orresetre-masks them). - A global
ctx.tools.guard(exec => …)keyed onexec.agentdenies hidden-tool executions even from conversation history; activation lifts the denial automatically. - Keep beats hide, hide beats default-lazy;
run_code+ own tools are never hidden (reserved transport + own-layer registrations throw inrestrict). - While lazy is on, a
maxcompact:lazy-hintsection (order 10501) tells the model how many tools are hidden and to callmc_discover; it renders empty — drops out — once nothing is masked.
Section hygiene (lib/dsh/lazy-prompt.js)
One global system-prompt/assemble listener (context.scope = the
assembling agent) drops sections that document currently-masked tools —
tools:workflow and friends stop burning tokens while their tool is lazy.
The waterfall cannot rewrite a complete section (the host restores it);
that limit is documented, not worked around. /mc sections inspects the
last assembly.
Managed sections (lib/core/managed-sections.js, lib/dsh/section-shadow.js)
Three modes pinned per named section, independent of the lazy switch:
- hide — the waterfall drops the section for matching agents. The only mode that works on agent-scoped contributions (shadows would collide in the same layer).
- shadow — same-name section registered in the agent's own scope replaces the original (deeper layer wins by name, the host's own persona mechanism). Order self-heals: the waterfall records the original's position and the shadow re-registers there once seen.
- trim — lines containing a keep-substring survive; the only mode safe
for dynamic sections (
tier-routingshows live tier labels — a static shadow would freeze stale values, sosetrefuses theNO_SHADOWlist).
Scopes follow matchesScope: all (default) | subagents | preset ids.
Agents without session.meta (older hosts) match only all. Multiple
rules may target the same name — hide wins over shadow for a matching
agent, so "shadow for all + hide for subagents" compresses parents and
drops the section for children. A trim whose patterns match nothing
leaves the original text — a mistyped rule must degrade to "unchanged",
never to "silently deleted". Rules persist in the settings document and
lift instantly on /mc section off.
Prompt layer (lib/core/prompt-layer.js, lib/dsh/files.js)
Section maxcompact:layer (order 10500, after deployment:persona-prefix
and suffix) resolves each assembly: file > active profile > inline. Files
are re-read every step through an mtime/size cache — external edits land on
the next model call with no reload.
Persona shadow (lib/dsh/persona.js)
deployment:persona-prefix (order 0) registered in the agent's own
scope shadows the preset's persona row — same-name sections shadow across
layers (duplicate names only collide within one layer). Off by default;
/mc persona set/off refreshes every live agent.
Ponytail minimal-code mode (lib/core/ponytail.js, lib/dsh/ponytail.js)
One global maxcompact:ponytail section (order 50) renders ONLY the baseline
locked at agent/created — mid-session /mc pt switches never re-hash the
prompt prefix. Mode changes travel as one tagged <system-reminder> user
message appended on the agent/pre-step waterfall (a retry replaces it by
tag). stop ponytail / normal mode as a whole message flips the session
off. Default resolution: PONYTAIL_DEFAULT_MODE env → ponytailDefault
field → lite. The vendored skills/ catalog registers through
skills.registerProvider; maxcompact:ponytail is denylisted from managed
sections (NO_MANAGE).
Preset composer (lib/core/presets.js, lib/dsh/preset-registry.js)
agentPresets.list()— every declared preset incl.brokendiagnostics.readDocument(id)— the full composition YAML, parsed with a!!js→{__jsExpr}schema so host-evaluated predicates survive cloning verbatim.- Clone registers under a new id (foreign declarations are never
touched);
group/isolatestructure is preserved so service rows keep their realms; relative./x.mjsspecifiers become absolutefile://URLs. - Toggle =
disabled: trueon the row + dispose/re-register (duplicate ids throw — disposal first). New sessions pick up the new revision; running sessions keep their retained generation. That's the platform's revision-retention design, not a limitation of this plugin. - Managed specs persist through the volatile
managedPresetsfield and the settings document (nsmax-compact) — clones survive restarts.
Config
All fields are volatile (WebUI-editable, persisted via the settings document):
| Field | Default | Meaning |
|---|---|---|
lazyEnabled | false | Master switch for the compact surface |
lazyKeep | [] | Extra tool names to keep resident |
lazyHide | [] | Tool names forced lazy (beats keep) |
lazyHideSections | [] | Section names filtered from assemblies while lazy is on |
customPrompt | '' | Inline layer text |
customPromptFile | '' | External prompt file path |
promptProfiles | {} | {name: text} named layers |
activePromptProfile | '' | Selected profile |
customPersona | '' | Persona shadow text |
layerPresets | [] | Layer scope: [] all, [':subagent'] delegates only, preset ids |
personaPresets | [] | Persona scope, same vocabulary |
managedSections | [] | [{name, mode, text?, keep?, scope?}] hide/shadow/trim rules; several rules may target one name under different scopes (hide wins over shadow) |
managedPresets | [] | Cloned preset specs |
ponytailDefault | unset | Ponytail baseline for new sessions — PONYTAIL_DEFAULT_MODE env wins; falls back to lite |
Honest limitations
- Preview APIs.
agentPresets,tools.restrict/guard,system-prompt/assembleare preview surfaces — all probed; missing seams degrade features, never crash. - Global rows can still add tools. Profile-global plugins mount on top
of any preset — no preset or mask fences their own-layer additions, so
/mc lazy listreports what the host actually shows, not an ideal count. - Foreign presets are read-only.
readDocumentis "for viewing only" — clone under a new id to customize; the original is never edited in place. completesections can't be rewritten by the assemble waterfall — including acompletepersona. The persona shadow uses a named prefix section instead, which layering does shadow.- Shadows freeze static text. Sections resolving live state per step
(
tier-routing's tier labels) belong totrim, notset— theNO_SHADOWdenylist enforces it. Agent-scoped contributions (registered per-agent by the host, e.g.context:file-reference) collide with a shadow in the same layer — usehidefor those. - Revision retention. Preset toggles affect new sessions; running sessions keep the generation they mounted.
Development
npm test # 88 tests — pure core + mocked-ctx smoke
npm run check # node --check every lib file
npm run pack:check # npm pack --dry-run
lib/core/ is pure logic (no DSH imports, no I/O); lib/dsh/ is the only
place that knows DSH exists; lib/index.js wires the two. Per-agent state
lives in WeakMaps keyed on agent objects — never session-id strings.