Skip to content

fix(commands): 斜杠命令 /review 从未出现——两处契约违约 - #39

Merged
Nicholas023 merged 1 commit into
mainfrom
fix/slash-command-contract
Nov 4, 2026
Merged

Nicholas023 merged 1 commit into
mainfrom
fix/slash-command-contract

Conversation

@Nicholas023

Copy link
Copy Markdown
Owner

问题

斜杠命令 /review 从来没出现过(输入 /re 只出 skill)。

根因:两处违约,都被自己的 try/catch 吞掉

DSH 的 dsh-commands 在 register() 和调用时各有一次严格校验:

# 我们的写法 契约 后果
1 input: 'repo_path [mode] [focus]'(字符串) input 若给,必须是 { hint: string } register 抛 TypeError
2 handler 返回纯字符串 必须返回 { kind: 'success' | 'error', text? } 调用时抛 TypeError

两处都在 try/catch 里,所以表现是静默失败:命令不出现,日志里什么都没有。

修法

  • input 改为 { hint }
  • handler 返回 { kind, text }
  • 补 definitionId,让宿主能配对注册与卸载

证据

按 dsh-commands 源码复刻 normalizeDefinition / normalizeResult,直接喂真实注册对象:

✅ normalizeDefinition 通过
✅ normalizeResult 通过,kind = success

并新增两条回归测试锁住这两个形状(防止再被 try/catch 静默吞掉)。

影响

只改命令注册与返回值,不影响工具调用、评审流程与配置。

本 PR 由 DeepSeek Harness 辅助创建

The slash command never appeared. Two contract violations, both of which throw
inside the plugin and get swallowed by its own try/catch:

  1. `input` was a string. dsh-commands requires an object with a `hint`
     string, so register() threw 'input hint must be a string'.
  2. handler returned a bare string. The registry requires a CommandResult
     ({ kind: success|error, text? }), which would have thrown on invoke.

Also sets definitionId so the host can pair registration with disposal.

Verified against the host rules transcribed from dsh-commands: both
normalizeDefinition and normalizeResult now pass on the real registration.
@Nicholas023
Nicholas023 merged commit 45d75eb into main Nov 4, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant