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

engrain

v1.1.0

Published

Embed documentation indexes into agent context. Clone docs, generate compact indexes, inject into AGENTS.md as always-on passive context.

Readme

engrain

Index documentation into always-on agent context

Status: ✅ V1 complete (core CLI). Polishing docs + UX.

What is engrain?

engrain clones documentation repositories, generates deterministic directory indexes, and injects them into AGENTS.md (or .ENGRAIN) as always-on context.

Concept

  • Problem: On-demand retrieval (skills/tools) often isn’t invoked
  • Solution: Embed a compact docs index into AGENTS.md as passive context
  • Result: Passive context beats active retrieval

Inspiration

Based on Vercel's approach where an 8KB compressed docs index in AGENTS.md achieved 100% pass rate vs 79% for traditional skills.

Usage

# Clone docs, index, and inject into AGENTS.md
npx engrain docs <repository-url>

# Check if installed docs are stale
npx engrain check [doc-name]

Telemetry

engrain collects anonymous usage telemetry to help improve the tool. No personally identifiable information (PII) is collected—only command usage patterns, repository sources, and index sizes.

Opt-out: Set either environment variable to disable telemetry:

Dev mode: Set ENGRAIN_DEV=1 to explicitly mark environment as development (otherwise auto-detected from /src/ path or NODE_ENV=development).

Telemetry is fire-and-forget and never blocks CLI execution. See _workstream/TELEMETRY_PLAN.md for details.

Architecture

Tech stack

  • Runtime: Bun for dev, Node.js for the distributed bundle
  • Language: TypeScript
  • CLI: Node’s parseArgs
  • Git: simple-git (shallow clone + ls-remote for staleness)
  • Index sizing: tokenx (bytes + token estimate)
  • Output: injected into AGENTS.md via semantic <docs name="..."> blocks

Module layout

src/
├── engrain.ts              # CLI entry point
├── commands/
│   ├── docs.ts             # parse → clone → copy → index → inject → lock
│   └── check.ts            # read lock → fetch latest hash → compare
├── indexer/
│   ├── discover.ts         # recursive discovery w/ negative filtering
│   ├── generate.ts         # deterministic pipe-delimited index
│   └── size.ts             # bytes + tokens
├── injector/
│   ├── inject.ts           # <docs name="..."> injection into output file
│   └── lock.ts             # global lock file (~/.engrain/.engrain-lock.json)
└── utils/
    ├── source-parser.ts    # GitHub/GitLab/local URL parsing
    ├── git.ts              # shallow clone + cleanup + ls-remote
    ├── sanitize.ts         # sanitizeName/isPathSafe
    └── auth.ts             # token helpers (optional)

Data layout

  • Local docs: ./engrain/<doc-id>/...
  • Injected index: AGENTS.md (or .ENGRAIN via --output)
  • Global lock: ~/.engrain/.engrain-lock.json keyed by process.cwd()

Key ADRs (design decisions)

  1. Passive docs index in AGENTS.md
    • Rationale: passive context is always available; avoids “agent forgot to invoke tool/skill”.
  2. Pipe-delimited, single-line index format
    • Rationale: compact + proven effective; easy to scan for path/file names.
  3. Deterministic index generation
    • Rationale: stable diffs and idempotent re-runs (sort dirs/files alphabetically).
  4. Negative filtering for discovery
    • Rationale: exclude obvious non-doc artifacts (images/binaries/archives) without missing valid docs formats.
  5. Shallow clone + strict cleanup
    • Rationale: fast clones (--depth 1) and no temp-dir orphans (try/finally cleanup).
  6. Idempotent injection markers
    • Rationale: safe updates via <docs name="id">...</docs> + --force.
  7. Global lock file for staleness checks
    • Rationale: track commit hash + sizes per project and enable engrain check.

Development

bun install
bun run dev docs --help
bun run build

License

MIT