sensemaking 0.28.1 → 0.28.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/chunk/extract.js +2 -2
- package/dist/cjs/chunk/extract.js.map +1 -1
- package/dist/cjs/chunk/group.js +15 -15
- package/dist/cjs/chunk/group.js.map +1 -1
- package/dist/cjs/chunk/index.js +13 -13
- package/dist/cjs/chunk/index.js.map +1 -1
- package/dist/cjs/chunk/parse.js +4 -4
- package/dist/cjs/chunk/parse.js.map +1 -1
- package/dist/cjs/chunk/parser.js.map +1 -1
- package/dist/cjs/chunk/tokens.js +2 -2
- package/dist/cjs/chunk/tokens.js.map +1 -1
- package/dist/cjs/cli/build.js +7 -7
- package/dist/cjs/cli/build.js.map +1 -1
- package/dist/cjs/cli/download.js +12 -12
- package/dist/cjs/cli/download.js.map +1 -1
- package/dist/cjs/cli/init.js +6 -6
- package/dist/cjs/cli/init.js.map +1 -1
- package/dist/cjs/cli/map.js +9 -9
- package/dist/cjs/cli/map.js.map +1 -1
- package/dist/cjs/cli/named.js +21 -21
- package/dist/cjs/cli/named.js.map +1 -1
- package/dist/cjs/cli/path.js +11 -11
- package/dist/cjs/cli/path.js.map +1 -1
- package/dist/cjs/cli/peek.js +12 -12
- package/dist/cjs/cli/peek.js.map +1 -1
- package/dist/cjs/cli/related.js +20 -20
- package/dist/cjs/cli/related.js.map +1 -1
- package/dist/cjs/cli/search.js +22 -22
- package/dist/cjs/cli/search.js.map +1 -1
- package/dist/cjs/cli/shared.js +16 -16
- package/dist/cjs/cli/shared.js.map +1 -1
- package/dist/cjs/cli/sql.js +7 -7
- package/dist/cjs/cli/sql.js.map +1 -1
- package/dist/cjs/cli/status.js +41 -41
- package/dist/cjs/cli/status.js.map +1 -1
- package/dist/cjs/cli/watch.js +7 -7
- package/dist/cjs/cli/watch.js.map +1 -1
- package/dist/cjs/cli.js +16 -16
- package/dist/cjs/cli.js.map +1 -1
- package/dist/cjs/commands/index.js +15 -15
- package/dist/cjs/commands/index.js.map +1 -1
- package/dist/cjs/commands/map.js +14 -14
- package/dist/cjs/commands/map.js.map +1 -1
- package/dist/cjs/commands/path.js +16 -16
- package/dist/cjs/commands/path.js.map +1 -1
- package/dist/cjs/commands/peek.js +24 -24
- package/dist/cjs/commands/peek.js.map +1 -1
- package/dist/cjs/commands/related.js +29 -29
- package/dist/cjs/commands/related.js.map +1 -1
- package/dist/cjs/commands/scope.js +11 -11
- package/dist/cjs/commands/scope.js.map +1 -1
- package/dist/cjs/commands/search.js +44 -44
- package/dist/cjs/commands/search.js.map +1 -1
- package/dist/cjs/commands/signals.js +10 -10
- package/dist/cjs/commands/signals.js.map +1 -1
- package/dist/cjs/commands/snapshot.js +11 -11
- package/dist/cjs/commands/snapshot.js.map +1 -1
- package/dist/cjs/commands/status.js +4 -4
- package/dist/cjs/commands/status.js.map +1 -1
- package/dist/cjs/config/access.js +5 -5
- package/dist/cjs/config/access.js.map +1 -1
- package/dist/cjs/config/index.js +31 -31
- package/dist/cjs/config/index.js.map +1 -1
- package/dist/cjs/config/load.js +27 -27
- package/dist/cjs/config/load.js.map +1 -1
- package/dist/cjs/config/resolve.js +4 -4
- package/dist/cjs/config/resolve.js.map +1 -1
- package/dist/cjs/config/validate.js +54 -54
- package/dist/cjs/config/validate.js.map +1 -1
- package/dist/cjs/embed/cohere.js +11 -11
- package/dist/cjs/embed/cohere.js.map +1 -1
- package/dist/cjs/embed/distribution.js +3 -3
- package/dist/cjs/embed/distribution.js.map +1 -1
- package/dist/cjs/embed/endpoint.js.map +1 -1
- package/dist/cjs/embed/handoff.js.map +1 -1
- package/dist/cjs/embed/http.js +3 -3
- package/dist/cjs/embed/http.js.map +1 -1
- package/dist/cjs/embed/identity.js +4 -4
- package/dist/cjs/embed/identity.js.map +1 -1
- package/dist/cjs/embed/langfit.js +8 -8
- package/dist/cjs/embed/langfit.js.map +1 -1
- package/dist/cjs/embed/openai.js +12 -12
- package/dist/cjs/embed/openai.js.map +1 -1
- package/dist/cjs/embed/query.js +36 -36
- package/dist/cjs/embed/query.js.map +1 -1
- package/dist/cjs/embed/registry.js +14 -14
- package/dist/cjs/embed/registry.js.map +1 -1
- package/dist/cjs/embed/static.js +10 -10
- package/dist/cjs/embed/static.js.map +1 -1
- package/dist/cjs/embed/store.d.cts +1 -1
- package/dist/cjs/embed/store.d.ts +1 -1
- package/dist/cjs/embed/store.js +193 -70
- package/dist/cjs/embed/store.js.map +1 -1
- package/dist/cjs/features/embed.js +16 -16
- package/dist/cjs/features/embed.js.map +1 -1
- package/dist/cjs/features/index.js +15 -15
- package/dist/cjs/features/index.js.map +1 -1
- package/dist/cjs/features/links.js +5 -5
- package/dist/cjs/features/links.js.map +1 -1
- package/dist/cjs/features/rank.js +5 -5
- package/dist/cjs/features/rank.js.map +1 -1
- package/dist/cjs/features/sections.js +7 -7
- package/dist/cjs/features/sections.js.map +1 -1
- package/dist/cjs/features/tags.js +5 -5
- package/dist/cjs/features/tags.js.map +1 -1
- package/dist/cjs/graph/graph.js +1 -1
- package/dist/cjs/graph/graph.js.map +1 -1
- package/dist/cjs/graph/traverse.js +3 -3
- package/dist/cjs/graph/traverse.js.map +1 -1
- package/dist/cjs/index.js +27 -27
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/lib/atomic-write.js.map +1 -1
- package/dist/cjs/lib/watch-notification.js +2 -2
- package/dist/cjs/lib/watch-notification.js.map +1 -1
- package/dist/cjs/lib/worker-file.js.map +1 -1
- package/dist/cjs/output/column-hint.js +1 -1
- package/dist/cjs/output/output.js +1 -1
- package/dist/cjs/output/output.js.map +1 -1
- package/dist/cjs/output/progress.js.map +1 -1
- package/dist/cjs/output/search-error.js +7 -7
- package/dist/cjs/output/search-error.js.map +1 -1
- package/dist/cjs/scan/frontmatter.js +1 -1
- package/dist/cjs/scan/frontmatter.js.map +1 -1
- package/dist/cjs/scan/index.js +18 -18
- package/dist/cjs/scan/index.js.map +1 -1
- package/dist/cjs/scan/list.js +6 -6
- package/dist/cjs/scan/list.js.map +1 -1
- package/dist/cjs/scan/pool.js +5 -5
- package/dist/cjs/scan/pool.js.map +1 -1
- package/dist/cjs/scan/reparse.js +5 -5
- package/dist/cjs/scan/reparse.js.map +1 -1
- package/dist/cjs/scan/worker-error.js +3 -3
- package/dist/cjs/scan/worker-error.js.map +1 -1
- package/dist/cjs/store/batch.js +1 -1
- package/dist/cjs/store/builder.js +61 -61
- package/dist/cjs/store/builder.js.map +1 -1
- package/dist/cjs/store/cache.js +2 -2
- package/dist/cjs/store/cache.js.map +1 -1
- package/dist/cjs/store/duckdb/batch.js +3 -3
- package/dist/cjs/store/duckdb/batch.js.map +1 -1
- package/dist/cjs/store/duckdb/connection.js +10 -10
- package/dist/cjs/store/duckdb/connection.js.map +1 -1
- package/dist/cjs/store/duckdb/engine.js +4 -4
- package/dist/cjs/store/duckdb/engine.js.map +1 -1
- package/dist/cjs/store/duckdb/fieldStats.js +3 -3
- package/dist/cjs/store/duckdb/fieldStats.js.map +1 -1
- package/dist/cjs/store/duckdb/lexical.js +28 -28
- package/dist/cjs/store/duckdb/lexical.js.map +1 -1
- package/dist/cjs/store/duckdb/native.js +3 -3
- package/dist/cjs/store/duckdb/native.js.map +1 -1
- package/dist/cjs/store/duckdb/open.js +39 -39
- package/dist/cjs/store/duckdb/open.js.map +1 -1
- package/dist/cjs/store/duckdb/reconcile.js +15 -15
- package/dist/cjs/store/duckdb/reconcile.js.map +1 -1
- package/dist/cjs/store/duckdb/sql-functions.js +7 -7
- package/dist/cjs/store/duckdb/sql-functions.js.map +1 -1
- package/dist/cjs/store/duckdb/store.js +19 -19
- package/dist/cjs/store/duckdb/store.js.map +1 -1
- package/dist/cjs/store/duckdb/vectors.js +11 -11
- package/dist/cjs/store/duckdb/vectors.js.map +1 -1
- package/dist/cjs/store/embed-scope.js +1 -1
- package/dist/cjs/store/engine.js +2 -2
- package/dist/cjs/store/engine.js.map +1 -1
- package/dist/cjs/store/feature-scope.js +1 -1
- package/dist/cjs/store/index.js +37 -37
- package/dist/cjs/store/index.js.map +1 -1
- package/dist/cjs/store/lock-wait.js +2 -2
- package/dist/cjs/store/lock-wait.js.map +1 -1
- package/dist/cjs/store/native.js +14 -6
- package/dist/cjs/store/native.js.map +1 -1
- package/dist/cjs/store/open.js +44 -44
- package/dist/cjs/store/open.js.map +1 -1
- package/dist/cjs/store/preset-scope.js +5 -5
- package/dist/cjs/store/preset-scope.js.map +1 -1
- package/dist/cjs/store/reconcile.js +28 -28
- package/dist/cjs/store/reconcile.js.map +1 -1
- package/dist/cjs/store/shared.js.map +1 -1
- package/dist/cjs/store/signature.js +1 -1
- package/dist/cjs/store/sql-functions.js.map +1 -1
- package/dist/cjs/store/sqlite/connection.js +4 -4
- package/dist/cjs/store/sqlite/connection.js.map +1 -1
- package/dist/cjs/store/sqlite/engine.js +3 -3
- package/dist/cjs/store/sqlite/engine.js.map +1 -1
- package/dist/cjs/store/sqlite/fieldStats.js +3 -3
- package/dist/cjs/store/sqlite/fieldStats.js.map +1 -1
- package/dist/cjs/store/sqlite/lexical.js +4 -4
- package/dist/cjs/store/sqlite/lexical.js.map +1 -1
- package/dist/cjs/store/sqlite/open.js +31 -31
- package/dist/cjs/store/sqlite/open.js.map +1 -1
- package/dist/cjs/store/sqlite/reconcile.js +11 -11
- package/dist/cjs/store/sqlite/reconcile.js.map +1 -1
- package/dist/cjs/store/sqlite/sql-functions.js +5 -5
- package/dist/cjs/store/sqlite/sql-functions.js.map +1 -1
- package/dist/cjs/store/sqlite/store.js +17 -17
- package/dist/cjs/store/sqlite/store.js.map +1 -1
- package/dist/cjs/store/sqlite/vectors.js +9 -9
- package/dist/cjs/store/sqlite/vectors.js.map +1 -1
- package/dist/cjs/store/stages.js +1 -1
- package/dist/cjs/store/transaction.js.map +1 -1
- package/dist/cjs/store/turso/connection.js +15 -15
- package/dist/cjs/store/turso/connection.js.map +1 -1
- package/dist/cjs/store/turso/engine.js +4 -4
- package/dist/cjs/store/turso/engine.js.map +1 -1
- package/dist/cjs/store/turso/fieldStats.js +3 -3
- package/dist/cjs/store/turso/fieldStats.js.map +1 -1
- package/dist/cjs/store/turso/lexical-text.js +3 -3
- package/dist/cjs/store/turso/lexical-text.js.map +1 -1
- package/dist/cjs/store/turso/lexical.js +13 -13
- package/dist/cjs/store/turso/lexical.js.map +1 -1
- package/dist/cjs/store/turso/native.js +3 -3
- package/dist/cjs/store/turso/native.js.map +1 -1
- package/dist/cjs/store/turso/open.js +41 -41
- package/dist/cjs/store/turso/open.js.map +1 -1
- package/dist/cjs/store/turso/reconcile.js +15 -15
- package/dist/cjs/store/turso/reconcile.js.map +1 -1
- package/dist/cjs/store/turso/sql-functions.js +2 -2
- package/dist/cjs/store/turso/sql-functions.js.map +1 -1
- package/dist/cjs/store/turso/store.js +26 -26
- package/dist/cjs/store/turso/store.js.map +1 -1
- package/dist/cjs/store/turso/vectors.js +9 -9
- package/dist/cjs/store/turso/vectors.js.map +1 -1
- package/dist/cjs/text/segment.js.map +1 -1
- package/dist/cjs/text/strip.js +4 -4
- package/dist/cjs/text/strip.js.map +1 -1
- package/dist/cjs/watch-claim.js +11 -11
- package/dist/cjs/watch-claim.js.map +1 -1
- package/dist/cjs/watch.js +18 -18
- package/dist/cjs/watch.js.map +1 -1
- package/dist/cjs/workers/parse.js +7 -7
- package/dist/cjs/workers/parse.js.map +1 -1
- package/dist/cjs/workers/watch-heartbeat.js +8 -8
- package/dist/cjs/workers/watch-heartbeat.js.map +1 -1
- package/dist/esm/chunk/extract.js +1 -1
- package/dist/esm/chunk/extract.js.map +1 -1
- package/dist/esm/chunk/group.js +3 -3
- package/dist/esm/chunk/group.js.map +1 -1
- package/dist/esm/chunk/index.js +6 -6
- package/dist/esm/chunk/parse.js +2 -2
- package/dist/esm/chunk/tokens.js +1 -1
- package/dist/esm/cli/build.js +3 -3
- package/dist/esm/cli/download.js +5 -5
- package/dist/esm/cli/index.js +11 -11
- package/dist/esm/cli/init.js +3 -3
- package/dist/esm/cli/map.js +4 -4
- package/dist/esm/cli/named.js +7 -7
- package/dist/esm/cli/path.js +4 -4
- package/dist/esm/cli/path.js.map +1 -1
- package/dist/esm/cli/peek.js +4 -4
- package/dist/esm/cli/related.js +7 -7
- package/dist/esm/cli/search.js +7 -7
- package/dist/esm/cli/search.js.map +1 -1
- package/dist/esm/cli/shared.js +6 -6
- package/dist/esm/cli/shared.js.map +1 -1
- package/dist/esm/cli/sql.js +2 -2
- package/dist/esm/cli/status.js +11 -11
- package/dist/esm/cli/status.js.map +1 -1
- package/dist/esm/cli/watch.js +3 -3
- package/dist/esm/cli.js +4 -4
- package/dist/esm/cli.js.map +1 -1
- package/dist/esm/commands/index.js +7 -7
- package/dist/esm/commands/map.js +5 -5
- package/dist/esm/commands/map.js.map +1 -1
- package/dist/esm/commands/path.js +7 -7
- package/dist/esm/commands/path.js.map +1 -1
- package/dist/esm/commands/peek.js +6 -6
- package/dist/esm/commands/peek.js.map +1 -1
- package/dist/esm/commands/related.js +8 -8
- package/dist/esm/commands/related.js.map +1 -1
- package/dist/esm/commands/scope.js +3 -3
- package/dist/esm/commands/scope.js.map +1 -1
- package/dist/esm/commands/search.js +10 -10
- package/dist/esm/commands/search.js.map +1 -1
- package/dist/esm/commands/signals.js +4 -4
- package/dist/esm/commands/signals.js.map +1 -1
- package/dist/esm/commands/snapshot.js +4 -4
- package/dist/esm/commands/status.js +1 -1
- package/dist/esm/commands/status.js.map +1 -1
- package/dist/esm/config/access.js +1 -1
- package/dist/esm/config/index.js +6 -6
- package/dist/esm/config/load.js +4 -4
- package/dist/esm/config/load.js.map +1 -1
- package/dist/esm/config/resolve.js +2 -2
- package/dist/esm/config/validate.js +3 -3
- package/dist/esm/config/validate.js.map +1 -1
- package/dist/esm/embed/cohere.js +3 -3
- package/dist/esm/embed/cohere.js.map +1 -1
- package/dist/esm/embed/distribution.js +1 -1
- package/dist/esm/embed/http.js +1 -1
- package/dist/esm/embed/identity.js +1 -1
- package/dist/esm/embed/langfit.js +3 -3
- package/dist/esm/embed/openai.js +3 -3
- package/dist/esm/embed/openai.js.map +1 -1
- package/dist/esm/embed/query.js +13 -13
- package/dist/esm/embed/query.js.map +1 -1
- package/dist/esm/embed/registry.js +6 -6
- package/dist/esm/embed/registry.js.map +1 -1
- package/dist/esm/embed/static.js +2 -2
- package/dist/esm/embed/store.d.ts +1 -1
- package/dist/esm/embed/store.js +84 -15
- package/dist/esm/embed/store.js.map +1 -1
- package/dist/esm/features/embed.js +7 -7
- package/dist/esm/features/embed.js.map +1 -1
- package/dist/esm/features/index.js +7 -7
- package/dist/esm/features/links.js +2 -2
- package/dist/esm/features/links.js.map +1 -1
- package/dist/esm/features/rank.js +2 -2
- package/dist/esm/features/rank.js.map +1 -1
- package/dist/esm/features/sections.js +3 -3
- package/dist/esm/features/tags.js +2 -2
- package/dist/esm/graph/graph.js.map +1 -1
- package/dist/esm/graph/traverse.js +1 -1
- package/dist/esm/index.js +6 -6
- package/dist/esm/lib/atomic-write.js.map +1 -1
- package/dist/esm/lib/watch-notification.js +1 -1
- package/dist/esm/output/output.js.map +1 -1
- package/dist/esm/output/progress.js.map +1 -1
- package/dist/esm/output/search-error.js +2 -2
- package/dist/esm/scan/index.js +5 -5
- package/dist/esm/scan/list.js +1 -1
- package/dist/esm/scan/pool.js +2 -2
- package/dist/esm/scan/pool.js.map +1 -1
- package/dist/esm/scan/reparse.js +2 -2
- package/dist/esm/scan/reparse.js.map +1 -1
- package/dist/esm/scan/worker-error.js +1 -1
- package/dist/esm/store/builder.js +16 -16
- package/dist/esm/store/builder.js.map +1 -1
- package/dist/esm/store/cache.js +1 -1
- package/dist/esm/store/duckdb/batch.js +1 -1
- package/dist/esm/store/duckdb/connection.js +4 -4
- package/dist/esm/store/duckdb/engine.js +2 -2
- package/dist/esm/store/duckdb/engine.js.map +1 -1
- package/dist/esm/store/duckdb/fieldStats.js +1 -1
- package/dist/esm/store/duckdb/lexical.js +6 -6
- package/dist/esm/store/duckdb/lexical.js.map +1 -1
- package/dist/esm/store/duckdb/native.js +1 -1
- package/dist/esm/store/duckdb/native.js.map +1 -1
- package/dist/esm/store/duckdb/open.js +14 -14
- package/dist/esm/store/duckdb/open.js.map +1 -1
- package/dist/esm/store/duckdb/reconcile.js +4 -4
- package/dist/esm/store/duckdb/reconcile.js.map +1 -1
- package/dist/esm/store/duckdb/sql-functions.js +3 -3
- package/dist/esm/store/duckdb/store.js +8 -8
- package/dist/esm/store/duckdb/vectors.js +3 -3
- package/dist/esm/store/duckdb/vectors.js.map +1 -1
- package/dist/esm/store/engine.js +1 -1
- package/dist/esm/store/index.js +13 -13
- package/dist/esm/store/lock-wait.js +1 -1
- package/dist/esm/store/native.js +11 -3
- package/dist/esm/store/native.js.map +1 -1
- package/dist/esm/store/open.js +14 -14
- package/dist/esm/store/open.js.map +1 -1
- package/dist/esm/store/preset-scope.js +2 -2
- package/dist/esm/store/reconcile.js +8 -8
- package/dist/esm/store/reconcile.js.map +1 -1
- package/dist/esm/store/sqlite/connection.js +1 -1
- package/dist/esm/store/sqlite/engine.js +1 -1
- package/dist/esm/store/sqlite/fieldStats.js +1 -1
- package/dist/esm/store/sqlite/lexical.js +2 -2
- package/dist/esm/store/sqlite/open.js +11 -11
- package/dist/esm/store/sqlite/open.js.map +1 -1
- package/dist/esm/store/sqlite/reconcile.js +4 -4
- package/dist/esm/store/sqlite/sql-functions.js +2 -2
- package/dist/esm/store/sqlite/store.js +6 -6
- package/dist/esm/store/sqlite/vectors.js +1 -1
- package/dist/esm/store/sqlite/vectors.js.map +1 -1
- package/dist/esm/store/turso/connection.js +5 -5
- package/dist/esm/store/turso/connection.js.map +1 -1
- package/dist/esm/store/turso/engine.js +2 -2
- package/dist/esm/store/turso/engine.js.map +1 -1
- package/dist/esm/store/turso/fieldStats.js +1 -1
- package/dist/esm/store/turso/lexical-text.js +1 -1
- package/dist/esm/store/turso/lexical.js +4 -4
- package/dist/esm/store/turso/lexical.js.map +1 -1
- package/dist/esm/store/turso/native.js +1 -1
- package/dist/esm/store/turso/native.js.map +1 -1
- package/dist/esm/store/turso/open.js +13 -13
- package/dist/esm/store/turso/open.js.map +1 -1
- package/dist/esm/store/turso/reconcile.js +6 -6
- package/dist/esm/store/turso/reconcile.js.map +1 -1
- package/dist/esm/store/turso/sql-functions.js +1 -1
- package/dist/esm/store/turso/store.js +8 -8
- package/dist/esm/store/turso/store.js.map +1 -1
- package/dist/esm/store/turso/vectors.js +1 -1
- package/dist/esm/store/turso/vectors.js.map +1 -1
- package/dist/esm/text/segment.js.map +1 -1
- package/dist/esm/text/strip.js +2 -2
- package/dist/esm/watch-claim.js +5 -5
- package/dist/esm/watch-claim.js.map +1 -1
- package/dist/esm/watch.js +5 -5
- package/dist/esm/watch.js.map +1 -1
- package/dist/esm/workers/parse.js +4 -4
- package/dist/esm/workers/watch-heartbeat.js +3 -3
- package/package.json +4 -2
|
@@ -19,14 +19,14 @@ _export(exports, {
|
|
|
19
19
|
return resolveRelatedSeed;
|
|
20
20
|
}
|
|
21
21
|
});
|
|
22
|
-
var
|
|
23
|
-
var
|
|
24
|
-
var
|
|
25
|
-
var
|
|
26
|
-
var
|
|
27
|
-
var
|
|
28
|
-
var
|
|
29
|
-
var
|
|
22
|
+
var _index = require("../config/index.js");
|
|
23
|
+
var _query = require("../embed/query.js");
|
|
24
|
+
var _store = require("../embed/store.js");
|
|
25
|
+
var _errors = require("../errors.js");
|
|
26
|
+
var _serialquery = require("../lib/serial-query.js");
|
|
27
|
+
var _peek = require("./peek.js");
|
|
28
|
+
var _scope = require("./scope.js");
|
|
29
|
+
var _snapshot = require("./snapshot.js");
|
|
30
30
|
function _array_like_to_array(arr, len) {
|
|
31
31
|
if (len == null || len > arr.length) len = arr.length;
|
|
32
32
|
for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
|
|
@@ -176,7 +176,7 @@ function _unsupported_iterable_to_array(o, minLen) {
|
|
|
176
176
|
if (typeof o === "string") return _array_like_to_array(o, minLen);
|
|
177
177
|
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
178
178
|
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
179
|
-
if (n === "Map" || n === "Set") return Array.from(
|
|
179
|
+
if (n === "Map" || n === "Set") return Array.from(o);
|
|
180
180
|
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
|
|
181
181
|
}
|
|
182
182
|
var RELATED_DEFAULT_K = 5;
|
|
@@ -201,7 +201,7 @@ function resolveRelatedSeed(store, pathArg) {
|
|
|
201
201
|
});
|
|
202
202
|
return [
|
|
203
203
|
2,
|
|
204
|
-
(0,
|
|
204
|
+
(0, _peek.resolveNote)(paths, pathArg)
|
|
205
205
|
];
|
|
206
206
|
}
|
|
207
207
|
});
|
|
@@ -209,7 +209,7 @@ function resolveRelatedSeed(store, pathArg) {
|
|
|
209
209
|
}
|
|
210
210
|
function relatedNotes(store, cfg, pathArg) {
|
|
211
211
|
var options = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : {};
|
|
212
|
-
return (0,
|
|
212
|
+
return (0, _serialquery.serialQuery)(store, function() {
|
|
213
213
|
var _options_k;
|
|
214
214
|
return relatedIndexed(store, cfg, pathArg, options, (_options_k = options.k) !== null && _options_k !== void 0 ? _options_k : RELATED_DEFAULT_K);
|
|
215
215
|
});
|
|
@@ -219,24 +219,24 @@ function relatedIndexed(store, cfg, pathArg, overrides, k) {
|
|
|
219
219
|
var effective, e;
|
|
220
220
|
return _ts_generator(this, function(_state) {
|
|
221
221
|
if (!Number.isFinite(k) || !Number.isInteger(k) || k <= 0) {
|
|
222
|
-
throw new
|
|
222
|
+
throw new _errors.SenseError('SEARCH_OPTION_INVALID', 'related option "k" must be a positive finite integer, got '.concat(String(k)));
|
|
223
223
|
}
|
|
224
224
|
// Vectors are the only signal `related` has, so every way of not having them is an error
|
|
225
225
|
// naming the cause; an empty result means one thing, nothing near in meaning.
|
|
226
|
-
effective = (0,
|
|
227
|
-
if (!(0,
|
|
228
|
-
throw new
|
|
226
|
+
effective = (0, _index.resolveSearch)(cfg, overrides);
|
|
227
|
+
if (!(0, _index.embedEnabled)(cfg)) {
|
|
228
|
+
throw new _errors.SenseError('EMBED_DISABLED', 'related ranks notes by meaning, and this tree has no embedding model; add an "embed" block naming one to sense.config.json (a Hugging Face id fetches automatically at first use; `sense download` prefetches it) -- search works without it, on words and links');
|
|
229
229
|
}
|
|
230
230
|
// search gates on the same signal, so a preset's declared signals mean one thing: without
|
|
231
231
|
// this check an overlapping vectors-on preset would answer for a scope that declined them.
|
|
232
232
|
if (effective.signals.vectors === undefined) {
|
|
233
|
-
throw new
|
|
233
|
+
throw new _errors.SenseError('PRESET_NOT_SEMANTIC', 'preset "'.concat(effective.presetName, '" has no "vectors" signal, so this scope has no vectors and related has no other signal; search it instead (words and links), or add "vectors" to that preset\'s signals'));
|
|
234
234
|
}
|
|
235
235
|
// A downloadable HF id can be fetched by preparation. Only a local path with missing files
|
|
236
236
|
// can never fetch itself.
|
|
237
|
-
e = (0,
|
|
238
|
-
if ((0,
|
|
239
|
-
throw new
|
|
237
|
+
e = (0, _index.embedConfig)(cfg); // embedEnabled(cfg) above guarantees this is set
|
|
238
|
+
if ((0, _store.localModelMissing)(e)) {
|
|
239
|
+
throw new _errors.SenseError('EMBED_MODEL_MISSING', 'related ranks notes by meaning, so it needs the embedding model, but the local model path "'.concat(e.model, '" is missing ').concat(_store.MODEL_FILENAMES, "; point embed.model at a directory containing them (search still works without it, on words and links)"));
|
|
240
240
|
}
|
|
241
241
|
return [
|
|
242
242
|
2,
|
|
@@ -248,14 +248,14 @@ function relatedIndexed(store, cfg, pathArg, overrides, k) {
|
|
|
248
248
|
case 0:
|
|
249
249
|
return [
|
|
250
250
|
4,
|
|
251
|
-
(0,
|
|
251
|
+
(0, _snapshot.assertQuerySnapshot)(store, cfg)
|
|
252
252
|
];
|
|
253
253
|
case 1:
|
|
254
254
|
_state.sent();
|
|
255
255
|
// Repeat effective preset validation inside the snapshot that supplies its durable scope.
|
|
256
|
-
current = (0,
|
|
256
|
+
current = (0, _index.resolveSearch)(cfg, overrides);
|
|
257
257
|
if (current.signals.vectors === undefined) {
|
|
258
|
-
throw new
|
|
258
|
+
throw new _errors.SenseError('PRESET_NOT_SEMANTIC', 'preset "'.concat(current.presetName, '" has no "vectors" signal, so this scope has no vectors and related has no other signal; search it instead (words and links), or add "vectors" to that preset\'s signals'));
|
|
259
259
|
}
|
|
260
260
|
return [
|
|
261
261
|
4,
|
|
@@ -294,7 +294,7 @@ function relatedIndexed(store, cfg, pathArg, overrides, k) {
|
|
|
294
294
|
].concat(_to_consumable_array(outbound), _to_consumable_array(backlinks)));
|
|
295
295
|
return [
|
|
296
296
|
4,
|
|
297
|
-
(0,
|
|
297
|
+
(0, _scope.scopedPaths)(store, cfg, overrides)
|
|
298
298
|
];
|
|
299
299
|
case 7:
|
|
300
300
|
allowed = _state.sent();
|
|
@@ -302,7 +302,7 @@ function relatedIndexed(store, cfg, pathArg, overrides, k) {
|
|
|
302
302
|
// be ready, while pending vectors in unrelated notes do not block this operation.
|
|
303
303
|
return [
|
|
304
304
|
4,
|
|
305
|
-
(0,
|
|
305
|
+
(0, _query.ensureDocumentEmbeddings)(store, cfg, new Set(_to_consumable_array(allowed).concat([
|
|
306
306
|
path
|
|
307
307
|
])))
|
|
308
308
|
];
|
|
@@ -310,15 +310,15 @@ function relatedIndexed(store, cfg, pathArg, overrides, k) {
|
|
|
310
310
|
_state.sent();
|
|
311
311
|
return [
|
|
312
312
|
4,
|
|
313
|
-
(0,
|
|
313
|
+
(0, _query.hasEmbedding)(store, path)
|
|
314
314
|
];
|
|
315
315
|
case 9:
|
|
316
316
|
if (!_state.sent()) {
|
|
317
|
-
throw new
|
|
317
|
+
throw new _errors.SenseError('NOTE_NOT_EMBEDDED', "".concat(path, " has no indexed text to compare -- a note that is frontmatter only, or empty, has nothing to rank by meaning"));
|
|
318
318
|
}
|
|
319
319
|
return [
|
|
320
320
|
4,
|
|
321
|
-
(0,
|
|
321
|
+
(0, _scope.scopeHasEmbeddings)(store, cfg, allowed)
|
|
322
322
|
];
|
|
323
323
|
case 10:
|
|
324
324
|
if (!_state.sent()) return [
|
|
@@ -327,8 +327,8 @@ function relatedIndexed(store, cfg, pathArg, overrides, k) {
|
|
|
327
327
|
];
|
|
328
328
|
return [
|
|
329
329
|
2,
|
|
330
|
-
(0,
|
|
331
|
-
return (0,
|
|
330
|
+
(0, _scope.withMaterializedVectorScope)(store, allowed, function() {
|
|
331
|
+
return (0, _query.similarNotes)(store, cfg, path, {
|
|
332
332
|
exclude: exclude,
|
|
333
333
|
allowed: allowed,
|
|
334
334
|
k: k
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/Users/kevin/Dev/open-source/ai/sensemaking/src/commands/related.ts"],"sourcesContent":["import type { ResolvedConfig, SearchOverrides } from '../config/index.ts';\nimport { embedConfig, embedEnabled, resolveSearch } from '../config/index.ts';\nimport { ensureDocumentEmbeddings, hasEmbedding, similarNotes } from '../embed/query.ts';\nimport { localModelMissing, MODEL_FILENAMES } from '../embed/store.ts';\nimport { SenseError } from '../errors.ts';\nimport { serialQuery } from '../lib/serial-query.ts';\nimport type { Store } from '../store/types.ts';\nimport { resolveNote } from './peek.ts';\nimport { scopedPaths, scopeHasEmbeddings, withMaterializedVectorScope } from './scope.ts';\nimport { assertQuerySnapshot } from './snapshot.ts';\n\nexport const RELATED_DEFAULT_K = 5;\n\n/**\n * Options for {@link relatedNotes}. Scope fields filter result candidates, not the seed note;\n * `k` defaults to 5, matching the CLI.\n */\nexport interface RelatedOptions extends SearchOverrides {\n k?: number;\n}\n\nexport type RelatedResult = {\n path: string;\n similarity: number;\n};\n\nexport async function resolveRelatedSeed(store: Store, pathArg: string): Promise<string> {\n const paths = ((await (await store.prepare('SELECT \"path\" FROM frontmatter')).all()) as Array<{ path: string }>).map((row) => row.path);\n return resolveNote(paths, pathArg);\n}\n\n/**\n * Returns the notes most similar to an indexed seed, excluding the seed and notes linked either\n * way. The seed resolves across the indexed tree even when it is outside the candidate scope.\n */\nexport function relatedNotes(store: Store, cfg: ResolvedConfig, pathArg: string, options: RelatedOptions = {}): Promise<RelatedResult[]> {\n return serialQuery(store, () => relatedIndexed(store, cfg, pathArg, options, options.k ?? RELATED_DEFAULT_K));\n}\n\nasync function relatedIndexed(store: Store, cfg: ResolvedConfig, pathArg: string, overrides: RelatedOptions, k: number): Promise<RelatedResult[]> {\n if (!Number.isFinite(k) || !Number.isInteger(k) || k <= 0) {\n throw new SenseError('SEARCH_OPTION_INVALID', `related option \"k\" must be a positive finite integer, got ${String(k)}`);\n }\n // Vectors are the only signal `related` has, so every way of not having them is an error\n // naming the cause; an empty result means one thing, nothing near in meaning.\n const effective = resolveSearch(cfg, overrides);\n if (!embedEnabled(cfg)) {\n throw new SenseError('EMBED_DISABLED', 'related ranks notes by meaning, and this tree has no embedding model; add an \"embed\" block naming one to sense.config.json (a Hugging Face id fetches automatically at first use; `sense download` prefetches it) -- search works without it, on words and links');\n }\n // search gates on the same signal, so a preset's declared signals mean one thing: without\n // this check an overlapping vectors-on preset would answer for a scope that declined them.\n if (effective.signals.vectors === undefined) {\n throw new SenseError('PRESET_NOT_SEMANTIC', `preset \"${effective.presetName}\" has no \"vectors\" signal, so this scope has no vectors and related has no other signal; search it instead (words and links), or add \"vectors\" to that preset's signals`);\n }\n // A downloadable HF id can be fetched by preparation. Only a local path with missing files\n // can never fetch itself.\n const e = embedConfig(cfg); // embedEnabled(cfg) above guarantees this is set\n if (localModelMissing(e)) {\n throw new SenseError('EMBED_MODEL_MISSING', `related ranks notes by meaning, so it needs the embedding model, but the local model path \"${e.model}\" is missing ${MODEL_FILENAMES}; point embed.model at a directory containing them (search still works without it, on words and links)`);\n }\n\n return store.transaction(async () => {\n await assertQuerySnapshot(store, cfg);\n // Repeat effective preset validation inside the snapshot that supplies its durable scope.\n const current = resolveSearch(cfg, overrides);\n if (current.signals.vectors === undefined) {\n throw new SenseError('PRESET_NOT_SEMANTIC', `preset \"${current.presetName}\" has no \"vectors\" signal, so this scope has no vectors and related has no other signal; search it instead (words and links), or add \"vectors\" to that preset's signals`);\n }\n\n const path = await resolveRelatedSeed(store, pathArg);\n const outbound = ((await (await store.prepare('SELECT DISTINCT dst FROM links WHERE src = ? AND dst IS NOT NULL AND dst != src')).all(path)) as Array<{ dst: string }>).map((r) => r.dst);\n const backlinks = ((await (await store.prepare('SELECT DISTINCT src FROM links WHERE dst = ? AND src != dst')).all(path)) as Array<{ src: string }>).map((r) => r.src);\n const exclude = new Set([path, ...outbound, ...backlinks]);\n const allowed = await scopedPaths(store, cfg, overrides);\n // The seed may sit outside a narrowed candidate scope; both it and every eligible result must\n // be ready, while pending vectors in unrelated notes do not block this operation.\n await ensureDocumentEmbeddings(store, cfg, new Set([...allowed, path]));\n if (!(await hasEmbedding(store, path))) {\n throw new SenseError('NOTE_NOT_EMBEDDED', `${path} has no indexed text to compare -- a note that is frontmatter only, or empty, has nothing to rank by meaning`);\n }\n if (!(await scopeHasEmbeddings(store, cfg, allowed))) return [];\n return withMaterializedVectorScope(store, allowed, () => similarNotes(store, cfg, path, { exclude, allowed, k }));\n });\n}\n"],"names":["RELATED_DEFAULT_K","relatedNotes","resolveRelatedSeed","store","pathArg","paths","prepare","all","map","row","path","resolveNote","cfg","options","serialQuery","relatedIndexed","k","overrides","effective","e","Number","isFinite","isInteger","SenseError","String","resolveSearch","embedEnabled","signals","vectors","undefined","presetName","embedConfig","localModelMissing","MODEL_FILENAMES","model","transaction","current","outbound","backlinks","exclude","allowed","assertQuerySnapshot","r","dst","src","Set","scopedPaths","ensureDocumentEmbeddings","hasEmbedding","scopeHasEmbeddings","withMaterializedVectorScope","similarNotes"],"mappings":";;;;;;;;;;;QAWaA;eAAAA;;QAwBGC;eAAAA;;QATMC;eAAAA;;;
|
|
1
|
+
{"version":3,"sources":["/Users/kevin/Dev/open-source/ai/sensemaking/src/commands/related.ts"],"sourcesContent":["import type { ResolvedConfig, SearchOverrides } from '../config/index.ts';\nimport { embedConfig, embedEnabled, resolveSearch } from '../config/index.ts';\nimport { ensureDocumentEmbeddings, hasEmbedding, similarNotes } from '../embed/query.ts';\nimport { localModelMissing, MODEL_FILENAMES } from '../embed/store.ts';\nimport { SenseError } from '../errors.ts';\nimport { serialQuery } from '../lib/serial-query.ts';\nimport type { Store } from '../store/types.ts';\nimport { resolveNote } from './peek.ts';\nimport { scopedPaths, scopeHasEmbeddings, withMaterializedVectorScope } from './scope.ts';\nimport { assertQuerySnapshot } from './snapshot.ts';\n\nexport const RELATED_DEFAULT_K = 5;\n\n/**\n * Options for {@link relatedNotes}. Scope fields filter result candidates, not the seed note;\n * `k` defaults to 5, matching the CLI.\n */\nexport interface RelatedOptions extends SearchOverrides {\n k?: number;\n}\n\nexport type RelatedResult = {\n path: string;\n similarity: number;\n};\n\nexport async function resolveRelatedSeed(store: Store, pathArg: string): Promise<string> {\n const paths = ((await (await store.prepare('SELECT \"path\" FROM frontmatter')).all()) as Array<{ path: string }>).map((row) => row.path);\n return resolveNote(paths, pathArg);\n}\n\n/**\n * Returns the notes most similar to an indexed seed, excluding the seed and notes linked either\n * way. The seed resolves across the indexed tree even when it is outside the candidate scope.\n */\nexport function relatedNotes(store: Store, cfg: ResolvedConfig, pathArg: string, options: RelatedOptions = {}): Promise<RelatedResult[]> {\n return serialQuery(store, () => relatedIndexed(store, cfg, pathArg, options, options.k ?? RELATED_DEFAULT_K));\n}\n\nasync function relatedIndexed(store: Store, cfg: ResolvedConfig, pathArg: string, overrides: RelatedOptions, k: number): Promise<RelatedResult[]> {\n if (!Number.isFinite(k) || !Number.isInteger(k) || k <= 0) {\n throw new SenseError('SEARCH_OPTION_INVALID', `related option \"k\" must be a positive finite integer, got ${String(k)}`);\n }\n // Vectors are the only signal `related` has, so every way of not having them is an error\n // naming the cause; an empty result means one thing, nothing near in meaning.\n const effective = resolveSearch(cfg, overrides);\n if (!embedEnabled(cfg)) {\n throw new SenseError('EMBED_DISABLED', 'related ranks notes by meaning, and this tree has no embedding model; add an \"embed\" block naming one to sense.config.json (a Hugging Face id fetches automatically at first use; `sense download` prefetches it) -- search works without it, on words and links');\n }\n // search gates on the same signal, so a preset's declared signals mean one thing: without\n // this check an overlapping vectors-on preset would answer for a scope that declined them.\n if (effective.signals.vectors === undefined) {\n throw new SenseError('PRESET_NOT_SEMANTIC', `preset \"${effective.presetName}\" has no \"vectors\" signal, so this scope has no vectors and related has no other signal; search it instead (words and links), or add \"vectors\" to that preset's signals`);\n }\n // A downloadable HF id can be fetched by preparation. Only a local path with missing files\n // can never fetch itself.\n const e = embedConfig(cfg); // embedEnabled(cfg) above guarantees this is set\n if (localModelMissing(e)) {\n throw new SenseError('EMBED_MODEL_MISSING', `related ranks notes by meaning, so it needs the embedding model, but the local model path \"${e.model}\" is missing ${MODEL_FILENAMES}; point embed.model at a directory containing them (search still works without it, on words and links)`);\n }\n\n return store.transaction(async () => {\n await assertQuerySnapshot(store, cfg);\n // Repeat effective preset validation inside the snapshot that supplies its durable scope.\n const current = resolveSearch(cfg, overrides);\n if (current.signals.vectors === undefined) {\n throw new SenseError('PRESET_NOT_SEMANTIC', `preset \"${current.presetName}\" has no \"vectors\" signal, so this scope has no vectors and related has no other signal; search it instead (words and links), or add \"vectors\" to that preset's signals`);\n }\n\n const path = await resolveRelatedSeed(store, pathArg);\n const outbound = ((await (await store.prepare('SELECT DISTINCT dst FROM links WHERE src = ? AND dst IS NOT NULL AND dst != src')).all(path)) as Array<{ dst: string }>).map((r) => r.dst);\n const backlinks = ((await (await store.prepare('SELECT DISTINCT src FROM links WHERE dst = ? AND src != dst')).all(path)) as Array<{ src: string }>).map((r) => r.src);\n const exclude = new Set([path, ...outbound, ...backlinks]);\n const allowed = await scopedPaths(store, cfg, overrides);\n // The seed may sit outside a narrowed candidate scope; both it and every eligible result must\n // be ready, while pending vectors in unrelated notes do not block this operation.\n await ensureDocumentEmbeddings(store, cfg, new Set([...allowed, path]));\n if (!(await hasEmbedding(store, path))) {\n throw new SenseError('NOTE_NOT_EMBEDDED', `${path} has no indexed text to compare -- a note that is frontmatter only, or empty, has nothing to rank by meaning`);\n }\n if (!(await scopeHasEmbeddings(store, cfg, allowed))) return [];\n return withMaterializedVectorScope(store, allowed, () => similarNotes(store, cfg, path, { exclude, allowed, k }));\n });\n}\n"],"names":["RELATED_DEFAULT_K","relatedNotes","resolveRelatedSeed","store","pathArg","paths","prepare","all","map","row","path","resolveNote","cfg","options","serialQuery","relatedIndexed","k","overrides","effective","e","Number","isFinite","isInteger","SenseError","String","resolveSearch","embedEnabled","signals","vectors","undefined","presetName","embedConfig","localModelMissing","MODEL_FILENAMES","model","transaction","current","outbound","backlinks","exclude","allowed","assertQuerySnapshot","r","dst","src","Set","scopedPaths","ensureDocumentEmbeddings","hasEmbedding","scopeHasEmbeddings","withMaterializedVectorScope","similarNotes"],"mappings":";;;;;;;;;;;QAWaA;eAAAA;;QAwBGC;eAAAA;;QATMC;eAAAA;;;aAzBmC,QAAA;aACY,QAAA;aAClB,QAAA;cACxB,QAAA;mBACC,QAAA;YAEA,QAAA;aACiD,QAAA;gBACzC,QAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAE7B,IAAMF,oBAAoB;AAe1B,SAAeE,mBAAmBC,KAAY,EAAEC,OAAe;;YAC9DC;;;;oBAAiB;;wBAAMF,MAAMG,OAAO,CAAC;;;oBAA3B;;wBAAO,cAAuDC,GAAG;;;oBAA3EF,QAAQ,AAAE,cAAiGG,GAAG,CAAC,SAACC;+BAAQA,IAAIC,IAAI;;oBACtI;;wBAAOC,IAAAA,iBAAW,EAACN,OAAOD;;;;IAC5B;;AAMO,SAASH,aAAaE,KAAY,EAAES,GAAmB,EAAER,OAAe;QAAES,UAAAA,iEAA0B,CAAC;IAC1G,OAAOC,IAAAA,wBA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node:path");
|
|
41
|
-
var
|
|
42
|
-
var
|
|
43
|
-
var
|
|
41
|
+
var _index = require("../config/index.js");
|
|
42
|
+
var _columnhint = require("../output/column-hint.js");
|
|
43
|
+
var _vectors = require("../store/vectors.js");
|
|
44
44
|
function _array_like_to_array(arr, len) {
|
|
45
45
|
if (len == null || len > arr.length) len = arr.length;
|
|
46
46
|
for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
|
|
@@ -190,7 +190,7 @@ function _unsupported_iterable_to_array(o, minLen) {
|
|
|
190
190
|
if (typeof o === "string") return _array_like_to_array(o, minLen);
|
|
191
191
|
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
192
192
|
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
193
|
-
if (n === "Map" || n === "Set") return Array.from(
|
|
193
|
+
if (n === "Map" || n === "Set") return Array.from(o);
|
|
194
194
|
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
|
|
195
195
|
}
|
|
196
196
|
var INTERNAL_COLUMNS = new Set([
|
|
@@ -216,7 +216,7 @@ function scopeHasEmbeddings(store, cfg, scopedPaths) {
|
|
|
216
216
|
return _ts_generator(this, function(_state) {
|
|
217
217
|
switch(_state.label){
|
|
218
218
|
case 0:
|
|
219
|
-
if (!(0,
|
|
219
|
+
if (!(0, _index.anyPresetEmbeds)(cfg)) return [
|
|
220
220
|
2,
|
|
221
221
|
false
|
|
222
222
|
]; // the embeddings table doesn't exist at all in this case
|
|
@@ -248,7 +248,7 @@ function rawScope(store, cfg, overrides, allPaths) {
|
|
|
248
248
|
return _ts_generator(this, function(_state) {
|
|
249
249
|
switch(_state.label){
|
|
250
250
|
case 0:
|
|
251
|
-
effective = (0,
|
|
251
|
+
effective = (0, _index.resolveSearch)(cfg, overrides);
|
|
252
252
|
include = effective.include, exclude = effective.exclude;
|
|
253
253
|
adHocScope = overrides.include !== undefined || overrides.exclude !== undefined || overrides.noExclude === true;
|
|
254
254
|
if (!!adHocScope) return [
|
|
@@ -374,7 +374,7 @@ function narrowByWhere(store, paths, where) {
|
|
|
374
374
|
store.docs.columns()
|
|
375
375
|
];
|
|
376
376
|
case 5:
|
|
377
|
-
throw
|
|
377
|
+
throw _columnhint.columnHint.apply(void 0, [
|
|
378
378
|
_state.sent(),
|
|
379
379
|
err
|
|
380
380
|
]);
|
|
@@ -398,7 +398,7 @@ function scopedPaths(store, cfg, overrides) {
|
|
|
398
398
|
return _ts_generator(this, function(_state) {
|
|
399
399
|
switch(_state.label){
|
|
400
400
|
case 0:
|
|
401
|
-
effective = (0,
|
|
401
|
+
effective = (0, _index.resolveSearch)(cfg, overrides);
|
|
402
402
|
_tmp = [
|
|
403
403
|
store
|
|
404
404
|
];
|
|
@@ -458,7 +458,7 @@ function withMaterializedVectorScope(store, allowed, callback, knownTotal) {
|
|
|
458
458
|
return _ts_generator(this, function(_state) {
|
|
459
459
|
switch(_state.label){
|
|
460
460
|
case 0:
|
|
461
|
-
reservation = (0,
|
|
461
|
+
reservation = (0, _vectors.reserveNativeVectorScope)(store.vectors, allowed);
|
|
462
462
|
if (!reservation) return [
|
|
463
463
|
2,
|
|
464
464
|
callback()
|
|
@@ -525,7 +525,7 @@ function withMaterializedVectorScope(store, allowed, callback, knownTotal) {
|
|
|
525
525
|
]);
|
|
526
526
|
return [
|
|
527
527
|
4,
|
|
528
|
-
materializeScope(store,
|
|
528
|
+
materializeScope(store, _vectors.NATIVE_VECTOR_SCOPE_TABLE, allowed)
|
|
529
529
|
];
|
|
530
530
|
case 7:
|
|
531
531
|
_state.sent();
|
|
@@ -561,7 +561,7 @@ function withMaterializedVectorScope(store, allowed, callback, knownTotal) {
|
|
|
561
561
|
reservation.deactivate();
|
|
562
562
|
return [
|
|
563
563
|
4,
|
|
564
|
-
store.exec("DROP TABLE IF EXISTS ".concat(
|
|
564
|
+
store.exec("DROP TABLE IF EXISTS ".concat(_vectors.NATIVE_VECTOR_SCOPE_TABLE))
|
|
565
565
|
];
|
|
566
566
|
case 12:
|
|
567
567
|
_state.sent();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/Users/kevin/Dev/open-source/ai/sensemaking/src/commands/scope.ts"],"sourcesContent":["import { matchesGlob } from 'node:path';\nimport type { ResolvedConfig, SearchOverrides } from '../config/index.ts';\nimport { anyPresetEmbeds, resolveSearch } from '../config/index.ts';\nimport { columnHint } from '../output/column-hint.ts';\nimport type { Store } from '../store/types.ts';\nimport { NATIVE_VECTOR_SCOPE_TABLE, reserveNativeVectorScope } from '../store/vectors.ts';\n\nexport const INTERNAL_COLUMNS = new Set(['path', '_mtime', '_ctime', '_size', '_rank', '_parse_error']);\n\n// node:path's matchesGlob is experimental (stable behind an unstable-API flag) at the\n// Node >=22.20 engines floor; used here in JS rather than a directory walk in the query path.\nexport function inScope(path: string, include: string[], exclude?: string[]): boolean {\n if (!include.some((g) => matchesGlob(path, g))) return false;\n if (exclude?.some((g) => matchesGlob(path, g))) return false;\n return true;\n}\n\nexport async function scopeHasEmbeddings(store: Store, cfg: ResolvedConfig, scopedPaths: Set<string>): Promise<boolean> {\n if (!anyPresetEmbeds(cfg)) return false; // the embeddings table doesn't exist at all in this case\n const stmt = await store.prepare('SELECT DISTINCT \"path\" FROM embeddings WHERE vector IS NOT NULL');\n const rows = (await stmt.all()) as Array<{ path: string }>;\n return rows.some((r) => scopedPaths.has(r.path));\n}\n\n// Scope only (no --where): preset_files for a named preset, JS glob matching for an ad hoc\n// include/exclude override. Shared by scopedPaths() and search()'s candidate-pool sizing.\nexport async function rawScope(store: Store, cfg: ResolvedConfig, overrides: SearchOverrides, allPaths?: string[]): Promise<Set<string>> {\n const effective = resolveSearch(cfg, overrides);\n const { include, exclude } = effective;\n const adHocScope = overrides.include !== undefined || overrides.exclude !== undefined || overrides.noExclude === true;\n if (!adHocScope) {\n const stmt = await store.prepare('SELECT \"path\" FROM preset_files WHERE preset = ?');\n return new Set(((await stmt.all(effective.presetName)) as Array<{ path: string }>).map((r) => r.path));\n }\n const paths = allPaths ?? (await allFrontmatterPaths(store));\n return new Set(paths.filter((p) => inScope(p, include, exclude)));\n}\n\nasync function allFrontmatterPaths(store: Store): Promise<string[]> {\n const stmt = await store.prepare('SELECT \"path\" FROM frontmatter');\n return ((await stmt.all()) as Array<{ path: string }>).map((r) => r.path);\n}\n\nexport async function narrowByWhere(store: Store, paths: Set<string>, where: string | undefined): Promise<Set<string>> {\n if (!where) return paths;\n let whereRows: Array<{ path: string }>;\n try {\n const stmt = await store.prepare(`SELECT \"path\" FROM frontmatter f WHERE (${where})`);\n whereRows = (await stmt.all()) as Array<{ path: string }>;\n } catch (err) {\n throw columnHint(await store.docs.columns(), err as Error);\n }\n const wherePaths = new Set(whereRows.map((r) => r.path));\n return new Set([...paths].filter((p) => wherePaths.has(p)));\n}\n\n// The scope resolver for non-search commands (path, peek, map): same coverage rule search()\n// applies, then narrowed by the resolved `where`.\nexport async function scopedPaths(store: Store, cfg: ResolvedConfig, overrides: SearchOverrides): Promise<Set<string>> {\n const effective = resolveSearch(cfg, overrides);\n return narrowByWhere(store, await rawScope(store, cfg, overrides), effective.where);\n}\n\n// Materializes a path set into a named temp table (same shape as traverse.ts's allowed_nodes)\n// so a query can join/filter against it cheaply instead of binding a parameter per path.\nexport async function materializeScope(store: Store, table: string, paths: Set<string>): Promise<void> {\n await store.exec(`DROP TABLE IF EXISTS ${table}`);\n await store.exec(`CREATE TEMP TABLE ${table} (\"path\" TEXT PRIMARY KEY)`);\n await store.runBatch(\n `INSERT INTO ${table} (\"path\") VALUES (?)`,\n [...paths].map((p) => [p])\n );\n}\n\n// Native vector adapters can consume a small exact scope through their connection-local temp\n// table. The reservation is tied to this Store's VectorStore wrapper, so another Store cannot\n// activate it by receiving the same Set object.\nexport async function withMaterializedVectorScope<T>(store: Store, allowed: Set<string>, callback: () => Promise<T>, knownTotal?: number): Promise<T> {\n const reservation = reserveNativeVectorScope(store.vectors, allowed);\n if (!reservation) return callback();\n\n if (allowed.size === 0) {\n reservation.invalidate();\n return callback();\n }\n\n let total = knownTotal;\n if (total === undefined) {\n try {\n const stmt = await store.prepare('SELECT COUNT(*) AS count FROM frontmatter');\n const row = (await stmt.get()) as { count: number | bigint };\n total = Number(row.count);\n } catch (err) {\n reservation.invalidate();\n throw err;\n }\n }\n // Materialization only buys work when this is a nonempty true narrowing and the allowed side\n // is no larger than its complement. Direct adapter calls and broader scopes retain JS filtering.\n if (allowed.size >= total || allowed.size > total - allowed.size) {\n reservation.invalidate();\n return callback();\n }\n\n let operationFailed = false;\n let operationError: unknown;\n let result!: T;\n try {\n await materializeScope(store, NATIVE_VECTOR_SCOPE_TABLE, allowed);\n reservation.activate();\n result = await callback();\n } catch (err) {\n operationFailed = true;\n operationError = err;\n }\n\n let cleanupFailed = false;\n let cleanupError: unknown;\n try {\n reservation.deactivate();\n await store.exec(`DROP TABLE IF EXISTS ${NATIVE_VECTOR_SCOPE_TABLE}`);\n } catch (err) {\n cleanupFailed = true;\n cleanupError = err;\n } finally {\n reservation.invalidate();\n }\n\n if (operationFailed && cleanupFailed) throw new AggregateError([operationError, cleanupError], 'native vector scope operation and cleanup failed');\n if (operationFailed) throw operationError;\n if (cleanupFailed) throw cleanupError;\n return result;\n}\n\nexport async function setupMapScope(store: Store, paths: Set<string>): Promise<void> {\n await materializeScope(store, '_map_scope', paths);\n}\n"],"names":["INTERNAL_COLUMNS","inScope","materializeScope","narrowByWhere","rawScope","scopeHasEmbeddings","scopedPaths","setupMapScope","withMaterializedVectorScope","Set","path","include","exclude","some","g","matchesGlob","store","cfg","stmt","rows","anyPresetEmbeds","prepare","all","r","has","overrides","allPaths","effective","adHocScope","paths","resolveSearch","undefined","noExclude","presetName","map","allFrontmatterPaths","filter","p","where","whereRows","err","wherePaths","docs","columns","columnHint","table","exec","runBatch","allowed","callback","knownTotal","reservation","total","row","operationFailed","operationError","result","cleanupFailed","cleanupError","reserveNativeVectorScope","vectors","size","invalidate","get","Number","count","NATIVE_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ACA;;wBAAMA,KAAK6C,GAAG;;;oBAArBV,MAAO;oBACbD,QAAQY,OAAOX,IAAIY,KAAK;;;;;;oBACjBzB;oBACPW,YAAYW,UAAU;oBACtB,MAAMtB;;oBAGV,6FAA6F;oBAC7F,iGAAiG;oBACjG,IAAIQ,QAAQa,IAAI,IAAIT,SAASJ,QAAQa,IAAI,GAAGT,QAAQJ,QAAQa,IAAI,EAAE;wBAChEV,YAAYW,UAAU;wBACtB;;4BAAOb;;oBACT;oBAEIK,kBAAkB;;;;;;;;;oBAIpB;;wBAAMpD,iBAAiBc,OAAOkD,oCAAyB,EAAElB;;;oBAAzD;oBACAG,YAAYgB,QAAQ;oBACX;;wBAAMlB;;;oBAAfO,SAAS;;;;;;oBACFhB;oBACPc,kBAAkB;oBAClBC,iBAAiBf;;;;;;oBAGfiB,gBAAgB;;;;;;;;;oBAGlBN,YAAYiB,UAAU;oBACtB;;wBAAMpD,MAAM8B,IAAI,CAAC,AAAC,wBAAiD,OAA1BoB,oCAAyB;;;oBAAlE;;;;;;oBACO1B;oBACPiB,gBAAgB;oBAChBC,eAAelB;;;;;;oBAEfW,YAAYW,UAAU;;;;;oBAGxB,IAAIR,mBAAmBG,eAAe,MAAM,IAAIY;wBAAgBd;wBAAgBG;uBAAe;oBAC/F,IAAIJ,iBAAiB,MAAMC;oBAC3B,IAAIE,eAAe,MAAMC;oBACzB;;wBAAOF;;;;IACT;;AAEO,SAAejD,cAAcS,KAAY,EAAEa,KAAkB;;;;;oBAClE;;wBAAM3B,iBAAiBc,OAAO,cAAca;;;oBAA5C;;;;;;IACF"}
|
|
1
|
+
{"version":3,"sources":["/Users/kevin/Dev/open-source/ai/sensemaking/src/commands/scope.ts"],"sourcesContent":["import { matchesGlob } from 'node:path';\nimport type { ResolvedConfig, SearchOverrides } from '../config/index.ts';\nimport { anyPresetEmbeds, resolveSearch } from '../config/index.ts';\nimport { columnHint } from '../output/column-hint.ts';\nimport type { Store } from '../store/types.ts';\nimport { NATIVE_VECTOR_SCOPE_TABLE, reserveNativeVectorScope } from '../store/vectors.ts';\n\nexport const INTERNAL_COLUMNS = new Set(['path', '_mtime', '_ctime', '_size', '_rank', '_parse_error']);\n\n// node:path's matchesGlob is experimental (stable behind an unstable-API flag) at the\n// Node >=22.20 engines floor; used here in JS rather than a directory walk in the query path.\nexport function inScope(path: string, include: string[], exclude?: string[]): boolean {\n if (!include.some((g) => matchesGlob(path, g))) return false;\n if (exclude?.some((g) => matchesGlob(path, g))) return false;\n return true;\n}\n\nexport async function scopeHasEmbeddings(store: Store, cfg: ResolvedConfig, scopedPaths: Set<string>): Promise<boolean> {\n if (!anyPresetEmbeds(cfg)) return false; // the embeddings table doesn't exist at all in this case\n const stmt = await store.prepare('SELECT DISTINCT \"path\" FROM embeddings WHERE vector IS NOT NULL');\n const rows = (await stmt.all()) as Array<{ path: string }>;\n return rows.some((r) => scopedPaths.has(r.path));\n}\n\n// Scope only (no --where): preset_files for a named preset, JS glob matching for an ad hoc\n// include/exclude override. Shared by scopedPaths() and search()'s candidate-pool sizing.\nexport async function rawScope(store: Store, cfg: ResolvedConfig, overrides: SearchOverrides, allPaths?: string[]): Promise<Set<string>> {\n const effective = resolveSearch(cfg, overrides);\n const { include, exclude } = effective;\n const adHocScope = overrides.include !== undefined || overrides.exclude !== undefined || overrides.noExclude === true;\n if (!adHocScope) {\n const stmt = await store.prepare('SELECT \"path\" FROM preset_files WHERE preset = ?');\n return new Set(((await stmt.all(effective.presetName)) as Array<{ path: string }>).map((r) => r.path));\n }\n const paths = allPaths ?? (await allFrontmatterPaths(store));\n return new Set(paths.filter((p) => inScope(p, include, exclude)));\n}\n\nasync function allFrontmatterPaths(store: Store): Promise<string[]> {\n const stmt = await store.prepare('SELECT \"path\" FROM frontmatter');\n return ((await stmt.all()) as Array<{ path: string }>).map((r) => r.path);\n}\n\nexport async function narrowByWhere(store: Store, paths: Set<string>, where: string | undefined): Promise<Set<string>> {\n if (!where) return paths;\n let whereRows: Array<{ path: string }>;\n try {\n const stmt = await store.prepare(`SELECT \"path\" FROM frontmatter f WHERE (${where})`);\n whereRows = (await stmt.all()) as Array<{ path: string }>;\n } catch (err) {\n throw columnHint(await store.docs.columns(), err as Error);\n }\n const wherePaths = new Set(whereRows.map((r) => r.path));\n return new Set([...paths].filter((p) => wherePaths.has(p)));\n}\n\n// The scope resolver for non-search commands (path, peek, map): same coverage rule search()\n// applies, then narrowed by the resolved `where`.\nexport async function scopedPaths(store: Store, cfg: ResolvedConfig, overrides: SearchOverrides): Promise<Set<string>> {\n const effective = resolveSearch(cfg, overrides);\n return narrowByWhere(store, await rawScope(store, cfg, overrides), effective.where);\n}\n\n// Materializes a path set into a named temp table (same shape as traverse.ts's allowed_nodes)\n// so a query can join/filter against it cheaply instead of binding a parameter per path.\nexport async function materializeScope(store: Store, table: string, paths: Set<string>): Promise<void> {\n await store.exec(`DROP TABLE IF EXISTS ${table}`);\n await store.exec(`CREATE TEMP TABLE ${table} (\"path\" TEXT PRIMARY KEY)`);\n await store.runBatch(\n `INSERT INTO ${table} (\"path\") VALUES (?)`,\n [...paths].map((p) => [p])\n );\n}\n\n// Native vector adapters can consume a small exact scope through their connection-local temp\n// table. The reservation is tied to this Store's VectorStore wrapper, so another Store cannot\n// activate it by receiving the same Set object.\nexport async function withMaterializedVectorScope<T>(store: Store, allowed: Set<string>, callback: () => Promise<T>, knownTotal?: number): Promise<T> {\n const reservation = reserveNativeVectorScope(store.vectors, allowed);\n if (!reservation) return callback();\n\n if (allowed.size === 0) {\n reservation.invalidate();\n return callback();\n }\n\n let total = knownTotal;\n if (total === undefined) {\n try {\n const stmt = await store.prepare('SELECT COUNT(*) AS count FROM frontmatter');\n const row = (await stmt.get()) as { count: number | bigint };\n total = Number(row.count);\n } catch (err) {\n reservation.invalidate();\n throw err;\n }\n }\n // Materialization only buys work when this is a nonempty true narrowing and the allowed side\n // is no larger than its complement. Direct adapter calls and broader scopes retain JS filtering.\n if (allowed.size >= total || allowed.size > total - allowed.size) {\n reservation.invalidate();\n return callback();\n }\n\n let operationFailed = false;\n let operationError: unknown;\n let result!: T;\n try {\n await materializeScope(store, NATIVE_VECTOR_SCOPE_TABLE, allowed);\n reservation.activate();\n result = await callback();\n } catch (err) {\n operationFailed = true;\n operationError = err;\n }\n\n let cleanupFailed = false;\n let cleanupError: unknown;\n try {\n reservation.deactivate();\n await store.exec(`DROP TABLE IF EXISTS ${NATIVE_VECTOR_SCOPE_TABLE}`);\n } catch (err) {\n cleanupFailed = true;\n cleanupError = err;\n } finally {\n reservation.invalidate();\n }\n\n if (operationFailed && cleanupFailed) throw new AggregateError([operationError, cleanupError], 'native vector scope operation and cleanup failed');\n if (operationFailed) throw operationError;\n if (cleanupFailed) throw cleanupError;\n return result;\n}\n\nexport async function setupMapScope(store: Store, paths: Set<string>): Promise<void> {\n await materializeScope(store, '_map_scope', paths);\n}\n"],"names":["INTERNAL_COLUMNS","inScope","materializeScope","narrowByWhere","rawScope","scopeHasEmbeddings","scopedPaths","setupMapScope","withMaterializedVectorScope","Set","path","include","exclude","some","g","matchesGlob","store","cfg","stmt","rows","anyPresetEmbeds","prepare","all","r","has","overrides","allPaths","effective","adHocScope","paths","resolveSearch","undefined","noExclude","presetName","map","allFrontmatterPaths","filter","p","where","whereRows","err","wherePaths","docs","columns","columnHint","table","exec","runBatch","allowed","callback","knownTotal","reservation","total","row","operationFailed","operationError","result","cleanupFailed","cleanupError","reserveNativeVectorScope","vectors","size","invalidate","get","Number","count","NATIVE_VECTOR_SCOPE_TABLE","activate","deactivate","AggregateError"],"mappings":";;;;;;;;;;;QAOaA;eAAAA;;QAIGC;eAAAA;;QAsDMC;eAAAA;;QAtBAC;eAAAA;;QAjBAC;eAAAA;;QATAC;eAAAA;;QAyCAC;eAAAA;;QA4EAC;eAAAA;;QAzDAC;eAAAA;;;gBA7EM,QAAA;aAEmB,QAAA;kBACpB,QAAA;eAEyC,QAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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