active

package
v0.7.2 Latest Latest
Warning

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

Go to latest
Published: Sep 9, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package active manages the project active-skill layer: the per-skill entry at .agents/skills/<name> that links into the content store and is the single source of truth every agent target derives from.

The three layers gskill maintains are:

.gskill/store/<algo>/<hash>   immutable canonical content (one physical copy)
          ▲ symlink (copy fallback)
.agents/skills/<name>          active project skill (one per installed skill)
          ▲ symlink (copy fallback)
.<agent>/skills/<name>         per-agent targets (claude, codex, cursor, …)

The active layer holds no independent copy of the content: it links into the store, so adding an agent is one cheap link and a skill shared by N agents still exists exactly once on disk. The active layer is gitignored and regenerated by `gskill project sync` from the committed manifest + lockfile.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Dir

func Dir(root string) string

Dir returns the active-skills container directory under root.

func EnsureActive

func EnsureActive(root, name, src string, opts EnsureOptions) (string, error)

EnsureActive makes .agents/skills/<name> a real directory whose content is copied from src and verified against opts.ExpectedHash (spec 022: the repo owns skill content; the entry is committed, never a link into a store). It is idempotent — an entry already matching ExpectedHash is left untouched — and atomic: the copy is staged as a temporary sibling, verified, then swapped in, so the project never observes a half-written skill. It NEVER destroys content gskill does not own: foreign symlinks and unrecognized directories fail closed and are left intact.

func List

func List(root string) ([]string, error)

List returns the names of active entries (directories and symlinks) under root. Plain files are skipped: they are never gskill-managed.

func Owned added in v0.3.0

func Owned(dest string, roots []string, acceptHashes ...string) bool

Owned reports whether dest is gskill-managed content: a symlink resolving under any of the given roots (the repo's .agents/skills root; agent links resolve there), or a real directory whose content hash matches one of acceptHashes (the active entry itself, or a copy-mode install). A missing dest is not owned. This is the single ownership predicate shared by the installer's overwrite guard and the plan layer's conflict detection, so the two cannot drift (spec 011 FR-016).

func Path

func Path(root, name string) string

Path returns the active entry path for a skill name under root.

func Rel

func Rel(name string) string

Rel returns the project-relative active entry path for a skill name.

func Remove

func Remove(root, name string, acceptHashes ...string) error

Remove deletes a gskill-managed active entry for name: a symlink (a legacy or stale managed link), or a real directory whose content matches one of acceptHashes (the lock-recorded content). It is a no-op when the entry is absent, and it never deletes content it cannot prove gskill installed — a drifted or foreign directory is left intact.

Types

type EnsureOptions added in v0.7.0

type EnsureOptions struct {
	// ExpectedHash is the content hash the entry must match after the call
	// (the lock's recorded hash for the incoming content). Required.
	ExpectedHash string
	// AcceptHashes are additional gskill-owned content hashes (e.g. the
	// previously locked version): an existing directory matching one of them
	// is replaced rather than treated as foreign.
	AcceptHashes []string
	// Replace allows replacing a real directory that matches neither
	// ExpectedHash nor AcceptHashes. Reconcile paths (install/sync/repair,
	// --force) set it; guarded add paths leave it false so drifted or foreign
	// content fails closed.
	Replace bool
	// LegacyRoots are store roots from the pre-022 layout: a symlink entry
	// resolving under one of them is a stale managed link and is replaced by
	// the real copy. Symlinks resolving anywhere else are foreign.
	LegacyRoots []string
}

EnsureOptions parameterizes EnsureActive.

type Health

type Health string

Health classifies the state of an active entry in the repo-owned model (spec 022): the entry is a real committed directory, and its identity is its content hash against the lock.

const (
	// HealthOK means the entry is a real directory whose content hash matches
	// the expected (lock-recorded) hash.
	HealthOK Health = "ok"
	// HealthMissing means no entry exists.
	HealthMissing Health = "missing"
	// HealthDrifted means the entry is a real directory whose content no
	// longer matches the expected hash (hand-edited committed content).
	HealthDrifted Health = "drifted"
	// HealthLegacy means the entry is a symlink into a known legacy store
	// root (the pre-022 layout); migration converts it on the next mutating
	// command.
	HealthLegacy Health = "legacy"
	// HealthForeign means something gskill does not own occupies the entry:
	// a symlink resolving elsewhere, or a plain file.
	HealthForeign Health = "foreign"
)

Active-entry health states.

func HealthOf

func HealthOf(root, name, expectedHash string, legacyRoots ...string) (Health, error)

HealthOf reports the active entry's state against the expected content hash. legacyRoots name pre-022 store roots so their stale symlinks are classified as HealthLegacy (migratable) rather than HealthForeign.

Jump to

Keyboard shortcuts

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