@mastra/code-sdk 0.0.0-esbuild-bundle-worker-20260807173433

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 (491) hide show
  1. package/CHANGELOG.md +1349 -0
  2. package/LICENSE.md +30 -0
  3. package/README.md +70 -0
  4. package/dist/acp/agent.d.ts +35 -0
  5. package/dist/acp/agent.d.ts.map +1 -0
  6. package/dist/acp/agent.js +161 -0
  7. package/dist/acp/agent.js.map +1 -0
  8. package/dist/acp/event-mapper.d.ts +22 -0
  9. package/dist/acp/event-mapper.d.ts.map +1 -0
  10. package/dist/acp/event-mapper.js +214 -0
  11. package/dist/acp/event-mapper.js.map +1 -0
  12. package/dist/acp/index.d.ts +8 -0
  13. package/dist/acp/index.d.ts.map +1 -0
  14. package/dist/acp/index.js +65 -0
  15. package/dist/acp/index.js.map +1 -0
  16. package/dist/acp/server.d.ts +7 -0
  17. package/dist/acp/server.d.ts.map +1 -0
  18. package/dist/acp/server.js +35 -0
  19. package/dist/acp/server.js.map +1 -0
  20. package/dist/acp.d.ts +2 -0
  21. package/dist/acp.d.ts.map +1 -0
  22. package/dist/acp.js +2 -0
  23. package/dist/agents/credential-resolver.d.ts +51 -0
  24. package/dist/agents/credential-resolver.d.ts.map +1 -0
  25. package/dist/agents/credential-resolver.js +52 -0
  26. package/dist/agents/credential-resolver.js.map +1 -0
  27. package/dist/agents/custom-provider-source.d.ts +35 -0
  28. package/dist/agents/custom-provider-source.d.ts.map +1 -0
  29. package/dist/agents/custom-provider-source.js +25 -0
  30. package/dist/agents/custom-provider-source.js.map +1 -0
  31. package/dist/agents/instructions.d.ts +6 -0
  32. package/dist/agents/instructions.d.ts.map +1 -0
  33. package/dist/agents/instructions.js +32 -0
  34. package/dist/agents/instructions.js.map +1 -0
  35. package/dist/agents/mastracode-gateway.d.ts +74 -0
  36. package/dist/agents/mastracode-gateway.d.ts.map +1 -0
  37. package/dist/agents/mastracode-gateway.js +400 -0
  38. package/dist/agents/mastracode-gateway.js.map +1 -0
  39. package/dist/agents/memory.d.ts +13 -0
  40. package/dist/agents/memory.d.ts.map +1 -0
  41. package/dist/agents/memory.js +116 -0
  42. package/dist/agents/memory.js.map +1 -0
  43. package/dist/agents/model.d.ts +59 -0
  44. package/dist/agents/model.d.ts.map +1 -0
  45. package/dist/agents/model.js +132 -0
  46. package/dist/agents/model.js.map +1 -0
  47. package/dist/agents/modes/build.d.ts +10 -0
  48. package/dist/agents/modes/build.d.ts.map +1 -0
  49. package/dist/agents/modes/build.js +44 -0
  50. package/dist/agents/modes/build.js.map +1 -0
  51. package/dist/agents/modes/explore.d.ts +10 -0
  52. package/dist/agents/modes/explore.d.ts.map +1 -0
  53. package/dist/agents/modes/explore.js +39 -0
  54. package/dist/agents/modes/explore.js.map +1 -0
  55. package/dist/agents/modes/plan.d.ts +6 -0
  56. package/dist/agents/modes/plan.d.ts.map +1 -0
  57. package/dist/agents/modes/plan.js +37 -0
  58. package/dist/agents/modes/plan.js.map +1 -0
  59. package/dist/agents/prompts/agent-instructions.d.ts +61 -0
  60. package/dist/agents/prompts/agent-instructions.d.ts.map +1 -0
  61. package/dist/agents/prompts/agent-instructions.js +201 -0
  62. package/dist/agents/prompts/agent-instructions.js.map +1 -0
  63. package/dist/agents/prompts/build.d.ts +12 -0
  64. package/dist/agents/prompts/build.d.ts.map +1 -0
  65. package/dist/agents/prompts/build.js +76 -0
  66. package/dist/agents/prompts/build.js.map +1 -0
  67. package/dist/agents/prompts/fast.d.ts +5 -0
  68. package/dist/agents/prompts/fast.d.ts.map +1 -0
  69. package/dist/agents/prompts/fast.js +26 -0
  70. package/dist/agents/prompts/fast.js.map +1 -0
  71. package/dist/agents/prompts/index.d.ts +19 -0
  72. package/dist/agents/prompts/index.d.ts.map +1 -0
  73. package/dist/agents/prompts/index.js +65 -0
  74. package/dist/agents/prompts/index.js.map +1 -0
  75. package/dist/agents/prompts/model.d.ts +5 -0
  76. package/dist/agents/prompts/model.d.ts.map +1 -0
  77. package/dist/agents/prompts/model.js +23 -0
  78. package/dist/agents/prompts/model.js.map +1 -0
  79. package/dist/agents/prompts/plan.d.ts +6 -0
  80. package/dist/agents/prompts/plan.d.ts.map +1 -0
  81. package/dist/agents/prompts/plan.js +111 -0
  82. package/dist/agents/prompts/plan.js.map +1 -0
  83. package/dist/agents/prompts/tool-guidance.d.ts +13 -0
  84. package/dist/agents/prompts/tool-guidance.d.ts.map +1 -0
  85. package/dist/agents/prompts/tool-guidance.js +149 -0
  86. package/dist/agents/prompts/tool-guidance.js.map +1 -0
  87. package/dist/agents/sandbox-filesystem.d.ts +99 -0
  88. package/dist/agents/sandbox-filesystem.d.ts.map +1 -0
  89. package/dist/agents/sandbox-filesystem.js +328 -0
  90. package/dist/agents/sandbox-filesystem.js.map +1 -0
  91. package/dist/agents/sandbox-reattach.d.ts +19 -0
  92. package/dist/agents/sandbox-reattach.d.ts.map +1 -0
  93. package/dist/agents/sandbox-reattach.js +15 -0
  94. package/dist/agents/sandbox-reattach.js.map +1 -0
  95. package/dist/agents/thread-caveman-state.d.ts +17 -0
  96. package/dist/agents/thread-caveman-state.d.ts.map +1 -0
  97. package/dist/agents/thread-caveman-state.js +107 -0
  98. package/dist/agents/thread-caveman-state.js.map +1 -0
  99. package/dist/agents/tool-availability.d.ts +10 -0
  100. package/dist/agents/tool-availability.d.ts.map +1 -0
  101. package/dist/agents/tool-availability.js +87 -0
  102. package/dist/agents/tool-availability.js.map +1 -0
  103. package/dist/agents/tools.d.ts +19 -0
  104. package/dist/agents/tools.d.ts.map +1 -0
  105. package/dist/agents/tools.js +105 -0
  106. package/dist/agents/tools.js.map +1 -0
  107. package/dist/agents/workspace.d.ts +32 -0
  108. package/dist/agents/workspace.d.ts.map +1 -0
  109. package/dist/agents/workspace.js +251 -0
  110. package/dist/agents/workspace.js.map +1 -0
  111. package/dist/analytics.d.ts +18 -0
  112. package/dist/analytics.d.ts.map +1 -0
  113. package/dist/analytics.js +163 -0
  114. package/dist/analytics.js.map +1 -0
  115. package/dist/auth/authorization-input.d.ts +16 -0
  116. package/dist/auth/authorization-input.d.ts.map +1 -0
  117. package/dist/auth/authorization-input.js +42 -0
  118. package/dist/auth/authorization-input.js.map +1 -0
  119. package/dist/auth/device-code.d.ts +93 -0
  120. package/dist/auth/device-code.d.ts.map +1 -0
  121. package/dist/auth/device-code.js +129 -0
  122. package/dist/auth/device-code.js.map +1 -0
  123. package/dist/auth/index.d.ts +10 -0
  124. package/dist/auth/index.d.ts.map +1 -0
  125. package/dist/auth/index.js +6 -0
  126. package/dist/auth/pkce.d.ts +13 -0
  127. package/dist/auth/pkce.d.ts.map +1 -0
  128. package/dist/auth/pkce.js +32 -0
  129. package/dist/auth/pkce.js.map +1 -0
  130. package/dist/auth/providers/anthropic.d.ts +40 -0
  131. package/dist/auth/providers/anthropic.d.ts.map +1 -0
  132. package/dist/auth/providers/anthropic.js +126 -0
  133. package/dist/auth/providers/anthropic.js.map +1 -0
  134. package/dist/auth/providers/github-copilot.d.ts +154 -0
  135. package/dist/auth/providers/github-copilot.d.ts.map +1 -0
  136. package/dist/auth/providers/github-copilot.js +340 -0
  137. package/dist/auth/providers/github-copilot.js.map +1 -0
  138. package/dist/auth/providers/openai-codex.d.ts +139 -0
  139. package/dist/auth/providers/openai-codex.d.ts.map +1 -0
  140. package/dist/auth/providers/openai-codex.js +519 -0
  141. package/dist/auth/providers/openai-codex.js.map +1 -0
  142. package/dist/auth/providers/xai.d.ts +64 -0
  143. package/dist/auth/providers/xai.d.ts.map +1 -0
  144. package/dist/auth/providers/xai.js +205 -0
  145. package/dist/auth/providers/xai.js.map +1 -0
  146. package/dist/auth/storage.d.ts +91 -0
  147. package/dist/auth/storage.d.ts.map +1 -0
  148. package/dist/auth/storage.js +197 -0
  149. package/dist/auth/storage.js.map +1 -0
  150. package/dist/auth/types.d.ts +89 -0
  151. package/dist/auth/types.d.ts.map +1 -0
  152. package/dist/auth/types.js +1 -0
  153. package/dist/clipboard/index.d.ts +26 -0
  154. package/dist/clipboard/index.d.ts.map +1 -0
  155. package/dist/clipboard/index.js +226 -0
  156. package/dist/clipboard/index.js.map +1 -0
  157. package/dist/constants.d.ts +10 -0
  158. package/dist/constants.d.ts.map +1 -0
  159. package/dist/constants.js +18 -0
  160. package/dist/constants.js.map +1 -0
  161. package/dist/error-classification.d.ts +10 -0
  162. package/dist/error-classification.d.ts.map +1 -0
  163. package/dist/error-classification.js +22 -0
  164. package/dist/error-classification.js.map +1 -0
  165. package/dist/evals/context-builder.d.ts +41 -0
  166. package/dist/evals/context-builder.d.ts.map +1 -0
  167. package/dist/evals/context-builder.js +161 -0
  168. package/dist/evals/context-builder.js.map +1 -0
  169. package/dist/evals/index.d.ts +4 -0
  170. package/dist/evals/index.d.ts.map +1 -0
  171. package/dist/evals/index.js +5 -0
  172. package/dist/evals/scorers/classify-command.d.ts +31 -0
  173. package/dist/evals/scorers/classify-command.d.ts.map +1 -0
  174. package/dist/evals/scorers/classify-command.js +73 -0
  175. package/dist/evals/scorers/classify-command.js.map +1 -0
  176. package/dist/evals/scorers/efficiency.d.ts +44 -0
  177. package/dist/evals/scorers/efficiency.d.ts.map +1 -0
  178. package/dist/evals/scorers/efficiency.js +259 -0
  179. package/dist/evals/scorers/efficiency.js.map +1 -0
  180. package/dist/evals/scorers/extract-tools.d.ts +25 -0
  181. package/dist/evals/scorers/extract-tools.d.ts.map +1 -0
  182. package/dist/evals/scorers/extract-tools.js +60 -0
  183. package/dist/evals/scorers/extract-tools.js.map +1 -0
  184. package/dist/evals/scorers/index.d.ts +3 -0
  185. package/dist/evals/scorers/index.d.ts.map +1 -0
  186. package/dist/evals/scorers/index.js +3 -0
  187. package/dist/evals/scorers/outcome.d.ts +49 -0
  188. package/dist/evals/scorers/outcome.d.ts.map +1 -0
  189. package/dist/evals/scorers/outcome.js +347 -0
  190. package/dist/evals/scorers/outcome.js.map +1 -0
  191. package/dist/goal-manager.d.ts +78 -0
  192. package/dist/goal-manager.d.ts.map +1 -0
  193. package/dist/goal-manager.js +273 -0
  194. package/dist/goal-manager.js.map +1 -0
  195. package/dist/goal-signal.d.ts +14 -0
  196. package/dist/goal-signal.d.ts.map +1 -0
  197. package/dist/goal-signal.js +17 -0
  198. package/dist/goal-signal.js.map +1 -0
  199. package/dist/headless/cli.d.ts +42 -0
  200. package/dist/headless/cli.d.ts.map +1 -0
  201. package/dist/headless/cli.js +195 -0
  202. package/dist/headless/cli.js.map +1 -0
  203. package/dist/headless/flags.d.ts +33 -0
  204. package/dist/headless/flags.d.ts.map +1 -0
  205. package/dist/headless/flags.js +190 -0
  206. package/dist/headless/flags.js.map +1 -0
  207. package/dist/headless/format.d.ts +38 -0
  208. package/dist/headless/format.d.ts.map +1 -0
  209. package/dist/headless/format.js +89 -0
  210. package/dist/headless/format.js.map +1 -0
  211. package/dist/headless/index.d.ts +25 -0
  212. package/dist/headless/index.d.ts.map +1 -0
  213. package/dist/headless/index.js +6 -0
  214. package/dist/headless/policy.d.ts +17 -0
  215. package/dist/headless/policy.d.ts.map +1 -0
  216. package/dist/headless/policy.js +42 -0
  217. package/dist/headless/policy.js.map +1 -0
  218. package/dist/headless/run-mc.d.ts +7 -0
  219. package/dist/headless/run-mc.d.ts.map +1 -0
  220. package/dist/headless/run-mc.js +346 -0
  221. package/dist/headless/run-mc.js.map +1 -0
  222. package/dist/headless/types.d.ts +158 -0
  223. package/dist/headless/types.d.ts.map +1 -0
  224. package/dist/headless/types.js +18 -0
  225. package/dist/headless/types.js.map +1 -0
  226. package/dist/hooks/config.d.ts +11 -0
  227. package/dist/hooks/config.d.ts.map +1 -0
  228. package/dist/hooks/config.js +73 -0
  229. package/dist/hooks/config.js.map +1 -0
  230. package/dist/hooks/executor.d.ts +13 -0
  231. package/dist/hooks/executor.d.ts.map +1 -0
  232. package/dist/hooks/executor.js +128 -0
  233. package/dist/hooks/executor.js.map +1 -0
  234. package/dist/hooks/index.d.ts +6 -0
  235. package/dist/hooks/index.d.ts.map +1 -0
  236. package/dist/hooks/index.js +5 -0
  237. package/dist/hooks/manager.d.ts +47 -0
  238. package/dist/hooks/manager.d.ts.map +1 -0
  239. package/dist/hooks/manager.js +225 -0
  240. package/dist/hooks/manager.js.map +1 -0
  241. package/dist/hooks/types.d.ts +152 -0
  242. package/dist/hooks/types.d.ts.map +1 -0
  243. package/dist/hooks/types.js +8 -0
  244. package/dist/hooks/types.js.map +1 -0
  245. package/dist/index.d.ts +258 -0
  246. package/dist/index.d.ts.map +1 -0
  247. package/dist/index.js +740 -0
  248. package/dist/index.js.map +1 -0
  249. package/dist/ipc/ipc-reporter.d.ts +14 -0
  250. package/dist/ipc/ipc-reporter.d.ts.map +1 -0
  251. package/dist/ipc/ipc-reporter.js +21 -0
  252. package/dist/ipc/ipc-reporter.js.map +1 -0
  253. package/dist/lsp/client.d.ts +56 -0
  254. package/dist/lsp/client.d.ts.map +1 -0
  255. package/dist/lsp/client.js +251 -0
  256. package/dist/lsp/client.js.map +1 -0
  257. package/dist/lsp/index.d.ts +4 -0
  258. package/dist/lsp/index.d.ts.map +1 -0
  259. package/dist/lsp/index.js +4 -0
  260. package/dist/lsp/language.d.ts +9 -0
  261. package/dist/lsp/language.d.ts.map +1 -0
  262. package/dist/lsp/language.js +44 -0
  263. package/dist/lsp/language.js.map +1 -0
  264. package/dist/lsp/manager.d.ts +34 -0
  265. package/dist/lsp/manager.d.ts.map +1 -0
  266. package/dist/lsp/manager.js +82 -0
  267. package/dist/lsp/manager.js.map +1 -0
  268. package/dist/lsp/server.d.ts +27 -0
  269. package/dist/lsp/server.d.ts.map +1 -0
  270. package/dist/lsp/server.js +159 -0
  271. package/dist/lsp/server.js.map +1 -0
  272. package/dist/lsp/workspace.d.ts +9 -0
  273. package/dist/lsp/workspace.d.ts.map +1 -0
  274. package/dist/lsp/workspace.js +55 -0
  275. package/dist/lsp/workspace.js.map +1 -0
  276. package/dist/mcp/config.d.ts +54 -0
  277. package/dist/mcp/config.d.ts.map +1 -0
  278. package/dist/mcp/config.js +240 -0
  279. package/dist/mcp/config.js.map +1 -0
  280. package/dist/mcp/index.d.ts +5 -0
  281. package/dist/mcp/index.d.ts.map +1 -0
  282. package/dist/mcp/index.js +3 -0
  283. package/dist/mcp/manager.d.ts +98 -0
  284. package/dist/mcp/manager.d.ts.map +1 -0
  285. package/dist/mcp/manager.js +612 -0
  286. package/dist/mcp/manager.js.map +1 -0
  287. package/dist/mcp/state.d.ts +33 -0
  288. package/dist/mcp/state.d.ts.map +1 -0
  289. package/dist/mcp/state.js +88 -0
  290. package/dist/mcp/state.js.map +1 -0
  291. package/dist/mcp/types.d.ts +120 -0
  292. package/dist/mcp/types.d.ts.map +1 -0
  293. package/dist/mcp/types.js +1 -0
  294. package/dist/onboarding/custom-packs.d.ts +7 -0
  295. package/dist/onboarding/custom-packs.d.ts.map +1 -0
  296. package/dist/onboarding/custom-packs.js +17 -0
  297. package/dist/onboarding/custom-packs.js.map +1 -0
  298. package/dist/onboarding/custom-providers.d.ts +4 -0
  299. package/dist/onboarding/custom-providers.d.ts.map +1 -0
  300. package/dist/onboarding/custom-providers.js +30 -0
  301. package/dist/onboarding/custom-providers.js.map +1 -0
  302. package/dist/onboarding/index.d.ts +5 -0
  303. package/dist/onboarding/index.d.ts.map +1 -0
  304. package/dist/onboarding/index.js +3 -0
  305. package/dist/onboarding/om-settings.d.ts +25 -0
  306. package/dist/onboarding/om-settings.d.ts.map +1 -0
  307. package/dist/onboarding/om-settings.js +47 -0
  308. package/dist/onboarding/om-settings.js.map +1 -0
  309. package/dist/onboarding/packs.d.ts +46 -0
  310. package/dist/onboarding/packs.d.ts.map +1 -0
  311. package/dist/onboarding/packs.js +160 -0
  312. package/dist/onboarding/packs.js.map +1 -0
  313. package/dist/onboarding/settings.d.ts +338 -0
  314. package/dist/onboarding/settings.d.ts.map +1 -0
  315. package/dist/onboarding/settings.js +673 -0
  316. package/dist/onboarding/settings.js.map +1 -0
  317. package/dist/permissions.d.ts +55 -0
  318. package/dist/permissions.d.ts.map +1 -0
  319. package/dist/permissions.js +132 -0
  320. package/dist/permissions.js.map +1 -0
  321. package/dist/plugin.d.ts +81 -0
  322. package/dist/plugin.d.ts.map +1 -0
  323. package/dist/plugin.js +28 -0
  324. package/dist/plugin.js.map +1 -0
  325. package/dist/plugins/dependencies.d.ts +9 -0
  326. package/dist/plugins/dependencies.d.ts.map +1 -0
  327. package/dist/plugins/dependencies.js +88 -0
  328. package/dist/plugins/dependencies.js.map +1 -0
  329. package/dist/plugins/install.d.ts +21 -0
  330. package/dist/plugins/install.d.ts.map +1 -0
  331. package/dist/plugins/install.js +190 -0
  332. package/dist/plugins/install.js.map +1 -0
  333. package/dist/plugins/loader.d.ts +15 -0
  334. package/dist/plugins/loader.d.ts.map +1 -0
  335. package/dist/plugins/loader.js +206 -0
  336. package/dist/plugins/loader.js.map +1 -0
  337. package/dist/plugins/manager.d.ts +64 -0
  338. package/dist/plugins/manager.d.ts.map +1 -0
  339. package/dist/plugins/manager.js +384 -0
  340. package/dist/plugins/manager.js.map +1 -0
  341. package/dist/plugins/manifest.d.ts +14 -0
  342. package/dist/plugins/manifest.d.ts.map +1 -0
  343. package/dist/plugins/manifest.js +50 -0
  344. package/dist/plugins/manifest.js.map +1 -0
  345. package/dist/plugins/package-link.d.ts +3 -0
  346. package/dist/plugins/package-link.d.ts.map +1 -0
  347. package/dist/plugins/package-link.js +61 -0
  348. package/dist/plugins/package-link.js.map +1 -0
  349. package/dist/plugins/paths.d.ts +10 -0
  350. package/dist/plugins/paths.d.ts.map +1 -0
  351. package/dist/plugins/paths.js +25 -0
  352. package/dist/plugins/paths.js.map +1 -0
  353. package/dist/plugins/registry.d.ts +8 -0
  354. package/dist/plugins/registry.d.ts.map +1 -0
  355. package/dist/plugins/registry.js +112 -0
  356. package/dist/plugins/registry.js.map +1 -0
  357. package/dist/plugins/scaffold.d.ts +10 -0
  358. package/dist/plugins/scaffold.d.ts.map +1 -0
  359. package/dist/plugins/scaffold.js +116 -0
  360. package/dist/plugins/scaffold.js.map +1 -0
  361. package/dist/plugins/types.d.ts +45 -0
  362. package/dist/plugins/types.d.ts.map +1 -0
  363. package/dist/plugins/types.js +1 -0
  364. package/dist/processors/plan-rejection-abort.d.ts +12 -0
  365. package/dist/processors/plan-rejection-abort.d.ts.map +1 -0
  366. package/dist/processors/plan-rejection-abort.js +54 -0
  367. package/dist/processors/plan-rejection-abort.js.map +1 -0
  368. package/dist/providers/amazon-bedrock-gateway.d.ts +47 -0
  369. package/dist/providers/amazon-bedrock-gateway.d.ts.map +1 -0
  370. package/dist/providers/amazon-bedrock-gateway.js +152 -0
  371. package/dist/providers/amazon-bedrock-gateway.js.map +1 -0
  372. package/dist/providers/amazon-bedrock.d.ts +28 -0
  373. package/dist/providers/amazon-bedrock.d.ts.map +1 -0
  374. package/dist/providers/amazon-bedrock.js +83 -0
  375. package/dist/providers/amazon-bedrock.js.map +1 -0
  376. package/dist/providers/claude-max.d.ts +52 -0
  377. package/dist/providers/claude-max.d.ts.map +1 -0
  378. package/dist/providers/claude-max.js +171 -0
  379. package/dist/providers/claude-max.js.map +1 -0
  380. package/dist/providers/github-copilot.d.ts +60 -0
  381. package/dist/providers/github-copilot.d.ts.map +1 -0
  382. package/dist/providers/github-copilot.js +265 -0
  383. package/dist/providers/github-copilot.js.map +1 -0
  384. package/dist/providers/openai-codex.d.ts +72 -0
  385. package/dist/providers/openai-codex.d.ts.map +1 -0
  386. package/dist/providers/openai-codex.js +302 -0
  387. package/dist/providers/openai-codex.js.map +1 -0
  388. package/dist/providers/xai.d.ts +33 -0
  389. package/dist/providers/xai.d.ts.map +1 -0
  390. package/dist/providers/xai.js +70 -0
  391. package/dist/providers/xai.js.map +1 -0
  392. package/dist/schema.d.ts +192 -0
  393. package/dist/schema.d.ts.map +1 -0
  394. package/dist/schema.js +98 -0
  395. package/dist/schema.js.map +1 -0
  396. package/dist/theme-palette.d.ts +17 -0
  397. package/dist/theme-palette.d.ts.map +1 -0
  398. package/dist/theme-palette.js +21 -0
  399. package/dist/theme-palette.js.map +1 -0
  400. package/dist/tool-names.d.ts +73 -0
  401. package/dist/tool-names.d.ts.map +1 -0
  402. package/dist/tool-names.js +52 -0
  403. package/dist/tool-names.js.map +1 -0
  404. package/dist/tools/index.d.ts +6 -0
  405. package/dist/tools/index.d.ts.map +1 -0
  406. package/dist/tools/index.js +3 -0
  407. package/dist/tools/request-sandbox-access.d.ts +6 -0
  408. package/dist/tools/request-sandbox-access.d.ts.map +1 -0
  409. package/dist/tools/request-sandbox-access.js +79 -0
  410. package/dist/tools/request-sandbox-access.js.map +1 -0
  411. package/dist/tools/utils.d.ts +20 -0
  412. package/dist/tools/utils.d.ts.map +1 -0
  413. package/dist/tools/utils.js +32 -0
  414. package/dist/tools/utils.js.map +1 -0
  415. package/dist/tools/web-search.d.ts +35 -0
  416. package/dist/tools/web-search.d.ts.map +1 -0
  417. package/dist/tools/web-search.js +61 -0
  418. package/dist/tools/web-search.js.map +1 -0
  419. package/dist/utils/binaries.d.ts +7 -0
  420. package/dist/utils/binaries.d.ts.map +1 -0
  421. package/dist/utils/binaries.js +78 -0
  422. package/dist/utils/binaries.js.map +1 -0
  423. package/dist/utils/debug-log.d.ts +12 -0
  424. package/dist/utils/debug-log.d.ts.map +1 -0
  425. package/dist/utils/debug-log.js +59 -0
  426. package/dist/utils/debug-log.js.map +1 -0
  427. package/dist/utils/errors.d.ts +36 -0
  428. package/dist/utils/errors.d.ts.map +1 -0
  429. package/dist/utils/errors.js +172 -0
  430. package/dist/utils/errors.js.map +1 -0
  431. package/dist/utils/gateway-sync.d.ts +26 -0
  432. package/dist/utils/gateway-sync.d.ts.map +1 -0
  433. package/dist/utils/gateway-sync.js +61 -0
  434. package/dist/utils/gateway-sync.js.map +1 -0
  435. package/dist/utils/path-security.d.ts +2 -0
  436. package/dist/utils/path-security.d.ts.map +1 -0
  437. package/dist/utils/path-security.js +10 -0
  438. package/dist/utils/path-security.js.map +1 -0
  439. package/dist/utils/plan-diff.d.ts +25 -0
  440. package/dist/utils/plan-diff.d.ts.map +1 -0
  441. package/dist/utils/plan-diff.js +62 -0
  442. package/dist/utils/plan-diff.js.map +1 -0
  443. package/dist/utils/plans.d.ts +56 -0
  444. package/dist/utils/plans.d.ts.map +1 -0
  445. package/dist/utils/plans.js +117 -0
  446. package/dist/utils/plans.js.map +1 -0
  447. package/dist/utils/project.d.ts +160 -0
  448. package/dist/utils/project.d.ts.map +1 -0
  449. package/dist/utils/project.js +364 -0
  450. package/dist/utils/project.js.map +1 -0
  451. package/dist/utils/signals-pubsub.d.ts +41 -0
  452. package/dist/utils/signals-pubsub.d.ts.map +1 -0
  453. package/dist/utils/signals-pubsub.js +122 -0
  454. package/dist/utils/signals-pubsub.js.map +1 -0
  455. package/dist/utils/slash-command-loader.d.ts +52 -0
  456. package/dist/utils/slash-command-loader.d.ts.map +1 -0
  457. package/dist/utils/slash-command-loader.js +141 -0
  458. package/dist/utils/slash-command-loader.js.map +1 -0
  459. package/dist/utils/slash-command-processor.d.ts +14 -0
  460. package/dist/utils/slash-command-processor.d.ts.map +1 -0
  461. package/dist/utils/slash-command-processor.js +105 -0
  462. package/dist/utils/slash-command-processor.js.map +1 -0
  463. package/dist/utils/stdin-pipe.d.ts +33 -0
  464. package/dist/utils/stdin-pipe.d.ts.map +1 -0
  465. package/dist/utils/stdin-pipe.js +96 -0
  466. package/dist/utils/stdin-pipe.js.map +1 -0
  467. package/dist/utils/storage-factory.d.ts +50 -0
  468. package/dist/utils/storage-factory.d.ts.map +1 -0
  469. package/dist/utils/storage-factory.js +121 -0
  470. package/dist/utils/storage-factory.js.map +1 -0
  471. package/dist/utils/storage-maintenance.d.ts +103 -0
  472. package/dist/utils/storage-maintenance.d.ts.map +1 -0
  473. package/dist/utils/storage-maintenance.js +274 -0
  474. package/dist/utils/storage-maintenance.js.map +1 -0
  475. package/dist/utils/thread-lock.d.ts +26 -0
  476. package/dist/utils/thread-lock.d.ts.map +1 -0
  477. package/dist/utils/thread-lock.js +112 -0
  478. package/dist/utils/thread-lock.js.map +1 -0
  479. package/dist/utils/token-estimator.d.ts +3 -0
  480. package/dist/utils/token-estimator.d.ts.map +1 -0
  481. package/dist/utils/token-estimator.js +21 -0
  482. package/dist/utils/token-estimator.js.map +1 -0
  483. package/dist/utils/update-check.d.ts +101 -0
  484. package/dist/utils/update-check.d.ts.map +1 -0
  485. package/dist/utils/update-check.js +383 -0
  486. package/dist/utils/update-check.js.map +1 -0
  487. package/dist/voice/stt-registry.d.ts +64 -0
  488. package/dist/voice/stt-registry.d.ts.map +1 -0
  489. package/dist/voice/stt-registry.js +144 -0
  490. package/dist/voice/stt-registry.js.map +1 -0
  491. package/package.json +96 -0
@@ -0,0 +1,201 @@
1
+ import { DEFAULT_CONFIG_DIR } from "../../constants.js";
2
+ import { existsSync, readFileSync, statSync } from "fs";
3
+ import { homedir } from "os";
4
+ import { isAbsolute, join, normalize, relative, sep } from "path";
5
+ import { execFileSync } from "child_process";
6
+ //#region src/agents/prompts/agent-instructions.ts
7
+ /**
8
+ * Load project and global agent instruction files (AGENTS.md, CLAUDE.md).
9
+ * Prefers AGENTS.md over CLAUDE.md when multiple exist at the same location.
10
+ */
11
+ const INSTRUCTION_FILES = ["AGENTS.md", "CLAUDE.md"];
12
+ const PROJECT_LOCATIONS = [
13
+ "",
14
+ ".claude",
15
+ ".mastracode"
16
+ ];
17
+ const GLOBAL_LOCATIONS = [
18
+ ".claude",
19
+ ".mastracode",
20
+ ".config/claude",
21
+ ".config/mastracode"
22
+ ];
23
+ const fsInstructionReader = {
24
+ exists: (path) => existsSync(path),
25
+ read: (path) => readFileSync(path, "utf-8")
26
+ };
27
+ /**
28
+ * Create a reader that serves instruction files from a git ref instead of the
29
+ * working tree. Paths are still addressed as working-tree paths under
30
+ * `projectPath`; content comes from `git show <ref>:<relpath>` so an untrusted
31
+ * checkout (e.g. a PR branch under review) cannot influence what is loaded.
32
+ * Tries `origin/<ref>` first (remote truth), then the local ref. Any git
33
+ * failure (missing ref, missing file, no repo) reports the file as absent.
34
+ */
35
+ function createGitRefInstructionReader(projectPath, ref) {
36
+ const toRelative = (path) => {
37
+ const rel = relative(projectPath, path);
38
+ if (!rel || rel.startsWith("..") || isAbsolute(rel)) return null;
39
+ return rel.split(sep).join("/");
40
+ };
41
+ const show = (path) => {
42
+ const rel = toRelative(path);
43
+ if (rel === null) return null;
44
+ for (const candidate of [`origin/${ref}`, ref]) try {
45
+ return execFileSync("git", [
46
+ "-C",
47
+ projectPath,
48
+ "show",
49
+ `${candidate}:${rel}`
50
+ ], {
51
+ encoding: "utf-8",
52
+ stdio: [
53
+ "ignore",
54
+ "pipe",
55
+ "ignore"
56
+ ],
57
+ maxBuffer: 1024 * 1024
58
+ });
59
+ } catch {}
60
+ return null;
61
+ };
62
+ return {
63
+ ref,
64
+ exists: (path) => show(path) !== null,
65
+ read: (path) => {
66
+ const content = show(path);
67
+ if (content === null) throw new Error(`Not found at ref ${ref}: ${path}`);
68
+ return content;
69
+ }
70
+ };
71
+ }
72
+ /**
73
+ * Reader for the reactive reminder channel (AgentsMDInjector) that serves
74
+ * paths under `projectPath` from a trusted git ref. Paths outside the project
75
+ * fall back to the operator machine's filesystem (those are trusted); paths
76
+ * inside the project are only ever resolved against the ref, never the
77
+ * working tree, so an untrusted checkout cannot feed content in.
78
+ */
79
+ function createGitRefReminderReader(projectPath, ref) {
80
+ const gitReader = createGitRefInstructionReader(projectPath, ref);
81
+ const toRelative = (path) => {
82
+ const rel = relative(projectPath, normalize(path));
83
+ if (rel.startsWith("..") || isAbsolute(rel)) return null;
84
+ return rel.split(sep).join("/");
85
+ };
86
+ const objectType = (rel) => {
87
+ if (rel === "") return "tree";
88
+ for (const candidate of [`origin/${ref}`, ref]) try {
89
+ return execFileSync("git", [
90
+ "-C",
91
+ projectPath,
92
+ "cat-file",
93
+ "-t",
94
+ `${candidate}:${rel}`
95
+ ], {
96
+ encoding: "utf-8",
97
+ stdio: [
98
+ "ignore",
99
+ "pipe",
100
+ "ignore"
101
+ ]
102
+ }).trim();
103
+ } catch {}
104
+ return null;
105
+ };
106
+ return {
107
+ pathExists: (path) => {
108
+ const rel = toRelative(path);
109
+ if (rel === null) return existsSync(path);
110
+ return objectType(rel) !== null;
111
+ },
112
+ isDirectory: (path) => {
113
+ const rel = toRelative(path);
114
+ if (rel === null) try {
115
+ return statSync(path).isDirectory();
116
+ } catch {
117
+ return false;
118
+ }
119
+ return objectType(rel) === "tree";
120
+ },
121
+ readFile: (path) => {
122
+ if (toRelative(path) === null) return readFileSync(path, "utf-8");
123
+ return gitReader.read(path);
124
+ }
125
+ };
126
+ }
127
+ /**
128
+ * Find the first existing instruction file at a given base path.
129
+ * Prefers AGENTS.md over CLAUDE.md.
130
+ */
131
+ function findInstructionFile(basePath, reader = fsInstructionReader) {
132
+ for (const filename of INSTRUCTION_FILES) {
133
+ const fullPath = join(basePath, filename);
134
+ if (reader.exists(fullPath)) return fullPath;
135
+ }
136
+ return null;
137
+ }
138
+ /**
139
+ * Load all agent instruction files from global and project locations.
140
+ * Returns an array of instruction sources, with global ones first.
141
+ *
142
+ * `projectReader` controls where project-scope content comes from (defaults to
143
+ * the working tree). Global instructions read the operator machine's
144
+ * filesystem, unless `skipGlobal` keeps them out entirely.
145
+ */
146
+ function loadAgentInstructions(projectPath, configDirName = DEFAULT_CONFIG_DIR, projectReader = fsInstructionReader, { skipGlobal = false } = {}) {
147
+ const sources = [];
148
+ const home = homedir();
149
+ const projectLocations = PROJECT_LOCATIONS.map((loc) => loc === ".mastracode" ? configDirName : loc);
150
+ const globalLocations = skipGlobal ? [] : GLOBAL_LOCATIONS.map((loc) => {
151
+ if (loc === ".mastracode") return configDirName;
152
+ if (loc === ".config/mastracode") return ".config/" + configDirName.replace(/^\./, "");
153
+ return loc;
154
+ });
155
+ for (const location of globalLocations) {
156
+ const filePath = findInstructionFile(join(home, location));
157
+ if (filePath) try {
158
+ const content = readFileSync(filePath, "utf-8").trim();
159
+ if (content) {
160
+ sources.push({
161
+ path: filePath,
162
+ content,
163
+ scope: "global"
164
+ });
165
+ break;
166
+ }
167
+ } catch {}
168
+ }
169
+ for (const location of projectLocations) {
170
+ const filePath = findInstructionFile(location ? join(projectPath, location) : projectPath, projectReader);
171
+ if (filePath) try {
172
+ const content = projectReader.read(filePath).trim();
173
+ if (content) {
174
+ sources.push({
175
+ path: filePath,
176
+ content,
177
+ scope: "project",
178
+ ...projectReader.ref ? { ref: projectReader.ref } : {}
179
+ });
180
+ break;
181
+ }
182
+ } catch {}
183
+ }
184
+ return sources;
185
+ }
186
+ function getStaticallyLoadedInstructionPaths(projectPath, configDirName = DEFAULT_CONFIG_DIR, projectReader) {
187
+ return loadAgentInstructions(projectPath, configDirName, projectReader).map((source) => normalize(source.path));
188
+ }
189
+ /**
190
+ * Format loaded instructions into a string for the system prompt.
191
+ */
192
+ function formatAgentInstructions(sources) {
193
+ if (sources.length === 0) return "";
194
+ return `\n# Agent Instructions\n\n${sources.map((source) => {
195
+ return `<!-- ${source.scope === "global" ? "Global" : "Project"} instructions from ${source.ref ? `${source.path} (at ref ${source.ref})` : source.path} -->\n${source.content}`;
196
+ }).join("\n\n")}\n`;
197
+ }
198
+ //#endregion
199
+ export { createGitRefInstructionReader, createGitRefReminderReader, formatAgentInstructions, getStaticallyLoadedInstructionPaths, loadAgentInstructions };
200
+
201
+ //# sourceMappingURL=agent-instructions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"agent-instructions.js","names":[],"sources":["../../../src/agents/prompts/agent-instructions.ts"],"sourcesContent":["/**\n * Load project and global agent instruction files (AGENTS.md, CLAUDE.md).\n * Prefers AGENTS.md over CLAUDE.md when multiple exist at the same location.\n */\n\nimport { execFileSync } from 'node:child_process';\nimport { existsSync, readFileSync, statSync } from 'node:fs';\nimport { homedir } from 'node:os';\nimport { isAbsolute, join, normalize, relative, sep } from 'node:path';\nimport { DEFAULT_CONFIG_DIR } from '../../constants.js';\n\n// Filenames to check, in order of preference\nconst INSTRUCTION_FILES = ['AGENTS.md', 'CLAUDE.md'];\n\n// Locations to scan (relative to project root or home)\nconst PROJECT_LOCATIONS = [\n '', // project root\n '.claude',\n '.mastracode',\n];\n\nconst GLOBAL_LOCATIONS = ['.claude', '.mastracode', '.config/claude', '.config/mastracode'];\n\nexport interface InstructionSource {\n path: string;\n content: string;\n scope: 'global' | 'project';\n /** Git ref the content was read from, when not read off the working tree. */\n ref?: string;\n}\n\n/**\n * Reads project-scope instruction files. The default implementation reads the\n * working tree via `fs`; alternative readers can serve content from another\n * source (e.g. a trusted git ref) while keeping working-tree paths as the\n * addressing scheme.\n */\nexport interface InstructionFileReader {\n exists(path: string): boolean;\n read(path: string): string;\n /** Git ref backing this reader, recorded on the loaded sources. */\n ref?: string;\n}\n\nconst fsInstructionReader: InstructionFileReader = {\n exists: path => existsSync(path),\n read: path => readFileSync(path, 'utf-8'),\n};\n\n/**\n * Create a reader that serves instruction files from a git ref instead of the\n * working tree. Paths are still addressed as working-tree paths under\n * `projectPath`; content comes from `git show <ref>:<relpath>` so an untrusted\n * checkout (e.g. a PR branch under review) cannot influence what is loaded.\n * Tries `origin/<ref>` first (remote truth), then the local ref. Any git\n * failure (missing ref, missing file, no repo) reports the file as absent.\n */\nexport function createGitRefInstructionReader(projectPath: string, ref: string): InstructionFileReader {\n const toRelative = (path: string): string | null => {\n const rel = relative(projectPath, path);\n if (!rel || rel.startsWith('..') || isAbsolute(rel)) return null;\n return rel.split(sep).join('/');\n };\n const show = (path: string): string | null => {\n const rel = toRelative(path);\n if (rel === null) return null;\n for (const candidate of [`origin/${ref}`, ref]) {\n try {\n return execFileSync('git', ['-C', projectPath, 'show', `${candidate}:${rel}`], {\n encoding: 'utf-8',\n stdio: ['ignore', 'pipe', 'ignore'],\n maxBuffer: 1024 * 1024,\n });\n } catch {\n // Ref or file missing at this candidate — try the next one.\n }\n }\n return null;\n };\n return {\n ref,\n exists: path => show(path) !== null,\n read: path => {\n const content = show(path);\n if (content === null) throw new Error(`Not found at ref ${ref}: ${path}`);\n return content;\n },\n };\n}\n\n/**\n * Reader for the reactive reminder channel (AgentsMDInjector) that serves\n * paths under `projectPath` from a trusted git ref. Paths outside the project\n * fall back to the operator machine's filesystem (those are trusted); paths\n * inside the project are only ever resolved against the ref, never the\n * working tree, so an untrusted checkout cannot feed content in.\n */\nexport function createGitRefReminderReader(\n projectPath: string,\n ref: string,\n): {\n pathExists: (path: string) => boolean;\n isDirectory: (path: string) => boolean;\n readFile: (path: string) => string;\n} {\n const gitReader = createGitRefInstructionReader(projectPath, ref);\n const toRelative = (path: string): string | null => {\n const rel = relative(projectPath, normalize(path));\n if (rel.startsWith('..') || isAbsolute(rel)) return null;\n return rel.split(sep).join('/');\n };\n const objectType = (rel: string): string | null => {\n if (rel === '') return 'tree'; // project root\n for (const candidate of [`origin/${ref}`, ref]) {\n try {\n return execFileSync('git', ['-C', projectPath, 'cat-file', '-t', `${candidate}:${rel}`], {\n encoding: 'utf-8',\n stdio: ['ignore', 'pipe', 'ignore'],\n }).trim();\n } catch {\n // Ref or object missing at this candidate — try the next one.\n }\n }\n return null;\n };\n return {\n pathExists: path => {\n const rel = toRelative(path);\n if (rel === null) return existsSync(path);\n return objectType(rel) !== null;\n },\n isDirectory: path => {\n const rel = toRelative(path);\n if (rel === null) {\n try {\n return statSync(path).isDirectory();\n } catch {\n return false;\n }\n }\n return objectType(rel) === 'tree';\n },\n readFile: path => {\n const rel = toRelative(path);\n if (rel === null) return readFileSync(path, 'utf-8');\n return gitReader.read(path);\n },\n };\n}\n\n/**\n * Find the first existing instruction file at a given base path.\n * Prefers AGENTS.md over CLAUDE.md.\n */\nfunction findInstructionFile(basePath: string, reader: InstructionFileReader = fsInstructionReader): string | null {\n for (const filename of INSTRUCTION_FILES) {\n const fullPath = join(basePath, filename);\n if (reader.exists(fullPath)) {\n return fullPath;\n }\n }\n return null;\n}\n\n/**\n * Load all agent instruction files from global and project locations.\n * Returns an array of instruction sources, with global ones first.\n *\n * `projectReader` controls where project-scope content comes from (defaults to\n * the working tree). Global instructions read the operator machine's\n * filesystem, unless `skipGlobal` keeps them out entirely.\n */\nexport function loadAgentInstructions(\n projectPath: string,\n configDirName = DEFAULT_CONFIG_DIR,\n projectReader: InstructionFileReader = fsInstructionReader,\n { skipGlobal = false }: { skipGlobal?: boolean } = {},\n): InstructionSource[] {\n const sources: InstructionSource[] = [];\n const home = homedir();\n\n // Derive location arrays from the base constants, substituting the config dir name\n const projectLocations = PROJECT_LOCATIONS.map(loc => (loc === '.mastracode' ? configDirName : loc));\n const globalLocations = skipGlobal\n ? []\n : GLOBAL_LOCATIONS.map(loc => {\n if (loc === '.mastracode') return configDirName;\n // XDG-style path (~/.config/<name>): strip the leading dot since the\n // .config/ prefix already signals a hidden/config directory.\n if (loc === '.config/mastracode') return '.config/' + configDirName.replace(/^\\./, '');\n return loc;\n });\n\n // Load global instructions first\n for (const location of globalLocations) {\n const basePath = join(home, location);\n const filePath = findInstructionFile(basePath);\n if (filePath) {\n try {\n const content = readFileSync(filePath, 'utf-8').trim();\n if (content) {\n sources.push({ path: filePath, content, scope: 'global' });\n break; // Only use first found global instruction file\n }\n } catch {\n // Skip unreadable files\n }\n }\n }\n\n // Load project instructions\n for (const location of projectLocations) {\n const basePath = location ? join(projectPath, location) : projectPath;\n const filePath = findInstructionFile(basePath, projectReader);\n if (filePath) {\n try {\n const content = projectReader.read(filePath).trim();\n if (content) {\n sources.push({\n path: filePath,\n content,\n scope: 'project',\n ...(projectReader.ref ? { ref: projectReader.ref } : {}),\n });\n break; // Only use first found project instruction file\n }\n } catch {\n // Skip unreadable files\n }\n }\n }\n\n return sources;\n}\n\nexport function getStaticallyLoadedInstructionPaths(\n projectPath: string,\n configDirName = DEFAULT_CONFIG_DIR,\n projectReader?: InstructionFileReader,\n): string[] {\n return loadAgentInstructions(projectPath, configDirName, projectReader).map(source => normalize(source.path));\n}\n\n/**\n * Format loaded instructions into a string for the system prompt.\n */\nexport function formatAgentInstructions(sources: InstructionSource[]): string {\n if (sources.length === 0) return '';\n\n const sections = sources.map(source => {\n const label = source.scope === 'global' ? 'Global' : 'Project';\n const origin = source.ref ? `${source.path} (at ref ${source.ref})` : source.path;\n return `<!-- ${label} instructions from ${origin} -->\\n${source.content}`;\n });\n\n return `\\n# Agent Instructions\\n\\n${sections.join('\\n\\n')}\\n`;\n}\n"],"mappings":"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"}
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Build mode prompt — full tool access, make changes and verify.
3
+ */
4
+ import type { PromptContext } from './index.js';
5
+ /**
6
+ * Dynamic build mode prompt function.
7
+ * When an approved plan exists in state, prepends it so the agent
8
+ * knows exactly what to implement.
9
+ */
10
+ export declare function buildModePromptFn(ctx: PromptContext): string;
11
+ export declare const buildModePrompt = "\n# Build Mode\n\nYou are in BUILD mode. You have full access to all tools and can read, write, edit, and execute commands.\n\n## Working Style\n\n**For simple tasks** (typo fixes, small edits, single-file changes):\n- Just do it. No need to explain your plan first.\n\n**For non-trivial tasks** (3+ files, architectural decisions, unclear requirements):\n- Use the available task-management tools to create and update your task list\n- Work on ONE step at a time \u2014 complete it and verify it works before moving on\n- If multiple approaches are plausible and the choice would materially affect scope, behavior, or risk, stop and ask the user\n\n## The Implementation Loop\n\nFor each change you make:\n\n1. **Understand** \u2014 Read the relevant code. Check how similar things are done elsewhere.\n2. **Implement** \u2014 Make the change. Follow existing patterns and conventions.\n3. **Verify** \u2014 Test that it works. Don't assume \u2014 actually run it.\n4. **Prove** \u2014 Proactively prove that the change is good, makes sense in context, is a positive contribution, and works fully. The burden of proof is on YOU.\n5. **Clean up** \u2014 Ensure no broken code, no debug statements, no half-done features.\n\nOnly move to the next change after the current one is verified and proved to be working.\n\n## Verification is Required\n\nBefore considering any task complete:\n- Run relevant tests (check package.json for test scripts)\n- For TypeScript, run `tsc --noEmit` to catch type errors\n- If there are no automated tests, manually verify the behavior works as expected\n- Confirm the result makes sense in the codebase and improves the requested behavior\n- Use available task-checking tools to ensure all tracked tasks are done\n\n**Don't mark something as done until you've verified and proved it actually works.**\n\n## Error Recovery\n\nWhen something breaks:\n1. Read the full error output carefully \u2014 don't guess\n2. Find the root cause, not just the symptom\n3. Fix it properly \u2014 no casts or suppressions to hide errors\n4. Re-run to confirm the fix\n5. If progress is blocked after reasonable attempts, briefly explain the blocker, what you've tried, and the next best option\n\n## Git in Build Mode\n\n- Before committing, verify the code compiles and passes lint\n- Use descriptive branch names: `feat/...`, `fix/...`, `refactor/...`\n";
12
+ //# sourceMappingURL=build.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"build.d.ts","sourceRoot":"","sources":["../../../src/agents/prompts/build.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAEhD;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,aAAa,GAAG,MAAM,CAiB5D;AAED,eAAO,MAAM,eAAe,00EAmD3B,CAAC"}
@@ -0,0 +1,76 @@
1
+ //#region src/agents/prompts/build.ts
2
+ /**
3
+ * Dynamic build mode prompt function.
4
+ * When an approved plan exists in state, prepends it so the agent
5
+ * knows exactly what to implement.
6
+ */
7
+ function buildModePromptFn(ctx) {
8
+ if (ctx.activePlan) return `# Approved Plan
9
+
10
+ **${ctx.activePlan.title}**
11
+
12
+ ${ctx.activePlan.plan}
13
+
14
+ ---
15
+
16
+ Implement the approved plan above. Follow the steps in order and verify each step works before moving on.
17
+
18
+ ` + buildModePrompt;
19
+ return buildModePrompt;
20
+ }
21
+ const buildModePrompt = `
22
+ # Build Mode
23
+
24
+ You are in BUILD mode. You have full access to all tools and can read, write, edit, and execute commands.
25
+
26
+ ## Working Style
27
+
28
+ **For simple tasks** (typo fixes, small edits, single-file changes):
29
+ - Just do it. No need to explain your plan first.
30
+
31
+ **For non-trivial tasks** (3+ files, architectural decisions, unclear requirements):
32
+ - Use the available task-management tools to create and update your task list
33
+ - Work on ONE step at a time — complete it and verify it works before moving on
34
+ - If multiple approaches are plausible and the choice would materially affect scope, behavior, or risk, stop and ask the user
35
+
36
+ ## The Implementation Loop
37
+
38
+ For each change you make:
39
+
40
+ 1. **Understand** — Read the relevant code. Check how similar things are done elsewhere.
41
+ 2. **Implement** — Make the change. Follow existing patterns and conventions.
42
+ 3. **Verify** — Test that it works. Don't assume — actually run it.
43
+ 4. **Prove** — Proactively prove that the change is good, makes sense in context, is a positive contribution, and works fully. The burden of proof is on YOU.
44
+ 5. **Clean up** — Ensure no broken code, no debug statements, no half-done features.
45
+
46
+ Only move to the next change after the current one is verified and proved to be working.
47
+
48
+ ## Verification is Required
49
+
50
+ Before considering any task complete:
51
+ - Run relevant tests (check package.json for test scripts)
52
+ - For TypeScript, run \`tsc --noEmit\` to catch type errors
53
+ - If there are no automated tests, manually verify the behavior works as expected
54
+ - Confirm the result makes sense in the codebase and improves the requested behavior
55
+ - Use available task-checking tools to ensure all tracked tasks are done
56
+
57
+ **Don't mark something as done until you've verified and proved it actually works.**
58
+
59
+ ## Error Recovery
60
+
61
+ When something breaks:
62
+ 1. Read the full error output carefully — don't guess
63
+ 2. Find the root cause, not just the symptom
64
+ 3. Fix it properly — no casts or suppressions to hide errors
65
+ 4. Re-run to confirm the fix
66
+ 5. If progress is blocked after reasonable attempts, briefly explain the blocker, what you've tried, and the next best option
67
+
68
+ ## Git in Build Mode
69
+
70
+ - Before committing, verify the code compiles and passes lint
71
+ - Use descriptive branch names: \`feat/...\`, \`fix/...\`, \`refactor/...\`
72
+ `;
73
+ //#endregion
74
+ export { buildModePrompt, buildModePromptFn };
75
+
76
+ //# sourceMappingURL=build.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"build.js","names":[],"sources":["../../../src/agents/prompts/build.ts"],"sourcesContent":["/**\n * Build mode prompt — full tool access, make changes and verify.\n */\n\nimport type { PromptContext } from './index.js';\n\n/**\n * Dynamic build mode prompt function.\n * When an approved plan exists in state, prepends it so the agent\n * knows exactly what to implement.\n */\nexport function buildModePromptFn(ctx: PromptContext): string {\n if (ctx.activePlan) {\n return (\n `# Approved Plan\n\n**${ctx.activePlan.title}**\n\n${ctx.activePlan.plan}\n\n---\n\nImplement the approved plan above. Follow the steps in order and verify each step works before moving on.\n\n` + buildModePrompt\n );\n }\n return buildModePrompt;\n}\n\nexport const buildModePrompt = `\n# Build Mode\n\nYou are in BUILD mode. You have full access to all tools and can read, write, edit, and execute commands.\n\n## Working Style\n\n**For simple tasks** (typo fixes, small edits, single-file changes):\n- Just do it. No need to explain your plan first.\n\n**For non-trivial tasks** (3+ files, architectural decisions, unclear requirements):\n- Use the available task-management tools to create and update your task list\n- Work on ONE step at a time — complete it and verify it works before moving on\n- If multiple approaches are plausible and the choice would materially affect scope, behavior, or risk, stop and ask the user\n\n## The Implementation Loop\n\nFor each change you make:\n\n1. **Understand** — Read the relevant code. Check how similar things are done elsewhere.\n2. **Implement** — Make the change. Follow existing patterns and conventions.\n3. **Verify** — Test that it works. Don't assume — actually run it.\n4. **Prove** — Proactively prove that the change is good, makes sense in context, is a positive contribution, and works fully. The burden of proof is on YOU.\n5. **Clean up** — Ensure no broken code, no debug statements, no half-done features.\n\nOnly move to the next change after the current one is verified and proved to be working.\n\n## Verification is Required\n\nBefore considering any task complete:\n- Run relevant tests (check package.json for test scripts)\n- For TypeScript, run \\`tsc --noEmit\\` to catch type errors\n- If there are no automated tests, manually verify the behavior works as expected\n- Confirm the result makes sense in the codebase and improves the requested behavior\n- Use available task-checking tools to ensure all tracked tasks are done\n\n**Don't mark something as done until you've verified and proved it actually works.**\n\n## Error Recovery\n\nWhen something breaks:\n1. Read the full error output carefully — don't guess\n2. Find the root cause, not just the symptom\n3. Fix it properly — no casts or suppressions to hide errors\n4. Re-run to confirm the fix\n5. If progress is blocked after reasonable attempts, briefly explain the blocker, what you've tried, and the next best option\n\n## Git in Build Mode\n\n- Before committing, verify the code compiles and passes lint\n- Use descriptive branch names: \\`feat/...\\`, \\`fix/...\\`, \\`refactor/...\\`\n`;\n"],"mappings":";;;;;;AAWA,SAAgB,kBAAkB,KAA4B;CAC5D,IAAI,IAAI,YACN,OACE;;IAEF,IAAI,WAAW,MAAM;;EAEvB,IAAI,WAAW,KAAK;;;;;;IAMlB;CAGF,OAAO;AACT;AAEA,MAAa,kBAAkB"}
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Fast mode prompt — quick answers and small edits, minimal overhead.
3
+ */
4
+ export declare const fastModePrompt = "\n# Fast Mode\n\nYou are in FAST mode. Optimize for speed and brevity.\n\n## Rules\n- Keep responses short. Under 200 words unless the task genuinely requires more.\n- Skip planning. Just do the task directly.\n- For questions: give the direct answer, not a tutorial.\n- For edits: make the change, show what you did, move on.\n- Don't explore the codebase more than necessary for the immediate task.\n\n## When to Use Tools vs. Just Answer\n- If the user asks a general programming question, answer directly from knowledge. Don't search the codebase.\n- If the user asks about THIS project's code, use tools to look it up \u2014 don't guess.\n- If the user asks for a quick edit and you know the file, read it and edit it. Don't ask for confirmation.\n- One tool call to read + one to edit is ideal. Minimize round trips.\n";
5
+ //# sourceMappingURL=fast.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fast.d.ts","sourceRoot":"","sources":["../../../src/agents/prompts/fast.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,eAAO,MAAM,cAAc,6zBAiB1B,CAAC"}
@@ -0,0 +1,26 @@
1
+ //#region src/agents/prompts/fast.ts
2
+ /**
3
+ * Fast mode prompt — quick answers and small edits, minimal overhead.
4
+ */
5
+ const fastModePrompt = `
6
+ # Fast Mode
7
+
8
+ You are in FAST mode. Optimize for speed and brevity.
9
+
10
+ ## Rules
11
+ - Keep responses short. Under 200 words unless the task genuinely requires more.
12
+ - Skip planning. Just do the task directly.
13
+ - For questions: give the direct answer, not a tutorial.
14
+ - For edits: make the change, show what you did, move on.
15
+ - Don't explore the codebase more than necessary for the immediate task.
16
+
17
+ ## When to Use Tools vs. Just Answer
18
+ - If the user asks a general programming question, answer directly from knowledge. Don't search the codebase.
19
+ - If the user asks about THIS project's code, use tools to look it up — don't guess.
20
+ - If the user asks for a quick edit and you know the file, read it and edit it. Don't ask for confirmation.
21
+ - One tool call to read + one to edit is ideal. Minimize round trips.
22
+ `;
23
+ //#endregion
24
+ export { fastModePrompt };
25
+
26
+ //# sourceMappingURL=fast.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fast.js","names":[],"sources":["../../../src/agents/prompts/fast.ts"],"sourcesContent":["/**\n * Fast mode prompt — quick answers and small edits, minimal overhead.\n */\n\nexport const fastModePrompt = `\n# Fast Mode\n\nYou are in FAST mode. Optimize for speed and brevity.\n\n## Rules\n- Keep responses short. Under 200 words unless the task genuinely requires more.\n- Skip planning. Just do the task directly.\n- For questions: give the direct answer, not a tutorial.\n- For edits: make the change, show what you did, move on.\n- Don't explore the codebase more than necessary for the immediate task.\n\n## When to Use Tools vs. Just Answer\n- If the user asks a general programming question, answer directly from knowledge. Don't search the codebase.\n- If the user asks about THIS project's code, use tools to look it up — don't guess.\n- If the user asks for a quick edit and you know the file, read it and edit it. Don't ask for confirmation.\n- One tool call to read + one to edit is ideal. Minimize round trips.\n`;\n"],"mappings":";;;;AAIA,MAAa,iBAAiB"}
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Prompt system — exports the prompt builder and mode-specific prompts.
3
+ */
4
+ export { buildModePrompt, buildModePromptFn } from './build.js';
5
+ export { planModePrompt } from './plan.js';
6
+ export { fastModePrompt } from './fast.js';
7
+ import type { PromptContext as BasePromptContext } from '@mastra/core/coding-agent';
8
+ export interface PromptContext extends Omit<BasePromptContext, 'toolGuidance'> {
9
+ modeId: string;
10
+ state?: any;
11
+ currentDate: string;
12
+ workingDir: string;
13
+ }
14
+ /**
15
+ * Build the full system prompt for a given mode and context.
16
+ * Combines the base prompt with mode-specific instructions.
17
+ */
18
+ export declare function buildFullPrompt(ctx: PromptContext): string;
19
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/agents/prompts/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,eAAe,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAChE,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAC3C,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAG3C,OAAO,KAAK,EAAE,aAAa,IAAI,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAUpF,MAAM,WAAW,aAAc,SAAQ,IAAI,CAAC,iBAAiB,EAAE,cAAc,CAAC;IAC5E,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,GAAG,CAAC;IACZ,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,MAAM,CAAC;CACpB;AAQD;;;GAGG;AACH,wBAAgB,eAAe,CAAC,GAAG,EAAE,aAAa,GAAG,MAAM,CAqE1D"}
@@ -0,0 +1,65 @@
1
+ import { buildModePrompt, buildModePromptFn } from "./build.js";
2
+ import { planModePrompt } from "./plan.js";
3
+ import { fastModePrompt } from "./fast.js";
4
+ import { hasTavilyKey } from "../../tools/web-search.js";
5
+ import "../../tools/index.js";
6
+ import { createGitRefInstructionReader, formatAgentInstructions, loadAgentInstructions } from "./agent-instructions.js";
7
+ import { modelSpecificPrompts } from "./model.js";
8
+ import { buildToolGuidance } from "./tool-guidance.js";
9
+ import { buildBasePrompt } from "@mastra/core/coding-agent";
10
+ //#region src/agents/prompts/index.ts
11
+ const modePrompts = {
12
+ build: buildModePromptFn,
13
+ plan: planModePrompt,
14
+ fast: fastModePrompt
15
+ };
16
+ /**
17
+ * Build the full system prompt for a given mode and context.
18
+ * Combines the base prompt with mode-specific instructions.
19
+ */
20
+ function buildFullPrompt(ctx) {
21
+ const modelId = ctx.modelId;
22
+ const hasWebSearch = hasTavilyKey() || !!modelId && modelId.startsWith("anthropic/");
23
+ const deniedTools = /* @__PURE__ */ new Set();
24
+ const permRules = ctx.state?.permissionRules;
25
+ if (permRules?.tools) {
26
+ for (const [name, policy] of Object.entries(permRules.tools)) if (policy === "deny") deniedTools.add(name);
27
+ }
28
+ const toolGuidance = buildToolGuidance(ctx.modeId, {
29
+ hasWebSearch,
30
+ deniedTools
31
+ });
32
+ const base = buildBasePrompt({
33
+ projectPath: ctx.workingDir,
34
+ projectName: ctx.projectName || "unknown",
35
+ gitBranch: ctx.gitBranch,
36
+ platform: process.platform,
37
+ commonBinaries: ctx.commonBinaries,
38
+ date: ctx.currentDate,
39
+ mode: ctx.modeId,
40
+ modelId: ctx.modelId,
41
+ activePlan: ctx.state?.activePlan,
42
+ toolGuidance
43
+ });
44
+ const entry = modePrompts[ctx.modeId] || modePrompts.build;
45
+ const modeSpecific = (typeof entry === "function" ? entry(ctx) : entry) ?? "";
46
+ const modelSpecific = ctx.modelId ? modelSpecificPrompts[ctx.modelId] ?? "" : "";
47
+ const configDir = ctx.state?.configDir;
48
+ const untrustedCheckout = ctx.state?.untrustedCheckout === true;
49
+ const skipGlobalInstructions = ctx.state?.skipGlobalInstructions === true;
50
+ const baseRef = typeof ctx.state?.baseRef === "string" ? ctx.state.baseRef : void 0;
51
+ const projectReader = untrustedCheckout ? baseRef ? createGitRefInstructionReader(ctx.workingDir, baseRef) : {
52
+ exists: () => false,
53
+ read: () => ""
54
+ } : void 0;
55
+ return [
56
+ base,
57
+ formatAgentInstructions(loadAgentInstructions(ctx.workingDir, configDir, projectReader, { skipGlobal: skipGlobalInstructions })).trim(),
58
+ modelSpecific.trim(),
59
+ modeSpecific.trim()
60
+ ].filter(Boolean).join("\n\n");
61
+ }
62
+ //#endregion
63
+ export { buildFullPrompt, buildModePrompt, buildModePromptFn, fastModePrompt, planModePrompt };
64
+
65
+ //# 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 { hasTavilyKey } from '../../tools/index.js';\nimport { loadAgentInstructions, formatAgentInstructions, createGitRefInstructionReader } 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 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 * 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 // Determine whether web search tools are available\n const modelId = ctx.modelId;\n const hasWebSearch = hasTavilyKey() || (!!modelId && modelId.startsWith('anthropic/'));\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 // Build mode-aware tool guidance\n const toolGuidance = buildToolGuidance(ctx.modeId, { hasWebSearch, deniedTools });\n\n // Map new context to base context\n const baseCtx: BasePromptContext = {\n projectPath: ctx.workingDir,\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 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 const instructionSources = loadAgentInstructions(ctx.workingDir, configDir, projectReader, {\n skipGlobal: skipGlobalInstructions,\n });\n const instructionsSection = formatAgentInstructions(instructionSources);\n\n const sections = [base, instructionsSection.trim(), modelSpecific.trim(), modeSpecific.trim()].filter(Boolean);\n\n return sections.join('\\n\\n');\n}\n"],"mappings":";;;;;;;;;;AA0BA,MAAM,cAAyE;CAC7E,OAAO;CACP,MAAM;CACN,MAAM;AACR;;;;;AAMA,SAAgB,gBAAgB,KAA4B;CAE1D,MAAM,UAAU,IAAI;CACpB,MAAM,eAAe,aAAa,KAAM,CAAC,CAAC,WAAW,QAAQ,WAAW,YAAY;CAGpF,MAAM,8BAAc,IAAI,IAAY;CACpC,MAAM,YAAY,IAAI,OAAO;CAC7B,IAAI,WAAW,OACR;OAAA,MAAM,CAAC,MAAM,WAAW,OAAO,QAAQ,UAAU,KAAK,GACzD,IAAI,WAAW,QAAQ,YAAY,IAAI,IAAI;CAAA;CAK/C,MAAM,eAAe,kBAAkB,IAAI,QAAQ;EAAE;EAAc;CAAY,CAAC;CAgBhF,MAAM,OAAO,gBAAgB;EAZ3B,aAAa,IAAI;EACjB,aAAa,IAAI,eAAe;EAChC,WAAW,IAAI;EACf,UAAU,QAAQ;EAClB,gBAAgB,IAAI;EACpB,MAAM,IAAI;EACV,MAAM,IAAI;EACV,SAAS,IAAI;EACb,YAAY,IAAI,OAAO;EACvB;CAGiC,CAAC;CACpC,MAAM,QAAQ,YAAY,IAAI,WAAW,YAAY;CACrD,MAAM,gBAAgB,OAAO,UAAU,aAAa,MAAM,GAAG,IAAI,UAAU;CAC3E,MAAM,gBAAgB,IAAI,UACrB,qBAAqB,IAAI,YAAiD,KAC3E;CAgBJ,MAAM,YAAY,IAAI,OAAO;CAC7B,MAAM,oBAAoB,IAAI,OAAO,sBAAsB;CAC3D,MAAM,yBAAyB,IAAI,OAAO,2BAA2B;CACrE,MAAM,UAAU,OAAO,IAAI,OAAO,YAAY,WAAW,IAAI,MAAM,UAAU,KAAA;CAC7E,MAAM,gBAAgB,oBAClB,UACE,8BAA8B,IAAI,YAAY,OAAO,IACrD;EAAE,cAAc;EAAO,YAAY;CAAG,IACxC,KAAA;CAQJ,OAFiB;EAAC;EAFU,wBAHD,sBAAsB,IAAI,YAAY,WAAW,eAAe,EACzF,YAAY,uBACd,CACqE,CAE3B,CAAC,CAAC,KAAK;EAAG,cAAc,KAAK;EAAG,aAAa,KAAK;CAAC,CAAC,CAAC,OAAO,OAExF,CAAC,CAAC,KAAK,MAAM;AAC7B"}
@@ -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,IAAI,EAAE,iBAAiB,GAAG,MAAM,CAsG9D"}