@jungjaehoon/mama-core 1.4.1 → 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.
@@ -13,6 +13,7 @@
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;
@@ -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 = {
36
+ configVersion: CURRENT_CONFIG_VERSION,
34
37
  modelName: 'Xenova/multilingual-e5-large',
35
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);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jungjaehoon/mama-core",
3
- "version": "1.4.1",
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",