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:
Amruth Pillai
2026-07-04 19:27:13 +02:00
parent dfe75390cd
commit 5762eb6a3e
4 changed files with 44 additions and 82 deletions
+1 -19
View File
@@ -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)],
};
}