@agentuity/cli
Bun-native CLI framework for Agentuity applications.
Requirements
Installation
bun install -g @agentuity/cli
bun add -d @agentuity/cli
Usage
agentuity
agentuity example create my-app
agentuity example create my-app --type=advanced --force
agentuity example list
agentuity example list --json
agentuity --log-level=debug example create test
agentuity --config=/custom/path/config.yaml example list
Configuration
The CLI loads configuration from ~/.config/agentuity/config.yaml by default.
Example config:
api:
endpoint: https://api.agentuity.com
token: your-token-here
defaults:
environment: development
region: us-west-2
You can override the config path with --config:
agentuity --config=/path/to/config.yaml [command]
Log Levels
Control output verbosity with --log-level:
agentuity --log-level=debug example create test
agentuity --log-level=error example list
Creating Commands
Commands are auto-discovered from the src/cmd/ directory. Each command is a directory with an index.ts file.
Simple Command
import type { CommandDefinition, CommandContext } from '@agentuity/cli';
import { Command } from 'commander';
export const versionCommand: CommandDefinition = {
name: 'version',
description: 'Display version information',
register(program: Command, ctx: CommandContext) {
program
.command('version')
.description('Display version information')
.action(() => {
console.log('v1.0.0');
});
},
};
export default versionCommand;
Command with Options
import type { CommandDefinition, CommandContext } from '@agentuity/cli';
import { Command } from 'commander';
interface DeployOptions {
force: boolean;
dryRun: boolean;
}
export const deployCommand: CommandDefinition = {
name: 'deploy',
description: 'Deploy application',
register(program: Command, ctx: CommandContext) {
program
.command('deploy <environment>')
.description('Deploy to an environment')
.option('-f, --force', 'Force deployment', false)
.option('--dry-run', 'Dry run mode', false)
.action(async (environment: string, options: DeployOptions) => {
const { logger, config } = ctx;
logger.info(`Deploying to: ${environment}`);
if (options.dryRun) {
logger.info('Dry run - no changes made');
return;
}
});
},
};
export default deployCommand;
Command with Subcommands
import type { CommandDefinition, CommandContext } from '@agentuity/cli';
import { Command } from 'commander';
import { createSubcommand } from './create';
import { listSubcommand } from './list';
export const projectCommand: CommandDefinition = {
name: 'project',
description: 'Manage projects',
subcommands: [createSubcommand, listSubcommand],
register(program: Command, ctx: CommandContext) {
const cmd = program.command('project').description('Manage projects');
if (this.subcommands) {
for (const sub of this.subcommands) {
sub.register(cmd, ctx);
}
}
cmd.action(() => cmd.help());
},
};
export default projectCommand;
import type { SubcommandDefinition, CommandContext } from '@agentuity/cli';
import { Command } from 'commander';
interface CreateOptions {
template: string;
}
export const createSubcommand: SubcommandDefinition = {
name: 'create',
description: 'Create a new project',
register(parent: Command, ctx: CommandContext) {
parent
.command('create <name>')
.description('Create a new project')
.option('-t, --template <template>', 'Project template', 'default')
.action(async (name: string, options: CreateOptions) => {
const { logger } = ctx;
logger.info(`Creating project: ${name}`);
});
},
};
Command Context
Every command receives a CommandContext with:
config: Loaded YAML configuration
logger: Structured logger (respects --log-level)
options: Global CLI options
.action(async (args, options) => {
const { logger, config } = ctx;
logger.info('Starting...');
logger.debug('Debug info');
logger.warn('Warning');
logger.error('Error occurred');
const apiToken = config.api?.token;
});
API
Types
CommandDefinition - Main command definition
SubcommandDefinition - Subcommand definition
CommandContext - Context passed to commands
Config - Configuration object (Record<string, unknown>)
LogLevel - Log level type ('debug' | 'trace' | 'info' | 'warn' | 'error')
GlobalOptions - Global CLI options
Functions
createCLI(version: string) - Create CLI program
registerCommands(program, commands, ctx) - Register commands
discoverCommands() - Auto-discover commands from src/cmd/
loadConfig(path?) - Load YAML config
validateRuntime() - Validate Bun runtime
showBanner(version) - Show startup banner
License
MIT