# @agentuity/cli 中文文档

规范地址：https://npmcn.com/package/%40agentuity/cli/

版本：3\.1\.18
npm 元数据更新时间：2026-08-01T00:44:17.902Z
中文译文更新时间：2026-11-08T14:50:06.164Z
软件包许可：Apache-2\.0

本文由上游 README 翻译，可能存在偏差，请结合原文核对 API、命令与配置。版权与许可归原作者所有。

原始 npm 页面：https://www.npmjs.com/package/%40agentuity/cli
原文对照：https://npmcn.com/package/%40agentuity/cli/?lang=original
源码仓库：https://github.com/agentuity/sdk

## 关键信息（来自 npm 元数据）

- 包体积（解压后）：5.9 MB，2095 个文件
- 模块格式：ES Module
- TypeScript 类型：包内自带
- 运行依赖：29 个
- 首次发布：2025-10-28T19:14:33.771Z
- 最新版本发布：2026-08-01T00:44:17.700Z
- 近 30 天下载量：1772（2026-10-05 至 2026-11-03，npm 官方下载统计）
- 已发布版本数：292（近 12 个月 260 个）

## 中文简介

暂无中文简介

## 安装

```sh
npm install @agentuity/cli
```

也可以使用：`pnpm add @agentuity/cli`、`yarn add @agentuity/cli`、`bun add @agentuity/cli`

## README

# @ agentuity/ cli (英语)

代理命令行工具 。 项目脚手架, Dev 服务器, 建设,部署,云资源管理.

## 所需资源

-   1.3分贝 **或者说** 节点.js 24+

## 安装

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

# Local installation
bun add -d @agentuity/cli
```

## 使用量

```bash
# 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` 默认.

示例配置 :

```yaml
# ~/.config/agentuity/production.yaml
api:
   endpoint: https://api.agentuity.com
   token: your-token-here

defaults:
   environment: development
   region: us-west-2
```

您可以覆盖配置路径 `--config`数字 :

```bash
agentuity --config=/path/to/production.yaml [command]
```

## 日志级别

控制输出动词 `--log-level`数字 :

```bash
# 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` 文档.

### 简单命令

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

### 有选项的命令

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

### 有子命令的命令

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

```typescript
// 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 选项

```typescript
.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？

在项目目录运行 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 和提交记录判断。

