project

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Aug 14, 2026 License: MIT Imports: 19 Imported by: 0

Documentation

Overview

Package project orchestrates the multi-step use cases behind lore's project subcommands. It composes the domain modules so command adapters stay thin.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func OfferPullGitignoreFixes

func OfferPullGitignoreFixes(result *PullResult)

OfferPullGitignoreFixes offers the existing picker for unignored copies.

func Path

func Path(projectName, dirName string) (string, error)

Path returns the absolute on-disk path of an agent directory tracked for projectName inside the central repo. When dirName is empty: returns the single tracked dir's path, or CodeConflict if the project has multiple. When dirName is non-empty: validates against the tracked set and returns CodeNotFound if the named dir isn't tracked.

func PathRepo

func PathRepo() (string, error)

PathRepo returns the absolute path of the central repo.

func ValidateProjectName

func ValidateProjectName(name, source string) error

ValidateProjectName checks name against the strict-slug rule. source describes where the name came from (e.g. "--name" or "project path basename") so the returned error names a fix the user can act on.

Types

type AddOptions

type AddOptions struct {
	// ProjectPath is the project root. May be relative or contain a `~`;
	// Add resolves to an absolute, symlink-evaluated canonical path
	// before doing anything else. Empty string means "use cwd".
	ProjectPath string

	// Dirs scopes which agent dirs to add. Empty slice (the default)
	// means "all detected agent dirs at the project root"; a non-empty
	// slice restricts the run to the named dirs. Names that don't exist
	// at the project root surface as CodeNotFound; names already tracked
	// for this project are reported as AlreadyTracked rather than added
	// again (extending a tracked project is supported via a fresh
	// `--dir` invocation).
	Dirs []string

	// Name overrides the project name lore records (and uses to key
	// central/projects/<name>/). Empty means "use filepath.Base of the
	// resolved project path". Useful when two projects share a basename
	// in different parents, or when the user wants a different label in
	// central than the on-disk directory name.
	Name string

	// Create asks Add to scaffold an agent dir at the project root when
	// none would otherwise be found. With --dir, each named dir that
	// doesn't already exist is scaffolded (silent default filename). Without
	// --dir, an interactive picker collects a (dir, file) pair. Existing
	// dirs are left untouched (idempotent skip). Non-TTY without --dir is
	// CodeInconsistency.
	Create bool
}

AddOptions configures a single Add() call.

type AddResult

type AddResult struct {
	ProjectName   string
	ProjectPath   string // resolved, absolute
	CentralRepo   string // central repo root (for the Next hint)
	CommitMessage string // empty when nothing was newly added
	CommitSHA     string // full central commit SHA used as the sync-base
	SyncBase      string // checkout sync-base after this operation
	Dirs          []AgentDirResult
	// ScaffoldRequested is true when the user passed --create. Carried
	// even when no scaffolding actually happened (all targets already
	// existed) so JSON consumers can distinguish "user asked for
	// create" from "lore decided to create".
	ScaffoldRequested bool
}

AddResult is the structured outcome of an Add. cmd/lore/add.go converts it to the output package's render type.

func Add

func Add(opts AddOptions) (AddResult, error)

Add onboards a checkout with real project and central copies.

func (AddResult) AllAlreadyTracked

func (r AddResult) AllAlreadyTracked() bool

AllAlreadyTracked reports whether every per-dir result is StatusAlreadyTracked. The output layer uses this to render the terse idempotent-reentry message instead of the full per-dir block.

type AgentDirResult

type AgentDirResult struct {
	Name        string
	Status      DirStatus
	CentralPath string             // populated for StatusAdded, StatusAlreadyTracked, StatusScaffolded
	Violations  []detect.Violation // populated for StatusSkippedSafety
}

AgentDirResult is the per-dir outcome inside an AddResult.

type CheckoutStatus

type CheckoutStatus struct {
	Path      string
	SyncBase  string
	State     reconcile.SyncState
	BaseStale bool
	Dirs      []DirSyncStatus
	Issues    []reconcile.Issue
}

CheckoutStatus is the rollup for one independently tracked checkout.

type DirStatus

type DirStatus string

DirStatus names the per-dir outcome inside an AddResult.

const (
	// StatusAdded is set when the dir was freshly onboarded in this run.
	StatusAdded DirStatus = "added"
	// StatusAlreadyTracked is set when state already mapped the dir to
	// central and the project copy is valid; the dir is reported but
	// no side effects fired for it.
	StatusAlreadyTracked DirStatus = "already-tracked"
	// StatusSkippedSafety is set when a slice-3 safety check refused this
	// dir; other dirs in the same run may still have been added.
	StatusSkippedSafety DirStatus = "skipped-safety"
	// StatusScaffolded is set when --create created this dir fresh in
	// this run AND the normal add flow succeeded on it. Idempotent
	// re-creates (dir already existed) report as StatusAdded instead.
	StatusScaffolded DirStatus = "scaffolded"
	// StatusAdopted is set when identical existing copies rebuild tracking.
	StatusAdopted DirStatus = "adopted"
)

type DirSyncStatus

type DirSyncStatus struct {
	Name      string
	State     reconcile.SyncState
	BaseStale bool
	Files     []reconcile.FileResult
	Issues    []reconcile.Issue
}

DirSyncStatus contains one agent directory's classification.

type DoctorResult

type DoctorResult struct {
	Status  StatusResult
	Fixed   []string
	Healthy bool
}

func Doctor

func Doctor(fix bool) (DoctorResult, error)

Doctor checks copy integrity and sync-base health. Fix mode restores only missing project-copy directories from committed central content.

type ListResult

type ListResult struct {
	CentralRepo string
	CentralHead string
	Rows        []ListRow
}

func List

func List() (ListResult, error)

List reports one row per checkout plus one not-placed row for central-only projects.

type ListRow

type ListRow struct {
	Name      string
	Path      string
	AgentDirs []string
	State     string
	Issues    []reconcile.Issue
}

type MoveCheckoutResult

type MoveCheckoutResult struct {
	OldPath  string
	Path     string
	SyncBase string
}

MoveCheckoutResult describes one checkout retained by a rename.

type MoveResult

type MoveResult struct {
	OldName       string
	ProjectName   string
	CentralRepo   string
	CommitMessage string
	Commit        string
	Checkouts     []MoveCheckoutResult
	CentralOnly   bool
}

MoveResult is the structured outcome of a project rename.

func Move

func Move(old, newName, newPath string) (MoveResult, error)

Move renames one committed central project and its local-state key. Project copies never move. The optional path updates one checkout record.

type ProjectStatus

type ProjectStatus struct {
	Name      string
	Checkouts []CheckoutStatus
	Issues    []reconcile.Issue
}

ProjectStatus groups every recorded checkout for one project.

type PullCheckoutResult

type PullCheckoutResult struct {
	Path     string
	Status   PullCheckoutStatus
	SyncBase string
	Dirs     []PullDirResult
	Err      error
}

PullCheckoutResult describes one checkout considered by pull.

type PullCheckoutStatus

type PullCheckoutStatus string

PullCheckoutStatus names one checkout outcome.

const (
	PullCheckoutMaterialized  PullCheckoutStatus = "materialized"
	PullCheckoutUpdated       PullCheckoutStatus = "updated"
	PullCheckoutAdopted       PullCheckoutStatus = "adopted"
	PullCheckoutUnchanged     PullCheckoutStatus = "unchanged"
	PullCheckoutProjectAhead  PullCheckoutStatus = "project-ahead"
	PullCheckoutRefused       PullCheckoutStatus = "refused"
	PullCheckoutFailed        PullCheckoutStatus = "failed"
	PullCheckoutMerged        PullCheckoutStatus = "merged"
	PullCheckoutConflicted    PullCheckoutStatus = "conflicted"
	PullCheckoutCentralForced PullCheckoutStatus = "central-forced"
	PullCheckoutProjectForced PullCheckoutStatus = "project-forced"
)

type PullConflictResult

type PullConflictResult struct {
	Path        string
	Kind        reconcile.ConflictKind
	SiblingPath string
}

PullConflictResult describes one unresolved merge artifact.

type PullDirResult

type PullDirResult struct {
	Name      string
	Path      string
	Status    PullDirStatus
	Unignored bool
	Conflicts []PullConflictResult
}

PullDirResult describes one agent directory considered by pull.

type PullDirStatus

type PullDirStatus string

PullDirStatus names one agent-directory outcome.

const (
	PullDirMaterialized  PullDirStatus = "materialized"
	PullDirUpdated       PullDirStatus = "updated"
	PullDirUnchanged     PullDirStatus = "unchanged"
	PullDirProjectAhead  PullDirStatus = "project-ahead"
	PullDirMerged        PullDirStatus = "merged"
	PullDirConflicted    PullDirStatus = "conflicted"
	PullDirKeepBoth      PullDirStatus = "keep-both"
	PullDirCentralForced PullDirStatus = "central-forced"
	PullDirProjectForced PullDirStatus = "project-forced"
)

type PullOptions

type PullOptions struct {
	Name    string
	Path    string
	All     bool
	Central bool
	Project bool
}

PullOptions selects project copies that receive committed central content.

type PullProjectResult

type PullProjectResult struct {
	Name      string
	Status    PullProjectStatus
	Matches   []string
	Checkouts []PullCheckoutResult
	Err       error
}

PullProjectResult describes one central project considered by pull.

type PullProjectStatus

type PullProjectStatus string

PullProjectStatus names one project outcome in a sweep.

const (
	PullProjectPulled     PullProjectStatus = "pulled"
	PullProjectUnchanged  PullProjectStatus = "unchanged"
	PullProjectMissing    PullProjectStatus = "missing"
	PullProjectAmbiguous  PullProjectStatus = "ambiguous"
	PullProjectRefused    PullProjectStatus = "refused"
	PullProjectFailed     PullProjectStatus = "failed"
	PullProjectConflicted PullProjectStatus = "conflicted"
)

type PullResult

type PullResult struct {
	CentralRepo  string
	CentralHead  string
	ScannedRoots []string
	Projects     []PullProjectResult
}

PullResult is the stable pull command result.

func Pull

func Pull(opts PullOptions) (PullResult, error)

Pull receives committed central content without merging divergent copies.

func (PullResult) HasConflicts

func (result PullResult) HasConflicts() bool

HasConflicts reports whether pull wrote unresolved conflict artifacts.

type PushCheckoutResult

type PushCheckoutResult struct {
	Path   string
	Status PushStatus
}

PushCheckoutResult describes one checkout considered by push.

type PushOptions

type PushOptions struct {
	Project        string
	ProjectFromCWD bool
}

PushOptions selects the checkouts whose project copies are captured.

type PushProjectResult

type PushProjectResult struct {
	Name      string
	Checkouts []PushCheckoutResult
}

PushProjectResult describes one selected project.

type PushResult

type PushResult struct {
	CentralRepo   string
	PreviousHead  string
	CommitSHA     string
	CommitMessage string
	Projects      []PushProjectResult
	ScopeProject  string
}

PushResult is the stable command result.

func Push

func Push(opts PushOptions) (PushResult, error)

Push captures selected project copies in one central commit.

type PushStatus

type PushStatus string

PushStatus names the per-checkout outcome inside a PushResult. Push reads these back to decide which sync-bases to advance, so they are typed rather than bare strings.

const (
	// PushUnchanged means the checkout already matches central at a live base.
	PushUnchanged PushStatus = "unchanged"
	// PushPushed means the checkout's content was captured in central.
	PushPushed PushStatus = "pushed"
	// PushAdopted means content already matched and only the base advanced.
	PushAdopted PushStatus = "adopted"
)

type RmCopyResult

type RmCopyResult struct {
	Checkout string
	Dir      string
	Path     string
	State    reconcile.SyncState
	Issues   []reconcile.Issue
	Status   RmCopyStatus
}

type RmCopyStatus

type RmCopyStatus string
const (
	RmCopyKept    RmCopyStatus = "kept"
	RmCopyPurged  RmCopyStatus = "purged"
	RmCopyMissing RmCopyStatus = "missing"
)

type RmPlan

type RmPlan struct {
	ProjectName string
	CentralRepo string
	CommitMsg   string
	RecoveryCmd string
	Purge       bool
	Copies      []RmCopyResult
	RefusalErr  error
	Force       bool
	// contains filtered or unexported fields
}

func PreflightRm

func PreflightRm(name string, purge bool, force bool) (*RmPlan, error)

PreflightRm inspects the complete removal scope while holding the central mutation lock. Call Close when the plan will not be executed.

func (*RmPlan) Close

func (p *RmPlan) Close()

Close releases a preflight plan that will not be executed.

type RmResult

type RmResult struct {
	ProjectName   string
	CentralRepo   string
	CommitMessage string
	Commit        string
	RecoveryCmd   string
	Purge         bool
	Copies        []RmCopyResult
}

func Remove

func Remove(plan *RmPlan) (RmResult, error)

Remove commits the central deletion, drops all checkout state, and then purges project copies when requested. A closed preflight plan is reopened and revalidated so interactive confirmation never holds the mutation lock.

type StatusResult

type StatusResult struct {
	CentralRepo string
	CentralHead string
	Projects    []ProjectStatus
}

StatusResult is the complete read-only sync report.

func Diff

func Diff(projectName string) (StatusResult, error)

Diff returns status data narrowed to current project-central differences.

func Status

func Status(projectName string) (StatusResult, error)

Status inspects one named project or all tracked projects.

func (StatusResult) HasIssues

func (r StatusResult) HasIssues() bool

HasIssues reports whether inspection found a health issue.

func (StatusResult) Unhealthy

func (r StatusResult) Unhealthy() bool

Unhealthy reports whether status must return CodeInconsistency.

Jump to

Keyboard shortcuts

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