@agentuity/cli

中文文档
3.1.18发布于 2026/08/01Apache-2.0TypeScriptES Module近 30 天下载 1772
中文使用文档
文档目录14 节
  1. 所需资源
  2. 安装
  3. 使用量
  4. 配置
  5. 日志级别
  6. 命令结构
  7. 简单命令
  8. 有选项的命令
  9. 有子命令的命令
  10. 命令上下文
  11. API 密码
  12. 类型
  13. 职能
  14. 许可证

@ 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 (英语)

版本与发布记录

@agentuity/cli 共发布 292 个版本,首次发布于 2025/10/29;过去 12 个月发布了 260 个版本。

版本发布日期距今
3.1.18latest2026/08/013 个月前
3.1.172026/08/013 个月前
3.1.162026/08/013 个月前
3.1.152026/07/303 个月前
3.1.142026/07/243 个月前
3.1.132026/07/223 个月前

其他发布通道:alpha → 3.0.0-alpha.7,beta → 3.0.0-beta.9,next → 3.1.1,v2 → 2.0.30。

关于 @agentuity/cli 的常见问题

如何安装 @agentuity/cli?

在项目目录运行 npm install @agentuity/cli,或使用 pnpm add / yarn add / bun add。它还提供命令行工具 agentuity,可以用 npx agentuity 直接运行。

@agentuity/cli 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@agentuity/cli 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@agentuity/cli 可以商用吗?

@agentuity/cli 使用 Apache-2.0 许可。宽松许可:允许商业使用、修改和再分发,并附带明确的专利授权;分发时需保留许可与 NOTICE 文件,修改过的文件要注明改动。以上为概括,不构成法律意见,请以许可原文为准。

@agentuity/cli 的下载量有多少?

根据 npm 官方下载统计,@agentuity/cli 在 2026/10/05 – 2026/11/03 这 30 天内被下载 1,772 次,日均约 59 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@agentuity/cli 还在维护吗?

最新版本 3.1.18 发布于 2026/08/01(3 个月前);至今共发布 292 个版本,其中过去 12 个月发布了 260 个;首次发布于 2025/10/29。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。