project

package
v1.54.0 Latest Latest
Warning

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

Go to latest
Published: Aug 22, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package project manages project directories under a configured root.

Index

Constants

This section is empty.

Variables

View Source
var ErrExists = errors.New("A project with that name already exists.")

ErrExists is what Create answers for a name whose directory already holds content. It is a sentinel so a caller can tell the taken name apart from a name that cannot be used at all.

Functions

This section is empty.

Types

type CoderRef

type CoderRef struct {
	ID       string
	Name     string
	Coder    string    // owning coder id, for the badge when several coders run
	At       time.Time // started (active) or last updated (inactive); for date sorting
	TabPos   int       // tab strip position from @dc_tab_pos, 0 when unset (active only)
	Group    string    // split view group id from @dc_tab_group, empty when ungrouped
	GroupPos int       // position inside the group from @dc_tab_gpos, 0 when unset
	HasNews  bool      // an unread notification points at this coder
}

type Project

type Project struct {
	Name              string
	Root              string
	Path              string
	Label             string
	GitBranch         string
	GitOrigin         string
	GitOriginURL      string
	GitRepo           bool
	ActiveCoders      int
	InactiveCoders    int
	ActiveCoderRefs   []CoderRef
	InactiveCoderRefs []CoderRef
	ShellRefs         []ShellRef
	ActiveRefs        []TerminalRef // coders and shells merged in tab strip order
	LastUsedUnix      int64         // last time the project was opened; 0 = never
	HasNews           bool          // any coder or shell below has an unread notification
}

Project is one project directory.

type Repository

type Repository struct {
	Root string
	// contains filtered or unexported fields
}

Repository wraps the on-disk projects root.

func NewRepository

func NewRepository(root string, store *recent.Store) *Repository

NewRepository creates a Repository for the given root directory. The store records and supplies per-project last-used timestamps.

func (*Repository) Create

func (r *Repository) Create(rawName string) (string, error)

Create makes a new project directory under the root. A directory that already exists but is empty is adopted and answered like a fresh one, a leftover of an earlier attempt is a place to fill and not a refusal; anything with content in it, and anything that is not a plain directory, is somebody's data and answers ErrExists.

func (*Repository) DefaultPath

func (r *Repository) DefaultPath() string

DefaultPath returns the first selectable project (for new-session defaults).

func (*Repository) EnsureRoot

func (r *Repository) EnsureRoot() (string, error)

EnsureRoot creates the root if missing and returns its resolved path.

func (*Repository) Find

func (r *Repository) Find(raw string) (Project, error)

Find resolves a project from a raw path.

func (*Repository) FindByName

func (r *Repository) FindByName(raw string) (Project, error)

FindByName resolves a project from its directory name under the configured root.

func (*Repository) Label

func (r *Repository) Label(path string) string

Label returns a short user-facing label (path relative to root when possible).

func (*Repository) List

func (r *Repository) List() []Project

List returns all selectable projects as Project records.

func (*Repository) ProjectNameFor

func (r *Repository) ProjectNameFor(cwd string) string

ProjectNameFor returns the name of the top-level project that cwd lives under, or "" when cwd is outside the projects root. Unlike Find it accepts arbitrary subdirectories, so a session or shell working deep inside a project still maps back to it. It is cheap: it only inspects the path and reads no git metadata, so it is safe to call per entry in list/quick-nav views.

func (*Repository) Remove

func (r *Repository) Remove(p Project) error

Remove deletes a project directory. The caller is responsible for checking session conflicts first.

func (*Repository) SelectablePaths

func (r *Repository) SelectablePaths() []string

SelectablePaths returns absolute project directory paths suitable as session working directories.

func (*Repository) Touch

func (r *Repository) Touch(name string)

Touch records that the named project was just opened.

func (*Repository) ValidatePath

func (r *Repository) ValidatePath(raw string) (string, error)

ValidatePath checks that raw is a non-symlink project directly under the root.

type ShellRef

type ShellRef struct {
	ID       string
	Name     string
	At       time.Time // started; tiebreak for the tab order sort
	TabPos   int       // tab strip position from @dc_tab_pos, 0 when unset
	Group    string    // split view group id from @dc_tab_group, empty when ungrouped
	GroupPos int       // position inside the group from @dc_tab_gpos, 0 when unset
	HasNews  bool      // an unread notification points at this shell
}

type TerminalRef

type TerminalRef struct {
	ID      string
	Name    string
	Kind    string // "coder" or "shell"
	Coder   string // owning coder id when Kind is "coder"
	HasNews bool
}

TerminalRef is one live coder or shell of a project, merged into the tab strip order for the projects page chip row.

Jump to

Keyboard shortcuts

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