Skip to content

Commit 9592ee2

Browse files
authored
Update dependencies and improve diff line handling logic (#56)
1 parent c959dcc commit 9592ee2

16 files changed

+1490
-91
lines changed

.github/copilot-instructions.md

Lines changed: 492 additions & 0 deletions
Large diffs are not rendered by default.

.github/workflows/cd.yml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,10 @@ jobs:
3737
- os: ubuntu-latest
3838
target: x86_64-unknown-linux-musl
3939
steps:
40-
- uses: actions/checkout@v4
40+
- uses: actions/checkout@v5
41+
- uses: Swatinem/rust-cache@v2
42+
with:
43+
cache-on-failure: true
4144

4245
- name: Setup Rust
4346
uses: dtolnay/rust-toolchain@nightly
@@ -84,7 +87,8 @@ jobs:
8487
runs-on: ubuntu-latest
8588
needs: artifact
8689
steps:
87-
- uses: actions/checkout@v4
90+
- uses: actions/checkout@v5
91+
- uses: Swatinem/rust-cache@v2
8892

8993
- name: Setup Rust
9094
uses: dtolnay/rust-toolchain@nightly

.github/workflows/ci.yml

Lines changed: 19 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -10,30 +10,23 @@ concurrency:
1010

1111
env:
1212
CARGO_TERM_COLOR: always
13+
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
1314

1415
jobs:
1516
lint:
1617
runs-on: ubuntu-latest
1718
steps:
18-
- name: Checkout code
19-
uses: actions/checkout@v3
19+
- uses: actions/checkout@v5
20+
- uses: Swatinem/rust-cache@v2
21+
with:
22+
cache-on-failure: true
2023

2124
- name: Setup nightly toolchain
2225
uses: actions-rs/toolchain@v1
2326
with:
2427
components: rustfmt, clippy
2528
toolchain: nightly
2629

27-
- uses: actions/cache@v3
28-
with:
29-
path: |
30-
~/.cargo/bin/
31-
~/.cargo/registry/index/
32-
~/.cargo/registry/cache/
33-
~/.cargo/git/db/
34-
target/
35-
key: ${{ runner.os }}-nightly-${{ hashFiles('**/Cargo.lock') }}
36-
3730
- name: Run clippy
3831
uses: actions-rs/cargo@v1
3932
with:
@@ -45,6 +38,7 @@ jobs:
4538
with:
4639
command: fmt
4740
args: -- --check
41+
4842
test:
4943
needs: lint
5044
strategy:
@@ -55,8 +49,10 @@ jobs:
5549
runs-on: ${{ matrix.os }}
5650
continue-on-error: false
5751
steps:
58-
- name: Checkout code
59-
uses: actions/checkout@v4
52+
- uses: actions/checkout@v5
53+
- uses: Swatinem/rust-cache@v2
54+
with:
55+
cache-on-failure: true
6056

6157
- name: Set up Rust
6258
uses: actions-rs/toolchain@v1
@@ -65,29 +61,18 @@ jobs:
6561
override: true
6662
profile: minimal
6763

68-
- uses: actions/cache@v4
69-
with:
70-
path: |
71-
~/.cargo/bin/
72-
~/.cargo/registry/index/
73-
~/.cargo/registry/cache/
74-
~/.cargo/git/db/
75-
target/
76-
key: ${{ runner.os }}-${{ matrix.rust }}-${{ hashFiles('**/Cargo.lock') }}
77-
restore-keys: ${{ runner.os }}-${{ matrix.rust }}-
78-
79-
- name: Install fish on linux
64+
- name: Install fish (Linux)
8065
if: startsWith(matrix.os, 'ubuntu')
81-
run: sudo apt-get install fish
66+
run: sudo apt install fish
8267

83-
- name: Install fish on macos
68+
- name: Install fish (macOS)
8469
if: startsWith(matrix.os, 'macos')
8570
run: brew install fish
8671

8772
- name: Run integration tests
88-
run: |
89-
./scripts/integration-tests
90-
cargo build --release
91-
cargo test --release
92-
env:
93-
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
73+
run: fish ./scripts/integration-tests
74+
75+
- name: Run cargo test
76+
uses: actions-rs/cargo@v1
77+
with:
78+
command: test
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
---
2+
name: "Copilot Setup Steps"
3+
4+
on:
5+
workflow_dispatch:
6+
push:
7+
paths:
8+
- .github/workflows/copilot-setup-steps.yml
9+
pull_request:
10+
paths:
11+
- .github/workflows/copilot-setup-steps.yml
12+
13+
concurrency:
14+
group: ${{ github.workflow }}-${{ github.head_ref || github.ref }}-copilot-setup-steps
15+
cancel-in-progress: true
16+
17+
env:
18+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
19+
CARGO_TERM_COLOR: always
20+
21+
jobs:
22+
copilot-setup-steps:
23+
runs-on: ubuntu-latest
24+
permissions:
25+
contents: write
26+
actions: write
27+
packages: write
28+
pull-requests: write
29+
issues: write
30+
checks: write
31+
deployments: write
32+
steps:
33+
- name: Checkout code
34+
uses: actions/checkout@v5
35+
36+
- name: Cache Rust dependencies
37+
uses: Swatinem/rust-cache@v2
38+
with:
39+
cache-on-failure: true
40+
41+
- name: Setup Rust nightly toolchain
42+
uses: actions-rust-lang/setup-rust-toolchain@v1
43+
44+
- run: cargo install --path . --debug
45+
- run: git ai hook install
46+
- run: git ai config set openai-api-key ${{ secrets.OPENAI_API_KEY }}
47+
- run: git ai config set model gpt-4.1

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,4 @@ finetune_verify.jsonl
1010
finetune_train.jsonl
1111

1212
**/.claude/settings.local.json
13+
test-repo/

CLAUDE.md

Lines changed: 43 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,10 +111,12 @@ The project is structured into several core components:
111111

112112
8. **Function Calling** (`src/function_calling.rs`): Implements OpenAI function calling for structured commit message generation with reasoning and file change summaries.
113113

114-
9. **Multi-Step Analysis** (`src/multi_step_analysis.rs` and `src/multi_step_integration.rs`): Implements the sophisticated divide-and-conquer approach that analyzes files individually, calculates impact scores, and generates multiple commit message candidates.
114+
9. **Multi-Step Analysis** (`src/multi_step_analysis.rs` and `src/multi_step_integration.rs`): Implements the sophisticated divide-and-conquer approach that analyzes files individually, calculates impact scores, and generates multiple commit message candidates. The integration module uses parallel processing via `join_all` to analyze multiple files concurrently.
115115

116116
10. **Profiling** (`src/profiling.rs`): Performance profiling utilities to measure execution time of various operations.
117117

118+
11. **Debug Output** (`src/debug_output.rs`): Provides debugging session tracking for multi-step analysis, including file analysis results, timings, and payloads.
119+
118120
## Key Workflows
119121

120122
1. **Hook Installation**: When `git-ai hook install` is run, the tool symlinks its executable to the repository's `.git/hooks/prepare-commit-msg` hook.
@@ -160,6 +162,12 @@ cargo test
160162
# Run specific tests
161163
cargo test test_empty_diff
162164

165+
# Run specific test with debugging output
166+
RUST_LOG=debug cargo test --lib -- multi_step_integration::tests::test_parse_diff_with_c_i_prefixes --exact --nocapture
167+
168+
# Run all multi-step integration tests
169+
RUST_LOG=debug cargo test --lib multi_step_integration::tests --no-fail-fast
170+
163171
# Run comprehensive tests
164172
./scripts/comprehensive-tests
165173

@@ -186,3 +194,37 @@ git commit --all --no-edit
186194
```
187195

188196
The commit message will be automatically generated based on the staged changes.
197+
198+
## Code Style and Conventions
199+
200+
Based on the project's Cursor rules:
201+
202+
### Formatting
203+
- Use `rustfmt.toml` with `edition = "2021"` and `max_width = 100`
204+
- Keep imports grouped: std → external → internal, then alphabetized
205+
- Run `cargo fmt` before committing
206+
207+
### Naming
208+
- snake_case for items and functions
209+
- SCREAMING_SNAKE_CASE for constants
210+
- PascalCase for types and traits
211+
- crate names use kebab-case
212+
213+
### Error Handling
214+
- Use `thiserror` for typed errors; `anyhow::Result<T>` for binaries
215+
- Prefer `?` operator over `unwrap`/`expect` in library code
216+
217+
### Module Organization
218+
- Files with underscores should be nested directories (e.g., `foo_bar.rs``foo/bar.rs`)
219+
- Public re-exports go in `lib.rs` for clean API surface
220+
- Avoid deep module trees (>3 levels)
221+
222+
### Testing
223+
- Each module should have `#[cfg(test)] mod tests { use super::*; ... }`
224+
- Integration tests in `tests/` directory use only public API
225+
- Run tests with debugging: `RUST_LOG=debug cargo test`
226+
227+
### Performance
228+
- Use parallel processing for large operations (see `multi_step_integration.rs` using `join_all`)
229+
- Token management and smart truncation for API limits
230+
- Profile with `profiling.rs` utilities

Cargo.lock

Lines changed: 33 additions & 18 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@ tracing = "0.1"
4848
# CLI and UI
4949

5050
colored = "3.0.0"
51-
console = { version = "0.15.11", default-features = false }
52-
indicatif = { version = "0.17.11", default-features = false }
51+
console = { version = "0.16", default-features = false }
52+
indicatif = { version = "0.18", default-features = false }
5353
log = "0.4.27"
5454
env_logger = { version = "0.11.8", default-features = false }
5555

@@ -65,7 +65,7 @@ serde_ini = "0.2.0"
6565
serde_json = "1.0"
6666

6767
# OpenAI integration
68-
async-openai = { version = "0.28.1", default-features = false }
68+
async-openai = { version = "0.29", default-features = false }
6969
tiktoken-rs = "0.7.0"
7070
reqwest = { version = "0.12.15", default-features = true }
7171

0 commit comments

Comments
 (0)