projects

package
v0.2.16 Latest Latest
Warning

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

Go to latest
Published: Jul 17, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package projects discovers project roots under configured scan roots and tracks which ones the user keeps visible. Discovery is depth-1: a direct child of a scan root that contains one of the configured marker paths (default .docs/ai) is a project. Enabled/disabled state lives in an app-owned JSON file (projects.json); newly discovered projects are enabled by default, so the user unchecks to hide rather than checks to show.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func StatePath

func StatePath() string

StatePath is the default location of the project-state file. It sits beside the config file — config.Dir() already resolves the HARNESS_DECK_CONFIG override and $XDG_CONFIG_HOME, so state and config always move together (handy for the fixture-based manual test setup).

Types

type Manager

type Manager struct {
	// contains filtered or unexported fields
}

Manager discovers projects and persists which ones are hidden.

func NewManager

func NewManager(scanRoots, explicit, markers []string, statePath string) *Manager

NewManager builds a Manager. scanRoots are directories scanned depth-1 for projects; explicit are project roots included unconditionally; markers are the paths whose presence marks a child as a project (empty means the .docs/ai default); statePath is the JSON file recording hidden projects.

func (*Manager) Discovered

func (m *Manager) Discovered() []Project

Discovered returns every project found, sorted by name, with Enabled reflecting the persisted hidden set.

func (*Manager) Enabled

func (m *Manager) Enabled() []Project

Enabled returns only the projects the user has left visible.

func (*Manager) Fingerprint

func (m *Manager) Fingerprint() string

Fingerprint is a digest of discovered projects, their visibility, and the size and mtime of each project's .docs/ai docs. The watcher compares it between polls to decide when to push an SSE refresh.

func (*Manager) Reorder added in v0.1.3

func (m *Manager) Reorder(names []string) error

Reorder records the user's preferred display order for discovered projects and persists it. Every name must match a currently discovered project so stale browser state can't smuggle ghost entries into the order. The hidden set is preserved untouched — visibility and order are independent.

func (*Manager) SetRoots added in v0.2.7

func (m *Manager) SetRoots(scanRoots, explicit, markers []string)

SetRoots replaces the discovery roots and markers — used when config.json changes at runtime (e.g. `harness-deck register` added a project) so the watcher picks up the new roots without a restart. The next Discovered/Enabled recomputes against them. Safe for concurrent use; copies the inputs so a later mutation of the caller's slices can't alias the Manager's state.

func (*Manager) Toggle

func (m *Manager) Toggle(name string) error

Toggle flips the visibility of a discovered project and persists the change. It returns an error if name is not a discovered project.

type Project

type Project struct {
	Name    string `json:"name"`    // display name (directory basename; disambiguated with a parent-dir hint on collision) — also the persistence key
	Path    string `json:"path"`    // absolute path to the project root
	Enabled bool   `json:"enabled"` // false when the user has hidden it
}

Project is one discovered project root.

Jump to

Keyboard shortcuts

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