projects

package
v0.0.10 Latest Latest
Warning

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

Go to latest
Published: Oct 7, 2026 License: AGPL-3.0 Imports: 6 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package projects makes a project a first-class entity rather than a name that happens to appear on some tasks.

Before this package a "project" was one Markdown file under projects/. Tasks carried a project name, the queue could filter on it, and that was the whole model: there was no record of what a project is, no directory where its work happens, and no notion of the one you are currently in — so every ask had to name it again, and a task delegated to another machine arrived carrying a name that machine had never heard of.

Two things live here. The metadata (name, work dir, description, timestamps) is what makes a project addressable and portable; the work dir in particular is the tree a task runs in and therefore the tree that travels with a delegation. And the active-project pointer, which has to be on disk rather than in memory because `panda ask` is a one-shot process: a pointer held in RAM would be forgotten between two consecutive commands.

The project's *memory* stays where it was, in internal/memory.Projects — this package deliberately does not own it. The isolation wall (design §17.2) is structural, and moving project memory behind a store that also knows about work directories and active state would be the first crack in it.

Index

Constants

View Source
const (
	ScopeOnce    = "once"
	ScopeSession = "session"
	ScopeProject = "project"
)

Approval remember scopes: where an approval card's "remember" writes the answer it was given. Once applies the answer to that prompt only.

View Source
const (
	DecisionApprove = "approve"
	DecisionDeny    = "deny"
)

Approval decision values: the remembered answer the tier-2 gate replays.

Variables

View Source
var ErrExists = errors.New("projects: project already exists")

ErrExists reports a create/rename onto a name already taken.

View Source
var ErrNotFound = errors.New("projects: no such project")

ErrNotFound reports a project name that is not in the table.

Functions

func ValidateApprovalDecision added in v0.0.9

func ValidateApprovalDecision(decision string) error

ValidateApprovalDecision rejects a remembered answer outside approve|deny.

func ValidateApprovalMode added in v0.0.9

func ValidateApprovalMode(mode string) error

ValidateApprovalMode rejects a project approval mode outside the understood set. "" means "inherit the global gate" and is always legal; the alias words config accepts (strict/auto) are legal here too so a policy can be written in the vocabulary the config file already uses — the engine normalizes either way. Anything else is a typo that must not silently degrade to on-request.

func ValidateApprovalScope added in v0.0.9

func ValidateApprovalScope(scope string) error

ValidateApprovalScope rejects a remember-scope outside once|session|project.

func ValidateName

func ValidateName(name string) error

ValidateName rejects names that cannot be used as a path segment or a wire value. A project name reaches the filesystem (its memory file), the bus (the delegation payload) and the CLI (as an argument), so the safe set is the intersection of all three rather than whatever SQLite would accept.

Types

type Project

type Project struct {
	Name        string    `json:"name"`
	WorkDir     string    `json:"work_dir,omitempty"`
	Description string    `json:"description,omitempty"`
	CreatedAt   time.Time `json:"created_at"`
	UpdatedAt   time.Time `json:"updated_at"`
	// ApprovalMode is a project-scoped override of the node's approval.mode
	// gate (always|on-request|never); empty inherits the global policy.
	ApprovalMode string `json:"approval_mode,omitempty"`
	// ApprovalScope picks where the "remember" choice on an approval card
	// writes its answer by default (once|session|project); empty reads as
	// session — narrower than the project row itself.
	ApprovalScope string `json:"approval_scope,omitempty"`
	// ApprovalDecision is the remembered project-level answer (approve|deny)
	// the gate replays instead of prompting again; empty remembers nothing.
	ApprovalDecision string `json:"approval_decision,omitempty"`
}

Project is one project's metadata. WorkDir is absolute when set; empty means the project has no tree of its own and its tasks run in the node's work directory, which is how a memory-only project (every project that existed before this table) keeps working.

func (Project) NormalizedScope added in v0.0.9

func (p Project) NormalizedScope() string

NormalizedScope reads the configured remember-scope, defaulting to session: a project that never picked one remembers approvals for the conversation it was granted in — a default narrower than persisting onto the project row.

type Store

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

Store is the projects table plus the settings row that names the active one.

func NewStore

func NewStore(db *sql.DB) *Store

NewStore wraps an already-migrated database.

func (*Store) Active

func (s *Store) Active() (string, error)

Active returns the current project's name, or "" when none is set. A pointer at a project that has since been deleted reads as "" rather than as an error: the caller's next question is always "which project am I in", and "none" is the honest answer.

func (*Store) ClearActive

func (s *Store) ClearActive() error

ClearActive leaves whatever project was current. Idempotent: leaving when you are not in a project is not an error, it is already true.

func (*Store) Create

func (s *Store) Create(name, workDir, description string) (Project, error)

Create inserts a project. workDir is resolved to an absolute path so a project created from one directory still points at the same tree when a task runs from another — the daemon's cwd is not the cwd of whoever typed the command.

func (*Store) Delete

func (s *Store) Delete(name string) error

Delete removes a project's metadata and clears the active pointer when it named this one. It does not touch the work directory: deleting a project is an act of bookkeeping, and silently removing a tree the user pointed at would be the one irreversible thing in this package.

func (*Store) EnsureFromName

func (s *Store) EnsureFromName(name string) (Project, error)

EnsureFromName creates a metadata row for a project that only ever existed as a memory file. Projects predate this table, so a name that appears on a task or in projects/<name>/ must still resolve to a project; this is the adoption path, and it is idempotent.

func (*Store) FindByWorkDir

func (s *Store) FindByWorkDir(dir string) (Project, error)

FindByWorkDir looks up the first project pointing at the given work directory.

func (*Store) Get

func (s *Store) Get(name string) (Project, error)

Get reads one project.

func (*Store) List

func (s *Store) List() ([]Project, error)

List returns every project, newest activity first.

func (*Store) Rename

func (s *Store) Rename(oldName, newName string) (Project, error)

Rename moves a project to a new name, carrying the active pointer with it. The two writes are one transaction: a rename that renamed the row but left the pointer behind would leave the user "inside" a project that no longer exists.

The caller is responsible for the project's memory file and for any tasks that reference the old name — renaming is metadata here, and the CLI wires the rest.

func (*Store) SetActive

func (s *Store) SetActive(name string) error

SetActive points at a project, which must exist — entering a project that was never created would make every later "which project am I in" answer a lie.

func (*Store) SetApprovalDecision added in v0.0.9

func (s *Store) SetApprovalDecision(name, decision string) error

SetApprovalDecision writes the remembered project-level approval answer — approve|deny, or "" to forget. This is the write the "remember" choice on an approval card lands when its scope is project.

func (*Store) SetApprovalPolicy added in v0.0.9

func (s *Store) SetApprovalPolicy(name, mode, scope string) error

SetApprovalPolicy writes a project's approval overrides. mode is always|on-request|never (or the config's alias spellings); "" inherits the global gate. scope is once|session|project; "" restores the session default. Unknown values are rejected rather than normalized away — a typo'd policy silently reading as a different mode is how gates open by accident. The project is adopted when it only exists as a memory file, matching every other path that resolves a name to a project.

func (*Store) Touch

func (s *Store) Touch(name string) error

Touch moves a project's updated_at, which is what orders `panda project list`. Called when work happens in a project rather than when its row is edited, so the list reads as "what I have been working on".

func (*Store) Update

func (s *Store) Update(name, workDir, description string) (Project, error)

Update rewrites a project's work dir and description. An empty string clears the field, which is how a project gives up its tree.

Jump to

Keyboard shortcuts

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