diff --git a/genkit-tools/cli/src/cli.ts b/genkit-tools/cli/src/cli.ts index e1a93472b9..db3504d0d8 100644 --- a/genkit-tools/cli/src/cli.ts +++ b/genkit-tools/cli/src/cli.ts @@ -21,7 +21,6 @@ import { notifyAnalyticsIfFirstRun, record, } from '@genkit-ai/tools-common/utils'; -import * as clc from 'colorette'; import { Command, program } from 'commander'; import { config } from './commands/config'; import { evalExtractData } from './commands/eval-extract-data'; @@ -57,7 +56,7 @@ const commands: Command[] = [ export async function startCLI(): Promise { program .name('genkit') - .description('Google Genkit CLI') + .description('Firebase Genkit CLI') .version(version) .hook('preAction', async (_, actionCommand) => { await notifyAnalyticsIfFirstRun(); @@ -84,12 +83,20 @@ export async function startCLI(): Promise { for (const command of await getPluginCommands()) program.addCommand(command); for (const cmd of ToolPluginSubCommandsSchema.keyof().options) { - program.addCommand(await getPluginSubCommand(cmd)); + const command = await getPluginSubCommand(cmd); + if (command) { + program.addCommand(command); + } } - + program.addCommand( + new Command('help').action(() => { + logger.info(program.help()); + }) + ); // Default action to catch unknown commands. - program.action((_, { args }: { args: string[] }) => { - logger.error(`"${clc.bold(args[0])}" is not a known Genkit command.`); + program.action(() => { + // print help + logger.info(program.help()); }); await program.parseAsync(); diff --git a/genkit-tools/cli/src/commands/config.ts b/genkit-tools/cli/src/commands/config.ts index c7c6859828..558c142e70 100644 --- a/genkit-tools/cli/src/commands/config.ts +++ b/genkit-tools/cli/src/commands/config.ts @@ -43,6 +43,7 @@ const CONFIG_TAGS: Record< export const config = new Command('config'); config + .description('set development environment configuration') .command('get') .argument('', `The config tag to get. One of [${readableTagsHint()}]`) .action((tag) => { diff --git a/genkit-tools/cli/src/commands/eval-extract-data.ts b/genkit-tools/cli/src/commands/eval-extract-data.ts index f48157fbcf..eda82bb443 100644 --- a/genkit-tools/cli/src/commands/eval-extract-data.ts +++ b/genkit-tools/cli/src/commands/eval-extract-data.ts @@ -33,6 +33,7 @@ interface EvalDatasetOptions { /** Command to extract evaluation data. */ export const evalExtractData = new Command('eval:extractData') + .description('extract evaludation data for a given flow from the trace store') .argument('', 'name of the flow to run') .option('--env ', 'environment (dev/prod)', 'dev') .option( diff --git a/genkit-tools/cli/src/commands/eval-flow.ts b/genkit-tools/cli/src/commands/eval-flow.ts index 551b97a3ae..04f4a4ca1e 100644 --- a/genkit-tools/cli/src/commands/eval-flow.ts +++ b/genkit-tools/cli/src/commands/eval-flow.ts @@ -56,6 +56,9 @@ const EVAL_FLOW_SCHEMA = '{samples: Array<{input: any; reference?: any;}>}'; /** Command to run a flow and evaluate the output */ export const evalFlow = new Command('eval:flow') + .description( + 'evaluate a flow against configured evaluators using provided data as input' + ) .argument('', 'Name of the flow to run') .argument('[data]', 'JSON data to use to start the flow') .option('--input ', 'JSON batch data to use to run the flow') diff --git a/genkit-tools/cli/src/commands/eval-run.ts b/genkit-tools/cli/src/commands/eval-run.ts index 78c2f3ba58..d3ab2322e8 100644 --- a/genkit-tools/cli/src/commands/eval-run.ts +++ b/genkit-tools/cli/src/commands/eval-run.ts @@ -41,6 +41,7 @@ interface EvalRunOptions { } /** Command to run evaluation on a dataset. */ export const evalRun = new Command('eval:run') + .description('evaluate provided dataset against configured evaluators') .argument( '', 'Dataset to evaluate on (currently only supports JSON)' diff --git a/genkit-tools/cli/src/commands/flow-batch-run.ts b/genkit-tools/cli/src/commands/flow-batch-run.ts index 8f5c8ffa09..68a65e959e 100644 --- a/genkit-tools/cli/src/commands/flow-batch-run.ts +++ b/genkit-tools/cli/src/commands/flow-batch-run.ts @@ -36,6 +36,9 @@ interface FlowBatchRunOptions { /** Command to run flows with batch input. */ export const flowBatchRun = new Command('flow:batchRun') + .description( + 'batch run a flow using provided set of data from a file as input' + ) .argument('', 'name of the flow to run') .argument('', 'JSON batch data to use to run the flow') .option('-w, --wait', 'Wait for the flow to complete', false) diff --git a/genkit-tools/cli/src/commands/flow-resume.ts b/genkit-tools/cli/src/commands/flow-resume.ts index 9e25e03c46..344945a494 100644 --- a/genkit-tools/cli/src/commands/flow-resume.ts +++ b/genkit-tools/cli/src/commands/flow-resume.ts @@ -20,6 +20,7 @@ import { Command } from 'commander'; /** Command to start GenKit server, optionally without static file serving */ export const flowResume = new Command('flow:resume') + .description('resume an interrupted flow (experimental)') .argument('', 'name of the flow to resume') .argument('', 'ID of the flow to resume') .argument('', 'JSON data to use to resume the flow') diff --git a/genkit-tools/cli/src/commands/flow-run.ts b/genkit-tools/cli/src/commands/flow-run.ts index 4dd2c47727..3c70ef0be1 100644 --- a/genkit-tools/cli/src/commands/flow-run.ts +++ b/genkit-tools/cli/src/commands/flow-run.ts @@ -32,6 +32,7 @@ interface FlowRunOptions { /** Command to start GenKit server, optionally without static file serving */ export const flowRun = new Command('flow:run') + .description('run a flow using provided data as input') .argument('', 'name of the flow to run') .argument('[data]', 'JSON data to use to start the flow') .option('-w, --wait', 'Wait for the flow to complete', false) diff --git a/genkit-tools/cli/src/commands/init.ts b/genkit-tools/cli/src/commands/init.ts index 17680728c6..eff440b9b2 100644 --- a/genkit-tools/cli/src/commands/init.ts +++ b/genkit-tools/cli/src/commands/init.ts @@ -154,7 +154,7 @@ const sampleTemplatePaths: Record = { const supportedRuntimes: Runtime[] = ['node']; export const init = new Command('init') - .description('Initialize a project directory with Genkit') + .description('initialize a project directory with Genkit') .option( '-p, --platform ', 'Deployment platform (firebase, googlecloud, or nodejs)' diff --git a/genkit-tools/cli/src/commands/plugins.ts b/genkit-tools/cli/src/commands/plugins.ts index 55305bf20b..f9d3b405b5 100644 --- a/genkit-tools/cli/src/commands/plugins.ts +++ b/genkit-tools/cli/src/commands/plugins.ts @@ -34,7 +34,7 @@ export async function getPluginCommands(): Promise { /** Gets special-case commands for plugins in the config file. */ export async function getPluginSubCommand( commandString: SpecialAction -): Promise { +): Promise { const config = await findToolsConfig(); const actions = (config?.cliPlugins || []) .filter((p) => !!p.subCommands?.[commandString]) @@ -48,12 +48,7 @@ export async function getPluginSubCommand( ); if (!actions.length) { - return command.action(() => { - logger.error( - `No plugins installed that support ${commandString}. Add a supported ` + - `plugin to your ${clc.bold('genkit-tools.conf.js')} file.` - ); - }); + return undefined; } for (const a of actions) { diff --git a/genkit-tools/cli/src/commands/start.ts b/genkit-tools/cli/src/commands/start.ts index a8acc78c45..5d6980e957 100644 --- a/genkit-tools/cli/src/commands/start.ts +++ b/genkit-tools/cli/src/commands/start.ts @@ -28,6 +28,7 @@ interface StartOptions { /** Command to start GenKit server, optionally without static file serving */ export const start = new Command('start') + .description('run the app in dev mode and start a Developer UI') .option( '-x, --headless', 'Do not serve static UI files (for development)',