wave-agent-sdk 0.6.1 → 0.6.3

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 (73) hide show
  1. package/dist/agent.d.ts +0 -5
  2. package/dist/agent.d.ts.map +1 -1
  3. package/dist/agent.js +3 -67
  4. package/dist/constants/subagents.d.ts +5 -0
  5. package/dist/constants/subagents.d.ts.map +1 -0
  6. package/dist/constants/subagents.js +4 -0
  7. package/dist/managers/aiManager.d.ts.map +1 -1
  8. package/dist/managers/aiManager.js +9 -25
  9. package/dist/managers/backgroundTaskManager.d.ts.map +1 -1
  10. package/dist/managers/backgroundTaskManager.js +4 -0
  11. package/dist/managers/messageManager.d.ts +0 -18
  12. package/dist/managers/messageManager.d.ts.map +1 -1
  13. package/dist/managers/messageManager.js +1 -36
  14. package/dist/managers/reversionManager.d.ts.map +1 -1
  15. package/dist/managers/reversionManager.js +23 -2
  16. package/dist/managers/slashCommandManager.js +1 -1
  17. package/dist/managers/subagentManager.d.ts +4 -14
  18. package/dist/managers/subagentManager.d.ts.map +1 -1
  19. package/dist/managers/subagentManager.js +35 -109
  20. package/dist/{constants/prompts.d.ts → prompts/index.d.ts} +7 -8
  21. package/dist/prompts/index.d.ts.map +1 -0
  22. package/dist/{constants/prompts.js → prompts/index.js} +127 -11
  23. package/dist/services/aiService.js +1 -1
  24. package/dist/services/taskManager.d.ts +5 -1
  25. package/dist/services/taskManager.d.ts.map +1 -1
  26. package/dist/services/taskManager.js +6 -0
  27. package/dist/tools/bashTool.d.ts.map +1 -1
  28. package/dist/tools/bashTool.js +34 -29
  29. package/dist/tools/exitPlanMode.js +1 -1
  30. package/dist/tools/taskManagementTools.d.ts.map +1 -1
  31. package/dist/tools/taskManagementTools.js +8 -0
  32. package/dist/tools/taskTool.d.ts.map +1 -1
  33. package/dist/tools/taskTool.js +32 -2
  34. package/dist/tools/types.d.ts +2 -0
  35. package/dist/tools/types.d.ts.map +1 -1
  36. package/dist/types/messaging.d.ts +1 -11
  37. package/dist/types/messaging.d.ts.map +1 -1
  38. package/dist/types/processes.d.ts +5 -0
  39. package/dist/types/processes.d.ts.map +1 -1
  40. package/dist/utils/builtinSubagents.d.ts.map +1 -1
  41. package/dist/utils/builtinSubagents.js +28 -50
  42. package/dist/utils/editUtils.d.ts.map +1 -1
  43. package/dist/utils/editUtils.js +2 -2
  44. package/dist/utils/gitUtils.d.ts +7 -0
  45. package/dist/utils/gitUtils.d.ts.map +1 -0
  46. package/dist/utils/gitUtils.js +24 -0
  47. package/dist/utils/messageOperations.d.ts +1 -23
  48. package/dist/utils/messageOperations.d.ts.map +1 -1
  49. package/dist/utils/messageOperations.js +0 -49
  50. package/package.json +1 -1
  51. package/src/agent.ts +3 -89
  52. package/src/constants/subagents.ts +4 -0
  53. package/src/managers/aiManager.ts +9 -25
  54. package/src/managers/backgroundTaskManager.ts +5 -0
  55. package/src/managers/messageManager.ts +0 -80
  56. package/src/managers/reversionManager.ts +26 -2
  57. package/src/managers/slashCommandManager.ts +1 -1
  58. package/src/managers/subagentManager.ts +42 -145
  59. package/src/{constants/prompts.ts → prompts/index.ts} +136 -13
  60. package/src/services/aiService.ts +1 -1
  61. package/src/services/taskManager.ts +8 -1
  62. package/src/tools/bashTool.ts +35 -30
  63. package/src/tools/exitPlanMode.ts +1 -1
  64. package/src/tools/taskManagementTools.ts +18 -0
  65. package/src/tools/taskTool.ts +39 -1
  66. package/src/tools/types.ts +2 -0
  67. package/src/types/messaging.ts +0 -12
  68. package/src/types/processes.ts +5 -0
  69. package/src/utils/builtinSubagents.ts +41 -51
  70. package/src/utils/editUtils.ts +2 -6
  71. package/src/utils/gitUtils.ts +24 -0
  72. package/src/utils/messageOperations.ts +1 -93
  73. package/dist/constants/prompts.d.ts.map +0 -1
@@ -8,7 +8,6 @@ export class SubagentManager {
8
8
  this.cachedConfigurations = null;
9
9
  this.workdir = options.workdir;
10
10
  this.parentToolManager = options.parentToolManager;
11
- this.parentMessageManager = options.parentMessageManager;
12
11
  this.taskManager = options.taskManager;
13
12
  this.callbacks = options.callbacks; // Store SubagentManagerCallbacks
14
13
  this.logger = options.logger;
@@ -56,7 +55,7 @@ export class SubagentManager {
56
55
  /**
57
56
  * Create a new subagent instance with isolated managers
58
57
  */
59
- async createInstance(configuration, parameters, runInBackground) {
58
+ async createInstance(configuration, parameters, runInBackground, onUpdate) {
60
59
  if (!this.parentToolManager) {
61
60
  throw new Error("SubagentManager not properly initialized - call initialize() first");
62
61
  }
@@ -120,11 +119,11 @@ export class SubagentManager {
120
119
  toolManager,
121
120
  status: "initializing",
122
121
  messages: [],
122
+ lastTools: [], // Initialize lastTools
123
123
  subagentType: parameters.subagent_type, // Store the subagent type
124
+ onUpdate,
124
125
  };
125
126
  this.instances.set(subagentId, instance);
126
- // Create subagent block in parent message manager
127
- this.parentMessageManager.addSubagentBlock(subagentId, configuration.name, messageManager.getSessionId(), configuration, "active", parameters, runInBackground);
128
127
  return instance;
129
128
  }
130
129
  /**
@@ -141,9 +140,6 @@ export class SubagentManager {
141
140
  }
142
141
  // Set status to active and update parent
143
142
  this.updateInstanceStatus(instance.subagentId, "active");
144
- this.parentMessageManager.updateSubagentBlock(instance.subagentId, {
145
- status: "active",
146
- });
147
143
  if (runInBackground && this.backgroundTaskManager) {
148
144
  const taskId = this.backgroundTaskManager.generateId();
149
145
  const startTime = Date.now();
@@ -155,7 +151,11 @@ export class SubagentManager {
155
151
  description: instance.configuration.description,
156
152
  stdout: "",
157
153
  stderr: "",
158
- onStop: () => instance.aiManager.abortAIMessage(),
154
+ subagentId: instance.subagentId,
155
+ onStop: () => {
156
+ instance.aiManager.abortAIMessage();
157
+ this.cleanupInstance(instance.subagentId);
158
+ },
159
159
  });
160
160
  instance.backgroundTaskId = taskId;
161
161
  // Execute in background
@@ -187,9 +187,6 @@ export class SubagentManager {
187
187
  }
188
188
  catch (error) {
189
189
  this.updateInstanceStatus(instance.subagentId, "error");
190
- this.parentMessageManager.updateSubagentBlock(instance.subagentId, {
191
- status: "error",
192
- });
193
190
  throw error;
194
191
  }
195
192
  }
@@ -211,13 +208,13 @@ export class SubagentManager {
211
208
  description: instance.configuration.description,
212
209
  stdout: "",
213
210
  stderr: "",
214
- onStop: () => instance.aiManager.abortAIMessage(),
211
+ subagentId: instance.subagentId,
212
+ onStop: () => {
213
+ instance.aiManager.abortAIMessage();
214
+ this.cleanupInstance(instance.subagentId);
215
+ },
215
216
  });
216
217
  instance.backgroundTaskId = taskId;
217
- // Update parent message manager to reflect background status
218
- this.parentMessageManager.updateSubagentBlock(subagentId, {
219
- runInBackground: true,
220
- });
221
218
  return taskId;
222
219
  }
223
220
  async internalExecute(instance, prompt, abortSignal) {
@@ -229,9 +226,8 @@ export class SubagentManager {
229
226
  () => {
230
227
  // Update status to aborted
231
228
  this.updateInstanceStatus(instance.subagentId, "aborted");
232
- this.parentMessageManager.updateSubagentBlock(instance.subagentId, {
233
- status: "aborted",
234
- });
229
+ // Cleanup instance immediately on abort
230
+ this.cleanupInstance(instance.subagentId);
235
231
  },
236
232
  () => {
237
233
  // Abort the AI execution
@@ -297,9 +293,6 @@ export class SubagentManager {
297
293
  const response = textBlocks.map((block) => block.content).join("\n");
298
294
  // Update status to completed and update parent
299
295
  this.updateInstanceStatus(instance.subagentId, "completed");
300
- this.parentMessageManager.updateSubagentBlock(instance.subagentId, {
301
- status: "completed",
302
- });
303
296
  // If this was transitioned to background, update the background task
304
297
  if (instance.backgroundTaskId && this.backgroundTaskManager) {
305
298
  const task = this.backgroundTaskManager.getTask(instance.backgroundTaskId);
@@ -384,83 +377,6 @@ export class SubagentManager {
384
377
  cleanup() {
385
378
  this.instances.clear();
386
379
  }
387
- /**
388
- * Restore subagent instances from saved session data
389
- * This method is called during agent initialization to restore previous subagent states
390
- */
391
- async restoreSubagentSessions(subagentSessions) {
392
- for (const { sessionData, subagentId, configuration } of subagentSessions) {
393
- try {
394
- // Use the configuration from the SubagentBlock
395
- // Create the subagent instance without executing - just restore the state
396
- // Create MessageManager for the restored subagent
397
- const subagentCallbacks = this.createSubagentCallbacks(subagentId);
398
- const messageManager = new MessageManager({
399
- callbacks: subagentCallbacks,
400
- workdir: this.workdir,
401
- logger: this.logger,
402
- sessionType: "subagent",
403
- subagentType: configuration.name, // Use configuration name for restored sessions
404
- memoryRuleManager: this.memoryRuleManager,
405
- });
406
- // Use the parent tool manager
407
- const toolManager = this.parentToolManager;
408
- // Determine model to use
409
- let modelToUse;
410
- const parentModelConfig = this.getModelConfig();
411
- if (!configuration.model || configuration.model === "inherit") {
412
- modelToUse = parentModelConfig.agentModel;
413
- }
414
- else if (configuration.model === "fastModel") {
415
- modelToUse = parentModelConfig.fastModel;
416
- }
417
- else {
418
- modelToUse = configuration.model;
419
- }
420
- // Create AIManager for the restored subagent
421
- const aiManager = new AIManager({
422
- messageManager,
423
- toolManager,
424
- taskManager: this.taskManager,
425
- logger: this.logger,
426
- workdir: this.workdir,
427
- systemPrompt: configuration.systemPrompt,
428
- subagentType: configuration.name, // Use configuration name as subagent type for restored instances
429
- hookManager: this.hookManager,
430
- permissionManager: this.parentToolManager.getPermissionManager(),
431
- getGatewayConfig: this.getGatewayConfig,
432
- getModelConfig: () => ({
433
- ...parentModelConfig,
434
- agentModel: modelToUse,
435
- }),
436
- getMaxInputTokens: this.getMaxInputTokens,
437
- getLanguage: this.getLanguage,
438
- callbacks: {
439
- onUsageAdded: this.onUsageAdded,
440
- },
441
- });
442
- // Create restored instance
443
- const instance = {
444
- subagentId,
445
- configuration,
446
- aiManager,
447
- messageManager,
448
- toolManager,
449
- status: "completed", // Restored sessions are considered completed
450
- messages: sessionData.messages,
451
- subagentType: configuration.name, // Use configuration name as subagent type for restored instances
452
- };
453
- // IMPORTANT: Store instance in map BEFORE calling setMessages
454
- // This ensures the callback can find the instance
455
- this.instances.set(subagentId, instance);
456
- messageManager.initializeFromSession(sessionData);
457
- }
458
- catch (error) {
459
- this.logger?.warn(`Failed to restore subagent session ${subagentId}:`, error);
460
- // Continue with other sessions even if one fails
461
- }
462
- }
463
- }
464
380
  /**
465
381
  * Create subagent callbacks for a specific subagent ID
466
382
  * Extracted to reuse in both create and restore flows
@@ -492,6 +408,19 @@ export class SubagentManager {
492
408
  }
493
409
  },
494
410
  onToolBlockUpdated: (params) => {
411
+ // Track last two tool names when a tool starts running
412
+ if (params.stage === "running" && params.name) {
413
+ const instance = this.instances.get(subagentId);
414
+ if (instance) {
415
+ // Add to lastTools if it's different from the last one or we want to show duplicates
416
+ // Based on "ToolA, ToolB" requirement, we'll just keep the last two
417
+ instance.lastTools.push(params.name);
418
+ if (instance.lastTools.length > 2) {
419
+ instance.lastTools.shift();
420
+ }
421
+ instance.onUpdate?.();
422
+ }
423
+ }
495
424
  // Forward tool block updates to parent via SubagentManager callbacks
496
425
  if (this.callbacks?.onSubagentToolBlockUpdated) {
497
426
  this.callbacks.onSubagentToolBlockUpdated(subagentId, params);
@@ -502,28 +431,25 @@ export class SubagentManager {
502
431
  const instance = this.instances.get(subagentId);
503
432
  if (instance) {
504
433
  instance.messages = messages;
434
+ // Trigger the onUpdate callback if provided
435
+ instance.onUpdate?.();
505
436
  // Forward subagent message changes to parent via callbacks
506
437
  if (this.callbacks?.onSubagentMessagesChange) {
507
438
  this.callbacks.onSubagentMessagesChange(subagentId, messages);
508
439
  }
509
440
  }
510
441
  },
511
- onSessionIdChange: (newSessionId) => {
512
- // Update the subagent block with the new session ID
513
- this.parentMessageManager.updateSubagentBlock(subagentId, {
514
- sessionId: newSessionId,
515
- });
516
- },
517
442
  onLatestTotalTokensChange: (tokens) => {
443
+ const instance = this.instances.get(subagentId);
444
+ if (instance) {
445
+ // Trigger the onUpdate callback if provided
446
+ instance.onUpdate?.();
447
+ }
518
448
  // Forward latest total tokens to parent via SubagentManager callbacks
519
449
  if (this.callbacks?.onSubagentLatestTotalTokensChange) {
520
450
  this.callbacks.onSubagentLatestTotalTokensChange(subagentId, tokens);
521
451
  }
522
452
  },
523
- onFileHistoryBlockAdded: (snapshots) => {
524
- // Forward file history blocks to parent MessageManager
525
- this.parentMessageManager.addFileHistoryBlock(snapshots);
526
- },
527
453
  };
528
454
  }
529
455
  }
@@ -1,24 +1,23 @@
1
1
  import { ToolPlugin } from "../tools/types.js";
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 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.";
3
+ export declare const TOOL_POLICY = "\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.";
3
4
  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;
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.";
5
+ export declare function buildPlanModePrompt(planFilePath: string, planExists: boolean, isSubagent?: boolean): string;
6
+ 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.";
6
7
  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.";
7
8
  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.";
9
+ export declare const EXPLORE_SUBAGENT_SYSTEM_PROMPT = "You are a file search specialist. You excel at thoroughly navigating and exploring codebases.\n\t\n\t=== CRITICAL: READ-ONLY MODE - NO FILE MODIFICATIONS ===\n\tThis is a READ-ONLY exploration task. You are STRICTLY PROHIBITED from:\n\t- Creating new files (no Write, touch, or file creation of any kind)\n\t- Modifying existing files (no Edit operations)\n\t- Deleting files (no rm or deletion)\n\t- Moving or copying files (no mv or cp)\n\t- Creating temporary files anywhere, including /tmp\n\t- Using redirect operators (>, >>, |) or heredocs to write to files\n\t- Running ANY commands that change system state\n\t\n\tYour role is EXCLUSIVELY to search and analyze existing code. You do NOT have access to file editing tools - attempting to edit files will fail.\n\t\n\tYour strengths:\n\t- Rapidly finding files using glob patterns\n\t- Searching code and text with powerful regex patterns\n\t- Reading and analyzing file contents\n\t- Using Language Server Protocol (LSP) for deep code intelligence (definitions, references, etc.)\n\t\n\tGuidelines:\n\t- Use Glob for broad file pattern matching\n\t- Use Grep for searching file contents with regex\n\t- Use Read when you know the specific file path you need to read\n\t- Use LSP for code intelligence features like finding definitions, references, implementations, and symbols. This is especially useful for understanding complex code relationships.\n\t- Use Bash ONLY for read-only operations (ls, git status, git log, git diff, find, cat, head, tail)\n\t- NEVER use Bash for: mkdir, touch, rm, cp, mv, git add, git commit, npm install, pip install, or any file creation/modification\n\t- Adapt your search approach based on the thoroughness level specified by the caller\n\t- Return file paths as absolute paths in your final response\n\t- For clear communication, avoid using emojis\n\t- Communicate your final report directly as a regular message - do NOT attempt to create files\n\t\n\tNOTE: You are meant to be a fast agent that returns output as quickly as possible. In order to achieve this you must:\n\t- Make efficient use of the tools that you have at your disposal: be smart about how you search for files and implementations\n\t- Wherever possible you should try to spawn multiple parallel tool calls for grepping and reading files\n\t\n\tComplete the user's search request efficiently and report your findings clearly.";
8
10
  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.";
9
11
  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```";
10
12
  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
13
  export declare function buildSystemPrompt(basePrompt: string | undefined, tools: ToolPlugin[], options?: {
12
14
  workdir?: string;
13
- isGitRepo?: string;
14
- platform?: string;
15
- osVersion?: string;
16
- today?: string;
17
15
  memory?: string;
18
16
  language?: string;
17
+ isSubagent?: boolean;
19
18
  planMode?: {
20
19
  planFilePath: string;
21
20
  planExists: boolean;
22
21
  };
23
22
  }): string;
24
- //# sourceMappingURL=prompts.d.ts.map
23
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/prompts/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAqB/C,eAAO,MAAM,kBAAkB,g9DAU+J,CAAC;AAE/L,eAAO,MAAM,WAAW,qvBAIqH,CAAC;AAE9I,eAAO,MAAM,sBAAsB,moBAImH,CAAC;AAEvJ,wBAAgB,mBAAmB,CACjC,YAAY,EAAE,MAAM,EACpB,UAAU,EAAE,OAAO,EACnB,UAAU,GAAE,OAAe,GAC1B,MAAM,CAmFR;AAED,eAAO,MAAM,qBAAqB,g9DAAqB,CAAC;AAExD,eAAO,MAAM,2BAA2B,igBAWO,CAAC;AAEhD,eAAO,MAAM,6BAA6B,izCAeK,CAAC;AAEhD,eAAO,MAAM,8BAA8B,21EAoCuC,CAAC;AAEnF,eAAO,MAAM,2BAA2B,25EAiDyG,CAAC;AAElJ,eAAO,MAAM,WAAW,kkDAoBjB,CAAC;AAER,eAAO,MAAM,+BAA+B,20CAsBG,CAAC;AAEhD,wBAAgB,iBAAiB,CAC/B,UAAU,EAAE,MAAM,GAAG,SAAS,EAC9B,KAAK,EAAE,UAAU,EAAE,EACnB,OAAO,GAAE;IACP,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,QAAQ,CAAC,EAAE;QACT,YAAY,EAAE,MAAM,CAAC;QACrB,UAAU,EAAE,OAAO,CAAC;KACrB,CAAC;CACE,GACL,MAAM,CAqDR"}
@@ -1,4 +1,7 @@
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";
1
+ import * as os from "node:os";
2
+ import { isGitRepository } from "../utils/gitUtils.js";
3
+ import { EXPLORE_SUBAGENT_TYPE, PLAN_SUBAGENT_TYPE, } from "../constants/subagents.js";
4
+ 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, EXIT_PLAN_MODE_TOOL_NAME, } from "../constants/tools.js";
2
5
  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
6
 
4
7
  # Doing tasks
@@ -9,8 +12,8 @@ The user will primarily request you perform software engineering tasks. This inc
9
12
  - 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.
10
13
  - 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.
11
14
  - 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—three similar lines of code is better than a premature abstraction.
12
- - 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.
13
-
15
+ - 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.`;
16
+ export const TOOL_POLICY = `
14
17
  # Tool usage policy
15
18
  - 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.
16
19
  - 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.
@@ -20,16 +23,87 @@ export const TASK_MANAGEMENT_POLICY = `
20
23
  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
24
  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
25
  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) {
26
+ export function buildPlanModePrompt(planFilePath, planExists, isSubagent = false) {
24
27
  const planFileInfo = planExists
25
28
  ? `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
29
  : `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:
30
+ if (isSubagent) {
31
+ 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:
32
+
33
+ ## Plan File Info:
34
+ ${planFileInfo}
35
+ 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.
36
+ Answer the user's query comprehensively, using the ${ASK_USER_QUESTION_TOOL_NAME} tool if you need to ask the user clarifying questions. If you do use the ${ASK_USER_QUESTION_TOOL_NAME}, make sure to ask all clarifying questions you need to fully understand the user's intent before proceeding.`;
37
+ }
38
+ return `Plan mode is active. The user indicated that they do not want you to execute yet -- you MUST NOT make any edits (with the exception of the plan file mentioned below), 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.
28
39
 
29
40
  ## Plan File Info:
30
41
  ${planFileInfo}
31
42
  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.`;
43
+
44
+ ## Plan Workflow
45
+
46
+ ### Phase 1: Initial Understanding
47
+ Goal: Gain a comprehensive understanding of the user's request by reading through code and asking them questions. Critical: In this phase you should only use the Task subagent type with subagent_type=${EXPLORE_SUBAGENT_TYPE}.
48
+
49
+ 1. Focus on understanding the user's request and the code associated with their request. Actively search for existing functions, utilities, and patterns that can be reused — avoid proposing new code when suitable implementations already exist.
50
+
51
+ 2. **Launch up to 3 ${EXPLORE_SUBAGENT_TYPE} agents IN PARALLEL** (single message, multiple tool calls) to efficiently explore the codebase.
52
+ - Use 1 agent when the task is isolated to known files, the user provided specific file paths, or you're making a small targeted change.
53
+ - Use multiple agents when: the scope is uncertain, multiple areas of the codebase are involved, or you need to understand existing patterns before planning.
54
+ - Quality over quantity - 3 agents maximum, but you should try to use the minimum number of agents necessary (usually just 1)
55
+ - If using multiple agents: Provide each agent with a specific search focus or area to explore. Example: One agent searches for existing implementations, another explores related components, a third investigating testing patterns
56
+
57
+ ### Phase 2: Design
58
+ Goal: Design an implementation approach.
59
+
60
+ Launch Task agent(s) with subagent_type=${PLAN_SUBAGENT_TYPE} to design the implementation based on the user's intent and your exploration results from Phase 1.
61
+
62
+ You can launch up to 3 agent(s) in parallel.
63
+
64
+ **Guidelines:**
65
+ - **Default**: Launch at least 1 Plan agent for most tasks - it helps validate your understanding and consider alternatives
66
+ - **Skip agents**: Only for truly trivial tasks (typo fixes, single-line changes, simple renames)
67
+ - **Multiple agents**: Use up to 3 agents for complex tasks that benefit from different perspectives
68
+
69
+ Examples of when to use multiple agents:
70
+ - The task touches multiple parts of the codebase
71
+ - It's a large refactor or architectural change
72
+ - There are many edge cases to consider
73
+ - You'd benefit from exploring different approaches
74
+
75
+ Example perspectives by task type:
76
+ - New feature: simplicity vs performance vs maintainability
77
+ - Bug fix: root cause vs workaround vs prevention
78
+ - Refactoring: minimal change vs clean architecture
79
+
80
+ In the agent prompt:
81
+ - Provide comprehensive background context from Phase 1 exploration including filenames and code path traces
82
+ - Describe requirements and constraints
83
+ - Request a detailed implementation plan
84
+
85
+ ### Phase 3: Review
86
+ Goal: Review the plan(s) from Phase 2 and ensure alignment with the user's intentions.
87
+ 1. Read the critical files identified by agents to deepen your understanding
88
+ 2. Ensure that the plans align with the user's original request
89
+ 3. Use ${ASK_USER_QUESTION_TOOL_NAME} to clarify any remaining questions with the user
90
+
91
+ ### Phase 4: Final Plan
92
+ Goal: Write your final plan to the plan file (the only file you can edit).
93
+ - Begin with a **Context** section: explain why this change is being made — the problem or need it addresses, what prompted it, and the intended outcome
94
+ - Include only your recommended approach, not all alternatives
95
+ - Ensure that the plan file is concise enough to scan quickly, but detailed enough to execute effectively
96
+ - Include the paths of critical files to be modified
97
+ - Reference existing functions and utilities you found that should be reused, with their file paths
98
+ - Include a verification section describing how to test the changes end-to-end (run the code, use MCP tools, run tests)
99
+
100
+ ### Phase 5: Call ${EXIT_PLAN_MODE_TOOL_NAME}
101
+ At the very end of your turn, once you have asked the user questions and are happy with your final plan file - you should always call ${EXIT_PLAN_MODE_TOOL_NAME} to indicate to the user that you are done planning.
102
+ This is critical - your turn should only end with either using the ${ASK_USER_QUESTION_TOOL_NAME} tool OR calling ${EXIT_PLAN_MODE_TOOL_NAME}. Do not stop unless it's for these 2 reasons
103
+
104
+ **Important:** Use ${ASK_USER_QUESTION_TOOL_NAME} ONLY to clarify requirements or choose between approaches. Use ${EXIT_PLAN_MODE_TOOL_NAME} to request plan approval. Do NOT ask about plan approval in any other way - no text questions, no AskUserQuestion. Phrases like "Is this plan okay?", "Should I proceed?", "How does this plan look?", "Any changes before we start?", or similar MUST use ${EXIT_PLAN_MODE_TOOL_NAME}.
105
+
106
+ NOTE: At any point in time through this workflow you should feel free to ask the user questions or clarifications using the ${ASK_USER_QUESTION_TOOL_NAME} tool. Don't make large assumptions about user intent. The goal is to present a well researched plan to the user, and tie any loose ends before implementation begins.`;
33
107
  }
34
108
  export const DEFAULT_SYSTEM_PROMPT = BASE_SYSTEM_PROMPT;
35
109
  export const BASH_SUBAGENT_SYSTEM_PROMPT = `You are a command execution specialist. Your role is to execute bash commands efficiently and safely.
@@ -60,6 +134,43 @@ Guidelines:
60
134
  - NEVER proactively create documentation files (*.md) or README files. Only create documentation files if explicitly requested.
61
135
  - 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.
62
136
  - For clear communication, avoid using emojis.`;
137
+ export const EXPLORE_SUBAGENT_SYSTEM_PROMPT = `You are a file search specialist. You excel at thoroughly navigating and exploring codebases.
138
+
139
+ === CRITICAL: READ-ONLY MODE - NO FILE MODIFICATIONS ===
140
+ This is a READ-ONLY exploration task. You are STRICTLY PROHIBITED from:
141
+ - Creating new files (no Write, touch, or file creation of any kind)
142
+ - Modifying existing files (no Edit operations)
143
+ - Deleting files (no rm or deletion)
144
+ - Moving or copying files (no mv or cp)
145
+ - Creating temporary files anywhere, including /tmp
146
+ - Using redirect operators (>, >>, |) or heredocs to write to files
147
+ - Running ANY commands that change system state
148
+
149
+ Your role is EXCLUSIVELY to search and analyze existing code. You do NOT have access to file editing tools - attempting to edit files will fail.
150
+
151
+ Your strengths:
152
+ - Rapidly finding files using glob patterns
153
+ - Searching code and text with powerful regex patterns
154
+ - Reading and analyzing file contents
155
+ - Using Language Server Protocol (LSP) for deep code intelligence (definitions, references, etc.)
156
+
157
+ Guidelines:
158
+ - Use ${GLOB_TOOL_NAME} for broad file pattern matching
159
+ - Use ${GREP_TOOL_NAME} for searching file contents with regex
160
+ - Use ${READ_TOOL_NAME} when you know the specific file path you need to read
161
+ - Use LSP for code intelligence features like finding definitions, references, implementations, and symbols. This is especially useful for understanding complex code relationships.
162
+ - Use ${BASH_TOOL_NAME} ONLY for read-only operations (ls, git status, git log, git diff, find, cat, head, tail)
163
+ - NEVER use ${BASH_TOOL_NAME} for: mkdir, touch, rm, cp, mv, git add, git commit, npm install, pip install, or any file creation/modification
164
+ - Adapt your search approach based on the thoroughness level specified by the caller
165
+ - Return file paths as absolute paths in your final response
166
+ - For clear communication, avoid using emojis
167
+ - Communicate your final report directly as a regular message - do NOT attempt to create files
168
+
169
+ NOTE: You are meant to be a fast agent that returns output as quickly as possible. In order to achieve this you must:
170
+ - Make efficient use of the tools that you have at your disposal: be smart about how you search for files and implementations
171
+ - Wherever possible you should try to spawn multiple parallel tool calls for grepping and reading files
172
+
173
+ Complete the user's search request efficiently and report your findings clearly.`;
63
174
  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
175
 
65
176
  === CRITICAL: READ-ONLY MODE - NO FILE MODIFICATIONS ===
@@ -163,6 +274,7 @@ export function buildSystemPrompt(basePrompt, tools, options = {}) {
163
274
  toolNames.has(TASK_LIST_TOOL_NAME)) {
164
275
  prompt += TASK_MANAGEMENT_POLICY;
165
276
  }
277
+ prompt += `\n\n${TOOL_POLICY}`;
166
278
  for (const tool of tools) {
167
279
  if (tool.prompt) {
168
280
  prompt += tool.prompt();
@@ -172,18 +284,22 @@ export function buildSystemPrompt(basePrompt, tools, options = {}) {
172
284
  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.`;
173
285
  }
174
286
  if (options.planMode) {
175
- prompt += `\n\n${buildPlanModePrompt(options.planMode.planFilePath, options.planMode.planExists)}`;
287
+ prompt += `\n\n${buildPlanModePrompt(options.planMode.planFilePath, options.planMode.planExists, options.isSubagent)}`;
176
288
  }
177
289
  if (options.workdir) {
290
+ const isGitRepo = isGitRepository(options.workdir);
291
+ const platform = os.platform();
292
+ const osVersion = `${os.type()} ${os.release()}`;
293
+ const today = new Date().toISOString().split("T")[0];
178
294
  prompt += `
179
295
 
180
296
  Here is useful information about the environment you are running in:
181
297
  <env>
182
298
  Working directory: ${options.workdir}
183
- Is directory a git repo: ${options.isGitRepo || "No"}
184
- Platform: ${options.platform || ""}
185
- OS Version: ${options.osVersion || ""}
186
- Today's date: ${options.today || new Date().toISOString().split("T")[0]}
299
+ Is directory a git repo: ${isGitRepo}
300
+ Platform: ${platform}
301
+ OS Version: ${osVersion}
302
+ Today's date: ${today}
187
303
  </env>
188
304
  `;
189
305
  }
@@ -4,7 +4,7 @@ import { transformMessagesForClaudeCache, addCacheControlToLastTool, isClaudeMod
4
4
  import * as os from "os";
5
5
  import * as fs from "fs";
6
6
  import * as path from "path";
7
- import { COMPRESS_MESSAGES_SYSTEM_PROMPT } from "../constants/prompts.js";
7
+ import { COMPRESS_MESSAGES_SYSTEM_PROMPT } from "../prompts/index.js";
8
8
  /**
9
9
  * Get specific configuration parameters based on model name
10
10
  * @param modelName Model name
@@ -7,7 +7,7 @@ export declare class TaskManager extends EventEmitter {
7
7
  getTaskListId(): string;
8
8
  setTaskListId(taskListId: string): void;
9
9
  private getSessionDir;
10
- private getTaskPath;
10
+ getTaskPath(taskId: string): string;
11
11
  private getLockPath;
12
12
  ensureSessionDir(): Promise<void>;
13
13
  private withLock;
@@ -17,5 +17,9 @@ export declare class TaskManager extends EventEmitter {
17
17
  updateTask(task: Task): Promise<void>;
18
18
  listTasks(): Promise<Task[]>;
19
19
  getNextTaskId(): Promise<string>;
20
+ /**
21
+ * Refreshes the task list by re-reading tasks from disk and emitting a change event.
22
+ */
23
+ refreshTasks(): Promise<void>;
20
24
  }
21
25
  //# sourceMappingURL=taskManager.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"taskManager.d.ts","sourceRoot":"","sources":["../../src/services/taskManager.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AACtC,OAAO,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AAGzC,qBAAa,WAAY,SAAQ,YAAY;IAC3C,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAS;IACjC,OAAO,CAAC,UAAU,CAAS;gBAEf,UAAU,EAAE,MAAM;IAMvB,aAAa,IAAI,MAAM;IAIvB,aAAa,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI;IAI9C,OAAO,CAAC,aAAa;IAIrB,OAAO,CAAC,WAAW;IAInB,OAAO,CAAC,WAAW;IAIb,gBAAgB,IAAI,OAAO,CAAC,IAAI,CAAC;YAIzB,QAAQ;IA2CtB,OAAO,CAAC,YAAY;IAed,UAAU,CAAC,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,GAAG,OAAO,CAAC,MAAM,CAAC;IAcnD,OAAO,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,GAAG,IAAI,CAAC;IAmB7C,UAAU,CAAC,IAAI,EAAE,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;IAWrC,SAAS,IAAI,OAAO,CAAC,IAAI,EAAE,CAAC;IA+B5B,aAAa,IAAI,OAAO,CAAC,MAAM,CAAC;CAavC"}
1
+ {"version":3,"file":"taskManager.d.ts","sourceRoot":"","sources":["../../src/services/taskManager.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AACtC,OAAO,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AAGzC,qBAAa,WAAY,SAAQ,YAAY;IAC3C,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAS;IACjC,OAAO,CAAC,UAAU,CAAS;gBAEf,UAAU,EAAE,MAAM;IAMvB,aAAa,IAAI,MAAM;IAIvB,aAAa,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI;IAI9C,OAAO,CAAC,aAAa;IAId,WAAW,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM;IAI1C,OAAO,CAAC,WAAW;IAIb,gBAAgB,IAAI,OAAO,CAAC,IAAI,CAAC;YAIzB,QAAQ;IA2CtB,OAAO,CAAC,YAAY;IAed,UAAU,CAAC,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,GAAG,OAAO,CAAC,MAAM,CAAC;IAcnD,OAAO,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,GAAG,IAAI,CAAC;IAmB7C,UAAU,CAAC,IAAI,EAAE,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;IAWrC,SAAS,IAAI,OAAO,CAAC,IAAI,EAAE,CAAC;IA+B5B,aAAa,IAAI,OAAO,CAAC,MAAM,CAAC;IActC;;OAEG;IACU,YAAY,IAAI,OAAO,CAAC,IAAI,CAAC;CAG3C"}
@@ -155,4 +155,10 @@ export class TaskManager extends EventEmitter {
155
155
  }
156
156
  return (Math.max(...ids) + 1).toString();
157
157
  }
158
+ /**
159
+ * Refreshes the task list by re-reading tasks from disk and emitting a change event.
160
+ */
161
+ async refreshTasks() {
162
+ this.emit("tasksChange", this.taskListId);
163
+ }
158
164
  }
@@ -1 +1 @@
1
- {"version":3,"file":"bashTool.d.ts","sourceRoot":"","sources":["../../src/tools/bashTool.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,UAAU,EAA2B,MAAM,YAAY,CAAC;AActE;;GAEG;AACH,eAAO,MAAM,QAAQ,EAAE,UA6WtB,CAAC"}
1
+ {"version":3,"file":"bashTool.d.ts","sourceRoot":"","sources":["../../src/tools/bashTool.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,UAAU,EAA2B,MAAM,YAAY,CAAC;AActE;;GAEG;AACH,eAAO,MAAM,QAAQ,EAAE,UAkXtB,CAAC"}