Code Quality Pipeline
Relevant source files
The following files were used as context for generating this wiki page:
The Code Quality Pipeline is a specialized module designed to ensure code integrity following modifications by the AI agent. Its primary purpose is to auto-detect and execute project-specific quality gates—such as linting, type-checking, testing, and building—to verify that changes do not introduce regressions or violate repository standards.
The pipeline acts as a verification layer within the Agent Runtime Loop. It is triggered automatically during implementation tasks to validate file modifications before a task is considered complete. Sources: src/core/CodeQualityPipeline.ts:1-74, src/core/agent.ts:1218-1250
Pipeline Architecture and Workflow
The pipeline operates through a sequence of discovery and execution phases. It identifies available scripts from the project's package.json and runs them in a specific order (parallel vs. sequential) to optimize for speed and dependency requirements.
Execution Flow
- Script Detection: Scans the workspace root for
package.jsonand identifies relevant scripts. - Auto-Fix Phase: If configured, runs linting fix commands before formal checks.
- Parallel Execution: Runs non-dependent checks (linting and type-checking) concurrently.
- Sequential Execution: Runs tests and build commands, which typically depend on successful type-checking.
The following diagram illustrates the internal logic of the CodeQualityPipeline.run() method:
Execution logic for verifying modifications. Sources: src/core/CodeQualityPipeline.ts:90-132, tests/core/CodeQualityPipeline.spec.ts:124-205
Key Components
Script Detection
The pipeline utilizes a pattern-matching system to identify scripts in package.json. It looks for primary names and common alternatives for different quality gates.
| Check Type | Primary Name | Alternatives |
|---|---|---|
| Lint | lint | lint:check, eslint |
| Typecheck | typecheck | type-check, tsc, types, check:types |
| Test | test | test:unit, vitest, jest |
| Build | build | build:prod, compile |
Sources: src/core/CodeQualityPipeline.ts:77-82, src/core/CodeQualityPipeline.ts:154-180
Execution Engine
The runCheck method handles the execution of individual shell commands. It wraps child_process.exec with a default timeout of 5 minutes and captures both stdout and stderr for analysis. Output is automatically truncated to the first and last 25 lines (50 lines total) to prevent overwhelming the agent's context. Sources: src/core/CodeQualityPipeline.ts:87, src/core/CodeQualityPipeline.ts:206-241, src/core/CodeQualityPipeline.ts:276-291
Integration with AutohandAgent
The pipeline is integrated into the AutohandAgent via the runInstruction workflow. When the agent detects an "implementation" intent and files are modified during the session, it invokes the pipeline to provide immediate feedback to the LLM.
Integration between the agent core and the quality verification system. Sources: src/core/agent.ts:1016-1035, src/core/agent.ts:1218-1250, src/core/actionExecutor.ts:311-344
Data Structures
QualityResult
The pipeline returns a comprehensive result object used by the agent to determine the success of the verification phase.
export interface QualityResult {
passed: boolean; // True if all checks passed or were skipped
checks: QualityCheck[]; // Detailed result for each individual check
duration: number; // Total execution time in ms
summary: string; // Formatted string (e.g., "3 passed, 1 failed")
}
Sources: src/core/CodeQualityPipeline.ts:46-51
QualityOptions
Users can configure the pipeline behavior through specific flags, allowing for faster iterations by skipping heavy checks.
| Option | Type | Description |
|---|---|---|
skipLint | boolean | Skips the linting phase |
skipTypecheck | boolean | Skips TypeScript/type validation |
skipTest | boolean | Skips unit/integration tests |
skipBuild | boolean | Skips the project build phase |
autoFix | boolean | Attempts to run --fix on linter before check |
testFilter | string | Appends a --grep filter to the test command |
Sources: src/core/CodeQualityPipeline.ts:56-63, tests/core/CodeQualityPipeline.spec.ts:207-260
Summary
The Code Quality Pipeline provides a critical automated safety net for AI-driven code modifications. By dynamically discovering and running existing project scripts, it ensures that the agent remains compliant with local development standards and prevents the accidental introduction of broken code into the repository. Sources: src/core/CodeQualityPipeline.ts:1-74, src/core/agent.ts:1240-1250