@maxenceleguery/codefold
v0.8.3
Published
Structural code reader for LLM agents — Read, with zoom levels.
Maintainers
Readme
@maxenceleguery/codefold (Node.js)
Node.js bindings for codefold — structural code reader for LLM agents.
The unscoped name codefold was blocked by npm as too similar to an existing
code-fold package, so this lives under the maintainer's user scope. The
per-platform native sub-packages are unscoped (codefold-linux-x64-gnu, etc.).
Install
npm install @maxenceleguery/codefoldPrebuilt binaries are shipped for:
- Linux x86_64 (glibc) / aarch64 (glibc)
- macOS x86_64 / arm64
- Windows x64
npm picks the right sub-package automatically based on your platform.
Use
import { read } from "@maxenceleguery/codefold";
const r = read("src/auth.py", "signatures");
console.log(r.content);
console.log(`~${r.tokensEst} tokens, ${r.symbols.length} symbols, ${r.language}`);
// With focus: keep `login` and `verifyToken` at full body, the rest as signatures.
const r2 = read("src/auth.py", "signatures", ["login", "verifyToken"]);API
function read(
path: string,
level?: "full" | "signatures" | "public" | "bodies", // default "signatures"
focus?: string[],
): FoldResult;
interface FoldResult {
content: string;
symbols: Symbol[];
hiddenRanges: { start: number; end: number }[];
language: string;
tokensEst: number;
}
interface Symbol {
name: string;
kind: "function" | "method" | "class" | "import";
byteStart: number;
byteEnd: number;
lineStart: number;
lineEnd: number;
}Build from source
Requires a Rust toolchain.
cd bindings/node
npm install
npm run build # builds the native binary + JS bindings
npm testLicense
MIT
