@encoredigitalgroup/opencode 0.2.8 → 0.2.9

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.
@@ -33,10 +33,11 @@ interface QuotaExportEntryBase {
33
33
  /** Unix seconds of the next source-backed reset. */
34
34
  resetAt?: number;
35
35
  }
36
- /** One row in the version 3 export document. */
36
+ /** One row in the version 4 export document. */
37
37
  export type QuotaExportEntry = (QuotaExportEntryBase & {
38
38
  renderType: "percent";
39
- percentRemaining: number;
39
+ /** Consumed share of the quota, from 0 to 100. */
40
+ percentUsed: number;
40
41
  }) | (QuotaExportEntryBase & {
41
42
  renderType: "value";
42
43
  value: string;
@@ -85,10 +86,10 @@ export type QuotaExportProvider = ({
85
86
  /** Present for aggregate providers; preserves configured source order. */
86
87
  sources?: QuotaExportSource[];
87
88
  };
88
- /** The version 3 export document, assembled from all configured providers. */
89
+ /** The version 4 export document, assembled from all configured providers. */
89
90
  export interface QuotaExport {
90
91
  /** Schema version. */
91
- version: 3;
92
+ version: 4;
92
93
  /** Unix seconds when this document was assembled. */
93
94
  exportedAt: number;
94
95
  /** True when data was read from disk cache without a live fetch. */
@@ -334,11 +334,11 @@ export declare const SETTINGS_SCHEMA: {
334
334
  readonly kind: "separator";
335
335
  readonly default: " · ";
336
336
  };
337
- /** The words every client uses: "58% left", "58% remaining", "58%", or "42% used". */
337
+ /** Every client shows quota consumed: "42% used". */
338
338
  readonly "words.percent": {
339
339
  readonly kind: "choice";
340
- readonly values: readonly ["left", "remaining", "bare", "used"];
341
- readonly default: "used" | "remaining" | "left" | "bare";
340
+ readonly values: readonly ["used"];
341
+ readonly default: "used";
342
342
  };
343
343
  /** "4.5d" (smart), "2h 14m", "2h14m", "2h", or "2.2h" (with `resetDecimals`). */
344
344
  readonly "words.reset": {
@@ -34,7 +34,7 @@ export type Theme = {
34
34
  };
35
35
  };
36
36
  export declare function namedColor(theme: Theme, name: ColorName): RGBA;
37
- /** The bar color for a percent left: plenty left, getting low, or almost out. */
37
+ /** The bar color for a remaining percent: low, high, or nearly complete usage. */
38
38
  export declare function levelColor(theme: Theme, display: Settings, percent: number): RGBA;
39
39
  /** A role's color. A role set to "bar" takes the level color of the row's percent. */
40
40
  export declare function roleColor(theme: Theme, display: Settings, role: ColorRole, percent?: number): RGBA;
@@ -14,9 +14,9 @@ export declare function formatTokens(count: number): string;
14
14
  export declare function formatShare(share: number): string;
15
15
  /** The words until the server sends its own (docs/v6-build.local.md §5). */
16
16
  export declare const DEFAULT_WORDS: Words;
17
- /** The word after a percent ("left", "used", or "" for the bare style). */
17
+ /** The word after every quota percentage. */
18
18
  export declare function percentWord(words: Words): string;
19
- /** "58% left", "42% used", or "58%" without the word. */
19
+ /** A raw percent remaining displayed as the consumed percentage: "42% used". */
20
20
  export declare function percentText(words: Words, percentRemaining: number, withWord: boolean): string;
21
21
  /**
22
22
  * docs/v6-plan.local.md §4.7. Zero units are dropped in every style; the past is "now".
@@ -26,7 +26,7 @@ export declare function percentText(words: Words, percentRemaining: number, with
26
26
  */
27
27
  export declare function formatDuration(ms: number, style: Words["reset"], decimals: number): string;
28
28
  export type BarShape = Settings["layout"]["bar"];
29
- /** A bar in two parts (used, remaining), so each can have its own color. */
29
+ /** A bar in two parts: consumed quota, then the unfilled portion. */
30
30
  export declare function barParts(shape: BarShape, percentRemaining: number, width: number): [string, string];
31
31
  /**
32
32
  * The cell of a bar `width` cells wide where even use would be (the │ mark): `evenLeft` is the
@@ -38,14 +38,14 @@ export type Thresholds = {
38
38
  warningBelow: number;
39
39
  lowBelow: number;
40
40
  };
41
- /** Plenty left, getting low, or almost out; "almost out" wins where both would. */
41
+ /** Low, high, or nearly complete usage; "nearly complete" wins where both would. */
42
42
  export declare function levelOf(percentRemaining: number, thresholds: Thresholds): Level;
43
43
  /**
44
44
  * "$12.40", "12.40 EUR", "1 request", "1,200 requests", "30 nano". A count unit is one word
45
45
  * ("request"); it is plural for every number but 1, and the plain "unit" is not shown.
46
46
  */
47
47
  export declare function amountText(amount: Amount): string;
48
- /** The value of a row without a percent: its text, amount, used/limit, or yes/no. */
48
+ /** The value of a row without a percent: its text, used amount, used/limit, or yes/no. */
49
49
  export declare function rowValueText(row: QuotaRow): string;
50
50
  /** "12.3K in · 2.10K out". */
51
51
  export declare function sessionTokensText(tokens: SessionTokens): string;
@@ -12,8 +12,8 @@ export type Place = {
12
12
  */
13
13
  names: "words" | "label";
14
14
  /**
15
- * "number": "58%", the place says the word elsewhere. "words": "58% left", "42% used", or
16
- * "58%" in the bare style. "usedWord": "58%", but "42% used", which bare would read as left.
15
+ * "number": "42%", the place says the word elsewhere. "words": "42% used", and "usedWord":
16
+ * "42%" except where the consumed-usage label is needed.
17
17
  */
18
18
  percent: "number" | "words" | "usedWord";
19
19
  /** Reset and pace times in this style, whatever the words (Limits: always "exact"). */
@@ -22,7 +22,7 @@ export type Place = {
22
22
  evenUse?: boolean;
23
23
  /**
24
24
  * The pace words it shows, none without: "runsOut" only "runs out in 2h" (before the reset),
25
- * "fast" also "faster than it refills", "all" also "plenty to spare" and "on track".
25
+ * "fast" also "faster than it refills", "all" also "using less than planned" and "on track".
26
26
  */
27
27
  pace?: "runsOut" | "fast" | "all";
28
28
  };
@@ -30,9 +30,9 @@ export type RowFacts = {
30
30
  /** The row's id, for the lines that show it. */
31
31
  id: string;
32
32
  name: string;
33
- /** Its percent left as the row has it, for bars and level colors; undefined without one. */
33
+ /** Its remaining percent as the row has it, for bars and level colors; undefined without one. */
34
34
  percent?: number;
35
- /** Its percent in the place's style, or the value of a row without one ("$1,240.50 left"). */
35
+ /** Its percent in the place's style, or the value of a row without one ("$1,240.50 used"). */
36
36
  value: string;
37
37
  /** The time until it resets in the place's style ("2h 14m", "3.2d"); "" without a percent. */
38
38
  reset: string;
@@ -63,6 +63,6 @@ export declare function windowFor(windows: Readonly<Record<string, WindowChoice>
63
63
  /**
64
64
  * The one row a group shows in the collapsed sidebar and the status line: the preferred
65
65
  * window's row; with "lowest", or when the group has no row of that window, the row with the
66
- * least left; else the first row.
66
+ * most used; else the first row.
67
67
  */
68
68
  export declare function pickRow(group: Pick<Group, "rows">, choice?: WindowChoice): VisibleRow | undefined;
@@ -11,7 +11,7 @@ import { type Group, type WindowChoice } from "./select.js";
11
11
  export type ColorRole = "title" | "provider" | "account" | "label" | "good" | "warning" | "low" | "empty" | "percent" | "reset" | "value" | "error" | "statusName" | "separator" | "arrows";
12
12
  /**
13
13
  * A piece of a line. `role` "bar" is the filled part of a bar, drawn in its level color.
14
- * `percent` is the row's percent left, for roles that follow the bar color.
14
+ * `percent` is the row's remaining percent, for roles that follow the bar color.
15
15
  */
16
16
  export type Segment = {
17
17
  text: string;
@@ -43,7 +43,7 @@ type SidebarInput = {
43
43
  /** A "runs out in 2h" line under each row that runs out before its reset. */
44
44
  runsOut?: boolean;
45
45
  };
46
- /** §4.1: the expanded panel's title, with the percent's word its rows leave out: "▼ Quota left". */
46
+ /** §4.1: the expanded panel's title, with the rows' consumed-usage word: "▼ Quota used". */
47
47
  export declare function sidebarTitle(words: Words): string;
48
48
  /**
49
49
  * §4.1: the expanded Quota panel, below its title line (`sidebarTitle`). The name column fits
@@ -1741,21 +1741,14 @@ function formatTokens(count) {
1741
1741
  const whole = Math.round(count);
1742
1742
  return whole < 1000 ? String(whole) : COMPACT.format(whole);
1743
1743
  }
1744
- var PERCENT_WORDS = {
1745
- left: "left",
1746
- remaining: "remaining",
1747
- bare: "",
1748
- used: "used"
1749
- };
1750
1744
  function percentWord(words) {
1751
- return PERCENT_WORDS[words.percent];
1745
+ return "used";
1752
1746
  }
1753
1747
  function clampPercent(percent) {
1754
1748
  return Math.max(0, Math.min(100, Math.round(percent)));
1755
1749
  }
1756
1750
  function percentText(words, percentRemaining, withWord) {
1757
- const left = clampPercent(percentRemaining);
1758
- const value = words.percent === "used" ? 100 - left : left;
1751
+ const value = 100 - clampPercent(percentRemaining);
1759
1752
  const word = withWord ? percentWord(words) : "";
1760
1753
  return word ? `${value}% ${word}` : `${value}%`;
1761
1754
  }
@@ -1827,14 +1820,10 @@ function rowValueText(row) {
1827
1820
  return row.text;
1828
1821
  if (row.amount) {
1829
1822
  const amount = amountText(row.amount);
1830
- if (row.type === "balance")
1831
- return `${amount} left`;
1832
1823
  return row.type === "usage" ? `${amount} used` : amount;
1833
1824
  }
1834
- if (row.remaining)
1835
- return `${amountText(row.remaining)} left`;
1836
1825
  if (row.used && row.limit)
1837
- return `${amountText(row.used)}/${amountText(row.limit)}`;
1826
+ return `${amountText(row.used)}/${amountText(row.limit)} used`;
1838
1827
  if (row.used)
1839
1828
  return `${amountText(row.used)} used`;
1840
1829
  if (row.flag !== undefined)
@@ -3847,7 +3836,7 @@ function rowEntry(providerId, providerLabel, row) {
3847
3836
  ...resetAt !== undefined ? { resetAt } : {}
3848
3837
  };
3849
3838
  if (row.percentRemaining !== undefined) {
3850
- return { ...base, renderType: "percent", percentRemaining: row.percentRemaining };
3839
+ return { ...base, renderType: "percent", percentUsed: 100 - row.percentRemaining };
3851
3840
  }
3852
3841
  return {
3853
3842
  ...base,
@@ -3860,7 +3849,7 @@ function exportProvider(provider, answeredAtMs, nowMs) {
3860
3849
  return { status: "unavailable" };
3861
3850
  }
3862
3851
  const fetchedAt = Math.floor(answeredAtMs / 1000);
3863
- const entries = provider.rows.map((row) => rowEntry(provider.providerId, provider.label, row));
3852
+ const entries = provider.rows.filter((row) => row.type !== "balance").map((row) => rowEntry(provider.providerId, provider.label, row));
3864
3853
  if (!provider.error)
3865
3854
  return { status: "ok", fetchedAt, entries };
3866
3855
  const error = sanitizeSingleLineDisplaySnippet(describeError(provider.error, provider.label, nowMs), EXPORT_ERROR_MAX_LENGTH);
@@ -7283,7 +7272,7 @@ var SETTINGS_SCHEMA = {
7283
7272
  "layout.labelWidth": { ...whole(3, 20), default: 8 },
7284
7273
  "layout.providerGap": { ...whole(0, 2), default: 1 },
7285
7274
  "layout.separator": { kind: "separator", default: " \xB7 " },
7286
- "words.percent": choice(["left", "remaining", "bare", "used"], "left"),
7275
+ "words.percent": choice(["used"], "used"),
7287
7276
  "words.reset": choice(["smart", "exact", "compact", "short", "decimal"], "smart"),
7288
7277
  "words.resetDecimals": { ...whole(0, 4), default: 1 },
7289
7278
  "words.rowNames": choice(["short", "full"], "short"),
@@ -7558,7 +7547,8 @@ function settingsFrom(assignments) {
7558
7547
  issues.push({ key, message: "expected an object" });
7559
7548
  continue;
7560
7549
  }
7561
- const checked = checkSetting(key, value);
7550
+ const normalized = key === "words.percent" && ["left", "remaining", "bare", "used"].includes(String(value)) ? "used" : value;
7551
+ const checked = checkSetting(key, normalized);
7562
7552
  issues.push(...checked.issues);
7563
7553
  if (checked.value === undefined)
7564
7554
  continue;
@@ -8846,11 +8836,8 @@ function mapV5Values(values) {
8846
8836
  }
8847
8837
  const percentKeys = ["percentDisplayMode", "percentLabelStyle"].filter(has);
8848
8838
  if (percentKeys.length > 0) {
8849
- const used = chosen("percentDisplayMode", "remaining") === "used";
8850
- const bare = chosen("percentLabelStyle", "full") === "bare";
8851
- const note = used && bare ? 'v6 has no bare "used" percent; it shows "42% used"' : undefined;
8852
8839
  for (const key of percentKeys) {
8853
- toServer(key, "words.percent", used ? "used" : bare ? "bare" : "left", note);
8840
+ toServer(key, "words.percent", "used", "quota percentages now always show consumed usage");
8854
8841
  }
8855
8842
  }
8856
8843
  const resetKeys = ["resetTimeDecimals", "resetTimeSpaced"].filter(has);
package/dist/tui/index.js CHANGED
@@ -5532,7 +5532,7 @@ var SETTINGS_SCHEMA = {
5532
5532
  "layout.labelWidth": { ...whole(3, 20), default: 8 },
5533
5533
  "layout.providerGap": { ...whole(0, 2), default: 1 },
5534
5534
  "layout.separator": { kind: "separator", default: " \xB7 " },
5535
- "words.percent": choice(["left", "remaining", "bare", "used"], "left"),
5535
+ "words.percent": choice(["used"], "used"),
5536
5536
  "words.reset": choice(["smart", "exact", "compact", "short", "decimal"], "smart"),
5537
5537
  "words.resetDecimals": { ...whole(0, 4), default: 1 },
5538
5538
  "words.rowNames": choice(["short", "full"], "short"),
@@ -5807,7 +5807,8 @@ function settingsFrom(assignments) {
5807
5807
  issues.push({ key, message: "expected an object" });
5808
5808
  continue;
5809
5809
  }
5810
- const checked = checkSetting(key, value);
5810
+ const normalized = key === "words.percent" && ["left", "remaining", "bare", "used"].includes(String(value)) ? "used" : value;
5811
+ const checked = checkSetting(key, normalized);
5811
5812
  issues.push(...checked.issues);
5812
5813
  if (checked.value === undefined)
5813
5814
  continue;
@@ -5899,21 +5900,14 @@ function formatTokens(count) {
5899
5900
  const whole = Math.round(count);
5900
5901
  return whole < 1000 ? String(whole) : COMPACT.format(whole);
5901
5902
  }
5902
- var PERCENT_WORDS = {
5903
- left: "left",
5904
- remaining: "remaining",
5905
- bare: "",
5906
- used: "used"
5907
- };
5908
5903
  function percentWord(words) {
5909
- return PERCENT_WORDS[words.percent];
5904
+ return "used";
5910
5905
  }
5911
5906
  function clampPercent(percent) {
5912
5907
  return Math.max(0, Math.min(100, Math.round(percent)));
5913
5908
  }
5914
5909
  function percentText(words, percentRemaining, withWord) {
5915
- const left = clampPercent(percentRemaining);
5916
- const value = words.percent === "used" ? 100 - left : left;
5910
+ const value = 100 - clampPercent(percentRemaining);
5917
5911
  const word = withWord ? percentWord(words) : "";
5918
5912
  return word ? `${value}% ${word}` : `${value}%`;
5919
5913
  }
@@ -5985,14 +5979,10 @@ function rowValueText(row) {
5985
5979
  return row.text;
5986
5980
  if (row.amount) {
5987
5981
  const amount = amountText(row.amount);
5988
- if (row.type === "balance")
5989
- return `${amount} left`;
5990
5982
  return row.type === "usage" ? `${amount} used` : amount;
5991
5983
  }
5992
- if (row.remaining)
5993
- return `${amountText(row.remaining)} left`;
5994
5984
  if (row.used && row.limit)
5995
- return `${amountText(row.used)}/${amountText(row.limit)}`;
5985
+ return `${amountText(row.used)}/${amountText(row.limit)} used`;
5996
5986
  if (row.used)
5997
5987
  return `${amountText(row.used)} used`;
5998
5988
  if (row.flag !== undefined)
@@ -6070,7 +6060,7 @@ function nameOf(item, group, place) {
6070
6060
  }
6071
6061
  function paceWords(pace, times, words) {
6072
6062
  if (pace.kind === "spare")
6073
- return "plenty to spare";
6063
+ return "using less than planned";
6074
6064
  if (pace.kind === "on_track")
6075
6065
  return "on track";
6076
6066
  if (pace.runsOutInMs === undefined)
@@ -6151,7 +6141,7 @@ function visibleGroups(snapshot, settings, surface, words) {
6151
6141
  const providers = ordered(snapshot.providers, (provider) => provider.providerId, shown.providerOrder).filter((provider) => !hidden.has(provider.providerId) && (currentModel === undefined || currentModel.includes(provider.providerId)));
6152
6142
  return providers.flatMap((provider) => {
6153
6143
  const prefixes = rowPrefixes?.[provider.providerId];
6154
- const rows = ordered(provider.rows, (row) => row.id, shown.rowOrder[provider.providerId] ?? []).filter((row) => !hidden.has(row.id)).filter((row) => prefixes === undefined || prefixes.some((prefix) => row.id.startsWith(prefix))).filter((row) => words.detail === "detailed" || row.prominence === "primary").map((row) => visibleRow(row, names));
6144
+ const rows = ordered(provider.rows, (row) => row.id, shown.rowOrder[provider.providerId] ?? []).filter((row) => !hidden.has(row.id)).filter((row) => row.type !== "balance").filter((row) => prefixes === undefined || prefixes.some((prefix) => row.id.startsWith(prefix))).filter((row) => words.detail === "detailed" || row.prominence === "primary").map((row) => visibleRow(row, names));
6155
6145
  return groupsOf(provider, rows, provider.rows.length > 0);
6156
6146
  });
6157
6147
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@encoredigitalgroup/opencode",
3
3
  "type": "module",
4
- "version": "0.2.8",
4
+ "version": "0.2.9",
5
5
  "description": "OpenCode planning pickers, a todo tracker, and a quota sidebar.",
6
6
  "publishConfig": {
7
7
  "access": "public"
@@ -26,7 +26,7 @@
26
26
  "@opencode/client": "2.1.4",
27
27
  "@opencode/plugin": "2.1.4",
28
28
  "@opentui/core": "0.5.14",
29
- "@types/node": "^22.0.0",
29
+ "@types/node": "^22.20.5",
30
30
  "@types/bun": "1.4.0",
31
31
  "tsfmt": "^0.3.0-beta9",
32
32
  "typescript": "5.8.2"