fix(pi): loosen plan-mode write gate to directory scope#594
Closed
backnotprop wants to merge 1 commit intomainfrom
Closed
fix(pi): loosen plan-mode write gate to directory scope#594backnotprop wants to merge 1 commit intomainfrom
backnotprop wants to merge 1 commit intomainfrom
Conversation
The write/edit gate required an exact path match against planFilePath, so `/plannotator plans/` (or any directory-style path) blocked every write the agent attempted, including files inside that same directory. Agents then fell back to bash/python heredocs to bypass the gate. Now directory-scoped: writes inside the plan's directory are allowed when planFilePath ends with a separator, has no file extension, or points to a subdirectory. Default `PLAN.md` behavior is unchanged. Extracted the gate into a pure function in tool-scope.ts with test coverage for the main cases (default file, trailing-slash dir, bare dir name, subdir sibling, traversal rejection, absolute paths). For provenance purposes, this commit was AI assisted.
7 tasks
Owner
Author
|
Superseded by #595, which redesigns plan mode around agent-supplied file paths instead of the configured-path gate. That approach avoids both the sibling-unlock regression this PR introduced and the pre-existing submit-on-directory failure. |
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
write/editgate did an exact-path comparison againstplanFilePath, so/plannotator plans/blocked every file insideplans/and the agent fell back tobash cat > fileto bypass it.planFilePathends with a separator, has no file extension, or points to a subdirectory. DefaultPLAN.mdbehavior is unchanged.isPlanWritePathAllowed) intool-scope.tswith 6 new unit tests.Repro that now works
Test plan
bun test apps/pi-extension/tool-scope.test.ts— 9 pass, 0 failtsc --noEmit -p apps/pi-extension/tsconfig.json— clean/plannotator plans/in a fresh project, confirm plan writes succeed/plannotator PLAN.md(default), confirm behavior unchanged and writes tosrc/still blocked/plannotator plans/auth.md, confirm sibling writes (plans/notes.md) allowed, writes outside blocked