엔그램 – AI 코딩 에이전트를 위한 컨텍스트 스파인, 88% 입증된 토큰 절약
hackernews
|
|
📦 오픈소스
#claude
#review
원문 출처: hackernews · Genesis Park에서 요약 및 분석
요약
Engram은 AI 코딩 에이전트의 파일 읽기를 감지하여 미리 구성된 문맥 패킷으로 대체함으로써, 불필요한 토큰 사용을 줄이는 도구입니다. Claude Code와 자동 통합되며 실제 벤치마크에서 평균 88.1%의 토큰 절감 효과를 입증했습니다. AST, Git 히스토리 등 8개의 제공자 정보를 활용해 약 500토큰 분량의 응답을 제공하며, 모든 데이터는 로컬에서 처리되어 보안을 보장합니다.
본문
Install · Quickstart · Benchmark · IDE Integrations · HTTP API · ECP Spec · Contributing engram intercepts every file read your AI agent makes and replaces it with a pre-assembled context packet — structure, decisions, git history, library docs, and known issues — from 8 providers, delivered in a single ~500-token response. The agent gets what it needs without reading the file. You stop paying for context you've already paid for. This is not a tool the agent calls. It hooks at the Claude Code tool boundary. Every Read , Edit , Write , and cat is intercepted automatically. npm install -g engramx cd ~/my-project engram init engram install-hook That's the full setup. The next Claude Code session starts with a project brief already loaded, file reads intercepted, and a live HUD showing cumulative savings. Measured across 10 structured coding tasks against a baseline of reading the relevant files directly. No synthetic data. No cherry-picked queries. | Task | Baseline (tokens) | engram (tokens) | Savings | |---|---|---|---| | task-01-find-caller | 4,500 | 650 | 85.6% | | task-02-parent-class | 2,800 | 400 | 85.7% | | task-03-file-for-class | 3,200 | 300 | 90.6% | | task-04-import-graph | 6,800 | 900 | 86.8% | | task-05-exported-api | 5,500 | 700 | 87.3% | | task-06-landmine-check | 8,200 | 850 | 89.6% | | task-07-architecture-sketch | 14,500 | 1,600 | 89.0% | | task-08-refactor-scope | 9,200 | 1,100 | 88.0% | | task-09-hot-files | 3,800 | 550 | 85.5% | | task-10-cross-file-flow | 12,800 | 1,400 | 89.1% | | Aggregate | 7,130 | 845 | 88.1% | Run the benchmark yourself: engram bench or engram stress-test for the full suite. engram sits between your AI agent and the filesystem. When the agent reads a file, engram checks its knowledge graph. If the file is covered with sufficient confidence, it blocks the read and injects a compact context packet instead. The packet is assembled from up to 8 providers in parallel, all pre-cached at session start. The 8 providers: | Provider | Source | Confidence | Latency | |---|---|---|---| engram:ast | Tree-sitter parse (10 languages) | 1.0 | and delegates to the Read handler. | SessionStart | Injects a compact project brief (god nodes, graph stats, top landmines, git branch). Bundles MemPalace context in parallel. | UserPromptSubmit | Extracts keywords from the prompt, runs a budget-capped pre-query, injects results before the agent responds. | PostToolUse | Observer only. Writes to .engram/hook-log.jsonl for hook-stats . | PreCompact | Re-injects god nodes and active landmines right before Claude compresses the conversation. Survives compaction. | CwdChanged | Auto-switches project context when you navigate to a different repo mid-session. | Ten safety invariants enforced at runtime: - Any handler error → passthrough (Claude Code is never blocked) - 2-second per-handler timeout - Kill switch ( .engram/hook-disabled ) respected by every handler - Atomic settings.json writes with timestamped backups - Never intercept outside the project root - Never intercept binary files or secrets ( .env ,.pem ,.key ,id_rsa , etc.) - Never log user prompt content (privacy invariant, asserted in tests) - Never inject more than 8,000 chars per hook response - Stale graph detection — file mtime newer than graph mtime → passthrough - Partial-read bypass — explicit offset orlimit on Read → passthrough npm install -g engramx Requires Node.js 20+. Zero native dependencies. No build tools. Local SQLite via sql.js WASM — no Rust, no Python, no system libs. cd ~/my-project engram init # scan codebase → .engram/graph.db (~40ms, 0 tokens) engram install-hook # wire the Sentinel into Claude Code Open a Claude Code session. When the agent reads a well-covered file you will see a system-reminder with the structural summary instead of file contents. After the session: engram hook-stats # what was intercepted, tokens saved engram hook-preview src/auth.ts # dry-run: see what the hook would inject for one file Full recommended setup (one-time per project): npm install -g engramx cd ~/my-project engram init --with-skills # also index ~/.claude/skills/ into the graph engram install-hook # wire Sentinel into Claude Code engram hooks install # auto-rebuild graph on every git commit Experience tiers — each works standalone: | Tier | What you run | What you get | |---|---|---| | Graph only | engram init | CLI queries, MCP server, engram gen for CLAUDE.md | | + Sentinel | engram install-hook | Automatic Read interception, Edit warnings, session briefs, HUD | | + Context Spine | Configure providers.json | Rich packets from all 8 providers per read | | + Skills index | engram init --with-skills | Graph includes your ~/.claude/skills/ | | + Git hooks | engram hooks install | Graph rebuilds on every commit, stays current | | + HTTP server | engram server --http | REST API on port 7337 for external tooling | | IDE | Integration | Setup | |---|---|---| | Claude Code | Hook-based interception (native, automatic) | engram install-hook | | Continue.dev | @engram context provider | See docs/integrations/continue.md | | Cursor | MDC generation | engram gen-mdc | | Zed | Context server | engram context-server | | Aider | Context file generation | engram gen-aider | Per-IDE setup guides are in docs/integrations/ . | engram | Continue @RepoMap | Cursor .cursorrules | Aider repo-map | @199-bio/engram | | |---|---|---|---|---|---| | Interception model | Hook-based, automatic on every Read | Fetched at @-mention time | Static file, manual | Per-session map | MCP server, called explicitly | | Cache strategy | SQLite at SessionStart, # dry-run Read handler for a specific file engram hook-disable # kill switch engram hook-enable # remove kill switch Infrastructure: engram watch [path] # live file watcher — incremental re-index on save engram dashboard [path] # live terminal dashboard engram hud-label [path] # JSON label for Claude HUD --extra-cmd integration engram hooks install # install post-commit + post-checkout git hooks engram hooks status # check git hook installation engram hooks uninstall # remove git hooks engram server --http # start HTTP REST server on port 7337 engram context-server # start Zed context server engram tune --dry-run # auto-tune provider weights (preview mode) engram db status # schema version, migration state engram init --from-ccs # import from CCS-format context file Claude HUD integration: Add --extra-cmd="engram hud-label" to your statusLine command to see live savings: engram 48.5K saved 75% Start the server with engram server --http (default port 7337). | Method | Endpoint | Description | |---|---|---| GET | /health | Server health + graph stats | POST | /query | Query the knowledge graph | GET | /gods | Most connected entities | GET | /stats | Node/edge counts, confidence breakdown | POST | /path | Shortest path between two concepts | GET | /mistakes | Known failure nodes | POST | /learn | Add a decision or pattern | POST | /init | Trigger a graph rebuild | GET | /hook-stats | Hook interception log summary | All responses are JSON. The server is local-only by default — bind address is 127.0.0.1 . { "mcpServers": { "engram": { "command": "npx", "args": ["-y", "engramx", "serve", "/path/to/your/project"] } } } MCP Tools (6): query_graph — search the knowledge graph with natural languagegod_nodes — core abstractions (most connected entities)graph_stats — node/edge counts, confidence breakdownshortest_path — trace connections between two conceptsbenchmark — token reduction measurementlist_mistakes — known failure modes from past sessions Shell wrapper (for Bash-based agents): cp scripts/mcp-engram ~/bin/mcp-engram && chmod +x ~/bin/mcp-engram mcp-engram query "how does auth work" -p ~/myrepo engram v1.0 ships the first draft of the Engram Context Protocol (ECP v0.1) — an open specification for how AI coding tools should package and exchange structured context packets. The spec defines the wire format, provider negotiation, budget constraints, and confidence scoring used by engram internally. Any tool can implement the spec to produce or consume engram-compatible context packets. License: CC-BY 4.0 Spec: docs/specs/ecp-v0.1.md import { init, query, godNodes, stats } from "engramx"; const result = await init("./my-project"); console.log(`${result.nodes} nodes, ${result.edges} edges`); const answer = await query("./my-project", "how does auth work"); console.log(answer.text); const gods = await godNodes("./my-project"); for (const g of gods) { console.log(`${g.label} — ${g.degree} connections`); } src/ ├── cli.ts CLI entry point ├── core.ts API surface (init, query, stats, learn) ├── serve.ts MCP server (6 tools, JSON-RPC stdio) ├── server.ts HTTP REST server (port 7337) ├── hooks.ts Git hook install/uninstall ├── autogen.ts CLAUDE.md / .cursorrules / MDC generation ├── graph/ │ ├── schema.ts Types: nodes, edges, confidence, schema versioning │ ├── store.ts SQLite persistence (sql.js WASM, zero native deps) │ └── query.ts BFS/DFS traversal, shortest path ├── miners/ │ ├── ast-miner.ts Tree-sitter AST extraction (10 languages, confidence 1.0) │ ├── git-miner.ts Change patterns from git history │ ├── session-miner.ts Decisions/patterns from AI session docs │ └── skills-miner.ts ~/.claude/skills/ indexer (opt-in) ├── providers/ │ ├── context-spine.ts Provider assembly + budget management │ ├── mempalace.ts MemPalace integration │ ├── context7.ts Context7 library docs │ ├── obsidian.ts Obsidian vault │ └── lsp.ts LSP diagnostic capture └── intelligence/ └── token-tracker.ts Cumulative token savings measurement Supported languages (AST): TypeScript, JavaScript, Python, Go, Rust, Java, C, C++, Ruby, PHP. Everything runs locally. No data leaves your machine. No telemetry. No cloud dependency. The only network call is npm install . Prompt content is never logged (asserted in 579 tests). Issues and PRs welcome at github.com/NickCirv/engram. Run engram init on a real codebase and share what it got right and wrong. The benchmark suite (engram bench ) is the fastest way to see the difference on your own code.
Genesis Park 편집팀이 AI를 활용하여 작성한 분석입니다. 원문은 출처 링크를 통해 확인할 수 있습니다.
공유