3.1 KiB
CLAUDE.md
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
Commands
bun install # install dependencies
bun run check # Biome lint + format (run before committing)
bun test # run all tests
bun test <path> # run a single test file
bun run bundle # bundle all *-entry.ts files → dist/*.esm.js
uncaged-workflow add <name> <bundle.esm.js> # register a workflow bundle
uncaged-workflow run <name> # run a registered workflow
One-time setup for docx-diff binary
cd /Users/yanjiayi/workspace/docx-diff && npm install && npm run build && npm link
The @uncaged scoped packages resolve from a private registry configured in bunfig.toml (https://git.shazhou.work/api/packages/shazhou/npm/).
Architecture
This is a Bun monorepo (workspaces: ["templates/*", "workflows"]) for developing @uncaged/workflow-runtime workflows.
Two layers:
templates/<name>/— pure data packages:WorkflowDefinition(roles +ModeratorTable), no agent binding. Exported fromsrc/index.ts.workflows/— binds a template'sWorkflowDefinitionto anAdapterFnandExtractFn; each workflow instance is a*-entry.tsfile that the bundle script turns into a singledist/*.esm.js.
Bundle script (scripts/bundle.ts): scans workflows/ for *-entry.ts files, bundles each with Bun into dist/<stem>.esm.js (ESM, Node target, no splitting). All @uncaged/workflow-* packages are kept external. Also emits a .d.ts shim per bundle.
Engine loop: ModeratorTable routes from START → role → … → END. Each step: Adapter produces typed meta via the role's Zod schema; engine appends the step and selects the next role.
Core types (from @uncaged/workflow-runtime):
RoleMeta—Record<string, Record<string, unknown>>: role name → meta shapeRoleDefinition<Meta>—description,systemPrompt,schema(Zod v4)WorkflowDefinition<M>—description+roles+ModeratorTableModeratorTable— declarative, serializable routing table; mapsSTART/role names to ordered transition lists (check+ next role orEND)AdapterFn— receives system prompt + Zod schema, returns aRoleFnExtractFn— resolves structured data from a CAS content hash
Coding Conventions
typenotinterface— use type aliases everywhere.T | nullnot?:— write nullable fields asfield: T | null, notfield?: T.functionnotclass— no classes except third-party requirements orErrorsubclasses.- Named exports only — no default exports. Workflow bundles must export
runanddescriptorby name. - No
console.log— use structured logger in library code. - No dynamic
import()— bundles must be statically analyzable; dynamic imports break hash and loading constraints. - No
import()in business code — the only exception is the engine's own bundle loader.