Skip to content

Commit 14a5b6f

Browse files
committed
chore: ensure test code is type-checked in packages/core
1 parent 384da08 commit 14a5b6f

16 files changed

+54
-47
lines changed

packages/core/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@
3030
},
3131
"scripts": {
3232
"prepublishOnly": "pnpm run build",
33-
"build": "tsc -p tsconfig.json",
34-
"typecheck": "tsc -p tsconfig.json --noEmit",
33+
"build": "tsc -p tsconfig.build.json",
34+
"typecheck": "tsc -p tsconfig.json",
3535
"test": "vitest run",
3636
"lint": "eslint src test",
3737
"generate:schema": "tsx scripts/generate-schema.ts"
@@ -52,4 +52,4 @@
5252
"unified": "^11.0.5",
5353
"zod": "^4.3.6"
5454
}
55-
}
55+
}

packages/core/test/chunk-cache.test.ts renamed to packages/core/src/test/chunk-cache.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ import { mkdtemp, rm } from "node:fs/promises";
22
import path from "node:path";
33
import os from "node:os";
44
import { afterEach, beforeEach, describe, expect, it } from "vitest";
5-
import { computeChunkFingerprint, loadChunksFromPreviousIndex } from "../src/chunk-cache.js";
6-
import { buildLanceDbIndex } from "../src/lancedb.js";
7-
import type { Chunk, ChunkingStrategy } from "../src/types.js";
5+
import { computeChunkFingerprint, loadChunksFromPreviousIndex } from "../chunk-cache.js";
6+
import { buildLanceDbIndex } from "../lancedb.js";
7+
import type { Chunk, ChunkingStrategy } from "../types.js";
88

99
function makeChunk(overrides: Partial<Chunk> = {}): Chunk {
1010
return {
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { describe, expect, it } from "vitest";
2-
import { buildChunks, DEFAULT_MAX_CHUNK_SIZE } from "../src/chunking.js";
2+
import { buildChunks, DEFAULT_MAX_CHUNK_SIZE } from "../chunking.js";
33

44
describe("buildChunks", () => {
55
it("creates deterministic chunk IDs and resolves duplicates", () => {
Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,6 @@
11
import { describe, it, expect } from "vitest";
2-
import {
3-
encodeCursor,
4-
decodeCursor,
5-
encodeSearchCursor,
6-
decodeSearchCursor,
7-
} from "../src/cursor.js";
8-
import type { CursorPayload } from "../src/types.js";
2+
import { encodeCursor, decodeCursor, encodeSearchCursor, decodeSearchCursor } from "../cursor.js";
3+
import type { CursorPayload } from "../types.js";
94

105
describe("cursor encode/decode", () => {
116
// ─── Round-trip tests ──────────────────────────────────────────
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { describe, expect, it } from "vitest";
2-
import { dedupKey } from "../src/search-common.js";
3-
import { InMemorySearchEngine } from "../src/search.js";
4-
import type { Chunk } from "../src/types.js";
2+
import { dedupKey } from "../search-common.js";
3+
import { InMemorySearchEngine } from "../search.js";
4+
import type { Chunk } from "../types.js";
55

66
describe("dedupKey", () => {
77
const getter = (metadata: Record<string, string>) => (key: string) => metadata[key] ?? "";

packages/core/test/embedding-cache.test.ts renamed to packages/core/src/test/embedding-cache.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ import {
77
embedChunksIncremental,
88
loadCache,
99
saveCache,
10-
} from "../src/embedding-cache.js";
11-
import { HashEmbeddingProvider, toEmbeddingInput } from "../src/embedding.js";
12-
import type { Chunk, EmbeddingConfig } from "../src/types.js";
10+
} from "../embedding-cache.js";
11+
import { HashEmbeddingProvider, toEmbeddingInput } from "../embedding.js";
12+
import type { Chunk, EmbeddingConfig } from "../types.js";
1313

1414
function makeChunk(overrides: Partial<Chunk> = {}): Chunk {
1515
return {
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import {
44
NoopEmbeddingProvider,
55
OpenAIEmbeddingProvider,
66
createEmbeddingProvider,
7-
} from "../src/embedding.js";
7+
} from "../embedding.js";
88

99
afterEach(() => {
1010
vi.restoreAllMocks();
@@ -295,7 +295,7 @@ describe("embedding providers", () => {
295295
// Instead, we'll rely on the fact that the provider builds JSONL deterministically,
296296
// so two providers with the same config and inputs produce the same SHA.
297297
// We'll build the expected SHA by constructing a second provider.
298-
const { sha256hex } = await import("../src/embedding.js");
298+
const { sha256hex } = await import("../embedding.js");
299299
// Build the JSONL the provider would create (access via same logic)
300300
const expectedJsonl = [
301301
JSON.stringify({

packages/core/test/integration.test.ts renamed to packages/core/src/test/integration.test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@ import { mkdtemp, rm } from "node:fs/promises";
33
import os from "node:os";
44
import path from "node:path";
55
import { afterEach, describe, expect, it } from "vitest";
6-
import { buildChunks } from "../src/chunking.js";
7-
import { buildLanceDbIndex, LanceDbSearchEngine } from "../src/lancedb.js";
8-
import { parseManifest, resolveFileConfig } from "../src/manifest.js";
9-
import type { Chunk, Manifest } from "../src/types.js";
6+
import { buildChunks } from "../chunking.js";
7+
import { buildLanceDbIndex, LanceDbSearchEngine } from "../lancedb.js";
8+
import { parseManifest, resolveFileConfig } from "../manifest.js";
9+
import type { Chunk, Manifest } from "../types.js";
1010

1111
const FIXTURES_DIR = path.resolve(import.meta.dirname, "../../../tests/fixtures/docs");
1212

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import { mkdtemp, rm } from "node:fs/promises";
22
import os from "node:os";
33
import path from "node:path";
4-
import { afterEach, describe, expect, it } from "vitest";
5-
import { buildLanceDbIndex, LanceDbSearchEngine } from "../src/lancedb.js";
6-
import type { Chunk, EmbeddingProvider } from "../src/types.js";
7-
import { buildChunks } from "../src/chunking.js";
4+
import { afterEach, describe, expect, it, assert } from "vitest";
5+
import { buildLanceDbIndex, LanceDbSearchEngine } from "../lancedb.js";
6+
import type { Chunk, EmbeddingProvider } from "../types.js";
7+
import { buildChunks } from "../chunking.js";
88

99
const tempDirs: string[] = [];
1010

@@ -234,6 +234,9 @@ describe("LanceDbSearchEngine", () => {
234234
async embed(): Promise<number[][]> {
235235
return [[0, 1, 0]];
236236
},
237+
238+
configFingerprint: "",
239+
costPerMillionTokens: 0,
237240
};
238241

239242
const engine = await LanceDbSearchEngine.open({
@@ -286,6 +289,8 @@ describe("LanceDbSearchEngine", () => {
286289
async embed(): Promise<number[][]> {
287290
throw new Error("provider unavailable");
288291
},
292+
configFingerprint: "",
293+
costPerMillionTokens: 0,
289294
};
290295

291296
const engine = await LanceDbSearchEngine.open({
@@ -484,6 +489,7 @@ third
484489
metadataKeys: [],
485490
});
486491

492+
assert(chunks[1]?.chunk_id);
487493
const result = await engine.getDoc({
488494
chunk_id: chunks[1].chunk_id,
489495
context: -1,
@@ -554,6 +560,7 @@ Greetings friend!
554560
metadataKeys: [],
555561
});
556562

563+
assert(target[1]?.chunk_id);
557564
const result = await engine.getDoc({
558565
chunk_id: target[1].chunk_id,
559566
context: -1,

packages/core/test/manifest-schema.test.ts renamed to packages/core/src/test/manifest-schema.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { resolve, dirname } from "node:path";
33
import { fileURLToPath } from "node:url";
44
import { describe, expect, it } from "vitest";
55
import { z } from "zod";
6-
import { ManifestSchema } from "../src/manifest-schema.js";
6+
import { ManifestSchema } from "../manifest-schema.js";
77

88
const __dirname = dirname(fileURLToPath(import.meta.url));
99
const schemaPath = resolve(__dirname, "../../../schemas/docs-mcp.schema.json");

0 commit comments

Comments
 (0)