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