-
Notifications
You must be signed in to change notification settings - Fork 1k
feat: add firebase init aitools command. #8807
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
base: master
Are you sure you want to change the base?
Conversation
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.
Summary of Changes
Hello @taeold, 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 by adding a new ai-tools
initialization command. This feature streamlines the process of integrating Firebase projects with popular AI coding assistants, providing them with rich, structured context about the project's Firebase setup, CLI commands, and best practices. The goal is to empower developers to leverage AI more effectively within their Firebase workflows.
Highlights
- New
firebase init ai-tools
Command: I've introduced a new interactive command,firebase init ai-tools
, which allows users to configure their Firebase projects for various AI coding assistants. This command is now available as an option when runningfirebase init
. - AI Tool Integration: The new command supports configuring three specific AI tools: Cursor, Gemini CLI, and Firebase Studio. For each selected tool, it generates tool-specific configuration files and AI context files within the project directory (e.g.,
.cursor/
,.gemini/
,.idx/
). - Context Generation for AI Assistants: The core functionality involves generating comprehensive Markdown-based context files for AI assistants. These files include general Firebase CLI context (
FIREBASE.md
) and detailed Firebase Functions context (FIREBASE_FUNCTIONS.md
), tailored to each AI tool's preferred format (e.g., file references for Cursor, appended content for Gemini/Studio). The context also includes specific guidelines and a persona for Firebase Studio. - Feature Optimization: Users can optionally choose to optimize the generated AI context based on the Firebase features already enabled in their project (e.g., Functions, Firestore, Hosting). This ensures the AI assistant receives more relevant information, potentially improving its performance and accuracy.
Using Gemini Code Assist
The 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 in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command>
or @gemini-code-assist <command>
. Below is a summary of the supported commands.
Feature | Command | Description |
---|---|---|
Code Review | /gemini review |
Performs a code review for the current pull request in its current state. |
Pull Request Summary | /gemini summary |
Provides a summary of the current pull request in its current state. |
Comment | @gemini-code-assist | Responds in comments when explicitly tagged, both in issue comments and review comments. |
Help | /gemini help |
Displays a list of available commands. |
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 .gemini/
folder in the base of the repository. Detailed instructions can be found here.
Limitations & Feedback
Gemini Code Assist is currently in preview and 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 to provide feedback.
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
-
Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution. ↩
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.
Code Review
This pull request introduces a new init
feature for configuring AI agents. The implementation looks good, with new prompt files for context and logic to generate tool-specific configurations.
However, there is a critical issue that prevents the feature from working: the new agents
feature is not registered in the featuresList
in src/init/index.ts
. This will cause firebase init agents
to fail. This file must be updated to include the new feature.
I've also identified a high-severity bug in generateFirebaseContext
that duplicates content for the Firebase Studio configuration, and a medium-severity issue in one of the prompt files. Please see the detailed comments.
Addressing these issues will make this a great addition.
Adds a new init feature to configure AI coding assistants with Firebase context and MCP server integration. Supported tools: - Cursor: MCP server config + rules files with Firebase context - Gemini CLI: Extension config + combined Firebase context - Firebase Studio: AI rules file with structured Firebase guidance Features: - Multi-select tool configuration - Optional Firebase feature optimization - Modular architecture for easy extension - Single source of truth for prompts in /prompts directory - Clean separation of tool-specific logic Usage: firebase init ai-tools
Remove hyphens from all ai-tools references for consistency: - Command: firebase init aitools (was ai-tools) - File/directory names: aitools.ts, aitools/ (was ai-tools.ts, ai-tools/) - Template paths: init/aitools/ (was init/ai-tools/) - All imports and references updated accordingly
- Add Claude Code AI tool using `claude mcp add` command - Implement XML-based config management with diff preview for all tools - Auto-detect Firebase features from firebase.json - Add comprehensive tests for config management
/gemini review |
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.
Code Review
This pull request introduces a new firebase init aitools
command, which is a significant feature for improving the developer experience with AI coding assistants. The implementation is comprehensive, covering integration with multiple AI tools like Claude, Cursor, Gemini, and Firebase Studio. It also adds new context files and MCP server tools. I've identified a few issues, including a critical syntax error in a prompt file and some incorrect test mocks that need to be addressed. I've also provided some suggestions to improve code clarity and maintainability.
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #8807 +/- ##
==========================================
+ Coverage 51.97% 52.01% +0.04%
==========================================
Files 407 409 +2
Lines 30315 30453 +138
Branches 6276 6300 +24
==========================================
+ Hits 15755 15839 +84
- Misses 13143 13195 +52
- Partials 1417 1419 +2 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
/gemini review |
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.
Code Review
This PR introduces a new firebase init aitools
command to configure various AI coding assistants with Firebase-specific context. The implementation is quite comprehensive, adding support for Claude, Cursor, Gemini, and Firebase Studio (IDX). It includes new prompt files, configuration logic for each tool, and a shared prompt updater utility.
My review focuses on improving code quality and consistency. I've identified a few areas for improvement:
- A bug in the prompt updater that could lead to duplicated content.
- Some unused code, including a dependency and a template file.
- An opportunity to refactor for better code consistency.
Overall, this is a great feature addition. Addressing these points will make the implementation more robust and maintainable.
import { logger } from "../../../logger"; | ||
|
||
const PROMPTS_DIR = path.join(__dirname, "../../../../prompts"); | ||
const FIREBASE_TAG_REGEX = /<firebase_prompts\s+hash="([^"]+)">([\s\S]*?)<\/firebase_prompts>/; |
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.
The current regex FIREBASE_TAG_REGEX
requires the hash
attribute to be present in the <firebase_prompts>
tag. If a file contains a <firebase_prompts>
tag without a hash
, updateFirebaseSection
will fail to find it and will append a new section, resulting in duplicated content blocks.
This can lead to unexpected behavior and malformed configuration files.
Please consider updating the regex to optionally match the hash
attribute and adjust the logic in updateFirebaseSection
to handle replacement correctly in this case.
const FIREBASE_TAG_REGEX = /<firebase_prompts\s+hash="([^"]+)">([\s\S]*?)<\/firebase_prompts>/; | |
const FIREBASE_TAG_REGEX = /<firebase_prompts(?:\s+hash="([^"]+)")?>([\s\S]*?)<\/firebase_prompts>/; |
@@ -123,6 +123,7 @@ | |||
"cross-spawn": "^7.0.5", | |||
"csv-parse": "^5.0.4", | |||
"deep-equal-in-any-order": "^2.0.6", | |||
"diff": "^5.0.0", |
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.
@@ -189,6 +190,7 @@ | |||
"@types/cors": "^2.8.10", | |||
"@types/cross-spawn": "^6.0.1", | |||
"@types/deep-equal-in-any-order": "^1.0.3", | |||
"@types/diff": "^5.0.0", |
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.
|
||
interface AgentsInitSelections { | ||
tools?: string[]; | ||
includeFeatures?: boolean; |
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.
let extensionUpdated = false; | ||
try { | ||
const existing = config.readProjectFile(extensionPath); | ||
if (existing !== extensionConfig) { | ||
config.writeProjectFile(extensionPath, extensionConfig); | ||
extensionUpdated = true; | ||
} | ||
} catch { | ||
// File doesn't exist, needs to be created | ||
config.writeProjectFile(extensionPath, extensionConfig); | ||
extensionUpdated = true; | ||
} | ||
files.push({ path: extensionPath, updated: extensionUpdated }); |
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.
This block of code manually implements logic to check and update the gemini-extension.json
file. A helper function replaceFirebaseFile
already exists in promptUpdater.ts
for this exact purpose and is used in other tool configurations like cursor.ts
.
To improve consistency and reduce code duplication, I suggest refactoring this to use replaceFirebaseFile
.
const { updated: extensionUpdated } = await replaceFirebaseFile(
config,
extensionPath,
extensionConfig,
);
files.push({ path: extensionPath, updated: extensionUpdated });
{ | ||
"mcpServers": { | ||
"firebase": { | ||
"command": "npx", | ||
"args": ["-y", "firebase-tools", "experimental:mcp", "--dir", "{{PROJECT_PATH}}"] | ||
} | ||
} | ||
} |
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.
This template file cursor-mcp.json
seems to be unused. The logic in src/init/features/aitools/cursor.ts
constructs the MCP configuration object manually instead of using this template.
Please either use this template in cursor.ts
for consistency with other features like Gemini, or remove this file if it's not needed.
No description provided.