Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/logos/logo-mark.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<h1>skilld</h1>
<h1><a href="https://skilld.dev"><img src=".github/logos/logo-mark.svg" alt="" width="28" height="28" valign="middle"></a> skilld</h1>

[![npm version](https://img.shields.io/npm/v/skilld?color=yellow)](https://npmjs.com/package/skilld)
[![npm downloads](https://img.shields.io/npm/dm/skilld?color=yellow)](https://npm.chart.dev/skilld)
Expand Down
76 changes: 38 additions & 38 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions pnpm-workspace.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ packages:
overrides:
global-agent: ^4.1.3
catalog:
'@mariozechner/pi-ai': ^0.63.1
'@mariozechner/pi-ai': ^0.64.0
'@mdream/crawl': ^1.0.3
'@types/semver': ^7.7.1
bumpp: ^11.0.1
Expand Down Expand Up @@ -36,7 +36,7 @@ catalogs:
mlly: ^1.8.2
oxc-parser: ^0.121.0
p-limit: ^7.3.0
sqlite-vec: ^0.1.7
sqlite-vec: ^0.1.8
tinyglobby: ^0.2.15
unist-util-visit: ^5.1.0
dev-build:
Expand Down
36 changes: 34 additions & 2 deletions src/retriv/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,47 @@ export type { ChunkEntity, Document, IndexConfig, IndexPhase, IndexProgress, Sea
type RetrivInstance = Awaited<ReturnType<typeof getDb>>

export class SearchDepsUnavailableError extends Error {
constructor(cause: unknown) {
super('Search dependencies unavailable (sqlite-vec or retriv not installed). Search indexing skipped.')
constructor(cause: unknown, message?: string) {
super(message ?? 'Search dependencies unavailable (sqlite-vec or retriv not installed). Search indexing skipped.')
this.name = 'SearchDepsUnavailableError'
this.cause = cause
}
}

let _fts5Available: boolean | null = null

/**
* Probe whether SQLite FTS5 module is available.
* Windows Node.js binaries often ship without FTS5 compiled in.
*/
function checkFts5(): boolean {
if (_fts5Available !== null)
return _fts5Available
const nodeSqlite = globalThis.process?.getBuiltinModule?.('node:sqlite') as typeof import('node:sqlite') | undefined
if (!nodeSqlite) {
_fts5Available = false
return false
}
const db = new nodeSqlite.DatabaseSync(':memory:')
try {
db.exec('CREATE VIRTUAL TABLE _fts5_probe USING fts5(content)')
db.exec('DROP TABLE _fts5_probe')
_fts5Available = true
}
catch {
_fts5Available = false
}
finally {
db.close()
}
return _fts5Available
}

// Dynamic imports: retriv/chunkers/auto eagerly loads typescript which may not be installed (e.g. npx)
export async function getDb(config: Pick<IndexConfig, 'dbPath'>) {
if (!checkFts5())
throw new SearchDepsUnavailableError(new Error('FTS5 module not available'), 'SQLite FTS5 module not available. Search indexing skipped. On Windows, run from WSL where FTS5 is included.')

let createRetriv, autoChunker, sqliteMod, sqliteVec, transformersJs, cachedEmbeddings
try {
;([
Expand Down
Loading