/** * Split a file into symbol/section chunks AND collect its import specifiers, in a single parse, * routed by extension. Falls back to a single file-level chunk (no imports) for unsupported * types or on parse failure — both are additive substrate, recall never depends on them, so * this can never throw or block indexing. * @param {string} path repo-relative path * @param {string} body file contents * @returns {Promise<{ chunks: Chunk[], imports: string[] }>} */ export function chunkAndImports(path: string, body: string): Promise<{ chunks: Chunk[]; imports: string[]; }>; /** * Symbol/section chunks for a file (imports discarded). Thin wrapper over {@link chunkAndImports}. * @param {string} path repo-relative path * @param {string} body file contents * @returns {Promise} */ export function chunkFile(path: string, body: string): Promise; /** * The compact signature of a symbol's chunk body, for {@link import("./compress.js").compress}'s * `signature` tier: the declaration header (modifiers, name, params, return type) WITH its doc, * but WITHOUT the implementation body. Extraction is tree-sitter — cut at the def's `body` field — * because a naive line-slice mangled arrows / generics / multiline params (POC `rc7-compress-sig`: * tree-sitter 99% vs naive 32% on 303 real defs). The header is sliced from the chunk start (after * the leading doc-comment) to the body, so `export` / `async` / decorators are kept (they sit OUTSIDE * the inner def node). Doc placement is language-shaped: a JS/TS JSDoc rides ABOVE the header (the * chunker attaches it to the chunk); a Python docstring is the first in-body string, re-attached * BELOW the header. Returns null when nothing parses (markdown, preamble, parse failure) → the * caller falls back to verbatim. * @param {string} format "py" | "js" | "ts" * @param {string} body the symbol's source text (a chunk body) * @returns {Promise<{ name: string|null, signature: string } | null>} */ export function signatureOf(format: string, body: string): Promise<{ name: string | null; signature: string; } | null>; /** * Analyse one symbol's body: the names it CALLS (callees, by name) and its cyclomatic-ish * complexity (1 + decision-point count). Tree-sitter only; parse failure → empty/zero (never * throws — impact is a hedged view, not a hard dependency). Callees are raw names; the caller * resolves them against the indexed symbol set. * @param {string} format "py" | "js" | "ts" * @param {string} body the symbol's source text * @returns {Promise<{ calls: string[], complexity: number }>} */ export function analyzeBody(format: string, body: string): Promise<{ calls: string[]; complexity: number; }>; /** * Confirmed call sites of `name` in a file body: every place `name` is actually CALLED (not merely * mentioned in a comment/string), with the enclosing caller symbol. This is the tree-sitter * "confirm" step that turns an `rg -w` candidate into a real caller (§7.1 called-by). * @param {string} format "py" | "js" | "ts" * @param {string} body file contents * @param {string} name callee name to confirm * @returns {Promise<{ line: number, enclosing: string|null }[]>} line is 0-based */ export function callSitesOf(format: string, body: string, name: string): Promise<{ line: number; enclosing: string | null; }[]>; /** * Named re-export bindings of a file: one entry per specifier in `export { local as exported } * from "source"` (exported === local when un-renamed). Star re-exports (`export * from`) are * intentionally omitted: they re-export under the ORIGINAL name (no rename) and never cover a * default export, so they can't hide a symbol from a name sweep. * @param {string} format "js" | "ts" (others → []) * @param {string} body * @returns {Promise<{ local: string, exported: string, source: string }[]>} */ export function reExportsOf(format: string, body: string): Promise<{ local: string; exported: string; source: string; }[]>; /** * Import bindings of a file: `{ imported, source }` per name brought in by `import { imported }` * / `import { x as local }` (imported = the EXTERNAL name, matched against a barrel's exported * alias) and `import D from "s"` (imported = "default"). Namespace imports (`import * as ns`) are * omitted — member dispatch (`ns.x()`) is out of v1's name-only reach (over-count-safe miss). * @param {string} format "js" | "ts" (others → []) * @param {string} body * @returns {Promise<{ imported: string, source: string }[]>} */ export function importBindingsOf(format: string, body: string): Promise<{ imported: string; source: string; }[]>; export type Chunk = { /** * symbol name when recoverable, else null */ symbol: string | null; /** * tree-sitter node type, or "preamble" | "section" | "file" */ nodeType: string; /** * 0-based, inclusive */ startLine: number; /** * 0-based, inclusive */ endLine: number; /** * chunk source text */ text: string; };