Avoid treating .copilot/agents as target of GithubCopiilot (#298706)

* Avoid treating .copilot/agents as target of GithubCopiilot

* Remove test
This commit is contained in:
Don Jayamanne
2026-03-03 09:25:58 +11:00
committed by GitHub
parent 9d6ae94c14
commit b4a0baf0d9
2 changed files with 1 additions and 53 deletions

View File

@@ -23,7 +23,7 @@ import { ResourceMap } from '../../../../../../base/common/map.js';
import { IFileService } from '../../../../../../platform/files/common/files.js';
import { IPromptsService, Target } from '../service/promptsService.js';
import { ILabelService } from '../../../../../../platform/label/common/label.js';
import { AGENTS_SOURCE_FOLDER, isInClaudeAgentsFolder, isInClaudeRulesFolder, isInCopilotAgentsFolder, LEGACY_MODE_FILE_EXTENSION } from '../config/promptFileLocations.js';
import { AGENTS_SOURCE_FOLDER, isInClaudeAgentsFolder, isInClaudeRulesFolder, LEGACY_MODE_FILE_EXTENSION } from '../config/promptFileLocations.js';
import { Lazy } from '../../../../../../base/common/lazy.js';
import { CancellationToken } from '../../../../../../base/common/cancellation.js';
import { URI } from '../../../../../../base/common/uri.js';
@@ -1025,9 +1025,6 @@ export function getTarget(promptType: PromptsType, header: PromptHeader | URI):
if (isInClaudeAgentsFolder(uri)) {
return Target.Claude;
}
if (isInCopilotAgentsFolder(uri)) {
return Target.GitHubCopilot;
}
if (!(header instanceof URI)) {
const target = header.target;
if (target === Target.GitHubCopilot || target === Target.VSCode) {

View File

@@ -1177,55 +1177,6 @@ suite('PromptsService', () => {
);
});
test('copilot user agents from ~/.copilot/agents/ should have GitHubCopilot target', async () => {
const rootFolderName = 'copilot-user-agents';
const rootFolder = `/${rootFolderName}`;
const rootFolderUri = URI.file(rootFolder);
workspaceContextService.setWorkspace(testWorkspace(rootFolderUri));
await mockFiles(fileService, [
{
// Copilot user agent in ~/.copilot/agents/ (resolved from /home/user/.copilot/agents/)
path: '/home/user/.copilot/agents/copilot-user-agent.md',
contents: [
'---',
'description: \'Copilot user agent from home folder.\'',
'tools: [ read ]',
'---',
'I am a Copilot user agent.',
]
},
]);
const result = (await service.getCustomAgents(CancellationToken.None)).map(agent => ({ ...agent, uri: URI.from(agent.uri) }));
const expected: ICustomAgent[] = [
{
name: 'copilot-user-agent',
description: 'Copilot user agent from home folder.',
target: Target.GitHubCopilot,
tools: ['read'],
agentInstructions: {
content: 'I am a Copilot user agent.',
toolReferences: [],
metadata: undefined
},
handOffs: undefined,
model: undefined,
argumentHint: undefined,
visibility: { userInvocable: true, agentInvocable: true },
agents: undefined,
uri: URI.file('/home/user/.copilot/agents/copilot-user-agent.md'),
source: { storage: PromptsStorage.user }
},
];
assert.deepEqual(
result,
expected,
'Agents from ~/.copilot/agents/ must have Target.GitHubCopilot.',
);
});
test('agents with .md extension should be recognized, except README.md', async () => {
const rootFolderName = 'custom-agents-md-extension';