import assert from "node:assert/strict"; import test from "node:test"; import { buildExecutionPromptForTesting, resolveRelevantMemoriesForTesting, } from "@/lib/execution/prompt-assembler"; test("PromptAssembler 会按固定顺序拼管理员提示词、用户提示词、对话提示词和记忆", () => { const prompt = buildExecutionPromptForTesting({ globalPrompt: "GLOBAL", userPrompt: "USER", conversationPrompt: "CONVERSATION", projectMemories: [{ title: "项目记忆", content: "PROJECT", projectId: "boss-console", tags: [] }], userMemories: [{ title: "用户记忆", content: "USER_MEMORY", tags: [] }], requestText: "继续", }); assert.equal( prompt, [ "管理员全局主提示词:\nGLOBAL", "用户私有主提示词:\nUSER", "当前对话附加提示词:\nCONVERSATION", "项目记忆:\n- [boss-console] 项目记忆: PROJECT", "用户通用记忆:\n- 用户记忆: USER_MEMORY", "当前消息:\n继续", ].join("\n\n"), ); }); test("PromptAssembler 会透出可测试的记忆筛选器", () => { const resolved = resolveRelevantMemoriesForTesting({ projectId: "master-agent", requestText: "boss-console 的审批流", memories: [ { memoryId: "m1", scope: "project", projectId: "boss-console", title: "审批流", content: "boss-console approval", tags: ["approval"], memoryType: "project_progress", createdAt: "2026-01-01T00:00:00.000Z", updatedAt: "2026-01-01T00:00:00.000Z", }, { memoryId: "m2", scope: "project", projectId: "wenshenapp", title: "UI", content: "wechat ui", tags: ["ui"], memoryType: "project_progress", createdAt: "2026-01-02T00:00:00.000Z", updatedAt: "2026-01-02T00:00:00.000Z", }, ], }); assert.equal(resolved.projectMemories.length, 1); assert.equal(resolved.projectMemories[0]?.projectId, "boss-console"); });