-
Notifications
You must be signed in to change notification settings - Fork 245
Feature/augment integration #120
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature/augment integration #120
Conversation
Cursor API returns bonus credits in breakdown.total field, which includes both the base plan limit and any bonus credits awarded. Previously, the code only used the 'limit' field, causing incorrect usage percentages for users with bonus credits. For example, a user with 00 base + 6.88 bonus would show 100% used when they still had 6.88 remaining. Changes: - Use breakdown.total when available (includes bonus credits) - Fall back to limit if breakdown is not present - Add rawJSON capture for debugging - Add Cursor to debug pane for easier troubleshooting - Add fetchWithManualCookies method for testing Fixes usage calculation for Cursor Ultra and other plans with bonus credits.
- Implement AugmentProvider with credits API integration - Add official Augment logo icon (simplified for menu bar) - Support keychain-based API key storage - Add usage tracking and credit monitoring - Include provider in registry and settings - Add comprehensive error handling and logging
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 Codex Review
Here are some automated review suggestions for this pull request.
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
…ests - Add debugRawProbe() method to AugmentStatusProbe for detailed probe diagnostics - Implement ring buffer to maintain 5 most recent debug dumps - Add latestDumps() method to retrieve captured probe failures - Integrate debug logging into UsageStore with 15-second timeout - Add comprehensive test suite (AugmentStatusProbeTests) with 6 passing tests - Fix CursorStatusProbeTests compilation errors (missing rawJSON parameter) Debug output includes: - Timestamp and cookie import logs - Probe success/failure status - Credits balance, consumed, monthly limit, plan name, account status - Raw API response JSON for troubleshooting Follows existing debug logging patterns from Claude and Cursor providers.
Add .augment to expected provider order list in providerOrder_persistsAndAppendsNewProviders test.
Previously only error paths were captured in the debug ring buffer. Now both success and error paths record to ensure latestDumps() shows complete debugging history for troubleshooting.
Initialize augmentCookieSourceRaw from UserDefaults in init, matching the pattern used by other providers. Without this, the cookie source always falls back to .auto after relaunch, causing users who select .manual or .off to lose their preference. Addresses Codex bot review feedback on PR steipete#120.
Initialize augmentCookieSourceRaw from UserDefaults in init, matching the pattern used by other providers. Without this, the cookie source always falls back to .auto after relaunch, causing users who select .manual or .off to lose their preference. Addresses Codex bot review feedback on PR steipete#120.
…ogging - Add Auth0 session cookies (auth0, auth0.is.authenticated, a0.spajs.txs) - Expand cookie domains to include login.augmentcode.com and .augmentcode.com - Add detailed debug logging with emoji indicators (✓, ✗,⚠️ ) - Implement fallback to use any augmentcode.com cookies if known session cookies not found - Improve error messages for better troubleshooting
…ry pattern - Remove early return for non-session cookies - Now continues searching other browsers if session cookies not found - Matches Cursor/Factory behavior: only returns when valid session cookies present - Prevents false positives from random augmentcode.com cookies
- Add NextAuth and AuthJS cookie variants for broader compatibility - Add comprehensive comment noting list may not be exhaustive - Improve logging to help discover missing cookie names - Log specific matched cookies when found - Warn users when cookies exist but don't match known session cookies - Request users report unrecognized cookies to improve detection This addresses potential authentication failures if Augment uses non-standard cookie names not in our current list.
- Remove CodexBar 2.app and CodexBar_Dev.app from git (should never be committed) - Improve .gitignore to catch all app bundle variations (CodexBar_*.app/) - Add development setup documentation (docs/DEVELOPMENT_SETUP.md) - Add script to create stable dev signing certificate (Scripts/setup_dev_signing.sh) This prevents build artifacts from polluting the repository and provides guidance for reducing keychain permission prompts during development.
- Fix provider icons not showing by including Resources as SwiftPM bundle - Update ProviderBrandIcon to load icons from CodexBar_CodexBar.bundle - Add session expiration detection (HTTP 401) for Augment provider - Add 'Refresh Cookies' button when session expires - Update Package.swift to process Resources instead of excluding them
- Implement automatic retry logic when session expires (HTTP 401) - Detect session expiration and automatically re-import fresh cookies from browser - Add comprehensive logging for debugging cookie import and API requests - Update error handling to show 'Log in to Augment' for both session expiration and missing cookies - Preserve manual cookie mode (no auto-refresh when using manual override) This eliminates the need for manual 'Refresh Cookies' button - the system now automatically recovers from expired sessions when browser cookies are still valid.
🔄 Automatic Cookie Refresh ImplementationThis commit adds automatic cookie refresh functionality for the Augment provider, eliminating the need for manual intervention when sessions expire. Changes Made1. Automatic Retry Logic ()
2. Enhanced Error Handling ()
How It Works
Benefits
This implementation follows the same pattern as modern authentication systems that automatically refresh tokens when they expire. |
Fixes packaging failure when Developer ID certificate is unavailable. Without this, the script would exit before copying resource bundles, causing provider icons to not display.
## Keychain Permission Prompts Fix ### Problem Development rebuilds changed code signature, causing 9+ keychain prompts (once per credential: Claude, Codex, MiniMax, Copilot, Zai cookies/tokens). ### Solution - Changed keychain accessibility from kSecAttrAccessibleAfterFirstUnlock to kSecAttrAccessibleAfterFirstUnlockThisDeviceOnly - Created one-time migration (KeychainMigration.swift) to convert existing items - First launch after update: 4-5 prompts (migration) - Subsequent rebuilds: Zero prompts! ### Files Changed - CookieHeaderStore.swift - Updated accessibility - MiniMaxCookieStore.swift - Updated accessibility - ZaiTokenStore.swift - Updated accessibility - CopilotTokenStore.swift - Updated accessibility - KeychainMigration.swift - New migration logic - CodexBarApp.swift - Added migration call on startup ## Augment Cookie Detection Improvements ### Enhanced Cookie Discovery - Added 'session' and 'web_rpc_proxy_session' to known cookie names - Improved logging with cookie expiration details - Fallback: attempt to use unrecognized cookies (auto-refresh handles expiration) - Better debugging output for cookie troubleshooting ### Files Changed - AugmentStatusProbe.swift - Enhanced cookie detection and logging ## Development Workflow Improvements ### New Scripts - Scripts/launch.sh - Simple launch script (no rebuild) ### Documentation - docs/DEVELOPMENT.md - Comprehensive development guide - docs/KEYCHAIN_FIX.md - Detailed keychain fix explanation - AUGMENT_COOKIE_FIX.md - Augment cookie troubleshooting guide - README.md - Added development section ## Testing - Verified zero keychain prompts on subsequent rebuilds - Confirmed migration runs once and sets UserDefaults flag - Tested Augment cookie auto-refresh with Chrome/Arc - Validated app launches successfully after changes
🔧 Keychain Prompts Fix + Development ImprovementsThis update addresses keychain permission prompts during development and adds comprehensive documentation. 🎯 Keychain Permission Prompts FixProblem: Development rebuilds changed code signature, causing 9+ keychain prompts (once per credential: Claude, Codex, MiniMax, Copilot, Zai cookies/tokens). Solution:
Files Changed:
🍪 Augment Cookie Detection ImprovementsEnhanced Cookie Discovery:
Files Changed:
🛠️ Development Workflow ImprovementsNew Scripts:
Documentation:
✅ Testing
📊 ImpactThis update significantly improves the development experience by eliminating repetitive keychain prompts while maintaining security. The migration is automatic and transparent to users. |
- Include Chrome Beta and Chrome Canary in Augment browser cookie order - Fixes cookie import for users running beta/canary Chrome versions - Remove temporary debug files and documentation
- Add browserSessionExpired error case for when both cached and browser cookies expire - Update error message to clarify that browser session needs refreshing - Change button text from 'Log in to Augment' to 'Refresh Augment Session' - Improve logging to distinguish between auto-retry success and browser session expiration - Automatic retry logic now clearly indicates when browser visit is required
- Add domain filtering to AugmentCookieImporter.SessionInfo.cookieHeader(for:) - Only send cookies valid for the target URL's domain (RFC 6265 semantics) - Support exact match, parent domain, and wildcard domain matching - Prevent cookies from auth.augmentcode.com being sent to app.augmentcode.com - Add 7 comprehensive test cases covering all domain matching scenarios - All 338 tests pass This prevents potential authentication issues from cookies intended for other subdomains being sent to the Augment API endpoints.
🔒 Cookie Domain Filtering FixThis update fixes a security/correctness issue with Augment cookie handling. 🎯 ProblemThe Augment status probe was sending all cookies from
This could cause authentication issues or unexpected behavior. ✅ SolutionAdded proper domain filtering to Allowed matches:
Blocked:
📝 Files Changed
This ensures only cookies valid for the target domain are sent to Augment API endpoints. |
Session Keepalive: - Add AugmentSessionKeepalive actor for automatic session management - Proactively refresh cookies before expiration (5-minute buffer) - Check session health every 5 minutes - Rate-limited refresh attempts (2-minute minimum interval) - Support for both expiring and session cookies - Integrated into UsageStore lifecycle Menu Improvements: - Update Augment error action text for clarity - Change 'Refresh Augment Session' to 'Open Augment (Log Out & Back In)' - Remove outdated 'session has expired in your browser' error check Performance Optimization: - Add 1-minute cache for Claude OAuth credentials - Reduce repeated keychain access during rapid credential checks - Invalidate cache on login/logout Integration: - Start keepalive automatically when Augment is enabled - Stop keepalive when Augment is disabled - Observe augmentCookieSource setting changes - Comprehensive logging for debugging This ensures Augment sessions remain active without manual intervention, improving user experience and reducing authentication errors.
🔄 Augment Session KeepaliveThis update adds automatic session management for Augment to prevent cookie expiration. 🎯 FeaturesAutomatic Session Refresh:
Smart Integration:
Session Refresh Mechanism:
📝 Implementation DetailsNew File:
✅ Benefits
🧪 Testing
|
Phase 1: Fork Identity & Credits About Section: - Add dual attribution: Original author (Peter Steinberger) + Fork maintainer (Brandon Charleson) - Update About.swift with clear original/fork links - Update PreferencesAboutPane.swift with organized sections - Change app icon click to open fork repository README Updates: - Add fork notice at top with link to original - Update download links to point to fork releases - Add 'Fork Enhancements' section documenting improvements - List Augment provider as fork enhancement - Update credits section with dual attribution Documentation: - Add comprehensive docs/augment.md covering: - Setup and configuration - Cookie import mechanism - Automatic session keepalive - Troubleshooting guide - Privacy and security details - Technical implementation notes This establishes the fork's identity while properly crediting the original author, preparing for independent development and distribution via topoffunnel.com while maintaining option to contribute upstream.
Planning Documents: - FORK_ROADMAP.md: Complete 5-phase development plan - Phase 1: Fork identity (COMPLETE) - Phase 2: Enhanced Augment diagnostics - Phase 3: Quotio feature analysis - Phase 4: Upstream sync workflow - Phase 5: Multi-account management - FORK_QUICK_START.md: Developer quick reference - Common commands and workflows - Troubleshooting guide - Contribution guidelines - Learning resources These documents provide a clear roadmap for fork development while maintaining the option to contribute valuable changes upstream.
Adds FORK_STATUS.md to track: - Completed work (Phase 1) - Current state and known issues - Next steps for each phase - Progress tracking checklist - Questions and decisions needed - Recommendations for proceeding This document serves as a living status tracker for the fork development process.
Implements complete strategy for managing fork while monitoring and selectively incorporating changes from both upstream repositories. Automation Scripts: - check_upstreams.sh: Monitor both upstreams for new commits - review_upstream.sh: Create review branches for upstream changes - prepare_upstream_pr.sh: Prepare clean branches for upstream PRs - analyze_quotio.sh: Analyze quotio for patterns and features GitHub Actions: - upstream-monitor.yml: Automated weekly monitoring - Runs Monday/Thursday at 9 AM UTC - Creates/updates GitHub issues with change summaries - Provides links to review changes Documentation: - UPSTREAM_STRATEGY.md: Complete multi-upstream management guide - Git repository structure and remotes - Workflows for monitoring, reviewing, incorporating changes - Decision matrix for what to contribute upstream vs keep in fork - Commit message strategies and attribution - Practical examples and best practices - QUOTIO_ANALYSIS.md: Framework for learning from quotio - Ethical guidelines for pattern analysis - Analysis process and templates - Feature comparison matrix - Implementation planning - Legal and attribution considerations - FORK_SETUP.md: One-time setup guide - Git remote configuration - Script testing and verification - Critical discovery: upstream removed Augment provider - Selective sync strategy - Regular workflow recommendations Key Features: - Separate commits for fork-specific vs upstream-suitable changes - Cherry-pick valuable upstream improvements - Learn from quotio patterns without copying code - Protect fork attribution and identity - Maintain option to contribute back upstream - Automated monitoring and notifications Critical Discovery: Upstream (steipete) has removed Augment provider in recent commits. This validates the fork strategy - we preserve features important to our users while selectively incorporating valuable upstream improvements. This system enables best-of-both-worlds: independent fork development while staying current with upstream innovations.
Updates FORK_STATUS.md to reflect: - Completion of multi-upstream management system - Critical discovery: upstream removed Augment provider - New automation scripts and GitHub Actions - Urgent upstream sync decision needed - Updated git status and next steps - Three options for proceeding This validates the fork strategy - we preserve Augment support while selectively incorporating valuable upstream improvements.
Creates IMPLEMENTATION_SUMMARY.md documenting: - Complete Phase 1 accomplishments - Multi-upstream management system details - Critical discovery: upstream removed Augment - Strategic benefits of fork approach - Current state and next steps - Documentation index - Success criteria verification This serves as the definitive record of what was accomplished and provides clear guidance for next steps.
…orce Refresh button Improves Augment session management to prevent disconnections: Session Keepalive Enhancements: - Try multiple session endpoints (/api/auth/session, /api/session, /api/user) - Add detailed logging for each endpoint attempt - Log Set-Cookie headers when received - Better error handling and fallback logic - Enhanced cookie expiration diagnostics with per-cookie status Cookie Diagnostics: - Log each cookie's name and expiration time - Show time until expiration in seconds - Identify which cookie expires first - Better visibility into session health UI Improvements: - Add 'Force Refresh Session' button in Augment settings (auto mode) - Button manually triggers session refresh and usage update - Separate actions for auto vs manual cookie modes - Better user guidance for session issues Implementation: - forceRefreshAugmentSession() method in UsageStore - Automatically starts keepalive if not running - Refreshes usage after forcing session refresh - All changes are @mainactor safe This should significantly improve session stability and give users a manual recovery option when automatic refresh fails.
- Enable supportsTokenCost in VertexAIProviderDescriptor - Route Vertex AI cost requests to use Claude JSONL scanner (same data source) - Add vertexai support in CostUsageFetcher and CostUsageScanner - Enable token snapshot loading in StatusItemController+Menu - Enable token usage refresh in UsageStore - Add vertexai to MenuCardView token usage section - Remove quota usage display (user only cares about token cost)
- Add docs/vertexai.md with setup instructions, prerequisites, and troubleshooting - Update docs/providers.md to include Vertex AI in fetch strategies table - Update README.md to list Vertex AI as a supported provider - Update CHANGELOG.md with Vertex AI feature details for 0.17.1 Vertex AI cost tracking uses gcloud OAuth credentials and reads local Claude usage logs from ~/.claude/projects/ for cost calculation. This provides the same cost display (daily + 30-day) as Claude provider.
Since Vertex AI uses the same local Claude logs in as the standard Claude provider, tracking cost for Vertex AI separately results in double-counting if both providers are active. This change disables discrete cost tracking for Vertex AI and updates documentation to advise users to view their combined Claude + Vertex AI token costs via the Claude provider.
Vertex AI entries in Claude logs now have dedicated token cost tracking: - Detect Vertex AI entries by _vrtx_ prefix in message/request IDs (e.g., msg_vrtx_0154LUXjFVzQGUca3yK2RUeo) - Fall back to model name @ format detection and metadata fields - Add ClaudeLogProviderFilter enum for filtering log entries by provider - Handle Cloud Monitoring .noData error gracefully so token costs display - Include Vertex AI in cost history chart submenu and token cost section - Add tests for _vrtx_ prefix detection and provider filtering This enables the Vertex AI tab to show token costs independently of the Claude provider, with proper filtering to avoid double-counting.
- Use contains closure instead of for-if loop for Vertex detection - Reduce processClaudeFile parameter count by moving range/filter to state - Fix line wrapping in VertexAIProviderDescriptor
… cookie guidance Addresses the common issue where browser cookies in the database are stale even though the user has an active session in their browser tabs. UI Improvements: - Add 'Refresh Browser Cookies' button in Augment settings (auto mode) - Button opens Augment dashboard and shows step-by-step instructions - Explains that browser cookies may take time to write to disk - Suggests closing/reopening browser if cookies remain stale Error Message Improvements: - Update browserSessionExpired error to mention new button - Add detailed logging with step-by-step fix instructions - Clarify that the issue is stale saved cookies, not expired session User Workflow: 1. Click 'Refresh Browser Cookies' to open dashboard + see instructions 2. Refresh the page in browser (⌘R) or log out/in 3. Wait a few seconds for cookies to write to disk 4. Click 'Force Refresh Session' to reload usage data This provides a clear path to recove when browser cookies are out of sync with the active browser session, which is the most common cause of 401 errors.
- Fetch from /api/subscription endpoint to get plan name and billing period end - Display plan name (e.g., 'Max') in menu header top-right corner - Show billing cycle reset countdown (e.g., 'Resets in 4d 4h') below credits bar - Parse billingPeriodEnd from ISO8601 format to Date - Make subscription API optional/graceful - credits API is still primary - Add --augment-debug CLI flag to dump raw API responses for debugging - Combine Credits API and Subscription API JSON in debug output - Maintain backward compatibility with existing cookie session handling - Preserve all existing error handling and fallback behavior
Remove fork-specific branding to maintain consistency with upstream project. Personal branding will be maintained in fork's main branch only.
- Revert to upstream README structure - Keep Augment in provider list (without 'Fork enhancement' label) - Remove fork download links, fork enhancements section, and dual attribution - Personal branding will be maintained in fork's main branch only
Initialize augmentCookieSourceRaw from UserDefaults in init, matching the pattern used by other providers. Without this, the cookie source always falls back to .auto after relaunch, causing users who select .manual or .off to lose their preference. Addresses Codex bot review feedback on PR steipete#120.
…ration Feature/augment integration
Summary
Adds Augment Code as a fully-featured provider in CodexBar with comprehensive credit tracking, plan information, and billing cycle management.
Features
Core Integration
/api/creditsendpoint/api/subscriptionendpointMenu Bar Display
Developer Experience
codexbar usage --provider augmentwith--augment-debugflagImplementation Details
Architecture
Cookie Import
~/Library/Application Support/CodexBar/augment-session.jsonAPI Integration
https://app.augmentcode.com/api/creditshttps://app.augmentcode.com/api/subscriptionTesting
Manual Testing
--augment-debugflag worksBuild & Code Quality
Files Changed
New Files
Sources/CodexBarCore/Providers/Augment/AugmentProCodexBarCore/Providers/Augment/AugmentStatusProbe.swiftSources/CodexBarCore/Providers/Augment/AugmentIcon.swiftModified Files
Sources/CodexBarCore/ProviderRegistry.swift- Register Augment providerSources/CodexBar/PreferencesDebugPane.swift- Add Augment debug sectionSources/CodexBarCLI/CLIEntry.swift- Add--augment-debugflagCompatibility
License
MIT License - maintains compatibility with CodexBar