feat: initial project setup with gai tool
This commit is contained in:
@@ -0,0 +1,56 @@
|
||||
import type { ProjectContext } from "./types";
|
||||
|
||||
export const SYSTEM_PROMPT = `You are an expert at writing concise, meaningful git commit messages following the Conventional Commits specification.
|
||||
|
||||
Format: <type>(<scope>): <description>
|
||||
|
||||
Types: feat, fix, docs, style, refactor, perf, test, build, ci, chore, revert
|
||||
|
||||
Rules:
|
||||
1. Use imperative mood in description (e.g., "add feature" not "added feature")
|
||||
2. Keep the first line (subject) under 72 characters
|
||||
3. Scope is optional but recommended when the change area is clear
|
||||
4. For breaking changes, add "!" after the scope: feat(scope)!: description
|
||||
5. If the change needs explanation, add a body separated by a blank line — explain WHY, not WHAT
|
||||
6. Match the language and style of recent commits if provided
|
||||
7. Be specific — avoid vague messages like "update code" or "fix bugs"
|
||||
8. Output ONLY the commit message text, no markdown, no code blocks, no prefixes`;
|
||||
|
||||
export function buildPrompt(context: ProjectContext): string {
|
||||
const parts: string[] = [];
|
||||
|
||||
if (
|
||||
context.packageDescription ||
|
||||
context.readme ||
|
||||
context.structure
|
||||
) {
|
||||
parts.push("## Project Context");
|
||||
if (context.packageDescription) {
|
||||
parts.push(`Description: ${context.packageDescription}`);
|
||||
}
|
||||
if (context.structure) {
|
||||
parts.push(`Structure: ${context.structure}`);
|
||||
}
|
||||
if (context.readme) {
|
||||
parts.push(`README:\n${context.readme}`);
|
||||
}
|
||||
parts.push("");
|
||||
}
|
||||
|
||||
if (context.recentCommits.length > 0) {
|
||||
parts.push("## Recent Commits (for style reference)");
|
||||
for (const c of context.recentCommits) {
|
||||
parts.push(c);
|
||||
}
|
||||
parts.push("");
|
||||
}
|
||||
|
||||
parts.push("## Staged Changes");
|
||||
parts.push("```diff");
|
||||
parts.push(context.diff);
|
||||
parts.push("```");
|
||||
parts.push("");
|
||||
parts.push("Generate a commit message for the above changes.");
|
||||
|
||||
return parts.join("\n");
|
||||
}
|
||||
Reference in New Issue
Block a user