github-router 0.3.350 → 0.3.352
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.
- package/NOTICE +72 -0
- package/README.md +19 -0
- package/dist/ado-tools-xbuVU7YN.js +1 -0
- package/dist/{aic-ledger-D4oMcg7c.js → aic-ledger-BdvCgRmx.js} +3 -3
- package/dist/{aic-ledger-D4oMcg7c.js.map → aic-ledger-BdvCgRmx.js.map} +1 -1
- package/dist/{aic-statusline-settings-DCFywz3N.js → aic-statusline-settings-LnoxjBPe.js} +2 -2
- package/dist/{aic-statusline-settings-DCFywz3N.js.map → aic-statusline-settings-LnoxjBPe.js.map} +1 -1
- package/dist/{attribution-settings-B9T-EsEs.js → attribution-settings-ul6VU6iP.js} +11 -650
- package/dist/attribution-settings-ul6VU6iP.js.map +1 -0
- package/dist/{auth-Cgsy2T0s.js → auth-a_1lXYZ1.js} +4 -4
- package/dist/{auth-Cgsy2T0s.js.map → auth-a_1lXYZ1.js.map} +1 -1
- package/dist/{bluebird-client-DpYl1YmJ.js → bluebird-client-ltPIiyJU.js} +1103 -499
- package/dist/bluebird-client-ltPIiyJU.js.map +1 -0
- package/dist/bluebird-client-mr3M67k-.js +1 -0
- package/dist/browser-bridge/index.js +116 -98
- package/dist/browser-ext/manifest.json +1 -1
- package/dist/{check-usage-26G2hw_F.js → check-usage-Bsbc-Sn6.js} +4 -4
- package/dist/{check-usage-26G2hw_F.js.map → check-usage-Bsbc-Sn6.js.map} +1 -1
- package/dist/claude-md-injection-BoXOsg7h.js +669 -0
- package/dist/claude-md-injection-BoXOsg7h.js.map +1 -0
- package/dist/{claude-BY4e9ueE.js → claude-xO1XW-Nn.js} +79 -51
- package/dist/claude-xO1XW-Nn.js.map +1 -0
- package/dist/{codex-BOugL-uX.js → codex-DzUR40JA.js} +10 -8
- package/dist/{codex-BOugL-uX.js.map → codex-DzUR40JA.js.map} +1 -1
- package/dist/{copilot-discount-CilBhKQW.js → copilot-discount-C3jfysK-.js} +2 -2
- package/dist/{copilot-discount-CilBhKQW.js.map → copilot-discount-C3jfysK-.js.map} +1 -1
- package/dist/{debug-CigFsS-h.js → debug-BtqbflcL.js} +2 -2
- package/dist/{debug-CigFsS-h.js.map → debug-BtqbflcL.js.map} +1 -1
- package/dist/engine-DwLIk1Zn.js +1 -0
- package/dist/{exec-MCU1H-KZ.js → exec-Bf8g_bIR.js} +27 -2
- package/dist/exec-Bf8g_bIR.js.map +1 -0
- package/dist/{gate-discovery-BFqulsWz.js → gate-discovery-Cvdko01z.js} +6 -6
- package/dist/{gate-discovery-BFqulsWz.js.map → gate-discovery-Cvdko01z.js.map} +1 -1
- package/dist/{get-copilot-usage-C_6ast5h.js → get-copilot-usage-0_S8pRWJ.js} +3 -3
- package/dist/{get-copilot-usage-C_6ast5h.js.map → get-copilot-usage-0_S8pRWJ.js.map} +1 -1
- package/dist/{hook-mcp-client-BRL_y-bz.js → hook-mcp-client-DERIkeR7.js} +5 -3
- package/dist/{hook-mcp-client-BRL_y-bz.js.map → hook-mcp-client-DERIkeR7.js.map} +1 -1
- package/dist/hooks.mjs +10998 -6840
- package/dist/hooks.sha256 +1 -1
- package/dist/{index-cmd-DXYWgKS6.js → index-cmd-CJXUOH4q.js} +5 -5
- package/dist/{index-cmd-DXYWgKS6.js.map → index-cmd-CJXUOH4q.js.map} +1 -1
- package/dist/{internal-aic-status-lM0YNDaH.js → internal-aic-status-Dmi2bCsR.js} +4 -4
- package/dist/{internal-aic-status-lM0YNDaH.js.map → internal-aic-status-Dmi2bCsR.js.map} +1 -1
- package/dist/{internal-artifact-open-DErO3WpR.js → internal-artifact-open-C67gDjKo.js} +2 -2
- package/dist/{internal-artifact-open-DErO3WpR.js.map → internal-artifact-open-C67gDjKo.js.map} +1 -1
- package/dist/{internal-fast-dispatch-guard-DRsZJ-Rg.js → internal-fast-dispatch-guard-BQm1MI9d.js} +2 -2
- package/dist/{internal-fast-dispatch-guard-DRsZJ-Rg.js.map → internal-fast-dispatch-guard-BQm1MI9d.js.map} +1 -1
- package/dist/internal-fast-dispatch-guard-Cv7zf0ZI.js +1 -0
- package/dist/{internal-first-mate-guard-BEwDjHfX.js → internal-first-mate-guard-BJvCsVlU.js} +3 -3
- package/dist/{internal-first-mate-guard-BEwDjHfX.js.map → internal-first-mate-guard-BJvCsVlU.js.map} +1 -1
- package/dist/internal-first-mate-guard-D-IQGiTs.js +1 -0
- package/dist/{internal-max-dispatch-guard-DSjJwVH2.js → internal-max-dispatch-guard-DkJixDmG.js} +7 -5
- package/dist/{internal-max-dispatch-guard-DSjJwVH2.js.map → internal-max-dispatch-guard-DkJixDmG.js.map} +1 -1
- package/dist/internal-max-dispatch-guard-T-M7DRIW.js +1 -0
- package/dist/{internal-plan-review-DbX-mr9i.js → internal-plan-review-DIvaBBUd.js} +4 -4
- package/dist/{internal-plan-review-DbX-mr9i.js.map → internal-plan-review-DIvaBBUd.js.map} +1 -1
- package/dist/internal-prompt-submit-6OXEdQCK.js +2 -0
- package/dist/internal-prompt-submit-B9MJxc3K.js +194 -0
- package/dist/internal-prompt-submit-B9MJxc3K.js.map +1 -0
- package/dist/{internal-rebrief-BH9PMJhF.js → internal-rebrief-zIdunX3R.js} +6 -6
- package/dist/{internal-rebrief-BH9PMJhF.js.map → internal-rebrief-zIdunX3R.js.map} +1 -1
- package/dist/{internal-session-bind-DxdVbJ7x.js → internal-session-bind-CQLDPuTx.js} +2 -2
- package/dist/{internal-session-bind-DxdVbJ7x.js.map → internal-session-bind-CQLDPuTx.js.map} +1 -1
- package/dist/{internal-stop-hook-DlGc9WwJ.js → internal-stop-hook-DGcRVh_2.js} +7 -7
- package/dist/{internal-stop-hook-DlGc9WwJ.js.map → internal-stop-hook-DGcRVh_2.js.map} +1 -1
- package/dist/{internal-stop-review-CORT3UGr.js → internal-stop-review-X7zRRhyc.js} +3 -3
- package/dist/{internal-stop-review-CORT3UGr.js.map → internal-stop-review-X7zRRhyc.js.map} +1 -1
- package/dist/{internal-worker-guard-C0FJ4b29.js → internal-worker-guard-wP3UN-3D.js} +2 -2
- package/dist/{internal-worker-guard-C0FJ4b29.js.map → internal-worker-guard-wP3UN-3D.js.map} +1 -1
- package/dist/{internal-workspace-header-tvJVAXpv.js → internal-workspace-header-DiUnkUeU.js} +2 -2
- package/dist/{internal-workspace-header-tvJVAXpv.js.map → internal-workspace-header-DiUnkUeU.js.map} +1 -1
- package/dist/lib/tree-sitter-pool/worker.js +1 -2
- package/dist/{lifecycle-BqWTXaeC.js → lifecycle-BJ83L0tz.js} +3 -3
- package/dist/{lifecycle-BqWTXaeC.js.map → lifecycle-BJ83L0tz.js.map} +1 -1
- package/dist/lifecycle-CVg2-zQ3.js +1 -0
- package/dist/lifecycle-Dk_BHtfz.js +1 -0
- package/dist/{lifecycle-kpLzHUgD.js → lifecycle-aApO0hZW.js} +2 -2
- package/dist/{lifecycle-kpLzHUgD.js.map → lifecycle-aApO0hZW.js.map} +1 -1
- package/dist/main.js +23 -23
- package/dist/{max-profile-contract--dAYkEG1.js → max-profile-contract-DQDEDCsR.js} +2 -2
- package/dist/{max-profile-contract--dAYkEG1.js.map → max-profile-contract-DQDEDCsR.js.map} +1 -1
- package/dist/{mcp-workspace-header-B77WqVFw.js → mcp-workspace-header-DBQugQlQ.js} +2 -2
- package/dist/{mcp-workspace-header-B77WqVFw.js.map → mcp-workspace-header-DBQugQlQ.js.map} +1 -1
- package/dist/{models-BGCeGVXl.js → models-JIvKAGn0.js} +3 -3
- package/dist/{models-BGCeGVXl.js.map → models-JIvKAGn0.js.map} +1 -1
- package/dist/{orchestration-Dkqv-iv0.js → orchestration-D-S_0GVt.js} +3 -3
- package/dist/{orchestration-Dkqv-iv0.js.map → orchestration-D-S_0GVt.js.map} +1 -1
- package/dist/paths-C9x5U3dO.js +1 -0
- package/dist/{paths-CpbTHKeP.js → paths-xTSEAWfN.js} +115 -22
- package/dist/paths-xTSEAWfN.js.map +1 -0
- package/dist/{peer-mcp-personas-BwwSNnBC.js → peer-mcp-personas-DDMKRFFG.js} +2350 -836
- package/dist/peer-mcp-personas-DDMKRFFG.js.map +1 -0
- package/dist/{pi-Dpw8Otxw.js → pi-jVNeQXWf.js} +362 -37
- package/dist/pi-jVNeQXWf.js.map +1 -0
- package/dist/{plan-review-hook-LfG01VMp.js → plan-review-hook-BQ29WGv7.js} +5 -5
- package/dist/{plan-review-hook-LfG01VMp.js.map → plan-review-hook-BQ29WGv7.js.map} +1 -1
- package/dist/{provision-9TAIgyL7.js → provision-BtYRtvrj.js} +26 -18
- package/dist/provision-BtYRtvrj.js.map +1 -0
- package/dist/{self-invocation-DIUyoRgL.js → self-invocation-Dr5zlbpM.js} +2 -2
- package/dist/{self-invocation-DIUyoRgL.js.map → self-invocation-Dr5zlbpM.js.map} +1 -1
- package/dist/{serve-BRKRWkd1.js → serve-CmgmxigM.js} +35 -17
- package/dist/serve-CmgmxigM.js.map +1 -0
- package/dist/{server-setup-DXVFE7bf.js → server-setup-DinOFWiC.js} +393 -42
- package/dist/server-setup-DinOFWiC.js.map +1 -0
- package/dist/{service-backend-7SPDLUB9.js → service-backend-DV1u5x0Q.js} +51 -23
- package/dist/service-backend-DV1u5x0Q.js.map +1 -0
- package/dist/{start-CoR3jqUR.js → start-Dgsaz0HM.js} +4 -4
- package/dist/{start-CoR3jqUR.js.map → start-Dgsaz0HM.js.map} +1 -1
- package/dist/{state-CVp30CBF.js → state-CfEVoqBM.js} +8 -1
- package/dist/{state-CVp30CBF.js.map → state-CfEVoqBM.js.map} +1 -1
- package/dist/{prompt-submit-hook-DzhmQRs_.js → static-context-pack-CyucviRD.js} +402 -4
- package/dist/static-context-pack-CyucviRD.js.map +1 -0
- package/dist/{stop-gate-hook-C9VNxmt1.js → stop-gate-hook-BYd0NruJ.js} +4 -4
- package/dist/{stop-gate-hook-C9VNxmt1.js.map → stop-gate-hook-BYd0NruJ.js.map} +1 -1
- package/dist/{stop-gate-policy-DQsfjnsx.js → stop-gate-policy-FGAfpfc-.js} +3 -3
- package/dist/{stop-gate-policy-DQsfjnsx.js.map → stop-gate-policy-FGAfpfc-.js.map} +1 -1
- package/dist/{token-s5Wd-Kwr.js → token-CTf5jCmP.js} +7 -5
- package/dist/{token-s5Wd-Kwr.js.map → token-CTf5jCmP.js.map} +1 -1
- package/dist/{worker-dispatch-lRhno09M.js → worker-dispatch-BjfROaic.js} +2 -2
- package/dist/{worker-dispatch-lRhno09M.js.map → worker-dispatch-BjfROaic.js.map} +1 -1
- package/docs/azure-mcp.md +453 -0
- package/docs/bluebird-search.md +96 -7
- package/package.json +22 -22
- package/dist/attribution-settings-B9T-EsEs.js.map +0 -1
- package/dist/bluebird-client-DpYl1YmJ.js.map +0 -1
- package/dist/bluebird-client-bn9Yv6Cb.js +0 -2
- package/dist/claude-BY4e9ueE.js.map +0 -1
- package/dist/engine-DZfLaVcf.js +0 -2
- package/dist/exec-MCU1H-KZ.js.map +0 -1
- package/dist/internal-fast-dispatch-guard-DeZ6KilC.js +0 -2
- package/dist/internal-first-mate-guard-CAefr6Ce.js +0 -2
- package/dist/internal-max-dispatch-guard-KmbYwh7h.js +0 -2
- package/dist/internal-prompt-submit-CA5Y4DWM.js +0 -2
- package/dist/internal-prompt-submit-UhfnM_qG.js +0 -573
- package/dist/internal-prompt-submit-UhfnM_qG.js.map +0 -1
- package/dist/lifecycle-DMRZswwc.js +0 -2
- package/dist/lifecycle-FT75ohVw.js +0 -2
- package/dist/paths-CpbTHKeP.js.map +0 -1
- package/dist/paths-Dfivvq21.js +0 -2
- package/dist/peer-mcp-personas-BwwSNnBC.js.map +0 -1
- package/dist/pi-Dpw8Otxw.js.map +0 -1
- package/dist/prompt-submit-hook-DzhmQRs_.js.map +0 -1
- package/dist/provision-9TAIgyL7.js.map +0 -1
- package/dist/serve-BRKRWkd1.js.map +0 -1
- package/dist/server-setup-DXVFE7bf.js.map +0 -1
- package/dist/service-backend-7SPDLUB9.js.map +0 -1
|
@@ -1,16 +1,17 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { L as withInstallLock, P as warmTreeSitterPool } from "./service-backend-DV1u5x0Q.js";
|
|
2
2
|
import { t as getPackageVersion } from "./version-C8x2hQrZ.js";
|
|
3
|
-
import { t as PATHS } from "./paths-
|
|
4
|
-
import { t as state } from "./state-
|
|
5
|
-
import { c as
|
|
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-
|
|
3
|
+
import { t as PATHS } from "./paths-xTSEAWfN.js";
|
|
4
|
+
import { t as state } from "./state-CfEVoqBM.js";
|
|
5
|
+
import { c as runCommandCapture, s as resolveExecutable, u as runCommandVoid } from "./exec-Bf8g_bIR.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-DinOFWiC.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-XiIj4O1U.js";
|
|
8
|
-
import {
|
|
9
|
-
import { r as resolveSelfInvocation } from "./self-invocation-
|
|
10
|
-
import { i as launchChild, t as provisionToolbelt } from "./provision-
|
|
11
|
-
import { d as sweepStaleAicLedgerFiles, n as aicSnapshot, o as formatAicExitSummary, t as aicLedgerPath, u as removeAicLedgerFile } from "./aic-ledger-
|
|
12
|
-
import {
|
|
13
|
-
import { n as
|
|
8
|
+
import { D as toolbeltEnabled, Gn as CHEAPEST_PROFILE_MODELS, Un as CHEAPEST_PROFILE_ADVISOR_EFFORT, Wn as CHEAPEST_PROFILE_ADVISOR_MODEL, Xn as CHEAPEST_PROFILE_ORACLE_MODEL, Yn as CHEAPEST_PROFILE_ORACLE_EFFORT, _n as colbertDegradedWarning, fn as provisionBrowserAssets, nn as unregisterLaunch, pt as adoToolsEnabled, qn as CHEAPEST_PROFILE_NATIVE_EFFORTS, tn as registerLaunch, vn as provisionAndIndexColbert, xt as browserToolsEnabled, zt as kustoToolsEnabled } from "./peer-mcp-personas-DDMKRFFG.js";
|
|
9
|
+
import { r as resolveSelfInvocation } from "./self-invocation-Dr5zlbpM.js";
|
|
10
|
+
import { i as launchChild, t as provisionToolbelt } from "./provision-BtYRtvrj.js";
|
|
11
|
+
import { d as sweepStaleAicLedgerFiles, n as aicSnapshot, o as formatAicExitSummary, t as aicLedgerPath, u as removeAicLedgerFile } from "./aic-ledger-BdvCgRmx.js";
|
|
12
|
+
import { t as CHEAPEST_CONSULT_CONTRACT } from "./claude-md-injection-BoXOsg7h.js";
|
|
13
|
+
import { i as buildAicStatusHookCommand, n as AIC_STATUSLINE_DISABLE_ENV, t as AIC_LEDGER_ENV } from "./aic-statusline-settings-LnoxjBPe.js";
|
|
14
|
+
import { n as formatDiscountedCostTable, t as discountedUsdForSnapshot } from "./copilot-discount-C3jfysK-.js";
|
|
14
15
|
import { defineCommand } from "citty";
|
|
15
16
|
import consola from "consola";
|
|
16
17
|
import { existsSync } from "node:fs";
|
|
@@ -21,8 +22,55 @@ import os from "node:os";
|
|
|
21
22
|
import process$1 from "node:process";
|
|
22
23
|
//#region src/lib/pi-version-check.ts
|
|
23
24
|
const PI_NPM_PACKAGE = "@earendil-works/pi-coding-agent";
|
|
24
|
-
/**
|
|
25
|
-
|
|
25
|
+
/**
|
|
26
|
+
* Minimum Pi version the `pi` launcher supports.
|
|
27
|
+
*
|
|
28
|
+
* The floor is pinned to the first release whose `before_agent_start` event
|
|
29
|
+
* carries the `messageType` discriminator (present at 1.3.0, absent at 1.1.0).
|
|
30
|
+
* The generated extension's prompt hook stands down for non-user events using
|
|
31
|
+
* that field, and without it the hook would fire on subagent and system turns
|
|
32
|
+
* the user never typed, which is a wrong brief rather than a missing one.
|
|
33
|
+
* Below-floor Pi hard-exits at the launcher (`src/pi.ts`), but only where the
|
|
34
|
+
* gate actually runs: the install probe, the background refresh, and this floor
|
|
35
|
+
* check all sit inside `--update-check` (default on), so `--no-update-check`
|
|
36
|
+
* (documented for offline/CI) skips the floor as well. That path is still
|
|
37
|
+
* fail-closed rather than silently wrong: the generated extension's own shape
|
|
38
|
+
* probe sees the missing `messageType`, warns once with the fix, and injects
|
|
39
|
+
* nothing.
|
|
40
|
+
*/
|
|
41
|
+
const PI_MIN_VERSION = "1.3.0";
|
|
42
|
+
/**
|
|
43
|
+
* Registry used for the PI PACKAGE ONLY.
|
|
44
|
+
*
|
|
45
|
+
* Pi must come from a registry that actually carries it. A corporate npm mirror
|
|
46
|
+
* can lag npmjs far enough that its `latest` sits below `PI_MIN_VERSION`, and
|
|
47
|
+
* the launcher then fail-closes on an upgrade command the user cannot satisfy
|
|
48
|
+
* (their `npm install -g` resolves through the same lagging mirror). Pointing
|
|
49
|
+
* the Pi probe and install at npmjs by default keeps the floor reachable;
|
|
50
|
+
* `GH_ROUTER_NPM_REGISTRY` overrides it for a mirror that does carry the
|
|
51
|
+
* package. Everything else this repo installs still resolves through the user's
|
|
52
|
+
* configured registry.
|
|
53
|
+
*/
|
|
54
|
+
const PI_DEFAULT_REGISTRY = "https://registry.npmjs.org/";
|
|
55
|
+
/**
|
|
56
|
+
* Resolve the registry for Pi package operations. Accepts `GH_ROUTER_NPM_REGISTRY`
|
|
57
|
+
* when it is an http(s) URL and falls back to `PI_DEFAULT_REGISTRY` with a
|
|
58
|
+
* warning otherwise, so a typo degrades to the working default rather than
|
|
59
|
+
* bricking the launcher.
|
|
60
|
+
*/
|
|
61
|
+
function resolvePiRegistry() {
|
|
62
|
+
const raw = process.env.GH_ROUTER_NPM_REGISTRY?.trim();
|
|
63
|
+
if (!raw) return PI_DEFAULT_REGISTRY;
|
|
64
|
+
if (!/^https?:\/\//i.test(raw)) {
|
|
65
|
+
consola.warn(`Ignoring GH_ROUTER_NPM_REGISTRY=${JSON.stringify(raw)}: expected an http(s) URL. Using ${PI_DEFAULT_REGISTRY}.`);
|
|
66
|
+
return PI_DEFAULT_REGISTRY;
|
|
67
|
+
}
|
|
68
|
+
return raw.endsWith("/") ? raw : `${raw}/`;
|
|
69
|
+
}
|
|
70
|
+
/** `npm` args that pin an operation to the resolved Pi registry. */
|
|
71
|
+
function piRegistryArgs(registry = resolvePiRegistry()) {
|
|
72
|
+
return [`--registry=${registry}`];
|
|
73
|
+
}
|
|
26
74
|
const THROTTLE_HOURS = 1;
|
|
27
75
|
const NPM_VIEW_TIMEOUT_MS = 5e3;
|
|
28
76
|
const PI_VERSION_TIMEOUT_MS = 3e3;
|
|
@@ -84,7 +132,8 @@ async function getLatestPiVersion() {
|
|
|
84
132
|
"view",
|
|
85
133
|
PI_NPM_PACKAGE,
|
|
86
134
|
"version",
|
|
87
|
-
"--silent"
|
|
135
|
+
"--silent",
|
|
136
|
+
...piRegistryArgs()
|
|
88
137
|
], { timeoutMs: NPM_VIEW_TIMEOUT_MS });
|
|
89
138
|
if (code !== 0) return null;
|
|
90
139
|
const v = stdout.trim();
|
|
@@ -185,12 +234,14 @@ function updatePi(version, opts = {}) {
|
|
|
185
234
|
const npmPath = resolveExecutable("npm");
|
|
186
235
|
if (!npmPath) throw new Error("npm not found on PATH; cannot install Pi automatically");
|
|
187
236
|
return withInstallLock("pi-install.lock", async () => {
|
|
188
|
-
|
|
237
|
+
const registry = resolvePiRegistry();
|
|
238
|
+
consola.info(`Installing ${PI_NPM_PACKAGE}@${version} from ${registry}...`);
|
|
189
239
|
await runCommandVoid([
|
|
190
240
|
npmPath,
|
|
191
241
|
"install",
|
|
192
242
|
"-g",
|
|
193
|
-
`${PI_NPM_PACKAGE}@${version}
|
|
243
|
+
`${PI_NPM_PACKAGE}@${version}`,
|
|
244
|
+
...piRegistryArgs(registry)
|
|
194
245
|
], {
|
|
195
246
|
timeoutMs: NPM_INSTALL_TIMEOUT_MS,
|
|
196
247
|
signal: opts.signal
|
|
@@ -239,7 +290,7 @@ function refreshPiInBackground(opts) {
|
|
|
239
290
|
if (!npmPath) return;
|
|
240
291
|
if (!latestVersion || !isPiNewer(installedVersion, latestVersion)) return;
|
|
241
292
|
if (await withInstallLock("pi-install.lock", async () => {
|
|
242
|
-
queueDetachedGlobalInstall(npmPath, `@earendil-works/pi-coding-agent@${latestVersion}
|
|
293
|
+
queueDetachedGlobalInstall(npmPath, `@earendil-works/pi-coding-agent@${latestVersion}`, piRegistryArgs());
|
|
243
294
|
})) consola.info(`Pi ${installedVersion} → ${latestVersion} update queued; it takes effect on the next launch.`);
|
|
244
295
|
} catch (err) {
|
|
245
296
|
consola.debug("Background Pi refresh failed:", err);
|
|
@@ -752,7 +803,7 @@ function piThinkingLevelMapFor(efforts) {
|
|
|
752
803
|
}
|
|
753
804
|
/** Provider key used in models.json and agent `provider/model` references. */
|
|
754
805
|
const PI_PROVIDER_NAME = "gh-router";
|
|
755
|
-
const PI_MIN_VERSION_NOTE =
|
|
806
|
+
const PI_MIN_VERSION_NOTE = `Requires Pi >= ${PI_MIN_VERSION} and Node >= 22.19.`;
|
|
756
807
|
function piLeadModel(profileId) {
|
|
757
808
|
return profileId === "cheapest" ? CHEAPEST_PROFILE_MODELS.lead : BALANCED_PROFILE_MODELS.lead;
|
|
758
809
|
}
|
|
@@ -1400,6 +1451,7 @@ function buildPiLaunchCard(opts) {
|
|
|
1400
1451
|
if (opts.swe) surface.push("swe");
|
|
1401
1452
|
if (opts.search) surface.push("search");
|
|
1402
1453
|
if (opts.browse) surface.push("browse");
|
|
1454
|
+
for (const group of opts.azureGroups ?? []) surface.push(group);
|
|
1403
1455
|
const identity = [
|
|
1404
1456
|
opts.accountType,
|
|
1405
1457
|
opts.login,
|
|
@@ -1427,6 +1479,7 @@ function buildPiAppendSystem(profileId, opts = {}) {
|
|
|
1427
1479
|
];
|
|
1428
1480
|
if (peers) lines.push(`- Delegate FREELY to Explore for discovery and General-Purpose for scoped work.`, `- Call subagent directly (agent + task); save workflows for genuinely parallel fanout.`, profileId === "balanced" ? `- Send work to reviewer ONLY when the change alters behavior.` : `- Send finished work to reviewer for assessment.`, `- Ask oracle for a second opinion when the decision itself feels risky.`, advisor ? `- Review the final plan with advisor (advisory) before presenting it.` : `- There is no advisor in this mode: oracle is the only consultant.`, `- Verify, don't vote: consultant verdicts never substitute for running the tests.`, `- After any subagent work completes, always write the final answer yourself.`);
|
|
1429
1481
|
else lines.push(`- Peerless launch: no subagents or consultants in this session; plan, implement, and verify directly.`);
|
|
1482
|
+
if (advisor) lines.push("", CHEAPEST_CONSULT_CONTRACT.trimEnd());
|
|
1430
1483
|
lines.push("", `(${PI_MIN_VERSION_NOTE})`, "");
|
|
1431
1484
|
return lines.join("\n");
|
|
1432
1485
|
}
|
|
@@ -1793,6 +1846,7 @@ function buildPiMemoryBridgeSection(bridge) {
|
|
|
1793
1846
|
function buildPiExtensionSource(opts) {
|
|
1794
1847
|
const peers = opts.peers !== false;
|
|
1795
1848
|
const advisor = peers ? piAdvisorModel(opts.profileId) : void 0;
|
|
1849
|
+
const promptBrief = opts.profileId === "cheapest";
|
|
1796
1850
|
const lines = [];
|
|
1797
1851
|
lines.push(`// gh-router-pi extension (${opts.profileId} mode). Generated per launch; do not edit.`, `// Executable seams only. Workflow guidance lives in skills/, not here.`, `import { Type } from "typebox";`, `import { spawn } from "node:child_process";`, ``, ...peers ? [
|
|
1798
1852
|
`const OracleParams = Type.Object({`,
|
|
@@ -1845,7 +1899,7 @@ function buildPiExtensionSource(opts) {
|
|
|
1845
1899
|
` schema: Type.Any({ description: "JSON schema for the desired output shape" }),`,
|
|
1846
1900
|
` instruction: Type.String({ description: "What to extract" }),`,
|
|
1847
1901
|
`});`
|
|
1848
|
-
] : [], `function stripNul(s) { return String(s ?? "").replace(/\\0/g, ""); }`, `async function toolText(promise) {`, ` const text = await promise;`, ` return { content: [{ type: "text", text: stripNul(text) }], details: undefined };`, `}`, `function toolErrorText(text) {`, ` return { content: [{ type: "text", text }], details: undefined };`, `}`, `const MCP_URL = (process.env.GH_ROUTER_HOOK_MCP_URL ?? "").replace(/\\/+$/, "");`, `const MCP_NONCE = process.env.GH_ROUTER_HOOK_NONCE ?? "";`, `const PI_WORKSPACE = (process.env.GH_ROUTER_WORKSPACE ?? "").trim();`, `const LEAD_MODEL = ${JSON.stringify(`${PI_PROVIDER_NAME}/${piLeadModel(opts.profileId)}`)};`, `const LEAD_THINKING = ${JSON.stringify(piLeadThinking(opts.profileId))};`, `void LEAD_MODEL; void LEAD_THINKING;`, ``, `async function callMcp(group, tool, args, signal) {`, ` const headers = { "content-type": "application/json", accept: "application/json", authorization: "Bearer " + MCP_NONCE };`, ` if (PI_WORKSPACE && (group === "search" || group === "workers" || group === "orchestrate")) { headers["X-GH-Workspace"] = PI_WORKSPACE; }`, ` const res = await fetch(MCP_URL + "/mcp/" + group, {`, ` method: "POST",`, ` headers,`, ` body: JSON.stringify({ jsonrpc: "2.0", id: 1, method: "tools/call", params: { name: tool, arguments: args } }),`, ` signal,`, ` });`, ` if (!res.ok) throw new Error("mcp " + group + "/" + tool + " -> HTTP " + res.status);`, ` const body = await res.json();`, ` if (body.error) return "Error: " + body.error.message;`, ` const content = body.result && body.result.content;`, ` if (!Array.isArray(content)) return "";`, ` return content.map((c) => c.text || "").join("\\n");`, `}`, ``, `export default function (pi) {`, ...peers ? [
|
|
1902
|
+
] : [], `function stripNul(s) { return String(s ?? "").replace(/\\0/g, ""); }`, `async function toolText(promise) {`, ` const text = await promise;`, ` return { content: [{ type: "text", text: stripNul(text) }], details: undefined };`, `}`, `function toolErrorText(text) {`, ` return { content: [{ type: "text", text }], details: undefined };`, `}`, `const MCP_URL = (process.env.GH_ROUTER_HOOK_MCP_URL ?? "").replace(/\\/+$/, "");`, `const MCP_NONCE = process.env.GH_ROUTER_HOOK_NONCE ?? "";`, `const PI_WORKSPACE = (process.env.GH_ROUTER_WORKSPACE ?? "").trim();`, ...promptBrief ? [`const BRIEF_TIMEOUT_MS = 45000;`] : [], `const LEAD_MODEL = ${JSON.stringify(`${PI_PROVIDER_NAME}/${piLeadModel(opts.profileId)}`)};`, `const LEAD_THINKING = ${JSON.stringify(piLeadThinking(opts.profileId))};`, `void LEAD_MODEL; void LEAD_THINKING;`, ``, `async function callMcp(group, tool, args, signal) {`, ` const headers = { "content-type": "application/json", accept: "application/json", authorization: "Bearer " + MCP_NONCE };`, ` if (PI_WORKSPACE && (group === "search" || group === "workers" || group === "orchestrate")) { headers["X-GH-Workspace"] = PI_WORKSPACE; }`, ` const res = await fetch(MCP_URL + "/mcp/" + group, {`, ` method: "POST",`, ` headers,`, ` body: JSON.stringify({ jsonrpc: "2.0", id: 1, method: "tools/call", params: { name: tool, arguments: args } }),`, ` signal,`, ` });`, ` if (!res.ok) throw new Error("mcp " + group + "/" + tool + " -> HTTP " + res.status);`, ` const body = await res.json();`, ` if (body.error) return "Error: " + body.error.message;`, ` const content = body.result && body.result.content;`, ` if (!Array.isArray(content)) return "";`, ` return content.map((c) => c.text || "").join("\\n");`, `}`, ``, `export default function (pi) {`, ...peers ? [
|
|
1849
1903
|
` pi.registerTool({`,
|
|
1850
1904
|
` name: "oracle",`,
|
|
1851
1905
|
` label: "Oracle",`,
|
|
@@ -1862,10 +1916,64 @@ function buildPiExtensionSource(opts) {
|
|
|
1862
1916
|
` });`
|
|
1863
1917
|
] : []);
|
|
1864
1918
|
if (advisor) lines.push(` pi.registerTool({`, ` name: "advisor",`, ` label: "Advisor",`, ` description: "Advisory plan review for the lead: review the final plan before presenting it. Never executes.",`, ` parameters: AdvisorParams,`, ` async execute(_toolCallId, params, signal) {`, ` const plan = stripNul(params.plan || "").trim();`, ` const ctx = stripNul(params.context || "").trim();`, ` const context = (plan ? "Plan under review:\\n" + plan : "") + (ctx ? "\\n\\nBackground:\\n" + ctx : "");`, ` if (!plan || !context.trim()) return toolErrorText("advisor: plan and context are required (non-empty strings)");`, ` return await toolText(callMcp("peers", "oracle", { query: "Review this plan (advisory)", context }, signal));`, ` },`, ` });`);
|
|
1865
|
-
if (opts.searchEnabled)
|
|
1919
|
+
if (opts.searchEnabled) {
|
|
1920
|
+
const codeSearchDescription = opts.searchBackend === "bluebird" ? "Search the indexed Azure DevOps code for this repository (Bluebird). Modes semantic and lexical answer from the remote index and have NO local fallback: a failure returns source \\\"error\\\" and zero results, which means the search did not run, not that nothing matched. Use mode exact/regex/ast for the local engine." : "Semantic-first code search over the workspace index (falls back to lexical with a label). Use for finding code by meaning.";
|
|
1921
|
+
lines.push(` pi.registerTool({`, ` name: "code_search",`, ` label: "Code search",`, ` description: "${codeSearchDescription}",`, ` parameters: CodeSearchParams,`, ` async execute(_toolCallId, params, signal) {`, ` const query = stripNul(params.query || "").trim();`, ` if (!query) return toolErrorText("code_search: query is required (non-empty string)");`, ` const workspace = (typeof params.workspace === "string" && params.workspace.trim()) ? params.workspace.trim() : PI_WORKSPACE;`, ` if (!workspace) return toolErrorText("code_search: a workspace is required. Pass the absolute project path as workspace.");`, ` const args = { query, mode: params.mode || "semantic", limit: params.limit || 15, workspace };`, ` if (typeof params.file_glob === "string" && params.file_glob) args.file_glob = params.file_glob;`, ` return await toolText(callMcp("search", "code", args, signal));`, ` },`, ` });`);
|
|
1922
|
+
}
|
|
1866
1923
|
if (opts.browseEnabled) lines.push(` pi.registerTool({`, ` name: "open_tab",`, ` label: "Browser open tab",`, ` description: "Open a URL in a new browser tab (MCP browser/open_tab). Returns install_required with setup steps when the extension is not loaded.",`, ` parameters: OpenTabParams,`, ` async execute(_toolCallId, params, signal) {`, ` const url = stripNul(params.url || "").trim();`, ` if (!url) return toolErrorText("open_tab: url is required");`, ` const args = { url };`, ` if (typeof params.reuseActive === "boolean") args.reuseActive = params.reuseActive;`, ` return await toolText(callMcp("browser", "open_tab", args, signal));`, ` },`, ` });`, ` pi.registerTool({`, ` name: "navigate",`, ` label: "Browser navigate",`, ` description: "Navigate an existing tab (MCP browser/navigate). Requires tabId + action; url only for action=goto.",`, ` parameters: NavigateParams,`, ` async execute(_toolCallId, params, signal) {`, ` if (typeof params.tabId !== "number") return toolErrorText("navigate: tabId is required (number from open_tab)");`, ` if (!params.action) return toolErrorText("navigate: action is required (goto, back, forward, reload)");`, ` const args = { tabId: params.tabId, action: params.action };`, ` if (typeof params.url === "string" && params.url) args.url = params.url;`, ` if (typeof params.hard === "boolean") args.hard = params.hard;`, ` return await toolText(callMcp("browser", "navigate", args, signal));`, ` },`, ` });`, ` pi.registerTool({`, ` name: "screenshot",`, ` label: "Browser screenshot",`, ` description: "Screenshot a tab (MCP browser/screenshot). Requires tabId.",`, ` parameters: ScreenshotParams,`, ` async execute(_toolCallId, params, signal) {`, ` if (typeof params.tabId !== "number") return toolErrorText("screenshot: tabId is required (number from open_tab)");`, ` const args = { tabId: params.tabId };`, ` if (typeof params.format === "string" && params.format) args.format = params.format;`, ` if (typeof params.quality === "number") args.quality = params.quality;`, ` return await toolText(callMcp("browser", "screenshot", args, signal));`, ` },`, ` });`, ` pi.registerTool({`, ` name: "act",`, ` label: "Browser act",`, ` description: "Interact with a tab (MCP browser/act). Requires tabId plus intent or ref.",`, ` parameters: ActParams,`, ` async execute(_toolCallId, params, signal) {`, ` if (typeof params.tabId !== "number") return toolErrorText("act: tabId is required (number from open_tab)");`, ` if (!params.intent && !params.ref) return toolErrorText("act: intent or ref is required");`, ` const args = { tabId: params.tabId };`, ` if (typeof params.intent === "string" && params.intent) args.intent = params.intent;`, ` if (typeof params.ref === "string" && params.ref) args.ref = params.ref;`, ` if (typeof params.action === "string" && params.action) args.action = params.action;`, ` if (typeof params.value === "string") args.value = params.value;`, ` return await toolText(callMcp("browser", "act", args, signal));`, ` },`, ` });`, ` pi.registerTool({`, ` name: "observe",`, ` label: "Browser observe",`, ` description: "Summarize a tab (MCP browser/observe). Requires tabId.",`, ` parameters: ObserveParams,`, ` async execute(_toolCallId, params, signal) {`, ` if (typeof params.tabId !== "number") return toolErrorText("observe: tabId is required (number from open_tab)");`, ` const args = { tabId: params.tabId };`, ` if (typeof params.intent === "string" && params.intent) args.intent = params.intent;`, ` return await toolText(callMcp("browser", "observe", args, signal));`, ` },`, ` });`, ` pi.registerTool({`, ` name: "extract",`, ` label: "Browser extract",`, ` description: "Extract structured data from a tab (MCP browser/extract). Requires tabId, schema, instruction.",`, ` parameters: ExtractParams,`, ` async execute(_toolCallId, params, signal) {`, ` if (typeof params.tabId !== "number") return toolErrorText("extract: tabId is required (number from open_tab)");`, ` if (!params.instruction) return toolErrorText("extract: instruction is required");`, ` if (params.schema === undefined) return toolErrorText("extract: schema is required");`, ` return await toolText(callMcp("browser", "extract", { tabId: params.tabId, schema: params.schema, instruction: params.instruction }, signal));`, ` },`, ` });`);
|
|
1867
1924
|
if (opts.bridge && opts.bridge.scopedRules.length + opts.bridge.stats.staticFiles > 0) lines.push(...buildPiMemoryBridgeSection(opts.bridge));
|
|
1868
|
-
lines.push(...buildPiStatuslineFooterSection(), ` // Route compaction summaries to the mode's cheap capable model;`, ` // ALWAYS fall back to Pi native (return undefined) on any failure.`, ` pi.on("session_before_compact", async (event) => {`, ` try {`, ` const preparation = event.preparation;`, ` if (!preparation || !Array.isArray(preparation.messagesToSummarize)) return undefined;`, ` return undefined; // v1: observe only; native pipeline stays authoritative.`, ` } catch {`, ` return undefined;`, ` }`, ` });`,
|
|
1925
|
+
lines.push(...buildPiStatuslineFooterSection(), ` // Route compaction summaries to the mode's cheap capable model;`, ` // ALWAYS fall back to Pi native (return undefined) on any failure.`, ` pi.on("session_before_compact", async (event) => {`, ` try {`, ` const preparation = event.preparation;`, ` if (!preparation || !Array.isArray(preparation.messagesToSummarize)) return undefined;`, ` return undefined; // v1: observe only; native pipeline stays authoritative.`, ` } catch {`, ` return undefined;`, ` }`, ` });`, ...promptBrief ? [
|
|
1926
|
+
` // Cheapest-profile execution brief, injected ABOVE the model's turn.`,
|
|
1927
|
+
` // Produced server-side; this only relays the prompt and re-emits the`,
|
|
1928
|
+
` // result as a custom message. Additive: the user prompt stays the user`,
|
|
1929
|
+
` // turn and systemPrompt is never replaced.`,
|
|
1930
|
+
` let briefShapeWarned = false;`,
|
|
1931
|
+
` pi.on("before_agent_start", async (event, ctx) => {`,
|
|
1932
|
+
` try {`,
|
|
1933
|
+
` if (!event || typeof event !== "object") return undefined;`,
|
|
1934
|
+
` // Shape probe: Pi 1.3 carries messageType; the older flat shape does`,
|
|
1935
|
+
` // not, and a missing discriminator would make the brief silently`,
|
|
1936
|
+
` // never fire. Report once rather than no-op forever.`,
|
|
1937
|
+
` if (!("messageType" in event)) {`,
|
|
1938
|
+
` if (!briefShapeWarned) {`,
|
|
1939
|
+
` briefShapeWarned = true;`,
|
|
1940
|
+
` try { ctx.ui.notify("gh-router: this Pi build's before_agent_start has no messageType, so the cheapest prompt brief is inactive. Re-run github-router pi to update Pi.", "warning"); } catch {}`,
|
|
1941
|
+
` }`,
|
|
1942
|
+
` return undefined;`,
|
|
1943
|
+
` }`,
|
|
1944
|
+
` if (event.messageType !== "user") return undefined;`,
|
|
1945
|
+
` // Stand down inside a pi-subagents async runner: that process hosts`,
|
|
1946
|
+
` // CHILD sessions which load this extension too, and every child would`,
|
|
1947
|
+
` // otherwise spend a brief of its own. pi-subagents marks the process`,
|
|
1948
|
+
` // with PI_SUBAGENT_CHILD=1 (subagent-runner.js). Foreground subagents`,
|
|
1949
|
+
` // run with ambient extensions off, so they never reach here.`,
|
|
1950
|
+
` if (process.env.PI_SUBAGENT_CHILD === "1") return undefined;`,
|
|
1951
|
+
` const prompt = String(event.prompt || "").trim();`,
|
|
1952
|
+
` if (!prompt) return undefined;`,
|
|
1953
|
+
` const sm = ctx && ctx.sessionManager;`,
|
|
1954
|
+
` const sid = sm && typeof sm.getSessionId === "function" ? sm.getSessionId() : "";`,
|
|
1955
|
+
` if (typeof sid !== "string" || !sid) return undefined;`,
|
|
1956
|
+
` const ac = new AbortController();`,
|
|
1957
|
+
` const timer = setTimeout(() => { try { ac.abort(); } catch {} }, BRIEF_TIMEOUT_MS);`,
|
|
1958
|
+
` let reply = "";`,
|
|
1959
|
+
` try {`,
|
|
1960
|
+
` reply = await callMcp("search", "prompt_brief", PI_WORKSPACE ? { prompt, session_id: sid, workspace: PI_WORKSPACE } : { prompt, session_id: sid }, ac.signal);`,
|
|
1961
|
+
` } finally { clearTimeout(timer); }`,
|
|
1962
|
+
` const text = stripNul(String(reply || "")).trim();`,
|
|
1963
|
+
` // Fail open: a miss, a refusal, or a transport error injects NOTHING`,
|
|
1964
|
+
` // and never blocks the prompt. callMcp returns an "Error: " string`,
|
|
1965
|
+
` // for a JSON-RPC error and throws on a non-OK HTTP status. The`,
|
|
1966
|
+
` // proxy answers a decline (wrong profile, trivial prompt, already`,
|
|
1967
|
+
` // spent, rewrite timeout) with an empty text block.`,
|
|
1968
|
+
` if (!text || text.indexOf("Error: ") === 0 || text.indexOf("prompt_brief") === 0) return undefined;`,
|
|
1969
|
+
` // display:false keeps it context, not conversation (convertToLlm maps`,
|
|
1970
|
+
` // every custom message to a user message regardless of display).`,
|
|
1971
|
+
` return { message: { customType: "gh-router-prompt-brief", content: text, display: false } };`,
|
|
1972
|
+
` } catch {`,
|
|
1973
|
+
` return undefined;`,
|
|
1974
|
+
` }`,
|
|
1975
|
+
` });`
|
|
1976
|
+
] : [], `}`, ``);
|
|
1869
1977
|
return `${lines.join("\n")}\n`;
|
|
1870
1978
|
}
|
|
1871
1979
|
/**
|
|
@@ -2004,6 +2112,199 @@ function buildPiPrompts(opts) {
|
|
|
2004
2112
|
return prompts;
|
|
2005
2113
|
}
|
|
2006
2114
|
//#endregion
|
|
2115
|
+
//#region src/lib/pi-mcp-config.ts
|
|
2116
|
+
/**
|
|
2117
|
+
* Pi's MCP surface for the router's scoped groups.
|
|
2118
|
+
*
|
|
2119
|
+
* `<Pi agent dir>/mcp.json` is Pi's own MCP configuration (the file `pi mcp add`
|
|
2120
|
+
* writes), and `pi-mcp-adapter` reads it as a compatibility input on Pi 0.99+.
|
|
2121
|
+
* Pi's agent dir in a router launch IS the per-launch mirror
|
|
2122
|
+
* (`PI_CODING_AGENT_DIR`, `getPiLaunchEnvVars`), so this file is per-launch and
|
|
2123
|
+
* swept with the mirror. Nothing here touches the user's real `~/.pi/agent`.
|
|
2124
|
+
*
|
|
2125
|
+
* Precedence is the reason every key carries the `gh-router-` prefix. In the
|
|
2126
|
+
* adapter's load order the mirror file is #4, while `.mcp.json` (#7),
|
|
2127
|
+
* `.pi/mcp.json` (#8) and `.pi/mcp-adapter.json` (#9) all win over it and
|
|
2128
|
+
* replace a same-named server as a whole. Keying a group as `ado` would
|
|
2129
|
+
* therefore hand the model the workspace's own `ado` server under a name we
|
|
2130
|
+
* meant for ours; `gh-router-ado` cannot be shadowed by accident.
|
|
2131
|
+
*
|
|
2132
|
+
* The bearer is written as an interpolation placeholder rather than a literal:
|
|
2133
|
+
* the adapter expands `${VAR}` in `headers` from the child environment at
|
|
2134
|
+
* connection time, and `GH_ROUTER_HOOK_NONCE` is already in the Pi launch env
|
|
2135
|
+
* (`src/pi.ts`). A literal token would put a live secret on disk for the life
|
|
2136
|
+
* of the mirror.
|
|
2137
|
+
*
|
|
2138
|
+
* The mirror file is read-merge-written, and a file we cannot parse is left
|
|
2139
|
+
* exactly as it is: a config we do not understand is not ours to overwrite.
|
|
2140
|
+
*/
|
|
2141
|
+
/** Key prefix reserved for router-owned entries. Never emit a bare group name. */
|
|
2142
|
+
const PI_MCP_SERVER_PREFIX = "gh-router-";
|
|
2143
|
+
/** Placeholder the adapter expands from the Pi child env at connect time. */
|
|
2144
|
+
const PI_MCP_NONCE_PLACEHOLDER = "Bearer ${GH_ROUTER_HOOK_NONCE}";
|
|
2145
|
+
/** Router-owned server key for a scoped group, e.g. `ado` -> `gh-router-ado`. */
|
|
2146
|
+
function piMcpServerKey(group) {
|
|
2147
|
+
return `${PI_MCP_SERVER_PREFIX}${group}`;
|
|
2148
|
+
}
|
|
2149
|
+
/**
|
|
2150
|
+
* Server keys a config declares, or `null` when the file is absent,
|
|
2151
|
+
* unreadable, or not a JSON object. `null` and `[]` are different answers:
|
|
2152
|
+
* one means "no evidence", the other "read it, nothing declared" — and the
|
|
2153
|
+
* shadow scan must not report a warning it cannot support.
|
|
2154
|
+
*/
|
|
2155
|
+
function readMcpServerKeys(raw) {
|
|
2156
|
+
try {
|
|
2157
|
+
const parsed = JSON.parse(raw);
|
|
2158
|
+
if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) return null;
|
|
2159
|
+
const servers = parsed["mcpServers"];
|
|
2160
|
+
if (!servers || typeof servers !== "object" || Array.isArray(servers)) return [];
|
|
2161
|
+
return Object.keys(servers);
|
|
2162
|
+
} catch {
|
|
2163
|
+
return null;
|
|
2164
|
+
}
|
|
2165
|
+
}
|
|
2166
|
+
/**
|
|
2167
|
+
* The adapter forwards `description` verbatim, so this is the model's only
|
|
2168
|
+
* pre-search signal for what a server is. Kept to what every tool in the group
|
|
2169
|
+
* actually does; read-only is a property of the group's default surface, not a
|
|
2170
|
+
* promise about every call.
|
|
2171
|
+
*/
|
|
2172
|
+
const GROUP_DESCRIPTIONS = {
|
|
2173
|
+
ado: "Azure DevOps for the open repository: repositories, work items, pipelines and wikis.",
|
|
2174
|
+
kusto: "Azure Data Explorer: query and management commands against the cluster named on each call, or the launch default."
|
|
2175
|
+
};
|
|
2176
|
+
/**
|
|
2177
|
+
* The one place that decides which Pi surfaces this launch emits.
|
|
2178
|
+
*
|
|
2179
|
+
* `search` and `codeSearch` are deliberately separate. `searchEnabled` feeds
|
|
2180
|
+
* three consumers today, and Bluebird must move exactly one of them: it does
|
|
2181
|
+
* not serve `pi-web-access` (a Copilot-backed fetch/find package gated on the
|
|
2182
|
+
* same flag), and the skill prose it would enable is ColBERT-specific. What
|
|
2183
|
+
* Bluebird does serve is `code` — `runUnifiedCodeSearch` routes `semantic` and
|
|
2184
|
+
* `lexical` through it whenever `state.bluebirdEnabled` is set — so an Azure
|
|
2185
|
+
* checkout with Bluebird auto-enabled and no `--search` still deserves the seam.
|
|
2186
|
+
*
|
|
2187
|
+
* The Azure groups ride the adapter, which only exists when `helpers` and
|
|
2188
|
+
* `peers` both hold (`buildPiSettingsJson` adds it as `helpers && peers`).
|
|
2189
|
+
* Writing the config without the adapter would leave it inert at best: the file
|
|
2190
|
+
* is also Pi's own built-in MCP config, so an ungated write would expose the
|
|
2191
|
+
* groups through a backend this path has never validated.
|
|
2192
|
+
*/
|
|
2193
|
+
function resolvePiSurfaces(opts) {
|
|
2194
|
+
const codeSearchBackend = opts.bluebirdEnabled ? "bluebird" : "colbert";
|
|
2195
|
+
const groups = [];
|
|
2196
|
+
if (opts.helpersEnabled && opts.peersEnabled) {
|
|
2197
|
+
if (opts.adoEnabled) groups.push({
|
|
2198
|
+
group: "ado",
|
|
2199
|
+
description: GROUP_DESCRIPTIONS["ado"]
|
|
2200
|
+
});
|
|
2201
|
+
if (opts.kustoEnabled) groups.push({
|
|
2202
|
+
group: "kusto",
|
|
2203
|
+
description: GROUP_DESCRIPTIONS["kusto"]
|
|
2204
|
+
});
|
|
2205
|
+
}
|
|
2206
|
+
return {
|
|
2207
|
+
search: opts.searchEnabled,
|
|
2208
|
+
codeSearch: opts.searchEnabled || opts.bluebirdEnabled,
|
|
2209
|
+
codeSearchBackend,
|
|
2210
|
+
groups
|
|
2211
|
+
};
|
|
2212
|
+
}
|
|
2213
|
+
/** File text, or `null` when it is absent or unreadable. */
|
|
2214
|
+
async function readIfPresent(file) {
|
|
2215
|
+
try {
|
|
2216
|
+
return await fs$1.readFile(file, "utf8");
|
|
2217
|
+
} catch {
|
|
2218
|
+
return null;
|
|
2219
|
+
}
|
|
2220
|
+
}
|
|
2221
|
+
/** Project-scoped files the adapter reads, in its own precedence order. */
|
|
2222
|
+
const PROJECT_MCP_FILES = [
|
|
2223
|
+
path.join(".mcp.json"),
|
|
2224
|
+
path.join(".pi", "mcp.json"),
|
|
2225
|
+
path.join(".pi", "mcp-adapter.json")
|
|
2226
|
+
];
|
|
2227
|
+
/**
|
|
2228
|
+
* Write one remote entry per group into `<mirrorDir>/mcp.json`.
|
|
2229
|
+
*
|
|
2230
|
+
* Never throws for an unreadable or malformed existing file: it returns a
|
|
2231
|
+
* result the caller can warn about. Callers gate on the group being enabled
|
|
2232
|
+
* before calling; this function trusts the list it is given.
|
|
2233
|
+
*/
|
|
2234
|
+
async function writePiMcpJson(opts) {
|
|
2235
|
+
const target = path.join(opts.mirrorDir, "mcp.json");
|
|
2236
|
+
let existing = {};
|
|
2237
|
+
let existingServers = {};
|
|
2238
|
+
const raw = await readIfPresent(target);
|
|
2239
|
+
if (raw !== null) try {
|
|
2240
|
+
const parsed = JSON.parse(raw);
|
|
2241
|
+
if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) return {
|
|
2242
|
+
path: target,
|
|
2243
|
+
added: [],
|
|
2244
|
+
preserved: [],
|
|
2245
|
+
shadowed: [],
|
|
2246
|
+
skippedReason: "not a JSON object"
|
|
2247
|
+
};
|
|
2248
|
+
existing = parsed;
|
|
2249
|
+
const servers = existing["mcpServers"];
|
|
2250
|
+
existingServers = servers && typeof servers === "object" && !Array.isArray(servers) ? servers : {};
|
|
2251
|
+
} catch {
|
|
2252
|
+
return {
|
|
2253
|
+
path: target,
|
|
2254
|
+
added: [],
|
|
2255
|
+
preserved: [],
|
|
2256
|
+
shadowed: [],
|
|
2257
|
+
skippedReason: "malformed JSON"
|
|
2258
|
+
};
|
|
2259
|
+
}
|
|
2260
|
+
const added = [];
|
|
2261
|
+
const nextServers = { ...existingServers };
|
|
2262
|
+
for (const group of opts.groups) {
|
|
2263
|
+
const key = piMcpServerKey(group.group);
|
|
2264
|
+
added.push(key);
|
|
2265
|
+
nextServers[key] = {
|
|
2266
|
+
type: "http",
|
|
2267
|
+
url: `${opts.serverUrl}/mcp/${group.group}`,
|
|
2268
|
+
headers: { Authorization: PI_MCP_NONCE_PLACEHOLDER },
|
|
2269
|
+
description: group.description
|
|
2270
|
+
};
|
|
2271
|
+
}
|
|
2272
|
+
const shadowed = await findShadowedKeys(opts.workspace, added);
|
|
2273
|
+
const preserved = Object.keys(existingServers).filter((key) => !added.includes(key)).sort();
|
|
2274
|
+
await fs$1.mkdir(opts.mirrorDir, { recursive: true });
|
|
2275
|
+
await fs$1.writeFile(target, `${JSON.stringify({
|
|
2276
|
+
...existing,
|
|
2277
|
+
mcpServers: nextServers
|
|
2278
|
+
}, null, 2)}\n`, { mode: 384 });
|
|
2279
|
+
return {
|
|
2280
|
+
path: target,
|
|
2281
|
+
added,
|
|
2282
|
+
preserved,
|
|
2283
|
+
shadowed
|
|
2284
|
+
};
|
|
2285
|
+
}
|
|
2286
|
+
/**
|
|
2287
|
+
* Which of `keys` a project-scoped file would replace. A file that cannot be
|
|
2288
|
+
* read or parsed is skipped silently: it yields no evidence either way, and a
|
|
2289
|
+
* false warning about a config we merely failed to parse is worse than a
|
|
2290
|
+
* missing one.
|
|
2291
|
+
*/
|
|
2292
|
+
async function findShadowedKeys(workspace, keys) {
|
|
2293
|
+
const found = [];
|
|
2294
|
+
for (const rel of PROJECT_MCP_FILES) {
|
|
2295
|
+
const file = path.join(workspace, rel);
|
|
2296
|
+
const raw = await readIfPresent(file);
|
|
2297
|
+
if (raw === null) continue;
|
|
2298
|
+
const declared = readMcpServerKeys(raw);
|
|
2299
|
+
if (!declared) continue;
|
|
2300
|
+
for (const key of keys) if (declared.includes(key)) found.push({
|
|
2301
|
+
key,
|
|
2302
|
+
file
|
|
2303
|
+
});
|
|
2304
|
+
}
|
|
2305
|
+
return found;
|
|
2306
|
+
}
|
|
2307
|
+
//#endregion
|
|
2007
2308
|
//#region src/pi.ts
|
|
2008
2309
|
const piArgs = {
|
|
2009
2310
|
...sharedServerArgs,
|
|
@@ -2165,31 +2466,41 @@ const pi = defineCommand({
|
|
|
2165
2466
|
if (pendingInstall.promise) try {
|
|
2166
2467
|
installedVersion = await pendingInstall.promise;
|
|
2167
2468
|
} catch (err) {
|
|
2168
|
-
consola.error(`Pi is not installed and automatic install failed (${err instanceof Error ? err.message : String(err)}). Install it with \`npm install -g @earendil-works/pi-coding-agent\`, then retry.`);
|
|
2469
|
+
consola.error(`Pi is not installed and automatic install failed (${err instanceof Error ? err.message : String(err)}). Install it with \`npm install -g @earendil-works/pi-coding-agent --registry=${resolvePiRegistry()}\`, then retry.`);
|
|
2169
2470
|
process$1.exit(1);
|
|
2170
2471
|
} finally {
|
|
2171
2472
|
pendingInstall.promise = null;
|
|
2172
2473
|
pendingInstall.abort = null;
|
|
2173
2474
|
}
|
|
2174
|
-
if (updateCheck && installedVersion !== null)
|
|
2175
|
-
if (autoUpdate) try {
|
|
2176
|
-
await updatePi("latest");
|
|
2177
|
-
installedVersion = await getInstalledPiVersion();
|
|
2178
|
-
} catch (err) {
|
|
2179
|
-
consola.error(`Installed Pi v${installedVersion} is below the supported floor and auto-upgrade failed (${err instanceof Error ? err.message : String(err)}). Upgrade manually: \`npm install -g @earendil-works/pi-coding-agent@latest\`.`);
|
|
2180
|
-
process$1.exit(1);
|
|
2181
|
-
}
|
|
2475
|
+
if (updateCheck && installedVersion !== null) {
|
|
2182
2476
|
if (!meetsPiMinVersion(installedVersion)) {
|
|
2183
|
-
|
|
2184
|
-
|
|
2185
|
-
|
|
2186
|
-
|
|
2477
|
+
if (autoUpdate) try {
|
|
2478
|
+
await updatePi("latest");
|
|
2479
|
+
installedVersion = await getInstalledPiVersion();
|
|
2480
|
+
} catch (err) {
|
|
2481
|
+
consola.error(`Installed Pi v${installedVersion} is below the supported floor and auto-upgrade failed (${err instanceof Error ? err.message : String(err)}). Upgrade manually: \`npm install -g @earendil-works/pi-coding-agent@latest --registry=${resolvePiRegistry()}\`.`);
|
|
2482
|
+
process$1.exit(1);
|
|
2483
|
+
}
|
|
2484
|
+
if (!meetsPiMinVersion(installedVersion)) {
|
|
2485
|
+
consola.error(`Installed Pi v${installedVersion} is below the supported floor (v${PI_MIN_VERSION}). Upgrade: \`npm install -g @earendil-works/pi-coding-agent@latest --registry=${resolvePiRegistry()}\`.`);
|
|
2486
|
+
process$1.exit(1);
|
|
2487
|
+
}
|
|
2488
|
+
} else refreshPiInBackground({ autoUpdate });
|
|
2489
|
+
}
|
|
2187
2490
|
const peersEnabled = args["peers"] !== false;
|
|
2188
2491
|
const sweEnabled = args["swe"] === true;
|
|
2189
2492
|
const helpersEnabled = args["helpers"] !== false;
|
|
2190
2493
|
const uiEnabled = args["ui"] !== false;
|
|
2191
2494
|
const searchEnabled = parsed.searchEnabled || process$1.env.GH_ROUTER_ENABLE_SEMANTIC_SEARCH === "1";
|
|
2192
2495
|
const browseEnabled = browserToolsEnabled();
|
|
2496
|
+
const surfaces = resolvePiSurfaces({
|
|
2497
|
+
searchEnabled,
|
|
2498
|
+
bluebirdEnabled: state.bluebirdEnabled === true,
|
|
2499
|
+
adoEnabled: adoToolsEnabled(),
|
|
2500
|
+
kustoEnabled: kustoToolsEnabled(),
|
|
2501
|
+
helpersEnabled,
|
|
2502
|
+
peersEnabled
|
|
2503
|
+
});
|
|
2193
2504
|
const prereqCheck = profileId === "cheapest" ? validateCheapestProfilePrerequisites(state.models, { peers: peersEnabled }) : validateBalancedProfilePrerequisites(state.models, { peers: peersEnabled });
|
|
2194
2505
|
if (!prereqCheck.ok) {
|
|
2195
2506
|
const message = profileId === "cheapest" ? formatCheapestPrerequisiteFailure(prereqCheck.missing) : formatBalancedPrerequisiteFailure(prereqCheck.missing);
|
|
@@ -2279,7 +2590,8 @@ const pi = defineCommand({
|
|
|
2279
2590
|
}
|
|
2280
2591
|
await writeTextFile(path.join(mirror, "extensions", "gh-router-pi", "index.ts"), buildPiExtensionSource({
|
|
2281
2592
|
profileId,
|
|
2282
|
-
searchEnabled,
|
|
2593
|
+
searchEnabled: surfaces.codeSearch,
|
|
2594
|
+
searchBackend: surfaces.codeSearchBackend,
|
|
2283
2595
|
browseEnabled,
|
|
2284
2596
|
peers: peersEnabled,
|
|
2285
2597
|
bridge: bridgeStats ? {
|
|
@@ -2287,6 +2599,16 @@ const pi = defineCommand({
|
|
|
2287
2599
|
scopedRules: bridgeScoped
|
|
2288
2600
|
} : void 0
|
|
2289
2601
|
}));
|
|
2602
|
+
if (surfaces.groups.length > 0) {
|
|
2603
|
+
const written = await writePiMcpJson({
|
|
2604
|
+
mirrorDir: mirror,
|
|
2605
|
+
workspace: process$1.cwd(),
|
|
2606
|
+
serverUrl,
|
|
2607
|
+
groups: surfaces.groups
|
|
2608
|
+
});
|
|
2609
|
+
if (written.skippedReason) consola.warn(`Pi MCP: left ${written.path} alone (${written.skippedReason}); the Azure groups are not exposed to Pi this launch.`);
|
|
2610
|
+
else for (const { key, file } of written.shadowed) consola.warn(`Pi MCP: ${file} declares "${key}" and outranks the mirror copy, so the router's version is not the one Pi will run. Rename that entry to keep both.`);
|
|
2611
|
+
}
|
|
2290
2612
|
if (peersEnabled) {
|
|
2291
2613
|
const agentFiles = buildPiAgentFiles(profileId);
|
|
2292
2614
|
for (const [rel, content] of Object.entries(agentFiles)) await writeTextFile(path.join(mirror, rel), content);
|
|
@@ -2384,10 +2706,12 @@ const pi = defineCommand({
|
|
|
2384
2706
|
swe: sweEnabled,
|
|
2385
2707
|
search: searchEnabled,
|
|
2386
2708
|
browse: browseEnabled,
|
|
2709
|
+
azureGroups: surfaces.groups.map((g) => g.group),
|
|
2387
2710
|
serverUrl
|
|
2388
2711
|
})}\n`);
|
|
2389
2712
|
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");
|
|
2390
|
-
const { disposeBluebirdClients } = await import("./bluebird-client-
|
|
2713
|
+
const { disposeBluebirdClients } = await import("./bluebird-client-mr3M67k-.js");
|
|
2714
|
+
const { disposeAdoClients } = await import("./ado-tools-xbuVU7YN.js");
|
|
2391
2715
|
launchChild({
|
|
2392
2716
|
kind: "pi",
|
|
2393
2717
|
envVars: {
|
|
@@ -2407,6 +2731,7 @@ const pi = defineCommand({
|
|
|
2407
2731
|
unregisterLaunch(entry.launchId);
|
|
2408
2732
|
await stopKeepAwake();
|
|
2409
2733
|
await disposeBluebirdClients();
|
|
2734
|
+
await disposeAdoClients();
|
|
2410
2735
|
await savePiPackageCache(mirror, packagesForCache);
|
|
2411
2736
|
await removeOwnPiAgentMirror();
|
|
2412
2737
|
await removeAicLedgerFile();
|
|
@@ -2424,4 +2749,4 @@ const pi = defineCommand({
|
|
|
2424
2749
|
//#endregion
|
|
2425
2750
|
export { pi };
|
|
2426
2751
|
|
|
2427
|
-
//# sourceMappingURL=pi-
|
|
2752
|
+
//# sourceMappingURL=pi-jVNeQXWf.js.map
|