project

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Mar 26, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNotInProjectPath = errors.New("not in a registered project path")
View Source
var ErrProjectExists = errors.New("project already exists")
View Source
var ErrProjectHandleNotInitialized = errors.New("project handle not initialized")
View Source
var ErrProjectNotFound = errors.New("project not found")
View Source
var ErrProjectNotRegistered = errors.New("project root is not registered")
View Source
var ErrWorktreeExists = errors.New("worktree already exists for branch")
View Source
var ErrWorktreeNotFound = errors.New("worktree not found")

Functions

func NewWorktreeDirProvider added in v0.2.0

func NewWorktreeDirProvider(log *logger.Logger, cfg config.Config, projectRoot string) git.WorktreeDirProvider

NewWorktreeDirProvider creates a WorktreeDirProvider for the given project. It looks up the project in the registry to populate known worktree paths, enabling path reuse for existing worktrees and UUID-based generation for new ones. External callers (e.g. container/shared) use this instead of the full project service.

Types

type GitManagerFactory added in v0.2.0

type GitManagerFactory func(projectRoot string) (*git.GitManager, error)

GitManagerFactory creates a git.GitManager for the given project root. Production callers pass git.NewGitManager; tests pass a factory returning gittest.InMemoryGitManager.GitManager.

type Project added in v0.2.0

type Project interface {
	Name() string
	RepoPath() string
	Record() (ProjectRecord, error)
	CreateWorktree(ctx context.Context, branch, base string) (string, error)
	AddWorktree(ctx context.Context, branch, base string) (WorktreeState, error)
	RemoveWorktree(ctx context.Context, branch string, deleteBranch bool) error
	PruneStaleWorktrees(ctx context.Context, dryRun bool) (*PruneStaleResult, error)
	ListWorktrees(ctx context.Context) ([]WorktreeState, error)
	GetWorktree(ctx context.Context, branch string) (WorktreeState, error)
}

Project is the runtime behavior contract for a single registered project. The concrete implementation is package-private.

type ProjectManager added in v0.2.0

type ProjectManager interface {
	Register(ctx context.Context, name string, repoPath string) (Project, error)
	Update(ctx context.Context, entry config.ProjectEntry) (Project, error)
	List(ctx context.Context) ([]config.ProjectEntry, error)
	ListProjects(ctx context.Context) ([]ProjectState, error)
	Remove(ctx context.Context, root string) error
	Get(ctx context.Context, root string) (Project, error)
	ResolvePath(ctx context.Context, cwd string) (Project, error)
	CurrentProject(ctx context.Context) (Project, error)
	ListWorktrees(ctx context.Context) ([]WorktreeState, error)
}

func NewProjectManager added in v0.2.0

func NewProjectManager(cfg config.Config, log *logger.Logger, gitFactory GitManagerFactory) (ProjectManager, error)

type ProjectRecord added in v0.2.0

type ProjectRecord struct {
	Name      string
	Root      string
	Worktrees map[string]WorktreeRecord
}

ProjectRecord is the persisted model for a registered project.

type ProjectState added in v0.4.0

type ProjectState struct {
	Name      string
	Root      string
	Worktrees []WorktreeState
	Status    ProjectStatus
	StatusErr error // non-nil when Status is ProjectInaccessible
}

ProjectState is a caller-facing enriched project view. Analogous to WorktreeState: combines registry data with runtime checks.

type ProjectStatus added in v0.4.0

type ProjectStatus string

ProjectStatus captures the health of a project's root directory.

const (
	ProjectOK           ProjectStatus = "ok"
	ProjectMissing      ProjectStatus = "missing"
	ProjectInaccessible ProjectStatus = "inaccessible"
)

type PruneStaleResult added in v0.2.0

type PruneStaleResult struct {
	Prunable []string
	Removed  []string
	Failed   map[string]error
	Locked   []string // worktrees skipped due to git worktree lock
}

type WorktreeRecord added in v0.2.0

type WorktreeRecord struct {
	Path   string
	Branch string
}

WorktreeRecord is the persisted model for a project worktree.

type WorktreeState added in v0.2.0

type WorktreeState struct {
	Project          string
	Branch           string
	Path             string
	Head             string
	IsDetached       bool
	ExistsInRegistry bool
	ExistsInGit      bool
	Status           WorktreeStatus
	IsLocked         bool  // worktree is locked against pruning (.git/worktrees/<slug>/locked exists)
	InspectError     error // non-nil indicates degraded health check (permissions, git errors)
}

WorktreeState is a caller-facing merged worktree view.

type WorktreeStatus added in v0.2.0

type WorktreeStatus string

WorktreeStatus captures the health/drift status of a worktree.

const (
	WorktreeHealthy            WorktreeStatus = "healthy"
	WorktreeRegistryOnly       WorktreeStatus = "registry_only"
	WorktreeGitOnly            WorktreeStatus = "git_only"
	WorktreeBroken             WorktreeStatus = "broken"
	WorktreeDotGitMissing      WorktreeStatus = "dotgit_missing"
	WorktreeGitMetadataMissing WorktreeStatus = "git_metadata_missing"
)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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