@colbymchenry/codegraph 0.7.10 → 0.9.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 +70 -54
- package/npm-shim.js +43 -0
- package/package.json +13 -51
- package/LICENSE +0 -21
- package/dist/bin/codegraph.d.ts +0 -21
- package/dist/bin/codegraph.d.ts.map +0 -1
- package/dist/bin/codegraph.js +0 -1232
- package/dist/bin/codegraph.js.map +0 -1
- package/dist/bin/node-version-check.d.ts +0 -20
- package/dist/bin/node-version-check.d.ts.map +0 -1
- package/dist/bin/node-version-check.js +0 -42
- package/dist/bin/node-version-check.js.map +0 -1
- package/dist/bin/uninstall.d.ts +0 -14
- package/dist/bin/uninstall.d.ts.map +0 -1
- package/dist/bin/uninstall.js +0 -36
- package/dist/bin/uninstall.js.map +0 -1
- package/dist/config.d.ts +0 -51
- package/dist/config.d.ts.map +0 -1
- package/dist/config.js +0 -321
- package/dist/config.js.map +0 -1
- package/dist/context/formatter.d.ts +0 -30
- package/dist/context/formatter.d.ts.map +0 -1
- package/dist/context/formatter.js +0 -244
- package/dist/context/formatter.js.map +0 -1
- package/dist/context/index.d.ts +0 -97
- package/dist/context/index.d.ts.map +0 -1
- package/dist/context/index.js +0 -1048
- package/dist/context/index.js.map +0 -1
- package/dist/db/index.d.ts +0 -72
- package/dist/db/index.d.ts.map +0 -1
- package/dist/db/index.js +0 -200
- package/dist/db/index.js.map +0 -1
- package/dist/db/migrations.d.ts +0 -44
- package/dist/db/migrations.d.ts.map +0 -1
- package/dist/db/migrations.js +0 -131
- package/dist/db/migrations.js.map +0 -1
- package/dist/db/queries.d.ts +0 -253
- package/dist/db/queries.d.ts.map +0 -1
- package/dist/db/queries.js +0 -1207
- package/dist/db/queries.js.map +0 -1
- package/dist/db/schema.sql +0 -151
- package/dist/db/sqlite-adapter.d.ts +0 -52
- package/dist/db/sqlite-adapter.d.ts.map +0 -1
- package/dist/db/sqlite-adapter.js +0 -237
- package/dist/db/sqlite-adapter.js.map +0 -1
- package/dist/directory.d.ts +0 -57
- package/dist/directory.d.ts.map +0 -1
- package/dist/directory.js +0 -264
- package/dist/directory.js.map +0 -1
- package/dist/errors.d.ts +0 -136
- package/dist/errors.d.ts.map +0 -1
- package/dist/errors.js +0 -219
- package/dist/errors.js.map +0 -1
- package/dist/extraction/dfm-extractor.d.ts +0 -31
- package/dist/extraction/dfm-extractor.d.ts.map +0 -1
- package/dist/extraction/dfm-extractor.js +0 -151
- package/dist/extraction/dfm-extractor.js.map +0 -1
- package/dist/extraction/grammars.d.ts +0 -78
- package/dist/extraction/grammars.d.ts.map +0 -1
- package/dist/extraction/grammars.js +0 -322
- package/dist/extraction/grammars.js.map +0 -1
- package/dist/extraction/index.d.ts +0 -130
- package/dist/extraction/index.d.ts.map +0 -1
- package/dist/extraction/index.js +0 -1279
- package/dist/extraction/index.js.map +0 -1
- package/dist/extraction/languages/c-cpp.d.ts +0 -4
- package/dist/extraction/languages/c-cpp.d.ts.map +0 -1
- package/dist/extraction/languages/c-cpp.js +0 -126
- package/dist/extraction/languages/c-cpp.js.map +0 -1
- package/dist/extraction/languages/csharp.d.ts +0 -3
- package/dist/extraction/languages/csharp.d.ts.map +0 -1
- package/dist/extraction/languages/csharp.js +0 -72
- package/dist/extraction/languages/csharp.js.map +0 -1
- package/dist/extraction/languages/dart.d.ts +0 -3
- package/dist/extraction/languages/dart.d.ts.map +0 -1
- package/dist/extraction/languages/dart.js +0 -192
- package/dist/extraction/languages/dart.js.map +0 -1
- package/dist/extraction/languages/go.d.ts +0 -3
- package/dist/extraction/languages/go.d.ts.map +0 -1
- package/dist/extraction/languages/go.js +0 -58
- package/dist/extraction/languages/go.js.map +0 -1
- package/dist/extraction/languages/index.d.ts +0 -10
- package/dist/extraction/languages/index.d.ts.map +0 -1
- package/dist/extraction/languages/index.js +0 -45
- package/dist/extraction/languages/index.js.map +0 -1
- package/dist/extraction/languages/java.d.ts +0 -3
- package/dist/extraction/languages/java.d.ts.map +0 -1
- package/dist/extraction/languages/java.js +0 -64
- package/dist/extraction/languages/java.js.map +0 -1
- package/dist/extraction/languages/javascript.d.ts +0 -3
- package/dist/extraction/languages/javascript.d.ts.map +0 -1
- package/dist/extraction/languages/javascript.js +0 -90
- package/dist/extraction/languages/javascript.js.map +0 -1
- package/dist/extraction/languages/kotlin.d.ts +0 -3
- package/dist/extraction/languages/kotlin.d.ts.map +0 -1
- package/dist/extraction/languages/kotlin.js +0 -253
- package/dist/extraction/languages/kotlin.js.map +0 -1
- package/dist/extraction/languages/pascal.d.ts +0 -3
- package/dist/extraction/languages/pascal.d.ts.map +0 -1
- package/dist/extraction/languages/pascal.js +0 -66
- package/dist/extraction/languages/pascal.js.map +0 -1
- package/dist/extraction/languages/php.d.ts +0 -3
- package/dist/extraction/languages/php.d.ts.map +0 -1
- package/dist/extraction/languages/php.js +0 -107
- package/dist/extraction/languages/php.js.map +0 -1
- package/dist/extraction/languages/python.d.ts +0 -3
- package/dist/extraction/languages/python.d.ts.map +0 -1
- package/dist/extraction/languages/python.js +0 -56
- package/dist/extraction/languages/python.js.map +0 -1
- package/dist/extraction/languages/ruby.d.ts +0 -3
- package/dist/extraction/languages/ruby.d.ts.map +0 -1
- package/dist/extraction/languages/ruby.js +0 -114
- package/dist/extraction/languages/ruby.js.map +0 -1
- package/dist/extraction/languages/rust.d.ts +0 -3
- package/dist/extraction/languages/rust.d.ts.map +0 -1
- package/dist/extraction/languages/rust.js +0 -109
- package/dist/extraction/languages/rust.js.map +0 -1
- package/dist/extraction/languages/scala.d.ts +0 -3
- package/dist/extraction/languages/scala.d.ts.map +0 -1
- package/dist/extraction/languages/scala.js +0 -139
- package/dist/extraction/languages/scala.js.map +0 -1
- package/dist/extraction/languages/swift.d.ts +0 -3
- package/dist/extraction/languages/swift.d.ts.map +0 -1
- package/dist/extraction/languages/swift.js +0 -91
- package/dist/extraction/languages/swift.js.map +0 -1
- package/dist/extraction/languages/typescript.d.ts +0 -3
- package/dist/extraction/languages/typescript.d.ts.map +0 -1
- package/dist/extraction/languages/typescript.js +0 -129
- package/dist/extraction/languages/typescript.js.map +0 -1
- package/dist/extraction/liquid-extractor.d.ts +0 -52
- package/dist/extraction/liquid-extractor.d.ts.map +0 -1
- package/dist/extraction/liquid-extractor.js +0 -313
- package/dist/extraction/liquid-extractor.js.map +0 -1
- package/dist/extraction/parse-worker.d.ts +0 -8
- package/dist/extraction/parse-worker.d.ts.map +0 -1
- package/dist/extraction/parse-worker.js +0 -94
- package/dist/extraction/parse-worker.js.map +0 -1
- package/dist/extraction/svelte-extractor.d.ts +0 -56
- package/dist/extraction/svelte-extractor.d.ts.map +0 -1
- package/dist/extraction/svelte-extractor.js +0 -272
- package/dist/extraction/svelte-extractor.js.map +0 -1
- package/dist/extraction/tree-sitter-helpers.d.ts +0 -28
- package/dist/extraction/tree-sitter-helpers.d.ts.map +0 -1
- package/dist/extraction/tree-sitter-helpers.js +0 -103
- package/dist/extraction/tree-sitter-helpers.js.map +0 -1
- package/dist/extraction/tree-sitter-types.d.ts +0 -179
- package/dist/extraction/tree-sitter-types.d.ts.map +0 -1
- package/dist/extraction/tree-sitter-types.js +0 -10
- package/dist/extraction/tree-sitter-types.js.map +0 -1
- package/dist/extraction/tree-sitter.d.ts +0 -233
- package/dist/extraction/tree-sitter.d.ts.map +0 -1
- package/dist/extraction/tree-sitter.js +0 -2393
- package/dist/extraction/tree-sitter.js.map +0 -1
- package/dist/extraction/vue-extractor.d.ts +0 -36
- package/dist/extraction/vue-extractor.d.ts.map +0 -1
- package/dist/extraction/vue-extractor.js +0 -163
- package/dist/extraction/vue-extractor.js.map +0 -1
- package/dist/extraction/wasm/tree-sitter-pascal.wasm +0 -0
- package/dist/extraction/wasm/tree-sitter-scala.wasm +0 -0
- package/dist/graph/index.d.ts +0 -8
- package/dist/graph/index.d.ts.map +0 -1
- package/dist/graph/index.js +0 -13
- package/dist/graph/index.js.map +0 -1
- package/dist/graph/queries.d.ts +0 -106
- package/dist/graph/queries.d.ts.map +0 -1
- package/dist/graph/queries.js +0 -366
- package/dist/graph/queries.js.map +0 -1
- package/dist/graph/traversal.d.ts +0 -127
- package/dist/graph/traversal.d.ts.map +0 -1
- package/dist/graph/traversal.js +0 -493
- package/dist/graph/traversal.js.map +0 -1
- package/dist/index.d.ts +0 -447
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js +0 -825
- package/dist/index.js.map +0 -1
- package/dist/installer/claude-md-template.d.ts +0 -14
- package/dist/installer/claude-md-template.d.ts.map +0 -1
- package/dist/installer/claude-md-template.js +0 -21
- package/dist/installer/claude-md-template.js.map +0 -1
- package/dist/installer/config-writer.d.ts +0 -29
- package/dist/installer/config-writer.d.ts.map +0 -1
- package/dist/installer/config-writer.js +0 -109
- package/dist/installer/config-writer.js.map +0 -1
- package/dist/installer/index.d.ts +0 -53
- package/dist/installer/index.d.ts.map +0 -1
- package/dist/installer/index.js +0 -338
- package/dist/installer/index.js.map +0 -1
- package/dist/installer/instructions-template.d.ts +0 -28
- package/dist/installer/instructions-template.d.ts.map +0 -1
- package/dist/installer/instructions-template.js +0 -63
- package/dist/installer/instructions-template.js.map +0 -1
- package/dist/installer/targets/claude.d.ts +0 -27
- package/dist/installer/targets/claude.d.ts.map +0 -1
- package/dist/installer/targets/claude.js +0 -246
- package/dist/installer/targets/claude.js.map +0 -1
- package/dist/installer/targets/codex.d.ts +0 -18
- package/dist/installer/targets/codex.d.ts.map +0 -1
- package/dist/installer/targets/codex.js +0 -185
- package/dist/installer/targets/codex.js.map +0 -1
- package/dist/installer/targets/cursor.d.ts +0 -35
- package/dist/installer/targets/cursor.d.ts.map +0 -1
- package/dist/installer/targets/cursor.js +0 -229
- package/dist/installer/targets/cursor.js.map +0 -1
- package/dist/installer/targets/opencode.d.ts +0 -30
- package/dist/installer/targets/opencode.d.ts.map +0 -1
- package/dist/installer/targets/opencode.js +0 -235
- package/dist/installer/targets/opencode.js.map +0 -1
- package/dist/installer/targets/registry.d.ts +0 -35
- package/dist/installer/targets/registry.d.ts.map +0 -1
- package/dist/installer/targets/registry.js +0 -83
- package/dist/installer/targets/registry.js.map +0 -1
- package/dist/installer/targets/shared.d.ts +0 -77
- package/dist/installer/targets/shared.d.ts.map +0 -1
- package/dist/installer/targets/shared.js +0 -246
- package/dist/installer/targets/shared.js.map +0 -1
- package/dist/installer/targets/toml.d.ts +0 -52
- package/dist/installer/targets/toml.d.ts.map +0 -1
- package/dist/installer/targets/toml.js +0 -147
- package/dist/installer/targets/toml.js.map +0 -1
- package/dist/installer/targets/types.d.ts +0 -116
- package/dist/installer/targets/types.d.ts.map +0 -1
- package/dist/installer/targets/types.js +0 -16
- package/dist/installer/targets/types.js.map +0 -1
- package/dist/mcp/index.d.ts +0 -86
- package/dist/mcp/index.d.ts.map +0 -1
- package/dist/mcp/index.js +0 -355
- package/dist/mcp/index.js.map +0 -1
- package/dist/mcp/server-instructions.d.ts +0 -19
- package/dist/mcp/server-instructions.d.ts.map +0 -1
- package/dist/mcp/server-instructions.js +0 -59
- package/dist/mcp/server-instructions.js.map +0 -1
- package/dist/mcp/tools.d.ts +0 -200
- package/dist/mcp/tools.d.ts.map +0 -1
- package/dist/mcp/tools.js +0 -1319
- package/dist/mcp/tools.js.map +0 -1
- package/dist/mcp/transport.d.ts +0 -89
- package/dist/mcp/transport.d.ts.map +0 -1
- package/dist/mcp/transport.js +0 -170
- package/dist/mcp/transport.js.map +0 -1
- package/dist/resolution/frameworks/cargo-workspace.d.ts +0 -18
- package/dist/resolution/frameworks/cargo-workspace.d.ts.map +0 -1
- package/dist/resolution/frameworks/cargo-workspace.js +0 -225
- package/dist/resolution/frameworks/cargo-workspace.js.map +0 -1
- package/dist/resolution/frameworks/csharp.d.ts +0 -8
- package/dist/resolution/frameworks/csharp.d.ts.map +0 -1
- package/dist/resolution/frameworks/csharp.js +0 -213
- package/dist/resolution/frameworks/csharp.js.map +0 -1
- package/dist/resolution/frameworks/express.d.ts +0 -8
- package/dist/resolution/frameworks/express.d.ts.map +0 -1
- package/dist/resolution/frameworks/express.js +0 -225
- package/dist/resolution/frameworks/express.js.map +0 -1
- package/dist/resolution/frameworks/go.d.ts +0 -8
- package/dist/resolution/frameworks/go.d.ts.map +0 -1
- package/dist/resolution/frameworks/go.js +0 -158
- package/dist/resolution/frameworks/go.js.map +0 -1
- package/dist/resolution/frameworks/index.d.ts +0 -41
- package/dist/resolution/frameworks/index.d.ts.map +0 -1
- package/dist/resolution/frameworks/index.js +0 -129
- package/dist/resolution/frameworks/index.js.map +0 -1
- package/dist/resolution/frameworks/java.d.ts +0 -8
- package/dist/resolution/frameworks/java.d.ts.map +0 -1
- package/dist/resolution/frameworks/java.js +0 -177
- package/dist/resolution/frameworks/java.js.map +0 -1
- package/dist/resolution/frameworks/laravel.d.ts +0 -13
- package/dist/resolution/frameworks/laravel.d.ts.map +0 -1
- package/dist/resolution/frameworks/laravel.js +0 -248
- package/dist/resolution/frameworks/laravel.js.map +0 -1
- package/dist/resolution/frameworks/python.d.ts +0 -10
- package/dist/resolution/frameworks/python.d.ts.map +0 -1
- package/dist/resolution/frameworks/python.js +0 -278
- package/dist/resolution/frameworks/python.js.map +0 -1
- package/dist/resolution/frameworks/react.d.ts +0 -8
- package/dist/resolution/frameworks/react.d.ts.map +0 -1
- package/dist/resolution/frameworks/react.js +0 -272
- package/dist/resolution/frameworks/react.js.map +0 -1
- package/dist/resolution/frameworks/ruby.d.ts +0 -8
- package/dist/resolution/frameworks/ruby.d.ts.map +0 -1
- package/dist/resolution/frameworks/ruby.js +0 -198
- package/dist/resolution/frameworks/ruby.js.map +0 -1
- package/dist/resolution/frameworks/rust.d.ts +0 -8
- package/dist/resolution/frameworks/rust.d.ts.map +0 -1
- package/dist/resolution/frameworks/rust.js +0 -207
- package/dist/resolution/frameworks/rust.js.map +0 -1
- package/dist/resolution/frameworks/svelte.d.ts +0 -9
- package/dist/resolution/frameworks/svelte.d.ts.map +0 -1
- package/dist/resolution/frameworks/svelte.js +0 -249
- package/dist/resolution/frameworks/svelte.js.map +0 -1
- package/dist/resolution/frameworks/swift.d.ts +0 -10
- package/dist/resolution/frameworks/swift.d.ts.map +0 -1
- package/dist/resolution/frameworks/swift.js +0 -376
- package/dist/resolution/frameworks/swift.js.map +0 -1
- package/dist/resolution/frameworks/vue.d.ts +0 -9
- package/dist/resolution/frameworks/vue.d.ts.map +0 -1
- package/dist/resolution/frameworks/vue.js +0 -306
- package/dist/resolution/frameworks/vue.js.map +0 -1
- package/dist/resolution/import-resolver.d.ts +0 -40
- package/dist/resolution/import-resolver.d.ts.map +0 -1
- package/dist/resolution/import-resolver.js +0 -663
- package/dist/resolution/import-resolver.js.map +0 -1
- package/dist/resolution/index.d.ts +0 -106
- package/dist/resolution/index.d.ts.map +0 -1
- package/dist/resolution/index.js +0 -709
- package/dist/resolution/index.js.map +0 -1
- package/dist/resolution/name-matcher.d.ts +0 -32
- package/dist/resolution/name-matcher.d.ts.map +0 -1
- package/dist/resolution/name-matcher.js +0 -384
- package/dist/resolution/name-matcher.js.map +0 -1
- package/dist/resolution/path-aliases.d.ts +0 -68
- package/dist/resolution/path-aliases.d.ts.map +0 -1
- package/dist/resolution/path-aliases.js +0 -238
- package/dist/resolution/path-aliases.js.map +0 -1
- package/dist/resolution/strip-comments.d.ts +0 -27
- package/dist/resolution/strip-comments.d.ts.map +0 -1
- package/dist/resolution/strip-comments.js +0 -441
- package/dist/resolution/strip-comments.js.map +0 -1
- package/dist/resolution/types.d.ts +0 -172
- package/dist/resolution/types.d.ts.map +0 -1
- package/dist/resolution/types.js +0 -8
- package/dist/resolution/types.js.map +0 -1
- package/dist/search/query-parser.d.ts +0 -57
- package/dist/search/query-parser.d.ts.map +0 -1
- package/dist/search/query-parser.js +0 -177
- package/dist/search/query-parser.js.map +0 -1
- package/dist/search/query-utils.d.ts +0 -53
- package/dist/search/query-utils.d.ts.map +0 -1
- package/dist/search/query-utils.js +0 -347
- package/dist/search/query-utils.js.map +0 -1
- package/dist/sync/index.d.ts +0 -13
- package/dist/sync/index.d.ts.map +0 -1
- package/dist/sync/index.js +0 -17
- package/dist/sync/index.js.map +0 -1
- package/dist/sync/watcher.d.ts +0 -81
- package/dist/sync/watcher.d.ts.map +0 -1
- package/dist/sync/watcher.js +0 -184
- package/dist/sync/watcher.js.map +0 -1
- package/dist/types.d.ts +0 -423
- package/dist/types.d.ts.map +0 -1
- package/dist/types.js +0 -256
- package/dist/types.js.map +0 -1
- package/dist/ui/glyphs.d.ts +0 -42
- package/dist/ui/glyphs.d.ts.map +0 -1
- package/dist/ui/glyphs.js +0 -78
- package/dist/ui/glyphs.js.map +0 -1
- package/dist/ui/shimmer-progress.d.ts +0 -11
- package/dist/ui/shimmer-progress.d.ts.map +0 -1
- package/dist/ui/shimmer-progress.js +0 -90
- package/dist/ui/shimmer-progress.js.map +0 -1
- package/dist/ui/shimmer-worker.d.ts +0 -2
- package/dist/ui/shimmer-worker.d.ts.map +0 -1
- package/dist/ui/shimmer-worker.js +0 -118
- package/dist/ui/shimmer-worker.js.map +0 -1
- package/dist/ui/types.d.ts +0 -17
- package/dist/ui/types.d.ts.map +0 -1
- package/dist/ui/types.js +0 -3
- package/dist/ui/types.js.map +0 -1
- package/dist/utils.d.ts +0 -205
- package/dist/utils.d.ts.map +0 -1
- package/dist/utils.js +0 -549
- package/dist/utils.js.map +0 -1
- package/scripts/local-install.sh +0 -41
- package/scripts/patch-tree-sitter-dart.js +0 -112
- package/scripts/release.sh +0 -70
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Field-qualified search query parser.
|
|
3
|
-
*
|
|
4
|
-
* Splits a raw query like
|
|
5
|
-
*
|
|
6
|
-
* kind:function name:auth path:src/api authenticate
|
|
7
|
-
*
|
|
8
|
-
* into structured filters (kind=function, name="auth", path prefix
|
|
9
|
-
* "src/api") plus the free-text portion ("authenticate") that goes
|
|
10
|
-
* to FTS. Free-text and filters compose: filters narrow the result
|
|
11
|
-
* set, FTS scores within the narrowed set.
|
|
12
|
-
*
|
|
13
|
-
* Recognised fields (case-insensitive, value is the rest until
|
|
14
|
-
* whitespace):
|
|
15
|
-
*
|
|
16
|
-
* kind: one of function|method|class|interface|struct|...
|
|
17
|
-
* lang: one of typescript|python|go|... (alias: language:)
|
|
18
|
-
* path: case-insensitive substring of file_path
|
|
19
|
-
* name: case-insensitive substring of the symbol's name
|
|
20
|
-
*
|
|
21
|
-
* Unknown field prefixes (e.g. `foo:bar`) are passed through to FTS
|
|
22
|
-
* as plain text — that's how someone searching for `TODO:` gets a
|
|
23
|
-
* result instead of a parse error.
|
|
24
|
-
*
|
|
25
|
-
* Quoting:
|
|
26
|
-
* kind:function path:"src/some path/with spaces" → handled by stripping
|
|
27
|
-
* the surrounding double quotes from the value (single token only,
|
|
28
|
-
* no nested escapes).
|
|
29
|
-
*/
|
|
30
|
-
import type { NodeKind, Language } from '../types';
|
|
31
|
-
export interface ParsedQuery {
|
|
32
|
-
/** Free-text portion to feed to FTS / LIKE. May be empty. */
|
|
33
|
-
text: string;
|
|
34
|
-
/** kind: filters (OR'd). Empty when none specified. */
|
|
35
|
-
kinds: NodeKind[];
|
|
36
|
-
/** lang:/language: filters (OR'd). Empty when none specified. */
|
|
37
|
-
languages: Language[];
|
|
38
|
-
/** path: filters (OR'd, case-insensitive substring of file_path). Empty when none. */
|
|
39
|
-
pathFilters: string[];
|
|
40
|
-
/** name: filters (OR'd, case-insensitive substring of node.name). */
|
|
41
|
-
nameFilters: string[];
|
|
42
|
-
}
|
|
43
|
-
/**
|
|
44
|
-
* Parse a raw query into structured filters + remaining text.
|
|
45
|
-
* Always returns a value; never throws.
|
|
46
|
-
*/
|
|
47
|
-
export declare function parseQuery(raw: string): ParsedQuery;
|
|
48
|
-
/**
|
|
49
|
-
* Damerau-Levenshtein-ish bounded edit distance. Returns `maxDist + 1`
|
|
50
|
-
* as soon as the distance is known to exceed `maxDist`; that early-exit
|
|
51
|
-
* makes the fuzzy fallback cheap even over tens of thousands of names.
|
|
52
|
-
*
|
|
53
|
-
* Pure DP, O(min(len(a), len(b))) memory. Compares case-folded inputs;
|
|
54
|
-
* callers should pass `lowercase(name)` strings.
|
|
55
|
-
*/
|
|
56
|
-
export declare function boundedEditDistance(a: string, b: string, maxDist: number): number;
|
|
57
|
-
//# sourceMappingURL=query-parser.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"query-parser.d.ts","sourceRoot":"","sources":["../../src/search/query-parser.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AAGH,OAAO,KAAK,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AAEnD,MAAM,WAAW,WAAW;IAC1B,6DAA6D;IAC7D,IAAI,EAAE,MAAM,CAAC;IACb,uDAAuD;IACvD,KAAK,EAAE,QAAQ,EAAE,CAAC;IAClB,iEAAiE;IACjE,SAAS,EAAE,QAAQ,EAAE,CAAC;IACtB,sFAAsF;IACtF,WAAW,EAAE,MAAM,EAAE,CAAC;IACtB,qEAAqE;IACrE,WAAW,EAAE,MAAM,EAAE,CAAC;CACvB;AAiBD;;;GAGG;AACH,wBAAgB,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,WAAW,CAiFnD;AAED;;;;;;;GAOG;AACH,wBAAgB,mBAAmB,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,CA2BjF"}
|
|
@@ -1,177 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* Field-qualified search query parser.
|
|
4
|
-
*
|
|
5
|
-
* Splits a raw query like
|
|
6
|
-
*
|
|
7
|
-
* kind:function name:auth path:src/api authenticate
|
|
8
|
-
*
|
|
9
|
-
* into structured filters (kind=function, name="auth", path prefix
|
|
10
|
-
* "src/api") plus the free-text portion ("authenticate") that goes
|
|
11
|
-
* to FTS. Free-text and filters compose: filters narrow the result
|
|
12
|
-
* set, FTS scores within the narrowed set.
|
|
13
|
-
*
|
|
14
|
-
* Recognised fields (case-insensitive, value is the rest until
|
|
15
|
-
* whitespace):
|
|
16
|
-
*
|
|
17
|
-
* kind: one of function|method|class|interface|struct|...
|
|
18
|
-
* lang: one of typescript|python|go|... (alias: language:)
|
|
19
|
-
* path: case-insensitive substring of file_path
|
|
20
|
-
* name: case-insensitive substring of the symbol's name
|
|
21
|
-
*
|
|
22
|
-
* Unknown field prefixes (e.g. `foo:bar`) are passed through to FTS
|
|
23
|
-
* as plain text — that's how someone searching for `TODO:` gets a
|
|
24
|
-
* result instead of a parse error.
|
|
25
|
-
*
|
|
26
|
-
* Quoting:
|
|
27
|
-
* kind:function path:"src/some path/with spaces" → handled by stripping
|
|
28
|
-
* the surrounding double quotes from the value (single token only,
|
|
29
|
-
* no nested escapes).
|
|
30
|
-
*/
|
|
31
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
32
|
-
exports.parseQuery = parseQuery;
|
|
33
|
-
exports.boundedEditDistance = boundedEditDistance;
|
|
34
|
-
const types_1 = require("../types");
|
|
35
|
-
// Derived from the canonical `NODE_KINDS` / `LANGUAGES` arrays in
|
|
36
|
-
// types.ts so adding a new kind or language doesn't silently fall
|
|
37
|
-
// through to plain text here.
|
|
38
|
-
const KIND_VALUES = new Set(types_1.NODE_KINDS);
|
|
39
|
-
const LANGUAGE_VALUES = new Set(types_1.LANGUAGES);
|
|
40
|
-
/**
|
|
41
|
-
* Strip a surrounding pair of double quotes from `s`. Allows users to
|
|
42
|
-
* keep whitespace in path filters: `path:"my dir/file"`.
|
|
43
|
-
*/
|
|
44
|
-
function unquote(s) {
|
|
45
|
-
if (s.length >= 2 && s.startsWith('"') && s.endsWith('"'))
|
|
46
|
-
return s.slice(1, -1);
|
|
47
|
-
return s;
|
|
48
|
-
}
|
|
49
|
-
/**
|
|
50
|
-
* Parse a raw query into structured filters + remaining text.
|
|
51
|
-
* Always returns a value; never throws.
|
|
52
|
-
*/
|
|
53
|
-
function parseQuery(raw) {
|
|
54
|
-
const out = {
|
|
55
|
-
text: '',
|
|
56
|
-
kinds: [],
|
|
57
|
-
languages: [],
|
|
58
|
-
pathFilters: [],
|
|
59
|
-
nameFilters: [],
|
|
60
|
-
};
|
|
61
|
-
// Tokenise on whitespace, preserving quoted spans as part of the
|
|
62
|
-
// current token. Quotes can appear at the start (`"…"`) OR mid-token
|
|
63
|
-
// (`path:"…"`); in both cases everything from the opening `"` to the
|
|
64
|
-
// matching `"` is included in the token, whitespace and all.
|
|
65
|
-
const tokens = [];
|
|
66
|
-
let i = 0;
|
|
67
|
-
while (i < raw.length) {
|
|
68
|
-
while (i < raw.length && /\s/.test(raw[i]))
|
|
69
|
-
i++;
|
|
70
|
-
if (i >= raw.length)
|
|
71
|
-
break;
|
|
72
|
-
const start = i;
|
|
73
|
-
while (i < raw.length && !/\s/.test(raw[i])) {
|
|
74
|
-
if (raw[i] === '"') {
|
|
75
|
-
const end = raw.indexOf('"', i + 1);
|
|
76
|
-
if (end === -1) {
|
|
77
|
-
// Unterminated quote — swallow the rest of the input as
|
|
78
|
-
// one token. Forgiving rather than throwing.
|
|
79
|
-
i = raw.length;
|
|
80
|
-
break;
|
|
81
|
-
}
|
|
82
|
-
i = end + 1;
|
|
83
|
-
continue;
|
|
84
|
-
}
|
|
85
|
-
i++;
|
|
86
|
-
}
|
|
87
|
-
tokens.push(raw.slice(start, i));
|
|
88
|
-
}
|
|
89
|
-
const textParts = [];
|
|
90
|
-
for (const tok of tokens) {
|
|
91
|
-
const colon = tok.indexOf(':');
|
|
92
|
-
if (colon <= 0 || colon === tok.length - 1) {
|
|
93
|
-
textParts.push(tok);
|
|
94
|
-
continue;
|
|
95
|
-
}
|
|
96
|
-
const key = tok.slice(0, colon).toLowerCase();
|
|
97
|
-
const valueRaw = unquote(tok.slice(colon + 1));
|
|
98
|
-
if (!valueRaw) {
|
|
99
|
-
textParts.push(tok);
|
|
100
|
-
continue;
|
|
101
|
-
}
|
|
102
|
-
switch (key) {
|
|
103
|
-
case 'kind': {
|
|
104
|
-
if (KIND_VALUES.has(valueRaw)) {
|
|
105
|
-
out.kinds.push(valueRaw);
|
|
106
|
-
}
|
|
107
|
-
else {
|
|
108
|
-
textParts.push(tok);
|
|
109
|
-
}
|
|
110
|
-
break;
|
|
111
|
-
}
|
|
112
|
-
case 'lang':
|
|
113
|
-
case 'language': {
|
|
114
|
-
const lower = valueRaw.toLowerCase();
|
|
115
|
-
if (LANGUAGE_VALUES.has(lower)) {
|
|
116
|
-
out.languages.push(lower);
|
|
117
|
-
}
|
|
118
|
-
else {
|
|
119
|
-
textParts.push(tok);
|
|
120
|
-
}
|
|
121
|
-
break;
|
|
122
|
-
}
|
|
123
|
-
case 'path':
|
|
124
|
-
out.pathFilters.push(valueRaw);
|
|
125
|
-
break;
|
|
126
|
-
case 'name':
|
|
127
|
-
out.nameFilters.push(valueRaw);
|
|
128
|
-
break;
|
|
129
|
-
default:
|
|
130
|
-
textParts.push(tok);
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
out.text = textParts.join(' ').trim();
|
|
134
|
-
return out;
|
|
135
|
-
}
|
|
136
|
-
/**
|
|
137
|
-
* Damerau-Levenshtein-ish bounded edit distance. Returns `maxDist + 1`
|
|
138
|
-
* as soon as the distance is known to exceed `maxDist`; that early-exit
|
|
139
|
-
* makes the fuzzy fallback cheap even over tens of thousands of names.
|
|
140
|
-
*
|
|
141
|
-
* Pure DP, O(min(len(a), len(b))) memory. Compares case-folded inputs;
|
|
142
|
-
* callers should pass `lowercase(name)` strings.
|
|
143
|
-
*/
|
|
144
|
-
function boundedEditDistance(a, b, maxDist) {
|
|
145
|
-
if (a === b)
|
|
146
|
-
return 0;
|
|
147
|
-
const al = a.length;
|
|
148
|
-
const bl = b.length;
|
|
149
|
-
if (Math.abs(al - bl) > maxDist)
|
|
150
|
-
return maxDist + 1;
|
|
151
|
-
if (al === 0)
|
|
152
|
-
return bl;
|
|
153
|
-
if (bl === 0)
|
|
154
|
-
return al;
|
|
155
|
-
let prev = new Array(bl + 1);
|
|
156
|
-
let cur = new Array(bl + 1);
|
|
157
|
-
for (let j = 0; j <= bl; j++)
|
|
158
|
-
prev[j] = j;
|
|
159
|
-
for (let i = 1; i <= al; i++) {
|
|
160
|
-
cur[0] = i;
|
|
161
|
-
let rowMin = cur[0];
|
|
162
|
-
for (let j = 1; j <= bl; j++) {
|
|
163
|
-
const cost = a.charCodeAt(i - 1) === b.charCodeAt(j - 1) ? 0 : 1;
|
|
164
|
-
const insertion = cur[j - 1] + 1;
|
|
165
|
-
const deletion = prev[j] + 1;
|
|
166
|
-
const substitution = prev[j - 1] + cost;
|
|
167
|
-
cur[j] = Math.min(insertion, deletion, substitution);
|
|
168
|
-
if (cur[j] < rowMin)
|
|
169
|
-
rowMin = cur[j];
|
|
170
|
-
}
|
|
171
|
-
if (rowMin > maxDist)
|
|
172
|
-
return maxDist + 1;
|
|
173
|
-
[prev, cur] = [cur, prev];
|
|
174
|
-
}
|
|
175
|
-
return prev[bl];
|
|
176
|
-
}
|
|
177
|
-
//# sourceMappingURL=query-parser.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"query-parser.js","sourceRoot":"","sources":["../../src/search/query-parser.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;;AAqCH,gCAiFC;AAUD,kDA2BC;AAzJD,oCAAiD;AAgBjD,kEAAkE;AAClE,kEAAkE;AAClE,8BAA8B;AAC9B,MAAM,WAAW,GAAwB,IAAI,GAAG,CAAW,kBAAU,CAAC,CAAC;AACvE,MAAM,eAAe,GAAwB,IAAI,GAAG,CAAW,iBAAS,CAAC,CAAC;AAE1E;;;GAGG;AACH,SAAS,OAAO,CAAC,CAAS;IACxB,IAAI,CAAC,CAAC,MAAM,IAAI,CAAC,IAAI,CAAC,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,QAAQ,CAAC,GAAG,CAAC;QAAE,OAAO,CAAC,CAAC,KAAK,CAAC,CAAC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
7
|
-
/**
|
|
8
|
-
* Common stop words to filter from search queries.
|
|
9
|
-
* Includes generic English + code-specific noise words.
|
|
10
|
-
*/
|
|
11
|
-
export declare const STOP_WORDS: Set<string>;
|
|
12
|
-
/**
|
|
13
|
-
* Generate stem variants of a search term by removing common English suffixes.
|
|
14
|
-
* Used for FTS query expansion so "caching" also finds "cache", "eviction" finds "evict", etc.
|
|
15
|
-
* Stems are used as PREFIX matches in FTS, so they don't need to be perfect English words.
|
|
16
|
-
*/
|
|
17
|
-
export declare function getStemVariants(term: string): string[];
|
|
18
|
-
/**
|
|
19
|
-
* Extract meaningful search terms from a natural language query.
|
|
20
|
-
* Splits camelCase, PascalCase, snake_case, SCREAMING_SNAKE, and dot.notation
|
|
21
|
-
* into individual tokens before filtering.
|
|
22
|
-
*
|
|
23
|
-
* Preserves original compound identifiers (e.g., "scrapeLoop") alongside
|
|
24
|
-
* their split parts so that FTS can match both the full symbol name and
|
|
25
|
-
* individual words within it.
|
|
26
|
-
*
|
|
27
|
-
* Also generates stem variants (e.g., "caching"→"cache", "eviction"→"evict")
|
|
28
|
-
* so FTS prefix matching can find related code symbols.
|
|
29
|
-
*/
|
|
30
|
-
export declare function extractSearchTerms(query: string, options?: {
|
|
31
|
-
stems?: boolean;
|
|
32
|
-
}): string[];
|
|
33
|
-
/**
|
|
34
|
-
* Score path relevance to a query
|
|
35
|
-
* Higher score = more relevant path
|
|
36
|
-
*/
|
|
37
|
-
export declare function scorePathRelevance(filePath: string, query: string): number;
|
|
38
|
-
/**
|
|
39
|
-
* Check if a file path looks like a test file
|
|
40
|
-
*/
|
|
41
|
-
export declare function isTestFile(filePath: string): boolean;
|
|
42
|
-
/**
|
|
43
|
-
* Bonus when a node's name matches the search query.
|
|
44
|
-
* Exact matches get the largest boost; prefix matches get smaller boosts.
|
|
45
|
-
* Multi-word queries also check individual term matches against the name.
|
|
46
|
-
*/
|
|
47
|
-
export declare function nameMatchBonus(nodeName: string, query: string): number;
|
|
48
|
-
/**
|
|
49
|
-
* Kind-based bonus for search ranking
|
|
50
|
-
* Functions and classes are typically more relevant than variables/imports
|
|
51
|
-
*/
|
|
52
|
-
export declare function kindBonus(kind: Node['kind']): number;
|
|
53
|
-
//# sourceMappingURL=query-utils.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"query-utils.d.ts","sourceRoot":"","sources":["../../src/search/query-utils.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AAEhC;;;GAGG;AACH,eAAO,MAAM,UAAU,aAkBrB,CAAC;AAEH;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,CAyDtD;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE;IAAE,KAAK,CAAC,EAAE,OAAO,CAAA;CAAE,GAAG,MAAM,EAAE,CA2DzF;AAED;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CA4B1E;AAED;;GAEG;AACH,wBAAgB,UAAU,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAgCpD;AAmBD;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAuCtE;AAED;;;GAGG;AACH,wBAAgB,SAAS,CAAC,IAAI,EAAE,IAAI,CAAC,MAAM,CAAC,GAAG,MAAM,CA0BpD"}
|
|
@@ -1,347 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* Search Query Utilities
|
|
4
|
-
*
|
|
5
|
-
* Shared module for search term extraction and scoring.
|
|
6
|
-
*/
|
|
7
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
8
|
-
if (k2 === undefined) k2 = k;
|
|
9
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
10
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
11
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
12
|
-
}
|
|
13
|
-
Object.defineProperty(o, k2, desc);
|
|
14
|
-
}) : (function(o, m, k, k2) {
|
|
15
|
-
if (k2 === undefined) k2 = k;
|
|
16
|
-
o[k2] = m[k];
|
|
17
|
-
}));
|
|
18
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
19
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
20
|
-
}) : function(o, v) {
|
|
21
|
-
o["default"] = v;
|
|
22
|
-
});
|
|
23
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
24
|
-
var ownKeys = function(o) {
|
|
25
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
26
|
-
var ar = [];
|
|
27
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
28
|
-
return ar;
|
|
29
|
-
};
|
|
30
|
-
return ownKeys(o);
|
|
31
|
-
};
|
|
32
|
-
return function (mod) {
|
|
33
|
-
if (mod && mod.__esModule) return mod;
|
|
34
|
-
var result = {};
|
|
35
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
36
|
-
__setModuleDefault(result, mod);
|
|
37
|
-
return result;
|
|
38
|
-
};
|
|
39
|
-
})();
|
|
40
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
41
|
-
exports.STOP_WORDS = void 0;
|
|
42
|
-
exports.getStemVariants = getStemVariants;
|
|
43
|
-
exports.extractSearchTerms = extractSearchTerms;
|
|
44
|
-
exports.scorePathRelevance = scorePathRelevance;
|
|
45
|
-
exports.isTestFile = isTestFile;
|
|
46
|
-
exports.nameMatchBonus = nameMatchBonus;
|
|
47
|
-
exports.kindBonus = kindBonus;
|
|
48
|
-
const path = __importStar(require("path"));
|
|
49
|
-
/**
|
|
50
|
-
* Common stop words to filter from search queries.
|
|
51
|
-
* Includes generic English + code-specific noise words.
|
|
52
|
-
*/
|
|
53
|
-
exports.STOP_WORDS = new Set([
|
|
54
|
-
// English
|
|
55
|
-
'the', 'a', 'an', 'and', 'or', 'but', 'in', 'on', 'at', 'to', 'for',
|
|
56
|
-
'of', 'with', 'by', 'from', 'is', 'it', 'that', 'this', 'are', 'was',
|
|
57
|
-
'be', 'has', 'had', 'have', 'do', 'does', 'did', 'will', 'would', 'could',
|
|
58
|
-
'should', 'may', 'might', 'can', 'shall', 'not', 'no', 'all', 'each',
|
|
59
|
-
'every', 'how', 'what', 'where', 'when', 'who', 'which', 'why',
|
|
60
|
-
'i', 'me', 'my', 'we', 'our', 'you', 'your', 'he', 'she', 'they',
|
|
61
|
-
'show', 'give', 'tell',
|
|
62
|
-
'been', 'done', 'made', 'used', 'using', 'work', 'works', 'found',
|
|
63
|
-
'also', 'into', 'then', 'than', 'just', 'more', 'some', 'such',
|
|
64
|
-
'over', 'only', 'out', 'its', 'so', 'up', 'as', 'if',
|
|
65
|
-
'look', 'need', 'needs', 'want', 'happen', 'happens',
|
|
66
|
-
'affect', 'affected', 'break', 'breaks', 'failing',
|
|
67
|
-
'implemented', 'implement',
|
|
68
|
-
// Code-specific noise (avoid filtering common symbol names like get/set/add/build/find/list)
|
|
69
|
-
'code', 'file', 'files', 'function', 'method', 'class', 'type',
|
|
70
|
-
'fix', 'bug', 'called',
|
|
71
|
-
]);
|
|
72
|
-
/**
|
|
73
|
-
* Generate stem variants of a search term by removing common English suffixes.
|
|
74
|
-
* Used for FTS query expansion so "caching" also finds "cache", "eviction" finds "evict", etc.
|
|
75
|
-
* Stems are used as PREFIX matches in FTS, so they don't need to be perfect English words.
|
|
76
|
-
*/
|
|
77
|
-
function getStemVariants(term) {
|
|
78
|
-
const variants = new Set();
|
|
79
|
-
const t = term.toLowerCase();
|
|
80
|
-
// -ing: caching→cach/cache, handling→handl/handle, running→run
|
|
81
|
-
if (t.endsWith('ing') && t.length > 5) {
|
|
82
|
-
const base = t.slice(0, -3);
|
|
83
|
-
variants.add(base);
|
|
84
|
-
variants.add(base + 'e');
|
|
85
|
-
if (base.length >= 2 && base[base.length - 1] === base[base.length - 2]) {
|
|
86
|
-
variants.add(base.slice(0, -1));
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
// -tion/-sion: eviction→evict, expression→express
|
|
90
|
-
if ((t.endsWith('tion') || t.endsWith('sion')) && t.length > 5) {
|
|
91
|
-
variants.add(t.slice(0, -3));
|
|
92
|
-
}
|
|
93
|
-
// -ment: management→manage
|
|
94
|
-
if (t.endsWith('ment') && t.length > 6) {
|
|
95
|
-
variants.add(t.slice(0, -4));
|
|
96
|
-
}
|
|
97
|
-
// -ies: entries→entry
|
|
98
|
-
if (t.endsWith('ies') && t.length > 4) {
|
|
99
|
-
variants.add(t.slice(0, -3) + 'y');
|
|
100
|
-
}
|
|
101
|
-
// -es: processes→process, classes→class
|
|
102
|
-
else if (t.endsWith('es') && t.length > 4) {
|
|
103
|
-
variants.add(t.slice(0, -2));
|
|
104
|
-
}
|
|
105
|
-
// -s: errors→error (skip -ss endings like "class")
|
|
106
|
-
else if (t.endsWith('s') && !t.endsWith('ss') && t.length > 4) {
|
|
107
|
-
variants.add(t.slice(0, -1));
|
|
108
|
-
}
|
|
109
|
-
// -ed: handled→handle, propagated→propagate, carried→carry
|
|
110
|
-
if (t.endsWith('ed') && !t.endsWith('eed') && t.length > 4) {
|
|
111
|
-
variants.add(t.slice(0, -1));
|
|
112
|
-
variants.add(t.slice(0, -2));
|
|
113
|
-
if (t.endsWith('ied') && t.length > 5) {
|
|
114
|
-
variants.add(t.slice(0, -3) + 'y');
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
// -er: builder→build/builde, handler→handl/handle, getter→get
|
|
118
|
-
if (t.endsWith('er') && t.length > 4) {
|
|
119
|
-
const base = t.slice(0, -2);
|
|
120
|
-
variants.add(base);
|
|
121
|
-
variants.add(base + 'e');
|
|
122
|
-
if (base.length >= 2 && base[base.length - 1] === base[base.length - 2]) {
|
|
123
|
-
variants.add(base.slice(0, -1));
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
return [...variants].filter(v => v.length >= 3 && v !== t);
|
|
127
|
-
}
|
|
128
|
-
/**
|
|
129
|
-
* Extract meaningful search terms from a natural language query.
|
|
130
|
-
* Splits camelCase, PascalCase, snake_case, SCREAMING_SNAKE, and dot.notation
|
|
131
|
-
* into individual tokens before filtering.
|
|
132
|
-
*
|
|
133
|
-
* Preserves original compound identifiers (e.g., "scrapeLoop") alongside
|
|
134
|
-
* their split parts so that FTS can match both the full symbol name and
|
|
135
|
-
* individual words within it.
|
|
136
|
-
*
|
|
137
|
-
* Also generates stem variants (e.g., "caching"→"cache", "eviction"→"evict")
|
|
138
|
-
* so FTS prefix matching can find related code symbols.
|
|
139
|
-
*/
|
|
140
|
-
function extractSearchTerms(query, options) {
|
|
141
|
-
const includeStems = options?.stems !== false;
|
|
142
|
-
const tokens = new Set();
|
|
143
|
-
// First, extract and preserve compound identifiers before splitting
|
|
144
|
-
// CamelCase: scrapeLoop, UserService, getCallGraph
|
|
145
|
-
const compoundPattern = /\b([a-zA-Z][a-zA-Z0-9]*(?:[A-Z][a-z]+)+|[A-Z][a-z]+(?:[A-Z][a-z]*)+)\b/g;
|
|
146
|
-
let match;
|
|
147
|
-
while ((match = compoundPattern.exec(query)) !== null) {
|
|
148
|
-
if (match[1] && match[1].length >= 3) {
|
|
149
|
-
tokens.add(match[1].toLowerCase()); // preserve full compound: "scrapeloop"
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
// snake_case: scrape_loop, user_service
|
|
153
|
-
const snakePattern = /\b([a-zA-Z][a-zA-Z0-9]*(?:_[a-zA-Z0-9]+)+)\b/g;
|
|
154
|
-
while ((match = snakePattern.exec(query)) !== null) {
|
|
155
|
-
if (match[1] && match[1].length >= 3) {
|
|
156
|
-
tokens.add(match[1].toLowerCase());
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
|
-
// Split camelCase / PascalCase: "getUserName" → "get User Name"
|
|
160
|
-
const camelSplit = query
|
|
161
|
-
.replace(/([a-z])([A-Z])/g, '$1 $2')
|
|
162
|
-
.replace(/([A-Z]+)([A-Z][a-z])/g, '$1 $2');
|
|
163
|
-
// Replace underscores and dots with spaces (snake_case, dot.notation)
|
|
164
|
-
const normalised = camelSplit.replace(/[_.]+/g, ' ');
|
|
165
|
-
// Split on any non-alphanumeric character
|
|
166
|
-
const words = normalised.split(/[^a-zA-Z0-9]+/).filter(Boolean);
|
|
167
|
-
for (const word of words) {
|
|
168
|
-
const lower = word.toLowerCase();
|
|
169
|
-
if (lower.length < 3)
|
|
170
|
-
continue;
|
|
171
|
-
if (exports.STOP_WORDS.has(lower))
|
|
172
|
-
continue;
|
|
173
|
-
tokens.add(lower);
|
|
174
|
-
}
|
|
175
|
-
// Generate stem variants for broader FTS matching.
|
|
176
|
-
// "caching" → "cache" finds CacheBuilder; "eviction" → "evict" finds evictEntries.
|
|
177
|
-
// Also enables co-occurrence dampening by increasing term count above 1.
|
|
178
|
-
// Stems are skipped when scoring path relevance (stems inflate path scores).
|
|
179
|
-
if (includeStems) {
|
|
180
|
-
const stems = new Set();
|
|
181
|
-
for (const token of tokens) {
|
|
182
|
-
for (const variant of getStemVariants(token)) {
|
|
183
|
-
if (!tokens.has(variant) && !exports.STOP_WORDS.has(variant)) {
|
|
184
|
-
stems.add(variant);
|
|
185
|
-
}
|
|
186
|
-
}
|
|
187
|
-
}
|
|
188
|
-
for (const stem of stems) {
|
|
189
|
-
tokens.add(stem);
|
|
190
|
-
}
|
|
191
|
-
}
|
|
192
|
-
return [...tokens];
|
|
193
|
-
}
|
|
194
|
-
/**
|
|
195
|
-
* Score path relevance to a query
|
|
196
|
-
* Higher score = more relevant path
|
|
197
|
-
*/
|
|
198
|
-
function scorePathRelevance(filePath, query) {
|
|
199
|
-
// Use base terms only — stem variants inflate path scores by generating
|
|
200
|
-
// many near-duplicate terms that all match the same path segments.
|
|
201
|
-
const terms = extractSearchTerms(query, { stems: false });
|
|
202
|
-
if (terms.length === 0)
|
|
203
|
-
return 0;
|
|
204
|
-
const pathLower = filePath.toLowerCase();
|
|
205
|
-
const fileName = path.basename(filePath).toLowerCase();
|
|
206
|
-
const dirName = path.dirname(filePath).toLowerCase();
|
|
207
|
-
let score = 0;
|
|
208
|
-
for (const term of terms) {
|
|
209
|
-
// Exact filename match (strongest)
|
|
210
|
-
if (fileName.includes(term))
|
|
211
|
-
score += 10;
|
|
212
|
-
// Directory match
|
|
213
|
-
if (dirName.includes(term))
|
|
214
|
-
score += 5;
|
|
215
|
-
// General path match
|
|
216
|
-
else if (pathLower.includes(term))
|
|
217
|
-
score += 3;
|
|
218
|
-
}
|
|
219
|
-
// Deprioritize test files unless the query is explicitly about tests
|
|
220
|
-
const queryLower = query.toLowerCase();
|
|
221
|
-
const isTestQuery = queryLower.includes('test') || queryLower.includes('spec');
|
|
222
|
-
if (!isTestQuery && isTestFile(filePath)) {
|
|
223
|
-
score -= 15;
|
|
224
|
-
}
|
|
225
|
-
return score;
|
|
226
|
-
}
|
|
227
|
-
/**
|
|
228
|
-
* Check if a file path looks like a test file
|
|
229
|
-
*/
|
|
230
|
-
function isTestFile(filePath) {
|
|
231
|
-
const lower = filePath.toLowerCase();
|
|
232
|
-
const fileName = path.basename(lower);
|
|
233
|
-
// Common test file patterns
|
|
234
|
-
return (fileName.startsWith('test_') ||
|
|
235
|
-
fileName.startsWith('test.') ||
|
|
236
|
-
fileName.endsWith('.test.ts') ||
|
|
237
|
-
fileName.endsWith('.test.js') ||
|
|
238
|
-
fileName.endsWith('.test.tsx') ||
|
|
239
|
-
fileName.endsWith('.test.jsx') ||
|
|
240
|
-
fileName.endsWith('.spec.ts') ||
|
|
241
|
-
fileName.endsWith('.spec.js') ||
|
|
242
|
-
fileName.endsWith('_test.go') ||
|
|
243
|
-
fileName.endsWith('_test.py') ||
|
|
244
|
-
fileName.endsWith('_test.rs') ||
|
|
245
|
-
fileName.endsWith('Tests.java') ||
|
|
246
|
-
fileName.endsWith('Test.java') ||
|
|
247
|
-
fileName.endsWith('Tester.java') ||
|
|
248
|
-
fileName.endsWith('TestCase.java') ||
|
|
249
|
-
lower.includes('/tests/') ||
|
|
250
|
-
lower.includes('/test/') ||
|
|
251
|
-
lower.includes('/__tests__/') ||
|
|
252
|
-
lower.includes('/spec/') ||
|
|
253
|
-
lower.includes('/testlib/') ||
|
|
254
|
-
lower.includes('/testing/') ||
|
|
255
|
-
// Non-production directories: examples, samples, benchmarks, fixtures, demos.
|
|
256
|
-
// Check both mid-path (/integration/) and start-of-path (integration/) since
|
|
257
|
-
// file paths may be stored as relative paths without a leading slash.
|
|
258
|
-
matchesNonProductionDir(lower));
|
|
259
|
-
}
|
|
260
|
-
/**
|
|
261
|
-
* Check if a path is in a non-production directory (integration, sample, example, etc.)
|
|
262
|
-
* Handles both absolute paths (/foo/integration/bar) and relative paths (integration/bar).
|
|
263
|
-
*/
|
|
264
|
-
function matchesNonProductionDir(lowerPath) {
|
|
265
|
-
const dirs = [
|
|
266
|
-
'integration', 'sample', 'samples', 'example', 'examples',
|
|
267
|
-
'fixture', 'fixtures', 'benchmark', 'benchmarks', 'demo', 'demos',
|
|
268
|
-
];
|
|
269
|
-
for (const dir of dirs) {
|
|
270
|
-
if (lowerPath.includes('/' + dir + '/') || lowerPath.startsWith(dir + '/')) {
|
|
271
|
-
return true;
|
|
272
|
-
}
|
|
273
|
-
}
|
|
274
|
-
return false;
|
|
275
|
-
}
|
|
276
|
-
/**
|
|
277
|
-
* Bonus when a node's name matches the search query.
|
|
278
|
-
* Exact matches get the largest boost; prefix matches get smaller boosts.
|
|
279
|
-
* Multi-word queries also check individual term matches against the name.
|
|
280
|
-
*/
|
|
281
|
-
function nameMatchBonus(nodeName, query) {
|
|
282
|
-
const nameLower = nodeName.toLowerCase();
|
|
283
|
-
// Split query into word-level terms (handles "CacheBuilder build" → ["cache","builder","build"])
|
|
284
|
-
const rawTerms = query
|
|
285
|
-
.replace(/([a-z])([A-Z])/g, '$1 $2')
|
|
286
|
-
.split(/[\s_.\-]+/)
|
|
287
|
-
.map(t => t.toLowerCase())
|
|
288
|
-
.filter(t => t.length >= 2);
|
|
289
|
-
// Also keep original space-separated tokens for exact-term matching
|
|
290
|
-
const queryTokens = query.split(/\s+/).map(t => t.toLowerCase()).filter(t => t.length >= 2);
|
|
291
|
-
// Full query as a single token (for compound identifiers like "CacheBuilder")
|
|
292
|
-
const queryLower = query.replace(/[\s]+/g, '').toLowerCase();
|
|
293
|
-
// Exact match: query exactly equals the node name
|
|
294
|
-
if (nameLower === queryLower)
|
|
295
|
-
return 80;
|
|
296
|
-
// Exact match on a query token: "CacheBuilder build" and node name is "build"
|
|
297
|
-
if (queryTokens.length > 1 && queryTokens.includes(nameLower))
|
|
298
|
-
return 60;
|
|
299
|
-
// Name starts with query — scale by length ratio so "Pod"→"Pod" (exact, handled above)
|
|
300
|
-
// scores much higher than "Pod"→"PodGCControllerOptions" (ratio 0.125).
|
|
301
|
-
if (nameLower.startsWith(queryLower)) {
|
|
302
|
-
const ratio = queryLower.length / nameLower.length;
|
|
303
|
-
return Math.round(10 + 30 * ratio);
|
|
304
|
-
}
|
|
305
|
-
// All camelCase-split terms appear in the name
|
|
306
|
-
if (rawTerms.length > 1) {
|
|
307
|
-
const allMatch = rawTerms.every(t => nameLower.includes(t));
|
|
308
|
-
if (allMatch)
|
|
309
|
-
return 15;
|
|
310
|
-
}
|
|
311
|
-
// Name contains the full query as substring
|
|
312
|
-
if (nameLower.includes(queryLower))
|
|
313
|
-
return 10;
|
|
314
|
-
return 0;
|
|
315
|
-
}
|
|
316
|
-
/**
|
|
317
|
-
* Kind-based bonus for search ranking
|
|
318
|
-
* Functions and classes are typically more relevant than variables/imports
|
|
319
|
-
*/
|
|
320
|
-
function kindBonus(kind) {
|
|
321
|
-
const bonuses = {
|
|
322
|
-
function: 10,
|
|
323
|
-
method: 10,
|
|
324
|
-
class: 8,
|
|
325
|
-
interface: 9,
|
|
326
|
-
type_alias: 6,
|
|
327
|
-
struct: 6,
|
|
328
|
-
trait: 9,
|
|
329
|
-
enum: 5,
|
|
330
|
-
component: 8,
|
|
331
|
-
route: 9,
|
|
332
|
-
module: 4,
|
|
333
|
-
property: 3,
|
|
334
|
-
field: 3,
|
|
335
|
-
variable: 2,
|
|
336
|
-
constant: 3,
|
|
337
|
-
import: 1,
|
|
338
|
-
export: 1,
|
|
339
|
-
parameter: 0,
|
|
340
|
-
namespace: 4,
|
|
341
|
-
file: 0,
|
|
342
|
-
protocol: 9,
|
|
343
|
-
enum_member: 3,
|
|
344
|
-
};
|
|
345
|
-
return bonuses[kind] ?? 0;
|
|
346
|
-
}
|
|
347
|
-
//# sourceMappingURL=query-utils.js.map
|