Skip to content

Package Architecture

LumenFlow is a TypeScript monorepo with clear dependency boundaries between packages. This page explains the package graph, what each package contains, and how packs are built and distributed.

Diagram

The CLI package sits at the top of the dependency graph. The kernel is standalone with minimal external dependencies and contains no persistence adapter. The host package implements kernel ports for local Node.js environments. Domain packs consume kernel contracts and generic host adapters. The Software Delivery Pack owns delivery behavior. Generic layers never import the pack. The remaining dynamic runtime-CLI adapter is a measured migration exception: the dependency gate prevents the exception set from growing while native pack handlers replace it. The same ratchet records two narrow host exceptions for the scheduler transport and phone-device identity helper; the allowed direction remains the target shown by the solid edges.

PackagePathRoleKey Dependencies
@hellmai/lumenflow-clipackages/@lumenflow/cli110+ CLI commands, each exporting main()software-delivery pack, agent, kernel, host
@hellmai/lumenflow-kernelpackages/@lumenflow/kernelKernelRuntime, canonical identifiers, protected-state and event ports, pure projections, ToolHost, scope intersection, and policy enginezod, yaml, micromatch
@hellmai/lumenflow-hostpackages/@lumenflow/hostLocal Node.js adapters, including Linux descriptor-held protected state, transactional SQLite/WAL event log, and JSONL migrationkernel, better-sqlite3
@hellmai/lumenflow-memorypackages/@lumenflow/memoryDeprecated compatibility shell for delivery/workflow memorysoftware-delivery pack
@hellmai/lumenflow-agentpackages/@lumenflow/agentAgent coordination, delegation, spawn management(minimal)
@hellmai/lumenflow-metricspackages/@lumenflow/metricsDeprecated compatibility shell for delivery flow metricssoftware-delivery pack
@hellmai/lumenflow-initiativespackages/@lumenflow/initiativesDeprecated compatibility shell for multi-WU initiative orchestrationsoftware-delivery pack
@hellmai/lumenflow-runtimepackages/@lumenflow/runtimeRuntime surface for programmatic API usagekernel
@hellmai/lumenflow-mcppackages/@lumenflow/mcpMCP (Model Context Protocol) server for AI agent integrationkernel, host
@hellmai/lumenflow-shimspackages/@lumenflow/shimsGit safety shims (pre-commit, pre-push hooks)(none)
@hellmai/lumenflow-control-plane-sdkpackages/@lumenflow/control-plane-sdkControl plane sync contracts and adapters for the LumenFlow runtimezod
@hellmai/lumenflow-conductor-sdkpackages/@lumenflow/conductor-sdkConductor SDK for the Software Delivery Pack — SDLC-specific event kinds and conductor contractscontrol-plane-sdk
@hellmai/lumenflow-surfacespackages/@lumenflow/surfacesKernel surfaces — HTTP, CLI, and MCP integration layers (cloud-facing boundary, ADR-011 §1)control-plane-sdk, host, kernel
software-deliverypackages/@lumenflow/packs/software-deliveryCanonical owner of WU lifecycle, initiatives, delivery metrics, workflow memory, and 90+ software-delivery tool implementationskernel, host, agent-runtime pack
agent-runtimepackages/@lumenflow/packs/agent-runtimeGoverned turn execution, provider adapters, policy/capability factories, and agent-session orchestrationkernel (types only)

WU authoring is owned by @hellmai/lumenflow-packs-software-delivery/runtime/authoring. Direct module subpaths cover parsing, claim/create validation, ID generation, lint/list, rules, normalization, validation, and YAML repair. The pack also exposes an authoring namespace from its runtime barrel. Ownership tests require static pack code to remain free of dependencies on higher-level CLI surfaces. The remaining dynamic runtime adapter is separately ratcheted and cannot expand.

Canonical identifier validation, protected path intents, task/evidence behavior, and event projections in @hellmai/lumenflow-kernel are host-neutral. @hellmai/lumenflow-host binds the protected-state port to descriptor-held Linux filesystem operations and binds the event-log port to SQLite/WAL. The kernel requires that binding and fails closed for unbound custom factories; it never falls back to host filesystem access. Immutable task publication is an explicit port operation so the host can stage, flush, and atomically publish a complete spec without exposing partial content. Workspace and pack discovery adapters continue to move out of the broader runtime under INIT-087.

The pnpm bootstrap command builds the CLI and all its workspace dependencies in the correct order:

turbo build --filter=@hellmai/lumenflow-cli

Turbo’s ^build dependency means “build all workspace dependencies first.” This produces a build order like:

Diagram

The diagram is illustrative; the workspace manifests remain the source of truth. The package-local CLI distribution build, MCP source build, and web production build select their complete transitive prerequisite graph with pnpm’s dependency-only "<package>^..." selector. Repository-level build:dist and pack:dist runs derive their distribution prerequisite graph through Turbo’s ^build:dist dependency edge instead. Both mechanisms follow workspace manifests rather than a second handwritten package list, so a clean checkout cannot accidentally compile against ignored dist/ output from an omitted dependency. The target package builds only after its derived closure succeeds. The web app declares its source-shipped @hellmai/lumenflow-surfaces edge explicitly and hashes the HTTP surface source in its build task until that package gains the standalone dist/ artifact described in its package README.

Both the governed local release command and tag-driven publish workflow delete package output and run the repository build:dist graph before packing. Every publishable dist package exposes that task, and distribution TypeScript configurations disable declaration maps and source maps. A normal developer build may retain maps for debugging; it is not a publish artifact authority.

The local host adapter uses better-sqlite3, so both direct @hellmai/lumenflow-host consumers and packed CLI consumers must allow that package’s native install script. This approval belongs to the consuming project, never to published LumenFlow dependency metadata.

Before pnpm add @hellmai/lumenflow-host or pnpm add -D @hellmai/lumenflow-cli, merge the applicable policy into the consumer root’s existing pnpm-workspace.yaml. Preserve unrelated settings and approvals.

For pnpm 10.26 and newer (including pnpm 11):

allowBuilds:
  better-sqlite3: true

For pnpm 10.0 through 10.25:

onlyBuiltDependencies:
  - better-sqlite3

Use only the policy form supported by the project’s pnpm version. pnpm 9 does not require an explicit dependency-build approval. When migrating to allowBuilds, preserve every existing approval as a true entry before removing onlyBuiltDependencies. If installation already completed with an “ignored build scripts” warning, add the policy and run:

pnpm rebuild better-sqlite3

LumenFlow’s release smoke installs the packed CLI with pnpm, a scratch-local store, strict dependency-build checks, and a consumer-root allowlist. It then loads the native binding and runs the installed task create/inspect path against SQLite. This prevents npm hoisting or a previously built global-store artifact from masking a broken pnpm release.

The Software Delivery Pack is bundled into the CLI package for npm distribution. A sync-bundled-packs.mjs script handles this:

Diagram

The CLI’s package.json files array includes "packs", ensuring the bundled pack ships with the npm package. The prepack hook runs sync automatically before npm publish.

When the kernel starts, it resolves pack locations using resolvePacksRoot() with this priority:

  1. Workspace packs directory{workspaceRoot}/packs/ (for projects with local packs)
  2. Monorepo development path{workspaceRoot}/packages/@lumenflow/packs/ (for LumenFlow development)
  3. CLI-relative fallback{cliPackageRoot}/packs/ (for end-user npm installs)
Diagram