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
- func AddSecurityChecklist(p *project.Project, id string) (*task.Task, bool, error)
- func AgentInEnv() string
- func Claim(p *project.Project, id string, ttl time.Duration) (claims.Claim, error)
- func GuardText(what string, texts ...string) error
- func IsBugTask(t *task.Task) bool
- func IsTestPath(path string) bool
- func OpenDependencies(t *task.Task, byID map[string]*task.Task) []string
- func Release(p *project.Project, id string, force bool) (bool, error)
- func ReviewPass(p *project.Project, id string, findings int) (*task.Task, error)
- func RunScope(next string) error
- func Slop(p *project.Project, paths []string) []slop.Hit
- func SwitchAllowed(p *project.Project, next string) error
- func SwitchTools() []string
- func TaskChanges(p *project.Project, t *task.Task) []profile.Change
- func TaskNew(p *project.Project, in NewTaskInput) (*task.Task, error)
- func TaskStart(p *project.Project, id string) (*task.Task, error)
- func TaskUpdate(p *project.Project, id string, in UpdateInput) (*task.Task, error)
- func Tool() string
- func TrackedFiles(p *project.Project) []string
- func UATScript(p *project.Project, id string, force bool) (string, error)
- func WithLock(p *project.Project, fn func() error) error
- type AuditResult
- type AuditTasksResult
- type Candidate
- type CheckResult
- type CloseInput
- type CloseResult
- type Goal
- type ImpactFile
- type ImpactResult
- type ImportResult
- func ImportBMAD(p *project.Project, paths []string, dry bool) (*ImportResult, error)
- func ImportChecklist(p *project.Project, kind string, paths []string, dry bool) (*ImportResult, error)
- func ImportGitHub(p *project.Project, repo, label, state string, limit int, dry bool) (*ImportResult, error)
- func ImportSuperpowers(p *project.Project, paths []string, dry bool) (*ImportResult, error)
- type InitResult
- type NewTaskInput
- type NextFilter
- type NextResult
- type ReleaseInput
- type ReleaseResult
- type Report
- type RunInput
- type RunResult
- type RunTask
- type Shortcut
- type SwitchResult
- type TaskRow
- type UATDecision
- type UpdateInput
- type WorkResult
Constants ¶
const ASVSSection = "Security checklist (OWASP ASVS 4.0.3)"
ASVSSection is the security checklist section name.
const DefaultClaimTTL = 4 * time.Hour
DefaultClaimTTL is how long a task claim lasts without renewal (task start renews it).
const RunEnv = "AITK_RUN"
RunEnv marks processes started by aitk run, so an agent cannot start a nested run.
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
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 GuardText ¶ added in v2.1.0
GuardText refuses text that would put a credential into the repository (agents paste tokens into summaries and notes surprisingly often).
func IsTestPath ¶ added in v2.4.0
IsTestPath reports whether a repository path is a test file, by common naming conventions.
func OpenDependencies ¶ added in v2.4.0
OpenDependencies returns the dependencies of t that are not done or cancelled (missing IDs count as open).
func ReviewPass ¶
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
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
Slop scans the given paths, or else the files changed on this branch (aitk metadata excluded).
func SwitchAllowed ¶ added in v2.11.0
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
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 TaskUpdate ¶
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
TrackedFiles lists tracked and untracked (not ignored) files, for a whole-repository scan.
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.
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.
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 GoalStatus ¶ added in v2.2.0
GoalStatus changes a goal's status.
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
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
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.
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
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 ¶
BuildReport aggregates tasks and handoffs updated since `since`.
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
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
Shortcut is one deliberate limit recorded in code as "shortcut: <the limit>, <when to upgrade>".
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.
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.
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.