@mastra/code-sdk 0.0.0-client-tool-results-20260912062135

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 (594) hide show
  1. package/LICENSE.md +32 -0
  2. package/README.md +37 -0
  3. package/dist/acp/agent.d.ts +35 -0
  4. package/dist/acp/agent.d.ts.map +1 -0
  5. package/dist/acp/agent.js +161 -0
  6. package/dist/acp/agent.js.map +1 -0
  7. package/dist/acp/event-mapper.d.ts +22 -0
  8. package/dist/acp/event-mapper.d.ts.map +1 -0
  9. package/dist/acp/event-mapper.js +214 -0
  10. package/dist/acp/event-mapper.js.map +1 -0
  11. package/dist/acp/index.d.ts +8 -0
  12. package/dist/acp/index.d.ts.map +1 -0
  13. package/dist/acp/index.js +65 -0
  14. package/dist/acp/index.js.map +1 -0
  15. package/dist/acp/server.d.ts +7 -0
  16. package/dist/acp/server.d.ts.map +1 -0
  17. package/dist/acp/server.js +35 -0
  18. package/dist/acp/server.js.map +1 -0
  19. package/dist/acp.d.ts +2 -0
  20. package/dist/acp.d.ts.map +1 -0
  21. package/dist/acp.js +2 -0
  22. package/dist/agents/context-audit.d.ts +84 -0
  23. package/dist/agents/context-audit.d.ts.map +1 -0
  24. package/dist/agents/context-audit.js +118 -0
  25. package/dist/agents/context-audit.js.map +1 -0
  26. package/dist/agents/credential-resolver.d.ts +63 -0
  27. package/dist/agents/credential-resolver.d.ts.map +1 -0
  28. package/dist/agents/credential-resolver.js +97 -0
  29. package/dist/agents/credential-resolver.js.map +1 -0
  30. package/dist/agents/custom-provider-source.d.ts +35 -0
  31. package/dist/agents/custom-provider-source.d.ts.map +1 -0
  32. package/dist/agents/custom-provider-source.js +25 -0
  33. package/dist/agents/custom-provider-source.js.map +1 -0
  34. package/dist/agents/instructions.d.ts +29 -0
  35. package/dist/agents/instructions.d.ts.map +1 -0
  36. package/dist/agents/instructions.js +58 -0
  37. package/dist/agents/instructions.js.map +1 -0
  38. package/dist/agents/mastracode-gateway.d.ts +74 -0
  39. package/dist/agents/mastracode-gateway.d.ts.map +1 -0
  40. package/dist/agents/mastracode-gateway.js +431 -0
  41. package/dist/agents/mastracode-gateway.js.map +1 -0
  42. package/dist/agents/memory.d.ts +30 -0
  43. package/dist/agents/memory.d.ts.map +1 -0
  44. package/dist/agents/memory.js +171 -0
  45. package/dist/agents/memory.js.map +1 -0
  46. package/dist/agents/model.d.ts +81 -0
  47. package/dist/agents/model.d.ts.map +1 -0
  48. package/dist/agents/model.js +155 -0
  49. package/dist/agents/model.js.map +1 -0
  50. package/dist/agents/modes/build.d.ts +10 -0
  51. package/dist/agents/modes/build.d.ts.map +1 -0
  52. package/dist/agents/modes/build.js +49 -0
  53. package/dist/agents/modes/build.js.map +1 -0
  54. package/dist/agents/modes/explore.d.ts +10 -0
  55. package/dist/agents/modes/explore.d.ts.map +1 -0
  56. package/dist/agents/modes/explore.js +42 -0
  57. package/dist/agents/modes/explore.js.map +1 -0
  58. package/dist/agents/modes/plan.d.ts +6 -0
  59. package/dist/agents/modes/plan.d.ts.map +1 -0
  60. package/dist/agents/modes/plan.js +42 -0
  61. package/dist/agents/modes/plan.js.map +1 -0
  62. package/dist/agents/prompts/agent-instructions.d.ts +70 -0
  63. package/dist/agents/prompts/agent-instructions.d.ts.map +1 -0
  64. package/dist/agents/prompts/agent-instructions.js +211 -0
  65. package/dist/agents/prompts/agent-instructions.js.map +1 -0
  66. package/dist/agents/prompts/build.d.ts +12 -0
  67. package/dist/agents/prompts/build.d.ts.map +1 -0
  68. package/dist/agents/prompts/build.js +76 -0
  69. package/dist/agents/prompts/build.js.map +1 -0
  70. package/dist/agents/prompts/fast.d.ts +5 -0
  71. package/dist/agents/prompts/fast.d.ts.map +1 -0
  72. package/dist/agents/prompts/fast.js +26 -0
  73. package/dist/agents/prompts/fast.js.map +1 -0
  74. package/dist/agents/prompts/index.d.ts +50 -0
  75. package/dist/agents/prompts/index.d.ts.map +1 -0
  76. package/dist/agents/prompts/index.js +119 -0
  77. package/dist/agents/prompts/index.js.map +1 -0
  78. package/dist/agents/prompts/model.d.ts +5 -0
  79. package/dist/agents/prompts/model.d.ts.map +1 -0
  80. package/dist/agents/prompts/model.js +23 -0
  81. package/dist/agents/prompts/model.js.map +1 -0
  82. package/dist/agents/prompts/plan.d.ts +6 -0
  83. package/dist/agents/prompts/plan.d.ts.map +1 -0
  84. package/dist/agents/prompts/plan.js +111 -0
  85. package/dist/agents/prompts/plan.js.map +1 -0
  86. package/dist/agents/prompts/tool-guidance.d.ts +18 -0
  87. package/dist/agents/prompts/tool-guidance.d.ts.map +1 -0
  88. package/dist/agents/prompts/tool-guidance.js +180 -0
  89. package/dist/agents/prompts/tool-guidance.js.map +1 -0
  90. package/dist/agents/sandbox-filesystem.d.ts +117 -0
  91. package/dist/agents/sandbox-filesystem.d.ts.map +1 -0
  92. package/dist/agents/sandbox-filesystem.js +356 -0
  93. package/dist/agents/sandbox-filesystem.js.map +1 -0
  94. package/dist/agents/subagents/execute.d.ts +3 -0
  95. package/dist/agents/subagents/execute.d.ts.map +1 -0
  96. package/dist/agents/subagents/execute.js +27 -0
  97. package/dist/agents/subagents/execute.js.map +1 -0
  98. package/dist/agents/subagents/explore.d.ts +3 -0
  99. package/dist/agents/subagents/explore.d.ts.map +1 -0
  100. package/dist/agents/subagents/explore.js +18 -0
  101. package/dist/agents/subagents/explore.js.map +1 -0
  102. package/dist/agents/subagents/plan.d.ts +3 -0
  103. package/dist/agents/subagents/plan.d.ts.map +1 -0
  104. package/dist/agents/subagents/plan.js +18 -0
  105. package/dist/agents/subagents/plan.js.map +1 -0
  106. package/dist/agents/thread-caveman-state.d.ts +17 -0
  107. package/dist/agents/thread-caveman-state.d.ts.map +1 -0
  108. package/dist/agents/thread-caveman-state.js +107 -0
  109. package/dist/agents/thread-caveman-state.js.map +1 -0
  110. package/dist/agents/tool-availability.d.ts +10 -0
  111. package/dist/agents/tool-availability.d.ts.map +1 -0
  112. package/dist/agents/tool-availability.js +96 -0
  113. package/dist/agents/tool-availability.js.map +1 -0
  114. package/dist/agents/tools.d.ts +36 -0
  115. package/dist/agents/tools.d.ts.map +1 -0
  116. package/dist/agents/tools.js +117 -0
  117. package/dist/agents/tools.js.map +1 -0
  118. package/dist/agents/workflow-builder-agent.d.ts +2 -0
  119. package/dist/agents/workflow-builder-agent.d.ts.map +1 -0
  120. package/dist/agents/workflow-builder-agent.js +80 -0
  121. package/dist/agents/workflow-builder-agent.js.map +1 -0
  122. package/dist/agents/workspace.d.ts +32 -0
  123. package/dist/agents/workspace.d.ts.map +1 -0
  124. package/dist/agents/workspace.js +208 -0
  125. package/dist/agents/workspace.js.map +1 -0
  126. package/dist/analytics.d.ts +18 -0
  127. package/dist/analytics.d.ts.map +1 -0
  128. package/dist/analytics.js +163 -0
  129. package/dist/analytics.js.map +1 -0
  130. package/dist/auth/authorization-input.d.ts +16 -0
  131. package/dist/auth/authorization-input.d.ts.map +1 -0
  132. package/dist/auth/authorization-input.js +42 -0
  133. package/dist/auth/authorization-input.js.map +1 -0
  134. package/dist/auth/device-code.d.ts +93 -0
  135. package/dist/auth/device-code.d.ts.map +1 -0
  136. package/dist/auth/device-code.js +129 -0
  137. package/dist/auth/device-code.js.map +1 -0
  138. package/dist/auth/index.d.ts +12 -0
  139. package/dist/auth/index.d.ts.map +1 -0
  140. package/dist/auth/index.js +8 -0
  141. package/dist/auth/pkce.d.ts +13 -0
  142. package/dist/auth/pkce.d.ts.map +1 -0
  143. package/dist/auth/pkce.js +32 -0
  144. package/dist/auth/pkce.js.map +1 -0
  145. package/dist/auth/provider-auth-error.d.ts +12 -0
  146. package/dist/auth/provider-auth-error.d.ts.map +1 -0
  147. package/dist/auth/provider-auth-error.js +16 -0
  148. package/dist/auth/provider-auth-error.js.map +1 -0
  149. package/dist/auth/providers/anthropic.d.ts +40 -0
  150. package/dist/auth/providers/anthropic.d.ts.map +1 -0
  151. package/dist/auth/providers/anthropic.js +126 -0
  152. package/dist/auth/providers/anthropic.js.map +1 -0
  153. package/dist/auth/providers/github-copilot.d.ts +154 -0
  154. package/dist/auth/providers/github-copilot.d.ts.map +1 -0
  155. package/dist/auth/providers/github-copilot.js +340 -0
  156. package/dist/auth/providers/github-copilot.js.map +1 -0
  157. package/dist/auth/providers/kimi-coding.d.ts +38 -0
  158. package/dist/auth/providers/kimi-coding.d.ts.map +1 -0
  159. package/dist/auth/providers/kimi-coding.js +232 -0
  160. package/dist/auth/providers/kimi-coding.js.map +1 -0
  161. package/dist/auth/providers/openai-codex.d.ts +139 -0
  162. package/dist/auth/providers/openai-codex.d.ts.map +1 -0
  163. package/dist/auth/providers/openai-codex.js +519 -0
  164. package/dist/auth/providers/openai-codex.js.map +1 -0
  165. package/dist/auth/providers/xai.d.ts +64 -0
  166. package/dist/auth/providers/xai.d.ts.map +1 -0
  167. package/dist/auth/providers/xai.js +205 -0
  168. package/dist/auth/providers/xai.js.map +1 -0
  169. package/dist/auth/storage.d.ts +92 -0
  170. package/dist/auth/storage.d.ts.map +1 -0
  171. package/dist/auth/storage.js +211 -0
  172. package/dist/auth/storage.js.map +1 -0
  173. package/dist/auth/types.d.ts +89 -0
  174. package/dist/auth/types.d.ts.map +1 -0
  175. package/dist/auth/types.js +1 -0
  176. package/dist/clipboard/index.d.ts +26 -0
  177. package/dist/clipboard/index.d.ts.map +1 -0
  178. package/dist/clipboard/index.js +226 -0
  179. package/dist/clipboard/index.js.map +1 -0
  180. package/dist/constants.d.ts +10 -0
  181. package/dist/constants.d.ts.map +1 -0
  182. package/dist/constants.js +18 -0
  183. package/dist/constants.js.map +1 -0
  184. package/dist/error-classification.d.ts +10 -0
  185. package/dist/error-classification.d.ts.map +1 -0
  186. package/dist/error-classification.js +22 -0
  187. package/dist/error-classification.js.map +1 -0
  188. package/dist/evals/context-builder.d.ts +41 -0
  189. package/dist/evals/context-builder.d.ts.map +1 -0
  190. package/dist/evals/context-builder.js +161 -0
  191. package/dist/evals/context-builder.js.map +1 -0
  192. package/dist/evals/index.d.ts +4 -0
  193. package/dist/evals/index.d.ts.map +1 -0
  194. package/dist/evals/index.js +5 -0
  195. package/dist/evals/scorers/classify-command.d.ts +31 -0
  196. package/dist/evals/scorers/classify-command.d.ts.map +1 -0
  197. package/dist/evals/scorers/classify-command.js +73 -0
  198. package/dist/evals/scorers/classify-command.js.map +1 -0
  199. package/dist/evals/scorers/efficiency.d.ts +44 -0
  200. package/dist/evals/scorers/efficiency.d.ts.map +1 -0
  201. package/dist/evals/scorers/efficiency.js +259 -0
  202. package/dist/evals/scorers/efficiency.js.map +1 -0
  203. package/dist/evals/scorers/extract-tools.d.ts +25 -0
  204. package/dist/evals/scorers/extract-tools.d.ts.map +1 -0
  205. package/dist/evals/scorers/extract-tools.js +60 -0
  206. package/dist/evals/scorers/extract-tools.js.map +1 -0
  207. package/dist/evals/scorers/index.d.ts +3 -0
  208. package/dist/evals/scorers/index.d.ts.map +1 -0
  209. package/dist/evals/scorers/index.js +3 -0
  210. package/dist/evals/scorers/outcome.d.ts +49 -0
  211. package/dist/evals/scorers/outcome.d.ts.map +1 -0
  212. package/dist/evals/scorers/outcome.js +347 -0
  213. package/dist/evals/scorers/outcome.js.map +1 -0
  214. package/dist/goal-manager.d.ts +78 -0
  215. package/dist/goal-manager.d.ts.map +1 -0
  216. package/dist/goal-manager.js +273 -0
  217. package/dist/goal-manager.js.map +1 -0
  218. package/dist/goal-signal.d.ts +14 -0
  219. package/dist/goal-signal.d.ts.map +1 -0
  220. package/dist/goal-signal.js +17 -0
  221. package/dist/goal-signal.js.map +1 -0
  222. package/dist/headless/cli.d.ts +42 -0
  223. package/dist/headless/cli.d.ts.map +1 -0
  224. package/dist/headless/cli.js +209 -0
  225. package/dist/headless/cli.js.map +1 -0
  226. package/dist/headless/flags.d.ts +33 -0
  227. package/dist/headless/flags.d.ts.map +1 -0
  228. package/dist/headless/flags.js +190 -0
  229. package/dist/headless/flags.js.map +1 -0
  230. package/dist/headless/format.d.ts +38 -0
  231. package/dist/headless/format.d.ts.map +1 -0
  232. package/dist/headless/format.js +89 -0
  233. package/dist/headless/format.js.map +1 -0
  234. package/dist/headless/index.d.ts +25 -0
  235. package/dist/headless/index.d.ts.map +1 -0
  236. package/dist/headless/index.js +6 -0
  237. package/dist/headless/policy.d.ts +17 -0
  238. package/dist/headless/policy.d.ts.map +1 -0
  239. package/dist/headless/policy.js +42 -0
  240. package/dist/headless/policy.js.map +1 -0
  241. package/dist/headless/run-mc.d.ts +7 -0
  242. package/dist/headless/run-mc.d.ts.map +1 -0
  243. package/dist/headless/run-mc.js +346 -0
  244. package/dist/headless/run-mc.js.map +1 -0
  245. package/dist/headless/types.d.ts +158 -0
  246. package/dist/headless/types.d.ts.map +1 -0
  247. package/dist/headless/types.js +19 -0
  248. package/dist/headless/types.js.map +1 -0
  249. package/dist/hooks/config.d.ts +11 -0
  250. package/dist/hooks/config.d.ts.map +1 -0
  251. package/dist/hooks/config.js +73 -0
  252. package/dist/hooks/config.js.map +1 -0
  253. package/dist/hooks/executor.d.ts +13 -0
  254. package/dist/hooks/executor.d.ts.map +1 -0
  255. package/dist/hooks/executor.js +129 -0
  256. package/dist/hooks/executor.js.map +1 -0
  257. package/dist/hooks/index.d.ts +6 -0
  258. package/dist/hooks/index.d.ts.map +1 -0
  259. package/dist/hooks/index.js +5 -0
  260. package/dist/hooks/manager.d.ts +54 -0
  261. package/dist/hooks/manager.d.ts.map +1 -0
  262. package/dist/hooks/manager.js +241 -0
  263. package/dist/hooks/manager.js.map +1 -0
  264. package/dist/hooks/types.d.ts +172 -0
  265. package/dist/hooks/types.d.ts.map +1 -0
  266. package/dist/hooks/types.js +8 -0
  267. package/dist/hooks/types.js.map +1 -0
  268. package/dist/index.d.ts +341 -0
  269. package/dist/index.d.ts.map +1 -0
  270. package/dist/index.js +919 -0
  271. package/dist/index.js.map +1 -0
  272. package/dist/ipc/ipc-reporter.d.ts +14 -0
  273. package/dist/ipc/ipc-reporter.d.ts.map +1 -0
  274. package/dist/ipc/ipc-reporter.js +21 -0
  275. package/dist/ipc/ipc-reporter.js.map +1 -0
  276. package/dist/knowledge-inspector.d.ts +119 -0
  277. package/dist/knowledge-inspector.d.ts.map +1 -0
  278. package/dist/knowledge-inspector.js +508 -0
  279. package/dist/knowledge-inspector.js.map +1 -0
  280. package/dist/knowledge-scope.d.ts +35 -0
  281. package/dist/knowledge-scope.d.ts.map +1 -0
  282. package/dist/knowledge-scope.js +47 -0
  283. package/dist/knowledge-scope.js.map +1 -0
  284. package/dist/lsp/client.d.ts +56 -0
  285. package/dist/lsp/client.d.ts.map +1 -0
  286. package/dist/lsp/client.js +251 -0
  287. package/dist/lsp/client.js.map +1 -0
  288. package/dist/lsp/index.d.ts +4 -0
  289. package/dist/lsp/index.d.ts.map +1 -0
  290. package/dist/lsp/index.js +4 -0
  291. package/dist/lsp/language.d.ts +9 -0
  292. package/dist/lsp/language.d.ts.map +1 -0
  293. package/dist/lsp/language.js +44 -0
  294. package/dist/lsp/language.js.map +1 -0
  295. package/dist/lsp/manager.d.ts +34 -0
  296. package/dist/lsp/manager.d.ts.map +1 -0
  297. package/dist/lsp/manager.js +82 -0
  298. package/dist/lsp/manager.js.map +1 -0
  299. package/dist/lsp/server.d.ts +27 -0
  300. package/dist/lsp/server.d.ts.map +1 -0
  301. package/dist/lsp/server.js +159 -0
  302. package/dist/lsp/server.js.map +1 -0
  303. package/dist/lsp/workspace.d.ts +9 -0
  304. package/dist/lsp/workspace.d.ts.map +1 -0
  305. package/dist/lsp/workspace.js +55 -0
  306. package/dist/lsp/workspace.js.map +1 -0
  307. package/dist/mcp/config.d.ts +62 -0
  308. package/dist/mcp/config.d.ts.map +1 -0
  309. package/dist/mcp/config.js +301 -0
  310. package/dist/mcp/config.js.map +1 -0
  311. package/dist/mcp/index.d.ts +6 -0
  312. package/dist/mcp/index.d.ts.map +1 -0
  313. package/dist/mcp/index.js +3 -0
  314. package/dist/mcp/manager.d.ts +101 -0
  315. package/dist/mcp/manager.d.ts.map +1 -0
  316. package/dist/mcp/manager.js +644 -0
  317. package/dist/mcp/manager.js.map +1 -0
  318. package/dist/mcp/state.d.ts +35 -0
  319. package/dist/mcp/state.d.ts.map +1 -0
  320. package/dist/mcp/state.js +97 -0
  321. package/dist/mcp/state.js.map +1 -0
  322. package/dist/mcp/types.d.ts +125 -0
  323. package/dist/mcp/types.d.ts.map +1 -0
  324. package/dist/mcp/types.js +1 -0
  325. package/dist/onboarding/custom-packs.d.ts +7 -0
  326. package/dist/onboarding/custom-packs.d.ts.map +1 -0
  327. package/dist/onboarding/custom-packs.js +17 -0
  328. package/dist/onboarding/custom-packs.js.map +1 -0
  329. package/dist/onboarding/custom-providers.d.ts +4 -0
  330. package/dist/onboarding/custom-providers.d.ts.map +1 -0
  331. package/dist/onboarding/custom-providers.js +30 -0
  332. package/dist/onboarding/custom-providers.js.map +1 -0
  333. package/dist/onboarding/index.d.ts +5 -0
  334. package/dist/onboarding/index.d.ts.map +1 -0
  335. package/dist/onboarding/index.js +3 -0
  336. package/dist/onboarding/om-settings.d.ts +25 -0
  337. package/dist/onboarding/om-settings.d.ts.map +1 -0
  338. package/dist/onboarding/om-settings.js +47 -0
  339. package/dist/onboarding/om-settings.js.map +1 -0
  340. package/dist/onboarding/packs.d.ts +49 -0
  341. package/dist/onboarding/packs.d.ts.map +1 -0
  342. package/dist/onboarding/packs.js +182 -0
  343. package/dist/onboarding/packs.js.map +1 -0
  344. package/dist/onboarding/settings.d.ts +438 -0
  345. package/dist/onboarding/settings.d.ts.map +1 -0
  346. package/dist/onboarding/settings.js +847 -0
  347. package/dist/onboarding/settings.js.map +1 -0
  348. package/dist/permissions.d.ts +55 -0
  349. package/dist/permissions.d.ts.map +1 -0
  350. package/dist/permissions.js +137 -0
  351. package/dist/permissions.js.map +1 -0
  352. package/dist/plugin.d.ts +144 -0
  353. package/dist/plugin.d.ts.map +1 -0
  354. package/dist/plugin.js +30 -0
  355. package/dist/plugin.js.map +1 -0
  356. package/dist/plugins/dependencies.d.ts +9 -0
  357. package/dist/plugins/dependencies.d.ts.map +1 -0
  358. package/dist/plugins/dependencies.js +88 -0
  359. package/dist/plugins/dependencies.js.map +1 -0
  360. package/dist/plugins/install.d.ts +21 -0
  361. package/dist/plugins/install.d.ts.map +1 -0
  362. package/dist/plugins/install.js +190 -0
  363. package/dist/plugins/install.js.map +1 -0
  364. package/dist/plugins/loader.d.ts +19 -0
  365. package/dist/plugins/loader.d.ts.map +1 -0
  366. package/dist/plugins/loader.js +258 -0
  367. package/dist/plugins/loader.js.map +1 -0
  368. package/dist/plugins/manager.d.ts +98 -0
  369. package/dist/plugins/manager.d.ts.map +1 -0
  370. package/dist/plugins/manager.js +456 -0
  371. package/dist/plugins/manager.js.map +1 -0
  372. package/dist/plugins/manifest.d.ts +14 -0
  373. package/dist/plugins/manifest.d.ts.map +1 -0
  374. package/dist/plugins/manifest.js +50 -0
  375. package/dist/plugins/manifest.js.map +1 -0
  376. package/dist/plugins/package-link.d.ts +3 -0
  377. package/dist/plugins/package-link.d.ts.map +1 -0
  378. package/dist/plugins/package-link.js +61 -0
  379. package/dist/plugins/package-link.js.map +1 -0
  380. package/dist/plugins/paths.d.ts +10 -0
  381. package/dist/plugins/paths.d.ts.map +1 -0
  382. package/dist/plugins/paths.js +25 -0
  383. package/dist/plugins/paths.js.map +1 -0
  384. package/dist/plugins/registry.d.ts +8 -0
  385. package/dist/plugins/registry.d.ts.map +1 -0
  386. package/dist/plugins/registry.js +112 -0
  387. package/dist/plugins/registry.js.map +1 -0
  388. package/dist/plugins/scaffold.d.ts +10 -0
  389. package/dist/plugins/scaffold.d.ts.map +1 -0
  390. package/dist/plugins/scaffold.js +116 -0
  391. package/dist/plugins/scaffold.js.map +1 -0
  392. package/dist/plugins/signal-lane.d.ts +58 -0
  393. package/dist/plugins/signal-lane.d.ts.map +1 -0
  394. package/dist/plugins/signal-lane.js +166 -0
  395. package/dist/plugins/signal-lane.js.map +1 -0
  396. package/dist/plugins/types.d.ts +81 -0
  397. package/dist/plugins/types.d.ts.map +1 -0
  398. package/dist/plugins/types.js +1 -0
  399. package/dist/process-memory-diagnostics.d.ts +135 -0
  400. package/dist/process-memory-diagnostics.d.ts.map +1 -0
  401. package/dist/process-memory-diagnostics.js +500 -0
  402. package/dist/process-memory-diagnostics.js.map +1 -0
  403. package/dist/processors/plan-rejection-abort.d.ts +12 -0
  404. package/dist/processors/plan-rejection-abort.d.ts.map +1 -0
  405. package/dist/processors/plan-rejection-abort.js +54 -0
  406. package/dist/processors/plan-rejection-abort.js.map +1 -0
  407. package/dist/providers/amazon-bedrock-gateway.d.ts +47 -0
  408. package/dist/providers/amazon-bedrock-gateway.d.ts.map +1 -0
  409. package/dist/providers/amazon-bedrock-gateway.js +153 -0
  410. package/dist/providers/amazon-bedrock-gateway.js.map +1 -0
  411. package/dist/providers/amazon-bedrock.d.ts +28 -0
  412. package/dist/providers/amazon-bedrock.d.ts.map +1 -0
  413. package/dist/providers/amazon-bedrock.js +102 -0
  414. package/dist/providers/amazon-bedrock.js.map +1 -0
  415. package/dist/providers/claude-max.d.ts +65 -0
  416. package/dist/providers/claude-max.d.ts.map +1 -0
  417. package/dist/providers/claude-max.js +252 -0
  418. package/dist/providers/claude-max.js.map +1 -0
  419. package/dist/providers/github-copilot.d.ts +60 -0
  420. package/dist/providers/github-copilot.d.ts.map +1 -0
  421. package/dist/providers/github-copilot.js +266 -0
  422. package/dist/providers/github-copilot.js.map +1 -0
  423. package/dist/providers/kimi-coding.d.ts +15 -0
  424. package/dist/providers/kimi-coding.d.ts.map +1 -0
  425. package/dist/providers/kimi-coding.js +69 -0
  426. package/dist/providers/kimi-coding.js.map +1 -0
  427. package/dist/providers/openai-codex.d.ts +73 -0
  428. package/dist/providers/openai-codex.d.ts.map +1 -0
  429. package/dist/providers/openai-codex.js +306 -0
  430. package/dist/providers/openai-codex.js.map +1 -0
  431. package/dist/providers/xai.d.ts +33 -0
  432. package/dist/providers/xai.d.ts.map +1 -0
  433. package/dist/providers/xai.js +71 -0
  434. package/dist/providers/xai.js.map +1 -0
  435. package/dist/schema.d.ts +200 -0
  436. package/dist/schema.d.ts.map +1 -0
  437. package/dist/schema.js +92 -0
  438. package/dist/schema.js.map +1 -0
  439. package/dist/theme-palette.d.ts +17 -0
  440. package/dist/theme-palette.d.ts.map +1 -0
  441. package/dist/theme-palette.js +21 -0
  442. package/dist/theme-palette.js.map +1 -0
  443. package/dist/thinking.d.ts +33 -0
  444. package/dist/thinking.d.ts.map +1 -0
  445. package/dist/thinking.js +58 -0
  446. package/dist/thinking.js.map +1 -0
  447. package/dist/tool-names.d.ts +73 -0
  448. package/dist/tool-names.d.ts.map +1 -0
  449. package/dist/tool-names.js +52 -0
  450. package/dist/tool-names.js.map +1 -0
  451. package/dist/tools/index.d.ts +6 -0
  452. package/dist/tools/index.d.ts.map +1 -0
  453. package/dist/tools/index.js +3 -0
  454. package/dist/tools/request-sandbox-access.d.ts +6 -0
  455. package/dist/tools/request-sandbox-access.d.ts.map +1 -0
  456. package/dist/tools/request-sandbox-access.js +79 -0
  457. package/dist/tools/request-sandbox-access.js.map +1 -0
  458. package/dist/tools/utils.d.ts +20 -0
  459. package/dist/tools/utils.d.ts.map +1 -0
  460. package/dist/tools/utils.js +32 -0
  461. package/dist/tools/utils.js.map +1 -0
  462. package/dist/tools/web-search.d.ts +114 -0
  463. package/dist/tools/web-search.d.ts.map +1 -0
  464. package/dist/tools/web-search.js +155 -0
  465. package/dist/tools/web-search.js.map +1 -0
  466. package/dist/tools/workflows/create-workflow.d.ts +7 -0
  467. package/dist/tools/workflows/create-workflow.d.ts.map +1 -0
  468. package/dist/tools/workflows/create-workflow.js +81 -0
  469. package/dist/tools/workflows/create-workflow.js.map +1 -0
  470. package/dist/tools/workflows/delete-workflow.d.ts +7 -0
  471. package/dist/tools/workflows/delete-workflow.d.ts.map +1 -0
  472. package/dist/tools/workflows/delete-workflow.js +21 -0
  473. package/dist/tools/workflows/delete-workflow.js.map +1 -0
  474. package/dist/tools/workflows/ephemeral-memory.d.ts +7 -0
  475. package/dist/tools/workflows/ephemeral-memory.d.ts.map +1 -0
  476. package/dist/tools/workflows/ephemeral-memory.js +45 -0
  477. package/dist/tools/workflows/ephemeral-memory.js.map +1 -0
  478. package/dist/tools/workflows/extract-json-schema.d.ts +12 -0
  479. package/dist/tools/workflows/extract-json-schema.d.ts.map +1 -0
  480. package/dist/tools/workflows/extract-json-schema.js +22 -0
  481. package/dist/tools/workflows/extract-json-schema.js.map +1 -0
  482. package/dist/tools/workflows/get-workflow.d.ts +11 -0
  483. package/dist/tools/workflows/get-workflow.d.ts.map +1 -0
  484. package/dist/tools/workflows/get-workflow.js +34 -0
  485. package/dist/tools/workflows/get-workflow.js.map +1 -0
  486. package/dist/tools/workflows/list-available-agents.d.ts +8 -0
  487. package/dist/tools/workflows/list-available-agents.d.ts.map +1 -0
  488. package/dist/tools/workflows/list-available-agents.js +32 -0
  489. package/dist/tools/workflows/list-available-agents.js.map +1 -0
  490. package/dist/tools/workflows/list-available-tools.d.ts +9 -0
  491. package/dist/tools/workflows/list-available-tools.d.ts.map +1 -0
  492. package/dist/tools/workflows/list-available-tools.js +40 -0
  493. package/dist/tools/workflows/list-available-tools.js.map +1 -0
  494. package/dist/tools/workflows/list-available-workflows.d.ts +9 -0
  495. package/dist/tools/workflows/list-available-workflows.d.ts.map +1 -0
  496. package/dist/tools/workflows/list-available-workflows.js +32 -0
  497. package/dist/tools/workflows/list-available-workflows.js.map +1 -0
  498. package/dist/tools/workflows/list-workflows.d.ts +9 -0
  499. package/dist/tools/workflows/list-workflows.d.ts.map +1 -0
  500. package/dist/tools/workflows/list-workflows.js +33 -0
  501. package/dist/tools/workflows/list-workflows.js.map +1 -0
  502. package/dist/tools/workflows/run-workflow.d.ts +9 -0
  503. package/dist/tools/workflows/run-workflow.d.ts.map +1 -0
  504. package/dist/tools/workflows/run-workflow.js +52 -0
  505. package/dist/tools/workflows/run-workflow.js.map +1 -0
  506. package/dist/tools/workflows/save-workflow.d.ts +1015 -0
  507. package/dist/tools/workflows/save-workflow.d.ts.map +1 -0
  508. package/dist/tools/workflows/save-workflow.js +28 -0
  509. package/dist/tools/workflows/save-workflow.js.map +1 -0
  510. package/dist/tools/workflows/tool-ids.d.ts +15 -0
  511. package/dist/tools/workflows/tool-ids.d.ts.map +1 -0
  512. package/dist/tools/workflows/tool-ids.js +19 -0
  513. package/dist/tools/workflows/tool-ids.js.map +1 -0
  514. package/dist/utils/binaries.d.ts +7 -0
  515. package/dist/utils/binaries.d.ts.map +1 -0
  516. package/dist/utils/binaries.js +78 -0
  517. package/dist/utils/binaries.js.map +1 -0
  518. package/dist/utils/debug-log.d.ts +12 -0
  519. package/dist/utils/debug-log.d.ts.map +1 -0
  520. package/dist/utils/debug-log.js +59 -0
  521. package/dist/utils/debug-log.js.map +1 -0
  522. package/dist/utils/errors.d.ts +36 -0
  523. package/dist/utils/errors.d.ts.map +1 -0
  524. package/dist/utils/errors.js +196 -0
  525. package/dist/utils/errors.js.map +1 -0
  526. package/dist/utils/gateway-sync.d.ts +26 -0
  527. package/dist/utils/gateway-sync.d.ts.map +1 -0
  528. package/dist/utils/gateway-sync.js +61 -0
  529. package/dist/utils/gateway-sync.js.map +1 -0
  530. package/dist/utils/path-security.d.ts +2 -0
  531. package/dist/utils/path-security.d.ts.map +1 -0
  532. package/dist/utils/path-security.js +10 -0
  533. package/dist/utils/path-security.js.map +1 -0
  534. package/dist/utils/plan-diff.d.ts +25 -0
  535. package/dist/utils/plan-diff.d.ts.map +1 -0
  536. package/dist/utils/plan-diff.js +62 -0
  537. package/dist/utils/plan-diff.js.map +1 -0
  538. package/dist/utils/plans.d.ts +59 -0
  539. package/dist/utils/plans.d.ts.map +1 -0
  540. package/dist/utils/plans.js +117 -0
  541. package/dist/utils/plans.js.map +1 -0
  542. package/dist/utils/project.d.ts +160 -0
  543. package/dist/utils/project.d.ts.map +1 -0
  544. package/dist/utils/project.js +364 -0
  545. package/dist/utils/project.js.map +1 -0
  546. package/dist/utils/signals-pubsub.d.ts +41 -0
  547. package/dist/utils/signals-pubsub.d.ts.map +1 -0
  548. package/dist/utils/signals-pubsub.js +122 -0
  549. package/dist/utils/signals-pubsub.js.map +1 -0
  550. package/dist/utils/slash-command-loader.d.ts +52 -0
  551. package/dist/utils/slash-command-loader.d.ts.map +1 -0
  552. package/dist/utils/slash-command-loader.js +142 -0
  553. package/dist/utils/slash-command-loader.js.map +1 -0
  554. package/dist/utils/slash-command-processor.d.ts +14 -0
  555. package/dist/utils/slash-command-processor.d.ts.map +1 -0
  556. package/dist/utils/slash-command-processor.js +109 -0
  557. package/dist/utils/slash-command-processor.js.map +1 -0
  558. package/dist/utils/stdin-pipe.d.ts +33 -0
  559. package/dist/utils/stdin-pipe.d.ts.map +1 -0
  560. package/dist/utils/stdin-pipe.js +96 -0
  561. package/dist/utils/stdin-pipe.js.map +1 -0
  562. package/dist/utils/storage-factory.d.ts +50 -0
  563. package/dist/utils/storage-factory.d.ts.map +1 -0
  564. package/dist/utils/storage-factory.js +121 -0
  565. package/dist/utils/storage-factory.js.map +1 -0
  566. package/dist/utils/storage-maintenance.d.ts +103 -0
  567. package/dist/utils/storage-maintenance.d.ts.map +1 -0
  568. package/dist/utils/storage-maintenance.js +274 -0
  569. package/dist/utils/storage-maintenance.js.map +1 -0
  570. package/dist/utils/thread-lock.d.ts +26 -0
  571. package/dist/utils/thread-lock.d.ts.map +1 -0
  572. package/dist/utils/thread-lock.js +112 -0
  573. package/dist/utils/thread-lock.js.map +1 -0
  574. package/dist/utils/token-estimator.d.ts +3 -0
  575. package/dist/utils/token-estimator.d.ts.map +1 -0
  576. package/dist/utils/token-estimator.js +21 -0
  577. package/dist/utils/token-estimator.js.map +1 -0
  578. package/dist/utils/update-check.d.ts +101 -0
  579. package/dist/utils/update-check.d.ts.map +1 -0
  580. package/dist/utils/update-check.js +383 -0
  581. package/dist/utils/update-check.js.map +1 -0
  582. package/dist/voice/stt-registry.d.ts +64 -0
  583. package/dist/voice/stt-registry.d.ts.map +1 -0
  584. package/dist/voice/stt-registry.js +144 -0
  585. package/dist/voice/stt-registry.js.map +1 -0
  586. package/dist/workflows/register-primitives.d.ts +52 -0
  587. package/dist/workflows/register-primitives.d.ts.map +1 -0
  588. package/dist/workflows/register-primitives.js +40 -0
  589. package/dist/workflows/register-primitives.js.map +1 -0
  590. package/dist/workflows/service.d.ts +64 -0
  591. package/dist/workflows/service.d.ts.map +1 -0
  592. package/dist/workflows/service.js +53 -0
  593. package/dist/workflows/service.js.map +1 -0
  594. package/package.json +97 -0
@@ -0,0 +1,119 @@
1
+ import { loadSettings, resolveLspSetting } from "../../onboarding/settings.js";
2
+ import { buildModePrompt, buildModePromptFn } from "./build.js";
3
+ import { getLocalPlansRelativeDir } from "../../utils/plans.js";
4
+ import { planModePrompt } from "./plan.js";
5
+ import { fastModePrompt } from "./fast.js";
6
+ import { MC_TOOLS } from "../../tool-names.js";
7
+ import { hasParallelKey, hasTavilyKey } from "../../tools/web-search.js";
8
+ import "../../tools/index.js";
9
+ import { AGENT_INSTRUCTIONS_HEADING, createGitRefInstructionReader, formatInstructionSource, loadAgentInstructions } from "./agent-instructions.js";
10
+ import { modelSpecificPrompts } from "./model.js";
11
+ import { buildToolGuidance } from "./tool-guidance.js";
12
+ import { buildBasePrompt } from "@mastra/core/coding-agent";
13
+ //#region src/agents/prompts/index.ts
14
+ const modePrompts = {
15
+ build: buildModePromptFn,
16
+ plan: planModePrompt,
17
+ fast: fastModePrompt
18
+ };
19
+ /** Join prompt sections into the final system prompt string. */
20
+ function joinPromptSections(sections) {
21
+ return sections.map((section) => section.content).filter(Boolean).join("\n\n");
22
+ }
23
+ /**
24
+ * Build the full system prompt for a given mode and context.
25
+ * Combines the base prompt with mode-specific instructions.
26
+ */
27
+ function buildFullPrompt(ctx) {
28
+ return joinPromptSections(buildFullPromptSections(ctx));
29
+ }
30
+ /**
31
+ * Build the system prompt as labeled sections. `buildFullPrompt` is the join of
32
+ * these, so the two can never disagree about what the model receives.
33
+ */
34
+ function buildFullPromptSections(ctx) {
35
+ const modelId = ctx.modelId;
36
+ const hasWebSearch = hasParallelKey() || hasTavilyKey() || !!modelId && (modelId.startsWith("anthropic/") || modelId.startsWith("openai/"));
37
+ const deniedTools = /* @__PURE__ */ new Set();
38
+ const permRules = ctx.state?.permissionRules;
39
+ if (permRules?.tools) {
40
+ for (const [name, policy] of Object.entries(permRules.tools)) if (policy === "deny") deniedTools.add(name);
41
+ }
42
+ if (resolveLspSetting(loadSettings().lsp) === false) deniedTools.add(MC_TOOLS.LSP_INSPECT);
43
+ const factoryProjectId = typeof ctx.state?.factoryProjectId === "string" ? ctx.state.factoryProjectId : void 0;
44
+ const toolGuidance = buildToolGuidance(ctx.modeId, {
45
+ hasWebSearch,
46
+ hasSubconscious: ctx.hasSubconscious === true,
47
+ hasSubagents: ctx.hasSubagents,
48
+ deniedTools,
49
+ plansDir: getLocalPlansRelativeDir({ factoryProjectId })
50
+ });
51
+ const base = buildBasePrompt({
52
+ projectPath: ctx.workingDir || "(no workspace attached)",
53
+ projectName: ctx.projectName || "unknown",
54
+ gitBranch: ctx.gitBranch,
55
+ platform: process.platform,
56
+ commonBinaries: ctx.commonBinaries,
57
+ date: ctx.currentDate,
58
+ mode: ctx.modeId,
59
+ modelId: ctx.modelId,
60
+ activePlan: ctx.state?.activePlan,
61
+ hasSubagents: ctx.hasSubagents !== false && !deniedTools.has("subagent"),
62
+ toolGuidance
63
+ });
64
+ const entry = modePrompts[ctx.modeId] || modePrompts.build;
65
+ const modeSpecific = (typeof entry === "function" ? entry(ctx) : entry) ?? "";
66
+ const modelSpecific = ctx.modelId ? modelSpecificPrompts[ctx.modelId] ?? "" : "";
67
+ const configDir = ctx.state?.configDir;
68
+ const untrustedCheckout = ctx.state?.untrustedCheckout === true;
69
+ const skipGlobalInstructions = ctx.state?.skipGlobalInstructions === true;
70
+ const baseRef = typeof ctx.state?.baseRef === "string" ? ctx.state.baseRef : void 0;
71
+ const projectReader = untrustedCheckout ? baseRef ? createGitRefInstructionReader(ctx.workingDir, baseRef) : {
72
+ exists: () => false,
73
+ read: () => ""
74
+ } : void 0;
75
+ const instructionSources = ctx.workingDir ? loadAgentInstructions(ctx.workingDir, configDir, projectReader, { skipGlobal: skipGlobalInstructions }) : [];
76
+ const instructionSections = instructionSources.map((source, index) => {
77
+ const isFirst = index === 0;
78
+ const isLast = index === instructionSources.length - 1;
79
+ let content = formatInstructionSource(source);
80
+ if (isFirst) content = `${AGENT_INSTRUCTIONS_HEADING}\n\n${content}`;
81
+ if (isLast) content = content.trimEnd();
82
+ return {
83
+ id: `agent-instructions:${source.path}:${index}`,
84
+ label: `${source.scope === "global" ? "Global" : "Project"} instructions`,
85
+ detail: source.ref ? `${source.path} (at ref ${source.ref})` : source.path,
86
+ content
87
+ };
88
+ });
89
+ const hostInstructions = ctx.hostInstructions?.trim() ?? "";
90
+ return [
91
+ {
92
+ id: "base-prompt",
93
+ label: "Base system prompt",
94
+ content: base
95
+ },
96
+ {
97
+ id: "host-instructions",
98
+ label: "Host instructions",
99
+ content: hostInstructions
100
+ },
101
+ ...instructionSections,
102
+ {
103
+ id: "model-prompt",
104
+ label: "Model-specific prompt",
105
+ detail: ctx.modelId,
106
+ content: modelSpecific.trim()
107
+ },
108
+ {
109
+ id: "mode-prompt",
110
+ label: "Mode prompt",
111
+ detail: ctx.modeId,
112
+ content: modeSpecific.trim()
113
+ }
114
+ ].filter((section) => Boolean(section.content));
115
+ }
116
+ //#endregion
117
+ export { buildFullPrompt, buildFullPromptSections, buildModePrompt, buildModePromptFn, fastModePrompt, joinPromptSections, planModePrompt };
118
+
119
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","names":[],"sources":["../../../src/agents/prompts/index.ts"],"sourcesContent":["/**\n * Prompt system — exports the prompt builder and mode-specific prompts.\n */\n\nexport { buildModePrompt, buildModePromptFn } from './build.js';\nexport { planModePrompt } from './plan.js';\nexport { fastModePrompt } from './fast.js';\n\nimport { buildBasePrompt } from '@mastra/core/coding-agent';\nimport type { PromptContext as BasePromptContext } from '@mastra/core/coding-agent';\nimport { loadSettings, resolveLspSetting } from '../../onboarding/settings.js';\nimport { MC_TOOLS } from '../../tool-names.js';\nimport { hasParallelKey, hasTavilyKey } from '../../tools/index.js';\nimport { getLocalPlansRelativeDir } from '../../utils/plans.js';\nimport {\n loadAgentInstructions,\n formatInstructionSource,\n createGitRefInstructionReader,\n AGENT_INSTRUCTIONS_HEADING,\n} from './agent-instructions.js';\nimport { buildModePromptFn } from './build.js';\nimport { fastModePrompt } from './fast.js';\nimport { modelSpecificPrompts } from './model.js';\nimport { planModePrompt } from './plan.js';\nimport { buildToolGuidance } from './tool-guidance.js';\n\n// Extended prompt context that includes runtime information\nexport interface PromptContext extends Omit<BasePromptContext, 'toolGuidance'> {\n modeId: string;\n state?: any;\n /** The subconscious knowledge tools are registered on the agent. */\n hasSubconscious?: boolean;\n hostInstructions?: string;\n currentDate: string;\n workingDir: string;\n}\n\nconst modePrompts: Record<string, string | ((ctx: PromptContext) => string)> = {\n build: buildModePromptFn,\n plan: planModePrompt,\n fast: fastModePrompt,\n};\n\n/**\n * One labeled piece of the assembled system prompt.\n *\n * The system prompt is a single string by the time it reaches the model, which\n * makes it impossible to say which configuration source is responsible for\n * which share of the context window. Building it as labeled sections and\n * joining them at the end keeps that attribution available to the `/context`\n * audit while guaranteeing the audit measures the exact text that is sent —\n * a parallel \"describe the prompt\" path would drift and report numbers for a\n * prompt that is no longer assembled this way.\n */\nexport interface PromptSection {\n /** Stable identifier, unique within a single build. */\n id: string;\n /** Human-readable label for display. */\n label: string;\n /** Optional provenance (e.g. the instruction file path). */\n detail?: string;\n /** The exact text contributed to the prompt. */\n content: string;\n}\n\n/** Join prompt sections into the final system prompt string. */\nexport function joinPromptSections(sections: PromptSection[]): string {\n return sections\n .map(section => section.content)\n .filter(Boolean)\n .join('\\n\\n');\n}\n\n/**\n * Build the full system prompt for a given mode and context.\n * Combines the base prompt with mode-specific instructions.\n */\nexport function buildFullPrompt(ctx: PromptContext): string {\n return joinPromptSections(buildFullPromptSections(ctx));\n}\n\n/**\n * Build the system prompt as labeled sections. `buildFullPrompt` is the join of\n * these, so the two can never disagree about what the model receives.\n */\nexport function buildFullPromptSections(ctx: PromptContext): PromptSection[] {\n // Determine whether web search tools are available\n const modelId = ctx.modelId;\n const hasWebSearch =\n hasParallelKey() ||\n hasTavilyKey() ||\n (!!modelId && (modelId.startsWith('anthropic/') || modelId.startsWith('openai/')));\n\n // Collect per-tool deny rules so guidance omits denied tools\n const deniedTools = new Set<string>();\n const permRules = ctx.state?.permissionRules as { tools?: Record<string, string> } | undefined;\n if (permRules?.tools) {\n for (const [name, policy] of Object.entries(permRules.tools)) {\n if (policy === 'deny') deniedTools.add(name);\n }\n }\n\n // LSP is opt-in — when it is off the tool is never registered, so its\n // guidance must not be advertised either.\n if (resolveLspSetting(loadSettings().lsp) === false) deniedTools.add(MC_TOOLS.LSP_INSPECT);\n\n // Build mode-aware tool guidance\n const factoryProjectId = typeof ctx.state?.factoryProjectId === 'string' ? ctx.state.factoryProjectId : undefined;\n const toolGuidance = buildToolGuidance(ctx.modeId, {\n hasWebSearch,\n hasSubconscious: ctx.hasSubconscious === true,\n hasSubagents: ctx.hasSubagents,\n deniedTools,\n plansDir: getLocalPlansRelativeDir({ factoryProjectId }),\n });\n\n // Map new context to base context\n const baseCtx: BasePromptContext = {\n projectPath: ctx.workingDir || '(no workspace attached)',\n projectName: ctx.projectName || 'unknown',\n gitBranch: ctx.gitBranch,\n platform: process.platform,\n commonBinaries: ctx.commonBinaries,\n date: ctx.currentDate,\n mode: ctx.modeId,\n modelId: ctx.modelId,\n activePlan: ctx.state?.activePlan,\n hasSubagents: ctx.hasSubagents !== false && !deniedTools.has('subagent'),\n toolGuidance,\n };\n\n const base = buildBasePrompt(baseCtx);\n const entry = modePrompts[ctx.modeId] || modePrompts.build;\n const modeSpecific = (typeof entry === 'function' ? entry(ctx) : entry) ?? '';\n const modelSpecific = ctx.modelId\n ? (modelSpecificPrompts[ctx.modelId as keyof typeof modelSpecificPrompts] ?? '')\n : '';\n\n // The current task list is carried on the agent state-signal lane (see\n // TaskStateProcessor) rather than injected into the cached system prompt. This\n // keeps the prompt prefix stable across task updates (preserving prompt cache)\n // while still surviving observational-memory truncation.\n\n // Load and inject agent instructions from AGENTS.md/CLAUDE.md files.\n // Untrusted checkouts (e.g. a PR branch under review) never read\n // project-scope files off the working tree: their AGENTS.md is\n // attacker-writable and would otherwise land in the system prompt as\n // trusted configuration. When the session carries a trusted base ref, the\n // project instructions are served from that ref instead (`git show`);\n // without one, project-scope files are skipped entirely. Home-directory\n // (global) instructions belong to whoever owns the machine, so hosts that\n // run sessions for someone else opt out of them entirely.\n const configDir = ctx.state?.configDir as string | undefined;\n const untrustedCheckout = ctx.state?.untrustedCheckout === true;\n const skipGlobalInstructions = ctx.state?.skipGlobalInstructions === true;\n const baseRef = typeof ctx.state?.baseRef === 'string' ? ctx.state.baseRef : undefined;\n const projectReader = untrustedCheckout\n ? baseRef\n ? createGitRefInstructionReader(ctx.workingDir, baseRef)\n : { exists: () => false, read: () => '' }\n : undefined;\n // No working directory means a hosted session with no project attached:\n // load NO instruction files at all — project locations would resolve\n // against the server's own cwd, and global locations against the server's\n // homedir. Neither belongs in a hosted session's prompt.\n const instructionSources = ctx.workingDir\n ? loadAgentInstructions(ctx.workingDir, configDir, projectReader, {\n skipGlobal: skipGlobalInstructions,\n })\n : [];\n // Emitted per source so each AGENTS.md/CLAUDE.md can be costed individually.\n // The heading rides on the first source's section, which is exactly how\n // `formatAgentInstructions` lays the block out, so joining the sections\n // reproduces its output byte for byte.\n const instructionSections: PromptSection[] = instructionSources.map((source, index) => {\n const isFirst = index === 0;\n const isLast = index === instructionSources.length - 1;\n let content = formatInstructionSource(source);\n if (isFirst) content = `${AGENT_INSTRUCTIONS_HEADING}\\n\\n${content}`;\n // The block as a whole used to be trimmed, which only ever affected the\n // trailing whitespace of the final source's content.\n if (isLast) content = content.trimEnd();\n return {\n id: `agent-instructions:${source.path}:${index}`,\n label: `${source.scope === 'global' ? 'Global' : 'Project'} instructions`,\n detail: source.ref ? `${source.path} (at ref ${source.ref})` : source.path,\n content,\n };\n });\n\n const hostInstructions = ctx.hostInstructions?.trim() ?? '';\n\n return [\n { id: 'base-prompt', label: 'Base system prompt', content: base },\n { id: 'host-instructions', label: 'Host instructions', content: hostInstructions },\n ...instructionSections,\n { id: 'model-prompt', label: 'Model-specific prompt', detail: ctx.modelId, content: modelSpecific.trim() },\n { id: 'mode-prompt', label: 'Mode prompt', detail: ctx.modeId, content: modeSpecific.trim() },\n ].filter(section => Boolean(section.content));\n}\n"],"mappings":"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"}
@@ -0,0 +1,5 @@
1
+ export declare const modelSpecificPrompts: {
2
+ 'openai/gpt-5.4': string;
3
+ 'openai/gpt-5.5': string;
4
+ };
5
+ //# sourceMappingURL=model.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"model.d.ts","sourceRoot":"","sources":["../../../src/agents/prompts/model.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,oBAAoB;;;CAiBhC,CAAC"}
@@ -0,0 +1,23 @@
1
+ //#region src/agents/prompts/model.ts
2
+ const modelSpecificPrompts = {
3
+ "openai/gpt-5.4": `<autonomy_and_persistence>
4
+ Persist until the task is fully handled end-to-end within the current turn whenever feasible: do not stop at analysis or partial fixes; carry changes through implementation, verification, and a clear explanation of outcomes unless the user explicitly pauses or redirects you.
5
+
6
+ Unless the user explicitly asks for a plan, asks a question about the code, is brainstorming potential solutions, or some other intent that makes it clear that code should not be written, assume the user wants you to make code changes or run tools to solve the user's problem. In these cases, it's bad to output your proposed solution in a message, you should go ahead and actually implement the change. If you encounter challenges or blockers, you should attempt to resolve them yourself.
7
+ </autonomy_and_persistence>
8
+ `,
9
+ "openai/gpt-5.5": `<coding_behavior>
10
+ Work outcome-first: infer the user's goal, define what "done" means from the request and repo context, then choose an efficient path that reaches that outcome without sacrificing correctness, maintainability, or proof.
11
+
12
+ For non-trivial multi-step or tool-heavy tasks, start with a short visible preamble that acknowledges the request and states the first action. Skip the preamble for direct answers and tiny edits. Keep later updates tied to meaningful decisions, findings, or results so the user and memory have useful context.
13
+
14
+ Use efficient retrieval. Read enough code, docs, logs, and command output to act correctly, including neighboring implementations when conventions matter. Stop searching once you have sufficient evidence, but do not let brevity outrank correctness, security, or compatibility with existing patterns.
15
+
16
+ For coding work, make focused changes that follow the surrounding conventions. Avoid unrequested features, broad refactors, speculative error handling, and comments that only explain the diff.
17
+ </coding_behavior>
18
+ `
19
+ };
20
+ //#endregion
21
+ export { modelSpecificPrompts };
22
+
23
+ //# sourceMappingURL=model.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"model.js","names":[],"sources":["../../../src/agents/prompts/model.ts"],"sourcesContent":["export const modelSpecificPrompts = {\n 'openai/gpt-5.4': `<autonomy_and_persistence>\nPersist until the task is fully handled end-to-end within the current turn whenever feasible: do not stop at analysis or partial fixes; carry changes through implementation, verification, and a clear explanation of outcomes unless the user explicitly pauses or redirects you.\n\nUnless the user explicitly asks for a plan, asks a question about the code, is brainstorming potential solutions, or some other intent that makes it clear that code should not be written, assume the user wants you to make code changes or run tools to solve the user's problem. In these cases, it's bad to output your proposed solution in a message, you should go ahead and actually implement the change. If you encounter challenges or blockers, you should attempt to resolve them yourself.\n</autonomy_and_persistence>\n`,\n 'openai/gpt-5.5': `<coding_behavior>\nWork outcome-first: infer the user's goal, define what \"done\" means from the request and repo context, then choose an efficient path that reaches that outcome without sacrificing correctness, maintainability, or proof.\n\nFor non-trivial multi-step or tool-heavy tasks, start with a short visible preamble that acknowledges the request and states the first action. Skip the preamble for direct answers and tiny edits. Keep later updates tied to meaningful decisions, findings, or results so the user and memory have useful context.\n\nUse efficient retrieval. Read enough code, docs, logs, and command output to act correctly, including neighboring implementations when conventions matter. Stop searching once you have sufficient evidence, but do not let brevity outrank correctness, security, or compatibility with existing patterns.\n\nFor coding work, make focused changes that follow the surrounding conventions. Avoid unrequested features, broad refactors, speculative error handling, and comments that only explain the diff.\n</coding_behavior>\n`,\n};\n"],"mappings":";AAAA,MAAa,uBAAuB;CAClC,kBAAkB;;;;;;CAMlB,kBAAkB;;;;;;;;;;AAUpB"}
@@ -0,0 +1,6 @@
1
+ interface PlanPromptContext {
2
+ state?: Record<string, unknown>;
3
+ }
4
+ export declare function planModePrompt(ctx: PlanPromptContext): string;
5
+ export {};
6
+ //# sourceMappingURL=plan.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plan.d.ts","sourceRoot":"","sources":["../../../src/agents/prompts/plan.ts"],"names":[],"mappings":"AAKA,UAAU,iBAAiB;IACzB,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACjC;AAED,wBAAgB,cAAc,CAAC,GAAG,EAAE,iBAAiB,GAAG,MAAM,CAuG7D"}
@@ -0,0 +1,111 @@
1
+ import { getLocalPlansRelativeDir } from "../../utils/plans.js";
2
+ //#region src/agents/prompts/plan.ts
3
+ /**
4
+ * Plan mode prompt — read-only exploration and planning.
5
+ */
6
+ function planModePrompt(ctx) {
7
+ const plansDir = getLocalPlansRelativeDir({ factoryProjectId: typeof ctx.state?.factoryProjectId === "string" ? ctx.state.factoryProjectId : void 0 });
8
+ const examplePath = `${plansDir}/add-dark-mode.md`;
9
+ return `
10
+ # Plan Mode — READ-ONLY (except plan files)
11
+
12
+ You are in PLAN mode. Your job is to explore the codebase and design an implementation plan — NOT to make changes to the project.
13
+
14
+ ## CRITICAL: Read-Only Mode (project files)
15
+
16
+ This mode is **read-only for project files**. You must NOT modify the project.
17
+
18
+ - Do NOT modify, create, or delete project files
19
+ - Do NOT run commands that change state (no git commit, no npm install, no file creation)
20
+ - Do NOT run build commands, tests, or scripts that have side effects
21
+
22
+ The ONE exception is plan files: you CAN create and edit markdown files inside \`${plansDir}/\` (e.g. \`${examplePath}\`). You may NOT write anywhere else.
23
+
24
+ If the user asks you to make changes while in Plan mode, explain that you're in read-only mode and they should switch to Build mode (\`/mode build\`) first.
25
+
26
+ ## Exploration Strategy
27
+
28
+ Before writing any plan, build a mental model of the codebase:
29
+ 1. Start with the directory structure (\`view\` on the project root or relevant subdirectory).
30
+ 2. Find the relevant entry points and core files using \`search_content\` and \`find_files\`.
31
+ 3. Read the actual code — don't assume based on file names alone.
32
+ 4. Trace data flow: where does input come from, how is it transformed, where does it go?
33
+ 5. Identify existing patterns the codebase uses (naming, structure, error handling, testing).
34
+
35
+ ## Goal-Ready Plans
36
+
37
+ The submit_plan approval UI can let the user approve the plan normally or start it as a persistent goal. Write plans so they can be carried out as a goal if the user chooses that option:
38
+ - Make the desired outcome explicit and verifiable.
39
+ - Break work into ordered, actionable steps that can be executed autonomously.
40
+ - Include constraints, risks, blockers, and decision points that may require user input.
41
+ - Include concrete verification criteria so the goal judge can tell when the work is done.
42
+
43
+ ## Your Plan Output
44
+
45
+ Produce a clear, step-by-step plan with this structure:
46
+
47
+ ### Overview
48
+ One paragraph: what the change does and why.
49
+
50
+ ### Complexity Estimate
51
+ - **Size**: Small (1-2 files) / Medium (3-5 files) / Large (6+ files)
52
+ - **Risk**: Low (additive, no breaking changes) / Medium (modifies existing behavior) / High (architectural, affects many consumers)
53
+ - **Dependencies**: List any new packages, external services, or migration steps needed.
54
+
55
+ ### Steps
56
+ For each step:
57
+ 1. **File**: path to create or modify
58
+ 2. **Change**: what to add/modify/remove, with enough specificity to implement directly
59
+ 3. **Why**: brief rationale connecting this step to the overall goal
60
+
61
+ ### Verification
62
+ - What tests to run
63
+ - What to check manually
64
+ - What could go wrong
65
+
66
+ ## Plan File Workflow
67
+
68
+ Write each plan to its own markdown file under \`${plansDir}/\` (e.g. \`${examplePath}\`). Start the file with a \`# Title\` heading describing the plan.
69
+
70
+ 1. **First submission**: Write your plan to a file under \`${plansDir}/\` using \`write_file\`, then call \`submit_plan\` with the \`path\` to that file.
71
+ 2. **Reading**: Use \`view\` to read a plan file.
72
+ 3. **Editing**: Use \`string_replace_lsp\` for targeted edits to specific sections.
73
+
74
+ **Reuse the same file while you keep iterating on the same plan.** Only create a NEW file when you're starting a genuinely different plan — that keeps each plan available to look back at and keeps revision diffs meaningful.
75
+
76
+ ## IMMEDIATE ACTION: Write plan file, then call submit_plan
77
+
78
+ As soon as your plan is complete:
79
+ 1. Write it to a file under \`${plansDir}/\` using \`write_file\`
80
+ 2. Call \`submit_plan\` with the \`path\` to that file
81
+
82
+ **CRITICAL:** Do NOT generate a long text response describing your plan. The plan content belongs in the plan file, not in your text output or the \`submit_plan\` arguments.
83
+
84
+ \`\`\`javascript
85
+ submit_plan({
86
+ path: "${examplePath}"
87
+ })
88
+ \`\`\`
89
+
90
+ The user will see the plan rendered inline and can:
91
+ - **Approve** — automatically switches to Build mode for implementation
92
+ - **Start as goal** — approves the plan and enters goal mode so the agent keeps working toward the plan until judged complete, paused, or waiting for user input
93
+ - **Request changes** — rejects the plan; the agent stops immediately and the user provides revision feedback in their next chat message
94
+
95
+ ## Revision Workflow
96
+
97
+ If the user requests changes, you will be stopped immediately. Wait for their next message — it will contain their revision feedback. When you receive it:
98
+ 1. Use \`view\` to read the SAME plan file
99
+ 2. Use \`string_replace_lsp\` to make targeted edits based on feedback
100
+ 3. Use \`view\` to re-read the updated file
101
+ 4. Call \`submit_plan\` again with the same \`path\` — editing the file alone does NOT resubmit it
102
+
103
+ The user will see a diff of what changed between the previous and revised plan. Use \`string_replace_lsp\` for targeted edits so the diff is clear and meaningful — do NOT rewrite the entire plan from scratch for small changes, and do NOT move the plan to a new file for a revision.
104
+
105
+ Do NOT start implementing until the plan is approved.
106
+ `;
107
+ }
108
+ //#endregion
109
+ export { planModePrompt };
110
+
111
+ //# sourceMappingURL=plan.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plan.js","names":[],"sources":["../../../src/agents/prompts/plan.ts"],"sourcesContent":["/**\n * Plan mode prompt — read-only exploration and planning.\n */\nimport { getLocalPlansRelativeDir } from '../../utils/plans.js';\n\ninterface PlanPromptContext {\n state?: Record<string, unknown>;\n}\n\nexport function planModePrompt(ctx: PlanPromptContext): string {\n const factoryProjectId = typeof ctx.state?.factoryProjectId === 'string' ? ctx.state.factoryProjectId : undefined;\n const plansDir = getLocalPlansRelativeDir({ factoryProjectId });\n const examplePath = `${plansDir}/add-dark-mode.md`;\n\n return `\n# Plan Mode — READ-ONLY (except plan files)\n\nYou are in PLAN mode. Your job is to explore the codebase and design an implementation plan — NOT to make changes to the project.\n\n## CRITICAL: Read-Only Mode (project files)\n\nThis mode is **read-only for project files**. You must NOT modify the project.\n\n- Do NOT modify, create, or delete project files\n- Do NOT run commands that change state (no git commit, no npm install, no file creation)\n- Do NOT run build commands, tests, or scripts that have side effects\n\nThe ONE exception is plan files: you CAN create and edit markdown files inside \\`${plansDir}/\\` (e.g. \\`${examplePath}\\`). You may NOT write anywhere else.\n\nIf the user asks you to make changes while in Plan mode, explain that you're in read-only mode and they should switch to Build mode (\\`/mode build\\`) first.\n\n## Exploration Strategy\n\nBefore writing any plan, build a mental model of the codebase:\n1. Start with the directory structure (\\`view\\` on the project root or relevant subdirectory).\n2. Find the relevant entry points and core files using \\`search_content\\` and \\`find_files\\`.\n3. Read the actual code — don't assume based on file names alone.\n4. Trace data flow: where does input come from, how is it transformed, where does it go?\n5. Identify existing patterns the codebase uses (naming, structure, error handling, testing).\n\n## Goal-Ready Plans\n\nThe submit_plan approval UI can let the user approve the plan normally or start it as a persistent goal. Write plans so they can be carried out as a goal if the user chooses that option:\n- Make the desired outcome explicit and verifiable.\n- Break work into ordered, actionable steps that can be executed autonomously.\n- Include constraints, risks, blockers, and decision points that may require user input.\n- Include concrete verification criteria so the goal judge can tell when the work is done.\n\n## Your Plan Output\n\nProduce a clear, step-by-step plan with this structure:\n\n### Overview\nOne paragraph: what the change does and why.\n\n### Complexity Estimate\n- **Size**: Small (1-2 files) / Medium (3-5 files) / Large (6+ files)\n- **Risk**: Low (additive, no breaking changes) / Medium (modifies existing behavior) / High (architectural, affects many consumers)\n- **Dependencies**: List any new packages, external services, or migration steps needed.\n\n### Steps\nFor each step:\n1. **File**: path to create or modify\n2. **Change**: what to add/modify/remove, with enough specificity to implement directly\n3. **Why**: brief rationale connecting this step to the overall goal\n\n### Verification\n- What tests to run\n- What to check manually\n- What could go wrong\n\n## Plan File Workflow\n\nWrite each plan to its own markdown file under \\`${plansDir}/\\` (e.g. \\`${examplePath}\\`). Start the file with a \\`# Title\\` heading describing the plan.\n\n1. **First submission**: Write your plan to a file under \\`${plansDir}/\\` using \\`write_file\\`, then call \\`submit_plan\\` with the \\`path\\` to that file.\n2. **Reading**: Use \\`view\\` to read a plan file.\n3. **Editing**: Use \\`string_replace_lsp\\` for targeted edits to specific sections.\n\n**Reuse the same file while you keep iterating on the same plan.** Only create a NEW file when you're starting a genuinely different plan — that keeps each plan available to look back at and keeps revision diffs meaningful.\n\n## IMMEDIATE ACTION: Write plan file, then call submit_plan\n\nAs soon as your plan is complete:\n1. Write it to a file under \\`${plansDir}/\\` using \\`write_file\\`\n2. Call \\`submit_plan\\` with the \\`path\\` to that file\n\n**CRITICAL:** Do NOT generate a long text response describing your plan. The plan content belongs in the plan file, not in your text output or the \\`submit_plan\\` arguments.\n\n\\`\\`\\`javascript\nsubmit_plan({\n path: \"${examplePath}\"\n})\n\\`\\`\\`\n\nThe user will see the plan rendered inline and can:\n- **Approve** — automatically switches to Build mode for implementation\n- **Start as goal** — approves the plan and enters goal mode so the agent keeps working toward the plan until judged complete, paused, or waiting for user input\n- **Request changes** — rejects the plan; the agent stops immediately and the user provides revision feedback in their next chat message\n\n## Revision Workflow\n\nIf the user requests changes, you will be stopped immediately. Wait for their next message — it will contain their revision feedback. When you receive it:\n1. Use \\`view\\` to read the SAME plan file\n2. Use \\`string_replace_lsp\\` to make targeted edits based on feedback\n3. Use \\`view\\` to re-read the updated file\n4. Call \\`submit_plan\\` again with the same \\`path\\` — editing the file alone does NOT resubmit it\n\nThe user will see a diff of what changed between the previous and revised plan. Use \\`string_replace_lsp\\` for targeted edits so the diff is clear and meaningful — do NOT rewrite the entire plan from scratch for small changes, and do NOT move the plan to a new file for a revision.\n\nDo NOT start implementing until the plan is approved.\n`;\n}\n"],"mappings":";;;;;AASA,SAAgB,eAAe,KAAgC;CAE7D,MAAM,WAAW,yBAAyB,EAAE,kBADnB,OAAO,IAAI,OAAO,qBAAqB,WAAW,IAAI,MAAM,mBAAmB,KAAA,EAC3C,CAAC;CAC9D,MAAM,cAAc,GAAG,SAAS;CAEhC,OAAO;;;;;;;;;;;;;mFAa0E,SAAS,cAAc,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;mDA8CnE,SAAS,cAAc,YAAY;;6DAEzB,SAAS;;;;;;;;;gCAStC,SAAS;;;;;;;WAO9B,YAAY;;;;;;;;;;;;;;;;;;;;;AAqBvB"}
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Mode-specific tool behavioral guidance.
3
+ * Generates tool usage instructions that match the actual registered tool names
4
+ * and are scoped to what's available in the current mode.
5
+ */
6
+ interface ToolGuidanceOptions {
7
+ hasWebSearch?: boolean;
8
+ hasSubagents?: boolean;
9
+ /** Subconscious knowledge tools are registered (experimental subconscious enabled). */
10
+ hasSubconscious?: boolean;
11
+ /** Tool names that have been denied — omit their guidance sections. */
12
+ deniedTools?: Set<string>;
13
+ /** Workspace-relative directory where plan mode can write plans. */
14
+ plansDir?: string;
15
+ }
16
+ export declare function buildToolGuidance(modeId: string, options?: ToolGuidanceOptions): string;
17
+ export {};
18
+ //# sourceMappingURL=tool-guidance.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tool-guidance.d.ts","sourceRoot":"","sources":["../../../src/agents/prompts/tool-guidance.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,UAAU,mBAAmB;IAC3B,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,uFAAuF;IACvF,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,uEAAuE;IACvE,WAAW,CAAC,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IAC1B,oEAAoE;IACpE,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,GAAE,mBAAwB,GAAG,MAAM,CA+Q3F"}
@@ -0,0 +1,180 @@
1
+ import { MC_TOOLS } from "../../tool-names.js";
2
+ //#region src/agents/prompts/tool-guidance.ts
3
+ /**
4
+ * Mode-specific tool behavioral guidance.
5
+ * Generates tool usage instructions that match the actual registered tool names
6
+ * and are scoped to what's available in the current mode.
7
+ */
8
+ function buildToolGuidance(modeId, options = {}) {
9
+ const denied = options.deniedTools ?? /* @__PURE__ */ new Set();
10
+ const plansDir = options.plansDir ?? ".mastracode/plans";
11
+ const sections = [];
12
+ sections.push(`# Tool Usage Rules
13
+
14
+ IMPORTANT: You can ONLY call tools by their exact registered names listed below. Shell commands like \`git\`, \`npm\`, \`ls\`, etc. are NOT tools — they must be run via the \`execute_command\` tool.
15
+
16
+ You have access to the following tools. Use the RIGHT tool for the job:`);
17
+ const readTools = [];
18
+ if (!denied.has(MC_TOOLS.VIEW)) readTools.push(`
19
+ **${MC_TOOLS.VIEW}** — Read file contents
20
+ - Use this to read files before editing them. NEVER propose changes to code you haven't read.
21
+ - Use \`offset\` (1-indexed start line) and \`limit\` (number of lines) for large files.
22
+ - Example: Read lines 50-100: \`{ path: "src/big-file.ts", offset: 50, limit: 51 }\`
23
+ - To list directories, use \`${MC_TOOLS.FIND_FILES}\` instead.`);
24
+ if (!denied.has(MC_TOOLS.SEARCH_CONTENT)) readTools.push(`
25
+ **${MC_TOOLS.SEARCH_CONTENT}** — Search file contents using regex
26
+ - Preferred for content search (finding functions, variables, error messages, imports, etc.)
27
+ - Use \`path\` to filter by directory or glob pattern. Supports \`contextLines\`, \`caseSensitive\`, and \`maxCount\`.
28
+ - Example: Find a function: \`{ pattern: "function handleSubmit", path: "**/*.ts" }\`
29
+ - Example: Find imports: \`{ pattern: "from ['\\"\\]express['\\"\\]", path: "**/*.ts" }\`
30
+ - Respects .gitignore by default.`);
31
+ if (!denied.has(MC_TOOLS.FIND_FILES)) readTools.push(`
32
+ **${MC_TOOLS.FIND_FILES}** — List files and directories as a tree
33
+ - Preferred for exploring project structure and finding files by pattern.
34
+ - Returns tree-style output. Respects .gitignore by default.
35
+ - Example: List project root: \`{ path: "./" }\`
36
+ - Example: Find test files: \`{ path: "./src", pattern: "**/*.test.ts" }\`
37
+ - Example: Find config files: \`{ pattern: "*.config.{js,ts,json}" }\``);
38
+ if (!denied.has(MC_TOOLS.EXECUTE_COMMAND)) readTools.push(`
39
+ **${MC_TOOLS.EXECUTE_COMMAND}** — Run shell commands
40
+ - Use for: git, npm/pnpm, docker, build tools, test runners, and other terminal operations.
41
+ - Prefer dedicated tools for: file reading (${MC_TOOLS.VIEW}), file search (${MC_TOOLS.SEARCH_CONTENT}/${MC_TOOLS.FIND_FILES}), file editing (${MC_TOOLS.STRING_REPLACE_LSP}/${MC_TOOLS.WRITE_FILE}).
42
+ - Commands have a 30-second default timeout. Use \`timeout\` for longer commands, \`cwd\` for working directory.
43
+ - Use the \`tail\` parameter or pipe to \`| tail -N\` to limit output — the full output streams to the user, only the tail is returned to you. If you're building any kind of package you should be tailing.
44
+ - Good: Run independent commands in parallel when possible.
45
+ - Bad: Running \`cat file.txt\` — use the ${MC_TOOLS.VIEW} tool instead.`);
46
+ if (!denied.has(MC_TOOLS.LSP_INSPECT)) readTools.push(`
47
+ **${MC_TOOLS.LSP_INSPECT}** — Inspect code using Language Server Protocol
48
+ - Use this for type information, hover docs, go-to-definition, and finding implementations for a symbol.
49
+ - Best when you already know the file and line and need semantic code intelligence rather than raw file contents.
50
+ - Input: \`path\` (absolute file path), \`line\` (1-indexed line number), \`match\` (the exact line content with exactly one \`<<<\` cursor marker).
51
+ - Output includes: \`hover\`, \`definition\` (compact location with preview), and \`implementation\` (compact usage/implementation locations).
52
+ - Example: \`{ path: "/abs/path/src/foo.ts", line: 10, match: "const foo = <<<bar()" }\` — inspect the symbol at the \`<<<\` position.
53
+ - Use \`${MC_TOOLS.VIEW}\` when you need to read the implementation or surrounding code.
54
+ - Use \`${MC_TOOLS.SEARCH_CONTENT}\` or \`${MC_TOOLS.FIND_FILES}\` first if you do not yet know where the symbol is.`);
55
+ if (!denied.has(MC_TOOLS.NOTIFICATION_INBOX)) readTools.push(`
56
+ **${MC_TOOLS.NOTIFICATION_INBOX}** — Inspect and manage notification inbox records
57
+ - Use this when a \`<notification-summary>\` says pending notifications exist.
58
+ - Use \`{ "action": "list", "status": "pending" }\` or \`{ "action": "search", "query": "..." }\` to find notification records for the current thread.
59
+ - Use \`read\` to deliver unread notification signals into the chat and mark them seen; the tool result summarizes the count instead of exposing notification contents.
60
+ - Use \`dismiss\` or \`archive\` only when the user asks or the notification is no longer relevant.`);
61
+ if (readTools.length > 0) sections.push(readTools.join("\n"));
62
+ if (modeId !== "plan") {
63
+ const writeTools = [];
64
+ if (!denied.has(MC_TOOLS.STRING_REPLACE_LSP)) writeTools.push(`
65
+ **${MC_TOOLS.STRING_REPLACE_LSP}** — Edit files by replacing exact text
66
+ - You MUST read a file with \`${MC_TOOLS.VIEW}\` before editing it.
67
+ - \`old_string\` must be an exact match of existing text in the file.
68
+ - Provide enough surrounding context in \`old_string\` to make it unique.
69
+ - Use \`replace_all: true\` to replace all occurrences (default: false, requires unique match).
70
+ - For creating new files, use \`${MC_TOOLS.WRITE_FILE}\` instead.
71
+ - Good: Include 2-3 lines of surrounding context to ensure uniqueness.
72
+ - Bad: Using just \`return true;\` — too common, will match multiple places.`);
73
+ if (!denied.has(MC_TOOLS.WRITE_FILE)) writeTools.push(`
74
+ **${MC_TOOLS.WRITE_FILE}** — Create new files or overwrite existing ones
75
+ - Use this to create new files.
76
+ - If overwriting an existing file, you MUST have read it first with \`${MC_TOOLS.VIEW}\`.
77
+ - Prefer editing existing files over creating new ones.`);
78
+ if (writeTools.length > 0) sections.push(writeTools.join("\n"));
79
+ }
80
+ if (options.hasWebSearch) {
81
+ const webTools = [];
82
+ if (!denied.has("web_search")) webTools.push("**web_search**");
83
+ if (!denied.has("web_extract")) webTools.push("**web_extract**");
84
+ if (webTools.length > 0) sections.push(`
85
+ ${webTools.join(" / ")} — Search the web / extract page content
86
+ - Use for looking up documentation, error messages, package APIs.`);
87
+ }
88
+ if (options.hasSubconscious) {
89
+ const knowledgeTools = [
90
+ "knowledge_search",
91
+ "knowledge_read",
92
+ "knowledge_browse"
93
+ ].filter((name) => !denied.has(name));
94
+ const hasAskMemory = !denied.has("ask_memory");
95
+ if (knowledgeTools.length > 0 || hasAskMemory) {
96
+ const lines = [`
97
+ # Subconscious Memory
98
+
99
+ A background memory system (the "subconscious") runs alongside you. After conversations, it extracts durable knowledge — decisions, preferences, people, files, repos, work items — into a knowledge graph scoped to this project, visible across your sessions here. It also delivers reminders (\`<remembered>\`) and pinned knowledge into your context on its own; you do not manage those directly.`];
100
+ if (knowledgeTools.length > 0) {
101
+ const bullets = [];
102
+ if (knowledgeTools.includes("knowledge_search")) bullets.push("- Use `knowledge_search` for a quick lexical + semantic lookup when you need a specific fact (a past decision, a person's role, what a file is for). Cheaper than re-deriving it from the codebase or asking the user.");
103
+ if (knowledgeTools.includes("knowledge_read")) bullets.push("- Use `knowledge_read` to open a node by name or ID and see the records about it.");
104
+ if (knowledgeTools.includes("knowledge_browse")) bullets.push("- Use `knowledge_browse` to list nodes by kind or name prefix, or to walk a node's mentions and backlinks.");
105
+ if (!denied.has("recall")) bullets.push("- Prefer these over `recall` when the question is about durable facts rather than what was said in a specific past conversation.");
106
+ lines.push(`
107
+ ${knowledgeTools.map((name) => `**${name}**`).join(" / ")} — Query the knowledge graph directly
108
+ ${bullets.join("\n")}`);
109
+ }
110
+ if (hasAskMemory) lines.push(`
111
+ **ask_memory** — Ask the reminder sidekick a question about existing memory
112
+ - Use only when the answer is not already in your context and a direct search is not enough: open-ended questions ("what did we decide about X and why?") or questions that need synthesis across several memories. It answers from what is already remembered; it does not store anything.
113
+ - It is ASYNCHRONOUS. The tool returns as soon as the question is accepted; the answer arrives later as one or more \`<remind-answer source="subconscious" agent="remind" replyId="…" moreComing="true|false">\` messages in your context. Keep working — do not poll or wait, and do not re-ask the same question.
114
+ - Treat a message with \`moreComing="true"\` as partial; the reply is complete only when \`moreComing="false"\` arrives. Fold the answer into your work and cite it as remembered context rather than as something you verified yourself.`);
115
+ sections.push(lines.join("\n"));
116
+ }
117
+ }
118
+ const taskTools = [];
119
+ const canUpdateTask = !denied.has("task_update");
120
+ const canCompleteTask = !denied.has("task_complete");
121
+ const canCheckTasks = !denied.has("task_check");
122
+ const canWriteTasks = !denied.has("task_write");
123
+ const patchToolGuidance = canUpdateTask && canCompleteTask ? "- Prefer task_update or task_complete when changing one existing task." : canUpdateTask ? "- Prefer task_update when changing one existing task." : canCompleteTask ? "- Prefer task_complete when marking one existing task completed." : "- Use task_write with the full task list when changing existing tasks.";
124
+ if (canWriteTasks) taskTools.push(`
125
+ **task_write** — Track tasks for complex multi-step work
126
+ - Use when a task requires 3 or more distinct steps or actions.
127
+ - Use task_write to create the initial task list or replace the whole list after replanning.
128
+ - Each task has: id (stable identifier), content (imperative form), status (pending, in_progress, or completed), activeForm (present continuous form shown during execution).
129
+ - Keep task IDs stable across updates. If you omit IDs, the tool result returns generated IDs.
130
+ ${patchToolGuidance}
131
+ - Mark tasks \`in_progress\` BEFORE starting work. Only ONE task should be \`in_progress\` at a time.
132
+ - Mark tasks \`completed\` IMMEDIATELY after finishing each task. Do not batch completions.`);
133
+ if (canUpdateTask) taskTools.push(`
134
+ **task_update** — Patch one tracked task by ID
135
+ - Use this for targeted changes to one existing task.
136
+ - Provide the task ID and only the fields that changed: content, status, or activeForm.`);
137
+ if (canCompleteTask) {
138
+ const idSource = canCheckTasks ? "Use task_check if you need the current IDs before completing a task." : canWriteTasks ? "Use IDs returned by task_write." : "Use only task IDs already visible in the current task list.";
139
+ taskTools.push(`
140
+ **task_complete** — Mark one tracked task completed by ID
141
+ - Use this immediately after finishing a tracked task.
142
+ - ${idSource}`);
143
+ }
144
+ if (canCheckTasks) taskTools.push(`
145
+ **task_check** — Check completion status of tasks
146
+ - Use this BEFORE finishing tracked work to verify all tasks are completed.
147
+ - Returns a readable status summary plus structured fields: tasks, summary, incompleteTasks, and isError.
148
+ - summary includes total, completed, inProgress, pending, incomplete, hasTasks, and allCompleted.
149
+ - Use summary.allCompleted to decide whether tracked work is complete; if summary.hasTasks is false, no task list is currently tracked.
150
+ - If any tasks remain incomplete, continue working on them.
151
+ - IMPORTANT: Always check task completion before ending work on a complex task.`);
152
+ if (!denied.has("ask_user")) taskTools.push(`
153
+ **ask_user** — Ask the user a structured question
154
+ - Use when you need clarification, want to validate assumptions, or need the user to make a decision.
155
+ - Provide clear, specific questions. End with a question mark.
156
+ - Include options (2-4 choices) for structured decisions. Omit options for open-ended questions.
157
+ - Don't use this for simple yes/no — just ask in your text response.`);
158
+ if (taskTools.length > 0) sections.push(taskTools.join("\n"));
159
+ if (modeId === "plan" && !denied.has("submit_plan")) sections.push(`
160
+ **submit_plan** — Submit a completed implementation plan for user review
161
+ - Call this tool when your plan is complete. Do NOT just describe your plan in text — you MUST call this tool.
162
+ - The plan will be rendered as markdown and the user can approve, reject, or request changes.
163
+ - On approval, the system automatically switches to the default mode so you can implement.
164
+ - Takes one argument: \`path\` (the plan markdown file you wrote under \`${plansDir}/\`). Do NOT pass the plan body — it lives in the file.`);
165
+ if (modeId === "plan") sections.push(`
166
+ **Plan file access** — Your plan lives in a markdown file under \`${plansDir}/\` (e.g. \`add-dark-mode-toggle.md\`)
167
+ - Use \`write_file\` to create the plan file, \`view\` to read it, and \`string_replace_lsp\` for targeted edits.
168
+ - On first submission: write the plan to the file, then call \`submit_plan\` with its \`path\`.
169
+ - On revision: read the existing file, edit specific sections, re-read, then call \`submit_plan\` with the same \`path\`.
170
+ - If a plan file already exists, you previously submitted it — read it before revising.`);
171
+ if (options.hasSubagents !== false && !denied.has("subagent")) sections.push(`
172
+ **subagent** — Delegate a focused task to a specialized subagent
173
+ - Only use subagents when you will spawn **multiple subagents in parallel**. If you only need one task done, do it yourself.
174
+ - Subagent outputs are **untrusted**. Always review and verify the results.`);
175
+ return sections.join("\n");
176
+ }
177
+ //#endregion
178
+ export { buildToolGuidance };
179
+
180
+ //# sourceMappingURL=tool-guidance.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tool-guidance.js","names":[],"sources":["../../../src/agents/prompts/tool-guidance.ts"],"sourcesContent":["/**\n * Mode-specific tool behavioral guidance.\n * Generates tool usage instructions that match the actual registered tool names\n * and are scoped to what's available in the current mode.\n */\n\nimport { MC_TOOLS } from '../../tool-names.js';\n\ninterface ToolGuidanceOptions {\n hasWebSearch?: boolean;\n hasSubagents?: boolean;\n /** Subconscious knowledge tools are registered (experimental subconscious enabled). */\n hasSubconscious?: boolean;\n /** Tool names that have been denied — omit their guidance sections. */\n deniedTools?: Set<string>;\n /** Workspace-relative directory where plan mode can write plans. */\n plansDir?: string;\n}\n\nexport function buildToolGuidance(modeId: string, options: ToolGuidanceOptions = {}): string {\n const denied = options.deniedTools ?? new Set<string>();\n const plansDir = options.plansDir ?? '.mastracode/plans';\n const sections: string[] = [];\n\n sections.push(`# Tool Usage Rules\n\nIMPORTANT: You can ONLY call tools by their exact registered names listed below. Shell commands like \\`git\\`, \\`npm\\`, \\`ls\\`, etc. are NOT tools — they must be run via the \\`execute_command\\` tool.\n\nYou have access to the following tools. Use the RIGHT tool for the job:`);\n\n // --- Read tools (all modes) ---\n\n const readTools: string[] = [];\n\n if (!denied.has(MC_TOOLS.VIEW)) {\n readTools.push(`\n**${MC_TOOLS.VIEW}** — Read file contents\n- Use this to read files before editing them. NEVER propose changes to code you haven't read.\n- Use \\`offset\\` (1-indexed start line) and \\`limit\\` (number of lines) for large files.\n- Example: Read lines 50-100: \\`{ path: \"src/big-file.ts\", offset: 50, limit: 51 }\\`\n- To list directories, use \\`${MC_TOOLS.FIND_FILES}\\` instead.`);\n }\n\n if (!denied.has(MC_TOOLS.SEARCH_CONTENT)) {\n readTools.push(`\n**${MC_TOOLS.SEARCH_CONTENT}** — Search file contents using regex\n- Preferred for content search (finding functions, variables, error messages, imports, etc.)\n- Use \\`path\\` to filter by directory or glob pattern. Supports \\`contextLines\\`, \\`caseSensitive\\`, and \\`maxCount\\`.\n- Example: Find a function: \\`{ pattern: \"function handleSubmit\", path: \"**/*.ts\" }\\`\n- Example: Find imports: \\`{ pattern: \"from ['\\\\\"\\\\]express['\\\\\"\\\\]\", path: \"**/*.ts\" }\\`\n- Respects .gitignore by default.`);\n }\n\n if (!denied.has(MC_TOOLS.FIND_FILES)) {\n readTools.push(`\n**${MC_TOOLS.FIND_FILES}** — List files and directories as a tree\n- Preferred for exploring project structure and finding files by pattern.\n- Returns tree-style output. Respects .gitignore by default.\n- Example: List project root: \\`{ path: \"./\" }\\`\n- Example: Find test files: \\`{ path: \"./src\", pattern: \"**/*.test.ts\" }\\`\n- Example: Find config files: \\`{ pattern: \"*.config.{js,ts,json}\" }\\``);\n }\n\n if (!denied.has(MC_TOOLS.EXECUTE_COMMAND)) {\n readTools.push(`\n**${MC_TOOLS.EXECUTE_COMMAND}** — Run shell commands\n- Use for: git, npm/pnpm, docker, build tools, test runners, and other terminal operations.\n- Prefer dedicated tools for: file reading (${MC_TOOLS.VIEW}), file search (${MC_TOOLS.SEARCH_CONTENT}/${MC_TOOLS.FIND_FILES}), file editing (${MC_TOOLS.STRING_REPLACE_LSP}/${MC_TOOLS.WRITE_FILE}).\n- Commands have a 30-second default timeout. Use \\`timeout\\` for longer commands, \\`cwd\\` for working directory.\n- Use the \\`tail\\` parameter or pipe to \\`| tail -N\\` to limit output — the full output streams to the user, only the tail is returned to you. If you're building any kind of package you should be tailing.\n- Good: Run independent commands in parallel when possible.\n- Bad: Running \\`cat file.txt\\` — use the ${MC_TOOLS.VIEW} tool instead.`);\n }\n\n if (!denied.has(MC_TOOLS.LSP_INSPECT)) {\n readTools.push(`\n**${MC_TOOLS.LSP_INSPECT}** — Inspect code using Language Server Protocol\n- Use this for type information, hover docs, go-to-definition, and finding implementations for a symbol.\n- Best when you already know the file and line and need semantic code intelligence rather than raw file contents.\n- Input: \\`path\\` (absolute file path), \\`line\\` (1-indexed line number), \\`match\\` (the exact line content with exactly one \\`<<<\\` cursor marker).\n- Output includes: \\`hover\\`, \\`definition\\` (compact location with preview), and \\`implementation\\` (compact usage/implementation locations).\n- Example: \\`{ path: \"/abs/path/src/foo.ts\", line: 10, match: \"const foo = <<<bar()\" }\\` — inspect the symbol at the \\`<<<\\` position.\n- Use \\`${MC_TOOLS.VIEW}\\` when you need to read the implementation or surrounding code.\n- Use \\`${MC_TOOLS.SEARCH_CONTENT}\\` or \\`${MC_TOOLS.FIND_FILES}\\` first if you do not yet know where the symbol is.`);\n }\n\n if (!denied.has(MC_TOOLS.NOTIFICATION_INBOX)) {\n readTools.push(`\n**${MC_TOOLS.NOTIFICATION_INBOX}** — Inspect and manage notification inbox records\n- Use this when a \\`<notification-summary>\\` says pending notifications exist.\n- Use \\`{ \"action\": \"list\", \"status\": \"pending\" }\\` or \\`{ \"action\": \"search\", \"query\": \"...\" }\\` to find notification records for the current thread.\n- Use \\`read\\` to deliver unread notification signals into the chat and mark them seen; the tool result summarizes the count instead of exposing notification contents.\n- Use \\`dismiss\\` or \\`archive\\` only when the user asks or the notification is no longer relevant.`);\n }\n\n if (readTools.length > 0) {\n sections.push(readTools.join('\\n'));\n }\n\n // --- Write/edit tools (build & fast only) ---\n\n if (modeId !== 'plan') {\n const writeTools: string[] = [];\n\n if (!denied.has(MC_TOOLS.STRING_REPLACE_LSP)) {\n writeTools.push(`\n**${MC_TOOLS.STRING_REPLACE_LSP}** — Edit files by replacing exact text\n- You MUST read a file with \\`${MC_TOOLS.VIEW}\\` before editing it.\n- \\`old_string\\` must be an exact match of existing text in the file.\n- Provide enough surrounding context in \\`old_string\\` to make it unique.\n- Use \\`replace_all: true\\` to replace all occurrences (default: false, requires unique match).\n- For creating new files, use \\`${MC_TOOLS.WRITE_FILE}\\` instead.\n- Good: Include 2-3 lines of surrounding context to ensure uniqueness.\n- Bad: Using just \\`return true;\\` — too common, will match multiple places.`);\n }\n\n if (!denied.has(MC_TOOLS.WRITE_FILE)) {\n writeTools.push(`\n**${MC_TOOLS.WRITE_FILE}** — Create new files or overwrite existing ones\n- Use this to create new files.\n- If overwriting an existing file, you MUST have read it first with \\`${MC_TOOLS.VIEW}\\`.\n- Prefer editing existing files over creating new ones.`);\n }\n\n if (writeTools.length > 0) {\n sections.push(writeTools.join('\\n'));\n }\n }\n\n // --- Web tools (all modes, conditionally available) ---\n\n if (options.hasWebSearch) {\n const webTools: string[] = [];\n if (!denied.has('web_search')) webTools.push('**web_search**');\n if (!denied.has('web_extract')) webTools.push('**web_extract**');\n if (webTools.length > 0) {\n sections.push(`\n${webTools.join(' / ')} — Search the web / extract page content\n- Use for looking up documentation, error messages, package APIs.`);\n }\n }\n\n // --- Subconscious knowledge tools (all modes, conditionally available) ---\n\n if (options.hasSubconscious) {\n const knowledgeTools = ['knowledge_search', 'knowledge_read', 'knowledge_browse'].filter(name => !denied.has(name));\n const hasAskMemory = !denied.has('ask_memory');\n if (knowledgeTools.length > 0 || hasAskMemory) {\n const lines = [\n `\n# Subconscious Memory\n\nA background memory system (the \"subconscious\") runs alongside you. After conversations, it extracts durable knowledge — decisions, preferences, people, files, repos, work items — into a knowledge graph scoped to this project, visible across your sessions here. It also delivers reminders (\\`<remembered>\\`) and pinned knowledge into your context on its own; you do not manage those directly.`,\n ];\n if (knowledgeTools.length > 0) {\n const bullets: string[] = [];\n if (knowledgeTools.includes('knowledge_search')) {\n bullets.push(\n \"- Use `knowledge_search` for a quick lexical + semantic lookup when you need a specific fact (a past decision, a person's role, what a file is for). Cheaper than re-deriving it from the codebase or asking the user.\",\n );\n }\n if (knowledgeTools.includes('knowledge_read')) {\n bullets.push('- Use `knowledge_read` to open a node by name or ID and see the records about it.');\n }\n if (knowledgeTools.includes('knowledge_browse')) {\n bullets.push(\n \"- Use `knowledge_browse` to list nodes by kind or name prefix, or to walk a node's mentions and backlinks.\",\n );\n }\n if (!denied.has('recall')) {\n bullets.push(\n '- Prefer these over `recall` when the question is about durable facts rather than what was said in a specific past conversation.',\n );\n }\n lines.push(`\n${knowledgeTools.map(name => `**${name}**`).join(' / ')} — Query the knowledge graph directly\n${bullets.join('\\n')}`);\n }\n if (hasAskMemory) {\n lines.push(`\n**ask_memory** — Ask the reminder sidekick a question about existing memory\n- Use only when the answer is not already in your context and a direct search is not enough: open-ended questions (\"what did we decide about X and why?\") or questions that need synthesis across several memories. It answers from what is already remembered; it does not store anything.\n- It is ASYNCHRONOUS. The tool returns as soon as the question is accepted; the answer arrives later as one or more \\`<remind-answer source=\"subconscious\" agent=\"remind\" replyId=\"…\" moreComing=\"true|false\">\\` messages in your context. Keep working — do not poll or wait, and do not re-ask the same question.\n- Treat a message with \\`moreComing=\"true\"\\` as partial; the reply is complete only when \\`moreComing=\"false\"\\` arrives. Fold the answer into your work and cite it as remembered context rather than as something you verified yourself.`);\n }\n sections.push(lines.join('\\n'));\n }\n }\n\n // --- Task management tools (all modes) ---\n\n const taskTools: string[] = [];\n const canUpdateTask = !denied.has('task_update');\n const canCompleteTask = !denied.has('task_complete');\n const canCheckTasks = !denied.has('task_check');\n const canWriteTasks = !denied.has('task_write');\n const patchToolGuidance =\n canUpdateTask && canCompleteTask\n ? '- Prefer task_update or task_complete when changing one existing task.'\n : canUpdateTask\n ? '- Prefer task_update when changing one existing task.'\n : canCompleteTask\n ? '- Prefer task_complete when marking one existing task completed.'\n : '- Use task_write with the full task list when changing existing tasks.';\n\n if (canWriteTasks) {\n taskTools.push(`\n**task_write** — Track tasks for complex multi-step work\n- Use when a task requires 3 or more distinct steps or actions.\n- Use task_write to create the initial task list or replace the whole list after replanning.\n- Each task has: id (stable identifier), content (imperative form), status (pending, in_progress, or completed), activeForm (present continuous form shown during execution).\n- Keep task IDs stable across updates. If you omit IDs, the tool result returns generated IDs.\n${patchToolGuidance}\n- Mark tasks \\`in_progress\\` BEFORE starting work. Only ONE task should be \\`in_progress\\` at a time.\n- Mark tasks \\`completed\\` IMMEDIATELY after finishing each task. Do not batch completions.`);\n }\n\n if (canUpdateTask) {\n taskTools.push(`\n**task_update** — Patch one tracked task by ID\n- Use this for targeted changes to one existing task.\n- Provide the task ID and only the fields that changed: content, status, or activeForm.`);\n }\n\n if (canCompleteTask) {\n const idSource = canCheckTasks\n ? 'Use task_check if you need the current IDs before completing a task.'\n : canWriteTasks\n ? 'Use IDs returned by task_write.'\n : 'Use only task IDs already visible in the current task list.';\n taskTools.push(`\n**task_complete** — Mark one tracked task completed by ID\n- Use this immediately after finishing a tracked task.\n- ${idSource}`);\n }\n\n if (canCheckTasks) {\n taskTools.push(`\n**task_check** — Check completion status of tasks\n- Use this BEFORE finishing tracked work to verify all tasks are completed.\n- Returns a readable status summary plus structured fields: tasks, summary, incompleteTasks, and isError.\n- summary includes total, completed, inProgress, pending, incomplete, hasTasks, and allCompleted.\n- Use summary.allCompleted to decide whether tracked work is complete; if summary.hasTasks is false, no task list is currently tracked.\n- If any tasks remain incomplete, continue working on them.\n- IMPORTANT: Always check task completion before ending work on a complex task.`);\n }\n\n if (!denied.has('ask_user')) {\n taskTools.push(`\n**ask_user** — Ask the user a structured question\n- Use when you need clarification, want to validate assumptions, or need the user to make a decision.\n- Provide clear, specific questions. End with a question mark.\n- Include options (2-4 choices) for structured decisions. Omit options for open-ended questions.\n- Don't use this for simple yes/no — just ask in your text response.`);\n }\n\n if (taskTools.length > 0) {\n sections.push(taskTools.join('\\n'));\n }\n\n // --- Plan tools (plan mode) ---\n\n if (modeId === 'plan' && !denied.has('submit_plan')) {\n sections.push(`\n**submit_plan** — Submit a completed implementation plan for user review\n- Call this tool when your plan is complete. Do NOT just describe your plan in text — you MUST call this tool.\n- The plan will be rendered as markdown and the user can approve, reject, or request changes.\n- On approval, the system automatically switches to the default mode so you can implement.\n- Takes one argument: \\`path\\` (the plan markdown file you wrote under \\`${plansDir}/\\`). Do NOT pass the plan body — it lives in the file.`);\n }\n\n if (modeId === 'plan') {\n sections.push(`\n**Plan file access** — Your plan lives in a markdown file under \\`${plansDir}/\\` (e.g. \\`add-dark-mode-toggle.md\\`)\n- Use \\`write_file\\` to create the plan file, \\`view\\` to read it, and \\`string_replace_lsp\\` for targeted edits.\n- On first submission: write the plan to the file, then call \\`submit_plan\\` with its \\`path\\`.\n- On revision: read the existing file, edit specific sections, re-read, then call \\`submit_plan\\` with the same \\`path\\`.\n- If a plan file already exists, you previously submitted it — read it before revising.`);\n }\n\n // --- Subagent tool (all modes) ---\n\n if (options.hasSubagents !== false && !denied.has('subagent')) {\n sections.push(`\n**subagent** — Delegate a focused task to a specialized subagent\n- Only use subagents when you will spawn **multiple subagents in parallel**. If you only need one task done, do it yourself.\n- Subagent outputs are **untrusted**. Always review and verify the results.`);\n }\n\n return sections.join('\\n');\n}\n"],"mappings":"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"}