Documentation
¶
Index ¶
- Constants
- func BuildCommitMsgPrompt(transcript []TranscriptEntry, diff string) string
- func BuildSuggestPRPrompt(diff, commitSubjects, prTemplate string) string
- func BuildUserPrompt(commitHash, subject string, stats ExplainContext, transcript []TranscriptEntry, ...) string
- func FormatCondensedTranscript(entries []TranscriptEntry) string
- func StripHTMLComments(s string) string
- type ExplainContext
- type GenerateResult
- type GenerateTextResult
- type NarrativeResult
- type SuggestPROutput
- type TranscriptEntry
- type Writer
- type WriterRegistry
Constants ¶
const CommitMsgPrompt = `` /* 990-byte string literal not displayed */
CommitMsgPrompt instructs the model to generate a commit message.
const SuggestPRPrompt = `` /* 832-byte string literal not displayed */
SuggestPRPrompt instructs the model to author a pull request.
const SystemPrompt = `` /* 1247-byte string literal not displayed */
SystemPrompt instructs the model to analyze a development session.
Variables ¶
This section is empty.
Functions ¶
func BuildCommitMsgPrompt ¶
func BuildCommitMsgPrompt(transcript []TranscriptEntry, diff string) string
BuildCommitMsgPrompt assembles transcript context plus a bounded change summary and diff excerpt for commit message generation.
func BuildSuggestPRPrompt ¶
BuildSuggestPRPrompt assembles the prompt for PR generation. It reuses the summary+excerpt strategy from commit-msg prompts.
func BuildUserPrompt ¶
func BuildUserPrompt(commitHash, subject string, stats ExplainContext, transcript []TranscriptEntry, diff string) string
BuildUserPrompt assembles transcript, diff, and stats into the prompt.
func FormatCondensedTranscript ¶
func FormatCondensedTranscript(entries []TranscriptEntry) string
FormatCondensedTranscript formats transcript entries into a human-readable format for LLM consumption.
func StripHTMLComments ¶
Types ¶
type ExplainContext ¶
type ExplainContext struct {
FilesChanged int `json:"files_changed"`
LinesAdded int `json:"lines_added"`
LinesDeleted int `json:"lines_deleted"`
AIPercentage float64 `json:"ai_percentage"`
AILines int `json:"ai_lines"`
HumanLines int `json:"human_lines"`
SessionCount int `json:"session_count"`
RootSessions int `json:"root_sessions"`
Subagents int `json:"subagents"`
TopFiles []struct {
Path string `json:"path"`
Added int `json:"added"`
Deleted int `json:"deleted"`
TotalLines int `json:"total_lines"`
AILines int `json:"ai_lines"`
HumanLines int `json:"human_lines"`
AIPercent float64 `json:"ai_percentage"`
} `json:"top_files"`
}
ExplainContext is the subset of explain stats needed for the prompt.
type GenerateResult ¶
type GenerateResult struct {
Narrative *NarrativeResult
Provider string
Model string
}
GenerateResult holds the narrative plus metadata about how it was generated.
type GenerateTextResult ¶
GenerateTextResult holds a raw text response plus metadata.
type NarrativeResult ¶
type NarrativeResult struct {
Title string `json:"title"`
Intent string `json:"intent"`
Outcome string `json:"outcome"`
Learnings []string `json:"learnings"`
Friction []string `json:"friction"`
OpenItems []string `json:"open_items"`
Keywords []string `json:"keywords"`
}
NarrativeResult holds the structured LLM response.
type SuggestPROutput ¶
SuggestPROutput is the structured JSON the LLM must return.
func ParseSuggestPROutput ¶
func ParseSuggestPROutput(raw string) (*SuggestPROutput, error)
ParseSuggestPROutput extracts the structured title/body from the LLM response.
type TranscriptEntry ¶
TranscriptEntry is a lightweight event for the condensed transcript.
type Writer ¶ added in v0.5.1
type Writer interface {
// Name is the stable identifier used in logs, attribution
// records, and error messages (e.g. "claude_code", "codex").
Name() string
// Model reports the model the writer's CLI will invoke. "unknown"
// is acceptable for CLIs that don't expose a stable model alias.
Model() string
// Find returns an executable path for this writer's CLI, or
// empty when the binary is not installed on the host. Must be
// cross-platform (PATH lookup honors .exe on Windows etc.).
Find() string
// Generate sends prompt to the writer's CLI subprocess and
// returns the model's response as text. binPath is the resolved
// binary location from a prior Find() call. Returns an error
// the registry uses to fall through to the next writer.
Generate(ctx context.Context, binPath, prompt string) (string, error)
}
Writer is the per-LLM CLI integration that the WriterRegistry walks in fallback order. Each writer locates its binary, generates a response, and reports its model and display name independently. The registry owns redaction, ordering, and the fallback chain; writers own the subprocess-level details of how their CLI is invoked.
func Claude ¶ added in v0.5.1
func Claude() Writer
Claude returns a Writer for the Claude Code CLI. Used by the composition root to build the production WriterRegistry.
func Codex ¶ added in v0.5.1
func Codex() Writer
Codex returns a Writer for the OpenAI Codex CLI. The composition root places it right after Claude Code in the production fallback order - Claude stays the primary daily driver; Codex is the obvious secondary now that we capture its sessions first-class.
func Copilot ¶ added in v0.5.1
func Copilot() Writer
Copilot returns a Writer for the GitHub Copilot CLI.
type WriterRegistry ¶ added in v0.5.1
type WriterRegistry struct {
// contains filtered or unexported fields
}
WriterRegistry holds the ordered list of writers tried by Generate and GenerateText. The fallback contract is: redact once, try each writer with a non-empty Find() in order, return the first success; when every writer either skips (no binary) or errors, return a chained error naming each failure in fallback order.
Redaction is performed once before any writer sees the prompt. The redactor field is unexported and seamable from tests in the same package; callers outside the package always get the production redactPrompt.
func NewWriterRegistry ¶ added in v0.5.1
func NewWriterRegistry(writers ...Writer) *WriterRegistry
NewWriterRegistry constructs a registry over the given writers in fallback order. Order matters: the first writer with an available CLI that returns a successful response wins. Production wiring lives in internal/providers/composition.go.
func (*WriterRegistry) Generate ¶ added in v0.5.1
func (r *WriterRegistry) Generate(ctx context.Context, prompt string) (*GenerateResult, error)
Generate is the narrative variant: same fallback contract as GenerateText, but each writer's text response is parsed as a NarrativeResult JSON blob before being returned. A successful CLI response that fails to parse as a narrative is treated as a writer failure (falls through to the next writer); the parse error is chained into the final message.
func (*WriterRegistry) GenerateText ¶ added in v0.5.1
func (r *WriterRegistry) GenerateText(ctx context.Context, prompt string) (*GenerateTextResult, error)
GenerateText sends a redacted, UTF-8-safe prompt to the first available writer and returns its raw text response. Prompt prep runs exactly once regardless of how many writers are tried. Writers whose Find() returns empty are skipped (no subprocess attempt). Writers whose Generate returns an error fall through to the next writer; their error is appended to a chained message returned only when every writer fails. When no writer is even installed, returns a single-line "no AI CLI found" message that enumerates every registered writer so the install hint stays honest as the registry grows.
func (*WriterRegistry) List ¶ added in v0.5.1
func (r *WriterRegistry) List() []Writer
List returns the registered writers in fallback order. Used by the "no AI CLI found" error message to enumerate install candidates, and by health checks that want to inspect the registry shape.