ex-brain 0.1.0 → 0.2.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/README.md +87 -37
- package/package.json +6 -5
- package/src/ai/compiler.ts +494 -0
- package/src/ai/embed-factory.ts +116 -0
- package/src/ai/entity-link.ts +195 -0
- package/src/ai/hash-embed.ts +30 -0
- package/src/ai/llm-client.ts +291 -0
- package/src/ai/timeline-extractor.ts +403 -0
- package/src/cli.ts +16 -0
- package/src/commands/compile-cmd.ts +208 -0
- package/src/commands/graph-cmd.ts +1070 -0
- package/src/commands/index.ts +1973 -0
- package/src/config.ts +80 -0
- package/src/db/client.ts +207 -0
- package/src/db/errors.ts +178 -0
- package/src/db/schema.ts +50 -0
- package/src/markdown/io.ts +61 -0
- package/src/markdown/parser.ts +72 -0
- package/src/mcp/server.ts +703 -0
- package/src/repositories/brain-repo.ts +990 -0
- package/src/settings.ts +235 -0
- package/src/types/index.ts +56 -0
- package/src/utils/cli-output.ts +569 -0
- package/src/utils/progress.ts +171 -0
- package/src/utils/query-sanitizer.ts +63 -0
- package/dist/cli.js +0 -93543
package/README.md
CHANGED
|
@@ -1,95 +1,145 @@
|
|
|
1
1
|
# ex-brain
|
|
2
2
|
|
|
3
|
-
CLI
|
|
3
|
+
CLI personal knowledge base built on [seekdb](https://docs.seekdb.ai/), featuring page management, hybrid search, timelines, tags, import/export, and MCP Server.
|
|
4
4
|
|
|
5
|
-
##
|
|
5
|
+
## Core Features
|
|
6
6
|
|
|
7
|
-
-
|
|
8
|
-
-
|
|
9
|
-
-
|
|
10
|
-
-
|
|
11
|
-
-
|
|
7
|
+
- **Knowledge Graph Visualization** - Interactive graph showing entity relationships
|
|
8
|
+
- **Intelligent Compilation** - Semantic analysis with smart Compiled Truth updates
|
|
9
|
+
- **Timeline Management** - Automatic event extraction and history tracking
|
|
10
|
+
- **Hybrid Search** - Full-text search + vector semantic queries
|
|
11
|
+
- **Entity Linking** - Auto-detect entities and create linked pages
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
<img src="https://mdn.alipayobjects.com/huamei_ytl0i7/afts/img/A*TqdfTZ-yCPwAAAAAgBAAAAgAejCYAQ/original" width="800">
|
|
14
14
|
|
|
15
|
-
|
|
15
|
+
## Data Collection
|
|
16
16
|
|
|
17
|
-
|
|
18
|
-
- 支持代码块、表格、数学公式
|
|
19
|
-
- 本地处理,隐私友好
|
|
20
|
-
- 支持 Obsidian 集成
|
|
17
|
+
We recommend [MarkSnip](https://chromewebstore.google.com/detail/kcbaglhfgbkjdnpeokaamjjkddempipm) for data collection:
|
|
21
18
|
|
|
22
|
-
|
|
19
|
+
- One-click web clipping to Markdown format
|
|
20
|
+
- Supports code blocks, tables, math formulas
|
|
21
|
+
- Local processing, privacy-friendly
|
|
22
|
+
- Obsidian integration support
|
|
23
|
+
|
|
24
|
+
Use with ex-brain:
|
|
23
25
|
|
|
24
26
|
```bash
|
|
25
|
-
# MarkSnip
|
|
27
|
+
# After clipping with MarkSnip, import to knowledge base
|
|
26
28
|
cat article.md | ebrain put articles/slug --stdin
|
|
27
29
|
|
|
28
|
-
#
|
|
30
|
+
# Or intelligent compilation
|
|
29
31
|
ebrain compile companies/river-ai --file article.md --source web_clip
|
|
30
32
|
```
|
|
31
33
|
|
|
32
|
-
##
|
|
34
|
+
## Installation
|
|
33
35
|
|
|
34
36
|
```bash
|
|
35
|
-
#
|
|
37
|
+
# Global installation (requires Bun or Node.js)
|
|
36
38
|
bun install -g ex-brain
|
|
37
|
-
#
|
|
39
|
+
# or
|
|
38
40
|
npm install -g ex-brain
|
|
39
41
|
|
|
40
42
|
ebrain --help
|
|
41
43
|
```
|
|
42
44
|
|
|
43
|
-
##
|
|
45
|
+
## Quick Start
|
|
44
46
|
|
|
45
47
|
```bash
|
|
46
|
-
#
|
|
48
|
+
# Initialize (creates ~/.ebrain/data/ebrain.db automatically)
|
|
47
49
|
ebrain init
|
|
48
50
|
|
|
49
|
-
#
|
|
51
|
+
# Write a page
|
|
50
52
|
ebrain put my/note --file note.md
|
|
51
53
|
|
|
52
|
-
#
|
|
53
|
-
ebrain graph #
|
|
54
|
-
ebrain graph --port 8080 --open #
|
|
54
|
+
# Knowledge graph visualization
|
|
55
|
+
ebrain graph # Start graph Web UI (http://localhost:3000)
|
|
56
|
+
ebrain graph --port 8080 --open # Custom port and auto-open browser
|
|
55
57
|
|
|
56
|
-
#
|
|
58
|
+
# Intelligently compile new information
|
|
57
59
|
ebrain compile companies/river-ai "River AI completed Series A funding" --source meeting_notes
|
|
58
60
|
|
|
59
|
-
#
|
|
61
|
+
# Extract timeline events from a page
|
|
60
62
|
ebrain timeline extract companies/river-ai
|
|
61
63
|
|
|
62
|
-
#
|
|
63
|
-
ebrain search "
|
|
64
|
-
ebrain query "
|
|
64
|
+
# Search
|
|
65
|
+
ebrain search "some topic"
|
|
66
|
+
ebrain query "some question"
|
|
67
|
+
|
|
68
|
+
# AI-powered Q&A with LLM (RAG)
|
|
69
|
+
ebrain query --llm "What is the main idea of River AI's product?"
|
|
70
|
+
ebrain query --llm "What are Mario Zechner's main views on game development?"
|
|
71
|
+
|
|
72
|
+
# Smart ingest: compile + timeline + entity links in one command
|
|
73
|
+
ebrain smart-ingest companies/river-ai --file article.md
|
|
65
74
|
|
|
66
|
-
#
|
|
75
|
+
# Start MCP Server (for AI tool integration)
|
|
67
76
|
ebrain serve
|
|
68
77
|
```
|
|
69
78
|
|
|
70
|
-
##
|
|
79
|
+
## Configuration
|
|
71
80
|
|
|
72
|
-
|
|
81
|
+
Edit `~/.ebrain/settings.json`:
|
|
73
82
|
|
|
74
83
|
```jsonc
|
|
75
84
|
{
|
|
76
85
|
"db": { "path": "~/.ebrain/data/ebrain.db" },
|
|
77
86
|
"embed": {
|
|
78
|
-
"provider": "hash", //
|
|
87
|
+
"provider": "hash", // or "openai_compatible"
|
|
79
88
|
"baseURL": "...",
|
|
80
89
|
"model": "...",
|
|
81
90
|
"dimensions": 1024,
|
|
82
91
|
"apiKey": "sk-..."
|
|
92
|
+
},
|
|
93
|
+
"llm": {
|
|
94
|
+
"baseURL": "https://dashscope.aliyuncs.com/compatible-mode/v1",
|
|
95
|
+
"model": "qwen-plus",
|
|
96
|
+
"apiKey": "sk-..."
|
|
97
|
+
},
|
|
98
|
+
"extraction": {
|
|
99
|
+
"confidenceThreshold": 0.7 // Entity extraction confidence (0~1)
|
|
83
100
|
}
|
|
84
101
|
}
|
|
85
102
|
```
|
|
86
103
|
|
|
87
|
-
|
|
104
|
+
Run `ebrain config` to view active configuration. See [docs/ebrain-cli.md](docs/ebrain-cli.md) for details.
|
|
105
|
+
|
|
106
|
+
## AI Q&A (RAG)
|
|
107
|
+
|
|
108
|
+
Ask natural language questions and get answers based on your knowledge base:
|
|
109
|
+
|
|
110
|
+
```bash
|
|
111
|
+
# Basic Q&A
|
|
112
|
+
ex-brain query --llm "What is the main idea of River AI's product?"
|
|
113
|
+
|
|
114
|
+
# Control context depth
|
|
115
|
+
ebrain query --llm "What happened in Q4?" --context-limit 3
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
How it works:
|
|
119
|
+
|
|
120
|
+
1. **Semantic Search** — Finds top matching pages for your question
|
|
121
|
+
2. **Multi-Layer Context Collection** — Builds rich context from:
|
|
122
|
+
- **Page Content** — Compiled truth + timeline for each matched page
|
|
123
|
+
- **Raw Documents** — Original imported documents (via `raw set`)
|
|
124
|
+
- **Linked Pages** — Incoming and outgoing linked pages, filtered by semantic relevance to the question
|
|
125
|
+
3. **LLM Synthesis** — Generates a sourced answer with `[[slug|title]]` citations
|
|
126
|
+
|
|
127
|
+
Configure LLM in `~/.ebrain/settings.json`:
|
|
128
|
+
|
|
129
|
+
```json
|
|
130
|
+
{
|
|
131
|
+
"llm": {
|
|
132
|
+
"baseURL": "https://dashscope.aliyuncs.com/compatible-mode/v1",
|
|
133
|
+
"model": "qwen-plus",
|
|
134
|
+
"apiKey": "sk-..."
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
```
|
|
88
138
|
|
|
89
|
-
##
|
|
139
|
+
## Development
|
|
90
140
|
|
|
91
141
|
```bash
|
|
92
142
|
bun install
|
|
93
143
|
bun run src/cli.ts --help
|
|
94
144
|
bun test
|
|
95
|
-
```
|
|
145
|
+
```
|
package/package.json
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ex-brain",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "CLI personal knowledge base powered by seekdb",
|
|
5
|
-
"
|
|
5
|
+
"module": "src/cli.ts",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"bin": {
|
|
8
|
-
"ebrain": "
|
|
8
|
+
"ebrain": "src/cli.ts"
|
|
9
9
|
},
|
|
10
10
|
"files": [
|
|
11
|
-
"
|
|
12
|
-
"
|
|
11
|
+
"src",
|
|
12
|
+
"!src/**/*.test.ts"
|
|
13
13
|
],
|
|
14
14
|
"scripts": {
|
|
15
15
|
"dev": "bun run src/cli.ts",
|
|
@@ -29,6 +29,7 @@
|
|
|
29
29
|
"@seekdb/openai": "1.2.0",
|
|
30
30
|
"commander": "^14.0.3",
|
|
31
31
|
"gray-matter": "^4.0.3",
|
|
32
|
+
"jsonrepair": "^3.13.3",
|
|
32
33
|
"pinyin-pro": "^3.28.0",
|
|
33
34
|
"seekdb": "^1.2.0",
|
|
34
35
|
"yaml": "^2.8.3",
|