/** * ============================================================ * src/prompts/system.ts —— 系统提示词(向后兼容壳) * ------------------------------------------------------------ * * 所有提示词组装逻辑已迁移到 promptAssembly.ts。 * 本文件保留为向后兼容的委托壳,现有调用方无需改动。 * * 新代码请直接使用: * - assembleStablePrompt() → 稳定 system 层 * - assemblePromptEnvelope() → 分离的稳定层与易变层 * ============================================================ */ import type { Tool } from '../types.js'; import { assembleBasePrompt, assemblePromptEnvelope, assembleStablePrompt, type PromptEnvelope, type PromptProfile, type PromptRuntimeContext, } from './promptAssembly.js'; export { buildTransientBundle, buildTransientContext, buildTransientLayer, buildTransientPromptBundle } from './promptAssembly.js'; export { browserPromptRuntime } from './promptAssembly.js'; /** * 只取**稳定层**作为 system 消息内容 —— 提示词缓存的主入口。 * * 本函数只返回稳定层;旧 buildFullSystemPrompt 返回合并层,不应用于新宿主。宿主应当: * 1. 用本函数拿 base 建 history[0](每会话一次) * 2. 每回合另调 buildTransientContext() 拿易变层,经 RunQueryOptions.transientContext 下传 * (loop 会把它附加到本轮用户消息的模型副本,不污染历史) */ export async function buildBaseSystemPrompt( cwd: string, tools: Tool[], profile: PromptProfile = 'main', ): Promise { return assembleStablePrompt({ cwd, tools, profile, }); } /** * @deprecated 合并层兼容入口;新宿主使用 assemblePromptEnvelope() 分离稳定与易变内容。 */ export async function getSystemPrompt( cwd: string, tools: Tool[], profile: PromptProfile = 'main', ): Promise { return assembleBasePrompt({ cwd, tools, profile }); } /** * @deprecated 合并层兼容入口;新宿主使用 assemblePromptEnvelope({ includeProjectInstructions: true })。 */ export async function buildFullSystemPrompt( cwd: string, tools: Tool[], profile: PromptProfile = 'main', ): Promise { return assembleBasePrompt({ cwd, tools, profile, includeProjectInstructions: true }); } export async function buildSystemPromptEnvelope( cwd: string, tools: Tool[], runtime: Partial, profile: PromptProfile = 'main', ): Promise { return assemblePromptEnvelope({ cwd, tools, profile, includeProjectInstructions: true, runtime, }); }