wave-agent-sdk 0.9.1 → 0.9.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/core/session.d.ts +1 -1
- package/dist/core/session.d.ts.map +1 -1
- package/dist/core/session.js +1 -1
- package/dist/managers/liveConfigManager.d.ts +1 -5
- package/dist/managers/liveConfigManager.d.ts.map +1 -1
- package/dist/managers/liveConfigManager.js +12 -126
- package/dist/managers/permissionManager.d.ts +5 -0
- package/dist/managers/permissionManager.d.ts.map +1 -1
- package/dist/managers/permissionManager.js +32 -1
- package/dist/services/configurationService.d.ts +1 -20
- package/dist/services/configurationService.d.ts.map +1 -1
- package/dist/services/configurationService.js +14 -93
- package/dist/services/initializationService.d.ts.map +1 -1
- package/dist/services/initializationService.js +8 -0
- package/dist/services/memory.d.ts.map +1 -1
- package/dist/services/memory.js +4 -1
- package/dist/tools/exitPlanMode.d.ts.map +1 -1
- package/dist/tools/exitPlanMode.js +7 -0
- package/dist/tools/globTool.d.ts.map +1 -1
- package/dist/tools/globTool.js +48 -11
- package/dist/tools/grepTool.js +2 -2
- package/dist/types/history.d.ts +1 -0
- package/dist/types/history.d.ts.map +1 -1
- package/dist/types/permissions.d.ts +1 -0
- package/dist/types/permissions.d.ts.map +1 -1
- package/dist/types/permissions.js +1 -0
- package/dist/utils/configPaths.d.ts +5 -5
- package/dist/utils/configPaths.js +6 -6
- package/dist/utils/containerSetup.js +1 -1
- package/dist/utils/fileFilter.d.ts +0 -11
- package/dist/utils/fileFilter.d.ts.map +1 -1
- package/dist/utils/fileFilter.js +0 -142
- package/dist/utils/fileSearch.js +2 -2
- package/dist/utils/messageOperations.js +4 -2
- package/dist/utils/promptHistory.d.ts +9 -3
- package/dist/utils/promptHistory.d.ts.map +1 -1
- package/dist/utils/promptHistory.js +16 -7
- package/package.json +1 -1
- package/src/core/session.ts +1 -0
- package/src/managers/liveConfigManager.ts +20 -163
- package/src/managers/permissionManager.ts +41 -1
- package/src/services/configurationService.ts +14 -116
- package/src/services/initializationService.ts +11 -0
- package/src/services/memory.ts +5 -1
- package/src/tools/exitPlanMode.ts +7 -0
- package/src/tools/globTool.ts +61 -11
- package/src/tools/grepTool.ts +2 -2
- package/src/types/history.ts +1 -0
- package/src/types/permissions.ts +2 -0
- package/src/utils/configPaths.ts +6 -6
- package/src/utils/containerSetup.ts +1 -1
- package/src/utils/fileFilter.ts +0 -163
- package/src/utils/fileSearch.ts +2 -2
- package/src/utils/messageOperations.ts +2 -2
- package/src/utils/promptHistory.ts +27 -6
package/dist/core/session.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { listSessions, truncateContent, loadSessionFromJsonl, } from "../services/session.js";
|
|
1
|
+
export { listSessions, truncateContent, loadSessionFromJsonl, loadFullMessageThread, } from "../services/session.js";
|
|
2
2
|
export type { SessionMetadata, SessionData } from "../services/session.js";
|
|
3
3
|
//# sourceMappingURL=session.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"session.d.ts","sourceRoot":"","sources":["../../src/core/session.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,YAAY,EACZ,eAAe,EACf,oBAAoB,
|
|
1
|
+
{"version":3,"file":"session.d.ts","sourceRoot":"","sources":["../../src/core/session.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,YAAY,EACZ,eAAe,EACf,oBAAoB,EACpB,qBAAqB,GACtB,MAAM,wBAAwB,CAAC;AAChC,YAAY,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC"}
|
package/dist/core/session.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { listSessions, truncateContent, loadSessionFromJsonl, } from "../services/session.js";
|
|
1
|
+
export { listSessions, truncateContent, loadSessionFromJsonl, loadFullMessageThread, } from "../services/session.js";
|
|
@@ -29,7 +29,7 @@ export declare class LiveConfigManager {
|
|
|
29
29
|
/**
|
|
30
30
|
* Initialize configuration watching
|
|
31
31
|
* Maps to FR-004: System MUST watch settings.json files
|
|
32
|
-
* Supports watching multiple file paths (e.g., settings.local.json and settings.json)
|
|
32
|
+
* Supports watching multiple file paths (e.g., local settings.local.json and settings.json)
|
|
33
33
|
*/
|
|
34
34
|
private initializeWatching;
|
|
35
35
|
/**
|
|
@@ -74,10 +74,6 @@ export declare class LiveConfigManager {
|
|
|
74
74
|
};
|
|
75
75
|
private setupFileWatcherEvents;
|
|
76
76
|
private handleFileChange;
|
|
77
|
-
/**
|
|
78
|
-
* Validate configuration structure and content
|
|
79
|
-
*/
|
|
80
|
-
private validateConfiguration;
|
|
81
77
|
private detectChanges;
|
|
82
78
|
/**
|
|
83
79
|
* Get configuration file paths for user and project settings
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"liveConfigManager.d.ts","sourceRoot":"","sources":["../../src/managers/liveConfigManager.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;
|
|
1
|
+
{"version":3,"file":"liveConfigManager.d.ts","sourceRoot":"","sources":["../../src/managers/liveConfigManager.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAaH,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAElD,OAAO,KAAK,EAEV,iBAAiB,EAClB,MAAM,2BAA2B,CAAC;AAInC,MAAM,WAAW,wBAAwB;IACvC,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,qBAAa,iBAAiB;IAgB1B,OAAO,CAAC,SAAS;IAfnB,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAS;IACjC,OAAO,CAAC,aAAa,CAAkB;IAGvC,OAAO,CAAC,oBAAoB,CAAkC;IAC9D,OAAO,CAAC,sBAAsB,CAAkC;IAGhE,OAAO,CAAC,WAAW,CAAqB;IACxC,OAAO,CAAC,eAAe,CAAC,CAAW;IACnC,OAAO,CAAC,kBAAkB,CAAC,CAAW;IACtC,OAAO,CAAC,UAAU,CAAkB;IACpC,OAAO,CAAC,gBAAgB,CAAkB;gBAGhC,SAAS,EAAE,SAAS,EAC5B,OAAO,EAAE,wBAAwB;IAOnC,OAAO,KAAK,WAAW,GAEtB;IAED,OAAO,KAAK,iBAAiB,GAE5B;IAED,OAAO,KAAK,oBAAoB,GAE/B;IAED;;;;OAIG;YACW,kBAAkB;IA0ChC;;OAEG;IACH,uBAAuB,IAAI,iBAAiB,GAAG,IAAI;IAInD;;OAEG;IACG,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;IAmBjC;;OAEG;IACG,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC;IAsB/B;;;OAGG;YACW,mBAAmB;IAuIjC;;OAEG;IACG,MAAM,IAAI,OAAO,CAAC,iBAAiB,CAAC;IAI1C;;OAEG;IACH,gBAAgB,IAAI,OAAO;IAI3B;;OAEG;IACH,gBAAgB;;;;;;;;;;;;IAgBhB,OAAO,CAAC,sBAAsB;YAMhB,gBAAgB;IAmC9B,OAAO,CAAC,aAAa;IAuDrB;;;OAGG;IACH,OAAO,CAAC,qBAAqB;CAU9B"}
|
|
@@ -8,8 +8,7 @@
|
|
|
8
8
|
*/
|
|
9
9
|
import { existsSync } from "fs";
|
|
10
10
|
import { FileWatcherService, } from "../services/fileWatcher.js";
|
|
11
|
-
import {
|
|
12
|
-
import { isValidHookEvent, isValidHookEventConfig } from "../types/hooks.js";
|
|
11
|
+
import { isValidHookEvent } from "../types/hooks.js";
|
|
13
12
|
import { ensureGlobalGitIgnore } from "../utils/fileUtils.js";
|
|
14
13
|
import { logger } from "../utils/globalLogger.js";
|
|
15
14
|
export class LiveConfigManager {
|
|
@@ -37,7 +36,7 @@ export class LiveConfigManager {
|
|
|
37
36
|
/**
|
|
38
37
|
* Initialize configuration watching
|
|
39
38
|
* Maps to FR-004: System MUST watch settings.json files
|
|
40
|
-
* Supports watching multiple file paths (e.g., settings.local.json and settings.json)
|
|
39
|
+
* Supports watching multiple file paths (e.g., local settings.local.json and settings.json)
|
|
41
40
|
*/
|
|
42
41
|
async initializeWatching(userPaths, projectPaths) {
|
|
43
42
|
try {
|
|
@@ -51,7 +50,7 @@ export class LiveConfigManager {
|
|
|
51
50
|
await this.fileWatcher.watchFile(userPath, (event) => this.handleFileChange(event, "user"));
|
|
52
51
|
}
|
|
53
52
|
}
|
|
54
|
-
// Start watching
|
|
53
|
+
// Start watching local configs that exist
|
|
55
54
|
if (projectPaths) {
|
|
56
55
|
for (const projectPath of projectPaths) {
|
|
57
56
|
if (existsSync(projectPath)) {
|
|
@@ -160,32 +159,6 @@ export class LiveConfigManager {
|
|
|
160
159
|
if (loadResult.warnings && loadResult.warnings.length > 0) {
|
|
161
160
|
logger?.warn(`Live Config: Configuration warnings: ${loadResult.warnings.join("; ")}`);
|
|
162
161
|
}
|
|
163
|
-
// Validate new configuration if it exists
|
|
164
|
-
if (newConfig) {
|
|
165
|
-
const validation = this.validateConfiguration(newConfig);
|
|
166
|
-
if (!validation.valid) {
|
|
167
|
-
const errorMessage = `Configuration validation failed: ${validation.errors.join(", ")}`;
|
|
168
|
-
logger?.error(`Live Config: ${errorMessage}`);
|
|
169
|
-
// Use previous valid configuration for error recovery
|
|
170
|
-
if (this.lastValidConfiguration) {
|
|
171
|
-
this.currentConfiguration = this.lastValidConfiguration;
|
|
172
|
-
// Apply environment variables to configuration service if configured
|
|
173
|
-
if (this.lastValidConfiguration.env) {
|
|
174
|
-
this.configurationService.setEnvironmentVars(this.lastValidConfiguration.env);
|
|
175
|
-
}
|
|
176
|
-
// Update hook manager if available
|
|
177
|
-
if (this.hookManager) {
|
|
178
|
-
this.hookManager.loadConfigurationFromWaveConfig(this.lastValidConfiguration);
|
|
179
|
-
}
|
|
180
|
-
return this.currentConfiguration;
|
|
181
|
-
}
|
|
182
|
-
else {
|
|
183
|
-
logger?.warn("Live Config: No previous valid configuration available, using empty config");
|
|
184
|
-
this.currentConfiguration = {};
|
|
185
|
-
return this.currentConfiguration;
|
|
186
|
-
}
|
|
187
|
-
}
|
|
188
|
-
}
|
|
189
162
|
// Detect changes between old and new configuration
|
|
190
163
|
this.detectChanges(this.currentConfiguration, newConfig);
|
|
191
164
|
// Update current configuration
|
|
@@ -202,18 +175,10 @@ export class LiveConfigManager {
|
|
|
202
175
|
}
|
|
203
176
|
// Update permission manager if available
|
|
204
177
|
if (this.permissionManager) {
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
this.permissionManager.updateAllowedRules(this.currentConfiguration.permissions.allow);
|
|
210
|
-
}
|
|
211
|
-
if (this.currentConfiguration.permissions?.deny) {
|
|
212
|
-
this.permissionManager.updateDeniedRules(this.currentConfiguration.permissions.deny);
|
|
213
|
-
}
|
|
214
|
-
if (this.currentConfiguration.permissions?.additionalDirectories) {
|
|
215
|
-
this.permissionManager.updateAdditionalDirectories(this.currentConfiguration.permissions.additionalDirectories);
|
|
216
|
-
}
|
|
178
|
+
this.permissionManager.updateConfiguredDefaultMode(this.currentConfiguration.permissions?.defaultMode);
|
|
179
|
+
this.permissionManager.updateAllowedRules(this.currentConfiguration.permissions?.allow || []);
|
|
180
|
+
this.permissionManager.updateDeniedRules(this.currentConfiguration.permissions?.deny || []);
|
|
181
|
+
this.permissionManager.updateAdditionalDirectories(this.currentConfiguration.permissions?.additionalDirectories || []);
|
|
217
182
|
}
|
|
218
183
|
return this.currentConfiguration;
|
|
219
184
|
}
|
|
@@ -302,87 +267,6 @@ export class LiveConfigManager {
|
|
|
302
267
|
logger?.error(`Live Config: Error handling file change for ${source} config: ${error.message}`);
|
|
303
268
|
}
|
|
304
269
|
}
|
|
305
|
-
/**
|
|
306
|
-
* Validate configuration structure and content
|
|
307
|
-
*/
|
|
308
|
-
validateConfiguration(config) {
|
|
309
|
-
const errors = [];
|
|
310
|
-
if (!config || typeof config !== "object") {
|
|
311
|
-
return { valid: false, errors: ["Configuration must be an object"] };
|
|
312
|
-
}
|
|
313
|
-
// Validate permissions if present
|
|
314
|
-
if (config.permissions) {
|
|
315
|
-
if (typeof config.permissions !== "object") {
|
|
316
|
-
errors.push("permissions property must be an object");
|
|
317
|
-
}
|
|
318
|
-
else {
|
|
319
|
-
// Validate defaultMode if present
|
|
320
|
-
if (config.permissions.defaultMode !== undefined) {
|
|
321
|
-
const validModes = [
|
|
322
|
-
"default",
|
|
323
|
-
"bypassPermissions",
|
|
324
|
-
"acceptEdits",
|
|
325
|
-
"plan",
|
|
326
|
-
];
|
|
327
|
-
if (!validModes.includes(config.permissions.defaultMode)) {
|
|
328
|
-
errors.push(`Invalid defaultMode: "${config.permissions.defaultMode}". Must be one of: ${validModes.join(", ")}`);
|
|
329
|
-
}
|
|
330
|
-
}
|
|
331
|
-
// Validate allow if present
|
|
332
|
-
if (config.permissions.allow) {
|
|
333
|
-
if (!Array.isArray(config.permissions.allow)) {
|
|
334
|
-
errors.push("permissions.allow must be an array");
|
|
335
|
-
}
|
|
336
|
-
}
|
|
337
|
-
}
|
|
338
|
-
}
|
|
339
|
-
// Validate hooks if present
|
|
340
|
-
if (config.hooks) {
|
|
341
|
-
if (typeof config.hooks !== "object") {
|
|
342
|
-
errors.push("hooks property must be an object");
|
|
343
|
-
}
|
|
344
|
-
else {
|
|
345
|
-
// Validate each hook event
|
|
346
|
-
for (const [eventName, eventConfigs] of Object.entries(config.hooks)) {
|
|
347
|
-
// Validate event name
|
|
348
|
-
if (!isValidHookEvent(eventName)) {
|
|
349
|
-
errors.push(`Invalid hook event: ${eventName}`);
|
|
350
|
-
continue;
|
|
351
|
-
}
|
|
352
|
-
// Validate event configurations
|
|
353
|
-
if (!Array.isArray(eventConfigs)) {
|
|
354
|
-
errors.push(`Hook event ${eventName} must be an array of configurations`);
|
|
355
|
-
continue;
|
|
356
|
-
}
|
|
357
|
-
eventConfigs.forEach((eventConfig, index) => {
|
|
358
|
-
if (!isValidHookEventConfig(eventConfig)) {
|
|
359
|
-
errors.push(`Invalid hook event configuration at ${eventName}[${index}]`);
|
|
360
|
-
}
|
|
361
|
-
});
|
|
362
|
-
}
|
|
363
|
-
}
|
|
364
|
-
}
|
|
365
|
-
// Validate environment variables if present
|
|
366
|
-
if (config.env) {
|
|
367
|
-
if (typeof config.env !== "object" || Array.isArray(config.env)) {
|
|
368
|
-
errors.push("env property must be an object");
|
|
369
|
-
}
|
|
370
|
-
else {
|
|
371
|
-
for (const [key, value] of Object.entries(config.env)) {
|
|
372
|
-
if (typeof key !== "string" || key.trim() === "") {
|
|
373
|
-
errors.push(`Invalid environment variable key: ${key}`);
|
|
374
|
-
}
|
|
375
|
-
if (typeof value !== "string") {
|
|
376
|
-
errors.push(`Environment variable ${key} must have a string value`);
|
|
377
|
-
}
|
|
378
|
-
}
|
|
379
|
-
}
|
|
380
|
-
}
|
|
381
|
-
return {
|
|
382
|
-
valid: errors.length === 0,
|
|
383
|
-
errors,
|
|
384
|
-
};
|
|
385
|
-
}
|
|
386
270
|
detectChanges(oldConfig, newConfig) {
|
|
387
271
|
const added = [];
|
|
388
272
|
const modified = [];
|
|
@@ -428,8 +312,10 @@ export class LiveConfigManager {
|
|
|
428
312
|
* Returns paths in priority order (local.json first, then .json)
|
|
429
313
|
*/
|
|
430
314
|
getConfigurationPaths() {
|
|
431
|
-
const
|
|
432
|
-
|
|
433
|
-
|
|
315
|
+
const paths = this.configurationService.getConfigurationPaths(this.workdir);
|
|
316
|
+
return {
|
|
317
|
+
userPaths: paths.userPaths,
|
|
318
|
+
projectPaths: paths.projectPaths,
|
|
319
|
+
};
|
|
434
320
|
}
|
|
435
321
|
}
|
|
@@ -31,6 +31,7 @@ export declare class PermissionManager {
|
|
|
31
31
|
private deniedRules;
|
|
32
32
|
private temporaryRules;
|
|
33
33
|
private additionalDirectories;
|
|
34
|
+
private systemAdditionalDirectories;
|
|
34
35
|
private workdir?;
|
|
35
36
|
private planFilePath?;
|
|
36
37
|
private onConfiguredDefaultModeChange?;
|
|
@@ -84,6 +85,10 @@ export declare class PermissionManager {
|
|
|
84
85
|
* Update the additional directories (e.g., when configuration reloads)
|
|
85
86
|
*/
|
|
86
87
|
updateAdditionalDirectories(directories: string[]): void;
|
|
88
|
+
/**
|
|
89
|
+
* Add a system-level additional directory that is persistent across configuration reloads
|
|
90
|
+
*/
|
|
91
|
+
addSystemAdditionalDirectory(directory: string): void;
|
|
87
92
|
/**
|
|
88
93
|
* Update the working directory
|
|
89
94
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"permissionManager.d.ts","sourceRoot":"","sources":["../../src/managers/permissionManager.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAIH,OAAO,KAAK,EACV,kBAAkB,EAClB,qBAAqB,EACrB,kBAAkB,EAClB,cAAc,EACf,MAAM,yBAAyB,CAAC;AAEjC,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAgBhD,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AA8BlD,MAAM,WAAW,wBAAwB;IACvC,uDAAuD;IACvD,qBAAqB,CAAC,EAAE,cAAc,CAAC;IACvC,kCAAkC;IAClC,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;IACxB,iCAAiC;IACjC,WAAW,CAAC,EAAE,MAAM,EAAE,CAAC;IACvB,8DAA8D;IAC9D,qBAAqB,CAAC,EAAE,MAAM,EAAE,CAAC;IACjC,iCAAiC;IACjC,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,oCAAoC;IACpC,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,sBAAsB;IACtB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,qBAAa,iBAAiB;
|
|
1
|
+
{"version":3,"file":"permissionManager.d.ts","sourceRoot":"","sources":["../../src/managers/permissionManager.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAIH,OAAO,KAAK,EACV,kBAAkB,EAClB,qBAAqB,EACrB,kBAAkB,EAClB,cAAc,EACf,MAAM,yBAAyB,CAAC;AAEjC,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAgBhD,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;A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,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,EAAE;IAmFjE;;;OAGG;IACU,iBAAiB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;CA4C5D"}
|
|
@@ -42,6 +42,7 @@ export class PermissionManager {
|
|
|
42
42
|
this.deniedRules = [];
|
|
43
43
|
this.temporaryRules = [];
|
|
44
44
|
this.additionalDirectories = [];
|
|
45
|
+
this.systemAdditionalDirectories = [];
|
|
45
46
|
this.configuredDefaultMode = options.configuredDefaultMode;
|
|
46
47
|
this.allowedRules = options.allowedRules || [];
|
|
47
48
|
this.deniedRules = options.deniedRules || [];
|
|
@@ -133,6 +134,17 @@ export class PermissionManager {
|
|
|
133
134
|
return path.resolve(dir);
|
|
134
135
|
});
|
|
135
136
|
}
|
|
137
|
+
/**
|
|
138
|
+
* Add a system-level additional directory that is persistent across configuration reloads
|
|
139
|
+
*/
|
|
140
|
+
addSystemAdditionalDirectory(directory) {
|
|
141
|
+
const resolvedPath = this.workdir && !path.isAbsolute(directory)
|
|
142
|
+
? path.resolve(this.workdir, directory)
|
|
143
|
+
: path.resolve(directory);
|
|
144
|
+
if (!this.systemAdditionalDirectories.includes(resolvedPath)) {
|
|
145
|
+
this.systemAdditionalDirectories.push(resolvedPath);
|
|
146
|
+
}
|
|
147
|
+
}
|
|
136
148
|
/**
|
|
137
149
|
* Update the working directory
|
|
138
150
|
*/
|
|
@@ -170,6 +182,12 @@ export class PermissionManager {
|
|
|
170
182
|
return { isInside: true, resolvedPath: absolutePath };
|
|
171
183
|
}
|
|
172
184
|
}
|
|
185
|
+
// Check system additional directories
|
|
186
|
+
for (const dir of this.systemAdditionalDirectories) {
|
|
187
|
+
if (isPathInside(absolutePath, dir)) {
|
|
188
|
+
return { isInside: true, resolvedPath: absolutePath };
|
|
189
|
+
}
|
|
190
|
+
}
|
|
173
191
|
return { isInside: false, resolvedPath: absolutePath };
|
|
174
192
|
}
|
|
175
193
|
/**
|
|
@@ -418,7 +436,20 @@ export class PermissionManager {
|
|
|
418
436
|
const targetPath = (context.toolInput?.file_path ||
|
|
419
437
|
context.toolInput?.path);
|
|
420
438
|
if (targetPath) {
|
|
421
|
-
|
|
439
|
+
if (minimatch(targetPath, pattern, { dot: true })) {
|
|
440
|
+
return true;
|
|
441
|
+
}
|
|
442
|
+
// If direct match fails, try matching relative path if targetPath is absolute and pattern is relative
|
|
443
|
+
if (path.isAbsolute(targetPath) &&
|
|
444
|
+
!path.isAbsolute(pattern) &&
|
|
445
|
+
this.workdir) {
|
|
446
|
+
const relativePath = path.relative(this.workdir, targetPath);
|
|
447
|
+
// Ensure the path is not outside the workdir (doesn't start with ..)
|
|
448
|
+
if (!relativePath.startsWith("..") &&
|
|
449
|
+
!path.isAbsolute(relativePath)) {
|
|
450
|
+
return minimatch(relativePath, pattern, { dot: true });
|
|
451
|
+
}
|
|
452
|
+
}
|
|
422
453
|
}
|
|
423
454
|
}
|
|
424
455
|
return false;
|
|
@@ -34,10 +34,6 @@ export declare class ConfigurationService {
|
|
|
34
34
|
* Validate configuration file without loading
|
|
35
35
|
*/
|
|
36
36
|
validateConfigurationFile(filePath: string): ValidationResult;
|
|
37
|
-
/**
|
|
38
|
-
* Get currently loaded configuration
|
|
39
|
-
*/
|
|
40
|
-
getCurrentConfiguration(): WaveConfiguration | null;
|
|
41
37
|
/**
|
|
42
38
|
* Set environment variables from configuration
|
|
43
39
|
* This replaces direct process.env modification
|
|
@@ -101,7 +97,7 @@ export declare class ConfigurationService {
|
|
|
101
97
|
*/
|
|
102
98
|
getConfigurationPaths(workdir: string): ConfigurationPaths;
|
|
103
99
|
/**
|
|
104
|
-
* Add a permission rule to the
|
|
100
|
+
* Add a permission rule to the local settings.local.json
|
|
105
101
|
*/
|
|
106
102
|
addAllowedRule(workdir: string, rule: string): Promise<void>;
|
|
107
103
|
/**
|
|
@@ -135,21 +131,6 @@ export declare function mergeEnvironmentConfig(userEnv: Record<string, string> |
|
|
|
135
131
|
* Supports both hooks and environment variables with proper validation
|
|
136
132
|
*/
|
|
137
133
|
export declare function loadWaveConfigFromFile(filePath: string): WaveConfiguration | null;
|
|
138
|
-
/**
|
|
139
|
-
* Load Wave configuration from multiple file paths in priority order
|
|
140
|
-
* Returns the first valid configuration found, or null if none exist
|
|
141
|
-
*/
|
|
142
|
-
export declare function loadWaveConfigFromFiles(filePaths: string[]): WaveConfiguration | null;
|
|
143
|
-
/**
|
|
144
|
-
* Load user-specific Wave configuration
|
|
145
|
-
* Checks .local.json first, then falls back to .json
|
|
146
|
-
*/
|
|
147
|
-
export declare function loadUserWaveConfig(): WaveConfiguration | null;
|
|
148
|
-
/**
|
|
149
|
-
* Load project-specific Wave configuration
|
|
150
|
-
* Checks .local.json first, then falls back to .json
|
|
151
|
-
*/
|
|
152
|
-
export declare function loadProjectWaveConfig(workdir: string): WaveConfiguration | null;
|
|
153
134
|
/**
|
|
154
135
|
* Load and merge Wave configuration from both user and project sources
|
|
155
136
|
* Project configuration takes precedence over user configuration
|
|
@@ -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,EACd,YAAY,EACb,MAAM,mBAAmB,CAAC;AAK3B,OAAO,EAAE,aAAa,EAAE,MAAM,QAAQ,CAAC;AAGvC;;;;;GAKG;AACH,qBAAa,oBAAoB;IAC/B,OAAO,CAAC,oBAAoB,CAAkC;IAC9D,OAAO,CAAC,GAAG,CAA8B;IACzC,OAAO,CAAC,OAAO,CAAoB;IAEnC;;OAEG;IACH,UAAU,CAAC,OAAO,EAAE,YAAY,GAAG,IAAI;IAMvC;;OAEG;IACG,uBAAuB,CAC3B,OAAO,EAAE,MAAM,GACd,OAAO,CAAC,uBAAuB,CAAC;
|
|
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,EACd,YAAY,EACb,MAAM,mBAAmB,CAAC;AAK3B,OAAO,EAAE,aAAa,EAAE,MAAM,QAAQ,CAAC;AAGvC;;;;;GAKG;AACH,qBAAa,oBAAoB;IAC/B,OAAO,CAAC,oBAAoB,CAAkC;IAC9D,OAAO,CAAC,GAAG,CAA8B;IACzC,OAAO,CAAC,OAAO,CAAoB;IAEnC;;OAEG;IACH,UAAU,CAAC,OAAO,EAAE,YAAY,GAAG,IAAI;IAMvC;;OAEG;IACG,uBAAuB,CAC3B,OAAO,EAAE,MAAM,GACd,OAAO,CAAC,uBAAuB,CAAC;IA4DnC;;OAEG;IACH,qBAAqB,CAAC,MAAM,EAAE,iBAAiB,GAAG,gBAAgB;IAoJlE;;OAEG;IACH,yBAAyB,CAAC,QAAQ,EAAE,MAAM,GAAG,gBAAgB;IAwC7D;;;OAGG;IACH,kBAAkB,CAAC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,IAAI;IAIrD;;OAEG;IACH,kBAAkB,IAAI,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC;IAQ5C;;;;;;;;;;OAUG;IACH,oBAAoB,CAClB,MAAM,CAAC,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BAAsB,CAAC,QAAQ,EAAE,MAAM,GAAG,iBAAiB,GAAG,IAAI;CAGnE;AAKD;;GAEG;AACH,wBAAgB,yBAAyB,CACvC,GAAG,EAAE,OAAO,EACZ,UAAU,CAAC,EAAE,MAAM,GAClB,2BAA2B,CAsD7B;AAED;;GAEG;AACH,wBAAgB,sBAAsB,CACpC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,SAAS,EAC3C,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,SAAS,EAC9C,OAAO,GAAE,uBAA4B,GACpC,wBAAwB,CAoC1B;AAED;;;GAGG;AACH,wBAAgB,sBAAsB,CACpC,QAAQ,EAAE,MAAM,GACf,iBAAiB,GAAG,IAAI,CA4B1B;AAED;;;;GAIG;AACH,wBAAgB,oBAAoB,CAClC,OAAO,EAAE,MAAM,GACd,iBAAiB,GAAG,IAAI,CAoI1B"}
|
|
@@ -36,41 +36,27 @@ export class ConfigurationService {
|
|
|
36
36
|
*/
|
|
37
37
|
async loadMergedConfiguration(workdir) {
|
|
38
38
|
try {
|
|
39
|
-
const userConfigPaths = getUserConfigPaths();
|
|
40
|
-
const projectConfigPaths = getProjectConfigPaths(workdir);
|
|
41
39
|
// Use the merged configuration function (this loads user and project configs internally)
|
|
42
40
|
const mergedConfig = loadMergedWaveConfig(workdir);
|
|
43
|
-
// Track loading context for better error messages by checking which files exist
|
|
44
|
-
const loadingContext = [];
|
|
45
|
-
const userPath = userConfigPaths.find((path) => existsSync(path));
|
|
46
|
-
if (userPath) {
|
|
47
|
-
loadingContext.push(`user config from ${userPath}`);
|
|
48
|
-
}
|
|
49
|
-
const projectPath = projectConfigPaths.find((path) => existsSync(path));
|
|
50
|
-
if (projectPath) {
|
|
51
|
-
loadingContext.push(`project config from ${projectPath}`);
|
|
52
|
-
}
|
|
53
41
|
if (!mergedConfig) {
|
|
54
|
-
const message = loadingContext.length > 0
|
|
55
|
-
? `No valid configuration found despite attempting to load: ${loadingContext.join(", ")}`
|
|
56
|
-
: "No configuration files found in user or project directories";
|
|
57
42
|
// Still set system environment variables even if no config is found
|
|
58
43
|
const env = { WAVE_PROJECT_DIR: workdir };
|
|
59
44
|
this.setEnvironmentVars(env);
|
|
60
45
|
return {
|
|
61
46
|
configuration: { env },
|
|
62
47
|
success: true, // No config is valid
|
|
63
|
-
warnings: [
|
|
48
|
+
warnings: [
|
|
49
|
+
"No configuration files found in user or project directories",
|
|
50
|
+
],
|
|
64
51
|
};
|
|
65
52
|
}
|
|
66
53
|
// Comprehensive validation
|
|
67
54
|
const validation = this.validateConfiguration(mergedConfig);
|
|
68
55
|
if (!validation.isValid) {
|
|
69
|
-
const sourcePaths = loadingContext.join(" and ");
|
|
70
56
|
return {
|
|
71
57
|
configuration: null,
|
|
72
58
|
success: false,
|
|
73
|
-
error: `Merged configuration validation failed
|
|
59
|
+
error: `Merged configuration validation failed: ${validation.errors.join(", ")}`,
|
|
74
60
|
warnings: validation.warnings,
|
|
75
61
|
};
|
|
76
62
|
}
|
|
@@ -83,11 +69,10 @@ export class ConfigurationService {
|
|
|
83
69
|
};
|
|
84
70
|
this.setEnvironmentVars(env);
|
|
85
71
|
mergedConfig.env = env;
|
|
86
|
-
const sourcePaths = loadingContext.join(" and ");
|
|
87
72
|
return {
|
|
88
73
|
configuration: mergedConfig,
|
|
89
74
|
success: true,
|
|
90
|
-
sourcePath:
|
|
75
|
+
sourcePath: "merged configuration",
|
|
91
76
|
warnings: validation.warnings,
|
|
92
77
|
};
|
|
93
78
|
}
|
|
@@ -260,12 +245,6 @@ export class ConfigurationService {
|
|
|
260
245
|
return result;
|
|
261
246
|
}
|
|
262
247
|
// Utility operations
|
|
263
|
-
/**
|
|
264
|
-
* Get currently loaded configuration
|
|
265
|
-
*/
|
|
266
|
-
getCurrentConfiguration() {
|
|
267
|
-
return this.currentConfiguration;
|
|
268
|
-
}
|
|
269
248
|
/**
|
|
270
249
|
* Set environment variables from configuration
|
|
271
250
|
* This replaces direct process.env modification
|
|
@@ -318,15 +297,6 @@ export class ConfigurationService {
|
|
|
318
297
|
else {
|
|
319
298
|
resolvedBaseURL = this.env.WAVE_BASE_URL || "";
|
|
320
299
|
}
|
|
321
|
-
// If we have a parent configuration, use it as a fallback for API key and base URL
|
|
322
|
-
if (this.currentConfiguration?.env) {
|
|
323
|
-
if (resolvedApiKey === undefined) {
|
|
324
|
-
resolvedApiKey = this.currentConfiguration.env.WAVE_API_KEY;
|
|
325
|
-
}
|
|
326
|
-
if (!resolvedBaseURL) {
|
|
327
|
-
resolvedBaseURL = this.currentConfiguration.env.WAVE_BASE_URL || "";
|
|
328
|
-
}
|
|
329
|
-
}
|
|
330
300
|
// Fallback to process.env if still not resolved (for dynamic updates in tests)
|
|
331
301
|
if (resolvedApiKey === undefined) {
|
|
332
302
|
resolvedApiKey = process.env.WAVE_API_KEY;
|
|
@@ -376,16 +346,10 @@ export class ConfigurationService {
|
|
|
376
346
|
const DEFAULT_FAST_MODEL = "gemini-2.5-flash";
|
|
377
347
|
// Resolve agent model: override > options > env (settings.json) > process.env > default
|
|
378
348
|
let resolvedAgentModel = model || this.options.model || this.env.WAVE_MODEL;
|
|
379
|
-
if (!resolvedAgentModel && this.currentConfiguration?.env?.WAVE_MODEL) {
|
|
380
|
-
resolvedAgentModel = this.currentConfiguration.env.WAVE_MODEL;
|
|
381
|
-
}
|
|
382
349
|
resolvedAgentModel =
|
|
383
350
|
resolvedAgentModel || process.env.WAVE_MODEL || DEFAULT_AGENT_MODEL;
|
|
384
351
|
// Resolve fast model: override > options > env (settings.json) > process.env > default
|
|
385
352
|
let resolvedFastModel = fastModel || this.options.fastModel || this.env.WAVE_FAST_MODEL;
|
|
386
|
-
if (!resolvedFastModel && this.currentConfiguration?.env?.WAVE_FAST_MODEL) {
|
|
387
|
-
resolvedFastModel = this.currentConfiguration.env.WAVE_FAST_MODEL;
|
|
388
|
-
}
|
|
389
353
|
resolvedFastModel =
|
|
390
354
|
resolvedFastModel || process.env.WAVE_FAST_MODEL || DEFAULT_FAST_MODEL;
|
|
391
355
|
// Resolve max output tokens
|
|
@@ -502,7 +466,7 @@ export class ConfigurationService {
|
|
|
502
466
|
};
|
|
503
467
|
}
|
|
504
468
|
/**
|
|
505
|
-
* Add a permission rule to the
|
|
469
|
+
* Add a permission rule to the local settings.local.json
|
|
506
470
|
*/
|
|
507
471
|
async addAllowedRule(workdir, rule) {
|
|
508
472
|
const localConfigPath = path.join(workdir, ".wave", "settings.local.json");
|
|
@@ -541,13 +505,13 @@ export class ConfigurationService {
|
|
|
541
505
|
}
|
|
542
506
|
let configPath;
|
|
543
507
|
if (scope === "user") {
|
|
544
|
-
configPath = getUserConfigPaths()[
|
|
508
|
+
configPath = getUserConfigPaths()[0]; // settings.json
|
|
545
509
|
}
|
|
546
510
|
else if (scope === "project") {
|
|
547
511
|
configPath = getProjectConfigPaths(workdir)[1]; // settings.json
|
|
548
512
|
}
|
|
549
513
|
else {
|
|
550
|
-
configPath = getProjectConfigPaths(workdir)[0]; // settings.local.json
|
|
514
|
+
configPath = getProjectConfigPaths(workdir)[0]; // local settings.local.json
|
|
551
515
|
}
|
|
552
516
|
// Ensure directory exists
|
|
553
517
|
const configDir = path.dirname(configPath);
|
|
@@ -579,13 +543,13 @@ export class ConfigurationService {
|
|
|
579
543
|
}
|
|
580
544
|
let configPath;
|
|
581
545
|
if (scope === "user") {
|
|
582
|
-
configPath = getUserConfigPaths()[
|
|
546
|
+
configPath = getUserConfigPaths()[0]; // settings.json
|
|
583
547
|
}
|
|
584
548
|
else if (scope === "project") {
|
|
585
549
|
configPath = getProjectConfigPaths(workdir)[1]; // settings.json
|
|
586
550
|
}
|
|
587
551
|
else {
|
|
588
|
-
configPath = getProjectConfigPaths(workdir)[0]; // settings.local.json
|
|
552
|
+
configPath = getProjectConfigPaths(workdir)[0]; // local settings.local.json
|
|
589
553
|
}
|
|
590
554
|
if (!existsSync(configPath)) {
|
|
591
555
|
return; // Nothing to remove
|
|
@@ -710,21 +674,6 @@ export function loadWaveConfigFromFile(filePath) {
|
|
|
710
674
|
try {
|
|
711
675
|
const content = readFileSync(filePath, "utf-8");
|
|
712
676
|
const config = JSON.parse(content);
|
|
713
|
-
// Validate basic structure
|
|
714
|
-
if (!config || typeof config !== "object") {
|
|
715
|
-
throw new Error(`Invalid configuration structure in ${filePath}`);
|
|
716
|
-
}
|
|
717
|
-
// Validate environment variables if present
|
|
718
|
-
if (config.env !== undefined) {
|
|
719
|
-
const envValidation = validateEnvironmentConfig(config.env, filePath);
|
|
720
|
-
if (!envValidation.isValid) {
|
|
721
|
-
throw new Error(`Environment variable validation failed in ${filePath}: ${envValidation.errors.join(", ")}`);
|
|
722
|
-
}
|
|
723
|
-
// Log warnings if any
|
|
724
|
-
if (envValidation.warnings.length > 0) {
|
|
725
|
-
console.warn(`Environment variable warnings in ${filePath}:\n- ${envValidation.warnings.join("\n- ")}`);
|
|
726
|
-
}
|
|
727
|
-
}
|
|
728
677
|
return {
|
|
729
678
|
hooks: config.hooks || undefined,
|
|
730
679
|
env: config.env || undefined,
|
|
@@ -744,48 +693,20 @@ export function loadWaveConfigFromFile(filePath) {
|
|
|
744
693
|
throw error;
|
|
745
694
|
}
|
|
746
695
|
}
|
|
747
|
-
/**
|
|
748
|
-
* Load Wave configuration from multiple file paths in priority order
|
|
749
|
-
* Returns the first valid configuration found, or null if none exist
|
|
750
|
-
*/
|
|
751
|
-
export function loadWaveConfigFromFiles(filePaths) {
|
|
752
|
-
for (const filePath of filePaths) {
|
|
753
|
-
const config = loadWaveConfigFromFile(filePath);
|
|
754
|
-
if (config !== null) {
|
|
755
|
-
return config;
|
|
756
|
-
}
|
|
757
|
-
}
|
|
758
|
-
return null;
|
|
759
|
-
}
|
|
760
|
-
/**
|
|
761
|
-
* Load user-specific Wave configuration
|
|
762
|
-
* Checks .local.json first, then falls back to .json
|
|
763
|
-
*/
|
|
764
|
-
export function loadUserWaveConfig() {
|
|
765
|
-
return loadWaveConfigFromFiles(getUserConfigPaths());
|
|
766
|
-
}
|
|
767
|
-
/**
|
|
768
|
-
* Load project-specific Wave configuration
|
|
769
|
-
* Checks .local.json first, then falls back to .json
|
|
770
|
-
*/
|
|
771
|
-
export function loadProjectWaveConfig(workdir) {
|
|
772
|
-
return loadWaveConfigFromFiles(getProjectConfigPaths(workdir));
|
|
773
|
-
}
|
|
774
696
|
/**
|
|
775
697
|
* Load and merge Wave configuration from both user and project sources
|
|
776
698
|
* Project configuration takes precedence over user configuration
|
|
777
699
|
* Checks .local.json files first, then falls back to .json files
|
|
778
700
|
*/
|
|
779
701
|
export function loadMergedWaveConfig(workdir) {
|
|
780
|
-
const userPaths = getUserConfigPaths(); // [
|
|
702
|
+
const userPaths = getUserConfigPaths(); // [json]
|
|
781
703
|
const projectPaths = getProjectConfigPaths(workdir); // [local, json]
|
|
782
704
|
// Priority order (lowest to highest):
|
|
783
|
-
// user settings.json ->
|
|
705
|
+
// user settings.json -> project settings.json -> local settings.local.json
|
|
784
706
|
const pathsToLoad = [
|
|
785
|
-
userPaths[
|
|
786
|
-
userPaths[0], // user settings.local.json
|
|
707
|
+
userPaths[0], // user settings.json
|
|
787
708
|
projectPaths[1], // project settings.json
|
|
788
|
-
projectPaths[0], //
|
|
709
|
+
projectPaths[0], // local settings.local.json
|
|
789
710
|
];
|
|
790
711
|
const configs = [];
|
|
791
712
|
for (const path of pathsToLoad) {
|
|
@@ -1 +1 @@
|
|
|
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,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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;CAgPjB"}
|
|
@@ -57,6 +57,9 @@ export class InitializationService {
|
|
|
57
57
|
if (configResult.configuration.permissions.defaultMode) {
|
|
58
58
|
permissionManager.updateConfiguredDefaultMode(configResult.configuration.permissions.defaultMode);
|
|
59
59
|
}
|
|
60
|
+
if (configResult.configuration.permissions.additionalDirectories) {
|
|
61
|
+
permissionManager.updateAdditionalDirectories(configResult.configuration.permissions.additionalDirectories);
|
|
62
|
+
}
|
|
60
63
|
}
|
|
61
64
|
}
|
|
62
65
|
}
|
|
@@ -93,6 +96,11 @@ export class InitializationService {
|
|
|
93
96
|
const memoryService = container.get("MemoryService");
|
|
94
97
|
if (memoryService) {
|
|
95
98
|
await memoryService.ensureAutoMemoryDirectory(workdir);
|
|
99
|
+
const permissionManager = container.get("PermissionManager");
|
|
100
|
+
if (permissionManager) {
|
|
101
|
+
const autoMemoryDir = memoryService.getAutoMemoryDirectory(workdir);
|
|
102
|
+
permissionManager.addSystemAdditionalDirectory(autoMemoryDir);
|
|
103
|
+
}
|
|
96
104
|
}
|
|
97
105
|
}
|
|
98
106
|
}
|
|
@@ -1 +1 @@
|
|
|
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;
|
|
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;IAU/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"}
|
package/dist/services/memory.js
CHANGED
|
@@ -14,7 +14,10 @@ export class MemoryService {
|
|
|
14
14
|
* Uses the git common directory to ensure worktrees share the same memory.
|
|
15
15
|
*/
|
|
16
16
|
getAutoMemoryDirectory(workdir) {
|
|
17
|
-
const
|
|
17
|
+
const commonDir = getGitCommonDir(workdir);
|
|
18
|
+
// If the common directory is a .git directory, use its parent as the project root
|
|
19
|
+
// for a cleaner encoded name while maintaining stability across worktrees.
|
|
20
|
+
const projectRoot = path.basename(commonDir) === ".git" ? path.dirname(commonDir) : commonDir;
|
|
18
21
|
const encodedName = pathEncoder.encodeSync(projectRoot);
|
|
19
22
|
return path.join(homedir(), ".wave", "projects", encodedName, "memory");
|
|
20
23
|
}
|