fix(tracking): Detect more coding agents; Improve typing around Ai Agents.#10104
fix(tracking): Detect more coding agents; Improve typing around Ai Agents.#10104richieforeman wants to merge 4 commits intomainfrom
Conversation
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request significantly enhances the Firebase CLI's ability to identify and track various AI coding agents. By standardizing agent identifiers with constants and introducing a type-safe union, the changes improve code maintainability and robustness. The updated detection logic covers a broader range of AI environments, ensuring more accurate telemetry and better integration with different development tools. Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Changelog
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request effectively refactors the AI agent detection logic, enhancing type safety and maintainability by introducing constants and a union type. The addition of unit tests is a great step towards ensuring the reliability of this logic. I have a couple of suggestions: one to improve the test coverage to be more comprehensive, and another to simplify a conditional block for better readability, in line with the repository's style guide.
### Description Refactors the AI agent detection logic to improve type safety and maintainability. Key changes: - Defined CONSTANT_CASE constants for all supported AI agents in src/env.ts. - Introduced an AiAgents union type for better type safety. - Refactored detectAIAgent() to use these constants and return the new type. - Incorporated detection for GOOGLE_AI_STUDIO via the APPLET_DIR environment variable. - Updated apiv2.ts to use the normalized UNKNOWN constant. - Added 18 unit tests in src/env.spec.ts with Sinon stubs and module reloading. ### Scenarios Tested - Unit Testing (src/env.spec.ts): Verified detection of all AI agents (Antigravity, Claude, Cline, Codex, Cursor, Gemini, OpenCode, Replit, Copilot, Google AI Studio) and alternative environment variables. - Verified isFirebaseStudio() and isFirebaseMcp() logic. ### Sample Commands N/A
d597773 to
6a77fc0
Compare
| if ( | ||
| process.env["CURSOR_AGENT"] || | ||
| process.env["CURSOR_TRACE_ID"] || | ||
| process.env["CODEX_THREAD_ID"] || |
There was a problem hiding this comment.
Do these CODEX env vars really map to cursor? Smells fishy to me, but i have seen weirder.
|
Quick sanity check, but LGTM otherwise |
This PR refactors the AI agent detection logic to improve type safety and maintainability. While here, I added detection of a few new coding agents or made the detection for some more robust.
Description
Refactored the environment detection logic in src/env.ts to use standardized constants and a union type. This ensures consistency across the codebase, particularly for Google Analytics tracking and API request headers.
Key changes include:
CONSTANT_CASEconstants for all supported AI agents (e.g.,ANTIGRAVITY,CURSOR,GOOGLE_AI_STUDIO) in src/env.ts.GOOGLE_AI_STUDIOvia theAPPLET_DIRenvironment variable.UNKNOWNconstant.process.envand module reloading to ensure reliable state isolation.Scenarios Tested
UNKNOWNstatus) based on their respective environment variables./google/idxfolder.Sample Commands
N/A (This internal refactoring does not change the user-facing CLI command structure or flags).