Language and Framework Specific Settings
Relevant source files
The following files were used as context for generating this wiki page:
Language and Framework Specific Settings define how the PR-Agent and autonomous repair tools interact with different programming environments. These settings enable the system to detect project types, execute appropriate validation commands, and parse language-specific error logs to facilitate automated code improvements and fixes.
The system uses these configurations to tailor its behavior based on the detected presence of specific manifest files (like package.json, Cargo.toml, or go.mod). This ensures that tools like autofix.py apply changes that are idiomatic and verified against the correct language toolchain.
Sources: scripts/autofix.py:65-90, README.md:1-15
Framework Detection and Test Execution
The detect_test_runner function identifies the project's technical stack by checking for specific files in the repository root or subdirectories. Once it identifies the environment, it selects the corresponding command for validation.
Supported Language Environments
The following table details how the system identifies frameworks and the commands it executes for each:
| Environment | Detection Marker | Command Executed | Context |
|---|---|---|---|
| Rust (Workspace) | v2/Cargo.toml | cargo check --workspace --no-default-features | Subdirectory v2 |
| Rust (Standard) | Cargo.toml | cargo check --workspace | Root directory |
| Node.js (Mobile) | ui/mobile/package.json | npm test --if-present | Subdirectory ui/mobile |
| Node.js (Standard) | package.json | npm test or npm run build | Root directory |
| Python | pyproject.toml or requirements.txt | pytest -q | Root directory |
| Go | go.mod | go test ./... | Root directory |
Sources: scripts/autofix.py:65-87
Logic Flow for Detection
The following diagram illustrates the decision logic for selecting a test runner based on the modified files and filesystem markers.
The system prioritizes specific subdirectories (like v2/ or ui/mobile/) before checking the root directory to support monorepos or multi-module layouts.
Sources: scripts/autofix.py:67-89
Error Parsing and Path Extraction
The system utilizes regular expressions to extract file paths and line numbers from language-specific compiler and runtime error logs. This allows the AI to focus its repairs on the exact files causing CI failures.
Pattern Recognition
The extract_relevant_files_from_error function employs two primary regex patterns:
- Rust Style: Recognizes patterns like
--> path/to/file.rs:line. - General Style: Recognizes common file extensions including
.rs,.ts,.tsx,.js,.jsx,.py,.go,.toml, and.jsonfollowed by a line number colon.
# Regex implementation for error extraction
for m in re.finditer(r"-->\s+([a-zA-Z0-9_\-/\.]+\.\w+):(\d+)", error_log):
# Extracts path from Rust-style pointer
for m in re.finditer(r"([a-zA-Z0-9_\-/\.]+\.(?:rs|ts|tsx|js|jsx|py|go|toml|json)):(\d+)", error_log):
# Extracts path from general language outputs
Sources: scripts/autofix.py:284-291
Validation and Rollback Mechanism
When a fix is generated, the system performs a language-specific verification. If the validation command fails, the system rolls back the changes to maintain repository integrity.
This ensures that autonomous repairs do not introduce new regressions that break the build or existing tests.
Sources: scripts/autofix.py:237-255
Global vs. Repository Configuration
Settings can be applied globally or overridden at the repository level.
- Global Configuration: Loaded from
JWEB0689/pr-agent-settings/.pr_agent.tomlfor all repositories under the owner. - Repository Overrides: Local
.pr_agent.tomlfiles in specific repositories take precedence over global settings.
Sources: README.md:5-15
Language and framework specific settings enable the autonomous agent to act as a "senior software engineer," applying surgical fixes that are idiomatic to the specific language environment while ensuring every change is verified by the project's own toolchain.
Sources: scripts/autofix.py:175-185, scripts/autofix.py:295-305