ai-battery 0.1.28 → 0.2.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.
- package/README.md +82 -323
- package/bin/ai-battery-run +8 -6
- package/docs/REFERENCE.md +78 -0
- package/docs/RELEASING.md +22 -7
- package/docs/antigravity-icon.svg +76 -0
- package/docs/claude-statusline-preview.svg +1 -2
- package/docs/hud-preview.svg +144 -0
- package/docs/terminal-preview.svg +54 -44
- package/lib/cli.js +198 -88
- package/lib/core/cli-help.js +38 -24
- package/lib/core/cli-output.js +24 -4
- package/lib/core/config-editor.js +135 -0
- package/lib/core/display-config.js +29 -0
- package/lib/core/statusline-git.js +47 -0
- package/lib/core/uninstall.js +3 -3
- package/lib/platforms/linux/gnome-control.js +7 -2
- package/lib/platforms/linux/gnome-uuid.js +3 -0
- package/lib/platforms/linux/gnome.js +42 -19
- package/lib/platforms/linux/hud.js +3 -2
- package/lib/platforms/macos/hud.js +3 -2
- package/lib/platforms/process-scanner.js +2 -1
- package/lib/platforms/ui-language.js +41 -0
- package/lib/platforms/windows/codex-runner.js +7 -6
- package/lib/platforms/windows/hud/controls.ps1 +95 -73
- package/lib/platforms/windows/hud/main.ps1 +74 -55
- package/lib/platforms/windows/hud/rendering.ps1 +6 -1
- package/lib/platforms/windows/hud/snapshot.ps1 +23 -0
- package/lib/providers/antigravity.js +167 -0
- package/package.json +4 -2
- package/scripts/linux-gnome-menu-check.mjs +1 -0
- package/scripts/linux-gnome-menu-smoke.js +11 -2
- package/lib/README.md +0 -23
|
@@ -21,7 +21,7 @@ param(
|
|
|
21
21
|
[Int64]$DockWindowHandle = 0,
|
|
22
22
|
[Int64]$DockSession = 0,
|
|
23
23
|
[int]$DockOwnerPid = 0,
|
|
24
|
-
[ValidateSet("", "codex", "claude")]
|
|
24
|
+
[ValidateSet("", "codex", "claude", "antigravity")]
|
|
25
25
|
[string]$DockProvider = "",
|
|
26
26
|
[string]$DockMarkerPath = "",
|
|
27
27
|
[ValidateSet("bottom", "tabs")]
|
|
@@ -380,8 +380,7 @@ $script:initialHudSnapshot = Read-InitialHudSnapshot
|
|
|
380
380
|
|
|
381
381
|
if ($Once) {
|
|
382
382
|
$texts = Get-Texts
|
|
383
|
-
|
|
384
|
-
if ($texts.ClaudeVisible) { Write-Output "$($texts.Claude.Prefix)[battery]$($texts.Claude.Suffix)" }
|
|
383
|
+
foreach ($row in $texts.Rows) { Write-Output "$($row.Parts.Prefix)[battery]$($row.Parts.Suffix)" }
|
|
385
384
|
exit 0
|
|
386
385
|
}
|
|
387
386
|
|
|
@@ -411,6 +410,9 @@ if ($Mode -eq "tray") {
|
|
|
411
410
|
$claudeRow = New-StatusMenuRow $trayFont
|
|
412
411
|
$menu.Items.Add($codexRow.Host) | Out-Null
|
|
413
412
|
$menu.Items.Add($claudeRow.Host) | Out-Null
|
|
413
|
+
$antigravityRow = New-StatusMenuRow $trayFont
|
|
414
|
+
$menu.Items.Add($antigravityRow.Host) | Out-Null
|
|
415
|
+
$trayRows = @{ codex = $codexRow; claude = $claudeRow; antigravity = $antigravityRow }
|
|
414
416
|
$menu.Items.Add("-") | Out-Null
|
|
415
417
|
$refreshItem = $menu.Items.Add("Refresh")
|
|
416
418
|
$exitItem = $menu.Items.Add("Exit")
|
|
@@ -431,11 +433,8 @@ if ($Mode -eq "tray") {
|
|
|
431
433
|
if ($oldIcon) { $oldIcon.Dispose() }
|
|
432
434
|
|
|
433
435
|
$shortParts = @()
|
|
434
|
-
|
|
435
|
-
$shortParts += $(if ($null -ne $
|
|
436
|
-
}
|
|
437
|
-
if ($Texts.ClaudeVisible) {
|
|
438
|
-
$shortParts += $(if ($null -ne $Texts.ClaudeResult.percentRemaining) { "Claude $($Texts.ClaudeResult.percentRemaining)%" } else { "Claude --%" })
|
|
436
|
+
foreach ($row in $Texts.Rows) {
|
|
437
|
+
$shortParts += $(if ($null -ne $row.Result.percentRemaining) { "$($row.Name) $($row.Result.percentRemaining)%" } else { "$($row.Name) --%" })
|
|
439
438
|
}
|
|
440
439
|
$notifyIcon.Text = Limit-Text "AI Battery: $($shortParts -join ', ')" 63
|
|
441
440
|
}
|
|
@@ -443,15 +442,21 @@ if ($Mode -eq "tray") {
|
|
|
443
442
|
function Update-Tray {
|
|
444
443
|
try {
|
|
445
444
|
$texts = Get-Texts
|
|
446
|
-
$
|
|
447
|
-
$
|
|
448
|
-
$
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
445
|
+
foreach ($entry in $trayRows.Values) { $entry.Host.Visible = $false }
|
|
446
|
+
$lines = @()
|
|
447
|
+
$index = 0
|
|
448
|
+
foreach ($row in $texts.Rows) {
|
|
449
|
+
$entry = $trayRows[$row.Provider]
|
|
450
|
+
if (-not $entry) { continue }
|
|
451
|
+
$entry.Host.Visible = $true
|
|
452
|
+
$menu.Items.Remove($entry.Host)
|
|
453
|
+
$menu.Items.Insert($index, $entry.Host)
|
|
454
|
+
Set-StatusMenuRow $entry $row.Parts
|
|
455
|
+
$lines += Get-LineText $row.Parts
|
|
456
|
+
$index += 1
|
|
457
|
+
}
|
|
453
458
|
Set-SingleNotifyIcon $texts
|
|
454
|
-
$script:lastBalloonText =
|
|
459
|
+
$script:lastBalloonText = $lines -join "`n"
|
|
455
460
|
} catch {
|
|
456
461
|
Set-StatusMenuRow $codexRow @{
|
|
457
462
|
Prefix = "Codex "
|
|
@@ -486,6 +491,7 @@ if ($Mode -eq "tray") {
|
|
|
486
491
|
$notifyIcon.Visible = $false
|
|
487
492
|
Dispose-StatusMenuRow $codexRow
|
|
488
493
|
Dispose-StatusMenuRow $claudeRow
|
|
494
|
+
Dispose-StatusMenuRow $antigravityRow
|
|
489
495
|
if ($notifyIcon.Icon) { $notifyIcon.Icon.Dispose() }
|
|
490
496
|
$notifyIcon.Dispose()
|
|
491
497
|
$trayFont.Dispose()
|
|
@@ -523,6 +529,7 @@ $script:dockTuiResponsiveLayoutName = ""
|
|
|
523
529
|
$script:dockTuiResponsiveThresholds = ""
|
|
524
530
|
$script:dockOuterBorderColor = [System.Drawing.Color]::FromArgb(72, 72, 72)
|
|
525
531
|
$form = New-Object System.Windows.Forms.Form
|
|
532
|
+
Enable-HudDoubleBuffering $form
|
|
526
533
|
$form.Text = "AI Battery"
|
|
527
534
|
$form.AutoScaleMode = [System.Windows.Forms.AutoScaleMode]::None
|
|
528
535
|
$form.StartPosition = [System.Windows.Forms.FormStartPosition]::Manual
|
|
@@ -593,8 +600,9 @@ $font = New-HudMainFont
|
|
|
593
600
|
$symbolFont = New-HudSymbolFont
|
|
594
601
|
|
|
595
602
|
$panel = New-Object System.Windows.Forms.TableLayoutPanel
|
|
603
|
+
Enable-HudDoubleBuffering $panel
|
|
596
604
|
$panel.Dock = [System.Windows.Forms.DockStyle]::Fill
|
|
597
|
-
$panel.RowCount = $(if ($script:dockTuiStatusline) { 1 } else {
|
|
605
|
+
$panel.RowCount = $(if ($script:dockTuiStatusline) { 1 } else { 3 })
|
|
598
606
|
$panel.ColumnCount = 1
|
|
599
607
|
$panel.GrowStyle = [System.Windows.Forms.TableLayoutPanelGrowStyle]::FixedSize
|
|
600
608
|
$panel.Padding = if ($script:dockTuiStatusline) {
|
|
@@ -608,11 +616,13 @@ $panel.BackColor = $script:hudSurfaceBackColor
|
|
|
608
616
|
$panel.RowStyles.Add([System.Windows.Forms.RowStyle]::new([System.Windows.Forms.SizeType]::Percent, $(if ($script:dockTuiStatusline) { 100 } else { 50 }))) | Out-Null
|
|
609
617
|
if (-not $script:dockTuiStatusline) {
|
|
610
618
|
$panel.RowStyles.Add([System.Windows.Forms.RowStyle]::new([System.Windows.Forms.SizeType]::Percent, 50)) | Out-Null
|
|
619
|
+
$panel.RowStyles.Add([System.Windows.Forms.RowStyle]::new([System.Windows.Forms.SizeType]::Absolute, 0)) | Out-Null
|
|
611
620
|
}
|
|
612
621
|
$panel.ColumnStyles.Add([System.Windows.Forms.ColumnStyle]::new([System.Windows.Forms.SizeType]::Percent, 100)) | Out-Null
|
|
613
622
|
|
|
614
623
|
function New-HudRow {
|
|
615
624
|
$row = New-Object System.Windows.Forms.FlowLayoutPanel
|
|
625
|
+
Enable-HudDoubleBuffering $row
|
|
616
626
|
$row.Dock = [System.Windows.Forms.DockStyle]::Fill
|
|
617
627
|
$row.FlowDirection = [System.Windows.Forms.FlowDirection]::LeftToRight
|
|
618
628
|
$row.WrapContents = $false
|
|
@@ -730,7 +740,7 @@ function Get-TuiTextWidth([string]$Value, $DrawFont) {
|
|
|
730
740
|
return [int]$size.Width
|
|
731
741
|
}
|
|
732
742
|
|
|
733
|
-
function Get-TuiProviderDisplayValues($Result, [string]$Name, [int]$BarWidth, [bool]$ShowWindows) {
|
|
743
|
+
function Get-TuiProviderDisplayValues($Result, [string]$Name, [int]$BarWidth, [bool]$ShowWindows, [bool]$PrimaryOnly = $false) {
|
|
734
744
|
$percent = if ($Result -and $Result.ok -and $null -ne $Result.percentRemaining) { [int]$Result.percentRemaining } else { $null }
|
|
735
745
|
$values = [ordered]@{
|
|
736
746
|
Prefix = $Name + " "
|
|
@@ -742,7 +752,7 @@ function Get-TuiProviderDisplayValues($Result, [string]$Name, [int]$BarWidth, [b
|
|
|
742
752
|
if ($ShowWindows -and $Result -and $Result.primary) {
|
|
743
753
|
$values.Primary = "$(Get-WindowText $Result.primary.windowMinutes) $(Get-ResetClock $Result.primary)"
|
|
744
754
|
}
|
|
745
|
-
if ($ShowWindows -and $Result -and $Result.secondary) {
|
|
755
|
+
if ($ShowWindows -and -not $PrimaryOnly -and $Result -and $Result.secondary) {
|
|
746
756
|
$values.Secondary = "$(Get-WindowText $Result.secondary.windowMinutes) $([int]$Result.secondary.remainingPercent)%"
|
|
747
757
|
if ($Result.secondary.remainingPercent -le 10 -and -not $Result.secondary.resetPassed) {
|
|
748
758
|
$values.Secondary += " $(Get-ResetClock $Result.secondary)"
|
|
@@ -751,8 +761,8 @@ function Get-TuiProviderDisplayValues($Result, [string]$Name, [int]$BarWidth, [b
|
|
|
751
761
|
return [PSCustomObject]$values
|
|
752
762
|
}
|
|
753
763
|
|
|
754
|
-
function Get-TuiProviderDisplayWidth($Result, [string]$Name, $DrawFont, [int]$BarWidth, [bool]$ShowWindows) {
|
|
755
|
-
$values = Get-TuiProviderDisplayValues $Result $Name $BarWidth $ShowWindows
|
|
764
|
+
function Get-TuiProviderDisplayWidth($Result, [string]$Name, $DrawFont, [int]$BarWidth, [bool]$ShowWindows, [bool]$PrimaryOnly = $false) {
|
|
765
|
+
$values = Get-TuiProviderDisplayValues $Result $Name $BarWidth $ShowWindows $PrimaryOnly
|
|
756
766
|
$width = (Get-TuiTextWidth $values.Prefix $DrawFont) +
|
|
757
767
|
(Get-TuiTextWidth $values.Bar $DrawFont) +
|
|
758
768
|
(Get-TuiTextWidth $values.Percent $DrawFont)
|
|
@@ -766,38 +776,32 @@ function Get-TuiProviderDisplayWidth($Result, [string]$Name, $DrawFont, [int]$Ba
|
|
|
766
776
|
return $width
|
|
767
777
|
}
|
|
768
778
|
|
|
769
|
-
function Get-DockedTuiResponsiveLayout($
|
|
770
|
-
#
|
|
771
|
-
#
|
|
772
|
-
# summary still fits at Windows Terminal's minimum practical width.
|
|
779
|
+
function Get-DockedTuiResponsiveLayout($Results, $DrawFont, [int]$AvailableWidth) {
|
|
780
|
+
# Match the text TUI: 10/5 cells with both windows, 5 cells with 5h only,
|
|
781
|
+
# then 10/5/4-cell summaries. Each stage must fit its actual content.
|
|
773
782
|
$candidates = @(
|
|
774
783
|
[PSCustomObject]@{ Name = "full"; BarWidth = 10; ShowWindows = $true },
|
|
775
784
|
[PSCustomObject]@{ Name = "metrics-half"; BarWidth = 5; ShowWindows = $true },
|
|
776
|
-
[PSCustomObject]@{ Name = "
|
|
785
|
+
[PSCustomObject]@{ Name = "primary-half"; BarWidth = 5; ShowWindows = $true; PrimaryOnly = $true },
|
|
786
|
+
[PSCustomObject]@{ Name = "summary-full"; BarWidth = 10; ShowWindows = $false },
|
|
787
|
+
[PSCustomObject]@{ Name = "summary-half"; BarWidth = 5; ShowWindows = $false },
|
|
788
|
+
[PSCustomObject]@{ Name = "summary-min"; BarWidth = 4; ShowWindows = $false }
|
|
777
789
|
)
|
|
778
|
-
$providerDividerWidth =
|
|
790
|
+
$providerDividerWidth = [math]::Max(0, @($Results).Count - 1) * (Get-TuiTextWidth " $([char]0x2503) " $DrawFont)
|
|
779
791
|
$requiredWidths = @()
|
|
780
792
|
foreach ($candidate in $candidates) {
|
|
781
793
|
$required = $providerDividerWidth
|
|
782
|
-
|
|
783
|
-
$required += Get-TuiProviderDisplayWidth $
|
|
784
|
-
}
|
|
785
|
-
if ($Claude) {
|
|
786
|
-
$required += Get-TuiProviderDisplayWidth $Claude "Claude" $DrawFont $candidate.BarWidth $candidate.ShowWindows
|
|
794
|
+
foreach ($result in $Results) {
|
|
795
|
+
$required += Get-TuiProviderDisplayWidth $result (Get-ProviderLabel $result.provider) $DrawFont $candidate.BarWidth $candidate.ShowWindows ([bool]$candidate.PrimaryOnly)
|
|
787
796
|
}
|
|
788
797
|
$requiredWidths += $required
|
|
789
798
|
}
|
|
790
799
|
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
$metricsHalfThreshold = [math]::Max($requiredWidths[1], [int][math]::Ceiling($requiredWidths[0] * 0.98))
|
|
797
|
-
$script:dockTuiResponsiveThresholds = "$fullThreshold,$metricsHalfThreshold"
|
|
798
|
-
if ($AvailableWidth -ge $fullThreshold) { return $candidates[0] }
|
|
799
|
-
if ($AvailableWidth -ge $metricsHalfThreshold) { return $candidates[1] }
|
|
800
|
-
return $candidates[2]
|
|
800
|
+
$script:dockTuiResponsiveThresholds = $requiredWidths -join ","
|
|
801
|
+
for ($i = 0; $i -lt $candidates.Count; $i += 1) {
|
|
802
|
+
if ($AvailableWidth -ge $requiredWidths[$i]) { return $candidates[$i] }
|
|
803
|
+
}
|
|
804
|
+
return $candidates[-1]
|
|
801
805
|
}
|
|
802
806
|
|
|
803
807
|
function Draw-TuiProvider($Graphics, $Result, [string]$Name, [ref]$X, [int]$Y, $DrawFont, $Layout) {
|
|
@@ -810,7 +814,7 @@ function Draw-TuiProvider($Graphics, $Result, [string]$Name, [ref]$X, [int]$Y, $
|
|
|
810
814
|
$filled = if ($null -ne $percent) { [int][math]::Round(($clamped / 100.0) * $barWidth) } else { 0 }
|
|
811
815
|
if ($clamped -gt 0 -and $filled -eq 0) { $filled = 1 }
|
|
812
816
|
$barGlyph = [string][char]0x275A
|
|
813
|
-
$values = Get-TuiProviderDisplayValues $Result $Name $barWidth ([bool]$Layout.ShowWindows)
|
|
817
|
+
$values = Get-TuiProviderDisplayValues $Result $Name $barWidth ([bool]$Layout.ShowWindows) ([bool]$Layout.PrimaryOnly)
|
|
814
818
|
|
|
815
819
|
Draw-TuiSegment $Graphics $values.Prefix $textColor $X $Y $DrawFont
|
|
816
820
|
$barStart = [int]$X.Value
|
|
@@ -834,7 +838,8 @@ function Draw-TuiProvider($Graphics, $Result, [string]$Name, [ref]$X, [int]$Y, $
|
|
|
834
838
|
|
|
835
839
|
function Get-DockedTuiProviderRunning($Result, [string]$Name) {
|
|
836
840
|
if ($script:dockTuiStatusline -and $script:dockSessionTrackingEnabled) {
|
|
837
|
-
|
|
841
|
+
$provider = if ($Result -and $Result.provider) { $Result.provider } else { $Name }
|
|
842
|
+
return Test-DockProviderActiveForTarget $provider ([Int64]$script:dockTargetHandle)
|
|
838
843
|
}
|
|
839
844
|
return [bool]($Result -and $Result.running)
|
|
840
845
|
}
|
|
@@ -842,13 +847,11 @@ function Get-DockedTuiProviderRunning($Result, [string]$Name) {
|
|
|
842
847
|
function Draw-DockedTuiStatusline($Graphics, [int]$Width, [int]$Height) {
|
|
843
848
|
$snapshot = $script:latestSnapshot
|
|
844
849
|
if (-not $snapshot -or -not $snapshot.results) { return }
|
|
845
|
-
$codex = Get-Provider $snapshot "codex"
|
|
846
|
-
$claude = Get-Provider $snapshot "claude"
|
|
847
850
|
$xValue = Scale-HudValue 15
|
|
848
851
|
$x = [ref]$xValue
|
|
849
852
|
$rightPadding = Scale-HudValue 10
|
|
850
853
|
$availableWidth = [math]::Max(1, $Width - $xValue - $rightPadding)
|
|
851
|
-
$layout = Get-DockedTuiResponsiveLayout $
|
|
854
|
+
$layout = Get-DockedTuiResponsiveLayout $snapshot.results $font $availableWidth
|
|
852
855
|
if ($script:dockTuiResponsiveLayoutName -ne $layout.Name) {
|
|
853
856
|
$script:dockTuiResponsiveLayoutName = $layout.Name
|
|
854
857
|
if (Get-Command Write-HudDockDebug -ErrorAction SilentlyContinue) {
|
|
@@ -858,11 +861,12 @@ function Draw-DockedTuiStatusline($Graphics, [int]$Width, [int]$Height) {
|
|
|
858
861
|
$visibleTop = [math]::Max(0, [int]$script:dockJoinOverlap - (Scale-HudValue 2))
|
|
859
862
|
$visibleHeight = [math]::Max(1, $Height - $visibleTop)
|
|
860
863
|
$y = $visibleTop + [math]::Max(0, [int][math]::Floor(($visibleHeight - $font.Height) / 2) - 1)
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
Draw-TuiSegment $Graphics " $([char]0x2503) " ([System.Drawing.Color]::FromArgb(150, 150, 150)) $x $y $font
|
|
864
|
+
$index = 0
|
|
865
|
+
foreach ($result in $snapshot.results) {
|
|
866
|
+
if ($index -gt 0) { Draw-TuiSegment $Graphics " $([char]0x2503) " ([System.Drawing.Color]::FromArgb(150, 150, 150)) $x $y $font }
|
|
867
|
+
Draw-TuiProvider $Graphics $result (Get-ProviderLabel $result.provider) $x $y $font $layout
|
|
868
|
+
$index += 1
|
|
864
869
|
}
|
|
865
|
-
if ($claude) { Draw-TuiProvider $Graphics $claude "Claude" $x $y $font $layout }
|
|
866
870
|
}
|
|
867
871
|
|
|
868
872
|
$script:dockTuiRenderKey = $null
|
|
@@ -870,8 +874,8 @@ $script:dockTuiRenderKey = $null
|
|
|
870
874
|
function Get-DockedTuiRenderKey($Snapshot) {
|
|
871
875
|
if (-not $Snapshot -or -not $Snapshot.results) { return "empty" }
|
|
872
876
|
$parts = @()
|
|
873
|
-
foreach ($
|
|
874
|
-
$
|
|
877
|
+
foreach ($result in $Snapshot.results) {
|
|
878
|
+
$name = $result.provider
|
|
875
879
|
if (-not $result) { $parts += "$name`:missing"; continue }
|
|
876
880
|
$primary = if ($result.primary) {
|
|
877
881
|
"$(Get-WindowText $result.primary.windowMinutes):$(Get-ResetClock $result.primary)"
|
|
@@ -932,6 +936,7 @@ function Draw-DockedTuiOuterBorder($Graphics, [int]$Width, [int]$Height) {
|
|
|
932
936
|
|
|
933
937
|
$codexRow = New-HudRow
|
|
934
938
|
$claudeRow = New-HudRow
|
|
939
|
+
$antigravityRow = New-HudRow
|
|
935
940
|
$codexPrefixLabel = New-HudLabel
|
|
936
941
|
$codexIconLabel = New-HudIconBox
|
|
937
942
|
$codexDivider1 = New-HudDivider
|
|
@@ -960,6 +965,14 @@ foreach ($label in @($codexIconLabel, $claudeIconLabel)) {
|
|
|
960
965
|
$codexHudControls = @($codexPrefixLabel, $codexIconLabel, $codexDivider1, $codexResetLabel, $codexDivider2, $codexWeekLabel, $codexExtraLabel)
|
|
961
966
|
$claudeHudControls = @($claudePrefixLabel, $claudeIconLabel, $claudeDivider1, $claudeResetLabel, $claudeDivider2, $claudeWeekLabel, $claudeExtraLabel)
|
|
962
967
|
|
|
968
|
+
$antigravityHudControls = @((New-HudLabel), (New-HudIconBox), (New-HudDivider), (New-HudLabel), (New-HudDivider), (New-HudLabel), (New-HudLabel))
|
|
969
|
+
$script:hudProviderRows = @{
|
|
970
|
+
codex = @{ Row = $codexRow; Controls = $codexHudControls }
|
|
971
|
+
claude = @{ Row = $claudeRow; Controls = $claudeHudControls }
|
|
972
|
+
antigravity = @{ Row = $antigravityRow; Controls = $antigravityHudControls }
|
|
973
|
+
}
|
|
974
|
+
$script:hudVisibleProviders = @("codex", "claude")
|
|
975
|
+
|
|
963
976
|
function Test-PointInBounds($Bounds, [System.Drawing.Point]$Point) {
|
|
964
977
|
if (-not $Bounds) { return $false }
|
|
965
978
|
return $Bounds.Contains($Point)
|
|
@@ -994,6 +1007,11 @@ foreach ($label in $claudeHudControls) {
|
|
|
994
1007
|
$label.ContextMenuStrip = $menu
|
|
995
1008
|
$claudeRow.Controls.Add($label) | Out-Null
|
|
996
1009
|
}
|
|
1010
|
+
foreach ($control in $antigravityHudControls) {
|
|
1011
|
+
$control.ContextMenuStrip = $menu
|
|
1012
|
+
$antigravityRow.Controls.Add($control) | Out-Null
|
|
1013
|
+
}
|
|
1014
|
+
$antigravityRow.ContextMenuStrip = $menu
|
|
997
1015
|
$codexRow.ContextMenuStrip = $menu
|
|
998
1016
|
$claudeRow.ContextMenuStrip = $menu
|
|
999
1017
|
$providerDivider.ContextMenuStrip = $menu
|
|
@@ -1020,6 +1038,7 @@ if ($script:dockTuiStatusline) {
|
|
|
1020
1038
|
} else {
|
|
1021
1039
|
$panel.Controls.Add($codexRow, 0, 0) | Out-Null
|
|
1022
1040
|
$panel.Controls.Add($claudeRow, 0, 1) | Out-Null
|
|
1041
|
+
$panel.Controls.Add($antigravityRow, 0, 2) | Out-Null
|
|
1023
1042
|
}
|
|
1024
1043
|
if ($script:dockTuiStatusline) {
|
|
1025
1044
|
$form.Controls.Add($script:dockTuiPaintPanel)
|
|
@@ -1138,7 +1157,7 @@ function Save-HudPositionIfReady {
|
|
|
1138
1157
|
}
|
|
1139
1158
|
|
|
1140
1159
|
if ($canMove) {
|
|
1141
|
-
$dragControls = @($form, $panel, $codexRow, $claudeRow) + $codexHudControls + $claudeHudControls
|
|
1160
|
+
$dragControls = @($form, $panel, $codexRow, $claudeRow, $antigravityRow) + $codexHudControls + $claudeHudControls + $antigravityHudControls
|
|
1142
1161
|
if ($hitForm) { $dragControls += $hitForm }
|
|
1143
1162
|
foreach ($control in $dragControls) {
|
|
1144
1163
|
$control.add_MouseDown($mouseDown)
|
|
@@ -1307,7 +1326,7 @@ $form.add_FormClosed({
|
|
|
1307
1326
|
$menuAutoHideTimer.Dispose()
|
|
1308
1327
|
Stop-FullscreenEventHooks
|
|
1309
1328
|
Stop-SnapshotFetch
|
|
1310
|
-
foreach ($box in @($codexIconLabel, $claudeIconLabel)) {
|
|
1329
|
+
foreach ($box in @($codexIconLabel, $claudeIconLabel, $antigravityHudControls[1])) {
|
|
1311
1330
|
if ($box.Image) {
|
|
1312
1331
|
$box.Image.Dispose()
|
|
1313
1332
|
$box.Image = $null
|
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
function Enable-HudDoubleBuffering($Control) {
|
|
2
|
+
$property = [System.Windows.Forms.Control].GetProperty("DoubleBuffered", [System.Reflection.BindingFlags]::Instance -bor [System.Reflection.BindingFlags]::NonPublic)
|
|
3
|
+
$property.SetValue($Control, $true, $null)
|
|
4
|
+
}
|
|
5
|
+
|
|
1
6
|
function Get-HudDpi {
|
|
2
7
|
try {
|
|
3
8
|
if ($DockWindowHandle -ne 0) {
|
|
@@ -96,7 +101,7 @@ function Limit-Text([string]$Text, [int]$MaxLength) {
|
|
|
96
101
|
|
|
97
102
|
function Select-TrayPercent($Texts) {
|
|
98
103
|
$items = @()
|
|
99
|
-
foreach ($result in @($Texts.CodexResult, $Texts.ClaudeResult)) {
|
|
104
|
+
foreach ($result in @($Texts.CodexResult, $Texts.ClaudeResult, $Texts.AntigravityResult)) {
|
|
100
105
|
if ($result -and $result.ok -and $null -ne $result.percentRemaining) {
|
|
101
106
|
$items += [PSCustomObject]@{
|
|
102
107
|
Percent = [int]$result.percentRemaining
|
|
@@ -169,6 +169,7 @@ function Format-Parts($Result, [string]$Name) {
|
|
|
169
169
|
$divider = [string][char]0x2502
|
|
170
170
|
if ($Result.primary) {
|
|
171
171
|
$resetWindow = Get-WindowText $Result.primary.windowMinutes
|
|
172
|
+
if ($Result.provider -eq "antigravity" -and -not $Result.primary.windowMinutes) { $resetWindow = $Result.primary.id }
|
|
172
173
|
$resetValue = "$resetWindow $(Get-ResetClock $Result.primary)".PadRight(8)
|
|
173
174
|
$resetText = $resetValue
|
|
174
175
|
}
|
|
@@ -230,6 +231,8 @@ function Merge-HudSnapshot($Snapshot, $CachedSnapshot) {
|
|
|
230
231
|
if ($usable) {
|
|
231
232
|
$current | Add-Member -NotePropertyName "hudCachedAt" -NotePropertyValue $nowUtc.ToString("o") -Force
|
|
232
233
|
}
|
|
234
|
+
# agy readings already come from a local cache; expired buckets must stay unknown.
|
|
235
|
+
if ($current.provider -eq "antigravity") { continue }
|
|
233
236
|
|
|
234
237
|
$cached = $null
|
|
235
238
|
if ($CachedSnapshot) { $cached = Get-Provider $CachedSnapshot $current.provider }
|
|
@@ -265,6 +268,13 @@ function Merge-HudSnapshot($Snapshot, $CachedSnapshot) {
|
|
|
265
268
|
function ConvertTo-HudTexts($Snapshot) {
|
|
266
269
|
$codex = Get-Provider $Snapshot "codex"
|
|
267
270
|
$claude = Get-Provider $Snapshot "claude"
|
|
271
|
+
$antigravity = Get-Provider $Snapshot "antigravity"
|
|
272
|
+
$rows = @()
|
|
273
|
+
foreach ($result in $Snapshot.results) {
|
|
274
|
+
if (-not $result) { continue }
|
|
275
|
+
$name = Get-ProviderLabel $result.provider
|
|
276
|
+
$rows += @{ Provider = $result.provider; Name = $name; Result = $result; Parts = (Format-Parts $result $name) }
|
|
277
|
+
}
|
|
268
278
|
$codexVisible = $null -ne $codex
|
|
269
279
|
$claudeVisible = $null -ne $claude
|
|
270
280
|
return @{
|
|
@@ -274,6 +284,19 @@ function ConvertTo-HudTexts($Snapshot) {
|
|
|
274
284
|
ClaudeResult = $claude
|
|
275
285
|
CodexVisible = $codexVisible
|
|
276
286
|
ClaudeVisible = $claudeVisible
|
|
287
|
+
Antigravity = $(if ($antigravity) { Format-Parts $antigravity "Gemini" } else { $null })
|
|
288
|
+
AntigravityResult = $antigravity
|
|
289
|
+
AntigravityVisible = $null -ne $antigravity
|
|
290
|
+
Rows = $rows
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
function Get-ProviderLabel([string]$Provider) {
|
|
295
|
+
switch ($Provider) {
|
|
296
|
+
"codex" { return "Codex" }
|
|
297
|
+
"claude" { return "Claude" }
|
|
298
|
+
"antigravity" { return "Gemini" }
|
|
299
|
+
default { return $Provider }
|
|
277
300
|
}
|
|
278
301
|
}
|
|
279
302
|
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
import fs from "node:fs";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import { isDeepStrictEqual } from "node:util";
|
|
4
|
+
import { clamp, resetEpochSeconds } from "../core/limits.js";
|
|
5
|
+
|
|
6
|
+
function selectAntigravityLimits(quotas, model, now) {
|
|
7
|
+
const modelName = typeof model === "string" ? model : model?.id || model?.display_name || "";
|
|
8
|
+
const family = /claude|opus|sonnet|haiku|gpt|codex|openai/i.test(modelName)
|
|
9
|
+
? /^(?:3p)(?:[-_]|$)|claude|gpt|openai/i : /gemini/i;
|
|
10
|
+
const normalized = quotas.map(quota => {
|
|
11
|
+
const seconds = resetEpochSeconds(quota.resetsAt);
|
|
12
|
+
const resetsAt = seconds > 0 ? new Date(seconds * 1000).toISOString() : null;
|
|
13
|
+
return { ...quota, resetsAt, resetPassed: resetsAt !== null && seconds <= now / 1000 };
|
|
14
|
+
});
|
|
15
|
+
const matching = normalized.filter(quota => family.test(quota.id));
|
|
16
|
+
// Unrecognized bucket names can be used, but never borrow another model family's quota.
|
|
17
|
+
const candidates = (matching.length ? matching : normalized.filter(quota => !/gemini|^3p(?:[-_]|$)|claude|gpt|openai/i.test(quota.id)))
|
|
18
|
+
.filter(quota => typeof quota.remainingPercent === "number")
|
|
19
|
+
.sort((a, b) => a.remainingPercent - b.remainingPercent || a.id.localeCompare(b.id));
|
|
20
|
+
// Periods have fixed meanings in every renderer: primary is 5h, secondary is 7d.
|
|
21
|
+
const primary = candidates.find(quota => quota.windowMinutes === 300)
|
|
22
|
+
?? candidates.find(quota => !quota.windowMinutes) ?? null;
|
|
23
|
+
const secondary = candidates.find(quota => quota.windowMinutes === 10080 && !quota.resetPassed) ?? null;
|
|
24
|
+
const reading = primary ?? secondary;
|
|
25
|
+
const ok = Boolean(reading && !reading.resetPassed);
|
|
26
|
+
return { quotas: normalized, primary, secondary, ok,
|
|
27
|
+
percentRemaining: ok ? reading.remainingPercent : null,
|
|
28
|
+
percentUsed: ok ? reading.usedPercent : null,
|
|
29
|
+
error: ok ? null : reading?.resetPassed ? "Gemini quota reset; waiting for a fresh payload" : "Gemini quota percentage unavailable" };
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
// https://antigravity.google/docs/cli/statusline
|
|
33
|
+
// agy invokes a shell command, sends JSON on stdin, and accepts ANSI/multiline stdout.
|
|
34
|
+
export function normalizeAntigravityPayload(input, now = Date.now()) {
|
|
35
|
+
const quotas = Object.entries(input.quota || {}).flatMap(([id, value]) => {
|
|
36
|
+
if (!value || typeof value !== "object" || value.disabled === true) return [];
|
|
37
|
+
const fraction = value.remaining_fraction;
|
|
38
|
+
const remainingPercent = typeof fraction === "number" && Number.isFinite(fraction)
|
|
39
|
+
? clamp(Math.round(fraction * 100), 0, 100) : null;
|
|
40
|
+
const resetTime = resetEpochSeconds(value.reset_time);
|
|
41
|
+
const resetSeconds = resetTime > 0 ? resetTime
|
|
42
|
+
: typeof value.reset_in_seconds === "number" && Number.isFinite(value.reset_in_seconds) && value.reset_in_seconds > 0
|
|
43
|
+
? Math.floor(now / 1000 + value.reset_in_seconds) : null;
|
|
44
|
+
return [{ id, remainingPercent, remainingAmount: value.remaining_amount ?? null,
|
|
45
|
+
usedPercent: remainingPercent === null ? null : 100 - remainingPercent,
|
|
46
|
+
windowMinutes: /weekly|7d/i.test(id) ? 10080 : /5h|five.hour/i.test(id) ? 300 : null,
|
|
47
|
+
resetsAt: resetSeconds === null ? null : new Date(resetSeconds * 1000).toISOString(),
|
|
48
|
+
resetPassed: resetSeconds !== null && resetSeconds <= now / 1000 }];
|
|
49
|
+
});
|
|
50
|
+
return {
|
|
51
|
+
provider: "antigravity", sourceType: "statusline", timestamp: new Date(now).toISOString(),
|
|
52
|
+
sessionId: input.session_id || input.conversation_id || null,
|
|
53
|
+
model: typeof input.model === "object" && input.model ? { id: input.model.id, display_name: input.model.display_name, effort: input.model.effort } : input.model || "",
|
|
54
|
+
workspace: input.workspace ? { current_dir: input.workspace.current_dir, project_dir: input.workspace.project_dir } : null,
|
|
55
|
+
contextWindow: input.context_window ? {
|
|
56
|
+
remainingPercentage: input.context_window.remaining_percentage,
|
|
57
|
+
usedPercentage: input.context_window.used_percentage
|
|
58
|
+
} : null,
|
|
59
|
+
agentState: input.agent_state || null,
|
|
60
|
+
...selectAntigravityLimits(quotas, input.model, now)
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export function antigravityStatuslineCommand(scriptPath, flags, shellArg, platform = process.platform) {
|
|
65
|
+
if (platform === "win32") {
|
|
66
|
+
// agy's cmd /c invocation applies Windows argv escaping to the whole
|
|
67
|
+
// command. Embedded path quotes then reach Node as literal quotes. Keep
|
|
68
|
+
// the quoted script path out of the shell arguments and decode it inside
|
|
69
|
+
// Node instead. The plain marker
|
|
70
|
+
// preserves managed-hook detection and the normal CLI argv positions.
|
|
71
|
+
const loader = `process.argv[1]=${JSON.stringify(scriptPath)};import(require('node:url').pathToFileURL(process.argv[1]).href).catch(error=>{console.error(error);process.exitCode=1});`;
|
|
72
|
+
const encoded = Buffer.from(loader, "utf8").toString("base64");
|
|
73
|
+
return ["node", "-e", `eval(Buffer.from('${encoded}','base64').toString())`, "ai-battery.js", "capture-antigravity", ...flags].join(" ");
|
|
74
|
+
}
|
|
75
|
+
return [shellArg(process.execPath), shellArg(scriptPath), "capture-antigravity", ...flags].join(" ");
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
export function createAntigravityIntegration({ homePath, stateDir, readJson, readUserJsonObject, readConfig, writeConfig, writeJsonAtomic, samePath, shellArg, scriptDir, isProviderRunning }) {
|
|
79
|
+
const settingsPath = () => homePath(".gemini", "antigravity-cli", "settings.json");
|
|
80
|
+
const cachePath = () => path.join(stateDir(), "antigravity-statusline.json");
|
|
81
|
+
const backupKey = "antigravityStatusLineBackup";
|
|
82
|
+
const managed = value => typeof value?.command === "string" && value.command.includes("ai-battery.js") && value.command.includes("capture-antigravity");
|
|
83
|
+
|
|
84
|
+
function install(args = {}) {
|
|
85
|
+
const target = settingsPath();
|
|
86
|
+
const settings = readUserJsonObject(target, `Gemini settings at ${target}`);
|
|
87
|
+
if (!settings.ok) return { ok: false, settingsPath: target, error: settings.error };
|
|
88
|
+
const config = readConfig({ strict: true });
|
|
89
|
+
const backup = config[backupKey];
|
|
90
|
+
if (backup?.settingsPath && !samePath(backup.settingsPath, target)) {
|
|
91
|
+
return { ok: false, settingsPath: target, error: `Gemini recovery record belongs to ${backup.settingsPath}; settings preserved` };
|
|
92
|
+
}
|
|
93
|
+
const existing = settings.value.statusLine;
|
|
94
|
+
if (existing?.command && !managed(existing) && !args.force) {
|
|
95
|
+
return { settingsPath: target, skipped: true, reason: "Existing Gemini statusLine preserved. Replace: ai-battery setup gemini --force" };
|
|
96
|
+
}
|
|
97
|
+
const flags = ["--muted", "--left-padding", "1"];
|
|
98
|
+
if (args.header === false) flags.push("--no-header");
|
|
99
|
+
if (args.usageRow === false) flags.push("--no-usage-row");
|
|
100
|
+
if (args.usageRow === true) flags.push("--usage-row");
|
|
101
|
+
const command = antigravityStatuslineCommand(path.join(scriptDir(), "ai-battery.js"), flags, shellArg);
|
|
102
|
+
const next = { type: "command", command, padding: 0, enabled: true, stack_with_default: false };
|
|
103
|
+
if (!backup) config[backupKey] = {
|
|
104
|
+
settingsPath: target, settingsExisted: settings.exists, mode: settings.mode,
|
|
105
|
+
hadStatusLine: Boolean(Object.hasOwn(settings.value, "statusLine") && !managed(existing)),
|
|
106
|
+
statusLine: managed(existing) ? null : existing ?? null, managedStatusLines: []
|
|
107
|
+
};
|
|
108
|
+
const record = config[backupKey];
|
|
109
|
+
record.managedStatusLines ??= [];
|
|
110
|
+
if (!record.managedStatusLines.some(value => isDeepStrictEqual(value, next))) record.managedStatusLines.push(next);
|
|
111
|
+
// Save recovery before changing the settings file.
|
|
112
|
+
writeConfig(config);
|
|
113
|
+
writeJsonAtomic(target, { ...settings.value, statusLine: next }, settings.mode ?? 0o600);
|
|
114
|
+
return { ok: true, changed: !isDeepStrictEqual(existing, next), settingsPath: target, command: next.command, backedUp: !backup };
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
function uninstall() {
|
|
118
|
+
const target = settingsPath();
|
|
119
|
+
const settings = readUserJsonObject(target, `Gemini settings at ${target}`);
|
|
120
|
+
if (!settings.ok) return { settingsPath: target, error: settings.error };
|
|
121
|
+
const config = readConfig({ strict: true });
|
|
122
|
+
const backup = config[backupKey];
|
|
123
|
+
if (backup?.settingsPath && !samePath(backup.settingsPath, target)) return { settingsPath: target, retainedBackup: true, error: "Gemini recovery record belongs to a different HOME" };
|
|
124
|
+
const existing = settings.value.statusLine;
|
|
125
|
+
const restored = backup && (backup.hadStatusLine ? isDeepStrictEqual(existing, backup.statusLine) : !Object.hasOwn(settings.value, "statusLine"));
|
|
126
|
+
if (restored) {
|
|
127
|
+
config[backupKey] = null; writeConfig(config);
|
|
128
|
+
return { settingsPath: target, changed: false, alreadyRestored: true };
|
|
129
|
+
}
|
|
130
|
+
const owned = backup ? backup.managedStatusLines.some(value => isDeepStrictEqual(value, existing)) : managed(existing);
|
|
131
|
+
if (!owned) return { settingsPath: target, changed: false, skipped: Boolean(backup), retainedBackup: Boolean(backup), reason: "Gemini settings changed; settings and recovery record preserved" };
|
|
132
|
+
if (backup?.settingsExisted === false && Object.keys(settings.value).length === 1) fs.rmSync(target, { force: true });
|
|
133
|
+
else {
|
|
134
|
+
const next = { ...settings.value };
|
|
135
|
+
if (backup?.hadStatusLine) next.statusLine = backup.statusLine;
|
|
136
|
+
else delete next.statusLine;
|
|
137
|
+
writeJsonAtomic(target, next, backup?.mode ?? settings.mode ?? 0o600);
|
|
138
|
+
}
|
|
139
|
+
config[backupKey] = null; writeConfig(config);
|
|
140
|
+
return { settingsPath: target, changed: true, restored: Boolean(backup?.hadStatusLine || backup?.settingsExisted) };
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
function capture(input) {
|
|
144
|
+
const snapshot = normalizeAntigravityPayload(input);
|
|
145
|
+
// Deliberately exclude account email and transcript contents from the cache.
|
|
146
|
+
writeJsonAtomic(cachePath(), snapshot);
|
|
147
|
+
return snapshot;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
function read(options = {}) {
|
|
151
|
+
const cached = readJson(cachePath());
|
|
152
|
+
const running = options.runningOverride ?? isProviderRunning("antigravity");
|
|
153
|
+
if (cached?.provider !== "antigravity") return { provider: "antigravity", ok: false, running, error: "Waiting for Gemini statusLine payload", source: cachePath() };
|
|
154
|
+
const limits = Array.isArray(cached.quotas) ? selectAntigravityLimits(cached.quotas, cached.model, Date.now()) : {};
|
|
155
|
+
const snapshot = { ...cached, ...limits, running, source: cachePath(), ageSeconds: Math.max(0, (Date.now() - Date.parse(cached.timestamp)) / 1000) };
|
|
156
|
+
return snapshot;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
function diagnose() {
|
|
160
|
+
const settings = readUserJsonObject(settingsPath(), "Gemini settings");
|
|
161
|
+
const statusLine = settings.value?.statusLine;
|
|
162
|
+
return { providerEnabled: readConfig().providers.antigravity !== false, settingsPath: settingsPath(),
|
|
163
|
+
configured: Boolean(statusLine), managed: managed(statusLine), enabled: statusLine?.enabled !== false,
|
|
164
|
+
cachePath: cachePath(), statuslineCache: readJson(cachePath())?.provider === "antigravity", error: settings.error || null };
|
|
165
|
+
}
|
|
166
|
+
return { install, uninstall, capture, read, diagnose, cachePath, settingsPath };
|
|
167
|
+
}
|
package/package.json
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ai-battery",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "Tiny terminal battery meter for local Codex
|
|
3
|
+
"version": "0.2.0",
|
|
4
|
+
"description": "Tiny terminal battery meter for local Codex, Claude Code and Gemini CLI usage.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"ai",
|
|
8
8
|
"battery",
|
|
9
9
|
"codex",
|
|
10
10
|
"claude",
|
|
11
|
+
"antigravity",
|
|
11
12
|
"statusline",
|
|
12
13
|
"tui",
|
|
13
14
|
"usage"
|
|
@@ -43,6 +44,7 @@
|
|
|
43
44
|
"vendor/rowpty/RowPty.cs",
|
|
44
45
|
"docs/*.svg",
|
|
45
46
|
"docs/RELEASING.md",
|
|
47
|
+
"docs/REFERENCE.md",
|
|
46
48
|
"docs/SETUP-REGRESSION.md",
|
|
47
49
|
"README.md"
|
|
48
50
|
],
|
|
@@ -29,6 +29,7 @@ const env = { ...process.env, HOME: home, CODEX_HOME: codex, LANGUAGE: "ko", GIO
|
|
|
29
29
|
AI_BATTERY_STATE_DIR: path.join(root, "state"), AI_BATTERY_DATA_DIR: path.join(root, "data"),
|
|
30
30
|
AI_BATTERY_SHARED_USAGE_STATE_DIR: path.join(root, "shared"), AI_BATTERY_NO_UPDATE_CHECK: "1",
|
|
31
31
|
AI_BATTERY_MENU_ROOT: root, AI_BATTERY_MENU_SOURCE: runtime, AI_BATTERY_MENU_NODE: process.execPath,
|
|
32
|
+
AI_BATTERY_MENU_UUID: gnomeHudMetadata.uuid,
|
|
32
33
|
AI_BATTERY_MENU_BUS: linuxHudBusName(path.join(root, "state")) };
|
|
33
34
|
for (const key of ["DISPLAY", "WAYLAND_DISPLAY", "GNOME_KEYRING_CONTROL", "GNOME_SETUP_DISPLAY", "SESSION_MANAGER", "DBUS_STARTER_ADDRESS", "DBUS_STARTER_BUS_TYPE"]) delete env[key];
|
|
34
35
|
const on = spawnSync(process.execPath, [path.join(runtime, "bin/ai-battery.js"), "on", "all"], { env, encoding: "utf8" });
|
|
@@ -32,7 +32,7 @@ export async function run() {
|
|
|
32
32
|
const source = GLib.getenv("AI_BATTERY_MENU_SOURCE");
|
|
33
33
|
const node = GLib.getenv("AI_BATTERY_MENU_NODE");
|
|
34
34
|
const name = GLib.getenv("AI_BATTERY_MENU_BUS");
|
|
35
|
-
const uuid =
|
|
35
|
+
const uuid = GLib.getenv("AI_BATTERY_MENU_UUID");
|
|
36
36
|
Main.overview.hide();
|
|
37
37
|
const backend = Gio.Subprocess.new(["gjs", "-m", `${source}/lib/platforms/linux/panel.js`, "--bus-name", name,
|
|
38
38
|
"--node", node, "--snapshot", `${source}/lib/platforms/linux/panel-snapshot.js`, "--state-dir", `${root}/state`, "--provider", "all"],
|
|
@@ -42,6 +42,15 @@ export async function run() {
|
|
|
42
42
|
extension = Main.extensionManager.lookup(uuid)?.stateObj;
|
|
43
43
|
return extension?._panels?.size === 1;
|
|
44
44
|
});
|
|
45
|
+
// GNOME can retain the disabled old UUID after its directory was migrated.
|
|
46
|
+
// Exercise the real controller against Shell and dconf, not a command stub.
|
|
47
|
+
const settings = new Gio.Settings({ schema_id: "org.gnome.shell" });
|
|
48
|
+
const disabled = settings.get_strv("disabled-extensions").filter(value => value !== "ai-battery@hnode.dev");
|
|
49
|
+
settings.set_strv("disabled-extensions", [...disabled, "ai-battery@hnode.dev"]);
|
|
50
|
+
Gio.Settings.sync();
|
|
51
|
+
await command(["gjs", "-m", `${source}/lib/platforms/linux/gnome-control.js`, "enable", uuid]);
|
|
52
|
+
await until(() => !settings.get_strv("disabled-extensions").includes("ai-battery@hnode.dev"));
|
|
53
|
+
expect(settings.get_strv("disabled-extensions").join("\0") === disabled.join("\0"), "Migration must preserve unrelated disabled extensions");
|
|
45
54
|
let panel = extension._panels.get(name);
|
|
46
55
|
await until(() => panel.data.presentation === "gnome");
|
|
47
56
|
expect(panel.detail.width === 392, "Detail artwork must retain the macOS width");
|
|
@@ -90,7 +99,7 @@ export async function run() {
|
|
|
90
99
|
await call(name, "Quit");
|
|
91
100
|
await until(() => extension._panels.size === 0);
|
|
92
101
|
const result = { result: "passed", checks: ["Shared macOS detail SVG at full size", "Open GNOME menu renders artwork",
|
|
93
|
-
"Korean menu actions", "Provider visibility and image resizing", "Standard tray fallback on disable", "Enable/reconnect and service shutdown"],
|
|
102
|
+
"Korean menu actions", "Provider visibility and image resizing", "Legacy UUID settings cleanup", "Standard tray fallback on disable", "Enable/reconnect and service shutdown"],
|
|
94
103
|
screenshot: `${root}/detail-menu.png`, fullScreenshot: `${root}/menu.png`, detailImage: detailPath };
|
|
95
104
|
GLib.file_set_contents(`${root}/result.json`, new TextEncoder().encode(JSON.stringify(result, null, 2)));
|
|
96
105
|
print(JSON.stringify(result));
|
package/lib/README.md
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
# Internal module layout
|
|
2
|
-
|
|
3
|
-
The bin directory contains stable executable entrypoints only. Runtime
|
|
4
|
-
implementation belongs under lib:
|
|
5
|
-
|
|
6
|
-
- core: provider-independent usage normalization and terminal formatting.
|
|
7
|
-
- hud: desktop HUD dispatch and shared snapshot prefetch.
|
|
8
|
-
- platforms/runtime.js: cross-platform environment detection helpers.
|
|
9
|
-
- platforms/process-scanner.js: Windows, WSL, macOS, and Linux process scans.
|
|
10
|
-
- platforms/macos: macOS menu bar integration.
|
|
11
|
-
- platforms/linux: GJS StatusNotifierItem and native detail menu, sharing the
|
|
12
|
-
macOS panel artwork; GNOME display extension sharing the full-size macOS
|
|
13
|
-
detail image, Node snapshot worker, and owned XDG/extension setup and cleanup.
|
|
14
|
-
- platforms/windows: Windows Codex runner, compositor, PATH integration, and
|
|
15
|
-
HUD launcher.
|
|
16
|
-
- platforms/windows/hud: WinForms modules. dock.ps1 owns terminal attachment
|
|
17
|
-
and AppBar behavior; windowing.ps1 owns desktop placement; snapshot.ps1 owns
|
|
18
|
-
refresh; rendering.ps1 and controls.ps1 own UI drawing and updates;
|
|
19
|
-
native.ps1 contains Win32 interop.
|
|
20
|
-
|
|
21
|
-
Keep public command paths and test imports pointed at bin. Those entrypoints
|
|
22
|
-
re-export implementation APIs so internal modules can move without breaking
|
|
23
|
-
installed commands or downstream imports.
|