sqlite

package
v0.32.0 Latest Latest
Warning

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

Go to latest
Published: Jun 30, 2026 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Overview

Package sqlite provides SQLite-backed persistent storage for ToolHive.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DefaultDBPath

func DefaultDBPath() string

DefaultDBPath returns the default file path for the ToolHive SQLite database, located under the XDG state directory.

func NewDefaultPluginStore added in v0.32.0

func NewDefaultPluginStore() (storage.PluginStore, error)

NewDefaultPluginStore creates a PluginStore using OS environment for runtime detection. In Kubernetes it returns a NoopPluginStore; locally it opens the shared SQLite database at the default path (the same file as skills — Open runs all migrations including 002_create_plugins). The caller owns the returned store. Mirrors NewDefaultSkillStore.

func NewDefaultSkillStore

func NewDefaultSkillStore() (storage.SkillStore, error)

NewDefaultSkillStore creates a SkillStore using OS environment for runtime detection. In Kubernetes it returns a NoopSkillStore; locally it opens a SQLite database at the default path. The caller owns the returned store.

Types

type DB

type DB struct {
	// contains filtered or unexported fields
}

DB wraps a *sql.DB connection to a SQLite database.

func Open

func Open(ctx context.Context, dbPath string) (_ *DB, err error)

Open opens (or creates) a SQLite database at the given path. It ensures the parent directory exists, configures recommended PRAGMAs for WAL mode, runs any pending migrations, and verifies the connection before returning.

func (*DB) Close

func (d *DB) Close() error

Close closes the underlying database connection.

func (*DB) DB

func (d *DB) DB() *sql.DB

DB returns the underlying *sql.DB for use by store implementations.

type PluginStore added in v0.32.0

type PluginStore struct {
	// contains filtered or unexported fields
}

PluginStore implements storage.PluginStore using SQLite. It is a structural mirror of SkillStore (pkg/storage/sqlite/skill_store.go), substituting plugin types and the installed_plugins/plugin_dependencies tables. It shares the entries table with SkillStore via the entry_type discriminator (storage.EntryTypePlugin), so a skill and a plugin can share the same name.

func NewPluginStore added in v0.32.0

func NewPluginStore(db *DB) *PluginStore

NewPluginStore creates a new SQLite-backed PluginStore.

func (*PluginStore) Close added in v0.32.0

func (s *PluginStore) Close() error

Close closes the underlying database connection.

func (*PluginStore) Create added in v0.32.0

func (s *PluginStore) Create(ctx context.Context, plugin plugins.InstalledPlugin) error

Create stores a new installed plugin.

func (*PluginStore) Delete added in v0.32.0

func (s *PluginStore) Delete(ctx context.Context, name string, scope plugins.Scope, projectRoot string) error

Delete removes an installed plugin by name, scope, and project root.

func (*PluginStore) Get added in v0.32.0

func (s *PluginStore) Get(
	ctx context.Context, name string, scope plugins.Scope, projectRoot string,
) (plugins.InstalledPlugin, error)

Get retrieves an installed plugin by name, scope, and project root.

func (*PluginStore) List added in v0.32.0

List returns all installed plugins matching the given filter. It uses the SAME two-phase fetch pattern as SkillStore.List: Phase 1 collects rows + IDs and closes the rows cursor; Phase 2 fetches dependencies per ID. This is required because SQLite MaxOpenConns=1 means fetchDependencies cannot run while the List rows cursor is still open — forgetting this deadlocks under load.

func (*PluginStore) Update added in v0.32.0

func (s *PluginStore) Update(ctx context.Context, plugin plugins.InstalledPlugin) error

Update modifies an existing installed plugin.

type SkillStore

type SkillStore struct {
	// contains filtered or unexported fields
}

SkillStore implements storage.SkillStore using SQLite.

func NewSkillStore

func NewSkillStore(db *DB) *SkillStore

NewSkillStore creates a new SQLite-backed SkillStore.

func (*SkillStore) Close

func (s *SkillStore) Close() error

Close closes the underlying database connection.

func (*SkillStore) Create

func (s *SkillStore) Create(ctx context.Context, skill skills.InstalledSkill) error

Create stores a new installed skill.

func (*SkillStore) Delete

func (s *SkillStore) Delete(ctx context.Context, name string, scope skills.Scope, projectRoot string) error

Delete removes an installed skill by name, scope, and project root.

func (*SkillStore) Get

func (s *SkillStore) Get(
	ctx context.Context, name string, scope skills.Scope, projectRoot string,
) (skills.InstalledSkill, error)

Get retrieves an installed skill by name, scope, and project root.

func (*SkillStore) List

List returns all installed skills matching the given filter.

func (*SkillStore) Update

func (s *SkillStore) Update(ctx context.Context, skill skills.InstalledSkill) error

Update modifies an existing installed skill.

Jump to

Keyboard shortcuts

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