import os


with open("./prompt.md", "r") as file:
    prompt = file.read()


typ_files = [i for i in os.listdir("./modules_zh") if i.endswith(".typ")]

cv_content = ""

for typ_file in typ_files:
    with open(f"./modules_zh/{typ_file}", "r") as file:
        typ_content = file.read()

    cv_content += f"### {typ_file.replace('.typ', '')}\n\n"
    cv_content += typ_content + "\n\n"

final_prompt = prompt.replace("###DIST_INSERT_CV###", cv_content)

os.makedirs("./dist", exist_ok=True)

with open("./dist/final_prompt.md", "w") as file:
    file.write(final_prompt)
