r/npm • • 11h ago

Self Promotion contextpack-cli: zero-dependency CLI that packs a repo into a token-budgeted prompt for LLMs

1 Upvotes

I published contextpack-cli recently. It solves a problem I kept hitting: pasting a repo into an LLM one file at a time and blowing the context window on node_modules and lockfiles.

npm: https://www.npmjs.com/package/contextpack-cli Source: https://github.com/fadiuniv1/contextpack

Run it with `npx contextpack-cli . -o context.md`

It respects nested .gitignore and .ignore files, ranks source code above tests, redacts common secret formats, and supports --task, --diff, --profile and JSON output. Zero runtime dependencies, MIT licensed.

Honest caveat: token counts are local estimates (~±15%), not exact tokenizer counts. Feedback welcome.


r/npm • • 14h ago

Self Promotion Built a lightweight Node.js (ESM) MCP server & CLI that maps repo import topology and git hotspots so AI coding agents stop reading 20+ files blindly

1 Upvotes

I built project-context-map-mcp (MIT, Node.js >=20, pure ESM with u/modelcontextprotocol/sdk as the only runtime dependency).

Why I built it

When using AI coding agents (Claude Code, Cursor, VS Code Copilot) on medium/large Node.js repos, they usually start by walking directories and reading 15–25 files just to trace imports and recent changes—burning tokens and context before editing anything.

I wanted a lightweight, zero-config indexer that turns a repo into a structured map (.project.md, .project-map.json, .project-map.md) so the agent queries topology first and only reads the relevant files.

How it works under the hood

  • File & Module Indexing: Walks the repo (skipping node_modules, dist, build, .git, etc.), infers modules/roles/tags, and detects stack/entrypoints (package.json, frameworks).
  • Import Topology Graph: Extracts ES import/export ... from, dynamic import(), CommonJS require(), and Python imports into dependencies and usedBy adjacency lists + a Mermaid diagram in .project.md.
  • Git Hotspot Signal: Uses git log via execFileSync to track recently modified files and commit reasons, boosting them in task-relevance ranking.
  • MCP Server (StdioServerTransport): Exposes 10 tools (get_project_summary, query_topology, find_relevant_files, read_files_sparse, get_module_context, explain_file_role, get_recent_git_changes, write_and_log, refresh_project_map, read_project_context).
  • Safety & Testing: Enforces lexical + realpathSync symlink-traversal checks on read_files_sparse and write_and_log, validates tool args, and tests the MCP handlers end-to-end with InMemoryTransport in Jest (--experimental-vm-modules).

Try it with npx

Run a one-off map refresh in any Node repo:

bashnpx -y project-context-map-mcp refresh --project-root .

Or add it to your MCP client config:

{
  "mcpServers": {
    "project-context-map": {
      "command": "npx",
      "args": ["-y", "project-context-map-mcp", "serve", "--project-root", "."]
    }
  }
}

Feedback from Node/TS folks is very welcome—especially around supporting tsconfig.json path aliases (@/...) or monorepo workspaces (pnpm-workspace.yaml / npm workspaces) in the topology resolver!


r/npm • • 17h ago

Self Promotion Built an open-source MCP server (Shanaxon) that compresses repo context with AST + PageRank, skips optimization when it isn't cost-effective, and lets agents recover exact source files on demand

Thumbnail
reddit.com
1 Upvotes