Skip to content

Commit 6c8fcf1

Browse files
joshspicerCopilot
andauthored
fix: exempt agent instructions from workspace subpath filter (#307937)
* fix: exempt agent instructions from workspace subpath filter AGENTS.md, CLAUDE.md, and copilot-instructions.md live at the workspace root by design. The CLI harness restricts items to workspaceSubpaths (.github, .copilot, .agents, .claude) which filtered out these root-level agent instruction files. Now items with groupKey 'agent-instructions' are exempt from the subpath filter, matching the existing exemption for instructionFileFilter patterns. * sessions: include AGENTS.md in instructions listing The sessions AI customization tree view and overview were only calling listPromptFiles(PromptsType.instructions) to discover instruction files. However, AGENTS.md (along with CLAUDE.md and copilot-instructions.md) is classified as an agent type by getPromptFileType(), so it was never returned by that call. Fix by also calling listAgentInstructions() and merging the results (deduplicating by URI), matching the pattern already used by the workbench customization editor. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --------- Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent ec038bf commit 6c8fcf1

3 files changed

Lines changed: 32 additions & 1 deletion

File tree

src/vs/sessions/contrib/aiCustomizationTreeView/browser/aiCustomizationOverviewView.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import { IContextKeyService } from '../../../../platform/contextkey/common/conte
1919
import { IOpenerService } from '../../../../platform/opener/common/opener.js';
2020
import { IThemeService } from '../../../../platform/theme/common/themeService.js';
2121
import { IHoverService } from '../../../../platform/hover/browser/hover.js';
22+
import { ResourceSet } from '../../../../base/common/map.js';
2223
import { IPromptsService } from '../../../../workbench/contrib/chat/common/promptSyntax/service/promptsService.js';
2324
import { PromptsType } from '../../../../workbench/contrib/chat/common/promptSyntax/promptTypes.js';
2425
import { AICustomizationManagementSection } from '../../../../workbench/contrib/chat/browser/aiCustomization/aiCustomizationManagement.js';
@@ -171,6 +172,17 @@ export class AICustomizationOverviewView extends ViewPane {
171172
} else {
172173
const allItems = await this.promptsService.listPromptFiles(type, CancellationToken.None);
173174
count = allItems.length;
175+
176+
// For instructions, also count agent instructions (AGENTS.md, copilot-instructions.md, CLAUDE.md, etc.)
177+
if (type === PromptsType.instructions) {
178+
const existingUris = new ResourceSet(allItems.map(item => item.uri));
179+
const agentInstructions = await this.promptsService.listAgentInstructions(CancellationToken.None);
180+
for (const file of agentInstructions) {
181+
if (!existingUris.has(file.uri)) {
182+
count++;
183+
}
184+
}
185+
}
174186
}
175187

176188
const sectionData = this.sections.find(s => s.id === section);

src/vs/sessions/contrib/aiCustomizationTreeView/browser/aiCustomizationTreeViewViews.ts

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import { IThemeService } from '../../../../platform/theme/common/themeService.js
2727
import { IViewPaneOptions, ViewPane } from '../../../../workbench/browser/parts/views/viewPane.js';
2828
import { IViewDescriptorService } from '../../../../workbench/common/views.js';
2929
import { IPromptsService, PromptsStorage, IAgentSkill, IPromptPath } from '../../../../workbench/contrib/chat/common/promptSyntax/service/promptsService.js';
30+
import { ResourceSet } from '../../../../base/common/map.js';
3031
import { PromptsType } from '../../../../workbench/contrib/chat/common/promptSyntax/promptTypes.js';
3132
import { agentIcon, extensionIcon, instructionsIcon, mcpServerIcon, pluginIcon, promptIcon, skillIcon, userIcon, workspaceIcon, builtinIcon } from '../../../../workbench/contrib/chat/browser/aiCustomization/aiCustomizationIcons.js';
3233
import { AICustomizationItemMenuId } from './aiCustomizationTreeView.js';
@@ -446,7 +447,19 @@ class UnifiedAICustomizationDataSource implements IAsyncDataSource<RootElement,
446447

447448
// For other types, fetch once and cache grouped by storage
448449
if (!cached.files) {
449-
const allItems = await this.promptsService.listPromptFiles(promptType, CancellationToken.None);
450+
const allItems: IPromptPath[] = [...await this.promptsService.listPromptFiles(promptType, CancellationToken.None)];
451+
452+
// For instructions, also include agent instructions (AGENTS.md, copilot-instructions.md, CLAUDE.md, etc.)
453+
if (promptType === PromptsType.instructions) {
454+
const existingUris = new ResourceSet(allItems.map(item => item.uri));
455+
const agentInstructions = await this.promptsService.listAgentInstructions(CancellationToken.None);
456+
for (const file of agentInstructions) {
457+
if (!existingUris.has(file.uri)) {
458+
allItems.push({ uri: file.uri, storage: PromptsStorage.local, type: PromptsType.instructions });
459+
}
460+
}
461+
}
462+
450463
const workspaceItems = allItems.filter(item => item.storage === PromptsStorage.local);
451464
const userItems = allItems.filter(item => item.storage === PromptsStorage.user);
452465
const extensionItems = allItems.filter(item => item.storage === PromptsStorage.extension);

src/vs/workbench/contrib/chat/browser/aiCustomization/aiCustomizationListWidget.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1609,6 +1609,12 @@ export class AICustomizationListWidget extends Disposable {
16091609
if (instrFilter && promptType === PromptsType.instructions && matchesInstructionFileFilter(item.uri.path, instrFilter)) {
16101610
continue;
16111611
}
1612+
// Keep agent instruction files (AGENTS.md, CLAUDE.md, copilot-instructions.md)
1613+
// — these live at the workspace root by design and should not be
1614+
// filtered out by workspace subpath restrictions.
1615+
if (item.groupKey === 'agent-instructions') {
1616+
continue;
1617+
}
16121618
items.splice(i, 1);
16131619
}
16141620
}

0 commit comments

Comments
 (0)