feat: 优化默认提示词(HARD GATE约束) + 扩展prompt变量(Phase1+2)

Phase 1: 重写 DEFAULT_TASK_BLOCKS 全部6个任务的 role/format/rules
- 统一应用 HARD GATE 约束段 + 常见错误负例
- compress/synopsis 增加自检清单
- 增强 JSON 稳定性约束

Phase 2: 扩展 prompt 内置变量
- 新建 st-context.js: 统一读取 ST 上下文
- 新增变量: charName/userName/charDescription/userPersona/currentTime
- 更新 extractor/retriever/compressor/consolidator 共6处调用端
- 更新 BUILTIN_BLOCK_DEFINITIONS 帮助文案(多轮对话指引)
This commit is contained in:
Youzini-afk
2026-03-26 10:30:26 +08:00
parent 0e590a6256
commit 2f9524d993
6 changed files with 232 additions and 46 deletions

View File

@@ -13,6 +13,7 @@ import {
import { callLLMForJSON } from "./llm.js";
import { buildTaskPrompt } from "./prompt-builder.js";
import { applyTaskRegex } from "./task-regex.js";
import { getSTContextForPrompt } from "./st-context.js";
import { findSimilarNodesByText, validateVectorConfig } from "./vector-index.js";
function createAbortError(message = "操作已终止") {
@@ -425,6 +426,7 @@ async function llmRecall(
candidateNodes: candidateDescriptions,
candidateText: candidateDescriptions,
graphStats: `candidate_count=${candidates.length}`,
...getSTContextForPrompt(),
});
const systemPrompt = applyTaskRegex(
settings,