wave-agent-sdk 1.0.4 → 1.0.6
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.
- package/dist/agent.d.ts +23 -1
- package/dist/agent.js +34 -4
- package/dist/managers/aiManager.d.ts +36 -0
- package/dist/managers/aiManager.js +240 -8
- package/dist/managers/messageManager.d.ts +1 -3
- package/dist/managers/messageManager.js +19 -9
- package/dist/managers/slashCommandManager.js +28 -0
- package/dist/managers/subagentManager.d.ts +0 -2
- package/dist/services/session.js +2 -9
- package/dist/telemetry/instrumentation.d.ts +1 -1
- package/dist/telemetry/instrumentation.js +57 -28
- package/dist/tools/bashTool.js +16 -6
- package/dist/tools/grepTool.js +11 -3
- package/dist/types/index.d.ts +3 -0
- package/dist/types/messaging.d.ts +2 -0
- package/dist/utils/containerSetup.js +0 -3
- package/dist/utils/messageOperations.d.ts +10 -1
- package/dist/utils/messageOperations.js +19 -1
- package/dist/utils/notificationXml.js +5 -0
- package/dist/utils/ripgrep.d.ts +4 -4
- package/dist/utils/ripgrep.js +4 -27
- package/package.json +20 -8
- package/bin/rg +0 -79
- package/dist/managers/forkedAgentManager.d.ts +0 -50
- package/dist/managers/forkedAgentManager.js +0 -130
- package/scripts/install_ripgrep.js +0 -111
- package/scripts/postinstall.js +0 -38
- package/src/agent.ts +0 -1271
- package/src/constants/subagents.ts +0 -4
- package/src/constants/toolLimits.ts +0 -15
- package/src/constants/tools.ts +0 -24
- package/src/core/plugin.ts +0 -237
- package/src/core/session.ts +0 -9
- package/src/index.ts +0 -38
- package/src/managers/MemoryRuleManager.ts +0 -198
- package/src/managers/aiManager.ts +0 -2429
- package/src/managers/backgroundTaskManager.ts +0 -480
- package/src/managers/bangManager.ts +0 -119
- package/src/managers/cronManager.ts +0 -401
- package/src/managers/foregroundTaskManager.ts +0 -30
- package/src/managers/forkedAgentManager.ts +0 -216
- package/src/managers/hookManager.ts +0 -1089
- package/src/managers/liveConfigManager.ts +0 -445
- package/src/managers/lspManager.ts +0 -470
- package/src/managers/mcpManager.ts +0 -1010
- package/src/managers/messageManager.ts +0 -1180
- package/src/managers/messageQueue.ts +0 -157
- package/src/managers/permissionManager.ts +0 -1140
- package/src/managers/planManager.ts +0 -112
- package/src/managers/pluginManager.ts +0 -330
- package/src/managers/pluginScopeManager.ts +0 -124
- package/src/managers/reversionManager.ts +0 -178
- package/src/managers/skillManager.ts +0 -578
- package/src/managers/slashCommandManager.ts +0 -564
- package/src/managers/subagentManager.ts +0 -915
- package/src/managers/toolManager.ts +0 -489
- package/src/managers/workflowManager.ts +0 -493
- package/src/prompts/autoMemory.ts +0 -33
- package/src/prompts/autoMemoryExtraction.ts +0 -146
- package/src/prompts/index.ts +0 -506
- package/src/prompts/planModeReminders.ts +0 -126
- package/src/services/GitService.ts +0 -131
- package/src/services/MarketplaceService.ts +0 -1052
- package/src/services/MemoryRuleService.ts +0 -71
- package/src/services/aiService.ts +0 -919
- package/src/services/authService.ts +0 -565
- package/src/services/autoMemoryService.ts +0 -280
- package/src/services/configurationService.ts +0 -1520
- package/src/services/fileWatcher.ts +0 -319
- package/src/services/hook.ts +0 -348
- package/src/services/initializationService.ts +0 -357
- package/src/services/interactionService.ts +0 -229
- package/src/services/jsonlHandler.ts +0 -295
- package/src/services/memory.ts +0 -234
- package/src/services/pluginLoader.ts +0 -252
- package/src/services/remoteSettingsService.ts +0 -366
- package/src/services/reversionService.ts +0 -122
- package/src/services/session.ts +0 -922
- package/src/services/taskManager.ts +0 -321
- package/src/telemetry/events.ts +0 -65
- package/src/telemetry/instrumentation.ts +0 -499
- package/src/telemetry/sessionTracing.ts +0 -348
- package/src/tools/agentTool.ts +0 -322
- package/src/tools/askUserQuestion.ts +0 -160
- package/src/tools/bashTool.ts +0 -621
- package/src/tools/buildTool.ts +0 -61
- package/src/tools/cronCreateTool.ts +0 -161
- package/src/tools/cronDeleteTool.ts +0 -51
- package/src/tools/cronListTool.ts +0 -47
- package/src/tools/editTool.ts +0 -313
- package/src/tools/enterPlanMode.ts +0 -124
- package/src/tools/enterWorktreeTool.ts +0 -190
- package/src/tools/exitPlanMode.ts +0 -139
- package/src/tools/exitWorktreeTool.ts +0 -236
- package/src/tools/globTool.ts +0 -167
- package/src/tools/grepTool.ts +0 -399
- package/src/tools/lspTool.ts +0 -883
- package/src/tools/readTool.ts +0 -426
- package/src/tools/skillTool.ts +0 -248
- package/src/tools/taskManagementTools.ts +0 -574
- package/src/tools/taskStopTool.ts +0 -78
- package/src/tools/types.ts +0 -137
- package/src/tools/webFetchTool.ts +0 -373
- package/src/tools/workflowTool.ts +0 -205
- package/src/tools/writeTool.ts +0 -267
- package/src/types/agent.ts +0 -128
- package/src/types/auth.ts +0 -19
- package/src/types/commands.ts +0 -30
- package/src/types/config.ts +0 -43
- package/src/types/configuration.ts +0 -168
- package/src/types/core.ts +0 -105
- package/src/types/cron.ts +0 -13
- package/src/types/environment.ts +0 -106
- package/src/types/fileSearch.ts +0 -4
- package/src/types/history.ts +0 -7
- package/src/types/hooks.ts +0 -256
- package/src/types/index.ts +0 -41
- package/src/types/lsp.ts +0 -98
- package/src/types/marketplace.ts +0 -71
- package/src/types/mcp.ts +0 -43
- package/src/types/memoryRule.ts +0 -31
- package/src/types/messaging.ts +0 -114
- package/src/types/permissions.ts +0 -80
- package/src/types/plugins.ts +0 -39
- package/src/types/processes.ts +0 -99
- package/src/types/reversion.ts +0 -29
- package/src/types/session.ts +0 -12
- package/src/types/skills.ts +0 -108
- package/src/types/tasks.ts +0 -13
- package/src/types/telemetry.ts +0 -98
- package/src/types/tools.ts +0 -44
- package/src/types/workflow.ts +0 -6
- package/src/utils/abortUtils.ts +0 -118
- package/src/utils/atomicWrite.ts +0 -61
- package/src/utils/bashParser.ts +0 -899
- package/src/utils/cacheControlUtils.ts +0 -426
- package/src/utils/commandArgumentParser.ts +0 -161
- package/src/utils/commandPathResolver.ts +0 -88
- package/src/utils/configPaths.ts +0 -220
- package/src/utils/configValidator.ts +0 -100
- package/src/utils/constants.ts +0 -39
- package/src/utils/container.ts +0 -92
- package/src/utils/containerSetup.ts +0 -371
- package/src/utils/convertMessagesForAPI.ts +0 -326
- package/src/utils/cronTasks.ts +0 -128
- package/src/utils/cronTasksLock.ts +0 -182
- package/src/utils/cronToHuman.ts +0 -99
- package/src/utils/customCommands.ts +0 -95
- package/src/utils/editUtils.ts +0 -20
- package/src/utils/fileFormat.ts +0 -40
- package/src/utils/fileSearch.ts +0 -151
- package/src/utils/fileUtils.ts +0 -223
- package/src/utils/gitUtils.ts +0 -315
- package/src/utils/globalLogger.ts +0 -128
- package/src/utils/groupMessagesByApiRound.ts +0 -121
- package/src/utils/hookMatcher.ts +0 -176
- package/src/utils/markdownParser.ts +0 -317
- package/src/utils/mcpUtils.ts +0 -138
- package/src/utils/messageOperations.ts +0 -641
- package/src/utils/modelCapabilities.ts +0 -30
- package/src/utils/nameGenerator.ts +0 -99
- package/src/utils/notificationXml.ts +0 -57
- package/src/utils/openaiClient.ts +0 -251
- package/src/utils/parseCronExpression.ts +0 -78
- package/src/utils/path.ts +0 -72
- package/src/utils/pathEncoder.ts +0 -400
- package/src/utils/pathSafety.ts +0 -40
- package/src/utils/promptHistory.ts +0 -168
- package/src/utils/ripgrep.ts +0 -35
- package/src/utils/shellResolver.ts +0 -190
- package/src/utils/skillParser.ts +0 -246
- package/src/utils/stringUtils.ts +0 -156
- package/src/utils/subagentParser.ts +0 -279
- package/src/utils/taskReminder.ts +0 -96
- package/src/utils/tokenCalculation.ts +0 -43
- package/src/utils/tokenEstimate.ts +0 -34
- package/src/utils/toolResultStorage.ts +0 -117
- package/src/utils/worktreeSession.ts +0 -26
- package/src/utils/worktreeUtils.ts +0 -786
- package/src/workflow/budgetTracker.ts +0 -34
- package/src/workflow/concurrencyLimiter.ts +0 -47
- package/src/workflow/journal.ts +0 -95
- package/src/workflow/progressReporter.ts +0 -141
- package/src/workflow/runState.ts +0 -65
- package/src/workflow/scriptRuntime.ts +0 -274
- package/src/workflow/structuredOutput.ts +0 -123
- package/src/workflow/types.ts +0 -101
- package/src/workflow/workflowApis.ts +0 -410
- package/vendor/ripgrep/linux-aarch64/rg +0 -0
- package/vendor/ripgrep/linux-x86_64/rg +0 -0
- package/vendor/ripgrep/macos-aarch64/rg +0 -0
- package/vendor/ripgrep/macos-x86_64/rg +0 -0
- package/vendor/ripgrep/windows-aarch64/rg.exe +0 -0
- package/vendor/ripgrep/windows-x86_64/rg.exe +0 -0
|
@@ -1,445 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Live Configuration Manager
|
|
3
|
-
*
|
|
4
|
-
* Orchestrates live configuration reload functionality including:
|
|
5
|
-
* - Hook configuration watching and reloading
|
|
6
|
-
* - Configuration file watching for settings.json files
|
|
7
|
-
* - Coordination between file watchers and configuration updates
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
import { existsSync } from "fs";
|
|
11
|
-
import type { Scope } from "../types/configuration.js";
|
|
12
|
-
import {
|
|
13
|
-
FileWatcherService,
|
|
14
|
-
type FileWatchEvent,
|
|
15
|
-
} from "../services/fileWatcher.js";
|
|
16
|
-
import type { HookManager } from "./hookManager.js";
|
|
17
|
-
import type { PermissionManager } from "./permissionManager.js";
|
|
18
|
-
import { isValidHookEvent } from "../types/hooks.js";
|
|
19
|
-
import { ConfigurationService } from "../services/configurationService.js";
|
|
20
|
-
import { Container } from "../utils/container.js";
|
|
21
|
-
|
|
22
|
-
import type {
|
|
23
|
-
ConfigurationLoadResult,
|
|
24
|
-
WaveConfiguration,
|
|
25
|
-
} from "../types/configuration.js";
|
|
26
|
-
|
|
27
|
-
import { logger } from "../utils/globalLogger.js";
|
|
28
|
-
|
|
29
|
-
export interface LiveConfigManagerOptions {
|
|
30
|
-
workdir: string;
|
|
31
|
-
onReload?: (config: WaveConfiguration) => void;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
export class LiveConfigManager {
|
|
35
|
-
private readonly workdir: string;
|
|
36
|
-
private isInitialized: boolean = false;
|
|
37
|
-
|
|
38
|
-
// Configuration state
|
|
39
|
-
private currentConfiguration: WaveConfiguration | null = null;
|
|
40
|
-
private lastValidConfiguration: WaveConfiguration | null = null;
|
|
41
|
-
|
|
42
|
-
// File watching state
|
|
43
|
-
private fileWatcher: FileWatcherService;
|
|
44
|
-
private userConfigPaths?: string[];
|
|
45
|
-
private projectConfigPaths?: string[];
|
|
46
|
-
private isWatching: boolean = false;
|
|
47
|
-
private reloadInProgress: boolean = false;
|
|
48
|
-
|
|
49
|
-
constructor(
|
|
50
|
-
private container: Container,
|
|
51
|
-
private options: LiveConfigManagerOptions,
|
|
52
|
-
) {
|
|
53
|
-
this.workdir = options.workdir;
|
|
54
|
-
this.fileWatcher = new FileWatcherService(logger);
|
|
55
|
-
this.setupFileWatcherEvents();
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
private get hookManager(): HookManager | undefined {
|
|
59
|
-
return this.container.get<HookManager>("HookManager");
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
private get permissionManager(): PermissionManager | undefined {
|
|
63
|
-
return this.container.get<PermissionManager>("PermissionManager");
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
private get configurationService(): ConfigurationService {
|
|
67
|
-
return this.container.get<ConfigurationService>("ConfigurationService")!;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
/**
|
|
71
|
-
* Initialize configuration watching
|
|
72
|
-
* Maps to FR-004: System MUST watch settings.json files
|
|
73
|
-
* Supports watching multiple file paths (e.g., local settings.local.json and settings.json)
|
|
74
|
-
*/
|
|
75
|
-
private async initializeWatching(
|
|
76
|
-
userPaths: string[],
|
|
77
|
-
projectPaths?: string[],
|
|
78
|
-
): Promise<void> {
|
|
79
|
-
try {
|
|
80
|
-
this.userConfigPaths = userPaths;
|
|
81
|
-
this.projectConfigPaths = projectPaths;
|
|
82
|
-
|
|
83
|
-
// Load initial configuration
|
|
84
|
-
await this.reloadConfiguration();
|
|
85
|
-
|
|
86
|
-
// Start watching user configs that exist
|
|
87
|
-
for (const userPath of userPaths) {
|
|
88
|
-
if (existsSync(userPath)) {
|
|
89
|
-
await this.fileWatcher.watchFile(userPath, (event) =>
|
|
90
|
-
this.handleFileChange(event, "user"),
|
|
91
|
-
);
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
// Start watching local configs that exist
|
|
96
|
-
if (projectPaths) {
|
|
97
|
-
for (const projectPath of projectPaths) {
|
|
98
|
-
if (existsSync(projectPath)) {
|
|
99
|
-
await this.fileWatcher.watchFile(projectPath, (event) =>
|
|
100
|
-
this.handleFileChange(event, "project"),
|
|
101
|
-
);
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
this.isWatching = true;
|
|
107
|
-
} catch (error) {
|
|
108
|
-
const errorMessage = `Failed to initialize configuration watching: ${(error as Error).message}`;
|
|
109
|
-
logger?.error(`Live Config: ${errorMessage}`);
|
|
110
|
-
throw new Error(errorMessage);
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
/**
|
|
115
|
-
* Get current configuration
|
|
116
|
-
*/
|
|
117
|
-
getCurrentConfiguration(): WaveConfiguration | null {
|
|
118
|
-
return this.currentConfiguration ? { ...this.currentConfiguration } : null;
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
/**
|
|
122
|
-
* Initialize configuration management with file watching
|
|
123
|
-
*/
|
|
124
|
-
async initialize(): Promise<void> {
|
|
125
|
-
if (this.isInitialized) {
|
|
126
|
-
return;
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
try {
|
|
130
|
-
// Get configuration file paths
|
|
131
|
-
const { userPaths, projectPaths } = this.getConfigurationPaths();
|
|
132
|
-
|
|
133
|
-
// Initialize configuration watching
|
|
134
|
-
await this.initializeWatching(userPaths, projectPaths);
|
|
135
|
-
|
|
136
|
-
this.isInitialized = true;
|
|
137
|
-
} catch (error) {
|
|
138
|
-
logger?.error(`Failed to initialize: ${(error as Error).message}`);
|
|
139
|
-
throw error;
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
/**
|
|
144
|
-
* Shutdown configuration management and cleanup resources
|
|
145
|
-
*/
|
|
146
|
-
async shutdown(): Promise<void> {
|
|
147
|
-
if (!this.isInitialized) {
|
|
148
|
-
return;
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
try {
|
|
152
|
-
this.isWatching = false;
|
|
153
|
-
|
|
154
|
-
// Cleanup file watcher
|
|
155
|
-
await this.fileWatcher.cleanup();
|
|
156
|
-
|
|
157
|
-
// Clean up state
|
|
158
|
-
this.currentConfiguration = null;
|
|
159
|
-
this.lastValidConfiguration = null;
|
|
160
|
-
|
|
161
|
-
this.isInitialized = false;
|
|
162
|
-
} catch (error) {
|
|
163
|
-
logger?.error(`Error during shutdown: ${(error as Error).message}`);
|
|
164
|
-
throw error;
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
/**
|
|
169
|
-
* Reload configuration from files
|
|
170
|
-
* Maps to FR-008: Continue with previous valid configuration on errors
|
|
171
|
-
*/
|
|
172
|
-
private async reloadConfiguration(): Promise<WaveConfiguration> {
|
|
173
|
-
if (this.reloadInProgress) {
|
|
174
|
-
return this.currentConfiguration || {};
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
this.reloadInProgress = true;
|
|
178
|
-
|
|
179
|
-
try {
|
|
180
|
-
// Load merged configuration using ConfigurationService
|
|
181
|
-
const loadResult: ConfigurationLoadResult =
|
|
182
|
-
await this.configurationService.loadMergedConfiguration(this.workdir);
|
|
183
|
-
const newConfig = loadResult.configuration;
|
|
184
|
-
|
|
185
|
-
// Check for errors during loading
|
|
186
|
-
if (!loadResult.success) {
|
|
187
|
-
const errorMessage =
|
|
188
|
-
loadResult.error || "Configuration loading failed with unknown error";
|
|
189
|
-
logger?.error(
|
|
190
|
-
`Live Config: Configuration loading failed: ${errorMessage}`,
|
|
191
|
-
);
|
|
192
|
-
|
|
193
|
-
// Log warnings if any
|
|
194
|
-
if (loadResult.warnings && loadResult.warnings.length > 0) {
|
|
195
|
-
logger?.warn(
|
|
196
|
-
`Live Config: Configuration warnings: ${loadResult.warnings.join("; ")}`,
|
|
197
|
-
);
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
// Use fallback configuration if available
|
|
201
|
-
if (this.lastValidConfiguration) {
|
|
202
|
-
this.currentConfiguration = this.lastValidConfiguration;
|
|
203
|
-
|
|
204
|
-
// Apply environment variables to configuration service if configured
|
|
205
|
-
if (this.lastValidConfiguration.env) {
|
|
206
|
-
this.configurationService.setEnvironmentVars(
|
|
207
|
-
this.lastValidConfiguration.env,
|
|
208
|
-
);
|
|
209
|
-
}
|
|
210
|
-
|
|
211
|
-
// Update hook manager if available
|
|
212
|
-
if (this.hookManager) {
|
|
213
|
-
this.hookManager.loadConfigurationFromWaveConfig(
|
|
214
|
-
this.lastValidConfiguration,
|
|
215
|
-
);
|
|
216
|
-
}
|
|
217
|
-
|
|
218
|
-
return this.currentConfiguration;
|
|
219
|
-
} else {
|
|
220
|
-
logger?.warn(
|
|
221
|
-
"Live Config: No previous valid configuration available, using empty config",
|
|
222
|
-
);
|
|
223
|
-
this.currentConfiguration = {};
|
|
224
|
-
return this.currentConfiguration;
|
|
225
|
-
}
|
|
226
|
-
}
|
|
227
|
-
|
|
228
|
-
// Log warnings from successful loading
|
|
229
|
-
if (loadResult.warnings && loadResult.warnings.length > 0) {
|
|
230
|
-
logger?.warn(
|
|
231
|
-
`Live Config: Configuration warnings: ${loadResult.warnings.join("; ")}`,
|
|
232
|
-
);
|
|
233
|
-
}
|
|
234
|
-
|
|
235
|
-
// Detect changes between old and new configuration
|
|
236
|
-
this.detectChanges(this.currentConfiguration, newConfig);
|
|
237
|
-
|
|
238
|
-
// Update current configuration
|
|
239
|
-
this.currentConfiguration = newConfig || {};
|
|
240
|
-
|
|
241
|
-
// Save as last valid configuration if it's valid and not empty
|
|
242
|
-
if (newConfig && (newConfig.hooks || newConfig.env)) {
|
|
243
|
-
this.lastValidConfiguration = { ...newConfig };
|
|
244
|
-
}
|
|
245
|
-
|
|
246
|
-
// Note: Environment variables are already applied by loadMergedConfiguration()
|
|
247
|
-
// No need to set them again here as currentConfiguration === newConfig
|
|
248
|
-
|
|
249
|
-
// Update hook manager if available
|
|
250
|
-
if (this.hookManager) {
|
|
251
|
-
this.hookManager.loadConfigurationFromWaveConfig(
|
|
252
|
-
this.currentConfiguration,
|
|
253
|
-
);
|
|
254
|
-
}
|
|
255
|
-
|
|
256
|
-
// Update permission manager if available
|
|
257
|
-
if (this.permissionManager) {
|
|
258
|
-
this.permissionManager.updateConfiguredPermissionMode(
|
|
259
|
-
this.currentConfiguration.permissions?.permissionMode,
|
|
260
|
-
);
|
|
261
|
-
this.permissionManager.updateAllowedRules(
|
|
262
|
-
this.currentConfiguration.permissions?.allow || [],
|
|
263
|
-
);
|
|
264
|
-
this.permissionManager.updateDeniedRules(
|
|
265
|
-
this.currentConfiguration.permissions?.deny || [],
|
|
266
|
-
);
|
|
267
|
-
this.permissionManager.updateAdditionalDirectories(
|
|
268
|
-
this.currentConfiguration.permissions?.additionalDirectories || [],
|
|
269
|
-
);
|
|
270
|
-
}
|
|
271
|
-
|
|
272
|
-
// Trigger reload callback
|
|
273
|
-
this.options.onReload?.(this.currentConfiguration);
|
|
274
|
-
|
|
275
|
-
return this.currentConfiguration;
|
|
276
|
-
} catch (error) {
|
|
277
|
-
const errorMessage = `Configuration reload failed with exception: ${(error as Error).message}`;
|
|
278
|
-
logger?.error(`Live Config: ${errorMessage}`);
|
|
279
|
-
|
|
280
|
-
// Use previous valid configuration for error recovery
|
|
281
|
-
if (this.lastValidConfiguration) {
|
|
282
|
-
this.currentConfiguration = this.lastValidConfiguration;
|
|
283
|
-
|
|
284
|
-
// Apply environment variables to configuration service if configured
|
|
285
|
-
if (this.lastValidConfiguration.env) {
|
|
286
|
-
this.configurationService.setEnvironmentVars(
|
|
287
|
-
this.lastValidConfiguration.env,
|
|
288
|
-
);
|
|
289
|
-
}
|
|
290
|
-
|
|
291
|
-
// Update hook manager if available
|
|
292
|
-
if (this.hookManager) {
|
|
293
|
-
this.hookManager.loadConfigurationFromWaveConfig(
|
|
294
|
-
this.lastValidConfiguration,
|
|
295
|
-
);
|
|
296
|
-
}
|
|
297
|
-
} else {
|
|
298
|
-
logger?.warn(
|
|
299
|
-
"Live Config: No previous valid configuration available, using empty config",
|
|
300
|
-
);
|
|
301
|
-
this.currentConfiguration = {};
|
|
302
|
-
}
|
|
303
|
-
|
|
304
|
-
return this.currentConfiguration;
|
|
305
|
-
} finally {
|
|
306
|
-
this.reloadInProgress = false;
|
|
307
|
-
}
|
|
308
|
-
}
|
|
309
|
-
|
|
310
|
-
/**
|
|
311
|
-
* Reload configuration from files (public method)
|
|
312
|
-
*/
|
|
313
|
-
async reload(): Promise<WaveConfiguration> {
|
|
314
|
-
return await this.reloadConfiguration();
|
|
315
|
-
}
|
|
316
|
-
|
|
317
|
-
/**
|
|
318
|
-
* Check if watching is active
|
|
319
|
-
*/
|
|
320
|
-
isWatchingActive(): boolean {
|
|
321
|
-
return this.isWatching;
|
|
322
|
-
}
|
|
323
|
-
|
|
324
|
-
/**
|
|
325
|
-
* Get watcher status for monitoring
|
|
326
|
-
*/
|
|
327
|
-
getWatcherStatus() {
|
|
328
|
-
const statuses = this.fileWatcher.getAllWatcherStatuses();
|
|
329
|
-
return {
|
|
330
|
-
isActive: this.isWatching,
|
|
331
|
-
configurationLoaded: this.currentConfiguration !== null,
|
|
332
|
-
hasValidConfiguration: this.lastValidConfiguration !== null,
|
|
333
|
-
reloadInProgress: this.reloadInProgress,
|
|
334
|
-
watchedFiles: statuses.map((s) => ({
|
|
335
|
-
path: s.path,
|
|
336
|
-
isActive: s.isActive,
|
|
337
|
-
method: s.method,
|
|
338
|
-
errorCount: s.errorCount,
|
|
339
|
-
})),
|
|
340
|
-
};
|
|
341
|
-
}
|
|
342
|
-
|
|
343
|
-
private setupFileWatcherEvents(): void {
|
|
344
|
-
this.fileWatcher.on("watcherError", (error: Error) => {
|
|
345
|
-
logger?.error(`Live Config: File watcher error: ${error.message}`);
|
|
346
|
-
});
|
|
347
|
-
}
|
|
348
|
-
|
|
349
|
-
private async handleFileChange(
|
|
350
|
-
event: FileWatchEvent,
|
|
351
|
-
source: Scope,
|
|
352
|
-
): Promise<void> {
|
|
353
|
-
try {
|
|
354
|
-
// Handle file deletion
|
|
355
|
-
if (event.type === "delete") {
|
|
356
|
-
// Reload configuration without the deleted file
|
|
357
|
-
await this.reloadConfiguration();
|
|
358
|
-
return;
|
|
359
|
-
}
|
|
360
|
-
|
|
361
|
-
// Handle file creation or modification
|
|
362
|
-
if (event.type === "change" || event.type === "create") {
|
|
363
|
-
// Add small delay to ensure file write is complete
|
|
364
|
-
await new Promise((resolve) => setTimeout(resolve, 50));
|
|
365
|
-
|
|
366
|
-
// Reload configuration
|
|
367
|
-
await this.reloadConfiguration();
|
|
368
|
-
}
|
|
369
|
-
} catch (error) {
|
|
370
|
-
logger?.error(
|
|
371
|
-
`Live Config: Error handling file change for ${source} config: ${(error as Error).message}`,
|
|
372
|
-
);
|
|
373
|
-
}
|
|
374
|
-
}
|
|
375
|
-
|
|
376
|
-
private detectChanges(
|
|
377
|
-
oldConfig: WaveConfiguration | null,
|
|
378
|
-
newConfig: WaveConfiguration | null,
|
|
379
|
-
): {
|
|
380
|
-
added: string[];
|
|
381
|
-
modified: string[];
|
|
382
|
-
removed: string[];
|
|
383
|
-
} {
|
|
384
|
-
const added: string[] = [];
|
|
385
|
-
const modified: string[] = [];
|
|
386
|
-
const removed: string[] = [];
|
|
387
|
-
|
|
388
|
-
// Handle environment variables changes
|
|
389
|
-
const oldEnv = oldConfig?.env || {};
|
|
390
|
-
const newEnv = newConfig?.env || {};
|
|
391
|
-
|
|
392
|
-
for (const key of Object.keys(newEnv)) {
|
|
393
|
-
if (!(key in oldEnv)) {
|
|
394
|
-
added.push(`env.${key}`);
|
|
395
|
-
} else if (oldEnv[key] !== newEnv[key]) {
|
|
396
|
-
modified.push(`env.${key}`);
|
|
397
|
-
}
|
|
398
|
-
}
|
|
399
|
-
|
|
400
|
-
for (const key of Object.keys(oldEnv)) {
|
|
401
|
-
if (!(key in newEnv)) {
|
|
402
|
-
removed.push(`env.${key}`);
|
|
403
|
-
}
|
|
404
|
-
}
|
|
405
|
-
|
|
406
|
-
// Handle hooks changes (simplified)
|
|
407
|
-
const oldHooks = oldConfig?.hooks || {};
|
|
408
|
-
const newHooks = newConfig?.hooks || {};
|
|
409
|
-
|
|
410
|
-
for (const event of Object.keys(newHooks)) {
|
|
411
|
-
if (isValidHookEvent(event)) {
|
|
412
|
-
if (!(event in oldHooks)) {
|
|
413
|
-
added.push(`hooks.${event}`);
|
|
414
|
-
} else if (
|
|
415
|
-
JSON.stringify(oldHooks[event]) !== JSON.stringify(newHooks[event])
|
|
416
|
-
) {
|
|
417
|
-
modified.push(`hooks.${event}`);
|
|
418
|
-
}
|
|
419
|
-
}
|
|
420
|
-
}
|
|
421
|
-
|
|
422
|
-
for (const event of Object.keys(oldHooks)) {
|
|
423
|
-
if (isValidHookEvent(event) && !(event in newHooks)) {
|
|
424
|
-
removed.push(`hooks.${event}`);
|
|
425
|
-
}
|
|
426
|
-
}
|
|
427
|
-
|
|
428
|
-
return { added, modified, removed };
|
|
429
|
-
}
|
|
430
|
-
|
|
431
|
-
/**
|
|
432
|
-
* Get configuration file paths for user and project settings
|
|
433
|
-
* Returns paths in priority order (local.json first, then .json)
|
|
434
|
-
*/
|
|
435
|
-
private getConfigurationPaths(): {
|
|
436
|
-
userPaths: string[];
|
|
437
|
-
projectPaths: string[];
|
|
438
|
-
} {
|
|
439
|
-
const paths = this.configurationService.getConfigurationPaths(this.workdir);
|
|
440
|
-
return {
|
|
441
|
-
userPaths: paths.userPaths,
|
|
442
|
-
projectPaths: paths.projectPaths,
|
|
443
|
-
};
|
|
444
|
-
}
|
|
445
|
-
}
|