feat: Apso co-authors commits that include generated work (prepare-commit-msg hook)#97
Open
cultron wants to merge 1 commit into
Open
feat: Apso co-authors commits that include generated work (prepare-commit-msg hook)#97cultron wants to merge 1 commit into
cultron wants to merge 1 commit into
Conversation
Install a `prepare-commit-msg` git hook into target projects that appends `Co-authored-by: Apso <bot@apso.ai>` to commits whose staged changes touch an Apso-generated `autogen/` path. As a git hook it works for any committer (Claude, other agents, humans), not just one tool. - src/lib/utils/git-hooks.ts: pure `buildCoAuthorHookScript()` (merge/squash skip, APSO_NO_COAUTHOR opt-out, autogen guard, idempotent `git interpret-trailers`) and best-effort `installCoAuthorHook()` that writes `.apso/hooks/prepare-commit-msg` (0755) and sets a relative `core.hooksPath`, never clobbering a custom one (husky etc.). - generate.ts / init.ts: best-effort install, logged, never fails the command; honors `.apsorc coAuthor:false` and the env opt-out. - apsorc-parser.ts: thread `coAuthor?: boolean` through the config. - test/lib/utils/git-hooks.test.ts: unit + temp-repo integration + e2e. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Apso co-signs commits that include Apso-generated work, the way Claude Code adds its own
Co-authored-bytrailer — via a git hook, so it works for any committer (Claude, other agents, humans), not just an instructed agent.How it works
apso generate(andapso init) install a committedprepare-commit-msghook at.apso/hooks/and idempotently pointcore.hooksPathat it (best-effort; never fails the command; logged).Co-authored-by: Apso <bot@apso.ai>only when the staged changes include an Apso-generated path ((^|/)autogen/) — faithful "work Apso did" attribution. It skips merge/squash commits and usesgit interpret-trailers(idempotent; coexists withCo-authored-by: Claude).Opt-out & safety
APSO_NO_COAUTHOR=1(checked at install and commit time) or.apsorc"coAuthor": false(generate skips install).core.hooksPathis already set to something else, the installer does not clobber it — it warns with the exactgit interpret-trailersline to add to the existing hook.core.hooksPathis local config, so the install runs in each clone (which is whygenerate/initown it rather than the template).Verification
git-hooks.test.ts: 13 tests for the script + temp-repo install/idempotency/custom-hooksPath).apso generatein a temp git repo installs the executable hook + setscore.hooksPath; a commit stagingautogen/**gets the Apso trailer, a hand-written-only commit does not.Related: telemetry is tracked separately in #96 (the co-author trailer is attribution, not telemetry).
🤖 Generated with Claude Code