micro-models-agent 0.59.0 → 0.60.0

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 (233) hide show
  1. package/CHANGELOG.md +578 -564
  2. package/README.md +358 -358
  3. package/dist/certification/certifications.json +493 -493
  4. package/dist/i18n/en.json +732 -718
  5. package/dist/i18n/ru.json +732 -718
  6. package/dist/main.js +504 -62
  7. package/dist/modules/browser/bridge-server.mjs +219 -219
  8. package/dist/skills/builtin/git.md +36 -36
  9. package/dist/skills/builtin/typescript.md +35 -35
  10. package/package.json +51 -51
  11. package/dist/cli/commands.js +0 -447
  12. package/dist/cli/completer.js +0 -167
  13. package/dist/cli/index.js +0 -2
  14. package/dist/cli/main.js +0 -153
  15. package/dist/cli/plugin-commands.js +0 -36
  16. package/dist/cli/repl-commands.js +0 -761
  17. package/dist/cli/repl.js +0 -702
  18. package/dist/cli/run-result.js +0 -33
  19. package/dist/cli/security-commands.js +0 -164
  20. package/dist/cli/setup.js +0 -237
  21. package/dist/config/config.js +0 -276
  22. package/dist/config/defaults.js +0 -141
  23. package/dist/config/domains.js +0 -179
  24. package/dist/config/experts.js +0 -15
  25. package/dist/config/index.js +0 -4
  26. package/dist/config/security.js +0 -213
  27. package/dist/config/types.js +0 -1
  28. package/dist/core/agent-moe.js +0 -102
  29. package/dist/core/agent.js +0 -1018
  30. package/dist/core/bootstrap.js +0 -481
  31. package/dist/core/crash-handler.js +0 -51
  32. package/dist/core/environment.js +0 -199
  33. package/dist/core/index.js +0 -2
  34. package/dist/core/prompt-builder.js +0 -76
  35. package/dist/core/session-logger.js +0 -251
  36. package/dist/core/types.js +0 -1
  37. package/dist/core/version.js +0 -26
  38. package/dist/core/workspace.js +0 -76
  39. package/dist/i18n/index.js +0 -46
  40. package/dist/index.js +0 -22
  41. package/dist/llm/image-utils.js +0 -143
  42. package/dist/llm/index.js +0 -4
  43. package/dist/llm/model-loader.js +0 -78
  44. package/dist/llm/openai-compat.js +0 -497
  45. package/dist/llm/orchestrator.js +0 -200
  46. package/dist/llm/provider.js +0 -10
  47. package/dist/llm/response.js +0 -39
  48. package/dist/llm/token-counter.js +0 -39
  49. package/dist/llm/types.js +0 -1
  50. package/dist/logger/app-logger.js +0 -189
  51. package/dist/logger/file-log.js +0 -151
  52. package/dist/logger/index.js +0 -1
  53. package/dist/migration/backup.js +0 -45
  54. package/dist/migration/detect.js +0 -50
  55. package/dist/migration/index.js +0 -2
  56. package/dist/modules/artifacts/store.js +0 -61
  57. package/dist/modules/browser/actions.js +0 -76
  58. package/dist/modules/browser/bridge-client.js +0 -199
  59. package/dist/modules/browser/bridge-path.js +0 -10
  60. package/dist/modules/browser/cookie-store.js +0 -24
  61. package/dist/modules/browser/driver.js +0 -136
  62. package/dist/modules/browser/index.js +0 -7
  63. package/dist/modules/browser/module.js +0 -29
  64. package/dist/modules/browser/session.js +0 -342
  65. package/dist/modules/browser/snapshot.js +0 -148
  66. package/dist/modules/browser/types.js +0 -12
  67. package/dist/modules/certification/cli.js +0 -213
  68. package/dist/modules/certification/fact-checker.js +0 -82
  69. package/dist/modules/certification/loader.js +0 -106
  70. package/dist/modules/certification/manifest.js +0 -58
  71. package/dist/modules/certification/runner.js +0 -245
  72. package/dist/modules/certification/scenarios.js +0 -407
  73. package/dist/modules/certification/types.js +0 -1
  74. package/dist/modules/context/chunk-query.js +0 -100
  75. package/dist/modules/context/fact-extractor.js +0 -168
  76. package/dist/modules/context/history.js +0 -15
  77. package/dist/modules/context/index.js +0 -1
  78. package/dist/modules/context/manager.js +0 -440
  79. package/dist/modules/execution/audit-runners.js +0 -206
  80. package/dist/modules/execution/auditor.js +0 -218
  81. package/dist/modules/execution/execution-plugin.js +0 -431
  82. package/dist/modules/execution/index.js +0 -8
  83. package/dist/modules/execution/module.js +0 -625
  84. package/dist/modules/execution/moe-executor.js +0 -304
  85. package/dist/modules/execution/plan-coverage.js +0 -68
  86. package/dist/modules/execution/plan-persister.js +0 -46
  87. package/dist/modules/execution/plan-store.js +0 -196
  88. package/dist/modules/execution/plan-tool.js +0 -677
  89. package/dist/modules/execution/plan-validator.js +0 -153
  90. package/dist/modules/execution/planner.js +0 -94
  91. package/dist/modules/execution/stuck-detector.js +0 -746
  92. package/dist/modules/execution/tracker.js +0 -69
  93. package/dist/modules/execution/types.js +0 -1
  94. package/dist/modules/execution/verifier.js +0 -235
  95. package/dist/modules/execution/windows-commands.js +0 -41
  96. package/dist/modules/hallucination/confidence.js +0 -66
  97. package/dist/modules/hallucination/consistency.js +0 -26
  98. package/dist/modules/hallucination/detector.js +0 -47
  99. package/dist/modules/hallucination/factual.js +0 -169
  100. package/dist/modules/hallucination/index.js +0 -5
  101. package/dist/modules/hallucination/js-identifiers.js +0 -262
  102. package/dist/modules/hallucination/llm-judge.js +0 -101
  103. package/dist/modules/index.js +0 -5
  104. package/dist/modules/indexer/cache.js +0 -40
  105. package/dist/modules/indexer/index.js +0 -3
  106. package/dist/modules/indexer/module.js +0 -246
  107. package/dist/modules/indexer/project-profile.js +0 -183
  108. package/dist/modules/indexer/walker.js +0 -101
  109. package/dist/modules/lsp/check-tool.js +0 -58
  110. package/dist/modules/lsp/client.js +0 -389
  111. package/dist/modules/lsp/command.js +0 -60
  112. package/dist/modules/lsp/config.js +0 -135
  113. package/dist/modules/lsp/index.js +0 -3
  114. package/dist/modules/lsp/module.js +0 -260
  115. package/dist/modules/lsp/probe.js +0 -86
  116. package/dist/modules/lsp/project-root.js +0 -32
  117. package/dist/modules/lsp/startup-check.js +0 -144
  118. package/dist/modules/lsp/types.js +0 -1
  119. package/dist/modules/mcp/client.js +0 -399
  120. package/dist/modules/mcp/index.js +0 -3
  121. package/dist/modules/mcp/module.js +0 -142
  122. package/dist/modules/mcp/registry.js +0 -15
  123. package/dist/modules/memory/index.js +0 -1
  124. package/dist/modules/memory/module.js +0 -96
  125. package/dist/modules/memory/search.js +0 -42
  126. package/dist/modules/memory/store.js +0 -69
  127. package/dist/modules/pipelines/engine.js +0 -60
  128. package/dist/modules/pipelines/index.js +0 -3
  129. package/dist/modules/pipelines/parser.js +0 -56
  130. package/dist/modules/pipelines/template.js +0 -14
  131. package/dist/modules/plugins/builtin/lint-on-write.js +0 -334
  132. package/dist/modules/plugins/builtin/notify.js +0 -9
  133. package/dist/modules/plugins/index.js +0 -1
  134. package/dist/modules/plugins/loader.js +0 -70
  135. package/dist/modules/plugins/manager.js +0 -261
  136. package/dist/modules/plugins/types.js +0 -1
  137. package/dist/modules/pricing/index.js +0 -61
  138. package/dist/modules/pricing/prices.js +0 -129
  139. package/dist/modules/processes/detect.js +0 -34
  140. package/dist/modules/processes/index.js +0 -2
  141. package/dist/modules/processes/registry.js +0 -327
  142. package/dist/modules/processes/runner.js +0 -23
  143. package/dist/modules/providers/create.js +0 -22
  144. package/dist/modules/providers/fallback.js +0 -79
  145. package/dist/modules/providers/health.js +0 -46
  146. package/dist/modules/providers/index.js +0 -5
  147. package/dist/modules/providers/manager.js +0 -161
  148. package/dist/modules/providers/presets.js +0 -128
  149. package/dist/modules/providers/registry.js +0 -22
  150. package/dist/modules/providers/types.js +0 -1
  151. package/dist/modules/registry.js +0 -48
  152. package/dist/modules/security/audit-log.js +0 -136
  153. package/dist/modules/security/audit-notifier.js +0 -292
  154. package/dist/modules/security/command-validator.js +0 -219
  155. package/dist/modules/security/content-scanner.js +0 -53
  156. package/dist/modules/security/data-sanitizer.js +0 -89
  157. package/dist/modules/security/encryption.js +0 -242
  158. package/dist/modules/security/index.js +0 -14
  159. package/dist/modules/security/network-validator.js +0 -88
  160. package/dist/modules/security/path-validator.js +0 -203
  161. package/dist/modules/security/rate-limiter.js +0 -119
  162. package/dist/modules/security/security-policies.js +0 -531
  163. package/dist/modules/security/session-encryption.js +0 -210
  164. package/dist/modules/security/session-isolation.js +0 -95
  165. package/dist/modules/session/index.js +0 -3
  166. package/dist/modules/session/manager.js +0 -172
  167. package/dist/modules/session/module.js +0 -24
  168. package/dist/modules/session/store.js +0 -222
  169. package/dist/modules/session/types.js +0 -1
  170. package/dist/modules/skills/index.js +0 -2
  171. package/dist/modules/skills/loader.js +0 -72
  172. package/dist/modules/skills/matcher.js +0 -27
  173. package/dist/modules/skills/module.js +0 -129
  174. package/dist/modules/types.js +0 -1
  175. package/dist/modules/updater/checker.js +0 -96
  176. package/dist/modules/updater/index.js +0 -2
  177. package/dist/modules/updater/module.js +0 -116
  178. package/dist/modules/user-profile/compressor.js +0 -16
  179. package/dist/modules/user-profile/index.js +0 -1
  180. package/dist/modules/user-profile/profile.js +0 -68
  181. package/dist/tools/approve.js +0 -33
  182. package/dist/tools/attach-image.js +0 -101
  183. package/dist/tools/bash.js +0 -519
  184. package/dist/tools/browser.js +0 -115
  185. package/dist/tools/chunk-query.js +0 -100
  186. package/dist/tools/create-dir.js +0 -56
  187. package/dist/tools/delete-file.js +0 -63
  188. package/dist/tools/download-file.js +0 -117
  189. package/dist/tools/edit-file.js +0 -80
  190. package/dist/tools/enable-tools.js +0 -59
  191. package/dist/tools/executor.js +0 -154
  192. package/dist/tools/file-info.js +0 -47
  193. package/dist/tools/filter-tools.js +0 -17
  194. package/dist/tools/glob-tool.js +0 -27
  195. package/dist/tools/grep-tool.js +0 -125
  196. package/dist/tools/hidden-tools-block.js +0 -37
  197. package/dist/tools/index.js +0 -78
  198. package/dist/tools/list-dir.js +0 -49
  199. package/dist/tools/load-skill.js +0 -43
  200. package/dist/tools/mcp-call.js +0 -69
  201. package/dist/tools/move-file.js +0 -86
  202. package/dist/tools/path-utils.js +0 -101
  203. package/dist/tools/pipeline-run.js +0 -145
  204. package/dist/tools/preview.js +0 -2
  205. package/dist/tools/process-kill.js +0 -40
  206. package/dist/tools/process-list.js +0 -37
  207. package/dist/tools/process-log.js +0 -54
  208. package/dist/tools/question.js +0 -141
  209. package/dist/tools/read-file.js +0 -179
  210. package/dist/tools/recall.js +0 -118
  211. package/dist/tools/registry.js +0 -47
  212. package/dist/tools/remember.js +0 -68
  213. package/dist/tools/scope-check.js +0 -32
  214. package/dist/tools/search-history.js +0 -85
  215. package/dist/tools/subagent.js +0 -196
  216. package/dist/tools/types.js +0 -1
  217. package/dist/tools/user-input.js +0 -123
  218. package/dist/tools/web-browse.js +0 -87
  219. package/dist/tools/web-fetch.js +0 -119
  220. package/dist/tools/web-search.js +0 -105
  221. package/dist/tools/write-file.js +0 -82
  222. package/dist/ui/box.js +0 -77
  223. package/dist/ui/colors.js +0 -4
  224. package/dist/ui/diff.js +0 -178
  225. package/dist/ui/index.js +0 -6
  226. package/dist/ui/line-editor.js +0 -822
  227. package/dist/ui/line-math.js +0 -73
  228. package/dist/ui/md-formatter.js +0 -212
  229. package/dist/ui/output.js +0 -13
  230. package/dist/ui/plan-view.js +0 -103
  231. package/dist/ui/renderer.js +0 -259
  232. package/dist/ui/spinner.js +0 -70
  233. package/dist/ui/table.js +0 -144
package/dist/main.js CHANGED
@@ -2511,7 +2511,7 @@ The path was joined onto the working directory because it does not exist as give
2511
2511
  "session.available": "Available sessions:",
2512
2512
  "session.no_match": 'No session matching "{query}"',
2513
2513
  "session.default_name": "Session {date}",
2514
- "session.info": '[Session: "{name}" ({id}) {count} messages so far]',
2514
+ "session.info_full": '[Session: "{name}" ({id}) | model: {model} | context: {contextWindow} tokens]',
2515
2515
  "session.col_active": "",
2516
2516
  "session.col_id": "ID",
2517
2517
  "session.col_name": "Name",
@@ -3191,7 +3191,27 @@ Apply a matching solution from these results. If none is relevant — do NOT rep
3191
3191
  "moe.cycles_exhausted": "Max re-plan cycles ({max}) reached — returning partial results",
3192
3192
  "moe.partial_result": "Partial result",
3193
3193
  "moe.scope_approved": '🔓 Scope expanded for "{subtask}": {files}',
3194
- "moe.scope_rejected": '⛔ Scope request rejected for "{subtask}"'
3194
+ "moe.scope_rejected": '⛔ Scope request rejected for "{subtask}"',
3195
+ "prompt.overflow.exceeded": 'Prompt overflow: "{label}" ({original} tok) exceeded the system-prompt budget ({budget} tok) — {mode} to {resolved} tok. To fit fully, {hint}.',
3196
+ "prompt.overflow.failed": "Prompt overflow resolution failed: {error} — oversized blocks will be dropped.",
3197
+ "prompt.overflow.startup": "Startup check: {block} ({original} tok) exceeds the system-prompt budget ({budget} tok) — it will be summarized/truncated before the first run. To include it fully, {hint}.",
3198
+ "tool.session_info.no_active": "No active session",
3199
+ "tool.session_info.result": `Session: "{name}" ({id})
3200
+ Model: {model}
3201
+ Provider: {provider}
3202
+ Context window: {contextWindow} tokens
3203
+ Messages: {messages}
3204
+ Created: {createdAt}
3205
+ Updated: {updatedAt}`,
3206
+ "tool.session_info.context": "Context used: {used} / {budget} tokens ({percent}%)",
3207
+ "tool.friendly.session_info": "Session info",
3208
+ "cli.map.description": "Work with the project index / map",
3209
+ "cli.map.action": "Action: summary (default), refresh, find",
3210
+ "cli.map.query": "Search query for the find action",
3211
+ "repl.map": "Show the project map / index (summary, refresh, find)",
3212
+ "repl.map_usage": "Usage: /map [summary|refresh|find <query>]",
3213
+ "map.refreshed": "Project map refreshed",
3214
+ "map.find_usage": "Usage: map find <query>"
3195
3215
  };
3196
3216
  });
3197
3217
 
@@ -3281,7 +3301,7 @@ var init_ru = __esm(() => {
3281
3301
  "session.available": "Доступные сессии:",
3282
3302
  "session.no_match": 'Нет сессии подходящей по "{query}"',
3283
3303
  "session.default_name": "Сессия {date}",
3284
- "session.info": '[Сессия: "{name}" ({id}) {count} сообщений]',
3304
+ "session.info_full": '[Сессия: "{name}" ({id}) | модель: {model} | контекст: {contextWindow} токенов]',
3285
3305
  "session.col_active": "",
3286
3306
  "session.col_id": "ID",
3287
3307
  "session.col_name": "Имя",
@@ -3963,7 +3983,27 @@ var init_ru = __esm(() => {
3963
3983
  "moe.cycles_exhausted": "Достигнут лимит re-plan циклов ({max}) — возвращаю частичные результаты",
3964
3984
  "moe.partial_result": "Частичный результат",
3965
3985
  "moe.scope_approved": '🔓 Scope расширен для "{subtask}": {files}',
3966
- "moe.scope_rejected": '⛔ Запрос scope отклонён для "{subtask}"'
3986
+ "moe.scope_rejected": '⛔ Запрос scope отклонён для "{subtask}"',
3987
+ "prompt.overflow.exceeded": 'Промпт переполнен: "{label}" ({original} токенов) превысил бюджет системного промпта ({budget} токенов) — {mode} до {resolved} токенов. Чтобы включить полностью, {hint}.',
3988
+ "prompt.overflow.failed": "Не удалось разрешить переполнение промпта: {error} — слишком большие блоки будут отброшены.",
3989
+ "prompt.overflow.startup": "Проверка при старте: {block} ({original} токенов) превышает бюджет системного промпта ({budget} токенов) — будет суммаризован/обрезан перед первым запуском. Чтобы включить полностью, {hint}.",
3990
+ "tool.session_info.no_active": "Нет активной сессии",
3991
+ "tool.session_info.result": `Сессия: "{name}" ({id})
3992
+ Модель: {model}
3993
+ Провайдер: {provider}
3994
+ Контекстное окно: {contextWindow} токенов
3995
+ Сообщений: {messages}
3996
+ Создана: {createdAt}
3997
+ Обновлена: {updatedAt}`,
3998
+ "tool.session_info.context": "Использовано контекста: {used} / {budget} токенов ({percent}%)",
3999
+ "tool.friendly.session_info": "Информация о сессии",
4000
+ "cli.map.description": "Работа с индексом / картой проекта",
4001
+ "cli.map.action": "Действие: summary (по умолчанию), refresh, find",
4002
+ "cli.map.query": "Поисковый запрос для действия find",
4003
+ "repl.map": "Показать карту проекта / индекс (summary, refresh, find)",
4004
+ "repl.map_usage": "Использование: /map [summary|refresh|find <запрос>]",
4005
+ "map.refreshed": "Карта проекта обновлена",
4006
+ "map.find_usage": "Использование: map find <запрос>"
3967
4007
  };
3968
4008
  });
3969
4009
 
@@ -14883,7 +14923,14 @@ class Agent {
14883
14923
  const recommended = recommendContextSize(dry.blocks.filter((b) => b.included).reduce((s, b) => s + b.tokens, 0) + overflow.reduce((s, b) => s + b.estimatedTokens, 0) + HINT_BLOCK_TOKENS);
14884
14924
  const hint = this.deps.configDir ? contextWindowHint(cfg, this.deps.configDir, recommended) : `increase contextWindow (e.g. to ${recommended})`;
14885
14925
  for (const w of res.warnings) {
14886
- this.deps.logger.warn(`Prompt overflow: "${w.label}" (${w.originalTokens} tok) exceeded the system-prompt budget (${systemBudget} tok) — ${w.mode === "summary" ? "summarized" : "truncated"} to ${w.resolvedTokens} tok. To fit fully, ${hint}.`);
14926
+ this.deps.logger.warn(t("prompt.overflow.exceeded", {
14927
+ label: w.label,
14928
+ original: String(w.originalTokens),
14929
+ budget: String(systemBudget),
14930
+ mode: w.mode === "summary" ? "summarized" : "truncated",
14931
+ resolved: String(w.resolvedTokens),
14932
+ hint
14933
+ }));
14887
14934
  }
14888
14935
  }
14889
14936
  refreshSystemPrompt() {
@@ -14933,7 +14980,7 @@ class Agent {
14933
14980
  try {
14934
14981
  await this.resolvePromptOverflowOnce();
14935
14982
  } catch (err) {
14936
- this.deps.logger.warn(`Prompt overflow resolution failed: ${err?.message ?? err} — oversized blocks will be dropped.`);
14983
+ this.deps.logger.warn(t("prompt.overflow.failed", { error: String(err?.message ?? err) }));
14937
14984
  }
14938
14985
  }
14939
14986
  if (this.deps.reasoningProbe) {
@@ -20218,6 +20265,56 @@ var init_enable_tools = __esm(() => {
20218
20265
  };
20219
20266
  });
20220
20267
 
20268
+ // src/tools/session-info.ts
20269
+ var sessionInfoTool;
20270
+ var init_session_info = __esm(() => {
20271
+ init_i18n();
20272
+ sessionInfoTool = {
20273
+ name: "session_info",
20274
+ icon: "ℹ️",
20275
+ description: "Show metadata about the current session: id, name, model, provider, context window, message count, and how much of the context budget is used. Use when the user asks which session this is or how much context is left.",
20276
+ alwaysOn: true,
20277
+ boundedOutput: true,
20278
+ parameters: {
20279
+ type: "object",
20280
+ properties: {}
20281
+ },
20282
+ handler: async (ctx) => {
20283
+ const meta = ctx.sessionManager?.getActiveMeta();
20284
+ if (!meta) {
20285
+ return { success: true, output: t("tool.session_info.no_active") };
20286
+ }
20287
+ const provider = ctx.config.provider;
20288
+ const providerName = provider.active ?? provider.type ?? "unknown";
20289
+ const lines = [
20290
+ t("tool.session_info.result", {
20291
+ id: meta.id,
20292
+ name: meta.name,
20293
+ model: meta.model ?? ctx.config.model ?? "unknown",
20294
+ provider: providerName,
20295
+ contextWindow: String(meta.contextWindow ?? ctx.config.contextWindow),
20296
+ messages: String(meta.messageCount),
20297
+ createdAt: meta.createdAt,
20298
+ updatedAt: meta.updatedAt
20299
+ })
20300
+ ];
20301
+ const snapshot = ctx.contextManager?.getSnapshot();
20302
+ if (snapshot) {
20303
+ const used = snapshot.tokens;
20304
+ const budget = snapshot.budget.history;
20305
+ const percent = budget > 0 ? Math.round(used / budget * 100) : 0;
20306
+ lines.push(t("tool.session_info.context", {
20307
+ used: String(used),
20308
+ budget: String(budget),
20309
+ percent: String(percent)
20310
+ }));
20311
+ }
20312
+ return { success: true, output: lines.join(`
20313
+ `) };
20314
+ }
20315
+ };
20316
+ });
20317
+
20221
20318
  // src/tools/index.ts
20222
20319
  function registerAllTools(registry2, skillsModule, opts) {
20223
20320
  const tools = [
@@ -20244,7 +20341,8 @@ function registerAllTools(registry2, skillsModule, opts) {
20244
20341
  pipelineRunTool,
20245
20342
  mcpCallTool,
20246
20343
  searchHistoryTool,
20247
- attachImageTool
20344
+ attachImageTool,
20345
+ sessionInfoTool
20248
20346
  ];
20249
20347
  if (opts?.enableOnDemand !== false) {
20250
20348
  tools.push(enableToolsTool);
@@ -20287,6 +20385,7 @@ var init_tools = __esm(() => {
20287
20385
  init_browser();
20288
20386
  init_attach_image();
20289
20387
  init_enable_tools();
20388
+ init_session_info();
20290
20389
  });
20291
20390
 
20292
20391
  // src/tools/hidden-tools-block.ts
@@ -23398,13 +23497,18 @@ class SessionModule {
23398
23497
  }
23399
23498
  getSystemPromptBlock() {
23400
23499
  const meta = this.manager.getActiveMeta();
23401
- if (!meta || meta.messageCount === 0)
23500
+ if (!meta)
23402
23501
  return null;
23403
23502
  return {
23404
- content: t("session.info", { name: meta.name, id: meta.id, count: meta.messageCount }),
23503
+ content: t("session.info_full", {
23504
+ name: meta.name,
23505
+ id: meta.id,
23506
+ model: meta.model,
23507
+ contextWindow: meta.contextWindow
23508
+ }),
23405
23509
  priority: "low",
23406
23510
  essential: false,
23407
- estimatedTokens: 20
23511
+ estimatedTokens: 30
23408
23512
  };
23409
23513
  }
23410
23514
  getPlugin() {
@@ -24582,9 +24686,186 @@ var init_startup_check = __esm(() => {
24582
24686
  init_utils();
24583
24687
  });
24584
24688
 
24689
+ // src/modules/indexer/symbols.ts
24690
+ function dedupe2(names) {
24691
+ const seen = new Set;
24692
+ const out = [];
24693
+ for (const name of names) {
24694
+ if (name && !seen.has(name)) {
24695
+ seen.add(name);
24696
+ out.push(name);
24697
+ }
24698
+ }
24699
+ return out;
24700
+ }
24701
+ function collect(content, patterns) {
24702
+ const names = [];
24703
+ for (const re of patterns) {
24704
+ re.lastIndex = 0;
24705
+ let match;
24706
+ while ((match = re.exec(content)) !== null) {
24707
+ if (match[1])
24708
+ names.push(match[1]);
24709
+ if (match.index === re.lastIndex)
24710
+ re.lastIndex++;
24711
+ }
24712
+ }
24713
+ return names;
24714
+ }
24715
+ function collectExportClauses(content) {
24716
+ const names = [];
24717
+ const re = /export\s+(?:type\s+)?\{([^}]*)\}/g;
24718
+ let match;
24719
+ while ((match = re.exec(content)) !== null) {
24720
+ for (const part of match[1].split(",")) {
24721
+ const cleaned = part.trim().replace(/^type\s+/, "");
24722
+ if (!cleaned || cleaned.startsWith("//"))
24723
+ continue;
24724
+ const alias = cleaned.split(/\s+as\s+/);
24725
+ const exported = (alias.length > 1 ? alias[1] : alias[0]).trim();
24726
+ if (/^\w+$/.test(exported))
24727
+ names.push(exported);
24728
+ }
24729
+ }
24730
+ return names;
24731
+ }
24732
+ function tsLike(content) {
24733
+ return dedupe2([...collect(content, TS_JS_PATTERNS), ...collectExportClauses(content)]);
24734
+ }
24735
+ function languageIdForExt(ext) {
24736
+ return EXT_TO_LANGUAGE[ext.toLowerCase()] ?? null;
24737
+ }
24738
+ function isCodeLanguage(languageId) {
24739
+ return RULES[languageId]?.code ?? false;
24740
+ }
24741
+ function extractSymbols(content, languageId) {
24742
+ const rule = RULES[languageId];
24743
+ if (!rule)
24744
+ return [];
24745
+ return dedupe2(rule.extract(content)).slice(0, MAX_SYMBOLS_PER_FILE);
24746
+ }
24747
+ var MAX_SYMBOLS_PER_FILE = 40, TS_JS_PATTERNS, PYTHON_PATTERNS, RUST_PATTERNS, GO_PATTERNS, JAVA_PATTERNS, KOTLIN_PATTERNS, CSHARP_PATTERNS, RUBY_PATTERNS, PHP_PATTERNS, SWIFT_PATTERNS, SCALA_PATTERNS, C_CPP_PATTERNS, SHELL_PATTERNS, LUA_PATTERNS, NO_SYMBOLS = () => [], RULES, EXT_TO_LANGUAGE;
24748
+ var init_symbols = __esm(() => {
24749
+ TS_JS_PATTERNS = [
24750
+ /^export\s+(?:default\s+)?(?:declare\s+)?(?:abstract\s+)?(?:async\s+)?(?:const|let|var|function|class|interface|type|enum)\s+(\w+)/gm,
24751
+ /^export\s+default\s+(?:class|function)\s+(\w+)/gm
24752
+ ];
24753
+ PYTHON_PATTERNS = [/^(?:async\s+)?def\s+(\w+)/gm, /^class\s+(\w+)/gm];
24754
+ RUST_PATTERNS = [
24755
+ /^\s*pub(?:\([^)]*\))?\s+(?:async\s+)?(?:unsafe\s+)?(?:fn|struct|enum|trait|const|static|type|mod)\s+(\w+)/gm,
24756
+ /macro_rules!\s+(\w+)/g
24757
+ ];
24758
+ GO_PATTERNS = [
24759
+ /^func\s+(\w+)\s*[([]/gm,
24760
+ /^func\s+\([^)]*\)\s+(\w+)\s*[([]/gm,
24761
+ /^type\s+(\w+)/gm,
24762
+ /^(?:var|const)\s+(\w+)/gm
24763
+ ];
24764
+ JAVA_PATTERNS = [
24765
+ /^\s*(?:(?:public|protected|private|final|abstract|static|sealed|non-sealed|strictfp)\s+)*(?:class|interface|enum|record)\s+(\w+)/gm
24766
+ ];
24767
+ KOTLIN_PATTERNS = [
24768
+ /^\s*(?:(?:public|internal|private|protected|open|abstract|sealed|data|enum|annotation|value|inline)\s+)*(?:class|interface|object)\s+(\w+)/gm,
24769
+ /^\s*(?:(?:public|internal|private|protected|open|override|suspend|inline|operator|infix|tailrec|external)\s+)*fun\s+(\w+)/gm
24770
+ ];
24771
+ CSHARP_PATTERNS = [
24772
+ /^\s*(?:(?:public|internal|private|protected|static|sealed|abstract|partial|readonly|unsafe|new|record)\s+)*(?:class|interface|struct|enum|record)\s+(\w+)/gm
24773
+ ];
24774
+ RUBY_PATTERNS = [/^\s*(?:def|class|module)\s+([A-Za-z_]\w*[?!]?)/gm];
24775
+ PHP_PATTERNS = [/\b(?:function|class|interface|trait|enum)\s+(\w+)/g];
24776
+ SWIFT_PATTERNS = [/\b(?:func|class|struct|enum|protocol|extension)\s+(\w+)/g];
24777
+ SCALA_PATTERNS = [
24778
+ /^\s*(?:(?:private|protected|final|abstract|sealed|implicit|lazy|override)\s+)*(?:def|class|object|trait)\s+(\w+)/gm
24779
+ ];
24780
+ C_CPP_PATTERNS = [
24781
+ /^\s*(?:typedef\s+)?(?:class|struct|enum|union|namespace)\s+(\w+)/gm,
24782
+ /\}\s*(\w+)\s*;/g
24783
+ ];
24784
+ SHELL_PATTERNS = [/^\s*(?:function\s+)?(\w+)\s*\(\s*\)\s*\{/gm];
24785
+ LUA_PATTERNS = [/^\s*(?:local\s+)?function\s+([\w.:]+)/gm];
24786
+ RULES = {
24787
+ typescript: { code: true, extract: tsLike },
24788
+ "typescript-react": { code: true, extract: tsLike },
24789
+ javascript: { code: true, extract: tsLike },
24790
+ "javascript-react": { code: true, extract: tsLike },
24791
+ python: { code: true, extract: (c) => collect(c, PYTHON_PATTERNS) },
24792
+ rust: { code: true, extract: (c) => collect(c, RUST_PATTERNS) },
24793
+ go: { code: true, extract: (c) => collect(c, GO_PATTERNS) },
24794
+ java: { code: true, extract: (c) => collect(c, JAVA_PATTERNS) },
24795
+ kotlin: { code: true, extract: (c) => collect(c, KOTLIN_PATTERNS) },
24796
+ csharp: { code: true, extract: (c) => collect(c, CSHARP_PATTERNS) },
24797
+ ruby: { code: true, extract: (c) => collect(c, RUBY_PATTERNS) },
24798
+ php: { code: true, extract: (c) => collect(c, PHP_PATTERNS) },
24799
+ swift: { code: true, extract: (c) => collect(c, SWIFT_PATTERNS) },
24800
+ scala: { code: true, extract: (c) => collect(c, SCALA_PATTERNS) },
24801
+ c: { code: true, extract: (c) => collect(c, C_CPP_PATTERNS) },
24802
+ cpp: { code: true, extract: (c) => collect(c, C_CPP_PATTERNS) },
24803
+ shell: { code: true, extract: (c) => collect(c, SHELL_PATTERNS) },
24804
+ lua: { code: true, extract: (c) => collect(c, LUA_PATTERNS) },
24805
+ json: { code: false, extract: NO_SYMBOLS },
24806
+ markdown: { code: false, extract: NO_SYMBOLS },
24807
+ yaml: { code: false, extract: NO_SYMBOLS },
24808
+ toml: { code: false, extract: NO_SYMBOLS },
24809
+ xml: { code: false, extract: NO_SYMBOLS },
24810
+ html: { code: false, extract: NO_SYMBOLS },
24811
+ css: { code: false, extract: NO_SYMBOLS }
24812
+ };
24813
+ EXT_TO_LANGUAGE = {
24814
+ ".ts": "typescript",
24815
+ ".mts": "typescript",
24816
+ ".cts": "typescript",
24817
+ ".tsx": "typescript-react",
24818
+ ".js": "javascript",
24819
+ ".mjs": "javascript",
24820
+ ".cjs": "javascript",
24821
+ ".jsx": "javascript-react",
24822
+ ".py": "python",
24823
+ ".pyi": "python",
24824
+ ".rs": "rust",
24825
+ ".go": "go",
24826
+ ".java": "java",
24827
+ ".kt": "kotlin",
24828
+ ".kts": "kotlin",
24829
+ ".cs": "csharp",
24830
+ ".rb": "ruby",
24831
+ ".php": "php",
24832
+ ".swift": "swift",
24833
+ ".scala": "scala",
24834
+ ".c": "c",
24835
+ ".h": "c",
24836
+ ".cpp": "cpp",
24837
+ ".cc": "cpp",
24838
+ ".cxx": "cpp",
24839
+ ".hpp": "cpp",
24840
+ ".hxx": "cpp",
24841
+ ".sh": "shell",
24842
+ ".bash": "shell",
24843
+ ".zsh": "shell",
24844
+ ".lua": "lua",
24845
+ ".json": "json",
24846
+ ".md": "markdown",
24847
+ ".markdown": "markdown",
24848
+ ".yaml": "yaml",
24849
+ ".yml": "yaml",
24850
+ ".toml": "toml",
24851
+ ".xml": "xml",
24852
+ ".html": "html",
24853
+ ".htm": "html",
24854
+ ".css": "css",
24855
+ ".scss": "css",
24856
+ ".less": "css"
24857
+ };
24858
+ });
24859
+
24585
24860
  // src/modules/indexer/walker.ts
24586
24861
  import { readdirSync as readdirSync15, readFileSync as readFileSync27, statSync as statSync8, lstatSync, existsSync as existsSync45, watch } from "fs";
24587
24862
  import { join as join38, relative as relative6, extname as extname7 } from "path";
24863
+ function isIgnoredDirName(name) {
24864
+ return IGNORE_DIRS.has(name.toLowerCase());
24865
+ }
24866
+ function isIgnoredPath(filename) {
24867
+ return filename.split(/[\\/]/).some((segment) => isIgnoredDirName(segment));
24868
+ }
24588
24869
 
24589
24870
  class Indexer {
24590
24871
  baseDir;
@@ -24595,7 +24876,7 @@ class Indexer {
24595
24876
  }
24596
24877
  watch(callback) {
24597
24878
  this.watcher = watch(this.baseDir, { recursive: true }, (event, filename) => {
24598
- if (filename && !Array.from(IGNORE_DIRS).some((dir) => filename.includes(dir))) {
24879
+ if (filename && !isIgnoredPath(filename)) {
24599
24880
  callback(event, filename);
24600
24881
  }
24601
24882
  });
@@ -24630,15 +24911,15 @@ class Indexer {
24630
24911
  continue;
24631
24912
  const stat2 = statSync8(fullPath);
24632
24913
  if (stat2.isDirectory()) {
24633
- if (!IGNORE_DIRS.has(entry)) {
24914
+ if (!isIgnoredDirName(entry)) {
24634
24915
  walkDir2(fullPath);
24635
24916
  }
24636
24917
  } else if (stat2.isFile()) {
24637
24918
  const ext = extname7(entry).toLowerCase();
24638
- const language = LANGUAGES[ext];
24919
+ const language = languageIdForExt(ext);
24639
24920
  if (language) {
24640
24921
  const content = readFileSync27(fullPath, "utf-8");
24641
- const exports = this.extractExports(content, language);
24922
+ const exports = extractSymbols(content, language);
24642
24923
  files.push({ path: relPath, language, exports, size: stat2.size });
24643
24924
  totalSize += stat2.size;
24644
24925
  count++;
@@ -24653,18 +24934,6 @@ class Indexer {
24653
24934
  walkDir2(this.baseDir);
24654
24935
  return { files, totalSize };
24655
24936
  }
24656
- extractExports(content, language) {
24657
- if (language === "typescript" || language === "javascript") {
24658
- const exports = [];
24659
- const exportRegex = /export\s+(?:const|function|class|interface|type|enum|default\s+(?:class|function))\s+(\w+)/g;
24660
- let match;
24661
- while ((match = exportRegex.exec(content)) !== null) {
24662
- exports.push(match[1]);
24663
- }
24664
- return exports;
24665
- }
24666
- return [];
24667
- }
24668
24937
  summarize(result) {
24669
24938
  const byLang = {};
24670
24939
  for (const f of result.files) {
@@ -24674,24 +24943,47 @@ class Indexer {
24674
24943
  return `[Index: ${result.files.length} files, ${(result.totalSize / 1024).toFixed(1)}KB (${langs})]`;
24675
24944
  }
24676
24945
  }
24677
- var logger2, LANGUAGES, IGNORE_DIRS;
24946
+ var logger2, IGNORE_DIRS;
24678
24947
  var init_walker = __esm(() => {
24679
24948
  init_app_logger();
24949
+ init_symbols();
24680
24950
  logger2 = new Logger("warn", "indexer");
24681
- LANGUAGES = {
24682
- ".ts": "typescript",
24683
- ".tsx": "typescript-react",
24684
- ".js": "javascript",
24685
- ".jsx": "javascript-react",
24686
- ".json": "json",
24687
- ".md": "markdown",
24688
- ".yaml": "yaml",
24689
- ".yml": "yaml",
24690
- ".py": "python",
24691
- ".rs": "rust",
24692
- ".go": "go"
24693
- };
24694
- IGNORE_DIRS = new Set(["node_modules", ".git", "dist", "build", ".mma", "coverage"]);
24951
+ IGNORE_DIRS = new Set([
24952
+ ".git",
24953
+ ".hg",
24954
+ ".svn",
24955
+ ".mma",
24956
+ "node_modules",
24957
+ "dist",
24958
+ "build",
24959
+ "coverage",
24960
+ ".next",
24961
+ ".nuxt",
24962
+ ".svelte-kit",
24963
+ ".turbo",
24964
+ ".parcel-cache",
24965
+ ".cache",
24966
+ "venv",
24967
+ ".venv",
24968
+ "env",
24969
+ "virtualenv",
24970
+ "__pycache__",
24971
+ ".pytest_cache",
24972
+ ".mypy_cache",
24973
+ ".ruff_cache",
24974
+ ".tox",
24975
+ "site-packages",
24976
+ "target",
24977
+ "vendor",
24978
+ ".bundle",
24979
+ ".gradle",
24980
+ "out",
24981
+ "obj",
24982
+ "pods",
24983
+ "deriveddata",
24984
+ ".idea",
24985
+ ".vscode"
24986
+ ]);
24695
24987
  });
24696
24988
 
24697
24989
  // src/modules/indexer/cache.ts
@@ -24734,6 +25026,71 @@ class IndexCache {
24734
25026
  }
24735
25027
  var init_cache = () => {};
24736
25028
 
25029
+ // src/modules/indexer/map-select.ts
25030
+ function isNoiseFile(file) {
25031
+ const base = toForwardSlash(file.path).split("/").pop()?.toLowerCase() ?? "";
25032
+ return NOISE_BASENAMES.has(base);
25033
+ }
25034
+ function isTestFile(path) {
25035
+ return path.startsWith("test/") || path.startsWith("tests/") || path.includes("/test/") || path.includes("/tests/") || path.includes("__tests__/") || /\.(test|spec)\.[a-z0-9]+$/i.test(path);
25036
+ }
25037
+ function rank(file) {
25038
+ const path = toForwardSlash(file.path).toLowerCase();
25039
+ if (isTestFile(path))
25040
+ return 1;
25041
+ if (isCodeLanguage(file.language))
25042
+ return 0;
25043
+ return 2;
25044
+ }
25045
+ function topDir(path) {
25046
+ const normalized = toForwardSlash(path);
25047
+ const slash = normalized.indexOf("/");
25048
+ return slash >= 0 ? normalized.slice(0, slash) : normalized;
25049
+ }
25050
+ function codeCountByTopDir(files) {
25051
+ const counts = new Map;
25052
+ for (const file of files) {
25053
+ if (isNoiseFile(file) || rank(file) !== 0)
25054
+ continue;
25055
+ const dir = topDir(file.path);
25056
+ counts.set(dir, (counts.get(dir) ?? 0) + 1);
25057
+ }
25058
+ return counts;
25059
+ }
25060
+ function selectMapFiles(files, max) {
25061
+ const codeByDir = codeCountByTopDir(files);
25062
+ return files.filter((file) => !isNoiseFile(file)).sort((a, b) => {
25063
+ const rankDiff = rank(a) - rank(b);
25064
+ if (rankDiff !== 0)
25065
+ return rankDiff;
25066
+ const densityDiff = (codeByDir.get(topDir(b.path)) ?? 0) - (codeByDir.get(topDir(a.path)) ?? 0);
25067
+ if (densityDiff !== 0)
25068
+ return densityDiff;
25069
+ const pathA = toForwardSlash(a.path);
25070
+ const pathB = toForwardSlash(b.path);
25071
+ const depthDiff = pathA.split("/").length - pathB.split("/").length;
25072
+ if (depthDiff !== 0)
25073
+ return depthDiff;
25074
+ return pathA < pathB ? -1 : pathA > pathB ? 1 : 0;
25075
+ }).slice(0, max);
25076
+ }
25077
+ var NOISE_BASENAMES;
25078
+ var init_map_select = __esm(() => {
25079
+ init_path_utils();
25080
+ init_symbols();
25081
+ NOISE_BASENAMES = new Set([
25082
+ "package-lock.json",
25083
+ "bun.lock",
25084
+ "bun.lockb",
25085
+ "yarn.lock",
25086
+ "pnpm-lock.yaml",
25087
+ "cargo.lock",
25088
+ "go.sum",
25089
+ "composer.lock",
25090
+ "poetry.lock"
25091
+ ]);
25092
+ });
25093
+
24737
25094
  // src/modules/indexer/project-profile.ts
24738
25095
  import { readFileSync as readFileSync29, existsSync as existsSync47 } from "fs";
24739
25096
  import { join as join40 } from "path";
@@ -24948,6 +25305,22 @@ class IndexerModule {
24948
25305
  return path.includes(q) || f.exports.some((e) => e.toLowerCase().includes(q));
24949
25306
  });
24950
25307
  }
25308
+ formatFind(query) {
25309
+ const matches = this.find(query);
25310
+ if (matches.length === 0) {
25311
+ return t("indexer.no_matches", { query });
25312
+ }
25313
+ const lines = matches.map((f) => {
25314
+ const path = toForwardSlash(f.path);
25315
+ const exports = f.exports.length > 0 ? `: ${f.exports.join(", ")}` : "";
25316
+ return `- ${path}${exports}`;
25317
+ }).join(`
25318
+ `);
25319
+ return t("indexer.find_results", { count: matches.length, results: lines });
25320
+ }
25321
+ getPromptMap() {
25322
+ return this.index ? this.formatMap(this.index) : null;
25323
+ }
24951
25324
  watch() {
24952
25325
  this.unwatch();
24953
25326
  try {
@@ -25001,13 +25374,14 @@ class IndexerModule {
25001
25374
  const stackLine = buildProjectProfileLine(this.baseDir);
25002
25375
  const dirCounts = this.getDirectoryCounts(result);
25003
25376
  const topDirs = Object.entries(dirCounts).sort((a, b) => b[1] - a[1]).slice(0, 10).map(([dir, count]) => `${dir} (${count})`).join(", ") || "-";
25004
- const fileLines = result.files.slice(0, 100).map((f) => {
25377
+ const listed = selectMapFiles(result.files, MAP_FILE_LIMIT);
25378
+ const fileLines = listed.map((f) => {
25005
25379
  const path = toForwardSlash(f.path);
25006
25380
  const exports = f.exports.length > 0 ? `: ${f.exports.join(", ")}` : "";
25007
25381
  return `- ${path}${exports}`;
25008
25382
  });
25009
- const more = result.files.length > 100 ? `
25010
- ${t("indexer.and_more", { count: result.files.length - 100 })}` : "";
25383
+ const more = result.files.length > listed.length ? `
25384
+ ${t("indexer.and_more", { count: result.files.length - listed.length })}` : "";
25011
25385
  const duplicates = this.findDuplicateBasenames(result);
25012
25386
  return [
25013
25387
  `${t("indexer.map_header")} (${this.baseDir})`,
@@ -25099,20 +25473,7 @@ ${stackLine2}` : summary2;
25099
25473
  const query = String(args.query || "").toLowerCase();
25100
25474
  if (!query)
25101
25475
  return { success: false, output: t("tool.invalid_params") };
25102
- const matches = this.find(query);
25103
- if (matches.length === 0) {
25104
- return this.makeResult(t("indexer.no_matches", { query }));
25105
- }
25106
- const lines = matches.map((f) => {
25107
- const path = toForwardSlash(f.path);
25108
- const exports = f.exports.length > 0 ? `: ${f.exports.join(", ")}` : "";
25109
- return `- ${path}${exports}`;
25110
- }).join(`
25111
- `);
25112
- return this.makeResult(t("indexer.find_results", {
25113
- count: matches.length,
25114
- results: lines
25115
- }));
25476
+ return this.makeResult(this.formatFind(query));
25116
25477
  }
25117
25478
  if (!this.index) {
25118
25479
  await this.buildIndex();
@@ -25132,9 +25493,11 @@ ${stackLine}` : summary;
25132
25493
  return { success: true, output, display: output };
25133
25494
  }
25134
25495
  }
25496
+ var MAP_FILE_LIMIT = 80;
25135
25497
  var init_module6 = __esm(() => {
25136
25498
  init_walker();
25137
25499
  init_cache();
25500
+ init_map_select();
25138
25501
  init_project_profile();
25139
25502
  init_i18n();
25140
25503
  init_path_utils();
@@ -26311,6 +26674,10 @@ async function bootstrap(configDir, projectDir, noAgentsMd, exitOnComplete, reas
26311
26674
  get: () => sessionManager.getSessionContext() ?? undefined,
26312
26675
  configurable: true
26313
26676
  });
26677
+ Object.defineProperty(toolCtx, "sessionManager", {
26678
+ get: () => sessionManager,
26679
+ configurable: true
26680
+ });
26314
26681
  const toolExecutor = new ToolExecutor(toolRegistry, toolCtx, pluginManager);
26315
26682
  toolCtx.llmProvider = llmProvider;
26316
26683
  toolCtx.toolExecutor = toolExecutor;
@@ -26385,7 +26752,7 @@ async function bootstrap(configDir, projectDir, noAgentsMd, exitOnComplete, reas
26385
26752
  const agentsMdBlocks = loadAgentsMdBlocks(baseDir, dir, noAgentsMd === true);
26386
26753
  const promptBlocks = [
26387
26754
  systemInfoPrompt,
26388
- ...moduleRegistry.collectPromptBlocks(["indexer"]),
26755
+ ...moduleRegistry.collectPromptBlocks(["indexer", "session"]),
26389
26756
  ...agentsMdBlocks,
26390
26757
  {
26391
26758
  content: "[Plan Reminder] An active plan may exist for this session. Before creating a new plan, check with `plan show`. If a plan is active, continue it — do NOT create a new plan.",
@@ -26418,7 +26785,12 @@ async function bootstrap(configDir, projectDir, noAgentsMd, exitOnComplete, reas
26418
26785
  const recommended = recommendContextSize(dry.includedTokens + overflowTokens);
26419
26786
  const hint = contextWindowHint(config, dir, recommended);
26420
26787
  for (const b of dry.overflow) {
26421
- logger4.warn(`Startup check: ${b.kind === "instructions" ? "AGENTS.md" : "project map"} (${b.estimatedTokens} tok) exceeds the system-prompt budget (${systemBudget} tok) — it will be summarized/truncated before the first run. To include it fully, ${hint}.`);
26788
+ logger4.warn(t("prompt.overflow.startup", {
26789
+ block: b.kind === "instructions" ? "AGENTS.md" : "project map",
26790
+ original: String(b.estimatedTokens),
26791
+ budget: String(systemBudget),
26792
+ hint
26793
+ }));
26422
26794
  }
26423
26795
  }
26424
26796
  }
@@ -26441,6 +26813,9 @@ async function bootstrap(configDir, projectDir, noAgentsMd, exitOnComplete, reas
26441
26813
  const skillsBlock = skillsModule.getSystemPromptBlock();
26442
26814
  if (skillsBlock)
26443
26815
  blocks.push(skillsBlock);
26816
+ const sessionBlock = sessionModule.getSystemPromptBlock();
26817
+ if (sessionBlock)
26818
+ blocks.push(sessionBlock);
26444
26819
  const mapBlock = indexerModule.getSystemPromptBlock();
26445
26820
  if (mapBlock)
26446
26821
  blocks.push(mapBlock);
@@ -27278,6 +27653,41 @@ var init_setup = __esm(() => {
27278
27653
  ];
27279
27654
  });
27280
27655
 
27656
+ // src/modules/indexer/map-command.ts
27657
+ async function runMapAction(module, action, query) {
27658
+ const summary = async () => {
27659
+ const result = await module.buildIndex();
27660
+ if (!result)
27661
+ return { ok: false, output: t("indexer.not_indexed") };
27662
+ return { ok: true, output: module.getPromptMap() ?? t("indexer.not_indexed") };
27663
+ };
27664
+ switch (action) {
27665
+ case "refresh": {
27666
+ const result = await module.refresh();
27667
+ if (!result)
27668
+ return { ok: false, output: t("indexer.not_indexed") };
27669
+ return {
27670
+ ok: true,
27671
+ output: `${t("map.refreshed")}
27672
+ ${module.getPromptMap() ?? ""}`.trimEnd()
27673
+ };
27674
+ }
27675
+ case "find": {
27676
+ const q = (query ?? "").trim();
27677
+ if (!q)
27678
+ return { ok: false, output: t("map.find_usage") };
27679
+ await module.buildIndex();
27680
+ return { ok: true, output: module.formatFind(q) };
27681
+ }
27682
+ case "summary":
27683
+ default:
27684
+ return summary();
27685
+ }
27686
+ }
27687
+ var init_map_command = __esm(() => {
27688
+ init_i18n();
27689
+ });
27690
+
27281
27691
  // node_modules/yaml/dist/nodes/identity.js
27282
27692
  var require_identity = __commonJS((exports) => {
27283
27693
  var ALIAS = Symbol.for("yaml.alias");
@@ -35712,6 +36122,22 @@ function registerConfigCommands(ctx) {
35712
36122
  }
35713
36123
  }
35714
36124
  });
36125
+ ctx.registerCommand({
36126
+ name: "map",
36127
+ description: t("repl.map"),
36128
+ usage: t("repl.map_usage"),
36129
+ action: async (args) => {
36130
+ const indexer = ctx.agent.getModule("indexer");
36131
+ if (!indexer) {
36132
+ console.log(pc2.yellow(t("indexer.not_indexed")));
36133
+ return;
36134
+ }
36135
+ const action = args[0] || "summary";
36136
+ const query = args.slice(1).join(" ");
36137
+ const result = await runMapAction(indexer, action, query);
36138
+ console.log(result.output);
36139
+ }
36140
+ });
35715
36141
  }
35716
36142
  function registerProviderCommands(ctx) {
35717
36143
  ctx.registerCommand({
@@ -36216,6 +36642,7 @@ var init_repl_commands = __esm(() => {
36216
36642
  init_setup();
36217
36643
  init_config2();
36218
36644
  init_token_counter();
36645
+ init_map_command();
36219
36646
  init_utils();
36220
36647
  version2 = readMmaVersion();
36221
36648
  COMMAND_GROUPS = {
@@ -36233,6 +36660,7 @@ var init_repl_commands = __esm(() => {
36233
36660
  reload: "agent",
36234
36661
  wizard: "agent",
36235
36662
  sysprompt: "agent",
36663
+ map: "agent",
36236
36664
  lsp: "agent",
36237
36665
  sessions: "session",
36238
36666
  new: "session",
@@ -36943,6 +37371,7 @@ function targetsFromProviders(entries) {
36943
37371
 
36944
37372
  // src/cli/commands.ts
36945
37373
  init_version();
37374
+ init_map_command();
36946
37375
 
36947
37376
  // src/modules/updater/changelog-reader.ts
36948
37377
  import { readFileSync as readFileSync35, existsSync as existsSync53 } from "fs";
@@ -37216,6 +37645,18 @@ function buildContextCommand(program2) {
37216
37645
  console.log(t("cli.context_set", { size: contextWindow }));
37217
37646
  });
37218
37647
  }
37648
+ function buildMapCommand(program2) {
37649
+ program2.command("map").description(t("cli.map.description")).argument("[action]", t("cli.map.action"), "summary").argument("[query]", t("cli.map.query")).action(async (action, query) => {
37650
+ const { agent } = await bootstrap();
37651
+ const indexer = agent.getModule("indexer");
37652
+ if (!indexer) {
37653
+ console.log(t("indexer.not_indexed"));
37654
+ return;
37655
+ }
37656
+ const result = await runMapAction(indexer, action, query);
37657
+ console.log(result.output);
37658
+ });
37659
+ }
37219
37660
  function buildProviderCommands(program2) {
37220
37661
  const provider = program2.command("provider").description(t("cli.manage_providers"));
37221
37662
  provider.command("check").description(t("cli.provider_check")).option("--timeout <ms>", "Per-provider probe timeout in ms").action(async (opts) => {
@@ -37399,6 +37840,7 @@ function createProgram() {
37399
37840
  buildConfigCommands(program2);
37400
37841
  buildModelCommands(program2);
37401
37842
  buildContextCommand(program2);
37843
+ buildMapCommand(program2);
37402
37844
  buildProviderCommands(program2);
37403
37845
  buildSessionCommands(program2);
37404
37846
  createSecurityCommand(program2);
@@ -38901,8 +39343,8 @@ async function probeLspServers(config, baseDir, deps = {}) {
38901
39343
  const timeoutCap = deps.timeoutMs ?? DEFAULT_PROBE_TIMEOUT_MS;
38902
39344
  const deadlineMs = deps.deadlineMs ?? DEFAULT_PROBE_DEADLINE_MS;
38903
39345
  const maxParallel = deps.maxParallel ?? DEFAULT_MAX_PARALLEL;
38904
- const collect = deps.collectFiles ?? collectCheckFiles;
38905
- const files = await collect(baseDir, config);
39346
+ const collect2 = deps.collectFiles ?? collectCheckFiles;
39347
+ const files = await collect2(baseDir, config);
38906
39348
  const seen = new Set;
38907
39349
  const servers = [];
38908
39350
  for (const file of files) {