@currents/cmd

中文文档
3.0.0发布于 2026/11/05MITTypeScriptESM + CJS构建来源已验证近 30 天下载 24.9万

Currents CLI tools

原始使用文档
文档目录13 节
  1. Installation
  2. Upload test results
  3. Notes
  4. Configuration
  5. Attach files to a run
  6. Share a run
  7. Cancel a run
  8. Capture a session as evidence
  9. Use Currents API
  10. Cache test artifacts
  11. Agent skill
  12. Guides
  13. Troubleshooting

@currents/cmd

CLI tool for Currents - a cloud platform for debugging, troubleshooting, and analyzing CI tests.

Installation

Requires Node.js 22.13 or later.

npm install @currents/cmd --save-dev

Outside a project that installs @currents/cmd, run npx --package @currents/cmd@2 currents. Without the package, npx currents runs an unrelated npm package named currents.

Upgrading from 1.x: see Upgrade @currents/cmd to 2.0.

Upload test results

  • Generate test results with one of the supported reporters
  • Upload the results
npx currents run upload --project-id=xxx --key=yyy

For JUnit XML reports, run upload converts them to the Currents format first, then uploads them. Put quotes around the --input-file pattern, so that the CLI expands it and not the shell:

npx currents run upload --project-id=xxx --key=yyy --input-format junit --input-file "reports/*.xml" --framework postman

--framework takes cypress, postman, node, vitest or wdio. For Cypress run results saved by after:run, use --input-format cypress-json --input-file results.json without --framework: it uploads every attempt, screenshot and video. The converted reports are saved to --output-dir, or --report-dir, or a new folder in .currents. A folder you name must be empty or not exist yet.

ℹ️ Get familiar with CI Build ID 📖 before using currents in CI. It is important to set the CI Build ID explicitly using --ci-build-id option, if you are using CI sharding or multiple CI machines to parallelize your tests. If not set explicitly, the CI Build ID will be set to a random value.

Notes

Obtain --project-id and --key from https://app.currents.dev to identify the project and associate the results with your organization.

currents will upload the results, as follows:

  • use process.env.CURRENTS_REPORT_DIR or --report-dir to read the results previously generated by one of supported reporters, otherwise
  • use the most recently created folder named as .currents/[timestamp]-[uuidv4()] in the current working directory

currents run upload sends the list of every test of the run, which Currents uses to show the progress of a sharded run. It reads the list from fullTestSuite.json, which @currents/jest writes to the report, or builds it from the results. A shard has only the results of its own tests, so without fullTestSuite.json the command runs the Jest installed in the current folder to list the tests of every shard. Run it from the project folder, with Jest 29.5 or later installed. @currents/cmd does not install Jest. In a Detox project, that Jest run loads the test files in the node test environment, so Detox does not start a device. A test file that uses Detox while it loads gets its tests from the results of the shard that ran it, and the command prints a warning.

For Detox runs reported by @currents/jest, currents run upload also attaches the videos, screenshots and logs that Detox recorded to the matching test attempt, adds the element actions of detox.trace.json as steps, and uploads detox.trace.json. Run it after detox test exits: Detox finishes writing the files only then.

currents run upload applies the actions of the project to the results before it sends them. The tests already ran, so each attempt keeps its result, errors and artifacts:

  • a skip action marks the test as skipped
  • a quarantine action marks a failed test as skipped
  • a tag action adds its tags to the test

The dashboard shows which action changed each test. Actions with regex or date conditions are not applied yet. The command uploads the results without actions when it can't get them.

With --fail-on-failures, or CURRENTS_FAIL_ON_FAILURES=true, the command exits with 1 after it uploads the results when a test failed, and lists the failed tests. A test that an action quarantined or skipped does not count. Let the test command pass and use the upload to fail the CI job, so a quarantined test does not fail it:

npx detox test || true
npx currents run upload --fail-on-failures

Configuration

Please note that all options apart from --project-id and --key are optional.

PropertyTypeDescriptionEnvironment variableDefault
-k, --keystringThe record key to record the results to Currents. Read more: https://currents.dev/readme/guides/record-keyCURRENTS_RECORD_KEY-
-p, --project-idstringThe id of the project for reportingCURRENTS_PROJECT_ID-
--machine-idstringUnique identifier of the machine running the tests. If not provided, it will be generated automatically. See: https://currents.dev/readme/readme?q=machineIdCURRENTS_MACHINE_ID[random-string]
--report-dirstringThe folder containing the test results created with one of the supported reportersCURRENTS_REPORT_DIR.currents/*
--ci-build-idstringThe id of the build to record the test run. Read more: https://currents.dev/readme/guides/ci-build-idCURRENTS_CI_BUILD_IDauto:[random-string]
--debugbooleanEnable debug logsCURRENTS_DEBUGfalse
-t, --tagstringComma-separated tag(s) for recorded runs in CurrentsCURRENTS_TAG-
--environmentstringThe environment to label the run with, e.g. stagingCURRENTS_ENVIRONMENT-
--disable-title-tagsbooleanDisable extracting tags from test title, e.g. Test name @smoke would not be tagged with smokeCURRENTS_DISABLE_TITLE_TAGSfalse
--remove-title-tagsbooleanRemove tags from test names in Currents, e.g. Test name @smoke becomes Test name in the dashboardCURRENTS_REMOVE_TITLE_TAGSfalse
--fail-on-failuresbooleanExit with 1 after uploading when a test failed. A test quarantined or skipped by a Currents action does not countCURRENTS_FAIL_ON_FAILURESfalse

An option on the command line wins over its environment variable. The configuration is also available by running the CLI command with the --help argument.

Attach files to a run

currents run attach uploads files, such as logs or screenshots, to a run that CI already recorded. It uses the record key, or an API key with write access when no record key is set:

npx currents run attach --key <record-key> --project-id <id> --ci-build-id <build-id> --machine-id shard-1 docker-logs.zip
npx currents run attach --key <record-key> --project-id <id> --ci-build-id <build-id> --spec tests/cart.spec.ts --test-title "adds an item" --attempt 0 screenshot.png

Without --spec, the files are attached to the whole run. For the options, run npx currents run attach --help.

Share a run

currents run share prints a public link to a run, or to one spec file or test of it, and a link to the same content as Markdown. It uses an API key with write access:

npx currents run share <run-id>
npx currents run share <run-id> --instance-id <instance-id> --test-id <test-id> --purpose fix

--purpose report, the default, holds every test with its attempts and files, for a person. --purpose fix holds the failure context, for an agent fixing the tests. For the options, run npx currents run share --help.

Cancel a run

currents run cancel cancels a run in progress, for example when its CI job is cancelled. It uses the record key:

npx currents run cancel --key <record-key> --project-id <id> --ci-build-id <build-id>

See Cancel Runs on Workflow Cancellation for GitHub Actions.

Capture a session as evidence

currents session captures an agent or browser session, such as a bug before and after a fix. Each command uses the record key, or an API key with write access when no record key is set. In CI, where CURRENTS_RECORD_KEY is already set, nothing else is needed; elsewhere, set an API key once as CURRENTS_API_KEY:

export CURRENTS_API_KEY=<api-key>
npx currents session start --project-id <id> --title "Checkout fails on empty cart" --status failed
npx currents session attach before.png .playwright-mcp/traces
npx currents session share --expires-in-days 7

session share prints a public link to the session page, and a link to the same content as Markdown. For the options, run npx currents session --help.

Use Currents API

  • Retrieve information about Currents resources in JSON format. See the REST API docs.

ℹ️ The command requires the --project-id and --api-key from Currents to authenticate the request and provide the required data. Alternatively, you can set the CURRENTS_PROJECT_ID and CURRENTS_API_KEY environment variables.

Supported operations:

  • Obtain run data using the CI Build ID 📖 by running the following command:

    npx currents run get --ci-build-id <ci-build-id> --output path/to/save/run.json
    
  • Obtain the last completed run data, filtered by --branch and/or --tag, by running the following command:

    npx currents run get --branch <branch> --tag <tag-1,tag-2,...tag-n>
    

For more examples and usage options, run npx currents run get --help.

To call any other REST API route, use currents api with the route path. It reads the API key from --api-key or CURRENTS_API_KEY:

npx currents api /v1/runs/<run-id>
npx currents api /v1/runs/<run-id>/cancel -X PUT

For the options, run npx currents api --help.

Cache test artifacts

The currents cache command allows you to archive files from specified locations and save them under an ID in Currents storage. It also stores a meta file with configuration data. You can provide the ID manually, or it is made from the variables of the CI job. When no CI job is detected the ID is random, and the command warns: pass --id to save and restore the same cache.

To cache files, use the following command:

npx currents cache set --key <record-key> --id <id> --path <path-1,path-2,...path-n>

To download files, use the following command:

npx currents cache get --key <record-key> --id <id>

For more examples and usage options, run npx currents cache --help.

Agent skill

The package includes the currents-cli agent skill, which tells coding agents how to use this CLI.

# Print the skill
npx currents skill

# Add it to the project for Codex and Cursor, in .agents/skills/currents-cli
npx currents skill --install

# Add it for Claude Code
npx currents skill --install --dir .claude/skills

The skill is also in this repository, in skills/currents-cli: npx skills add https://github.com/currents-dev/currents-reporter --skill currents-cli.

Guides

npx currents docs lists the guides that ship with the package, such as the CI setup steps. npx currents docs <topic> prints one as Markdown. The guides are in docs/.

Troubleshooting

Run the CLI command with the --debug argument or prefix it with DEBUG="currents,currents:*" to obtain detailed information about the command execution process. Keys are hidden in the debug output.

The full documentation is at https://docs.currents.dev/resources/reporters/currents-cmd.

版本与发布记录

@currents/cmd 共发布 87 个版本,首次发布于 2024/07/11;过去 12 个月发布了 17 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
3.0.0latest2026/11/056 天前
2.3.02026/10/1626 天前
2.2.02026/10/111 个月前
2.1.02026/10/101 个月前
2.0.22026/10/071 个月前
2.0.12026/10/071 个月前

其他发布通道:oldversion → 1.9.0,beta → 2.0.0-beta.0。

关于 @currents/cmd 的常见问题

@currents/cmd 是什么?

Currents CLI tools

如何安装 @currents/cmd?

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

@currents/cmd 支持 TypeScript 吗?

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

@currents/cmd 支持 ESM 还是 CommonJS?

同时提供 ES Module 与 CommonJS 入口,import 和 require() 都可以使用,打包工具会自动选择合适的版本。

@currents/cmd 需要什么版本的 Node.js?

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

@currents/cmd 可以商用吗?

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

@currents/cmd 的下载量有多少?

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

@currents/cmd 还在维护吗?

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