perf: optimized ai providers with lazy-loading imports and cached init

- Consolidated AI provider imports through register-builtins and moved Gemini/Antigravity header helpers to a shared module.
- Added lazy loading for heavy providers and SDK-backed modules with cached initialization to trim startup cost.
- Converted markdown conversion helpers to async and awaited htmlToBasicMarkdown in affected scraper and kernel output paths.
- Parsed bundled agent definitions on-demand and moved BrowserTool prompt rendering behind a memoized getter.
- Added cached validation/error handling paths by replacing AJV runtime checks with Value.Check and trimming validation error output.
This commit is contained in:
can1357
2026-05-01 18:54:21 +02:00
parent 74d71e8807
commit ca84ee760d
43 changed files with 419 additions and 322 deletions
+4 -3
View File
@@ -25,7 +25,8 @@ import type { CommitCommandArgs, ConventionalAnalysis } from "./types";
const SUMMARY_MAX_CHARS = 72;
const RECENT_COMMITS_COUNT = 8;
const TYPES_DESCRIPTION = prompt.render(typesDescriptionPrompt);
let _typesDescription: string | undefined;
const TYPES_DESCRIPTION = (): string => (_typesDescription ??= prompt.render(typesDescriptionPrompt));
/**
* Execute the omp commit pipeline for staged changes.
@@ -176,7 +177,7 @@ async function generateAnalysis(input: {
diff: input.diff,
stat: input.stat,
scopeCandidates: input.scopeCandidates,
typesDescription: TYPES_DESCRIPTION,
typesDescription: TYPES_DESCRIPTION(),
settings: {
enabled: input.commitSettings.mapReduceEnabled,
minFiles: input.commitSettings.mapReduceMinFiles,
@@ -193,7 +194,7 @@ async function generateAnalysis(input: {
thinkingLevel: input.primaryThinkingLevel,
contextFiles: input.contextFiles,
userContext: input.userContext,
typesDescription: TYPES_DESCRIPTION,
typesDescription: TYPES_DESCRIPTION(),
recentCommits: input.recentCommits,
scopeCandidates: input.scopeCandidates,
stat: input.stat,