@agentreins/core

中文文档
0.8.1发布于 2026/11/07MITES Module近 30 天下载 2762

Framework-agnostic core of reins: architecture check, doctor, reports and the adapter contract.

原始使用文档
文档目录5 节
  1. You don't install this package yourself
  2. What is inside
  3. Writing an adapter
  4. Learn more
  5. License

@agentreins/core

The framework-agnostic engine of reins: architecture rules, baseline, architecture.yml loader, reports, impact analysis, doctor rules, module notes and the adapter contract.

You don't install this package yourself

It comes with the CLI. To use reins in a project (Node.js 22 or newer):

npm install -D @agentreins/cli @agentreins/adapter-js
npx reins install
npx reins init

See @agentreins/cli for the quick start.

What is inside

  • Rules: layer-direction (a layer only imports from itself and the layers below), domain-boundary (code outside a domain only imports its public API), no-cycles, and integrity (changes to the plan and a growing baseline are made visible). Messages name the rule, the reason and the fix, and can be overridden per rule in architecture.yml.
  • Baseline: today's violations are frozen so only new ones fail; sorted, no timestamps, clean diffs in pull requests.
  • architecture.yml loader: validates the plan and reports every problem with its field path, all at once. Unknown keys are errors: a typo must not pass silently.
  • Impact analysis (impactOf): the reverse of scope. It joins the adapter's import edges with the domains: who consumes a file (grouped by domain), which imports bypass a public API, which files a breaking change would touch. Powers reins impact.
  • Triage signals (scopeSignals, suggestLevel): turn a list of files into the minimum task level (small / medium / large). The same thresholds power reins scope and the doctor's triage-mismatch, so what the agent announces is what the diff is measured against.
  • Reports: text and JSON (stable schema number), each finding with its rule, reason and fix.
  • Doctor: the workflow rules behind reins doctor (triage vs diff, notebook, module notes, AGENTS.md size) and the progress notebook parser and one-line-at-a-time editor behind reins progress.
  • Module notes: parsing, the path → note lookup (notesFor), drafting from the import graph (draftNote), and stale ranking from git history (rankStaleNotes).
  • Audit backlog: the local findings file behind reins audit — parsing, rendering, status changes.
  • Glob matching: its own matcher (*, **, ?, {a,b}) for layers, domains and public APIs. No glob dependency.

The core never reads source files and knows no framework: it only sees { from, to, kind } import edges, computed by a language adapter. Everything framework- or language-specific (TypeScript, Vite, Next) lives in adapters such as @agentreins/adapter-js.

Writing an adapter

Adapters import only the contract entry point:

import { CONTRACT_VERSION, validateAdapter, validateEdges, normalizeGraph, matchesAny } from '@agentreins/core/contract';

The contract is versioned (reins.contract: 1 in the adapter's package.json; the CLI refuses a mismatched one):

  • detect(repoPath) — does this adapter apply to the repo? Return true, a preset name or nothing.
  • graph(repoPath, config) — the import edges: { from, to, kind } with kinds static, dynamic (import()) and type (type-only), plus the file list, entry points and warnings. An edge kind the rules should skip is the team's call (ignore_kinds per rule), not the adapter's. Never drop edges silently: an unresolved alias must become a warning, or check goes green over a hole.
  • GraphResult may add barrels and uses — what each importer really uses through re-export barrels, so init can tell which folder owns what and impact can count importers behind a barrel as consumers of the real file. Optional: the rules only need edges.
  • evaluate(edges, config, graph) — optional framework rules that need more than edges (file contents, directives; next-server-client is one), merged into the same report and baseline.
  • presets, suggestPreset, loadPreset — optional starting plans for reins init (layers, where domains come from). Without them check works the same; init just asks for a hand-written architecture.yml.

The contract is documented in docs/adapter-contract.md. Name a third-party adapter reins-adapter-<language>; the CLI finds it from adapter: <language> in architecture.yml.

Learn more

License

MIT

版本与发布记录

@agentreins/core 共发布 17 个版本,首次发布于 2026/11/05;过去 12 个月发布了 17 个版本。

版本发布日期距今
0.8.1latest2026/11/07今天
0.8.02026/11/07今天
0.7.42026/11/071 天前
0.7.22026/11/071 天前
0.7.12026/11/061 天前
0.7.02026/11/062 天前

关于 @agentreins/core 的常见问题

@agentreins/core 是什么?

Framework-agnostic core of reins: architecture check, doctor, reports and the adapter contract.

如何安装 @agentreins/core?

在项目目录运行 npm install @agentreins/core,或使用 pnpm add / yarn add / bun add。

@agentreins/core 支持 TypeScript 吗?

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

@agentreins/core 支持 ESM 还是 CommonJS?

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

@agentreins/core 需要什么版本的 Node.js?

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

@agentreins/core 可以商用吗?

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

@agentreins/core 的下载量有多少?

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

@agentreins/core 还在维护吗?

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