@cortexkit/aft-opencode 0.45.0 → 0.46.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.
Files changed (34) hide show
  1. package/dist/config.d.ts +0 -22
  2. package/dist/config.d.ts.map +1 -1
  3. package/dist/hooks/auto-update-checker/types.d.ts +0 -3
  4. package/dist/hooks/auto-update-checker/types.d.ts.map +1 -1
  5. package/dist/index.d.ts.map +1 -1
  6. package/dist/index.js +347 -127
  7. package/dist/lsp-github-table.d.ts +0 -8
  8. package/dist/lsp-github-table.d.ts.map +1 -1
  9. package/dist/notifications.d.ts +2 -9
  10. package/dist/notifications.d.ts.map +1 -1
  11. package/dist/shared/ignored-message.d.ts +9 -7
  12. package/dist/shared/ignored-message.d.ts.map +1 -1
  13. package/dist/shared/rpc-client.d.ts +23 -1
  14. package/dist/shared/rpc-client.d.ts.map +1 -1
  15. package/dist/subc-tool-schemas.d.ts.map +1 -1
  16. package/dist/tools/_shared.d.ts +0 -7
  17. package/dist/tools/_shared.d.ts.map +1 -1
  18. package/dist/tools/hoisted.d.ts.map +1 -1
  19. package/dist/tools/permissions.d.ts +7 -0
  20. package/dist/tools/permissions.d.ts.map +1 -1
  21. package/dist/tools/semantic.d.ts.map +1 -1
  22. package/dist/tui/notification-socket.d.ts.map +1 -1
  23. package/package.json +17 -14
  24. package/src/shared/ignored-message.ts +38 -19
  25. package/src/shared/rpc-client.ts +116 -4
  26. package/src/tui/entry.mjs +16 -0
  27. package/src/tui/notification-socket.ts +28 -1
  28. package/src/tui-compiled/badge-contrast.ts +43 -0
  29. package/src/tui-compiled/index.tsx +992 -0
  30. package/src/tui-compiled/notification-socket.ts +448 -0
  31. package/src/tui-compiled/preferences.ts +243 -0
  32. package/src/tui-compiled/sidebar.tsx +936 -0
  33. package/src/tui-compiled/types/opencode-plugin-tui.d.ts +239 -0
  34. package/dist/tui.js +0 -13462
@@ -0,0 +1,43 @@
1
+ /**
2
+ * Pick the text color for a sidebar badge label drawn on a theme accent.
3
+ * Keep this logic in sync with Magic Context so both sidebars make the same
4
+ * contrast decision for shared themes.
5
+ */
6
+
7
+ type Color = { r: number; g: number; b: number; a?: number };
8
+
9
+ const MIN_OPAQUE_ALPHA = 0.5;
10
+ const MIN_CHANNEL_DISTANCE = 0.06;
11
+ const LIGHT_ACCENT_LUMINANCE = 0.5;
12
+
13
+ function srgbChannelToLinear(c: number): number {
14
+ return c <= 0.03928 ? c / 12.92 : ((c + 0.055) / 1.055) ** 2.4;
15
+ }
16
+
17
+ function relativeLuminance(bg: Color): number {
18
+ return (
19
+ 0.2126 * srgbChannelToLinear(bg.r) +
20
+ 0.7152 * srgbChannelToLinear(bg.g) +
21
+ 0.0722 * srgbChannelToLinear(bg.b)
22
+ );
23
+ }
24
+
25
+ function nearlyEqual(a: Color, b: Color): boolean {
26
+ return (
27
+ Math.abs(a.r - b.r) < MIN_CHANNEL_DISTANCE &&
28
+ Math.abs(a.g - b.g) < MIN_CHANNEL_DISTANCE &&
29
+ Math.abs(a.b - b.b) < MIN_CHANNEL_DISTANCE
30
+ );
31
+ }
32
+
33
+ export function readableTextColorOn(bg: Color): string {
34
+ return relativeLuminance(bg) < LIGHT_ACCENT_LUMINANCE ? "#ffffff" : "#000000";
35
+ }
36
+
37
+ export function badgeTextColor<T extends Color>(accent: T, background: T): T | string {
38
+ const alpha = background.a ?? 1;
39
+ if (alpha >= MIN_OPAQUE_ALPHA && !nearlyEqual(accent, background)) {
40
+ return background;
41
+ }
42
+ return readableTextColorOn(accent);
43
+ }