Documentation
¶
Index ¶
- func AdjustColumnWidths(cols []TableColumn, prs []PRInfo)
- func AgeColorCode(created, now time.Time) string
- func AgeColorFunc(p PRInfo) string
- func AgeDays(created, now time.Time) int
- func AgeInfoFunc(p PRInfo) string
- func AuthorInfoFunc(p PRInfo) string
- func ColorizeRescue(m *RescueMarker, now time.Time) string
- func ColorizeStatus(state StatusState, detail string) string
- func DependencyInfoFunc(p PRInfo) string
- func DisableLineWrap(w *os.File)
- func EnableLineWrap(w *os.File)
- func ExtractDependencyName(title string) string
- func ExtractOwnerRepo(htmlURL string) (string, string, error)
- func ExtractVersion(title string) string
- func FormatAge(created, now time.Time) string
- func FormatRescue(m *RescueMarker, now time.Time) string
- func IsDependencyUpdateTitle(title string) bool
- func MakeHyperlink(text, url string) string
- func ParsePRURL(htmlURL string) (owner, repo string, number int, err error)
- func PrintPlainResults(w *os.File, status *PRStatus)
- func PrintRow(w *os.File, e StatusEntry, cols []TableColumn)
- func PrintTableHeader(w *os.File, cols []TableColumn)
- func RepoInfoFunc(p PRInfo) string
- func UpdateTable(w *os.File, entries []StatusEntry, cols []TableColumn)
- func VersionInfoFunc(p PRInfo) string
- type PRGroup
- type PRInfo
- type PRStatus
- func (s *PRStatus) ActionRequired() []StatusEntry
- func (s *PRStatus) Add(pr PRInfo) int
- func (s *PRStatus) BlockedEntries() []StatusEntry
- func (s *PRStatus) FormatSummary() string
- func (s *PRStatus) Len() int
- func (s *PRStatus) MergedEntries() []StatusEntry
- func (s *PRStatus) SecurityFailedEntries() []StatusEntry
- func (s *PRStatus) SetRescue(idx int, marker *RescueMarker)
- func (s *PRStatus) SkippedEntries() []StatusEntry
- func (s *PRStatus) Snapshot() []StatusEntry
- func (s *PRStatus) StateAt(idx int) StatusState
- func (s *PRStatus) Summary() (merged, failed, blocked, skipped int)
- func (s *PRStatus) Update(idx int, state StatusState, detail string)
- type RescueMarker
- type StatusEntry
- type StatusState
- type TableColumn
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AdjustColumnWidths ¶ added in v0.0.14
func AdjustColumnWidths(cols []TableColumn, prs []PRInfo)
AdjustColumnWidths widens each column so every value fits without truncation.
func AgeColorCode ¶ added in v0.0.49
AgeColorCode returns the ANSI color prefix for a PR age: "" while the PR is fresh, yellow once it passes ageWarnAfter, red once it passes ageStaleAfter. Callers must reset with \033[0m when non-empty.
func AgeColorFunc ¶ added in v0.0.49
AgeColorFunc is the table-column color accessor for the Age column.
func AgeDays ¶ added in v0.0.49
AgeDays returns the whole number of days since created, or 0 for a zero creation time.
func AgeInfoFunc ¶ added in v0.0.49
AgeInfoFunc is the table-column accessor for the Age column.
func AuthorInfoFunc ¶ added in v0.0.9
func ColorizeRescue ¶ added in v0.0.49
func ColorizeRescue(m *RescueMarker, now time.Time) string
ColorizeRescue wraps the FormatRescue annotation in ANSI colors: a stale marker renders yellow (retriable -- the code changed since the attempt), a fresh one bold red (a rescue already failed on exactly this code; a human is needed).
func ColorizeStatus ¶ added in v0.0.10
func ColorizeStatus(state StatusState, detail string) string
func DependencyInfoFunc ¶ added in v0.0.6
func DisableLineWrap ¶ added in v0.0.41
DisableLineWrap turns off the terminal's auto-wrap (DECAWM) so rows wider than the terminal are clipped at the right edge instead of wrapping onto a second physical line. UpdateTable's cursor-up math counts logical rows, so a wrapped row would desync the redraw and produce the garbled output users see when CI detail strings push a line past the terminal width.
func EnableLineWrap ¶ added in v0.0.41
EnableLineWrap restores the terminal's auto-wrap mode. Always pair it with DisableLineWrap (typically via defer) so an early return does not leave the user's terminal in a clipped state.
func ExtractDependencyName ¶
func ExtractOwnerRepo ¶ added in v0.0.10
ExtractOwnerRepo parses owner and repo from a GitHub HTML URL (e.g. "https://github.com/OWNER/REPO/pull/123").
func ExtractVersion ¶ added in v0.0.9
func FormatAge ¶ added in v0.0.49
FormatAge renders the time since created as a compact human string ("5h", "3d", "2w"). It returns "" for a zero creation time so callers can omit the column value when the discovery path did not provide it.
func FormatRescue ¶ added in v0.0.49
func FormatRescue(m *RescueMarker, now time.Time) string
FormatRescue renders the marker as a short human-readable annotation for status output, e.g. "rescue failed 1d ago (klaus): ESM-only" or "rescue failed 3d ago (klaus), stale: new commits since".
func IsDependencyUpdateTitle ¶ added in v0.0.5
IsDependencyUpdateTitle returns true if the PR title looks like an automated dependency update (Renovate or Dependabot), regardless of who authored it.
func MakeHyperlink ¶
func ParsePRURL ¶ added in v0.0.49
ParsePRURL parses owner, repo, and PR number from a GitHub pull request URL (e.g. "https://github.com/OWNER/REPO/pull/123").
func PrintPlainResults ¶ added in v0.0.7
func PrintRow ¶ added in v0.0.6
func PrintRow(w *os.File, e StatusEntry, cols []TableColumn)
func PrintTableHeader ¶
func PrintTableHeader(w *os.File, cols []TableColumn)
func RepoInfoFunc ¶ added in v0.0.6
func UpdateTable ¶
func UpdateTable(w *os.File, entries []StatusEntry, cols []TableColumn)
func VersionInfoFunc ¶ added in v0.0.9
Types ¶
type PRStatus ¶
type PRStatus struct {
// contains filtered or unexported fields
}
func NewPRStatus ¶
func NewPRStatus() *PRStatus
func (*PRStatus) ActionRequired ¶ added in v0.0.7
func (s *PRStatus) ActionRequired() []StatusEntry
ActionRequired returns the failure entries, oldest PR first: the longer a dependency PR has been open, the more sweeps it has already survived, so the old ones are the most likely to need manual work. Entries without a known creation time sort last, in insertion order.
func (*PRStatus) BlockedEntries ¶ added in v0.0.47
func (s *PRStatus) BlockedEntries() []StatusEntry
BlockedEntries returns entries whose CI could not run because a GitHub Actions budget / spending-limit block prevented every job from starting. These are deliberately kept out of ActionRequired and the failed counts: the remedy is "raise or await the Actions budget", not "rescue the code".
func (*PRStatus) FormatSummary ¶
func (*PRStatus) MergedEntries ¶ added in v0.0.7
func (s *PRStatus) MergedEntries() []StatusEntry
func (*PRStatus) SecurityFailedEntries ¶ added in v0.0.41
func (s *PRStatus) SecurityFailedEntries() []StatusEntry
SecurityFailedEntries returns entries that failed specifically because a security-related check reported a problem.
func (*PRStatus) SetRescue ¶ added in v0.0.49
func (s *PRStatus) SetRescue(idx int, marker *RescueMarker)
SetRescue attaches a prior rescue-attempt marker to an entry.
func (*PRStatus) SkippedEntries ¶ added in v0.0.7
func (s *PRStatus) SkippedEntries() []StatusEntry
func (*PRStatus) Snapshot ¶
func (s *PRStatus) Snapshot() []StatusEntry
func (*PRStatus) StateAt ¶ added in v0.0.49
func (s *PRStatus) StateAt(idx int) StatusState
StateAt returns the current state of the entry at idx, or StatusPending when idx is out of range.
type RescueMarker ¶ added in v0.0.49
type RescueMarker struct {
Tool string `json:"tool,omitempty"`
Outcome string `json:"outcome"`
Reason string `json:"reason,omitempty"`
HeadSHA string `json:"head_sha,omitempty"`
At time.Time `json:"at,omitempty"`
// Stale is computed by MarkStale, never serialized into the marker.
Stale bool `json:"-"`
}
RescueMarker records a prior automated rescue attempt on a PR. It is embedded as a machine-readable HTML comment inside an ordinary PR comment, so any tool that can comment on a PR (a klaus agent, a Cursor agent, a GitHub Action) can participate without coupling to marge:
<!-- ai-rescue: {"tool":"klaus","outcome":"failed","reason":"...","head_sha":"...","at":"2026-06-09T18:40:00Z"} -->
HeadSHA ties the attempt to the code it was attempted against. Renovate force-pushes on rebase or version change, so a marker whose head_sha no longer matches the PR head describes code that no longer exists -- the attempt is stale and the PR is fair game for another rescue.
func ParseRescueMarker ¶ added in v0.0.49
func ParseRescueMarker(body string) *RescueMarker
ParseRescueMarker extracts the last ai-rescue marker from a comment body. It returns nil when the body contains no parseable marker; a malformed JSON payload is ignored rather than treated as an error so a mangled comment can never break a sweep.
func (*RescueMarker) CommentBody ¶ added in v0.0.49
func (m *RescueMarker) CommentBody() string
CommentBody renders the full PR comment for this marker: a human-readable summary followed by the machine-readable marker.
func (*RescueMarker) MarkStale ¶ added in v0.0.49
func (m *RescueMarker) MarkStale(currentHeadSHA string)
MarkStale sets Stale by comparing the marker's recorded head SHA with the PR's current head. Short-vs-full SHA prefixes match. A marker without a recorded SHA cannot be aged out, so it stays non-stale until a newer marker replaces it.
type StatusEntry ¶
type StatusEntry struct {
PR PRInfo
State StatusState
Detail string
// Rescue is the most recent prior automated rescue attempt found on
// the PR, if any. Only populated for failure-state entries.
Rescue *RescueMarker
}
func SplitActionRequired ¶ added in v0.0.41
func SplitActionRequired(entries []StatusEntry) (security, other []StatusEntry)
SplitActionRequired partitions the action-required list into security failures and everything else, preserving the input order in each group.
type StatusState ¶
type StatusState int
const ( StatusPending StatusState = iota StatusChecking StatusApproving StatusMerging StatusRetrying StatusMerged StatusAlreadyMerged StatusAutoMerge StatusFailed StatusFailedSecurity StatusBlockedCI StatusSkipped StatusConflict StatusUntrustedAuthor )
func (StatusState) String ¶
func (s StatusState) String() string
type TableColumn ¶ added in v0.0.9
type TableColumn struct {
Label string
Width int
Fn func(PRInfo) string
// Color optionally returns an ANSI color prefix for a value. The
// value is padded to Width first, then wrapped, so colored cells
// stay aligned with the rest of the table.
Color func(PRInfo) string
}
func DependencySelectedColumns ¶ added in v0.0.9
func DependencySelectedColumns() []TableColumn
func FullColumns ¶ added in v0.0.9
func FullColumns() []TableColumn
func RepoSelectedColumns ¶ added in v0.0.9
func RepoSelectedColumns() []TableColumn