@danielsimonjr/memoryjs 1.1.0 → 1.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.
package/package.json CHANGED
@@ -1,75 +1,75 @@
1
- {
2
- "name": "@danielsimonjr/memoryjs",
3
- "version": "1.1.0",
4
- "description": "Core knowledge graph library with search, storage, and graph algorithms",
5
- "type": "module",
6
- "main": "dist/index.cjs",
7
- "module": "dist/index.js",
8
- "types": "dist/index.d.ts",
9
- "exports": {
10
- ".": {
11
- "types": "./dist/index.d.ts",
12
- "import": "./dist/index.js",
13
- "require": "./dist/index.cjs"
14
- }
15
- },
16
- "bin": {
17
- "memoryjs": "./dist/index.js"
18
- },
19
- "files": [
20
- "dist",
21
- "README.md",
22
- "LICENSE"
23
- ],
24
- "scripts": {
25
- "build": "tsup",
26
- "build:watch": "tsup --watch",
27
- "build:tsc": "tsc",
28
- "typecheck": "tsc --noEmit",
29
- "test": "vitest run",
30
- "test:watch": "vitest",
31
- "test:coverage": "vitest run --coverage",
32
- "clean": "rimraf dist",
33
- "prepublishOnly": "npm run clean && npm run build && npm run test",
34
- "tools:install": "cd tools/chunking-for-files && npm install && cd ../compress-for-context && npm install && cd ../create-dependency-graph && npm install && cd ../migrate-from-jsonl-to-sqlite && npm install",
35
- "tools:build": "cd tools/chunking-for-files && npm run build && cd ../compress-for-context && npm run build && cd ../create-dependency-graph && npm run build && cd ../migrate-from-jsonl-to-sqlite && npm run build"
36
- },
37
- "keywords": [
38
- "knowledge-graph",
39
- "graph-database",
40
- "entity-management",
41
- "search",
42
- "sqlite",
43
- "jsonl",
44
- "semantic-search",
45
- "hybrid-search"
46
- ],
47
- "author": "Daniel Simon Jr",
48
- "license": "MIT",
49
- "repository": {
50
- "type": "git",
51
- "url": "git+https://github.com/danielsimonjr/memoryjs.git"
52
- },
53
- "bugs": {
54
- "url": "https://github.com/danielsimonjr/memoryjs/issues"
55
- },
56
- "homepage": "https://github.com/danielsimonjr/memoryjs#readme",
57
- "engines": {
58
- "node": ">=18.0.0"
59
- },
60
- "dependencies": {
61
- "@danielsimonjr/workerpool": "^10.0.1",
62
- "async-mutex": "^0.5.0",
63
- "better-sqlite3": "^11.7.0",
64
- "zod": "^3.24.1"
65
- },
66
- "devDependencies": {
67
- "@types/better-sqlite3": "^7.6.12",
68
- "@types/node": "^22.10.5",
69
- "@vitest/coverage-v8": "^4.0.16",
70
- "rimraf": "^6.0.1",
71
- "tsup": "^8.3.5",
72
- "typescript": "^5.7.2",
73
- "vitest": "^4.0.16"
74
- }
75
- }
1
+ {
2
+ "name": "@danielsimonjr/memoryjs",
3
+ "version": "1.2.1",
4
+ "description": "Core knowledge graph library with search, storage, and graph algorithms",
5
+ "type": "module",
6
+ "main": "dist/index.cjs",
7
+ "module": "dist/index.js",
8
+ "types": "dist/index.d.ts",
9
+ "exports": {
10
+ ".": {
11
+ "types": "./dist/index.d.ts",
12
+ "import": "./dist/index.js",
13
+ "require": "./dist/index.cjs"
14
+ }
15
+ },
16
+ "bin": {
17
+ "memoryjs": "./dist/index.js"
18
+ },
19
+ "files": [
20
+ "dist",
21
+ "README.md",
22
+ "LICENSE"
23
+ ],
24
+ "scripts": {
25
+ "build": "tsup",
26
+ "build:watch": "tsup --watch",
27
+ "build:tsc": "tsc",
28
+ "typecheck": "tsc --noEmit",
29
+ "test": "vitest run",
30
+ "test:watch": "vitest",
31
+ "test:coverage": "vitest run --coverage",
32
+ "clean": "rimraf dist",
33
+ "prepublishOnly": "npm run clean && npm run build && npm run test",
34
+ "tools:install": "cd tools/chunking-for-files && npm install && cd ../compress-for-context && npm install && cd ../create-dependency-graph && npm install && cd ../migrate-from-jsonl-to-sqlite && npm install",
35
+ "tools:build": "cd tools/chunking-for-files && npm run build && cd ../compress-for-context && npm run build && cd ../create-dependency-graph && npm run build && cd ../migrate-from-jsonl-to-sqlite && npm run build"
36
+ },
37
+ "keywords": [
38
+ "knowledge-graph",
39
+ "graph-database",
40
+ "entity-management",
41
+ "search",
42
+ "sqlite",
43
+ "jsonl",
44
+ "semantic-search",
45
+ "hybrid-search"
46
+ ],
47
+ "author": "Daniel Simon Jr",
48
+ "license": "MIT",
49
+ "repository": {
50
+ "type": "git",
51
+ "url": "git+https://github.com/danielsimonjr/memoryjs.git"
52
+ },
53
+ "bugs": {
54
+ "url": "https://github.com/danielsimonjr/memoryjs/issues"
55
+ },
56
+ "homepage": "https://github.com/danielsimonjr/memoryjs#readme",
57
+ "engines": {
58
+ "node": ">=18.0.0"
59
+ },
60
+ "dependencies": {
61
+ "@danielsimonjr/workerpool": "^10.0.1",
62
+ "async-mutex": "^0.5.0",
63
+ "better-sqlite3": "^11.7.0",
64
+ "zod": "^3.24.1"
65
+ },
66
+ "devDependencies": {
67
+ "@types/better-sqlite3": "^7.6.12",
68
+ "@types/node": "^22.10.5",
69
+ "@vitest/coverage-v8": "^4.0.16",
70
+ "rimraf": "^6.0.1",
71
+ "tsup": "^8.3.5",
72
+ "typescript": "^5.7.2",
73
+ "vitest": "^4.0.16"
74
+ }
75
+ }
@@ -1,266 +0,0 @@
1
- # @danielsimonjr/memoryjs
2
-
3
- Core knowledge graph library for managing entities, relations, and observations with advanced search capabilities.
4
-
5
- ## Features
6
-
7
- - **Entity Management**: Create, read, update, delete entities with observations
8
- - **Relation Management**: Connect entities with typed relationships
9
- - **Hierarchical Organization**: Parent-child entity nesting
10
- - **Multiple Storage Backends**: JSONL (default) or SQLite
11
- - **Advanced Search**: Basic, ranked (TF-IDF), boolean, fuzzy, semantic, and hybrid search
12
- - **Tag Management**: Tag aliasing, bulk operations
13
- - **Graph Algorithms**: Shortest path, centrality, connected components
14
- - **Import/Export**: JSON, CSV, GraphML formats with compression
15
-
16
- ## Installation
17
-
18
- ```bash
19
- npm install @danielsimonjr/memoryjs
20
- ```
21
-
22
- ## Quick Start
23
-
24
- ```typescript
25
- import { ManagerContext } from '@danielsimonjr/memoryjs';
26
-
27
- // Initialize with JSONL storage (default)
28
- const ctx = new ManagerContext({
29
- storagePath: './memory.jsonl'
30
- });
31
-
32
- // Create entities
33
- await ctx.entityManager.createEntities([
34
- { name: 'TypeScript', entityType: 'language', observations: ['A typed superset of JavaScript'] },
35
- { name: 'Node.js', entityType: 'runtime', observations: ['JavaScript runtime built on V8'] }
36
- ]);
37
-
38
- // Create relations
39
- await ctx.relationManager.createRelations([
40
- { from: 'TypeScript', to: 'Node.js', relationType: 'runs_on' }
41
- ]);
42
-
43
- // Search entities
44
- const results = await ctx.searchManager.search('JavaScript');
45
- ```
46
-
47
- ## Storage Options
48
-
49
- ### JSONL (Default)
50
-
51
- ```typescript
52
- const ctx = new ManagerContext({
53
- storagePath: './memory.jsonl'
54
- });
55
- ```
56
-
57
- ### SQLite
58
-
59
- ```typescript
60
- const ctx = new ManagerContext({
61
- storageType: 'sqlite',
62
- storagePath: './memory.db'
63
- });
64
- ```
65
-
66
- SQLite provides:
67
- - FTS5 full-text search with BM25 ranking
68
- - Referential integrity (ON DELETE CASCADE)
69
- - WAL mode for better concurrency
70
- - ACID transactions
71
-
72
- ## Core Components
73
-
74
- ### ManagerContext
75
-
76
- Central access point for all managers:
77
-
78
- ```typescript
79
- ctx.entityManager // Entity CRUD + hierarchy
80
- ctx.relationManager // Relation management
81
- ctx.searchManager // All search operations
82
- ctx.tagManager // Tag aliases
83
- ctx.ioManager // Import/export/backup
84
- ctx.graphTraversal // Graph algorithms
85
- ctx.semanticSearch // Vector similarity search (optional)
86
- ```
87
-
88
- ### Entity Structure
89
-
90
- ```typescript
91
- interface Entity {
92
- name: string; // Unique identifier
93
- entityType: string; // Classification
94
- observations: string[]; // Facts about the entity
95
- parentId?: string; // For hierarchy
96
- tags?: string[]; // Categories
97
- importance?: number; // 0-10 scale
98
- createdAt?: string; // ISO 8601
99
- lastModified?: string;
100
- }
101
- ```
102
-
103
- ### Relation Structure
104
-
105
- ```typescript
106
- interface Relation {
107
- from: string; // Source entity name
108
- to: string; // Target entity name
109
- relationType: string; // Connection type
110
- }
111
- ```
112
-
113
- ## Search Capabilities
114
-
115
- ### Basic Search
116
-
117
- ```typescript
118
- // Find entities by name or observation content
119
- const results = await ctx.searchManager.search('TypeScript');
120
- ```
121
-
122
- ### Ranked Search (TF-IDF)
123
-
124
- ```typescript
125
- // Get relevance-scored results
126
- const ranked = await ctx.searchManager.searchRanked('JavaScript runtime', { limit: 10 });
127
- ```
128
-
129
- ### Boolean Search
130
-
131
- ```typescript
132
- // AND, OR, NOT operators
133
- const results = await ctx.searchManager.booleanSearch('TypeScript AND runtime');
134
- const excluded = await ctx.searchManager.booleanSearch('JavaScript NOT browser');
135
- ```
136
-
137
- ### Fuzzy Search
138
-
139
- ```typescript
140
- // Typo-tolerant search
141
- const results = await ctx.searchManager.fuzzySearch('Typscript', { threshold: 0.7 });
142
- ```
143
-
144
- ### Hybrid Search
145
-
146
- Combines semantic (vector), lexical (TF-IDF), and symbolic (metadata) signals:
147
-
148
- ```typescript
149
- const results = await ctx.searchManager.hybridSearch('programming concepts', {
150
- weights: { semantic: 0.5, lexical: 0.3, symbolic: 0.2 },
151
- filters: { entityTypes: ['concept'], minImportance: 5 }
152
- });
153
- ```
154
-
155
- ## Graph Algorithms
156
-
157
- ```typescript
158
- // Shortest path between entities
159
- const path = await ctx.graphTraversal.findShortestPath('A', 'Z');
160
-
161
- // All paths up to max depth
162
- const paths = await ctx.graphTraversal.findAllPaths('A', 'Z', { maxDepth: 5 });
163
-
164
- // Centrality analysis
165
- const centrality = await ctx.graphTraversal.getCentrality({ algorithm: 'pagerank' });
166
-
167
- // Connected components
168
- const components = await ctx.graphTraversal.getConnectedComponents();
169
- ```
170
-
171
- ## Import/Export
172
-
173
- ```typescript
174
- // Export to JSON
175
- const json = await ctx.ioManager.exportGraph('json');
176
-
177
- // Export to CSV
178
- const csv = await ctx.ioManager.exportGraph('csv');
179
-
180
- // Export to GraphML (with compression)
181
- await ctx.ioManager.exportGraph('graphml', {
182
- outputPath: './graph.graphml.br',
183
- compress: true
184
- });
185
-
186
- // Import from file
187
- await ctx.ioManager.importGraph('json', jsonData, { mergeStrategy: 'merge' });
188
- ```
189
-
190
- ## Hierarchical Organization
191
-
192
- ```typescript
193
- // Set parent
194
- await ctx.entityManager.setEntityParent('Component', 'Module');
195
-
196
- // Get hierarchy
197
- const children = await ctx.entityManager.getChildren('Module');
198
- const ancestors = await ctx.entityManager.getAncestors('Component');
199
- const subtree = await ctx.entityManager.getSubtree('Module');
200
- ```
201
-
202
- ## Tag Management
203
-
204
- ```typescript
205
- // Add/remove tags
206
- await ctx.entityManager.addTags('Entity1', ['tag1', 'tag2']);
207
- await ctx.entityManager.removeTags('Entity1', ['tag1']);
208
-
209
- // Tag aliases (synonyms)
210
- await ctx.tagManager.addTagAlias('js', 'javascript');
211
-
212
- // Bulk operations
213
- await ctx.entityManager.addTagsToMultipleEntities(['E1', 'E2'], ['shared-tag']);
214
- ```
215
-
216
- ## API Reference
217
-
218
- ### EntityManager
219
-
220
- | Method | Description |
221
- |--------|-------------|
222
- | `createEntities(entities)` | Create multiple entities |
223
- | `deleteEntities(names)` | Delete entities by name |
224
- | `getEntityByName(name)` | Get single entity |
225
- | `addObservations(name, observations)` | Add observations to entity |
226
- | `deleteObservations(name, observations)` | Remove observations |
227
- | `addTags(name, tags)` | Add tags to entity |
228
- | `removeTags(name, tags)` | Remove tags from entity |
229
- | `setImportance(name, score)` | Set importance (0-10) |
230
- | `setEntityParent(name, parentName)` | Set hierarchy parent |
231
- | `getChildren(name)` | Get child entities |
232
- | `getAncestors(name)` | Get ancestor chain |
233
- | `getDescendants(name)` | Get all descendants |
234
-
235
- ### SearchManager
236
-
237
- | Method | Description |
238
- |--------|-------------|
239
- | `search(query, options)` | Basic search |
240
- | `searchRanked(query, options)` | TF-IDF ranked search |
241
- | `booleanSearch(query, options)` | Boolean operators |
242
- | `fuzzySearch(query, options)` | Typo-tolerant |
243
- | `hybridSearch(query, options)` | Multi-signal search |
244
- | `smartSearch(query, options)` | AI-assisted refinement |
245
-
246
- ### IOManager
247
-
248
- | Method | Description |
249
- |--------|-------------|
250
- | `exportGraph(format, options)` | Export to format |
251
- | `importGraph(format, data, options)` | Import from format |
252
- | `createBackup(options)` | Create backup |
253
- | `restoreBackup(path)` | Restore from backup |
254
-
255
- ## Requirements
256
-
257
- - Node.js >= 18.0.0
258
- - TypeScript >= 5.0 (for development)
259
-
260
- ## License
261
-
262
- MIT
263
-
264
- ## Related
265
-
266
- - [@danielsimonjr/memory-mcp](https://github.com/danielsimonjr/memory-mcp) - MCP server built on this library