index

package
v0.2.0-beta.1 Latest Latest
Warning

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

Go to latest
Published: Jan 28, 2026 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type GitMode

type GitMode int
const (
	GitNone GitMode = iota
	GitOpenOnly
	GitAll
	GitTasks
)

type GitPolicy

type GitPolicy struct {
	Mode GitMode

	// TTL controls how long cached git stats are considered fresh.
	// If zero, a default is used.
	TTL time.Duration

	// Tasks is used when Mode == GitTasks.
	Tasks []string

	IncludeConflicts bool
}

type Index

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

Index is a SQLite-backed cache of task metadata for fast queries.

The task files on disk remain the source of truth; the index can be rebuilt at any time.

func Open

func Open(path string) (*Index, error)

Open opens (or creates) the index database at path.

func OpenDefault

func OpenDefault() (*Index, error)

OpenDefault opens (or creates) the index database at .subtask/index.db.

func (*Index) Close

func (i *Index) Close() error

Close closes the underlying database connection.

func (*Index) Get

func (i *Index) Get(ctx context.Context, taskName string) (Record, bool, error)

func (*Index) ListAll

func (i *Index) ListAll(ctx context.Context) ([]ListItem, error)

func (*Index) ListClosed

func (i *Index) ListClosed(ctx context.Context) ([]ListItem, error)

func (*Index) ListOpen

func (i *Index) ListOpen(ctx context.Context) ([]ListItem, error)

func (*Index) Refresh

func (i *Index) Refresh(ctx context.Context, policy RefreshPolicy) error

Refresh updates the index from task files on disk.

It is safe to call frequently: when no files changed, Refresh performs no DB writes.

func (*Index) UpdateChangesCache added in v0.2.0

func (i *Index) UpdateChangesCache(ctx context.Context, name string, baseCommit string, branchHead string, added int, removed int) error

func (*Index) UpdateCommitCountCache added in v0.2.0

func (i *Index) UpdateCommitCountCache(ctx context.Context, name string, baseCommit string, branchHead string, count int) error

func (*Index) UpdateCommitLogLastHead added in v0.2.0

func (i *Index) UpdateCommitLogLastHead(ctx context.Context, name string, branchHead string) error

func (*Index) UpdateIntegrationCache added in v0.2.0

func (i *Index) UpdateIntegrationCache(ctx context.Context, name string, branchHead string, targetHead string, reason string) error

func (*Index) UpdateRefHeads added in v0.2.0

func (i *Index) UpdateRefHeads(ctx context.Context, name string, branchHead string, baseHead string) error

type ListItem

type ListItem struct {
	Name       string
	Title      string
	FollowUp   string
	BaseBranch string
	BaseCommit string

	TaskStatus   task.TaskStatus
	WorkerStatus task.WorkerStatus
	Stage        string

	Workspace string
	StartedAt time.Time
	LastError string

	LastHistory time.Time
	LastActive  time.Time
	ToolCalls   int

	LastRunDurationMS int

	ProgressDone  int
	ProgressTotal int

	LinesAdded   int
	LinesRemoved int
}

ListItem is a task summary record suitable for list output.

type Record

type Record struct {
	Task *task.Task

	BaseCommit string

	TaskStatus   task.TaskStatus
	WorkerStatus task.WorkerStatus
	Stage        string

	State        *task.State
	ProgressMeta *task.Progress

	LastHistory time.Time

	ProgressDone  int
	ProgressTotal int

	LastRunDurationMS int

	LinesAdded        int
	LinesRemoved      int
	ConflictFilesJSON string

	// Integration (content detection) cache keyed by (base_head, branch_head).
	IntegratedReason      string
	IntegratedBranchHead  string
	IntegratedTargetHead  string
	IntegratedCheckedAtNS int64

	// Git redesign cache fields (input-based invalidation).
	BranchHead string
	BaseHead   string

	ChangesAdded      int
	ChangesRemoved    int
	ChangesBaseCommit string
	ChangesBranchHead string

	CommitCount           int
	CommitCountBaseCommit string
	CommitCountBranchHead string

	CommitLogLastHead string
}

Record is the cached file-backed data for a single task.

type RefreshPolicy

type RefreshPolicy struct {
	Git GitPolicy
}

RefreshPolicy controls what work Refresh performs. File-backed fields are always refreshed; git refresh is optional.

Jump to

Keyboard shortcuts

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