@loop-kit/graphite-core
v0.1.0
Published
Graphite runtime kernel: graph store, queries, validation, interaction runtime.
Downloads
52
Readme
@loop-kit/graphite-core
Graphite runtime kernel for intent graphs, overlay previews, validation, interaction, history, and effects.
Concepts
IntentStore: durable graph with schema-light node/edge/prop data.OverlayLayer: per-scope ephemeral patch stack for previews; easy to clear.PatchandCommit: invertible low-level ops applied atomically with version bumps.QueryEngine: dependency-captured reactive queries with touched-key invalidation.ValidatorsandStateView: deterministic intent snapshot transforms into derived slices + diagnostics.InteractionRuntime: recognizer arena, capture, hit-testing, and ephemeral session state.- Optional
History,EventLog,EffectRunner, and instrumentation (GraphiteMetrics).
How To Use
import { GraphiteRuntime, asNodeId, asScopeId } from '@loop-kit/graphite-core';
const runtime = new GraphiteRuntime({
enableHistory: true,
enableEventLog: true,
validateMode: 'lazy',
});
runtime.registerValidator('my.facet', (snapshot) => ({
slice: { nodes: snapshot.listNodeIds() },
diagnostics: [],
}));
const scope = runtime.getScope(asScopeId('main'));
scope.commitIntentPatch({
ops: [{ kind: 'setProp', nodeId: asNodeId('n1'), key: 'label', value: 'Node 1' }],
});How Dock Demonstrates It
@loop-kit/dock uses:
IntentStorefor dock root/group/tab nodes.OverlayLayerfor drag/drop preview intent.Validator->StateViewfor normalized dock tree, layout IR, and diagnostics.InteractionRuntime+ recognizer arena for drag gestures.Historyboundaries for undo/redo on docking commits.
Add A New Facet/System
- Define schema constants and patch builders in a separate package/module.
- Implement a validator
(snapshot) => { slice, diagnostics }. - Register it with
runtime.registerValidator('facet.name', validator). - Optionally register actions/effects that commit patches with explicit
meta.origin.
Commands
moon run graphite-core:typecheckmoon run graphite-core:testmoon run graphite-core:benchmoon run graphite-core:build
