micro-models-agent 2.16.1 → 2.17.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 (428) hide show
  1. package/CHANGELOG.md +34 -0
  2. package/README.md +8 -3
  3. package/dist/assets/app.js +1 -314
  4. package/dist/assets/hljs.js +5 -1244
  5. package/dist/assets/index.html +11 -0
  6. package/dist/assets/js/api.js +1 -28
  7. package/dist/assets/js/core/menus.js +1 -0
  8. package/dist/assets/js/core/store/feed.js +1 -0
  9. package/dist/assets/js/core/store/index.js +1 -0
  10. package/dist/assets/js/core/store/session.js +1 -0
  11. package/dist/assets/js/core/store/settings.js +1 -0
  12. package/dist/assets/js/core/store/tabs.js +1 -0
  13. package/dist/assets/js/dialog.js +1 -105
  14. package/dist/assets/js/dom.js +1 -178
  15. package/dist/assets/js/feed/core.js +1 -0
  16. package/dist/assets/js/feed/history.js +1 -0
  17. package/dist/assets/js/feed/plan.js +1 -0
  18. package/dist/assets/js/feed/question.js +3 -0
  19. package/dist/assets/js/feed/sidebar.js +1 -0
  20. package/dist/assets/js/feed/stream.js +1 -0
  21. package/dist/assets/js/feed/turn.js +5 -0
  22. package/dist/assets/js/feed.js +1 -1250
  23. package/dist/assets/js/format.js +2 -122
  24. package/dist/assets/js/i18n.js +1 -46
  25. package/dist/assets/js/rail.js +1 -114
  26. package/dist/assets/js/session/cmdk.js +1 -0
  27. package/dist/assets/js/session/composer.js +1 -0
  28. package/dist/assets/js/session/sessions-menu.js +1 -0
  29. package/dist/assets/js/session/tabs.js +1 -0
  30. package/dist/assets/js/settings/controls.js +1 -0
  31. package/dist/assets/js/settings/editors.js +1 -0
  32. package/dist/assets/js/settings/form.js +1 -0
  33. package/dist/assets/js/settings/modal.js +1 -0
  34. package/dist/assets/js/settings/panels.js +1 -0
  35. package/dist/assets/js/settings/providers.js +1 -0
  36. package/dist/assets/js/settings/search.js +1 -0
  37. package/dist/assets/js/settings/subdialog.js +1 -0
  38. package/dist/assets/js/settings/write.js +1 -0
  39. package/dist/assets/js/settings.js +1 -1914
  40. package/dist/assets/js/sidebar/core.js +1 -0
  41. package/dist/assets/js/sidebar/lsp.js +2 -0
  42. package/dist/assets/js/sidebar/map.js +1 -0
  43. package/dist/assets/js/sidebar/state.js +1 -0
  44. package/dist/assets/js/sidebar/trace.js +5 -0
  45. package/dist/assets/js/sidebar.js +1 -705
  46. package/dist/assets/js/store.js +1 -82
  47. package/dist/assets/js/subdialog.js +1 -0
  48. package/dist/assets/md.js +1 -291
  49. package/dist/assets/setup.js +3 -816
  50. package/dist/assets/smd.js +29 -1665
  51. package/dist/assets/styles.css +1 -1598
  52. package/dist/certification/certifications.json +1 -494
  53. package/dist/i18n/en.json +1 -1851
  54. package/dist/i18n/ru.json +1 -1854
  55. package/dist/main.js +815 -55797
  56. package/dist/modules/browser/bridge-server.mjs +2 -252
  57. package/package.json +10 -5
  58. package/dist/assets/js/settings-controls.js +0 -452
  59. package/dist/assets/js/tabs.js +0 -867
  60. package/dist/cli/cache-line.js +0 -31
  61. package/dist/cli/command-suggest.js +0 -39
  62. package/dist/cli/commands.js +0 -781
  63. package/dist/cli/completer.js +0 -268
  64. package/dist/cli/index.js +0 -3
  65. package/dist/cli/json-payload.js +0 -32
  66. package/dist/cli/main.js +0 -346
  67. package/dist/cli/onboarding-commands.js +0 -126
  68. package/dist/cli/plugin-commands.js +0 -38
  69. package/dist/cli/relaunch.js +0 -40
  70. package/dist/cli/repl-commands-lsp.js +0 -75
  71. package/dist/cli/repl-commands-skills.js +0 -105
  72. package/dist/cli/repl-commands.js +0 -1218
  73. package/dist/cli/repl.js +0 -1238
  74. package/dist/cli/run-result.js +0 -38
  75. package/dist/cli/security-commands.js +0 -177
  76. package/dist/cli/setup-order.js +0 -6
  77. package/dist/cli/setup-prompt.js +0 -50
  78. package/dist/cli/setup.js +0 -161
  79. package/dist/cli/web-command.js +0 -98
  80. package/dist/config/budget.js +0 -48
  81. package/dist/config/config.js +0 -345
  82. package/dist/config/defaults.js +0 -197
  83. package/dist/config/domains.js +0 -135
  84. package/dist/config/env.js +0 -46
  85. package/dist/config/experts.js +0 -17
  86. package/dist/config/index.js +0 -5
  87. package/dist/config/paths.js +0 -56
  88. package/dist/config/redact.js +0 -44
  89. package/dist/config/registry-extra.js +0 -334
  90. package/dist/config/registry.js +0 -584
  91. package/dist/config/security.js +0 -212
  92. package/dist/config/timeouts.js +0 -74
  93. package/dist/config/types.js +0 -1
  94. package/dist/config/utils.js +0 -57
  95. package/dist/core/agent/artifact-progress.js +0 -59
  96. package/dist/core/agent/artifact-resolve.js +0 -79
  97. package/dist/core/agent/audit-gate.js +0 -53
  98. package/dist/core/agent/compaction.js +0 -89
  99. package/dist/core/agent/constants.js +0 -90
  100. package/dist/core/agent/context-log.js +0 -454
  101. package/dist/core/agent/context-renderer.js +0 -45
  102. package/dist/core/agent/critic-gate.js +0 -132
  103. package/dist/core/agent/hallucination-gate.js +0 -197
  104. package/dist/core/agent/loop-state.js +0 -68
  105. package/dist/core/agent/prefix-monitor.js +0 -101
  106. package/dist/core/agent/reasoning-resolver.js +0 -65
  107. package/dist/core/agent/token-tracker.js +0 -99
  108. package/dist/core/agent/tool-batch.js +0 -312
  109. package/dist/core/agent/tool-images.js +0 -18
  110. package/dist/core/agent/tool-output.js +0 -116
  111. package/dist/core/agent/tool-pairing.js +0 -60
  112. package/dist/core/agent-moe.js +0 -248
  113. package/dist/core/agent.js +0 -1299
  114. package/dist/core/bootstrap/agent-phase.js +0 -66
  115. package/dist/core/bootstrap/config-phase.js +0 -86
  116. package/dist/core/bootstrap/modules-phase.js +0 -269
  117. package/dist/core/bootstrap/provider-phase.js +0 -183
  118. package/dist/core/bootstrap/session-phase.js +0 -204
  119. package/dist/core/bootstrap/state.js +0 -94
  120. package/dist/core/bootstrap/workspace-phase.js +0 -115
  121. package/dist/core/bootstrap.js +0 -112
  122. package/dist/core/crash-handler.js +0 -62
  123. package/dist/core/environment.js +0 -224
  124. package/dist/core/host-plan.js +0 -43
  125. package/dist/core/host.js +0 -23
  126. package/dist/core/index.js +0 -3
  127. package/dist/core/prompt-builder.js +0 -95
  128. package/dist/core/prompt-overflow.js +0 -306
  129. package/dist/core/session-logger.js +0 -375
  130. package/dist/core/system-prompt.js +0 -117
  131. package/dist/core/types.js +0 -1
  132. package/dist/core/version.js +0 -28
  133. package/dist/core/web-host.js +0 -34
  134. package/dist/core/workspace.js +0 -80
  135. package/dist/i18n/index.js +0 -80
  136. package/dist/index.js +0 -30
  137. package/dist/llm/cache-usage.js +0 -76
  138. package/dist/llm/image-utils.js +0 -138
  139. package/dist/llm/index.js +0 -4
  140. package/dist/llm/llm-errors.js +0 -50
  141. package/dist/llm/model-loader.js +0 -86
  142. package/dist/llm/models-dev.js +0 -121
  143. package/dist/llm/openai-compat.js +0 -756
  144. package/dist/llm/orchestrator.js +0 -294
  145. package/dist/llm/provider-budget.js +0 -68
  146. package/dist/llm/provider-context.js +0 -233
  147. package/dist/llm/provider.js +0 -9
  148. package/dist/llm/response.js +0 -44
  149. package/dist/llm/stream-state.js +0 -26
  150. package/dist/llm/token-counter.js +0 -83
  151. package/dist/llm/types.js +0 -1
  152. package/dist/logger/app-logger.js +0 -212
  153. package/dist/logger/file-log.js +0 -160
  154. package/dist/logger/index.js +0 -2
  155. package/dist/migration/backup.js +0 -56
  156. package/dist/migration/detect.js +0 -61
  157. package/dist/migration/index.js +0 -3
  158. package/dist/modules/artifacts/store.js +0 -62
  159. package/dist/modules/browser/actions.js +0 -79
  160. package/dist/modules/browser/bridge-client.js +0 -203
  161. package/dist/modules/browser/bridge-path.js +0 -10
  162. package/dist/modules/browser/console-buffer.js +0 -37
  163. package/dist/modules/browser/cookie-store.js +0 -29
  164. package/dist/modules/browser/driver-types.js +0 -1
  165. package/dist/modules/browser/driver.js +0 -186
  166. package/dist/modules/browser/index.js +0 -9
  167. package/dist/modules/browser/module.js +0 -30
  168. package/dist/modules/browser/session.js +0 -322
  169. package/dist/modules/browser/snapshot.js +0 -154
  170. package/dist/modules/browser/types.js +0 -13
  171. package/dist/modules/certification/cli.js +0 -264
  172. package/dist/modules/certification/fact-checker.js +0 -90
  173. package/dist/modules/certification/loader.js +0 -127
  174. package/dist/modules/certification/manifest.js +0 -231
  175. package/dist/modules/certification/runner.js +0 -233
  176. package/dist/modules/certification/scenarios.js +0 -586
  177. package/dist/modules/certification/syntax-scenarios.js +0 -50
  178. package/dist/modules/certification/types.js +0 -1
  179. package/dist/modules/context/chunk-query.js +0 -122
  180. package/dist/modules/context/fact-extractor.js +0 -170
  181. package/dist/modules/context/history.js +0 -15
  182. package/dist/modules/context/index.js +0 -2
  183. package/dist/modules/context/manager.js +0 -482
  184. package/dist/modules/critic/client.js +0 -176
  185. package/dist/modules/critic/evidence.js +0 -81
  186. package/dist/modules/critic/provider.js +0 -45
  187. package/dist/modules/critic/tools.js +0 -78
  188. package/dist/modules/critic/types.js +0 -1
  189. package/dist/modules/execution/audit-runners.js +0 -206
  190. package/dist/modules/execution/auditor.js +0 -222
  191. package/dist/modules/execution/execution-plugin.js +0 -478
  192. package/dist/modules/execution/index.js +0 -8
  193. package/dist/modules/execution/input-from.js +0 -70
  194. package/dist/modules/execution/module.js +0 -891
  195. package/dist/modules/execution/moe-executor.js +0 -443
  196. package/dist/modules/execution/plan-actions.js +0 -642
  197. package/dist/modules/execution/plan-checks.js +0 -35
  198. package/dist/modules/execution/plan-coverage.js +0 -71
  199. package/dist/modules/execution/plan-persister.js +0 -46
  200. package/dist/modules/execution/plan-steps.js +0 -31
  201. package/dist/modules/execution/plan-store.js +0 -274
  202. package/dist/modules/execution/plan-tool.js +0 -249
  203. package/dist/modules/execution/plan-validator.js +0 -197
  204. package/dist/modules/execution/planner.js +0 -103
  205. package/dist/modules/execution/stuck-detector.js +0 -834
  206. package/dist/modules/execution/tracker.js +0 -92
  207. package/dist/modules/execution/transient-error.js +0 -30
  208. package/dist/modules/execution/types.js +0 -1
  209. package/dist/modules/execution/verifier.js +0 -343
  210. package/dist/modules/execution/windows-commands.js +0 -52
  211. package/dist/modules/hallucination/artifact-claim.js +0 -93
  212. package/dist/modules/hallucination/confidence.js +0 -81
  213. package/dist/modules/hallucination/consistency.js +0 -37
  214. package/dist/modules/hallucination/detector.js +0 -57
  215. package/dist/modules/hallucination/factual.js +0 -205
  216. package/dist/modules/hallucination/index.js +0 -6
  217. package/dist/modules/hallucination/js-identifiers.js +0 -261
  218. package/dist/modules/hallucination/llm-judge.js +0 -116
  219. package/dist/modules/hallucination/success-claim.js +0 -59
  220. package/dist/modules/index.js +0 -5
  221. package/dist/modules/indexer/cache.js +0 -88
  222. package/dist/modules/indexer/index.js +0 -4
  223. package/dist/modules/indexer/map-command.js +0 -33
  224. package/dist/modules/indexer/map-select.js +0 -87
  225. package/dist/modules/indexer/module.js +0 -293
  226. package/dist/modules/indexer/project-profile.js +0 -184
  227. package/dist/modules/indexer/symbols.js +0 -189
  228. package/dist/modules/indexer/walker.js +0 -285
  229. package/dist/modules/lsp/check-tool.js +0 -61
  230. package/dist/modules/lsp/client.js +0 -406
  231. package/dist/modules/lsp/command.js +0 -53
  232. package/dist/modules/lsp/config.js +0 -189
  233. package/dist/modules/lsp/index.js +0 -4
  234. package/dist/modules/lsp/module.js +0 -295
  235. package/dist/modules/lsp/probe.js +0 -86
  236. package/dist/modules/lsp/project-root.js +0 -69
  237. package/dist/modules/lsp/startup-check.js +0 -154
  238. package/dist/modules/lsp/types.js +0 -1
  239. package/dist/modules/mcp/client.js +0 -445
  240. package/dist/modules/mcp/index.js +0 -4
  241. package/dist/modules/mcp/module.js +0 -295
  242. package/dist/modules/mcp/registry.js +0 -20
  243. package/dist/modules/memory/index.js +0 -2
  244. package/dist/modules/memory/module.js +0 -101
  245. package/dist/modules/memory/search.js +0 -45
  246. package/dist/modules/memory/store.js +0 -107
  247. package/dist/modules/onboarding/init.js +0 -47
  248. package/dist/modules/onboarding/meet.js +0 -30
  249. package/dist/modules/onboarding/mode.js +0 -30
  250. package/dist/modules/onboarding/prompts.js +0 -43
  251. package/dist/modules/pipelines/engine.js +0 -70
  252. package/dist/modules/pipelines/index.js +0 -4
  253. package/dist/modules/pipelines/parser.js +0 -59
  254. package/dist/modules/pipelines/template.js +0 -18
  255. package/dist/modules/plugins/builtin/lint-on-write.js +0 -377
  256. package/dist/modules/plugins/builtin/notify.js +0 -11
  257. package/dist/modules/plugins/index.js +0 -2
  258. package/dist/modules/plugins/loader.js +0 -85
  259. package/dist/modules/plugins/manager.js +0 -244
  260. package/dist/modules/plugins/types.js +0 -1
  261. package/dist/modules/pricing/index.js +0 -70
  262. package/dist/modules/pricing/prices.js +0 -147
  263. package/dist/modules/processes/detect.js +0 -34
  264. package/dist/modules/processes/index.js +0 -4
  265. package/dist/modules/processes/kill-tree.js +0 -52
  266. package/dist/modules/processes/registry.js +0 -294
  267. package/dist/modules/processes/runner.js +0 -23
  268. package/dist/modules/providers/cache.js +0 -23
  269. package/dist/modules/providers/capabilities.js +0 -28
  270. package/dist/modules/providers/create.js +0 -21
  271. package/dist/modules/providers/factory.js +0 -28
  272. package/dist/modules/providers/fallback.js +0 -81
  273. package/dist/modules/providers/health.js +0 -47
  274. package/dist/modules/providers/index.js +0 -6
  275. package/dist/modules/providers/manager.js +0 -207
  276. package/dist/modules/providers/naming.js +0 -15
  277. package/dist/modules/providers/preflight.js +0 -71
  278. package/dist/modules/providers/presets.js +0 -232
  279. package/dist/modules/providers/registry.js +0 -27
  280. package/dist/modules/providers/types.js +0 -1
  281. package/dist/modules/reasoning/policy.js +0 -42
  282. package/dist/modules/reasoning/probe.js +0 -116
  283. package/dist/modules/registry.js +0 -48
  284. package/dist/modules/security/audit-log.js +0 -119
  285. package/dist/modules/security/audit-notifier.js +0 -267
  286. package/dist/modules/security/command-validator.js +0 -272
  287. package/dist/modules/security/content-scanner.js +0 -53
  288. package/dist/modules/security/data-sanitizer.js +0 -82
  289. package/dist/modules/security/encryption.js +0 -216
  290. package/dist/modules/security/index.js +0 -15
  291. package/dist/modules/security/network-validator.js +0 -236
  292. package/dist/modules/security/path-validator.js +0 -261
  293. package/dist/modules/security/protected-paths.js +0 -73
  294. package/dist/modules/security/rate-limiter.js +0 -98
  295. package/dist/modules/security/security-policies.js +0 -499
  296. package/dist/modules/security/session-encryption.js +0 -182
  297. package/dist/modules/security/session-isolation.js +0 -75
  298. package/dist/modules/session/auto-name.js +0 -63
  299. package/dist/modules/session/export.js +0 -98
  300. package/dist/modules/session/index.js +0 -4
  301. package/dist/modules/session/manager.js +0 -234
  302. package/dist/modules/session/module.js +0 -33
  303. package/dist/modules/session/store.js +0 -295
  304. package/dist/modules/session/types.js +0 -1
  305. package/dist/modules/setup/answers.js +0 -35
  306. package/dist/modules/setup/apply.js +0 -79
  307. package/dist/modules/setup/discovery.js +0 -72
  308. package/dist/modules/skills/index.js +0 -3
  309. package/dist/modules/skills/loader.js +0 -86
  310. package/dist/modules/skills/matcher.js +0 -27
  311. package/dist/modules/skills/module.js +0 -141
  312. package/dist/modules/types.js +0 -1
  313. package/dist/modules/updater/changelog-reader.js +0 -93
  314. package/dist/modules/updater/checker.js +0 -101
  315. package/dist/modules/updater/dev-detect.js +0 -18
  316. package/dist/modules/updater/index.js +0 -4
  317. package/dist/modules/updater/module.js +0 -129
  318. package/dist/modules/user-profile/compressor.js +0 -18
  319. package/dist/modules/user-profile/index.js +0 -2
  320. package/dist/modules/user-profile/profile.js +0 -77
  321. package/dist/modules/webui/answer-api.js +0 -29
  322. package/dist/modules/webui/assets.js +0 -50
  323. package/dist/modules/webui/body.js +0 -21
  324. package/dist/modules/webui/commands-settings.js +0 -209
  325. package/dist/modules/webui/commands-shared.js +0 -60
  326. package/dist/modules/webui/commands.js +0 -174
  327. package/dist/modules/webui/config-api.js +0 -134
  328. package/dist/modules/webui/file-api.js +0 -202
  329. package/dist/modules/webui/forward.js +0 -159
  330. package/dist/modules/webui/history-api.js +0 -112
  331. package/dist/modules/webui/host-state.js +0 -60
  332. package/dist/modules/webui/i18n-api.js +0 -9
  333. package/dist/modules/webui/limits.js +0 -6
  334. package/dist/modules/webui/log-forward.js +0 -20
  335. package/dist/modules/webui/memory-commands.js +0 -64
  336. package/dist/modules/webui/model-cache.js +0 -18
  337. package/dist/modules/webui/module.js +0 -148
  338. package/dist/modules/webui/persist.js +0 -24
  339. package/dist/modules/webui/prompt-io.js +0 -97
  340. package/dist/modules/webui/providers-api.js +0 -337
  341. package/dist/modules/webui/providers-view.js +0 -56
  342. package/dist/modules/webui/reasoning-view.js +0 -15
  343. package/dist/modules/webui/run-agent.js +0 -81
  344. package/dist/modules/webui/server.js +0 -284
  345. package/dist/modules/webui/sessions-api.js +0 -178
  346. package/dist/modules/webui/settings-api.js +0 -561
  347. package/dist/modules/webui/setup-api.js +0 -201
  348. package/dist/modules/webui/state.js +0 -74
  349. package/dist/modules/webui/util.js +0 -261
  350. package/dist/output/bus.js +0 -37
  351. package/dist/output/channel.js +0 -285
  352. package/dist/output/format.js +0 -15
  353. package/dist/output/index.js +0 -8
  354. package/dist/output/json-sink.js +0 -24
  355. package/dist/output/machine.js +0 -9
  356. package/dist/output/session-sink.js +0 -27
  357. package/dist/output/types.js +0 -1
  358. package/dist/tools/approve.js +0 -41
  359. package/dist/tools/attach-image.js +0 -102
  360. package/dist/tools/auto-fixer.js +0 -180
  361. package/dist/tools/auto-tags.js +0 -83
  362. package/dist/tools/bash.js +0 -649
  363. package/dist/tools/browser.js +0 -160
  364. package/dist/tools/chunk-query.js +0 -112
  365. package/dist/tools/create-dir.js +0 -60
  366. package/dist/tools/delete-file.js +0 -67
  367. package/dist/tools/download-file.js +0 -142
  368. package/dist/tools/edit-file.js +0 -136
  369. package/dist/tools/enable-tools.js +0 -59
  370. package/dist/tools/executor.js +0 -304
  371. package/dist/tools/file-info.js +0 -49
  372. package/dist/tools/filter-tools.js +0 -17
  373. package/dist/tools/glob-tool.js +0 -37
  374. package/dist/tools/grep-tool.js +0 -142
  375. package/dist/tools/hidden-tools-block.js +0 -37
  376. package/dist/tools/index.js +0 -88
  377. package/dist/tools/list-dir.js +0 -53
  378. package/dist/tools/load-skill.js +0 -51
  379. package/dist/tools/mcp-call.js +0 -80
  380. package/dist/tools/meet-done.js +0 -14
  381. package/dist/tools/move-file.js +0 -94
  382. package/dist/tools/path-utils.js +0 -108
  383. package/dist/tools/pipeline-run.js +0 -167
  384. package/dist/tools/preview.js +0 -2
  385. package/dist/tools/process-ids.js +0 -31
  386. package/dist/tools/process-kill.js +0 -33
  387. package/dist/tools/process-list.js +0 -38
  388. package/dist/tools/process-log.js +0 -49
  389. package/dist/tools/process-wait.js +0 -63
  390. package/dist/tools/prompt-io.js +0 -29
  391. package/dist/tools/question.js +0 -288
  392. package/dist/tools/read-file.js +0 -200
  393. package/dist/tools/recall.js +0 -124
  394. package/dist/tools/registry.js +0 -48
  395. package/dist/tools/remember.js +0 -72
  396. package/dist/tools/scope-check.js +0 -32
  397. package/dist/tools/scope-request.js +0 -96
  398. package/dist/tools/search-history.js +0 -88
  399. package/dist/tools/session-info.js +0 -46
  400. package/dist/tools/set-thinking.js +0 -75
  401. package/dist/tools/subagent.js +0 -257
  402. package/dist/tools/syntax-validator.js +0 -379
  403. package/dist/tools/types.js +0 -1
  404. package/dist/tools/user-input.js +0 -134
  405. package/dist/tools/web-browse.js +0 -93
  406. package/dist/tools/web-fetch.js +0 -108
  407. package/dist/tools/web-search.js +0 -107
  408. package/dist/tools/write-file.js +0 -128
  409. package/dist/ui/action-log.js +0 -13
  410. package/dist/ui/box.js +0 -78
  411. package/dist/ui/colors.js +0 -6
  412. package/dist/ui/diff.js +0 -189
  413. package/dist/ui/index.js +0 -7
  414. package/dist/ui/line-editor.js +0 -1083
  415. package/dist/ui/line-math.js +0 -98
  416. package/dist/ui/md-formatter.js +0 -322
  417. package/dist/ui/output.js +0 -19
  418. package/dist/ui/plan-view.js +0 -109
  419. package/dist/ui/renderer.js +0 -589
  420. package/dist/ui/spinner.js +0 -91
  421. package/dist/ui/table.js +0 -142
  422. package/dist/ui/theme.js +0 -143
  423. package/dist/utils/child-run.js +0 -20
  424. package/dist/utils/error.js +0 -4
  425. package/dist/utils/index.js +0 -6
  426. package/dist/utils/retry.js +0 -17
  427. package/dist/utils/sleep.js +0 -23
  428. package/dist/utils/truncate.js +0 -9
@@ -1,1218 +0,0 @@
1
- // Slash-команды REPL: /config, /model, /provider, сессии, сахар над mutateConfig.
2
- import { pc } from "../ui/colors";
3
- import { resolveVerbosity } from "../ui/theme";
4
- import { readMmaVersion } from "../core/version";
5
- import { renderTable } from "../ui/table";
6
- import { t, setLocale } from "../i18n/index";
7
- import { runSetup } from "./setup";
8
- import { applyAnswersToConfig } from "./setup-order";
9
- import { saveConfig } from "../config/config";
10
- import { HOSTED_BASE_URLS } from "../modules/providers/presets";
11
- import { providerNameTaken } from "../modules/providers/naming";
12
- import { activeProviderEndpoint } from "../modules/providers/manager";
13
- import { budgetBreakdownLines } from "../config/budget";
14
- import { setConfigValue, getConfigValue, resolveConfigKey, canonicalKeys, keysForGroup, configDefs, formatConfigValue, } from "../config/registry";
15
- import { formatExport, redactExport, sanitizeFileName, extensionFor, } from "../modules/session/export";
16
- import { getMessageText } from "../llm/provider";
17
- import { join, dirname } from "path";
18
- import { existsSync, writeFileSync, mkdirSync } from "fs";
19
- import { runMapAction } from "../modules/indexer/map-command";
20
- import { registerOnboardingCommands } from "./onboarding-commands";
21
- import { errMsg } from "../utils";
22
- import { globalExportsDir } from "../config/paths";
23
- import { registerLspCommands } from "./repl-commands-lsp";
24
- import { registerSkillCommands } from "./repl-commands-skills";
25
- const version = readMmaVersion();
26
- /** Группы команд для `/help` (general/agent/session/skill). */
27
- export const COMMAND_GROUPS = {
28
- help: "general",
29
- exit: "general",
30
- clear: "general",
31
- run: "general",
32
- image: "general",
33
- config: "agent",
34
- status: "agent",
35
- reasoning: "agent",
36
- verbose: "agent",
37
- provider: "agent",
38
- model: "agent",
39
- context: "agent",
40
- reload: "agent",
41
- wizard: "agent",
42
- meet: "agent",
43
- init: "agent",
44
- memory: "agent",
45
- sysprompt: "agent",
46
- map: "agent",
47
- lsp: "agent",
48
- security: "agent",
49
- sessions: "session",
50
- new: "session",
51
- resume: "session",
52
- rename: "session",
53
- delete: "session",
54
- export: "session",
55
- skill: "skill",
56
- plugins: "agent",
57
- };
58
- /** Регистрирует все команды REPL (builtin + mma + онбординг + сессии + скиллы). */
59
- export function registerAllCommands(ctx) {
60
- registerBuiltinCommands(ctx);
61
- registerMmaCommands(ctx);
62
- registerOnboardingCommands(ctx);
63
- registerSessionCommands(ctx);
64
- registerSkillCommands(ctx);
65
- }
66
- function registerBuiltinCommands(ctx) {
67
- ctx.registerCommand({
68
- name: "help",
69
- description: t("repl.help"),
70
- usage: t("repl.help_usage"),
71
- examples: ["/help", "/help config"],
72
- action: (args) => ctx.showHelp(args[0]),
73
- });
74
- ctx.registerCommand({
75
- name: "exit",
76
- description: t("repl.exit"),
77
- aliases: ["quit", "q"],
78
- usage: t("repl.exit_usage"),
79
- action: () => ctx.stop(),
80
- });
81
- ctx.registerCommand({
82
- name: "clear",
83
- description: t("repl.clear"),
84
- usage: t("repl.clear_usage"),
85
- action: () => {
86
- ctx.output.clearScreen();
87
- ctx.output.writeLine(pc.dim(t("repl.clear_hint")));
88
- },
89
- });
90
- }
91
- function registerRunCommands(ctx) {
92
- ctx.registerCommand({
93
- name: "run",
94
- description: t("repl.run"),
95
- usage: t("repl.run_usage"),
96
- action: async (args) => {
97
- if (args.length === 0) {
98
- ctx.output.writeLine(t("repl.run_usage"));
99
- return;
100
- }
101
- const prompt = args.join(" ");
102
- await ctx.runAgent(prompt);
103
- },
104
- });
105
- ctx.registerCommand({
106
- name: "image",
107
- description: t("repl.image"),
108
- aliases: ["img"],
109
- usage: t("repl.image_usage"),
110
- action: async (args) => {
111
- const source = args.join(" ");
112
- if (!source) {
113
- ctx.output.writeLine(t("repl.image_usage"));
114
- return;
115
- }
116
- try {
117
- const { loadFileAsDataUrl, loadUrlAsDataUrl, readClipboardImage } = await import("../llm/image-utils");
118
- const { existsSync } = await import("fs");
119
- const { resolve } = await import("path");
120
- let dataUrl;
121
- let label;
122
- if (source.toLowerCase() === "clipboard") {
123
- const clipBuf = await readClipboardImage();
124
- if (!clipBuf) {
125
- ctx.output.writeLine(pc.yellow(t("image.clipboard_empty")));
126
- return;
127
- }
128
- const { bufferToDataUrl } = await import("../llm/image-utils");
129
- const result = await bufferToDataUrl(clipBuf);
130
- dataUrl = result.dataUrl;
131
- label = "clipboard";
132
- }
133
- else if (source.startsWith("http://") || source.startsWith("https://")) {
134
- const result = await loadUrlAsDataUrl(source);
135
- dataUrl = result.dataUrl;
136
- label = source;
137
- }
138
- else {
139
- const absPath = resolve(process.cwd(), source);
140
- if (!existsSync(absPath)) {
141
- ctx.output.writeLine(pc.red(t("image.not_found", { path: source })), "stderr");
142
- return;
143
- }
144
- const result = await loadFileAsDataUrl(absPath);
145
- dataUrl = result.dataUrl;
146
- label = source;
147
- }
148
- const contextManager = ctx.agent.contextManager;
149
- if (!contextManager) {
150
- ctx.output.writeLine(pc.red(t("image.no_context")), "stderr");
151
- return;
152
- }
153
- contextManager.addPendingImage({
154
- type: "image_url",
155
- image_url: { url: dataUrl },
156
- });
157
- const sizeKb = Math.round((dataUrl.length * 3) / 4 / 1024);
158
- ctx.output.writeLine(pc.green(t("image.attached", { source: label, size: `${sizeKb} KB` })));
159
- }
160
- catch (err) {
161
- ctx.output.writeLine(pc.red(t("image.error", { message: err.message })), "stderr");
162
- }
163
- },
164
- });
165
- }
166
- const SUGAR_HINTS = {
167
- model: "/model use <name>",
168
- "provider.active": "/provider use <name>",
169
- contextWindow: "/context <size>",
170
- "contextBudget.systemPrompt": "/context system <share>",
171
- "contextBudget.responseReserve": "/context reserve <share>",
172
- showReasoning: "/reasoning show | hide",
173
- "reasoning.mode": "/reasoning level <level>",
174
- "ui.verbosity": "/verbose <level>",
175
- };
176
- function changeHint(def) {
177
- if (def.readOnly)
178
- return t("config.read_only_hint");
179
- return SUGAR_HINTS[def.key] ?? `/config ${def.key} <value>`;
180
- }
181
- function configValueHint(def) {
182
- if (!def)
183
- return "";
184
- switch (def.valueType) {
185
- case "enum":
186
- return t("config.hint_enum", { values: (def.enumValues ?? []).join(", ") });
187
- case "bool":
188
- return t("config.hint_bool");
189
- case "share":
190
- return t("config.hint_share");
191
- case "int":
192
- return t("config.hint_int", { min: String(def.min ?? 1) });
193
- default:
194
- return t("config.hint_string");
195
- }
196
- }
197
- function editDistance(a, b) {
198
- const dp = Array.from({ length: b.length + 1 }, (_, i) => i);
199
- for (let i = 1; i <= a.length; i++) {
200
- let prev = dp[0];
201
- dp[0] = i;
202
- for (let j = 1; j <= b.length; j++) {
203
- const tmp = dp[j];
204
- dp[j] = Math.min(dp[j] + 1, dp[j - 1] + 1, prev + (a[i - 1] === b[j - 1] ? 0 : 1));
205
- prev = tmp;
206
- }
207
- }
208
- return dp[b.length];
209
- }
210
- function nearestConfigKey(input) {
211
- const names = canonicalKeys();
212
- let best = null;
213
- for (const name of names) {
214
- const d = editDistance(input.toLowerCase(), name.toLowerCase());
215
- if (best === null || d < best.dist)
216
- best = { name, dist: d };
217
- }
218
- if (!best)
219
- return null;
220
- const threshold = Math.max(2, Math.floor(best.name.length / 3));
221
- return best.dist <= threshold ? best.name : null;
222
- }
223
- function renderConfigError(ctx, result) {
224
- const key = result.key ?? result.input;
225
- switch (result.reason) {
226
- case "unknown-key": {
227
- const suggestion = nearestConfigKey(result.input);
228
- const suffix = suggestion
229
- ? t("config.suggest", { name: suggestion })
230
- : t("config.valid_keys", { keys: canonicalKeys().join(", ") });
231
- ctx.output.writeLine(pc.yellow(t("config.unknown_key", { key: result.input, suggestion: suffix })), "stderr");
232
- return;
233
- }
234
- case "read-only":
235
- ctx.output.writeLine(pc.yellow(t("config.read_only", { key })), "stderr");
236
- return;
237
- case "range":
238
- ctx.output.writeLine(pc.yellow(t("config.range", { key })), "stderr");
239
- return;
240
- case "combined":
241
- ctx.output.writeLine(pc.yellow(t("config.combined")), "stderr");
242
- return;
243
- default:
244
- ctx.output.writeLine(pc.yellow(t("config.invalid_value", { key, hint: configValueHint(result.def) })), "stderr");
245
- }
246
- }
247
- function applyConfigSideEffects(ctx, result) {
248
- if (result.key === "ui.verbosity") {
249
- // Зеркало стартового правила (`main.ts`): структурные info-логи и диагностика
250
- // петли видимы в чате только в verbose.
251
- const verbose = result.value === "verbose";
252
- ctx.output.setSuppressInfoLogs(!verbose);
253
- ctx.output.setShowDiagnostics(verbose);
254
- }
255
- else if (result.key === "reasoning.mode") {
256
- ctx.agent.setReasoningLevel(result.value);
257
- }
258
- else if (result.key === "locale") {
259
- setLocale(result.value);
260
- }
261
- }
262
- function persistConfig(ctx) {
263
- const configPath = join(ctx.configDir, "config.json");
264
- saveConfig(ctx.config, configPath, dirname(configPath));
265
- }
266
- /**
267
- * Единый путь записи каждой мутации настроек. Сахарные команды тоже идут сюда,
268
- * чтобы валидация, сайд-эффекты, персист и reconfigure не расходились.
269
- */
270
- async function mutateConfig(ctx, key, raw) {
271
- const result = setConfigValue(ctx.config, key, raw);
272
- if (!result.ok)
273
- return result;
274
- applyConfigSideEffects(ctx, result);
275
- persistConfig(ctx);
276
- if (result.reconfigure)
277
- await ctx.agent.reconfigure(ctx.config);
278
- if (result.key === "locale")
279
- ctx.reregisterCommands();
280
- return result;
281
- }
282
- function reportSaved(ctx, result) {
283
- ctx.output.writeLine(pc.green(t("config.saved", { key: result.key })));
284
- }
285
- function rawFromValue(value) {
286
- if (typeof value === "boolean")
287
- return value ? "on" : "off";
288
- return String(value);
289
- }
290
- function printConfigTable(ctx, defs) {
291
- const list = defs ?? configDefs();
292
- const rows = list.map((def) => [
293
- def.key,
294
- formatConfigValue(def.get(ctx.config)),
295
- def.domain,
296
- changeHint(def),
297
- ]);
298
- ctx.output.writeLine(pc.bold(t("config.header")));
299
- for (const line of renderTable([
300
- t("config.col_setting"),
301
- t("config.col_value"),
302
- t("config.col_domain"),
303
- t("config.col_change"),
304
- ], rows)) {
305
- ctx.output.writeLine(line);
306
- }
307
- const meta = ctx.sessionManager?.getActiveMeta();
308
- if (meta) {
309
- ctx.output.writeLine(pc.dim(t("config.session_line", {
310
- name: meta.name,
311
- id: meta.id,
312
- count: String(meta.messageCount),
313
- })));
314
- }
315
- ctx.output.writeLine(pc.dim(t("config.usage_hint")));
316
- }
317
- function confirm(ctx, prompt) {
318
- return new Promise((resolve) => {
319
- void ctx.withExclusiveInput(async () => {
320
- await new Promise((done) => {
321
- ctx.rl.question(prompt, (answer) => {
322
- resolve(/^y(es)?$/i.test(answer.trim()));
323
- done();
324
- });
325
- });
326
- });
327
- });
328
- }
329
- async function runConfigReset(ctx, rest) {
330
- const snapshot = ctx.getConfigSnapshot();
331
- const yes = rest.includes("--yes");
332
- const all = rest.includes("--all");
333
- const target = rest.find((a) => !a.startsWith("--"));
334
- if (all) {
335
- const changed = canonicalKeys().filter((k) => {
336
- const def = resolveConfigKey(k);
337
- if (!def || !snapshot.has(k))
338
- return false;
339
- return rawFromValue(def.get(ctx.config)) !== rawFromValue(snapshot.get(k));
340
- });
341
- if (changed.length === 0) {
342
- ctx.output.writeLine(t("config.reset_none"));
343
- return;
344
- }
345
- if (!yes) {
346
- if (!process.stdin.isTTY) {
347
- ctx.output.writeLine(pc.yellow(t("config.reset_all_needs_yes")), "stderr");
348
- return;
349
- }
350
- const ok = await confirm(ctx, t("config.reset_all_confirm", { count: String(changed.length) }));
351
- if (!ok) {
352
- ctx.output.writeLine(t("config.reset_cancelled"));
353
- return;
354
- }
355
- }
356
- let anyReconfig = false;
357
- let localeChanged = false;
358
- for (const k of changed) {
359
- const result = setConfigValue(ctx.config, k, rawFromValue(snapshot.get(k)));
360
- if (result.ok) {
361
- applyConfigSideEffects(ctx, result);
362
- anyReconfig = anyReconfig || result.reconfigure;
363
- localeChanged = localeChanged || result.key === "locale";
364
- }
365
- }
366
- persistConfig(ctx);
367
- if (anyReconfig)
368
- await ctx.agent.reconfigure(ctx.config);
369
- if (localeChanged)
370
- ctx.reregisterCommands();
371
- ctx.output.writeLine(pc.green(t("config.reset_all_done", { count: String(changed.length) })));
372
- return;
373
- }
374
- if (!target) {
375
- ctx.output.writeLine(t("config.reset_usage"));
376
- return;
377
- }
378
- const def = resolveConfigKey(target);
379
- if (!def) {
380
- renderConfigError(ctx, { reason: "unknown-key", input: target });
381
- return;
382
- }
383
- if (def.readOnly || !snapshot.has(def.key)) {
384
- ctx.output.writeLine(t("config.reset_unchanged", { key: def.key }));
385
- return;
386
- }
387
- if (rawFromValue(def.get(ctx.config)) === rawFromValue(snapshot.get(def.key))) {
388
- ctx.output.writeLine(t("config.reset_unchanged", { key: def.key }));
389
- return;
390
- }
391
- const result = await mutateConfig(ctx, def.key, rawFromValue(snapshot.get(def.key)));
392
- if (!result.ok) {
393
- renderConfigError(ctx, result);
394
- return;
395
- }
396
- ctx.output.writeLine(pc.green(t("config.reset_ok", { key: result.key, value: result.display })));
397
- }
398
- function printReasoningStatus(ctx) {
399
- const display = ctx.config.showReasoning ? t("reasoning.on") : t("reasoning.off");
400
- const mode = ctx.config.reasoning?.mode ?? "auto";
401
- const auto = mode === "auto" ? t("reasoning.auto_on") : t("reasoning.auto_off");
402
- ctx.output.writeLine(t("reasoning.status", { display, level: mode, auto }));
403
- }
404
- function registerConfigCommands(ctx) {
405
- ctx.registerCommand({
406
- name: "config",
407
- description: t("repl.config"),
408
- usage: t("repl.config_usage"),
409
- examples: ["/config", "/config model", "/config reasoning.mode high", "/config reset ui.verbosity"],
410
- action: async (args) => {
411
- // Роутинг субкоманды `/config migrate`. Отдельная регистрация с пробелом в
412
- // имени недостижима: диспетчер режет ввод по пробелам, и "/config migrate"
413
- // всегда резолвился в plain "config".
414
- if ((args[0] ?? "").trim().toLowerCase() === "migrate") {
415
- return runConfigMigrate(ctx);
416
- }
417
- if (args.length === 0) {
418
- printConfigTable(ctx);
419
- return;
420
- }
421
- if (args[0] === "reset") {
422
- await runConfigReset(ctx, args.slice(1));
423
- return;
424
- }
425
- const name = args[0];
426
- if (args.length === 1) {
427
- const group = keysForGroup(name);
428
- if (group.length > 0) {
429
- printConfigTable(ctx, group);
430
- return;
431
- }
432
- const got = getConfigValue(ctx.config, name);
433
- if (!got.ok) {
434
- renderConfigError(ctx, got);
435
- return;
436
- }
437
- ctx.output.writeLine(`${got.key} = ${got.display}`);
438
- return;
439
- }
440
- const raw = args.slice(1).join(" ");
441
- const result = await mutateConfig(ctx, name, raw);
442
- if (!result.ok) {
443
- renderConfigError(ctx, result);
444
- return;
445
- }
446
- reportSaved(ctx, result);
447
- if (result.key === "model") {
448
- const known = ctx.knownModels();
449
- if (known.length > 0 && !known.includes(String(result.value))) {
450
- ctx.output.writeLine(pc.yellow(t("model.not_in_list", { name: String(result.value) })));
451
- }
452
- }
453
- },
454
- });
455
- ctx.registerCommand({
456
- name: "reasoning",
457
- description: t("repl.reasoning"),
458
- usage: t("repl.reasoning_usage"),
459
- examples: ["/reasoning", "/reasoning show", "/reasoning level high"],
460
- action: async (args) => {
461
- const sub = args[0]?.trim().toLowerCase();
462
- if (!sub) {
463
- printReasoningStatus(ctx);
464
- return;
465
- }
466
- if (sub === "show" || sub === "on" || sub === "hide" || sub === "off") {
467
- const on = sub === "show" || sub === "on";
468
- const result = await mutateConfig(ctx, "showReasoning", on ? "on" : "off");
469
- if (!result.ok) {
470
- renderConfigError(ctx, result);
471
- return;
472
- }
473
- ctx.output.writeLine(pc.green(t("reasoning.display_set", { state: on ? t("reasoning.on") : t("reasoning.off") })));
474
- return;
475
- }
476
- if (sub === "level") {
477
- const lvl = args[1]?.trim().toLowerCase();
478
- if (!lvl) {
479
- ctx.output.writeLine(t("repl.reasoning_usage"));
480
- return;
481
- }
482
- const result = await mutateConfig(ctx, "reasoning.mode", lvl);
483
- if (!result.ok) {
484
- renderConfigError(ctx, result);
485
- return;
486
- }
487
- ctx.output.writeLine(pc.green(t("repl.reasoning_level_set", { level: lvl })));
488
- if (lvl !== "auto")
489
- ctx.output.writeLine(pc.dim(t("reasoning.auto_off_hint")));
490
- return;
491
- }
492
- ctx.output.writeLine(pc.yellow(t("reasoning.unknown_sub", { sub })));
493
- ctx.output.writeLine(t("repl.reasoning_usage"));
494
- },
495
- });
496
- ctx.registerCommand({
497
- name: "verbose",
498
- description: t("repl.verbose"),
499
- usage: t("repl.verbose_usage"),
500
- examples: ["/verbose", "/verbose normal"],
501
- action: async (args) => {
502
- const level = args[0]?.trim().toLowerCase();
503
- if (!level) {
504
- ctx.output.writeLine(t("verbose.status", { level: resolveVerbosity(ctx.config.ui) }));
505
- return;
506
- }
507
- const result = await mutateConfig(ctx, "ui.verbosity", level);
508
- if (!result.ok) {
509
- renderConfigError(ctx, result);
510
- return;
511
- }
512
- ctx.output.writeLine(pc.green(t("repl.verbose_set", { level: result.display })));
513
- },
514
- });
515
- ctx.registerCommand({
516
- name: "status",
517
- description: t("repl.status"),
518
- usage: t("repl.status_usage"),
519
- action: () => {
520
- const providers = ctx.agent.listProviders();
521
- const active = providers.find((p) => p.active);
522
- const providerLabel = active ? active.label : ctx.config.provider.type;
523
- const parts = [ctx.config.model, providerLabel];
524
- const meta = ctx.sessionManager?.getActiveMeta();
525
- if (meta)
526
- parts.push(`${meta.name} (${meta.messageCount} ${t("repl.msgs")})`);
527
- parts.push(`${ctx.config.contextWindow} tok`);
528
- ctx.output.writeLine(parts.join(pc.dim(" · ")));
529
- },
530
- });
531
- ctx.registerCommand({
532
- name: "wizard",
533
- description: t("repl.wizard"),
534
- aliases: ["setup"],
535
- usage: t("repl.wizard_usage"),
536
- action: async () => {
537
- ctx.output.writeLine(pc.yellow(t("repl.wizard_running")));
538
- await ctx.withExclusiveInput(async () => {
539
- const answers = await runSetup(ctx.rl);
540
- const configPath = join(ctx.configDir, "config.json");
541
- applyAnswersToConfig(ctx.config, answers);
542
- saveConfig(ctx.config, configPath, dirname(configPath));
543
- await ctx.agent.reconfigure(ctx.config);
544
- ctx.output.writeLine(pc.green(t("cli.config_saved")));
545
- });
546
- },
547
- });
548
- ctx.registerCommand({
549
- name: "sysprompt",
550
- description: t("repl.sysprompt_desc"),
551
- usage: t("repl.sysprompt_usage"),
552
- examples: ["/sysprompt", "/sysprompt --full"],
553
- action: (args) => {
554
- const info = ctx.agent.getSystemPromptInfo();
555
- const full = args.includes("--full");
556
- ctx.output.writeLine(pc.bold(t("repl.sysprompt_tokens", { count: String(info.tokenCount) })));
557
- if (info.excluded.length > 0) {
558
- ctx.output.writeLine(pc.yellow(t("repl.excluded_blocks", { count: String(info.excluded.length) })));
559
- for (const e of info.excluded) {
560
- ctx.output.writeLine(pc.dim(` - ${e.slice(0, 80)}${e.length > 80 ? "..." : ""}`));
561
- }
562
- }
563
- if (full) {
564
- ctx.output.writeLine(pc.dim("─".repeat(60)));
565
- for (const line of info.text.split("\n")) {
566
- ctx.output.writeLine(line);
567
- }
568
- ctx.output.writeLine(pc.dim("─".repeat(60)));
569
- }
570
- else {
571
- ctx.output.writeLine(pc.dim(t("repl.sysprompt_full_hint")));
572
- }
573
- },
574
- });
575
- ctx.registerCommand({
576
- name: "map",
577
- description: t("repl.map"),
578
- usage: t("repl.map_usage"),
579
- action: async (args) => {
580
- const indexer = ctx.agent.getModule("indexer");
581
- if (!indexer) {
582
- ctx.output.writeLine(pc.yellow(t("indexer.not_indexed")));
583
- return;
584
- }
585
- const action = args[0] || "summary";
586
- const query = args.slice(1).join(" ");
587
- const result = await runMapAction(indexer, action, query);
588
- ctx.output.writeLine(result.output);
589
- },
590
- });
591
- }
592
- function registerProviderCommands(ctx) {
593
- const list = () => {
594
- const providers = ctx.agent.listProviders();
595
- if (providers.length === 0) {
596
- const endpoint = activeProviderEndpoint(ctx.config.provider);
597
- ctx.output.writeLine(`${t("repl.provider_current")} ${endpoint.type}`);
598
- ctx.output.writeLine(` ${endpoint.baseUrl}`);
599
- return;
600
- }
601
- ctx.output.writeLine(t("repl.provider_current"));
602
- for (const p of providers) {
603
- const marker = p.active ? pc.green("* ") : " ";
604
- ctx.output.writeLine(` ${marker}${p.label} (${pc.dim(p.type)}) ${pc.dim(p.baseUrl)}`);
605
- }
606
- };
607
- const use = async (args) => {
608
- const name = args[0];
609
- if (!name) {
610
- ctx.output.writeLine(t("repl.provider_usage"));
611
- return;
612
- }
613
- const result = await mutateConfig(ctx, "provider.active", name);
614
- if (!result.ok) {
615
- renderConfigError(ctx, result);
616
- return;
617
- }
618
- ctx.refreshModelCache();
619
- ctx.output.writeLine(pc.green(t("repl.provider_set", { name })));
620
- reportSaved(ctx, result);
621
- };
622
- const add = async (args) => {
623
- const flags = {};
624
- let name;
625
- for (let i = 0; i < args.length; i++) {
626
- const arg = args[i];
627
- if (arg.startsWith("--")) {
628
- const value = args[i + 1];
629
- if (value === undefined || value.startsWith("--")) {
630
- ctx.output.writeLine(pc.red(t("repl.provider_add_missing_value", { flag: arg })), "stderr");
631
- return;
632
- }
633
- flags[arg.slice(2)] = value;
634
- i++;
635
- }
636
- else if (name === undefined) {
637
- name = arg;
638
- }
639
- }
640
- if (!name) {
641
- ctx.output.writeLine(t("repl.provider_usage"));
642
- return;
643
- }
644
- for (const flag of ["priority", "context-window", "rpm", "parallel"]) {
645
- const v = flags[flag];
646
- if (v !== undefined && !Number.isFinite(Number(v))) {
647
- ctx.output.writeLine(pc.red(t("repl.provider_add_invalid_number", { flag: `--${flag}`, value: v })), "stderr");
648
- return;
649
- }
650
- }
651
- const entries = Array.isArray(ctx.config.provider.entries) ? ctx.config.provider.entries : [];
652
- if (entries.length === 0) {
653
- entries.push({
654
- type: ctx.config.provider.type,
655
- label: ctx.config.provider.type,
656
- baseUrl: ctx.config.provider.baseUrl,
657
- apiKey: ctx.config.provider.apiKey,
658
- });
659
- }
660
- const baseUrl = flags.url || HOSTED_BASE_URLS[name] || HOSTED_BASE_URLS[`opencode-${name}`] || "";
661
- if (!baseUrl) {
662
- ctx.output.writeLine(pc.red(t("cli.provider_no_url", { name })), "stderr");
663
- return;
664
- }
665
- if (providerNameTaken(entries, name)) {
666
- ctx.output.writeLine(pc.red(t("cli.provider_name_conflict", { name })), "stderr");
667
- return;
668
- }
669
- entries.push({
670
- type: name,
671
- label: name,
672
- baseUrl,
673
- apiKey: flags.key,
674
- ...(flags.priority !== undefined ? { priority: Number(flags.priority) } : {}),
675
- ...(flags["context-window"] !== undefined
676
- ? { contextWindow: Number(flags["context-window"]) }
677
- : {}),
678
- ...(flags.rpm !== undefined || flags.parallel !== undefined
679
- ? {
680
- rateLimits: {
681
- maxRequestsPerMinute: Number(flags.rpm ?? 0) || 60,
682
- maxParallelTasks: Number(flags.parallel ?? 0) || 1,
683
- },
684
- }
685
- : {}),
686
- });
687
- ctx.config.provider.entries = entries;
688
- ctx.config.provider.active = ctx.config.provider.active || ctx.config.provider.type;
689
- persistConfig(ctx);
690
- await ctx.agent.reconfigure(ctx.config);
691
- ctx.output.writeLine(pc.green(t("cli.provider_added", { name })));
692
- ctx.output.writeLine(t("repl.provider_switch_hint", { name }));
693
- };
694
- const handlers = {
695
- list,
696
- use,
697
- add,
698
- };
699
- ctx.registerCommand({
700
- name: "provider",
701
- description: t("repl.provider_list"),
702
- usage: t("repl.provider_usage"),
703
- examples: ["/provider list", "/provider use openrouter", "/provider add openai --key sk-..."],
704
- action: async (args) => {
705
- const subcmd = args[0];
706
- const handler = subcmd ? handlers[subcmd] : handlers.list;
707
- if (!handler) {
708
- ctx.output.writeLine(pc.yellow(t("repl.unknown_sub", { cmd: "provider", sub: subcmd })));
709
- ctx.output.writeLine(t("repl.provider_usage"));
710
- return;
711
- }
712
- await handler(args.slice(1));
713
- },
714
- });
715
- const listModels = async () => {
716
- ctx.output.writeLine(`${t("repl.model_current")} ${ctx.config.model}`);
717
- const { OpenAICompatProvider } = await import("../llm/openai-compat");
718
- const provider = new OpenAICompatProvider({
719
- model: ctx.config.model,
720
- baseUrl: ctx.config.provider.baseUrl,
721
- apiKey: ctx.config.provider.apiKey,
722
- contextWindow: ctx.config.contextWindow,
723
- });
724
- const { Spinner } = await import("../ui/spinner");
725
- const s = new Spinner({ channel: ctx.output });
726
- s.start(t("cli.fetching_models"));
727
- try {
728
- const models = await provider.listModels();
729
- s.stop();
730
- if (models.length > 0) {
731
- ctx.refreshModelCache();
732
- ctx.output.writeLine(t("cli.available_models"));
733
- const { getCertMark } = await import("../modules/certification/manifest");
734
- for (const m of models) {
735
- const marker = m === ctx.config.model ? pc.green("* ") : " ";
736
- const mark = getCertMark(m, ctx.config.provider.baseUrl, version, process.cwd());
737
- const cert = mark === "certified" ? pc.green("✔") : mark === "stale" ? pc.yellow("○") : pc.dim("·");
738
- const label = mark === "certified"
739
- ? ` ${pc.green(t("cli.cert_label"))}`
740
- : mark === "stale"
741
- ? ` ${pc.yellow(t("cli.cert_stale_label"))}`
742
- : "";
743
- ctx.output.writeLine(` ${marker}${cert} ${m}${label}`);
744
- }
745
- }
746
- else {
747
- ctx.output.writeLine(t("cli.no_models_found"));
748
- }
749
- }
750
- catch (err) {
751
- s.stop();
752
- ctx.output.writeLine(t("cli.model_fetch_failed", { error: String(err) }), "stderr");
753
- }
754
- ctx.output.writeLine(t("cli.model_hint"));
755
- };
756
- const useModel = async (args) => {
757
- const name = args[0];
758
- if (!name) {
759
- ctx.output.writeLine(t("repl.model_usage"));
760
- return;
761
- }
762
- const result = await mutateConfig(ctx, "model", name);
763
- if (!result.ok) {
764
- renderConfigError(ctx, result);
765
- return;
766
- }
767
- ctx.output.writeLine(pc.green(t("repl.model_set", { name })));
768
- const known = ctx.knownModels();
769
- if (known.length > 0 && !known.includes(name)) {
770
- ctx.output.writeLine(pc.yellow(t("model.not_in_list", { name })));
771
- }
772
- reportSaved(ctx, result);
773
- };
774
- const modelHandlers = {
775
- list: listModels,
776
- use: useModel,
777
- };
778
- ctx.registerCommand({
779
- name: "model",
780
- description: t("repl.model_list"),
781
- usage: t("repl.model_usage"),
782
- examples: ["/model list", "/model use qwen/qwen3.5-9b"],
783
- action: async (args) => {
784
- const subcmd = args[0];
785
- const handler = subcmd ? modelHandlers[subcmd] : modelHandlers.list;
786
- if (!handler) {
787
- ctx.output.writeLine(pc.yellow(t("repl.unknown_sub", { cmd: "model", sub: subcmd })));
788
- ctx.output.writeLine(t("repl.model_usage"));
789
- return;
790
- }
791
- await handler(args.slice(1));
792
- },
793
- });
794
- ctx.registerCommand({
795
- name: "context",
796
- description: t("cli.manage_context"),
797
- usage: t("repl.context_usage"),
798
- examples: ["/context", "/context 64000", "/context system 10%", "/context reserve 0.2"],
799
- action: async (args) => {
800
- if (args.length === 0) {
801
- for (const line of budgetBreakdownLines(ctx.config))
802
- ctx.output.writeLine(line);
803
- ctx.output.writeLine(pc.dim(t("repl.context_usage")));
804
- return;
805
- }
806
- if (args[0] === "system" || args[0] === "reserve") {
807
- const raw = args[1];
808
- if (!raw) {
809
- ctx.output.writeLine(t("repl.context_usage"));
810
- return;
811
- }
812
- const key = args[0] === "system"
813
- ? "contextBudget.systemPrompt"
814
- : "contextBudget.responseReserve";
815
- const result = await mutateConfig(ctx, key, raw);
816
- if (!result.ok) {
817
- renderConfigError(ctx, result);
818
- return;
819
- }
820
- ctx.output.writeLine(pc.green(t("cli.context_fraction_set", { key: args[0], value: result.display })));
821
- return;
822
- }
823
- if (!/^\d+$/.test(args[0])) {
824
- ctx.output.writeLine(pc.yellow(t("context.unknown_arg", { arg: args[0] })));
825
- ctx.output.writeLine(t("repl.context_usage"));
826
- return;
827
- }
828
- const result = await mutateConfig(ctx, "contextWindow", args[0]);
829
- if (!result.ok) {
830
- renderConfigError(ctx, result);
831
- return;
832
- }
833
- ctx.output.writeLine(pc.green(t("cli.context_set", { size: String(result.value) })));
834
- reportSaved(ctx, result);
835
- },
836
- });
837
- }
838
- function registerAgentCommands(ctx) {
839
- const securityStatus = () => {
840
- const s = ctx.config.security;
841
- const flag = (v) => (v ? t("reasoning.on") : t("reasoning.off"));
842
- const sep = pc.dim(" · ");
843
- ctx.output.writeLine(`security${sep}${flag(s?.enabled)}`);
844
- ctx.output.writeLine(`↳ bash ${flag(s?.bash.enabled)}${sep}paths ${flag(s?.paths.enabled)}${sep}network ${flag(s?.network.enabled)}`);
845
- ctx.output.writeLine(`↳ contentScan ${flag(s?.contentScan.enabled)}${sep}encryption ${flag(s?.sessionEncryption.enabled)}`);
846
- };
847
- const securityHandlers = {
848
- status: securityStatus,
849
- };
850
- ctx.registerCommand({
851
- name: "security",
852
- description: t("repl.security"),
853
- action: (args) => {
854
- const sub = args[0]?.trim().toLowerCase();
855
- const handler = sub ? securityHandlers[sub] : securityHandlers.status;
856
- if (!handler) {
857
- ctx.output.writeLine(pc.yellow(t("repl.unknown_sub", { cmd: "security", sub })));
858
- return;
859
- }
860
- handler();
861
- },
862
- });
863
- ctx.registerCommand({
864
- name: "reload",
865
- description: t("repl.reload"),
866
- usage: t("repl.reload_usage"),
867
- action: async () => {
868
- ctx.output.writeLine(pc.yellow(t("repl.reloading")));
869
- await ctx.reload();
870
- ctx.output.writeLine(pc.green(t("repl.reloaded")));
871
- ctx.output.writeLine(`${t("repl.model")} ${ctx.config.model}`);
872
- ctx.output.writeLine(`${t("repl.context")} ${ctx.config.contextWindow}`);
873
- const endpoint = activeProviderEndpoint(ctx.config.provider);
874
- ctx.output.writeLine(`${t("repl.provider")} ${endpoint.type} @ ${endpoint.baseUrl}`);
875
- },
876
- });
877
- ctx.registerCommand({
878
- name: "plugins",
879
- description: t("repl.plugins"),
880
- usage: t("repl.plugins_usage"),
881
- action: (args) => {
882
- if (!ctx.pluginManager) {
883
- ctx.output.writeLine(t("cli.plugins.none"));
884
- return;
885
- }
886
- const showAll = args.includes("--all");
887
- const infos = ctx.pluginManager.getPluginInfos();
888
- const filtered = showAll ? infos : infos.filter(({ plugin }) => !plugin.isBuiltin);
889
- if (filtered.length === 0) {
890
- ctx.output.writeLine(t("cli.plugins.none"));
891
- return;
892
- }
893
- const mmaVersion = version;
894
- ctx.output.writeLine(t("cli.plugins.header", {
895
- count: String(filtered.length),
896
- mma: mmaVersion,
897
- }));
898
- for (const { plugin, source } of filtered) {
899
- const v = plugin.version || "-";
900
- const origin = source || "builtin";
901
- const mark = plugin.isBuiltin ? t("cli.plugins.builtin_mark") : " ";
902
- ctx.output.writeLine(` ${mark} ${plugin.name} v${v} [${origin}]`);
903
- }
904
- if (!showAll) {
905
- const builtinCount = infos.filter(({ plugin }) => plugin.isBuiltin).length;
906
- if (builtinCount > 0) {
907
- ctx.output.writeLine(pc.dim(` ${t("repl.plugins_hidden", { count: String(builtinCount) })}`));
908
- }
909
- }
910
- },
911
- });
912
- }
913
- function registerMmaCommands(ctx) {
914
- registerRunCommands(ctx);
915
- registerConfigCommands(ctx);
916
- registerProviderCommands(ctx);
917
- registerAgentCommands(ctx);
918
- registerLspCommands(ctx);
919
- }
920
- function registerSessionCommands(ctx) {
921
- if (!ctx.sessionManager)
922
- return;
923
- ctx.registerCommand({
924
- name: "sessions",
925
- description: t("repl.sessions"),
926
- aliases: ["ls"],
927
- usage: t("repl.sessions_usage"),
928
- action: (args) => {
929
- if (args[0] === "prune") {
930
- const dry = args.includes("--dry-run");
931
- const active = ctx.sessionManager.getActive();
932
- const candidates = ctx.sessionManager.list().filter((s) => s.id !== active && ctx.sessionManager.isEmptySession(s.id));
933
- if (candidates.length === 0) {
934
- ctx.output.writeLine(t("session.prune_empty"));
935
- return;
936
- }
937
- if (!dry)
938
- ctx.sessionManager.pruneEmpty(active ?? undefined);
939
- ctx.output.writeLine(t(dry ? "session.prune_dry" : "session.pruned", { n: candidates.length }));
940
- for (const s of candidates) {
941
- ctx.output.writeLine(pc.dim(` ${s.id.slice(0, 12)} ${s.name}`));
942
- }
943
- return;
944
- }
945
- const sessions = ctx.sessionManager.list();
946
- const active = ctx.sessionManager.getActive();
947
- if (sessions.length === 0) {
948
- ctx.output.writeLine(t("session.no_sessions_hint"));
949
- return;
950
- }
951
- const rows = sessions.map((s) => [
952
- s.id === active ? pc.green("●") : "",
953
- s.id.slice(0, 12),
954
- s.name,
955
- s.updatedAt.slice(0, 19).replace("T", " "),
956
- String(s.messageCount),
957
- ]);
958
- for (const line of renderTable([
959
- t("session.col_active"),
960
- t("session.col_id"),
961
- t("session.col_name"),
962
- t("session.col_updated"),
963
- t("session.col_msgs"),
964
- ], rows)) {
965
- ctx.output.writeLine(line);
966
- }
967
- ctx.output.writeLine(pc.dim(`\n ${t("repl.resume_hint")}`));
968
- },
969
- });
970
- ctx.registerCommand({
971
- name: "new",
972
- description: t("repl.new"),
973
- aliases: ["create"],
974
- usage: t("repl.new_usage"),
975
- action: (args) => {
976
- const name = args.join(" ") || undefined;
977
- const meta = ctx.sessionManager.create(name);
978
- ctx.agent.clearContext();
979
- // План следует за сессией: новая — без плана, трекер сбрасывается.
980
- const exec = ctx.agent.getModule("execution");
981
- try {
982
- exec?.switchSession(meta.id);
983
- }
984
- catch {
985
- // fail-open: сессия создана, план остался как был
986
- }
987
- ctx.output.clearScreen();
988
- ctx.output.writeLine(`${t("session.created", { name: meta.name })} (${pc.dim(meta.id.slice(0, 12))})`);
989
- ctx.output.writeLine(pc.dim(` ${t("session.chat_cleared")}\n`));
990
- },
991
- });
992
- ctx.registerCommand({
993
- name: "resume",
994
- description: t("repl.resume"),
995
- aliases: ["switch"],
996
- usage: t("repl.resume_usage"),
997
- examples: ["/resume", "/resume my-session"],
998
- action: (args) => {
999
- const query = args.join(" ");
1000
- const sessions = ctx.sessionManager.list();
1001
- if (!query) {
1002
- ctx.output.writeLine(pc.dim(t("session.available")));
1003
- const active = ctx.sessionManager.getActive();
1004
- for (const s of sessions) {
1005
- const marker = s.id === active ? pc.green(" *") : " ";
1006
- ctx.output.writeLine(pc.dim(` ${marker} ${s.id.slice(0, 12)} ${s.name}`));
1007
- }
1008
- ctx.output.writeLine(pc.dim(`\n ${t("repl.resume_usage")}`));
1009
- return;
1010
- }
1011
- const match = sessions.find((s) => s.id === query ||
1012
- s.id.startsWith(query) ||
1013
- s.name.toLowerCase().includes(query.toLowerCase()));
1014
- if (!match) {
1015
- ctx.output.writeLine(t("session.no_match", { query }));
1016
- return;
1017
- }
1018
- ctx.sessionManager.setActive(match.id);
1019
- const history = ctx.sessionManager.loadHistory();
1020
- ctx.agent.setContext(history);
1021
- // План следует за сессией: трекер переключается на план этой сессии
1022
- // (или пустеет, если у неё плана нет).
1023
- const exec = ctx.agent.getModule("execution");
1024
- let planLine = null;
1025
- try {
1026
- exec?.switchSession(match.id);
1027
- planLine = exec?.getPlanSummary() ?? null;
1028
- }
1029
- catch {
1030
- // fail-open: история загружена, план остался как был
1031
- }
1032
- ctx.output.clearScreen();
1033
- ctx.output.writeLine(pc.bold(pc.green(t("session.resumed", { name: match.name }))) +
1034
- " " +
1035
- pc.dim(`(${match.id.slice(0, 12)})`) +
1036
- " — " +
1037
- match.messageCount +
1038
- " " +
1039
- t("repl.msgs"));
1040
- ctx.output.writeLine(pc.dim("─".repeat(50)));
1041
- if (history.length === 0) {
1042
- ctx.output.writeLine(pc.dim(t("session.no_history")));
1043
- }
1044
- else {
1045
- ctx.output.writeLine(pc.dim(t("session.chat_history")));
1046
- ctx.output.writeLine("");
1047
- for (const msg of history) {
1048
- if (msg.role === "user") {
1049
- ctx.output.writeLine(pc.cyan(`${t("session.user_label")}:`));
1050
- ctx.output.writeLine(getMessageText(msg.content));
1051
- ctx.output.writeLine("");
1052
- }
1053
- else if (msg.role === "assistant") {
1054
- ctx.output.writeLine(pc.green(`${t("session.assistant_label")}:`));
1055
- ctx.output.writeLine(getMessageText(msg.content));
1056
- ctx.output.writeLine("");
1057
- }
1058
- }
1059
- }
1060
- ctx.output.writeLine(pc.dim("─".repeat(50)));
1061
- ctx.output.writeLine(pc.dim(` ${t("session.chat_loaded")}`));
1062
- ctx.output.writeLine(pc.dim(` ◇ ${planLine ?? t("plan.no_active")}`));
1063
- },
1064
- });
1065
- ctx.registerCommand({
1066
- name: "rename",
1067
- description: t("repl.rename"),
1068
- usage: t("repl.rename_usage"),
1069
- action: (args) => {
1070
- const name = args.join(" ");
1071
- if (!name) {
1072
- ctx.output.writeLine(t("repl.rename_usage"));
1073
- return;
1074
- }
1075
- const active = ctx.sessionManager.getActive();
1076
- if (!active) {
1077
- ctx.output.writeLine(t("session.no_active"));
1078
- return;
1079
- }
1080
- ctx.sessionManager.rename(active, name);
1081
- ctx.output.writeLine(t("session.renamed", { name }));
1082
- },
1083
- });
1084
- ctx.registerCommand({
1085
- name: "delete",
1086
- description: t("repl.delete"),
1087
- aliases: ["rm"],
1088
- usage: t("repl.delete_usage"),
1089
- action: (args) => {
1090
- const query = args[0];
1091
- if (!query) {
1092
- ctx.output.writeLine(t("repl.delete_usage"));
1093
- return;
1094
- }
1095
- const sessions = ctx.sessionManager.list();
1096
- const match = sessions.find((s) => s.id === query || s.id.startsWith(query));
1097
- if (!match) {
1098
- ctx.output.writeLine(t("session.no_match", { query }));
1099
- return;
1100
- }
1101
- ctx.sessionManager.delete(match.id);
1102
- // План следует за сессией: слот удалённой сессии не оставляем мусором.
1103
- try {
1104
- ctx.agent
1105
- .getModule("execution")
1106
- ?.forgetSession(match.id);
1107
- }
1108
- catch {
1109
- /* best-effort */
1110
- }
1111
- ctx.output.writeLine(`${t("session.deleted", { id: match.id })}: ${match.name}`);
1112
- },
1113
- });
1114
- ctx.registerCommand({
1115
- name: "export",
1116
- description: t("repl.export"),
1117
- usage: t("repl.export_usage"),
1118
- examples: [
1119
- "/export",
1120
- "/export my-session --format md",
1121
- "/export --format json --out -",
1122
- ],
1123
- action: async (args) => {
1124
- let format = "md";
1125
- let out;
1126
- let redact = true;
1127
- let compact = false;
1128
- const positional = [];
1129
- for (let i = 0; i < args.length; i++) {
1130
- const a = args[i];
1131
- if (a === "--format") {
1132
- const v = args[++i];
1133
- if (!v) {
1134
- ctx.output.writeLine(t("export.missing_value", { flag: a }));
1135
- return;
1136
- }
1137
- format = v;
1138
- }
1139
- else if (a === "--out") {
1140
- const v = args[++i];
1141
- if (v === undefined) {
1142
- ctx.output.writeLine(t("export.missing_value", { flag: a }));
1143
- return;
1144
- }
1145
- out = v;
1146
- }
1147
- else if (a === "--no-redact") {
1148
- redact = false;
1149
- }
1150
- else if (a === "--compact") {
1151
- compact = true;
1152
- }
1153
- else {
1154
- positional.push(a);
1155
- }
1156
- }
1157
- if (format !== "md" && format !== "json" && format !== "jsonl") {
1158
- ctx.output.writeLine(pc.yellow(t("export.invalid_format", { format })), "stderr");
1159
- return;
1160
- }
1161
- const query = positional.join(" ");
1162
- const sessions = ctx.sessionManager.list();
1163
- const match = query
1164
- ? sessions.find((s) => s.id === query ||
1165
- s.id.startsWith(query) ||
1166
- s.name.toLowerCase().includes(query.toLowerCase()))
1167
- : sessions.find((s) => s.id === ctx.sessionManager.getActive());
1168
- if (!match) {
1169
- ctx.output.writeLine(query ? t("session.no_match", { query }) : t("session.no_active"));
1170
- return;
1171
- }
1172
- const messages = ctx.sessionManager.getHistory(match.id);
1173
- const log = ctx.sessionManager.loadSessionLog(match.id);
1174
- if (format === "jsonl" ? log.length === 0 : messages.length === 0) {
1175
- ctx.output.writeLine(pc.yellow(t("export.empty")));
1176
- return;
1177
- }
1178
- const text = redactExport(formatExport({ meta: match, messages, log }, format, { compact }), redact);
1179
- if (out === "-") {
1180
- ctx.output.writeLine(text);
1181
- return;
1182
- }
1183
- const baseDir = out ? dirname(out) : globalExportsDir();
1184
- const path = out ?? join(baseDir, `${sanitizeFileName(match.name)}-${match.id.slice(0, 8)}.${extensionFor(format)}`);
1185
- try {
1186
- mkdirSync(baseDir, { recursive: true });
1187
- writeFileSync(path, text, "utf-8");
1188
- }
1189
- catch (e) {
1190
- ctx.output.writeLine(pc.red(t("export.write_failed", { error: errMsg(e) })), "stderr");
1191
- return;
1192
- }
1193
- ctx.output.writeLine(pc.green(t("export.written", { path })));
1194
- ctx.output.writeLine(pc.dim(redact ? t("export.redacted") : t("export.raw")));
1195
- },
1196
- });
1197
- }
1198
- async function runConfigMigrate(ctx) {
1199
- const { hasDomainFiles } = await import("../config/domains");
1200
- const { loadConfig: loadCfg } = await import("../config/config");
1201
- const configDir = ctx.configDir;
1202
- const configPath = join(configDir, "config.json");
1203
- if (hasDomainFiles(configDir)) {
1204
- ctx.output.writeLine(pc.yellow(t("config.migrate_no_legacy")));
1205
- return;
1206
- }
1207
- if (!existsSync(configPath)) {
1208
- ctx.output.writeLine(pc.yellow(t("config.migrate_no_legacy")));
1209
- return;
1210
- }
1211
- ctx.output.writeLine(t("config.migrate_start"));
1212
- const { config } = loadCfg({ configDir, projectConfigPath: join(configDir, ".mmrc") });
1213
- saveConfig(config, configPath, configDir);
1214
- const { renameSync, readdirSync } = await import("fs");
1215
- renameSync(configPath, `${configPath}.bak`);
1216
- const domainFiles = readdirSync(join(configDir, "config")).filter((f) => f.endsWith(".json"));
1217
- ctx.output.writeLine(pc.green(t("config.migrate_done", { count: String(domainFiles.length) })));
1218
- }