sweet-search 2.6.2 → 2.6.5
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.
|
@@ -3,6 +3,8 @@
|
|
|
3
3
|
* Extracted to prevent drift between graph-search.js and sweet-search.js
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
+
import { EXTENSION_MAP } from './language-patterns/maps.js';
|
|
7
|
+
|
|
6
8
|
export const SYMBOL_KIND_WEIGHTS = {
|
|
7
9
|
class: 1.0,
|
|
8
10
|
interface: 0.95,
|
|
@@ -26,25 +28,43 @@ export const DEFINITION_TYPES = new Set([
|
|
|
26
28
|
]);
|
|
27
29
|
|
|
28
30
|
/**
|
|
29
|
-
* Canonical set of code file extensions recognized by sweet-search
|
|
30
|
-
*
|
|
31
|
-
*
|
|
31
|
+
* Canonical set of code file extensions recognized by sweet-search's
|
|
32
|
+
* grep/pattern path — the sparse-gram literal index, native-grep extension
|
|
33
|
+
* filter, ripgrep `--type-add code` fallback, and `isRipgrepCodePath`.
|
|
34
|
+
*
|
|
35
|
+
* DERIVED from EXTENSION_MAP (the single source of truth for which extensions
|
|
36
|
+
* sweet-search indexes) so ss-grep coverage can NEVER drift behind newly-added
|
|
37
|
+
* languages. This drift previously dropped Solidity, .cts/.mts, .cljc/.cljs/.edn,
|
|
38
|
+
* .mli, .rd/.rmd, shaders, build DSLs, etc. from ss-grep even though they were
|
|
39
|
+
* discovered + embedded (so ss-search worked but ss-grep silently returned
|
|
40
|
+
* nothing). Keys are stored bare + lowercase (no leading dot) to match
|
|
41
|
+
* `path.extname(f).slice(1).toLowerCase()` at the call sites.
|
|
42
|
+
*
|
|
43
|
+
* Pure document formats (Markdown/reStructuredText/plaintext) are intentionally
|
|
44
|
+
* EXCLUDED — they go through DocumentChunker and are not part of the grep
|
|
45
|
+
* code-path (isRipgrepCodePath('README.md') must stay false, and sparse-gram
|
|
46
|
+
* candidate lists drop doc files). Config/markup/style formats (json/yaml/xml/
|
|
47
|
+
* html/css/ini/…) stay in, matching the historical set.
|
|
48
|
+
*
|
|
49
|
+
* Plus a few historically grep-able languages that have no EXTENSION_MAP entry
|
|
50
|
+
* (no chunker grammar): Ada, D, V.
|
|
32
51
|
*/
|
|
52
|
+
const DOC_FORMAT_LANGUAGE_IDS = new Set(['markdown', 'rst', 'plaintext']);
|
|
53
|
+
const LEGACY_EXTRA_CODE_EXTENSIONS = ['ada', 'd', 'v'];
|
|
33
54
|
export const CODE_FILE_EXTENSIONS = new Set([
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
'json', 'toml', 'xml', 'html', 'css', 'scss', 'sass', 'less', 'svelte',
|
|
39
|
-
'vue', 'astro', 'mdx',
|
|
55
|
+
...Object.entries(EXTENSION_MAP)
|
|
56
|
+
.filter(([, id]) => !DOC_FORMAT_LANGUAGE_IDS.has(id))
|
|
57
|
+
.map(([ext]) => ext.replace(/^\./, '').toLowerCase()),
|
|
58
|
+
...LEGACY_EXTRA_CODE_EXTENSIONS,
|
|
40
59
|
]);
|
|
41
60
|
|
|
42
61
|
/**
|
|
43
62
|
* Ripgrep type definition glob matching CODE_FILE_EXTENSIONS.
|
|
44
|
-
* Used with --type-add to define a custom 'code' type for ripgrep.
|
|
63
|
+
* Used with --type-add to define a custom 'code' type for ripgrep. Derived from
|
|
64
|
+
* the same set so it stays in lockstep.
|
|
45
65
|
*/
|
|
46
66
|
export const RIPGREP_CODE_TYPE_GLOB =
|
|
47
|
-
|
|
67
|
+
`code:*.{${Array.from(CODE_FILE_EXTENSIONS).join(',')}}`;
|
|
48
68
|
|
|
49
69
|
/**
|
|
50
70
|
* Sparse gram symbol type bitmasks.
|
|
@@ -235,6 +235,95 @@ export const TOOLING_LANGUAGES = {
|
|
|
235
235
|
skipCallObjects: [],
|
|
236
236
|
},
|
|
237
237
|
},
|
|
238
|
+
// ─── Solidity ────────────────────────────────────────────────────────────────
|
|
239
|
+
// Real chunking is done by tree-sitter-solidity (GRAMMAR_MAP); these regex
|
|
240
|
+
// patterns are the fallback used only when tree-sitter is unavailable.
|
|
241
|
+
solidity: {
|
|
242
|
+
indentBased: false,
|
|
243
|
+
endKeyword: null,
|
|
244
|
+
comment: { line: "//", block: ["/*", "*/"] },
|
|
245
|
+
chunker: {
|
|
246
|
+
contract: /^\s*(?:abstract\s+)?contract\s+(\w+)/,
|
|
247
|
+
interface: /^\s*interface\s+(\w+)/,
|
|
248
|
+
library: /^\s*library\s+(\w+)/,
|
|
249
|
+
function: /^\s*function\s+(\w+)/,
|
|
250
|
+
struct: /^\s*struct\s+(\w+)/,
|
|
251
|
+
},
|
|
252
|
+
graph: {
|
|
253
|
+
entities: {
|
|
254
|
+
contract: /^\s*(?:abstract\s+)?contract\s+(\w+)/,
|
|
255
|
+
interface: /^\s*interface\s+(\w+)/,
|
|
256
|
+
library: /^\s*library\s+(\w+)/,
|
|
257
|
+
function: /^\s*function\s+(\w+)/,
|
|
258
|
+
},
|
|
259
|
+
relationships: {
|
|
260
|
+
import: /^\s*import\s+.*["']([^"']+)["']/,
|
|
261
|
+
inherit: /\bis\s+([A-Z]\w*)/,
|
|
262
|
+
},
|
|
263
|
+
skipCallObjects: ["require", "assert", "revert", "emit"],
|
|
264
|
+
},
|
|
265
|
+
},
|
|
266
|
+
// ─── OCaml ───────────────────────────────────────────────────────────────────
|
|
267
|
+
// tree-sitter-ocaml does the real chunking. OCaml has no line comment — only
|
|
268
|
+
// `(* … *)` blocks.
|
|
269
|
+
ocaml: {
|
|
270
|
+
indentBased: false,
|
|
271
|
+
endKeyword: null,
|
|
272
|
+
comment: { line: null, block: ["(*", "*)"] },
|
|
273
|
+
chunker: {
|
|
274
|
+
function: /^\s*let\s+(?:rec\s+)?(\w+)/,
|
|
275
|
+
type: /^\s*(?:and\s+)?type\s+(\w+)/,
|
|
276
|
+
module: /^\s*module\s+(\w+)/,
|
|
277
|
+
},
|
|
278
|
+
graph: {
|
|
279
|
+
entities: {
|
|
280
|
+
function: /^\s*let\s+(?:rec\s+)?(\w+)/,
|
|
281
|
+
type: /^\s*type\s+(\w+)/,
|
|
282
|
+
module: /^\s*module\s+(\w+)/,
|
|
283
|
+
},
|
|
284
|
+
relationships: { open: /^\s*open\s+([\w.]+)/ },
|
|
285
|
+
skipCallObjects: [],
|
|
286
|
+
},
|
|
287
|
+
},
|
|
288
|
+
// ─── ReScript ────────────────────────────────────────────────────────────────
|
|
289
|
+
rescript: {
|
|
290
|
+
indentBased: false,
|
|
291
|
+
endKeyword: null,
|
|
292
|
+
comment: { line: "//", block: ["/*", "*/"] },
|
|
293
|
+
chunker: {
|
|
294
|
+
function: /^\s*let\s+(\w+)/,
|
|
295
|
+
type: /^\s*type\s+(\w+)/,
|
|
296
|
+
module: /^\s*module\s+(\w+)/,
|
|
297
|
+
},
|
|
298
|
+
graph: {
|
|
299
|
+
entities: {
|
|
300
|
+
function: /^\s*let\s+(\w+)/,
|
|
301
|
+
type: /^\s*type\s+(\w+)/,
|
|
302
|
+
module: /^\s*module\s+(\w+)/,
|
|
303
|
+
},
|
|
304
|
+
relationships: { open: /^\s*open\s+(\w+)/ },
|
|
305
|
+
skipCallObjects: [],
|
|
306
|
+
},
|
|
307
|
+
},
|
|
308
|
+
// ─── TLA+ ────────────────────────────────────────────────────────────────────
|
|
309
|
+
// tree-sitter-tlaplus does the real chunking. Comments are `\* …` / `(* … *)`.
|
|
310
|
+
tlaplus: {
|
|
311
|
+
indentBased: false,
|
|
312
|
+
endKeyword: null,
|
|
313
|
+
comment: { line: "\\*", block: ["(*", "*)"] },
|
|
314
|
+
chunker: {
|
|
315
|
+
module: /^-{2,}\s*MODULE\s+(\w+)/,
|
|
316
|
+
operator: /^(\w+)\s*==/,
|
|
317
|
+
},
|
|
318
|
+
graph: {
|
|
319
|
+
entities: {
|
|
320
|
+
module: /^-{2,}\s*MODULE\s+(\w+)/,
|
|
321
|
+
operator: /^(\w+)\s*==/,
|
|
322
|
+
},
|
|
323
|
+
relationships: { extends: /^EXTENDS\s+([\w,\s]+)/ },
|
|
324
|
+
skipCallObjects: [],
|
|
325
|
+
},
|
|
326
|
+
},
|
|
238
327
|
};
|
|
239
328
|
|
|
240
329
|
export default TOOLING_LANGUAGES;
|
|
@@ -46,6 +46,14 @@ const GRAMMAR_MAP = {
|
|
|
46
46
|
// classes. Wiring tree-sitter-c-sharp puts C# on the same code path as
|
|
47
47
|
// the other 13 languages (cAST sibling-merge over a proper AST).
|
|
48
48
|
csharp: 'tree-sitter-c_sharp',
|
|
49
|
+
// Wired 2026-06 (v2.6.3) for first-class AST/cAST chunking. All four wasm
|
|
50
|
+
// grammars ship in tree-sitter-wasms and load on the installed web-tree-sitter
|
|
51
|
+
// ABI. (tree-sitter-elm / tree-sitter-ql also ship but are ABI 12/10 vs the
|
|
52
|
+
// required 13–15, so they stay on generic chunking.)
|
|
53
|
+
solidity: 'tree-sitter-solidity',
|
|
54
|
+
tlaplus: 'tree-sitter-tlaplus',
|
|
55
|
+
ocaml: 'tree-sitter-ocaml',
|
|
56
|
+
rescript: 'tree-sitter-rescript',
|
|
49
57
|
};
|
|
50
58
|
|
|
51
59
|
// Identifier node types — used to detect leaf-ident captures in extractSymbols()
|
|
@@ -56,6 +64,10 @@ const IDENT_TYPES = new Set([
|
|
|
56
64
|
'name', // PHP all identifiers
|
|
57
65
|
'simple_identifier', // Kotlin functions, Swift functions
|
|
58
66
|
'namespace_identifier', // C++ namespace names
|
|
67
|
+
// OCaml — names live in *_binding children (see _extractNodeName drill)
|
|
68
|
+
'value_name', 'type_constructor', 'module_name',
|
|
69
|
+
// ReScript — value/module binding names (type_identifier already covered)
|
|
70
|
+
'value_identifier', 'module_identifier',
|
|
59
71
|
]);
|
|
60
72
|
|
|
61
73
|
// AST node types that represent meaningful chunk boundaries
|
|
@@ -156,6 +168,25 @@ const LANG_EXTRA_BOUNDARY_TYPES = {
|
|
|
156
168
|
'local_function_statement',
|
|
157
169
|
'event_declaration', 'event_field_declaration',
|
|
158
170
|
]),
|
|
171
|
+
// Solidity (tree-sitter-solidity). `function_definition` is already a global
|
|
172
|
+
// boundary; these are the contract-level declarations the grammar emits, all
|
|
173
|
+
// carrying a `name: (identifier)` field so _extractNodeName resolves them.
|
|
174
|
+
solidity: new Set([
|
|
175
|
+
'contract_declaration', 'interface_declaration', 'library_declaration',
|
|
176
|
+
'struct_declaration', 'enum_declaration', 'event_definition',
|
|
177
|
+
'modifier_definition', 'constructor_definition', 'error_declaration',
|
|
178
|
+
]),
|
|
179
|
+
// TLA+ (tree-sitter-tlaplus). `module` is already global; operator_definition
|
|
180
|
+
// (`Foo == ...`) is the unit of definition, name via `name: (identifier)`.
|
|
181
|
+
tlaplus: new Set(['operator_definition']),
|
|
182
|
+
// OCaml (tree-sitter-ocaml). `type_definition` is already global; these wrap a
|
|
183
|
+
// *_binding whose name (value_name/type_constructor/module_name) is recovered
|
|
184
|
+
// by the _extractNodeName binding-wrapper drill. value_definition is top-level
|
|
185
|
+
// only (local `let … in` is a let_expression), so this doesn't over-chunk.
|
|
186
|
+
ocaml: new Set(['value_definition', 'module_definition', 'exception_definition']),
|
|
187
|
+
// ReScript (tree-sitter-rescript). `type_declaration` is already global; the
|
|
188
|
+
// let/module declarations wrap a *_binding handled by the same drill.
|
|
189
|
+
rescript: new Set(['let_declaration', 'module_declaration']),
|
|
159
190
|
};
|
|
160
191
|
|
|
161
192
|
// Per-language EXCLUSIONS from BOUNDARY_TYPES. Removes node-type names that
|
|
@@ -283,6 +314,37 @@ const NODE_TYPE_MAP = {
|
|
|
283
314
|
'local_function_statement': 'function',
|
|
284
315
|
'event_declaration': 'property',
|
|
285
316
|
'event_field_declaration': 'field',
|
|
317
|
+
// Solidity (tree-sitter-solidity) — grammar-unique node names, so these are
|
|
318
|
+
// null-ops for every other language's chunking.
|
|
319
|
+
'contract_declaration': 'class',
|
|
320
|
+
'library_declaration': 'class',
|
|
321
|
+
'event_definition': 'event',
|
|
322
|
+
'modifier_definition': 'function',
|
|
323
|
+
'constructor_definition': 'method',
|
|
324
|
+
'error_declaration': 'type',
|
|
325
|
+
// TLA+
|
|
326
|
+
'operator_definition': 'function',
|
|
327
|
+
// OCaml
|
|
328
|
+
'value_definition': 'function',
|
|
329
|
+
'module_definition': 'module',
|
|
330
|
+
'exception_definition': 'class',
|
|
331
|
+
// ReScript
|
|
332
|
+
'let_declaration': 'function',
|
|
333
|
+
'module_declaration': 'module',
|
|
334
|
+
};
|
|
335
|
+
|
|
336
|
+
// OCaml / ReScript boundary node -> the `*_binding` child that carries the name.
|
|
337
|
+
// Consulted only by _extractNodeName; the keys are grammar-unique node types.
|
|
338
|
+
const OCAML_RESCRIPT_BINDING_WRAPPERS = {
|
|
339
|
+
// OCaml
|
|
340
|
+
value_definition: 'let_binding',
|
|
341
|
+
module_definition: 'module_binding',
|
|
342
|
+
// ReScript
|
|
343
|
+
let_declaration: 'let_binding',
|
|
344
|
+
module_declaration: 'module_binding',
|
|
345
|
+
// Shared (already a global boundary; name nested in *_binding for both langs)
|
|
346
|
+
type_definition: 'type_binding',
|
|
347
|
+
type_declaration: 'type_binding',
|
|
286
348
|
};
|
|
287
349
|
|
|
288
350
|
// Standard tags.scm query patterns for symbol extraction
|
|
@@ -534,6 +596,34 @@ const TAGS_QUERIES = {
|
|
|
534
596
|
(field_declaration (variable_declaration (variable_declarator name: (identifier) @field.definition)))
|
|
535
597
|
(local_function_statement name: (identifier) @function.definition)
|
|
536
598
|
`,
|
|
599
|
+
// Solidity (tree-sitter-solidity) — every declaration carries name: (identifier).
|
|
600
|
+
solidity: `
|
|
601
|
+
(contract_declaration name: (identifier) @class.definition)
|
|
602
|
+
(interface_declaration name: (identifier) @interface.definition)
|
|
603
|
+
(library_declaration name: (identifier) @class.definition)
|
|
604
|
+
(struct_declaration name: (identifier) @struct.definition)
|
|
605
|
+
(enum_declaration name: (identifier) @enum.definition)
|
|
606
|
+
(function_definition name: (identifier) @function.definition)
|
|
607
|
+
(modifier_definition name: (identifier) @function.definition)
|
|
608
|
+
(event_definition name: (identifier) @function.definition)
|
|
609
|
+
`,
|
|
610
|
+
// TLA+ (tree-sitter-tlaplus)
|
|
611
|
+
tlaplus: `
|
|
612
|
+
(module name: (identifier) @namespace.definition)
|
|
613
|
+
(operator_definition name: (identifier) @function.definition)
|
|
614
|
+
`,
|
|
615
|
+
// OCaml (tree-sitter-ocaml) — names nested in the *_binding child.
|
|
616
|
+
ocaml: `
|
|
617
|
+
(value_definition (let_binding (value_name) @function.definition))
|
|
618
|
+
(type_definition (type_binding (type_constructor) @type.definition))
|
|
619
|
+
(module_definition (module_binding (module_name) @namespace.definition))
|
|
620
|
+
`,
|
|
621
|
+
// ReScript (tree-sitter-rescript) — names nested in the *_binding child.
|
|
622
|
+
rescript: `
|
|
623
|
+
(let_declaration (let_binding (value_identifier) @function.definition))
|
|
624
|
+
(type_declaration (type_binding (type_identifier) @type.definition))
|
|
625
|
+
(module_declaration (module_binding (module_identifier) @namespace.definition))
|
|
626
|
+
`,
|
|
537
627
|
};
|
|
538
628
|
|
|
539
629
|
// Names that tree-sitter-c / tree-sitter-cpp sometimes emit as the `name:`
|
|
@@ -1361,6 +1451,24 @@ export class TreeSitterProvider {
|
|
|
1361
1451
|
}
|
|
1362
1452
|
}
|
|
1363
1453
|
|
|
1454
|
+
// OCaml / ReScript — the definition's name lives one level down in the
|
|
1455
|
+
// grammar's `*_binding` child (value_definition → let_binding → value_name;
|
|
1456
|
+
// type_definition → type_binding → type_constructor/type_identifier;
|
|
1457
|
+
// module_definition → module_binding → module_name/module_identifier). The
|
|
1458
|
+
// wrapper node-type strings below are unique to tree-sitter-ocaml/rescript,
|
|
1459
|
+
// so this branch is a null-op for every other grammar.
|
|
1460
|
+
const BINDING_WRAPPER = OCAML_RESCRIPT_BINDING_WRAPPERS[node.type];
|
|
1461
|
+
if (BINDING_WRAPPER) {
|
|
1462
|
+
for (let i = 0; i < node.childCount; i++) {
|
|
1463
|
+
const binding = node.child(i);
|
|
1464
|
+
if (binding.type !== BINDING_WRAPPER) continue;
|
|
1465
|
+
for (let j = 0; j < binding.childCount; j++) {
|
|
1466
|
+
const nm = binding.child(j);
|
|
1467
|
+
if (IDENT_TYPES.has(nm.type)) return nm.text;
|
|
1468
|
+
}
|
|
1469
|
+
}
|
|
1470
|
+
}
|
|
1471
|
+
|
|
1364
1472
|
// Fallback: look for identifier-type children (uses IDENT_TYPES set).
|
|
1365
1473
|
// Visibility-keyword stoplist: tree-sitter-ruby parses bare `private`,
|
|
1366
1474
|
// `protected`, `public` (with no args) as standalone `identifier`
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "sweet-search",
|
|
3
|
-
"version": "2.6.
|
|
3
|
+
"version": "2.6.5",
|
|
4
4
|
"description": "Sweet Search - SOTA Hybrid Code Search Engine with WASM CatBoost Query Router, Semantic/Lexical/Structural Search, and Multilingual Support",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "core/search/sweet-search.js",
|
|
@@ -167,13 +167,13 @@
|
|
|
167
167
|
"vitest": "^4.0.16"
|
|
168
168
|
},
|
|
169
169
|
"optionalDependencies": {
|
|
170
|
-
"@sweet-search/native-darwin-arm64": "2.6.
|
|
171
|
-
"@sweet-search/native-darwin-x64": "2.6.
|
|
172
|
-
"@sweet-search/native-linux-arm64-gnu": "2.6.
|
|
173
|
-
"@sweet-search/native-linux-arm64-gnu-cuda": "2.6.
|
|
174
|
-
"@sweet-search/native-linux-x64-gnu": "2.6.
|
|
175
|
-
"@sweet-search/native-linux-x64-gnu-cuda": "2.6.
|
|
176
|
-
"@sweet-search/bg-priority": "2.6.
|
|
170
|
+
"@sweet-search/native-darwin-arm64": "2.6.5",
|
|
171
|
+
"@sweet-search/native-darwin-x64": "2.6.5",
|
|
172
|
+
"@sweet-search/native-linux-arm64-gnu": "2.6.5",
|
|
173
|
+
"@sweet-search/native-linux-arm64-gnu-cuda": "2.6.5",
|
|
174
|
+
"@sweet-search/native-linux-x64-gnu": "2.6.5",
|
|
175
|
+
"@sweet-search/native-linux-x64-gnu-cuda": "2.6.5",
|
|
176
|
+
"@sweet-search/bg-priority": "2.6.5"
|
|
177
177
|
},
|
|
178
178
|
"engines": {
|
|
179
179
|
"node": ">=18.0.0"
|