@andespindola/brainlink 0.1.0-beta.156 → 0.1.0-beta.158
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md
CHANGED
|
@@ -82,14 +82,14 @@ Legacy `.jsonl.gz` packs are upgraded to `.blpk` automatically on first search/c
|
|
|
82
82
|
- Built-in MCP stdio server for agent tool integration.
|
|
83
83
|
- Local HTTP API.
|
|
84
84
|
- Realtime graph UI with agent selector and colored knowledge groups.
|
|
85
|
-
- Graph renderer uses a
|
|
86
|
-
-
|
|
87
|
-
- Graph exploration uses
|
|
85
|
+
- Graph renderer uses a cauliflower-style hub layout: the primary hub stays centered, segment hubs anchor surrounding lobes, and visual edges are simplified to root hub -> segment hubs -> local context nodes.
|
|
86
|
+
- Real weighted `[[wiki link]]` edges stay preserved in the indexed graph APIs for backlinks, ranking and context traversal; the browser layout uses a separate visual edge layer for readability.
|
|
87
|
+
- Graph exploration uses stable chunk streaming (`/api/graph-stream`) with explicit node/edge budgets, returning the full mode-level scene while it fits the budget.
|
|
88
88
|
- Render pipeline uses WebGL in a dedicated worker through `OffscreenCanvas`, keeping the main thread focused on UI controls and details panels.
|
|
89
89
|
- Large graph layout API automatically uses compact payload encoding with link-coverage-aware edge selection to reduce initial client load without hiding major relationships.
|
|
90
90
|
- Large-segment layout spacing now grows logarithmically to keep initial visual density consistent between medium and very large vaults (for example, ~1k vs ~50k notes).
|
|
91
91
|
- Graph coordinates are visually compacted across graph sizes so reset starts from a stable fitted scene and zoom-in progressively reveals local detail.
|
|
92
|
-
- Zoomed-out graph
|
|
92
|
+
- Zoomed-out graph summarizes the scene as segment hub clusters, then progressively reveals individual nodes as the user zooms in.
|
|
93
93
|
- Graph reset fits the full graph scene instead of starting in a separate macro overview mode.
|
|
94
94
|
- Graph filtering runs in a dedicated browser worker to keep the UI thread responsive during heavy datasets.
|
|
95
95
|
- Node titles are shown as the user zooms closer, while labels remain bounded to visible on-screen nodes in very large graphs.
|
|
@@ -599,12 +599,12 @@ When native GUI is used, the GUI window automatically closes when the `blink ser
|
|
|
599
599
|
The graph UI shows:
|
|
600
600
|
|
|
601
601
|
- notes as nodes
|
|
602
|
-
- all non-self `[[wiki links]]` inside `## Context Links` as weighted edges
|
|
603
|
-
- default
|
|
602
|
+
- all non-self `[[wiki links]]` inside `## Context Links` as weighted indexed edges
|
|
603
|
+
- default cauliflower-style visual layout centered on the primary hub, with segment hubs anchoring surrounding lobes and visual edges simplified to root hub -> segment hubs -> local context nodes
|
|
604
604
|
- details opened in a non-modal side panel (tags, outgoing links, backlinks, full Markdown content), so zoom and pan remain available while inspecting data
|
|
605
605
|
- neutral graph nodes with segment/group metadata
|
|
606
606
|
- agent selector (id-only labels) for isolated views
|
|
607
|
-
- context selector for segment-scoped
|
|
607
|
+
- context selector for segment-scoped cauliflower subgraphs derived from the visual graph context
|
|
608
608
|
- graph filter matches title, path, tags and note content
|
|
609
609
|
- graph filter keeps hub context nodes visible (`Memory Hub`/`MOC`/high-degree fallback) to preserve relationship readability
|
|
610
610
|
- realtime refresh while watch mode is enabled
|
|
@@ -612,14 +612,14 @@ The graph UI shows:
|
|
|
612
612
|
- wheel zoom (including `cmd+scroll` and `ctrl+scroll`) anchored to cursor position for faster navigation in large graphs
|
|
613
613
|
- wheel/button zoom updates immediately at the cursor anchor without delayed focus-transition interpolation
|
|
614
614
|
- Bloom-like scene navigation: reset fits the current graph scene, wheel zoom stays anchored to the cursor, and worker-driven WebGL rendering keeps pan/zoom interaction responsive
|
|
615
|
-
- zoom-out
|
|
615
|
+
- zoom-out cluster mode that shows segment hub clusters first, then reveals local nodes as zoom increases
|
|
616
616
|
- keyboard shortcuts: `+` zoom in, `-` zoom out, `0` reset fit
|
|
617
617
|
- click on a node opens its details panel; double-click on empty canvas zooms in at cursor position
|
|
618
618
|
- floating graph totals (notes, links, tags) below the Brainlink title
|
|
619
619
|
- graph rendering safeguards (batched GPU draw calls, lower redraw rate, zoom-aware interaction)
|
|
620
620
|
- adaptive CPU safeguards for large graphs: idle frame pacing, throttled background physics updates and cached viewport dimensions to reduce redraw/layout overhead while preserving interaction responsiveness
|
|
621
621
|
- worker-first WebGL rendering with Canvas fallback when `OffscreenCanvas` or worker rendering is unavailable
|
|
622
|
-
- large graph view keeps
|
|
622
|
+
- large graph view keeps one indexed graph model across zoom levels, uses a stable visual hierarchy for rendering, uses segment clusters at high zoom-out, and shows node titles as zoom approaches readable scale
|
|
623
623
|
|
|
624
624
|
The server indexes before starting by default. Use `--no-index` to skip that step:
|
|
625
625
|
|
|
@@ -2,10 +2,10 @@ import { createHash } from 'node:crypto';
|
|
|
2
2
|
import { mkdir, readFile, rename, stat, writeFile } from 'node:fs/promises';
|
|
3
3
|
import { dirname, join } from 'node:path';
|
|
4
4
|
import { addVisualContextEdges } from '../domain/graph-contexts.js';
|
|
5
|
-
import {
|
|
5
|
+
import { createCauliflowerGraphLayout } from '../domain/graph-layout.js';
|
|
6
6
|
import { indexStoragePath } from '../infrastructure/file-index.js';
|
|
7
7
|
import { getGraphSummary } from './get-graph-summary.js';
|
|
8
|
-
const graphLayoutVersion =
|
|
8
|
+
const graphLayoutVersion = 8;
|
|
9
9
|
const graphLayoutCache = new Map();
|
|
10
10
|
const safeCacheSegment = (value, fallback) => value?.replace(/[^a-zA-Z0-9_-]/g, '_') || fallback;
|
|
11
11
|
const graphLayoutStoragePath = (vaultPath, options) => {
|
|
@@ -48,14 +48,14 @@ const createGraphSignature = (graph) => {
|
|
|
48
48
|
.digest('hex');
|
|
49
49
|
};
|
|
50
50
|
const createLayout = (graph) => {
|
|
51
|
-
const rawLayout =
|
|
51
|
+
const rawLayout = createCauliflowerGraphLayout(graph);
|
|
52
52
|
return {
|
|
53
53
|
...rawLayout,
|
|
54
54
|
nodes: rawLayout.nodes.map((node) => ({ ...node, content: '' }))
|
|
55
55
|
};
|
|
56
56
|
};
|
|
57
57
|
const filterGraphByContext = (graph, context) => {
|
|
58
|
-
const baseLayout =
|
|
58
|
+
const baseLayout = createCauliflowerGraphLayout(graph);
|
|
59
59
|
const selectedNodeIds = new Set(baseLayout.nodes
|
|
60
60
|
.filter((node) => node.segment === context)
|
|
61
61
|
.map((node) => node.id));
|
|
@@ -107,13 +107,15 @@ const selectTopByRelevance = (items, relevanceById, budget) => [...items]
|
|
|
107
107
|
.slice(0, Math.max(1, budget));
|
|
108
108
|
const selectNearNodes = (nodes, cache, input) => {
|
|
109
109
|
const padding = Math.max(input.width, input.height) * viewportPaddingFactor;
|
|
110
|
-
const
|
|
110
|
+
const candidateNodes = nodes.length <= input.nodeBudget
|
|
111
|
+
? nodes
|
|
112
|
+
: nodes.filter((node) => inViewport(node, input, padding));
|
|
111
113
|
const relevance = new Map();
|
|
112
|
-
for (let index = 0; index <
|
|
113
|
-
const node =
|
|
114
|
+
for (let index = 0; index < candidateNodes.length; index += 1) {
|
|
115
|
+
const node = candidateNodes[index];
|
|
114
116
|
relevance.set(node.id, rankNodeRelevance(node, input, cache.degrees));
|
|
115
117
|
}
|
|
116
|
-
const selected = selectTopByRelevance(
|
|
118
|
+
const selected = selectTopByRelevance(candidateNodes, relevance, input.nodeBudget);
|
|
117
119
|
return selected.map((node) => [
|
|
118
120
|
node.id,
|
|
119
121
|
node.title,
|
|
@@ -127,13 +129,15 @@ const selectNearNodes = (nodes, cache, input) => {
|
|
|
127
129
|
};
|
|
128
130
|
const selectMidNodes = (nodes, cache, input) => {
|
|
129
131
|
const padding = Math.max(input.width, input.height) * (viewportPaddingFactor + 0.08);
|
|
130
|
-
const
|
|
132
|
+
const candidateNodes = nodes.length <= input.nodeBudget
|
|
133
|
+
? nodes
|
|
134
|
+
: nodes.filter((node) => inViewport(node, input, padding));
|
|
131
135
|
const relevance = new Map();
|
|
132
|
-
for (let index = 0; index <
|
|
133
|
-
const node =
|
|
136
|
+
for (let index = 0; index < candidateNodes.length; index += 1) {
|
|
137
|
+
const node = candidateNodes[index];
|
|
134
138
|
relevance.set(node.id, rankNodeRelevance(node, input, cache.degrees) * 1.1);
|
|
135
139
|
}
|
|
136
|
-
const selected = selectTopByRelevance(
|
|
140
|
+
const selected = selectTopByRelevance(candidateNodes, relevance, input.nodeBudget);
|
|
137
141
|
return selected.map((node) => [
|
|
138
142
|
node.id,
|
|
139
143
|
node.title,
|
|
@@ -145,16 +149,14 @@ const selectMidNodes = (nodes, cache, input) => {
|
|
|
145
149
|
relevance.get(node.id) ?? 0
|
|
146
150
|
]);
|
|
147
151
|
};
|
|
148
|
-
const selectFarClusters = (
|
|
149
|
-
const roots =
|
|
150
|
-
const padding = Math.max(input.width, input.height) * 0.12;
|
|
151
|
-
const candidates = roots.filter((group) => inViewport(group, input, padding));
|
|
152
|
+
const selectFarClusters = (nodes, input, nodeBudget) => {
|
|
153
|
+
const roots = createSegmentClusters(nodes);
|
|
152
154
|
const relevance = new Map();
|
|
153
|
-
for (let index = 0; index <
|
|
154
|
-
const group =
|
|
155
|
+
for (let index = 0; index < roots.length; index += 1) {
|
|
156
|
+
const group = roots[index];
|
|
155
157
|
relevance.set(group.id, rankGroupRelevance(group, input));
|
|
156
158
|
}
|
|
157
|
-
const selected = selectTopByRelevance(
|
|
159
|
+
const selected = selectTopByRelevance(roots, relevance, nodeBudget);
|
|
158
160
|
return selected.map((group) => [
|
|
159
161
|
`cluster:${group.id}`,
|
|
160
162
|
group.title,
|
|
@@ -166,10 +168,42 @@ const selectFarClusters = (groups, input, nodeBudget) => {
|
|
|
166
168
|
relevance.get(group.id) ?? 0
|
|
167
169
|
]);
|
|
168
170
|
};
|
|
171
|
+
const createSegmentClusters = (nodes) => {
|
|
172
|
+
const nodesBySegment = new Map();
|
|
173
|
+
nodes.forEach((node) => {
|
|
174
|
+
const bucket = nodesBySegment.get(node.segment) ?? [];
|
|
175
|
+
bucket.push(node);
|
|
176
|
+
nodesBySegment.set(node.segment, bucket);
|
|
177
|
+
});
|
|
178
|
+
return Array.from(nodesBySegment.entries()).map(([segment, segmentNodes]) => {
|
|
179
|
+
const center = segmentNodes.reduce((state, node) => ({
|
|
180
|
+
x: state.x + node.x,
|
|
181
|
+
y: state.y + node.y
|
|
182
|
+
}), { x: 0, y: 0 });
|
|
183
|
+
const x = center.x / Math.max(segmentNodes.length, 1);
|
|
184
|
+
const y = center.y / Math.max(segmentNodes.length, 1);
|
|
185
|
+
const radius = segmentNodes.reduce((largest, node) => Math.max(largest, Math.hypot(node.x - x, node.y - y)), 80);
|
|
186
|
+
return {
|
|
187
|
+
id: `segment:${segment}`,
|
|
188
|
+
level: 0,
|
|
189
|
+
parentId: null,
|
|
190
|
+
title: segment,
|
|
191
|
+
segment,
|
|
192
|
+
group: segmentNodes[0]?.group ?? segment,
|
|
193
|
+
x,
|
|
194
|
+
y,
|
|
195
|
+
radius: Math.max(radius + 96, 160),
|
|
196
|
+
nodeIds: segmentNodes.map((node) => node.id),
|
|
197
|
+
childGroupIds: [],
|
|
198
|
+
internalEdges: [],
|
|
199
|
+
externalEdges: []
|
|
200
|
+
};
|
|
201
|
+
});
|
|
202
|
+
};
|
|
169
203
|
const collectEdgesForNodes = (allEdges, cache, nodeRows, edgeBudget, maxEdgesPerNode) => {
|
|
170
204
|
const isClusterMode = nodeRows.length > 0 && nodeRows[0]?.[6] === 'cluster';
|
|
171
205
|
if (isClusterMode) {
|
|
172
|
-
const
|
|
206
|
+
const clusterSegments = new Set(nodeRows.map((row) => row[5]));
|
|
173
207
|
const clusterEdges = new Map();
|
|
174
208
|
for (let index = 0; index < allEdges.length; index += 1) {
|
|
175
209
|
const edge = allEdges[index];
|
|
@@ -179,9 +213,9 @@ const collectEdgesForNodes = (allEdges, cache, nodeRows, edgeBudget, maxEdgesPer
|
|
|
179
213
|
const targetNode = cache.nodeById.get(edge.target);
|
|
180
214
|
if (!sourceNode || !targetNode)
|
|
181
215
|
continue;
|
|
182
|
-
const sourceCluster = sourceNode.
|
|
183
|
-
const targetCluster = targetNode.
|
|
184
|
-
if (!
|
|
216
|
+
const sourceCluster = sourceNode.segment;
|
|
217
|
+
const targetCluster = targetNode.segment;
|
|
218
|
+
if (!clusterSegments.has(sourceCluster) || !clusterSegments.has(targetCluster) || sourceCluster === targetCluster)
|
|
185
219
|
continue;
|
|
186
220
|
const key = sourceCluster < targetCluster ? `${sourceCluster}|${targetCluster}` : `${targetCluster}|${sourceCluster}`;
|
|
187
221
|
const current = clusterEdges.get(key);
|
|
@@ -193,12 +227,12 @@ const collectEdgesForNodes = (allEdges, cache, nodeRows, edgeBudget, maxEdgesPer
|
|
|
193
227
|
.sort((left, right) => edgeRank(right) - edgeRank(left))
|
|
194
228
|
.slice(0, Math.max(1, edgeBudget))
|
|
195
229
|
.map((edge) => [
|
|
196
|
-
`cluster:${cache.nodeById.get(edge.source)?.
|
|
197
|
-
`cluster:${cache.nodeById.get(edge.target ?? '')?.
|
|
230
|
+
`cluster:segment:${cache.nodeById.get(edge.source)?.segment ?? ''}`,
|
|
231
|
+
`cluster:segment:${cache.nodeById.get(edge.target ?? '')?.segment ?? ''}`,
|
|
198
232
|
edge.weight,
|
|
199
233
|
edge.priority
|
|
200
234
|
])
|
|
201
|
-
.filter((edge) => edge[0] !== edge[1] && edge[0] !== 'cluster:' && edge[1] !== 'cluster:');
|
|
235
|
+
.filter((edge) => edge[0] !== edge[1] && edge[0] !== 'cluster:segment:' && edge[1] !== 'cluster:segment:');
|
|
202
236
|
}
|
|
203
237
|
const nodeIds = new Set(nodeRows.map((row) => row[0]));
|
|
204
238
|
const collected = new Map();
|
|
@@ -267,8 +301,8 @@ export const getGraphStreamChunk = async (vaultPath, input) => {
|
|
|
267
301
|
: input.scale < midScaleThreshold
|
|
268
302
|
? 'mid'
|
|
269
303
|
: 'near';
|
|
270
|
-
const nodes = mode === 'far'
|
|
271
|
-
? selectFarClusters(
|
|
304
|
+
const nodes = mode === 'far'
|
|
305
|
+
? selectFarClusters(layout.nodes, input, nodeBudget)
|
|
272
306
|
: mode === 'mid'
|
|
273
307
|
? selectMidNodes(layout.nodes, cache, {
|
|
274
308
|
...input,
|
|
@@ -193,29 +193,101 @@ const compareByStarOrder = (levels, degrees, segmentIndexByName, segments) => (l
|
|
|
193
193
|
const degreeDelta = (degrees.get(right.id) ?? 0) - (degrees.get(left.id) ?? 0);
|
|
194
194
|
return degreeDelta === 0 ? left.title.localeCompare(right.title) : degreeDelta;
|
|
195
195
|
};
|
|
196
|
-
const
|
|
196
|
+
const petalRadiusForSegmentSize = (size) => {
|
|
197
197
|
const safeSize = Math.max(size, 1);
|
|
198
|
-
return
|
|
198
|
+
return Math.max(260, Math.sqrt(safeSize) * 96);
|
|
199
199
|
};
|
|
200
|
-
const
|
|
200
|
+
const selectSegmentHub = (nodes, degrees, primaryHubId) => {
|
|
201
|
+
const primary = nodes.find((node) => node.id === primaryHubId);
|
|
202
|
+
if (primary) {
|
|
203
|
+
return primary;
|
|
204
|
+
}
|
|
205
|
+
return [...nodes].sort((left, right) => {
|
|
206
|
+
const hubDelta = hubScore(right) - hubScore(left);
|
|
207
|
+
if (hubDelta !== 0)
|
|
208
|
+
return hubDelta;
|
|
209
|
+
const degreeDelta = (degrees.get(right.id) ?? 0) - (degrees.get(left.id) ?? 0);
|
|
210
|
+
if (degreeDelta !== 0)
|
|
211
|
+
return degreeDelta;
|
|
212
|
+
return left.title.localeCompare(right.title);
|
|
213
|
+
})[0] ?? null;
|
|
214
|
+
};
|
|
215
|
+
const segmentCenterRadius = (segments) => {
|
|
216
|
+
if (segments.length <= 1) {
|
|
217
|
+
return 0;
|
|
218
|
+
}
|
|
219
|
+
const circumference = segments.reduce((total, [, nodes]) => total + petalRadiusForSegmentSize(nodes.length) * 2 + 180, 0);
|
|
220
|
+
return Math.max(520, circumference / (Math.PI * 2));
|
|
221
|
+
};
|
|
222
|
+
const createCauliflowerSegmentNodes = (segments, degrees, rootHubId, segmentGroups) => ([segment, nodes], segmentIndex) => {
|
|
201
223
|
const sortedNodes = [...nodes].sort(byDegreeThenTitle(degrees));
|
|
202
|
-
const
|
|
203
|
-
const
|
|
204
|
-
const
|
|
205
|
-
const
|
|
206
|
-
const
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
224
|
+
const segmentHub = selectSegmentHub(sortedNodes, degrees, rootHubId);
|
|
225
|
+
const angle = segmentAngle(segment, segmentIndex, segmentGroups.length);
|
|
226
|
+
const globalRadius = segmentCenterRadius(segmentGroups);
|
|
227
|
+
const petalRadius = petalRadiusForSegmentSize(sortedNodes.length);
|
|
228
|
+
const isPrimarySegment = Boolean(segmentHub && segmentHub.id === rootHubId);
|
|
229
|
+
const centerX = isPrimarySegment || globalRadius === 0 ? 0 : Math.cos(angle) * globalRadius;
|
|
230
|
+
const centerY = isPrimarySegment || globalRadius === 0 ? 0 : Math.sin(angle) * (globalRadius * 0.86);
|
|
231
|
+
const nonHubNodes = sortedNodes.filter((node) => node.id !== segmentHub?.id);
|
|
232
|
+
const hubNode = segmentHub
|
|
233
|
+
? [{
|
|
234
|
+
...segmentHub,
|
|
235
|
+
group: groupLabel(groupKey(segmentHub)),
|
|
236
|
+
segment: segments.get(segmentHub.id) ?? segment,
|
|
237
|
+
x: centerX,
|
|
238
|
+
y: centerY
|
|
239
|
+
}]
|
|
240
|
+
: [];
|
|
241
|
+
const petalNodes = nonHubNodes.map((node, index) => {
|
|
242
|
+
const localAngle = index * 2.399963 + jitter(node.title, 0.5);
|
|
243
|
+
const radialLayer = Math.sqrt(index + 1) / Math.sqrt(Math.max(nonHubNodes.length, 1));
|
|
244
|
+
const localRadius = 150 + radialLayer * petalRadius + jitter(node.id, 34);
|
|
245
|
+
const degreePull = Math.min(degrees.get(node.id) ?? 0, 16) * 8;
|
|
246
|
+
const radius = Math.max(126, localRadius - degreePull);
|
|
211
247
|
return {
|
|
212
248
|
...node,
|
|
213
249
|
group: groupLabel(groupKey(node)),
|
|
214
250
|
segment: segments.get(node.id) ?? segment,
|
|
215
|
-
x: centerX + Math.cos(localAngle) *
|
|
216
|
-
y: centerY + Math.sin(localAngle) *
|
|
251
|
+
x: centerX + Math.cos(localAngle) * radius + jitter(node.title, 20),
|
|
252
|
+
y: centerY + Math.sin(localAngle) * radius * 0.84 + jitter(node.path, 20)
|
|
217
253
|
};
|
|
218
254
|
});
|
|
255
|
+
return [...hubNode, ...petalNodes];
|
|
256
|
+
};
|
|
257
|
+
const createVisualEdge = (source, target, weight, priority) => ({
|
|
258
|
+
source: source.id,
|
|
259
|
+
target: target.id,
|
|
260
|
+
targetTitle: target.title,
|
|
261
|
+
weight,
|
|
262
|
+
priority
|
|
263
|
+
});
|
|
264
|
+
const createCauliflowerVisualEdges = (segmentGroups, degrees, rootHubId) => {
|
|
265
|
+
const nodeById = new Map(segmentGroups.flatMap(([, nodes]) => nodes.map((node) => [node.id, node])));
|
|
266
|
+
const rootHub = rootHubId ? nodeById.get(rootHubId) ?? null : null;
|
|
267
|
+
const edges = new Map();
|
|
268
|
+
const addEdge = (edge) => {
|
|
269
|
+
if (!edge.target || edge.source === edge.target) {
|
|
270
|
+
return;
|
|
271
|
+
}
|
|
272
|
+
edges.set(`${edge.source}|${edge.target}`, edge);
|
|
273
|
+
};
|
|
274
|
+
segmentGroups.forEach(([, nodes]) => {
|
|
275
|
+
const segmentHub = selectSegmentHub(nodes, degrees, rootHubId);
|
|
276
|
+
const parent = segmentHub ?? rootHub;
|
|
277
|
+
if (!parent) {
|
|
278
|
+
return;
|
|
279
|
+
}
|
|
280
|
+
if (rootHub && parent.id !== rootHub.id) {
|
|
281
|
+
addEdge(createVisualEdge(rootHub, parent, 6, 'high'));
|
|
282
|
+
}
|
|
283
|
+
nodes.forEach((node) => {
|
|
284
|
+
if (node.id === parent.id || node.id === rootHub?.id) {
|
|
285
|
+
return;
|
|
286
|
+
}
|
|
287
|
+
addEdge(createVisualEdge(parent, node, 1, 'low'));
|
|
288
|
+
});
|
|
289
|
+
});
|
|
290
|
+
return Array.from(edges.values());
|
|
219
291
|
};
|
|
220
292
|
const distanceBetween = (left, right) => Math.hypot(right.x - left.x, right.y - left.y);
|
|
221
293
|
const layoutBounds = (nodes) => {
|
|
@@ -539,13 +611,14 @@ export const createCauliflowerGraphLayout = (graph) => {
|
|
|
539
611
|
const segments = assignSegments(graph.nodes, graph.edges, degrees);
|
|
540
612
|
const segmentGroups = Array.from(groupNodesBySegment(graph.nodes, segments).entries())
|
|
541
613
|
.sort(([left], [right]) => left.localeCompare(right));
|
|
542
|
-
const
|
|
543
|
-
const
|
|
544
|
-
const centeredNodes = centerLayoutByNode(nodes,
|
|
545
|
-
const
|
|
614
|
+
const rootHubId = selectPrimaryHubId(graph.nodes, degrees) ?? selectHighestDegreeNodeId(graph.nodes, degrees);
|
|
615
|
+
const nodes = relaxCollisions(segmentGroups.flatMap(createCauliflowerSegmentNodes(segments, degrees, rootHubId, segmentGroups)), 156, 28);
|
|
616
|
+
const centeredNodes = centerLayoutByNode(nodes, rootHubId);
|
|
617
|
+
const visualEdges = createCauliflowerVisualEdges(segmentGroups, degrees, rootHubId);
|
|
618
|
+
const groups = createGraphLayoutHierarchy(centeredNodes, visualEdges, degrees);
|
|
546
619
|
return {
|
|
547
620
|
nodes: centeredNodes,
|
|
548
|
-
edges:
|
|
621
|
+
edges: visualEdges,
|
|
549
622
|
...(groups.length > 0 ? { groups } : {})
|
|
550
623
|
};
|
|
551
624
|
};
|
package/docs/AGENT_USAGE.md
CHANGED
|
@@ -610,7 +610,7 @@ Without `--vault`, the graph UI serves `$HOME/.brainlink/vault`.
|
|
|
610
610
|
|
|
611
611
|
The frontend includes an agent selector that shows only the agent id. Selecting an agent calls the same read APIs with `agent=<agent-id>` and renders that namespace instead of merging every agent into one graph.
|
|
612
612
|
|
|
613
|
-
Graph navigation controls include zoom in, zoom out, fit visible nodes and reset-to-fit-all nodes. Mouse wheel zoom (including `cmd+scroll` and `ctrl+scroll`) is anchored to the cursor and applied immediately without delayed focus interpolation. Keyboard shortcuts are `+` (zoom in), `-` (zoom out) and `0` (reset fit). Double-click on empty canvas zooms in at cursor position. Clicking a node opens its details panel. Totals for notes, links and tags stay visible as floating metrics under the Brainlink title, and node details open in a non-modal side panel (tags, outgoing links, backlinks and Markdown content), so zoom and pan remain available during inspection. The visual layout is a
|
|
613
|
+
Graph navigation controls include zoom in, zoom out, fit visible nodes and reset-to-fit-all nodes. Mouse wheel zoom (including `cmd+scroll` and `ctrl+scroll`) is anchored to the cursor and applied immediately without delayed focus interpolation. Keyboard shortcuts are `+` (zoom in), `-` (zoom out) and `0` (reset fit). Double-click on empty canvas zooms in at cursor position. Clicking a node opens its details panel. Totals for notes, links and tags stay visible as floating metrics under the Brainlink title, and node details open in a non-modal side panel (tags, outgoing links, backlinks and Markdown content), so zoom and pan remain available during inspection. The visual layout is a cauliflower hub layout: the primary hub stays centered, segment hubs anchor surrounding lobes, and visual edges are simplified to root hub -> segment hubs -> local context nodes. Indexed weighted wiki-link edges remain available for backlinks, ranking and context traversal outside the render layer. At high zoom-out, graph streams show segment hub clusters first; zooming in progressively reveals the individual nodes inside those lobes. Node titles appear as zoom approaches readable scale, limited to on-screen nodes in very large graphs.
|
|
614
614
|
During graph filtering, Brainlink keeps hub context nodes visible (`Memory Hub`/`MOC`/high-degree fallback) so filtered views still show relationship anchors.
|
|
615
615
|
|
|
616
616
|
The command reindexes by default, then serves:
|
package/docs/ARCHITECTURE.md
CHANGED
|
@@ -156,13 +156,13 @@ server command
|
|
|
156
156
|
-> /api/agents lists indexed namespaces
|
|
157
157
|
-> /api/graph-contexts lists visual graph contexts
|
|
158
158
|
-> /api/graph reads indexed documents and links
|
|
159
|
-
-> /api/graph-layout derives a
|
|
160
|
-
-> optional context query narrows the layout to a segment-scoped
|
|
159
|
+
-> /api/graph-layout derives a cauliflower hub layout from indexed graph data
|
|
160
|
+
-> optional context query narrows the layout to a segment-scoped cauliflower subgraph
|
|
161
161
|
-> browser renders graph canvas
|
|
162
162
|
```
|
|
163
163
|
|
|
164
164
|
The graph UI is intentionally read-only. Markdown remains the write interface and index artifacts remain derived data.
|
|
165
|
-
The
|
|
165
|
+
The cauliflower layout is a visual projection over the indexed graph. Indexed weighted wiki-link edges remain unchanged for backlinks, ranking, graph reads and context traversal. The browser layout renders a simplified hierarchy instead: primary hub -> segment hubs -> local context nodes. This avoids unstable cross-context visual edges while preserving the real relationship model outside the render layer. Zoomed-out graph streams summarize those lobes as segment clusters before revealing individual nodes on zoom-in.
|
|
166
166
|
|
|
167
167
|
## HTTP API Flow
|
|
168
168
|
|
package/package.json
CHANGED