@mastra/code-sdk 1.0.3-alpha.0 → 1.1.0-alpha.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (258) hide show
  1. package/CHANGELOG.md +49 -0
  2. package/dist/acp/agent.js +155 -167
  3. package/dist/acp/agent.js.map +1 -1
  4. package/dist/acp/event-mapper.js +193 -168
  5. package/dist/acp/event-mapper.js.map +1 -1
  6. package/dist/acp/index.js +60 -49
  7. package/dist/acp/index.js.map +1 -1
  8. package/dist/acp/server.js +31 -30
  9. package/dist/acp/server.js.map +1 -1
  10. package/dist/acp.js +1 -4
  11. package/dist/agents/credential-resolver.js +40 -29
  12. package/dist/agents/credential-resolver.js.map +1 -1
  13. package/dist/agents/custom-provider-source.js +16 -9
  14. package/dist/agents/custom-provider-source.js.map +1 -1
  15. package/dist/agents/instructions.js +27 -36
  16. package/dist/agents/instructions.js.map +1 -1
  17. package/dist/agents/mastracode-gateway.js +355 -428
  18. package/dist/agents/mastracode-gateway.js.map +1 -1
  19. package/dist/agents/memory.js +87 -78
  20. package/dist/agents/memory.js.map +1 -1
  21. package/dist/agents/model.js +114 -119
  22. package/dist/agents/model.js.map +1 -1
  23. package/dist/agents/modes/build.js +12 -13
  24. package/dist/agents/modes/build.js.map +1 -1
  25. package/dist/agents/modes/explore.js +14 -13
  26. package/dist/agents/modes/explore.js.map +1 -1
  27. package/dist/agents/modes/plan.js +14 -15
  28. package/dist/agents/modes/plan.js.map +1 -1
  29. package/dist/agents/prompts/agent-instructions.js +78 -69
  30. package/dist/agents/prompts/agent-instructions.js.map +1 -1
  31. package/dist/agents/prompts/build.js +19 -16
  32. package/dist/agents/prompts/build.js.map +1 -1
  33. package/dist/agents/prompts/fast.js +8 -4
  34. package/dist/agents/prompts/fast.js.map +1 -1
  35. package/dist/agents/prompts/index.js +48 -47
  36. package/dist/agents/prompts/index.js.map +1 -1
  37. package/dist/agents/prompts/model.js +6 -5
  38. package/dist/agents/prompts/model.js.map +1 -1
  39. package/dist/agents/prompts/plan.js +20 -16
  40. package/dist/agents/prompts/plan.js.map +1 -1
  41. package/dist/agents/prompts/tool-guidance.js +77 -109
  42. package/dist/agents/prompts/tool-guidance.js.map +1 -1
  43. package/dist/agents/sandbox-filesystem.js +245 -259
  44. package/dist/agents/sandbox-filesystem.js.map +1 -1
  45. package/dist/agents/sandbox-reattach.js +9 -11
  46. package/dist/agents/sandbox-reattach.js.map +1 -1
  47. package/dist/agents/thread-caveman-state.js +92 -81
  48. package/dist/agents/thread-caveman-state.js.map +1 -1
  49. package/dist/agents/tool-availability.js +62 -80
  50. package/dist/agents/tool-availability.js.map +1 -1
  51. package/dist/agents/tools.js +99 -139
  52. package/dist/agents/tools.js.map +1 -1
  53. package/dist/agents/workspace.js +232 -225
  54. package/dist/agents/workspace.js.map +1 -1
  55. package/dist/analytics.js +139 -128
  56. package/dist/analytics.js.map +1 -1
  57. package/dist/auth/authorization-input.js +39 -25
  58. package/dist/auth/authorization-input.js.map +1 -1
  59. package/dist/auth/device-code.js +112 -80
  60. package/dist/auth/device-code.js.map +1 -1
  61. package/dist/auth/index.js +2 -9
  62. package/dist/auth/pkce.js +27 -16
  63. package/dist/auth/pkce.js.map +1 -1
  64. package/dist/auth/providers/anthropic.js +107 -93
  65. package/dist/auth/providers/anthropic.js.map +1 -1
  66. package/dist/auth/providers/github-copilot.js +304 -293
  67. package/dist/auth/providers/github-copilot.js.map +1 -1
  68. package/dist/auth/providers/openai-codex.js +442 -460
  69. package/dist/auth/providers/openai-codex.js.map +1 -1
  70. package/dist/auth/providers/xai.js +179 -145
  71. package/dist/auth/providers/xai.js.map +1 -1
  72. package/dist/auth/storage.js +182 -175
  73. package/dist/auth/storage.js.map +1 -1
  74. package/dist/auth/types.js +1 -1
  75. package/dist/clipboard/index.js +206 -172
  76. package/dist/clipboard/index.js.map +1 -1
  77. package/dist/constants.js +11 -16
  78. package/dist/constants.js.map +1 -1
  79. package/dist/error-classification.js +19 -11
  80. package/dist/error-classification.js.map +1 -1
  81. package/dist/evals/context-builder.js +145 -104
  82. package/dist/evals/context-builder.js.map +1 -1
  83. package/dist/evals/index.js +4 -7
  84. package/dist/evals/scorers/classify-command.js +62 -41
  85. package/dist/evals/scorers/classify-command.js.map +1 -1
  86. package/dist/evals/scorers/efficiency.js +239 -181
  87. package/dist/evals/scorers/efficiency.js.map +1 -1
  88. package/dist/evals/scorers/extract-tools.js +51 -47
  89. package/dist/evals/scorers/extract-tools.js.map +1 -1
  90. package/dist/evals/scorers/index.js +1 -5
  91. package/dist/evals/scorers/outcome.js +321 -212
  92. package/dist/evals/scorers/outcome.js.map +1 -1
  93. package/dist/goal-manager.js +266 -261
  94. package/dist/goal-manager.js.map +1 -1
  95. package/dist/goal-signal.js +14 -13
  96. package/dist/goal-signal.js.map +1 -1
  97. package/dist/headless/cli.js +153 -154
  98. package/dist/headless/cli.js.map +1 -1
  99. package/dist/headless/flags.js +180 -178
  100. package/dist/headless/flags.js.map +1 -1
  101. package/dist/headless/format.js +72 -71
  102. package/dist/headless/format.js.map +1 -1
  103. package/dist/headless/index.js +5 -31
  104. package/dist/headless/policy.js +35 -31
  105. package/dist/headless/policy.js.map +1 -1
  106. package/dist/headless/run-mc.js +332 -334
  107. package/dist/headless/run-mc.js.map +1 -1
  108. package/dist/headless/types.js +16 -7
  109. package/dist/headless/types.js.map +1 -1
  110. package/dist/hooks/config.js +56 -61
  111. package/dist/hooks/config.js.map +1 -1
  112. package/dist/hooks/executor.js +118 -116
  113. package/dist/hooks/executor.js.map +1 -1
  114. package/dist/hooks/index.js +4 -15
  115. package/dist/hooks/manager.js +221 -280
  116. package/dist/hooks/manager.js.map +1 -1
  117. package/dist/hooks/types.js +5 -4
  118. package/dist/hooks/types.js.map +1 -1
  119. package/dist/index.d.ts.map +1 -1
  120. package/dist/index.js +632 -712
  121. package/dist/index.js.map +1 -1
  122. package/dist/ipc/ipc-reporter.js +19 -22
  123. package/dist/ipc/ipc-reporter.js.map +1 -1
  124. package/dist/lsp/client.js +248 -306
  125. package/dist/lsp/client.js.map +1 -1
  126. package/dist/lsp/index.js +1 -6
  127. package/dist/lsp/language.js +39 -43
  128. package/dist/lsp/language.js.map +1 -1
  129. package/dist/lsp/manager.js +78 -93
  130. package/dist/lsp/manager.js.map +1 -1
  131. package/dist/lsp/server.js +151 -120
  132. package/dist/lsp/server.js.map +1 -1
  133. package/dist/lsp/workspace.js +50 -47
  134. package/dist/lsp/workspace.js.map +1 -1
  135. package/dist/mcp/config.js +210 -199
  136. package/dist/mcp/config.js.map +1 -1
  137. package/dist/mcp/index.js +2 -9
  138. package/dist/mcp/manager.js +482 -475
  139. package/dist/mcp/manager.js.map +1 -1
  140. package/dist/mcp/types.js +1 -1
  141. package/dist/onboarding/custom-packs.js +14 -17
  142. package/dist/onboarding/custom-packs.js.map +1 -1
  143. package/dist/onboarding/custom-providers.js +22 -20
  144. package/dist/onboarding/custom-providers.js.map +1 -1
  145. package/dist/onboarding/index.d.ts +1 -1
  146. package/dist/onboarding/index.d.ts.map +1 -1
  147. package/dist/onboarding/index.js +3 -21
  148. package/dist/onboarding/om-settings.d.ts +5 -0
  149. package/dist/onboarding/om-settings.d.ts.map +1 -1
  150. package/dist/onboarding/om-settings.js +41 -20
  151. package/dist/onboarding/om-settings.js.map +1 -1
  152. package/dist/onboarding/packs.d.ts +4 -6
  153. package/dist/onboarding/packs.d.ts.map +1 -1
  154. package/dist/onboarding/packs.js +154 -105
  155. package/dist/onboarding/packs.js.map +1 -1
  156. package/dist/onboarding/settings.js +575 -517
  157. package/dist/onboarding/settings.js.map +1 -1
  158. package/dist/permissions.js +112 -99
  159. package/dist/permissions.js.map +1 -1
  160. package/dist/plugin.js +21 -23
  161. package/dist/plugin.js.map +1 -1
  162. package/dist/plugins/dependencies.js +64 -87
  163. package/dist/plugins/dependencies.js.map +1 -1
  164. package/dist/plugins/install.js +159 -169
  165. package/dist/plugins/install.js.map +1 -1
  166. package/dist/plugins/loader.js +170 -185
  167. package/dist/plugins/loader.js.map +1 -1
  168. package/dist/plugins/manager.js +374 -380
  169. package/dist/plugins/manager.js.map +1 -1
  170. package/dist/plugins/manifest.js +38 -63
  171. package/dist/plugins/manifest.js.map +1 -1
  172. package/dist/plugins/package-link.js +48 -64
  173. package/dist/plugins/package-link.js.map +1 -1
  174. package/dist/plugins/paths.js +18 -19
  175. package/dist/plugins/paths.js.map +1 -1
  176. package/dist/plugins/registry.js +97 -81
  177. package/dist/plugins/registry.js.map +1 -1
  178. package/dist/plugins/scaffold.js +62 -98
  179. package/dist/plugins/scaffold.js.map +1 -1
  180. package/dist/plugins/types.js +1 -1
  181. package/dist/processors/plan-rejection-abort.js +45 -44
  182. package/dist/processors/plan-rejection-abort.js.map +1 -1
  183. package/dist/providers/amazon-bedrock-gateway.js +134 -125
  184. package/dist/providers/amazon-bedrock-gateway.js.map +1 -1
  185. package/dist/providers/amazon-bedrock.js +68 -47
  186. package/dist/providers/amazon-bedrock.js.map +1 -1
  187. package/dist/providers/claude-max.js +153 -133
  188. package/dist/providers/claude-max.js.map +1 -1
  189. package/dist/providers/github-copilot.js +232 -230
  190. package/dist/providers/github-copilot.js.map +1 -1
  191. package/dist/providers/openai-codex.js +271 -260
  192. package/dist/providers/openai-codex.js.map +1 -1
  193. package/dist/providers/xai.js +57 -50
  194. package/dist/providers/xai.js.map +1 -1
  195. package/dist/schema.js +91 -89
  196. package/dist/schema.js.map +1 -1
  197. package/dist/theme-palette.js +18 -14
  198. package/dist/theme-palette.js.map +1 -1
  199. package/dist/tool-names.js +46 -37
  200. package/dist/tool-names.js.map +1 -1
  201. package/dist/tools/index.js +2 -8
  202. package/dist/tools/request-sandbox-access.js +71 -80
  203. package/dist/tools/request-sandbox-access.js.map +1 -1
  204. package/dist/tools/utils.js +26 -16
  205. package/dist/tools/utils.js.map +1 -1
  206. package/dist/tools/web-search.js +51 -55
  207. package/dist/tools/web-search.js.map +1 -1
  208. package/dist/utils/binaries.js +65 -61
  209. package/dist/utils/binaries.js.map +1 -1
  210. package/dist/utils/debug-log.js +51 -47
  211. package/dist/utils/debug-log.js.map +1 -1
  212. package/dist/utils/errors.js +157 -192
  213. package/dist/utils/errors.js.map +1 -1
  214. package/dist/utils/gateway-sync.js +49 -37
  215. package/dist/utils/gateway-sync.js.map +1 -1
  216. package/dist/utils/path-security.js +7 -6
  217. package/dist/utils/path-security.js.map +1 -1
  218. package/dist/utils/plan-diff.js +58 -39
  219. package/dist/utils/plan-diff.js.map +1 -1
  220. package/dist/utils/plans.js +92 -74
  221. package/dist/utils/plans.js.map +1 -1
  222. package/dist/utils/project.js +318 -256
  223. package/dist/utils/project.js.map +1 -1
  224. package/dist/utils/signals-pubsub.js +117 -99
  225. package/dist/utils/signals-pubsub.js.map +1 -1
  226. package/dist/utils/slash-command-loader.js +118 -154
  227. package/dist/utils/slash-command-loader.js.map +1 -1
  228. package/dist/utils/slash-command-processor.js +92 -83
  229. package/dist/utils/slash-command-processor.js.map +1 -1
  230. package/dist/utils/stdin-pipe.js +87 -63
  231. package/dist/utils/stdin-pipe.js.map +1 -1
  232. package/dist/utils/storage-factory.js +104 -84
  233. package/dist/utils/storage-factory.js.map +1 -1
  234. package/dist/utils/storage-maintenance.js +249 -211
  235. package/dist/utils/storage-maintenance.js.map +1 -1
  236. package/dist/utils/thread-lock.js +96 -92
  237. package/dist/utils/thread-lock.js.map +1 -1
  238. package/dist/utils/token-estimator.js +12 -12
  239. package/dist/utils/token-estimator.js.map +1 -1
  240. package/dist/utils/update-check.d.ts +1 -1
  241. package/dist/utils/update-check.js +341 -259
  242. package/dist/utils/update-check.js.map +1 -1
  243. package/dist/voice/stt-registry.js +131 -113
  244. package/dist/voice/stt-registry.js.map +1 -1
  245. package/package.json +11 -11
  246. package/dist/acp.js.map +0 -1
  247. package/dist/auth/index.js.map +0 -1
  248. package/dist/auth/types.js.map +0 -1
  249. package/dist/evals/index.js.map +0 -1
  250. package/dist/evals/scorers/index.js.map +0 -1
  251. package/dist/headless/index.js.map +0 -1
  252. package/dist/hooks/index.js.map +0 -1
  253. package/dist/lsp/index.js.map +0 -1
  254. package/dist/mcp/index.js.map +0 -1
  255. package/dist/mcp/types.js.map +0 -1
  256. package/dist/onboarding/index.js.map +0 -1
  257. package/dist/plugins/types.js.map +0 -1
  258. package/dist/tools/index.js.map +0 -1
@@ -1,82 +1,91 @@
1
- import { existsSync, readFileSync } from "node:fs";
2
- import { homedir } from "node:os";
3
- import { join, normalize } from "node:path";
4
1
  import { DEFAULT_CONFIG_DIR } from "../../constants.js";
2
+ import { existsSync, readFileSync } from "fs";
3
+ import { homedir } from "os";
4
+ import { join, normalize } from "path";
5
+ //#region src/agents/prompts/agent-instructions.ts
6
+ /**
7
+ * Load project and global agent instruction files (AGENTS.md, CLAUDE.md).
8
+ * Prefers AGENTS.md over CLAUDE.md when multiple exist at the same location.
9
+ */
5
10
  const INSTRUCTION_FILES = ["AGENTS.md", "CLAUDE.md"];
6
11
  const PROJECT_LOCATIONS = [
7
- "",
8
- // project root
9
- ".claude",
10
- ".mastracode"
12
+ "",
13
+ ".claude",
14
+ ".mastracode"
11
15
  ];
12
- const GLOBAL_LOCATIONS = [".claude", ".mastracode", ".config/claude", ".config/mastracode"];
16
+ const GLOBAL_LOCATIONS = [
17
+ ".claude",
18
+ ".mastracode",
19
+ ".config/claude",
20
+ ".config/mastracode"
21
+ ];
22
+ /**
23
+ * Find the first existing instruction file at a given base path.
24
+ * Prefers AGENTS.md over CLAUDE.md.
25
+ */
13
26
  function findInstructionFile(basePath) {
14
- for (const filename of INSTRUCTION_FILES) {
15
- const fullPath = join(basePath, filename);
16
- if (existsSync(fullPath)) {
17
- return fullPath;
18
- }
19
- }
20
- return null;
27
+ for (const filename of INSTRUCTION_FILES) {
28
+ const fullPath = join(basePath, filename);
29
+ if (existsSync(fullPath)) return fullPath;
30
+ }
31
+ return null;
21
32
  }
33
+ /**
34
+ * Load all agent instruction files from global and project locations.
35
+ * Returns an array of instruction sources, with global ones first.
36
+ */
22
37
  function loadAgentInstructions(projectPath, configDirName = DEFAULT_CONFIG_DIR) {
23
- const sources = [];
24
- const home = homedir();
25
- const projectLocations = PROJECT_LOCATIONS.map((loc) => loc === ".mastracode" ? configDirName : loc);
26
- const globalLocations = GLOBAL_LOCATIONS.map((loc) => {
27
- if (loc === ".mastracode") return configDirName;
28
- if (loc === ".config/mastracode") return ".config/" + configDirName.replace(/^\./, "");
29
- return loc;
30
- });
31
- for (const location of globalLocations) {
32
- const basePath = join(home, location);
33
- const filePath = findInstructionFile(basePath);
34
- if (filePath) {
35
- try {
36
- const content = readFileSync(filePath, "utf-8").trim();
37
- if (content) {
38
- sources.push({ path: filePath, content, scope: "global" });
39
- break;
40
- }
41
- } catch {
42
- }
43
- }
44
- }
45
- for (const location of projectLocations) {
46
- const basePath = location ? join(projectPath, location) : projectPath;
47
- const filePath = findInstructionFile(basePath);
48
- if (filePath) {
49
- try {
50
- const content = readFileSync(filePath, "utf-8").trim();
51
- if (content) {
52
- sources.push({ path: filePath, content, scope: "project" });
53
- break;
54
- }
55
- } catch {
56
- }
57
- }
58
- }
59
- return sources;
38
+ const sources = [];
39
+ const home = homedir();
40
+ const projectLocations = PROJECT_LOCATIONS.map((loc) => loc === ".mastracode" ? configDirName : loc);
41
+ const globalLocations = GLOBAL_LOCATIONS.map((loc) => {
42
+ if (loc === ".mastracode") return configDirName;
43
+ if (loc === ".config/mastracode") return ".config/" + configDirName.replace(/^\./, "");
44
+ return loc;
45
+ });
46
+ for (const location of globalLocations) {
47
+ const filePath = findInstructionFile(join(home, location));
48
+ if (filePath) try {
49
+ const content = readFileSync(filePath, "utf-8").trim();
50
+ if (content) {
51
+ sources.push({
52
+ path: filePath,
53
+ content,
54
+ scope: "global"
55
+ });
56
+ break;
57
+ }
58
+ } catch {}
59
+ }
60
+ for (const location of projectLocations) {
61
+ const filePath = findInstructionFile(location ? join(projectPath, location) : projectPath);
62
+ if (filePath) try {
63
+ const content = readFileSync(filePath, "utf-8").trim();
64
+ if (content) {
65
+ sources.push({
66
+ path: filePath,
67
+ content,
68
+ scope: "project"
69
+ });
70
+ break;
71
+ }
72
+ } catch {}
73
+ }
74
+ return sources;
60
75
  }
61
76
  function getStaticallyLoadedInstructionPaths(projectPath) {
62
- return loadAgentInstructions(projectPath).map((source) => normalize(source.path));
77
+ return loadAgentInstructions(projectPath).map((source) => normalize(source.path));
63
78
  }
79
+ /**
80
+ * Format loaded instructions into a string for the system prompt.
81
+ */
64
82
  function formatAgentInstructions(sources) {
65
- if (sources.length === 0) return "";
66
- const sections = sources.map((source) => {
67
- const label = source.scope === "global" ? "Global" : "Project";
68
- return `<!-- ${label} instructions from ${source.path} -->
69
- ${source.content}`;
70
- });
71
- return `
72
- # Agent Instructions
73
-
74
- ${sections.join("\n\n")}
75
- `;
83
+ if (sources.length === 0) return "";
84
+ return `\n# Agent Instructions\n\n${sources.map((source) => {
85
+ return `<!-- ${source.scope === "global" ? "Global" : "Project"} instructions from ${source.path} -->\n${source.content}`;
86
+ }).join("\n\n")}\n`;
76
87
  }
77
- export {
78
- formatAgentInstructions,
79
- getStaticallyLoadedInstructionPaths,
80
- loadAgentInstructions
81
- };
88
+ //#endregion
89
+ export { formatAgentInstructions, getStaticallyLoadedInstructionPaths, loadAgentInstructions };
90
+
82
91
  //# sourceMappingURL=agent-instructions.js.map
@@ -1 +1 @@
1
- {"version":3,"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 { existsSync, readFileSync } from 'node:fs';\nimport { homedir } from 'node:os';\nimport { join, normalize } 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}\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): string | null {\n for (const filename of INSTRUCTION_FILES) {\n const fullPath = join(basePath, filename);\n if (existsSync(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 */\nexport function loadAgentInstructions(projectPath: string, configDirName = DEFAULT_CONFIG_DIR): 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 = 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);\n if (filePath) {\n try {\n const content = readFileSync(filePath, 'utf-8').trim();\n if (content) {\n sources.push({ path: filePath, content, scope: 'project' });\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(projectPath: string): string[] {\n return loadAgentInstructions(projectPath).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 return `<!-- ${label} instructions from ${source.path} -->\\n${source.content}`;\n });\n\n return `\\n# Agent Instructions\\n\\n${sections.join('\\n\\n')}\\n`;\n}\n"],"mappings":"AAKA,SAAS,YAAY,oBAAoB;AACzC,SAAS,eAAe;AACxB,SAAS,MAAM,iBAAiB;AAChC,SAAS,0BAA0B;AAGnC,MAAM,oBAAoB,CAAC,aAAa,WAAW;AAGnD,MAAM,oBAAoB;AAAA,EACxB;AAAA;AAAA,EACA;AAAA,EACA;AACF;AAEA,MAAM,mBAAmB,CAAC,WAAW,eAAe,kBAAkB,oBAAoB;AAY1F,SAAS,oBAAoB,UAAiC;AAC5D,aAAW,YAAY,mBAAmB;AACxC,UAAM,WAAW,KAAK,UAAU,QAAQ;AACxC,QAAI,WAAW,QAAQ,GAAG;AACxB,aAAO;AAAA,IACT;AAAA,EACF;AACA,SAAO;AACT;AAMO,SAAS,sBAAsB,aAAqB,gBAAgB,oBAAyC;AAClH,QAAM,UAA+B,CAAC;AACtC,QAAM,OAAO,QAAQ;AAGrB,QAAM,mBAAmB,kBAAkB,IAAI,SAAQ,QAAQ,gBAAgB,gBAAgB,GAAI;AACnG,QAAM,kBAAkB,iBAAiB,IAAI,SAAO;AAClD,QAAI,QAAQ,cAAe,QAAO;AAGlC,QAAI,QAAQ,qBAAsB,QAAO,aAAa,cAAc,QAAQ,OAAO,EAAE;AACrF,WAAO;AAAA,EACT,CAAC;AAGD,aAAW,YAAY,iBAAiB;AACtC,UAAM,WAAW,KAAK,MAAM,QAAQ;AACpC,UAAM,WAAW,oBAAoB,QAAQ;AAC7C,QAAI,UAAU;AACZ,UAAI;AACF,cAAM,UAAU,aAAa,UAAU,OAAO,EAAE,KAAK;AACrD,YAAI,SAAS;AACX,kBAAQ,KAAK,EAAE,MAAM,UAAU,SAAS,OAAO,SAAS,CAAC;AACzD;AAAA,QACF;AAAA,MACF,QAAQ;AAAA,MAER;AAAA,IACF;AAAA,EACF;AAGA,aAAW,YAAY,kBAAkB;AACvC,UAAM,WAAW,WAAW,KAAK,aAAa,QAAQ,IAAI;AAC1D,UAAM,WAAW,oBAAoB,QAAQ;AAC7C,QAAI,UAAU;AACZ,UAAI;AACF,cAAM,UAAU,aAAa,UAAU,OAAO,EAAE,KAAK;AACrD,YAAI,SAAS;AACX,kBAAQ,KAAK,EAAE,MAAM,UAAU,SAAS,OAAO,UAAU,CAAC;AAC1D;AAAA,QACF;AAAA,MACF,QAAQ;AAAA,MAER;AAAA,IACF;AAAA,EACF;AAEA,SAAO;AACT;AAEO,SAAS,oCAAoC,aAA+B;AACjF,SAAO,sBAAsB,WAAW,EAAE,IAAI,YAAU,UAAU,OAAO,IAAI,CAAC;AAChF;AAKO,SAAS,wBAAwB,SAAsC;AAC5E,MAAI,QAAQ,WAAW,EAAG,QAAO;AAEjC,QAAM,WAAW,QAAQ,IAAI,YAAU;AACrC,UAAM,QAAQ,OAAO,UAAU,WAAW,WAAW;AACrD,WAAO,QAAQ,KAAK,sBAAsB,OAAO,IAAI;AAAA,EAAS,OAAO,OAAO;AAAA,EAC9E,CAAC;AAED,SAAO;AAAA;AAAA;AAAA,EAA6B,SAAS,KAAK,MAAM,CAAC;AAAA;AAC3D;","names":[]}
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 { existsSync, readFileSync } from 'node:fs';\nimport { homedir } from 'node:os';\nimport { join, normalize } 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}\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): string | null {\n for (const filename of INSTRUCTION_FILES) {\n const fullPath = join(basePath, filename);\n if (existsSync(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 */\nexport function loadAgentInstructions(projectPath: string, configDirName = DEFAULT_CONFIG_DIR): 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 = 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);\n if (filePath) {\n try {\n const content = readFileSync(filePath, 'utf-8').trim();\n if (content) {\n sources.push({ path: filePath, content, scope: 'project' });\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(projectPath: string): string[] {\n return loadAgentInstructions(projectPath).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 return `<!-- ${label} instructions from ${source.path} -->\\n${source.content}`;\n });\n\n return `\\n# Agent Instructions\\n\\n${sections.join('\\n\\n')}\\n`;\n}\n"],"mappings":";;;;;;;;;AAWA,MAAM,oBAAoB,CAAC,aAAa,WAAW;AAGnD,MAAM,oBAAoB;CACxB;CACA;CACA;AACF;AAEA,MAAM,mBAAmB;CAAC;CAAW;CAAe;CAAkB;AAAoB;;;;;AAY1F,SAAS,oBAAoB,UAAiC;CAC5D,KAAK,MAAM,YAAY,mBAAmB;EACxC,MAAM,WAAW,KAAK,UAAU,QAAQ;EACxC,IAAI,WAAW,QAAQ,GACrB,OAAO;CAEX;CACA,OAAO;AACT;;;;;AAMA,SAAgB,sBAAsB,aAAqB,gBAAgB,oBAAyC;CAClH,MAAM,UAA+B,CAAC;CACtC,MAAM,OAAO,QAAQ;CAGrB,MAAM,mBAAmB,kBAAkB,KAAI,QAAQ,QAAQ,gBAAgB,gBAAgB,GAAI;CACnG,MAAM,kBAAkB,iBAAiB,KAAI,QAAO;EAClD,IAAI,QAAQ,eAAe,OAAO;EAGlC,IAAI,QAAQ,sBAAsB,OAAO,aAAa,cAAc,QAAQ,OAAO,EAAE;EACrF,OAAO;CACT,CAAC;CAGD,KAAK,MAAM,YAAY,iBAAiB;EAEtC,MAAM,WAAW,oBADA,KAAK,MAAM,QACgB,CAAC;EAC7C,IAAI,UACF,IAAI;GACF,MAAM,UAAU,aAAa,UAAU,OAAO,CAAC,CAAC,KAAK;GACrD,IAAI,SAAS;IACX,QAAQ,KAAK;KAAE,MAAM;KAAU;KAAS,OAAO;IAAS,CAAC;IACzD;GACF;EACF,QAAQ,CAER;CAEJ;CAGA,KAAK,MAAM,YAAY,kBAAkB;EAEvC,MAAM,WAAW,oBADA,WAAW,KAAK,aAAa,QAAQ,IAAI,WACb;EAC7C,IAAI,UACF,IAAI;GACF,MAAM,UAAU,aAAa,UAAU,OAAO,CAAC,CAAC,KAAK;GACrD,IAAI,SAAS;IACX,QAAQ,KAAK;KAAE,MAAM;KAAU;KAAS,OAAO;IAAU,CAAC;IAC1D;GACF;EACF,QAAQ,CAER;CAEJ;CAEA,OAAO;AACT;AAEA,SAAgB,oCAAoC,aAA+B;CACjF,OAAO,sBAAsB,WAAW,CAAC,CAAC,KAAI,WAAU,UAAU,OAAO,IAAI,CAAC;AAChF;;;;AAKA,SAAgB,wBAAwB,SAAsC;CAC5E,IAAI,QAAQ,WAAW,GAAG,OAAO;CAOjC,OAAO,6BALU,QAAQ,KAAI,WAAU;EAErC,OAAO,QADO,OAAO,UAAU,WAAW,WAAW,UAChC,qBAAqB,OAAO,KAAK,QAAQ,OAAO;CACvE,CAE2C,CAAC,CAAC,KAAK,MAAM,EAAE;AAC5D"}
@@ -1,6 +1,11 @@
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
+ */
1
7
  function buildModePromptFn(ctx) {
2
- if (ctx.activePlan) {
3
- return `# Approved Plan
8
+ if (ctx.activePlan) return `# Approved Plan
4
9
 
5
10
  **${ctx.activePlan.title}**
6
11
 
@@ -11,8 +16,7 @@ ${ctx.activePlan.plan}
11
16
  Implement the approved plan above. Follow the steps in order and verify each step works before moving on.
12
17
 
13
18
  ` + buildModePrompt;
14
- }
15
- return buildModePrompt;
19
+ return buildModePrompt;
16
20
  }
17
21
  const buildModePrompt = `
18
22
  # Build Mode
@@ -26,18 +30,18 @@ You are in BUILD mode. You have full access to all tools and can read, write, ed
26
30
 
27
31
  **For non-trivial tasks** (3+ files, architectural decisions, unclear requirements):
28
32
  - Use the available task-management tools to create and update your task list
29
- - Work on ONE step at a time \u2014 complete it and verify it works before moving on
33
+ - Work on ONE step at a time complete it and verify it works before moving on
30
34
  - If multiple approaches are plausible and the choice would materially affect scope, behavior, or risk, stop and ask the user
31
35
 
32
36
  ## The Implementation Loop
33
37
 
34
38
  For each change you make:
35
39
 
36
- 1. **Understand** \u2014 Read the relevant code. Check how similar things are done elsewhere.
37
- 2. **Implement** \u2014 Make the change. Follow existing patterns and conventions.
38
- 3. **Verify** \u2014 Test that it works. Don't assume \u2014 actually run it.
39
- 4. **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.
40
- 5. **Clean up** \u2014 Ensure no broken code, no debug statements, no half-done features.
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.
41
45
 
42
46
  Only move to the next change after the current one is verified and proved to be working.
43
47
 
@@ -55,9 +59,9 @@ Before considering any task complete:
55
59
  ## Error Recovery
56
60
 
57
61
  When something breaks:
58
- 1. Read the full error output carefully \u2014 don't guess
62
+ 1. Read the full error output carefully don't guess
59
63
  2. Find the root cause, not just the symptom
60
- 3. Fix it properly \u2014 no casts or suppressions to hide errors
64
+ 3. Fix it properly no casts or suppressions to hide errors
61
65
  4. Re-run to confirm the fix
62
66
  5. If progress is blocked after reasonable attempts, briefly explain the blocker, what you've tried, and the next best option
63
67
 
@@ -66,8 +70,7 @@ When something breaks:
66
70
  - Before committing, verify the code compiles and passes lint
67
71
  - Use descriptive branch names: \`feat/...\`, \`fix/...\`, \`refactor/...\`
68
72
  `;
69
- export {
70
- buildModePrompt,
71
- buildModePromptFn
72
- };
73
+ //#endregion
74
+ export { buildModePrompt, buildModePromptFn };
75
+
73
76
  //# sourceMappingURL=build.js.map
@@ -1 +1 @@
1
- {"version":3,"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":"AAWO,SAAS,kBAAkB,KAA4B;AAC5D,MAAI,IAAI,YAAY;AAClB,WACE;AAAA;AAAA,IAEF,IAAI,WAAW,KAAK;AAAA;AAAA,EAEtB,IAAI,WAAW,IAAI;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAMjB;AAAA,EAEF;AACA,SAAO;AACT;AAEO,MAAM,kBAAkB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;","names":[]}
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"}
@@ -1,3 +1,7 @@
1
+ //#region src/agents/prompts/fast.ts
2
+ /**
3
+ * Fast mode prompt — quick answers and small edits, minimal overhead.
4
+ */
1
5
  const fastModePrompt = `
2
6
  # Fast Mode
3
7
 
@@ -12,11 +16,11 @@ You are in FAST mode. Optimize for speed and brevity.
12
16
 
13
17
  ## When to Use Tools vs. Just Answer
14
18
  - If the user asks a general programming question, answer directly from knowledge. Don't search the codebase.
15
- - If the user asks about THIS project's code, use tools to look it up \u2014 don't guess.
19
+ - If the user asks about THIS project's code, use tools to look it up don't guess.
16
20
  - If the user asks for a quick edit and you know the file, read it and edit it. Don't ask for confirmation.
17
21
  - One tool call to read + one to edit is ideal. Minimize round trips.
18
22
  `;
19
- export {
20
- fastModePrompt
21
- };
23
+ //#endregion
24
+ export { fastModePrompt };
25
+
22
26
  //# sourceMappingURL=fast.js.map
@@ -1 +1 @@
1
- {"version":3,"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":"AAIO,MAAM,iBAAiB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;","names":[]}
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"}
@@ -1,57 +1,58 @@
1
1
  import { buildModePrompt, buildModePromptFn } from "./build.js";
2
2
  import { planModePrompt } from "./plan.js";
3
3
  import { fastModePrompt } from "./fast.js";
4
- import { buildBasePrompt } from "@mastra/core/coding-agent";
5
- import { hasTavilyKey } from "../../tools/index.js";
6
- import { loadAgentInstructions, formatAgentInstructions } from "./agent-instructions.js";
7
- import { buildModePromptFn as buildModePromptFn2 } from "./build.js";
8
- import { fastModePrompt as fastModePrompt2 } from "./fast.js";
4
+ import { hasTavilyKey } from "../../tools/web-search.js";
5
+ import "../../tools/index.js";
6
+ import { formatAgentInstructions, loadAgentInstructions } from "./agent-instructions.js";
9
7
  import { modelSpecificPrompts } from "./model.js";
10
- import { planModePrompt as planModePrompt2 } from "./plan.js";
11
8
  import { buildToolGuidance } from "./tool-guidance.js";
9
+ import { buildBasePrompt } from "@mastra/core/coding-agent";
10
+ //#region src/agents/prompts/index.ts
12
11
  const modePrompts = {
13
- build: buildModePromptFn2,
14
- plan: planModePrompt2,
15
- fast: fastModePrompt2
12
+ build: buildModePromptFn,
13
+ plan: planModePrompt,
14
+ fast: fastModePrompt
16
15
  };
16
+ /**
17
+ * Build the full system prompt for a given mode and context.
18
+ * Combines the base prompt with mode-specific instructions.
19
+ */
17
20
  function buildFullPrompt(ctx) {
18
- const modelId = ctx.modelId;
19
- const hasWebSearch = hasTavilyKey() || !!modelId && modelId.startsWith("anthropic/");
20
- const deniedTools = /* @__PURE__ */ new Set();
21
- const permRules = ctx.state?.permissionRules;
22
- if (permRules?.tools) {
23
- for (const [name, policy] of Object.entries(permRules.tools)) {
24
- if (policy === "deny") deniedTools.add(name);
25
- }
26
- }
27
- const toolGuidance = buildToolGuidance(ctx.modeId, { hasWebSearch, deniedTools });
28
- const baseCtx = {
29
- projectPath: ctx.workingDir,
30
- projectName: ctx.projectName || "unknown",
31
- gitBranch: ctx.gitBranch,
32
- platform: process.platform,
33
- commonBinaries: ctx.commonBinaries,
34
- date: ctx.currentDate,
35
- mode: ctx.modeId,
36
- modelId: ctx.modelId,
37
- activePlan: ctx.state?.activePlan,
38
- toolGuidance
39
- };
40
- const base = buildBasePrompt(baseCtx);
41
- const entry = modePrompts[ctx.modeId] || modePrompts.build;
42
- const modeSpecific = (typeof entry === "function" ? entry(ctx) : entry) ?? "";
43
- const modelSpecific = ctx.modelId ? modelSpecificPrompts[ctx.modelId] ?? "" : "";
44
- const configDir = ctx.state?.configDir;
45
- const instructionSources = loadAgentInstructions(ctx.workingDir, configDir);
46
- const instructionsSection = formatAgentInstructions(instructionSources);
47
- const sections = [base, instructionsSection.trim(), modelSpecific.trim(), modeSpecific.trim()].filter(Boolean);
48
- return sections.join("\n\n");
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
+ return [
49
+ base,
50
+ formatAgentInstructions(loadAgentInstructions(ctx.workingDir, configDir)).trim(),
51
+ modelSpecific.trim(),
52
+ modeSpecific.trim()
53
+ ].filter(Boolean).join("\n\n");
49
54
  }
50
- export {
51
- buildFullPrompt,
52
- buildModePrompt,
53
- buildModePromptFn,
54
- fastModePrompt,
55
- planModePrompt
56
- };
55
+ //#endregion
56
+ export { buildFullPrompt, buildModePrompt, buildModePromptFn, fastModePrompt, planModePrompt };
57
+
57
58
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"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 } 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 const configDir = ctx.state?.configDir as string | undefined;\n const instructionSources = loadAgentInstructions(ctx.workingDir, configDir);\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":"AAIA,SAAS,iBAAiB,yBAAyB;AACnD,SAAS,sBAAsB;AAC/B,SAAS,sBAAsB;AAE/B,SAAS,uBAAuB;AAEhC,SAAS,oBAAoB;AAC7B,SAAS,uBAAuB,+BAA+B;AAC/D,SAAS,qBAAAA,0BAAyB;AAClC,SAAS,kBAAAC,uBAAsB;AAC/B,SAAS,4BAA4B;AACrC,SAAS,kBAAAC,uBAAsB;AAC/B,SAAS,yBAAyB;AAUlC,MAAM,cAAyE;AAAA,EAC7E,OAAOF;AAAA,EACP,MAAME;AAAA,EACN,MAAMD;AACR;AAMO,SAAS,gBAAgB,KAA4B;AAE1D,QAAM,UAAU,IAAI;AACpB,QAAM,eAAe,aAAa,KAAM,CAAC,CAAC,WAAW,QAAQ,WAAW,YAAY;AAGpF,QAAM,cAAc,oBAAI,IAAY;AACpC,QAAM,YAAY,IAAI,OAAO;AAC7B,MAAI,WAAW,OAAO;AACpB,eAAW,CAAC,MAAM,MAAM,KAAK,OAAO,QAAQ,UAAU,KAAK,GAAG;AAC5D,UAAI,WAAW,OAAQ,aAAY,IAAI,IAAI;AAAA,IAC7C;AAAA,EACF;AAGA,QAAM,eAAe,kBAAkB,IAAI,QAAQ,EAAE,cAAc,YAAY,CAAC;AAGhF,QAAM,UAA6B;AAAA,IACjC,aAAa,IAAI;AAAA,IACjB,aAAa,IAAI,eAAe;AAAA,IAChC,WAAW,IAAI;AAAA,IACf,UAAU,QAAQ;AAAA,IAClB,gBAAgB,IAAI;AAAA,IACpB,MAAM,IAAI;AAAA,IACV,MAAM,IAAI;AAAA,IACV,SAAS,IAAI;AAAA,IACb,YAAY,IAAI,OAAO;AAAA,IACvB;AAAA,EACF;AAEA,QAAM,OAAO,gBAAgB,OAAO;AACpC,QAAM,QAAQ,YAAY,IAAI,MAAM,KAAK,YAAY;AACrD,QAAM,gBAAgB,OAAO,UAAU,aAAa,MAAM,GAAG,IAAI,UAAU;AAC3E,QAAM,gBAAgB,IAAI,UACrB,qBAAqB,IAAI,OAA4C,KAAK,KAC3E;AAQJ,QAAM,YAAY,IAAI,OAAO;AAC7B,QAAM,qBAAqB,sBAAsB,IAAI,YAAY,SAAS;AAC1E,QAAM,sBAAsB,wBAAwB,kBAAkB;AAEtE,QAAM,WAAW,CAAC,MAAM,oBAAoB,KAAK,GAAG,cAAc,KAAK,GAAG,aAAa,KAAK,CAAC,EAAE,OAAO,OAAO;AAE7G,SAAO,SAAS,KAAK,MAAM;AAC7B;","names":["buildModePromptFn","fastModePrompt","planModePrompt"]}
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 } 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 const configDir = ctx.state?.configDir as string | undefined;\n const instructionSources = loadAgentInstructions(ctx.workingDir, configDir);\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;CAQJ,MAAM,YAAY,IAAI,OAAO;CAM7B,OAFiB;EAAC;EAFU,wBADD,sBAAsB,IAAI,YAAY,SACI,CAE3B,CAAC,CAAC,KAAK;EAAG,cAAc,KAAK;EAAG,aAAa,KAAK;CAAC,CAAC,CAAC,OAAO,OAExF,CAAC,CAAC,KAAK,MAAM;AAC7B"}
@@ -1,11 +1,12 @@
1
+ //#region src/agents/prompts/model.ts
1
2
  const modelSpecificPrompts = {
2
- "openai/gpt-5.4": `<autonomy_and_persistence>
3
+ "openai/gpt-5.4": `<autonomy_and_persistence>
3
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.
4
5
 
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.
6
7
  </autonomy_and_persistence>
7
8
  `,
8
- "openai/gpt-5.5": `<coding_behavior>
9
+ "openai/gpt-5.5": `<coding_behavior>
9
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.
10
11
 
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.
@@ -16,7 +17,7 @@ For coding work, make focused changes that follow the surrounding conventions. A
16
17
  </coding_behavior>
17
18
  `
18
19
  };
19
- export {
20
- modelSpecificPrompts
21
- };
20
+ //#endregion
21
+ export { modelSpecificPrompts };
22
+
22
23
  //# sourceMappingURL=model.js.map
@@ -1 +1 @@
1
- {"version":3,"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":"AAAO,MAAM,uBAAuB;AAAA,EAClC,kBAAkB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAMlB,kBAAkB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAUpB;","names":[]}
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"}
@@ -1,11 +1,15 @@
1
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
+ */
2
6
  function planModePrompt(_ctx) {
3
- const plansDir = getLocalPlansRelativeDir();
4
- const examplePath = `${plansDir}/add-dark-mode.md`;
5
- return `
6
- # Plan Mode \u2014 READ-ONLY (except plan files)
7
+ const plansDir = getLocalPlansRelativeDir();
8
+ const examplePath = `${plansDir}/add-dark-mode.md`;
9
+ return `
10
+ # Plan Mode READ-ONLY (except plan files)
7
11
 
8
- You are in PLAN mode. Your job is to explore the codebase and design an implementation plan \u2014 NOT to make changes to the project.
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.
9
13
 
10
14
  ## CRITICAL: Read-Only Mode (project files)
11
15
 
@@ -24,7 +28,7 @@ If the user asks you to make changes while in Plan mode, explain that you're in
24
28
  Before writing any plan, build a mental model of the codebase:
25
29
  1. Start with the directory structure (\`view\` on the project root or relevant subdirectory).
26
30
  2. Find the relevant entry points and core files using \`search_content\` and \`find_files\`.
27
- 3. Read the actual code \u2014 don't assume based on file names alone.
31
+ 3. Read the actual code don't assume based on file names alone.
28
32
  4. Trace data flow: where does input come from, how is it transformed, where does it go?
29
33
  5. Identify existing patterns the codebase uses (naming, structure, error handling, testing).
30
34
 
@@ -67,7 +71,7 @@ Write each plan to its own markdown file under \`${plansDir}/\` (e.g. \`${exampl
67
71
  2. **Reading**: Use \`view\` to read a plan file.
68
72
  3. **Editing**: Use \`string_replace_lsp\` for targeted edits to specific sections.
69
73
 
70
- **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 \u2014 that keeps each plan available to look back at and keeps revision diffs meaningful.
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.
71
75
 
72
76
  ## IMMEDIATE ACTION: Write plan file, then call submit_plan
73
77
 
@@ -84,24 +88,24 @@ submit_plan({
84
88
  \`\`\`
85
89
 
86
90
  The user will see the plan rendered inline and can:
87
- - **Approve** \u2014 automatically switches to Build mode for implementation
88
- - **Start as goal** \u2014 approves the plan and enters goal mode so the agent keeps working toward the plan until judged complete, paused, or waiting for user input
89
- - **Request changes** \u2014 rejects the plan; the agent stops immediately and the user provides revision feedback in their next chat message
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
90
94
 
91
95
  ## Revision Workflow
92
96
 
93
- If the user requests changes, you will be stopped immediately. Wait for their next message \u2014 it will contain their revision feedback. When you receive it:
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:
94
98
  1. Use \`view\` to read the SAME plan file
95
99
  2. Use \`string_replace_lsp\` to make targeted edits based on feedback
96
100
  3. Use \`view\` to re-read the updated file
97
- 4. Call \`submit_plan\` again with the same \`path\` \u2014 editing the file alone does NOT resubmit it
101
+ 4. Call \`submit_plan\` again with the same \`path\` editing the file alone does NOT resubmit it
98
102
 
99
- 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 \u2014 do NOT rewrite the entire plan from scratch for small changes, and do NOT move the plan to a new file for a revision.
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.
100
104
 
101
105
  Do NOT start implementing until the plan is approved.
102
106
  `;
103
107
  }
104
- export {
105
- planModePrompt
106
- };
108
+ //#endregion
109
+ export { planModePrompt };
110
+
107
111
  //# sourceMappingURL=plan.js.map
@@ -1 +1 @@
1
- {"version":3,"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 plansDir = getLocalPlansRelativeDir();\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":"AAGA,SAAS,gCAAgC;AAMlC,SAAS,eAAe,MAAiC;AAC9D,QAAM,WAAW,yBAAyB;AAC1C,QAAM,cAAc,GAAG,QAAQ;AAE/B,SAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mFAa0E,QAAQ,eAAe,WAAW;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mDA8ClE,QAAQ,eAAe,WAAW;AAAA;AAAA,6DAExB,QAAQ;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,gCASrC,QAAQ;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,WAO7B,WAAW;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAqBtB;","names":[]}
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 plansDir = getLocalPlansRelativeDir();\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,MAAiC;CAC9D,MAAM,WAAW,yBAAyB;CAC1C,MAAM,cAAc,GAAG,SAAS;CAEhC,OAAO;;;;;;;;;;;;;mFAa0E,SAAS,cAAc,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;mDA8CnE,SAAS,cAAc,YAAY;;6DAEzB,SAAS;;;;;;;;;gCAStC,SAAS;;;;;;;WAO9B,YAAY;;;;;;;;;;;;;;;;;;;;;AAqBvB"}