github-router 0.3.380 → 0.3.382

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 (47) hide show
  1. package/dist/ado-tools-CNEWS1kF.js +1 -0
  2. package/dist/{attribution-settings-BJ1fjX7V.js → attribution-settings-BhQmS2u9.js} +23 -26
  3. package/dist/{attribution-settings-BJ1fjX7V.js.map → attribution-settings-BhQmS2u9.js.map} +1 -1
  4. package/dist/browser-ext/manifest.json +1 -1
  5. package/dist/{claude-BWwkOMi3.js → claude-B9Mw8x0M.js} +12 -12
  6. package/dist/{claude-BWwkOMi3.js.map → claude-B9Mw8x0M.js.map} +1 -1
  7. package/dist/{claude-md-injection-DNMDcw1W.js → claude-md-injection-DiokMV4p.js} +16 -7
  8. package/dist/claude-md-injection-DiokMV4p.js.map +1 -0
  9. package/dist/{codex-C6ix3BaY.js → codex-DiybqRAO.js} +5 -5
  10. package/dist/{codex-C6ix3BaY.js.map → codex-DiybqRAO.js.map} +1 -1
  11. package/dist/engine-DCR1lSsw.js +1 -0
  12. package/dist/{gate-discovery-2ILpM2fi.js → gate-discovery-DCdds1gg.js} +2 -2
  13. package/dist/{gate-discovery-2ILpM2fi.js.map → gate-discovery-DCdds1gg.js.map} +1 -1
  14. package/dist/{internal-max-dispatch-guard-DeEfWqfP.js → internal-max-dispatch-guard-CXaZ5TTR.js} +1 -1
  15. package/dist/{internal-max-dispatch-guard-4RLca1i5.js → internal-max-dispatch-guard-sjBGijoa.js} +2 -2
  16. package/dist/{internal-max-dispatch-guard-4RLca1i5.js.map → internal-max-dispatch-guard-sjBGijoa.js.map} +1 -1
  17. package/dist/{internal-prompt-submit-BZ2-CExM.js → internal-prompt-submit-C_QigwLP.js} +2 -2
  18. package/dist/{internal-prompt-submit-BZ2-CExM.js.map → internal-prompt-submit-C_QigwLP.js.map} +1 -1
  19. package/dist/{internal-prompt-submit-ZBhH-SQ1.js → internal-prompt-submit-DBmCOUfy.js} +2 -2
  20. package/dist/{internal-rebrief-BIWbN7Sr.js → internal-rebrief-CjaEXHIo.js} +3 -3
  21. package/dist/{internal-rebrief-BIWbN7Sr.js.map → internal-rebrief-CjaEXHIo.js.map} +1 -1
  22. package/dist/{internal-stop-hook-cDF1MuJZ.js → internal-stop-hook-CcXuDASI.js} +2 -2
  23. package/dist/{internal-stop-hook-cDF1MuJZ.js.map → internal-stop-hook-CcXuDASI.js.map} +1 -1
  24. package/dist/main.js +9 -9
  25. package/dist/{max-profile-contract-DbHwiLTx.js → max-profile-contract-CEn8hKb3.js} +60 -60
  26. package/dist/{max-profile-contract-DbHwiLTx.js.map → max-profile-contract-CEn8hKb3.js.map} +1 -1
  27. package/dist/{peer-mcp-personas-Dny0r5Am.js → peer-mcp-personas-Ckbn70c5.js} +40 -40
  28. package/dist/{peer-mcp-personas-Dny0r5Am.js.map → peer-mcp-personas-Ckbn70c5.js.map} +1 -1
  29. package/dist/{pi-YhoA26wi.js → pi-D9IbxlSj.js} +88 -180
  30. package/dist/pi-D9IbxlSj.js.map +1 -0
  31. package/dist/{provision-BWtuDq_v.js → provision-BY5pXtSG.js} +2 -2
  32. package/dist/{provision-BWtuDq_v.js.map → provision-BY5pXtSG.js.map} +1 -1
  33. package/dist/{serve-DrHAX2Bh.js → serve-DPPh7goh.js} +7 -7
  34. package/dist/{serve-DrHAX2Bh.js.map → serve-DPPh7goh.js.map} +1 -1
  35. package/dist/{server-setup-DLwejgVA.js → server-setup-CVMUKERN.js} +703 -9
  36. package/dist/server-setup-CVMUKERN.js.map +1 -0
  37. package/dist/{start-DvV3Lbwy.js → start-B7z2Mg2B.js} +3 -3
  38. package/dist/{start-DvV3Lbwy.js.map → start-B7z2Mg2B.js.map} +1 -1
  39. package/dist/{static-context-pack-BKFelEbM.js → static-context-pack-DdQpWwQN.js} +140 -140
  40. package/dist/{static-context-pack-BKFelEbM.js.map → static-context-pack-DdQpWwQN.js.map} +1 -1
  41. package/dist/{workiq-tools-DdiQ2DOW.js → workiq-tools-3K9WKiQ2.js} +1 -1
  42. package/package.json +1 -1
  43. package/dist/ado-tools-CsfbnY8x.js +0 -1
  44. package/dist/claude-md-injection-DNMDcw1W.js.map +0 -1
  45. package/dist/engine-B6la_uIW.js +0 -1
  46. package/dist/pi-YhoA26wi.js.map +0 -1
  47. package/dist/server-setup-DLwejgVA.js.map +0 -1
@@ -6,12 +6,12 @@ import { i as buildAicStatusHookCommand, n as AIC_STATUSLINE_DISABLE_ENV, t as A
6
6
  import { d as removeAicLedgerFile, f as sweepStaleAicLedgerFiles, n as aicSnapshot, o as formatAicExitSummary, t as aicLedgerPath } from "./aic-ledger-6GKI28nY.js";
7
7
  import { n as formatDiscountedCostTable, t as discountedUsdForSnapshot } from "./copilot-discount-DM98PuAF.js";
8
8
  import { r as resolveSelfInvocation } from "./self-invocation-Dnq4iVD6.js";
9
- import { B as validateCheapestProfilePrerequisites, F as profileDescriptor, H as validateLocalProfilePrerequisites, I as resolveLaunchProfile, L as validateBalancedProfilePrerequisites, M as formatCheapestPrerequisiteFailure, P as formatLocalPrerequisiteFailure, a as setupAndServe, c as ensurePiAgentMirror, d as startKeepAwake, f as stopKeepAwake, h as enableFileLogging, i as parseSharedArgs, k as formatBalancedPrerequisiteFailure, l as removeOwnPiAgentMirror, o as sharedServerArgs, r as getPiLaunchEnvVars, s as LAUNCH_SECRET_HEADER, u as sweepStalePiAgentMirrors } from "./server-setup-DLwejgVA.js";
9
+ import { H as validateCheapestProfilePrerequisites, I as formatLocalPrerequisiteFailure, L as profileDescriptor, P as formatCheapestPrerequisiteFailure, R as resolveLaunchProfile, W as validateLocalProfilePrerequisites, _ as enableFileLogging, a as setupAndServe, c as ensurePiAgentMirror, d as seedPiPackageCache, f as sweepStalePiPackageCaches, i as parseSharedArgs, j as formatBalancedPrerequisiteFailure, l as removeOwnPiAgentMirror, m as stopKeepAwake, o as sharedServerArgs, p as startKeepAwake, r as getPiLaunchEnvVars, s as LAUNCH_SECRET_HEADER, u as sweepStalePiAgentMirrors, z as validateBalancedProfilePrerequisites } from "./server-setup-CVMUKERN.js";
10
+ import { t as FRESH_CONSULT_CONTRACT } from "./claude-md-injection-DiokMV4p.js";
11
+ import { Bn as colbertDegradedWarning, Bt as cloudAgentToolsEnabled, D as toolbeltEnabled, Dt as artifactToolsEnabled, Mn as provisionBrowserAssets, Nt as browserToolsEnabled, Qt as kustoToolsEnabled, Sn as unregisterLaunch, Tt as adoToolsEnabled, Vn as provisionAndIndexColbert, _r as LOCAL_CONSULT_REDACTION_LINE, bn as registerLaunch, fn as configureLocalEgress, jt as browseAgentEnabled, pn as localBaseUrl, sn as workiqToolsEnabled, vr as LOCAL_CONSULT_REDACTION_NOTE } from "./peer-mcp-personas-Ckbn70c5.js";
12
+ import { C as localContractFor, D as LOCAL_PROFILE_TIER_MODELS, S as local2AdvisorContract, _ as isBalancedFamily, b as isLocalFamily, f as balancedContractFor, h as consultIsLocalTransport, p as cheapestContractFor, v as isCheapestFamily, y as isCheaplocalProfile } from "./static-context-pack-DdQpWwQN.js";
13
+ import { i as launchChild, t as provisionToolbelt } from "./provision-BY5pXtSG.js";
10
14
  import { t as PATHS } from "./paths-DeFmYJhO.js";
11
- import { t as FRESH_CONSULT_CONTRACT } from "./claude-md-injection-DNMDcw1W.js";
12
- import { Bn as colbertDegradedWarning, Bt as cloudAgentToolsEnabled, D as toolbeltEnabled, Dt as artifactToolsEnabled, Gn as LOCAL_CONSULT_REDACTION_NOTE, Mn as provisionBrowserAssets, Nt as browserToolsEnabled, Qt as kustoToolsEnabled, Sn as unregisterLaunch, Tt as adoToolsEnabled, Vn as provisionAndIndexColbert, Wn as LOCAL_CONSULT_REDACTION_LINE, bn as registerLaunch, fn as configureLocalEgress, jt as browseAgentEnabled, pn as localBaseUrl, sn as workiqToolsEnabled } from "./peer-mcp-personas-Dny0r5Am.js";
13
- import { C as localContractFor, O as LOCAL_PROFILE_TIER_MODELS, S as local2AdvisorContract, _ as isBalancedFamily, b as isLocalFamily, f as balancedContractFor, h as consultIsLocalTransport, p as cheapestContractFor, v as isCheapestFamily, y as isCheaplocalProfile } from "./static-context-pack-BKFelEbM.js";
14
- import { i as launchChild, t as provisionToolbelt } from "./provision-BWtuDq_v.js";
15
15
  import { t as state } from "./state-CCGDJ43X.js";
16
16
  import { t as getPackageVersion } from "./version-CTqwKr26.js";
17
17
  import { P as warmTreeSitterPool } from "./service-backend-BdhWVRSz.js";
@@ -19,7 +19,7 @@ import { defineCommand } from "citty";
19
19
  import consola from "consola";
20
20
  import { existsSync } from "node:fs";
21
21
  import path from "node:path";
22
- import { createHash, randomBytes } from "node:crypto";
22
+ import { randomBytes } from "node:crypto";
23
23
  import fs$1 from "node:fs/promises";
24
24
  import process$1 from "node:process";
25
25
  // src/lib/managed-install/pi-command.ts
@@ -484,156 +484,6 @@ function buildPiStatusPayload(source, opts) {
484
484
  worktree: null
485
485
  };
486
486
  }
487
- // src/lib/pi-package-cache.ts
488
- /**
489
- * Persistent npm-package cache for Pi launches.
490
- *
491
- * Pi installs the mirror's `packages[]` into `<agentDir>/npm` on every
492
- * boot, and the agent dir is a fresh per-launch mirror
493
- * (`pi-agent-<pid>-<rand>`) — so every launch pays a full registry
494
- * install (~5s + `added N packages` noise that bypasses
495
- * `npm_config_loglevel=error`). Pi skips the install when the package
496
- * dir already exists and the installed version satisfies the configured
497
- * range — and unpinned `npm:name` specs match ANY installed version —
498
- * so pre-seeding `<mirror>/npm` from a durable cache makes repeat
499
- * launches install nothing: faster AND silent.
500
- *
501
- * Keyed by the exact package set (sorted spec fingerprints), so flag
502
- * combinations (`--helpers`/`--ui`/`--search`/`--browse`) each get
503
- * their own entry and can never cross-contaminate. Entries older than
504
- * the max age are treated as a miss so unpinned packages periodically
505
- * refresh to upstream latest; the fresh install is then saved back over
506
- * the entry. Opt out entirely with `GH_ROUTER_PI_NO_PACKAGE_CACHE=1`.
507
- *
508
- * Max age defaults to 24h, not the original 7d. Pi resolves an unpinned
509
- * `npm:name` spec to whatever is already installed, so the max age IS the
510
- * worst-case staleness of every extension the user runs — a week of it meant a
511
- * fix published upstream on Monday was still missing the following Sunday.
512
- * A day bounds the lag without making the cache pointless: the npm install it
513
- * avoids takes ~5s, so one refresh per day is paid back by every other launch
514
- * that day. Override with `GH_ROUTER_PI_PACKAGE_CACHE_HOURS`.
515
- */
516
- const PI_PACKAGE_CACHE_MAX_AGE_MS = 864e5;
517
- /**
518
- * Effective max age. Read per call rather than at module load so a test (or a
519
- * long-lived process re-reading config) can change the env and observe it, and
520
- * so a malformed value degrades to the default instead of `NaN` day math —
521
- * `Date.now() - mtime > NaN` is always false, which would make every entry
522
- * eternally fresh.
523
- */
524
- function piPackageCacheMaxAgeMs() {
525
- const raw = (process.env["GH_ROUTER_PI_PACKAGE_CACHE_HOURS"] ?? "").trim();
526
- if (!raw) return PI_PACKAGE_CACHE_MAX_AGE_MS;
527
- const hours = Number(raw);
528
- if (!Number.isFinite(hours) || hours <= 0) return PI_PACKAGE_CACHE_MAX_AGE_MS;
529
- return hours * 3600 * 1e3;
530
- }
531
- function cacheDisabled() {
532
- return process.env.GH_ROUTER_PI_NO_PACKAGE_CACHE === "1";
533
- }
534
- /** Stable fingerprint of one `packages[]` entry (order-independent). */
535
- function piPackageSpecFingerprint(entry) {
536
- if (typeof entry === "string") return entry;
537
- const join = (v) => [...v ?? []].sort().join(",");
538
- return [
539
- entry.source,
540
- `ext:${join(entry.extensions)}`,
541
- `skills:${join(entry.skills)}`,
542
- `prompts:${join(entry.prompts)}`,
543
- `themes:${join(entry.themes)}`
544
- ].join("::");
545
- }
546
- /** Order-independent cache key for a launch's full `packages[]` slice. */
547
- function piPackageCacheKey(packages) {
548
- const specs = packages.map(piPackageSpecFingerprint).sort();
549
- return createHash("sha256").update(specs.join("\n")).digest("hex").slice(0, 16);
550
- }
551
- function piPackageCacheDir(key) {
552
- return path.join(PATHS.APP_DIR, "pi-packages", key);
553
- }
554
- function npmDirOf(root) {
555
- return path.join(root, "npm");
556
- }
557
- async function mtimeMsOf(dir) {
558
- try {
559
- return (await fs$1.stat(dir)).mtimeMs;
560
- } catch {
561
- return null;
562
- }
563
- }
564
- /**
565
- * Copy the cached `<key>/npm` tree into a fresh mirror before Pi boots.
566
- * Returns true on a hit (mirror pre-seeded; Pi should install nothing).
567
- * Stale entries (older than the max age) are a miss so the launch
568
- * refreshes to upstream latest. Never throws.
569
- */
570
- async function seedPiPackageCache(mirrorDir, packages) {
571
- if (cacheDisabled()) return false;
572
- const key = piPackageCacheKey(packages);
573
- const cachedNpm = npmDirOf(piPackageCacheDir(key));
574
- const mtime = await mtimeMsOf(cachedNpm);
575
- if (mtime === null) return false;
576
- const maxAge = piPackageCacheMaxAgeMs();
577
- if (Date.now() - mtime > maxAge) {
578
- const ageHours = Math.floor((Date.now() - mtime) / 36e5);
579
- consola.debug(`Pi package cache ${key} is stale (${ageHours}h old, max ${Math.round(maxAge / 36e5)}h); refreshing from registry.`);
580
- return false;
581
- }
582
- try {
583
- await fs$1.cp(cachedNpm, npmDirOf(mirrorDir), { recursive: true });
584
- return true;
585
- } catch (err) {
586
- consola.debug("Pi package cache seed skipped:", err);
587
- return false;
588
- }
589
- }
590
- /**
591
- * Persist a mirror's installed `<mirror>/npm` tree back to the cache
592
- * (call on shutdown, BEFORE the mirror is removed). Overwrites the
593
- * entry, refreshing its mtime. Never throws.
594
- */
595
- async function savePiPackageCache(mirrorDir, packages) {
596
- if (cacheDisabled()) return;
597
- const mirrorNpm = npmDirOf(mirrorDir);
598
- if (await mtimeMsOf(path.join(mirrorNpm, "node_modules")) === null) return;
599
- const dest = npmDirOf(piPackageCacheDir(piPackageCacheKey(packages)));
600
- try {
601
- await fs$1.mkdir(path.dirname(dest), { recursive: true });
602
- await fs$1.rm(dest, {
603
- recursive: true,
604
- force: true
605
- });
606
- await fs$1.cp(mirrorNpm, dest, { recursive: true });
607
- } catch (err) {
608
- consola.debug("Pi package cache save skipped:", err);
609
- }
610
- }
611
- /**
612
- * Sweep cache entries whose `npm/` tree is older than the max age.
613
- * Best-effort, never throws. Runs opportunistically at boot.
614
- */
615
- async function sweepStalePiPackageCaches() {
616
- if (cacheDisabled()) return;
617
- const root = path.join(PATHS.APP_DIR, "pi-packages");
618
- let entries;
619
- try {
620
- entries = await fs$1.readdir(root);
621
- } catch {
622
- return;
623
- }
624
- await Promise.all(entries.map(async (entry) => {
625
- const npmDir = npmDirOf(path.join(root, entry));
626
- try {
627
- const mtime = await mtimeMsOf(npmDir);
628
- if (mtime === null || Date.now() - mtime > piPackageCacheMaxAgeMs()) await fs$1.rm(path.join(root, entry), {
629
- recursive: true,
630
- force: true
631
- });
632
- } catch (err) {
633
- consola.debug(`Pi package cache sweep: skipping ${entry}:`, err);
634
- }
635
- }));
636
- }
637
487
  // src/lib/pi-models-settings.ts
638
488
  /**
639
489
  * Pi thinking levels that can appear in `thinkingLevelMap`. `off` is
@@ -713,21 +563,56 @@ const PI_MIN_VERSION_NOTE = `Requires Pi >= ${PI_MIN_VERSION} and Node >= 22.19.
713
563
  */
714
564
  const PI_TOOL_PREFERENCE_LINE = "- Use the dedicated tools where they fit — read/write/edit for files and grep/find/ls for search — instead of shelling out to cat, sed, or python; but reach for rg, jq, ast-grep, git, and the build/test commands whenever those are the better tool for the job.";
715
565
  /**
716
- * The search-order steer, emitted only when this launch serves `code`.
566
+ * The search-order steer, emitted whenever the `code` tool is in the roster.
567
+ *
568
+ * Two variants, because the tool answers with two different engines and a
569
+ * digest that claims the wrong one is worse than silence. `semanticReady`
570
+ * (the launch opted into `--search` or Bluebird) selects the first; every
571
+ * other launch gets the second. The lexical variant is the default so the
572
+ * digest never claims a meaning-ranked index that nothing provisioned: the
573
+ * stock launch publishes `code` (`pi-mcp-config.ts` pushes the `search` group
574
+ * unconditionally) while `--search` defaults off, so this is the common path.
717
575
  *
718
- * The tool's own description already says semantic-first with a labelled
719
- * lexical fallback, but a description is read once at roster time and the
720
- * model still reaches for `grep` first on exact strings. This sentence is the
721
- * ordering, stated where it is read every turn: narrow by meaning first,
722
- * because a semantic hit set is ranked and small, then fall back to
723
- * `rg`/`grep` for what meaning cannot answer — every occurrence, a literal
724
- * token, a regex, a filename.
576
+ * Both variants carry the same four jobs that ranking cannot do — every
577
+ * occurrence, an exact token, a regex, a filename — because the tool's own
578
+ * description is read once at roster time while the digest is read every
579
+ * turn, and without the split the model greps for concepts and reads the
580
+ * whole tree for symbols. Both also carry the `tool_search` hint: the server is
581
+ * published with `exposure: "deferred"`, so the tool does not exist in the
582
+ * model's surface until it loads it, and naming `code` alone is a dead pointer.
725
583
  *
726
- * Only emitted when the launch actually serves the tool (`surfaces.codeSearch`,
727
- * i.e. `--search` or Bluebird). Naming a tool that is not in the roster is the
728
- * failure mode the digest exists to avoid.
584
+ * Neither variant claims why a fallback happened. `lexical-fallback` is
585
+ * returned both mid-index and when ColBERT is disabled or unprovisioned
586
+ * (`unified-code-search.ts`: `semanticOffNotice()` rides the same source
587
+ * label), so the text says what the label means and leaves the cause to the
588
+ * `notice`.
729
589
  */
730
- const PI_SEARCH_ORDER_LINE = "- When code search is available, narrow with semantic `code` search first — it ranks by meaning and returns a small relevant set — then reach for rg/grep for what meaning cannot answer: every occurrence, an exact token, a regex, or a filename.";
590
+ const PI_SEARCH_ORDER_LINE = "- Search `code` first, before reading broadly: load it with `tool_search`, then semantic mode for intent and `lexical`/`exact` for a symbol, file, error, route, flag, or config key. `source`/`notice` say which engine answered; `lexical-fallback` means semantic did not run, not that the symbol is absent. Take what ranking cannot answer to rg/grep: every occurrence, an exact token, a regex, a filename. Never shell out to `grep -r`: the `grep` tool already runs ripgrep, and `rg -uu` is the only search that needs bash.";
591
+ /** The lexical-backend sibling of {@link PI_SEARCH_ORDER_LINE}, for a launch
592
+ * whose `code` tool answers without a semantic index. */
593
+ const PI_SEARCH_ORDER_LEXICAL_LINE = "- Search `code` first, before reading broadly: load it with `tool_search`. Semantic is off on this launch (`--search` turns it on), so it answers lexically and a `lexical-fallback` source is the expected state, not a miss. Take what it cannot answer to rg/grep: every occurrence, an exact token, a regex, a filename. Never shell out to `grep -r`: the `grep` tool already runs ripgrep.";
594
+ /**
595
+ * The batching steer. Pi runs every tool call from one assistant message
596
+ * concurrently with no semaphore (`src/vendor/pi/agent/agent-loop.ts`,
597
+ * `executeToolCallsParallel` -> `Promise.all`), and its own system prompt never
598
+ * mentions batching, so a model that issues one call per turn pays a full
599
+ * round trip per lookup. The second half is not a hedge: two edits of the same
600
+ * file in one batch race, and a call whose arguments come from an earlier
601
+ * result cannot be batched at all.
602
+ */
603
+ const PI_PARALLEL_TOOL_LINE = "- Batch independent tool calls into one message: they run concurrently, so N reads, searches, or `ls` calls cost one round trip instead of N turns. Keep dependent calls and two edits of the same file in separate turns.";
604
+ /**
605
+ * The bounded-call steer. `timeout` is the ONLY per-call bound Pi exposes, and
606
+ * only `bash`/`powershell` take it; its schema documents "no default timeout"
607
+ * (`dist/core/tools/bash.js`), so an unbounded command can hold the turn
608
+ * indefinitely. There is no global tool timeout, concurrency cap, or
609
+ * forced-sequential setting in `schemas/settings.schema.json`, and the model
610
+ * cannot cancel a running call (`killProcessTree` runs at the bound or on the
611
+ * user's abort), so the instruction is to choose the bound up front rather
612
+ * than to stop a call later: an expired bound kills the process tree and
613
+ * returns, which is the outcome the digest wants.
614
+ */
615
+ const PI_TOOL_TIMEOUT_LINE = "- Pass `timeout` (seconds) to `bash` and `powershell`: neither has a default, and the process is killed at the bound rather than left running. Read an expired bound as a signal that the command was too broad: narrow it and re-issue, unless the work is genuinely long, in which case bound it past the expected run.";
731
616
  function piCopilotContractFor(profileId) {
732
617
  return isCheapestFamily(profileId) ? cheapestContractFor(profileId) : balancedContractFor(profileId);
733
618
  }
@@ -1583,6 +1468,7 @@ function roleDescription(profileId, role) {
1583
1468
  function buildPiAgentFiles(profileId) {
1584
1469
  const files = {};
1585
1470
  const advisor = piAdvisorModel(profileId);
1471
+ const gatheringSteer = isCheapestFamily(profileId) || isLocalFamily(profileId);
1586
1472
  for (const role of piNativeRoles(profileId)) {
1587
1473
  const isImplementer = role.name === "General-Purpose";
1588
1474
  const isReviewer = role.name === "reviewer";
@@ -1605,11 +1491,14 @@ function buildPiAgentFiles(profileId) {
1605
1491
  if (isBalancedFamily(profileId) && isReviewer) lines.push("allowNestedSubagents: true", "allowedAgents: Explore");
1606
1492
  if (advisor && isReviewer) lines.push("allowNestedSubagents: true", "allowedAgents: advisor");
1607
1493
  lines.push("---", "");
1608
- if (role.name === "Explore") lines.push("You are a read-only scout. Never modify files.", "Use bash only for non-interactive inspection.", "Search first, read second: return the smallest sufficient evidence — entry points,", "key types and functions, data flow, files likely to need changes, constraints and", "open questions — with exact file paths and line ranges.");
1494
+ const gatherSteer = gatheringSteer ? ["`grep` runs ripgrep and `find` walks the tree: narrow the `path` or `glob` before you", "read, and never shell out to `grep -r`."] : [];
1495
+ const batchSteer = gatheringSteer ? ["Batch independent searches and reads into one turn; they run concurrently."] : [];
1496
+ const boundsSteer = gatheringSteer ? ["Pass `bash` a `timeout` (seconds) for anything that can hang: there is no default."] : [];
1497
+ if (role.name === "Explore") lines.push("You are a read-only scout. Never modify files.", "Use bash only for non-interactive inspection.", ...gatherSteer, "Search first, read second: return the smallest sufficient evidence — entry points,", "key types and functions, data flow, files likely to need changes, constraints and", "open questions — with exact file paths and line ranges.", ...batchSteer, ...boundsSteer);
1609
1498
  else if (isReviewer) {
1610
- lines.push("You are a disciplined review subagent. Inspect the actual change; verify from code,", "tests, and docs — never guess. Cover intent match, correctness and edge cases,", "test coverage, side effects, and minimality.", "Report findings with file:line evidence ranked P0 (blocker) / P1 (should fix) / P2 (nit),", "ending with one of: Merge verdict: BLOCK, Merge verdict: OK, Merge verdict: OK with notes.", "You have no shell: cite the test commands for the lead to run rather than executing them.", "Do not rewrite code outside small, clearly-marked suggestions.");
1499
+ lines.push("You are a disciplined review subagent. Inspect the actual change; verify from code,", "tests, and docs — never guess. Cover intent match, correctness and edge cases,", "test coverage, side effects, and minimality.", ...gatherSteer, ...batchSteer, "Report findings with file:line evidence ranked P0 (blocker) / P1 (should fix) / P2 (nit),", "ending with one of: Merge verdict: BLOCK, Merge verdict: OK, Merge verdict: OK with notes.", "You have no shell: cite the test commands for the lead to run rather than executing them.", "Do not rewrite code outside small, clearly-marked suggestions.");
1611
1500
  if (advisor) lines.push("You may consult the `advisor` subagent, the profile's own consultant,", "on the Advisor contract the lead uses: it sees only the brief you write.", "You own the verdict; the advisor is counsel, never authority: it never", "approves, vetoes, or decides for you.", "Budget: at most 5 advisor rounds per review — one round is one back-and-forth", "exchange. Spend them only on consequential uncertainty that code, builds, or tests", "cannot settle: a changed assumption, conflicting evidence, an approach that will", "not converge, or a severity call with merge-blocking consequences. Never consult for", "routine verification, progress narration, or completion ritual — run the check", "yourself. State the question, your evidence with file:line citations, the credible", "alternatives, and what evidence would change your verdict. If the advisor disagrees,", "evaluate on the merits: adopt what is right with a one-line reason, defend what you", "verified with evidence, and record the disagreement in your report. Do not delegate", "to any other agent.");
1612
- } else lines.push("You are the single writer thread. Execute the assigned task with narrow, coherent edits;", "the lead remains the decision authority. Work from the brief's pasted context,", "then implement minimally and verify by running the relevant tests.", "If the work reveals an unapproved decision you cannot safely resolve, stop and escalate", "instead of guessing; never leave placeholders or TODOs.", "Hand behavior-changing results to reviewer when asked; otherwise summarize the diff,", "validation, risks, and next step.");
1501
+ } else lines.push("You are the single writer thread. Execute the assigned task with narrow, coherent edits;", "the lead remains the decision authority. Work from the brief's pasted context,", "then implement minimally and verify by running the relevant tests.", ...gatherSteer, ...batchSteer, ...boundsSteer, "If the work reveals an unapproved decision you cannot safely resolve, stop and escalate", "instead of guessing; never leave placeholders or TODOs.", "Hand behavior-changing results to reviewer when asked; otherwise summarize the diff,", "validation, risks, and next step.");
1613
1502
  files[`agents/${agentFileName(role.name)}`] = `${lines.join("\n")}\n`;
1614
1503
  }
1615
1504
  const oracleModel = piOracleModel(profileId);
@@ -1717,16 +1606,36 @@ const PI_CONTEXT_CONTRACT_LINE = "- Your project instructions below come from `A
1717
1606
  * Short operating digest appended to APPEND_SYSTEM.md (prompt-cache-stable).
1718
1607
  * Mode identity — always injected. Peer consult sentences drop out under
1719
1608
  * `peers: false` so the digest never names tools that don't exist.
1609
+ *
1610
+ * `codeTool` answers "is the `code` search tool in this launch's roster", NOT
1611
+ * "did `--search` opt into a semantic index". The `search` MCP group is pushed
1612
+ * unconditionally (`pi-mcp-config.ts`), so the tool is in every session while
1613
+ * `--search` defaults off; gating the search-order line on the flag left the
1614
+ * tool undocumented on the stock launch, which is the one that needs the
1615
+ * ordering most. `semanticReady` only picks which of the two order lines it
1616
+ * gets, and defaults to the lexical one rather than claiming an engine nothing
1617
+ * provisioned.
1618
+ *
1619
+ * The search-order line rides every profile that has the tool, `balanced*`
1620
+ * included: which engine answers, and when to reach for `rg` instead, is true
1621
+ * regardless of who gathers first. The batching and bounded-call steer is the
1622
+ * narrower one — only `cheapest*` and `local*`, whose leads do their own
1623
+ * gathering; `balanced*` sends discovery to `Explore` first, so those two
1624
+ * would fight its pipeline. `codeTool: false` omits the search line entirely:
1625
+ * a pointer to a tool the session does not have is the failure this digest
1626
+ * exists to avoid.
1720
1627
  */
1721
1628
  function buildPiAppendSystem(profileId, opts = {}) {
1722
1629
  const peers = opts.peers !== false;
1723
1630
  const advisor = peers ? piAdvisorModel(profileId) : void 0;
1631
+ const gatheringSteer = isCheapestFamily(profileId) || isLocalFamily(profileId);
1724
1632
  const lines = [
1725
1633
  `# gh-router ${profileId} mode`,
1726
1634
  "",
1727
1635
  `- Lead owns planning directly; there is no Plan subagent.`,
1728
1636
  PI_TOOL_PREFERENCE_LINE,
1729
- ...opts.codeSearch === true ? [PI_SEARCH_ORDER_LINE] : [],
1637
+ ...opts.codeTool === true ? [opts.semanticReady === true ? PI_SEARCH_ORDER_LINE : PI_SEARCH_ORDER_LEXICAL_LINE] : [],
1638
+ ...gatheringSteer ? [PI_PARALLEL_TOOL_LINE, PI_TOOL_TIMEOUT_LINE] : [],
1730
1639
  ...opts.bridge === true ? [PI_CONTEXT_CONTRACT_LINE] : []
1731
1640
  ];
1732
1641
  if (peers) {
@@ -3432,7 +3341,7 @@ function readMcpServerKeys(raw) {
3432
3341
  */
3433
3342
  const GROUP_DESCRIPTIONS = {
3434
3343
  peers: "Cross-lab adversarial reviewers (codex_critic, codex_reviewer, gemini_critic, gemini_reviewer, opus_critic) plus oracle, a stateless expert consultant. Reach for a critic when a plan or a diff needs a second lab's judgement; reach for oracle when repository evidence alone cannot settle a self-contained technical trade-off.",
3435
- search: "Code and web search for this workspace. code is semantic-first with a labelled lexical fallback and reports which engine answered; web runs a Copilot-backed web search. Reach for code before broad file reads when you are locating code by meaning rather than by exact text.",
3344
+ search: "Code and web search for this workspace: code ranks the tree by meaning or lexical match and says which engine answered, while web runs a Copilot-backed search. Reach for code before broad file reads.",
3436
3345
  workers: "Autonomous worker subagents that run their own agent loop on a scoped task: explore reads and searches, review also runs commands to verify, implement edits files in an isolated git worktree and returns the diff. Reach for a worker when the task is big enough that its context should not land in yours.",
3437
3346
  browser: "Drive a real Chrome or Edge tab: open, navigate, read the page, screenshot, click, type, evaluate JavaScript. Reach for it when the answer lives in a web UI rather than in the repository.",
3438
3347
  ado: "Azure DevOps for the open repository: repositories, work items, pipelines and wikis.",
@@ -3866,7 +3775,6 @@ const pi = defineCommand({
3866
3775
  const precedence = await inspectMirrorPrecedence(mirror, process$1.cwd());
3867
3776
  if (precedence.systemMd) consola.warn(`Pi: ${path.join(mirror, "SYSTEM.md")} REPLACES Pi's default system prompt. gh-router's mode guidance is still appended to it, but any harness rules your SYSTEM.md leaves out are not restored. Remove it (or merge it into APPEND_SYSTEM.md) for the stock prompt.`);
3868
3777
  if (precedence.projectAppendSystem) consola.warn(`Pi: ${precedence.projectAppendSystem} exists. If this project is trusted, Pi loads it INSTEAD of the gh-router mode digest (the mirror's APPEND_SYSTEM.md). Keep one or the other.`);
3869
- let packagesForCache = [];
3870
3778
  let foreignAvailable;
3871
3779
  let foreignStats;
3872
3780
  const launchSecret = randomBytes(32).toString("hex");
@@ -3929,8 +3837,8 @@ const pi = defineCommand({
3929
3837
  userKeybindings = {};
3930
3838
  }
3931
3839
  await writeJsonFile(keybindingsPath, { ...mergePiKeybindingsSettings(userKeybindings, buildPiKeybindingsJson()) });
3932
- packagesForCache = [...builtSettings.packages];
3933
- if (await seedPiPackageCache(mirror, packagesForCache)) consola.debug("Pi package cache hit: mirror pre-seeded, skipping registry install.");
3840
+ const seed = await seedPiPackageCache(mirror, builtSettings.packages);
3841
+ consola.debug(`Pi package cache: ${seed.reason}.`);
3934
3842
  const bridgeDisabled = args["memory-bridge"] === false || process$1.env.GH_ROUTER_PI_BRIDGE === "0" || process$1.env.GH_ROUTER_DISABLE_PI_BRIDGE === "1";
3935
3843
  let bridgeStats;
3936
3844
  let bridgeScoped = [];
@@ -3976,7 +3884,8 @@ const pi = defineCommand({
3976
3884
  for (const prompt of routerPrompts) await writeTextFile(path.join(mirror, "prompts", `${prompt.name}.md`), prompt.content);
3977
3885
  await writeTextFile(path.join(mirror, "APPEND_SYSTEM.md"), buildPiAppendSystem(profileId, {
3978
3886
  peers: peersEnabled,
3979
- codeSearch: surfaces.codeSearch,
3887
+ codeTool: true,
3888
+ semanticReady: surfaces.codeSearch,
3980
3889
  bridge: bridgeActive
3981
3890
  }));
3982
3891
  let foreign;
@@ -4162,7 +4071,7 @@ const pi = defineCommand({
4162
4071
  })}\n`);
4163
4072
  if (sweEnabled && !peersEnabled) process$1.stderr.write("Note: --swe without --peers emits no delegate/review skills or prompts (no agents behind them in a peerless launch).\n");
4164
4073
  const { disposeBluebirdClients } = await import("./bluebird-client-BvoMTmEv.js");
4165
- const { disposeAdoClients } = await import("./ado-tools-CsfbnY8x.js");
4074
+ const { disposeAdoClients } = await import("./ado-tools-CNEWS1kF.js");
4166
4075
  launchChild({
4167
4076
  kind: "pi",
4168
4077
  execArgs: piCommand && piCommand.command !== "" ? [piCommand.command, ...piCommand.args] : void 0,
@@ -4184,7 +4093,6 @@ const pi = defineCommand({
4184
4093
  await stopKeepAwake();
4185
4094
  await disposeBluebirdClients();
4186
4095
  await disposeAdoClients();
4187
- await savePiPackageCache(mirror, packagesForCache);
4188
4096
  await removeOwnPiAgentMirror();
4189
4097
  await removeAicLedgerFile();
4190
4098
  },
@@ -4200,4 +4108,4 @@ const pi = defineCommand({
4200
4108
  });
4201
4109
  export { pi };
4202
4110
 
4203
- //# sourceMappingURL=pi-YhoA26wi.js.map
4111
+ //# sourceMappingURL=pi-D9IbxlSj.js.map