plan

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Mar 18, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AtomicWriteFile added in v0.2.0

func AtomicWriteFile(path string, data []byte) error

AtomicWriteFile writes data to path using a temp file + rename.

func BranchExists

func BranchExists(branchName string) bool

BranchExists checks if a git branch exists.

func CreateBackup added in v0.2.0

func CreateBackup(path string) error

CreateBackup copies the file at path to plans/.backup in the same directory.

func CurrentBranch

func CurrentBranch() (string, error)

CurrentBranch returns the current git branch name.

func CurrentFile

func CurrentFile() (string, error)

CurrentFile returns the path to the .current file that tracks the active plan.

func GenerateTemplate added in v0.2.0

func GenerateTemplate(name, goal string) []byte

GenerateTemplate creates a new plan Markdown file with the given name and goal.

func GetCurrent

func GetCurrent() (string, error)

GetCurrent reads the current plan name from plans/.current. Returns empty string if no current plan is set.

func GitRoot

func GitRoot() (string, error)

GitRoot walks up from cwd to find the directory containing .git/.

func ListPlans

func ListPlans() ([]string, error)

ListPlans returns all plan file slugs in the plans/ directory.

func NameToBranch

func NameToBranch(name string) string

NameToBranch converts a plan name to a branch name.

func NameToFilename

func NameToFilename(name string) string

NameToFilename converts a plan name to a filename slug.

func ParseTitle added in v0.2.0

func ParseTitle(data []byte) string

ParseTitle extracts the first # heading from the data.

func PlansDir

func PlansDir() (string, error)

PlansDir returns the plans/ directory path at the git root.

func ResolveCurrentPlan

func ResolveCurrentPlan(name string) (string, error)

ResolveCurrentPlan figures out which plan to use: 1. If a name is given, use that 2. If plans/.current exists, use that 3. If only one plan exists, use that Returns the plan name or error.

func ResolvePlanPath

func ResolvePlanPath(name string) (string, error)

ResolvePlanPath returns the full path to a named plan file.

func SetCurrent

func SetCurrent(name string) error

SetCurrent writes the current plan name to plans/.current.

func SetSubTaskDone added in v0.2.0

func SetSubTaskDone(data []byte, ref string) ([]byte, error)

SetSubTaskDone marks a sub-task as done by reference (e.g. "1.1"). It finds the indented line matching "- [ ] 1.1." under ## Tasks and flips [ ] → [x].

func SetTaskBlocked added in v0.2.0

func SetTaskBlocked(data []byte, taskNum int, reason string) ([]byte, error)

SetTaskBlocked marks a task with a [blocked] annotation. taskNum is 1-based.

func SetTaskDone added in v0.2.0

func SetTaskDone(data []byte, taskNum int) ([]byte, error)

SetTaskDone marks a task as done by flipping [ ] → [x]. taskNum is 1-based.

func SlugToTitle added in v0.2.0

func SlugToTitle(slug string) string

SlugToTitle converts a filename slug to a title. "deploy-pipeline" → "Deploy Pipeline"

func SwitchBranch

func SwitchBranch(branchName string) error

SwitchBranch switches to an existing git branch.

Types

type PlanStatus added in v0.2.0

type PlanStatus struct {
	Name      string
	FilePath  string
	Tasks     []TaskInfo
	DoneCount int
	Total     int
}

PlanStatus holds parsed status information for a plan file.

func ParsePlanStatus added in v0.2.0

func ParsePlanStatus(path string) (*PlanStatus, error)

ParsePlanStatus reads a plan file and returns its status.

type TaskInfo added in v0.2.0

type TaskInfo struct {
	Index   int    // 1-based task number
	Text    string // Full text of the task line (after checkbox)
	Done    bool   // true if [x] or [X]
	Blocked bool   // true if text contains "[blocked]" marker
	LineNum int    // 0-based line number in the file
}

TaskInfo holds parsed info about a top-level task under ## Tasks.

func ParseTasks added in v0.2.0

func ParseTasks(data []byte) []TaskInfo

ParseTasks finds the ## Tasks section and parses top-level checkboxes. Only top-level items (lines starting with "- [ ]" or "- [x]") are parsed. Sub-items (indented lines) are ignored.

Jump to

Keyboard shortcuts

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