mirror of
https://github.com/AmruthPillai/Reactive-Resume.git
synced 2026-08-24 23:32:19 +10:00
refactor(ai): collapse parser prompts to template; replace makeEmptyItem with structuredClone
- Replace pdf-parser-system.md + docx-parser-system.md with a single parser-system.md template; prompts.ts substitutes 6 placeholders per source type. Produced strings are byte-identical to the former files. - Remove makeEmptyItem recursive walker (all SECTION_ITEM_SHAPES leaves are already zero-valued) and call structuredClone(shape) instead. Claude-Session: https://claude.ai/code/session_012Bnvt1MghwHj4qQRxuQUGa
This commit is contained in:
@@ -1,23 +1,5 @@
|
||||
import { defaultResumeData } from "@reactive-resume/schema/resume/default";
|
||||
|
||||
function makeEmptyItem(shape: Record<string, unknown>): Record<string, unknown> {
|
||||
const item: Record<string, unknown> = {};
|
||||
|
||||
for (const [key, value] of Object.entries(shape)) {
|
||||
if (typeof value === "string") item[key] = "";
|
||||
else if (typeof value === "number") item[key] = 0;
|
||||
else if (typeof value === "boolean") item[key] = false;
|
||||
else if (Array.isArray(value)) item[key] = [];
|
||||
else if (value !== null && typeof value === "object") {
|
||||
item[key] = makeEmptyItem(value as Record<string, unknown>);
|
||||
} else {
|
||||
item[key] = "";
|
||||
}
|
||||
}
|
||||
|
||||
return item;
|
||||
}
|
||||
|
||||
const SECTION_ITEM_SHAPES: Record<string, Record<string, unknown>> = {
|
||||
profiles: {
|
||||
id: "",
|
||||
@@ -114,7 +96,7 @@ export function buildAiExtractionTemplate() {
|
||||
const sectionKey = key as keyof typeof defaultResumeData.sections;
|
||||
sections[key] = {
|
||||
...defaultResumeData.sections[sectionKey],
|
||||
items: [makeEmptyItem(shape)],
|
||||
items: [structuredClone(shape)],
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user