Skip to content

feat: add PRU-aware budget config with Copilot plan presets#55

Draft
maxbeizer wants to merge 1 commit intomarcus:mainfrom
maxbeizer:feat/pru-budget-config
Draft

feat: add PRU-aware budget config with Copilot plan presets#55
maxbeizer wants to merge 1 commit intomarcus:mainfrom
maxbeizer:feat/pru-budget-config

Conversation

@maxbeizer
Copy link

Summary

Replaces the hardcoded weeklyBudget * 4 monthly limit approximation with proper Copilot plan-aware budget configuration.

Changes

  • internal/config/config.go

    • Added MonthlyLimit and CopilotPlan fields to ProviderConfig
    • Added CopilotPlanLimits map with all GitHub Copilot plan tiers
    • Added GetCopilotMonthlyLimit() with cascading resolution:
      1. Explicit monthly_limit (user override)
      2. copilot_plan preset lookup
      3. weekly_tokens * 4 fallback (backwards compatible)
  • internal/budget/budget.go — Updated GetUsedPercent() to use GetCopilotMonthlyLimit()

  • cmd/nightshift/commands/doctor.go — Updated doctor to use config-driven limit

Plan Presets

Plan PRUs/month Config value
Free 50 free
Pro 300 pro
Pro+ 1,500 pro_plus
Business 300 business
Enterprise 1,000 enterprise

Config Example

[providers.copilot]
enabled = true
copilot_plan = "pro"      # auto-sets 300 PRUs/month
# monthly_limit = 500     # or explicit override

Testing

8 new table-driven tests covering all plan presets, explicit override priority, unknown plan fallback, and backwards compatibility. All existing tests pass (one pre-existing TestCurrentBranch flake unrelated to this change).

Related: Builds on #54 (Copilot provider Execute wiring).

- Add MonthlyLimit and CopilotPlan fields to ProviderConfig
- Add CopilotPlanLimits map: free=50, pro=300, pro_plus=1500,
  business=300, enterprise=1000 PRUs/month
- Add GetCopilotMonthlyLimit() with resolution order:
  MonthlyLimit > CopilotPlan preset > weeklyTokens*4 fallback
- Update budget.Manager to use GetCopilotMonthlyLimit() instead
  of hardcoded weeklyBudget*4 approximation
- Update doctor command to use config-driven monthly limit
- Table-driven tests for all plan presets and fallback behavior

Config example:
  [providers.copilot]
  copilot_plan = "pro"      # auto-sets 300 PRUs/month
  # or: monthly_limit = 500  # explicit override

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant