@agenticprimitives/devkit

中文文档
0.0.0-alpha.34发布于 2026/10/26MITTypeScriptES Module近 30 天下载 5477

The Developer Kit core (spec 398 §10 / spec 399 §3): ap doctor runs the doctrine gates as data + pure rules over any tree, ap doctor --rules projects one pinned rules source into AGENTS.md / CLAUDE.md / .cursor/rules by digest, ap upgrade rewrites e

原始使用文档
文档目录8 节
  1. Doctor rules
  2. Rules projection
  3. agentic.lock.json
  4. Pinned definitions — ap upgrade stops for review (398 §10.3)
  5. The Developer MCP ( ap mcp )
  6. ap generate client|cli|parity — the fourth and fifth surfac…
  7. ap eval — cases as data against a live Home (398 §10 / P1.3)
  8. What it will not do

@agenticprimitives/devkit

Part of Agentic Primitives — the open-source trust substrate for agentic applications: identity that can sign, authority checked at act time, evidence the owner carries. Developer kit · All packages

The Developer Kit core — ap, the CLI that is the packages' own front door (spec 398 §10, spec 399 §3, ADR-0063).

npx ap doctor                          # every rule, this tree, the config it found
npx ap doctor --rule no-private-keys   # one rule; --json for a coding agent
npx ap doctor --rules --write          # project the rules source; pin digests in agentic.lock.json
npx ap upgrade --canary                # newest canary of every @agenticprimitives/* pin, one exact set
npx ap upgrade --pin 1.0.0-alpha.24    # or one named version / dist-tag
npx ap conform a2a https://…           # A2A 1.0 conformance (dispatches to @agenticprimitives/a2a)
npx ap test --live-gates live-gates.json
npx ap create my-product --template product-repo --pin 1.0.0-alpha.24

Doctor rules

Each rule is one file under src/rules/, data plus one pure judgement, parameterised by a config section. The ids are the ones spec 399 §2.3 gives to the root checks they replace:

RuleTwin (root check)Enforces
web-no-direct-mcpcheck:no-direct-mcp-in-webADR-0044 — browser code reaches MCP only via /a2a/*
no-private-keyscheck:no-app-private-keysno raw key material in app source; allow-list with reasons
no-hmac-home-bridgecheck:no-hmac-home-bridgespec 341 ratchet — the bridge count only falls
no-cross-subject-vault-readscheck:no-cross-subject-vault-readsspec 366 R3 — reads only at the own subject
fail-open-knobscheck:fail-open-knobsADR-0045 — every permissive knob allow-listed by name
internal-marker-splitcheck:internal-marker-splitspec 341 §7 — marker ≠ custody secret
custodian-coveragecheck:custodian-coveragespecs 294/295 — provider-neutral custodian
archetype-catalogcheck:archetype-catalogspec 354 §3 — catalog validates at recorded digests
capability-vocabularycheck:capability-vocabularyADR-0051 — capability / protocol features / playbook
demo-person-org-distinctcheck:demo-person-org-distinctADR-0046 — person SA ≠ org SA
rules-drift—399 §3.4 — projections match the pinned source by digest
lock-coherent—399 §3.1 — exact, coherent @agenticprimitives/* pins

Config resolution is one mechanism: ap.config.json#doctor, else agentic.lock.json#doctor, else the built-in reference layout of the agenticprimitives monorepo. A product repo gets its own section from create-app.

Exit codes: 0 clean · 1 findings · 2 usage or config · 3 a rule or dispatch errored. Error codes are stable strings (E_CONFIG, E_RULE_UNKNOWN, E_MODULE_ABSENT, …) so an agent branches on the code.

Rules projection

ap doctor --rules projects one rules source into .cursor/rules/*.mdc (frontmatter from rules/sidecar.json, body byte-for-byte) and into the <!-- ap:rules -->…<!-- /ap:rules --> block of AGENTS.md and CLAUDE.md. A file without the block is left alone. Digests are pinned in agentic.lock.json#rules; rules-drift fails when a projection or a pin no longer matches the source. In this monorepo the source is docs/architecture/agent-rules; a consumer uses the copy bundled in the package.

agentic.lock.json

{ "lockVersion": 1, "packages": { "@agenticprimitives/a2a": "1.0.0-alpha.24" }, "rules": { "skill-terminology": "sha256:…" }, "devkit": "…", "template": { "name": "product-repo", "revision": "…" }, "doctor": { … } }

packages is the coherent set ap upgrade maintains; rules the source digests; doctor the product's rule config (each section replaces the reference section whole).

Pinned definitions — ap upgrade stops for review (398 §10.3)

ap upgrade --pin-definitions <registry> agentic-trust/org-steward,agentic-trust/person-steward records, in agentic.lock.json#definitions, each archetype definition's digest and the authority shape of every tool (risk, action, requirement type, resource and authority args, approval policy, effects, idempotency). Every later ap upgrade reads the registry first: a wording change is a version bump; a change to any of those fields stops the upgrade with the change named per tool (treasury.payment.execute: authorityArg payer → org), and --accept-definitions re-pins once a reviewer has read it. The pin is a reviewer's memory, never a verifier's input.

The Developer MCP (ap mcp)

A coding agent's host spawns ap mcp (stdio JSON-RPC) and gets a read-only server: packages_list, package_exports (the names each entry's .d.ts declares), ontology_term (T-box IRI, label, comment — what a term means and what it is not), contract_deployments (addresses per chain), recipes (the agent rules and each package's spec), doctor (the same report, redacted). Everything is answered from the packages installed beside it. It is the third MCP — not the runtime's private MCP behind admission (ADR-0057), not the Home MCP (spec 397) — and its ap://developer-mcp/doctrine resource says so first: no signing key, no vault, no authority, no production effect (spec 398 §10.4, T23). Claude Code: claude mcp add ap-dev -- npx ap mcp --root .

ap generate client|cli|parity — the fourth and fifth surfaces of one contract (398 §7.2)

ap generate client --registry https://<skills-registry> --definition agentic-trust/person-steward --only web.search,person.memory.remember --out src/lib/agent-client.ts
ap generate cli    --registry … --definition agentic-trust/org-steward --only treasury.payment.execute
ap generate parity --registry … --definition agentic-trust/org-steward --json

Projected FROM the compiled definition (the registry's, or --file <definition.json>) by @agenticprimitives/harness's pure generateCapabilityClient / cliArgumentSchema / generateParityCases — the kit dispatches to the consumer's install (absent ⇒ E_MODULE_ABSENT). The client's every operation posts an intent to the app's /harness/run boundary through an injected port and carries no authority; the parity cases are the positive pair (screen intent vs Ask sentence → the same normalized plan digest) and the negative pair (a forged surface, a changed party after approval). Regenerate after ap upgrade moves a pinned definition.

ap eval — cases as data against a live Home (398 §10 / P1.3)

ap eval evals/faithnet.eval.json --home https://www.faithnet.me --persona alice --report live-gates-reports/eval-faithnet-latest.json
ap eval --from-runs --home https://www.faithnet.me --persona alice --out evals/from-runs.eval.json

A case is { id, incident, persona | (the --session bearer), addressee?, message, plan?, truth?, checks[] }; a check is one of the deterministic judges by name (answered, replyKindIs, neverClaims, claimsRequire, falseEmptiness, emptinessCarriesReason, evidenceFromTool, evidenceCountAgrees, noPlaceholderLeaks, textIncludes, textExcludes, evidenceNoneFrom). An act's correct outcome in a case is authority_required — the twin, as a test; an eval never signs. An unrunnable case is a FAILING case. --from-runs turns an agent's live run records into case skeletons to edit. Exit 1 on any failing case.

What it will not do

Hold a key, read a vault, mint authority, invoke a production effect. A doctor finding is a review checkpoint; no verifier reads it (spec 361 §1).

版本与发布记录

@agenticprimitives/devkit 共发布 34 个版本,首次发布于 2026/09/12;过去 12 个月发布了 34 个版本。

版本发布日期距今
0.0.0-alpha.34latest2026/10/2610 天前
0.0.0-alpha.332026/10/2610 天前
0.0.0-alpha.322026/10/1720 天前
0.0.0-alpha.312026/10/1720 天前
0.0.0-alpha.302026/10/1720 天前
0.0.0-alpha.292026/10/1620 天前

关于 @agenticprimitives/devkit 的常见问题

@agenticprimitives/devkit 是什么?

The Developer Kit core (spec 398 §10 / spec 399 §3): ap doctor runs the doctrine gates as data + pure rules over any tree, ap doctor --rules projects one pinned rules source into AGENTS.md / CLAUDE.md / .cursor/rules by digest, ap upgrade rewrites e

如何安装 @agenticprimitives/devkit?

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

@agenticprimitives/devkit 支持 TypeScript 吗?

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

@agenticprimitives/devkit 支持 ESM 还是 CommonJS?

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

@agenticprimitives/devkit 可以商用吗?

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

@agenticprimitives/devkit 的下载量有多少?

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

@agenticprimitives/devkit 还在维护吗?

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