wave-agent-sdk 0.0.5 → 0.0.7

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 +3 -6
  2. package/dist/agent.d.ts.map +1 -1
  3. package/dist/agent.js +24 -21
  4. package/dist/index.d.ts +3 -2
  5. package/dist/index.d.ts.map +1 -1
  6. package/dist/index.js +3 -3
  7. package/dist/managers/aiManager.d.ts +4 -2
  8. package/dist/managers/aiManager.d.ts.map +1 -1
  9. package/dist/managers/aiManager.js +91 -53
  10. package/dist/managers/backgroundBashManager.d.ts +1 -1
  11. package/dist/managers/backgroundBashManager.d.ts.map +1 -1
  12. package/dist/{hooks/manager.d.ts → managers/hookManager.d.ts} +27 -16
  13. package/dist/managers/hookManager.d.ts.map +1 -0
  14. package/dist/{hooks/manager.js → managers/hookManager.js} +112 -17
  15. package/dist/managers/mcpManager.d.ts +1 -1
  16. package/dist/managers/mcpManager.d.ts.map +1 -1
  17. package/dist/managers/messageManager.d.ts +20 -15
  18. package/dist/managers/messageManager.d.ts.map +1 -1
  19. package/dist/managers/messageManager.js +19 -25
  20. package/dist/managers/skillManager.d.ts +1 -1
  21. package/dist/managers/skillManager.d.ts.map +1 -1
  22. package/dist/managers/slashCommandManager.d.ts +1 -1
  23. package/dist/managers/slashCommandManager.d.ts.map +1 -1
  24. package/dist/managers/slashCommandManager.js +5 -2
  25. package/dist/managers/subagentManager.d.ts +7 -12
  26. package/dist/managers/subagentManager.d.ts.map +1 -1
  27. package/dist/managers/subagentManager.js +40 -46
  28. package/dist/managers/toolManager.d.ts +1 -1
  29. package/dist/managers/toolManager.d.ts.map +1 -1
  30. package/dist/services/aiService.d.ts +1 -1
  31. package/dist/services/aiService.d.ts.map +1 -1
  32. package/dist/services/aiService.js +8 -1
  33. package/dist/services/hook.d.ts +56 -0
  34. package/dist/services/hook.d.ts.map +1 -0
  35. package/dist/services/hook.js +276 -0
  36. package/dist/services/session.d.ts +1 -1
  37. package/dist/services/session.d.ts.map +1 -1
  38. package/dist/services/session.js +5 -4
  39. package/dist/tools/taskTool.d.ts.map +1 -1
  40. package/dist/tools/taskTool.js +7 -3
  41. package/dist/tools/todoWriteTool.d.ts.map +1 -1
  42. package/dist/tools/todoWriteTool.js +3 -10
  43. package/dist/types/commands.d.ts +24 -0
  44. package/dist/types/commands.d.ts.map +1 -0
  45. package/dist/types/commands.js +5 -0
  46. package/dist/types/config.d.ts +13 -0
  47. package/dist/types/config.d.ts.map +1 -0
  48. package/dist/types/config.js +5 -0
  49. package/dist/types/core.d.ts +38 -0
  50. package/dist/types/core.d.ts.map +1 -0
  51. package/dist/{types.js → types/core.js} +4 -13
  52. package/dist/{hooks/types.d.ts → types/hooks.d.ts} +2 -1
  53. package/dist/types/hooks.d.ts.map +1 -0
  54. package/dist/types/index.d.ts +20 -0
  55. package/dist/types/index.d.ts.map +1 -0
  56. package/dist/types/index.js +21 -0
  57. package/dist/types/mcp.d.ts +28 -0
  58. package/dist/types/mcp.d.ts.map +1 -0
  59. package/dist/types/mcp.js +5 -0
  60. package/dist/types/messaging.d.ts +80 -0
  61. package/dist/types/messaging.d.ts.map +1 -0
  62. package/dist/types/messaging.js +9 -0
  63. package/dist/types/processes.d.ts +17 -0
  64. package/dist/types/processes.d.ts.map +1 -0
  65. package/dist/types/processes.js +5 -0
  66. package/dist/types/skills.d.ts +78 -0
  67. package/dist/types/skills.d.ts.map +1 -0
  68. package/dist/types/skills.js +17 -0
  69. package/dist/utils/configResolver.d.ts +1 -1
  70. package/dist/utils/configResolver.d.ts.map +1 -1
  71. package/dist/utils/configResolver.js +1 -1
  72. package/dist/utils/configValidator.d.ts +1 -1
  73. package/dist/utils/configValidator.d.ts.map +1 -1
  74. package/dist/utils/configValidator.js +1 -1
  75. package/dist/utils/convertMessagesForAPI.d.ts +1 -1
  76. package/dist/utils/convertMessagesForAPI.d.ts.map +1 -1
  77. package/dist/utils/convertMessagesForAPI.js +1 -8
  78. package/dist/utils/customCommands.d.ts +1 -1
  79. package/dist/utils/customCommands.d.ts.map +1 -1
  80. package/dist/{hooks/matcher.d.ts → utils/hookMatcher.d.ts} +2 -7
  81. package/dist/utils/hookMatcher.d.ts.map +1 -0
  82. package/dist/utils/markdownParser.d.ts +1 -1
  83. package/dist/utils/markdownParser.d.ts.map +1 -1
  84. package/dist/utils/mcpUtils.d.ts +1 -1
  85. package/dist/utils/mcpUtils.d.ts.map +1 -1
  86. package/dist/utils/messageOperations.d.ts +14 -21
  87. package/dist/utils/messageOperations.d.ts.map +1 -1
  88. package/dist/utils/messageOperations.js +37 -20
  89. package/dist/utils/skillParser.d.ts +1 -1
  90. package/dist/utils/skillParser.d.ts.map +1 -1
  91. package/package.json +1 -1
  92. package/src/agent.ts +49 -43
  93. package/src/index.ts +3 -4
  94. package/src/managers/aiManager.ts +241 -160
  95. package/src/managers/backgroundBashManager.ts +1 -1
  96. package/src/{hooks/manager.ts → managers/hookManager.ts} +168 -56
  97. package/src/managers/mcpManager.ts +1 -1
  98. package/src/managers/messageManager.ts +44 -44
  99. package/src/managers/skillManager.ts +1 -1
  100. package/src/managers/slashCommandManager.ts +10 -7
  101. package/src/managers/subagentManager.ts +47 -54
  102. package/src/managers/toolManager.ts +1 -1
  103. package/src/services/aiService.ts +9 -2
  104. package/src/services/hook.ts +360 -0
  105. package/src/services/session.ts +6 -7
  106. package/src/tools/taskTool.ts +13 -5
  107. package/src/tools/todoWriteTool.ts +3 -11
  108. package/src/types/commands.ts +26 -0
  109. package/src/types/config.ts +14 -0
  110. package/src/types/core.ts +49 -0
  111. package/src/{hooks/types.ts → types/hooks.ts} +1 -0
  112. package/src/types/index.ts +23 -0
  113. package/src/types/mcp.ts +31 -0
  114. package/src/types/messaging.ts +102 -0
  115. package/src/types/processes.ts +18 -0
  116. package/src/types/skills.ts +91 -0
  117. package/src/utils/configResolver.ts +1 -1
  118. package/src/utils/configValidator.ts +5 -1
  119. package/src/utils/convertMessagesForAPI.ts +2 -10
  120. package/src/utils/customCommands.ts +1 -1
  121. package/src/{hooks/matcher.ts → utils/hookMatcher.ts} +1 -12
  122. package/src/utils/markdownParser.ts +1 -1
  123. package/src/utils/mcpUtils.ts +1 -1
  124. package/src/utils/messageOperations.ts +56 -42
  125. package/src/utils/skillParser.ts +1 -1
  126. package/dist/hooks/executor.d.ts +0 -56
  127. package/dist/hooks/executor.d.ts.map +0 -1
  128. package/dist/hooks/executor.js +0 -312
  129. package/dist/hooks/index.d.ts +0 -17
  130. package/dist/hooks/index.d.ts.map +0 -1
  131. package/dist/hooks/index.js +0 -14
  132. package/dist/hooks/manager.d.ts.map +0 -1
  133. package/dist/hooks/matcher.d.ts.map +0 -1
  134. package/dist/hooks/settings.d.ts +0 -46
  135. package/dist/hooks/settings.d.ts.map +0 -1
  136. package/dist/hooks/settings.js +0 -100
  137. package/dist/hooks/types.d.ts.map +0 -1
  138. package/dist/types.d.ts +0 -288
  139. package/dist/types.d.ts.map +0 -1
  140. package/src/hooks/executor.ts +0 -440
  141. package/src/hooks/index.ts +0 -52
  142. package/src/hooks/settings.ts +0 -129
  143. package/src/types.ts +0 -357
  144. /package/dist/{hooks/types.js → types/hooks.js} +0 -0
  145. /package/dist/{hooks/matcher.js → utils/hookMatcher.js} +0 -0
@@ -1,312 +0,0 @@
1
- /**
2
- * Hook Command Executor
3
- *
4
- * Handles the execution of hook commands in isolated processes with proper
5
- * timeout handling, environment variable injection, and cross-platform support.
6
- */
7
- import { spawn } from "child_process";
8
- import { getSessionFilePath, } from "./types.js";
9
- /**
10
- * Build JSON input data for hook stdin
11
- */
12
- function buildHookJsonInput(context) {
13
- const jsonInput = {
14
- session_id: context.sessionId || "unknown",
15
- transcript_path: context.transcriptPath ||
16
- (context.sessionId ? getSessionFilePath(context.sessionId) : ""),
17
- cwd: context.cwd || context.projectDir,
18
- hook_event_name: context.event,
19
- };
20
- // Add optional fields based on event type
21
- if (context.event === "PreToolUse" || context.event === "PostToolUse") {
22
- if (context.toolName) {
23
- jsonInput.tool_name = context.toolName;
24
- }
25
- if (context.toolInput !== undefined) {
26
- jsonInput.tool_input = context.toolInput;
27
- }
28
- }
29
- if (context.event === "PostToolUse" && context.toolResponse !== undefined) {
30
- jsonInput.tool_response = context.toolResponse;
31
- }
32
- if (context.event === "UserPromptSubmit" &&
33
- context.userPrompt !== undefined) {
34
- jsonInput.user_prompt = context.userPrompt;
35
- }
36
- return jsonInput;
37
- }
38
- export class HookExecutor {
39
- constructor(logger, options) {
40
- this.defaultTimeout = 10000; // 10 seconds
41
- this.maxTimeout = 300000; // 5 minutes
42
- this.logger = logger;
43
- // Skip execution in test environment unless we're specifically testing the executor
44
- this.skipExecution =
45
- options?.skipExecution ??
46
- ((process.env.NODE_ENV === "test" || process.env.VITEST === "true") &&
47
- !process.env.WAVE_TEST_HOOKS_EXECUTION);
48
- }
49
- /**
50
- * Execute a single hook command in an isolated process
51
- */
52
- async executeCommand(command, context, options = {}) {
53
- const startTime = Date.now();
54
- const timeout = Math.min(options.timeout ?? this.defaultTimeout, this.maxTimeout);
55
- const cwd = options.cwd ?? context.projectDir;
56
- // Skip command execution in test environment (unless specifically testing hooks)
57
- if (this.skipExecution) {
58
- this.logger?.debug(`[Hook] Skipping command execution: ${command}`);
59
- return {
60
- success: true,
61
- exitCode: 0,
62
- stdout: "Test environment: command execution skipped",
63
- duration: Date.now() - startTime,
64
- timedOut: false,
65
- };
66
- }
67
- // Log hook execution start
68
- this.logger?.debug(`[Hook] Executing ${context.event} hook: ${command}`);
69
- this.logger?.debug(`[Hook] Context: event=${context.event}, tool=${context.toolName || "N/A"}, cwd=${cwd}`);
70
- // Validate command safety
71
- if (!this.isCommandSafe(command)) {
72
- const error = "Command contains potentially unsafe characters";
73
- this.logger?.warn(`[Hook] Command safety validation failed: ${error}`);
74
- return {
75
- success: false,
76
- exitCode: -1,
77
- stderr: error,
78
- duration: Date.now() - startTime,
79
- timedOut: false,
80
- };
81
- }
82
- // Prepare environment variables
83
- const env = this.buildEnvironment(context);
84
- // Resolve command with environment variables
85
- const resolvedCommand = this.resolveEnvironmentVariables(command, env);
86
- // Prepare JSON input for stdin (if extended context is provided)
87
- const isExtendedContext = "sessionId" in context ||
88
- "toolInput" in context ||
89
- "toolResponse" in context ||
90
- "userPrompt" in context;
91
- const jsonInput = isExtendedContext
92
- ? buildHookJsonInput(context)
93
- : null;
94
- this.logger?.debug(`[Hook] Resolved command: ${resolvedCommand}`);
95
- if (jsonInput) {
96
- this.logger?.debug(`[Hook] JSON input: ${JSON.stringify(jsonInput)}`);
97
- }
98
- return new Promise((resolve) => {
99
- let stdout = "";
100
- let stderr = "";
101
- let timedOut = false;
102
- let childProcess;
103
- // Setup timeout
104
- const timeoutId = setTimeout(() => {
105
- timedOut = true;
106
- this.logger?.warn(`[Hook] Command timed out after ${timeout}ms: ${resolvedCommand}`);
107
- if (childProcess && !childProcess.killed) {
108
- childProcess.kill("SIGTERM");
109
- // Force kill after 5 seconds if SIGTERM doesn't work
110
- setTimeout(() => {
111
- if (childProcess && !childProcess.killed) {
112
- this.logger?.warn(`[Hook] Force killing process: ${resolvedCommand}`);
113
- childProcess.kill("SIGKILL");
114
- }
115
- }, 5000);
116
- }
117
- }, timeout);
118
- try {
119
- // Execute command using shell for cross-platform compatibility
120
- const shell = process.platform === "win32" ? "cmd.exe" : "/bin/sh";
121
- const shellArgs = process.platform === "win32" ? ["/c"] : ["-c"];
122
- childProcess = spawn(shell, [...shellArgs, resolvedCommand], {
123
- cwd,
124
- env,
125
- stdio: "pipe",
126
- windowsHide: true, // Hide console window on Windows
127
- });
128
- this.logger?.debug(`[Hook] Process started (PID: ${childProcess.pid})`);
129
- // Write JSON input to stdin if available
130
- if (jsonInput && childProcess.stdin) {
131
- try {
132
- const jsonString = JSON.stringify(jsonInput, null, 2);
133
- childProcess.stdin.write(jsonString);
134
- childProcess.stdin.end();
135
- this.logger?.debug(`[Hook] JSON input written to stdin`);
136
- }
137
- catch (error) {
138
- this.logger?.warn(`[Hook] Failed to write JSON to stdin: ${error}`);
139
- }
140
- }
141
- // Collect stdout
142
- childProcess.stdout?.on("data", (data) => {
143
- stdout += data.toString();
144
- });
145
- // Collect stderr
146
- childProcess.stderr?.on("data", (data) => {
147
- stderr += data.toString();
148
- });
149
- // Handle process completion
150
- childProcess.on("close", (exitCode) => {
151
- clearTimeout(timeoutId);
152
- const duration = Date.now() - startTime;
153
- const success = !timedOut && exitCode === 0;
154
- // Log execution result
155
- if (success) {
156
- this.logger?.debug(`[Hook] Command completed successfully in ${duration}ms (exit code: ${exitCode})`);
157
- }
158
- else {
159
- this.logger?.warn(`[Hook] Command failed in ${duration}ms (exit code: ${exitCode}, timed out: ${timedOut})`);
160
- if (stderr) {
161
- this.logger?.warn(`[Hook] stderr: ${stderr.trim()}`);
162
- }
163
- }
164
- if (stdout && stdout.trim()) {
165
- this.logger?.debug(`[Hook] stdout: ${stdout.trim()}`);
166
- }
167
- resolve({
168
- success,
169
- exitCode: exitCode ?? undefined,
170
- stdout: stdout.trim() || undefined,
171
- stderr: stderr.trim() || undefined,
172
- duration,
173
- timedOut,
174
- });
175
- });
176
- // Handle process errors
177
- childProcess.on("error", (error) => {
178
- clearTimeout(timeoutId);
179
- const duration = Date.now() - startTime;
180
- this.logger?.error(`[Hook] Process error in ${duration}ms: ${error.message}`);
181
- resolve({
182
- success: false,
183
- stderr: error.message,
184
- duration,
185
- timedOut,
186
- });
187
- });
188
- }
189
- catch (error) {
190
- clearTimeout(timeoutId);
191
- const duration = Date.now() - startTime;
192
- const errorMessage = error instanceof Error ? error.message : "Unknown execution error";
193
- this.logger?.error(`[Hook] Execution error in ${duration}ms: ${errorMessage}`);
194
- resolve({
195
- success: false,
196
- stderr: errorMessage,
197
- duration,
198
- timedOut,
199
- });
200
- }
201
- });
202
- }
203
- /**
204
- * Execute multiple commands in sequence
205
- * Stops on first failure unless configured otherwise
206
- */
207
- async executeCommands(commands, context, options = {}) {
208
- const results = [];
209
- this.logger?.debug(`[Hook] Executing ${commands.length} commands in sequence for ${context.event} event`);
210
- for (let i = 0; i < commands.length; i++) {
211
- const command = commands[i];
212
- this.logger?.debug(`[Hook] Command ${i + 1}/${commands.length}: ${command}`);
213
- try {
214
- const result = await this.executeCommand(command, context, options);
215
- results.push(result);
216
- // Stop on first failure to prevent cascading issues
217
- if (!result.success) {
218
- this.logger?.warn(`[Hook] Stopping sequence at command ${i + 1} due to failure`);
219
- break;
220
- }
221
- }
222
- catch (error) {
223
- // This shouldn't happen as executeCommand handles all errors,
224
- // but include defensive handling
225
- const errorMessage = error instanceof Error ? error.message : "Unknown error";
226
- this.logger?.error(`[Hook] Unexpected error in command ${i + 1}: ${errorMessage}`);
227
- results.push({
228
- success: false,
229
- stderr: errorMessage,
230
- duration: 0,
231
- timedOut: false,
232
- });
233
- break;
234
- }
235
- }
236
- const successCount = results.filter((r) => r.success).length;
237
- this.logger?.debug(`[Hook] Completed sequence: ${successCount}/${results.length} commands succeeded`);
238
- return results;
239
- }
240
- /**
241
- * Validate command safety to prevent injection attacks
242
- */
243
- isCommandSafe(command) {
244
- if (!command || typeof command !== "string")
245
- return false;
246
- // Command cannot be empty
247
- const trimmed = command.trim();
248
- if (trimmed.length === 0)
249
- return false;
250
- // Basic safety checks - these could be expanded based on security requirements
251
- const dangerousPatterns = [
252
- /\b(rm\s+-rf\s+\/|rm\s+-rf\s+~|rm\s+-rf\s+\*)/i, // Dangerous rm commands
253
- /\bdd\s+if=/i, // dd commands that could be destructive
254
- /:\(\)\{.*\}/, // Fork bomb patterns
255
- /\beval\s*[(\s]/i, // Code evaluation
256
- /\bexec\s+/i, // Process execution in shells
257
- ];
258
- // Check for obviously dangerous patterns
259
- if (dangerousPatterns.some((pattern) => pattern.test(trimmed))) {
260
- return false;
261
- }
262
- return true;
263
- }
264
- /**
265
- * Build environment variables for hook execution
266
- */
267
- buildEnvironment(context) {
268
- return {
269
- ...process.env, // Inherit parent environment
270
- WAVE_PROJECT_DIR: context.projectDir,
271
- };
272
- }
273
- /**
274
- * Resolve environment variables in command string
275
- */
276
- resolveEnvironmentVariables(command, env) {
277
- let resolved = command;
278
- // Replace $VAR and ${VAR} patterns
279
- Object.entries(env).forEach(([key, value]) => {
280
- if (value !== undefined) {
281
- // Handle both $VAR and ${VAR} syntax
282
- const dollarPattern = new RegExp(`\\$${key}\\b`, "g");
283
- const bracesPattern = new RegExp(`\\$\\{${key}\\}`, "g");
284
- resolved = resolved.replace(dollarPattern, value);
285
- resolved = resolved.replace(bracesPattern, value);
286
- }
287
- });
288
- return resolved;
289
- }
290
- /**
291
- * Get process statistics for monitoring
292
- */
293
- getExecutionStats() {
294
- return {
295
- platform: process.platform,
296
- defaultTimeout: this.defaultTimeout,
297
- maxTimeout: this.maxTimeout,
298
- };
299
- }
300
- /**
301
- * Test if the executor can run commands on this platform
302
- */
303
- isSupported() {
304
- try {
305
- // Try to detect shell availability - basic check could be enhanced with actual shell testing
306
- return true;
307
- }
308
- catch {
309
- return false;
310
- }
311
- }
312
- }
@@ -1,17 +0,0 @@
1
- /**
2
- * Hooks System Entry Point
3
- *
4
- * Exports all public APIs for the Wave Code hooks system.
5
- * This module provides a clean interface for integrating hooks
6
- * into AI workflows and CLI applications.
7
- */
8
- export type { HookEvent, HookCommand, HookEventConfig, HookConfiguration, HookExecutionContext, HookExecutionResult, HookExecutionOptions, ValidationResult, HookEnvironment, } from "./types.js";
9
- export { isValidHookEvent, isValidHookCommand, isValidHookEventConfig, HookExecutionError, HookConfigurationError, } from "./types.js";
10
- export type { IHookMatcher } from "./matcher.js";
11
- export { HookMatcher } from "./matcher.js";
12
- export type { IHookExecutor } from "./executor.js";
13
- export { HookExecutor } from "./executor.js";
14
- export type { IHookManager } from "./manager.js";
15
- export { HookManager } from "./manager.js";
16
- export { getUserHooksConfigPath, getProjectHooksConfigPath, loadUserHooksConfig, loadProjectHooksConfig, loadMergedHooksConfig, hasHooksConfiguration, getHooksConfigurationInfo, } from "./settings.js";
17
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/hooks/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,YAAY,EACV,SAAS,EACT,WAAW,EACX,eAAe,EACf,iBAAiB,EACjB,oBAAoB,EACpB,mBAAmB,EACnB,oBAAoB,EACpB,gBAAgB,EAChB,eAAe,GAChB,MAAM,YAAY,CAAC;AAGpB,OAAO,EACL,gBAAgB,EAChB,kBAAkB,EAClB,sBAAsB,EACtB,kBAAkB,EAClB,sBAAsB,GACvB,MAAM,YAAY,CAAC;AAGpB,YAAY,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AACjD,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAG3C,YAAY,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AACnD,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAG7C,YAAY,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AACjD,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAG3C,OAAO,EACL,sBAAsB,EACtB,yBAAyB,EACzB,mBAAmB,EACnB,sBAAsB,EACtB,qBAAqB,EACrB,qBAAqB,EACrB,yBAAyB,GAC1B,MAAM,eAAe,CAAC"}
@@ -1,14 +0,0 @@
1
- /**
2
- * Hooks System Entry Point
3
- *
4
- * Exports all public APIs for the Wave Code hooks system.
5
- * This module provides a clean interface for integrating hooks
6
- * into AI workflows and CLI applications.
7
- */
8
- // Type guards and utility functions
9
- export { isValidHookEvent, isValidHookCommand, isValidHookEventConfig, HookExecutionError, HookConfigurationError, } from "./types.js";
10
- export { HookMatcher } from "./matcher.js";
11
- export { HookExecutor } from "./executor.js";
12
- export { HookManager } from "./manager.js";
13
- // Settings and configuration loading
14
- export { getUserHooksConfigPath, getProjectHooksConfigPath, loadUserHooksConfig, loadProjectHooksConfig, loadMergedHooksConfig, hasHooksConfiguration, getHooksConfigurationInfo, } from "./settings.js";
@@ -1 +0,0 @@
1
- {"version":3,"file":"manager.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OAAO,EAAE,MAAM,GAAG,OAAO,CAAC;IAGzC,cAAc,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,GAAG,MAAM,GAAG,OAAO,GAAG,cAAc,CAAC;CAC9E;AAED,qBAAa,WAAY,YAAW,YAAY;IAC9C;;;;;;;OAOG;IACH,OAAO,CAAC,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO;IAYnD;;OAEG;IACH,OAAO,CAAC,aAAa;IAmBrB;;OAEG;IACH,cAAc,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO;IAoBxC;;OAEG;IACH,OAAO,CAAC,oBAAoB;IAmB5B;;OAEG;IACH,cAAc,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,GAAG,MAAM,GAAG,OAAO,GAAG,cAAc;IA6B5E;;;OAGG;IACH,UAAU,CAAC,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,GAAG,MAAM,EAAE;IAI1D;;;OAGG;IACH,OAAO,CAAC,OAAO,EAAE,MAAM,GAAG,CAAC,QAAQ,EAAE,MAAM,KAAK,OAAO;CAkCxD"}
@@ -1,46 +0,0 @@
1
- /**
2
- * Hook Settings Management
3
- *
4
- * Handles loading and merging of hook configurations from:
5
- * - User settings: ~/.wave/hooks.json
6
- * - Project settings: ./.wave/hooks.json
7
- */
8
- import type { PartialHookConfiguration } from "./types.js";
9
- /**
10
- * Get the user-specific hooks configuration file path
11
- */
12
- export declare function getUserHooksConfigPath(): string;
13
- /**
14
- * Get the project-specific hooks configuration file path
15
- */
16
- export declare function getProjectHooksConfigPath(workdir: string): string;
17
- /**
18
- * Load hooks configuration from a JSON file
19
- */
20
- export declare function loadHooksConfigFromFile(filePath: string): PartialHookConfiguration | null;
21
- /**
22
- * Load user hooks configuration
23
- */
24
- export declare function loadUserHooksConfig(): PartialHookConfiguration | null;
25
- /**
26
- * Load project hooks configuration
27
- */
28
- export declare function loadProjectHooksConfig(workdir: string): PartialHookConfiguration | null;
29
- /**
30
- * Load and merge hooks configuration with project settings taking precedence
31
- */
32
- export declare function loadMergedHooksConfig(workdir: string): PartialHookConfiguration;
33
- /**
34
- * Check if any hooks configuration files exist
35
- */
36
- export declare function hasHooksConfiguration(workdir: string): boolean;
37
- /**
38
- * Get information about available hooks configuration files
39
- */
40
- export declare function getHooksConfigurationInfo(workdir: string): {
41
- userConfigExists: boolean;
42
- projectConfigExists: boolean;
43
- userConfigPath: string;
44
- projectConfigPath: string;
45
- };
46
- //# sourceMappingURL=settings.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"settings.d.ts","sourceRoot":"","sources":["../../src/hooks/settings.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAKH,OAAO,KAAK,EAAqB,wBAAwB,EAAE,MAAM,YAAY,CAAC;AAG9E;;GAEG;AACH,wBAAgB,sBAAsB,IAAI,MAAM,CAE/C;AAED;;GAEG;AACH,wBAAgB,yBAAyB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAEjE;AAED;;GAEG;AACH,wBAAgB,uBAAuB,CACrC,QAAQ,EAAE,MAAM,GACf,wBAAwB,GAAG,IAAI,CAoBjC;AAED;;GAEG;AACH,wBAAgB,mBAAmB,IAAI,wBAAwB,GAAG,IAAI,CAErE;AAED;;GAEG;AACH,wBAAgB,sBAAsB,CACpC,OAAO,EAAE,MAAM,GACd,wBAAwB,GAAG,IAAI,CAEjC;AAED;;GAEG;AACH,wBAAgB,qBAAqB,CACnC,OAAO,EAAE,MAAM,GACd,wBAAwB,CAyB1B;AAED;;GAEG;AACH,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAK9D;AAED;;GAEG;AACH,wBAAgB,yBAAyB,CAAC,OAAO,EAAE,MAAM,GAAG;IAC1D,gBAAgB,EAAE,OAAO,CAAC;IAC1B,mBAAmB,EAAE,OAAO,CAAC;IAC7B,cAAc,EAAE,MAAM,CAAC;IACvB,iBAAiB,EAAE,MAAM,CAAC;CAC3B,CAOA"}
@@ -1,100 +0,0 @@
1
- /**
2
- * Hook Settings Management
3
- *
4
- * Handles loading and merging of hook configurations from:
5
- * - User settings: ~/.wave/hooks.json
6
- * - Project settings: ./.wave/hooks.json
7
- */
8
- import { existsSync, readFileSync } from "fs";
9
- import { join } from "path";
10
- import { homedir } from "os";
11
- import { isValidHookEvent } from "./types.js";
12
- /**
13
- * Get the user-specific hooks configuration file path
14
- */
15
- export function getUserHooksConfigPath() {
16
- return join(homedir(), ".wave", "hooks.json");
17
- }
18
- /**
19
- * Get the project-specific hooks configuration file path
20
- */
21
- export function getProjectHooksConfigPath(workdir) {
22
- return join(workdir, ".wave", "hooks.json");
23
- }
24
- /**
25
- * Load hooks configuration from a JSON file
26
- */
27
- export function loadHooksConfigFromFile(filePath) {
28
- try {
29
- if (!existsSync(filePath)) {
30
- return null;
31
- }
32
- const content = readFileSync(filePath, "utf-8");
33
- const config = JSON.parse(content);
34
- // Validate basic structure
35
- if (!config || typeof config !== "object" || !config.hooks) {
36
- console.warn(`Invalid hooks configuration structure in ${filePath}`);
37
- return null;
38
- }
39
- return config.hooks;
40
- }
41
- catch (error) {
42
- console.warn(`Failed to load hooks configuration from ${filePath}:`, error);
43
- return null;
44
- }
45
- }
46
- /**
47
- * Load user hooks configuration
48
- */
49
- export function loadUserHooksConfig() {
50
- return loadHooksConfigFromFile(getUserHooksConfigPath());
51
- }
52
- /**
53
- * Load project hooks configuration
54
- */
55
- export function loadProjectHooksConfig(workdir) {
56
- return loadHooksConfigFromFile(getProjectHooksConfigPath(workdir));
57
- }
58
- /**
59
- * Load and merge hooks configuration with project settings taking precedence
60
- */
61
- export function loadMergedHooksConfig(workdir) {
62
- const userConfig = loadUserHooksConfig();
63
- const projectConfig = loadProjectHooksConfig(workdir);
64
- const merged = {};
65
- // Start with user configuration
66
- if (userConfig) {
67
- Object.entries(userConfig).forEach(([event, configs]) => {
68
- if (isValidHookEvent(event)) {
69
- merged[event] = [...configs];
70
- }
71
- });
72
- }
73
- // Override with project configuration (project takes precedence)
74
- if (projectConfig) {
75
- Object.entries(projectConfig).forEach(([event, configs]) => {
76
- if (isValidHookEvent(event)) {
77
- merged[event] = [...configs];
78
- }
79
- });
80
- }
81
- return merged;
82
- }
83
- /**
84
- * Check if any hooks configuration files exist
85
- */
86
- export function hasHooksConfiguration(workdir) {
87
- return (existsSync(getUserHooksConfigPath()) ||
88
- existsSync(getProjectHooksConfigPath(workdir)));
89
- }
90
- /**
91
- * Get information about available hooks configuration files
92
- */
93
- export function getHooksConfigurationInfo(workdir) {
94
- return {
95
- userConfigExists: existsSync(getUserHooksConfigPath()),
96
- projectConfigExists: existsSync(getProjectHooksConfigPath(workdir)),
97
- userConfigPath: getUserHooksConfigPath(),
98
- projectConfigPath: getProjectHooksConfigPath(workdir),
99
- };
100
- }
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/hooks/types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAMH,wBAAgB,kBAAkB,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAG5D;AAGD,MAAM,MAAM,SAAS,GACjB,YAAY,GACZ,aAAa,GACb,kBAAkB,GAClB,MAAM,CAAC;AAGX,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,SAAS,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;CACjB;AAGD,MAAM,WAAW,eAAe;IAC9B,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,WAAW,EAAE,CAAC;CACtB;AAGD,MAAM,WAAW,iBAAiB;IAChC,KAAK,EAAE,OAAO,CAAC,MAAM,CAAC,SAAS,EAAE,eAAe,EAAE,CAAC,CAAC,CAAC;CACtD;AAGD,MAAM,MAAM,wBAAwB,GAAG,OAAO,CAC5C,MAAM,CAAC,SAAS,EAAE,eAAe,EAAE,CAAC,CACrC,CAAC;AAGF,MAAM,MAAM,uBAAuB,GAAG,MAAM,CAAC,SAAS,EAAE,eAAe,EAAE,CA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