← Catalog

@juanem1/pi-git

Focused Git tools for Pi with explicit confirmation for mutations.

Package

Install

Install with PiG

pig install npm:@juanem1/pi-git

Install with Pi

pi install npm:@juanem1/pi-git
Review before installing

Packages run code with your permissions and influence agent behavior. Catalog inclusion is not a security audit. Review the source before installing a third-party package.

Pi manifest JSON

The pi field of package.json.

{
  "extensions": [
    "./extensions/git.js"
  ]
}

README

Written by the package's publisher, shown as published in version 0.2.0 (README.md). PiG does not review it.

Package pi-git

A Pi package for Git, with no npm dependencies or installation scripts. Commits, pushes, and worktree changes require individual confirmation, unless the person running Pi pre-authorizes them (see Runs without a person). It does not add co-authors or impose a commit message format.

Requirements

  • Pi
  • Git
  • Node.js 22 or later

Install in Pi

Install from npm:

pi install npm:@juanem1/pi-git

Or from a local clone:

git clone https://github.com/juanem1/pi-git.git
pi install ./pi-git

Add -l to install it only for the current project (.pi/settings.json). Restart Pi or run /reload if it is already open.

To try it without installing, from a local clone:

pi -e ./pi-git

To update or uninstall:

pi update npm:@juanem1/pi-git
pi remove npm:@juanem1/pi-git

Tools

ToolBehavior
git_statusBranch, staged, modified, and new files.
git_diffLocal or staged diff, or diff against a revision; optional literal paths.
git_logUp to 200 commits; 20 by default.
git_showCommit message and diff.
git_commitConfirms the message, branch, and files; commits only those complete files, without pushing.
git_pushConfirms the remote, destination, branch, and commit; pushes only the current branch.
git_worktree_listLists existing worktrees.
git_worktree_addConfirms a new path and branch; does not change the current worktree's branch.
git_worktree_removeConfirms removal of a clean worktree; preserves its branch.
git_worktree_prunePreviews and confirms cleanup of metadata for missing worktrees.

File paths are relative to the root of the current repository. Commit does not accept directories: list individual files and both paths of a renamed file. If a file is partially staged, its entire working tree content is committed. Other already-staged files are excluded from the commit.

Security limits

  • Runs only git, with separate arguments and no shell. It does not use eval, downloads, cleanup commands, or background processes.
  • Does not offer reset, discarding changes, rebase, amend, force push, branch deletion, or forced worktree removal.
  • Refuses to remove worktrees with modified, new, or ignored files, as well as the main, current, or locked worktrees.
  • Push requires an explicit remote with a single HTTPS/SSH URL. It does not accept local paths, remote helpers, tags, or refspecs from the model.
  • Mutations are rejected without a Pi confirmation interface, unless they are pre-authorized with --git-allow or PI_GIT_ALLOW. Nothing is pre-authorized by default.
  • In RPC mode (pi --mode rpc) Pi reports an interface and sends each confirmation to the client as an extension_ui_request (method: "confirm"). Pi turns a cancelled: true response into the same false as an explicit "No", so the extension cannot tell them apart. In RPC mode a refusal says so, and the client also gets a notify warning.
  • Does not disable hooks or configured signing. Git hooks, filters, and transports can run programs from the repository or environment: use trusted repositories and Git configurations.

Runs without a person (RPC and CI)

A client with nobody to answer the dialogs can pre-authorize specific mutations for the whole run, with a comma-separated list:

pi --mode rpc --git-allow commit
PI_GIT_ALLOW=commit,push pi -p "..."

Accepted values: commit, push, worktree_add, worktree_remove, worktree_prune. There is no all. An unknown value, or --git-allow without a value, blocks every mutation with an error. If both are set, --git-allow wins over PI_GIT_ALLOW, so --git-allow "" turns the variable off. Authorizing commit does not authorize push or any worktree change.

Pre-authorization only skips the dialog. Every other check still runs: explicit files, branch rechecks, HTTPS/SSH remotes only, and clean worktrees only. When there is an interface, each pre-authorized mutation sends an info notification with the same details as the dialog. The model cannot turn it on from the session: the flag and the environment variable are read from the Pi process. A variable left in your shell profile also applies to interactive sessions.

This is not a sandbox and does not block Pi's general Bash access or other extensions. Queries disable external diff, textconv, and signature verification. Large outputs are explicitly limited; a process that exceeds 120 seconds or 4 MiB of output fails. If a mutation fails, check the status before retrying.

Development

No npm install is needed.

npm test

Release

Publishing runs in GitHub Actions with npm trusted publishing when a v* tag is pushed. Add the version's entry to CHANGELOG.md, then:

npm version patch   # or minor / major; commits and tags vX.Y.Z
git push --follow-tags