gitview 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,161 @@
1
+ # Installation Guide
2
+
3
+ ## Three Ways to Use GitView
4
+
5
+ ### 1. System Installation (Recommended)
6
+
7
+ **What happens:** Creates a `gitview` command available system-wide
8
+
9
+ ```bash
10
+ pip install -e .
11
+ ```
12
+
13
+ This reads the configuration from `pyproject.toml` and `setup.py`:
14
+ - Installs all dependencies from `requirements.txt`
15
+ - Creates entry point: `gitview` → `gitview.cli:main()`
16
+ - Puts executable wrapper in `/usr/local/bin/gitview` (or platform equivalent)
17
+
18
+ **Verify:**
19
+ ```bash
20
+ which gitview # Shows: /usr/local/bin/gitview
21
+ gitview --version
22
+ ```
23
+
24
+ **Files involved:**
25
+ - `pyproject.toml` - Modern Python packaging config
26
+ - `setup.py` - Traditional setup script (compatible with pyproject.toml)
27
+ - `requirements.txt` - Dependencies list
28
+
29
+ ---
30
+
31
+ ### 2. Direct Execution (No Installation)
32
+
33
+ **What happens:** Run directly from the repo using the wrapper script
34
+
35
+ ```bash
36
+ pip install -r requirements.txt # Dependencies only
37
+ ./bin/gitview analyze
38
+ ```
39
+
40
+ **Files involved:**
41
+ - `bin/gitview` - Executable Python script that imports `gitview.cli:main()`
42
+
43
+ **Useful for:**
44
+ - Development without polluting system PATH
45
+ - Testing changes without reinstalling
46
+ - Running from a git clone without pip install
47
+
48
+ ---
49
+
50
+ ### 3. Python Module Mode
51
+
52
+ **What happens:** Run as a Python module
53
+
54
+ ```bash
55
+ pip install -r requirements.txt # Dependencies only
56
+ python -m gitview.cli analyze
57
+ ```
58
+
59
+ **Files involved:**
60
+ - `gitview/cli.py` - Contains `main()` function and CLI definition
61
+
62
+ **Useful for:**
63
+ - Debugging with Python debugger
64
+ - Running in environments without executable permissions
65
+ - Scripting where you want explicit Python invocation
66
+
67
+ ---
68
+
69
+ ## Understanding the Entry Point
70
+
71
+ All three methods ultimately call the same function: `gitview.cli:main()`
72
+
73
+ ### Method 1: System Installation
74
+ ```
75
+ gitview
76
+
77
+ /usr/local/bin/gitview (auto-generated wrapper)
78
+
79
+ gitview.cli:main()
80
+ ```
81
+
82
+ ### Method 2: Direct Execution
83
+ ```
84
+ ./bin/gitview (explicit wrapper script)
85
+
86
+ gitview.cli:main()
87
+ ```
88
+
89
+ ### Method 3: Module Mode
90
+ ```
91
+ python -m gitview.cli
92
+
93
+ gitview.cli:main()
94
+ ```
95
+
96
+ ---
97
+
98
+ ## Files Explained
99
+
100
+ ### `setup.py`
101
+ Traditional Python setup script. Defines:
102
+ - Package metadata (name, version, author)
103
+ - Dependencies from `requirements.txt`
104
+ - Entry points (console scripts)
105
+
106
+ ### `pyproject.toml`
107
+ Modern Python packaging standard (PEP 518). Defines:
108
+ - Build system requirements
109
+ - Project metadata
110
+ - Dependencies
111
+ - Entry points via `[project.scripts]`
112
+
113
+ ### `bin/gitview`
114
+ Simple executable Python script:
115
+ ```python
116
+ #!/usr/bin/env python3
117
+ if __name__ == "__main__":
118
+ from gitview.cli import main
119
+ main()
120
+ ```
121
+
122
+ ### How `/usr/local/bin/gitview` Gets Created
123
+
124
+ When you run `pip install -e .`:
125
+
126
+ 1. Pip reads `[project.scripts]` from `pyproject.toml`:
127
+ ```toml
128
+ [project.scripts]
129
+ gitview = "gitview.cli:main"
130
+ ```
131
+
132
+ 2. Pip generates a wrapper script at `/usr/local/bin/gitview`:
133
+ ```python
134
+ #!/usr/bin/env python
135
+ # -*- coding: utf-8 -*-
136
+ import re
137
+ import sys
138
+ from gitview.cli import main
139
+ if __name__ == '__main__':
140
+ sys.exit(main())
141
+ ```
142
+
143
+ 3. Makes it executable (`chmod +x`)
144
+
145
+ 4. Now `gitview` command works from anywhere!
146
+
147
+ ---
148
+
149
+ ## Verification
150
+
151
+ Run the verification script to check your installation:
152
+
153
+ ```bash
154
+ python verify_installation.py
155
+ ```
156
+
157
+ This checks:
158
+ - ✓ Python version (3.8+)
159
+ - ✓ All dependencies installed
160
+ - ✓ `gitview` command availability
161
+ - ✓ LLM backends configured
gitview-0.1.0/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 GitView Contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,27 @@
1
+ # Include important files in source distribution
2
+ include README.md
3
+ include LICENSE
4
+ include INSTALL.md
5
+ include requirements.txt
6
+ include verify_installation.py
7
+
8
+ # Include executable wrapper
9
+ recursive-include bin *
10
+
11
+ # Include examples
12
+ recursive-include examples *.py
13
+
14
+ # Exclude unnecessary files
15
+ global-exclude __pycache__
16
+ global-exclude *.py[co]
17
+ global-exclude .DS_Store
18
+ global-exclude *.so
19
+ global-exclude .git*
20
+
21
+ # Exclude output and test files
22
+ exclude output/
23
+ exclude test_output/
24
+ exclude *.jsonl
25
+ exclude docs/history_story.md
26
+ exclude docs/history_data.json
27
+ exclude docs/timeline.md
gitview-0.1.0/PKG-INFO ADDED
@@ -0,0 +1,468 @@
1
+ Metadata-Version: 2.4
2
+ Name: gitview
3
+ Version: 0.1.0
4
+ Summary: Git history analyzer with LLM-powered narrative generation
5
+ Home-page: https://github.com/carstenbund/gitview
6
+ Author: GitView Contributors
7
+ Author-email:
8
+ Maintainer: GitView Contributors
9
+ License: MIT
10
+ Project-URL: Homepage, https://github.com/carstenbund/gitview
11
+ Project-URL: Documentation, https://github.com/carstenbund/gitview/blob/main/README.md
12
+ Project-URL: Repository, https://github.com/carstenbund/gitview
13
+ Project-URL: Issues, https://github.com/carstenbund/gitview/issues
14
+ Keywords: git,history,analyzer,llm,narrative,ai,claude,openai,ollama
15
+ Classifier: Development Status :: 3 - Alpha
16
+ Classifier: Intended Audience :: Developers
17
+ Classifier: Intended Audience :: Information Technology
18
+ Classifier: Topic :: Software Development :: Version Control :: Git
19
+ Classifier: Topic :: Software Development :: Documentation
20
+ Classifier: Topic :: Text Processing :: Markup :: Markdown
21
+ Classifier: License :: OSI Approved :: MIT License
22
+ Classifier: Programming Language :: Python :: 3
23
+ Classifier: Programming Language :: Python :: 3.8
24
+ Classifier: Programming Language :: Python :: 3.9
25
+ Classifier: Programming Language :: Python :: 3.10
26
+ Classifier: Programming Language :: Python :: 3.11
27
+ Classifier: Programming Language :: Python :: 3.12
28
+ Classifier: Operating System :: OS Independent
29
+ Classifier: Environment :: Console
30
+ Requires-Python: >=3.8
31
+ Description-Content-Type: text/markdown
32
+ License-File: LICENSE
33
+ Requires-Dist: anthropic>=0.39.0
34
+ Requires-Dist: openai>=1.0.0
35
+ Requires-Dist: requests>=2.31.0
36
+ Requires-Dist: gitpython>=3.1.40
37
+ Requires-Dist: python-dateutil>=2.8.2
38
+ Requires-Dist: click>=8.1.7
39
+ Requires-Dist: rich>=13.7.0
40
+ Requires-Dist: pydantic>=2.5.0
41
+ Dynamic: home-page
42
+ Dynamic: license-file
43
+ Dynamic: requires-python
44
+
45
+ # GitView
46
+
47
+ **Git history analyzer with LLM-powered narrative generation**
48
+
49
+ GitView extracts your repository's git history and uses AI to generate compelling narratives about how your codebase evolved. Instead of manually reading through thousands of commits, get a comprehensive story of your project's journey.
50
+
51
+ Example run on this repository:
52
+
53
+ [[(https://github.com/carstenbund/gitview/blob/main/output/history_story.md)]
54
+ ](https://github.com/carstenbund/gitview/blob/main/output/history_story.md)
55
+
56
+ ## Features
57
+
58
+ - ** Comprehensive History Extraction**: Extracts commit metadata, LOC changes, language breakdown, README evolution, comment analysis, and more
59
+ - ** Smart Chunking**: Automatically divides history into meaningful "phases" or "epochs" based on significant changes
60
+ - ** LLM-Powered Summaries**: Uses Claude to generate narrative summaries for each phase
61
+ - ** Global Story Generation**: Combines phase summaries into executive summaries, timelines, technical retrospectives, and deletion stories
62
+ - ** Multiple Output Formats**: Generates markdown reports, JSON data, and timelines
63
+
64
+ ## Installation
65
+
66
+ ### Option 1: Install with pip (recommended)
67
+
68
+ This creates a `gitview` command in your PATH:
69
+
70
+ ```bash
71
+ # Clone the repository
72
+ git clone https://github.com/yourusername/gitview.git
73
+ cd gitview
74
+
75
+ # Install in editable mode with dependencies
76
+ pip install -e .
77
+
78
+ # The gitview command is now available system-wide
79
+ gitview --version
80
+ gitview --help
81
+ ```
82
+
83
+ **How it works:** The `pip install -e .` command reads `pyproject.toml` and `setup.py`, which define an entry point that creates `/usr/local/bin/gitview` (or similar on Windows) that calls `gitview.cli:main`.
84
+
85
+ ### Option 2: Run directly from repo (no installation)
86
+
87
+ Use the executable wrapper in `bin/`:
88
+
89
+ ```bash
90
+ # Clone the repository
91
+ git clone https://github.com/yourusername/gitview.git
92
+ cd gitview
93
+
94
+ # Install dependencies only
95
+ pip install -r requirements.txt
96
+
97
+ # Run directly from the repo
98
+ ./bin/gitview --version
99
+ ./bin/gitview analyze
100
+
101
+ # Or add bin/ to your PATH
102
+ export PATH="$PWD/bin:$PATH"
103
+ gitview analyze
104
+ ```
105
+
106
+ ### Option 3: Run as Python module
107
+
108
+ ```bash
109
+ # Install dependencies
110
+ pip install -r requirements.txt
111
+
112
+ # Run as a module
113
+ python -m gitview.cli --help
114
+ python -m gitview.cli analyze
115
+ ```
116
+
117
+ ### Verify Installation
118
+
119
+ Run the verification script to check everything is set up correctly:
120
+
121
+ ```bash
122
+ python verify_installation.py
123
+ ```
124
+
125
+ This will check:
126
+ - Python version (3.8+ required)
127
+ - All required dependencies
128
+ - `gitview` command availability
129
+ - LLM backend configuration (API keys, Ollama server)
130
+
131
+ ### Troubleshooting Installation
132
+
133
+ If `gitview` command is not found after installation:
134
+
135
+ ```bash
136
+ # Option 1: Use full path to module
137
+ python -m gitview.cli analyze
138
+
139
+ # Option 2: Reinstall in editable mode
140
+ pip uninstall gitview -y
141
+ pip install -e .
142
+
143
+ # Option 3: Check if it's in your PATH
144
+ which gitview # Unix/Linux/Mac
145
+ where gitview # Windows
146
+ ```
147
+
148
+ ## Quick Start
149
+
150
+ ```bash
151
+ # Using Anthropic Claude (default)
152
+ export ANTHROPIC_API_KEY="your-api-key-here"
153
+ gitview analyze
154
+
155
+ # Using OpenAI GPT
156
+ export OPENAI_API_KEY="your-api-key-here"
157
+ gitview analyze --backend openai
158
+
159
+ # Using local Ollama (no API key needed)
160
+ gitview analyze --backend ollama --model llama3
161
+
162
+ # Skip LLM summarization (just extract and chunk)
163
+ gitview analyze --skip-llm
164
+ ```
165
+
166
+ ## Usage
167
+
168
+ ### Full Analysis Pipeline
169
+
170
+ The main command runs the complete pipeline: extract → chunk → summarize → story → output
171
+
172
+ ```bash
173
+ gitview analyze [OPTIONS]
174
+
175
+ Options:
176
+ -r, --repo PATH Path to git repository (default: current directory)
177
+ -o, --output PATH Output directory (default: "output")
178
+ -s, --strategy STRATEGY Chunking strategy: fixed, time, or adaptive (default: adaptive)
179
+ --chunk-size INTEGER Chunk size for fixed strategy (default: 50)
180
+ --max-commits INTEGER Maximum commits to analyze
181
+ --branch TEXT Branch to analyze (default: HEAD)
182
+ -b, --backend BACKEND LLM backend: anthropic, openai, or ollama (auto-detected)
183
+ -m, --model TEXT Model identifier (uses backend defaults if not specified)
184
+ --api-key TEXT API key for the backend (defaults to env var)
185
+ --ollama-url TEXT Ollama API URL (default: http://localhost:11434)
186
+ --repo-name TEXT Repository name for output
187
+ --skip-llm Skip LLM summarization (extract and chunk only)
188
+ ```
189
+
190
+ ### Extract Only
191
+
192
+ Extract git history to JSONL file without LLM processing:
193
+
194
+ ```bash
195
+ gitview extract --repo /path/to/repo --output history.jsonl
196
+ ```
197
+
198
+ ### Chunk Only
199
+
200
+ Chunk an extracted JSONL file into phases:
201
+
202
+ ```bash
203
+ gitview chunk history.jsonl --output ./phases --strategy adaptive
204
+ ```
205
+
206
+ ## Chunking Strategies
207
+
208
+ GitView supports three chunking strategies:
209
+
210
+ ### 1. **Adaptive** (Recommended)
211
+
212
+ Automatically splits history when significant changes occur:
213
+ - LOC changes by >30%
214
+ - Large deletions/additions detected
215
+ - README rewrites
216
+ - Major refactorings
217
+
218
+ ```bash
219
+ gitview analyze --strategy adaptive
220
+ ```
221
+
222
+ ### 2. **Fixed Size**
223
+
224
+ Splits history into fixed-size chunks (e.g., 50 commits per phase):
225
+
226
+ ```bash
227
+ gitview analyze --strategy fixed --chunk-size 50
228
+ ```
229
+
230
+ ### 3. **Time-Based**
231
+
232
+ Splits by time periods (week, month, quarter, year):
233
+
234
+ ```bash
235
+ gitview analyze --strategy time --period quarter
236
+ ```
237
+
238
+ ## Output Files
239
+
240
+ GitView generates several output files:
241
+
242
+ ```
243
+ output/
244
+ ├── repo_history.jsonl # Raw commit data
245
+ ├── phases/ # Phase data
246
+ │ ├── phase_01.json
247
+ │ ├── phase_02.json
248
+ │ └── phase_index.json
249
+ ├── history_story.md # Main narrative report
250
+ ├── timeline.md # Simple timeline
251
+ └── history_data.json # Complete data in JSON
252
+ ```
253
+
254
+ ### Main Report (`history_story.md`)
255
+
256
+ Contains:
257
+ - **Executive Summary**: High-level overview for stakeholders
258
+ - **Timeline**: Chronological phases with descriptive headings
259
+ - **Full Narrative**: Complete story of the codebase evolution
260
+ - **Technical Evolution**: Architectural journey and key decisions
261
+ - **Story of Deletions**: What was removed and why
262
+ - **Phase Details**: Detailed breakdown of each phase
263
+ - **Statistics**: Comprehensive metrics
264
+
265
+ ## How It Works
266
+
267
+ ### Phase 1: Extract Raw History
268
+
269
+ Analyzes git commits and extracts:
270
+ - Commit metadata (hash, author, date, message)
271
+ - Lines of code changes (insertions/deletions)
272
+ - File statistics
273
+ - Language breakdown
274
+ - README state and changes
275
+ - Code comments and density
276
+ - Detection of large changes, refactors, etc.
277
+
278
+ ### Phase 2: Chunk into Epochs
279
+
280
+ Divides history into meaningful phases based on:
281
+ - Significant LOC changes
282
+ - Large deletions or additions
283
+ - Language mix changes
284
+ - README rewrites
285
+ - Major refactorings
286
+
287
+ ### Phase 3: Summarize Each Phase
288
+
289
+ Uses Claude to generate narrative summaries for each phase, answering:
290
+ - What were the main activities?
291
+ - Why were changes made?
292
+ - What was deleted/added and why?
293
+ - How did documentation evolve?
294
+ - What do commit messages reveal?
295
+
296
+ ### Phase 4: Generate Global Story
297
+
298
+ Combines phase summaries to create:
299
+ - Executive summary for non-technical readers
300
+ - Chronological timeline with meaningful headings
301
+ - Technical retrospective
302
+ - Story of code deletions and cleanups
303
+ - Full detailed narrative
304
+
305
+ ## Examples
306
+
307
+ ### Analyze a Large Open Source Project
308
+
309
+ ```bash
310
+ gitview analyze \
311
+ --repo /path/to/large-project \
312
+ --output ./project-analysis \
313
+ --strategy adaptive \
314
+ --repo-name "My Project"
315
+ ```
316
+
317
+ ### Quick Analysis Without LLM
318
+
319
+ Perfect for quick exploration or when you don't have an API key:
320
+
321
+ ```bash
322
+ gitview analyze --skip-llm --output ./quick-analysis
323
+ ```
324
+
325
+ ### Extract and Process Later
326
+
327
+ ```bash
328
+ # Extract once
329
+ gitview extract --repo /path/to/repo --output history.jsonl
330
+
331
+ # Experiment with different chunking strategies
332
+ gitview chunk history.jsonl --strategy adaptive --output ./adaptive-phases
333
+ gitview chunk history.jsonl --strategy fixed --chunk-size 25 --output ./fixed-phases
334
+ ```
335
+
336
+ ## Architecture
337
+
338
+ ```
339
+ ┌─────────────────────┐
340
+ │ Git Repository │
341
+ └──────────┬──────────┘
342
+
343
+ v
344
+ ┌─────────────────────┐
345
+ │ Extractor │ Analyzes commits, extracts metadata
346
+ │ (extractor.py) │ Output: repo_history.jsonl
347
+ └──────────┬──────────┘
348
+
349
+ v
350
+ ┌─────────────────────┐
351
+ │ Chunker │ Splits into meaningful phases
352
+ │ (chunker.py) │ Strategies: adaptive, fixed, time
353
+ └──────────┬──────────┘
354
+
355
+ v
356
+ ┌─────────────────────┐
357
+ │ Summarizer │ LLM summarizes each phase
358
+ │ (summarizer.py) │ Uses Claude API
359
+ └──────────┬──────────┘
360
+
361
+ v
362
+ ┌─────────────────────┐
363
+ │ StoryTeller │ Generates global narratives
364
+ │ (storyteller.py) │ Multiple story formats
365
+ └──────────┬──────────┘
366
+
367
+ v
368
+ ┌─────────────────────┐
369
+ │ Writer │ Outputs markdown, JSON, etc.
370
+ │ (writer.py) │
371
+ └─────────────────────┘
372
+ ```
373
+
374
+ ## Requirements
375
+
376
+ - Python 3.8+
377
+ - Git repository with commit history
378
+ - **One of the following LLM backends:**
379
+ - **Anthropic Claude** (requires API key)
380
+ - **OpenAI GPT** (requires API key)
381
+ - **Ollama** (runs locally, no API key needed)
382
+ - Dependencies: gitpython, anthropic, openai, requests, click, rich, pydantic
383
+
384
+ ## LLM Backend Configuration
385
+
386
+ GitView supports three LLM backends with automatic detection based on environment variables:
387
+
388
+ ### Anthropic Claude (Default)
389
+
390
+ Get an API key from [Anthropic](https://www.anthropic.com/)
391
+
392
+ ```bash
393
+ export ANTHROPIC_API_KEY="your-api-key-here"
394
+ gitview analyze
395
+ ```
396
+
397
+ Default models:
398
+ - `claude-sonnet-4-5-20250929` (default)
399
+ - `claude-3-opus-20240229` (more powerful)
400
+ - `claude-3-haiku-20240307` (faster)
401
+
402
+ ### OpenAI GPT
403
+
404
+ Get an API key from [OpenAI](https://platform.openai.com/)
405
+
406
+ ```bash
407
+ export OPENAI_API_KEY="your-api-key-here"
408
+ gitview analyze --backend openai
409
+ ```
410
+
411
+ Default models:
412
+ - `gpt-4` (default)
413
+ - `gpt-4-turbo-preview` (faster)
414
+ - `gpt-3.5-turbo` (cheaper)
415
+
416
+ ### Ollama (Local)
417
+
418
+ Install [Ollama](https://ollama.ai/) and pull a model:
419
+
420
+ ```bash
421
+ # Install Ollama
422
+ curl -fsSL https://ollama.ai/install.sh | sh
423
+
424
+ # Pull a model
425
+ ollama pull llama3
426
+
427
+ # Start Ollama server
428
+ ollama serve
429
+
430
+ # Use with GitView (no API key needed)
431
+ gitview analyze --backend ollama --model llama3
432
+ ```
433
+
434
+ Popular Ollama models:
435
+ - `llama3` (default, balanced)
436
+ - `mistral` (fast, good quality)
437
+ - `codellama` (optimized for code)
438
+ - `mixtral` (large, powerful)
439
+
440
+ ### Custom Configuration
441
+
442
+ ```bash
443
+ # Specify custom model
444
+ gitview analyze --backend anthropic --model claude-3-opus-20240229
445
+
446
+ # Use custom Ollama URL
447
+ gitview analyze --backend ollama --ollama-url http://192.168.1.100:11434
448
+
449
+ # Pass API key directly (instead of env var)
450
+ gitview analyze --backend openai --api-key "your-key"
451
+ ```
452
+
453
+ ## Use Cases
454
+
455
+ - **Technical Documentation**: Automatically generate project history documentation
456
+ - **Onboarding**: Help new developers understand codebase evolution
457
+ - **Retrospectives**: Review what worked and what didn't
458
+ - **Project Reports**: Create compelling narratives for stakeholders
459
+ - **Code Archaeology**: Understand why code evolved the way it did
460
+ - **Cleanup Planning**: Identify what to remove based on deletion history
461
+
462
+ ## Contributing
463
+
464
+ Contributions welcome! Please open an issue or submit a pull request.
465
+
466
+ ## License
467
+
468
+ MIT License - see LICENSE file for details