plan

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Mar 16, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BranchExists

func BranchExists(branchName string) bool

BranchExists checks if a git branch exists.

func BranchToFilename

func BranchToFilename(branch string) string

Legacy support

func CreateBranch

func CreateBranch(branchName string) error

CreateBranch creates a new git branch with the given name and switches to it.

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 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 files 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 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 current branch matches a plan's branch field, use that 4. If only one active 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 Serialize

func Serialize(p *Plan, notes string) ([]byte, error)

Serialize converts a Plan and notes string into the file format: ---\n<yaml>\n---\n<rendered markdown>

func SetCurrent

func SetCurrent(name string) error

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

func SwitchBranch

func SwitchBranch(branchName string) error

SwitchBranch switches to an existing git branch.

func WriteFile

func WriteFile(path string, p *Plan, notes string) error

WriteFile atomically writes a plan to disk. It creates a backup of the existing file (if any) at .plans/.backup before writing.

Types

type Context

type Context struct {
	CurrentFile     NullableString `yaml:"current_file"`
	LastError       NullableString `yaml:"last_error"`
	TestState       NullableString `yaml:"test_state"`
	OpenQuestions   NullableString `yaml:"open_questions"`
	PendingRefactor NullableString `yaml:"pending_refactor"`
}

Context holds session state fields.

type Decision

type Decision struct {
	Time time.Time `yaml:"time"`
	Text string    `yaml:"text"`
}

Decision represents a timestamped decision.

type FileRef

type FileRef struct {
	Path string `yaml:"path"`
	Role string `yaml:"role"`
}

FileRef is a project-level file reference with its role.

type NullableString

type NullableString string

NullableString is a string that marshals to YAML ~ when empty.

func (NullableString) MarshalYAML

func (n NullableString) MarshalYAML() (interface{}, error)

func (*NullableString) UnmarshalYAML

func (n *NullableString) UnmarshalYAML(value *yaml.Node) error

type Plan

type Plan struct {
	Name         string     `yaml:"name"`
	Goal         string     `yaml:"goal"`
	Diagram      string     `yaml:"diagram,omitempty"` // optional — Mermaid diagram source
	Branch       string     `yaml:"branch,omitempty"`  // optional — associated git branch
	Status       string     `yaml:"status"`            // active, complete
	SessionCount int        `yaml:"session_count"`
	Created      string     `yaml:"created"` // date string YYYY-MM-DD
	Updated      string     `yaml:"updated"` // date string YYYY-MM-DD
	CurrentTask  int        `yaml:"current_task"`
	Constraints  []string   `yaml:"constraints,omitempty"` // global rules for the agent
	PlanFiles    []FileRef  `yaml:"files,omitempty"`       // key project files
	Tasks        []Task     `yaml:"tasks"`
	Context      Context    `yaml:"context"`
	Decisions    []Decision `yaml:"decisions"`
}

Plan is the complete plan state, stored as YAML frontmatter.

func Parse

func Parse(data []byte) (*Plan, string, error)

Parse splits a plan file into YAML frontmatter and freeform notes, then unmarshals the frontmatter into a Plan struct.

func ReadFile

func ReadFile(path string) (*Plan, string, error)

ReadFile reads a plan file from disk and parses it.

type Task

type Task struct {
	Text   string   `yaml:"text"`
	Status string   `yaml:"status"`           // todo, active, done, blocked
	Reason string   `yaml:"reason,omitempty"` // only set when status=blocked
	Spec   string   `yaml:"spec,omitempty"`   // implementation instructions
	Verify []string `yaml:"verify,omitempty"` // verification steps
	Files  []string `yaml:"files,omitempty"`  // files this task touches
}

Task represents a single task in the plan.

Jump to

Keyboard shortcuts

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