@octocodeai/octocode-engine 16.5.0 → 16.6.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/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- /* auto-generated by NAPI-RS */
1
+ /* Public types for @octocodeai/octocode-engine */
2
2
  /* eslint-disable */
3
3
  export declare class NativeLspClient {
4
4
  constructor(config: JsLanguageServerConfig)
@@ -6,20 +6,10 @@ export declare class NativeLspClient {
6
6
  stop(): Promise<void>
7
7
  waitForReady(timeoutMs?: number | undefined | null): Promise<void>
8
8
  hasCapability(capability: string): boolean
9
+ /** Server-selected LSP `positionEncoding` (utf-16 unless the server is non-conformant); null if omitted/not started. */
10
+ positionEncoding(): string | null
9
11
  getRecentStderr(): Array<string>
10
- /**
11
- * Sync a document's in-memory content to the server, honoring the LSP
12
- * document lifecycle: the FIRST sync of a URI sends `textDocument/didOpen`
13
- * (version 1); every subsequent sync sends `textDocument/didChange` with an
14
- * incremented version and a full-document content change. Re-sending
15
- * `didOpen` (as before) is ignored or rejected by many servers and can make
16
- * changed content resolve against the stale original.
17
- */
18
12
  openDocument(filePath: string, content: string): Promise<void>
19
- /**
20
- * Close a previously opened document (`textDocument/didClose`) and forget
21
- * its version, so a later `open_document` starts a fresh `didOpen`.
22
- */
23
13
  closeDocument(filePath: string): Promise<void>
24
14
  getDefinition(filePath: string, line: number, character: number): Promise<Array<JsCodeSnippet>>
25
15
  getReferences(filePath: string, line: number, character: number, includeDeclaration?: boolean | undefined | null): Promise<Array<JsCodeSnippet>>
@@ -30,6 +20,16 @@ export declare class NativeLspClient {
30
20
  prepareCallHierarchy(filePath: string, line: number, character: number): Promise<any>
31
21
  incomingCalls(item: any): Promise<any>
32
22
  outgoingCalls(item: any): Promise<any>
23
+ /** Project-wide fuzzy symbol search — `workspace/symbol`. Returns `WorkspaceSymbol[] | SymbolInformation[]`. */
24
+ workspaceSymbol(query: string): Promise<any>
25
+ /** Prepare a type-hierarchy item at a position — `textDocument/prepareTypeHierarchy`. */
26
+ prepareTypeHierarchy(filePath: string, line: number, character: number): Promise<any>
27
+ /** Supertypes (base classes / implemented interfaces) — `typeHierarchy/supertypes`. */
28
+ typeHierarchySupertypes(item: any): Promise<any>
29
+ /** Subtypes (subclasses / implementors) — `typeHierarchy/subtypes`. */
30
+ typeHierarchySubtypes(item: any): Promise<any>
31
+ /** Pull diagnostics for a single file — `textDocument/diagnostic` (LSP 3.17+). */
32
+ getDiagnostics(filePath: string): Promise<any>
33
33
  }
34
34
 
35
35
  /**
@@ -108,6 +108,30 @@ export interface BinaryStrings {
108
108
  nextScanOffset?: number
109
109
  }
110
110
 
111
+ /**
112
+ * Native strings extraction. Recovers printable ASCII **and** UTF-16 (LE/BE)
113
+ * runs of at least `min_length` from the scan window of `path` beginning at
114
+ * `scan_offset`, longest-first, optionally hex offset-prefixed. Replaces the
115
+ * `strings` shell-out and additionally surfaces the wide strings GNU
116
+ * `strings -a` misses.
117
+ *
118
+ * Lossless pagination: the returned `nextScanOffset` (when set) is the absolute
119
+ * byte offset of the next window, rewound to a safe break so no string is split
120
+ * across windows. Pass `scanOffset = 0` for the first window.
121
+ */
122
+ export declare function extractBinaryStringsNative(path: string, minLength: number, includeOffsets: boolean, scanOffset: number): BinaryStrings
123
+
124
+ /**
125
+ * Native binary inspection (format lane). Parses `path` as an executable /
126
+ * object / archive and returns its identity plus — for recognized executable
127
+ * formats — symbols, imports, exports, sections and dynamic dependencies.
128
+ *
129
+ * Replaces the `file` + `xxd` shell-outs. Never throws on malformed input: a
130
+ * parse failure degrades to magic-byte identity with an explanatory note. The
131
+ * only `Err` cases are unreadable / oversized files.
132
+ */
133
+ export declare function inspectBinaryNative(path: string): BinaryInspectInfo
134
+
111
135
  /** Extract a byte-range substring from `content`. */
112
136
  export declare function byteSliceContent(content: string, byteStart: number, byteEnd: number): string
113
137
 
@@ -129,34 +153,6 @@ export declare function convertSymbolKind(kind?: number | undefined | null): str
129
153
  /** Return the LSP language identifier for the file at `file_path`. */
130
154
  export declare function detectLanguageId(filePath: string): string | null
131
155
 
132
- /**
133
- * Native strings extraction. Recovers printable ASCII **and** UTF-16 (LE/BE)
134
- * runs of at least `min_length` from the scan window of `path` beginning at
135
- * `scan_offset`, longest-first, optionally hex offset-prefixed. Replaces the
136
- * `strings` shell-out and additionally surfaces the wide strings GNU
137
- * `strings -a` misses.
138
- *
139
- * Lossless pagination: the returned `nextScanOffset` (when set) is the absolute
140
- * byte offset of the next window, rewound to a safe break so no string is split
141
- * across windows. Pass `scanOffset = 0` for the first window.
142
- */
143
- export declare function extractBinaryStringsNative(path: string, minLength: number, includeOffsets: boolean, scanOffset: number): BinaryStrings
144
-
145
- /**
146
- * Native JS/TS document symbols (server-free) as a JSON `DocumentSymbol[]`.
147
- *
148
- * Parses ECMAScript/TypeScript *syntax* with `oxc_parser` and walks
149
- * declarations into the LSP `DocumentSymbol` shape (nested, numeric
150
- * `SymbolKind`, 0-based UTF-16 ranges). **No type inference** — in-file
151
- * scope/binding accuracy only; type-aware outlines still require a language
152
- * server. Only `ts/tsx/js/jsx/mjs/cjs/mts/cts` are handled.
153
- *
154
- * Returns `null` for non-JS/TS files, oversized content, a hard parse failure
155
- * (caller should fall back to `extractSignatures`/tree-sitter), or a file with
156
- * no extractable top-level symbols.
157
- */
158
- export declare function extractJsSymbols(content: string, filePath: string): string | null
159
-
160
156
  /**
161
157
  * Search `content` line-by-line for `pattern` (literal or regex), returning
162
158
  * matched lines with context windows and omission markers.
@@ -189,12 +185,146 @@ export interface ExtractMatchingLinesResult {
189
185
 
190
186
  /**
191
187
  * Structural skeleton with an `NNN| ` line-number gutter, produced purely by
192
- * tree-sitter parsing (no regex heuristics). Returns `null` for data/config
193
- * formats, any language without a wired grammar, content above the 1MB guard,
194
- * and any skeleton that would not be smaller than the source.
188
+ * tree-sitter parsing. Returns `null` for data/config formats, any language
189
+ * without a wired grammar, content above the 1MB guard, and any skeleton that
190
+ * would not be smaller than the source.
195
191
  */
196
192
  export declare function extractSignatures(content: string, filePath: string): string | null
197
193
 
194
+ /**
195
+ * Native JS/TS document symbols (server-free) as a JSON `DocumentSymbol[]`.
196
+ *
197
+ * Parses ECMAScript/TypeScript *syntax* with oxc and walks declarations into
198
+ * the LSP `DocumentSymbol` shape (nested, numeric `SymbolKind`, 0-based UTF-16
199
+ * ranges). **No type inference** — in-file scope/binding accuracy only; type-aware
200
+ * outlines still require a language server. Only `ts/tsx/js/jsx/mjs/cjs/mts/cts`
201
+ * are handled.
202
+ *
203
+ * Returns `null` for non-JS/TS files, oversized content, a hard parse failure
204
+ * (caller should fall back to `extractSignatures`), or a file with no
205
+ * extractable top-level symbols.
206
+ */
207
+ export declare function extractJsSymbols(content: string, filePath: string): string | null
208
+
209
+ /**
210
+ * Native in-file references (server-free) for the JS/TS symbol under
211
+ * `(line, character)` (0-based, UTF-16), as a JSON `Range[]` covering the
212
+ * declaration and every resolved in-file reference (declaration first).
213
+ *
214
+ * **Same-file only** — oxc resolves bindings within one module; cross-file
215
+ * references require a language server. No type inference. Returns `null` for
216
+ * non-JS/TS files, oversized content, a parse failure, or when the cursor is
217
+ * not on a resolvable binding/reference.
218
+ */
219
+ export declare function findInFileReferences(content: string, filePath: string, line: number, character: number): string | null
220
+
221
+ export interface GraphFactPosition {
222
+ line: number
223
+ character: number
224
+ }
225
+
226
+ export interface GraphFactRange {
227
+ start: GraphFactPosition
228
+ end: GraphFactPosition
229
+ }
230
+
231
+ export interface GraphFactDeclaration {
232
+ id: string
233
+ name: string
234
+ kind: string
235
+ line: number
236
+ range: GraphFactRange
237
+ selectionRange: GraphFactRange
238
+ exported: boolean
239
+ parent?: string
240
+ }
241
+
242
+ export interface GraphFactImport {
243
+ id: string
244
+ specifier: string
245
+ line: number
246
+ importKind: string
247
+ localName?: string
248
+ importedName?: string
249
+ }
250
+
251
+ export interface GraphFactExport {
252
+ id: string
253
+ name: string
254
+ line: number
255
+ exportKind: string
256
+ localName?: string
257
+ source?: string
258
+ }
259
+
260
+ export interface GraphFactCall {
261
+ id: string
262
+ caller: string
263
+ callee: string
264
+ line: number
265
+ range: GraphFactRange
266
+ kind: string
267
+ }
268
+
269
+ export interface GraphFactEdge {
270
+ id: string
271
+ from: string
272
+ to: string
273
+ relation: string
274
+ source: string
275
+ line: number
276
+ }
277
+
278
+ export interface GraphFacts {
279
+ kind: 'graphFacts'
280
+ source: 'native-ast'
281
+ language: string
282
+ file: string
283
+ declarations: Array<GraphFactDeclaration>
284
+ imports: Array<GraphFactImport>
285
+ exports: Array<GraphFactExport>
286
+ calls: Array<GraphFactCall>
287
+ edges: Array<GraphFactEdge>
288
+ diagnostics: Array<string>
289
+ }
290
+
291
+ export interface GraphFactCapability {
292
+ extension: string
293
+ language: string
294
+ languageId?: string
295
+ structuralSearch: boolean
296
+ signatureOutline: boolean
297
+ graphFacts: boolean
298
+ factFamilies: Array<string>
299
+ }
300
+
301
+ /**
302
+ * Native graph facts as a JSON `GraphFacts` object, or null when no graph-fact
303
+ * extractor supports the file. JS/TS use the richer OXC lane; other supported
304
+ * source languages use tree-sitter syntax inventory. Cross-file semantic
305
+ * identity still needs LSP proof.
306
+ */
307
+ export declare function extractGraphFacts(content: string, filePath: string): string | null
308
+
309
+ /**
310
+ * Canonical list of file extensions (lowercase, no leading dot) handled by the
311
+ * native oxc JS/TS path (`extractJsSymbols` / `findInFileReferences`). Gate
312
+ * native dispatch on this list instead of hardcoding it.
313
+ */
314
+ export declare function getSupportedJsTsExtensions(): Array<string>
315
+
316
+ /**
317
+ * Canonical list of file extensions (lowercase, no leading dot) that can emit
318
+ * native graph facts. JS/TS use OXC; other entries use tree-sitter syntax
319
+ * inventory.
320
+ */
321
+ export declare function getSupportedGraphFactExtensions(): Array<string>
322
+
323
+ /**
324
+ * JSON `GraphFactCapability[]` describing graph-fact coverage by extension.
325
+ */
326
+ export declare function getGraphFactCapabilities(): string
327
+
198
328
  export interface FileSystemEntry {
199
329
  /** Absolute or input-root-relative path as returned by the platform. */
200
330
  path: string
@@ -226,6 +356,8 @@ export interface FileSystemQueryOptions {
226
356
  showHidden?: boolean
227
357
  /** Match basename globs, OR-combined. */
228
358
  names?: Array<string>
359
+ /** Match file extensions, OR-combined. Values may include a leading dot. Directories are preserved. */
360
+ extensions?: Array<string>
229
361
  /** Match full path glob. */
230
362
  pathPattern?: string
231
363
  /** Rust regex against basename. */
@@ -263,10 +395,30 @@ export interface FileSystemQueryResult {
263
395
  warnings: Array<string>
264
396
  }
265
397
 
398
+ export type CommentPatternGroup =
399
+ | 'c-style'
400
+ | 'hash'
401
+ | 'html'
402
+ | 'sql'
403
+ | 'lua'
404
+ | 'haskell'
405
+ | 'semicolon'
406
+ | 'wasm-text'
407
+ | 'percent'
408
+ | 'haml'
409
+ | 'slim'
410
+ | 'powershell'
411
+ | 'bang'
412
+ | 'apostrophe'
413
+ | 'double-dash'
414
+ | 'fsharp-block'
415
+ | 'pascal'
416
+ | 'template'
417
+ | 'python-docstring'
418
+
266
419
  export interface FileTypeMinifyConfig {
267
420
  strategy: string
268
- /** CommentPatternGroup | CommentPatternGroup[] */
269
- comments?: any
421
+ comments?: CommentPatternGroup | CommentPatternGroup[] | null
270
422
  }
271
423
 
272
424
  /**
@@ -290,18 +442,6 @@ export interface FilterPatchOptions {
290
442
  contextLines?: number
291
443
  }
292
444
 
293
- /**
294
- * Native in-file references (server-free) for the JS/TS symbol under
295
- * `(line, character)` (0-based, UTF-16), as a JSON `Range[]` covering the
296
- * declaration and every resolved in-file reference (declaration first).
297
- *
298
- * **Same-file only.** oxc resolves bindings within one module; cross-file
299
- * references require a language server. No type inference. Returns `null` for
300
- * non-JS/TS files, oversized content, a parse failure, or when the cursor is
301
- * not on a resolvable binding/reference.
302
- */
303
- export declare function findInFileReferences(content: string, filePath: string, line: number, character: number): string | null
304
-
305
445
  /** Convert a `file://` URI string back to an absolute filesystem path. */
306
446
  export declare function fromUri(uri: string): string
307
447
 
@@ -326,17 +466,26 @@ export declare function getLanguageServerForFile(filePath: string, workspaceRoot
326
466
  * Returns the full MINIFY_CONFIG as a JS-compatible object.
327
467
  * Shape: `{ fileTypes: Record<string, { strategy: string, comments: string | string[] | null }> }`
328
468
  */
329
- export declare function getMINIFY_CONFIG(): any
469
+ export declare function getMINIFY_CONFIG(): MinifyConfigSnapshot
470
+
471
+ export interface MinifyConfigSnapshot {
472
+ fileTypes: Record<string, { strategy: string; comments: CommentPatternGroup | CommentPatternGroup[] | null }>
473
+ }
474
+
475
+ export declare const MINIFY_CONFIG: MinifyConfigSnapshot
476
+ export declare const SUPPORTED_SIGNATURE_EXTENSIONS: readonly string[]
477
+ export declare const SUPPORTED_GRAPH_FACT_EXTENSIONS: readonly string[]
478
+ export declare const SUPPORTED_STRUCTURAL_EXTENSIONS: readonly string[]
330
479
 
331
480
  /**
332
481
  * Returns a sorted list of JS char offsets (UTF-16 code units) where
333
482
  * top-level semantic blocks begin in `content`.
334
483
  *
335
- * **Tree-sitter only** (exact AST): `ts tsx js jsx mjs cjs mts cts py pyi go rs
336
- * java c h cpp cc cxx hpp hh hxx cs sh bash zsh`. Languages without a wired
337
- * grammar and structural-only grammars (HTML/CSS/Scala/JSON/YAML/TOML) return
338
- * `[]` there is no regex/heuristic fallback. Also `[]` for data/config files,
339
- * plain text, and files above the 1 MB guard.
484
+ * **Tree-sitter** (exact AST): `ts tsx js jsx mjs cjs py go rs java c h sh bash zsh`
485
+ * **Heuristic** (pattern-based): `cpp hpp cc cxx cs kt kotlin scala rb php swift
486
+ * css scss less html htm sql vue svelte ex exs hs lhs md lua` + 10 more
487
+ * **Returns `[]`** for data/config files (`json yaml toml ini csv xml …`),
488
+ * plain text, and files above the 1 MB guard.
340
489
  *
341
490
  * Char offsets match JavaScript `string.substring()` — pass them directly to
342
491
  * JavaScript string slicing without conversion.
@@ -344,34 +493,13 @@ export declare function getMINIFY_CONFIG(): any
344
493
  export declare function getSemanticBoundaryOffsets(content: string, filePath: string): Array<number>
345
494
 
346
495
  /**
347
- * Canonical list of file extensions (lowercase, no leading dot) handled by the
348
- * native oxc JS/TS path (`extractJsSymbols` / `findInFileReferences`). Callers
349
- * should gate native dispatch on this list rather than hardcoding it, so the
350
- * Rust and JS sides never drift.
351
- */
352
- export declare function getSupportedJsTsExtensions(): Array<string>
353
-
354
- /**
355
- * Returns all extensions that have signature-outline support. This is exactly
356
- * the set of tree-sitter grammars with a function-body query (no regex
357
- * heuristics): structural-only grammars (HTML/CSS/Scala/JSON/YAML/TOML) are
358
- * excluded because they produce no outline.
496
+ * Returns all extensions that have signature extraction support
497
+ * (tree-sitter languages + heuristic-covered languages).
359
498
  */
360
499
  export declare function getSupportedSignatureExtensions(): Array<string>
361
500
 
362
501
  export declare function getSupportedStructuralExtensions(): Array<string>
363
502
 
364
- /**
365
- * Native binary inspection (format lane). Parses `path` as an executable /
366
- * object / archive and returns its identity plus — for recognized executable
367
- * formats — symbols, imports, exports, sections and dynamic dependencies.
368
- *
369
- * Replaces the `file` + `xxd` shell-outs. Never throws on malformed input: a
370
- * parse failure degrades to magic-byte identity with an explanatory note. The
371
- * only `Err` cases are unreadable / oversized files.
372
- */
373
- export declare function inspectBinaryNative(path: string): BinaryInspectInfo
374
-
375
503
  /** Check whether `command` is available on `PATH`. */
376
504
  export declare function isCommandAvailable(command: string): boolean
377
505
 
@@ -409,7 +537,15 @@ export interface JsLanguageServerConfig {
409
537
  * response. Optional key sorting and priority-key ordering; multiline
410
538
  * strings become block scalars. Emission is locked by yaml_utils tests.
411
539
  */
412
- export declare function jsonToYamlString(jsonObject: any, config?: YamlConversionConfig | undefined | null): string
540
+ export type JsonPrimitive = string | number | boolean | null
541
+ export type JsonValue = JsonPrimitive | JsonValue[] | { [key: string]: JsonValue }
542
+ export type JsonInput =
543
+ | JsonPrimitive
544
+ | undefined
545
+ | JsonInput[]
546
+ | { [key: string]: JsonInput }
547
+
548
+ export declare function jsonToYamlString(jsonObject: JsonInput, config?: YamlConversionConfig | undefined | null): string
413
549
 
414
550
  export interface JsRange {
415
551
  start: JsExactPosition
@@ -423,12 +559,6 @@ export interface JsResolvedSymbol {
423
559
  lineContent: string
424
560
  }
425
561
 
426
- /**
427
- * Mask secrets in place: every even-indexed char of a matched secret becomes
428
- * `*`, preserving partial readability. File-context patterns are skipped.
429
- */
430
- export declare function maskSensitiveData(text: string): string
431
-
432
562
  export interface MatchRange {
433
563
  /** 1-based inclusive start line. */
434
564
  start: number
@@ -458,7 +588,7 @@ export declare function minifyConservativeCore(content: string, config: FileType
458
588
  * Full minification on libuv's worker pool.
459
589
  * Returns a Promise from JavaScript and does not block the event loop.
460
590
  */
461
- export declare function minifyContent(content: string, filePath: string): Promise<unknown>
591
+ export declare function minifyContent(content: string, filePath: string): Promise<MinifyResult>
462
592
 
463
593
  /** Synchronous full minification result. */
464
594
  export declare function minifyContentResult(content: string, filePath: string): MinifyResult
@@ -528,12 +658,6 @@ export interface MinifyResult {
528
658
  reason?: string
529
659
  }
530
660
 
531
- export interface ParsedPatchLine {
532
- originalLineNumber?: number
533
- newLineNumber?: number
534
- content: string
535
- lineType: PatchLineType
536
- }
537
661
 
538
662
  /**
539
663
  * Parse ripgrep `--json` NDJSON stdout into structured files + stats.
@@ -545,15 +669,23 @@ export interface ParsedPatchLine {
545
669
  */
546
670
  export declare function parseRipgrepJson(stdout: string, options?: RipgrepParseOptions | undefined | null): RipgrepParseResult
547
671
 
672
+ /**
673
+ * Run ripgrep in-process: walk `path`, search every file with ripgrep's own
674
+ * engine, and return the same `{ files, stats }` shape the `--json` parser
675
+ * produced. Replaces shelling out to an `rg` binary (and the `@vscode/ripgrep`
676
+ * bundle) — octocode is now its own source of ripgrep.
677
+ *
678
+ * Runs on the libuv thread pool so the filesystem walk never blocks the event
679
+ * loop, mirroring the old async `spawn` of `rg`.
680
+ */
681
+ export declare function searchRipgrep(options: RipgrepSearchOptions): Promise<RipgrepParseResult>
682
+
548
683
  export declare const enum PatchLineType {
549
684
  Addition = 'Addition',
550
685
  Deletion = 'Deletion',
551
686
  Context = 'Context'
552
687
  }
553
688
 
554
- /** Number of loaded secret-detection patterns (testing / benchmarking). */
555
- export declare function patternCount(): number
556
-
557
689
  /**
558
690
  * Cross-platform filesystem traversal and metadata filtering for local tools.
559
691
  *
@@ -593,13 +725,11 @@ export interface RipgrepMatch {
593
725
  column: number
594
726
  /** Assembled match + context window, truncated to `max_snippet_chars`. */
595
727
  value: string
596
- /** Frequency for this value when `count_unique` is enabled. */
728
+ /** Frequency for `onlyMatching + countUnique` values. */
597
729
  count?: number
598
730
  /**
599
- * AST node-kind label (declaration|import|export|callsite|identifier|
600
- * comment|string|configKey|heading) when `classify_matches` is enabled.
601
- * `None` when classification was off, the language is unsupported, or the
602
- * file failed to parse.
731
+ * AST node-kind label (declaration|import|export|callsite|identifier|comment|
732
+ * string|configKey|heading) when `classifyMatches` is enabled.
603
733
  */
604
734
  kind?: string
605
735
  /** Deterministic relevance hint (0.0..1.0) derived from `kind`. */
@@ -625,8 +755,7 @@ export interface RipgrepPatternValidationResult {
625
755
 
626
756
  /**
627
757
  * Options for the in-process ripgrep search (`searchRipgrep`). Field semantics
628
- * mirror the ripgrep CLI flags the old `RipgrepCommandBuilder` emitted, so the
629
- * search behaves identically to shelling out to `rg`.
758
+ * mirror the ripgrep CLI flags the old `RipgrepCommandBuilder` emitted.
630
759
  */
631
760
  export interface RipgrepSearchOptions {
632
761
  /** Search root: a directory (recursive) or a single file. */
@@ -637,7 +766,7 @@ export interface RipgrepSearchOptions {
637
766
  fixedString?: boolean
638
767
  /** Use the PCRE2 engine for lookaround/backreferences (`-P`). */
639
768
  perlRegex?: boolean
640
- /** Case-sensitive match (`-s`). Wins over `case_insensitive`. */
769
+ /** Case-sensitive match (`-s`). Wins over `caseInsensitive`. */
641
770
  caseSensitive?: boolean
642
771
  /** Case-insensitive match (`-i`). Default is smart-case (`-S`). */
643
772
  caseInsensitive?: boolean
@@ -677,34 +806,29 @@ export interface RipgrepSearchOptions {
677
806
  sortReverse?: boolean
678
807
  /** Max Unicode chars per assembled snippet (default 500). */
679
808
  maxSnippetChars?: number
680
- /**
681
- * When true, label each match with its AST node kind (tree-sitter) for
682
- * language-aware ranking. Optional and capped by the caller; degrades to
683
- * unlabeled matches on unsupported/unparseable files.
684
- */
809
+ /** Label each match with its AST node kind (tree-sitter) for ranking. */
685
810
  classifyMatches?: boolean
686
811
  /**
687
- * Emit one match per *submatch* with `value` set to the matched span
688
- * (not the whole line) — ripgrep's `-o`/`--only-matching`. The win on a
689
- * minified one-liner: line mode can only count hits, this enumerates them.
812
+ * Emit one match per submatch with `value` set to the matched span (not the
813
+ * whole line) — ripgrep's `-o`/`--only-matching`. Enumerates every hit on a
814
+ * minified one-liner that line mode can only count.
690
815
  */
691
816
  onlyMatching?: boolean
692
817
  /**
693
- * With `only_matching`, widen each span by this many characters on each
694
- * side (char-boundary safe), marking trimmed sides with `…`. 0/unset =
695
- * the bare matched span.
696
- */
697
- matchWindow?: number
698
- /**
699
- * With `only_matching`, collapse duplicate values per file, preserving
700
- * first-occurrence order and anchor.
818
+ * With `onlyMatching`, collapse repeated matched values per file while
819
+ * keeping the first occurrence anchor.
701
820
  */
702
821
  unique?: boolean
703
822
  /**
704
- * With `only_matching`, collapse duplicate values and attach their
705
- * frequency, sorted by count descending.
823
+ * With `onlyMatching`, collapse repeated values per file and attach a
824
+ * frequency count to each returned match. Sorted by count descending.
706
825
  */
707
826
  countUnique?: boolean
827
+ /**
828
+ * With `onlyMatching`, widen each span by this many characters on each side
829
+ * (char-boundary safe), marking trimmed sides with `…`. 0/unset = bare span.
830
+ */
831
+ matchWindow?: number
708
832
  }
709
833
 
710
834
  export interface RipgrepStats {
@@ -722,32 +846,6 @@ export interface RipgrepStats {
722
846
  */
723
847
  export declare function safeReadFile(filePath: string): string
724
848
 
725
- export interface SanitizationResult {
726
- content: string
727
- hasSecrets: boolean
728
- secretsDetected: Array<string>
729
- warnings: Array<string>
730
- }
731
-
732
- /**
733
- * Detect and redact all secrets from `content`, returning the sanitized string
734
- * with `[REDACTED-*]` placeholders plus detection metadata. `file_path` gates
735
- * file-context patterns (e.g. Kubernetes/`.env` secrets).
736
- */
737
- export declare function sanitizeContent(content: string, filePath?: string | undefined | null): SanitizationResult
738
-
739
- /**
740
- * Run ripgrep in-process: walk `path`, search every file with ripgrep's own
741
- * engine, and return the same `{ files, stats }` shape the `--json` parser
742
- * produced. Replaces shelling out to an `rg` binary (and the `@vscode/ripgrep`
743
- * bundle) — octocode is now its own source of ripgrep.
744
- *
745
- * Runs on the libuv thread pool so the filesystem walk never blocks the event
746
- * loop, mirroring the old async `spawn` of `rg`.
747
- */
748
- export declare function searchRipgrep(options: RipgrepSearchOptions): Promise<unknown>
749
-
750
- /** Native exports. */
751
849
  export const SIGNATURES_ONLY_HINT: string
752
850
 
753
851
  /**
@@ -779,37 +877,23 @@ export interface SliceContentResult {
779
877
  */
780
878
  export declare function stripPythonDocstrings(content: string): string
781
879
 
782
- /**
783
- * A structural match with stable evidence metadata. Existing
784
- * `StructuralMatch` remains unchanged for the legacy APIs; detailed APIs add
785
- * IDs and confidence without forcing old callers to carry metadata.
786
- */
787
- export interface StructuralDetailedMatch {
788
- id: string
789
- startLine: number
790
- endLine: number
791
- startCol: number
792
- endCol: number
793
- text: string
794
- metavars: Record<string, Array<string>>
795
- nodeKind?: string
796
- confidence: string
797
- }
798
-
799
- export interface StructuralDiagnostic {
800
- code: string
801
- severity: string
802
- stage: string
803
- message: string
804
- path?: string
805
- recovery?: string
806
- }
807
-
808
880
  /**
809
881
  * One structural match. Line numbers are 1-based so `start_line` can be fed
810
882
  * directly as an `lspGetSemantics` `lineHint`; columns are 0-based char
811
883
  * offsets (tree-sitter native).
812
884
  */
885
+ /**
886
+ * Precise position of one captured metavariable node. `line` is 1-based
887
+ * (usable as an `lspGetSemantics` lineHint); columns are 0-based char offsets.
888
+ */
889
+ export interface MetavarRange {
890
+ text: string
891
+ line: number
892
+ column: number
893
+ endLine: number
894
+ endColumn: number
895
+ }
896
+
813
897
  export interface StructuralMatch {
814
898
  startLine: number
815
899
  endLine: number
@@ -822,53 +906,82 @@ export interface StructuralMatch {
822
906
  * metavar name (no leading `$`).
823
907
  */
824
908
  metavars: Record<string, Array<string>>
909
+ /**
910
+ * Per-capture precise ranges, parallel to `metavars` (same keys/order).
911
+ * Lets an agent hand a capture straight to LSP without re-searching.
912
+ */
913
+ metavarRanges: Record<string, Array<MetavarRange>>
914
+ }
915
+
916
+ export interface StructuralDiagnostic {
917
+ code: string
918
+ severity: 'info' | 'warning' | 'error' | string
919
+ stage:
920
+ | 'snapshot'
921
+ | 'regionize'
922
+ | 'scan'
923
+ | 'parse'
924
+ | 'match'
925
+ | 'minify'
926
+ | 'sanitize'
927
+ | 'lsp'
928
+ | 'paginate'
929
+ | string
930
+ message: string
931
+ path?: string
932
+ recovery?: string
825
933
  }
826
934
 
827
935
  export interface StructuralQueryExplanation {
828
- kind: string
936
+ kind: 'pattern' | 'rule' | 'invalid' | string
829
937
  source: string
830
938
  literalAnchor?: string
831
- preFilter: string
939
+ preFilter: 'literal-anchor' | 'disabled' | 'unavailable' | string
832
940
  unsafeReason?: string
833
941
  diagnostics: Array<StructuralDiagnostic>
834
942
  }
835
943
 
836
- /**
837
- * Structural (AST) search — octocode's L2 layer. Resolves the grammar from
838
- * `file_path`'s extension and matches a code-shaped `pattern` OR a YAML `rule`
839
- * (exactly one). Returns node ranges (1-based lines, ready as `lineHint`s)
840
- * plus captured metavariables. Throws on unsupported extension, invalid
841
- * pattern/rule, or both/neither query supplied.
842
- */
843
- export declare function structuralSearch(content: string, filePath: string, pattern?: string | undefined | null, rule?: string | undefined | null): Array<StructuralMatch>
844
-
845
- /**
846
- * Detailed structural search. Unlike `structuralSearch`, unsupported
847
- * extensions and invalid queries are represented as status + diagnostics so
848
- * callers can distinguish true empty results from weak evidence.
849
- */
850
- export declare function structuralSearchDetailed(content: string, filePath: string, pattern?: string | undefined | null, rule?: string | undefined | null): StructuralSearchDetailedResult
851
-
852
- export interface StructuralSearchDetailedFileResult {
853
- path: string
854
- status: string
855
- languageId?: string
856
- skippedReason?: string
857
- matches: Array<StructuralDetailedMatch>
858
- diagnostics: Array<StructuralDiagnostic>
944
+ export interface StructuralDetailedMatch extends StructuralMatch {
945
+ id: string
946
+ nodeKind?: string
947
+ confidence: 'exact-ast' | 'partial-ast' | 'fallback-text' | string
859
948
  }
860
949
 
861
950
  export interface StructuralSearchDetailedResult {
862
951
  path: string
863
952
  analyzer: string
864
953
  analyzerVersion: string
865
- status: string
954
+ status:
955
+ | 'ok'
956
+ | 'partial'
957
+ | 'unsupported'
958
+ | 'ambiguous'
959
+ | 'parserFailed'
960
+ | 'fallback'
961
+ | 'truncated'
962
+ | 'stale'
963
+ | string
866
964
  languageId?: string
867
965
  query: StructuralQueryExplanation
868
966
  matches: Array<StructuralDetailedMatch>
869
967
  diagnostics: Array<StructuralDiagnostic>
870
968
  }
871
969
 
970
+ /**
971
+ * Structural (AST) search — octocode's L2 layer. Resolves the grammar from
972
+ * `file_path`'s extension and matches an Octocode structural `pattern` OR a YAML `rule`
973
+ * (exactly one). Returns node ranges (1-based lines, ready as `lineHint`s)
974
+ * plus captured metavariables. Throws on unsupported extension, invalid
975
+ * pattern/rule, or both/neither query supplied.
976
+ */
977
+ export declare function structuralSearch(content: string, filePath: string, pattern?: string | undefined | null, rule?: string | undefined | null): Array<StructuralMatch>
978
+
979
+ /**
980
+ * Detailed structural search. Unsupported extensions and invalid queries return
981
+ * status + diagnostics instead of being collapsed into a thrown legacy error.
982
+ */
983
+ export declare function structuralSearchDetailed(content: string, filePath: string, pattern?: string | undefined | null, rule?: string | undefined | null): StructuralSearchDetailedResult
984
+
872
985
  export interface StructuralSearchFileResult {
873
986
  path: string
874
987
  matches: Array<StructuralMatch>
@@ -878,22 +991,6 @@ export declare function structuralSearchFiles(options: StructuralSearchFilesOpti
878
991
 
879
992
  export declare function structuralSearchFilesDetailed(options: StructuralSearchFilesOptions): StructuralSearchFilesDetailedResult
880
993
 
881
- export interface StructuralSearchFilesDetailedResult {
882
- files: Array<StructuralSearchDetailedFileResult>
883
- totalMatches: number
884
- parsedFiles: number
885
- skippedByPreFilter: number
886
- skippedUnsupported: number
887
- skippedUnreadable: number
888
- skippedLarge: number
889
- analyzer: string
890
- analyzerVersion: string
891
- status: string
892
- query: StructuralQueryExplanation
893
- diagnostics: Array<StructuralDiagnostic>
894
- warnings: Array<string>
895
- }
896
-
897
994
  export interface StructuralSearchFilesOptions {
898
995
  path: string
899
996
  pattern?: string
@@ -914,6 +1011,31 @@ export interface StructuralSearchFilesResult {
914
1011
  warnings: Array<string>
915
1012
  }
916
1013
 
1014
+ export interface StructuralSearchDetailedFileResult {
1015
+ path: string
1016
+ status: string
1017
+ languageId?: string
1018
+ skippedReason?: string
1019
+ matches: Array<StructuralDetailedMatch>
1020
+ diagnostics: Array<StructuralDiagnostic>
1021
+ }
1022
+
1023
+ export interface StructuralSearchFilesDetailedResult {
1024
+ files: Array<StructuralSearchDetailedFileResult>
1025
+ totalMatches: number
1026
+ parsedFiles: number
1027
+ skippedByPreFilter: number
1028
+ skippedUnsupported: number
1029
+ skippedUnreadable: number
1030
+ skippedLarge: number
1031
+ analyzer: string
1032
+ analyzerVersion: string
1033
+ status: string
1034
+ query: StructuralQueryExplanation
1035
+ diagnostics: Array<StructuralDiagnostic>
1036
+ warnings: Array<string>
1037
+ }
1038
+
917
1039
  /**
918
1040
  * Convert a human-readable symbol kind string back to the LSP `SymbolKind`
919
1041
  * numeric code. Unknown strings return `13` (Variable).
@@ -932,3 +1054,27 @@ export interface YamlConversionConfig {
932
1054
  sortKeys?: boolean
933
1055
  keysPriority?: Array<string>
934
1056
  }
1057
+
1058
+ /** Result of secret detection + redaction over a string. */
1059
+ export interface SanitizationResult {
1060
+ content: string
1061
+ hasSecrets: boolean
1062
+ secretsDetected: Array<string>
1063
+ warnings: Array<string>
1064
+ }
1065
+
1066
+ /**
1067
+ * Detect and redact all secrets from `content`, returning the sanitized string
1068
+ * with `[REDACTED-*]` placeholders plus detection metadata. `filePath` gates
1069
+ * file-context patterns (e.g. Kubernetes/`.env` secrets).
1070
+ */
1071
+ export declare function sanitizeContent(content: string, filePath?: string | undefined | null): SanitizationResult
1072
+
1073
+ /**
1074
+ * Mask secrets in place: every even-indexed char of a matched secret becomes
1075
+ * `*`, preserving partial readability. File-context patterns are skipped.
1076
+ */
1077
+ export declare function maskSensitiveData(text: string): string
1078
+
1079
+ /** Number of loaded secret-detection patterns (testing / benchmarking). */
1080
+ export declare function patternCount(): number