fix: add Status() health check and SilenceUsage for baidu-cli and google-cli#17
Conversation
…gle-cli Bug 1: baidu-cli missing SilenceUsage / SilenceErrors - All other CLIs set these flags so cobra doesn't print usage text on error, which would pollute the JSON output. - baidu-cli was the only one missing it. Bug 2: baidu-cli and google-cli missing Status() health check - nanobanana-cli and chatgpt-image-cli call client.Status() before operations to check daemon + extension readiness, giving friendly error messages. - baidu-cli and google-cli just jumped into operations, producing confusing errors with no guidance. - Added Status struct and Status() method to both CLIs. - Added pre-flight checks to baidu-cli search, google-cli search, and google-cli result commands.
PR Review — ✅ 高质量一致性 fix,可以合入这个 PR 做了什么(我的理解)把 baidu-cli 和 google-cli 拉齐到 nanobanana-cli / chatgpt-image-cli 已有的两个习惯:
替换被关掉的 #10(拆出 timestamp 改动到 #16 后重建分支)。 Code review做得好的地方
可选优化(不阻塞合入) 🟢 Nit 1:16 行 pre-flight 检查重复 3 次(baidu-cli/cmd/root.go、google-cli/cmd/search.go、google-cli/cmd/result.go)。后续可以考虑抽到 // browser/client.go
func (c *Client) RequireReady() error {
st, err := c.Status()
if err != nil { return fmt.Errorf("daemon_unreachable: %w", err) }
if !st.Running { return errors.New("daemon_not_running") }
if !st.ExtensionConnected { return errors.New("extension_not_connected") }
return nil
}然后调用点变成 3 行处理 不过现在的样子和 nanobanana / chatgpt-image 一致,本 PR 的目标是"对齐"而不是"提炼",所以这条建议属于跨 CLI 的后续重构,不应该让这个 PR 背。如果未来要做,建议是另开一个 PR,把 4 个 CLI 一起改。 🟢 Nit 2: 🟢 Nit 3: End-to-end 验证通过 kimi-webbridge 真实 Chrome 会话跑:
不健康路径(daemon down / extension disconnected)没有实际模拟(需要关掉用户的 WebBridge App,过于侵入),但代码路径明确、和 nanobanana/chatgpt 同款,无理由怀疑。 baidu-cli search "claude code" 浏览器渲染(与 CLI 返回的 3 条结果一一对应):
google-cli search "kimi webbridge" 浏览器渲染(与 CLI 返回的 3 条结果一一对应):
结论✅ Approve —— 0 blocker,3 个 🟢 nit 都是跨 CLI 的后续优化(不属于本 PR 范围) 这是个干净利落的一致性修复 PR,质量很高。可以合入。 After merge合入后 @RachelXiaolan 已是常驻贡献者(在 .all-contributorsrc 里有 entry 的话),建议补一个 |
Recognizing @RachelXiaolan for code contributions (PR #17 — Status() health check + SilenceUsage for baidu-cli/google-cli) and pull-request reviews (detailed technical review on PR #9, plus follow-up PR #16). Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>


Summary
Two consistency fixes for baidu-cli and google-cli. Timestamp changes are in a separate PR (#16).
This replaces #10 (closed due to branch re-creation after splitting out the timestamp changes).
Fix 1: baidu-cli missing SilenceUsage / SilenceErrors
All other CLIs (google-cli, nanobanana-cli, chatgpt-image-cli) set
SilenceUsage = trueandSilenceErrors = trueon their cobra commands so that cobra doesn't print usage text alongside the structured JSON error output. baidu-cli was the only one missing these flags, causing it to print an extraUsage:block on every error.Fix: Added
SilenceUsageandSilenceErrorsto baidu-cli's search command.Fix 2: baidu-cli and google-cli missing Status() health check
nanobanana-cli and chatgpt-image-cli call
client.Status()before operations to verify that the kimi-webbridge daemon is running and the Chrome extension is connected. This gives users friendly, actionable error messages like:{"ok":false,"error":{"code":"daemon_not_running","message":"kimi-webbridge daemon is not running (open the Kimi Desktop App)"}}baidu-cli and google-cli skipped this check entirely. When the daemon wasn't running, they produced a raw
"daemon unreachable"error with no guidance on what to do.Fix:
Statusstruct andStatus()method tobaidu-cli/browser/client.goandgoogle-cli/browser/client.go(matching the existing implementation in nanobanana/chatgpt).search, google-clisearch, google-cliresult.Testing
All affected CLIs compile successfully: