Skip to content

Add agent-usage extension - #25049

Merged
raycastbot merged 10 commits into
raycast:mainfrom
natsustan:ext/agent-usage
Feb 20, 2026
Merged

raycastbot merged 10 commits into
raycast:mainfrom
natsustan:ext/agent-usage

Conversation

@natsustan

@natsustan natsustan commented Feb 1, 2026 •

Copy link
Copy Markdown
Contributor

Description

Adds Agent Usage extension - track usage across multiple AI coding agents in one place.

Supported agents:

Amp Code - reads from local SQLite database (no setup required)
Codex (OpenAI) - requires authorization token
Droid (Factory AI) - requires authorization token
Gemini CLI - reads from local state file (no setup required)

Features:

Quick overview of remaining quotas and usage
Detailed breakdown for each agent
Refresh data and copy usage to clipboard
Show/hide agents and reorder list via preferences

Screencast

screencast-raycast-ext-agent-usage.mp4

Checklist

- Update README.md
- chore: update extension icon and minor fixes
- docs: update README and CHANGELOG for initial release
- refactor: prioritize Refresh action over Copy in ActionPanel
- feat: add copy usage details to clipboard action
- feat(amp): add display mode preference for amount or percentage
- feat: add agent list reorder with LocalStorage persistence
- style(assets): refine codex icon with thinner strokes and add dark variant
- feat: add dark mode support for droid icon
- feat(preferences): add per-agent visibility toggles
- feat(gemini): add Google Gemini CLI usage support
- feat: show amp replenishes time
- feat(droid): add Factory AI Droid usage support
- docs: update agent architecture notes
- refactor(agent-usage): centralize usage state and settings links
- feat(codex): show 5h limit in accessory
- refactor(agents): add shared types and ui helpers
- feat: integrate Codex support into Agent Usage command
- feat: implement Codex usage tracking module
- chore: add Codex icon asset
- refactor: enhance Amp error handling and fetcher logic
- feat: add custom Amp icon
- feat: support Amp usage tracking
- init: Raycast Agent Usage extension setup
@raycastbot

Copy link
Copy Markdown
Collaborator

Congratulations on your new Raycast extension! 🚀

We're currently experiencing a high volume of incoming requests. As a result, the initial review may take up to 10-15 business days.

Once the PR is approved and merged, the extension will be available on our Store.

@natsustan
natsustan marked this pull request as ready for review February 1, 2026 12:33
@greptile-apps

greptile-apps Bot commented Feb 1, 2026 •

Copy link
Copy Markdown
Contributor

Greptile Summary

Adds a new Agent Usage extension that tracks usage across 7 AI coding agents (Amp, Codex, Droid, Gemini, Kimi, Antigravity, z.ai) with a unified interface for monitoring quotas and usage limits.

Key features:

  • Multi-agent support with per-agent visibility toggles and custom ordering
  • Auto-detection for local agents (Amp, Gemini) and API-based fetching for cloud agents
  • OAuth token refresh for Gemini, fallback token support for Codex
  • Cross-platform Amp detection (macOS/Windows) with proper async execution
  • Interactive re-authentication flow for expired Gemini tokens

Implementation highlights:

  • Fixed previous review issues: removed manual Preferences interface, corrected import ordering, uses async execFileAsync for CLI calls, proper JWT base64url decoding
  • Properly configured ESLint v9 flat config and Raycast Prettier standards
  • Comprehensive test coverage for auth, parsing, and probing logic

Issues found:

  • Debug console.log statements in gemini/fetcher.ts (lines 138, 159)
  • Author mismatch in package.json (thuggyduck vs PR author natsustan)
  • Changelog incomplete (missing 3 agents: Kimi, Antigravity, z.ai)

Confidence Score: 4/5

  • Safe to merge after removing debug console.log statements
  • The extension addresses all critical issues from previous review threads (async execution, proper type generation, JWT decoding). Only minor cleanup needed: debug logs and documentation completeness. Core functionality is well-tested and follows Raycast patterns correctly.
  • extensions/agent-usage/src/gemini/fetcher.ts requires removal of console.log statements before merge

Important Files Changed

Filename Overview
extensions/agent-usage/src/agent-usage.tsx Main entry point with proper React hooks, state management, and action handlers. Fixed import ordering and removed manual Preferences interface.
extensions/agent-usage/package.json Extension configuration with author mismatch (package.json shows thuggyduck, PR author is natsustan). Standard dependencies and properly configured metadata.
extensions/agent-usage/src/gemini/fetcher.ts Gemini usage fetcher with proper JWT base64url decoding fix, OAuth token refresh, and multi-API integration. Contains debug console.log statements.
extensions/agent-usage/src/amp/fetcher.ts Cross-platform Amp detection with proper fallback logic and async path detection using execFileAsync.
extensions/agent-usage/src/codex/fetcher.ts Codex API integration with token fallback logic and proper error handling. Contains hardcoded User-Agent string.

Last reviewed commit: 8787041

@greptile-apps greptile-apps Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

10 files reviewed, 8 comments

Edit Code Review Agent Settings | Greptile

Comment thread extensions/agent-usage/package.json Resolved
spike added 5 commits February 2, 2026 09:17
- docs(package): improve extension description and subtitle
- feat(gemini): add re-authenticate action when OAuth token expires
- chore(settings): mark codex token as optional
- fix(kimi): guard percentage rendering for zero limits
- fix(gemini): make oauth refresh fallback resilient
- refactor(kimi): show rate and weekly limits as percentages
- feat(codex): add zero-config auth fallback strategy
- fix(kimi): use POST request with scope body
- feat(kimi): add Kimi agent support
- refactor(gemini): extract binary resolution into dedicated module
- refactor(gemini): replace Terminal-based reauth with inline execSync
- feat: add Antigravity provider and improve Gemini re-authentication
- docs: update extension description to include Kimi agent
@0xdhrv

ghost commented Feb 16, 2026

Copy link
Copy Markdown
Member

@greptileai, could you please do a fresh review of this PR?

ghost left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

62 files reviewed, 3 comments

Edit Code Review Agent Settings | Greptile

Comment on lines +13 to +15
export async function launchGeminiReauth(): Promise<void> {
execFileSync(getGeminiReauthCommand(), [], { timeout: 120000 });
}

ghost Feb 16, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

execFileSync blocks the UI thread

launchGeminiReauth is declared async but uses execFileSync, which blocks the Node.js event loop synchronously. Since the gemini CLI login flow is interactive (it opens a browser for Google OAuth and waits for the user to complete it), this will freeze the entire Raycast UI for up to 120 seconds.

This function is invoked from a toast action button in agent-usage.tsx, so users will experience a completely unresponsive UI until the command finishes or times out.

Use execFile (the async version, already imported in probe.ts via promisify) instead:

Suggested change
export async function launchGeminiReauth(): Promise<void> {
execFileSync(getGeminiReauthCommand(), [], { timeout: 120000 });
}
export async function launchGeminiReauth(): Promise<void> {
const { execFile } = await import("node:child_process");
const { promisify } = await import("node:util");
const execFileAsync = promisify(execFile);
await execFileAsync(getGeminiReauthCommand(), [], { timeout: 120000 });
}

content={getAgentCopyText(agent, {
amp: ampState,
codex: codexState,
droid: droidState,

ghost Feb 16, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Inconsistent title casing

"Move up" uses a lowercase "u" while the corresponding "Move Down" on line 362 uses an uppercase "D". Action titles should use consistent title case.

Suggested change
droid: droidState,
title="Move Up"

Context Used: Rule from dashboard - What: Use title case for titles in package.json.

Why: Title case improves readability and maintai... (source)

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

Comment on lines +5 to +7
interface AmpPreferences {
ampDisplayMode?: "amount" | "percentage";
}

ghost Feb 16, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Manual AmpPreferences interface is redundant

This defines a manual AmpPreferences interface for getPreferenceValues, but Raycast auto-generates Preferences.AgentUsage in raycast-env.d.ts from package.json. Other files in this extension (e.g., codex/fetcher.ts, droid/fetcher.ts) already use the generated type via type Preferences = Preferences.AgentUsage. This manual definition can drift out of sync with the actual preference schema.

Suggested change
interface AmpPreferences {
ampDisplayMode?: "amount" | "percentage";
}
type Preferences = Preferences.AgentUsage;

And update line 125 to:

const { ampDisplayMode = "amount" } = getPreferenceValues<Preferences>();

Context Used: Rule from dashboard - What: Don't manually define Preferences for getPreferenceValues() or commends Argument interfa... (source)

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

@0xdhrv 0xdhrv self-assigned this Feb 16, 2026
@0xdhrv

ghost commented Feb 16, 2026

Copy link
Copy Markdown
Member

Hi 👋

Thanks for your contribution 💪

Could you look into the suggestions from Greptile

I'm looking forward to reviewing this extension again 🔥

I converted this PR into a draft until it's ready for the review, please press the button Ready for review when it's ready and we'll have a look 😊

Feel free to contact me here or at Slack if you have any questions.

@0xdhrv
0xdhrv marked this pull request as draft February 16, 2026 12:34
- fix(agent-usage): avoid blocking binary detection
- fix: normalize preferences typing and async gemini reauth
- fix(zai): remove used suffix from usage display
- feat(zai): add z.ai (GLM) usage tracking provider
@natsustan
natsustan marked this pull request as ready for review February 17, 2026 01:40

ghost left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

66 files reviewed, 3 comments

Edit Code Review Agent Settings | Greptile

Comment on lines +138 to +139
console.log("fetchTier response not ok:", response.status, await response.text());
return { tier: "Unknown" };

ghost Feb 17, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove debug console.log statements before production

Suggested change
console.log("fetchTier response not ok:", response.status, await response.text());
return { tier: "Unknown" };
if (!response.ok) {
return { tier: "Unknown" };

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!


return { tier, projectId };
} catch (e) {
console.log("fetchTier error:", e);

ghost Feb 17, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove debug console.log statement

Suggested change
console.log("fetchTier error:", e);
return { tier: "Unknown" };

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

Comment thread extensions/agent-usage/CHANGELOG.md Outdated
Comment on lines +5 to +9
- Track usage for Amp, Codex, Droid, and Gemini CLI
- View remaining quotas and detailed usage breakdown
- Refresh data and copy usage details to clipboard
- Customize visible agents and display order
- Amp display mode: amount or percentage No newline at end of file

ghost Feb 17, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

changelog should list all 7 supported agents (Kimi, Antigravity, and z.ai are missing)

- chore: refresh extension branding assets
- fix(gemini): remove debug logs and update changelog
@natsustan

ghost commented Feb 20, 2026

Copy link
Copy Markdown
Contributor Author

@0xdhrv Could you help me review it one more time? I feel like the review process is a bit too long.

ghost left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me, approved 🔥

@raycastbot
raycastbot merged commit 04d93fb into raycast:main Feb 20, 2026
@github-actions

ghost commented Feb 20, 2026

Copy link
Copy Markdown
Contributor

@raycastbot

ghost commented Feb 20, 2026

Copy link
Copy Markdown
Collaborator

🎉 🎉 🎉

We've rewarded your Raycast account with some credits. You will soon be able to exchange them for some swag.

@natsustan
natsustan deleted the ext/agent-usage branch February 24, 2026 01:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

Couldn't load reviewers.

Assignees

Couldn't load assignees.