gptdiff 0.1.2__tar.gz → 0.1.4__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.
gptdiff-0.1.4/PKG-INFO ADDED
@@ -0,0 +1,273 @@
1
+ Metadata-Version: 2.2
2
+ Name: gptdiff
3
+ Version: 0.1.4
4
+ Summary: A tool to generate and apply git diffs using LLMs
5
+ Author: 255labs
6
+ Classifier: License :: OSI Approved :: MIT License
7
+ Classifier: Programming Language :: Python :: 3
8
+ Classifier: Operating System :: OS Independent
9
+ Description-Content-Type: text/markdown
10
+ License-File: LICENSE.txt
11
+ Requires-Dist: openai>=1.0.0
12
+ Requires-Dist: tiktoken>=0.5.0
13
+ Requires-Dist: ai_agent_toolbox>=0.1.0
14
+ Provides-Extra: test
15
+ Requires-Dist: pytest; extra == "test"
16
+ Requires-Dist: pytest-mock; extra == "test"
17
+ Provides-Extra: docs
18
+ Requires-Dist: mkdocs; extra == "docs"
19
+ Requires-Dist: mkdocs-material; extra == "docs"
20
+ Dynamic: author
21
+ Dynamic: classifier
22
+ Dynamic: description
23
+ Dynamic: description-content-type
24
+ Dynamic: provides-extra
25
+ Dynamic: requires-dist
26
+ Dynamic: summary
27
+
28
+ # GPTDiff
29
+
30
+ 🚀 **AI-Powered Code Evolution** - Transform your codebase with natural language instructions
31
+
32
+ ```bash
33
+ cd myproject
34
+ gptdiff 'add hover effects to the buttons'
35
+ ```
36
+
37
+ Generates a prompt.txt file that you can copy and paste into a large context gpt to have a conversation with suggested changes. You can also invoke the API and try to directly apply the patch using a smartapply if the git apply fails.
38
+
39
+ ## Value Proposition
40
+
41
+ ```bash
42
+ gptdiff "Update the readme with an api section" --apply
43
+ ```
44
+ <span style="color: #00ff00;">Patch applied successfully.</span>
45
+
46
+ ### Why GPTDiff?
47
+
48
+ - **Understands Your Code** - Describe changes in plain English
49
+ - **Safe Modifications** - Keeps existing code working
50
+ - **Auto-Fix** - `--apply` fixes mistakes in generated changes
51
+ - **Works Instantly** - No complex setup needed
52
+ - **Whole Project View** - Handles multiple files together
53
+
54
+ ## Core Capabilities
55
+
56
+ ### ⚡ CLI Excellence
57
+ - **Target Specific Files** - Change just what you need
58
+ - **Live Updates** - See changes as they're made
59
+ - **Try Before Applying** - Test changes safely first
60
+ - **Clear Pricing** - Know costs upfront
61
+ - **Preview Changes** - See what will change with `--call`
62
+ - **Fix Mistakes** - Automatic error correction
63
+
64
+ ### ✨ Magic Diff Generation
65
+ ```bash
66
+ gptdiff "Convert class components to React hooks" --model deepseek-reasoner
67
+ ```
68
+ - Full project context awareness
69
+ - Cross-file refactoring support
70
+ - Automatic conflict prevention
71
+
72
+ ### 🧠 Smart Apply System
73
+
74
+ **Git-native Workflow:**
75
+ ```bash
76
+ # 1. Apply AI-generated changes
77
+ gptdiff "Improve error handling" --apply
78
+
79
+ # 2. Review each change interactively
80
+ git add -p
81
+
82
+ # 3. Commit or discard
83
+ git commit -m "Enhanced error handling"
84
+ git reset --hard # To undo all changes
85
+ ```
86
+
87
+ ```bash
88
+ gptdiff "Refactor authentication to use OAuth 2.0" --apply
89
+ ```
90
+ <span style="color: #00ff00;">✅ Successfully applied complex changes across 5 files</span>
91
+
92
+ ## Get Started
93
+
94
+ ### Installation
95
+
96
+ Requires Python 3.8+. Install from PyPI:
97
+
98
+ ```bash
99
+ pip install gptdiff
100
+ pip install tiktoken # For token counting
101
+ ```
102
+
103
+ Development install (no pip package yet)
104
+ ```bash
105
+ python setup.py install
106
+ ```
107
+
108
+ ### Configuration
109
+
110
+ First sign up for an API key at https://nano-gpt.com/api and generate your key. Then configure your environment:
111
+
112
+ #### Linux/MacOS
113
+ ```bash
114
+ export GPTDIFF_LLM_API_KEY='your-api-key'
115
+ # Optional: For switching API providers
116
+ export GPTDIFF_MODEL='deepseek-reasoner' # Set default model for all commands
117
+ export GPTDIFF_LLM_BASE_URL='https://nano-gpt.com/api/v1/
118
+ ```
119
+
120
+ #### Windows
121
+ ```cmd
122
+ set GPTDIFF_LLM_API_KEY=your-api-key
123
+ rem Optional: For switching API providers
124
+ set GPTDIFF_MODEL=deepseek-reasoner
125
+ set GPTDIFF_LLM_BASE_URL=https://nano-gpt.com/api/v1/
126
+ ```
127
+
128
+ The default base URL points to nano-gpt.com's API. Supported models can be specified with:
129
+
130
+ ```bash
131
+ gptdiff 'your prompt' --model deepseek-reasoner
132
+ # Default model can be set via GPTDIFF_MODEL environment variable
133
+ ```
134
+
135
+ OpenAI will not be called unless you specify `--call` or `--apply`
136
+
137
+ Prevent files being appended to the prompt by adding them to `.gitignore` or `.gptignore`
138
+
139
+ ### Command Line Usage
140
+
141
+ After installing the package, you can use the `gptdiff` command in your terminal. cd into your codebase and run:
142
+
143
+ ```bash
144
+ gptdiff '<user_prompt>'
145
+ ```
146
+
147
+ any files that are included in .gitignore are ignored when generating prompt.txt.
148
+
149
+ #### Specifying Additional Files
150
+
151
+ You can specify additional files or directories to include in the prompt by adding them as arguments to the `gptdiff` command. If no additional files or directories are specified, the tool will default to using the current working directory.
152
+
153
+ Example usage:
154
+
155
+ ```bash
156
+ gptdiff 'make this change' src test
157
+ ```
158
+
159
+ #### Autopatch Changes
160
+
161
+ You can also call openai and automatically apply the generated git diff with the `--apply` flag:
162
+
163
+ ```bash
164
+ gptdiff '<user_prompt>' --apply
165
+ ```
166
+
167
+ ### Dry-Run Validation
168
+ Preview changes without applying them by omitting the `--apply` flag when using `--call`:
169
+ ```bash
170
+ gptdiff "Modernize database queries" --call
171
+ ```
172
+ <span style="color: #0066cc;">ℹ️ Diff preview generated - review changes before applying</span>
173
+
174
+ This often generates incorrect diffs that need to be manually merged.
175
+
176
+ #### Smart Apply
177
+
178
+ For more reliable patching of complex changes, use `smartapply` which processes each file's diff individually with the LLM:
179
+
180
+ ```bash
181
+ gptdiff 'refactor authentication system' --apply
182
+ ```
183
+
184
+ ### Completion Notification
185
+
186
+ Use the `--nobeep` option to disable the default completion beep:
187
+
188
+ ```bash
189
+ gptdiff '<user_prompt>' --beep
190
+ ```
191
+
192
+ ## Local API Documentation
193
+
194
+ Preview API docs locally using MkDocs:
195
+
196
+ ```bash
197
+ pip install .[docs]
198
+ mkdocs serve
199
+ ```
200
+ Open http://localhost:8000 to view the documentation
201
+
202
+ ## Python API
203
+
204
+ Integrate GPTDiff directly into your Python workflows:
205
+
206
+ ```python
207
+ from gptdiff import generate_diff, smartapply
208
+ import os
209
+
210
+ os.environ['GPTDIFF_LLM_API_KEY'] = 'your-api-key'
211
+
212
+ # Create environment representation
213
+ environment = '''
214
+ File: main.py
215
+ Content:
216
+ def old_name():
217
+ print("Need renaming")
218
+ '''
219
+
220
+ # Generate transformation diff
221
+ diff = generate_diff(
222
+ environment=environment,
223
+ goal='Rename function to new_name()',
224
+ model='deepseek-reasoner'
225
+ )
226
+
227
+ # Apply changes safely
228
+ updated_environment = smartapply(
229
+ diff_text=diff,
230
+ environment_str=environment
231
+ )
232
+
233
+ print("Transformed codebase:")
234
+ print(updated_environment)
235
+ ```
236
+
237
+ **Batch Processing Example:**
238
+ ```python
239
+ from gptdiff import generate_diff, smartapply
240
+
241
+ files = load_your_codebase() # Dict of {path: content}
242
+
243
+ transformations = [
244
+ "Add python type annotations",
245
+ "Convert string formatting to f-strings",
246
+ "Update deprecated API calls"
247
+ ]
248
+
249
+ for task in transformations:
250
+ files = smartapply(generate_diff(build_environment(files), task), files)
251
+ ```
252
+
253
+ **Integration Note:** GPTDiff leverages the [AI Agent Toolbox](https://github.com/255BITS/ai-agent-toolbox) for seamless tool usage across AI models and frameworks, making it ideal for both single responses and complex agent workflows.
254
+
255
+ ### Core Functions
256
+
257
+ - `generate_diff(environment: str, goal: str, model: str) -> str`
258
+ Generates a git diff implementing the requested changes
259
+
260
+ *`model` parameter defaults to `GPTDIFF_MODEL` environment variable*
261
+ - `smartapply(diff_text: str, environment_str: str, model: str) -> str`
262
+ Applies complex diffs while preserving file context
263
+
264
+ ## Testing
265
+
266
+ To run the test suite:
267
+
268
+ ```bash
269
+ pip install -e .[test]
270
+ pytest tests/
271
+ ```
272
+
273
+ This will execute all unit tests verifying core diff generation and application logic.
@@ -36,7 +36,14 @@ def create_toolbox():
36
36
  "description": "Complete diff."
37
37
  }
38
38
  },
39
- description="Save the calculated diff as used in 'git apply'"
39
+ description="""Save the calculated diff as used in 'git apply'. Should include the file and line number. For example:
40
+ a/file.py b/file.py
41
+ --- a/file.py
42
+ +++ b/file.py
43
+ @@ -1,2 +1,2 @@
44
+ -def old():
45
+ +def new():
46
+ """
40
47
  )
41
48
  return toolbox
42
49
 
@@ -0,0 +1,273 @@
1
+ Metadata-Version: 2.2
2
+ Name: gptdiff
3
+ Version: 0.1.4
4
+ Summary: A tool to generate and apply git diffs using LLMs
5
+ Author: 255labs
6
+ Classifier: License :: OSI Approved :: MIT License
7
+ Classifier: Programming Language :: Python :: 3
8
+ Classifier: Operating System :: OS Independent
9
+ Description-Content-Type: text/markdown
10
+ License-File: LICENSE.txt
11
+ Requires-Dist: openai>=1.0.0
12
+ Requires-Dist: tiktoken>=0.5.0
13
+ Requires-Dist: ai_agent_toolbox>=0.1.0
14
+ Provides-Extra: test
15
+ Requires-Dist: pytest; extra == "test"
16
+ Requires-Dist: pytest-mock; extra == "test"
17
+ Provides-Extra: docs
18
+ Requires-Dist: mkdocs; extra == "docs"
19
+ Requires-Dist: mkdocs-material; extra == "docs"
20
+ Dynamic: author
21
+ Dynamic: classifier
22
+ Dynamic: description
23
+ Dynamic: description-content-type
24
+ Dynamic: provides-extra
25
+ Dynamic: requires-dist
26
+ Dynamic: summary
27
+
28
+ # GPTDiff
29
+
30
+ 🚀 **AI-Powered Code Evolution** - Transform your codebase with natural language instructions
31
+
32
+ ```bash
33
+ cd myproject
34
+ gptdiff 'add hover effects to the buttons'
35
+ ```
36
+
37
+ Generates a prompt.txt file that you can copy and paste into a large context gpt to have a conversation with suggested changes. You can also invoke the API and try to directly apply the patch using a smartapply if the git apply fails.
38
+
39
+ ## Value Proposition
40
+
41
+ ```bash
42
+ gptdiff "Update the readme with an api section" --apply
43
+ ```
44
+ <span style="color: #00ff00;">Patch applied successfully.</span>
45
+
46
+ ### Why GPTDiff?
47
+
48
+ - **Understands Your Code** - Describe changes in plain English
49
+ - **Safe Modifications** - Keeps existing code working
50
+ - **Auto-Fix** - `--apply` fixes mistakes in generated changes
51
+ - **Works Instantly** - No complex setup needed
52
+ - **Whole Project View** - Handles multiple files together
53
+
54
+ ## Core Capabilities
55
+
56
+ ### ⚡ CLI Excellence
57
+ - **Target Specific Files** - Change just what you need
58
+ - **Live Updates** - See changes as they're made
59
+ - **Try Before Applying** - Test changes safely first
60
+ - **Clear Pricing** - Know costs upfront
61
+ - **Preview Changes** - See what will change with `--call`
62
+ - **Fix Mistakes** - Automatic error correction
63
+
64
+ ### ✨ Magic Diff Generation
65
+ ```bash
66
+ gptdiff "Convert class components to React hooks" --model deepseek-reasoner
67
+ ```
68
+ - Full project context awareness
69
+ - Cross-file refactoring support
70
+ - Automatic conflict prevention
71
+
72
+ ### 🧠 Smart Apply System
73
+
74
+ **Git-native Workflow:**
75
+ ```bash
76
+ # 1. Apply AI-generated changes
77
+ gptdiff "Improve error handling" --apply
78
+
79
+ # 2. Review each change interactively
80
+ git add -p
81
+
82
+ # 3. Commit or discard
83
+ git commit -m "Enhanced error handling"
84
+ git reset --hard # To undo all changes
85
+ ```
86
+
87
+ ```bash
88
+ gptdiff "Refactor authentication to use OAuth 2.0" --apply
89
+ ```
90
+ <span style="color: #00ff00;">✅ Successfully applied complex changes across 5 files</span>
91
+
92
+ ## Get Started
93
+
94
+ ### Installation
95
+
96
+ Requires Python 3.8+. Install from PyPI:
97
+
98
+ ```bash
99
+ pip install gptdiff
100
+ pip install tiktoken # For token counting
101
+ ```
102
+
103
+ Development install (no pip package yet)
104
+ ```bash
105
+ python setup.py install
106
+ ```
107
+
108
+ ### Configuration
109
+
110
+ First sign up for an API key at https://nano-gpt.com/api and generate your key. Then configure your environment:
111
+
112
+ #### Linux/MacOS
113
+ ```bash
114
+ export GPTDIFF_LLM_API_KEY='your-api-key'
115
+ # Optional: For switching API providers
116
+ export GPTDIFF_MODEL='deepseek-reasoner' # Set default model for all commands
117
+ export GPTDIFF_LLM_BASE_URL='https://nano-gpt.com/api/v1/
118
+ ```
119
+
120
+ #### Windows
121
+ ```cmd
122
+ set GPTDIFF_LLM_API_KEY=your-api-key
123
+ rem Optional: For switching API providers
124
+ set GPTDIFF_MODEL=deepseek-reasoner
125
+ set GPTDIFF_LLM_BASE_URL=https://nano-gpt.com/api/v1/
126
+ ```
127
+
128
+ The default base URL points to nano-gpt.com's API. Supported models can be specified with:
129
+
130
+ ```bash
131
+ gptdiff 'your prompt' --model deepseek-reasoner
132
+ # Default model can be set via GPTDIFF_MODEL environment variable
133
+ ```
134
+
135
+ OpenAI will not be called unless you specify `--call` or `--apply`
136
+
137
+ Prevent files being appended to the prompt by adding them to `.gitignore` or `.gptignore`
138
+
139
+ ### Command Line Usage
140
+
141
+ After installing the package, you can use the `gptdiff` command in your terminal. cd into your codebase and run:
142
+
143
+ ```bash
144
+ gptdiff '<user_prompt>'
145
+ ```
146
+
147
+ any files that are included in .gitignore are ignored when generating prompt.txt.
148
+
149
+ #### Specifying Additional Files
150
+
151
+ You can specify additional files or directories to include in the prompt by adding them as arguments to the `gptdiff` command. If no additional files or directories are specified, the tool will default to using the current working directory.
152
+
153
+ Example usage:
154
+
155
+ ```bash
156
+ gptdiff 'make this change' src test
157
+ ```
158
+
159
+ #### Autopatch Changes
160
+
161
+ You can also call openai and automatically apply the generated git diff with the `--apply` flag:
162
+
163
+ ```bash
164
+ gptdiff '<user_prompt>' --apply
165
+ ```
166
+
167
+ ### Dry-Run Validation
168
+ Preview changes without applying them by omitting the `--apply` flag when using `--call`:
169
+ ```bash
170
+ gptdiff "Modernize database queries" --call
171
+ ```
172
+ <span style="color: #0066cc;">ℹ️ Diff preview generated - review changes before applying</span>
173
+
174
+ This often generates incorrect diffs that need to be manually merged.
175
+
176
+ #### Smart Apply
177
+
178
+ For more reliable patching of complex changes, use `smartapply` which processes each file's diff individually with the LLM:
179
+
180
+ ```bash
181
+ gptdiff 'refactor authentication system' --apply
182
+ ```
183
+
184
+ ### Completion Notification
185
+
186
+ Use the `--nobeep` option to disable the default completion beep:
187
+
188
+ ```bash
189
+ gptdiff '<user_prompt>' --beep
190
+ ```
191
+
192
+ ## Local API Documentation
193
+
194
+ Preview API docs locally using MkDocs:
195
+
196
+ ```bash
197
+ pip install .[docs]
198
+ mkdocs serve
199
+ ```
200
+ Open http://localhost:8000 to view the documentation
201
+
202
+ ## Python API
203
+
204
+ Integrate GPTDiff directly into your Python workflows:
205
+
206
+ ```python
207
+ from gptdiff import generate_diff, smartapply
208
+ import os
209
+
210
+ os.environ['GPTDIFF_LLM_API_KEY'] = 'your-api-key'
211
+
212
+ # Create environment representation
213
+ environment = '''
214
+ File: main.py
215
+ Content:
216
+ def old_name():
217
+ print("Need renaming")
218
+ '''
219
+
220
+ # Generate transformation diff
221
+ diff = generate_diff(
222
+ environment=environment,
223
+ goal='Rename function to new_name()',
224
+ model='deepseek-reasoner'
225
+ )
226
+
227
+ # Apply changes safely
228
+ updated_environment = smartapply(
229
+ diff_text=diff,
230
+ environment_str=environment
231
+ )
232
+
233
+ print("Transformed codebase:")
234
+ print(updated_environment)
235
+ ```
236
+
237
+ **Batch Processing Example:**
238
+ ```python
239
+ from gptdiff import generate_diff, smartapply
240
+
241
+ files = load_your_codebase() # Dict of {path: content}
242
+
243
+ transformations = [
244
+ "Add python type annotations",
245
+ "Convert string formatting to f-strings",
246
+ "Update deprecated API calls"
247
+ ]
248
+
249
+ for task in transformations:
250
+ files = smartapply(generate_diff(build_environment(files), task), files)
251
+ ```
252
+
253
+ **Integration Note:** GPTDiff leverages the [AI Agent Toolbox](https://github.com/255BITS/ai-agent-toolbox) for seamless tool usage across AI models and frameworks, making it ideal for both single responses and complex agent workflows.
254
+
255
+ ### Core Functions
256
+
257
+ - `generate_diff(environment: str, goal: str, model: str) -> str`
258
+ Generates a git diff implementing the requested changes
259
+
260
+ *`model` parameter defaults to `GPTDIFF_MODEL` environment variable*
261
+ - `smartapply(diff_text: str, environment_str: str, model: str) -> str`
262
+ Applies complex diffs while preserving file context
263
+
264
+ ## Testing
265
+
266
+ To run the test suite:
267
+
268
+ ```bash
269
+ pip install -e .[test]
270
+ pytest tests/
271
+ ```
272
+
273
+ This will execute all unit tests verifying core diff generation and application logic.
@@ -2,11 +2,13 @@ from setuptools import setup, find_packages
2
2
 
3
3
  setup(
4
4
  name='gptdiff',
5
- version='0.1.2',
5
+ version='0.1.4',
6
6
  description='A tool to generate and apply git diffs using LLMs',
7
7
  author='255labs',
8
8
  packages=find_packages(), # Use find_packages() to automatically discover packages
9
9
  package_data={'gptdiff': []}, # Add any package data if needed
10
+ long_description=open('README.md').read(),
11
+ long_description_content_type='text/markdown',
10
12
  install_requires=[
11
13
  'openai>=1.0.0',
12
14
  'tiktoken>=0.5.0',
gptdiff-0.1.2/PKG-INFO DELETED
@@ -1,23 +0,0 @@
1
- Metadata-Version: 2.2
2
- Name: gptdiff
3
- Version: 0.1.2
4
- Summary: A tool to generate and apply git diffs using LLMs
5
- Author: 255labs
6
- Classifier: License :: OSI Approved :: MIT License
7
- Classifier: Programming Language :: Python :: 3
8
- Classifier: Operating System :: OS Independent
9
- License-File: LICENSE.txt
10
- Requires-Dist: openai>=1.0.0
11
- Requires-Dist: tiktoken>=0.5.0
12
- Requires-Dist: ai_agent_toolbox>=0.1.0
13
- Provides-Extra: test
14
- Requires-Dist: pytest; extra == "test"
15
- Requires-Dist: pytest-mock; extra == "test"
16
- Provides-Extra: docs
17
- Requires-Dist: mkdocs; extra == "docs"
18
- Requires-Dist: mkdocs-material; extra == "docs"
19
- Dynamic: author
20
- Dynamic: classifier
21
- Dynamic: provides-extra
22
- Dynamic: requires-dist
23
- Dynamic: summary
@@ -1,23 +0,0 @@
1
- Metadata-Version: 2.2
2
- Name: gptdiff
3
- Version: 0.1.2
4
- Summary: A tool to generate and apply git diffs using LLMs
5
- Author: 255labs
6
- Classifier: License :: OSI Approved :: MIT License
7
- Classifier: Programming Language :: Python :: 3
8
- Classifier: Operating System :: OS Independent
9
- License-File: LICENSE.txt
10
- Requires-Dist: openai>=1.0.0
11
- Requires-Dist: tiktoken>=0.5.0
12
- Requires-Dist: ai_agent_toolbox>=0.1.0
13
- Provides-Extra: test
14
- Requires-Dist: pytest; extra == "test"
15
- Requires-Dist: pytest-mock; extra == "test"
16
- Provides-Extra: docs
17
- Requires-Dist: mkdocs; extra == "docs"
18
- Requires-Dist: mkdocs-material; extra == "docs"
19
- Dynamic: author
20
- Dynamic: classifier
21
- Dynamic: provides-extra
22
- Dynamic: requires-dist
23
- Dynamic: summary
File without changes
File without changes
File without changes
File without changes