Replace the five variable nodes with one Variables node

A single node now lists any number of variables. Every entry is an output
that reads the current value whenever it is pulled; an entry switched to
Set is also an input and is written when the flow arrives. Exec pins only
exist while at least one entry writes, and all inputs are read before any
write, so one node can swap two variables.

Get/Set variable, Get/Set variables and Variable are gone. Old project
files are converted on load: each old node becomes a Variables node with
the same variables, edges and typed values.

A written port without a typed value now shows the zero of its kind on
the node body, matching what the inspector shows and what the run writes.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
rootandClaude Opus 5 committed 2026-09-11 16:56:24 +02:00
1 parent 854ae2e756
commit 7c63c884ef
40 files changed
+895 -590

No files matched your search

+22 -8
View File
@@ -7,8 +7,7 @@ import { nodeDef, type NodeDef, type PortDef } from './NodeRegistry';
export const BEHAVIOR_START = 'BehaviorStart';
export const BEHAVIOR_END = 'BehaviorEnd';
export const RUN_BEHAVIOR = 'RunBehavior';
export const GET_VARIABLES = 'GetVariables';
export const SET_VARIABLES = 'SetVariables';
export const VARIABLES = 'Variables';
export const GET_PROPERTIES = 'GetProperties';
export const SET_PROPERTIES = 'SetProperties';
@@ -20,7 +19,7 @@ export const BEHAVIOR_PARAM = 'behavior';
* instead of letting them be typed.
*/
export function declaresVariablePorts(type: string): boolean {
return type === GET_VARIABLES || type === SET_VARIABLES;
return type === VARIABLES;
}
/** Nodes whose declared ports are properties of the object they are handed. */
@@ -35,7 +34,19 @@ export function isValidPortName(name: string): boolean {
/** Keys a declared port cannot take: the node's fixed ports on the side it declares (`object`). */
export function fixedPortKeys(def: NodeDef): string[] {
return (def.declaresPorts === 'inputs' ? def.inputs : def.outputs).map((p) => p.key);
const side = def.declaresPorts;
const fixed =
side === 'inputs' ? def.inputs : side === 'outputs' ? def.outputs : [...def.inputs, ...def.outputs];
return fixed.map((p) => p.key);
}
export function declaredOn(
def: NodeDef,
ports: readonly DeclaredPort[],
side: 'inputs' | 'outputs',
): DeclaredPort[] {
if (def.declaresPorts === 'both') return side === 'outputs' ? [...ports] : ports.filter((p) => p.write);
return def.declaresPorts === side ? [...ports] : [];
}
/** The single start (or end) node of a graph; a second one is ignored. */
@@ -68,14 +79,17 @@ export function declaredPorts(graph: Graph | undefined, type: string): PortDef[]
export function resolveDef(node: GraphNode, graph: Graph, lookup: BehaviorLookup): NodeDef | undefined {
const def = nodeDef(node.type);
if (!def || (!def.declaresPorts && !def.derivePorts)) return def;
const own = def.declaresPorts ? (node.ports ?? []).map((p) => (def.declaredPort ?? portDefOf)(p)) : [];
const side = (which: 'inputs' | 'outputs') => (def.declaresPorts === which ? own : []);
const own = (side: 'inputs' | 'outputs') =>
declaredOn(def, node.ports ?? [], side).map((p) =>
def.declaredPort ? def.declaredPort(p) : portDefOf(p),
);
const grown = def.derivePorts?.({ node, graph, behaviors: lookup }) ?? {};
// Derived before declared: a derived exec pin belongs at the top.
return {
...def,
label: grown.label ?? def.label,
inputs: [...def.inputs, ...side('inputs'), ...(grown.inputs ?? [])],
outputs: [...def.outputs, ...side('outputs'), ...(grown.outputs ?? [])],
inputs: [...def.inputs, ...(grown.inputs ?? []), ...own('inputs')],
outputs: [...def.outputs, ...(grown.outputs ?? []), ...own('outputs')],
};
}