feat: add AI message generation via spice.messageGenerator#1160
Closed
ed-irl wants to merge 1 commit into
Closed
Conversation
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.
Collaborator
Author
|
This change is part of the following stack: Change managed by git-spice. |
Owner
|
assuming #1170 is authoritative. closing in favor of that. |
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.
Summary
Adds a
--fillflag togs commit create,gs commit amend,gs branch create,gs branch submit, andgs branch squashthatinvokes an external script to generate or update commit messages and
PR titles/bodies. The script is configured via the
spice.messageGeneratorgit config key and runs in the repositoryroot.
Scripts receive context through environment variables
(
GS_MESSAGE_KIND,GS_MESSAGE_UPDATE,GS_BRANCH,GS_BASE,GS_MESSAGE,GS_TITLE,GS_BODY) and the invokinggsargumentvector as positional parameters. Output is parsed as either a full
commit message or as
title\n\nbodyfor branch messages. If thescript starts with
#!, it is written to a temp file and executeddirectly; otherwise it is run via
sh -c. Script failures fall backto the default editor flow; when
--fillis set with no generatorconfigured, the command errors with guidance to configure one.
The forge layer gains
Subject/Bodyfields onEditChangeOptionsand
FindChangeItemso that branch updates can push generatedtitles/bodies to GitHub, GitLab, Bitbucket, and ShamHub. A new
guide/ai-messages.mddocuments the feature, including a ClaudeCode example.
Test plan
mise run test(unit tests formsggenandspice.Config)mise run test:scriptcovering 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_updaterspice.messageGenerator(shell one-linerand shebang script) and verify
--fillpopulates commit andPR messages on a real GitHub repo
the explicit error when
--fillis used without a configuredgenerator