Skip to content

fix: gh CLI 加 --repo 参数适配 workspace 本地 remote - #124

Merged
lishuceo merged 1 commit into
mainfrom
fix/gh-cli-repo-flag
Mar 10, 2026
Merged

fix: gh CLI 加 --repo 参数适配 workspace 本地 remote#124
lishuceo merged 1 commit into
mainfrom
fix/gh-cli-repo-flag

Conversation

@lishuceo

Copy link
Copy Markdown
Owner

Summary

  • 工作区 git remote 指向本地缓存路径,gh CLI 无法自动识别 GitHub host
  • 在普通模式 workspace prompt (executor.ts) 和 pipeline push prompt (prompts.ts) 中加入提示:始终使用 --repo owner/repo 参数
  • PM bot 不受影响(走 systemPromptOverride 路径)

改动文件

  • src/claude/executor.tsbuildWorkspaceSystemPrompt 新增 ## GitHub CLI (gh) 注意事项
  • src/pipeline/prompts.tsPUSH_SYSTEM_PROMPT 追加 gh 注意事项

工作区 git remote 指向本地缓存路径,gh 无法自动识别 GitHub host。
在普通模式 workspace prompt 和 pipeline push prompt 中加入提示:
始终使用 --repo owner/repo 参数。

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@claude

claude Bot commented Mar 10, 2026

Copy link
Copy Markdown

Claude finished @lishuceo's task in 1m 33s —— View job


PR Review: gh CLI --repo flag adaptation

  • Check previous review comments
  • Read changed files and understand context
  • Review changes and post findings

Verdict: ✅ Approve with minor suggestions

Overall assessment: Clean, focused PR that solves a real problem — workspace git remotes point to local bare cache paths, so gh CLI can't auto-detect the GitHub repo. The fix correctly adds --repo owner/repo guidance to both the normal workspace prompt (executor.ts) and the pipeline push prompt (prompts.ts).

2 minor suggestions posted as inline comments:

  • 🟡 prompts.ts:122 (confidence: 80) — Step 8 still shows gh pr create --fill without --repo, inconsistent with the new "all gh commands must use --repo" guidance right below it.
  • 🟡 executor.ts:133 (confidence: 78) — Unlike prompts.ts which hints "从 git remote URL 或项目配置中推断 owner/repo", the executor prompt doesn't explain how the agent should determine the actual owner/repo value when the remote is a local path.

What looks good:

  • Correct scoping — only affects workspace prompts, PM bot (systemPromptOverride path) is unaffected
  • PR_FIXUP_SYSTEM_PROMPT doesn't need changes since it delegates to the /pr-fixup skill
  • For writable mode workspaces cloned via repoUrl, the manager already resets origin to the real remote URL (manager.ts:165-168), so --repo is technically redundant there but doesn't hurt — safe/conservative guidance

Comment thread src/pipeline/prompts.ts

**重要:gh CLI 注意事项**
工作区的 git remote 指向本地缓存路径(非 GitHub URL),\`gh\` 无法自动识别仓库。
所有 \`gh\` 命令必须加 \`--repo owner/repo\` 参数(从 git remote URL 或项目配置中推断 owner/repo)。

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Minor inconsistency (confidence: 80)

Step 8 above (line 118) still shows gh pr create --fill without --repo, which contradicts the new guidance on lines 120-122 that says all gh commands must use --repo. An agent might follow the specific step 8 example and omit --repo.

Consider updating step 8 to be consistent:

Suggested change
所有 \`gh\` 命令必须加 \`--repo owner/repo\` 参数(从 git remote URL 或项目配置中推断 owner/repo)。
所有 \`gh\` 命令必须加 \`--repo owner/repo\` 参数(从 git remote URL 或项目配置中推断 owner/repo)。例如 \`gh pr create --fill --repo owner/repo\`

Comment thread src/claude/executor.ts
## GitHub CLI (gh) 注意事项

工作区的 git remote 指向本地缓存路径(非 GitHub URL),\`gh\` CLI 无法自动识别仓库。
**始终使用 \`--repo owner/repo\` 参数**,不要 cd 到其他目录:

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Missing guidance on how to resolve owner/repo (confidence: 78)

The examples use literal owner/repo as a placeholder, but unlike prompts.ts (which says "从 git remote URL 或项目配置中推断 owner/repo"), this prompt doesn't tell the agent how to determine the actual owner/repo value. Since the workspace remote points to a local cache path, git remote -v won't directly reveal the GitHub owner/repo.

Consider adding a hint, e.g.:

owner/repo 可以从项目 CLAUDE.md、git log 中的 GitHub 链接、或 bare cache 路径结构推断。

@lishuceo
lishuceo merged commit c21d7fa into main Mar 10, 2026
6 checks passed
@lishuceo
lishuceo deleted the fix/gh-cli-repo-flag branch March 10, 2026 10:28
lishuceo added a commit that referenced this pull request Apr 8, 2026
工作区 git remote 指向本地缓存路径,gh 无法自动识别 GitHub host。
在普通模式 workspace prompt 和 pipeline push prompt 中加入提示:
始终使用 --repo owner/repo 参数。

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
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