feat: 启动时自动发现 GitHub 用户组织,解决全新环境搜不到仓库的问题 - #208
Conversation
全新环境下 .repo-cache 为空,listKnownOrgs 返回空数组, 导致全局搜索无法匹配到组织内仓库(如 taptap/sce-tools)。 现在启动时通过 gh api 自动获取用户所属组织和用户名, 与缓存目录发现的组织合并,注入系统提示词的搜索指令中。 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
Claude finished @lishuceo's task in 1m 35s —— View job PR Review: Auto-discover GitHub orgs
|
| Severity | File | Issue | Confidence |
|---|---|---|---|
| 🟡 Warning | src/claude/executor.ts:238-241 |
Promise.all discards both results on partial failure — should use Promise.allSettled |
80 |
Overall Assessment
Clean, well-scoped PR. The approach is sound — using gh api at startup to discover orgs and merging with cache-dir discovery is a good solution for the cold-start problem. Tests are thorough (8 new tests covering success, dedup, failure, ordering, and merge scenarios).
Positives:
execFile(notexec) used correctly — no shell injection risk- 10s timeout prevents startup from hanging
- Fire-and-forget in
index.tswith.catch(() => {})— startup isn't blocked - Deduplication via
Setworks correctly slice(0, 20)bump from 10 is reasonable for the expanded source
One suggestion: The Promise.all in initGitHubOrgCache means a failure in either API call (orgs or user login) discards both results. Promise.allSettled would make this more resilient — see inline comment with a suggested fix.
Not blocking — the current behavior is acceptable since the whole function is best-effort with a catch handler. But allSettled would be a small improvement for environments where one endpoint might be restricted.
- Promise.all → Promise.allSettled,避免 orgs API 失败时丢失 user login - 移除未使用的 rmdirSync import - Function → (...a: unknown[]) => void 修复 @typescript-eslint/ban-types Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
Claude finished @lishuceo's task in 48s —— View job PR Review: Auto-discover GitHub orgs (re-review after sync)
✅ Approved — No new issues found1 previous issue fixed: Code ReviewRe-reviewed all 3 changed files after the sync. The code is clean:
No new issues with confidence ≥ 75. |
* feat: 启动时自动发现 GitHub 用户组织,解决全新环境搜不到仓库的问题 全新环境下 .repo-cache 为空,listKnownOrgs 返回空数组, 导致全局搜索无法匹配到组织内仓库(如 taptap/sce-tools)。 现在启动时通过 gh api 自动获取用户所属组织和用户名, 与缓存目录发现的组织合并,注入系统提示词的搜索指令中。 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * fix: 使用 Promise.allSettled 保留部分结果 + 修复 lint errors - Promise.all → Promise.allSettled,避免 orgs API 失败时丢失 user login - 移除未使用的 rmdirSync import - Function → (...a: unknown[]) => void 修复 @typescript-eslint/ban-types Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Summary
gh api user/orgs+gh api user自动获取当前 GitHub 用户所属的组织和用户名.repo-cache目录结构发现的组织合并去重,注入系统提示词sce-tools等组织内仓库时因缺少--owner参数而找不到的问题Test plan
npm run typecheck通过npx vitest run src/claude/__tests__/— 41 个测试全部通过(含 8 个新增测试)taptap/sce-toolsGitHub org cache initialized及正确的组织列表🤖 Generated with Claude Code