wave-agent-sdk 0.2.1 → 0.4.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 (145) hide show
  1. package/dist/agent.d.ts +38 -15
  2. package/dist/agent.d.ts.map +1 -1
  3. package/dist/agent.js +101 -50
  4. package/dist/constants/prompts.d.ts +7 -2
  5. package/dist/constants/prompts.d.ts.map +1 -1
  6. package/dist/constants/prompts.js +41 -5
  7. package/dist/index.d.ts +1 -1
  8. package/dist/index.d.ts.map +1 -1
  9. package/dist/index.js +1 -1
  10. package/dist/managers/MemoryRuleManager.d.ts.map +1 -1
  11. package/dist/managers/MemoryRuleManager.js +15 -1
  12. package/dist/managers/aiManager.d.ts +6 -1
  13. package/dist/managers/aiManager.d.ts.map +1 -1
  14. package/dist/managers/aiManager.js +26 -0
  15. package/dist/managers/bashManager.d.ts.map +1 -1
  16. package/dist/managers/bashManager.js +0 -3
  17. package/dist/managers/liveConfigManager.d.ts.map +1 -1
  18. package/dist/managers/messageManager.d.ts +22 -2
  19. package/dist/managers/messageManager.d.ts.map +1 -1
  20. package/dist/managers/messageManager.js +68 -11
  21. package/dist/managers/permissionManager.d.ts.map +1 -1
  22. package/dist/managers/permissionManager.js +10 -6
  23. package/dist/managers/pluginScopeManager.d.ts +13 -2
  24. package/dist/managers/pluginScopeManager.d.ts.map +1 -1
  25. package/dist/managers/pluginScopeManager.js +38 -0
  26. package/dist/managers/reversionManager.d.ts +39 -0
  27. package/dist/managers/reversionManager.d.ts.map +1 -0
  28. package/dist/managers/reversionManager.js +118 -0
  29. package/dist/managers/slashCommandManager.d.ts +1 -1
  30. package/dist/managers/slashCommandManager.d.ts.map +1 -1
  31. package/dist/managers/slashCommandManager.js +15 -6
  32. package/dist/managers/subagentManager.d.ts +2 -0
  33. package/dist/managers/subagentManager.d.ts.map +1 -1
  34. package/dist/managers/subagentManager.js +3 -0
  35. package/dist/managers/toolManager.d.ts +4 -0
  36. package/dist/managers/toolManager.d.ts.map +1 -1
  37. package/dist/managers/toolManager.js +2 -0
  38. package/dist/services/MarketplaceService.d.ts +13 -0
  39. package/dist/services/MarketplaceService.d.ts.map +1 -1
  40. package/dist/services/MarketplaceService.js +63 -2
  41. package/dist/services/aiService.js +1 -1
  42. package/dist/services/configurationService.d.ts +18 -2
  43. package/dist/services/configurationService.d.ts.map +1 -1
  44. package/dist/services/configurationService.js +62 -0
  45. package/dist/services/fileWatcher.d.ts +0 -5
  46. package/dist/services/fileWatcher.d.ts.map +1 -1
  47. package/dist/services/fileWatcher.js +0 -11
  48. package/dist/services/pluginLoader.d.ts.map +1 -1
  49. package/dist/services/pluginLoader.js +6 -1
  50. package/dist/services/reversionService.d.ts +24 -0
  51. package/dist/services/reversionService.d.ts.map +1 -0
  52. package/dist/services/reversionService.js +76 -0
  53. package/dist/services/session.d.ts +7 -0
  54. package/dist/services/session.d.ts.map +1 -1
  55. package/dist/services/session.js +126 -3
  56. package/dist/tools/deleteFileTool.d.ts.map +1 -1
  57. package/dist/tools/deleteFileTool.js +9 -0
  58. package/dist/tools/editTool.d.ts.map +1 -1
  59. package/dist/tools/editTool.js +11 -1
  60. package/dist/tools/multiEditTool.d.ts.map +1 -1
  61. package/dist/tools/multiEditTool.js +11 -1
  62. package/dist/tools/types.d.ts +4 -0
  63. package/dist/tools/types.d.ts.map +1 -1
  64. package/dist/tools/writeTool.d.ts.map +1 -1
  65. package/dist/tools/writeTool.js +9 -0
  66. package/dist/types/commands.d.ts +1 -0
  67. package/dist/types/commands.d.ts.map +1 -1
  68. package/dist/types/configuration.d.ts +3 -0
  69. package/dist/types/configuration.d.ts.map +1 -1
  70. package/dist/types/environment.d.ts +2 -1
  71. package/dist/types/environment.d.ts.map +1 -1
  72. package/dist/types/environment.js +0 -6
  73. package/dist/types/history.d.ts +5 -0
  74. package/dist/types/history.d.ts.map +1 -0
  75. package/dist/types/history.js +1 -0
  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/marketplace.d.ts +3 -0
  80. package/dist/types/marketplace.d.ts.map +1 -1
  81. package/dist/types/messaging.d.ts +6 -1
  82. package/dist/types/messaging.d.ts.map +1 -1
  83. package/dist/types/reversion.d.ts +29 -0
  84. package/dist/types/reversion.d.ts.map +1 -0
  85. package/dist/types/reversion.js +1 -0
  86. package/dist/utils/builtinSubagents.d.ts.map +1 -1
  87. package/dist/utils/builtinSubagents.js +16 -0
  88. package/dist/utils/constants.d.ts +2 -2
  89. package/dist/utils/constants.d.ts.map +1 -1
  90. package/dist/utils/constants.js +2 -2
  91. package/dist/utils/editUtils.d.ts +4 -0
  92. package/dist/utils/editUtils.d.ts.map +1 -1
  93. package/dist/utils/editUtils.js +26 -0
  94. package/dist/utils/messageOperations.d.ts.map +1 -1
  95. package/dist/utils/messageOperations.js +3 -0
  96. package/dist/utils/openaiClient.d.ts.map +1 -1
  97. package/dist/utils/openaiClient.js +56 -26
  98. package/dist/utils/promptHistory.d.ts +20 -0
  99. package/dist/utils/promptHistory.d.ts.map +1 -0
  100. package/dist/utils/promptHistory.js +117 -0
  101. package/package.json +3 -1
  102. package/src/agent.ts +120 -70
  103. package/src/constants/prompts.ts +45 -5
  104. package/src/index.ts +1 -1
  105. package/src/managers/MemoryRuleManager.ts +17 -1
  106. package/src/managers/aiManager.ts +37 -1
  107. package/src/managers/bashManager.ts +0 -4
  108. package/src/managers/liveConfigManager.ts +2 -1
  109. package/src/managers/messageManager.ts +88 -16
  110. package/src/managers/permissionManager.ts +10 -6
  111. package/src/managers/pluginScopeManager.ts +57 -8
  112. package/src/managers/reversionManager.ts +152 -0
  113. package/src/managers/slashCommandManager.ts +26 -7
  114. package/src/managers/subagentManager.ts +5 -0
  115. package/src/managers/toolManager.ts +7 -0
  116. package/src/services/MarketplaceService.ts +80 -2
  117. package/src/services/aiService.ts +1 -1
  118. package/src/services/configurationService.ts +79 -1
  119. package/src/services/fileWatcher.ts +0 -13
  120. package/src/services/pluginLoader.ts +7 -1
  121. package/src/services/reversionService.ts +94 -0
  122. package/src/services/session.ts +161 -3
  123. package/src/tools/deleteFileTool.ts +15 -0
  124. package/src/tools/editTool.ts +21 -0
  125. package/src/tools/multiEditTool.ts +21 -0
  126. package/src/tools/types.ts +4 -0
  127. package/src/tools/writeTool.ts +14 -0
  128. package/src/types/commands.ts +3 -0
  129. package/src/types/configuration.ts +4 -0
  130. package/src/types/environment.ts +3 -1
  131. package/src/types/history.ts +4 -0
  132. package/src/types/index.ts +1 -0
  133. package/src/types/marketplace.ts +4 -0
  134. package/src/types/messaging.ts +8 -1
  135. package/src/types/reversion.ts +29 -0
  136. package/src/utils/builtinSubagents.ts +18 -0
  137. package/src/utils/constants.ts +2 -2
  138. package/src/utils/editUtils.ts +46 -0
  139. package/src/utils/messageOperations.ts +3 -0
  140. package/src/utils/openaiClient.ts +69 -35
  141. package/src/utils/promptHistory.ts +133 -0
  142. package/dist/utils/bashHistory.d.ts +0 -50
  143. package/dist/utils/bashHistory.d.ts.map +0 -1
  144. package/dist/utils/bashHistory.js +0 -256
  145. package/src/utils/bashHistory.ts +0 -320
package/dist/agent.d.ts CHANGED
@@ -21,6 +21,8 @@ export interface AgentOptions {
21
21
  fastModel?: string;
22
22
  maxInputTokens?: number;
23
23
  maxTokens?: number;
24
+ /** Preferred language for agent communication */
25
+ language?: string;
24
26
  callbacks?: AgentCallbacks;
25
27
  restoreSessionId?: string;
26
28
  continueLastSession?: boolean;
@@ -61,6 +63,7 @@ export declare class Agent {
61
63
  private pluginManager;
62
64
  private skillManager;
63
65
  private hookManager;
66
+ private reversionManager;
64
67
  private memoryRuleManager;
65
68
  private liveConfigManager;
66
69
  private configurationService;
@@ -74,17 +77,7 @@ export declare class Agent {
74
77
  getGatewayConfig(): GatewayConfig;
75
78
  getModelConfig(): ModelConfig;
76
79
  getMaxInputTokens(): number;
77
- /**
78
- * Update agent configuration dynamically
79
- *
80
- * @param config - Configuration updates for gateway, model, and token limit
81
- */
82
- updateConfig(config: {
83
- gateway?: Partial<GatewayConfig>;
84
- model?: Partial<ModelConfig>;
85
- maxInputTokens?: number;
86
- maxTokens?: number;
87
- }): void;
80
+ getLanguage(): string | undefined;
88
81
  /**
89
82
  * Agent constructor - handles configuration resolution and validation
90
83
  *
@@ -207,6 +200,15 @@ export declare class Agent {
207
200
  abortSlashCommand(): void;
208
201
  /** Destroy managers, clean up resources */
209
202
  destroy(): Promise<void>;
203
+ /**
204
+ * Get a subagent instance by its ID
205
+ * @param subagentId - The ID of the subagent instance
206
+ */
207
+ getSubagentInstance(subagentId: string): import("./managers/subagentManager.js").SubagentInstance | null;
208
+ /**
209
+ * Trigger the rewind UI callback
210
+ */
211
+ triggerShowRewind(): void;
210
212
  /**
211
213
  * Send a message to the AI agent with optional images
212
214
  *
@@ -255,6 +257,10 @@ export declare class Agent {
255
257
  getCustomCommand(commandId: string): CustomSlashCommand | undefined;
256
258
  /** Get all custom commands */
257
259
  getCustomCommands(): CustomSlashCommand[];
260
+ /**
261
+ * Register a custom slash command
262
+ */
263
+ registerSlashCommand(command: SlashCommand): void;
258
264
  /**
259
265
  * Get the current permission mode
260
266
  */
@@ -265,14 +271,31 @@ export declare class Agent {
265
271
  */
266
272
  setPermissionMode(mode: PermissionMode): void;
267
273
  /**
268
- * Handle plan mode transition, generating or clearing plan file path
269
- * @param mode - The current effective permission mode
274
+ * Truncate history to a specific index and revert file changes.
275
+ * @param index - The index of the user message to truncate to.
270
276
  */
271
- private handlePlanModeTransition;
277
+ truncateHistory(index: number): Promise<void>;
278
+ /**
279
+ * Get the current plan file path (for testing and UI)
280
+ */
281
+ getPlanFilePath(): string | undefined;
282
+ /**
283
+ * Get all currently allowed rules (for testing and UI)
284
+ */
285
+ getAllowedRules(): string[];
286
+ /**
287
+ * Check permission for a tool call (for testing)
288
+ */
289
+ checkPermission(context: import("./types/permissions.js").ToolPermissionContext): Promise<import("./types/permissions.js").PermissionDecision>;
272
290
  /**
273
291
  * Add a persistent permission rule
274
292
  * @param rule - The rule to add (e.g., "Bash(ls)")
275
293
  */
276
- private addPermissionRule;
294
+ addPermissionRule(rule: string): Promise<void>;
295
+ /**
296
+ * Handle plan mode transition, generating or clearing plan file path
297
+ * @param mode - The current effective permission mode
298
+ */
299
+ private handlePlanModeTransition;
277
300
  }
278
301
  //# sourceMappingURL=agent.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"agent.d.ts","sourceRoot":"","sources":["../src/agent.ts"],"names":[],"mappings":"AAAA,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;AAM7C,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,EACnB,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,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACxC,YAAY,CAAC,EAAE,aAAa,CAAC,cAAc,CAAC,CAAC;IAC7C,KAAK,CAAC,EAAE,aAAa,CAAC,OAAO,CAAC,CAAC;IAC/B,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,SAAS,CAA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MAAM,GAAG,OAAO;IAIlD,6BAA6B;IACtB,oBAAoB,IAAI,IAAI;IAInC,iCAAiC;IAC1B,gBAAgB,CAAC,SAAS,EAAE,MAAM,GAAG,kBAAkB,GAAG,SAAS;IAI1E,8BAA8B;IACvB,iBAAiB,IAAI,kBAAkB,EAAE;IAIhD;;OAEG;IACI,oBAAoB,CAAC,OAAO,EAAE,YAAY,GAAG,IAAI;IAIxD;;OAEG;IACI,iBAAiB,IAAI,cAAc;IAI1C;;;OAGG;IACI,iBAAiB,CAAC,IAAI,EAAE,cAAc,GAAG,IAAI;IASpD;;;OAGG;IACU,eAAe,CAAC,KAAK,EAAE,MAAM,GAAG,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;CAejC"}
package/dist/agent.js CHANGED
@@ -10,6 +10,8 @@ import { BackgroundBashManager, } from "./managers/backgroundBashManager.js";
10
10
  import { SlashCommandManager } from "./managers/slashCommandManager.js";
11
11
  import { PluginManager } from "./managers/pluginManager.js";
12
12
  import { HookManager } from "./managers/hookManager.js";
13
+ import { ReversionManager } from "./managers/reversionManager.js";
14
+ import { ReversionService } from "./services/reversionService.js";
13
15
  import { PermissionManager } from "./managers/permissionManager.js";
14
16
  import { PlanManager } from "./managers/planManager.js";
15
17
  import { MemoryRuleManager } from "./managers/MemoryRuleManager.js";
@@ -33,35 +35,8 @@ export class Agent {
33
35
  getMaxInputTokens() {
34
36
  return this.configurationService.resolveMaxInputTokens(this.options.maxInputTokens);
35
37
  }
36
- /**
37
- * Update agent configuration dynamically
38
- *
39
- * @param config - Configuration updates for gateway, model, and token limit
40
- */
41
- updateConfig(config) {
42
- if (config.gateway) {
43
- this.options.apiKey = config.gateway.apiKey ?? this.options.apiKey;
44
- this.options.baseURL = config.gateway.baseURL ?? this.options.baseURL;
45
- this.options.defaultHeaders =
46
- config.gateway.defaultHeaders ?? this.options.defaultHeaders;
47
- this.options.fetchOptions =
48
- config.gateway.fetchOptions ?? this.options.fetchOptions;
49
- this.options.fetch = config.gateway.fetch ?? this.options.fetch;
50
- }
51
- if (config.model) {
52
- this.options.agentModel =
53
- config.model.agentModel ?? this.options.agentModel;
54
- this.options.fastModel = config.model.fastModel ?? this.options.fastModel;
55
- this.options.maxTokens = config.model.maxTokens ?? this.options.maxTokens;
56
- }
57
- if (config.maxInputTokens !== undefined) {
58
- this.options.maxInputTokens = config.maxInputTokens;
59
- }
60
- if (config.maxTokens !== undefined) {
61
- this.options.maxTokens = config.maxTokens;
62
- }
63
- // Re-validate configuration after update
64
- this.resolveAndValidateConfig();
38
+ getLanguage() {
39
+ return this.configurationService.resolveLanguage(this.options.language);
65
40
  }
66
41
  /**
67
42
  * Agent constructor - handles configuration resolution and validation
@@ -119,6 +94,8 @@ export class Agent {
119
94
  workdir: this.workdir,
120
95
  logger: this.logger,
121
96
  });
97
+ // Initialize ReversionManager
98
+ this.reversionManager = new ReversionManager(new ReversionService(this.messageManager.getTranscriptPath()));
122
99
  // Initialize memory rule manager
123
100
  this.memoryRuleManager = new MemoryRuleManager({
124
101
  workdir: this.workdir,
@@ -166,6 +143,7 @@ export class Agent {
166
143
  lspManager: this.lspManager,
167
144
  logger: this.logger,
168
145
  permissionManager: this.permissionManager,
146
+ reversionManager: this.reversionManager,
169
147
  permissionMode: options.permissionMode, // Let PermissionManager handle defaultMode resolution
170
148
  canUseToolCallback: canUseToolWithNotification,
171
149
  }); // Initialize tool registry with permission support
@@ -194,6 +172,7 @@ export class Agent {
194
172
  getGatewayConfig: () => this.getGatewayConfig(),
195
173
  getModelConfig: () => this.getModelConfig(),
196
174
  getMaxInputTokens: () => this.getMaxInputTokens(),
175
+ getLanguage: () => this.getLanguage(),
197
176
  hookManager: this.hookManager,
198
177
  onUsageAdded: (usage) => this.addUsage(usage),
199
178
  });
@@ -214,9 +193,11 @@ export class Agent {
214
193
  workdir: this.workdir,
215
194
  systemPrompt: this.systemPrompt,
216
195
  stream: this.stream, // Pass streaming mode flag
196
+ reversionManager: this.reversionManager,
217
197
  getGatewayConfig: () => this.getGatewayConfig(),
218
198
  getModelConfig: () => this.getModelConfig(),
219
199
  getMaxInputTokens: () => this.getMaxInputTokens(),
200
+ getLanguage: () => this.getLanguage(),
220
201
  getEnvironmentVars: () => this.configurationService.getEnvironmentVars(), // Provide access to configuration environment variables
221
202
  });
222
203
  // Initialize command manager
@@ -316,11 +297,15 @@ export class Agent {
316
297
  const filesInContext = this.messageManager.getFilesInContext();
317
298
  const activeRules = this.memoryRuleManager.getActiveRules(filesInContext);
318
299
  if (activeRules.length > 0) {
300
+ this.logger?.debug(`Active modular rules (${activeRules.length}): ${activeRules.map((r) => r.id).join(", ")}`);
319
301
  if (combined) {
320
302
  combined += "\n\n";
321
303
  }
322
304
  combined += activeRules.map((r) => r.content).join("\n\n");
323
305
  }
306
+ else {
307
+ this.logger?.debug("No active modular rules for current context");
308
+ }
324
309
  return combined;
325
310
  }
326
311
  /** Get AI loading status */
@@ -457,6 +442,8 @@ export class Agent {
457
442
  }
458
443
  // Resolve and validate configuration after loading settings.json
459
444
  this.resolveAndValidateConfig();
445
+ // Set global logger for SDK-wide access before discovering rules
446
+ setGlobalLogger(this.logger || null);
460
447
  // Discover modular memory rules
461
448
  try {
462
449
  await this.memoryRuleManager.discoverRules();
@@ -464,8 +451,6 @@ export class Agent {
464
451
  catch (error) {
465
452
  this.logger?.error("Failed to discover memory rules:", error);
466
453
  }
467
- // Set global logger for SDK-wide access after validation
468
- setGlobalLogger(this.logger || null);
469
454
  // Initialize live configuration reload
470
455
  try {
471
456
  this.logger?.debug("Initializing live configuration reload...");
@@ -694,6 +679,19 @@ export class Agent {
694
679
  }
695
680
  // Cleanup memory store
696
681
  }
682
+ /**
683
+ * Get a subagent instance by its ID
684
+ * @param subagentId - The ID of the subagent instance
685
+ */
686
+ getSubagentInstance(subagentId) {
687
+ return this.subagentManager.getInstance(subagentId);
688
+ }
689
+ /**
690
+ * Trigger the rewind UI callback
691
+ */
692
+ triggerShowRewind() {
693
+ this.messageManager.triggerShowRewind();
694
+ }
697
695
  /**
698
696
  * Send a message to the AI agent with optional images
699
697
  *
@@ -806,7 +804,18 @@ export class Agent {
806
804
  const memoryText = message.substring(1).trim();
807
805
  const typeLabel = type === "project" ? "Project Memory" : "User Memory";
808
806
  const storagePath = "AGENTS.md";
809
- this.messageManager.addMemoryBlock(`${typeLabel}: ${memoryText}`, true, type, storagePath);
807
+ const messages = this.messageManager.getMessages();
808
+ const lastMessage = messages[messages.length - 1];
809
+ if (lastMessage && lastMessage.role === "assistant") {
810
+ lastMessage.blocks.push({
811
+ type: "memory",
812
+ content: `${typeLabel}: ${memoryText}`,
813
+ isSuccess: true,
814
+ memoryType: type,
815
+ storagePath,
816
+ });
817
+ this.messageManager.setMessages(messages);
818
+ }
810
819
  }
811
820
  catch (error) {
812
821
  // Add failed MemoryBlock to the last assistant message
@@ -814,7 +823,18 @@ export class Agent {
814
823
  const typeLabel = type === "project" ? "Project Memory" : "User Memory";
815
824
  const storagePath = "AGENTS.md";
816
825
  const errorMessage = error instanceof Error ? error.message : String(error);
817
- this.messageManager.addMemoryBlock(`${typeLabel}: ${memoryText} - Error: ${errorMessage}`, false, type, storagePath);
826
+ const messages = this.messageManager.getMessages();
827
+ const lastMessage = messages[messages.length - 1];
828
+ if (lastMessage && lastMessage.role === "assistant") {
829
+ lastMessage.blocks.push({
830
+ type: "memory",
831
+ content: `${typeLabel}: ${memoryText} - Error: ${errorMessage}`,
832
+ isSuccess: false,
833
+ memoryType: type,
834
+ storagePath,
835
+ });
836
+ this.messageManager.setMessages(messages);
837
+ }
818
838
  }
819
839
  }
820
840
  // ========== MCP Management Methods ==========
@@ -851,6 +871,12 @@ export class Agent {
851
871
  getCustomCommands() {
852
872
  return this.slashCommandManager.getCustomCommands();
853
873
  }
874
+ /**
875
+ * Register a custom slash command
876
+ */
877
+ registerSlashCommand(command) {
878
+ this.slashCommandManager.registerCommand(command);
879
+ }
854
880
  /**
855
881
  * Get the current permission mode
856
882
  */
@@ -868,24 +894,29 @@ export class Agent {
868
894
  this.options.callbacks?.onPermissionModeChange?.(mode);
869
895
  }
870
896
  /**
871
- * Handle plan mode transition, generating or clearing plan file path
872
- * @param mode - The current effective permission mode
897
+ * Truncate history to a specific index and revert file changes.
898
+ * @param index - The index of the user message to truncate to.
873
899
  */
874
- handlePlanModeTransition(mode) {
875
- if (mode === "plan") {
876
- this.planManager
877
- .getOrGeneratePlanFilePath()
878
- .then(({ path }) => {
879
- this.logger?.debug("Plan file path generated", { path });
880
- this.permissionManager.setPlanFilePath(path);
881
- })
882
- .catch((error) => {
883
- this.logger?.error("Failed to generate plan file path", error);
884
- });
885
- }
886
- else {
887
- this.permissionManager.setPlanFilePath(undefined);
888
- }
900
+ async truncateHistory(index) {
901
+ await this.messageManager.truncateHistory(index, this.reversionManager);
902
+ }
903
+ /**
904
+ * Get the current plan file path (for testing and UI)
905
+ */
906
+ getPlanFilePath() {
907
+ return this.permissionManager.getPlanFilePath();
908
+ }
909
+ /**
910
+ * Get all currently allowed rules (for testing and UI)
911
+ */
912
+ getAllowedRules() {
913
+ return this.permissionManager.getAllowedRules();
914
+ }
915
+ /**
916
+ * Check permission for a tool call (for testing)
917
+ */
918
+ async checkPermission(context) {
919
+ return this.permissionManager.checkPermission(context);
889
920
  }
890
921
  /**
891
922
  * Add a persistent permission rule
@@ -920,4 +951,24 @@ export class Agent {
920
951
  }
921
952
  }
922
953
  }
954
+ /**
955
+ * Handle plan mode transition, generating or clearing plan file path
956
+ * @param mode - The current effective permission mode
957
+ */
958
+ handlePlanModeTransition(mode) {
959
+ if (mode === "plan") {
960
+ this.planManager
961
+ .getOrGeneratePlanFilePath()
962
+ .then(({ path }) => {
963
+ this.logger?.debug("Plan file path generated", { path });
964
+ this.permissionManager.setPlanFilePath(path);
965
+ })
966
+ .catch((error) => {
967
+ this.logger?.error("Failed to generate plan file path", error);
968
+ });
969
+ }
970
+ else {
971
+ this.permissionManager.setPlanFilePath(undefined);
972
+ }
973
+ }
923
974
  }
@@ -2,10 +2,15 @@ export declare const BASE_SYSTEM_PROMPT = "You are an interactive CLI tool that
2
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
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
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 = "\n- Use specialized tools instead of bash commands when possible, as this provides a better user experience. For file operations, use dedicated tools: Read for reading files instead of cat/head/tail, Edit/MultiEdit for editing instead of sed/awk, Write for creating files instead of cat with heredoc or echo redirection, and LS/Glob/Grep for searching and listing files instead of find/ls/grep.";
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";
6
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.";
7
11
  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.";
8
- export declare const INIT_PROMPT = "Please analyze this codebase and create a AGENTS.md file, which will be given to future instances of Wave Code 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 Wave Code when working with code in this repository.\n```";
12
+ 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.";
13
+ 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```";
9
14
  export declare function buildSystemPrompt(basePrompt: string, tools: {
10
15
  name?: string;
11
16
  function?: {
@@ -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;AAEv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AE,GACtD,MAAM,CAsDR"}
@@ -27,13 +27,32 @@ export const SUBAGENT_POLICY = `
27
27
  - When doing file search, prefer to use the ${TASK_TOOL_NAME} tool in order to reduce context usage.
28
28
  - You should proactively use the ${TASK_TOOL_NAME} tool with specialized agents when the task at hand matches the agent's description.
29
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 = `
31
- - Use specialized tools instead of bash commands when possible, as this provides a better user experience. For file operations, use dedicated tools: ${READ_TOOL_NAME} for reading files instead of cat/head/tail, ${EDIT_TOOL_NAME}/${MULTI_EDIT_TOOL_NAME} for editing instead of sed/awk, ${WRITE_TOOL_NAME} for creating files instead of cat with heredoc or echo redirection, and ${LS_TOOL_NAME}/${GLOB_TOOL_NAME}/${GREP_TOOL_NAME} for searching and listing files instead of find/ls/grep.`;
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`;
32
35
  export const BASH_POLICY = `
33
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.
34
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.`;
35
38
  export const DEFAULT_SYSTEM_PROMPT = BASE_SYSTEM_PROMPT;
36
- export const INIT_PROMPT = `Please analyze this codebase and create a AGENTS.md file, which will be given to future instances of Wave Code to operate in this repository.
39
+ 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
+
41
+ Your strengths:
42
+ - Searching for code, configurations, and patterns across large codebases
43
+ - Analyzing multiple files to understand system architecture
44
+ - Investigating complex questions that require exploring many files
45
+ - Performing multi-step research tasks
46
+
47
+ Guidelines:
48
+ - For file searches: Use Grep or Glob when you need to search broadly. Use Read when you know the specific file path.
49
+ - For analysis: Start broad and narrow down. Use multiple search strategies if the first doesn't yield results.
50
+ - Be thorough: Check multiple locations, consider different naming conventions, look for related files.
51
+ - NEVER create files unless they're absolutely necessary for achieving your goal. ALWAYS prefer editing an existing file to creating a new one.
52
+ - NEVER proactively create documentation files (*.md) or README files. Only create documentation files if explicitly requested.
53
+ - 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
+ - For clear communication, avoid using emojis.`;
55
+ 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.
37
56
 
38
57
  What to add:
39
58
  1. 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.
@@ -52,7 +71,7 @@ Usage notes:
52
71
  \`\`\`
53
72
  # AGENTS.md
54
73
 
55
- This file provides guidance to Wave Code when working with code in this repository.
74
+ This file provides guidance to Agent when working with code in this repository.
56
75
  \`\`\``;
57
76
  export function buildSystemPrompt(basePrompt, tools) {
58
77
  let prompt = basePrompt;
@@ -73,7 +92,24 @@ export function buildSystemPrompt(basePrompt, tools) {
73
92
  toolNames.has(LS_TOOL_NAME) ||
74
93
  toolNames.has(GLOB_TOOL_NAME) ||
75
94
  toolNames.has(GREP_TOOL_NAME)) {
76
- prompt += FILE_TOOL_POLICY;
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
+ }
77
113
  }
78
114
  if (toolNames.has(BASH_TOOL_NAME)) {
79
115
  prompt += BASH_POLICY;
package/dist/index.d.ts CHANGED
@@ -9,7 +9,6 @@ export * from "./constants/tools.js";
9
9
  export * from "./managers/pluginManager.js";
10
10
  export * from "./managers/pluginScopeManager.js";
11
11
  export * from "./agent.js";
12
- export * from "./utils/bashHistory.js";
13
12
  export * from "./utils/bashParser.js";
14
13
  export * from "./utils/convertMessagesForAPI.js";
15
14
  export * from "./utils/fileFilter.js";
@@ -18,6 +17,7 @@ export * from "./utils/globalLogger.js";
18
17
  export * from "./utils/mcpUtils.js";
19
18
  export * from "./utils/messageOperations.js";
20
19
  export * from "./utils/path.js";
20
+ export * from "./utils/promptHistory.js";
21
21
  export * from "./utils/stringUtils.js";
22
22
  export * from "./utils/customCommands.js";
23
23
  export * from "./utils/hookMatcher.js";
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,cAAc,yBAAyB,CAAC;AACxC,cAAc,sBAAsB,CAAC;AACrC,cAAc,uBAAuB,CAAC;AACtC,cAAc,oBAAoB,CAAC;AACn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AAkB,CAAC"}
package/dist/index.js CHANGED
@@ -14,7 +14,6 @@ export * from "./managers/pluginScopeManager.js";
14
14
  // Export main agent
15
15
  export * from "./agent.js";
16
16
  // Export all utilities
17
- export * from "./utils/bashHistory.js";
18
17
  export * from "./utils/bashParser.js";
19
18
  export * from "./utils/convertMessagesForAPI.js";
20
19
  export * from "./utils/fileFilter.js";
@@ -23,6 +22,7 @@ export * from "./utils/globalLogger.js";
23
22
  export * from "./utils/mcpUtils.js";
24
23
  export * from "./utils/messageOperations.js";
25
24
  export * from "./utils/path.js";
25
+ export * from "./utils/promptHistory.js";
26
26
  export * from "./utils/stringUtils.js";
27
27
  export * from "./utils/customCommands.js";
28
28
  export * from "./utils/hookMatcher.js";
@@ -1 +1 @@
1
- {"version":3,"file":"MemoryRuleManager.d.ts","sourceRoot":"","sources":["../../src/managers/MemoryRuleManager.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAOzD,MAAM,WAAW,uBAAuB;IACtC,0CAA0C;IAC1C,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC;IAClC,0DAA0D;IAC1D,aAAa,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;CAC5B;AAED,MAAM,WAAW,wBAAwB;IACvC,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,qBAAa,iBAAiB;IAC5B,OAAO,CAAC,KAAK,CAGX;IAEF,OAAO,CAAC,OAAO,CAAS;IACxB,OAAO,CAAC,OAAO,CAAoB;gBAEvB,OAAO,EAAE,wBAAwB;IAK7C;;OAEG;IACG,aAAa,IAAI,OAAO,CAAC,IAAI,CAAC;YAetB,aAAa;YAyDb,YAAY;IAqB1B;;OAEG;IACH,cAAc,CAAC,cAAc,EAAE,MAAM,EAAE,GAAG,UAAU,EAAE;IAUtD;;OAEG;IACG,MAAM,IAAI,OAAO,CAAC,IAAI,CAAC;CAG9B"}
1
+ {"version":3,"file":"MemoryRuleManager.d.ts","sourceRoot":"","sources":["../../src/managers/MemoryRuleManager.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAOzD,MAAM,WAAW,uBAAuB;IACtC,0CAA0C;IAC1C,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC;IAClC,0DAA0D;IAC1D,aAAa,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;CAC5B;AAED,MAAM,WAAW,wBAAwB;IACvC,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,qBAAa,iBAAiB;IAC5B,OAAO,CAAC,KAAK,CAGX;IAEF,OAAO,CAAC,OAAO,CAAS;IACxB,OAAO,CAAC,OAAO,CAAoB;gBAEvB,OAAO,EAAE,wBAAwB;IAK7C;;OAEG;IACG,aAAa,IAAI,OAAO,CAAC,IAAI,CAAC;YA8BtB,aAAa;YAyDb,YAAY;IAsB1B;;OAEG;IACH,cAAc,CAAC,cAAc,EAAE,MAAM,EAAE,GAAG,UAAU,EAAE;IAUtD;;OAEG;IACG,MAAM,IAAI,OAAO,CAAC,IAAI,CAAC;CAG9B"}
@@ -18,13 +18,26 @@ export class MemoryRuleManager {
18
18
  async discoverRules() {
19
19
  const projectRulesDir = path.join(this.workdir, ".wave", "rules");
20
20
  const userRulesDir = path.join(os.homedir(), ".wave", "rules");
21
+ logger.debug(`Scanning for modular memory rules...`);
22
+ logger.debug(` User rules directory: ${userRulesDir}`);
23
+ logger.debug(` Project rules directory: ${projectRulesDir}`);
21
24
  const newRules = {};
22
25
  // Discover user rules first, then project rules so project rules can override if needed
23
26
  // (though IDs are based on file path, so they shouldn't collide unless same path)
24
27
  await this.scanDirectory(userRulesDir, "user", newRules);
25
28
  await this.scanDirectory(projectRulesDir, "project", newRules);
26
29
  this.state.rules = newRules;
27
- logger.debug(`Discovered ${Object.keys(newRules).length} memory rules`);
30
+ const ruleCount = Object.keys(newRules).length;
31
+ logger.debug(`Discovered ${ruleCount} modular memory rules`);
32
+ if (ruleCount > 0) {
33
+ logger.debug("Loaded memory rules:");
34
+ for (const [id, rule] of Object.entries(newRules)) {
35
+ const pathInfo = rule.metadata.paths
36
+ ? `paths: ${JSON.stringify(rule.metadata.paths)}`
37
+ : "global (no path restriction)";
38
+ logger.debug(` - ${id} (${rule.source}): ${pathInfo}`);
39
+ }
40
+ }
28
41
  }
29
42
  async scanDirectory(dir, source, registry, visited = new Set()) {
30
43
  const realDir = await fs.realpath(dir).catch(() => dir);
@@ -84,6 +97,7 @@ export class MemoryRuleManager {
84
97
  const relativeId = path.relative(rulesRoot, filePath);
85
98
  rule.id = relativeId;
86
99
  registry[rule.id] = rule;
100
+ logger.debug(`Loaded memory rule: ${relativeId} from ${filePath}`);
87
101
  }
88
102
  catch (error) {
89
103
  logger.error(`Failed to parse memory rule at ${filePath}:`, error);
@@ -19,11 +19,13 @@ export interface AIManagerOptions {
19
19
  workdir: string;
20
20
  systemPrompt?: string;
21
21
  subagentType?: string;
22
+ reversionManager?: import("./reversionManager.js").ReversionManager;
22
23
  /**Whether to use streaming mode for AI responses - defaults to true */
23
24
  stream?: boolean;
24
25
  getGatewayConfig: () => GatewayConfig;
25
26
  getModelConfig: () => ModelConfig;
26
27
  getMaxInputTokens: () => number;
28
+ getLanguage: () => string | undefined;
27
29
  getEnvironmentVars?: () => Record<string, string>;
28
30
  }
29
31
  export declare class AIManager {
@@ -35,6 +37,7 @@ export declare class AIManager {
35
37
  private messageManager;
36
38
  private backgroundBashManager?;
37
39
  private hookManager?;
40
+ private reversionManager?;
38
41
  private permissionManager?;
39
42
  private workdir;
40
43
  private systemPrompt?;
@@ -43,11 +46,13 @@ export declare class AIManager {
43
46
  private getGatewayConfigFn;
44
47
  private getModelConfigFn;
45
48
  private getMaxInputTokensFn;
49
+ private getLanguageFn;
46
50
  private getEnvironmentVarsFn?;
47
51
  constructor(options: AIManagerOptions);
48
52
  getGatewayConfig(): GatewayConfig;
49
53
  getModelConfig(): ModelConfig;
50
54
  getMaxInputTokens(): number;
55
+ getLanguage(): string | undefined;
51
56
  private isCompressing;
52
57
  private callbacks;
53
58
  /**
@@ -63,7 +68,7 @@ export declare class AIManager {
63
68
  sendAIMessage(options?: {
64
69
  recursionDepth?: number;
65
70
  model?: string;
66
- /** Rules for automatic tool approval (e.g., "Bash(git status:*)") */
71
+ /** Rules for automatic tool approval (e.g., "Bash(git status*)") */
67
72
  allowedRules?: string[];
68
73
  /** List of tools available to the AI (e.g., ["Bash", "Read"]) */
69
74
  tools?: string[];