Skip to content

Commit c5784fe

Browse files
committed
feat: add refine_message for interactive commit refinement
Users can now provide feedback to regenerate commit messages with natural language guidance. The refine_message method accepts user feedback and calls resolve_refinement_prompt to build a targeted LLM request, enabling iterative message improvement before committing.
1 parent 663bf59 commit c5784fe

7 files changed

Lines changed: 189 additions & 31 deletions

File tree

CHANGELOG.md

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,17 @@ SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Commercial
88

99
All notable changes to CommitBee are documented here.
1010

11-
## `v0.6.0-rc.1` — Deep Understanding (release candidate)
11+
## `v0.6.0-dev` — Deep Understanding (release candidate)
12+
13+
### UI/UX
14+
15+
- **Interactive message refinement** — Added a "Refine" option to the candidate selection and confirmation menu. Users can provide feedback to the LLM (e.g., "more detail about the API change") to regenerate the message with natural language guidance.
16+
- **Native clipboard support** — Replaced external commands (`pbcopy`, `xclip`) with the `arboard` crate for a native, cross-platform clipboard implementation.
17+
- **Interactive commit editing** — Added an "Edit" option to the candidate selection and confirmation menu. Users can now refine the generated message using their system editor before committing.
1218

1319
### Semantic Analysis
1420

21+
- **Full AST diffs for structs and enums**`AstDiffer` now supports structured diffing for structs, enums, classes, interfaces, and traits. Detects added/removed fields, changed variants, and type modifications.
1522
- **Parent scope extraction** — Methods inside `impl`, `class`, or `trait` blocks now show their parent in the prompt: `CommitValidator > pub fn validate(...)`. Walks the AST tree through intermediate nodes (declaration_list, class_body). Verified across 7 languages (Rust, Python, TypeScript, Java, Go, Ruby, C#).
1623
- **Import change detection** — New `IMPORTS CHANGED:` prompt section shows added/removed import statements. Supports Rust `use`, JS/TS `import`, Python `from`/`import`, Node `require()`, and C/C++ `#include`. Capped at 10 entries.
1724
- **Doc-vs-code distinction**`SpanChangeKind` enum classifies modified symbols as WhitespaceOnly, DocsOnly, Mixed, or Semantic. Doc-only changes suggest `docs` type. Modified symbols show `[docs only]` or `[docs + code]` suffix in the prompt.
@@ -30,21 +37,26 @@ All notable changes to CommitBee are documented here.
3037
- **Diff-based intent patterns** — Scans added lines for error handling (`Result`, `?`, `Err()`), test additions (`#[test]`, `assert!`), logging (`tracing::`, `debug!`), and dependency updates. Shown as `INTENT:` section in the prompt with confidence scores.
3138
- **Conservative type refinement** — High-confidence performance optimization patterns can override the base type to `perf`.
3239

33-
### Prompt Quality
34-
35-
- **Token budget rebalance** — Symbol budget reduced from 30% to 20% when structural diffs are available, freeing space for the raw diff. SYSTEM_PROMPT updated to guide the LLM to prefer STRUCTURED CHANGES for signature details.
36-
- **Unsafe constraint rule** — When `unsafe` is added to a function, a CONSTRAINTS rule instructs the LLM to mention safety justification in the commit body.
37-
38-
### Fixes
40+
### Security
3941

42+
- **Accurate secret scan line numbers** — The secret scanner now parses `@@` hunk headers to report accurate source line numbers for potential secrets, instead of absolute diff line numbers.
4043
- **API key validation ordering**`set-key`, `get-key`, `init`, `config`, `completions`, and `hook` commands no longer require an API key to be present. CLI `--provider` flag now applies before keyring lookup.
4144
- **Platform-native keyring backends** — keyring v3 now uses macOS Keychain (`apple-native`), Windows Credential Manager (`windows-native`), and Linux Secret Service (`linux-native`) instead of a mock file-based backend.
4245
- **SecretString for API keys** — API keys stored as `secrecy::SecretString` in Config and provider structs. Memory zeroed on drop, never exposed except at HTTP header insertion.
4346
- **Overflow checks in release builds**`overflow-checks = true` added to release profile for ANSSI-FR compliance.
4447

48+
### Performance
49+
50+
- **Optimized symbol dependency merging** — Improved `CommitSplitter` performance for large commits by pre-indexing symbols and optimizing diff scanning.
51+
52+
### Prompt Quality
53+
54+
- **Token budget rebalance** — Symbol budget reduced from 30% to 20% when structural diffs are available, freeing space for the raw diff. SYSTEM_PROMPT updated to guide the LLM to prefer STRUCTURED CHANGES for signature details.
55+
- **Unsafe constraint rule** — When `unsafe` is added to a function, a CONSTRAINTS rule instructs the LLM to mention safety justification in the commit body.
56+
4557
### Testing
4658

47-
- **424 tests** total (up from 367 at v0.5.0).
59+
- **442 tests** total (up from 367 at v0.5.0).
4860

4961
## `v0.5.0` — Beyond the Diff
5062

@@ -79,7 +91,7 @@ All notable changes to CommitBee are documented here.
7991
- **Evaluation harness** — 36 fixtures covering all 11 commit types, AST features, and edge cases. Per-type accuracy reporting with `EvalSummary`.
8092
- **15+ new unit tests** — Coverage for `detect_primary_change`, `detect_metadata_breaking`, `detect_bug_evidence` (all 7 patterns), Deleted/Renamed status, signature edge cases, connection content assertions.
8193
- **5 fuzz targets**`fuzz_sanitizer`, `fuzz_safety`, `fuzz_diff_parser`, `fuzz_signature`, `fuzz_classify_span`.
82-
- **367 tests** total (up from 308 at v0.4.0). Current count at v0.6.0-rc.1: 410.
94+
- **367 tests** total (up from 308 at v0.4.0).
8395

8496
### API
8597

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
[package]
66
name = "commitbee"
7-
version = "0.6.0-rc.1"
7+
version = "0.6.0-dev"
88
edition = "2024"
99
rust-version = "1.94"
1010
description = "AI-powered commit message generator using tree-sitter semantic analysis and local LLMs"

PRD.md

Lines changed: 37 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,23 +6,25 @@ SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Commercial
66

77
# CommitBee — Product Requirements Document
88

9-
**Version**: 5.2
10-
**Date**: 2026-03-28
9+
**Version**: 5.4
10+
**Date**: 2026-04-07
1111
**Status**: Active
12-
**Author**: [Sephyi](https://github.com/Sephyi) + [Claude Opus 4.6](https://www.anthropic.com/news/claude-opus-4-6)
12+
**Author**: [Sephyi](https://github.com/Sephyi) + Junie (LLM Agent)
1313

1414
## Changelog
1515

1616
<details>
17-
<summary>Revision history (v3.3 → v5.2)</summary>
17+
<summary>Revision history (v3.3 → v6.0)</summary>
1818

1919
| Version | Date | Summary |
2020
| ------- | ---------- | ------- |
21+
| 5.4 | 2026-04-07 | v0.6.0-dev: Added FR-081 (Interactive Message Refinement). Updated test count to 442. |
22+
| 5.3 | 2026-04-07 | v0.6.0-dev: Added FR-076 to FR-080 (Interactive editing, optimized splitter, native clipboard, secret scan accuracy, struct/enum diff completion). Updated test count to 440. |
2123
| 5.2 | 2026-03-28 | Security hardening: `secrecy::SecretString` for API keys (F-004), overflow-checks in release profile (F-001). Updated SR-002, DR-005, DR-006. |
2224
| 5.1 | 2026-03-28 | fix: keyring platform-native backends, API key validation ordering for set-key command. Updated FR-019 and SR-002. |
2325
| 5.0 | 2026-03-28 | PRD structural overhaul: removed stale §3.1 Resolved Issues (all v0.2.0), removed Dependency Status table, removed dead ORCommit references. Updated §2 competitive landscape for 2026 (added IDE-native competitors: GitHub Copilot Desktop, Cursor, Windsurf; updated star counts; refreshed feature matrix). Updated §3 codebase structure (added diff.rs, differ.rs, progress.rs). Updated PE-001/PE-002 with v0.6.0 prompt sections (STRUCTURED CHANGES, IMPORTS, RELATED FILES, INTENT). Updated PR-005 with adaptive budget. Added v0.6.0 feature section §4.6 (FR-064–FR-072). Renumbered Future to §4.7. |
2426
| 4.4 | 2026-03-27 | Added future requirements from audit: FR-073 (move detection), FR-074 (AST-based splitting), FR-075 (configurable categorization), TR-008 (LLM quality testing), PE-007 (token-accurate budgets). |
25-
| 4.3 | 2026-03-27 | v0.6.0-rc.1 deep semantic understanding: parent scope, import detection, doc-vs-code, structural AST diffs, semantic markers (FR-071), change intent (FR-072). 424 tests. |
27+
| 4.3 | 2026-03-27 | v0.6.0-dev deep semantic understanding: parent scope, import detection, doc-vs-code, structural AST diffs, semantic markers (FR-071), change intent (FR-072). 424 tests. |
2628
| 4.2 | 2026-03-22 | v0.5.0 hardening: security fixes (SSRF prevention, streaming caps), prompt optimization (budget fix, evidence omission, emoji removal), eval harness (36 fixtures, per-type reporting), test coverage (15+ new tests), API hygiene (pub(crate) demotions), 5 fuzz targets. 359 tests. |
2729
| 4.1 | 2026-03-22 | AST context overhaul (v0.5.0): full signature extraction from tree-sitter nodes, semantic change classification (whitespace vs body vs signature), old→new signature diffs, cross-file connection detection, formatting auto-detection via symbols. 359 tests. |
2830
| 4.0 | 2026-03-13 | PRD normalization: aligned phases with shipped versions (v0.2.0/v0.3.x/v0.4.0), collapsed revision history, unified status markers, resolved stale critical issues, canonicalized test count to 308, removed dead cross-references. FR-031 (Exclude Files) and FR-033 (Copy to Clipboard) shipped. |
@@ -66,7 +68,7 @@ CommitBee is a Rust-native CLI tool that uses tree-sitter semantic analysis and
6668
| v0.3.1 | Patch — default model → `qwen3.5:4b`, subject length validation, `think` config | None |
6769
| v0.4.0 | Feature completion (templates, languages, rename detection, history learning) | None |
6870
| v0.5.0 | AST context overhaul (signatures, semantic classification, cross-file connections) | None |
69-
| v0.6.0-rc.1 | Deep semantic understanding (parent scope, imports, doc-vs-code, structural AST diffs) | None |
71+
| v0.6.0-dev | Deep semantic understanding (parent scope, imports, doc-vs-code, structural AST diffs, native clipboard, interactive edit) | None |
7072

7173
## 2. Competitive Landscape
7274

@@ -98,7 +100,7 @@ CommitBee is a Rust-native CLI tool that uses tree-sitter semantic analysis and
98100
| Multiple message generation (pick from N) | Common (aicommits, aicommit2) | ✅ v0.2.0 |
99101
| Commit splitting (multi-concern detection) | No competitor has this | ✅ v0.2.0 |
100102
| Custom prompt/instruction files | Growing (Copilot, aicommit2) | ✅ v0.4.0 |
101-
| Unit/integration tests | Non-negotiable for quality |424 tests |
103+
| Unit/integration tests | Non-negotiable for quality |442 tests |
102104

103105
## 3. Architecture
104106

@@ -457,7 +459,7 @@ Project-level `.commitbee.toml` can no longer override `openai_base_url`, `anthr
457459

458460
Subject character budget accounts for `!` suffix on breaking changes. EVIDENCE section omitted when all flags are default (~200 chars saved). Symbol marker legend added to SYSTEM_PROMPT (`[+] added, [-] removed, [~] modified`). Duplicate JSON schema removed from system prompt. Emoji replaced with text labels (`WARNING:` instead of ``). CONNECTIONS instruction softened for small models. Python tree-sitter queries enhanced with `decorated_definition` support.
459461

460-
### 4.6 Shipped — v0.6.0-rc.1 (Deep Semantic Understanding)
462+
### 4.6 Shipped — v0.6.0-dev (Deep Semantic Understanding)
461463

462464
#### FR-064: Parent Scope Extraction ✅
463465

@@ -495,6 +497,30 @@ In `infer_commit_type`, when >80% of additions are in `FileCategory::Test` files
495497

496498
`detect_intents()` scans added diff lines for error handling patterns (9 patterns including `Result<>`, `?`, `Err()`, `.map_err()`), test patterns (6 patterns including `#[test]`, `assert!`), logging patterns (9 patterns including `tracing::`, `debug!()`, `info!()`), and dependency updates (version changes in manifests). `INTENT:` prompt section shows detected patterns with confidence scores. `refine_type_with_intents()` conservatively overrides base type only for high-confidence performance optimization. 7 tests.
497499

500+
#### FR-076: Interactive Commit Editing ✅
501+
502+
Added an "Edit" choice to the candidate selection and confirmation menu. Users can refine the generated message using their system editor (via the `EDITOR` env var) before committing, allowing for final manual tweaks without leaving the tool's flow.
503+
504+
#### FR-077: Optimized Symbol Dependency Merging ✅
505+
506+
Improved `CommitSplitter` performance for large commits by pre-indexing symbols and optimizing diff scanning. Reduces complexity from $O(F \times S \times L)$ to $O(F \times L)$, where F is files, S is symbols, and L is diff lines. Ensures commit splitting remains fast even for large refactorings.
507+
508+
#### FR-078: Native Clipboard Implementation ✅
509+
510+
Replaced external command dependencies (`pbcopy`, `xclip`) with the `arboard` crate for a native, cross-platform clipboard implementation. (Improvement over `FR-033`).
511+
512+
#### FR-079: Accurate Secret Scan Line Numbers ✅
513+
514+
The secret scanner now parses `@@` hunk headers to correctly report the source line number of detected secrets in the staged file, instead of the absolute diff line number. (Improvement over `SR-001`).
515+
516+
#### FR-080: Full AST Diffs for Structs and Enums ✅
517+
518+
Extended `AstDiffer` to support structured diffing for structs, enums, classes, and traits, detecting added/removed fields and variants. (Completion of `FR-069`).
519+
520+
#### FR-081: Interactive Message Refinement ✅
521+
522+
Added a "Refine" option to the candidate selection and confirmation menu. Users can provide feedback to the LLM (e.g., "more detail about the API change") to regenerate the message with natural language guidance.
523+
498524
### 4.7 Future — v0.7.0+ (Market Leadership)
499525

500526
#### FR-050: MCP Server Mode
@@ -693,7 +719,7 @@ commitbee eval # Run evaluation harness (dev, feature-ga
693719

694720
## 8. Testing Requirements
695721

696-
**Current test count: 424**
722+
**Current test count: 440**
697723

698724
### TR-001: Unit Tests
699725

@@ -880,7 +906,7 @@ Replace character-based budget estimation (~4:1 char-to-token ratio approximatio
880906
| 3 | v0.4.0 | ✅ Shipped | Feature completion — templates, languages, rename, history, eval, fuzzing |
881907
| 4 | v0.4.x | ✅ Shipped | Remaining polish — exclude files (FR-031), clipboard (FR-033) |
882908
| 5 | v0.5.0 | ✅ Shipped | AST context overhaul — full signatures, semantic change classification, cross-file connections. 367 tests. |
883-
| 6 | v0.6.0-rc.1 | ✅ Shipped | Deep semantic understanding — parent scope, import detection, doc-vs-code classification, structural AST diffs, structured changes prompt section, semantic markers, change intent detection. 424 tests. |
909+
| 6 | v0.6.0-dev | 📋 Active | Deep semantic understanding — parent scope, import detection, doc-vs-code classification, structural AST diffs, structured changes prompt section, semantic markers, change intent detection. 442 tests. |
884910
| 7 | v0.7.0+ | 📋 Planned | Market leadership — MCP server, changelog, monorepo, version bumping, GitHub Action |
885911

886912
## 12. Success Metrics
@@ -895,7 +921,7 @@ Replace character-based budget estimation (~4:1 char-to-token ratio approximatio
895921
| Commit message quality | > 80% "good enough" first try | Manual evaluation + `commitbee eval` |
896922
| Secret leak rate | 0 | Integration tests with known patterns |
897923
| MSRV | Rust 1.94 (edition 2024) | CI matrix (stable + 1.94) |
898-
| Test count | ≥ 308 | `cargo test` (current: 424) |
924+
| Test count | ≥ 308 | `cargo test` (current: 440) |
899925

900926
## 13. Non-Goals
901927

0 commit comments

Comments
 (0)