@earlyai/cli

中文文档
2.23.16发布于 2026/11/01ISCCommonJS

early cli

原始使用文档

@earlyai/cli

AI-powered CLI tool that generates unit tests for TypeScript/JavaScript codebases.

Requires Node.js >= 20.19.0.

Installed as the early command (ISC licensed).

npm install -g @earlyai/cli

Commands

gather-stats

Gathers adoption statistics for EarlyAI-generated test files in merged PRs. Analyzes which .early.test.* files were added, modified, or deleted, and reports adoption metrics to the EarlyAI backend.

Alias: stats

early gather-stats [options]

Options

OptionEnv VarDefaultDescription
--api-key <key>API_KEY—EarlyAI API key (required)
--token <token>TOKEN—GitHub/Bitbucket token (required)
--git-org <org>GIT_ORGauto-detectedGit organization name
--git-repo <repo>GIT_REPOauto-detectedGit repository name
--scm-provider <provider>SCM_PROVIDERgithubSCM provider (github or bitbucket)
--ref-name <ref>REF_NAME—Head branch name (required)
--backfill [value]BACKFILLfalseIgnore last run timestamp and reprocess recent PRs
--max-prs <number>MAX_PRS5Maximum PRs to process on first run or backfill
--pr-number <number>PR_NUMBER—Process a single PR by number
--summary-only [value]SUMMARY_ONLYtrueReport only the adoption summary per PR. When false, also includes per-file details (file paths, change types) and per-commit breakdowns

How it works

Incremental by default. On each run, gather-stats records a timestamp. The next run only processes PRs merged after that timestamp — no cap on how many.

First run. When no previous run exists, there is no timestamp to start from. Instead, it processes the most recent merged PRs up to --max-prs (default: 5).

Backfill mode (--backfill). Resets the "since" timestamp and reprocesses the most recent merged PRs up to --max-prs. Use this to reprocess PRs that were missed or to refresh data after a bug fix.

Single PR mode (--pr-number). Fetches and processes only the specified PR. Bypasses the timestamp check, --backfill, and --max-prs. Use this to refresh data for a specific PR.

What gets reported. A merged or closed PR is included in the report if:

  1. Its diff contains .early.test.* files (added, modified, or deleted), OR
  2. Any of its commits contain .early.test.* files, OR
  3. It has an EarlyAI workflow run (Early ran on it, even if no test files were committed)

Open PRs and PRs with no EarlyAI involvement are skipped.

PR state tracking. Each reported PR includes its state (MERGED or CLOSED). This is sent as prState in the adoption entry, allowing the backend to store it in pr_change_type for the SUMMARY record. The UI can use this to distinguish between merged PRs (green dot) and closed-without-merge PRs.

Summary-only mode (--summary-only, default: true). By default, only the adoption summary is reported for each PR (how many tests were added, modified, deleted, or unchanged). This creates a single SUMMARY record per PR on the backend. Set --summary-only false to also include per-file details (file paths, change types) and per-commit breakdowns — useful for debugging or detailed auditing.

Examples

# Normal incremental run
early gather-stats --api-key $KEY --token $TOKEN --ref-name master

# First run or backfill with more PRs
early gather-stats --api-key $KEY --token $TOKEN --ref-name master --backfill --max-prs 50

# Refresh data for a specific PR
early gather-stats --api-key $KEY --token $TOKEN --ref-name master --pr-number 1419

版本与发布记录

@earlyai/cli 共发布 139 个版本,首次发布于 2026/01/12;过去 12 个月发布了 139 个版本。

版本发布日期距今
2.23.16latest2026/11/012 天前
2.23.152026/11/012 天前
2.23.142026/10/304 天前
2.23.132026/10/295 天前
2.23.122026/10/286 天前
2.23.112026/10/268 天前

关于 @earlyai/cli 的常见问题

@earlyai/cli 是什么?

早期的cli

如何安装 @earlyai/cli?

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

@earlyai/cli 支持 TypeScript 吗?

该包的 package.json 没有声明类型入口。需要类型提示时,可以在 npm 上查找社区维护的 @types/earlyai__cli 是否存在。

@earlyai/cli 支持 ESM 还是 CommonJS?

以 CommonJS 形式发布,可以直接 require();在 ES Module 项目中也可以用 import 引入(Node.js 会把 module.exports 作为默认导出)。

@earlyai/cli 需要什么版本的 Node.js?

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

@earlyai/cli 可以商用吗?

@earlyai/cli 使用 ISC 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@earlyai/cli 还在维护吗?

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