# @ez-corp/ez-ai-pipeline 中文文档

规范地址：https://npmcn.com/package/%40ez-corp/ez-ai-pipeline/

版本：1\.4\.4
npm 元数据更新时间：2026-01-08T19:50:50.014Z
中文译文更新时间：2026-11-14T09:55:39.712Z
软件包许可：MIT

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

原始 npm 页面：https://www.npmjs.com/package/%40ez-corp/ez-ai-pipeline
原文对照：https://npmcn.com/package/%40ez-corp/ez-ai-pipeline/?lang=original

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

- 包体积（解压后）：2.2 MB，10 个文件
- 模块格式：ES Module
- TypeScript 类型：包内自带
- Node.js 要求：\>=18\.0\.0
- 运行依赖：15 个
- 首次发布：2025-12-21T21:32:15.736Z
- 最新版本发布：2026-01-08T19:50:49.816Z
- 近 30 天下载量：2082（2026-10-14 至 2026-11-12，npm 官方下载统计）
- 已发布版本数：11（近 12 个月 11 个）

## 中文简介

使用 OpenCode SDK 执行快速优化管道的生产准备的 CLI 工具

## 安装

```sh
npm install @ez-corp/ez-ai-pipeline
```

也可以使用：`pnpm add @ez-corp/ez-ai-pipeline`、`yarn add @ez-corp/ez-ai-pipeline`、`bun add @ez-corp/ez-ai-pipeline`

## README

# EZ AI 管道

[![npm version](https://img.shields.io/npm/v/@ez-corp/ez-ai-pipeline.svg)](https://www.npmjs.com/package/@ez-corp/ez-ai-pipeline) [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)

一个生产准备的CLI工具,用于使用AI模型执行即时优化管道. 具备了美丽的终端接口,多相相接管执行,成本效益高的模型选择,以及内置的网络仪表板.

## 特征

-   **多站式管道**: 定义具有多个AI处理阶段的复杂工作流程
-   **有条件的执行**: 跳过阶段,有条件运行,或根据结果提前退出
-   **费用追踪**: 所有 API 呼叫的自动令牌计数和成本计算
-   **美丽的终端用户界面**: 进度指标、旋转器和格式化产出
-   **可变内插**: 使用模板变量在各阶段之间传递数据
-   **多个输出格式**: JSON, Markdown, 和文本解析支持
-   **暂停/恢复/取消**: 实时控制管道执行
-   **网页盘**: 内置网络查看器以浏览管道输出
-   **包括管道**: 装有随时可以使用的管道的船舶(即时优化器、管道生成器)

## 安装

```bash
# Install globally from npm
npm install -g @ez-corp/ez-ai-pipeline

# Or use with npx
npx @ez-corp/ez-ai-pipeline --help
```

## 快速启动

### 1\. 设置您的 API 密钥( 或使用 CLI 模式)

```bash
# Option A: Use your Anthropic API key
export ANTHROPIC_API_KEY="your-api-key"

# Option B: Use CLI mode with Claude Code (no API key needed)
# Just have Claude Code installed and authenticated
```

### 2\. 运行包含的管道

```bash
ez-ai-pipeline run -p prompt-optimizer -i "Write a blog post about productivity"
```

### 3\. 在网络仪表板上查看结果

```bash
ez-ai-pipeline web
```

### 4\. 创建自己的管道

```bash
ez-ai-pipeline init my-pipeline
```

## 图标

### `run` - 执行管道

```bash
ez-ai-pipeline run --pipeline <id> --input <text>
ez-ai-pipeline run --pipeline <id> --input-file <path>
ez-ai-pipeline run --pipeline <id> --input <text> --output ./results/
ez-ai-pipeline run --pipeline <id> --input <text> --json  # JSON output only
ez-ai-pipeline run --pipeline <id> --input <text> --quiet # Minimal output
```

### `list` - 显示可用的管道

```bash
ez-ai-pipeline list
ez-ai-pipeline list --json
```

### `validate` - 验证管道配置

```bash
ez-ai-pipeline validate --pipeline <id>
```

### `init` - 从模板创建新管道

```bash
ez-ai-pipeline init <name>
```

### `web` - 启动网络仪表板

```bash
ez-ai-pipeline web              # Start on default port 3000
ez-ai-pipeline web -p 8080      # Start on custom port
```

打开本地网络界面浏览管道,并在浏览器中直接执行.

**特征 :**

-   **运行管道**: 执行任何有实时进度跟踪的管道
-   **现场进展**: 完成WebSocket功能更新的监视阶段
-   **费用追踪**: 在每个阶段完成时参见成本累积
-   **查看产出**: 浏览所有管道执行结果
-   **阶段细节**: 探索分阶段产出和配置
-   **CLI 模式**: 使用 Claude 代码、 OpenCode 或 Aider 而不是 API 密钥

**执行模式 :**

-   **API 模式**: 使用您的 Anthropic API 密钥( 在 ATHROPIC API KEY 设定时默认)
-   **CLI 模式**: shells out to Claude Code, OpenCode, 或 Aider (不需要 API 密钥)

仪表板自动检测器安装了 CLI 工具, 并允许您选择首选的执行模式 .

**从网络运行管道 :**

1.  启动网络仪表板 : `ez-ai-pipeline web`
2.  从边栏导航到管道
3.  使用 CLI 模式选择执行模式( API 或 CLI) 和工具
4.  在文本区域输入您的提示
5.  点击“运行管道”或按 `Ctrl+Enter`
6.  在每个阶段执行时观察实时进度
7.  查看最终优化的输出

**键盘快捷键 :**

-   `Ctrl+Enter` - 运行管道
-   `Escape` - 取消运行中的执行

## 包括管道

装有随时可以使用的管道的邮轮:

### `prompt-optimizer`

优化推动AI更好回应. 分析输入,识别改进,并生成增强版本.

```bash
ez-ai-pipeline run -p prompt-optimizer -i "Your prompt to optimize"
```

### `pipeline-generator`

从自然语言描述中生成新的管道配置.

```bash
ez-ai-pipeline run -p pipeline-generator -i "Create a pipeline that summarizes articles"
```

## 管道配置

管道是类型脚本文件 `pipelines/` 目录 :

```typescript
import type { PipelineConfig } from "../src/typings/pipeline.ts";

const config: PipelineConfig = {
  pipeline: {
    id: "my-pipeline",
    name: "My Pipeline",
    version: "1.0.0",
    description: "Description of what this pipeline does",
    settings: {
      enableCaching: true,
      enableEarlyExit: true,
      maxRetries: 2,
      timeoutMs: 300000,
    },
  },
  stages: [
    {
      id: "stage-1",
      name: "Analyze Input",
      type: "analyze",
      model: {
        providerID: "anthropic",
        modelID: "claude-haiku-4-5-20251001",
        tier: "small",
        maxTokens: 1024,
        temperature: 0.1,
      },
      prompt: {
        systemPrompt: "You are an expert analyst.",
        template: `Analyze this: {{input_prompt}}`,
        variables: [
          { name: "input_prompt", source: "input", path: "prompt", required: true },
        ],
      },
      output: {
        format: "json",
        extract: [
          { name: "result", path: "result", required: true },
        ],
      },
    },
  ],
};

export default config;
```

## 阶段类型

-   `analyze` - 分析和提取信息
-   `structure` - 调整或组织内容
-   `enhance` - 改进或丰富内容
-   `validate` - 根据标准验证结果
-   `test` - 测试产出或运行检查
-   `iterate` - 进行反复改进
-   `custom` - 自定义处理阶段

## 可变源

变量可以来自:

-   `input` - 管道的原始输入
-   `previousStage` - 前一个阶段的产出
-   `context` - 整个管道的累积背景
-   `static` - 在配置中定义的静态值

## 条件

### 跳过如果

满足条件时跳过一个阶段 :

```typescript
conditions: {
  skipIf: {
    condition: { path: "status", equals: "complete" },
    sourceStage: "stage-1",
  },
}
```

### 运行如果

仅在满足条件的情况下运行一个舞台:

```typescript
conditions: {
  runIf: {
    condition: { path: "needsWork", equals: true },
    sourceStage: "stage-1",
  },
}
```

### 提前退出

如果满足条件,则提前退出管道:

```typescript
conditions: {
  earlyExit: {
    condition: { path: "overall", equals: "COMPLETE" },
    returnStage: "stage-1",
  },
}
```

## 产出

结果被保存到 `outputs/` 目录 :

-   `result-{pipeline}-{timestamp}.json` - 全部编审结果
-   `prompt-{pipeline}-{timestamp}.md` - 优化快速(快速管道)

## 网络 API

网络仪表板显示一个 REST API 和 WebSocket 程序访问端点:

### REST 终点

| 方法 | 终点 | 说明 |
| --- | --- | --- |
| 获取 | `/api/pipelines` | 列出所有可用的管道 |
| 获取 | `/api/pipelines/:id` | 获取管道配置 |
| 邮政 | `/api/pipelines/:id/run` | 启动管道执行 |
| 获取 | `/api/executions/:id` | 获取执行状态 |
| 邮政 | `/api/executions/:id/cancel` | 取消运行中的执行 |
| 获取 | `/api/outputs` | 列出全部执行产出 |
| 获取 | `/api/outputs/:filename` | 获取特定输出文件 |
| 获取 | `/api/config/status` | 检查是否配置了 API 密钥 |

### 通过 API 运行管道

```bash
# Start execution
curl -X POST http://localhost:3000/api/pipelines/prompt-optimizer/run \
  -H "Content-Type: application/json" \
  -d '{"input": "Your prompt to optimize"}'

# Response: { "executionId": "exec_123...", "pipelineId": "prompt-optimizer", "status": "started" }

# Check status
curl http://localhost:3000/api/executions/exec_123...

# Cancel execution
curl -X POST http://localhost:3000/api/executions/exec_123.../cancel
```

### 实时更新的 WebSocket

连接到 `ws://localhost:3000/ws` 实时执行进度:

```javascript
const ws = new WebSocket('ws://localhost:3000/ws');

// Subscribe to an execution
ws.send(JSON.stringify({ type: 'subscribe', executionId: 'exec_123...' }));

// Receive events
ws.onmessage = (event) => {
  const data = JSON.parse(event.data);
  // Event types: stage:started, stage:completed, stage:failed,
  //              stage:skipped, execution:completed, execution:cancelled
  console.log(data);
};
```

## 发展

```bash
# Run tests
bun test

# Type check
bun run typecheck

# Format code
bun run format
```

## 项目结构

```
ez-ai-pipeline/
├── src/
│   ├── index.ts              # CLI entry point
│   ├── cli/                  # CLI commands and UI
│   │   └── commands/         # Command implementations (run, list, validate, init, web)
│   ├── core/                 # Pipeline execution engine
│   ├── schema/               # Zod schemas and validation
│   ├── typings/              # TypeScript type definitions
│   ├── utils/                # Utilities (cost, templates, etc.)
│   └── config/               # Configuration and constants
├── pipelines/                # Included pipeline definitions
├── web/                      # Web dashboard source
├── web-dist/                 # Built web assets (included in npm package)
├── outputs/                  # Generated outputs
├── tests/                    # Test files
└── package.json
```

## 支持的模式

### 安东尼

-   claude-opus-4-5-20250929(大号)
-   claude-sonnet-4-5-20250929(中型)
-   克来德-海库-4-5-20251001(小)

### 开放AI

-   gpt-4o(中层)
-   gpt-4o-mini( 小号)
-   gpt-4-涡轮(大)

### 谷歌

-   gemini-1.5-正(大)
-   遗传1.5-发光(小)
-   双发( 小)

## 许可证

麻省理工学院执照 - 看 [自由主义](https://npmcn.com/package/%40ez-corp/ez-ai-pipeline/LICENSE) 详细情况.

## 捐款

见 [捐款额](https://npmcn.com/package/%40ez-corp/ez-ai-pipeline/CONTRIBUTING.md) 捐款准则.

## 常见问题

### @ez-corp/ez-ai-pipeline 是什么？

使用 OpenCode SDK 执行快速优化管道的生产准备的 CLI 工具

### 如何安装 @ez-corp/ez-ai-pipeline？

在项目目录运行 npm install @ez-corp/ez-ai-pipeline，或使用 pnpm add / yarn add / bun add。它还提供命令行工具 ez-ai-pipeline，可以用 npx ez-ai-pipeline 直接运行。

### @ez-corp/ez-ai-pipeline 支持 TypeScript 吗？

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

### @ez-corp/ez-ai-pipeline 支持 ESM 还是 CommonJS？

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

### @ez-corp/ez-ai-pipeline 需要什么版本的 Node\.js？

package\.json 的 engines 字段要求 Node\.js \>=18\.0\.0。版本不符时 npm 默认只给出警告，开启 engine-strict 后会拒绝安装。

### @ez-corp/ez-ai-pipeline 可以商用吗？

@ez-corp/ez-ai-pipeline 使用 MIT 许可。宽松许可：允许商业使用、修改和再分发，通常只需在分发时保留原版权与许可声明。以上为概括，不构成法律意见，请以许可原文为准。

### @ez-corp/ez-ai-pipeline 的下载量有多少？

根据 npm 官方下载统计，@ez-corp/ez-ai-pipeline 在 2026/10/14 – 2026/11/12 这 30 天内被下载 2,082 次，日均约 69 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入，适合横向比较热度，不能直接等同于使用人数。

### @ez-corp/ez-ai-pipeline 还在维护吗？

最新版本 1\.4\.4 发布于 2026/01/09（10 个月前）；至今共发布 11 个版本，其中过去 12 个月发布了 11 个；首次发布于 2025/12/22。发布频率只是参考信号：功能稳定的工具可能很少需要更新，建议结合源码仓库的 issue 和提交记录判断。

