patch-cloud
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.app
or 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/.
Dark lights board (/status)
/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 in merged.json; add one with node 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; uses gh 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 by node build-watchlist.mjs from /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
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.
Idea
- 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 in mapping.json, refreshed live.
- You point
npm install at this registry (explicit --registry or 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 labeled manual: fix available switch (below).
- Only the fork's version is replaced: the rest of the upstream packument (other versions, dist-tags) is merged in, so ranges like
ms@2.0.0 or ajv@^8 keep resolving to upstream.
- Unmapped packages (including scoped
@scope/name) are always proxied.
Opt in (one-liner)
npm install <pkg> --registry http://127.0.0.1:4873
Or a project .npmrc:
registry=http://127.0.0.1:4873/
After you pick a host, replace with https://<your-host>/. See DEPLOY.md.
Safety
- Opt-in only — never the default registry.
- Only packages in
mapping.json with rewriteReady: true are rewritten, and only while their light is dark.
- Registry is read-only (PUT/POST/DELETE → 405).
- Check
/status or open / for the landing page.
- Opt out: remove the
registry= override and reinstall from registry.npmjs.org.
- Lockfiles: rewritten tarballs have different
integrity hashes. Existing package-lock.json / npm ci will fail until you regenerate the lock while opted in (or opt out and use upstream).
Quick start (local)
# 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 .
Demo: broken-demo
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 require
Annotated next (CI-only fork)
The 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 next@16.4.0 tarball:
PATCH-CLOUD.md inside the package
package.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.md
Repack / 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
Mapping (npm rewrite targets)
| 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 react@19.3.0 (fork fitzyracing1/react, no code changes yet), lit→proxy |
ZJONSSON/node-unzipper |
unzipper@0.12.5 |
dark→fork: PR #331, @aws-sdk/client-s3 moved to dependencies |
jimp-dev/jimp |
jimp@1.6.1 |
dark→fork: real browser bundle instead of the published stub (#1402) |
vercel/ms |
ms@2.1.3 |
dark→fork: format/parse round-trip (port of #299) + decimal option (#125) |
prebuild/prebuild-install |
prebuild-install@7.1.3 |
dark→fork: tar-fs ^2.1.4 (CVE-2025-59343, PR #214) |
cli-table/cli-table3 |
cli-table3@0.6.5 |
dark→fork: rowSpan crash fix (PR #359) |
iamkun/dayjs |
dayjs@1.11.23 |
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: true and a reason. If the light goes dark, the normal dark rewrite applies.
/status shows rewrite: "manual", a manual object (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: manual and _patchCloud.source: "manual"; tarballs are counted under downloads.manual, not fork.
Status wording
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 |
Config (env)
| Env |
Default |
Purpose |
PORT / PATCH_CLOUD_PORT |
4873 |
Listen port |