ai-battery 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.
Files changed (45) hide show
  1. package/README.md +30 -14
  2. package/bin/ai-battery-macos-status.applescript +5 -12
  3. package/bin/ai-battery-run +701 -31
  4. package/bin/ai-battery-tmux.js +17 -0
  5. package/bin/terminal-compositor.js +111 -0
  6. package/docs/REFERENCE.md +23 -3
  7. package/docs/RELEASING.md +24 -7
  8. package/docs/WINDOWS-TERMINAL-SHARED-BAR.md +74 -0
  9. package/docs/hud-preview.svg +43 -20
  10. package/docs/terminal-vertical-preview.svg +73 -0
  11. package/lib/cli.js +945 -219
  12. package/lib/core/atomic-rename.js +18 -0
  13. package/lib/core/cli-help.js +35 -7
  14. package/lib/core/cli-messages.js +45 -1
  15. package/lib/core/cli-output.js +277 -72
  16. package/lib/core/cli-wrappers.js +410 -0
  17. package/lib/core/config-editor.js +177 -29
  18. package/lib/core/display-config.js +45 -0
  19. package/lib/core/integration-files.js +32 -3
  20. package/lib/core/shared-bar.js +603 -0
  21. package/lib/core/statusline-git.js +179 -15
  22. package/lib/core/terminal.js +25 -7
  23. package/lib/core/tmux-status.js +172 -0
  24. package/lib/core/uninstall.js +20 -7
  25. package/lib/core/usage-store.js +85 -0
  26. package/lib/hud/launcher.js +29 -31
  27. package/lib/platforms/linux/hud.js +1 -1
  28. package/lib/platforms/linux/panel.js +1 -1
  29. package/lib/platforms/macos/hud.js +5 -5
  30. package/lib/platforms/process-scanner.js +77 -29
  31. package/lib/platforms/windows/autostart-cleanup.js +1 -1
  32. package/lib/platforms/windows/codex-runner.js +178 -21
  33. package/lib/platforms/windows/hud/controls.ps1 +44 -10
  34. package/lib/platforms/windows/hud/main.ps1 +350 -43
  35. package/lib/platforms/windows/hud/rendering.ps1 +1227 -1
  36. package/lib/platforms/windows/hud/snapshot.ps1 +26 -46
  37. package/lib/platforms/windows/hud-launcher.js +153 -79
  38. package/lib/platforms/windows/shared-bar-platform.js +972 -0
  39. package/lib/platforms/windows/terminal-compositor.js +210 -25
  40. package/lib/platforms/windows/wt-bar.js +729 -0
  41. package/lib/platforms/windows/wt-fragment.js +665 -0
  42. package/lib/platforms/windows/wt-keybinding.js +300 -0
  43. package/lib/providers/antigravity.js +155 -8
  44. package/package.json +5 -2
  45. package/vendor/PaneContext.cs +875 -0
@@ -1,5 +1,33 @@
1
1
  export const PROVIDERS = ["codex", "claude", "antigravity"];
2
2
  export const STATUS_LINE_ITEMS = ["model-with-reasoning", "current-dir", "git-branch", "branch-changes", "context-remaining"];
3
+ export const SPLIT_BAR_MODES = ["auto", "manual", "off"];
4
+ export const BAR_POSITIONS = ["bottom", "top", "left", "right"];
5
+ export const DEFAULT_SIDEBAR_WIDTH = 5;
6
+ export const MIN_SIDEBAR_WIDTH = 5;
7
+ export const MAX_SIDEBAR_WIDTH = 5;
8
+
9
+ export function normalizeSidebarWidth(value, fallback = DEFAULT_SIDEBAR_WIDTH) {
10
+ const num = Number(value);
11
+ if (!Number.isFinite(num)) return fallback;
12
+ return Math.max(MIN_SIDEBAR_WIDTH, Math.min(MAX_SIDEBAR_WIDTH, Math.round(num)));
13
+ }
14
+
15
+ export function normalizeSplitBarMode(value, fallback = "auto") {
16
+ if (typeof value !== "string") return fallback;
17
+ const normalized = value.trim().toLowerCase();
18
+ if (normalized === "on") return "auto";
19
+ return SPLIT_BAR_MODES.includes(normalized) ? normalized : fallback;
20
+ }
21
+
22
+ export function normalizeBarPosition(value, fallback = "bottom") {
23
+ if (typeof value !== "string") return fallback;
24
+ const normalized = value.trim().toLowerCase();
25
+ if (normalized === "down" || normalized === "b") return "bottom";
26
+ if (normalized === "up" || normalized === "t") return "top";
27
+ if (normalized === "l") return "left";
28
+ if (normalized === "r") return "right";
29
+ return BAR_POSITIONS.includes(normalized) ? normalized : fallback;
30
+ }
3
31
 
4
32
  export function providerId(value) {
5
33
  return value === "gemini" || value === "agy" ? "antigravity" : value;
@@ -24,6 +52,23 @@ export function orderResults(results, order) {
24
52
  return [...results].sort((a, b) => providers.indexOf(a.provider) - providers.indexOf(b.provider));
25
53
  }
26
54
 
55
+ export function defaultDisplayConfig() {
56
+ return {
57
+ version: 1,
58
+ providers: Object.fromEntries(PROVIDERS.map(provider => [provider, true])),
59
+ providerOrder: [...PROVIDERS],
60
+ splitBar: "auto",
61
+ barPosition: "bottom",
62
+ splitBarPosition: null,
63
+ sidebarWidth: DEFAULT_SIDEBAR_WIDTH
64
+ };
65
+ }
66
+
67
+ export function isDisplayConfig(value) {
68
+ return Boolean(value && typeof value === "object" && !Array.isArray(value) && value.version === 1
69
+ && (Object.hasOwn(value, "providers") || Object.hasOwn(value, "providerOrder") || Object.hasOwn(value, "splitBar") || Object.hasOwn(value, "barPosition") || Object.hasOwn(value, "splitBarPosition") || Object.hasOwn(value, "sidebarWidth")));
70
+ }
71
+
27
72
  export function providerLabel(provider) {
28
73
  return { codex: "Codex", claude: "Claude", antigravity: "Gemini", ai: "AI" }[provider] || provider;
29
74
  }
@@ -9,7 +9,13 @@ export function createIntegrationFiles({ readConfig, writeConfig, writeTextAtomi
9
9
  function checkTarget(file, record) {
10
10
  let stat;
11
11
  try { stat = fs.lstatSync(file); } catch (error) { if (error.code === "ENOENT") return; throw error; }
12
- if ((record?.target && fs.realpathSync(file) !== record.target) || (!record?.target && stat.isSymbolicLink())) {
12
+ let resolved = null;
13
+ if (record?.target) {
14
+ try { resolved = fs.realpathSync(file); } catch {
15
+ throw new Error(`Integration symlink target changed; left untouched: ${file}`);
16
+ }
17
+ }
18
+ if ((record?.target && resolved !== record.target) || (!record?.target && stat.isSymbolicLink())) {
13
19
  throw new Error(`Integration symlink target changed; left untouched: ${file}`);
14
20
  }
15
21
  }
@@ -39,6 +45,15 @@ export function createIntegrationFiles({ readConfig, writeConfig, writeTextAtomi
39
45
  const config = readConfig({ strict: true });
40
46
  const previous = config.integrationFiles?.[key(file)];
41
47
  if (previous) checkTarget(file, previous);
48
+ else {
49
+ let stat = null;
50
+ try { stat = fs.lstatSync(file); } catch (error) { if (error.code !== "ENOENT") throw error; }
51
+ if (stat?.isSymbolicLink()) {
52
+ try { fs.realpathSync(file); } catch {
53
+ throw new Error(`Refusing to replace dangling symlink: ${file}`);
54
+ }
55
+ }
56
+ }
42
57
  const current = read(file);
43
58
  if (previous && current !== null) {
44
59
  checkTarget(file, previous);
@@ -54,9 +69,23 @@ export function createIntegrationFiles({ readConfig, writeConfig, writeTextAtomi
54
69
  installedText: next,
55
70
  block
56
71
  };
57
- config.integrationFiles = { ...config.integrationFiles, [key(file)]: record };
72
+ const previousFiles = config.integrationFiles;
73
+ config.integrationFiles = { ...previousFiles, [key(file)]: record };
58
74
  writeConfig(config);
59
- writeTextAtomic(file, next, mode);
75
+ try {
76
+ writeTextAtomic(file, next, mode);
77
+ } catch (error) {
78
+ try {
79
+ if (previous) config.integrationFiles = { ...previousFiles, [key(file)]: previous };
80
+ else if (previousFiles) {
81
+ const restored = { ...previousFiles };
82
+ delete restored[key(file)];
83
+ config.integrationFiles = restored;
84
+ } else delete config.integrationFiles;
85
+ writeConfig(config);
86
+ } catch { /* Preserve the original write error. */ }
87
+ throw error;
88
+ }
60
89
  }
61
90
  function removeManagedText(file, fallback) {
62
91
  const config = readConfig({ strict: true });