Skip to content

Commit 2e2e6d2

Browse files
committed
push: reframe usage messaging from 'commits' to 'agent sync events'
Server billing now only meters MCP-driven /v1/sync/push events. The CLI messaging still said 'commits' which was both inaccurate and confusing — users would see '150 commits' and think their git commits were being counted. Updated to say 'agent sync events' on warnings, and 'events' (tier-neutral) on the block message. kai push itself is no longer metered server-side; these messages now only appear on pushes where MCP sessions have pushed enough sync events during the period to warrant a warning.
1 parent ff86358 commit 2e2e6d2

1 file changed

Lines changed: 15 additions & 8 deletions

File tree

kai-cli/cmd/kai/main.go

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14611,20 +14611,23 @@ func runPush(cmd *cobra.Command, args []string) error {
1461114611
if len(batchUpdates) > 0 {
1461214612
result, err := client.BatchUpdateRefs(batchUpdates)
1461314613
if err != nil {
14614-
// Check for commit limit error
14614+
// Check for usage limit error. Current server only meters live-sync
14615+
// pushes from MCP sessions; plain 'kai push' should no longer hit
14616+
// this. Left in place for older servers that still meter ref
14617+
// updates.
1461514618
if limErr, ok := err.(*remote.CommitLimitError); ok {
1461614619
fmt.Fprintf(os.Stderr, "\r\033[K")
1461714620
fmt.Println()
14618-
fmt.Println(" Push blocked: you've reached the commit limit for this billing period.")
14621+
fmt.Println(" Push blocked: usage limit reached for this billing period.")
1461914622
fmt.Println()
1462014623
fmt.Printf(" Plan: %s\n", limErr.Tier)
14621-
fmt.Printf(" Used: %d / %d commits\n", limErr.Used, limErr.Limit)
14624+
fmt.Printf(" Used: %d / %d events\n", limErr.Used, limErr.Limit)
1462214625
fmt.Println()
1462314626
if limErr.UpgradeURL != "" {
14624-
fmt.Printf(" Upgrade to Pro for more commits: %s\n", limErr.UpgradeURL)
14627+
fmt.Printf(" Upgrade for a higher limit: %s\n", limErr.UpgradeURL)
1462514628
}
1462614629
fmt.Println()
14627-
return fmt.Errorf("commit limit reached")
14630+
return fmt.Errorf("usage limit reached")
1462814631
}
1462914632
// Fallback to individual updates if batch not supported (405 or other error)
1463014633
if strings.Contains(err.Error(), "405") || strings.Contains(err.Error(), "Method Not Allowed") {
@@ -14789,22 +14792,26 @@ func runPush(cmd *cobra.Command, args []string) error {
1478914792
if pushUsage.Limit > 0 {
1479014793
pct = pushUsage.Used * 100 / pushUsage.Limit
1479114794
}
14795+
// Usage reflects live-sync events from MCP sessions, not 'kai push'
14796+
// itself — the latter is always free. We still surface these warnings
14797+
// on kai push because it's the natural moment to tell a user about
14798+
// their monthly sync budget.
1479214799
switch {
1479314800
case pushUsage.Plan == "pro" && pushUsage.Used > pushUsage.Limit:
1479414801
overage := pushUsage.Used - pushUsage.Limit
1479514802
rate := pushUsage.OverageRate
1479614803
if rate == "" {
1479714804
rate = "$0.05"
1479814805
}
14799-
fmt.Printf("\n Pro plan: %d commits used (%d overage at %s/each)\n\n", pushUsage.Used, overage, rate)
14806+
fmt.Printf("\n Pro plan: %d sync events used (%d overage at %s/each)\n\n", pushUsage.Used, overage, rate)
1480014807
case pct >= 90:
14801-
fmt.Printf("\n Usage: %d / %d commits (%d%%) this period\n", pushUsage.Used, pushUsage.Limit, pct)
14808+
fmt.Printf("\n Usage: %d / %d agent sync events (%d%%) this period\n", pushUsage.Used, pushUsage.Limit, pct)
1480214809
if pushUsage.UpgradeURL != "" {
1480314810
fmt.Printf(" Upgrade to Pro: %s\n", pushUsage.UpgradeURL)
1480414811
}
1480514812
fmt.Println()
1480614813
case pct >= 80:
14807-
fmt.Printf("\n Usage: %d / %d commits (%d%%) this period\n\n", pushUsage.Used, pushUsage.Limit, pct)
14814+
fmt.Printf("\n Usage: %d / %d agent sync events (%d%%) this period\n\n", pushUsage.Used, pushUsage.Limit, pct)
1480814815
}
1480914816
}
1481014817

0 commit comments

Comments
 (0)