Skip to content

dsh-baize-rules v0.2.0

Choose a tag to compare

@bvcvb bvcvb released this 22 Sep 08:01
· 10 commits to main since this release
  • Rule tags. A rule (and a template) can carry free-text tags: tag/untag on the command side, chip editing + chip filtering in the panel. Tags are panel-only by default — injectTags: true opts into rendering them as - [tag,tag] body, and with the default off the injected <system-reminder> is byte-identical to 0.1.6, so retagging never triggers a redundant re-injection. Stored tags are optional and normalized (max 8 per rule, 24 chars each, case-insensitive dedupe), so pre-tag rule files load unchanged and are rewritten byte-identically.
  • Template library ($DSH_HOME/rules/templates.json, global, not bound to a scope): tmpl list|add|edit|rm, save <id> to store a rule as a template, and from <id|#tag> [scope] to apply templates as rules (a #tag ref applies every template carrying that tag; a same-text rule already in the target scope is skipped, so re-applying never piles up duplicates; applied templates bump a use counter).
  • Template import/export. tmpl export [<file>] writes a versioned envelope (kind/schemaVersion/exportedAt) that deliberately omits ids; tmpl import <file> [--merge|--replace] [--dry-run] [--yes] is dry-run by default, dedupes by text, unions tags, and collects every entry error before writing anything.
  • Panel: two panes. 规则 (scope switch, tag chips, per-row Edit / Save as template / Remove, and a "From template" multi-select picker) and 模板 (create/edit body+tags, delete, apply into a scope, export to file, import with a dry-run preview). Both panes refresh from a single response.
  • HTTP API grows an op dispatch (rule.update, rule.setTags, rule.saveAsTemplate, rule.addFromTemplates, template.create|update|delete|export|import) while POST { raw, scope } keeps working unchanged for older panels; GET now also returns templates.
  • Rule ids accept a unique prefix. remove/edit/enable/disable/tag/untag/save take the abbreviated 8-char id that list prints; an ambiguous prefix reports ambiguous with the candidates instead of guessing.
  • Fixes. /baize-rules clear project cleared the session scope instead of project (clear only branched on global), and export omitted the project section. Both are corrected.
  • Review fixes (all found by auditing the feature before release):
    • The panel silently dropped session/project edits when it had no sessionId/cwd (the new-chat overlay renders the panel that way): the op answered ok:true and the rule showed up, then it was gone on the next fetch — nothing was persisted. The API now refuses that write with a 400 that explains it, and the panel disables the scopes it cannot store (session/project) with a hint, defaulting to global.
    • tmpl add reported an already-existing template as a command error, while the HTTP API treated the same call as success. Both paths now branch on an explicit ok/changed result instead of matching on message text; a failed template write no longer carries a nextTemplates side effect.
    • Template import froze the mode into the dry-run preview: toggling merge/replace after previewing used to apply something different from what was shown. Confirming now always applies exactly the previewed mode.
    • A failed template/rule edit no longer exits edit mode (it used to discard the typed text), and a failed import no longer dismisses the dry-run report.
    • A malformed JSON request body reported empty raw; it now reports invalid JSON body.
    • template.update can now clear tags (an explicit empty list replaces them; omitting tags still keeps them), a no-op write no longer bumps updatedAt or rewrites the file, and template ordering gained an updatedAt tie-break.
    • Follow-up to the scope fix: gating availability on the docs' cwd was wrong — the conversation.view slot's owner share carries only inspect/onInspectDone (verified in the shipped dsh-client-ui-conversation bundle), so project was empty even inside a conversation, the project scope got disabled everywhere, and the hint wrongly claimed "not attached to a session". Availability now keys off sessionId alone: the host resolves that session's cwd itself when storing project rules (resolveProject), which was verified end-to-end — a request with a real sessionId and no project wrote projects/<cwd-slug>.json successfully. Only a genuinely session-less panel is limited to global.
  • Docs: README (EN + ZH) cover tags, templates, the new commands, injectTags, the template file location and the extended API; install examples bumped to 0.2.0.
  • Docs: add the panel and slash-command screenshots to both READMEs, and rewrite the Publishing section to state what actually ships — the tag-driven CI publish job fails without the NPM_TOKEN secret, so a local npm publish --access public is the step that publishes (commit 4317d1a, which landed after this entry was written and is folded in here).

Install: dsh plugin --profile web add dsh-baize-rules@0.2.0

Published to npm on 2026-09-15.