← Catalog

@pi-in-go/pigpen-dirty-repo-guard

Go port of Pi's dirty-repo-guard example: blocks a session switch or fork while the git tree has uncommitted changes unless you allow it

ExtensionPigpen

Install

Install with PiG

pig install npm:@pi-in-go/pigpen-dirty-repo-guard
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. This one is published by the PiG project from the Pigpen repository; that is not a verification claim.

Pi manifest JSON

The pi field of package.json.

{
  "extensions": [
    "extensions/dirty-repo-guard"
  ]
}

README

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

dirty-repo-guard (Go port)

A Go extension for PiG that stops you from starting a new session, switching session or forking while your git working tree has uncommitted changes, unless you say it is fine:

You have 2 uncommitted file(s). new session anyway?
  Yes, proceed anyway
  No, let me commit first

Choosing the second option (or dismissing the dialog) cancels the action and shows "Commit your changes first". Outside a git repository, or when git fails, the action is allowed. Without a UI (print and JSON mode) a dirty tree cancels without asking.

This is a port of Pi's dirty-repo-guard.ts example (see CREDITS.md), made with the extension porting Skill as the worked example of its workflow. It needs no Node runtime.

Install

pig install ./components/dirty-repo-guard

The extension builds from source on first use (Go toolchain required), or fuses into a Piglet Binary. It is a Package: pig package validate ./components/dirty-repo-guard. Package discovery uses the pig-package keyword in package.json. The Package is private until the owner publishes it.

Proof that it behaves like the original

port/ holds the evidence and it ships with the Package:

PathWhat
port/oracle/dirty-repo-guard.ts, port/oracle/LICENSEThe unmodified original and Pi's license.
port/scenarios/*.json11 scripted event sequences: decline, proceed, dismissed dialog, clean, not a repository, git missing, canned git output (blank lines, U+00A0/U+FEFF, exit 128), fork decline and proceed.
port/golden/*.jsonlThe traces the original recorded under Pi 1.0.1 for those scenarios: every dialog, notification, git call and exit, model request, event and command response, in order. Each is also identical under PiG's Node runtime.
port/mutations.json26 deliberate defects. Every one must be caught.
port/PORT.mdThe mapping table, the SDK gap check, and the results.

Re-check the port against the recorded Pi traces (no Pi needed):

PIG_BIN=/path/to/pig npm run test:port         # from the Pigpen root

Re-run the original under Pi as well: add PI_BIN=/path/to/pi. Go tests (fake PiG host, hasUI == false, wording, helpers): PIG_BIN=/path/to/pig npm run test:go-ports -- -race.

Differences from the original

None observable in the recorded scenarios. Two deliberate implementation notes: git status output is trimmed and counted with JavaScript's trim() whitespace set (not Go's), and a failure of the host call itself (as opposed to git exiting non-zero) is returned as an error rather than treated as "not a repository".

MIT. Original © Mario Zechner (Pi); port © Michael Kinsy.