github-router 0.3.342 → 0.3.343
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-DA3wkQHE.js → attribution-settings-DJEBjfJQ.js} +2 -2
- package/dist/{attribution-settings-DA3wkQHE.js.map → attribution-settings-DJEBjfJQ.js.map} +1 -1
- package/dist/browser-ext/manifest.json +1 -1
- package/dist/{claude-CMuHUWWy.js → claude-DJeYKVL2.js} +3 -3
- package/dist/{claude-CMuHUWWy.js.map → claude-DJeYKVL2.js.map} +1 -1
- package/dist/{codex-B__qfHCC.js → codex-cUYAC32x.js} +2 -2
- package/dist/{codex-B__qfHCC.js.map → codex-cUYAC32x.js.map} +1 -1
- package/dist/main.js +5 -5
- package/dist/{pi-WT6IahMr.js → pi-CnsdJGF0.js} +184 -49
- package/dist/pi-CnsdJGF0.js.map +1 -0
- package/dist/{pi-memory-bridge-BWZJnjpz.js → pi-memory-bridge-DEU1SUDz.js} +5 -5
- package/dist/{pi-memory-bridge-BWZJnjpz.js.map → pi-memory-bridge-DEU1SUDz.js.map} +1 -1
- package/dist/{serve-BaLMvHSp.js → serve-CwaKseAj.js} +3 -3
- package/dist/{serve-BaLMvHSp.js.map → serve-CwaKseAj.js.map} +1 -1
- package/dist/{server-setup-B7Usfq5v.js → server-setup-CtzSW7Ms.js} +2 -2
- package/dist/{server-setup-B7Usfq5v.js.map → server-setup-CtzSW7Ms.js.map} +1 -1
- package/dist/{start-C-13_1Ld.js → start-DqfQyqxD.js} +2 -2
- package/dist/{start-C-13_1Ld.js.map → start-DqfQyqxD.js.map} +1 -1
- package/package.json +1 -1
- package/dist/pi-WT6IahMr.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-CtzSW7Ms.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-cUYAC32x.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"codex-
|
|
1
|
+
{"version":3,"file":"codex-cUYAC32x.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-DqfQyqxD.js").then((m) => m.start),
|
|
51
|
+
claude: () => import("./claude-DJeYKVL2.js").then((m) => m.claude),
|
|
52
|
+
codex: () => import("./codex-cUYAC32x.js").then((m) => m.codex),
|
|
53
|
+
pi: () => import("./pi-CnsdJGF0.js").then((m) => m.pi),
|
|
54
|
+
serve: () => import("./serve-CwaKseAj.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-CtzSW7Ms.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";
|
|
@@ -490,10 +490,12 @@ async function ensurePiAgentMirror() {
|
|
|
490
490
|
} catch {
|
|
491
491
|
return mirror;
|
|
492
492
|
}
|
|
493
|
+
const keepUserExtensions = process.env.GH_ROUTER_PI_KEEP_USER_EXTENSIONS === "1";
|
|
493
494
|
const SKIP = /* @__PURE__ */ new Set([
|
|
494
495
|
"auth.json",
|
|
495
496
|
"sessions",
|
|
496
|
-
"models-store.json"
|
|
497
|
+
"models-store.json",
|
|
498
|
+
...keepUserExtensions ? [] : ["extensions"]
|
|
497
499
|
]);
|
|
498
500
|
await Promise.all(entries.filter((e) => !SKIP.has(e)).map(async (entry) => {
|
|
499
501
|
try {
|
|
@@ -787,30 +789,87 @@ function buildPiSettingsJson(opts) {
|
|
|
787
789
|
source: "npm:pi-subagents",
|
|
788
790
|
skills: [],
|
|
789
791
|
prompts: []
|
|
790
|
-
}] : [], "local:gh-router-pi"]
|
|
792
|
+
}] : [], "local:gh-router-pi"],
|
|
793
|
+
...peers ? { subagents: { agentOverrides: {
|
|
794
|
+
scout: { disabled: true },
|
|
795
|
+
worker: { disabled: true },
|
|
796
|
+
researcher: { disabled: true },
|
|
797
|
+
"evidence-auditor": { disabled: true }
|
|
798
|
+
} } } : {}
|
|
791
799
|
};
|
|
792
800
|
}
|
|
793
801
|
function agentFileName(name) {
|
|
794
802
|
return `${name.toLowerCase().replace(/[^a-z0-9]+/g, "-")}.md`;
|
|
795
803
|
}
|
|
804
|
+
/**
|
|
805
|
+
* Deep-merge the `subagents` settings key across the snapshot/user and
|
|
806
|
+
* built layer. Only `agentOverrides` merges (per-agent, user wins);
|
|
807
|
+
* every other `subagents` sub-key follows the standard rule (built wins
|
|
808
|
+
* when present, else user survives). Non-object inputs are ignored so a
|
|
809
|
+
* corrupt user file degrades to built-only instead of crashing launch.
|
|
810
|
+
*/
|
|
811
|
+
function mergeSubagentsSettings(userSubagents, builtSubagents) {
|
|
812
|
+
const user = userSubagents && typeof userSubagents === "object" && !Array.isArray(userSubagents) ? userSubagents : void 0;
|
|
813
|
+
const built = builtSubagents ?? void 0;
|
|
814
|
+
if (!user && !built) return void 0;
|
|
815
|
+
const userOverrides = user?.["agentOverrides"] && typeof user["agentOverrides"] === "object" && !Array.isArray(user["agentOverrides"]) ? user["agentOverrides"] : void 0;
|
|
816
|
+
const builtOverrides = built?.["agentOverrides"];
|
|
817
|
+
const mergedOverrides = userOverrides || builtOverrides ? {
|
|
818
|
+
...builtOverrides,
|
|
819
|
+
...userOverrides
|
|
820
|
+
} : void 0;
|
|
821
|
+
return {
|
|
822
|
+
...user,
|
|
823
|
+
...built,
|
|
824
|
+
...mergedOverrides ? { agentOverrides: mergedOverrides } : {}
|
|
825
|
+
};
|
|
826
|
+
}
|
|
796
827
|
function roleDescription(profileId, role) {
|
|
797
|
-
const oracleNote = "
|
|
798
|
-
if (role.name === "Explore") return
|
|
828
|
+
const oracleNote = "May consult the oracle subagent when a decision feels risky.";
|
|
829
|
+
if (role.name === "Explore") return "Fast read-only recon: locate code, answer evidence questions, return compressed context.";
|
|
799
830
|
if (role.name === "General-Purpose") return profileId === "balanced" ? `General implementation and follow-through on scoped tasks. May hand the result to reviewer only when the change alters behavior. ${oracleNote}` : `General implementation and follow-through on scoped tasks. May hand the result to reviewer for assessment. ${oracleNote}`;
|
|
800
831
|
return profileId === "balanced" ? "Behavior-changing review only: assess a change, narrow scope with search first, delegate targeted discovery to Explore rather than sweeping the repo." : "Code review and assessment, including reproducing and root-causing a failure.";
|
|
801
832
|
}
|
|
802
833
|
/**
|
|
803
834
|
* Build `.md` agent definitions for the mode's native roster, in the
|
|
804
835
|
* OpenCode/pi-subagents-lite frontmatter format Pi delegation tools
|
|
805
|
-
* consume (`name/description/tools/model/thinking
|
|
806
|
-
*
|
|
836
|
+
* consume (`name/description/tools/model/thinking`, plus `allowedAgents`
|
|
837
|
+
* where the delegation graph has an edge). Bodies are
|
|
807
838
|
* short execution contracts; workflow prose lives in skills so agent
|
|
808
839
|
* files stay small enough to inline cheaply.
|
|
840
|
+
*
|
|
841
|
+
* Load-bearing semantics (verified against pi-subagents docs + source):
|
|
842
|
+
* - `reviewer`/`oracle` intentionally SHADOW the same-named builtins
|
|
843
|
+
* wholesale (user scope wins; omitted fields are NOT inherited). That
|
|
844
|
+
* is how the roster pins gh-router models/thinking for cost control.
|
|
845
|
+
* The shadowed `advisor` alias dies with the builtin oracle definition,
|
|
846
|
+
* which is why `advisor` ships as its own file on cheapest.
|
|
847
|
+
* - `allowedAgents` only narrows an existing nesting grant, so every
|
|
848
|
+
* delegating agent also sets `allowNestedSubagents: true` and lists
|
|
849
|
+
* `subagent` in `tools`. Depth reaches 3 on balanced
|
|
850
|
+
* (lead → General-Purpose → reviewer → Explore), covered by
|
|
851
|
+
* `PI_SUBAGENT_MAX_DEPTH=3` in the launch env (default guard is 2).
|
|
852
|
+
* - Deliberately NO `output:`/`defaultReads`/`defaultProgress` file
|
|
853
|
+
* bindings: single-shot launches resolve relative outputs under
|
|
854
|
+
* per-run artifact dirs while `defaultReads` resolves against the
|
|
855
|
+
* child cwd and skips missing files silently — a lead-mediated
|
|
856
|
+
* Explore→General-Purpose file handoff never fires. Handoff is inline
|
|
857
|
+
* prose via the delegating brief instead. `defaultProgress` is doubly
|
|
858
|
+
* out: its default dir is the repo cwd (untracked litter, no cleanup).
|
|
859
|
+
* - `advertise: true` puts custom agents in the parent prompt catalog
|
|
860
|
+
* (default false); `aliases` catch habitual builtin invocations
|
|
861
|
+
* (`scout`, `worker`, …) deterministically since those builtins are
|
|
862
|
+
* disabled in settings.
|
|
863
|
+
* - `inheritProjectContext: true` keeps bridged repo rules (AGENTS.md)
|
|
864
|
+
* visible to children; `defaultContext: fresh` pins the cold-start
|
|
865
|
+
* contract explicitly instead of relying on implicit fallback.
|
|
809
866
|
*/
|
|
810
867
|
function buildPiAgentFiles(profileId) {
|
|
811
868
|
const files = {};
|
|
812
869
|
for (const role of piNativeRoles(profileId)) {
|
|
813
|
-
const
|
|
870
|
+
const isImplementer = role.name === "General-Purpose";
|
|
871
|
+
const isReviewer = role.name === "reviewer";
|
|
872
|
+
const tools = isImplementer ? "[read, grep, find, ls, bash, edit, write, subagent, contact_supervisor]" : isReviewer ? profileId === "balanced" ? "[read, grep, find, ls, watchdog_diff, contact_supervisor, subagent]" : "[read, grep, find, ls, watchdog_diff, contact_supervisor]" : "[read, grep, find, ls, bash]";
|
|
814
873
|
const lines = [
|
|
815
874
|
"---",
|
|
816
875
|
`name: ${role.name}`,
|
|
@@ -818,28 +877,36 @@ function buildPiAgentFiles(profileId) {
|
|
|
818
877
|
`tools: ${tools}`,
|
|
819
878
|
`model: ${PI_PROVIDER_NAME}/${role.model}`,
|
|
820
879
|
`thinking: ${role.thinking}`,
|
|
821
|
-
"
|
|
880
|
+
"advertise: true",
|
|
881
|
+
"systemPromptMode: replace",
|
|
882
|
+
"inheritProjectContext: true",
|
|
883
|
+
"defaultContext: fresh"
|
|
822
884
|
];
|
|
823
|
-
if (
|
|
824
|
-
if (
|
|
885
|
+
if (role.name === "Explore") lines.push("aliases: scout");
|
|
886
|
+
if (isImplementer) lines.push("aliases: worker, developer, coder, implementer, develop", "acceptanceRole: writer", "allowNestedSubagents: true", "allowedAgents: reviewer, oracle");
|
|
887
|
+
if (profileId === "balanced" && isReviewer) lines.push("allowNestedSubagents: true", "allowedAgents: Explore");
|
|
825
888
|
lines.push("---", "");
|
|
826
|
-
if (role.name === "Explore") lines.push("You are a read-only scout. Never modify files. Search first, read second
|
|
827
|
-
else if (
|
|
828
|
-
else lines.push("You
|
|
889
|
+
if (role.name === "Explore") lines.push("You are a read-only scout. Never modify files.", "Use bash only for non-interactive inspection.", "Search first, read second: return the smallest sufficient evidence — entry points,", "key types and functions, data flow, files likely to need changes, constraints and", "open questions — with exact file paths and line ranges.");
|
|
890
|
+
else if (isReviewer) lines.push("You are a disciplined review subagent. Inspect the actual change; verify from code,", "tests, and docs — never guess. Cover intent match, correctness and edge cases,", "test coverage, side effects, and minimality.", "Report findings with file:line evidence ranked P0 (blocker) / P1 (should fix) / P2 (nit),", "ending with one of: Merge verdict: BLOCK, Merge verdict: OK, Merge verdict: OK with notes.", "You have no shell: cite the test commands for the lead to run rather than executing them.", "Do not rewrite code outside small, clearly-marked suggestions.");
|
|
891
|
+
else lines.push("You are the single writer thread. Execute the assigned task with narrow, coherent edits;", "the lead remains the decision authority. Work from the brief's pasted context,", "then implement minimally and verify by running the relevant tests.", "If the work reveals an unapproved decision you cannot safely resolve, stop and escalate", "instead of guessing; never leave placeholders or TODOs.", "Hand behavior-changing results to reviewer when asked; otherwise summarize the diff,", "validation, risks, and next step.");
|
|
829
892
|
files[`agents/${agentFileName(role.name)}`] = `${lines.join("\n")}\n`;
|
|
830
893
|
}
|
|
831
894
|
const oracle = [
|
|
832
895
|
"---",
|
|
833
896
|
"name: oracle",
|
|
834
|
-
|
|
835
|
-
"tools: [read, grep, find, ls]",
|
|
897
|
+
"description: Second opinion before acting. Challenges assumptions without editing. Use when the decision itself feels risky.",
|
|
898
|
+
"tools: [read, grep, find, ls, bash]",
|
|
836
899
|
`model: ${PI_PROVIDER_NAME}/${piOracleModel(profileId)}`,
|
|
837
900
|
`thinking: ${piOracleThinking(profileId)}`,
|
|
838
|
-
"
|
|
901
|
+
"advertise: true",
|
|
902
|
+
"systemPromptMode: replace",
|
|
903
|
+
"inheritProjectContext: true",
|
|
904
|
+
"defaultContext: fresh",
|
|
839
905
|
"---",
|
|
840
906
|
"",
|
|
841
907
|
"You are an oracle: a second set of eyes. You see only the task context",
|
|
842
908
|
"you are given — you have no repo memory beyond what you read now.",
|
|
909
|
+
"Inspect the code yourself with read/grep/find/ls before opining.",
|
|
843
910
|
"Challenge assumptions, name what is missing, recommend; never execute."
|
|
844
911
|
].join("\n");
|
|
845
912
|
files[`agents/${agentFileName("oracle")}`] = `${oracle}\n`;
|
|
@@ -848,11 +915,14 @@ function buildPiAgentFiles(profileId) {
|
|
|
848
915
|
const body = [
|
|
849
916
|
"---",
|
|
850
917
|
"name: advisor",
|
|
851
|
-
|
|
918
|
+
"description: Advisory plan review for the lead: review the final plan before it is presented. Never executes.",
|
|
852
919
|
"tools: [read, grep, find, ls]",
|
|
853
920
|
`model: ${PI_PROVIDER_NAME}/${advisor.model}`,
|
|
854
921
|
`thinking: ${advisor.thinking}`,
|
|
855
|
-
"
|
|
922
|
+
"advertise: true",
|
|
923
|
+
"systemPromptMode: replace",
|
|
924
|
+
"inheritProjectContext: true",
|
|
925
|
+
"defaultContext: fresh",
|
|
856
926
|
"---",
|
|
857
927
|
"",
|
|
858
928
|
"You review the lead's final plan and give advisory feedback only.",
|
|
@@ -1135,8 +1205,8 @@ function buildPiStatuslineFooterSection() {
|
|
|
1135
1205
|
*/
|
|
1136
1206
|
function buildPiMemoryBridgeSection(bridge) {
|
|
1137
1207
|
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,
|
|
1208
|
+
file: r.file.replaceAll("\0", ""),
|
|
1209
|
+
body: (r.body.length > 8e3 ? `${r.body.slice(0, 8e3)}\n…[truncated by gh-router memory bridge]` : r.body).replaceAll("\0", ""),
|
|
1140
1210
|
globs: r.globs,
|
|
1141
1211
|
source: r.source
|
|
1142
1212
|
}));
|
|
@@ -1244,8 +1314,6 @@ function buildPiMemoryBridgeSection(bridge) {
|
|
|
1244
1314
|
function buildPiExtensionSource(opts) {
|
|
1245
1315
|
const peers = opts.peers !== false;
|
|
1246
1316
|
const advisor = peers ? piAdvisorModel(opts.profileId) : void 0;
|
|
1247
|
-
const oracleModel = piOracleModel(opts.profileId);
|
|
1248
|
-
const oracleThinking = piOracleThinking(opts.profileId);
|
|
1249
1317
|
const lines = [];
|
|
1250
1318
|
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 ? [
|
|
1251
1319
|
`const OracleParams = Type.Object({`,
|
|
@@ -1258,20 +1326,65 @@ function buildPiExtensionSource(opts) {
|
|
|
1258
1326
|
` plan: Type.String({ description: "The final plan to review (advisory)" }),`,
|
|
1259
1327
|
` context: Type.Optional(Type.String({ description: "Background context" })),`,
|
|
1260
1328
|
`});`
|
|
1261
|
-
] : [],
|
|
1329
|
+
] : [], ...opts.searchEnabled ? [
|
|
1330
|
+
`const CodeSearchParams = Type.Object({`,
|
|
1331
|
+
` query: Type.String({ description: "What to find" }),`,
|
|
1332
|
+
` mode: Type.Optional(Type.String({ description: "semantic (default), lexical, exact, regex, or ast" })),`,
|
|
1333
|
+
` limit: Type.Optional(Type.Number({ description: "Max results" })),`,
|
|
1334
|
+
` workspace: Type.Optional(Type.String({ description: "Absolute path to the project root to search. Defaults to the launch workspace." })),`,
|
|
1335
|
+
` file_glob: Type.Optional(Type.String({ description: "Optional ripgrep glob filter (e.g. src/**/*.ts)" })),`,
|
|
1336
|
+
`});`
|
|
1337
|
+
] : [], ...opts.browseEnabled ? [
|
|
1338
|
+
`const OpenTabParams = Type.Object({`,
|
|
1339
|
+
` url: Type.String({ description: "URL to load" }),`,
|
|
1340
|
+
` reuseActive: Type.Optional(Type.Boolean({ description: "Navigate the active tab instead of opening a new one" })),`,
|
|
1341
|
+
`});`,
|
|
1342
|
+
`const NavigateParams = Type.Object({`,
|
|
1343
|
+
` tabId: Type.Number({ description: "Tab id from open_tab" }),`,
|
|
1344
|
+
` action: Type.String({ description: "goto, back, forward, or reload" }),`,
|
|
1345
|
+
` url: Type.Optional(Type.String({ description: "URL for action=goto" })),`,
|
|
1346
|
+
` hard: Type.Optional(Type.Boolean({ description: "Reload only: bypass cache" })),`,
|
|
1347
|
+
`});`,
|
|
1348
|
+
`const ScreenshotParams = Type.Object({`,
|
|
1349
|
+
` tabId: Type.Number({ description: "Tab id from open_tab" }),`,
|
|
1350
|
+
` format: Type.Optional(Type.String({ description: "png or jpeg" })),`,
|
|
1351
|
+
` quality: Type.Optional(Type.Number({ description: "JPEG quality 1-100" })),`,
|
|
1352
|
+
`});`,
|
|
1353
|
+
`const ActParams = Type.Object({`,
|
|
1354
|
+
` tabId: Type.Number({ description: "Tab id from open_tab" }),`,
|
|
1355
|
+
` intent: Type.Optional(Type.String({ description: "Natural-language action (INTENT mode)" })),`,
|
|
1356
|
+
` ref: Type.Optional(Type.String({ description: "Element ref for REF mode" })),`,
|
|
1357
|
+
` action: Type.Optional(Type.String({ description: "REF mode action" })),`,
|
|
1358
|
+
` value: Type.Optional(Type.String({ description: "Value for fill/type/select" })),`,
|
|
1359
|
+
`});`,
|
|
1360
|
+
`const ObserveParams = Type.Object({`,
|
|
1361
|
+
` tabId: Type.Number({ description: "Tab id from open_tab" }),`,
|
|
1362
|
+
` intent: Type.Optional(Type.String({ description: "Focus for the summary" })),`,
|
|
1363
|
+
`});`,
|
|
1364
|
+
`const ExtractParams = Type.Object({`,
|
|
1365
|
+
` tabId: Type.Number({ description: "Tab id from open_tab" }),`,
|
|
1366
|
+
` schema: Type.Any({ description: "JSON schema for the desired output shape" }),`,
|
|
1367
|
+
` instruction: Type.String({ description: "What to extract" }),`,
|
|
1368
|
+
`});`
|
|
1369
|
+
] : [], `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 ? [
|
|
1262
1370
|
` pi.registerTool({`,
|
|
1263
1371
|
` name: "oracle",`,
|
|
1264
1372
|
` label: "Oracle",`,
|
|
1265
1373
|
` description: "Second opinion before acting on a risky decision. Advisory only: challenges assumptions, never edits. Pass decision, options, and context.",`,
|
|
1266
1374
|
` parameters: OracleParams,`,
|
|
1267
1375
|
` async execute(_toolCallId, params, signal) {`,
|
|
1268
|
-
`
|
|
1376
|
+
` const query = stripNul(params.decision || "").trim();`,
|
|
1377
|
+
` const opts = stripNul(params.options || "").trim();`,
|
|
1378
|
+
` const ctx = stripNul(params.context || "").trim();`,
|
|
1379
|
+
` const context = (opts ? "Options considered:\\n" + opts + "\\n\\n" : "") + ctx;`,
|
|
1380
|
+
` if (!query || !context.trim()) return toolErrorText("oracle: decision and context are required (non-empty strings)");`,
|
|
1381
|
+
` return await toolText(callMcp("peers", "oracle", { query, context }, signal));`,
|
|
1269
1382
|
` },`,
|
|
1270
1383
|
` });`
|
|
1271
1384
|
] : []);
|
|
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) {`, `
|
|
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) {`, `
|
|
1274
|
-
if (opts.browseEnabled) lines.push(` const
|
|
1385
|
+
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));`, ` },`, ` });`);
|
|
1386
|
+
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) {`, ` 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));`, ` },`, ` });`);
|
|
1387
|
+
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));`, ` },`, ` });`);
|
|
1275
1388
|
if (opts.bridge && opts.bridge.scopedRules.length + opts.bridge.stats.staticFiles > 0) lines.push(...buildPiMemoryBridgeSection(opts.bridge));
|
|
1276
1389
|
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;`, ` }`, ` });`, `}`, ``);
|
|
1277
1390
|
return `${lines.join("\n")}\n`;
|
|
@@ -1280,8 +1393,9 @@ function buildPiExtensionSource(opts) {
|
|
|
1280
1393
|
* Workflow guidance as skills (progressive disclosure, not tools).
|
|
1281
1394
|
* Ownership mirrors the Claude launcher: peer consult prose rides
|
|
1282
1395
|
* `--peers`, semantic-search prose rides `--search`, and the
|
|
1283
|
-
* delegation/review pipeline rides `--swe
|
|
1284
|
-
*
|
|
1396
|
+
* delegation/review pipeline rides `--swe` AND `--peers` — without
|
|
1397
|
+
* agents + the subagent provider its prose dangles, so peerless+swe
|
|
1398
|
+
* emits none. A bare launch emits NO skills at all.
|
|
1285
1399
|
*/
|
|
1286
1400
|
function buildPiSkills(opts) {
|
|
1287
1401
|
const peers = opts.peers !== false;
|
|
@@ -1299,7 +1413,9 @@ function buildPiSkills(opts) {
|
|
|
1299
1413
|
"Call the `oracle` tool with the decision, the options considered, and the",
|
|
1300
1414
|
"missing-context gaps. The oracle is cold-start: it sees only what you pass.",
|
|
1301
1415
|
"Its verdict is advisory — verify with tests and code, never substitute votes",
|
|
1302
|
-
"for verification."
|
|
1416
|
+
"for verification. (The `oracle` tool is the one-shot consult; the `oracle`",
|
|
1417
|
+
"subagent is the same role for interactive follow-ups — same name, different",
|
|
1418
|
+
"invocation. Prefer the tool for a single verdict.)"
|
|
1303
1419
|
].join("\n")
|
|
1304
1420
|
});
|
|
1305
1421
|
if (opts.search === true) skills.push({
|
|
@@ -1318,7 +1434,8 @@ function buildPiSkills(opts) {
|
|
|
1318
1434
|
"assuming full coverage."
|
|
1319
1435
|
].join("\n")
|
|
1320
1436
|
});
|
|
1321
|
-
if (opts.swe === true) {
|
|
1437
|
+
if (opts.swe === true && peers) {
|
|
1438
|
+
const consults = opts.profileId === "balanced" ? "`oracle` for consults" : "`oracle`/`advisor` for consults";
|
|
1322
1439
|
skills.push({
|
|
1323
1440
|
dir: "gh-delegate",
|
|
1324
1441
|
content: [
|
|
@@ -1329,9 +1446,14 @@ function buildPiSkills(opts) {
|
|
|
1329
1446
|
"",
|
|
1330
1447
|
"# Delegate",
|
|
1331
1448
|
"",
|
|
1332
|
-
"
|
|
1333
|
-
"
|
|
1334
|
-
|
|
1449
|
+
"You may delegate via the `subagent` tool to this roster only: `Explore`",
|
|
1450
|
+
"for discovery, `General-Purpose` for scoped implementation, `reviewer`",
|
|
1451
|
+
`for verification, ${consults}. (Builtin \`scout\` and`,
|
|
1452
|
+
"`worker` are disabled in this session; their aliases resolve here.)",
|
|
1453
|
+
"Recommended loop: `Explore` to map the code, paste the brief excerpts",
|
|
1454
|
+
"into the `General-Purpose` brief to implement, `reviewer` to check,",
|
|
1455
|
+
"`General-Purpose` to apply feedback. Keep delegated tasks",
|
|
1456
|
+
"scoped with file:line evidence on return.",
|
|
1335
1457
|
opts.profileId === "balanced" ? "Send work to reviewer ONLY when the change alters behavior." : "Send finished work to reviewer for assessment."
|
|
1336
1458
|
].join("\n")
|
|
1337
1459
|
});
|
|
@@ -1355,11 +1477,17 @@ function buildPiSkills(opts) {
|
|
|
1355
1477
|
}
|
|
1356
1478
|
/**
|
|
1357
1479
|
* Saved workflow shortcuts as prompt templates (`/name`). The review
|
|
1358
|
-
* pipeline is SWE-pipeline surface: only `--swe`
|
|
1359
|
-
*
|
|
1480
|
+
* pipeline is SWE-pipeline surface: only `--swe` AND `--peers` emit
|
|
1481
|
+
* prompts (peerless launches have no agents behind them), so a bare
|
|
1482
|
+
* launch advertises none.
|
|
1483
|
+
*
|
|
1484
|
+
* `/parallel-review` intentionally shadows the packaged pi-subagents
|
|
1485
|
+
* prompt of the same name (package prompts are filtered to `[]` in
|
|
1486
|
+
* settings): ours routes to our pinned-model `reviewer`, not the
|
|
1487
|
+
* default-model builtin. `/review` is novel — no packaged collision.
|
|
1360
1488
|
*/
|
|
1361
1489
|
function buildPiPrompts(opts) {
|
|
1362
|
-
if (opts.swe !== true) return [];
|
|
1490
|
+
if (opts.swe !== true || opts.peers === false) return [];
|
|
1363
1491
|
const prompts = [{
|
|
1364
1492
|
name: "review",
|
|
1365
1493
|
content: [
|
|
@@ -1589,15 +1717,18 @@ const pi = defineCommand({
|
|
|
1589
1717
|
} catch {
|
|
1590
1718
|
userSettings = {};
|
|
1591
1719
|
}
|
|
1720
|
+
const builtSettings = buildPiSettingsJson({
|
|
1721
|
+
profileId,
|
|
1722
|
+
searchEnabled,
|
|
1723
|
+
browseEnabled,
|
|
1724
|
+
catalog,
|
|
1725
|
+
peers: peersEnabled
|
|
1726
|
+
});
|
|
1727
|
+
const mergedSubagents = mergeSubagentsSettings(userSettings["subagents"], builtSettings.subagents);
|
|
1592
1728
|
await writeJsonFile(settingsPath, {
|
|
1593
1729
|
...userSettings,
|
|
1594
|
-
...
|
|
1595
|
-
|
|
1596
|
-
searchEnabled,
|
|
1597
|
-
browseEnabled,
|
|
1598
|
-
catalog,
|
|
1599
|
-
peers: peersEnabled
|
|
1600
|
-
})
|
|
1730
|
+
...builtSettings,
|
|
1731
|
+
...mergedSubagents ? { subagents: mergedSubagents } : {}
|
|
1601
1732
|
});
|
|
1602
1733
|
const bridgeDisabled = args["memory-bridge"] === false || process$1.env.GH_ROUTER_PI_BRIDGE === "0" || process$1.env.GH_ROUTER_DISABLE_PI_BRIDGE === "1";
|
|
1603
1734
|
let bridgeStats;
|
|
@@ -1605,7 +1736,7 @@ const pi = defineCommand({
|
|
|
1605
1736
|
if (!bridgeDisabled) {
|
|
1606
1737
|
const passthrough = collectPiPassthroughArgs(rawArgs, piArgs);
|
|
1607
1738
|
if (!(passthrough.includes("--no-context-files") || passthrough.includes("-nc"))) try {
|
|
1608
|
-
const { collectBridgeInputs } = await import("./pi-memory-bridge-
|
|
1739
|
+
const { collectBridgeInputs } = await import("./pi-memory-bridge-DEU1SUDz.js");
|
|
1609
1740
|
const collected = await collectBridgeInputs(process$1.cwd());
|
|
1610
1741
|
bridgeStats = {
|
|
1611
1742
|
staticFiles: collected.copilotInstructions.length + collected.unscopedRules.length + collected.userGlobal.length,
|
|
@@ -1641,13 +1772,14 @@ const pi = defineCommand({
|
|
|
1641
1772
|
})) await writeTextFile(path.join(mirror, "skills", skill.dir, "SKILL.md"), skill.content);
|
|
1642
1773
|
for (const prompt of buildPiPrompts({
|
|
1643
1774
|
profileId,
|
|
1644
|
-
swe: sweEnabled
|
|
1775
|
+
swe: sweEnabled,
|
|
1776
|
+
peers: peersEnabled
|
|
1645
1777
|
})) await writeTextFile(path.join(mirror, "prompts", `${prompt.name}.md`), prompt.content);
|
|
1646
1778
|
await writeTextFile(path.join(mirror, "APPEND_SYSTEM.md"), buildPiAppendSystem(profileId, { peers: peersEnabled }));
|
|
1647
1779
|
try {
|
|
1648
1780
|
const collected = globalThis.__ghRouterBridgeCollected;
|
|
1649
1781
|
if (collected) {
|
|
1650
|
-
const { buildMirrorBridgeSection, mergeBridgeIntoAgentsMd } = await import("./pi-memory-bridge-
|
|
1782
|
+
const { buildMirrorBridgeSection, mergeBridgeIntoAgentsMd } = await import("./pi-memory-bridge-DEU1SUDz.js");
|
|
1651
1783
|
const { section } = buildMirrorBridgeSection(collected, { repoRoot: process$1.cwd() });
|
|
1652
1784
|
const agentsPath = path.join(mirror, "AGENTS.md");
|
|
1653
1785
|
let existing;
|
|
@@ -1712,6 +1844,7 @@ const pi = defineCommand({
|
|
|
1712
1844
|
const modelIds = piProfileModelIds(profileId, { peers: peersEnabled });
|
|
1713
1845
|
const surface = [`peers=${peersEnabled ? "on" : "off"}`, `swe=${sweEnabled ? "on" : "off"}`].join(" ");
|
|
1714
1846
|
process$1.stderr.write(`Server ready on ${serverUrl}, launching Pi (${profileId} lead ${lead}, models ${modelIds.length}, ${surface})...\n`);
|
|
1847
|
+
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");
|
|
1715
1848
|
const { disposeBluebirdClients } = await import("./bluebird-client-bn9Yv6Cb.js");
|
|
1716
1849
|
launchChild({
|
|
1717
1850
|
kind: "pi",
|
|
@@ -1719,6 +1852,8 @@ const pi = defineCommand({
|
|
|
1719
1852
|
...getPiLaunchEnvVars(mirror),
|
|
1720
1853
|
GH_ROUTER_HOOK_MCP_URL: serverUrl,
|
|
1721
1854
|
GH_ROUTER_HOOK_NONCE: nonce,
|
|
1855
|
+
GH_ROUTER_WORKSPACE: process$1.cwd(),
|
|
1856
|
+
PI_SUBAGENT_MAX_DEPTH: "3",
|
|
1722
1857
|
...aicLedgerEnv ? { [AIC_LEDGER_ENV]: aicLedgerEnv } : {},
|
|
1723
1858
|
...aicStatusCommandEnv ? { [PI_STATUS_COMMAND_ENV]: aicStatusCommandEnv } : {}
|
|
1724
1859
|
},
|
|
@@ -1736,4 +1871,4 @@ const pi = defineCommand({
|
|
|
1736
1871
|
//#endregion
|
|
1737
1872
|
export { pi };
|
|
1738
1873
|
|
|
1739
|
-
//# sourceMappingURL=pi-
|
|
1874
|
+
//# sourceMappingURL=pi-CnsdJGF0.js.map
|