Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 11 additions & 10 deletions .agents/skills/fbp/references/fbp-evaluator.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ import type { NodeDefinitionWithImpl } from '@fbp/evaluator';
// Define node implementations
const addDef: NodeDefinitionWithImpl = {
context: 'js',
name: 'add',
category: 'math',
type: 'js/math/add',
inputs: [
{ name: 'a', type: 'number' },
{ name: 'b', type: 'number' }
Expand All @@ -39,8 +39,8 @@ const addDef: NodeDefinitionWithImpl = {

const constNumberDef: NodeDefinitionWithImpl = {
context: 'js',
name: 'number',
category: 'const',
type: 'js/const/number',
props: [{ name: 'value', type: 'number' }],
outputs: [{ name: 'value', type: 'number' }],
impl: (inputs, props) => ({
Expand All @@ -52,9 +52,9 @@ const constNumberDef: NodeDefinitionWithImpl = {
const graph: Graph = {
name: 'simple-add',
nodes: [
{ name: 'num1', type: 'js/const/number', props: [{ name: 'value', value: 5 }] },
{ name: 'num2', type: 'js/const/number', props: [{ name: 'value', value: 3 }] },
{ name: 'add', type: 'js/math/add' }
{ name: 'num1', type: 'const:number', props: [{ name: 'value', value: 5 }] },
{ name: 'num2', type: 'const:number', props: [{ name: 'value', value: 3 }] },
{ name: 'add', type: 'math:add' }
],
edges: [
{ src: { node: 'num1', port: 'value' }, dst: { node: 'add', port: 'a' } },
Expand Down Expand Up @@ -117,7 +117,8 @@ Supports ports that accept multiple incoming edges. Values are collected in edge

```typescript
const mergeDef: NodeDefinitionWithImpl = {
type: 'js/array/merge',
name: 'merge',
category: 'array',
inputs: [{ name: 'items', type: 'any', multi: true }],
outputs: [{ name: 'array', type: 'any[]' }],
impl: (inputs) => ({
Expand Down Expand Up @@ -147,8 +148,8 @@ const result = evaluate(graph, {
const mathNodes: NodeDefinitionWithImpl[] = [
{
context: 'js',
name: 'add',
category: 'math',
type: 'js/math/add',
inputs: [
{ name: 'a', type: 'number' },
{ name: 'b', type: 'number' }
Expand All @@ -158,8 +159,8 @@ const mathNodes: NodeDefinitionWithImpl[] = [
},
{
context: 'js',
name: 'multiply',
category: 'math',
type: 'js/math/multiply',
inputs: [
{ name: 'a', type: 'number' },
{ name: 'b', type: 'number' }
Expand All @@ -169,8 +170,8 @@ const mathNodes: NodeDefinitionWithImpl[] = [
},
{
context: 'js',
name: 'negate',
category: 'math',
type: 'js/math/negate',
inputs: [{ name: 'value', type: 'number' }],
outputs: [{ name: 'negated', type: 'number' }],
impl: (inputs) => ({ negated: -(inputs.value ?? 0) })
Expand All @@ -180,7 +181,7 @@ const mathNodes: NodeDefinitionWithImpl[] = [

## Best Practices

1. Use descriptive type paths like `context/category/name` (e.g., `js/math/add`)
1. Use short names on definitions (e.g., `name: 'add'`); the task_identifier `category:name` is used in `Node.type` (e.g., `type: 'math:add'`)
2. Always provide default values in `impl` functions for missing inputs
3. Keep node implementations pure — no side effects
4. Use `multi: true` for ports that should accept multiple connections
16 changes: 8 additions & 8 deletions .agents/skills/fbp/references/fbp-graph-editor.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ const graph: Graph = {
definitions: [
{
context: 'js',
name: 'add',
category: 'math',
type: 'js/math/add',
inputs: [
{ name: 'a', type: 'number' },
{ name: 'b', type: 'number' }
Expand All @@ -38,7 +38,7 @@ const graph: Graph = {
}
],
nodes: [
{ name: 'add1', type: 'js/math/add', meta: { x: 100, y: 100 } }
{ name: 'add1', type: 'math:add', meta: { x: 100, y: 100 } }
],
edges: []
};
Expand All @@ -60,7 +60,7 @@ The editor uses SVG for rendering, providing crisp visuals at any zoom level. Pa

### Node Rendering

Nodes display their fully-qualified type paths (e.g., `js/math/add`) and show input/output ports based on their definition.
Nodes display their type (e.g., `math:add`) and show input/output ports based on their definition.

### Bezier Edge Connections

Expand Down Expand Up @@ -157,15 +157,15 @@ const initialGraph: Graph = {
name: 'calculator',
definitions: [
{
type: 'js/const/number',
context: 'js',
name: 'number',
category: 'const',
props: [{ name: 'value', type: 'number', default: 0 }],
outputs: [{ name: 'value', type: 'number' }]
},
{
type: 'js/math/add',
context: 'js',
name: 'add',
category: 'math',
inputs: [
{ name: 'a', type: 'number' },
Expand All @@ -175,9 +175,9 @@ const initialGraph: Graph = {
}
],
nodes: [
{ name: 'num1', type: 'js/const/number', meta: { x: 50, y: 50 }, props: [{ name: 'value', value: 5 }] },
{ name: 'num2', type: 'js/const/number', meta: { x: 50, y: 150 }, props: [{ name: 'value', value: 3 }] },
{ name: 'add', type: 'js/math/add', meta: { x: 250, y: 100 } }
{ name: 'num1', type: 'const:number', meta: { x: 50, y: 50 }, props: [{ name: 'value', value: 5 }] },
{ name: 'num2', type: 'const:number', meta: { x: 50, y: 150 }, props: [{ name: 'value', value: 3 }] },
{ name: 'add', type: 'math:add', meta: { x: 250, y: 100 } }
],
edges: [
{ src: { node: 'num1', port: 'value' }, dst: { node: 'add', port: 'a' } },
Expand Down
2 changes: 1 addition & 1 deletion .agents/skills/fbp/references/fbp-spec.md
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ const newGraph = setPosition(graph, '/add1', 100, 200);
},
{
"name": "add1",
"type": "math/add",
"type": "math:add",
"meta": { "x": 200, "y": 50 }
},
{
Expand Down
17 changes: 13 additions & 4 deletions .agents/skills/fbp/references/fbp-types.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ Node identity equals name within parent scope. Names may be hierarchical paths b
```typescript
interface Graph {
name?: string;
context?: string; // Default context for node lookups
nodes: Node[];
edges: Edge[];
definitions?: NodeDefinition[];
Expand All @@ -44,7 +45,8 @@ interface Graph {
```typescript
interface Node {
name: string; // Unique within parent scope
type: string; // References a NodeDefinition
type: string; // References a NodeDefinition.name
context?: string; // Override the graph-level context
meta?: NodeMeta; // Position and metadata
props?: PropValue[]; // Property values
nodes?: Node[]; // Child nodes (makes this a subnet)
Expand All @@ -71,12 +73,15 @@ interface PortRef {

```typescript
interface NodeDefinition {
type: string; // Unique identifier (e.g., "math/add")
context?: string; // Namespace (e.g., "math", "ui")
category?: string; // Palette category
context: string; // Execution context (e.g., "js", "core")
name: string; // Short identifier (e.g., "add", "number", "Page")
category: string; // Required grouping + part of composite key (e.g., "math", "json")
inputs?: PortDef[]; // Input port definitions
outputs?: PortDef[]; // Output port definitions
props?: PropDef[]; // Property definitions
graph?: Graph; // Inline subgraph (for composite definitions)
volatile?: boolean; // If true, re-evaluate on every tick
runtime?: string; // Execution runtime (e.g., "inline", "http")
icon?: string;
description?: string;
}
Expand All @@ -88,15 +93,19 @@ interface NodeDefinition {
interface PortDef {
name: string;
type?: string; // Data type (e.g., "string", "number", "any")
schema?: Record<string, any>; // JSON Schema for complex types
multi?: boolean; // Accepts multiple connections
description?: string;
}

interface PropDef {
name: string;
type?: string;
schema?: Record<string, any>; // JSON Schema for complex types
default?: any;
description?: string;
required?: boolean;
options?: string[]; // Valid values for enum/select types
}

interface PropValue {
Expand Down
6 changes: 3 additions & 3 deletions packages/evaluator/__tests__/core-nodes.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ describe('core nodes', () => {
},
{
name: 'select',
type: 'core/json/select',
type: 'json:select',
props: [{ name: 'path', type: 'string', value: 'user.name' }]
}
],
Expand Down Expand Up @@ -47,7 +47,7 @@ describe('core nodes', () => {
},
{
name: 'select',
type: 'core/json/select',
type: 'json:select',
props: [{ name: 'path', type: 'string', value: 'response.data.users.1.id' }]
}
],
Expand Down Expand Up @@ -76,7 +76,7 @@ describe('core nodes', () => {
},
{
name: 'select',
type: 'core/json/select',
type: 'json:select',
props: [{ name: 'path', type: 'string', value: 'baz.qux' }]
}
],
Expand Down
6 changes: 3 additions & 3 deletions packages/evaluator/__tests__/core-nodes.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ describe('core nodes', () => {
},
{
name: 'select',
type: 'select',
type: 'json:select',
props: [{ name: 'path', type: 'string', value: 'user.name' }]
}
],
Expand Down Expand Up @@ -53,7 +53,7 @@ describe('core nodes', () => {
},
{
name: 'select',
type: 'select',
type: 'json:select',
props: [{ name: 'path', type: 'string', value: 'response.data.users.1.id' }]
}
],
Expand Down Expand Up @@ -86,7 +86,7 @@ describe('core nodes', () => {
},
{
name: 'select',
type: 'select',
type: 'json:select',
props: [{ name: 'path', type: 'string', value: 'baz.qux' }]
}
],
Expand Down
Loading
Loading