dsh-preset-guard
Repairs the durable preset state a DeepSeek Harness release rename broke —
one plugin for both preset failure modes.
A DeepSeek Harness (dsh) plugin. Symptom search terms: preset 加载错误,
旧版本创建的 preset 打不开, new session does nothing after upgrade,
升级后无法新建对话, persona invalid config,$.prefix missing required value,
agent-preset/not-found, 默认 preset 失效.
The two failure modes
A release renames something, and the state a person authored keeps naming the
old name. Both are silent: the roster reports the preset as healthy either
way, and the client folds the mount failure into a console warning.
1. A renamed shipped preset leaves agent-presets.default naming an id the
deployment no longer ships. Every new session then fails with
agent-preset/not-found, and the New Session control reports nothing.
2. A renamed plugin config field leaves a user preset unmountable. In
0.1.5-rc.1 @deepseek-ai/dsh-persona renamed its text key to prefix
(commit 40792330c0, packages/preset/persona/src/index.ts:36,50), so every
preset under <dsh-home>/.agent-presets/ that still writes text fails with:
agent-presets: preset "my-preset" failed to mount: failed to apply loader
entry persona (@deepseek-ai/dsh-persona): invalid config:
- $.prefix missing required value (at prefix)
Discovery never catches this: compositionProblem()
(packages/preset/agent-presets/src/discovery.ts:225) checks only the row shape
and package resolution, and entryListProblem()'s own comment says it "does
not resolve plugin names or apply configs". So the stale preset passes the
health check with its broken marker still null.
What it does
At start:
- Files. For every user preset root (
trust === 'user'), scan each
agent.cordis.ymland rename a legacytextkey inside a
@deepseek-ai/dsh-personarow'sconfigblock toprefix. The rewrite is
conservative: every other line, comment, and blank line must be byte-identical
or it refuses to write; it re-scans its own output; flow-style configs are
reported, never guessed at; the original is kept as
agent.cordis.yml.dsh-preset-guard.bak. This half is synchronous, because
the loader applies sibling entries concurrently and an awaited rewrite could
still be in flight when the first session mounts the preset it repairs. - Default. Compare the resolved
agent-presets.defaultagainst the live
roster and repair the user layer when the two disagree, preferring the
deployment default, then the configured fallback, thenstandard.
Install
Simplest — install the umbrella, which mounts this and the other verified
community fixes in one line:
dsh plugin --profile <your-profile> add dsh-community-fixes
Then add dsh-community-fixes to that profile's dsh.profile.bundles.
Use this package alone:
dsh plugin --profile <your-profile> add dsh-preset-guard
- insert:
- id: preset-guard
name: 'dsh-preset-guard'
Config
| Field | Default | Meaning |
|---|---|---|
fix |
true |
Repair both the stored compositions and the persisted default. false reports every mismatch and writes nothing. |
fallback |
'' |
Preset id to install when clearing a stale default leaves no usable one. Absent prefers standard, then the first id in the roster. |
Verification
19 contract tests (npm test) plus two end-to-end runs in an isolated harness —
see docs/verification.md. Both halves were also
re-verified mounted through the dsh-community-fixes umbrella.
| Half | Control | With the guard |
|---|---|---|
| Preset file | $.prefix missing required value, session creation fails |
file migrated at boot, session created |
| Stale default | new session fails with agent-preset/not-found |
user layer repaired, deployment default applies |
Limits
- A plugin, not an upstream patch. It repairs stored state at start; it does not
teach discovery to validate a row's config schema, so a preset broken by some
other future rename still fails silently. - It migrates the persona
text→prefixrename only. Other renames need
their own rule. - The roster keeps reporting
broken: nullfor a stale preset even once it
mounts, because the health check never looks at config.
Lineage
This package merges two previously separate guards, both now retired:
dsh-plugin-preset-default-guard— theagent-presets.defaultrepair.
npm: deprecated. GitHub: repository removed.dsh-plugin-preset-migrate— the user-preset file migration.
npm: deprecated. GitHub: repository removed.
Their commit histories are merged into this repository, so git log shows the
whole lineage; both behaviours now live behind one apply().
License
MIT