flow-core
Shared types, configuration, themes, errors, and events used across all Flow crates.
What it does
flow-core is the foundation crate that every other crate depends on. It defines the common language that all parts of Flow use to communicate. Think of it as the dictionary and grammar rules that everyone agrees on.
It contains:
- Types: Feature, Task, Session - the data structures everything works with
- Configuration: Both workflow config (
~/.config/flow/config.toml) and agent monitoring config - Themes: 7 color themes with ANSI (terminal) and CSS (web) representations
- Errors: A unified error type with 14 variants for everything that can go wrong
- Events: Event types for real-time updates between components
Architecture
flow-core/
├── lib.rs - Module exports and Result type alias
├── config.rs - Workflow config (projects_dir, state_dir, default_branch)
├── agent.rs - AgentConfig (port, theme, concurrency, paths)
├── feature.rs - Feature, FeatureStats, FeatureGraphNode, CreateFeatureInput
├── task.rs - Task, SessionListItem, SessionMeta, TaskWithSession
├── theme.rs - 7 themes with ANSI + CSS color definitions
├── event.rs - FlowEvent enum for SSE/WebSocket broadcasting
├── error.rs - FlowError with 14 variants
├── state.rs - Shared state types
└── project.rs - Project metadata types
Key Types
Feature (SQLite-backed)
Task (JSON file-based)
Theme
Each theme provides both ANSI 256-color codes (for the TUI) and CSS hex values (for the web UI).
FlowError
Usage
use ;
// Load workflow configuration
let config = load?;
println!;
// Create agent monitoring config
let agent_config = new
.with_port
.with_theme
.with_open_browser;
// Use theme colors
let theme = Aurora;
let colors = theme.colors;
println!;
println!;
// Cycle through themes
let next = theme.next; // Business
Configuration
Workflow Config (~/.config/flow/config.toml)
= "~/Projects"
= "~/.local/state/flow"
= "main"
If the file doesn't exist, sensible defaults are used.
Agent Config (programmatic)
let config = new // Defaults
.with_port // Web server port
.with_theme // Color theme
.with_max_concurrency // Max parallel agents
.with_open_browser; // Auto-open browser
Testing
Related Crates
Every crate in the workspace depends on flow-core:
- flow-db - Uses Feature, CreateFeatureInput, FlowError
- flow-resolver - Uses Feature, FlowError
- flow-server - Uses AgentConfig, Task, Theme, FlowEvent
- flow-tui - Uses Theme, ThemeColors
- flow-cli - Uses Config, AgentConfig, Theme