Repository navigation
Refactor Autofix Architecture: Extensible Tool Adapters & Default Toolchains - #327
google-labs-jules[bot] wants to merge 25 commits into
Conversation
|
👋 Jules, reporting for duty! I'm here to lend a hand with this pull request. When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down. I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job! For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with New to Jules? Learn more at jules.google/docs. For security, I will only act on instructions from the user who triggered this task. |
🦋 Changeset detectedLatest commit: b503c51 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Refactor autofix architecture to support default toolchains, capability-based detection, and extensible tool adapters. Python uses Ruff as the default toolchain without requiring dependency detection. JavaScript/TypeScript employs hybrid detection respecting explicit scripts and tool configuration. Core orchestration is language-agnostic with deterministic conflict resolution and aggregated error handling.
Decompose tokenizeShellCommands into smaller helper functions (processQuoteOrEscape, getSeparatorLength, skipComment) to reduce cyclomatic complexity for CodeFactor. Rebuild distribution bundles.
Correct shell comment parsing so '#' only begins a comment when starting a shell word (at line start or preceded by whitespace), preventing URL fragments and words containing '#' from discarding subsequent commands.
Support leading shell environment variable assignments (e.g., NODE_ENV=production npm run format:write) in doesFixScriptDelegateTo so package-manager delegations are properly recognized and redundant formatting or linting tasks are not scheduled. Rebuild bundles.
- Preserve single/double quoted script arguments and executables in doesFixScriptDelegateTo while maintaining token boundaries. - Decompose BiomeAdapter into independent format and lint tasks so partial capability conflicts resolve cleanly. - Fix JavaScriptScriptAdapter detection for check-mode scripts. - Add comprehensive regression and integration tests, re-build dist.
Decompose Biome into discrete formatting, linting, and safe assist actions (--formatter-enabled=false --linter-enabled=false) to preserve safe assist actions while enabling capability conflict resolution. Synchronize autofix/README.md documentation. Rebuild bundles.
Model 'assist' as an independent capability in Capability type and BiomeAdapter so separate format and lint scripts do not mistakenly suppress Biome safe assist actions. Synchronize documentation & dist.
- Ensure fix scripts delegating exclusively to formatting or linting only cover those specific capabilities, avoiding suppression of independent Biome Assist tasks. - Prevent check-mode fallback to format/fmt so check mode is strictly non-writing. - Update regression tests, README documentation, and dist bundles.
- Avoid overclaiming autofix capability for scripts executing or delegating only to formatting or linting, or unknown custom scripts. - Reject write-capable lint commands (--fix, --write) in check mode. - Streamline autofix/README.md to a concise, user-oriented guide. - Update tests and rebuild distribution bundle dist/autofix.mjs.
Extract checkCoverage and createFixScriptMappings helper functions to simplify capability mapping and reduce cyclomatic complexity in resolveFixScriptTasks. Rebuild dist/autofix.mjs.
- Require explicit write flags (--write, --fix, vp fmt, vp lint --fix) before assigning formatting/linting autofix capabilities to scripts. - Prevent read-only commands (prettier ., eslint .) from suppressing tools. - Prevent standalone vp fmt and vp lint from overclaiming full autofix. - Apply write-safety check to format:check, fmt:check, lint:check, and lint to guarantee check mode is strictly read-only. - Add regression tests and rebuild dist/autofix.mjs.
- Inspect parsed command tokens to distinguish actual tool invocations from arguments and wrappers like echo or comments. - Require verified write flags (--write, -w, --fix) before attributing formatting/linting autofix capabilities to commands. - Prevent read-only format scripts (prettier --check) from being selected in fix mode and suppressing dedicated formatters. - Validate format:check, fmt:check, lint:check, and lint against write flags to guarantee check mode is strictly read-only. - Add regression tests and rebuild dist/autofix.mjs.
- Introduce shared execution model: Capability, ExecutionTask, ToolAdapter, LanguageProvider, and AutofixRegistry. - Set Ruff as default Python toolchain without dependency checks or pyproject declarations. - Implement hybrid JavaScript detection with explicit script precedence, check-mode safety, and tool adapters for Biome, Prettier, ESLint, Oxlint, Oxfmt, and Vite+. - Support independent Biome assist actions alongside format and lint. - Add explainable planning, error aggregation, and comprehensive tests.
- Implement fail-safe tri-state script classification ('read-only', 'write-capable', 'unknown') in check mode.
- Reject unverified, unknown, and write-capable scripts in check mode across all check conventions.
- Positively verify write-capable formatting commands before selecting format candidates and claiming formatting capabilities.
- Prevent unverified scripts from suppressing dedicated formatter adapters.
- Revert autofix README to PR base branch state without modifications.
- Add regression tests covering check-mode safety, delegation cycles, and formatter verification.
- Decompose resolveFixScriptTasks into modular helper functions - Address CodeFactor complexity check warning - Rebuild distribution bundles cleanly
- Prevent unsafe shell commands with redirections, backgrounding, or substitutions from being classified as read-only - Fail closed on malformed quotes and incomplete command substitutions - Fall back to fmt:check when format:check cannot be safely classified as read-only - Regenerate dist/autofix.mjs bundle - Add regression test coverage for shell safety and check script candidate fallback Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
#332) * fix(autofix): shell variable expansion safety and windows binary shims * fix(autofix): reject explicit ps1 shims and verify windows binary resolution * fix(autofix): restrict windows executable extensions * fix(autofix): restrict windows executable extensions --------- Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
* fix(autofix): nested script delegation and classification issues - F-01: Prevent duplicate formatting and linting task execution from nested script delegation via recursive delegation resolver. - F-02: Reject commands with file-writing side effects (cache, output-file, reporter-file, init, etc.) from read-only classification. - F-03: Use active call-path tracking instead of global visited sets to permit sequential delegation without false circular-dependency detection. - Synchronize dist/autofix.mjs bundle. * fix(autofix): nested script delegation and classification issues - F-01: Prevent duplicate formatting and linting task execution from nested script delegation via recursive delegation resolver. - F-02: Reject commands with file-writing side effects (cache, output-file, reporter-file, init, etc.) from read-only classification, while classifying ESLint --fix-dry-run as read-only. - F-03: Use active call-path tracking instead of global visited sets to permit sequential delegation without false circular-dependency detection. - Add changeset for patch release. - Synchronize dist/autofix.mjs bundle. --------- Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
* fix(autofix): standalone adapter conflict resolution and vite-plus detection
- F-01: Include standalone adapters in capability conflict resolution by reusing processCandidateTools and sharing coveredCapabilities.
- F-02: Make Vite+ detection resistant to false positives using parseCommandInvocations.
- Rebuild dist/autofix.mjs bundle.
- Add changeset and comprehensive regression tests.
* fix(autofix): provider capability isolation and vite-plus wrapper detection
- F-01: Preserve capability isolation across language providers using scope-based capability tracking (adapter.scope ?? provider.id / 'standalone'), preventing unrelated language providers from suppressing each other's execution tasks.
- F-02: Support Vite+ detection through command wrappers (cross-env, sh -c, bash -c, package-manager runners, script delegations) via unwrapEnvironmentWrapper and hasVitePlusCommand.
- Rebuild dist/autofix.mjs bundle.
- Add changeset and comprehensive regression tests.
* fix(autofix): standalone adapter scope semantics and cross-env option parsing
- F-01: Clarify and correct standalone adapter scope semantics with explicit conflict domains, defaulting unassigned standalone adapters to isolated per-adapter scopes (standalone:${id}) and unassigned provider adapters to provider.id.
- F-02: Implement option-aware parsing in unwrapEnvironmentWrapper for cross-env and cross-env-shell to handle options consuming separate arguments (-f, --file, -c, --config, --env-file), inline values (--option=val), boolean flags, and delimiter -- while failing closed on unrecognized options.
- Rebuild dist/autofix.mjs bundle.
- Add changeset and comprehensive regression tests.
* fix(autofix): correct cross-env CLI parsing and unwrapping
- Align unwrapEnvironmentWrapper with actual cross-env CLI syntax by removing hypothetical options (-f, --file, etc.) and stripping leading environment variable assignments.
- Update regression tests to verify valid cross-env invocations and prevent false-positive detection from unsupported options or unrelated commands.
- Synchronize dist/autofix.mjs bundle.
* fix(autofix): reject invalid shell syntax during vite-plus detection
- Expose syntax error diagnostics via parseCommandInvocationsDetailed.
- Make hasVitePlusCommand reject commands containing confirmed shell syntax errors (unterminated quotes, trailing escapes).
- Synchronize dist/autofix.mjs bundle.
- Add regression tests covering malformed commands and wrappers.
---------
Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
* fix(autofix): handle environment wrappers in script delegation * fix(autofix): parse quoted shell commands in cross-env-shell * fix(autofix): preserve syntax errors in recursive script analysis --------- Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
Refactors the autofix architecture to introduce a shared, capability-based execution model with extensible tool adapters and default toolchains:
findRuffDependencyInToml,isRuffDeclaredInProject, etc.) removed fromsrc/python-env.ts.fix,check:fix,format:write,lint:fix, etc.) while generic validation scripts (check,test,typecheck) are strictly excluded from fix mode.ToolAdapter,LanguageProvider,ExecutionTask,ExecutionEngine,AutofixRegistry,planExecution) with deterministic conflict resolution and explainable execution plan logging in CI.PR created automatically by Jules for task 15113170007543883834 started by @torn4dom4n