@chernabog/sdk

中文文档
0.11.1发布于 2026/11/09MITES Module零依赖构建来源已验证近 30 天下载 2487

The blocks Chernabog flows are written from (Implement, Review, Plan, Hybrid, PullRequest, prompts), over @chernabog/core, which it re-exports

原始使用文档
文档目录3 节
  1. Flows
  2. Steps
  3. Services

@chernabog/sdk

The blocks Chernabog flows and steps are written from (Implement, Review, Plan, Hybrid, Stack, PullRequest, prompts), over @chernabog/core, which it re-exports, so a flow imports everything from this one package.

A repo lists it in .chernabog/package.json's dependencies, at the version it chooses, and each snapshot of the repo's base branch installs it: two repos on different versions run side by side in one daemon. The chernabog binary supplies its own copies of @chernabog/core and effect at runtime, and runs this package when its peer range on @chernabog/core includes a core the binary provides. chernabog recipes upgrade moves a repo to the version released with its binary.

Flows

import { Claims, defineFlow, Implement, step } from "@chernabog/sdk";
import { Effect, Schema } from "effect";

export default defineFlow({
  trigger: Implement.triggerFor("auto:eligible"), // the work items to act on
  gate: Implement.gate, // checked before each run starts; fail with Skip to hold it back
  concurrency: 1,
  workflow: (item) =>
    Effect.gen(function* () {
      const issue = yield* Implement.issueOf(item);

      // However the run ends, its claim on the issue goes.
      return yield* Effect.gen(function* () {
        const { branch } = yield* Implement.claim(issue);
        const checked = yield* step(
          "check-scope",
          { issue },
          { output: Schema.Struct({ ok: Schema.Boolean }) },
        );
        // ...
      }).pipe(Claims.releasing(Claims.issue(issue)));
    }),
});
HelperWhat it does
activity(name, effect, { success })One durable step. It runs once and its result is saved; a replay returns the saved result. Names are unique within a run, so a step in a loop carries its round: fix-ci-2.
step(name, input, { output })Runs .chernabog/stages/<name> in its own process, as an activity.
sleep(name, duration)A durable pause that survives restarts.
awaitSignal(signals, { id, timeout })Waits for one of the signals (which the trigger reports in WorkItem.signals) or the timeout, whichever comes first, and says which. A trigger can report an item with wakeOnly to wake a waiting run without starting a new one, or with held: "<why>" to start no run and show why in chernabog status.
renderPrompt(name, values)Fills .chernabog/prompts/<name>.md, or, for a flow imported from a recipe package (FlowPackage), the package's when the repo has none.
Skip, NeedsHumanEnd a run cleanly, or hand its item to a person.

Implement, Review and PullRequest hold the building blocks of the review loop, each an activity a flow can reorder, leave out or wrap. Hybrid holds the blocks of the hybrid path, where a person works on an issue with the agent in an interactive session. Plan holds the blocks of the plan recipe, which turns a spec issue into an epic of sub-issues once a person approves the agent's plan. Stack brings a layer of a stack of pull requests up to date with its base by merging, including once the layer below was squash-merged, and adjusts the layer to what moved in the session that wrote it. Chernabog's recipes are complete flows written out from these blocks, which a repo bakes into its own .chernabog/flows/; they are published as @chernabog/recipes, whose source is packages/recipes/.

A flow can also give item: (key) => Effect<Option<WorkItem>>, the work item for a key a person names that the trigger doesn't report, as Hybrid.itemFor finds the issue chernabog start names.

Side effects belong inside activities or steps, never in the workflow body, which runs again on every replay.

Steps

// .chernabog/stages/find-work.ts
import { defineStage, GitHub, Skip } from "@chernabog/sdk";
import { Effect, Schema } from "effect";

export default defineStage({
  name: "find-work",
  input: Schema.Struct({}),
  output: Schema.Struct({ issue: Schema.Number }),
  run: () =>
    Effect.gen(function* () {
      const [issue] = yield* (yield* GitHub).queuedIssuesLabelled("auto:eligible");
      if (issue === undefined) return yield* new Skip({ reason: "nothing queued" });
      return { issue: issue.number };
    }),
});

Services

The services are core's: each is a port the binary provides.

ServiceCovers
RepoThe repo's merged settings: slug, base branch, labels, limits, gates, notes
RunThe run: flow, run id and work item
GitHubQueued issues, claims, labels, comments, sub-issues and blockers, branches, pull requests, CI state
AgentStarting and resuming agent sessions through an adapter; withPerson opens one in front of a person
Git, WorktreeCommits ahead, changed files, pushes; one worktree per branch
UsageThe account check and the usage gate
RunLogThe run's log

Each service is a layer, so a team can replace one with its own implementation, and tests can use fakes.

版本与发布记录

@chernabog/sdk 共发布 14 个版本,首次发布于 2026/10/19;过去 12 个月发布了 14 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
0.11.1latest2026/11/09今天
0.11.02026/11/09今天
0.10.02026/11/045 天前
0.9.02026/11/018 天前
0.8.12026/10/319 天前
0.8.02026/10/3010 天前

关于 @chernabog/sdk 的常见问题

@chernabog/sdk 是什么?

The blocks Chernabog flows are written from (Implement, Review, Plan, Hybrid, PullRequest, prompts), over @chernabog/core, which it re-exports

如何安装 @chernabog/sdk?

在项目目录运行 npm install @chernabog/sdk,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:effect(4.0.5)、@chernabog/core(^1.0.0)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@chernabog/sdk 支持 TypeScript 吗?

该包的 package.json 没有声明类型入口。需要类型提示时,可以在 npm 上查找社区维护的 @types/chernabog__sdk 是否存在。

@chernabog/sdk 支持 ESM 还是 CommonJS?

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

@chernabog/sdk 可以商用吗?

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

@chernabog/sdk 的下载量有多少?

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

@chernabog/sdk 还在维护吗?

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