Prompts
Prompt templates for commit message generation.
COMMIT_SYSTEM_PROMPT
module-attribute
COMMIT_SYSTEM_PROMPT = "\nYou are an AI assistant knowledgeable in Git best practices.\nYou are tasked with generating Conventional Commit 1.0.0 messages from Git diffs.\nFollow the user's requirements carefully and to the letter.\nYour response must be a valid JSON object matching the provided schema.\n"
DEFAULT_PROMPT_TEMPLATE
module-attribute
DEFAULT_PROMPT_TEMPLATE = '\n**Instructions & Rules:**\n\n1. **Type:** REQUIRED. Must be lowercase and one of: {convention.types}.\n * `feat`: New feature (MINOR SemVer).\n * `fix`: Bug fix (PATCH SemVer).\n * Other types (`build`, `chore`, `ci`, `docs`, `style`, `refactor`, `perf`, `test`, etc.) are allowed.\n2. **Scope:** OPTIONAL. Lowercase noun(s) in parentheses describing the code section (e.g., `(parser)`).\n * Keep short (1-2 words).\n3. **Description:** REQUIRED. Concise, imperative, present tense summary of *what* changed and *why* based on the diff.\n * Must follow the colon and space.\n * Must be >= 10 characters.\n * Must NOT end with a period.\n * The entire header line (`<type>[scope]: <description>`) must be <= {convention.max_length} characters.\n4. **Body:** OPTIONAL. Explain *why* and *how*. Start one blank line after the description.\n\t*\tUse the body only if extra context is needed to understand the changes.\n\t*\tDo not use the body to add unrelated information.\n\t*\tDo not use the body to explain *what* was changed.\n\t*\tTry to keep the body concise and to the point.\n5. **Footer(s):** OPTIONAL. Format `Token: value` or `Token # value`.\n * Start one blank line after the body.\n * Use `-` for spaces in tokens (e.g., `Reviewed-by`).\n6. **BREAKING CHANGE:** Indicate with `!` before the colon in the header (e.g., `feat(api)!: ...`)\n * OR with a `BREAKING CHANGE: <description>` footer (MUST be uppercase).\n * Correlates with MAJOR SemVer.\n * If `!` is used, the description explains the break.\n7. **Special Case - Binary Files:**\n * For binary file changes, use `chore` type with a scope indicating the file type (e.g., `(assets)`, `(images)`, `(builds)`)\n * Be specific about what changed (e.g., "update image assets", "add new icon files", "replace binary database")\n * If the diff content is empty or shows binary file changes, focus on the filenames to determine the purpose\n\n**Commit Message Format:**\n```\n<type>[optional scope]: <description>\n\n[optional body]\n\n[optional footer(s)]\n```\n\n**File Summary:**\n{files_summary}\n\n**Git diff:**\n{diff}\n\n**Output Requirements:**\n\n**(IMPORTANT) STRICTLY OMIT footers: `Related Issue #`, `Closes #`, `REVIEWED-BY`, `TRACKING #`, `APPROVED`.\n\n**(IMPORTANT) Following JSON Schema must be followed for Output:**\n{schema}\n\n---\nPlease analyze the `Git diff` and `File Summary` and create a valid commit message.\nReturn your answer as json.\n'
MOVE_CONTEXT
module-attribute
MOVE_CONTEXT = "\n---\nThis diff group contains file moves. Here is the list of files that are relocated:\n{files}\n\nThese files are moved from {source_dir} to {target_dir}.\n"
get_lint_prompt_template
get_lint_prompt_template() -> str
Get the prompt template for lint feedback.
Returns:
Type | Description |
---|---|
str
|
The prompt template with lint feedback placeholders |
Source code in src/codemap/git/commit_generator/prompts.py
88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 |
|
file_info_to_human_summary
file_info_to_human_summary(
file_info: dict[str, Any],
) -> str
Convert file_info dict to a human-readable summary (used in both initial and regeneration prompts).
Parameters:
Name | Type | Description | Default |
---|---|---|---|
file_info
|
dict[str, Any]
|
Dictionary with information about files |
required |
Returns:
Type | Description |
---|---|
str
|
Human-readable summary string |
Source code in src/codemap/git/commit_generator/prompts.py
136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 |
|
prepare_prompt
prepare_prompt(
template: str,
diff_content: str,
file_info: dict[str, Any],
config_loader: ConfigLoader,
extra_context: dict[str, Any] | None = None,
) -> str
Prepare the prompt for the LLM.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
template
|
str
|
Prompt template to use |
required |
diff_content
|
str
|
Diff content to include |
required |
file_info
|
dict[str, Any]
|
Information about files in the diff |
required |
config_loader
|
ConfigLoader
|
ConfigLoader instance to use for configuration |
required |
extra_context
|
dict[str, Any] | None
|
Optional additional context values for the template |
None
|
Returns:
Type | Description |
---|---|
str
|
Formatted prompt |
Source code in src/codemap/git/commit_generator/prompts.py
158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 |
|
prepare_lint_prompt
prepare_lint_prompt(
template: str,
file_info: dict[str, Any],
config_loader: ConfigLoader,
lint_messages: list[str],
original_message: str | None = None,
) -> str
Prepare a prompt with lint feedback for regeneration.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
template
|
str
|
Prompt template to use |
required |
file_info
|
dict[str, Any]
|
Information about files in the diff |
required |
config_loader
|
ConfigLoader
|
ConfigLoader instance to use for configuration |
required |
lint_messages
|
list[str]
|
List of linting error messages |
required |
original_message
|
str | None
|
The original failed commit message |
None
|
Returns:
Type | Description |
---|---|
str
|
Enhanced prompt with linting feedback |
Source code in src/codemap/git/commit_generator/prompts.py
198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 |
|