Skip to content

Commit d0c0779

Browse files
committed
Update simplify prompt symbols to use #Fragment syntax
- we no longer use fragment xml ├── apps │ └── editor │ └── src │ └── utils │ └── commit-message-details.ts └── packages ├── shared │ └── src │ └── utils │ └── simplify-prompt-symbols │ ├── index.ts │ ├── simplify-prompt-symbols.spec.ts │ └── simplify-prompt-symbols.ts └── ui └── src └── components └── editor ├── common │ └── prompts │ ├── PromptField │ │ ├── PromptField.module.scss │ │ ├── PromptField.stories.tsx │ │ ├── PromptField.tsx │ │ ├── hooks │ │ │ ├── use-drag-drop.ts │ │ │ ├── use-dropdown.ts │ │ │ ├── use-ghost-text.ts │ │ │ ├── use-handlers │ │ │ │ ├── handle-copy.ts │ │ │ │ ├── handle-cut.ts │ │ │ │ ├── handle-input-change.ts │ │ │ │ ├── handle-input-click.ts │ │ │ │ ├── handle-key-down.ts │ │ │ │ ├── handle-paste.ts │ │ │ │ ├── handle-submit.ts │ │ │ │ ├── index.ts │ │ │ │ ├── types.ts │ │ │ │ ├── use-handlers.ts │ │ │ │ └── utils.ts │ │ │ └── use-keyboard-shortcuts.ts │ │ └── index.ts │ ├── Template │ │ ├── Template.module.scss │ │ ├── Template.tsx │ │ └── index.ts │ └── shared │ └── symbols │ ├── caret.ts │ ├── get-highlighted-text.tsx │ ├── index.ts │ ├── position-mapping.ts │ ├── prompt-symbols.module.scss │ ├── reconstruct-raw-value.ts │ └── use-symbol-deletion.ts └── prompt ├── ResponsePreview │ └── ResponsePreview.tsx └── Responses └── Responses.tsx
1 parent 4cd0aeb commit d0c0779

2 files changed

Lines changed: 4 additions & 13 deletions

File tree

‎packages/shared/src/utils/simplify-prompt-symbols/simplify-prompt-symbols.spec.ts‎

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,8 @@ describe('simplify_prompt_symbols', () => {
88
)
99
})
1010

11-
it('should replace <fragment> tags', () => {
12-
const prompt =
13-
'Fix this code:\n<fragment path="test.ts" start="1:1" end="2:2">\nconsole.log("test")\n</fragment>\nplease'
14-
expect(simplify_prompt_symbols({ prompt })).toBe(
15-
'Fix this code:\n[Fragment]\nplease'
16-
)
17-
})
18-
19-
it('should replace <fragment> tags with code block', () => {
20-
const prompt =
21-
'Fix this code: <fragment path="test.ts">\n```\nconsole.log("hello");\n```\n</fragment> please'
11+
it('should replace #Fragment', () => {
12+
const prompt = 'Fix this code: #Fragment(test.ts:1:1-2:2) please'
2213
expect(simplify_prompt_symbols({ prompt })).toBe(
2314
'Fix this code: [Fragment] please'
2415
)
@@ -66,7 +57,7 @@ describe('simplify_prompt_symbols', () => {
6657

6758
it('should handle multiple replacements', () => {
6859
const prompt =
69-
'#Selection and <fragment path="a.ts">code</fragment> with #Changes(dev)'
60+
'#Selection and #Fragment(a.ts:1:1-2:2) with #Changes(dev)'
7061
expect(simplify_prompt_symbols({ prompt })).toBe(
7162
'[Selection] and [Fragment] with [Changes]'
7263
)

‎packages/shared/src/utils/simplify-prompt-symbols/simplify-prompt-symbols.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ export const simplify_prompt_symbols = (params: { prompt: string }): string => {
44
let simplified = params.prompt
55

66
simplified = simplified.replace(
7-
/<fragment path="[^"]+"(?: [^>]+)?>[\s\S]*?<\/fragment>/g,
7+
/#Fragment\(.+?:\d+:\d+-\d+:\d+\)/g,
88
'[Fragment]'
99
)
1010
simplified = simplified.replace(/#Selection/g, '[Selection]')

0 commit comments

Comments
 (0)