dsh-preset-guard
其他 活跃维护

dsh-preset-guard

Robin1987China/dsh-preset-guard

自动修复发布重命名造成的持久化预设状态损坏。过期默认预设ID会被重置,用户预设中指向已重命名配置字段的旧引用得到同步校正,加载无异常且预设完整保留。

0
Stars 标星
0
Forks 分支
0
Watchers 关注
0
Open Issues
JavaScript
主要语言
MIT
开源协议
99 KB
仓库大小
2 个月前
最后推送
一键安装扩展 / 插件指令
dsh plugin --profile web add github:Robin1987China/dsh-preset-guard
git clone https://github.com/Robin1987China/dsh-preset-guard.git
git clone git@github.com:Robin1987China/dsh-preset-guard.git
README.md main

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.yml and rename a legacy text key inside a
    @deepseek-ai/dsh-persona row's config block to prefix. 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.default against the live
    roster and repair the user layer when the two disagree, preferring the
    deployment default, then the configured fallback, then standard.

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 → prefix rename only. Other renames need
    their own rule.
  • The roster keeps reporting broken: null for 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 — the agent-presets.default repair.
    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