refactor(instructions): share instruction template rendering via @d3ro/core
This commit is contained in:
parent
d311e8123f
commit
ba0dbbd813
11 changed files with 423 additions and 36 deletions
|
|
@ -0,0 +1,37 @@
|
|||
// 회귀: 사용자 입력의 `$$`, `$'`, `$&`가 String.replace 치환 패턴으로 해석되어
|
||||
// LLM에 훼손된 텍스트가 전달되던 버그.
|
||||
import {
|
||||
buildBuiltinCommandPrompt,
|
||||
buildSyncedCommandPrompt,
|
||||
type SyncedCommand,
|
||||
} from '../src/features/commands/command-service'
|
||||
|
||||
function syncedCommand(prompt: string): SyncedCommand {
|
||||
return {
|
||||
id: '22222222-2222-4222-8222-222222222222',
|
||||
userId: '33333333-3333-4333-8333-333333333333',
|
||||
builtinKey: null,
|
||||
name: 'test',
|
||||
description: '',
|
||||
prompt,
|
||||
icon: 'bolt',
|
||||
sortOrder: 0,
|
||||
revision: 1,
|
||||
createdAt: '2026-01-01T00:00:00.000Z',
|
||||
updatedAt: '2026-01-01T00:00:00.000Z',
|
||||
}
|
||||
}
|
||||
|
||||
const DOLLAR_INPUT = "price is $$5, echo $'x', a $& b, c $` d"
|
||||
|
||||
describe('command prompt placeholder substitution keeps `$` patterns literal', () => {
|
||||
it('synced command with {{text}}', () => {
|
||||
expect(buildSyncedCommandPrompt(syncedCommand('요약: {{text}} 끝'), DOLLAR_INPUT))
|
||||
.toBe(`요약: ${DOLLAR_INPUT} 끝`)
|
||||
})
|
||||
|
||||
it('built-in command', () => {
|
||||
const prompt = buildBuiltinCommandPrompt('builtin-summarize', DOLLAR_INPUT)
|
||||
expect(prompt.endsWith(`\n\n${DOLLAR_INPUT}`)).toBe(true)
|
||||
})
|
||||
})
|
||||
Loading…
Add table
Add a link
Reference in a new issue