ledger

package
v0.10.0 Latest Latest
Warning

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

Go to latest
Published: Mar 23, 2026 License: MIT Imports: 23 Imported by: 0

Documentation

Overview

Package ledger provides an interactive TUI for browsing and managing beads across all registered Forge anvils.

Index

Constants

View Source
const (
	LaneOpen       = 0
	LaneInProgress = 1
	LaneInReview   = 2
	LaneClosed     = 3
)

Lane indices for the kanban board.

Variables

This section is empty.

Functions

func AddDepCmd

func AddDepCmd(anvilPath, beadID, depID string) tea.Cmd

AddDepCmd adds a dependency to a bead via bd dep add <beadID> <depID>. After this, beadID depends on depID (depID blocks beadID).

func AppendNotesCmd

func AppendNotesCmd(anvilPath, beadID, notes string) tea.Cmd

AppendNotesCmd appends text to a bead's notes field.

func BulkCloseCmd

func BulkCloseCmd(anvils map[string]string, beads []Bead, selectedIDs map[string]bool) tea.Cmd

BulkCloseCmd closes all selected beads sequentially and returns a summary message.

func BulkLabelCmd

func BulkLabelCmd(anvils map[string]string, beads []Bead, selectedIDs map[string]bool, label string, remove bool) tea.Cmd

BulkLabelCmd adds or removes a label from all selected beads sequentially.

func BulkPriorityCmd

func BulkPriorityCmd(anvils map[string]string, beads []Bead, selectedIDs map[string]bool, priority int) tea.Cmd

BulkPriorityCmd sets the priority of all selected beads sequentially.

func CloseBeadCmd

func CloseBeadCmd(anvilPath, beadID, reason string) tea.Cmd

CloseBeadCmd closes a bead with an optional reason.

func EditBeadCmd

func EditBeadCmd(anvilPath, beadID, title, description string) tea.Cmd

EditBeadCmd updates a bead's title and description.

func FetchAllBeads

func FetchAllBeads(anvils map[string]string, db *state.DB) tea.Cmd

FetchAllBeads returns a tea.Cmd that fetches beads from all anvils in parallel. It fetches open/in_progress beads plus up to 50 closed beads (best-effort), then filters the closed beads to those updated or closed within the last 7 days. Note: closed-bead ordering is not guaranteed, so the 7-day window is applied after fetching — beads closed within 7 days but outside the first 50 results may not appear.

func FetchAnvilBeads

func FetchAnvilBeads(anvilName, anvilPath string, db *state.DB) tea.Cmd

FetchAnvilBeads returns a tea.Cmd that fetches beads for a single named anvil. It fetches open/in_progress beads plus recently-closed beads (last 7 days, up to 50), then enriches the results with PR data from the state DB.

func NewBeadCmd

func NewBeadCmd(anvilPath, title, description, issueType string, priority int) tea.Cmd

NewBeadCmd creates a new bead via bd create.

func RemoveDepCmd

func RemoveDepCmd(anvilPath, beadID, depID string) tea.Cmd

RemoveDepCmd removes a dependency via bd dep remove <beadID> <depID>. This removes the relationship where beadID depends on depID.

func ReopenBeadCmd

func ReopenBeadCmd(anvilPath, beadID string) tea.Cmd

ReopenBeadCmd reopens a closed bead.

func UpdateAssigneeCmd

func UpdateAssigneeCmd(anvilPath, beadID, assignee string) tea.Cmd

UpdateAssigneeCmd assigns or unassigns a bead.

func UpdateLabelCmd

func UpdateLabelCmd(anvilPath, beadID, label string, remove bool) tea.Cmd

UpdateLabelCmd adds or removes a label from a bead.

func UpdateNotesCmd

func UpdateNotesCmd(anvilPath, beadID, notes string) tea.Cmd

UpdateNotesCmd replaces a bead's notes field.

func UpdatePriorityCmd

func UpdatePriorityCmd(anvilPath, beadID string, priority int) tea.Cmd

UpdatePriorityCmd changes a bead's priority.

Types

type ActionErrorMsg

type ActionErrorMsg struct{ Err error }

ActionErrorMsg indicates a bead action failed.

type Bead

type Bead struct {
	ID          string     `json:"id"`
	Title       string     `json:"title"`
	Description string     `json:"description"`
	Status      string     `json:"status"`
	Priority    int        `json:"priority"`
	IssueType   string     `json:"issue_type"`
	Assignee    string     `json:"assignee"`
	Labels      []string   `json:"labels"`
	Blocks      []string   `json:"blocks"`
	DependsOn   []string   `json:"depends_on"`
	ClosedAt    *time.Time `json:"closed_at"`
	UpdatedAt   *time.Time `json:"updated_at"`

	// Enriched fields (not from bd JSON)
	Anvil string `json:"-"`
	HasPR bool   `json:"-"`
}

Bead represents an issue from bd with enrichment from Forge's state DB.

func (*Bead) UnmarshalJSON

func (b *Bead) UnmarshalJSON(data []byte) error

UnmarshalJSON implements json.Unmarshaler for Bead. It sanitises timestamp fields whose year is outside the JSON-safe range [0,9999], zeroing those fields instead of storing an unrepresentable value that would crash when the Bead is later re-marshalled to JSON.

type BeadClosedMsg

type BeadClosedMsg struct{ ID string }

BeadClosedMsg indicates a bead was successfully closed.

type BeadCreatedMsg

type BeadCreatedMsg struct{ ID string }

BeadCreatedMsg indicates a new bead was successfully created.

type BeadReopenedMsg

type BeadReopenedMsg struct{ ID string }

BeadReopenedMsg indicates a bead was successfully reopened.

type BeadUpdatedMsg

type BeadUpdatedMsg struct{ ID string }

BeadUpdatedMsg indicates a bead was successfully updated.

type BulkCloseResultMsg

type BulkCloseResultMsg struct {
	Closed int
	Failed int
}

BulkCloseResultMsg is returned after a bulk close operation completes.

type BulkState

type BulkState struct {
	// contains filtered or unexported fields
}

BulkState tracks which beads are currently selected for bulk operations.

func (*BulkState) Clear

func (b *BulkState) Clear()

Clear removes all selections.

func (*BulkState) Count

func (b *BulkState) Count() int

Count returns the number of selected beads.

func (*BulkState) IsSelected

func (b *BulkState) IsSelected(id string) bool

IsSelected reports whether the given bead ID is selected.

func (*BulkState) SelectAll

func (b *BulkState) SelectAll(beads []Bead)

SelectAll marks all given beads as selected.

func (*BulkState) Toggle

func (b *BulkState) Toggle(id string)

Toggle flips the selection state for the given bead ID.

type BulkUpdatedMsg

type BulkUpdatedMsg struct {
	Updated int
	Failed  int
}

BulkUpdatedMsg is returned after a bulk update operation (label/priority) completes.

type DepAddedMsg

type DepAddedMsg struct {
	BeadID string
	DepID  string
}

DepAddedMsg indicates a dependency was successfully added.

type DepRemovedMsg

type DepRemovedMsg struct {
	BeadID string
	DepID  string
}

DepRemovedMsg indicates a dependency was successfully removed.

type EventEntry

type EventEntry struct {
	Timestamp string
	Level     EventLevel
	Message   string
}

EventEntry is one entry in the Ledger's in-memory event/error log.

type EventLevel

type EventLevel int

EventLevel indicates the severity of a log entry.

const (
	EventInfo EventLevel = iota
	EventWarn
	EventError
)

type FormKind

type FormKind int

FormKind tracks which overlay form is active.

const (
	FormNone FormKind = iota
	FormNewBead
	FormEditBead
	FormCloseBead
	FormLabel
	FormPriority
	FormComment
	FormNotes
	FormAssign
	FormAddDep       // d key: pick a bead to add as a dependency
	FormViewDeps     // b key: view and optionally remove dependencies
	FormBulkLabel    // ctrl+l: set a label on all selected beads
	FormBulkPriority // ctrl+p: set priority on all selected beads
)

type Model

type Model struct {
	// contains filtered or unexported fields
}

Model is the top-level Bubbletea model for the Ledger TUI.

func NewModel

func NewModel(anvils map[string]string, anvilConfigs map[string]config.AnvilConfig, db *state.DB) *Model

NewModel creates a new Ledger model. anvilConfigs is the per-anvil configuration map from forge.yaml (may be nil); it is used when running dependency updates so they respect per-anvil Temper settings.

func (*Model) Init

func (m *Model) Init() tea.Cmd

Init schedules the periodic refresh tick. Bead data is fetched lazily when the user selects an anvil from the top-level ViewAnvils screen.

func (*Model) Update

func (m *Model) Update(msg tea.Msg) (tea.Model, tea.Cmd)

Update handles incoming messages.

func (*Model) View

func (m *Model) View() string

View renders the current state.

type SortField

type SortField int

SortField determines how beads are sorted in the list view.

const (
	SortPriority SortField = iota // default
	SortStatus
	SortUpdatedAt
)

func (SortField) String

func (s SortField) String() string

type TreeNode

type TreeNode struct {
	Bead     *Bead
	Depth    int
	Children []*TreeNode
	Progress string // e.g. "3/5" (closed/total children); empty for leaf nodes
}

TreeNode represents a node in the bead hierarchy tree.

type UpdateBeadsMsg

type UpdateBeadsMsg struct {
	Beads []Bead
	Err   error
}

UpdateBeadsMsg carries the result of a FetchAllBeads operation.

type ViewMode

type ViewMode int

ViewMode determines which screen the Ledger is showing.

const (
	ViewList ViewMode = iota
	ViewKanban
	ViewHierarchy
	ViewAnvils // top-level anvil picker — shown on startup
)

Jump to

Keyboard shortcuts

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