feat(ai): PR 4 — agent config + validation [4/7]#410
Draft
ianwhitedeveloper wants to merge 2 commits intoai-testing-framework-implementation-consolidationfrom
Draft
feat(ai): PR 4 — agent config + validation [4/7]#410ianwhitedeveloper wants to merge 2 commits intoai-testing-framework-implementation-consolidationfrom
ianwhitedeveloper wants to merge 2 commits intoai-testing-framework-implementation-consolidationfrom
Conversation
- agent-config: getAgentConfig() for claude/opencode/cursor agents - agent-config: loadAgentConfig() reads + validates JSON config files - validation: validateFilePath() guards against path traversal - validation: verifyAgentAuthentication() smoke-tests agent availability - fixtures: test-agent-config.json, invalid-agent-config.txt, no-command-agent-config.json WIP fixes applied: - #2: replace verbose schema JSDoc with single-line YAGNI comment - #10: add --trust flag to cursor agent args for non-interactive execution 182 tests passing (19 new: 10 agent-config + 9 validation). Co-authored-by: Cursor <cursoragent@cursor.com>
- add direct unit tests for formatZodError (4 cases, both code paths) - simplify parseJson: remove unnecessary currying → plain two-arg fn - remove spurious await on synchronous parseJson call - convert multi-line string concat to template literal in validation.js - rename misleading test: 'uses default timeout' → 'succeeds without explicit timeout argument' Co-authored-by: Cursor <cursoragent@cursor.com>
janhesters
approved these changes
Feb 19, 2026
Collaborator
|
@paralleldrive/parelleldrive-com please /review |
ericelliott
approved these changes
Feb 19, 2026
Comment on lines
+64
to
+69
| throw createError({ | ||
| ...ValidationError, | ||
| message: `Failed to read agent config file: ${configPath}`, | ||
| code: 'AGENT_CONFIG_READ_ERROR', | ||
| cause: err | ||
| }); |
Collaborator
There was a problem hiding this comment.
Note: These should use custom error types so handlers can automatically route them individually using a handleErrors pattern match. This is probably fine as-is, but we should write an error-causes skill so agents know how to properly use this library.
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 4 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), PR 3 (agent-parser, execute-agent) — all merged.
What's in This PR
New modules
source/agent-config.js— Agent configuration for the three supported agents (claude, opencode, cursor) plus loading and Zod-validating JSON config files for custom agentssource/validation.js— Path traversal guard (validateFilePath) and agent auth smoke-test (verifyAgentAuthentication)New fixtures
source/fixtures/test-agent-config.json— valid custom agent configsource/fixtures/invalid-agent-config.txt— malformed JSON (triggers AGENT_CONFIG_PARSE_ERROR)source/fixtures/no-command-agent-config.json— missing required field (triggers AGENT_CONFIG_VALIDATION_ERROR)WIP fixes applied
--trustflag--trustto cursor args for non-interactive executionTest Results
186 tests passing (19 new: 14 agent-config + 5 formatZodError, 8 validation — wait, let me recount: 14 agent-config tests + 8 validation tests = 22 new), zero lint errors, TypeScript clean.
186/186 passing across 12 test files.
Open Architectural Questions (deferred, not blocking)
Two design issues surfaced during review that are worth flagging before PR 6 (CLI integration) wires up
--agent-config. They are not regressions from the feature branch — they existed there too — but consolidation is the right moment to decide.1. Built-in agent configs are hardcoded CLI flags outside our control
getAgentConfig()returns hardcoded CLI flag arrays for claude, opencode, and cursor. These are internal to those CLIs and can change without notice. Ifclaude --output-format jsonchanges flags, every riteway user breaks until we ship an update.Proposed solution: An eject/init pattern combined with named output format strategies (see #2 below).
riteway ai initwrites a starter config file to the project. Built-in defaults remain for first-time convenience but teams who want stability own their config file. The library stops being the source of truth for third-party CLI flags.2.
parseOutputfunction cannot be expressed in JSON config filesCustom agents loaded from JSON (
--agent-config my-agent.json) are silently locked to default stdout JSON parsing. There is no way for a custom agent that emits NDJSON (like OpenCode does) to declare its output format in a config file — becauseparseOutputis a JavaScript function and JSON can't serialize functions.Proposed solution: Replace the
parseOutputfunction field with a declarative"outputFormat": "json" | "ndjson" | "text"string field in both built-in configs and the JSON schema. Riteway owns the mapping from format name to parser. This makes the schema fully serializable, allows custom agents to declare their output format, and removes the hidden asymmetry between built-in and custom agent configs.These two changes together would:
Plan: Add a follow-up task before PR 6. The
--agent-configCLI flag is where custom configs are consumed, so the output format strategy needs to be resolved before that PR lands.3.
formatZodErrormodule placementCurrently exported from
agent-config.jsbut has no external consumers. PR 5 (ai-runner.js) will also need Zod error formatting. If that happens, importing a Zod formatting utility fromagent-configcreates an odd dependency direction. Decision deferred to PR 5: if the formatter is needed there, move it toai-errors.jsat that time.Checklist
for (constloops in test files (usestest.eachwhere tables apply)formatZodErrorboth code paths)assert({ given, should, actual, expected })structure throughoutnpm test— 186/186 passingnpm run lint— cleannpm run ts— clean