glassbrain 0.0.0-stage → 0.1.1
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/LICENSE +21 -0
- package/README.md +237 -2
- package/dist/adapters/common.d.ts +51 -0
- package/dist/adapters/graphify.d.ts +51 -0
- package/dist/adapters/index.d.ts +24 -0
- package/dist/adapters/memory.d.ts +7 -0
- package/dist/adapters/obsidian.d.ts +18 -0
- package/dist/adapters/understand.d.ts +70 -0
- package/dist/adapters.js +492 -0
- package/dist/animate.d.ts +312 -0
- package/dist/chunks/chunk-37BAJC3L.js +234 -0
- package/dist/chunks/chunk-3CNKH3HB.js +5226 -0
- package/dist/chunks/chunk-EJURBBFC.js +92 -0
- package/dist/chunks/chunk-LEYJCT6O.js +0 -0
- package/dist/chunks/chunk-SA6RSWZP.js +0 -0
- package/dist/chunks/chunk-UJCALP4P.js +2283 -0
- package/dist/chunks/chunk-YGRPNAXE.js +95 -0
- package/dist/chunks/chunk-ZA47FP7C.js +7 -0
- package/dist/cli/glassbrain.js +1523 -0
- package/dist/cli/viewer.js +851 -0
- package/dist/core.d.ts +10 -0
- package/dist/core.js +148 -0
- package/dist/diff.d.ts +156 -0
- package/dist/edit.d.ts +58 -0
- package/dist/elements.d.ts +57 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.js +175 -0
- package/dist/internal.d.ts +7 -0
- package/dist/internal.js +287 -0
- package/dist/layout/diff-layout.d.ts +92 -0
- package/dist/layout/divide.d.ts +61 -0
- package/dist/layout/engine.d.ts +63 -0
- package/dist/layout/inline-pool.d.ts +2 -0
- package/dist/layout/inline-pool.js +7 -0
- package/dist/layout/planes.d.ts +39 -0
- package/dist/layout/presets.d.ts +5 -0
- package/dist/layout/readability.d.ts +65 -0
- package/dist/layout/relax.d.ts +19 -0
- package/dist/layout/run-job.d.ts +30 -0
- package/dist/layout/worker-pool.d.ts +2 -0
- package/dist/layout/worker-pool.js +17 -0
- package/dist/layout/worker.d.ts +1 -0
- package/dist/layout/worker.js +87 -0
- package/dist/model.d.ts +92 -0
- package/dist/paint.d.ts +94 -0
- package/dist/profile.d.ts +133 -0
- package/dist/react/DetailPanel.d.ts +29 -0
- package/dist/react/DetailPanel.js +10 -0
- package/dist/react/DiffOverlay.d.ts +59 -0
- package/dist/react/EditPanel.d.ts +30 -0
- package/dist/react/GraphCanvas.d.ts +208 -0
- package/dist/react/GraphCanvas.js +13 -0
- package/dist/react/Legend.d.ts +47 -0
- package/dist/react/Toolbar.d.ts +48 -0
- package/dist/react/camera.d.ts +29 -0
- package/dist/react/i18n.d.ts +3 -0
- package/dist/react/icons.d.ts +20 -0
- package/dist/react/markdown.d.ts +11 -0
- package/dist/strings.d.ts +84 -0
- package/dist/style.d.ts +138 -0
- package/dist/view.d.ts +69 -0
- package/package.json +110 -4
- package/schema/graph.schema.json +54 -0
- package/schema/profile.schema.json +59 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Voidixyn
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,238 @@
|
|
|
1
|
-
#
|
|
1
|
+
# glassbrain
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
**Know what your agent knows.**
|
|
4
|
+
|
|
5
|
+
Your agent keeps knowledge graphs: of your code, your docs, its research, its own plans. glassbrain
|
|
6
|
+
lets you read one at a glance, and when the agent learns something, shows you exactly what changed.
|
|
7
|
+
|
|
8
|
+

|
|
9
|
+
|
|
10
|
+
```bash
|
|
11
|
+
npx glassbrain kg/ # open a graph in the browser (kg/ = JSON files, or one folder per version)
|
|
12
|
+
npx glassbrain diff HEAD~1 kg/ # what changed in the last commit
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
[**Live demo**](https://voidixyn.github.io/glassbrain/) · [Agents write it](#1-a-brain-your-agent-can-write) ·
|
|
16
|
+
[Humans read it](#2-read-it-like-a-brain-scan) · [Every brain](#3-every-brain-on-demand) ·
|
|
17
|
+
[Try it](#4-try-it-yourself) · [Docs](#docs)
|
|
18
|
+
|
|
19
|
+
---
|
|
20
|
+
|
|
21
|
+
## 1. A brain your agent can write
|
|
22
|
+
|
|
23
|
+
*Two arrays. No SDK.* An agent writes the format with no library and no API:
|
|
24
|
+
|
|
25
|
+
```json
|
|
26
|
+
{
|
|
27
|
+
"nodes": [
|
|
28
|
+
{ "id": "src", "label": "src", "kind": "folder" },
|
|
29
|
+
{ "id": "src/auth", "label": "auth", "kind": "folder", "parent": "src" },
|
|
30
|
+
{ "id": "src/auth/login.ts", "label": "login.ts", "kind": "file", "parent": "src/auth" },
|
|
31
|
+
{ "id": "src/db.ts", "label": "db.ts", "kind": "file", "parent": "src" }
|
|
32
|
+
],
|
|
33
|
+
"edges": [{ "source": "src/auth/login.ts", "target": "src/db.ts", "kind": "uses" }]
|
|
34
|
+
}
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
`parent` says what sits inside what; that is the whole structure. Everything else is an edge.
|
|
38
|
+
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
|
|
39
|
+
agent can act on:
|
|
40
|
+
|
|
41
|
+
```text
|
|
42
|
+
$ npx glassbrain validate kg
|
|
43
|
+
warn 2-filled/ Dangling edge: points to missing node src/session
|
|
44
|
+
|
|
45
|
+
kg: 2 versions, 3 nodes, 1 edge — 0 errors, 1 warning
|
|
46
|
+
|
|
47
|
+
$ npx glassbrain diff kg/1-skeleton kg/2-filled
|
|
48
|
+
1-skeleton → 2-filled
|
|
49
|
+
nodes: +0 −0 ~1 changed, 0 moved (2 unchanged)
|
|
50
|
+
edges: +1 −0 (0 unchanged)
|
|
51
|
+
|
|
52
|
+
changed (1)
|
|
53
|
+
~ login.ts [src/auth/login.ts] — description
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
Errors exit 1 (`--strict`: warnings too), `diff --exit-code` exits 1 when anything changed, and
|
|
57
|
+
`--json` gives the same as structured output. So an agent can build a graph in steps, validate
|
|
58
|
+
each one, and check that a step did only its job.
|
|
59
|
+
|
|
60
|
+
## 2. Read it like a brain scan
|
|
61
|
+
|
|
62
|
+
*Not a pretty viewer: the widest channel from an agent's memory to your head.* A few hundred
|
|
63
|
+
nodes hold more than any report an agent could write you, and a picture of them is read in
|
|
64
|
+
seconds: what is there, what sits inside what, what touches what. That only works if the picture
|
|
65
|
+
holds still.
|
|
66
|
+
|
|
67
|
+
Most graph viewers use a force layout: every edge pulls, so a few hundred
|
|
68
|
+
relations decide the whole picture, and one change reshuffles all of it. glassbrain takes the
|
|
69
|
+
shape from **containment** (folder ⊃ file ⊃ function, area ⊃ feature ⊃ step). Relations are
|
|
70
|
+
drawn on top and move nothing. So the picture reads like a map, keeps reading at thousands of
|
|
71
|
+
nodes, and **stays where it was** when the graph changes.
|
|
72
|
+
|
|
73
|
+
That makes change the main event:
|
|
74
|
+
|
|
75
|
+
- **Step through versions.** A folder of snapshots (`1-skeleton/`, `2-filled/`, …) opens with a
|
|
76
|
+
version bar. Each step is a short animated scene: what leaves is cut loose first, survivors
|
|
77
|
+
move, new things grow out of their parent.
|
|
78
|
+
- **Compare two.** Side by side, one shared set of coordinates: what did not change is on the
|
|
79
|
+
same pixel in both panes. Added, removed, changed and moved are marked, and a node that moved
|
|
80
|
+
to a new parent is a *move*, not a deletion plus an addition.
|
|
81
|
+
- **Against git.** `npx glassbrain diff main kg/` compares with any commit. The terminal gets a
|
|
82
|
+
summary, the browser gets the picture.
|
|
83
|
+
|
|
84
|
+

|
|
85
|
+
|
|
86
|
+
Search ranks by how well a node matches, the detail panel renders the node's markdown, labels
|
|
87
|
+
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)
|
|
88
|
+
from the light palette. Graphs with layers can be stood up in 2.5D:
|
|
89
|
+
|
|
90
|
+

|
|
91
|
+
|
|
92
|
+
## 3. Every brain, on demand
|
|
93
|
+
|
|
94
|
+
*The model already knows how. Codebase memory, docs knowledge bases, deep research, agent
|
|
95
|
+
plans: each is a short skill or a single prompt.*
|
|
96
|
+
|
|
97
|
+
glassbrain does not build graphs; your agent does. Because the format is two arrays and the CLI
|
|
98
|
+
checks every step, there is no extractor, pipeline or embedding store to build: the reach comes
|
|
99
|
+
from the model, not from machinery around it. Every dataset in the
|
|
100
|
+
[demo](https://voidixyn.github.io/glassbrain/) was made that way by Claude Sonnet 5.5, and each
|
|
101
|
+
has a `RUN.md` with the exact prompt and the token count.
|
|
102
|
+
|
|
103
|
+
| The need | What people use | With glassbrain | In the demo |
|
|
104
|
+
|---|---|---|---|
|
|
105
|
+
| **Codebase memory** | Graphify, Understand-Anything: a dedicated extractor per tool | [`kg-build`](https://github.com/voidixyn/glassbrain/blob/main/skills/kg-build/SKILL.md) (a 34-line skill) | [`flask`](https://github.com/voidixyn/glassbrain/blob/main/data/demo/flask/RUN.md), `glassbrain-src` |
|
|
106
|
+
| **Docs knowledge base** | chunk-and-embed RAG, or a custom pipeline | [`docs-to-kg`](https://github.com/voidixyn/glassbrain/blob/main/skills/docs-to-kg/SKILL.md) (a 94-line skill: two blind passes, merged) | [`boards`](https://github.com/voidixyn/glassbrain/blob/main/data/demo/boards/RUN.md) |
|
|
107
|
+
| **Deep research** | a Deep Research report: thousands of words, read once | a prompt of 80–100 words; the graph is the report, and the next run is a diff | [`agent-stack`](https://github.com/voidixyn/glassbrain/blob/main/data/demo/agent-stack/RUN.md), [`citations`](https://github.com/voidixyn/glassbrain/blob/main/data/demo/citations/RUN.md) |
|
|
108
|
+
| **Agent plans & explanations** | plan mode, a long spec in markdown | a prompt of 110–135 words: decisions tied to requirements, the self-review as a diff | [`agent-plan`](https://github.com/voidixyn/glassbrain/blob/main/data/demo/agent-plan/RUN.md), [`how-agents-work`](https://github.com/voidixyn/glassbrain/blob/main/data/demo/how-agents-work/RUN.md) |
|
|
109
|
+
| **Open what you have** | each tool's own viewer | the output of Graphify, Understand-Anything, an MCP memory server or an Obsidian vault, as it is | [`graphify-flask`](https://github.com/voidixyn/glassbrain/blob/main/data/demo/graphify-flask/RUN.md), [`mcp-wiki`](https://github.com/voidixyn/glassbrain/blob/main/data/demo/mcp-wiki/RUN.md) |
|
|
110
|
+
|
|
111
|
+
What that gets you, measured on the demo data:
|
|
112
|
+
|
|
113
|
+
- **Codebase.** On Flask's `src/flask`, `kg-build` gave 540 nodes (folder ⊃ module ⊃ class ⊃
|
|
114
|
+
method), every one with a description written from the code, and 751 typed edges (imports,
|
|
115
|
+
calls, extends, decorators, signals); 230k tokens. Graphify on the same folder: 892 nodes, none
|
|
116
|
+
described, 257 of them docstring fragments.
|
|
117
|
+
- **Docs.** `docs-to-kg` read 4ga Boards' docs and, separately, its UI code: 421 features found,
|
|
118
|
+
merged to 268 in 9 areas, each a user story with steps and expected results. 49 are missing
|
|
119
|
+
from the docs, 93 were found only in the docs, and 94 stories note where docs and app differ.
|
|
120
|
+
Two blind judges (Sonnet 5.5 and Opus 5.5, sets unlabeled and swapped) compared it with an
|
|
121
|
+
earlier multi-stage pipeline of ours on the same product: both picked it "overwhelmingly", and
|
|
122
|
+
23 of 24 sampled stories checked out against the source code, against 11 of 24.
|
|
123
|
+
- **Research.** From memory, then checked on the web: the agent-ecosystem graph grew from 130 to
|
|
124
|
+
166 nodes and 25 of the remembered facts were flagged `corrected`. Compare the two snapshots
|
|
125
|
+
and you are reading what the research changed, not a new report.
|
|
126
|
+
- **Plans.** The agent's plan for real-time collaboration has every decision linked to the
|
|
127
|
+
requirement it serves and every rejected alternative to the decision that beat it; its
|
|
128
|
+
self-review shows up as 8 nodes added, 1 decision demoted to rejected, 9 changed.
|
|
129
|
+
|
|
130
|
+
The skills, for any agent that reads `SKILL.md`:
|
|
131
|
+
|
|
132
|
+
| Skill | What the agent does with it |
|
|
133
|
+
|---|---|
|
|
134
|
+
| [`kg-build`](https://github.com/voidixyn/glassbrain/blob/main/skills/kg-build/SKILL.md) | Maps a codebase, docs or a website in three snapshots (skeleton → filled → linked), validating and diffing after each |
|
|
135
|
+
| [`docs-to-kg`](https://github.com/voidixyn/glassbrain/blob/main/skills/docs-to-kg/SKILL.md) | Turns docs plus the product into features as user stories: two independent passes, merged, written up, linked |
|
|
136
|
+
| [`kg-view`](https://github.com/voidixyn/glassbrain/blob/main/skills/kg-view/SKILL.md) | Finds a graph in the project, in any format below, and opens it |
|
|
137
|
+
| [`kg-diff`](https://github.com/voidixyn/glassbrain/blob/main/skills/kg-diff/SKILL.md) | Says what changed since a commit, in a few sentences, and shows it |
|
|
138
|
+
|
|
139
|
+
```bash
|
|
140
|
+
npx skills add voidixyn/glassbrain # the skills CLI (skills.sh); or copy skills/* into your agent's skills folder
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
Already have a graph from another tool? Open it as it is; the format is detected from the content.
|
|
144
|
+
|
|
145
|
+
| You have | Open it with |
|
|
146
|
+
|---|---|
|
|
147
|
+
| [Graphify](https://github.com/Graphify-Labs/graphify) `graphify-out/graph.json` | `npx glassbrain graphify-out/graph.json` |
|
|
148
|
+
| [Understand-Anything](https://github.com/Egonex-AI/Understand-Anything) `.ua/knowledge-graph.json` | `npx glassbrain .ua/knowledge-graph.json` |
|
|
149
|
+
| [MCP memory server](https://github.com/modelcontextprotocol/servers/tree/main/src/memory) `memory.jsonl` | `npx glassbrain path/to/memory.jsonl` |
|
|
150
|
+
| An Obsidian vault or an LLM wiki (markdown + `[[links]]`) | `npx glassbrain my-vault/` |
|
|
151
|
+
|
|
152
|
+
Each tool's own notion of "inside" becomes the structure; everything else becomes edges.
|
|
153
|
+
`npx glassbrain convert <path> <out>` writes any of them as plain glassbrain JSON
|
|
154
|
+
([formats](https://github.com/voidixyn/glassbrain/blob/main/docs/cli.md#formats)).
|
|
155
|
+
|
|
156
|
+
## 4. Try it yourself
|
|
157
|
+
|
|
158
|
+
*Light enough to try in a minute.* Nothing is hidden and nothing runs in the background:
|
|
159
|
+
|
|
160
|
+
- **One file out.** `npx glassbrain` writes a single html page (about 1 MB plus your data): no
|
|
161
|
+
server, no database, no requests of its own, opens from `file://`, can be sent to anyone.
|
|
162
|
+
(Images that node descriptions link to load from their URLs.)
|
|
163
|
+
- **Your data stays plain.** JSON files you can read, diff in git and edit by hand. Nothing
|
|
164
|
+
derived (flags, validation, layout) is ever written back into them.
|
|
165
|
+
- **No lock-in, no key.** Every supported format comes in, `convert` writes plain JSON out, and
|
|
166
|
+
everything runs locally.
|
|
167
|
+
|
|
168
|
+
**Three ways in:**
|
|
169
|
+
|
|
170
|
+
1. Open the [live demo](https://voidixyn.github.io/glassbrain/), or drop a folder of your own JSON onto it.
|
|
171
|
+
2. Point it at something you have: `npx glassbrain <file-or-folder>`.
|
|
172
|
+
3. Ask your agent, no skill needed:
|
|
173
|
+
|
|
174
|
+
> Map how our checkout flow works as a glassbrain graph (run `npx glassbrain` first).
|
|
175
|
+
|
|
176
|
+
`npx glassbrain` with no arguments prints the format and how to build in passes, so the
|
|
177
|
+
agent needs nothing else.
|
|
178
|
+
|
|
179
|
+
Or give it the skills above and write your own: a skill is a short markdown file.
|
|
180
|
+
|
|
181
|
+
**In your own app** it is a React component on top of [cytoscape.js](https://js.cytoscape.org/):
|
|
182
|
+
|
|
183
|
+
```bash
|
|
184
|
+
npm i glassbrain cytoscape cytoscape-fcose cytoscape-cose-bilkent
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
```tsx
|
|
188
|
+
import { parseSources, diffModels, GraphCanvas } from 'glassbrain';
|
|
189
|
+
|
|
190
|
+
const model = parseSources([{ origin: 'graph.json', text }]);
|
|
191
|
+
<GraphCanvas model={model} /> // browse
|
|
192
|
+
<GraphCanvas model={after} diff={diffModels(before, after)} /> // compare
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
Colors, layers, field names and your own JSON dialects go in a profile; the canvas can be made
|
|
196
|
+
editable and hands you each edit as a patch. All of it is in [the guide](https://github.com/voidixyn/glassbrain/blob/main/docs/guide.md).
|
|
197
|
+
|
|
198
|
+
How big it goes (the generated page in headless Chrome on an Apple M4 laptop, [method](https://github.com/voidixyn/glassbrain/blob/main/docs/cli.md#size)):
|
|
199
|
+
|
|
200
|
+
| Graph | Ready | Pan / zoom |
|
|
201
|
+
|---|---|---|
|
|
202
|
+
| 1,000 nodes | 1.1 s | 60 fps |
|
|
203
|
+
| 5,000 nodes | 4.7 s | 60 fps |
|
|
204
|
+
| 10,000 nodes | 9.7 s | 30 fps |
|
|
205
|
+
|
|
206
|
+
Beyond about 10,000 nodes, look at [sigma.js](https://www.sigmajs.org/).
|
|
207
|
+
|
|
208
|
+
## Questions
|
|
209
|
+
|
|
210
|
+
**Is this a graph database or a graph builder?** Neither. It is the screen: something else
|
|
211
|
+
(your agent, Graphify, a script) builds the graph; glassbrain shows it and its changes.
|
|
212
|
+
|
|
213
|
+
**How is it different from Graphify's or Understand-Anything's own viewer?** Those come with
|
|
214
|
+
their extractors. glassbrain opens their output too, and adds stable structure and version
|
|
215
|
+
comparison. Use both.
|
|
216
|
+
|
|
217
|
+
**Can I edit the graph by hand?** Yes, in your app (`onEdit`) or in the demo. Edits are a patch of
|
|
218
|
+
small operations, so they can be replayed after the agent regenerates the graph.
|
|
219
|
+
|
|
220
|
+
## Docs
|
|
221
|
+
|
|
222
|
+
- [Guide](https://github.com/voidixyn/glassbrain/blob/main/docs/guide.md): the library: profiles, colors, positions, theming, editing.
|
|
223
|
+
- [CLI](https://github.com/voidixyn/glassbrain/blob/main/docs/cli.md): the commands, the formats they read, and how size was measured.
|
|
224
|
+
- [Design](https://github.com/voidixyn/glassbrain/blob/main/docs/design.md): why it moves the way it does, for contributors and the curious.
|
|
225
|
+
|
|
226
|
+
## Develop
|
|
227
|
+
|
|
228
|
+
```bash
|
|
229
|
+
npm ci
|
|
230
|
+
npm run verify # typecheck, build, check the package, test
|
|
231
|
+
npm run demo:public # demo/dist/public.html, the page behind the live demo
|
|
232
|
+
```
|
|
233
|
+
|
|
234
|
+
See [CONTRIBUTING.md](https://github.com/voidixyn/glassbrain/blob/main/CONTRIBUTING.md). Security reports: [SECURITY.md](https://github.com/voidixyn/glassbrain/blob/main/SECURITY.md).
|
|
235
|
+
|
|
236
|
+
## License
|
|
237
|
+
|
|
238
|
+
[MIT](https://github.com/voidixyn/glassbrain/blob/main/LICENSE)
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
export interface InputFile {
|
|
2
|
+
path: string;
|
|
3
|
+
text: string;
|
|
4
|
+
}
|
|
5
|
+
export interface PhysicalNode {
|
|
6
|
+
id: string;
|
|
7
|
+
label: string;
|
|
8
|
+
kind?: string;
|
|
9
|
+
parent?: string;
|
|
10
|
+
[k: string]: unknown;
|
|
11
|
+
}
|
|
12
|
+
export interface PhysicalEdge {
|
|
13
|
+
source: string;
|
|
14
|
+
target: string;
|
|
15
|
+
kind?: string;
|
|
16
|
+
label?: string;
|
|
17
|
+
weight?: number;
|
|
18
|
+
[k: string]: unknown;
|
|
19
|
+
}
|
|
20
|
+
export interface PhysicalGraph {
|
|
21
|
+
name?: string;
|
|
22
|
+
nodes: PhysicalNode[];
|
|
23
|
+
edges: PhysicalEdge[];
|
|
24
|
+
}
|
|
25
|
+
/** Conversion result: one or several glassbrain graphs (origin is the source file's relative path), plus a profile. */
|
|
26
|
+
export interface Adapted {
|
|
27
|
+
sources: {
|
|
28
|
+
origin: string;
|
|
29
|
+
graph: PhysicalGraph;
|
|
30
|
+
}[];
|
|
31
|
+
profile: Record<string, unknown>;
|
|
32
|
+
}
|
|
33
|
+
export interface Adapter {
|
|
34
|
+
id: string;
|
|
35
|
+
/** A name for people (the CLI prints "read as X"). */
|
|
36
|
+
label: string;
|
|
37
|
+
/** Whether these files are its format. Looks only at the shape of the content, never the file name: people rename files. */
|
|
38
|
+
detect(files: InputFile[]): boolean;
|
|
39
|
+
convert(files: InputFile[]): Adapted;
|
|
40
|
+
}
|
|
41
|
+
export declare const tryJson: (text: string) => any;
|
|
42
|
+
export declare const isObj: (v: unknown) => v is Record<string, any>;
|
|
43
|
+
/** A set of hues, handed out in order of appearance to kinds whose names are not known in advance (memory's entityType, Obsidian's type). */
|
|
44
|
+
export declare const HUES: string[];
|
|
45
|
+
export declare const autoPalette: (kinds: Iterable<string>) => Record<string, string>;
|
|
46
|
+
/** Path → a chain of folder nodes (`dir:a`, `dir:a/b`); returns the innermost id; top-level files return undefined. */
|
|
47
|
+
export declare function folderOf(file: string, out: Map<string, PhysicalNode>): string | undefined;
|
|
48
|
+
/** Cycle guard when assigning parents: walk up the parent chain, and if it comes back to itself, reject this one. */
|
|
49
|
+
export declare function wouldCycle(parentOf: Map<string, string>, child: string, parent: string): boolean;
|
|
50
|
+
/** Remove undefined / empty strings so the output JSON is clean (and diff does not report "changed" over null vs missing). */
|
|
51
|
+
export declare const clean: <T extends Record<string, unknown>>(o: T) => T;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { type Adapter, type PhysicalEdge, type PhysicalNode } from './common.js';
|
|
2
|
+
export declare function convertGraphify(d: any, name?: string): {
|
|
3
|
+
name: string;
|
|
4
|
+
nodes: PhysicalNode[];
|
|
5
|
+
edges: PhysicalEdge[];
|
|
6
|
+
};
|
|
7
|
+
export declare const PROFILE: {
|
|
8
|
+
nodePalette: {
|
|
9
|
+
symbol: string;
|
|
10
|
+
concept: string;
|
|
11
|
+
rationale: string;
|
|
12
|
+
document: string;
|
|
13
|
+
paper: string;
|
|
14
|
+
image: string;
|
|
15
|
+
};
|
|
16
|
+
edgePalette: {
|
|
17
|
+
calls: string;
|
|
18
|
+
imports: string;
|
|
19
|
+
imports_from: string;
|
|
20
|
+
re_exports: string;
|
|
21
|
+
references: string;
|
|
22
|
+
extends: string;
|
|
23
|
+
inherits: string;
|
|
24
|
+
implements: string;
|
|
25
|
+
conceptually_related_to: string;
|
|
26
|
+
semantically_similar_to: string;
|
|
27
|
+
shares_data_with: string;
|
|
28
|
+
};
|
|
29
|
+
kindLabels: {
|
|
30
|
+
folder: string;
|
|
31
|
+
file: string;
|
|
32
|
+
symbol: string;
|
|
33
|
+
concept: string;
|
|
34
|
+
rationale: string;
|
|
35
|
+
document: string;
|
|
36
|
+
group: string;
|
|
37
|
+
calls: string;
|
|
38
|
+
imports: string;
|
|
39
|
+
imports_from: string;
|
|
40
|
+
references: string;
|
|
41
|
+
};
|
|
42
|
+
detail: {
|
|
43
|
+
line: {
|
|
44
|
+
key: string;
|
|
45
|
+
label: string;
|
|
46
|
+
}[];
|
|
47
|
+
};
|
|
48
|
+
rootLabel: string;
|
|
49
|
+
diffIgnore: string[];
|
|
50
|
+
};
|
|
51
|
+
export declare const graphify: Adapter;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { Adapter, InputFile } from './common.js';
|
|
2
|
+
export type { Adapted, Adapter, InputFile, PhysicalEdge, PhysicalGraph, PhysicalNode } from './common.js';
|
|
3
|
+
export { convertGraphify } from './graphify.js';
|
|
4
|
+
export { convertUnderstand } from './understand.js';
|
|
5
|
+
export { convertMemory } from './memory.js';
|
|
6
|
+
export { convertObsidian } from './obsidian.js';
|
|
7
|
+
export declare const ADAPTERS: Adapter[];
|
|
8
|
+
/** Markdown folders are their own tier: read as notes only when there is **no** json graph in them. */
|
|
9
|
+
export declare const MARKDOWN: Adapter;
|
|
10
|
+
export interface AdaptResult {
|
|
11
|
+
/** What goes to `parseSources`: origin + text (glassbrain's own `{nodes, edges}`). */
|
|
12
|
+
sources: {
|
|
13
|
+
origin: string;
|
|
14
|
+
text: string;
|
|
15
|
+
}[];
|
|
16
|
+
/** The profile the adapter suggests (same shape as `_profile.json`); null for native data. */
|
|
17
|
+
profile: Record<string, unknown> | null;
|
|
18
|
+
/** Which adapter was used; null for native data. */
|
|
19
|
+
adapter: Adapter | null;
|
|
20
|
+
/** Data files the chosen format does not read (one format decides the folder; say so instead of dropping them silently). */
|
|
21
|
+
skipped: string[];
|
|
22
|
+
}
|
|
23
|
+
/** A batch of files → sources glassbrain can parse directly. `only` names an adapter id ('native' = no conversion). */
|
|
24
|
+
export declare function adapt(files: InputFile[], only?: string): AdaptResult;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { type Adapter, type InputFile, type PhysicalEdge, type PhysicalNode } from './common.js';
|
|
2
|
+
export declare function convertObsidian(files: InputFile[]): {
|
|
3
|
+
origin: string;
|
|
4
|
+
graph: {
|
|
5
|
+
name: string;
|
|
6
|
+
nodes: (PhysicalNode | {
|
|
7
|
+
id: string;
|
|
8
|
+
label: string;
|
|
9
|
+
kind: string;
|
|
10
|
+
parent: string | undefined;
|
|
11
|
+
description: string | undefined;
|
|
12
|
+
path: string;
|
|
13
|
+
tags: string[] | undefined;
|
|
14
|
+
})[];
|
|
15
|
+
edges: PhysicalEdge[];
|
|
16
|
+
};
|
|
17
|
+
}[];
|
|
18
|
+
export declare const obsidian: Adapter;
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { type Adapter, type PhysicalEdge, type PhysicalNode } from './common.js';
|
|
2
|
+
export declare function convertUnderstand(d: any): {
|
|
3
|
+
name: string;
|
|
4
|
+
nodes: PhysicalNode[];
|
|
5
|
+
edges: PhysicalEdge[];
|
|
6
|
+
};
|
|
7
|
+
export declare const PROFILE: {
|
|
8
|
+
nodePalette: {
|
|
9
|
+
function: string;
|
|
10
|
+
class: string;
|
|
11
|
+
concept: string;
|
|
12
|
+
document: string;
|
|
13
|
+
config: string;
|
|
14
|
+
service: string;
|
|
15
|
+
table: string;
|
|
16
|
+
endpoint: string;
|
|
17
|
+
schema: string;
|
|
18
|
+
pipeline: string;
|
|
19
|
+
resource: string;
|
|
20
|
+
domain: string;
|
|
21
|
+
flow: string;
|
|
22
|
+
step: string;
|
|
23
|
+
article: string;
|
|
24
|
+
entity: string;
|
|
25
|
+
topic: string;
|
|
26
|
+
claim: string;
|
|
27
|
+
source: string;
|
|
28
|
+
screen: string;
|
|
29
|
+
component: string;
|
|
30
|
+
token: string;
|
|
31
|
+
};
|
|
32
|
+
edgePalette: {
|
|
33
|
+
imports: string;
|
|
34
|
+
exports: string;
|
|
35
|
+
calls: string;
|
|
36
|
+
depends_on: string;
|
|
37
|
+
tested_by: string;
|
|
38
|
+
inherits: string;
|
|
39
|
+
implements: string;
|
|
40
|
+
related: string;
|
|
41
|
+
similar_to: string;
|
|
42
|
+
documents: string;
|
|
43
|
+
reads_from: string;
|
|
44
|
+
writes_to: string;
|
|
45
|
+
cites: string;
|
|
46
|
+
contradicts: string;
|
|
47
|
+
builds_on: string;
|
|
48
|
+
};
|
|
49
|
+
kindLabels: {
|
|
50
|
+
layer: string;
|
|
51
|
+
folder: string;
|
|
52
|
+
file: string;
|
|
53
|
+
function: string;
|
|
54
|
+
class: string;
|
|
55
|
+
document: string;
|
|
56
|
+
config: string;
|
|
57
|
+
};
|
|
58
|
+
detail: {
|
|
59
|
+
line: {
|
|
60
|
+
key: string;
|
|
61
|
+
label: string;
|
|
62
|
+
}[];
|
|
63
|
+
list: {
|
|
64
|
+
key: string;
|
|
65
|
+
label: string;
|
|
66
|
+
}[];
|
|
67
|
+
};
|
|
68
|
+
rootLabel: string;
|
|
69
|
+
};
|
|
70
|
+
export declare const understand: Adapter;
|