Ability to pull files from GitHub, edit, and push back - #384
Conversation
Claude was confused since it said it goes on interfaces, but it actually goes on implementations.
This was written out by my human hand to illustrate what I'm going for, before engaging the agent to write any plans.
Written by Fable with lots of guidance from me as well as no fewer than FIVE review passes by Sol, each of which came up with more actual legit issues to fix.
This implements commit 1 of plans/worktrees.md. This introduces the new Gatekeeper APIs for interacting wit the git cache. They are not implemented yet, so workshop-backend fails to build at this point. (gatekeeper-cloudflare is updated to avoid breaking its test. No other gatekeeper needed such an update.)
This is commit 2 from the plan in plans/worktrees.md. This introduces the core new functionality underlying the git cache with remote provenance. The `gitObjectMetadata` table is introduced which tracks information about objects that may not yet be present locally, allowing them to be pulled on demand.
This implements commit 3 of plans/worktrees.md. This introduces the actual concept of worktrees as a type of workpiece, along with agent tools for operating on them.
This implements commit 4 of plans/worktrees.md. This introduces the Worktree binding API, accessible to agents via executeCode.
This implements commit 5 of plans/worktrees.md. This extends the GitHub gatekeeper to allow querying refs and to advertise the commits it holds so that they can be mounted. However, actually pulling them is not implemented yet (next commit).
This implements commit 6 of plans/worktrees.md. This commit implements support for pulling from GitHub, in order to fulfill requests to mount a worktree from commits advertised by the gatekeeper.
This implements commit 7 of plans/worktrees.md. This completes the series by implementing the ability to push to GitHub, including opening a PR!
Preview:
|
|
An agent can now mount a Git repo at a particular commit and do stuff with it.
This happens with NO containers, NO bash, NO git CLI. It's entirely JS/TS in a Durable Object
Specifically, the agent can create a "worktree", which appears to it kind of like a gadget that doesn't have any executable app. It's just code. The agent can read and edit files within the worktree using the same tool calls it uses to read and edit gadget code. A worktree is also a named binding in
env-- the binding provides a JavaScript API to allow programmatic operations, including the ability to read, edit, grep, diff, make commits, etc.The GitHub gatekeeper now makes commits visible in its API. Any time the gatekeeper tells the caller about a commit, it lets the Overseer know about the commit ID. If the agent subsequently tries to mount that commit, the Overseer will pull it from the gatekeeper. Pulls are shallow / lazy and populate the same local git storage used for gadget code.
The GitHub gatekeeper also now supports pushing commits and creating pull requests from them.
The plan file in
plans/worktrees.tscontains a more complete explanation and implementation plain which the remaining commits follow.This pull request was created entirely by my Cloudflare OS agent: kentonv/lanparty#10
TODO before merging:
env.WORKTREE.grep(".", pattern)and got an error because "." isn't recognized -- should special-case this.