You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: packages/agentflow/ARCHITECTURE.md
+15-3Lines changed: 15 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -42,7 +42,7 @@ atoms/
42
42
- No API calls
43
43
- Stateless or minimal local state
44
44
- Imported by features, never the reverse
45
-
-**Forbidden**: Importing from `features/` or `infrastructure/` (except types from `core/types` for prop definitions, design tokens from `core/theme`, and utilities from `core/utils`)
45
+
-**Forbidden**: Importing from `features/` or `infrastructure/` (except types from `core/types` for prop definitions, design tokens from `core/theme`, and primitives from `core/primitives`)
46
46
47
47
**Goal:** 100% visual consistency.
48
48
@@ -110,6 +110,9 @@ features/
110
110
core/
111
111
├── types/ # Global interfaces (Node, Edge, Flow)
112
112
│ └── index.ts
113
+
├── primitives/ # Domain-free utilities (safe for atoms)
├── utils/ # Domain-aware utilities (NOT importable by atoms)
128
131
│ ├── nodeFactory.ts # initNode, getUniqueNodeId
129
132
│ └── ...
130
133
└── index.ts # Barrel export (use sparingly)
@@ -138,6 +141,15 @@ core/
138
141
- Pure functions where possible
139
142
- Can be tested in isolation
140
143
144
+
#### `core/primitives/` vs `core/utils/`
145
+
146
+
`core/` contains two utility directories with different import permissions:
147
+
148
+
-**`primitives/`** — Domain-free, general-purpose functions with no knowledge of nodes, flows, or any business concept. These are pure data transformations (e.g., computing a default value from a type string). **Safe to import from `atoms/`.**
149
+
-**`utils/`** — Domain-aware utilities that understand node structures, flow data, or validation logic (e.g., `initNode`, `buildDynamicOutputAnchors`). **Only importable by `features/` and `infrastructure/`.**
150
+
151
+
When adding a new utility, ask: _"Does this function need to know what a Node or Flow is?"_ If no → `primitives/`. If yes → `utils/`.
152
+
141
153
**Goal:** To be the framework-agnostic source of truth.
142
154
143
155
---
@@ -210,7 +222,7 @@ infrastructure/
210
222
211
223
-`features` → `atoms`, `infrastructure`, `core` ✅
212
224
-`infrastructure` → `core` ✅
213
-
-`atoms` → `core/types` and `core/theme` only (for type definitions and design tokens) ✅
225
+
-`atoms` → `core/types`, `core/theme`, and `core/primitives` only ✅
214
226
-`core` → nothing (leaf node) ✅
215
227
-**Atoms and Core are "leaf" nodes** - they cannot import from `features/` or `infrastructure/`
0 commit comments