skillscheck

package
v1.0.88 Latest Latest
Warning

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

Go to latest
Published: Aug 18, 2026 License: MIT Imports: 16 Imported by: 0

Documentation

Overview

Package skillscheck verifies that the locally installed lark-cli skills are in sync with the running binary version, by comparing the current binary version against skills-state.json. On mismatch it stores a notice for injection into JSON envelopes via output.PendingNotice.

Index

Constants

This section is empty.

Variables

View Source
var ErrUnreadableState = errors.New("skills state is unreadable")

Functions

func Init

func Init(currentVersion string)

Init runs the synchronous skills version check. Stores a StaleNotice when the local skills state records a version that does not match currentVersion, or the last sync could not determine the complete official Skill set. Safe to call from cmd/root.go before rootCmd.Execute(); zero network, zero subprocess — only a local state file read.

Skip rules: see shouldSkip (CI envs, DEV builds, non-release semver, LARKSUITE_CLI_NO_SKILLS_NOTIFIER opt-out).

func ParseOfficialSkillsIndexJSON added in v1.0.49

func ParseOfficialSkillsIndexJSON(text string) ([]string, error)

func ParseSkillsList added in v1.0.35

func ParseSkillsList(text string) []string

func ReadSyncedVersion added in v1.0.35

func ReadSyncedVersion() (string, bool)

func SetPending

func SetPending(n *StaleNotice)

SetPending stores the stale notice for consumption by output decorators. Pass nil to clear.

func WriteState added in v1.0.35

func WriteState(state SkillsState) error

Types

type Layout added in v1.0.88

type Layout string
const (
	LayoutSeparate Layout = "separate"
	LayoutSuite    Layout = "suite"
)

func EffectiveLayout added in v1.0.88

func EffectiveLayout(state *SkillsState) Layout

func ParseLayout added in v1.0.88

func ParseLayout(value string) (Layout, error)

func ResolveLayout added in v1.0.88

func ResolveLayout(requested Layout, state *SkillsState, readable bool) (Layout, error)

type SkillsRunner added in v1.0.35

type SkillsRunner interface {
	SkillsSources() []string
	FetchSkillsIndex(source string) *selfupdate.NpmResult
	ListGlobalSkillsJSON() *selfupdate.NpmResult
	ListGlobalSkills() *selfupdate.NpmResult
	InstallSkills(source string, nameList []string) *selfupdate.NpmResult
	InstallAllSkills(source string) *selfupdate.NpmResult
	StageSuite(source, dir string) *selfupdate.NpmResult
	InstallLocalSuite(path string) *selfupdate.NpmResult
	RemoveGlobalSkills(names []string) *selfupdate.NpmResult
}

type SkillsState added in v1.0.35

type SkillsState struct {
	Version               string   `json:"version"`
	Layout                Layout   `json:"layout,omitempty"`
	OfficialSkills        []string `json:"official_skills"`
	OfficialSkillsUnknown bool     `json:"official_skills_unknown,omitempty"`
	UpdatedSkills         []string `json:"updated_skills"`
	AddedOfficialSkills   []string `json:"added_official_skills"`
	SkippedDeletedSkills  []string `json:"skipped_deleted_skills"`
	UpdatedAt             string   `json:"updated_at"`
}

func ReadState added in v1.0.35

func ReadState() (*SkillsState, bool, error)

type StaleNotice

type StaleNotice struct {
	Current         string `json:"current"`
	Target          string `json:"target"`
	OfficialUnknown bool   `json:"official_unknown,omitempty"`
}

StaleNotice signals that the locally synced skills need attention because their version is stale or their official completeness is unknown. Current is the last successfully synced version (always non-empty — Init does not emit a notice on cold start). Target is the running binary version. Mirrors internal/update.UpdateInfo's pending-notice pattern.

func GetPending

func GetPending() *StaleNotice

GetPending returns the pending stale notice, or nil.

func (*StaleNotice) Message

func (s *StaleNotice) Message() string

Message returns a single-line, AI-agent-parseable description of the drift plus the canonical fix command. Mirrors internal/update.UpdateInfo.Message in style ("..., run: lark-cli update" suffix). Current is guaranteed non-empty because Init only emits a StaleNotice after a completed sync.

type SyncInput added in v1.0.35

type SyncInput struct {
	Version        string
	OfficialSkills []string
	LocalSkills    []string
	PreviousState  *SkillsState
	StateReadable  bool
	Force          bool
}

type SyncOptions added in v1.0.35

type SyncOptions struct {
	Version string
	Layout  Layout
	Force   bool
	Runner  SkillsRunner
	Now     func() time.Time
}

type SyncPlan added in v1.0.35

type SyncPlan struct {
	Version         string
	OfficialSkills  []string
	CleanupOfficial []string
	ToUpdate        []string
	Added           []string
	SkippedDeleted  []string
}

func PlanSync added in v1.0.35

func PlanSync(input SyncInput) SyncPlan

type SyncResult added in v1.0.35

type SyncResult struct {
	Action          string
	Official        []string
	OfficialUnknown bool
	Updated         []string
	Added           []string
	SkippedDeleted  []string
	Failed          []string
	Err             error
	Detail          string
	Warning         string
	Layout          Layout
	Force           bool
}

func SyncSkills added in v1.0.35

func SyncSkills(opts SyncOptions) *SyncResult

Jump to

Keyboard shortcuts

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