@octocodeai/octocode-engine 16.5.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.
Files changed (95) hide show
  1. package/README.md +558 -0
  2. package/dist/lsp/client.d.ts +28 -0
  3. package/dist/lsp/client.js +98 -0
  4. package/dist/lsp/config.d.ts +3 -0
  5. package/dist/lsp/config.js +7 -0
  6. package/dist/lsp/evidence.d.ts +4 -0
  7. package/dist/lsp/evidence.js +28 -0
  8. package/dist/lsp/index.d.ts +7 -0
  9. package/dist/lsp/index.js +6 -0
  10. package/dist/lsp/initConstants.d.ts +4 -0
  11. package/dist/lsp/initConstants.js +27 -0
  12. package/dist/lsp/lspClientPool.d.ts +27 -0
  13. package/dist/lsp/lspClientPool.js +87 -0
  14. package/dist/lsp/lspErrorCodes.d.ts +12 -0
  15. package/dist/lsp/lspErrorCodes.js +12 -0
  16. package/dist/lsp/manager.d.ts +23 -0
  17. package/dist/lsp/manager.js +94 -0
  18. package/dist/lsp/native.d.ts +35 -0
  19. package/dist/lsp/native.js +3 -0
  20. package/dist/lsp/resolver.d.ts +26 -0
  21. package/dist/lsp/resolver.js +73 -0
  22. package/dist/lsp/schemas.d.ts +9 -0
  23. package/dist/lsp/schemas.js +30 -0
  24. package/dist/lsp/types.d.ts +85 -0
  25. package/dist/lsp/types.js +1 -0
  26. package/dist/lsp/uri.d.ts +15 -0
  27. package/dist/lsp/uri.js +24 -0
  28. package/dist/lsp/validation.d.ts +6 -0
  29. package/dist/lsp/validation.js +23 -0
  30. package/dist/lsp/workspaceRoot.d.ts +2 -0
  31. package/dist/lsp/workspaceRoot.js +7 -0
  32. package/dist/security/commandUtils.d.ts +1 -0
  33. package/dist/security/commandUtils.js +7 -0
  34. package/dist/security/commandValidator.d.ts +7 -0
  35. package/dist/security/commandValidator.js +472 -0
  36. package/dist/security/contentSanitizer.d.ts +2 -0
  37. package/dist/security/contentSanitizer.js +181 -0
  38. package/dist/security/filePatterns.d.ts +1 -0
  39. package/dist/security/filePatterns.js +209 -0
  40. package/dist/security/ignoredPathFilter.d.ts +3 -0
  41. package/dist/security/ignoredPathFilter.js +72 -0
  42. package/dist/security/index.d.ts +16 -0
  43. package/dist/security/index.js +13 -0
  44. package/dist/security/mask.d.ts +1 -0
  45. package/dist/security/mask.js +49 -0
  46. package/dist/security/maskUtils.d.ts +1 -0
  47. package/dist/security/maskUtils.js +7 -0
  48. package/dist/security/native.d.ts +9 -0
  49. package/dist/security/native.js +161 -0
  50. package/dist/security/paramExtractors.d.ts +7 -0
  51. package/dist/security/paramExtractors.js +75 -0
  52. package/dist/security/pathPatterns.d.ts +1 -0
  53. package/dist/security/pathPatterns.js +26 -0
  54. package/dist/security/pathUtils.d.ts +1 -0
  55. package/dist/security/pathUtils.js +37 -0
  56. package/dist/security/pathValidator.d.ts +22 -0
  57. package/dist/security/pathValidator.js +229 -0
  58. package/dist/security/regexes/ai-providers.d.ts +2 -0
  59. package/dist/security/regexes/ai-providers.js +177 -0
  60. package/dist/security/regexes/analytics.d.ts +2 -0
  61. package/dist/security/regexes/analytics.js +50 -0
  62. package/dist/security/regexes/auth-crypto.d.ts +6 -0
  63. package/dist/security/regexes/auth-crypto.js +255 -0
  64. package/dist/security/regexes/aws.d.ts +2 -0
  65. package/dist/security/regexes/aws.js +68 -0
  66. package/dist/security/regexes/cloudProviders.d.ts +2 -0
  67. package/dist/security/regexes/cloudProviders.js +328 -0
  68. package/dist/security/regexes/communications.d.ts +4 -0
  69. package/dist/security/regexes/communications.js +260 -0
  70. package/dist/security/regexes/databases.d.ts +2 -0
  71. package/dist/security/regexes/databases.js +135 -0
  72. package/dist/security/regexes/devTools.d.ts +2 -0
  73. package/dist/security/regexes/devTools.js +236 -0
  74. package/dist/security/regexes/index.d.ts +3 -0
  75. package/dist/security/regexes/index.js +31 -0
  76. package/dist/security/regexes/monitoring.d.ts +2 -0
  77. package/dist/security/regexes/monitoring.js +92 -0
  78. package/dist/security/regexes/payments-commerce.d.ts +3 -0
  79. package/dist/security/regexes/payments-commerce.js +197 -0
  80. package/dist/security/regexes/types.d.ts +2 -0
  81. package/dist/security/regexes/types.js +1 -0
  82. package/dist/security/regexes/vcs.d.ts +2 -0
  83. package/dist/security/regexes/vcs.js +105 -0
  84. package/dist/security/registry.d.ts +48 -0
  85. package/dist/security/registry.js +156 -0
  86. package/dist/security/securityConstants.d.ts +3 -0
  87. package/dist/security/securityConstants.js +12 -0
  88. package/dist/security/types.d.ts +35 -0
  89. package/dist/security/types.js +1 -0
  90. package/dist/security/withSecurityValidation.d.ts +21 -0
  91. package/dist/security/withSecurityValidation.js +107 -0
  92. package/index.cjs +97 -0
  93. package/index.d.ts +934 -0
  94. package/index.js +652 -0
  95. package/package.json +311 -0
package/index.d.ts ADDED
@@ -0,0 +1,934 @@
1
+ /* auto-generated by NAPI-RS */
2
+ /* eslint-disable */
3
+ export declare class NativeLspClient {
4
+ constructor(config: JsLanguageServerConfig)
5
+ start(): Promise<void>
6
+ stop(): Promise<void>
7
+ waitForReady(timeoutMs?: number | undefined | null): Promise<void>
8
+ hasCapability(capability: string): boolean
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
+ 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
+ closeDocument(filePath: string): Promise<void>
24
+ getDefinition(filePath: string, line: number, character: number): Promise<Array<JsCodeSnippet>>
25
+ getReferences(filePath: string, line: number, character: number, includeDeclaration?: boolean | undefined | null): Promise<Array<JsCodeSnippet>>
26
+ getHover(filePath: string, line: number, character: number): Promise<any>
27
+ getTypeDefinition(filePath: string, line: number, character: number): Promise<Array<JsCodeSnippet>>
28
+ getImplementation(filePath: string, line: number, character: number): Promise<Array<JsCodeSnippet>>
29
+ getDocumentSymbols(filePath: string): Promise<any>
30
+ prepareCallHierarchy(filePath: string, line: number, character: number): Promise<any>
31
+ incomingCalls(item: any): Promise<any>
32
+ outgoingCalls(item: any): Promise<any>
33
+ }
34
+
35
+ /**
36
+ * Agent-readable "standard" view: strips comments and blank-line noise while
37
+ * preserving indentation and code shape. Capped at 1MB; panic-contained.
38
+ */
39
+ export declare function applyContentViewMinification(content: string, filePath: string): string
40
+
41
+ /**
42
+ * Full minification that never grows the content — returns the minified
43
+ * form only when it is shorter, otherwise the original. Panic-contained.
44
+ */
45
+ export declare function applyMinification(content: string, filePath: string): string
46
+
47
+ /**
48
+ * Structural inspection of a binary (executable / object / archive) file.
49
+ *
50
+ * `format`/`arch`/`bits`/`endianness`/`stripped` are always populated (the
51
+ * fields the old `identify` mode produced). The list fields are populated only
52
+ * when the file is a recognized executable format `goblin` could parse; for an
53
+ * unrecognized file they stay empty and `notes` explains why (e.g. "use
54
+ * mode=list/decompress for archives").
55
+ *
56
+ * Every list is capped (see `crate::binary::inspect::LIST_CAP`); the `*_count`
57
+ * fields carry the true totals, and `truncated` is set when any list was cut.
58
+ */
59
+ export interface BinaryInspectInfo {
60
+ /** elf | macho | macho-fat | pe | coff | archive | wasm | unknown */
61
+ format: string
62
+ /** Human-readable one-line summary (drop-in for `file -b`). */
63
+ description: string
64
+ /** Space-separated hex of the leading bytes (drop-in for `xxd -p -l 32`). */
65
+ magicHex: string
66
+ arch?: string
67
+ bits?: number
68
+ /** "little" | "big" */
69
+ endianness?: string
70
+ stripped?: boolean
71
+ /** Hex entry-point address, when the format has one. */
72
+ entry?: string
73
+ symbols: Array<string>
74
+ imports: Array<string>
75
+ exports: Array<string>
76
+ sections: Array<string>
77
+ /** Dynamic dependencies / needed shared libraries. */
78
+ libraries: Array<string>
79
+ symbolCount: number
80
+ importCount: number
81
+ exportCount: number
82
+ /** True when any list was capped. */
83
+ truncated: boolean
84
+ /** Advisory notes (unrecognized format, parse degradation, size truncation). */
85
+ notes: Array<string>
86
+ }
87
+
88
+ /** Result of a strings extraction pass over a binary buffer. */
89
+ export interface BinaryStrings {
90
+ /**
91
+ * Printable runs, longest-first. ASCII **and** UTF-16 (LE/BE) — the win
92
+ * over GNU `strings -a`, which misses wide strings. Each entry is prefixed
93
+ * with its hex byte offset when offsets were requested.
94
+ */
95
+ strings: Array<string>
96
+ /** Total runs found before any display capping. */
97
+ totalFound: number
98
+ /**
99
+ * True when more of the file remains to scan beyond this window — follow
100
+ * `next_scan_offset`. Lossless continuation cursor, **not** a data-loss
101
+ * flag (the old fixed-cap meaning): every byte is reachable by paging.
102
+ */
103
+ truncated: boolean
104
+ /**
105
+ * Absolute byte offset to start the next scan window, or `None` at EOF.
106
+ * Rewound to a safe break so no string is split across windows.
107
+ */
108
+ nextScanOffset?: number
109
+ }
110
+
111
+ /** Extract a byte-range substring from `content`. */
112
+ export declare function byteSliceContent(content: string, byteStart: number, byteEnd: number): string
113
+
114
+ /**
115
+ * JavaScript UTF-16 code-unit offset for `byte_offset` bytes into `content`.
116
+ * Zero-allocation — no `Buffer.from()` needed.
117
+ */
118
+ export declare function byteToCharOffset(content: string, byteOffset: number): number
119
+
120
+ /**
121
+ * Number of UTF-8 bytes up to (not including) the `char_index`-th JavaScript
122
+ * UTF-16 code unit in `content`. Zero-allocation — no `Buffer.from()` needed.
123
+ */
124
+ export declare function charToByteOffset(content: string, charIndex: number): number
125
+
126
+ /** Convert an LSP `SymbolKind` numeric code to a human-readable string tag. */
127
+ export declare function convertSymbolKind(kind?: number | undefined | null): string
128
+
129
+ /** Return the LSP language identifier for the file at `file_path`. */
130
+ export declare function detectLanguageId(filePath: string): string | null
131
+
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
+ /**
161
+ * Search `content` line-by-line for `pattern` (literal or regex), returning
162
+ * matched lines with context windows and omission markers.
163
+ *
164
+ * Replaces `extractMatchingLines` (contentExtractor.ts) which performed 2–3
165
+ * full `forEach` scans with per-line `toLowerCase` + `RegExp.test`.
166
+ */
167
+ export declare function extractMatchingLines(content: string, pattern: string, options?: ExtractMatchingLinesOptions | undefined | null): ExtractMatchingLinesResult
168
+
169
+ export interface ExtractMatchingLinesOptions {
170
+ /** Treat `pattern` as a regex (default false — literal match). */
171
+ isRegex?: boolean
172
+ /** Case-sensitive match (default false). */
173
+ caseSensitive?: boolean
174
+ /** Lines of context to include around each match (default 0). */
175
+ contextLines?: number
176
+ /** Cap the number of matched lines returned. */
177
+ maxMatches?: number
178
+ }
179
+
180
+ export interface ExtractMatchingLinesResult {
181
+ /** Output lines including context and omission markers. */
182
+ lines: Array<string>
183
+ /** 1-based line numbers of actual matches (capped by `max_matches`). */
184
+ matchingLines: Array<number>
185
+ /** Total matches before `max_matches` cap. */
186
+ matchCount: number
187
+ matchRanges: Array<MatchRange>
188
+ }
189
+
190
+ /**
191
+ * 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.
195
+ */
196
+ export declare function extractSignatures(content: string, filePath: string): string | null
197
+
198
+ export interface FileSystemEntry {
199
+ /** Absolute or input-root-relative path as returned by the platform. */
200
+ path: string
201
+ /** Path relative to the query root. */
202
+ relativePath: string
203
+ name: string
204
+ /** "file", "directory", "symlink", or "other". */
205
+ entryType: string
206
+ size?: number
207
+ modifiedMs?: number
208
+ accessedMs?: number
209
+ permissions?: string
210
+ extension?: string
211
+ /** Output depth where direct children are 0. */
212
+ depth: number
213
+ }
214
+
215
+ export interface FileSystemQueryOptions {
216
+ path: string
217
+ /** Include the root path itself in results (default false). */
218
+ includeRoot?: boolean
219
+ /** Descend into child directories (default true). */
220
+ recursive?: boolean
221
+ /** Maximum depth where direct children are depth 1. */
222
+ maxDepth?: number
223
+ /** Minimum depth where direct children are depth 1. */
224
+ minDepth?: number
225
+ /** Include dotfiles and dot-directories (default true). */
226
+ showHidden?: boolean
227
+ /** Match basename globs, OR-combined. */
228
+ names?: Array<string>
229
+ /** Match full path glob. */
230
+ pathPattern?: string
231
+ /** Rust regex against basename. */
232
+ regex?: string
233
+ /** POSIX find-style entry type: f=file, d=directory, l=symlink. */
234
+ entryType?: string
235
+ /** Match only empty files or directories. */
236
+ empty?: boolean
237
+ /** Modified within a duration string such as 7d, 2h, 30m. */
238
+ modifiedWithin?: string
239
+ /** Modified before a duration string such as 30d. */
240
+ modifiedBefore?: string
241
+ /** Accessed within a duration string such as 7d. */
242
+ accessedWithin?: string
243
+ /** Size greater than a string such as 100k, 1m, 500b. */
244
+ sizeGreater?: string
245
+ /** Size less than a string such as 100k, 1m, 500b. */
246
+ sizeLess?: string
247
+ /** Exact octal permissions, e.g. 644. */
248
+ permissions?: string
249
+ executable?: boolean
250
+ readable?: boolean
251
+ writable?: boolean
252
+ excludeDir?: Array<string>
253
+ /** Store at most this many matching entries while still counting matches. */
254
+ limit?: number
255
+ }
256
+
257
+ export interface FileSystemQueryResult {
258
+ entries: Array<FileSystemEntry>
259
+ totalDiscovered: number
260
+ wasCapped: boolean
261
+ skipped: number
262
+ permissionDenied: number
263
+ warnings: Array<string>
264
+ }
265
+
266
+ export interface FileTypeMinifyConfig {
267
+ strategy: string
268
+ /** CommentPatternGroup | CommentPatternGroup[] */
269
+ comments?: any
270
+ }
271
+
272
+ /**
273
+ * Filter and optionally trim a unified diff patch.
274
+ *
275
+ * Replaces `filterPatch` + `trimDiffContext` from `utils/parsers/diff.ts` which
276
+ * called `patch.split('
277
+ ')` independently in both functions. This combines
278
+ * both operations in a single pass.
279
+ */
280
+ export declare function filterPatch(patch: string, options?: FilterPatchOptions | undefined | null): string
281
+
282
+ export interface FilterPatchOptions {
283
+ /** Only keep additions at these new-file line numbers. */
284
+ additions?: Array<number>
285
+ /** Only keep deletions at these original-file line numbers. */
286
+ deletions?: Array<number>
287
+ /** Apply context trimming (equivalent to `trimDiffContext`, default false). */
288
+ trimContext?: boolean
289
+ /** Context window size when `trim_context` is true (default 2). */
290
+ contextLines?: number
291
+ }
292
+
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
+ /** Convert a `file://` URI string back to an absolute filesystem path. */
306
+ export declare function fromUri(uri: string): string
307
+
308
+ /**
309
+ * Extract the file extension from a path (dotfile-aware).
310
+ * Options control lowercasing and the configured default used when no extension exists.
311
+ */
312
+ export declare function getExtension(filePath: string, options?: GetExtensionOptions | undefined | null): string
313
+
314
+ export interface GetExtensionOptions {
315
+ lowercase?: boolean
316
+ fallback?: string
317
+ }
318
+
319
+ /**
320
+ * Return the default language server configuration for `file_path` inside
321
+ * `workspace_root`.
322
+ */
323
+ export declare function getLanguageServerForFile(filePath: string, workspaceRoot: string): JsLanguageServerConfig | null
324
+
325
+ /**
326
+ * Returns the full MINIFY_CONFIG as a JS-compatible object.
327
+ * Shape: `{ fileTypes: Record<string, { strategy: string, comments: string | string[] | null }> }`
328
+ */
329
+ export declare function getMINIFY_CONFIG(): any
330
+
331
+ /**
332
+ * Returns a sorted list of JS char offsets (UTF-16 code units) where
333
+ * top-level semantic blocks begin in `content`.
334
+ *
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.
340
+ *
341
+ * Char offsets match JavaScript `string.substring()` — pass them directly to
342
+ * JavaScript string slicing without conversion.
343
+ */
344
+ export declare function getSemanticBoundaryOffsets(content: string, filePath: string): Array<number>
345
+
346
+ /**
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.
359
+ */
360
+ export declare function getSupportedSignatureExtensions(): Array<string>
361
+
362
+ export declare function getSupportedStructuralExtensions(): Array<string>
363
+
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
+ /** Check whether `command` is available on `PATH`. */
376
+ export declare function isCommandAvailable(command: string): boolean
377
+
378
+ export interface JsCodeSnippet {
379
+ uri: string
380
+ range: JsRange
381
+ content: string
382
+ symbolKind?: string
383
+ displayRange?: any
384
+ }
385
+
386
+ export interface JsExactPosition {
387
+ line: number
388
+ character: number
389
+ }
390
+
391
+ export interface JsFuzzyPosition {
392
+ symbolName: string
393
+ lineHint?: number
394
+ orderHint?: number
395
+ }
396
+
397
+ export interface JsLanguageServerConfig {
398
+ command: string
399
+ args?: Array<string>
400
+ workspaceRoot: string
401
+ languageId?: string
402
+ initializationOptions?: any
403
+ /** Extra environment variables to inject into the language server process. */
404
+ env?: Record<string, string>
405
+ }
406
+
407
+ /**
408
+ * Serialize a JSON value to YAML — the formatter for every MCP tool
409
+ * response. Optional key sorting and priority-key ordering; multiline
410
+ * strings become block scalars. Emission is locked by yaml_utils tests.
411
+ */
412
+ export declare function jsonToYamlString(jsonObject: any, config?: YamlConversionConfig | undefined | null): string
413
+
414
+ export interface JsRange {
415
+ start: JsExactPosition
416
+ end: JsExactPosition
417
+ }
418
+
419
+ export interface JsResolvedSymbol {
420
+ position: JsExactPosition
421
+ foundAtLine: number
422
+ lineOffset: number
423
+ lineContent: string
424
+ }
425
+
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
+ export interface MatchRange {
433
+ /** 1-based inclusive start line. */
434
+ start: number
435
+ /** 1-based inclusive end line. */
436
+ end: number
437
+ }
438
+
439
+ /**
440
+ * Aggressive strategy: strip comments, collapse all whitespace, tighten
441
+ * punctuation. Lossy — for token-budget views only.
442
+ */
443
+ export declare function minifyAggressiveCore(content: string, config: FileTypeMinifyConfig): string
444
+
445
+ /**
446
+ * Whitespace-only code cleanup: trim line ends, collapse 3+ blank lines,
447
+ * preserve indentation.
448
+ */
449
+ export declare function minifyCodeCore(content: string): string
450
+
451
+ /**
452
+ * Conservative strategy: strip the configured comment groups, collapse blank
453
+ * runs, preserve indentation.
454
+ */
455
+ export declare function minifyConservativeCore(content: string, config: FileTypeMinifyConfig): string
456
+
457
+ /**
458
+ * Full minification on libuv's worker pool.
459
+ * Returns a Promise from JavaScript and does not block the event loop.
460
+ */
461
+ export declare function minifyContent(content: string, filePath: string): Promise<unknown>
462
+
463
+ /** Synchronous full minification result. */
464
+ export declare function minifyContentResult(content: string, filePath: string): MinifyResult
465
+
466
+ /**
467
+ * Full minification, synchronous. Content above the 1MB guard is returned
468
+ * unchanged; unknown file types use the general strategy.
469
+ */
470
+ export declare function minifyContentSync(content: string, filePath: string): string
471
+
472
+ /**
473
+ * Lightweight CSS cleanup (comment strip + whitespace). See
474
+ * `minifyCSSQuality` for the lightningcss-backed variant.
475
+ */
476
+ export declare function minifyCSSCore(content: string): string
477
+
478
+ /**
479
+ * CSS minification via lightningcss — parser-grade, strips comments and
480
+ * redundant units.
481
+ */
482
+ export declare function minifyCSSQuality(content: string): string
483
+
484
+ /** Generic text cleanup for unknown file types: trim + collapse blank runs. */
485
+ export declare function minifyGeneralCore(content: string): string
486
+
487
+ /**
488
+ * Lightweight HTML/XML cleanup (comment strip + whitespace). See
489
+ * `minifyHTMLQuality` for the style-aware built-in variant.
490
+ */
491
+ export declare function minifyHTMLCore(content: string): string
492
+
493
+ /**
494
+ * Style-aware HTML cleanup: strips comments, tightens whitespace, and minifies
495
+ * embedded `<style>` blocks through the existing CSS pipeline.
496
+ */
497
+ export declare function minifyHTMLQuality(content: string): string
498
+
499
+ /**
500
+ * Heuristic JS minifier (comment strip + whitespace tightening) used when
501
+ * the OXC pipeline declines the input.
502
+ */
503
+ export declare function minifyJavaScriptCore(content: string): string
504
+
505
+ /**
506
+ * Compact JSON to a single line. JSONC/JSON5 noise (comments, trailing
507
+ * commas) is stripped before parsing; unparseable input is returned trimmed.
508
+ */
509
+ export declare function minifyJsonCore(content: string): MinifyResult
510
+
511
+ /**
512
+ * Readable JSON view: keeps formatting, strips JSONC noise and trailing
513
+ * whitespace, collapses blank runs. Valid JSON passes through unchanged.
514
+ */
515
+ export declare function minifyJsonReadable(content: string): MinifyResult
516
+
517
+ /**
518
+ * Markdown view: drops HTML comments, badges, and generated TOCs; compacts
519
+ * tables and headings; preserves code fences and frontmatter verbatim.
520
+ */
521
+ export declare function minifyMarkdownCore(content: string): string
522
+
523
+ export interface MinifyResult {
524
+ content: string
525
+ failed: boolean
526
+ /** Strategy name or "failed" */
527
+ type: string
528
+ reason?: string
529
+ }
530
+
531
+ export interface ParsedPatchLine {
532
+ originalLineNumber?: number
533
+ newLineNumber?: number
534
+ content: string
535
+ lineType: PatchLineType
536
+ }
537
+
538
+ /**
539
+ * Parse ripgrep `--json` NDJSON stdout into structured files + stats.
540
+ *
541
+ * Replaces the TypeScript `parseRipgrepJson` (utils/parsers/ripgrep.ts) which
542
+ * used `JSON.parse` + Zod `safeParse` per NDJSON line and a `[...value]`
543
+ * UTF-16 spread per match snippet. A single `serde_json` streaming pass with
544
+ * no per-line schema validation.
545
+ */
546
+ export declare function parseRipgrepJson(stdout: string, options?: RipgrepParseOptions | undefined | null): RipgrepParseResult
547
+
548
+ export declare const enum PatchLineType {
549
+ Addition = 'Addition',
550
+ Deletion = 'Deletion',
551
+ Context = 'Context'
552
+ }
553
+
554
+ /** Number of loaded secret-detection patterns (testing / benchmarking). */
555
+ export declare function patternCount(): number
556
+
557
+ /**
558
+ * Cross-platform filesystem traversal and metadata filtering for local tools.
559
+ *
560
+ * Replaces the POSIX `find`/`ls` execution paths in octocode-tools-core while
561
+ * keeping MCP response shaping in TypeScript.
562
+ */
563
+ export declare function queryFileSystem(options: FileSystemQueryOptions): FileSystemQueryResult
564
+
565
+ /** `commentTypes` accepts a single string or array of strings. */
566
+ export declare function removeComments(content: string, commentTypes: any): string
567
+
568
+ /**
569
+ * Resolve a fuzzy symbol position (name + optional line hint) to an exact
570
+ * line/character position inside the file at `file_path`.
571
+ */
572
+ export declare function resolvePosition(filePath: string, fuzzy: JsFuzzyPosition): JsResolvedSymbol
573
+
574
+ /**
575
+ * Resolve a fuzzy symbol position against in-memory `content` rather than
576
+ * reading from disk. Use when the caller already holds the file text.
577
+ */
578
+ export declare function resolvePositionFromContent(content: string, fuzzy: JsFuzzyPosition): JsResolvedSymbol
579
+
580
+ /** Walk upward from `file_path` to find the workspace root. */
581
+ export declare function resolveWorkspaceRootForFile(filePath: string): string
582
+
583
+ export interface RipgrepFile {
584
+ path: string
585
+ matchCount: number
586
+ matches: Array<RipgrepMatch>
587
+ }
588
+
589
+ export interface RipgrepMatch {
590
+ /** 1-based line number. */
591
+ line: number
592
+ /** 0-based column offset of the first submatch. */
593
+ column: number
594
+ /** Assembled match + context window, truncated to `max_snippet_chars`. */
595
+ value: string
596
+ /** Frequency for this value when `count_unique` is enabled. */
597
+ count?: number
598
+ /**
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.
603
+ */
604
+ kind?: string
605
+ /** Deterministic relevance hint (0.0..1.0) derived from `kind`. */
606
+ scoreHint?: number
607
+ }
608
+
609
+ export interface RipgrepParseOptions {
610
+ /** Number of context lines around each match (default 0). */
611
+ contextLines?: number
612
+ /** Max Unicode chars per match snippet (default 500). */
613
+ maxSnippetChars?: number
614
+ }
615
+
616
+ export interface RipgrepParseResult {
617
+ files: Array<RipgrepFile>
618
+ stats: RipgrepStats
619
+ }
620
+
621
+ export interface RipgrepPatternValidationResult {
622
+ valid: boolean
623
+ error?: string
624
+ }
625
+
626
+ /**
627
+ * 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`.
630
+ */
631
+ export interface RipgrepSearchOptions {
632
+ /** Search root: a directory (recursive) or a single file. */
633
+ path: string
634
+ /** The search pattern (rg's positional pattern / `keywords`). */
635
+ pattern: string
636
+ /** Treat the pattern as a literal string, not a regex (`-F`). */
637
+ fixedString?: boolean
638
+ /** Use the PCRE2 engine for lookaround/backreferences (`-P`). */
639
+ perlRegex?: boolean
640
+ /** Case-sensitive match (`-s`). Wins over `case_insensitive`. */
641
+ caseSensitive?: boolean
642
+ /** Case-insensitive match (`-i`). Default is smart-case (`-S`). */
643
+ caseInsensitive?: boolean
644
+ /** Match whole words only (`-w`). */
645
+ wholeWord?: boolean
646
+ /** Invert: report non-matching lines (`-v`). */
647
+ invertMatch?: boolean
648
+ /** Multi-line mode: `.` and the pattern may span lines (`-U`). */
649
+ multiline?: boolean
650
+ /** In multi-line mode, let `.` match newlines (`--multiline-dotall`). */
651
+ multilineDotall?: boolean
652
+ /** List only the paths of files that contain a match (`-l`). */
653
+ filesOnly?: boolean
654
+ /** List only the paths of files with no match (`--files-without-match`). */
655
+ filesWithoutMatch?: boolean
656
+ /** Per-file count of matching lines (`-c`). */
657
+ countLinesPerFile?: boolean
658
+ /** Per-file count of individual matches (`--count-matches`). */
659
+ countMatchesPerFile?: boolean
660
+ /** Context lines around each match (`-C`). */
661
+ contextLines?: number
662
+ /** Restrict to a ripgrep file type, e.g. `ts`, `py` (`-t`). */
663
+ langType?: string
664
+ /** Include globs (`-g <glob>`). */
665
+ include?: Array<string>
666
+ /** Exclude globs (`-g !<glob>`). */
667
+ exclude?: Array<string>
668
+ /** Exclude directories (`-g !<dir>/`). */
669
+ excludeDir?: Array<string>
670
+ /** Do not honor .gitignore/.ignore/etc. (`--no-ignore`). */
671
+ noIgnore?: boolean
672
+ /** Search hidden files and directories (`--hidden`). */
673
+ hidden?: boolean
674
+ /** Sort key: `path` (default), `modified`, `accessed`, or `created`. */
675
+ sort?: string
676
+ /** Reverse the sort order (`--sortr`). */
677
+ sortReverse?: boolean
678
+ /** Max Unicode chars per assembled snippet (default 500). */
679
+ 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
+ */
685
+ classifyMatches?: boolean
686
+ /**
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.
690
+ */
691
+ onlyMatching?: boolean
692
+ /**
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.
701
+ */
702
+ unique?: boolean
703
+ /**
704
+ * With `only_matching`, collapse duplicate values and attach their
705
+ * frequency, sorted by count descending.
706
+ */
707
+ countUnique?: boolean
708
+ }
709
+
710
+ export interface RipgrepStats {
711
+ matchCount?: number
712
+ matchedLines?: number
713
+ filesMatched?: number
714
+ filesSearched?: number
715
+ bytesSearched?: number
716
+ searchTime?: string
717
+ }
718
+
719
+ /**
720
+ * Read `file_path` from disk after canonicalizing it and confirming it is an
721
+ * absolute regular file.
722
+ */
723
+ export declare function safeReadFile(filePath: string): string
724
+
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
+ export const SIGNATURES_ONLY_HINT: string
752
+
753
+ /**
754
+ * Paginate `content` by char offset + length, with optional line-boundary
755
+ * snapping. Replaces both the char-mode conversion block in `applyPagination`
756
+ * and the dead-code `sliceByCharRespectLines` (0 callers confirmed by LSP).
757
+ */
758
+ export declare function sliceContent(content: string, charOffset: number, charLength: number, options?: SliceContentOptions | undefined | null): SliceContentResult
759
+
760
+ export interface SliceContentOptions {
761
+ /** When true, snap start to line start and end to line end (default false). */
762
+ snapToLineBoundary?: boolean
763
+ }
764
+
765
+ export interface SliceContentResult {
766
+ text: string
767
+ /** Actual start char offset (may differ from requested when snapping). */
768
+ charOffset: number
769
+ charLength: number
770
+ byteOffset: number
771
+ byteLength: number
772
+ hasMore: boolean
773
+ nextCharOffset?: number
774
+ }
775
+
776
+ /**
777
+ * Remove Python docstrings (module/class/function level) while preserving
778
+ * all runtime code.
779
+ */
780
+ export declare function stripPythonDocstrings(content: string): string
781
+
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
+ /**
809
+ * One structural match. Line numbers are 1-based so `start_line` can be fed
810
+ * directly as an `lspGetSemantics` `lineHint`; columns are 0-based char
811
+ * offsets (tree-sitter native).
812
+ */
813
+ export interface StructuralMatch {
814
+ startLine: number
815
+ endLine: number
816
+ startCol: number
817
+ endCol: number
818
+ text: string
819
+ /**
820
+ * Captured metavariables. `$X` yields a single-element list;
821
+ * `$$$ARGS` yields the full list of captured nodes. Keyed by the bare
822
+ * metavar name (no leading `$`).
823
+ */
824
+ metavars: Record<string, Array<string>>
825
+ }
826
+
827
+ export interface StructuralQueryExplanation {
828
+ kind: string
829
+ source: string
830
+ literalAnchor?: string
831
+ preFilter: string
832
+ unsafeReason?: string
833
+ diagnostics: Array<StructuralDiagnostic>
834
+ }
835
+
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>
859
+ }
860
+
861
+ export interface StructuralSearchDetailedResult {
862
+ path: string
863
+ analyzer: string
864
+ analyzerVersion: string
865
+ status: string
866
+ languageId?: string
867
+ query: StructuralQueryExplanation
868
+ matches: Array<StructuralDetailedMatch>
869
+ diagnostics: Array<StructuralDiagnostic>
870
+ }
871
+
872
+ export interface StructuralSearchFileResult {
873
+ path: string
874
+ matches: Array<StructuralMatch>
875
+ }
876
+
877
+ export declare function structuralSearchFiles(options: StructuralSearchFilesOptions): StructuralSearchFilesResult
878
+
879
+ export declare function structuralSearchFilesDetailed(options: StructuralSearchFilesOptions): StructuralSearchFilesDetailedResult
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
+ export interface StructuralSearchFilesOptions {
898
+ path: string
899
+ pattern?: string
900
+ rule?: string
901
+ include?: Array<string>
902
+ excludeDir?: Array<string>
903
+ maxFiles?: number
904
+ maxFileBytes?: number
905
+ }
906
+
907
+ export interface StructuralSearchFilesResult {
908
+ files: Array<StructuralSearchFileResult>
909
+ totalMatches: number
910
+ parsedFiles: number
911
+ skippedByPreFilter: number
912
+ skippedUnreadable: number
913
+ skippedLarge: number
914
+ warnings: Array<string>
915
+ }
916
+
917
+ /**
918
+ * Convert a human-readable symbol kind string back to the LSP `SymbolKind`
919
+ * numeric code. Unknown strings return `13` (Variable).
920
+ */
921
+ export declare function toLspSymbolKind(kind: string): number
922
+
923
+ /** Convert a filesystem path to a `file://` URI string. */
924
+ export declare function toUri(path: string): string
925
+
926
+ /** Validate that `command` resolves to an executable LSP server binary. */
927
+ export declare function validateLspServerPath(command: string): string
928
+
929
+ export declare function validateRipgrepPattern(pattern: string, fixedString?: boolean | undefined | null, perlRegex?: boolean | undefined | null): RipgrepPatternValidationResult
930
+
931
+ export interface YamlConversionConfig {
932
+ sortKeys?: boolean
933
+ keysPriority?: Array<string>
934
+ }