Skip to content

demo: Gemini CLI integration #8792

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 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
142 changes: 142 additions & 0 deletions npm-shrinkwrap.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@
"@google-cloud/cloud-sql-connector": "^1.3.3",
"@google-cloud/pubsub": "^4.5.0",
"@inquirer/prompts": "^7.4.0",
"@lydell/node-pty": "^1.1.0",
"@modelcontextprotocol/sdk": "^1.10.2",
"abort-controller": "^3.0.0",
"ajv": "^8.17.1",
Expand Down
32 changes: 32 additions & 0 deletions src/bin/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import * as clc from "colorette";
import { markedTerminal } from "marked-terminal";
import { marked } from "marked";
marked.use(markedTerminal() as any);

Check warning on line 5 in src/bin/cli.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Unexpected any. Specify a different type

Check warning on line 5 in src/bin/cli.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Unsafe argument of type `any` assigned to a parameter of type `MarkedExtension`

import { CommanderStatic } from "commander";
import * as fs from "node:fs";
Expand All @@ -17,9 +17,11 @@

import { enableExperimentsFromCliEnvVariable } from "../experiments";
import { fetchMOTD } from "../fetchMOTD";
import { launchGeminiWithCommand } from "../gemini/cli";
import { detectProjectRoot } from "../detectProjectRoot";

export function cli(pkg: any) {

Check warning on line 23 in src/bin/cli.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Unexpected any. Specify a different type

Check warning on line 23 in src/bin/cli.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Missing JSDoc comment

Check warning on line 23 in src/bin/cli.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Missing return type on function
const updateNotifier = updateNotifierPkg({ pkg });

Check warning on line 24 in src/bin/cli.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Unsafe assignment of an `any` value

const args = process.argv.slice(2);
let cmd: CommanderStatic;
Expand All @@ -34,7 +36,7 @@

logger.debug("-".repeat(70));
logger.debug("Command: ", process.argv.join(" "));
logger.debug("CLI Version: ", pkg.version);

Check warning on line 39 in src/bin/cli.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Unsafe member access .version on an `any` value
logger.debug("Platform: ", process.platform);
logger.debug("Node Version: ", process.version);
logger.debug("Time: ", new Date().toString());
Expand All @@ -54,7 +56,7 @@
}

if (code > 0 && process.stdout.isTTY) {
const lastError = configstore.get("lastError") || 0;

Check warning on line 59 in src/bin/cli.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Unsafe assignment of an `any` value
const timestamp = Date.now();
if (lastError > timestamp - 120000) {
let help;
Expand Down Expand Up @@ -84,7 +86,7 @@
const updateMessage =
`Update available ${clc.gray("{currentVersion}")} → ${clc.green("{latestVersion}")}\n` +
`To update to the latest version using ${installMethod}, run\n${clc.cyan(updateCommand)}\n` +
`For other CLI management options, visit the ${marked(

Check warning on line 89 in src/bin/cli.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Invalid type "string | Promise<string>" of template literal expression
"[CLI documentation](https://firebase.google.com/docs/cli#update-cli)",
)}`;
// `defer: true` would interfere with commands that perform tasks (emulators etc.)
Expand All @@ -108,6 +110,36 @@
});

if (!handlePreviewToggles(args)) {
// Check if --with-gemini flag is present
const withGeminiIndex = args.indexOf("--with-gemini");
if (withGeminiIndex !== -1) {
// Remove --with-gemini from args
const cleanArgs = [...args];
cleanArgs.splice(withGeminiIndex, 1);

Check failure on line 119 in src/bin/cli.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Delete `······`

Check failure on line 119 in src/bin/cli.ts

View workflow job for this annotation

GitHub Actions / unit (22)

Delete `······`

Check failure on line 119 in src/bin/cli.ts

View workflow job for this annotation

GitHub Actions / unit (22)

Delete `······`

Check failure on line 119 in src/bin/cli.ts

View workflow job for this annotation

GitHub Actions / unit (20)

Delete `······`
// Extract command and remaining args
if (cleanArgs.length === 0) {
// No command specified, just show help in Gemini
const projectDir = detectProjectRoot({}) || process.cwd();
launchGeminiWithCommand("help", [], projectDir, client).catch((err) => {
errorOut(err);

Check warning on line 125 in src/bin/cli.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Unsafe argument of type `any` assigned to a parameter of type `Error`
});
return;
}

Check failure on line 129 in src/bin/cli.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Delete `······`

Check failure on line 129 in src/bin/cli.ts

View workflow job for this annotation

GitHub Actions / unit (22)

Delete `······`

Check failure on line 129 in src/bin/cli.ts

View workflow job for this annotation

GitHub Actions / unit (22)

Delete `······`

Check failure on line 129 in src/bin/cli.ts

View workflow job for this annotation

GitHub Actions / unit (20)

Delete `······`
// Get the command (first non-flag argument)
const command = cleanArgs[0];
const commandArgs = cleanArgs.slice(1);

Check failure on line 133 in src/bin/cli.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Delete `······`

Check failure on line 133 in src/bin/cli.ts

View workflow job for this annotation

GitHub Actions / unit (22)

Delete `······`

Check failure on line 133 in src/bin/cli.ts

View workflow job for this annotation

GitHub Actions / unit (22)

Delete `······`

Check failure on line 133 in src/bin/cli.ts

View workflow job for this annotation

GitHub Actions / unit (20)

Delete `······`
// Launch Gemini with the command context
const projectDir = detectProjectRoot({}) || process.cwd();
launchGeminiWithCommand(command, commandArgs, projectDir, client).catch((err) => {
errorOut(err);
});
return;
}

Check failure on line 141 in src/bin/cli.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Delete `····`

Check failure on line 141 in src/bin/cli.ts

View workflow job for this annotation

GitHub Actions / unit (22)

Delete `····`

Check failure on line 141 in src/bin/cli.ts

View workflow job for this annotation

GitHub Actions / unit (22)

Delete `····`

Check failure on line 141 in src/bin/cli.ts

View workflow job for this annotation

GitHub Actions / unit (20)

Delete `····`
// Normal flow without --with-gemini
// determine if there are any arguments. if not, display help
if (!args.length) {
client.cli.help();
Expand Down
3 changes: 3 additions & 0 deletions src/deploy/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
import { includes, each } from "lodash";
import { needProjectId } from "../projectUtils";
import { logBullet, logSuccess, consoleUrl, addSubdomain } from "../utils";
import { logError } from "../logError";

Check failure on line 8 in src/deploy/index.ts

View workflow job for this annotation

GitHub Actions / lint (20)

'logError' is defined but never used

Check failure on line 8 in src/deploy/index.ts

View workflow job for this annotation

GitHub Actions / unit (22)

'logError' is defined but never used

Check failure on line 8 in src/deploy/index.ts

View workflow job for this annotation

GitHub Actions / unit (22)

'logError' is defined but never used

Check failure on line 8 in src/deploy/index.ts

View workflow job for this annotation

GitHub Actions / unit (20)

'logError' is defined but never used
import { FirebaseError } from "../error";
import { execSync } from "child_process";

Check failure on line 10 in src/deploy/index.ts

View workflow job for this annotation

GitHub Actions / lint (20)

'execSync' is defined but never used

Check failure on line 10 in src/deploy/index.ts

View workflow job for this annotation

GitHub Actions / unit (22)

'execSync' is defined but never used

Check failure on line 10 in src/deploy/index.ts

View workflow job for this annotation

GitHub Actions / unit (22)

'execSync' is defined but never used

Check failure on line 10 in src/deploy/index.ts

View workflow job for this annotation

GitHub Actions / unit (20)

'execSync' is defined but never used
import { AnalyticsParams, trackGA4 } from "../track";
import { lifecycleHooks } from "./lifecycleHooks";
import * as experiments from "../experiments";
Expand All @@ -26,6 +28,7 @@
import { requirePermissions } from "../requirePermissions";
import { Options } from "../options";
import { HostingConfig } from "../firebaseConfig";
import { confirm } from "../prompt";

Check failure on line 31 in src/deploy/index.ts

View workflow job for this annotation

GitHub Actions / lint (20)

'confirm' is defined but never used

Check failure on line 31 in src/deploy/index.ts

View workflow job for this annotation

GitHub Actions / unit (22)

'confirm' is defined but never used

Check failure on line 31 in src/deploy/index.ts

View workflow job for this annotation

GitHub Actions / unit (22)

'confirm' is defined but never used

Check failure on line 31 in src/deploy/index.ts

View workflow job for this annotation

GitHub Actions / unit (20)

'confirm' is defined but never used

const TARGETS = {
hosting: HostingTarget,
Expand Down
Loading
Loading