@ agentuity/ cli (英语)
代理命令行工具 。 项目脚手架, Dev 服务器, 建设,部署,云资源管理.
所需资源
- 1.3分贝 或者说 节点.js 24+
安装
# Global installation
bun install -g @agentuity/cli
# or
npm install -g @agentuity/cli
# Local installation
bun add -d @agentuity/cli
使用量
# Show banner and help
agentuity
# Top-level commands
agentuity auth login
agentuity project create my-app
agentuity build
agentuity dev
# Cloud commands
agentuity cloud keyvalue set mykey myvalue
agentuity cloud agents
agentuity cloud env list
agentuity cloud env set MY_SECRET value --secret
# AI commands
agentuity ai capabilities show
agentuity ai prompt llm
agentuity ai schema show
# Coder Hub commands
agentuity coder config set url https://hub.example.com
agentuity coder config set apikey agc_...
agentuity coder start
agentuity coder ls
agentuity coder inspect codesess_abc123
# Global options
agentuity --log-level=debug cloud keyvalue list
agentuity --config=/custom/path/production.yaml project list
Coder Hub命令使用活性的CLI配置来进行默认的Hub配置. 你们可以
以 --hub-url,或使用
AGENTUITY_CODER_HUB_URL 编号 : AGENTUITY_CODER_API_KEY 当环境超越.
配置
CLI 配置从 ~/.config/agentuity/production.yaml 默认.
示例配置 :
# ~/.config/agentuity/production.yaml
api:
endpoint: https://api.agentuity.com
token: your-token-here
defaults:
environment: development
region: us-west-2
您可以覆盖配置路径 --config数字 :
agentuity --config=/path/to/production.yaml [command]
日志级别
控制输出动词 --log-level数字 :
# Available levels: debug, trace, info, warn, error
agentuity --log-level=debug example create test
agentuity --log-level=error example list
命令结构
命令分为:
- 顶级数字 :
auth, (中文(简体) ),project, (中文(简体) ),version, (中文(简体) ),build(别名:bundle, (中文(简体) ),dev - 云头 (单位:千美元)
cloud:keyvalue, (中文(简体) ),agents, (中文(简体) ),env,以及与部署有关的命令 - 大赦国际 (单位:千美元)
ai:capabilities, (中文(简体) ),prompt, (中文(简体) ),schema - 隐藏数字 :
profile(仅内部使用)
命令是自动从 src/cmd/ 目录。 每个命令都包含一个目录 index.ts 文档.
简单命令
// src/cmd/version/index.ts
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;
有选项的命令
// src/cmd/deploy/index.ts
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;
}
// Deployment logic here
});
},
};
export default deployCommand;
有子命令的命令
// src/cmd/project/index.ts
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;
// src/cmd/project/create.ts
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}`);
// Implementation here
});
},
};
命令上下文
每个命令都收到 CommandContext 改为:
config: 已装入 YAML 配置logger: 有结构的日志( 尊重 -- -- log- 级别)options: 全球CLI 选项
.action(async (args, options) => {
const { logger, config } = ctx;
// Use logger for output
logger.info('Starting...');
logger.debug('Debug info');
logger.warn('Warning');
logger.error('Error occurred');
// Access config
const apiToken = config.api?.token;
});
API 密码
类型
CommandDefinition- 主要命令定义SubcommandDefinition- 子命令定义CommandContext- 向命令传递上下文Config- 配置对象(Record<string, unknown>(中文(简体) )LogLevel- 日志级别类型('debug' | 'trace' | 'info' | 'warn' | 'error'(中文(简体) )GlobalOptions- 全球CLI选项
职能
createCLI(version: string)- 创建CLI程序registerCommands(program, commands, ctx)- 登记命令discoverCommands()- 从src/cmd/自动发现命令loadConfig(path?)- 装入 YAML 配置showBanner(version)- 显示启动横幅
许可证
Apache 2.0 (英语)