feat(kol): add selection-based AI optimize for prompt editor
Trigger an AI optimize panel from a text selection in the KOL prompt editor, accept a user instruction, and stream a preview before replacing the selected fragment. Extend the shared editor AI assist panel with boundary-aware placement so it can be hosted inside scoped surfaces, and update the backend optimize prompt to honor the user instruction. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -72,6 +72,20 @@ func TestParseKolAssistResponseSupportsStringVariables(t *testing.T) {
|
||||
require.Equal(t, "城市", result.Schema.Variables[0].Key)
|
||||
}
|
||||
|
||||
func TestBuildKolAssistUserPromptIncludesOptimizeInstruction(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
prompt, err := BuildKolAssistUserPrompt(AssistRequest{
|
||||
Mode: kolAssistModeOptimize,
|
||||
Description: "让表达更清晰,但保留变量",
|
||||
CurrentContent: "围绕 {{城市}} 写一段内容",
|
||||
})
|
||||
|
||||
require.NoError(t, err)
|
||||
require.Contains(t, prompt, "Instruction:\n让表达更清晰,但保留变量")
|
||||
require.Contains(t, prompt, "PROMPT:\n围绕 {{城市}} 写一段内容")
|
||||
}
|
||||
|
||||
func TestExtractKolAssistContentFromPartialJSON(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user