diff --git a/CHANGELOG.md b/CHANGELOG.md index a36082a1..3551d7f6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ and the versioning follows [Semantic Versioning](https://semver.org/). - Binary files in the diff (images, office documents, PDFs, …) now show their Git LFS status — a "Git LFS · <size>" tag for LFS-managed files, or a "⚠ Not LFS" tag for files stored inline in git. - Comments can now be anchored to a whole file (not only a single line) where the platform supports it (Bitbucket / GitHub): a "comment on file" entry in the diff, and existing file-level comments now display correctly instead of being shown as generic PR comments. +- Reviews now pick up the reviewed repository's own guidance file (`AGENTS.md`) as project context, so the review, description, and suggestions follow the project's stated conventions. ## [0.11.0] - 2026-07-07 diff --git a/CHANGELOG.zh-CN.md b/CHANGELOG.zh-CN.md index 40995a5e..b6267c69 100644 --- a/CHANGELOG.zh-CN.md +++ b/CHANGELOG.zh-CN.md @@ -11,6 +11,7 @@ - diff 中的二进制文件(图片、Office 文档、PDF 等)现会显示其 Git LFS 状态——受 LFS 管理的文件显示「Git LFS · <大小>」标记,直接内联存入 git 的文件显示「⚠ 非 LFS」标记。 - 现可对整个文件(而不仅是某一行)添加评论(平台支持时,Bitbucket / GitHub):diff 中新增「对文件评论」入口,且已存在的文件级评论现能正确归属显示,不再被当作 PR 通用评论。 +- 评审现会读取被审仓库自身的规范文件(`AGENTS.md`)作为项目上下文,使评审、描述与建议遵循该项目既定的约定。 ## [0.11.0] - 2026-07-07 diff --git a/apps/desktop/scripts/pragent-shim/meebox_pragent_shim/patches/local_git_provider.py b/apps/desktop/scripts/pragent-shim/meebox_pragent_shim/patches/local_git_provider.py index 809ca1c5..62d153ac 100644 --- a/apps/desktop/scripts/pragent-shim/meebox_pragent_shim/patches/local_git_provider.py +++ b/apps/desktop/scripts/pragent-shim/meebox_pragent_shim/patches/local_git_provider.py @@ -1,4 +1,4 @@ -"""LocalGitProvider patch (version-guarded): binary-safe get_diff_files + get_line_link anchor.""" +"""LocalGitProvider patch (version-guarded): binary-safe get_diff_files + get_line_link anchor + repo-context file fetch.""" from ..runtime import _EXPECTED_PRAGENT_VERSION, _pragent_version, _warn @@ -122,3 +122,29 @@ def get_pr_labels(self, update=False): return [] module.LocalGitProvider.get_pr_labels = get_pr_labels + + # get_repo_file_content: pr-agent 0.39.0's configuration.toml ships a new default + # `repo_context_files = ["AGENTS.md"]` — build_repo_context() fetches those files from the reviewed + # repo and injects them as so /review /describe /improve follow the project's own + # conventions. The base class returns "" (no-op), so LocalGitProvider is judged "does not support + # repository file fetching" and logs a WARNING each run while silently skipping the feature. Implement it + # by reading the blob straight from the base branch's tree object (not the working tree): the review's diff + # is head.commit vs merge-base(target_branch_name), and target_branch_name is the branch the PR merges + # into — the trusted "default/base branch" content the feature wants (repo_context_from_default_branch=true). + # Reading the tree object (never the working tree) also keeps this independent of _prepare_repo's working-tree + # sanitizing of agent instruction files (that guards the /ask CLI subprocess; repo_context serves the other + # tools). A missing file / any git error degrades to "" (no context) rather than raising, so + # build_repo_context treats it as "no context" and never caches a fetch error. + def get_repo_file_content(self, file_path, from_default_branch=False): + rel = (file_path or "").lstrip("/") + if not rel: + return "" + try: + # For a local provider there is no remote "default branch" distinct from the PR base, so both the + # default-branch and target-branch cases collapse to target_branch_name (guaranteed to exist by + # _prepare_repo). `git show :` returns the file text, or errors if the path is absent. + return self.repo.git.show(f"{self.target_branch_name}:{rel}") + except Exception: + return "" + + module.LocalGitProvider.get_repo_file_content = get_repo_file_content diff --git a/docs/arch/02-agent/05-pragent-runtime.md b/docs/arch/02-agent/05-pragent-runtime.md index 6fc56739..b0b904e2 100644 --- a/docs/arch/02-agent/05-pragent-runtime.md +++ b/docs/arch/02-agent/05-pragent-runtime.md @@ -62,6 +62,7 @@ Current patches: letting `/review`'s key_issues render with a structured file:line. - **Anthropic drops temperature**: new Claude models deprecate temperature, so all `anthropic/*` are put into the "don't send temperature" set. - **load_yaml tolerance**: an anchor marker taking a whole line breaks YAML → on parse failure, strip the marker and retry, avoiding a whole review crash. +- **repo-context file fetch**: pr-agent 0.39.0 defaults `repo_context_files = ["AGENTS.md"]`, but `LocalGitProvider` inherits the base no-op `get_repo_file_content` → the feature is skipped with a per-run WARNING. Implement it by reading the blob from the base branch's tree (`git show :`, never the working tree), so `/review /describe /improve` inject the reviewed repo's `AGENTS.md`/etc. as ``; a missing file degrades to `""`. - **Local CLI provider**: when `MEEBOX_CLI_MODE` is set, replace `chat_completion` wholesale with the "call the local CLI" version (see below). - **token usage collection**: see below.