267
268
public createAgentInstructionsUpdatedEvent(): { readonly event: Event<void>; dispose: () => void } {
270
>
const eventEmitter = disposables.add(new Emitter<void>());
271
>
const cts = new CancellationTokenSource();
272
>
disposables.add(toDisposable(() => cts.dispose(true)));
273
>
const token = cts.token;
274
>
const watchers = disposables.add(new DisposableStore());
275
>
const watchedRoots = new ResourceSet();
276
>
277
>
const addWatch = (resource: URI) => {
278
>
if (token.isCancellationRequested) {
279
return;
280
}
282
return;
283
}
285
>
watchedRoots.add(resource);
286
>
watchers.add(this.fileService.watch(resource));
287
>
};
288
>
289
>
const updateWatchers = async () => {
290
>
watchers.clear();
291
>
watchedRoots.clear();
292
>
293
>
const watchWorkspaceRoots = this.configService.getValue(PromptsConfig.USE_AGENT_MD) || this.configService.getValue(PromptsConfig.USE_CLAUDE_MD);
294
>
const watchClaudeFolders = this.configService.getValue(PromptsConfig.USE_CLAUDE_MD);
295
>
const watchCopilotFolders = this.configService.getValue(PromptsConfig.USE_COPILOT_INSTRUCTION_FILES);
296
>
const includeParents = this.configService.getValue(PromptsConfig.USE_CUSTOMIZATIONS_IN_PARENT_REPOS) === true;
297
>
const workspaceRoots = await this.getWorkspaceFolderRoots(includeParents);
298
>
if (token.isCancellationRequested) {
299
return;
300
}
302
>
if (token.isCancellationRequested) {
303
return;
304
}
306
>
for (const workspaceRoot of workspaceRoots) {
307
>
if (watchWorkspaceRoots) {
308
>
addWatch(workspaceRoot);
309
>
}
310
>
if (watchClaudeFolders) {
311
addWatch(joinPath(workspaceRoot, CLAUDE_CONFIG_FOLDER));
312
}
314
>
addWatch(joinPath(workspaceRoot, GITHUB_CONFIG_FOLDER));
315
>
}
316
>
}
317
>
318
>
if (watchClaudeFolders) {
319
addWatch(joinPath(userHome, CLAUDE_CONFIG_FOLDER));
320
}
322
>
addWatch(joinPath(userHome, COPILOT_CONFIG_FOLDER));
323
>
}
324
>
};
325
>
326
>
const refresh = () => {
327
void updateWatchers();
328
eventEmitter.fire();
329
};
331
>
disposables.add(this.configService.onDidChangeConfiguration(e => {
332
if (
333
e.affectsConfiguration(PromptsConfig.USE_AGENT_MD) ||