opencode-cache-hit 0.2.0 → 0.2.1

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.
@@ -1,6 +1,6 @@
1
1
  /** @jsxImportSource @opentui/solid */
2
2
  import { Show, type JSX } from "solid-js"
3
- import { padBeforeTitleSummary, sepAfterPrefix, visualWidth } from "./layout.ts"
3
+ import { padBeforeTitleSummary, sepAfterPrefix, UNIT_GAP, visualWidth } from "./layout.ts"
4
4
  import type { PanelLayout } from "./use-panel-layout.ts"
5
5
  import type { PanelPalette } from "./palette.ts"
6
6
 
@@ -126,18 +126,45 @@ export function TuiSection(props: {
126
126
  )
127
127
  }
128
128
 
129
+ function metricRowGap(label: string, value: string, unit: string, gauge: number): number {
130
+ const used =
131
+ visualWidth(label) + visualWidth(value) + (unit ? visualWidth(unit) + UNIT_GAP : 0)
132
+ return Math.max(1, gauge - used)
133
+ }
134
+
129
135
  export function TuiMetricRow(props: {
130
136
  pal: PanelPalette
131
137
  layout: PanelLayout
132
138
  label: string
133
139
  value: string
134
140
  unit?: string
141
+ /** Whole line (label + value + unit). Ignored when `labelFg` / `valueFg` set. */
135
142
  fg?: string
143
+ /** Label-only color (e.g. sub-agent model); value stays `valueFg` or muted. */
144
+ labelFg?: string
145
+ valueFg?: string
136
146
  }) {
137
- const fg = props.fg ?? props.pal.muted
147
+ const unit = props.unit ?? ""
148
+ const unitSuffix = unit ? " " + unit : ""
149
+ const split = props.labelFg !== undefined || props.valueFg !== undefined
150
+ if (split) {
151
+ const gap = metricRowGap(props.label, props.value, unit, props.layout.gauge())
152
+ const labelColor = props.labelFg ?? props.fg ?? props.pal.muted
153
+ const valueColor = props.valueFg ?? props.fg ?? props.pal.muted
154
+ return (
155
+ <text>
156
+ <span style={{ fg: labelColor }}>{props.label}</span>
157
+ {" ".repeat(gap)}
158
+ <span style={{ fg: valueColor }}>
159
+ {props.value}
160
+ {unitSuffix}
161
+ </span>
162
+ </text>
163
+ )
164
+ }
138
165
  return (
139
- <text fg={fg}>
140
- {props.layout.row(props.label, props.value, props.unit ?? "")}
166
+ <text fg={props.fg ?? props.pal.muted}>
167
+ {props.layout.row(props.label, props.value, unit)}
141
168
  </text>
142
169
  )
143
170
  }
@@ -19,7 +19,12 @@ export {
19
19
  padBeforeTitleSummary,
20
20
  } from "./layout.ts"
21
21
 
22
- export { buildPanelPalette, themeColorToHex, type PanelPalette } from "./palette.ts"
22
+ export {
23
+ buildPanelPalette,
24
+ themeColorToHex,
25
+ toneBrandHex,
26
+ type PanelPalette,
27
+ } from "./palette.ts"
23
28
 
24
29
  export {
25
30
  createPanelLayout,
@@ -79,6 +79,11 @@ export function themeColorToHex(raw: unknown, fallback: string): string {
79
79
  return "#" + [c.r, c.g, c.b].map((v) => v.toString(16).padStart(2, "0")).join("")
80
80
  }
81
81
 
82
+ /** Tone a vendor brand hex for dark TUI panels (same max saturation as theme colors). */
83
+ export function toneBrandHex(hex: string, fallback: string): string {
84
+ return desaturateTo(hex, MAX_SAT, fallback)
85
+ }
86
+
82
87
  export function buildPanelPalette(theme: Record<string, unknown>): PanelPalette {
83
88
  const sat = (k: string, fb: string) => desaturateTo(theme[k], MAX_SAT, fb)
84
89
  return {
package/src/version.ts CHANGED
@@ -1 +1,4 @@
1
- export const PLUGIN_VERSION = "0.1.0"
1
+ import packageJson from "../package.json" with { type: "json" }
2
+
3
+ /** Sidebar label; kept in sync with package.json "version". */
4
+ export const PLUGIN_VERSION = packageJson.version
File without changes
Binary file