Repository navigation
feat(harness): grep, find and ls built-in tools - #64
Merged
Merged
Conversation
grep runs ripgrep and find runs fd inside the mounted sandbox: the host's or
the remote's own binary, or just-bash's built-in rg on a virtual mount, which
has no fd and says so. A missing binary is installed on first use, into
<home>/bin for the host and into the sandbox's own $HOME/.codework/bin for a
remote, downloaded on the host so the sandbox needs no network. ls lists
through the sandbox filesystem. Output, limits and truncation follow Pi.
The tools ship off, as Pi ships them. A plugin can declare `optIn: true`: it
keeps its built-in position but runs only once settings turn it on with
`{ "plugin": "codework.tool.grep", "enabled": true }`.
Plugin setup now gets `ctx.paths` (home, bin, cache, data, log).
Covered end to end on the host, a memory sandbox, live Daytona and Vercel
sandboxes, and live OpenAI and Anthropic models through the harness and the
CLI.
Co-Authored-By: Claude Opus 5.5 <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
Adds Pi's search and listing tools as built-in plugins.
rgrglimitmatches leave the sandbox. Context lines are read throughscanLines.fdin the sandbox. Virtual mounts have nofd, and the tool says so to the model instead of emulating it.rg --sort pathand sorted fd results, so results come back in the same order every run.Path not foundup front, as Pi's non-fd path does.Missing binaries
tool/binary.tschecks forrg/fdthe first time a tool needs them. It remembers per sandbox only that a binary was found.<home>/bin.$HOME/.codework/bin. The release is downloaded on the host and uploaded, so the sandbox needs no network access.Some providers (Daytona) merge stderr into stdout. The grep pipeline therefore sends ripgrep's exit status as a final JSON line and holds its stderr until the pipe has closed. find recognises fd's
[fd error]:lines.Opt-in, as in Pi
Pi's default tools are
read, bash, edit, write. A plugin can now declareoptIn: true: it keeps its built-in position but runs only after settings turn it on:{ "plugins": [{ "plugin": "codework.tool.grep", "enabled": true }] }grep, find and ls are opt-in. Configuration still never adds a plugin by itself. Once turned on, an opt-in plugin stays on when its module is listed again, for example by project settings.
Plugin context
Plugin
setupnow getsctx.paths(home,bin,cache,data,log), the harness's own directories on the host.global.tsgainsbin.Testing
All end to end, each ending in a snapshot under
__artifacts__/:Host and memory sandboxes (
tools.search.test.ts): one shared fixture with Pi's own cases:--pre=pattern that must not run anything.gitignorescoping (Pi #3303)grep and ls give the same results on both. The one real difference is recorded: real ripgrep lets
--globoverride.gitignore.Live Daytona and Vercel sandboxes (shared spec in the existing e2e suites): results identical to the host. Daytona used its own
rgand the tool installedfd; on Vercel the tool installed both.Live models through the harness (
tools.search.live.test.ts) and the real CLI (cli.search.live.test.ts): OpenAI and Anthropic answer a question that needs find, grep and ls. Through the CLI the tools are absent without settings and present with them.Opt-in: an end-to-end check that the tools are off by default and turned on by settings, plus catalog cases for the opt-in rule.
vp run typecheckpasses. Tests: harness 572, plugin 117, codework (including the live CLI test).🤖 Generated with Claude Code