@agentreins/adapter-js

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

JavaScript/TypeScript language adapter for reins (Vite + React, Next).

原始使用文档
文档目录6 节
  1. Install
  2. Supported projects
  3. What it does
  4. TypeScript
  5. Learn more
  6. License

@agentreins/adapter-js

The JavaScript/TypeScript adapter of reins: it reads the import graph of Vite + React and Next projects so reins check can enforce your architecture.

Install

Install it next to the CLI, in the root of your project (Node.js 22 or newer):

npm install -D @agentreins/cli @agentreins/adapter-js
# pnpm add -D @agentreins/cli @agentreins/adapter-js
# yarn add -D @agentreins/cli @agentreins/adapter-js

npx reins install
npx reins init

You never import this package yourself: the reins command finds it from adapter: js in .reins/architecture.yml.

Supported projects

PresetProjectDetected from
vite-reactVite + React single page appvite.config.*
next-appNext.js, app routernext.config.* and an app/ folder
next-pagesNext.js, pages routernext.config.* and a pages/ folder

Plain JS/JSX or TypeScript, with or without src/, single package or monorepo workspaces. reins init detects the preset; force one with reins init --preset <name>.

What it does

  • Reads imports with dependency-cruiser: static, dynamic (import()) and type-only imports, each tagged so rules can treat them differently (ignore_kinds in architecture.yml).
  • Resolves aliases such as @/ from jsconfig.json/tsconfig.json (paths, baseUrl, following extends and references) and from vite.config resolve.alias. Config files are read as text, never executed.
  • Reads re-export barrels (components/index.js) and reports what each importer really uses through them, so reins init can tell which domain owns a folder and reins impact can count importers behind a barrel as consumers of the real file. The import graph alone would make every importer use everything behind a barrel.
  • Warns about local imports it can't resolve, so a broken alias never turns into a silently green check.
  • Knows framework entry points (Next's page, layout, route..., Vite's main), so they are never reported as orphans.
  • Monorepos: workspace packages resolve, including packages that only declare exports and symlinked workspaces.
  • Scans the whole repo except node_modules, .git, .next, .reins and build output (dist, build, out, coverage, .turbo, .vercel, .cache, storybook-static); layers decide what matters.
  • Presets give reins init a starting plan: layers (app > features > components > shared) and domains from features/* or modules/*, or from route folders when there are none. Route groups ((main)) are looked through; a folder needs more than one source file to become a domain.
  • Optional rule next-server-client: a 'use client' file must not reach, directly or through its imports, a module that imports server-only or next/headers.

TypeScript

TypeScript projects use the typescript package they already have; it is an optional peer dependency. If the project has .ts/.tsx files and typescript is missing, reins check stops with an error instead of skipping those files.

Learn more

License

MIT

版本与发布记录

@agentreins/adapter-js 共发布 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/adapter-js 的常见问题

@agentreins/adapter-js 是什么?

JavaScript/TypeScript language adapter for reins (Vite + React, Next).

如何安装 @agentreins/adapter-js?

在项目目录运行 npm install @agentreins/adapter-js,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:@agentreins/core(^0.8.1)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@agentreins/adapter-js 支持 TypeScript 吗?

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

@agentreins/adapter-js 支持 ESM 还是 CommonJS?

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

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

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

@agentreins/adapter-js 可以商用吗?

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

@agentreins/adapter-js 的下载量有多少?

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

@agentreins/adapter-js 还在维护吗?

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