git

package
v0.0.0-...-374cbe0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 11, 2026 License: MIT Imports: 7 Imported by: 0

README

pkg/git

Git operations focused on the semantic-commit workflow. Backed by git and the external llm-stream tool.

API

  • GetCurrentBranch() (string, error)git branch --show-current, trimmed.
  • HasStagedFiles() (bool, error) — true when git diff --cached --name-only is non-empty.
  • CreateSemanticCommit() (string, error) — pipes the staged diff into llm-stream and extracts the message from the <output>…</output> tag. Fails fast when nothing is staged, with a hint pointing at --add / --all.
  • Commit(message string) errorgit commit -F - with the message on stdin.
  • AddAll() errorgit add -A.
  • Add() error — interactive fzf picker over git ls-files --modified --others with a live git diff --color preview.
  • CommitAmend() error — opens git commit --amend bound to the user's stdio so the editor pops up.

Diff Filtering

The diff fed to llm-stream excludes lock files so they don't pollute the prompt:

':(exclude)package-lock.json' ':(exclude)lazy-lock.json' ':(exclude)*.lock'

llm-stream Contract

The git-semantic-commit template returns the commit message wrapped in <output></output>. CreateSemanticCommit matches with (?s)<output>(.*?)</output>; missing or empty contents are a hard error that surfaces the raw LLM output so the user can see what went wrong.

Semantic Commit Workflow

  1. Stage files (or pass --all / --add to the command).
  2. Build the filtered staged diff.
  3. Call llm-stream --template git-semantic-commit --vars '{"branch": "<branch>"}' --preset gpt.
  4. Extract the message from <output></output>.
  5. Commit writes it.
  6. CommitAmend opens the editor so the user can review and edit before the commit lands.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Add

func Add() error

Add opens up an fzf window to select the files that need to be staged before the semantic commit is generated.

func AddAll

func AddAll() error

AddAll stages all changes.

func Commit

func Commit(commit string) error

Commit creates a commit with the given message

func CommitAmend

func CommitAmend() error

CommitAmend amends the last commit

func CreateSemanticCommit

func CreateSemanticCommit() (string, error)

CreateSemanticCommit creates a semantic commit message based on the git diff output

func GetCurrentBranch

func GetCurrentBranch() (string, error)

GetCurrentBranch returns the current branch name

func HasStagedFiles

func HasStagedFiles() (bool, error)

HasStagedFiles checks if there are any staged files

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL