@andespindola/brainlink 0.1.0-alpha.0
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/AGENTS.md +142 -0
- package/CHANGELOG.md +13 -0
- package/CONTRIBUTING.md +28 -0
- package/LICENSE +23 -0
- package/README.md +715 -0
- package/SECURITY.md +35 -0
- package/dist/application/add-note.js +30 -0
- package/dist/application/analyze-vault.js +28 -0
- package/dist/application/build-context.js +15 -0
- package/dist/application/frontend/client-css.js +294 -0
- package/dist/application/frontend/client-html.js +66 -0
- package/dist/application/frontend/client-js.js +416 -0
- package/dist/application/get-graph-layout.js +3 -0
- package/dist/application/get-graph.js +12 -0
- package/dist/application/index-vault.js +67 -0
- package/dist/application/list-agents.js +12 -0
- package/dist/application/list-links.js +22 -0
- package/dist/application/search-knowledge.js +19 -0
- package/dist/application/server/host-security.js +6 -0
- package/dist/application/server/http.js +13 -0
- package/dist/application/server/routes.js +88 -0
- package/dist/application/server/types.js +1 -0
- package/dist/application/start-server.js +54 -0
- package/dist/application/watch-vault.js +36 -0
- package/dist/benchmarks/large-vault.js +88 -0
- package/dist/cli/commands/read-commands.js +149 -0
- package/dist/cli/commands/write-commands.js +107 -0
- package/dist/cli/main.js +21 -0
- package/dist/cli/runtime.js +18 -0
- package/dist/cli/types.js +1 -0
- package/dist/domain/agents.js +11 -0
- package/dist/domain/context.js +44 -0
- package/dist/domain/embeddings.js +117 -0
- package/dist/domain/graph-analysis.js +48 -0
- package/dist/domain/graph-layout.js +187 -0
- package/dist/domain/ids.js +2 -0
- package/dist/domain/markdown.js +100 -0
- package/dist/domain/note-safety.js +54 -0
- package/dist/domain/tokens.js +1 -0
- package/dist/domain/types.js +1 -0
- package/dist/infrastructure/config.js +60 -0
- package/dist/infrastructure/file-system-vault.js +62 -0
- package/dist/infrastructure/sqlite/document-writer.js +50 -0
- package/dist/infrastructure/sqlite/graph-reader.js +108 -0
- package/dist/infrastructure/sqlite/schema.js +87 -0
- package/dist/infrastructure/sqlite/search-reader.js +156 -0
- package/dist/infrastructure/sqlite/types.js +1 -0
- package/dist/infrastructure/sqlite-index.js +20 -0
- package/docs/AGENT_USAGE.md +477 -0
- package/docs/ARCHITECTURE.md +286 -0
- package/docs/RELEASE.md +67 -0
- package/package.json +67 -0
package/AGENTS.md
ADDED
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
# Brainlink Agent Guide
|
|
2
|
+
|
|
3
|
+
This file tells coding agents and AI assistants how to use this repository.
|
|
4
|
+
|
|
5
|
+
## Project Purpose
|
|
6
|
+
|
|
7
|
+
Brainlink is a local-first knowledge memory for agents.
|
|
8
|
+
|
|
9
|
+
It reads a Markdown vault, extracts `[[wiki links]]` and `#tags`, builds a local SQLite full-text index, and returns compact context packages that agents can inject into prompts.
|
|
10
|
+
|
|
11
|
+
## Source Of Truth
|
|
12
|
+
|
|
13
|
+
Markdown files are the source of truth.
|
|
14
|
+
|
|
15
|
+
The SQLite database at `.brainlink/brainlink.db` is a derived index. It can be deleted and rebuilt with:
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
npm run dev -- index --vault ./vault
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
Do not store permanent knowledge only in SQLite.
|
|
22
|
+
|
|
23
|
+
## Agent Workflow
|
|
24
|
+
|
|
25
|
+
Use this loop when using Brainlink as memory:
|
|
26
|
+
|
|
27
|
+
1. Write durable knowledge into Markdown notes.
|
|
28
|
+
2. Link related notes with `[[Note Title]]`.
|
|
29
|
+
3. Add explicit `#tags` for retrieval.
|
|
30
|
+
4. Run `index` after writes.
|
|
31
|
+
5. Run `context "<task or question>"` before answering.
|
|
32
|
+
6. Use the returned sources as grounded context.
|
|
33
|
+
|
|
34
|
+
## Commands
|
|
35
|
+
|
|
36
|
+
```bash
|
|
37
|
+
npm install
|
|
38
|
+
npm run build
|
|
39
|
+
npm run test
|
|
40
|
+
npm run check
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
Create and query a vault:
|
|
44
|
+
|
|
45
|
+
```bash
|
|
46
|
+
npm run dev -- init ./vault
|
|
47
|
+
npm run dev -- add "Architecture" --vault ./vault --content "Markdown is the source of truth. #architecture"
|
|
48
|
+
npm run dev -- index --vault ./vault
|
|
49
|
+
npm run dev -- context "what architecture decisions exist?" --vault ./vault
|
|
50
|
+
npm run dev -- context "what architecture decisions exist?" --vault ./vault --json
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
Inspect graph relationships:
|
|
54
|
+
|
|
55
|
+
```bash
|
|
56
|
+
npm run dev -- links --vault ./vault
|
|
57
|
+
npm run dev -- backlinks "Architecture" --vault ./vault
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
Start the local graph UI:
|
|
61
|
+
|
|
62
|
+
```bash
|
|
63
|
+
npm run dev -- server --vault ./vault --port 4321
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
The server reindexes by default and exposes:
|
|
67
|
+
|
|
68
|
+
```txt
|
|
69
|
+
http://127.0.0.1:4321/
|
|
70
|
+
http://127.0.0.1:4321/api/graph
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
Use watch mode while editing notes:
|
|
74
|
+
|
|
75
|
+
```bash
|
|
76
|
+
npm run dev -- server --vault ./vault --watch
|
|
77
|
+
npm run dev -- watch --vault ./vault
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
Start MCP over stdio:
|
|
81
|
+
|
|
82
|
+
```bash
|
|
83
|
+
npm run dev -- mcp
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
Automation-facing CLI commands support `--json`. When invoking through `npm`, use `npm run --silent dev -- ...` so stdout remains valid JSON.
|
|
87
|
+
|
|
88
|
+
Vault health commands:
|
|
89
|
+
|
|
90
|
+
```bash
|
|
91
|
+
npm run dev -- stats --vault ./vault
|
|
92
|
+
npm run dev -- broken-links --vault ./vault
|
|
93
|
+
npm run dev -- orphans --vault ./vault
|
|
94
|
+
npm run dev -- validate --vault ./vault
|
|
95
|
+
npm run dev -- doctor --vault ./vault
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
## Implementation Boundaries
|
|
99
|
+
|
|
100
|
+
- Keep domain rules in `src/domain`.
|
|
101
|
+
- Keep use cases in `src/application`.
|
|
102
|
+
- Keep filesystem and SQLite details in `src/infrastructure`.
|
|
103
|
+
- Keep CLI concerns in `src/cli`.
|
|
104
|
+
- Prefer pure functions for parsing, ranking, formatting, and transformation.
|
|
105
|
+
- Do not make SQLite the canonical storage layer.
|
|
106
|
+
- Do not add comments with emojis.
|
|
107
|
+
- Keep JSON output backwards compatible where possible.
|
|
108
|
+
|
|
109
|
+
## Expected Context Output
|
|
110
|
+
|
|
111
|
+
The `context` command returns Markdown:
|
|
112
|
+
|
|
113
|
+
```md
|
|
114
|
+
# Brainlink Context
|
|
115
|
+
Query: user question
|
|
116
|
+
|
|
117
|
+
## 1. Note Title
|
|
118
|
+
Source: note.md
|
|
119
|
+
Tags: #tag
|
|
120
|
+
Score: 0.000
|
|
121
|
+
|
|
122
|
+
Relevant chunk content
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
Agents should treat `Source` as citation metadata and preserve it when reasoning about project memory.
|
|
126
|
+
|
|
127
|
+
## Verification Before Handoff
|
|
128
|
+
|
|
129
|
+
Run:
|
|
130
|
+
|
|
131
|
+
```bash
|
|
132
|
+
npm run check
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
For CLI behavior, also run a smoke flow with a temporary vault:
|
|
136
|
+
|
|
137
|
+
```bash
|
|
138
|
+
npm run dev -- init .tmp-vault
|
|
139
|
+
npm run dev -- add "Architecture" --vault .tmp-vault --content "Markdown source of truth. #architecture"
|
|
140
|
+
npm run dev -- index --vault .tmp-vault
|
|
141
|
+
npm run dev -- context "architecture" --vault .tmp-vault
|
|
142
|
+
```
|
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## 0.1.0-alpha.0
|
|
4
|
+
|
|
5
|
+
- Added local-first Markdown vault indexing.
|
|
6
|
+
- Added SQLite FTS, local semantic retrieval, wiki links, backlinks and graph retrieval.
|
|
7
|
+
- Added SQLite semantic bucket indexing to narrow vector candidates for larger vaults.
|
|
8
|
+
- Optimized title/link resolution with precomputed agent-scoped title maps.
|
|
9
|
+
- Added CLI, JSON output, HTTP API and graph UI.
|
|
10
|
+
- Added vault diagnostics: stats, broken links, orphans, validation and doctor.
|
|
11
|
+
- Added agent namespaces under `agents/<agent-id>/`.
|
|
12
|
+
- Added external MCP integration guidance through CLI subprocess wrappers.
|
|
13
|
+
- Added large vault benchmark command and graph layout stress coverage.
|
package/CONTRIBUTING.md
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
# Contributing
|
|
2
|
+
|
|
3
|
+
## Development
|
|
4
|
+
|
|
5
|
+
```bash
|
|
6
|
+
npm install
|
|
7
|
+
npm run check
|
|
8
|
+
```
|
|
9
|
+
|
|
10
|
+
## Local CLI
|
|
11
|
+
|
|
12
|
+
```bash
|
|
13
|
+
npm run dev -- --help
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
## Package Smoke Test
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
npm run pack:smoke
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
## Design Rules
|
|
23
|
+
|
|
24
|
+
- Markdown files are the source of truth.
|
|
25
|
+
- SQLite is a derived index and must remain rebuildable.
|
|
26
|
+
- Domain parsing, graph analysis and layout should stay pure and testable.
|
|
27
|
+
- CLI, HTTP, filesystem and SQLite code are adapters around application use cases.
|
|
28
|
+
- MCP integration should live outside this package by wrapping the CLI with `--json`.
|
package/LICENSE
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
SPDX-License-Identifier: MIT
|
|
2
|
+
|
|
3
|
+
MIT License
|
|
4
|
+
|
|
5
|
+
Copyright (c) 2026 Anderson Espindola
|
|
6
|
+
|
|
7
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
8
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
9
|
+
in the Software without restriction, including without limitation the rights
|
|
10
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
11
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
12
|
+
furnished to do so, subject to the following conditions:
|
|
13
|
+
|
|
14
|
+
The above copyright notice and this permission notice shall be included in all
|
|
15
|
+
copies or substantial portions of the Software.
|
|
16
|
+
|
|
17
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
18
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
19
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
20
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
21
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
22
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
23
|
+
SOFTWARE.
|