This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
FlowGram is a composable, visual workflow development framework built as a Rush-managed monorepo. It provides tools for building AI workflow platforms, including a flow canvas, node configuration forms, variable scope chains, and pre-built materials (LLM, Condition, Code Editor, etc.).
This monorepo uses Rush 5.150.0 with pnpm 10.6.5 as the package manager. Node.js version must be >=18.20.3 <19.0.0 || >=20.14.0 <23.0.0.
# Install dependencies (required first step)
rush install
# Build all packages
rush build
# Build specific package and its dependencies
rush build --to @flowgram.ai/core
# Lint all packages
rush lint
# Fix lint issues
rush lint:fix
# TypeScript type checking
rush ts-check
# Run unit tests
rush test
# Run tests with coverage
rush test:cov
# Build packages in watch mode (for development)
rush build:watch
# E2E tests with Playwright
rush e2e:test
# Update E2E screenshots
rush e2e:update-screenshot
# Run docs site with hot reload
rush dev:docs
# Run specific demo apps with hot reload
rush dev:demo-free-layout
rush dev:demo-fixed-layout
rush dev:demo-fixed-layout-simple
rush dev:demo-free-layout-simple
rush dev:demo-nextjs
rush dev:demo-nextjs-antd
These commands use concurrently to run rush build:watch for dependencies alongside the demo's dev server.
To work on a single package in isolation:
cd packages/canvas-engine/core
rushx build # Runs the build script for this package only
rushx test # Runs tests for this package only
rushx ts-check # Type checks this package only
packages/ - Production libraries organized by functional area:
canvas-engine/ - Canvas rendering and layout systems (core, document, renderer, fixed-layout-core, free-layout-core)node-engine/ - Node data and form management (node, form, form-core)variable-engine/ - Variable scoping and type inference (variable-core, variable-layout, json-schema)runtime/ - Workflow execution engines (interface, js-core, nodejs)plugins/ - Extensibility modules (23+ plugins for features like history, drag, snap, minimap, etc.)client/ - High-level React components (editor, fixed-layout-editor, free-layout-editor, playground-react)materials/ - Pre-built node materials (form-materials, form-antd-materials, fixed-semi-materials, coze-editor, type-editor)common/ - Shared utilities (utils, reactive, command, history, history-storage, i18n)apps/ - Demos and documentation:
docs/ - Main documentation sitedemo-*/ - Example applications (free-layout, fixed-layout, nextjs, vite, playground, etc.)create-app/, cli/ - CLI tools for scaffoldinge2e/ - End-to-end test suites (fixed-layout, free-layout)
config/ - Shared configuration (eslint-config, ts-config)
common/ - Rush tooling and scripts
FlowGram is architected in distinct layers:
Canvas Engine Layer (@flowgram.ai/core, @flowgram.ai/document, @flowgram.ai/renderer)
Node Engine Layer (@flowgram.ai/node, @flowgram.ai/form, @flowgram.ai/form-core)
FormModelV2 (exported as FormModel from @flowgram.ai/editor)Variable Engine Layer (@flowgram.ai/variable-core, @flowgram.ai/json-schema)
Runtime Layer (@flowgram.ai/runtime-js, @flowgram.ai/runtime-nodejs, @flowgram.ai/runtime-interface)
Client/Editor Layer (@flowgram.ai/editor, @flowgram.ai/fixed-layout-editor, @flowgram.ai/free-layout-editor)
@flowgram.ai/editor is the main barrel export for fixed-layout workflowsPlugin Ecosystem
free-*-plugin for free-layout, fixed-*-plugin for fixed-layout, or generic pluginsThe codebase heavily uses inversify for dependency injection. Services are decorated with @injectable() and injected via @inject(). Container modules organize related services.
Uses a custom reactive system (@flowgram.ai/reactive) with React hooks:
ReactiveState and ReactiveBaseState for observable stateuseReactiveState, useReadonlyReactiveState, useObserve hooksTracker for dependency tracking@flowgram.ai/command provides a command/command registry system for undo/redo operations. Re-exported by @flowgram.ai/core.
Plugins extend functionality via:
Plugin interface from @flowgram.ai/coreonInit, onDestroy, etc.)__tests__/ folders or *.test.ts filese2e/*/tests/ directoriesrush testrush e2e:test --to @flowgram.ai/e2e-free-layoutrush e2e:update-screenshotconfig/eslint-config enforces 2-space indentation, semicolons, and import orderconfig/ts-configrush lint:fix before committingrush ts-check to validate TypeScript across all packagesflow-node-form.tsx)rush lint-staged - Runs linting on staged filesrush commitlint - Validates commit message format (conventional commits)rush check-circular-dependency - Detects circular dependenciesrush dep-check - Validates dependency consistencyFollow conventional commits format: type(scope): subject
Examples from recent history:
fix(auto-layout): rankdir top to bottomfeat(landing): hover logo node glowingdocs(variable): optimize variable docs by codexKeep commit subjects imperative, ≤72 characters. Reference GitHub issues in PR descriptions.
packages/<category>/<package-name>)rush.json "projects" array with:
packageName: @flowgram.ai/<package-name>projectFolder: relative pathversionPolicyName: typically "publishPolicy" for libraries, "appPolicy" for appstags: for categorizationrush update to link the packagePackages with versionPolicyName: "publishPolicy" are publishable to npm. Apps use "appPolicy".
Use workspace:^x.x.x protocol in package.json for internal dependencies. Rush will link them locally during development.
rush install was run after pulling changesnodeSupportedVersionRange in rush.jsoncommon/temp and rebuildThe main editor packages (@flowgram.ai/editor, @flowgram.ai/fixed-layout-editor, @flowgram.ai/free-layout-editor) re-export many types. Look for type definitions in their upstream dependencies (@flowgram.ai/form, @flowgram.ai/core, @flowgram.ai/node).
Plugins must be registered in a dependency injection container. Check demo apps for examples of container module setup.
Ensure Rush is installed globally: npm install -g @microsoft/rush
Or use the install-run script: node common/scripts/install-run-rush.js <command>