@naturali/cli

中文文档
0.220.3发布于 2026/11/02UNLICENSEDES Module

Command-line interface for the naturali.ai API, generated from its OpenAPI specs

原始使用文档
文档目录8 节
  1. Configuration
  2. Commands
  3. Values
  4. File values
  5. Output
  6. Generation
  7. Testing
  8. Versioning

@naturali/cli

The naturali command — one command per naturali.ai API operation, generated from the OpenAPI specs.

pnpm add -g @naturali/cli
export NATURALI_TOKEN=nat_sk_...

Configuration

The CLI always talks to https://api.naturali.ai — the only naturali.ai API origin, and not configurable. Credentials and the default project come from the environment:

VariablePurpose
NATURALI_TOKENBearer credential (nat_sk_… or a session JWT). Required.
NATURALI_PROJECT_IDDefault --project-id for commands that take one. An explicit --project-id still wins.

Commands

Every operation is a command named by kebab-casing its operationId: createAgent → create-agent, rotateApiKey → rotate-api-key.

naturali list-commands              # every command, with its description
naturali create-agent --help        # one command's flags, and its docs link

Flags are the spec's parameter names. Kebab-case is the documented convention, but snake_case and camelCase are accepted too — --project-id, --project_id and --projectId are the same flag.

naturali list-agents --project-id proj_V1StGXR8Z5jdHi6B --limit 10

naturali create-agent \
  --project-id proj_V1StGXR8Z5jdHi6B \
  --provider-id aip_V1StGXR8Z5jdHi6B \
  --name support-triage \
  --tool-bindings '[{"tool_id":"tool_V1StGXR8Z5jdHi6B"}]'

Where a flag's value goes — URL path, query string or request body — comes from the spec, so you never have to know.

Values

KindHow to pass it
String--name support-triage
Number / boolean--temperature 0.7, --force (a bare flag is true)
Object--tool-choice '{"type":"tool","name":"get_weather"}'
Arrayrepeat the flag (--capabilities a --capabilities b) or pass a JSON array (--tool-bindings '[{"tool_id":"tool_a"}]')
From a file--content @playbook.md (@@ sends a literal leading @)

An array-typed field is always sent as a list, even with one value.

File values

@path reads the value from disk. A .yaml, .yml or .json file is parsed, and a { "file": "..." } inside it is replaced by that file's contents, resolved relative to the document holding the reference:

# naturali/squad.formation.yaml
resources:
  Playbook:
    type: document
    properties:
      path: /squad/playbook.md
      content:
        file: ../intelligence/playbook.md
naturali validate-formation --project-id proj_V1StGXR8Z5jdHi6B \
  --template @naturali/squad.formation.yaml

That is what lets a formation template declare documents whose text is versioned beside it, instead of carrying a pasted copy of each. Any other extension is read as text and never parsed, so a markdown file opening with { stays a string.

Only a lone { "file": ... } is a reference — an object with other keys beside it is left alone, so a property genuinely named file is not hijacked.

A template can read any file you can. Read one you did not write before deploying it.

Every path parameter a command needs must be passed explicitly; a command that leaves one out fails and names it rather than guessing.

Output

The response body is printed to stdout as formatted JSON, so it pipes into jq:

naturali list-agents --project-id proj_V1StGXR8Z5jdHi6B | jq -r '.data[].id'

A non-2xx response prints the platform's error envelope to stderr and exits 1:

{
  "status": 403,
  "error": { "code": "access_denied", "message": "Not your project" }
}

Generation

src/generated/routes.ts is build output — never edit it, and never commit it. It is rebuilt from api/openapi/v1/*.yaml by pnpm generate, which typecheck, test and build all run first. See ../README.md for the pipeline.

Hand-written source is limited to dispatch, flag parsing, credentials and help; there is no per-endpoint code.

Testing

pnpm test runs the unit suite against a mocked fetch — flag parsing, dispatch, and help output, on every pull request.

pnpm e2e (tests/e2e/smoke.ts) is different: it drives the built CLI binary (bin/naturali) as real subprocesses against the real, deployed API, using a NATURALI_E2E_API_KEY account-scoped key. It proves the one thing the mocked suite can't — that the CLI, the @naturali/sdk it bundles, and the live API actually agree — and it provisions and archives its own throwaway project. It costs real model-provider money, so it only runs as part of the e2e job in main.yml, never on pull requests.

Versioning

Releases are automatic, and the version is shared with the API and with @naturali/sdk — one number, one git tag, three packages. @naturali/[email protected] speaks to API 0.28.0, and naturali --help is generated from the specs that release was built from, so it is always the authority on what your version can do.

Any change to api/openapi/v1/*.yaml regenerates this package and publishes it — new endpoints become new commands without anyone editing the CLI — and so does a change to @naturali/sdk, which is bundled in at build time rather than resolved from npm.

fix:/chore: changes release a patch and feat: a minor, inferred from the squashed commit subject. Every case publishes on merge, breaking changes included. See the repository's PIPELINE.md and CHANGELOG.md.

版本与发布记录

@naturali/cli 共发布 419 个版本,首次发布于 2026/07/29;过去 12 个月发布了 419 个版本。

版本发布日期距今
0.220.3latest2026/11/021 天前
0.220.22026/11/021 天前
0.220.12026/11/021 天前
0.220.02026/11/021 天前
0.219.12026/11/011 天前
0.219.02026/11/012 天前

关于 @naturali/cli 的常见问题

@naturali/cli 是什么?

的命令行接口。ai API,由OpenAPI规范生成

如何安装 @naturali/cli?

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

@naturali/cli 支持 TypeScript 吗?

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

@naturali/cli 支持 ESM 还是 CommonJS?

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

@naturali/cli 可以商用吗?

@naturali/cli 使用 UNLICENSED 许可。作者声明为 UNLICENSED,即不授予公开使用许可(与公共领域的 Unlicense 不同)。使用前需获得作者授权。以上为概括,不构成法律意见,请以许可原文为准。

@naturali/cli 还在维护吗?

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