refactor(prompts): extract prompts to dedicated module and enhance instructions
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
export const SYSTEM_PROMPT =
|
||||
"You are a git commit message generator. Output only the commit message — no explanation, no preamble, no backticks, no quotes. All messages must be written in English."
|
||||
|
||||
export const CONVENTIONAL_INSTRUCTION = `Based on the provided git diff, generate a concise and descriptive commit message following the Conventional Commits format:
|
||||
|
||||
<type>(<scope>): <short description>
|
||||
|
||||
Types: feat, fix, refactor, style, docs, test, chore, perf, revert
|
||||
- feat: new feature
|
||||
- fix: bug fix
|
||||
- refactor: code restructuring without behavior change
|
||||
- style: formatting only (spaces, commas, no logic change)
|
||||
- docs: documentation only
|
||||
- test: add or update tests
|
||||
- chore: maintenance, dependencies, build config
|
||||
- perf: performance improvement
|
||||
- revert: revert a previous commit (format: revert: revert "<original message>")
|
||||
|
||||
Rules:
|
||||
- Scope is optional, specifies the affected area (e.g. auth, api, storage, ui, config)
|
||||
- Description: lowercase, no trailing period, in English
|
||||
- One commit = one intention, do not mix fix and refactor
|
||||
- For breaking changes, add ! after the type and a BREAKING CHANGE: footer
|
||||
- Only include a body if there are multiple distinct changes to explain; for a single focused change, output the title only`
|
||||
|
||||
export const SIMPLE_INSTRUCTION = `Based on the provided git diff, generate a short and clear one-line commit message (50-72 characters).`
|
||||
+1
-13
@@ -1,17 +1,5 @@
|
||||
import * as vscode from "vscode"
|
||||
|
||||
const SYSTEM_PROMPT =
|
||||
"You are a helpful assistant that generates informative git commit messages based on git diffs output. Skip preamble and remove all backticks surrounding the commit message."
|
||||
|
||||
const CONVENTIONAL_INSTRUCTION = `Based on the provided git diff, generate a concise and descriptive commit message.
|
||||
|
||||
The commit message should:
|
||||
1. Have a short title (50-72 characters)
|
||||
2. Follow the Conventional Commits format (feat:, fix:, chore:, docs:, refactor:, test:, style:, etc.)
|
||||
3. Be clear and informative
|
||||
4. Only include a body description if there are multiple distinct changes to explain, if the diff represents a single focused change, output the title only`
|
||||
|
||||
const SIMPLE_INSTRUCTION = `Based on the provided git diff, generate a short and clear one-line commit message (50-72 characters).`
|
||||
import { SYSTEM_PROMPT, CONVENTIONAL_INSTRUCTION, SIMPLE_INSTRUCTION } from "./prompts"
|
||||
|
||||
export interface AIProvider {
|
||||
generateCommitMessage(diff: string, style: string, signal: AbortSignal): AsyncIterable<string>
|
||||
|
||||
Reference in New Issue
Block a user