-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprompt.ts
More file actions
12 lines (11 loc) · 721 Bytes
/
Copy pathprompt.ts
File metadata and controls
12 lines (11 loc) · 721 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
import { readFile } from "node:fs/promises";
import { resolve } from "node:path";
import type { GithubOptions } from "./config.js";
export async function botPrompt(options: Pick<GithubOptions, "ownerDirectory" | "systemPromptFile">) {
const baseline = await readFile(new URL("../prompts/bot.md", import.meta.url), "utf8");
if (!baseline.trim()) throw new Error("The bundled bot system prompt is empty");
if (!options.systemPromptFile) return baseline;
const custom = await readFile(resolve(options.ownerDirectory, options.systemPromptFile), "utf8");
if (!custom.trim()) throw new Error("The configured bot system prompt is empty");
return `${baseline}\n\n# Project-specific bot instructions\n\n${custom}`;
}