Opt-in npm-compatible registry that rewrites broken dependencies to your fork when the light computer internet lights say CI is dark.
Live status: https://patch-cloud-production.up.railway.app/status
Opt in to the live registry for one install:
npm install <pkg> --registry https://patch-cloud-production.up.railway.appor for a whole project, add registry=https://patch-cloud-production.up.railway.app/ to .npmrc. Remove it to opt out.
pnpm users can opt in with the pnpm plugin instead (not on npm yet): pnpm add --config pnpm-plugin-patch-cloud. It only swaps packages whose light is dark and that have a fork ready, and installs normally if patch-cloud can't be reached.
Not committed here: the ~44 MB annotated next tarball (rebuild with npm run pack:next) and local-lights.json (copy local-lights.example.json to force the demo light dark).
Nothing is published to the public npm registry by this project. Fork / annotated tarballs live under tarballs/.
/status in a browser is a public dark lights board:
- Dark now: tracked packages whose upstream build is red, with days dark (from the first red run after the last passing one; "≥" when no passing run is in the 30 runs checked), whether a patch-cloud fork is served, and the one-line opt-in install when it is.
- Merged fixes: near the top of
/status(JSON:merged), upstream PRs merged by their maintainers that took a dark light to lit upstream: repo, PR link, title, merged date (ET), merged by, what was dark before, and that it's lit upstream now. Each entry says what happened: Before (which upstream light was dark, since when, why, plus a dark upstream run before the merge), Fix (one sentence) and After (the first upstream run after the merge and how many of the light's jobs are lit; "waiting for upstream light" until it is). Data lives inmerged.json; add one withnode add-merged.mjs owner/repo N --light "job name" --dark "why" --dark-since ISO --fix "what changed" [--dark-run URL] [--lit-run URL](no deps; usesgh api, refuses unmerged PRs, dedupes by repo + PR, auto-detects the runs on the default branch when the URLs are omitted), then redeploy. Same list as lit-dark. - Watchlist: popular packages with dark CI from the npmmirror scan (
watchlist.json, built bynode build-watchlist.mjsfrom/workspace/mirror/dig.json+notes.json), with repo link, red run, why the build is red, fixability, and "no patch-cloud fork yet". It's a snapshot with day counts as of the scan; it isn't refreshed live. - All tracked lights: the full table as before.
JSON (/status?format=json) adds packages[].dark, packages[].install, packages[].npmWeeklyDownloads, and a top-level watchlist. "Dark" always means the upstream CI didn't pass. Installs from npm still work.
node seed-lights.mjs refreshes the bundled lights.json (with darkSince) before a deploy.
light-programs reads this repo's lights.json, mapping.json and watchlist.json (plus the light computer's state.json) and prints suggested actions in plain words, such as the opt-in install line for a dark package with a ready fork. It's read-only, offline and suggest-only: node cli.mjs --patch-cloud ../patch-cloud.
- The light computer fetches CI status for public repos into
lights.json(● lit = upstream build passing, ○ dark = upstream build failing; active-low). The registry tracks the light computer's 8 repos plus every GitHub repo inmapping.json, refreshed live. - You point
npm installat this registry (explicit--registryor project.npmrc). - For a mapped package whose light is dark and
rewriteReady, the registry serves your fork / annotated tarball under the same package name. - When the light is lit, it serves local upstream (demo) or proxies to
registry.npmjs.org— unless the package carries the labeledmanual: fix availableswitch (below). - Only the fork's version is replaced: the rest of the upstream packument (other versions, dist-tags) is merged in, so ranges like
[email protected]orajv@^8keep resolving to upstream. - Unmapped packages (including scoped
@scope/name) are always proxied.
npm install <pkg> --registry http://127.0.0.1:4873Or a project .npmrc:
registry=http://127.0.0.1:4873/
After you pick a host, replace with https://<your-host>/. See DEPLOY.md.
- Opt-in only — never the default registry.
- Only packages in
mapping.jsonwithrewriteReady: trueare rewritten, and only while their light is dark. - Registry is read-only (PUT/POST/DELETE → 405).
- Check
/statusor open/for the landing page. - Opt out: remove the
registry=override and reinstall fromregistry.npmjs.org. - Lockfiles: rewritten tarballs have different
integrityhashes. Existingpackage-lock.json/npm ciwill fail until you regenerate the lock while opted in (or opt out and use upstream).
# Terminal 1
node server.mjs
# or: npm start
curl -s http://127.0.0.1:4873/health
open http://127.0.0.1:4873/ # landing
curl -s http://127.0.0.1:4873/status | jq .Forces both light states on demand (local/broken-demo). See the public light specification and proof in fitzyracing1/lit-dark (active-low: lit = 0, dark = 1).
node flip-light.mjs dark
npm install broken-demo --registry http://127.0.0.1:4873
node -e "console.log(require('broken-demo'))" # fork
node flip-light.mjs lit
rm -rf node_modules/broken-demo package-lock.json
npm install broken-demo --registry http://127.0.0.1:4873
# upstream throws on requireThe Next.js patch (PR #100001, branch rspack-manifest-fix) changes test manifests only. A rebuilt next would match upstream runtime for the same version, so we do not build the monorepo.
Instead, when vercel/next.js is dark, patch-cloud serves an annotated upstream [email protected] tarball:
PATCH-CLOUD.mdinside the packagepackage.json#_patchCloud→{ fork, branch, pr, … }
When the light is lit, requests for next are proxied to the public registry.
npm install next --registry http://127.0.0.1:4873
# then: ls node_modules/next/PATCH-CLOUD.mdRepack / refresh the annotated tarball:
node pack-annotated.mjs next \
--fork fitzyracing1/next.js \
--branch rspack-manifest-fix \
--pr https://github.com/vercel/next.js/pull/100001 \
--version 16.4.0| Light repo | npm name | Rewrite |
|---|---|---|
local/broken-demo |
broken-demo |
dark→fork, lit→local upstream |
vercel/next.js |
next |
dark→annotated upstream tarball, lit→proxy |
react/react |
react |
dark→annotated upstream [email protected] (fork fitzyracing1/react, no code changes yet), lit→proxy |
ZJONSSON/node-unzipper |
[email protected] |
dark→fork: PR #331, @aws-sdk/client-s3 moved to dependencies |
jimp-dev/jimp |
[email protected] |
dark→fork: real browser bundle instead of the published stub (#1402) |
vercel/ms |
[email protected] |
dark→fork: format/parse round-trip (port of #299) + decimal option (#125) |
prebuild/prebuild-install |
[email protected] |
dark→fork: tar-fs ^2.1.4 (CVE-2025-59343, PR #214) |
cli-table/cli-table3 |
[email protected] |
dark→fork: rowSpan crash fix (PR #359) |
iamkun/dayjs |
[email protected] |
light lit → served via manual: fix available (fork: tz perf, port of PR #2019) |
ajv-validator/ajv |
ajv |
not rewritten (rewriteReady: false): PR #2591's ReDoS could not be reproduced; corrected branch on the fork for review |
| deno / node / vscode / rust / cpython / fakegreen | — | not npm rewrite targets (see ciPatch on some) |
Each fork tarball keeps the upstream package name and version and adds PATCH-CLOUD.md plus package.json#_patchCloud describing exactly what changed. Built with node annotate-fork.mjs <checkout> fork-specs/<pkg>.json then npm pack. Focused repros live in repros/.
Manual switch: manual: fix available (#1)
Some fixes are real but CI can't see them (e.g. a performance bug). Faking a dark light would be dishonest, so a mapping entry can carry a clearly labeled override instead:
"iamkun/dayjs": {
"npmName": "dayjs", "version": "1.11.23", "rewriteReady": true,
"forkTarball": "tarballs/dayjs-1.11.23.tgz",
"manualRewrite": { "reason": "Upstream CI is green but the perf fix (PR #2019) is unmerged", "since": "2026-10-11" }
}- Serves the fork while the light is lit; the light keeps its real CI conclusion and is never changed.
- Needs
rewriteReady: trueand areason. If the light goes dark, the normal dark rewrite applies. /statusshowsrewrite: "manual", amanualobject (label: "manual: fix available", reason, since) and counts it separately (counts.manual); HTML shows Fork available (manual: fix waiting upstream).- Responses carry
X-Patch-Cloud: manualand_patchCloud.source: "manual"; tarballs are counted underdownloads.manual, notfork.
The primary label says what an installer gets; the upstream CI result is a small secondary line linking to the run:
| Situation | Primary label | Secondary |
|---|---|---|
| light dark + fork packaged | Fork available — download via patch-cloud | upstream build: failing |
| manual switch | Fork available (manual: fix waiting upstream) | upstream build: passing |
| light dark, no fork | Upstream build failing — no fork yet | upstream build: failing |
| light lit | Upstream OK — normal npm | upstream build: passing |
| Env | Default | Purpose |
|---|---|---|
PORT / PATCH_CLOUD_PORT |
4873 |
Listen port |
HOST / PATCH_CLOUD_HOST |
127.0.0.1 |
Bind address (0.0.0.0 in Docker) |
PUBLIC_URL |
(empty) | Absolute base for dist.tarball URLs |
LIGHTS_FILE |
greenlight or ./lights.json |
Lights snapshot |
LIGHTS_CACHE_MINUTES |
5 |
Cache TTL |
LIGHTS_REFRESH |
off | 1 = refresh from GitHub when cache expires |
GITHUB_TOKEN |
— | Optional for API rate limits (recommended: 15 repos are tracked) |
LIGHTS_REFRESH_MINUTES |
cache minutes with token, 20 without |
Min interval between GitHub lights refreshes; failed fetches keep the last known light |
UPSTREAM_REFRESH_MINUTES |
10 with token, 60 without |
Min interval between upstream PR/issue state checks |
PACKUMENT_CACHE_MINUTES |
5 |
Cache for upstream packuments merged into rewrites |
RATE_LIMIT_PER_MIN |
120 |
Per-IP; 0 = off |
node test-server.mjsStarts the server on a random port and checks dark/lit rewrite, proxy (incl. scoped), PUT rejection, every patch-cloud target (fork version merged into the upstream packument, deps from the fork tarball, PATCH-CLOUD.md), the manual switch, and the status wording.
Live on Railway: https://patch-cloud-production.up.railway.app (railway up from this directory; .railwayignore keeps fork checkouts out of the upload). See DEPLOY.md for other hosts.
Silently replacing popular packages in a production registry that people hit by accident would be wrong. This tool is opt-in, read-only, and documents every rewrite on / and /status.
| Path | Role |
|---|---|
server.mjs |
Registry (no npm deps) |
config.mjs |
Env-driven config |
mapping.json |
lightRepo → npm / tarballs / ciPatch / manualRewrite |
annotate-fork.mjs |
Adds PATCH-CLOUD.md + _patchCloud to a fork checkout before npm pack |
fork-specs/ |
Per-package change/verification descriptions used for PATCH-CLOUD.md |
repros/ |
Focused repros run against installed copies (unzipper, ms, cli-table3, dayjs, jimp, prebuild-install, ajv) |
pack-annotated.mjs |
Download upstream + annotate + repack |
test-server.mjs |
Integration tests |
Dockerfile |
Container image |
DEPLOY.md |
Host options (no accounts created) |
tarballs/ |
Served .tgz files |
lights.json |
Bundled snapshot for deploy |
This project is free, and its license stays as is. Support it through GitHub Sponsors:
- Free: use the code, community support.
- Pro ($49/month): priority issues and support.
- Team ($199/month): priority support for your team plus early access.