harvest

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 6, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package harvest turns repository backlogs into queue tasks.

It is the ingestion half of a self-managing agent pool: every repo's TODO_LIST.md is the shared, human-readable work backlog; the harvester repeatedly scans it and enqueues one agent task per open item, paced to at most one in-flight task per repo. Agents (see executor.AgentExecutor) do the item and mark it done in the same file, which closes the loop: done items are never re-enqueued, edited items become new work.

Index

Constants

View Source
const DefaultMaxPerTick = 10

DefaultMaxPerTick bounds how many new agent tasks one harvest run may enqueue across all repos — the cost throttle for unattended pools.

View Source
const DefaultPromptTemplate = `` /* 676-byte string literal not displayed */

DefaultPromptTemplate is the agent contract handed to Crush for each item. Placeholders: {{REPO_ABS}}, {{REPO}}, {{HEADING}}, {{ITEM}}.

View Source
const DefaultTodoFile = "TODO_LIST.md"

DefaultTodoFile is the backlog file scanned in each repository.

View Source
const DefaultType = "agent"

DefaultType is the task type harvest enqueues: the headless agent executor (executor.AgentExecutor, registered as "agent" by the tq CLI).

Variables

This section is empty.

Functions

func DiscoverRepos

func DiscoverRepos(dir, todoFile string) ([]string, error)

DiscoverRepos returns the depth-1 subdirectories of dir that contain the todo file, sorted by name.

func ItemKey

func ItemKey(repoName, text string) string

ItemKey derives the stable dedup key for an item: the hash of repo name and item text. Item text is whitespace-collapsed so reflowing a line does not create duplicate work.

Types

type Config

type Config struct {
	// ProjectsDir is scanned (depth 1) for repos containing TodoFile.
	ProjectsDir string
	// Repos lists explicit repo directories; when set, ProjectsDir is ignored.
	Repos []string
	// Type is the task type enqueued (must match a registered executor).
	Type string
	// TodoFile is the backlog file name inside each repo.
	TodoFile string
	// MaxPerTick caps new enqueues per run across all repos.
	MaxPerTick int
	// MaxAttempts is the attempt budget for harvested tasks (0 = default).
	MaxAttempts int
	// Priority for harvested tasks.
	Priority int
	// PromptTemplate overrides DefaultPromptTemplate.
	PromptTemplate string
	// RequireClean passes the clean-tree policy through to agent payloads:
	// nil = executor default (require a clean git tree), false lets agents
	// run on dirty repos (scratch/fixtures only), true forces the check.
	RequireClean *bool
	// DryRun reports what a real run would enqueue, without writing to the
	// queue. Result.Enqueued entries then carry an empty TaskID.
	DryRun bool
}

Config controls one harvester.

type Enqueued

type Enqueued struct {
	Item   Item
	TaskID task.ID
	Fresh  bool // true when this run actually created the task
}

Enqueued records a task created (or already present) for an item.

type Harvester

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

Harvester scans repos and enqueues agent tasks for open todo items.

func New

func New(q *queue.Queue, cfg Config) *Harvester

New creates a Harvester over a queue.

func (*Harvester) Run

func (h *Harvester) Run(ctx context.Context) (Result, error)

Run performs one scan-and-enqueue pass. It never fails on individual repos; repo-level errors are reported as Skipped entries with the error as reason.

type Item

type Item struct {
	Repo     string // absolute repo path
	RepoName string // project name (repo dir base name)
	Heading  string // nearest markdown heading above the item
	Text     string // the checkbox text, trimmed
	Key      string // stable dedup key: hash of repo name + item text
}

Item is one open checkbox found in a repo's todo file.

func ParseRepo

func ParseRepo(repo, todoFile string) ([]Item, error)

ParseRepo extracts the open checkbox items from a repo's todo file.

Semantics: a line matching `- [ ]`/`* [ ]` (leading whitespace allowed) is an item; `- [x]`/`- [X]` are done and ignored. The nearest heading above the item (any level, text without the #s) is its Heading. Lines inside fenced code blocks are ignored, so TODO examples in documentation are never harvested. The Key changes when the item text changes, so editing an item re-arms it even if a previous task for the old wording exists.

type Result

type Result struct {
	Repos    int
	Items    int
	Enqueued []Enqueued
	Skipped  []Skipped
}

Result summarizes one harvest run.

type Skipped

type Skipped struct {
	Item   Item
	Reason string
}

Skipped records an item deliberately not enqueued, and why. Reasons are stable strings meant for humans and tests.

Jump to

Keyboard shortcuts

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