# @freetesh/canon 中文文档

规范地址：https://npmcn.com/package/%40freetesh/canon/

版本：6\.7\.0
npm 元数据更新时间：2026-11-07T05:46:00.234Z
中文译文更新时间：2026-11-15T13:28:47.405Z
软件包许可：MIT

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

原始 npm 页面：https://www.npmjs.com/package/%40freetesh/canon
原文对照：https://npmcn.com/package/%40freetesh/canon/?lang=original
项目主页：https://ritesh-firodiya.github.io/products/canon/
源码仓库：https://github.com/ritesh-firodiya/canon-cli

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

- 包体积（解压后）：675 kB，265 个文件
- 模块格式：ES Module
- TypeScript 类型：未声明
- Node.js 要求：\>=22
- 运行依赖：4 个
- 首次发布：2026-10-27T10:27:51.186Z
- 最新版本发布：2026-11-07T05:45:59.863Z
- 近 30 天下载量：9901（2026-10-16 至 2026-11-14，npm 官方下载统计）
- 已发布版本数：52（近 12 个月 52 个）

## 中文简介

canon CLI: 将你的域名知识和AI规则保存在你的Repo中,并强制执行.

## 安装

```sh
npm install @freetesh/canon
```

也可以使用：`pnpm add @freetesh/canon`、`yarn add @freetesh/canon`、`bun add @freetesh/canon`

## README

![canon icon](https://npmcn.com/package/%40freetesh/canon/.github/assets/icon.svg)

# 宽度

**请在提示上看到您的用法和快速缓存 .** 其余的只要你想打开.

一个新安装的 Canon 做一件事: 它在克洛德码上加了个带 快点 它没有添加技能,没有启动文本和搜索服务器. 在我们的测试中 完全没有添加启动符号 .

```
☼  $1.20                                      M  7D 41%  5H 96%  ctx 62%  ↻ 53m +$0.17
```

-   **唤醒:** QQ已关闭; 点击后将它变成绿色的QQ, 在会话打开时保持这个 Mac 及其屏幕保持清醒 .
-   **回复大小 :** S, M或L. 点击会移动到下个大小, 它会与每个提示相邻,所以缓存会保持.
-   **左用法** 在你的7天和5小时的窗口中,当它运行低时会重设时间,而房间则留在上下文窗口中.
-   **快速缓存 :** 多久它保持温暖, 和你的下一个信息 费用一旦冷。 点击一次重新启动时段; 标签会显示成本 .
-   **点击可查看其含义 :** 每个短项都用一行来解释自己,这行本身就结束了.

其它的都关了 直到你打开它来换货 自由与麻省理工学院.

## 安装

```bash
claude plugin marketplace add ritesh-firodiya/canon-cli
claude plugin install canon@canon
```

这就是整个乐队。 要打开其他东西,你还需要CLI:

```bash
npm install -g @freetesh/canon
```

## 打开你想要的

在 repo 中运行, 或将名称添加到 `features:` 内 `.context/context.yaml`。 。 。 . `canon disable <feature>` 又关了.

```bash
canon enable process
```

| 特性 | 你得到的东西 | 添加启动令牌 |
| --- | --- | --- |
| `process` | 决策门,决定,标准,从历史中学习,用通卡的想法,以及你的舞台,大门,运行和检查乐队 | 约550人 |
| `knowledge` | 从你的Repo知识中搜索并回答, 本地索引是每个产品一个收藏 | 约600人 |
| `routing` | 努力和模型选择每个提示,显示在乐队上,你可以覆盖它 | 无 |

一个特性只影响您启用的重播 。 打开你的车 机器,在每个 repo 和其他文件夹中,添加 `--user`数字 : `canon enable routing --user`在父文件夹中开始的会话不装入 repo 的插件, 因此使用 `--user` 如果你这样做.

### `process`:事实而非假设

![canon weighs a request. Two of three claims have no facts and the request breaks a decided rule, so it pushes back and stops until the user brings facts, agrees to terms, or drops it.](https://npmcn.com/package/%40freetesh/canon/.github/assets/demo.svg)

-   **在演戏前先拍.** 对于非部落请求,克洛德检查 宪法,维基和决定,特征和任务,成本与价值, 和无文的梯子,然后回答: **做到这一点**, (中文(简体) ), **做不一样的** 或者说 **倒车** 与引用。 尝试 `/canon-process:weigh add a dark mode toggle`。 。 。 .
-   **没有假设.** 请求中的每一项索赔(“用户想要这个”,“缓慢”) 与 repo 及其数据源进行核对,并标记是否备份.
-   **你的数据来源 工具.** Repo描述了每个持有其 数据a `SOURCE.*` 用于命名 MCP 服务器、 技能或 CLI 的维基实体 读它。 门只询问它是否背信弃义.
-   **一地决定.** `/canon-process:decision` 每个话题写一个文件, 选择更改时覆盖 . `tasks.md` 只能公开工作 历史就是历史.
-   **维则被行.** 快速的大小大改变什么,直到重量运行.
-   **学习历史.** `/canon-process:learn` 读取 `canon learn` 并提议规则的改变 人们总是凌驾于规则之上。 它不会改变任何事情 直到你决定.
-   **更多点子.** `/canon-process:wildcard` 每10个想法中就有2个打破了你的模式.

### `knowledge`: 在克劳德回答之前找到的

每个 repo 的 wiki 和 特征 板 的索引 [QMD 主题](https://github.com/tobi/qmd),克劳德在回答前搜索。 询问用 `/canon-knowledge:ask`· ; `/canon-knowledge:ingest` 毫无争议地抓住了课程的教训。 每一个输入的提示都包含着最多三页的文字,通过标题和路径,所以克洛德在回答之前可以看到存在的东西.

```bash
npm install -g @tobilu/qmd --allow-scripts=node-llama-cpp,tree-sitter-go,tree-sitter-python,tree-sitter-rust,tree-sitter-typescript,tree-sitter-javascript
```

### 知识之门:总是在产品回放中

在克劳德写下一页之前 `.context/`,乐队运行 `canon gate`: 每条规则 已经,在还本付息 和它会与页。 重复事实的一页 另一页,缺乏它的前题 或打破一个盖子被拒绝, 克劳德被告知修复它或 拿来给你.

### `routing`: 每一提示的正确努力

Haiku通过自己的登录,将每个输入的提示分为小、中或大. 努力跟随每一个提示,因为这样可以保存缓存. 模特被选中 开始会话,然后只向上移动,因为更改会重新加载聊天. 你的选择在乐队,或 `/model`总是赢. `canon learn --cost` 显示计数 和什么决定成本。 无头会议和 `canon run` 特工绝对不会被跟踪.

## 您运行的图标

命令只在输入时运行 。 这些功能不需要打开:

-   **`canon learn`** 说明历史所言:判决和规则的改变; `--cost` 按技能、工具、模型和产品来显示您所使用和成本.
-   **`canon check`** 当一个 repo 打破其规则时失败: 排版、 wiki 前题、 stale pages、 大小封顶、 被屏蔽的任务, 功能页,死道和链接,不再符合其代码的维基页面,缺少最小起始页面(作为警告),没有条子屋的价格,导入架构,管道门和你自己的检查器. `canon hooks install` 每推一推都开.
-   **`canon run`** 用一个特工通过管道移动一个记录, 停留在每一个门并花出上限.
-   **`canon check --standards`** 按名称显示默认值和库的 repo 导入( y)`standards: [design-sets, pipeline]`) (中文(简体) ).

一个主机知识网站,每个repo的 `.context/` 在一个地方 一个团队, 是一种基于这个CLI的单独付费产品.

## {\\fn黑体\\fs22\\bord1\\shad0\\3aHBE\\4aH00\\fscx67\\fscy66\\2cHFFFFFF\\3cH808080}在回购中能期待什么

{\\fn黑体\\fs22\\bord1\\shad0\\3aHBE\\4aH00\\fscx67\\fscy66\\2cHFFFFFF\\3cH808080}雷波把知识藏在 `.context/`输入 **纯背景**: 一个家的事实, 简洁地说,每个事实都有来源和日期.

-   [`standards/constitution.md`](https://npmcn.com/package/%40freetesh/canon/standards/constitution.md): 每一份申请都要权衡十一条规则.
-   [`standards/context.md`](https://npmcn.com/package/%40freetesh/canon/standards/context.md):知识生活的地方,以及起步的最小:目的页,词汇,如何运行,架构,决定.
-   [`standards/writing.md`](https://npmcn.com/package/%40freetesh/canon/standards/writing.md):每一页的阅读方式.

`canon check` 当缺少一个最小起始页时警告 。 这是雷波自己的 `.context/` 遵循同样的规则: [`.context/README.md`](https://npmcn.com/package/%40freetesh/canon/.context/README.md)。 。 。 .

## 所有命令

```bash
canon init             # write .context/context.yaml and the missing .context files
canon add              # list packs; `canon add expo` adds one and indexes its docs
canon gate <file>      # a page on stdin, judged by every rule before it is written (the band runs it)
canon check            # this repo against the standards (exit 1 on any error); --all for every repo beside it
canon hooks install    # a pre-push hook that runs `canon check` (--all: every product)
canon check --status   # version, kind, modules, config layers, check summary
canon check --standards   # which standards apply here, and where each comes from (--constitution: only the rule titles)
canon check --drift    # only the drift check: each wiki page still matches the code it names
canon check --copies   # shared files against copies.source (--sync repairs the drifted ones, never adds one)
canon update           # update the CLI and the Claude plugin, then refresh: packs, search index, pinned version, models
canon update --refresh # only the refresh, installing nothing
canon models           # the models this machine can run and their prices
canon doctor           # node, git, qmd — plus any tools your config lists
canon learn            # verdicts, and the rule changes overrides propose (--json for the learn skill)
canon new <kind> <t>   # start a page from its template: problem, idea, plan, finding, ...
canon records          # what each kind, status and priority means here
canon queue            # open work, most urgent first, and what it waits for
canon reject <stage> --record <id> --note <why>   # a person sends any stage back; it and later stages run again
canon set <record> field=value   # change a field, checked against the rules
canon done <record>    # mark it complete
canon new experiment <name> --from <stage>   # a named experiment, from any stage
canon run <record>     # move a record through its pipeline with an agent; stops at gates and caps
canon trigger [id]     # read connectors, open problems, join repeats (--run works on new ones)
canon verdict          # put a weigh verdict on the record it judged
canon approve <stage> --record <id>   # a person approves a stage on a record, in a terminal
canon pipeline         # the stages this repo resolves to, and where each stands
canon ui               # this repo's design set on localhost, with canon's shell
canon wiki             # every product wiki on localhost
canon learn --flow <product>   # how far each local Claude conversation got against the pipeline (--write: metrics/flow.json)
canon learn --cost     # what local Claude sessions used and cost at list prices (--skill <name>, --unused, --json, --save)
canon band             # the facts the band above the Claude Code prompt shows, as JSON
canon enable <feature> # turn on process, knowledge or routing for this repo (canon disable turns it off)
```

## 配置

每一次回购都有自己的规则 `.context/context.yaml`; 重播上方没有 读取。 未承诺 `context.local.yaml` 除了它,它覆盖它在一个机器上. 横跨产品(`--all`, (中文(简体) ), `ui`, (中文(简体) ), `learn`)使用文件夹 持有您所持有的还款,或 `CANON_WORKSPACE`。 。 。 .

```yaml
# <repo>/.context/context.yaml — written by `canon init`
canon: 6.0.0
kind: mobile                        # mobile | web | mobile-and-web | package | content
mvp: false                          # listed on Google Play or the App Store; absent means MVP
standards: [design-sets, pipeline, expo]   # canon's library standards this repo follows; ./rules adds a folder of its own
modules: [docs, knowledge, code, listing, refs]
packs: [expo]
name: Acme                          # how the product is written; `named` copies swap it in
features: [routing]                 # what this repo turns on; only the band is on by default
formerly: [acme-old]                # older folder names, so `canon learn --flow` counts their conversations
extends: [../rules/team.yaml]       # organization, product and team rules; the closest wins
product: acme                       # repos naming one product act as one
team: growth
cap: 5                              # dollars per stage, unless a stage sets its own
pipelines:                          # `default` is canon's flow until you change it; add your own
  default:
    - { id: code, verify: [sentry, "https://app.example.com"] }   # check the real source first
    - { id: review, gate: true }
  hotfix:
    - { id: fix, by: agent, cap: 2 }
locked: [pipelines.default.review]  # a lower layer cannot change this
connectors:                         # your tools, read-only; keys stay in .env
  - { id: sentry, via: cli }
  - { id: acme-erp, via: api, target: https://erp.example.com, env: [ACME_ERP_TOKEN] }   # your own
records:                            # add, change or remove record kinds
  - { folder: plans, fields: { timeline: date-range, owner: remove }, required: [timeline] }
  - { folder: campaigns, prefix: CAMP, statuses: [draft, live], sections: [Goal] }
triggers:                           # what opens a Problem; source is a connector, manual or schedule
  - { id: new-error, source: sentry, when: a p0 error, pipeline: hotfix, cap: 2 }
commands:                           # your own checkers, run by `canon check`
  - { id: lint-copy, run: ./scripts/lint-copy.sh, if: .context/designs, module: design }
copies:                             # files copied from one source repo, kept equal to it
  source: ../design-system
  use: [upload, shell-web]          # sets the source names under its own copies.sets
```

```yaml
# ../design-system/.context/context.yaml — the source names its sets
copies:
  sets:
    upload: [scripts/upload.mjs]
    shell-web:
      - { from: designs/mobile/index.html, to: designs/web/index.html, named: true }
```

内建, 每次重播: 移动或网络重播保存 `.context/designs/` (设计) 首先,一个绘制屏幕的回波总是得到设计检查.

姓名一览表`packs`, (中文(简体) ), `standards`, (中文(简体) ), `copies.use`将两个文件合并; `commands`, (中文(简体) ), `doctor.tools`, (中文(简体) ), `wiki.types`, (中文(简体) ), `context.folders` 财务报告和审定财务报表 `context.rootFolders` 按名称合并. `context.rootFolders` (单位:千美元)`{ folder, reason }`) 宣布一个有轨根文件夹 conon 单独离开; 今天只有 `docs` 选中此项.

## 版式

```
.claude-plugin/   plugin manifest and marketplace
hooks/            the band: the only thing on by default
plugins/          what `canon enable` adds per repo: canon-process (weigh, decision, standards, learn, wiki-lint and wildcard skills; weigher and challenger agents), canon-knowledge (ask, ingest)
standards/        default standards
packs/            vendor doc packs
templates/        files init writes (dependency-cruiser base and starters)
evals/            plugin evals on a fixture product
cli/              the canon CLI (TypeScript, vitest); `@freetesh/canon/api` for tools built on it
```

内部 `cli/src/`数字 :

```
index.ts          the program: registers every command
api.ts            what other tools import (`@freetesh/canon/api`)
setup/            init, update, doctor, features (enable/disable), models
know/             packs, the refresh of packs and the search index
enforce/          checks (one file per check; index.ts lists them), the gate, standards, status
work/             records, pipeline and gates, run and trigger
learn/            learn, flow, usage: what history says
serve/            ui, wiki, the band's facts
config/           .context/context.yaml: schema and loading
lib/              shared helpers: files, frontmatter, env, qmd, transcripts, system calls
```

每个功能文件夹都有其逻辑和 `<command>.command.ts` 每个命令(只有选项和输出). 测试镜像它 `cli/test/`。 。 。 .

## 开发

如何运行、测试和释放猎犬本身: [`.context/ops/run.md`](https://npmcn.com/package/%40freetesh/canon/.context/ops/run.md)。 。 。 .

麻省理工学院执照.

## 常见问题

### @freetesh/canon 是什么？

canon CLI: 将你的域名知识和AI规则保存在你的Repo中,并强制执行\.

### 如何安装 @freetesh/canon？

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

### @freetesh/canon 支持 TypeScript 吗？

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

### @freetesh/canon 支持 ESM 还是 CommonJS？

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

### @freetesh/canon 需要什么版本的 Node\.js？

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

### @freetesh/canon 可以商用吗？

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

### @freetesh/canon 的下载量有多少？

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

### @freetesh/canon 还在维护吗？

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

