sensemaking 0.15.4 → 0.17.0
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/README.md +33 -5
- package/dist/cjs/chunk/extract.d.cts +2 -0
- package/dist/cjs/chunk/extract.d.ts +2 -0
- package/dist/cjs/chunk/extract.js +139 -0
- package/dist/cjs/chunk/extract.js.map +1 -0
- package/dist/cjs/chunk/group.d.cts +4 -0
- package/dist/cjs/chunk/group.d.ts +4 -0
- package/dist/cjs/chunk/group.js +489 -0
- package/dist/cjs/chunk/group.js.map +1 -0
- package/dist/cjs/chunk/index.d.cts +8 -0
- package/dist/cjs/chunk/index.d.ts +8 -0
- package/dist/cjs/chunk/index.js +44 -0
- package/dist/cjs/chunk/index.js.map +1 -0
- package/dist/cjs/chunk/parse.d.cts +2 -0
- package/dist/cjs/chunk/parse.d.ts +2 -0
- package/dist/cjs/chunk/parse.js +71 -0
- package/dist/cjs/chunk/parse.js.map +1 -0
- package/dist/cjs/chunk/types.d.cts +19 -0
- package/dist/cjs/chunk/types.d.ts +19 -0
- package/dist/cjs/chunk/types.js +5 -0
- package/dist/cjs/chunk/types.js.map +1 -0
- package/dist/cjs/chunk/version.d.cts +1 -0
- package/dist/cjs/chunk/version.d.ts +1 -0
- package/dist/cjs/chunk/version.js +14 -0
- package/dist/cjs/chunk/version.js.map +1 -0
- package/dist/cjs/cli/download.js +12 -11
- package/dist/cjs/cli/download.js.map +1 -1
- package/dist/cjs/cli/index.d.cts +1 -1
- package/dist/cjs/cli/index.d.ts +1 -1
- package/dist/cjs/cli/index.js +1 -1
- package/dist/cjs/cli/index.js.map +1 -1
- package/dist/cjs/cli/init.js +31 -5
- package/dist/cjs/cli/init.js.map +1 -1
- package/dist/cjs/cli/map.js +1 -1
- package/dist/cjs/cli/map.js.map +1 -1
- package/dist/cjs/cli/named.js +1 -1
- package/dist/cjs/cli/named.js.map +1 -1
- package/dist/cjs/cli/path.js +2 -2
- package/dist/cjs/cli/path.js.map +1 -1
- package/dist/cjs/cli/peek.js +1 -1
- package/dist/cjs/cli/peek.js.map +1 -1
- package/dist/cjs/cli/related.js +1 -1
- package/dist/cjs/cli/related.js.map +1 -1
- package/dist/cjs/cli/search.js +1 -1
- package/dist/cjs/cli/search.js.map +1 -1
- package/dist/cjs/cli/shared.d.cts +1 -1
- package/dist/cjs/cli/shared.d.ts +1 -1
- package/dist/cjs/cli/shared.js +3 -3
- package/dist/cjs/cli/shared.js.map +1 -1
- package/dist/cjs/cli/status.js +344 -100
- package/dist/cjs/cli/status.js.map +1 -1
- package/dist/cjs/commands/map.d.cts +1 -1
- package/dist/cjs/commands/map.d.ts +1 -1
- package/dist/cjs/commands/map.js.map +1 -1
- package/dist/cjs/commands/peek.d.cts +1 -1
- package/dist/cjs/commands/peek.d.ts +1 -1
- package/dist/cjs/commands/peek.js +13 -6
- package/dist/cjs/commands/peek.js.map +1 -1
- package/dist/cjs/commands/related.js +17 -13
- package/dist/cjs/commands/related.js.map +1 -1
- package/dist/cjs/commands/scope.js +1 -1
- package/dist/cjs/commands/scope.js.map +1 -1
- package/dist/cjs/commands/search.d.cts +1 -1
- package/dist/cjs/commands/search.d.ts +1 -1
- package/dist/cjs/commands/search.js +28 -99
- package/dist/cjs/commands/search.js.map +1 -1
- package/dist/cjs/commands/signals.d.cts +18 -0
- package/dist/cjs/commands/signals.d.ts +18 -0
- package/dist/cjs/commands/signals.js +299 -0
- package/dist/cjs/commands/signals.js.map +1 -0
- package/dist/cjs/commands/status.d.cts +2 -2
- package/dist/cjs/commands/status.d.ts +2 -2
- package/dist/cjs/commands/status.js +1 -1
- package/dist/cjs/commands/status.js.map +1 -1
- package/dist/cjs/config/access.d.cts +8 -3
- package/dist/cjs/config/access.d.ts +8 -3
- package/dist/cjs/config/access.js +35 -17
- package/dist/cjs/config/access.js.map +1 -1
- package/dist/cjs/config/index.d.cts +5 -1
- package/dist/cjs/config/index.d.ts +5 -1
- package/dist/cjs/config/index.js +16 -2
- package/dist/cjs/config/index.js.map +1 -1
- package/dist/cjs/config/load.d.cts +6 -1
- package/dist/cjs/config/load.d.ts +6 -1
- package/dist/cjs/config/load.js +83 -8
- package/dist/cjs/config/load.js.map +1 -1
- package/dist/cjs/config/resolve.js +1 -1
- package/dist/cjs/config/resolve.js.map +1 -1
- package/dist/cjs/config/signals.d.cts +4 -0
- package/dist/cjs/config/signals.d.ts +4 -0
- package/dist/cjs/config/signals.js +30 -0
- package/dist/cjs/config/signals.js.map +1 -0
- package/dist/cjs/config/types.d.cts +7 -4
- package/dist/cjs/config/types.d.ts +7 -4
- package/dist/cjs/config/types.js +1 -1
- package/dist/cjs/config/types.js.map +1 -1
- package/dist/cjs/config/validate.d.cts +1 -0
- package/dist/cjs/config/validate.d.ts +1 -0
- package/dist/cjs/config/validate.js +127 -11
- package/dist/cjs/config/validate.js.map +1 -1
- package/dist/cjs/db/open.d.cts +1 -1
- package/dist/cjs/db/open.d.ts +1 -1
- package/dist/cjs/db/open.js +9 -4
- package/dist/cjs/db/open.js.map +1 -1
- package/dist/cjs/db/reconcile.d.cts +1 -0
- package/dist/cjs/db/reconcile.d.ts +1 -0
- package/dist/cjs/db/reconcile.js +23 -8
- package/dist/cjs/db/reconcile.js.map +1 -1
- package/dist/cjs/{sql-functions.js → db/sql-functions.js} +1 -1
- package/dist/cjs/db/sql-functions.js.map +1 -0
- package/dist/cjs/embed/cohere.d.cts +2 -0
- package/dist/cjs/embed/cohere.d.ts +2 -0
- package/dist/cjs/embed/cohere.js +238 -0
- package/dist/cjs/embed/cohere.js.map +1 -0
- package/dist/cjs/embed/http.d.cts +2 -0
- package/dist/cjs/embed/http.d.ts +2 -0
- package/dist/cjs/embed/http.js +258 -0
- package/dist/cjs/embed/http.js.map +1 -0
- package/dist/cjs/embed/identity.d.cts +13 -0
- package/dist/cjs/embed/identity.d.ts +13 -0
- package/dist/cjs/embed/identity.js +194 -0
- package/dist/cjs/embed/identity.js.map +1 -0
- package/dist/cjs/embed/langfit.d.cts +6 -0
- package/dist/cjs/embed/langfit.d.ts +6 -0
- package/dist/cjs/embed/langfit.js +286 -0
- package/dist/cjs/embed/langfit.js.map +1 -0
- package/dist/cjs/embed/languages.d.cts +3 -0
- package/dist/cjs/embed/languages.d.ts +3 -0
- package/dist/cjs/embed/languages.js +98 -0
- package/dist/cjs/embed/languages.js.map +1 -0
- package/dist/cjs/embed/openai.d.cts +2 -0
- package/dist/cjs/embed/openai.d.ts +2 -0
- package/dist/cjs/embed/openai.js +268 -0
- package/dist/cjs/embed/openai.js.map +1 -0
- package/dist/cjs/embed/query.d.cts +21 -0
- package/dist/cjs/embed/query.d.ts +21 -0
- package/dist/cjs/embed/query.js +610 -0
- package/dist/cjs/embed/query.js.map +1 -0
- package/dist/cjs/embed/registry.d.cts +3 -0
- package/dist/cjs/embed/registry.d.ts +3 -0
- package/dist/cjs/embed/registry.js +114 -0
- package/dist/cjs/embed/registry.js.map +1 -0
- package/dist/cjs/embed/static.d.cts +2 -0
- package/dist/cjs/embed/static.d.ts +2 -0
- package/dist/cjs/embed/static.js +330 -0
- package/dist/cjs/embed/static.js.map +1 -0
- package/dist/cjs/embed/store.d.cts +8 -0
- package/dist/cjs/embed/store.d.ts +8 -0
- package/dist/cjs/embed/store.js +498 -0
- package/dist/cjs/embed/store.js.map +1 -0
- package/dist/cjs/embed/types.d.cts +8 -0
- package/dist/cjs/embed/types.d.ts +8 -0
- package/dist/cjs/embed/types.js +7 -0
- package/dist/cjs/embed/types.js.map +1 -0
- package/dist/cjs/errors.d.cts +1 -1
- package/dist/cjs/errors.d.ts +1 -1
- package/dist/cjs/errors.js.map +1 -1
- package/dist/cjs/features/embed.d.cts +2 -28
- package/dist/cjs/features/embed.d.ts +2 -28
- package/dist/cjs/features/embed.js +39 -1027
- package/dist/cjs/features/embed.js.map +1 -1
- package/dist/cjs/{fences.js → features/fences.js} +1 -1
- package/dist/cjs/features/fences.js.map +1 -0
- package/dist/cjs/features/links.js +1 -1
- package/dist/cjs/features/links.js.map +1 -1
- package/dist/cjs/features/rank.js +1 -1
- package/dist/cjs/features/rank.js.map +1 -1
- package/dist/cjs/features/sections.js +4 -3
- package/dist/cjs/features/sections.js.map +1 -1
- package/dist/cjs/features/tags.js +1 -1
- package/dist/cjs/features/tags.js.map +1 -1
- package/dist/cjs/features/types.d.cts +4 -2
- package/dist/cjs/features/types.d.ts +4 -2
- package/dist/cjs/graph/graph.js.map +1 -0
- package/dist/cjs/graph/traverse.js.map +1 -0
- package/dist/cjs/index.d.cts +4 -4
- package/dist/cjs/index.d.ts +4 -4
- package/dist/cjs/index.js +4 -1
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/output/column-hint.js.map +1 -0
- package/dist/cjs/{output.d.cts → output/output.d.cts} +2 -2
- package/dist/cjs/{output.d.ts → output/output.d.ts} +2 -2
- package/dist/cjs/{output.js → output/output.js} +9 -2
- package/dist/cjs/output/output.js.map +1 -0
- package/dist/cjs/output/progress.js.map +1 -0
- package/dist/cjs/{search-error.js → output/search-error.js} +1 -1
- package/dist/cjs/output/search-error.js.map +1 -0
- package/dist/cjs/scan/frontmatter.d.cts +13 -0
- package/dist/cjs/scan/frontmatter.d.ts +13 -0
- package/dist/cjs/scan/frontmatter.js +229 -0
- package/dist/cjs/scan/frontmatter.js.map +1 -0
- package/dist/cjs/scan/index.d.cts +25 -0
- package/dist/cjs/scan/index.d.ts +25 -0
- package/dist/cjs/scan/index.js +107 -0
- package/dist/cjs/scan/index.js.map +1 -0
- package/dist/cjs/scan/list.d.cts +12 -0
- package/dist/cjs/scan/list.d.ts +12 -0
- package/dist/cjs/scan/list.js +154 -0
- package/dist/cjs/scan/list.js.map +1 -0
- package/dist/cjs/text/segment.d.cts +3 -0
- package/dist/cjs/text/segment.d.ts +3 -0
- package/dist/cjs/text/segment.js +154 -0
- package/dist/cjs/text/segment.js.map +1 -0
- package/dist/cjs/text/strip.d.cts +3 -0
- package/dist/cjs/text/strip.d.ts +3 -0
- package/dist/cjs/text/strip.js +32 -0
- package/dist/cjs/text/strip.js.map +1 -0
- package/dist/esm/chunk/extract.d.ts +2 -0
- package/dist/esm/chunk/extract.js +114 -0
- package/dist/esm/chunk/extract.js.map +1 -0
- package/dist/esm/chunk/group.d.ts +4 -0
- package/dist/esm/chunk/group.js +253 -0
- package/dist/esm/chunk/group.js.map +1 -0
- package/dist/esm/chunk/index.d.ts +8 -0
- package/dist/esm/chunk/index.js +16 -0
- package/dist/esm/chunk/index.js.map +1 -0
- package/dist/esm/chunk/parse.d.ts +2 -0
- package/dist/esm/chunk/parse.js +63 -0
- package/dist/esm/chunk/parse.js.map +1 -0
- package/dist/esm/chunk/types.d.ts +19 -0
- package/dist/esm/chunk/types.js +2 -0
- package/dist/esm/chunk/types.js.map +1 -0
- package/dist/esm/chunk/version.d.ts +1 -0
- package/dist/esm/chunk/version.js +3 -0
- package/dist/esm/chunk/version.js.map +1 -0
- package/dist/esm/cli/download.js +9 -8
- package/dist/esm/cli/download.js.map +1 -1
- package/dist/esm/cli/index.d.ts +1 -1
- package/dist/esm/cli/index.js +1 -1
- package/dist/esm/cli/index.js.map +1 -1
- package/dist/esm/cli/init.js +32 -6
- package/dist/esm/cli/init.js.map +1 -1
- package/dist/esm/cli/map.js +1 -1
- package/dist/esm/cli/map.js.map +1 -1
- package/dist/esm/cli/named.js +1 -1
- package/dist/esm/cli/named.js.map +1 -1
- package/dist/esm/cli/path.js +2 -2
- package/dist/esm/cli/path.js.map +1 -1
- package/dist/esm/cli/peek.js +1 -1
- package/dist/esm/cli/peek.js.map +1 -1
- package/dist/esm/cli/related.js +1 -1
- package/dist/esm/cli/related.js.map +1 -1
- package/dist/esm/cli/search.js +1 -1
- package/dist/esm/cli/search.js.map +1 -1
- package/dist/esm/cli/shared.d.ts +1 -1
- package/dist/esm/cli/shared.js +3 -3
- package/dist/esm/cli/shared.js.map +1 -1
- package/dist/esm/cli/status.js +37 -9
- package/dist/esm/cli/status.js.map +1 -1
- package/dist/esm/commands/map.d.ts +1 -1
- package/dist/esm/commands/map.js.map +1 -1
- package/dist/esm/commands/peek.d.ts +1 -1
- package/dist/esm/commands/peek.js +8 -1
- package/dist/esm/commands/peek.js.map +1 -1
- package/dist/esm/commands/related.js +14 -10
- package/dist/esm/commands/related.js.map +1 -1
- package/dist/esm/commands/scope.js +1 -1
- package/dist/esm/commands/scope.js.map +1 -1
- package/dist/esm/commands/search.d.ts +1 -1
- package/dist/esm/commands/search.js +30 -81
- package/dist/esm/commands/search.js.map +1 -1
- package/dist/esm/commands/signals.d.ts +18 -0
- package/dist/esm/commands/signals.js +78 -0
- package/dist/esm/commands/signals.js.map +1 -0
- package/dist/esm/commands/status.d.ts +2 -2
- package/dist/esm/commands/status.js +2 -2
- package/dist/esm/commands/status.js.map +1 -1
- package/dist/esm/config/access.d.ts +8 -3
- package/dist/esm/config/access.js +34 -15
- package/dist/esm/config/access.js.map +1 -1
- package/dist/esm/config/index.d.ts +5 -1
- package/dist/esm/config/index.js +3 -1
- package/dist/esm/config/index.js.map +1 -1
- package/dist/esm/config/load.d.ts +6 -1
- package/dist/esm/config/load.js +67 -9
- package/dist/esm/config/load.js.map +1 -1
- package/dist/esm/config/resolve.js +2 -2
- package/dist/esm/config/resolve.js.map +1 -1
- package/dist/esm/config/signals.d.ts +4 -0
- package/dist/esm/config/signals.js +14 -0
- package/dist/esm/config/signals.js.map +1 -0
- package/dist/esm/config/types.d.ts +7 -4
- package/dist/esm/config/types.js +1 -1
- package/dist/esm/config/types.js.map +1 -1
- package/dist/esm/config/validate.d.ts +1 -0
- package/dist/esm/config/validate.js +65 -12
- package/dist/esm/config/validate.js.map +1 -1
- package/dist/esm/db/open.d.ts +1 -1
- package/dist/esm/db/open.js +11 -6
- package/dist/esm/db/open.js.map +1 -1
- package/dist/esm/db/reconcile.d.ts +1 -0
- package/dist/esm/db/reconcile.js +14 -4
- package/dist/esm/db/reconcile.js.map +1 -1
- package/dist/esm/{sql-functions.js → db/sql-functions.js} +1 -1
- package/dist/esm/db/sql-functions.js.map +1 -0
- package/dist/esm/embed/cohere.d.ts +2 -0
- package/dist/esm/embed/cohere.js +46 -0
- package/dist/esm/embed/cohere.js.map +1 -0
- package/dist/esm/embed/http.d.ts +2 -0
- package/dist/esm/embed/http.js +33 -0
- package/dist/esm/embed/http.js.map +1 -0
- package/dist/esm/embed/identity.d.ts +13 -0
- package/dist/esm/embed/identity.js +92 -0
- package/dist/esm/embed/identity.js.map +1 -0
- package/dist/esm/embed/langfit.d.ts +6 -0
- package/dist/esm/embed/langfit.js +44 -0
- package/dist/esm/embed/langfit.js.map +1 -0
- package/dist/esm/embed/languages.d.ts +3 -0
- package/dist/esm/embed/languages.js +80 -0
- package/dist/esm/embed/languages.js.map +1 -0
- package/dist/esm/embed/openai.d.ts +2 -0
- package/dist/esm/embed/openai.js +49 -0
- package/dist/esm/embed/openai.js.map +1 -0
- package/dist/esm/embed/query.d.ts +21 -0
- package/dist/esm/embed/query.js +181 -0
- package/dist/esm/embed/query.js.map +1 -0
- package/dist/esm/embed/registry.d.ts +3 -0
- package/dist/esm/embed/registry.js +45 -0
- package/dist/esm/embed/registry.js.map +1 -0
- package/dist/esm/embed/static.d.ts +2 -0
- package/dist/esm/embed/static.js +71 -0
- package/dist/esm/embed/static.js.map +1 -0
- package/dist/esm/embed/store.d.ts +8 -0
- package/dist/esm/embed/store.js +123 -0
- package/dist/esm/embed/store.js.map +1 -0
- package/dist/esm/embed/types.d.ts +8 -0
- package/dist/esm/embed/types.js +3 -0
- package/dist/esm/embed/types.js.map +1 -0
- package/dist/esm/errors.d.ts +1 -1
- package/dist/esm/errors.js.map +1 -1
- package/dist/esm/features/embed.d.ts +2 -28
- package/dist/esm/features/embed.js +33 -377
- package/dist/esm/features/embed.js.map +1 -1
- package/dist/esm/{fences.js → features/fences.js} +1 -1
- package/dist/esm/features/fences.js.map +1 -0
- package/dist/esm/features/links.js +1 -1
- package/dist/esm/features/links.js.map +1 -1
- package/dist/esm/features/rank.js +1 -1
- package/dist/esm/features/rank.js.map +1 -1
- package/dist/esm/features/sections.js +4 -3
- package/dist/esm/features/sections.js.map +1 -1
- package/dist/esm/features/tags.js +1 -1
- package/dist/esm/features/tags.js.map +1 -1
- package/dist/esm/features/types.d.ts +4 -2
- package/dist/esm/features/types.js.map +1 -1
- package/dist/esm/graph/graph.js.map +1 -0
- package/dist/esm/graph/traverse.js.map +1 -0
- package/dist/esm/index.d.ts +4 -4
- package/dist/esm/index.js +2 -2
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/output/column-hint.js.map +1 -0
- package/dist/esm/{output.d.ts → output/output.d.ts} +2 -2
- package/dist/esm/{output.js → output/output.js} +6 -2
- package/dist/esm/output/output.js.map +1 -0
- package/dist/esm/output/progress.js.map +1 -0
- package/dist/esm/{search-error.js → output/search-error.js} +1 -1
- package/dist/esm/output/search-error.js.map +1 -0
- package/dist/esm/scan/frontmatter.d.ts +13 -0
- package/dist/esm/{scan.js → scan/frontmatter.js} +4 -120
- package/dist/esm/scan/frontmatter.js.map +1 -0
- package/dist/esm/scan/index.d.ts +25 -0
- package/dist/esm/scan/index.js +58 -0
- package/dist/esm/scan/index.js.map +1 -0
- package/dist/esm/scan/list.d.ts +12 -0
- package/dist/esm/scan/list.js +58 -0
- package/dist/esm/scan/list.js.map +1 -0
- package/dist/esm/text/segment.d.ts +3 -0
- package/dist/esm/text/segment.js +95 -0
- package/dist/esm/text/segment.js.map +1 -0
- package/dist/esm/text/strip.d.ts +3 -0
- package/dist/esm/text/strip.js +12 -0
- package/dist/esm/text/strip.js.map +1 -0
- package/package.json +23 -2
- package/schema.json +22 -8
- package/skills/sense/SKILL.md +21 -5
- package/skills/sense-setup/EXAMPLES.md +6 -6
- package/skills/sense-setup/SKILL.md +7 -5
- package/dist/cjs/column-hint.js.map +0 -1
- package/dist/cjs/fences.js.map +0 -1
- package/dist/cjs/graph.js.map +0 -1
- package/dist/cjs/output.js.map +0 -1
- package/dist/cjs/progress.js.map +0 -1
- package/dist/cjs/scan.d.cts +0 -35
- package/dist/cjs/scan.d.ts +0 -35
- package/dist/cjs/scan.js +0 -433
- package/dist/cjs/scan.js.map +0 -1
- package/dist/cjs/search-error.js.map +0 -1
- package/dist/cjs/segment.d.cts +0 -2
- package/dist/cjs/segment.d.ts +0 -2
- package/dist/cjs/segment.js +0 -98
- package/dist/cjs/segment.js.map +0 -1
- package/dist/cjs/sql-functions.js.map +0 -1
- package/dist/cjs/traverse.js.map +0 -1
- package/dist/esm/column-hint.js.map +0 -1
- package/dist/esm/fences.js.map +0 -1
- package/dist/esm/graph.js.map +0 -1
- package/dist/esm/output.js.map +0 -1
- package/dist/esm/progress.js.map +0 -1
- package/dist/esm/scan.d.ts +0 -35
- package/dist/esm/scan.js.map +0 -1
- package/dist/esm/search-error.js.map +0 -1
- package/dist/esm/segment.d.ts +0 -2
- package/dist/esm/segment.js +0 -65
- package/dist/esm/segment.js.map +0 -1
- package/dist/esm/sql-functions.js.map +0 -1
- package/dist/esm/traverse.js.map +0 -1
- /package/dist/cjs/{sql-functions.d.cts → db/sql-functions.d.cts} +0 -0
- /package/dist/cjs/{sql-functions.d.ts → db/sql-functions.d.ts} +0 -0
- /package/dist/cjs/{fences.d.cts → features/fences.d.cts} +0 -0
- /package/dist/cjs/{fences.d.ts → features/fences.d.ts} +0 -0
- /package/dist/cjs/{graph.d.cts → graph/graph.d.cts} +0 -0
- /package/dist/cjs/{graph.d.ts → graph/graph.d.ts} +0 -0
- /package/dist/cjs/{graph.js → graph/graph.js} +0 -0
- /package/dist/cjs/{traverse.d.cts → graph/traverse.d.cts} +0 -0
- /package/dist/cjs/{traverse.d.ts → graph/traverse.d.ts} +0 -0
- /package/dist/cjs/{traverse.js → graph/traverse.js} +0 -0
- /package/dist/cjs/{column-hint.d.cts → output/column-hint.d.cts} +0 -0
- /package/dist/cjs/{column-hint.d.ts → output/column-hint.d.ts} +0 -0
- /package/dist/cjs/{column-hint.js → output/column-hint.js} +0 -0
- /package/dist/cjs/{progress.d.cts → output/progress.d.cts} +0 -0
- /package/dist/cjs/{progress.d.ts → output/progress.d.ts} +0 -0
- /package/dist/cjs/{progress.js → output/progress.js} +0 -0
- /package/dist/cjs/{search-error.d.cts → output/search-error.d.cts} +0 -0
- /package/dist/cjs/{search-error.d.ts → output/search-error.d.ts} +0 -0
- /package/dist/esm/{sql-functions.d.ts → db/sql-functions.d.ts} +0 -0
- /package/dist/esm/{fences.d.ts → features/fences.d.ts} +0 -0
- /package/dist/esm/{graph.d.ts → graph/graph.d.ts} +0 -0
- /package/dist/esm/{graph.js → graph/graph.js} +0 -0
- /package/dist/esm/{traverse.d.ts → graph/traverse.d.ts} +0 -0
- /package/dist/esm/{traverse.js → graph/traverse.js} +0 -0
- /package/dist/esm/{column-hint.d.ts → output/column-hint.d.ts} +0 -0
- /package/dist/esm/{column-hint.js → output/column-hint.js} +0 -0
- /package/dist/esm/{progress.d.ts → output/progress.d.ts} +0 -0
- /package/dist/esm/{progress.js → output/progress.js} +0 -0
- /package/dist/esm/{search-error.d.ts → output/search-error.d.ts} +0 -0
|
@@ -0,0 +1,253 @@
|
|
|
1
|
+
import { UNSPACED_SCRIPTS } from '../text/segment.js';
|
|
2
|
+
import { extractText } from './extract.js';
|
|
3
|
+
import { parse } from './parse.js';
|
|
4
|
+
export const DEFAULT_TARGET_TOKENS = 500;
|
|
5
|
+
const PGC_GROUP_SIZE = 2;
|
|
6
|
+
const OVERSIZE_TRIGGER_MULTIPLE = 2;
|
|
7
|
+
// D5: segment.ts's unspaced-script set packs close to one token per character; Hangul is
|
|
8
|
+
// spaced but still token-dense, added here as a conservative bound (one Unicode set, one home).
|
|
9
|
+
const DENSE_SCRIPT = new RegExp(`[${UNSPACED_SCRIPTS}\\p{scx=Hangul}]`, 'u');
|
|
10
|
+
// D5's size estimate: dense-script graphemes 1:1, everything else at 4 chars/token.
|
|
11
|
+
export function estimateTokens(text) {
|
|
12
|
+
let dense = 0;
|
|
13
|
+
let other = 0;
|
|
14
|
+
for (const ch of text){
|
|
15
|
+
if (DENSE_SCRIPT.test(ch)) dense++;
|
|
16
|
+
else other++;
|
|
17
|
+
}
|
|
18
|
+
return dense + other / 4;
|
|
19
|
+
}
|
|
20
|
+
function resolveOptions(opts) {
|
|
21
|
+
var _ref, _ref1;
|
|
22
|
+
return {
|
|
23
|
+
targetTokens: (_ref = opts === null || opts === void 0 ? void 0 : opts.targetTokens) !== null && _ref !== void 0 ? _ref : DEFAULT_TARGET_TOKENS,
|
|
24
|
+
text: (_ref1 = opts === null || opts === void 0 ? void 0 : opts.text) !== null && _ref1 !== void 0 ? _ref1 : 'raw'
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
// A heading of any depth ends the current scope and starts a new one (D1); the heading block
|
|
28
|
+
// itself is carried into the new scope, where it joins that scope's first group (F7/F10).
|
|
29
|
+
function splitScopes(blocks) {
|
|
30
|
+
const scopes = [];
|
|
31
|
+
let current = [];
|
|
32
|
+
for (const block of blocks){
|
|
33
|
+
if (block.type === 'heading' && current.length > 0) {
|
|
34
|
+
scopes.push(current);
|
|
35
|
+
current = [];
|
|
36
|
+
}
|
|
37
|
+
current.push(block);
|
|
38
|
+
}
|
|
39
|
+
if (current.length > 0) scopes.push(current);
|
|
40
|
+
return scopes;
|
|
41
|
+
}
|
|
42
|
+
function finalize(parts) {
|
|
43
|
+
if (parts.length === 0) return undefined;
|
|
44
|
+
const first = parts[0];
|
|
45
|
+
const last = parts[parts.length - 1];
|
|
46
|
+
return {
|
|
47
|
+
startLine: first.startLine,
|
|
48
|
+
endLine: last.endLine,
|
|
49
|
+
text: parts.map((p)=>p.text).join('\n'),
|
|
50
|
+
final: parts.some((p)=>p.final)
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
const NEWLINE_TOKENS = estimateTokens('\n');
|
|
54
|
+
const SENTENCE_SEGMENTER = new Intl.Segmenter(undefined, {
|
|
55
|
+
granularity: 'sentence'
|
|
56
|
+
});
|
|
57
|
+
const WORD_SEGMENTER = new Intl.Segmenter(undefined, {
|
|
58
|
+
granularity: 'word'
|
|
59
|
+
});
|
|
60
|
+
function segmentsOf(text, segmenter) {
|
|
61
|
+
return Array.from(segmenter.segment(text), (s)=>s.segment);
|
|
62
|
+
}
|
|
63
|
+
// Greedily packs segments (already contiguous, tiling the source text with no gaps) into groups
|
|
64
|
+
// of at most `working` estimated tokens; a lone segment over `working` still stands alone.
|
|
65
|
+
function pack(segments, working) {
|
|
66
|
+
const groups = [];
|
|
67
|
+
let current = '';
|
|
68
|
+
let tokens = 0;
|
|
69
|
+
for (const segment of segments){
|
|
70
|
+
const segmentTokens = estimateTokens(segment);
|
|
71
|
+
if (current.length > 0 && tokens + segmentTokens > working) {
|
|
72
|
+
groups.push(current);
|
|
73
|
+
current = '';
|
|
74
|
+
tokens = 0;
|
|
75
|
+
}
|
|
76
|
+
current += segment;
|
|
77
|
+
tokens += segmentTokens;
|
|
78
|
+
}
|
|
79
|
+
if (current.length > 0) groups.push(current);
|
|
80
|
+
return groups;
|
|
81
|
+
}
|
|
82
|
+
// A single line's text, still over working after rule 5's line-split can't reduce a lone line
|
|
83
|
+
// (the CJK case, one sentence-dense line with no newlines), falls back to Intl.Segmenter sentence
|
|
84
|
+
// boundaries, then word boundaries for any one sentence still over working. Never splits inside a
|
|
85
|
+
// grapheme either way (both are ECMA-402, the same proven component segment.ts uses for
|
|
86
|
+
// graphemes). Mode-agnostic: the caller decides whether `text` is the raw line or its extracted
|
|
87
|
+
// flavor -- this only packs whatever text it is given.
|
|
88
|
+
function splitLineText(text, working) {
|
|
89
|
+
const sentences = segmentsOf(text, SENTENCE_SEGMENTER);
|
|
90
|
+
const out = [];
|
|
91
|
+
let current = '';
|
|
92
|
+
let tokens = 0;
|
|
93
|
+
const flush = ()=>{
|
|
94
|
+
if (current.length > 0) {
|
|
95
|
+
out.push(current);
|
|
96
|
+
current = '';
|
|
97
|
+
tokens = 0;
|
|
98
|
+
}
|
|
99
|
+
};
|
|
100
|
+
for (const sentence of sentences){
|
|
101
|
+
const sentenceTokens = estimateTokens(sentence);
|
|
102
|
+
if (sentenceTokens > working) {
|
|
103
|
+
flush();
|
|
104
|
+
out.push(...pack(segmentsOf(sentence, WORD_SEGMENTER), working));
|
|
105
|
+
continue;
|
|
106
|
+
}
|
|
107
|
+
if (current.length > 0 && tokens + sentenceTokens > working) flush();
|
|
108
|
+
current += sentence;
|
|
109
|
+
tokens += sentenceTokens;
|
|
110
|
+
}
|
|
111
|
+
flush();
|
|
112
|
+
return out;
|
|
113
|
+
}
|
|
114
|
+
const ATOMIC_TYPES = new Set([
|
|
115
|
+
'code',
|
|
116
|
+
'table',
|
|
117
|
+
'list'
|
|
118
|
+
]);
|
|
119
|
+
// An atomic block's (code/table/list) piece is always a raw line slice: re-parsing a table's
|
|
120
|
+
// later pieces without their header/delimiter rows demotes them to paragraph text. A non-atomic
|
|
121
|
+
// piece is a raw line slice too when raw mode requested it; extracted mode re-parses and resolves
|
|
122
|
+
// flavor as before.
|
|
123
|
+
function piece(pieceLines, startLine, endLine, blockType, textMode) {
|
|
124
|
+
const text = ATOMIC_TYPES.has(blockType) || textMode === 'raw' ? pieceLines.join('\n') : parse(pieceLines.join('\n')).map((b)=>extractText(b.node)).join('\n');
|
|
125
|
+
return {
|
|
126
|
+
startLine,
|
|
127
|
+
endLine,
|
|
128
|
+
text
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
// A piece over working size that came from exactly one source line cannot be reduced by another
|
|
132
|
+
// line-boundary pass (rule 5's gap); it is sliced instead, at sentence then word boundaries, over
|
|
133
|
+
// the mode-resolved text piece() already produced -- so raw mode packs the raw line and extracted
|
|
134
|
+
// mode packs its flavor-resolved text. Extents collapse to that one line for every sub-piece (F5:
|
|
135
|
+
// re-derivation is by index over chunk()'s own deterministic output, not by a unique line range
|
|
136
|
+
// per piece); `final` flags each sub-piece so group() knows not to re-derive its text from that
|
|
137
|
+
// shared extent.
|
|
138
|
+
function finalizePiece(pieceLines, startLine, endLine, working, blockType, textMode) {
|
|
139
|
+
const p = piece(pieceLines, startLine, endLine, blockType, textMode);
|
|
140
|
+
if (pieceLines.length === 1 && estimateTokens(p.text) > working) {
|
|
141
|
+
return splitLineText(p.text, working).map((text)=>({
|
|
142
|
+
startLine,
|
|
143
|
+
endLine,
|
|
144
|
+
text,
|
|
145
|
+
final: true
|
|
146
|
+
}));
|
|
147
|
+
}
|
|
148
|
+
return [
|
|
149
|
+
p
|
|
150
|
+
];
|
|
151
|
+
}
|
|
152
|
+
// A block over 2x working size splits at line boundaries into pieces each <= working size,
|
|
153
|
+
// never mid-line. `seed`: pending tokens (a heading) the first piece must join, checked against
|
|
154
|
+
// the limit too.
|
|
155
|
+
function splitOversizeBlock(lines, startLine, endLine, working, blockType, textMode, seed = 0) {
|
|
156
|
+
const pieces = [];
|
|
157
|
+
let pieceLines = [];
|
|
158
|
+
let pieceStart = startLine;
|
|
159
|
+
let tokens = seed;
|
|
160
|
+
for(let line = startLine; line <= endLine; line++){
|
|
161
|
+
const lineText = lines[line - 1];
|
|
162
|
+
const sep = pieceLines.length > 0 || tokens > 0 ? NEWLINE_TOKENS : 0;
|
|
163
|
+
const lineTokens = estimateTokens(lineText);
|
|
164
|
+
if (pieceLines.length > 0 && tokens + sep + lineTokens > working) {
|
|
165
|
+
pieces.push(...finalizePiece(pieceLines, pieceStart, line - 1, working, blockType, textMode));
|
|
166
|
+
pieceLines = [];
|
|
167
|
+
tokens = 0;
|
|
168
|
+
pieceStart = line;
|
|
169
|
+
pieceLines.push(lineText);
|
|
170
|
+
tokens += lineTokens;
|
|
171
|
+
continue;
|
|
172
|
+
}
|
|
173
|
+
pieceLines.push(lineText);
|
|
174
|
+
tokens += sep + lineTokens;
|
|
175
|
+
}
|
|
176
|
+
if (pieceLines.length > 0) pieces.push(...finalizePiece(pieceLines, pieceStart, endLine, working, blockType, textMode));
|
|
177
|
+
return pieces;
|
|
178
|
+
}
|
|
179
|
+
// One heading scope's groups (D1): a heading opens the first group, and an oversize block
|
|
180
|
+
// (rule 5, including an oversize heading) splits into pieces that each close their own group.
|
|
181
|
+
function groupScope(scopeBlocks, lines, resolved) {
|
|
182
|
+
const working = resolved.targetTokens;
|
|
183
|
+
const trigger = working * OVERSIZE_TRIGGER_MULTIPLE;
|
|
184
|
+
const finished = [];
|
|
185
|
+
let parts = [];
|
|
186
|
+
let paragraphCount = 0;
|
|
187
|
+
let tokens = 0;
|
|
188
|
+
function close() {
|
|
189
|
+
const group = finalize(parts);
|
|
190
|
+
if (group) finished.push(group);
|
|
191
|
+
parts = [];
|
|
192
|
+
paragraphCount = 0;
|
|
193
|
+
tokens = 0;
|
|
194
|
+
}
|
|
195
|
+
// tokens tracks the active text mode's own estimate (a newline between parts costs
|
|
196
|
+
// NEWLINE_TOKENS too), so packing decisions size the text the chunk will actually ship as.
|
|
197
|
+
function addPart(text, sizeText, startLine, endLine) {
|
|
198
|
+
tokens += (parts.length > 0 ? NEWLINE_TOKENS : 0) + estimateTokens(sizeText);
|
|
199
|
+
parts.push({
|
|
200
|
+
startLine,
|
|
201
|
+
endLine,
|
|
202
|
+
text
|
|
203
|
+
});
|
|
204
|
+
}
|
|
205
|
+
for (const block of scopeBlocks){
|
|
206
|
+
const raw = lines.slice(block.startLine - 1, block.endLine).join('\n');
|
|
207
|
+
const blockTokens = estimateTokens(raw);
|
|
208
|
+
if (blockTokens > trigger) {
|
|
209
|
+
const seed = parts.length > 0 ? tokens : 0;
|
|
210
|
+
for (const p of splitOversizeBlock(lines, block.startLine, block.endLine, working, block.type, resolved.text, seed)){
|
|
211
|
+
parts.push(p);
|
|
212
|
+
close();
|
|
213
|
+
}
|
|
214
|
+
continue;
|
|
215
|
+
}
|
|
216
|
+
const extracted = extractText(block.node);
|
|
217
|
+
const sizeText = resolved.text === 'raw' ? raw : extracted;
|
|
218
|
+
if (block.type === 'heading') {
|
|
219
|
+
addPart(extracted, sizeText, block.startLine, block.endLine);
|
|
220
|
+
continue;
|
|
221
|
+
}
|
|
222
|
+
// The 2x-working invariant holds even under pgc's paper-faithful 2-paragraph pairing --
|
|
223
|
+
// close first if the pair about to form would cross it.
|
|
224
|
+
const pairOversize = parts.length > 0 && tokens + NEWLINE_TOKENS + blockTokens > trigger;
|
|
225
|
+
if (pairOversize) close();
|
|
226
|
+
addPart(extracted, sizeText, block.startLine, block.endLine);
|
|
227
|
+
paragraphCount++;
|
|
228
|
+
if (paragraphCount >= PGC_GROUP_SIZE) close();
|
|
229
|
+
}
|
|
230
|
+
close();
|
|
231
|
+
return finished;
|
|
232
|
+
}
|
|
233
|
+
// Groups already-parsed blocks per opts (D1/D3), against the same body the blocks were parsed
|
|
234
|
+
// from (line lookups for oversize splitting).
|
|
235
|
+
export function group(blocks, body, opts) {
|
|
236
|
+
const resolved = resolveOptions(opts);
|
|
237
|
+
const lines = body.split('\n');
|
|
238
|
+
const chunks = [];
|
|
239
|
+
for (const scope of splitScopes(blocks))chunks.push(...groupScope(scope, lines, resolved));
|
|
240
|
+
// 'raw': the chunk's own source lines verbatim, replacing the flavor-resolved join above (D9).
|
|
241
|
+
// A `final` chunk (a sub-line split) already carries its own slice's raw text -- re-slicing by
|
|
242
|
+
// extent would return the whole shared source line instead, once per sub-piece.
|
|
243
|
+
const texted = resolved.text === 'raw' ? chunks.map((c)=>c.final ? c : {
|
|
244
|
+
...c,
|
|
245
|
+
text: lines.slice(c.startLine - 1, c.endLine).join('\n').trim()
|
|
246
|
+
}) : chunks;
|
|
247
|
+
// A group can be all-blank (flavor-stripped to nothing, or a raw slice of pure syntax); it never produces a chunk.
|
|
248
|
+
return texted.filter((c)=>c.text.trim().length > 0).map((c)=>({
|
|
249
|
+
startLine: c.startLine,
|
|
250
|
+
endLine: c.endLine,
|
|
251
|
+
text: c.text
|
|
252
|
+
}));
|
|
253
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/ai/sensemaking/src/chunk/group.ts"],"sourcesContent":["import { UNSPACED_SCRIPTS } from '../text/segment.ts';\nimport { extractText } from './extract.ts';\nimport { parse } from './parse.ts';\nimport type { Block, BlockType, Chunk, ChunkOptions } from './types.ts';\n\nexport const DEFAULT_TARGET_TOKENS = 500;\nconst PGC_GROUP_SIZE = 2;\nconst OVERSIZE_TRIGGER_MULTIPLE = 2;\n\n// D5: segment.ts's unspaced-script set packs close to one token per character; Hangul is\n// spaced but still token-dense, added here as a conservative bound (one Unicode set, one home).\nconst DENSE_SCRIPT = new RegExp(`[${UNSPACED_SCRIPTS}\\\\p{scx=Hangul}]`, 'u');\n\n// D5's size estimate: dense-script graphemes 1:1, everything else at 4 chars/token.\nexport function estimateTokens(text: string): number {\n let dense = 0;\n let other = 0;\n for (const ch of text) {\n if (DENSE_SCRIPT.test(ch)) dense++;\n else other++;\n }\n return dense + other / 4;\n}\n\ninterface ResolvedOptions {\n targetTokens: number;\n text: 'extracted' | 'raw';\n}\n\nfunction resolveOptions(opts?: ChunkOptions): ResolvedOptions {\n return {\n targetTokens: opts?.targetTokens ?? DEFAULT_TARGET_TOKENS,\n text: opts?.text ?? 'raw',\n };\n}\n\n// A heading of any depth ends the current scope and starts a new one (D1); the heading block\n// itself is carried into the new scope, where it joins that scope's first group (F7/F10).\nfunction splitScopes(blocks: Block[]): Block[][] {\n const scopes: Block[][] = [];\n let current: Block[] = [];\n for (const block of blocks) {\n if (block.type === 'heading' && current.length > 0) {\n scopes.push(current);\n current = [];\n }\n current.push(block);\n }\n if (current.length > 0) scopes.push(current);\n return scopes;\n}\n\ninterface Part {\n startLine: number;\n endLine: number;\n text: string;\n // true for a sub-line split piece (finalizePiece's splitLineText branch): its text is already\n // the active mode's final text for its own slice of the line, not the whole line, so group()'s\n // extent-based raw re-slice (startLine === endLine for every sibling sub-piece) must not touch it.\n final?: boolean;\n}\n\nfunction finalize(parts: Part[]): (Chunk & { final?: boolean }) | undefined {\n if (parts.length === 0) return undefined;\n const first = parts[0];\n const last = parts[parts.length - 1];\n return { startLine: first.startLine, endLine: last.endLine, text: parts.map((p) => p.text).join('\\n'), final: parts.some((p) => p.final) };\n}\n\nconst NEWLINE_TOKENS = estimateTokens('\\n');\nconst SENTENCE_SEGMENTER = new Intl.Segmenter(undefined, { granularity: 'sentence' });\nconst WORD_SEGMENTER = new Intl.Segmenter(undefined, { granularity: 'word' });\n\nfunction segmentsOf(text: string, segmenter: Intl.Segmenter): string[] {\n return Array.from(segmenter.segment(text), (s) => s.segment);\n}\n\n// Greedily packs segments (already contiguous, tiling the source text with no gaps) into groups\n// of at most `working` estimated tokens; a lone segment over `working` still stands alone.\nfunction pack(segments: string[], working: number): string[] {\n const groups: string[] = [];\n let current = '';\n let tokens = 0;\n for (const segment of segments) {\n const segmentTokens = estimateTokens(segment);\n if (current.length > 0 && tokens + segmentTokens > working) {\n groups.push(current);\n current = '';\n tokens = 0;\n }\n current += segment;\n tokens += segmentTokens;\n }\n if (current.length > 0) groups.push(current);\n return groups;\n}\n\n// A single line's text, still over working after rule 5's line-split can't reduce a lone line\n// (the CJK case, one sentence-dense line with no newlines), falls back to Intl.Segmenter sentence\n// boundaries, then word boundaries for any one sentence still over working. Never splits inside a\n// grapheme either way (both are ECMA-402, the same proven component segment.ts uses for\n// graphemes). Mode-agnostic: the caller decides whether `text` is the raw line or its extracted\n// flavor -- this only packs whatever text it is given.\nfunction splitLineText(text: string, working: number): string[] {\n const sentences = segmentsOf(text, SENTENCE_SEGMENTER);\n const out: string[] = [];\n let current = '';\n let tokens = 0;\n const flush = () => {\n if (current.length > 0) {\n out.push(current);\n current = '';\n tokens = 0;\n }\n };\n for (const sentence of sentences) {\n const sentenceTokens = estimateTokens(sentence);\n if (sentenceTokens > working) {\n flush();\n out.push(...pack(segmentsOf(sentence, WORD_SEGMENTER), working));\n continue;\n }\n if (current.length > 0 && tokens + sentenceTokens > working) flush();\n current += sentence;\n tokens += sentenceTokens;\n }\n flush();\n return out;\n}\n\nconst ATOMIC_TYPES: ReadonlySet<BlockType> = new Set(['code', 'table', 'list']);\n\n// An atomic block's (code/table/list) piece is always a raw line slice: re-parsing a table's\n// later pieces without their header/delimiter rows demotes them to paragraph text. A non-atomic\n// piece is a raw line slice too when raw mode requested it; extracted mode re-parses and resolves\n// flavor as before.\nfunction piece(pieceLines: string[], startLine: number, endLine: number, blockType: BlockType, textMode: 'extracted' | 'raw'): Part {\n const text =\n ATOMIC_TYPES.has(blockType) || textMode === 'raw'\n ? pieceLines.join('\\n')\n : parse(pieceLines.join('\\n'))\n .map((b) => extractText(b.node))\n .join('\\n');\n return { startLine, endLine, text };\n}\n\n// A piece over working size that came from exactly one source line cannot be reduced by another\n// line-boundary pass (rule 5's gap); it is sliced instead, at sentence then word boundaries, over\n// the mode-resolved text piece() already produced -- so raw mode packs the raw line and extracted\n// mode packs its flavor-resolved text. Extents collapse to that one line for every sub-piece (F5:\n// re-derivation is by index over chunk()'s own deterministic output, not by a unique line range\n// per piece); `final` flags each sub-piece so group() knows not to re-derive its text from that\n// shared extent.\nfunction finalizePiece(pieceLines: string[], startLine: number, endLine: number, working: number, blockType: BlockType, textMode: 'extracted' | 'raw'): Part[] {\n const p = piece(pieceLines, startLine, endLine, blockType, textMode);\n if (pieceLines.length === 1 && estimateTokens(p.text) > working) {\n return splitLineText(p.text, working).map((text) => ({ startLine, endLine, text, final: true }));\n }\n return [p];\n}\n\n// A block over 2x working size splits at line boundaries into pieces each <= working size,\n// never mid-line. `seed`: pending tokens (a heading) the first piece must join, checked against\n// the limit too.\nfunction splitOversizeBlock(lines: string[], startLine: number, endLine: number, working: number, blockType: BlockType, textMode: 'extracted' | 'raw', seed = 0): Part[] {\n const pieces: Part[] = [];\n let pieceLines: string[] = [];\n let pieceStart = startLine;\n let tokens = seed;\n for (let line = startLine; line <= endLine; line++) {\n const lineText = lines[line - 1];\n const sep = pieceLines.length > 0 || tokens > 0 ? NEWLINE_TOKENS : 0;\n const lineTokens = estimateTokens(lineText);\n if (pieceLines.length > 0 && tokens + sep + lineTokens > working) {\n pieces.push(...finalizePiece(pieceLines, pieceStart, line - 1, working, blockType, textMode));\n pieceLines = [];\n tokens = 0;\n pieceStart = line;\n pieceLines.push(lineText);\n tokens += lineTokens;\n continue;\n }\n pieceLines.push(lineText);\n tokens += sep + lineTokens;\n }\n if (pieceLines.length > 0) pieces.push(...finalizePiece(pieceLines, pieceStart, endLine, working, blockType, textMode));\n return pieces;\n}\n\n// One heading scope's groups (D1): a heading opens the first group, and an oversize block\n// (rule 5, including an oversize heading) splits into pieces that each close their own group.\nfunction groupScope(scopeBlocks: Block[], lines: string[], resolved: ResolvedOptions): (Chunk & { final?: boolean })[] {\n const working = resolved.targetTokens;\n const trigger = working * OVERSIZE_TRIGGER_MULTIPLE;\n const finished: (Chunk & { final?: boolean })[] = [];\n let parts: Part[] = [];\n let paragraphCount = 0;\n let tokens = 0;\n\n function close(): void {\n const group = finalize(parts);\n if (group) finished.push(group);\n parts = [];\n paragraphCount = 0;\n tokens = 0;\n }\n\n // tokens tracks the active text mode's own estimate (a newline between parts costs\n // NEWLINE_TOKENS too), so packing decisions size the text the chunk will actually ship as.\n function addPart(text: string, sizeText: string, startLine: number, endLine: number): void {\n tokens += (parts.length > 0 ? NEWLINE_TOKENS : 0) + estimateTokens(sizeText);\n parts.push({ startLine, endLine, text });\n }\n\n for (const block of scopeBlocks) {\n const raw = lines.slice(block.startLine - 1, block.endLine).join('\\n');\n const blockTokens = estimateTokens(raw);\n\n if (blockTokens > trigger) {\n const seed = parts.length > 0 ? tokens : 0;\n for (const p of splitOversizeBlock(lines, block.startLine, block.endLine, working, block.type, resolved.text, seed)) {\n parts.push(p);\n close();\n }\n continue;\n }\n\n const extracted = extractText(block.node);\n const sizeText = resolved.text === 'raw' ? raw : extracted;\n\n if (block.type === 'heading') {\n addPart(extracted, sizeText, block.startLine, block.endLine);\n continue;\n }\n\n // The 2x-working invariant holds even under pgc's paper-faithful 2-paragraph pairing --\n // close first if the pair about to form would cross it.\n const pairOversize = parts.length > 0 && tokens + NEWLINE_TOKENS + blockTokens > trigger;\n if (pairOversize) close();\n\n addPart(extracted, sizeText, block.startLine, block.endLine);\n paragraphCount++;\n\n if (paragraphCount >= PGC_GROUP_SIZE) close();\n }\n close();\n\n return finished;\n}\n\n// Groups already-parsed blocks per opts (D1/D3), against the same body the blocks were parsed\n// from (line lookups for oversize splitting).\nexport function group(blocks: Block[], body: string, opts?: ChunkOptions): Chunk[] {\n const resolved = resolveOptions(opts);\n const lines = body.split('\\n');\n const chunks: (Chunk & { final?: boolean })[] = [];\n for (const scope of splitScopes(blocks)) chunks.push(...groupScope(scope, lines, resolved));\n // 'raw': the chunk's own source lines verbatim, replacing the flavor-resolved join above (D9).\n // A `final` chunk (a sub-line split) already carries its own slice's raw text -- re-slicing by\n // extent would return the whole shared source line instead, once per sub-piece.\n const texted =\n resolved.text === 'raw'\n ? chunks.map((c) =>\n c.final\n ? c\n : {\n ...c,\n text: lines\n .slice(c.startLine - 1, c.endLine)\n .join('\\n')\n .trim(),\n }\n )\n : chunks;\n // A group can be all-blank (flavor-stripped to nothing, or a raw slice of pure syntax); it never produces a chunk.\n return texted.filter((c) => c.text.trim().length > 0).map((c) => ({ startLine: c.startLine, endLine: c.endLine, text: c.text }));\n}\n"],"names":["UNSPACED_SCRIPTS","extractText","parse","DEFAULT_TARGET_TOKENS","PGC_GROUP_SIZE","OVERSIZE_TRIGGER_MULTIPLE","DENSE_SCRIPT","RegExp","estimateTokens","text","dense","other","ch","test","resolveOptions","opts","targetTokens","splitScopes","blocks","scopes","current","block","type","length","push","finalize","parts","undefined","first","last","startLine","endLine","map","p","join","final","some","NEWLINE_TOKENS","SENTENCE_SEGMENTER","Intl","Segmenter","granularity","WORD_SEGMENTER","segmentsOf","segmenter","Array","from","segment","s","pack","segments","working","groups","tokens","segmentTokens","splitLineText","sentences","out","flush","sentence","sentenceTokens","ATOMIC_TYPES","Set","piece","pieceLines","blockType","textMode","has","b","node","finalizePiece","splitOversizeBlock","lines","seed","pieces","pieceStart","line","lineText","sep","lineTokens","groupScope","scopeBlocks","resolved","trigger","finished","paragraphCount","close","group","addPart","sizeText","raw","slice","blockTokens","extracted","pairOversize","body","split","chunks","scope","texted","c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AWJ,UAAUpE,MAAMS,SAAS,EAAET,MAAMU,OAAO;QAC3DsD;QAEA,IAAIA,kBAAkBjF,gBAAgBkF;IACxC;IACAA;IAEA,OAAOF;AACT;AAEA,8FAA8F;AAC9F,8CAA8C;AAC9C,OAAO,SAASG,MAAMrE,MAAe,EAAE6E,IAAY,EAAEhF,IAAmB;IACtE,MAAMmE,WAAWpE,eAAeC;IAChC,MAAMyD,QAAQuB,KAAKC,KAAK,CAAC;IACzB,MAAMC,SAA0C,EAAE;IAClD,KAAK,MAAMC,SAASjF,YAAYC,QAAS+E,OAAOzE,IAAI,IAAIwD,WAAWkB,OAAO1B,OAAOU;IACjF,+FAA+F;IAC/F,+FAA+F;IAC/F,gFAAgF;IAChF,MAAMiB,SACJjB,SAASzE,IAAI,KAAK,QACdwF,OAAOjE,GAAG,CAAC,CAACoE,IACVA,EAAEjE,KAAK,GACHiE,IACA;YACE,GAAGA,CAAC;YACJ3F,MAAM+D,MACHmB,KAAK,CAACS,EAAEtE,SAAS,GAAG,GAAGsE,EAAErE,OAAO,EAChCG,IAAI,CAAC,MACLmE,IAAI;QACT,KAENJ;IACN,mHAAmH;IACnH,OAAOE,OAAOG,MAAM,CAAC,CAACF,IAAMA,EAAE3F,IAAI,CAAC4F,IAAI,GAAG9E,MAAM,GAAG,GAAGS,GAAG,CAAC,CAACoE,IAAO,CAAA;YAAEtE,WAAWsE,EAAEtE,SAAS;YAAEC,SAASqE,EAAErE,OAAO;YAAEtB,MAAM2F,EAAE3F,IAAI;QAAC,CAAA;AAC/H"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { Block, Chunk, ChunkOptions } from './types.js';
|
|
2
|
+
export declare function chunkFromBlocks(blocks: Block[], body: string, opts?: ChunkOptions): Chunk[];
|
|
3
|
+
export declare function chunk(body: string, opts?: ChunkOptions): Chunk[];
|
|
4
|
+
export { extractText } from './extract.js';
|
|
5
|
+
export { DEFAULT_TARGET_TOKENS, estimateTokens } from './group.js';
|
|
6
|
+
export { parse } from './parse.js';
|
|
7
|
+
export type { Block, BlockType, Chunk, ChunkOptions } from './types.js';
|
|
8
|
+
export { CHUNK_VERSION } from './version.js';
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { group } from './group.js';
|
|
2
|
+
import { parse } from './parse.js';
|
|
3
|
+
// Groups blocks a caller already parsed (e.g. scan/index.ts, sharing one parse with the FTS
|
|
4
|
+
// text path) against the same body they came from, per opts (D1/D3).
|
|
5
|
+
export function chunkFromBlocks(blocks, body, opts) {
|
|
6
|
+
return group(blocks, body, opts);
|
|
7
|
+
}
|
|
8
|
+
// Pure, deterministic function of file content; chunk semantics are version-stamped via
|
|
9
|
+
// CHUNK_VERSION (./version.ts). Algorithm and evidence: BENCHMARKING.md, "The chunking algorithm".
|
|
10
|
+
export function chunk(body, opts) {
|
|
11
|
+
return chunkFromBlocks(parse(body), body, opts);
|
|
12
|
+
}
|
|
13
|
+
export { extractText } from './extract.js';
|
|
14
|
+
export { DEFAULT_TARGET_TOKENS, estimateTokens } from './group.js';
|
|
15
|
+
export { parse } from './parse.js';
|
|
16
|
+
export { CHUNK_VERSION } from './version.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/ai/sensemaking/src/chunk/index.ts"],"sourcesContent":["import { group } from './group.ts';\nimport { parse } from './parse.ts';\nimport type { Block, Chunk, ChunkOptions } from './types.ts';\n\n// Groups blocks a caller already parsed (e.g. scan/index.ts, sharing one parse with the FTS\n// text path) against the same body they came from, per opts (D1/D3).\nexport function chunkFromBlocks(blocks: Block[], body: string, opts?: ChunkOptions): Chunk[] {\n return group(blocks, body, opts);\n}\n\n// Pure, deterministic function of file content; chunk semantics are version-stamped via\n// CHUNK_VERSION (./version.ts). Algorithm and evidence: BENCHMARKING.md, \"The chunking algorithm\".\nexport function chunk(body: string, opts?: ChunkOptions): Chunk[] {\n return chunkFromBlocks(parse(body), body, opts);\n}\n\nexport { extractText } from './extract.ts';\nexport { DEFAULT_TARGET_TOKENS, estimateTokens } from './group.ts';\nexport { parse } from './parse.ts';\nexport type { Block, BlockType, Chunk, ChunkOptions } from './types.ts';\nexport { CHUNK_VERSION } from './version.ts';\n"],"names":["group","parse","chunkFromBlocks","blocks","body","opts","chunk","extractText","DEFAULT_TARGET_TOKENS","estimateTokens","CHUNK_VERSION"],"mappings":"AAAA,SAASA,KAAK,QAAQ,aAAa;AACnC,SAASC,KAAK,QAAQ,aAAa;AAGnC,4FAA4F;AAC5F,qEAAqE;AACrE,OAAO,SAASC,gBAAgBC,MAAe,EAAEC,IAAY,EAAEC,IAAmB;IAChF,OAAOL,MAAMG,QAAQC,MAAMC;AAC7B;AAEA,wFAAwF;AACxF,mGAAmG;AACnG,OAAO,SAASC,MAAMF,IAAY,EAAEC,IAAmB;IACrD,OAAOH,gBAAgBD,MAAMG,OAAOA,MAAMC;AAC5C;AAEA,SAASE,WAAW,QAAQ,eAAe;AAC3C,SAASC,qBAAqB,EAAEC,cAAc,QAAQ,aAAa;AACnE,SAASR,KAAK,QAAQ,aAAa;AAEnC,SAASS,aAAa,QAAQ,eAAe"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { fromMarkdown } from 'mdast-util-from-markdown';
|
|
2
|
+
import { gfmAutolinkLiteralFromMarkdown } from 'mdast-util-gfm-autolink-literal';
|
|
3
|
+
import { gfmFootnoteFromMarkdown } from 'mdast-util-gfm-footnote';
|
|
4
|
+
import { gfmStrikethroughFromMarkdown } from 'mdast-util-gfm-strikethrough';
|
|
5
|
+
import { gfmTableFromMarkdown } from 'mdast-util-gfm-table';
|
|
6
|
+
import { gfmTaskListItemFromMarkdown } from 'mdast-util-gfm-task-list-item';
|
|
7
|
+
import { gfmAutolinkLiteral } from 'micromark-extension-gfm-autolink-literal';
|
|
8
|
+
import { gfmFootnote } from 'micromark-extension-gfm-footnote';
|
|
9
|
+
import { gfmStrikethrough } from 'micromark-extension-gfm-strikethrough';
|
|
10
|
+
import { gfmTable } from 'micromark-extension-gfm-table';
|
|
11
|
+
import { gfmTaskListItem } from 'micromark-extension-gfm-task-list-item';
|
|
12
|
+
import { extractText } from './extract.js';
|
|
13
|
+
const BLOCK_TYPES = {
|
|
14
|
+
heading: 'heading',
|
|
15
|
+
paragraph: 'paragraph',
|
|
16
|
+
code: 'code',
|
|
17
|
+
table: 'table',
|
|
18
|
+
list: 'list',
|
|
19
|
+
blockquote: 'blockquote'
|
|
20
|
+
};
|
|
21
|
+
// The five extensions extract.ts/group.ts actually consume, imported individually rather than
|
|
22
|
+
// through micromark-extension-gfm/mdast-util-gfm: those bundles also pull in gfm-tagfilter,
|
|
23
|
+
// an HTML-serialization sanitizer this library never uses (no htmlExtensions call anywhere).
|
|
24
|
+
// micromark and mdast-util-from-markdown each already flatten an extensions array themselves,
|
|
25
|
+
// so no combine-extensions helper is needed here.
|
|
26
|
+
const EXTENSIONS = [
|
|
27
|
+
gfmAutolinkLiteral(),
|
|
28
|
+
gfmFootnote(),
|
|
29
|
+
gfmStrikethrough(),
|
|
30
|
+
gfmTable(),
|
|
31
|
+
gfmTaskListItem()
|
|
32
|
+
];
|
|
33
|
+
const MDAST_EXTENSIONS = [
|
|
34
|
+
gfmAutolinkLiteralFromMarkdown(),
|
|
35
|
+
gfmFootnoteFromMarkdown(),
|
|
36
|
+
gfmStrikethroughFromMarkdown(),
|
|
37
|
+
gfmTableFromMarkdown(),
|
|
38
|
+
gfmTaskListItemFromMarkdown()
|
|
39
|
+
];
|
|
40
|
+
// Top-level blocks of a markdown body, typed and line-extent bounded. Extents come from
|
|
41
|
+
// mdast's own node.position, never a regex guess at where a block starts or ends; GFM adds
|
|
42
|
+
// tables, task lists, footnotes and strikethrough to the CommonMark set fromMarkdown parses.
|
|
43
|
+
export function parse(body) {
|
|
44
|
+
const tree = fromMarkdown(body, {
|
|
45
|
+
extensions: EXTENSIONS,
|
|
46
|
+
mdastExtensions: MDAST_EXTENSIONS
|
|
47
|
+
});
|
|
48
|
+
return tree.children.map((node)=>{
|
|
49
|
+
var _BLOCK_TYPES_node_type;
|
|
50
|
+
const position = node.position;
|
|
51
|
+
const block = {
|
|
52
|
+
type: (_BLOCK_TYPES_node_type = BLOCK_TYPES[node.type]) !== null && _BLOCK_TYPES_node_type !== void 0 ? _BLOCK_TYPES_node_type : 'other',
|
|
53
|
+
startLine: position ? position.start.line : 1,
|
|
54
|
+
endLine: position ? position.end.line : 1,
|
|
55
|
+
node
|
|
56
|
+
};
|
|
57
|
+
if (node.type === 'heading') {
|
|
58
|
+
block.depth = node.depth;
|
|
59
|
+
block.text = extractText(node);
|
|
60
|
+
}
|
|
61
|
+
return block;
|
|
62
|
+
});
|
|
63
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/ai/sensemaking/src/chunk/parse.ts"],"sourcesContent":["import type { RootContent } from 'mdast';\nimport { fromMarkdown } from 'mdast-util-from-markdown';\nimport { gfmAutolinkLiteralFromMarkdown } from 'mdast-util-gfm-autolink-literal';\nimport { gfmFootnoteFromMarkdown } from 'mdast-util-gfm-footnote';\nimport { gfmStrikethroughFromMarkdown } from 'mdast-util-gfm-strikethrough';\nimport { gfmTableFromMarkdown } from 'mdast-util-gfm-table';\nimport { gfmTaskListItemFromMarkdown } from 'mdast-util-gfm-task-list-item';\nimport { gfmAutolinkLiteral } from 'micromark-extension-gfm-autolink-literal';\nimport { gfmFootnote } from 'micromark-extension-gfm-footnote';\nimport { gfmStrikethrough } from 'micromark-extension-gfm-strikethrough';\nimport { gfmTable } from 'micromark-extension-gfm-table';\nimport { gfmTaskListItem } from 'micromark-extension-gfm-task-list-item';\nimport { extractText } from './extract.ts';\nimport type { Block, BlockType } from './types.ts';\n\nconst BLOCK_TYPES: Partial<Record<RootContent['type'], BlockType>> = {\n heading: 'heading',\n paragraph: 'paragraph',\n code: 'code',\n table: 'table',\n list: 'list',\n blockquote: 'blockquote',\n};\n\n// The five extensions extract.ts/group.ts actually consume, imported individually rather than\n// through micromark-extension-gfm/mdast-util-gfm: those bundles also pull in gfm-tagfilter,\n// an HTML-serialization sanitizer this library never uses (no htmlExtensions call anywhere).\n// micromark and mdast-util-from-markdown each already flatten an extensions array themselves,\n// so no combine-extensions helper is needed here.\nconst EXTENSIONS = [gfmAutolinkLiteral(), gfmFootnote(), gfmStrikethrough(), gfmTable(), gfmTaskListItem()];\nconst MDAST_EXTENSIONS = [gfmAutolinkLiteralFromMarkdown(), gfmFootnoteFromMarkdown(), gfmStrikethroughFromMarkdown(), gfmTableFromMarkdown(), gfmTaskListItemFromMarkdown()];\n\n// Top-level blocks of a markdown body, typed and line-extent bounded. Extents come from\n// mdast's own node.position, never a regex guess at where a block starts or ends; GFM adds\n// tables, task lists, footnotes and strikethrough to the CommonMark set fromMarkdown parses.\nexport function parse(body: string): Block[] {\n const tree = fromMarkdown(body, { extensions: EXTENSIONS, mdastExtensions: MDAST_EXTENSIONS });\n return tree.children.map((node) => {\n const position = node.position;\n const block: Block = {\n type: BLOCK_TYPES[node.type] ?? 'other',\n startLine: position ? position.start.line : 1,\n endLine: position ? position.end.line : 1,\n node,\n };\n if (node.type === 'heading') {\n block.depth = node.depth;\n block.text = extractText(node);\n }\n return block;\n });\n}\n"],"names":["fromMarkdown","gfmAutolinkLiteralFromMarkdown","gfmFootnoteFromMarkdown","gfmStrikethroughFromMarkdown","gfmTableFromMarkdown","gfmTaskListItemFromMarkdown","gfmAutolinkLiteral","gfmFootnote","gfmStrikethrough","gfmTable","gfmTaskListItem","extractText","BLOCK_TYPES","heading","paragraph","code","table","list","blockquote","EXTENSIONS","MDAST_EXTENSIONS","parse","body","tree","extensions","mdastExtensions","children","map","node","position","block","type","startLine","start","line","endLine","end","depth","text"],"mappings":"AACA,SAASA,YAAY,QAAQ,2BAA2B;AACxD,SAASC,8BAA8B,QAAQ,kCAAkC;AACjF,SAASC,uBAAuB,QAAQ,0BAA0B;AAClE,SAASC,4BAA4B,QAAQ,+BAA+B;AAC5E,SAASC,oB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
|
|
1
|
+
import type { RootContent } from 'mdast';
|
|
2
|
+
export type BlockType = 'heading' | 'paragraph' | 'code' | 'table' | 'list' | 'blockquote' | 'other';
|
|
3
|
+
export interface Block {
|
|
4
|
+
type: BlockType;
|
|
5
|
+
startLine: number;
|
|
6
|
+
endLine: number;
|
|
7
|
+
depth?: number;
|
|
8
|
+
text?: string;
|
|
9
|
+
node: RootContent;
|
|
10
|
+
}
|
|
11
|
+
export interface ChunkOptions {
|
|
12
|
+
targetTokens?: number;
|
|
13
|
+
text?: 'extracted' | 'raw';
|
|
14
|
+
}
|
|
15
|
+
export interface Chunk {
|
|
16
|
+
startLine: number;
|
|
17
|
+
endLine: number;
|
|
18
|
+
text: string;
|
|
19
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/ai/sensemaking/src/chunk/types.ts"],"sourcesContent":["import type { RootContent } from 'mdast';\n\nexport type BlockType = 'heading' | 'paragraph' | 'code' | 'table' | 'list' | 'blockquote' | 'other';\n\n// One top-level mdast node plus its 1-indexed source line extent, heading depth/text if any.\n// `node` is the mdast node itself, so extract.ts and group.ts (W2) read the same parse.\nexport interface Block {\n type: BlockType;\n startLine: number;\n endLine: number;\n depth?: number;\n text?: string;\n node: RootContent;\n}\n\nexport interface ChunkOptions {\n // D3/W3b: the pgc pairing cap and the sole owner lever (embed.chunkTokens); default 500.\n targetTokens?: number;\n // D9: 'raw' (source lines verbatim) is the shipped default; 'extracted' (flavor-resolved)\n // stays available for a future measured revisit, not currently shipped.\n text?: 'extracted' | 'raw';\n}\n\n// One grouped, extracted unit: 1-indexed line extent over the body, flavor-resolved text.\nexport interface Chunk {\n startLine: number;\n endLine: number;\n text: string;\n}\n"],"names":[],"mappings":"AAuBA,0FAA0F;AAC1F,WAIC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const CHUNK_VERSION = "chunk:v5";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/ai/sensemaking/src/chunk/version.ts"],"sourcesContent":["// D8: bump whenever chunk semantics change (grouping, sizing, splitting); the digest in\n// test/unit/chunk/version.test.ts tracks EXTRACTION changes only, so the two move independently.\nexport const CHUNK_VERSION = 'chunk:v5';\n"],"names":["CHUNK_VERSION"],"mappings":"AAAA,wFAAwF;AACxF,iGAAiG;AACjG,OAAO,MAAMA,gBAAgB,WAAW"}
|
package/dist/esm/cli/download.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
+
import { basename } from 'node:path';
|
|
1
2
|
import { embedConfig } from '../config/index.js';
|
|
3
|
+
import { downloadModel, isDownloadable, modelDir, modelPresent } from '../embed/store.js';
|
|
2
4
|
import { SenseError } from '../errors.js';
|
|
3
|
-
import { downloadModel, modelDir, modelPresent } from '../features/embed.js';
|
|
4
5
|
import { USAGE } from './index.js';
|
|
5
6
|
import { CONFIG, parse } from './shared.js';
|
|
6
|
-
//
|
|
7
|
-
//
|
|
8
|
-
// is no prompt for CI to bypass; running it twice is a no-op.
|
|
7
|
+
// A prefetch over the store's own fetch path: a search would fetch the same weights
|
|
8
|
+
// lazily, so this only moves the wait earlier. Idempotent; asks nothing, so CI can run it unattended.
|
|
9
9
|
const download = async (ctx)=>{
|
|
10
10
|
const { values } = parse(ctx.argv, `usage: ${ctx.name} ${USAGE.download}`, {
|
|
11
11
|
...CONFIG
|
|
@@ -13,15 +13,16 @@ const download = async (ctx)=>{
|
|
|
13
13
|
const cfg = ctx.resolveConfig(values.config);
|
|
14
14
|
const e = embedConfig(cfg);
|
|
15
15
|
if (!e) throw new SenseError('EMBED_DISABLED', 'no preset asks for vectors, so there is no model to download');
|
|
16
|
-
if (e.
|
|
17
|
-
console.log(`embed
|
|
16
|
+
if (e.provider !== 'static') {
|
|
17
|
+
console.log(`embed provider is "${e.provider}" (${e.url}), so there is nothing to download; ${ctx.name} search reaches it over the network`);
|
|
18
18
|
return;
|
|
19
19
|
}
|
|
20
20
|
if (modelPresent(cfg)) {
|
|
21
|
-
|
|
21
|
+
const at = isDownloadable(e.model) ? `@${basename(modelDir(e.model))} ` : ' ';
|
|
22
|
+
console.log(`${e.model}${at}is already available in ${modelDir(e.model)}`);
|
|
22
23
|
return;
|
|
23
24
|
}
|
|
24
25
|
const dir = await downloadModel(e.model, (file, into)=>console.error(`fetching ${e.model}/${file} into ${into}`));
|
|
25
|
-
console.log(`downloaded ${e.model} into ${dir}`);
|
|
26
|
+
console.log(`downloaded ${e.model}@${basename(dir)} into ${dir}`);
|
|
26
27
|
};
|
|
27
28
|
export default download;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/ai/sensemaking/src/cli/download.ts"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/ai/sensemaking/src/cli/download.ts"],"sourcesContent":["import { basename } from 'node:path';\nimport { embedConfig } from '../config/index.ts';\nimport { downloadModel, isDownloadable, modelDir, modelPresent } from '../embed/store.ts';\nimport { SenseError } from '../errors.ts';\nimport { USAGE } from './index.ts';\nimport { CONFIG, parse } from './shared.ts';\nimport type { Command } from './types.ts';\n\n// A prefetch over the store's own fetch path: a search would fetch the same weights\n// lazily, so this only moves the wait earlier. Idempotent; asks nothing, so CI can run it unattended.\nconst download: Command = async (ctx) => {\n const { values } = parse(ctx.argv, `usage: ${ctx.name} ${USAGE.download}`, { ...CONFIG });\n const cfg = ctx.resolveConfig(values.config as string | undefined);\n const e = embedConfig(cfg);\n if (!e) throw new SenseError('EMBED_DISABLED', 'no preset asks for vectors, so there is no model to download');\n\n if (e.provider !== 'static') {\n console.log(`embed provider is \"${e.provider}\" (${e.url}), so there is nothing to download; ${ctx.name} search reaches it over the network`);\n return;\n }\n if (modelPresent(cfg)) {\n const at = isDownloadable(e.model) ? `@${basename(modelDir(e.model))} ` : ' ';\n console.log(`${e.model}${at}is already available in ${modelDir(e.model)}`);\n return;\n }\n const dir = await downloadModel(e.model, (file, into) => console.error(`fetching ${e.model}/${file} into ${into}`));\n console.log(`downloaded ${e.model}@${basename(dir)} into ${dir}`);\n};\nexport default download;\n"],"names":["basename","embedConfig","downloadModel","isDownloadable","modelDir","modelPresent","SenseError","USAGE","CONFIG","parse","download","ctx","values","argv","name","cfg","resolveConfig","config","e","provider","console","log","url","at","model","dir","file","into","error"],"mappings":"AAAA,SAASA,QAAQ,QAAQ,YAAY;AACrC,SAASC,WAAW,QAAQ,qBAAqB;AACjD,SAASC,aAAa,EAAEC,cAAc,EAAEC,QAAQ,EAAEC,YAAY,QAAQ,oBAAoB;AAC1F,SAASC,UAAU,QAAQ,eAAe;AAC1C,SAASC,KAAK,QAAQ,aAAa;AACnC,SAASC,MAAM,EAAEC,KAAK,QAAQ,cAAc;AAG5C,oFAAoF;AACpF,sGAAsG;AACtG,MAAMC,WAAoB,OAAOC;IAC/B,MAAM,EAAEC,MAAM,EAAE,GAAGH,MAAME,IAAIE,IAAI,EAAE,CAAC,OAAO,EAAEF,IAAIG,IAAI,CAAC,CAAC,EAAEP,MAAMG,QAAQ,EAAE,EAAE;QAAE,GAAGF,MAAM;IAAC;IACvF,MAAMO,MAAMJ,IAAIK,aAAa,CAACJ,OAAOK,MAAM;IAC3C,MAAMC,IAAIjB,YAAYc;IACtB,IAAI,CAACG,GAAG,MAAM,IAAIZ,WAAW,kBAAkB;IAE/C,IAAIY,EAAEC,QAAQ,KAAK,UAAU;QAC3BC,QAAQC,GAAG,CAAC,CAAC,mBAAmB,EAAEH,EAAEC,QAAQ,CAAC,GAAG,EAAED,EAAEI,GAAG,CAAC,oCAAoC,EAAEX,IAAIG,IAAI,CAAC,mCAAmC,CAAC;QAC3I;IACF;IACA,IAAIT,aAAaU,MAAM;QACrB,MAAMQ,KAAKpB,eAAee,EAAEM,KAAK,IAAI,CAAC,CAAC,EAAExB,SAASI,SAASc,EAAEM,KAAK,GAAG,CAAC,CAAC,GAAG;QAC1EJ,QAAQC,GAAG,CAAC,GAAGH,EAAEM,KAAK,GAAGD,GAAG,wBAAwB,EAAEnB,SAASc,EAAEM,KAAK,GAAG;QACzE;IACF;IACA,MAAMC,MAAM,MAAMvB,cAAcgB,EAAEM,KAAK,EAAE,CAACE,MAAMC,OAASP,QAAQQ,KAAK,CAAC,CAAC,SAAS,EAAEV,EAAEM,KAAK,CAAC,CAAC,EAAEE,KAAK,MAAM,EAAEC,MAAM;IACjHP,QAAQC,GAAG,CAAC,CAAC,WAAW,EAAEH,EAAEM,KAAK,CAAC,CAAC,EAAExB,SAASyB,KAAK,MAAM,EAAEA,KAAK;AAClE;AACA,eAAef,SAAS"}
|
package/dist/esm/cli/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Command } from './types.js';
|
|
2
2
|
export declare const USAGE: {
|
|
3
|
-
readonly init: "init";
|
|
3
|
+
readonly init: "init [--model id-or-path] [--provider static|openai|cohere] [--url url]";
|
|
4
4
|
readonly watch: "watch [--force] [--config path]";
|
|
5
5
|
readonly status: "status [--format table|json] [--config path]";
|
|
6
6
|
readonly download: "download [--config path]";
|
package/dist/esm/cli/index.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// top-level usage() and the command's own parse() error/--help output, so there is one
|
|
3
3
|
// copy of each line, not two that can drift.
|
|
4
4
|
export const USAGE = {
|
|
5
|
-
init: 'init',
|
|
5
|
+
init: 'init [--model id-or-path] [--provider static|openai|cohere] [--url url]',
|
|
6
6
|
watch: 'watch [--force] [--config path]',
|
|
7
7
|
status: 'status [--format table|json] [--config path]',
|
|
8
8
|
download: 'download [--config path]',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/ai/sensemaking/src/cli/index.ts"],"sourcesContent":["import type { Command } from './types.ts';\n\n// Each command's usage line, minus the leading \"usage: <name> \" -- shared by cli.ts's\n// top-level usage() and the command's own parse() error/--help output, so there is one\n// copy of each line, not two that can drift.\nexport const USAGE = {\n init: 'init',\n watch: 'watch [--force] [--config path]',\n status: 'status [--format table|json] [--config path]',\n download: 'download [--config path]',\n sql: 'sql \"<statement>\" [params...] [--preset name] [--format table|json|csv] [--config path]',\n search: 'search \"<terms>\" [--preset name] [--include glob ...] [--exclude glob ...] [--no-exclude] [--where \"<sql>\"] [--k n] [--format table|json|csv] [--config path]',\n map: 'map [--format table|json] [--config path]',\n peek: 'peek <path> [--preset name] [--include glob ...] [--exclude glob ...] [--no-exclude] [--where \"<sql>\"] [--format table|json] [--config path]',\n path: 'path <a> <b> [--preset name] [--include glob ...] [--exclude glob ...] [--no-exclude] [--where \"<sql>\"] [--max-depth n] [--format table|json] [--config path]',\n related: 'related <note> [--preset name] [--include glob ...] [--exclude glob ...] [--no-exclude] [--where \"<sql>\"] [--k n] [--format table|json|csv] [--config path]',\n} as const;\n\n// Lazy registry: a command's imports load only when it runs, so a heavy dependency in one\n// command never taxes the others (or --version/--help). These names are reserved: a saved\n// entry in config can never shadow them.\nexport const COMMANDS: Record<string, () => Promise<{ default: Command }>> = {\n init: () => import('./init.ts'),\n watch: () => import('./watch.ts'),\n status: () => import('./status.ts'),\n download: () => import('./download.ts'),\n sql: () => import('./sql.ts'),\n search: () => import('./search.ts'),\n map: () => import('./map.ts'),\n peek: () => import('./peek.ts'),\n path: () => import('./path.ts'),\n related: () => import('./related.ts'),\n};\n\nexport type { Command, Ctx } from './types.ts';\n"],"names":["USAGE","init","watch","status","download","sql","search","map","peek","path","related","COMMANDS"],"mappings":"AAEA,sFAAsF;AACtF,uFAAuF;AACvF,6CAA6C;AAC7C,OAAO,MAAMA,QAAQ;IACnBC,MAAM;IACNC,OAAO;IACPC,QAAQ;IACRC,UAAU;IACVC,KAAK;IACLC,QAAQ;IACRC,KAAK;IACLC,MAAM;IACNC,MAAM;IACNC,SAAS;AACX,EAAW;AAEX,0FAA0F;AAC1F,0FAA0F;AAC1F,yCAAyC;AACzC,OAAO,MAAMC,WAAgE;IAC3EV,MAAM,IAAM,MAAM,CAAC;IACnBC,OAAO,IAAM,MAAM,CAAC;IACpBC,QAAQ,IAAM,MAAM,CAAC;IACrBC,UAAU,IAAM,MAAM,CAAC;IACvBC,KAAK,IAAM,MAAM,CAAC;IAClBC,QAAQ,IAAM,MAAM,CAAC;IACrBC,KAAK,IAAM,MAAM,CAAC;IAClBC,MAAM,IAAM,MAAM,CAAC;IACnBC,MAAM,IAAM,MAAM,CAAC;IACnBC,SAAS,IAAM,MAAM,CAAC;AACxB,EAAE"}
|
|
1
|
+
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/ai/sensemaking/src/cli/index.ts"],"sourcesContent":["import type { Command } from './types.ts';\n\n// Each command's usage line, minus the leading \"usage: <name> \" -- shared by cli.ts's\n// top-level usage() and the command's own parse() error/--help output, so there is one\n// copy of each line, not two that can drift.\nexport const USAGE = {\n init: 'init [--model id-or-path] [--provider static|openai|cohere] [--url url]',\n watch: 'watch [--force] [--config path]',\n status: 'status [--format table|json] [--config path]',\n download: 'download [--config path]',\n sql: 'sql \"<statement>\" [params...] [--preset name] [--format table|json|csv] [--config path]',\n search: 'search \"<terms>\" [--preset name] [--include glob ...] [--exclude glob ...] [--no-exclude] [--where \"<sql>\"] [--k n] [--format table|json|csv] [--config path]',\n map: 'map [--format table|json] [--config path]',\n peek: 'peek <path> [--preset name] [--include glob ...] [--exclude glob ...] [--no-exclude] [--where \"<sql>\"] [--format table|json] [--config path]',\n path: 'path <a> <b> [--preset name] [--include glob ...] [--exclude glob ...] [--no-exclude] [--where \"<sql>\"] [--max-depth n] [--format table|json] [--config path]',\n related: 'related <note> [--preset name] [--include glob ...] [--exclude glob ...] [--no-exclude] [--where \"<sql>\"] [--k n] [--format table|json|csv] [--config path]',\n} as const;\n\n// Lazy registry: a command's imports load only when it runs, so a heavy dependency in one\n// command never taxes the others (or --version/--help). These names are reserved: a saved\n// entry in config can never shadow them.\nexport const COMMANDS: Record<string, () => Promise<{ default: Command }>> = {\n init: () => import('./init.ts'),\n watch: () => import('./watch.ts'),\n status: () => import('./status.ts'),\n download: () => import('./download.ts'),\n sql: () => import('./sql.ts'),\n search: () => import('./search.ts'),\n map: () => import('./map.ts'),\n peek: () => import('./peek.ts'),\n path: () => import('./path.ts'),\n related: () => import('./related.ts'),\n};\n\nexport type { Command, Ctx } from './types.ts';\n"],"names":["USAGE","init","watch","status","download","sql","search","map","peek","path","related","COMMANDS"],"mappings":"AAEA,sFAAsF;AACtF,uFAAuF;AACvF,6CAA6C;AAC7C,OAAO,MAAMA,QAAQ;IACnBC,MAAM;IACNC,OAAO;IACPC,QAAQ;IACRC,UAAU;IACVC,KAAK;IACLC,QAAQ;IACRC,KAAK;IACLC,MAAM;IACNC,MAAM;IACNC,SAAS;AACX,EAAW;AAEX,0FAA0F;AAC1F,0FAA0F;AAC1F,yCAAyC;AACzC,OAAO,MAAMC,WAAgE;IAC3EV,MAAM,IAAM,MAAM,CAAC;IACnBC,OAAO,IAAM,MAAM,CAAC;IACpBC,QAAQ,IAAM,MAAM,CAAC;IACrBC,UAAU,IAAM,MAAM,CAAC;IACvBC,KAAK,IAAM,MAAM,CAAC;IAClBC,QAAQ,IAAM,MAAM,CAAC;IACrBC,KAAK,IAAM,MAAM,CAAC;IAClBC,MAAM,IAAM,MAAM,CAAC;IACnBC,MAAM,IAAM,MAAM,CAAC;IACnBC,SAAS,IAAM,MAAM,CAAC;AACxB,EAAE"}
|
package/dist/esm/cli/init.js
CHANGED
|
@@ -1,14 +1,40 @@
|
|
|
1
|
-
import { initConfig } from '../config/index.js';
|
|
1
|
+
import { DEFAULT_EMBED_MODEL, initConfig } from '../config/index.js';
|
|
2
2
|
import { USAGE } from './index.js';
|
|
3
3
|
import { parse } from './shared.js';
|
|
4
4
|
const init = (ctx)=>{
|
|
5
|
-
parse(ctx.argv, `usage: ${ctx.name} ${USAGE.init}`, {
|
|
6
|
-
|
|
5
|
+
const { values } = parse(ctx.argv, `usage: ${ctx.name} ${USAGE.init}`, {
|
|
6
|
+
model: {
|
|
7
|
+
type: 'string'
|
|
8
|
+
},
|
|
9
|
+
provider: {
|
|
10
|
+
type: 'string'
|
|
11
|
+
},
|
|
12
|
+
url: {
|
|
13
|
+
type: 'string'
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
const modelFlag = values.model;
|
|
17
|
+
const providerFlag = values.provider;
|
|
18
|
+
const model = modelFlag !== null && modelFlag !== void 0 ? modelFlag : DEFAULT_EMBED_MODEL;
|
|
19
|
+
const provider = providerFlag !== null && providerFlag !== void 0 ? providerFlag : 'static';
|
|
20
|
+
const url = values.url;
|
|
21
|
+
// An invalid --provider throws here (validateConfig's own shape error), before anything is
|
|
22
|
+
// written -- one validator, not a second copy of its rules.
|
|
23
|
+
const configPath = initConfig(process.cwd(), {
|
|
24
|
+
model: modelFlag,
|
|
25
|
+
provider: providerFlag,
|
|
26
|
+
url
|
|
27
|
+
});
|
|
7
28
|
console.log(`created ${configPath}`);
|
|
8
29
|
console.log(`query away: ${ctx.name} sql "SELECT path FROM frontmatter LIMIT 10"`);
|
|
9
|
-
//
|
|
10
|
-
//
|
|
11
|
-
|
|
30
|
+
// Naming a model is consent to fetch it, so writing one into the config says so loudly,
|
|
31
|
+
// with the download consequence and the prefetch command, right where it was just written.
|
|
32
|
+
if (provider === 'static') {
|
|
33
|
+
console.log(`embed model: ${model} (static); nothing downloads until the first vector search -- ${ctx.name} download fetches it now instead`);
|
|
34
|
+
} else {
|
|
35
|
+
console.log(`embed model: ${model} (${provider}${url ? ` at ${url}` : ''}); reached over the network at search time, nothing to download`);
|
|
36
|
+
}
|
|
37
|
+
console.log('a non-English tree should pick a model for its languages: see the sense-setup skill or INTEGRATIONS.md');
|
|
12
38
|
// The decisions a new tree faces -- features, frontmatter conventions, note size -- are not
|
|
13
39
|
// in this output; name both places that hold them, since an agent may have neither.
|
|
14
40
|
console.log('features and tree design: the sense-setup skill, or schema.json');
|
package/dist/esm/cli/init.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/ai/sensemaking/src/cli/init.ts"],"sourcesContent":["import { initConfig } from '../config/index.ts';\nimport { USAGE } from './index.ts';\nimport { parse } from './shared.ts';\nimport type { Command } from './types.ts';\n\nconst init: Command = (ctx) => {\n parse(ctx.argv, `usage: ${ctx.name} ${USAGE.init}`, {});\n const configPath = initConfig(process.cwd());\n console.log(`created ${configPath}`);\n console.log(`query away: ${ctx.name} sql \"SELECT path FROM frontmatter LIMIT 10\"`);\n //
|
|
1
|
+
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/ai/sensemaking/src/cli/init.ts"],"sourcesContent":["import { DEFAULT_EMBED_MODEL, initConfig } from '../config/index.ts';\nimport { USAGE } from './index.ts';\nimport { parse } from './shared.ts';\nimport type { Command } from './types.ts';\n\nconst init: Command = (ctx) => {\n const { values } = parse(ctx.argv, `usage: ${ctx.name} ${USAGE.init}`, {\n model: { type: 'string' },\n provider: { type: 'string' },\n url: { type: 'string' },\n });\n const modelFlag = values.model as string | undefined;\n const providerFlag = values.provider as string | undefined;\n const model = modelFlag ?? DEFAULT_EMBED_MODEL;\n const provider = providerFlag ?? 'static';\n const url = values.url as string | undefined;\n // An invalid --provider throws here (validateConfig's own shape error), before anything is\n // written -- one validator, not a second copy of its rules.\n const configPath = initConfig(process.cwd(), { model: modelFlag, provider: providerFlag, url });\n console.log(`created ${configPath}`);\n console.log(`query away: ${ctx.name} sql \"SELECT path FROM frontmatter LIMIT 10\"`);\n // Naming a model is consent to fetch it, so writing one into the config says so loudly,\n // with the download consequence and the prefetch command, right where it was just written.\n if (provider === 'static') {\n console.log(`embed model: ${model} (static); nothing downloads until the first vector search -- ${ctx.name} download fetches it now instead`);\n } else {\n console.log(`embed model: ${model} (${provider}${url ? ` at ${url}` : ''}); reached over the network at search time, nothing to download`);\n }\n console.log('a non-English tree should pick a model for its languages: see the sense-setup skill or INTEGRATIONS.md');\n // The decisions a new tree faces -- features, frontmatter conventions, note size -- are not\n // in this output; name both places that hold them, since an agent may have neither.\n console.log('features and tree design: the sense-setup skill, or schema.json');\n};\nexport default init;\n"],"names":["DEFAULT_EMBED_MODEL","initConfig","USAGE","parse","init","ctx","values","argv","name","model","type","provider","url","modelFlag","providerFlag","configPath","process","cwd","console","log"],"mappings":"AAAA,SAASA,mBAAmB,EAAEC,UAAU,QAAQ,qBAAqB;AACrE,SAASC,KAAK,QAAQ,aAAa;AACnC,SAASC,KAAK,QAAQ,cAAc;AAGpC,MAAMC,OAAgB,CAACC;IACrB,MAAM,EAAEC,MAAM,EAAE,GAAGH,MAAME,IAAIE,IAAI,EAAE,CAAC,OAAO,EAAEF,IAAIG,IAAI,CAAC,CAAC,EAAEN,MAAME,IAAI,EAAE,EAAE;QACrEK,OAAO;YAAEC,MAAM;QAAS;QACxBC,UAAU;YAAED,MAAM;QAAS;QAC3BE,KAAK;YAAEF,MAAM;QAAS;IACxB;IACA,MAAMG,YAAYP,OAAOG,KAAK;IAC9B,MAAMK,eAAeR,OAAOK,QAAQ;IACpC,MAAMF,QAAQI,sBAAAA,uBAAAA,YAAab;IAC3B,MAAMW,WAAWG,yBAAAA,0BAAAA,eAAgB;IACjC,MAAMF,MAAMN,OAAOM,GAAG;IACtB,2FAA2F;IAC3F,4DAA4D;IAC5D,MAAMG,aAAad,WAAWe,QAAQC,GAAG,IAAI;QAAER,OAAOI;QAAWF,UAAUG;QAAcF;IAAI;IAC7FM,QAAQC,GAAG,CAAC,CAAC,QAAQ,EAAEJ,YAAY;IACnCG,QAAQC,GAAG,CAAC,CAAC,YAAY,EAAEd,IAAIG,IAAI,CAAC,4CAA4C,CAAC;IACjF,wFAAwF;IACxF,2FAA2F;IAC3F,IAAIG,aAAa,UAAU;QACzBO,QAAQC,GAAG,CAAC,CAAC,aAAa,EAAEV,MAAM,8DAA8D,EAAEJ,IAAIG,IAAI,CAAC,gCAAgC,CAAC;IAC9I,OAAO;QACLU,QAAQC,GAAG,CAAC,CAAC,aAAa,EAAEV,MAAM,EAAE,EAAEE,WAAWC,MAAM,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