feat(config): allow custom prompt template file via config
Merged
40
3mo ago+854+854+012345678901234567890123456789-80-80-01234567890123456789
Summary
Add a templatePath config option that loads a custom prompt template file from disk, enabling users to define highly customized commit-message guidance without forking the project.
Changes
- feat: Add
templatePathfield toConfiginterface andCOMMIT_ECHO_TEMPLATE_PATHenv var override - feat: Load template files with
---separator for system/user prompt splitting - feat:
templatePathtakes precedence over inlinesystemPromptTemplate/userPromptTemplate - feat: Init wizard prompts for template file path with existence validation
- test: Add 8 new tests for file loading, separator parsing, env var, missing file errors, and precedence
Template File Format
The template file supports the same {{variable}} syntax as inline templates:
{{diff}}— The git diff text{{profile}}— The learned style profile summary{{branch}}— Current git branch name{{message}}— Previous commit message context
Use --- on its own line to separate the system prompt (above) from the user prompt (below). Without a separator, the entire file is used as the system prompt.
Example
You are an expert Git commit message assistant for the {{branch}} branch.
Style guidance:
{{profile}}
---
Generate 3 commit messages for:
```diff
{{diff}}
Testing
All 340 tests pass (including 8 new template file tests). Run with npm test.
Related
Closes #237
Summary by CodeRabbit
-
New Features
- Added support for custom prompt templates loaded from a file.
- Templates can define separate system and user prompts using an optional separator.
- Added configuration through an environment variable or configuration file.
- The setup flow now validates template paths and reports the selected template.
-
Bug Fixes
- Improved prompt resolution in suggestions and dry-run output.
- Added clearer errors when prompt template files cannot be read.
-
Tests
- Expanded coverage for template loading, configuration overrides, fallbacks, and validation.