Documentation
¶
Index ¶
- func CleanupStaleTasks()
- func ConfigPath() string
- func CountProgressSteps(steps []ProgressStep) (done, total int)
- func Dir(name string) string
- func EnsureOwnProcessGroup()
- func EscapeName(name string) string
- func EscapePath(p string) string
- func GitRootAbs() (string, error)
- func GlobalDir() string
- func HistoryPath(name string) string
- func IndexPath() string
- func InternalDir() string
- func List() ([]string, error)
- func Path(name string) string
- func ProjectConfigPath() string
- func ProjectDir() string
- func ProjectDirAbs() string
- func ProjectRoot() string
- func ProjectsDir() string
- func SelfProcessGroupID() int
- func StatePath(name string) string
- func TasksDir() string
- func TryWithLock(taskName string, fn func() error) (bool, error)
- func UnescapeName(escaped string) string
- func WithLock(taskName string, fn func() error) error
- func WorkspacesDir() string
- type ConversationEvent
- type ConversationHeader
- type ConversationItem
- type ConversationMessage
- type ConversationRole
- type Progress
- type ProgressStep
- type State
- type Task
- type TaskStatus
- type UserStatus
- type WorkerStatus
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CleanupStaleTasks ¶
func CleanupStaleTasks()
CleanupStaleTasks clears stale supervisor PIDs and records an error. Should be called before any workspace-acquiring operation.
func ConfigPath ¶
func ConfigPath() string
ConfigPath returns ~/.subtask/config.json (global defaults).
func CountProgressSteps ¶
func CountProgressSteps(steps []ProgressStep) (done, total int)
CountProgressSteps returns (done,total) for a set of steps.
func EnsureOwnProcessGroup ¶
func EnsureOwnProcessGroup()
EnsureOwnProcessGroup puts the current process into its own process group (PGID == PID) so that interrupts can safely target the group without affecting unrelated processes.
Best-effort: if it fails, callers should fall back to PID-only signaling.
func EscapeName ¶
EscapeName converts "fix/epoch-boundary" to "fix--epoch-boundary".
func EscapePath ¶
EscapePath converts a path to a safe directory name. It resolves symlinks first to ensure consistency across different cwd resolutions.
func GitRootAbs ¶ added in v0.2.0
GitRootAbs returns the git project root (worktree-aware).
func IndexPath ¶ added in v0.2.0
func IndexPath() string
IndexPath returns the default index db path for this repo: ~/.subtask/projects/<escaped-git-root>/index.db
If not in git, falls back to .subtask/index.db (legacy behavior).
func InternalDir ¶
func InternalDir() string
InternalDir returns the runtime internal directory for this repo: ~/.subtask/projects/<escaped-git-root>/internal
If not in git, falls back to <cwd>/.subtask/internal (legacy behavior).
func ProjectConfigPath ¶ added in v0.2.0
func ProjectConfigPath() string
ProjectConfigPath returns the optional project override config path (<git-root>/.subtask/config.json), expressed relative to cwd when possible.
func ProjectDir ¶
func ProjectDir() string
ProjectDir returns .subtask relative to cwd (anchored at git root).
func ProjectDirAbs ¶
func ProjectDirAbs() string
ProjectDirAbs returns the absolute path to the project's .subtask directory. If not in git, it returns "<cwd>/.subtask".
func ProjectRoot ¶
func ProjectRoot() string
ProjectRoot returns the absolute path to the git project root. If not in git, it returns the current working directory.
func ProjectsDir ¶ added in v0.2.0
func ProjectsDir() string
ProjectsDir returns ~/.subtask/projects.
func SelfProcessGroupID ¶
func SelfProcessGroupID() int
SelfProcessGroupID returns the current process group ID, or 0 if unknown.
func TryWithLock ¶
TryWithLock attempts to acquire an exclusive per-task lock without blocking. If the lock is already held by another process, it returns (false, nil).
func UnescapeName ¶
UnescapeName converts "fix--epoch-boundary" to "fix/epoch-boundary".
Types ¶
type ConversationEvent ¶
ConversationEvent represents a lifecycle event (task opened, stage changed, etc.).
type ConversationHeader ¶
ConversationHeader is derived metadata about a task's activity history. It is populated from history events (e.g. worker.session).
type ConversationItem ¶
type ConversationItem struct {
IsEvent bool
Message ConversationMessage
Event ConversationEvent
}
ConversationItem represents either a message or a lifecycle event in the timeline.
type ConversationMessage ¶
type ConversationMessage struct {
Role ConversationRole
Body string
Time time.Time
}
type ConversationRole ¶
type ConversationRole string
const ( ConversationRoleLead ConversationRole = "lead" ConversationRoleWorker ConversationRole = "worker" )
type Progress ¶
type Progress struct {
ToolCalls int `json:"tool_calls,omitempty"`
LastActive time.Time `json:"last_activity,omitempty"`
}
Progress is frequently-updated, informational task metadata. It is intentionally separated from State to avoid clobbering state transitions.
func LoadProgress ¶
LoadProgress reads progress from .subtask/internal/<task>/progress.json.
type ProgressStep ¶
ProgressStep represents a step in PROGRESS.json (task folder).
func LoadProgressSteps ¶
func LoadProgressSteps(taskName string) []ProgressStep
LoadProgressSteps reads .subtask/tasks/<task>/PROGRESS.json.
This is best-effort and returns nil on missing/invalid files, matching the CLI's historical behavior (progress is informational).
type State ¶
type State struct {
Workspace string `json:"workspace,omitempty"` // absolute local path
SessionID string `json:"session_id,omitempty"` // current session
Harness string `json:"harness,omitempty"` // current session harness
SupervisorPID int `json:"supervisor_pid,omitempty"` // current run supervisor PID
SupervisorPGID int `json:"supervisor_pgid,omitempty"` // current run supervisor process group ID (unix)
StartedAt time.Time `json:"started_at,omitempty"` // current run start (UTC)
LastError string `json:"last_error,omitempty"` // current/last run error
}
State is local, runtime-only state for a task.
This file is intentionally NOT syncable: it contains machine-specific details (workspace path) and ephemeral execution state (PIDs).
type Task ¶
type Task struct {
Name string // Task name (e.g., "fix/epoch-boundary")
Title string // Short description
BaseBranch string // Branch to fork from
FollowUp string // Optional: task whose conversation to continue
Model string // Optional: override model for this task
Reasoning string // Optional: override reasoning (codex-only) for this task
Schema int // Task schema version (0 if missing)
Description string // Optional task description/context (not the prompt)
}
Task represents a task definition from TASK.md.
type TaskStatus ¶
type TaskStatus string
TaskStatus is the durable, syncable status of a task (stored in history.jsonl).
const ( TaskStatusOpen TaskStatus = "open" TaskStatusMerged TaskStatus = "merged" TaskStatusClosed TaskStatus = "closed" )
type UserStatus ¶
type UserStatus string
UserStatus is the simplified status shown to users (derived from task+worker state).
const ( UserStatusDraft UserStatus = "draft" // open, worker never started UserStatusRunning UserStatus = "working" UserStatusReplied UserStatus = "replied" UserStatusError UserStatus = "error" UserStatusMerged UserStatus = "merged" UserStatusClosed UserStatus = "closed" )
func UserStatusFor ¶
func UserStatusFor(ts TaskStatus, ws WorkerStatus) UserStatus
UserStatusFor derives the user-visible status from the internal task+worker state.
type WorkerStatus ¶
type WorkerStatus string
WorkerStatus is the ephemeral status of the local worker process.
const ( // WorkerStatusNotStarted means the worker has never been invoked for this task yet. // This is represented as the empty string so it can be omitted easily in UIs. WorkerStatusNotStarted WorkerStatus = "" // WorkerStatusRunning means the worker is currently executing. // // Note: this used to be serialized as "running". We now use "working" but // accept both on read for backwards compatibility. WorkerStatusRunning WorkerStatus = "working" WorkerStatusReplied WorkerStatus = "replied" WorkerStatusError WorkerStatus = "error" )
func NormalizeWorkerStatus ¶
func NormalizeWorkerStatus(ws WorkerStatus) WorkerStatus
NormalizeWorkerStatus maps legacy serialized values to their current equivalents.
func ParseWorkerStatus ¶
func ParseWorkerStatus(s string) WorkerStatus