Skip to content

feat(agent): support repo_context_files on LocalGitProvider via shim - #212

Merged
huhamhire merged 2 commits into
devfrom
feat/pragent-repo-context-local
Jul 10, 2026
Merged

feat(agent): support repo_context_files on LocalGitProvider via shim#212
huhamhire merged 2 commits into
devfrom
feat/pragent-repo-context-local

Conversation

@huhamhire

Copy link
Copy Markdown
Owner

What

pr-agent 0.39.0 introduced a new upstream default in configuration.toml:

repo_context_files = ["AGENTS.md"]
repo_context_from_default_branch = true
repo_context_max_lines = 500

The feature fetches these files from the reviewed repo and injects them as <instruction_files> so /review, /describe, and /improve follow the project's own conventions. But LocalGitProvider (the only provider meebox uses) inherits the base no-op get_repo_file_content_provider_supports_repo_context judges it unsupported, logs a per-run WARNING, and silently skips the feature.

Change

Add LocalGitProvider.get_repo_file_content in the version-guarded shim (local_git_provider.py):

  • Reads the blob straight from the base branch's tree object (git show <target_branch>:<path>), never the working tree — the review diff is already head.commit vs merge-base(target_branch), and target_branch_name is the trusted branch the PR merges into (matches repo_context_from_default_branch=true).
  • Reading the tree (not the working tree) keeps it independent of _prepare_repo's /ask-worktree sanitizing of agent instruction files.
  • A missing file / any git error degrades to "", so build_repo_context treats it as "no context" and caches no fetch error.

Docs: added the patch to the current-patches list in docs/arch/02-agent/05-pragent-runtime.md.

Effect

  • /review /describe /improve inject the reviewed repo's AGENTS.md (capped at repo_context_max_lines = 500) as <instruction_files>; the WARNING no longer fires.
  • Token cost: only when the reviewed repo actually ships the file (else one failed git show, near-zero). When present, bounded by the line cap; the 15-min cache saves fetch/render, not prompt tokens.

Verification

  • prepare:pragent re-synced the shim + smoke test passed (shim patch active).
  • Ran the embedded Python directly: get_repo_file_content overrides the base no-op; existing file returns content, missing file returns ""; _provider_supports_repo_context now returns True.

The embedded shim is pure Python and not part of npm/Nx, so the root lint/typecheck/test/build do not cover it.

🤖 Generated with Claude Code

pr-agent 0.39.0 ships a new default `repo_context_files = ["AGENTS.md"]`,
but LocalGitProvider (the only provider meebox uses) inherits the base
no-op `get_repo_file_content`, so the feature is skipped with a per-run
WARNING and never injects project guidance into the review.

Patch LocalGitProvider.get_repo_file_content in the version-guarded shim
to read the blob from the base branch's tree (`git show <target>:<path>`,
never the working tree, so it stays independent of _prepare_repo's /ask
worktree sanitizing). Missing files / git errors degrade to "" so
build_repo_context treats them as "no context" and caches no fetch error.

Result: /review /describe /improve now inject the reviewed repo's
AGENTS.md (capped at repo_context_max_lines) as <instruction_files>, and
the WARNING no longer fires.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@huhamhire huhamhire added the enhancement New feature or request label Jul 9, 2026
…leased

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@huhamhire
huhamhire merged commit f15edd5 into dev Jul 10, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant