Commit dfdedf6
feat(ai): PR 3 — Parsers + Execute Agent (#409)
Add agent-parser, extraction-parser, aggregation, and execute-agent
modules with full unit test coverage.
- agent-parser: parseStringResult, parseOpenCodeNDJSON, unwrapEnvelope
(new shared export), unwrapAgentResult. Shared unwrapEnvelope breaks
duplication between agent-parser and execute-agent (WIP fix #9).
- extraction-parser: parseExtractionResult with multi-strategy JSON
parsing (direct, markdown fence, pre-parsed object), and
resolveImportPaths for prompt file resolution.
- aggregation: normalizeJudgment, calculateRequiredPasses,
aggregatePerAssertionResults with Zod validation.
- execute-agent: extracted from ai-runner.js to break the circular
dependency (ai-runner ↔ test-extractor). Logger injected at
executeAgent call site rather than created inside spawnProcess
(WIP fix #8). Uses shared unwrapEnvelope from agent-parser.
- Test files use test.each for all table-driven cases per convention.
164 tests pass, 0 lint errors, TypeScript checks pass.
Co-authored-by: Cursor <cursoragent@cursor.com>
* fix(ai): address PR 3 code review findings
- aggregation.js: validate once in aggregatePerAssertionResults — capture
the Zod-validated result and compute Math.ceil inline, eliminating the
redundant second schema parse inside calculateRequiredPasses
- aggregation.js: remove misleading optional chaining (raw?.passed etc.)
after the null-guard throw; use plain property access
- agent-parser.js: replace acc.push() with [...acc, text] in reduce
accumulator to prefer immutability per JS style guide
- agent-parser.test.js: drop redundant "parsed object:" prefix from
unwrapEnvelope test.each given fields; remove duplicate standalone
"no result key" test that overlapped with test.each row
- aggregation.test.js: remove redundant export-existence assertion for
normalizeJudgment; add empty perAssertionResults edge case (vacuous
truth — every() on [] returns true)
- execute-agent.test.js: strengthen parseOutput test to verify stdout
and logger are threaded through as expected (documents WIP fix #8)
Co-authored-by: Cursor <cursoragent@cursor.com>
* fix(ai): address PR 3 author review findings
- aggregation.js: rename `raw` param to `judgeResponse` and
fold into single options object for normalizeJudgment; removes
the two-argument signature (breaking change, callers updated)
- aggregation.js: remove calculateRequiredPasses — math is inlined
in aggregatePerAssertionResults, eliminating double schema parse
- aggregation.test.js: remove calculateRequiredPasses describe block;
fix Try() usage (direct fn ref, not arrow wrapper); update all
normalizeJudgment call sites to new single-options signature
- execute-agent.js: extract magic number 500 to maxOutputPreviewLength
constant (camelCase per javascript.mdc); applied to all 3 truncation sites
- execute-agent.test.js: replace try/catch antipatterns with await Try();
add Try import from riteway.js
- extraction-parser.test.js: strengthen weak typeof assertions to check
specific fields; strengthen cause !== undefined to cause.name === SyntaxError
151 tests pass, 0 lint errors, TypeScript clean.
Co-authored-by: Cursor <cursoragent@cursor.com>
* fix(ai): address PR 3 follow-up review findings
- constants.js: rename calculateRequiredPassesSchema to
aggregationParamsSchema — name now reflects what the schema
validates (aggregation input params) rather than the deleted
calculateRequiredPasses function; update all import sites
- aggregation.test.js: add 6 missing Zod validation edge cases
for aggregatePerAssertionResults (zero runs, negative runs,
non-integer runs, NaN runs, negative threshold, NaN threshold)
— coverage gap introduced when calculateRequiredPasses and its
tests were removed; all cases now exercised via
aggregatePerAssertionResults test.each
157 tests pass, 0 lint errors, TypeScript clean.
Co-authored-by: Cursor <cursoragent@cursor.com>
* refactor(test): complete PR review remediation
🐛 - Remove weak instanceof Error assertions
🔄 - Add threshold calculation verification tests
Tests now verify threshold-based pass/fail logic directly
164 tests passing, 0 lint errors, TypeScript clean
Co-authored-by: Ian White <ian.white.developer@gmail.com>
* fix(ai): remove implementation detail from test
- execute-agent.test.js: remove logger type assertion from
parseOutput test — typeof checks violate tdd.mdc:64 and
logger threading is an implementation detail; the three
remaining assertions (call count, stdout arg, parsed result)
collectively verify correct integration
164 tests pass, 0 lint errors, TypeScript clean.
Co-authored-by: Cursor <cursoragent@cursor.com>
---------
Co-authored-by: Cursor <cursoragent@cursor.com>1 parent 5bcb456 commit dfdedf6
10 files changed
Lines changed: 1843 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
0 commit comments