shift-this-version 1.3.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.
- shift_this_version-1.3.0/.gitignore +48 -0
- shift_this_version-1.3.0/.python-version +1 -0
- shift_this_version-1.3.0/CLI_GUIDE.md +258 -0
- shift_this_version-1.3.0/PKG-INFO +395 -0
- shift_this_version-1.3.0/README.md +380 -0
- shift_this_version-1.3.0/examples/custom_release.py +69 -0
- shift_this_version-1.3.0/pyproject.toml +34 -0
- shift_this_version-1.3.0/pytest.ini +5 -0
- shift_this_version-1.3.0/run_tests.py +28 -0
- shift_this_version-1.3.0/shift_this_version/__init__.py +23 -0
- shift_this_version-1.3.0/shift_this_version/analyzer.py +514 -0
- shift_this_version-1.3.0/shift_this_version/cli.py +751 -0
- shift_this_version-1.3.0/shift_this_version/config.py +59 -0
- shift_this_version-1.3.0/shift_this_version/git_ops.py +248 -0
- shift_this_version-1.3.0/shift_this_version/updater.py +272 -0
- shift_this_version-1.3.0/tests/test_core.py +293 -0
- shift_this_version-1.3.0/uv.lock +474 -0
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
# Byte-compiled / optimized / cache files
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[cod]
|
|
4
|
+
*$py.class
|
|
5
|
+
|
|
6
|
+
# Distribution / packaging builds
|
|
7
|
+
build/
|
|
8
|
+
dist/
|
|
9
|
+
wheels/
|
|
10
|
+
*.egg-info/
|
|
11
|
+
*.egg
|
|
12
|
+
|
|
13
|
+
# Virtual environments
|
|
14
|
+
.venv/
|
|
15
|
+
venv/
|
|
16
|
+
env/
|
|
17
|
+
ENV/
|
|
18
|
+
|
|
19
|
+
# Secrets & Environment variables
|
|
20
|
+
.env
|
|
21
|
+
.env.*
|
|
22
|
+
*.env
|
|
23
|
+
|
|
24
|
+
# Testing, Coverage & Linters
|
|
25
|
+
.pytest_cache/
|
|
26
|
+
.coverage
|
|
27
|
+
.coverage.*
|
|
28
|
+
htmlcov/
|
|
29
|
+
.mypy_cache/
|
|
30
|
+
.ruff_cache/
|
|
31
|
+
|
|
32
|
+
# IDE & Editor settings
|
|
33
|
+
.vscode/
|
|
34
|
+
.idea/
|
|
35
|
+
*.swp
|
|
36
|
+
*.swo
|
|
37
|
+
|
|
38
|
+
# Operating System temporary files
|
|
39
|
+
.DS_Store
|
|
40
|
+
Thumbs.db
|
|
41
|
+
ehthumbs.db
|
|
42
|
+
Desktop.ini
|
|
43
|
+
|
|
44
|
+
# Logs
|
|
45
|
+
*.log
|
|
46
|
+
|
|
47
|
+
# Private local scripts
|
|
48
|
+
pypi_publish.py
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
3.10
|
|
@@ -0,0 +1,258 @@
|
|
|
1
|
+
# CLI User Guide (`shift-this-version`)
|
|
2
|
+
|
|
3
|
+
Comprehensive guide and reference for using `shift-this-version` from the command line.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## Table of Contents
|
|
8
|
+
1. [First-Time Setup Wizard](#1-first-time-setup-wizard)
|
|
9
|
+
2. [Command: `inspect`](#2-command-inspect)
|
|
10
|
+
3. [Command: `shift`](#3-command-shift)
|
|
11
|
+
4. [Command: `help`](#4-command-help)
|
|
12
|
+
5. [Advanced Options & Providers](#5-advanced-options--providers)
|
|
13
|
+
6. [CI/CD Integration](#6-cicd-integration)
|
|
14
|
+
|
|
15
|
+
---
|
|
16
|
+
|
|
17
|
+
## 1. First-Time Setup Wizard
|
|
18
|
+
|
|
19
|
+
Run `shift-this-version` with no arguments on first use. The interactive setup wizard will guide you through configuration:
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
shift-this-version
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
### What the wizard does:
|
|
26
|
+
1. **Presents Provider Categories**: Choose from 4 groups:
|
|
27
|
+
- Group 1 (Direct Cloud Giants): Google Gemini, Anthropic Claude, OpenAI
|
|
28
|
+
- Group 2 (High-Speed & Value Powerhouses): DeepSeek, Groq
|
|
29
|
+
- Group 3 (Universal Hub): OpenRouter (Access 200+ models with 1 key)
|
|
30
|
+
- Group 4 (Local & Self-Hosted): Ollama, Custom OpenAI-Compatible
|
|
31
|
+
2. **Prompts for Provider Credentials**:
|
|
32
|
+
- For Cloud providers: Prompts for API key (securely masked)
|
|
33
|
+
- For OpenRouter: Prompts for API key and lets you specify any model
|
|
34
|
+
- For Ollama: Prompts **only for the Host URL** (defaults to `http://localhost:11434`, no API key needed!)
|
|
35
|
+
- For Custom endpoints: Prompts for Base URL, model name, and optional key
|
|
36
|
+
3. **Saves Configuration**: Saves settings securely to `~/.shift-this-version/config.json`.
|
|
37
|
+
4. **Displays Quick-Start Guide**: Shows next recommended commands.
|
|
38
|
+
|
|
39
|
+
> Note: To change providers, models, or keys at any time, run:
|
|
40
|
+
> `shift-this-version config`
|
|
41
|
+
|
|
42
|
+
---
|
|
43
|
+
|
|
44
|
+
## 2. Command: `inspect`
|
|
45
|
+
|
|
46
|
+
Scan Git history, commit count, code diff preview, and all detected version files and variables:
|
|
47
|
+
|
|
48
|
+
```bash
|
|
49
|
+
shift-this-version inspect
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
### Sample Output:
|
|
53
|
+
```text
|
|
54
|
+
┌───────────────────────────────── Git State ─────────────────────────────────┐
|
|
55
|
+
│ Latest Tag: v0.1.0 │
|
|
56
|
+
│ Commits Ahead: 2 │
|
|
57
|
+
└─────────────────────────────────────────────────────────────────────────────┘
|
|
58
|
+
Detected Version Targets (Files & Code Variables)
|
|
59
|
+
┌──────────┬─────────────────────────┬──────┬─────────────────┬───────────────┐
|
|
60
|
+
│ Type │ File Path │ Line │ Current Version │ Snippet │
|
|
61
|
+
├──────────┼─────────────────────────┼──────┼─────────────────┼───────────────┤
|
|
62
|
+
│ config │ pyproject.toml │ 3 │ 0.1.0 │ version = … │
|
|
63
|
+
│ code_var │ frontend/src/config.ts │ 8 │ 0.1.0 │ const VERSION…│
|
|
64
|
+
└──────────┴─────────────────────────┴──────┴─────────────────┴───────────────┘
|
|
65
|
+
|
|
66
|
+
Recent Commits:
|
|
67
|
+
• feat: add OAuth2 login handler
|
|
68
|
+
• fix: correct button padding
|
|
69
|
+
|
|
70
|
+
Filtered Diff Size: 1,420 characters
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
---
|
|
74
|
+
|
|
75
|
+
## 3. Command: `shift` (Standard Usage)
|
|
76
|
+
|
|
77
|
+
Once initial setup is complete, running `shift-this-version shift` automatically analyzes your Git diff and commits using your saved AI provider and model:
|
|
78
|
+
|
|
79
|
+
```bash
|
|
80
|
+
# Standard shift (uses your saved AI configuration from setup - no flags needed!)
|
|
81
|
+
shift-this-version shift
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
### 3.1 Dry-Run Mode (Preview without modifying files)
|
|
85
|
+
```bash
|
|
86
|
+
# Preview AI recommendation safely:
|
|
87
|
+
shift-this-version shift --dry-run
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
### 3.2 Interactive Confirmation (Default)
|
|
91
|
+
When you run `shift-this-version shift`:
|
|
92
|
+
|
|
93
|
+
**Workflow:**
|
|
94
|
+
1. AI analyzes diff and commits.
|
|
95
|
+
2. Displays structured recommendation:
|
|
96
|
+
```text
|
|
97
|
+
╭───────────────────── AI Recommendation: MINOR ──────────────────────╮
|
|
98
|
+
│ Current Version: 0.1.0 │
|
|
99
|
+
│ Suggested Version: 0.2.0 (MINOR shift) │
|
|
100
|
+
│ Confidence: 95.0% │
|
|
101
|
+
│ │
|
|
102
|
+
│ Reasoning: │
|
|
103
|
+
│ Added OAuth login support without breaking existing endpoints. │
|
|
104
|
+
│ │
|
|
105
|
+
│ Key Changes: │
|
|
106
|
+
│ • Added Google OAuth login handler │
|
|
107
|
+
╰─────────────────────────────────────────────────────────────────────╯
|
|
108
|
+
|
|
109
|
+
Files to update:
|
|
110
|
+
• pyproject.toml:3 (0.1.0 -> 0.2.0)
|
|
111
|
+
• frontend/src/config.ts:8 (0.1.0 -> 0.2.0)
|
|
112
|
+
```
|
|
113
|
+
3. Prompts for confirmation:
|
|
114
|
+
```text
|
|
115
|
+
Do you want to shift version to 0.2.0 across 2 targets? [Y/n]: y
|
|
116
|
+
```
|
|
117
|
+
4. Updates files, commits changes, creates Git tag, and pushes to remote:
|
|
118
|
+
```text
|
|
119
|
+
Updated pyproject.toml
|
|
120
|
+
Updated frontend/src/config.ts
|
|
121
|
+
Git committed: 'chore(release): shift version to 0.2.0'
|
|
122
|
+
Created Git Tag: v0.2.0
|
|
123
|
+
Pushed to remote: main & v0.2.0
|
|
124
|
+
|
|
125
|
+
Successfully shifted version to 0.2.0!
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
*(Note: Automatic pushing is enabled by default. Use `--no-push` if you want to push manually.)*
|
|
129
|
+
|
|
130
|
+
### 3.3 Manual SemVer Mode (No AI Required)
|
|
131
|
+
If you are working offline, have not configured an AI provider, or simply prefer to select the bump level yourself:
|
|
132
|
+
|
|
133
|
+
```bash
|
|
134
|
+
shift-this-version shift --manual
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
This presents a fast interactive selection:
|
|
138
|
+
- `[1] Patch -> 1.2.4 (Bug fixes, backwards-compatible)`
|
|
139
|
+
- `[2] Minor -> 1.3.0 (New features, backwards-compatible)`
|
|
140
|
+
- `[3] Major -> 2.0.0 (Breaking changes, major redesign)`
|
|
141
|
+
- `[4] Custom -> Enter custom version string`
|
|
142
|
+
|
|
143
|
+
After choosing, it flows directly into the 5 discrete release confirmation stages (Version -> Commit -> Commit Message -> Tag -> Push).
|
|
144
|
+
|
|
145
|
+
---
|
|
146
|
+
|
|
147
|
+
## 4. Command: `help`
|
|
148
|
+
|
|
149
|
+
Display usage guide and command syntax:
|
|
150
|
+
|
|
151
|
+
```bash
|
|
152
|
+
# General help and examples
|
|
153
|
+
shift-this-version help
|
|
154
|
+
|
|
155
|
+
# Command-specific help
|
|
156
|
+
shift-this-version help shift
|
|
157
|
+
shift-this-version help inspect
|
|
158
|
+
shift-this-version help config
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
---
|
|
162
|
+
|
|
163
|
+
## 5. Advanced Options & Providers
|
|
164
|
+
|
|
165
|
+
### Provider Selection:
|
|
166
|
+
|
|
167
|
+
#### Group 1: Direct Cloud Giants
|
|
168
|
+
```bash
|
|
169
|
+
# Google Gemini
|
|
170
|
+
shift-this-version shift -p gemini -m gemini-2.5-flash
|
|
171
|
+
|
|
172
|
+
# Anthropic Claude
|
|
173
|
+
shift-this-version shift -p anthropic -m claude-3-5-sonnet-20241022
|
|
174
|
+
|
|
175
|
+
# OpenAI
|
|
176
|
+
shift-this-version shift -p openai -m gpt-4o
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
#### Group 2: High-Speed & Value Powerhouses
|
|
180
|
+
```bash
|
|
181
|
+
# DeepSeek
|
|
182
|
+
shift-this-version shift -p deepseek -m deepseek-chat
|
|
183
|
+
|
|
184
|
+
# Groq
|
|
185
|
+
shift-this-version shift -p groq -m llama-3.3-70b-versatile
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
#### Group 3: Universal Hub (OpenRouter)
|
|
189
|
+
```bash
|
|
190
|
+
# Specify any model available on openrouter.ai
|
|
191
|
+
shift-this-version shift -p openrouter -m anthropic/claude-3.5-haiku
|
|
192
|
+
shift-this-version shift -p openrouter -m deepseek/deepseek-chat
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
#### Group 4: Local & Self-Hosted
|
|
196
|
+
```bash
|
|
197
|
+
# Ollama: Specify host URL (no API key needed!)
|
|
198
|
+
shift-this-version shift -p ollama --host http://localhost:11434
|
|
199
|
+
|
|
200
|
+
# Custom OpenAI-compatible endpoint (LM Studio, vLLM, LocalAI)
|
|
201
|
+
shift-this-version shift -p custom --host http://localhost:1234/v1 -m local-model
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
### Custom Code Variables (`--var`)
|
|
205
|
+
If your project uses non-standard variable names in code:
|
|
206
|
+
```bash
|
|
207
|
+
shift-this-version shift --var RELEASE_VER --var APP_VERSION
|
|
208
|
+
```
|
|
209
|
+
|
|
210
|
+
### Disable Git Commit or Tag
|
|
211
|
+
```bash
|
|
212
|
+
# Modify version files only without creating git tags or commits
|
|
213
|
+
shift-this-version shift --no-tag --no-commit
|
|
214
|
+
```
|
|
215
|
+
|
|
216
|
+
---
|
|
217
|
+
|
|
218
|
+
## 6. CI/CD Integration
|
|
219
|
+
|
|
220
|
+
For non-interactive pipelines (GitHub Actions, GitLab CI):
|
|
221
|
+
|
|
222
|
+
```bash
|
|
223
|
+
shift-this-version shift -p gemini --yes
|
|
224
|
+
```
|
|
225
|
+
|
|
226
|
+
### GitHub Actions Workflow Example (`.github/workflows/release.yml`):
|
|
227
|
+
```yaml
|
|
228
|
+
name: AI Version Shift
|
|
229
|
+
|
|
230
|
+
on:
|
|
231
|
+
push:
|
|
232
|
+
branches:
|
|
233
|
+
- main
|
|
234
|
+
|
|
235
|
+
jobs:
|
|
236
|
+
shift-version:
|
|
237
|
+
runs-on: ubuntu-latest
|
|
238
|
+
steps:
|
|
239
|
+
- name: Checkout Code
|
|
240
|
+
uses: actions/checkout@v4
|
|
241
|
+
with:
|
|
242
|
+
fetch-depth: 0
|
|
243
|
+
|
|
244
|
+
- name: Setup Python
|
|
245
|
+
uses: actions/setup-python@v5
|
|
246
|
+
with:
|
|
247
|
+
python-version: "3.12"
|
|
248
|
+
|
|
249
|
+
- name: Install shift-this-version
|
|
250
|
+
run: pip install shift-this-version
|
|
251
|
+
|
|
252
|
+
- name: Run AI Shift
|
|
253
|
+
env:
|
|
254
|
+
GEMINI_API_KEY: ${{ secrets.GEMINI_API_KEY }}
|
|
255
|
+
run: |
|
|
256
|
+
shift-this-version shift --yes -p gemini
|
|
257
|
+
git push --tags
|
|
258
|
+
```
|
|
@@ -0,0 +1,395 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: shift-this-version
|
|
3
|
+
Version: 1.3.0
|
|
4
|
+
Summary: Smart SemVer Bumper driven by Code Diff
|
|
5
|
+
Author-email: snui1s <snailsqz@gmail.com>
|
|
6
|
+
Requires-Python: >=3.10
|
|
7
|
+
Requires-Dist: httpx>=0.27.0
|
|
8
|
+
Requires-Dist: pydantic>=2.0
|
|
9
|
+
Requires-Dist: python-dotenv>=1.0.0
|
|
10
|
+
Requires-Dist: rich>=13.9.4
|
|
11
|
+
Requires-Dist: typer>=0.15.2
|
|
12
|
+
Provides-Extra: test
|
|
13
|
+
Requires-Dist: pytest>=8.0.0; extra == 'test'
|
|
14
|
+
Description-Content-Type: text/markdown
|
|
15
|
+
|
|
16
|
+
# shift-this-version
|
|
17
|
+
|
|
18
|
+
> Smart SemVer bumper driven by code diff and AI.
|
|
19
|
+
|
|
20
|
+
`shift-this-version` is an automated release utility that inspects Git diffs and commit histories since the last release tag. Using LLMs (Google Gemini, OpenRouter, OpenAI, DeepSeek, Groq, or local Ollama instances), it analyzes code modifications against the [SemVer 2.0.0](https://semver.org/) specification to recommend the appropriate version increment (`major`, `minor`, `patch`).
|
|
21
|
+
|
|
22
|
+
The tool updates version fields in standard project configurations (`pyproject.toml`, `package.json`, `Cargo.toml`, `setup.cfg`, `setup.py`, `composer.json`, `pubspec.yaml`) as well as designated version variables directly within source code (e.g., `VERSION = "1.0.0"`, `export const VERSION = "1.0.0"`, `__version__ = "1.0.0"`). It also manages Git commits, release tags, and remote pushes.
|
|
23
|
+
|
|
24
|
+
## Table of Contents
|
|
25
|
+
|
|
26
|
+
- [Background](#background)
|
|
27
|
+
- [Install](#install)
|
|
28
|
+
- [Usage](#usage)
|
|
29
|
+
- [1. First-Time Setup Wizard](#1-first-time-setup-wizard)
|
|
30
|
+
- [2. Inspect Repository](#2-inspect-repository)
|
|
31
|
+
- [3. Shift Version](#3-shift-version)
|
|
32
|
+
- [Standard Run (Zero Flags Needed)](#31-standard-run-zero-flags-needed)
|
|
33
|
+
- [Dry-Run Mode](#32-dry-run-mode)
|
|
34
|
+
- [Interactive Confirmation Stages](#33-interactive-confirmation-stages)
|
|
35
|
+
- [Manual SemVer Mode (No AI Required)](#34-manual-semver-mode-no-ai-required)
|
|
36
|
+
- [Provider Options (Optional Overrides)](#35-provider-options-optional-overrides)
|
|
37
|
+
- [Custom Code Variables](#36-custom-code-variables)
|
|
38
|
+
- [Disable Commit, Tag, or Push](#37-disable-commit-tag-or-push)
|
|
39
|
+
- [CI/CD Integration](#38-cicd-integration)
|
|
40
|
+
- [4. Command Reference](#4-command-reference)
|
|
41
|
+
- [API](#api)
|
|
42
|
+
- [Security](#security)
|
|
43
|
+
- [Contributing](#contributing)
|
|
44
|
+
- [License](#license)
|
|
45
|
+
|
|
46
|
+
## Background
|
|
47
|
+
|
|
48
|
+
Traditional version-bumping tools either require manual developer input (e.g. choosing between patch, minor, or major) or rely strictly on Conventional Commit messages. In reality, commit histories can be incomplete or inaccurate, increasing the risk of unflagged breaking changes or improper releases.
|
|
49
|
+
|
|
50
|
+
`shift-this-version` solves this by examining actual source code diffs:
|
|
51
|
+
- Noise reduction: automatically ignores lockfiles, minified bundles, documentation, and image assets.
|
|
52
|
+
- Token management: summarizes and truncates large diffs using `git diff --stat` to prevent context window overflow.
|
|
53
|
+
- Semantic evaluation: prompts the AI to identify API signature breaks, additions, bug fixes, and non-functional changes.
|
|
54
|
+
- Fallback resilience: operates seamlessly in manual mode when offline or when no AI provider is configured.
|
|
55
|
+
|
|
56
|
+
## Install
|
|
57
|
+
|
|
58
|
+
### Requirements
|
|
59
|
+
- Python >= 3.10
|
|
60
|
+
- Git CLI accessible in PATH
|
|
61
|
+
|
|
62
|
+
### Via uv or pip
|
|
63
|
+
```sh
|
|
64
|
+
# Install as a global CLI tool
|
|
65
|
+
uv tool install shift-this-version
|
|
66
|
+
|
|
67
|
+
# Or install via pip
|
|
68
|
+
pip install shift-this-version
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
### Local Development Setup
|
|
72
|
+
```sh
|
|
73
|
+
git clone https://github.com/snui1s/shift-this-version.git
|
|
74
|
+
cd shift-this-version
|
|
75
|
+
uv sync
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
## Usage
|
|
79
|
+
|
|
80
|
+
### 1. First-Time Setup Wizard
|
|
81
|
+
|
|
82
|
+
Run `shift-this-version` with no arguments on first use. The interactive setup wizard guides you through selecting your preferred AI provider, securely storing your configuration in `~/.shift-this-version/config.json`:
|
|
83
|
+
|
|
84
|
+
```sh
|
|
85
|
+
shift-this-version
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
#### What the wizard does:
|
|
89
|
+
1. **Presents Provider Categories**: Choose from 4 groups:
|
|
90
|
+
- Group 1 (Direct Cloud Giants): Google Gemini, Anthropic Claude, OpenAI
|
|
91
|
+
- Group 2 (High-Speed & Value Powerhouses): DeepSeek, Groq
|
|
92
|
+
- Group 3 (Universal Hub): OpenRouter (Access 200+ models with 1 key)
|
|
93
|
+
- Group 4 (Local & Self-Hosted): Ollama, Custom OpenAI-Compatible
|
|
94
|
+
2. **Prompts for Provider Credentials**:
|
|
95
|
+
- For Cloud providers: Prompts for API key (securely masked)
|
|
96
|
+
- For OpenRouter: Prompts for API key and lets you specify any model
|
|
97
|
+
- For Ollama: Prompts only for the Host URL (defaults to `http://localhost:11434`, no API key needed)
|
|
98
|
+
- For Custom endpoints: Prompts for Base URL, model name, and optional key
|
|
99
|
+
3. **Saves Configuration**: Saves settings securely to `~/.shift-this-version/config.json`.
|
|
100
|
+
4. **Displays Quick-Start Guide**: Shows next recommended commands.
|
|
101
|
+
|
|
102
|
+
To reconfigure your provider or update your API key at any time, run:
|
|
103
|
+
```sh
|
|
104
|
+
shift-this-version config
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
*(Optional: You can also supply keys via environment variables such as `GEMINI_API_KEY`, `OPENROUTER_API_KEY`, or `OPENAI_API_KEY` for CI/CD environments.)*
|
|
108
|
+
|
|
109
|
+
---
|
|
110
|
+
|
|
111
|
+
### 2. Inspect Repository
|
|
112
|
+
|
|
113
|
+
Verify the current Git state, recent commits, diff summary, and all detected version targets:
|
|
114
|
+
|
|
115
|
+
```sh
|
|
116
|
+
shift-this-version inspect
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
#### Sample Output:
|
|
120
|
+
```text
|
|
121
|
+
── 1. Git State ──────────────────────────────────────────
|
|
122
|
+
┌───────────────────────────────── Git State ─────────────────────────────────┐
|
|
123
|
+
│ Latest Tag: v0.1.0 │
|
|
124
|
+
│ Commits Ahead: 2 commits ahead │
|
|
125
|
+
└─────────────────────────────────────────────────────────────────────────────┘
|
|
126
|
+
|
|
127
|
+
── 2. Detected Version Files & Variables ─────────────────
|
|
128
|
+
Targets Found in Project:
|
|
129
|
+
┌──────────┬─────────────────────────┬──────┬─────────────────┬───────────────┐
|
|
130
|
+
│ Type │ File Path │ Line │ Current Version │ Snippet │
|
|
131
|
+
├──────────┼─────────────────────────┼──────┼─────────────────┼───────────────┤
|
|
132
|
+
│ config │ pyproject.toml │ 3 │ 0.1.0 │ version = … │
|
|
133
|
+
│ code_var │ frontend/src/config.ts │ 8 │ 0.1.0 │ const VERSION…│
|
|
134
|
+
└──────────┴─────────────────────────┴──────┴─────────────────┴───────────────┘
|
|
135
|
+
|
|
136
|
+
Recent Commits:
|
|
137
|
+
• feat: add OAuth2 login handler
|
|
138
|
+
• fix: correct button padding
|
|
139
|
+
|
|
140
|
+
── 3. Changed Files Summary ──────────────────────────────
|
|
141
|
+
pyproject.toml | 2 +-
|
|
142
|
+
frontend/src/config.ts | 2 +-
|
|
143
|
+
2 files changed, 2 insertions(+), 2 deletions(-)
|
|
144
|
+
|
|
145
|
+
── 4. Latest Uncommitted Changes ─────────────────────────
|
|
146
|
+
diff --git a/frontend/src/config.ts b/frontend/src/config.ts
|
|
147
|
+
...
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
---
|
|
151
|
+
|
|
152
|
+
### 3. Shift Version
|
|
153
|
+
|
|
154
|
+
#### 3.1 Standard Run (Zero Flags Needed)
|
|
155
|
+
Run `shift-this-version shift` to analyze code changes with AI, bump version files, commit, tag, and push to remote automatically using your saved AI configuration:
|
|
156
|
+
|
|
157
|
+
```sh
|
|
158
|
+
shift-this-version shift
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
#### 3.2 Dry-Run Mode
|
|
162
|
+
Simulate the AI evaluation without modifying any files or Git state:
|
|
163
|
+
|
|
164
|
+
```sh
|
|
165
|
+
shift-this-version shift --dry-run
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
#### 3.3 Interactive Confirmation Stages
|
|
169
|
+
When running `shift-this-version shift`, the CLI guides you through 5 discrete confirmation stages:
|
|
170
|
+
|
|
171
|
+
1. **AI Recommendation Display**:
|
|
172
|
+
```text
|
|
173
|
+
╭───────────────────── AI Recommendation: MINOR ──────────────────────╮
|
|
174
|
+
│ Current Version: 0.1.0 │
|
|
175
|
+
│ Suggested Version: 0.2.0 (MINOR shift) │
|
|
176
|
+
│ Confidence: 95.0% │
|
|
177
|
+
│ │
|
|
178
|
+
│ Reasoning: │
|
|
179
|
+
│ Added OAuth login support without breaking existing endpoints. │
|
|
180
|
+
│ │
|
|
181
|
+
│ Key Changes: │
|
|
182
|
+
│ • Added Google OAuth login handler │
|
|
183
|
+
╰─────────────────────────────────────────────────────────────────────╯
|
|
184
|
+
|
|
185
|
+
Files to update:
|
|
186
|
+
• pyproject.toml:3 (0.1.0 -> 0.2.0)
|
|
187
|
+
• frontend/src/config.ts:8 (0.1.0 -> 0.2.0)
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
2. **Stage-by-Stage Confirmation**:
|
|
191
|
+
- **Stage 1 (Version)**: Confirm `0.2.0` across all target files `[Y/n]` (enter `n` to provide a custom version).
|
|
192
|
+
- **Stage 2 (Git Commit)**: Confirm creating a Git commit `[Y/n]`.
|
|
193
|
+
- **Stage 3 (Commit Message)**: Accept default message (`chore(release): shift version to 0.2.0`) or provide a custom message.
|
|
194
|
+
- **Stage 4 (Git Tag)**: Confirm creating Git tag `v0.2.0` `[Y/n]` (automatically warns if tag already exists).
|
|
195
|
+
- **Stage 5 (Git Push)**: Confirm pushing branch and tag to remote repository `[Y/n]`.
|
|
196
|
+
|
|
197
|
+
```text
|
|
198
|
+
Updated pyproject.toml -> 0.2.0
|
|
199
|
+
Updated frontend/src/config.ts -> 0.2.0
|
|
200
|
+
Git committed: 'chore(release): shift version to 0.2.0'
|
|
201
|
+
Created Git Tag: v0.2.0
|
|
202
|
+
Pushed to remote: main & v0.2.0
|
|
203
|
+
|
|
204
|
+
Successfully shifted version to 0.2.0!
|
|
205
|
+
```
|
|
206
|
+
|
|
207
|
+
*(Note: Automatic pushing is enabled by default. Use `--no-push` if you prefer to push manually.)*
|
|
208
|
+
|
|
209
|
+
#### 3.4 Manual SemVer Mode (No AI Required)
|
|
210
|
+
If you are working offline, have not configured an AI provider, or prefer to choose the SemVer bump yourself, use the `--manual` flag:
|
|
211
|
+
|
|
212
|
+
```sh
|
|
213
|
+
shift-this-version shift --manual
|
|
214
|
+
```
|
|
215
|
+
|
|
216
|
+
The tool also falls back to manual mode automatically if your AI provider is unreachable or unconfigured.
|
|
217
|
+
|
|
218
|
+
```text
|
|
219
|
+
╭──────────────── Manual Version Shift (No AI) ────────────────╮
|
|
220
|
+
│ Current Version: 0.1.0 │
|
|
221
|
+
│ │
|
|
222
|
+
│ [1] Patch ➔ 0.1.1 (Bug fixes, backwards-compatible) │
|
|
223
|
+
│ [2] Minor ➔ 0.2.0 (New features, backwards-compatible) │
|
|
224
|
+
│ [3] Major ➔ 1.0.0 (Breaking changes, major redesign) │
|
|
225
|
+
│ [4] Custom ➔ Enter a custom version string │
|
|
226
|
+
│ [0] Cancel │
|
|
227
|
+
╰──────────────────────────────────────────────────────────────╯
|
|
228
|
+
Select bump level [1/2/3/4/0] (1):
|
|
229
|
+
```
|
|
230
|
+
|
|
231
|
+
After selection, it proceeds through the same 5 confirmation stages (Version -> Commit -> Commit Message -> Tag -> Push).
|
|
232
|
+
|
|
233
|
+
#### 3.5 Provider Options (Optional Overrides)
|
|
234
|
+
You can optionally override your saved default provider or model for a single run:
|
|
235
|
+
|
|
236
|
+
- **Group 1: Direct Cloud Giants**
|
|
237
|
+
```sh
|
|
238
|
+
# Google Gemini (Default: gemini-2.5-flash)
|
|
239
|
+
shift-this-version shift -p gemini -m gemini-2.5-flash
|
|
240
|
+
|
|
241
|
+
# Anthropic Claude (Default: claude-3-5-haiku-20241022)
|
|
242
|
+
shift-this-version shift -p anthropic -m claude-3-5-sonnet-20241022
|
|
243
|
+
|
|
244
|
+
# OpenAI (Default: gpt-4o-mini)
|
|
245
|
+
shift-this-version shift -p openai -m gpt-4o
|
|
246
|
+
```
|
|
247
|
+
|
|
248
|
+
- **Group 2: High-Speed & Value Powerhouses**
|
|
249
|
+
```sh
|
|
250
|
+
# DeepSeek (Default: deepseek-chat)
|
|
251
|
+
shift-this-version shift -p deepseek -m deepseek-chat
|
|
252
|
+
|
|
253
|
+
# Groq (Default: llama-3.3-70b-versatile)
|
|
254
|
+
shift-this-version shift -p groq -m llama-3.3-70b-versatile
|
|
255
|
+
```
|
|
256
|
+
|
|
257
|
+
- **Group 3: Universal Hub**
|
|
258
|
+
```sh
|
|
259
|
+
# OpenRouter (Choose any model available on openrouter.ai)
|
|
260
|
+
shift-this-version shift -p openrouter -m anthropic/claude-3.5-haiku
|
|
261
|
+
shift-this-version shift -p openrouter -m deepseek/deepseek-chat
|
|
262
|
+
```
|
|
263
|
+
|
|
264
|
+
- **Group 4: Local & Self-Hosted**
|
|
265
|
+
```sh
|
|
266
|
+
# Ollama: Specify host URL (no API key needed)
|
|
267
|
+
shift-this-version shift -p ollama --host http://localhost:11434
|
|
268
|
+
|
|
269
|
+
# Custom OpenAI-Compatible Endpoint (LM Studio, vLLM, LocalAI)
|
|
270
|
+
shift-this-version shift -p custom --host http://localhost:1234/v1 -m local-model
|
|
271
|
+
```
|
|
272
|
+
|
|
273
|
+
#### 3.6 Custom Code Variables
|
|
274
|
+
Target specific variable names defined in frontend or backend code:
|
|
275
|
+
```sh
|
|
276
|
+
shift-this-version shift --var APP_VERSION --var RELEASE_VERSION
|
|
277
|
+
```
|
|
278
|
+
|
|
279
|
+
#### 3.7 Disable Commit, Tag, or Push
|
|
280
|
+
Disable Git commit, tag generation, or remote push when needed:
|
|
281
|
+
```sh
|
|
282
|
+
# Update version files only without creating git commits, tags, or pushing
|
|
283
|
+
shift-this-version shift --no-tag --no-commit --no-push
|
|
284
|
+
```
|
|
285
|
+
|
|
286
|
+
#### 3.8 CI/CD Integration
|
|
287
|
+
For non-interactive pipelines (GitHub Actions, GitLab CI), use `--yes` or `-y`:
|
|
288
|
+
|
|
289
|
+
```sh
|
|
290
|
+
shift-this-version shift -p gemini --yes
|
|
291
|
+
```
|
|
292
|
+
|
|
293
|
+
##### GitHub Actions Workflow Example (`.github/workflows/release.yml`):
|
|
294
|
+
```yaml
|
|
295
|
+
name: AI Version Shift
|
|
296
|
+
|
|
297
|
+
on:
|
|
298
|
+
push:
|
|
299
|
+
branches:
|
|
300
|
+
- main
|
|
301
|
+
|
|
302
|
+
jobs:
|
|
303
|
+
shift-version:
|
|
304
|
+
runs-on: ubuntu-latest
|
|
305
|
+
steps:
|
|
306
|
+
- name: Checkout Code
|
|
307
|
+
uses: actions/checkout@v4
|
|
308
|
+
with:
|
|
309
|
+
fetch-depth: 0
|
|
310
|
+
|
|
311
|
+
- name: Setup Python
|
|
312
|
+
uses: actions/setup-python@v5
|
|
313
|
+
with:
|
|
314
|
+
python-version: "3.12"
|
|
315
|
+
|
|
316
|
+
- name: Install shift-this-version
|
|
317
|
+
run: pip install shift-this-version
|
|
318
|
+
|
|
319
|
+
- name: Run AI Shift
|
|
320
|
+
env:
|
|
321
|
+
GEMINI_API_KEY: ${{ secrets.GEMINI_API_KEY }}
|
|
322
|
+
run: |
|
|
323
|
+
shift-this-version shift --yes -p gemini
|
|
324
|
+
git push --tags
|
|
325
|
+
```
|
|
326
|
+
|
|
327
|
+
---
|
|
328
|
+
|
|
329
|
+
### 4. Command Reference
|
|
330
|
+
|
|
331
|
+
| Command | Description |
|
|
332
|
+
| :--- | :--- |
|
|
333
|
+
| `shift-this-version` | Run setup wizard on first run, or show provider status and commands overview |
|
|
334
|
+
| `shift-this-version shift` | Analyze diff with AI and shift SemVer across targets |
|
|
335
|
+
| `shift-this-version shift --manual` | Run interactive SemVer bump without AI |
|
|
336
|
+
| `shift-this-version shift --dry-run` | Preview AI recommendation without modifying files |
|
|
337
|
+
| `shift-this-version shift -y` | Non-interactive auto-confirm mode for CI/CD |
|
|
338
|
+
| `shift-this-version inspect` | Inspect Git diff, commit history, and detected version targets |
|
|
339
|
+
| `shift-this-version config` | Reconfigure default provider, API key, model, or host |
|
|
340
|
+
| `shift-this-version help` | Display detailed command guide and usage examples |
|
|
341
|
+
|
|
342
|
+
---
|
|
343
|
+
|
|
344
|
+
## API
|
|
345
|
+
|
|
346
|
+
`shift-this-version` can also be integrated into custom automation scripts as a Python library:
|
|
347
|
+
|
|
348
|
+
```python
|
|
349
|
+
import shift_this_version as stv
|
|
350
|
+
|
|
351
|
+
# 1. Locate version files and variables
|
|
352
|
+
targets = stv.find_version_targets()
|
|
353
|
+
|
|
354
|
+
# 2. Retrieve Git context
|
|
355
|
+
tag = stv.get_latest_tag()
|
|
356
|
+
diff = stv.get_filtered_diff(tag=tag)
|
|
357
|
+
commits = stv.get_commits_since(tag=tag)
|
|
358
|
+
|
|
359
|
+
# 3. Analyze changes via AI
|
|
360
|
+
analysis = stv.analyze(
|
|
361
|
+
diff=diff,
|
|
362
|
+
commits=commits,
|
|
363
|
+
provider="gemini"
|
|
364
|
+
)
|
|
365
|
+
|
|
366
|
+
print(f"Recommendation: {analysis.bump_type}")
|
|
367
|
+
print(f"Reasoning: {analysis.reasoning}")
|
|
368
|
+
print(f"Breaking Changes: {analysis.breaking_changes}")
|
|
369
|
+
|
|
370
|
+
# 4. Compute next version and update files
|
|
371
|
+
current_version = targets[0].current_version
|
|
372
|
+
next_version = stv.calculate_next_version(current_version, analysis.bump_type)
|
|
373
|
+
|
|
374
|
+
for target in targets:
|
|
375
|
+
stv.apply_version_bump(target, next_version)
|
|
376
|
+
```
|
|
377
|
+
|
|
378
|
+
## Security
|
|
379
|
+
|
|
380
|
+
- API keys are stored locally in `~/.shift-this-version/config.json` with restricted user permissions, or read from environment variables. Keys are never logged or transmitted except to your chosen provider endpoint.
|
|
381
|
+
- Git diff extraction excludes ignored directories (`.git`, `.venv`, `node_modules`), secrets, and common binary/image assets.
|
|
382
|
+
- For private or sensitive source code, use the local `ollama` provider to ensure data remains strictly on your local machine.
|
|
383
|
+
|
|
384
|
+
## Contributing
|
|
385
|
+
|
|
386
|
+
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
|
|
387
|
+
|
|
388
|
+
Run the test suite before submitting changes:
|
|
389
|
+
```sh
|
|
390
|
+
python tests/test_core.py
|
|
391
|
+
```
|
|
392
|
+
|
|
393
|
+
## License
|
|
394
|
+
|
|
395
|
+
[MIT](LICENSE)
|