{"modulePath":"github.com/stacklok/toolhive","version":"v0.69.0","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package sqlite\n\nPackage sqlite provides SQLite-backed persistent storage for ToolHive.\n\n## Functions\n\n```go\nfunc DefaultDBPath() string\n```\nDefaultDBPath returns the default file path for the ToolHive SQLite database, located under the XDG state directory.\n\n```go\nfunc NewDefaultPluginStore() (storage.PluginStore, error)\n```\nNewDefaultPluginStore 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.\n\n```go\nfunc NewDefaultSkillStore() (storage.SkillStore, error)\n```\nNewDefaultSkillStore 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.\n\n## Types\n\n```go\ntype DB struct {\n\t// contains filtered or unexported fields\n}\n```\nDB wraps a \\*sql.DB connection to a SQLite database.\n\n```go\nfunc Open(ctx context.Context, dbPath string) (_ *DB, err error)\n```\nOpen 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.\n\n```go\nfunc (d *DB) Close() error\n```\nClose closes the underlying database connection.\n\n```go\nfunc (d *DB) DB() *sql.DB\n```\nDB returns the underlying \\*sql.DB for use by store implementations.\n\n```go\ntype PluginStore struct {\n\t// contains filtered or unexported fields\n}\n```\nPluginStore 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.\n\n```go\nfunc NewPluginStore(db *DB) *PluginStore\n```\nNewPluginStore creates a new SQLite-backed PluginStore.\n\n```go\nfunc (s *PluginStore) Close() error\n```\nClose closes the underlying database connection.\n\n```go\nfunc (s *PluginStore) Create(ctx context.Context, plugin plugins.InstalledPlugin) error\n```\nCreate stores a new installed plugin.\n\n```go\nfunc (s *PluginStore) Delete(ctx context.Context, name string, scope plugins.Scope, projectRoot string) error\n```\nDelete removes an installed plugin by name, scope, and project root.\n\n```go\nfunc (s *PluginStore) Get(\n\tctx context.Context, name string, scope plugins.Scope, projectRoot string,\n) (plugins.InstalledPlugin, error)\n```\nGet retrieves an installed plugin by name, scope, and project root.\n\n```go\nfunc (s *PluginStore) List(ctx context.Context, filter storage.ListFilter) ([]plugins.InstalledPlugin, error)\n```\nList 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.\n\n```go\nfunc (s *PluginStore) Update(ctx context.Context, plugin plugins.InstalledPlugin) error\n```\nUpdate modifies an existing installed plugin.\n\n```go\ntype SkillStore struct {\n\t// contains filtered or unexported fields\n}\n```\nSkillStore implements storage.SkillStore using SQLite.\n\n```go\nfunc NewSkillStore(db *DB) *SkillStore\n```\nNewSkillStore creates a new SQLite-backed SkillStore.\n\n```go\nfunc (s *SkillStore) Close() error\n```\nClose closes the underlying database connection.\n\n```go\nfunc (s *SkillStore) Create(ctx context.Context, skill skills.InstalledSkill) error\n```\nCreate stores a new installed skill.\n\n```go\nfunc (s *SkillStore) Delete(ctx context.Context, name string, scope skills.Scope, projectRoot string) error\n```\nDelete removes an installed skill by name, scope, and project root.\n\n```go\nfunc (s *SkillStore) Get(\n\tctx context.Context, name string, scope skills.Scope, projectRoot string,\n) (skills.InstalledSkill, error)\n```\nGet retrieves an installed skill by name, scope, and project root.\n\n```go\nfunc (s *SkillStore) List(ctx context.Context, filter storage.ListFilter) ([]skills.InstalledSkill, error)\n```\nList returns all installed skills matching the given filter.\n\n```go\nfunc (s *SkillStore) Update(ctx context.Context, skill skills.InstalledSkill) error\n```\nUpdate modifies an existing installed skill.\n\n","path":"github.com/stacklok/toolhive/pkg/storage/sqlite","name":"sqlite","synopsis":"Package sqlite provides SQLite-backed persistent storage for ToolHive.","isRedistributable":true}
