Fix discover, improve LLM heuristics, add integration tests

- discover.ts: Fix ignore package path handling for root '.' directories,
  add .pi-map.md to default ignore list
- llm-extract.ts: Fix export regex to only match line-start exports and
  handle 'export async function', fix root package role to 'Project root'
- init.ts: Minor cleanup
- .gitignore: Add .pi-map.md
- tests: 6 integration tests covering init, patch (small/large packages),
  validate (missing, orphaned, stale-signature detection)

All 14 tests pass. TypeScript compiles clean.
This commit is contained in:
2026-06-09 19:14:41 +02:00
parent d311c8fb3c
commit 3dbb3cb7b2
9 changed files with 733 additions and 34 deletions
+16 -4
View File
@@ -1,5 +1,9 @@
import { describe, it, expect } from "vitest";
import { renderPackageMap, parsePackageMap, type PackageMapData } from "../src/format.js";
import {
renderPackageMap,
parsePackageMap,
type PackageMapData,
} from "../src/format.js";
const sampleData: PackageMapData = {
path: "pkg/auth",
@@ -34,7 +38,9 @@ describe("format", () => {
expect(output).toContain("# pkg/auth");
expect(output).toContain("## role");
expect(output).toContain("## files");
expect(output).toContain("- tokens.ts | JWT gen/val | exp: issueToken, verifyToken, refreshToken | dep: crypto/hmac, db/sessions");
expect(output).toContain(
"- tokens.ts | JWT gen/val | exp: issueToken, verifyToken, refreshToken | dep: crypto/hmac, db/sessions",
);
expect(output).toContain("## arch");
expect(output).toContain("## dirty");
expect(output).toContain("-");
@@ -53,7 +59,11 @@ describe("format", () => {
const tokens = parsed.files.find((f) => f.name === "tokens.ts");
expect(tokens).toBeDefined();
expect(tokens!.purpose).toBe("JWT gen/val");
expect(tokens!.exports).toEqual(["issueToken", "verifyToken", "refreshToken"]);
expect(tokens!.exports).toEqual([
"issueToken",
"verifyToken",
"refreshToken",
]);
expect(tokens!.deps).toEqual(["crypto/hmac", "db/sessions"]);
});
@@ -61,7 +71,9 @@ describe("format", () => {
const data: PackageMapData = {
path: "pkg/utils",
role: "Utilities",
files: [{ name: "helpers.ts", purpose: "Helpers", exports: [], deps: [] }],
files: [
{ name: "helpers.ts", purpose: "Helpers", exports: [], deps: [] },
],
arch: "Shared helpers",
dirty: "2024-01-01: patched",
};