Documentation
¶
Index ¶
- Constants
- func SyncBuiltin(ctx context.Context, store *SQLiteStore, builtinFS fs.FS) error
- type MigrateFSConfig
- type MigrateFSResult
- type SQLiteStore
- func (s *SQLiteStore) Create(ctx context.Context, sk Skill, files map[string]string) (string, error)
- func (s *SQLiteStore) Delete(ctx context.Context, id string) error
- func (s *SQLiteStore) DeleteFile(ctx context.Context, skillID, path string) error
- func (s *SQLiteStore) ExpireDrafts(ctx context.Context, before time.Time) error
- func (s *SQLiteStore) List(ctx context.Context, vc ViewContext) ([]Skill, error)
- func (s *SQLiteStore) ListAll(ctx context.Context) ([]Skill, error)
- func (s *SQLiteStore) ListFiles(ctx context.Context, skillID string) ([]string, error)
- func (s *SQLiteStore) LoadFile(ctx context.Context, skillID, path string) (string, error)
- func (s *SQLiteStore) Resolve(ctx context.Context, name string, vc ViewContext) (*Skill, error)
- func (s *SQLiteStore) Update(ctx context.Context, id string, patch UpdatePatch) error
- func (s *SQLiteStore) UpsertFile(ctx context.Context, skillID, path, content string) error
- type Skill
- type Store
- type UpdatePatch
- type ViewContext
Constants ¶
const MainFile = "SKILL.md"
Variables ¶
This section is empty.
Functions ¶
func SyncBuiltin ¶ added in v0.13.0
SyncBuiltin imports or updates builtin skills from the embedded FS into the DB. Only scope='system' rows are created/updated; user/agent/project rows are never touched.
Called at server start (wiring happens in Phase 4; this function is exported for that use).
TODO(orphan-cleanup): Skills that exist in the DB as scope='system' but are absent from builtinFS are not deleted here. Phase 4+ should add an explicit tombstone pass once the full lifecycle is understood.
Types ¶
type MigrateFSConfig ¶ added in v0.13.0
type MigrateFSConfig struct {
// AnnaHome is intentionally unused: builtin (anna source) skills are handled
// exclusively by SyncBuiltin, not by filesystem migration.
AnnaHome string
AgentRoot string
UserRoot string
UserSkillsDir string
// Owner fields used when creating scoped rows.
UserID int64
AgentID string
}
MigrateFSConfig controls how on-disk skills are discovered and mapped to DB rows.
type MigrateFSResult ¶ added in v0.13.0
MigrateFSResult contains counts for a MigrateFilesystem run.
func MigrateFilesystem ¶ added in v0.13.0
func MigrateFilesystem(ctx context.Context, store *SQLiteStore, cfg MigrateFSConfig) (MigrateFSResult, error)
MigrateFilesystem reads on-disk skills and idempotently imports each into the DB.
Skills with source="anna" (builtin) are skipped — use SyncBuiltin for those. The function is safe to call multiple times; existing rows are counted as Skipped.
type SQLiteStore ¶ added in v0.13.0
type SQLiteStore struct {
// contains filtered or unexported fields
}
SQLiteStore implements Store against a SQLite database via sqlc.
func New ¶ added in v0.13.0
func New(db *sql.DB) *SQLiteStore
New returns a new SQLiteStore. Callers may store it as a Store interface.
func (*SQLiteStore) Create ¶ added in v0.13.0
func (s *SQLiteStore) Create(ctx context.Context, sk Skill, files map[string]string) (string, error)
Create inserts the skill row and all its files in a transaction. The files map must include MainFile ("SKILL.md"). If s.ID is empty a new ID is generated.
func (*SQLiteStore) Delete ¶ added in v0.13.0
func (s *SQLiteStore) Delete(ctx context.Context, id string) error
Delete removes a skill and (via ON DELETE CASCADE) all its files.
func (*SQLiteStore) DeleteFile ¶ added in v0.13.0
func (s *SQLiteStore) DeleteFile(ctx context.Context, skillID, path string) error
DeleteFile removes a single file from a skill.
func (*SQLiteStore) ExpireDrafts ¶ added in v0.13.0
ExpireDrafts deprecates all draft skills whose created-at metadata timestamp is before the given cutoff.
func (*SQLiteStore) List ¶ added in v0.13.0
func (s *SQLiteStore) List(ctx context.Context, vc ViewContext) ([]Skill, error)
List returns all visible skills for the given context.
func (*SQLiteStore) ListAll ¶ added in v0.13.0
func (s *SQLiteStore) ListAll(ctx context.Context) ([]Skill, error)
ListAll returns every skill regardless of status, visibility, or scope filter.
func (*SQLiteStore) ListFiles ¶ added in v0.13.0
ListFiles returns all file paths for a skill (no content).
func (*SQLiteStore) Resolve ¶ added in v0.13.0
func (s *SQLiteStore) Resolve(ctx context.Context, name string, vc ViewContext) (*Skill, error)
Resolve finds the highest-priority visible skill by name.
func (*SQLiteStore) Update ¶ added in v0.13.0
func (s *SQLiteStore) Update(ctx context.Context, id string, patch UpdatePatch) error
Update patches metadata fields using read-modify-write.
func (*SQLiteStore) UpsertFile ¶ added in v0.13.0
func (s *SQLiteStore) UpsertFile(ctx context.Context, skillID, path, content string) error
UpsertFile creates or replaces a single file under a skill.
type Skill ¶ added in v0.13.0
type Skill struct {
ID string
Scope string // system | agent | user
UserID int64
AgentID string
Name string
Description string
Status string // draft | active | deprecated
DisableModelInvocation bool
Metadata json.RawMessage
CreatedAt time.Time
UpdatedAt time.Time
}
Skill represents a skill row (metadata only, no file content).
type Store ¶ added in v0.13.0
type Store interface {
// List returns all visible skills for the given context (metadata only, no file content).
List(ctx context.Context, vc ViewContext) ([]Skill, error)
// ListAll returns every skill regardless of status or visibility (admin use only).
ListAll(ctx context.Context) ([]Skill, error)
// Resolve finds the highest-priority visible skill by name.
// Priority: user > agent > system.
Resolve(ctx context.Context, name string, vc ViewContext) (*Skill, error)
// LoadFile fetches a single file by path. Pass MainFile ("SKILL.md") for the body.
LoadFile(ctx context.Context, skillID, path string) (string, error)
// ListFiles returns all file paths for a skill (no content).
ListFiles(ctx context.Context, skillID string) ([]string, error)
// Create inserts the skill row and all its files (must include "SKILL.md").
Create(ctx context.Context, s Skill, files map[string]string) (string, error)
// Update patches metadata fields. Use UpsertFile to change file content.
Update(ctx context.Context, id string, patch UpdatePatch) error
// UpsertFile creates or replaces a single file under a skill.
UpsertFile(ctx context.Context, skillID, path, content string) error
DeleteFile(ctx context.Context, skillID, path string) error
Delete(ctx context.Context, id string) error
// ExpireDrafts deprecates all draft skills whose created-at timestamp is
// before the given cutoff.
ExpireDrafts(ctx context.Context, before time.Time) error
}
Store is the persistence interface for skills.
type UpdatePatch ¶ added in v0.13.0
type UpdatePatch struct {
Description *string
Status *string
DisableModelInvocation *bool
Metadata json.RawMessage // optional; set to overwrite
}
UpdatePatch carries optional updates for a skill's metadata fields.
type ViewContext ¶ added in v0.13.0
ViewContext describes who is asking and from where. Empty fields mean no such context (e.g. UserID=0 → only system skills visible).