mindlore 0.0.1 → 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/LICENSE +21 -21
- package/README.md +61 -4
- package/SCHEMA.md +71 -12
- package/hooks/lib/mindlore-common.cjs +106 -0
- package/hooks/mindlore-decision-detector.cjs +51 -0
- package/hooks/mindlore-fts5-sync.cjs +13 -24
- package/hooks/mindlore-index.cjs +11 -27
- package/hooks/mindlore-post-compact.cjs +2 -2
- package/hooks/mindlore-pre-compact.cjs +1 -1
- package/hooks/mindlore-read-guard.cjs +62 -0
- package/hooks/mindlore-search.cjs +94 -76
- package/hooks/mindlore-session-end.cjs +74 -8
- package/hooks/mindlore-session-focus.cjs +2 -2
- package/package.json +1 -1
- package/plugin.json +26 -2
- package/scripts/init.cjs +126 -13
- package/scripts/mindlore-fts5-index.cjs +7 -10
- package/scripts/mindlore-fts5-search.cjs +3 -6
- package/scripts/mindlore-health-check.cjs +98 -29
- package/scripts/uninstall.cjs +186 -0
- package/skills/mindlore-decide/SKILL.md +71 -0
- package/skills/mindlore-ingest/SKILL.md +13 -2
- package/skills/mindlore-log/SKILL.md +79 -0
- package/skills/mindlore-query/SKILL.md +125 -0
- package/templates/SCHEMA.md +280 -0
|
@@ -0,0 +1,280 @@
|
|
|
1
|
+
# Mindlore Schema
|
|
2
|
+
|
|
3
|
+
This file is the single source of truth for how the `.mindlore/` knowledge base works.
|
|
4
|
+
It is written for LLM agents — not humans. Every rule here must be followed exactly.
|
|
5
|
+
|
|
6
|
+
## 1. Identity
|
|
7
|
+
|
|
8
|
+
Mindlore is an AI-native knowledge system. It stores, indexes, and evolves knowledge
|
|
9
|
+
across Claude Code sessions. Knowledge lives in `.mindlore/` as plain Markdown files
|
|
10
|
+
with YAML frontmatter. Search is powered by FTS5 (SQLite full-text search).
|
|
11
|
+
|
|
12
|
+
## 2. Directory Structure
|
|
13
|
+
|
|
14
|
+
```
|
|
15
|
+
.mindlore/
|
|
16
|
+
├── raw/ # Immutable source captures (URL dumps, pasted text)
|
|
17
|
+
├── sources/ # Processed source summaries (one per ingested source)
|
|
18
|
+
├── domains/ # Topic wiki pages (entities + concepts)
|
|
19
|
+
├── analyses/ # Large syntheses (200+ lines, 3+ sources)
|
|
20
|
+
├── insights/ # Short Q&A writebacks (<200 lines, 1-2 sources)
|
|
21
|
+
├── connections/ # Cross-cutting links between 2+ sources
|
|
22
|
+
├── learnings/ # Persistent rules extracted from reflect (topic-based)
|
|
23
|
+
├── diary/ # Session logs, delta files (delta-YYYY-MM-DD-HHmm.md)
|
|
24
|
+
├── decisions/ # Decision records with context and rationale
|
|
25
|
+
├── INDEX.md # Minimal navigation map (~15-20 lines, fixed size)
|
|
26
|
+
├── SCHEMA.md # This file (copied from repo template)
|
|
27
|
+
├── log.md # Operation log (append-only)
|
|
28
|
+
└── mindlore.db # FTS5 search database (SQLite)
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
### Directory Rules
|
|
32
|
+
|
|
33
|
+
- Each directory corresponds to exactly one frontmatter `type` value
|
|
34
|
+
- `type: raw` → `raw/`, `type: source` → `sources/`, etc.
|
|
35
|
+
- Files MUST live in the directory matching their `type`
|
|
36
|
+
- The health check script validates this cross-reference
|
|
37
|
+
|
|
38
|
+
## 3. Frontmatter
|
|
39
|
+
|
|
40
|
+
Every `.md` file in `.mindlore/` MUST have YAML frontmatter. Format:
|
|
41
|
+
|
|
42
|
+
```yaml
|
|
43
|
+
---
|
|
44
|
+
slug: kebab-case-unique-identifier
|
|
45
|
+
type: raw|source|domain|analysis|insight|connection|learning|decision|diary
|
|
46
|
+
title: Human-readable title
|
|
47
|
+
tags: [tag1, tag2]
|
|
48
|
+
---
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
### Required Fields (all types)
|
|
52
|
+
|
|
53
|
+
| Field | Format | Rule |
|
|
54
|
+
|-------|--------|------|
|
|
55
|
+
| `slug` | kebab-case | Unique within directory. Used as filename: `{slug}.md` |
|
|
56
|
+
| `type` | enum | Must match the parent directory (see Section 2) |
|
|
57
|
+
|
|
58
|
+
### Type-Specific Fields
|
|
59
|
+
|
|
60
|
+
| Type | Required Fields | Optional |
|
|
61
|
+
|------|----------------|----------|
|
|
62
|
+
| `raw` | slug, type, source_url | tags, description |
|
|
63
|
+
| `source` | slug, type, title, tags, quality, source_url, ingested | date_captured, description, raw_slug |
|
|
64
|
+
| `domain` | slug, type, title, tags | description, status |
|
|
65
|
+
| `analysis` | slug, type, title, tags, confidence, sources_used | description |
|
|
66
|
+
| `insight` | slug, type, title, tags | sources_used, description |
|
|
67
|
+
| `connection` | slug, type, title, tags | sources_used, description |
|
|
68
|
+
| `learning` | slug, type, title, tags | description |
|
|
69
|
+
| `decision` | slug, type, title, tags | supersedes, status, description |
|
|
70
|
+
| `diary` | slug, type, date | — (hook adds automatically) |
|
|
71
|
+
|
|
72
|
+
### Field Value Rules
|
|
73
|
+
|
|
74
|
+
- `quality`: `high` | `medium` | `low`
|
|
75
|
+
- `confidence`: `high` | `medium` | `low` (how certain is this analysis)
|
|
76
|
+
- `ingested`: `true` | `false` (has this source been processed into domains)
|
|
77
|
+
- `sources_used`: list of slugs referenced in the analysis
|
|
78
|
+
- `supersedes`: slug of the decision this one replaces
|
|
79
|
+
- `date`: ISO 8601 date (YYYY-MM-DD)
|
|
80
|
+
- `description`: one-line summary (15-30 words). Used in FTS5 search and inject output. Optional but strongly recommended for search quality
|
|
81
|
+
- `raw_slug`: slug of the raw/ file this source was processed from (source→raw traceability)
|
|
82
|
+
- `status`: `stub` | `active` | `archived` (domain maturity indicator)
|
|
83
|
+
|
|
84
|
+
## 4. Seven Operations
|
|
85
|
+
|
|
86
|
+
### 4.1 Ingest (skill: /mindlore-ingest)
|
|
87
|
+
|
|
88
|
+
Add new knowledge. Flow: capture → raw/ → process → sources/ → update domains/ → FTS5.
|
|
89
|
+
|
|
90
|
+
- URL mode: markitdown CLI (if available) or WebFetch → raw/ → Sonnet summarizes → sources/
|
|
91
|
+
- Text mode: user paste → raw/ → summarize → sources/
|
|
92
|
+
- PDF mode: CC Read tool (max 20 pages/request) → raw/ → summarize → sources/
|
|
93
|
+
- **markitdown is NOT used for PDF** — quality is poor. Use CC Read tool or Marker/Chandra (v0.3+)
|
|
94
|
+
|
|
95
|
+
### 4.2 Query (skill: /mindlore-query, v0.2 — PLANNED, not yet implemented)
|
|
96
|
+
|
|
97
|
+
Search and retrieve knowledge. Four modes:
|
|
98
|
+
- `search`: FTS5 keyword search, return top 3 matches with snippets
|
|
99
|
+
- `ask`: Natural language question → FTS5 → read relevant files → synthesize answer
|
|
100
|
+
- `stats`: Knowledge base statistics (counts by type, recent activity)
|
|
101
|
+
- `brief`: Quick context on a topic (read domain page if exists)
|
|
102
|
+
|
|
103
|
+
### 4.3 Health (skill: /mindlore-health)
|
|
104
|
+
|
|
105
|
+
Run 16-point structural check:
|
|
106
|
+
- 9 directory existence checks
|
|
107
|
+
- SCHEMA.md parse validation
|
|
108
|
+
- INDEX.md format check (~15-20 lines)
|
|
109
|
+
- mindlore.db FTS5 integrity
|
|
110
|
+
- Orphan file detection (files not in FTS5)
|
|
111
|
+
- Frontmatter validation (type-directory cross-reference)
|
|
112
|
+
|
|
113
|
+
### 4.4 Log (skill: /mindlore-log, v0.2 — PLANNED, not yet implemented)
|
|
114
|
+
|
|
115
|
+
Session logging with four modes:
|
|
116
|
+
- `log`: Write session/task record to diary/
|
|
117
|
+
- `reflect`: Scan old deltas, extract patterns, move to learnings/
|
|
118
|
+
- `status`: Recent N sessions summary, trends, open items
|
|
119
|
+
- `save`: Structured delta + log.md append + wiki update
|
|
120
|
+
|
|
121
|
+
### 4.5 Decide (skill: /mindlore-decide, v0.2 — PLANNED, not yet implemented)
|
|
122
|
+
|
|
123
|
+
Record decisions with context, options considered, rationale, and outcome.
|
|
124
|
+
Supports `supersedes` chain for decision evolution.
|
|
125
|
+
|
|
126
|
+
### 4.6 Evolve (skill: /mindlore-evolve, v0.3 — PLANNED, not yet implemented)
|
|
127
|
+
|
|
128
|
+
Schema co-evolution. Scan domains + sources, suggest structural updates.
|
|
129
|
+
Run monthly or after major changes.
|
|
130
|
+
|
|
131
|
+
### 4.7 Explore (skill: /mindlore-explore, v0.3 — PLANNED, not yet implemented)
|
|
132
|
+
|
|
133
|
+
Discover unexpected connections between sources. Cross-reference analysis.
|
|
134
|
+
|
|
135
|
+
## 5. Search Behavior
|
|
136
|
+
|
|
137
|
+
### FTS5 Search (hooks + scripts)
|
|
138
|
+
|
|
139
|
+
- Database: `.mindlore/mindlore.db`
|
|
140
|
+
- Table: `mindlore_fts` (columns: path, content)
|
|
141
|
+
- Dedup: `file_hashes` table with SHA256 content-hash
|
|
142
|
+
- Tokenizer: `unicode61`
|
|
143
|
+
- Max results: 3 per query (BM25 ranking)
|
|
144
|
+
- Hook injects: file path + first 2 headings
|
|
145
|
+
|
|
146
|
+
### FTS5 Columns (9-col schema, v0.2)
|
|
147
|
+
|
|
148
|
+
| Column | Indexed | Source |
|
|
149
|
+
|--------|---------|--------|
|
|
150
|
+
| `path` | UNINDEXED | File system path |
|
|
151
|
+
| `slug` | Yes | Frontmatter slug |
|
|
152
|
+
| `description` | Yes | Frontmatter description |
|
|
153
|
+
| `type` | UNINDEXED | Frontmatter type |
|
|
154
|
+
| `category` | Yes | Parent directory name |
|
|
155
|
+
| `title` | Yes | Frontmatter title or first heading |
|
|
156
|
+
| `content` | Yes | Markdown body (sans frontmatter) |
|
|
157
|
+
| `tags` | Yes | Frontmatter tags (comma-separated) |
|
|
158
|
+
| `quality` | UNINDEXED | Frontmatter quality (NULL until 50+ sources) |
|
|
159
|
+
|
|
160
|
+
### Search Flow (UserPromptSubmit hook)
|
|
161
|
+
|
|
162
|
+
1. Extract keywords from user prompt
|
|
163
|
+
2. Query FTS5 with BM25 ranking
|
|
164
|
+
3. Return max 3 results as stdout additionalContext
|
|
165
|
+
4. Agent reads full file only if needed (progressive disclosure)
|
|
166
|
+
|
|
167
|
+
## 6. Wiki vs Diary (Writeback Target Rules)
|
|
168
|
+
|
|
169
|
+
Knowledge goes to one of two layers. The agent MUST pick the correct one.
|
|
170
|
+
|
|
171
|
+
### Wiki Layer (permanent knowledge)
|
|
172
|
+
|
|
173
|
+
Directories: `sources/`, `domains/`, `analyses/`, `insights/`, `connections/`, `learnings/`
|
|
174
|
+
|
|
175
|
+
- Persists across sessions — reference value
|
|
176
|
+
- Indexed by FTS5, discoverable via search hook
|
|
177
|
+
- Updated by ingest, query writeback, reflect, evolve
|
|
178
|
+
- Content should be factual, sourced, and reusable
|
|
179
|
+
|
|
180
|
+
### Diary Layer (session-scoped logs)
|
|
181
|
+
|
|
182
|
+
Directories: `diary/`, `decisions/`
|
|
183
|
+
|
|
184
|
+
- Session-specific: deltas, logs, decision snapshots
|
|
185
|
+
- diary/ entries get `archived: true` after reflect processes them
|
|
186
|
+
- decisions/ are permanent but session-originated (context + rationale)
|
|
187
|
+
- Patterns extracted from diary → moved to `learnings/` (wiki layer)
|
|
188
|
+
|
|
189
|
+
### Selection Rule
|
|
190
|
+
|
|
191
|
+
| Content Type | Target | Example |
|
|
192
|
+
|-------------|--------|---------|
|
|
193
|
+
| Ingested source summary | `sources/` | URL or text summary |
|
|
194
|
+
| Topic wiki page | `domains/` | Consolidated knowledge on a subject |
|
|
195
|
+
| Multi-source synthesis | `analyses/` | Comparison table, architecture decision |
|
|
196
|
+
| Short Q&A answer | `insights/` | Query writeback (<200 lines) |
|
|
197
|
+
| Cross-reference finding | `connections/` | Link between 2+ unrelated sources |
|
|
198
|
+
| Persistent rule/lesson | `learnings/` | YAPMA/BEST PRACTICE from reflect |
|
|
199
|
+
| Session log/delta | `diary/` | What happened this session |
|
|
200
|
+
| Decision record | `decisions/` | Why X was chosen over Y |
|
|
201
|
+
| Raw capture | `raw/` | Immutable original (URL dump, paste) |
|
|
202
|
+
|
|
203
|
+
### Anti-patterns
|
|
204
|
+
|
|
205
|
+
- Do NOT write session-specific notes to `insights/` — use `diary/`
|
|
206
|
+
- Do NOT write permanent rules to `diary/` — use `learnings/`
|
|
207
|
+
- Do NOT write decision rationale to `analyses/` — use `decisions/`
|
|
208
|
+
|
|
209
|
+
## 7. Compounding
|
|
210
|
+
|
|
211
|
+
Knowledge compounds when outputs become inputs:
|
|
212
|
+
|
|
213
|
+
```
|
|
214
|
+
Query answer → writeback to insights/ → FTS5 indexes → next query finds it
|
|
215
|
+
Reflect → patterns to learnings/ → session-focus injects → agent applies
|
|
216
|
+
```
|
|
217
|
+
|
|
218
|
+
### Writeback Triggers
|
|
219
|
+
|
|
220
|
+
Offer to save when:
|
|
221
|
+
- Comparison table generated (X vs Y)
|
|
222
|
+
- Architectural decision or evaluation made
|
|
223
|
+
- 3+ sources synthesized
|
|
224
|
+
- User says "save this" or "remember this"
|
|
225
|
+
|
|
226
|
+
### Writeback Rules
|
|
227
|
+
|
|
228
|
+
- Short answer (<200 lines) → insights/
|
|
229
|
+
- Large synthesis (200+ lines, 3+ sources) → analyses/
|
|
230
|
+
- Cross-cutting link → connections/
|
|
231
|
+
|
|
232
|
+
## 8. Learnings
|
|
233
|
+
|
|
234
|
+
Persistent rules extracted from reflect operations.
|
|
235
|
+
Organized by topic: `git.md`, `testing.md`, `security.md`, etc.
|
|
236
|
+
|
|
237
|
+
### Format
|
|
238
|
+
|
|
239
|
+
```markdown
|
|
240
|
+
---
|
|
241
|
+
slug: testing
|
|
242
|
+
type: learning
|
|
243
|
+
title: Testing Learnings
|
|
244
|
+
tags: [testing, jest, mock]
|
|
245
|
+
---
|
|
246
|
+
|
|
247
|
+
# Testing Learnings
|
|
248
|
+
|
|
249
|
+
- YAPMA: Error handling testinde mock'u dolayli tetikleme
|
|
250
|
+
- BEST PRACTICE: Side-effect'li moduller eklerken TUM test'lerde mock ekle
|
|
251
|
+
```
|
|
252
|
+
|
|
253
|
+
### Rules
|
|
254
|
+
|
|
255
|
+
- One file per topic (not per lesson)
|
|
256
|
+
- Append new learnings to existing topic file
|
|
257
|
+
- Use `YAPMA:` / `BEST PRACTICE:` / `KRITIK:` prefixes
|
|
258
|
+
- Reflect skill proposes, user approves before writing
|
|
259
|
+
|
|
260
|
+
## 9. Naming Conventions
|
|
261
|
+
|
|
262
|
+
### Files
|
|
263
|
+
|
|
264
|
+
- Filename = `{slug}.md` (kebab-case)
|
|
265
|
+
- Diary: `delta-YYYY-MM-DD-HHmm.md`
|
|
266
|
+
- No spaces, no uppercase in filenames
|
|
267
|
+
|
|
268
|
+
### Slugs
|
|
269
|
+
|
|
270
|
+
- kebab-case only: `my-analysis-topic`
|
|
271
|
+
- Unique within directory
|
|
272
|
+
- Descriptive but concise (3-5 words max)
|
|
273
|
+
|
|
274
|
+
### INDEX.md
|
|
275
|
+
|
|
276
|
+
- Fixed size: ~15-20 lines
|
|
277
|
+
- Domain list (entities/concepts headings)
|
|
278
|
+
- Stats line: "N source, N analysis, N total"
|
|
279
|
+
- Last 5 added (initially empty)
|
|
280
|
+
- NO full file listing — discovery via FTS5
|