wave-agent-sdk 0.8.4 → 0.9.1
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.map +1 -1
- package/dist/agent.js +5 -8
- package/dist/managers/aiManager.d.ts +6 -10
- package/dist/managers/aiManager.d.ts.map +1 -1
- package/dist/managers/aiManager.js +38 -13
- package/dist/managers/hookManager.d.ts.map +1 -1
- package/dist/managers/hookManager.js +15 -1
- package/dist/managers/messageManager.d.ts +1 -0
- package/dist/managers/messageManager.d.ts.map +1 -1
- package/dist/managers/messageManager.js +8 -2
- package/dist/managers/subagentManager.d.ts +2 -11
- package/dist/managers/subagentManager.d.ts.map +1 -1
- package/dist/managers/subagentManager.js +4 -53
- package/dist/prompts/autoMemory.d.ts +2 -0
- package/dist/prompts/autoMemory.d.ts.map +1 -0
- package/dist/prompts/autoMemory.js +33 -0
- package/dist/prompts/index.d.ts +4 -0
- package/dist/prompts/index.d.ts.map +1 -1
- package/dist/prompts/index.js +7 -0
- package/dist/services/aiService.js +6 -7
- package/dist/services/configurationService.d.ts +28 -16
- package/dist/services/configurationService.d.ts.map +1 -1
- package/dist/services/configurationService.js +87 -28
- package/dist/services/hook.js +2 -2
- package/dist/services/initializationService.d.ts.map +1 -1
- package/dist/services/initializationService.js +20 -9
- package/dist/services/memory.d.ts +22 -4
- package/dist/services/memory.d.ts.map +1 -1
- package/dist/services/memory.js +132 -73
- package/dist/types/configuration.d.ts +2 -0
- package/dist/types/configuration.d.ts.map +1 -1
- package/dist/types/history.d.ts +2 -0
- package/dist/types/history.d.ts.map +1 -1
- package/dist/types/hooks.d.ts +2 -0
- package/dist/types/hooks.d.ts.map +1 -1
- package/dist/types/hooks.js +17 -7
- package/dist/utils/containerSetup.d.ts +0 -5
- package/dist/utils/containerSetup.d.ts.map +1 -1
- package/dist/utils/containerSetup.js +11 -24
- package/dist/utils/fileSearch.d.ts +1 -6
- package/dist/utils/fileSearch.d.ts.map +1 -1
- package/dist/utils/fileSearch.js +104 -75
- package/dist/utils/gitUtils.d.ts +6 -0
- package/dist/utils/gitUtils.d.ts.map +1 -1
- package/dist/utils/gitUtils.js +18 -0
- package/dist/utils/promptHistory.d.ts +3 -3
- package/dist/utils/promptHistory.d.ts.map +1 -1
- package/dist/utils/promptHistory.js +12 -6
- package/package.json +2 -1
- package/src/agent.ts +7 -18
- package/src/managers/aiManager.ts +73 -28
- package/src/managers/hookManager.ts +22 -1
- package/src/managers/messageManager.ts +12 -2
- package/src/managers/subagentManager.ts +7 -69
- package/src/prompts/autoMemory.ts +33 -0
- package/src/prompts/index.ts +12 -0
- package/src/services/aiService.ts +8 -8
- package/src/services/configurationService.ts +100 -28
- package/src/services/hook.ts +2 -2
- package/src/services/initializationService.ts +24 -12
- package/src/services/memory.ts +144 -82
- package/src/types/configuration.ts +2 -0
- package/src/types/history.ts +2 -0
- package/src/types/hooks.ts +25 -9
- package/src/utils/containerSetup.ts +11 -33
- package/src/utils/fileSearch.ts +112 -80
- package/src/utils/gitUtils.ts +18 -0
- package/src/utils/promptHistory.ts +20 -6
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
*/
|
|
7
7
|
import type { ConfigurationLoadResult, ValidationResult, ConfigurationPaths, WaveConfiguration, Scope } from "../types/configuration.js";
|
|
8
8
|
import { type EnvironmentValidationResult, type MergedEnvironmentContext, type EnvironmentMergeOptions } from "../types/environment.js";
|
|
9
|
-
import { GatewayConfig, ModelConfig, PermissionMode } from "../types/index.js";
|
|
9
|
+
import { GatewayConfig, ModelConfig, PermissionMode, AgentOptions } from "../types/index.js";
|
|
10
10
|
import { ClientOptions } from "openai";
|
|
11
11
|
/**
|
|
12
12
|
* Default ConfigurationService implementation
|
|
@@ -17,6 +17,11 @@ import { ClientOptions } from "openai";
|
|
|
17
17
|
export declare class ConfigurationService {
|
|
18
18
|
private currentConfiguration;
|
|
19
19
|
private env;
|
|
20
|
+
private options;
|
|
21
|
+
/**
|
|
22
|
+
* Set agent options for configuration resolution
|
|
23
|
+
*/
|
|
24
|
+
setOptions(options: AgentOptions): void;
|
|
20
25
|
/**
|
|
21
26
|
* Load and merge configuration with comprehensive validation
|
|
22
27
|
*/
|
|
@@ -45,42 +50,49 @@ export declare class ConfigurationService {
|
|
|
45
50
|
/**
|
|
46
51
|
* Resolves gateway configuration from constructor args and environment
|
|
47
52
|
* Resolution priority: options > env (from settings.json) > process.env > error
|
|
48
|
-
* @param apiKey - API key
|
|
49
|
-
* @param baseURL - Base URL
|
|
50
|
-
* @param defaultHeaders - HTTP headers
|
|
51
|
-
* @param fetchOptions - Fetch options
|
|
52
|
-
* @param fetch - Custom fetch implementation
|
|
53
|
+
* @param apiKey - API key override (optional)
|
|
54
|
+
* @param baseURL - Base URL override (optional)
|
|
55
|
+
* @param defaultHeaders - HTTP headers override (optional)
|
|
56
|
+
* @param fetchOptions - Fetch options override (optional)
|
|
57
|
+
* @param fetch - Custom fetch implementation override (optional)
|
|
53
58
|
* @returns Resolved gateway configuration
|
|
54
59
|
* @throws ConfigurationError if required configuration is missing after fallbacks
|
|
55
60
|
*/
|
|
56
61
|
resolveGatewayConfig(apiKey?: string, baseURL?: string, defaultHeaders?: Record<string, string>, fetchOptions?: ClientOptions["fetchOptions"], fetch?: ClientOptions["fetch"]): GatewayConfig;
|
|
57
62
|
/**
|
|
58
63
|
* Resolves model configuration with fallbacks
|
|
59
|
-
* Resolution priority: options > env (from settings.json) > process.env > default
|
|
60
|
-
* @param model - Agent model
|
|
61
|
-
* @param fastModel - Fast model
|
|
62
|
-
* @param maxTokens - Max output tokens
|
|
64
|
+
* Resolution priority: override > options > env (from settings.json) > process.env > default
|
|
65
|
+
* @param model - Agent model override (optional)
|
|
66
|
+
* @param fastModel - Fast model override (optional)
|
|
67
|
+
* @param maxTokens - Max output tokens override (optional)
|
|
68
|
+
* @param permissionMode - Permission mode override (optional)
|
|
63
69
|
* @returns Resolved model configuration with defaults
|
|
64
70
|
*/
|
|
65
71
|
resolveModelConfig(model?: string, fastModel?: string, maxTokens?: number, permissionMode?: PermissionMode): ModelConfig;
|
|
66
72
|
/**
|
|
67
73
|
* Resolves token limit with fallbacks
|
|
68
|
-
* Resolution priority: options > env (from settings.json) > process.env > default
|
|
69
|
-
* @param constructorLimit - Token limit
|
|
74
|
+
* Resolution priority: override > options > env (from settings.json) > process.env > default
|
|
75
|
+
* @param constructorLimit - Token limit override (optional)
|
|
70
76
|
* @returns Resolved token limit
|
|
71
77
|
*/
|
|
72
78
|
resolveMaxInputTokens(constructorLimit?: number): number;
|
|
73
79
|
/**
|
|
74
80
|
* Resolves preferred language with fallbacks
|
|
75
|
-
* Resolution priority: options > settings.json > undefined
|
|
76
|
-
* @param constructorLanguage - Language
|
|
81
|
+
* Resolution priority: override > options > settings.json > undefined
|
|
82
|
+
* @param constructorLanguage - Language override (optional)
|
|
77
83
|
* @returns Resolved language or undefined
|
|
78
84
|
*/
|
|
79
85
|
resolveLanguage(constructorLanguage?: string): string | undefined;
|
|
86
|
+
/**
|
|
87
|
+
* Resolves auto-memory enabled state with fallbacks
|
|
88
|
+
* Resolution priority: settings.json > WAVE_DISABLE_AUTO_MEMORY > default (true)
|
|
89
|
+
* @returns Resolved auto-memory enabled state
|
|
90
|
+
*/
|
|
91
|
+
resolveAutoMemoryEnabled(): boolean;
|
|
80
92
|
/**
|
|
81
93
|
* Resolves max output tokens with fallbacks
|
|
82
|
-
* Resolution priority: options > env (from settings.json) > process.env > default
|
|
83
|
-
* @param constructorLimit - Max output tokens
|
|
94
|
+
* Resolution priority: override > options > env (from settings.json) > process.env > default
|
|
95
|
+
* @param constructorLimit - Max output tokens override (optional)
|
|
84
96
|
* @returns Resolved max output tokens
|
|
85
97
|
*/
|
|
86
98
|
resolveMaxOutputTokens(constructorLimit?: number): number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"configurationService.d.ts","sourceRoot":"","sources":["../../src/services/configurationService.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAKH,OAAO,KAAK,EACV,uBAAuB,EACvB,gBAAgB,EAChB,kBAAkB,EAClB,iBAAiB,EACjB,KAAK,EACN,MAAM,2BAA2B,CAAC;AAOnC,OAAO,EACL,KAAK,2BAA2B,EAChC,KAAK,wBAAwB,EAC7B,KAAK,uBAAuB,EAE7B,MAAM,yBAAyB,CAAC;AACjC,OAAO,EACL,aAAa,EACb,WAAW,EAGX,cAAc,
|
|
1
|
+
{"version":3,"file":"configurationService.d.ts","sourceRoot":"","sources":["../../src/services/configurationService.ts"],"names":[],"mappings":"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"}
|
|
@@ -22,6 +22,13 @@ export class ConfigurationService {
|
|
|
22
22
|
constructor() {
|
|
23
23
|
this.currentConfiguration = null;
|
|
24
24
|
this.env = {};
|
|
25
|
+
this.options = {};
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Set agent options for configuration resolution
|
|
29
|
+
*/
|
|
30
|
+
setOptions(options) {
|
|
31
|
+
this.options = options;
|
|
25
32
|
}
|
|
26
33
|
// Core loading operations
|
|
27
34
|
/**
|
|
@@ -210,6 +217,12 @@ export class ConfigurationService {
|
|
|
210
217
|
}
|
|
211
218
|
}
|
|
212
219
|
}
|
|
220
|
+
// Validate autoMemoryEnabled if present
|
|
221
|
+
if (config.autoMemoryEnabled !== undefined &&
|
|
222
|
+
typeof config.autoMemoryEnabled !== "boolean") {
|
|
223
|
+
result.isValid = false;
|
|
224
|
+
result.errors.push("autoMemoryEnabled configuration must be a boolean");
|
|
225
|
+
}
|
|
213
226
|
return result;
|
|
214
227
|
}
|
|
215
228
|
/**
|
|
@@ -272,30 +285,36 @@ export class ConfigurationService {
|
|
|
272
285
|
/**
|
|
273
286
|
* Resolves gateway configuration from constructor args and environment
|
|
274
287
|
* Resolution priority: options > env (from settings.json) > process.env > error
|
|
275
|
-
* @param apiKey - API key
|
|
276
|
-
* @param baseURL - Base URL
|
|
277
|
-
* @param defaultHeaders - HTTP headers
|
|
278
|
-
* @param fetchOptions - Fetch options
|
|
279
|
-
* @param fetch - Custom fetch implementation
|
|
288
|
+
* @param apiKey - API key override (optional)
|
|
289
|
+
* @param baseURL - Base URL override (optional)
|
|
290
|
+
* @param defaultHeaders - HTTP headers override (optional)
|
|
291
|
+
* @param fetchOptions - Fetch options override (optional)
|
|
292
|
+
* @param fetch - Custom fetch implementation override (optional)
|
|
280
293
|
* @returns Resolved gateway configuration
|
|
281
294
|
* @throws ConfigurationError if required configuration is missing after fallbacks
|
|
282
295
|
*/
|
|
283
296
|
resolveGatewayConfig(apiKey, baseURL, defaultHeaders, fetchOptions, fetch) {
|
|
284
|
-
// Resolve API key:
|
|
297
|
+
// Resolve API key: override > options > env (settings.json) > process.env
|
|
285
298
|
// Note: Explicitly provided empty strings should be treated as invalid, not fall back to env
|
|
286
299
|
let resolvedApiKey;
|
|
287
300
|
if (apiKey !== undefined) {
|
|
288
301
|
resolvedApiKey = apiKey;
|
|
289
302
|
}
|
|
303
|
+
else if (this.options.apiKey !== undefined) {
|
|
304
|
+
resolvedApiKey = this.options.apiKey;
|
|
305
|
+
}
|
|
290
306
|
else {
|
|
291
307
|
resolvedApiKey = this.env.WAVE_API_KEY;
|
|
292
308
|
}
|
|
293
|
-
// Resolve base URL:
|
|
309
|
+
// Resolve base URL: override > options > env (settings.json) > process.env
|
|
294
310
|
// Note: Explicitly provided empty strings should be treated as invalid, not fall back to env
|
|
295
311
|
let resolvedBaseURL;
|
|
296
312
|
if (baseURL !== undefined) {
|
|
297
313
|
resolvedBaseURL = baseURL;
|
|
298
314
|
}
|
|
315
|
+
else if (this.options.baseURL !== undefined) {
|
|
316
|
+
resolvedBaseURL = this.options.baseURL;
|
|
317
|
+
}
|
|
299
318
|
else {
|
|
300
319
|
resolvedBaseURL = this.env.WAVE_BASE_URL || "";
|
|
301
320
|
}
|
|
@@ -328,40 +347,42 @@ export class ConfigurationService {
|
|
|
328
347
|
// Resolve custom headers from environment: env (settings.json) > process.env
|
|
329
348
|
const envCustomHeaders = this.env.WAVE_CUSTOM_HEADERS || process.env.WAVE_CUSTOM_HEADERS || "";
|
|
330
349
|
const parsedEnvHeaders = parseCustomHeaders(envCustomHeaders);
|
|
331
|
-
// Merge headers: env headers <
|
|
350
|
+
// Merge headers: env headers < options < override
|
|
332
351
|
const resolvedHeaders = {
|
|
333
352
|
...parsedEnvHeaders,
|
|
353
|
+
...this.options.defaultHeaders,
|
|
334
354
|
...defaultHeaders,
|
|
335
355
|
};
|
|
336
356
|
return {
|
|
337
357
|
apiKey: resolvedApiKey,
|
|
338
358
|
baseURL: resolvedBaseURL,
|
|
339
359
|
defaultHeaders: Object.keys(resolvedHeaders).length > 0 ? resolvedHeaders : undefined,
|
|
340
|
-
fetchOptions,
|
|
341
|
-
fetch,
|
|
360
|
+
fetchOptions: fetchOptions ?? this.options.fetchOptions,
|
|
361
|
+
fetch: fetch ?? this.options.fetch,
|
|
342
362
|
};
|
|
343
363
|
}
|
|
344
364
|
/**
|
|
345
365
|
* Resolves model configuration with fallbacks
|
|
346
|
-
* Resolution priority: options > env (from settings.json) > process.env > default
|
|
347
|
-
* @param model - Agent model
|
|
348
|
-
* @param fastModel - Fast model
|
|
349
|
-
* @param maxTokens - Max output tokens
|
|
366
|
+
* Resolution priority: override > options > env (from settings.json) > process.env > default
|
|
367
|
+
* @param model - Agent model override (optional)
|
|
368
|
+
* @param fastModel - Fast model override (optional)
|
|
369
|
+
* @param maxTokens - Max output tokens override (optional)
|
|
370
|
+
* @param permissionMode - Permission mode override (optional)
|
|
350
371
|
* @returns Resolved model configuration with defaults
|
|
351
372
|
*/
|
|
352
373
|
resolveModelConfig(model, fastModel, maxTokens, permissionMode) {
|
|
353
374
|
// Default values as per data-model.md
|
|
354
375
|
const DEFAULT_AGENT_MODEL = "gemini-3-flash";
|
|
355
376
|
const DEFAULT_FAST_MODEL = "gemini-2.5-flash";
|
|
356
|
-
// Resolve agent model:
|
|
357
|
-
let resolvedAgentModel = model || this.env.WAVE_MODEL;
|
|
377
|
+
// Resolve agent model: override > options > env (settings.json) > process.env > default
|
|
378
|
+
let resolvedAgentModel = model || this.options.model || this.env.WAVE_MODEL;
|
|
358
379
|
if (!resolvedAgentModel && this.currentConfiguration?.env?.WAVE_MODEL) {
|
|
359
380
|
resolvedAgentModel = this.currentConfiguration.env.WAVE_MODEL;
|
|
360
381
|
}
|
|
361
382
|
resolvedAgentModel =
|
|
362
383
|
resolvedAgentModel || process.env.WAVE_MODEL || DEFAULT_AGENT_MODEL;
|
|
363
|
-
// Resolve fast model:
|
|
364
|
-
let resolvedFastModel = fastModel || this.env.WAVE_FAST_MODEL;
|
|
384
|
+
// Resolve fast model: override > options > env (settings.json) > process.env > default
|
|
385
|
+
let resolvedFastModel = fastModel || this.options.fastModel || this.env.WAVE_FAST_MODEL;
|
|
365
386
|
if (!resolvedFastModel && this.currentConfiguration?.env?.WAVE_FAST_MODEL) {
|
|
366
387
|
resolvedFastModel = this.currentConfiguration.env.WAVE_FAST_MODEL;
|
|
367
388
|
}
|
|
@@ -373,20 +394,24 @@ export class ConfigurationService {
|
|
|
373
394
|
model: resolvedAgentModel,
|
|
374
395
|
fastModel: resolvedFastModel,
|
|
375
396
|
maxTokens: resolvedMaxTokens,
|
|
376
|
-
permissionMode,
|
|
397
|
+
permissionMode: permissionMode ?? this.options.permissionMode,
|
|
377
398
|
};
|
|
378
399
|
}
|
|
379
400
|
/**
|
|
380
401
|
* Resolves token limit with fallbacks
|
|
381
|
-
* Resolution priority: options > env (from settings.json) > process.env > default
|
|
382
|
-
* @param constructorLimit - Token limit
|
|
402
|
+
* Resolution priority: override > options > env (from settings.json) > process.env > default
|
|
403
|
+
* @param constructorLimit - Token limit override (optional)
|
|
383
404
|
* @returns Resolved token limit
|
|
384
405
|
*/
|
|
385
406
|
resolveMaxInputTokens(constructorLimit) {
|
|
386
|
-
// If
|
|
407
|
+
// If override value provided, use it
|
|
387
408
|
if (constructorLimit !== undefined) {
|
|
388
409
|
return constructorLimit;
|
|
389
410
|
}
|
|
411
|
+
// If options value provided, use it
|
|
412
|
+
if (this.options.maxInputTokens !== undefined) {
|
|
413
|
+
return this.options.maxInputTokens;
|
|
414
|
+
}
|
|
390
415
|
// Try env (settings.json) first, then process.env
|
|
391
416
|
const envMaxInputTokens = this.env.WAVE_MAX_INPUT_TOKENS || process.env.WAVE_MAX_INPUT_TOKENS;
|
|
392
417
|
if (envMaxInputTokens) {
|
|
@@ -400,32 +425,58 @@ export class ConfigurationService {
|
|
|
400
425
|
}
|
|
401
426
|
/**
|
|
402
427
|
* Resolves preferred language with fallbacks
|
|
403
|
-
* Resolution priority: options > settings.json > undefined
|
|
404
|
-
* @param constructorLanguage - Language
|
|
428
|
+
* Resolution priority: override > options > settings.json > undefined
|
|
429
|
+
* @param constructorLanguage - Language override (optional)
|
|
405
430
|
* @returns Resolved language or undefined
|
|
406
431
|
*/
|
|
407
432
|
resolveLanguage(constructorLanguage) {
|
|
408
|
-
// 1.
|
|
433
|
+
// 1. Override (highest priority)
|
|
409
434
|
if (constructorLanguage !== undefined) {
|
|
410
435
|
return constructorLanguage;
|
|
411
436
|
}
|
|
437
|
+
// 2. Agent options
|
|
438
|
+
if (this.options.language !== undefined) {
|
|
439
|
+
return this.options.language;
|
|
440
|
+
}
|
|
412
441
|
// 2. settings.json (merged)
|
|
413
442
|
if (this.currentConfiguration?.language) {
|
|
414
443
|
return this.currentConfiguration.language;
|
|
415
444
|
}
|
|
416
445
|
return undefined;
|
|
417
446
|
}
|
|
447
|
+
/**
|
|
448
|
+
* Resolves auto-memory enabled state with fallbacks
|
|
449
|
+
* Resolution priority: settings.json > WAVE_DISABLE_AUTO_MEMORY > default (true)
|
|
450
|
+
* @returns Resolved auto-memory enabled state
|
|
451
|
+
*/
|
|
452
|
+
resolveAutoMemoryEnabled() {
|
|
453
|
+
// 1. settings.json (merged)
|
|
454
|
+
if (this.currentConfiguration?.autoMemoryEnabled !== undefined) {
|
|
455
|
+
return this.currentConfiguration.autoMemoryEnabled;
|
|
456
|
+
}
|
|
457
|
+
// 2. WAVE_DISABLE_AUTO_MEMORY environment variable
|
|
458
|
+
const disableAutoMemory = this.env.WAVE_DISABLE_AUTO_MEMORY || process.env.WAVE_DISABLE_AUTO_MEMORY;
|
|
459
|
+
if (disableAutoMemory === "1" || disableAutoMemory === "true") {
|
|
460
|
+
return false;
|
|
461
|
+
}
|
|
462
|
+
// 3. Default (true)
|
|
463
|
+
return true;
|
|
464
|
+
}
|
|
418
465
|
/**
|
|
419
466
|
* Resolves max output tokens with fallbacks
|
|
420
|
-
* Resolution priority: options > env (from settings.json) > process.env > default
|
|
421
|
-
* @param constructorLimit - Max output tokens
|
|
467
|
+
* Resolution priority: override > options > env (from settings.json) > process.env > default
|
|
468
|
+
* @param constructorLimit - Max output tokens override (optional)
|
|
422
469
|
* @returns Resolved max output tokens
|
|
423
470
|
*/
|
|
424
471
|
resolveMaxOutputTokens(constructorLimit) {
|
|
425
|
-
// If
|
|
472
|
+
// If override value provided, use it
|
|
426
473
|
if (constructorLimit !== undefined) {
|
|
427
474
|
return constructorLimit;
|
|
428
475
|
}
|
|
476
|
+
// If options value provided, use it
|
|
477
|
+
if (this.options.maxTokens !== undefined) {
|
|
478
|
+
return this.options.maxTokens;
|
|
479
|
+
}
|
|
429
480
|
// Try env (settings.json) first, then process.env
|
|
430
481
|
const envMaxOutputTokens = this.env.WAVE_MAX_OUTPUT_TOKENS || process.env.WAVE_MAX_OUTPUT_TOKENS;
|
|
431
482
|
if (envMaxOutputTokens) {
|
|
@@ -680,6 +731,9 @@ export function loadWaveConfigFromFile(filePath) {
|
|
|
680
731
|
permissions: config.permissions || undefined,
|
|
681
732
|
enabledPlugins: config.enabledPlugins || undefined,
|
|
682
733
|
language: config.language || undefined,
|
|
734
|
+
autoMemoryEnabled: config.autoMemoryEnabled !== undefined
|
|
735
|
+
? config.autoMemoryEnabled
|
|
736
|
+
: undefined,
|
|
683
737
|
};
|
|
684
738
|
}
|
|
685
739
|
catch (error) {
|
|
@@ -815,6 +869,10 @@ export function loadMergedWaveConfig(workdir) {
|
|
|
815
869
|
if (config.language !== undefined) {
|
|
816
870
|
mergedConfig.language = config.language;
|
|
817
871
|
}
|
|
872
|
+
// Merge autoMemoryEnabled (last one wins)
|
|
873
|
+
if (config.autoMemoryEnabled !== undefined) {
|
|
874
|
+
mergedConfig.autoMemoryEnabled = config.autoMemoryEnabled;
|
|
875
|
+
}
|
|
818
876
|
}
|
|
819
877
|
return {
|
|
820
878
|
hooks: mergedConfig.hooks && Object.keys(mergedConfig.hooks).length > 0
|
|
@@ -832,5 +890,6 @@ export function loadMergedWaveConfig(workdir) {
|
|
|
832
890
|
? mergedConfig.enabledPlugins
|
|
833
891
|
: undefined,
|
|
834
892
|
language: mergedConfig.language,
|
|
893
|
+
autoMemoryEnabled: mergedConfig.autoMemoryEnabled,
|
|
835
894
|
};
|
|
836
895
|
}
|
package/dist/services/hook.js
CHANGED
|
@@ -71,8 +71,8 @@ async function buildHookJsonInput(context) {
|
|
|
71
71
|
* Execute a single hook command
|
|
72
72
|
*/
|
|
73
73
|
export async function executeCommand(command, context, options) {
|
|
74
|
-
const defaultTimeout =
|
|
75
|
-
const maxTimeout =
|
|
74
|
+
const defaultTimeout = 600000; // 10 minutes
|
|
75
|
+
const maxTimeout = 600000; // 10 minutes
|
|
76
76
|
const skipExecution = process.env.NODE_ENV === "test" &&
|
|
77
77
|
process.env.TEST_HOOK_EXECUTION !== "true";
|
|
78
78
|
const startTime = Date.now();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"initializationService.d.ts","sourceRoot":"","sources":["../../src/services/initializationService.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"initializationService.d.ts","sourceRoot":"","sources":["../../src/services/initializationService.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EACV,OAAO,EACP,MAAM,EACN,YAAY,EACZ,WAAW,EACZ,MAAM,mBAAmB,CAAC;AAC3B,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAC;AACtE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAC9D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAClE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,oCAAoC,CAAC;AAC9E,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AAC5D,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AACtE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAC9D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AACpE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,kCAAkC,CAAC;AAC1E,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,kCAAkC,CAAC;AAC1E,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAIpD,MAAM,WAAW,qBAAqB;IACpC,YAAY,EAAE,YAAY,CAAC;IAC3B,eAAe,EAAE,eAAe,CAAC;IACjC,SAAS,EAAE,SAAS,CAAC;IACrB,WAAW,EAAE,WAAW,CAAC;IACzB,aAAa,EAAE,aAAa,CAAC;IAC7B,OAAO,EAAE,YAAY,CAAC;IACtB,mBAAmB,EAAE,mBAAmB,CAAC;IACzC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,UAAU,CAAC;IACvB,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,WAAW,CAAC;IACxB,oBAAoB,EAAE,oBAAoB,CAAC;IAC3C,WAAW,EAAE,WAAW,CAAC;IACzB,cAAc,EAAE,cAAc,CAAC;IAC/B,iBAAiB,EAAE,iBAAiB,CAAC;IACrC,iBAAiB,EAAE,iBAAiB,CAAC;IACrC,WAAW,EAAE,WAAW,CAAC;IACzB,gBAAgB,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;IAC5C,aAAa,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;IACzC,wBAAwB,EAAE,MAAM,IAAI,CAAC;CACtC;AAED,qBAAa,qBAAqB;WACZ,UAAU,CAC5B,OAAO,EAAE,qBAAqB,EAC9B,OAAO,CAAC,EAAE;QACR,gBAAgB,CAAC,EAAE,MAAM,CAAC;QAC1B,mBAAmB,CAAC,EAAE,OAAO,CAAC;QAC9B,QAAQ,CAAC,EAAE,OAAO,EAAE,CAAC;KACtB,GACA,OAAO,CAAC,IAAI,CAAC;CAqOjB"}
|
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
import path from "path";
|
|
2
|
-
import * as fs from "fs/promises";
|
|
3
|
-
import os from "os";
|
|
4
1
|
import { handleSessionRestoration } from "./session.js";
|
|
5
2
|
import { setGlobalLogger } from "../utils/globalLogger.js";
|
|
6
3
|
import { LspManager } from "../managers/lspManager.js";
|
|
@@ -90,6 +87,18 @@ export class InitializationService {
|
|
|
90
87
|
}
|
|
91
88
|
// Resolve and validate configuration after loading settings.json
|
|
92
89
|
resolveAndValidateConfig();
|
|
90
|
+
// Initialize auto-memory directory
|
|
91
|
+
try {
|
|
92
|
+
if (configurationService.resolveAutoMemoryEnabled()) {
|
|
93
|
+
const memoryService = container.get("MemoryService");
|
|
94
|
+
if (memoryService) {
|
|
95
|
+
await memoryService.ensureAutoMemoryDirectory(workdir);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
catch (error) {
|
|
100
|
+
logger?.error("Failed to initialize auto-memory directory:", error);
|
|
101
|
+
}
|
|
93
102
|
// Set global logger for SDK-wide access before discovering rules
|
|
94
103
|
setGlobalLogger(logger || null);
|
|
95
104
|
// Discover modular memory rules
|
|
@@ -109,20 +118,22 @@ export class InitializationService {
|
|
|
109
118
|
}
|
|
110
119
|
// Load memory files during initialization
|
|
111
120
|
try {
|
|
112
|
-
|
|
121
|
+
const memoryService = container.get("MemoryService");
|
|
122
|
+
if (!memoryService) {
|
|
123
|
+
throw new Error("MemoryService not found in container");
|
|
124
|
+
}
|
|
125
|
+
// Load project memory from AGENTS.md
|
|
113
126
|
try {
|
|
114
|
-
const
|
|
115
|
-
const projectMemoryContent = await fs.readFile(projectMemoryPath, "utf-8");
|
|
127
|
+
const projectMemoryContent = await memoryService.readMemoryFile(workdir);
|
|
116
128
|
setProjectMemory(projectMemoryContent);
|
|
117
129
|
}
|
|
118
130
|
catch (error) {
|
|
119
131
|
logger?.warn("Failed to load project memory file:", error);
|
|
120
132
|
setProjectMemory("");
|
|
121
133
|
}
|
|
122
|
-
// Load user memory
|
|
134
|
+
// Load user memory
|
|
123
135
|
try {
|
|
124
|
-
const
|
|
125
|
-
const userMemoryContent = await fs.readFile(userMemoryPath, "utf-8");
|
|
136
|
+
const userMemoryContent = await memoryService.getUserMemoryContent();
|
|
126
137
|
setUserMemory(userMemoryContent);
|
|
127
138
|
}
|
|
128
139
|
catch (error) {
|
|
@@ -1,5 +1,23 @@
|
|
|
1
|
-
|
|
2
|
-
export declare
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import { Container } from "../utils/container.js";
|
|
2
|
+
export declare class MemoryService {
|
|
3
|
+
private container;
|
|
4
|
+
constructor(container: Container);
|
|
5
|
+
/**
|
|
6
|
+
* Get the project-specific auto-memory directory.
|
|
7
|
+
* Uses the git common directory to ensure worktrees share the same memory.
|
|
8
|
+
*/
|
|
9
|
+
getAutoMemoryDirectory(workdir: string): string;
|
|
10
|
+
/**
|
|
11
|
+
* Ensure the auto-memory directory and initial MEMORY.md exist.
|
|
12
|
+
*/
|
|
13
|
+
ensureAutoMemoryDirectory(workdir: string): Promise<void>;
|
|
14
|
+
/**
|
|
15
|
+
* Get the first 200 lines of MEMORY.md.
|
|
16
|
+
*/
|
|
17
|
+
getAutoMemoryContent(workdir: string): Promise<string>;
|
|
18
|
+
ensureUserMemoryFile(): Promise<void>;
|
|
19
|
+
getUserMemoryContent(): Promise<string>;
|
|
20
|
+
readMemoryFile(workdir: string): Promise<string>;
|
|
21
|
+
getCombinedMemoryContent(workdir: string): Promise<string>;
|
|
22
|
+
}
|
|
5
23
|
//# sourceMappingURL=memory.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"memory.d.ts","sourceRoot":"","sources":["../../src/services/memory.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"memory.d.ts","sourceRoot":"","sources":["../../src/services/memory.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAIlD,qBAAa,aAAa;IACZ,OAAO,CAAC,SAAS;gBAAT,SAAS,EAAE,SAAS;IAExC;;;OAGG;IACH,sBAAsB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM;IAM/C;;OAEG;IACG,yBAAyB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IA2B/D;;OAEG;IACG,oBAAoB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAiBtD,oBAAoB,IAAI,OAAO,CAAC,IAAI,CAAC;IA8BrC,oBAAoB,IAAI,OAAO,CAAC,MAAM,CAAC;IAevC,cAAc,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAuBhD,wBAAwB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;CAqBjE"}
|