Skip to content

feat: add AI message generation via spice.messageGenerator#1160

Closed
ed-irl wants to merge 1 commit into
mainfrom
ai-message-gen
Closed

feat: add AI message generation via spice.messageGenerator#1160
ed-irl wants to merge 1 commit into
mainfrom
ai-message-gen

Conversation

@ed-irl

@ed-irl ed-irl commented May 14, 2026

Copy link
Copy Markdown
Collaborator

Summary

Adds a --fill flag to gs commit create, gs commit amend,
gs branch create, gs branch submit, and gs branch squash that
invokes an external script to generate or update commit messages and
PR titles/bodies. The script is configured via the
spice.messageGenerator git config key and runs in the repository
root.

Scripts receive context through environment variables
(GS_MESSAGE_KIND, GS_MESSAGE_UPDATE, GS_BRANCH, GS_BASE,
GS_MESSAGE, GS_TITLE, GS_BODY) and the invoking gs argument
vector as positional parameters. Output is parsed as either a full
commit message or as title\n\nbody for branch messages. If the
script starts with #!, it is written to a temp file and executed
directly; otherwise it is run via sh -c. Script failures fall back
to the default editor flow; when --fill is set with no generator
configured, the command errors with guidance to configure one.

The forge layer gains Subject/Body fields on EditChangeOptions
and FindChangeItem so that branch updates can push generated
titles/bodies to GitHub, GitLab, Bitbucket, and ShamHub. A new
guide/ai-messages.md documents the feature, including a Claude
Code example.

Test plan

  • mise run test (unit tests for msggen and spice.Config)
  • mise run test:script covering the new scripts:
    commit_create_fill_generator, commit_create_fill_env,
    commit_create_fill_generator_fallback,
    commit_amend_fill_updater,
    commit_amend_fill_no_generator,
    branch_squash_fill, branch_squash_fill_no_generator,
    branch_submit_fill_generator,
    branch_submit_fill_updater,
    stack_submit_fill_generator, stack_submit_fill_updater
  • Manually configure spice.messageGenerator (shell one-liner
    and shebang script) and verify --fill populates commit and
    PR messages on a real GitHub repo
  • Verify graceful fallback when the script exits non-zero, and
    the explicit error when --fill is used without a configured
    generator

Add `spice.messageGenerator` config option and `--fill`/`-c` flag to
`commit create`, `commit amend`, `branch create`, `branch submit`, and
`branch squash`. The configured script runs in the repository root with
`GS_MESSAGE_KIND`, `GS_MESSAGE_UPDATE`, and context-specific environment
variables (`GS_BRANCH`, `GS_BASE`, `GS_MESSAGE`, `GS_TITLE`, `GS_BODY`).
The invoking process's argv is forwarded as positional parameters.

The new `msggen` package executes scripts in either shebang or `sh -c`
mode. Forges (GitHub, GitLab, Bitbucket, ShamHub) gain support for
editing CR subject/body so generated messages can update existing
changes. `--fill` coexists with `-m`/`-F` so a generator failure can
fall back to a user-supplied message.

Includes documentation, an example generator script, and end-to-end
test scripts covering generation, updating, fallback on generator
failure, and missing-generator errors.
@ed-irl

ed-irl commented May 14, 2026

Copy link
Copy Markdown
Collaborator Author

This change is part of the following stack:

Change managed by git-spice.

@abhinav

abhinav commented Jun 7, 2026

Copy link
Copy Markdown
Owner

assuming #1170 is authoritative. closing in favor of that.

@abhinav abhinav closed this Jun 7, 2026
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