Skip to content

Let the chat answer questions about GitHub repos that aren't cloned - #44

Merged
meddlin merged 1 commit into
mainfrom
claude/remote-repo-metadata-queries-c60e7f
Nov 3, 2026
Merged

meddlin merged 1 commit into
mainfrom
claude/remote-repo-metadata-queries-c60e7f

Conversation

@meddlin

@meddlin meddlin commented Nov 3, 2026

Copy link
Copy Markdown
Owner

What

The Ask panel could only talk about repos cloned under ~/git, so a question like "What can you tell me about the repo composition?" about a GitHub-only repo got "I don't see that repo." This adds a repository picker to the panel and gives the model a stored GitHub snapshot for repos that aren't cloned.

  • Snapshot store: a new github_repo_snapshots table (keyed by lowercased owner/repo, like the community profiles). A snapshot is 4 GitHub calls: repo details, languages, top-level files, README. It is fetched on demand when you pick the repo or ask about it, reused for 24h (GITLIB_SNAPSHOT_REFRESH_HOURS, 0 = only on Refresh), and shared between concurrent askers. If GitHub can't be reached, the chat falls back to the stored snapshot, or to listing data only, and the prompt says why.
  • Prompt: the picked repo is described in <current_repository> (with <repository_files> and <repository_readme>), with language percentages computed on the server and the snapshot time stated. A small capped <remote_library> section lists GitHub-only repos for library-wide questions. All GitHub-sourced text goes through the existing neutralize so it can't close a block.
  • Protocol: /api/chat takes an optional remote (owner/repo), mutually exclusive with repo. The server only accepts repos the GitHub account lists, never an arbitrary slug. handleChat takes the remote source as an injected argument, so tests and non-GitHub setups are unaffected.
  • Picker UI: the scope chip becomes a searchable dropdown of all repos (cloned and GitHub-only). On a repo page it still defaults to that repo. A GitHub-only pick shows "Details from GitHub, N min ago" with a Refresh button.

Cloned repos are unchanged: they still use scanner data, notes and the README on disk.

For reviewers

  • GitHub only for now; GitLab repos aren't offered in the picker.
  • The picked repo reuses the <current_repository> tag rather than a new one, so "this repo" means the same thing for cloned and GitHub-only repos.
  • Without GITLIB_GITHUB_TOKEN, GitHub allows 60 calls/hour (shared with the Issues/PRs tabs) and private repos won't work. Each snapshot costs 4 calls.
  • A test caught that my first owner/repo pattern accepted ../etc; it now follows GitHub's naming rules.
  • Cloned repos don't get GitHub data (e.g. the language breakdown). That is a possible follow-up.

Testing

  • npm run typecheck and npx vitest run: 22 files, 550 tests pass. New coverage: prompt blocks (budgets, fallbacks, injection), protocol validation, snapshot parsing, and an end-to-end flow against a fake GitHub (fetch once, staleness, forced refresh, concurrent askers, no README, rate-limit fallback, unlisted repo refused).
  • Ran the dev server against a throwaway data folder with a fake Ollama that echoes the system prompt. The picker listed all three scopes, picking the GitHub-only repo showed its sync status, and the model received the snapshot (Rust 90.0%, Shell 10.0%, file list, README). No real GitHub request or real model was used.

🤖 Generated with Claude Code

Picking a GitHub-only repo in a new searchable picker in the chat panel
fetches a snapshot from GitHub (repo details, language breakdown, top-level
files, README), stores it in a new github_repo_snapshots table, and feeds it
to the model as the current repository. Snapshots refresh after 24h
(GITLIB_SNAPSHOT_REFRESH_HOURS) or on demand; if GitHub can't be reached the
chat falls back to the stored snapshot or listing data and says so.

- core: RemoteRepoContext prompt blocks, capped <remote_library> list, and
  neutralization of GitHub-sourced text
- web: `remote` field on /api/chat (owner/repo, exclusive with `repo`),
  validated against the account's listing; syncRemoteRepo server function
- tests for prompt building, protocol, snapshot parsing and fetching, and
  the chat route

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@meddlin
meddlin merged commit f54734c into main Nov 3, 2026
1 check passed
@meddlin
meddlin deleted the claude/remote-repo-metadata-queries-c60e7f branch November 3, 2026 05:37
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