@agentuity/cli

中文文档
3.1.18发布于 2026/08/01Apache-2.0TypeScriptES Module近 30 天下载 1772
原始使用文档
文档目录14 节
  1. Requirements
  2. Installation
  3. Usage
  4. Configuration
  5. Log Levels
  6. Command Structure
  7. Simple Command
  8. Command with Options
  9. Command with Subcommands
  10. Command Context
  11. API
  12. Types
  13. Functions
  14. License

@agentuity/cli

The Agentuity command line tool. Project scaffolding, dev server, build, deploy, cloud resource management.

Requirements

  • Bun 1.3+ or Node.js 24+

Installation

# Global installation
bun install -g @agentuity/cli
# or
npm install -g @agentuity/cli

# Local installation
bun add -d @agentuity/cli

Usage

# 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 commands use the active CLI profile for default Hub configuration. You can override the stored Hub URL per command with --hub-url, or use AGENTUITY_CODER_HUB_URL / AGENTUITY_CODER_API_KEY as environment overrides.

Configuration

The CLI loads configuration from ~/.config/agentuity/production.yaml by default.

Example config:

# ~/.config/agentuity/production.yaml
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/production.yaml [command]

Log Levels

Control output verbosity with --log-level:

# Available levels: debug, trace, info, warn, error
agentuity --log-level=debug example create test
agentuity --log-level=error example list

Command Structure

Commands are organized into groups:

  • Top-level: auth, project, version, build (alias: bundle), dev
  • Cloud (cloud): keyvalue, agents, env, and deployment-related commands
  • AI (ai): capabilities, prompt, schema
  • Hidden: profile (internal use only)

Commands are auto-discovered from the src/cmd/ directory. Each command is a directory with an index.ts file.

Simple Command

// 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;

Command with Options

// 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;

Command with Subcommands

// 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
            });
    },
};

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;

    // 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

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
  • showBanner(version) - Show startup banner

License

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 和提交记录判断。