Skip to content

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

2 Commits

Folders and files

Repository files navigation

Pi Patchgate

Pi Patchgate is an extension for the Pi coding agent that gives a cheaper or local model the first two attempts at a focused patch. It runs the repository's checks on each valid proposal and can hand off to a stronger model if both attempts fail. The result is a Git patch you can review before applying.

Install

Requires Git, Node.js 22.19 or newer, and Pi 1.5.2 or newer within the 1.x series.

pi install git:github.com/RisqueSept/pi-patchgate

From a local clone, run npm ci and start Pi in the target project with pi -e /absolute/path/to/pi-patchgate/src/index.ts.

Configure a repository

Create .pi/patchgate.json at the Git root. Choose a fast model available in the Pi model picker, optionally choose a fallback model, and configure the commands used to validate a patch. Each command is an array containing an executable and its arguments. Pi resolves credentials using its normal provider configuration.

{
  "fastModel": "openai/gpt-5-mini",
  "strongModel": "openai/gpt-5.2",
  "verify": [["npm", "ci"], ["npm", "test"]],
  "timeoutMs": 120000
}

Checks run sequentially in a fresh temporary Git worktree for each proposal. Include dependency setup in verify when the checks need it. The timeout applies per command. Checks execute locally with your OS permissions, including any changed project code they load. Use them in repositories you trust. Selected source files, prior diffs and bounded verification output can be sent to the configured providers.

Use a local editor with a cloud planner

Start Ollama on your machine and pull a coding model. The 7B example below is a starting point for benchmarking.

ollama pull qwen2.5-coder:7b

Merge this provider into your existing ~/.pi/agent/models.json. Use the Ollama model tag from ollama list. Pi also supports llama.cpp and other compatible endpoints.

{
  "providers": {
    "ollama": {
      "baseUrl": "http://127.0.0.1:11434/v1",
      "api": "openai-completions",
      "apiKey": "ollama",
      "models": [{ "id": "qwen2.5-coder:7b" }]
    }
  }
}

Set "fastModel": "ollama/qwen2.5-coder:7b" in .pi/patchgate.json. In Pi, select your preferred cloud model with /model and ask it to plan the task and delegate the edit to patchgate. The cloud model remains the session's planner. The Ollama model gets the focused brief and files, generates the patch, and can retry locally with test feedback.

Omit strongModel to end after the two local attempts. If you configure a cloud strongModel, escalation sends it the selected files, the previous candidate diff and bounded verification output. The delegation tool returns a status and, on success, the local patch path. The cloud planner can still receive repository content through its regular Pi tools, for example if it reads a file while planning or opens the patch during review.

Use

In a trusted Pi session, run:

/patchgate src/validation.ts, test/validation.test.ts -- Reject empty usernames and cover the edge case in the existing tests

Pi also exposes a patchgate tool to the main agent when the config is present at session start. The agent can choose the existing files and pass an implementation brief. The command takes paths relative to the Git root and uses the committed contents at HEAD. The first release supports focused changes to existing UTF-8 files, with a combined input cap of 48 KB.

Patchgate sends the fast model any failed candidate diff and bounded error output for a single retry. A configured fallback model gets the final attempt. If verification passes, the extension returns a patch path under the repository's Git metadata directory. Review the patch and run git apply --check /path/to/validated.patch from the repository root before applying it with git apply /path/to/validated.patch. Local changes stay in your working tree throughout generation.

Development

npm ci
npm run check
npm test

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages