@app-studio/qa-doctor

中文文档
0.11.6发布于 2026/11/06UNLICENSEDTypeScriptES Module近 30 天下载 1879

Proves a repository's qa.bindings.json describes the repository it is in — as a CLI report and as a vitest suite CI cannot skip.

原始使用文档
文档目录6 节
  1. Why this exists
  2. Two ways to run it, one implementation
  3. What it checks
  4. The report
  5. Writing your own rules
  6. Requirements

@app-studio/qa-doctor

Proves that a repository's qa.bindings.json describes the repository it is actually in.

Why this exists

A mature QA setup was copied from one repository into another without its bindings being rewritten. In the new repository the guard hook's patterns matched no file, so it denied nothing while looking exactly like a guard with nothing to complain about. The documented ports were wrong, so every instruction built on them sent people to a door that was not there. The seeded accounts did not exist, so agents signing in with them reported an authentication bug. And the documentation that was accurate was referenced by no entrypoint, so nobody read it.

None of that failed loudly. All of it was greppable. This package is that observation turned into a check.

Two ways to run it, one implementation

On demand:

pnpm exec qa doctor            # human report
pnpm exec qa doctor --json     # for agents and CI
pnpm exec qa doctor --strict   # warnings become errors

Inside the repository's own suite, which is what makes it un-skippable:

// tests/qa-doctor.test.ts
import { doctorSuite } from '@app-studio/qa-doctor/vitest';

doctorSuite();

One it() per rule. qa doctor catches a wrong binding when somebody runs it; this catches it on every CI run, in the suite that already gates merges — so skipping the check means skipping the suite, which is a decision somebody has to make out loud. A self/* rule verifies this file exists and falls inside the globs the test command selects, because a test nothing runs is worse than no test: the repository looks checked.

What it checks

GroupProves
bindings/repo-name-matchesrepo.name equals package.json's name — the copied-file detector, run before anything else can be misled.
commands/scripts-resolveEvery declared command names a real script or an installed binary, and the files it reads exist.
commands/layers-reference-commandsLayers point at commands the registry defines, and layer keys are unique.
commands/gates-reference-commandsThe gate matrix asks for evidence this repository can produce.
commands/one-package-managerNothing tells anyone to run npm in a pnpm repository.
commands/smoke (CLI only)The cheap commands — typecheck, lint, format check — actually run.
paths/existEvery declared path is there, unless listed under deliberatelyAbsent.
paths/guard-globs-liveEvery non-empty guard pattern matches at least one real file. The inert-guard detector.
paths/generated-existThe trees declared generated are really there.
ports/bound-by-agreesEach port is the number the file that binds it actually uses, and no two surfaces claim one port.
env/required-declaredRequired variables are written down where a newcomer will find them.
env/secrets-not-committedNo committed file carries a real value for a variable marked secret.
seed/accounts-in-sourceEvery promised account appears in the seed sources.
hooks/registeredEach enabled hook is wired under the right event, with a matcher that covers what it must.
hooks/wrappers-resolveThe wrappers exist, are executable, and point at logic that is installed.
hooks/deny-protects-generatedGenerated trees cannot be hand-edited.
self/doctor-test-wired, self/hooks-test-wiredThe checking runs inside this repository's suite.
docs/entrypoints-point-at-qaThe files an agent reads on arriving say how QA works here.

Rule ids are stable: the CLI groups by them, tests assert on them, and hosts grep for them.

The report

Each finding carries three things, not one:

✖ ports/bound-by-agrees — each declared port is the number the file that binds it actually uses
   ports.front says 5173, but playwright.config.ts never mentions that number.
   in: playwright.config.ts
   what this means: Every instruction built on this port sends people to a door
     that is not there, and the resulting connection refused reads as a broken
     application rather than a wrong binding.
   fix: Open playwright.config.ts, read the port it binds, and put that number
     in ports.front.

A doctor that prints rule names and exit codes gets ignored within a week, and an ignored doctor is indistinguishable from no doctor at all.

Writing your own rules

import { runRules, createDoctorContext } from '@app-studio/qa-doctor';
import type { Rule } from '@app-studio/qa-core';

const noOrphanedFeatures: Rule = {
  id: 'features/registered',
  describes: 'every feature directory is in the composed registry',
  appliesTo: (context) => context.exists('src/features'),
  check(context) {
    const declared = context.read('src/generated/registry.ts') ?? '';
    return context
      .glob('src/features/*/manifest.json')
      .filter((path) => !declared.includes(path.split('/')[2]!))
      .map((path) => ({
        level: 'error' as const,
        rule: 'features/registered',
        message: `${path} is not in the composed registry.`,
        means: 'The feature exists on disk and is not part of the application, which is invisible until someone looks for it.',
        fix: 'Run the composer, or delete the directory.',
      }));
  },
};

Rules are pure functions of a DoctorContext, so they test against fixture repositories rather than against your real one — which matters more than usual here, because a doctor nobody has watched go red is exactly the inert machinery this package exists to prevent.

Requirements

Node.js 20 or newer. vitest is an optional peer, needed only for the /vitest entry point.

版本与发布记录

@app-studio/qa-doctor 共发布 33 个版本,首次发布于 2026/08/09;过去 12 个月发布了 33 个版本。

版本发布日期距今
0.11.6latest2026/11/062 天前
0.11.32026/11/017 天前
0.11.22026/10/2217 天前
0.11.12026/10/1622 天前
0.10.42026/10/081 个月前
0.10.3next2026/10/081 个月前

关于 @app-studio/qa-doctor 的常见问题

@app-studio/qa-doctor 是什么?

Proves a repository's qa.bindings.json describes the repository it is in — as a CLI report and as a vitest suite CI cannot skip.

如何安装 @app-studio/qa-doctor?

在项目目录运行 npm install @app-studio/qa-doctor,或使用 pnpm add / yarn add / bun add。

@app-studio/qa-doctor 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@app-studio/qa-doctor 支持 ESM 还是 CommonJS?

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

@app-studio/qa-doctor 需要什么版本的 Node.js?

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

@app-studio/qa-doctor 可以商用吗?

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

@app-studio/qa-doctor 的下载量有多少?

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

@app-studio/qa-doctor 还在维护吗?

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