Documentation
¶
Overview ¶
Package detect inspects a project root and decides which agent directory(ies) lore should onboard. Pure filesystem logic; no config or state knowledge.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CheckSafetyAll ¶
CheckSafetyAll runs the slice-3 refusals against every name in names independently. Returns a map keyed by name; entries are present only when violations fired (an absent key means that candidate is clean OR doesn't exist as a directory/symlink at root).
Each candidate is policed in isolation so multi-dir onboarding can skip just the offending dir and proceed with the rest, matching the slice-5 acceptance criterion. The slice-3 "polices what it manages" principle survives in the orchestrator's selection logic: only names the orchestrator intends to onboard are passed in.
A symlinked candidate produces exactly one violation (AgentDirSymlink) and the dir-only checks are skipped: those checks read through the symlink and would report against the resolved target rather than the candidate name the user controls. A directory candidate can produce up to two violations (tracked + nested .git) so the user fixes both in one round-trip.
Pure inspection: no mutation, no network. Only `git ls-files` is consulted, and only for directory candidates.
Types ¶
type AgentDir ¶
type AgentDir struct {
Name string // bare directory name, e.g. ".claude"
Path string // absolute path on disk
}
AgentDir names one detected agent directory at a project root.
func DetectAgentDirs ¶
DetectAgentDirs scans root for every entry in candidates that is a real directory (not a symlink, not a regular file). Iteration follows the order in candidates so callers control precedence via config.AgentDirs and `lore add` preserves a stable per-run order.
Symlinked candidates are intentionally skipped. A top-level link cannot satisfy the project-copy contract. CheckSafetyAll handles it when the user requests that candidate explicitly through `--dir`.
Returns an empty slice when nothing matches (never a nil-vs-empty distinction). Errors only on unexpected stat failures (permission etc).
type Violation ¶
type Violation struct {
Kind ViolationKind
Name string // candidate name that tripped the check (e.g. ".claude")
Message string
}
Violation describes one safety-gate failure. Message is the full user-facing line including the recovery instruction, ready to be surfaced verbatim by project.Add.
type ViolationKind ¶
type ViolationKind string
ViolationKind names one of the slice-3 safety refusals. Stable string values so callers (notably project.Add's error builder and any future `lore doctor` check) can branch on a specific kind without depending on the user-facing message wording.
const ( ViolationTrackedFiles ViolationKind = "tracked-files" ViolationNestedGit ViolationKind = "nested-git" ViolationAgentDirSymlink ViolationKind = "agent-dir-symlink" )