@bismawy/pi-arnative 0.13.0 → 0.15.0

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.
@@ -12,7 +12,7 @@
12
12
  * 5. `↓ Jump to latest message` pill (fullscreen): bg selectedBg (grey) -> accent,
13
13
  * text darkened (theme canvas) so contrast stays high (9.6:1).
14
14
  * 6. `ctx.ui.select` rows: pi paints the whole selected row accent -> keep accent on
15
- * the `→` marker and `·` separators, selected text in soft.
15
+ * the `❯` marker and `·` separators, selected text in soft.
16
16
  */
17
17
  import {
18
18
  AssistantMessageComponent,
@@ -40,9 +40,9 @@ import {
40
40
  import { readdirSync, readFileSync } from "node:fs";
41
41
  import { renderBoxLines } from "../lib/box.ts";
42
42
  import { statusRows } from "../lib/status-widget.ts";
43
- import { ansiBgOpen, getActiveTheme, setActiveTheme, stripAnsi, themeOf, softSecondaryOf } from "../lib/ansi.ts";
43
+ import { ansiBgOpen, getActiveTheme, setActiveTheme, stripAnsi, themeOf, softOf } from "../lib/ansi.ts";
44
44
  import { assert, isMain } from "../lib/check.ts";
45
- import { contrast, oklchToRgb, parseOklch, toHex } from "../lib/color.ts";
45
+ import { contrast, hexToRgb, oklchToRgb, parseOklch, rgbToAnsi256, toHex } from "../lib/color.ts";
46
46
  import { expandKeyName } from "../lib/format.ts";
47
47
  import { patchOnce } from "../lib/patch.ts";
48
48
 
@@ -171,12 +171,12 @@ if (TuiAltScreen?.prototype) {
171
171
  }
172
172
 
173
173
  // 6. Select menus (ctx.ui.select -> ExtensionSelectorComponent.updateList): pi colors the
174
- // whole selected row accent. Arnative keeps accent on the `→` marker and `·` separators
174
+ // whole selected row accent. Arnative keeps accent on the `❯` marker and `·` separators
175
175
  // and moves the selected text to soft (accent on themes without the token).
176
176
 
177
177
  /** Selected row body: `·` separators accent, the text around them soft. */
178
178
  export function selectRowText(row: string, th: { fg(c: string, t: string): string }): string {
179
- const soft = softSecondaryOf(th);
179
+ const soft = softOf(th);
180
180
  return row
181
181
  .split("·")
182
182
  .map((part) => soft(part))
@@ -197,7 +197,7 @@ if (ExtensionSelectorComponent?.prototype) {
197
197
  for (let i = 0; i < this.options.length; i++) {
198
198
  const text =
199
199
  i === this.selectedIndex
200
- ? th.fg("accent", "→ ") + selectRowText(this.options[i]!, th)
200
+ ? th.fg("accent", "❯ ") + selectRowText(this.options[i]!, th)
201
201
  : ` ${th.fg("text", this.options[i]!)}`;
202
202
  this.listContainer.addChild(new Text(text, 1, 0));
203
203
  }
@@ -697,7 +697,7 @@ if (isMain(import.meta.url)) {
697
697
  assert(accentPill("other text", thPill) === "other text", "pill: non-pill text untouched");
698
698
  assert(accentPill(pillOriginal, null) === pillOriginal, "pill: no theme -> passed through");
699
699
 
700
- // select rows: `→` + `·` stay accent, selected text moves to accentSoft
700
+ // select rows: `❯` + `·` stay accent, selected text moves to accentSoft
701
701
  const tagFg = { fg: (c: string, t: string) => `<${c}>${t}</${c}>` };
702
702
  assert(
703
703
  selectRowText("Routing · off", tagFg) === "<accentSoft>Routing </accentSoft><accent>·</accent><accentSoft> off</accentSoft>",
@@ -718,6 +718,13 @@ if (isMain(import.meta.url)) {
718
718
  "searchMatchBg", "border", "borderAccent", "borderMuted", "mdCodeBlockBorder", "mdQuoteBorder", "mdHr",
719
719
  "scrollbarTrack", "scrollbarThumb",
720
720
  ]);
721
+ // Every background a box or a highlight paints. These carry no text contrast
722
+ // requirement, but each must still be *visible*: a box the same color as the
723
+ // terminal canvas is not a box.
724
+ const BOX_TOKENS = [
725
+ "userMessageBg", "customMessageBg", "toolPendingBg", "toolSuccessBg", "toolErrorBg",
726
+ "selectedBg", "searchMatchBg",
727
+ ];
721
728
  const secondary = new Set(["muted", "dim", "mdQuote", "mdLinkUrl", "toolOutput", "toolDiffContext", "thinkingText", "syntaxComment"]);
722
729
  // Thinking ramp: the higher the more readable; thinkingMax = accent (measured on the pill path).
723
730
  const ramp: Record<string, number> = {
@@ -831,6 +838,15 @@ if (isMain(import.meta.url)) {
831
838
  // Scrollbar thumb & highlight must be distinguishable from track/selection (they used to be identical).
832
839
  assert(hex("scrollbarThumb") !== hex("scrollbarTrack"), `theme ${f}: scrollbarThumb still equals scrollbarTrack`);
833
840
  assert(hex("searchMatchBg") !== hex("selectedBg"), `theme ${f}: searchMatchBg still equals selectedBg`);
841
+ // Every box must be visible on a pure-black terminal AND survive 256-color
842
+ // quantization. At L 0.19 the panel was `#001817` (1.14:1 on black) and every
843
+ // theme's boxes quantized to cube black (index 16) — invisible in both modes.
844
+ for (const tok of BOX_TOKENS) {
845
+ const color = hex(tok);
846
+ assert(contrast(color, "#000000") >= 1.4, `theme ${f}: ${tok} ${color} is invisible on a black terminal`);
847
+ const quantized = rgbToAnsi256(hexToRgb(color));
848
+ assert(quantized !== 16, `theme ${f}: ${tok} ${color} quantizes to index 16 (pure black) in 256-color mode`);
849
+ }
834
850
  }
835
851
  // Only `muted`, `text` and `selectedBg` exist. pi's Theme constructor maps whatever
836
852
  // it gets — including the thinkingMax <- thinkingXhigh fallback — so these probe
@@ -88,7 +88,7 @@ const statsOf = (
88
88
  type UsageView = "provider" | "project" | "prices";
89
89
 
90
90
  /** Labels on the range bar, in tab order. */
91
- const RANGE_LABELS: Record<UsageRange, string> = { all: "All", today: "Today", "7d": "7 day", "30d": "30 day", "3m": "3 month" };
91
+ const RANGE_LABELS: Record<UsageRange, string> = { all: "All", today: "Today", "7d": "7 day", "30d": "30 day" };
92
92
  /** The three views `v` cycles, in that order, and the view a press would show next. */
93
93
  const VIEW_LABELS: Record<UsageView, string> = { provider: "Provider", project: "Project", prices: "Prices" };
94
94
  const NEXT_VIEW: Record<UsageView, UsageView> = { provider: "project", project: "prices", prices: "provider" };
@@ -1323,7 +1323,6 @@ if (isMain(import.meta.url)) {
1323
1323
  assert(msgIn("today") === 1, "today counts only the message written today");
1324
1324
  assert(msgIn("7d") === 1, "7 day stops before the ten-day record, so only today counts");
1325
1325
  assert(msgIn("30d") === 2, "30 day covers today and ten days back, not forty-five");
1326
- assert(msgIn("3m") === 3, "3 month covers all three");
1327
1326
  // A window with nothing in it is empty, not an error: the bar can be pressed on a quiet day.
1328
1327
  assert(collectUsageSummary(true, "today").totals.msgs >= 1, "today still reports the rows it has");
1329
1328
 
@@ -1339,11 +1338,11 @@ if (isMain(import.meta.url)) {
1339
1338
  const reloaded = JSON.parse(readFileSync(cacheFile, "utf8")) as Record<string, { d?: unknown }>;
1340
1339
  assert(Object.values(reloaded).some((item) => item.d !== undefined), "the re-parse writes the day buckets back");
1341
1340
 
1342
- // The range bar: five windows, the active one accented, and the counter states how many
1341
+ // The range bar: four windows, the active one accented, and the counter states how many
1343
1342
  // rows exist past the viewport. Tab moves the window and the numbers follow it.
1344
1343
  const barModal = new UsageModalComponent(fakeTheme, () => {}, () => {}, "high");
1345
1344
  const barOnce = barModal.render(100).map(plain);
1346
- const barLine = barOnce.find((l) => l.includes("All") && l.includes("Today") && l.includes("3 month"));
1345
+ const barLine = barOnce.find((l) => l.includes("All") && l.includes("Today") && l.includes("30 day"));
1347
1346
  assert(barLine !== undefined, "the range bar names every window on one line");
1348
1347
  assert(USAGE_RANGES.every((r) => barLine!.includes(RANGE_LABELS[r])), "every range label is on the bar");
1349
1348
  assert(barLine!.indexOf("All") < barLine!.indexOf("Today"), "the bar keeps tab order");
package/lib/color.ts CHANGED
@@ -75,6 +75,34 @@ export function toHex(value: string): string {
75
75
  throw new Error(`Not a hex/oklch color: ${value}`);
76
76
  }
77
77
 
78
+ /**
79
+ * Nearest xterm-256 index for an sRGB color, mirroring `rgbToAnsi256` in
80
+ * @earendil-works/pi-tui (`colors.ts`). pi draws every theme color through that
81
+ * quantizer whenever the terminal is not truecolor, so a value that lands on the
82
+ * 6x6x6 cube black renders as `#000000` no matter what the theme file declared.
83
+ * Kept in sync by test/theme-canvas.test.ts.
84
+ */
85
+ export function rgbToAnsi256(rgb: Rgb): number {
86
+ const CUBE = [0, 95, 135, 175, 215, 255];
87
+ const GRAY = Array.from({ length: 24 }, (_, i) => 8 + i * 10);
88
+ const nearest = (values: readonly number[], v: number) =>
89
+ values.reduce((best, x, i) => (Math.abs(x - v) < Math.abs(values[best]! - v) ? i : best), 0);
90
+ const distance = (a: Rgb, b: Rgb) => (a.r - b.r) ** 2 * 0.299 + (a.g - b.g) ** 2 * 0.587 + (a.b - b.b) ** 2 * 0.114;
91
+ const [ri, gi, bi] = [rgb.r, rgb.g, rgb.b].map((c) => nearest(CUBE, c)) as [number, number, number];
92
+ const cube = { r: CUBE[ri]!, g: CUBE[gi]!, b: CUBE[bi]! };
93
+ const grayIndex = nearest(GRAY, Math.round(0.299 * rgb.r + 0.587 * rgb.g + 0.114 * rgb.b));
94
+ const gray = { r: GRAY[grayIndex]!, g: GRAY[grayIndex]!, b: GRAY[grayIndex]! };
95
+ const spread = Math.max(rgb.r, rgb.g, rgb.b) - Math.min(rgb.r, rgb.g, rgb.b);
96
+ if (spread < 10 && distance(rgb, gray) < distance(rgb, cube)) return 232 + grayIndex;
97
+ return 16 + 36 * ri + 6 * gi + bi;
98
+ }
99
+
100
+ /** `#rrggbb` -> sRGB channels. Inverse of the hex branch of {@link toHex}. */
101
+ export function hexToRgb(hex: string): Rgb {
102
+ const v = toHex(hex);
103
+ return { r: parseInt(v.slice(1, 3), 16), g: parseInt(v.slice(3, 5), 16), b: parseInt(v.slice(5, 7), 16) };
104
+ }
105
+
78
106
  function relativeLuminance(hex: string): number {
79
107
  const [r, g, b] = [1, 3, 5]
80
108
  .map((i) => parseInt(hex.slice(i, i + 2), 16) / 255)
@@ -122,5 +150,11 @@ if (isMain(import.meta.url)) {
122
150
  const back = hexToOklch(FIXTURE.cyan);
123
151
  assert(Math.abs(back.H - 218) < 6, `hexToOklch hue of ${FIXTURE.cyan} ~218 (got ${back.H.toFixed(1)})`);
124
152
  assert(oklchToRgb(0.7, 0.4, 145).chroma < 0.4, "out-of-gamut chroma is reduced");
153
+ // Quantizer vectors taken from pi-tui's own table: cube black, the teal panel pi's
154
+ // dark theme uses, and a near-neutral that must fall on the grey ramp.
155
+ assert(rgbToAnsi256({ r: 0, g: 24, b: 23 }) === 16, "near-black quantizes to cube black (index 16)");
156
+ assert(rgbToAnsi256({ r: 33, g: 59, b: 73 }) === 23, "pi dark panel quantizes to 23");
157
+ assert(rgbToAnsi256({ r: 200, g: 200, b: 200 }) >= 232, "neutral grey uses the grey ramp");
158
+ assert(hexToRgb("#1c3f3d").g === 0x3f, "hexToRgb reads channels");
125
159
  console.log("lib/color.ts OK");
126
160
  }
@@ -5,7 +5,7 @@
5
5
  * can import it without importing the settings menu back (no import cycle).
6
6
  */
7
7
  import { Input, matchesKey, truncateToWidth, visibleWidth, type Component, type Focusable } from "@earendil-works/pi-tui";
8
- import { softSecondaryOf, thinkingColorOf } from "../lib/ansi.ts";
8
+ import { softOf, thinkingColorOf } from "../lib/ansi.ts";
9
9
  import { renderScreen, screenTitle, type ScreenText } from "../lib/box.ts";
10
10
  import { assert, isMain } from "../lib/check.ts";
11
11
  import { ROW_DIVIDER } from "../lib/format.ts";
@@ -33,7 +33,7 @@ export function rowText(row: ListRow): string {
33
33
  return row.note ? `${row.label} · ${row.note}` : row.label;
34
34
  }
35
35
 
36
- /** Bare names (preset lists) as rows; the cursor's `→` marks the live value. */
36
+ /** Bare names (preset lists) as rows; the cursor's `❯` marks the live value. */
37
37
  export const nameRows = (names: readonly string[]): ListRow[] => names.map((label) => ({ label }));
38
38
 
39
39
  interface ListPickerHooks {
@@ -260,7 +260,7 @@ export class ListPicker implements Component {
260
260
  render(width: number): string[] {
261
261
  const th = this.theme;
262
262
  const bold = th.bold ?? ((t: string) => `\x1b[1m${t}\x1b[22m`);
263
- const soft = softSecondaryOf(th);
263
+ const soft = softOf(th);
264
264
  const edge = (text: string) => this.edge(text);
265
265
  const column = Math.max(0, ...this.rows.map((r) => visibleWidth(r.label)));
266
266
  const body: string[] = [];
@@ -272,7 +272,7 @@ export class ListPicker implements Component {
272
272
  for (let i = windowStart; i < windowEnd; i++) {
273
273
  const item = this.rows[shown[i]!]!;
274
274
  const isSelected = i === this.selected;
275
- const paint = isSelected ? (s: string) => soft(bold(s)) : (s: string) => th.fg(item.note ? "text" : "muted", s);
275
+ const paint = isSelected ? (s: string) => soft(bold(s)) : (s: string) => th.fg("text", s);
276
276
  const pad = " ".repeat(Math.max(0, column - visibleWidth(item.label)));
277
277
  const noteText = this.hooks.note?.(item.label) ?? item.note;
278
278
  const note = noteText ? `${th.fg("dim", ROW_DIVIDER)}${th.fg("dim", noteText)}` : "";
@@ -287,7 +287,7 @@ export class ListPicker implements Component {
287
287
  const suffix = /(\(.*\))$/.exec(item.label)?.[1] ?? "";
288
288
  const head = suffix ? item.label.slice(0, item.label.length - suffix.length) : item.label;
289
289
  const tail = suffix ? th.fg("dim", suffix) : "";
290
- const content = `${isSelected ? th.fg("accent", "→ ") : " "}${mark}${paint(head)}${tail}${pad}${note}${chosen}`;
290
+ const content = `${isSelected ? th.fg("accent", "❯ ") : " "}${mark}${paint(head)}${tail}${pad}${note}${chosen}`;
291
291
  body.push(truncateToWidth(content, width - 4, ""));
292
292
  }
293
293
  // Hidden rows are announced, never silently cut (an empty line is still a row).
@@ -402,7 +402,7 @@ if (isMain(import.meta.url)) {
402
402
  const lines = picker.render(50);
403
403
  assert(lines[0]!.startsWith("╭") && lines[lines.length - 1]!.startsWith("╰"), "picker framed");
404
404
  assert(lines.every((l) => visibleWidth(l) === 50), "picker lines fit width 50");
405
- assert(lines.some((l) => l.includes("→ a")), "the cursor marks the selection");
405
+ assert(lines.some((l) => l.includes("❯ a")), "the cursor marks the selection");
406
406
 
407
407
  // The chosen marker: ✓ ends the saved row only, colored by the theme's success slot.
408
408
  const chosenPicker = new ListPicker(
@@ -447,18 +447,18 @@ if (isMain(import.meta.url)) {
447
447
  frame = scrolled.render(50);
448
448
  assert(countItems(frame) === 10, "still 10 rows after scrolling");
449
449
  assert(frame.some((l) => l.includes("↑ 9 more")) && frame.some((l) => l.includes("↓ 6 more")), "both ends announce their hidden rows");
450
- assert(frame.some((l) => l.includes("→ m14")), "the cursor row stays visible");
450
+ assert(frame.some((l) => l.includes("❯ m14")), "the cursor row stays visible");
451
451
  scrolled.handleInput("\x1b[B");
452
452
  const frameNext = scrolled.render(50);
453
453
  assert(frameNext.length === frame.length && countItems(frameNext) === 10, "the frame height stays constant while scrolling inside the list");
454
454
  for (let i = 0; i < 9; i++) scrolled.handleInput("\x1b[B");
455
455
  frame = scrolled.render(50);
456
- assert(frame.some((l) => l.includes("→ m24")) && frame.some((l) => l.includes("↑ 15 more")) && !frame.some((l) => l.includes("↓")), "the bottom of the list announces only what is above");
456
+ assert(frame.some((l) => l.includes("❯ m24")) && frame.some((l) => l.includes("↑ 15 more")) && !frame.some((l) => l.includes("↓")), "the bottom of the list announces only what is above");
457
457
  // Wrap at both edges, matching the /jev-eye picker: a held key never sticks.
458
458
  scrolled.handleInput("\x1b[B");
459
- assert(scrolled.render(50).some((l) => l.includes("→ m0")), "↓ at the last row wraps to the top");
459
+ assert(scrolled.render(50).some((l) => l.includes("❯ m0")), "↓ at the last row wraps to the top");
460
460
  scrolled.handleInput("\x1b[A");
461
- assert(scrolled.render(50).some((l) => l.includes("→ m24")), "↑ at the top row wraps to the last row");
461
+ assert(scrolled.render(50).some((l) => l.includes("❯ m24")), "↑ at the top row wraps to the last row");
462
462
  const short = new ListPicker(fakeTheme, nameRows(["a", "b"]), "a", { preview: quiet, revert: quiet, done: quiet, requestRender: quiet }, { title: screenTitle("Test"), description: "d", legend: "l" }, false, undefined, 10);
463
463
  assert(!short.render(50).some((l) => l.includes("more")), "a short list shows no scroll indicators");
464
464
 
@@ -511,7 +511,7 @@ if (isMain(import.meta.url)) {
511
511
 
512
512
  const summarized = new ListPicker(fakeTheme, nameRows(["a", "b"]), "a", { preview: quiet, revert: quiet, done: quiet, requestRender: quiet, summary: () => ["Box · a"] }, { title: "T", description: "d", legend: "l" }, false);
513
513
  const sumLines = summarized.render(40).map(plain);
514
- assert(sumLines.some((l) => l.includes("Box · a")) && sumLines.indexOf(sumLines.find((l) => l.includes("Box · a"))!) < sumLines.indexOf(sumLines.find((l) => l.includes("→ a"))!), "summary renders above the picker rows");
514
+ assert(sumLines.some((l) => l.includes("Box · a")) && sumLines.indexOf(sumLines.find((l) => l.includes("Box · a"))!) < sumLines.indexOf(sumLines.find((l) => l.includes("❯ a"))!), "summary renders above the picker rows");
515
515
 
516
516
  console.log("list-picker.ts self-check OK");
517
517
  }
@@ -28,6 +28,10 @@ export const BUDGET_MONTH_KEY = "budgetMonth";
28
28
  export const BUDGET_ENFORCE_KEY = "budgetEnforce";
29
29
  /** Transcript render cache: `"On"` / `"Off"`, absent reads as `"On"`. */
30
30
  export const RENDER_CACHE_KEY = "renderCache";
31
+ /** Remote proxy payload limit: `"Off"` or `"<N> MB"`, absent reads as `"1 MB"`. */
32
+ export const PAYLOAD_LIMIT_KEY = "payloadLimit";
33
+ /** Expanded `edit` diff layout: `"Split"` (default) or `"Unified"`. */
34
+ export const EDIT_DIFF_KEY = "editDiff";
31
35
 
32
36
  // Resolved per call, not at import: the self-check points getAgentDir() at a fixture dir.
33
37
  // Everything pi-arnative writes lives in one folder (agent dir/arnative); the config moved
@@ -83,6 +87,11 @@ export function loadChoice<T extends string>(key: string, allowed: readonly T[])
83
87
  return typeof value === "string" && (allowed as readonly string[]).includes(value) ? (value as T) : undefined;
84
88
  }
85
89
 
90
+ /** Raw stored value for `key` (used by callers with custom parsers like `payloadLimit`). */
91
+ export function loadSetting(key: string): unknown {
92
+ return readConfig()[key];
93
+ }
94
+
86
95
  /** The stored value for `key` as a finite number in `[min, max]`, or undefined when absent, empty,
87
96
  * unparsable or out of range. Amounts are stored as strings (`"5"`, `""` = unset) because
88
97
  * `loadChoice` only accepts strings from an allowed set, so numbers get their own reader. */
@@ -95,7 +104,7 @@ export function loadNumber(key: string, range: { min: number; max: number }): nu
95
104
  /** Reading order of `config.json`: the presets in the order the settings menu shows them,
96
105
  * then `layoutVersion`, then anything else (a key from another module or a newer version).
97
106
  * Times a user edits the file by hand or reads it back. */
98
- const KEY_ORDER = ["headerPreset", "footerPreset", "footerCost", "chatboxPreset", "chatboxPrompt", "chatboxDialog", "budgetDay", "budgetMonth", "budgetEnforce", "spinnerPreset", "spinnerGradient", "layoutVersion", "autoCompact", "modelHeal", "renderCache"];
107
+ const KEY_ORDER = ["headerPreset", "footerPreset", "footerCost", "chatboxPreset", "chatboxPrompt", "chatboxDialog", "budgetDay", "budgetMonth", "budgetEnforce", "spinnerPreset", "spinnerGradient", "layoutVersion", "autoCompact", "payloadLimit", "modelHeal", "renderCache", "editDiff"];
99
108
 
100
109
  /** The record in {@link KEY_ORDER}; unknown keys keep the order they were written in. */
101
110
  function ordered(record: Record<string, unknown>): Record<string, unknown> {
@@ -88,10 +88,10 @@ function addToRollup(r: Rollup, e: UsageEntry): void {
88
88
  }
89
89
 
90
90
  /** A time window the dashboard can show. `all` is the whole history. */
91
- export type UsageRange = "all" | "today" | "7d" | "30d" | "3m";
91
+ export type UsageRange = "all" | "today" | "7d" | "30d";
92
92
 
93
93
  /** Tab order of the range bar. */
94
- export const USAGE_RANGES: readonly UsageRange[] = ["all", "today", "7d", "30d", "3m"];
94
+ export const USAGE_RANGES: readonly UsageRange[] = ["all", "today", "7d", "30d"];
95
95
 
96
96
  /** UTC day bucket key (`YYYY-MM-DD`) of a timestamp. UTC on purpose: local time would make the
97
97
  * on-disk cache depend on the timezone of the machine that wrote it, so a restore elsewhere
@@ -100,7 +100,7 @@ export function dayKey(ms: number): string {
100
100
  return new Date(ms > 0 ? ms : 0).toISOString().slice(0, 10);
101
101
  }
102
102
 
103
- /** UTC midnight where `range` starts: today, 7 or 30 calendar days back, 3 months back.
103
+ /** UTC midnight where `range` starts: today, 7 or 30 calendar days back.
104
104
  * `undefined` for `all`, which has no floor. UTC to match the day buckets: a local-midnight
105
105
  * floor would cut a UTC+7 "today" at 7am local and drop the morning's spend. */
106
106
  export function rangeStart(range: UsageRange, now = Date.now()): number | undefined {
@@ -108,8 +108,7 @@ export function rangeStart(range: UsageRange, now = Date.now()): number | undefi
108
108
  const d = new Date(now);
109
109
  d.setUTCHours(0, 0, 0, 0);
110
110
  if (range === "today") return d.getTime();
111
- if (range === "3m") d.setUTCMonth(d.getUTCMonth() - 3);
112
- else d.setUTCDate(d.getUTCDate() - (range === "7d" ? 6 : 29));
111
+ d.setUTCDate(d.getUTCDate() - (range === "7d" ? 6 : 29));
113
112
  return d.getTime();
114
113
  }
115
114
 
package/package.json CHANGED
@@ -1,51 +1,51 @@
1
1
  {
2
- "name": "@bismawy/pi-arnative",
3
- "version": "0.13.0",
4
- "description": "Refined aesthetics. Cohesive tools. Built for Pi. Warm themes, rounded tool boxes, tabbed header, compact footer and a /usage dashboard.",
5
- "keywords": [
6
- "pi-package",
7
- "pi-theme",
8
- "pi-extension"
9
- ],
10
- "type": "module",
11
- "license": "MIT",
12
- "publishConfig": {
13
- "access": "public"
14
- },
15
- "repository": {
16
- "type": "git",
17
- "url": "git+https://github.com/bismawy/pi-arnative.git"
18
- },
19
- "homepage": "https://github.com/bismawy/pi-arnative#readme",
20
- "files": [
21
- "extensions",
22
- "lib",
23
- "themes",
24
- "CHANGELOG.md",
25
- "LICENSE",
26
- "README.md"
27
- ],
28
- "pi": {
29
- "image": "https://raw.githubusercontent.com/bismawy/pi-arnative/main/assets/banner.webp",
30
- "extensions": [
31
- "./extensions/*.ts"
32
- ],
33
- "themes": [
34
- "./themes/*.json"
35
- ]
36
- },
37
- "peerDependencies": {
38
- "@earendil-works/pi-ai": "*",
39
- "@earendil-works/pi-coding-agent": "*",
40
- "@earendil-works/pi-tui": "*"
41
- },
42
- "scripts": {
43
- "dev": "pi --extension ./extensions/tools.ts --extension ./extensions/section-headers.ts --extension ./extensions/footer.ts --extension ./extensions/timestamps.ts --extension ./extensions/ui-render-tweaks.ts --extension ./extensions/render-cache.ts --extension ./extensions/usage.ts --extension ./extensions/usage-export.ts --extension ./extensions/budget.ts --extension ./extensions/animations.ts --extension ./extensions/autocompact.ts --extension ./extensions/model-heal.ts --extension ./extensions/todos.ts --extension ./extensions/arnative.ts",
44
- "test": "node lib/box.ts && node lib/patch.ts && node lib/ansi.ts && node lib/color.ts && node lib/shortcuts.ts && node lib/status-widget.ts && node lib/preset-store.ts && node lib/spinner.ts && node lib/todos.ts && node lib/usage-store.ts && node themes/gen-themes.mjs --check && node extensions/tools.ts && node lib/list-picker.ts && node lib/compat.ts && node lib/provider.ts && node lib/model-heal.ts && node extensions/footer.ts && node extensions/timestamps.ts && node extensions/ui-render-tweaks.ts && node extensions/render-cache.ts && node extensions/usage.ts && node extensions/usage-export.ts && node extensions/animations.ts && node extensions/autocompact.ts && node extensions/budget.ts && node extensions/model-heal.ts && node extensions/todos.ts && node extensions/arnative.ts && node scripts/reporter.mjs --self-check && node --test --test-reporter=./scripts/reporter.mjs",
45
- "preview": "node scripts/preview.mjs",
46
- "overlay": "node scripts/overlay.mjs",
47
- "themes": "node themes/gen-themes.mjs",
48
- "release:check": "node scripts/release-check.mjs pre-tag",
49
- "prepublishOnly": "npm test && node scripts/release-check.mjs pre-publish"
50
- }
2
+ "name": "@bismawy/pi-arnative",
3
+ "version": "0.15.0",
4
+ "description": "Refined aesthetics. Cohesive tools. Built for Pi. Warm themes, rounded tool boxes, tabbed header, compact footer and a /usage dashboard.",
5
+ "keywords": [
6
+ "pi-package",
7
+ "pi-theme",
8
+ "pi-extension"
9
+ ],
10
+ "type": "module",
11
+ "license": "MIT",
12
+ "publishConfig": {
13
+ "access": "public"
14
+ },
15
+ "repository": {
16
+ "type": "git",
17
+ "url": "git+https://github.com/bismawy/pi-arnative.git"
18
+ },
19
+ "homepage": "https://github.com/bismawy/pi-arnative#readme",
20
+ "files": [
21
+ "extensions",
22
+ "lib",
23
+ "themes",
24
+ "CHANGELOG.md",
25
+ "LICENSE",
26
+ "README.md"
27
+ ],
28
+ "pi": {
29
+ "image": "https://raw.githubusercontent.com/bismawy/pi-arnative/main/assets/banner.webp",
30
+ "extensions": [
31
+ "./extensions/*.ts"
32
+ ],
33
+ "themes": [
34
+ "./themes/*.json"
35
+ ]
36
+ },
37
+ "peerDependencies": {
38
+ "@earendil-works/pi-ai": "*",
39
+ "@earendil-works/pi-coding-agent": "*",
40
+ "@earendil-works/pi-tui": "*"
41
+ },
42
+ "scripts": {
43
+ "dev": "pi --extension ./extensions/tools.ts --extension ./extensions/section-headers.ts --extension ./extensions/footer.ts --extension ./extensions/timestamps.ts --extension ./extensions/ui-render-tweaks.ts --extension ./extensions/render-cache.ts --extension ./extensions/usage.ts --extension ./extensions/usage-export.ts --extension ./extensions/budget.ts --extension ./extensions/animations.ts --extension ./extensions/autocompact.ts --extension ./extensions/model-heal.ts --extension ./extensions/todos.ts --extension ./extensions/arnative.ts",
44
+ "test": "node lib/box.ts && node lib/patch.ts && node lib/ansi.ts && node lib/color.ts && node lib/shortcuts.ts && node lib/status-widget.ts && node lib/preset-store.ts && node lib/spinner.ts && node lib/todos.ts && node lib/usage-store.ts && node themes/gen-themes.mjs --check && node extensions/tools.ts && node lib/list-picker.ts && node lib/compat.ts && node lib/provider.ts && node lib/model-heal.ts && node extensions/footer.ts && node extensions/timestamps.ts && node extensions/ui-render-tweaks.ts && node extensions/render-cache.ts && node extensions/usage.ts && node extensions/usage-export.ts && node extensions/animations.ts && node extensions/autocompact.ts && node extensions/budget.ts && node extensions/model-heal.ts && node extensions/todos.ts && node extensions/arnative.ts && node scripts/reporter.mjs --self-check && node --test --test-reporter=./scripts/reporter.mjs",
45
+ "preview": "node scripts/preview.mjs",
46
+ "overlay": "node scripts/overlay.mjs",
47
+ "themes": "node themes/gen-themes.mjs",
48
+ "release:check": "node scripts/release-check.mjs pre-tag",
49
+ "prepublishOnly": "npm test && node scripts/release-check.mjs pre-publish"
50
+ }
51
51
  }
@@ -17,7 +17,7 @@
17
17
  "error": "oklch(76% 0.143 25)",
18
18
  "warning": "oklch(86% 0.14 85)",
19
19
  "tone": "oklch(84% 0.10 350)",
20
- "surfaceMsg": "oklch(19% 0.05 6)"
20
+ "surfaceMsg": "oklch(32% 0.06 6)"
21
21
  },
22
22
  "colors": {
23
23
  "accent": "accent",
@@ -32,19 +32,19 @@
32
32
  "text": "fg",
33
33
 
34
34
  "thinkingText": "fgMuted",
35
- "selectedBg": "oklch(31% 0.045 2)",
35
+ "selectedBg": "oklch(36% 0.045 2)",
36
36
  "scrollbarTrack": "fgFaint",
37
37
  "scrollbarThumb": "accentSoft",
38
- "searchMatchBg": "oklch(38% 0.081 18)",
38
+ "searchMatchBg": "oklch(40% 0.081 18)",
39
39
  "searchMatchText": "fg",
40
40
  "userMessageBg": "surfaceMsg",
41
41
  "userMessageText": "fg",
42
- "customMessageBg": "oklch(25% 0.05 6)",
42
+ "customMessageBg": "oklch(30% 0.06 6)",
43
43
  "customMessageText": "fg",
44
44
  "customMessageLabel": "oklch(78% 0.126 6)",
45
- "toolPendingBg": "oklch(22% 0.05 18)",
46
- "toolSuccessBg": "oklch(21% 0.06 145)",
47
- "toolErrorBg": "oklch(21% 0.06 25)",
45
+ "toolPendingBg": "oklch(30% 0.054 18)",
46
+ "toolSuccessBg": "oklch(30% 0.06 145)",
47
+ "toolErrorBg": "oklch(30% 0.06 25)",
48
48
  "toolTitle": "fg",
49
49
 
50
50
  "toolOutput": "fgMuted",
@@ -72,8 +72,8 @@
72
72
  "syntaxOperator": "fg",
73
73
 
74
74
  "syntaxPunctuation": "fgMuted",
75
- "thinkingOff": "oklch(40% 0.015 6)",
76
- "thinkingMinimal": "oklch(47% 0.045 18)",
75
+ "thinkingOff": "oklch(45% 0.015 6)",
76
+ "thinkingMinimal": "oklch(50% 0.045 18)",
77
77
  "thinkingLow": "oklch(55% 0.072 18)",
78
78
  "thinkingMedium": "oklch(63% 0.108 18)",
79
79
  "thinkingHigh": "oklch(71% 0.144 18)",
@@ -7,7 +7,7 @@
7
7
  "fgMuted": "oklch(72% 0.015 31)",
8
8
  "fgDim": "oklch(61% 0.015 31)",
9
9
  "fgFaint": "oklch(49% 0.015 31)",
10
- "primary": "oklch(58% 0.175 37)",
10
+ "primary": "oklch(60.5% 0.175 37)",
11
11
  "secondary": "oklch(79.2% 0.161 75)",
12
12
  "secondarySoft": "oklch(90% 0.05635 75)",
13
13
  "accent": "oklch(78% 0.129 31)",
@@ -17,7 +17,7 @@
17
17
  "error": "oklch(76% 0.143 25)",
18
18
  "warning": "oklch(86% 0.14 85)",
19
19
  "tone": "oklch(82% 0.14 70)",
20
- "surfaceMsg": "oklch(19% 0.05 37)"
20
+ "surfaceMsg": "oklch(32% 0.06 37)"
21
21
  },
22
22
  "colors": {
23
23
  "accent": "accent",
@@ -32,19 +32,19 @@
32
32
  "text": "fg",
33
33
 
34
34
  "thinkingText": "fgMuted",
35
- "selectedBg": "oklch(31% 0.04 75)",
35
+ "selectedBg": "oklch(36% 0.04 75)",
36
36
  "scrollbarTrack": "fgFaint",
37
37
  "scrollbarThumb": "accentSoft",
38
- "searchMatchBg": "oklch(38% 0.072 31)",
38
+ "searchMatchBg": "oklch(40% 0.072 31)",
39
39
  "searchMatchText": "fg",
40
40
  "userMessageBg": "surfaceMsg",
41
41
  "userMessageText": "fg",
42
- "customMessageBg": "oklch(25% 0.05 37)",
42
+ "customMessageBg": "oklch(30% 0.06 37)",
43
43
  "customMessageText": "fg",
44
44
  "customMessageLabel": "oklch(78% 0.112 37)",
45
- "toolPendingBg": "oklch(22% 0.048 31)",
46
- "toolSuccessBg": "oklch(21% 0.06 145)",
47
- "toolErrorBg": "oklch(21% 0.06 25)",
45
+ "toolPendingBg": "oklch(30% 0.048 31)",
46
+ "toolSuccessBg": "oklch(30% 0.06 145)",
47
+ "toolErrorBg": "oklch(30% 0.06 25)",
48
48
  "toolTitle": "fg",
49
49
 
50
50
  "toolOutput": "fgMuted",
@@ -72,8 +72,8 @@
72
72
  "syntaxOperator": "fg",
73
73
 
74
74
  "syntaxPunctuation": "fgMuted",
75
- "thinkingOff": "oklch(40% 0.015 31)",
76
- "thinkingMinimal": "oklch(47% 0.04 31)",
75
+ "thinkingOff": "oklch(45% 0.015 31)",
76
+ "thinkingMinimal": "oklch(50% 0.04 31)",
77
77
  "thinkingLow": "oklch(55% 0.064 31)",
78
78
  "thinkingMedium": "oklch(63% 0.096 31)",
79
79
  "thinkingHigh": "oklch(71% 0.128 31)",
@@ -16,7 +16,7 @@
16
16
  "success": "oklch(78% 0.15 145)",
17
17
  "error": "oklch(76% 0.143 25)",
18
18
  "warning": "oklch(86% 0.14 85)",
19
- "surfaceMsg": "oklch(19% 0.033 201)"
19
+ "surfaceMsg": "oklch(32% 0.055 201)"
20
20
  },
21
21
  "colors": {
22
22
  "accent": "accent",
@@ -31,19 +31,19 @@
31
31
  "text": "fg",
32
32
 
33
33
  "thinkingText": "fgMuted",
34
- "selectedBg": "oklch(31% 0.053 201)",
34
+ "selectedBg": "oklch(36% 0.055 201)",
35
35
  "scrollbarTrack": "fgFaint",
36
36
  "scrollbarThumb": "accentSoft",
37
- "searchMatchBg": "oklch(38% 0.099 332)",
37
+ "searchMatchBg": "oklch(40% 0.099 332)",
38
38
  "searchMatchText": "fg",
39
39
  "userMessageBg": "surfaceMsg",
40
40
  "userMessageText": "fg",
41
- "customMessageBg": "oklch(25% 0.043 201)",
41
+ "customMessageBg": "oklch(30% 0.051 201)",
42
42
  "customMessageText": "fg",
43
43
  "customMessageLabel": "oklch(78% 0.133 201)",
44
- "toolPendingBg": "oklch(22% 0.05 332)",
45
- "toolSuccessBg": "oklch(21% 0.06 145)",
46
- "toolErrorBg": "oklch(21% 0.06 25)",
44
+ "toolPendingBg": "oklch(30% 0.06 332)",
45
+ "toolSuccessBg": "oklch(30% 0.06 145)",
46
+ "toolErrorBg": "oklch(30% 0.06 25)",
47
47
  "toolTitle": "fg",
48
48
 
49
49
  "toolOutput": "fgMuted",
@@ -71,8 +71,8 @@
71
71
  "syntaxOperator": "fg",
72
72
 
73
73
  "syntaxPunctuation": "fgMuted",
74
- "thinkingOff": "oklch(40% 0.02 275)",
75
- "thinkingMinimal": "oklch(47% 0.055 332)",
74
+ "thinkingOff": "oklch(45% 0.02 275)",
75
+ "thinkingMinimal": "oklch(50% 0.055 332)",
76
76
  "thinkingLow": "oklch(55% 0.088 332)",
77
77
  "thinkingMedium": "oklch(63% 0.132 332)",
78
78
  "thinkingHigh": "oklch(71% 0.176 332)",
@@ -17,7 +17,7 @@
17
17
  "error": "oklch(76% 0.143 25)",
18
18
  "warning": "oklch(86% 0.14 85)",
19
19
  "tone": "oklch(86% 0.09 213)",
20
- "surfaceMsg": "oklch(19% 0.05 288)"
20
+ "surfaceMsg": "oklch(32% 0.06 288)"
21
21
  },
22
22
  "colors": {
23
23
  "accent": "accent",
@@ -32,19 +32,19 @@
32
32
  "text": "fg",
33
33
 
34
34
  "thinkingText": "fgMuted",
35
- "selectedBg": "oklch(35% 0.043 109)",
35
+ "selectedBg": "oklch(36% 0.043 109)",
36
36
  "scrollbarTrack": "fgFaint",
37
37
  "scrollbarThumb": "accentSoft",
38
- "searchMatchBg": "oklch(42% 0.077 351)",
38
+ "searchMatchBg": "oklch(40% 0.077 351)",
39
39
  "searchMatchText": "fg",
40
40
  "userMessageBg": "surfaceMsg",
41
41
  "userMessageText": "fg",
42
- "customMessageBg": "oklch(29% 0.05 288)",
42
+ "customMessageBg": "oklch(30% 0.06 288)",
43
43
  "customMessageText": "fg",
44
44
  "customMessageLabel": "oklch(78% 0.119 288)",
45
- "toolPendingBg": "oklch(26% 0.05 351)",
46
- "toolSuccessBg": "oklch(25% 0.06 145)",
47
- "toolErrorBg": "oklch(25% 0.06 25)",
45
+ "toolPendingBg": "oklch(30% 0.051 351)",
46
+ "toolSuccessBg": "oklch(30% 0.06 145)",
47
+ "toolErrorBg": "oklch(30% 0.06 25)",
48
48
  "toolTitle": "fg",
49
49
 
50
50
  "toolOutput": "fgMuted",
@@ -72,8 +72,8 @@
72
72
  "syntaxOperator": "fg",
73
73
 
74
74
  "syntaxPunctuation": "fgMuted",
75
- "thinkingOff": "oklch(40% 0.012 278)",
76
- "thinkingMinimal": "oklch(47% 0.043 351)",
75
+ "thinkingOff": "oklch(45% 0.012 278)",
76
+ "thinkingMinimal": "oklch(50% 0.043 351)",
77
77
  "thinkingLow": "oklch(55% 0.068 351)",
78
78
  "thinkingMedium": "oklch(63% 0.102 351)",
79
79
  "thinkingHigh": "oklch(71% 0.136 351)",