mindlore 0.5.1 → 0.5.2

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 (90) hide show
  1. package/README.md +15 -2
  2. package/dist/scripts/fetch-raw.d.ts +2 -0
  3. package/dist/scripts/fetch-raw.d.ts.map +1 -0
  4. package/dist/scripts/fetch-raw.js +124 -0
  5. package/dist/scripts/fetch-raw.js.map +1 -0
  6. package/dist/scripts/lib/constants.d.ts +2 -0
  7. package/dist/scripts/lib/constants.d.ts.map +1 -1
  8. package/dist/scripts/lib/constants.js +13 -4
  9. package/dist/scripts/lib/constants.js.map +1 -1
  10. package/dist/scripts/lib/db-helpers.d.ts +12 -2
  11. package/dist/scripts/lib/db-helpers.d.ts.map +1 -1
  12. package/dist/scripts/lib/db-helpers.js +36 -0
  13. package/dist/scripts/lib/db-helpers.js.map +1 -1
  14. package/dist/scripts/lib/hybrid-search.d.ts +0 -2
  15. package/dist/scripts/lib/hybrid-search.d.ts.map +1 -1
  16. package/dist/scripts/lib/hybrid-search.js +7 -1
  17. package/dist/scripts/lib/hybrid-search.js.map +1 -1
  18. package/dist/scripts/lib/migrations-v052.d.ts +3 -0
  19. package/dist/scripts/lib/migrations-v052.d.ts.map +1 -0
  20. package/dist/scripts/lib/migrations-v052.js +23 -0
  21. package/dist/scripts/lib/migrations-v052.js.map +1 -0
  22. package/dist/scripts/lib/skeleton.d.ts +2 -0
  23. package/dist/scripts/lib/skeleton.d.ts.map +1 -0
  24. package/dist/scripts/lib/skeleton.js +99 -0
  25. package/dist/scripts/lib/skeleton.js.map +1 -0
  26. package/dist/scripts/lib/skill-memory.d.ts +13 -0
  27. package/dist/scripts/lib/skill-memory.d.ts.map +1 -0
  28. package/dist/scripts/lib/skill-memory.js +94 -0
  29. package/dist/scripts/lib/skill-memory.js.map +1 -0
  30. package/dist/scripts/mindlore-fts5-index.js +2 -1
  31. package/dist/scripts/mindlore-fts5-index.js.map +1 -1
  32. package/dist/scripts/mindlore-health-check.d.ts +1 -1
  33. package/dist/scripts/mindlore-health-check.d.ts.map +1 -1
  34. package/dist/scripts/mindlore-health-check.js +110 -142
  35. package/dist/scripts/mindlore-health-check.js.map +1 -1
  36. package/dist/tests/catch-up.test.d.ts +2 -0
  37. package/dist/tests/catch-up.test.d.ts.map +1 -0
  38. package/dist/tests/catch-up.test.js +88 -0
  39. package/dist/tests/catch-up.test.js.map +1 -0
  40. package/dist/tests/episode-file.test.js +9 -6
  41. package/dist/tests/episode-file.test.js.map +1 -1
  42. package/dist/tests/fetch-raw.test.d.ts +2 -0
  43. package/dist/tests/fetch-raw.test.d.ts.map +1 -0
  44. package/dist/tests/fetch-raw.test.js +43 -0
  45. package/dist/tests/fetch-raw.test.js.map +1 -0
  46. package/dist/tests/resolve-hook-common.test.d.ts +2 -0
  47. package/dist/tests/resolve-hook-common.test.d.ts.map +1 -0
  48. package/dist/tests/resolve-hook-common.test.js +30 -0
  49. package/dist/tests/resolve-hook-common.test.js.map +1 -0
  50. package/dist/tests/search-offload.test.d.ts +2 -0
  51. package/dist/tests/search-offload.test.d.ts.map +1 -0
  52. package/dist/tests/search-offload.test.js +34 -0
  53. package/dist/tests/search-offload.test.js.map +1 -0
  54. package/dist/tests/skeleton.test.d.ts +2 -0
  55. package/dist/tests/skeleton.test.d.ts.map +1 -0
  56. package/dist/tests/skeleton.test.js +116 -0
  57. package/dist/tests/skeleton.test.js.map +1 -0
  58. package/dist/tests/skill-memory-api.test.d.ts +2 -0
  59. package/dist/tests/skill-memory-api.test.d.ts.map +1 -0
  60. package/dist/tests/skill-memory-api.test.js +62 -0
  61. package/dist/tests/skill-memory-api.test.js.map +1 -0
  62. package/dist/tests/skill-memory.test.d.ts +2 -0
  63. package/dist/tests/skill-memory.test.d.ts.map +1 -0
  64. package/dist/tests/skill-memory.test.js +67 -0
  65. package/dist/tests/skill-memory.test.js.map +1 -0
  66. package/dist/tests/wiki-lint.test.d.ts +2 -0
  67. package/dist/tests/wiki-lint.test.d.ts.map +1 -0
  68. package/dist/tests/wiki-lint.test.js +47 -0
  69. package/dist/tests/wiki-lint.test.js.map +1 -0
  70. package/hooks/lib/mindlore-common.cjs +24 -5
  71. package/hooks/mindlore-cwd-changed.cjs +2 -2
  72. package/hooks/mindlore-decision-detector.cjs +2 -2
  73. package/hooks/mindlore-dont-repeat.cjs +2 -2
  74. package/hooks/mindlore-fts5-sync.cjs +2 -2
  75. package/hooks/mindlore-index.cjs +60 -2
  76. package/hooks/mindlore-model-router.cjs +2 -2
  77. package/hooks/mindlore-post-compact.cjs +2 -2
  78. package/hooks/mindlore-post-read.cjs +2 -2
  79. package/hooks/mindlore-pre-compact.cjs +2 -2
  80. package/hooks/mindlore-read-guard.cjs +15 -3
  81. package/hooks/mindlore-research-guard.cjs +2 -2
  82. package/hooks/mindlore-search.cjs +20 -2
  83. package/hooks/mindlore-session-end.cjs +1 -1
  84. package/package.json +3 -2
  85. package/plugin.json +29 -2
  86. package/skills/mindlore-diary/SKILL.md +76 -0
  87. package/skills/mindlore-ingest/SKILL.md +41 -49
  88. package/skills/mindlore-log/SKILL.md +3 -143
  89. package/skills/mindlore-reflect/SKILL.md +104 -0
  90. package/templates/config.json +1 -1
@@ -3,6 +3,8 @@ name: mindlore-ingest
3
3
  description: Add new knowledge sources to .mindlore/ (URL, text, file, PDF, GitHub repo)
4
4
  effort: medium
5
5
  allowed-tools: [Read, Write, Edit, Bash, Grep, Glob, Agent, WebFetch]
6
+ context: fork
7
+ agent: coder
6
8
  ---
7
9
 
8
10
  # /mindlore-ingest
@@ -23,60 +25,50 @@ User shares a URL, text, file, or says "kaynak ekle", "source ingest", "bu linki
23
25
 
24
26
  ## Modes
25
27
 
26
- ### URL Mode
28
+ ### URL Mode (v0.5.2 — Zero-Token Pipeline)
27
29
 
28
- **Agent Delegation:** URL fetch + raw/sources yazımını subagent'a delege et (maliyet optimizasyonu).
30
+ **Trigger:** Input starts with `http://` or `https://`
29
31
 
30
- 1. Spawn an Agent with the following pattern:
32
+ **Pre-check (before fetch):**
33
+ ```bash
34
+ node dist/scripts/lib/skill-memory.js get mindlore-ingest last_ingest_urls
35
+ ```
36
+ If URL already in the list, warn user: "This URL was ingested recently. Re-ingest?"
37
+
38
+ **Flow:**
39
+
40
+ 1. **Fetch raw content (zero token):**
41
+ ```bash
42
+ node dist/scripts/fetch-raw.js "$URL" --out-dir "$MINDLORE_DIR/raw"
31
43
  ```
32
- Agent({
33
- description: "mindlore ingest: <slug>",
34
- subagent_type: "researcher",
35
- prompt: "[mindlore:ingest] <aşağıdaki talimatları buraya koy>"
36
- })
44
+ Script output: `{ "saved": "/path/to/raw/2026-04-18-abc123.md", "chars": 14823, "method": "curl" }`
45
+
46
+ 2. **Read first 3000 chars (heading-aware truncation):**
47
+ - Read the saved raw file
48
+ - Find the last `##` heading before char 3000
49
+ - Truncate at that heading boundary (not mid-paragraph)
50
+ - If no heading found before 3000, truncate at last paragraph break
51
+
52
+ 3. **Write sources/ summary from truncated content:**
53
+ - Extract: title, description (first paragraph), key topics
54
+ - Generate frontmatter: slug, type: source, source_url, date_captured, tags, quality
55
+ - Write to `$MINDLORE_DIR/sources/{slug}.md`
56
+
57
+ 4. **Update INDEX.md** with new source entry
58
+
59
+ 5. **Update skill_memory:**
60
+ ```bash
61
+ node dist/scripts/lib/skill-memory.js set mindlore-ingest last_ingest_urls "$URL"
37
62
  ```
38
63
 
39
- Agent talimatları:
40
- - Extract content from URL:
41
- - If `markitdown` is available: `markitdown <url>` (best quality, zero tokens)
42
- - Else: use `WebFetch` or `ctx_fetch_and_index`
43
- - **YouTube URL** detected (`youtube.com` or `youtu.be`):
44
- 1. markitdown installed `markitdown <url>` (includes transcript)
45
- 2. Else youtube-transcript npm → `hasYoutubeTranscript()` check
46
- 3. Else return error, ask user to paste transcript
47
- - Save raw capture to `.mindlore/raw/` with frontmatter:
48
- ```yaml
49
- ---
50
- slug: source-name-kebab
51
- type: raw
52
- source_url: https://...
53
- date_captured: YYYY-MM-DD
54
- tags: [tag1, tag2]
55
- ---
56
- ```
57
- - Summarize into `.mindlore/sources/` with full frontmatter:
58
- ```yaml
59
- ---
60
- slug: source-name-kebab
61
- type: source
62
- title: Human Readable Title
63
- source_url: https://...
64
- source_type: github-repo|blog|docs|video|x-thread
65
- date_captured: YYYY-MM-DD
66
- tags: [tag1, tag2]
67
- quality: high|medium|low
68
- ingested: true
69
- ---
70
- ```
71
- - Agent must report: created file paths, slug, quality assigned
72
-
73
- 2. After agent returns — verify raw/ and sources/ files exist and have valid frontmatter
74
- 3. Update relevant domain page(s) in `.mindlore/domains/` (max 2)
75
- 4. Update `.mindlore/INDEX.md` stats line
76
- 5. Append entry to `.mindlore/log.md`
77
- 6. Run FTS5 re-index: `npm run index`
78
-
79
- **IMPORTANT:** The `[mindlore:ingest]` marker in the Agent prompt is required — it triggers the model-router hook to use the cost-optimized model (haiku by default).
64
+ 6. **Return to caller (this is all the ana session sees):**
65
+ ```json
66
+ { "source_id": "abc123", "title": "Extracted Title" }
67
+ ```
68
+
69
+ **Token budget:** ~2-3k tokens in fork context (vs ~40-50k before). Ana session: ~50 tokens.
70
+
71
+ **Fallback:** If fetch-raw.js fails (network error, unsupported format), fall back to existing WebFetch-based flow with warning: "Zero-token fetch failed, using legacy flow (higher token cost)."
80
72
 
81
73
  ### Text Mode
82
74
  1. User pastes text directly
@@ -12,7 +12,9 @@ Determine target using `getActiveMindloreDir()` logic:
12
12
 
13
13
  ## Trigger
14
14
 
15
- `/mindlore-log <mode>` where mode is `log`, `diary`, `reflect`, `status`, or `save`.
15
+ `/mindlore-log <mode>` where mode is `log`, `status`, or `save`.
16
+
17
+ For diary analysis, use `/mindlore-diary`. For pattern extraction, use `/mindlore-reflect`.
16
18
 
17
19
  ## Modes
18
20
 
@@ -36,148 +38,6 @@ date: 2026-04-11
36
38
  4. Body: user's note as-is
37
39
  5. Append to `log.md`: `| {date} | log | {slug}.md |`
38
40
 
39
- ### diary
40
-
41
- LLM-driven session analysis → enriched episodes in the episodes table.
42
-
43
- **Trigger:** User runs `/mindlore-log diary` or Stop hook asks "Diary analizi yapayım mı?"
44
-
45
- **Model:** `[mindlore:diary]` marker → sonnet (analysis needed)
46
-
47
- **Flow:**
48
- 1. Open `~/.mindlore/mindlore.db`, ensure episodes table exists
49
- 2. Find the latest bare session episode for current project: `WHERE kind = 'session' AND project = ? AND source = 'hook' ORDER BY created_at DESC LIMIT 1`
50
- 3. Gather context:
51
- - The bare episode's body (commits, files, read stats)
52
- - Git log last 10 commits
53
- - Decision-detector captures (if any in session)
54
- 4. LLM analyzes and extracts structured episodes:
55
- - **Decisions** → `kind: 'decision'` — architectural/tool/format choices
56
- - **Discoveries** → `kind: 'discovery'` — assumption vs reality findings
57
- - **Frictions** → `kind: 'friction'` — tool errors, blockers, recurring issues
58
- - **Learnings** → `kind: 'learning'` — reusable knowledge
59
- - **Preferences** → `kind: 'preference'` — user behavioral preferences
60
- - **Events** → `kind: 'event'` — releases, incidents, milestones
61
- 5. **Deduplication rule:** Each finding belongs to exactly ONE kind. Priority: `decision > discovery > friction > learning > preference > event`. Never write the same finding to multiple kinds.
62
- 6. Present to user, get approval
63
- 7. Write approved episodes to DB:
64
- - `source: 'diary'`
65
- - `parent_id: {bare_session_episode_id}` — links enriched episodes to source session
66
- - `scope: 'project'` (default) or `'global'` if cross-project
67
- 8. Optionally mirror to FTS5 for text search
68
- 9. Append to `log.md`: `| {date} | diary | {N} episodes extracted from session |`
69
-
70
- **Rules:**
71
- - NEVER write episodes without user approval
72
- - parent_id always points to the source session episode
73
- - Each episode gets its own summary (max 100 chars) and body (markdown, unbounded)
74
- - entities field: JSON array of relevant file paths (max 10)
75
-
76
- ### reflect
77
-
78
- LLM-driven pattern extraction from episodes → persistent learnings.
79
-
80
- **Flow (v0.4 — episodes-powered):**
81
- 1. Read active episodes: `WHERE status = 'active' AND source IN ('hook', 'diary')`
82
- 2. Optionally filter by time: `--days 7` (default 7), `--days 30`
83
- 3. Present summary: "Found N episodes spanning DATE1 to DATE2"
84
- 4. LLM analyzes episodes (not deltas) for patterns:
85
- - Repeated decisions (same choice 2+ times)
86
- - Recurring frictions (same blocker/error)
87
- - Discovery patterns (assumptions that keep breaking)
88
- - Workflow patterns that worked well
89
- 5. **3-Tier Confidence Assessment:**
90
- For each detected pattern, count occurrences across episodes:
91
-
92
- | Tekrar | Tier | Aksiyon |
93
- |--------|------|---------|
94
- | 1x | Note | Sessiz — episode olarak kalır, raporda göster |
95
- | 2x | Learning | `kind: learning` episode oluştur, learnings/ dosyasına yaz |
96
- | 3x+ | Nomination | `kind: nomination, status: staged, source: reflect` episode oluştur |
97
-
98
- 6. **Structured report output:**
99
-
100
- ```
101
- ── Reflect Raporu (son {days} gün, {N} episode) ──
102
-
103
- Friction ({count}):
104
- - {summary} — {repeat_count}x tekrar
105
-
106
- Discoveries ({count}):
107
- - {summary}
108
-
109
- Decisions ({count}):
110
- - {summary}
111
-
112
- Patterns:
113
- - "CO-EVOLUTION sync hatası" → 3x tekrar → NOMINATION (staged)
114
- - "ESM import sorunu" → 2x tekrar → LEARNING
115
- - "Test mock karmaşıklığı" → 1x → NOTE
116
-
117
- Önerilen:
118
- [ ] {rule} ({repeat_count}x, {confidence} confidence)
119
- ```
120
-
121
- 7. **Nomination oluşturma (3x+ tekrar):**
122
- - `kind: nomination`, `status: staged`, `source: reflect`
123
- - Body formatı:
124
- ```markdown
125
- ## Target: learnings
126
- ## Rule
127
- YAPMA: Schema değişikliğinde tek dosyayı güncelleme — CO-EVOLUTION sync zorunlu
128
- ## Evidence
129
- - ep-xxx: episodes.ts güncellendi ama common.cjs unutuldu (2026-04-10)
130
- - ep-yyy: Aynı hata tekrar (2026-04-12)
131
- - ep-zzz: Test'te yakalandı (2026-04-13)
132
- ## Confidence
133
- 3x tekrar, 3 gün içinde
134
- ```
135
- - Target options: `learnings` | `claude.md` | `domain:{slug}`
136
-
137
- 8. **Pending nominations check:**
138
- Reflect başlarken staged nomination'ları kontrol et:
139
- ```sql
140
- SELECT id, summary, body, created_at FROM episodes
141
- WHERE kind = 'nomination' AND status = 'staged' AND project = ?
142
- ORDER BY created_at ASC
143
- ```
144
- Varsa kullanıcıya sun:
145
- ```
146
- ── Bekleyen Nomination'lar ({N} adet) ──
147
- 1. "CO-EVOLUTION sync zorunlu" (staged 2 gün önce)
148
- Target: learnings | Confidence: 3x
149
- 2. "Test before commit" (staged 5 gün önce)
150
- Target: claude.md | Confidence: 4x
151
-
152
- Onaylamak istediğin numara(lar)ı seç, veya 'skip' de:
153
- ```
154
-
155
- 9. **Nomination approval flow:**
156
- Kullanıcı onaylarsa:
157
- - `status: staged → approved`
158
- - Target'a göre yaz:
159
- - `learnings` → ilgili `learnings/{topic}.md` dosyasına YAPMA/BEST PRACTICE ekle
160
- - `claude.md` → ilgili projenin CLAUDE.md'sine kural ekle (kullanıcıya göster, onay al)
161
- - `domain:{slug}` → ilgili domain sayfasına ekle
162
- Kullanıcı reddederse:
163
- - `status: staged → rejected`
164
- - Body'ye `## Rejection Reason\n{kullanıcı açıklaması}` ekle
165
-
166
- 10. User approves new learnings → write to `learnings/{topic}.md`
167
- 11. Format: `YAPMA:` / `BEST PRACTICE:` / `KRITIK:` prefixed rules
168
- 12. Update relevant domain page if pattern relates to an existing domain
169
- 13. Mark processed episodes: future reflect skips already-processed timeranges
170
- 14. Append to `log.md`: `| {date} | reflect | {N} episodes processed, {M} learnings written |`
171
-
172
- **Fallback:** Also reads non-archived delta files if episodes table is empty (backward compat with v0.3 deltas).
173
-
174
- **Rules:**
175
- - NEVER write learnings or nominations without user approval
176
- - Group related patterns into existing topic files (don't create one file per pattern)
177
- - Reflect scans both project + global diary/ in `--all` mode
178
- - Deduplication: same pattern found in both episodes and deltas → episodes win
179
- - Nominations with `status: staged` are hidden from default queries — only reflect sees them
180
-
181
41
  ### status
182
42
 
183
43
  Show recent session summary.
@@ -0,0 +1,104 @@
1
+ ---
2
+ name: mindlore-reflect
3
+ description: Pattern extraction from episodes — 3-tier confidence, nomination pipeline, CLAUDE.md update proposals.
4
+ ---
5
+
6
+ # /mindlore-reflect
7
+
8
+ ## Scope
9
+
10
+ Scans both project + global `~/.mindlore/` diary/ for patterns.
11
+
12
+ ## Trigger
13
+
14
+ `/mindlore-reflect` or `/mindlore-log reflect`
15
+
16
+ ## On Start — Check pending nominations + skill_memory
17
+
18
+ ```bash
19
+ node dist/scripts/lib/skill-memory.js get mindlore-reflect last_reflect_date
20
+ node dist/scripts/lib/skill-memory.js get mindlore-reflect nomination_count
21
+ ```
22
+
23
+ Check pending nominations:
24
+ ```sql
25
+ SELECT id, summary, body, created_at FROM episodes
26
+ WHERE kind = 'nomination' AND status = 'staged' AND project = ?
27
+ ORDER BY created_at ASC
28
+ ```
29
+
30
+ If pending nominations exist, present them first:
31
+ ```
32
+ -- Bekleyen Nomination'lar ({N} adet) --
33
+ 1. "{summary}" (staged {days} gun once)
34
+ Target: learnings | Confidence: 3x
35
+
36
+ Onaylamak istediklerini sec, veya 'skip':
37
+ ```
38
+
39
+ ## Flow
40
+
41
+ 1. Read active episodes: `WHERE status = 'active' AND source IN ('hook', 'diary')`
42
+ 2. Filter by time: `--days 7` (default), `--days 30`
43
+ 3. Present summary: "Found N episodes spanning DATE1 to DATE2"
44
+ 4. LLM analyzes episodes for recurring patterns:
45
+ - Repeated decisions (same choice 2+ times)
46
+ - Recurring frictions (same blocker/error)
47
+ - Discovery patterns (assumptions that keep breaking)
48
+ - Workflow patterns that worked well
49
+
50
+ 5. **3-Tier Confidence Assessment:**
51
+
52
+ | Tekrar | Tier | Aksiyon |
53
+ |--------|------|---------|
54
+ | 1x | Note | Sessiz — episode olarak kalir, raporda goster |
55
+ | 2x | Learning | `kind: learning` episode olustur, learnings/ dosyasina yaz |
56
+ | 3x+ | Nomination | `kind: nomination, status: staged, source: reflect` episode olustur |
57
+
58
+ 6. **Structured report:**
59
+ ```
60
+ -- Reflect Raporu (son {days} gun, {N} episode) --
61
+
62
+ Friction ({count}):
63
+ - {summary} — {repeat_count}x tekrar
64
+
65
+ Discoveries ({count}):
66
+ - {summary}
67
+
68
+ Patterns:
69
+ - "{pattern}" -> 3x tekrar -> NOMINATION (staged)
70
+ - "{pattern}" -> 2x tekrar -> LEARNING
71
+ - "{pattern}" -> 1x -> NOTE
72
+
73
+ Onerilen:
74
+ [ ] {rule} ({repeat_count}x, {confidence} confidence)
75
+ ```
76
+
77
+ 7. **Nomination creation (3x+ tekrar):**
78
+ ```sql
79
+ INSERT INTO episodes (summary, body, kind, status, source, project, created_at)
80
+ VALUES (?, ?, 'nomination', 'staged', 'reflect', ?, ?)
81
+ ```
82
+
83
+ 8. **Nomination approval flow:**
84
+ User approves -> `status: staged -> approved` -> write to target:
85
+ - `learnings` -> `learnings/{topic}.md`
86
+ - `claude.md` -> project CLAUDE.md'ye kural ekle
87
+ - `domain:{slug}` -> ilgili domain sayfasina ekle
88
+
89
+ User rejects -> `status: staged -> rejected` + rejection reason
90
+
91
+ ## On End — Write skill_memory
92
+
93
+ ```bash
94
+ node dist/scripts/lib/skill-memory.js set mindlore-reflect last_reflect_date "$(date -I)"
95
+ node dist/scripts/lib/skill-memory.js set mindlore-reflect nomination_count "{staged_count}"
96
+ ```
97
+
98
+ ## Rules
99
+
100
+ - NEVER write learnings or nominations without user approval
101
+ - Group related patterns into existing topic files
102
+ - Reflect READS episodes, diary WRITES episodes — clear separation
103
+ - Mark processed episodes so future reflect skips them
104
+ - Append to `log.md`: `| {date} | reflect | {N} episodes processed, {M} learnings written |`
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "0.5.1",
2
+ "version": "0.5.2",
3
3
  "models": {
4
4
  "ingest": "haiku",
5
5
  "evolve": "sonnet",