ralph-hero-knowledge-index 0.1.49 → 0.1.51

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.
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ralph-knowledge",
3
- "version": "0.1.49",
3
+ "version": "0.1.51",
4
4
  "description": "Knowledge graph for ralph-hero: semantic search, relationship traversal, and document indexing across thoughts/ documents. Optional companion to ralph-hero.",
5
5
  "author": {
6
6
  "name": "Chad Dubiel",
package/.mcp.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "mcpServers": {
3
3
  "ralph-knowledge": {
4
4
  "command": "npx",
5
- "args": ["-y", "ralph-hero-knowledge-index@0.1.48"]
5
+ "args": ["-y", "ralph-hero-knowledge-index@0.1.49"]
6
6
  }
7
7
  }
8
8
  }
@@ -940,7 +940,7 @@ export function chunkText(text: string, opts: ChunkerOptions = {}): Chunk[] {
940
940
  <div class='footer quiet pad2 space-top1 center small'>
941
941
  Code coverage generated by
942
942
  <a href="https://istanbul.js.org/" target="_blank" rel="noopener noreferrer">istanbul</a>
943
- at 2026-05-25T14:17:29.291Z
943
+ at 2026-06-09T20:48:57.716Z
944
944
  </div>
945
945
  <script src="prettify.js"></script>
946
946
  <script>
@@ -385,7 +385,7 @@ export function loadConfig(): KnowledgeConfig {
385
385
  <div class='footer quiet pad2 space-top1 center small'>
386
386
  Code coverage generated by
387
387
  <a href="https://istanbul.js.org/" target="_blank" rel="noopener noreferrer">istanbul</a>
388
- at 2026-05-25T14:17:29.291Z
388
+ at 2026-06-09T20:48:57.716Z
389
389
  </div>
390
390
  <script src="prettify.js"></script>
391
391
  <script>
@@ -1897,7 +1897,7 @@ export class KnowledgeDB {
1897
1897
  <div class='footer quiet pad2 space-top1 center small'>
1898
1898
  Code coverage generated by
1899
1899
  <a href="https://istanbul.js.org/" target="_blank" rel="noopener noreferrer">istanbul</a>
1900
- at 2026-05-25T14:17:29.291Z
1900
+ at 2026-06-09T20:48:57.716Z
1901
1901
  </div>
1902
1902
  <script src="prettify.js"></script>
1903
1903
  <script>
@@ -763,7 +763,7 @@ export function prepareTextForEmbedding(
763
763
  <div class='footer quiet pad2 space-top1 center small'>
764
764
  Code coverage generated by
765
765
  <a href="https://istanbul.js.org/" target="_blank" rel="noopener noreferrer">istanbul</a>
766
- at 2026-05-25T14:17:29.291Z
766
+ at 2026-06-09T20:48:57.716Z
767
767
  </div>
768
768
  <script src="prettify.js"></script>
769
769
  <script>
@@ -199,7 +199,7 @@ export function findMarkdownFiles(dir: string, matcher?: IgnoreMatcher): string[
199
199
  <div class='footer quiet pad2 space-top1 center small'>
200
200
  Code coverage generated by
201
201
  <a href="https://istanbul.js.org/" target="_blank" rel="noopener noreferrer">istanbul</a>
202
- at 2026-05-25T14:17:29.291Z
202
+ at 2026-06-09T20:48:57.716Z
203
203
  </div>
204
204
  <script src="prettify.js"></script>
205
205
  <script>
@@ -295,7 +295,7 @@ export function formatTraverseResults(
295
295
  <div class='footer quiet pad2 space-top1 center small'>
296
296
  Code coverage generated by
297
297
  <a href="https://istanbul.js.org/" target="_blank" rel="noopener noreferrer">istanbul</a>
298
- at 2026-05-25T14:17:29.291Z
298
+ at 2026-06-09T20:48:57.716Z
299
299
  </div>
300
300
  <script src="prettify.js"></script>
301
301
  <script>
@@ -946,7 +946,7 @@ export function generateIndexes(outDir: string, allDocs: ParsedDocument[]): void
946
946
  <div class='footer quiet pad2 space-top1 center small'>
947
947
  Code coverage generated by
948
948
  <a href="https://istanbul.js.org/" target="_blank" rel="noopener noreferrer">istanbul</a>
949
- at 2026-05-25T14:17:29.291Z
949
+ at 2026-06-09T20:48:57.716Z
950
950
  </div>
951
951
  <script src="prettify.js"></script>
952
952
  <script>
@@ -292,7 +292,7 @@ export class GraphBuilder {
292
292
  <div class='footer quiet pad2 space-top1 center small'>
293
293
  Code coverage generated by
294
294
  <a href="https://istanbul.js.org/" target="_blank" rel="noopener noreferrer">istanbul</a>
295
- at 2026-05-25T14:17:29.291Z
295
+ at 2026-06-09T20:48:57.716Z
296
296
  </div>
297
297
  <script src="prettify.js"></script>
298
298
  <script>
@@ -2821,7 +2821,7 @@ export function registerGraphTools(server: McpServer, db: KnowledgeDB): void {
2821
2821
  <div class='footer quiet pad2 space-top1 center small'>
2822
2822
  Code coverage generated by
2823
2823
  <a href="https://istanbul.js.org/" target="_blank" rel="noopener noreferrer">istanbul</a>
2824
- at 2026-05-25T14:17:29.291Z
2824
+ at 2026-06-09T20:48:57.716Z
2825
2825
  </div>
2826
2826
  <script src="prettify.js"></script>
2827
2827
  <script>
@@ -1606,7 +1606,7 @@ export class HybridSearch {
1606
1606
  <div class='footer quiet pad2 space-top1 center small'>
1607
1607
  Code coverage generated by
1608
1608
  <a href="https://istanbul.js.org/" target="_blank" rel="noopener noreferrer">istanbul</a>
1609
- at 2026-05-25T14:17:29.291Z
1609
+ at 2026-06-09T20:48:57.716Z
1610
1610
  </div>
1611
1611
  <script src="prettify.js"></script>
1612
1612
  <script>
@@ -316,7 +316,7 @@ export function loadIgnoreForRoot(
316
316
  <div class='footer quiet pad2 space-top1 center small'>
317
317
  Code coverage generated by
318
318
  <a href="https://istanbul.js.org/" target="_blank" rel="noopener noreferrer">istanbul</a>
319
- at 2026-05-25T14:17:29.291Z
319
+ at 2026-06-09T20:48:57.716Z
320
320
  </div>
321
321
  <script src="prettify.js"></script>
322
322
  <script>
@@ -371,7 +371,7 @@
371
371
  <div class='footer quiet pad2 space-top1 center small'>
372
372
  Code coverage generated by
373
373
  <a href="https://istanbul.js.org/" target="_blank" rel="noopener noreferrer">istanbul</a>
374
- at 2026-05-25T14:17:29.291Z
374
+ at 2026-06-09T20:48:57.716Z
375
375
  </div>
376
376
  <script src="prettify.js"></script>
377
377
  <script>
@@ -2515,7 +2515,7 @@ server.connect(transport).catch(console.error);
2515
2515
  <div class='footer quiet pad2 space-top1 center small'>
2516
2516
  Code coverage generated by
2517
2517
  <a href="https://istanbul.js.org/" target="_blank" rel="noopener noreferrer">istanbul</a>
2518
- at 2026-05-25T14:17:29.291Z
2518
+ at 2026-06-09T20:48:57.716Z
2519
2519
  </div>
2520
2520
  <script src="prettify.js"></script>
2521
2521
  <script>
@@ -478,7 +478,7 @@ export function createLlmClient(opts: LlmClientOptions = {}): LlmClient {
478
478
  <div class='footer quiet pad2 space-top1 center small'>
479
479
  Code coverage generated by
480
480
  <a href="https://istanbul.js.org/" target="_blank" rel="noopener noreferrer">istanbul</a>
481
- at 2026-05-25T14:17:29.291Z
481
+ at 2026-06-09T20:48:57.716Z
482
482
  </div>
483
483
  <script src="prettify.js"></script>
484
484
  <script>
@@ -565,7 +565,7 @@ export function parseDocument(id: string, path: string, raw: string): ParsedDocu
565
565
  <div class='footer quiet pad2 space-top1 center small'>
566
566
  Code coverage generated by
567
567
  <a href="https://istanbul.js.org/" target="_blank" rel="noopener noreferrer">istanbul</a>
568
- at 2026-05-25T14:17:29.291Z
568
+ at 2026-06-09T20:48:57.716Z
569
569
  </div>
570
570
  <script src="prettify.js"></script>
571
571
  <script>
@@ -2032,7 +2032,7 @@ const isMain = process.argv[1]?.endsWith("reindex.js");
2032
2032
  <div class='footer quiet pad2 space-top1 center small'>
2033
2033
  Code coverage generated by
2034
2034
  <a href="https://istanbul.js.org/" target="_blank" rel="noopener noreferrer">istanbul</a>
2035
- at 2026-05-25T14:17:29.291Z
2035
+ at 2026-06-09T20:48:57.716Z
2036
2036
  </div>
2037
2037
  <script src="prettify.js"></script>
2038
2038
  <script>
@@ -790,7 +790,7 @@ export class Reranker {
790
790
  <div class='footer quiet pad2 space-top1 center small'>
791
791
  Code coverage generated by
792
792
  <a href="https://istanbul.js.org/" target="_blank" rel="noopener noreferrer">istanbul</a>
793
- at 2026-05-25T14:17:29.291Z
793
+ at 2026-06-09T20:48:57.716Z
794
794
  </div>
795
795
  <script src="prettify.js"></script>
796
796
  <script>
@@ -814,7 +814,7 @@ export class FtsSearch {
814
814
  <div class='footer quiet pad2 space-top1 center small'>
815
815
  Code coverage generated by
816
816
  <a href="https://istanbul.js.org/" target="_blank" rel="noopener noreferrer">istanbul</a>
817
- at 2026-05-25T14:17:29.291Z
817
+ at 2026-06-09T20:48:57.716Z
818
818
  </div>
819
819
  <script src="prettify.js"></script>
820
820
  <script>
@@ -487,7 +487,7 @@ export class Traverser {
487
487
  <div class='footer quiet pad2 space-top1 center small'>
488
488
  Code coverage generated by
489
489
  <a href="https://istanbul.js.org/" target="_blank" rel="noopener noreferrer">istanbul</a>
490
- at 2026-05-25T14:17:29.291Z
490
+ at 2026-06-09T20:48:57.716Z
491
491
  </div>
492
492
  <script src="prettify.js"></script>
493
493
  <script>
@@ -439,7 +439,7 @@ export class VectorSearch {
439
439
  <div class='footer quiet pad2 space-top1 center small'>
440
440
  Code coverage generated by
441
441
  <a href="https://istanbul.js.org/" target="_blank" rel="noopener noreferrer">istanbul</a>
442
- at 2026-05-25T14:17:29.291Z
442
+ at 2026-06-09T20:48:57.716Z
443
443
  </div>
444
444
  <script src="prettify.js"></script>
445
445
  <script>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ralph-hero-knowledge-index",
3
- "version": "0.1.49",
3
+ "version": "0.1.51",
4
4
  "type": "module",
5
5
  "main": "dist/index.js",
6
6
  "bin": {
@@ -0,0 +1,77 @@
1
+ ---
2
+ description: Run the dream-loop — the nightly memory-consolidation pipeline that ingests the last window of raw activity (Gemma lab logs, git history, llm-cli transcripts) as memory_tier=raw documents, then clusters them and synthesizes one memory_tier=reflection per cluster. This is the memorykeepers surface that orchestrates the existing scripts/dream/ infra (ingest.py + reflect.py + logrotate.sh) on demand. Use when the user mentions "dream", "dream-loop", "consolidate memories", "run reflection", "memorykeepers", "ingest raw memories", or wants to manually trigger the memory tiers (raw to reflection) without waiting for the 03:00 launchd fire. The launchd nightly schedule and the model-gate dream-now zsh function are separate; this skill is the in-session manual entrypoint.
3
+ argument-hint: "[--since 24h]"
4
+ ---
5
+
6
+ # Dream-Loop — Memory Consolidation (memorykeepers)
7
+
8
+ The dream-loop is the memory-consolidation pipeline for ralph-knowledge. It pulls raw activity into `memory_tier=raw` documents, then clusters them (UMAP/HDBSCAN) and asks a local model to synthesize one `memory_tier=reflection` per cluster. This skill is the in-session manual entrypoint that the memorykeepers team owns.
9
+
10
+ ## How you talk
11
+
12
+ You are a librarian. Cite the memory tier and the path for every operation. State promotion/synthesis decisions as facts, not recommendations, and always include the verification step that preceded the operation.
13
+
14
+ - **Bad:** "This reflection looks good enough to promote."
15
+ - **Good:** "Wrote `reflections/2026-05/cluster-7.md` (memory_tier=reflection). Verification: clustered from 3 raw sources under `dream-memories/2026/05/`, no contradictions found."
16
+
17
+ You refuse to:
18
+ - promote unverified reflections to the wiki tier (that is the human-gated `/ralph-knowledge:curate` surface, not this one)
19
+ - discard raw memories without an outcome record
20
+
21
+ ## Prerequisites
22
+
23
+ 1. **Dream scripts present.** The pipeline lives at the repo root in `scripts/dream/` (`ingest.py`, `reflect.py`, `logrotate.sh`). It is NOT bundled inside this plugin — this skill orchestrates the repo-root scripts.
24
+ 2. **Python deps installed.** `cd <repo>/scripts/dream && uv sync` (one-time).
25
+ 3. **`~/.ralph/knowledge.config.json` authored** with the `roots` to scan and `dbPath`.
26
+ 4. **A local model reachable** at `RALPH_LLM_URL` (default `http://localhost:8000`) for the reflection synthesis step. If the model is unreachable, the pipeline fails open: empty reflections and a single stderr warning — raw ingest still succeeds.
27
+
28
+ If `scripts/dream/` is absent, surface a clear error and stop: the dream-loop infra has not been set up. Direct the user to `/ralph-knowledge:setup` (which installs the launchd schedule and can bootstrap the scripts).
29
+
30
+ ## Workflow
31
+
32
+ ### Step 1: Resolve the window
33
+
34
+ Parse `--since` from the arguments (default `24h`). This bounds how far back `ingest.py` pulls raw activity.
35
+
36
+ ### Step 2: Locate the dream scripts
37
+
38
+ Find the repo root and confirm `scripts/dream/ingest.py` and `scripts/dream/reflect.py` exist. Cite the resolved path.
39
+
40
+ ### Step 3: Ingest raw memories
41
+
42
+ ```bash
43
+ cd <repo>/scripts/dream
44
+ uv run ingest.py --since <WINDOW>
45
+ ```
46
+
47
+ `ingest.py` writes markdown under `memory_tier=raw` to `~/projects/thoughts/dream-memories/YYYY/MM/DD/`. Report the count of raw documents written and the path.
48
+
49
+ ### Step 4: Synthesize reflections
50
+
51
+ ```bash
52
+ uv run reflect.py --since <WINDOW>
53
+ ```
54
+
55
+ `reflect.py` clusters the raw memories and writes `memory_tier=reflection` synthesis documents to `.../dream-memories/reflections/YYYY/MM/DD/`. If a local model id is known (e.g. via `RALPH_DREAM_MODEL`), pass it with `--model`. Report the number of clusters and reflections written, and each reflection path.
56
+
57
+ ### Step 5: Rotate logs
58
+
59
+ ```bash
60
+ ./logrotate.sh
61
+ ```
62
+
63
+ Caps the pipeline log files so repeated runs do not grow unbounded.
64
+
65
+ ### Step 6: Report
66
+
67
+ State, as facts with paths and tiers:
68
+ - raw documents ingested (count + `dream-memories/YYYY/MM/DD/`)
69
+ - reflections synthesized (count + `reflections/YYYY/MM/DD/`)
70
+ - any clusters that crossed the recurring-failure thresholds and would warrant a `process-improvement` follow-up
71
+ - whether the local model was reachable, or whether the run failed open
72
+
73
+ ## Relationship to other surfaces
74
+
75
+ - **Nightly schedule** — `scripts/dream/launchd/com.dubiel.dream-loop.plist.template`, installed by `/ralph-knowledge:setup` (or `bootstrap.sh`). Fires at 03:00 daily. This skill is the manual on-demand counterpart.
76
+ - **`dream-now`** — a model-gate zsh function that is gate-aware (loads the model first, then ingest + reflect + logrotate). Owned by model-gate, not this plugin. This skill does not call `dream-now`; it invokes the scripts directly.
77
+ - **`/ralph-knowledge:curate`** — the human-gated promotion of reflections into the personal wiki tier. The dream-loop produces reflections; curate (not this skill) decides what becomes canonical.
@@ -923,7 +923,10 @@ describe("knowledge_expert", () => {
923
923
  it("returns wiki + reflection buckets filtered by domain tag", async () => {
924
924
  const mod = await import("../index.js");
925
925
  const { server, db } = mod.createServer(":memory:");
926
- // Seed: one wiki doc and one reflection, both tagged 'auth'
926
+ // Seed: one wiki doc and one reflection, both tagged 'auth'. The
927
+ // reflection date must be computed relative to now — the default
928
+ // recency_window_days is 30, so a hardcoded date ages out of the window.
929
+ const recentReflDate = new Date(Date.now() - 5 * 86_400_000).toISOString().slice(0, 10);
927
930
  db.upsertDocument({
928
931
  id: "wiki-auth",
929
932
  path: "thoughts/wiki/auth.md",
@@ -939,7 +942,7 @@ describe("knowledge_expert", () => {
939
942
  id: "refl-auth",
940
943
  path: "thoughts/dream-memories/2026/05/refl.md",
941
944
  title: "Auth reflection",
942
- date: "2026-05-10",
945
+ date: recentReflDate,
943
946
  type: null,
944
947
  status: null,
945
948
  githubIssue: null,