Releases: myothuko98/contextsnap
Release list
v2.3.0 — token budget, duplicate detector, monorepo hints
Added
--budget=<tokens> — fit any context window
Trims the least-imported exports until the snapshot fits a token ceiling. Usage ranking only counts imports that actually resolve to the scanned files (with /index fallback) or name a workspace package — import { format } from 'date-fns' can never inflate a local export's rank. --budget also lifts the scan cap from 300 to 5,000 files, since large repos are exactly who needs it. Config key: "budget".
--dupes — find duplication before your AI adds more
Flags likely duplicate exports: identical names in different files (parseISO ≈ parse_iso) and same-words-different-order names (formatDate ≈ dateFormat), each with file:line locations. Exits 1 when any are found — slots into CI next to --check.
Monorepo awareness
npm/yarn/pnpm workspaces are auto-detected (package.json workspaces, pnpm-workspace.yaml). Import hints for files in another workspace package now say @acme/ui instead of ../../packages/ui/src/button — in markdown, JSON, and MCP output.
Fixed
- MCP
rootparameter on all tools: Claude Desktop starts MCP servers in/or the home directory, so cwd-based scans silently found nothing there. Pass your project path once and the tools work from any host. - Version-stamped snapshots: the header now carries
contextsnap@<version>(JSON gets a"version"field).--checkdetects a generator/checker version mismatch and tells you to pin the version in CI, instead of reporting a misleading "stale". - Prompt-injection hardening: JSDoc is capped at 600 chars and the snapshot preamble instructs the AI to treat comment text as reference material, never as instructions.
- README no longer claims
--budget"guarantees" a ceiling — token counts are ~4 chars/token estimates.
🤖 Generated with Claude Code
v2.2.0 — MCP query tools, CLAUDE.md inject, CI drift check
Added
MCP query tools
search_exports— find an export by name, signature, or JSDoc substring. Returnsfile:linelocations so your agent jumps straight to a definition instead of pulling the whole snapshot.get_file_context— compact contract block (signatures, line numbers, JSDoc) for a single file. Much cheaper thanget_contextwhen the agent already knows the file.
--inject[=<file>]
Writes the snapshot between <!-- contextsnap:start/end --> markers in CLAUDE.md / AGENTS.md (auto-detected) or any file. Your content outside the markers is never touched; re-runs are idempotent. Every Claude Code / agent session picks the context up automatically — no clipboard, no MCP setup. Composes with --watch. Config key: "inject": true | "<file>".
--check
CI drift guard: regenerates the snapshot in memory and compares it (generation dates ignored) against the committed .ai-context.md — or the injected block when combined with --inject. Exits 1 on drift, like a lint step:
- run: npx contextsnap src --checkFixed
- MCP scans no longer crash with
ENOENTwhen an auto-detect directory (e.g.src/lib) doesn't exist. - MCP server version now reads from package.json instead of a stale hardcoded string.
🤖 Generated with Claude Code
v2.1.0 — per-export line numbers
Added
Source line numbers on every export — requested by a user so AI agents can jump straight to an implementation instead of reading the whole file.
- Markdown output: each signature ends with
// :N(its 1-based line in the source file), and the preamble tells the agent what the suffix means:export function formatLocal(isoString: string): string; // :12
- JSON output (
--format=json) and the MCPget_contexttool: each export gains a"line"field. - Zero config — always on, ~2 tokens per export.
🤖 Generated with Claude Code
v2.0.1 — parser validation layer
Fixed
Silent-failure gaps in export extraction. The fast regex parser could silently drop or corrupt exports — giving the LLM false confidence about what exists in your codebase. This release closes that class of bug:
- New export forms extracted:
export default <expression>(identifiers, object literals, arrow functions),export enum,export abstract class,export let/var, generator functions,export * [as ns] from,export type { ... },export declare - Regex-literal safety: source containing
/"/or/{/no longer derails string/brace scanning - No phantom exports: export syntax inside string values (e.g. templates that build export statements) is no longer matched
- Validation layer: every file is cross-checked against es-module-lexer. Any ESM export the fast parser misses is still emitted as a name-only stub (
export host; // signature unresolved) with a CLI warning — the context never silently omits an export.
Notes
- New dependency:
es-module-lexer(tiny, zero-dep, wasm-based) parseFile()results now include awarningsarray- Known limitations documented in README (TS generic object constraints, decorators, TS lexer coverage)
🤖 Generated with Claude Code