fix: preserve structured error from site CLI in provider#187
Merged
Conversation
When a site CLI command exits non-zero, prefer stdout (which contains structured JSON with error/hint) over stderr (which is often empty), so callers receive actionable error messages instead of generic "Command failed: node ..." text. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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.
Summary
runSiteCli()在 CLI 返回非零 exit code 时,优先使用 stdout(包含结构化 JSON 错误)而非 stderr(通常为空),使调用方能收到可操作的错误信息而非Command failed: node ...背景
agent-clip 调用 site command 失败时,日志里只有
[error] github: Command failed: node .../cli.js site run github/me --json,丢失了 CLI stdout 中的结构化错误(如{"success":false,"error":"Not logged in","hint":"Please log in to ..."})。根因:
runSiteCli()用execFile调用 CLI,exit code 非零时只取stderr,丢弃了 stdout 里的 JSON 错误信息。改动
bin/bb-browser-provider.ts:364一行:stderr2 || stderr || err2.message→stdout2.trim() || stderr2 || err2.message验证
bb-browser@0.11.3-beta.1,在 Mac Mini 上通过npm install -g安装pinix github me调用,确认返回结构化 JSON 错误而非Command failed🤖 Generated with Claude Code