Cherrypick extensions changes to v0.6.0 (#9179)

Co-authored-by: hritan <48129645+hritan@users.noreply.github.com>
Co-authored-by: Taneja Hriday <hridayt@google.com>
Co-authored-by: shishu314 <shishu_1998@yahoo.com>
Co-authored-by: Shi Shu <shii@google.com>
Co-authored-by: Jacob MacDonald <jakemac@google.com>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
This commit is contained in:
christine betts
2025-09-23 13:35:18 -04:00
committed by GitHub
parent 3477abd296
commit 4a92f938e1
40 changed files with 3125 additions and 925 deletions
@@ -5,10 +5,8 @@
*/
import type { CommandModule } from 'yargs';
import {
installExtension,
type ExtensionInstallMetadata,
} from '../../config/extension.js';
import { installExtension } from '../../config/extension.js';
import type { ExtensionInstallMetadata } from '@google/gemini-cli-core';
import { getErrorMessage } from '../../utils/errors.js';
@@ -16,12 +14,12 @@ interface InstallArgs {
source?: string;
path?: string;
ref?: string;
autoUpdate?: boolean;
}
export async function handleInstall(args: InstallArgs) {
try {
let installMetadata: ExtensionInstallMetadata;
if (args.source) {
const { source } = args;
if (
@@ -34,6 +32,7 @@ export async function handleInstall(args: InstallArgs) {
source,
type: 'git',
ref: args.ref,
autoUpdate: args.autoUpdate,
};
} else {
throw new Error(`The source "${source}" is not a valid URL format.`);
@@ -42,6 +41,7 @@ export async function handleInstall(args: InstallArgs) {
installMetadata = {
source: args.path,
type: 'local',
autoUpdate: args.autoUpdate,
};
} else {
// This should not be reached due to the yargs check.
@@ -57,7 +57,7 @@ export async function handleInstall(args: InstallArgs) {
}
export const installCommand: CommandModule = {
command: 'install [source]',
command: 'install [<source>] [--path] [--ref] [--auto-update]',
describe: 'Installs an extension from a git repository URL or a local path.',
builder: (yargs) =>
yargs
@@ -73,8 +73,13 @@ export const installCommand: CommandModule = {
describe: 'The git ref to install from.',
type: 'string',
})
.option('auto-update', {
describe: 'Enable auto-update for this extension.',
type: 'boolean',
})
.conflicts('source', 'path')
.conflicts('path', 'ref')
.conflicts('path', 'auto-update')
.check((argv) => {
if (!argv.source && !argv.path) {
throw new Error('Either source or --path must be provided.');
@@ -86,6 +91,7 @@ export const installCommand: CommandModule = {
source: argv['source'] as string | undefined,
path: argv['path'] as string | undefined,
ref: argv['ref'] as string | undefined,
autoUpdate: argv['auto-update'] as boolean | undefined,
});
},
};