Skip to main content
Y

dsh-pre-work

yujh129/dsh-pre-work

Pre-step task shaping for DSH agents: filters follow-up messages for free, clarifies ambiguous requests with clickable questions, and rewrites fuzzy requests into an explicit goal→constraints→completion-criteria brief; ships with /pre-work-model to route the two helper subagents.

Install

dsh plugin --profile web add github:yujh129/dsh-pre-work

README

dsh-pre-work

中文文档

One-line: A DSH plugin that selectively and automatically polishes requests before DSH starts working.


What it does

Every user turn passes through three zero-or-low-cost gates before the main agent starts working:

  1. Follow-up filter (always free). Acknowledgements ("ok", "好的"), corrections ("no, do X instead"), parameter supplements ("also…"), and "continue" pass through untouched. The plugin never answers tasks, never sends messages, and never re-asks after a clarification answer.
  2. Fast lane (always free). Requests that already read as a structured task book (goal + constraints + completion criteria present) pass through unchanged.
  3. Shape lane (one merged helper call). Everything else is classified by a helper subagent ({isNewTask, isClear}):
    • Clear → a polish helper rewrites the request into a goal → constraints → completion criteria brief (only rewrites, never answers; ≈200–350 chars in Chinese, 300–450 in English). Attachments (images/files) are preserved.
    • Ambiguous → a clarify helper proposes 2–3 questions with clickable options via the host question UI. Every question ends with a fixed “我不知道,你替我定” / "I don't know, you decide" option. Your answers (or a skip) are merged by a rewrite helper; anything still unknown survives verbatim as a [待补充: …] / [TBD: …] placeholder.

Failure policy (no silent degradation): if the subagents service, the spawn backend, or a helper run fails, the plugin logs a [dsh-pre-work] warning and passes the original request through. It never blocks your turn.

Install

npm registry:

npm install dsh-pre-work

GitHub:

npm install github:yujh129/dsh-pre-work

Then enable the plugin in your DSH profile (the bundle patch in cordis.patch.yml registers it automatically when installed through the plugin manager).

Default behavior

  • Session-level first: per-session model overrides made with /pre-work-model win over global defaults; global defaults (the plugin's own settings) win over inheritance.
  • Helper subagents inherit the main agent's provider/model/effort by default — zero configuration, zero interference. They run as fresh spawned children (spawn backend) with no parent context.
  • Processing mode is first-only: only the first step of each user turn is examined. every-message exists for debugging only and is not recommended.

/pre-work-model

Type /pre-work-model in a session to open the route panel:

  • Header shows both roles' current routes (inherit main agent (current: provider/model) when unset, or inherit … — saved config unavailable: … when a saved route went stale).
  • Each role lists inherit (default) plus the models authorized for this session (subagent-model-selection.allowedModels), intersected with the live model catalog — unauthorized or dead routes simply don't appear. When the session carries no authorization at all, only inherit plus the main agent's own route are offered.
  • If the module-A core is not active (e.g. the subagents service is missing), the panel still opens but states “Pre-work core is not active / Pre-work 核心未激活” instead of erroring.
  • Apply to this session (default) or apply to all sessions (writes the global default). Want both helpers on the same model? Just pick the same option in both rows.
  • Saving is atomic: if persistence fails nothing changes and the panel reports it.
  • If a saved route later becomes unauthorized/deleted, the plugin logs a warning, falls back to inheritance, and the panel says so.

The same routes can be edited globally in the plugin settings area (provider/model/effort fields for both helpers). Efforts are validated against the model's real effort list — unsupported values fall back to inheritance with a warning.

Compatibility

Tested against DSH 0.2.2-rc.5 (engines.dsh >= 0.2.2-rc.5). Uses only public host seams: agent/pre-step, subagents.startActivation, userQuestions.ask, commands.register, llm catalog, configEditor.

API surface

ExportPurpose
apply(ctx, config)Plugin entry (registers the pre-step listener, /pre-work-model, and the preWorkModelConfig service).
ConfigSchemastery schema: mode, polish, clarify.
ctx.preWorkModelConfigService (canonical name; ctx.preWorkModel is kept as an alias): getSession / setSession / clearSession / resolveRoute(agent, role) / describe. A UI plugin only ever writes this service — the core reads it before every helper spawn and inherits when nothing is set.
looksLikeFollowUp(text) / looksStructured(text) / findSessionPolicy(session) / resolveConfiguredRoute(...)Exported helpers (unit-testable classification and authorization logic).

License

MIT — see LICENSE.

Related plugins