no gemini

This commit is contained in:
Ian Gulliver
2026-10-18 16:24:11 -07:00
parent c4d7a67dad
commit 603a0eda6b
4 changed files with 83 additions and 2 deletions
+41
View File
@@ -0,0 +1,41 @@
package antigravity
import (
"context"
"encoding/json"
"fmt"
"os/exec"
"time"
)
type UsageBucket struct {
ID string `json:"id"`
Name string `json:"name"`
Window string `json:"window"`
RemainingFraction float64 `json:"remaining_fraction"`
ResetTime time.Time `json:"reset_time"`
}
type UsageGroup struct {
Name string `json:"name"`
Buckets []UsageBucket `json:"buckets"`
}
func ReadUsage(ctx context.Context) ([]UsageGroup, error) {
out, err := exec.CommandContext(ctx, "agy", "--output-format", "json", "--print", "/usage").Output()
if err != nil {
return nil, fmt.Errorf("agy /usage: %w", err)
}
resp := struct {
Command struct {
Data struct {
Groups []UsageGroup `json:"groups"`
} `json:"data"`
} `json:"command"`
}{}
err = json.Unmarshal(out, &resp)
if err != nil {
return nil, fmt.Errorf("agy /usage: %w", err)
}
return resp.Command.Data.Groups, nil
}