Repository navigation
fix(cli): 阻止 autostart 帮助参数触发系统变更 - #1269
Merged
deepcoldy merged 1 commit intoSep 7, 2026
Merged
Conversation
在处理 autostart 子命令前识别 --help/-h,并拒绝所有额外参数,避免帮助探测或拼错参数时执行 enable/disable。补充无副作用回归测试,覆盖正式子命令及兼容别名。 Refs: deepcoldy#1268 Co-authored-by: TRAE CLI <[email protected]>
There was a problem hiding this comment.
🟢 Approval recommended
改动范围小且参数校验前置能明确阻断副作用路径,并配套新增了覆盖 help/未知参数的回归测试验证行为与退出码。
Pull request overview
该 PR 修复 botmux autostart 子命令在携带 --help/-h 或额外参数时仍可能触发 ensureConfigDir() / enable/disable 等副作用的问题,确保帮助查询与非法参数路径 fail closed,避免用户仅查看帮助却意外修改系统自启动配置。
Changes:
- 在
autostart分支里先解析并拦截--help/-h:仅打印专用 usage 并以 0 退出(不创建配置目录、不做系统变更)。 - 对未知子命令及任何额外参数统一报错并设置退出码
2,且在调用ensureConfigDir()之前完成校验。 - 增加回归测试:覆盖 help 路径、未知参数、未知子命令均不得修改 HOME 快照。
File summaries
| File | Description |
|---|---|
| src/cli.ts | 调整 autostart 参数分发顺序:help 优先、参数校验前置、非法参数设置 rc=2 并避免副作用 |
| test/cli-unknown-args.test.ts | 新增 HOME 递归快照回归测试,验证 help/未知参数/未知子命令路径无副作用且返回码符合预期 |
Review details
- Files reviewed: 2/2 changed files
- Comments generated: 0
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Owner
|
你好!这是 Botmux 的自动评审流程。 但你暂时未被拉入群中——你的 GitHub 账号(LPX-E5BD8)不在自动拉群名单里。请把你的 GitHub 账号和飞书信息补进名单文档: 补好后,后续复审会自动把你拉进群。感谢贡献! |
deepcoldy
approved these changes
Sep 7, 2026
deepcoldy
left a comment
Owner
There was a problem hiding this comment.
双审通过(自动评审 + 复审),0 阻断。
- 修复方向正确:
--help/ 未知参数在ensureConfigDir()与任何系统变更之前 fail closed,与主干既有的舰队命令参数闸同构。 - 影响面已核:唯一程序化调用方 Dashboard
/api/autostart固定传enable/disable,不触达新闸;编译态纯 argv 解析,无路径拼接风险。 - 本地在最新 master 上 rebase 后验证:tsc 通过、build 通过、vitest 43/43、bun 28/28;反变异验证测试对该回归有区分力。
- CI 四腿全绿。
|
🚀 Released in v3.19.3 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
问题
botmux autostart enable --help会把--help静默忽略并直接调用enableAutostart(),导致只想查看帮助的用户意外写入并启用系统自启动配置。其它 autostart 子命令也会吞掉额外参数;未知子命令则会在报错前先创建配置目录。Fixes #1268
修复
--help/-h,输出专用 usage 并成功退出。install/uninstall兼容别名。影响面
botmux autostart的 CLI 参数分发。验证
npx vitest run --project unit test/cli-unknown-args.test.ts:28 passed。bun run vitest run --project unit test/cli-unknown-args.test.ts:28 passed。bun run build:通过。bun run test:21373 passed、31 skipped;13 个失败均为当前主机上的既有环境/时序问题(tmux locale/socket、npm allow-scripts、mojo/native-subagent 时序),与本次修改文件无关。