mirror of
https://github.com/supermemoryai/supermemory.git
synced 2026-08-28 05:25:33 +00:00
fix(tools): resolve lint and format errors
- Replace `as any` with typed assertion in claude-memory.ts - Apply Biome formatting fixes Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
parent
d21d661380
commit
7153801f11
4 changed files with 28 additions and 23 deletions
|
|
@ -39,7 +39,7 @@ const NEIGHBOUR_DOCUMENT = {
|
|||
content: "backup stuff",
|
||||
}
|
||||
|
||||
function mockDocuments(documents: typeof FILE_DOCUMENT[]) {
|
||||
function mockDocuments(documents: (typeof FILE_DOCUMENT)[]) {
|
||||
documentsListMock.mockResolvedValue({
|
||||
memories: documents.map((document) => ({
|
||||
id: document.id,
|
||||
|
|
@ -191,20 +191,22 @@ describe("ClaudeMemoryTool str_replace replacement literalness", () => {
|
|||
tool = new ClaudeMemoryTool("test-api-key")
|
||||
})
|
||||
|
||||
it.each(["$&", "$'", "$`", "$$"])(
|
||||
"stores %s literally instead of expanding it as a replacement pattern",
|
||||
async (dollarSequence) => {
|
||||
const result = await tool.handleCommand({
|
||||
command: "str_replace",
|
||||
path: FILE_PATH,
|
||||
old_str: "line3",
|
||||
new_str: `price is ${dollarSequence} today`,
|
||||
})
|
||||
it.each([
|
||||
"$&",
|
||||
"$'",
|
||||
"$`",
|
||||
"$$",
|
||||
])("stores %s literally instead of expanding it as a replacement pattern", async (dollarSequence) => {
|
||||
const result = await tool.handleCommand({
|
||||
command: "str_replace",
|
||||
path: FILE_PATH,
|
||||
old_str: "line3",
|
||||
new_str: `price is ${dollarSequence} today`,
|
||||
})
|
||||
|
||||
expect(result.success).toBe(true)
|
||||
expect(addMock).toHaveBeenCalledTimes(1)
|
||||
const stored = addMock.mock.calls[0]?.[0]?.content as string
|
||||
expect(stored).toContain(`price is ${dollarSequence} today`)
|
||||
},
|
||||
)
|
||||
expect(result.success).toBe(true)
|
||||
expect(addMock).toHaveBeenCalledTimes(1)
|
||||
const stored = addMock.mock.calls[0]?.[0]?.content as string
|
||||
expect(stored).toContain(`price is ${dollarSequence} today`)
|
||||
})
|
||||
})
|
||||
|
|
|
|||
|
|
@ -150,7 +150,7 @@ export class ClaudeMemoryTool {
|
|||
default:
|
||||
return {
|
||||
success: false,
|
||||
error: `Unknown command: ${(command as any).command}`,
|
||||
error: `Unknown command: ${(command as { command: string }).command}`,
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
|
|
|
|||
|
|
@ -15,9 +15,7 @@ import type { SupermemoryToolsConfig } from "../types"
|
|||
*/
|
||||
export interface MemorySearchResult {
|
||||
success: boolean
|
||||
results?: Awaited<
|
||||
ReturnType<Supermemory["search"]["documents"]>
|
||||
>["results"]
|
||||
results?: Awaited<ReturnType<Supermemory["search"]["documents"]>>["results"]
|
||||
count?: number
|
||||
error?: string
|
||||
}
|
||||
|
|
|
|||
|
|
@ -47,7 +47,8 @@ export const PARAMETER_DESCRIPTIONS = {
|
|||
"Profile-memory ID from query-backed getProfile searchResults. Soft-forgets one learned fact; document and chunk IDs from searchMemories are not valid.",
|
||||
memoryContent:
|
||||
"Exact text of the profile memory to forget (alternative to memoryId). Must match precisely; if unsure, query getProfile and use a search-result memory ID.",
|
||||
reason: "Optional reason recorded when forgetting (e.g. outdated, user correction)",
|
||||
reason:
|
||||
"Optional reason recorded when forgetting (e.g. outdated, user correction)",
|
||||
} as const
|
||||
|
||||
// Default values
|
||||
|
|
@ -77,7 +78,9 @@ export function getContainerTags(config?: {
|
|||
}
|
||||
if (config?.projectId !== undefined) {
|
||||
if (config.projectId.trim() === "") {
|
||||
throw new Error("Supermemory tools config requires a non-empty projectId.")
|
||||
throw new Error(
|
||||
"Supermemory tools config requires a non-empty projectId.",
|
||||
)
|
||||
}
|
||||
return [`${CONTAINER_TAG_CONSTANTS.projectPrefix}${config.projectId}`]
|
||||
}
|
||||
|
|
@ -104,7 +107,9 @@ export async function deleteDocumentById(
|
|||
const response = await client.documents.deleteBulk({ ids: [documentId] })
|
||||
if (response.success && response.deletedCount === 1) return
|
||||
|
||||
const detail = response.errors?.find((error) => error.id === documentId)?.error
|
||||
const detail = response.errors?.find(
|
||||
(error) => error.id === documentId,
|
||||
)?.error
|
||||
throw new Error(
|
||||
detail
|
||||
? `Failed to delete document ${documentId}: ${detail}`
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue