- Início
- Plugins
- Desenvolvimento e ferramentas de plugins
- dsh-syntax-gate
dsh-syntax-gate
xinming-chenniang/dsh-syntax-gate
After each write or edit of a .js, .mjs, .cjs, .py or .json file, runs the real parser (node --check, Python compile, JSON.parse) and injects the parse error into the next step so the model fixes it immediately. Observes only: never blocks a tool call and never changes the tool result.
Instalar
dsh plugin --profile web add github:xinming-chenniang/dsh-syntax-gateREADME
dsh-syntax-gate · 落盘即校验的语法闸门
DSH 宿主插件(无界面)。
write/edit落盘后,按扩展名用真解析器检查一遍; 失败就在模型下一步注入「文件 + 错误」,当步即可修。只观察,不拦截,不改工具结果。
它补的是哪一段
AI 写代码最容易坏的时机不是提交,而是落盘那一刻:写坏一个 .mjs,要等下一次运行才炸,
而 pre-commit 管不到没有 git 的目录、也管不到还没提交的改动。这个插件把检查放到落盘后的一步之内。
行为
| 事件 | 动作 |
|---|---|
tools/result(write / edit) | 按扩展名校验:.js/.mjs/.cjs → node --check;.py → Python compile()(不写 __pycache__);.json → JSON.parse |
| 校验失败 | 进队列(同路径只留最新,最多 5 条,10 分钟过期),不抛错、不改工具结果 |
agent/pre-step | 队列非空时把最多 3 条拼成一条用户消息注入,随后清空 |
| 其它工具 / 其它扩展名 | 连读都不读(.gd/.lua/.ps1 没有 50ms 级语法器,故意不查) |
边界(别指望它做超过这些)
- 只查语法,不跑 lint / 类型 / 测试——那些慢,且各项目有自己的入口(
npm run check)。 - 不拦:不
reject、不改入参、不碰tools/pre-execute;拦提交是 pre-commit 的事。 - 只在同回合内回灌:错误 TTL 10 分钟,超时就丢;旧错误不会追着人跑。
- 队列不按会话隔离(宿主
agent/pre-step不带可靠的会话/agent 身份):一条错误消息可能出现在 同进程的另一回合——但它是共享文件系统上的客观事实,误投危害小。
安装
-
市场:DSH 桌面端 → 设置 → 插件 → 搜
syntax-gate。 -
CLI(源码安装):
dsh plugin --profile <profile> add github:xinming-chenniang/dsh-syntax-gate -
本地开发:在 profile 的
package.json里加"dsh-syntax-gate": "link:<仓库路径>",并把dsh-syntax-gate追加进dsh.profile.bundles, 然后pnpm install;装载状态看dsh plugin --profile <profile> why dsh-syntax-gate。 改bundles后需重启应用才生效。
配置
在 profile 的 cordis.patch.yml 里按 id 覆盖(也可直接改本包的 cordis.patch.yml):
- id: dsh-syntax-gate
name: dsh-syntax-gate
config:
enabled: true
timeoutMs: 20000 # 单次校验上限
maxBytes: 8388608 # 超过这个体积不查
maxQueued: 5
ttlMs: 600000
skipDirs: [node_modules, .git, dist, build, coverage, __pycache__, .venv, venv, _trash]
关掉:给该条目加 disabled: true。
自检
node --test # 期望 10 个用例全绿
端到端:让 AI 写一个含语法错误的 .mjs,下一步上下文里应出现 [语法闸门] … 解析失败 开头的用户消息;
把文件改对再写一次,不再出现。
与 dsh-verify-gate 的区别
名字像,做的事不同:Raysnows/dsh-verify-gate 是完成闸门——一个回合改过代码却没跑验证时,
提醒模型「去跑测试或申报豁免」;本插件直接执行语法校验,把解析错误回灌给模型。
两者插件 id 不同,可以同时装。
实测经验
- 兜底 catch 会吃掉 JSON 校验失败:
JSON.parse的异常若落进runSyntaxCheck最外层 「任何意外都不弄坏工具调用」的 catch,就会被判成 ok=true——单测第一版就是这么挂的。 JSON 分支必须自己 catch 并返回ok:false。 python -m py_compile会往__pycache__写.pyc,把工作区弄脏;改用compile(source, path, 'exec')。
License
MIT
Plugins relacionados
deepseek-harness
deepseek-ai/deepseek-harness
dsh-market
dsh-market/dsh-market
dsh-web (dsh-plugin-manager)
zhu1090093659/dsh-web
dsh-web
zhu1090093659/dsh-web