Repository navigation
feat(tools): let export_memories write to a file path - #54
Merged
Merged
Conversation
export_memories returned the whole envelope as one JSON blob in the tool response, which is an unwieldy payload for a large repo and competes with the model's context budget. Add an optional `path` argument: when set, the envelope is written to that file and the response is a short summary (counts + path) instead of the full JSON. Omitting `path` keeps the current inline behavior, so this is backward compatible. Path handling is safe: the path is resolved against the workspace root and rejected if it escapes (relative ../ or an absolute path pointing elsewhere), preventing a tool call from writing outside the project. Covered by tests: inline mode, file mode, a nested in-workspace path, and both traversal-guard rejections.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
This branch was successfully deployed
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.
Closes #35.
Problem
export_memoriesreturned the entire envelope as one JSON blob in the tool response. For a repo with many memories that is an unwieldy payload to round-trip through the client, and it competes with the model's context budget.Fix
Add an optional
pathargument:path: the envelope is written to that file and the response is a short summary (memory/alias counts + the resolved path) instead of the full JSON.path: unchanged - the full JSON is returned inline. Backward compatible.Safe path handling: the path is resolved against the workspace root (
FOSSEL_WORKSPACE), and rejected if it escapes - a relative../...or an absolute path pointing outside the workspace both fail with a clear error. This stops a tool call from writing anywhere on disk.Example:
Tests
tests/export-tool.test.ts(drives the real handler viainitDb+ a captured handler): inline mode, file mode (asserts the file content and the summary), a nested in-workspace path, and both traversal-guard rejections (relative../and absolute-outside).Verification
npm run typecheckclean; full suite 257/257 pass;npm run smokepasses;npm run buildsucceeds.Note
Does not create missing parent directories - the target directory must exist (standard
writeFileSyncbehavior). Can addmkdir -psemantics later if wanted; left out to keep the change minimal.