Skip to content

Add attribution templates and CLI --co-author flag support#242

Open
aviadshiber wants to merge 2 commits intomainfrom
claude/kapsis-integration-planning-UPdtO
Open

Add attribution templates and CLI --co-author flag support#242
aviadshiber wants to merge 2 commits intomainfrom
claude/kapsis-integration-planning-UPdtO

Conversation

@aviadshiber
Copy link
Copy Markdown
Owner

Summary

This PR adds support for customizable git attribution templates and a new --co-author CLI flag to Kapsis. Attribution templates allow agents to customize how they sign commits and PR descriptions, with placeholder substitution for version, agent ID, branch, and worktree. The CLI flag enables users to add co-authors directly from the command line, which merge with config-defined co-authors.

Type of Change

  • New feature (non-breaking change that adds functionality)
  • Documentation update

Changes Made

Core Features

  • Attribution Templates: Added git.attribution.commit and git.attribution.pr config options with support for placeholders ({version}, {agent_id}, {branch}, {worktree})

    • Defaults to a Kapsis-only attribution when not configured
    • Empty string disables attribution entirely
    • For Claude Code, templates are injected into ~/.claude/settings.local.json as native Claude settings
    • For other agents, templates are appended to commit messages by host-side scripts
  • CLI --co-author Flag: New repeatable --co-author "Name <email>" flag in launch-agent.sh

    • Validates email format (must contain <email> with @ symbol)
    • Merges with config-defined co-authors using pipe separator
    • Deduplication handled downstream in build_coauthor_trailers()

Implementation Details

  • launch-agent.sh:

    • Added CLI_CO_AUTHORS array to track CLI-provided co-authors
    • Parse and validate --co-author arguments in parse_args()
    • Merge CLI co-authors with config co-authors in parse_config()
    • Parse attribution templates from config with fallback to defaults
    • Substitute placeholders ({version}, {agent_id}, {branch}) early
    • Export attribution and agent type to environment for container and host-side scripts
  • post-container-git.sh:

    • Updated commit_changes() to use KAPSIS_ATTRIBUTION_COMMIT from environment
    • Added Claude Code detection to skip duplicate attribution (Claude writes its own)
    • Resolve {worktree} placeholder at commit time
    • Support empty attribution string to disable signing
  • entrypoint.sh:

    • Updated post_exit_git() to use templated attribution from environment
    • Support empty attribution string
  • inject-status-hooks.sh:

    • Updated Claude Code settings injection to include attribution.commit and attribution.pr
    • Only merge when env vars are explicitly set (including empty string)
    • Preserve user-configured attribution when Kapsis vars are unset

Documentation

  • Updated CONFIG-REFERENCE.md with attribution template documentation and examples
  • Updated GIT-WORKFLOW.md with new commit message format and attribution behavior
  • Updated claude.yaml example config with attribution templates
  • Added inline comments explaining placeholder substitution and Claude-specific behavior

Testing

  • Added 13 comprehensive test cases covering:
    • Attribution config parsing with yq
    • Placeholder substitution logic
    • Environment variable handling
    • Empty attribution disabling
    • Claude Code deduplication
    • CLI co-author merging (with and without config co-authors)
    • Co-author format validation
  • Tests validate both positive cases and edge cases (empty config, invalid formats, etc.)

Checklist

  • Code follows project style guidelines
  • Self-review completed
  • Code is commented, especially placeholder substitution logic
  • Documentation updated (CONFIG-REFERENCE.md, GIT-WORKFLOW.md, example configs)
  • Tests added and passing
  • No new warnings introduced

Additional Notes

  • Attribution is now agent-aware: Claude Code uses native settings, other agents use commit message appending
  • Backward compatible: existing configs without attribution key use sensible defaults
  • Empty string in config is a valid way to disable attribution entirely
  • Placeholder substitution happens early in parse_config() except for {worktree} which is

https://claude.ai/code/session_018mdcbzthMYwuwE3fC66y2R

claude and others added 2 commits April 13, 2026 17:47
…LI flag

Kapsis used to append its own attribution block to every commit regardless
of what Claude Code already added via its native `attribution.commit`
setting — causing duplicated or inconsistent attribution depending on
whether Claude or Kapsis made the commit.

Now Kapsis injects `attribution.commit` and `attribution.pr` into
`~/.claude/settings.local.json` so Claude writes the attribution itself,
and the host-side commit detects the signature and skips duplicates. For
non-Claude agents (codex, gemini, aider), Kapsis continues to append the
same template via `KAPSIS_ATTRIBUTION_COMMIT` env var.

Default attribution is now a markdown-linked `[Generated by Kapsis](...)`
that renders as a clickable link on GitHub. Supports `{version}`,
`{agent_id}`, `{branch}`, `{worktree}` placeholders. Empty string disables
attribution entirely.

Also adds a `--co-author "Name <email>"` CLI flag (repeatable) that merges
with co-authors from config. Existing dedup in `build_coauthor_trailers`
handles duplicates across config/CLI/git user/commit message.

https://claude.ai/code/session_018mdcbzthMYwuwE3fC66y2R
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.

2 participants