mnemon-mcp 1.0.0

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 (104) hide show
  1. package/CHANGELOG.md +34 -0
  2. package/CONTRIBUTING.md +59 -0
  3. package/LICENSE +21 -0
  4. package/README.md +434 -0
  5. package/SECURITY.md +29 -0
  6. package/config.example.json +52 -0
  7. package/dist/.tsbuildinfo +1 -0
  8. package/dist/db.d.ts +16 -0
  9. package/dist/db.d.ts.map +1 -0
  10. package/dist/db.js +360 -0
  11. package/dist/db.js.map +1 -0
  12. package/dist/embedder.d.ts +22 -0
  13. package/dist/embedder.d.ts.map +1 -0
  14. package/dist/embedder.js +109 -0
  15. package/dist/embedder.js.map +1 -0
  16. package/dist/import/cli.d.ts +12 -0
  17. package/dist/import/cli.d.ts.map +1 -0
  18. package/dist/import/cli.js +105 -0
  19. package/dist/import/cli.js.map +1 -0
  20. package/dist/import/config-loader.d.ts +29 -0
  21. package/dist/import/config-loader.d.ts.map +1 -0
  22. package/dist/import/config-loader.js +140 -0
  23. package/dist/import/config-loader.js.map +1 -0
  24. package/dist/import/kb-config.d.ts +27 -0
  25. package/dist/import/kb-config.d.ts.map +1 -0
  26. package/dist/import/kb-config.js +10 -0
  27. package/dist/import/kb-config.js.map +1 -0
  28. package/dist/import/kb-import.d.ts +45 -0
  29. package/dist/import/kb-import.d.ts.map +1 -0
  30. package/dist/import/kb-import.js +285 -0
  31. package/dist/import/kb-import.js.map +1 -0
  32. package/dist/import/md-parser.d.ts +35 -0
  33. package/dist/import/md-parser.d.ts.map +1 -0
  34. package/dist/import/md-parser.js +104 -0
  35. package/dist/import/md-parser.js.map +1 -0
  36. package/dist/index-http.d.ts +12 -0
  37. package/dist/index-http.d.ts.map +1 -0
  38. package/dist/index-http.js +202 -0
  39. package/dist/index-http.js.map +1 -0
  40. package/dist/index.d.ts +9 -0
  41. package/dist/index.d.ts.map +1 -0
  42. package/dist/index.js +56 -0
  43. package/dist/index.js.map +1 -0
  44. package/dist/server.d.ts +16 -0
  45. package/dist/server.d.ts.map +1 -0
  46. package/dist/server.js +341 -0
  47. package/dist/server.js.map +1 -0
  48. package/dist/stemmer.d.ts +29 -0
  49. package/dist/stemmer.d.ts.map +1 -0
  50. package/dist/stemmer.js +68 -0
  51. package/dist/stemmer.js.map +1 -0
  52. package/dist/stop-words.d.ts +12 -0
  53. package/dist/stop-words.d.ts.map +1 -0
  54. package/dist/stop-words.js +112 -0
  55. package/dist/stop-words.js.map +1 -0
  56. package/dist/tools/memory-add.d.ts +15 -0
  57. package/dist/tools/memory-add.d.ts.map +1 -0
  58. package/dist/tools/memory-add.js +120 -0
  59. package/dist/tools/memory-add.js.map +1 -0
  60. package/dist/tools/memory-delete.d.ts +10 -0
  61. package/dist/tools/memory-delete.d.ts.map +1 -0
  62. package/dist/tools/memory-delete.js +39 -0
  63. package/dist/tools/memory-delete.js.map +1 -0
  64. package/dist/tools/memory-export.d.ts +10 -0
  65. package/dist/tools/memory-export.d.ts.map +1 -0
  66. package/dist/tools/memory-export.js +102 -0
  67. package/dist/tools/memory-export.js.map +1 -0
  68. package/dist/tools/memory-health.d.ts +11 -0
  69. package/dist/tools/memory-health.d.ts.map +1 -0
  70. package/dist/tools/memory-health.js +79 -0
  71. package/dist/tools/memory-health.js.map +1 -0
  72. package/dist/tools/memory-inspect.d.ts +10 -0
  73. package/dist/tools/memory-inspect.d.ts.map +1 -0
  74. package/dist/tools/memory-inspect.js +139 -0
  75. package/dist/tools/memory-inspect.js.map +1 -0
  76. package/dist/tools/memory-search.d.ts +16 -0
  77. package/dist/tools/memory-search.d.ts.map +1 -0
  78. package/dist/tools/memory-search.js +459 -0
  79. package/dist/tools/memory-search.js.map +1 -0
  80. package/dist/tools/memory-update.d.ts +11 -0
  81. package/dist/tools/memory-update.d.ts.map +1 -0
  82. package/dist/tools/memory-update.js +142 -0
  83. package/dist/tools/memory-update.js.map +1 -0
  84. package/dist/tools/style-extract.d.ts +40 -0
  85. package/dist/tools/style-extract.d.ts.map +1 -0
  86. package/dist/tools/style-extract.js +43 -0
  87. package/dist/tools/style-extract.js.map +1 -0
  88. package/dist/tools/utils.d.ts +28 -0
  89. package/dist/tools/utils.d.ts.map +1 -0
  90. package/dist/tools/utils.js +33 -0
  91. package/dist/tools/utils.js.map +1 -0
  92. package/dist/types.d.ts +216 -0
  93. package/dist/types.d.ts.map +1 -0
  94. package/dist/types.js +6 -0
  95. package/dist/types.js.map +1 -0
  96. package/dist/validation.d.ts +122 -0
  97. package/dist/validation.d.ts.map +1 -0
  98. package/dist/validation.js +96 -0
  99. package/dist/validation.js.map +1 -0
  100. package/dist/vector.d.ts +30 -0
  101. package/dist/vector.d.ts.map +1 -0
  102. package/dist/vector.js +90 -0
  103. package/dist/vector.js.map +1 -0
  104. package/package.json +75 -0
@@ -0,0 +1,40 @@
1
+ /**
2
+ * style_extract — stub implementation.
3
+ * Writing style analysis pipeline is not yet implemented.
4
+ */
5
+ import type Database from "better-sqlite3";
6
+ import type { StyleExtractInput, StyleExtractOutput } from "../types.js";
7
+ export declare function styleExtract(_db: Database.Database, _input: StyleExtractInput): StyleExtractOutput;
8
+ /** JSON Schema for MCP tool registration */
9
+ export declare const styleExtractSchema: {
10
+ readonly type: "object";
11
+ readonly properties: {
12
+ readonly source: {
13
+ readonly type: "string";
14
+ readonly enum: readonly ["file", "directory", "inline"];
15
+ readonly description: "Source type: file path, directory glob, or inline text";
16
+ };
17
+ readonly path: {
18
+ readonly type: "string";
19
+ readonly description: "File or directory path (required for source=file|directory)";
20
+ };
21
+ readonly content: {
22
+ readonly type: "string";
23
+ readonly description: "Inline text to analyze (required for source=inline)";
24
+ };
25
+ readonly file_glob: {
26
+ readonly type: "string";
27
+ readonly description: "Glob pattern to filter files in directory (e.g. '**/*.md')";
28
+ };
29
+ readonly store_as_procedural: {
30
+ readonly type: "boolean";
31
+ readonly description: "Store extracted style profile as a procedural memory";
32
+ };
33
+ readonly scope: {
34
+ readonly type: "string";
35
+ readonly description: "Scope for the stored memory";
36
+ };
37
+ };
38
+ readonly required: readonly ["source"];
39
+ };
40
+ //# sourceMappingURL=style-extract.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"style-extract.d.ts","sourceRoot":"","sources":["../../src/tools/style-extract.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,QAAQ,MAAM,gBAAgB,CAAC;AAC3C,OAAO,KAAK,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAEzE,wBAAgB,YAAY,CAC1B,GAAG,EAAE,QAAQ,CAAC,QAAQ,EACtB,MAAM,EAAE,iBAAiB,GACxB,kBAAkB,CAOpB;AAED,4CAA4C;AAC5C,eAAO,MAAM,kBAAkB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA8BrB,CAAC"}
@@ -0,0 +1,43 @@
1
+ /**
2
+ * style_extract — stub implementation.
3
+ * Writing style analysis pipeline is not yet implemented.
4
+ */
5
+ export function styleExtract(_db, _input) {
6
+ throw new Error("style_extract is not implemented yet. " +
7
+ "Planned: analyze writing patterns and vocabulary from source files, " +
8
+ "store as procedural memory. " +
9
+ "Track progress at https://github.com/nikitacometa/mnemon-mcp");
10
+ }
11
+ /** JSON Schema for MCP tool registration */
12
+ export const styleExtractSchema = {
13
+ type: "object",
14
+ properties: {
15
+ source: {
16
+ type: "string",
17
+ enum: ["file", "directory", "inline"],
18
+ description: "Source type: file path, directory glob, or inline text",
19
+ },
20
+ path: {
21
+ type: "string",
22
+ description: "File or directory path (required for source=file|directory)",
23
+ },
24
+ content: {
25
+ type: "string",
26
+ description: "Inline text to analyze (required for source=inline)",
27
+ },
28
+ file_glob: {
29
+ type: "string",
30
+ description: "Glob pattern to filter files in directory (e.g. '**/*.md')",
31
+ },
32
+ store_as_procedural: {
33
+ type: "boolean",
34
+ description: "Store extracted style profile as a procedural memory",
35
+ },
36
+ scope: {
37
+ type: "string",
38
+ description: "Scope for the stored memory",
39
+ },
40
+ },
41
+ required: ["source"],
42
+ };
43
+ //# sourceMappingURL=style-extract.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"style-extract.js","sourceRoot":"","sources":["../../src/tools/style-extract.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAKH,MAAM,UAAU,YAAY,CAC1B,GAAsB,EACtB,MAAyB;IAEzB,MAAM,IAAI,KAAK,CACb,wCAAwC;QACtC,sEAAsE;QACtE,8BAA8B;QAC9B,8DAA8D,CACjE,CAAC;AACJ,CAAC;AAED,4CAA4C;AAC5C,MAAM,CAAC,MAAM,kBAAkB,GAAG;IAChC,IAAI,EAAE,QAAQ;IACd,UAAU,EAAE;QACV,MAAM,EAAE;YACN,IAAI,EAAE,QAAQ;YACd,IAAI,EAAE,CAAC,MAAM,EAAE,WAAW,EAAE,QAAQ,CAAC;YACrC,WAAW,EAAE,wDAAwD;SACtE;QACD,IAAI,EAAE;YACJ,IAAI,EAAE,QAAQ;YACd,WAAW,EAAE,6DAA6D;SAC3E;QACD,OAAO,EAAE;YACP,IAAI,EAAE,QAAQ;YACd,WAAW,EAAE,qDAAqD;SACnE;QACD,SAAS,EAAE;YACT,IAAI,EAAE,QAAQ;YACd,WAAW,EAAE,4DAA4D;SAC1E;QACD,mBAAmB,EAAE;YACnB,IAAI,EAAE,SAAS;YACf,WAAW,EAAE,sDAAsD;SACpE;QACD,KAAK,EAAE;YACL,IAAI,EAAE,QAAQ;YACd,WAAW,EAAE,6BAA6B;SAC3C;KACF;IACD,QAAQ,EAAE,CAAC,QAAQ,CAAC;CACZ,CAAC"}
@@ -0,0 +1,28 @@
1
+ /**
2
+ * Shared utilities for memory tools — deduplicates generateId() and INSERT logic.
3
+ */
4
+ import type Database from "better-sqlite3";
5
+ export declare function generateId(): string;
6
+ export interface InsertMemoryParams {
7
+ id: string;
8
+ layer: string;
9
+ content: string;
10
+ title: string | null;
11
+ source: string;
12
+ source_file: string | null;
13
+ session_id: string | null;
14
+ event_at: string | null;
15
+ expires_at: string | null;
16
+ confidence: number;
17
+ importance: number;
18
+ supersedes: string | null;
19
+ entity_type: string | null;
20
+ entity_name: string | null;
21
+ scope: string;
22
+ meta: string;
23
+ valid_from: string | null;
24
+ valid_until: string | null;
25
+ }
26
+ /** Insert a memory row with automatic index-time stemming. */
27
+ export declare function insertMemory(db: Database.Database, params: InsertMemoryParams): void;
28
+ //# sourceMappingURL=utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/tools/utils.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OAAO,KAAK,QAAQ,MAAM,gBAAgB,CAAC;AAG3C,wBAAgB,UAAU,IAAI,MAAM,CAEnC;AAED,MAAM,WAAW,kBAAkB;IACjC,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;CAC5B;AAED,8DAA8D;AAC9D,wBAAgB,YAAY,CAAC,EAAE,EAAE,QAAQ,CAAC,QAAQ,EAAE,MAAM,EAAE,kBAAkB,GAAG,IAAI,CA+BpF"}
@@ -0,0 +1,33 @@
1
+ /**
2
+ * Shared utilities for memory tools — deduplicates generateId() and INSERT logic.
3
+ */
4
+ import { randomBytes } from "node:crypto";
5
+ import { stemText } from "../stemmer.js";
6
+ export function generateId() {
7
+ return randomBytes(16).toString("hex");
8
+ }
9
+ /** Insert a memory row with automatic index-time stemming. */
10
+ export function insertMemory(db, params) {
11
+ const stemmedContent = stemText(params.content);
12
+ const stemmedTitle = params.title ? stemText(params.title) : null;
13
+ db.prepare(`
14
+ INSERT INTO memories (
15
+ id, layer, content, title, source, source_file,
16
+ session_id, event_at, expires_at,
17
+ confidence, importance,
18
+ supersedes,
19
+ entity_type, entity_name, scope, meta,
20
+ stemmed_content, stemmed_title,
21
+ valid_from, valid_until
22
+ ) VALUES (
23
+ ?, ?, ?, ?, ?, ?,
24
+ ?, ?, ?,
25
+ ?, ?,
26
+ ?,
27
+ ?, ?, ?, ?,
28
+ ?, ?,
29
+ ?, ?
30
+ )
31
+ `).run(params.id, params.layer, params.content, params.title, params.source, params.source_file, params.session_id, params.event_at, params.expires_at, params.confidence, params.importance, params.supersedes, params.entity_type, params.entity_name, params.scope, params.meta, stemmedContent, stemmedTitle, params.valid_from, params.valid_until);
32
+ }
33
+ //# sourceMappingURL=utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/tools/utils.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAE1C,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAEzC,MAAM,UAAU,UAAU;IACxB,OAAO,WAAW,CAAC,EAAE,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;AACzC,CAAC;AAuBD,8DAA8D;AAC9D,MAAM,UAAU,YAAY,CAAC,EAAqB,EAAE,MAA0B;IAC5E,MAAM,cAAc,GAAG,QAAQ,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;IAChD,MAAM,YAAY,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;IAElE,EAAE,CAAC,OAAO,CAAC;;;;;;;;;;;;;;;;;;GAkBV,CAAC,CAAC,GAAG,CACJ,MAAM,CAAC,EAAE,EAAE,MAAM,CAAC,KAAK,EAAE,MAAM,CAAC,OAAO,EAAE,MAAM,CAAC,KAAK,EACrD,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,WAAW,EAAE,MAAM,CAAC,UAAU,EACpD,MAAM,CAAC,QAAQ,EAAE,MAAM,CAAC,UAAU,EAAE,MAAM,CAAC,UAAU,EACrD,MAAM,CAAC,UAAU,EAAE,MAAM,CAAC,UAAU,EAAE,MAAM,CAAC,WAAW,EACxD,MAAM,CAAC,WAAW,EAAE,MAAM,CAAC,KAAK,EAAE,MAAM,CAAC,IAAI,EAC7C,cAAc,EAAE,YAAY,EAC5B,MAAM,CAAC,UAAU,EAAE,MAAM,CAAC,WAAW,CACtC,CAAC;AACJ,CAAC"}
@@ -0,0 +1,216 @@
1
+ /**
2
+ * Shared TypeScript types for mnemon-mcp.
3
+ * All types correspond 1:1 to SQLite schema columns.
4
+ */
5
+ export type Layer = "episodic" | "semantic" | "procedural" | "resource";
6
+ export type EntityType = "user" | "project" | "person" | "concept" | "file" | "rule" | "tool";
7
+ export type MemorySource = "claude-code" | "cursor" | "api" | `import:${"claude-md" | "kb" | "chatgpt-export" | string}`;
8
+ export type SearchMode = "fts" | "exact" | "vector" | "hybrid";
9
+ export interface MemoryRow {
10
+ id: string;
11
+ layer: Layer;
12
+ content: string;
13
+ title: string | null;
14
+ source: string;
15
+ source_file: string | null;
16
+ session_id: string | null;
17
+ created_at: string;
18
+ updated_at: string;
19
+ event_at: string | null;
20
+ expires_at: string | null;
21
+ confidence: number;
22
+ importance: number;
23
+ access_count: number;
24
+ last_accessed: string | null;
25
+ superseded_by: string | null;
26
+ supersedes: string | null;
27
+ entity_type: EntityType | null;
28
+ entity_name: string | null;
29
+ scope: string;
30
+ embedding: Buffer | null;
31
+ meta: string;
32
+ valid_from: string | null;
33
+ valid_until: string | null;
34
+ }
35
+ export interface SessionRow {
36
+ id: string;
37
+ client: string;
38
+ project: string | null;
39
+ started_at: string;
40
+ ended_at: string | null;
41
+ summary: string | null;
42
+ meta: string;
43
+ }
44
+ export interface ImportLogRow {
45
+ id: string;
46
+ source_path: string;
47
+ source_type: "claude-md" | "kb-markdown" | "json" | "chatgpt-export";
48
+ imported_at: string;
49
+ memories_created: number;
50
+ memories_updated: number;
51
+ file_hash: string | null;
52
+ status: "success" | "partial" | "failed";
53
+ errors: string;
54
+ }
55
+ export type EventType = "created" | "updated" | "superseded" | "deleted";
56
+ export interface EventLogRow {
57
+ id: string;
58
+ memory_id: string;
59
+ event_type: EventType;
60
+ actor: string;
61
+ old_content: string | null;
62
+ new_content: string | null;
63
+ diff_meta: string;
64
+ occurred_at: string;
65
+ }
66
+ export interface MemoryAddInput {
67
+ content: string;
68
+ layer: Layer;
69
+ title?: string;
70
+ entity_type?: EntityType;
71
+ entity_name?: string;
72
+ event_at?: string;
73
+ ttl_days?: number;
74
+ confidence?: number;
75
+ importance?: number;
76
+ scope?: string;
77
+ source?: string;
78
+ source_file?: string;
79
+ session_id?: string;
80
+ meta?: Record<string, unknown>;
81
+ valid_from?: string;
82
+ valid_until?: string;
83
+ }
84
+ export interface MemorySearchInput {
85
+ query: string;
86
+ layers?: Layer[];
87
+ entity_name?: string;
88
+ scope?: string;
89
+ date_from?: string;
90
+ date_to?: string;
91
+ min_confidence?: number;
92
+ min_importance?: number;
93
+ include_superseded?: boolean;
94
+ limit?: number;
95
+ offset?: number;
96
+ mode?: SearchMode;
97
+ as_of?: string;
98
+ }
99
+ export interface MemoryUpdateInput {
100
+ id: string;
101
+ content?: string;
102
+ title?: string;
103
+ confidence?: number;
104
+ importance?: number;
105
+ meta?: Record<string, unknown>;
106
+ supersede?: boolean;
107
+ new_content?: string;
108
+ }
109
+ export interface MemoryInspectInput {
110
+ id?: string;
111
+ layer?: Layer;
112
+ entity_name?: string;
113
+ include_history?: boolean;
114
+ }
115
+ export interface MemoryExportInput {
116
+ format: "json" | "markdown" | "claude-md";
117
+ layers?: Layer[];
118
+ scope?: string;
119
+ include_superseded?: boolean;
120
+ date_from?: string;
121
+ date_to?: string;
122
+ limit?: number;
123
+ }
124
+ export interface MemoryDeleteInput {
125
+ id: string;
126
+ }
127
+ export interface MemoryDeleteOutput {
128
+ deleted_id: string;
129
+ }
130
+ export interface MemoryHealthInput {
131
+ cleanup?: boolean;
132
+ }
133
+ export interface MemoryHealthOutput {
134
+ status: "healthy" | "warning" | "degraded";
135
+ issues: string[];
136
+ stats: {
137
+ total_active: number;
138
+ total_superseded: number;
139
+ by_layer: Record<string, number>;
140
+ };
141
+ expired: Array<{
142
+ id: string;
143
+ title: string | null;
144
+ expires_at: string;
145
+ }>;
146
+ orphaned_chains: Array<{
147
+ id: string;
148
+ missing_supersedes: string;
149
+ }>;
150
+ stale_count: number;
151
+ low_confidence_count: number;
152
+ cleaned_expired?: number;
153
+ }
154
+ export interface MemoryExportOutput {
155
+ format: string;
156
+ count: number;
157
+ content: string;
158
+ }
159
+ export interface MemoryAddOutput {
160
+ id: string;
161
+ layer: Layer;
162
+ created: boolean;
163
+ superseded_ids?: string[];
164
+ potential_conflicts?: Array<{
165
+ id: string;
166
+ snippet: string;
167
+ }>;
168
+ }
169
+ export interface MemorySearchResult {
170
+ id: string;
171
+ layer: Layer;
172
+ title: string | null;
173
+ content: string;
174
+ snippet: string;
175
+ score: number;
176
+ entity_type: EntityType | null;
177
+ entity_name: string | null;
178
+ confidence: number;
179
+ importance: number;
180
+ scope: string;
181
+ created_at: string;
182
+ event_at: string | null;
183
+ }
184
+ export interface MemorySearchOutput {
185
+ memories: MemorySearchResult[];
186
+ /**
187
+ * Number of results returned after post-filter (superseded, confidence, importance).
188
+ * This is NOT the total count of matching rows in the DB — it equals memories.length.
189
+ */
190
+ total_found: number;
191
+ query_time_ms: number;
192
+ }
193
+ export interface MemoryUpdateOutput {
194
+ updated_id: string;
195
+ new_id?: string;
196
+ superseded: boolean;
197
+ }
198
+ export interface LayerStat {
199
+ total: number;
200
+ active: number;
201
+ superseded: number;
202
+ avg_confidence: number;
203
+ never_accessed: number;
204
+ stale_count: number;
205
+ avg_age_days: number;
206
+ top_entities: Array<{
207
+ entity_name: string;
208
+ count: number;
209
+ }>;
210
+ }
211
+ export interface MemoryInspectOutput {
212
+ memory?: MemoryRow;
213
+ layer_stats?: Record<Layer, LayerStat>;
214
+ superseded_chain?: MemoryRow[];
215
+ }
216
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,MAAM,MAAM,KAAK,GAAG,UAAU,GAAG,UAAU,GAAG,YAAY,GAAG,UAAU,CAAC;AAExE,MAAM,MAAM,UAAU,GAClB,MAAM,GACN,SAAS,GACT,QAAQ,GACR,SAAS,GACT,MAAM,GACN,MAAM,GACN,MAAM,CAAC;AAEX,MAAM,MAAM,YAAY,GACpB,aAAa,GACb,QAAQ,GACR,KAAK,GACL,UAAU,WAAW,GAAG,IAAI,GAAG,gBAAgB,GAAG,MAAM,EAAE,CAAC;AAE/D,MAAM,MAAM,UAAU,GAAG,KAAK,GAAG,OAAO,GAAG,QAAQ,GAAG,QAAQ,CAAC;AAO/D,MAAM,WAAW,SAAS;IACxB,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,KAAK,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,UAA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2
+ * Shared TypeScript types for mnemon-mcp.
3
+ * All types correspond 1:1 to SQLite schema columns.
4
+ */
5
+ export {};
6
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;GAGG"}
@@ -0,0 +1,122 @@
1
+ /**
2
+ * Runtime input validation for MCP tool args.
3
+ * Uses Zod for validation AND JSON Schema generation (single source of truth).
4
+ *
5
+ * Tool input schemas are generated via z.toJSONSchema() — no manual JSON Schema
6
+ * objects in tool files. Descriptions on Zod fields become tool parameter docs.
7
+ */
8
+ import { z } from "zod";
9
+ export declare const MemoryAddSchema: z.ZodObject<{
10
+ content: z.ZodString;
11
+ layer: z.ZodEnum<{
12
+ episodic: "episodic";
13
+ semantic: "semantic";
14
+ procedural: "procedural";
15
+ resource: "resource";
16
+ }>;
17
+ title: z.ZodOptional<z.ZodString>;
18
+ entity_type: z.ZodOptional<z.ZodEnum<{
19
+ user: "user";
20
+ project: "project";
21
+ person: "person";
22
+ concept: "concept";
23
+ file: "file";
24
+ rule: "rule";
25
+ tool: "tool";
26
+ }>>;
27
+ entity_name: z.ZodOptional<z.ZodString>;
28
+ event_at: z.ZodOptional<z.ZodString>;
29
+ ttl_days: z.ZodOptional<z.ZodNumber>;
30
+ confidence: z.ZodOptional<z.ZodNumber>;
31
+ importance: z.ZodOptional<z.ZodNumber>;
32
+ scope: z.ZodOptional<z.ZodString>;
33
+ source: z.ZodOptional<z.ZodString>;
34
+ source_file: z.ZodOptional<z.ZodString>;
35
+ session_id: z.ZodOptional<z.ZodString>;
36
+ meta: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
37
+ valid_from: z.ZodOptional<z.ZodString>;
38
+ valid_until: z.ZodOptional<z.ZodString>;
39
+ }, z.core.$strip>;
40
+ export declare const MemorySearchSchema: z.ZodObject<{
41
+ query: z.ZodString;
42
+ layers: z.ZodOptional<z.ZodArray<z.ZodEnum<{
43
+ episodic: "episodic";
44
+ semantic: "semantic";
45
+ procedural: "procedural";
46
+ resource: "resource";
47
+ }>>>;
48
+ entity_name: z.ZodOptional<z.ZodString>;
49
+ scope: z.ZodOptional<z.ZodString>;
50
+ date_from: z.ZodOptional<z.ZodString>;
51
+ date_to: z.ZodOptional<z.ZodString>;
52
+ min_confidence: z.ZodOptional<z.ZodNumber>;
53
+ min_importance: z.ZodOptional<z.ZodNumber>;
54
+ include_superseded: z.ZodOptional<z.ZodBoolean>;
55
+ limit: z.ZodOptional<z.ZodNumber>;
56
+ offset: z.ZodOptional<z.ZodNumber>;
57
+ mode: z.ZodOptional<z.ZodEnum<{
58
+ fts: "fts";
59
+ exact: "exact";
60
+ vector: "vector";
61
+ hybrid: "hybrid";
62
+ }>>;
63
+ as_of: z.ZodOptional<z.ZodString>;
64
+ }, z.core.$strip>;
65
+ export declare const MemoryUpdateSchema: z.ZodObject<{
66
+ id: z.ZodString;
67
+ content: z.ZodOptional<z.ZodString>;
68
+ title: z.ZodOptional<z.ZodString>;
69
+ confidence: z.ZodOptional<z.ZodNumber>;
70
+ importance: z.ZodOptional<z.ZodNumber>;
71
+ meta: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
72
+ supersede: z.ZodOptional<z.ZodBoolean>;
73
+ new_content: z.ZodOptional<z.ZodString>;
74
+ }, z.core.$strip>;
75
+ export declare const MemoryInspectSchema: z.ZodObject<{
76
+ id: z.ZodOptional<z.ZodString>;
77
+ layer: z.ZodOptional<z.ZodEnum<{
78
+ episodic: "episodic";
79
+ semantic: "semantic";
80
+ procedural: "procedural";
81
+ resource: "resource";
82
+ }>>;
83
+ entity_name: z.ZodOptional<z.ZodString>;
84
+ include_history: z.ZodOptional<z.ZodBoolean>;
85
+ }, z.core.$strip>;
86
+ export declare const MemoryExportSchema: z.ZodObject<{
87
+ format: z.ZodEnum<{
88
+ "claude-md": "claude-md";
89
+ json: "json";
90
+ markdown: "markdown";
91
+ }>;
92
+ layers: z.ZodOptional<z.ZodArray<z.ZodEnum<{
93
+ episodic: "episodic";
94
+ semantic: "semantic";
95
+ procedural: "procedural";
96
+ resource: "resource";
97
+ }>>>;
98
+ scope: z.ZodOptional<z.ZodString>;
99
+ include_superseded: z.ZodOptional<z.ZodBoolean>;
100
+ date_from: z.ZodOptional<z.ZodString>;
101
+ date_to: z.ZodOptional<z.ZodString>;
102
+ limit: z.ZodOptional<z.ZodNumber>;
103
+ }, z.core.$strip>;
104
+ export declare const MemoryDeleteSchema: z.ZodObject<{
105
+ id: z.ZodString;
106
+ }, z.core.$strip>;
107
+ export declare const MemoryHealthSchema: z.ZodObject<{
108
+ cleanup: z.ZodOptional<z.ZodBoolean>;
109
+ }, z.core.$strip>;
110
+ /**
111
+ * Convert a Zod schema to MCP-compatible JSON Schema.
112
+ * Strips $schema and additionalProperties fields that MCP doesn't use.
113
+ */
114
+ export declare function zodToToolSchema(schema: z.ZodObject<z.ZodRawShape>): Record<string, unknown>;
115
+ export declare const memoryAddToolSchema: Record<string, unknown>;
116
+ export declare const memorySearchToolSchema: Record<string, unknown>;
117
+ export declare const memoryUpdateToolSchema: Record<string, unknown>;
118
+ export declare const memoryInspectToolSchema: Record<string, unknown>;
119
+ export declare const memoryExportToolSchema: Record<string, unknown>;
120
+ export declare const memoryDeleteToolSchema: Record<string, unknown>;
121
+ export declare const memoryHealthToolSchema: Record<string, unknown>;
122
+ //# sourceMappingURL=validation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validation.d.ts","sourceRoot":"","sources":["../src/validation.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAYxB,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAiB1B,CAAC;AAEH,eAAO,MAAM,kBAAkB;;;;;;;;;;;;;;;;;;;;;;;;iBAc7B,CAAC;AAEH,eAAO,MAAM,kBAAkB;;;;;;;;;iBAS7B,CAAC;AAEH,eAAO,MAAM,mBAAmB;;;;;;;;;;iBAK9B,CAAC;AAEH,eAAO,MAAM,kBAAkB;;;;;;;;;;;;;;;;;iBAQ7B,CAAC;AAEH,eAAO,MAAM,kBAAkB;;iBAE7B,CAAC;AAEH,eAAO,MAAM,kBAAkB;;iBAE7B,CAAC;AAEH;;;GAGG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,WAAW,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAK3F;AAGD,eAAO,MAAM,mBAAmB,yBAAmC,CAAC;AACpE,eAAO,MAAM,sBAAsB,yBAAsC,CAAC;AAC1E,eAAO,MAAM,sBAAsB,yBAAsC,CAAC;AAC1E,eAAO,MAAM,uBAAuB,yBAAuC,CAAC;AAC5E,eAAO,MAAM,sBAAsB,yBAAsC,CAAC;AAC1E,eAAO,MAAM,sBAAsB,yBAAsC,CAAC;AAC1E,eAAO,MAAM,sBAAsB,yBAAsC,CAAC"}
@@ -0,0 +1,96 @@
1
+ /**
2
+ * Runtime input validation for MCP tool args.
3
+ * Uses Zod for validation AND JSON Schema generation (single source of truth).
4
+ *
5
+ * Tool input schemas are generated via z.toJSONSchema() — no manual JSON Schema
6
+ * objects in tool files. Descriptions on Zod fields become tool parameter docs.
7
+ */
8
+ import { z } from "zod";
9
+ const Layer = z.enum(["episodic", "semantic", "procedural", "resource"]);
10
+ const EntityType = z.enum(["user", "project", "person", "concept", "file", "rule", "tool"]);
11
+ const SearchMode = z.enum(["fts", "exact", "vector", "hybrid"]);
12
+ const ExportFormat = z.enum(["json", "markdown", "claude-md"]);
13
+ const isoDatePrefix = z.string().regex(/^\d{4}-\d{2}-\d{2}/, "Must be an ISO 8601 date (YYYY-MM-DD...)");
14
+ export const MemoryAddSchema = z.object({
15
+ content: z.string().min(1).max(100_000).describe("The memory content to store"),
16
+ layer: Layer.describe("Cognitive layer: episodic=events/sessions, semantic=facts/concepts, procedural=rules/workflows, resource=reference material"),
17
+ title: z.string().max(500).optional().describe("Optional short title for the memory"),
18
+ entity_type: EntityType.optional().describe("Entity this memory is about"),
19
+ entity_name: z.string().max(500).optional().describe("Name of the entity (e.g. 'nikita', 'mnemon-mcp')"),
20
+ event_at: isoDatePrefix.optional().describe("ISO 8601 datetime when the event occurred (episodic layer)"),
21
+ ttl_days: z.number().positive().optional().describe("Days until this memory expires (null = never)"),
22
+ confidence: z.number().min(0).max(1).optional().describe("How certain this memory is (0.0–1.0, default 0.8)"),
23
+ importance: z.number().min(0).max(1).optional().describe("Retrieval priority weight (0.0–1.0, default 0.5)"),
24
+ scope: z.string().max(200).optional().describe("Project/context scope (default 'global')"),
25
+ source: z.string().max(200).optional().describe("Source identifier (e.g. 'claude-code', 'api')"),
26
+ source_file: z.string().max(1000).optional().describe("Original file path for imports"),
27
+ session_id: z.string().max(200).optional().describe("Session ID for grouping episodic memories"),
28
+ meta: z.record(z.string(), z.unknown()).optional().describe("Additional metadata (layer-specific fields)"),
29
+ valid_from: isoDatePrefix.optional().describe("ISO 8601 date when this fact becomes valid (null = always valid)"),
30
+ valid_until: isoDatePrefix.optional().describe("ISO 8601 date when this fact stops being valid (null = no end date)"),
31
+ });
32
+ export const MemorySearchSchema = z.object({
33
+ query: z.string().min(1).max(10_000).describe("Search query — free text, tokenized for FTS5"),
34
+ layers: z.array(Layer).optional().describe("Filter by memory layers (default: all layers)"),
35
+ entity_name: z.string().max(500).optional().describe("Filter by entity name (exact match, supports aliases)"),
36
+ scope: z.string().max(200).optional().describe("Filter by scope (exact match)"),
37
+ date_from: isoDatePrefix.optional().describe("Filter by event date (event_at if set, else created_at) >= ISO 8601 datetime"),
38
+ date_to: isoDatePrefix.optional().describe("Filter by event date (event_at if set, else created_at) <= ISO 8601 datetime"),
39
+ min_confidence: z.number().min(0).max(1).optional().describe("Minimum confidence threshold"),
40
+ min_importance: z.number().min(0).max(1).optional().describe("Minimum importance threshold"),
41
+ include_superseded: z.boolean().optional().describe("Include superseded (outdated) memories in results (default false)"),
42
+ limit: z.number().min(1).max(100).optional().describe("Maximum results to return (default 10, max 100)"),
43
+ offset: z.number().min(0).optional().describe("Number of results to skip (for pagination, default 0)"),
44
+ mode: SearchMode.optional().describe("Search mode: fts=FTS5 tokenized (default), exact=LIKE substring, vector=embedding similarity (requires MNEMON_EMBEDDING_PROVIDER), hybrid=FTS5+vector with RRF fusion"),
45
+ as_of: isoDatePrefix.optional().describe("ISO 8601 date to filter temporal facts. Only returns memories where valid_from <= as_of and valid_until >= as_of (nulls treated as unbounded)."),
46
+ });
47
+ export const MemoryUpdateSchema = z.object({
48
+ id: z.string().min(1).describe("ID of the memory to update"),
49
+ content: z.string().max(100_000).optional().describe("New content. For in-place update (supersede=false): replaces content directly. For supersede=true: used as fallback if new_content is not provided."),
50
+ title: z.string().max(500).optional().describe("New title"),
51
+ confidence: z.number().min(0).max(1).optional().describe("New confidence score"),
52
+ importance: z.number().min(0).max(1).optional().describe("New importance score"),
53
+ meta: z.record(z.string(), z.unknown()).optional().describe("Metadata fields to merge into existing meta JSON"),
54
+ supersede: z.boolean().optional().describe("When true, creates a new entry that supersedes this one (preserves history). When false (default), updates fields in place."),
55
+ new_content: z.string().max(100_000).optional().describe("Content for the superseding entry (used only when supersede=true). Falls back to `content` if omitted."),
56
+ });
57
+ export const MemoryInspectSchema = z.object({
58
+ id: z.string().optional().describe("Memory ID to inspect. When provided, returns the full memory row and optionally its history chain."),
59
+ layer: Layer.optional().describe("Filter layer stats by this layer (used when id is omitted)"),
60
+ entity_name: z.string().max(500).optional().describe("Filter stats by entity name (used when id is omitted)"),
61
+ include_history: z.boolean().optional().describe("When true and id is provided, include the full superseded chain (ancestor entries)"),
62
+ });
63
+ export const MemoryExportSchema = z.object({
64
+ format: ExportFormat.describe("Export format: json (structured), markdown (human-readable), claude-md (compact for LLM context)"),
65
+ layers: z.array(Layer).optional().describe("Filter by memory layers (omit for all)"),
66
+ scope: z.string().max(200).optional().describe("Filter by scope (e.g. 'global', 'project-name')"),
67
+ include_superseded: z.boolean().optional().describe("Include superseded (old version) memories (default: false)"),
68
+ date_from: isoDatePrefix.optional().describe("Filter: event date (event_at if set, else created_at) >= ISO 8601 date"),
69
+ date_to: isoDatePrefix.optional().describe("Filter: event date (event_at if set, else created_at) <= ISO 8601 date"),
70
+ limit: z.number().min(1).max(10_000).optional().describe("Maximum entries to export (default 1000, max 10000)"),
71
+ });
72
+ export const MemoryDeleteSchema = z.object({
73
+ id: z.string().min(1).describe("ID of the memory to permanently delete"),
74
+ });
75
+ export const MemoryHealthSchema = z.object({
76
+ cleanup: z.boolean().optional().describe("When true, garbage-collect expired entries (TTL past due). Default false — report only."),
77
+ });
78
+ /**
79
+ * Convert a Zod schema to MCP-compatible JSON Schema.
80
+ * Strips $schema and additionalProperties fields that MCP doesn't use.
81
+ */
82
+ export function zodToToolSchema(schema) {
83
+ const jsonSchema = z.toJSONSchema(schema);
84
+ delete jsonSchema["$schema"];
85
+ delete jsonSchema["additionalProperties"];
86
+ return jsonSchema;
87
+ }
88
+ // Pre-generated tool schemas (used in server.ts for tool registration)
89
+ export const memoryAddToolSchema = zodToToolSchema(MemoryAddSchema);
90
+ export const memorySearchToolSchema = zodToToolSchema(MemorySearchSchema);
91
+ export const memoryUpdateToolSchema = zodToToolSchema(MemoryUpdateSchema);
92
+ export const memoryInspectToolSchema = zodToToolSchema(MemoryInspectSchema);
93
+ export const memoryExportToolSchema = zodToToolSchema(MemoryExportSchema);
94
+ export const memoryDeleteToolSchema = zodToToolSchema(MemoryDeleteSchema);
95
+ export const memoryHealthToolSchema = zodToToolSchema(MemoryHealthSchema);
96
+ //# sourceMappingURL=validation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validation.js","sourceRoot":"","sources":["../src/validation.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,MAAM,KAAK,GAAG,CAAC,CAAC,IAAI,C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