MCPcopy Index your code
hub / github.com/usestrix/strix / build_diff_scope_instruction

Function build_diff_scope_instruction

strix/interface/utils.py:803–869  ·  view source on GitHub ↗
(scopes: list[RepoDiffScope])

Source from the content-addressed store, hash-verified

801
802
803def build_diff_scope_instruction(scopes: list[RepoDiffScope]) -> str:
804 lines = [
805 "The user is requesting a review of a Pull Request.",
806 "Instruction: Direct your analysis primarily at the changes in the listed files. "
807 "You may reference other files in the repository for context (imports, definitions, "
808 "usage), but report findings only if they relate to the listed changes.",
809 "For Added files, review the entire file content.",
810 "For Modified files, focus primarily on the changed areas.",
811 ]
812
813 for scope in scopes:
814 repo_name = scope.workspace_subdir or Path(scope.source_path).name or "repository"
815 lines.append("")
816 lines.append(f"Repository Scope: {repo_name}")
817 lines.append(f"Base reference: {scope.base_ref}")
818 lines.append(f"Merge base: {scope.merge_base}")
819
820 focus_files, focus_truncated = _truncate_file_list(scope.analyzable_files)
821 scope.truncated_sections["analyzable_files"] = focus_truncated
822 if focus_files:
823 lines.append("Primary Focus (changed files to analyze):")
824 lines.extend(f"- {path}" for path in focus_files)
825 if focus_truncated:
826 lines.append(f"- ... ({len(scope.analyzable_files) - len(focus_files)} more files)")
827 else:
828 lines.append("Primary Focus: No analyzable changed files detected.")
829
830 added_files, added_truncated = _truncate_file_list(scope.added_files)
831 scope.truncated_sections["added_files"] = added_truncated
832 if added_files:
833 lines.append("Added files (review entire file):")
834 lines.extend(f"- {path}" for path in added_files)
835 if added_truncated:
836 lines.append(f"- ... ({len(scope.added_files) - len(added_files)} more files)")
837
838 modified_files, modified_truncated = _truncate_file_list(scope.modified_files)
839 scope.truncated_sections["modified_files"] = modified_truncated
840 if modified_files:
841 lines.append("Modified files (focus on changes):")
842 lines.extend(f"- {path}" for path in modified_files)
843 if modified_truncated:
844 lines.append(
845 f"- ... ({len(scope.modified_files) - len(modified_files)} more files)"
846 )
847
848 if scope.renamed_files:
849 rename_lines = []
850 for rename in scope.renamed_files:
851 old_path = rename.get("old_path") or "unknown"
852 new_path = rename.get("new_path") or "unknown"
853 similarity = rename.get("similarity")
854 if isinstance(similarity, int):
855 rename_lines.append(f"- {old_path} -> {new_path} (similarity {similarity}%)")
856 else:
857 rename_lines.append(f"- {old_path} -> {new_path}")
858 lines.append("Renamed files:")
859 lines.extend(rename_lines)
860

Callers 1

Calls 1

_truncate_file_listFunction · 0.85

Tested by

no test coverage detected