github-router 0.3.348 → 0.3.349

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.
Files changed (44) hide show
  1. package/dist/{aic-statusline-settings-YoDG20pq.js → aic-statusline-settings-DCFywz3N.js} +2 -2
  2. package/dist/aic-statusline-settings-DCFywz3N.js.map +1 -0
  3. package/dist/{attribution-settings-P_vba-ri.js → attribution-settings-BgYkynRc.js} +14 -12
  4. package/dist/{attribution-settings-P_vba-ri.js.map → attribution-settings-BgYkynRc.js.map} +1 -1
  5. package/dist/browser-ext/manifest.json +1 -1
  6. package/dist/{claude-D26fp1ih.js → claude-Chtd07VA.js} +25 -10
  7. package/dist/{claude-D26fp1ih.js.map → claude-Chtd07VA.js.map} +1 -1
  8. package/dist/{codex-DM97sCtu.js → codex-DayPQ8t5.js} +4 -4
  9. package/dist/{codex-DM97sCtu.js.map → codex-DayPQ8t5.js.map} +1 -1
  10. package/dist/engine-T81FYVwK.js +2 -0
  11. package/dist/{gate-discovery-V-mslLHt.js → gate-discovery-CBOPoK9-.js} +2 -2
  12. package/dist/{gate-discovery-V-mslLHt.js.map → gate-discovery-CBOPoK9-.js.map} +1 -1
  13. package/dist/hooks.mjs +472 -49
  14. package/dist/hooks.sha256 +1 -1
  15. package/dist/{internal-aic-status-CCvU7zhC.js → internal-aic-status-lM0YNDaH.js} +52 -11
  16. package/dist/internal-aic-status-lM0YNDaH.js.map +1 -0
  17. package/dist/internal-prompt-submit-DRCJ5kWC.js +559 -0
  18. package/dist/internal-prompt-submit-DRCJ5kWC.js.map +1 -0
  19. package/dist/{internal-stop-hook-v5WF6Kc2.js → internal-stop-hook-CIe2kVss.js} +2 -2
  20. package/dist/{internal-stop-hook-v5WF6Kc2.js.map → internal-stop-hook-CIe2kVss.js.map} +1 -1
  21. package/dist/main.js +8 -8
  22. package/dist/{peer-mcp-personas-C200IycG.js → peer-mcp-personas-agpBeTgS.js} +233 -61
  23. package/dist/peer-mcp-personas-agpBeTgS.js.map +1 -0
  24. package/dist/{pi-BWGfNpi7.js → pi-BLDBFXg3.js} +5 -5
  25. package/dist/{pi-BWGfNpi7.js.map → pi-BLDBFXg3.js.map} +1 -1
  26. package/dist/{prompt-submit-hook-wjuHUrpS.js → prompt-submit-hook-CBGlhEpU.js} +94 -35
  27. package/dist/prompt-submit-hook-CBGlhEpU.js.map +1 -0
  28. package/dist/{provision-BFTONLfA.js → provision-BKdrO1Sv.js} +2 -2
  29. package/dist/{provision-BFTONLfA.js.map → provision-BKdrO1Sv.js.map} +1 -1
  30. package/dist/{serve-D9xQeGqi.js → serve-p_58sDJK.js} +6 -6
  31. package/dist/{serve-D9xQeGqi.js.map → serve-p_58sDJK.js.map} +1 -1
  32. package/dist/{server-setup-R1HQtpR9.js → server-setup-PAHohZ-u.js} +25 -14
  33. package/dist/server-setup-PAHohZ-u.js.map +1 -0
  34. package/dist/{start-vg2n8UjI.js → start-CTHcqkQL.js} +3 -3
  35. package/dist/{start-vg2n8UjI.js.map → start-CTHcqkQL.js.map} +1 -1
  36. package/package.json +1 -1
  37. package/dist/aic-statusline-settings-YoDG20pq.js.map +0 -1
  38. package/dist/engine-VTQo0qUy.js +0 -2
  39. package/dist/internal-aic-status-CCvU7zhC.js.map +0 -1
  40. package/dist/internal-prompt-submit-B1nd4y4V.js +0 -213
  41. package/dist/internal-prompt-submit-B1nd4y4V.js.map +0 -1
  42. package/dist/peer-mcp-personas-C200IycG.js.map +0 -1
  43. package/dist/prompt-submit-hook-wjuHUrpS.js.map +0 -1
  44. package/dist/server-setup-R1HQtpR9.js.map +0 -1
package/dist/hooks.sha256 CHANGED
@@ -1 +1 @@
1
- 729c327dfa6dd86d73b113a80bab71a0eeaecc3e444a9ef99d0bb8e50ee60ce3
1
+ 70a4755bcd98af2f3bcb7ef8bff5de8cb6cbcf7d5e8ea9ae4c0a5262491564e3
@@ -18,7 +18,16 @@ import { spawnSync } from "node:child_process";
18
18
  * Segment order (left = highest priority; narrow terminals drop from the
19
19
  * right, `AIC` is never dropped):
20
20
  *
21
- * `[AIC] | [ctx bar] % | model | dir (branch) | ~$actual | in/out | dur | +a -r`
21
+ * `[AIC] | [ctx bar] %·window | model | dir (branch) | ~$actual | in/out | dur | +a -r`
22
+ *
23
+ * The `·window` suffix is the session's own context window (`200K`, `272K`,
24
+ * `1M`, `--` when the client does not report one), so a percentage is always
25
+ * readable against a real denominator: the cheap 200K cost classes versus Pi's
26
+ * 272K Copilot Default-tier windows, and a `/model` switch into Claude Code's
27
+ * 1M accounting are visible at a glance. Both clients already report it
28
+ * (`context_window.context_window_size`: Claude Code 2.1.285+ resolves it from
29
+ * the active model, the Pi footer payload forwards `getContextUsage()`'s), so
30
+ * no launch-time plumbing is involved.
22
31
  *
23
32
  * The `$` segment is the DISCOUNTED actual (`~$` = factor-discounted
24
33
  * session total from `copilot-discount.ts`, capped at AIC × $0.01) — NOT
@@ -47,6 +56,9 @@ const CTX_BAR_LEN = 10;
47
56
  const GIT_TIMEOUT_MS = 300;
48
57
  const WIDTH_FALLBACK = 120;
49
58
  const SEP_TEXT = `${DIM} | ${RESET}`;
59
+ /** Joins the ctx percentage to its window (`42%·272K`); dimmed in `text`. */
60
+ const WINDOW_JOINER = "·";
61
+ const UNKNOWN_WINDOW = "--";
50
62
  function asRecord(value) {
51
63
  if (!value || typeof value !== "object" || Array.isArray(value)) return;
52
64
  return value;
@@ -77,6 +89,8 @@ function parseStatusInput(raw) {
77
89
  if (ctx) {
78
90
  const pct = finiteNumber(ctx.used_percentage);
79
91
  if (pct !== void 0) out.usedPct = pct;
92
+ const size = finiteNumber(ctx.context_window_size);
93
+ if (size !== void 0 && size > 0) out.windowSize = Math.floor(size);
80
94
  const tIn = finiteNumber(ctx.total_input_tokens);
81
95
  if (tIn !== void 0 && tIn >= 0) out.totalInputTokens = Math.floor(tIn);
82
96
  const tOut = finiteNumber(ctx.total_output_tokens);
@@ -107,6 +121,18 @@ function compactTokens(n) {
107
121
  if (n >= 1e3) return `${(n / 1e3).toFixed(1)}k`;
108
122
  return `${n}`;
109
123
  }
124
+ /**
125
+ * Context window, compact and exact where it matters: `200000` → `200K`,
126
+ * `272000` → `272K`, `1000000` → `1M`, `1048576` → `1.05M`. Trailing zeros
127
+ * are trimmed so the round client windows stay short. Total: a missing,
128
+ * non-finite, or non-positive size yields `--` rather than a wrong number.
129
+ */
130
+ function formatWindow(tokens) {
131
+ if (tokens === void 0 || !Number.isFinite(tokens) || tokens <= 0) return UNKNOWN_WINDOW;
132
+ if (tokens >= 1e6) return `${String(Number((tokens / 1e6).toFixed(2)))}M`;
133
+ if (tokens >= 1e3) return `${String(Number((tokens / 1e3).toFixed(2)))}K`;
134
+ return `${Math.floor(tokens)}`;
135
+ }
110
136
  /** `45000` → `0m45s`, `198000` → `3m18s`, `3720000` → `1h02m`. */
111
137
  function formatDurationMs(ms) {
112
138
  const totalSeconds = Math.floor(ms / 1e3);
@@ -122,10 +148,18 @@ function dirLeaf(cwd) {
122
148
  const parts = trimmed.split(/[/\\]/);
123
149
  return parts[parts.length - 1] ?? trimmed;
124
150
  }
125
- function buildCtxSegment(usedPct) {
151
+ /**
152
+ * Context segment: `[####------] 42%·200K`. The percentage keeps the
153
+ * green/yellow/red threshold coloring; the window is dimmed so it reads as
154
+ * context, not another metric. Both halves are independently optional —
155
+ * `windowSize` undefined renders `--` (clients that report no window), and
156
+ * `usedPct` undefined keeps the placeholder bar.
157
+ */
158
+ function buildCtxSegment(usedPct, windowSize) {
159
+ const win = formatWindow(windowSize);
126
160
  if (usedPct === void 0 || !Number.isFinite(usedPct)) return {
127
- text: `${DIM}[----------] --%${RESET}`,
128
- plain: "[----------] --%"
161
+ text: `${DIM}[----------] --%${RESET}${DIM}${WINDOW_JOINER}${win}${RESET}`,
162
+ plain: `[----------] --%${WINDOW_JOINER}${win}`
129
163
  };
130
164
  const u = Math.max(0, Math.min(100, Math.round(usedPct)));
131
165
  let filled = Math.round(u / 100 * CTX_BAR_LEN);
@@ -133,8 +167,8 @@ function buildCtxSegment(usedPct) {
133
167
  if (filled < 0) filled = 0;
134
168
  const bar = `#`.repeat(filled) + `-`.repeat(CTX_BAR_LEN - filled);
135
169
  return {
136
- text: `${u < 50 ? GREEN : u < 75 ? YELLOW : RED}[${bar}] ${u}%${RESET}`,
137
- plain: `[${bar}] ${u}%`
170
+ text: `${u < 50 ? GREEN : u < 75 ? YELLOW : RED}[${bar}] ${u}%${RESET}${DIM}${WINDOW_JOINER}${win}${RESET}`,
171
+ plain: `[${bar}] ${u}%${WINDOW_JOINER}${win}`
138
172
  };
139
173
  }
140
174
  /**
@@ -264,13 +298,15 @@ function terminalWidth(env = process.env) {
264
298
  * PINNED — it renders even when nothing else fits. `actualUsd` feeds the
265
299
  * `~$` segment (the capped factor-discounted total from
266
300
  * `discountedUsdForSnapshot`, same snapshot the fragment came from).
267
- * Droppable segments in priority order: ctx, model, dir/git, ~$, toks,
268
- * dur, lines.
301
+ * Droppable segments in priority order: ctx (`%·window`), model, dir/git,
302
+ * ~$, toks, dur, lines. The window rides inside the ctx segment rather than
303
+ * taking its own slot, so the added width is ~6 columns instead of a whole
304
+ * ` | 200K` group.
269
305
  */
270
306
  function assembleStatusLine(aicFragment, input, opts = {}) {
271
307
  const aic = aicFragment.trim();
272
308
  const aicText = aic ? `${AIC_COLOR}${aic}${RESET}` : "";
273
- const droppable = [buildCtxSegment(input.usedPct)];
309
+ const droppable = [buildCtxSegment(input.usedPct, input.windowSize)];
274
310
  const model = buildModelSegment(input.modelName);
275
311
  if (model) droppable.push(model);
276
312
  const dirGit = buildDirGitSegment(input.cwd, opts.branch);
@@ -323,8 +359,13 @@ function buildRichStatusLine(stdinRaw, aicFragment, opts = {}) {
323
359
  *
324
360
  * Default-on rich status line: Claude Code's stdin JSON is rendered natively
325
361
  * (see `src/lib/default-statusline.ts`) as
326
- * `[ctx bar] % | model | dir (branch) | ~$actual | in/out | dur | +a -r`,
362
+ * `[ctx bar] %·window | model | dir (branch) | ~$actual | in/out | dur | +a -r`,
327
363
  * with this launch's AIC ledger total PINNED ahead of it: `[AIC 12.42] ...`.
364
+ * The `%·window` half is the session's own context window (`200K` for the
365
+ * cheap Claude profiles, `272K` on Pi's Copilot Default-tier rows, `1M` after
366
+ * a `/model` switch into Claude Code's 1M accounting, `--` when a client
367
+ * reports none) — both clients ship it in
368
+ * `context_window.context_window_size`, so the denominator is never guessed.
328
369
  * The `~$` segment is the factor-discounted actual (per-model static
329
370
  * factors over ledger nano, capped at AIC × $0.01 — see
330
371
  * `src/lib/copilot-discount.ts`), not Claude's list-price `total_cost_usd`.
@@ -440,4 +481,4 @@ const internalAicStatus = defineCommand({
440
481
  //#endregion
441
482
  export { internalAicStatus };
442
483
 
443
- //# sourceMappingURL=internal-aic-status-CCvU7zhC.js.map
484
+ //# sourceMappingURL=internal-aic-status-lM0YNDaH.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"internal-aic-status-lM0YNDaH.js","names":[],"sources":["../src/lib/default-statusline.ts","../src/internal-aic-status.ts"],"sourcesContent":["/**\n * Rich default status line for `github-router claude` sessions.\n *\n * Replaces the need for users to maintain their own PowerShell/bash status\n * script: `internal-aic-status` renders these segments natively from the\n * Claude Code stdin JSON, then pins the `[AIC x.xx]` ledger fragment ahead\n * of them. Zero dependencies, cross-platform (Windows 11 is the primary\n * target — no `powershell`/`bash`/`jq` required), and fast (no shell\n * startup; one bounded `git rev-parse` at most).\n *\n * Segment order (left = highest priority; narrow terminals drop from the\n * right, `AIC` is never dropped):\n *\n * `[AIC] | [ctx bar] %·window | model | dir (branch) | ~$actual | in/out | dur | +a -r`\n *\n * The `·window` suffix is the session's own context window (`200K`, `272K`,\n * `1M`, `--` when the client does not report one), so a percentage is always\n * readable against a real denominator: the cheap 200K cost classes versus Pi's\n * 272K Copilot Default-tier windows, and a `/model` switch into Claude Code's\n * 1M accounting are visible at a glance. Both clients already report it\n * (`context_window.context_window_size`: Claude Code 2.1.285+ resolves it from\n * the active model, the Pi footer payload forwards `getContextUsage()`'s), so\n * no launch-time plumbing is involved.\n *\n * The `$` segment is the DISCOUNTED actual (`~$` = factor-discounted\n * session total from `copilot-discount.ts`, capped at AIC × $0.01) — NOT\n * Claude's `cost.total_cost_usd`, which prices at Anthropic list rates and\n * reads ~10-100x high against Copilot billing (a 28-day sample: 41.1B tokens\n * for $5,142 ≈ $0.13/1M blended vs $15-75/1M list). Rendering list price\n * next to the real `[AIC]` billing unit would show two contradictory\n * numbers, so list price is deliberately not rendered at all.\n *\n * Width comes from `COLUMNS` (set by Claude Code for status scripts since\n * v2.1.153); fallback is 120 when unset/unparseable so a missing `COLUMNS`\n * never needlessly drops segments.\n */\n\nimport { spawnSync } from \"node:child_process\"\n\nimport { USD_PER_AIC_CREDIT } from \"./copilot-discount\"\nimport {\n buildExecInvocation,\n resolveExecutable,\n} from \"./exec\"\n\nconst ESC = \"\\x1b\"\nconst RESET = `${ESC}[0m`\nconst DIM = `${ESC}[90m`\nconst GREEN = `${ESC}[32m`\nconst YELLOW = `${ESC}[33m`\nconst RED = `${ESC}[31m`\nconst ORANGE = `${ESC}[38;5;208m`\nconst CYAN = `${ESC}[36m`\nconst MAGENTA = `${ESC}[35m`\nconst BLUE = `${ESC}[34m`\nconst AIC_COLOR = `${ESC}[1;33m`\n\nconst CTX_BAR_LEN = 10\nconst GIT_TIMEOUT_MS = 300\nconst WIDTH_FALLBACK = 120\nconst SEP_PLAIN = \" | \"\nconst SEP_TEXT = `${DIM} | ${RESET}`\n/** Joins the ctx percentage to its window (`42%·272K`); dimmed in `text`. */\nconst WINDOW_JOINER = \"·\"\nconst UNKNOWN_WINDOW = \"--\"\n\nexport interface StatusInput {\n usedPct?: number\n /** Session context window in tokens (`200000`, `272000`, `1000000`). */\n windowSize?: number\n totalInputTokens?: number\n totalOutputTokens?: number\n totalDurationMs?: number\n linesAdded?: number\n linesRemoved?: number\n cwd?: string\n modelName?: string\n}\n\nexport interface StatusSegment {\n text: string\n plain: string\n}\n\nfunction asRecord(value: unknown): Record<string, unknown> | undefined {\n if (!value || typeof value !== \"object\" || Array.isArray(value)) {\n return undefined\n }\n return value as Record<string, unknown>\n}\n\nfunction finiteNumber(value: unknown): number | undefined {\n return typeof value === \"number\" && Number.isFinite(value) ? value : undefined\n}\n\nfunction nonEmptyString(value: unknown): string | undefined {\n return typeof value === \"string\" && value.length > 0 ? value : undefined\n}\n\n/**\n * Parse Claude Code's status-line stdin JSON into the fields we render.\n * Total function: malformed JSON or unexpected shapes yield `{}` (every\n * segment then renders its `--` placeholder or is omitted) — never throws.\n */\nexport function parseStatusInput(raw: string): StatusInput {\n if (!raw.trim()) return {}\n let parsed: unknown\n try {\n parsed = JSON.parse(raw) as unknown\n } catch {\n return {}\n }\n const root = asRecord(parsed)\n if (!root) return {}\n const out: StatusInput = {}\n\n const ctx = asRecord(root.context_window)\n if (ctx) {\n const pct = finiteNumber(ctx.used_percentage)\n if (pct !== undefined) out.usedPct = pct\n // The window is the same number the client's own `used_percentage` is\n // measured against (Claude Code resolves it from the active model; the Pi\n // footer forwards `contextUsage.contextWindow`), so it is the honest\n // denominator for the bar. Non-positive/garbage values stay `undefined`\n // and render the `--` placeholder.\n const size = finiteNumber(ctx.context_window_size)\n if (size !== undefined && size > 0) out.windowSize = Math.floor(size)\n const tIn = finiteNumber(ctx.total_input_tokens)\n if (tIn !== undefined && tIn >= 0) out.totalInputTokens = Math.floor(tIn)\n const tOut = finiteNumber(ctx.total_output_tokens)\n if (tOut !== undefined && tOut >= 0) out.totalOutputTokens = Math.floor(tOut)\n }\n\n const cost = asRecord(root.cost)\n if (cost) {\n const dur = finiteNumber(cost.total_duration_ms)\n if (dur !== undefined && dur >= 0) out.totalDurationMs = dur\n const la = finiteNumber(cost.total_lines_added)\n if (la !== undefined && la >= 0) out.linesAdded = Math.floor(la)\n const lr = finiteNumber(cost.total_lines_removed)\n if (lr !== undefined && lr >= 0) out.linesRemoved = Math.floor(lr)\n }\n\n const workspace = asRecord(root.workspace)\n const wsDir = workspace ? nonEmptyString(workspace.current_dir) : undefined\n const cwd = wsDir ?? nonEmptyString(root.cwd)\n if (cwd) out.cwd = cwd\n\n const model = asRecord(root.model)\n if (model) {\n const name =\n nonEmptyString(model.display_name) ?? nonEmptyString(model.id)\n if (name) out.modelName = name\n }\n\n return out\n}\n\n/** Compact token count: `999` → `999`, `15234` → `15.2k`, `2.1M`. */\nexport function compactTokens(n: number): string {\n if (n >= 1_000_000) return `${(n / 1_000_000).toFixed(1)}M`\n if (n >= 1000) return `${(n / 1000).toFixed(1)}k`\n return `${n}`\n}\n\n/**\n * Context window, compact and exact where it matters: `200000` → `200K`,\n * `272000` → `272K`, `1000000` → `1M`, `1048576` → `1.05M`. Trailing zeros\n * are trimmed so the round client windows stay short. Total: a missing,\n * non-finite, or non-positive size yields `--` rather than a wrong number.\n */\nexport function formatWindow(tokens: number | undefined): string {\n if (tokens === undefined || !Number.isFinite(tokens) || tokens <= 0) {\n return UNKNOWN_WINDOW\n }\n if (tokens >= 1_000_000) {\n return `${String(Number((tokens / 1_000_000).toFixed(2)))}M`\n }\n if (tokens >= 1000) {\n return `${String(Number((tokens / 1000).toFixed(2)))}K`\n }\n return `${Math.floor(tokens)}`\n}\n\n/** `45000` → `0m45s`, `198000` → `3m18s`, `3720000` → `1h02m`. */\nexport function formatDurationMs(ms: number): string {\n const totalSeconds = Math.floor(ms / 1000)\n const hours = Math.floor(totalSeconds / 3600)\n const minutes = Math.floor((totalSeconds % 3600) / 60)\n const seconds = totalSeconds % 60\n if (hours >= 1) {\n return `${hours}h${String(minutes).padStart(2, \"0\")}m`\n }\n return `${minutes}m${String(seconds).padStart(2, \"0\")}s`\n}\n\n/** Basename of a cwd, tolerant of `/` and `\\` separators + trailing slash. */\nexport function dirLeaf(cwd: string): string {\n const trimmed = cwd.replace(/[/\\\\]+$/, \"\")\n const parts = trimmed.split(/[/\\\\]/)\n return parts[parts.length - 1] ?? trimmed\n}\n\n/**\n * Context segment: `[####------] 42%·200K`. The percentage keeps the\n * green/yellow/red threshold coloring; the window is dimmed so it reads as\n * context, not another metric. Both halves are independently optional —\n * `windowSize` undefined renders `--` (clients that report no window), and\n * `usedPct` undefined keeps the placeholder bar.\n */\nexport function buildCtxSegment(\n usedPct: number | undefined,\n windowSize?: number,\n): StatusSegment {\n const win = formatWindow(windowSize)\n if (usedPct === undefined || !Number.isFinite(usedPct)) {\n return {\n text: `${DIM}[----------] --%${RESET}${DIM}${WINDOW_JOINER}${win}${RESET}`,\n plain: `[----------] --%${WINDOW_JOINER}${win}`,\n }\n }\n const u = Math.max(0, Math.min(100, Math.round(usedPct)))\n let filled = Math.round((u / 100) * CTX_BAR_LEN)\n if (filled > CTX_BAR_LEN) filled = CTX_BAR_LEN\n if (filled < 0) filled = 0\n const bar = `#`.repeat(filled) + `-`.repeat(CTX_BAR_LEN - filled)\n const color = u < 50 ? GREEN : u < 75 ? YELLOW : RED\n return {\n text:\n `${color}[${bar}] ${u}%${RESET}`\n + `${DIM}${WINDOW_JOINER}${win}${RESET}`,\n plain: `[${bar}] ${u}%${WINDOW_JOINER}${win}`,\n }\n}\n\n/**\n * AIC credits → undiscounted USD. 1 credit ≈ $0.01 — the same convention as\n * the session exit summary (`aic-ledger.ts`). Kept for tests/callers that\n * need the raw conversion; the status line itself shows the\n * factor-discounted total from `copilot-discount.ts`.\n */\nexport function usdFromAicCredits(credits: number): number {\n return credits * USD_PER_AIC_CREDIT\n}\n\n/**\n * Discounted-actual `$` segment. Callers pass the capped total from\n * `discountedUsdForSnapshot` — this function only formats. Placeholder\n * `~$--` until the first priced upstream response lands in the ledger.\n * Thresholds are tuned for ACTUALS scale (a session runs ~$0.10-2.00) —\n * not the old list-price scale.\n */\nexport function buildUsdSegment(\n actualUsd: number | undefined,\n): StatusSegment {\n if (actualUsd === undefined || !Number.isFinite(actualUsd) || actualUsd < 0) {\n return { text: `${DIM}~$--${RESET}`, plain: \"~$--\" }\n }\n const c = actualUsd\n const color = c < 1 ? GREEN : c < 5 ? YELLOW : c < 20 ? ORANGE : RED\n const formatted = c < 10 ? c.toFixed(2) : c.toFixed(1)\n return {\n text: `${color}~$${formatted}${RESET}`,\n plain: `~$${formatted}`,\n }\n}\n\nexport function buildToksSegment(\n tIn: number | undefined,\n tOut: number | undefined,\n): StatusSegment {\n if (tIn === undefined || tOut === undefined) {\n return { text: `${DIM}--/--${RESET}`, plain: \"--/--\" }\n }\n const cin = compactTokens(tIn)\n const cout = compactTokens(tOut)\n return {\n text: `${CYAN}${cin}${RESET}${DIM}/${RESET}${MAGENTA}${cout}${RESET}`,\n plain: `${cin}/${cout}`,\n }\n}\n\nexport function buildDurSegment(durMs: number | undefined): StatusSegment {\n if (durMs === undefined || !Number.isFinite(durMs) || durMs < 0) {\n return { text: `${DIM}--${RESET}`, plain: \"--\" }\n }\n const formatted = formatDurationMs(durMs)\n return { text: `${DIM}${formatted}${RESET}`, plain: formatted }\n}\n\nexport function buildLinesSegment(\n added: number | undefined,\n removed: number | undefined,\n): StatusSegment {\n const a = added ?? 0\n const r = removed ?? 0\n return {\n text: `${GREEN}+${a}${RESET} ${RED}-${r}${RESET}`,\n plain: `+${a} -${r}`,\n }\n}\n\nexport function buildModelSegment(\n modelName: string | undefined,\n): StatusSegment | undefined {\n if (!modelName || modelName === \"--\") return undefined\n return {\n text: `${MAGENTA}${modelName}${RESET}`,\n plain: modelName,\n }\n}\n\nexport function buildDirGitSegment(\n cwd: string | undefined,\n branch: string | undefined,\n): StatusSegment | undefined {\n const leaf = cwd ? dirLeaf(cwd) : \"\"\n const br = branch && branch !== \"HEAD\" ? branch : \"\"\n if (!leaf && !br) return undefined\n if (leaf && br) {\n return {\n text: `${BLUE}${leaf}${RESET} ${CYAN}(${br})${RESET}`,\n plain: `${leaf} (${br})`,\n }\n }\n if (leaf) {\n return { text: `${BLUE}${leaf}${RESET}`, plain: leaf }\n }\n return { text: `${CYAN}${br}${RESET}`, plain: br }\n}\n\n/**\n * Resolve the current git branch for `cwd`. Bounded (`GIT_TIMEOUT_MS`) and\n * total: any failure (no git binary, not a repo, detached `HEAD`, timeout,\n * `%` in a Windows path that cmd.exe cannot safely quote) yields `\"\"`\n * (caller omits the branch) — never throws.\n */\nexport function resolveGitBranch(cwd: string | undefined): string {\n try {\n if (!cwd) return \"\"\n const gitPath = resolveExecutable(\"git\")\n if (!gitPath) return \"\"\n const { command, args, shell, windowsVerbatimArguments } =\n buildExecInvocation([\n gitPath,\n \"-C\",\n cwd,\n \"rev-parse\",\n \"--abbrev-ref\",\n \"HEAD\",\n ])\n const result = spawnSync(command, args, {\n shell,\n windowsVerbatimArguments,\n timeout: GIT_TIMEOUT_MS,\n encoding: \"utf8\",\n stdio: [\"ignore\", \"pipe\", \"ignore\"],\n })\n if (result.error) return \"\"\n const out =\n typeof result.stdout === \"string\" ? result.stdout.trim() : \"\"\n if (!out || out === \"HEAD\") return \"\"\n return out.split(\"\\n\")[0]?.trim() ?? \"\"\n } catch {\n return \"\"\n }\n}\n\n/** Terminal width for the drop-right-to-left assembly. */\nexport function terminalWidth(env: NodeJS.ProcessEnv = process.env): number {\n const raw = env.COLUMNS\n if (raw !== undefined) {\n const n = Number(raw)\n if (Number.isInteger(n) && n > 0) return n\n }\n return WIDTH_FALLBACK\n}\n\n/**\n * Assemble the full status line. `aicFragment` (e.g. `[AIC 12.42]`) is\n * PINNED — it renders even when nothing else fits. `actualUsd` feeds the\n * `~$` segment (the capped factor-discounted total from\n * `discountedUsdForSnapshot`, same snapshot the fragment came from).\n * Droppable segments in priority order: ctx (`%·window`), model, dir/git,\n * ~$, toks, dur, lines. The window rides inside the ctx segment rather than\n * taking its own slot, so the added width is ~6 columns instead of a whole\n * ` | 200K` group.\n */\nexport function assembleStatusLine(\n aicFragment: string,\n input: StatusInput,\n opts: { width?: number; branch?: string; actualUsd?: number } = {},\n): string {\n const aic = aicFragment.trim()\n const aicText = aic ? `${AIC_COLOR}${aic}${RESET}` : \"\"\n\n const droppable: Array<StatusSegment> = [\n buildCtxSegment(input.usedPct, input.windowSize),\n ]\n const model = buildModelSegment(input.modelName)\n if (model) droppable.push(model)\n // Location context sits right after ctx/model: more useful than the\n // numbers when the bar is wide, still dropped before ctx/model.\n const dirGit = buildDirGitSegment(input.cwd, opts.branch)\n if (dirGit) droppable.push(dirGit)\n droppable.push(\n buildUsdSegment(opts.actualUsd),\n buildToksSegment(input.totalInputTokens, input.totalOutputTokens),\n buildDurSegment(input.totalDurationMs),\n buildLinesSegment(input.linesAdded, input.linesRemoved),\n )\n\n const width = opts.width ?? terminalWidth()\n const sepLen = SEP_PLAIN.length\n\n // Drop from the end (lowest priority) until the line fits. AIC is pinned:\n // it is excluded from the dropping loop entirely.\n let count = droppable.length\n while (count > 0) {\n let total = aic ? aic.length : 0\n for (let i = 0; i < count; i++) {\n if (aic || i > 0) total += sepLen\n total += droppable[i].plain.length\n }\n if (total <= width) break\n // Never drop the last segment when there is no AIC: an over-wide line\n // with real data beats an empty status line.\n if (count === 1 && !aic) break\n count--\n }\n\n const parts: Array<string> = []\n if (aic) parts.push(aicText)\n for (let i = 0; i < count; i++) parts.push(droppable[i].text)\n if (parts.length === 0) return \"\"\n return parts.join(SEP_TEXT)\n}\n\n/**\n * Convenience: parse stdin JSON + assemble with branch resolution.\n * `branchOverride` skips the `git` spawn (used by tests). `actualUsd`\n * comes from `discountedUsdForSnapshot` on the same ledger snapshot as\n * `aicFragment` (read by the caller — this module never touches the\n * ledger file).\n */\nexport function buildRichStatusLine(\n stdinRaw: string,\n aicFragment: string,\n opts: { width?: number; branchOverride?: string; actualUsd?: number } = {},\n): string {\n const input = parseStatusInput(stdinRaw)\n const branch =\n opts.branchOverride !== undefined\n ? opts.branchOverride\n : resolveGitBranch(input.cwd)\n return assembleStatusLine(aicFragment, input, {\n ...(opts.width !== undefined ? { width: opts.width } : {}),\n ...(branch ? { branch } : {}),\n ...(opts.actualUsd !== undefined ? { actualUsd: opts.actualUsd } : {}),\n })\n}\n","/**\n * The internal `internal-aic-status` subcommand: the executable a spawned\n * Claude Code session's `statusLine` invokes (registered into the mirrored\n * settings.json by the launcher — see `src/lib/aic-statusline-settings.ts`)\n * AND the Pi footer in the mode's `gh-router-pi` extension invokes (command\n * delivered via `GH_ROUTER_AIC_STATUS_COMMAND`, payload built natively —\n * see `src/lib/pi-statusline.ts`). One runner, identical segments.\n *\n * Default-on rich status line: Claude Code's stdin JSON is rendered natively\n * (see `src/lib/default-statusline.ts`) as\n * `[ctx bar] %·window | model | dir (branch) | ~$actual | in/out | dur | +a -r`,\n * with this launch's AIC ledger total PINNED ahead of it: `[AIC 12.42] ...`.\n * The `%·window` half is the session's own context window (`200K` for the\n * cheap Claude profiles, `272K` on Pi's Copilot Default-tier rows, `1M` after\n * a `/model` switch into Claude Code's 1M accounting, `--` when a client\n * reports none) — both clients ship it in\n * `context_window.context_window_size`, so the denominator is never guessed.\n * The `~$` segment is the factor-discounted actual (per-model static\n * factors over ledger nano, capped at AIC × $0.01 — see\n * `src/lib/copilot-discount.ts`), not Claude's list-price `total_cost_usd`.\n * Narrow terminals drop segments right-to-left; AIC is never dropped.\n *\n * When the user already had a `statusLine` command, its text arrives via\n * `GH_ROUTER_AIC_USER_STATUSLINE` and is run instead of the rich default\n * (their script already renders ctx/cost/model itself — rendering both\n * would duplicate every segment), so the output stays one composed line:\n * `[AIC 12.42] <user line>`.\n *\n * Status-line contract: stdout is the rendered line (first line wins), fast\n * (<1s budget — ledger read is local, git branch has a 300ms cap, the user\n * command gets a 5s cap), and NEVER failing (any error → print whatever is\n * available → exit 0).\n */\n\nimport { defineCommand } from \"citty\"\n\nimport { spawnSync } from \"node:child_process\"\nimport { readFileSync } from \"node:fs\"\n\nimport {\n formatAicStatus,\n readAicSnapshotFile,\n} from \"./lib/aic-ledger\"\nimport { discountedUsdForSnapshot } from \"./lib/copilot-discount\"\nimport { buildRichStatusLine } from \"./lib/default-statusline\"\n\n/**\n * Read stdin synchronously. Claude Code pipes session JSON to the\n * statusLine command; an unread pipe can SIGPIPE the writer on some\n * platforms. Returns \"\" when stdin is a TTY or unreadable — callers render\n * placeholders/omit segments rather than failing.\n */\nfunction readStdin(): string {\n try {\n if (process.stdin.isTTY) return \"\"\n return readFileSync(0, \"utf8\")\n } catch {\n // Best-effort; the ledger read below does not depend on stdin.\n return \"\"\n }\n}\n\n/**\n * Pure core: compose the status line from an AIC fragment and a user line.\n * Exported for unit tests.\n */\nexport function composeAicStatusLine(\n aicFragment: string,\n userLine: string,\n): string {\n const aic = aicFragment.trim()\n const user = userLine.split(\"\\n\")[0]?.trim() ?? \"\"\n if (aic && user) return `${aic} ${user}`\n return aic || user\n}\n\n/**\n * Run the user's own statusLine command (from `GH_ROUTER_AIC_USER_STATUSLINE`),\n * returning its first stdout line or \"\" on any failure/timeout. Exported for\n * unit tests (command + timeout injectable).\n *\n * Claude Code pipes session JSON to the statusLine command's stdin, and\n * user scripts commonly block reading it to EOF — so the received\n * `stdinRaw` is forwarded via `input` (written then closed) rather than\n * leaving stdin disconnected, which would hang such scripts until the\n * timeout and silently drop their segment.\n */\nexport function runUserStatusLine(\n command: string,\n stdinRaw: string,\n timeoutMs = 5000,\n): string {\n if (!command.trim()) return \"\"\n try {\n const result = spawnSync(command, {\n shell: true,\n timeout: timeoutMs,\n encoding: \"utf8\",\n input: stdinRaw,\n stdio: [\"pipe\", \"pipe\", \"ignore\"],\n // Inherit env so user scripts see the same session context they would\n // under their own statusLine (cwd included — spawnSync inherits it).\n env: process.env,\n })\n if (result.error) return \"\"\n const out = typeof result.stdout === \"string\" ? result.stdout : \"\"\n return out.split(\"\\n\")[0]?.trim() ?? \"\"\n } catch {\n return \"\"\n }\n}\n\nfunction readAicSnapshot(): { fragment: string; actualUsd?: number } {\n try {\n const ledgerPath = process.env.GH_ROUTER_AIC_LEDGER\n if (!ledgerPath) return { fragment: \"\" }\n const snapshot = readAicSnapshotFile(ledgerPath)\n if (!snapshot) return { fragment: \"\" }\n // No priced responses yet → no fragment AND no USD: the `~$`\n // segment renders its `~$--` placeholder instead of `~$0.00`.\n if (snapshot.requests === 0 || snapshot.totalNanoAiu <= 0) {\n return { fragment: \"\" }\n }\n return {\n fragment: formatAicStatus(snapshot),\n actualUsd: discountedUsdForSnapshot(snapshot).total,\n }\n } catch {\n return { fragment: \"\" }\n }\n}\n\nexport const internalAicStatus = defineCommand({\n meta: {\n name: \"internal-aic-status\",\n description:\n \"Internal: Claude Code statusLine handler printing AIC total + rich session line.\",\n },\n async run() {\n const stdinRaw = readStdin()\n const { fragment: aic, actualUsd } = readAicSnapshot()\n const userCommand = process.env.GH_ROUTER_AIC_USER_STATUSLINE ?? \"\"\n // Wrap mode: the user's own script already renders ctx/cost/model from\n // the same stdin JSON — run it and prepend AIC only.\n if (userCommand.trim()) {\n const userLine = runUserStatusLine(userCommand, stdinRaw)\n const line = composeAicStatusLine(aic, userLine)\n if (line) process.stdout.write(`${line}\\n`)\n process.exitCode = 0\n return\n }\n // Default mode: native rich line with AIC pinned ahead of it. The\n // builder never throws; an empty result (no ledger yet AND no stdin)\n // prints nothing rather than a placeholder line.\n let line: string\n try {\n line = buildRichStatusLine(stdinRaw, aic, {\n ...(actualUsd !== undefined ? { actualUsd } : {}),\n })\n } catch {\n line = aic.trim()\n }\n if (line) process.stdout.write(`${line}\\n`)\n // Signal success WITHOUT tearing the loop down — same resolution as the\n // other internal hooks (see main.ts help-path comment): a hard\n // process.exit() can abort through a pipe on Windows.\n process.exitCode = 0\n },\n})\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6CA,MAAM,MAAM;AACZ,MAAM,QAAQ,GAAG,IAAI;AACrB,MAAM,MAAM,GAAG,IAAI;AACnB,MAAM,QAAQ,GAAG,IAAI;AACrB,MAAM,SAAS,GAAG,IAAI;AACtB,MAAM,MAAM,GAAG,IAAI;AACnB,MAAM,SAAS,GAAG,IAAI;AACtB,MAAM,OAAO,GAAG,IAAI;AACpB,MAAM,UAAU,GAAG,IAAI;AACvB,MAAM,OAAO,GAAG,IAAI;AACpB,MAAM,YAAY,GAAG,IAAI;AAEzB,MAAM,cAAc;AACpB,MAAM,iBA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