micro-models-agent 2.16.1 → 2.17.1

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 (427) hide show
  1. package/CHANGELOG.md +28 -0
  2. package/dist/assets/app.js +1 -314
  3. package/dist/assets/hljs.js +5 -1244
  4. package/dist/assets/index.html +11 -0
  5. package/dist/assets/js/api.js +1 -28
  6. package/dist/assets/js/core/menus.js +1 -0
  7. package/dist/assets/js/core/store/feed.js +1 -0
  8. package/dist/assets/js/core/store/index.js +1 -0
  9. package/dist/assets/js/core/store/session.js +1 -0
  10. package/dist/assets/js/core/store/settings.js +1 -0
  11. package/dist/assets/js/core/store/tabs.js +1 -0
  12. package/dist/assets/js/dialog.js +1 -105
  13. package/dist/assets/js/dom.js +1 -178
  14. package/dist/assets/js/feed/core.js +1 -0
  15. package/dist/assets/js/feed/history.js +1 -0
  16. package/dist/assets/js/feed/plan.js +1 -0
  17. package/dist/assets/js/feed/question.js +3 -0
  18. package/dist/assets/js/feed/sidebar.js +1 -0
  19. package/dist/assets/js/feed/stream.js +1 -0
  20. package/dist/assets/js/feed/turn.js +5 -0
  21. package/dist/assets/js/feed.js +1 -1250
  22. package/dist/assets/js/format.js +2 -122
  23. package/dist/assets/js/i18n.js +1 -46
  24. package/dist/assets/js/rail.js +1 -114
  25. package/dist/assets/js/session/cmdk.js +1 -0
  26. package/dist/assets/js/session/composer.js +1 -0
  27. package/dist/assets/js/session/sessions-menu.js +1 -0
  28. package/dist/assets/js/session/tabs.js +1 -0
  29. package/dist/assets/js/settings/controls.js +1 -0
  30. package/dist/assets/js/settings/editors.js +1 -0
  31. package/dist/assets/js/settings/form.js +1 -0
  32. package/dist/assets/js/settings/modal.js +1 -0
  33. package/dist/assets/js/settings/panels.js +1 -0
  34. package/dist/assets/js/settings/providers.js +1 -0
  35. package/dist/assets/js/settings/search.js +1 -0
  36. package/dist/assets/js/settings/subdialog.js +1 -0
  37. package/dist/assets/js/settings/write.js +1 -0
  38. package/dist/assets/js/settings.js +1 -1914
  39. package/dist/assets/js/sidebar/core.js +1 -0
  40. package/dist/assets/js/sidebar/lsp.js +2 -0
  41. package/dist/assets/js/sidebar/map.js +1 -0
  42. package/dist/assets/js/sidebar/state.js +1 -0
  43. package/dist/assets/js/sidebar/trace.js +5 -0
  44. package/dist/assets/js/sidebar.js +1 -705
  45. package/dist/assets/js/store.js +1 -82
  46. package/dist/assets/js/subdialog.js +1 -0
  47. package/dist/assets/md.js +1 -291
  48. package/dist/assets/setup.js +3 -816
  49. package/dist/assets/smd.js +29 -1665
  50. package/dist/assets/styles.css +1 -1598
  51. package/dist/certification/certifications.json +1 -494
  52. package/dist/i18n/en.json +1 -1851
  53. package/dist/i18n/ru.json +1 -1854
  54. package/dist/main.js +815 -55797
  55. package/dist/modules/browser/bridge-server.mjs +2 -252
  56. package/package.json +10 -5
  57. package/dist/assets/js/settings-controls.js +0 -452
  58. package/dist/assets/js/tabs.js +0 -867
  59. package/dist/cli/cache-line.js +0 -31
  60. package/dist/cli/command-suggest.js +0 -39
  61. package/dist/cli/commands.js +0 -781
  62. package/dist/cli/completer.js +0 -268
  63. package/dist/cli/index.js +0 -3
  64. package/dist/cli/json-payload.js +0 -32
  65. package/dist/cli/main.js +0 -346
  66. package/dist/cli/onboarding-commands.js +0 -126
  67. package/dist/cli/plugin-commands.js +0 -38
  68. package/dist/cli/relaunch.js +0 -40
  69. package/dist/cli/repl-commands-lsp.js +0 -75
  70. package/dist/cli/repl-commands-skills.js +0 -105
  71. package/dist/cli/repl-commands.js +0 -1218
  72. package/dist/cli/repl.js +0 -1238
  73. package/dist/cli/run-result.js +0 -38
  74. package/dist/cli/security-commands.js +0 -177
  75. package/dist/cli/setup-order.js +0 -6
  76. package/dist/cli/setup-prompt.js +0 -50
  77. package/dist/cli/setup.js +0 -161
  78. package/dist/cli/web-command.js +0 -98
  79. package/dist/config/budget.js +0 -48
  80. package/dist/config/config.js +0 -345
  81. package/dist/config/defaults.js +0 -197
  82. package/dist/config/domains.js +0 -135
  83. package/dist/config/env.js +0 -46
  84. package/dist/config/experts.js +0 -17
  85. package/dist/config/index.js +0 -5
  86. package/dist/config/paths.js +0 -56
  87. package/dist/config/redact.js +0 -44
  88. package/dist/config/registry-extra.js +0 -334
  89. package/dist/config/registry.js +0 -584
  90. package/dist/config/security.js +0 -212
  91. package/dist/config/timeouts.js +0 -74
  92. package/dist/config/types.js +0 -1
  93. package/dist/config/utils.js +0 -57
  94. package/dist/core/agent/artifact-progress.js +0 -59
  95. package/dist/core/agent/artifact-resolve.js +0 -79
  96. package/dist/core/agent/audit-gate.js +0 -53
  97. package/dist/core/agent/compaction.js +0 -89
  98. package/dist/core/agent/constants.js +0 -90
  99. package/dist/core/agent/context-log.js +0 -454
  100. package/dist/core/agent/context-renderer.js +0 -45
  101. package/dist/core/agent/critic-gate.js +0 -132
  102. package/dist/core/agent/hallucination-gate.js +0 -197
  103. package/dist/core/agent/loop-state.js +0 -68
  104. package/dist/core/agent/prefix-monitor.js +0 -101
  105. package/dist/core/agent/reasoning-resolver.js +0 -65
  106. package/dist/core/agent/token-tracker.js +0 -99
  107. package/dist/core/agent/tool-batch.js +0 -312
  108. package/dist/core/agent/tool-images.js +0 -18
  109. package/dist/core/agent/tool-output.js +0 -116
  110. package/dist/core/agent/tool-pairing.js +0 -60
  111. package/dist/core/agent-moe.js +0 -248
  112. package/dist/core/agent.js +0 -1299
  113. package/dist/core/bootstrap/agent-phase.js +0 -66
  114. package/dist/core/bootstrap/config-phase.js +0 -86
  115. package/dist/core/bootstrap/modules-phase.js +0 -269
  116. package/dist/core/bootstrap/provider-phase.js +0 -183
  117. package/dist/core/bootstrap/session-phase.js +0 -204
  118. package/dist/core/bootstrap/state.js +0 -94
  119. package/dist/core/bootstrap/workspace-phase.js +0 -115
  120. package/dist/core/bootstrap.js +0 -112
  121. package/dist/core/crash-handler.js +0 -62
  122. package/dist/core/environment.js +0 -224
  123. package/dist/core/host-plan.js +0 -43
  124. package/dist/core/host.js +0 -23
  125. package/dist/core/index.js +0 -3
  126. package/dist/core/prompt-builder.js +0 -95
  127. package/dist/core/prompt-overflow.js +0 -306
  128. package/dist/core/session-logger.js +0 -375
  129. package/dist/core/system-prompt.js +0 -117
  130. package/dist/core/types.js +0 -1
  131. package/dist/core/version.js +0 -28
  132. package/dist/core/web-host.js +0 -34
  133. package/dist/core/workspace.js +0 -80
  134. package/dist/i18n/index.js +0 -80
  135. package/dist/index.js +0 -30
  136. package/dist/llm/cache-usage.js +0 -76
  137. package/dist/llm/image-utils.js +0 -138
  138. package/dist/llm/index.js +0 -4
  139. package/dist/llm/llm-errors.js +0 -50
  140. package/dist/llm/model-loader.js +0 -86
  141. package/dist/llm/models-dev.js +0 -121
  142. package/dist/llm/openai-compat.js +0 -756
  143. package/dist/llm/orchestrator.js +0 -294
  144. package/dist/llm/provider-budget.js +0 -68
  145. package/dist/llm/provider-context.js +0 -233
  146. package/dist/llm/provider.js +0 -9
  147. package/dist/llm/response.js +0 -44
  148. package/dist/llm/stream-state.js +0 -26
  149. package/dist/llm/token-counter.js +0 -83
  150. package/dist/llm/types.js +0 -1
  151. package/dist/logger/app-logger.js +0 -212
  152. package/dist/logger/file-log.js +0 -160
  153. package/dist/logger/index.js +0 -2
  154. package/dist/migration/backup.js +0 -56
  155. package/dist/migration/detect.js +0 -61
  156. package/dist/migration/index.js +0 -3
  157. package/dist/modules/artifacts/store.js +0 -62
  158. package/dist/modules/browser/actions.js +0 -79
  159. package/dist/modules/browser/bridge-client.js +0 -203
  160. package/dist/modules/browser/bridge-path.js +0 -10
  161. package/dist/modules/browser/console-buffer.js +0 -37
  162. package/dist/modules/browser/cookie-store.js +0 -29
  163. package/dist/modules/browser/driver-types.js +0 -1
  164. package/dist/modules/browser/driver.js +0 -186
  165. package/dist/modules/browser/index.js +0 -9
  166. package/dist/modules/browser/module.js +0 -30
  167. package/dist/modules/browser/session.js +0 -322
  168. package/dist/modules/browser/snapshot.js +0 -154
  169. package/dist/modules/browser/types.js +0 -13
  170. package/dist/modules/certification/cli.js +0 -264
  171. package/dist/modules/certification/fact-checker.js +0 -90
  172. package/dist/modules/certification/loader.js +0 -127
  173. package/dist/modules/certification/manifest.js +0 -231
  174. package/dist/modules/certification/runner.js +0 -233
  175. package/dist/modules/certification/scenarios.js +0 -586
  176. package/dist/modules/certification/syntax-scenarios.js +0 -50
  177. package/dist/modules/certification/types.js +0 -1
  178. package/dist/modules/context/chunk-query.js +0 -122
  179. package/dist/modules/context/fact-extractor.js +0 -170
  180. package/dist/modules/context/history.js +0 -15
  181. package/dist/modules/context/index.js +0 -2
  182. package/dist/modules/context/manager.js +0 -482
  183. package/dist/modules/critic/client.js +0 -176
  184. package/dist/modules/critic/evidence.js +0 -81
  185. package/dist/modules/critic/provider.js +0 -45
  186. package/dist/modules/critic/tools.js +0 -78
  187. package/dist/modules/critic/types.js +0 -1
  188. package/dist/modules/execution/audit-runners.js +0 -206
  189. package/dist/modules/execution/auditor.js +0 -222
  190. package/dist/modules/execution/execution-plugin.js +0 -478
  191. package/dist/modules/execution/index.js +0 -8
  192. package/dist/modules/execution/input-from.js +0 -70
  193. package/dist/modules/execution/module.js +0 -891
  194. package/dist/modules/execution/moe-executor.js +0 -443
  195. package/dist/modules/execution/plan-actions.js +0 -642
  196. package/dist/modules/execution/plan-checks.js +0 -35
  197. package/dist/modules/execution/plan-coverage.js +0 -71
  198. package/dist/modules/execution/plan-persister.js +0 -46
  199. package/dist/modules/execution/plan-steps.js +0 -31
  200. package/dist/modules/execution/plan-store.js +0 -274
  201. package/dist/modules/execution/plan-tool.js +0 -249
  202. package/dist/modules/execution/plan-validator.js +0 -197
  203. package/dist/modules/execution/planner.js +0 -103
  204. package/dist/modules/execution/stuck-detector.js +0 -834
  205. package/dist/modules/execution/tracker.js +0 -92
  206. package/dist/modules/execution/transient-error.js +0 -30
  207. package/dist/modules/execution/types.js +0 -1
  208. package/dist/modules/execution/verifier.js +0 -343
  209. package/dist/modules/execution/windows-commands.js +0 -52
  210. package/dist/modules/hallucination/artifact-claim.js +0 -93
  211. package/dist/modules/hallucination/confidence.js +0 -81
  212. package/dist/modules/hallucination/consistency.js +0 -37
  213. package/dist/modules/hallucination/detector.js +0 -57
  214. package/dist/modules/hallucination/factual.js +0 -205
  215. package/dist/modules/hallucination/index.js +0 -6
  216. package/dist/modules/hallucination/js-identifiers.js +0 -261
  217. package/dist/modules/hallucination/llm-judge.js +0 -116
  218. package/dist/modules/hallucination/success-claim.js +0 -59
  219. package/dist/modules/index.js +0 -5
  220. package/dist/modules/indexer/cache.js +0 -88
  221. package/dist/modules/indexer/index.js +0 -4
  222. package/dist/modules/indexer/map-command.js +0 -33
  223. package/dist/modules/indexer/map-select.js +0 -87
  224. package/dist/modules/indexer/module.js +0 -293
  225. package/dist/modules/indexer/project-profile.js +0 -184
  226. package/dist/modules/indexer/symbols.js +0 -189
  227. package/dist/modules/indexer/walker.js +0 -285
  228. package/dist/modules/lsp/check-tool.js +0 -61
  229. package/dist/modules/lsp/client.js +0 -406
  230. package/dist/modules/lsp/command.js +0 -53
  231. package/dist/modules/lsp/config.js +0 -189
  232. package/dist/modules/lsp/index.js +0 -4
  233. package/dist/modules/lsp/module.js +0 -295
  234. package/dist/modules/lsp/probe.js +0 -86
  235. package/dist/modules/lsp/project-root.js +0 -69
  236. package/dist/modules/lsp/startup-check.js +0 -154
  237. package/dist/modules/lsp/types.js +0 -1
  238. package/dist/modules/mcp/client.js +0 -445
  239. package/dist/modules/mcp/index.js +0 -4
  240. package/dist/modules/mcp/module.js +0 -295
  241. package/dist/modules/mcp/registry.js +0 -20
  242. package/dist/modules/memory/index.js +0 -2
  243. package/dist/modules/memory/module.js +0 -101
  244. package/dist/modules/memory/search.js +0 -45
  245. package/dist/modules/memory/store.js +0 -107
  246. package/dist/modules/onboarding/init.js +0 -47
  247. package/dist/modules/onboarding/meet.js +0 -30
  248. package/dist/modules/onboarding/mode.js +0 -30
  249. package/dist/modules/onboarding/prompts.js +0 -43
  250. package/dist/modules/pipelines/engine.js +0 -70
  251. package/dist/modules/pipelines/index.js +0 -4
  252. package/dist/modules/pipelines/parser.js +0 -59
  253. package/dist/modules/pipelines/template.js +0 -18
  254. package/dist/modules/plugins/builtin/lint-on-write.js +0 -377
  255. package/dist/modules/plugins/builtin/notify.js +0 -11
  256. package/dist/modules/plugins/index.js +0 -2
  257. package/dist/modules/plugins/loader.js +0 -85
  258. package/dist/modules/plugins/manager.js +0 -244
  259. package/dist/modules/plugins/types.js +0 -1
  260. package/dist/modules/pricing/index.js +0 -70
  261. package/dist/modules/pricing/prices.js +0 -147
  262. package/dist/modules/processes/detect.js +0 -34
  263. package/dist/modules/processes/index.js +0 -4
  264. package/dist/modules/processes/kill-tree.js +0 -52
  265. package/dist/modules/processes/registry.js +0 -294
  266. package/dist/modules/processes/runner.js +0 -23
  267. package/dist/modules/providers/cache.js +0 -23
  268. package/dist/modules/providers/capabilities.js +0 -28
  269. package/dist/modules/providers/create.js +0 -21
  270. package/dist/modules/providers/factory.js +0 -28
  271. package/dist/modules/providers/fallback.js +0 -81
  272. package/dist/modules/providers/health.js +0 -47
  273. package/dist/modules/providers/index.js +0 -6
  274. package/dist/modules/providers/manager.js +0 -207
  275. package/dist/modules/providers/naming.js +0 -15
  276. package/dist/modules/providers/preflight.js +0 -71
  277. package/dist/modules/providers/presets.js +0 -232
  278. package/dist/modules/providers/registry.js +0 -27
  279. package/dist/modules/providers/types.js +0 -1
  280. package/dist/modules/reasoning/policy.js +0 -42
  281. package/dist/modules/reasoning/probe.js +0 -116
  282. package/dist/modules/registry.js +0 -48
  283. package/dist/modules/security/audit-log.js +0 -119
  284. package/dist/modules/security/audit-notifier.js +0 -267
  285. package/dist/modules/security/command-validator.js +0 -272
  286. package/dist/modules/security/content-scanner.js +0 -53
  287. package/dist/modules/security/data-sanitizer.js +0 -82
  288. package/dist/modules/security/encryption.js +0 -216
  289. package/dist/modules/security/index.js +0 -15
  290. package/dist/modules/security/network-validator.js +0 -236
  291. package/dist/modules/security/path-validator.js +0 -261
  292. package/dist/modules/security/protected-paths.js +0 -73
  293. package/dist/modules/security/rate-limiter.js +0 -98
  294. package/dist/modules/security/security-policies.js +0 -499
  295. package/dist/modules/security/session-encryption.js +0 -182
  296. package/dist/modules/security/session-isolation.js +0 -75
  297. package/dist/modules/session/auto-name.js +0 -63
  298. package/dist/modules/session/export.js +0 -98
  299. package/dist/modules/session/index.js +0 -4
  300. package/dist/modules/session/manager.js +0 -234
  301. package/dist/modules/session/module.js +0 -33
  302. package/dist/modules/session/store.js +0 -295
  303. package/dist/modules/session/types.js +0 -1
  304. package/dist/modules/setup/answers.js +0 -35
  305. package/dist/modules/setup/apply.js +0 -79
  306. package/dist/modules/setup/discovery.js +0 -72
  307. package/dist/modules/skills/index.js +0 -3
  308. package/dist/modules/skills/loader.js +0 -86
  309. package/dist/modules/skills/matcher.js +0 -27
  310. package/dist/modules/skills/module.js +0 -141
  311. package/dist/modules/types.js +0 -1
  312. package/dist/modules/updater/changelog-reader.js +0 -93
  313. package/dist/modules/updater/checker.js +0 -101
  314. package/dist/modules/updater/dev-detect.js +0 -18
  315. package/dist/modules/updater/index.js +0 -4
  316. package/dist/modules/updater/module.js +0 -129
  317. package/dist/modules/user-profile/compressor.js +0 -18
  318. package/dist/modules/user-profile/index.js +0 -2
  319. package/dist/modules/user-profile/profile.js +0 -77
  320. package/dist/modules/webui/answer-api.js +0 -29
  321. package/dist/modules/webui/assets.js +0 -50
  322. package/dist/modules/webui/body.js +0 -21
  323. package/dist/modules/webui/commands-settings.js +0 -209
  324. package/dist/modules/webui/commands-shared.js +0 -60
  325. package/dist/modules/webui/commands.js +0 -174
  326. package/dist/modules/webui/config-api.js +0 -134
  327. package/dist/modules/webui/file-api.js +0 -202
  328. package/dist/modules/webui/forward.js +0 -159
  329. package/dist/modules/webui/history-api.js +0 -112
  330. package/dist/modules/webui/host-state.js +0 -60
  331. package/dist/modules/webui/i18n-api.js +0 -9
  332. package/dist/modules/webui/limits.js +0 -6
  333. package/dist/modules/webui/log-forward.js +0 -20
  334. package/dist/modules/webui/memory-commands.js +0 -64
  335. package/dist/modules/webui/model-cache.js +0 -18
  336. package/dist/modules/webui/module.js +0 -148
  337. package/dist/modules/webui/persist.js +0 -24
  338. package/dist/modules/webui/prompt-io.js +0 -97
  339. package/dist/modules/webui/providers-api.js +0 -337
  340. package/dist/modules/webui/providers-view.js +0 -56
  341. package/dist/modules/webui/reasoning-view.js +0 -15
  342. package/dist/modules/webui/run-agent.js +0 -81
  343. package/dist/modules/webui/server.js +0 -284
  344. package/dist/modules/webui/sessions-api.js +0 -178
  345. package/dist/modules/webui/settings-api.js +0 -561
  346. package/dist/modules/webui/setup-api.js +0 -201
  347. package/dist/modules/webui/state.js +0 -74
  348. package/dist/modules/webui/util.js +0 -261
  349. package/dist/output/bus.js +0 -37
  350. package/dist/output/channel.js +0 -285
  351. package/dist/output/format.js +0 -15
  352. package/dist/output/index.js +0 -8
  353. package/dist/output/json-sink.js +0 -24
  354. package/dist/output/machine.js +0 -9
  355. package/dist/output/session-sink.js +0 -27
  356. package/dist/output/types.js +0 -1
  357. package/dist/tools/approve.js +0 -41
  358. package/dist/tools/attach-image.js +0 -102
  359. package/dist/tools/auto-fixer.js +0 -180
  360. package/dist/tools/auto-tags.js +0 -83
  361. package/dist/tools/bash.js +0 -649
  362. package/dist/tools/browser.js +0 -160
  363. package/dist/tools/chunk-query.js +0 -112
  364. package/dist/tools/create-dir.js +0 -60
  365. package/dist/tools/delete-file.js +0 -67
  366. package/dist/tools/download-file.js +0 -142
  367. package/dist/tools/edit-file.js +0 -136
  368. package/dist/tools/enable-tools.js +0 -59
  369. package/dist/tools/executor.js +0 -304
  370. package/dist/tools/file-info.js +0 -49
  371. package/dist/tools/filter-tools.js +0 -17
  372. package/dist/tools/glob-tool.js +0 -37
  373. package/dist/tools/grep-tool.js +0 -142
  374. package/dist/tools/hidden-tools-block.js +0 -37
  375. package/dist/tools/index.js +0 -88
  376. package/dist/tools/list-dir.js +0 -53
  377. package/dist/tools/load-skill.js +0 -51
  378. package/dist/tools/mcp-call.js +0 -80
  379. package/dist/tools/meet-done.js +0 -14
  380. package/dist/tools/move-file.js +0 -94
  381. package/dist/tools/path-utils.js +0 -108
  382. package/dist/tools/pipeline-run.js +0 -167
  383. package/dist/tools/preview.js +0 -2
  384. package/dist/tools/process-ids.js +0 -31
  385. package/dist/tools/process-kill.js +0 -33
  386. package/dist/tools/process-list.js +0 -38
  387. package/dist/tools/process-log.js +0 -49
  388. package/dist/tools/process-wait.js +0 -63
  389. package/dist/tools/prompt-io.js +0 -29
  390. package/dist/tools/question.js +0 -288
  391. package/dist/tools/read-file.js +0 -200
  392. package/dist/tools/recall.js +0 -124
  393. package/dist/tools/registry.js +0 -48
  394. package/dist/tools/remember.js +0 -72
  395. package/dist/tools/scope-check.js +0 -32
  396. package/dist/tools/scope-request.js +0 -96
  397. package/dist/tools/search-history.js +0 -88
  398. package/dist/tools/session-info.js +0 -46
  399. package/dist/tools/set-thinking.js +0 -75
  400. package/dist/tools/subagent.js +0 -257
  401. package/dist/tools/syntax-validator.js +0 -379
  402. package/dist/tools/types.js +0 -1
  403. package/dist/tools/user-input.js +0 -134
  404. package/dist/tools/web-browse.js +0 -93
  405. package/dist/tools/web-fetch.js +0 -108
  406. package/dist/tools/web-search.js +0 -107
  407. package/dist/tools/write-file.js +0 -128
  408. package/dist/ui/action-log.js +0 -13
  409. package/dist/ui/box.js +0 -78
  410. package/dist/ui/colors.js +0 -6
  411. package/dist/ui/diff.js +0 -189
  412. package/dist/ui/index.js +0 -7
  413. package/dist/ui/line-editor.js +0 -1083
  414. package/dist/ui/line-math.js +0 -98
  415. package/dist/ui/md-formatter.js +0 -322
  416. package/dist/ui/output.js +0 -19
  417. package/dist/ui/plan-view.js +0 -109
  418. package/dist/ui/renderer.js +0 -589
  419. package/dist/ui/spinner.js +0 -91
  420. package/dist/ui/table.js +0 -142
  421. package/dist/ui/theme.js +0 -143
  422. package/dist/utils/child-run.js +0 -20
  423. package/dist/utils/error.js +0 -4
  424. package/dist/utils/index.js +0 -6
  425. package/dist/utils/retry.js +0 -17
  426. package/dist/utils/sleep.js +0 -23
  427. package/dist/utils/truncate.js +0 -9
@@ -1,71 +0,0 @@
1
- // Покрытие плана: упомянутые в задаче файлы обязаны встречаться в шагах.
2
- import { stripUrls } from "../hallucination/js-identifiers";
3
- /**
4
- * Coverage-allow-list расширений. Считаются только реальные типы deliverable-
5
- * файлов: проза `e.g` / `i.e` (расширения `g`/`e`) за файлы не сойдёт, а
6
- * web/doc-результаты (`.css`, `.html`, `.scss`, `.md`) проверяются —
7
- * старый deny-list их молча пропускал.
8
- */
9
- const COVERAGE_EXT = new Set([
10
- // Код
11
- "ts", "tsx", "js", "jsx", "mjs", "cjs", "py", "rb", "go", "rs", "java",
12
- "kt", "kts", "cs", "php", "swift", "c", "cc", "cpp", "cxx", "h", "hpp",
13
- "lua", "pl", "sh", "bash", "zsh", "bat", "cmd", "ps1", "sql", "vue",
14
- "svelte", "dart", "scala", "clj",
15
- // web / доки / конфиги
16
- "css", "scss", "less", "html", "htm", "md", "mdx", "json", "json5",
17
- "toml", "yaml", "yml", "ini", "env", "txt",
18
- ]);
19
- const FILE_PATH_RE = /\b[\w./\\-]+\.[a-z]{1,6}\b/gi;
20
- /**
21
- * Извлекает пути файлов (с расширениями), упомянутые в формулировке задачи.
22
- * Проверяет, покрывает ли сгенерированный план каждый требуемый файл.
23
- */
24
- export function extractFilePaths(text) {
25
- if (!text)
26
- return [];
27
- const seen = new Set();
28
- const result = [];
29
- for (const m of stripUrls(text).matchAll(FILE_PATH_RE)) {
30
- const p = m[0].replace(/[.,;:)\]>]+$/g, "");
31
- if (!p)
32
- continue;
33
- // Требуем настоящее имя: непустой stem перед расширением в последнем
34
- // сегменте (сегменты `tsx/.ts` / `.env` — не "файлы").
35
- const slash = Math.max(p.lastIndexOf("/"), p.lastIndexOf("\\"));
36
- const last = slash >= 0 ? p.slice(slash + 1) : p;
37
- const dot = last.lastIndexOf(".");
38
- if (dot <= 0)
39
- continue;
40
- if (!COVERAGE_EXT.has(last.slice(dot + 1).toLowerCase()))
41
- continue;
42
- const key = p.toLowerCase();
43
- if (seen.has(key))
44
- continue;
45
- seen.add(key);
46
- result.push(p);
47
- }
48
- return result;
49
- }
50
- function basename(p) {
51
- const parts = p.split(/[/\\]/);
52
- return parts[parts.length - 1] ?? p;
53
- }
54
- /**
55
- * Сравнивает файловые требования задачи с описаниями шагов плана. Требование
56
- * "покрыто", если его путь (или basename) есть хоть в одном шаге. Возвращает
57
- * недостающие пути.
58
- */
59
- export function checkPlanCoverage(taskText, stepDescriptions) {
60
- const taskPaths = extractFilePaths(taskText);
61
- if (taskPaths.length === 0)
62
- return { missing: [] };
63
- const stepText = stepDescriptions.map((s) => s.toLowerCase()).join("\n");
64
- const missing = taskPaths.filter((p) => {
65
- const lower = p.toLowerCase();
66
- const base = basename(lower);
67
- // Шаг с полным относительным путём или его basename — засчитывается.
68
- return !stepText.includes(lower) && !stepText.includes(base);
69
- });
70
- return { missing };
71
- }
@@ -1,46 +0,0 @@
1
- import { readFileSync, writeFileSync, mkdirSync, existsSync } from "fs";
2
- import { join } from "path";
3
- export class PlanPersister {
4
- filePath;
5
- constructor(baseDir) {
6
- const mmaDir = join(baseDir, ".mma");
7
- if (!existsSync(mmaDir)) {
8
- mkdirSync(mmaDir, { recursive: true });
9
- }
10
- this.filePath = join(mmaDir, "plan.json");
11
- }
12
- save(plan) {
13
- const file = {
14
- id: plan.id,
15
- title: plan.title,
16
- steps: plan.steps,
17
- createdAt: plan.createdAt,
18
- updatedAt: new Date().toISOString(),
19
- baseDir: plan.baseDir,
20
- };
21
- writeFileSync(this.filePath, JSON.stringify(file, null, 2), "utf-8");
22
- }
23
- load() {
24
- if (!existsSync(this.filePath))
25
- return null;
26
- try {
27
- const raw = readFileSync(this.filePath, "utf-8");
28
- const file = JSON.parse(raw);
29
- return {
30
- id: file.id || "plan_legacy",
31
- title: file.title,
32
- steps: file.steps,
33
- createdAt: file.createdAt,
34
- baseDir: file.baseDir || process.cwd(),
35
- };
36
- }
37
- catch {
38
- return null;
39
- }
40
- }
41
- clear() {
42
- if (existsSync(this.filePath)) {
43
- writeFileSync(this.filePath, "", "utf-8");
44
- }
45
- }
46
- }
@@ -1,31 +0,0 @@
1
- /**
2
- * Авто-переключение шага плана на kind="delete".
3
- *
4
- * Два независимых механизма писали `step.kind = "delete"` и сами персистили
5
- * план:
6
- * - plan-tool: шаг помечается done, а все его дативные файлы подтверждённо
7
- * удалены (deliverable gate);
8
- * - execution-plugin: модель вызвала delete_file, и удалённый путь
9
- * пересекается с описанием шага.
10
- *
11
- * Здесь — единая точка, чтобы инвариант «сменить kind и сохранить план»
12
- * жил в одном месте и не расходился между авторами.
13
- *
14
- * @returns true, если шаг был переключён (и план сохранён); false, если
15
- * kind уже был "delete" — ничего не менялось.
16
- */
17
- export function switchStepKind(plan, step, kind, save) {
18
- if (step.kind === kind)
19
- return false;
20
- step.kind = kind;
21
- save(plan);
22
- return true;
23
- }
24
- /** Переключает шаг в kind="delete" (с сохранением плана). Возвращает, был ли сменён. */
25
- export function switchStepToDelete(plan, step, save) {
26
- return switchStepKind(plan, step, "delete", save);
27
- }
28
- /** Переключает шаг в kind="create" (с сохранением плана). Возвращает, был ли сменён. */
29
- export function switchStepToCreate(plan, step, save) {
30
- return switchStepKind(plan, step, "create", save);
31
- }
@@ -1,274 +0,0 @@
1
- // Персист планов: active/drafts/archive в .mma/plans + миграция legacy plan.json.
2
- import { readFileSync, writeFileSync, renameSync, mkdirSync, existsSync, readdirSync, rmSync } from "fs";
3
- import { join } from "path";
4
- import { Logger } from "../../logger/app-logger";
5
- import { errMsg } from "../../utils";
6
- import { projectMmaDir } from "../../config/paths";
7
- const log = new Logger("info", "plan-store");
8
- const LEGACY_FILE = "plan.json";
9
- function readPlanFile(path, fallbackBaseDir) {
10
- try {
11
- const raw = readFileSync(path, "utf-8");
12
- if (!raw.trim())
13
- return null;
14
- const parsed = JSON.parse(raw);
15
- if (!parsed || !Array.isArray(parsed.steps))
16
- return null;
17
- return {
18
- id: parsed.id || "plan_legacy",
19
- title: parsed.title || "Legacy plan",
20
- steps: parsed.steps,
21
- createdAt: parsed.createdAt || new Date().toISOString(),
22
- baseDir: parsed.baseDir || fallbackBaseDir,
23
- name: parsed.name,
24
- };
25
- }
26
- catch {
27
- return null;
28
- }
29
- }
30
- function writePlanFile(path, plan) {
31
- // Атомарная запись: крах посреди записи не оставит обрезанный файл плана
32
- // (readPlanFile молча вернёт null на битом JSON → активный план потерян).
33
- // Имя tmp уникально на процесс: два `mma` на общем `.mma/plans/active.json`
34
- // не уводят друг у друга `.tmp` (ENOENT).
35
- const tmpPath = `${path}.${process.pid}.${Math.random().toString(36).slice(2, 8)}.tmp`;
36
- try {
37
- writeFileSync(tmpPath, JSON.stringify(plan, null, 2), "utf-8");
38
- renameSync(tmpPath, path);
39
- }
40
- catch (e) {
41
- try {
42
- if (existsSync(tmpPath))
43
- rmSync(tmpPath);
44
- }
45
- catch {
46
- /* best-effort очистка */
47
- }
48
- log.warn(`failed to persist plan to ${path}`, { error: errMsg(e) });
49
- throw e;
50
- }
51
- }
52
- function listDir(dir, baseDir) {
53
- if (!existsSync(dir))
54
- return [];
55
- const files = readdirSync(dir).filter((f) => f.endsWith(".json"));
56
- return files.map((f) => readPlanFile(join(dir, f), baseDir)).filter((p) => p !== null);
57
- }
58
- function toMeta(plan, status) {
59
- return {
60
- id: plan.id,
61
- name: plan.name,
62
- title: plan.title,
63
- status,
64
- createdAt: plan.createdAt,
65
- stepCount: plan.steps.length,
66
- doneCount: plan.steps.filter((s) => s.status === "done" || s.status === "skipped").length,
67
- };
68
- }
69
- /** Хранилище планов: active/drafts/archive + миграция legacy-файла. */
70
- export class PlanStore {
71
- baseDir;
72
- plansDir;
73
- draftsDir;
74
- archiveDir;
75
- legacyPath;
76
- constructor(baseDir) {
77
- const mmaDir = projectMmaDir(baseDir);
78
- if (!existsSync(mmaDir))
79
- mkdirSync(mmaDir, { recursive: true });
80
- this.baseDir = baseDir;
81
- this.plansDir = join(mmaDir, "plans");
82
- this.draftsDir = join(this.plansDir, "drafts");
83
- this.archiveDir = join(this.plansDir, "archive");
84
- this.legacyPath = join(mmaDir, LEGACY_FILE);
85
- for (const dir of [this.plansDir, this.draftsDir, this.archiveDir]) {
86
- if (!existsSync(dir))
87
- mkdirSync(dir, { recursive: true });
88
- }
89
- }
90
- activePath() {
91
- return join(this.plansDir, "active.json");
92
- }
93
- /** Корень per-session слотов активного плана. */
94
- sessionsDir() {
95
- return join(this.plansDir, "sessions");
96
- }
97
- /** Проверяет id сессии как сегмент пути (без сепараторов/..). */
98
- sessionActivePath(sessionId) {
99
- if (!/^[A-Za-z0-9_-]+$/.test(sessionId)) {
100
- throw new Error(`invalid session id: ${sessionId}`);
101
- }
102
- return join(this.sessionsDir(), sessionId, "active.json");
103
- }
104
- // ---- Активный план сессии ----
105
- /** Сохраняет активный план сессии. */
106
- saveSessionActive(sessionId, plan) {
107
- const p = this.sessionActivePath(sessionId);
108
- const dir = join(this.sessionsDir(), sessionId);
109
- if (!existsSync(dir))
110
- mkdirSync(dir, { recursive: true });
111
- writePlanFile(p, plan);
112
- }
113
- /** Загружает активный план сессии. Пустая/новая сессия — null.
114
- * Без fallback на глобальный active.json: усыновление legacy-плана делает
115
- * явно только bootstrap (через switchSession-персист), иначе каждая новая
116
- * сессия наследовала бы чужой план. */
117
- loadSessionActive(sessionId) {
118
- const p = this.sessionActivePath(sessionId);
119
- if (!existsSync(p))
120
- return null;
121
- return readPlanFile(p, this.baseDir);
122
- }
123
- /** Убирает активный план сессии. Нет слота — no-op. */
124
- clearSessionActive(sessionId) {
125
- const p = this.sessionActivePath(sessionId);
126
- if (existsSync(p))
127
- rmSync(p, { force: true });
128
- }
129
- // ---- Активный план ----
130
- /** Сохраняет активный план. */
131
- saveActive(plan) {
132
- writePlanFile(this.activePath(), plan);
133
- }
134
- /** Загружает активный план (с миграцией legacy .mma/plan.json). Null, если нет. */
135
- loadActive() {
136
- const activePath = this.activePath();
137
- if (existsSync(activePath)) {
138
- const plan = readPlanFile(activePath, this.baseDir);
139
- if (plan)
140
- return plan;
141
- }
142
- // Миграция legacy: читаем .mma/plan.json и переносим в active
143
- if (existsSync(this.legacyPath)) {
144
- const legacy = readPlanFile(this.legacyPath, this.baseDir);
145
- if (legacy) {
146
- this.saveActive(legacy);
147
- try {
148
- rmSync(this.legacyPath, { force: true });
149
- }
150
- catch (err) {
151
- log.warn("Failed to remove migrated legacy plan.json", {
152
- path: this.legacyPath,
153
- error: errMsg(err),
154
- });
155
- }
156
- return legacy;
157
- }
158
- }
159
- return null;
160
- }
161
- /** Убирает активный план. */
162
- clearActive() {
163
- const p = this.activePath();
164
- if (existsSync(p))
165
- rmSync(p, { force: true });
166
- }
167
- // ---- Черновики (сохранённые планы) ----
168
- /** Сохраняет план в черновики. */
169
- saveDraft(plan) {
170
- writePlanFile(join(this.draftsDir, `${plan.id}.json`), plan);
171
- }
172
- /** Загружает черновик по id. Null, если нет. */
173
- loadDraft(id) {
174
- const p = join(this.draftsDir, `${id}.json`);
175
- return existsSync(p) ? readPlanFile(p, this.baseDir) : null;
176
- }
177
- /** Удаляет черновик по id. */
178
- removeDraft(id) {
179
- const p = join(this.draftsDir, `${id}.json`);
180
- if (existsSync(p))
181
- rmSync(p, { force: true });
182
- }
183
- /** Все черновики. */
184
- listDrafts() {
185
- return listDir(this.draftsDir, this.baseDir);
186
- }
187
- // ---- Архив ----
188
- /** Архивирует план (убирает из черновиков/активного при совпадении). */
189
- archivePlan(plan) {
190
- writePlanFile(join(this.archiveDir, `${plan.id}.json`), plan);
191
- // Убираем из черновиков, если там был
192
- this.removeDraft(plan.id);
193
- // Если архивируемый был активным — чистим active
194
- const active = this.loadActive();
195
- if (active && active.id === plan.id) {
196
- this.clearActive();
197
- }
198
- }
199
- /** Все архивные планы. */
200
- listArchived() {
201
- return listDir(this.archiveDir, this.baseDir);
202
- }
203
- /** Удаляет архивный план по id. */
204
- removeArchived(id) {
205
- const p = join(this.archiveDir, `${id}.json`);
206
- if (existsSync(p))
207
- rmSync(p, { force: true });
208
- }
209
- // ---- Кросс-статусные запросы ----
210
- /** Метаданные всех планов (активный + черновики + архив). */
211
- listAll() {
212
- const metas = [];
213
- const active = this.loadActive();
214
- if (active)
215
- metas.push(toMeta(active, "active"));
216
- for (const p of this.listDrafts())
217
- metas.push(toMeta(p, "draft"));
218
- for (const p of this.listArchived())
219
- metas.push(toMeta(p, "archived"));
220
- return metas;
221
- }
222
- /** Находит план по id в любом статусе. Null, если нет. */
223
- find(id) {
224
- const active = this.loadActive();
225
- if (active && active.id === id)
226
- return { plan: active, status: "active" };
227
- const draft = this.loadDraft(id);
228
- if (draft)
229
- return { plan: draft, status: "draft" };
230
- const archived = this.listArchived().find((p) => p.id === id);
231
- if (archived)
232
- return { plan: archived, status: "archived" };
233
- return null;
234
- }
235
- // ---- Удаление (юзер просил: планы должны реально исчезать) ----
236
- /** Навсегда удаляет план, где бы ни лежал. Возвращает его статус, или null
237
- * если плана с таким id нет. */
238
- deletePlan(id) {
239
- const active = this.loadActive();
240
- if (active && active.id === id) {
241
- this.clearActive();
242
- return "active";
243
- }
244
- const draftPath = join(this.draftsDir, `${id}.json`);
245
- if (existsSync(draftPath)) {
246
- rmSync(draftPath, { force: true });
247
- return "draft";
248
- }
249
- const archivedPath = join(this.archiveDir, `${id}.json`);
250
- if (existsSync(archivedPath)) {
251
- rmSync(archivedPath, { force: true });
252
- return "archived";
253
- }
254
- return null;
255
- }
256
- /** Удаляет все планы (активный, черновики, архив). Возвращает число удалённых. */
257
- purgeAll() {
258
- let n = 0;
259
- const active = this.loadActive();
260
- if (active) {
261
- this.clearActive();
262
- n++;
263
- }
264
- for (const p of this.listDrafts()) {
265
- this.removeDraft(p.id);
266
- n++;
267
- }
268
- for (const p of this.listArchived()) {
269
- this.removeArchived(p.id);
270
- n++;
271
- }
272
- return n;
273
- }
274
- }
@@ -1,249 +0,0 @@
1
- import { t } from "../../i18n/index";
2
- import { dispatchPlanAction, updatePlanStep } from "./plan-actions";
3
- /**
4
- * Маркит подзадачи done по числовым id (предпочтительно) или точному тексту (фолбэк).
5
- * Возвращает число отмеченных, или строку ошибки если ничего не сошлось.
6
- */
7
- function markTodoDone(subs, ids, items) {
8
- let marked = 0;
9
- if (ids.length > 0) {
10
- for (const id of ids) {
11
- const sub = subs.find((s) => !s.done && s.id === id);
12
- if (sub) {
13
- sub.done = true;
14
- marked++;
15
- }
16
- }
17
- if (marked === 0) {
18
- return {
19
- error: t("todo.subtask_id_not_found", { ids: ids.join(", ") }),
20
- };
21
- }
22
- return { marked };
23
- }
24
- for (const item of items) {
25
- const sub = subs.find((s) => !s.done && s.text.toLowerCase() === item.toLowerCase());
26
- if (sub) {
27
- sub.done = true;
28
- marked++;
29
- }
30
- }
31
- if (marked === 0) {
32
- return {
33
- error: t("todo.subtask_not_found", { items: items.join(", ") }),
34
- };
35
- }
36
- return { marked };
37
- }
38
- /**
39
- * Определения тулов plan / todo / verify для execution-модуля. Хендлеры
40
- * вынесены дословно из ExecutionModule.getToolDefinitions() — весь доступ к
41
- * состоянию идёт через `deps`-замыкания (трекер и стор принадлежат модулю).
42
- */
43
- export function createPlanToolDefinitions(deps) {
44
- return [
45
- {
46
- name: "plan",
47
- icon: "📋",
48
- alwaysOn: true,
49
- description: 'Create, update, show, abort, list, switch, delete, purge, or re-plan multi-step plans.\n\nActions:\n- create: Start a new plan. Previous active plan is auto-preserved: incomplete → draft, complete → archive.\n- update: Mark step status (done/failed/skipped). To change the plan\'s steps use "re-plan" (keeps completed steps) or "create".\n- show: Print current plan checklist.\n- abort: Archive the current plan (or the plan given by id) and clear the active slot.\n- list: Show all plans (active, drafts, archived) with progress.\n- switch: Make a different plan active (by plan id).\n- re-plan: Iterative replanning: keep completed steps, replace remaining with new steps.\n- delete: Permanently delete a plan by id (plan delete id=plan_xxx).\n- purge: Delete ALL plans (active, drafts, archived).\n\nWrite CONCRETE steps with exact file paths and commands:\n- Specify WHICH files to create with exact paths (e.g. "create src/components/Header.tsx with navigation and logo")\n- Specify WHICH packages to install (e.g. "run npm install react react-dom")\n- Specify WHICH CLI commands to run with exact arguments\n- Each step should include at least one file extension (.ts, .tsx, .json, etc.) or a command verb (install, create, build, run, add, init)\n- Good: "Создать src/components/Header.tsx с навигацией и логотипом"\n- Bad: "Настройка проекта" (too vague — what exactly needs to be configured?)\n- Steps that REMOVE files need no extra flag: create/delete intent is detected automatically from what the agent actually does.\n- Every step needs a verification contract: pass "checks" aligned 1:1 with "steps". Each check is "file-exists:<path>" (verified automatically on done), "command:<exact command>" (run it before done), or "manual:<what to check by eye>" (UI/visual work only). Example: steps ["Create src/a.ts with X"] + checks ["file-exists:src/a.ts"].',
50
- parameters: {
51
- type: "object",
52
- properties: {
53
- action: {
54
- type: "string",
55
- enum: [
56
- "create",
57
- "update",
58
- "show",
59
- "abort",
60
- "list",
61
- "switch",
62
- "re-plan",
63
- "delete",
64
- "purge",
65
- ],
66
- },
67
- title: { type: "string" },
68
- steps: { type: "array", items: { type: "string" } },
69
- checks: {
70
- type: "array",
71
- items: { type: "string" },
72
- description: 'REQUIRED on create/re-plan, aligned 1:1 with steps. One contract per step: "file-exists:<path>", "command:<cmd>", or "manual:<text>".',
73
- },
74
- step: { type: "number" },
75
- status: { type: "string", enum: ["done", "failed", "skipped"] },
76
- note: { type: "string" },
77
- id: { type: "string", description: "Plan id (for switch action)" },
78
- },
79
- required: ["action"],
80
- },
81
- handler: async (ctx, args) => {
82
- const action = String(args.action);
83
- // Диспетчер по действию: по одной функции на action (plan-actions.ts).
84
- const result = dispatchPlanAction(action, deps, ctx, args);
85
- if (result !== null)
86
- return result;
87
- return {
88
- success: false,
89
- output: t("plan.unknown_action", { action }),
90
- };
91
- },
92
- },
93
- {
94
- name: "plan_step",
95
- icon: "📋",
96
- alwaysOn: true,
97
- description: 'Mark ONE plan step done/failed/skipped: plan_step step=N status=done|failed|skipped (note="..." optional). Prefer this over "plan update" — no action parameter to confuse. The step\'s check contract is verified automatically on done ("file-exists:" hard-verified, "command:"/"manual:" self-certified).',
98
- parameters: {
99
- type: "object",
100
- properties: {
101
- step: { type: "number", description: "Step number to update" },
102
- status: { type: "string", enum: ["done", "failed", "skipped"] },
103
- note: { type: "string" },
104
- },
105
- required: ["step"],
106
- },
107
- handler: async (ctx, args) => {
108
- if (!deps.trackerRef.current) {
109
- return { success: false, output: t("plan.no_active") };
110
- }
111
- if (args.step === undefined || args.step === null || Number.isNaN(Number(args.step))) {
112
- return { success: false, output: t("plan.step_required") };
113
- }
114
- return updatePlanStep(deps, ctx, args);
115
- },
116
- },
117
- {
118
- name: "todo",
119
- icon: "☑️",
120
- alwaysOn: true,
121
- description: "Manage sub-tasks within current plan step. Use to break down complex steps into smaller tasks. Mark done by subtask ids from todo list (ids=[...]) — reliable; matching by text is a fallback.",
122
- parameters: {
123
- type: "object",
124
- properties: {
125
- action: { type: "string", enum: ["add", "done", "list"] },
126
- items: { type: "array", items: { type: "string" } },
127
- ids: {
128
- type: "array",
129
- items: { type: "number" },
130
- description: "Subtask ids to mark done (see todo list output). Preferred over items.",
131
- },
132
- },
133
- required: ["action"],
134
- },
135
- handler: async (_ctx, args) => {
136
- if (!deps.trackerRef.current) {
137
- return { success: false, output: t("plan.no_active") };
138
- }
139
- const tracker = deps.trackerRef.current;
140
- const action = String(args.action);
141
- const currentStep = tracker.getCurrentStep();
142
- if (!currentStep) {
143
- return { success: false, output: t("plan.step_not_found") };
144
- }
145
- if (action === "add" && Array.isArray(args.items)) {
146
- const items = args.items.map(String);
147
- const existing = currentStep.subtasks ?? [];
148
- let nextId = existing.reduce((m, s) => Math.max(m, s.id), 0) + 1;
149
- for (const item of items) {
150
- existing.push({ id: nextId++, text: item, done: false });
151
- }
152
- currentStep.subtasks = existing;
153
- deps.store.saveActive(tracker.getPlan());
154
- const display = tracker.toPromptBlock();
155
- const addedIds = existing.slice(-items.length).map((s) => s.id);
156
- const addedOutput = t("todo.added", {
157
- count: String(items.length),
158
- items: items.join(", "),
159
- }) + ` (ids: ${addedIds.join(", ")})`;
160
- return {
161
- success: true,
162
- output: addedOutput,
163
- display,
164
- };
165
- }
166
- if (action === "done") {
167
- const ids = Array.isArray(args.ids) ? args.ids.map(Number).filter((n) => !Number.isNaN(n)) : [];
168
- const items = Array.isArray(args.items) ? args.items.map(String) : [];
169
- if (ids.length === 0 && items.length === 0) {
170
- return {
171
- success: false,
172
- output: t("todo.no_items"),
173
- };
174
- }
175
- const subs = currentStep.subtasks ?? [];
176
- const done = markTodoDone(subs, ids, items);
177
- if ("error" in done) {
178
- return { success: false, output: done.error };
179
- }
180
- const marked = done.marked;
181
- currentStep.subtasks = subs;
182
- deps.store.saveActive(tracker.getPlan());
183
- const doneCount = subs.filter((s) => s.done).length;
184
- const display = tracker.toPromptBlock();
185
- // Отметка подзадачи done НЕ должна автозавершать шаг плана: шаг done,
186
- // только когда модель подтвердит весь шаг через plan update (было: 3 ×
187
- // "todo done" вернули "Step 3: done" и преждевременно закрыли шаг).
188
- let output = t("todo.marked_done", {
189
- count: String(marked),
190
- });
191
- output += ` (${doneCount}/${subs.length})`;
192
- if (doneCount === subs.length) {
193
- output += `\n${t("plan.subtasks_done", { stepId: String(currentStep.id) })}`;
194
- }
195
- return { success: true, output, display };
196
- }
197
- if (action === "list") {
198
- const subs = currentStep.subtasks ?? [];
199
- const lines = subs.length
200
- ? subs.map((s) => `[${s.id}] ${s.done ? "[x]" : "[ ]"} ${s.text}`)
201
- : [t("plan.no_subtasks")];
202
- return {
203
- success: true,
204
- output: `${t("plan.step_label", { stepId: String(currentStep.id), description: currentStep.description })}\n${lines.join("\n")}`,
205
- };
206
- }
207
- return {
208
- success: false,
209
- output: t("todo.unknown_action", { action }),
210
- };
211
- },
212
- },
213
- {
214
- name: "verify",
215
- icon: "✅",
216
- alwaysOn: true,
217
- description: "Run verification for the current step. Checks files mentioned in the step description.",
218
- parameters: {
219
- type: "object",
220
- properties: {
221
- step: { type: "number", description: "Step number to verify" },
222
- },
223
- },
224
- handler: async (_ctx, args) => {
225
- if (!deps.trackerRef.current)
226
- return { success: false, output: t("plan.no_active") };
227
- const tracker = deps.trackerRef.current;
228
- const step = args.step ? tracker.getStep(Number(args.step)) : tracker.getCurrentStep();
229
- if (!step)
230
- return { success: false, output: t("plan.step_not_found") };
231
- const result = await deps.verifier.verifyStep(step.description, step.kind);
232
- if (result.noFiles) {
233
- return {
234
- success: true,
235
- output: t("verify.no_files", { step: String(step.id) }),
236
- };
237
- }
238
- return {
239
- success: result.passed,
240
- output: result.passed
241
- ? t("verify.passed")
242
- : t("verify.failed", {
243
- details: result.failed.map((f) => f.message).join("; "),
244
- }),
245
- };
246
- },
247
- },
248
- ];
249
- }