69d3acda5d
- Add LLM client abstraction (src/llm-client.ts) with factory pattern - Add OpenAI-compatible external client (src/external-llm-client.ts) - Add Kimi.com client using Anthropic-based API (src/kimi-llm-client.ts) - Add Pi native LLM stub (src/pi-llm-client.ts) for future ExtensionAPI wiring - Add SHA-256 disk cache at ~/.cache/pi-project-map/ (src/llm-cache.ts) - Add parallel batching with p-limit, retry + exponential backoff (src/llm-batch.ts) - Rewrite llm-extract.ts to use real LLM calls with structured prompts - File-level: PURPOSE, DEPS, CONCEPTS - Package-level: ROLE, ARCH - Context truncation, 50KB skip, cache before LLM call - Wire CLI with --llm-provider, --llm-model, --llm-base-url flags - Update config.ts with llmProvider, llmBaseUrl fields - Update init.ts and patch.ts to accept optional LLMClient - Add sample project fixture for manual testing - Add tests: llm-cache (3), llm-batch (5), llm-integration (8 with real Kimi API), pi-extension (14 mocked) - All 56 tests pass
22 lines
726 B
TypeScript
22 lines
726 B
TypeScript
import { describe, it, expect } from "vitest";
|
|
import { validateEmail, validateNotEmpty, validateMinLength } from "../src/utils/validation.js";
|
|
|
|
describe("Validation utils", () => {
|
|
it("validates email format", () => {
|
|
expect(validateEmail("test@example.com")).toBe(true);
|
|
expect(validateEmail("invalid")).toBe(false);
|
|
expect(validateEmail("")).toBe(false);
|
|
});
|
|
|
|
it("checks non-empty strings", () => {
|
|
expect(validateNotEmpty("hello")).toBe(true);
|
|
expect(validateNotEmpty(" ")).toBe(false);
|
|
expect(validateNotEmpty("")).toBe(false);
|
|
});
|
|
|
|
it("checks minimum length", () => {
|
|
expect(validateMinLength("hello", 3)).toBe(true);
|
|
expect(validateMinLength("hi", 3)).toBe(false);
|
|
});
|
|
});
|