@jungjaehoon/mama-core 1.4.0 → 1.4.2

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.
@@ -124,7 +124,7 @@ CREATE INDEX IF NOT EXISTS idx_sessions_last_active ON sessions(last_active_at);
124
124
  -- because sqlite-vss requires extension loading first
125
125
  --
126
126
  -- CREATE VIRTUAL TABLE vss_memories USING vss0(
127
- -- embedding(384) -- multilingual-e5-small embeddings
127
+ -- embedding(1024) -- multilingual-e5-large embeddings
128
128
  -- );
129
129
 
130
130
  -- ══════════════════════════════════════════════════════════════
@@ -33,7 +33,7 @@ CREATE TABLE IF NOT EXISTS error_patterns (
33
33
  first_seen INTEGER NOT NULL, -- First occurrence timestamp
34
34
 
35
35
  -- Vector Embedding (for semantic matching)
36
- embedding BLOB, -- 384-dim embedding (multilingual-e5-small)
36
+ embedding BLOB, -- 1024-dim embedding (multilingual-e5-large)
37
37
 
38
38
  -- Metadata
39
39
  created_at INTEGER DEFAULT (unixepoch() * 1000),
@@ -0,0 +1,59 @@
1
+ -- v0.17: Extend kind CHECK constraint to include 'task' and 'schedule'.
2
+ -- Only runs if the old CHECK exists (idempotent).
3
+ -- Uses a temp table approach since SQLite cannot ALTER CHECK constraints.
4
+
5
+ -- Drop the old column constraint by recreating the table
6
+ -- This is safe because we explicitly list all columns
7
+
8
+ CREATE TABLE IF NOT EXISTS decisions_v17 (
9
+ id TEXT PRIMARY KEY,
10
+ topic TEXT NOT NULL,
11
+ decision TEXT NOT NULL,
12
+ reasoning TEXT,
13
+ outcome TEXT,
14
+ failure_reason TEXT,
15
+ limitation TEXT,
16
+ user_involvement TEXT,
17
+ session_id TEXT,
18
+ supersedes TEXT,
19
+ superseded_by TEXT,
20
+ refined_from TEXT,
21
+ confidence REAL DEFAULT 0.5 CHECK (confidence >= 0.0 AND confidence <= 1.0),
22
+ created_at INTEGER NOT NULL DEFAULT (strftime('%s','now') * 1000),
23
+ updated_at INTEGER NOT NULL DEFAULT (strftime('%s','now') * 1000),
24
+ needs_validation INTEGER DEFAULT 0 CHECK (needs_validation IN (0, 1)),
25
+ validation_attempts INTEGER DEFAULT 0,
26
+ last_validated_at INTEGER,
27
+ usage_count INTEGER DEFAULT 0,
28
+ trust_context TEXT,
29
+ usage_success INTEGER DEFAULT 0,
30
+ usage_failure INTEGER DEFAULT 0,
31
+ time_saved INTEGER DEFAULT 0,
32
+ evidence TEXT,
33
+ alternatives TEXT,
34
+ risks TEXT,
35
+ event_date TEXT,
36
+ kind TEXT DEFAULT 'decision'
37
+ CHECK (kind IN ('decision', 'preference', 'constraint', 'lesson', 'fact', 'task', 'schedule')),
38
+ status TEXT DEFAULT 'active'
39
+ CHECK (status IN ('active', 'superseded', 'contradicted', 'stale')),
40
+ summary TEXT,
41
+ is_static INTEGER DEFAULT 0
42
+ );
43
+
44
+ INSERT OR IGNORE INTO decisions_v17 (
45
+ id, topic, decision, reasoning, outcome, failure_reason, limitation,
46
+ user_involvement, session_id, supersedes, superseded_by, refined_from,
47
+ confidence, created_at, updated_at, needs_validation, validation_attempts,
48
+ last_validated_at, usage_count, trust_context, usage_success, usage_failure,
49
+ time_saved, evidence, alternatives, risks, event_date, kind, status, summary, is_static
50
+ ) SELECT
51
+ id, topic, decision, reasoning, outcome, failure_reason, limitation,
52
+ user_involvement, session_id, supersedes, superseded_by, refined_from,
53
+ confidence, created_at, updated_at, needs_validation, validation_attempts,
54
+ last_validated_at, usage_count, trust_context, usage_success, usage_failure,
55
+ time_saved, evidence, alternatives, risks, event_date, kind, status, summary, is_static
56
+ FROM decisions;
57
+
58
+ DROP TABLE decisions;
59
+ ALTER TABLE decisions_v17 RENAME TO decisions;
@@ -6,13 +6,14 @@
6
6
  *
7
7
  * Loads user configuration from ~/.mama/config.json with sensible defaults.
8
8
  * Supports:
9
- * - Model selection (default: multilingual-e5-small)
9
+ * - Model selection (default: multilingual-e5-large)
10
10
  * - Embedding dimensions
11
11
  * - Cache directory configuration
12
12
  *
13
13
  * @module config-loader
14
14
  */
15
15
  export interface MAMAConfig {
16
+ configVersion: number;
16
17
  modelName: string;
17
18
  embeddingDim: number;
18
19
  quantized: boolean;
@@ -7,7 +7,7 @@
7
7
  *
8
8
  * Loads user configuration from ~/.mama/config.json with sensible defaults.
9
9
  * Supports:
10
- * - Model selection (default: multilingual-e5-small)
10
+ * - Model selection (default: multilingual-e5-large)
11
11
  * - Embedding dimensions
12
12
  * - Cache directory configuration
13
13
  *
@@ -29,13 +29,48 @@ const fs_1 = __importDefault(require("fs"));
29
29
  const path_1 = __importDefault(require("path"));
30
30
  const os_1 = __importDefault(require("os"));
31
31
  const debug_logger_js_1 = require("./debug-logger.js");
32
+ // Current config version — bump this when adding migrations
33
+ const CURRENT_CONFIG_VERSION = 2;
32
34
  // Default configuration
33
35
  exports.DEFAULT_CONFIG = {
34
- modelName: 'Xenova/multilingual-e5-small',
35
- embeddingDim: 384,
36
+ configVersion: CURRENT_CONFIG_VERSION,
37
+ modelName: 'Xenova/multilingual-e5-large',
38
+ embeddingDim: 1024,
36
39
  quantized: true,
37
40
  cacheDir: path_1.default.join(os_1.default.homedir(), '.cache', 'huggingface', 'transformers'),
38
41
  };
42
+ /**
43
+ * Config migrations — each entry upgrades from (version - 1) to version.
44
+ * Migrations run sequentially and mutate the config object in place.
45
+ */
46
+ const CONFIG_MIGRATIONS = {
47
+ // v1 → v2: e5-small (384-dim) → e5-large (1024-dim)
48
+ 2: (cfg) => {
49
+ if (cfg.modelName === 'Xenova/multilingual-e5-small' && cfg.embeddingDim === 384) {
50
+ (0, debug_logger_js_1.info)('[config] Migration v2: upgrading embedding model e5-small → e5-large');
51
+ cfg.modelName = 'Xenova/multilingual-e5-large';
52
+ cfg.embeddingDim = 1024;
53
+ }
54
+ },
55
+ };
56
+ /**
57
+ * Apply pending migrations to a config object.
58
+ * Returns true if any migrations were applied.
59
+ */
60
+ function applyMigrations(config) {
61
+ const startVersion = config.configVersion || 1;
62
+ if (startVersion >= CURRENT_CONFIG_VERSION)
63
+ return false;
64
+ for (let v = startVersion + 1; v <= CURRENT_CONFIG_VERSION; v++) {
65
+ const migrate = CONFIG_MIGRATIONS[v];
66
+ if (migrate) {
67
+ migrate(config);
68
+ (0, debug_logger_js_1.info)(`[config] Applied migration v${v}`);
69
+ }
70
+ }
71
+ config.configVersion = CURRENT_CONFIG_VERSION;
72
+ return true;
73
+ }
39
74
  // Config file path
40
75
  const CONFIG_DIR = path_1.default.join(os_1.default.homedir(), '.mama');
41
76
  const CONFIG_PATH = path_1.default.join(CONFIG_DIR, 'config.json');
@@ -80,11 +115,19 @@ function loadConfig(reload = false) {
80
115
  // Read and parse config file
81
116
  const configData = fs_1.default.readFileSync(CONFIG_PATH, 'utf8');
82
117
  const userConfig = JSON.parse(configData);
118
+ // Determine file's config version before merging with defaults
119
+ const fileVersion = userConfig.configVersion || 1;
83
120
  // Merge with defaults (user config overrides)
84
121
  const config = {
85
122
  ...exports.DEFAULT_CONFIG,
86
123
  ...userConfig,
124
+ configVersion: fileVersion, // preserve file version for migration check
87
125
  };
126
+ // Apply pending migrations based on file's version
127
+ if (applyMigrations(config)) {
128
+ fs_1.default.writeFileSync(CONFIG_PATH, JSON.stringify(config, null, 2), 'utf8');
129
+ (0, debug_logger_js_1.info)(`[config] Migrated config saved to ${CONFIG_PATH}`);
130
+ }
88
131
  // Validate configuration
89
132
  if (!config.modelName || typeof config.modelName !== 'string') {
90
133
  (0, debug_logger_js_1.warn)('[config] Invalid modelName, using default:', exports.DEFAULT_CONFIG.modelName);
@@ -43,7 +43,7 @@ export declare abstract class DatabaseAdapter {
43
43
  abstract transaction<T>(fn: () => T): T;
44
44
  /**
45
45
  * Vector similarity search
46
- * @param embedding - Query embedding (384-dim)
46
+ * @param embedding - Query embedding (1024-dim)
47
47
  * @param limit - Max results
48
48
  * @returns Search results with distance
49
49
  */
@@ -156,7 +156,7 @@ export declare function listScopesForMemory(memoryId: string): Promise<Array<{
156
156
  * Stores embedding in the embeddings table for vector similarity search
157
157
  *
158
158
  * @param decisionRowid - SQLite rowid
159
- * @param embedding - 384-dim embedding vector
159
+ * @param embedding - 1024-dim embedding vector
160
160
  */
161
161
  export declare function insertEmbedding(decisionRowid: number, embedding: Float32Array | number[]): Promise<void>;
162
162
  /**
@@ -164,7 +164,7 @@ export declare function insertEmbedding(decisionRowid: number, embedding: Float3
164
164
  *
165
165
  * Returns empty array if vector search not available (no keyword fallback)
166
166
  *
167
- * @param queryEmbedding - Query embedding (384-dim)
167
+ * @param queryEmbedding - Query embedding (1024-dim)
168
168
  * @param limit - Max results to return (default: 5)
169
169
  * @param threshold - Minimum similarity threshold (default: 0.7)
170
170
  * @returns Array of decisions with similarity scores, or empty array
@@ -189,7 +189,7 @@ async function listScopesForMemory(memoryId) {
189
189
  * Stores embedding in the embeddings table for vector similarity search
190
190
  *
191
191
  * @param decisionRowid - SQLite rowid
192
- * @param embedding - 384-dim embedding vector
192
+ * @param embedding - 1024-dim embedding vector
193
193
  */
194
194
  async function insertEmbedding(decisionRowid, embedding) {
195
195
  const adapter = getAdapter();
@@ -207,7 +207,7 @@ async function insertEmbedding(decisionRowid, embedding) {
207
207
  *
208
208
  * Returns empty array if vector search not available (no keyword fallback)
209
209
  *
210
- * @param queryEmbedding - Query embedding (384-dim)
210
+ * @param queryEmbedding - Query embedding (1024-dim)
211
211
  * @param limit - Max results to return (default: 5)
212
212
  * @param threshold - Minimum similarity threshold (default: 0.7)
213
213
  * @returns Array of decisions with similarity scores, or empty array
@@ -2,7 +2,7 @@
2
2
  * MAMA (Memory-Augmented MCP Architecture) - Embedding Generation
3
3
  *
4
4
  * Story M1.4: Configurable embedding model selection
5
- * Generates embeddings using configurable model (default: multilingual-e5-small)
5
+ * Generates embeddings using configurable model (default: multilingual-e5-large)
6
6
  * Supports: Korean-English cross-lingual similarity, enhanced metadata
7
7
  *
8
8
  * @module embeddings
@@ -43,7 +43,7 @@ export declare function generateEmbedding(text: string): Promise<Float32Array>;
43
43
  * Inspired by A-mem: Content + Metadata for richer semantic representation
44
44
  *
45
45
  * @param decision - Decision object
46
- * @returns 384-dim enhanced embedding
46
+ * @returns 1024-dim enhanced embedding
47
47
  */
48
48
  export declare function generateEnhancedEmbedding(decision: DecisionForEmbedding): Promise<Float32Array>;
49
49
  /**
@@ -3,7 +3,7 @@
3
3
  * MAMA (Memory-Augmented MCP Architecture) - Embedding Generation
4
4
  *
5
5
  * Story M1.4: Configurable embedding model selection
6
- * Generates embeddings using configurable model (default: multilingual-e5-small)
6
+ * Generates embeddings using configurable model (default: multilingual-e5-large)
7
7
  * Supports: Korean-English cross-lingual similarity, enhanced metadata
8
8
  *
9
9
  * @module embeddings
@@ -142,7 +142,7 @@ async function generateEmbedding(text) {
142
142
  * Inspired by A-mem: Content + Metadata for richer semantic representation
143
143
  *
144
144
  * @param decision - Decision object
145
- * @returns 384-dim enhanced embedding
145
+ * @returns 1024-dim enhanced embedding
146
146
  */
147
147
  async function generateEnhancedEmbedding(decision) {
148
148
  // Construct enriched text representation with narrative fields (Story 2.2)
@@ -1,6 +1,6 @@
1
1
  export declare const MEMORY_SCOPE_KINDS: readonly ["global", "user", "channel", "project"];
2
2
  export type MemoryScopeKind = (typeof MEMORY_SCOPE_KINDS)[number];
3
- export declare const MEMORY_KINDS: readonly ["decision", "preference", "constraint", "lesson", "fact"];
3
+ export declare const MEMORY_KINDS: readonly ["decision", "preference", "constraint", "lesson", "fact", "task", "schedule", "compiled"];
4
4
  export type MemoryKind = (typeof MEMORY_KINDS)[number];
5
5
  export declare const MEMORY_STATUSES: readonly ["active", "superseded", "contradicted", "stale"];
6
6
  export type MemoryStatus = (typeof MEMORY_STATUSES)[number];
@@ -5,7 +5,16 @@ exports.createEmptyRecallBundle = createEmptyRecallBundle;
5
5
  exports.createEmptyMemoryAgentBootstrap = createEmptyMemoryAgentBootstrap;
6
6
  exports.createMemoryAuditAck = createMemoryAuditAck;
7
7
  exports.MEMORY_SCOPE_KINDS = ['global', 'user', 'channel', 'project'];
8
- exports.MEMORY_KINDS = ['decision', 'preference', 'constraint', 'lesson', 'fact'];
8
+ exports.MEMORY_KINDS = [
9
+ 'decision',
10
+ 'preference',
11
+ 'constraint',
12
+ 'lesson',
13
+ 'fact',
14
+ 'task',
15
+ 'schedule',
16
+ 'compiled',
17
+ ];
9
18
  exports.MEMORY_STATUSES = ['active', 'superseded', 'contradicted', 'stale'];
10
19
  exports.MEMORY_TRUTH_STATUSES = [
11
20
  'active',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jungjaehoon/mama-core",
3
- "version": "1.4.0",
3
+ "version": "1.4.2",
4
4
  "description": "MAMA Core - Shared modules for Memory-Augmented MCP Assistant",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",