@polydeukes/adapter-git
v0.3.0
Published
Polydeukes adapter for git — up-translates a staged diff into the agent-neutral covenant input IR at commit time. Alpha.
Readme
@polydeukes/adapter-git
English · 한국어
The boundary where git's vocabulary is translated away. A staged diff becomes the agent-neutral covenant input IR at commit time — the same judgment for every hand, AI or human.
Alpha. This is the second adapter, and its existence is itself the proof of IR neutrality: it fills the same per-call fileChange evidence the Claude Code adapter fills — from git blobs instead of virtual applies — and the core consumed both without a single changed line.
What lives here
- Staged-change collection —
collectStagedChanges(repoRoot)reads the staging area with--no-renamesforced on, so a rename is judged as a deletion plus an addition (agit mvof a protected file must not slip through as one opaque rename entry).precomes from the HEAD blob andpostfrom the STAGED blob — never the worktree, which may have diverged aftergit add. A binary blob (NUL heuristic) yields null content instead of lossily decoded bytes, and the unborn first commit narrows to all-added instead of throwing. - Pure translation —
covenantInputFromStagedChanges(changes)folds the collected changes into oneCovenantInput: one tool call per change under the adapter-owned namesstaged-write/staged-delete, each carrying its own discriminated-union evidence (fileChange:create/modify/delete— deletion is first-class, its optionalprebaseline dropping only for a binary HEAD blob), and honestly empty session collections — the commit surface has no session, and keys are never fabricated. - The adapter's own vocabulary —
resolveGitAdapterSettings(namespace)validates this adapter's config namespace (adapters.git):enforce: block | advise, the commit surface's enforcement level, andprotectedPaths, the commit surface's additive protection scope — entries judged at commit time on top of the common list, which the session surface never reads (as the level is the observer's, so is the scope). The core validates only the container shape (one settings object per adapter) and passes contents through verbatim, so the vocabulary, its validator, and its defaults live here — absence fillsblockand an empty list, unknown keys and values fail fast with the full field path. - Nothing else, on purpose — this is a pure library. It knows the staged-diff payload format and nothing about installation, hook runners, or valves. The umbrella's
pdks covenant checkassembles it into the pre-commit surface; wiring it into a hook runner is a deployment act that lives outside this module.
See the project repository for the architecture blueprint and design rationale.
License
MIT
