refactor(prompts): extract prompt templates to dedicated module

This commit is contained in:
mitchell 2026-06-17 01:25:27 -04:00
parent 3c3dab1525
commit eec90209d2
2 changed files with 19 additions and 14 deletions

View file

@ -6,6 +6,7 @@ import { streamText } from "ai";
import { initConfig, loadConfig } from "./config";
import { Conversation } from "./conversation";
import { handleTopLevel } from "./errors";
import { Prompts } from "./prompts";
import Renderer from "./render";
async function main() {
@ -73,21 +74,10 @@ async function main() {
let prompt = "Introduce yourself.";
const input = positionals.join(" ").trim();
if (messageFlag) {
prompt = `\`\`\`diff
${input}
\`\`\`
if (messageFlag) prompt = Prompts.commit(input);
else if (reviewFlag) prompt = Prompts.review(input);
else if (input) prompt = input;
Generate a conventional commit message for this diff. If you are unable to generate a reasonable option, ask for more context.`;
} else if (reviewFlag) {
prompt = `\`\`\`diff
${input}
\`\`\`
Review the above diff for any potential bugs, best practices, performance issues, or security flaws. Let me know if you need any more context to compelete your review.`;
} else if (input) {
prompt = input;
}
convo.messages.push({ role: "user", content: prompt });
const { fullStream, text, totalUsage } = streamText({