diff --git a/packages/ai/test/github-copilot-anthropic-auth.test.ts b/packages/ai/test/github-copilot-anthropic-auth.test.ts index e3ff73992..880436951 100644 --- a/packages/ai/test/github-copilot-anthropic-auth.test.ts +++ b/packages/ai/test/github-copilot-anthropic-auth.test.ts @@ -36,7 +36,11 @@ const testContext = { messages: [{ role: "user", content: "hello", timestamp: Date.now() }], } as const; -function getRequestHeader(input: string | URL | Request, init: RequestInit | undefined, headerName: string): string | null { +function getRequestHeader( + input: string | URL | Request, + init: RequestInit | undefined, + headerName: string, +): string | null { if (input instanceof Request) { return input.headers.get(headerName); } @@ -137,13 +141,10 @@ describe("Anthropic Copilot auth config", () => { const requestedInitiators: Array = []; global.fetch = vi.fn(async (input: string | URL | Request, init?: RequestInit) => { requestedInitiators.push(getRequestHeader(input, init, "X-Initiator")); - return new Response( - JSON.stringify({ error: { type: "authentication_error", message: "Unauthorized" } }), - { - status: 401, - headers: { "Content-Type": "application/json" }, - }, - ); + return new Response(JSON.stringify({ error: { type: "authentication_error", message: "Unauthorized" } }), { + status: 401, + headers: { "Content-Type": "application/json" }, + }); }) as unknown as typeof fetch; const model = makeCopilotClaudeModel(); diff --git a/packages/ai/test/github-copilot-openai-base-url.test.ts b/packages/ai/test/github-copilot-openai-base-url.test.ts index fff282737..afdc92a99 100644 --- a/packages/ai/test/github-copilot-openai-base-url.test.ts +++ b/packages/ai/test/github-copilot-openai-base-url.test.ts @@ -22,7 +22,11 @@ function getRequestUrl(input: string | URL | Request): string { return typeof input === "string" ? input : input.toString(); } -function getRequestHeader(input: string | URL | Request, init: RequestInit | undefined, headerName: string): string | null { +function getRequestHeader( + input: string | URL | Request, + init: RequestInit | undefined, + headerName: string, +): string | null { if (input instanceof Request) { return input.headers.get(headerName); } diff --git a/packages/coding-agent/src/memories/index.ts b/packages/coding-agent/src/memories/index.ts index 12833ff9b..625d38c1b 100644 --- a/packages/coding-agent/src/memories/index.ts +++ b/packages/coding-agent/src/memories/index.ts @@ -288,13 +288,13 @@ async function runPhase1(options: { } if (result.kind === "no_output") { - markStage1SucceededNoOutput(db, { - threadId: claim.threadId, - ownershipToken: claim.ownershipToken, - sourceUpdatedAt: claim.sourceUpdatedAt, - nowSec: unixNow(), - cwd: claim.cwd, - }); + markStage1SucceededNoOutput(db, { + threadId: claim.threadId, + ownershipToken: claim.ownershipToken, + sourceUpdatedAt: claim.sourceUpdatedAt, + nowSec: unixNow(), + cwd: claim.cwd, + }); stats.succeededNoOutput += 1; return; } diff --git a/packages/coding-agent/src/prompts/system/btw-user.md b/packages/coding-agent/src/prompts/system/btw-user.md index 857614841..902326373 100644 --- a/packages/coding-agent/src/prompts/system/btw-user.md +++ b/packages/coding-agent/src/prompts/system/btw-user.md @@ -5,4 +5,4 @@ Do not use tools. Do not ask follow-up questions. Question: {{question}} - + \ No newline at end of file diff --git a/packages/coding-agent/src/session/session-manager.ts b/packages/coding-agent/src/session/session-manager.ts index fe955b9e5..aa33dff3e 100644 --- a/packages/coding-agent/src/session/session-manager.ts +++ b/packages/coding-agent/src/session/session-manager.ts @@ -23,7 +23,16 @@ import { toError, } from "@oh-my-pi/pi-utils"; import { ArtifactManager } from "./artifacts"; -import { type BlobPutResult, BlobStore, externalizeImageData, externalizeImageDataUrl, isBlobRef, isImageDataUrl, resolveImageData, resolveImageDataUrl } from "./blob-store"; +import { + type BlobPutResult, + BlobStore, + externalizeImageData, + externalizeImageDataUrl, + isBlobRef, + isImageDataUrl, + resolveImageData, + resolveImageDataUrl, +} from "./blob-store"; import { type BashExecutionMessage, type CustomMessage, @@ -988,7 +997,12 @@ async function truncateForPersistence(obj: unknown, blobStore: BlobStore, key?: const contentEntry = entries.find(([childKey]) => childKey === "content"); const lineCountEntry = entries.find(([childKey]) => childKey === "lineCount"); - if (contentEntry && typeof contentEntry[1] === "string" && lineCountEntry && typeof lineCountEntry[1] === "number") { + if ( + contentEntry && + typeof contentEntry[1] === "string" && + lineCountEntry && + typeof lineCountEntry[1] === "number" + ) { const content = contentEntry[1]; const updatedEntries = entries.map(([childKey, value]) => childKey === "lineCount" ? ([childKey, content.split("\n").length] as const) : ([childKey, value] as const), diff --git a/packages/coding-agent/test/agent-session-auto-compaction-x-initiator.test.ts b/packages/coding-agent/test/agent-session-auto-compaction-x-initiator.test.ts index ea179bc73..fbb8bd4dc 100644 --- a/packages/coding-agent/test/agent-session-auto-compaction-x-initiator.test.ts +++ b/packages/coding-agent/test/agent-session-auto-compaction-x-initiator.test.ts @@ -5,8 +5,13 @@ import { TempDir } from "@oh-my-pi/pi-utils"; const compactMock = vi.fn(); mock.module("../src/session/compaction", () => ({ - calculateContextTokens: (usage: { totalTokens?: number; input: number; output: number; cacheRead: number; cacheWrite: number }) => - usage.totalTokens || usage.input + usage.output + usage.cacheRead + usage.cacheWrite, + calculateContextTokens: (usage: { + totalTokens?: number; + input: number; + output: number; + cacheRead: number; + cacheWrite: number; + }) => usage.totalTokens || usage.input + usage.output + usage.cacheRead + usage.cacheWrite, calculatePromptTokens: () => 0, collectEntriesForBranchSummary: () => [], compact: compactMock, @@ -127,10 +132,13 @@ describe("AgentSession compaction Copilot initiator attribution", async () => { expect(model.headers?.["X-Initiator"]).toBeUndefined(); } - async function triggerAutoCompaction(session: { - agent: { emitExternalEvent: (event: unknown) => void }; - subscribe: (listener: (event: { type: string }) => void) => () => void; - }, model: { api: string; provider: string; id: string; contextWindow: number }) { + async function triggerAutoCompaction( + session: { + agent: { emitExternalEvent: (event: unknown) => void }; + subscribe: (listener: (event: { type: string }) => void) => () => void; + }, + model: { api: string; provider: string; id: string; contextWindow: number }, + ) { const { promise, resolve } = Promise.withResolvers(); const unsubscribe = session.subscribe(event => { if (event.type === "auto_compaction_end") { @@ -169,7 +177,11 @@ describe("AgentSession compaction Copilot initiator attribution", async () => { await session.compact(); expect(compactMock).toHaveBeenCalledTimes(1); - const compactModel = compactMock.mock.calls[0]?.[1] as { provider: string; id: string; headers?: Record }; + const compactModel = compactMock.mock.calls[0]?.[1] as { + provider: string; + id: string; + headers?: Record; + }; const compactOptions = compactMock.mock.calls[0]?.[5] as { initiatorOverride?: string } | undefined; expect(compactModel.provider).toBe("github-copilot"); expect(compactModel.id).toBe(model.id); @@ -183,7 +195,11 @@ describe("AgentSession compaction Copilot initiator attribution", async () => { await triggerAutoCompaction(session, model); expect(compactMock).toHaveBeenCalledTimes(1); - const compactModel = compactMock.mock.calls[0]?.[1] as { provider: string; id: string; headers?: Record }; + const compactModel = compactMock.mock.calls[0]?.[1] as { + provider: string; + id: string; + headers?: Record; + }; const compactOptions = compactMock.mock.calls[0]?.[5] as { initiatorOverride?: string } | undefined; expect(compactModel.provider).toBe("github-copilot"); expect(compactModel.id).toBe(model.id); @@ -197,7 +213,11 @@ describe("AgentSession compaction Copilot initiator attribution", async () => { await session.compact(); expect(compactMock).toHaveBeenCalledTimes(1); - const compactModel = compactMock.mock.calls[0]?.[1] as { provider: string; id: string; headers?: Record }; + const compactModel = compactMock.mock.calls[0]?.[1] as { + provider: string; + id: string; + headers?: Record; + }; const compactOptions = compactMock.mock.calls[0]?.[5] as { initiatorOverride?: string } | undefined; expect(compactModel.provider).toBe("github-copilot"); expect(compactModel.id).toBe(model.id); @@ -211,11 +231,15 @@ describe("AgentSession compaction Copilot initiator attribution", async () => { await triggerAutoCompaction(session, model); expect(compactMock).toHaveBeenCalledTimes(1); - const compactModel = compactMock.mock.calls[0]?.[1] as { provider: string; id: string; headers?: Record }; + const compactModel = compactMock.mock.calls[0]?.[1] as { + provider: string; + id: string; + headers?: Record; + }; const compactOptions = compactMock.mock.calls[0]?.[5] as { initiatorOverride?: string } | undefined; expect(compactModel.provider).toBe("github-copilot"); expect(compactModel.id).toBe(model.id); expectNoForcedCopilotHeader(compactModel); expect(compactOptions?.initiatorOverride).toBe("agent"); }); -}); \ No newline at end of file +}); diff --git a/packages/coding-agent/test/memories/isolation.test.ts b/packages/coding-agent/test/memories/isolation.test.ts index c9d6ba63e..77869a6f2 100644 --- a/packages/coding-agent/test/memories/isolation.test.ts +++ b/packages/coding-agent/test/memories/isolation.test.ts @@ -26,12 +26,8 @@ describe("memory project isolation", () => { ]); // Insert stage1 outputs directly (bypassing job machinery) - db.run( - "INSERT INTO stage1_outputs VALUES ('thread-a', 1000, 'alpha raw memory', 'alpha summary', null, 999)", - ); - db.run( - "INSERT INTO stage1_outputs VALUES ('thread-b', 1001, 'beta raw memory', 'beta summary', null, 999)", - ); + db.run("INSERT INTO stage1_outputs VALUES ('thread-a', 1000, 'alpha raw memory', 'alpha summary', null, 999)"); + db.run("INSERT INTO stage1_outputs VALUES ('thread-b', 1001, 'beta raw memory', 'beta summary', null, 999)"); const aOutputs = listStage1OutputsForGlobal(db, 100, CWD_A); const bOutputs = listStage1OutputsForGlobal(db, 100, CWD_B); diff --git a/packages/coding-agent/test/session-manager/signature-persistence.test.ts b/packages/coding-agent/test/session-manager/signature-persistence.test.ts index e2ba1b6e4..6c49c8edb 100644 --- a/packages/coding-agent/test/session-manager/signature-persistence.test.ts +++ b/packages/coding-agent/test/session-manager/signature-persistence.test.ts @@ -1,6 +1,6 @@ +import { describe, expect, it } from "bun:test"; import * as fs from "node:fs/promises"; import * as path from "node:path"; -import { describe, expect, it } from "bun:test"; import type { AssistantMessage } from "@oh-my-pi/pi-ai"; import { SessionManager, type SessionMessageEntry } from "@oh-my-pi/pi-coding-agent/session/session-manager"; import { getBlobsDir, TempDir } from "@oh-my-pi/pi-utils";