diff --git a/apps/mcp/src/server/tools/get-profile.test.ts b/apps/mcp/src/server/tools/get-profile.test.ts deleted file mode 100644 index 9ea21d32..00000000 --- a/apps/mcp/src/server/tools/get-profile.test.ts +++ /dev/null @@ -1,88 +0,0 @@ -import { describe, expect, it } from "vitest" -import * as getProfile from "./get-profile" -import type { ToolDeps } from "./types" - -function registerProfile(client: { - getProfile: () => Promise<{ - profile: { static: string[]; dynamic: string[] } - }> -}) { - let handler: - | ((args: { containerTag?: string }) => Promise) - | undefined - - getProfile.register({ - server: { - registerTool: ( - _name: string, - _config: unknown, - registered: (args: { containerTag?: string }) => Promise, - ) => { - handler = registered - }, - }, - resolveContainerTag: async (tag?: string) => tag ?? "sm_project_default", - getClient: () => client, - errorResult: (error: unknown) => ({ - content: [ - { - type: "text" as const, - text: error instanceof Error ? error.message : "error", - }, - ], - isError: true, - }), - } as unknown as ToolDeps) - - if (!handler) throw new Error("getProfile was not registered") - return handler -} - -describe("get_profile", () => { - it("returns stable and recent profile facts for the resolved space", async () => { - const handler = registerProfile({ - getProfile: async () => ({ - profile: { - static: ["User is a software engineer"], - dynamic: ["User is debugging auth"], - }, - }), - }) - - const result = (await handler({ containerTag: "team_eng" })) as { - content: Array<{ text: string }> - structuredContent: { - containerTag: string - profile: { static: string[]; dynamic: string[] } - } - } - - expect(result.structuredContent).toEqual({ - containerTag: "team_eng", - profile: { - static: ["User is a software engineer"], - dynamic: ["User is debugging auth"], - }, - }) - expect(result.content[0]?.text).toContain("## Stable Context") - expect(result.content[0]?.text).toContain("User is a software engineer") - expect(result.content[0]?.text).toContain("## Recent Context") - expect(result.content[0]?.text).toContain("User is debugging auth") - }) - - it("says when the space has no profile facts yet", async () => { - const handler = registerProfile({ - getProfile: async () => ({ - profile: { static: [], dynamic: [] }, - }), - }) - - const result = (await handler({})) as { - content: Array<{ text: string }> - } - - expect(result.content[0]?.text).toBe( - "No profile facts are available for this space yet.", - ) - }) -}) diff --git a/apps/mcp/src/server/tools/search-memory.test.ts b/apps/mcp/src/server/tools/search-memory.test.ts deleted file mode 100644 index 7ebd2800..00000000 --- a/apps/mcp/src/server/tools/search-memory.test.ts +++ /dev/null @@ -1,93 +0,0 @@ -import { describe, expect, it, vi } from "vitest" -import * as searchMemory from "./search-memory" -import type { ToolDeps } from "./types" - -function registerSearch(client: { - search: (query: string) => Promise<{ - results: Array<{ - id: string - memory?: string - chunk?: string - similarity: number - title?: string - }> - total: number - timing: number - }> - getProfile?: () => Promise -}) { - let handler: - | ((args: { query: string; containerTag?: string }) => Promise) - | undefined - - searchMemory.register({ - server: { - registerTool: ( - _name: string, - _config: unknown, - registered: (args: { - query: string - containerTag?: string - }) => Promise, - ) => { - handler = registered - }, - }, - resolveContainerTag: async (tag?: string) => tag ?? "sm_project_default", - getClient: () => client, - errorResult: (error: unknown) => ({ - content: [ - { - type: "text" as const, - text: error instanceof Error ? error.message : "error", - }, - ], - isError: true, - }), - } as unknown as ToolDeps) - - if (!handler) throw new Error("searchMemory was not registered") - return handler -} - -describe("search_memory", () => { - it("returns matching memories without fetching or including profile", async () => { - const getProfile = vi.fn() - const handler = registerSearch({ - getProfile, - search: async () => ({ - results: [ - { - id: "mem_1", - memory: "User prefers dark mode", - similarity: 0.91, - }, - ], - total: 1, - timing: 12, - }), - }) - - const result = (await handler({ query: "theme preference" })) as { - content: Array<{ text: string }> - structuredContent: { - profile?: unknown - results: Array<{ text: string }> - } - } - - expect(getProfile).not.toHaveBeenCalled() - expect(result.content[0]?.text).toContain("## Matching memories") - expect(result.content[0]?.text).toContain("User prefers dark mode") - expect(result.content[0]?.text).not.toContain("## Profile") - expect(result.content[0]?.text).not.toContain("## Recent context") - expect(result.structuredContent.profile).toBeUndefined() - expect(result.structuredContent.results).toEqual([ - { - id: "mem_1", - text: "User prefers dark mode", - similarity: 0.91, - }, - ]) - }) -})