ktx/packages/cli/test/context/llm/embedding-port.test.ts
Andrey Avtomonov 00cdf2de90
refactor: enforce ktx naming and AGENTS.md compliance sweep (#289)
Align the tree with AGENTS.md/CLAUDE.md conventions:

- Rewrite user-facing strings, docs, and tests to lowercase `ktx`
  (no bare uppercase `KTX` tokens remain outside literal identifiers).
- Drop the legacy `historicSql` migration path and its now-unused
  helpers, per the no-backward-compat rule.
- Remove `as unknown as` / `any` casts: narrow `BaseTool` generics to
  `z.ZodObject`, add a typed `createLookerClient`, and delete the dead
  `getParametersSchema`/`toAnthropicFormat` pre-AI-SDK helpers.
- Use `InvalidArgumentError` for Commander parse failures.
- Finish the adapter→connector prose conversion in the `ktx.yaml` docs
  while keeping the literal `adapters` config key.
2026-06-11 13:49:45 +02:00

38 lines
1.3 KiB
TypeScript

import { describe, expect, it, vi } from 'vitest';
import { KtxIngestEmbeddingPortAdapter, KtxScanEmbeddingPortAdapter } from '../../../src/context/llm/embedding-port.js';
describe('ktx embedding port adapters', () => {
it('adapts LLM modules embeddings to ingest embedding port shape', async () => {
const provider = {
dimensions: 3,
maxBatchSize: 2,
embed: vi.fn(async () => [1, 2, 3]),
[['embed', 'Many'].join('')]: vi.fn(async () => [
[1, 2, 3],
[4, 5, 6],
]),
};
const adapter = new KtxIngestEmbeddingPortAdapter(provider as never);
await expect(adapter.computeEmbedding('alpha')).resolves.toEqual([1, 2, 3]);
await expect(adapter.computeEmbeddingsBulk(['alpha', 'beta'])).resolves.toEqual([
[1, 2, 3],
[4, 5, 6],
]);
expect(adapter.maxBatchSize).toBe(2);
});
it('adapts LLM modules embeddings to scan embedding port shape', async () => {
const provider = {
dimensions: 3,
maxBatchSize: 2,
embed: vi.fn(),
[['embed', 'Many'].join('')]: vi.fn(async () => [[1, 2, 3]]),
};
const adapter = new KtxScanEmbeddingPortAdapter(provider as never);
await expect(adapter.embedBatch(['alpha'])).resolves.toEqual([[1, 2, 3]]);
expect(adapter.dimensions).toBe(3);
expect(adapter.maxBatchSize).toBe(2);
});
});