ops

package
v2.11.1 Latest Latest
Warning

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

Go to latest
Published: Nov 29, 2026 License: Apache-2.0 Imports: 44 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package ops implements aitk operations. The CLI and the MCP server both call these, so their effects are identical (docs/spec/integrations.md).

Index

Constants

View Source
const ASVSSection = "Security checklist (OWASP ASVS 4.0.3)"

ASVSSection is the security checklist section name.

View Source
const DefaultClaimTTL = 4 * time.Hour

DefaultClaimTTL is how long a task claim lasts without renewal (task start renews it).

View Source
const RunEnv = "AITK_RUN"

RunEnv marks processes started by aitk run, so an agent cannot start a nested run.

View Source
const StopAfterFailures = 2

StopAfterFailures is the consecutive failing-check count at which agents must stop.

Variables

This section is empty.

Functions

func AddSecurityChecklist added in v2.2.0

func AddSecurityChecklist(p *project.Project, id string) (*task.Task, bool, error)

AddSecurityChecklist appends the ASVS checklist to a task (idempotent).

func AgentInEnv added in v2.2.0

func AgentInEnv() string

AgentInEnv names the AI agent running this process, or "" for a person. An explicit AITK_TOOL=human cannot override agent environment variables.

func Claim

func Claim(p *project.Project, id string, ttl time.Duration) (claims.Claim, error)

Claim claims id for this worktree, failing when another worktree holds it.

func GuardText added in v2.1.0

func GuardText(what string, texts ...string) error

GuardText refuses text that would put a credential into the repository (agents paste tokens into summaries and notes surprisingly often).

func IsBugTask added in v2.4.0

func IsBugTask(t *task.Task) bool

IsBugTask reports whether t is a bug fix (tagged bug).

func IsTestPath added in v2.4.0

func IsTestPath(path string) bool

IsTestPath reports whether a repository path is a test file, by common naming conventions.

func OpenDependencies added in v2.4.0

func OpenDependencies(t *task.Task, byID map[string]*task.Task) []string

OpenDependencies returns the dependencies of t that are not done or cancelled (missing IDs count as open).

func Release

func Release(p *project.Project, id string, force bool) (bool, error)

Release drops this worktree's claim (or any claim with force).

func ReviewPass

func ReviewPass(p *project.Project, id string, findings int) (*task.Task, error)

ReviewPass records a bug-hunt pass on the active task. With id, a reviewer records the pass without starting the task (starting it would make the reviewer one of its workers, and the review would no longer count as independent).

func RunScope added in v2.11.0

func RunScope(next string) error

RunScope keeps an agent inside aitk run on the one task it was given; work on anything else would be finished outside the run's own verification.

func Slop added in v2.10.0

func Slop(p *project.Project, paths []string) []slop.Hit

Slop scans the given paths, or else the files changed on this branch (aitk metadata excluded).

func SwitchAllowed added in v2.11.0

func SwitchAllowed(p *project.Project, next string) error

SwitchAllowed enforces one task at a time: an agent finishes the active task (review until clean, then close) or blocks it before starting another in the same worktree.

func SwitchTools

func SwitchTools() []string

SwitchTools lists tools whose start command aitk knows.

func TaskChanges added in v2.5.1

func TaskChanges(p *project.Project, t *task.Task) []profile.Change

TaskChanges are the changes that make up t's risk profile: the branch's changes since the default branch plus everything since the task started (on the default branch, the first part is only uncommitted work). Without a task, the branch's changes.

func TaskNew

func TaskNew(p *project.Project, in NewTaskInput) (*task.Task, error)

TaskNew creates a task in status todo.

func TaskStart

func TaskStart(p *project.Project, id string) (*task.Task, error)

TaskStart makes id the active task of this worktree and marks it in_progress.

func TaskUpdate

func TaskUpdate(p *project.Project, id string, in UpdateInput) (*task.Task, error)

TaskUpdate edits structured fields without hand-editing YAML.

func Tool

func Tool() string

Tool identifies the AI tool (or human) running aitk. AITK_TOOL overrides detection.

func TrackedFiles added in v2.10.0

func TrackedFiles(p *project.Project) []string

TrackedFiles lists tracked and untracked (not ignored) files, for a whole-repository scan.

func UATScript added in v2.2.0

func UATScript(p *project.Project, id string, force bool) (string, error)

UATScript writes docs/ai/uat/<id>.md: a test script for a person, from the criteria.

func WithLock

func WithLock(p *project.Project, fn func() error) error

WithLock runs fn while holding the project lock.

Types

type AuditResult added in v2.2.0

type AuditResult struct {
	task.Audit
	Task     string            `json:"task,omitempty"`
	Tasks    *AuditTasksResult `json:"fix_tasks,omitempty"`
	Warnings []string          `json:"-"`
}

AuditResult is the outcome of aitk audit.

func Audit added in v2.2.0

func Audit(p *project.Project, stream bool) (*AuditResult, error)

Audit runs the security scanners and records evidence on the active task.

type AuditTasksResult added in v2.4.0

type AuditTasksResult struct {
	Created []string `json:"created"`
	Open    []string `json:"already_open"` // findings that already have an open task
}

AuditTasksResult lists fix tasks created from audit findings.

func AuditTasks added in v2.4.0

func AuditTasks(p *project.Project, r *AuditResult) (*AuditTasksResult, error)

AuditTasks turns the findings of a failed audit into fix tasks: one per vulnerable dependency (from osv-scanner, with the version that fixes every advisory) and one per other failing scanner. Findings that already have an open task are not duplicated.

type Candidate added in v2.4.0

type Candidate struct {
	ID        string   `json:"id"`
	Title     string   `json:"title"`
	Status    string   `json:"status"`
	Profile   string   `json:"profile"`
	WaitingOn []string `json:"waiting_on,omitempty"` // unfinished dependencies
	ClaimedBy string   `json:"claimed_by,omitempty"` // another worktree's claim
}

Candidate is a task that could be worked on next, or why it cannot.

type CheckResult

type CheckResult struct {
	task.Check
	Task     string `json:"task,omitempty"`
	TimedOut bool   `json:"timed_out,omitempty"`
	Failures int    `json:"consecutive_failures,omitempty"`
}

CheckResult is the outcome of aitk check.

func Check

func Check(p *project.Project, stream bool) (*CheckResult, error)

Check runs check.cmd and records evidence on the active task (if any).

type CloseInput

type CloseInput struct {
	Summary   string
	Knowledge string // "none" allowed
	Next      []string
	Status    string // optional: in_progress or blocked to close a session without finishing
	Tags      []string
}

CloseInput holds close fields.

type CloseResult

type CloseResult struct {
	Task      string   `json:"task"`
	Status    string   `json:"status"`
	Profile   string   `json:"profile"`
	Handoff   string   `json:"handoff"`
	Knowledge bool     `json:"knowledge_recorded"`
	Compacted bool     `json:"compacted,omitempty"`
	Notes     []string `json:"notes,omitempty"`
}

CloseResult reports what close did.

func Close

func Close(p *project.Project, in CloseInput) (*CloseResult, error)

Close applies the Definition of Done (docs/spec/workflow.md §5) and records evidence.

type Goal added in v2.2.0

type Goal struct {
	ID     string `json:"id"`
	Title  string `json:"title"`
	Status string `json:"status"`
	Parent string `json:"parent,omitempty"`
	Tasks  int    `json:"tasks"`
	Done   int    `json:"done"`
}

Goal mirrors ai-state.json goals.

func FindGoal added in v2.2.0

func FindGoal(p *project.Project, id string) *Goal

FindGoal returns the goal with id.

func GoalAdd added in v2.2.0

func GoalAdd(p *project.Project, title, id, parent string) (*Goal, error)

GoalAdd creates a goal (status planned).

func GoalStatus added in v2.2.0

func GoalStatus(p *project.Project, id, status string) (*Goal, error)

GoalStatus changes a goal's status.

func Goals added in v2.2.0

func Goals(p *project.Project) []Goal

Goals lists goals with task progress.

type ImpactFile added in v2.4.0

type ImpactFile struct {
	Path         string   `json:"path"`
	Lines        int      `json:"lines"`
	ReferencedBy []string `json:"referenced_by"`
	Tests        []string `json:"tests"` // tests that reference it, sit next to it, or were changed with it
	More         int      `json:"more,omitempty"`
}

ImpactFile is one changed source file and the code that depends on it.

type ImpactResult added in v2.4.0

type ImpactResult struct {
	Files        []ImpactFile `json:"files"`
	TestsChanged []string     `json:"tests_changed"`
	Untested     []string     `json:"untested"`          // changed source files no test appears to cover
	Deleted      []ImpactFile `json:"deleted,omitempty"` // deleted source files that code still references
}

ImpactResult lists the blast radius of the current change.

func Impact added in v2.4.0

func Impact(p *project.Project) *ImpactResult

Impact finds, for each changed source file, which tracked files reference it (by module name, or by Go package import path) and which tests cover it. It is a heuristic over text search: a fast way to see what a change can break, not a call graph.

type ImportResult

type ImportResult struct {
	Source   string   `json:"source"`
	Imported []string `json:"imported"`
	Skipped  []string `json:"skipped"` // already present
	DryRun   bool     `json:"dry_run"`
	Synced   []string `json:"synced,omitempty"`                 // done in aitk, now checked in the source file
	Drift    []string `json:"checked_in_source_only,omitempty"` // checked in the source file, not done in aitk
}

ImportResult reports imported and skipped items.

func ImportBMAD added in v2.2.0

func ImportBMAD(p *project.Project, paths []string, dry bool) (*ImportResult, error)

ImportBMAD imports BMAD tickets (story, bug, spike files with YAML frontmatter). Criteria come from "## Acceptance Criteria" (numbered Given/When/Then items, or a Verify: line); status from the sibling <type>-<slug>-plan.md; risk: high pins the strict profile.

func ImportChecklist

func ImportChecklist(p *project.Project, kind string, paths []string, dry bool) (*ImportResult, error)

ImportChecklist imports Spec Kit (specs/*/tasks.md) or OpenSpec (openspec/changes/*/tasks.md) checklists: each checkbox line becomes a task; "T001 …" keeps its ID (prefixed by the spec name). Spec Kit markers become tags ([P] → parallel, [US1] → us1) and its phases become dependencies: a task waits for the previous sequential task, and a sequential task waits for the parallel tasks before it. Tasks link the feature's spec.md and plan.md. Importing again checks off the items of tasks done in aitk and reports items checked only in the file.

func ImportGitHub

func ImportGitHub(p *project.Project, repo, label, state string, limit int, dry bool) (*ImportResult, error)

ImportGitHub imports issues through the GitHub CLI (`gh`). Checkbox lines in the issue body become acceptance criteria; labels become tags; closed issues become done tasks.

func ImportSuperpowers added in v2.2.0

func ImportSuperpowers(p *project.Project, paths []string, dry bool) (*ImportResult, error)

ImportSuperpowers imports Superpowers implementation plans (docs/superpowers/plans/*.md): each "### Task N: Name" becomes a task; its "- [ ] **Step k: …**" lines become criteria.

type InitResult

type InitResult struct {
	Created []string `json:"created"`
	Updated []string `json:"updated"`
	Kept    []string `json:"kept_hand_written,omitempty"` // existing docs aitk will not overwrite
	Check   string   `json:"check,omitempty"`
}

InitResult reports what init created.

func Init

func Init(dir, name, check string, dryRun bool) (*InitResult, error)

Init bootstraps a v2 project in the repository containing dir. It never overwrites user content.

type NewTaskInput

type NewTaskInput struct {
	Title, ID, Goal, Profile, Objective string
	Criteria, Tags, DependsOn           []string
}

NewTaskInput holds task creation fields.

type NextFilter added in v2.4.0

type NextFilter struct {
	Goal string
	Tag  string
	Skip map[string]bool // task IDs to leave out (e.g. already attempted in this run)
}

NextFilter narrows which tasks are candidates.

type NextResult added in v2.4.0

type NextResult struct {
	Ready   []Candidate `json:"ready"`
	Waiting []Candidate `json:"waiting"`
}

NextResult lists ready tasks in the order they should be worked on, and tasks waiting on others.

func Next added in v2.4.0

func Next(p *project.Project, f NextFilter) *NextResult

Next orders the work that can start now: this worktree's active task, then unfinished tasks nobody else holds (in_progress before todo), oldest first. Tasks waiting for a person (in_review), blocked, done, or cancelled are not candidates; tasks with open dependencies are listed as waiting.

type ReleaseInput added in v2.2.0

type ReleaseInput struct {
	Bump      string
	Pre       string
	DryRun    bool
	Tag       bool // commit the release files and create an annotated tag
	SkipCheck bool
}

ReleaseInput controls aitk release.

type ReleaseResult added in v2.2.0

type ReleaseResult struct {
	*release.Plan
	Written  []string `json:"written,omitempty"`
	Commit   string   `json:"commit,omitempty"`
	Tagged   bool     `json:"tagged"`
	Warnings []string `json:"-"`
}

ReleaseResult reports a release.

func ReleaseProject added in v2.2.0

func ReleaseProject(p *project.Project, in ReleaseInput) (*ReleaseResult, error)

ReleaseProject versions the project: SemVer from Conventional Commits, changelog, manifests, tag. It never pushes.

type Report

type Report struct {
	Since      string         `json:"since"`
	Done       []TaskRow      `json:"done"`
	InProgress []TaskRow      `json:"in_progress"`
	Blocked    []TaskRow      `json:"blocked"`
	InReview   []TaskRow      `json:"in_review"`
	ByTool     map[string]int `json:"handoffs_by_tool"`
	Handoffs   int            `json:"handoffs"`
	Knowledge  int            `json:"knowledge_added"`
}

Report summarizes activity since a time (docs/spec/cli.md, report).

func BuildReport

func BuildReport(p *project.Project, since time.Time) *Report

BuildReport aggregates tasks and handoffs updated since `since`.

func (*Report) Markdown

func (r *Report) Markdown(project string) string

Markdown renders the report.

type RunInput added in v2.4.0

type RunInput struct {
	Agent       string
	Cmd         string
	MaxTasks    int
	MaxAttempts int
	Timeout     time.Duration
	Goal        string
	Tag         string
	DryRun      bool
	Commit      *bool // nil: [run].commit
}

RunInput configures aitk run; zero values fall back to [run] in aitk.toml, then to defaults.

type RunResult added in v2.4.0

type RunResult struct {
	Agent   string      `json:"agent"`
	DryRun  bool        `json:"dry_run"`
	Planned []Candidate `json:"planned,omitempty"` // dry run: the order tasks would be taken in
	Tasks   []RunTask   `json:"tasks"`
	Stopped string      `json:"stopped"` // why the loop ended
}

RunResult reports a run.

func Run added in v2.4.0

func Run(p *project.Project, in RunInput, log io.Writer) (*RunResult, error)

Run works through ready tasks one at a time with a headless agent. aitk never marks work done itself: each task finishes only through the agent's own `aitk close` and the Definition of Done. Tasks that need a person (review or UAT) are left in_review; tasks the agent cannot finish are handed over as blocked with a handoff. The loop stops after two unfinished tasks in a row.

type RunTask added in v2.4.0

type RunTask struct {
	ID       string `json:"id"`
	Title    string `json:"title"`
	Attempts int    `json:"attempts"`
	Status   string `json:"status"`            // the task's status afterwards
	Note     string `json:"note,omitempty"`    // why it stopped there
	Handoff  string `json:"handoff,omitempty"` // written by aitk run when the agent did not finish
	Commit   string `json:"commit,omitempty"`  // with --commit: the commit of the task's work
	Stash    string `json:"stash,omitempty"`   // with --commit: unfinished work set aside with git stash
	// AgentError: the agent could not run at all; the task is left as it was.
	AgentError bool `json:"agent_error,omitempty"`
}

RunTask is the outcome of one task in a run.

type Shortcut added in v2.7.0

type Shortcut struct {
	File string `json:"file"`
	Line int    `json:"line"`
	Text string `json:"text"`
}

Shortcut is one deliberate limit recorded in code as "shortcut: <the limit>, <when to upgrade>".

func Debt added in v2.7.0

func Debt(p *project.Project) []Shortcut

Debt lists the shortcut comments in tracked and untracked (not ignored) files.

type SwitchResult

type SwitchResult struct {
	Tool       string   `json:"tool"`
	Handoff    string   `json:"handoff"`
	Command    []string `json:"command,omitempty"` // argv to start the tool with the brief, when known
	PromptFile string   `json:"prompt_file"`
	Prompt     string   `json:"prompt"`
}

SwitchResult tells the caller how to hand the work to another tool.

func Switch

func Switch(p *project.Project, tool, note string) (*SwitchResult, error)

Switch writes a handoff to tool and prepares the prompt that continues the work there.

type TaskRow

type TaskRow struct {
	ID      string `json:"id"`
	Title   string `json:"title"`
	Updated string `json:"updated"`
	By      string `json:"by,omitempty"`
	Commits int    `json:"commits,omitempty"`
}

TaskRow is a report line.

type UATDecision added in v2.2.0

type UATDecision struct {
	Task    string `json:"task"`
	Status  string `json:"status"`
	UAT     string `json:"uat"`
	Missing string `json:"missing,omitempty"` // what still blocks done after acceptance
}

UATDecision is the outcome of accept or reject.

func UATAccept added in v2.2.0

func UATAccept(p *project.Project, id, by, note string) (*UATDecision, error)

UATAccept records a person's acceptance and completes the task when nothing else blocks it.

func UATReject added in v2.2.0

func UATReject(p *project.Project, id, by, reason string) (*UATDecision, error)

UATReject records a rejection and sends the task back to in_progress.

type UpdateInput

type UpdateInput struct {
	Status  string
	ACDone  []int // 1-based
	AddAC   []string
	Note    string
	Tags    []string
	Profile string
	Reason  string // for blocked
}

UpdateInput holds task update fields; zero values mean "no change".

type WorkResult

type WorkResult struct {
	Task    string   `json:"task"`
	Path    string   `json:"path"`
	Branch  string   `json:"branch"`
	Created bool     `json:"created"`
	Copied  []string `json:"copied,omitempty"` // uncommitted aitk files copied into the worktree
}

WorkResult describes the worktree prepared for a task.

func Work

func Work(p *project.Project, id string) (*WorkResult, error)

Work creates (or reuses) a worktree and branch dedicated to task id, claims the task, and starts it there.

Jump to

Keyboard shortcuts

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