github-router 0.3.379 → 0.3.380
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/README.md +62 -0
- package/dist/ado-tools-CsfbnY8x.js +1 -0
- package/dist/{aic-ledger-CeSXqTEE.js → aic-ledger-6GKI28nY.js} +3 -3
- package/dist/{aic-ledger-CeSXqTEE.js.map → aic-ledger-6GKI28nY.js.map} +1 -1
- package/dist/{aic-statusline-settings-BKveu679.js → aic-statusline-settings-wLL1l_Z6.js} +2 -2
- package/dist/{aic-statusline-settings-BKveu679.js.map → aic-statusline-settings-wLL1l_Z6.js.map} +1 -1
- package/dist/atomic-file-Dif1kLKM.js +198 -0
- package/dist/atomic-file-Dif1kLKM.js.map +1 -0
- package/dist/{attribution-settings-BWYL2b8N.js → attribution-settings-BJ1fjX7V.js} +10 -10
- package/dist/{attribution-settings-BWYL2b8N.js.map → attribution-settings-BJ1fjX7V.js.map} +1 -1
- package/dist/{auth-BZHpTtfF.js → auth-5TKcQbbH.js} +3 -3
- package/dist/{auth-BZHpTtfF.js.map → auth-5TKcQbbH.js.map} +1 -1
- package/dist/bin.js +1479 -0
- package/dist/bin.js.map +1 -0
- package/dist/browser-ext/manifest.json +1 -1
- package/dist/{check-usage-BlIWDuV2.js → check-usage-DM39fdel.js} +4 -4
- package/dist/{check-usage-BlIWDuV2.js.map → check-usage-DM39fdel.js.map} +1 -1
- package/dist/{claude-CSuIdaLV.js → claude-BWwkOMi3.js} +26 -25
- package/dist/{claude-CSuIdaLV.js.map → claude-BWwkOMi3.js.map} +1 -1
- package/dist/{claude-md-injection-Biq_Xhve.js → claude-md-injection-DNMDcw1W.js} +15 -24
- package/dist/claude-md-injection-DNMDcw1W.js.map +1 -0
- package/dist/{codex-BG0pfud9.js → codex-C6ix3BaY.js} +8 -7
- package/dist/{codex-BG0pfud9.js.map → codex-C6ix3BaY.js.map} +1 -1
- package/dist/{copilot-discount-UXC6NQbN.js → copilot-discount-DM98PuAF.js} +2 -2
- package/dist/{copilot-discount-UXC6NQbN.js.map → copilot-discount-DM98PuAF.js.map} +1 -1
- package/dist/{debug-1HUHCWFl.js → debug-Df0Kuzi3.js} +2 -2
- package/dist/{debug-1HUHCWFl.js.map → debug-Df0Kuzi3.js.map} +1 -1
- package/dist/diagnostics-cXjCT_JQ.js +12 -0
- package/dist/diagnostics-cXjCT_JQ.js.map +1 -0
- package/dist/engine-B6la_uIW.js +1 -0
- package/dist/{gate-discovery-DjH9YXoN.js → gate-discovery-2ILpM2fi.js} +5 -5
- package/dist/{gate-discovery-DjH9YXoN.js.map → gate-discovery-2ILpM2fi.js.map} +1 -1
- package/dist/{get-copilot-usage-CKg42gSH.js → get-copilot-usage-BZ6t2hFZ.js} +2 -2
- package/dist/{get-copilot-usage-CKg42gSH.js.map → get-copilot-usage-BZ6t2hFZ.js.map} +1 -1
- package/dist/hooks.mjs +13 -0
- package/dist/hooks.sha256 +1 -1
- package/dist/{index-cmd-sKwchRJz.js → index-cmd-DsK6VFs8.js} +4 -4
- package/dist/{index-cmd-sKwchRJz.js.map → index-cmd-DsK6VFs8.js.map} +1 -1
- package/dist/{internal-aic-status-B_hEeM37.js → internal-aic-status-CUZ7-trf.js} +3 -3
- package/dist/{internal-aic-status-B_hEeM37.js.map → internal-aic-status-CUZ7-trf.js.map} +1 -1
- package/dist/{internal-artifact-open-DbHjipxU.js → internal-artifact-open-DRBg1PpV.js} +2 -2
- package/dist/{internal-artifact-open-DbHjipxU.js.map → internal-artifact-open-DRBg1PpV.js.map} +1 -1
- package/dist/{internal-fast-dispatch-guard-DMzqs-r8.js → internal-fast-dispatch-guard-D6-Ees_6.js} +1 -1
- package/dist/{internal-fast-dispatch-guard-PDdlkPU3.js → internal-fast-dispatch-guard-ZeS9u0A3.js} +2 -2
- package/dist/{internal-fast-dispatch-guard-PDdlkPU3.js.map → internal-fast-dispatch-guard-ZeS9u0A3.js.map} +1 -1
- package/dist/{internal-first-mate-guard-BxPDUsV3.js → internal-first-mate-guard-BijeVpi9.js} +1 -1
- package/dist/{internal-first-mate-guard-4Yro9xNM.js → internal-first-mate-guard-DsEEsLKJ.js} +3 -3
- package/dist/{internal-first-mate-guard-4Yro9xNM.js.map → internal-first-mate-guard-DsEEsLKJ.js.map} +1 -1
- package/dist/{internal-max-dispatch-guard-0teaxIc1.js → internal-max-dispatch-guard-4RLca1i5.js} +2 -2
- package/dist/{internal-max-dispatch-guard-0teaxIc1.js.map → internal-max-dispatch-guard-4RLca1i5.js.map} +1 -1
- package/dist/{internal-max-dispatch-guard-5LSaHN_y.js → internal-max-dispatch-guard-DeEfWqfP.js} +1 -1
- package/dist/{internal-plan-review-BfHLeszV.js → internal-plan-review-bzqGNdtw.js} +3 -3
- package/dist/{internal-plan-review-BfHLeszV.js.map → internal-plan-review-bzqGNdtw.js.map} +1 -1
- package/dist/{internal-prompt-submit-BixNLmM3.js → internal-prompt-submit-BZ2-CExM.js} +4 -4
- package/dist/{internal-prompt-submit-BixNLmM3.js.map → internal-prompt-submit-BZ2-CExM.js.map} +1 -1
- package/dist/{internal-prompt-submit-Ou8xtRXj.js → internal-prompt-submit-ZBhH-SQ1.js} +2 -2
- package/dist/{internal-rebrief-BBGM0PMv.js → internal-rebrief-BIWbN7Sr.js} +4 -4
- package/dist/{internal-rebrief-BBGM0PMv.js.map → internal-rebrief-BIWbN7Sr.js.map} +1 -1
- package/dist/{internal-session-bind-pN1V11Mn.js → internal-session-bind-BL6hFRLO.js} +2 -2
- package/dist/{internal-session-bind-pN1V11Mn.js.map → internal-session-bind-BL6hFRLO.js.map} +1 -1
- package/dist/{internal-stop-hook-DO9Iiaes.js → internal-stop-hook-cDF1MuJZ.js} +5 -5
- package/dist/{internal-stop-hook-DO9Iiaes.js.map → internal-stop-hook-cDF1MuJZ.js.map} +1 -1
- package/dist/{internal-stop-review-BWp-4XWW.js → internal-stop-review-y8zjpK_3.js} +2 -2
- package/dist/{internal-stop-review-BWp-4XWW.js.map → internal-stop-review-y8zjpK_3.js.map} +1 -1
- package/dist/{internal-worker-guard-C9OZPgzu.js → internal-worker-guard-DdyYBZR0.js} +2 -2
- package/dist/{internal-worker-guard-C9OZPgzu.js.map → internal-worker-guard-DdyYBZR0.js.map} +1 -1
- package/dist/{internal-workspace-header-B4TXFBLU.js → internal-workspace-header-BMKbO8yX.js} +2 -2
- package/dist/{internal-workspace-header-B4TXFBLU.js.map → internal-workspace-header-BMKbO8yX.js.map} +1 -1
- package/dist/lib/tree-sitter-pool/worker.js +268 -21
- package/dist/lifecycle-BOjgq9_l.js +1 -0
- package/dist/{lifecycle-vjHAFCaY.js → lifecycle-BlC_kzNt.js} +2 -2
- package/dist/{lifecycle-vjHAFCaY.js.map → lifecycle-BlC_kzNt.js.map} +1 -1
- package/dist/{lifecycle-Dh9y8OF1.js → lifecycle-COZhARmE.js} +2 -2
- package/dist/{lifecycle-Dh9y8OF1.js.map → lifecycle-COZhARmE.js.map} +1 -1
- package/dist/lifecycle-NQvr4flt.js +1 -0
- package/dist/main.js +39 -24
- package/dist/main.js.map +1 -1
- package/dist/{mcp-workspace-header-C5-dOWNa.js → mcp-workspace-header-Bpa4BId8.js} +2 -2
- package/dist/{mcp-workspace-header-C5-dOWNa.js.map → mcp-workspace-header-Bpa4BId8.js.map} +1 -1
- package/dist/{models-B6nH1sS6.js → models-BDV-YLf2.js} +3 -3
- package/dist/{models-B6nH1sS6.js.map → models-BDV-YLf2.js.map} +1 -1
- package/dist/npm-env-H60tX76c.js +130 -0
- package/dist/npm-env-H60tX76c.js.map +1 -0
- package/dist/optional-DGAeyguL.js +586 -0
- package/dist/optional-DGAeyguL.js.map +1 -0
- package/dist/{orchestration-B93jxrWI.js → orchestration-Bto5Nc1Y.js} +2 -2
- package/dist/{orchestration-B93jxrWI.js.map → orchestration-Bto5Nc1Y.js.map} +1 -1
- package/dist/origin-BXtpcKP9.js +382 -0
- package/dist/origin-BXtpcKP9.js.map +1 -0
- package/dist/origin-DbFUCiGp.js +1 -0
- package/dist/paths-CquOjytP.js +1 -0
- package/dist/paths-DK_b2ihK.js +176 -0
- package/dist/paths-DK_b2ihK.js.map +1 -0
- package/dist/{paths-CVEO8jEH.js → paths-DeFmYJhO.js} +16 -3
- package/dist/paths-DeFmYJhO.js.map +1 -0
- package/dist/{peer-mcp-personas-OWsSm6To.js → peer-mcp-personas-Dny0r5Am.js} +14 -14
- package/dist/{peer-mcp-personas-OWsSm6To.js.map → peer-mcp-personas-Dny0r5Am.js.map} +1 -1
- package/dist/{pi-DmeBxzIo.js → pi-YhoA26wi.js} +383 -88
- package/dist/pi-YhoA26wi.js.map +1 -0
- package/dist/{pi-foreign-artifacts-DZ4tioyO.js → pi-foreign-artifacts-CNt6wQ1P.js} +2 -2
- package/dist/{pi-foreign-artifacts-DZ4tioyO.js.map → pi-foreign-artifacts-CNt6wQ1P.js.map} +1 -1
- package/dist/pi-memory-bridge-BxmCIIbk.js +618 -0
- package/dist/pi-memory-bridge-BxmCIIbk.js.map +1 -0
- package/dist/pi-memory-bridge-D5A0h_Kf.js +1 -0
- package/dist/pi-version-check-BeBB0Ny9.js +551 -0
- package/dist/pi-version-check-BeBB0Ny9.js.map +1 -0
- package/dist/pi-version-check-D5RvdLsG.js +1 -0
- package/dist/{plan-review-hook-MhjK92wq.js → plan-review-hook-D_yyjOgO.js} +3 -3
- package/dist/{plan-review-hook-MhjK92wq.js.map → plan-review-hook-D_yyjOgO.js.map} +1 -1
- package/dist/{provision-DPL8aGe2.js → provision-BWtuDq_v.js} +30 -36
- package/dist/provision-BWtuDq_v.js.map +1 -0
- package/dist/rerank-cross-encoder-BhjImuwG.js +192 -0
- package/dist/rerank-cross-encoder-BhjImuwG.js.map +1 -0
- package/dist/{self-invocation-DMUnXVGT.js → self-invocation-Dnq4iVD6.js} +4 -31
- package/dist/{self-invocation-DMUnXVGT.js.map → self-invocation-Dnq4iVD6.js.map} +1 -1
- package/dist/{serve-zbQKfx1E.js → serve-DrHAX2Bh.js} +15 -14
- package/dist/{serve-zbQKfx1E.js.map → serve-DrHAX2Bh.js.map} +1 -1
- package/dist/{server-setup-ClZdV33Q.js → server-setup-DLwejgVA.js} +12 -638
- package/dist/server-setup-DLwejgVA.js.map +1 -0
- package/dist/{service-backend-Cdgz6WPx.js → service-backend-BdhWVRSz.js} +17 -62
- package/dist/service-backend-BdhWVRSz.js.map +1 -0
- package/dist/{start-mnedD5cH.js → start-DvV3Lbwy.js} +5 -4
- package/dist/{start-mnedD5cH.js.map → start-DvV3Lbwy.js.map} +1 -1
- package/dist/{static-context-pack-CtnBwHSd.js → static-context-pack-BKFelEbM.js} +3 -3
- package/dist/{static-context-pack-CtnBwHSd.js.map → static-context-pack-BKFelEbM.js.map} +1 -1
- package/dist/{stop-gate-hook-CBVLD8iB.js → stop-gate-hook-DBOj0TqL.js} +3 -3
- package/dist/{stop-gate-hook-CBVLD8iB.js.map → stop-gate-hook-DBOj0TqL.js.map} +1 -1
- package/dist/{stop-gate-policy-BehNiNix.js → stop-gate-policy-Bp2wGh_W.js} +2 -2
- package/dist/{stop-gate-policy-BehNiNix.js.map → stop-gate-policy-Bp2wGh_W.js.map} +1 -1
- package/dist/{token-CPzYxU4Y.js → token-CKPOBdO0.js} +23 -88
- package/dist/{token-CPzYxU4Y.js.map → token-CKPOBdO0.js.map} +1 -1
- package/dist/{token-DHEkiO4g.js → token-Ygd7D32L.js} +3 -3
- package/dist/{token-DHEkiO4g.js.map → token-Ygd7D32L.js.map} +1 -1
- package/dist/update-CB21YRKz.js +1 -0
- package/dist/update-T1L7yFon.js +1548 -0
- package/dist/update-T1L7yFon.js.map +1 -0
- package/dist/update-fEgWTrIx.js +214 -0
- package/dist/update-fEgWTrIx.js.map +1 -0
- package/dist/update-lock-BeS_WmC8.js +1 -0
- package/dist/update-lock-BmXx6QaR.js +171 -0
- package/dist/update-lock-BmXx6QaR.js.map +1 -0
- package/dist/volatile-root-DQNNvQ7Z.js +50 -0
- package/dist/volatile-root-DQNNvQ7Z.js.map +1 -0
- package/dist/{worker-dispatch-C7RtNOXv.js → worker-dispatch-DBWKTMda.js} +2 -2
- package/dist/{worker-dispatch-C7RtNOXv.js.map → worker-dispatch-DBWKTMda.js.map} +1 -1
- package/dist/{workiq-CQauEAMc.js → workiq-D5b7xlbr.js} +2 -2
- package/dist/{workiq-CQauEAMc.js.map → workiq-D5b7xlbr.js.map} +1 -1
- package/dist/{workiq-tools-DL6rC4bP.js → workiq-tools-DdiQ2DOW.js} +1 -1
- package/package.json +16 -4
- package/dist/ado-tools-CRkyU51J.js +0 -1
- package/dist/claude-md-injection-Biq_Xhve.js.map +0 -1
- package/dist/engine-V46un8Xl.js +0 -1
- package/dist/lifecycle-BENRuuX6.js +0 -1
- package/dist/lifecycle-Dli9vGI2.js +0 -1
- package/dist/paths-Be9_ujQ3.js +0 -1
- package/dist/paths-CVEO8jEH.js.map +0 -1
- package/dist/pi-DmeBxzIo.js.map +0 -1
- package/dist/pi-memory-bridge-Bp9AnYw9.js +0 -1
- package/dist/pi-memory-bridge-CICIdDVP.js +0 -413
- package/dist/pi-memory-bridge-CICIdDVP.js.map +0 -1
- package/dist/provision-DPL8aGe2.js.map +0 -1
- package/dist/rerank-cross-encoder-B87lZgvc.js +0 -110
- package/dist/rerank-cross-encoder-B87lZgvc.js.map +0 -1
- package/dist/server-setup-ClZdV33Q.js.map +0 -1
- package/dist/service-backend-Cdgz6WPx.js.map +0 -1
|
@@ -1,16 +1,20 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { d as
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import { t as
|
|
7
|
-
import { t as
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
1
|
+
import { c as refreshPiInBackground, l as resolvePiRegistry, n as PI_MIN_VERSION, o as meetsPiMinVersion, u as runSelfUpdate } from "./pi-version-check-BeBB0Ny9.js";
|
|
2
|
+
import { c as runCommandCapture, s as resolveExecutable } from "./exec-BC0MAnoA.js";
|
|
3
|
+
import { d as readPointer, l as isOurShim, o as scheduleBackgroundPiInstall, u as ensureManagedInstall } from "./update-T1L7yFon.js";
|
|
4
|
+
import { b as versionDir } from "./paths-DK_b2ihK.js";
|
|
5
|
+
import { i as buildAicStatusHookCommand, n as AIC_STATUSLINE_DISABLE_ENV, t as AIC_LEDGER_ENV } from "./aic-statusline-settings-wLL1l_Z6.js";
|
|
6
|
+
import { d as removeAicLedgerFile, f as sweepStaleAicLedgerFiles, n as aicSnapshot, o as formatAicExitSummary, t as aicLedgerPath } from "./aic-ledger-6GKI28nY.js";
|
|
7
|
+
import { n as formatDiscountedCostTable, t as discountedUsdForSnapshot } from "./copilot-discount-DM98PuAF.js";
|
|
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";
|
|
10
|
+
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";
|
|
11
15
|
import { t as state } from "./state-CCGDJ43X.js";
|
|
12
16
|
import { t as getPackageVersion } from "./version-CTqwKr26.js";
|
|
13
|
-
import { P as warmTreeSitterPool } from "./service-backend-
|
|
17
|
+
import { P as warmTreeSitterPool } from "./service-backend-BdhWVRSz.js";
|
|
14
18
|
import { defineCommand } from "citty";
|
|
15
19
|
import consola from "consola";
|
|
16
20
|
import { existsSync } from "node:fs";
|
|
@@ -18,6 +22,196 @@ import path from "node:path";
|
|
|
18
22
|
import { createHash, randomBytes } from "node:crypto";
|
|
19
23
|
import fs$1 from "node:fs/promises";
|
|
20
24
|
import process$1 from "node:process";
|
|
25
|
+
// src/lib/managed-install/pi-command.ts
|
|
26
|
+
/**
|
|
27
|
+
* "Which Pi do we launch, and how do we spell it?"
|
|
28
|
+
*
|
|
29
|
+
* Pi is not a dependency of this package: the launcher spawns whatever `pi` the
|
|
30
|
+
* user has. That is fine until you look at what happens today when the answer
|
|
31
|
+
* changes underneath a session — `npm install -g` while the launcher is running
|
|
32
|
+
* mutates a tree the spawned Pi has open, and on Windows that is `EPERM`. The
|
|
33
|
+
* managed install gives Pi a versioned, rename-published home instead, so a Pi
|
|
34
|
+
* refresh becomes the same safe operation as a router refresh.
|
|
35
|
+
*
|
|
36
|
+
* Precedence (plan §6), in order:
|
|
37
|
+
*
|
|
38
|
+
* 1. `--pi-path <abs>` — explicit user override, never floor-checked. Someone
|
|
39
|
+
* pointing at a local build is testing, not asking for our opinion.
|
|
40
|
+
* 2. `pi` on PATH, provided it is **not our own shim** and meets
|
|
41
|
+
* `PI_MIN_VERSION`. The shim check is not cosmetic: our `pi` shim execs the
|
|
42
|
+
* managed launcher, so adopting it as "the user's Pi" would make the
|
|
43
|
+
* launcher's own spawn resolve to itself.
|
|
44
|
+
* 3. The managed pointer, when it meets the floor.
|
|
45
|
+
* 4. Install into the managed dir and use that.
|
|
46
|
+
*
|
|
47
|
+
* Rule 2's floor is what lets the managed install take over from a user install
|
|
48
|
+
* that is too old, which previously could only be fixed by rewriting the user's
|
|
49
|
+
* global npm tree (`npm install -g` from `updatePi`). Falling through is
|
|
50
|
+
* reported, never silent: a user whose `pi` was silently ignored would file a
|
|
51
|
+
* bug about "the wrong version".
|
|
52
|
+
*/
|
|
53
|
+
/** Timeout for `pi --version`. Generous: a cold V8 start on Windows is slow. */
|
|
54
|
+
const VERSION_TIMEOUT_MS = 5e3;
|
|
55
|
+
/** Run `<exe> --version` and pull the semver out. Null on any failure. */
|
|
56
|
+
async function probePiVersion(command, args = []) {
|
|
57
|
+
try {
|
|
58
|
+
const { stdout, code } = await runCommandCapture([
|
|
59
|
+
command,
|
|
60
|
+
...args,
|
|
61
|
+
"--version"
|
|
62
|
+
], { timeoutMs: VERSION_TIMEOUT_MS });
|
|
63
|
+
if (code !== 0) return null;
|
|
64
|
+
const match = stdout.match(/(\d+\.\d+\.\d+)/);
|
|
65
|
+
return match ? match[1] : null;
|
|
66
|
+
} catch {
|
|
67
|
+
return null;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* The package's own `bin` target for `pi`, relative to the package root.
|
|
72
|
+
*
|
|
73
|
+
* Read from the installed `package.json` rather than hardcoded because Pi has
|
|
74
|
+
* already moved it once (`dist/cli.js` → `dist/bundle/cli.js`), and a hardcoded
|
|
75
|
+
* path turns a Pi refactor into "the launcher cannot start Pi at all".
|
|
76
|
+
*/
|
|
77
|
+
async function piBinEntry(packageRoot) {
|
|
78
|
+
try {
|
|
79
|
+
const raw = await fs$1.readFile(path.join(packageRoot, "package.json"), "utf8");
|
|
80
|
+
const parsed = JSON.parse(raw);
|
|
81
|
+
if (typeof parsed.bin === "string") return parsed.bin;
|
|
82
|
+
if (parsed.bin && typeof parsed.bin === "object") {
|
|
83
|
+
const value = parsed.bin["pi"];
|
|
84
|
+
if (typeof value === "string") return value;
|
|
85
|
+
}
|
|
86
|
+
} catch {}
|
|
87
|
+
return null;
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* The managed Pi's argv prefix, if a complete and in-floor payload is live.
|
|
91
|
+
*
|
|
92
|
+
* `process.execPath` is not necessarily Node — under `bunx` it is Bun, and Pi's
|
|
93
|
+
* bundle is built for Node. So prefer a real `node` on PATH and only fall back
|
|
94
|
+
* to the running interpreter, which at least guarantees *an* interpreter exists.
|
|
95
|
+
*/
|
|
96
|
+
async function managedPiCommand() {
|
|
97
|
+
const pointer = await readPointer("pi", { verifyEntry: false });
|
|
98
|
+
if (!pointer) return null;
|
|
99
|
+
if (!meetsPiMinVersion(pointer.version)) return null;
|
|
100
|
+
const root = versionDir("pi", pointer.version);
|
|
101
|
+
const packageDir = path.join(root, "node_modules", "@earendil-works", "pi-coding-agent");
|
|
102
|
+
const relative = await piBinEntry(packageDir);
|
|
103
|
+
if (!relative) return null;
|
|
104
|
+
const entry = path.join(packageDir, relative);
|
|
105
|
+
try {
|
|
106
|
+
if (!(await fs$1.stat(entry)).isFile()) return null;
|
|
107
|
+
} catch {
|
|
108
|
+
return null;
|
|
109
|
+
}
|
|
110
|
+
return {
|
|
111
|
+
command: resolveExecutable("node") ?? process.execPath,
|
|
112
|
+
args: [entry],
|
|
113
|
+
source: "managed",
|
|
114
|
+
version: pointer.version
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
/** Is this resolved `pi` a PATH user install rather than our own shim? */
|
|
118
|
+
async function isUserPi(candidate) {
|
|
119
|
+
try {
|
|
120
|
+
return !await isOurShim(candidate);
|
|
121
|
+
} catch {
|
|
122
|
+
return false;
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* Resolve the Pi invocation to spawn.
|
|
127
|
+
*
|
|
128
|
+
* Never throws: every failure degrades to a later rule, and the final answer is
|
|
129
|
+
* always a runnable-or-explainable command. The caller decides whether "nothing
|
|
130
|
+
* resolved" is fatal.
|
|
131
|
+
*/
|
|
132
|
+
async function resolvePiCommand(opts = {}) {
|
|
133
|
+
const explicit = opts.piPath?.trim();
|
|
134
|
+
if (explicit) return {
|
|
135
|
+
command: explicit,
|
|
136
|
+
args: [],
|
|
137
|
+
source: "flag",
|
|
138
|
+
version: await probePiVersion(explicit)
|
|
139
|
+
};
|
|
140
|
+
const onPath = resolveExecutable("pi");
|
|
141
|
+
let belowFloor = null;
|
|
142
|
+
if (onPath && await isUserPi(onPath)) {
|
|
143
|
+
const version = await probePiVersion(onPath);
|
|
144
|
+
if (version && meetsPiMinVersion(version)) return {
|
|
145
|
+
command: onPath,
|
|
146
|
+
args: [],
|
|
147
|
+
source: "path",
|
|
148
|
+
version
|
|
149
|
+
};
|
|
150
|
+
if (version) belowFloor = version;
|
|
151
|
+
}
|
|
152
|
+
const managed = await managedPiCommand();
|
|
153
|
+
if (managed) return belowFloor ? {
|
|
154
|
+
...managed,
|
|
155
|
+
note: `Using the managed Pi ${managed.version}: the \`pi\` on PATH is v${belowFloor}, below the supported floor v${PI_MIN_VERSION}. Upgrade that one (or drop it from PATH, or pass --pi-path) to choose it again.`
|
|
156
|
+
} : managed;
|
|
157
|
+
if (opts.noInstall || opts.allowInstall === false) return null;
|
|
158
|
+
const kind = "pi";
|
|
159
|
+
const latest = await latestPiVersion();
|
|
160
|
+
if (!latest) return {
|
|
161
|
+
command: "",
|
|
162
|
+
args: [],
|
|
163
|
+
source: "installed",
|
|
164
|
+
version: null,
|
|
165
|
+
note: "Pi is not installed and its latest version could not be resolved (offline, or npm is not on PATH)."
|
|
166
|
+
};
|
|
167
|
+
const outcome = await ensureManagedInstall({
|
|
168
|
+
kind,
|
|
169
|
+
version: latest,
|
|
170
|
+
registry: resolvePiRegistry(),
|
|
171
|
+
signal: opts.signal
|
|
172
|
+
});
|
|
173
|
+
const installed = await managedPiCommand();
|
|
174
|
+
if (installed) return belowFloor ? {
|
|
175
|
+
...installed,
|
|
176
|
+
note: `Using the managed Pi ${installed.version}: the \`pi\` on PATH is v${belowFloor}, below the supported floor v${PI_MIN_VERSION}. Upgrade that one (or drop it from PATH, or pass --pi-path) to choose it again.`
|
|
177
|
+
} : {
|
|
178
|
+
...installed,
|
|
179
|
+
source: "installed"
|
|
180
|
+
};
|
|
181
|
+
return {
|
|
182
|
+
command: "",
|
|
183
|
+
args: [],
|
|
184
|
+
source: "installed",
|
|
185
|
+
version: null,
|
|
186
|
+
note: outcome.kind === "installed" || outcome.kind === "adopted" ? `Pi ${outcome.version ?? ""} was installed but no runnable entry was found.` : outcome.detail ?? "Pi is not installed and could not be installed automatically."
|
|
187
|
+
};
|
|
188
|
+
}
|
|
189
|
+
/**
|
|
190
|
+
* `npm view … version` for Pi, pinned to the Pi registry.
|
|
191
|
+
*
|
|
192
|
+
* Returns null rather than the string `"latest"` on failure: the installer
|
|
193
|
+
* demands an exact version, so passing a tag through would fail one layer later
|
|
194
|
+
* with "invalid version latest" — a confusing error for "you are offline".
|
|
195
|
+
*/
|
|
196
|
+
async function latestPiVersion() {
|
|
197
|
+
const npmPath = resolveExecutable("npm");
|
|
198
|
+
if (!npmPath) return null;
|
|
199
|
+
try {
|
|
200
|
+
const { stdout, code } = await runCommandCapture([
|
|
201
|
+
npmPath,
|
|
202
|
+
"view",
|
|
203
|
+
"@earendil-works/pi-coding-agent",
|
|
204
|
+
"version",
|
|
205
|
+
"--silent",
|
|
206
|
+
`--registry=${resolvePiRegistry()}`
|
|
207
|
+
], { timeoutMs: 8e3 });
|
|
208
|
+
if (code !== 0) return null;
|
|
209
|
+
const value = stdout.trim().split(/\r?\n/).pop()?.trim() ?? "";
|
|
210
|
+
return /^\d+\.\d+\.\d+(?:[-+][0-9A-Za-z.-]+)?$/.test(value) ? value : null;
|
|
211
|
+
} catch {
|
|
212
|
+
return null;
|
|
213
|
+
}
|
|
214
|
+
}
|
|
21
215
|
// src/lib/pi-tier-windows.ts
|
|
22
216
|
/**
|
|
23
217
|
* Copilot Default-tier (cheap) input-token thresholds per model.
|
|
@@ -1503,6 +1697,23 @@ function buildPiLaunchCard(opts) {
|
|
|
1503
1697
|
return lines.join("\n");
|
|
1504
1698
|
}
|
|
1505
1699
|
/**
|
|
1700
|
+
* Registered with Pi inside the digest, only when the memory bridge actually
|
|
1701
|
+
* wrote a block into the mirror's `AGENTS.md`.
|
|
1702
|
+
*
|
|
1703
|
+
* Why a line at all: the block is a permanent per-turn prompt cost, and the
|
|
1704
|
+
* measured failure mode of agent-authored project instructions is restatement —
|
|
1705
|
+
* a study of LLM-generated AGENTS.md files found ~23% higher cost with no
|
|
1706
|
+
* success gain, because the model paraphrases the file back at the user. One
|
|
1707
|
+
* sentence stating the contract (follow it, cite it, do not repeat it) is
|
|
1708
|
+
* cheaper than any restructuring and is the whole behavioural delta we want
|
|
1709
|
+
* from "having read AGENTS.md".
|
|
1710
|
+
*
|
|
1711
|
+
* Emitted only when `bridge` is true: naming AGENTS.md on a launch whose bridge
|
|
1712
|
+
* is off (or whose `-nc` disabled context files) would point the model at
|
|
1713
|
+
* guidance this launch does not have.
|
|
1714
|
+
*/
|
|
1715
|
+
const PI_CONTEXT_CONTRACT_LINE = "- Your project instructions below come from `AGENTS.md` in this agent dir. Follow them and cite the rule when it changes a decision; do not restate them back to the user.";
|
|
1716
|
+
/**
|
|
1506
1717
|
* Short operating digest appended to APPEND_SYSTEM.md (prompt-cache-stable).
|
|
1507
1718
|
* Mode identity — always injected. Peer consult sentences drop out under
|
|
1508
1719
|
* `peers: false` so the digest never names tools that don't exist.
|
|
@@ -1515,7 +1726,8 @@ function buildPiAppendSystem(profileId, opts = {}) {
|
|
|
1515
1726
|
"",
|
|
1516
1727
|
`- Lead owns planning directly; there is no Plan subagent.`,
|
|
1517
1728
|
PI_TOOL_PREFERENCE_LINE,
|
|
1518
|
-
...opts.codeSearch === true ? [PI_SEARCH_ORDER_LINE] : []
|
|
1729
|
+
...opts.codeSearch === true ? [PI_SEARCH_ORDER_LINE] : [],
|
|
1730
|
+
...opts.bridge === true ? [PI_CONTEXT_CONTRACT_LINE] : []
|
|
1519
1731
|
];
|
|
1520
1732
|
if (peers) {
|
|
1521
1733
|
const oracle = piOracleEnabled(profileId);
|
|
@@ -2790,8 +3002,8 @@ function buildPiMemoryBridgeSection(bridge) {
|
|
|
2790
3002
|
` description: "Show bridged memory inventory and auto-memory locations (on-demand; nothing auto-injected)",`,
|
|
2791
3003
|
` handler: async (_args, ctx) => {`,
|
|
2792
3004
|
` try {`,
|
|
2793
|
-
` const s = (BRIDGE && BRIDGE.stats) || { staticFiles: 0, scopedRules: 0, imports: 0, skipped: 0 };`,
|
|
2794
|
-
` const lines = ["Memory bridge (gh-router)", " Static files: " + s.staticFiles, " Scoped rules (lazy): " + s.scopedRules, " Imports: " + s.imports, " Skipped: " + s.skipped, " Auto-memory: ~/.claude/projects/<slug>/memory/MEMORY.md (on-demand read only)", " Pi memory: ~/.pi/agent/memory/ (your own pi-memory install, snapshotted)"];`,
|
|
3005
|
+
` const s = (BRIDGE && BRIDGE.stats) || { staticFiles: 0, scopedRules: 0, imports: 0, skipped: 0, truncated: false, bytes: 0 };`,
|
|
3006
|
+
` const lines = ["Memory bridge (gh-router)", " Static files: " + s.staticFiles, " Scoped rules (lazy): " + s.scopedRules, " Imports: " + s.imports, " Skipped: " + s.skipped, " Mirror AGENTS.md block: " + (s.bytes || 0) + " bytes" + (s.truncated ? " (TRUNCATED to the budget)" : ""), " Auto-memory: ~/.claude/projects/<slug>/memory/MEMORY.md (on-demand read only)", " Pi memory: ~/.pi/agent/memory/ (your own pi-memory install, snapshotted)"];`,
|
|
2795
3007
|
` try {`,
|
|
2796
3008
|
` const files = (BRIDGE.scopedRules || []).map((r) => r.file);`,
|
|
2797
3009
|
` if (files.length > 0) lines.push(" Scoped files:", ...files.slice(0, 20).map((f) => " - " + f));`,
|
|
@@ -2807,8 +3019,8 @@ function buildPiMemoryBridgeSection(bridge) {
|
|
|
2807
3019
|
` description: "Show what the gh-router memory bridge loaded",`,
|
|
2808
3020
|
` handler: async (_args, ctx) => {`,
|
|
2809
3021
|
` try {`,
|
|
2810
|
-
` const s = (BRIDGE && BRIDGE.stats) || { staticFiles: 0, scopedRules: 0, imports: 0, skipped: 0 };`,
|
|
2811
|
-
` ctx.ui.notify("Bridge context: " + s.staticFiles + " static, " + s.scopedRules + " scoped (attached " + attached.size + "), " + s.imports + " imports, " + s.skipped + " skipped. Native AGENTS.md/CLAUDE.md still load via Pi.", "info");`,
|
|
3022
|
+
` const s = (BRIDGE && BRIDGE.stats) || { staticFiles: 0, scopedRules: 0, imports: 0, skipped: 0, truncated: false, bytes: 0 };`,
|
|
3023
|
+
` ctx.ui.notify("Bridge context: " + s.staticFiles + " static, " + s.scopedRules + " scoped (attached " + attached.size + "), " + s.imports + " imports, " + s.skipped + " skipped, " + (s.bytes || 0) + " bytes in the mirror AGENTS.md" + (s.truncated ? " (TRUNCATED)" : "") + ". Native AGENTS.md/CLAUDE.md still load via Pi.", "info");`,
|
|
2812
3024
|
` } catch {}`,
|
|
2813
3025
|
` },`,
|
|
2814
3026
|
` });`,
|
|
@@ -2843,7 +3055,7 @@ function buildPiExtensionSource(opts) {
|
|
|
2843
3055
|
`}`,
|
|
2844
3056
|
``
|
|
2845
3057
|
] : [], `export default function (pi) {`);
|
|
2846
|
-
if (opts.bridge
|
|
3058
|
+
if (opts.bridge) lines.push(...buildPiMemoryBridgeSection(opts.bridge));
|
|
2847
3059
|
if (opts.foreign && opts.foreign.agents.length + opts.foreign.index.length > 0) lines.push(...buildPiForeignAgentsSection(opts.foreign));
|
|
2848
3060
|
lines.push(...buildPiStatuslineFooterSection(), ...buildPiPlanModeSection(), ` // 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 ? [
|
|
2849
3061
|
` // Cheapest-profile execution brief, injected ABOVE the model's turn.`,
|
|
@@ -3051,6 +3263,69 @@ function buildPiPrompts(opts) {
|
|
|
3051
3263
|
});
|
|
3052
3264
|
return prompts;
|
|
3053
3265
|
}
|
|
3266
|
+
// src/lib/pi-mirror-guards.ts
|
|
3267
|
+
async function isFile(file) {
|
|
3268
|
+
try {
|
|
3269
|
+
return (await fs$1.stat(file)).isFile();
|
|
3270
|
+
} catch {
|
|
3271
|
+
return false;
|
|
3272
|
+
}
|
|
3273
|
+
}
|
|
3274
|
+
/** Collect the precedence hazards for this launch. Never throws. */
|
|
3275
|
+
async function inspectMirrorPrecedence(mirrorDir, projectCwd) {
|
|
3276
|
+
const projectAppend = path.join(projectCwd, ".pi", "APPEND_SYSTEM.md");
|
|
3277
|
+
const userClaudeMd = path.join(mirrorDir, "CLAUDE.md");
|
|
3278
|
+
return {
|
|
3279
|
+
agentsOverride: await isFile(path.join(mirrorDir, "AGENTS.override.md")),
|
|
3280
|
+
systemMd: await isFile(path.join(mirrorDir, "SYSTEM.md")),
|
|
3281
|
+
projectAppendSystem: await isFile(projectAppend) ? projectAppend : null,
|
|
3282
|
+
userClaudeMd: await isFile(userClaudeMd) ? userClaudeMd : null
|
|
3283
|
+
};
|
|
3284
|
+
}
|
|
3285
|
+
/**
|
|
3286
|
+
* The launch warnings a bridge block provokes, as data rather than as calls.
|
|
3287
|
+
*
|
|
3288
|
+
* Both messages describe the SAME Pi rule in opposite directions: one context
|
|
3289
|
+
* file per directory, first candidate wins. They are only true when a block was
|
|
3290
|
+
* actually written (`bridgeActive`), because otherwise `AGENTS.md` either does
|
|
3291
|
+
* not exist (so `CLAUDE.md` still loads) or was never touched by us. Returning
|
|
3292
|
+
* strings keeps the gating unit-testable; the launcher only logs them.
|
|
3293
|
+
*/
|
|
3294
|
+
function bridgeShadowWarnings(precedence, opts) {
|
|
3295
|
+
if (!opts.bridgeActive) return [];
|
|
3296
|
+
const warnings = [];
|
|
3297
|
+
if (precedence.agentsOverride) {
|
|
3298
|
+
const file = path.join(opts.mirrorDir, "AGENTS.override.md");
|
|
3299
|
+
warnings.push(`Pi memory bridge: ${file} shadows the mirror AGENTS.md, so the bridged Copilot/Claude rules are NOT loaded this launch. Remove that file (or pass --no-memory-bridge to silence this) and Pi will read the bridged block.`);
|
|
3300
|
+
}
|
|
3301
|
+
if (precedence.userClaudeMd && !opts.userOwnsAgentsMd) warnings.push(`Pi memory bridge: your ${precedence.userClaudeMd} is NOT loaded any more. Pi reads exactly one context file per agent dir and the bridged block lives in AGENTS.md, which outranks it. Copy your text into AGENTS.md — this launcher keeps it above the bridged block — or pass --no-memory-bridge to read CLAUDE.md again.`);
|
|
3302
|
+
return warnings;
|
|
3303
|
+
}
|
|
3304
|
+
/**
|
|
3305
|
+
* Split the router's skills into "write" and "already the user's".
|
|
3306
|
+
*
|
|
3307
|
+
* The mirror is seeded from `~/.pi/agent` before this runs, so a user-level
|
|
3308
|
+
* `skills/gh-oracle/SKILL.md` is already on disk. Overwriting it would silently
|
|
3309
|
+
* destroy the user's copy, so the user's file wins and the caller reports the
|
|
3310
|
+
* collision instead.
|
|
3311
|
+
*/
|
|
3312
|
+
async function planSkillWrites(mirrorDir, skills) {
|
|
3313
|
+
const write = [];
|
|
3314
|
+
const shadowed = [];
|
|
3315
|
+
for (const skill of skills) {
|
|
3316
|
+
const file = path.join(mirrorDir, "skills", skill.dir, "SKILL.md");
|
|
3317
|
+
if (await isFile(file)) shadowed.push({
|
|
3318
|
+
dir: skill.dir,
|
|
3319
|
+
file,
|
|
3320
|
+
skill
|
|
3321
|
+
});
|
|
3322
|
+
else write.push(skill);
|
|
3323
|
+
}
|
|
3324
|
+
return {
|
|
3325
|
+
write,
|
|
3326
|
+
shadowed
|
|
3327
|
+
};
|
|
3328
|
+
}
|
|
3054
3329
|
// src/lib/pi-mcp-config.ts
|
|
3055
3330
|
/**
|
|
3056
3331
|
* Pi's MCP surface for the router's scoped groups.
|
|
@@ -3358,6 +3633,10 @@ const piArgs = {
|
|
|
3358
3633
|
type: "string",
|
|
3359
3634
|
description: "Full base URL, including the /v1 prefix, of the local inference endpoint for `-m local` / `-m local2` (e.g. http://localhost:11111/v1). Sets scheme/host/path, which --localport cannot. Mutually exclusive with --localport. Inert on every other profile."
|
|
3360
3635
|
},
|
|
3636
|
+
"pi-path": {
|
|
3637
|
+
type: "string",
|
|
3638
|
+
description: "Run THIS Pi instead of the one on PATH or the managed copy (absolute path to a pi binary or script). Explicit: skips the version floor, the managed install, and the background refresh."
|
|
3639
|
+
},
|
|
3361
3640
|
"update-check": {
|
|
3362
3641
|
type: "boolean",
|
|
3363
3642
|
default: true,
|
|
@@ -3486,26 +3765,21 @@ const pi = defineCommand({
|
|
|
3486
3765
|
}
|
|
3487
3766
|
let server;
|
|
3488
3767
|
let serverUrl;
|
|
3768
|
+
const piPath = typeof args["pi-path"] === "string" ? args["pi-path"].trim() : "";
|
|
3489
3769
|
const updateCheck = args["update-check"] !== false;
|
|
3490
3770
|
const autoUpdate = args["auto-update"] !== false;
|
|
3491
|
-
|
|
3492
|
-
|
|
3771
|
+
const managePi = updateCheck && piPath === "";
|
|
3772
|
+
let piCommand = null;
|
|
3773
|
+
const pendingResolve = {
|
|
3493
3774
|
promise: null,
|
|
3494
3775
|
abort: null
|
|
3495
3776
|
};
|
|
3496
|
-
if (
|
|
3497
|
-
|
|
3498
|
-
|
|
3499
|
-
|
|
3500
|
-
|
|
3501
|
-
|
|
3502
|
-
if (installedVersion === null) {
|
|
3503
|
-
const controller = new AbortController();
|
|
3504
|
-
pendingInstall.abort = () => controller.abort();
|
|
3505
|
-
pendingInstall.promise = ensurePiInstalled({ signal: controller.signal });
|
|
3506
|
-
pendingInstall.promise.catch(() => {});
|
|
3507
|
-
}
|
|
3508
|
-
}
|
|
3777
|
+
if (managePi) {
|
|
3778
|
+
const controller = new AbortController();
|
|
3779
|
+
pendingResolve.abort = () => controller.abort();
|
|
3780
|
+
pendingResolve.promise = resolvePiCommand({ signal: controller.signal });
|
|
3781
|
+
pendingResolve.promise.catch(() => {});
|
|
3782
|
+
} else if (piPath !== "") piCommand = await resolvePiCommand({ piPath });
|
|
3509
3783
|
try {
|
|
3510
3784
|
const quietBoot = existsSync(PATHS.GITHUB_TOKEN_PATH) && !parsed.verbose && !parsed.showToken;
|
|
3511
3785
|
const priorLevel = consola.level;
|
|
@@ -3523,34 +3797,34 @@ const pi = defineCommand({
|
|
|
3523
3797
|
server = setupResult.server;
|
|
3524
3798
|
serverUrl = setupResult.serverUrl;
|
|
3525
3799
|
} catch (error) {
|
|
3526
|
-
|
|
3800
|
+
pendingResolve.abort?.();
|
|
3527
3801
|
consola.error("Failed to start server:", error instanceof Error ? error.message : error);
|
|
3528
3802
|
process$1.exit(1);
|
|
3529
3803
|
}
|
|
3530
3804
|
runSelfUpdate({ selfUpdate: args["self-update"] !== false });
|
|
3531
|
-
if (
|
|
3532
|
-
|
|
3805
|
+
if (pendingResolve.promise) try {
|
|
3806
|
+
piCommand = await pendingResolve.promise;
|
|
3533
3807
|
} catch (err) {
|
|
3534
|
-
consola.
|
|
3535
|
-
process$1.exit(1);
|
|
3808
|
+
consola.debug("Pi resolution failed:", err);
|
|
3536
3809
|
} finally {
|
|
3537
|
-
|
|
3538
|
-
|
|
3810
|
+
pendingResolve.promise = null;
|
|
3811
|
+
pendingResolve.abort = null;
|
|
3539
3812
|
}
|
|
3540
|
-
if (
|
|
3541
|
-
if (!
|
|
3542
|
-
|
|
3543
|
-
|
|
3544
|
-
|
|
3545
|
-
|
|
3546
|
-
|
|
3547
|
-
|
|
3548
|
-
|
|
3549
|
-
|
|
3550
|
-
|
|
3551
|
-
|
|
3552
|
-
}
|
|
3553
|
-
|
|
3813
|
+
if (managePi) {
|
|
3814
|
+
if (!piCommand || piCommand.command === "") {
|
|
3815
|
+
const detail = piCommand?.note ?? "no runnable `pi` was found";
|
|
3816
|
+
consola.error(`Cannot launch Pi: ${detail}\nInstall it with \`npm install -g @earendil-works/pi-coding-agent@latest --registry=${resolvePiRegistry()}\`, or run \`github-router update --pi\` to install the managed copy.`);
|
|
3817
|
+
process$1.exit(1);
|
|
3818
|
+
}
|
|
3819
|
+
if (!meetsPiMinVersion(piCommand.version)) {
|
|
3820
|
+
consola.error(`Pi v${piCommand.version ?? "unknown"} (${piCommand.command}) is below the supported floor v${PI_MIN_VERSION}. Install a newer one with \`github-router update --pi\`, or pass --pi-path.`);
|
|
3821
|
+
process$1.exit(1);
|
|
3822
|
+
}
|
|
3823
|
+
if (piCommand.note) consola.info(piCommand.note);
|
|
3824
|
+
if (autoUpdate) {
|
|
3825
|
+
if (piCommand.source === "path") refreshPiInBackground({ autoUpdate });
|
|
3826
|
+
else scheduleBackgroundPiInstall().then((detail) => consola.debug(`managed Pi refresh: ${detail}`), (err) => consola.debug("managed Pi refresh failed:", err));
|
|
3827
|
+
}
|
|
3554
3828
|
}
|
|
3555
3829
|
const peersEnabled = args["peers"] !== false;
|
|
3556
3830
|
const sweEnabled = args["swe"] === true;
|
|
@@ -3589,6 +3863,9 @@ const pi = defineCommand({
|
|
|
3589
3863
|
process$1.exit(1);
|
|
3590
3864
|
}
|
|
3591
3865
|
enableFileLogging();
|
|
3866
|
+
const precedence = await inspectMirrorPrecedence(mirror, process$1.cwd());
|
|
3867
|
+
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
|
+
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.`);
|
|
3592
3869
|
let packagesForCache = [];
|
|
3593
3870
|
let foreignAvailable;
|
|
3594
3871
|
let foreignStats;
|
|
@@ -3657,19 +3934,21 @@ const pi = defineCommand({
|
|
|
3657
3934
|
const bridgeDisabled = args["memory-bridge"] === false || process$1.env.GH_ROUTER_PI_BRIDGE === "0" || process$1.env.GH_ROUTER_DISABLE_PI_BRIDGE === "1";
|
|
3658
3935
|
let bridgeStats;
|
|
3659
3936
|
let bridgeScoped = [];
|
|
3937
|
+
let bridgeSection = "";
|
|
3938
|
+
let bridgeCollected;
|
|
3939
|
+
let bridgeActive = false;
|
|
3660
3940
|
if (!bridgeDisabled) {
|
|
3661
3941
|
const passthrough = collectPiPassthroughArgs(rawArgs, piArgs);
|
|
3662
3942
|
if (!(passthrough.includes("--no-context-files") || passthrough.includes("-nc"))) try {
|
|
3663
|
-
const { collectBridgeInputs } = await import("./pi-memory-bridge-
|
|
3943
|
+
const { PI_BRIDGE_STATIC_BUDGET_BYTES, buildMirrorBridgeSection, collectBridgeInputs } = await import("./pi-memory-bridge-D5A0h_Kf.js");
|
|
3664
3944
|
const collected = await collectBridgeInputs(process$1.cwd());
|
|
3665
|
-
|
|
3666
|
-
|
|
3667
|
-
|
|
3668
|
-
|
|
3669
|
-
skipped: collected.skipped.length
|
|
3670
|
-
};
|
|
3945
|
+
const rendered = buildMirrorBridgeSection(collected, { repoRoot: process$1.cwd() });
|
|
3946
|
+
bridgeCollected = collected;
|
|
3947
|
+
bridgeSection = rendered.section;
|
|
3948
|
+
bridgeStats = rendered.stats;
|
|
3671
3949
|
bridgeScoped = collected.scopedRules;
|
|
3672
|
-
|
|
3950
|
+
bridgeActive = rendered.stats.bytes > 0;
|
|
3951
|
+
if (rendered.stats.truncated) consola.warn(`Pi memory bridge: the bridged AGENTS.md block hit its ${Math.round(PI_BRIDGE_STATIC_BUDGET_BYTES / 1e3)} KB budget and was cut to ${rendered.stats.bytes} bytes, so some rules are incomplete or omitted this launch. Raise the budget in src/lib/pi-memory-bridge.ts, or move detail into .claude/rules/ so it attaches on demand instead.`);
|
|
3673
3952
|
} catch (err) {
|
|
3674
3953
|
consola.debug("Pi memory bridge collection skipped:", err);
|
|
3675
3954
|
}
|
|
@@ -3687,15 +3966,22 @@ const pi = defineCommand({
|
|
|
3687
3966
|
peers: peersEnabled
|
|
3688
3967
|
});
|
|
3689
3968
|
for (const [rel, content] of Object.entries(routerAgentFiles)) await writeTextFile(path.join(mirror, rel), content);
|
|
3690
|
-
|
|
3969
|
+
const skillPlan = await planSkillWrites(mirror, routerSkills);
|
|
3970
|
+
for (const skill of skillPlan.write) await writeTextFile(path.join(mirror, "skills", skill.dir, "SKILL.md"), skill.content);
|
|
3971
|
+
const shadowedSkills = skillPlan.shadowed.map(({ dir, file }) => ({
|
|
3972
|
+
dir,
|
|
3973
|
+
file
|
|
3974
|
+
}));
|
|
3975
|
+
if (shadowedSkills.length > 0) consola.warn(`Pi skills: kept your ${shadowedSkills.map((s) => `\`${s.dir}\``).join(", ")} instead of the router's copy (${shadowedSkills[0]?.file}). Remove the user skill to get the router's version back.`);
|
|
3691
3976
|
for (const prompt of routerPrompts) await writeTextFile(path.join(mirror, "prompts", `${prompt.name}.md`), prompt.content);
|
|
3692
3977
|
await writeTextFile(path.join(mirror, "APPEND_SYSTEM.md"), buildPiAppendSystem(profileId, {
|
|
3693
3978
|
peers: peersEnabled,
|
|
3694
|
-
codeSearch: surfaces.codeSearch
|
|
3979
|
+
codeSearch: surfaces.codeSearch,
|
|
3980
|
+
bridge: bridgeActive
|
|
3695
3981
|
}));
|
|
3696
3982
|
let foreign;
|
|
3697
3983
|
if (foreignEnabled) try {
|
|
3698
|
-
const { buildForeignAgentIndex, buildReservedNames, piForeignHomeDir, piForeignRepoRoot, planForeignArtifacts, writeForeignArtifacts } = await import("./pi-foreign-artifacts-
|
|
3984
|
+
const { buildForeignAgentIndex, buildReservedNames, piForeignHomeDir, piForeignRepoRoot, planForeignArtifacts, writeForeignArtifacts } = await import("./pi-foreign-artifacts-CNt6wQ1P.js");
|
|
3699
3985
|
const repoRoot = await piForeignRepoRoot(process$1.cwd());
|
|
3700
3986
|
const homeDir = piForeignHomeDir();
|
|
3701
3987
|
const reservedNames = await buildReservedNames({
|
|
@@ -3748,7 +4034,7 @@ const pi = defineCommand({
|
|
|
3748
4034
|
consola.debug("Pi foreign bridge skipped:", err);
|
|
3749
4035
|
}
|
|
3750
4036
|
else try {
|
|
3751
|
-
const { countForeignAgentFiles, piForeignHomeDir, piForeignRepoRoot } = await import("./pi-foreign-artifacts-
|
|
4037
|
+
const { countForeignAgentFiles, piForeignHomeDir, piForeignRepoRoot } = await import("./pi-foreign-artifacts-CNt6wQ1P.js");
|
|
3752
4038
|
foreignAvailable = await countForeignAgentFiles({
|
|
3753
4039
|
repoRoot: await piForeignRepoRoot(process$1.cwd()),
|
|
3754
4040
|
homeDir: piForeignHomeDir()
|
|
@@ -3775,30 +4061,38 @@ const pi = defineCommand({
|
|
|
3775
4061
|
if (written.skippedReason) consola.warn(`Pi MCP: left ${written.path} alone (${written.skippedReason}); the scoped groups are not exposed to Pi this launch.`);
|
|
3776
4062
|
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.`);
|
|
3777
4063
|
}
|
|
3778
|
-
try {
|
|
3779
|
-
const
|
|
3780
|
-
|
|
3781
|
-
|
|
3782
|
-
|
|
3783
|
-
|
|
3784
|
-
|
|
3785
|
-
|
|
3786
|
-
existing = await fs$1.readFile(agentsPath, "utf8");
|
|
3787
|
-
} catch {
|
|
3788
|
-
existing = void 0;
|
|
3789
|
-
}
|
|
3790
|
-
await writeTextFile(agentsPath, mergeBridgeIntoAgentsMd(existing, section));
|
|
3791
|
-
await writeJsonFile(path.join(mirror, ".gh-router-bridge.json"), {
|
|
3792
|
-
stats: bridgeStats ?? null,
|
|
3793
|
-
scopedRuleFiles: bridgeScoped.map((r) => r.file)
|
|
3794
|
-
});
|
|
4064
|
+
if (bridgeCollected) try {
|
|
4065
|
+
const { mergeBridgeIntoAgentsMd } = await import("./pi-memory-bridge-D5A0h_Kf.js");
|
|
4066
|
+
const agentsPath = path.join(mirror, "AGENTS.md");
|
|
4067
|
+
let existing;
|
|
4068
|
+
try {
|
|
4069
|
+
existing = await fs$1.readFile(agentsPath, "utf8");
|
|
4070
|
+
} catch {
|
|
4071
|
+
existing = void 0;
|
|
3795
4072
|
}
|
|
4073
|
+
const userText = mergeBridgeIntoAgentsMd(existing, "").trim();
|
|
4074
|
+
const merged = mergeBridgeIntoAgentsMd(existing, bridgeSection);
|
|
4075
|
+
if (merged !== (existing ?? "")) await writeTextFile(agentsPath, merged);
|
|
4076
|
+
const shadowWarnings = bridgeShadowWarnings(precedence, {
|
|
4077
|
+
bridgeActive,
|
|
4078
|
+
mirrorDir: mirror,
|
|
4079
|
+
userOwnsAgentsMd: userText.length > 0
|
|
4080
|
+
});
|
|
4081
|
+
for (const warning of shadowWarnings) consola.warn(warning);
|
|
4082
|
+
await writeJsonFile(path.join(mirror, ".gh-router-bridge.json"), {
|
|
4083
|
+
stats: bridgeStats ?? null,
|
|
4084
|
+
deduped: bridgeCollected.deduped ?? 0,
|
|
4085
|
+
shadowedSkills,
|
|
4086
|
+
scopedRuleFiles: bridgeScoped.map((r) => r.file),
|
|
4087
|
+
precedence: {
|
|
4088
|
+
agentsOverride: precedence.agentsOverride ? path.join(mirror, "AGENTS.override.md") : null,
|
|
4089
|
+
userClaudeMd: precedence.userClaudeMd,
|
|
4090
|
+
systemMd: precedence.systemMd ? path.join(mirror, "SYSTEM.md") : null,
|
|
4091
|
+
projectAppendSystem: precedence.projectAppendSystem
|
|
4092
|
+
}
|
|
4093
|
+
});
|
|
3796
4094
|
} catch (err) {
|
|
3797
4095
|
consola.debug("Pi memory bridge synthesis skipped:", err);
|
|
3798
|
-
} finally {
|
|
3799
|
-
try {
|
|
3800
|
-
delete globalThis.__ghRouterBridgeCollected;
|
|
3801
|
-
} catch {}
|
|
3802
4096
|
}
|
|
3803
4097
|
} catch (err) {
|
|
3804
4098
|
consola.error(`Failed to write Pi launch files: ${err instanceof Error ? err.message : String(err)}.`);
|
|
@@ -3868,9 +4162,10 @@ const pi = defineCommand({
|
|
|
3868
4162
|
})}\n`);
|
|
3869
4163
|
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");
|
|
3870
4164
|
const { disposeBluebirdClients } = await import("./bluebird-client-BvoMTmEv.js");
|
|
3871
|
-
const { disposeAdoClients } = await import("./ado-tools-
|
|
4165
|
+
const { disposeAdoClients } = await import("./ado-tools-CsfbnY8x.js");
|
|
3872
4166
|
launchChild({
|
|
3873
4167
|
kind: "pi",
|
|
4168
|
+
execArgs: piCommand && piCommand.command !== "" ? [piCommand.command, ...piCommand.args] : void 0,
|
|
3874
4169
|
envVars: {
|
|
3875
4170
|
...getPiLaunchEnvVars(mirror),
|
|
3876
4171
|
GH_ROUTER_HOOK_MCP_URL: serverUrl,
|
|
@@ -3905,4 +4200,4 @@ const pi = defineCommand({
|
|
|
3905
4200
|
});
|
|
3906
4201
|
export { pi };
|
|
3907
4202
|
|
|
3908
|
-
//# sourceMappingURL=pi-
|
|
4203
|
+
//# sourceMappingURL=pi-YhoA26wi.js.map
|