@pranavraut033/ats-checker 1.2.0 → 1.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +105 -11
- package/dist/chunk-ZJ5E4H7Z.mjs +446 -0
- package/dist/chunk-ZJ5E4H7Z.mjs.map +1 -0
- package/dist/{index.js → index.cjs} +594 -94
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.mts +4 -259
- package/dist/index.d.ts +4 -259
- package/dist/index.mjs +360 -301
- package/dist/index.mjs.map +1 -1
- package/dist/lang/de/index.cjs +70 -0
- package/dist/lang/de/index.cjs.map +1 -0
- package/dist/lang/de/index.d.mts +16 -0
- package/dist/lang/de/index.d.ts +16 -0
- package/dist/lang/de/index.mjs +65 -0
- package/dist/lang/de/index.mjs.map +1 -0
- package/dist/lang/en/index.cjs +212 -0
- package/dist/lang/en/index.cjs.map +1 -0
- package/dist/lang/en/index.d.mts +5 -0
- package/dist/lang/en/index.d.ts +5 -0
- package/dist/lang/en/index.mjs +9 -0
- package/dist/lang/en/index.mjs.map +1 -0
- package/dist/pdf/{index.js → index.cjs} +13 -4
- package/dist/pdf/index.cjs.map +1 -0
- package/dist/pdf/index.d.mts +15 -2
- package/dist/pdf/index.d.ts +15 -2
- package/dist/pdf/index.mjs +11 -2
- package/dist/pdf/index.mjs.map +1 -1
- package/dist/scoring-BCShrnki.d.mts +319 -0
- package/dist/scoring-BCShrnki.d.ts +319 -0
- package/package.json +13 -1
- package/dist/index.js.map +0 -1
- package/dist/pdf/index.js.map +0 -1
package/dist/pdf/index.d.mts
CHANGED
|
@@ -1,3 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Caller-supplied OCR implementation, invoked only when the PDF's text layer
|
|
3
|
+
* comes back too short to be useful (scanned/image PDFs). The caller owns
|
|
4
|
+
* the actual OCR engine and dependency — this library never bundles one.
|
|
5
|
+
*/
|
|
6
|
+
type OCRClient = (data: Uint8Array) => Promise<string>;
|
|
7
|
+
interface ExtractTextOptions {
|
|
8
|
+
/** Called with the raw PDF bytes when text-layer extraction is too short. */
|
|
9
|
+
ocrFallback?: OCRClient;
|
|
10
|
+
/** Threshold (trimmed char count) below which ocrFallback is tried. Default 100, matching resume.parser.ts's scanned-PDF warning. */
|
|
11
|
+
minTextLength?: number;
|
|
12
|
+
}
|
|
1
13
|
/**
|
|
2
14
|
* Extract plain text from a PDF buffer.
|
|
3
15
|
*
|
|
@@ -5,8 +17,9 @@
|
|
|
5
17
|
* npm install pdfjs-dist
|
|
6
18
|
*
|
|
7
19
|
* @param data - Raw PDF bytes as Uint8Array or ArrayBuffer
|
|
20
|
+
* @param options - Optional OCR fallback for scanned/image PDFs
|
|
8
21
|
* @returns Extracted text, ready to pass as `resumeText` to analyzeResume
|
|
9
22
|
*/
|
|
10
|
-
declare function extractTextFromPDF(data: Uint8Array | ArrayBuffer): Promise<string>;
|
|
23
|
+
declare function extractTextFromPDF(data: Uint8Array | ArrayBuffer, options?: ExtractTextOptions): Promise<string>;
|
|
11
24
|
|
|
12
|
-
export { extractTextFromPDF };
|
|
25
|
+
export { type ExtractTextOptions, type OCRClient, extractTextFromPDF };
|
package/dist/pdf/index.d.ts
CHANGED
|
@@ -1,3 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Caller-supplied OCR implementation, invoked only when the PDF's text layer
|
|
3
|
+
* comes back too short to be useful (scanned/image PDFs). The caller owns
|
|
4
|
+
* the actual OCR engine and dependency — this library never bundles one.
|
|
5
|
+
*/
|
|
6
|
+
type OCRClient = (data: Uint8Array) => Promise<string>;
|
|
7
|
+
interface ExtractTextOptions {
|
|
8
|
+
/** Called with the raw PDF bytes when text-layer extraction is too short. */
|
|
9
|
+
ocrFallback?: OCRClient;
|
|
10
|
+
/** Threshold (trimmed char count) below which ocrFallback is tried. Default 100, matching resume.parser.ts's scanned-PDF warning. */
|
|
11
|
+
minTextLength?: number;
|
|
12
|
+
}
|
|
1
13
|
/**
|
|
2
14
|
* Extract plain text from a PDF buffer.
|
|
3
15
|
*
|
|
@@ -5,8 +17,9 @@
|
|
|
5
17
|
* npm install pdfjs-dist
|
|
6
18
|
*
|
|
7
19
|
* @param data - Raw PDF bytes as Uint8Array or ArrayBuffer
|
|
20
|
+
* @param options - Optional OCR fallback for scanned/image PDFs
|
|
8
21
|
* @returns Extracted text, ready to pass as `resumeText` to analyzeResume
|
|
9
22
|
*/
|
|
10
|
-
declare function extractTextFromPDF(data: Uint8Array | ArrayBuffer): Promise<string>;
|
|
23
|
+
declare function extractTextFromPDF(data: Uint8Array | ArrayBuffer, options?: ExtractTextOptions): Promise<string>;
|
|
11
24
|
|
|
12
|
-
export { extractTextFromPDF };
|
|
25
|
+
export { type ExtractTextOptions, type OCRClient, extractTextFromPDF };
|
package/dist/pdf/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// src/pdf/index.ts
|
|
2
|
-
async function extractTextFromPDF(data) {
|
|
2
|
+
async function extractTextFromPDF(data, options) {
|
|
3
3
|
let pdfjsLib;
|
|
4
4
|
try {
|
|
5
5
|
pdfjsLib = await import('pdfjs-dist');
|
|
@@ -47,7 +47,16 @@ async function extractTextFromPDF(data) {
|
|
|
47
47
|
const columnTexts = columns.map((col) => renderColumn(col));
|
|
48
48
|
pages.push(columnTexts.filter(Boolean).join("\n"));
|
|
49
49
|
}
|
|
50
|
-
|
|
50
|
+
const text = pages.join("\n");
|
|
51
|
+
const minTextLength = options?.minTextLength ?? 100;
|
|
52
|
+
if (options?.ocrFallback && text.trim().length < minTextLength) {
|
|
53
|
+
try {
|
|
54
|
+
const ocrText = await options.ocrFallback(bytes);
|
|
55
|
+
if (ocrText.trim().length > text.trim().length) return ocrText;
|
|
56
|
+
} catch {
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
return text;
|
|
51
60
|
}
|
|
52
61
|
function renderColumn(items) {
|
|
53
62
|
const Y_TOLERANCE = 2;
|
package/dist/pdf/index.mjs.map
CHANGED
|
@@ -1 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MAAA,SAAA,CAAU,KAAK,CAAC,CAAA;AAChB,MAAA,OAAA,CAAQ,GAAA,CAAI,CAAA,EAAG,EAAE,CAAA;AAAA,IACnB;AACA,IAAA,OAAA,CAAQ,IAAI,SAAS,CAAA,CAAG,KAAK,EAAE,CAAA,EAAG,KAAK,CAAA;AAAA,EACzC;AAGA,EAAA,SAAA,CAAU,IAAA,CAAK,CAAC,CAAA,EAAG,CAAA,KAAM,IAAI,CAAC,CAAA;AAE9B,EAAA,OAAO,SAAA,CACJ,GAAA;AAAA,IAAI,CAAC,GAAA,KAAA,CACH,OAAA,CAAQ,GAAA,CAAI,GAAG,CAAA,IAAK,EAAC,EACnB,IAAA,CAAK,CAAC,CAAA,EAAG,CAAA,KAAM,EAAE,CAAA,GAAI,CAAA,CAAE,CAAC,CAAA,CACxB,GAAA,CAAI,CAAC,EAAA,KAAO,EAAA,CAAG,GAAG,CAAA,CAClB,IAAA,CAAK,GAAG,CAAA,CACR,OAAA,CAAQ,WAAA,EAAa,GAAG,EACxB,IAAA;AAAK,GACV,CACC,MAAA,CAAO,OAAO,CAAA,CACd,KAAK,IAAI,CAAA;AACd","file":"index.mjs","sourcesContent":["/**\n * Caller-supplied OCR implementation, invoked only when the PDF's text layer\n * comes back too short to be useful (scanned/image PDFs). The caller owns\n * the actual OCR engine and dependency — this library never bundles one.\n */\nexport type OCRClient = (data: Uint8Array) => Promise<string>;\n\nexport interface ExtractTextOptions {\n /** Called with the raw PDF bytes when text-layer extraction is too short. */\n ocrFallback?: OCRClient;\n /** Threshold (trimmed char count) below which ocrFallback is tried. Default 100, matching resume.parser.ts's scanned-PDF warning. */\n minTextLength?: number;\n}\n\n/**\n * Extract plain text from a PDF buffer.\n *\n * Requires `pdfjs-dist` to be installed (optional peerDependency):\n * npm install pdfjs-dist\n *\n * @param data - Raw PDF bytes as Uint8Array or ArrayBuffer\n * @param options - Optional OCR fallback for scanned/image PDFs\n * @returns Extracted text, ready to pass as `resumeText` to analyzeResume\n */\nexport async function extractTextFromPDF(\n data: Uint8Array | ArrayBuffer,\n options?: ExtractTextOptions\n): Promise<string> {\n // ponytail: lazy import keeps core zero-dep; missing peer throws with clear message\n let pdfjsLib: typeof import(\"pdfjs-dist\");\n try {\n pdfjsLib = await import(\"pdfjs-dist\");\n } catch {\n throw new Error(\n \"pdfjs-dist is required for PDF extraction. Install it: npm install pdfjs-dist\"\n );\n }\n\n const bytes =\n data instanceof ArrayBuffer ? new Uint8Array(data) : data;\n\n const doc = await pdfjsLib.getDocument({ data: bytes }).promise;\n const pages: string[] = [];\n\n for (let i = 1; i <= doc.numPages; i++) {\n const page = await doc.getPage(i);\n const content = await page.getTextContent();\n\n type RawItem = { x: number; y: number; str: string };\n const items: RawItem[] = [];\n\n for (const item of content.items) {\n if (!(\"str\" in item) || !item.str.trim()) continue;\n const transform: number[] | undefined = Array.isArray(\n (item as { transform?: number[] }).transform\n )\n ? (item as { transform: number[] }).transform\n : undefined;\n\n if (!transform) {\n // No positional info (unit-test mocks) — treat as single-column item\n items.push({ x: 0, y: 0, str: item.str });\n } else {\n items.push({ x: transform[4], y: transform[5], str: item.str });\n }\n }\n\n // Detect column boundary: find the largest x-gap among item start positions.\n // If it exceeds COLUMN_GAP_THRESHOLD, split into left / right columns and\n // process each independently so headers in different columns don't merge.\n // ponytail: single largest-gap heuristic handles the common 2-column resume;\n // n-column needs k-means on x-distribution — upgrade if this proves insufficient.\n // Column boundary heuristic: the largest gap in item x-positions.\n // Real PDF column gutters show as a gap >>80px; normal word spacing is <50px.\n // ponytail: magic number calibrated to PranavRaut2026.pdf (104px gap); raise\n // if single-column PDFs with wide indentation start getting falsely split.\n const COLUMN_GAP_THRESHOLD = 80;\n const xPositions = [...new Set(items.map((it) => Math.round(it.x)))].sort(\n (a, b) => a - b\n );\n\n let columnBoundary: number | null = null;\n let maxGap = 0;\n for (let j = 1; j < xPositions.length; j++) {\n const gap = xPositions[j] - xPositions[j - 1];\n if (gap > maxGap) {\n maxGap = gap;\n columnBoundary = (xPositions[j - 1] + xPositions[j]) / 2;\n }\n }\n if (maxGap < COLUMN_GAP_THRESHOLD) columnBoundary = null;\n\n const columns =\n columnBoundary !== null\n ? [\n items.filter((it) => it.x < columnBoundary!),\n items.filter((it) => it.x >= columnBoundary!),\n ]\n : [items];\n\n const columnTexts = columns.map((col) => renderColumn(col));\n pages.push(columnTexts.filter(Boolean).join(\"\\n\"));\n }\n\n const text = pages.join(\"\\n\");\n\n // ponytail: OCR is the caller's engine/dependency — we only decide *when*\n // to ask for it (text layer too short) and pick the better of the two results.\n const minTextLength = options?.minTextLength ?? 100;\n if (options?.ocrFallback && text.trim().length < minTextLength) {\n try {\n const ocrText = await options.ocrFallback(bytes);\n if (ocrText.trim().length > text.trim().length) return ocrText;\n } catch {\n // OCR failure falls back to the text-layer result, never throws.\n }\n }\n\n return text;\n}\n\nfunction renderColumn(items: Array<{ x: number; y: number; str: string }>): string {\n const Y_TOLERANCE = 2;\n const lineMap: Map<number, Array<{ x: number; str: string }>> = new Map();\n const lineOrder: number[] = [];\n\n for (const { x, y, str } of items) {\n let bucketKey: number | undefined;\n for (const key of lineOrder) {\n if (Math.abs(key - y) <= Y_TOLERANCE) {\n bucketKey = key;\n break;\n }\n }\n if (bucketKey === undefined) {\n bucketKey = y;\n lineOrder.push(y);\n lineMap.set(y, []);\n }\n lineMap.get(bucketKey)!.push({ x, str });\n }\n\n // pdfjs y=0 is bottom of page — sort descending so top comes first\n lineOrder.sort((a, b) => b - a);\n\n return lineOrder\n .map((key) =>\n (lineMap.get(key) ?? [])\n .sort((a, b) => a.x - b.x)\n .map((it) => it.str)\n .join(\" \")\n .replace(/[^\\S\\n]+/g, \" \")\n .trim()\n )\n .filter(Boolean)\n .join(\"\\n\");\n}\n"]}
|
|
@@ -0,0 +1,319 @@
|
|
|
1
|
+
type ResumeSection = "summary" | "experience" | "skills" | "education" | "projects" | "certifications";
|
|
2
|
+
interface ParsedDateRange {
|
|
3
|
+
raw?: string;
|
|
4
|
+
start?: string;
|
|
5
|
+
end?: string;
|
|
6
|
+
durationInMonths?: number;
|
|
7
|
+
/** Numeric year/month of the start and end, for overlap-aware summing. */
|
|
8
|
+
startYear?: number;
|
|
9
|
+
startMonth?: number;
|
|
10
|
+
endYear?: number;
|
|
11
|
+
endMonth?: number;
|
|
12
|
+
}
|
|
13
|
+
interface ParsedExperienceEntry {
|
|
14
|
+
title?: string;
|
|
15
|
+
company?: string;
|
|
16
|
+
location?: string;
|
|
17
|
+
dates?: ParsedDateRange;
|
|
18
|
+
description?: string;
|
|
19
|
+
}
|
|
20
|
+
interface ParsedAchievement {
|
|
21
|
+
text: string;
|
|
22
|
+
strength: "strong" | "weak";
|
|
23
|
+
reason: string;
|
|
24
|
+
}
|
|
25
|
+
interface ParsedLanguage {
|
|
26
|
+
/** Canonical lowercase language name, e.g. "german". */
|
|
27
|
+
name: string;
|
|
28
|
+
/** Raw level as written/normalized, e.g. "c1", "fluent", "native". */
|
|
29
|
+
level?: string;
|
|
30
|
+
/** CEFR-aligned rank 1 (A1/basic) – 6 (C2/native), for comparing proficiency. */
|
|
31
|
+
levelRank?: number;
|
|
32
|
+
}
|
|
33
|
+
interface ParsedResume {
|
|
34
|
+
raw: string;
|
|
35
|
+
normalizedText: string;
|
|
36
|
+
detectedSections: ResumeSection[];
|
|
37
|
+
sectionContent: Partial<Record<ResumeSection, string>>;
|
|
38
|
+
skills: string[];
|
|
39
|
+
jobTitles: string[];
|
|
40
|
+
actionVerbs: string[];
|
|
41
|
+
/** Weak verbs (helped, worked, performed, ...) found in the resume text. */
|
|
42
|
+
weakVerbs: string[];
|
|
43
|
+
/** Experience bullets classified as strong/weak achievement statements. */
|
|
44
|
+
achievements: ParsedAchievement[];
|
|
45
|
+
educationEntries: string[];
|
|
46
|
+
experience: ParsedExperienceEntry[];
|
|
47
|
+
totalExperienceYears: number;
|
|
48
|
+
keywords: string[];
|
|
49
|
+
languages: ParsedLanguage[];
|
|
50
|
+
warnings: string[];
|
|
51
|
+
}
|
|
52
|
+
interface ParsedJobDescription {
|
|
53
|
+
raw: string;
|
|
54
|
+
normalizedText: string;
|
|
55
|
+
requiredSkills: string[];
|
|
56
|
+
preferredSkills: string[];
|
|
57
|
+
roleKeywords: string[];
|
|
58
|
+
keywords: string[];
|
|
59
|
+
minExperienceYears?: number;
|
|
60
|
+
educationRequirements: string[];
|
|
61
|
+
/** canonical keyword -> the surface form (original casing/spelling) the JD used. */
|
|
62
|
+
keywordSurfaceForms: Record<string, string>;
|
|
63
|
+
requiredLanguages: ParsedLanguage[];
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
interface ATSWeights {
|
|
67
|
+
skills: number;
|
|
68
|
+
experience: number;
|
|
69
|
+
keywords: number;
|
|
70
|
+
education: number;
|
|
71
|
+
}
|
|
72
|
+
type SkillAliases = Record<string, string[]>;
|
|
73
|
+
type KeywordCategory = "technical" | "tool" | "concept" | "soft" | "marketing" | "domain";
|
|
74
|
+
interface KeywordEntry {
|
|
75
|
+
canonical: string;
|
|
76
|
+
aliases: string[];
|
|
77
|
+
category: KeywordCategory;
|
|
78
|
+
}
|
|
79
|
+
type KeywordRegistry = KeywordEntry[];
|
|
80
|
+
interface ATSProfile {
|
|
81
|
+
name: string;
|
|
82
|
+
mandatorySkills: string[];
|
|
83
|
+
optionalSkills: string[];
|
|
84
|
+
minExperience?: number;
|
|
85
|
+
}
|
|
86
|
+
interface KeywordDensityConfig {
|
|
87
|
+
/** Minimum density before a keyword is considered underused (informational only). */
|
|
88
|
+
min: number;
|
|
89
|
+
/** Maximum density before a keyword is considered stuffed. */
|
|
90
|
+
max: number;
|
|
91
|
+
/** Penalty applied when density exceeds max. */
|
|
92
|
+
overusePenalty: number;
|
|
93
|
+
}
|
|
94
|
+
interface SectionPenaltyConfig {
|
|
95
|
+
missingSummary?: number;
|
|
96
|
+
missingExperience?: number;
|
|
97
|
+
missingSkills?: number;
|
|
98
|
+
missingEducation?: number;
|
|
99
|
+
}
|
|
100
|
+
interface ATSRule {
|
|
101
|
+
id: string;
|
|
102
|
+
description?: string;
|
|
103
|
+
penalty: number;
|
|
104
|
+
warning?: string;
|
|
105
|
+
condition: (context: RuleContext) => boolean;
|
|
106
|
+
}
|
|
107
|
+
interface ATSConfig {
|
|
108
|
+
weights?: Partial<ATSWeights>;
|
|
109
|
+
skillAliases?: SkillAliases;
|
|
110
|
+
/** Categorized keyword/alias entries (technical, tool, concept, soft, marketing, domain). Merges over the default registry by canonical term. */
|
|
111
|
+
keywordRegistry?: KeywordRegistry;
|
|
112
|
+
profile?: ATSProfile;
|
|
113
|
+
rules?: ATSRule[];
|
|
114
|
+
keywordDensity?: KeywordDensityConfig;
|
|
115
|
+
sectionPenalties?: SectionPenaltyConfig;
|
|
116
|
+
allowPartialMatches?: boolean;
|
|
117
|
+
/**
|
|
118
|
+
* ISO date string (e.g. "2024-06-01") used as the "today" reference when
|
|
119
|
+
* computing duration for open-ended date ranges ("Present"/"Current"/"Now").
|
|
120
|
+
* Omit to use the actual current date (live/production behaviour).
|
|
121
|
+
* Set to a fixed value in tests or batch processing to guarantee determinism.
|
|
122
|
+
*/
|
|
123
|
+
referenceDate?: string;
|
|
124
|
+
}
|
|
125
|
+
interface NormalizedWeights extends ATSWeights {
|
|
126
|
+
/** Weights normalized so they sum to 1. */
|
|
127
|
+
normalizedTotal: number;
|
|
128
|
+
}
|
|
129
|
+
interface ResolvedATSConfig {
|
|
130
|
+
weights: NormalizedWeights;
|
|
131
|
+
skillAliases: SkillAliases;
|
|
132
|
+
keywordRegistry: KeywordRegistry;
|
|
133
|
+
/** canonical term -> category, derived once from keywordRegistry. */
|
|
134
|
+
categoryIndex: Map<string, KeywordCategory>;
|
|
135
|
+
profile?: ATSProfile;
|
|
136
|
+
rules: ATSRule[];
|
|
137
|
+
keywordDensity: KeywordDensityConfig;
|
|
138
|
+
sectionPenalties: Required<SectionPenaltyConfig>;
|
|
139
|
+
allowPartialMatches: boolean;
|
|
140
|
+
/** Resolved reference date for "Present" duration calculations. */
|
|
141
|
+
referenceDate?: Date;
|
|
142
|
+
}
|
|
143
|
+
interface RuleContext {
|
|
144
|
+
resume: ParsedResume;
|
|
145
|
+
job: ParsedJobDescription;
|
|
146
|
+
weights: NormalizedWeights;
|
|
147
|
+
keywordDensity: KeywordDensityConfig;
|
|
148
|
+
breakdown?: ATSBreakdown;
|
|
149
|
+
matchedKeywords?: string[];
|
|
150
|
+
overusedKeywords?: string[];
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
/**
|
|
154
|
+
* LLM v2 Support Types - Optional, Backward Compatible
|
|
155
|
+
*/
|
|
156
|
+
|
|
157
|
+
/**
|
|
158
|
+
* JSON Schema for response validation
|
|
159
|
+
*/
|
|
160
|
+
interface JSONSchema {
|
|
161
|
+
type: string;
|
|
162
|
+
properties?: Record<string, unknown>;
|
|
163
|
+
required?: string[];
|
|
164
|
+
items?: unknown;
|
|
165
|
+
[key: string]: unknown;
|
|
166
|
+
}
|
|
167
|
+
/**
|
|
168
|
+
* LLM Client abstraction - user provides their own implementation
|
|
169
|
+
* This allows flexibility with different LLM providers without direct dependencies
|
|
170
|
+
*/
|
|
171
|
+
interface LLMClient {
|
|
172
|
+
/**
|
|
173
|
+
* Create a structured completion from the LLM
|
|
174
|
+
* Must validate and return only valid JSON matching the schema
|
|
175
|
+
*/
|
|
176
|
+
createCompletion(input: {
|
|
177
|
+
model: string;
|
|
178
|
+
messages: {
|
|
179
|
+
role: "system" | "user";
|
|
180
|
+
content: string;
|
|
181
|
+
}[];
|
|
182
|
+
max_tokens: number;
|
|
183
|
+
response_format: JSONSchema;
|
|
184
|
+
}): Promise<{
|
|
185
|
+
content: unknown;
|
|
186
|
+
usage?: {
|
|
187
|
+
prompt_tokens?: number;
|
|
188
|
+
completion_tokens?: number;
|
|
189
|
+
total_tokens?: number;
|
|
190
|
+
};
|
|
191
|
+
}>;
|
|
192
|
+
}
|
|
193
|
+
/**
|
|
194
|
+
* LLM budget configuration - prevents runaway spending
|
|
195
|
+
*/
|
|
196
|
+
interface LLMBudget {
|
|
197
|
+
maxCalls: number;
|
|
198
|
+
maxTokensPerCall: number;
|
|
199
|
+
maxTotalTokens: number;
|
|
200
|
+
}
|
|
201
|
+
/**
|
|
202
|
+
* Feature toggles for LLM capabilities
|
|
203
|
+
*/
|
|
204
|
+
interface LLMFeatures {
|
|
205
|
+
skillNormalization?: boolean;
|
|
206
|
+
sectionClassification?: boolean;
|
|
207
|
+
suggestions?: boolean;
|
|
208
|
+
}
|
|
209
|
+
/**
|
|
210
|
+
* Complete LLM configuration
|
|
211
|
+
*/
|
|
212
|
+
interface LLMConfig {
|
|
213
|
+
/** User-provided LLM client (e.g., OpenAI wrapper) */
|
|
214
|
+
client: LLMClient;
|
|
215
|
+
/** Model identifiers */
|
|
216
|
+
models?: {
|
|
217
|
+
/** Default model for fast, structured output (e.g., "gpt-4o-mini") */
|
|
218
|
+
default: string;
|
|
219
|
+
/** Optional thinking model for complex reasoning (e.g., "o4-mini") */
|
|
220
|
+
thinking?: string;
|
|
221
|
+
};
|
|
222
|
+
/** Budget constraints */
|
|
223
|
+
limits: LLMBudget;
|
|
224
|
+
/** Which LLM features to enable */
|
|
225
|
+
enable?: LLMFeatures;
|
|
226
|
+
/** Request timeout in milliseconds */
|
|
227
|
+
timeoutMs?: number;
|
|
228
|
+
}
|
|
229
|
+
/**
|
|
230
|
+
* Updated AnalyzeResumeInput with optional LLM support
|
|
231
|
+
*/
|
|
232
|
+
interface AnalyzeResumeInputV2 {
|
|
233
|
+
resumeText: string;
|
|
234
|
+
jobDescription: string;
|
|
235
|
+
config?: ATSConfig;
|
|
236
|
+
llm?: LLMConfig;
|
|
237
|
+
}
|
|
238
|
+
/**
|
|
239
|
+
* LLM usage tracking for debugging
|
|
240
|
+
*/
|
|
241
|
+
interface LLMUsageStats {
|
|
242
|
+
totalCalls: number;
|
|
243
|
+
totalTokensUsed: number;
|
|
244
|
+
callsRemaining: number;
|
|
245
|
+
tokensRemaining: number;
|
|
246
|
+
features: Partial<Record<keyof LLMFeatures, boolean>>;
|
|
247
|
+
}
|
|
248
|
+
/**
|
|
249
|
+
* Result of an LLM operation (with fallback info)
|
|
250
|
+
*/
|
|
251
|
+
interface LLMResult<T> {
|
|
252
|
+
success: boolean;
|
|
253
|
+
data?: T;
|
|
254
|
+
fallback: boolean;
|
|
255
|
+
error?: string;
|
|
256
|
+
tokensUsed?: number;
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
interface ATSBreakdown {
|
|
260
|
+
skills: number;
|
|
261
|
+
experience: number;
|
|
262
|
+
keywords: number;
|
|
263
|
+
education: number;
|
|
264
|
+
}
|
|
265
|
+
interface AnalyzeResumeInput {
|
|
266
|
+
resumeText: string;
|
|
267
|
+
jobDescription: string;
|
|
268
|
+
config?: ATSConfig;
|
|
269
|
+
llm?: LLMConfig;
|
|
270
|
+
}
|
|
271
|
+
interface KeywordWeight {
|
|
272
|
+
term: string;
|
|
273
|
+
category: KeywordCategory;
|
|
274
|
+
/** Importance of this term in the job description (location + frequency based). */
|
|
275
|
+
jdWeight: number;
|
|
276
|
+
/** How often this term appears in the resume. */
|
|
277
|
+
resumeWeight: number;
|
|
278
|
+
/** Alias of jdWeight — how much this term matters for the role. */
|
|
279
|
+
importance: number;
|
|
280
|
+
}
|
|
281
|
+
interface ATSAnalysisResult {
|
|
282
|
+
score: number;
|
|
283
|
+
breakdown: ATSBreakdown;
|
|
284
|
+
/** Skills found in the resume that satisfy JD + profile requirements. */
|
|
285
|
+
matchedSkills: string[];
|
|
286
|
+
/** Required skills absent from the resume. */
|
|
287
|
+
missingSkills: string[];
|
|
288
|
+
matchedKeywords: string[];
|
|
289
|
+
missingKeywords: string[];
|
|
290
|
+
overusedKeywords: string[];
|
|
291
|
+
/** Matched/missing keywords grouped by category (technical, tool, concept, soft, marketing, domain). */
|
|
292
|
+
keywordsByCategory: Record<KeywordCategory, {
|
|
293
|
+
matched: string[];
|
|
294
|
+
missing: string[];
|
|
295
|
+
}>;
|
|
296
|
+
/** Per-keyword JD importance and resume usage, for callers who want the raw numbers. */
|
|
297
|
+
keywordWeights: KeywordWeight[];
|
|
298
|
+
/** Count of resume achievement bullets classified as strong vs weak. */
|
|
299
|
+
achievementStrength: {
|
|
300
|
+
strong: number;
|
|
301
|
+
weak: number;
|
|
302
|
+
};
|
|
303
|
+
/** JD-required languages the resume meets or exceeds in proficiency. */
|
|
304
|
+
matchedLanguages: ParsedLanguage[];
|
|
305
|
+
/** JD-required languages absent from the resume, or below the required proficiency. */
|
|
306
|
+
missingLanguages: ParsedLanguage[];
|
|
307
|
+
suggestions: string[];
|
|
308
|
+
warnings: string[];
|
|
309
|
+
/** Years below the JD's minimum experience requirement; 0 when the requirement is met. */
|
|
310
|
+
experienceGap: number;
|
|
311
|
+
/** Resume sections the parser successfully detected (e.g. "summary", "skills"). */
|
|
312
|
+
detectedSections: string[];
|
|
313
|
+
/** Total years of experience parsed from the resume's date ranges. */
|
|
314
|
+
parsedExperienceYears: number;
|
|
315
|
+
/** Parsed experience entries from the resume, with titles and date ranges. */
|
|
316
|
+
experienceEntries: ParsedExperienceEntry[];
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
export type { ATSProfile as A, JSONSchema as J, KeywordRegistry as K, LLMConfig as L, NormalizedWeights as N, ParsedDateRange as P, ResolvedATSConfig as R, SkillAliases as S, LLMResult as a, LLMBudget as b, AnalyzeResumeInput as c, ATSAnalysisResult as d, ATSWeights as e, KeywordCategory as f, KeywordEntry as g, KeywordDensityConfig as h, SectionPenaltyConfig as i, ATSRule as j, ATSConfig as k, RuleContext as l, ResumeSection as m, ParsedExperienceEntry as n, ParsedAchievement as o, ParsedLanguage as p, ParsedResume as q, ParsedJobDescription as r, ATSBreakdown as s, KeywordWeight as t, LLMClient as u, LLMFeatures as v, AnalyzeResumeInputV2 as w, LLMUsageStats as x };
|