Skip to content

feat: Apso co-authors commits that include generated work (prepare-commit-msg hook)#97

Open
cultron wants to merge 1 commit into
mainfrom
feat/apso-coauthor-hook
Open

feat: Apso co-authors commits that include generated work (prepare-commit-msg hook)#97
cultron wants to merge 1 commit into
mainfrom
feat/apso-coauthor-hook

Conversation

@cultron

@cultron cultron commented Jun 15, 2026

Copy link
Copy Markdown
Contributor

Apso co-signs commits that include Apso-generated work, the way Claude Code adds its own Co-authored-by trailer — via a git hook, so it works for any committer (Claude, other agents, humans), not just an instructed agent.

How it works

  • apso generate (and apso init) install a committed prepare-commit-msg hook at .apso/hooks/ and idempotently point core.hooksPath at it (best-effort; never fails the command; logged).
  • The hook appends 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 uses git interpret-trailers (idempotent; coexists with Co-authored-by: Claude).

Opt-out & safety

  • Opt out via APSO_NO_COAUTHOR=1 (checked at install and commit time) or .apsorc "coAuthor": false (generate skips install).
  • Husky-safe: if core.hooksPath is already set to something else, the installer does not clobber it — it warns with the exact git interpret-trailers line to add to the existing hook.
  • Per-clone note: core.hooksPath is local config, so the install runs in each clone (which is why generate/init own it rather than the template).

Verification

  • Build clean · lint 0 errors · jest 197 pass (17 suites; new git-hooks.test.ts: 13 tests for the script + temp-repo install/idempotency/custom-hooksPath).
  • Manual e2e: apso generate in a temp git repo installs the executable hook + sets core.hooksPath; a commit staging autogen/** 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).

Merging auto-publishes a new @apso/cli.

🤖 Generated with Claude Code

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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant