npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@mygsoft/context-diet

v1.3.2

Published

Smart AI Context Optimizer & Adaptive MCP Server with Global Language Support

Readme

📉 Context-Diet v1.3.2

Predictive AI Context Optimizer, Terminal Log Distiller & Universal MCP Infrastructure (Global OSS Synergy Edition)

npm version npm downloads License Node Tests MCP

Context-Diet is a high-performance engine designed to slash AI token costs by 85% to 99% while boosting reasoning accuracy. By combining AST-based folding, multi-turn context working-set caching, session delta diffs, virtual type bundling, RTK terminal log distillation, Headroom CCR reversible compression, 2-Tier atomic decision memory, and Repomix zero-body skeleton packing, Context-Diet ensures your AI agents (Claude, Cursor, Antigravity, Windsurf, Cline) process only the code that truly matters.


📑 Table of Contents


🚀 Quick Start

Initialize your project and AI IDE environments in one command:

# Interactive setup (prompts: Global, Local workspace only, or Both)
npx @mygsoft/context-diet init

# Or install globally across all AI IDEs on this PC (without creating local files)
npx @mygsoft/context-diet init --global

# Or install locally for the current project only (without modifying global settings)
npx @mygsoft/context-diet init --local

The init command prompts you to choose your desired installation scope:

  1. 🌐 Both (Recommended): Automatically deploys persistent zero-waste rules and MCP to Antigravity (~/.gemini/config), Claude Code (~/.claude/CLAUDE.md), Cursor (~/.cursor/rules/), Windsurf (~/.codeium/windsurf/), and Cline (~/.clinerules), AND configures current project workspace rules (GEMINI.md, .cursorrules, etc.).
  2. 🖥️ Global Only (--global / -g): Sets up PC-wide global rules and MCP servers across all detected AI IDEs without creating files in your current directory.
  3. 📁 Local Only (--local / -l): Injects rules, lifecycle guards (hooks.json & enforce-diet.cjs), and skills only into the current project workspace, leaving your global IDE settings 100% untouched.

🔌 One-Click MCP Installation

Automatically registers Context-Diet into all detected IDEs:

# Auto-detect and register into Claude Desktop, Cursor, Antigravity, Windsurf, Cline
diet install-mcp

# List detected clients and config paths
diet install-mcp --list

# Simulate installation without writing files
diet install-mcp --dry-run

# Force install to all supported clients
diet install-mcp --all

Supported MCP Clients:

  • Claude Desktop: %APPDATA%\Claude\claude_desktop_config.json (Windows) / ~/Library/Application Support/Claude/claude_desktop_config.json (macOS)
  • Cursor: ~/.cursor/mcp.json (Global) & .cursor/mcp.json (Workspace)
  • Antigravity IDE: ~/.gemini/config/mcp_config.json & .agents/mcp_config.json
  • Windsurf: ~/.codeium/windsurf/mcp_config.json
  • Cline / Roo Code: VS Code global extension settings

📦 Multi-OS Packages & Installation

Context-Diet is distributed as ready-to-run native packages for Gumroad and npm:

| Platform | Deliverable | Installation | | :--- | :--- | :--- | | Windows | context-diet-windows-x64.zip | Extract and run install.bat (installs standalone binary and adds to PATH) | | macOS | context-diet-macos.zip | Extract and run ./install.sh | | Linux | context-diet-linux.tar.gz | Extract and run ./install.sh | | NPM (Universal) | @mygsoft/context-diet | npm install -g @mygsoft/context-diet or npx @mygsoft/context-diet init |

For detailed step-by-step setup and troubleshooting, refer to INSTALL.md.


💎 Editions & Feature Matrix (Community vs Pro)

Context-Diet is released under the Functional Source License, Version 1.1 (FSL-1.1-MIT).

  • Source-Available: The entire source code is 100% transparent and public on GitHub.
  • Freedom to Build: Free to inspect, use locally, modify, and integrate into internal personal and team workflows.
  • Fair Competition & Anti-Crack: Creating competing commercial services or bypassing feature gating/paywalls is strictly prohibited. Automatically converts to standard MIT License 2 years from release date.

| Capability / Feature | Community Edition (Free) | Pro Lifetime ($14 Early-Bird / $29 Reg) | Team & Enterprise (Roadmap) | | :--- | :---: | :---: | :---: | | AST Semantic Code Folding (diet read, -s, -i, -t) | ✔ 100/day, 5M/mo (Graceful Fallback to Raw) | ✔ Unlimited | ✔ Unlimited | | Multi-Language Support (TS, JS, Py, Go, Rust, Java, C#, C++) | ✔ Unlimited | ✔ Unlimited | ✔ Unlimited | | Multi-Turn Working-Set Cache (35-token deduplication) | ✔ Unlimited | ✔ Unlimited | ✔ Unlimited | | Session Delta Diffs (Unified Myers diff delivery) | ✔ Unlimited | ✔ Unlimited | ✔ Unlimited | | RTK Terminal Log Distiller (diet_exec / 12 command profiles) | ✔ Unlimited | ✔ Unlimited | ✔ Unlimited | | Headroom CCR Reversible Log Expansion (diet expand) | ✔ Unlimited | ✔ Unlimited | ✔ Unlimited | | 2-Tier Atomic Decision Memory (diet memory, diet_memory) | ✔ Unlimited (Local) | ✔ Unlimited (Local) | 🚀 Team Central Sync (S3/GCS) | | AST Structural Query (diet query / ast-grep pattern) | ✔ Unlimited | ✔ Unlimited | ✔ Unlimited | | Architecture Skeleton Packer (diet pack / Repomix & PageRank) | ✔ Unlimited | ✔ Unlimited | ✔ Unlimited | | Native Hybrid Accelerated Search (diet search / Rust rg+fd) | ✔ Unlimited | ✔ Unlimited | ✔ Unlimited | | Real-Time Secret Masking (SecretSanitizer / Gitleaks 20+ patterns) | ✔ Unlimited | ✔ Unlimited | ✔ Unlimited | | Negative Compression Lossless Rollback Guard | ✔ Unlimited | ✔ Unlimited | ✔ Unlimited | | Token-Optimized Project Tree (diet tree) | ✔ Unlimited | ✔ Unlimited | ✔ Unlimited | | Universal One-Click MCP Registration (diet install-mcp) | ✔ Unlimited | ✔ Unlimited | ✔ Unlimited | | Real-Time Web Dashboard (diet ui) | ✔ Real-time Viewer | ✔ Full Viewer + CSV/JSON Export | 🚀 Org-Wide Analytics & Audit | | Virtual Type Bundler (--bundle-types) | 🔒 (Pro Required) | ✔ Unlimited | 🚀 Unlimited | | Sub-Agent Context Partitioning & Adapter (diet subagent) | 🔒 (Pro Required) | ✔ Unlimited | 🚀 Unlimited | | CI/CD Automated PR Gate & Threshold Bot (diet check --ci) | 🔒 (Pro Required) | ✔ Unlimited | 🚀 Unlimited PR Runners | | License | FSL-1.1-MIT | Commercial Lifetime Grant | Commercial Enterprise Grant | | Device Seats | Unlimited | 3 Devices (HWID Binding) | Volume Seats / SSO | | Pricing | Free ($0) | $14 Early-Bird (First 50 / Reg $29) | $12/mo or $99/yr (Roadmap) |

💡 ROI Payback Guarantee: Once Context-Diet saves you over $14 (Early-Bird) or $29 (Regular) in LLM API token costs, the Pro license has paid for itself completely! Pro Lifetime Edition can be activated via Polar with full offline cryptographic support (diet activate <key> --offline).
🏢 Team & Enterprise Edition (Roadmap): Centralized token telemetry, shared team cache, and organization-wide PR gates are planned for future release.


🛠 CLI Command Reference

1. diet init [options]

Initializes Context-Diet zero-waste protocols, lifecycle hooks, agent skills, and MCP servers across your workspace and global AI environments.

# Interactive setup (prompts: Global, Local only, or Both)
diet init

# Install globally across all AI IDEs on your PC (no local project files created)
diet init --global

# Install only for the current project workspace (global settings untouched)
diet init --local

# Non-interactive auto-setup for all supported formats
diet init -y --all
  • -g, --global: Install persistent zero-waste rules, lifecycle hooks, and MCP servers globally (~/.gemini/config, ~/.claude/CLAUDE.md, ~/.cursor/rules/, ~/.codeium/windsurf/, ~/.clinerules) without touching the local project folder.
  • -l, --local: Install rules, lifecycle guards, and MCP servers only to the current project workspace without modifying global settings.
  • -y, --yes: Non-interactive auto-setup without interactive prompts (defaults to both).
  • --all: Inject guidelines and register into all supported AI IDE formats simultaneously.

2. diet read <path> [options]

Reads a file with AST folding, predictive caching, session working-set tracking, and automated secret masking (SecretSanitizer).

diet read src/main.ts -s handleAuth
  • -s, --symbol <name>: Unfold a specific function, class, or method.
  • -i, --intent <keywords>: Unfold code blocks matching keywords.
  • -t, --types-only: Extract only pure type signatures and interfaces, stripping function bodies (95% token savings).
  • -b, --bundle-types: Inline imported local types at the bottom to eliminate round-trip reads.
  • -f, --force: Bypass working-set cache and force a complete re-dump.
  • --no-delta: Disable unified diff output on modified files.
  • --ref <id>: Expand stored raw log reference (Headroom CCR pattern).

2. diet exec <command...>

Runs terminal commands (tests, builds, lints, git, docker) and distills output using 12 RTK profiles, removing 95% of noise while preserving critical errors and stack traces. Stashes raw output to .context-diet/raw_logs/ for reversible restoration.

diet exec npm test
diet exec git status
diet exec docker build .

3. diet expand <ref_id> [options]

Reversibly restores original terminal or command raw logs on demand using Headroom CCR (Chunk-wise Continuous Retrieval) pattern.

diet expand log_1729001234_a1b2
diet expand log_1729001234_a1b2 -s 1 -e 50
  • -s, --start-line <number>: 1-indexed start line.
  • -e, --end-line <number>: 1-indexed end line.

4. diet doctor [--fix] [-y, --yes]

Comprehensive system and dependency health diagnosis.

diet doctor
diet doctor --fix

Checks Node.js version, package manager (npm/pnpm/yarn/bun), native SQLite acceleration, Tree-sitter WASM grammars, and MCP registrations.

5. diet fix-deps [-y, --yes]

Safely repairs/rebuilds missing WASM binaries and native dependencies with interactive TTY consent and zero root project pollution.

diet fix-deps

6. diet stats [path]

Displays telemetry on saved tokens, cost reductions ($), and cache hit rates.

diet stats

7. diet audit <path>

Audits compression ratio, parsing speed, and syntax integrity for any source file.

diet audit src/core/parser.ts

8. diet search <query> [path]

Fast hybrid code search powered by native Rust rg (ripgrep) / fd subprocesses with automatic pure Node.js fallback.

diet search "handleAuth" src/

9. diet tree [path]

Generates an optimized, token-friendly directory tree.

diet tree src/ -d 2
  • -d, --depth <number>: Maximum traversal depth (default: 2).

10. diet query <pattern> [target_path]

Performs fast AST structural pattern matching (ast-grep pattern) across files or directories without regex fragility.

diet query "function $NAME($$$ARGS) { $$$BODY }" src/
  • -l, --lang <language>: Language filter (typescript, javascript, python, go, rust, java, csharp, cpp).
  • -m, --max-results <number>: Maximum matching nodes to return (default: 20).

11. diet pack [target_path]

Packs project into a zero-body architecture skeleton for instant AI cold-start onboarding (Repomix & PageRank Repo-Map pattern).

# Output XML skeleton to stdout or file
diet pack src/ -f xml -o architecture-skeleton.xml
  • -f, --format <format>: Output format (xml or markdown, default: xml).
  • -o, --output <file>: Output file path (default: stdout).
  • -m, --max-tokens <number>: Upper limit on skeleton tokens (default: 20000).
  • --budget <number>: Target token budget for PageRank graph selection.

12. diet memory [action] [args...] (2-Tier Atomic Memory)

Manages long-term project architectural decisions, conventions, and constraints with a 2-Tier memory architecture (inspired by Mem0 & Letta).

# Record an architectural decision (atomic fact)
diet memory add "Use SQLite for Journal" "Avoid JSON files for write-heavy telemetry" -c architecture -t "db,perf"

# Search and recall decisions by keyword
diet memory recall "SQLite"

# Generate dense prompt decision capsule for AI prompt prefix (optional query filter)
diet memory prompt
diet memory prompt "SQLite"

# List all recorded decisions
diet memory list
  • -c, --category <category>: Category (architecture, convention, constraint, decision).
  • -t, --tags <tags>: Comma-separated tags.
  • Session Reset Protocol: On task/topic switch, record critical facts with diet memory add, reset the chat session (/clear or new chat), and restore only 1~3 targeted facts with diet memory recall. This limits turn accumulation and reduces how often /compact is needed (it complements /compact, it does not replace it).

13. diet subagent [action] [sub_agent_id] 🔒 (Pro)

Manages partitioned working-set contexts for concurrent sub-agents, preventing noise contamination and distilling ultra-compact handoff diff capsules.

# Initialize partitioned sub-agent session
diet subagent create worker-1 -p root-session

# Inspect active sub-agent sessions
diet subagent list

# Distill handoff XML diff summary (< 300 tokens)
diet subagent handoff worker-1

# Complete session and merge file changes to parent cache
diet subagent complete worker-1 --merge
  • -p, --parent-id <id>: Parent session or agent identifier.
  • --merge: Merge sub-agent file changes back to parent context working-set cache upon completion.

14. diet server (or diet serve, diet mcp)

Launches the Context-Diet MCP server directly in stdio mode.

15. diet clean

Removes injected AI guidelines and resets rule files.

16. diet activate <key> [options]

Activates Context-Diet Pro license with Gumroad online validation or offline signature.

# Online activation with automatic IDE MCP registration
diet activate YOUR-LICENSE-KEY --install-all

# Offline cryptographic activation
diet activate YOUR-LICENSE-KEY --offline
  • -e, --email <email>: Associate license with your purchase email.
  • --offline: Skip online server validation and use offline cryptographic check.
  • --install-all: Automatically register MCP server into all detected IDEs upon successful activation.

17. diet license [options]

Displays active license tier, machine instance ID, and status.

diet license
diet license --deactivate
  • --deactivate: Deactivates and unbinds active license from current machine and reverts to Community Edition.

18. diet check [path] [options] (alias: guard)

Audits project for AI context health (oversized files, high-volume barrel files, giant data files) to prevent context pollution in CI/CD.

# Audit current repository
diet check

# Enforce strict CI threshold
diet check --ci --min-score 85

# Output machine-readable JSON
diet check --json
  • --max-lines <number>: Maximum recommended lines per source file (default: 500).
  • --min-score <number>: Minimum passing health score (default: 80).
  • --ci: Exit with code 1 if health score fails threshold (for GitHub Actions / CI).
  • --json: Output results in structured JSON format.

19. diet ui [options]

Launches the embedded real-time Web Dashboard and token analytics server with instant browser launch.

# Launch dashboard on default port (3333) and open browser
diet ui

# Custom port or host without auto-opening browser
diet ui --port 8080 --host 0.0.0.0 --no-open
  • -p, --port <number>: Port to listen on (default: 3333, automatically falls back up to 3343 if occupied).
  • -h, --host <host>: Host address to bind (default: 127.0.0.1).
  • --no-open: Do not automatically open the browser on launch.

Dashboard Highlights:

  • Real-time KPI Metrics: Live cumulative tokens saved, dollar cost savings ($), folded lines, and compression efficiency rate.
  • Active AI Context Working-Set Cache: Inspect active deduplicated file sessions, hit ratios (X / 8), last referenced timestamps, and Myers delta diff statuses.
  • Telemetry & Operations Journal: Live event stream with instant text filter for file paths, commands, and queries.
  • Modern Custom Pagination: 25 rows per page default with custom dark glassmorphism popover dropdown (10, 25, 50, 100, All) and page navigation buttons.
  • Interactive SVG Time-Series Chart: Visualizes token compression trends with interactive hover tooltips.
  • In-App License Management: Activate and deactivate Pro Lifetime licenses with zero terminal hassle.

🧠 Core Capabilities (Multi-Tier Optimization)

  1. Tier 1: AST Code Diet (Tree-sitter WASM)
    • Semantic folding for TypeScript, JavaScript, Python, Go, Rust, Java, C#, and C++.
    • Types-Only Mode (-t) & Virtual Type Bundler (-b) preserving multi-line types and signatures.
  2. Tier 2: Predictive Computation Cache (SmartCacheEngine)
    • High-throughput AST caching with LRU eviction and background module import warmup.
  3. Tier 3: Universal AI Context Working-Set Cache with Disk Persistence
    • Multi-turn deduplication replacing already-read files with 35-token pointers (99% savings).
    • Session Delta Diff: sends compact unified diffs (@@ ... @@) using Myers diff algorithm.
    • 3-Way Guardrails: 1,000 LRU entries, 1-hour inactivity TTL, and 8-hit safe re-sync.
  4. Tier 4: RTK Terminal Log Distiller (diet_exec)
    • Captures verbose terminal logs (tests, builds, lints, git, docker, cargo, dotnet) with 12 specialized profiles and repeated line (×N) folding (95% log reduction).
  5. Tier 5: Architecture Skeleton Packer (diet pack / Repomix & PageRank Repo-Map)
    • Zero-body architecture skeleton bundler for instant AI onboarding with up to 98% token reduction.
    • PageRank dependency graph centrality ranking prioritizing entry points and core type hubs.
  6. Tier 6: Data Leak Guard & Secret Masking (SecretSanitizer)
    • Real-time Gitleaks pattern matching (20+ sensitive credential formats) auto-redacting secrets in file reads and execution outputs.
  7. Tier 7: 2-Tier Atomic Decision Memory & Session Reset (diet memory & diet_memory)
    • Atomic facts extraction & persistent storage (.context-diet/decisions.json) inspired by Mem0 & Letta.
    • Targeted prompt capsules (50~150 tokens) eliminating full-history turn bloat.
    • Topic-switching session reset protocol with working state (diet_memory action state) re-injected by a SessionStart hook after /compact or /clear, so compaction keeps the thread. It complements /compact; it does not replace it.
  8. Tier 8: Native Hybrid Accelerated Search (HybridSearchEngine)
    • Native Rust rg / fd subprocess acceleration (<10ms query times) with pure Node.js fallback.
  9. Tier 9: Dynamic MCP Tool Gating (DynamicToolGatingEngine)
    • Profile-based tool schema filtering (CONTEXT_DIET_TOOL_PROFILE=minimal|core|code|debug|full, default core) cutting 40%~60% fixed schema tokens (800~1,500 tokens/turn).
  10. Tier 10: Bundle AST Skimmer & ASAR Reader (BundleAstSkimmer, AsarReader)
    • Single-line minified bundle & Electron .asar AST skimmer extracting signatures and SourceMaps without exploding context (95%~99% savings).
  11. Tier 11: Call Graph & IPC Tracer (CallGraphEngine, IpcTracer)
    • High-precision caller/callee trees and Electron IPC / API routing without source body bloat (70%~85% savings).
  12. Tier 12: Evidence v2 Protocol (EvidenceProtocolAdapter)
    • Structured evidence metadata ([EVIDENCE], [LIMITATION], [RECOVERED_GRAPH]) eliminating hallucinated logic and reducing retry loops by 50%.

Additional Guardrails & Ergonomics:

  • Headroom CCR Reversible Storage (diet_expand): Distilled raw terminal logs are safely stashed in .context-diet/raw_logs/ and accessible via ref:<id>.
  • Negative Compression Guard (NegativeCompressionGuard): Guarantees zero token bloat by automatically falling back to lossless raw content if compression ratio is unfavorable.
  • Transparent Execution Rewriter (TransparentExecutionRewriter): Intercepts shell execution commands and transparently filters high-noise outputs.
  • Sub-Agent Context Isolation & Distillation Adapter (SubAgentAdapter): Partitions sub-agent working sets and distills handoff summaries to prevent main context contamination.
  • Real-Time Web Dashboard (diet ui): Zero-dependency embedded dashboard with SVG time-series analytics, interactive pagination, and in-app Pro licensing.

📊 Performance Benchmarks (Full Ultra-Lean vs Standard Agent)

Estimates, not measurements. Prompt caching bills cached input at ~10% of the base price, so cost savings are smaller than token savings. Measure on your own tasks with npm run bench (A/B harness in bench/; runs are billed).

| Metric | Standard AI Agent | Context-Diet v1.3.2 (Full Ultra-Lean) | | :--- | :--- | :--- | | Avg Input Tokens / Turn | 20,000 ~ 70,000+ | 800 ~ 2,200 (Up to 96% off) | | Avg Output Tokens / Turn| 800 ~ 1,500 | 50 ~ 150 (Up to 90% off) | | Total Cumulative Tokens | 400,000 ~ 1,200,000+| 15,000 ~ 35,000 (95%~97.5% off) | | Est. Cost / Session | $3.00 ~ $8.00 | $0.05 ~ $0.15 (90%~96% savings) | | Response Latency | Baseline | 60% ~ 75% faster | | Working Memory Cap | Unbounded Bloat | Capped stably under 10k tokens |

🚀 Pro Features Impact (Virtual Type Bundler & Sub-Agent Isolation)

| Metric / Benchmark Scenario | Free / Community Tier | Context-Diet Pro (Bundler & Isolation) | Pro Performance Impact | | :--- | :--- | :--- | :--- | | Round-trip Count (Type Inspection) | 3 ~ 5 iterative reads (RTT Overhead) | 0 trips (Zero-RTT AST Inlining) | -100% Round-trip file exploration eliminated | | Additional Token Savings (Cross-Module) | Baseline compression (~1,500~3,000 tok) | Auto-inlined virtual signatures at footer | +38% additional token savings | | Mission Success Rate | 68% (Type mismatch / hallucination risk) | 91% verified completion | +34% mission success boost | | Sub-Agent Context Isolation | Terminal / test noise leaks to parent | Root-level partitioning & summary distiller | 95% context pollution prevented | | Multi-Agent Subtask Completion Rate | Frequent context overflow errors | Ultra-compressed handoff diff merge | +42% subtask completion boost |


📦 MCP Tools for Agents

| Tool | Status | Parameters | Description | | :--- | :--- | :--- | :--- | | diet_read | Active | path, symbol, intent, startLine, endLine, typesOnly, bundleTypes, force, delta, ref, verbose | Primary intelligent reader with AST folding, predictive cache, Myers delta diffs, and secret masking. | | diet_exec | Active | command, cwd, verbose | Execute shell commands with RTK noise filtering, log distillation, and CCR ref ID generation. | | diet_expand | Active | symbol, path, xref, ipc, ref, startLine, endLine | Traces function Call Graphs (Callers/Callees), cross-references (XREF), Electron IPC channels & API routes, or restores raw CCR logs. | | diet_tree | Active | path, depth | Token-optimized project directory tree. | | diet_query | Active | pattern, targetPath, lang, maxResults | AST structural pattern matching across files (ast-grep pattern). | | diet_pack | Active | targetPath, format, maxTokens, budget | Pack codebase into zero-body architecture skeleton for cold starts with PageRank RepoMap. | | diet_memory | Active | action, title, detail, category, tags, query | Manage architectural decisions, conventions, and targeted prompt capsules. |

Note: Telemetry, diagnostic audits, and search are available directly via the CLI (diet stats, diet audit, diet search) and the real-time Web Dashboard (diet ui) to keep MCP prompt schemas lean.


🩺 System Diagnostics & Resilient Fallback

  • Graceful Fallback (FallbackJournal): If native better-sqlite3 fails to compile or load due to Node ABI mismatches, Context-Diet automatically falls back to pure JSON storage (.context-diet/journal.json). Operations never crash.
  • TTY Deadlock Guard: When invoked by background MCP daemons without an interactive terminal (!process.stdin.isTTY), prompts are automatically bypassed to prevent deadlocks.
  • Isolated Repair: Dependency repairs use the detected package manager (bun, pnpm, yarn, npm) without modifying user workspace dependencies.
  • ContextGuard & Lifecycle Interceptor: Hardware/hook-level prevention of raw terminal dumps and oversized (>100 lines) file reads.
  • Execution Environment Sanitization: Subprocess execution in diet_exec strips parent IDE environment variables (VSCODE_*) to ensure clean CLI runner execution.
  • Lossless Rollback & Negative Compression Guard: Prevents context inflation by falling back to raw output when compression ratio is negative.
  • Real-time Secret Masking: Prevents confidential tokens and credentials from leaking into agent prompt contexts.

🏗 Development & Testing

# Install dependencies & fetch WASM grammars
npm run setup

# Build TypeScript
npm run build

# Run Vitest test suite (30 test files, 268 tests, 100% pass)
npm test

# Launch Web Dashboard locally
npm run ui

# Bundle & Obfuscate (Phase 1)
npm run build:bundle

# Package standalone native binaries (Phase 2)
npm run build:binary

# Build complete multi-OS distribution bundles (Windows, macOS, Linux, NPM)
npm run build:releases

📄 License

Distributed under the Functional Source License, Version 1.1, MIT Future License (FSL-1.1-MIT). See LICENSE for more information.

Copyright © 2024-2026 Context-Diet Contributors