micro-models-agent 0.51.1 → 0.51.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.
Files changed (218) hide show
  1. package/README.md +358 -358
  2. package/dist/main.js +817 -573
  3. package/dist/modules/browser/bridge-server.mjs +202 -202
  4. package/dist/skills/builtin/git.md +36 -36
  5. package/dist/skills/builtin/typescript.md +35 -35
  6. package/package.json +48 -48
  7. package/dist/cli/commands.js +0 -323
  8. package/dist/cli/completer.js +0 -167
  9. package/dist/cli/index.js +0 -2
  10. package/dist/cli/main.js +0 -165
  11. package/dist/cli/plugin-commands.js +0 -36
  12. package/dist/cli/repl-commands.js +0 -661
  13. package/dist/cli/repl.js +0 -616
  14. package/dist/cli/run-result.js +0 -22
  15. package/dist/cli/security-commands.js +0 -164
  16. package/dist/cli/setup.js +0 -231
  17. package/dist/config/config.js +0 -249
  18. package/dist/config/defaults.js +0 -124
  19. package/dist/config/experts.js +0 -15
  20. package/dist/config/index.js +0 -3
  21. package/dist/config/security.js +0 -193
  22. package/dist/config/types.js +0 -1
  23. package/dist/core/agent-moe.js +0 -102
  24. package/dist/core/agent.js +0 -886
  25. package/dist/core/bootstrap.js +0 -404
  26. package/dist/core/index.js +0 -2
  27. package/dist/core/prompt-builder.js +0 -76
  28. package/dist/core/session-logger.js +0 -197
  29. package/dist/core/types.js +0 -1
  30. package/dist/core/version.js +0 -24
  31. package/dist/core/workspace.js +0 -76
  32. package/dist/i18n/en.json +0 -598
  33. package/dist/i18n/index.js +0 -46
  34. package/dist/i18n/ru.json +0 -598
  35. package/dist/index.js +0 -22
  36. package/dist/llm/image-utils.js +0 -143
  37. package/dist/llm/index.js +0 -4
  38. package/dist/llm/model-loader.js +0 -78
  39. package/dist/llm/openai-compat.js +0 -359
  40. package/dist/llm/orchestrator.js +0 -198
  41. package/dist/llm/provider.js +0 -10
  42. package/dist/llm/response.js +0 -39
  43. package/dist/llm/token-counter.js +0 -39
  44. package/dist/llm/types.js +0 -1
  45. package/dist/logger/app-logger.js +0 -143
  46. package/dist/logger/file-log.js +0 -151
  47. package/dist/logger/index.js +0 -1
  48. package/dist/migration/backup.js +0 -45
  49. package/dist/migration/detect.js +0 -50
  50. package/dist/migration/index.js +0 -2
  51. package/dist/modules/artifacts/store.js +0 -61
  52. package/dist/modules/browser/actions.js +0 -76
  53. package/dist/modules/browser/bridge-client.js +0 -199
  54. package/dist/modules/browser/bridge-path.js +0 -10
  55. package/dist/modules/browser/cookie-store.js +0 -24
  56. package/dist/modules/browser/driver.js +0 -136
  57. package/dist/modules/browser/index.js +0 -7
  58. package/dist/modules/browser/module.js +0 -29
  59. package/dist/modules/browser/session.js +0 -338
  60. package/dist/modules/browser/snapshot.js +0 -148
  61. package/dist/modules/browser/types.js +0 -12
  62. package/dist/modules/certification/cli.js +0 -174
  63. package/dist/modules/certification/fact-checker.js +0 -82
  64. package/dist/modules/certification/loader.js +0 -105
  65. package/dist/modules/certification/manifest.js +0 -50
  66. package/dist/modules/certification/runner.js +0 -159
  67. package/dist/modules/certification/scenarios.js +0 -124
  68. package/dist/modules/certification/types.js +0 -1
  69. package/dist/modules/context/chunk-query.js +0 -100
  70. package/dist/modules/context/fact-extractor.js +0 -162
  71. package/dist/modules/context/history.js +0 -15
  72. package/dist/modules/context/index.js +0 -1
  73. package/dist/modules/context/manager.js +0 -423
  74. package/dist/modules/execution/audit-runners.js +0 -152
  75. package/dist/modules/execution/auditor.js +0 -218
  76. package/dist/modules/execution/execution-plugin.js +0 -272
  77. package/dist/modules/execution/index.js +0 -8
  78. package/dist/modules/execution/module.js +0 -436
  79. package/dist/modules/execution/moe-executor.js +0 -291
  80. package/dist/modules/execution/plan-coverage.js +0 -68
  81. package/dist/modules/execution/plan-persister.js +0 -46
  82. package/dist/modules/execution/plan-store.js +0 -157
  83. package/dist/modules/execution/plan-tool.js +0 -508
  84. package/dist/modules/execution/plan-validator.js +0 -153
  85. package/dist/modules/execution/planner.js +0 -90
  86. package/dist/modules/execution/stuck-detector.js +0 -510
  87. package/dist/modules/execution/tracker.js +0 -67
  88. package/dist/modules/execution/types.js +0 -1
  89. package/dist/modules/execution/verifier.js +0 -222
  90. package/dist/modules/execution/windows-commands.js +0 -41
  91. package/dist/modules/hallucination/confidence.js +0 -66
  92. package/dist/modules/hallucination/consistency.js +0 -26
  93. package/dist/modules/hallucination/detector.js +0 -43
  94. package/dist/modules/hallucination/factual.js +0 -129
  95. package/dist/modules/hallucination/index.js +0 -5
  96. package/dist/modules/hallucination/js-identifiers.js +0 -262
  97. package/dist/modules/hallucination/llm-judge.js +0 -101
  98. package/dist/modules/index.js +0 -5
  99. package/dist/modules/indexer/cache.js +0 -40
  100. package/dist/modules/indexer/index.js +0 -3
  101. package/dist/modules/indexer/module.js +0 -245
  102. package/dist/modules/indexer/project-profile.js +0 -183
  103. package/dist/modules/indexer/walker.js +0 -101
  104. package/dist/modules/lsp/check-tool.js +0 -58
  105. package/dist/modules/lsp/client.js +0 -278
  106. package/dist/modules/lsp/command.js +0 -60
  107. package/dist/modules/lsp/config.js +0 -135
  108. package/dist/modules/lsp/index.js +0 -3
  109. package/dist/modules/lsp/module.js +0 -232
  110. package/dist/modules/lsp/probe.js +0 -76
  111. package/dist/modules/lsp/project-root.js +0 -32
  112. package/dist/modules/lsp/startup-check.js +0 -141
  113. package/dist/modules/lsp/types.js +0 -1
  114. package/dist/modules/mcp/client.js +0 -399
  115. package/dist/modules/mcp/index.js +0 -3
  116. package/dist/modules/mcp/module.js +0 -142
  117. package/dist/modules/mcp/registry.js +0 -15
  118. package/dist/modules/memory/index.js +0 -1
  119. package/dist/modules/memory/module.js +0 -96
  120. package/dist/modules/memory/search.js +0 -42
  121. package/dist/modules/memory/store.js +0 -69
  122. package/dist/modules/pipelines/engine.js +0 -60
  123. package/dist/modules/pipelines/index.js +0 -3
  124. package/dist/modules/pipelines/parser.js +0 -56
  125. package/dist/modules/pipelines/template.js +0 -14
  126. package/dist/modules/plugins/builtin/lint-on-write.js +0 -231
  127. package/dist/modules/plugins/builtin/notify.js +0 -9
  128. package/dist/modules/plugins/index.js +0 -1
  129. package/dist/modules/plugins/loader.js +0 -70
  130. package/dist/modules/plugins/manager.js +0 -217
  131. package/dist/modules/plugins/types.js +0 -1
  132. package/dist/modules/processes/detect.js +0 -34
  133. package/dist/modules/processes/index.js +0 -2
  134. package/dist/modules/processes/registry.js +0 -327
  135. package/dist/modules/processes/runner.js +0 -23
  136. package/dist/modules/registry.js +0 -47
  137. package/dist/modules/security/audit-log.js +0 -136
  138. package/dist/modules/security/audit-notifier.js +0 -292
  139. package/dist/modules/security/command-validator.js +0 -205
  140. package/dist/modules/security/content-scanner.js +0 -53
  141. package/dist/modules/security/data-sanitizer.js +0 -89
  142. package/dist/modules/security/encryption.js +0 -242
  143. package/dist/modules/security/index.js +0 -14
  144. package/dist/modules/security/network-validator.js +0 -71
  145. package/dist/modules/security/path-validator.js +0 -207
  146. package/dist/modules/security/rate-limiter.js +0 -119
  147. package/dist/modules/security/security-policies.js +0 -531
  148. package/dist/modules/security/session-encryption.js +0 -210
  149. package/dist/modules/security/session-isolation.js +0 -95
  150. package/dist/modules/session/index.js +0 -3
  151. package/dist/modules/session/manager.js +0 -172
  152. package/dist/modules/session/module.js +0 -24
  153. package/dist/modules/session/store.js +0 -222
  154. package/dist/modules/session/types.js +0 -1
  155. package/dist/modules/skills/index.js +0 -2
  156. package/dist/modules/skills/loader.js +0 -72
  157. package/dist/modules/skills/matcher.js +0 -27
  158. package/dist/modules/skills/module.js +0 -129
  159. package/dist/modules/types.js +0 -1
  160. package/dist/modules/updater/checker.js +0 -96
  161. package/dist/modules/updater/index.js +0 -2
  162. package/dist/modules/updater/module.js +0 -116
  163. package/dist/modules/user-profile/compressor.js +0 -16
  164. package/dist/modules/user-profile/index.js +0 -1
  165. package/dist/modules/user-profile/profile.js +0 -68
  166. package/dist/tools/approve.js +0 -32
  167. package/dist/tools/attach-image.js +0 -89
  168. package/dist/tools/bash.js +0 -496
  169. package/dist/tools/browser.js +0 -114
  170. package/dist/tools/chunk-query.js +0 -99
  171. package/dist/tools/create-dir.js +0 -55
  172. package/dist/tools/delete-file.js +0 -62
  173. package/dist/tools/download-file.js +0 -116
  174. package/dist/tools/edit-file.js +0 -79
  175. package/dist/tools/enable-tools.js +0 -58
  176. package/dist/tools/executor.js +0 -144
  177. package/dist/tools/file-info.js +0 -46
  178. package/dist/tools/filter-tools.js +0 -17
  179. package/dist/tools/glob-tool.js +0 -26
  180. package/dist/tools/grep-tool.js +0 -84
  181. package/dist/tools/hidden-tools-block.js +0 -37
  182. package/dist/tools/index.js +0 -78
  183. package/dist/tools/list-dir.js +0 -48
  184. package/dist/tools/load-skill.js +0 -42
  185. package/dist/tools/mcp-call.js +0 -68
  186. package/dist/tools/move-file.js +0 -85
  187. package/dist/tools/path-utils.js +0 -51
  188. package/dist/tools/pipeline-run.js +0 -144
  189. package/dist/tools/preview.js +0 -2
  190. package/dist/tools/process-kill.js +0 -29
  191. package/dist/tools/process-list.js +0 -36
  192. package/dist/tools/process-log.js +0 -45
  193. package/dist/tools/question.js +0 -140
  194. package/dist/tools/read-file.js +0 -91
  195. package/dist/tools/recall.js +0 -117
  196. package/dist/tools/registry.js +0 -47
  197. package/dist/tools/remember.js +0 -67
  198. package/dist/tools/scope-check.js +0 -30
  199. package/dist/tools/search-history.js +0 -84
  200. package/dist/tools/subagent.js +0 -196
  201. package/dist/tools/types.js +0 -1
  202. package/dist/tools/user-input.js +0 -123
  203. package/dist/tools/web-browse.js +0 -86
  204. package/dist/tools/web-fetch.js +0 -98
  205. package/dist/tools/web-search.js +0 -78
  206. package/dist/tools/write-file.js +0 -81
  207. package/dist/ui/box.js +0 -77
  208. package/dist/ui/colors.js +0 -4
  209. package/dist/ui/diff.js +0 -178
  210. package/dist/ui/index.js +0 -6
  211. package/dist/ui/line-editor.js +0 -703
  212. package/dist/ui/line-math.js +0 -69
  213. package/dist/ui/md-formatter.js +0 -212
  214. package/dist/ui/output.js +0 -13
  215. package/dist/ui/plan-view.js +0 -103
  216. package/dist/ui/renderer.js +0 -209
  217. package/dist/ui/spinner.js +0 -70
  218. package/dist/ui/table.js +0 -144
package/dist/main.js CHANGED
@@ -2634,6 +2634,7 @@ Fix the error and re-edit the file (a clean write clears the failure), or mark t
2634
2634
  "cli.set_value": "Set a config value",
2635
2635
  "cli.set_done": "Set {key}={value}",
2636
2636
  "cli.show_config": "Show current config",
2637
+ "cli.migrate_config": "Migrate legacy config.json to domain format",
2637
2638
  "cli.manage_models": "Manage models",
2638
2639
  "cli.list_models": "List available models",
2639
2640
  "cli.current_model": "Current model:",
@@ -3020,6 +3021,11 @@ Apply a matching solution from these results. If none is relevant — do NOT rep
3020
3021
  "tool.friendly.project_map": "Project map",
3021
3022
  "config.decryption_warning": "Warning: Failed to decrypt config: {error}",
3022
3023
  "config.encryption_warning": "Warning: Failed to encrypt config: {error}",
3024
+ "config.migrate_start": "Migrating config to domain format...",
3025
+ "config.migrate_done": "Migration complete. Created {count} domain files. Legacy saved as config.json.bak.",
3026
+ "config.migrate_no_legacy": "No legacy config.json found. Already using domain format.",
3027
+ "config.migrate_error": "Migration failed: {error}",
3028
+ "config.legacy_hint": 'Config: using legacy config.json. Run "mma config migrate" to switch to domain format.',
3023
3029
  "image.source_required": 'Image source is required. Provide a file path, URL, or "clipboard".',
3024
3030
  "image.clipboard_empty": "Clipboard does not contain an image. Copy an image first (e.g. screenshot with Win+Shift+S).",
3025
3031
  "image.not_found": "Image file not found: {path}",
@@ -3353,6 +3359,7 @@ var init_ru = __esm(() => {
3353
3359
  "cli.set_value": "Установить значение",
3354
3360
  "cli.set_done": "Установлено {key}={value}",
3355
3361
  "cli.show_config": "Показать текущий конфиг",
3362
+ "cli.migrate_config": "Мигрировать legacy config.json в domain-формат",
3356
3363
  "cli.manage_models": "Управление моделями",
3357
3364
  "cli.list_models": "Список доступных моделей",
3358
3365
  "cli.current_model": "Текущая модель:",
@@ -3739,6 +3746,11 @@ var init_ru = __esm(() => {
3739
3746
  "tool.friendly.project_map": "Карта проекта",
3740
3747
  "config.decryption_warning": "Предупреждение: не удалось расшифровать конфигурацию: {error}",
3741
3748
  "config.encryption_warning": "Предупреждение: не удалось зашифровать конфигурацию: {error}",
3749
+ "config.migrate_start": "Миграция конфига в domain-формат...",
3750
+ "config.migrate_done": "Миграция завершена. Создано {count} domain файлов. Legacy сохранён как config.json.bak.",
3751
+ "config.migrate_no_legacy": "Legacy config.json не найден. Уже используется domain-формат.",
3752
+ "config.migrate_error": "Ошибка миграции: {error}",
3753
+ "config.legacy_hint": 'Config: используется legacy config.json. Запустите "mma config migrate" для перехода к domain-формату.',
3742
3754
  "image.source_required": 'Укажите источник изображения: путь к файлу, URL или "clipboard".',
3743
3755
  "image.clipboard_empty": "Буфер обмена не содержит изображение. Скопируйте изображение (например, скриншот через Win+Shift+S).",
3744
3756
  "image.not_found": "Файл изображения не найден: {path}",
@@ -4142,15 +4154,163 @@ var init_encryption = __esm(() => {
4142
4154
  ];
4143
4155
  });
4144
4156
 
4157
+ // src/config/domains.ts
4158
+ var exports_domains = {};
4159
+ __export(exports_domains, {
4160
+ saveDomainFiles: () => saveDomainFiles,
4161
+ loadDomainFiles: () => loadDomainFiles,
4162
+ hasDomainFiles: () => hasDomainFiles,
4163
+ getDomainFilePath: () => getDomainFilePath,
4164
+ extractDomain: () => extractDomain,
4165
+ domainForKey: () => domainForKey,
4166
+ CONFIG_DOMAINS: () => CONFIG_DOMAINS
4167
+ });
4168
+ import { existsSync as existsSync4, readFileSync as readFileSync3, writeFileSync as writeFileSync3, mkdirSync as mkdirSync2, readdirSync as readdirSync3 } from "fs";
4169
+ import { join as join4 } from "path";
4170
+ function regexReplacer(_key, value) {
4171
+ if (value instanceof RegExp) {
4172
+ return { __regex: true, source: value.source, flags: value.flags };
4173
+ }
4174
+ return value;
4175
+ }
4176
+ function regexReviver(_key, value) {
4177
+ if (value && typeof value === "object" && value.__regex === true) {
4178
+ const { source, flags } = value;
4179
+ try {
4180
+ return new RegExp(source, flags);
4181
+ } catch {
4182
+ return value;
4183
+ }
4184
+ }
4185
+ return value;
4186
+ }
4187
+ function deepMerge(target, source) {
4188
+ const result = { ...target };
4189
+ for (const key of Object.keys(source)) {
4190
+ const srcVal = source[key];
4191
+ const tgtVal = target[key];
4192
+ if (srcVal !== null && srcVal !== undefined && typeof srcVal === "object" && !Array.isArray(srcVal) && typeof tgtVal === "object" && !Array.isArray(tgtVal)) {
4193
+ result[key] = deepMerge(tgtVal, srcVal);
4194
+ } else if (srcVal !== undefined) {
4195
+ result[key] = srcVal;
4196
+ }
4197
+ }
4198
+ return result;
4199
+ }
4200
+ function extractDomain(config, domain) {
4201
+ const keys = CONFIG_DOMAINS[domain];
4202
+ if (!keys)
4203
+ return {};
4204
+ const subset = {};
4205
+ for (const key of keys) {
4206
+ if (config[key] !== undefined) {
4207
+ subset[key] = config[key];
4208
+ }
4209
+ }
4210
+ return subset;
4211
+ }
4212
+ function getDomainFilePath(configDir, domain) {
4213
+ return join4(configDir, "config", `${domain}.json`);
4214
+ }
4215
+ function hasDomainFiles(configDir) {
4216
+ const configDirPath = join4(configDir, "config");
4217
+ if (!existsSync4(configDirPath))
4218
+ return false;
4219
+ try {
4220
+ const files = readdirSync3(configDirPath);
4221
+ return files.some((f) => f.endsWith(".json"));
4222
+ } catch {
4223
+ return false;
4224
+ }
4225
+ }
4226
+ function loadDomainFiles(configDir) {
4227
+ const configDirPath = join4(configDir, "config");
4228
+ if (!existsSync4(configDirPath))
4229
+ return null;
4230
+ let result = {};
4231
+ let anyLoaded = false;
4232
+ for (const domain of Object.keys(CONFIG_DOMAINS)) {
4233
+ const filePath = getDomainFilePath(configDir, domain);
4234
+ if (!existsSync4(filePath))
4235
+ continue;
4236
+ try {
4237
+ const raw = readFileSync3(filePath, "utf-8");
4238
+ const data = JSON.parse(raw, regexReviver);
4239
+ result = deepMerge(result, data);
4240
+ anyLoaded = true;
4241
+ } catch {}
4242
+ }
4243
+ return anyLoaded ? result : null;
4244
+ }
4245
+ function saveDomainFiles(config, configDir) {
4246
+ const configDirPath = join4(configDir, "config");
4247
+ mkdirSync2(configDirPath, { recursive: true });
4248
+ for (const [domain, keys] of Object.entries(CONFIG_DOMAINS)) {
4249
+ const subset = {};
4250
+ let hasContent = false;
4251
+ for (const key of keys) {
4252
+ if (config[key] !== undefined) {
4253
+ subset[key] = config[key];
4254
+ hasContent = true;
4255
+ }
4256
+ }
4257
+ if (!hasContent)
4258
+ continue;
4259
+ const filePath = getDomainFilePath(configDir, domain);
4260
+ writeFileSync3(filePath, JSON.stringify(subset, regexReplacer, 2), "utf-8");
4261
+ }
4262
+ }
4263
+ function domainForKey(key) {
4264
+ for (const [domain, keys] of Object.entries(CONFIG_DOMAINS)) {
4265
+ if (keys.includes(key))
4266
+ return domain;
4267
+ }
4268
+ return null;
4269
+ }
4270
+ var CONFIG_DOMAINS;
4271
+ var init_domains = __esm(() => {
4272
+ CONFIG_DOMAINS = {
4273
+ core: [
4274
+ "version",
4275
+ "model",
4276
+ "contextWindow",
4277
+ "contextBudget",
4278
+ "modelLoad",
4279
+ "maxToolIterations",
4280
+ "stuckThreshold",
4281
+ "autoPlan",
4282
+ "showReasoning",
4283
+ "logLevel",
4284
+ "locale"
4285
+ ],
4286
+ provider: ["provider", "orchestrator", "retry", "pricing"],
4287
+ moe: ["moe", "experts"],
4288
+ security: ["security"],
4289
+ browser: ["browser"],
4290
+ search: ["webSearch", "errorWebSearch"],
4291
+ tools: ["tools", "subagent"],
4292
+ session: ["session", "sessionIsolation"],
4293
+ ui: ["ui"],
4294
+ mcp: ["mcpServers"],
4295
+ lsp: ["lsp"],
4296
+ skills: ["skills"],
4297
+ updater: ["updater"]
4298
+ };
4299
+ });
4300
+
4145
4301
  // src/config/config.ts
4146
4302
  var exports_config = {};
4147
4303
  __export(exports_config, {
4148
4304
  validateConfig: () => validateConfig,
4149
4305
  saveConfig: () => saveConfig,
4150
- loadConfig: () => loadConfig
4306
+ loadConfig: () => loadConfig,
4307
+ CONFIG_FILE: () => CONFIG_FILE,
4308
+ CONFIG_DOMAIN_DIR: () => CONFIG_DOMAIN_DIR,
4309
+ CONFIG_DIR: () => CONFIG_DIR
4151
4310
  });
4152
- import { existsSync as existsSync4, readFileSync as readFileSync3, unlinkSync, writeFileSync as writeFileSync3, mkdirSync as mkdirSync2 } from "fs";
4153
- import { join as join4, dirname } from "path";
4311
+ import { existsSync as existsSync5, readFileSync as readFileSync4, unlinkSync, writeFileSync as writeFileSync4, mkdirSync as mkdirSync3 } from "fs";
4312
+ import { join as join5, dirname } from "path";
4313
+ import { homedir as homedir2 } from "os";
4154
4314
  function restoreDangerousPatterns(patterns, defaults) {
4155
4315
  const fallback = Array.isArray(defaults) ? defaults : [];
4156
4316
  if (!Array.isArray(patterns) || patterns.length === 0) {
@@ -4170,26 +4330,26 @@ function restoreDangerousPatterns(patterns, defaults) {
4170
4330
  return fallback[i] || fallback[0] || p;
4171
4331
  });
4172
4332
  }
4173
- function deepMerge(target, source) {
4333
+ function deepMerge2(target, source) {
4174
4334
  const result = { ...target };
4175
4335
  for (const key of Object.keys(source)) {
4176
4336
  const srcVal = source[key];
4177
4337
  const tgtVal = target[key];
4178
4338
  if (srcVal !== null && srcVal !== undefined && typeof srcVal === "object" && !Array.isArray(srcVal) && typeof tgtVal === "object" && !Array.isArray(tgtVal)) {
4179
- result[key] = deepMerge(tgtVal, srcVal);
4339
+ result[key] = deepMerge2(tgtVal, srcVal);
4180
4340
  } else if (srcVal !== undefined) {
4181
4341
  result[key] = srcVal;
4182
4342
  }
4183
4343
  }
4184
4344
  return result;
4185
4345
  }
4186
- function regexReplacer(_key, value) {
4346
+ function regexReplacer2(_key, value) {
4187
4347
  if (value instanceof RegExp) {
4188
4348
  return { __regex: true, source: value.source, flags: value.flags };
4189
4349
  }
4190
4350
  return value;
4191
4351
  }
4192
- function regexReviver(_key, value) {
4352
+ function regexReviver2(_key, value) {
4193
4353
  if (value && typeof value === "object" && value.__regex === true) {
4194
4354
  const { source, flags } = value;
4195
4355
  try {
@@ -4219,8 +4379,8 @@ function normalizeLspServerArgs(config) {
4219
4379
  }
4220
4380
  function loadJSON(path) {
4221
4381
  try {
4222
- if (existsSync4(path)) {
4223
- return JSON.parse(readFileSync3(path, "utf-8"), regexReviver);
4382
+ if (existsSync5(path)) {
4383
+ return JSON.parse(readFileSync4(path, "utf-8"), regexReviver2);
4224
4384
  }
4225
4385
  } catch {}
4226
4386
  return null;
@@ -4262,8 +4422,8 @@ function applyEnvVars(config) {
4262
4422
  return result;
4263
4423
  }
4264
4424
  function loadConfig(options) {
4265
- const globalPath = join4(options.configDir, "config.json");
4266
- mkdirSync2(options.configDir, { recursive: true });
4425
+ const globalPath = join5(options.configDir, "config.json");
4426
+ mkdirSync3(options.configDir, { recursive: true });
4267
4427
  const detector = new MigrationDetector(options.configDir);
4268
4428
  if (detector.needsMigration()) {
4269
4429
  const backup = new BackupManager(options.configDir);
@@ -4275,16 +4435,23 @@ function loadConfig(options) {
4275
4435
  } catch {}
4276
4436
  }
4277
4437
  let config = { ...DEFAULTS };
4438
+ let legacyDetected = false;
4278
4439
  const globalData = loadJSON(globalPath);
4279
4440
  if (globalData) {
4280
- config = deepMerge(config, globalData);
4441
+ config = deepMerge2(config, globalData);
4442
+ legacyDetected = true;
4443
+ }
4444
+ const domainConfig = loadDomainFiles(options.configDir);
4445
+ if (domainConfig) {
4446
+ config = deepMerge2(config, domainConfig);
4447
+ legacyDetected = false;
4281
4448
  }
4282
- if (!existsSync4(globalPath)) {
4283
- saveConfig(config, globalPath);
4449
+ if (!globalData && !domainConfig) {
4450
+ saveDomainFiles(config, options.configDir);
4284
4451
  }
4285
4452
  const projectData = loadJSON(options.projectConfigPath);
4286
4453
  if (projectData) {
4287
- config = deepMerge(config, projectData);
4454
+ config = deepMerge2(config, projectData);
4288
4455
  }
4289
4456
  if (config.security?.contentScan?.dangerousPatterns) {
4290
4457
  config.security.contentScan.dangerousPatterns = restoreDangerousPatterns(config.security.contentScan.dangerousPatterns, DEFAULT_SECURITY_CONFIG.contentScan.dangerousPatterns);
@@ -4300,7 +4467,7 @@ function loadConfig(options) {
4300
4467
  } catch (e) {
4301
4468
  console.warn(t("config.decryption_warning", { error: e.message }));
4302
4469
  }
4303
- return config;
4470
+ return { config, legacyDetected };
4304
4471
  }
4305
4472
  function validateConfig(config, allToolTags) {
4306
4473
  const errors = validateExpertConfig(config, allToolTags);
@@ -4316,21 +4483,25 @@ ${errors.join(`
4316
4483
  `)}`);
4317
4484
  }
4318
4485
  }
4319
- function saveConfig(config, configPath) {
4486
+ function saveConfig(config, configPath, configDir) {
4487
+ if (configDir) {
4488
+ saveDomainFiles(config, configDir);
4489
+ return;
4490
+ }
4320
4491
  const dir = dirname(configPath);
4321
- mkdirSync2(dir, { recursive: true });
4492
+ mkdirSync3(dir, { recursive: true });
4322
4493
  try {
4323
4494
  const encryptor = new ConfigEncryptor;
4324
4495
  const encryptedConfig = encryptor.encrypt({
4325
4496
  ...config
4326
4497
  });
4327
- writeFileSync3(configPath, JSON.stringify(encryptedConfig, regexReplacer, 2), "utf-8");
4498
+ writeFileSync4(configPath, JSON.stringify(encryptedConfig, regexReplacer2, 2), "utf-8");
4328
4499
  } catch (e) {
4329
4500
  console.warn(t("config.encryption_warning", { error: e.message }));
4330
- writeFileSync3(configPath, JSON.stringify(config, regexReplacer, 2), "utf-8");
4501
+ writeFileSync4(configPath, JSON.stringify(config, regexReplacer2, 2), "utf-8");
4331
4502
  }
4332
4503
  }
4333
- var LEGACY_LSP_SERVER_ARGS;
4504
+ var CONFIG_DIR, CONFIG_FILE, CONFIG_DOMAIN_DIR, LEGACY_LSP_SERVER_ARGS;
4334
4505
  var init_config2 = __esm(() => {
4335
4506
  init_defaults();
4336
4507
  init_security();
@@ -4339,6 +4510,10 @@ var init_config2 = __esm(() => {
4339
4510
  init_detect();
4340
4511
  init_backup();
4341
4512
  init_encryption();
4513
+ init_domains();
4514
+ CONFIG_DIR = join5(homedir2(), ".mma");
4515
+ CONFIG_FILE = join5(CONFIG_DIR, "config.json");
4516
+ CONFIG_DOMAIN_DIR = join5(CONFIG_DIR, "config");
4342
4517
  LEGACY_LSP_SERVER_ARGS = {
4343
4518
  typescript: { args: ["typescript-language-server", "--stdio"], timeout: 30000 },
4344
4519
  javascript: { args: ["typescript-language-server", "--stdio"], timeout: 30000 },
@@ -4409,31 +4584,31 @@ var init_data_sanitizer = __esm(() => {
4409
4584
  // src/logger/file-log.ts
4410
4585
  import {
4411
4586
  appendFileSync,
4412
- mkdirSync as mkdirSync3,
4413
- existsSync as existsSync5,
4414
- readdirSync as readdirSync3,
4587
+ mkdirSync as mkdirSync4,
4588
+ existsSync as existsSync6,
4589
+ readdirSync as readdirSync4,
4415
4590
  renameSync,
4416
4591
  statSync,
4417
4592
  unlinkSync as unlinkSync2
4418
4593
  } from "node:fs";
4419
- import { join as join5 } from "node:path";
4594
+ import { join as join6 } from "node:path";
4420
4595
 
4421
4596
  class FileLogWriter {
4422
4597
  logDir = null;
4423
4598
  sessionLogPath = null;
4424
4599
  setLogDir(dir) {
4425
4600
  this.logDir = dir;
4426
- if (!existsSync5(dir)) {
4427
- mkdirSync3(dir, { recursive: true });
4601
+ if (!existsSync6(dir)) {
4602
+ mkdirSync4(dir, { recursive: true });
4428
4603
  }
4429
4604
  }
4430
4605
  initSessionLog(sessionId) {
4431
4606
  if (!this.logDir)
4432
4607
  return;
4433
- if (!existsSync5(this.logDir)) {
4434
- mkdirSync3(this.logDir, { recursive: true });
4608
+ if (!existsSync6(this.logDir)) {
4609
+ mkdirSync4(this.logDir, { recursive: true });
4435
4610
  }
4436
- this.sessionLogPath = join5(this.logDir, `${sessionId}.log`);
4611
+ this.sessionLogPath = join6(this.logDir, `${sessionId}.log`);
4437
4612
  this.cleanupOldLogs();
4438
4613
  }
4439
4614
  closeSessionLog() {
@@ -4445,16 +4620,16 @@ class FileLogWriter {
4445
4620
  if (!this.logDir)
4446
4621
  return "";
4447
4622
  const date = new Date().toISOString().slice(0, 10);
4448
- return join5(this.logDir, `${date}.log`);
4623
+ return join6(this.logDir, `${date}.log`);
4449
4624
  }
4450
4625
  rotateIfNeeded(filePath) {
4451
- if (!existsSync5(filePath))
4626
+ if (!existsSync6(filePath))
4452
4627
  return;
4453
4628
  const size = statSync(filePath).size;
4454
4629
  if (size < MAX_LOG_SIZE)
4455
4630
  return;
4456
4631
  let idx = 1;
4457
- while (existsSync5(`${filePath}.${idx}`))
4632
+ while (existsSync6(`${filePath}.${idx}`))
4458
4633
  idx++;
4459
4634
  renameSync(filePath, `${filePath}.${idx}`);
4460
4635
  }
@@ -4462,8 +4637,8 @@ class FileLogWriter {
4462
4637
  const fp = this.getLogPath();
4463
4638
  if (!fp)
4464
4639
  return;
4465
- if (this.logDir && !existsSync5(this.logDir)) {
4466
- mkdirSync3(this.logDir, { recursive: true });
4640
+ if (this.logDir && !existsSync6(this.logDir)) {
4641
+ mkdirSync4(this.logDir, { recursive: true });
4467
4642
  }
4468
4643
  this.rotateIfNeeded(fp);
4469
4644
  const line = `[${new Date().toISOString()}] [${level}] [${tag}] ${message}
@@ -4504,13 +4679,13 @@ ${trimmed}`);
4504
4679
  this.log("INFO", `REPL/${tag}`, trimmed);
4505
4680
  }
4506
4681
  cleanupOldLogs(maxDays = DEFAULT_MAX_DAYS, maxFiles = MAX_LOG_FILES) {
4507
- if (!this.logDir || !existsSync5(this.logDir))
4682
+ if (!this.logDir || !existsSync6(this.logDir))
4508
4683
  return;
4509
4684
  const now = Date.now();
4510
- const list = () => readdirSync3(this.logDir).filter((f) => f.endsWith(".log") || /\.log\.\d+$/.test(f)).map((f) => ({
4685
+ const list = () => readdirSync4(this.logDir).filter((f) => f.endsWith(".log") || /\.log\.\d+$/.test(f)).map((f) => ({
4511
4686
  name: f,
4512
- path: join5(this.logDir, f),
4513
- mtime: statSync(join5(this.logDir, f)).mtimeMs
4687
+ path: join6(this.logDir, f),
4688
+ mtime: statSync(join6(this.logDir, f)).mtimeMs
4514
4689
  })).sort((a, b) => b.mtime - a.mtime);
4515
4690
  for (const f of list()) {
4516
4691
  if (now - f.mtime > maxDays * 24 * 60 * 60 * 1000) {
@@ -4603,8 +4778,8 @@ var require_picocolors = __commonJS((exports, module) => {
4603
4778
  });
4604
4779
 
4605
4780
  // src/logger/app-logger.ts
4606
- import { appendFileSync as appendFileSync2, mkdirSync as mkdirSync4, existsSync as existsSync6 } from "fs";
4607
- import { join as join6 } from "path";
4781
+ import { appendFileSync as appendFileSync2, mkdirSync as mkdirSync5, existsSync as existsSync7 } from "fs";
4782
+ import { join as join7 } from "path";
4608
4783
  function isColorEnabled() {
4609
4784
  return !process.env.NO_COLOR && !process.env.CI && process.stdout.isTTY === true;
4610
4785
  }
@@ -4625,15 +4800,15 @@ class Logger {
4625
4800
  }
4626
4801
  setLogDir(dir) {
4627
4802
  this.logDir = dir;
4628
- if (!existsSync6(dir)) {
4629
- mkdirSync4(dir, { recursive: true });
4803
+ if (!existsSync7(dir)) {
4804
+ mkdirSync5(dir, { recursive: true });
4630
4805
  }
4631
4806
  this.fileLog.setLogDir(dir);
4632
4807
  }
4633
4808
  setSessionDir(dir) {
4634
4809
  this.sessionDir = dir;
4635
- if (!existsSync6(dir)) {
4636
- mkdirSync4(dir, { recursive: true });
4810
+ if (!existsSync7(dir)) {
4811
+ mkdirSync5(dir, { recursive: true });
4637
4812
  }
4638
4813
  }
4639
4814
  clearSessionDir() {
@@ -4700,7 +4875,7 @@ class Logger {
4700
4875
  const logTarget = this.sessionDir ?? this.logDir;
4701
4876
  if (logTarget) {
4702
4877
  try {
4703
- appendFileSync2(join6(logTarget, "app.jsonl"), JSON.stringify({
4878
+ appendFileSync2(join7(logTarget, "app.jsonl"), JSON.stringify({
4704
4879
  level,
4705
4880
  ts,
4706
4881
  prefix: this.prefix,
@@ -4729,7 +4904,7 @@ class Logger {
4729
4904
  if (!logTarget)
4730
4905
  return;
4731
4906
  try {
4732
- appendFileSync2(join6(logTarget, "app.jsonl"), JSON.stringify({
4907
+ appendFileSync2(join7(logTarget, "app.jsonl"), JSON.stringify({
4733
4908
  level: "info",
4734
4909
  ts: new Date().toISOString(),
4735
4910
  type,
@@ -4746,7 +4921,7 @@ class Logger {
4746
4921
  const sanitizedMsg = sanitizeLogMessage(msg);
4747
4922
  const sanitizedMeta = meta ? this.sanitizeMeta(meta) : undefined;
4748
4923
  try {
4749
- appendFileSync2(join6(logTarget, "app.jsonl"), JSON.stringify({
4924
+ appendFileSync2(join7(logTarget, "app.jsonl"), JSON.stringify({
4750
4925
  level,
4751
4926
  ts,
4752
4927
  prefix: this.prefix,
@@ -6446,7 +6621,7 @@ var init_executor = __esm(() => {
6446
6621
 
6447
6622
  // src/tools/path-utils.ts
6448
6623
  import { resolve, normalize, dirname as dirname2, basename, sep, relative, isAbsolute } from "path";
6449
- import { existsSync as existsSync7 } from "fs";
6624
+ import { existsSync as existsSync8 } from "fs";
6450
6625
  function isInsideDir(targetPath, dirPath) {
6451
6626
  const norm = (p) => process.platform === "win32" ? p.toLowerCase() : p;
6452
6627
  const t2 = norm(resolve(targetPath));
@@ -6464,23 +6639,23 @@ function matchesScopeEntry(targetResolved, entryResolved) {
6464
6639
  function safeResolvePath(baseDir, userPath) {
6465
6640
  const asIs = resolve(normalize(userPath));
6466
6641
  if (userPath.startsWith("/") || userPath.startsWith("\\")) {
6467
- if (existsSync7(asIs) || existsSync7(dirname2(asIs)))
6642
+ if (existsSync8(asIs) || existsSync8(dirname2(asIs)))
6468
6643
  return asIs;
6469
6644
  }
6470
6645
  const norm = normalize(userPath);
6471
6646
  if (isAbsolute(norm)) {
6472
- if (existsSync7(norm) || existsSync7(dirname2(norm)))
6647
+ if (existsSync8(norm) || existsSync8(dirname2(norm)))
6473
6648
  return norm;
6474
6649
  const stripped2 = norm.replace(/^[/\\]/, "");
6475
6650
  const relativeCandidate = resolve(baseDir, stripped2);
6476
- if (existsSync7(relativeCandidate) || existsSync7(dirname2(relativeCandidate))) {
6651
+ if (existsSync8(relativeCandidate) || existsSync8(dirname2(relativeCandidate))) {
6477
6652
  return relativeCandidate;
6478
6653
  }
6479
6654
  return norm;
6480
6655
  }
6481
6656
  const stripped = norm.replace(/^[/\\]/, "");
6482
6657
  const resolved = resolve(baseDir, stripped);
6483
- if (existsSync7(resolved) || existsSync7(dirname2(resolved)))
6658
+ if (existsSync8(resolved) || existsSync8(dirname2(resolved)))
6484
6659
  return resolved;
6485
6660
  const baseNorm = normalize(baseDir);
6486
6661
  let cur = baseNorm;
@@ -6497,11 +6672,11 @@ function safeResolvePath(baseDir, userPath) {
6497
6672
  if (afterChar && afterChar !== "\\" && afterChar !== "/") {
6498
6673
  const fixed = stripped.slice(0, afterIdx) + sep + stripped.slice(afterIdx);
6499
6674
  const fixedResolved = resolve(baseDir, normalize(fixed));
6500
- if (existsSync7(fixedResolved) || existsSync7(dirname2(fixedResolved))) {
6675
+ if (existsSync8(fixedResolved) || existsSync8(dirname2(fixedResolved))) {
6501
6676
  return fixedResolved;
6502
6677
  }
6503
6678
  const fromParent = resolve(dirname2(cur), normalize(fixed));
6504
- if (existsSync7(fromParent) || existsSync7(dirname2(fromParent))) {
6679
+ if (existsSync8(fromParent) || existsSync8(dirname2(fromParent))) {
6505
6680
  return fromParent;
6506
6681
  }
6507
6682
  }
@@ -6699,10 +6874,10 @@ __export(exports_audit_notifier, {
6699
6874
  DEFAULT_AUDIT_NOTIFIER_CONFIG: () => DEFAULT_AUDIT_NOTIFIER_CONFIG,
6700
6875
  AuditNotifier: () => AuditNotifier
6701
6876
  });
6702
- import { writeFileSync as writeFileSync4, appendFileSync as appendFileSync3, existsSync as existsSync8, mkdirSync as mkdirSync5 } from "fs";
6703
- import { join as join7, dirname as dirname3 } from "path";
6704
- import { homedir as homedir2 } from "os";
6705
- import { readFileSync as readFileSync4 } from "fs";
6877
+ import { writeFileSync as writeFileSync5, appendFileSync as appendFileSync3, existsSync as existsSync9, mkdirSync as mkdirSync6 } from "fs";
6878
+ import { join as join8, dirname as dirname3 } from "path";
6879
+ import { homedir as homedir3 } from "os";
6880
+ import { readFileSync as readFileSync5 } from "fs";
6706
6881
 
6707
6882
  class AuditNotifier {
6708
6883
  config;
@@ -6728,7 +6903,7 @@ class AuditNotifier {
6728
6903
  ensureLogDirectory() {
6729
6904
  if (this.config.filePath) {
6730
6905
  const dir = dirname3(this.config.filePath);
6731
- mkdirSync5(dir, { recursive: true });
6906
+ mkdirSync6(dir, { recursive: true });
6732
6907
  }
6733
6908
  }
6734
6909
  shouldNotify(eventType) {
@@ -6850,11 +7025,11 @@ class AuditNotifier {
6850
7025
  this.isProcessing = false;
6851
7026
  }
6852
7027
  readNotifications(limit = 100) {
6853
- if (!this.config.filePath || !existsSync8(this.config.filePath)) {
7028
+ if (!this.config.filePath || !existsSync9(this.config.filePath)) {
6854
7029
  return [];
6855
7030
  }
6856
7031
  try {
6857
- const content = readFileSync4(this.config.filePath, "utf8");
7032
+ const content = readFileSync5(this.config.filePath, "utf8");
6858
7033
  const lines = content.split(`
6859
7034
  `).filter(Boolean);
6860
7035
  return lines.slice(-limit).map((line) => JSON.parse(line));
@@ -6864,7 +7039,7 @@ class AuditNotifier {
6864
7039
  }
6865
7040
  clearNotifications() {
6866
7041
  if (this.config.filePath) {
6867
- writeFileSync4(this.config.filePath, "", "utf8");
7042
+ writeFileSync5(this.config.filePath, "", "utf8");
6868
7043
  }
6869
7044
  this.retryQueue = [];
6870
7045
  }
@@ -6907,7 +7082,7 @@ var init_audit_notifier = __esm(() => {
6907
7082
  };
6908
7083
  DEFAULT_AUDIT_NOTIFIER_CONFIG = {
6909
7084
  enabled: false,
6910
- filePath: join7(homedir2(), ".mma", "logs", "audit-notifications.jsonl"),
7085
+ filePath: join8(homedir3(), ".mma", "logs", "audit-notifications.jsonl"),
6911
7086
  webhookTimeout: 5000,
6912
7087
  minSeverity: "medium",
6913
7088
  eventTypes: [
@@ -6924,26 +7099,26 @@ var init_audit_notifier = __esm(() => {
6924
7099
  });
6925
7100
 
6926
7101
  // src/modules/security/audit-log.ts
6927
- import { existsSync as existsSync9, mkdirSync as mkdirSync6, appendFileSync as appendFileSync4 } from "fs";
6928
- import { resolve as resolve3, join as join8 } from "path";
6929
- import { homedir as homedir3 } from "os";
7102
+ import { existsSync as existsSync10, mkdirSync as mkdirSync7, appendFileSync as appendFileSync4 } from "fs";
7103
+ import { resolve as resolve3, join as join9 } from "path";
7104
+ import { homedir as homedir4 } from "os";
6930
7105
  function getAuditDir() {
6931
7106
  return _sessionAuditDir ?? _globalAuditDir;
6932
7107
  }
6933
7108
  function setAuditSessionDir(dir) {
6934
7109
  _sessionAuditDir = dir;
6935
- if (!existsSync9(dir)) {
6936
- mkdirSync6(dir, { recursive: true, mode: 448 });
7110
+ if (!existsSync10(dir)) {
7111
+ mkdirSync7(dir, { recursive: true, mode: 448 });
6937
7112
  }
6938
7113
  }
6939
7114
  function logAudit(entry) {
6940
7115
  const dir = getAuditDir();
6941
- if (!existsSync9(dir)) {
6942
- mkdirSync6(dir, { recursive: true, mode: 448 });
7116
+ if (!existsSync10(dir)) {
7117
+ mkdirSync7(dir, { recursive: true, mode: 448 });
6943
7118
  }
6944
7119
  try {
6945
7120
  const logEntry = JSON.stringify(entry);
6946
- appendFileSync4(join8(dir, "audit.jsonl"), logEntry + `
7121
+ appendFileSync4(join9(dir, "audit.jsonl"), logEntry + `
6947
7122
  `, "utf8");
6948
7123
  } catch {}
6949
7124
  try {
@@ -7003,11 +7178,11 @@ function logSecurityBlock(sessionId, action, reason, details) {
7003
7178
  var _globalAuditDir, _sessionAuditDir = null;
7004
7179
  var init_audit_log = __esm(() => {
7005
7180
  init_audit_notifier();
7006
- _globalAuditDir = resolve3(homedir3(), ".mma", "logs");
7181
+ _globalAuditDir = resolve3(homedir4(), ".mma", "logs");
7007
7182
  });
7008
7183
 
7009
7184
  // src/tools/read-file.ts
7010
- import { readFileSync as readFileSync5, existsSync as existsSync10, statSync as statSync2, openSync, readSync, closeSync } from "fs";
7185
+ import { readFileSync as readFileSync6, existsSync as existsSync11, statSync as statSync2, openSync, readSync, closeSync } from "fs";
7011
7186
  import { extname } from "path";
7012
7187
  function readLineSlice(path, offset, limit) {
7013
7188
  const fd = openSync(path, "r");
@@ -7108,7 +7283,7 @@ var init_read_file = __esm(() => {
7108
7283
  })
7109
7284
  };
7110
7285
  }
7111
- if (!existsSync10(resolved)) {
7286
+ if (!existsSync11(resolved)) {
7112
7287
  const output = resolved !== path ? t("file.notfound_resolved", {
7113
7288
  path,
7114
7289
  resolved
@@ -7125,7 +7300,7 @@ var init_read_file = __esm(() => {
7125
7300
  total = slice.total;
7126
7301
  selected = slice.selected;
7127
7302
  } else {
7128
- const content = readFileSync5(resolved, "utf-8");
7303
+ const content = readFileSync6(resolved, "utf-8");
7129
7304
  lines = content.split(`
7130
7305
  `);
7131
7306
  total = lines.length;
@@ -7217,16 +7392,16 @@ __export(exports_session_isolation, {
7217
7392
  cleanupSessionTempDir: () => cleanupSessionTempDir,
7218
7393
  DEFAULT_SESSION_ISOLATION: () => DEFAULT_SESSION_ISOLATION
7219
7394
  });
7220
- import { join as join9, resolve as resolve5 } from "path";
7221
- import { homedir as homedir4 } from "os";
7222
- import { mkdirSync as mkdirSync7, existsSync as existsSync11 } from "fs";
7395
+ import { join as join10, resolve as resolve5 } from "path";
7396
+ import { homedir as homedir5 } from "os";
7397
+ import { mkdirSync as mkdirSync8, existsSync as existsSync12 } from "fs";
7223
7398
  function createSessionContext(sessionId, projectDir, isolationConfig, securityOverrides) {
7224
7399
  const config = { ...DEFAULT_SESSION_ISOLATION, ...isolationConfig };
7225
- const baseDir = config.baseDir || join9(homedir4(), ".mma", "sessions", sessionId);
7226
- const tempDir = join9(baseDir, "temp");
7227
- if (config.isolateTempFiles && !existsSync11(tempDir)) {
7400
+ const baseDir = config.baseDir || join10(homedir5(), ".mma", "sessions", sessionId);
7401
+ const tempDir = join10(baseDir, "temp");
7402
+ if (config.isolateTempFiles && !existsSync12(tempDir)) {
7228
7403
  try {
7229
- mkdirSync7(tempDir, { recursive: true, mode: 448 });
7404
+ mkdirSync8(tempDir, { recursive: true, mode: 448 });
7230
7405
  } catch {}
7231
7406
  }
7232
7407
  return {
@@ -7476,7 +7651,7 @@ var init_diff = __esm(() => {
7476
7651
  });
7477
7652
 
7478
7653
  // src/tools/write-file.ts
7479
- import { writeFileSync as writeFileSync5, mkdirSync as mkdirSync8, existsSync as existsSync12, readFileSync as readFileSync6 } from "fs";
7654
+ import { writeFileSync as writeFileSync6, mkdirSync as mkdirSync9, existsSync as existsSync13, readFileSync as readFileSync7 } from "fs";
7480
7655
  import { dirname as dirname4 } from "path";
7481
7656
  var writeFileTool;
7482
7657
  var init_write_file = __esm(() => {
@@ -7535,15 +7710,15 @@ var init_write_file = __esm(() => {
7535
7710
  }
7536
7711
  }
7537
7712
  const dir = dirname4(resolved);
7538
- if (!existsSync12(dir)) {
7539
- mkdirSync8(dir, { recursive: true });
7713
+ if (!existsSync13(dir)) {
7714
+ mkdirSync9(dir, { recursive: true });
7540
7715
  }
7541
- const fileExists = existsSync12(resolved);
7716
+ const fileExists = existsSync13(resolved);
7542
7717
  let oldContent = "";
7543
7718
  if (fileExists) {
7544
- oldContent = readFileSync6(resolved, "utf-8");
7719
+ oldContent = readFileSync7(resolved, "utf-8");
7545
7720
  }
7546
- writeFileSync5(resolved, content, "utf-8");
7721
+ writeFileSync6(resolved, content, "utf-8");
7547
7722
  const diff = fileExists ? generateDiff(oldContent, content) : generateNewFileDiff(content);
7548
7723
  ctx.fileOperationsCount = currentCount + 1;
7549
7724
  logFileWrite(ctx.sessionId, path, true, `File ${fileExists ? "updated" : "created"}`);
@@ -7553,7 +7728,7 @@ var init_write_file = __esm(() => {
7553
7728
  });
7554
7729
 
7555
7730
  // src/tools/edit-file.ts
7556
- import { readFileSync as readFileSync7, writeFileSync as writeFileSync6 } from "fs";
7731
+ import { readFileSync as readFileSync8, writeFileSync as writeFileSync7 } from "fs";
7557
7732
  var editFileTool;
7558
7733
  var init_edit_file = __esm(() => {
7559
7734
  init_i18n();
@@ -7600,7 +7775,7 @@ var init_edit_file = __esm(() => {
7600
7775
  })
7601
7776
  };
7602
7777
  }
7603
- const content = readFileSync7(resolved, "utf-8");
7778
+ const content = readFileSync8(resolved, "utf-8");
7604
7779
  const oldStr = String(args.old);
7605
7780
  const newStr = String(args.new);
7606
7781
  if (!content.includes(oldStr)) {
@@ -7620,7 +7795,7 @@ var init_edit_file = __esm(() => {
7620
7795
  };
7621
7796
  }
7622
7797
  }
7623
- writeFileSync6(resolved, updated, "utf-8");
7798
+ writeFileSync7(resolved, updated, "utf-8");
7624
7799
  const diff = generateDiff(content, updated);
7625
7800
  ctx.fileOperationsCount = currentCount + 1;
7626
7801
  logFileWrite(ctx.sessionId, path, true, "File edited");
@@ -7777,7 +7952,7 @@ var init_grep_tool = __esm(() => {
7777
7952
  });
7778
7953
 
7779
7954
  // src/tools/list-dir.ts
7780
- import { readdirSync as readdirSync4, statSync as statSync3, existsSync as existsSync13 } from "fs";
7955
+ import { readdirSync as readdirSync5, statSync as statSync3, existsSync as existsSync14 } from "fs";
7781
7956
  import { resolve as resolve8 } from "path";
7782
7957
  var listDirTool;
7783
7958
  var init_list_dir = __esm(() => {
@@ -7809,10 +7984,10 @@ var init_list_dir = __esm(() => {
7809
7984
  })
7810
7985
  };
7811
7986
  }
7812
- if (!existsSync13(resolved)) {
7987
+ if (!existsSync14(resolved)) {
7813
7988
  return { success: false, output: t("file.dir_notfound", { path }) };
7814
7989
  }
7815
- const entries = readdirSync4(resolved);
7990
+ const entries = readdirSync5(resolved);
7816
7991
  const lines = entries.map((e) => {
7817
7992
  const full = resolve8(resolved, e);
7818
7993
  return statSync3(full).isDirectory() ? `${e}/` : e;
@@ -7829,7 +8004,7 @@ var init_list_dir = __esm(() => {
7829
8004
  });
7830
8005
 
7831
8006
  // src/tools/create-dir.ts
7832
- import { mkdirSync as mkdirSync9, existsSync as existsSync14 } from "fs";
8007
+ import { mkdirSync as mkdirSync10, existsSync as existsSync15 } from "fs";
7833
8008
  var createDirTool;
7834
8009
  var init_create_dir = __esm(() => {
7835
8010
  init_i18n();
@@ -7872,8 +8047,8 @@ var init_create_dir = __esm(() => {
7872
8047
  })
7873
8048
  };
7874
8049
  }
7875
- if (!existsSync14(resolved)) {
7876
- mkdirSync9(resolved, { recursive: true });
8050
+ if (!existsSync15(resolved)) {
8051
+ mkdirSync10(resolved, { recursive: true });
7877
8052
  }
7878
8053
  ctx.fileOperationsCount = currentCount + 1;
7879
8054
  logFileWrite(ctx.sessionId, path, true, "Directory created");
@@ -7883,7 +8058,7 @@ var init_create_dir = __esm(() => {
7883
8058
  });
7884
8059
 
7885
8060
  // src/tools/delete-file.ts
7886
- import { unlinkSync as unlinkSync3, existsSync as existsSync15, statSync as statSync4, readFileSync as readFileSync8 } from "fs";
8061
+ import { unlinkSync as unlinkSync3, existsSync as existsSync16, statSync as statSync4, readFileSync as readFileSync9 } from "fs";
7887
8062
  var deleteFileTool;
7888
8063
  var init_delete_file = __esm(() => {
7889
8064
  init_i18n();
@@ -7927,13 +8102,13 @@ var init_delete_file = __esm(() => {
7927
8102
  })
7928
8103
  };
7929
8104
  }
7930
- if (!existsSync15(resolved)) {
8105
+ if (!existsSync16(resolved)) {
7931
8106
  return { success: false, output: t("file.notfound", { path }) };
7932
8107
  }
7933
8108
  if (statSync4(resolved).isDirectory()) {
7934
8109
  return { success: false, output: t("file.is_directory", { path }) };
7935
8110
  }
7936
- const content = readFileSync8(resolved, "utf-8");
8111
+ const content = readFileSync9(resolved, "utf-8");
7937
8112
  unlinkSync3(resolved);
7938
8113
  const diff = generateDeleteDiff(content);
7939
8114
  ctx.fileOperationsCount = currentCount + 1;
@@ -7944,7 +8119,7 @@ var init_delete_file = __esm(() => {
7944
8119
  });
7945
8120
 
7946
8121
  // src/tools/move-file.ts
7947
- import { renameSync as renameSync2, existsSync as existsSync16, mkdirSync as mkdirSync10 } from "fs";
8122
+ import { renameSync as renameSync2, existsSync as existsSync17, mkdirSync as mkdirSync11 } from "fs";
7948
8123
  import { resolve as resolve9, normalize as normalize3, dirname as dirname5 } from "path";
7949
8124
  var moveFileTool;
7950
8125
  var init_move_file = __esm(() => {
@@ -8003,15 +8178,15 @@ var init_move_file = __esm(() => {
8003
8178
  })
8004
8179
  };
8005
8180
  }
8006
- if (!existsSync16(fromResolved)) {
8181
+ if (!existsSync17(fromResolved)) {
8007
8182
  return {
8008
8183
  success: false,
8009
8184
  output: t("file.not_found_short", { path: fromPath })
8010
8185
  };
8011
8186
  }
8012
8187
  const toDir = dirname5(toResolved);
8013
- if (!existsSync16(toDir)) {
8014
- mkdirSync10(toDir, { recursive: true });
8188
+ if (!existsSync17(toDir)) {
8189
+ mkdirSync11(toDir, { recursive: true });
8015
8190
  }
8016
8191
  renameSync2(fromResolved, toResolved);
8017
8192
  const diff = generateMoveDiff(fromPath, toPath);
@@ -8027,7 +8202,7 @@ var init_move_file = __esm(() => {
8027
8202
  });
8028
8203
 
8029
8204
  // src/tools/file-info.ts
8030
- import { statSync as statSync5, existsSync as existsSync17 } from "fs";
8205
+ import { statSync as statSync5, existsSync as existsSync18 } from "fs";
8031
8206
  var fileInfoTool;
8032
8207
  var init_file_info = __esm(() => {
8033
8208
  init_i18n();
@@ -8058,7 +8233,7 @@ var init_file_info = __esm(() => {
8058
8233
  })
8059
8234
  };
8060
8235
  }
8061
- if (!existsSync17(resolved)) {
8236
+ if (!existsSync18(resolved)) {
8062
8237
  return { success: false, output: t("file.not_found_short", { path }) };
8063
8238
  }
8064
8239
  const stat = statSync5(resolved);
@@ -9120,8 +9295,8 @@ var init_prompt_builder = __esm(() => {
9120
9295
  });
9121
9296
 
9122
9297
  // src/core/session-logger.ts
9123
- import { join as join10 } from "path";
9124
- import { readFileSync as readFileSync9, existsSync as existsSync18 } from "fs";
9298
+ import { join as join11 } from "path";
9299
+ import { readFileSync as readFileSync10, existsSync as existsSync19 } from "fs";
9125
9300
 
9126
9301
  class SessionLogger {
9127
9302
  session;
@@ -9329,10 +9504,10 @@ class SessionLogger {
9329
9504
  logSessionStart(data) {
9330
9505
  const meta = this.session?.getActiveMeta();
9331
9506
  if (meta) {
9332
- const logPath = join10(this.session.getSessionDirectory(meta.id), "session.jsonl");
9507
+ const logPath = join11(this.session.getSessionDirectory(meta.id), "session.jsonl");
9333
9508
  try {
9334
- if (existsSync18(logPath)) {
9335
- const content = readFileSync9(logPath, "utf-8");
9509
+ if (existsSync19(logPath)) {
9510
+ const content = readFileSync10(logPath, "utf-8");
9336
9511
  if (content.includes('"type":"session_start"'))
9337
9512
  return;
9338
9513
  }
@@ -11056,7 +11231,7 @@ var init_stuck_detector = __esm(() => {
11056
11231
  });
11057
11232
 
11058
11233
  // src/modules/artifacts/store.ts
11059
- import { existsSync as existsSync19, mkdirSync as mkdirSync11, readFileSync as readFileSync10, writeFileSync as writeFileSync7 } from "node:fs";
11234
+ import { existsSync as existsSync20, mkdirSync as mkdirSync12, readFileSync as readFileSync11, writeFileSync as writeFileSync8 } from "node:fs";
11060
11235
  import { resolve as resolve10, relative as relative2, isAbsolute as isAbsolute2 } from "node:path";
11061
11236
 
11062
11237
  class ArtifactStore {
@@ -11082,21 +11257,21 @@ class ArtifactStore {
11082
11257
  save(name, content, ext = "md") {
11083
11258
  const safe = ArtifactStore.sanitizeName(name);
11084
11259
  const dir = resolve10(this.root);
11085
- mkdirSync11(dir, { recursive: true });
11260
+ mkdirSync12(dir, { recursive: true });
11086
11261
  const abs = resolve10(dir, `${safe}.${ext}`);
11087
11262
  if (!ArtifactStore.isInside(dir, abs)) {
11088
11263
  throw new Error(`Artifact path escapes root: ${abs}`);
11089
11264
  }
11090
- writeFileSync7(abs, content, "utf8");
11265
+ writeFileSync8(abs, content, "utf8");
11091
11266
  return abs;
11092
11267
  }
11093
11268
  read(path) {
11094
11269
  const abs = resolve10(this.root, path);
11095
11270
  if (!ArtifactStore.isInside(this.root, abs))
11096
11271
  return null;
11097
- if (!existsSync19(abs))
11272
+ if (!existsSync20(abs))
11098
11273
  return null;
11099
- return readFileSync10(abs, "utf8");
11274
+ return readFileSync11(abs, "utf8");
11100
11275
  }
11101
11276
  summary(content, maxChars) {
11102
11277
  if (content.length <= maxChars)
@@ -11420,15 +11595,15 @@ var init_moe_executor = __esm(() => {
11420
11595
  });
11421
11596
 
11422
11597
  // src/modules/lsp/project-root.ts
11423
- import { existsSync as existsSync20 } from "fs";
11424
- import { dirname as dirname6, join as join11 } from "path";
11598
+ import { existsSync as existsSync21 } from "fs";
11599
+ import { dirname as dirname6, join as join12 } from "path";
11425
11600
  function findProjectRoot(filePath, baseDir, markers) {
11426
11601
  if (!markers || markers.length === 0)
11427
11602
  return baseDir;
11428
11603
  let dir = dirname6(filePath);
11429
11604
  const root = baseDir.replace(/[\\/]+$/, "");
11430
11605
  while (true) {
11431
- if (markers.some((m) => existsSync20(join11(dir, m)))) {
11606
+ if (markers.some((m) => existsSync21(join12(dir, m)))) {
11432
11607
  return dir;
11433
11608
  }
11434
11609
  if (dir === root)
@@ -11651,13 +11826,13 @@ var init_js_identifiers = __esm(() => {
11651
11826
  });
11652
11827
 
11653
11828
  // src/modules/execution/audit-runners.ts
11654
- import { existsSync as existsSync21, readdirSync as readdirSync5, readFileSync as readFileSync11 } from "fs";
11655
- import { dirname as dirname7, join as join12, resolve as resolve11 } from "path";
11829
+ import { existsSync as existsSync22, readdirSync as readdirSync6, readFileSync as readFileSync12 } from "fs";
11830
+ import { dirname as dirname7, join as join13, resolve as resolve11 } from "path";
11656
11831
  function resolveTestCommand(dir) {
11657
- const pkgPath = join12(dir, "package.json");
11658
- if (existsSync21(pkgPath)) {
11832
+ const pkgPath = join13(dir, "package.json");
11833
+ if (existsSync22(pkgPath)) {
11659
11834
  try {
11660
- const pkg = JSON.parse(readFileSync11(pkgPath, "utf-8"));
11835
+ const pkg = JSON.parse(readFileSync12(pkgPath, "utf-8"));
11661
11836
  const script = pkg?.scripts?.test;
11662
11837
  if (typeof script === "string" && script.trim())
11663
11838
  return script.trim();
@@ -11673,7 +11848,7 @@ function resolveTestCommand(dir) {
11673
11848
  "jest.config.cjs",
11674
11849
  "bunfig.toml"
11675
11850
  ]) {
11676
- if (existsSync21(join12(dir, f))) {
11851
+ if (existsSync22(join13(dir, f))) {
11677
11852
  if (f.startsWith("vitest"))
11678
11853
  return "bunx vitest run";
11679
11854
  if (f.startsWith("jest"))
@@ -11682,12 +11857,12 @@ function resolveTestCommand(dir) {
11682
11857
  return "bun test";
11683
11858
  }
11684
11859
  }
11685
- if (existsSync21(join12(dir, "pyproject.toml")) || existsSync21(join12(dir, "pytest.ini")) || existsSync21(join12(dir, "conftest.py"))) {
11860
+ if (existsSync22(join13(dir, "pyproject.toml")) || existsSync22(join13(dir, "pytest.ini")) || existsSync22(join13(dir, "conftest.py"))) {
11686
11861
  return "python -m pytest -q";
11687
11862
  }
11688
- if (existsSync21(join12(dir, "go.mod")))
11863
+ if (existsSync22(join13(dir, "go.mod")))
11689
11864
  return "go test ./...";
11690
- if (existsSync21(join12(dir, "Cargo.toml")))
11865
+ if (existsSync22(join13(dir, "Cargo.toml")))
11691
11866
  return "cargo test";
11692
11867
  return "bun test";
11693
11868
  }
@@ -11696,12 +11871,12 @@ function findTestFile(dir, depth = 0) {
11696
11871
  return null;
11697
11872
  let entries;
11698
11873
  try {
11699
- entries = readdirSync5(dir, { withFileTypes: true });
11874
+ entries = readdirSync6(dir, { withFileTypes: true });
11700
11875
  } catch {
11701
11876
  return null;
11702
11877
  }
11703
11878
  for (const e of entries) {
11704
- const full = join12(dir, e.name);
11879
+ const full = join13(dir, e.name);
11705
11880
  if (e.isDirectory()) {
11706
11881
  if (SKIP_DIRS.has(e.name))
11707
11882
  continue;
@@ -11777,7 +11952,7 @@ function findTypecheckRoot(baseDir, existingFiles = []) {
11777
11952
  for (const start of candidates) {
11778
11953
  let dir = resolve11(start);
11779
11954
  for (let depth = 0;depth <= 10; depth++) {
11780
- if (existsSync21(join12(dir, "tsconfig.json"))) {
11955
+ if (existsSync22(join13(dir, "tsconfig.json"))) {
11781
11956
  if (!best || depth < best.depth)
11782
11957
  best = { depth, root: dir };
11783
11958
  break;
@@ -11821,11 +11996,11 @@ var init_audit_runners = __esm(() => {
11821
11996
  });
11822
11997
 
11823
11998
  // src/modules/execution/auditor.ts
11824
- import { existsSync as existsSync22, readdirSync as readdirSync6 } from "fs";
11825
- import { resolve as resolve12, join as join13, basename as basename2 } from "path";
11999
+ import { existsSync as existsSync23, readdirSync as readdirSync7 } from "fs";
12000
+ import { resolve as resolve12, join as join14, basename as basename2 } from "path";
11826
12001
  function findExistingFile(baseDir, filePath) {
11827
12002
  const direct = resolve12(baseDir, filePath);
11828
- if (existsSync22(direct))
12003
+ if (existsSync23(direct))
11829
12004
  return direct;
11830
12005
  const name = basename2(filePath).toLowerCase();
11831
12006
  const suffix = filePath.replace(/\\/g, "/").toLowerCase();
@@ -11835,14 +12010,14 @@ function findExistingFile(baseDir, filePath) {
11835
12010
  return;
11836
12011
  let entries;
11837
12012
  try {
11838
- entries = readdirSync6(dir, { withFileTypes: true });
12013
+ entries = readdirSync7(dir, { withFileTypes: true });
11839
12014
  } catch {
11840
12015
  return;
11841
12016
  }
11842
12017
  for (const e of entries) {
11843
12018
  if (found)
11844
12019
  return;
11845
- const full = join13(dir, e.name);
12020
+ const full = join14(dir, e.name);
11846
12021
  if (e.isDirectory()) {
11847
12022
  if (SKIP_DIRS.has(e.name))
11848
12023
  continue;
@@ -11980,8 +12155,8 @@ var init_auditor = __esm(() => {
11980
12155
  });
11981
12156
 
11982
12157
  // src/modules/execution/verifier.ts
11983
- import { existsSync as existsSync23 } from "fs";
11984
- import { resolve as resolve13, extname as extname2, join as join14 } from "path";
12158
+ import { existsSync as existsSync24 } from "fs";
12159
+ import { resolve as resolve13, extname as extname2, join as join15 } from "path";
11985
12160
  import { spawn as spawn3 } from "child_process";
11986
12161
 
11987
12162
  class StepVerifier {
@@ -11991,7 +12166,7 @@ class StepVerifier {
11991
12166
  }
11992
12167
  async checkFileExists(path) {
11993
12168
  const resolved = resolve13(this.baseDir, path);
11994
- const exists = existsSync23(resolved);
12169
+ const exists = existsSync24(resolved);
11995
12170
  return {
11996
12171
  passed: exists,
11997
12172
  message: exists ? t("verify.file_exists", { path }) : t("verify.file_not_found", { path })
@@ -12010,7 +12185,7 @@ class StepVerifier {
12010
12185
  }
12011
12186
  async runTypeCheck() {
12012
12187
  const tsconfigPath = resolve13(this.baseDir, "tsconfig.json");
12013
- if (!existsSync23(tsconfigPath)) {
12188
+ if (!existsSync24(tsconfigPath)) {
12014
12189
  return { passed: true, message: "No tsconfig.json found — skipping type check" };
12015
12190
  }
12016
12191
  try {
@@ -12023,8 +12198,8 @@ class StepVerifier {
12023
12198
  }
12024
12199
  async runTypeCheckForFile(filePath) {
12025
12200
  const projectRoot = findProjectRoot(filePath, this.baseDir, ["tsconfig.json", "package.json"]);
12026
- const tsconfigPath = join14(projectRoot, "tsconfig.json");
12027
- if (!existsSync23(tsconfigPath)) {
12201
+ const tsconfigPath = join15(projectRoot, "tsconfig.json");
12202
+ if (!existsSync24(tsconfigPath)) {
12028
12203
  return { passed: true, message: "No tsconfig.json found — skipping type check" };
12029
12204
  }
12030
12205
  try {
@@ -12037,7 +12212,7 @@ class StepVerifier {
12037
12212
  }
12038
12213
  async runTests() {
12039
12214
  const pkgPath = resolve13(this.baseDir, "package.json");
12040
- if (!existsSync23(pkgPath)) {
12215
+ if (!existsSync24(pkgPath)) {
12041
12216
  return { passed: true, message: "No package.json found — skipping tests" };
12042
12217
  }
12043
12218
  try {
@@ -12961,10 +13136,12 @@ ${t("tool.truncated", { tokens: Math.ceil(removedChars / 2) })}`;
12961
13136
  }
12962
13137
  }
12963
13138
  pluginManager.runOnToolEnd({ iteration, logger, contextManager }, { id: call.id, name: call.name, arguments: call.arguments }, result, duration);
12964
- if (result.display) {
12965
- onMeta?.(`
13139
+ if (result.display !== undefined) {
13140
+ if (result.display.length > 0) {
13141
+ onMeta?.(`
12966
13142
  ` + result.display + `
12967
13143
  `);
13144
+ }
12968
13145
  } else {
12969
13146
  const metaOut = pluginManager.runOnMeta({ iteration, logger, contextManager }, result.output);
12970
13147
  onMeta?.(`
@@ -13919,8 +14096,8 @@ var init_confidence = __esm(() => {
13919
14096
  });
13920
14097
 
13921
14098
  // src/modules/hallucination/factual.ts
13922
- import { existsSync as existsSync24, readdirSync as readdirSync7 } from "fs";
13923
- import { resolve as resolve14, isAbsolute as isAbsolute3, join as join15 } from "path";
14099
+ import { existsSync as existsSync25, readdirSync as readdirSync8 } from "fs";
14100
+ import { resolve as resolve14, isAbsolute as isAbsolute3, join as join16 } from "path";
13924
14101
 
13925
14102
  class FactualCheck {
13926
14103
  baseDir;
@@ -13960,13 +14137,13 @@ class FactualCheck {
13960
14137
  }
13961
14138
  pathExists(fp) {
13962
14139
  if (isAbsolute3(fp))
13963
- return existsSync24(fp);
14140
+ return existsSync25(fp);
13964
14141
  if (this.knownFiles.has(fp))
13965
14142
  return true;
13966
14143
  for (const cand of this.dotfileVariants(fp)) {
13967
14144
  if (this.knownFiles.has(cand))
13968
14145
  return true;
13969
- if (existsSync24(resolve14(this.baseDir, cand)))
14146
+ if (existsSync25(resolve14(this.baseDir, cand)))
13970
14147
  return true;
13971
14148
  }
13972
14149
  if (!fp.includes("/") && !fp.includes("\\")) {
@@ -13983,7 +14160,7 @@ class FactualCheck {
13983
14160
  }
13984
14161
  bareNameExists(name) {
13985
14162
  for (const cand of this.dotfileVariants(name)) {
13986
- if (existsSync24(resolve14(this.baseDir, cand)))
14163
+ if (existsSync25(resolve14(this.baseDir, cand)))
13987
14164
  return true;
13988
14165
  if (this.indexHas(cand))
13989
14166
  return true;
@@ -14022,14 +14199,14 @@ class FactualCheck {
14022
14199
  return count;
14023
14200
  let entries;
14024
14201
  try {
14025
- entries = readdirSync7(dir, { withFileTypes: true });
14202
+ entries = readdirSync8(dir, { withFileTypes: true });
14026
14203
  } catch {
14027
14204
  return count;
14028
14205
  }
14029
14206
  for (const entry of entries) {
14030
14207
  if (count >= FactualCheck.MAX_INDEXED_FILES)
14031
14208
  break;
14032
- const full = join15(dir, entry.name);
14209
+ const full = join16(dir, entry.name);
14033
14210
  if (entry.isDirectory()) {
14034
14211
  if (!IGNORED_DIRS.has(entry.name)) {
14035
14212
  count = this.scanDir(full, index, count);
@@ -14203,8 +14380,8 @@ var init_detector = __esm(() => {
14203
14380
  });
14204
14381
 
14205
14382
  // src/modules/lsp/command.ts
14206
- import { delimiter, join as join16 } from "path";
14207
- import { existsSync as existsSync25 } from "fs";
14383
+ import { delimiter, join as join17 } from "path";
14384
+ import { existsSync as existsSync26 } from "fs";
14208
14385
  import { platform as platform3 } from "os";
14209
14386
  function resolveSpawnCommand(command, platformName = platform3(), pathEnv = process.env.PATH ?? "") {
14210
14387
  if (platformName !== "win32")
@@ -14215,8 +14392,8 @@ function resolveSpawnCommand(command, platformName = platform3(), pathEnv = proc
14215
14392
  const dirs = pathEnv.split(delimiter).filter(Boolean);
14216
14393
  for (const dir of dirs) {
14217
14394
  for (const ext of WIN_EXTS) {
14218
- const candidate = join16(dir, `${command}${ext}`);
14219
- if (existsSync25(candidate))
14395
+ const candidate = join17(dir, `${command}${ext}`);
14396
+ if (existsSync26(candidate))
14220
14397
  return `${command}${ext}`;
14221
14398
  }
14222
14399
  }
@@ -14846,7 +15023,7 @@ ${joined}` }
14846
15023
  var DEFAULT_CHUNK_SYSTEM_PROMPT = 'Answer the query using ONLY the provided text. Be concise. If the text does not contain the answer, say "NO_EVIDENCE".', DEFAULT_SYNTHESIS_SYSTEM_PROMPT = "You are given a query and per-chunk answers over a large text. Produce the final answer to the query, combining evidence from the chunks. If no chunk had evidence, say so.";
14847
15024
 
14848
15025
  // src/tools/chunk-query.ts
14849
- import { readFileSync as readFileSync12 } from "node:fs";
15026
+ import { readFileSync as readFileSync13 } from "node:fs";
14850
15027
  import { resolve as resolve16 } from "node:path";
14851
15028
  var chunkQueryTool;
14852
15029
  var init_chunk_query = __esm(() => {
@@ -14916,7 +15093,7 @@ var init_chunk_query = __esm(() => {
14916
15093
  return { success: false, output: `[SCOPE] ${check.reason || "Path not allowed"}` };
14917
15094
  }
14918
15095
  try {
14919
- content = readFileSync12(resolve16(ctx.baseDir, inputPath), "utf8");
15096
+ content = readFileSync13(resolve16(ctx.baseDir, inputPath), "utf8");
14920
15097
  } catch (e) {
14921
15098
  return { success: false, output: `Cannot read ${inputPath}: ${e.message}` };
14922
15099
  }
@@ -15316,7 +15493,7 @@ var init_web_browse = __esm(() => {
15316
15493
  });
15317
15494
 
15318
15495
  // src/tools/download-file.ts
15319
- import { writeFileSync as writeFileSync8, mkdirSync as mkdirSync12 } from "fs";
15496
+ import { writeFileSync as writeFileSync9, mkdirSync as mkdirSync13 } from "fs";
15320
15497
  import { dirname as dirname9 } from "path";
15321
15498
  var MAX_DOWNLOAD_BYTES, downloadFileTool;
15322
15499
  var init_download_file = __esm(() => {
@@ -15405,8 +15582,8 @@ var init_download_file = __esm(() => {
15405
15582
  output: t("tool.download_too_large", { max: String(maxBytes) })
15406
15583
  };
15407
15584
  }
15408
- mkdirSync12(dirname9(resolved), { recursive: true });
15409
- writeFileSync8(resolved, buffer);
15585
+ mkdirSync13(dirname9(resolved), { recursive: true });
15586
+ writeFileSync9(resolved, buffer);
15410
15587
  const contentType = response.headers.get("content-type")?.split(";")[0]?.trim() || "unknown";
15411
15588
  logNetworkRequest(ctx.sessionId, sanitizeUrl(url), true, `Status: ${response.status}`);
15412
15589
  logFileWrite(ctx.sessionId, resolved, true, `Downloaded ${buffer.byteLength} bytes`);
@@ -16245,8 +16422,8 @@ ${JSON.stringify(result, null, 2)}`
16245
16422
 
16246
16423
  // src/tools/search-history.ts
16247
16424
  import * as fs from "fs";
16248
- import { join as join17 } from "path";
16249
- import { homedir as homedir5 } from "os";
16425
+ import { join as join18 } from "path";
16426
+ import { homedir as homedir6 } from "os";
16250
16427
  function searchFile(filePath, query, maxResults, results) {
16251
16428
  if (!fs.existsSync(filePath))
16252
16429
  return;
@@ -16290,7 +16467,7 @@ var init_search_history = __esm(() => {
16290
16467
  const query = String(args.query || "").toLowerCase();
16291
16468
  const maxResults = Number(args.maxResults) || 5;
16292
16469
  const sessionId = args.sessionId ? String(args.sessionId) : null;
16293
- const sessionDir = join17(homedir5(), ".mma", "sessions");
16470
+ const sessionDir = join18(homedir6(), ".mma", "sessions");
16294
16471
  const results = [];
16295
16472
  try {
16296
16473
  if (!fs.existsSync(sessionDir)) {
@@ -16305,7 +16482,7 @@ var init_search_history = __esm(() => {
16305
16482
  continue;
16306
16483
  if (sessionId && entry.name !== sessionId)
16307
16484
  continue;
16308
- const historyFile = join17(sessionDir, entry.name, "history.jsonl");
16485
+ const historyFile = join18(sessionDir, entry.name, "history.jsonl");
16309
16486
  searchFile(historyFile, query, maxResults, results);
16310
16487
  if (results.length >= maxResults)
16311
16488
  break;
@@ -16332,8 +16509,8 @@ var init_search_history = __esm(() => {
16332
16509
  });
16333
16510
 
16334
16511
  // src/modules/memory/search.ts
16335
- import { readFileSync as readFileSync14, existsSync as existsSync27 } from "fs";
16336
- import { join as join18 } from "path";
16512
+ import { readFileSync as readFileSync15, existsSync as existsSync28 } from "fs";
16513
+ import { join as join19 } from "path";
16337
16514
 
16338
16515
  class MemorySearch {
16339
16516
  memoryDir;
@@ -16344,10 +16521,10 @@ class MemorySearch {
16344
16521
  const results = [];
16345
16522
  const lowerQuery = query.toLowerCase();
16346
16523
  for (const name of MEMORY_FILES) {
16347
- const path = join18(this.memoryDir, `${name}.md`);
16348
- if (!existsSync27(path))
16524
+ const path = join19(this.memoryDir, `${name}.md`);
16525
+ if (!existsSync28(path))
16349
16526
  continue;
16350
- const content = readFileSync14(path, "utf-8");
16527
+ const content = readFileSync15(path, "utf-8");
16351
16528
  const lines = content.split(`
16352
16529
  `);
16353
16530
  for (const line of lines) {
@@ -16356,10 +16533,10 @@ class MemorySearch {
16356
16533
  }
16357
16534
  }
16358
16535
  }
16359
- const prefsPath = join18(this.memoryDir, "preferences.json");
16360
- if (existsSync27(prefsPath)) {
16536
+ const prefsPath = join19(this.memoryDir, "preferences.json");
16537
+ if (existsSync28(prefsPath)) {
16361
16538
  try {
16362
- const prefs = JSON.parse(readFileSync14(prefsPath, "utf-8"));
16539
+ const prefs = JSON.parse(readFileSync15(prefsPath, "utf-8"));
16363
16540
  for (const [key, value] of Object.entries(prefs)) {
16364
16541
  const searchStr = `${key}=${value}`;
16365
16542
  if (searchStr.toLowerCase().includes(lowerQuery)) {
@@ -16377,8 +16554,8 @@ var init_search = __esm(() => {
16377
16554
  });
16378
16555
 
16379
16556
  // src/modules/memory/store.ts
16380
- import { readFileSync as readFileSync15, writeFileSync as writeFileSync9, appendFileSync as appendFileSync5, existsSync as existsSync28, mkdirSync as mkdirSync13 } from "fs";
16381
- import { join as join19 } from "path";
16557
+ import { readFileSync as readFileSync16, writeFileSync as writeFileSync10, appendFileSync as appendFileSync5, existsSync as existsSync29, mkdirSync as mkdirSync14 } from "fs";
16558
+ import { join as join20 } from "path";
16382
16559
 
16383
16560
  class MemoryStore {
16384
16561
  memoryDir;
@@ -16386,27 +16563,27 @@ class MemoryStore {
16386
16563
  this.memoryDir = memoryDir;
16387
16564
  this.ensureDir();
16388
16565
  for (const name of MEMORY_FILES2) {
16389
- const path = join19(this.memoryDir, `${name}.md`);
16390
- if (!existsSync28(path)) {
16391
- writeFileSync9(path, `# ${name.charAt(0).toUpperCase() + name.slice(1)}
16566
+ const path = join20(this.memoryDir, `${name}.md`);
16567
+ if (!existsSync29(path)) {
16568
+ writeFileSync10(path, `# ${name.charAt(0).toUpperCase() + name.slice(1)}
16392
16569
 
16393
16570
  `, "utf-8");
16394
16571
  }
16395
16572
  }
16396
16573
  }
16397
16574
  ensureDir() {
16398
- if (!existsSync28(this.memoryDir)) {
16399
- mkdirSync13(this.memoryDir, { recursive: true });
16575
+ if (!existsSync29(this.memoryDir)) {
16576
+ mkdirSync14(this.memoryDir, { recursive: true });
16400
16577
  }
16401
16578
  }
16402
16579
  read(name) {
16403
- const path = join19(this.memoryDir, `${name}.md`);
16404
- if (!existsSync28(path))
16580
+ const path = join20(this.memoryDir, `${name}.md`);
16581
+ if (!existsSync29(path))
16405
16582
  return "";
16406
- return readFileSync15(path, "utf-8");
16583
+ return readFileSync16(path, "utf-8");
16407
16584
  }
16408
16585
  append(name, entry) {
16409
- const path = join19(this.memoryDir, `${name}.md`);
16586
+ const path = join20(this.memoryDir, `${name}.md`);
16410
16587
  const timestamp = new Date().toISOString().replace("T", " ").slice(0, 19);
16411
16588
  const formatted = `- **${timestamp}** — ${entry}
16412
16589
  `;
@@ -16417,14 +16594,14 @@ class MemoryStore {
16417
16594
  return searchModule.query(query);
16418
16595
  }
16419
16596
  prefsPath() {
16420
- return join19(this.memoryDir, "preferences.json");
16597
+ return join20(this.memoryDir, "preferences.json");
16421
16598
  }
16422
16599
  getPreferences() {
16423
16600
  const path = this.prefsPath();
16424
- if (!existsSync28(path))
16601
+ if (!existsSync29(path))
16425
16602
  return {};
16426
16603
  try {
16427
- return JSON.parse(readFileSync15(path, "utf-8"));
16604
+ return JSON.parse(readFileSync16(path, "utf-8"));
16428
16605
  } catch {
16429
16606
  return {};
16430
16607
  }
@@ -16432,14 +16609,14 @@ class MemoryStore {
16432
16609
  setPreference(key, value) {
16433
16610
  const prefs = this.getPreferences();
16434
16611
  prefs[key] = value;
16435
- writeFileSync9(this.prefsPath(), JSON.stringify(prefs, null, 2), "utf-8");
16612
+ writeFileSync10(this.prefsPath(), JSON.stringify(prefs, null, 2), "utf-8");
16436
16613
  }
16437
16614
  deletePreference(key) {
16438
16615
  const prefs = this.getPreferences();
16439
16616
  if (!(key in prefs))
16440
16617
  return false;
16441
16618
  delete prefs[key];
16442
- writeFileSync9(this.prefsPath(), JSON.stringify(prefs, null, 2), "utf-8");
16619
+ writeFileSync10(this.prefsPath(), JSON.stringify(prefs, null, 2), "utf-8");
16443
16620
  return true;
16444
16621
  }
16445
16622
  appendRule(category, pattern, cause, solution) {
@@ -16456,8 +16633,8 @@ var init_store2 = __esm(() => {
16456
16633
  });
16457
16634
 
16458
16635
  // src/tools/remember.ts
16459
- import { homedir as homedir6 } from "os";
16460
- import { join as join20 } from "path";
16636
+ import { homedir as homedir7 } from "os";
16637
+ import { join as join21 } from "path";
16461
16638
  var CATEGORIES, rememberTool;
16462
16639
  var init_remember = __esm(() => {
16463
16640
  init_i18n();
@@ -16496,7 +16673,7 @@ var init_remember = __esm(() => {
16496
16673
  if (!CATEGORIES.includes(category)) {
16497
16674
  return { success: false, output: t("tool.invalid_params") };
16498
16675
  }
16499
- const memoryDir = join20(homedir6(), ".mma", "memory");
16676
+ const memoryDir = join21(homedir7(), ".mma", "memory");
16500
16677
  const store = new MemoryStore(memoryDir);
16501
16678
  try {
16502
16679
  if (category === "preferences") {
@@ -16528,8 +16705,8 @@ var init_remember = __esm(() => {
16528
16705
  });
16529
16706
 
16530
16707
  // src/tools/recall.ts
16531
- import { homedir as homedir7 } from "os";
16532
- import { join as join21 } from "path";
16708
+ import { homedir as homedir8 } from "os";
16709
+ import { join as join22 } from "path";
16533
16710
  function formatAll(store) {
16534
16711
  const parts = [];
16535
16712
  const prefs = store.getPreferences();
@@ -16613,7 +16790,7 @@ var init_recall = __esm(() => {
16613
16790
  handler: async (_ctx, args) => {
16614
16791
  const query = args.query ? String(args.query) : "";
16615
16792
  const category = args.category ? String(args.category) : "";
16616
- const memoryDir = join21(homedir7(), ".mma", "memory");
16793
+ const memoryDir = join22(homedir8(), ".mma", "memory");
16617
16794
  const store = new MemoryStore(memoryDir);
16618
16795
  try {
16619
16796
  if (!query && !category) {
@@ -16651,9 +16828,9 @@ var init_recall = __esm(() => {
16651
16828
  });
16652
16829
 
16653
16830
  // src/modules/browser/bridge-path.ts
16654
- import { existsSync as existsSync29 } from "fs";
16831
+ import { existsSync as existsSync30 } from "fs";
16655
16832
  function pickExistingPath(candidates, fallback = candidates[0]) {
16656
- return candidates.find((p) => existsSync29(p)) ?? fallback;
16833
+ return candidates.find((p) => existsSync30(p)) ?? fallback;
16657
16834
  }
16658
16835
  var init_bridge_path = () => {};
16659
16836
 
@@ -16664,13 +16841,13 @@ __export(exports_bridge_client, {
16664
16841
  });
16665
16842
  import { spawn as spawn5 } from "child_process";
16666
16843
  import { createInterface } from "readline";
16667
- import { dirname as dirname10, join as join22 } from "path";
16844
+ import { dirname as dirname10, join as join23 } from "path";
16668
16845
  import { fileURLToPath } from "url";
16669
16846
  function bridgeScriptPath() {
16670
16847
  const dir = dirname10(fileURLToPath(import.meta.url));
16671
16848
  const candidates = [
16672
- join22(dir, "bridge-server.mjs"),
16673
- join22(dir, "modules", "browser", "bridge-server.mjs")
16849
+ join23(dir, "bridge-server.mjs"),
16850
+ join23(dir, "modules", "browser", "bridge-server.mjs")
16674
16851
  ];
16675
16852
  return pickExistingPath(candidates);
16676
16853
  }
@@ -17224,15 +17401,15 @@ function buildTextExtractionScript() {
17224
17401
 
17225
17402
  // src/modules/browser/cookie-store.ts
17226
17403
  import { readFile, writeFile, mkdir } from "fs/promises";
17227
- import { join as join23 } from "path";
17404
+ import { join as join24 } from "path";
17228
17405
 
17229
17406
  class CookieStore {
17230
17407
  filePath;
17231
17408
  constructor(cookieDir) {
17232
- this.filePath = join23(cookieDir, "cookies.json");
17409
+ this.filePath = join24(cookieDir, "cookies.json");
17233
17410
  }
17234
17411
  async save(cookies) {
17235
- await mkdir(join23(this.filePath, ".."), { recursive: true });
17412
+ await mkdir(join24(this.filePath, ".."), { recursive: true });
17236
17413
  await writeFile(this.filePath, JSON.stringify(cookies, null, 2), "utf-8");
17237
17414
  }
17238
17415
  async load() {
@@ -17590,10 +17767,10 @@ var init_session = __esm(() => {
17590
17767
  });
17591
17768
 
17592
17769
  // src/tools/browser.ts
17593
- import { join as join24 } from "path";
17770
+ import { join as join25 } from "path";
17594
17771
  function getSession(ctx) {
17595
17772
  if (!session) {
17596
- const cookieDir = join24(ctx.baseDir, ".mma", "browser");
17773
+ const cookieDir = join25(ctx.baseDir, ".mma", "browser");
17597
17774
  session = new BrowserSession({
17598
17775
  ...DEFAULT_BROWSER_CONFIG,
17599
17776
  headless: ctx.config.browser?.headless ?? true,
@@ -17719,7 +17896,7 @@ __export(exports_image_utils, {
17719
17896
  detectMime: () => detectMime,
17720
17897
  bufferToDataUrl: () => bufferToDataUrl
17721
17898
  });
17722
- import { readFileSync as readFileSync16 } from "fs";
17899
+ import { readFileSync as readFileSync17 } from "fs";
17723
17900
  import { extname as extname3 } from "path";
17724
17901
  function detectMime(filePath) {
17725
17902
  const ext = extname3(filePath).toLowerCase();
@@ -17740,9 +17917,9 @@ async function readClipboardImage() {
17740
17917
  async function readClipboardFallback() {
17741
17918
  const { platform: platform5 } = await import("os");
17742
17919
  const { execSync } = await import("child_process");
17743
- const { readFileSync: readFileSync17, unlinkSync: unlinkSync4 } = await import("fs");
17744
- const { join: join25 } = await import("path");
17745
- const tmpPath = join25(process.env.TEMP || process.env.TMP || "/tmp", `mma-clip-${Date.now()}.png`);
17920
+ const { readFileSync: readFileSync18, unlinkSync: unlinkSync4 } = await import("fs");
17921
+ const { join: join26 } = await import("path");
17922
+ const tmpPath = join26(process.env.TEMP || process.env.TMP || "/tmp", `mma-clip-${Date.now()}.png`);
17746
17923
  try {
17747
17924
  if (platform5() === "linux") {
17748
17925
  execSync(`xclip -selection clipboard -t image/png -o > "${tmpPath}" 2>/dev/null`, {
@@ -17751,7 +17928,7 @@ async function readClipboardFallback() {
17751
17928
  } else {
17752
17929
  return null;
17753
17930
  }
17754
- const buf = readFileSync17(tmpPath);
17931
+ const buf = readFileSync18(tmpPath);
17755
17932
  unlinkSync4(tmpPath);
17756
17933
  return buf.length > 0 ? buf : null;
17757
17934
  } catch {
@@ -17762,7 +17939,7 @@ async function readClipboardFallback() {
17762
17939
  }
17763
17940
  }
17764
17941
  async function loadFileAsDataUrl(filePath) {
17765
- const buf = readFileSync16(filePath);
17942
+ const buf = readFileSync17(filePath);
17766
17943
  if (typeof Bun !== "undefined" && typeof Bun.Image !== "undefined") {
17767
17944
  try {
17768
17945
  const img = new Bun.Image(buf);
@@ -17822,7 +17999,7 @@ var init_image_utils = __esm(() => {
17822
17999
  });
17823
18000
 
17824
18001
  // src/tools/attach-image.ts
17825
- import { existsSync as existsSync30 } from "fs";
18002
+ import { existsSync as existsSync31 } from "fs";
17826
18003
  import { resolve as resolve17 } from "path";
17827
18004
  var attachImageTool;
17828
18005
  var init_attach_image = __esm(() => {
@@ -17874,7 +18051,7 @@ var init_attach_image = __esm(() => {
17874
18051
  dataUrl = result.dataUrl;
17875
18052
  } else {
17876
18053
  const absPath = resolve17(ctx.baseDir, source);
17877
- if (!existsSync30(absPath)) {
18054
+ if (!existsSync31(absPath)) {
17878
18055
  return {
17879
18056
  success: false,
17880
18057
  output: t("image.not_found", { path: source })
@@ -18132,16 +18309,16 @@ class ModuleRegistry {
18132
18309
  }
18133
18310
 
18134
18311
  // src/modules/plugins/loader.ts
18135
- import { readdirSync as readdirSync9, existsSync as existsSync31, statSync as statSync6 } from "fs";
18136
- import { join as join25, basename as basename3 } from "path";
18312
+ import { readdirSync as readdirSync10, existsSync as existsSync32, statSync as statSync6 } from "fs";
18313
+ import { join as join26, basename as basename3 } from "path";
18137
18314
 
18138
18315
  class PluginLoader {
18139
18316
  loadFromDir(dirPath, pluginManager, logger, options) {
18140
- if (!existsSync31(dirPath))
18317
+ if (!existsSync32(dirPath))
18141
18318
  return;
18142
- const entries = readdirSync9(dirPath).sort();
18319
+ const entries = readdirSync10(dirPath).sort();
18143
18320
  for (const entry of entries) {
18144
- const fullPath = join25(dirPath, entry);
18321
+ const fullPath = join26(dirPath, entry);
18145
18322
  const stat = statSync6(fullPath);
18146
18323
  if (stat.isFile()) {
18147
18324
  if (!entry.endsWith(".ts") && !entry.endsWith(".js"))
@@ -18157,8 +18334,8 @@ class PluginLoader {
18157
18334
  }
18158
18335
  findEntryFile(dir) {
18159
18336
  for (const name of FOLDER_ENTRY_NAMES) {
18160
- const candidate = join25(dir, name);
18161
- if (existsSync31(candidate))
18337
+ const candidate = join26(dir, name);
18338
+ if (existsSync32(candidate))
18162
18339
  return candidate;
18163
18340
  }
18164
18341
  return null;
@@ -18200,8 +18377,8 @@ var init_loader = __esm(() => {
18200
18377
 
18201
18378
  // src/modules/plugins/builtin/lint-on-write.ts
18202
18379
  import { spawn as spawn6, execSync } from "child_process";
18203
- import { existsSync as existsSync32, readFileSync as readFileSync17 } from "fs";
18204
- import { resolve as resolve18, extname as extname4, join as join26 } from "path";
18380
+ import { existsSync as existsSync33, readFileSync as readFileSync18 } from "fs";
18381
+ import { resolve as resolve18, extname as extname4, join as join27 } from "path";
18205
18382
  import { platform as platform5 } from "os";
18206
18383
  function lintCacheKey(baseDir, lintScript) {
18207
18384
  return `${baseDir}::${lintScript}`;
@@ -18277,7 +18454,7 @@ class LintOnWritePlugin {
18277
18454
  if (!path)
18278
18455
  return;
18279
18456
  const fullPath = resolve18(ctx.baseDir, path);
18280
- if (!existsSync32(fullPath))
18457
+ if (!existsSync33(fullPath))
18281
18458
  return;
18282
18459
  const signal = ctx.signal;
18283
18460
  if (signal?.aborted)
@@ -18301,7 +18478,7 @@ class LintOnWritePlugin {
18301
18478
  if (ext === ".ts" || ext === ".tsx" || ext === ".cts" || ext === ".mts") {
18302
18479
  let content = "";
18303
18480
  try {
18304
- content = readFileSync17(filePath, "utf-8");
18481
+ content = readFileSync18(filePath, "utf-8");
18305
18482
  } catch {
18306
18483
  return null;
18307
18484
  }
@@ -18343,11 +18520,11 @@ class LintOnWritePlugin {
18343
18520
  async runProjectLint(ctx, result, signal) {
18344
18521
  let lintScript;
18345
18522
  try {
18346
- const packageJsonPath = join26(ctx.baseDir, "package.json");
18347
- if (!existsSync32(packageJsonPath)) {
18523
+ const packageJsonPath = join27(ctx.baseDir, "package.json");
18524
+ if (!existsSync33(packageJsonPath)) {
18348
18525
  return;
18349
18526
  }
18350
- const packageJson = JSON.parse(readFileSync17(packageJsonPath, "utf-8"));
18527
+ const packageJson = JSON.parse(readFileSync18(packageJsonPath, "utf-8"));
18351
18528
  lintScript = packageJson.scripts?.lint;
18352
18529
  if (!lintScript) {
18353
18530
  return;
@@ -18380,8 +18557,8 @@ ${stdout}`;
18380
18557
  }
18381
18558
  async runProjectTypeCheck(filePath, baseDir, result, signal) {
18382
18559
  const projectRoot = findProjectRoot(filePath, baseDir, ["tsconfig.json", "package.json"]);
18383
- const tsconfigPath = join26(projectRoot, "tsconfig.json");
18384
- if (!existsSync32(tsconfigPath)) {
18560
+ const tsconfigPath = join27(projectRoot, "tsconfig.json");
18561
+ if (!existsSync33(tsconfigPath)) {
18385
18562
  return;
18386
18563
  }
18387
18564
  const now = Date.now();
@@ -18637,11 +18814,11 @@ class PlanTracker {
18637
18814
  var init_tracker = () => {};
18638
18815
 
18639
18816
  // src/modules/execution/plan-store.ts
18640
- import { readFileSync as readFileSync18, writeFileSync as writeFileSync10, mkdirSync as mkdirSync14, existsSync as existsSync33, readdirSync as readdirSync10, rmSync } from "fs";
18641
- import { join as join27 } from "path";
18817
+ import { readFileSync as readFileSync19, writeFileSync as writeFileSync11, mkdirSync as mkdirSync15, existsSync as existsSync34, readdirSync as readdirSync11, rmSync } from "fs";
18818
+ import { join as join28 } from "path";
18642
18819
  function readPlanFile(path, fallbackBaseDir) {
18643
18820
  try {
18644
- const raw = readFileSync18(path, "utf-8");
18821
+ const raw = readFileSync19(path, "utf-8");
18645
18822
  if (!raw.trim())
18646
18823
  return null;
18647
18824
  const parsed = JSON.parse(raw);
@@ -18660,13 +18837,13 @@ function readPlanFile(path, fallbackBaseDir) {
18660
18837
  }
18661
18838
  }
18662
18839
  function writePlanFile(path, plan) {
18663
- writeFileSync10(path, JSON.stringify(plan, null, 2), "utf-8");
18840
+ writeFileSync11(path, JSON.stringify(plan, null, 2), "utf-8");
18664
18841
  }
18665
18842
  function listDir(dir, baseDir) {
18666
- if (!existsSync33(dir))
18843
+ if (!existsSync34(dir))
18667
18844
  return [];
18668
- const files = readdirSync10(dir).filter((f) => f.endsWith(".json"));
18669
- return files.map((f) => readPlanFile(join27(dir, f), baseDir)).filter((p) => p !== null);
18845
+ const files = readdirSync11(dir).filter((f) => f.endsWith(".json"));
18846
+ return files.map((f) => readPlanFile(join28(dir, f), baseDir)).filter((p) => p !== null);
18670
18847
  }
18671
18848
  function toMeta(plan, status) {
18672
18849
  return {
@@ -18687,33 +18864,33 @@ class PlanStore {
18687
18864
  archiveDir;
18688
18865
  legacyPath;
18689
18866
  constructor(baseDir) {
18690
- const mmaDir = join27(baseDir, ".mma");
18691
- if (!existsSync33(mmaDir))
18692
- mkdirSync14(mmaDir, { recursive: true });
18867
+ const mmaDir = join28(baseDir, ".mma");
18868
+ if (!existsSync34(mmaDir))
18869
+ mkdirSync15(mmaDir, { recursive: true });
18693
18870
  this.baseDir = baseDir;
18694
- this.plansDir = join27(mmaDir, "plans");
18695
- this.draftsDir = join27(this.plansDir, "drafts");
18696
- this.archiveDir = join27(this.plansDir, "archive");
18697
- this.legacyPath = join27(mmaDir, LEGACY_FILE);
18871
+ this.plansDir = join28(mmaDir, "plans");
18872
+ this.draftsDir = join28(this.plansDir, "drafts");
18873
+ this.archiveDir = join28(this.plansDir, "archive");
18874
+ this.legacyPath = join28(mmaDir, LEGACY_FILE);
18698
18875
  for (const dir of [this.plansDir, this.draftsDir, this.archiveDir]) {
18699
- if (!existsSync33(dir))
18700
- mkdirSync14(dir, { recursive: true });
18876
+ if (!existsSync34(dir))
18877
+ mkdirSync15(dir, { recursive: true });
18701
18878
  }
18702
18879
  }
18703
18880
  activePath() {
18704
- return join27(this.plansDir, "active.json");
18881
+ return join28(this.plansDir, "active.json");
18705
18882
  }
18706
18883
  saveActive(plan) {
18707
18884
  writePlanFile(this.activePath(), plan);
18708
18885
  }
18709
18886
  loadActive() {
18710
18887
  const activePath = this.activePath();
18711
- if (existsSync33(activePath)) {
18888
+ if (existsSync34(activePath)) {
18712
18889
  const plan = readPlanFile(activePath, this.baseDir);
18713
18890
  if (plan)
18714
18891
  return plan;
18715
18892
  }
18716
- if (existsSync33(this.legacyPath)) {
18893
+ if (existsSync34(this.legacyPath)) {
18717
18894
  const legacy = readPlanFile(this.legacyPath, this.baseDir);
18718
18895
  if (legacy) {
18719
18896
  this.saveActive(legacy);
@@ -18727,26 +18904,26 @@ class PlanStore {
18727
18904
  }
18728
18905
  clearActive() {
18729
18906
  const p = this.activePath();
18730
- if (existsSync33(p))
18907
+ if (existsSync34(p))
18731
18908
  rmSync(p, { force: true });
18732
18909
  }
18733
18910
  saveDraft(plan) {
18734
- writePlanFile(join27(this.draftsDir, `${plan.id}.json`), plan);
18911
+ writePlanFile(join28(this.draftsDir, `${plan.id}.json`), plan);
18735
18912
  }
18736
18913
  loadDraft(id) {
18737
- const p = join27(this.draftsDir, `${id}.json`);
18738
- return existsSync33(p) ? readPlanFile(p, this.baseDir) : null;
18914
+ const p = join28(this.draftsDir, `${id}.json`);
18915
+ return existsSync34(p) ? readPlanFile(p, this.baseDir) : null;
18739
18916
  }
18740
18917
  removeDraft(id) {
18741
- const p = join27(this.draftsDir, `${id}.json`);
18742
- if (existsSync33(p))
18918
+ const p = join28(this.draftsDir, `${id}.json`);
18919
+ if (existsSync34(p))
18743
18920
  rmSync(p, { force: true });
18744
18921
  }
18745
18922
  listDrafts() {
18746
18923
  return listDir(this.draftsDir, this.baseDir);
18747
18924
  }
18748
18925
  archivePlan(plan) {
18749
- writePlanFile(join27(this.archiveDir, `${plan.id}.json`), plan);
18926
+ writePlanFile(join28(this.archiveDir, `${plan.id}.json`), plan);
18750
18927
  this.removeDraft(plan.id);
18751
18928
  const active = this.loadActive();
18752
18929
  if (active && active.id === plan.id) {
@@ -18757,8 +18934,8 @@ class PlanStore {
18757
18934
  return listDir(this.archiveDir, this.baseDir);
18758
18935
  }
18759
18936
  removeArchived(id) {
18760
- const p = join27(this.archiveDir, `${id}.json`);
18761
- if (existsSync33(p))
18937
+ const p = join28(this.archiveDir, `${id}.json`);
18938
+ if (existsSync34(p))
18762
18939
  rmSync(p, { force: true });
18763
18940
  }
18764
18941
  listAll() {
@@ -18790,13 +18967,13 @@ class PlanStore {
18790
18967
  this.clearActive();
18791
18968
  return "active";
18792
18969
  }
18793
- const draftPath = join27(this.draftsDir, `${id}.json`);
18794
- if (existsSync33(draftPath)) {
18970
+ const draftPath = join28(this.draftsDir, `${id}.json`);
18971
+ if (existsSync34(draftPath)) {
18795
18972
  rmSync(draftPath, { force: true });
18796
18973
  return "draft";
18797
18974
  }
18798
- const archivedPath = join27(this.archiveDir, `${id}.json`);
18799
- if (existsSync33(archivedPath)) {
18975
+ const archivedPath = join28(this.archiveDir, `${id}.json`);
18976
+ if (existsSync34(archivedPath)) {
18800
18977
  rmSync(archivedPath, { force: true });
18801
18978
  return "archived";
18802
18979
  }
@@ -19832,7 +20009,7 @@ var init_plan_tool = __esm(() => {
19832
20009
  });
19833
20010
 
19834
20011
  // src/modules/execution/module.ts
19835
- import { existsSync as existsSync34, readFileSync as readFileSync19 } from "fs";
20012
+ import { existsSync as existsSync35, readFileSync as readFileSync20 } from "fs";
19836
20013
  import { resolve as resolve19 } from "path";
19837
20014
 
19838
20015
  class ExecutionModule {
@@ -20166,7 +20343,7 @@ class ExecutionModule {
20166
20343
  "poetry.lock",
20167
20344
  "requirements.txt"
20168
20345
  ];
20169
- const hasLockFile = lockFiles.some((f) => existsSync34(resolve19(this.baseDir, f)));
20346
+ const hasLockFile = lockFiles.some((f) => existsSync35(resolve19(this.baseDir, f)));
20170
20347
  if (!hasLockFile) {
20171
20348
  if (contextManager) {
20172
20349
  const hints = this.state.depsGateHints.get(step.id) || 0;
@@ -20198,7 +20375,7 @@ class ExecutionModule {
20198
20375
  if (!r)
20199
20376
  continue;
20200
20377
  try {
20201
- const content = readFileSync19(r, "utf-8");
20378
+ const content = readFileSync20(r, "utf-8");
20202
20379
  if (content.trim().length < 10) {
20203
20380
  emptyFiles.push(r);
20204
20381
  }
@@ -20306,9 +20483,9 @@ var init_module = __esm(() => {
20306
20483
  });
20307
20484
 
20308
20485
  // src/modules/security/session-encryption.ts
20309
- import { readFileSync as readFileSync20, writeFileSync as writeFileSync11, existsSync as existsSync35, readdirSync as readdirSync11, unlinkSync as unlinkSync4 } from "fs";
20310
- import { join as join28 } from "path";
20311
- import { homedir as homedir8 } from "os";
20486
+ import { readFileSync as readFileSync21, writeFileSync as writeFileSync12, existsSync as existsSync36, readdirSync as readdirSync12, unlinkSync as unlinkSync4 } from "fs";
20487
+ import { join as join29 } from "path";
20488
+ import { homedir as homedir9 } from "os";
20312
20489
 
20313
20490
  class SessionFileEncryptor {
20314
20491
  config;
@@ -20316,7 +20493,7 @@ class SessionFileEncryptor {
20316
20493
  constructor(config) {
20317
20494
  this.config = { ...DEFAULT_SESSION_ENCRYPTION, ...config };
20318
20495
  this.encryptor = new ConfigEncryptor({
20319
- keyPath: config?.keyPath || join28(homedir8(), ".mma", ".session-encryption-key")
20496
+ keyPath: config?.keyPath || join29(homedir9(), ".mma", ".session-encryption-key")
20320
20497
  });
20321
20498
  }
20322
20499
  isEnabled() {
@@ -20361,23 +20538,23 @@ class SessionFileEncryptor {
20361
20538
  return lines.map((line) => this.decryptFileContent(line));
20362
20539
  }
20363
20540
  readSessionFile(filePath) {
20364
- const content = readFileSync20(filePath, "utf8");
20541
+ const content = readFileSync21(filePath, "utf8");
20365
20542
  return this.decryptFileContent(content);
20366
20543
  }
20367
20544
  writeSessionFile(filePath, content) {
20368
20545
  const encrypted = this.encryptFileContent(content);
20369
- writeFileSync11(filePath, encrypted, "utf8");
20546
+ writeFileSync12(filePath, encrypted, "utf8");
20370
20547
  }
20371
20548
  readSessionJSON(filePath) {
20372
- const content = readFileSync20(filePath, "utf8");
20549
+ const content = readFileSync21(filePath, "utf8");
20373
20550
  return this.decryptJSON(content);
20374
20551
  }
20375
20552
  writeSessionJSON(filePath, obj) {
20376
20553
  const content = this.encryptJSON(obj);
20377
- writeFileSync11(filePath, content, "utf8");
20554
+ writeFileSync12(filePath, content, "utf8");
20378
20555
  }
20379
20556
  readSessionJSONL(filePath) {
20380
- const content = readFileSync20(filePath, "utf8");
20557
+ const content = readFileSync21(filePath, "utf8");
20381
20558
  const lines = content.split(`
20382
20559
  `).filter((line) => line.trim());
20383
20560
  const decryptedLines = this.decryptJSONL(lines);
@@ -20391,7 +20568,7 @@ class SessionFileEncryptor {
20391
20568
  }
20392
20569
  appendToSessionJSONL(filePath, obj) {
20393
20570
  const encryptedLine = this.encryptFileContent(JSON.stringify(obj));
20394
- writeFileSync11(filePath, encryptedLine + `
20571
+ writeFileSync12(filePath, encryptedLine + `
20395
20572
  `, {
20396
20573
  flag: "a",
20397
20574
  encoding: "utf8"
@@ -20400,14 +20577,14 @@ class SessionFileEncryptor {
20400
20577
  encryptSessionDirectory(sessionDir) {
20401
20578
  if (!this.config.enabled)
20402
20579
  return;
20403
- const files = readdirSync11(sessionDir);
20580
+ const files = readdirSync12(sessionDir);
20404
20581
  for (const file of files) {
20405
- const filePath = join28(sessionDir, file);
20406
- if (existsSync35(filePath) && !file.endsWith(".enc")) {
20582
+ const filePath = join29(sessionDir, file);
20583
+ if (existsSync36(filePath) && !file.endsWith(".enc")) {
20407
20584
  try {
20408
- const content = readFileSync20(filePath, "utf8");
20585
+ const content = readFileSync21(filePath, "utf8");
20409
20586
  const encrypted = this.encryptFileContent(content);
20410
- writeFileSync11(filePath + ".enc", encrypted, "utf8");
20587
+ writeFileSync12(filePath + ".enc", encrypted, "utf8");
20411
20588
  unlinkSync4(filePath);
20412
20589
  } catch {}
20413
20590
  }
@@ -20416,15 +20593,15 @@ class SessionFileEncryptor {
20416
20593
  decryptSessionDirectory(sessionDir) {
20417
20594
  if (!this.config.enabled)
20418
20595
  return;
20419
- const files = readdirSync11(sessionDir);
20596
+ const files = readdirSync12(sessionDir);
20420
20597
  for (const file of files) {
20421
20598
  if (file.endsWith(".enc")) {
20422
- const encFilePath = join28(sessionDir, file);
20599
+ const encFilePath = join29(sessionDir, file);
20423
20600
  const decFilePath = encFilePath.slice(0, -4);
20424
20601
  try {
20425
- const content = readFileSync20(encFilePath, "utf8");
20602
+ const content = readFileSync21(encFilePath, "utf8");
20426
20603
  const decrypted = this.decryptFileContent(content);
20427
- writeFileSync11(decFilePath, decrypted, "utf8");
20604
+ writeFileSync12(decFilePath, decrypted, "utf8");
20428
20605
  unlinkSync4(encFilePath);
20429
20606
  } catch {}
20430
20607
  }
@@ -20444,15 +20621,15 @@ var init_session_encryption = __esm(() => {
20444
20621
 
20445
20622
  // src/modules/session/store.ts
20446
20623
  import {
20447
- existsSync as existsSync36,
20448
- mkdirSync as mkdirSync15,
20449
- readdirSync as readdirSync12,
20450
- readFileSync as readFileSync21,
20624
+ existsSync as existsSync37,
20625
+ mkdirSync as mkdirSync16,
20626
+ readdirSync as readdirSync13,
20627
+ readFileSync as readFileSync22,
20451
20628
  rmSync as rmSync2,
20452
- writeFileSync as writeFileSync12,
20629
+ writeFileSync as writeFileSync13,
20453
20630
  appendFileSync as appendFileSync6
20454
20631
  } from "fs";
20455
- import { join as join29 } from "path";
20632
+ import { join as join30 } from "path";
20456
20633
  import { gzipSync } from "zlib";
20457
20634
 
20458
20635
  class SessionStore {
@@ -20466,7 +20643,7 @@ class SessionStore {
20466
20643
  }
20467
20644
  }
20468
20645
  getSessionDir(id) {
20469
- return join29(this.baseDir, id);
20646
+ return join30(this.baseDir, id);
20470
20647
  }
20471
20648
  updateEncryption(config) {
20472
20649
  if (config?.enabled) {
@@ -20479,32 +20656,32 @@ class SessionStore {
20479
20656
  return this.encryptor?.isEnabled() ?? false;
20480
20657
  }
20481
20658
  init() {
20482
- mkdirSync15(this.baseDir, { recursive: true, mode: 448 });
20659
+ mkdirSync16(this.baseDir, { recursive: true, mode: 448 });
20483
20660
  }
20484
20661
  sessionDir(id) {
20485
- return join29(this.baseDir, id);
20662
+ return join30(this.baseDir, id);
20486
20663
  }
20487
20664
  metaPath(id) {
20488
- return join29(this.sessionDir(id), "meta.json");
20665
+ return join30(this.sessionDir(id), "meta.json");
20489
20666
  }
20490
20667
  historyPath(id) {
20491
- return join29(this.sessionDir(id), "history.jsonl");
20668
+ return join30(this.sessionDir(id), "history.jsonl");
20492
20669
  }
20493
20670
  sessionLogPath(id) {
20494
- return join29(this.sessionDir(id), "session.jsonl");
20671
+ return join30(this.sessionDir(id), "session.jsonl");
20495
20672
  }
20496
20673
  sessionExists(id) {
20497
- return existsSync36(this.metaPath(id));
20674
+ return existsSync37(this.metaPath(id));
20498
20675
  }
20499
20676
  saveMeta(id, meta) {
20500
20677
  this._metaCache.set(id, meta);
20501
20678
  const dir = this.sessionDir(id);
20502
- mkdirSync15(dir, { recursive: true, mode: 448 });
20679
+ mkdirSync16(dir, { recursive: true, mode: 448 });
20503
20680
  const content = JSON.stringify(meta, null, 2);
20504
20681
  if (this.encryptor) {
20505
- writeFileSync12(this.metaPath(id), this.encryptor.encryptFileContent(content), { encoding: "utf-8", mode: 384 });
20682
+ writeFileSync13(this.metaPath(id), this.encryptor.encryptFileContent(content), { encoding: "utf-8", mode: 384 });
20506
20683
  } else {
20507
- writeFileSync12(this.metaPath(id), content, { encoding: "utf-8", mode: 384 });
20684
+ writeFileSync13(this.metaPath(id), content, { encoding: "utf-8", mode: 384 });
20508
20685
  }
20509
20686
  }
20510
20687
  loadMeta(id) {
@@ -20512,10 +20689,10 @@ class SessionStore {
20512
20689
  if (cached)
20513
20690
  return cached;
20514
20691
  const path = this.metaPath(id);
20515
- if (!existsSync36(path))
20692
+ if (!existsSync37(path))
20516
20693
  return null;
20517
20694
  try {
20518
- const raw = readFileSync21(path, "utf-8");
20695
+ const raw = readFileSync22(path, "utf-8");
20519
20696
  const content = this.encryptor ? this.encryptor.decryptFileContent(raw) : raw;
20520
20697
  const meta = JSON.parse(content);
20521
20698
  this._metaCache.set(id, meta);
@@ -20526,7 +20703,7 @@ class SessionStore {
20526
20703
  }
20527
20704
  appendMessage(id, msg) {
20528
20705
  const dir = this.sessionDir(id);
20529
- mkdirSync15(dir, { recursive: true, mode: 448 });
20706
+ mkdirSync16(dir, { recursive: true, mode: 448 });
20530
20707
  const line = JSON.stringify(msg);
20531
20708
  if (this.encryptor?.isEnabled()) {
20532
20709
  appendFileSync6(this.historyPath(id), this.encryptor.encryptFileContent(line) + `
@@ -20544,10 +20721,10 @@ class SessionStore {
20544
20721
  }
20545
20722
  loadHistory(id) {
20546
20723
  const path = this.historyPath(id);
20547
- if (!existsSync36(path))
20724
+ if (!existsSync37(path))
20548
20725
  return [];
20549
20726
  try {
20550
- const raw = readFileSync21(path, "utf-8");
20727
+ const raw = readFileSync22(path, "utf-8");
20551
20728
  const lines = raw.split(`
20552
20729
  `).filter(Boolean);
20553
20730
  const parseLine = (line) => {
@@ -20573,7 +20750,7 @@ class SessionStore {
20573
20750
  }
20574
20751
  appendSessionLog(id, entry) {
20575
20752
  const dir = this.sessionDir(id);
20576
- mkdirSync15(dir, { recursive: true, mode: 448 });
20753
+ mkdirSync16(dir, { recursive: true, mode: 448 });
20577
20754
  const line = JSON.stringify(entry);
20578
20755
  if (this.encryptor?.isEnabled()) {
20579
20756
  appendFileSync6(this.sessionLogPath(id), this.encryptor.encryptFileContent(line) + `
@@ -20585,10 +20762,10 @@ class SessionStore {
20585
20762
  }
20586
20763
  loadSessionLog(id) {
20587
20764
  const path = this.sessionLogPath(id);
20588
- if (!existsSync36(path))
20765
+ if (!existsSync37(path))
20589
20766
  return [];
20590
20767
  try {
20591
- const raw = readFileSync21(path, "utf-8");
20768
+ const raw = readFileSync22(path, "utf-8");
20592
20769
  const lines = raw.split(`
20593
20770
  `).filter(Boolean);
20594
20771
  const parseLine = (line) => {
@@ -20613,9 +20790,9 @@ class SessionStore {
20613
20790
  }
20614
20791
  }
20615
20792
  listSessions() {
20616
- if (!existsSync36(this.baseDir))
20793
+ if (!existsSync37(this.baseDir))
20617
20794
  return [];
20618
- const entries = readdirSync12(this.baseDir, { withFileTypes: true });
20795
+ const entries = readdirSync13(this.baseDir, { withFileTypes: true });
20619
20796
  const sessions = [];
20620
20797
  for (const entry of entries) {
20621
20798
  if (entry.isDirectory()) {
@@ -20630,7 +20807,7 @@ class SessionStore {
20630
20807
  deleteSession(id) {
20631
20808
  this._metaCache.delete(id);
20632
20809
  const dir = this.sessionDir(id);
20633
- if (existsSync36(dir)) {
20810
+ if (existsSync37(dir)) {
20634
20811
  rmSync2(dir, { recursive: true, force: true });
20635
20812
  }
20636
20813
  }
@@ -20642,11 +20819,11 @@ class SessionStore {
20642
20819
  const updatedAt = new Date(session2.updatedAt);
20643
20820
  if (updatedAt < thirtyDaysAgo) {
20644
20821
  const historyPath = this.historyPath(session2.id);
20645
- if (existsSync36(historyPath)) {
20646
- const content = readFileSync21(historyPath, "utf-8");
20822
+ if (existsSync37(historyPath)) {
20823
+ const content = readFileSync22(historyPath, "utf-8");
20647
20824
  const compressed = gzipSync(content);
20648
- const gzPath = join29(this.baseDir, `${session2.id}.jsonl.gz`);
20649
- writeFileSync12(gzPath, compressed);
20825
+ const gzPath = join30(this.baseDir, `${session2.id}.jsonl.gz`);
20826
+ writeFileSync13(gzPath, compressed);
20650
20827
  rmSync2(historyPath);
20651
20828
  }
20652
20829
  }
@@ -20855,9 +21032,9 @@ class ProfileCompressor {
20855
21032
  }
20856
21033
 
20857
21034
  // src/modules/user-profile/profile.ts
20858
- import { readFileSync as readFileSync22, writeFileSync as writeFileSync13, existsSync as existsSync37, mkdirSync as mkdirSync16 } from "fs";
20859
- import { join as join30 } from "path";
20860
- import { homedir as homedir9, hostname, platform as platform7, type } from "os";
21035
+ import { readFileSync as readFileSync23, writeFileSync as writeFileSync14, existsSync as existsSync38, mkdirSync as mkdirSync17 } from "fs";
21036
+ import { join as join31 } from "path";
21037
+ import { homedir as homedir10, hostname, platform as platform7, type } from "os";
20861
21038
  import { env } from "process";
20862
21039
 
20863
21040
  class UserProfile {
@@ -20873,24 +21050,24 @@ class UserProfile {
20873
21050
  os: `${type()} ${hostname()}`,
20874
21051
  hostname: hostname(),
20875
21052
  shell: env.SHELL || env.ComSpec || "unknown",
20876
- home: homedir9(),
21053
+ home: homedir10(),
20877
21054
  nodeVersion: process.version,
20878
21055
  preferences: { ...this.preferences }
20879
21056
  };
20880
21057
  return this.info;
20881
21058
  }
20882
21059
  save() {
20883
- if (!existsSync37(this.profileDir)) {
20884
- mkdirSync16(this.profileDir, { recursive: true });
21060
+ if (!existsSync38(this.profileDir)) {
21061
+ mkdirSync17(this.profileDir, { recursive: true });
20885
21062
  }
20886
- writeFileSync13(join30(this.profileDir, "profile.json"), JSON.stringify({ ...this.info, preferences: this.preferences }, null, 2), "utf-8");
21063
+ writeFileSync14(join31(this.profileDir, "profile.json"), JSON.stringify({ ...this.info, preferences: this.preferences }, null, 2), "utf-8");
20887
21064
  }
20888
21065
  load() {
20889
- const path = join30(this.profileDir, "profile.json");
20890
- if (!existsSync37(path))
21066
+ const path = join31(this.profileDir, "profile.json");
21067
+ if (!existsSync38(path))
20891
21068
  return null;
20892
21069
  try {
20893
- const data = JSON.parse(readFileSync22(path, "utf-8"));
21070
+ const data = JSON.parse(readFileSync23(path, "utf-8"));
20894
21071
  this.info = {
20895
21072
  platform: data.platform,
20896
21073
  os: data.os,
@@ -20925,21 +21102,21 @@ class UserProfile {
20925
21102
  var init_profile = () => {};
20926
21103
 
20927
21104
  // src/modules/skills/loader.ts
20928
- import { readdirSync as readdirSync13, readFileSync as readFileSync23, existsSync as existsSync38, statSync as statSync7 } from "fs";
20929
- import { join as join31 } from "path";
21105
+ import { readdirSync as readdirSync14, readFileSync as readFileSync24, existsSync as existsSync39, statSync as statSync7 } from "fs";
21106
+ import { join as join32 } from "path";
20930
21107
 
20931
21108
  class SkillsLoader {
20932
21109
  loadFromDir(dirPath) {
20933
- if (!existsSync38(dirPath))
21110
+ if (!existsSync39(dirPath))
20934
21111
  return [];
20935
21112
  const skills = [];
20936
21113
  this.scanDir(dirPath, skills);
20937
21114
  return skills;
20938
21115
  }
20939
21116
  scanDir(dirPath, skills) {
20940
- const entries = readdirSync13(dirPath);
21117
+ const entries = readdirSync14(dirPath);
20941
21118
  for (const entry of entries) {
20942
- const fullPath = join31(dirPath, entry);
21119
+ const fullPath = join32(dirPath, entry);
20943
21120
  const stat = statSync7(fullPath);
20944
21121
  if (stat.isDirectory()) {
20945
21122
  this.scanDir(fullPath, skills);
@@ -20947,7 +21124,7 @@ class SkillsLoader {
20947
21124
  }
20948
21125
  if (!entry.endsWith(".md") && !entry.endsWith(".skill.md"))
20949
21126
  continue;
20950
- const content = readFileSync23(fullPath, "utf-8");
21127
+ const content = readFileSync24(fullPath, "utf-8");
20951
21128
  const parsed = this.parseSkillFile(content, fullPath);
20952
21129
  if (parsed)
20953
21130
  skills.push(parsed);
@@ -21584,7 +21761,7 @@ var init_check_tool = __esm(() => {
21584
21761
  });
21585
21762
 
21586
21763
  // src/modules/lsp/module.ts
21587
- import { existsSync as existsSync39 } from "fs";
21764
+ import { existsSync as existsSync40 } from "fs";
21588
21765
  import { relative as relative4, resolve as resolve22 } from "path";
21589
21766
 
21590
21767
  class LspModule {
@@ -21639,7 +21816,7 @@ class LspModule {
21639
21816
  if (!filePath)
21640
21817
  return;
21641
21818
  const fullPath = resolve22(_ctx.baseDir, filePath);
21642
- if (!existsSync39(fullPath))
21819
+ if (!existsSync40(fullPath))
21643
21820
  return;
21644
21821
  const serverConfig = getServerForFile(fullPath, self.config);
21645
21822
  if (!serverConfig)
@@ -21731,7 +21908,7 @@ ${items}`;
21731
21908
  })
21732
21909
  };
21733
21910
  }
21734
- if (!existsSync39(resolved)) {
21911
+ if (!existsSync40(resolved)) {
21735
21912
  return { success: false, output: t("lsp.check_notfound", { path }) };
21736
21913
  }
21737
21914
  const files = await collectCheckFiles(resolved, this.config);
@@ -21831,8 +22008,8 @@ var init_lsp = __esm(() => {
21831
22008
  });
21832
22009
 
21833
22010
  // src/modules/lsp/startup-check.ts
21834
- import { existsSync as existsSync40 } from "fs";
21835
- import { join as join32 } from "path";
22011
+ import { existsSync as existsSync41 } from "fs";
22012
+ import { join as join33 } from "path";
21836
22013
  import { spawn as spawn8 } from "child_process";
21837
22014
  async function runStartupHealthCheck(config, baseDir, deps = {}) {
21838
22015
  if (!config.enabled)
@@ -21859,7 +22036,7 @@ ${result.lines.join(`
21859
22036
  }
21860
22037
  async function runCheck(config, baseDir, deps) {
21861
22038
  const projectRoot = findProjectRoot(baseDir, baseDir, ["tsconfig.json", "package.json"]);
21862
- if (existsSync40(join32(projectRoot, "tsconfig.json"))) {
22039
+ if (existsSync41(join33(projectRoot, "tsconfig.json"))) {
21863
22040
  const runTsc = deps.runTsc ?? runTscDefault;
21864
22041
  const errors = await runTsc(projectRoot, STARTUP_CHECK_TIMEOUT_MS);
21865
22042
  if (errors.length === 0)
@@ -21959,8 +22136,8 @@ var init_startup_check = __esm(() => {
21959
22136
  });
21960
22137
 
21961
22138
  // src/modules/indexer/walker.ts
21962
- import { readdirSync as readdirSync14, readFileSync as readFileSync24, statSync as statSync8, existsSync as existsSync41, watch } from "fs";
21963
- import { join as join33, relative as relative5, extname as extname5 } from "path";
22139
+ import { readdirSync as readdirSync15, readFileSync as readFileSync25, statSync as statSync8, existsSync as existsSync42, watch } from "fs";
22140
+ import { join as join34, relative as relative5, extname as extname5 } from "path";
21964
22141
 
21965
22142
  class Indexer {
21966
22143
  baseDir;
@@ -21987,18 +22164,18 @@ class Indexer {
21987
22164
  let totalSize = 0;
21988
22165
  let count = 0;
21989
22166
  const walkDir2 = (dir) => {
21990
- if (!existsSync41(dir))
22167
+ if (!existsSync42(dir))
21991
22168
  return;
21992
22169
  let entries;
21993
22170
  try {
21994
- entries = readdirSync14(dir);
22171
+ entries = readdirSync15(dir);
21995
22172
  } catch {
21996
22173
  return;
21997
22174
  }
21998
22175
  for (const entry of entries) {
21999
22176
  if (count >= this.MAX_FILES)
22000
22177
  return;
22001
- const fullPath = join33(dir, entry);
22178
+ const fullPath = join34(dir, entry);
22002
22179
  const relPath = relative5(this.baseDir, fullPath);
22003
22180
  const stat2 = statSync8(fullPath);
22004
22181
  if (stat2.isDirectory()) {
@@ -22009,7 +22186,7 @@ class Indexer {
22009
22186
  const ext = extname5(entry).toLowerCase();
22010
22187
  const language = LANGUAGES[ext];
22011
22188
  if (language) {
22012
- const content = readFileSync24(fullPath, "utf-8");
22189
+ const content = readFileSync25(fullPath, "utf-8");
22013
22190
  const exports = this.extractExports(content, language);
22014
22191
  files.push({ path: relPath, language, exports, size: stat2.size });
22015
22192
  totalSize += stat2.size;
@@ -22061,22 +22238,22 @@ var init_walker = __esm(() => {
22061
22238
  });
22062
22239
 
22063
22240
  // src/modules/indexer/cache.ts
22064
- import { readFileSync as readFileSync25, writeFileSync as writeFileSync14, existsSync as existsSync42, mkdirSync as mkdirSync17, rmSync as rmSync3 } from "fs";
22065
- import { join as join34 } from "path";
22241
+ import { readFileSync as readFileSync26, writeFileSync as writeFileSync15, existsSync as existsSync43, mkdirSync as mkdirSync18, rmSync as rmSync3 } from "fs";
22242
+ import { join as join35 } from "path";
22066
22243
 
22067
22244
  class IndexCache {
22068
22245
  cachePath;
22069
22246
  cache = null;
22070
22247
  constructor(cacheDir) {
22071
- this.cachePath = join34(cacheDir, "index-cache.json");
22248
+ this.cachePath = join35(cacheDir, "index-cache.json");
22072
22249
  }
22073
22250
  load() {
22074
22251
  if (this.cache)
22075
22252
  return this.cache;
22076
- if (!existsSync42(this.cachePath))
22253
+ if (!existsSync43(this.cachePath))
22077
22254
  return null;
22078
22255
  try {
22079
- this.cache = JSON.parse(readFileSync25(this.cachePath, "utf-8"));
22256
+ this.cache = JSON.parse(readFileSync26(this.cachePath, "utf-8"));
22080
22257
  return this.cache;
22081
22258
  } catch {
22082
22259
  return null;
@@ -22084,14 +22261,14 @@ class IndexCache {
22084
22261
  }
22085
22262
  save(result) {
22086
22263
  this.cache = result;
22087
- const dir = join34(this.cachePath, "..");
22088
- if (!existsSync42(dir))
22089
- mkdirSync17(dir, { recursive: true });
22090
- writeFileSync14(this.cachePath, JSON.stringify(result), "utf-8");
22264
+ const dir = join35(this.cachePath, "..");
22265
+ if (!existsSync43(dir))
22266
+ mkdirSync18(dir, { recursive: true });
22267
+ writeFileSync15(this.cachePath, JSON.stringify(result), "utf-8");
22091
22268
  }
22092
22269
  invalidate() {
22093
22270
  this.cache = null;
22094
- if (existsSync42(this.cachePath)) {
22271
+ if (existsSync43(this.cachePath)) {
22095
22272
  try {
22096
22273
  rmSync3(this.cachePath);
22097
22274
  } catch {}
@@ -22101,11 +22278,11 @@ class IndexCache {
22101
22278
  var init_cache = () => {};
22102
22279
 
22103
22280
  // src/modules/indexer/project-profile.ts
22104
- import { readFileSync as readFileSync26, existsSync as existsSync43 } from "fs";
22105
- import { join as join35 } from "path";
22281
+ import { readFileSync as readFileSync27, existsSync as existsSync44 } from "fs";
22282
+ import { join as join36 } from "path";
22106
22283
  function detectManifest(baseDir) {
22107
22284
  for (const manifest of MANIFEST_ORDER) {
22108
- if (existsSync43(join35(baseDir, manifest)))
22285
+ if (existsSync44(join36(baseDir, manifest)))
22109
22286
  return manifest;
22110
22287
  }
22111
22288
  return null;
@@ -22122,7 +22299,7 @@ function cleanDependency(entry) {
22122
22299
  }
22123
22300
  function readPackageJson(baseDir) {
22124
22301
  try {
22125
- const raw = JSON.parse(readFileSync26(join35(baseDir, "package.json"), "utf-8"));
22302
+ const raw = JSON.parse(readFileSync27(join36(baseDir, "package.json"), "utf-8"));
22126
22303
  if (!raw || typeof raw !== "object")
22127
22304
  return null;
22128
22305
  const profile = {
@@ -22146,7 +22323,7 @@ function readPackageJson(baseDir) {
22146
22323
  }
22147
22324
  function readPyproject(baseDir) {
22148
22325
  try {
22149
- const content = readFileSync26(join35(baseDir, "pyproject.toml"), "utf-8");
22326
+ const content = readFileSync27(join36(baseDir, "pyproject.toml"), "utf-8");
22150
22327
  const profile = { runtime: "python", deps: [], devDeps: [], scripts: {} };
22151
22328
  const nameMatch = content.match(/^\s*name\s*=\s*"([^"]+)"/m);
22152
22329
  if (nameMatch)
@@ -22162,7 +22339,7 @@ function readPyproject(baseDir) {
22162
22339
  }
22163
22340
  function readCargo(baseDir) {
22164
22341
  try {
22165
- const content = readFileSync26(join35(baseDir, "Cargo.toml"), "utf-8");
22342
+ const content = readFileSync27(join36(baseDir, "Cargo.toml"), "utf-8");
22166
22343
  const profile = { runtime: "rust", deps: [], devDeps: [], scripts: {} };
22167
22344
  const nameMatch = content.match(/^\s*name\s*=\s*"([^"]+)"/m);
22168
22345
  if (nameMatch)
@@ -22186,7 +22363,7 @@ function readCargo(baseDir) {
22186
22363
  }
22187
22364
  function readGoMod(baseDir) {
22188
22365
  try {
22189
- const content = readFileSync26(join35(baseDir, "go.mod"), "utf-8");
22366
+ const content = readFileSync27(join36(baseDir, "go.mod"), "utf-8");
22190
22367
  const profile = { runtime: "go", deps: [], devDeps: [], scripts: {} };
22191
22368
  const moduleMatch = content.match(/^module\s+(\S+)/m);
22192
22369
  if (moduleMatch)
@@ -22204,7 +22381,7 @@ function readGoMod(baseDir) {
22204
22381
  }
22205
22382
  function readRequirements(baseDir) {
22206
22383
  try {
22207
- const content = readFileSync26(join35(baseDir, "requirements.txt"), "utf-8");
22384
+ const content = readFileSync27(join36(baseDir, "requirements.txt"), "utf-8");
22208
22385
  const profile = { runtime: "python", deps: [], devDeps: [], scripts: {} };
22209
22386
  for (const line of content.split(`
22210
22387
  `)) {
@@ -22662,8 +22839,8 @@ var init_mcp = __esm(() => {
22662
22839
  });
22663
22840
 
22664
22841
  // src/modules/memory/module.ts
22665
- import { homedir as homedir10 } from "os";
22666
- import { join as join36 } from "path";
22842
+ import { homedir as homedir11 } from "os";
22843
+ import { join as join37 } from "path";
22667
22844
 
22668
22845
  class MemoryModule {
22669
22846
  name = "memory";
@@ -22672,7 +22849,7 @@ class MemoryModule {
22672
22849
  if (storeOrDir instanceof MemoryStore) {
22673
22850
  this.store = storeOrDir;
22674
22851
  } else {
22675
- const dir = storeOrDir || join36(homedir10(), ".mma", "memory");
22852
+ const dir = storeOrDir || join37(homedir11(), ".mma", "memory");
22676
22853
  this.store = new MemoryStore(dir);
22677
22854
  }
22678
22855
  }
@@ -22758,16 +22935,16 @@ var init_module8 = __esm(() => {
22758
22935
  });
22759
22936
 
22760
22937
  // src/core/version.ts
22761
- import { existsSync as existsSync44, readFileSync as readFileSync27 } from "fs";
22762
- import { join as join37, dirname as dirname13 } from "path";
22938
+ import { existsSync as existsSync45, readFileSync as readFileSync28 } from "fs";
22939
+ import { join as join38, dirname as dirname13 } from "path";
22763
22940
  import { fileURLToPath as fileURLToPath2 } from "url";
22764
22941
  function readMmaVersion() {
22765
22942
  const here = dirname13(fileURLToPath2(import.meta.url));
22766
- const candidates = [join37(here, "..", "..", "package.json"), join37(here, "..", "package.json")];
22943
+ const candidates = [join38(here, "..", "..", "package.json"), join38(here, "..", "package.json")];
22767
22944
  for (const p of candidates) {
22768
- if (existsSync44(p)) {
22945
+ if (existsSync45(p)) {
22769
22946
  try {
22770
- const raw = JSON.parse(readFileSync27(p, "utf8"));
22947
+ const raw = JSON.parse(readFileSync28(p, "utf8"));
22771
22948
  if (raw.version)
22772
22949
  return raw.version;
22773
22950
  } catch {}
@@ -22778,21 +22955,21 @@ function readMmaVersion() {
22778
22955
  var init_version = () => {};
22779
22956
 
22780
22957
  // src/core/environment.ts
22781
- import { existsSync as existsSync45, readFileSync as readFileSync28, readdirSync as readdirSync15 } from "fs";
22958
+ import { existsSync as existsSync46, readFileSync as readFileSync29, readdirSync as readdirSync16 } from "fs";
22782
22959
  import { spawnSync as spawnSync2 } from "child_process";
22783
22960
  import { createRequire as createRequire2 } from "module";
22784
- import { join as join38, dirname as dirname14 } from "path";
22961
+ import { join as join39, dirname as dirname14 } from "path";
22785
22962
  import { fileURLToPath as fileURLToPath3 } from "url";
22786
- import { arch, homedir as homedir11, hostname as hostname2, platform as platform9, release } from "os";
22963
+ import { arch, homedir as homedir12, hostname as hostname2, platform as platform9, release } from "os";
22787
22964
  import { env as env2 } from "process";
22788
22965
  function readEngineRequirement() {
22789
22966
  const here = dirname14(fileURLToPath3(import.meta.url));
22790
- const candidates = [join38(here, "..", "..", "package.json"), join38(here, "..", "package.json")];
22967
+ const candidates = [join39(here, "..", "..", "package.json"), join39(here, "..", "package.json")];
22791
22968
  for (const p of candidates) {
22792
- if (!existsSync45(p))
22969
+ if (!existsSync46(p))
22793
22970
  continue;
22794
22971
  try {
22795
- const raw = JSON.parse(readFileSync28(p, "utf8"));
22972
+ const raw = JSON.parse(readFileSync29(p, "utf8"));
22796
22973
  if (raw.engines?.node)
22797
22974
  return String(raw.engines.node);
22798
22975
  } catch {}
@@ -22855,7 +23032,7 @@ function toolVersion(cmd) {
22855
23032
  function playwrightBrowsersDir() {
22856
23033
  if (process.env.PLAYWRIGHT_BROWSERS_PATH)
22857
23034
  return process.env.PLAYWRIGHT_BROWSERS_PATH;
22858
- return process.platform === "win32" ? join38(homedir11(), "AppData", "Local", "ms-playwright") : join38(homedir11(), ".cache", "ms-playwright");
23035
+ return process.platform === "win32" ? join39(homedir12(), "AppData", "Local", "ms-playwright") : join39(homedir12(), ".cache", "ms-playwright");
22859
23036
  }
22860
23037
  function playwrightInfo() {
22861
23038
  let installed = false;
@@ -22864,15 +23041,15 @@ function playwrightInfo() {
22864
23041
  try {
22865
23042
  const require2 = createRequire2(import.meta.url);
22866
23043
  const pkgPath = require2.resolve("playwright/package.json");
22867
- installed = existsSync45(pkgPath);
22868
- version = JSON.parse(readFileSync28(pkgPath, "utf8")).version || "";
23044
+ installed = existsSync46(pkgPath);
23045
+ version = JSON.parse(readFileSync29(pkgPath, "utf8")).version || "";
22869
23046
  } catch {
22870
23047
  installed = false;
22871
23048
  }
22872
23049
  let browsersInstalled = false;
22873
23050
  try {
22874
- if (existsSync45(browsersDir)) {
22875
- browsersInstalled = readdirSync15(browsersDir).some((d) => /chrom/i.test(d));
23051
+ if (existsSync46(browsersDir)) {
23052
+ browsersInstalled = readdirSync16(browsersDir).some((d) => /chrom/i.test(d));
22876
23053
  }
22877
23054
  } catch {
22878
23055
  browsersInstalled = false;
@@ -22934,7 +23111,7 @@ function collectEnvironment(opts) {
22934
23111
  release: release(),
22935
23112
  hostname: hostname2(),
22936
23113
  shell: env2.SHELL || env2.ComSpec || "unknown",
22937
- home: homedir11(),
23114
+ home: homedir12(),
22938
23115
  cwd: process.cwd()
22939
23116
  },
22940
23117
  paths: { configDir: opts.configDir, baseDir: opts.baseDir || process.cwd() },
@@ -22965,9 +23142,9 @@ __export(exports_bootstrap, {
22965
23142
  buildSystemInfo: () => buildSystemInfo,
22966
23143
  bootstrap: () => bootstrap
22967
23144
  });
22968
- import { homedir as homedir12 } from "os";
22969
- import { join as join39, resolve as resolve23 } from "path";
22970
- import { existsSync as existsSync46, readFileSync as readFileSync29, writeFileSync as writeFileSync15 } from "fs";
23145
+ import { homedir as homedir13 } from "os";
23146
+ import { join as join40, resolve as resolve23 } from "path";
23147
+ import { existsSync as existsSync47, readFileSync as readFileSync30, writeFileSync as writeFileSync16 } from "fs";
22971
23148
  function buildSystemInfo(config, baseDir, profileCompressed) {
22972
23149
  const now = new Date().toISOString().replace("T", " ").slice(0, 19);
22973
23150
  const isWin = profileCompressed.toLowerCase().includes("win32");
@@ -23020,9 +23197,9 @@ function buildSystemInfo(config, baseDir, profileCompressed) {
23020
23197
  `);
23021
23198
  }
23022
23199
  async function bootstrap(configDir, projectDir, noAgentsMd, exitOnComplete) {
23023
- const dir = configDir || join39(homedir12(), ".mma");
23024
- const projectConfigPath = projectDir ? join39(projectDir, ".mmrc") : join39(process.cwd(), ".mmrc");
23025
- const config = loadConfig({ configDir: dir, projectConfigPath });
23200
+ const dir = configDir || join40(homedir13(), ".mma");
23201
+ const projectConfigPath = projectDir ? join40(projectDir, ".mmrc") : join40(process.cwd(), ".mmrc");
23202
+ const { config, legacyDetected } = loadConfig({ configDir: dir, projectConfigPath });
23026
23203
  setLocale(config.locale);
23027
23204
  try {
23028
23205
  const { globalAuditNotifier: globalAuditNotifier2 } = await Promise.resolve().then(() => (init_audit_notifier(), exports_audit_notifier));
@@ -23031,7 +23208,7 @@ async function bootstrap(configDir, projectDir, noAgentsMd, exitOnComplete) {
23031
23208
  }
23032
23209
  } catch {}
23033
23210
  const logger = new Logger(config.logLevel);
23034
- logger.setLogDir(join39(dir, "logs"));
23211
+ logger.setLogDir(join40(dir, "logs"));
23035
23212
  logger.debug("MMA bootstrap", {
23036
23213
  version: config.version,
23037
23214
  model: config.model
@@ -23053,7 +23230,7 @@ async function bootstrap(configDir, projectDir, noAgentsMd, exitOnComplete) {
23053
23230
  logger.info(`Model ${config.model} loaded in ${loadResult.loadTime}s`);
23054
23231
  }
23055
23232
  }
23056
- const profile = new UserProfile(join39(dir));
23233
+ const profile = new UserProfile(join40(dir));
23057
23234
  profile.load() || profile.collect();
23058
23235
  profile.save();
23059
23236
  const providerManager = new ProviderManager(config.provider, {
@@ -23079,7 +23256,7 @@ async function bootstrap(configDir, projectDir, noAgentsMd, exitOnComplete) {
23079
23256
  for (const warning of envReport.warnings) {
23080
23257
  logger.warn(warning);
23081
23258
  }
23082
- const projectMapCacheDir = join39(baseDir, ".mma");
23259
+ const projectMapCacheDir = join40(baseDir, ".mma");
23083
23260
  const indexerModule = new IndexerModule({
23084
23261
  baseDir,
23085
23262
  cacheDir: projectMapCacheDir
@@ -23090,9 +23267,9 @@ async function bootstrap(configDir, projectDir, noAgentsMd, exitOnComplete) {
23090
23267
  logger.warn(`Project indexing failed: ${err.message}`);
23091
23268
  }
23092
23269
  const skillsLoader = new SkillsLoader;
23093
- const builtinDir = join39(import.meta.dirname, "skills", "builtin");
23094
- const globalDir = join39(homedir12(), ".agents", "skills");
23095
- const projectSkillsDir = join39(baseDir, ".mma", "skills");
23270
+ const builtinDir = join40(import.meta.dirname, "skills", "builtin");
23271
+ const globalDir = join40(homedir13(), ".agents", "skills");
23272
+ const projectSkillsDir = join40(baseDir, ".mma", "skills");
23096
23273
  const availableSkills = skillsLoader.loadFromAllSources(builtinDir, globalDir, projectSkillsDir);
23097
23274
  const skillsBudget = Math.floor(config.contextWindow * config.skills.budget);
23098
23275
  const skillsModule = new SkillsModule(availableSkills, skillsBudget);
@@ -23108,11 +23285,11 @@ async function bootstrap(configDir, projectDir, noAgentsMd, exitOnComplete) {
23108
23285
  essential: true,
23109
23286
  estimatedTokens: Math.ceil(systemInfoContent.length / 4)
23110
23287
  };
23111
- const agentsMdGlobal = join39(dir, "AGENTS.md");
23112
- if (!existsSync46(agentsMdGlobal)) {
23113
- writeFileSync15(agentsMdGlobal, "", "utf-8");
23288
+ const agentsMdGlobal = join40(dir, "AGENTS.md");
23289
+ if (!existsSync47(agentsMdGlobal)) {
23290
+ writeFileSync16(agentsMdGlobal, "", "utf-8");
23114
23291
  }
23115
- const sessionDir = join39(dir, "sessions");
23292
+ const sessionDir = join40(dir, "sessions");
23116
23293
  const sessionStore = new SessionStore(sessionDir);
23117
23294
  sessionStore.init();
23118
23295
  const sessionManager = new SessionManager(sessionStore, {
@@ -23177,10 +23354,7 @@ async function bootstrap(configDir, projectDir, noAgentsMd, exitOnComplete) {
23177
23354
  const hallucinationDetector = new HallucinationDetector(baseDir, llmProvider);
23178
23355
  const moduleRegistry = new ModuleRegistry;
23179
23356
  const execModule = new ExecutionModule(baseDir, config.stuckThreshold, config.errorWebSearch?.threshold ?? 5);
23180
- const activeMeta = sessionManager.getActiveMeta();
23181
- if (activeMeta && activeMeta.messageCount > 0) {
23182
- execModule.restorePlan();
23183
- }
23357
+ execModule.restorePlan();
23184
23358
  moduleRegistry.register(execModule);
23185
23359
  execModule.setHallucinationDetector(hallucinationDetector);
23186
23360
  const sessionModule = new SessionModule(sessionManager);
@@ -23189,7 +23363,7 @@ async function bootstrap(configDir, projectDir, noAgentsMd, exitOnComplete) {
23189
23363
  const mcpModule = new MCPModule(config);
23190
23364
  await mcpModule.initialize();
23191
23365
  moduleRegistry.register(mcpModule);
23192
- const memoryStore = new MemoryStore(join39(dir, "memory"));
23366
+ const memoryStore = new MemoryStore(join40(dir, "memory"));
23193
23367
  const memoryModule = new MemoryModule(memoryStore);
23194
23368
  moduleRegistry.register(memoryModule);
23195
23369
  if (config.browser.enabled) {
@@ -23243,8 +23417,8 @@ async function bootstrap(configDir, projectDir, noAgentsMd, exitOnComplete) {
23243
23417
  pluginManager.register(plugin);
23244
23418
  pluginManager.register(plugin2);
23245
23419
  const pluginLoader = new PluginLoader;
23246
- const globalPluginsDir = join39(homedir12(), ".mma", "plugins");
23247
- const projectPluginsDir = join39(baseDir, ".mma", "plugins");
23420
+ const globalPluginsDir = join40(homedir13(), ".mma", "plugins");
23421
+ const projectPluginsDir = join40(baseDir, ".mma", "plugins");
23248
23422
  const mmaVersion = readMmaVersion();
23249
23423
  pluginLoader.loadFromDir(globalPluginsDir, pluginManager, logger, {
23250
23424
  source: "global",
@@ -23270,13 +23444,13 @@ async function bootstrap(configDir, projectDir, noAgentsMd, exitOnComplete) {
23270
23444
  const skipAgentsMd = noAgentsMd === true;
23271
23445
  if (!skipAgentsMd) {
23272
23446
  const agentsMdCandidates = [
23273
- join39(baseDir, "AGENTS.md"),
23274
- join39(baseDir, ".mma", "AGENTS.md"),
23275
- join39(dir, "AGENTS.md")
23447
+ join40(baseDir, "AGENTS.md"),
23448
+ join40(baseDir, ".mma", "AGENTS.md"),
23449
+ join40(dir, "AGENTS.md")
23276
23450
  ];
23277
23451
  for (const p of agentsMdCandidates) {
23278
- if (existsSync46(p)) {
23279
- const content = readFileSync29(p, "utf-8").trim();
23452
+ if (existsSync47(p)) {
23453
+ const content = readFileSync30(p, "utf-8").trim();
23280
23454
  if (content) {
23281
23455
  agentsMdBlocks.push({
23282
23456
  content,
@@ -23352,7 +23526,8 @@ async function bootstrap(configDir, projectDir, noAgentsMd, exitOnComplete) {
23352
23526
  configDir: dir,
23353
23527
  baseDir,
23354
23528
  noAgentsMd: skipAgentsMd,
23355
- envReport
23529
+ envReport,
23530
+ legacyDetected
23356
23531
  };
23357
23532
  }
23358
23533
  var init_bootstrap = __esm(() => {
@@ -24080,8 +24255,16 @@ async function runSetup(externalRl) {
24080
24255
  securityFlagsBlock = (await ask(rl, t("setup.security_flags_block"), "n")).toLowerCase() === "y";
24081
24256
  securityPathsDeny = (await ask(rl, t("setup.security_paths_deny"), "Y")).toLowerCase() !== "n";
24082
24257
  }
24083
- if (ownRl)
24258
+ if (ownRl) {
24084
24259
  rl.close();
24260
+ process.stdin.removeAllListeners("data");
24261
+ process.stdin.removeAllListeners("keypress");
24262
+ if (typeof process.stdin.setRawMode === "function") {
24263
+ process.stdin.setRawMode(false);
24264
+ }
24265
+ process.stdin.pause();
24266
+ process.stdin.resume();
24267
+ }
24085
24268
  const answers = {
24086
24269
  provider,
24087
24270
  apiBase,
@@ -24141,21 +24324,21 @@ __export(exports_manifest, {
24141
24324
  getCertMark: () => getCertMark,
24142
24325
  MANIFEST_PATH: () => MANIFEST_PATH
24143
24326
  });
24144
- import { existsSync as existsSync47, readFileSync as readFileSync30, mkdirSync as mkdirSync18, writeFileSync as writeFileSync16 } from "fs";
24145
- import { homedir as homedir14 } from "os";
24146
- import { join as join41 } from "path";
24327
+ import { existsSync as existsSync48, readFileSync as readFileSync31, mkdirSync as mkdirSync19, writeFileSync as writeFileSync17 } from "fs";
24328
+ import { homedir as homedir15 } from "os";
24329
+ import { join as join42 } from "path";
24147
24330
  function readManifest(path = MANIFEST_PATH) {
24148
24331
  try {
24149
- if (existsSync47(path)) {
24150
- const raw = JSON.parse(readFileSync30(path, "utf-8"));
24332
+ if (existsSync48(path)) {
24333
+ const raw = JSON.parse(readFileSync31(path, "utf-8"));
24151
24334
  return { version: 1, certifications: raw.certifications ?? [] };
24152
24335
  }
24153
24336
  } catch {}
24154
24337
  return { version: 1, certifications: [] };
24155
24338
  }
24156
24339
  function saveManifest(m, path = MANIFEST_PATH) {
24157
- mkdirSync18(join41(homedir14(), ".mma"), { recursive: true });
24158
- writeFileSync16(path, JSON.stringify(m, null, 2), "utf-8");
24340
+ mkdirSync19(join42(homedir15(), ".mma"), { recursive: true });
24341
+ writeFileSync17(path, JSON.stringify(m, null, 2), "utf-8");
24159
24342
  }
24160
24343
  function upsertCertification(entry, path = MANIFEST_PATH) {
24161
24344
  const m = readManifest(path);
@@ -24189,7 +24372,7 @@ function getCertMark(model, providerUrl, currentVersion, path = MANIFEST_PATH) {
24189
24372
  }
24190
24373
  var MANIFEST_PATH;
24191
24374
  var init_manifest = __esm(() => {
24192
- MANIFEST_PATH = join41(homedir14(), ".mma", "certifications.json");
24375
+ MANIFEST_PATH = join42(homedir15(), ".mma", "certifications.json");
24193
24376
  });
24194
24377
 
24195
24378
  // node_modules/yaml/dist/nodes/identity.js
@@ -31312,8 +31495,8 @@ var init_scenarios = __esm(() => {
31312
31495
  });
31313
31496
 
31314
31497
  // src/modules/certification/loader.ts
31315
- import { existsSync as existsSync48, readdirSync as readdirSync16, readFileSync as readFileSync31 } from "fs";
31316
- import { join as join42 } from "path";
31498
+ import { existsSync as existsSync49, readdirSync as readdirSync17, readFileSync as readFileSync32 } from "fs";
31499
+ import { join as join43 } from "path";
31317
31500
  function validateScenario(s) {
31318
31501
  const errors2 = [];
31319
31502
  const isSkip = s.mode === "skip";
@@ -31362,12 +31545,12 @@ function loadScenarios(userDir) {
31362
31545
  else
31363
31546
  scenarios.push(s);
31364
31547
  }
31365
- if (userDir && existsSync48(userDir)) {
31366
- for (const file of readdirSync16(userDir)) {
31548
+ if (userDir && existsSync49(userDir)) {
31549
+ for (const file of readdirSync17(userDir)) {
31367
31550
  if (!file.endsWith(".yaml") && !file.endsWith(".yml"))
31368
31551
  continue;
31369
31552
  try {
31370
- const raw = readFileSync31(join42(userDir, file), "utf-8");
31553
+ const raw = readFileSync32(join43(userDir, file), "utf-8");
31371
31554
  const data = $parse(raw);
31372
31555
  const parsed = normalizeScenario(data, file);
31373
31556
  const errs = validateScenario(parsed);
@@ -31420,8 +31603,8 @@ var init_loader3 = __esm(() => {
31420
31603
  });
31421
31604
 
31422
31605
  // src/modules/certification/fact-checker.ts
31423
- import { existsSync as existsSync49, readFileSync as readFileSync32, statSync as statSync9 } from "fs";
31424
- import { join as join43 } from "path";
31606
+ import { existsSync as existsSync50, readFileSync as readFileSync33, statSync as statSync9 } from "fs";
31607
+ import { join as join44 } from "path";
31425
31608
  function checkSandbox(sandboxDir, checks, exitCode, output) {
31426
31609
  const failures = [];
31427
31610
  for (const check of checks) {
@@ -31438,16 +31621,16 @@ function runCheck2(sandboxDir, check, exitCode, output) {
31438
31621
  case "outputContains":
31439
31622
  return output.includes(check.text);
31440
31623
  case "fileExists":
31441
- return isFile(join43(sandboxDir, check.path));
31624
+ return isFile(join44(sandboxDir, check.path));
31442
31625
  case "fileNotExists":
31443
- return !existsSync49(join43(sandboxDir, check.path));
31626
+ return !existsSync50(join44(sandboxDir, check.path));
31444
31627
  case "dirExists":
31445
- return isDir(join43(sandboxDir, check.path));
31628
+ return isDir(join44(sandboxDir, check.path));
31446
31629
  case "fileContent": {
31447
- const abs = join43(sandboxDir, check.path);
31630
+ const abs = join44(sandboxDir, check.path);
31448
31631
  if (!isFile(abs))
31449
31632
  return false;
31450
- const content = readFileSync32(abs, "utf-8");
31633
+ const content = readFileSync33(abs, "utf-8");
31451
31634
  if (check.contains !== undefined)
31452
31635
  return content.includes(check.contains);
31453
31636
  if (check.equals !== undefined)
@@ -31455,10 +31638,10 @@ function runCheck2(sandboxDir, check, exitCode, output) {
31455
31638
  return false;
31456
31639
  }
31457
31640
  case "fileRegex": {
31458
- const abs = join43(sandboxDir, check.path);
31641
+ const abs = join44(sandboxDir, check.path);
31459
31642
  if (!isFile(abs))
31460
31643
  return false;
31461
- return new RegExp(check.pattern).test(readFileSync32(abs, "utf-8"));
31644
+ return new RegExp(check.pattern).test(readFileSync33(abs, "utf-8"));
31462
31645
  }
31463
31646
  default:
31464
31647
  return false;
@@ -31466,14 +31649,14 @@ function runCheck2(sandboxDir, check, exitCode, output) {
31466
31649
  }
31467
31650
  function isFile(p) {
31468
31651
  try {
31469
- return existsSync49(p) && statSync9(p).isFile();
31652
+ return existsSync50(p) && statSync9(p).isFile();
31470
31653
  } catch {
31471
31654
  return false;
31472
31655
  }
31473
31656
  }
31474
31657
  function isDir(p) {
31475
31658
  try {
31476
- return existsSync49(p) && statSync9(p).isDirectory();
31659
+ return existsSync50(p) && statSync9(p).isDirectory();
31477
31660
  } catch {
31478
31661
  return false;
31479
31662
  }
@@ -31504,9 +31687,9 @@ var init_fact_checker = () => {};
31504
31687
 
31505
31688
  // src/modules/certification/runner.ts
31506
31689
  import { spawn as spawn9 } from "child_process";
31507
- import { existsSync as existsSync50, mkdirSync as mkdirSync19, rmSync as rmSync4, cpSync as cpSync2 } from "fs";
31690
+ import { existsSync as existsSync51, mkdirSync as mkdirSync20, rmSync as rmSync4, cpSync as cpSync2 } from "fs";
31508
31691
  import { platform as platform10 } from "os";
31509
- import { join as join44, resolve as resolve24, dirname as dirname15 } from "path";
31692
+ import { join as join45, resolve as resolve24, dirname as dirname16 } from "path";
31510
31693
  async function runScenario(scenario, opts) {
31511
31694
  if (scenario.mode === "skip") {
31512
31695
  return {
@@ -31525,7 +31708,7 @@ async function runScenario(scenario, opts) {
31525
31708
  let passed = 0;
31526
31709
  let firstError;
31527
31710
  for (let i = 1;i <= reps; i++) {
31528
- const sandbox = join44(opts.sandboxBase, `run-${scenario.id}-${i}`);
31711
+ const sandbox = join45(opts.sandboxBase, `run-${scenario.id}-${i}`);
31529
31712
  let failures = [];
31530
31713
  let exitCode = -1;
31531
31714
  let output = "";
@@ -31584,27 +31767,27 @@ ${res.stderr}`;
31584
31767
  }
31585
31768
  function prepareSandbox(sandbox, scenario, mmaRoot) {
31586
31769
  rmSync4(sandbox, { recursive: true, force: true });
31587
- mkdirSync19(sandbox, { recursive: true });
31770
+ mkdirSync20(sandbox, { recursive: true });
31588
31771
  for (const f of scenario.fixtures ?? []) {
31589
- const src = join44(mmaRoot, f.source);
31590
- if (!existsSync50(src)) {
31772
+ const src = join45(mmaRoot, f.source);
31773
+ if (!existsSync51(src)) {
31591
31774
  throw new Error(`fixture missing: ${f.source}`);
31592
31775
  }
31593
- const dest = join44(sandbox, f.dest);
31594
- mkdirSync19(dirname15(dest), { recursive: true });
31776
+ const dest = join45(sandbox, f.dest);
31777
+ mkdirSync20(dirname16(dest), { recursive: true });
31595
31778
  cpSync2(src, dest);
31596
31779
  }
31597
31780
  }
31598
31781
  function resolveMmaEntry(mmaRoot) {
31599
- const dev = join44(mmaRoot, "src", "cli", "main.ts");
31600
- if (existsSync50(dev))
31782
+ const dev = join45(mmaRoot, "src", "cli", "main.ts");
31783
+ if (existsSync51(dev))
31601
31784
  return dev;
31602
- return join44(mmaRoot, "dist", "main.js");
31785
+ return join45(mmaRoot, "dist", "main.js");
31603
31786
  }
31604
31787
  function findMmaRoot(fromDir) {
31605
31788
  const candidates = [resolve24(fromDir, "..", "..", ".."), resolve24(fromDir, "..")];
31606
31789
  for (const c of candidates) {
31607
- if (existsSync50(join44(c, "package.json")))
31790
+ if (existsSync51(join45(c, "package.json")))
31608
31791
  return c;
31609
31792
  }
31610
31793
  return process.cwd();
@@ -31671,16 +31854,16 @@ __export(exports_cli, {
31671
31854
  certList: () => certList
31672
31855
  });
31673
31856
  import { rmSync as rmSync5 } from "fs";
31674
- import { homedir as homedir15 } from "os";
31675
- import { join as join45, dirname as dirname16 } from "path";
31857
+ import { homedir as homedir16 } from "os";
31858
+ import { join as join46, dirname as dirname17 } from "path";
31676
31859
  import { fileURLToPath as fileURLToPath4 } from "url";
31677
- import { existsSync as existsSync51, readFileSync as readFileSync33 } from "fs";
31860
+ import { existsSync as existsSync52, readFileSync as readFileSync34 } from "fs";
31678
31861
  function readVersion() {
31679
- const candidates = [join45(MMA_ROOT, "package.json")];
31862
+ const candidates = [join46(MMA_ROOT, "package.json")];
31680
31863
  for (const p of candidates) {
31681
- if (existsSync51(p)) {
31864
+ if (existsSync52(p)) {
31682
31865
  try {
31683
- const raw = JSON.parse(readFileSync33(p, "utf-8"));
31866
+ const raw = JSON.parse(readFileSync34(p, "utf-8"));
31684
31867
  if (raw.version)
31685
31868
  return raw.version;
31686
31869
  } catch {}
@@ -31716,7 +31899,7 @@ async function certify(opts) {
31716
31899
  return;
31717
31900
  }
31718
31901
  console.log(t("cli.cert_started", { model: opts.name, provider: providerUrl }));
31719
- const sandboxBase = join45(process.cwd(), ".mma", "certification");
31902
+ const sandboxBase = join46(process.cwd(), ".mma", "certification");
31720
31903
  const results = [];
31721
31904
  const total = selected.length;
31722
31905
  let idx = 0;
@@ -31828,9 +32011,9 @@ var init_cli = __esm(() => {
31828
32011
  init_loader3();
31829
32012
  init_runner2();
31830
32013
  init_manifest();
31831
- HERE = dirname16(fileURLToPath4(import.meta.url));
32014
+ HERE = dirname17(fileURLToPath4(import.meta.url));
31832
32015
  MMA_ROOT = findMmaRoot(HERE);
31833
- USER_SCENARIO_DIR = join45(homedir15(), ".mma", "certification", "scenarios");
32016
+ USER_SCENARIO_DIR = join46(homedir16(), ".mma", "certification", "scenarios");
31834
32017
  });
31835
32018
 
31836
32019
  // src/cli/repl-commands.ts
@@ -31839,8 +32022,9 @@ __export(exports_repl_commands, {
31839
32022
  registerAllCommands: () => registerAllCommands,
31840
32023
  COMMAND_GROUPS: () => COMMAND_GROUPS
31841
32024
  });
31842
- import { join as join47 } from "path";
31843
- import { homedir as homedir17 } from "os";
32025
+ import { join as join48, dirname as dirname19 } from "path";
32026
+ import { homedir as homedir18 } from "os";
32027
+ import { existsSync as existsSync54 } from "fs";
31844
32028
  function registerAllCommands(ctx) {
31845
32029
  registerBuiltinCommands(ctx);
31846
32030
  registerMmaCommands(ctx);
@@ -31897,7 +32081,7 @@ function registerMmaCommands(ctx) {
31897
32081
  }
31898
32082
  try {
31899
32083
  const { loadFileAsDataUrl: loadFileAsDataUrl2, loadUrlAsDataUrl: loadUrlAsDataUrl2, readClipboardImage: readClipboardImage2 } = await Promise.resolve().then(() => (init_image_utils(), exports_image_utils));
31900
- const { existsSync: existsSync52 } = await import("fs");
32084
+ const { existsSync: existsSync55 } = await import("fs");
31901
32085
  const { resolve: resolve25 } = await import("path");
31902
32086
  let dataUrl;
31903
32087
  let label;
@@ -31917,7 +32101,7 @@ function registerMmaCommands(ctx) {
31917
32101
  label = source;
31918
32102
  } else {
31919
32103
  const absPath = resolve25(process.cwd(), source);
31920
- if (!existsSync52(absPath)) {
32104
+ if (!existsSync55(absPath)) {
31921
32105
  console.log(pc2.red(t("image.not_found", { path: source })));
31922
32106
  return;
31923
32107
  }
@@ -31970,6 +32154,31 @@ function registerMmaCommands(ctx) {
31970
32154
  }
31971
32155
  }
31972
32156
  });
32157
+ ctx.registerCommand({
32158
+ name: "config migrate",
32159
+ description: t("cli.migrate_config"),
32160
+ action: async () => {
32161
+ const { hasDomainFiles: hasDomainFiles3 } = await Promise.resolve().then(() => (init_domains(), exports_domains));
32162
+ const { loadConfig: loadCfg } = await Promise.resolve().then(() => (init_config2(), exports_config));
32163
+ const configDir = ctx.configDir;
32164
+ const configPath = join48(configDir, "config.json");
32165
+ if (hasDomainFiles3(configDir)) {
32166
+ console.log(pc2.yellow(t("config.migrate_no_legacy")));
32167
+ return;
32168
+ }
32169
+ if (!existsSync54(configPath)) {
32170
+ console.log(pc2.yellow(t("config.migrate_no_legacy")));
32171
+ return;
32172
+ }
32173
+ console.log(t("config.migrate_start"));
32174
+ const { config } = loadCfg({ configDir, projectConfigPath: join48(configDir, ".mmrc") });
32175
+ saveConfig(config, configPath, configDir);
32176
+ const { renameSync: renameSync3, readdirSync: readdirSync18 } = await import("fs");
32177
+ renameSync3(configPath, configPath + ".bak");
32178
+ const domainFiles = readdirSync18(join48(configDir, "config")).filter((f) => f.endsWith(".json"));
32179
+ console.log(pc2.green(t("config.migrate_done", { count: String(domainFiles.length) })));
32180
+ }
32181
+ });
31973
32182
  ctx.registerCommand({
31974
32183
  name: "reasoning",
31975
32184
  description: t("repl.reasoning"),
@@ -32008,7 +32217,7 @@ function registerMmaCommands(ctx) {
32008
32217
  console.log(pc2.yellow(t("repl.wizard_running")));
32009
32218
  await ctx.withExclusiveInput(async () => {
32010
32219
  const answers = await runSetup(ctx.rl);
32011
- const configPath = join47(homedir17(), ".mma", "config.json");
32220
+ const configPath = join48(homedir18(), ".mma", "config.json");
32012
32221
  ctx.config.provider.type = answers.provider;
32013
32222
  ctx.config.provider.baseUrl = answers.apiBase;
32014
32223
  ctx.config.provider.apiKey = answers.apiKey;
@@ -32016,7 +32225,7 @@ function registerMmaCommands(ctx) {
32016
32225
  ctx.config.contextWindow = answers.contextWindow;
32017
32226
  ctx.config.maxToolIterations = answers.maxToolIterations;
32018
32227
  ctx.config.locale = answers.locale;
32019
- saveConfig(ctx.config, configPath);
32228
+ saveConfig(ctx.config, configPath, dirname19(configPath));
32020
32229
  await ctx.agent.reconfigure(ctx.config);
32021
32230
  console.log(pc2.green(t("cli.config_saved")));
32022
32231
  });
@@ -32130,8 +32339,8 @@ Excluded blocks: ${info.excluded.length}`));
32130
32339
  return;
32131
32340
  }
32132
32341
  ctx.config.model = name;
32133
- const configPath = join47(homedir17(), ".mma", "config.json");
32134
- saveConfig(ctx.config, configPath);
32342
+ const configPath = join48(homedir18(), ".mma", "config.json");
32343
+ saveConfig(ctx.config, configPath, dirname19(configPath));
32135
32344
  await ctx.agent.reconfigure(ctx.config);
32136
32345
  console.log(pc2.green(t("repl.model_set", { name })));
32137
32346
  return;
@@ -32155,8 +32364,8 @@ Excluded blocks: ${info.excluded.length}`));
32155
32364
  return;
32156
32365
  }
32157
32366
  ctx.config.contextWindow = size;
32158
- const configPath = join47(homedir17(), ".mma", "config.json");
32159
- saveConfig(ctx.config, configPath);
32367
+ const configPath = join48(homedir18(), ".mma", "config.json");
32368
+ saveConfig(ctx.config, configPath, dirname19(configPath));
32160
32369
  await ctx.agent.reconfigure(ctx.config);
32161
32370
  console.log(pc2.green(t("cli.context_set", { size })));
32162
32371
  }
@@ -32170,12 +32379,12 @@ Excluded blocks: ${info.excluded.length}`));
32170
32379
  if (ctx.sessionManager && ctx.config.session.autoSave) {}
32171
32380
  ctx.agent.shutdown();
32172
32381
  const { loadConfig: loadConfig2 } = await Promise.resolve().then(() => (init_config2(), exports_config));
32173
- const { homedir: homedir18 } = await import("os");
32174
- const { join: join48 } = await import("path");
32382
+ const { homedir: homedir19 } = await import("os");
32383
+ const { join: join49 } = await import("path");
32175
32384
  const configDir = ctx.configDir;
32176
32385
  const baseDir = ctx.baseDir;
32177
- const projectConfigPath = join48(baseDir, ".mmrc");
32178
- const freshConfig = loadConfig2({ configDir, projectConfigPath });
32386
+ const projectConfigPath = join49(baseDir, ".mmrc");
32387
+ const { config: freshConfig } = loadConfig2({ configDir, projectConfigPath });
32179
32388
  Object.assign(ctx.config, freshConfig);
32180
32389
  const { bootstrap: bootstrap2 } = await Promise.resolve().then(() => (init_bootstrap(), exports_bootstrap));
32181
32390
  const result = await bootstrap2(configDir, baseDir, false, false);
@@ -32577,14 +32786,15 @@ init_config2();
32577
32786
  init_setup();
32578
32787
  init_i18n();
32579
32788
  init_colors();
32580
- import { join as join46 } from "path";
32581
- import { homedir as homedir16 } from "os";
32789
+ import { join as join47, dirname as dirname18 } from "path";
32790
+ import { homedir as homedir17 } from "os";
32791
+ import { existsSync as existsSync53 } from "fs";
32582
32792
 
32583
32793
  // src/cli/security-commands.ts
32584
32794
  init_bootstrap();
32585
32795
  init_config2();
32586
- import { join as join40 } from "path";
32587
- import { homedir as homedir13 } from "os";
32796
+ import { join as join41, dirname as dirname15 } from "path";
32797
+ import { homedir as homedir14 } from "os";
32588
32798
 
32589
32799
  // src/modules/security/security-policies.ts
32590
32800
  init_security();
@@ -33097,7 +33307,7 @@ function createSecurityCommand(program2) {
33097
33307
  }
33098
33308
  });
33099
33309
  securityCmd.command("set-policy").argument("<preset>", t("cli.security.preset")).description(t("cli.security.set_policy")).action(async (preset) => {
33100
- const configPath = join40(homedir13(), ".mma", "config.json");
33310
+ const configPath = join41(homedir14(), ".mma", "config.json");
33101
33311
  const { config: appConfig } = await bootstrap();
33102
33312
  const validPresets = ["strict", "balanced", "permissive"];
33103
33313
  if (!validPresets.includes(preset)) {
@@ -33107,12 +33317,12 @@ function createSecurityCommand(program2) {
33107
33317
  const policy = getSecurityPolicy(preset);
33108
33318
  const newSecurityConfig = applySecurityPolicy(preset);
33109
33319
  appConfig.security = newSecurityConfig;
33110
- saveConfig(appConfig, configPath);
33320
+ saveConfig(appConfig, configPath, dirname15(configPath));
33111
33321
  console.log(t("cli.security.policy_applied", { name: policy.name }));
33112
33322
  console.log(t("cli.security.policy_description", { description: policy.description }));
33113
33323
  });
33114
33324
  securityCmd.command("enable-encryption").description(t("cli.security.enable_encryption")).action(async () => {
33115
- const configPath = join40(homedir13(), ".mma", "config.json");
33325
+ const configPath = join41(homedir14(), ".mma", "config.json");
33116
33326
  const { config: appConfig } = await bootstrap();
33117
33327
  appConfig.security = appConfig.security || {};
33118
33328
  appConfig.security.sessionEncryption = {
@@ -33120,11 +33330,11 @@ function createSecurityCommand(program2) {
33120
33330
  encryptHistory: true,
33121
33331
  encryptSessionLog: true
33122
33332
  };
33123
- saveConfig(appConfig, configPath);
33333
+ saveConfig(appConfig, configPath, dirname15(configPath));
33124
33334
  console.log(t("cli.security.encryption_enabled"));
33125
33335
  });
33126
33336
  securityCmd.command("disable-encryption").description(t("cli.security.disable_encryption")).action(async () => {
33127
- const configPath = join40(homedir13(), ".mma", "config.json");
33337
+ const configPath = join41(homedir14(), ".mma", "config.json");
33128
33338
  const { config: appConfig } = await bootstrap();
33129
33339
  appConfig.security = appConfig.security || {};
33130
33340
  appConfig.security.sessionEncryption = {
@@ -33132,11 +33342,11 @@ function createSecurityCommand(program2) {
33132
33342
  encryptHistory: false,
33133
33343
  encryptSessionLog: false
33134
33344
  };
33135
- saveConfig(appConfig, configPath);
33345
+ saveConfig(appConfig, configPath, dirname15(configPath));
33136
33346
  console.log(t("cli.security.encryption_disabled"));
33137
33347
  });
33138
33348
  securityCmd.command("enable-audit").description(t("cli.security.enable_audit")).action(async () => {
33139
- const configPath = join40(homedir13(), ".mma", "config.json");
33349
+ const configPath = join41(homedir14(), ".mma", "config.json");
33140
33350
  const { config: appConfig } = await bootstrap();
33141
33351
  appConfig.security = appConfig.security || {};
33142
33352
  appConfig.security.auditNotifier = {
@@ -33146,11 +33356,11 @@ function createSecurityCommand(program2) {
33146
33356
  maxRetries: 3,
33147
33357
  webhookTimeout: 5000
33148
33358
  };
33149
- saveConfig(appConfig, configPath);
33359
+ saveConfig(appConfig, configPath, dirname15(configPath));
33150
33360
  console.log(t("cli.security.audit_enabled"));
33151
33361
  });
33152
33362
  securityCmd.command("disable-audit").description(t("cli.security.disable_audit")).action(async () => {
33153
- const configPath = join40(homedir13(), ".mma", "config.json");
33363
+ const configPath = join41(homedir14(), ".mma", "config.json");
33154
33364
  const { config: appConfig } = await bootstrap();
33155
33365
  appConfig.security = appConfig.security || {};
33156
33366
  appConfig.security.auditNotifier = {
@@ -33158,7 +33368,7 @@ function createSecurityCommand(program2) {
33158
33368
  maxRetries: 3,
33159
33369
  webhookTimeout: 5000
33160
33370
  };
33161
- saveConfig(appConfig, configPath);
33371
+ saveConfig(appConfig, configPath, dirname15(configPath));
33162
33372
  console.log(t("cli.security.audit_disabled"));
33163
33373
  });
33164
33374
  securityCmd.command("audit-stats").description(t("cli.security.audit_stats")).action(async () => {
@@ -33220,7 +33430,7 @@ function createProgram() {
33220
33430
  const program2 = new Command().name("mma").description(t("cli.description")).version(version).option("--no-agents-md", t("cli.no_agents_md")).option("-d, --dir <path>", t("cli.dir")).option("-e, --exit-on-complete", t("cli.exit_on_complete")).option("-j, --json", t("cli.json"));
33221
33431
  program2.command("init").description(t("cli.init")).action(async () => {
33222
33432
  const answers = await runSetup();
33223
- const configPath = join46(homedir16(), ".mma", "config.json");
33433
+ const configPath = join47(homedir17(), ".mma", "config.json");
33224
33434
  const { config } = await bootstrap();
33225
33435
  config.provider.type = answers.provider;
33226
33436
  config.provider.baseUrl = answers.apiBase;
@@ -33260,12 +33470,12 @@ function createProgram() {
33260
33470
  config.security.paths.denied = [];
33261
33471
  }
33262
33472
  }
33263
- saveConfig(config, configPath);
33473
+ saveConfig(config, configPath, dirname18(configPath));
33264
33474
  console.log(t("cli.config_saved"));
33265
33475
  });
33266
33476
  const configCmd = program2.command("config").description(t("cli.manage_config"));
33267
33477
  configCmd.command("set").argument("<key>", t("cli.config_key")).argument("<value>", "Config value").description(t("cli.set_value")).action(async (key, value) => {
33268
- const configPath = join46(homedir16(), ".mma", "config.json");
33478
+ const configPath = join47(homedir17(), ".mma", "config.json");
33269
33479
  const { config } = await bootstrap();
33270
33480
  const keys = key.split(".");
33271
33481
  let obj = config;
@@ -33285,13 +33495,36 @@ function createProgram() {
33285
33495
  obj[lastKey] = parseFloat(value);
33286
33496
  else
33287
33497
  obj[lastKey] = value;
33288
- saveConfig(config, configPath);
33498
+ saveConfig(config, configPath, dirname18(configPath));
33289
33499
  console.log(t("cli.set_done", { key, value }));
33290
33500
  });
33291
33501
  configCmd.command("show").description(t("cli.show_config")).action(async () => {
33292
33502
  const { config } = await bootstrap();
33293
33503
  console.log(JSON.stringify(config, null, 2));
33294
33504
  });
33505
+ configCmd.command("migrate").description(t("cli.migrate_config")).action(async () => {
33506
+ const { loadConfig: loadConfig2 } = await Promise.resolve().then(() => (init_config2(), exports_config));
33507
+ const { hasDomainFiles: hasDomainFiles3 } = await Promise.resolve().then(() => (init_domains(), exports_domains));
33508
+ const configDir = join47(homedir17(), ".mma");
33509
+ const configPath = join47(configDir, "config.json");
33510
+ if (hasDomainFiles3(configDir)) {
33511
+ console.log(pc2.yellow(t("config.migrate_no_legacy")));
33512
+ return;
33513
+ }
33514
+ if (!existsSync53(configPath)) {
33515
+ console.log(pc2.yellow(t("config.migrate_no_legacy")));
33516
+ return;
33517
+ }
33518
+ console.log(t("config.migrate_start"));
33519
+ const { config } = loadConfig2({ configDir, projectConfigPath: join47(configDir, ".mmrc") });
33520
+ saveConfig(config, configPath, configDir);
33521
+ const bakPath = configPath + ".bak";
33522
+ const { renameSync: renameSync3 } = await import("fs");
33523
+ renameSync3(configPath, bakPath);
33524
+ const { readdirSync: readdirSync18 } = await import("fs");
33525
+ const domainFiles = readdirSync18(join47(configDir, "config")).filter((f) => f.endsWith(".json"));
33526
+ console.log(pc2.green(t("config.migrate_done", { count: String(domainFiles.length) })));
33527
+ });
33295
33528
  const model = program2.command("model").description(t("cli.manage_models"));
33296
33529
  model.command("list").description(t("cli.list_models")).action(async () => {
33297
33530
  const { config } = await bootstrap();
@@ -33328,10 +33561,10 @@ function createProgram() {
33328
33561
  console.log(t("cli.model_hint"));
33329
33562
  });
33330
33563
  model.command("use").argument("<name>", "Model name").description(t("cli.set_model")).action(async (name) => {
33331
- const configPath = join46(homedir16(), ".mma", "config.json");
33564
+ const configPath = join47(homedir17(), ".mma", "config.json");
33332
33565
  const { config } = await bootstrap();
33333
33566
  config.model = name;
33334
- saveConfig(config, configPath);
33567
+ saveConfig(config, configPath, dirname18(configPath));
33335
33568
  console.log(t("cli.model_set", { name }));
33336
33569
  });
33337
33570
  model.command("certify").argument("<name>", "Model name").option("--provider-url <url>", t("cli.cert_provider_url")).option("--provider-key <key>", t("cli.cert_provider_key")).option("--context-window <n>", t("cli.cert_context_window")).option("--tags <tags>", t("cli.cert_tags"), "core").option("--reps <n>", t("cli.cert_reps")).option("--force", t("cli.cert_force")).option("--clean", t("cli.cert_clean")).description(t("cli.certify")).action(async (name, cmdOpts) => {
@@ -33364,7 +33597,7 @@ function createProgram() {
33364
33597
  await uncertify2(name, config);
33365
33598
  });
33366
33599
  program2.command("context").description(t("cli.manage_context")).argument("<size>", "Context window size in tokens").action(async (size) => {
33367
- const configPath = join46(homedir16(), ".mma", "config.json");
33600
+ const configPath = join47(homedir17(), ".mma", "config.json");
33368
33601
  const { config } = await bootstrap();
33369
33602
  const contextWindow = parseInt(size, 10);
33370
33603
  if (isNaN(contextWindow) || contextWindow < 1024) {
@@ -33372,7 +33605,7 @@ function createProgram() {
33372
33605
  return;
33373
33606
  }
33374
33607
  config.contextWindow = contextWindow;
33375
- saveConfig(config, configPath);
33608
+ saveConfig(config, configPath, dirname18(configPath));
33376
33609
  console.log(t("cli.context_set", { size: contextWindow }));
33377
33610
  });
33378
33611
  const provider = program2.command("provider").description(t("cli.manage_providers"));
@@ -33410,7 +33643,7 @@ function createProgram() {
33410
33643
  console.log(t("cli.base_url"), config.provider.baseUrl);
33411
33644
  });
33412
33645
  provider.command("use").argument("<name>", "Provider name").description(t("cli.set_provider")).action(async (name) => {
33413
- const configPath = join46(homedir16(), ".mma", "config.json");
33646
+ const configPath = join47(homedir17(), ".mma", "config.json");
33414
33647
  const { config, agent } = await bootstrap();
33415
33648
  if (config.provider.entries && config.provider.entries.length > 0) {
33416
33649
  try {
@@ -33426,14 +33659,14 @@ function createProgram() {
33426
33659
  if (baseUrl) {
33427
33660
  config.provider.baseUrl = baseUrl;
33428
33661
  }
33429
- saveConfig(config, configPath);
33662
+ saveConfig(config, configPath, dirname18(configPath));
33430
33663
  console.log(t("cli.provider_set", { name }));
33431
33664
  if (baseUrl) {
33432
33665
  console.log(t("cli.provider_base_hint", { baseUrl }));
33433
33666
  }
33434
33667
  });
33435
33668
  provider.command("add").argument("<name>", "Provider type or label").option("--url <url>", "Base URL").option("--key <key>", "API key").option("--priority <n>", "Fallback priority (lower = tried first)").option("--context-window <n>", "Context window override for this entry").option("--rpm <n>", "Max requests per minute for this entry").option("--parallel <n>", "Max parallel tasks for this entry").description(t("cli.add_provider")).action(async (name, opts) => {
33436
- const configPath = join46(homedir16(), ".mma", "config.json");
33669
+ const configPath = join47(homedir17(), ".mma", "config.json");
33437
33670
  const { config } = await bootstrap();
33438
33671
  const entries = Array.isArray(config.provider.entries) ? config.provider.entries : [];
33439
33672
  if (entries.length === 0) {
@@ -33465,7 +33698,7 @@ function createProgram() {
33465
33698
  });
33466
33699
  config.provider.entries = entries;
33467
33700
  config.provider.active = config.provider.active || config.provider.type;
33468
- saveConfig(config, configPath);
33701
+ saveConfig(config, configPath, dirname18(configPath));
33469
33702
  console.log(pc2.green(t("cli.provider_added", { name })));
33470
33703
  console.log(t("cli.provider_switch_hint"));
33471
33704
  });
@@ -33802,6 +34035,10 @@ class LineEditor {
33802
34035
  this.lastWasCR = false;
33803
34036
  return;
33804
34037
  }
34038
+ if (this.questionCb) {
34039
+ this.submit();
34040
+ return;
34041
+ }
33805
34042
  this.insertNewline();
33806
34043
  return;
33807
34044
  case "backspace":
@@ -34338,9 +34575,9 @@ class LineEditor {
34338
34575
  }
34339
34576
 
34340
34577
  // src/cli/repl.ts
34341
- import { existsSync as existsSync52, readFileSync as readFileSync34, writeFileSync as writeFileSync17 } from "fs";
34342
- import { join as join48 } from "path";
34343
- import { homedir as homedir18 } from "os";
34578
+ import { existsSync as existsSync55, readFileSync as readFileSync37, writeFileSync as writeFileSync18 } from "fs";
34579
+ import { join as join49 } from "path";
34580
+ import { homedir as homedir19 } from "os";
34344
34581
 
34345
34582
  // src/cli/completer.ts
34346
34583
  class SlashCommandProvider {
@@ -34924,7 +35161,6 @@ ${pc2.dim(marker)} ${friendlyTool(tool)}${summary ? ` ${pc2.dim(summary)}` : ""}
34924
35161
 
34925
35162
  // src/cli/repl.ts
34926
35163
  init_box();
34927
- init_string_width();
34928
35164
  init_i18n();
34929
35165
  init_repl_commands();
34930
35166
 
@@ -35164,10 +35400,10 @@ class Repl {
35164
35400
  this.envReport = envReport;
35165
35401
  this.execModule = execModule;
35166
35402
  this.slog = new SessionLogger(sessionManager, logger);
35167
- this.configDir = configDir || join48(homedir18(), ".mma");
35403
+ this.configDir = configDir || join49(homedir19(), ".mma");
35168
35404
  this.baseDir = baseDir || process.cwd();
35169
35405
  this.noAgentsMd = noAgentsMd === true;
35170
- this.historyPath = historyPath ?? join48(homedir18(), ".mma", "repl-history");
35406
+ this.historyPath = historyPath ?? join49(homedir19(), ".mma", "repl-history");
35171
35407
  this.loadHistory();
35172
35408
  this.rl = process.stdin.isTTY ? new LineEditor({
35173
35409
  input: process.stdin,
@@ -35213,9 +35449,9 @@ class Repl {
35213
35449
  }
35214
35450
  }
35215
35451
  loadHistory() {
35216
- if (existsSync52(this.historyPath)) {
35452
+ if (existsSync55(this.historyPath)) {
35217
35453
  try {
35218
- const raw = readFileSync34(this.historyPath, "utf-8");
35454
+ const raw = readFileSync37(this.historyPath, "utf-8");
35219
35455
  this.history = raw.split(`
35220
35456
  `).filter(Boolean).slice(-this.maxHistory);
35221
35457
  } catch {
@@ -35225,7 +35461,7 @@ class Repl {
35225
35461
  }
35226
35462
  saveHistory() {
35227
35463
  const allHistory = this.history.slice(-this.maxHistory);
35228
- writeFileSync17(this.historyPath, allHistory.join(`
35464
+ writeFileSync18(this.historyPath, allHistory.join(`
35229
35465
  `), "utf-8");
35230
35466
  }
35231
35467
  setupCompleter() {
@@ -35612,11 +35848,11 @@ ${t("image.clipboard_empty")}`));
35612
35848
  row(t("repl.agents_label"), pc2.red(t("repl.disabled")));
35613
35849
  } else {
35614
35850
  const agentsMdCandidates = [
35615
- join48(this.baseDir, "AGENTS.md"),
35616
- join48(this.baseDir, ".mma", "AGENTS.md"),
35617
- join48(this.configDir, "AGENTS.md")
35851
+ join49(this.baseDir, "AGENTS.md"),
35852
+ join49(this.baseDir, ".mma", "AGENTS.md"),
35853
+ join49(this.configDir, "AGENTS.md")
35618
35854
  ];
35619
- const foundAgents = agentsMdCandidates.filter((p) => existsSync52(p));
35855
+ const foundAgents = agentsMdCandidates.filter((p) => existsSync55(p));
35620
35856
  if (foundAgents.length > 0) {
35621
35857
  for (const p of foundAgents) {
35622
35858
  row(t("repl.agents_label"), pc2.dim(p));
@@ -35627,24 +35863,35 @@ ${t("image.clipboard_empty")}`));
35627
35863
  }
35628
35864
  const meta = this.sessionManager?.getActiveMeta();
35629
35865
  if (meta) {
35630
- const sessionPath = join48(this.configDir, "sessions", meta.id);
35866
+ const sessionPath = join49(this.configDir, "sessions", meta.id);
35631
35867
  row(t("repl.session_label"), `${pc2.cyan(meta.name)} ${pc2.dim(`(${meta.id.slice(0, 12)})`)} — ${meta.messageCount} msgs ${pc2.dim(sessionPath)}`);
35632
35868
  }
35633
- const headerWidth = Math.max(50, Math.min(96, process.stdout.columns || 96));
35634
35869
  const isTty2 = process.stdout.isTTY === true;
35635
35870
  const lspEnabled = isTty2 && (this.config.lsp ?? DEFAULT_LSP_CONFIG).enabled !== false;
35636
- if (lspEnabled) {
35637
- row(t("repl.lsp_label"), pc2.dim("…"));
35638
- }
35639
35871
  for (const line of info) {
35640
35872
  console.log(pc2.dim(line).trimEnd());
35641
35873
  }
35642
35874
  console.log();
35875
+ try {
35876
+ const { existsSync: exists } = await import("fs");
35877
+ const { join: pathJoin } = await import("path");
35878
+ const { hasDomainFiles: hasDomainFiles3 } = await Promise.resolve().then(() => (init_domains(), exports_domains));
35879
+ const legacyPath = pathJoin(this.configDir, "config.json");
35880
+ if (exists(legacyPath) && !hasDomainFiles3(this.configDir)) {
35881
+ console.log(pc2.yellow(` ${t("config.legacy_hint")}`));
35882
+ console.log();
35883
+ }
35884
+ } catch {}
35643
35885
  this.rl.prompt();
35644
35886
  if (lspEnabled) {
35645
35887
  this.probeLspBanner().then((lspSummary) => {
35646
- if (lspSummary)
35647
- this.updateLspRow(headerWidth, lspSummary);
35888
+ if (lspSummary) {
35889
+ const line = `${pc2.green(t("repl.agent"))}${pc2.yellow(t("repl.lsp_label"))} ${lspSummary}`;
35890
+ process.stdout.write(`\x1B[2K\r${divider()}
35891
+ ${line}
35892
+ `);
35893
+ this.rl.prompt();
35894
+ }
35648
35895
  }).catch(() => {});
35649
35896
  }
35650
35897
  if ((this.config.provider.entries?.length ?? 0) > 1) {
@@ -35660,17 +35907,6 @@ ${t("image.clipboard_empty")}`));
35660
35907
  }).catch(() => {});
35661
35908
  }
35662
35909
  }
35663
- updateLspRow(headerWidth, summary) {
35664
- if (this.agentRunning || !process.stdout.isTTY)
35665
- return;
35666
- if ((process.stdout.columns ?? 96) < headerWidth)
35667
- return;
35668
- const rowText = `${pc2.yellow(t("repl.lsp_label"))} ${summary.replace(/\s+/g, " ").trim()}`;
35669
- if (stringWidth(rowText) > headerWidth)
35670
- return;
35671
- const line = pc2.dim(rowText);
35672
- process.stdout.write(`\x1B[2A\r\x1B[2K${line}\x1B[2B\r`);
35673
- }
35674
35910
  async probeLspBanner() {
35675
35911
  const config = this.config.lsp ?? DEFAULT_LSP_CONFIG;
35676
35912
  try {
@@ -35742,9 +35978,9 @@ init_setup();
35742
35978
  init_config2();
35743
35979
  init_i18n();
35744
35980
  init_colors();
35745
- import { existsSync as existsSync53 } from "fs";
35746
- import { join as join50 } from "path";
35747
- import { homedir as homedir20 } from "os";
35981
+ import { existsSync as existsSync56 } from "fs";
35982
+ import { join as join51, dirname as dirname20 } from "path";
35983
+ import { homedir as homedir21 } from "os";
35748
35984
 
35749
35985
  // src/modules/updater/index.ts
35750
35986
  init_checker();
@@ -35847,10 +36083,10 @@ class UpdaterModule {
35847
36083
  init_environment();
35848
36084
  init_data_sanitizer();
35849
36085
  init_i18n();
35850
- import { appendFileSync as appendFileSync7, mkdirSync as mkdirSync20 } from "fs";
35851
- import { join as join49 } from "path";
35852
- import { homedir as homedir19 } from "os";
35853
- var CRASH_LOG_DIR = join49(homedir19(), ".mma", "logs");
36086
+ import { appendFileSync as appendFileSync7, mkdirSync as mkdirSync21 } from "fs";
36087
+ import { join as join50 } from "path";
36088
+ import { homedir as homedir20 } from "os";
36089
+ var CRASH_LOG_DIR = join50(homedir20(), ".mma", "logs");
35854
36090
  var CRASH_LOG_FILE = "crash.jsonl";
35855
36091
  function formatCrashEntry(type2, err) {
35856
36092
  const message = err instanceof Error ? err.message : String(err);
@@ -35860,13 +36096,13 @@ function formatCrashEntry(type2, err) {
35860
36096
  type: type2,
35861
36097
  message: sanitizeLogMessage(message),
35862
36098
  stack: sanitizeLogMessage(stack),
35863
- environment: collectEnvironment({ configDir: homedir19(), scanTools: false })
36099
+ environment: collectEnvironment({ configDir: homedir20(), scanTools: false })
35864
36100
  };
35865
36101
  }
35866
36102
  function writeCrashEntry(dir, entry) {
35867
36103
  try {
35868
- mkdirSync20(dir, { recursive: true });
35869
- appendFileSync7(join49(dir, CRASH_LOG_FILE), JSON.stringify(entry) + `
36104
+ mkdirSync21(dir, { recursive: true });
36105
+ appendFileSync7(join50(dir, CRASH_LOG_FILE), JSON.stringify(entry) + `
35870
36106
  `, "utf-8");
35871
36107
  } catch {}
35872
36108
  }
@@ -35924,7 +36160,10 @@ async function main() {
35924
36160
  }
35925
36161
  if (program2.args.length > 0) {
35926
36162
  const prompt = program2.args.join(" ");
35927
- const { agent, config, baseDir } = await bootstrap(undefined, projectDir, noAgentsMd, exitOnComplete);
36163
+ const { agent, config, baseDir, legacyDetected } = await bootstrap(undefined, projectDir, noAgentsMd, exitOnComplete);
36164
+ if (legacyDetected) {
36165
+ console.error(pc2.yellow(` ${t("config.legacy_hint")}`));
36166
+ }
35928
36167
  const updater = exitOnComplete ? undefined : startAutoUpdate(config);
35929
36168
  if (jsonMode) {
35930
36169
  const result2 = await agent.run(prompt);
@@ -35971,31 +36210,48 @@ async function main() {
35971
36210
  await updater?.waitForIdle();
35972
36211
  process.exit(exitCode);
35973
36212
  } else {
35974
- const configPath = join50(homedir20(), ".mma", "config.json");
35975
- if (!existsSync53(configPath)) {
36213
+ const mmaDir = join51(homedir21(), ".mma");
36214
+ const legacyConfigPath = join51(mmaDir, "config.json");
36215
+ let hasAnyConfig = existsSync56(legacyConfigPath);
36216
+ if (!hasAnyConfig) {
36217
+ try {
36218
+ const { hasDomainFiles: hasDomainFiles3 } = await Promise.resolve().then(() => (init_domains(), exports_domains));
36219
+ hasAnyConfig = hasDomainFiles3(mmaDir);
36220
+ } catch {}
36221
+ }
36222
+ const {
36223
+ agent,
36224
+ config,
36225
+ sessionManager,
36226
+ skillsModule,
36227
+ pluginManager,
36228
+ execModule,
36229
+ configDir,
36230
+ baseDir,
36231
+ logger,
36232
+ envReport
36233
+ } = await bootstrap(undefined, projectDir, noAgentsMd, exitOnComplete);
36234
+ const repl = new Repl(agent, config, sessionManager, skillsModule, pluginManager, configDir, baseDir, noAgentsMd, logger, true, envReport, undefined, execModule);
36235
+ if (!hasAnyConfig) {
35976
36236
  console.log(pc2.yellow(`
35977
36237
  ` + t("cli.first_run") + `
35978
36238
  `));
35979
- const answers = await runSetup();
35980
- const config2 = loadConfig({
35981
- configDir: join50(homedir20(), ".mma"),
35982
- projectConfigPath: projectDir ? join50(projectDir, ".mmrc") : join50(process.cwd(), ".mmrc")
35983
- });
35984
- config2.provider.type = answers.provider;
35985
- config2.provider.baseUrl = answers.apiBase;
35986
- config2.provider.apiKey = answers.apiKey;
35987
- config2.model = answers.model;
35988
- config2.contextWindow = answers.contextWindow;
35989
- config2.maxToolIterations = answers.maxToolIterations;
35990
- config2.locale = answers.locale;
35991
- if (config2.security) {
35992
- config2.security.enabled = true;
35993
- config2.security.bash.enabled = true;
35994
- config2.security.bash.blockDangerousFlags = answers.securityFlagsBlock || config2.security.bash.blockDangerousFlags;
36239
+ const answers = await runSetup(repl.rl);
36240
+ config.provider.type = answers.provider;
36241
+ config.provider.baseUrl = answers.apiBase;
36242
+ config.provider.apiKey = answers.apiKey;
36243
+ config.model = answers.model;
36244
+ config.contextWindow = answers.contextWindow;
36245
+ config.maxToolIterations = answers.maxToolIterations;
36246
+ config.locale = answers.locale;
36247
+ if (config.security) {
36248
+ config.security.enabled = true;
36249
+ config.security.bash.enabled = true;
36250
+ config.security.bash.blockDangerousFlags = answers.securityFlagsBlock || config.security.bash.blockDangerousFlags;
35995
36251
  if (answers.securityBashBlock) {
35996
- config2.security.bash.blacklist = [
36252
+ config.security.bash.blacklist = [
35997
36253
  ...new Set([
35998
- ...config2.security.bash.blacklist,
36254
+ ...config.security.bash.blacklist,
35999
36255
  "rm",
36000
36256
  "dd",
36001
36257
  "chmod",
@@ -36016,25 +36272,13 @@ async function main() {
36016
36272
  ];
36017
36273
  }
36018
36274
  if (!answers.securityPathsDeny) {
36019
- config2.security.paths.denied = [];
36275
+ config.security.paths.denied = [];
36020
36276
  }
36021
36277
  }
36022
- saveConfig(config2, configPath);
36278
+ saveConfig(config, legacyConfigPath, dirname20(legacyConfigPath));
36279
+ await agent.reconfigure(config);
36023
36280
  }
36024
- const {
36025
- agent,
36026
- config,
36027
- sessionManager,
36028
- skillsModule,
36029
- pluginManager,
36030
- execModule,
36031
- configDir,
36032
- baseDir,
36033
- logger,
36034
- envReport
36035
- } = await bootstrap(undefined, projectDir, noAgentsMd, exitOnComplete);
36036
36281
  startAutoUpdate(config);
36037
- const repl = new Repl(agent, config, sessionManager, skillsModule, pluginManager, configDir, baseDir, noAgentsMd, logger, true, envReport, undefined, execModule);
36038
36282
  await repl.start();
36039
36283
  }
36040
36284
  }