dbde651a2a
- Upgrade tree-sitter to 0.22.4 with compatible grammar versions - Add Python support via tree-sitter-python@0.23.6 - Add Go support via tree-sitter-go@0.23.4 - Extract class hierarchies with method signatures (params, returns) - Extract call graphs including external library calls - Extract exception raises (ValueError, Error, etc) - Extract top-level functions with full signatures - Encode rich AST data into compact markdown format: class:Name, method:name(params)→return, call:..., raise:... - Deduplicate nested call chains (db.query vs db.query().where()) - Filter out simple export names when rich func/class entries exist - All 55 tests passing
45 lines
1.2 KiB
TypeScript
45 lines
1.2 KiB
TypeScript
import { describe, it, expect, beforeEach, afterEach } from "vitest";
|
|
import { getCached, setCached } from "../src/llm-cache.js";
|
|
import { existsSync, unlinkSync } from "fs";
|
|
import { join } from "path";
|
|
import { tmpdir } from "os";
|
|
|
|
const TEST_CACHE_DIR = join(tmpdir(), "pi-project-map-test-cache");
|
|
const TEST_CACHE_FILE = join(TEST_CACHE_DIR, "llm-cache.json");
|
|
|
|
describe("llm-cache", () => {
|
|
beforeEach(() => {
|
|
if (existsSync(TEST_CACHE_FILE)) {
|
|
unlinkSync(TEST_CACHE_FILE);
|
|
}
|
|
});
|
|
|
|
afterEach(() => {
|
|
if (existsSync(TEST_CACHE_FILE)) {
|
|
unlinkSync(TEST_CACHE_FILE);
|
|
}
|
|
});
|
|
|
|
it("returns undefined for missing entries", () => {
|
|
const result = getCached("nonexistent-hash", TEST_CACHE_DIR);
|
|
expect(result).toBeUndefined();
|
|
});
|
|
|
|
it("stores and retrieves cached results", () => {
|
|
setCached(
|
|
"abc123",
|
|
"PURPOSE: test\nDEPS: none\nCONCEPTS: none",
|
|
TEST_CACHE_DIR,
|
|
);
|
|
const result = getCached("abc123", TEST_CACHE_DIR);
|
|
expect(result).toBe("PURPOSE: test\nDEPS: none\nCONCEPTS: none");
|
|
});
|
|
|
|
it("overwrites existing entries", () => {
|
|
setCached("abc123", "old", TEST_CACHE_DIR);
|
|
setCached("abc123", "new", TEST_CACHE_DIR);
|
|
const result = getCached("abc123", TEST_CACHE_DIR);
|
|
expect(result).toBe("new");
|
|
});
|
|
});
|