storage

package
v0.0.7 Latest Latest
Warning

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

Go to latest
Published: Jul 16, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SourceAuto   = "auto"
	SourceManual = "manual"
	SourceScan   = "scan"
)

Variables

This section is empty.

Functions

func AppendEvent

func AppendEvent(wrkHome string, ev Event) error

AppendEvent appends one JSON line to events.jsonl.

func AutoRecord

func AutoRecord(wrkHome, workDir string) (string, error)

AutoRecord records the main repo for workDir with source "auto" when git resolves successfully.

func FindProjectsByBasename

func FindProjectsByBasename(wrkHome, basename string) ([]string, error)

FindProjectsByBasename returns saved project paths whose final path component equals basename, sorted lexicographically.

func ListProjects

func ListProjects(wrkHome string) ([]string, error)

ListProjects returns recorded project paths sorted lexicographically.

func NormalizePath

func NormalizePath(path string) string

NormalizePath returns an absolute path, resolving symlinks when possible.

func RecordProject

func RecordProject(wrkHome, path, source string) error

RecordProject appends a project when absent. Re-adding is idempotent; the first recorded source wins.

func RemoveProject

func RemoveProject(wrkHome, path string) (bool, error)

RemoveProject deletes the project entry matching normalized path. Returns true when an entry was removed, false when no matching entry exists.

func ResetEventsIfDoctest

func ResetEventsIfDoctest(wrkHome string) error

ResetEventsIfDoctest truncates events.jsonl when DOCTEST_SESSION_ID is set so doctest assertions observe only the current invocation's event.

func ResolveMainRepoForWorkDir

func ResolveMainRepoForWorkDir(workDir string) (string, bool)

ResolveMainRepoForWorkDir returns the main repo for workDir when it exists and is inside a git work tree.

func SaveProjects

func SaveProjects(wrkHome string, pf ProjectsFile) error

SaveProjects writes projects.json under wrkHome.

Types

type Event

type Event struct {
	TS       string   `json:"ts"`
	Command  string   `json:"command"`
	WorkDir  string   `json:"work_dir"`
	MainRepo string   `json:"main_repo"`
	Args     []string `json:"args"`
	ExitCode int      `json:"exit_code"`
}

Event is one append-only events.jsonl record.

type Project

type Project struct {
	Path    string `json:"path"`
	AddedAt string `json:"added_at"`
	Source  string `json:"source"`
}

Project is one recorded main repository entry.

type ProjectsFile

type ProjectsFile struct {
	Version  int       `json:"version"`
	Projects []Project `json:"projects"`
}

ProjectsFile is the on-disk projects.json schema.

func LoadProjects

func LoadProjects(wrkHome string) (ProjectsFile, error)

LoadProjects reads projects.json, returning an empty file when absent.

Jump to

Keyboard shortcuts

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