mindlore 0.1.0 → 0.2.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.
Files changed (98) hide show
  1. package/README.md +13 -5
  2. package/SCHEMA.md +60 -4
  3. package/dist/scripts/init.d.ts +10 -0
  4. package/dist/scripts/init.d.ts.map +1 -0
  5. package/dist/scripts/init.js +375 -0
  6. package/dist/scripts/init.js.map +1 -0
  7. package/dist/scripts/lib/constants.d.ts +29 -0
  8. package/dist/scripts/lib/constants.d.ts.map +1 -0
  9. package/dist/scripts/lib/constants.js +58 -0
  10. package/dist/scripts/lib/constants.js.map +1 -0
  11. package/dist/scripts/mindlore-fts5-index.d.ts +9 -0
  12. package/dist/scripts/mindlore-fts5-index.d.ts.map +1 -0
  13. package/dist/scripts/mindlore-fts5-index.js +89 -0
  14. package/dist/scripts/mindlore-fts5-index.js.map +1 -0
  15. package/dist/scripts/mindlore-fts5-search.d.ts +10 -0
  16. package/dist/scripts/mindlore-fts5-search.d.ts.map +1 -0
  17. package/dist/scripts/mindlore-fts5-search.js +108 -0
  18. package/dist/scripts/mindlore-fts5-search.js.map +1 -0
  19. package/dist/scripts/mindlore-health-check.d.ts +10 -0
  20. package/dist/scripts/mindlore-health-check.d.ts.map +1 -0
  21. package/dist/scripts/mindlore-health-check.js +337 -0
  22. package/dist/scripts/mindlore-health-check.js.map +1 -0
  23. package/dist/scripts/uninstall.d.ts +10 -0
  24. package/dist/scripts/uninstall.d.ts.map +1 -0
  25. package/dist/scripts/uninstall.js +143 -0
  26. package/dist/scripts/uninstall.js.map +1 -0
  27. package/dist/tests/compounding.test.d.ts +8 -0
  28. package/dist/tests/compounding.test.d.ts.map +1 -0
  29. package/dist/tests/compounding.test.js +51 -0
  30. package/dist/tests/compounding.test.js.map +1 -0
  31. package/dist/tests/decision.test.d.ts +2 -0
  32. package/dist/tests/decision.test.d.ts.map +1 -0
  33. package/dist/tests/decision.test.js +61 -0
  34. package/dist/tests/decision.test.js.map +1 -0
  35. package/dist/tests/dedup.test.d.ts +2 -0
  36. package/dist/tests/dedup.test.d.ts.map +1 -0
  37. package/dist/tests/dedup.test.js +74 -0
  38. package/dist/tests/dedup.test.js.map +1 -0
  39. package/dist/tests/frontmatter.test.d.ts +2 -0
  40. package/dist/tests/frontmatter.test.d.ts.map +1 -0
  41. package/dist/tests/frontmatter.test.js +90 -0
  42. package/dist/tests/frontmatter.test.js.map +1 -0
  43. package/dist/tests/fts5.test.d.ts +2 -0
  44. package/dist/tests/fts5.test.d.ts.map +1 -0
  45. package/dist/tests/fts5.test.js +95 -0
  46. package/dist/tests/fts5.test.js.map +1 -0
  47. package/dist/tests/helpers/db.d.ts +7 -0
  48. package/dist/tests/helpers/db.d.ts.map +1 -0
  49. package/dist/tests/helpers/db.js +46 -0
  50. package/dist/tests/helpers/db.js.map +1 -0
  51. package/dist/tests/hook-smoke.test.d.ts +2 -0
  52. package/dist/tests/hook-smoke.test.d.ts.map +1 -0
  53. package/dist/tests/hook-smoke.test.js +58 -0
  54. package/dist/tests/hook-smoke.test.js.map +1 -0
  55. package/dist/tests/init.test.d.ts +2 -0
  56. package/dist/tests/init.test.d.ts.map +1 -0
  57. package/dist/tests/init.test.js +85 -0
  58. package/dist/tests/init.test.js.map +1 -0
  59. package/dist/tests/log.test.d.ts +2 -0
  60. package/dist/tests/log.test.d.ts.map +1 -0
  61. package/dist/tests/log.test.js +68 -0
  62. package/dist/tests/log.test.js.map +1 -0
  63. package/dist/tests/read-guard.test.d.ts +2 -0
  64. package/dist/tests/read-guard.test.d.ts.map +1 -0
  65. package/dist/tests/read-guard.test.js +69 -0
  66. package/dist/tests/read-guard.test.js.map +1 -0
  67. package/dist/tests/search-hook.test.d.ts +2 -0
  68. package/dist/tests/search-hook.test.d.ts.map +1 -0
  69. package/dist/tests/search-hook.test.js +108 -0
  70. package/dist/tests/search-hook.test.js.map +1 -0
  71. package/dist/tests/session-focus.test.d.ts +2 -0
  72. package/dist/tests/session-focus.test.d.ts.map +1 -0
  73. package/dist/tests/session-focus.test.js +71 -0
  74. package/dist/tests/session-focus.test.js.map +1 -0
  75. package/dist/tests/uninstall.test.d.ts +2 -0
  76. package/dist/tests/uninstall.test.d.ts.map +1 -0
  77. package/dist/tests/uninstall.test.js +98 -0
  78. package/dist/tests/uninstall.test.js.map +1 -0
  79. package/hooks/lib/mindlore-common.cjs +36 -2
  80. package/hooks/mindlore-decision-detector.cjs +51 -0
  81. package/hooks/mindlore-fts5-sync.cjs +4 -18
  82. package/hooks/mindlore-index.cjs +4 -18
  83. package/hooks/mindlore-read-guard.cjs +62 -0
  84. package/hooks/mindlore-search.cjs +5 -18
  85. package/hooks/mindlore-session-end.cjs +74 -8
  86. package/package.json +19 -7
  87. package/plugin.json +26 -2
  88. package/skills/mindlore-decide/SKILL.md +71 -0
  89. package/skills/mindlore-ingest/SKILL.md +13 -2
  90. package/skills/mindlore-log/SKILL.md +79 -0
  91. package/skills/mindlore-query/SKILL.md +125 -0
  92. package/templates/SCHEMA.md +60 -4
  93. package/scripts/init.cjs +0 -450
  94. package/scripts/lib/constants.cjs +0 -49
  95. package/scripts/mindlore-fts5-index.cjs +0 -112
  96. package/scripts/mindlore-fts5-search.cjs +0 -119
  97. package/scripts/mindlore-health-check.cjs +0 -336
  98. package/scripts/uninstall.cjs +0 -186
@@ -0,0 +1,71 @@
1
+ # Skill: Mindlore Decide
2
+
3
+ Record and list decisions in the `.mindlore/decisions/` directory.
4
+
5
+ ## Trigger
6
+
7
+ User says `/mindlore-decide record` or `/mindlore-decide list`.
8
+
9
+ ## Modes
10
+
11
+ ### record
12
+
13
+ Record a new decision.
14
+
15
+ **Flow:**
16
+ 1. Ask user (or extract from context): What was decided? What alternatives were considered? Why this choice?
17
+ 2. Generate slug from decision title (kebab-case, max 5 words)
18
+ 3. Check if a previous decision on same topic exists → set `supersedes` field
19
+ 4. Write to `.mindlore/decisions/{slug}.md` with frontmatter:
20
+
21
+ ```yaml
22
+ ---
23
+ slug: use-fts5-over-vector
24
+ type: decision
25
+ title: Use FTS5 over vector search for v0.1
26
+ tags: [search, fts5, architecture]
27
+ date: 2026-04-11
28
+ supersedes: null
29
+ status: active
30
+ description: Chose FTS5 keyword search as primary engine, vector deferred to v0.4
31
+ ---
32
+ ```
33
+
34
+ 5. Body structure:
35
+ ```markdown
36
+ # {title}
37
+
38
+ ## Context
39
+ Why this decision was needed.
40
+
41
+ ## Alternatives Considered
42
+ 1. **Option A** — pros/cons
43
+ 2. **Option B** — pros/cons
44
+
45
+ ## Decision
46
+ What was chosen and why.
47
+
48
+ ## Consequences
49
+ What this means going forward.
50
+ ```
51
+
52
+ 6. Append to `log.md`: `| {date} | decide | {slug}.md |`
53
+ 7. FTS5 auto-indexes via FileChanged hook
54
+
55
+ ### list
56
+
57
+ List active decisions.
58
+
59
+ **Flow:**
60
+ 1. Read all `.md` files in `.mindlore/decisions/`
61
+ 2. Parse frontmatter, filter `status: active`
62
+ 3. Display as table: slug, title, date, tags
63
+ 4. Show supersedes chain if any (A → B → C)
64
+
65
+ ## Rules
66
+
67
+ - Slug must be unique in decisions/
68
+ - `supersedes` field points to the slug of the replaced decision
69
+ - When a decision is superseded, update old one: `status: superseded`
70
+ - Tags should match domain topics for FTS5 discoverability
71
+ - Keep decision body concise — context + alternatives + choice + consequences
@@ -94,9 +94,20 @@ Only update the stats line: increment source count and total count.
94
94
  N source, N analysis, N total
95
95
  ```
96
96
 
97
- ## Post-Ingest Verification
97
+ ## Post-Ingest Quality Gate
98
98
 
99
- After ingest, run health check:
99
+ After every ingest, verify all 6 checkpoints before reporting success:
100
+
101
+ 1. **raw/ file exists** — immutable capture written with frontmatter (slug, type, source_url)
102
+ 2. **sources/ summary exists** — processed summary with full frontmatter (slug, type, title, tags, quality, description)
103
+ 3. **INDEX.md updated** — stats line incremented, Recent section has new entry
104
+ 4. **Domain updated** — if relevant domain exists, new finding added (max 1 domain per ingest)
105
+ 5. **log.md entry** — append `| {date} | ingest | {slug}.md |`
106
+ 6. **FTS5 indexed** — FileChanged hook auto-triggers, but verify: `node scripts/mindlore-fts5-search.cjs "{keyword}"` returns the new file
107
+
108
+ If any checkpoint fails, fix it before reporting "ingest complete". Do NOT skip steps.
109
+
110
+ Optional: run full health check for structural integrity:
100
111
  ```bash
101
112
  node scripts/mindlore-health-check.cjs
102
113
  ```
@@ -0,0 +1,79 @@
1
+ # Skill: Mindlore Log
2
+
3
+ Session logging, pattern extraction, and wiki updates.
4
+
5
+ ## Trigger
6
+
7
+ `/mindlore-log <mode>` where mode is `log`, `reflect`, `status`, or `save`.
8
+
9
+ ## Modes
10
+
11
+ ### log
12
+
13
+ Write a manual diary entry.
14
+
15
+ **Flow:**
16
+ 1. User provides note/observation (or extract from conversation context)
17
+ 2. Generate slug: `note-YYYY-MM-DD-HHmm`
18
+ 3. Write to `.mindlore/diary/{slug}.md`:
19
+
20
+ ```yaml
21
+ ---
22
+ slug: note-2026-04-11-1530
23
+ type: diary
24
+ date: 2026-04-11
25
+ ---
26
+ ```
27
+
28
+ 4. Body: user's note as-is
29
+ 5. Append to `log.md`: `| {date} | log | {slug}.md |`
30
+
31
+ ### reflect
32
+
33
+ Scan old deltas, extract patterns, write to learnings/.
34
+
35
+ **Flow (v0.2 — basic):**
36
+ 1. Read all non-archived delta files in `diary/` (no `archived: true` frontmatter)
37
+ 2. Present summary to user: "Found N unprocessed deltas spanning DATE1 to DATE2"
38
+ 3. For each delta, extract: repeated topics, recurring decisions, common file changes
39
+ 4. Propose learnings to user: "I found these patterns: ..."
40
+ 5. User approves → write to `learnings/{topic}.md` (append if exists, create if not)
41
+ 6. Format: `YAPMA:` / `BEST PRACTICE:` / `KRITIK:` prefixed rules
42
+ 7. Mark processed deltas: add `archived: true` to their frontmatter
43
+ 8. Append to `log.md`: `| {date} | reflect | {N} deltas processed, {M} learnings written |`
44
+
45
+ **Important:** Do NOT auto-extract patterns. Present findings, user approves. This is v0.2 basic mode — automated pattern extraction deferred to v0.2.1.
46
+
47
+ ### status
48
+
49
+ Show recent session summary.
50
+
51
+ **Flow:**
52
+ 1. Read last 5 delta files from `diary/` (sorted by date, newest first)
53
+ 2. For each delta, extract: date, commits count, changed files count
54
+ 3. Display as compact table
55
+ 4. Show any open items (from delta "Yarım Kalan" sections if present)
56
+ 5. Show total: "N sessions, M commits, K unique files changed"
57
+
58
+ ### save
59
+
60
+ Structured delta + log.md append + domain wiki update.
61
+
62
+ **Flow:**
63
+ 1. Gather current session context:
64
+ - Recent git commits (last 5)
65
+ - Changed files
66
+ - Decisions made (if decision-detector captured any)
67
+ 2. Write structured delta to `diary/delta-YYYY-MM-DD-HHmm.md` (same format as session-end hook)
68
+ 3. Append to `log.md`
69
+ 4. Ask user: "Which domain pages should be updated with this session's findings?"
70
+ 5. If user specifies domains → update those `.mindlore/domains/{slug}.md` pages with new findings
71
+ 6. Max 2 domain updates per save (prevent sprawl)
72
+
73
+ ## Rules
74
+
75
+ - Diary files are session-scoped (temporary), learnings are permanent
76
+ - reflect marks deltas as `archived: true` — they stay in diary/ but are not processed again
77
+ - Health check warns on deltas older than 30 days without `archived: true`
78
+ - learnings/ files are topic-based (one per topic), append-only
79
+ - save mode is the manual equivalent of what session-end hook does automatically
@@ -0,0 +1,125 @@
1
+ # Skill: Mindlore Query
2
+
3
+ Search, ask, analyze, and retrieve knowledge from `.mindlore/`.
4
+
5
+ ## Trigger
6
+
7
+ `/mindlore-query <mode> [query]` where mode is `search`, `ask`, `stats`, or `brief`.
8
+
9
+ ## Modes
10
+
11
+ ### search
12
+
13
+ FTS5 keyword search with direct results.
14
+
15
+ **Flow:**
16
+ 1. Parse user query into keywords (strip stop words)
17
+ 2. Run FTS5 MATCH on `mindlore_fts` table
18
+ 3. Return top 5 results (configurable) with: path, title, description, category, rank score
19
+ 4. Display as table with snippet preview
20
+ 5. If `--tags <tag>` flag provided: `WHERE tags MATCH '<tag>'` filter
21
+
22
+ **Output format:**
23
+ ```
24
+ | # | Category | Title | Description | Score |
25
+ |---|----------|-------|-------------|-------|
26
+ | 1 | sources | React Hooks | useEffect cleanup patterns | -2.34 |
27
+ ```
28
+
29
+ ### ask
30
+
31
+ Compounding query pipeline — knowledge grows with each answer.
32
+
33
+ **Flow:**
34
+ 1. Parse user question
35
+ 2. FTS5 search → find relevant files (sources + domains + analyses + insights — previous answers INCLUDED)
36
+ 3. Read top 3-5 relevant files using ctx_execute_file if context-mode available, else Read
37
+ 4. Synthesize answer from found knowledge
38
+ 5. Cite sources: `[kaynak: sources/x.md]` format
39
+ 6. Ask user: "Bu cevabı kaydetmemi ister misin?"
40
+ 7. If yes → determine target:
41
+ - Short answer (<200 lines, 1-2 sources) → `insights/{slug}.md`
42
+ - Large synthesis (200+ lines, 3+ sources) → `analyses/{slug}.md`
43
+ 8. Write with frontmatter:
44
+
45
+ ```yaml
46
+ ---
47
+ slug: react-hooks-cleanup-comparison
48
+ type: insight
49
+ title: React Hooks Cleanup Comparison
50
+ tags: [react, hooks, useEffect]
51
+ confidence: high
52
+ sources_used: [react-hooks, typescript-generics]
53
+ description: Comparison of cleanup patterns in useEffect vs useLayoutEffect
54
+ ---
55
+ ```
56
+
57
+ 9. FTS5 auto-indexes via FileChanged hook → next query finds this answer
58
+ 10. Update relevant domain page (max 1) with backlink if applicable
59
+ 11. Append to `log.md`: `| {date} | query-ask | {slug}.md |`
60
+
61
+ **Compounding effect:** Step 2 searches ALL of `.mindlore/` including previous `insights/` and `analyses/`. Each saved answer enriches the next query.
62
+
63
+ **Error compounding prevention:**
64
+ - `confidence` field is REQUIRED on writebacks (high/medium/low)
65
+ - `sources_used` lists exact slugs — traceability
66
+ - Health check flags conflicting analyses on same topic (different confidence)
67
+ - User approval is the quality gate — low-quality answers are not saved
68
+
69
+ ### stats
70
+
71
+ Knowledge base statistics.
72
+
73
+ **Flow:**
74
+ 1. Count files per directory (9 directories)
75
+ 2. Count FTS5 entries and file_hashes entries
76
+ 3. Find most recent ingest (latest file by modified date per directory)
77
+ 4. Count tags frequency (parse all frontmatter, aggregate tags)
78
+ 5. Display summary:
79
+
80
+ ```
81
+ Mindlore Stats
82
+ ─────────────
83
+ Total files: 47 (FTS5: 47 indexed)
84
+ - sources: 18
85
+ - domains: 5
86
+ - analyses: 6
87
+ - insights: 3
88
+ - connections: 2
89
+ - learnings: 4
90
+ - diary: 8
91
+ - decisions: 1
92
+ - raw: 0
93
+
94
+ Top tags: security (12), hooks (8), fts5 (6), testing (5)
95
+ Last ingest: 2026-04-11 (sources/react-hooks.md)
96
+ DB size: 1.2 MB
97
+ ```
98
+
99
+ ### brief
100
+
101
+ Quick context on a topic — token-efficient (~50 tokens output).
102
+
103
+ **Flow:**
104
+ 1. FTS5 search for topic
105
+ 2. If domain page exists → read first 3 lines of body (after frontmatter)
106
+ 3. If no domain → read description field from top FTS5 match
107
+ 4. Return: title + description + "Read full: {path}" pointer
108
+ 5. Do NOT read full file — this mode is for quick "do I need to open this?" decisions
109
+
110
+ **Output format:**
111
+ ```
112
+ [Mindlore Brief: Security]
113
+ SSH hardening, firewall rules, audit checks. 5 sources, 2 analyses linked.
114
+ → Read full: .mindlore/domains/security.md
115
+ ```
116
+
117
+ ## Rules
118
+
119
+ - All modes respect the SCHEMA.md writeback rules (Section 6: Wiki vs Diary)
120
+ - search and brief are read-only — no writes
121
+ - ask writes only with user approval
122
+ - stats is read-only
123
+ - Token strategy: prefer ctx_execute_file (if context-mode installed), fallback to Read
124
+ - Tags filter: `--tags security` works in search and ask modes
125
+ - Max results: search=5, ask=3-5 (for synthesis), brief=1
@@ -143,14 +143,70 @@ Discover unexpected connections between sources. Cross-reference analysis.
143
143
  - Max results: 3 per query (BM25 ranking)
144
144
  - Hook injects: file path + first 2 headings
145
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
+
146
160
  ### Search Flow (UserPromptSubmit hook)
147
161
 
148
162
  1. Extract keywords from user prompt
149
163
  2. Query FTS5 with BM25 ranking
150
- 3. Return max 3 results as stderr additionalContext
164
+ 3. Return max 3 results as stdout additionalContext
151
165
  4. Agent reads full file only if needed (progressive disclosure)
152
166
 
153
- ## 6. Compounding
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
154
210
 
155
211
  Knowledge compounds when outputs become inputs:
156
212
 
@@ -173,7 +229,7 @@ Offer to save when:
173
229
  - Large synthesis (200+ lines, 3+ sources) → analyses/
174
230
  - Cross-cutting link → connections/
175
231
 
176
- ## 7. Learnings
232
+ ## 8. Learnings
177
233
 
178
234
  Persistent rules extracted from reflect operations.
179
235
  Organized by topic: `git.md`, `testing.md`, `security.md`, etc.
@@ -201,7 +257,7 @@ tags: [testing, jest, mock]
201
257
  - Use `YAPMA:` / `BEST PRACTICE:` / `KRITIK:` prefixes
202
258
  - Reflect skill proposes, user approves before writing
203
259
 
204
- ## 8. Naming Conventions
260
+ ## 9. Naming Conventions
205
261
 
206
262
  ### Files
207
263