feat(ai): PR 5 — test extractor + core runner [5/7]#415
Closed
ianwhitedeveloper wants to merge 1 commit intoai-testing-framework-implementation-consolidationfrom
Closed
feat(ai): PR 5 — test extractor + core runner [5/7]#415ianwhitedeveloper wants to merge 1 commit intoai-testing-framework-implementation-consolidationfrom
ianwhitedeveloper wants to merge 1 commit intoai-testing-framework-implementation-consolidationfrom
Conversation
9eeb99e to
8dca8e1
Compare
8 tasks
- Add AgentConfigReadError, AgentConfigParseError, AgentConfigValidationError to ai-errors.js - Move formatZodError from agent-config.js to ai-errors.js (correct dependency direction) - Update agent-config.js to use specific AgentConfig* error types - Update agent-config.test.js to use handleAIErrors routing (no .cause.code inspection) - Extract truncateOutput helper in execute-agent.js (eliminates duplication) - Inject logger into resolveImportPaths; remove debug boolean from extraction-parser.js - Add test-extractor.js: buildExtractionPrompt, buildResultPrompt, buildJudgePrompt, extractTests (no circular dep — imports from execute-agent.js) - Add ai-runner.js: readTestFile, runAITests, verifyAgentAuthentication (orchestration only) - Add @paralleldrive/cuid2 dependency for test temp-dir naming Co-authored-by: Cursor <cursoragent@cursor.com>
8dca8e1 to
2fa5f31
Compare
13 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
PR 5 of 7 in the consolidation of draft PR #394 — decomposing the 80-commit monolith into small, focused, dependency-ordered PRs. Targets
ai-testing-framework-implementation-consolidation(staging area before master).Depends on: PR 1 (ai-errors, constants), PR 2 (debug-logger, tap-yaml), PR 3 (agent-parser, execute-agent), PR 4 (agent-config, validation) — all merged.
What's in This PR
New modules
source/test-extractor.js— Two-agent prompt pipeline for extracting and evaluating test assertions:buildExtractionPrompt— instructs an LLM to parse a test file into structured{ userPrompt, importPaths, assertions[] }databuildResultPrompt— instructs the result agent to execute the user prompt and return plain textbuildJudgePrompt— instructs the judge agent to evaluate one result against one requirement and return TAP YAMLextractTests— full extraction pipeline: calls extraction agent → validates result → resolves imported prompt files → returns{ userPrompt, promptUnderTest, assertions }source/ai-runner.js— Orchestration layer for the two-agent test execution flow:readTestFile— reads a test file from diskrunAITests— full pipeline: read file → extract tests → run N runs (result agent once per run, judge agents per assertion in parallel) → aggregate resultsverifyAgentAuthentication— delegates tovalidation.jswith injectedexecuteAgentModified modules
source/ai-errors.js— Three new error types (AgentConfigReadError,AgentConfigParseError,AgentConfigValidationError) +formatZodErrormoved here fromagent-config.js(correct dependency direction for PR 5)source/execute-agent.js—truncateOutputhelper extracted to eliminate the duplicated truncation expressionsource/agent-config.js— Updated to use specificAgentConfig*error types; importsformatZodErrorfromai-errors.jssource/extraction-parser.js—resolveImportPathssignature updated from(importPaths, projectRoot, debug)to(importPaths, projectRoot, logger)for proper dependency injectionDependency graph (this PR)
No cycles.
test-extractor.jsimportsexecuteAgentdirectly fromexecute-agent.js— not fromai-runner.js. This was the circular dependency in the original feature branch.WIP Fixes Applied
formatZodErrormoved toai-errors.js;agent-config.jsnow imports from theretest-extractor.jsparseTAPYAMLandparseExtractionResultimported directly by callersresolveImportPathsrawconsole.error(debug)callsloggerparameterAgentConfig*error types (Eric's PR #410 review)ai-errors.js;agent-config.jsuses specific types; tests usehandleAIErrorsroutingtruncateOutputduplicated expressionexecute-agent.jsArchitectural Notes (Deferred)
outputFormatstring strategy +parseOutputThe
parseOutput: fnpattern stays as-is for PRs 5–7. TheoutputFormatdeclarative string strategy (making configs fully serializable forriteway ai init) and the IO/mapping separation inexecuteAgentare deferred to the post-consolidation epic. See the consolidation plan's Post-Consolidation section for details.runAITestsdefaultagentConfigThe
runAITestsdefault ({ command: 'claude', args: [...] }) duplicatesgetAgentConfig('claude'). Deferred to post-consolidation alongside theoutputFormatrefactor — tracked in the plan.Test Results
150 tests across 13 test files, all passing. 18 new tests: 12 in
test-extractor.test.js+ 6 inai-runner.test.js.test-extractortests coverbuildExtractionPrompt,buildResultPrompt,buildJudgePrompt(full string comparison), andextractTests(integration tests using real node subprocesses for the agent mock, temp files for imports)ai-runnertests coverreadTestFileandrunAITestsend-to-end using a two-agent node mock (extraction → result → judge) with hermetic temp dirs — no reliance on project filesChecklist
test-extractor.js→execute-agent.js(notai-runner.js)test-extractor.jsformatZodErrormoved toai-errors.js(correct dependency direction)handleAIErrorsrouting pattern used throughout — no.cause.codeinspection in teststest.eachfor any table-driven cases; nofor...ofloops in test filesallNoopspread patternnpm test— 150/150 passingnpm run lint— cleannpm run ts— clean