Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 0 additions & 31 deletions extensions/copilot/src/extension/tools/node/test/readFile.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -885,37 +885,6 @@ suite('ReadFile', () => {
testAccessor.dispose();
});

test('should send skillStorage=internal for vscode-chat-internal scheme', async () => {
const skillContent = '# Internal Skill';
const skillUri = URI.from({ scheme: 'vscode-chat-internal', path: '/skills/internal-skill/SKILL.md' });
const testDoc = createTextDocumentData(skillUri, skillContent, 'markdown').document;

const services = createExtensionUnitTestingServices();
services.define(IWorkspaceService, new SyncDescriptor(
TestWorkspaceService,
[[URI.file('/workspace')], [testDoc]]
));

const mockCustomInstructions = new MockCustomInstructionsService();
mockCustomInstructions.setSkillFiles([skillUri], SkillStorage.Internal);
services.define(ICustomInstructionsService, mockCustomInstructions);

const telemetry = new CapturingTelemetryService();
services.define(ITelemetryService, telemetry);

const testAccessor = services.createTestingAccessor();
const readFileTool = testAccessor.get(IInstantiationService).createInstance(ReadFileTool);

const input: IReadFileParamsV2 = { filePath: skillUri.toString() };
await readFileTool.invoke({ input, toolInvocationToken: null as never }, CancellationToken.None);

const event = telemetry.events.find(e => e.eventName === 'skillContentRead');
expect(event).toBeDefined();
expect(event!.properties!.skillStorage).toBe(SkillStorage.Internal);

testAccessor.dispose();
});

test('should not send skillContentRead for non-skill files', async () => {
const telemetry = new CapturingTelemetryService();
const services = createExtensionUnitTestingServices();
Expand Down
3 changes: 0 additions & 3 deletions extensions/copilot/src/extension/tools/node/toolUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -206,9 +206,6 @@ export async function assertFileOkForTool(accessor: ServicesAccessor, uri: URI,
}

async function isExternalInstructionsFile(normalizedUri: URI, customInstructionsService: ICustomInstructionsService, buildPromptContext?: IBuildPromptContext): Promise<boolean> {
if (normalizedUri.scheme === 'vscode-chat-internal') {
return true;
}
if (customInstructionsService.getExtensionSkillInfo(normalizedUri)) {
return true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -439,9 +439,6 @@ export class CustomInstructionsService extends Disposable implements ICustomInst
}

public async isExternalInstructionsFile(uri: URI): Promise<boolean> {
if (uri.scheme === 'vscode-chat-internal') {
return true;
}
if (uri.scheme === Schemas.vscodeUserData && uri.path.endsWith(INSTRUCTION_FILE_EXTENSION)) {
return true;
}
Expand All @@ -465,44 +462,31 @@ export class CustomInstructionsService extends Disposable implements ICustomInst
}

public isSkillFile(uri: URI): boolean {
return this._matchInstructionLocationsFromSkills.get()(uri) !== undefined
|| this.getChatInternalSkillInfo(uri) !== undefined;
return this._matchInstructionLocationsFromSkills.get()(uri) !== undefined;
}

public isSkillMdFile(uri: URI): boolean {
return this.isSkillFile(uri) && extUriBiasedIgnorePathCase.basename(uri).toLowerCase() === 'skill.md';
}

public getSkillDirectory(uri: URI): URI | undefined {
const skillInfo = this._matchInstructionLocationsFromSkills.get()(uri) || this.getChatInternalSkillInfo(uri);
const skillInfo = this._matchInstructionLocationsFromSkills.get()(uri);
if (!skillInfo) {
return undefined;
}
return skillInfo.skillFolderUri;
}

public getSkillName(uri: URI): string | undefined {
const skillInfo = this._matchInstructionLocationsFromSkills.get()(uri) || this.getChatInternalSkillInfo(uri);
const skillInfo = this._matchInstructionLocationsFromSkills.get()(uri);
if (!skillInfo) {
return undefined;
}
return skillInfo.skillName;
}

public getSkillInfo(uri: URI): ISkillInfo | undefined {
return this._matchInstructionLocationsFromSkills.get()(uri) || this.getChatInternalSkillInfo(uri);
}

private getChatInternalSkillInfo(uri: URI): ISkillInfo | undefined {
if (uri.scheme !== 'vscode-chat-internal') {
return undefined;
}
if (extUriBiasedIgnorePathCase.basename(uri).toLowerCase() !== 'skill.md') {
return undefined;
}
const skillFolderUri = extUriBiasedIgnorePathCase.dirname(uri);
const skillName = extUriBiasedIgnorePathCase.basename(skillFolderUri);
return { skillName, skillFolderUri, storage: SkillStorage.Internal };
return this._matchInstructionLocationsFromSkills.get()(uri);
}
}

Expand Down Expand Up @@ -591,4 +575,4 @@ function xmlContents(text: string, tag: string): string[] {
matches.push(match[1].trim());
}
return matches;
}
}
Loading