beads

package
v0.53.2 Latest Latest
Warning

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

Go to latest
Published: Jun 2, 2026 License: MIT Imports: 15 Imported by: 0

Documentation

Overview

Package beads provides a minimal public API for extending bd with custom orchestration.

Most extensions should use direct SQL queries against bd's database. This package exports only the essential types and functions needed for Go-based extensions that want to use bd's storage layer programmatically.

For detailed guidance on extending bd, see EXTENDING.md.

Index

Constants

View Source
const (
	StatusOpen       = types.StatusOpen
	StatusInProgress = types.StatusInProgress
	StatusBlocked    = types.StatusBlocked
	StatusDeferred   = types.StatusDeferred
	StatusClosed     = types.StatusClosed
)

Status constants

View Source
const (
	TypeBug      = types.TypeBug
	TypeFeature  = types.TypeFeature
	TypeTask     = types.TypeTask
	TypeEpic     = types.TypeEpic
	TypeChore    = types.TypeChore
	TypeMolecule = types.TypeMolecule
)

IssueType constants

View Source
const (
	DepBlocks            = types.DepBlocks
	DepRelated           = types.DepRelated
	DepParentChild       = types.DepParentChild
	DepDiscoveredFrom    = types.DepDiscoveredFrom
	DepConditionalBlocks = types.DepConditionalBlocks // B runs only if A fails
)

DependencyType constants

View Source
const (
	SortPolicyHybrid   = types.SortPolicyHybrid
	SortPolicyPriority = types.SortPolicyPriority
	SortPolicyOldest   = types.SortPolicyOldest
)

SortPolicy constants

View Source
const (
	EventCreated           = types.EventCreated
	EventUpdated           = types.EventUpdated
	EventStatusChanged     = types.EventStatusChanged
	EventCommented         = types.EventCommented
	EventClosed            = types.EventClosed
	EventReopened          = types.EventReopened
	EventDependencyAdded   = types.EventDependencyAdded
	EventDependencyRemoved = types.EventDependencyRemoved
	EventLabelAdded        = types.EventLabelAdded
	EventLabelRemoved      = types.EventLabelRemoved
	EventCompacted         = types.EventCompacted
)

EventType constants

View Source
const CanonicalDatabaseName = "beads.db"

CanonicalDatabaseName is the required database filename for all beads repositories

View Source
const RedirectFileName = "redirect"

RedirectFileName is the name of the file that redirects to another .beads directory

Variables

View Source
var LegacyDatabaseNames = []string{"bd.db", "issues.db", "bugs.db"}

LegacyDatabaseNames are old names that should be migrated

Functions

func ComputeRepoID

func ComputeRepoID() (string, error)

ComputeRepoID generates a unique identifier for this git repository

func FindBeadsDir

func FindBeadsDir() string

FindBeadsDir finds the .beads/ directory in the current directory tree Returns empty string if not found. Supports both database and JSONL-only mode. Stops at the git repository root to avoid finding unrelated directories. Validates that the directory contains actual project files. Redirect files are supported: if a .beads/redirect file exists, its contents are used as the actual .beads directory path. For worktrees, prioritizes local .beads if present, otherwise uses main repo.

func FindDatabasePath

func FindDatabasePath() string

FindDatabasePath discovers the bd database path using bd's standard search order:

  1. $BEADS_DIR environment variable (points to .beads directory)
  2. $BEADS_DB environment variable (points directly to database file, deprecated)
  3. .beads/*.db in current directory or ancestors

Redirect files are supported: if a .beads/redirect file exists, its contents are used as the actual .beads directory path.

Returns empty string if no database is found.

func FindJSONLPath

func FindJSONLPath(dbPath string) string

FindJSONLPath returns the expected JSONL file path for the given database path. It searches for existing *.jsonl files in the database directory and returns the first one found, preferring issues.jsonl over beads.jsonl.

This function does not create directories or files - it only discovers paths. Use this when you need to know where bd stores its JSONL export.

func FollowRedirect

func FollowRedirect(beadsDir string) string

FollowRedirect checks if a .beads directory contains a redirect file and follows it. If a redirect file exists, it returns the target .beads directory path. If no redirect exists or there's an error, it returns the original path unchanged.

The redirect file should contain a single path (relative or absolute) to the target .beads directory. Relative paths are resolved from the parent directory of the original .beads directory (i.e., the project root).

Redirect chains are not followed - only one level of redirection is supported. This prevents infinite loops and keeps the behavior predictable.

func GetCloneID

func GetCloneID() (string, error)

GetCloneID generates a unique ID for this specific clone (not shared with other clones)

Types

type BlockedIssue

type BlockedIssue = types.BlockedIssue

BlockedIssue represents an issue with blocking dependencies.

type Comment

type Comment = types.Comment

Comment represents a user comment on an issue.

type DatabaseInfo

type DatabaseInfo struct {
	Path       string // Full path to the .db file
	BeadsDir   string // Parent .beads directory
	IssueCount int    // Number of issues (-1 if unknown)
}

DatabaseInfo contains information about a discovered beads database

func FindAllDatabases

func FindAllDatabases() []DatabaseInfo

FindAllDatabases scans the directory hierarchy for the closest .beads directory. Returns a slice with at most one DatabaseInfo - the closest database to CWD. Stops searching upward as soon as a .beads directory is found, because in multi-workspace setups, nested .beads directories are intentional and separate - parent directories are out of scope. Redirect files are supported: if a .beads/redirect file exists, its contents are used as the actual .beads directory path.

type Dependency

type Dependency = types.Dependency

Dependency represents a relationship between issues.

type DependencyType

type DependencyType = types.DependencyType

DependencyType represents the type of dependency (blocks, related, parent-child, discovered-from).

type EpicStatus

type EpicStatus = types.EpicStatus

EpicStatus represents the status of an epic issue.

type Event

type Event = types.Event

Event represents an audit log event.

type EventType

type EventType = types.EventType

EventType represents the type of audit event.

type Issue

type Issue = types.Issue

Issue represents a tracked work item with metadata, dependencies, and status.

type IssueFilter

type IssueFilter = types.IssueFilter

IssueFilter represents filtering criteria for issue queries.

type IssueType

type IssueType = types.IssueType

IssueType represents the type of issue (bug, feature, task, epic, chore).

type Label

type Label = types.Label

Label represents a tag attached to an issue.

type RedirectInfo

type RedirectInfo struct {
	// IsRedirected is true if the local .beads has a redirect file
	IsRedirected bool
	// LocalDir is the local .beads directory (the one with the redirect file)
	LocalDir string
	// TargetDir is the actual .beads directory being used (after following redirect)
	TargetDir string
}

RedirectInfo contains information about a beads directory redirect.

func GetRedirectInfo

func GetRedirectInfo() RedirectInfo

GetRedirectInfo checks if the current beads directory is redirected. It searches for the local .beads/ directory and checks if it contains a redirect file. Returns RedirectInfo with IsRedirected=true if a redirect is active.

type SortPolicy

type SortPolicy = types.SortPolicy

SortPolicy determines how ready work is ordered.

type Statistics

type Statistics = types.Statistics

Statistics represents project-wide metrics.

type Status

type Status = types.Status

Status represents the current state of an issue (open, in progress, closed, blocked).

type Storage

type Storage = storage.Storage

Storage provides the minimal interface for extension orchestration

func NewSQLiteStorage

func NewSQLiteStorage(ctx context.Context, dbPath string) (Storage, error)

NewSQLiteStorage opens a bd SQLite database for programmatic access. Most extensions should use this to query ready work and update issue status.

type Transaction

type Transaction = storage.Transaction

Transaction provides atomic multi-operation support within a database transaction. Use Storage.RunInTransaction() to obtain a Transaction instance.

type TreeNode

type TreeNode = types.TreeNode

TreeNode represents a node in a dependency tree.

type WorkFilter

type WorkFilter = types.WorkFilter

WorkFilter represents filtering criteria for work queries.

Jump to

Keyboard shortcuts

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