@octocodeai/octocode-engine 16.5.0 → 16.5.1
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 +9 -21
- package/dist/lsp/index.d.ts +1 -1
- package/dist/lsp/index.js +1 -1
- package/dist/lsp/resolver.d.ts +7 -1
- package/dist/lsp/resolver.js +117 -0
- package/dist/security/discoveryFilter.d.ts +11 -0
- package/dist/security/discoveryFilter.js +264 -0
- package/dist/security/index.d.ts +2 -0
- package/dist/security/index.js +1 -0
- package/index.d.ts +257 -224
- package/index.js +75 -650
- package/package.json +17 -11
package/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*
|
|
1
|
+
/* Public types for @octocodeai/octocode-engine */
|
|
2
2
|
/* eslint-disable */
|
|
3
3
|
export declare class NativeLspClient {
|
|
4
4
|
constructor(config: JsLanguageServerConfig)
|
|
@@ -7,19 +7,7 @@ export declare class NativeLspClient {
|
|
|
7
7
|
waitForReady(timeoutMs?: number | undefined | null): Promise<void>
|
|
8
8
|
hasCapability(capability: string): boolean
|
|
9
9
|
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
10
|
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
11
|
closeDocument(filePath: string): Promise<void>
|
|
24
12
|
getDefinition(filePath: string, line: number, character: number): Promise<Array<JsCodeSnippet>>
|
|
25
13
|
getReferences(filePath: string, line: number, character: number, includeDeclaration?: boolean | undefined | null): Promise<Array<JsCodeSnippet>>
|
|
@@ -108,6 +96,30 @@ export interface BinaryStrings {
|
|
|
108
96
|
nextScanOffset?: number
|
|
109
97
|
}
|
|
110
98
|
|
|
99
|
+
/**
|
|
100
|
+
* Native strings extraction. Recovers printable ASCII **and** UTF-16 (LE/BE)
|
|
101
|
+
* runs of at least `min_length` from the scan window of `path` beginning at
|
|
102
|
+
* `scan_offset`, longest-first, optionally hex offset-prefixed. Replaces the
|
|
103
|
+
* `strings` shell-out and additionally surfaces the wide strings GNU
|
|
104
|
+
* `strings -a` misses.
|
|
105
|
+
*
|
|
106
|
+
* Lossless pagination: the returned `nextScanOffset` (when set) is the absolute
|
|
107
|
+
* byte offset of the next window, rewound to a safe break so no string is split
|
|
108
|
+
* across windows. Pass `scanOffset = 0` for the first window.
|
|
109
|
+
*/
|
|
110
|
+
export declare function extractBinaryStringsNative(path: string, minLength: number, includeOffsets: boolean, scanOffset: number): BinaryStrings
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* Native binary inspection (format lane). Parses `path` as an executable /
|
|
114
|
+
* object / archive and returns its identity plus — for recognized executable
|
|
115
|
+
* formats — symbols, imports, exports, sections and dynamic dependencies.
|
|
116
|
+
*
|
|
117
|
+
* Replaces the `file` + `xxd` shell-outs. Never throws on malformed input: a
|
|
118
|
+
* parse failure degrades to magic-byte identity with an explanatory note. The
|
|
119
|
+
* only `Err` cases are unreadable / oversized files.
|
|
120
|
+
*/
|
|
121
|
+
export declare function inspectBinaryNative(path: string): BinaryInspectInfo
|
|
122
|
+
|
|
111
123
|
/** Extract a byte-range substring from `content`. */
|
|
112
124
|
export declare function byteSliceContent(content: string, byteStart: number, byteEnd: number): string
|
|
113
125
|
|
|
@@ -129,34 +141,6 @@ export declare function convertSymbolKind(kind?: number | undefined | null): str
|
|
|
129
141
|
/** Return the LSP language identifier for the file at `file_path`. */
|
|
130
142
|
export declare function detectLanguageId(filePath: string): string | null
|
|
131
143
|
|
|
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
144
|
/**
|
|
161
145
|
* Search `content` line-by-line for `pattern` (literal or regex), returning
|
|
162
146
|
* matched lines with context windows and omission markers.
|
|
@@ -189,12 +173,46 @@ export interface ExtractMatchingLinesResult {
|
|
|
189
173
|
|
|
190
174
|
/**
|
|
191
175
|
* Structural skeleton with an `NNN| ` line-number gutter, produced purely by
|
|
192
|
-
* tree-sitter parsing
|
|
193
|
-
*
|
|
194
|
-
*
|
|
176
|
+
* tree-sitter parsing. Returns `null` for data/config formats, any language
|
|
177
|
+
* without a wired grammar, content above the 1MB guard, and any skeleton that
|
|
178
|
+
* would not be smaller than the source.
|
|
195
179
|
*/
|
|
196
180
|
export declare function extractSignatures(content: string, filePath: string): string | null
|
|
197
181
|
|
|
182
|
+
/**
|
|
183
|
+
* Native JS/TS document symbols (server-free) as a JSON `DocumentSymbol[]`.
|
|
184
|
+
*
|
|
185
|
+
* Parses ECMAScript/TypeScript *syntax* with oxc and walks declarations into
|
|
186
|
+
* the LSP `DocumentSymbol` shape (nested, numeric `SymbolKind`, 0-based UTF-16
|
|
187
|
+
* ranges). **No type inference** — in-file scope/binding accuracy only; type-aware
|
|
188
|
+
* outlines still require a language server. Only `ts/tsx/js/jsx/mjs/cjs/mts/cts`
|
|
189
|
+
* are handled.
|
|
190
|
+
*
|
|
191
|
+
* Returns `null` for non-JS/TS files, oversized content, a hard parse failure
|
|
192
|
+
* (caller should fall back to `extractSignatures`), or a file with no
|
|
193
|
+
* extractable top-level symbols.
|
|
194
|
+
*/
|
|
195
|
+
export declare function extractJsSymbols(content: string, filePath: string): string | null
|
|
196
|
+
|
|
197
|
+
/**
|
|
198
|
+
* Native in-file references (server-free) for the JS/TS symbol under
|
|
199
|
+
* `(line, character)` (0-based, UTF-16), as a JSON `Range[]` covering the
|
|
200
|
+
* declaration and every resolved in-file reference (declaration first).
|
|
201
|
+
*
|
|
202
|
+
* **Same-file only** — oxc resolves bindings within one module; cross-file
|
|
203
|
+
* references require a language server. No type inference. Returns `null` for
|
|
204
|
+
* non-JS/TS files, oversized content, a parse failure, or when the cursor is
|
|
205
|
+
* not on a resolvable binding/reference.
|
|
206
|
+
*/
|
|
207
|
+
export declare function findInFileReferences(content: string, filePath: string, line: number, character: number): string | null
|
|
208
|
+
|
|
209
|
+
/**
|
|
210
|
+
* Canonical list of file extensions (lowercase, no leading dot) handled by the
|
|
211
|
+
* native oxc JS/TS path (`extractJsSymbols` / `findInFileReferences`). Gate
|
|
212
|
+
* native dispatch on this list instead of hardcoding it.
|
|
213
|
+
*/
|
|
214
|
+
export declare function getSupportedJsTsExtensions(): Array<string>
|
|
215
|
+
|
|
198
216
|
export interface FileSystemEntry {
|
|
199
217
|
/** Absolute or input-root-relative path as returned by the platform. */
|
|
200
218
|
path: string
|
|
@@ -226,6 +244,8 @@ export interface FileSystemQueryOptions {
|
|
|
226
244
|
showHidden?: boolean
|
|
227
245
|
/** Match basename globs, OR-combined. */
|
|
228
246
|
names?: Array<string>
|
|
247
|
+
/** Match file extensions, OR-combined. Values may include a leading dot. Directories are preserved. */
|
|
248
|
+
extensions?: Array<string>
|
|
229
249
|
/** Match full path glob. */
|
|
230
250
|
pathPattern?: string
|
|
231
251
|
/** Rust regex against basename. */
|
|
@@ -263,10 +283,30 @@ export interface FileSystemQueryResult {
|
|
|
263
283
|
warnings: Array<string>
|
|
264
284
|
}
|
|
265
285
|
|
|
286
|
+
export type CommentPatternGroup =
|
|
287
|
+
| 'c-style'
|
|
288
|
+
| 'hash'
|
|
289
|
+
| 'html'
|
|
290
|
+
| 'sql'
|
|
291
|
+
| 'lua'
|
|
292
|
+
| 'haskell'
|
|
293
|
+
| 'semicolon'
|
|
294
|
+
| 'wasm-text'
|
|
295
|
+
| 'percent'
|
|
296
|
+
| 'haml'
|
|
297
|
+
| 'slim'
|
|
298
|
+
| 'powershell'
|
|
299
|
+
| 'bang'
|
|
300
|
+
| 'apostrophe'
|
|
301
|
+
| 'double-dash'
|
|
302
|
+
| 'fsharp-block'
|
|
303
|
+
| 'pascal'
|
|
304
|
+
| 'template'
|
|
305
|
+
| 'python-docstring'
|
|
306
|
+
|
|
266
307
|
export interface FileTypeMinifyConfig {
|
|
267
308
|
strategy: string
|
|
268
|
-
|
|
269
|
-
comments?: any
|
|
309
|
+
comments?: CommentPatternGroup | CommentPatternGroup[] | null
|
|
270
310
|
}
|
|
271
311
|
|
|
272
312
|
/**
|
|
@@ -290,18 +330,6 @@ export interface FilterPatchOptions {
|
|
|
290
330
|
contextLines?: number
|
|
291
331
|
}
|
|
292
332
|
|
|
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
333
|
/** Convert a `file://` URI string back to an absolute filesystem path. */
|
|
306
334
|
export declare function fromUri(uri: string): string
|
|
307
335
|
|
|
@@ -326,17 +354,25 @@ export declare function getLanguageServerForFile(filePath: string, workspaceRoot
|
|
|
326
354
|
* Returns the full MINIFY_CONFIG as a JS-compatible object.
|
|
327
355
|
* Shape: `{ fileTypes: Record<string, { strategy: string, comments: string | string[] | null }> }`
|
|
328
356
|
*/
|
|
329
|
-
export declare function getMINIFY_CONFIG():
|
|
357
|
+
export declare function getMINIFY_CONFIG(): MinifyConfigSnapshot
|
|
358
|
+
|
|
359
|
+
export interface MinifyConfigSnapshot {
|
|
360
|
+
fileTypes: Record<string, { strategy: string; comments: CommentPatternGroup | CommentPatternGroup[] | null }>
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
export declare const MINIFY_CONFIG: MinifyConfigSnapshot
|
|
364
|
+
export declare const SUPPORTED_SIGNATURE_EXTENSIONS: readonly string[]
|
|
365
|
+
export declare const SUPPORTED_STRUCTURAL_EXTENSIONS: readonly string[]
|
|
330
366
|
|
|
331
367
|
/**
|
|
332
368
|
* Returns a sorted list of JS char offsets (UTF-16 code units) where
|
|
333
369
|
* top-level semantic blocks begin in `content`.
|
|
334
370
|
*
|
|
335
|
-
* **Tree-sitter
|
|
336
|
-
*
|
|
337
|
-
*
|
|
338
|
-
* `[]
|
|
339
|
-
*
|
|
371
|
+
* **Tree-sitter** (exact AST): `ts tsx js jsx mjs cjs py go rs java c h sh bash zsh`
|
|
372
|
+
* **Heuristic** (pattern-based): `cpp hpp cc cxx cs kt kotlin scala rb php swift
|
|
373
|
+
* css scss less html htm sql vue svelte ex exs hs lhs md lua` + 10 more
|
|
374
|
+
* **Returns `[]`** for data/config files (`json yaml toml ini csv xml …`),
|
|
375
|
+
* plain text, and files above the 1 MB guard.
|
|
340
376
|
*
|
|
341
377
|
* Char offsets match JavaScript `string.substring()` — pass them directly to
|
|
342
378
|
* JavaScript string slicing without conversion.
|
|
@@ -344,34 +380,13 @@ export declare function getMINIFY_CONFIG(): any
|
|
|
344
380
|
export declare function getSemanticBoundaryOffsets(content: string, filePath: string): Array<number>
|
|
345
381
|
|
|
346
382
|
/**
|
|
347
|
-
*
|
|
348
|
-
*
|
|
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.
|
|
383
|
+
* Returns all extensions that have signature extraction support
|
|
384
|
+
* (tree-sitter languages + heuristic-covered languages).
|
|
359
385
|
*/
|
|
360
386
|
export declare function getSupportedSignatureExtensions(): Array<string>
|
|
361
387
|
|
|
362
388
|
export declare function getSupportedStructuralExtensions(): Array<string>
|
|
363
389
|
|
|
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
390
|
/** Check whether `command` is available on `PATH`. */
|
|
376
391
|
export declare function isCommandAvailable(command: string): boolean
|
|
377
392
|
|
|
@@ -409,7 +424,15 @@ export interface JsLanguageServerConfig {
|
|
|
409
424
|
* response. Optional key sorting and priority-key ordering; multiline
|
|
410
425
|
* strings become block scalars. Emission is locked by yaml_utils tests.
|
|
411
426
|
*/
|
|
412
|
-
export
|
|
427
|
+
export type JsonPrimitive = string | number | boolean | null
|
|
428
|
+
export type JsonValue = JsonPrimitive | JsonValue[] | { [key: string]: JsonValue }
|
|
429
|
+
export type JsonInput =
|
|
430
|
+
| JsonPrimitive
|
|
431
|
+
| undefined
|
|
432
|
+
| JsonInput[]
|
|
433
|
+
| { [key: string]: JsonInput }
|
|
434
|
+
|
|
435
|
+
export declare function jsonToYamlString(jsonObject: JsonInput, config?: YamlConversionConfig | undefined | null): string
|
|
413
436
|
|
|
414
437
|
export interface JsRange {
|
|
415
438
|
start: JsExactPosition
|
|
@@ -423,12 +446,6 @@ export interface JsResolvedSymbol {
|
|
|
423
446
|
lineContent: string
|
|
424
447
|
}
|
|
425
448
|
|
|
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
449
|
export interface MatchRange {
|
|
433
450
|
/** 1-based inclusive start line. */
|
|
434
451
|
start: number
|
|
@@ -458,7 +475,7 @@ export declare function minifyConservativeCore(content: string, config: FileType
|
|
|
458
475
|
* Full minification on libuv's worker pool.
|
|
459
476
|
* Returns a Promise from JavaScript and does not block the event loop.
|
|
460
477
|
*/
|
|
461
|
-
export declare function minifyContent(content: string, filePath: string): Promise<
|
|
478
|
+
export declare function minifyContent(content: string, filePath: string): Promise<MinifyResult>
|
|
462
479
|
|
|
463
480
|
/** Synchronous full minification result. */
|
|
464
481
|
export declare function minifyContentResult(content: string, filePath: string): MinifyResult
|
|
@@ -528,12 +545,6 @@ export interface MinifyResult {
|
|
|
528
545
|
reason?: string
|
|
529
546
|
}
|
|
530
547
|
|
|
531
|
-
export interface ParsedPatchLine {
|
|
532
|
-
originalLineNumber?: number
|
|
533
|
-
newLineNumber?: number
|
|
534
|
-
content: string
|
|
535
|
-
lineType: PatchLineType
|
|
536
|
-
}
|
|
537
548
|
|
|
538
549
|
/**
|
|
539
550
|
* Parse ripgrep `--json` NDJSON stdout into structured files + stats.
|
|
@@ -545,15 +556,23 @@ export interface ParsedPatchLine {
|
|
|
545
556
|
*/
|
|
546
557
|
export declare function parseRipgrepJson(stdout: string, options?: RipgrepParseOptions | undefined | null): RipgrepParseResult
|
|
547
558
|
|
|
559
|
+
/**
|
|
560
|
+
* Run ripgrep in-process: walk `path`, search every file with ripgrep's own
|
|
561
|
+
* engine, and return the same `{ files, stats }` shape the `--json` parser
|
|
562
|
+
* produced. Replaces shelling out to an `rg` binary (and the `@vscode/ripgrep`
|
|
563
|
+
* bundle) — octocode is now its own source of ripgrep.
|
|
564
|
+
*
|
|
565
|
+
* Runs on the libuv thread pool so the filesystem walk never blocks the event
|
|
566
|
+
* loop, mirroring the old async `spawn` of `rg`.
|
|
567
|
+
*/
|
|
568
|
+
export declare function searchRipgrep(options: RipgrepSearchOptions): Promise<RipgrepParseResult>
|
|
569
|
+
|
|
548
570
|
export declare const enum PatchLineType {
|
|
549
571
|
Addition = 'Addition',
|
|
550
572
|
Deletion = 'Deletion',
|
|
551
573
|
Context = 'Context'
|
|
552
574
|
}
|
|
553
575
|
|
|
554
|
-
/** Number of loaded secret-detection patterns (testing / benchmarking). */
|
|
555
|
-
export declare function patternCount(): number
|
|
556
|
-
|
|
557
576
|
/**
|
|
558
577
|
* Cross-platform filesystem traversal and metadata filtering for local tools.
|
|
559
578
|
*
|
|
@@ -593,13 +612,11 @@ export interface RipgrepMatch {
|
|
|
593
612
|
column: number
|
|
594
613
|
/** Assembled match + context window, truncated to `max_snippet_chars`. */
|
|
595
614
|
value: string
|
|
596
|
-
/** Frequency for
|
|
615
|
+
/** Frequency for `onlyMatching + countUnique` values. */
|
|
597
616
|
count?: number
|
|
598
617
|
/**
|
|
599
|
-
* AST node-kind label (declaration|import|export|callsite|identifier|
|
|
600
|
-
*
|
|
601
|
-
* `None` when classification was off, the language is unsupported, or the
|
|
602
|
-
* file failed to parse.
|
|
618
|
+
* AST node-kind label (declaration|import|export|callsite|identifier|comment|
|
|
619
|
+
* string|configKey|heading) when `classifyMatches` is enabled.
|
|
603
620
|
*/
|
|
604
621
|
kind?: string
|
|
605
622
|
/** Deterministic relevance hint (0.0..1.0) derived from `kind`. */
|
|
@@ -625,8 +642,7 @@ export interface RipgrepPatternValidationResult {
|
|
|
625
642
|
|
|
626
643
|
/**
|
|
627
644
|
* Options for the in-process ripgrep search (`searchRipgrep`). Field semantics
|
|
628
|
-
* mirror the ripgrep CLI flags the old `RipgrepCommandBuilder` emitted
|
|
629
|
-
* search behaves identically to shelling out to `rg`.
|
|
645
|
+
* mirror the ripgrep CLI flags the old `RipgrepCommandBuilder` emitted.
|
|
630
646
|
*/
|
|
631
647
|
export interface RipgrepSearchOptions {
|
|
632
648
|
/** Search root: a directory (recursive) or a single file. */
|
|
@@ -637,7 +653,7 @@ export interface RipgrepSearchOptions {
|
|
|
637
653
|
fixedString?: boolean
|
|
638
654
|
/** Use the PCRE2 engine for lookaround/backreferences (`-P`). */
|
|
639
655
|
perlRegex?: boolean
|
|
640
|
-
/** Case-sensitive match (`-s`). Wins over `
|
|
656
|
+
/** Case-sensitive match (`-s`). Wins over `caseInsensitive`. */
|
|
641
657
|
caseSensitive?: boolean
|
|
642
658
|
/** Case-insensitive match (`-i`). Default is smart-case (`-S`). */
|
|
643
659
|
caseInsensitive?: boolean
|
|
@@ -677,34 +693,29 @@ export interface RipgrepSearchOptions {
|
|
|
677
693
|
sortReverse?: boolean
|
|
678
694
|
/** Max Unicode chars per assembled snippet (default 500). */
|
|
679
695
|
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
|
-
*/
|
|
696
|
+
/** Label each match with its AST node kind (tree-sitter) for ranking. */
|
|
685
697
|
classifyMatches?: boolean
|
|
686
698
|
/**
|
|
687
|
-
* Emit one match per
|
|
688
|
-
*
|
|
689
|
-
* minified one-liner
|
|
699
|
+
* Emit one match per submatch with `value` set to the matched span (not the
|
|
700
|
+
* whole line) — ripgrep's `-o`/`--only-matching`. Enumerates every hit on a
|
|
701
|
+
* minified one-liner that line mode can only count.
|
|
690
702
|
*/
|
|
691
703
|
onlyMatching?: boolean
|
|
692
704
|
/**
|
|
693
|
-
* With `
|
|
694
|
-
*
|
|
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.
|
|
705
|
+
* With `onlyMatching`, collapse repeated matched values per file while
|
|
706
|
+
* keeping the first occurrence anchor.
|
|
701
707
|
*/
|
|
702
708
|
unique?: boolean
|
|
703
709
|
/**
|
|
704
|
-
* With `
|
|
705
|
-
* frequency
|
|
710
|
+
* With `onlyMatching`, collapse repeated values per file and attach a
|
|
711
|
+
* frequency count to each returned match. Sorted by count descending.
|
|
706
712
|
*/
|
|
707
713
|
countUnique?: boolean
|
|
714
|
+
/**
|
|
715
|
+
* With `onlyMatching`, widen each span by this many characters on each side
|
|
716
|
+
* (char-boundary safe), marking trimmed sides with `…`. 0/unset = bare span.
|
|
717
|
+
*/
|
|
718
|
+
matchWindow?: number
|
|
708
719
|
}
|
|
709
720
|
|
|
710
721
|
export interface RipgrepStats {
|
|
@@ -722,32 +733,6 @@ export interface RipgrepStats {
|
|
|
722
733
|
*/
|
|
723
734
|
export declare function safeReadFile(filePath: string): string
|
|
724
735
|
|
|
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
736
|
export const SIGNATURES_ONLY_HINT: string
|
|
752
737
|
|
|
753
738
|
/**
|
|
@@ -779,37 +764,23 @@ export interface SliceContentResult {
|
|
|
779
764
|
*/
|
|
780
765
|
export declare function stripPythonDocstrings(content: string): string
|
|
781
766
|
|
|
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
767
|
/**
|
|
809
768
|
* One structural match. Line numbers are 1-based so `start_line` can be fed
|
|
810
769
|
* directly as an `lspGetSemantics` `lineHint`; columns are 0-based char
|
|
811
770
|
* offsets (tree-sitter native).
|
|
812
771
|
*/
|
|
772
|
+
/**
|
|
773
|
+
* Precise position of one captured metavariable node. `line` is 1-based
|
|
774
|
+
* (usable as an `lspGetSemantics` lineHint); columns are 0-based char offsets.
|
|
775
|
+
*/
|
|
776
|
+
export interface MetavarRange {
|
|
777
|
+
text: string
|
|
778
|
+
line: number
|
|
779
|
+
column: number
|
|
780
|
+
endLine: number
|
|
781
|
+
endColumn: number
|
|
782
|
+
}
|
|
783
|
+
|
|
813
784
|
export interface StructuralMatch {
|
|
814
785
|
startLine: number
|
|
815
786
|
endLine: number
|
|
@@ -822,53 +793,82 @@ export interface StructuralMatch {
|
|
|
822
793
|
* metavar name (no leading `$`).
|
|
823
794
|
*/
|
|
824
795
|
metavars: Record<string, Array<string>>
|
|
796
|
+
/**
|
|
797
|
+
* Per-capture precise ranges, parallel to `metavars` (same keys/order).
|
|
798
|
+
* Lets an agent hand a capture straight to LSP without re-searching.
|
|
799
|
+
*/
|
|
800
|
+
metavarRanges: Record<string, Array<MetavarRange>>
|
|
801
|
+
}
|
|
802
|
+
|
|
803
|
+
export interface StructuralDiagnostic {
|
|
804
|
+
code: string
|
|
805
|
+
severity: 'info' | 'warning' | 'error' | string
|
|
806
|
+
stage:
|
|
807
|
+
| 'snapshot'
|
|
808
|
+
| 'regionize'
|
|
809
|
+
| 'scan'
|
|
810
|
+
| 'parse'
|
|
811
|
+
| 'match'
|
|
812
|
+
| 'minify'
|
|
813
|
+
| 'sanitize'
|
|
814
|
+
| 'lsp'
|
|
815
|
+
| 'paginate'
|
|
816
|
+
| string
|
|
817
|
+
message: string
|
|
818
|
+
path?: string
|
|
819
|
+
recovery?: string
|
|
825
820
|
}
|
|
826
821
|
|
|
827
822
|
export interface StructuralQueryExplanation {
|
|
828
|
-
kind: string
|
|
823
|
+
kind: 'pattern' | 'rule' | 'invalid' | string
|
|
829
824
|
source: string
|
|
830
825
|
literalAnchor?: string
|
|
831
|
-
preFilter: string
|
|
826
|
+
preFilter: 'literal-anchor' | 'disabled' | 'unavailable' | string
|
|
832
827
|
unsafeReason?: string
|
|
833
828
|
diagnostics: Array<StructuralDiagnostic>
|
|
834
829
|
}
|
|
835
830
|
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
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>
|
|
831
|
+
export interface StructuralDetailedMatch extends StructuralMatch {
|
|
832
|
+
id: string
|
|
833
|
+
nodeKind?: string
|
|
834
|
+
confidence: 'exact-ast' | 'partial-ast' | 'fallback-text' | string
|
|
859
835
|
}
|
|
860
836
|
|
|
861
837
|
export interface StructuralSearchDetailedResult {
|
|
862
838
|
path: string
|
|
863
839
|
analyzer: string
|
|
864
840
|
analyzerVersion: string
|
|
865
|
-
status:
|
|
841
|
+
status:
|
|
842
|
+
| 'ok'
|
|
843
|
+
| 'partial'
|
|
844
|
+
| 'unsupported'
|
|
845
|
+
| 'ambiguous'
|
|
846
|
+
| 'parserFailed'
|
|
847
|
+
| 'fallback'
|
|
848
|
+
| 'truncated'
|
|
849
|
+
| 'stale'
|
|
850
|
+
| string
|
|
866
851
|
languageId?: string
|
|
867
852
|
query: StructuralQueryExplanation
|
|
868
853
|
matches: Array<StructuralDetailedMatch>
|
|
869
854
|
diagnostics: Array<StructuralDiagnostic>
|
|
870
855
|
}
|
|
871
856
|
|
|
857
|
+
/**
|
|
858
|
+
* Structural (AST) search — octocode's L2 layer. Resolves the grammar from
|
|
859
|
+
* `file_path`'s extension and matches an Octocode structural `pattern` OR a YAML `rule`
|
|
860
|
+
* (exactly one). Returns node ranges (1-based lines, ready as `lineHint`s)
|
|
861
|
+
* plus captured metavariables. Throws on unsupported extension, invalid
|
|
862
|
+
* pattern/rule, or both/neither query supplied.
|
|
863
|
+
*/
|
|
864
|
+
export declare function structuralSearch(content: string, filePath: string, pattern?: string | undefined | null, rule?: string | undefined | null): Array<StructuralMatch>
|
|
865
|
+
|
|
866
|
+
/**
|
|
867
|
+
* Detailed structural search. Unsupported extensions and invalid queries return
|
|
868
|
+
* status + diagnostics instead of being collapsed into a thrown legacy error.
|
|
869
|
+
*/
|
|
870
|
+
export declare function structuralSearchDetailed(content: string, filePath: string, pattern?: string | undefined | null, rule?: string | undefined | null): StructuralSearchDetailedResult
|
|
871
|
+
|
|
872
872
|
export interface StructuralSearchFileResult {
|
|
873
873
|
path: string
|
|
874
874
|
matches: Array<StructuralMatch>
|
|
@@ -878,22 +878,6 @@ export declare function structuralSearchFiles(options: StructuralSearchFilesOpti
|
|
|
878
878
|
|
|
879
879
|
export declare function structuralSearchFilesDetailed(options: StructuralSearchFilesOptions): StructuralSearchFilesDetailedResult
|
|
880
880
|
|
|
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
881
|
export interface StructuralSearchFilesOptions {
|
|
898
882
|
path: string
|
|
899
883
|
pattern?: string
|
|
@@ -914,6 +898,31 @@ export interface StructuralSearchFilesResult {
|
|
|
914
898
|
warnings: Array<string>
|
|
915
899
|
}
|
|
916
900
|
|
|
901
|
+
export interface StructuralSearchDetailedFileResult {
|
|
902
|
+
path: string
|
|
903
|
+
status: string
|
|
904
|
+
languageId?: string
|
|
905
|
+
skippedReason?: string
|
|
906
|
+
matches: Array<StructuralDetailedMatch>
|
|
907
|
+
diagnostics: Array<StructuralDiagnostic>
|
|
908
|
+
}
|
|
909
|
+
|
|
910
|
+
export interface StructuralSearchFilesDetailedResult {
|
|
911
|
+
files: Array<StructuralSearchDetailedFileResult>
|
|
912
|
+
totalMatches: number
|
|
913
|
+
parsedFiles: number
|
|
914
|
+
skippedByPreFilter: number
|
|
915
|
+
skippedUnsupported: number
|
|
916
|
+
skippedUnreadable: number
|
|
917
|
+
skippedLarge: number
|
|
918
|
+
analyzer: string
|
|
919
|
+
analyzerVersion: string
|
|
920
|
+
status: string
|
|
921
|
+
query: StructuralQueryExplanation
|
|
922
|
+
diagnostics: Array<StructuralDiagnostic>
|
|
923
|
+
warnings: Array<string>
|
|
924
|
+
}
|
|
925
|
+
|
|
917
926
|
/**
|
|
918
927
|
* Convert a human-readable symbol kind string back to the LSP `SymbolKind`
|
|
919
928
|
* numeric code. Unknown strings return `13` (Variable).
|
|
@@ -932,3 +941,27 @@ export interface YamlConversionConfig {
|
|
|
932
941
|
sortKeys?: boolean
|
|
933
942
|
keysPriority?: Array<string>
|
|
934
943
|
}
|
|
944
|
+
|
|
945
|
+
/** Result of secret detection + redaction over a string. */
|
|
946
|
+
export interface SanitizationResult {
|
|
947
|
+
content: string
|
|
948
|
+
hasSecrets: boolean
|
|
949
|
+
secretsDetected: Array<string>
|
|
950
|
+
warnings: Array<string>
|
|
951
|
+
}
|
|
952
|
+
|
|
953
|
+
/**
|
|
954
|
+
* Detect and redact all secrets from `content`, returning the sanitized string
|
|
955
|
+
* with `[REDACTED-*]` placeholders plus detection metadata. `filePath` gates
|
|
956
|
+
* file-context patterns (e.g. Kubernetes/`.env` secrets).
|
|
957
|
+
*/
|
|
958
|
+
export declare function sanitizeContent(content: string, filePath?: string | undefined | null): SanitizationResult
|
|
959
|
+
|
|
960
|
+
/**
|
|
961
|
+
* Mask secrets in place: every even-indexed char of a matched secret becomes
|
|
962
|
+
* `*`, preserving partial readability. File-context patterns are skipped.
|
|
963
|
+
*/
|
|
964
|
+
export declare function maskSensitiveData(text: string): string
|
|
965
|
+
|
|
966
|
+
/** Number of loaded secret-detection patterns (testing / benchmarking). */
|
|
967
|
+
export declare function patternCount(): number
|