feat: replace pi-mono filesystem tools with native implementation#366
Merged
shadowfax92 merged 2 commits intomainfrom Feb 26, 2026
Merged
feat: replace pi-mono filesystem tools with native implementation#366shadowfax92 merged 2 commits intomainfrom
shadowfax92 merged 2 commits intomainfrom
Conversation
…entation Remove @mariozechner/pi-coding-agent and @mariozechner/pi-agent-core dependencies that caused bun compile issues (tree traversal, package.json resolution). Reimplement all 7 filesystem tools (read, write, edit, bash, grep, find, ls) using only Bun and Node.js built-in libraries. - No external binary dependencies (no ripgrep, fd, etc.) - Cross-platform: Linux, macOS, Windows - 107 tests covering all tools and utilities - Pure JS grep/find using Bun.Glob and async directory walking Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Contributor
Greptile SummaryReplaced external Key changes:
Technical improvements:
Confidence Score: 5/5
Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[AI Agent] -->|requests filesystem operation| B[ai-sdk-agent.ts]
B -->|builds toolset| C[buildFilesystemToolSet]
C -->|creates tools| D[Individual Tool Creators]
D --> E[createReadTool]
D --> F[createWriteTool]
D --> G[createEditTool]
D --> H[createBashTool]
D --> I[createGrepTool]
D --> J[createFindTool]
D --> K[createLsTool]
E -->|uses| L[utils.ts]
F -->|uses| L
G -->|uses| L
H -->|uses| L
I -->|uses| L
J -->|uses| L
K -->|uses| L
L -->|provides| M[truncation]
L -->|provides| N[walkFiles]
L -->|provides| O[path helpers]
L -->|provides| P[binary detection]
E -->|reads via| Q[Node fs/promises]
F -->|writes via| Q
G -->|edits via| Q
I -->|searches via| Q
J -->|finds via| Q
K -->|lists via| Q
H -->|executes via| R[Bun.spawn]
Last reviewed commit: 3a3ba57 |
| } | ||
|
|
||
| // Check if searching a single file | ||
| const pathStat = await stat(searchPath) |
Contributor
There was a problem hiding this comment.
wrap stat() in try-catch to handle ENOENT
Suggested change
| const pathStat = await stat(searchPath) | |
| let pathStat: Awaited<ReturnType<typeof stat>> | |
| try { | |
| pathStat = await stat(searchPath) | |
| } catch (err) { | |
| return { | |
| text: `Path not found: ${params.path || '.'}`, | |
| isError: true, | |
| } | |
| } |
Prompt To Fix With AI
This is a comment left during a code review.
Path: apps/server/src/tools/filesystem/grep.ts
Line: 150
Comment:
wrap `stat()` in try-catch to handle ENOENT
```suggestion
let pathStat: Awaited<ReturnType<typeof stat>>
try {
pathStat = await stat(searchPath)
} catch (err) {
return {
text: `Path not found: ${params.path || '.'}`,
isError: true,
}
}
```
How can I resolve this? If you propose a fix, please make it concise.Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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
@mariozechner/pi-coding-agentand@mariozechner/pi-agent-coredependencies that caused bun compile issues (tree traversal looking for package.json creates complexity during compilation)Changes
Added (
apps/server/src/tools/filesystem/)utils.tsread.tswrite.tsedit.tsbash.tsgrep.tsfind.tsls.tsbuild-toolset.tsModified
apps/server/package.json— removed pi-mono dependenciesapps/server/src/agent/tool-loop/ai-sdk-agent.ts— import changed to new build-toolsetbun.lock— updatedDeleted
apps/server/src/agent/tool-loop/filesystem-tools/pi-tool-adapter.tsTest plan
as anyin test helpers)bun run dist:servercompile succeeds without pi-mono tree issues🤖 Generated with Claude Code