wave-agent-sdk 0.5.0 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (148) hide show
  1. package/dist/agent.d.ts +7 -2
  2. package/dist/agent.d.ts.map +1 -1
  3. package/dist/agent.js +58 -74
  4. package/dist/constants/prompts.d.ts +18 -14
  5. package/dist/constants/prompts.d.ts.map +1 -1
  6. package/dist/constants/prompts.js +134 -54
  7. package/dist/constants/tools.d.ts +4 -1
  8. package/dist/constants/tools.d.ts.map +1 -1
  9. package/dist/constants/tools.js +4 -1
  10. package/dist/index.d.ts +1 -0
  11. package/dist/index.d.ts.map +1 -1
  12. package/dist/index.js +1 -0
  13. package/dist/managers/aiManager.d.ts +2 -5
  14. package/dist/managers/aiManager.d.ts.map +1 -1
  15. package/dist/managers/aiManager.js +59 -48
  16. package/dist/managers/backgroundTaskManager.d.ts.map +1 -1
  17. package/dist/managers/backgroundTaskManager.js +59 -53
  18. package/dist/managers/foregroundTaskManager.d.ts.map +1 -1
  19. package/dist/managers/foregroundTaskManager.js +3 -2
  20. package/dist/managers/mcpManager.d.ts.map +1 -1
  21. package/dist/managers/messageManager.d.ts +7 -3
  22. package/dist/managers/messageManager.d.ts.map +1 -1
  23. package/dist/managers/messageManager.js +28 -24
  24. package/dist/managers/permissionManager.d.ts.map +1 -1
  25. package/dist/managers/permissionManager.js +25 -15
  26. package/dist/managers/planManager.d.ts +1 -1
  27. package/dist/managers/planManager.d.ts.map +1 -1
  28. package/dist/managers/planManager.js +2 -2
  29. package/dist/managers/subagentManager.d.ts +4 -0
  30. package/dist/managers/subagentManager.d.ts.map +1 -1
  31. package/dist/managers/subagentManager.js +22 -14
  32. package/dist/managers/toolManager.d.ts +11 -0
  33. package/dist/managers/toolManager.d.ts.map +1 -1
  34. package/dist/managers/toolManager.js +20 -2
  35. package/dist/services/aiService.d.ts +0 -1
  36. package/dist/services/aiService.d.ts.map +1 -1
  37. package/dist/services/aiService.js +4 -140
  38. package/dist/services/memory.d.ts +0 -3
  39. package/dist/services/memory.d.ts.map +1 -1
  40. package/dist/services/memory.js +0 -59
  41. package/dist/services/session.d.ts +3 -1
  42. package/dist/services/session.d.ts.map +1 -1
  43. package/dist/services/session.js +16 -1
  44. package/dist/services/taskManager.d.ts +21 -0
  45. package/dist/services/taskManager.d.ts.map +1 -0
  46. package/dist/services/taskManager.js +158 -0
  47. package/dist/tools/askUserQuestion.d.ts.map +1 -1
  48. package/dist/tools/askUserQuestion.js +39 -25
  49. package/dist/tools/bashTool.d.ts.map +1 -1
  50. package/dist/tools/bashTool.js +7 -9
  51. package/dist/tools/editTool.d.ts.map +1 -1
  52. package/dist/tools/editTool.js +2 -1
  53. package/dist/tools/exitPlanMode.d.ts.map +1 -1
  54. package/dist/tools/exitPlanMode.js +25 -1
  55. package/dist/tools/globTool.d.ts.map +1 -1
  56. package/dist/tools/globTool.js +8 -2
  57. package/dist/tools/grepTool.d.ts.map +1 -1
  58. package/dist/tools/grepTool.js +17 -6
  59. package/dist/tools/lsTool.d.ts.map +1 -1
  60. package/dist/tools/lsTool.js +3 -1
  61. package/dist/tools/readTool.d.ts.map +1 -1
  62. package/dist/tools/readTool.js +16 -1
  63. package/dist/tools/taskManagementTools.d.ts +6 -0
  64. package/dist/tools/taskManagementTools.d.ts.map +1 -0
  65. package/dist/tools/taskManagementTools.js +453 -0
  66. package/dist/tools/taskOutputTool.d.ts.map +1 -1
  67. package/dist/tools/taskOutputTool.js +32 -8
  68. package/dist/tools/taskStopTool.d.ts.map +1 -1
  69. package/dist/tools/taskStopTool.js +7 -1
  70. package/dist/tools/taskTool.d.ts.map +1 -1
  71. package/dist/tools/taskTool.js +6 -1
  72. package/dist/tools/types.d.ts +9 -0
  73. package/dist/tools/types.d.ts.map +1 -1
  74. package/dist/tools/writeTool.d.ts.map +1 -1
  75. package/dist/tools/writeTool.js +9 -1
  76. package/dist/types/index.d.ts +1 -0
  77. package/dist/types/index.d.ts.map +1 -1
  78. package/dist/types/index.js +1 -0
  79. package/dist/types/messaging.d.ts +2 -8
  80. package/dist/types/messaging.d.ts.map +1 -1
  81. package/dist/types/processes.d.ts +11 -6
  82. package/dist/types/processes.d.ts.map +1 -1
  83. package/dist/types/tasks.d.ts +13 -0
  84. package/dist/types/tasks.d.ts.map +1 -0
  85. package/dist/types/tasks.js +1 -0
  86. package/dist/types/tools.d.ts +4 -1
  87. package/dist/types/tools.d.ts.map +1 -1
  88. package/dist/utils/builtinSubagents.d.ts.map +1 -1
  89. package/dist/utils/builtinSubagents.js +38 -1
  90. package/dist/utils/cacheControlUtils.d.ts.map +1 -1
  91. package/dist/utils/cacheControlUtils.js +18 -12
  92. package/dist/utils/constants.d.ts +0 -4
  93. package/dist/utils/constants.d.ts.map +1 -1
  94. package/dist/utils/constants.js +0 -4
  95. package/dist/utils/convertMessagesForAPI.js +2 -2
  96. package/dist/utils/messageOperations.d.ts +2 -30
  97. package/dist/utils/messageOperations.d.ts.map +1 -1
  98. package/dist/utils/messageOperations.js +4 -79
  99. package/dist/utils/nameGenerator.d.ts +1 -1
  100. package/dist/utils/nameGenerator.d.ts.map +1 -1
  101. package/dist/utils/nameGenerator.js +19 -3
  102. package/package.json +1 -1
  103. package/src/agent.ts +79 -84
  104. package/src/constants/prompts.ts +161 -65
  105. package/src/constants/tools.ts +4 -1
  106. package/src/index.ts +1 -0
  107. package/src/managers/aiManager.ts +79 -70
  108. package/src/managers/backgroundTaskManager.ts +53 -54
  109. package/src/managers/foregroundTaskManager.ts +3 -2
  110. package/src/managers/mcpManager.ts +6 -3
  111. package/src/managers/messageManager.ts +37 -26
  112. package/src/managers/permissionManager.ts +32 -21
  113. package/src/managers/planManager.ts +2 -2
  114. package/src/managers/subagentManager.ts +33 -14
  115. package/src/managers/toolManager.ts +32 -2
  116. package/src/services/aiService.ts +3 -145
  117. package/src/services/memory.ts +0 -72
  118. package/src/services/session.ts +21 -0
  119. package/src/services/taskManager.ts +188 -0
  120. package/src/tools/askUserQuestion.ts +51 -29
  121. package/src/tools/bashTool.ts +9 -15
  122. package/src/tools/editTool.ts +3 -1
  123. package/src/tools/exitPlanMode.ts +26 -2
  124. package/src/tools/globTool.ts +10 -2
  125. package/src/tools/grepTool.ts +17 -6
  126. package/src/tools/lsTool.ts +3 -1
  127. package/src/tools/readTool.ts +17 -1
  128. package/src/tools/taskManagementTools.ts +498 -0
  129. package/src/tools/taskOutputTool.ts +34 -12
  130. package/src/tools/taskStopTool.ts +7 -1
  131. package/src/tools/taskTool.ts +7 -1
  132. package/src/tools/types.ts +10 -0
  133. package/src/tools/writeTool.ts +9 -2
  134. package/src/types/index.ts +1 -0
  135. package/src/types/messaging.ts +1 -9
  136. package/src/types/processes.ts +13 -7
  137. package/src/types/tasks.ts +13 -0
  138. package/src/types/tools.ts +4 -1
  139. package/src/utils/builtinSubagents.ts +47 -1
  140. package/src/utils/cacheControlUtils.ts +26 -18
  141. package/src/utils/constants.ts +0 -5
  142. package/src/utils/convertMessagesForAPI.ts +2 -2
  143. package/src/utils/messageOperations.ts +5 -116
  144. package/src/utils/nameGenerator.ts +20 -3
  145. package/dist/tools/todoWriteTool.d.ts +0 -6
  146. package/dist/tools/todoWriteTool.d.ts.map +0 -1
  147. package/dist/tools/todoWriteTool.js +0 -220
  148. package/src/tools/todoWriteTool.ts +0 -257
package/dist/agent.d.ts CHANGED
@@ -46,7 +46,9 @@ export interface AgentOptions {
46
46
  }
47
47
  export interface AgentCallbacks extends MessageManagerCallbacks, BackgroundTaskManagerCallbacks, McpManagerCallbacks, SubagentManagerCallbacks {
48
48
  onTasksChange?: (tasks: BackgroundTask[]) => void;
49
+ onSessionTasksChange?: (tasks: import("./types/tasks.js").Task[]) => void;
49
50
  onPermissionModeChange?: (mode: PermissionMode) => void;
51
+ onSubagentLatestTotalTokensChange?: (subagentId: string, tokens: number) => void;
50
52
  onBackgroundCurrentTask?: () => void;
51
53
  }
52
54
  export declare class Agent {
@@ -68,6 +70,7 @@ export declare class Agent {
68
70
  private reversionManager;
69
71
  private memoryRuleManager;
70
72
  private liveConfigManager;
73
+ private taskManager;
71
74
  private foregroundTaskManager;
72
75
  private configurationService;
73
76
  private workdir;
@@ -262,8 +265,6 @@ export declare class Agent {
262
265
  path: string;
263
266
  mimeType: string;
264
267
  }>): Promise<void>;
265
- /** Save memory to project or user memory file */
266
- saveMemory(message: string, type: "project" | "user"): Promise<void>;
267
268
  /** Get all MCP server status */
268
269
  getMcpServers(): McpServerStatus[];
269
270
  /** Connect MCP server */
@@ -320,5 +321,9 @@ export declare class Agent {
320
321
  * @param mode - The current effective permission mode
321
322
  */
322
323
  private handlePlanModeTransition;
324
+ /**
325
+ * Get the current task list ID
326
+ */
327
+ get taskListId(): string;
323
328
  }
324
329
  //# sourceMappingURL=agent.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"agent.d.ts","sourceRoot":"","sources":["../src/agent.ts"],"names":[],"mappings":"AACA,OAAO,EAEL,KAAK,uBAAuB,EAC7B,MAAM,8BAA8B,CAAC;AAGtC,OAAO,EAEL,KAAK,wBAAwB,EAC9B,MAAM,+BAA+B,CAAC;AAEvC,OAAO,EAAc,KAAK,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAGhF,OAAO,EAEL,KAAK,8BAA8B,EACpC,MAAM,qCAAqC,CAAC;AAQ7C,OAAO,KAAK,EACV,YAAY,EACZ,kBAAkB,EAClB,WAAW,EACX,YAAY,EACb,MAAM,kBAAkB,CAAC;AAC1B,OAAO,KAAK,EACV,OAAO,EACP,MAAM,EACN,eAAe,EACf,aAAa,EACb,WAAW,EACX,KAAK,EACL,cAAc,EACd,kBAAkB,EAClB,cAAc,EACd,cAAc,EACf,MAAM,kBAAkB,CAAC;AAe1B,OAAO,EAAE,aAAa,EAAE,MAAM,QAAQ,CAAC;AAEvC;;;;;GAKG;AACH,MAAM,WAAW,YAAY;IAE3B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,cAAc,CAAC,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AAG,OAAO,CAAC,IAAI,CAAC;IAI1D;;OAEG;IACI,eAAe,IAAI,MAAM,GAAG,SAAS;IAI5C;;OAEG;IACI,eAAe,IAAI,MAAM,EAAE;IAIlC;;OAEG;IACU,eAAe,CAC1B,OAAO,EAAE,OAAO,wBAAwB,EAAE,qBAAqB,GAC9D,OAAO,CAAC,OAAO,wBAAwB,EAAE,kBAAkB,CAAC;IAI/D;;;OAGG;IACU,iBAAiB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAkC3D;;;OAGG;IACH,OAAO,CAAC,wBAAwB;IAgBhC;;OAEG;IACH,IAAW,UAAU,IAAI,MAAM,CAE9B;CACF"}
package/dist/agent.js CHANGED
@@ -3,7 +3,6 @@ import { MessageManager, } from "./managers/messageManager.js";
3
3
  import { AIManager } from "./managers/aiManager.js";
4
4
  import { ToolManager } from "./managers/toolManager.js";
5
5
  import { SubagentManager, } from "./managers/subagentManager.js";
6
- import * as memory from "./services/memory.js";
7
6
  import { McpManager } from "./managers/mcpManager.js";
8
7
  import { LspManager } from "./managers/lspManager.js";
9
8
  import { BashManager } from "./managers/bashManager.js";
@@ -19,6 +18,7 @@ import { MemoryRuleManager } from "./managers/MemoryRuleManager.js";
19
18
  import { LiveConfigManager } from "./managers/liveConfigManager.js";
20
19
  import { configValidator } from "./utils/configValidator.js";
21
20
  import { SkillManager } from "./managers/skillManager.js";
21
+ import { TaskManager } from "./services/taskManager.js";
22
22
  import { loadSessionFromJsonl, handleSessionRestoration, } from "./services/session.js";
23
23
  import { setGlobalLogger } from "./utils/globalLogger.js";
24
24
  import { ConfigurationService } from "./services/configurationService.js";
@@ -65,6 +65,39 @@ export class Agent {
65
65
  // Store options for dynamic configuration resolution
66
66
  this.options = options;
67
67
  this.foregroundTaskManager = new ForegroundTaskManager();
68
+ // Initialize memory rule manager
69
+ this.memoryRuleManager = new MemoryRuleManager({
70
+ workdir: this.workdir,
71
+ });
72
+ // Initialize MessageManager
73
+ this.messageManager = new MessageManager({
74
+ callbacks: {
75
+ ...callbacks,
76
+ onSessionIdChange: (sessionId) => {
77
+ // When session ID changes (e.g. due to compression),
78
+ // we update the task manager to use the root session ID
79
+ // to ensure the task list remains consistent.
80
+ this.taskManager.setTaskListId(this.messageManager.getRootSessionId());
81
+ callbacks.onSessionIdChange?.(sessionId);
82
+ },
83
+ onSubagentTaskStopRequested: (subagentId) => {
84
+ this.backgroundTaskManager.stopTask(subagentId);
85
+ },
86
+ },
87
+ workdir: this.workdir,
88
+ logger: this.logger,
89
+ memoryRuleManager: this.memoryRuleManager,
90
+ });
91
+ // Resolve taskListId once during construction to ensure stability
92
+ const resolvedTaskListId = this.configurationService.getEnvironmentVars().WAVE_TASK_LIST_ID ||
93
+ process.env.WAVE_TASK_LIST_ID ||
94
+ this.messageManager.getRootSessionId();
95
+ this.taskManager = new TaskManager(resolvedTaskListId);
96
+ this.taskManager.on("tasksChange", async () => {
97
+ const tasks = await this.taskManager.listTasks();
98
+ this.options.callbacks?.onSessionTasksChange?.(tasks);
99
+ });
100
+ // Initialize BackgroundTaskManager
68
101
  this.backgroundTaskManager = new BackgroundTaskManager({
69
102
  callbacks: {
70
103
  ...callbacks,
@@ -95,18 +128,7 @@ export class Agent {
95
128
  logger: this.logger,
96
129
  workdir: this.workdir,
97
130
  });
98
- // Initialize memory rule manager
99
- this.memoryRuleManager = new MemoryRuleManager({
100
- workdir: this.workdir,
101
- });
102
- // Initialize MessageManager
103
- this.messageManager = new MessageManager({
104
- callbacks,
105
- workdir: this.workdir,
106
- logger: this.logger,
107
- memoryRuleManager: this.memoryRuleManager,
108
- });
109
- // Initialize ReversionManager
131
+ // ReversionManager depends on MessageManager
110
132
  this.reversionManager = new ReversionManager(new ReversionService(this.messageManager.getTranscriptPath()));
111
133
  // Create a wrapper for canUseTool that triggers notification hooks
112
134
  const canUseToolWithNotification = options.canUseTool
@@ -154,6 +176,7 @@ export class Agent {
154
176
  reversionManager: this.reversionManager,
155
177
  permissionMode: options.permissionMode, // Let PermissionManager handle defaultMode resolution
156
178
  canUseToolCallback: canUseToolWithNotification,
179
+ taskManager: this.taskManager,
157
180
  backgroundTaskManager: this.backgroundTaskManager,
158
181
  foregroundTaskManager: this.foregroundTaskManager,
159
182
  }); // Initialize tool registry with permission support
@@ -177,6 +200,7 @@ export class Agent {
177
200
  onSubagentAssistantReasoningUpdated: callbacks.onSubagentAssistantReasoningUpdated,
178
201
  onSubagentToolBlockUpdated: callbacks.onSubagentToolBlockUpdated,
179
202
  onSubagentMessagesChange: callbacks.onSubagentMessagesChange,
203
+ onSubagentLatestTotalTokensChange: callbacks.onSubagentLatestTotalTokensChange,
180
204
  }, // Pass subagent callbacks for forwarding
181
205
  logger: this.logger,
182
206
  getGatewayConfig: () => this.getGatewayConfig(),
@@ -186,12 +210,14 @@ export class Agent {
186
210
  hookManager: this.hookManager,
187
211
  onUsageAdded: (usage) => this.addUsage(usage),
188
212
  backgroundTaskManager: this.backgroundTaskManager,
213
+ taskManager: this.taskManager,
189
214
  memoryRuleManager: this.memoryRuleManager,
190
215
  });
191
216
  // Initialize AI manager with resolved configuration
192
217
  this.aiManager = new AIManager({
193
218
  messageManager: this.messageManager,
194
219
  toolManager: this.toolManager,
220
+ taskManager: this.taskManager,
195
221
  logger: this.logger,
196
222
  backgroundTaskManager: this.backgroundTaskManager,
197
223
  hookManager: this.hookManager,
@@ -527,8 +553,14 @@ export class Agent {
527
553
  this.rebuildUsageFromMessages(sessionToRestore?.messages || []);
528
554
  // After main session is restored, restore any associated subagent sessions
529
555
  await this.restoreSubagentSessions(sessionToRestore?.messages || []);
530
- if (sessionToRestore)
556
+ if (sessionToRestore) {
531
557
  this.messageManager.initializeFromSession(sessionToRestore);
558
+ // Update task manager with the root session ID to ensure continuity across compressions
559
+ this.taskManager.setTaskListId(sessionToRestore.rootSessionId || sessionToRestore.id);
560
+ // After session is initialized, load tasks for the session
561
+ const tasks = await this.taskManager.listTasks();
562
+ this.options.callbacks?.onSessionTasksChange?.(tasks);
563
+ }
532
564
  }
533
565
  }
534
566
  /**
@@ -620,6 +652,11 @@ export class Agent {
620
652
  await this.restoreSubagentSessions(sessionData.messages);
621
653
  // 6. Initialize session state last
622
654
  this.messageManager.initializeFromSession(sessionData);
655
+ // Update task manager with the root session ID to ensure continuity across compressions
656
+ this.taskManager.setTaskListId(sessionData.rootSessionId || sessionData.id);
657
+ // 7. Load tasks for the restored session
658
+ const tasks = await this.taskManager.listTasks();
659
+ this.options.callbacks?.onSessionTasksChange?.(tasks);
623
660
  }
624
661
  abortAIMessage() {
625
662
  this.aiManager.abortAIMessage();
@@ -670,11 +707,6 @@ export class Agent {
670
707
  async backgroundCurrentTask() {
671
708
  await this.foregroundTaskManager.backgroundCurrentTask();
672
709
  this.options.callbacks?.onBackgroundCurrentTask?.();
673
- // If there was no foreground task (e.g. a tool that doesn't register one),
674
- // or even if there was, we should stop the AI recursion loop.
675
- if (!this.foregroundTaskManager.hasActiveTasks()) {
676
- this.aiManager.abortRecursion();
677
- }
678
710
  }
679
711
  /** Destroy managers, clean up resources */
680
712
  async destroy() {
@@ -805,60 +837,6 @@ export class Agent {
805
837
  // Loading state will be automatically updated by the useEffect that watches messages
806
838
  }
807
839
  }
808
- /** Save memory to project or user memory file */
809
- async saveMemory(message, type) {
810
- try {
811
- // Ensure the message starts with # for memory functions
812
- const formattedMessage = message.startsWith("#")
813
- ? message
814
- : `#${message}`;
815
- if (type === "project") {
816
- await memory.addMemory(formattedMessage, this.workdir);
817
- // Update internal state after successful save
818
- this._projectMemoryContent = await memory.readMemoryFile(this.workdir);
819
- }
820
- else {
821
- await memory.addUserMemory(formattedMessage);
822
- // Update internal state after successful save
823
- this._userMemoryContent = await memory.getUserMemoryContent();
824
- }
825
- // Add successful MemoryBlock to the last assistant message
826
- const memoryText = message.substring(1).trim();
827
- const typeLabel = type === "project" ? "Project Memory" : "User Memory";
828
- const storagePath = "AGENTS.md";
829
- const messages = this.messageManager.getMessages();
830
- const lastMessage = messages[messages.length - 1];
831
- if (lastMessage && lastMessage.role === "assistant") {
832
- lastMessage.blocks.push({
833
- type: "memory",
834
- content: `${typeLabel}: ${memoryText}`,
835
- isSuccess: true,
836
- memoryType: type,
837
- storagePath,
838
- });
839
- this.messageManager.setMessages(messages);
840
- }
841
- }
842
- catch (error) {
843
- // Add failed MemoryBlock to the last assistant message
844
- const memoryText = message.substring(1).trim();
845
- const typeLabel = type === "project" ? "Project Memory" : "User Memory";
846
- const storagePath = "AGENTS.md";
847
- const errorMessage = error instanceof Error ? error.message : String(error);
848
- const messages = this.messageManager.getMessages();
849
- const lastMessage = messages[messages.length - 1];
850
- if (lastMessage && lastMessage.role === "assistant") {
851
- lastMessage.blocks.push({
852
- type: "memory",
853
- content: `${typeLabel}: ${memoryText} - Error: ${errorMessage}`,
854
- isSuccess: false,
855
- memoryType: type,
856
- storagePath,
857
- });
858
- this.messageManager.setMessages(messages);
859
- }
860
- }
861
- }
862
840
  // ========== MCP Management Methods ==========
863
841
  /** Get all MCP server status */
864
842
  getMcpServers() {
@@ -980,7 +958,7 @@ export class Agent {
980
958
  handlePlanModeTransition(mode) {
981
959
  if (mode === "plan") {
982
960
  this.planManager
983
- .getOrGeneratePlanFilePath()
961
+ .getOrGeneratePlanFilePath(this.messageManager.getRootSessionId())
984
962
  .then(({ path }) => {
985
963
  this.logger?.debug("Plan file path generated", { path });
986
964
  this.permissionManager.setPlanFilePath(path);
@@ -993,4 +971,10 @@ export class Agent {
993
971
  this.permissionManager.setPlanFilePath(undefined);
994
972
  }
995
973
  }
974
+ /**
975
+ * Get the current task list ID
976
+ */
977
+ get taskListId() {
978
+ return this.taskManager.getTaskListId();
979
+ }
996
980
  }
@@ -1,20 +1,24 @@
1
+ import { ToolPlugin } from "../tools/types.js";
1
2
  export declare const BASE_SYSTEM_PROMPT = "You are an interactive CLI tool that helps users with software engineering tasks. Use the instructions below and the tools available to you to assist the user.\n\n# Doing tasks\nThe user will primarily request you perform software engineering tasks. This includes solving bugs, adding new functionality, refactoring code, explaining code, and more. For these tasks the following steps are recommended:\n- NEVER propose changes to code you haven't read. If a user asks about or wants you to modify a file, read it first. Understand existing code before suggesting modifications.\n- Be careful not to introduce security vulnerabilities such as command injection, XSS, SQL injection, and other OWASP top 10 vulnerabilities. If you notice that you wrote insecure code, immediately fix it.\n- Avoid over-engineering. Only make changes that are directly requested or clearly necessary. Keep solutions simple and focused.\n - Don't add features, refactor code, or make \"improvements\" beyond what was asked. A bug fix doesn't need surrounding code cleaned up. A simple feature doesn't need extra configurability. Don't add docstrings, comments, or type annotations to code you didn't change. Only add comments where the logic isn't self-evident.\n - Don't add error handling, fallbacks, or validation for scenarios that can't happen. Trust internal code and framework guarantees. Only validate at system boundaries (user input, external APIs). Don't use feature flags or backwards-compatibility shims when you can just change the code.\n - Don't create helpers, utilities, or abstractions for one-time operations. Don't design for hypothetical future requirements. The right amount of complexity is the minimum needed for the current task\u2014three similar lines of code is better than a premature abstraction.\n- Avoid backwards-compatibility hacks like renaming unused `_vars`, re-exporting types, adding `// removed` comments for removed code, etc. If something is unused, delete it completely.\n\n# Tool usage policy\n- You can call multiple tools in a single response. If you intend to call multiple tools and there are no dependencies between them, make all independent tool calls in parallel. Maximize use of parallel tool calls where possible to increase efficiency.\n- However, if some tool calls depend on previous calls to inform dependent values, do NOT call these tools in parallel and instead call them sequentially. For instance, if one operation must complete before another starts, run these operations sequentially instead. Never use placeholders or guess missing parameters in tool calls.\n- If the user specifies that they want you to run tools \"in parallel\", you MUST send a single message with multiple tool use content blocks.";
2
- export declare const TASK_MANAGEMENT_POLICY = "\n# Task Management\nYou have access to the TodoWrite tools to help you manage and plan tasks. Use these tools VERY frequently to ensure that you are tracking your tasks and giving the user visibility into your progress.\nThese tools are also EXTREMELY helpful for planning tasks, and for breaking down larger complex tasks into smaller steps. If you do not use this tool when planning, you may forget to do important tasks - and that is unacceptable.\nIt is critical that you mark todos as completed as soon as you are done with a task. Do not batch up multiple tasks before marking them as completed.";
3
- export declare const ASK_USER_POLICY = "\n# Asking questions as you work\nYou have access to the AskUserQuestion tool to ask the user questions when you need clarification, want to validate assumptions, or need to make a decision you're unsure about. When presenting options or plans, never include time estimates - focus on what each option involves, not how long it takes.";
4
- export declare const SUBAGENT_POLICY = "\n- When doing file search, prefer to use the Task tool in order to reduce context usage.\n- You should proactively use the Task tool with specialized agents when the task at hand matches the agent's description.\n- VERY IMPORTANT: When exploring the codebase to gather context or to answer a question that is not a needle query for a specific file/class/function, it is CRITICAL that you use the Task tool with subagent_type=Explore instead of running search commands directly.";
5
- export declare const FILE_TOOL_POLICY_PREFIX = "\n- Use specialized tools instead of bash commands when possible, as this provides a better user experience. For file operations, use dedicated tools:";
6
- export declare const READ_FILE_POLICY = " Read for reading files instead of cat/head/tail";
7
- export declare const EDIT_FILE_POLICY = " Edit/MultiEdit for editing instead of sed/awk";
8
- export declare const WRITE_FILE_POLICY = " Write for creating files instead of cat with heredoc or echo redirection";
9
- export declare const SEARCH_FILE_POLICY = " LS/Glob/Grep for searching and listing files instead of find/ls/grep";
10
- export declare const BASH_POLICY = "\n- Reserve bash tools exclusively for actual system commands and terminal operations that require shell execution. NEVER use bash echo or other command-line tools to communicate thoughts, explanations, or instructions to the user. Output all communication directly in your response text instead.\n- When making multiple bash tool calls, you MUST send a single message with multiple tools calls to run the calls in parallel. For example, if you need to run \"git status\" and \"git diff\", send a single message with two tool calls to run the calls in parallel.";
3
+ export declare const TASK_MANAGEMENT_POLICY = "\n# Task Management\nYou have access to the TaskCreate, TaskGet, TaskUpdate, and TaskList tools to help you manage and plan tasks. Use these tools VERY frequently to ensure that you are tracking your tasks and giving the user visibility into your progress.\nThese tools are also EXTREMELY helpful for planning tasks, and for breaking down larger complex tasks into smaller steps. If you do not use this tool when planning, you may forget to do important tasks - and that is unacceptable.\nIt is critical that you mark tasks as completed as soon as you are done with a task. Do not batch up multiple tasks before marking them as completed.";
4
+ export declare function buildPlanModePrompt(planFilePath: string, planExists: boolean): string;
11
5
  export declare const DEFAULT_SYSTEM_PROMPT = "You are an interactive CLI tool that helps users with software engineering tasks. Use the instructions below and the tools available to you to assist the user.\n\n# Doing tasks\nThe user will primarily request you perform software engineering tasks. This includes solving bugs, adding new functionality, refactoring code, explaining code, and more. For these tasks the following steps are recommended:\n- NEVER propose changes to code you haven't read. If a user asks about or wants you to modify a file, read it first. Understand existing code before suggesting modifications.\n- Be careful not to introduce security vulnerabilities such as command injection, XSS, SQL injection, and other OWASP top 10 vulnerabilities. If you notice that you wrote insecure code, immediately fix it.\n- Avoid over-engineering. Only make changes that are directly requested or clearly necessary. Keep solutions simple and focused.\n - Don't add features, refactor code, or make \"improvements\" beyond what was asked. A bug fix doesn't need surrounding code cleaned up. A simple feature doesn't need extra configurability. Don't add docstrings, comments, or type annotations to code you didn't change. Only add comments where the logic isn't self-evident.\n - Don't add error handling, fallbacks, or validation for scenarios that can't happen. Trust internal code and framework guarantees. Only validate at system boundaries (user input, external APIs). Don't use feature flags or backwards-compatibility shims when you can just change the code.\n - Don't create helpers, utilities, or abstractions for one-time operations. Don't design for hypothetical future requirements. The right amount of complexity is the minimum needed for the current task\u2014three similar lines of code is better than a premature abstraction.\n- Avoid backwards-compatibility hacks like renaming unused `_vars`, re-exporting types, adding `// removed` comments for removed code, etc. If something is unused, delete it completely.\n\n# Tool usage policy\n- You can call multiple tools in a single response. If you intend to call multiple tools and there are no dependencies between them, make all independent tool calls in parallel. Maximize use of parallel tool calls where possible to increase efficiency.\n- However, if some tool calls depend on previous calls to inform dependent values, do NOT call these tools in parallel and instead call them sequentially. For instance, if one operation must complete before another starts, run these operations sequentially instead. Never use placeholders or guess missing parameters in tool calls.\n- If the user specifies that they want you to run tools \"in parallel\", you MUST send a single message with multiple tool use content blocks.";
6
+ export declare const BASH_SUBAGENT_SYSTEM_PROMPT = "You are a command execution specialist. Your role is to execute bash commands efficiently and safely.\n\nGuidelines:\n- Execute commands precisely as instructed\n- For git operations, follow git safety protocols\n- Report command output clearly and concisely\n- If a command fails, explain the error and suggest solutions\n- Use command chaining (&&) for dependent operations\n- Quote paths with spaces properly\n- For clear communication, avoid using emojis\n\nComplete the requested operations efficiently.";
12
7
  export declare const GENERAL_PURPOSE_SYSTEM_PROMPT = "You are an agent. Given the user's message, you should use the tools available to complete the task. Do what has been asked; nothing more, nothing less. When you complete the task simply respond with a detailed writeup.\n\nYour strengths:\n- Searching for code, configurations, and patterns across large codebases\n- Analyzing multiple files to understand system architecture\n- Investigating complex questions that require exploring many files\n- Performing multi-step research tasks\n\nGuidelines:\n- For file searches: Use Grep or Glob when you need to search broadly. Use Read when you know the specific file path.\n- For analysis: Start broad and narrow down. Use multiple search strategies if the first doesn't yield results.\n- Be thorough: Check multiple locations, consider different naming conventions, look for related files.\n- NEVER create files unless they're absolutely necessary for achieving your goal. ALWAYS prefer editing an existing file to creating a new one.\n- NEVER proactively create documentation files (*.md) or README files. Only create documentation files if explicitly requested.\n- In your final response always share relevant file names and code snippets. Any file paths you return in your response MUST be absolute. Do NOT use relative paths.\n- For clear communication, avoid using emojis.";
8
+ export declare const PLAN_SUBAGENT_SYSTEM_PROMPT = "You are a software architect and planning specialist. Your role is to explore the codebase and design implementation plans.\n\n=== CRITICAL: READ-ONLY MODE - NO FILE MODIFICATIONS ===\nThis is a READ-ONLY planning task. You are STRICTLY PROHIBITED from:\n- Creating new files (no Write, touch, or file creation of any kind)\n- Modifying existing files (no Edit operations)\n- Deleting files (no rm or deletion)\n- Moving or copying files (no mv or cp)\n- Creating temporary files anywhere, including /tmp\n- Using redirect operators (>, >>, |) or heredocs to write to files\n- Running ANY commands that change system state\n\nYour role is EXCLUSIVELY to explore the codebase and design implementation plans. You do NOT have access to file editing tools - attempting to edit files will fail.\n\nYou will be provided with a set of requirements and optionally a perspective on how to approach the design process.\n\n## Your Process\n\n1. **Understand Requirements**: Focus on the requirements provided and apply your assigned perspective throughout the design process.\n\n2. **Explore Thoroughly**:\n - Read any files provided to you in the initial prompt\n - Find existing patterns and conventions using Glob, Grep, and Read\n - Understand the current architecture\n - Identify similar features as reference\n - Trace through relevant code paths\n - Use Bash ONLY for read-only operations (ls, git status, git log, git diff, find, cat, head, tail)\n - NEVER use Bash for: mkdir, touch, rm, cp, mv, git add, git commit, npm install, pip install, or any file creation/modification\n\n3. **Design Solution**:\n - Create implementation approach based on your assigned perspective\n - Consider trade-offs and architectural decisions\n - Follow existing patterns where appropriate\n\n4. **Detail the Plan**:\n - Provide step-by-step implementation strategy\n - Identify dependencies and sequencing\n - Anticipate potential challenges\n\n## Required Output\n\nEnd your response with:\n\n### Critical Files for Implementation\nList 3-5 files most critical for implementing this plan:\n- path/to/file1.ts - [Brief reason: e.g., \"Core logic to modify\"]\n- path/to/file2.ts - [Brief reason: e.g., \"Interfaces to implement\"]\n- path/to/file3.ts - [Brief reason: e.g., \"Pattern to follow\"]\n\nREMEMBER: You can ONLY explore and plan. You CANNOT and MUST NOT write, edit, or modify any files. You do NOT have access to file editing tools.";
13
9
  export declare const INIT_PROMPT = "Please analyze this codebase and create a AGENTS.md file, which will be given to future instances of Agent to operate in this repository.\n\nWhat to add:\n1. Commands that will be commonly used, such as how to build, lint, and run tests. Include the necessary commands to develop in this codebase, such as how to run a single test.\n2. High-level code architecture and structure so that future instances can be productive more quickly. Focus on the \"big picture\" architecture that requires reading multiple files to understand.\n\nUsage notes:\n- If there's already a AGENTS.md, suggest improvements to it.\n- When you make the initial AGENTS.md, do not repeat yourself and do not include obvious instructions like \"Provide helpful error messages to users\", \"Write unit tests for all new utilities\", \"Never include sensitive information (API keys, tokens) in code or commits\".\n- Avoid listing every component or file structure that can be easily discovered.\n- Don't include generic development practices.\n- If there are Cursor rules (in .cursor/rules/ or .cursorrules) or Copilot rules (in .github/copilot-instructions.md), make sure to include the important parts.\n- If there is a README.md, make sure to include the important parts.\n- Do not make up information such as \"Common Development Tasks\", \"Tips for Development\", \"Support and Documentation\" unless this is expressly included in other files that you read.\n- Be sure to prefix the file with the following text:\n\n```\n# AGENTS.md\n\nThis file provides guidance to Agent when working with code in this repository.\n```";
14
- export declare function buildSystemPrompt(basePrompt: string, tools: {
15
- name?: string;
16
- function?: {
17
- name: string;
10
+ export declare const COMPRESS_MESSAGES_SYSTEM_PROMPT = "You have been working on the task described above but have not yet completed it. Write a continuation summary that will allow you (or another instance of yourself) to resume work efficiently in a future context window where the conversation history will be replaced with this summary. Your summary should be structured, concise, and actionable. Include:\n1. Task Overview\nThe user's core request and success criteria\nAny clarifications or constraints they specified\n2. Current State\nWhat has been completed so far\nFiles created, modified, or analyzed (with paths if relevant)\nKey outputs or artifacts produced\n3. Important Discoveries\nTechnical constraints or requirements uncovered\nDecisions made and their rationale\nErrors encountered and how they were resolved\nWhat approaches were tried that didn't work (and why)\n4. Next Steps\nSpecific actions needed to complete the task\nAny blockers or open questions to resolve\nPriority order if multiple steps remain\n5. Context to Preserve\nUser preferences or style requirements\nDomain-specific details that aren't obvious\nAny promises made to the user\nBe concise but complete\u2014err on the side of including information that would prevent duplicate work or repeated mistakes. Write in a way that enables immediate resumption of the task.\nWrap your summary in <summary></summary> tags.";
11
+ export declare function buildSystemPrompt(basePrompt: string | undefined, tools: ToolPlugin[], options?: {
12
+ workdir?: string;
13
+ isGitRepo?: string;
14
+ platform?: string;
15
+ osVersion?: string;
16
+ today?: string;
17
+ memory?: string;
18
+ language?: string;
19
+ planMode?: {
20
+ planFilePath: string;
21
+ planExists: boolean;
18
22
  };
19
- }[]): string;
23
+ }): string;
20
24
  //# sourceMappingURL=prompts.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"prompts.d.ts","sourceRoot":"","sources":["../../src/constants/prompts.ts"],"names":[],"mappings":"AAcA,eAAO,MAAM,kBAAkB,ksFAe8G,CAAC;AAE9I,eAAO,MAAM,sBAAsB,+lBAImH,CAAC;AAEvJ,eAAO,MAAM,eAAe,mVAEgS,CAAC;AAE7T,eAAO,MAAM,eAAe,meAG0P,CAAC;AAEvR,eAAO,MAAM,uBAAuB,2JAA2J,CAAC;AAChM,eAAO,MAAM,gBAAgB,qDAAkE,CAAC;AAChG,eAAO,MA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E,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE;QACT,YAAY,EAAE,MAAM,CAAC;QACrB,UAAU,EAAE,OAAO,CAAC;KACrB,CAAC;CACE,GACL,MAAM,CAmDR"}
@@ -1,4 +1,4 @@
1
- import { ASK_USER_QUESTION_TOOL_NAME, BASH_TOOL_NAME, EDIT_TOOL_NAME, GLOB_TOOL_NAME, GREP_TOOL_NAME, LS_TOOL_NAME, MULTI_EDIT_TOOL_NAME, READ_TOOL_NAME, TASK_TOOL_NAME, TODO_WRITE_TOOL_NAME, WRITE_TOOL_NAME, } from "./tools.js";
1
+ import { ASK_USER_QUESTION_TOOL_NAME, BASH_TOOL_NAME, EDIT_TOOL_NAME, GLOB_TOOL_NAME, GREP_TOOL_NAME, READ_TOOL_NAME, TASK_CREATE_TOOL_NAME, TASK_GET_TOOL_NAME, TASK_UPDATE_TOOL_NAME, TASK_LIST_TOOL_NAME, WRITE_TOOL_NAME, } from "./tools.js";
2
2
  export const BASE_SYSTEM_PROMPT = `You are an interactive CLI tool that helps users with software engineering tasks. Use the instructions below and the tools available to you to assist the user.
3
3
 
4
4
  # Doing tasks
@@ -17,25 +17,33 @@ The user will primarily request you perform software engineering tasks. This inc
17
17
  - If the user specifies that they want you to run tools "in parallel", you MUST send a single message with multiple tool use content blocks.`;
18
18
  export const TASK_MANAGEMENT_POLICY = `
19
19
  # Task Management
20
- You have access to the ${TODO_WRITE_TOOL_NAME} tools to help you manage and plan tasks. Use these tools VERY frequently to ensure that you are tracking your tasks and giving the user visibility into your progress.
20
+ You have access to the ${TASK_CREATE_TOOL_NAME}, ${TASK_GET_TOOL_NAME}, ${TASK_UPDATE_TOOL_NAME}, and ${TASK_LIST_TOOL_NAME} tools to help you manage and plan tasks. Use these tools VERY frequently to ensure that you are tracking your tasks and giving the user visibility into your progress.
21
21
  These tools are also EXTREMELY helpful for planning tasks, and for breaking down larger complex tasks into smaller steps. If you do not use this tool when planning, you may forget to do important tasks - and that is unacceptable.
22
- It is critical that you mark todos as completed as soon as you are done with a task. Do not batch up multiple tasks before marking them as completed.`;
23
- export const ASK_USER_POLICY = `
24
- # Asking questions as you work
25
- You have access to the ${ASK_USER_QUESTION_TOOL_NAME} tool to ask the user questions when you need clarification, want to validate assumptions, or need to make a decision you're unsure about. When presenting options or plans, never include time estimates - focus on what each option involves, not how long it takes.`;
26
- export const SUBAGENT_POLICY = `
27
- - When doing file search, prefer to use the ${TASK_TOOL_NAME} tool in order to reduce context usage.
28
- - You should proactively use the ${TASK_TOOL_NAME} tool with specialized agents when the task at hand matches the agent's description.
29
- - VERY IMPORTANT: When exploring the codebase to gather context or to answer a question that is not a needle query for a specific file/class/function, it is CRITICAL that you use the ${TASK_TOOL_NAME} tool with subagent_type=Explore instead of running search commands directly.`;
30
- export const FILE_TOOL_POLICY_PREFIX = `\n- Use specialized tools instead of bash commands when possible, as this provides a better user experience. For file operations, use dedicated tools:`;
31
- export const READ_FILE_POLICY = ` ${READ_TOOL_NAME} for reading files instead of cat/head/tail`;
32
- export const EDIT_FILE_POLICY = ` ${EDIT_TOOL_NAME}/${MULTI_EDIT_TOOL_NAME} for editing instead of sed/awk`;
33
- export const WRITE_FILE_POLICY = ` ${WRITE_TOOL_NAME} for creating files instead of cat with heredoc or echo redirection`;
34
- export const SEARCH_FILE_POLICY = ` ${LS_TOOL_NAME}/${GLOB_TOOL_NAME}/${GREP_TOOL_NAME} for searching and listing files instead of find/ls/grep`;
35
- export const BASH_POLICY = `
36
- - Reserve bash tools exclusively for actual system commands and terminal operations that require shell execution. NEVER use bash echo or other command-line tools to communicate thoughts, explanations, or instructions to the user. Output all communication directly in your response text instead.
37
- - When making multiple bash tool calls, you MUST send a single message with multiple tools calls to run the calls in parallel. For example, if you need to run "git status" and "git diff", send a single message with two tool calls to run the calls in parallel.`;
22
+ It is critical that you mark tasks as completed as soon as you are done with a task. Do not batch up multiple tasks before marking them as completed.`;
23
+ export function buildPlanModePrompt(planFilePath, planExists) {
24
+ const planFileInfo = planExists
25
+ ? `A plan file already exists at ${planFilePath}. You can read it and make incremental edits using the ${EDIT_TOOL_NAME} tool if you need to.`
26
+ : `No plan file exists yet. You should create your plan at ${planFilePath} using the ${WRITE_TOOL_NAME} tool if you need to.`;
27
+ return `Plan mode is active. The user indicated that they do not want you to execute yet -- you MUST NOT make any edits, run any non-readonly tools (including changing configs or making commits), or otherwise make any changes to the system. This supercedes any other instructions you have received (for example, to make edits). Instead, you should:
28
+
29
+ ## Plan File Info:
30
+ ${planFileInfo}
31
+ You should build your plan incrementally by writing to or editing this file. NOTE that this is the only file you are allowed to edit - other than this you are only allowed to take READ-ONLY actions.
32
+ Answer the user's query comprehensively. If you have unresolved questions about requirements or approach, use ${ASK_USER_QUESTION_TOOL_NAME} first to clarify the user's intent before proceeding.`;
33
+ }
38
34
  export const DEFAULT_SYSTEM_PROMPT = BASE_SYSTEM_PROMPT;
35
+ export const BASH_SUBAGENT_SYSTEM_PROMPT = `You are a command execution specialist. Your role is to execute bash commands efficiently and safely.
36
+
37
+ Guidelines:
38
+ - Execute commands precisely as instructed
39
+ - For git operations, follow git safety protocols
40
+ - Report command output clearly and concisely
41
+ - If a command fails, explain the error and suggest solutions
42
+ - Use command chaining (&&) for dependent operations
43
+ - Quote paths with spaces properly
44
+ - For clear communication, avoid using emojis
45
+
46
+ Complete the requested operations efficiently.`;
39
47
  export const GENERAL_PURPOSE_SYSTEM_PROMPT = `You are an agent. Given the user's message, you should use the tools available to complete the task. Do what has been asked; nothing more, nothing less. When you complete the task simply respond with a detailed writeup.
40
48
 
41
49
  Your strengths:
@@ -45,13 +53,63 @@ Your strengths:
45
53
  - Performing multi-step research tasks
46
54
 
47
55
  Guidelines:
48
- - For file searches: Use Grep or Glob when you need to search broadly. Use Read when you know the specific file path.
56
+ - For file searches: Use ${GREP_TOOL_NAME} or ${GLOB_TOOL_NAME} when you need to search broadly. Use ${READ_TOOL_NAME} when you know the specific file path.
49
57
  - For analysis: Start broad and narrow down. Use multiple search strategies if the first doesn't yield results.
50
58
  - Be thorough: Check multiple locations, consider different naming conventions, look for related files.
51
59
  - NEVER create files unless they're absolutely necessary for achieving your goal. ALWAYS prefer editing an existing file to creating a new one.
52
60
  - NEVER proactively create documentation files (*.md) or README files. Only create documentation files if explicitly requested.
53
61
  - In your final response always share relevant file names and code snippets. Any file paths you return in your response MUST be absolute. Do NOT use relative paths.
54
62
  - For clear communication, avoid using emojis.`;
63
+ export const PLAN_SUBAGENT_SYSTEM_PROMPT = `You are a software architect and planning specialist. Your role is to explore the codebase and design implementation plans.
64
+
65
+ === CRITICAL: READ-ONLY MODE - NO FILE MODIFICATIONS ===
66
+ This is a READ-ONLY planning task. You are STRICTLY PROHIBITED from:
67
+ - Creating new files (no Write, touch, or file creation of any kind)
68
+ - Modifying existing files (no Edit operations)
69
+ - Deleting files (no rm or deletion)
70
+ - Moving or copying files (no mv or cp)
71
+ - Creating temporary files anywhere, including /tmp
72
+ - Using redirect operators (>, >>, |) or heredocs to write to files
73
+ - Running ANY commands that change system state
74
+
75
+ Your role is EXCLUSIVELY to explore the codebase and design implementation plans. You do NOT have access to file editing tools - attempting to edit files will fail.
76
+
77
+ You will be provided with a set of requirements and optionally a perspective on how to approach the design process.
78
+
79
+ ## Your Process
80
+
81
+ 1. **Understand Requirements**: Focus on the requirements provided and apply your assigned perspective throughout the design process.
82
+
83
+ 2. **Explore Thoroughly**:
84
+ - Read any files provided to you in the initial prompt
85
+ - Find existing patterns and conventions using ${GLOB_TOOL_NAME}, ${GREP_TOOL_NAME}, and ${READ_TOOL_NAME}
86
+ - Understand the current architecture
87
+ - Identify similar features as reference
88
+ - Trace through relevant code paths
89
+ - Use ${BASH_TOOL_NAME} ONLY for read-only operations (ls, git status, git log, git diff, find, cat, head, tail)
90
+ - NEVER use ${BASH_TOOL_NAME} for: mkdir, touch, rm, cp, mv, git add, git commit, npm install, pip install, or any file creation/modification
91
+
92
+ 3. **Design Solution**:
93
+ - Create implementation approach based on your assigned perspective
94
+ - Consider trade-offs and architectural decisions
95
+ - Follow existing patterns where appropriate
96
+
97
+ 4. **Detail the Plan**:
98
+ - Provide step-by-step implementation strategy
99
+ - Identify dependencies and sequencing
100
+ - Anticipate potential challenges
101
+
102
+ ## Required Output
103
+
104
+ End your response with:
105
+
106
+ ### Critical Files for Implementation
107
+ List 3-5 files most critical for implementing this plan:
108
+ - path/to/file1.ts - [Brief reason: e.g., "Core logic to modify"]
109
+ - path/to/file2.ts - [Brief reason: e.g., "Interfaces to implement"]
110
+ - path/to/file3.ts - [Brief reason: e.g., "Pattern to follow"]
111
+
112
+ REMEMBER: You can ONLY explore and plan. You CANNOT and MUST NOT write, edit, or modify any files. You do NOT have access to file editing tools.`;
55
113
  export const INIT_PROMPT = `Please analyze this codebase and create a AGENTS.md file, which will be given to future instances of Agent to operate in this repository.
56
114
 
57
115
  What to add:
@@ -73,46 +131,68 @@ Usage notes:
73
131
 
74
132
  This file provides guidance to Agent when working with code in this repository.
75
133
  \`\`\``;
76
- export function buildSystemPrompt(basePrompt, tools) {
77
- let prompt = basePrompt;
78
- const toolNames = new Set(tools.map((t) => t.function?.name || t.name).filter(Boolean));
79
- if (toolNames.has(TODO_WRITE_TOOL_NAME)) {
134
+ export const COMPRESS_MESSAGES_SYSTEM_PROMPT = `You have been working on the task described above but have not yet completed it. Write a continuation summary that will allow you (or another instance of yourself) to resume work efficiently in a future context window where the conversation history will be replaced with this summary. Your summary should be structured, concise, and actionable. Include:
135
+ 1. Task Overview
136
+ The user's core request and success criteria
137
+ Any clarifications or constraints they specified
138
+ 2. Current State
139
+ What has been completed so far
140
+ Files created, modified, or analyzed (with paths if relevant)
141
+ Key outputs or artifacts produced
142
+ 3. Important Discoveries
143
+ Technical constraints or requirements uncovered
144
+ Decisions made and their rationale
145
+ Errors encountered and how they were resolved
146
+ What approaches were tried that didn't work (and why)
147
+ 4. Next Steps
148
+ Specific actions needed to complete the task
149
+ Any blockers or open questions to resolve
150
+ Priority order if multiple steps remain
151
+ 5. Context to Preserve
152
+ User preferences or style requirements
153
+ Domain-specific details that aren't obvious
154
+ Any promises made to the user
155
+ Be concise but complete—err on the side of including information that would prevent duplicate work or repeated mistakes. Write in a way that enables immediate resumption of the task.
156
+ Wrap your summary in <summary></summary> tags.`;
157
+ export function buildSystemPrompt(basePrompt, tools, options = {}) {
158
+ let prompt = basePrompt || DEFAULT_SYSTEM_PROMPT;
159
+ const toolNames = new Set(tools.map((t) => t.name));
160
+ if (toolNames.has(TASK_CREATE_TOOL_NAME) ||
161
+ toolNames.has(TASK_GET_TOOL_NAME) ||
162
+ toolNames.has(TASK_UPDATE_TOOL_NAME) ||
163
+ toolNames.has(TASK_LIST_TOOL_NAME)) {
80
164
  prompt += TASK_MANAGEMENT_POLICY;
81
165
  }
82
- if (toolNames.has(ASK_USER_QUESTION_TOOL_NAME)) {
83
- prompt += ASK_USER_POLICY;
166
+ for (const tool of tools) {
167
+ if (tool.prompt) {
168
+ const toolContext = {
169
+ workdir: options.workdir || "",
170
+ taskManager: undefined, // Context might not be fully available here
171
+ };
172
+ prompt += tool.prompt(toolContext);
173
+ }
84
174
  }
85
- if (toolNames.has(TASK_TOOL_NAME)) {
86
- prompt += SUBAGENT_POLICY;
175
+ if (options.language) {
176
+ prompt += `\n\n# Language\nAlways respond in ${options.language}. Technical terms (e.g., code, tool names, file paths) should remain in their original language or English where appropriate.`;
87
177
  }
88
- if (toolNames.has(READ_TOOL_NAME) ||
89
- toolNames.has(EDIT_TOOL_NAME) ||
90
- toolNames.has(MULTI_EDIT_TOOL_NAME) ||
91
- toolNames.has(WRITE_TOOL_NAME) ||
92
- toolNames.has(LS_TOOL_NAME) ||
93
- toolNames.has(GLOB_TOOL_NAME) ||
94
- toolNames.has(GREP_TOOL_NAME)) {
95
- const parts = [];
96
- if (toolNames.has(READ_TOOL_NAME)) {
97
- parts.push(READ_FILE_POLICY);
98
- }
99
- if (toolNames.has(EDIT_TOOL_NAME) || toolNames.has(MULTI_EDIT_TOOL_NAME)) {
100
- parts.push(EDIT_FILE_POLICY);
101
- }
102
- if (toolNames.has(WRITE_TOOL_NAME)) {
103
- parts.push(WRITE_FILE_POLICY);
104
- }
105
- if (toolNames.has(LS_TOOL_NAME) ||
106
- toolNames.has(GLOB_TOOL_NAME) ||
107
- toolNames.has(GREP_TOOL_NAME)) {
108
- parts.push(SEARCH_FILE_POLICY);
109
- }
110
- if (parts.length > 0) {
111
- prompt += FILE_TOOL_POLICY_PREFIX + parts.join(",") + ".";
112
- }
178
+ if (options.planMode) {
179
+ prompt += `\n\n${buildPlanModePrompt(options.planMode.planFilePath, options.planMode.planExists)}`;
180
+ }
181
+ if (options.workdir) {
182
+ prompt += `
183
+
184
+ Here is useful information about the environment you are running in:
185
+ <env>
186
+ Working directory: ${options.workdir}
187
+ Is directory a git repo: ${options.isGitRepo || "No"}
188
+ Platform: ${options.platform || ""}
189
+ OS Version: ${options.osVersion || ""}
190
+ Today's date: ${options.today || new Date().toISOString().split("T")[0]}
191
+ </env>
192
+ `;
113
193
  }
114
- if (toolNames.has(BASH_TOOL_NAME)) {
115
- prompt += BASH_POLICY;
194
+ if (options.memory && options.memory.trim()) {
195
+ prompt += `\n## Memory Context\n\nThe following is important context and memory from previous interactions:\n\n${options.memory}`;
116
196
  }
117
197
  return prompt;
118
198
  }
@@ -13,6 +13,9 @@ export declare const MULTI_EDIT_TOOL_NAME = "MultiEdit";
13
13
  export declare const READ_TOOL_NAME = "Read";
14
14
  export declare const SKILL_TOOL_NAME = "Skill";
15
15
  export declare const TASK_TOOL_NAME = "Task";
16
- export declare const TODO_WRITE_TOOL_NAME = "TodoWrite";
16
+ export declare const TASK_CREATE_TOOL_NAME = "TaskCreate";
17
+ export declare const TASK_GET_TOOL_NAME = "TaskGet";
18
+ export declare const TASK_UPDATE_TOOL_NAME = "TaskUpdate";
19
+ export declare const TASK_LIST_TOOL_NAME = "TaskList";
17
20
  export declare const WRITE_TOOL_NAME = "Write";
18
21
  //# sourceMappingURL=tools.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"tools.d.ts","sourceRoot":"","sources":["../../src/constants/tools.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,2BAA2B,oBAAoB,CAAC;AAC7D,eAAO,MAAM,cAAc,SAAS,CAAC;AACrC,eAAO,MAAM,qBAAqB,eAAe,CAAC;AAClD,eAAO,MAAM,mBAAmB,aAAa,CAAC;AAC9C,eAAO,MAAM,qBAAqB,WAAW,CAAC;AAC9C,eAAO,MAAM,cAAc,SAAS,CAAC;AACrC,eAAO,MAAM,wBAAwB,iBAAiB,CAAC;AACvD,eAAO,MAAM,cAAc,SAAS,CAAC;AACrC,eAAO,MAAM,cAAc,SAAS,CAAC;AACrC,eAAO,MAAM,aAAa,QAAQ,CAAC;AACnC,eAAO,MAAM,YAAY,OAAO,CAAC;AACjC,eAAO,MAAM,oBAAoB,cAAc,CAAC;AAChD,eAAO,MAAM,cAAc,SAAS,CAAC;AACrC,eAAO,MAAM,eAAe,UAAU,CAAC;AACvC,eAAO,MAAM,cAAc,SAAS,CAAC;AACrC,eAAO,MAAM,oBAAoB,cAAc,CAAC;AAChD,eAAO,MAAM,eAAe,UAAU,CAAC"}
1
+ {"version":3,"file":"tools.d.ts","sourceRoot":"","sources":["../../src/constants/tools.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,2BAA2B,oBAAoB,CAAC;AAC7D,eAAO,MAAM,cAAc,SAAS,CAAC;AACrC,eAAO,MAAM,qBAAqB,eAAe,CAAC;AAClD,eAAO,MAAM,mBAAmB,aAAa,CAAC;AAC9C,eAAO,MAAM,qBAAqB,WAAW,CAAC;AAC9C,eAAO,MAAM,cAAc,SAAS,CAAC;AACrC,eAAO,MAAM,wBAAwB,iBAAiB,CAAC;AACvD,eAAO,MAAM,cAAc,SAAS,CAAC;AACrC,eAAO,MAAM,cAAc,SAAS,CAAC;AACrC,eAAO,MAAM,aAAa,QAAQ,CAAC;AACnC,eAAO,MAAM,YAAY,OAAO,CAAC;AACjC,eAAO,MAAM,oBAAoB,cAAc,CAAC;AAChD,eAAO,MAAM,cAAc,SAAS,CAAC;AACrC,eAAO,MAAM,eAAe,UAAU,CAAC;AACvC,eAAO,MAAM,cAAc,SAAS,CAAC;AACrC,eAAO,MAAM,qBAAqB,eAAe,CAAC;AAClD,eAAO,MAAM,kBAAkB,YAAY,CAAC;AAC5C,eAAO,MAAM,qBAAqB,eAAe,CAAC;AAClD,eAAO,MAAM,mBAAmB,aAAa,CAAC;AAC9C,eAAO,MAAM,eAAe,UAAU,CAAC"}
@@ -13,5 +13,8 @@ export const MULTI_EDIT_TOOL_NAME = "MultiEdit";
13
13
  export const READ_TOOL_NAME = "Read";
14
14
  export const SKILL_TOOL_NAME = "Skill";
15
15
  export const TASK_TOOL_NAME = "Task";
16
- export const TODO_WRITE_TOOL_NAME = "TodoWrite";
16
+ export const TASK_CREATE_TOOL_NAME = "TaskCreate";
17
+ export const TASK_GET_TOOL_NAME = "TaskGet";
18
+ export const TASK_UPDATE_TOOL_NAME = "TaskUpdate";
19
+ export const TASK_LIST_TOOL_NAME = "TaskList";
17
20
  export const WRITE_TOOL_NAME = "Write";