projstate

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Aug 26, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package projstate manages a project's gitignored machine-local state file (.gskill/state.json): the stable project identifier, the global store object each skill activates, and the links gskill owns. The state exists for safe repair and removal only — a project is always restorable from its committed skills-lock.json alone, and deleting the state file simply regenerates it with a fresh project ID.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Path

func Path(root string) string

Path returns the state.json path for a project root.

Types

type AgentState

type AgentState struct {
	Target string `json:"target"`
	Mode   string `json:"mode"`
}

AgentState is one gskill-created agent target.

type SkillState

type SkillState struct {
	Agents map[string]AgentState `json:"agents,omitempty"`

	// Legacy v1 fields: read for migration detection (spec 022 §9), never
	// written — a v1 file upgrades on its next Save.
	StoreHash    string `json:"storeHash,omitempty"`
	StoreScope   string `json:"storeScope,omitempty"`
	ActiveTarget string `json:"activeTarget,omitempty"`
	ActiveMode   string `json:"activeMode,omitempty"`
}

SkillState records the gskill-created agent targets for one skill — the only machine-local facts left in the repo-owned model (spec 022 data-model §4): per-agent mode records the symlink→copy fallback, which is per-agent and per-machine. The active entry is always `.agents/skills/<name>` (derivable) and content identity lives in the committed lockfile.

type State

type State struct {
	SchemaVersion int                   `json:"schemaVersion"`
	ProjectID     string                `json:"projectId"`
	Skills        map[string]SkillState `json:"skills"`
	// contains filtered or unexported fields
}

State is a project's machine-local installation record. It is gitignored, never required to reproduce the project (the lockfile alone restores it, FR-015), and safe to delete: a fresh state with a new project ID is generated on the next gskill operation.

func LoadOrInit

func LoadOrInit(root string) (*State, error)

LoadOrInit loads the project state under root, or initializes a fresh one (with a newly generated stable project ID) when none exists. A fresh state is not persisted until Save is called.

func (*State) RemoveSkill

func (s *State) RemoveSkill(name string)

RemoveSkill drops the record for name.

func (*State) Root

func (s *State) Root() string

Root returns the project root this state belongs to.

func (*State) Save

func (s *State) Save() error

Save writes the state atomically and deterministically (map keys are sorted by encoding/json).

func (*State) SetSkill

func (s *State) SetSkill(name string, sk SkillState)

SetSkill records the state for name.

func (*State) Skill

func (s *State) Skill(name string) (SkillState, bool)

Skill returns the recorded state for name.

Jump to

Keyboard shortcuts

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