mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-02 08:15:56 +01:00
Avoid treating .copilot/agents as target of GithubCopiilot (#298706)
* Avoid treating .copilot/agents as target of GithubCopiilot * Remove test
This commit is contained in:
@@ -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) {
|
||||
|
||||
@@ -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';
|
||||
|
||||
Reference in New Issue
Block a user