github-router 0.3.38 → 0.3.39

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/main.js CHANGED
@@ -464,7 +464,7 @@ function resolveModel(modelId) {
464
464
  const oneMs = models.filter((m) => m.id.includes("opus") && /-1m(?:$|-)/.test(m.id));
465
465
  const versionMatch = lower.match(/opus-(\d+)[.-](\d+)/);
466
466
  const requestedVersion = versionMatch ? `${versionMatch[1]}.${versionMatch[2]}` : void 0;
467
- const oneM = (requestedVersion ? oneMs.find((m) => m.id.includes(`opus-${requestedVersion}-`)) : void 0) ?? oneMs[0];
467
+ const oneM = (requestedVersion ? oneMs.find((m) => m.id.includes(`opus-${requestedVersion}-`)) : void 0) ?? (requestedVersion ? void 0 : oneMs[0]);
468
468
  if (oneM) return oneM.id;
469
469
  }
470
470
  if (lower.includes("codex")) {
@@ -1553,7 +1553,11 @@ function buildExpansionPattern(variants) {
1553
1553
  return "(?:" + variants.join("|") + ")";
1554
1554
  }
1555
1555
  function buildRgArgs(input) {
1556
- const args = ["--json", "--no-follow"];
1556
+ const args = [
1557
+ "--json",
1558
+ "--no-binary",
1559
+ "--no-follow"
1560
+ ];
1557
1561
  if (input.contextLines > 0) args.push(`-C`, String(input.contextLines));
1558
1562
  if (!input.expansionPattern && (input.mode === "literal" || input.mode === "ranked")) args.push("-F");
1559
1563
  if (input.fileGlob && input.fileGlob !== "**/*") args.push("-g", input.fileGlob);
@@ -1596,6 +1600,7 @@ async function parseRgJsonStream(child, opts) {
1596
1600
  cancelled: false,
1597
1601
  stdoutBytes: 0
1598
1602
  };
1603
+ child.stdout.setEncoding("utf8");
1599
1604
  const rl = createInterface({
1600
1605
  input: child.stdout,
1601
1606
  crlfDelay: Infinity
@@ -1615,10 +1620,11 @@ async function parseRgJsonStream(child, opts) {
1615
1620
  killChild(child);
1616
1621
  break;
1617
1622
  }
1618
- if (rawLine.length === 0) continue;
1623
+ const line = rawLine.includes("\0") ? rawLine.replace(/\0/g, "") : rawLine;
1624
+ if (line.length === 0) continue;
1619
1625
  let evt;
1620
1626
  try {
1621
- evt = JSON.parse(rawLine);
1627
+ evt = JSON.parse(line);
1622
1628
  } catch {
1623
1629
  continue;
1624
1630
  }
@@ -9892,7 +9898,7 @@ const PERSONAS_READ = Object.freeze([
9892
9898
  toolNameHttp: "codex_critic",
9893
9899
  model: "gpt-5.5",
9894
9900
  endpoint: "/v1/responses",
9895
- description: "Adversarial second opinion on plans, designs, or code tradeoffs. Backed by gpt-5.5 (OpenAI) — different lab than Opus. Pass artifact verbatim.",
9901
+ description: "Adversarial second opinion on plans, designs, or code tradeoffs. Backed by gpt-5.5 (OpenAI, 400K context) — strongest reasoning model in the critic lineup, different lab than Opus. Best for architecture decisions, design reviews, and tradeoff analysis where cross-lab diversity matters. Not for line-level code review (use codex_reviewer). Pass artifact verbatim.",
9896
9902
  baseInstructions: CRITIC_BASE,
9897
9903
  agentPrompt: "",
9898
9904
  writeCapable: false,
@@ -9910,7 +9916,7 @@ const PERSONAS_READ = Object.freeze([
9910
9916
  toolNameHttp: "gemini_critic",
9911
9917
  model: "gemini-3.1-pro-preview",
9912
9918
  endpoint: "/v1/chat/completions",
9913
- description: "Adversarial second opinion. Backed by gemini-3.1-pro (Google) — third-lab triangulation, strong on long-context and formal reasoning. Pass artifact verbatim.",
9919
+ description: "Adversarial second opinion. Backed by gemini-3.1-pro (Google) — third-lab triangulation, strong on formal reasoning, proofs, and invariants. Useful for cross-checking findings from codex_critic or codex_reviewer when you want a third perspective. Pass artifact verbatim.",
9914
9920
  baseInstructions: GEMINI_CRITIC_BASE,
9915
9921
  agentPrompt: "",
9916
9922
  writeCapable: false,
@@ -9928,7 +9934,7 @@ const PERSONAS_READ = Object.freeze([
9928
9934
  toolNameHttp: "codex_reviewer",
9929
9935
  model: "gpt-5.3-codex",
9930
9936
  endpoint: "/v1/responses",
9931
- description: "Line-level review of a concrete diff or single file. Backed by gpt-5.3-codex (OpenAI) — code-specialist, narrow-scope. Pass artifact verbatim.",
9937
+ description: "Line-level review of a concrete diff or single file. Backed by gpt-5.3-codex (OpenAI, 400K context) — code-specialist, fastest critic (~16s). Surfaces bugs, edge cases, security issues, and idiom violations at specific line numbers. Not suited for architecture or design review (use codex_critic for plans). Pass artifact verbatim.",
9932
9938
  baseInstructions: REVIEWER_BASE,
9933
9939
  agentPrompt: "",
9934
9940
  writeCapable: false,
@@ -9946,7 +9952,7 @@ const PERSONAS_READ = Object.freeze([
9946
9952
  toolNameHttp: "opus_critic",
9947
9953
  model: "claude-opus-4-7",
9948
9954
  endpoint: "/v1/messages",
9949
- description: "Adversarial second opinion from a fresh-context Opus 4.7 — cheap same-lab sanity check. Pass artifact verbatim.",
9955
+ description: "Adversarial second opinion from a fresh-context Opus 4.7 — same lab as the lead, limited blind-spot diversity vs cross-lab critics, but has the largest context window (up to 1M tokens on enterprise tiers). Handles large artifacts without decomposition. Fast (~22s), catches confabulation and motivated reasoning. Pass artifact verbatim.",
9950
9956
  baseInstructions: OPUS_CRITIC_BASE,
9951
9957
  agentPrompt: "",
9952
9958
  writeCapable: false,
@@ -10023,41 +10029,33 @@ function buildAgentPrompt(persona, opts) {
10023
10029
  }
10024
10030
  /**
10025
10031
  * Build the awareness snippet appended to the spawned `claude` session's
10026
- * system prompt via `--append-system-prompt`. Non-prescriptive Claude
10027
- * sees that the peer tools and advisor exist; *when* to invoke is left
10028
- * to Claude's judgment.
10029
- *
10030
- * Trimmed to ~150 tokens by design. The per-tool descriptions are
10031
- * already in Claude's context as MCP tool descriptions (loaded from
10032
- * `tools/list`); the snippet's net-new value is:
10033
- * - the `advisor` mention (built-in, not MCP-discoverable),
10034
- * - the `peer-review-coordinator` fan-out hint,
10035
- * - the "subagents you spawn inherit these" claim (the load-bearing
10036
- * UX payoff of the holistic subagent-MCP-inheritance fix),
10037
- * - the worker-tools "offload to save your context" framing (the
10038
- * per-tool MCP descriptions cover capabilities; the snippet adds
10039
- * the strategic when-to-use signal).
10032
+ * system prompt via `--append-system-prompt`. Descriptive awareness layer
10033
+ * Claude sees what tools exist and their strategic value; *when* to
10034
+ * invoke is left to Claude's judgment informed by each tool's own
10035
+ * `description` field.
10036
+ *
10037
+ * Per Anthropic's guidance for Opus 4.8: tool descriptions carry the
10038
+ * routing signal (when/when-not); the system prompt should describe
10039
+ * capabilities in prose, not encode prescriptive decision trees. Opus 4.8
10040
+ * is responsive enough to overtrigger on aggressive routing language.
10040
10041
  *
10041
10042
  * Surface contract (regression-pinned in tests/peer-mcp-personas.test.ts):
10042
10043
  * - Always lists codex_critic, codex_reviewer, opus_critic, advisor,
10043
10044
  * peer-review-coordinator, and the subagent-inheritance fact.
10044
10045
  * - Conditionally lists gemini_critic only when `geminiAvailable`.
10045
10046
  * - Mentions `codex-cli` stdio bridge only when `codexCli`.
10046
- *
10047
- * The snippet is the awareness layer; the auto-invocation triggers
10048
- * (CALL BEFORE / CALL AFTER) remain in each MCP tool's own `description`.
10049
- * The two layers are intentionally complementary — keep the snippet
10050
- * terse and never re-encode the prescriptive triggers here.
10051
10047
  */
10052
10048
  function buildPeerAwarenessSnippet(opts) {
10053
10049
  const criticList = ["`codex_critic` (gpt-5.5)", "`codex_reviewer` (gpt-5.3-codex)"];
10054
10050
  if (opts.geminiAvailable) criticList.push("`gemini_critic` (gemini-3.1-pro)");
10055
10051
  criticList.push("`opus_critic` (Opus 4.7)");
10056
- const codexCliClause = opts.codexCli ? " The `mcp__codex-cli__codex` stdio bridge dispatches to `codex-implementer` for end-to-end coding tasks." : "";
10052
+ const codexCliClause = opts.codexCli ? " `mcp__codex-cli__codex` dispatches to `codex-implementer` (gpt-5.3-codex with workspace-write) for end-to-end coding tasks." : "";
10057
10053
  return [
10058
10054
  "## Peer review and advisor",
10059
10055
  "",
10060
- `Cross-lab peer critics under \`mcp__gh-router-peers__*\` — ${criticList.join(", ")} — plus the \`peer-review-coordinator\` fan-out subagent, and Claude Code's built-in \`advisor\` tool, are available at your discretion for second opinions and adversarial review. Subagents you spawn inherit them.${codexCliClause} Also \`mcp__gh-router-peers__code_search\` for accurate ranked code discovery (BM25F + tree-sitter) — prefer it over \`Grep\` when finding definitions or call sites. \`worker_explore\` / \`worker_implement\` delegate bounded research or scoped coding tasks (file ops, edits, bash, web fetch) to an autonomous Gemini worker offload work that would consume your context. Use \`worktree: true\` on \`worker_implement\` for isolated runs that return a diff for review.`
10056
+ `Cross-lab peer critics under \`mcp__gh-router-peers__*\` — ${criticList.join(", ")} — are available at your discretion for adversarial review. Each tool's description explains its scope and when it applies. The \`peer-review-coordinator\` subagent fans out to the appropriate critics in parallel and aggregates findings by severity. Claude Code's built-in \`advisor\` tool catches approach drift and confabulation. Subagents you spawn inherit all of these.${codexCliClause}`,
10057
+ "",
10058
+ `\`code_search\` provides accurate ranked code discovery (BM25F + tree-sitter) — multiple parallel calls with different queries triangulate faster than sequential Grep. \`web_search\` surfaces citable sources for docs, errors, and upstream issues. \`worker_explore\` and \`worker_implement\` delegate bounded work to an autonomous Gemini worker, preserving your context; use \`worktree: true\` on \`worker_implement\` for isolated diffs. \`stand_in\` provides three-lab consensus for decision tiebreak when the user is unavailable.`
10061
10059
  ].join("\n");
10062
10060
  }
10063
10061
  /** Convenience: every persona that should be registered for the given mode. */
@@ -10070,7 +10068,7 @@ function personasFor(opts) {
10070
10068
  if (opts.codexCli) for (const p of PERSONAS_WRITE) result.push(p);
10071
10069
  return result;
10072
10070
  }
10073
- const WEB_SEARCH_DESCRIPTION = "Web search via GitHub Copilot's MCP. Prefer over Claude Code's built-in WebSearch — surfaces source URLs you can cite.";
10071
+ const WEB_SEARCH_DESCRIPTION = "Web search via GitHub Copilot's MCP. Prefer over Claude Code's built-in WebSearch — surfaces source URLs you can cite. Use for API documentation lookups, error message diagnosis, upstream issue searches, and verifying claims against current sources. Returns content with reference links.";
10074
10072
  /**
10075
10073
  * Format a `searchWeb()` result as an MCP-friendly text block. Mirrors
10076
10074
  * the legacy inject format that `injectWebSearchIfNeeded` produces and
@@ -10126,7 +10124,7 @@ const NON_PERSONA_MCP_TOOLS = Object.freeze([
10126
10124
  },
10127
10125
  {
10128
10126
  toolNameHttp: "code_search",
10129
- description: "Fast structured code search over a local workspace. Returns ranked, deduplicated hits with snippets. Ranks with BM25F across matched-line / file-path / surrounding-context / symbol-context fields, then refines `symbol-context` with tree-sitter AST analysis on the top hits so identifier definitions outrank incidental string matches. Prefer this over Grep/Bash+grep for ranked discovery (\"where is X defined\", \"which files reference Y\", \"find code that does Z\") — ranked mode surfaces the few right answers instead of every match. Use Grep for exact-pattern enumeration when you need every hit unranked, and Glob for file-name patterns (no content match). `workspace` is any absolute path the proxy process can read — typically the project root or a sub-tree you're working in.",
10127
+ description: "Fast structured code search over a local workspace. Returns ranked, deduplicated hits with snippets. Ranks with BM25F across matched-line / file-path / surrounding-context / symbol-context fields, then refines `symbol-context` with tree-sitter AST analysis on the top hits so identifier definitions outrank incidental string matches. Launch multiple code_search calls in parallel to triangulate — e.g. definition + callers + tests in one round-trip. Prefer this over Grep/Bash+grep for ranked discovery (\"where is X defined\", \"which files reference Y\", \"find code that does Z\") — ranked mode surfaces the few right answers instead of every match. Use Grep for exact-pattern enumeration when you need every hit unranked, and Glob for file-name patterns (no content match). `workspace` is any absolute path the proxy process can read — typically the project root or a sub-tree you're working in.",
10130
10128
  inputSchema: {
10131
10129
  type: "object",
10132
10130
  required: ["query", "workspace"],
@@ -10216,7 +10214,7 @@ const NON_PERSONA_MCP_TOOLS = Object.freeze([
10216
10214
  {
10217
10215
  toolNameHttp: "worker_explore",
10218
10216
  capability: "worker",
10219
- description: "Read-only investigation by an autonomous worker (Gemini via Pi). Tools: read, glob, grep, code_search, web_search, fetch_url, peer_review, advisor. Use it to offload bounded research (\"find files matching X then summarize\", \"how does library Y handle Z\", \"survey this codebase for usages of deprecated API\") that would otherwise eat your context window. The worker plans its own tool calls and returns a single text answer.",
10217
+ description: "Read-only investigation by an autonomous worker (Gemini via Pi). Tools: read, glob, grep, code_search, web_search, fetch_url, peer_review, advisor. Offloads bounded research that would otherwise eat your context window — the worker plans its own tool calls and returns a single text answer. Examples: \"find files matching X then summarize\", \"how does library Y handle Z\", \"survey this codebase for usages of deprecated API\".",
10220
10218
  inputSchema: {
10221
10219
  type: "object",
10222
10220
  required: ["prompt"],
@@ -10615,15 +10613,16 @@ function buildCoordinatorAgent(opts) {
10615
10613
  "",
10616
10614
  "The lead's brief will include an artifact (plan, design, diff, or code) and a goal (e.g. 'review before exit-plan', 'review the commit I just made', 'cross-check codex-critic's verdict'). Pick the right peers for the artifact type:",
10617
10615
  "",
10618
- "- **Plan / design / architecture choice** → fan out to `codex-critic`" + (opts.geminiAvailable ? " AND `gemini-critic` in parallel" : "") + ". codex-reviewer is the wrong tool for plans (it's a code-specialist, not an architecture critic).",
10619
- "- **Concrete diff or single file** → fan out to `codex-reviewer`" + (opts.geminiAvailable ? " AND `gemini-critic` (gemini for cross-lab triangulation)" : "") + ". For very small changes (<20 lines), one `codex-reviewer` call is enough.",
10620
- "- **Tie-breaker after codex-critic has weighed in** → call `gemini-critic`" + (opts.geminiAvailable ? "" : " (NOT REGISTERED in this session gemini-3.x not in catalog; tie-break unavailable)") + " with the artifact AND codex-critic's verdict for cross-lab cross-check.",
10621
- "- **Long-context artifact (>100 KB)** → prefer `gemini-critic`" + (opts.geminiAvailable ? "" : " (NOT REGISTERED in this session)") + ". Otherwise, decompose into 2-4 batches and fan out across `codex-critic` calls in parallel.",
10622
- "- **Fast same-lab sanity check on a moderate artifact (<5 KB)** → prefer `opus-critic` (cheapest, ~22s, only `effort: low|medium` supported). Same lab as the lead limited blind-spot diversification, but a useful gut-check before committing to a controversial decision. For cross-lab diversification or deep dives on larger artifacts, use codex/gemini at higher effort with decomposition for >5KB.",
10616
+ "- **Plan / design / architecture choice** → fan out to `codex-critic` (gpt-5.5, strongest reasoning, cross-lab)" + (opts.geminiAvailable ? " AND `gemini-critic` (third-lab triangulation, strong on formal reasoning) in parallel" : "") + ". codex-reviewer is the wrong tool for plans (it's a code-specialist, not an architecture critic).",
10617
+ "- **Concrete diff or single file** → fan out to `codex-reviewer` (gpt-5.3-codex, line-level code specialist, fastest at ~16s)" + (opts.geminiAvailable ? " AND `gemini-critic` for cross-lab triangulation" : "") + ". For very small changes (<20 lines), one `codex-reviewer` call is enough.",
10618
+ "- **Large artifact (>50 KB)** → prefer `opus-critic` (Opus 4.7, up to 1M context the largest window in the lineup, no decomposition needed for most artifacts). For cross-lab diversity on large artifacts, pair with `codex-critic` and decompose the artifact into 2-4 semantic batches for codex.",
10619
+ "- **Formal reasoning, proofs, or invariants** → prefer `gemini-critic`" + (opts.geminiAvailable ? " (gemini-3.1-pro, strong on math and formally-stated properties)" : " (NOT REGISTERED in this session gemini-3.x not in catalog)") + ".",
10620
+ "- **Tie-breaker after codex-critic has weighed in** → call `gemini-critic`" + (opts.geminiAvailable ? "" : " (NOT REGISTERED in this session)") + " or `opus-critic` with the artifact AND codex-critic's verdict for cross-check.",
10621
+ "- **Fast sanity check** → `opus-critic` (~22s, same lab as lead but fresh context — catches confabulation and motivated reasoning).",
10623
10622
  "",
10624
10623
  "## Decomposition for large artifacts",
10625
10624
  "",
10626
- "Each per-call MCP wait is bounded (~60s SDK default on Claude Code v2.1.113+ per regressions #50289 / #52137 — empirically reproduced 2026-05-14). The proxy enforces per-persona effort allowlists AND a pre-flight `predictedTooLong` cap (codex_critic@high >8 KB, codex_reviewer@high >12 KB, opus_critic@medium >6 KB) to surface would-be-timeouts as fast actionable errors. For artifacts that exceed the cap, split into 2-4 logical batches BY CONCERN (not by raw size — semantic batches give better per-batch reviews) and call peers in parallel. The proxy's MCP cap allows up to 8 in-flight calls. Aggregate findings yourself before reporting back.",
10625
+ "Each per-call MCP wait is bounded (~60s SDK default on Claude Code v2.1.113+ per regressions #50289 / #52137 — empirically reproduced 2026-05-14). The proxy enforces per-persona effort allowlists AND a pre-flight `predictedTooLong` cap (codex_critic@high >8 KB, codex_reviewer@high >12 KB, opus_critic@medium >6 KB) to surface would-be-timeouts as fast actionable errors. For artifacts that exceed the cap but fit within opus-critic's context window (up to 1M tokens when available), route the full artifact to opus-critic. Otherwise, split into 2-4 logical batches BY CONCERN (not by raw size — semantic batches give better per-batch reviews) and call peers in parallel. The proxy's MCP cap allows up to 8 in-flight calls. Aggregate findings yourself before reporting back.",
10627
10626
  "",
10628
10627
  "## Aggregation contract",
10629
10628
  "",
@@ -11121,7 +11120,7 @@ function initProxyFromEnv() {
11121
11120
  //#endregion
11122
11121
  //#region package.json
11123
11122
  var name = "github-router";
11124
- var version = "0.3.38";
11123
+ var version = "0.3.39";
11125
11124
 
11126
11125
  //#endregion
11127
11126
  //#region src/lib/approval.ts