Skip to content

Commit 19dbf7c

Browse files
committed
Improved directory initialization, template management, and temporary file handling.
[feat] Added a feature to copy templates into $GIV_HOME/templates directory [fix] Resolved an issue where templates were not properly copied to user's project directory [chore] Improved script organization by moving common tasks to new system.sh helper functions
1 parent e612dad commit 19dbf7c

File tree

16 files changed

+201
-600
lines changed

16 files changed

+201
-600
lines changed

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,6 @@ dist
1313
.giv/tmp
1414
.giv/cache
1515
.giv/logs
16-
tests/.giv
16+
tests/.giv
17+
.notes
18+
.giv/config.bak

.giv/config

Lines changed: 34 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,39 @@
1-
GIV_TMPDIR_SAVE=1
1+
# GIV Configuration Example
2+
## Check the docs/configuration.md for more details.
23

3-
### Basic setup for Ollama CLI
4-
GIV_MODEL=devstral
5-
# Note: When using remote generation, the GIV_API_MODEL variable or the CLI --api-model arg will determine which model to use
4+
## Debugging
5+
# ### Set to "true" to enable debug mode, which provides detailed logging
6+
# GIV_DEBUG=""
7+
# ### If set to "true", enables dry run mode (no changes will be made)
8+
# GIV_DRY_RUN=""
9+
# ### Set to "true" to preserve temporary directories after execution for debugging purposes
10+
# GIV_TMPDIR_SAVE=""
11+
12+
13+
## Model and API configuration
14+
GIV_MODEL_MODE="auto"
15+
GIV_MODEL="devstral"
616

717
## Remote: groq API Configuration
818
GIV_API_URL="https://api.groq.com/openai/v1/chat/completions"
919
GIV_API_MODEL="compound-beta"
10-
GIV_API_KEY="${GROQ_API_KEY:-}"
20+
GIV_API_KEY="${GROQ_API_KEY:-}"
21+
22+
23+
## Remote: OpenAI Compatible API Configuration
24+
GIV_API_MODEL=gpt-4o-mini
25+
GIV_API_URL=https://api.openai.com/v1/chat/completions
26+
GIV_API_KEY="${OPENAI_API_KEY:-}"
27+
28+
## Project details
29+
### Path to the file containing the project version (e.g., "pyproject.toml" or "package.json")
30+
GIV_VERSION_FILE="src/config.sh"
31+
32+
### Regex pattern to extract the version string from the version file (e.g., 'version\s*=\s*"([0-9\.]+)"')
33+
GIV_VERSION_PATTERN=""
34+
35+
### Regex pattern to identify TODO comments in code (e.g., 'TODO:(.*)')
36+
GIV_TODO_PATTERN=""
37+
38+
### Comma-separated list of files or glob patterns to search for TODOs (e.g., "*.py,src/**/*.js")
39+
GIV_TODO_FILES="docs/todos.md"
File renamed without changes.

docs/code-review-01.md

Lines changed: 0 additions & 171 deletions
This file was deleted.

docs/config.example

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# GIV Configuration Example
2+
## Check the docs/configuration.md for more details.
3+
4+
## Debugging
5+
### Set to "true" to enable debug mode, which provides detailed logging
6+
GIV_DEBUG=""
7+
### If set to "true", enables dry run mode (no changes will be made)
8+
GIV_DRY_RUN=""
9+
### Set to "true" to preserve temporary directories after execution for debugging purposes
10+
GIV_TMPDIR_SAVE=""
11+
12+
## Default git revision and pathspec
13+
### GIV_REVISION="--current" uses the currently checked-out git branch or commit.
14+
GIV_REVISION="--current"
15+
GIV_PATHSPEC=""
16+
17+
## Model and API configuration
18+
GIV_MODEL_MODE="auto"
19+
GIV_MODEL="devstral"
20+
GIV_API_MODEL=""
21+
GIV_API_URL=""
22+
### Uses the OPENAI_API_KEY environment variable if set, otherwise empty
23+
GIV_API_KEY="${OPENAI_API_KEY:-}"
24+
25+
## Project details
26+
### Path to the file containing the project version (e.g., "pyproject.toml" or "package.json")
27+
GIV_VERSION_FILE=""
28+
29+
### Regex pattern to extract the version string from the version file (e.g., 'version\s*=\s*"([0-9\.]+)"')
30+
GIV_VERSION_PATTERN=""
31+
32+
### Regex pattern to identify TODO comments in code (e.g., 'TODO:(.*)')
33+
GIV_TODO_PATTERN=""
34+
35+
### Comma-separated list of files or glob patterns to search for TODOs (e.g., "*.py,src/**/*.js")
36+
GIV_TODO_FILES=""

docs/giv_folder.md

Lines changed: 0 additions & 140 deletions
This file was deleted.
File renamed without changes.

docs/roadmap/0.4.0.md

Lines changed: 31 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,46 @@
1-
21
### **Outstanding Tasks for Version 0.4.0**
32

3+
**Refactoring:**
4+
- Modularize the `summarize_target()` and `summarize_commit()` functions in `history.sh`.
5+
- Ensure edge cases like invalid commits or empty diffs are handled.
46

5-
**Refactoring:**
6-
- Simplify flow control for model invocation.
7-
- Modularize the `summarize_target()` and `summarize_commit()` functions.
8-
9-
**Configuration Enhancements:**
10-
- Implement the polished `parse_args()` function from giv_folder.md.
11-
- Add .giv initialization logic.
7+
**Testing:**
8+
- Expand tests for `summarize_target()` and `summarize_commit()` in `summarize_target.bats`.
9+
- Increase automated testing coverage for text insertion and token replacement functions.
1210

13-
**Testing:**
14-
- Increase automated testing coverage for:
15-
- Text insertion and token replacement functions.
16-
- The new `parse_args()` and .giv initialization logic.
11+
**Documentation:**
12+
- Update the roadmap and README to reflect completed and pending tasks.
1713

1814
---
1915

20-
### **Implementation Plan**
16+
### **Completed Tasks**
2117

22-
#### **Simplify Flow Control for Model Invocation**
23-
- **Steps:**
24-
1. Refactor the logic in giv.sh to streamline model invocation.
25-
2. Ensure `summarize_target()` respects `--dry-run` and skips calling the model when `--model-mode none` is set.
18+
**Configuration Enhancements:**
19+
- Implemented the polished `parse_args()` function in `args.sh`.
20+
- Added `.giv` initialization logic via `ensure_giv_dir_init` in `system.sh`.
21+
22+
**Bug Fixes:**
23+
- Resolved the `--api-key` parsing issue in `args.sh`.
24+
25+
**Testing:**
26+
- Added tests for `.giv` initialization in `test_giv_init.bats`.
27+
- Added tests for `replace_tokens` in `replace_tokens.bats`.
28+
29+
---
30+
31+
### **Implementation Plan for Remaining Tasks**
2632

2733
#### **Modularize `summarize_target()` and `summarize_commit()`**
2834
- **Steps:**
29-
1. Break down `summarize_target()` in history.sh into smaller, reusable functions.
30-
2. Ensure `summarize_commit()` in history.sh is modular and handles edge cases like invalid commits or empty diffs.
31-
35+
1. Break down `summarize_target()` into smaller, reusable functions.
36+
2. Refactor `summarize_commit()` to handle edge cases and improve readability.
3237

33-
#### **Add .giv Initialization Logic**
38+
#### **Expand Testing Coverage**
3439
- **Steps:**
35-
1. Add .giv initialization logic to system.sh using the `ensure_giv_dir()` function.
36-
2. Implement the `ensure_giv_dir()` function in giv.sh.
37-
3. Ensure it creates the .giv directory and default configuration files on the first run.
40+
1. Add unit tests for modularized `summarize_target()` and `summarize_commit()`.
41+
2. Expand tests for text insertion and token replacement functions.
3842

39-
#### **6. Increase Automated Testing Coverage**
43+
#### **Update Documentation**
4044
- **Steps:**
41-
1. Verify unit tests for `parse_args()` in test_parse_args.bats.
42-
2. Add tests for .giv initialization logic in a new test file (e.g., `tests/test_giv_init.bats`).
43-
3. Expand tests for token replacement in replace_tokens.bats.
45+
1. Update the roadmap to reflect completed tasks.
46+
2. Ensure README includes details of new features and fixes.

docs/roadmap/roadmap.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,8 @@
1010
- Simplify flow control for model invocation to improve maintainability.
1111
- Modularize the `summarize_target()` and `summarize_commit()` functions for better readability and testing.
1212
- **Configuration Enhancements:**
13-
- Implement the polished `parse_args()` function from the `giv_folder.md` file.
1413
- Add `.giv` initialization on first run with default templates and configuration.
15-
- Ensure proper precedence for configuration sources: CLI args → config file → `.giv/.givrc` → environment variables.
14+
- Ensure proper precedence for configuration sources: CLI args → config file → `.giv/config` → environment variables.
1615
- **Testing:**
1716
- Increase automated testing coverage for text insertion and token replacement functions.
1817
- Add unit tests for the new `parse_args()` and `.giv` initialization logic.

docs/todos.md

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,5 @@
11
# TODOs
22

3-
## Git Command Robustness:
4-
The use of `git diff` and `git rev-list` assumes the repository is in a clean state. If the user runs giv inside a shallow clone or with unusual ref names, some commands could fail.
5-
6-
The script does check `git rev-parse --is-inside-work-tree` early to ensure you’re in a git repo.
7-
8-
One scenario: very large diffs. Using `--compact-summary` and unified=3 limits output size, but if a commit touched 500 files, the diffstat could still be long.
9-
10-
It might be worth limiting or truncating extremely large diffs before feeding to the LLM summary (perhaps summarizing the diffstat itself). This is more a potential enhancement than a bug; currently, a huge commit might risk hitting token limits for summarization. The code doesn’t explicitly guard against that beyond the diff settings.
11-
12-
In practice, this might rarely be an issue, but it’s good to document.
13-
14-
## Environment Variable Confusion:
15-
There are both config file `.env` loading and environment variables like `GIV_MODEL`, `GIV_API_URL`, etc. The code merges these by preferring CLI args, then env vars, then defaults.
16-
17-
One thing to double-check: if the user sets `GIV_MODEL_MODE=none` (or uses `--model-mode none`), the script sets dry_run=true for generation but still goes through summarization unless explicitly handled.
18-
19-
Actually, in generate_response, if mode is "none", it doesn’t have a case and will default to local which tries Ollama (not desired). There is a check setting model_mode="none" will skip model usage and treat it effectively as dry-run.
20-
21-
This area could be refactored to make the logic clearer: e.g. a single flag that indicates “no model calls” which both summarization and final generation honor. As is, it does seem to work: model_mode none triggers warnings and then they set dry_run=true which causes generate_from_prompt to just print the prompt.
22-
23-
It might be cleaner if summarize_target also respected dry-run and skipped calling the model (currently if you do `--model-mode none`, it might still run summarize_commit which calls generate_response; though since they set model_mode="none" and pass that in, generate_response would return empty immediately or error).
24-
25-
This flow is a bit convoluted. A refactor could short-circuit summarization when no model is to be used – instead, just concatenate raw commit messages or something.
26-
27-
This ties into perhaps providing a mode where the tool generates a draft prompt for manual use (which it does via `--dry-run` or `--prompt-file` in document). Not a critical bug, but worth reviewing.
28-
29-
303

314
## Pending
325

0 commit comments

Comments
 (0)