minimem 0.0.3 → 0.0.4

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.
@@ -0,0 +1,65 @@
1
+ /**
2
+ * Debug function type for optional logging
3
+ */
4
+ type DebugFn = (message: string, data?: Record<string, unknown>) => void;
5
+ /**
6
+ * Log an error with context (for debugging).
7
+ * Only logs if a debug function is provided.
8
+ *
9
+ * @param context - A short identifier for where the error occurred
10
+ * @param error - The error object or message
11
+ * @param debug - Optional debug function to log to
12
+ */
13
+ declare function logError(context: string, error: unknown, debug?: DebugFn): void;
14
+ type MemoryFileEntry = {
15
+ path: string;
16
+ absPath: string;
17
+ mtimeMs: number;
18
+ size: number;
19
+ hash: string;
20
+ };
21
+ type MemoryChunk = {
22
+ startLine: number;
23
+ endLine: number;
24
+ text: string;
25
+ hash: string;
26
+ };
27
+ /**
28
+ * Ensure a directory exists, creating it if necessary.
29
+ *
30
+ * @param dir - The directory path to ensure exists
31
+ * @param debug - Optional debug function for logging errors
32
+ * @returns The directory path
33
+ */
34
+ declare function ensureDir(dir: string, debug?: DebugFn): string;
35
+ declare function normalizeRelPath(value: string): string;
36
+ declare function isMemoryPath(relPath: string): boolean;
37
+ declare function listMemoryFiles(memoryDir: string): Promise<string[]>;
38
+ declare function hashText(value: string): string;
39
+ declare function buildFileEntry(absPath: string, memoryDir: string): Promise<MemoryFileEntry>;
40
+ /**
41
+ * Strip content between <private>...</private> tags.
42
+ * Replaces private blocks with the same number of empty lines to preserve line numbering.
43
+ */
44
+ declare function stripPrivateContent(content: string): string;
45
+ declare function chunkMarkdown(content: string, chunking: {
46
+ tokens: number;
47
+ overlap: number;
48
+ }): MemoryChunk[];
49
+ /**
50
+ * Extract metadata from a chunk's text content.
51
+ * Looks for HTML comments like <!-- type: decision --> in the chunk.
52
+ */
53
+ declare function extractChunkMetadata(text: string): {
54
+ type?: string;
55
+ };
56
+ declare function parseEmbedding(raw: string): number[];
57
+ declare function cosineSimilarity(a: number[], b: number[]): number;
58
+ declare function truncateUtf16Safe(text: string, maxChars: number): string;
59
+ /**
60
+ * Convert a numeric embedding vector to a Buffer suitable for sqlite-vec storage.
61
+ * Uses Float32 encoding, which is the format expected by sqlite-vec's vector functions.
62
+ */
63
+ declare function vectorToBlob(embedding: number[]): Buffer;
64
+
65
+ export { type DebugFn, type MemoryChunk, type MemoryFileEntry, buildFileEntry, chunkMarkdown, cosineSimilarity, ensureDir, extractChunkMetadata, hashText, isMemoryPath, listMemoryFiles, logError, normalizeRelPath, parseEmbedding, stripPrivateContent, truncateUtf16Safe, vectorToBlob };
@@ -0,0 +1,33 @@
1
+ import {
2
+ buildFileEntry,
3
+ chunkMarkdown,
4
+ cosineSimilarity,
5
+ ensureDir,
6
+ extractChunkMetadata,
7
+ hashText,
8
+ isMemoryPath,
9
+ listMemoryFiles,
10
+ logError,
11
+ normalizeRelPath,
12
+ parseEmbedding,
13
+ stripPrivateContent,
14
+ truncateUtf16Safe,
15
+ vectorToBlob
16
+ } from "./chunk-ARZQHOJI.js";
17
+ export {
18
+ buildFileEntry,
19
+ chunkMarkdown,
20
+ cosineSimilarity,
21
+ ensureDir,
22
+ extractChunkMetadata,
23
+ hashText,
24
+ isMemoryPath,
25
+ listMemoryFiles,
26
+ logError,
27
+ normalizeRelPath,
28
+ parseEmbedding,
29
+ stripPrivateContent,
30
+ truncateUtf16Safe,
31
+ vectorToBlob
32
+ };
33
+ //# sourceMappingURL=internal.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -0,0 +1,96 @@
1
+ /**
2
+ * Session tracking for memory entries
3
+ *
4
+ * Captures context about the originating session (Claude Code, VS Code, etc.)
5
+ * and stores it as YAML frontmatter in memory files.
6
+ */
7
+ /**
8
+ * Session metadata for memory entries
9
+ */
10
+ type SessionContext = {
11
+ /** Session identifier (e.g., Claude Code session ID) */
12
+ id?: string;
13
+ /** Source application (claude-code, vscode, cursor, etc.) */
14
+ source?: string;
15
+ /** Project directory path */
16
+ project?: string;
17
+ /** Path to session transcript/log file */
18
+ transcript?: string;
19
+ };
20
+ /**
21
+ * Source provenance for a knowledge entry
22
+ */
23
+ type KnowledgeSource = {
24
+ origin?: string;
25
+ trajectories?: string[];
26
+ agentId?: string;
27
+ };
28
+ /**
29
+ * A directional link from this entry to another knowledge node
30
+ */
31
+ type KnowledgeLink = {
32
+ target: string;
33
+ relation: string;
34
+ layer?: string;
35
+ };
36
+ /**
37
+ * Frontmatter structure for memory files
38
+ */
39
+ type MemoryFrontmatter = {
40
+ session?: SessionContext;
41
+ created?: string;
42
+ updated?: string;
43
+ tags?: string[];
44
+ /** Knowledge node identifier */
45
+ id?: string;
46
+ /** Knowledge entry type */
47
+ type?: "observation" | "entity" | "domain-summary" | string;
48
+ /** Domain tags for this knowledge entry */
49
+ domain?: string[];
50
+ /** Entity references in this knowledge entry */
51
+ entities?: string[];
52
+ /** Confidence score 0-1 */
53
+ confidence?: number;
54
+ /** Source provenance */
55
+ source?: KnowledgeSource;
56
+ /** Links to other knowledge nodes */
57
+ links?: KnowledgeLink[];
58
+ /** ID of the entry this supersedes */
59
+ supersedes?: string | null;
60
+ };
61
+ /**
62
+ * Parse YAML frontmatter from content
63
+ *
64
+ * Frontmatter is delimited by --- at the start and end:
65
+ * ```
66
+ * ---
67
+ * session:
68
+ * id: abc123
69
+ * source: claude-code
70
+ * created: 2024-01-27T14:30:00Z
71
+ * ---
72
+ * Actual content here...
73
+ * ```
74
+ */
75
+ declare function parseFrontmatter(content: string): {
76
+ frontmatter: MemoryFrontmatter | undefined;
77
+ body: string;
78
+ };
79
+ /**
80
+ * Serialize frontmatter to YAML string
81
+ */
82
+ declare function serializeFrontmatter(frontmatter: MemoryFrontmatter): string;
83
+ /**
84
+ * Add or update frontmatter in content
85
+ */
86
+ declare function addFrontmatter(content: string, frontmatter: MemoryFrontmatter): string;
87
+ /**
88
+ * Add session context as frontmatter to content
89
+ */
90
+ declare function addSessionToContent(content: string, session: SessionContext): string;
91
+ /**
92
+ * Extract session context from file content
93
+ */
94
+ declare function extractSession(content: string): SessionContext | undefined;
95
+
96
+ export { type KnowledgeLink, type KnowledgeSource, type MemoryFrontmatter, type SessionContext, addFrontmatter, addSessionToContent, extractSession, parseFrontmatter, serializeFrontmatter };
@@ -0,0 +1,15 @@
1
+ import {
2
+ addFrontmatter,
3
+ addSessionToContent,
4
+ extractSession,
5
+ parseFrontmatter,
6
+ serializeFrontmatter
7
+ } from "./chunk-GVWPZRF7.js";
8
+ export {
9
+ addFrontmatter,
10
+ addSessionToContent,
11
+ extractSession,
12
+ parseFrontmatter,
13
+ serializeFrontmatter
14
+ };
15
+ //# sourceMappingURL=session.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "minimem",
3
- "version": "0.0.3",
3
+ "version": "0.0.4",
4
4
  "description": "A lightweight file-based memory system with vector search for AI agents",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -10,6 +10,14 @@
10
10
  ".": {
11
11
  "types": "./dist/index.d.ts",
12
12
  "import": "./dist/index.js"
13
+ },
14
+ "./session": {
15
+ "types": "./dist/session.d.ts",
16
+ "import": "./dist/session.js"
17
+ },
18
+ "./internal": {
19
+ "types": "./dist/internal.d.ts",
20
+ "import": "./dist/internal.js"
13
21
  }
14
22
  },
15
23
  "files": [
@@ -17,7 +25,7 @@
17
25
  ],
18
26
  "scripts": {
19
27
  "build": "tsup && npm run postbuild",
20
- "postbuild": "sed -i '' 's/from \"sqlite\"/from \"node:sqlite\"/g' dist/cli/index.js",
28
+ "postbuild": "node scripts/postbuild.js",
21
29
  "dev": "tsup --watch",
22
30
  "test": "vitest run",
23
31
  "test:integration": "npx tsx --test src/__tests__/minimem.integration.test.ts",