github-router 0.3.344 → 0.3.346

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 (39) hide show
  1. package/dist/{aic-ledger-D4fmThbS.js → aic-ledger-D4oMcg7c.js} +24 -2
  2. package/dist/aic-ledger-D4oMcg7c.js.map +1 -0
  3. package/dist/{attribution-settings-BkhBJn_K.js → attribution-settings-DyzvcqWL.js} +4 -4
  4. package/dist/{attribution-settings-BkhBJn_K.js.map → attribution-settings-DyzvcqWL.js.map} +1 -1
  5. package/dist/browser-ext/manifest.json +1 -1
  6. package/dist/{claude-CarqHLsD.js → claude-Bc-4s27I.js} +8 -8
  7. package/dist/{claude-CarqHLsD.js.map → claude-Bc-4s27I.js.map} +1 -1
  8. package/dist/{codex-AdG6FZIV.js → codex-D6ZfS7hJ.js} +4 -4
  9. package/dist/{codex-AdG6FZIV.js.map → codex-D6ZfS7hJ.js.map} +1 -1
  10. package/dist/{copilot-discount-yDaMQob0.js → copilot-discount-CilBhKQW.js} +2 -2
  11. package/dist/{copilot-discount-yDaMQob0.js.map → copilot-discount-CilBhKQW.js.map} +1 -1
  12. package/dist/engine-PexAztE4.js +2 -0
  13. package/dist/{gate-discovery-ByujYipc.js → gate-discovery-TC3k4dr1.js} +2 -2
  14. package/dist/{gate-discovery-ByujYipc.js.map → gate-discovery-TC3k4dr1.js.map} +1 -1
  15. package/dist/hooks.mjs +92 -0
  16. package/dist/hooks.sha256 +1 -1
  17. package/dist/{internal-aic-status-BmXhfpTS.js → internal-aic-status-CCvU7zhC.js} +3 -3
  18. package/dist/{internal-aic-status-BmXhfpTS.js.map → internal-aic-status-CCvU7zhC.js.map} +1 -1
  19. package/dist/{internal-stop-hook-DEMbF-hU.js → internal-stop-hook-BjdKy6On.js} +2 -2
  20. package/dist/{internal-stop-hook-DEMbF-hU.js.map → internal-stop-hook-BjdKy6On.js.map} +1 -1
  21. package/dist/main.js +7 -7
  22. package/dist/{peer-mcp-personas-CvqVopTx.js → peer-mcp-personas-CIV3aDP6.js} +12 -4
  23. package/dist/peer-mcp-personas-CIV3aDP6.js.map +1 -0
  24. package/dist/{pi-C8jxbK_2.js → pi-CugyWYp7.js} +142 -16
  25. package/dist/pi-CugyWYp7.js.map +1 -0
  26. package/dist/{provision-CJ3Zzs_Q.js → provision-J68elA3c.js} +2 -2
  27. package/dist/{provision-CJ3Zzs_Q.js.map → provision-J68elA3c.js.map} +1 -1
  28. package/dist/{serve-DQhAmfp2.js → serve-BEY7EjEv.js} +5 -5
  29. package/dist/{serve-DQhAmfp2.js.map → serve-BEY7EjEv.js.map} +1 -1
  30. package/dist/{server-setup-BBbpJRWv.js → server-setup-tNMUzFgE.js} +5 -4
  31. package/dist/server-setup-tNMUzFgE.js.map +1 -0
  32. package/dist/{start-C34seGtb.js → start-BDxUhfDG.js} +3 -3
  33. package/dist/{start-C34seGtb.js.map → start-BDxUhfDG.js.map} +1 -1
  34. package/package.json +1 -1
  35. package/dist/aic-ledger-D4fmThbS.js.map +0 -1
  36. package/dist/engine-gOzWnh6S.js +0 -2
  37. package/dist/peer-mcp-personas-CvqVopTx.js.map +0 -1
  38. package/dist/pi-C8jxbK_2.js.map +0 -1
  39. package/dist/server-setup-BBbpJRWv.js.map +0 -1
@@ -3,18 +3,19 @@ import { t as getPackageVersion } from "./version-C8x2hQrZ.js";
3
3
  import { t as PATHS } from "./paths-CpbTHKeP.js";
4
4
  import { t as state } from "./state-CVp30CBF.js";
5
5
  import { c as runCommandVoid, o as resolveExecutable, s as runCommandCapture } from "./exec-MCU1H-KZ.js";
6
- import { B as runSelfUpdate, E as formatBalancedPrerequisiteFailure, I as validateCheapestProfilePrerequisites, M as resolveLaunchProfile, N as validateBalancedProfilePrerequisites, a as setupAndServe, c as startKeepAwake, f as enableFileLogging, i as parseSharedArgs, j as profileDescriptor, k as formatCheapestPrerequisiteFailure, l as stopKeepAwake, o as sharedServerArgs, r as getPiLaunchEnvVars, z as queueDetachedGlobalInstall } from "./server-setup-BBbpJRWv.js";
6
+ import { B as runSelfUpdate, E as formatBalancedPrerequisiteFailure, I as validateCheapestProfilePrerequisites, M as resolveLaunchProfile, N as validateBalancedProfilePrerequisites, a as setupAndServe, c as startKeepAwake, f as enableFileLogging, i as parseSharedArgs, j as profileDescriptor, k as formatCheapestPrerequisiteFailure, l as stopKeepAwake, o as sharedServerArgs, r as getPiLaunchEnvVars, z as queueDetachedGlobalInstall } from "./server-setup-tNMUzFgE.js";
7
7
  import { a as BALANCED_PROFILE_NATIVE_EFFORTS, c as BALANCED_PROFILE_ORACLE_MODEL, r as BALANCED_PROFILE_MODELS, s as BALANCED_PROFILE_ORACLE_EFFORT } from "./balanced-profile-contract-C6AgFJNp.js";
8
- import { D as toolbeltEnabled, Gt as registerLaunch, In as CHEAPEST_PROFILE_NATIVE_EFFORTS, Kt as unregisterLaunch, Mn as CHEAPEST_PROFILE_ADVISOR_EFFORT, Nn as CHEAPEST_PROFILE_ADVISOR_MODEL, Pn as CHEAPEST_PROFILE_MODELS, Rn as CHEAPEST_PROFILE_ORACLE_EFFORT, an as provisionAndIndexColbert, ft as browserToolsEnabled, in as colbertDegradedWarning, nn as provisionBrowserAssets, zn as CHEAPEST_PROFILE_ORACLE_MODEL } from "./peer-mcp-personas-CvqVopTx.js";
8
+ import { D as toolbeltEnabled, Gt as registerLaunch, In as CHEAPEST_PROFILE_NATIVE_EFFORTS, Kt as unregisterLaunch, Mn as CHEAPEST_PROFILE_ADVISOR_EFFORT, Nn as CHEAPEST_PROFILE_ADVISOR_MODEL, Pn as CHEAPEST_PROFILE_MODELS, Rn as CHEAPEST_PROFILE_ORACLE_EFFORT, an as provisionAndIndexColbert, ft as browserToolsEnabled, in as colbertDegradedWarning, nn as provisionBrowserAssets, zn as CHEAPEST_PROFILE_ORACLE_MODEL } from "./peer-mcp-personas-CIV3aDP6.js";
9
9
  import { r as resolveSelfInvocation } from "./self-invocation-DIUyoRgL.js";
10
- import { i as launchChild, t as provisionToolbelt } from "./provision-CJ3Zzs_Q.js";
11
- import { d as sweepStaleAicLedgerFiles, t as aicLedgerPath } from "./aic-ledger-D4fmThbS.js";
10
+ import { i as launchChild, t as provisionToolbelt } from "./provision-J68elA3c.js";
11
+ import { d as sweepStaleAicLedgerFiles, n as aicSnapshot, o as formatAicExitSummary, t as aicLedgerPath, u as removeAicLedgerFile } from "./aic-ledger-D4oMcg7c.js";
12
12
  import { i as buildAicStatusHookCommand, n as AIC_STATUSLINE_DISABLE_ENV, t as AIC_LEDGER_ENV } from "./aic-statusline-settings-YoDG20pq.js";
13
+ import { n as formatDiscountedCostTable, t as discountedUsdForSnapshot } from "./copilot-discount-CilBhKQW.js";
13
14
  import { defineCommand } from "citty";
14
15
  import consola from "consola";
15
16
  import { existsSync } from "node:fs";
16
17
  import path from "node:path";
17
- import { randomBytes } from "node:crypto";
18
+ import { createHash, randomBytes } from "node:crypto";
18
19
  import fs$1 from "node:fs/promises";
19
20
  import os from "node:os";
20
21
  import process$1 from "node:process";
@@ -613,6 +614,110 @@ async function sweepStalePiAgentMirrors() {
613
614
  }
614
615
  }));
615
616
  }
617
+ function cacheDisabled() {
618
+ return process.env.GH_ROUTER_PI_NO_PACKAGE_CACHE === "1";
619
+ }
620
+ /** Stable fingerprint of one `packages[]` entry (order-independent). */
621
+ function piPackageSpecFingerprint(entry) {
622
+ if (typeof entry === "string") return entry;
623
+ const join = (v) => [...v ?? []].sort().join(",");
624
+ return [
625
+ entry.source,
626
+ `ext:${join(entry.extensions)}`,
627
+ `skills:${join(entry.skills)}`,
628
+ `prompts:${join(entry.prompts)}`,
629
+ `themes:${join(entry.themes)}`
630
+ ].join("::");
631
+ }
632
+ /** Order-independent cache key for a launch's full `packages[]` slice. */
633
+ function piPackageCacheKey(packages) {
634
+ const specs = packages.map(piPackageSpecFingerprint).sort();
635
+ return createHash("sha256").update(specs.join("\n")).digest("hex").slice(0, 16);
636
+ }
637
+ function piPackageCacheDir(key) {
638
+ return path.join(PATHS.APP_DIR, "pi-packages", key);
639
+ }
640
+ function npmDirOf(root) {
641
+ return path.join(root, "npm");
642
+ }
643
+ async function mtimeMsOf(dir) {
644
+ try {
645
+ return (await fs$1.stat(dir)).mtimeMs;
646
+ } catch {
647
+ return null;
648
+ }
649
+ }
650
+ /**
651
+ * Copy the cached `<key>/npm` tree into a fresh mirror before Pi boots.
652
+ * Returns true on a hit (mirror pre-seeded; Pi should install nothing).
653
+ * Stale entries (older than the max age) are a miss so the launch
654
+ * refreshes to upstream latest. Never throws.
655
+ */
656
+ async function seedPiPackageCache(mirrorDir, packages) {
657
+ if (cacheDisabled()) return false;
658
+ const key = piPackageCacheKey(packages);
659
+ const cachedNpm = npmDirOf(piPackageCacheDir(key));
660
+ const mtime = await mtimeMsOf(cachedNpm);
661
+ if (mtime === null) return false;
662
+ if (Date.now() - mtime > 6048e5) {
663
+ consola.debug(`Pi package cache ${key} is stale; refreshing from registry.`);
664
+ return false;
665
+ }
666
+ try {
667
+ await fs$1.cp(cachedNpm, npmDirOf(mirrorDir), { recursive: true });
668
+ return true;
669
+ } catch (err) {
670
+ consola.debug("Pi package cache seed skipped:", err);
671
+ return false;
672
+ }
673
+ }
674
+ /**
675
+ * Persist a mirror's installed `<mirror>/npm` tree back to the cache
676
+ * (call on shutdown, BEFORE the mirror is removed). Overwrites the
677
+ * entry, refreshing its mtime. Never throws.
678
+ */
679
+ async function savePiPackageCache(mirrorDir, packages) {
680
+ if (cacheDisabled()) return;
681
+ const mirrorNpm = npmDirOf(mirrorDir);
682
+ if (await mtimeMsOf(path.join(mirrorNpm, "node_modules")) === null) return;
683
+ const dest = npmDirOf(piPackageCacheDir(piPackageCacheKey(packages)));
684
+ try {
685
+ await fs$1.mkdir(path.dirname(dest), { recursive: true });
686
+ await fs$1.rm(dest, {
687
+ recursive: true,
688
+ force: true
689
+ });
690
+ await fs$1.cp(mirrorNpm, dest, { recursive: true });
691
+ } catch (err) {
692
+ consola.debug("Pi package cache save skipped:", err);
693
+ }
694
+ }
695
+ /**
696
+ * Sweep cache entries whose `npm/` tree is older than the max age.
697
+ * Best-effort, never throws. Runs opportunistically at boot.
698
+ */
699
+ async function sweepStalePiPackageCaches() {
700
+ if (cacheDisabled()) return;
701
+ const root = path.join(PATHS.APP_DIR, "pi-packages");
702
+ let entries;
703
+ try {
704
+ entries = await fs$1.readdir(root);
705
+ } catch {
706
+ return;
707
+ }
708
+ await Promise.all(entries.map(async (entry) => {
709
+ const npmDir = npmDirOf(path.join(root, entry));
710
+ try {
711
+ const mtime = await mtimeMsOf(npmDir);
712
+ if (mtime === null || Date.now() - mtime > 6048e5) await fs$1.rm(path.join(root, entry), {
713
+ recursive: true,
714
+ force: true
715
+ });
716
+ } catch (err) {
717
+ consola.debug(`Pi package cache sweep: skipping ${entry}:`, err);
718
+ }
719
+ }));
720
+ }
616
721
  //#endregion
617
722
  //#region src/lib/pi-models-settings.ts
618
723
  /**
@@ -956,10 +1061,15 @@ function applyCosmeticUserOverrides(userSettings, builtSettings) {
956
1061
  * the launch has neither `--search` nor `--browse`, otherwise it
957
1062
  * double-pays our ColBERT/browser surfaces.
958
1063
  * - `pi-agent-extensions`: allowlisted stable extensions only
959
- * (sessions, structured questions, todos, handoff, context/files
1064
+ * (sessions, structured questions, todos, handoff, context
960
1065
  * dashboards, notifications, analytics). `review`/`loop`/`workflow`/
961
1066
  * `control` overlap our delegate/review pipeline and `powerline-footer`
962
1067
  * would fight the router-owned AIC footer, so all are excluded.
1068
+ * `files` is deliberately excluded too: it registers `ctrl+shift+o`
1069
+ * (file browser), colliding with `pi-claude-code-ui`'s `ctrl+shift+o`
1070
+ * (extra tool detail) — Pi warns and the files binding dies, so
1071
+ * shipping it only buys noise. `@file` mentions + the `context`
1072
+ * dashboard + `read`/`ls`/`find` cover the need.
963
1073
  */
964
1074
  const PI_HELPERS_MCP_ADAPTER = {
965
1075
  source: "npm:pi-mcp-adapter",
@@ -974,7 +1084,9 @@ const PI_HELPERS_WEB_ACCESS = {
974
1084
  /** Verified manifest paths (pi-agent-extensions 0.5.x). Bare relative
975
1085
  * form, NO `./` prefix: Pi matches package-filter patterns with
976
1086
  * minimatch against root-relative paths, and a `./` prefix matches
977
- * nothing (observed live: zero extensions loaded, silent). */
1087
+ * nothing (observed live: zero extensions loaded, silent).
1088
+ * `extensions/files/index.ts` is intentionally absent: it owns
1089
+ * `ctrl+shift+o`, which `pi-claude-code-ui` also registers. */
978
1090
  const PI_HELPERS_AGENT_EXTENSIONS = {
979
1091
  source: "npm:pi-agent-extensions",
980
1092
  extensions: [
@@ -983,7 +1095,6 @@ const PI_HELPERS_AGENT_EXTENSIONS = {
983
1095
  "extensions/handoff/index.ts",
984
1096
  "extensions/notify/index.ts",
985
1097
  "extensions/context/index.ts",
986
- "extensions/files/index.ts",
987
1098
  "extensions/todos/index.ts",
988
1099
  "extensions/answer/index.ts",
989
1100
  "extensions/cwd-history/index.ts",
@@ -1921,7 +2032,7 @@ const piArgs = {
1921
2032
  helpers: {
1922
2033
  type: "boolean",
1923
2034
  default: true,
1924
- description: "Wire the helpful bundle: pi-mcp-adapter, allowlisted pi-agent-extensions (sessions, ask_user, todos, handoff, context, files, analytics — no review/loop/footer), and pi-web-access when neither --search nor --browse is on. Set to false (--no-helpers) for pi-subagents + gh-router-pi only."
2035
+ description: "Wire the helpful bundle: pi-mcp-adapter, allowlisted pi-agent-extensions (sessions, ask_user, todos, handoff, context, analytics — no review/loop/footer, no files picker so Ctrl+Shift+O stays unambiguous for the UI), and pi-web-access when neither --search nor --browse is on. Set to false (--no-helpers) for pi-subagents + gh-router-pi only."
1925
2036
  },
1926
2037
  ui: {
1927
2038
  type: "boolean",
@@ -2087,11 +2198,13 @@ const pi = defineCommand({
2087
2198
  try {
2088
2199
  mirror = await ensurePiAgentMirror();
2089
2200
  await sweepStalePiAgentMirrors();
2201
+ sweepStalePiPackageCaches();
2090
2202
  } catch (err) {
2091
2203
  consola.error(`Failed to provision Pi config mirror: ${err instanceof Error ? err.message : String(err)}.`);
2092
2204
  process$1.exit(1);
2093
2205
  }
2094
2206
  enableFileLogging();
2207
+ let packagesForCache = [];
2095
2208
  try {
2096
2209
  const catalog = state.models?.data.map((m) => {
2097
2210
  const cost = piUsdCostFor(m.billing?.token_prices);
@@ -2139,6 +2252,8 @@ const pi = defineCommand({
2139
2252
  ...cosmeticOverrides,
2140
2253
  ...mergedSubagents ? { subagents: mergedSubagents } : {}
2141
2254
  });
2255
+ packagesForCache = [...builtSettings.packages];
2256
+ if (await seedPiPackageCache(mirror, packagesForCache)) consola.debug("Pi package cache hit: mirror pre-seeded, skipping registry install.");
2142
2257
  const bridgeDisabled = args["memory-bridge"] === false || process$1.env.GH_ROUTER_PI_BRIDGE === "0" || process$1.env.GH_ROUTER_DISABLE_PI_BRIDGE === "1";
2143
2258
  let bridgeStats;
2144
2259
  let bridgeScoped = [];
@@ -2284,15 +2399,26 @@ const pi = defineCommand({
2284
2399
  extraArgs,
2285
2400
  model: lead,
2286
2401
  serverUrl
2287
- }, server, { onShutdown: async () => {
2288
- unregisterLaunch(entry.launchId);
2289
- await stopKeepAwake();
2290
- await disposeBluebirdClients();
2291
- await removeOwnPiAgentMirror();
2292
- } });
2402
+ }, server, {
2403
+ onShutdown: async () => {
2404
+ unregisterLaunch(entry.launchId);
2405
+ await stopKeepAwake();
2406
+ await disposeBluebirdClients();
2407
+ await savePiPackageCache(mirror, packagesForCache);
2408
+ await removeOwnPiAgentMirror();
2409
+ await removeAicLedgerFile();
2410
+ },
2411
+ onExitSummary: () => {
2412
+ const snapshot = aicSnapshot();
2413
+ if (snapshot.requests === 0 || snapshot.totalNanoAiu <= 0) return;
2414
+ const summary = formatAicExitSummary(snapshot, { verbose: consola.level >= 4 });
2415
+ const table = formatDiscountedCostTable(snapshot, discountedUsdForSnapshot(snapshot));
2416
+ return table ? `${summary}\n${table}` : summary;
2417
+ }
2418
+ });
2293
2419
  }
2294
2420
  });
2295
2421
  //#endregion
2296
2422
  export { pi };
2297
2423
 
2298
- //# sourceMappingURL=pi-C8jxbK_2.js.map
2424
+ //# sourceMappingURL=pi-CugyWYp7.js.map