Skip to content

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

Open
wants to merge 15 commits into
base: master
Choose a base branch
from
Open

Conversation

taeold
Copy link
Contributor

@taeold taeold commented Jul 2, 2025

No description provided.

Copy link

@gemini-code-assist gemini-code-assist bot left a 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 running firebase 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

  1. 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.

Copy link

@gemini-code-assist gemini-code-assist bot left a 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.

taeold and others added 6 commits July 2, 2025 12:06
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
@taeold taeold changed the title feat: add firebase init ai-tools command. feat: add firebase init aitools command. Jul 9, 2025
@taeold
Copy link
Contributor Author

taeold commented Jul 9, 2025

/gemini review

Copy link

@gemini-code-assist gemini-code-assist bot left a 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.

taeold and others added 6 commits July 9, 2025 14:04
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-commenter
Copy link

Codecov Report

Attention: Patch coverage is 93.22034% with 4 lines in your changes missing coverage. Please review.

Project coverage is 52.01%. Comparing base (609bb02) to head (0543c9b).
Report is 21 commits behind head on master.

Files with missing lines Patch % Lines
src/init/features/aitools/promptUpdater.ts 93.22% 0 Missing and 4 partials ⚠️
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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@taeold taeold marked this pull request as ready for review July 10, 2025 20:25
@taeold
Copy link
Contributor Author

taeold commented Jul 10, 2025

/gemini review

Copy link

@gemini-code-assist gemini-code-assist bot left a 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>/;

Choose a reason for hiding this comment

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

high

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.

Suggested change
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",

Choose a reason for hiding this comment

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

medium

The diff package is added as a dependency, but it doesn't seem to be used anywhere in the codebase. To keep dependencies minimal, please remove it if it's not needed.

@@ -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",

Choose a reason for hiding this comment

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

medium

The @types/diff package is added as a dev dependency, but the diff package doesn't seem to be used. This can be removed along with the diff dependency.


interface AgentsInitSelections {
tools?: string[];
includeFeatures?: boolean;

Choose a reason for hiding this comment

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

medium

The includeFeatures property in the AgentsInitSelections interface is declared but never used. It should be removed to avoid dead code.

Comment on lines +35 to +47
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 });

Choose a reason for hiding this comment

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

medium

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 });

Comment on lines +1 to +8
{
"mcpServers": {
"firebase": {
"command": "npx",
"args": ["-y", "firebase-tools", "experimental:mcp", "--dir", "{{PROJECT_PATH}}"]
}
}
}

Choose a reason for hiding this comment

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

medium

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.

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.

2 participants