Skip to content

Commit 9059f78

Browse files
author
vijay upadya
committed
few prompt tweaks
1 parent 94547bc commit 9059f78

File tree

3 files changed

+466
-368
lines changed

3 files changed

+466
-368
lines changed

src/extension/linkify/test/node/modelFilePathLinkifier.spec.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,12 @@ suite('Model File Path Linkifier', () => {
5151
assertPartsEqual(result.parts, ['other']);
5252
});
5353

54+
test('Should return label when text omits path', async () => {
55+
const service = createTestLinkifierService('src/file.ts');
56+
const result = await linkify(service, '[line 54](src/file.ts#L54)');
57+
assertPartsEqual(result.parts, ['line 54']);
58+
});
59+
5460
test('Should fallback for invalid anchor syntax', async () => {
5561
const service = createTestLinkifierService('src/file.ts');
5662
const result = await linkify(service, '[src/file.ts](src/file.ts#Lines10-12)');

src/extension/prompts/node/agent/fileLinkificationInstructions.tsx

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,20 @@ import { Tag } from '../base/tag';
99
export class FileLinkificationInstructions extends PromptElement<{}> {
1010
render() {
1111
return <Tag name='file_linkification'>
12-
ALWAYS convert file paths to markdown links with 1-based line numbers whenever you cite specific code locations:<br />
13-
[path/to/file.ts](path/to/file.ts) - whole file<br />
14-
[path/to/file.ts](path/to/file.ts#L10) - single line<br />
15-
[path/to/file.ts](path/to/file.ts#L10-12) - line range<br />
16-
When listing multiple references, start each item with the linked path, for example:<br />
17-
[path/to/chatQuick.ts](path/to/chatQuick.ts#L142) - awaiting a call to open the chat view<br />
18-
[path/to/chatQuick.ts](path/to/chatQuick.ts#L321) - awaiting the chat view widget<br />
12+
ALWAYS convert file paths to markdown links with 1-based line numbers whenever you cite specific code locations. Use links inside normal sentences, not as the entire answer.<br />
13+
Format examples:<br />
14+
- `The handler lives in [path/to/file.ts](path/to/file.ts#L10).` (single line)<br />
15+
- `See [path/to/file.ts](path/to/file.ts#L10-12) for the range.`<br />
16+
- `Configuration is defined in [path/to/file.ts](path/to/file.ts).` (whole file)<br />
17+
When you need a bullet list of references, write a short description before the link, for example:<br />
18+
- Await chat view: [path/to/chatQuick.ts](path/to/chatQuick.ts#L142)<br />
19+
- Show widget: [path/to/chatQuick.ts](path/to/chatQuick.ts#L321)<br />
1920
Examples:<br />
2021
❌ `The function is in exampleScript.ts at line 25.`<br />
2122
✓ `The function is in [exampleScript.ts](exampleScript.ts#L25).`<br />
2223
Critical rules:<br />
23-
- Link text = exact file path only (no backticks, no `#L` in the visible text, no extra wording). Keep any `#L` anchors in the link target, for example `[src/file.ts](src/file.ts#L25)`.<br />
24+
- Link text must be the exact file path (no backticks, no `#L` in the visible text, no extra wording). Keep the `#L` anchor in the **link target**, e.g. `[src/file.ts](src/file.ts#L25)`.<br />
25+
- Always include both brackets **and** parentheses. `[src/file.ts](src/file.ts#L25)` is valid; `[src/file.ts#L25]` is not.<br />
2426
- Path format: Strip drive letters and workspace parent folders - use only path after workspace root<br />
2527
- Transform `c:\Repos\workspace\src\file.ts` → `[src/file.ts](src/file.ts)`<br />
2628
- Always use forward slashes `/`, never backslashes `\`<br />

0 commit comments

Comments
 (0)