Repository navigation
feat: Phase 4 — Graceful Degradation and Prompt Templates - #7
Merged
Merged
Conversation
- Prompt templates in templates/ (commit_conventional.txt, commit_plain.txt, pr_summary.txt) with embedded version headers - Prompt engine in prompt.py with PromptTemplate, load_template, and render_commit_prompt using string.Template interpolation - Deterministic template-based fallback generator in fallback.py for offline commit message derivation from diff metadata - Graceful degradation in generate_commit_message catching ProviderUnavailable/TokenBudgetError with visible warning - 31 new tests in test_prompt.py, test_fallback.py, and test_orchestrator.py (149 passed) - README.md and class diagram updated for Phase 4
…ecret_store injection
getdownandcode
added a commit
that referenced
this pull request
Sep 19, 2026
…d orchestrator consolidation - #1 (Blocker): Fail loud with exit code 1 on git errors, budget cap breaches, and gh CLI errors across pr-summary and changelog CLI commands. - #2: Prevent duplicate printing when no changes/commits exist by early returning None. - #3: Route diagnostic warnings, budget alerts, and error messages to stderr console (err_console) to keep stdout clean for Unix piping. - #4: Correctly parse and surface breaking changes (exclamation mark and BREAKING CHANGE: footers) in conventional commits and templates. - #5: Bump changelog template to version 2, including from_ref..to_ref range and explicit release headers. - #6: Support --title (-t) flag in pr-summary and propagate gh pr create failures. - #7: Remove dead head argument from fallback PR summary. - #8: Consolidate duplicate budget checking, safe telemetry recording, and heuristic token counters into orchestrator.py. - #9: Enforce strict type hints with CommitLogEntry in fallback.py.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Phase 4 implements prompt templates and graceful degradation as specified in plan.md. If the LLM provider is down, rate-limited, offline, or unauthenticated, gitmate automatically catches the failure, displays a clear warning, and derives a high-quality commit message directly from diff metadata without an LLM call.
Changes
src/gitmate/templates/):commit_conventional.txt: Conventional Commits prompt (version: 1).commit_plain.txt: Plain imperative commit prompt (version: 1).pr_summary.txt: Structured PR summary description prompt (version: 1).src/gitmate/prompt.py):PromptTemplatedataclass withversion_keyfor diskcache hashing.load_template()reads templates viaimportlib.resources.render_commit_prompt()interpolates$diffand$summary_notesafely viastring.Template.src/gitmate/fallback.py):generate_fallback_message(): zero LLM calls, completely offline.added,modified,deleted,renamed), paths, and extensions to generate conventional and plain commit messages.generate_commit_messageinsrc/gitmate/fallback.py):ProviderUnavailableandTokenBudgetError, warns the user, and produces the fallback message.secret_storedependency injection; catchesKeyringErrorsafely when OS store is unavailable.GenerationResulttrackingis_fallbackandfallback_reason.README.mdupdated for Phase 4 usage.docs/class-diagram.drawioupdated with Phase 4 architecture and re-exported todocs/class-diagram.png(score: 0, 0 errors).tests/test_prompt.py,tests/test_fallback.py,tests/test_orchestrator.py, andtests/test_config.py.Verification
uv run pytest: 153 passed.uv run ruff check .: clean.uv run ruff format --check .: 23 files formatted.uv run mypy src tests: clean strict type check across 21 source files.