Documentation
¶
Overview ¶
Package ai is the port for drafting commit messages, branch names and pull-request text. Adapters (Claude Code today, a direct API tomorrow) implement Drafter; prompts and output schemas live here so every adapter behaves the same.
Index ¶
- Constants
- func CommitPrompt(in CommitInput) (instruction, context string)
- func PRPrompt(in PRInput) (instruction, context string)
- func TruncateDiff(diff string, maxBytes int) (string, bool)
- func ValidateCommit(c Commit) error
- func ValidatePR(p PullRequest) error
- type Commit
- type CommitInput
- type Drafter
- type PRInput
- type PullRequest
Constants ¶
const CommitSchema = `` /* 279-byte string literal not displayed */
CommitSchema is the JSON schema for Commit.
const MaxDiffBytes = 100_000
MaxDiffBytes bounds the diff sent to the model.
const PRSchema = `` /* 170-byte string literal not displayed */
PRSchema is the JSON schema for PullRequest.
Variables ¶
This section is empty.
Functions ¶
func CommitPrompt ¶
func CommitPrompt(in CommitInput) (instruction, context string)
CommitPrompt renders the instruction and the stdin context for DraftCommit.
func TruncateDiff ¶
TruncateDiff cuts a diff at a line boundary near max bytes and reports whether it did.
func ValidateCommit ¶
ValidateCommit checks a drafted commit for the obvious failure modes.
Types ¶
type CommitInput ¶
type CommitInput struct {
// Diff is the staged diff, possibly truncated.
Diff string
DiffTruncated bool
// Message, when set, is used as-is and only a branch name is drafted.
Message string
// RecentSubjects are the last trunk commit subjects, for house style.
RecentSubjects []string
// BranchPrefix is prepended to the generated name by the caller; the
// model is told about it so it does not repeat it.
BranchPrefix string
// TakenBranches lists existing branch names to avoid.
TakenBranches []string
// ExtraPrompt is appended verbatim (git config stack.ai.extraPrompt).
ExtraPrompt string
}
CommitInput is the context for drafting a branch name and commit message. The caller computes everything; the model never runs git.
type Drafter ¶
type Drafter interface {
DraftCommit(ctx context.Context, in CommitInput) (Commit, error)
DraftPR(ctx context.Context, in PRInput) (PullRequest, error)
}
Drafter generates text. Implementations must be safe to call from any goroutine and must honour ctx.
type PRInput ¶
type PRInput struct {
Branch, Parent string
Diff string
DiffTruncated bool
// Commits are the full commit messages on the branch, oldest first.
Commits []string
RecentSubjects []string
// Template is the repository's PR template, if any.
Template string
ExtraPrompt string
}
PRInput is the context for drafting a pull request title and body.
type PullRequest ¶
PullRequest is a drafted title and body.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package claudecode implements ai.Drafter with the local Claude Code CLI in headless mode (`claude -p`).
|
Package claudecode implements ai.Drafter with the local Claude Code CLI in headless mode (`claude -p`). |