Skip to content

Commit 3f86226

Browse files
committed
style: apply vp formatter defaults and drop unused test variable
Reformat 7 files with the default vp fmt style (line-width 100, multi-line expression collapsing) — no logic changes. Also remove the unused consoleLogSpy variable in tests/setup-opencode.test.ts flagged by the linter; the spy is still installed and restored via vi.restoreAllMocks().
1 parent 87a41fb commit 3f86226

8 files changed

Lines changed: 17 additions & 22 deletions

File tree

‎.github/workflows/ci.yml‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,3 @@ jobs:
3333

3434
- name: Build
3535
run: pnpm build
36-

‎README.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ Equivalent env vars (lower priority than CLI flags):
8181
| `CC_API_BASE` | Upstream API base URL |
8282
| `CC_CLI_VERSION` | CLI version sent upstream |
8383
| `CC_UPSTREAM_TIMEOUT_MS` | Max ms for upstream to return response headers + first byte (default `600000` / 10 min). Bump for slow reasoning models |
84-
| `CC_IDLE_TIMEOUT_MS` | Max ms between consecutive stream chunks (default `120000` / 2 min). `0` disables — detects stalled upstreams |
84+
| `CC_IDLE_TIMEOUT_MS` | Max ms between consecutive stream chunks (default `120000` / 2 min). `0` disables — detects stalled upstreams |
8585
| `LOG_LEVEL` | Log level (`info`, `debug`, etc.) |
8686
| `CORS_ORIGIN` | `Access-Control-Allow-Origin` value. `*` by default; empty string disables CORS. Restrict before exposing on a network. |
8787

‎src/translate/openai.ts‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,10 @@ export class OpenAIStreamEncoder {
242242
* a new one on first sighting. Falls back to the upstream-provided index
243243
* (if any) so we don't fight a bridge that already numbers them.
244244
*/
245-
private resolveToolCallIndex(toolCallId: string | undefined, upstreamIndex: number | undefined): number {
245+
private resolveToolCallIndex(
246+
toolCallId: string | undefined,
247+
upstreamIndex: number | undefined,
248+
): number {
246249
if (toolCallId) {
247250
const known = this.toolCallIdToIndex.get(toolCallId);
248251
if (known !== undefined) return known;

‎src/upstream.ts‎

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -97,13 +97,7 @@ export async function sendToCC(
9797
options: UpstreamOptions,
9898
signal?: AbortSignal,
9999
): Promise<{ stream: NodeJS.ReadableStream }> {
100-
const {
101-
apiBase,
102-
apiKey,
103-
ccVersion,
104-
timeoutMs = 600_000,
105-
idleTimeoutMs = 120_000,
106-
} = options;
100+
const { apiBase, apiKey, ccVersion, timeoutMs = 600_000, idleTimeoutMs = 120_000 } = options;
107101

108102
const url = `${apiBase}/alpha/generate`;
109103
// CC's API is always streaming — force it on so the upstream stays a stream.
@@ -249,9 +243,7 @@ function nodeReaderToStream(
249243
if (idleMs <= 0) return;
250244
disarmIdle();
251245
idleTimer = setTimeout(() => {
252-
const err = new Error(
253-
`CC upstream idle timeout: no data for ${idleMs}ms`,
254-
);
246+
const err = new Error(`CC upstream idle timeout: no data for ${idleMs}ms`);
255247
err.name = "IdleTimeoutError";
256248
// Cancel the reader — pending read() will reject with this reason.
257249
const cancel = (reader as { cancel?: (reason?: unknown) => Promise<void> }).cancel;

‎tests/e2e.test.ts‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -266,9 +266,10 @@ describe("E2E: OpenAI /v1/chat/completions", () => {
266266
}
267267
// The error text should appear as delta.content (visible to the user)
268268
// and the stream should still terminate with finish_reason:"stop".
269-
const errorChunk = parsed.find((c) =>
270-
typeof c.choices?.[0]?.delta?.content === "string" &&
271-
c.choices[0].delta.content.includes("simulated TCP RST"),
269+
const errorChunk = parsed.find(
270+
(c) =>
271+
typeof c.choices?.[0]?.delta?.content === "string" &&
272+
c.choices[0].delta.content.includes("simulated TCP RST"),
272273
);
273274
expect(errorChunk).toBeDefined();
274275
const finishChunks = parsed.filter((c) => c.choices?.[0]?.finish_reason);

‎tests/setup-opencode.test.ts‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,10 @@ import fs from "node:fs";
44

55
describe("setupOpenCodeConfig", () => {
66
let written: string | null = null;
7-
let consoleLogSpy: ReturnType<typeof vi.spyOn>;
87

98
beforeEach(() => {
109
written = null;
11-
consoleLogSpy = vi.spyOn(console, "log").mockImplementation(() => {});
10+
vi.spyOn(console, "log").mockImplementation(() => {});
1211
vi.spyOn(fs, "existsSync").mockImplementation(() => false);
1312
vi.spyOn(fs, "mkdirSync").mockImplementation(() => undefined as unknown as string);
1413
vi.spyOn(fs, "writeFileSync").mockImplementation(((_path, data) => {

‎tests/translate.test.ts‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -440,7 +440,10 @@ describe("buildNonStreamingResponse", () => {
440440
it("merges tool-call-delta + tool-call with the same id into one entry", () => {
441441
const events: CCEvent[] = [
442442
{ type: "start", data: {} },
443-
{ type: "tool-call-delta", data: { toolCallId: "call_X", name: "search", arguments: '{"q":' } },
443+
{
444+
type: "tool-call-delta",
445+
data: { toolCallId: "call_X", name: "search", arguments: '{"q":' },
446+
},
444447
{ type: "tool-call-delta", data: { toolCallId: "call_X", arguments: '"hi"}' } },
445448
{ type: "tool-call", data: { toolCallId: "call_X", toolName: "search", input: { q: "hi" } } },
446449
{ type: "finish", data: { finishReason: "tool-call" } },

‎tests/upstream.test.ts‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -177,9 +177,7 @@ describe("sendToCC retry", () => {
177177
}
178178
bodyLines.push(JSON.stringify({ type: "finish", data: { finishReason: "stop" } }) + "\n");
179179

180-
const mock = vi.fn().mockResolvedValue(
181-
fakeResponse({ ok: true, status: 200, bodyLines }),
182-
);
180+
const mock = vi.fn().mockResolvedValue(fakeResponse({ ok: true, status: 200, bodyLines }));
183181
globalThis.fetch = mock as unknown as typeof fetch;
184182

185183
const { stream } = await sendToCC(sampleBody(), {

0 commit comments

Comments
 (0)