state

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: May 30, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CatalogSkill

type CatalogSkill struct {
	Name              string
	Summary           string
	Categories        []string
	Tags              []string
	CompatibilityMode string
	CompatibilityData map[string]any
	Requirements      map[string]any
	Origin            map[string]any
	Fingerprint       string
}

type CatalogSnapshot

type CatalogSnapshot struct {
	Skills []CatalogSkill
}

type DB

type DB struct {
	*sql.DB
}

func Open

func Open(home string) (*DB, error)

func (*DB) Close

func (db *DB) Close() error

func (*DB) GetPendingUpdate

func (db *DB) GetPendingUpdate(skillName string) (*PendingUpdate, error)

GetPendingUpdate returns a single pending update by skill name.

func (*DB) GetSkillPoll

func (db *DB) GetSkillPoll(skillName string) (*SkillPollRecord, error)

GetSkillPoll retrieves the cached poll record for a skill. Returns nil if the skill has no poll record.

func (*DB) InsertUpdate

func (db *DB) InsertUpdate(skillName, fromVersion, toVersion, source string) error

InsertUpdate records a new or updated pending update.

func (*DB) ListPendingUpdates

func (db *DB) ListPendingUpdates() ([]PendingUpdate, error)

ListPendingUpdates returns all updates with status='pending'.

func (*DB) MarkUpdateAccepted

func (db *DB) MarkUpdateAccepted(skillName string) error

MarkUpdateAccepted marks a pending update as accepted, removing it from the list.

func (*DB) MarkUpdateRejected

func (db *DB) MarkUpdateRejected(skillName string) error

MarkUpdateRejected marks a pending update as rejected, removing it from the pending list. The row is retained (status='rejected') so the rejected version is recorded rather than silently re-detected.

func (*DB) MarkUpdateSummarized

func (db *DB) MarkUpdateSummarized(skillName, summaryStatus, summaryPath string) error

MarkUpdateSummarized records the advisory summary cache path for a pending update.

func (*DB) Rebuild

func (db *DB) Rebuild(snap CatalogSnapshot) error

Rebuild wipes derived-from-library tables (skills, requirement_checks) and repopulates skills from the snapshot. Per ownership rules, user-owned and machine-local-but-not-derived tables (projects, installs, invocations, detected, updates) are preserved.

func (*DB) RecordInvocation

func (db *DB) RecordInvocation(inv Invocation) error

RecordInvocation records a single invocation, merging on tool_use_id (see insertInvocationSQL). An empty InvokedAt is defaulted to the current UTC time.

func (*DB) RecordInvocations

func (db *DB) RecordInvocations(invs []Invocation) (int, error)

RecordInvocations records a batch of invocations in a single transaction. Records with an empty SkillName are skipped rather than aborting the batch, so a malformed event in an OTEL payload does not discard the valid ones. Returns the number of records processed (an upsert that merges into an existing row still counts as processed).

func (*DB) RefreshSkillPollCheckedAt

func (db *DB) RefreshSkillPollCheckedAt(skillName string) error

RefreshSkillPollCheckedAt updates only the last_checked_at timestamp for a skill, preserving the existing commit and etag. Used when polling completes but staging fails, or when a 304 Not Modified is received.

func (*DB) SyncCatalog

func (db *DB) SyncCatalog(snap CatalogSnapshot) error

func (*DB) UpsertSkillPoll

func (db *DB) UpsertSkillPoll(skillName, commit, etag string) error

UpsertSkillPoll inserts or updates the poll record for a skill.

func (*DB) UsageMatrix

func (db *DB) UsageMatrix() ([]UsageCell, error)

UsageMatrix returns invocation counts grouped by skill, project, and harness, ordered deterministically so callers and tests see stable output. This backs the Matrix view (skill × project × harness × count).

type Invocation

type Invocation struct {
	SkillName   string
	ProjectSlug string // empty when the source cannot attribute a project (e.g. OTEL)
	Harness     string
	Trigger     string // user-initiated | proactive | nested; empty when unknown
	InvokedAt   string // RFC3339 timestamp; defaulted to now when empty
	Source      string // otel | hook | watcher | manual
	ToolUseID   string // correlation id shared by the OTEL tool_result event and the hook
}

Invocation is a single recorded skill activation, sourced from Claude Code OTEL events, a PreToolUse hook, a watcher, or a manual entry.

type PendingUpdate

type PendingUpdate struct {
	SkillName     string
	FromVersion   string
	ToVersion     string
	Source        string
	DetectedAt    string // RFC3339 timestamp
	SummaryStatus string
	SummaryPath   string
	Status        string
}

PendingUpdate holds info about a staged update waiting for review.

type SkillPollRecord

type SkillPollRecord struct {
	SkillName     string
	ETag          string
	LastCheckedAt string // RFC3339 timestamp
	LastCommit    string
}

SkillPollRecord holds cached polling info for a GitHub-sourced skill.

type UsageCell

type UsageCell struct {
	SkillName   string `json:"skill_name"`
	ProjectSlug string `json:"project_slug"`
	Harness     string `json:"harness"`
	Count       int    `json:"count"`
}

UsageCell is one aggregated bucket of the usage matrix: a count of invocations grouped by skill, project, and harness.

Jump to

Keyboard shortcuts

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