@3f-consulting/spec-controller-core

中文文档
0.1.237发布于 2026/11/05MITTypeScriptES Module近 30 天下载 4万

The pure, embeddable reconciliation core behind spec-controller — Gherkin/@SCN parse, the evidence model, reconcile primitives, and renderers. No CLI, no I/O.

原始使用文档
文档目录5 节
  1. Install
  2. Your first call
  3. What it exports
  4. Stability
  5. Licence

@3f-consulting/spec-controller-core

The reconciliation engine behind spec-controller, as a pure library.

Scenarios and evidence observations go in; a ledger comes out. Nothing in this package reads a file, spawns a process, looks at the clock or writes to a stream. File reading, git-derived provenance, output routing and the command line live in the spec-controller package, which is built on this one.

Use this package to build your own tooling around the reconciliation: a service, an editor integration, a different front end, or a pipeline that already holds the reports in memory. Use spec-controller when you want a command to put in CI.

Requires Node ≥ 22. ESM only.

Install

npm install @3f-consulting/spec-controller-core

Your first call

import {
  parseFeatureCorpus,
  scenariosOf,
  parseVitestEvidenceObservations,
  reconcile,
  isBalanced,
} from "@3f-consulting/spec-controller-core";

// One .feature file's text, and one already-parsed Vitest JSON report.
const corpus = parseFeatureCorpus([{ file: "features/checkout.feature", source: featureSource }]);
if (corpus.kind === "unparseable") throw new Error(corpus.faults[0].message);
const scenarios = corpus.parsed.flatMap((feature) => scenariosOf(feature));
const observed = parseVitestEvidenceObservations(vitestReport);

const ledger = reconcile(scenarios, observed);
isBalanced(ledger); // false while any scenario names evidence that did not arrive
  • parseFeatureCorpus parses each feature file once. It returns every file parsed or, if any file does not parse, each file's fault in the parser's own words. scenariosOf reads the @SCN code and the tags naming its kinds of quality check off each parsed scenario and turns them into the obligations the scenario names.
  • parseVitestEvidenceObservations turns a test report into the observations that posted back, each citing the @SCN it claims.
  • reconcile sets the two sides against each other and gives an answer per scenario.

Everything else the package exports is a variation on these three steps.

What it exports

The package publishes exactly one entrypoint, a barrel that exports the following.

  • Parse:

    • scenarios: parseFeatureCorpus, which parses the feature files once; scenariosOf, untaggedScenariosOf and featureCountsOf over a parsed file; corpusCountsOfFeatures over the parsed files; and countScnOccurrences over a file's text;
    • evidence: parseVitestEvidenceObservations; parseJunitEvidenceObservations and parsePytestEvidenceObservations, both over a JUnit XML report you have already parsed into objects, from pytest, gotestsum or another runner; parseRspecEvidenceObservations, over RSpec's JSON report; and parseCucumberEvidenceObservations;
    • workflows: parseWorkflows, which parses the CI workflows once;
    • the readers for fitness functions, and for what a pipeline's steps actually ran.

    The two JUnit readers differ in how they read an <error> on an ordinary test: parseJunitEvidenceObservations reads it as a failing observation, and parsePytestEvidenceObservations reads it as broken, as pytest's setup error.

  • Reconcile: reconcile for the ledger, evidenceReconciliationOf for the ledger plus its summary, and evidenceReconciliationFromSources for the whole composition over the parsed feature files, the parsed workflows and the other sources you have already read.

  • Ask the ledger: isBalanced, hasPendingItems, hasBrokenEvidence and hasNothingToReconcile, the four questions a caller decides on. The run verdict itself is on the report: assembleRenderInput names it at summary.runVerdict, and the CLI reads its exit code from there.

  • Render: renderMarkdown, renderJson, renderReport, renderReportFromJson, and assembleRenderInput if you want the payload rather than a string. assembleSavedReport turns a saved JSON report back into a report and works its run verdict out afresh. A report saved without a verdict, or re-rendered under --strict, therefore states the verdict a run would.

  • Provenance: the pure subset, which records what a run was without asking the filesystem what it is.

The types these functions take and return are exported alongside them, so a consumer can name any value it holds.

Stability

What the entrypoint exports is the whole public surface, and the contract you build on. Nothing checks it for drift. The surface is not checked against a written list, so adding a symbol to the barrel or dropping one turns no build red. A generated API report will be adopted at 1.0, with a compatibility promise. The package is at a 0.x version and makes no compatibility promise; see docs/compatibility.md. Pin an exact version.

Source, issues and history: github.com/3f-consulting/spec-controller.

Licence

MIT — see LICENSE in this package. © 2026 3F Consulting Ltd.

版本与发布记录

@3f-consulting/spec-controller-core 共发布 326 个版本,首次发布于 2026/09/04;过去 12 个月发布了 326 个版本。

版本发布日期距今
0.1.237latest2026/11/05今天
0.1.2362026/11/051 天前
0.1.2352026/11/051 天前
0.1.2342026/11/051 天前
0.1.2332026/11/051 天前
0.1.2322026/11/051 天前

其他发布通道:alpha → 0.1.0-alpha.88。

关于 @3f-consulting/spec-controller-core 的常见问题

@3f-consulting/spec-controller-core 是什么?

The pure, embeddable reconciliation core behind spec-controller — Gherkin/@SCN parse, the evidence model, reconcile primitives, and renderers. No CLI, no I/O.

如何安装 @3f-consulting/spec-controller-core?

在项目目录运行 npm install @3f-consulting/spec-controller-core,或使用 pnpm add / yarn add / bun add。

@3f-consulting/spec-controller-core 支持 TypeScript 吗?

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

@3f-consulting/spec-controller-core 支持 ESM 还是 CommonJS?

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

@3f-consulting/spec-controller-core 需要什么版本的 Node.js?

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

@3f-consulting/spec-controller-core 可以商用吗?

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

@3f-consulting/spec-controller-core 的下载量有多少?

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

@3f-consulting/spec-controller-core 还在维护吗?

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