Path: blob/main/extensions/copilot/src/extension/prompts/node/agent/fileLinkificationInstructions.tsx
13405 views
/*---------------------------------------------------------------------------------------------1* Copyright (c) Microsoft Corporation. All rights reserved.2* Licensed under the MIT License. See License.txt in the project root for license information.3*--------------------------------------------------------------------------------------------*/45import { PromptElement } from '@vscode/prompt-tsx';6import { Tag } from '../base/tag';78export class FileLinkificationInstructions extends PromptElement<{}> {9render() {10return <Tag name='fileLinkification'>11When mentioning files or line numbers, always convert them to markdown links using workspace-relative paths and 1-based line numbers.<br />12NO BACKTICKS ANYWHERE:<br />13- Never wrap file names, paths, or links in backticks.<br />14- Never use inline-code formatting for any file reference.<br />15<br />1617REQUIRED FORMATS:<br />18- File: [path/file.ts](path/file.ts)<br />19- Line: [file.ts](file.ts#L10)<br />20- Range: [file.ts](file.ts#L10-L12)<br />21<br />2223PATH RULES:<br />24- Without line numbers: Display text must match the target path.<br />25- With line numbers: Display text can be either the path or descriptive text.<br />26- Use '/' only; strip drive letters and external folders.<br />27- Do not use these URI schemes: file://, vscode://<br />28- Encode spaces only in the target (My File.md → My%20File.md).<br />29- Non-contiguous lines require separate links. NEVER use comma-separated line references like #L10-L12, L20.<br />30- Valid formats: [file.ts](file.ts#L10) only. Invalid: ([file.ts#L10]) or [file.ts](file.ts)#L10<br />31- Only create links for files that exist in the workspace. Do not link to files you are suggesting to create or that do not exist yet.<br />32<br />3334USAGE EXAMPLES:<br />35- With path as display: The handler is in [src/handler.ts](src/handler.ts#L10).<br />36- With descriptive text: The [widget initialization](src/widget.ts#L321) runs on startup.<br />37- Bullet list: [Init widget](src/widget.ts#L321)<br />38- File only: See [src/config.ts](src/config.ts) for settings.<br />39<br />4041FORBIDDEN (NEVER OUTPUT):<br />42- Inline code: `file.ts`, `src/file.ts`, `L86`.<br />43- Plain text file names: file.ts, chatService.ts.<br />44- References without links when mentioning specific file locations.<br />45- Specific line citations without links ("Line 86", "at line 86", "on line 25").<br />46- Combining multiple line references in one link: [file.ts#L10-L12, L20](file.ts#L10-L12, L20)<br />47<br />48</Tag>;49}50}5152/**53* Condensed variant of FileLinkificationInstructions used by optimized Claude 4.6 prompt configurations.54* Removes usage examples, section headers, and redundant path rules while preserving core formatting requirements.55*/56export class FileLinkificationInstructionsOptimized extends PromptElement<{}> {57render() {58return <Tag name='fileLinkification'>59Convert file references to markdown links using workspace-relative paths and 1-based line numbers. NEVER wrap file references in backticks.<br />60<br />61Formats: [path/file.ts](path/file.ts), [file.ts](file.ts#L10), [file.ts](file.ts#L10-L12)<br />62<br />63Rules:<br />64- Without line numbers, display text must match target path<br />65- Use '/' only. Strip drive letters and external folders<br />66- Do not use file:// or vscode:// schemes<br />67- Encode spaces only in target (My%20File.md)<br />68- Non-contiguous lines require separate links. NEVER use comma-separated references like #L10-L12, L20<br />69- Only link to files that exist in the workspace<br />70<br />71FORBIDDEN: inline code for file names (`file.ts`), plain text file names without links, line citations without links ("Line 86"), combining multiple line references in one link.<br />72</Tag>;73}74}757677