github-router 0.3.379 → 0.3.381

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (165) hide show
  1. package/README.md +62 -0
  2. package/dist/ado-tools-CsfbnY8x.js +1 -0
  3. package/dist/{aic-ledger-CeSXqTEE.js → aic-ledger-6GKI28nY.js} +3 -3
  4. package/dist/{aic-ledger-CeSXqTEE.js.map → aic-ledger-6GKI28nY.js.map} +1 -1
  5. package/dist/{aic-statusline-settings-BKveu679.js → aic-statusline-settings-wLL1l_Z6.js} +2 -2
  6. package/dist/{aic-statusline-settings-BKveu679.js.map → aic-statusline-settings-wLL1l_Z6.js.map} +1 -1
  7. package/dist/atomic-file-Dif1kLKM.js +198 -0
  8. package/dist/atomic-file-Dif1kLKM.js.map +1 -0
  9. package/dist/{attribution-settings-BWYL2b8N.js → attribution-settings-BEwSkdhK.js} +10 -10
  10. package/dist/{attribution-settings-BWYL2b8N.js.map → attribution-settings-BEwSkdhK.js.map} +1 -1
  11. package/dist/{auth-BZHpTtfF.js → auth-5TKcQbbH.js} +3 -3
  12. package/dist/{auth-BZHpTtfF.js.map → auth-5TKcQbbH.js.map} +1 -1
  13. package/dist/bin.js +1479 -0
  14. package/dist/bin.js.map +1 -0
  15. package/dist/browser-ext/manifest.json +1 -1
  16. package/dist/{check-usage-BlIWDuV2.js → check-usage-DM39fdel.js} +4 -4
  17. package/dist/{check-usage-BlIWDuV2.js.map → check-usage-DM39fdel.js.map} +1 -1
  18. package/dist/{claude-CSuIdaLV.js → claude-CkrhHkPQ.js} +26 -25
  19. package/dist/{claude-CSuIdaLV.js.map → claude-CkrhHkPQ.js.map} +1 -1
  20. package/dist/{claude-md-injection-Biq_Xhve.js → claude-md-injection-DNMDcw1W.js} +15 -24
  21. package/dist/claude-md-injection-DNMDcw1W.js.map +1 -0
  22. package/dist/{codex-BG0pfud9.js → codex-50GzveCD.js} +8 -7
  23. package/dist/{codex-BG0pfud9.js.map → codex-50GzveCD.js.map} +1 -1
  24. package/dist/{copilot-discount-UXC6NQbN.js → copilot-discount-DM98PuAF.js} +2 -2
  25. package/dist/{copilot-discount-UXC6NQbN.js.map → copilot-discount-DM98PuAF.js.map} +1 -1
  26. package/dist/{debug-1HUHCWFl.js → debug-Df0Kuzi3.js} +2 -2
  27. package/dist/{debug-1HUHCWFl.js.map → debug-Df0Kuzi3.js.map} +1 -1
  28. package/dist/diagnostics-cXjCT_JQ.js +12 -0
  29. package/dist/diagnostics-cXjCT_JQ.js.map +1 -0
  30. package/dist/engine-B6la_uIW.js +1 -0
  31. package/dist/{gate-discovery-DjH9YXoN.js → gate-discovery-2ILpM2fi.js} +5 -5
  32. package/dist/{gate-discovery-DjH9YXoN.js.map → gate-discovery-2ILpM2fi.js.map} +1 -1
  33. package/dist/{get-copilot-usage-CKg42gSH.js → get-copilot-usage-BZ6t2hFZ.js} +2 -2
  34. package/dist/{get-copilot-usage-CKg42gSH.js.map → get-copilot-usage-BZ6t2hFZ.js.map} +1 -1
  35. package/dist/hooks.mjs +13 -0
  36. package/dist/hooks.sha256 +1 -1
  37. package/dist/{index-cmd-sKwchRJz.js → index-cmd-DsK6VFs8.js} +4 -4
  38. package/dist/{index-cmd-sKwchRJz.js.map → index-cmd-DsK6VFs8.js.map} +1 -1
  39. package/dist/{internal-aic-status-B_hEeM37.js → internal-aic-status-CUZ7-trf.js} +3 -3
  40. package/dist/{internal-aic-status-B_hEeM37.js.map → internal-aic-status-CUZ7-trf.js.map} +1 -1
  41. package/dist/{internal-artifact-open-DbHjipxU.js → internal-artifact-open-DRBg1PpV.js} +2 -2
  42. package/dist/{internal-artifact-open-DbHjipxU.js.map → internal-artifact-open-DRBg1PpV.js.map} +1 -1
  43. package/dist/{internal-fast-dispatch-guard-DMzqs-r8.js → internal-fast-dispatch-guard-D6-Ees_6.js} +1 -1
  44. package/dist/{internal-fast-dispatch-guard-PDdlkPU3.js → internal-fast-dispatch-guard-ZeS9u0A3.js} +2 -2
  45. package/dist/{internal-fast-dispatch-guard-PDdlkPU3.js.map → internal-fast-dispatch-guard-ZeS9u0A3.js.map} +1 -1
  46. package/dist/{internal-first-mate-guard-BxPDUsV3.js → internal-first-mate-guard-BijeVpi9.js} +1 -1
  47. package/dist/{internal-first-mate-guard-4Yro9xNM.js → internal-first-mate-guard-DsEEsLKJ.js} +3 -3
  48. package/dist/{internal-first-mate-guard-4Yro9xNM.js.map → internal-first-mate-guard-DsEEsLKJ.js.map} +1 -1
  49. package/dist/{internal-max-dispatch-guard-0teaxIc1.js → internal-max-dispatch-guard-4RLca1i5.js} +2 -2
  50. package/dist/{internal-max-dispatch-guard-0teaxIc1.js.map → internal-max-dispatch-guard-4RLca1i5.js.map} +1 -1
  51. package/dist/{internal-max-dispatch-guard-5LSaHN_y.js → internal-max-dispatch-guard-DeEfWqfP.js} +1 -1
  52. package/dist/{internal-plan-review-BfHLeszV.js → internal-plan-review-bzqGNdtw.js} +3 -3
  53. package/dist/{internal-plan-review-BfHLeszV.js.map → internal-plan-review-bzqGNdtw.js.map} +1 -1
  54. package/dist/{internal-prompt-submit-BixNLmM3.js → internal-prompt-submit-BZ2-CExM.js} +4 -4
  55. package/dist/{internal-prompt-submit-BixNLmM3.js.map → internal-prompt-submit-BZ2-CExM.js.map} +1 -1
  56. package/dist/{internal-prompt-submit-Ou8xtRXj.js → internal-prompt-submit-ZBhH-SQ1.js} +2 -2
  57. package/dist/{internal-rebrief-BBGM0PMv.js → internal-rebrief-BIWbN7Sr.js} +4 -4
  58. package/dist/{internal-rebrief-BBGM0PMv.js.map → internal-rebrief-BIWbN7Sr.js.map} +1 -1
  59. package/dist/{internal-session-bind-pN1V11Mn.js → internal-session-bind-BL6hFRLO.js} +2 -2
  60. package/dist/{internal-session-bind-pN1V11Mn.js.map → internal-session-bind-BL6hFRLO.js.map} +1 -1
  61. package/dist/{internal-stop-hook-DO9Iiaes.js → internal-stop-hook-cDF1MuJZ.js} +5 -5
  62. package/dist/{internal-stop-hook-DO9Iiaes.js.map → internal-stop-hook-cDF1MuJZ.js.map} +1 -1
  63. package/dist/{internal-stop-review-BWp-4XWW.js → internal-stop-review-y8zjpK_3.js} +2 -2
  64. package/dist/{internal-stop-review-BWp-4XWW.js.map → internal-stop-review-y8zjpK_3.js.map} +1 -1
  65. package/dist/{internal-worker-guard-C9OZPgzu.js → internal-worker-guard-DdyYBZR0.js} +2 -2
  66. package/dist/{internal-worker-guard-C9OZPgzu.js.map → internal-worker-guard-DdyYBZR0.js.map} +1 -1
  67. package/dist/{internal-workspace-header-B4TXFBLU.js → internal-workspace-header-BMKbO8yX.js} +2 -2
  68. package/dist/{internal-workspace-header-B4TXFBLU.js.map → internal-workspace-header-BMKbO8yX.js.map} +1 -1
  69. package/dist/lib/tree-sitter-pool/worker.js +268 -21
  70. package/dist/lifecycle-BOjgq9_l.js +1 -0
  71. package/dist/{lifecycle-vjHAFCaY.js → lifecycle-BlC_kzNt.js} +2 -2
  72. package/dist/{lifecycle-vjHAFCaY.js.map → lifecycle-BlC_kzNt.js.map} +1 -1
  73. package/dist/{lifecycle-Dh9y8OF1.js → lifecycle-COZhARmE.js} +2 -2
  74. package/dist/{lifecycle-Dh9y8OF1.js.map → lifecycle-COZhARmE.js.map} +1 -1
  75. package/dist/lifecycle-NQvr4flt.js +1 -0
  76. package/dist/main.js +39 -24
  77. package/dist/main.js.map +1 -1
  78. package/dist/{mcp-workspace-header-C5-dOWNa.js → mcp-workspace-header-Bpa4BId8.js} +2 -2
  79. package/dist/{mcp-workspace-header-C5-dOWNa.js.map → mcp-workspace-header-Bpa4BId8.js.map} +1 -1
  80. package/dist/{models-B6nH1sS6.js → models-BDV-YLf2.js} +3 -3
  81. package/dist/{models-B6nH1sS6.js.map → models-BDV-YLf2.js.map} +1 -1
  82. package/dist/npm-env-H60tX76c.js +130 -0
  83. package/dist/npm-env-H60tX76c.js.map +1 -0
  84. package/dist/optional-DGAeyguL.js +586 -0
  85. package/dist/optional-DGAeyguL.js.map +1 -0
  86. package/dist/{orchestration-B93jxrWI.js → orchestration-Bto5Nc1Y.js} +2 -2
  87. package/dist/{orchestration-B93jxrWI.js.map → orchestration-Bto5Nc1Y.js.map} +1 -1
  88. package/dist/origin-BXtpcKP9.js +382 -0
  89. package/dist/origin-BXtpcKP9.js.map +1 -0
  90. package/dist/origin-DbFUCiGp.js +1 -0
  91. package/dist/paths-CquOjytP.js +1 -0
  92. package/dist/paths-DK_b2ihK.js +176 -0
  93. package/dist/paths-DK_b2ihK.js.map +1 -0
  94. package/dist/{paths-CVEO8jEH.js → paths-DeFmYJhO.js} +16 -3
  95. package/dist/paths-DeFmYJhO.js.map +1 -0
  96. package/dist/{peer-mcp-personas-OWsSm6To.js → peer-mcp-personas-Dny0r5Am.js} +14 -14
  97. package/dist/{peer-mcp-personas-OWsSm6To.js.map → peer-mcp-personas-Dny0r5Am.js.map} +1 -1
  98. package/dist/{pi-DmeBxzIo.js → pi-DVud9eQn.js} +386 -243
  99. package/dist/pi-DVud9eQn.js.map +1 -0
  100. package/dist/{pi-foreign-artifacts-DZ4tioyO.js → pi-foreign-artifacts-CNt6wQ1P.js} +2 -2
  101. package/dist/{pi-foreign-artifacts-DZ4tioyO.js.map → pi-foreign-artifacts-CNt6wQ1P.js.map} +1 -1
  102. package/dist/pi-memory-bridge-BxmCIIbk.js +618 -0
  103. package/dist/pi-memory-bridge-BxmCIIbk.js.map +1 -0
  104. package/dist/pi-memory-bridge-D5A0h_Kf.js +1 -0
  105. package/dist/pi-version-check-BeBB0Ny9.js +551 -0
  106. package/dist/pi-version-check-BeBB0Ny9.js.map +1 -0
  107. package/dist/pi-version-check-D5RvdLsG.js +1 -0
  108. package/dist/{plan-review-hook-MhjK92wq.js → plan-review-hook-D_yyjOgO.js} +3 -3
  109. package/dist/{plan-review-hook-MhjK92wq.js.map → plan-review-hook-D_yyjOgO.js.map} +1 -1
  110. package/dist/{provision-DPL8aGe2.js → provision-BWtuDq_v.js} +30 -36
  111. package/dist/provision-BWtuDq_v.js.map +1 -0
  112. package/dist/rerank-cross-encoder-BhjImuwG.js +192 -0
  113. package/dist/rerank-cross-encoder-BhjImuwG.js.map +1 -0
  114. package/dist/{self-invocation-DMUnXVGT.js → self-invocation-Dnq4iVD6.js} +4 -31
  115. package/dist/{self-invocation-DMUnXVGT.js.map → self-invocation-Dnq4iVD6.js.map} +1 -1
  116. package/dist/{serve-zbQKfx1E.js → serve-B8Igr9Q0.js} +15 -14
  117. package/dist/{serve-zbQKfx1E.js.map → serve-B8Igr9Q0.js.map} +1 -1
  118. package/dist/{server-setup-ClZdV33Q.js → server-setup-byIhjgOb.js} +708 -640
  119. package/dist/server-setup-byIhjgOb.js.map +1 -0
  120. package/dist/{service-backend-Cdgz6WPx.js → service-backend-BdhWVRSz.js} +17 -62
  121. package/dist/service-backend-BdhWVRSz.js.map +1 -0
  122. package/dist/{start-mnedD5cH.js → start-7CiQIl0r.js} +5 -4
  123. package/dist/{start-mnedD5cH.js.map → start-7CiQIl0r.js.map} +1 -1
  124. package/dist/{static-context-pack-CtnBwHSd.js → static-context-pack-BKFelEbM.js} +3 -3
  125. package/dist/{static-context-pack-CtnBwHSd.js.map → static-context-pack-BKFelEbM.js.map} +1 -1
  126. package/dist/{stop-gate-hook-CBVLD8iB.js → stop-gate-hook-DBOj0TqL.js} +3 -3
  127. package/dist/{stop-gate-hook-CBVLD8iB.js.map → stop-gate-hook-DBOj0TqL.js.map} +1 -1
  128. package/dist/{stop-gate-policy-BehNiNix.js → stop-gate-policy-Bp2wGh_W.js} +2 -2
  129. package/dist/{stop-gate-policy-BehNiNix.js.map → stop-gate-policy-Bp2wGh_W.js.map} +1 -1
  130. package/dist/{token-CPzYxU4Y.js → token-CKPOBdO0.js} +23 -88
  131. package/dist/{token-CPzYxU4Y.js.map → token-CKPOBdO0.js.map} +1 -1
  132. package/dist/{token-DHEkiO4g.js → token-Ygd7D32L.js} +3 -3
  133. package/dist/{token-DHEkiO4g.js.map → token-Ygd7D32L.js.map} +1 -1
  134. package/dist/update-CB21YRKz.js +1 -0
  135. package/dist/update-T1L7yFon.js +1548 -0
  136. package/dist/update-T1L7yFon.js.map +1 -0
  137. package/dist/update-fEgWTrIx.js +214 -0
  138. package/dist/update-fEgWTrIx.js.map +1 -0
  139. package/dist/update-lock-BeS_WmC8.js +1 -0
  140. package/dist/update-lock-BmXx6QaR.js +171 -0
  141. package/dist/update-lock-BmXx6QaR.js.map +1 -0
  142. package/dist/volatile-root-DQNNvQ7Z.js +50 -0
  143. package/dist/volatile-root-DQNNvQ7Z.js.map +1 -0
  144. package/dist/{worker-dispatch-C7RtNOXv.js → worker-dispatch-DBWKTMda.js} +2 -2
  145. package/dist/{worker-dispatch-C7RtNOXv.js.map → worker-dispatch-DBWKTMda.js.map} +1 -1
  146. package/dist/{workiq-CQauEAMc.js → workiq-D5b7xlbr.js} +2 -2
  147. package/dist/{workiq-CQauEAMc.js.map → workiq-D5b7xlbr.js.map} +1 -1
  148. package/dist/{workiq-tools-DL6rC4bP.js → workiq-tools-DdiQ2DOW.js} +1 -1
  149. package/package.json +16 -4
  150. package/dist/ado-tools-CRkyU51J.js +0 -1
  151. package/dist/claude-md-injection-Biq_Xhve.js.map +0 -1
  152. package/dist/engine-V46un8Xl.js +0 -1
  153. package/dist/lifecycle-BENRuuX6.js +0 -1
  154. package/dist/lifecycle-Dli9vGI2.js +0 -1
  155. package/dist/paths-Be9_ujQ3.js +0 -1
  156. package/dist/paths-CVEO8jEH.js.map +0 -1
  157. package/dist/pi-DmeBxzIo.js.map +0 -1
  158. package/dist/pi-memory-bridge-Bp9AnYw9.js +0 -1
  159. package/dist/pi-memory-bridge-CICIdDVP.js +0 -413
  160. package/dist/pi-memory-bridge-CICIdDVP.js.map +0 -1
  161. package/dist/provision-DPL8aGe2.js.map +0 -1
  162. package/dist/rerank-cross-encoder-B87lZgvc.js +0 -110
  163. package/dist/rerank-cross-encoder-B87lZgvc.js.map +0 -1
  164. package/dist/server-setup-ClZdV33Q.js.map +0 -1
  165. package/dist/service-backend-Cdgz6WPx.js.map +0 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"optional-DGAeyguL.js","names":["fs"],"sources":["../src/lib/managed-install/optional.ts"],"sourcesContent":["/**\n * On-demand install of the heavy optional payloads.\n *\n * `@huggingface/transformers` (~547 MB with its ONNX runtime) and\n * `tree-sitter-wasms` (~49 MB of grammars) are the entire difference between a\n * 66 MB install and a 586 MB one. The plan moves them to **optional** peers so\n * nobody pays for them at install time — which has one blunt consequence that\n * must be stated plainly: **optional peers are installed for nobody**, at any\n * depth, by npm and by bun alike (measured). So \"optional\" cannot mean \"the\n * usual install will bring it\"; it has to mean \"we install it the first time\n * something actually needs it\".\n *\n * Three rules shape this file:\n *\n * 1. **One copy per machine, shared across versions.** The payload lands in\n * `<APP_DIR>/optional/<pkg>@<version>/`, never inside a managed version dir:\n * those are per-version and GC keeps two, so an in-tree copy would be 1.1 GB\n * and would be re-fetched on every bump.\n * 2. **Failure is always allowed.** Reranking falls back to BM25F and structural\n * ranking to the regex heuristic; both already warn for exactly this case.\n * Nothing here may ever make a search or a chat request fail.\n * 3. **Off the hot path.** Resolution (is a usable copy present?) is a couple of\n * `stat`s against a bounded directory listing, and it is synchronous because\n * both consumers are. Installation is a separate, throttled, detached child;\n * the request that noticed the gap proceeds without it.\n *\n * Supply-chain posture matches the managed installer: exact version, scrubbed\n * npm env, `--ignore-scripts`, `--no-global`, provenance from the lockfile.\n */\n\nimport fs from \"node:fs/promises\"\nimport { existsSync, readdirSync } from \"node:fs\"\nimport path from \"node:path\"\n\nimport { writeFileAtomic, readFileWithRetry } from \"../atomic-file\"\nimport { parseBoolEnv, resolveExecutable, runCommandCapture } from \"../exec\"\nimport { buildNpmEnv } from \"./npm-env\"\nimport { reportManagedDiagnostic } from \"./diagnostics\"\nimport { VERSION_RE, isTransientName, isVersionName, optionalRoot, randomHex } from \"./paths\"\n\n/** The packages that may be installed on demand. */\nexport const OPTIONAL_PACKAGES = [\"@huggingface/transformers\", \"tree-sitter-wasms\"] as const\nexport type OptionalPackage = (typeof OPTIONAL_PACKAGES)[number]\n\n/**\n * Entry file that must exist for a copy to count as installed.\n *\n * A package directory alone is not enough: an interrupted `npm install` can\n * leave `node_modules/<pkg>` in place with its payload missing, and an\n * on-demand install is precisely the kind that gets interrupted (the user\n * quits, the machine sleeps). These are the exact files the two consumers load.\n */\nexport const OPTIONAL_REQUIRED_FILE: Readonly<Record<OptionalPackage, string>> = {\n \"@huggingface/transformers\": \"dist/transformers.node.mjs\",\n // The filename must be the one the package actually ships:\n // `tree-sitter-wasms@0.1.13/out/tree-sitter-typescript.wasm`. A wrong name\n // here is not a loud failure — the install SUCCEEDS, `completeAt` then refuses\n // the payload, structural ranking silently keeps using the regex fallback,\n // and the package state backs off for an hour pretending npm broke.\n \"tree-sitter-wasms\": \"out/tree-sitter-typescript.wasm\",\n}\n\n/**\n * The peer range each payload must satisfy, mirroring `package.json`.\n *\n * On-demand installation used to take whatever `npm view <pkg> version` said,\n * which is unbounded: the day transformers 5.x ships, every machine fetches a\n * major the router has never run — and `completeAt` refusing the payload turns\n * that into a one-hour backoff that hides the cause. Bounding the query\n * (`npm view <pkg>@<range> version`) makes npm do the range arithmetic, so the\n * answer is by construction compatible. `tests/optional-payload-manifest.test.ts`\n * asserts this table still matches `package.json#peerDependencies`.\n */\nexport const OPTIONAL_VERSION_RANGE: Readonly<Record<OptionalPackage, string>> = {\n \"@huggingface/transformers\": \"^4.3.2\",\n \"tree-sitter-wasms\": \"^0.1.13\",\n}\n\n/** `<pkg>` → the directory name used under `optional/` (`@scope/name` is unsafe). */\nfunction sanitized(pkg: string): string {\n return pkg.replace(\"/\", \"__\")\n}\n\n/**\n * Test seam: what a slot actually installs.\n *\n * The install mechanics (staging, verify, publish-by-rename, provenance, GC) are\n * identical for a 547 MB ONNX payload and for a 6 KB package with no scripts, but\n * only one of them can run in a test. Overriding via a seam keeps ONE code path\n * instead of a re-implementation in the test that could pass while production\n * breaks. Nothing in `src/` calls the setters.\n */\ninterface OptionalSubject {\n packageName: string\n requiredFile: string\n version: string | null\n /** Peer range to resolve within; the real table by default. */\n range: string | null\n}\nconst subjects = new Map<OptionalPackage, OptionalSubject>()\n\nfunction subjectFor(pkg: OptionalPackage): OptionalSubject {\n return (\n subjects.get(pkg) ?? {\n packageName: pkg,\n requiredFile: OPTIONAL_REQUIRED_FILE[pkg],\n version: null,\n range: OPTIONAL_VERSION_RANGE[pkg],\n }\n )\n}\n\n/** @internal — point one slot at a throwaway package. */\nexport function __setOptionalTestSubject(input: {\n pkg: OptionalPackage\n packageName: string\n requiredFile: string\n version?: string\n}): void {\n subjects.set(input.pkg, {\n packageName: input.packageName,\n requiredFile: input.requiredFile,\n version: input.version ?? null,\n // A test stand-in (`is-number`) has its own version, so bind it to itself\n // rather than to the real package's peer range.\n range: input.version ? input.version : null,\n })\n}\n\n/** @internal — restore the real subjects. */\nexport function __resetOptionalTestSubject(): void {\n subjects.clear()\n}\n\n/**\n * True when the user disabled on-demand payloads.\n *\n * Uses the shared `parseBoolEnv`, not a local `raw === \"1\" || raw === \"true\"`:\n * `GH_ROUTER_NO_OPTIONAL_INSTALL=TRUE` or `=yes` used to be unrecognised and\n * silently *enabled* a 547 MB download, which is the worst possible way for an\n * off switch to fail.\n */\nexport function optionalInstallDisabled(env: NodeJS.ProcessEnv = process.env): boolean {\n return parseBoolEnv(env.GH_ROUTER_NO_OPTIONAL_INSTALL) === true\n}\n\n/** The `node_modules/<pkg>` directory inside an installed optional copy. */\nfunction payloadDir(target: string, pkg: OptionalPackage): string {\n return path.join(target, \"node_modules\", ...subjectFor(pkg).packageName.split(\"/\"))\n}\n\n/** Is `target` a complete payload? */\nfunction completeAt(target: string, pkg: OptionalPackage): boolean {\n const dir = payloadDir(target, pkg)\n return (\n existsSync(path.join(dir, \"package.json\"))\n && existsSync(path.join(dir, subjectFor(pkg).requiredFile))\n )\n}\n\n/**\n * A usable installed copy of `pkg`, preferring the NEWEST version present.\n *\n * Synchronous on purpose: `resolveGrammarRoot()` and the rerank loader are\n * called from synchronous contexts, and a promise here would force an `await`\n * onto a path that must stay cheap. The listing is small (one entry per\n * installed version, typically one).\n *\n * Returns the package directory (the thing a consumer imports from), not the\n * `optional/<pkg>@<ver>` prefix.\n */\nexport function installedOptional(pkg: OptionalPackage): string | null {\n const [newest] = completeTargets(pkg)\n return newest ? payloadDir(newest, pkg) : null\n}\n\n/**\n * Every COMPLETE `<root>/<pkg>@<version>` target dir, newest version first.\n *\n * Split out of `installedOptional` because two callers need the target dir\n * itself rather than the package dir inside it: the upgrade check (\"is the\n * version we just resolved already here?\") and the GC protection list (\"spare\n * the copy this process is using\").\n */\nfunction completeTargets(pkg: OptionalPackage): Array<string> {\n const root = optionalRoot()\n let names: Array<string>\n try {\n names = readdirSync(root)\n } catch {\n return []\n }\n const prefix = `${sanitized(pkg)}@`\n const candidates = names\n .filter((name) => name.startsWith(prefix) && !name.startsWith(\".\"))\n .map((name) => ({ name, version: name.slice(prefix.length) }))\n .filter((entry) => isVersionName(entry.version))\n // Newest first: a stale older copy must never shadow a fresh one.\n .sort((a, b) => compareVersions(b.version, a.version))\n\n const out: Array<string> = []\n for (const candidate of candidates) {\n const target = path.join(root, candidate.name)\n if (completeAt(target, pkg)) out.push(target)\n }\n return out\n}\n\n/** Where `pkg@version` would live. */\nexport function optionalTarget(pkg: OptionalPackage, version: string): string {\n return path.join(optionalRoot(), `${sanitized(pkg)}@${version}`)\n}\n\n/** `payloadDir` for exactly `pkg@version`, or null when that copy is not complete. */\nfunction installedOptionalTarget(pkg: OptionalPackage, version: string): string | null {\n const target = optionalTarget(pkg, version)\n return completeAt(target, pkg) ? payloadDir(target, pkg) : null\n}\n\n// ---------------------------------------------------------------------------\n// Backoff + GC state\n// ---------------------------------------------------------------------------\n\n/**\n * `optional/install-state.json`.\n *\n * Separate from `m/<kind>/install-state.json` because the lifecycles are\n * separate: pruning the managed tree must never reset (or inherit) a failing\n * optional install's ladder, and the optional ladder is per PACKAGE.\n */\ninterface OptionalState {\n packages?: Partial<\n Record<\n OptionalPackage,\n {\n lastAttemptAt?: string\n lastSuccessAt?: string\n consecutiveFailures?: number\n nextAttemptAt?: string\n lastError?: string\n version?: string\n }\n >\n >\n}\n\nconst BACKOFF_HOURS = [1, 6, 24] as const\nconst KEEP_OPTIONAL_VERSIONS = 2\nconst OPTIONAL_FLOOR_MS = 30 * 24 * 60 * 60_000\n\nfunction statePath(): string {\n return path.join(optionalRoot(), \"install-state.json\")\n}\n\nasync function readState(): Promise<OptionalState> {\n try {\n const raw = await readFileWithRetry(statePath(), { retryMissing: false })\n const parsed = JSON.parse(raw) as OptionalState\n return typeof parsed === \"object\" && parsed !== null ? parsed : {}\n } catch {\n return {}\n }\n}\n\nasync function patchState(\n pkg: OptionalPackage,\n patch: Partial<NonNullable<OptionalState[\"packages\"]>[OptionalPackage] & object>,\n): Promise<void> {\n try {\n const state = await readState()\n const next: OptionalState = {\n ...state,\n packages: { ...(state.packages ?? {}), [pkg]: { ...(state.packages?.[pkg] ?? {}), ...patch } },\n }\n // `undefined` means delete — how a success clears the ladder.\n for (const [key, value] of Object.entries(next.packages?.[pkg] ?? {})) {\n if (value === undefined) delete (next.packages![pkg] as Record<string, unknown>)[key]\n }\n await fs.mkdir(optionalRoot(), { recursive: true })\n await writeFileAtomic(statePath(), `${JSON.stringify(next, null, 2)}\\n`, { mode: 0o644 })\n } catch (err) {\n reportManagedDiagnostic(\"debug\", `optional: could not write state: ${String(err)}`)\n }\n}\n\nfunction nextAttemptAtFor(failures: number): string {\n const index = Math.min(Math.max(failures, 1), BACKOFF_HOURS.length) - 1\n return new Date(Date.now() + (BACKOFF_HOURS[index] ?? 24) * 3_600_000).toISOString()\n}\n\n/**\n * Whether an attempt may start — a RESERVATION is not a backoff.\n *\n * `nextAttemptAt` is written before every attempt so two processes cannot both\n * download a 500 MB payload, and it is also the ladder's output. Conflating them\n * makes `github-router update` (issued while an on-demand install is still\n * running, seconds after it reserved) report \"backing off after a failed\n * tree-sitter-wasms install\" when nothing had failed. With `consecutiveFailures`\n * still 0 the window is a reservation, so re-attempting is allowed; the loser of\n * the rename race adopts the winner's payload.\n */\nasync function mayAttemptNow(pkg: OptionalPackage): Promise<boolean> {\n const entry = (await readState()).packages?.[pkg]\n if ((entry?.consecutiveFailures ?? 0) === 0) return true\n if (!entry?.nextAttemptAt) return true\n const next = new Date(entry.nextAttemptAt).getTime()\n return Number.isNaN(next) ? true : Date.now() >= next\n}\n\n// ---------------------------------------------------------------------------\n// Install\n// ---------------------------------------------------------------------------\n\nexport interface EnsureOptionalResult {\n /** The `node_modules/<pkg>` directory when usable, else null. */\n dir: string | null\n detail?: string\n installed?: boolean\n}\n\n/**\n * Make sure `pkg` is installed and return its directory.\n *\n * Fail-open and throttled: a failure is remembered on the standard ladder, so a\n * permanently offline machine does not spawn an npm process per search.\n */\nexport async function ensureOptionalPackage(\n pkg: OptionalPackage,\n opts: { signal?: AbortSignal; force?: boolean; registry?: string } = {},\n): Promise<EnsureOptionalResult> {\n if (optionalInstallDisabled()) {\n return { dir: null, detail: \"GH_ROUTER_NO_OPTIONAL_INSTALL is set\" }\n }\n if (!opts.force && !(await mayAttemptNow(pkg))) {\n return { dir: null, detail: `backing off after a failed ${pkg} install` }\n }\n\n const npmPath = resolveExecutable(\"npm\")\n if (!npmPath) {\n // No npm is not a reason to refuse a payload that is already installed.\n const existing = installedOptional(pkg)\n return existing ? { dir: existing } : { dir: null, detail: \"npm is not on PATH\" }\n }\n\n // Resolve FIRST, then compare against what is installed.\n //\n // The obvious order — \"anything installed? return it\" — makes the payload\n // permanently un-upgradable: the first install wins forever, `update` keeps\n // reporting the stale copy \"ready\", and a fix for a broken payload can never\n // reach a machine that already has one. `installedOptional` prefers the newest\n // copy but cannot know whether a NEWER version exists.\n const version = await resolveOptionalVersion(pkg, opts.registry)\n // A payload dir, so it can be returned as-is (wrapping it in `payloadDir` again\n // produced `<pkg>/node_modules/<pkg>/node_modules/<pkg>`).\n const existing = version ? installedOptionalTarget(pkg, version) : installedOptional(pkg)\n if (existing && !opts.force) return { dir: existing }\n\n if (!version) {\n await patchState(pkg, {\n lastAttemptAt: new Date().toISOString(),\n consecutiveFailures: 1,\n nextAttemptAt: nextAttemptAtFor(1),\n lastError: \"could not resolve a version to install\",\n })\n return { dir: null, detail: `could not resolve a version for ${pkg}` }\n }\n\n const target = optionalTarget(pkg, version)\n // A concurrent install may have published it while we resolved.\n if (completeAt(target, pkg)) return { dir: payloadDir(target, pkg), installed: false }\n\n // The newest copy this machine already had, captured BEFORE the install so GC\n // can be told to spare it (see the `gcOptional` call below). A running process\n // may have it memory-mapped: the ONNX runtime is loaded lazily, so \"this\n // process installed the newer one\" says nothing about whether it is still\n // reading the older one.\n const [previousTarget] = completeTargets(pkg)\n\n // Reservation only, with the ladder value keyed on the REAL failure count: a\n // first attempt has `consecutiveFailures` 0, which `mayAttemptNow` treats as\n // \"not a backoff\".\n await patchState(pkg, {\n lastAttemptAt: new Date().toISOString(),\n nextAttemptAt: nextAttemptAtFor((await readState()).packages?.[pkg]?.consecutiveFailures ?? 0),\n })\n\n try {\n await installInto(pkg, version, target, npmPath, opts.registry, opts.signal)\n await patchState(pkg, {\n lastSuccessAt: new Date().toISOString(),\n consecutiveFailures: 0,\n nextAttemptAt: undefined,\n lastError: undefined,\n version,\n })\n // Protect BOTH the copy this process was already using (a rerank that has the\n // ONNX runtime loaded memory-maps files from it) and the one just installed.\n // GC removes by age + rank, and \"rank\" cannot see a running\n // process: on POSIX an `fs.rm` of a mapped directory SUCCEEDS (`EBUSY` only\n // rescues Windows), so the next lazy load in that process dies. Protecting\n // these two names is the whole of what this process can know; the 30-day\n // floor and keep-2 rule cover the rest.\n const protect = [path.basename(target)]\n if (previousTarget) protect.push(previousTarget)\n await gcOptional(Date.now(), protect).catch(() => {})\n return { dir: payloadDir(target, pkg), installed: true }\n } catch (err) {\n const detail = err instanceof Error ? err.message : String(err)\n const failures = ((await readState()).packages?.[pkg]?.consecutiveFailures ?? 0) + 1\n await patchState(pkg, {\n lastAttemptAt: new Date().toISOString(),\n consecutiveFailures: failures,\n nextAttemptAt: nextAttemptAtFor(failures),\n lastError: detail,\n })\n return { dir: null, detail }\n }\n}\n\n/**\n * Install `pkg@version` into `target` via a staging sibling.\n *\n * Same publish discipline as the managed installer (build in `.staging-*`,\n * verify the entry, rename into place) and for the same reason: the target may\n * be read concurrently by a running request, and a half-written payload that\n * passes a directory-existence check is worse than no payload.\n */\nasync function installInto(\n pkg: OptionalPackage,\n version: string,\n target: string,\n npmPath: string,\n registry?: string,\n signal?: AbortSignal,\n): Promise<void> {\n const root = optionalRoot()\n await fs.mkdir(root, { recursive: true })\n const staging = path.join(root, `.staging-${process.pid}-${randomHex()}`)\n // Not `recursive`: the name is unique, so an EEXIST means a leftover tree from\n // a same-pid attempt, and installing into it would let an INHERITED copy pass\n // the completeness check below. Fail and let the caller retry.\n await fs.mkdir(staging)\n try {\n const pkgJson = {\n name: `gh-router-optional-${sanitized(pkg)}`,\n private: true,\n version: \"0.0.0\",\n dependencies: { [subjectFor(pkg).packageName]: version },\n }\n await writeFileAtomic(path.join(staging, \"package.json\"), `${JSON.stringify(pkgJson, null, 2)}\\n`, {\n mode: 0o644,\n })\n\n const overrides: NodeJS.ProcessEnv = {}\n if (registry) overrides.npm_config_registry = registry\n const { env } = buildNpmEnv(process.env, overrides)\n\n reportManagedDiagnostic(\"info\", `Installing optional ${pkg}@${version} (one-time)…`)\n const { code, stderr } = await runCommandCapture(\n [\n npmPath,\n \"install\",\n \"--no-global\",\n \"--no-dry-run\",\n \"--include=optional\",\n \"--ignore-scripts\",\n \"--no-audit\",\n \"--no-fund\",\n \"--loglevel=error\",\n ...(registry ? [`--registry=${registry}`] : []),\n ],\n { cwd: staging, env, timeoutMs: 30 * 60_000, signal },\n )\n if (code !== 0) {\n throw new Error(`npm install ${pkg}@${version} failed (exit ${code}): ${stderr.slice(0, 400)}`)\n }\n if (!completeAt(staging, pkg)) {\n throw new Error(\n `${subjectFor(pkg).packageName}@${version} installed but ${subjectFor(pkg).requiredFile} is missing`,\n )\n }\n // The required file existing is not the same as the right version being\n // installed: a stale tree, a mirror serving another tarball, or a `--omit`\n // config that slipped through all look complete. The rename below publishes\n // this directory, so verify identity before that.\n try {\n const declared = (\n JSON.parse(await fs.readFile(path.join(payloadDir(staging, pkg), \"package.json\"), \"utf8\")) as {\n version?: unknown\n }\n ).version\n if (declared !== version) {\n throw new Error(\n `${subjectFor(pkg).packageName}@${version} installed but its package.json declares ${JSON.stringify(declared)}; refusing to publish it`,\n )\n }\n } catch (err) {\n if (err instanceof Error && err.message.includes(\"refusing to publish\")) throw err\n throw new Error(\n `${subjectFor(pkg).packageName}@${version} installed but its package.json is unreadable: ${\n err instanceof Error ? err.message : String(err)\n }`,\n { cause: err },\n )\n }\n const packages = await harvestProvenance(staging)\n await writeFileAtomic(\n path.join(staging, \".installed.json\"),\n `${JSON.stringify({ version, packages, installedAt: new Date().toISOString() }, null, 2)}\\n`,\n { mode: 0o644 },\n )\n\n try {\n await fs.rename(staging, target)\n } catch (err) {\n const code = (err as NodeJS.ErrnoException).code\n const clash =\n code === \"ENOTEMPTY\" || code === \"EEXIST\" || code === \"EPERM\" || code === \"EACCES\"\n if (!clash) throw err\n // Somebody published it first. Adopt theirs if it is complete.\n if (completeAt(target, pkg)) return\n const aside = path.join(root, `.trash-${randomHex()}`)\n let movedAside = false\n try {\n await fs.rename(target, aside)\n movedAside = true\n } catch (err) {\n if ((err as NodeJS.ErrnoException).code !== \"ENOENT\") throw err\n }\n try {\n await fs.rename(staging, target)\n } catch (err) {\n // Put the incomplete-but-present tree back rather than leaving the\n // package with NO copy at all: `installedOptional` refuses it either way,\n // but a single retry can repair it in place, and a missing directory\n // cannot be compared or resumed.\n if (movedAside) await fs.rename(aside, target).catch(() => {})\n throw err\n }\n }\n } finally {\n await fs.rm(staging, { recursive: true, force: true }).catch(() => {})\n }\n}\n\n/** `{ \"<pkg>@<ver>\": { resolved, integrity } }` from the prefix lockfile. */\nasync function harvestProvenance(\n prefix: string,\n): Promise<Record<string, { resolved?: string; integrity?: string }>> {\n const out: Record<string, { resolved?: string; integrity?: string }> = {}\n try {\n const raw = await fs.readFile(path.join(prefix, \"package-lock.json\"), \"utf8\")\n const parsed = JSON.parse(raw) as {\n packages?: Record<string, { version?: string; resolved?: string; integrity?: string; link?: boolean }>\n }\n for (const [key, entry] of Object.entries(parsed.packages ?? {})) {\n if (!key.startsWith(\"node_modules/\") || entry.link || !entry.version) continue\n const name = key.slice(\"node_modules/\".length)\n // Top-level only; the transitive tree is reproducible from the registry\n // once the root tarball's integrity is pinned.\n if (name.includes(\"node_modules/\")) continue\n out[`${name}@${entry.version}`] = {\n ...(entry.resolved ? { resolved: entry.resolved } : {}),\n ...(entry.integrity ? { integrity: entry.integrity } : {}),\n }\n }\n } catch {\n // No lockfile: provenance is diagnostics, never a gate.\n }\n return out\n}\n\n/** Newest published version of `pkg`, or null. */\nasync function resolveOptionalVersion(\n pkg: OptionalPackage,\n registry?: string,\n): Promise<string | null> {\n const pinned = subjectFor(pkg).version\n if (pinned) return pinned\n const npmPath = resolveExecutable(\"npm\")\n if (!npmPath) return null\n const subject = subjectFor(pkg)\n // With a range, npm does the range arithmetic and `--json` gives every match\n // newest-last; without one (a test stand-in) the spec is the bare name.\n const spec = subject.range ? `${subject.packageName}@${subject.range}` : subject.packageName\n try {\n const args = [npmPath, \"view\", spec, \"version\", \"--json\", \"--silent\"]\n if (registry) args.push(`--registry=${registry}`)\n const { stdout, code } = await runCommandCapture(args, { timeoutMs: 8000 })\n if (code !== 0) return null\n const value = lastVersionFromJson(stdout)\n return value && VERSION_RE.test(value) ? value : null\n } catch {\n return null\n }\n}\n\n/**\n * The newest version in `npm view … --json` output, or null.\n *\n * The output is a bare `\"1.2.3\"` when the spec matches exactly one version and\n * an ARRAY when a range matches several — and `npm view left-pad@^1.0.0 version`\n * prints the array newest-LAST, so the last element is the answer in both cases.\n * Parsing it as JSON rather than taking the last LINE is what makes a range with\n * a hundred matches work; the old line-based read returned `\"1.3.0\"` (with the\n * quotes) and the version regex then rejected it.\n */\nfunction lastVersionFromJson(stdout: string): string | null {\n const text = stdout.trim()\n if (!text) return null\n try {\n const parsed = JSON.parse(text) as unknown\n if (typeof parsed === \"string\") return parsed\n if (Array.isArray(parsed)) {\n for (let i = parsed.length - 1; i >= 0; i--) {\n const entry = parsed[i]\n if (typeof entry === \"string\") return entry\n }\n }\n return null\n } catch {\n return null\n }\n}\n\n/** Compare dotted versions on the leading three components. */\nexport function compareVersions(a: string, b: string): number {\n const pa = a.split(/[.+-]/).map((n) => Number.parseInt(n, 10))\n const pb = b.split(/[.+-]/).map((n) => Number.parseInt(n, 10))\n for (let i = 0; i < 3; i++) {\n const av = Number.isNaN(pa[i]) ? 0 : (pa[i] ?? 0)\n const bv = Number.isNaN(pb[i]) ? 0 : (pb[i] ?? 0)\n if (av !== bv) return av - bv\n }\n return 0\n}\n\n/**\n * Keep the newest `KEEP_OPTIONAL_VERSIONS` copies per package and sweep\n * abandoned staging/trash dirs.\n *\n * Deliberately more conservative than the managed GC (30-day floor, keep 2, and\n * never remove the only copy of a package): each copy is up to 547 MB, so\n * deleting the wrong one is expensive to undo.\n *\n * `protect` is the caller's knowledge of what is IN USE — directory names under\n * the optional root that must survive this sweep. Nothing on disk records which\n * copy a running process has loaded, and the two rules here cannot infer it: a\n * process that has been up for weeks holds an old version that ranks below the\n * two newest and is past the floor, and on POSIX `fs.rm` of a memory-mapped\n * payload SUCCEEDS (`EBUSY` only saves Windows). The next lazy load in that\n * process would then fail. The installer passes the copy it just wrote and the\n * one it replaced.\n */\nexport async function gcOptional(\n now = Date.now(),\n protect: ReadonlyArray<string> = [],\n): Promise<{\n removed: Array<string>\n removedTransient: Array<string>\n}> {\n const root = optionalRoot()\n let names: Array<string>\n try {\n names = await fs.readdir(root)\n } catch {\n return { removed: [], removedTransient: [] }\n }\n\n const removed: Array<string> = []\n const removedTransient: Array<string> = []\n\n // Bucket by package, carrying mtime so \"newest\" is by time, not by the order\n // the filesystem happened to hand back.\n const versions = new Map<string, Array<{ name: string; mtimeMs: number }>>()\n\n for (const name of names) {\n const full = path.join(root, name)\n let mtimeMs: number\n try {\n mtimeMs = (await fs.stat(full)).mtimeMs\n } catch {\n continue\n }\n // Same shapes as the managed GC (`paths.ts`): a user file that merely\n // starts with `.staging-` is not one of our abandoned attempts.\n if (isTransientName(name)) {\n if (now - mtimeMs > 60 * 60_000) {\n await fs.rm(full, { recursive: true, force: true }).catch(() => {})\n removedTransient.push(name)\n }\n continue\n }\n const match = /^(.+?)@(.+)$/.exec(name)\n if (!match) continue\n if (!isVersionName(match[2]!)) continue\n const bucket = versions.get(match[1]!) ?? []\n bucket.push({ name, mtimeMs })\n versions.set(match[1]!, bucket)\n }\n\n const spared = new Set(protect)\n for (const entries of versions.values()) {\n // Newest first, then keep the first N. Everything from index N on is a\n // removal CANDIDATE, still subject to the age floor and the protect list.\n entries.sort((a, b) => b.mtimeMs - a.mtimeMs)\n for (const entry of entries.slice(KEEP_OPTIONAL_VERSIONS)) {\n if (spared.has(entry.name)) continue\n if (now - entry.mtimeMs < OPTIONAL_FLOOR_MS) continue\n await fs.rm(path.join(root, entry.name), { recursive: true, force: true })\n .then(() => removed.push(entry.name))\n .catch(() => {\n // EBUSY on Windows (a loaded ONNX runtime): retried on the next pass.\n })\n }\n }\n return { removed, removedTransient }\n}\n\n// ---------------------------------------------------------------------------\n// Entry points used by the launcher / update\n// ---------------------------------------------------------------------------\n\n/**\n * Install ONE payload, whichever a caller asked for by name.\n *\n * Separate entry point from `ensureOptionalPackage` because the argument comes\n * from a command line: an unknown name must be a reported no-op, never a crash\n * and never \"install everything because the filter matched nothing\".\n */\nexport function isOptionalPackage(name: string): name is OptionalPackage {\n return (OPTIONAL_PACKAGES as ReadonlyArray<string>).includes(name)\n}\n\n/**\n * Install both payloads, reporting what happened.\n *\n * Called from `github-router update` (foreground, where a failure is visible)\n * and never from a request path.\n */\nexport async function ensureOptionalPackages(\n opts: { registry?: string; signal?: AbortSignal; force?: boolean } = {},\n): Promise<Array<{ pkg: OptionalPackage; dir: string | null; detail?: string }>> {\n const out: Array<{ pkg: OptionalPackage; dir: string | null; detail?: string }> = []\n for (const pkg of OPTIONAL_PACKAGES) {\n const result = await ensureOptionalPackage(pkg, opts)\n out.push({ pkg, dir: result.dir, ...(result.detail ? { detail: result.detail } : {}) })\n }\n return out\n}\n\n/** Set by {@link scheduleOptionalInstall}; one detached child per process. */\nlet scheduledInProcess = false\n\n/**\n * Detached, best-effort install for a launch that noticed a gap.\n *\n * Detached because the spawn cost of two npm installs (minutes on a cold cache)\n * must never be attributed to the command the user actually ran — and a search\n * that triggered this proceeds on its BM25F fallback regardless.\n */\nexport function scheduleOptionalInstall(\n pkg: OptionalPackage,\n argv1: string | undefined = process.argv[1],\n): boolean {\n if (optionalInstallDisabled()) return false\n if (typeof argv1 !== \"string\" || argv1.length === 0) return false\n // Once per process. The callers are on request paths (a rerank, a structural\n // search), and for an agent a \"request path\" means per turn: spawning a\n // detached node process on every one of them would be worse than the missing\n // payload. Cross-process throttling is the backoff in `install-state.json`;\n // this flag only stops the same process from re-spawning what it already\n // started.\n if (scheduledInProcess) return false\n scheduledInProcess = true\n const missing = pkg\n void (async () => {\n try {\n // Dynamic on purpose: modules that only ever RESOLVE a payload (the\n // rerank loader, the grammar resolver) should not pull\n // `node:child_process` into their import graph.\n const { spawn } = await import(\"node:child_process\")\n // `--optional-only --optional-pkg <pkg>`: the caller is a feature that found\n // no payload, so installing THAT payload is the whole request. Not a\n // self-update, not a managed Pi appearing on a source checkout because a\n // search was slow, and — the part that is easy to get wrong — not the OTHER\n // payload either: a structural-search miss must not start a 547 MB ONNX\n // download because both slots share one flag.\n const child = spawn(\n process.execPath,\n [argv1, \"update\", \"--quiet\", \"--optional-only\", \"--optional-pkg\", missing],\n {\n detached: true,\n stdio: \"ignore\",\n windowsHide: true,\n env: { ...process.env, GH_ROUTER_MANAGED_BACKGROUND: \"1\" },\n },\n )\n child.on(\"error\", () => {})\n child.unref()\n } catch {\n // Never fatal: the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C5C,KAAK,MAAM,SAAS,QAAQ,MAAM,sBAAsB,GAAG;GACzD,IAAI,OAAO,IAAI,MAAM,IAAI,GAAG;GAC5B,IAAI,MAAM,MAAM,UAAU,mBAAmB;GAC7C,MAAMA,KAAG,GAAG,KAAK,KAAK,MAAM,MAAM,IAAI,GAAG;IAAE,WAAW;IAAM,OAAO;GAAK,CAAC,CAAC,CACvE,WAAW,QAAQ,KAAK,MAAM,IAAI,CAAC,CAAC,CACpC,YAAY,CAEb,CAAC;EACL;CACF;CACA,OAAO;EAAE;EAAS;CAAiB;AACrC;;;;;;;;AAaA,SAAgB,kBAAkB,MAAuC;CACvE,OAAQ,kBAA4C,SAAS,IAAI;AACnE;;AAoBA,IAAI,qBAAqB;;;;;;;;AASzB,SAAgB,wBACd,KACA,QAA4B,QAAQ,KAAK,IAChC;CACT,IAAI,wBAAwB,GAAG,OAAO;CACtC,IAAI,OAAO,UAAU,YAAY,MAAM,WAAW,GAAG,OAAO;CAO5D,IAAI,oBAAoB,OAAO;CAC/B,qBAAqB;CACrB,MAAM,UAAU;CAChB,CAAM,YAAY;EAChB,IAAI;GAIF,MAAM,EAAE,UAAU,MAAM,OAAO;GAO/B,MAAM,QAAQ,MACZ,QAAQ,UACR;IAAC;IAAO;IAAU;IAAW;IAAmB;IAAkB;GAAO,GACzE;IACE,UAAU;IACV,OAAO;IACP,aAAa;IACb,KAAK;KAAE,GAAG,QAAQ;KAAK,8BAA8B;IAAI;GAC3D,CACF;GACA,MAAM,GAAG,eAAe,CAAC,CAAC;GAC1B,MAAM,MAAM;EACd,QAAQ,CAER;CACF,EAAA,CAAG;CACH,OAAO;AACT"}
@@ -1,4 +1,4 @@
1
- import "./stop-gate-hook-CBVLD8iB.js";
1
+ import "./stop-gate-hook-DBOj0TqL.js";
2
2
  import { c as runCommandCapture, o as parseIntEnv } from "./exec-BC0MAnoA.js";
3
3
  // src/lib/orchestration/live-exec.ts
4
4
  /**
@@ -35,4 +35,4 @@ const liveExec = async ({ command, cwd }) => {
35
35
  };
36
36
  export { liveExec as t };
37
37
 
38
- //# sourceMappingURL=orchestration-B93jxrWI.js.map
38
+ //# sourceMappingURL=orchestration-Bto5Nc1Y.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"orchestration-B93jxrWI.js","names":[],"sources":["../src/lib/orchestration/live-exec.ts"],"sourcesContent":["/**\n * Live `ExecFn` for the gate runner — runs the kernel's SEALED gate command in a\n * workspace via the project's Windows-safe exec helper (`runCommandCapture` →\n * `buildExecInvocation`, which handles cmd.exe quoting on Windows). Only the\n * kernel's sealed gate commands flow through here (tests/types/lint/build),\n * never a producer-authored string, so a simple whitespace split into argv is\n * safe for these fixed commands. A command that can't run (spawn error / killed)\n * counts as a non-zero exit, never a throw — the gate runner treats it as\n * not-passed.\n *\n * This is the one piece of the gate engine that touches a real subprocess; it is\n * model-free and cross-platform, so it is exercised directly in CI (unlike the\n * worker/worktree/model adapters, which need the gated E2E harness).\n */\n\nimport { runCommandCapture } from \"~/lib/exec\"\n\nimport { type ExecFn } from \"./gate-runner\"\nimport { parseIntEnv } from \"../exec\"\n\n/** Per-command wall-clock cap so a hung gate command (watch-mode test, a process\n * waiting on stdin, a stale lockfile) is tree-killed instead of hanging the\n * caller forever. Generous (a real typecheck/test/lint can take minutes) but\n * bounded; override with GH_ROUTER_GATE_CMD_TIMEOUT_MS. A timeout kills the\n * command (code null) which the gate runner treats as not-passed. */\nconst CMD_TIMEOUT_MS =\n parseIntEnv(process.env.GH_ROUTER_GATE_CMD_TIMEOUT_MS) ?? 600_000\n\nexport const liveExec: ExecFn = async ({ command, cwd }) => {\n const argv = command.trim().split(/\\s+/).filter(Boolean)\n if (argv.length === 0) return { exitCode: 1 }\n try {\n const r = await runCommandCapture(argv, { cwd, timeoutMs: CMD_TIMEOUT_MS })\n // `code` is null when killed by signal/timeout → treat as a failed gate.\n return { exitCode: r.code ?? 1 }\n } catch {\n return { exitCode: 1 }\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAyBA,MAAM,iBACJ,YAAY,QAAQ,IAAI,6BAA6B,KAAK;AAE5D,MAAa,WAAmB,OAAO,EAAE,SAAS,UAAU;CAC1D,MAAM,OAAO,QAAQ,KAAK,CAAC,CAAC,MAAM,KAAK,CAAC,CAAC,OAAO,OAAO;CACvD,IAAI,KAAK,WAAW,GAAG,OAAO,EAAE,UAAU,EAAE;CAC5C,IAAI;EAGF,OAAO,EAAE,WAAU,MAFH,kBAAkB,MAAM;GAAE;GAAK,WAAW;EAAe,CAAC,EAAA,CAErD,QAAQ,EAAE;CACjC,QAAQ;EACN,OAAO,EAAE,UAAU,EAAE;CACvB;AACF"}
1
+ {"version":3,"file":"orchestration-Bto5Nc1Y.js","names":[],"sources":["../src/lib/orchestration/live-exec.ts"],"sourcesContent":["/**\n * Live `ExecFn` for the gate runner — runs the kernel's SEALED gate command in a\n * workspace via the project's Windows-safe exec helper (`runCommandCapture` →\n * `buildExecInvocation`, which handles cmd.exe quoting on Windows). Only the\n * kernel's sealed gate commands flow through here (tests/types/lint/build),\n * never a producer-authored string, so a simple whitespace split into argv is\n * safe for these fixed commands. A command that can't run (spawn error / killed)\n * counts as a non-zero exit, never a throw — the gate runner treats it as\n * not-passed.\n *\n * This is the one piece of the gate engine that touches a real subprocess; it is\n * model-free and cross-platform, so it is exercised directly in CI (unlike the\n * worker/worktree/model adapters, which need the gated E2E harness).\n */\n\nimport { runCommandCapture } from \"~/lib/exec\"\n\nimport { type ExecFn } from \"./gate-runner\"\nimport { parseIntEnv } from \"../exec\"\n\n/** Per-command wall-clock cap so a hung gate command (watch-mode test, a process\n * waiting on stdin, a stale lockfile) is tree-killed instead of hanging the\n * caller forever. Generous (a real typecheck/test/lint can take minutes) but\n * bounded; override with GH_ROUTER_GATE_CMD_TIMEOUT_MS. A timeout kills the\n * command (code null) which the gate runner treats as not-passed. */\nconst CMD_TIMEOUT_MS =\n parseIntEnv(process.env.GH_ROUTER_GATE_CMD_TIMEOUT_MS) ?? 600_000\n\nexport const liveExec: ExecFn = async ({ command, cwd }) => {\n const argv = command.trim().split(/\\s+/).filter(Boolean)\n if (argv.length === 0) return { exitCode: 1 }\n try {\n const r = await runCommandCapture(argv, { cwd, timeoutMs: CMD_TIMEOUT_MS })\n // `code` is null when killed by signal/timeout → treat as a failed gate.\n return { exitCode: r.code ?? 1 }\n } catch {\n return { exitCode: 1 }\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAyBA,MAAM,iBACJ,YAAY,QAAQ,IAAI,6BAA6B,KAAK;AAE5D,MAAa,WAAmB,OAAO,EAAE,SAAS,UAAU;CAC1D,MAAM,OAAO,QAAQ,KAAK,CAAC,CAAC,MAAM,KAAK,CAAC,CAAC,OAAO,OAAO;CACvD,IAAI,KAAK,WAAW,GAAG,OAAO,EAAE,UAAU,EAAE;CAC5C,IAAI;EAGF,OAAO,EAAE,WAAU,MAFH,kBAAkB,MAAM;GAAE;GAAK,WAAW;EAAe,CAAC,EAAA,CAErD,QAAQ,EAAE;CACjC,QAAQ;EACN,OAAO,EAAE,UAAU,EAAE;CACvB;AACF"}
@@ -0,0 +1,382 @@
1
+ import { c as runCommandCapture, s as resolveExecutable } from "./exec-BC0MAnoA.js";
2
+ import { n as realpathIfPossible, t as isUnderVolatileRoot } from "./volatile-root-DQNNvQ7Z.js";
3
+ import { t as reportManagedDiagnostic } from "./diagnostics-cXjCT_JQ.js";
4
+ import { i as writeFileAtomic, n as readFileWithRetry } from "./atomic-file-Dif1kLKM.js";
5
+ import { f as managedRoot, s as installStatePath } from "./paths-DK_b2ihK.js";
6
+ import { existsSync, readFileSync } from "node:fs";
7
+ import path from "node:path";
8
+ import fs$1 from "node:fs/promises";
9
+ import os from "node:os";
10
+ // src/lib/managed-install/state.ts
11
+ /**
12
+ * `install-state.json`: the managed installer's memory across launches.
13
+ *
14
+ * Three separate concerns share one small file because they are written at the
15
+ * same moments and a second file would be a second thing to keep consistent:
16
+ *
17
+ * - **backoff** (`lastAttemptAt`, `consecutiveFailures`, `nextAttemptAt`,
18
+ * `lastError`), so a failing registry is retried on a ladder instead of on
19
+ * every launch;
20
+ * - **the cached npm cache path**, because `NPM_CONFIG_CACHE` is routinely moved
21
+ * and probing it costs a subprocess on every CLI invocation.
22
+ *
23
+ * There is deliberately no `registry` field. It used to be written here, was
24
+ * never read (`update --check` takes provenance from the version dir's
25
+ * `.installed.json`, which is per-install rather than per-machine), and never
26
+ * cleared — so it reported one old install's registry forever. A field nobody
27
+ * reads is a lie waiting to be trusted; `InstallState` ignores unknown keys, so
28
+ * dropping it cannot break an existing file.
29
+ *
30
+ * Lives here rather than in `install.ts` because `origin.ts` needs it and must not
31
+ * import the installer: the installer pulls `consola`, and `origin.ts` is on the
32
+ * bootstrap's path. Nothing here logs.
33
+ */
34
+ /** Backoff ladder for a failed install, in hours. The last entry repeats. */
35
+ const BACKOFF_HOURS = [
36
+ 1,
37
+ 6,
38
+ 24
39
+ ];
40
+ /** Age floor before an old version may be deleted, in ms. */
41
+ const VERSION_FLOOR_MS = 6048e5;
42
+ /** Abandoned `.staging-*`/`.trash-*` dirs older than this are swept. */
43
+ const TRANSIENT_TTL_MS = 36e5;
44
+ async function readInstallState(kind) {
45
+ try {
46
+ const raw = await readFileWithRetry(installStatePath(kind), { retryMissing: false });
47
+ const parsed = JSON.parse(raw);
48
+ return typeof parsed === "object" && parsed !== null ? parsed : {};
49
+ } catch {
50
+ return {};
51
+ }
52
+ }
53
+ /**
54
+ * Write state. Returns `false` on failure instead of throwing — this file is an
55
+ * optimisation, never a gate — but never silently: a failed write is reported,
56
+ * because the CALLER's next launch is what pays for it. The expensive case is the
57
+ * success patch: if that one fails, the ladder from a previous failure is still
58
+ * on disk, and every launch for the next 1–24 h reports "last attempt failed"
59
+ * on a machine that is perfectly up to date.
60
+ */
61
+ async function writeInstallState(kind, state) {
62
+ try {
63
+ await fs$1.mkdir(managedRoot(kind), { recursive: true });
64
+ await writeFileAtomic(installStatePath(kind), `${JSON.stringify(state, null, 2)}\n`, { mode: 420 });
65
+ return true;
66
+ } catch (err) {
67
+ reportManagedDiagnostic("warn", `managed[${kind}]: could not write ${installStatePath(kind)} (${err instanceof Error ? err.message : String(err)}). The next launch may re-attempt or back off as if the previous attempt had failed.`);
68
+ return false;
69
+ }
70
+ }
71
+ /**
72
+ * Read-modify-write a patch onto the CURRENT on-disk state.
73
+ *
74
+ * Not `writeInstallState({...staleSnapshot, ...patch})`: the callers that hold a
75
+ * snapshot across an install (which can take minutes) would otherwise clobber
76
+ * fields another process — or a `npmProbes()` probe earlier in this one — wrote
77
+ * in the meantime. The observable version of that bug is subtle and expensive: the
78
+ * cache/global-root memo disappears, and every launch pays a 250 ms npm probe
79
+ * again.
80
+ *
81
+ * KNOWN LIMIT, stated because suppressing it would need a real lock on the file:
82
+ * the read and the write are not atomic together, so two processes patching
83
+ * DIFFERENT keys in the same instant can lose one of them ("last writer wins for
84
+ * the whole file"). Callers hold the install lock for anything that must not be
85
+ * lost, and every other writer writes a self-healing value: a lost `npmProbe` is
86
+ * re-derived on the next launch, a lost `lastOrigin` is cosmetic. Do not add a
87
+ * field whose loss changes a decision without also holding the lock.
88
+ */
89
+ async function patchInstallState(kind, patch) {
90
+ const next = {
91
+ ...await readInstallState(kind),
92
+ ...patch
93
+ };
94
+ for (const key of Object.keys(patch)) if (patch[key] === void 0) delete next[key];
95
+ return writeInstallState(kind, next);
96
+ }
97
+ /**
98
+ * Whether the backoff window has expired.
99
+ *
100
+ * `nextAttemptAt` is written BEFORE an attempt (optimistic), so two launches
101
+ * racing on the same failing registry do not both hammer npm.
102
+ */
103
+ function installAllowedNow(state, now = Date.now()) {
104
+ if (!state.nextAttemptAt) return true;
105
+ const next = new Date(state.nextAttemptAt).getTime();
106
+ if (Number.isNaN(next)) return true;
107
+ return now >= next;
108
+ }
109
+ /**
110
+ * Whether an attempt may start, distinguishing a RESERVATION from a BACKOFF.
111
+ *
112
+ * `nextAttemptAt` is written optimistically before every attempt so two launches
113
+ * cannot both run npm, and it is also the backoff ladder's output. Those two
114
+ * meanings must not be conflated: a reservation (`consecutiveFailures` still 0)
115
+ * is not evidence of failure, so treating it as one makes an explicit
116
+ * `github-router update` issued right after a launch that merely *scheduled* an
117
+ * install print "last attempt failed (unknown error)" and do nothing. The install
118
+ * lock — not this window — is what serialises attempts, so re-attempting a
119
+ * reservation is cheap: the loser exits immediately.
120
+ *
121
+ * A crash mid-install also leaves a bare reservation, and retrying it is the
122
+ * correct repair (the leftover `.staging-*` is swept by GC).
123
+ */
124
+ function mayAttemptNow(state, now = Date.now()) {
125
+ if ((state.consecutiveFailures ?? 0) === 0) return true;
126
+ return installAllowedNow(state, now);
127
+ }
128
+ function nextAttemptAtFor(failures, now = Date.now()) {
129
+ const index = Math.min(Math.max(failures, 1), BACKOFF_HOURS.length) - 1;
130
+ const hours = BACKOFF_HOURS[index] ?? 24;
131
+ return new Date(now + hours * 60 * 6e4).toISOString();
132
+ }
133
+ // src/lib/managed-install/origin.ts
134
+ /**
135
+ * Where did this process start from?
136
+ *
137
+ * The bootstrap (`dist/bin.js`) has to answer one question before it does
138
+ * anything else: *is the tree I am running from a disposable copy?* If it is
139
+ * (`npx`, `bunx`), adopting the managed install is the whole point of the
140
+ * feature. If it is not (`npm i -g`, a git checkout, or already managed), the
141
+ * bootstrap must be a pure pass-through — user decision 4 is explicit that a
142
+ * global install stays its own owner and must never be duplicated.
143
+ *
144
+ * Classification is deliberately **positive** and **fail-safe**: each branch
145
+ * needs evidence (a realpath under a known root, a `.git` marker), and the
146
+ * default answer is `unknown`, which every caller treats as `source` — no adopt,
147
+ * no install, no background work. A wrong `npx` answer costs the user a 66 MB
148
+ * install they did not want; a wrong `source` answer costs nothing.
149
+ *
150
+ * Cost matters here in a way it does not elsewhere: this runs on EVERY CLI
151
+ * invocation. So every probe is bounded, cached in-process, and the two that
152
+ * spawn (`npm root -g`, `npm config get cache`) are cached across runs in
153
+ * `install-state.json` — `NPM_CONFIG_CACHE` moving is rare enough that one
154
+ * stale read is worth avoiding 300 ms on every launch.
155
+ */
156
+ /** Timeout for the two npm probes. A cold `npm root -g` can take ~300 ms. */
157
+ const PROBE_TIMEOUT_MS = 5e3;
158
+ let cached;
159
+ /** Walk up from `entry` to the `github-router` package root. */
160
+ function findPackageRoot(entry) {
161
+ if (typeof entry !== "string" || entry.length === 0) return void 0;
162
+ let cur = path.dirname(realpathIfPossible(entry));
163
+ for (let i = 0; i < 10; i++) {
164
+ try {
165
+ const pkg = JSON.parse(readFileSync(path.join(cur, "package.json"), "utf8"));
166
+ if (pkg.name === "github-router" || pkg.name === "@animeshkundu/github-router") return cur;
167
+ } catch {}
168
+ const parent = path.dirname(cur);
169
+ if (parent === cur) break;
170
+ cur = parent;
171
+ }
172
+ }
173
+ /**
174
+ * Normalized, separator-trailing form so prefix tests cannot match `/foo` in
175
+ * `/foobar`.
176
+ *
177
+ * Lowercased on Windows: NTFS is case-insensitive, so `C:\Users\X\AppData\npm`
178
+ * (what `npm root -g` reports) and `c:\users\x\appdata\npm\node_modules\…`
179
+ * (what a launcher spawned from a differently-cased PATH entry sees) are the same
180
+ * directory and must compare equal. A case-sensitive compare would classify a
181
+ * global install as `unknown` — and `unknown` means "never adopt, never install",
182
+ * so the failure is a silent absence of the feature on that machine.
183
+ */
184
+ function asPrefix(dir) {
185
+ const resolved = realpathIfPossible(dir);
186
+ const withSep = resolved.endsWith(path.sep) ? resolved : `${resolved}${path.sep}`;
187
+ return process.platform === "win32" ? withSep.toLowerCase() : withSep;
188
+ }
189
+ function normalizeForCompare(value) {
190
+ return process.platform === "win32" ? value.toLowerCase() : value;
191
+ }
192
+ function isUnder(target, root) {
193
+ if (!root) return false;
194
+ const prefix = asPrefix(root);
195
+ for (const candidate of [target, realpathIfPossible(target)]) {
196
+ if (normalizeForCompare(candidate).startsWith(prefix)) return true;
197
+ if (normalizeForCompare(realpathIfPossible(candidate)).startsWith(prefix)) return true;
198
+ }
199
+ return false;
200
+ }
201
+ /** One `npm config get <key>` probe, bounded and never throwing. */
202
+ async function npmConfigValue(args) {
203
+ const npmPath = resolveExecutable("npm");
204
+ if (!npmPath) return null;
205
+ try {
206
+ const { stdout, code } = await runCommandCapture([npmPath, ...args], { timeoutMs: PROBE_TIMEOUT_MS });
207
+ if (code !== 0) return null;
208
+ const value = stdout.trim().split(/\r?\n/).pop()?.trim();
209
+ return value && path.isAbsolute(value) ? value : null;
210
+ } catch {
211
+ return null;
212
+ }
213
+ }
214
+ /**
215
+ * Resolve (and memoise) both npm probes.
216
+ *
217
+ * Cached in-process for the life of this process and across runs in
218
+ * `install-state.json`, keyed by `process.execPath`. The key matters: under nvm
219
+ * the global root IS per-node-version, so an unkeyed cache would point the next
220
+ * launch at a tree that node version no longer owns.
221
+ *
222
+ * One probe run per cache miss, not one per query: `classifyEntry` needs both,
223
+ * and each is a ~250 ms subprocess.
224
+ */
225
+ async function npmProbes(kind = "self") {
226
+ const runtime = process.execPath;
227
+ const cached = (await readInstallState(kind)).npmProbe;
228
+ if (cached?.runtime === runtime && cached.globalRoot && cached.cacheRoot) return {
229
+ globalRoot: cached.globalRoot,
230
+ cacheRoot: cached.cacheRoot
231
+ };
232
+ const [globalRoot, cacheRoot] = await Promise.all([cached?.runtime === runtime && cached.globalRoot ? Promise.resolve(cached.globalRoot) : npmConfigValue(["root", "-g"]), cached?.runtime === runtime && cached.cacheRoot ? Promise.resolve(cached.cacheRoot) : npmConfigValue([
233
+ "config",
234
+ "get",
235
+ "cache"
236
+ ])]);
237
+ if (globalRoot || cacheRoot) await patchInstallState(kind, {
238
+ ...cacheRoot ? { npmCache: cacheRoot } : {},
239
+ npmProbe: {
240
+ runtime,
241
+ ...globalRoot ? { globalRoot } : {},
242
+ ...cacheRoot ? { cacheRoot } : {}
243
+ }
244
+ });
245
+ return {
246
+ globalRoot,
247
+ cacheRoot
248
+ };
249
+ }
250
+ /**
251
+ * Classify this process's install origin.
252
+ *
253
+ * Order is significant and cheapest-first:
254
+ *
255
+ * 1. `managed` — a realpath under our own version dir. This must come first and
256
+ * short-circuit the pointer read, or a managed payload would adopt itself.
257
+ * 2. `npm-global` — under `npm root -g`. User decision 4: never duplicated.
258
+ * 3. `npx` — under `<npm cache>/_npx`.
259
+ * 4. `source` — a `.git` beside the package root. Deliberately ahead of the
260
+ * volatility heuristic: a checkout in `/tmp` is still the developer's code.
261
+ * 5. `bunx` — under a `.bunx-*` root, or any other volatile temp root.
262
+ * 6. `unknown` — everything else, including "the package root could not be
263
+ * found". Treated exactly like `source` by every caller.
264
+ */
265
+ async function classifyOrigin() {
266
+ if (cached) return cached;
267
+ const info = await classifyEntry(process.argv[1]);
268
+ cached = info;
269
+ return info;
270
+ }
271
+ /**
272
+ * Classify an arbitrary entry path.
273
+ *
274
+ * Extracted from `classifyOrigin` so the matrix is testable without respawning
275
+ * the test runner with a doctored argv: the classification is pure with respect
276
+ * to `entry`, and the only impurity (two npm probes) is already injectable via
277
+ * the process PATH and the install-state cache.
278
+ */
279
+ async function classifyEntry(entry) {
280
+ if (typeof entry !== "string" || entry.length === 0) return {
281
+ origin: "unknown",
282
+ detail: "no argv[1]; cannot tell where this code lives"
283
+ };
284
+ const packageRoot = findPackageRoot(entry);
285
+ const probe = packageRoot ?? path.dirname(realpathIfPossible(entry));
286
+ if (isUnder(probe, managedRootOf("self")) || isUnder(probe, managedRootOf("pi"))) return {
287
+ origin: "managed",
288
+ packageRoot,
289
+ detail: `running from the managed tree (${probe})`
290
+ };
291
+ const { globalRoot, cacheRoot } = await npmProbes();
292
+ if (globalRoot && isUnder(probe, globalRoot)) return {
293
+ origin: "npm-global",
294
+ packageRoot,
295
+ detail: `running from the global install ${globalRoot}`
296
+ };
297
+ if (cacheRoot && isUnder(probe, path.join(cacheRoot, "_npx"))) return {
298
+ origin: "npx",
299
+ packageRoot,
300
+ detail: `running from the npx cache ${path.join(cacheRoot, "_npx")}`
301
+ };
302
+ if (hasGitAncestor(packageRoot ?? probe)) return {
303
+ origin: "source",
304
+ packageRoot,
305
+ detail: `running from a git checkout (${packageRoot ?? probe})`
306
+ };
307
+ if (isUnderBunCache(probe)) return {
308
+ origin: "bunx",
309
+ packageRoot,
310
+ detail: `running from the bun cache (${BUN_CACHE_HINT})`
311
+ };
312
+ if (probe.includes(`${path.sep}.bunx-`) || isUnderVolatileRoot(probe)) return {
313
+ origin: "bunx",
314
+ packageRoot,
315
+ detail: `running from a volatile bunx/temp tree (${probe})`
316
+ };
317
+ reportManagedDiagnostic("debug", `managed: unrecognised install origin at ${probe}`);
318
+ return {
319
+ origin: "unknown",
320
+ packageRoot,
321
+ detail: `unrecognised origin (${probe})`
322
+ };
323
+ }
324
+ /**
325
+ * Whether a `.git` sits at or above `dir`.
326
+ *
327
+ * "Above" matters: in a checkout the package.json IS the repo root, but a
328
+ * monorepo/workspace has the package in a subdirectory with `.git` above it, and
329
+ * a `git worktree` checkout puts `.git` in the parent with a pointer file. All
330
+ * three are the developer's own code.
331
+ *
332
+ * Bounded and non-recursive past the filesystem root; `existsSync` rather than a
333
+ * stat-only check so a `.git` FILE (worktree/submodule) counts too.
334
+ */
335
+ function hasGitAncestor(dir) {
336
+ let cur = dir;
337
+ for (let i = 0; i < 6; i++) {
338
+ if (existsSync(path.join(cur, ".git"))) return true;
339
+ const parent = path.dirname(cur);
340
+ if (parent === cur) return false;
341
+ cur = parent;
342
+ }
343
+ return false;
344
+ }
345
+ /** Where a `bunx` tree lands, for the diagnostic string. */
346
+ const BUN_CACHE_HINT = "$BUN_INSTALL/cache (or ~/.bun/install/cache)";
347
+ /**
348
+ * Whether `dir` is inside bun's shared install cache.
349
+ *
350
+ * Both the cache root and its parent are tested, because bun's layout has been
351
+ * `install/cache/<pkg>@<ver>@@@1` and, in older versions, a sibling directory.
352
+ * Case-insensitive on Windows for the same reason `asPrefix` is.
353
+ */
354
+ function isUnderBunCache(dir) {
355
+ const candidates = [process.env.BUN_INSTALL, process.env.BUN_INSTALL_CACHE_DIR].filter((value) => typeof value === "string" && value.length > 0);
356
+ const roots = /* @__PURE__ */ new Set();
357
+ for (const base of candidates) {
358
+ roots.add(path.join(base, "cache"));
359
+ roots.add(path.join(base, "install", "cache"));
360
+ }
361
+ const home = os.homedir();
362
+ if (home) roots.add(path.join(home, ".bun", "install", "cache"));
363
+ for (const root of roots) if (isUnder(dir, root) || isUnder(realpathIfPossible(dir), realpathIfPossible(root))) return true;
364
+ return false;
365
+ }
366
+ function managedRootOf(kind) {
367
+ return managedRoot(kind);
368
+ }
369
+ /** Human name for the origin, for the `update`/`--debug` output. */
370
+ function describeOrigin(origin) {
371
+ switch (origin) {
372
+ case "managed": return "managed install";
373
+ case "npm-global": return "npm global install";
374
+ case "npx": return "npx cache";
375
+ case "bunx": return "bunx temporary tree";
376
+ case "source": return "source checkout";
377
+ case "unknown": return "unrecognised";
378
+ }
379
+ }
380
+ export { TRANSIENT_TTL_MS as a, nextAttemptAtFor as c, findPackageRoot as i, patchInstallState as l, classifyOrigin as n, VERSION_FLOOR_MS as o, describeOrigin as r, mayAttemptNow as s, classifyEntry as t, readInstallState as u };
381
+
382
+ //# sourceMappingURL=origin-BXtpcKP9.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"origin-BXtpcKP9.js","names":["fs"],"sources":["../src/lib/managed-install/state.ts","../src/lib/managed-install/origin.ts"],"sourcesContent":["/**\n * `install-state.json`: the managed installer's memory across launches.\n *\n * Three separate concerns share one small file because they are written at the\n * same moments and a second file would be a second thing to keep consistent:\n *\n * - **backoff** (`lastAttemptAt`, `consecutiveFailures`, `nextAttemptAt`,\n * `lastError`), so a failing registry is retried on a ladder instead of on\n * every launch;\n * - **the cached npm cache path**, because `NPM_CONFIG_CACHE` is routinely moved\n * and probing it costs a subprocess on every CLI invocation.\n *\n * There is deliberately no `registry` field. It used to be written here, was\n * never read (`update --check` takes provenance from the version dir's\n * `.installed.json`, which is per-install rather than per-machine), and never\n * cleared — so it reported one old install's registry forever. A field nobody\n * reads is a lie waiting to be trusted; `InstallState` ignores unknown keys, so\n * dropping it cannot break an existing file.\n *\n * Lives here rather than in `install.ts` because `origin.ts` needs it and must not\n * import the installer: the installer pulls `consola`, and `origin.ts` is on the\n * bootstrap's path. Nothing here logs.\n */\n\nimport fs from \"node:fs/promises\"\nimport path from \"node:path\"\n\nimport { readFileWithRetry, writeFileAtomic } from \"../atomic-file\"\nimport { reportManagedDiagnostic } from \"./diagnostics\"\nimport { type ManagedKind, installStatePath, managedRoot } from \"./paths\"\n\n/** Backoff ladder for a failed install, in hours. The last entry repeats. */\nexport const BACKOFF_HOURS = [1, 6, 24] as const\n\n/** Version dirs kept besides the pointer's (newest first). */\nexport const KEEP_VERSIONS = 2\n\n/** Age floor before an old version may be deleted, in ms. */\nexport const VERSION_FLOOR_MS = 7 * 24 * 60 * 60_000\n\n/** Abandoned `.staging-*`/`.trash-*` dirs older than this are swept. */\nexport const TRANSIENT_TTL_MS = 60 * 60_000\n\nexport interface InstallState {\n lastAttemptAt?: string\n lastSuccessAt?: string\n consecutiveFailures?: number\n nextAttemptAt?: string\n lastError?: string\n /** Cached `npm config get cache`, because `NPM_CONFIG_CACHE` moves routinely. */\n npmCache?: string\n /**\n * Cached answers from the two npm probes, keyed by the RUNTIME that produced\n * them.\n *\n * Keyed, not plain, because both answers are runtime-dependent under a version\n * manager: `npm root -g` is `~/.nvm/versions/node/<v>/lib/node_modules`, so a\n * bare cached string would send an nvm user's next launch to the previous\n * node's global tree. `process.execPath` changes exactly when that matters.\n */\n npmProbe?: {\n runtime: string\n globalRoot?: string\n cacheRoot?: string\n }\n /** Origin classification result of the last launch, for diagnostics. */\n lastOrigin?: string\n}\n\nexport async function readInstallState(kind: ManagedKind): Promise<InstallState> {\n try {\n const raw = await readFileWithRetry(installStatePath(kind), { retryMissing: false })\n const parsed = JSON.parse(raw) as InstallState\n return typeof parsed === \"object\" && parsed !== null ? parsed : {}\n } catch {\n return {}\n }\n}\n\n/**\n * Write state. Returns `false` on failure instead of throwing — this file is an\n * optimisation, never a gate — but never silently: a failed write is reported,\n * because the CALLER's next launch is what pays for it. The expensive case is the\n * success patch: if that one fails, the ladder from a previous failure is still\n * on disk, and every launch for the next 1–24 h reports \"last attempt failed\"\n * on a machine that is perfectly up to date.\n */\nexport async function writeInstallState(kind: ManagedKind, state: InstallState): Promise<boolean> {\n try {\n await fs.mkdir(managedRoot(kind), { recursive: true })\n await writeFileAtomic(installStatePath(kind), `${JSON.stringify(state, null, 2)}\\n`, {\n mode: 0o644,\n })\n return true\n } catch (err) {\n reportManagedDiagnostic(\n \"warn\",\n `managed[${kind}]: could not write ${installStatePath(kind)} (${\n err instanceof Error ? err.message : String(err)\n }). The next launch may re-attempt or back off as if the previous attempt had failed.`,\n )\n return false\n }\n}\n\n/**\n * Read-modify-write a patch onto the CURRENT on-disk state.\n *\n * Not `writeInstallState({...staleSnapshot, ...patch})`: the callers that hold a\n * snapshot across an install (which can take minutes) would otherwise clobber\n * fields another process — or a `npmProbes()` probe earlier in this one — wrote\n * in the meantime. The observable version of that bug is subtle and expensive: the\n * cache/global-root memo disappears, and every launch pays a 250 ms npm probe\n * again.\n *\n * KNOWN LIMIT, stated because suppressing it would need a real lock on the file:\n * the read and the write are not atomic together, so two processes patching\n * DIFFERENT keys in the same instant can lose one of them (\"last writer wins for\n * the whole file\"). Callers hold the install lock for anything that must not be\n * lost, and every other writer writes a self-healing value: a lost `npmProbe` is\n * re-derived on the next launch, a lost `lastOrigin` is cosmetic. Do not add a\n * field whose loss changes a decision without also holding the lock.\n */\nexport async function patchInstallState(\n kind: ManagedKind,\n patch: Partial<InstallState>,\n): Promise<boolean> {\n const current = await readInstallState(kind)\n const next: InstallState = { ...current, ...patch }\n // An explicit `undefined` in the patch means DELETE, the same convention as\n // `buildNpmEnv`'s overrides: `nextAttemptAt: undefined` clears the backoff.\n for (const key of Object.keys(patch) as Array<keyof InstallState>) {\n if (patch[key] === undefined) delete next[key]\n }\n return writeInstallState(kind, next)\n}\n\n/**\n * Whether the backoff window has expired.\n *\n * `nextAttemptAt` is written BEFORE an attempt (optimistic), so two launches\n * racing on the same failing registry do not both hammer npm.\n */\nexport function installAllowedNow(state: InstallState, now = Date.now()): boolean {\n if (!state.nextAttemptAt) return true\n const next = new Date(state.nextAttemptAt).getTime()\n if (Number.isNaN(next)) return true\n return now >= next\n}\n\n/**\n * Whether an attempt may start, distinguishing a RESERVATION from a BACKOFF.\n *\n * `nextAttemptAt` is written optimistically before every attempt so two launches\n * cannot both run npm, and it is also the backoff ladder's output. Those two\n * meanings must not be conflated: a reservation (`consecutiveFailures` still 0)\n * is not evidence of failure, so treating it as one makes an explicit\n * `github-router update` issued right after a launch that merely *scheduled* an\n * install print \"last attempt failed (unknown error)\" and do nothing. The install\n * lock — not this window — is what serialises attempts, so re-attempting a\n * reservation is cheap: the loser exits immediately.\n *\n * A crash mid-install also leaves a bare reservation, and retrying it is the\n * correct repair (the leftover `.staging-*` is swept by GC).\n */\nexport function mayAttemptNow(state: InstallState, now = Date.now()): boolean {\n if ((state.consecutiveFailures ?? 0) === 0) return true\n return installAllowedNow(state, now)\n}\n\nexport function nextAttemptAtFor(failures: number, now = Date.now()): string {\n const index = Math.min(Math.max(failures, 1), BACKOFF_HOURS.length) - 1\n const hours = BACKOFF_HOURS[index] ?? 24\n return new Date(now + hours * 60 * 60_000).toISOString()\n}\n\n/** Dotted-path helpers for tests that need the file's location. */\nexport function installStateFile(kind: ManagedKind): string {\n return path.join(managedRoot(kind), \"install-state.json\")\n}\n","/**\n * Where did this process start from?\n *\n * The bootstrap (`dist/bin.js`) has to answer one question before it does\n * anything else: *is the tree I am running from a disposable copy?* If it is\n * (`npx`, `bunx`), adopting the managed install is the whole point of the\n * feature. If it is not (`npm i -g`, a git checkout, or already managed), the\n * bootstrap must be a pure pass-through — user decision 4 is explicit that a\n * global install stays its own owner and must never be duplicated.\n *\n * Classification is deliberately **positive** and **fail-safe**: each branch\n * needs evidence (a realpath under a known root, a `.git` marker), and the\n * default answer is `unknown`, which every caller treats as `source` — no adopt,\n * no install, no background work. A wrong `npx` answer costs the user a 66 MB\n * install they did not want; a wrong `source` answer costs nothing.\n *\n * Cost matters here in a way it does not elsewhere: this runs on EVERY CLI\n * invocation. So every probe is bounded, cached in-process, and the two that\n * spawn (`npm root -g`, `npm config get cache`) are cached across runs in\n * `install-state.json` — `NPM_CONFIG_CACHE` moving is rare enough that one\n * stale read is worth avoiding 300 ms on every launch.\n */\n\nimport { existsSync, readFileSync } from \"node:fs\"\nimport os from \"node:os\"\nimport path from \"node:path\"\n\nimport { resolveExecutable, runCommandCapture } from \"../exec\"\nimport { isUnderVolatileRoot, realpathIfPossible } from \"../volatile-root\"\nimport { reportManagedDiagnostic } from \"./diagnostics\"\nimport { patchInstallState, readInstallState } from \"./state\"\nimport { type ManagedKind, appDir, managedRoot } from \"./paths\"\n\nexport type InstallOrigin = \"managed\" | \"npm-global\" | \"npx\" | \"bunx\" | \"source\" | \"unknown\"\n\nexport interface OriginInfo {\n origin: InstallOrigin\n /** Realpath of the running package root, when it could be determined. */\n packageRoot?: string\n /** One-line reason, for `--debug` and for the \"why did nothing happen\" question. */\n detail: string\n}\n\n/** Timeout for the two npm probes. A cold `npm root -g` can take ~300 ms. */\nconst PROBE_TIMEOUT_MS = 5000\n\nlet cached: OriginInfo | undefined\n\n/** @internal — reset module state between test cases. */\nexport function __resetOriginForTests(): void {\n cached = undefined\n}\n\n/** The running package root: the directory holding `package.json` for this code. */\nexport function currentPackageRoot(): string | undefined {\n return findPackageRoot(process.argv[1])\n}\n\n/** Walk up from `entry` to the `github-router` package root. */\nexport function findPackageRoot(entry: string | undefined): string | undefined {\n if (typeof entry !== \"string\" || entry.length === 0) return undefined\n let cur = path.dirname(realpathIfPossible(entry))\n for (let i = 0; i < 10; i++) {\n try {\n const pkg = JSON.parse(readFileSync(path.join(cur, \"package.json\"), \"utf8\")) as {\n name?: unknown\n }\n // Exact names, not a substring: `not-github-router` and\n // `@someone/github-router-helper` are different packages, and adopting\n // based on a substring would let a look-alike tree claim the origin.\n if (pkg.name === \"github-router\" || pkg.name === \"@animeshkundu/github-router\") return cur\n } catch {\n // Not here; keep walking.\n }\n const parent = path.dirname(cur)\n if (parent === cur) break\n cur = parent\n }\n return undefined\n}\n\n/**\n * Normalized, separator-trailing form so prefix tests cannot match `/foo` in\n * `/foobar`.\n *\n * Lowercased on Windows: NTFS is case-insensitive, so `C:\\Users\\X\\AppData\\npm`\n * (what `npm root -g` reports) and `c:\\users\\x\\appdata\\npm\\node_modules\\…`\n * (what a launcher spawned from a differently-cased PATH entry sees) are the same\n * directory and must compare equal. A case-sensitive compare would classify a\n * global install as `unknown` — and `unknown` means \"never adopt, never install\",\n * so the failure is a silent absence of the feature on that machine.\n */\nfunction asPrefix(dir: string): string {\n const resolved = realpathIfPossible(dir)\n const withSep = resolved.endsWith(path.sep) ? resolved : `${resolved}${path.sep}`\n return process.platform === \"win32\" ? withSep.toLowerCase() : withSep\n}\n\nfunction normalizeForCompare(value: string): string {\n return process.platform === \"win32\" ? value.toLowerCase() : value\n}\n\nfunction isUnder(target: string, root: string): boolean {\n if (!root) return false\n const prefix = asPrefix(root)\n // Resolve both sides: macOS reports /var/... while a process sees\n // /private/var/..., and a symlinked APP_DIR is normal on Linux setups.\n for (const candidate of [target, realpathIfPossible(target)]) {\n if (normalizeForCompare(candidate).startsWith(prefix)) return true\n if (normalizeForCompare(realpathIfPossible(candidate)).startsWith(prefix)) return true\n }\n return false\n}\n\n/** One `npm config get <key>` probe, bounded and never throwing. */\nasync function npmConfigValue(args: Array<string>): Promise<string | null> {\n const npmPath = resolveExecutable(\"npm\")\n if (!npmPath) return null\n try {\n const { stdout, code } = await runCommandCapture([npmPath, ...args], {\n timeoutMs: PROBE_TIMEOUT_MS,\n })\n if (code !== 0) return null\n const value = stdout.trim().split(/\\r?\\n/).pop()?.trim()\n return value && path.isAbsolute(value) ? value : null\n } catch {\n return null\n }\n}\n\ninterface NpmProbes {\n globalRoot: string | null\n cacheRoot: string | null\n}\n\n/**\n * Resolve (and memoise) both npm probes.\n *\n * Cached in-process for the life of this process and across runs in\n * `install-state.json`, keyed by `process.execPath`. The key matters: under nvm\n * the global root IS per-node-version, so an unkeyed cache would point the next\n * launch at a tree that node version no longer owns.\n *\n * One probe run per cache miss, not one per query: `classifyEntry` needs both,\n * and each is a ~250 ms subprocess.\n */\nasync function npmProbes(kind: ManagedKind = \"self\"): Promise<NpmProbes> {\n const runtime = process.execPath\n const state = await readInstallState(kind)\n const cached = state.npmProbe\n if (cached?.runtime === runtime && cached.globalRoot && cached.cacheRoot) {\n return { globalRoot: cached.globalRoot, cacheRoot: cached.cacheRoot }\n }\n const [globalRoot, cacheRoot] = await Promise.all([\n cached?.runtime === runtime && cached.globalRoot\n ? Promise.resolve(cached.globalRoot)\n : npmConfigValue([\"root\", \"-g\"]),\n cached?.runtime === runtime && cached.cacheRoot\n ? Promise.resolve(cached.cacheRoot)\n : npmConfigValue([\"config\", \"get\", \"cache\"]),\n ])\n if (globalRoot || cacheRoot) {\n await patchInstallState(kind, {\n // Keep the flat field for older readers/messages.\n ...(cacheRoot ? { npmCache: cacheRoot } : {}),\n npmProbe: {\n runtime,\n ...(globalRoot ? { globalRoot } : {}),\n ...(cacheRoot ? { cacheRoot } : {}),\n },\n })\n }\n return { globalRoot, cacheRoot }\n}\n\n/**\n * Classify this process's install origin.\n *\n * Order is significant and cheapest-first:\n *\n * 1. `managed` — a realpath under our own version dir. This must come first and\n * short-circuit the pointer read, or a managed payload would adopt itself.\n * 2. `npm-global` — under `npm root -g`. User decision 4: never duplicated.\n * 3. `npx` — under `<npm cache>/_npx`.\n * 4. `source` — a `.git` beside the package root. Deliberately ahead of the\n * volatility heuristic: a checkout in `/tmp` is still the developer's code.\n * 5. `bunx` — under a `.bunx-*` root, or any other volatile temp root.\n * 6. `unknown` — everything else, including \"the package root could not be\n * found\". Treated exactly like `source` by every caller.\n */\nexport async function classifyOrigin(): Promise<OriginInfo> {\n if (cached) return cached\n const info = await classifyEntry(process.argv[1])\n cached = info\n return info\n}\n\n/**\n * Classify an arbitrary entry path.\n *\n * Extracted from `classifyOrigin` so the matrix is testable without respawning\n * the test runner with a doctored argv: the classification is pure with respect\n * to `entry`, and the only impurity (two npm probes) is already injectable via\n * the process PATH and the install-state cache.\n */\nexport async function classifyEntry(entry: string | undefined): Promise<OriginInfo> {\n if (typeof entry !== \"string\" || entry.length === 0) {\n return { origin: \"unknown\", detail: \"no argv[1]; cannot tell where this code lives\" }\n }\n const packageRoot = findPackageRoot(entry)\n const probe = packageRoot ?? path.dirname(realpathIfPossible(entry))\n\n if (isUnder(probe, managedRootOf(\"self\")) || isUnder(probe, managedRootOf(\"pi\"))) {\n return { origin: \"managed\", packageRoot, detail: `running from the managed tree (${probe})` }\n }\n\n const { globalRoot, cacheRoot } = await npmProbes()\n if (globalRoot && isUnder(probe, globalRoot)) {\n return {\n origin: \"npm-global\",\n packageRoot,\n detail: `running from the global install ${globalRoot}`,\n }\n }\n\n if (cacheRoot && isUnder(probe, path.join(cacheRoot, \"_npx\"))) {\n return { origin: \"npx\", packageRoot, detail: `running from the npx cache ${path.join(cacheRoot, \"_npx\")}` }\n }\n\n // A `.git` beside the package root is STRONGER evidence than \"this path is in\n // a temp dir\": a developer who cloned the repo into /tmp and runs it there is\n // running their own code and must not be silently switched onto a managed\n // build. So source is checked before the volatility heuristic.\n if (hasGitAncestor(packageRoot ?? probe)) {\n return { origin: \"source\", packageRoot, detail: `running from a git checkout (${packageRoot ?? probe})` }\n }\n\n // `bunx` no longer materialises a `.bunx-*` temp tree: current bun resolves\n // into its shared cache (`~/.bun/install/cache`, or `$BUN_INSTALL/cache`) and\n // executes from there. `isUnderVolatileRoot` does NOT cover that directory —\n // it is under $HOME, not the temp dir — so without this the most common modern\n // `bunx github-router` classified as `unknown`, which means \"never adopt, never\n // install\": the managed layer simply never engaged for bun users.\n if (isUnderBunCache(probe)) {\n return { origin: \"bunx\", packageRoot, detail: `running from the bun cache (${BUN_CACHE_HINT})` }\n }\n\n if (probe.includes(`${path.sep}.bunx-`) || isUnderVolatileRoot(probe)) {\n return { origin: \"bunx\", packageRoot, detail: `running from a volatile bunx/temp tree (${probe})` }\n }\n\n // A tree we cannot place. Refusing to act is the safe direction: the worst\n // outcome is that the managed install simply does not engage.\n reportManagedDiagnostic(\"debug\", `managed: unrecognised install origin at ${probe}`)\n return { origin: \"unknown\", packageRoot, detail: `unrecognised origin (${probe})` }\n}\n\n/**\n * Whether a `.git` sits at or above `dir`.\n *\n * \"Above\" matters: in a checkout the package.json IS the repo root, but a\n * monorepo/workspace has the package in a subdirectory with `.git` above it, and\n * a `git worktree` checkout puts `.git` in the parent with a pointer file. All\n * three are the developer's own code.\n *\n * Bounded and non-recursive past the filesystem root; `existsSync` rather than a\n * stat-only check so a `.git` FILE (worktree/submodule) counts too.\n */\nfunction hasGitAncestor(dir: string): boolean {\n let cur = dir\n for (let i = 0; i < 6; i++) {\n if (existsSync(path.join(cur, \".git\"))) return true\n const parent = path.dirname(cur)\n if (parent === cur) return false\n cur = parent\n }\n return false\n}\n\n/** Where a `bunx` tree lands, for the diagnostic string. */\nconst BUN_CACHE_HINT = \"$BUN_INSTALL/cache (or ~/.bun/install/cache)\"\n\n/**\n * Whether `dir` is inside bun's shared install cache.\n *\n * Both the cache root and its parent are tested, because bun's layout has been\n * `install/cache/<pkg>@<ver>@@@1` and, in older versions, a sibling directory.\n * Case-insensitive on Windows for the same reason `asPrefix` is.\n */\nfunction isUnderBunCache(dir: string): boolean {\n const candidates = [process.env.BUN_INSTALL, process.env.BUN_INSTALL_CACHE_DIR].filter(\n (value): value is string => typeof value === \"string\" && value.length > 0,\n )\n const roots = new Set<string>()\n for (const base of candidates) {\n roots.add(path.join(base, \"cache\"))\n roots.add(path.join(base, \"install\", \"cache\"))\n }\n const home = os.homedir()\n if (home) {\n // The CACHE only, deliberately. `~/.bun/install/global` is where `bun add -g`\n // puts a user's own global install, and user decision 4 is that a global\n // install is never duplicated — classifying it as `bunx` would silently swap\n // the binary a user installed for a managed one.\n roots.add(path.join(home, \".bun\", \"install\", \"cache\"))\n }\n for (const root of roots) {\n // Both spellings, like every other prefix test in this file: a caller may\n // hand us a resolved path and a PATH/cache root that is not (or vice versa).\n if (isUnder(dir, root) || isUnder(realpathIfPossible(dir), realpathIfPossible(root))) return true\n }\n return false\n}\n\nfunction managedRootOf(kind: ManagedKind): string {\n return managedRoot(kind)\n}\n\n/**\n * Whether this origin should adopt an existing managed install.\n *\n * Kept as its own function so the policy is one line to read and one line to\n * change: only the disposable-copy origins adopt. `npm-global` and `source`\n * never do (their trees are the owner's), and `unknown` never does.\n */\nexport function shouldAdoptFor(origin: InstallOrigin): boolean {\n return origin === \"npx\" || origin === \"bunx\"\n}\n\n/** Whether this origin should kick off a managed install in the background. */\nexport function shouldInstallFor(origin: InstallOrigin): boolean {\n return origin === \"npx\" || origin === \"bunx\"\n}\n\n/** Human name for the origin, for the `update`/`--debug` output. */\nexport function describeOrigin(origin: InstallOrigin): string {\n switch (origin) {\n case \"managed\":\n return \"managed install\"\n case \"npm-global\":\n return \"npm global install\"\n case \"npx\":\n return \"npx cache\"\n case \"bunx\":\n return \"bunx temporary tree\"\n case \"source\":\n return \"source checkout\"\n case \"unknown\":\n return \"unrecognised\"\n }\n}\n\n/** The app dir, exposed for messages. */\nexport function managedAppDir(): string {\n return appDir()\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgCA,MAAa,gBAAgB;CAAC;CAAG;CAAG;AAAE;;AAMtC,MAAa,mBAAmB;;AAGhC,MAAa,mBAAmB;AA4BhC,eAAsB,iBAAiB,MAA0C;CAC/E,IAAI;EACF,MAAM,MAAM,MAAM,kBAAkB,iBAAiB,IAAI,GAAG,EAAE,cAAc,MAAM,CAAC;EACnF,MAAM,SAAS,KAAK,MAAM,GAAG;EAC7B,OAAO,OAAO,WAAW,YAAY,WAAW,OAAO,SAAS,CAAC;CACnE,QAAQ;EACN,OAAO,CAAC;CACV;AACF;;;;;;;;;AAUA,eAAsB,kBAAkB,MAAmB,OAAuC;CAChG,IAAI;EACF,MAAMA,KAAG,MAAM,YAAY,IAAI,GAAG,EAAE,WAAW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