glassbrain 0.2.0-alpha.4 → 0.2.0-alpha.6

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
@@ -22,10 +22,12 @@ lets you read one at a glance, and when the agent learns something, shows you ex
22
22
  ```json
23
23
  {
24
24
  "nodes": [
25
- { "id": "src", "label": "src", "kind": "folder", "parent": null },
26
- { "id": "src/auth", "label": "auth", "kind": "folder", "parent": "src@1" },
27
- { "id": "src/auth/login.ts", "label": "login.ts", "kind": "file", "parent": "src/auth@-1" },
28
- { "id": "src/db.ts", "label": "db.ts", "kind": "file", "parent": "src@2" }
25
+ { "id": "src", "label": "src", "kind": "folder", "children": [
26
+ { "id": "src/auth", "label": "auth", "kind": "folder", "children": [
27
+ { "id": "src/auth/login.ts", "label": "login.ts", "kind": "file" }
28
+ ] },
29
+ { "id": "src/db.ts", "label": "db.ts", "kind": "file" }
30
+ ] }
29
31
  ],
30
32
  "edges": [{ "source": "src/auth/login.ts", "target": "src/db.ts", "kind": "uses" }]
31
33
  }
@@ -39,9 +41,17 @@ it as an error (forty kinds without colours look exactly like one kind):
39
41
  "edgePalette": { "uses": "#2563eb" } }
40
42
  ```
41
43
 
42
- `parent` is required on every node (null for the one root) and says what sits inside what **and where
43
- it sits**: `id@order`, or `id@-1` for an explicitly unordered set. The layout reads the numbers
44
- clockwise, and a root whose children are numbered *is* the 2.5D layer view. There is no layer field.
44
+ Only `id` is required. Nest nodes in `children`; array order is reading order. `kind` is recommended.
45
+ Within one pass, fragments with the same id fill absent fields. Equal values are accepted; conflicting values
46
+ are errors. Repeated `children` declarations must have the same direct child ids in the same order;
47
+ child details compose independently. An omitted list is unspecified; `[]` explicitly declares no children.
48
+ Top-level fragments attach wherever their id appears in another node's children. Unattached nodes are roots.
49
+ Each node has at most one parent, and cycles are errors. Each pass is a complete snapshot.
50
+
51
+ The layout reads children clockwise when seeding recursive sectors: the outer circle reserves an empty
52
+ sector at the top, and descendants subdivide their parent's angular interval. Re-layout samples again;
53
+ the force solver can change the final angular order. The layer view uses the root's children, or the forest's
54
+ roots, in reading order. No parent, order or layer field is written. See [tree composition](https://github.com/voidixyn/glassbrain/blob/main/docs/cli.md#tree-fragments-and-composition).
45
55
  A [JSON Schema](https://github.com/voidixyn/glassbrain/blob/main/schema/graph.schema.json) describes every field, and the CLI answers in a form an
46
56
  agent can act on — findings identify the problem and structural advice suggests a next step:
47
57
 
@@ -96,7 +106,7 @@ That makes change the main event:
96
106
 
97
107
  Search ranks by how well a node matches, the detail panel renders the node's markdown, labels
98
108
  make room for each other instead of piling up, and [dark mode is computed](https://github.com/voidixyn/glassbrain/blob/main/docs/guide.md#color-hue-is-configured-everything-else-is-computed)
99
- from the light palette. A root whose children carry `order` opens as floors in 2.5D:
109
+ from the light palette. The root’s children can be read as floors in 2.5D:
100
110
 
101
111
  ![Protocols, building blocks and products of the agent ecosystem, stacked in 2.5D](https://raw.githubusercontent.com/voidixyn/glassbrain/main/docs/media/layers.png)
102
112
 
package/dist/adapters.js CHANGED
@@ -481,12 +481,36 @@ function adapt(files, only) {
481
481
  const out = pick.convert(files);
482
482
  const skipped = pick === MARKDOWN ? [] : files.filter((f) => /\.jsonl?$/i.test(f.path) && !pick.detect([f])).map((f) => f.path);
483
483
  return {
484
- sources: out.sources.map((s) => ({ origin: s.origin, text: JSON.stringify(s.graph) })),
484
+ sources: treeSources(out),
485
485
  profile: out.profile,
486
486
  adapter: pick,
487
487
  skipped
488
488
  };
489
489
  }
490
+ function treeSources(out) {
491
+ const children = /* @__PURE__ */ new Map();
492
+ for (const s of out.sources) for (const n of s.graph.nodes) {
493
+ if (!n.parent) continue;
494
+ const kids = children.get(n.parent) ?? /* @__PURE__ */ new Map();
495
+ kids.set(n.id, typeof n.order === "number" ? n.order : void 0);
496
+ children.set(n.parent, kids);
497
+ }
498
+ const written = /* @__PURE__ */ new Set();
499
+ return out.sources.map((s) => ({ origin: s.origin, text: JSON.stringify({
500
+ ...s.graph,
501
+ nodes: s.graph.nodes.map((n) => {
502
+ const { parent: _parent, order: _order, layer: _layer, ...fields } = n;
503
+ const kids = children.get(n.id);
504
+ if (!kids || written.has(n.id)) return fields;
505
+ written.add(n.id);
506
+ return {
507
+ ...fields,
508
+ ...fields.unordered === void 0 && [...kids.values()].every((v) => v === void 0) ? { unordered: true } : {},
509
+ children: [...kids].sort((a, b) => (a[1] ?? Infinity) - (b[1] ?? Infinity)).map(([id]) => ({ id }))
510
+ };
511
+ })
512
+ }) }));
513
+ }
490
514
  var isNativeGraph = (f) => {
491
515
  if (!/\.json$/i.test(f.path)) return false;
492
516
  try {
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  EN
3
- } from "./chunk-ISWKAU5G.js";
3
+ } from "./chunk-5DEN6HXJ.js";
4
4
 
5
5
  // src/react/i18n.ts
6
6
  import { createContext, useContext } from "react";
@@ -175,6 +175,7 @@ function DetailPanel({ node, spec, kindLabels, onClose, renderText, onEdit, colo
175
175
  "label",
176
176
  "parent",
177
177
  "order",
178
+ "children",
178
179
  "layer",
179
180
  "flags"
180
181
  ]);
@@ -201,8 +202,8 @@ function DetailPanel({ node, spec, kindLabels, onClose, renderText, onEdit, colo
201
202
  /* @__PURE__ */ jsx3("span", { children: node.parent ?? "Root" })
202
203
  ] }),
203
204
  node.parent && /* @__PURE__ */ jsxs("div", { className: "gb-line", children: [
204
- /* @__PURE__ */ jsx3("span", { className: "gb-k", children: "Order" }),
205
- /* @__PURE__ */ jsx3("span", { children: node.order ?? "Unordered" })
205
+ /* @__PURE__ */ jsx3("span", { className: "gb-k", children: "Position" }),
206
+ /* @__PURE__ */ jsx3("span", { children: node.order ?? "\u2014" })
206
207
  ] }),
207
208
  node.flags.map((f) => {
208
209
  const note = spec.flagNotes?.[f];