mindgraph-core 0.1.0 → 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/README.md +119 -0
- package/package.json +5 -2
package/README.md
ADDED
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
# mindgraph-core
|
|
2
|
+
|
|
3
|
+
A local-first knowledge graph engine for Markdown notes. Extracts entities, concepts, beliefs, and contradictions, stores them in SQLite, and queries them with full-text and semantic search.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install mindgraph-core
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## What's included
|
|
12
|
+
|
|
13
|
+
- **Schema** — Typed graph primitives (entities, concepts, propositions, thoughts, beliefs) with provenance tracking
|
|
14
|
+
- **Storage** — `MemoryAdapter` for testing, `SqliteAdapter` (sql.js/WASM) with crash-safe atomic writes, FTS4, and auto-migrations
|
|
15
|
+
- **Ingestion** — Heading-aware Markdown chunker with stable content-hash IDs, plus `IngestionPipeline` to orchestrate chunk, extract, embed, store
|
|
16
|
+
- **Extraction** — `BasicExtractor` (regex/wiki-link/tag heuristics), `OllamaExtractor` (local LLM), `OpenAIExtractor`, `AnthropicExtractor`
|
|
17
|
+
- **Entity resolution** — Alias normalization and fast lookup via `EntityIndex`
|
|
18
|
+
- **Contradiction detection** — Finds conflicting claims across notes with topic-grounded filtering
|
|
19
|
+
- **Open loop detection** — Surfaces unresolved questions, TODOs, and uncertainties
|
|
20
|
+
- **Embeddings** — `TransformersEmbedder` (in-process ONNX/WASM) and `OllamaEmbedder`, with batch support
|
|
21
|
+
- **Query engine** — Full-text search, semantic search, belief queries, timeline, contradiction queries, graph traversal, and citation building
|
|
22
|
+
- **Export/import** — Full data portability in JSONL format
|
|
23
|
+
|
|
24
|
+
## Quick start
|
|
25
|
+
|
|
26
|
+
```typescript
|
|
27
|
+
import { MemoryAdapter, IngestionPipeline, BasicExtractor, QueryEngine } from 'mindgraph-core';
|
|
28
|
+
|
|
29
|
+
// Set up storage and extraction
|
|
30
|
+
const storage = new MemoryAdapter();
|
|
31
|
+
await storage.initialize();
|
|
32
|
+
|
|
33
|
+
const pipeline = new IngestionPipeline({ storage, extractor: new BasicExtractor() });
|
|
34
|
+
|
|
35
|
+
// Index a note
|
|
36
|
+
await pipeline.ingest({
|
|
37
|
+
notePath: 'notes/philosophy.md',
|
|
38
|
+
content: '# Stoicism\nMarcus Aurelius believed that virtue is the sole good.',
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
// Query the graph
|
|
42
|
+
const engine = new QueryEngine(storage);
|
|
43
|
+
const results = await engine.query({ query: 'Marcus Aurelius', mode: 'search' });
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
## Extraction tiers
|
|
47
|
+
|
|
48
|
+
| Tier | Provider | Setup |
|
|
49
|
+
|------|----------|-------|
|
|
50
|
+
| **Basic** (default) | `BasicExtractor` | None — regex + wiki-link + tag heuristics |
|
|
51
|
+
| **Ollama** | `OllamaExtractor` | Local LLM via [Ollama](https://ollama.com) |
|
|
52
|
+
| **OpenAI** | `OpenAIExtractor` | API key required |
|
|
53
|
+
| **Anthropic** | `AnthropicExtractor` | API key required |
|
|
54
|
+
|
|
55
|
+
## API overview
|
|
56
|
+
|
|
57
|
+
### Storage
|
|
58
|
+
|
|
59
|
+
```typescript
|
|
60
|
+
import { SqliteAdapter, MemoryAdapter } from 'mindgraph-core';
|
|
61
|
+
|
|
62
|
+
// SQLite (persistent, crash-safe)
|
|
63
|
+
const db = new SqliteAdapter('/path/to/graph.db');
|
|
64
|
+
await db.initialize();
|
|
65
|
+
|
|
66
|
+
// In-memory (for testing)
|
|
67
|
+
const mem = new MemoryAdapter();
|
|
68
|
+
await mem.initialize();
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
### Ingestion
|
|
72
|
+
|
|
73
|
+
```typescript
|
|
74
|
+
import { IngestionPipeline, BasicExtractor } from 'mindgraph-core';
|
|
75
|
+
|
|
76
|
+
const pipeline = new IngestionPipeline({ storage, extractor: new BasicExtractor() });
|
|
77
|
+
const stats = await pipeline.ingest({ notePath: 'note.md', content: '...' });
|
|
78
|
+
// stats: { entities: 3, concepts: 1, propositions: 2, chunks: 4 }
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
### Query
|
|
82
|
+
|
|
83
|
+
```typescript
|
|
84
|
+
import { QueryEngine } from 'mindgraph-core';
|
|
85
|
+
|
|
86
|
+
const engine = new QueryEngine(storage);
|
|
87
|
+
|
|
88
|
+
// Full-text search
|
|
89
|
+
const results = await engine.query({ query: 'stoicism', mode: 'search' });
|
|
90
|
+
|
|
91
|
+
// Belief query
|
|
92
|
+
const beliefs = await engine.query({ query: 'free will', mode: 'beliefs' });
|
|
93
|
+
|
|
94
|
+
// Contradictions
|
|
95
|
+
const contradictions = await engine.query({ query: 'ethics', mode: 'contradictions' });
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
### Export/Import
|
|
99
|
+
|
|
100
|
+
```typescript
|
|
101
|
+
import { GraphExporter, GraphImporter } from 'mindgraph-core';
|
|
102
|
+
|
|
103
|
+
// Export
|
|
104
|
+
const exporter = new GraphExporter(storage);
|
|
105
|
+
const jsonl = await exporter.export();
|
|
106
|
+
|
|
107
|
+
// Import with merge
|
|
108
|
+
const importer = new GraphImporter(storage);
|
|
109
|
+
const result = await importer.import(jsonl, { strategy: 'merge' });
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
## Requirements
|
|
113
|
+
|
|
114
|
+
- Node.js 18+
|
|
115
|
+
- ESM only (`"type": "module"`)
|
|
116
|
+
|
|
117
|
+
## License
|
|
118
|
+
|
|
119
|
+
MIT
|
package/package.json
CHANGED
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mindgraph-core",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.1",
|
|
4
|
+
"description": "Local-first knowledge graph engine for Markdown notes — extracts entities, concepts, beliefs, and contradictions",
|
|
5
|
+
"license": "MIT",
|
|
4
6
|
"type": "module",
|
|
5
7
|
"main": "dist/index.js",
|
|
6
8
|
"types": "dist/index.d.ts",
|
|
7
9
|
"files": [
|
|
8
|
-
"dist"
|
|
10
|
+
"dist",
|
|
11
|
+
"README.md"
|
|
9
12
|
],
|
|
10
13
|
"dependencies": {
|
|
11
14
|
"sql.js": "^1.11.0",
|