Skip to content

A one-of-a-kind resume builder that keeps your privacy in mind. Completely secure, customizable, portable, open-source and free forever. Try it out today!

2.7 KB
Raw Blame
import { readFileSync } from "node:fs";

export const safetySystemPrompt = readFileSync(new URL("./prompts/safety-system.md", import.meta.url), "utf-8");

const readPrompt = (filename: string) => {
	return readFileSync(new URL(`./prompts/${filename}`, import.meta.url), "utf-8");
};

// ponytail: single template with per-source substitutions; produced text is identical per source type
const parserTemplate = `${safetySystemPrompt}\n\n${readPrompt("parser-system.md")}`;

type ParserVars = {
	FORMAT_HEADER: string;
	FORMAT_NOUN: string;
	ALLOWED_INPUT: string;
	URL_CLAUSE: string;
	EXTRA_RULES: string;
	FALLBACK_CLAUSE: string;
};

function makeParserPrompt(vars: ParserVars): string {
	return Object.entries(vars).reduce((acc, [k, v]) => acc.replaceAll(`{{${k}}}`, v), parserTemplate);
}

const pdfParserSystemPrompt = makeParserPrompt({
	FORMAT_HEADER: "PDF files",
	FORMAT_NOUN: "PDF",
	ALLOWED_INPUT:
		"- Use only the visible content from the attached PDF document.\n- Ignore OCR noise, watermarks, repeated headers/footers, and broken line wraps.",
	URL_CLAUSE: "full URLs that are explicitly present",
	EXTRA_RULES: "",
	FALLBACK_CLAUSE: "PDF is low quality or partially unreadable",
});

const docxParserSystemPrompt = makeParserPrompt({
	FORMAT_HEADER: "Microsoft Word files (DOC/DOCX)",
	FORMAT_NOUN: "document",
	ALLOWED_INPUT:
		"- Use only visible, intended content from the attached document.\n- Ignore hidden text, comments, track changes, revision history, document metadata, and layout artifacts.",
	URL_CLAUSE: "URLs explicitly visible in document content",
	EXTRA_RULES:
		"- Lists and tables: extract visible text faithfully; preserve relationships in section fields.\n- Headers/footers: include only if they contain real resume data.\n",
	FALLBACK_CLAUSE: "document is malformed or partially unreadable",
});

const assistantSystemPromptTemplate = `${safetySystemPrompt}\n\n${readPrompt("assistant-system.md")}`;
export const careerSystemPromptTemplate = `${safetySystemPrompt}\n\n${readPrompt("career-system.md")}`;
const atsReviewSystemPrompt = readPrompt("ats-review-system.md");
const atsReviewUserPromptTemplate = readPrompt("ats-review-user.md");
const docxParserUserPrompt = readPrompt("docx-parser-user.md");
const improveSystemPrompt = readPrompt("improve-system.md");
const improveUserPromptTemplate = readPrompt("improve-user.md");
const letterDraftSystemPrompt = `${safetySystemPrompt}\n\n${readPrompt("letter-draft-system.md")}`;
const pdfParserUserPrompt = readPrompt("pdf-parser-user.md");

export {
	assistantSystemPromptTemplate,
	atsReviewSystemPrompt,
	atsReviewUserPromptTemplate,
	docxParserSystemPrompt,
	docxParserUserPrompt,
	improveSystemPrompt,
	improveUserPromptTemplate,
	letterDraftSystemPrompt,
	pdfParserSystemPrompt,
	pdfParserUserPrompt,
};