From a4f253ac29464e0b6e735de95013ffe79dcc3a86 Mon Sep 17 00:00:00 2001 From: unclee Date: Tue, 10 Mar 2026 09:52:15 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20gh=20CLI=20=E5=8A=A0=20--repo=20?= =?UTF-8?q?=E5=8F=82=E6=95=B0=E9=80=82=E9=85=8D=20workspace=20=E6=9C=AC?= =?UTF-8?q?=E5=9C=B0=20remote?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 工作区 git remote 指向本地缓存路径,gh 无法自动识别 GitHub host。 在普通模式 workspace prompt 和 pipeline push prompt 中加入提示: 始终使用 --repo owner/repo 参数。 Co-Authored-By: Claude Opus 4.6 --- src/claude/executor.ts | 16 +++++++++++++++- src/pipeline/prompts.ts | 4 ++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/src/claude/executor.ts b/src/claude/executor.ts index d90cd95e..9b491e8f 100644 --- a/src/claude/executor.ts +++ b/src/claude/executor.ts @@ -125,7 +125,21 @@ function buildWorkspaceSystemPrompt(workingDir?: string): string { - 不要 git add . 或 git add -A,只添加本次变更的文件 - 不要提交 .env、credentials 等敏感文件 - 如果某步骤失败且无法自动修复,停下来向用户说明情况 -- 如果用户只是提问、审查代码或做探索性修改,不需要走这个流程。不确定时问用户:"需要我提交这些改动并创建 PR 吗?"`; +- 如果用户只是提问、审查代码或做探索性修改,不需要走这个流程。不确定时问用户:"需要我提交这些改动并创建 PR 吗?" + +## GitHub CLI (gh) 注意事项 + +工作区的 git remote 指向本地缓存路径(非 GitHub URL),\`gh\` CLI 无法自动识别仓库。 +**始终使用 \`--repo owner/repo\` 参数**,不要 cd 到其他目录: + +\`\`\`bash +# 正确 ✓ +gh pr view 123 --repo owner/repo +gh search issues --repo owner/repo -- "keyword" + +# 错误 ✗ — 不要 cd 到主仓库或其他目录执行 gh +cd /some/other/dir && gh pr view 123 +\`\`\``; const feishuToolsGuide = config.feishu.tools.enabled ? ` diff --git a/src/pipeline/prompts.ts b/src/pipeline/prompts.ts index b65745d0..62bee79f 100644 --- a/src/pipeline/prompts.ts +++ b/src/pipeline/prompts.ts @@ -117,6 +117,10 @@ export const PUSH_SYSTEM_PROMPT = `你需要将当前工作目录中的代码变 7. \`git push -u origin <当前分支>\` 8. \`gh pr create --fill\` 或用更详细的标题/描述创建 PR +**重要:gh CLI 注意事项** +工作区的 git remote 指向本地缓存路径(非 GitHub URL),\`gh\` 无法自动识别仓库。 +所有 \`gh\` 命令必须加 \`--repo owner/repo\` 参数(从 git remote URL 或项目配置中推断 owner/repo)。 + 完成后输出: ## 推送结果 - Commit: