@dzhechkov/core

中文文档
0.2.31发布于 2026/11/07MITTypeScriptES Module近 30 天下载 2803

Canonical skill + hooks schemas and the platform-adapter contract for the DZ cross-platform harness.

原始使用文档
文档目录8 节
  1. What it provides
  2. Two-layer skill schema
  3. Managed Markdown
  4. Companion integration intent
  5. Claude Code mods contract
  6. Test-run temp-root guard
  7. Status
  8. Scripts

@dzhechkov/core

Site: https://aicoding.space · Source: https://github.com/djd1m/dz-harness/tree/main/packages/core

Foundation package of the DZ cross-platform harness. It owns the platform-neutral contracts that every other @dzhechkov/* package depends on.

What it provides

ModuleExportsPurpose
skill.schemaCanonicalSkillFrontmatter, ClaudeSkillFrontmatterTwo-layer Zod schema for SKILL.md frontmatter
hooks.schemaHookSchemaShape of lifecycle hooks
adapterAdapter, Platform, EmitResult, …The contract every @dzhechkov/adapter-* implements
integration.schemaHarnessIntegrationManifestV1Schema, integrationManifestDigest, outcome typesBounded INTEGRATIONS.json parsing, canonical digests, and the MCP/hooks result vocabulary consumed by live registration probes
mods-runtime.schemaModRuntimeIntentV1Schema, ModRuntimeObservationV1SchemaSeparate, bounded intent and evidence vocabulary for Claude Code mods; no plugin loading or runtime claims from parsing
agents-mdmergeAgentsMd, mergeGeminiMd, mergePolicyBlock, fence constantsOne parameterized managed-Markdown merge path for skill and always-on policy blocks; authored bytes outside each fence are preserved

Two-layer skill schema

The Agent Skills open standard defines six frontmatter fields (name, description required; license, compatibility, metadata, allowed-tools optional). Claude Code consumes that standard and adds its own optional fields, and this repo's 90 skills additionally carry ~26 project-local keys.

So the schema has two layers:

  • CanonicalSkillFrontmatter — strict agentskills.io standard. Used by the portable/canonical layer and by non-Claude adapters.
  • ClaudeSkillFrontmatter — the canonical schema relaxed, plus Claude Code extensions, plus passthrough of unknown keys, so every existing SKILL.md validates without edits.

See features/extended-a-migration/agentskills-spec-verification.md for the verified spec this schema is built against.

Managed Markdown

Use mergePolicyBlock(existing, sections) when adding the always-on policy fence to a root AGENTS.md. It uses the same merge implementation as the existing mergeAgentsMd and mergeGeminiMd projections, but with its own dz:policies markers and an early placement so a Codex truncation cap reaches policy before optional skill content.

mergePolicyBlock('# AGENTS.md\n\nTeam notes.\n', ['## Integrity Rule\n\nMeasure before asserting.']);

Expected result: the team notes remain byte-for-byte, followed by one <!-- dz:policies BEGIN … --> / <!-- dz:policies END --> block. Repeating the call is idempotent; a dz:skills block, when present, remains independent.

Companion integration intent

INTEGRATIONS.json is strict, versioned, size/depth/count bounded, and rejects literal-looking credentials. It represents intent only: parsing never runs a command or performs network I/O. Harness orchestration binds the canonical digest to operator authorization and requires separate live evidence before an adapter may emit a target carrier.

Claude Code mods contract

ModRuntimeIntentV1Schema describes one plugin module and target host: event handlers, mods API calls, intended render sites, lifecycle invalidation and fallback. It is a harness contract, not Claude Code's plugin.json. ModRuntimeObservationV1Schema keeps installation, API availability, handler completion and visible UI as four independent facts. Offline checks must leave runtime/UI facts unknown; an observed runtime fact needs an exact host build, session, plugin hash, nonce and appropriate evidence. An observed UI display also needs a capture with a visible marker. Parsing does not authenticate evidence or run a probe.

The schema does not prescribe a minimum Claude Code version or certify that a named event, method or render site exists in a particular build. Check the installed build's declarations and the official mods reference before enabling a mod. Settings hooks remain governed by hooks.schema.ts; matching names do not make the two mechanisms equivalent. Guard interactions and a live UI probe are separate follow-up work.

Test-run temp-root guard

Before creating a Vitest run root, dzTmpRunRoot checks the physical path of the system temp directory and every ancestor through the filesystem root. A .dz directory, a real .git repository or gitdir: file, or an unreadable path refuses the run. Empty or broken .git entries warn and allow the run to proceed: dz root finders skip them, and the source census in harness-core/test/root-finder-census.test.ts guards that invariant. Inherited active run roots are checked too. The shared Vitest module also exports findTempRootHazards and assertTempRootClean; both accept an injectable filesystem facade.

A clean check prints one stderr receipt:

dz tmp-root: clean — <n> ancestor(s) of <realpath> checked

A check with only advisory hazards prints one warning per hazard, followed by the clean receipt:

dz tmp-root: WARN — <path> — <kind> — not a repository boundary; no dz root finder adopts a .git without HEAD (census: harness-core test/root-finder-census.test.ts)

A refusal logs one dz tmp-root: REFUSED banner to stderr before throwing, naming the first blocking hazard and total hazard count and explaining that a runner's "No test files found" can mean this refusal. A refusal throws with every hazard, deepest ancestor first:

dz tmp-root: refused — unsafe temp-root ancestor chain
<absolute path> — <kind> — <one-sentence consequence>
remedy: move the entry aside or point TMPDIR at a clean root — this guard never deletes anything

There is no environment variable to disable the check. Move the offending entry aside or use a clean TMPDIR. The guard only reads: it never creates, moves, or deletes files.

The check has a post-run half (feature temp-root-post-run-check). The pre-run refusal names a hazard left by an EARLIER run, so the run that created /tmp/.dz used to finish green and the next run paid. Now dzTmpRunRoot keeps the pre-run scan as a snapshot and, when the LAST user tears the run root down, removes the run root first and then scans the same ancestor chain once more (the system temp root, or the shared run root's parent on the DZ_VITEST_TMP_ROOT branch — the run root itself is gone by then). diffTempRootHazards(before, after) — pure, exported from the shared module too — keeps only the hazards whose (path, kind) pair was absent before the run. Each one is logged to stderr; a new blocking hazard also fails the teardown, which Vitest reports as a globalSetup teardown error:

dz tmp-root: CREATED DURING THIS RUN of <package> — <absolute path> — <kind> — <one-sentence consequence>
remedy: move the entry aside or point TMPDIR at a clean root — this guard never deletes anything

A new advisory hazard (an empty or broken .git) prints one dz tmp-root: WARN — CREATED DURING THIS RUN of <package> — … line and does not fail the teardown. A hazard that was already present at setup is never attributed to the run. The post-run half removes nothing either: it names the run, and the entry stays for you to move aside.

Status

0.2.26 — published 2026-09-24 (supersedes 0.2.25, whose tarball lacked the LICENSE its signed manifest listed — the package now carries its own LICENSE, byte-identical to the repo root; backlog 71f1919d). 0.2.25 — same day: findTempRootHazards / assertTempRootClean (feature temp-root-guard-before-run) refuse a test run whose temp root sits under a .dz store or a .git ancestor, wired into dzTmpRunRoot on both branches; 0.2.24 was the same code (a sibling-drift gate artefact, backlog 71f1919d).

0.2.22 — staged, not published. Adds the bounded integration manifest and the shared emitted / refused / not-requested contract used by evidence-gated target adapters.

Scripts

pnpm --filter @dzhechkov/core build      # tsc -> dist/
pnpm --filter @dzhechkov/core test       # vitest run
pnpm --filter @dzhechkov/core typecheck  # tsc --noEmit

版本与发布记录

@dzhechkov/core 共发布 27 个版本,首次发布于 2026/06/01;过去 12 个月发布了 27 个版本。

版本发布日期距今
0.2.31latest2026/11/076 天前
0.2.302026/09/261 个月前
0.2.292026/09/251 个月前
0.2.282026/09/251 个月前
0.2.272026/09/241 个月前
0.2.262026/09/241 个月前

关于 @dzhechkov/core 的常见问题

@dzhechkov/core 是什么?

Canonical skill + hooks schemas and the platform-adapter contract for the DZ cross-platform harness.

如何安装 @dzhechkov/core?

在项目目录运行 npm install @dzhechkov/core,或使用 pnpm add / yarn add / bun add。

@dzhechkov/core 支持 TypeScript 吗?

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

@dzhechkov/core 支持 ESM 还是 CommonJS?

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

@dzhechkov/core 需要什么版本的 Node.js?

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

@dzhechkov/core 可以商用吗?

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

@dzhechkov/core 的下载量有多少?

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

@dzhechkov/core 还在维护吗?

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