From 5ea391a849b7756d5cb61761b606395117f85897 Mon Sep 17 00:00:00 2001 From: unclee Date: Thu, 5 Mar 2026 13:19:00 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E8=B7=AF=E7=94=B1=20prompt=20=E6=90=9C?= =?UTF-8?q?=E7=B4=A2=E6=8C=87=E4=BB=A4=E8=A6=81=E6=B1=82=E9=AA=8C=E8=AF=81?= =?UTF-8?q?=20.git=20=E7=9B=AE=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 路由 agent 通过工具搜索 ls 项目目录时,仍会匹配到非仓库目录 (如 talktype-target 编译产物)。即使 use_existing 验证能拒绝, 回退到 use_default 仍不符合预期。 修复: 在搜索指令中明确告知 agent 只有含 .git 的目录才是有效仓库, 编译产物目录不应被选择,部分名称匹配应继续查找更精确的结果。 Co-Authored-By: Claude Opus 4.6 --- src/claude/router.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/claude/router.ts b/src/claude/router.ts index 24754ae9..63745c85 100644 --- a/src/claude/router.ts +++ b/src/claude/router.ts @@ -114,7 +114,7 @@ ${projectsSection}## 快速决策规则(优先级从高到低,匹配即停 当用户提到一个**不在已知项目列表中的**仓库名时,按以下顺序查找: 1. **本地缓存** — 运行 \`find ${cacheDir} -maxdepth 3 -name "*.git" -type d\`,查找匹配的 bare clone。如果找到,从缓存路径推导 URL(如 \`${cacheDir}/github.com/org/repo.git\` → \`https://github.com/org/repo\`),返回 \`clone_remote\`。**不要凭猜测构造 URL。** -2. **项目目录** — \`ls ${projectsDir}\`,看有没有匹配的目录 +2. **项目目录** — \`ls ${projectsDir}\`,看有没有匹配的目录。**注意:只有包含 \`.git\` 子目录的才是有效仓库**,编译产物目录(如 \`xxx-target\`、\`build\`)不是仓库,不要选它们。如果目录名只是部分匹配(如 \`talktype-target\` 不等于 \`talktype\`),优先继续查找更精确的匹配。 3. **GitHub 搜索** — \`gh search repos <关键词> --json fullName,url --limit 20\`(不要用 \`gh repo list\`) 4. 都找不到 → 用户给了 URL 就用 URL;否则 \`need_clarification\`