@aaac/toolchain

中文文档
0.3.0发布于 2026/10/20MITTypeScriptES Module近 30 天下载 6439

Toolchain contract definitions for artifact-bound tool declarations

原始使用文档
文档目录13 节
  1. Install
  2. What it does
  3. Quick Start
  4. DSL Schema
  5. Kind types
  6. $refs
  7. CLI Commands
  8. aaac-toolchain validate
  9. aaac-toolchain lint
  10. Exit codes
  11. Library API
  12. Related packages
  13. License

@aaac/toolchain

Artifact-bound toolchain declarations — defines which tools operate on which artifacts.

Install

npm install @aaac/toolchain

What it does

toolchain-contracts is a declarative contract layer that binds tools → artifacts. Each toolchain entry declares what it consumes and produces, enabling static validation and dataflow lint across artifact-contracts, agent-contracts, and toolchain-contracts.

Quick Start

Create toolchain-contracts.yaml:

schema: aaac/toolchain/0.1

system:
  id: my-project

toolchains:
  prettier:
    kind: library
    module: prettier
    artifacts:
      consumes: [source-code]
      produces: [source-code]
    operations: [format]

  eslint:
    kind: cli
    command: npx eslint --fix
    artifacts:
      consumes: [source-code]
      produces: [source-code]

  speckeeper:
    kind: component
    component_contract: ./speckeeper.component.yaml
    artifacts:
      consumes: [spec-md, codebase]
      produces: [conformance-report]

Validate it:

npx aaac-toolchain validate toolchain-contracts.yaml

DSL Schema

FieldDescription
schemaSchema version (e.g. aaac/toolchain/0.1)
systemProject identity (id, optional name)
toolchainsMap of toolchain ID → toolchain definition

Each toolchain entry:

FieldDescription
kindBinding type: library, cli, or component
modulenpm package name (required for library)
commandShell command (for cli when no cli_contract)
cli_contractPath to cli-contracts YAML (alternative for cli)
component_contractPath to the component contract this toolchain embodies (required for component)
artifactsconsumes and produces artifact IDs
operationsOperation names, in the namespace component_contract names — that component's operations when it is set, the tool's own verbs (format, lint) when it is not

Kind types

KindMeaningRequired field
librarynpm package invoked programmaticallymodule
cliExternal CLI toolcommand or cli_contract
componentAaaC component with its own contractcomponent_contract

$refs

Split toolchain definitions across files using $refs:

schema: aaac/toolchain/0.1

system:
  id: my-project

toolchains:
  inline-tool:
    kind: library
    module: inline-lib
    artifacts:
      consumes: [source-code]

$refs:
  - ./formatting.yaml
  - ./linting.yaml

Referenced files contain additional toolchains entries that are merged into the root document. Duplicate toolchain IDs across files are rejected.

CLI Commands

aaac-toolchain validate

Validate schema and semantic rules for a toolchain-contracts file.

npx aaac-toolchain validate toolchain-contracts.yaml

# Optional: check artifact IDs against a known set
npx aaac-toolchain validate toolchain-contracts.yaml \
  --artifact-ids source-code spec-md codebase conformance-report

aaac-toolchain lint

Check dataflow integrity across contract layers.

npx aaac-toolchain lint toolchain-contracts.yaml \
  --artifact-contracts artifact-contracts.yaml \
  --agent-contracts agent-contracts.yaml

Exit codes

CodeMeaning
0All checks pass
1Validation or lint issues found
2File read or schema error

Library API

import {
  loadToolchainContracts,
  parseToolchainFile,
  validateToolchainContracts,
  lintDataflow,
} from "@aaac/toolchain";

// Load and parse (resolves $refs)
const doc = await loadToolchainContracts("./toolchain-contracts.yaml");

// Validate
const issues = validateToolchainContracts(doc, {
  artifactIds: ["source-code", "spec-md"],
});

// Lint dataflow against other contract layers
const lintIssues = lintDataflow(doc, {
  artifacts: [{ id: "source-code", derived_from: [] }],
  agents: [{ id: "reviewer", consumes: ["source-code"], produces: ["review-report"] }],
});
FunctionDescription
loadToolchainContractsLoad YAML file, resolve $refs, validate schema
parseToolchainFileParse file without $ref resolution
validateToolchainContractsSemantic validation (artifact IDs, duplicates)
lintDataflowCross-contract dataflow integrity checks

License

MIT — see LICENSE.

版本与发布记录

@aaac/toolchain 共发布 15 个版本,首次发布于 2026/06/08;过去 12 个月发布了 15 个版本。

版本发布日期距今
0.3.0latest2026/10/2018 天前
0.2.102026/10/2018 天前
0.2.92026/10/1127 天前
0.2.82026/10/1127 天前
0.2.72026/10/0929 天前
0.2.62026/10/061 个月前

关于 @aaac/toolchain 的常见问题

@aaac/toolchain 是什么?

Toolchain contract definitions for artifact-bound tool declarations

如何安装 @aaac/toolchain?

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

@aaac/toolchain 支持 TypeScript 吗?

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

@aaac/toolchain 支持 ESM 还是 CommonJS?

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

@aaac/toolchain 需要什么版本的 Node.js?

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

@aaac/toolchain 可以商用吗?

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

@aaac/toolchain 的下载量有多少?

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

@aaac/toolchain 还在维护吗?

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