github-router 0.3.381 → 0.3.383

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 (149) hide show
  1. package/README.md +6 -0
  2. package/dist/ado-tools-Ddv910Zl.js +1 -0
  3. package/dist/{aic-ledger-6GKI28nY.js → aic-ledger-Bz87EuHl.js} +3 -3
  4. package/dist/{aic-ledger-6GKI28nY.js.map → aic-ledger-Bz87EuHl.js.map} +1 -1
  5. package/dist/{aic-statusline-settings-wLL1l_Z6.js → aic-statusline-settings-dkVZbpRL.js} +2 -2
  6. package/dist/{aic-statusline-settings-wLL1l_Z6.js.map → aic-statusline-settings-dkVZbpRL.js.map} +1 -1
  7. package/dist/{attribution-settings-BEwSkdhK.js → attribution-settings-BcPiSoZe.js} +27 -30
  8. package/dist/{attribution-settings-BEwSkdhK.js.map → attribution-settings-BcPiSoZe.js.map} +1 -1
  9. package/dist/{auth-5TKcQbbH.js → auth-D9eTY_W6.js} +3 -3
  10. package/dist/{auth-5TKcQbbH.js.map → auth-D9eTY_W6.js.map} +1 -1
  11. package/dist/bin.js +21 -4
  12. package/dist/bin.js.map +1 -1
  13. package/dist/bluebird-client-CLXs7q-X.js +1 -0
  14. package/dist/{bluebird-client-BasIdv5J.js → bluebird-client-bykMZyn1.js} +2 -2
  15. package/dist/{bluebird-client-BasIdv5J.js.map → bluebird-client-bykMZyn1.js.map} +1 -1
  16. package/dist/browser-ext/manifest.json +1 -1
  17. package/dist/{check-usage-DM39fdel.js → check-usage-BBaD35u4.js} +4 -4
  18. package/dist/{check-usage-DM39fdel.js.map → check-usage-BBaD35u4.js.map} +1 -1
  19. package/dist/{claude-CkrhHkPQ.js → claude-DOKuv2zZ.js} +29 -29
  20. package/dist/{claude-CkrhHkPQ.js.map → claude-DOKuv2zZ.js.map} +1 -1
  21. package/dist/{claude-md-injection-DNMDcw1W.js → claude-md-injection-BadtN0-I.js} +17 -8
  22. package/dist/claude-md-injection-BadtN0-I.js.map +1 -0
  23. package/dist/{codex-50GzveCD.js → codex-Dw_eBfXW.js} +9 -9
  24. package/dist/{codex-50GzveCD.js.map → codex-Dw_eBfXW.js.map} +1 -1
  25. package/dist/{copilot-discount-DM98PuAF.js → copilot-discount-BSDefQRW.js} +2 -2
  26. package/dist/{copilot-discount-DM98PuAF.js.map → copilot-discount-BSDefQRW.js.map} +1 -1
  27. package/dist/{debug-Df0Kuzi3.js → debug-B8eRYH-c.js} +2 -2
  28. package/dist/{debug-Df0Kuzi3.js.map → debug-B8eRYH-c.js.map} +1 -1
  29. package/dist/engine-DPtLOUuj.js +1 -0
  30. package/dist/{exec-BC0MAnoA.js → exec-oCtz_dXO.js} +22 -5
  31. package/dist/exec-oCtz_dXO.js.map +1 -0
  32. package/dist/{gate-discovery-2ILpM2fi.js → gate-discovery-DE_KTX2p.js} +6 -6
  33. package/dist/{gate-discovery-2ILpM2fi.js.map → gate-discovery-DE_KTX2p.js.map} +1 -1
  34. package/dist/{get-copilot-usage-BZ6t2hFZ.js → get-copilot-usage-Dh9u7WeP.js} +2 -2
  35. package/dist/{get-copilot-usage-BZ6t2hFZ.js.map → get-copilot-usage-Dh9u7WeP.js.map} +1 -1
  36. package/dist/hooks.mjs +21 -4
  37. package/dist/hooks.sha256 +1 -1
  38. package/dist/{index-cmd-DsK6VFs8.js → index-cmd-C4womtOS.js} +5 -5
  39. package/dist/{index-cmd-DsK6VFs8.js.map → index-cmd-C4womtOS.js.map} +1 -1
  40. package/dist/{internal-aic-status-CUZ7-trf.js → internal-aic-status-DSO2sR5u.js} +4 -4
  41. package/dist/{internal-aic-status-CUZ7-trf.js.map → internal-aic-status-DSO2sR5u.js.map} +1 -1
  42. package/dist/{internal-artifact-open-DRBg1PpV.js → internal-artifact-open-dlgqWieq.js} +2 -2
  43. package/dist/{internal-artifact-open-DRBg1PpV.js.map → internal-artifact-open-dlgqWieq.js.map} +1 -1
  44. package/dist/{internal-fast-dispatch-guard-ZeS9u0A3.js → internal-fast-dispatch-guard-5nCNht5y.js} +2 -2
  45. package/dist/{internal-fast-dispatch-guard-ZeS9u0A3.js.map → internal-fast-dispatch-guard-5nCNht5y.js.map} +1 -1
  46. package/dist/{internal-fast-dispatch-guard-D6-Ees_6.js → internal-fast-dispatch-guard-DHm96Bj_.js} +1 -1
  47. package/dist/{internal-first-mate-guard-DsEEsLKJ.js → internal-first-mate-guard-Bb9Stjy-.js} +3 -3
  48. package/dist/{internal-first-mate-guard-DsEEsLKJ.js.map → internal-first-mate-guard-Bb9Stjy-.js.map} +1 -1
  49. package/dist/{internal-first-mate-guard-BijeVpi9.js → internal-first-mate-guard-D6HMd9Iz.js} +1 -1
  50. package/dist/{internal-max-dispatch-guard-4RLca1i5.js → internal-max-dispatch-guard-C8kq4WNV.js} +3 -3
  51. package/dist/{internal-max-dispatch-guard-4RLca1i5.js.map → internal-max-dispatch-guard-C8kq4WNV.js.map} +1 -1
  52. package/dist/{internal-max-dispatch-guard-DeEfWqfP.js → internal-max-dispatch-guard-CI17mrDJ.js} +1 -1
  53. package/dist/{internal-plan-review-bzqGNdtw.js → internal-plan-review-Bdga9wVP.js} +3 -3
  54. package/dist/{internal-plan-review-bzqGNdtw.js.map → internal-plan-review-Bdga9wVP.js.map} +1 -1
  55. package/dist/{internal-prompt-submit-ZBhH-SQ1.js → internal-prompt-submit-DKlHlcvK.js} +2 -2
  56. package/dist/{internal-prompt-submit-BZ2-CExM.js → internal-prompt-submit-Daswp8ro.js} +5 -5
  57. package/dist/{internal-prompt-submit-BZ2-CExM.js.map → internal-prompt-submit-Daswp8ro.js.map} +1 -1
  58. package/dist/{internal-rebrief-BIWbN7Sr.js → internal-rebrief-D8O1J-_J.js} +5 -5
  59. package/dist/{internal-rebrief-BIWbN7Sr.js.map → internal-rebrief-D8O1J-_J.js.map} +1 -1
  60. package/dist/{internal-session-bind-BL6hFRLO.js → internal-session-bind-0hQFrcWu.js} +2 -2
  61. package/dist/{internal-session-bind-BL6hFRLO.js.map → internal-session-bind-0hQFrcWu.js.map} +1 -1
  62. package/dist/{internal-stop-hook-cDF1MuJZ.js → internal-stop-hook-C3lLh-HY.js} +6 -6
  63. package/dist/{internal-stop-hook-cDF1MuJZ.js.map → internal-stop-hook-C3lLh-HY.js.map} +1 -1
  64. package/dist/{internal-stop-review-y8zjpK_3.js → internal-stop-review-Bnmzcqx5.js} +2 -2
  65. package/dist/{internal-stop-review-y8zjpK_3.js.map → internal-stop-review-Bnmzcqx5.js.map} +1 -1
  66. package/dist/{internal-worker-guard-DdyYBZR0.js → internal-worker-guard-LcPxDlbx.js} +2 -2
  67. package/dist/{internal-worker-guard-DdyYBZR0.js.map → internal-worker-guard-LcPxDlbx.js.map} +1 -1
  68. package/dist/{internal-workspace-header-BMKbO8yX.js → internal-workspace-header-BH53hBXO.js} +2 -2
  69. package/dist/{internal-workspace-header-BMKbO8yX.js.map → internal-workspace-header-BH53hBXO.js.map} +1 -1
  70. package/dist/{lifecycle-COZhARmE.js → lifecycle-BmoqtVj3.js} +2 -2
  71. package/dist/{lifecycle-COZhARmE.js.map → lifecycle-BmoqtVj3.js.map} +1 -1
  72. package/dist/lifecycle-CcNNfKbr.js +1 -0
  73. package/dist/lifecycle-CrImfxCd.js +1 -0
  74. package/dist/{lifecycle-BlC_kzNt.js → lifecycle-CwxOsp-U.js} +3 -3
  75. package/dist/{lifecycle-BlC_kzNt.js.map → lifecycle-CwxOsp-U.js.map} +1 -1
  76. package/dist/main.js +25 -25
  77. package/dist/{max-profile-contract-DbHwiLTx.js → max-profile-contract-CEn8hKb3.js} +60 -60
  78. package/dist/{max-profile-contract-DbHwiLTx.js.map → max-profile-contract-CEn8hKb3.js.map} +1 -1
  79. package/dist/{mcp-workspace-header-Bpa4BId8.js → mcp-workspace-header-lb7GV78v.js} +2 -2
  80. package/dist/{mcp-workspace-header-Bpa4BId8.js.map → mcp-workspace-header-lb7GV78v.js.map} +1 -1
  81. package/dist/{models-BDV-YLf2.js → models-BTCnhBCQ.js} +3 -3
  82. package/dist/{models-BDV-YLf2.js.map → models-BTCnhBCQ.js.map} +1 -1
  83. package/dist/{optional-DGAeyguL.js → optional-LUQJI6Vx.js} +216 -16
  84. package/dist/optional-LUQJI6Vx.js.map +1 -0
  85. package/dist/{orchestration-Bto5Nc1Y.js → orchestration-C_hyBL90.js} +3 -3
  86. package/dist/{orchestration-Bto5Nc1Y.js.map → orchestration-C_hyBL90.js.map} +1 -1
  87. package/dist/origin-9bOjyzvK.js +1 -0
  88. package/dist/{origin-BXtpcKP9.js → origin-B6GChVyp.js} +2 -2
  89. package/dist/{origin-BXtpcKP9.js.map → origin-B6GChVyp.js.map} +1 -1
  90. package/dist/{paths-DeFmYJhO.js → paths-CVXqt2tC.js} +3 -3
  91. package/dist/{paths-DeFmYJhO.js.map → paths-CVXqt2tC.js.map} +1 -1
  92. package/dist/paths-JIusmD6L.js +1 -0
  93. package/dist/{peer-mcp-personas-Dny0r5Am.js → peer-mcp-personas-Dgog_ZJ8.js} +54 -54
  94. package/dist/{peer-mcp-personas-Dny0r5Am.js.map → peer-mcp-personas-Dgog_ZJ8.js.map} +1 -1
  95. package/dist/{pi-DVud9eQn.js → pi-BZhnf1kx.js} +95 -35
  96. package/dist/pi-BZhnf1kx.js.map +1 -0
  97. package/dist/{pi-version-check-BeBB0Ny9.js → pi-version-check-BRt9XFLj.js} +4 -4
  98. package/dist/{pi-version-check-BeBB0Ny9.js.map → pi-version-check-BRt9XFLj.js.map} +1 -1
  99. package/dist/pi-version-check-SH1X9u4H.js +1 -0
  100. package/dist/{plan-review-hook-D_yyjOgO.js → plan-review-hook-Dx3suYmK.js} +4 -4
  101. package/dist/{plan-review-hook-D_yyjOgO.js.map → plan-review-hook-Dx3suYmK.js.map} +1 -1
  102. package/dist/{provision-BWtuDq_v.js → provision-A1YSravb.js} +6 -6
  103. package/dist/{provision-BWtuDq_v.js.map → provision-A1YSravb.js.map} +1 -1
  104. package/dist/{rerank-cross-encoder-BhjImuwG.js → rerank-cross-encoder-uqRu-LOe.js} +2 -2
  105. package/dist/{rerank-cross-encoder-BhjImuwG.js.map → rerank-cross-encoder-uqRu-LOe.js.map} +1 -1
  106. package/dist/{self-invocation-Dnq4iVD6.js → self-invocation-CayD3y72.js} +2 -2
  107. package/dist/{self-invocation-Dnq4iVD6.js.map → self-invocation-CayD3y72.js.map} +1 -1
  108. package/dist/{serve-B8Igr9Q0.js → serve-Cv3S3PFR.js} +17 -17
  109. package/dist/{serve-B8Igr9Q0.js.map → serve-Cv3S3PFR.js.map} +1 -1
  110. package/dist/{server-setup-byIhjgOb.js → server-setup--CYeBD-Z.js} +14 -14
  111. package/dist/{server-setup-byIhjgOb.js.map → server-setup--CYeBD-Z.js.map} +1 -1
  112. package/dist/{service-backend-BdhWVRSz.js → service-backend-EgwiO_K-.js} +6 -6
  113. package/dist/{service-backend-BdhWVRSz.js.map → service-backend-EgwiO_K-.js.map} +1 -1
  114. package/dist/{start-7CiQIl0r.js → start-CA0JsO56.js} +5 -5
  115. package/dist/{start-7CiQIl0r.js.map → start-CA0JsO56.js.map} +1 -1
  116. package/dist/{static-context-pack-BKFelEbM.js → static-context-pack-BIru_SKh.js} +142 -142
  117. package/dist/{static-context-pack-BKFelEbM.js.map → static-context-pack-BIru_SKh.js.map} +1 -1
  118. package/dist/{stop-gate-hook-DBOj0TqL.js → stop-gate-hook-Ba_RvZAj.js} +4 -4
  119. package/dist/{stop-gate-hook-DBOj0TqL.js.map → stop-gate-hook-Ba_RvZAj.js.map} +1 -1
  120. package/dist/{stop-gate-policy-Bp2wGh_W.js → stop-gate-policy-gW0a0hds.js} +3 -3
  121. package/dist/{stop-gate-policy-Bp2wGh_W.js.map → stop-gate-policy-gW0a0hds.js.map} +1 -1
  122. package/dist/{token-Ygd7D32L.js → token-BCzbNu8O.js} +3 -3
  123. package/dist/{token-Ygd7D32L.js.map → token-BCzbNu8O.js.map} +1 -1
  124. package/dist/{token-CKPOBdO0.js → token-CxKcs3I_.js} +2 -2
  125. package/dist/{token-CKPOBdO0.js.map → token-CxKcs3I_.js.map} +1 -1
  126. package/dist/{update-T1L7yFon.js → update-CM1yUCJR.js} +4 -4
  127. package/dist/{update-T1L7yFon.js.map → update-CM1yUCJR.js.map} +1 -1
  128. package/dist/update-Cpg-tbJG.js +1 -0
  129. package/dist/{update-fEgWTrIx.js → update-ZqCRVU0a.js} +4 -4
  130. package/dist/{update-fEgWTrIx.js.map → update-ZqCRVU0a.js.map} +1 -1
  131. package/dist/{worker-dispatch-DBWKTMda.js → worker-dispatch-DHZAfPO2.js} +2 -2
  132. package/dist/{worker-dispatch-DBWKTMda.js.map → worker-dispatch-DHZAfPO2.js.map} +1 -1
  133. package/dist/{workiq-D5b7xlbr.js → workiq-CRBVCUA4.js} +2 -2
  134. package/dist/{workiq-D5b7xlbr.js.map → workiq-CRBVCUA4.js.map} +1 -1
  135. package/dist/{workiq-tools-DdiQ2DOW.js → workiq-tools-BsoHfdYi.js} +1 -1
  136. package/package.json +1 -1
  137. package/dist/ado-tools-CsfbnY8x.js +0 -1
  138. package/dist/bluebird-client-BvoMTmEv.js +0 -1
  139. package/dist/claude-md-injection-DNMDcw1W.js.map +0 -1
  140. package/dist/engine-B6la_uIW.js +0 -1
  141. package/dist/exec-BC0MAnoA.js.map +0 -1
  142. package/dist/lifecycle-BOjgq9_l.js +0 -1
  143. package/dist/lifecycle-NQvr4flt.js +0 -1
  144. package/dist/optional-DGAeyguL.js.map +0 -1
  145. package/dist/origin-DbFUCiGp.js +0 -1
  146. package/dist/paths-CquOjytP.js +0 -1
  147. package/dist/pi-DVud9eQn.js.map +0 -1
  148. package/dist/pi-version-check-D5RvdLsG.js +0 -1
  149. package/dist/update-CB21YRKz.js +0 -1
@@ -1 +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;;AA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+ {"version":3,"file":"origin-B6GChVyp.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,KAAK,CAAC;EACrD,MAAM,gBAAgB,iBAAiB,IAAI,GAAG,GAAG,KAAK,UAAU,OAAO,MAAM,CAAC,EAAE,KAAK,EACnF,MAAM,IACR,CAAC;EACD,OAAO;CACT,SAAS,KAAK;EACZ,wBACE,QACA,WAAW,KAAK,qBAAqB,iBAAiB,IAAI,EAAE,IAC1D,eAAe,QAAQ,IAAI,UAAU,OAAO,GAAG,EAChD,qFACH;EACA,OAAO;CACT;AACF;;;;;;;;;;;;;;;;;;;AAoBA,eAAsB,kBACpB,MACA,OACkB;CAElB,MAAM,OAAqB;EAAE,GAAG,MADV,iBAAiB,IAAI;EACF,GAAG;CAAM;CAGlD,KAAK,MAAM,OAAO,OAAO,KAAK,KAAK,GACjC,IAAI,MAAM,SAAS,KAAA,GAAW,OAAO,KAAK;CAE5C,OAAO,kBAAkB,MAAM,IAAI;AACrC;;;;;;;AAQA,SAAgB,kBAAkB,OAAqB,MAAM,KAAK,IAAI,GAAY;CAChF,IAAI,CAAC,MAAM,eAAe,OAAO;CACjC,MAAM,OAAO,IA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;AAmBA,SAAgB,eAAe,QAA+B;CAC5D,QAAQ,QAAR;EACE,KAAK,WACH,OAAO;EACT,KAAK,cACH,OAAO;EACT,KAAK,OACH,OAAO;EACT,KAAK,QACH,OAAO;EACT,KAAK,UACH,OAAO;EACT,KAAK,WACH,OAAO;CACX;AACF"}
@@ -485,12 +485,12 @@ async function ensurePaths() {
485
485
  consola.debug("Peer-agent .md sweep skipped:", err);
486
486
  });
487
487
  await (async () => {
488
- await (await import("./lifecycle-NQvr4flt.js")).sweepStaleWorktreesAtBoot();
488
+ await (await import("./lifecycle-CrImfxCd.js")).sweepStaleWorktreesAtBoot();
489
489
  })().catch((err) => {
490
490
  consola.debug("Worker worktree boot sweep skipped:", err);
491
491
  });
492
492
  await (async () => {
493
- await (await import("./lifecycle-BOjgq9_l.js")).sweepStaleColbertMetaAtBoot();
493
+ await (await import("./lifecycle-CcNNfKbr.js")).sweepStaleColbertMetaAtBoot();
494
494
  })().catch((err) => {
495
495
  consola.debug("ColBERT meta boot sweep skipped:", err);
496
496
  });
@@ -1577,4 +1577,4 @@ async function removeOwnClaudeConfigMirror() {
1577
1577
  }
1578
1578
  export { isUnderClaudeConfigMirror as a, sweepStaleClaudeConfigMirrors as c, writeArtifactCredsToMirror as d, writeLaunchBoundSyntheticCredential as f, ensurePaths as i, sweepStalePeerAgentMdFiles as l, PEER_AGENT_MD_FILENAME as n, purgeNonRouterAgentsFromMirror as o, writeRuntimeFileSecure as p, ensureClaudeConfigMirror as r, removeOwnClaudeConfigMirror as s, PATHS as t, sweepStaleRuntimeFiles as u };
1579
1579
 
1580
- //# sourceMappingURL=paths-DeFmYJhO.js.map
1580
+ //# sourceMappingURL=paths-CVXqt2tC.js.map