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
56 lines
1.1 KiB
TypeScript
56 lines
1.1 KiB
TypeScript
import { existsSync, readFileSync } from "fs";
|
|
import { join } from "path";
|
|
|
|
export interface SkillConfig {
|
|
ignorePatterns: string[];
|
|
smallPackageThreshold: number;
|
|
llmProvider: "openai" | "kimi" | "pi";
|
|
llmModel: string;
|
|
llmBaseUrl?: string;
|
|
contextBudget: number;
|
|
autoInjectPrompt: boolean;
|
|
}
|
|
|
|
export const DEFAULT_CONFIG: SkillConfig = {
|
|
ignorePatterns: [
|
|
"node_modules",
|
|
".git",
|
|
"dist",
|
|
"build",
|
|
"coverage",
|
|
".next",
|
|
".venv",
|
|
"__pycache__",
|
|
".DS_Store",
|
|
"*.log",
|
|
".pi-map.md",
|
|
".cache",
|
|
"tmp",
|
|
"temp",
|
|
".tmp",
|
|
".turbo",
|
|
".parcel-cache",
|
|
".eslintcache",
|
|
".prettiercache",
|
|
],
|
|
smallPackageThreshold: 10,
|
|
llmProvider: "openai",
|
|
llmModel: "gpt-4o-mini",
|
|
contextBudget: 4000,
|
|
autoInjectPrompt: true,
|
|
};
|
|
|
|
export function loadConfig(cwd: string = process.cwd()): SkillConfig {
|
|
const configPath = join(cwd, ".pi-project-map.json");
|
|
if (existsSync(configPath)) {
|
|
try {
|
|
const content = readFileSync(configPath, "utf8");
|
|
const userConfig = JSON.parse(content);
|
|
return { ...DEFAULT_CONFIG, ...userConfig };
|
|
} catch {
|
|
// Fall through to default
|
|
}
|
|
}
|
|
return DEFAULT_CONFIG;
|
|
}
|