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

@forgememo-cli/aicap

v0.1.0

Published

Memory-cap any command (AI coding agents, builds, background jobs) on macOS/Linux — real enforcement via Docker cgroups or a polling watchdog, since macOS has no working per-process memory rlimit.

Readme

aicap

Memory-cap any command — AI coding agents, builds, background jobs — on macOS/Linux.

Why

macOS has no working per-process memory limit in userspace. Verified empirically:

  • setrlimit(RLIMIT_AS, ...), RLIMIT_DATA, RLIMIT_RSS all return EINVAL on modern macOS — the kernel rejects them outright, ulimit -v included.
  • launchd's own HardResourceLimits.ResidentSetSize is a no-op — a job capped at 100MB was observed running past 590MB, still state = active.

So a runaway process — a leaking build tool, an AI agent that gets stuck in a loop, a stray find / — has nothing standing between it and system OOM on macOS. aicap fills that gap with the two mechanisms that actually work.

What it does

aicap --limit <mb> -- <command> [args...]

Two backends, auto-selected:

  1. Docker cgroup (--memory) — used when Docker is installed and running. Hard cap, real kernel enforcement, zero race window.
  2. Polling watchdog (ps RSS + SIGKILL) — fallback when Docker isn't available. No dependencies, works anywhere ps exists. Has a small race window bounded by --interval (default 200ms) — a process can spike briefly past the cap between polls before being killed.

Both are honest about their mechanism: neither claims kernel-enforced rlimit, because that doesn't exist on macOS for arbitrary processes.

Install

npm install -g aicap

or clone and symlink bin/aicap onto your PATH.

Usage

# cap a build at 2GB
aicap --limit 2048 -- npm run build

# cap an AI coding agent run at 512MB
aicap --limit 512 -- claude -p "refactor this module"

# force the watchdog even if Docker is available
aicap --limit 1024 --force-watchdog -- ./some-script.sh

# use a different docker image for the docker backend (default: node:22-slim)
aicap --limit 4096 --image python:3.12-slim -- python train.py

Env var overrides: AICAP_LIMIT_MB, AICAP_IMAGE, AICAP_INTERVAL.

On cap breach, aicap kills the process and exits 137 (same convention as Docker's own OOM-kill exit code).

Limitations

  • Docker backend mounts $PWD into the container at /work and runs there — paths outside $PWD aren't visible to the command.
  • Watchdog backend has a real (if small) race window; for a hard guarantee, use the Docker backend.
  • Neither backend can cap a process that immediately forks and hides children under a different watched PID tree in unusual ways — the watchdog only tracks the direct child.

License

MIT