@mrciphersmith/keryx 0.4.24 → 0.4.25

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 (2) hide show
  1. package/dist/cli.js +87 -42
  2. package/package.json +1 -1
package/dist/cli.js CHANGED
@@ -34020,7 +34020,7 @@ var package_default;
34020
34020
  var init_package = __esm(() => {
34021
34021
  package_default = {
34022
34022
  name: "@mrciphersmith/keryx",
34023
- version: "0.4.24",
34023
+ version: "0.4.25",
34024
34024
  description: "Version-controlled project context for AI coding agents: code graph, architecture wiki, project memory, relevant tests, quality signals, and task flows.",
34025
34025
  private: false,
34026
34026
  publishConfig: {
@@ -198972,6 +198972,10 @@ async function createShellChrome(otui, renderer, opts) {
198972
198972
  return Math.max(1, room - 1 >= BUSY_FOOTER_MIN_HINT.length ? room - 1 : room);
198973
198973
  };
198974
198974
  let usageSource;
198975
+ const usageContent = (segments, suffix) => new otui.StyledText([
198976
+ ...segments.map((segment) => segment.role === "muted" ? dimChunk(otui, segment.text) : roleChunk(otui, segment.role, segment.text)),
198977
+ ...suffix !== undefined ? [dimChunk(otui, suffix)] : []
198978
+ ]);
198975
198979
  const paintBusyStatus = () => {
198976
198980
  if (busy && liveStatus !== undefined) {
198977
198981
  const frame = SPINNER[spinIdx % SPINNER.length] ?? "\u280B";
@@ -198985,7 +198989,7 @@ async function createShellChrome(otui, renderer, opts) {
198985
198989
  }
198986
198990
  if (!busy) {
198987
198991
  const usageIdle = usageSource?.();
198988
- footerLeft.content = otui.t`${dimChunk(otui, usageIdle ? `${opts.footerHint} \xB7 ${usageIdle}` : opts.footerHint)}`;
198992
+ footerLeft.content = usageIdle !== undefined ? usageContent(usageIdle) : otui.t`${dimChunk(otui, opts.footerHint)}`;
198989
198993
  footerRight.content = otui.t`${dimChunk(otui, status)}`;
198990
198994
  return;
198991
198995
  }
@@ -198993,7 +198997,7 @@ async function createShellChrome(otui, renderer, opts) {
198993
198997
  const right = perm !== undefined && perm.length > 0 ? `mode ${perm}` : status;
198994
198998
  footerRight.content = otui.t`${dimChunk(otui, right)}`;
198995
198999
  const usageBusy = usageSource?.();
198996
- footerLeft.content = otui.t`${dimChunk(otui, usageBusy ? `${usageBusy} \xB7 ${BUSY_FOOTER_MIN_HINT}` : formatBusyFooter(busyFooterInfo, footerLeftBudget(right)))}`;
199000
+ footerLeft.content = usageBusy !== undefined ? usageContent(usageBusy, ` \xB7 ${BUSY_FOOTER_MIN_HINT}`) : otui.t`${dimChunk(otui, formatBusyFooter(busyFooterInfo, footerLeftBudget(right)))}`;
198997
199001
  };
198998
199002
  const onFooterResized = () => {
198999
199003
  if (busy)
@@ -207641,19 +207645,28 @@ function formatActiveTime(ms) {
207641
207645
  function formatCostUsd(cost) {
207642
207646
  return `$${cost < 0.01 ? cost.toFixed(4) : cost.toFixed(2)}`;
207643
207647
  }
207644
- function totalsPart(t) {
207645
- const parts = [`\u2191${compactTokens(t.tokensIn)} \u2193${compactTokens(t.tokensOut)}`];
207646
- if (t.cacheRead > 0 || t.cacheWrite > 0)
207647
- parts.push(`cache ${compactTokens(t.cacheRead)}/${compactTokens(t.cacheWrite)}`);
207648
+ function totalsSegments(label, t) {
207649
+ const segments = [
207650
+ { role: "muted", text: label },
207651
+ { role: "accent", text: ` \u2191${compactTokens(t.tokensIn)}` },
207652
+ { role: "ok", text: ` \u2193${compactTokens(t.tokensOut)}` }
207653
+ ];
207654
+ if (t.cacheRead > 0 || t.cacheWrite > 0) {
207655
+ segments.push({ role: "muted", text: ` cache ${compactTokens(t.cacheRead)}/${compactTokens(t.cacheWrite)}` });
207656
+ }
207648
207657
  if (t.costUsd !== undefined)
207649
- parts.push(formatCostUsd(t.costUsd));
207650
- parts.push(formatActiveTime(t.activeMs));
207651
- return parts.join(" ");
207658
+ segments.push({ role: "attention", text: ` ${formatCostUsd(t.costUsd)}` });
207659
+ segments.push({ role: "text", text: ` ${formatActiveTime(t.activeMs)}` });
207660
+ return segments;
207652
207661
  }
207653
- function formatUsageFooter(snap) {
207662
+ function usageFooterSegments(snap) {
207654
207663
  if (!snap.turnRunning && snap.turns === 0)
207655
207664
  return;
207656
- return `turn ${totalsPart(snap.turn)} \xB7 session ${totalsPart(snap.session)}`;
207665
+ return [
207666
+ ...totalsSegments("turn", snap.turn),
207667
+ { role: "muted", text: " \xB7 " },
207668
+ ...totalsSegments("session", snap.session)
207669
+ ];
207657
207670
  }
207658
207671
  function formatUsageTable(snap) {
207659
207672
  const cost = (c) => c !== undefined ? formatCostUsd(c) : "n/a";
@@ -207673,6 +207686,42 @@ function formatUsageTable(snap) {
207673
207686
  `);
207674
207687
  }
207675
207688
 
207689
+ // src/tui/turn-usage.ts
207690
+ function installTurnUsageSink(io) {
207691
+ const base = io.onUsage?.bind(io);
207692
+ let current;
207693
+ io.onUsage = (usage) => {
207694
+ base?.(usage);
207695
+ current?.(usage);
207696
+ };
207697
+ return {
207698
+ set: (sink) => {
207699
+ current = sink;
207700
+ },
207701
+ clear: (sink) => {
207702
+ if (current === sink)
207703
+ current = undefined;
207704
+ }
207705
+ };
207706
+ }
207707
+ function createTurnUsage(opts) {
207708
+ const totals = { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 };
207709
+ return {
207710
+ totals,
207711
+ onUsage(usage) {
207712
+ totals.input += usage.inputTokens ?? 0;
207713
+ totals.output += usage.outputTokens ?? 0;
207714
+ totals.cacheRead += usage.cacheReadTokens ?? 0;
207715
+ totals.cacheWrite += usage.cacheWriteTokens ?? 0;
207716
+ const costUsd = opts.cost(totals);
207717
+ const tracker = opts.tracker();
207718
+ tracker.addUsage(usage);
207719
+ tracker.setTurnCost(costUsd);
207720
+ opts.onUpdate?.(totals, costUsd);
207721
+ }
207722
+ };
207723
+ }
207724
+
207676
207725
  // src/tui/usage-tracker.ts
207677
207726
  function createUsageTracker(opts = {}) {
207678
207727
  const now = opts.now ?? Date.now;
@@ -280086,7 +280135,7 @@ async function launchTuiAgentShell(opts) {
280086
280135
  const turnFooter = { tokensIn: 0, tokensOut: 0, costUsd: undefined };
280087
280136
  let usageTracker = createUsageTracker();
280088
280137
  let usageTurnOpen = false;
280089
- chrome.setUsageSource(() => formatUsageFooter(usageTracker.snapshot()));
280138
+ chrome.setUsageSource(() => usageFooterSegments(usageTracker.snapshot()));
280090
280139
  let contextTotal = 0;
280091
280140
  const pushBusyFooter = () => {
280092
280141
  if (!chrome.isBusy())
@@ -280745,6 +280794,7 @@ async function launchTuiAgentShell(opts) {
280745
280794
  lastUsage = usage;
280746
280795
  recordedUsage?.(usage);
280747
280796
  };
280797
+ const turnUsageSlot = installTurnUsageSink(io);
280748
280798
  const blockIo = attachBlockIo(io, addBlock, {
280749
280799
  onReasoningStart: () => {
280750
280800
  setBusyPhase("thinking");
@@ -284638,31 +284688,25 @@ ${formatThemeList(getThemeId())}`);
284638
284688
  }
284639
284689
  prevOnSystem?.(text);
284640
284690
  };
284641
- let turnInputTokens = 0;
284642
- let turnOutputTokens = 0;
284643
- let turnCacheReadTokens = 0;
284644
- let turnCacheWriteTokens = 0;
284645
- const prevOnUsageForCost = io.onUsage;
284646
- io.onUsage = (usage) => {
284647
- turnInputTokens += usage.inputTokens ?? 0;
284648
- turnOutputTokens += usage.outputTokens ?? 0;
284649
- turnCacheReadTokens += usage.cacheReadTokens ?? 0;
284650
- turnCacheWriteTokens += usage.cacheWriteTokens ?? 0;
284651
- turnFooter.tokensIn = turnInputTokens;
284652
- turnFooter.tokensOut = turnOutputTokens;
284653
- turnFooter.costUsd = estimateTurnCostUsd({
284691
+ const turnUsage = createTurnUsage({
284692
+ tracker: () => usageTracker,
284693
+ cost: (t) => estimateTurnCostUsd({
284654
284694
  providerId: deps.providerId,
284655
284695
  modelId: deps.modelId,
284656
- inputTokens: turnInputTokens,
284657
- outputTokens: turnOutputTokens,
284658
- cacheReadTokens: turnCacheReadTokens,
284659
- cacheWriteTokens: turnCacheWriteTokens
284660
- });
284661
- usageTracker.addUsage(usage);
284662
- usageTracker.setTurnCost(turnFooter.costUsd);
284663
- prevOnUsageForCost?.(usage);
284664
- pushBusyFooter();
284665
- };
284696
+ inputTokens: t.input,
284697
+ outputTokens: t.output,
284698
+ cacheReadTokens: t.cacheRead,
284699
+ cacheWriteTokens: t.cacheWrite
284700
+ }),
284701
+ onUpdate: (t, costUsd) => {
284702
+ turnFooter.tokensIn = t.input;
284703
+ turnFooter.tokensOut = t.output;
284704
+ turnFooter.costUsd = costUsd;
284705
+ pushBusyFooter();
284706
+ }
284707
+ });
284708
+ const turnUsageSink = (usage) => turnUsage.onUsage(usage);
284709
+ turnUsageSlot.set(turnUsageSink);
284666
284710
  const suggestNextStep = async () => {
284667
284711
  const { signal, isCurrent } = suggestionGate.start();
284668
284712
  try {
@@ -284865,6 +284909,7 @@ ${line}` : frameSubmittedLine(line) : line;
284865
284909
  ...agentShaped ? { origin: "agent-message" } : origin === "operator" ? {} : { origin },
284866
284910
  ...slateSession !== undefined ? { slateSession, pruneArchive: true } : {}
284867
284911
  })).finally(() => {
284912
+ turnUsageSlot.clear(turnUsageSink);
284868
284913
  const accepted = settleForegroundOperation(foregroundOperation, operation);
284869
284914
  if (!accepted) {
284870
284915
  if (!foregroundOperation.isDisposed)
@@ -284900,10 +284945,10 @@ ${line}` : frameSubmittedLine(line) : line;
284900
284945
  recordTurnTaskCostBestEffort({
284901
284946
  providerId: deps.providerId,
284902
284947
  modelId: deps.modelId,
284903
- inputTokens: turnInputTokens,
284904
- outputTokens: turnOutputTokens,
284905
- ...turnCacheReadTokens > 0 ? { cacheReadTokens: turnCacheReadTokens } : {},
284906
- ...turnCacheWriteTokens > 0 ? { cacheWriteTokens: turnCacheWriteTokens } : {},
284948
+ inputTokens: turnUsage.totals.input,
284949
+ outputTokens: turnUsage.totals.output,
284950
+ ...turnUsage.totals.cacheRead > 0 ? { cacheReadTokens: turnUsage.totals.cacheRead } : {},
284951
+ ...turnUsage.totals.cacheWrite > 0 ? { cacheWriteTokens: turnUsage.totals.cacheWrite } : {},
284907
284952
  success: !turnFailed,
284908
284953
  ...turnCategory !== undefined ? { category: turnCategory } : {}
284909
284954
  });
@@ -302638,7 +302683,7 @@ var init_native_coverage_generated = __esm(() => {
302638
302683
  registryDigest: "286041ef4394afd4de97b4da37e31ccb2728c485cd32488c737a2686c244fbca",
302639
302684
  contractDigest: "43cd83cfbd494ce63e1f6c86a5a0c057a160f4a537d8119358e0f262412a96c9",
302640
302685
  subjectCatalogueDigest: "819a324bfef3387bf464f5c78d4831751b03c9c4f3cb636471e2d8f4bd88d6cc",
302641
- inventoryDigest: "bd3d9d5179d674627fa15a280e9f145e4218f507f22f74e3b54026803b7791f9",
302686
+ inventoryDigest: "2b8bbe463dcdf62267f483ec25a194b35d3867a2aae54c2f5756d061442451fb",
302642
302687
  releaseReady: true,
302643
302688
  counts: {
302644
302689
  registeredCommands: 74,
@@ -302916,7 +302961,7 @@ var init_native_coverage_generated = __esm(() => {
302916
302961
  "workspace.navigate"
302917
302962
  ],
302918
302963
  otherBlockers: [],
302919
- descriptorDigest: "413f674dab92d4593ebbed54acb52d46f4a6b999bf55e5456fbb73b61d6feac0"
302964
+ descriptorDigest: "55a6b3e7f4025d94f5df676d6fcb1e70b7de936ca24e799790d2e5f3523ac01f"
302920
302965
  };
302921
302966
  });
302922
302967
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mrciphersmith/keryx",
3
- "version": "0.4.24",
3
+ "version": "0.4.25",
4
4
  "description": "Version-controlled project context for AI coding agents: code graph, architecture wiki, project memory, relevant tests, quality signals, and task flows.",
5
5
  "private": false,
6
6
  "publishConfig": {