skills

package
v0.1.18 Latest Latest
Warning

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

Go to latest
Published: Jul 10, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Overview

Package skills installs and keeps the byted-supabase Claude/agent skill in sync with the running CLI binary. The skill itself is NOT bundled in this repo; it is published to skills.volces.com and installed globally via the external `skills` tool (`npx -y skills add <source> -s <name> -g -y`).

Like the MCP layer, every file here is net-new so it never conflicts on an upstream rebase. The two touchpoints are:

  • internal/update calls Sync after a CLI update so the skill tracks the binary version (and installs it on first run).
  • cmd/root.go calls Init at startup; on version drift it stores a pending StaleNotice that Execute prints to stderr, mirroring the upgrade hint.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Init

func Init(currentVersion string)

Init runs the cheap, local, network-free skill drift check. It compares the version recorded in skills-state.json against the running binary version and, on mismatch, stores a pending StaleNotice for Execute to print. Safe to call once near the end of cmd.Execute.

Skip rules (shouldSkip): CI envs, dev/empty builds, non-release versions, and the BYTED_SUPABASE_CLI_NO_SKILLS_NOTIFIER opt-out. Nothing is emitted on a cold start (no state file yet) — the skill notice is reserved for genuine drift, not "never installed".

func IsSynced

func IsSynced(version string) bool

IsSynced reports whether the recorded skill version matches version (both normalized). Used by the update path to avoid re-running npx every time.

func Name

func Name() string

Name returns the skill name to install (`-s <name>`).

func ReadSyncedVersion

func ReadSyncedVersion() (string, bool)

ReadSyncedVersion returns the recorded skill version, or false if there is no readable state yet.

func SetPending

func SetPending(n *StaleNotice)

SetPending stores a stale notice; pass nil to clear.

func Source

func Source() string

Source returns the `skills add` source, overridable via env for testing or staging registries.

func WriteState

func WriteState(state State) error

WriteState persists the skills state, creating ~/.supabase if needed.

Types

type CmdResult

type CmdResult struct {
	Stdout bytes.Buffer
	Stderr bytes.Buffer
	Err    error
}

CmdResult captures the output of a skill install invocation.

type Runner

type Runner interface {
	Install(ctx context.Context, source, name string, force bool) *CmdResult
}

Runner installs the skill. The default implementation shells out to npx; tests inject a fake.

type StaleNotice

type StaleNotice struct {
	Current string
	Target  string
}

StaleNotice signals that the locally installed skill version no longer matches the running CLI binary. Current is the last synced version, Target is the running binary version.

func GetPending

func GetPending() *StaleNotice

GetPending returns the pending stale notice, or nil.

func (*StaleNotice) Message

func (n *StaleNotice) Message() string

Message is a single-line, agent-parseable hint pointing at the fix command.

type State

type State struct {
	Skill     string `json:"skill"`
	Source    string `json:"source"`
	Version   string `json:"version"`
	UpdatedAt string `json:"updated_at"`
}

State records the last successful skill install so version drift can be detected cheaply (no network) on subsequent CLI runs.

func ReadState

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

ReadState loads the skills state. The bool is false when no state file exists yet (cold start); a non-nil error means the file exists but is unreadable.

type SyncOptions

type SyncOptions struct {
	Version string           // CLI version to stamp into state; "" is treated as dev (still installs)
	Force   bool             // pass --force to reinstall even if the skill is current
	Runner  Runner           // nil → default npx runner
	Now     func() time.Time // nil → time.Now
}

SyncOptions controls a Sync call.

type SyncResult

type SyncResult struct {
	Action  string // "synced" | "failed"
	Skill   string
	Version string
	Err     error
	Detail  string // trailing combined output on failure (for JSON/debug)
}

SyncResult is the outcome of a Sync call.

func Sync

func Sync(ctx context.Context, opts SyncOptions) *SyncResult

Sync installs (or reinstalls) the skill and, on success, records the version in the global state file. It always runs the installer — callers that want to skip a redundant install should gate on IsSynced first.

Jump to

Keyboard shortcuts

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