@lotargo/memory_plugin 1.1.4 → 1.1.6

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,122 +1,122 @@
1
- ---
2
- name: using-memory
3
- description: Comprehensive guide for using the Memory & Hybrid RAG Knowledge Engine tools (remember, recall, forget, ingest_document, query_knowledge_base, manage_knowledge_base). Trigger whenever remembering user preferences/conventions, querying ingested documentation, indexing files/repos, or managing persistent knowledge.
4
- ---
5
-
6
- # Using Memory & Hybrid RAG Knowledge Engine
7
-
8
- You have access to a persistent dual-layer memory engine supercharged with an **Agent-Driven Knowledge Graph**:
9
- 1. **Layer 1: Notebook Store (Key-Value Facts)**: Stores high-signal personal preferences, project conventions, and durable rules in clean Markdown.
10
- 2. **Layer 2: RAG Knowledge Base**: Indexes documentation, repositories, and technical guides for hybrid semantic retrieval.
11
- 3. **Layer 3: Agent-Driven Knowledge Graph**: Connects Notebook facts (Layer 1) to specific Knowledge Base documents, sections, and **exact line ranges** (Layer 2).
12
-
13
- ---
14
-
15
- ## 1. Tool Selection Decision Matrix
16
-
17
- | Scenario / Intent | Target Tool | Key Parameters |
18
- |-------------------|-------------|----------------|
19
- | User shares identity, tech stack preference, or workflow rule | `remember` | `fact` (English), `scope`, optional `docId`, `startLine`, `endLine` |
20
- | User asks what you remember about them, the project, or linked docs | `recall` | `scope` ("all", "global", or "project") |
21
- | User corrects/updates an old saved fact | `forget` then `remember` | `query` (text or index number) |
22
- | Connect a Notebook fact to a document, section, or line range | `link_knowledge` | `factText`, `docId`, `startLine`, `endLine`, `relationType` |
23
- | User asks to index a documentation URL, file, or repository | `ingest_document` | `content` or `source_path`, `title`, `metadata` |
24
- | User asks a complex question about indexed docs or code | `query_knowledge_base` | `query`, `limit`, `generateEmbeddings` |
25
- | Read full raw content of an ambiguous/abstract document | `manage_knowledge_base` | `action: "read_document"`, `docId` |
26
- | User asks to view database stats, list indexed docs, or export snapshots | `manage_knowledge_base` | `action` ("stats", "list", "read_document", "delete", "export_snapshot") |
27
-
28
- ---
29
-
30
- ## 2. Layer 1 & 3: Notebook Store & Agent-Driven Knowledge Graph (`remember`, `recall`, `link_knowledge`)
31
-
32
- ### Agent-Driven Knowledge Graph Architecture
33
- Automatic regex/heuristic algorithms alone CANNOT infer high-level semantic intent or cross-document relationships. **You (the AI Agent) are the primary architect of the Knowledge Graph.**
34
-
35
- Whenever you ingest project documentation, web pages, or local files, you should link durable facts in the Notebook store directly to the corresponding RAG documents and exact line ranges.
36
-
37
- ### What to Save and Link (`remember` & `link_knowledge`)
38
- - **High-Signal Facts**: User name, role, language preferences, architectural constraints, framework choices, coding standards, test rules.
39
- - **Formating**: Always translate the fact into clear, concise English before calling `remember`.
40
- - **Linking to Knowledge Base Documents**:
41
- - Pass `docId` (or document title/path) and optional `startLine` / `endLine` when calling `remember` or `link_knowledge`.
42
- - Example: `remember(fact: "Use Fastify instead of Express for backend services", scope: "project", docId: "arch_specs.md", startLine: 5, endLine: 7)`
43
- - Example: `link_knowledge(factText: "Use PostgreSQL 16 for primary persistence", docId: "database_guide.md", startLine: 20, endLine: 35, relationType: "IMPLEMENTS")`
44
-
45
- ### How Linked Memory Appears (`recall`)
46
- When `recall` is invoked, the engine returns saved facts along with their Agent-linked Knowledge Base documents and exact line ranges:
47
- ```
48
- --- memory_plugin ---
49
- 1. Use Fastify instead of Express for backend services 🔗 [Linked Docs: Project Architecture Specs:L5-7]
50
- 2. PostgreSQL 16 is primary database 🔗 [Linked Docs: database_guide.md:L20-35]
51
- ```
52
-
53
- ---
54
-
55
- ## 3. Layer 2: RAG Knowledge Base (`ingest_document`, `query_knowledge_base`, `manage_knowledge_base`)
56
-
57
- ### Document Ingestion (`ingest_document`)
58
- Use this tool when adding technical documentation, API specs, architectural documents, or code repos into the searchable knowledge base.
59
- - **Hierarchy Chunking**: The engine automatically creates 3-tier chunks (Big Document -> Medium Section -> Small Micro-Chunk) and extracts GraphRAG code symbols.
60
- - **Auto Vector Embeddings**: Dense ONNX vectors (`multilingual-e5-small`) are automatically computed and indexed in SQLite.
61
- - **CRITICAL Schema Usage & Parameters**:
62
- - `content` (required, string): Must be the **actual raw text or markdown content** of the document, NOT just a file path!
63
- - `type` (optional, enum: `"text"`, `"file"`, `"url"`): Set to `"text"` (default) or `"file"`.
64
- - `path` (optional, string): Provide the absolute file path (e.g. `f:\projects\plugins\memory\README.md`).
65
- - `title` (optional, string): Provide document title (e.g. `README.md`).
66
- - **Correct Example**: `ingest_document(content: "<full text content>", path: "f:/path/to/file.md", title: "file.md", type: "file")`
67
- - ❌ **Common Error**: `ingest_document(content: "f:/path/to/file.md")` — this causes validation failures because `content` is missing the text content.
68
-
69
- - **CLI/Script Execution Note**: When writing batch node scripts to call `ingestDocument`, remember that `@lotargo/memory_plugin` uses ES Modules (`"type": "module"`). Use `import` syntax instead of `require()`.
70
-
71
- ### Hybrid Retrieval (`query_knowledge_base`)
72
- Use this tool BEFORE answering deep architectural or technical questions when indexed documents exist.
73
- - Performs **Hybrid RRF Fusion** combining SQLite FTS5 BM25 keyword matching with dense ONNX vector semantic search.
74
- - Returns candidate sections with breadcrumb paths and defined code symbols (classes, functions, types).
75
-
76
- #### Query Formulation Rules (CRITICAL for retrieval quality)
77
-
78
- The hybrid engine combines BM25 full-text keyword matching with dense ONNX vector search (`multilingual-e5-small`). Formulate queries according to these rules:
79
-
80
- **Rule 1 — Use Concept-Dense Declarative Phrases (POSITIVE EXAMPLES)**
81
- Formulate queries as concise, factual concept statements.
82
- - ✅ `"Библиотека для выполнения HTTP запросов и отмены отправки данных"`
83
- - ✅ `"Автоматизация сценариев пользователя в браузере и проверка веб-страниц"`
84
- - ✅ `"createStore combineReducers управление состоянием приложения Redux"`
85
-
86
- **Rule 2 — DO NOT Use Conversational Questions (NEGATIVE EXAMPLES)**
87
- - ❌ **DO NOT** ask conversational questions: *"Что такое Next.js и как его настроить?"*, *"Как мне сделать отмену запроса в axios?"*, *"Подскажи пожалуйста где про базу данных?"*. Conversational filler words (*"как"*, *"что такое"*, *"где"*, *"подскажи"*) pollute BM25 lexical tokens and add noise to vector embeddings!
88
- - ❌ **DO NOT** copy raw code signatures with exact dots verbatim (`browser.newPage page.goto expect.toBeVisible`) unless searching specifically for an exact symbol name.
89
- - ❌ **DO NOT** use long rambling conversational turns. Keep queries concise (10-30 words).
90
-
91
- **Rule 3 — Combine Exact Code Symbols + Semantic Intent**
92
- - Good: `"isCancel AxiosError библиотека HTTP запросов отмена"`
93
- - Good: `"useReducer useContext React component state management"`
94
-
95
- ---
96
-
97
- ### Reading Ambiguous or Abstract Documents ("Ода о единороге" Scenario)
98
-
99
- When documents have abstract, non-descriptive, or unpredictable titles/contents (e.g. *"Ода о единороге"*, *"Заметки_2026"*, *"Планы_проекта"*), searching via `query_knowledge_base` may fail if the user or agent cannot guess what terms are inside.
100
-
101
- In such cases, use the **Full Raw Document Reading** mechanism:
102
-
103
- 1. **Discover Ingested Documents**: Call `manage_knowledge_base(action: "list")` to see all ingested document IDs, titles, and paths.
104
- 2. **Read Full Raw Document Content**: Call `manage_knowledge_base(action: "read_document", docId: "<doc_id_or_title>")`.
105
- 3. **Analyze Content**: The server retrieves and decompresses the complete raw text document from CAS blob storage, allowing you to read and understand the entire document regardless of its title.
106
-
107
- ---
108
-
109
- ### Knowledge Base Management (`manage_knowledge_base`)
110
- - Use `action: "stats"` to inspect stored document count and total micro-chunks.
111
- - Use `action: "list"` to see all ingested documents.
112
- - Use `action: "read_document"` with `docId` to read the complete raw text content of any document.
113
- - Use `action: "delete"` with `docId` to remove an outdated document and purge its CAS blob.
114
-
115
- ---
116
-
117
- ## 4. Core Directives for AI Agents
118
-
119
- 1. **Be Proactive**: When the user mentions a durable preference or constraint, save it immediately using `remember`.
120
- 2. **Check Knowledge Base First**: If a user asks how a specific module, API, or project architecture works, call `query_knowledge_base` using concept-dense search phrases.
121
- 3. **Inspect Ambiguous Docs Directly**: If querying produces low relevance scores on abstractly-named documents, call `manage_knowledge_base(action: "read_document")` to inspect the full text directly.
122
- 4. **Keep Memory Clean**: If a preference changes, call `forget` on the outdated entry before saving the new one.
1
+ ---
2
+ name: using-memory
3
+ description: Comprehensive guide for using the Memory & Hybrid RAG Knowledge Engine tools (remember, recall, forget, ingest_document, query_knowledge_base, manage_knowledge_base). Trigger whenever remembering user preferences/conventions, querying ingested documentation, indexing files/repos, or managing persistent knowledge.
4
+ ---
5
+
6
+ # Using Memory & Hybrid RAG Knowledge Engine
7
+
8
+ You have access to a persistent dual-layer memory engine supercharged with an **Agent-Driven Knowledge Graph**:
9
+ 1. **Layer 1: Notebook Store (Key-Value Facts)**: Stores high-signal personal preferences, project conventions, and durable rules in clean Markdown.
10
+ 2. **Layer 2: RAG Knowledge Base**: Indexes documentation, repositories, and technical guides for hybrid semantic retrieval.
11
+ 3. **Layer 3: Agent-Driven Knowledge Graph**: Connects Notebook facts (Layer 1) to specific Knowledge Base documents, sections, and **exact line ranges** (Layer 2).
12
+
13
+ ---
14
+
15
+ ## 1. Tool Selection Decision Matrix
16
+
17
+ | Scenario / Intent | Target Tool | Key Parameters |
18
+ |-------------------|-------------|----------------|
19
+ | User shares identity, tech stack preference, or workflow rule | `remember` | `fact` (English), `scope`, optional `docId`, `startLine`, `endLine` |
20
+ | User asks what you remember about them, the project, or linked docs | `recall` | `scope` ("all", "global", or "project") |
21
+ | User corrects/updates an old saved fact | `forget` then `remember` | `query` (text or index number) |
22
+ | Connect a Notebook fact to a document, section, or line range | `link_knowledge` | `factText`, `docId`, `startLine`, `endLine`, `relationType` |
23
+ | User asks to index a documentation URL, file, or repository | `ingest_document` | `content` or `source_path`, `title`, `metadata` |
24
+ | User asks a complex question about indexed docs or code | `query_knowledge_base` | `query`, `limit`, `generateEmbeddings` |
25
+ | Read full raw content of an ambiguous/abstract document | `manage_knowledge_base` | `action: "read_document"`, `docId` |
26
+ | User asks to view database stats, list indexed docs, or export snapshots | `manage_knowledge_base` | `action` ("stats", "list", "read_document", "delete", "export_snapshot") |
27
+
28
+ ---
29
+
30
+ ## 2. Layer 1 & 3: Notebook Store & Agent-Driven Knowledge Graph (`remember`, `recall`, `link_knowledge`)
31
+
32
+ ### Agent-Driven Knowledge Graph Architecture
33
+ Automatic regex/heuristic algorithms alone CANNOT infer high-level semantic intent or cross-document relationships. **You (the AI Agent) are the primary architect of the Knowledge Graph.**
34
+
35
+ Whenever you ingest project documentation, web pages, or local files, you should link durable facts in the Notebook store directly to the corresponding RAG documents and exact line ranges.
36
+
37
+ ### What to Save and Link (`remember` & `link_knowledge`)
38
+ - **High-Signal Facts**: User name, role, language preferences, architectural constraints, framework choices, coding standards, test rules.
39
+ - **Formating**: Always translate the fact into clear, concise English before calling `remember`.
40
+ - **Linking to Knowledge Base Documents**:
41
+ - Pass `docId` (or document title/path) and optional `startLine` / `endLine` when calling `remember` or `link_knowledge`.
42
+ - Example: `remember(fact: "Use Fastify instead of Express for backend services", scope: "project", docId: "arch_specs.md", startLine: 5, endLine: 7)`
43
+ - Example: `link_knowledge(factText: "Use PostgreSQL 16 for primary persistence", docId: "database_guide.md", startLine: 20, endLine: 35, relationType: "IMPLEMENTS")`
44
+
45
+ ### How Linked Memory Appears (`recall`)
46
+ When `recall` is invoked, the engine returns saved facts along with their Agent-linked Knowledge Base documents and exact line ranges:
47
+ ```
48
+ --- memory_plugin ---
49
+ 1. Use Fastify instead of Express for backend services 🔗 [Linked Docs: Project Architecture Specs:L5-7]
50
+ 2. PostgreSQL 16 is primary database 🔗 [Linked Docs: database_guide.md:L20-35]
51
+ ```
52
+
53
+ ---
54
+
55
+ ## 3. Layer 2: RAG Knowledge Base (`ingest_document`, `query_knowledge_base`, `manage_knowledge_base`)
56
+
57
+ ### Document Ingestion (`ingest_document`)
58
+ Use this tool when adding technical documentation, API specs, architectural documents, or code repos into the searchable knowledge base.
59
+ - **Hierarchy Chunking**: The engine automatically creates 3-tier chunks (Big Document -> Medium Section -> Small Micro-Chunk) and extracts GraphRAG code symbols.
60
+ - **Auto Vector Embeddings**: Dense ONNX vectors (`multilingual-e5-small`) are automatically computed and indexed in SQLite.
61
+ - **CRITICAL Schema Usage & Parameters**:
62
+ - `content` (required, string): Must be the **actual raw text or markdown content** of the document, NOT just a file path!
63
+ - `type` (optional, enum: `"text"`, `"file"`, `"url"`): Set to `"text"` (default) or `"file"`.
64
+ - `path` (optional, string): Provide the absolute file path (e.g. `f:\projects\plugins\memory\README.md`).
65
+ - `title` (optional, string): Provide document title (e.g. `README.md`).
66
+ - **Correct Example**: `ingest_document(content: "<full text content>", path: "f:/path/to/file.md", title: "file.md", type: "file")`
67
+ - ❌ **Common Error**: `ingest_document(content: "f:/path/to/file.md")` — this causes validation failures because `content` is missing the text content.
68
+
69
+ - **CLI/Script Execution Note**: When writing batch node scripts to call `ingestDocument`, remember that `@lotargo/memory_plugin` uses ES Modules (`"type": "module"`). Use `import` syntax instead of `require()`.
70
+
71
+ ### Hybrid Retrieval (`query_knowledge_base`)
72
+ Use this tool BEFORE answering deep architectural or technical questions when indexed documents exist.
73
+ - Performs **Hybrid RRF Fusion** combining SQLite FTS5 BM25 keyword matching with dense ONNX vector semantic search.
74
+ - Returns candidate sections with breadcrumb paths and defined code symbols (classes, functions, types).
75
+
76
+ #### Query Formulation Rules (CRITICAL for retrieval quality)
77
+
78
+ The hybrid engine combines BM25 full-text keyword matching with dense ONNX vector search (`multilingual-e5-small`). Formulate queries according to these rules:
79
+
80
+ **Rule 1 — Use Concept-Dense Declarative Phrases (POSITIVE EXAMPLES)**
81
+ Formulate queries as concise, factual concept statements.
82
+ - ✅ `"Библиотека для выполнения HTTP запросов и отмены отправки данных"`
83
+ - ✅ `"Автоматизация сценариев пользователя в браузере и проверка веб-страниц"`
84
+ - ✅ `"createStore combineReducers управление состоянием приложения Redux"`
85
+
86
+ **Rule 2 — DO NOT Use Conversational Questions (NEGATIVE EXAMPLES)**
87
+ - ❌ **DO NOT** ask conversational questions: *"Что такое Next.js и как его настроить?"*, *"Как мне сделать отмену запроса в axios?"*, *"Подскажи пожалуйста где про базу данных?"*. Conversational filler words (*"как"*, *"что такое"*, *"где"*, *"подскажи"*) pollute BM25 lexical tokens and add noise to vector embeddings!
88
+ - ❌ **DO NOT** copy raw code signatures with exact dots verbatim (`browser.newPage page.goto expect.toBeVisible`) unless searching specifically for an exact symbol name.
89
+ - ❌ **DO NOT** use long rambling conversational turns. Keep queries concise (10-30 words).
90
+
91
+ **Rule 3 — Combine Exact Code Symbols + Semantic Intent**
92
+ - Good: `"isCancel AxiosError библиотека HTTP запросов отмена"`
93
+ - Good: `"useReducer useContext React component state management"`
94
+
95
+ ---
96
+
97
+ ### Reading Ambiguous or Abstract Documents ("Ода о единороге" Scenario)
98
+
99
+ When documents have abstract, non-descriptive, or unpredictable titles/contents (e.g. *"Ода о единороге"*, *"Заметки_2026"*, *"Планы_проекта"*), searching via `query_knowledge_base` may fail if the user or agent cannot guess what terms are inside.
100
+
101
+ In such cases, use the **Full Raw Document Reading** mechanism:
102
+
103
+ 1. **Discover Ingested Documents**: Call `manage_knowledge_base(action: "list")` to see all ingested document IDs, titles, and paths.
104
+ 2. **Read Full Raw Document Content**: Call `manage_knowledge_base(action: "read_document", docId: "<doc_id_or_title>")`.
105
+ 3. **Analyze Content**: The server retrieves and decompresses the complete raw text document from CAS blob storage, allowing you to read and understand the entire document regardless of its title.
106
+
107
+ ---
108
+
109
+ ### Knowledge Base Management (`manage_knowledge_base`)
110
+ - Use `action: "stats"` to inspect stored document count and total micro-chunks.
111
+ - Use `action: "list"` to see all ingested documents.
112
+ - Use `action: "read_document"` with `docId` to read the complete raw text content of any document.
113
+ - Use `action: "delete"` with `docId` to remove an outdated document and purge its CAS blob.
114
+
115
+ ---
116
+
117
+ ## 4. Core Directives for AI Agents
118
+
119
+ 1. **Be Proactive**: When the user mentions a durable preference or constraint, save it immediately using `remember`.
120
+ 2. **Check Knowledge Base First**: If a user asks how a specific module, API, or project architecture works, call `query_knowledge_base` using concept-dense search phrases.
121
+ 3. **Inspect Ambiguous Docs Directly**: If querying produces low relevance scores on abstractly-named documents, call `manage_knowledge_base(action: "read_document")` to inspect the full text directly.
122
+ 4. **Keep Memory Clean**: If a preference changes, call `forget` on the outdated entry before saving the new one.