fix(agents-squad): make handoff schema portable - #226
Open
dlynch90 wants to merge 1 commit into
Open
Conversation
Move absolute-path and traversal checks out of the model-facing Zod schema and into runtime validation so OpenAI-compatible providers do not reject the tool list before generation. Add a regression detector with escaped-literal and character-class controls.
There was a problem hiding this comment.
Pull request overview
This PR updates the agents-squad plugin’s model-facing handoff path schema to avoid JSON Schema regex lookarounds (which some providers reject), while preserving path safety via runtime validation and adding a regression detector that runs during collection validation.
Changes:
- Replaced lookaround-based schema constraints with runtime allowlist/relative/containment validation for handoff paths.
- Added a portability regression test to detect Zod regex lookarounds in the plugin source.
- Extended
npm run validateto run the new portability test.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| plugins/agents-squad/schema-portability.test.mjs | Adds a test that scans the plugin source for Zod regex lookarounds. |
| plugins/agents-squad/index.ts | Implements runtime handoff path validation and removes lookaround regex from the Zod schema. |
| package.json | Runs the new test as part of npm run validate. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Comment on lines
+306
to
314
| const pathFromHandoffsDir = relative(dir, resolved); | ||
| if ( | ||
| !pathFromHandoffsDir || | ||
| pathFromHandoffsDir === ".." || | ||
| pathFromHandoffsDir.startsWith(`..${sep}`) || | ||
| isAbsolute(pathFromHandoffsDir) | ||
| ) { | ||
| throw new Error(`Handoff path escapes directory: ${relativePath}`); | ||
| } |
Comment on lines
+7
to
+8
| function containsZodRegexLookaround(source) { | ||
| for (const match of source.matchAll(/\.regex\(\s*\//g)) { |
Comment on lines
1
to
9
| { | ||
| "name": "@cline/plugins-collection", | ||
| "version": "0.0.0", | ||
| "private": true, | ||
| "type": "module", | ||
| "scripts": { | ||
| "validate": "node scripts/validate-plugins.mjs" | ||
| "validate": "node scripts/validate-plugins.mjs && node --test plugins/agents-squad/schema-portability.test.mjs" | ||
| } | ||
| } |
Comment on lines
438
to
445
| const HandoffPathInput = z | ||
| .string() | ||
| .trim() | ||
| .min(1) | ||
| .max(240) | ||
| .regex( | ||
| /^(?!\/)(?!.*(?:^|\/)\.\.(?:\/|$))[A-Za-z0-9._/-]+$/, | ||
| "Use a relative file path with letters, numbers, '.', '_', '-', or '/'.", | ||
| .describe( | ||
| "Relative file path using letters, numbers, '.', '_', '-', or '/'. Must not be absolute or contain '..' segments.", | ||
| ); |
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
Why
OpenAI Codex rejects the current
properties.path.patternbefore generation because JSON Schema regex lookaround is unsupported. The same agents-squad fix shape already exists incline/cline; this ports it to the separately distributed official plugin collection.Verification
npm run validategit diff --checkRelated: cline/cline#12214, cline/cline#12205, cline/cline#11003