projstate

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Jul 17, 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 {
	StoreHash    string                `json:"storeHash"`
	StoreScope   string                `json:"storeScope,omitempty"`
	ActiveTarget string                `json:"activeTarget,omitempty"`
	ActiveMode   string                `json:"activeMode,omitempty"`
	Agents       map[string]AgentState `json:"agents,omitempty"`
}

SkillState records which global object a skill activates and which links gskill owns for it — enough for safe repair and removal (FR-014).

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