github-router 0.3.341 → 0.3.342
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/dist/{attribution-settings-DTPVRoYF.js → attribution-settings-DA3wkQHE.js} +2 -2
- package/dist/{attribution-settings-DTPVRoYF.js.map → attribution-settings-DA3wkQHE.js.map} +1 -1
- package/dist/browser-ext/manifest.json +1 -1
- package/dist/{claude-DaSQnZXM.js → claude-CMuHUWWy.js} +3 -3
- package/dist/{claude-DaSQnZXM.js.map → claude-CMuHUWWy.js.map} +1 -1
- package/dist/{codex-Eq758eVC.js → codex-B__qfHCC.js} +2 -2
- package/dist/{codex-Eq758eVC.js.map → codex-B__qfHCC.js.map} +1 -1
- package/dist/main.js +5 -5
- package/dist/{pi-BNvhtN7g.js → pi-WT6IahMr.js} +174 -3
- package/dist/pi-WT6IahMr.js.map +1 -0
- package/dist/pi-memory-bridge-BWZJnjpz.js +404 -0
- package/dist/pi-memory-bridge-BWZJnjpz.js.map +1 -0
- package/dist/{serve-DpfttCk6.js → serve-BaLMvHSp.js} +3 -3
- package/dist/{serve-DpfttCk6.js.map → serve-BaLMvHSp.js.map} +1 -1
- package/dist/{server-setup-LYpeaZ9B.js → server-setup-B7Usfq5v.js} +2 -2
- package/dist/{server-setup-LYpeaZ9B.js.map → server-setup-B7Usfq5v.js.map} +1 -1
- package/dist/{start-BoHdkXba.js → start-C-13_1Ld.js} +2 -2
- package/dist/{start-BoHdkXba.js.map → start-C-13_1Ld.js.map} +1 -1
- package/package.json +1 -1
- package/dist/pi-BNvhtN7g.js.map +0 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { N as warmTreeSitterPool } from "./service-backend-7SPDLUB9.js";
|
|
2
2
|
import { t as state } from "./state-CVp30CBF.js";
|
|
3
3
|
import { d as resolveModel, u as resolveCodexModel } from "./token-DATA_OQK.js";
|
|
4
|
-
import { a as setupAndServe, c as startKeepAwake, d as listModelsForEndpoint, f as enableFileLogging, i as parseSharedArgs, l as stopKeepAwake, n as getCodexEnvVars, o as sharedServerArgs, z as runSelfUpdate } from "./server-setup-
|
|
4
|
+
import { a as setupAndServe, c as startKeepAwake, d as listModelsForEndpoint, f as enableFileLogging, i as parseSharedArgs, l as stopKeepAwake, n as getCodexEnvVars, o as sharedServerArgs, z as runSelfUpdate } from "./server-setup-B7Usfq5v.js";
|
|
5
5
|
import { D as toolbeltEnabled, an as provisionAndIndexColbert, gn as DEFAULT_CODEX_MODEL_FALLBACKS, hn as DEFAULT_CODEX_MODEL, in as colbertDegradedWarning, nn as provisionBrowserAssets, rn as hasSupportedBrowserInstalled } from "./peer-mcp-personas-Dt0VRKYz.js";
|
|
6
6
|
import { i as launchChild, t as provisionToolbelt } from "./provision-D_aHUCXt.js";
|
|
7
7
|
import { s as disposeBluebirdClients } from "./bluebird-client-DpYl1YmJ.js";
|
|
@@ -90,4 +90,4 @@ const codex = defineCommand({
|
|
|
90
90
|
//#endregion
|
|
91
91
|
export { codex };
|
|
92
92
|
|
|
93
|
-
//# sourceMappingURL=codex-
|
|
93
|
+
//# sourceMappingURL=codex-B__qfHCC.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"codex-
|
|
1
|
+
{"version":3,"file":"codex-B__qfHCC.js","names":[],"sources":["../src/codex.ts"],"sourcesContent":["import process from \"node:process\"\n\nimport { defineCommand } from \"citty\"\nimport consola from \"consola\"\n\nimport { enableFileLogging } from \"./lib/file-log-reporter\"\nimport { launchChild } from \"./lib/launch\"\nimport { listModelsForEndpoint } from \"./lib/model-validation\"\nimport {\n DEFAULT_CODEX_MODEL,\n DEFAULT_CODEX_MODEL_FALLBACKS,\n} from \"./lib/port\"\nimport {\n getCodexEnvVars,\n parseSharedArgs,\n setupAndServe,\n sharedServerArgs,\n} from \"./lib/server-setup\"\nimport { runSelfUpdate } from \"./lib/self-update\"\nimport { state } from \"./lib/state\"\nimport { toolbeltEnabled } from \"./lib/toolbelt\"\nimport { provisionToolbelt } from \"./lib/toolbelt/provision\"\nimport { colbertDegradedWarning, provisionAndIndexColbert } from \"./lib/colbert\"\nimport { startKeepAwake, stopKeepAwake } from \"./lib/keep-awake\"\nimport { warmTreeSitterPool } from \"./lib/tree-sitter-pool/pool\"\nimport { provisionBrowserAssets } from \"./lib/browser-mcp/provision\"\nimport { hasSupportedBrowserInstalled } from \"./lib/browser-mcp/browser-detect\"\nimport { disposeBluebirdClients } from \"./lib/bluebird-client\"\nimport { resolveCodexModel, resolveModel } from \"./lib/utils\"\n\nexport const codex = defineCommand({\n meta: {\n name: \"codex\",\n description: \"Start the proxy server and launch Codex CLI\",\n },\n args: {\n ...sharedServerArgs,\n model: {\n alias: \"m\",\n type: \"string\",\n description: \"Override the default model for Codex CLI\",\n },\n },\n async run({ args }) {\n if (!process.stdout.isTTY) {\n consola.error(\"The codex subcommand requires a TTY (interactive terminal).\")\n process.exit(1)\n }\n\n const parsed = parseSharedArgs(args as unknown as Record<string, unknown>)\n\n let server: Awaited<ReturnType<typeof setupAndServe>>[\"server\"]\n let serverUrl: string\n try {\n const result = await setupAndServe({\n ...parsed,\n port: parsed.port, // undefined = random port\n silent: true,\n })\n server = result.server\n serverUrl = result.serverUrl\n } catch (error) {\n consola.error(\"Failed to start server:\", error instanceof Error ? error.message : error)\n process.exit(1)\n }\n\n // Best-effort self-update (detached, applies next launch).\n void runSelfUpdate({ selfUpdate: args[\"self-update\"] !== false })\n\n // Materialize the LLM toolbelt in the background (PATH prepend is in\n // getCodexEnvVars). Best-effort; never blocks launch.\n if (toolbeltEnabled()) {\n void provisionToolbelt().catch(() => {})\n }\n\n // Best-effort ColBERT semantic-search provision + background index of\n // the launch cwd. Opt-IN via --search (no-op otherwise); never blocks\n // launch, never throws.\n void provisionAndIndexColbert()\n\n // Surface a terminally-failed semantic index to the HUMAN (see the note\n // in claude.ts). Fire-and-forget; lexical search still works.\n void colbertDegradedWarning(undefined, { logsToFile: true })\n .then((warning) => {\n if (warning) process.stderr.write(`${warning}\\n`)\n })\n .catch(() => {})\n\n // Best-effort, bounded launch warm-up: ready one tree-sitter worker.\n // Opt out with GH_ROUTER_DISABLE_TS_POOL_WARMUP=1.\n void warmTreeSitterPool()\n\n // Best-effort: keep the machine awake while the proxy/Codex session\n // runs (win32 default-on; opt out GH_ROUTER_DISABLE_KEEP_AWAKE=1).\n // Self-registered SIGINT/SIGTERM/exit reaper releases the assertion.\n startKeepAwake()\n\n // Best-effort: materialize the browser extension + bridge into the\n // stable app-dir and stamp the running version. Gated inline (browse\n // opt-in + a supported browser) rather than via browserToolsEnabled()\n // so the codex command path doesn't eagerly pull the compressor /\n // worker-agent graph. Never blocks launch, never throws.\n const browseOptIn =\n state.browseEnabled || process.env.GH_ROUTER_ENABLE_BROWSE === \"1\"\n if (browseOptIn && hasSupportedBrowserInstalled()) {\n void provisionBrowserAssets().catch((err) =>\n consola.debug(\"Browser extension provisioning failed:\", err),\n )\n }\n\n const usingDefault = !args.model\n const requestedModel = args.model ?? DEFAULT_CODEX_MODEL\n\n // Resolve model before printing success message (so we show the actual model)\n // but enable file logging first so resolution warnings go to file, not terminal\n enableFileLogging()\n\n let codexModel = resolveCodexModel(requestedModel)\n if (codexModel !== requestedModel) {\n consola.info(`Model \"${requestedModel}\" resolved to \"${codexModel}\"`)\n }\n\n // For the implicit-default path only: honor the explicit fallback order\n // (DEFAULT_CODEX_MODEL, then DEFAULT_CODEX_MODEL_FALLBACKS led by gpt-5.5)\n // by cache presence BEFORE resolveCodexModel's codex-slug-preferring\n // \"best /responses model\" safety net. `resolveModel` (NOT resolveCodexModel)\n // walks the chain, so the codex-slug preference can't shadow an\n // earlier-in-chain named fallback (e.g. gpt-5.5) that IS present. The\n // resolveCodexModel result above stays as the FINAL safety net, used only\n // when none of the named chain entries is in the catalog.\n if (usingDefault && state.models) {\n const inCache = (id: string) =>\n state.models?.data.some((m) => m.id === id) ?? false\n const firstPresent = [DEFAULT_CODEX_MODEL, ...DEFAULT_CODEX_MODEL_FALLBACKS]\n .map((id) => resolveModel(id))\n .find((id) => inCache(id))\n if (firstPresent) {\n if (firstPresent !== codexModel) {\n consola.info(\n `Default model \"${DEFAULT_CODEX_MODEL}\" not in your Copilot model list; falling back to \"${firstPresent}\".`,\n )\n }\n codexModel = firstPresent\n }\n }\n\n // Validate model exists in Copilot model list\n const modelEntry = state.models?.data.find((m) => m.id === codexModel)\n if (!modelEntry) {\n const available = listModelsForEndpoint(\"/responses\")\n consola.warn(\n `Model \"${codexModel}\" not found. Available codex models: ${available.join(\", \")}`,\n )\n } else {\n const ctx = modelEntry.capabilities?.limits?.max_context_window_tokens\n if (ctx) consola.info(`Model context window: ${ctx.toLocaleString()} tokens`)\n }\n\n // Print to stderr directly — consola's terminal reporter is already gone\n process.stderr.write(`Server ready on ${serverUrl}, launching Codex CLI (${codexModel})...\\n`)\n\n const envVars = getCodexEnvVars(serverUrl)\n const extraArgs = ((args as unknown as Record<string, unknown>)._ as string[]) ?? []\n\n launchChild(\n {\n kind: \"codex\",\n envVars,\n extraArgs,\n model: codexModel,\n serverUrl,\n },\n server,\n {\n onShutdown: async () => {\n await stopKeepAwake()\n await disposeBluebirdClients()\n },\n },\n )\n },\n})\n"],"mappings":";;;;;;;;;;;AA8BA,MAAa,QAAQ,cAAc;CACjC,MAAM;EACJ,MAAM;EACN,aAAa;CACf;CACA,MAAM;EACJ,GAAG;EACH,OAAO;GACL,OAAO;GACP,MAAM;GACN,aAAa;EACf;CACF;CACA,MAAM,IAAI,EAAE,QAAQ;EAClB,IAAI,CAAC,QAAQ,OAAO,OAAO;GACzB,QAAQ,MAAM,6DAA6D;GAC3E,QAAQ,KAAK,CAAC;EAChB;EAEA,MAAM,SAAS,gBAAgB,IAA0C;EAEzE,IAAI;EACJ,IAAI;EACJ,IAAI;GACF,MAAM,SAAS,MAAM,cAAc;IACjC,GAAG;IACH,MAAM,OAAO;IACb,QAAQ;GACV,CAAC;GACD,SAAS,OAAO;GAChB,YAAY,OAAO;EACrB,SAAS,OAAO;GACd,QAAQ,MAAM,2BAA2B,iBAAiB,QAAQ,MAAM,UAAU,KAAK;GACvF,QAAQ,KAAK,CAAC;EAChB;EAGA,cAAmB,EAAE,YAAY,KAAK,mBAAmB,MAAM,CAAC;EAIhE,IAAI,gBAAgB,GAClB,kBAAuB,CAAC,CAAC,YAAY,CAAC,CAAC;EAMzC,yBAA8B;EAI9B,uBAA4B,KAAA,GAAW,EAAE,YAAY,KAAK,CAAC,CAAC,CACzD,MAAM,YAAY;GACjB,IAAI,SAAS,QAAQ,OAAO,MAAM,GAAG,QAAQ,GAAG;EAClD,CAAC,CAAC,CACD,YAAY,CAAC,CAAC;EAIjB,mBAAwB;EAKxB,eAAe;EASf,KADE,MAAM,iBAAiB,QAAQ,IAAI,4BAA4B,QAC9C,6BAA6B,GAC9C,uBAA4B,CAAC,CAAC,OAAO,QACnC,QAAQ,MAAM,0CAA0C,GAAG,CAC7D;EAGF,MAAM,eAAe,CAAC,KAAK;EAC3B,MAAM,iBAAiB,KAAK,SAAA;EAI5B,kBAAkB;EAElB,IAAI,aAAa,kBAAkB,cAAc;EACjD,IAAI,eAAe,gBACjB,QAAQ,KAAK,UAAU,eAAe,iBAAiB,WAAW,EAAE;EAWtE,IAAI,gBAAgB,MAAM,QAAQ;GAChC,MAAM,WAAW,OACf,MAAM,QAAQ,KAAK,MAAM,MAAM,EAAE,OAAO,EAAE,KAAK;GACjD,MAAM,eAAe,CAAC,qBAAqB,GAAG,6BAA6B,CAAC,CACzE,KAAK,OAAO,aAAa,EAAE,CAAC,CAAC,CAC7B,MAAM,OAAO,QAAQ,EAAE,CAAC;GAC3B,IAAI,cAAc;IAChB,IAAI,iBAAiB,YACnB,QAAQ,KACN,kBAAkB,oBAAoB,qDAAqD,aAAa,GAC1G;IAEF,aAAa;GACf;EACF;EAGA,MAAM,aAAa,MAAM,QAAQ,KAAK,MAAM,MAAM,EAAE,OAAO,UAAU;EACrE,IAAI,CAAC,YAAY;GACf,MAAM,YAAY,sBAAsB,YAAY;GACpD,QAAQ,KACN,UAAU,WAAW,uCAAuC,UAAU,KAAK,IAAI,GACjF;EACF,OAAO;GACL,MAAM,MAAM,WAAW,cAAc,QAAQ;GAC7C,IAAI,KAAK,QAAQ,KAAK,yBAAyB,IAAI,eAAe,EAAE,QAAQ;EAC9E;EAGA,QAAQ,OAAO,MAAM,mBAAmB,UAAU,yBAAyB,WAAW,OAAO;EAE7F,MAAM,UAAU,gBAAgB,SAAS;EACzC,MAAM,YAAc,KAA4C,KAAkB,CAAC;EAEnF,YACE;GACE,MAAM;GACN;GACA;GACA,OAAO;GACP;EACF,GACA,QACA,EACE,YAAY,YAAY;GACtB,MAAM,cAAc;GACpB,MAAM,uBAAuB;EAC/B,EACF,CACF;CACF;AACF,CAAC"}
|
package/dist/main.js
CHANGED
|
@@ -47,11 +47,11 @@ const main = defineCommand({
|
|
|
47
47
|
},
|
|
48
48
|
subCommands: {
|
|
49
49
|
auth: () => import("./auth-DjKEIiqG.js").then((m) => m.auth),
|
|
50
|
-
start: () => import("./start-
|
|
51
|
-
claude: () => import("./claude-
|
|
52
|
-
codex: () => import("./codex-
|
|
53
|
-
pi: () => import("./pi-
|
|
54
|
-
serve: () => import("./serve-
|
|
50
|
+
start: () => import("./start-C-13_1Ld.js").then((m) => m.start),
|
|
51
|
+
claude: () => import("./claude-CMuHUWWy.js").then((m) => m.claude),
|
|
52
|
+
codex: () => import("./codex-B__qfHCC.js").then((m) => m.codex),
|
|
53
|
+
pi: () => import("./pi-WT6IahMr.js").then((m) => m.pi),
|
|
54
|
+
serve: () => import("./serve-BaLMvHSp.js").then((m) => m.serve),
|
|
55
55
|
models: () => import("./models-68HDOEPK.js").then((m) => m.models),
|
|
56
56
|
"check-usage": () => import("./check-usage-B7UrDwD8.js").then((m) => m.checkUsage),
|
|
57
57
|
index: () => import("./index-cmd-DXYWgKS6.js").then((m) => m.indexCmd),
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { I as withInstallLock, N as warmTreeSitterPool } from "./service-backend-7SPDLUB9.js";
|
|
2
2
|
import { t as state } from "./state-CVp30CBF.js";
|
|
3
3
|
import { c as runCommandVoid, o as resolveExecutable, s as runCommandCapture } from "./exec-MCU1H-KZ.js";
|
|
4
|
-
import { 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 runSelfUpdate } from "./server-setup-
|
|
4
|
+
import { 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 runSelfUpdate } from "./server-setup-B7Usfq5v.js";
|
|
5
5
|
import { a as BALANCED_PROFILE_NATIVE_EFFORTS, c as BALANCED_PROFILE_ORACLE_MODEL, r as BALANCED_PROFILE_MODELS, s as BALANCED_PROFILE_ORACLE_EFFORT } from "./balanced-profile-contract-C6AgFJNp.js";
|
|
6
6
|
import { D as toolbeltEnabled, Gt as registerLaunch, In as CHEAPEST_PROFILE_NATIVE_EFFORTS, Kt as unregisterLaunch, Mn as CHEAPEST_PROFILE_ADVISOR_EFFORT, Nn as CHEAPEST_PROFILE_ADVISOR_MODEL, Pn as CHEAPEST_PROFILE_MODELS, Rn as CHEAPEST_PROFILE_ORACLE_EFFORT, an as provisionAndIndexColbert, ft as browserToolsEnabled, in as colbertDegradedWarning, nn as provisionBrowserAssets, zn as CHEAPEST_PROFILE_ORACLE_MODEL } from "./peer-mcp-personas-Dt0VRKYz.js";
|
|
7
7
|
import { r as resolveSelfInvocation } from "./self-invocation-DIUyoRgL.js";
|
|
@@ -1125,6 +1125,122 @@ function buildPiStatuslineFooterSection() {
|
|
|
1125
1125
|
` }`
|
|
1126
1126
|
];
|
|
1127
1127
|
}
|
|
1128
|
+
/**
|
|
1129
|
+
* Memory-bridge section for the generated extension: path-scoped rules
|
|
1130
|
+
* lazy-attach on `read/edit/write` tool results (once per rule per
|
|
1131
|
+
* session, mirroring `pi-code/claude-rules.ts`), plus `/memory` (bridge
|
|
1132
|
+
* inventory + auto-memory locations, on-demand only) and `/context`
|
|
1133
|
+
* (what bridged vs skipped). Fail-open: every handler is try/catch and
|
|
1134
|
+
* returns undefined on any error so Pi native behavior is preserved.
|
|
1135
|
+
*/
|
|
1136
|
+
function buildPiMemoryBridgeSection(bridge) {
|
|
1137
|
+
const cappedRules = bridge.scopedRules.map((r) => ({
|
|
1138
|
+
file: r.file,
|
|
1139
|
+
body: r.body.length > 8e3 ? `${r.body.slice(0, 8e3)}\n…[truncated by gh-router memory bridge]` : r.body,
|
|
1140
|
+
globs: r.globs,
|
|
1141
|
+
source: r.source
|
|
1142
|
+
}));
|
|
1143
|
+
return [
|
|
1144
|
+
` // Memory bridge: lazy path-scoped rules + /memory + /context (on-demand only).`,
|
|
1145
|
+
` {`,
|
|
1146
|
+
` let BRIDGE = null;`,
|
|
1147
|
+
` try { BRIDGE = ${JSON.stringify({
|
|
1148
|
+
stats: bridge.stats,
|
|
1149
|
+
scopedRules: cappedRules
|
|
1150
|
+
})}; } catch { BRIDGE = null; }`,
|
|
1151
|
+
` const attached = new Set();`,
|
|
1152
|
+
` function globToRegExp(glob) {`,
|
|
1153
|
+
` let g = String(glob || "").trim().replace(/^\\.\\//, "").replace(/^\\/+/, "");`,
|
|
1154
|
+
` let re = "";`,
|
|
1155
|
+
` for (let k = 0; k < g.length;) {`,
|
|
1156
|
+
` const c = g[k];`,
|
|
1157
|
+
` if (c === "*") {`,
|
|
1158
|
+
` if (g[k + 1] === "*") {`,
|
|
1159
|
+
` if (g[k + 2] === "/") { re += "(?:.*/)?"; k += 3; }`,
|
|
1160
|
+
` else { re += ".*"; k += 2; }`,
|
|
1161
|
+
` } else { re += "[^/]*"; k += 1; }`,
|
|
1162
|
+
` continue;`,
|
|
1163
|
+
` }`,
|
|
1164
|
+
` if (c === "?") { re += "[^/]"; k += 1; continue; }`,
|
|
1165
|
+
` if ("+()|^$.{}[]\\\\".includes(c)) re += "\\\\" + c; else re += c;`,
|
|
1166
|
+
` k += 1;`,
|
|
1167
|
+
` }`,
|
|
1168
|
+
` if (!g.includes("/")) re = "(?:.*/)?" + re;`,
|
|
1169
|
+
` try { return new RegExp("^" + re + "$"); } catch { return null; }`,
|
|
1170
|
+
` }`,
|
|
1171
|
+
` function ruleMatches(rule, touchedPath, cwd) {`,
|
|
1172
|
+
` try {`,
|
|
1173
|
+
` const cands = [touchedPath];`,
|
|
1174
|
+
` const base = String(touchedPath || "").split("/").pop() || "";`,
|
|
1175
|
+
` if (base) cands.push(base);`,
|
|
1176
|
+
` let rel = touchedPath || "";`,
|
|
1177
|
+
` try {`,
|
|
1178
|
+
` if (cwd && String(touchedPath).startsWith(String(cwd))) rel = String(touchedPath).slice(String(cwd).length).replace(/^\\/+/, "");`,
|
|
1179
|
+
` } catch {}`,
|
|
1180
|
+
` if (rel) cands.push(rel);`,
|
|
1181
|
+
` for (const g of (rule.globs || [])) {`,
|
|
1182
|
+
` const re = globToRegExp(g);`,
|
|
1183
|
+
` if (!re) continue;`,
|
|
1184
|
+
` for (const c of cands) { try { if (re.test(c)) return true; } catch {} }`,
|
|
1185
|
+
` }`,
|
|
1186
|
+
` } catch {}`,
|
|
1187
|
+
` return false;`,
|
|
1188
|
+
` }`,
|
|
1189
|
+
` try {`,
|
|
1190
|
+
` pi.on("tool_result", async (event, ctx) => {`,
|
|
1191
|
+
` try {`,
|
|
1192
|
+
` if (!BRIDGE || !Array.isArray(BRIDGE.scopedRules) || BRIDGE.scopedRules.length === 0) return undefined;`,
|
|
1193
|
+
` if (event.isError) return undefined;`,
|
|
1194
|
+
` if (event.toolName !== "read" && event.toolName !== "edit" && event.toolName !== "write") return undefined;`,
|
|
1195
|
+
` const rel = event.input && event.input.path;`,
|
|
1196
|
+
` if (typeof rel !== "string" || !rel) return undefined;`,
|
|
1197
|
+
` let abs = rel;`,
|
|
1198
|
+
` try { const cwd = ctx.cwd || ""; abs = rel.startsWith("/") ? rel : (cwd ? cwd + "/" + rel : rel); } catch {}`,
|
|
1199
|
+
` const bodies = [];`,
|
|
1200
|
+
` for (const rule of BRIDGE.scopedRules) {`,
|
|
1201
|
+
` try {`,
|
|
1202
|
+
` if (attached.has(rule.file)) continue;`,
|
|
1203
|
+
` if (!ruleMatches(rule, abs, ctx.cwd || "")) continue;`,
|
|
1204
|
+
` attached.add(rule.file);`,
|
|
1205
|
+
` bodies.push(rule.body);`,
|
|
1206
|
+
` } catch {}`,
|
|
1207
|
+
` }`,
|
|
1208
|
+
` if (bodies.length === 0) return undefined;`,
|
|
1209
|
+
` return { content: [...(event.content || []), ...bodies.map((text) => ({ type: "text", text }))] };`,
|
|
1210
|
+
` } catch { return undefined; }`,
|
|
1211
|
+
` });`,
|
|
1212
|
+
` } catch {}`,
|
|
1213
|
+
` try {`,
|
|
1214
|
+
` pi.registerCommand("memory", {`,
|
|
1215
|
+
` description: "Show bridged memory inventory and auto-memory locations (on-demand; nothing auto-injected)",`,
|
|
1216
|
+
` handler: async (_args, ctx) => {`,
|
|
1217
|
+
` try {`,
|
|
1218
|
+
` const s = (BRIDGE && BRIDGE.stats) || { staticFiles: 0, scopedRules: 0, imports: 0, skipped: 0 };`,
|
|
1219
|
+
` 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)"];`,
|
|
1220
|
+
` try {`,
|
|
1221
|
+
` const files = (BRIDGE.scopedRules || []).map((r) => r.file);`,
|
|
1222
|
+
` if (files.length > 0) lines.push(" Scoped files:", ...files.slice(0, 20).map((f) => " - " + f));`,
|
|
1223
|
+
` } catch {}`,
|
|
1224
|
+
` lines.push("cwd: " + (ctx.cwd || ""));`,
|
|
1225
|
+
` ctx.ui.notify(lines.join("\\n"), "info");`,
|
|
1226
|
+
` } catch {}`,
|
|
1227
|
+
` },`,
|
|
1228
|
+
` });`,
|
|
1229
|
+
` } catch {}`,
|
|
1230
|
+
` try {`,
|
|
1231
|
+
` pi.registerCommand("context", {`,
|
|
1232
|
+
` description: "Show what the gh-router memory bridge loaded",`,
|
|
1233
|
+
` handler: async (_args, ctx) => {`,
|
|
1234
|
+
` try {`,
|
|
1235
|
+
` const s = (BRIDGE && BRIDGE.stats) || { staticFiles: 0, scopedRules: 0, imports: 0, skipped: 0 };`,
|
|
1236
|
+
` 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");`,
|
|
1237
|
+
` } catch {}`,
|
|
1238
|
+
` },`,
|
|
1239
|
+
` });`,
|
|
1240
|
+
` } catch {}`,
|
|
1241
|
+
` }`
|
|
1242
|
+
];
|
|
1243
|
+
}
|
|
1128
1244
|
function buildPiExtensionSource(opts) {
|
|
1129
1245
|
const peers = opts.peers !== false;
|
|
1130
1246
|
const advisor = peers ? piAdvisorModel(opts.profileId) : void 0;
|
|
@@ -1156,6 +1272,7 @@ function buildPiExtensionSource(opts) {
|
|
|
1156
1272
|
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) {`, ` return await toolText(callMcp("peers", "oracle", { decision: "Review this plan (advisory)", options: params.plan, context: params.context || "", model: ADVISOR_MODEL, thinking: ADVISOR_THINKING }, signal));`, ` },`, ` });`);
|
|
1157
1273
|
if (opts.searchEnabled) lines.push(` pi.registerTool({`, ` name: "code_search",`, ` label: "Code search",`, ` description: "Semantic-first code search over the workspace index (falls back to lexical with a label). Use for finding code by meaning.",`, ` parameters: CodeSearchParams,`, ` async execute(_toolCallId, params, signal) {`, ` return await toolText(callMcp("search", "code", { query: params.query, mode: params.mode || "semantic", limit: params.limit || 15 }, signal));`, ` },`, ` });`);
|
|
1158
1274
|
if (opts.browseEnabled) lines.push(` const BROWSER_TOOLS = ["browser_open_tab", "browser_navigate", "browser_screenshot", "browser_act", "browser_observe", "browser_extract"];`, ` for (const wireName of BROWSER_TOOLS) {`, ` pi.registerTool({`, ` name: wireName,`, ` description: "Browser control (" + wireName + "). Returns install_required with setup steps when the extension is not loaded.",`, ` parameters: BrowserParams,`, ` async execute(_toolCallId, params, signal) {`, ` return await toolText(callMcp("browser", wireName, { url: params.url || "", intent: params.intent || "" }, signal));`, ` },`, ` });`, ` }`);
|
|
1275
|
+
if (opts.bridge && opts.bridge.scopedRules.length + opts.bridge.stats.staticFiles > 0) lines.push(...buildPiMemoryBridgeSection(opts.bridge));
|
|
1159
1276
|
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;`, ` }`, ` });`, `}`, ``);
|
|
1160
1277
|
return `${lines.join("\n")}\n`;
|
|
1161
1278
|
}
|
|
@@ -1302,6 +1419,11 @@ const piArgs = {
|
|
|
1302
1419
|
type: "boolean",
|
|
1303
1420
|
default: true,
|
|
1304
1421
|
description: "Wire the peer/subagent floor: native agent files, the oracle tool (plus cheapest-only advisor), the gh-oracle skill, and the pi-subagents package. Set to false (--no-peers) for a lead-only session; prereqs then validate the lead model only."
|
|
1422
|
+
},
|
|
1423
|
+
"memory-bridge": {
|
|
1424
|
+
type: "boolean",
|
|
1425
|
+
default: true,
|
|
1426
|
+
description: "Bridge Copilot (.github/copilot-instructions.md, .github/instructions/*.instructions.md) and Claude (.claude/rules/, .claude/CLAUDE.md, ~/.claude/CLAUDE.md) memory into Pi. Static repo-wide slice synthesizes into the mirror AGENTS.md; path-scoped rules lazy-attach. Set to false (--no-memory-bridge) for Pi-native discovery only."
|
|
1305
1427
|
}
|
|
1306
1428
|
};
|
|
1307
1429
|
/**
|
|
@@ -1477,11 +1599,35 @@ const pi = defineCommand({
|
|
|
1477
1599
|
peers: peersEnabled
|
|
1478
1600
|
})
|
|
1479
1601
|
});
|
|
1602
|
+
const bridgeDisabled = args["memory-bridge"] === false || process$1.env.GH_ROUTER_PI_BRIDGE === "0" || process$1.env.GH_ROUTER_DISABLE_PI_BRIDGE === "1";
|
|
1603
|
+
let bridgeStats;
|
|
1604
|
+
let bridgeScoped = [];
|
|
1605
|
+
if (!bridgeDisabled) {
|
|
1606
|
+
const passthrough = collectPiPassthroughArgs(rawArgs, piArgs);
|
|
1607
|
+
if (!(passthrough.includes("--no-context-files") || passthrough.includes("-nc"))) try {
|
|
1608
|
+
const { collectBridgeInputs } = await import("./pi-memory-bridge-BWZJnjpz.js");
|
|
1609
|
+
const collected = await collectBridgeInputs(process$1.cwd());
|
|
1610
|
+
bridgeStats = {
|
|
1611
|
+
staticFiles: collected.copilotInstructions.length + collected.unscopedRules.length + collected.userGlobal.length,
|
|
1612
|
+
scopedRules: collected.scopedRules.length,
|
|
1613
|
+
imports: collected.imports.length,
|
|
1614
|
+
skipped: collected.skipped.length
|
|
1615
|
+
};
|
|
1616
|
+
bridgeScoped = collected.scopedRules;
|
|
1617
|
+
globalThis.__ghRouterBridgeCollected = collected;
|
|
1618
|
+
} catch (err) {
|
|
1619
|
+
consola.debug("Pi memory bridge collection skipped:", err);
|
|
1620
|
+
}
|
|
1621
|
+
}
|
|
1480
1622
|
await writeTextFile(path.join(mirror, "extensions", "gh-router-pi", "index.ts"), buildPiExtensionSource({
|
|
1481
1623
|
profileId,
|
|
1482
1624
|
searchEnabled,
|
|
1483
1625
|
browseEnabled,
|
|
1484
|
-
peers: peersEnabled
|
|
1626
|
+
peers: peersEnabled,
|
|
1627
|
+
bridge: bridgeStats ? {
|
|
1628
|
+
stats: bridgeStats,
|
|
1629
|
+
scopedRules: bridgeScoped
|
|
1630
|
+
} : void 0
|
|
1485
1631
|
}));
|
|
1486
1632
|
if (peersEnabled) {
|
|
1487
1633
|
const agentFiles = buildPiAgentFiles(profileId);
|
|
@@ -1498,6 +1644,31 @@ const pi = defineCommand({
|
|
|
1498
1644
|
swe: sweEnabled
|
|
1499
1645
|
})) await writeTextFile(path.join(mirror, "prompts", `${prompt.name}.md`), prompt.content);
|
|
1500
1646
|
await writeTextFile(path.join(mirror, "APPEND_SYSTEM.md"), buildPiAppendSystem(profileId, { peers: peersEnabled }));
|
|
1647
|
+
try {
|
|
1648
|
+
const collected = globalThis.__ghRouterBridgeCollected;
|
|
1649
|
+
if (collected) {
|
|
1650
|
+
const { buildMirrorBridgeSection, mergeBridgeIntoAgentsMd } = await import("./pi-memory-bridge-BWZJnjpz.js");
|
|
1651
|
+
const { section } = buildMirrorBridgeSection(collected, { repoRoot: process$1.cwd() });
|
|
1652
|
+
const agentsPath = path.join(mirror, "AGENTS.md");
|
|
1653
|
+
let existing;
|
|
1654
|
+
try {
|
|
1655
|
+
existing = await fs.readFile(agentsPath, "utf8");
|
|
1656
|
+
} catch {
|
|
1657
|
+
existing = void 0;
|
|
1658
|
+
}
|
|
1659
|
+
await writeTextFile(agentsPath, mergeBridgeIntoAgentsMd(existing, section));
|
|
1660
|
+
await writeJsonFile(path.join(mirror, ".gh-router-bridge.json"), {
|
|
1661
|
+
stats: bridgeStats ?? null,
|
|
1662
|
+
scopedRuleFiles: bridgeScoped.map((r) => r.file)
|
|
1663
|
+
});
|
|
1664
|
+
}
|
|
1665
|
+
} catch (err) {
|
|
1666
|
+
consola.debug("Pi memory bridge synthesis skipped:", err);
|
|
1667
|
+
} finally {
|
|
1668
|
+
try {
|
|
1669
|
+
delete globalThis.__ghRouterBridgeCollected;
|
|
1670
|
+
} catch {}
|
|
1671
|
+
}
|
|
1501
1672
|
} catch (err) {
|
|
1502
1673
|
consola.error(`Failed to write Pi launch files: ${err instanceof Error ? err.message : String(err)}.`);
|
|
1503
1674
|
process$1.exit(1);
|
|
@@ -1565,4 +1736,4 @@ const pi = defineCommand({
|
|
|
1565
1736
|
//#endregion
|
|
1566
1737
|
export { pi };
|
|
1567
1738
|
|
|
1568
|
-
//# sourceMappingURL=pi-
|
|
1739
|
+
//# sourceMappingURL=pi-WT6IahMr.js.map
|