@canra/cli

中文文档
0.9.0发布于 2026/11/06MITES Module零依赖近 30 天下载 1920

CLI for Canra, the registry of machine-readable specs: fetch, search, and publish specs.

原始使用文档
文档目录5 节
  1. Commands
  2. Vendoring specs
  3. Publishing
  4. For agents
  5. License

@canra/cli

Command-line client for Canra, a registry of machine-readable specifications (library APIs, protocols, data formats). Fetch a spec, generate an implementation in any language, and check it against the spec's test vectors.

Runs on Node 20+ or Bun. No install needed:

npx @canra/cli search json
npx @canra/cli info canra/json
npx @canra/cli fetch canra/json

Commands

Or install it to get the canra command:

npm install -g @canra/cli
canra search json
CommandWhat it does
canra search <query>Search the registry
canra info <owner>/<name>Show a spec's metadata
canra fetch <owner>/<name>[@version]Download a spec (latest or a pinned version), verify its SHA-256, and save it to .canra/specs/<owner>/<name>/
canra outdated [--json]Check fetched specs for newer versions; exits 1 if any is outdated or quarantined
canra update [<owner>/<name>]Re-fetch the latest version of every outdated spec (or the named one); exits 1 if any spec is quarantined or fails to update
canra remove <owner>/<name>Delete a fetched spec from .canra/specs/
canra loginSave a registry URL and API token
canra whoamiShow which account your saved token belongs to
canra publish <file.spec.md> [--accepts <suggestion-id>]Publish a spec (needs a token); --accepts marks that suggestion on the spec accepted
canra suggest <owner>/<name> --title "..." [--body "..."] [--file <path.spec.md>]Suggest a change to a spec you don't own (needs a token); --file attaches a full edited spec, which the owner reviews as a diff
canra logoutRemove saved credentials
canra version / canra helpVersion and usage

<owner> is a user or organization name in any case: Canra/json and canra/json are the same spec, saved under the lowercase owner in .canra/specs/.

Vendoring specs

Commit .canra/ to source control. The saved specs are the record of which spec versions your project implemented (a version is exact and immutable). After canra update, git diff .canra/ shows what changed in each spec.

Publishing

Create an API token at canra.dev → Account → API tokens, choosing its permissions and expiry (canra publish needs Publish specs), then:

npx @canra/cli login        # paste the token when asked
npx @canra/cli publish my-spec.spec.md

Credentials are stored in ~/.canra/config.json.

For agents

You may not need the CLI at all:

  • Raw spec markdown: https://canra.dev/specs/{owner}/{name}.md
  • Site index for LLMs: https://canra.dev/llms.txt
  • Remote MCP server (no auth): https://canra.dev/mcp, e.g. claude mcp add --transport http canra https://canra.dev/mcp

API docs: https://canra.dev/docs/api

License

MIT

版本与发布记录

@canra/cli 共发布 11 个版本,首次发布于 2026/10/26;过去 12 个月发布了 11 个版本。

版本发布日期距今
0.9.0latest2026/11/064 天前
0.8.02026/11/045 天前
0.7.02026/11/036 天前
0.6.02026/11/018 天前
0.5.02026/11/018 天前
0.4.02026/11/019 天前

关于 @canra/cli 的常见问题

@canra/cli 是什么?

CLI for Canra, the registry of machine-readable specs: fetch, search, and publish specs.

如何安装 @canra/cli?

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

@canra/cli 支持 TypeScript 吗?

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

@canra/cli 支持 ESM 还是 CommonJS?

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

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

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

@canra/cli 可以商用吗?

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

@canra/cli 的下载量有多少?

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

@canra/cli 还在维护吗?

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