gptdiff 0.1.30__tar.gz → 0.1.31__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.30 → gptdiff-0.1.31}/PKG-INFO +26 -8
- {gptdiff-0.1.30 → gptdiff-0.1.31}/README.md +26 -8
- {gptdiff-0.1.30 → gptdiff-0.1.31}/gptdiff/gptdiff.py +13 -12
- {gptdiff-0.1.30 → gptdiff-0.1.31}/gptdiff.egg-info/PKG-INFO +26 -8
- {gptdiff-0.1.30 → gptdiff-0.1.31}/setup.py +1 -1
- {gptdiff-0.1.30 → gptdiff-0.1.31}/tests/test_multidiff.py +1 -2
- {gptdiff-0.1.30 → gptdiff-0.1.31}/tests/test_swallow_reasoning.py +28 -8
- {gptdiff-0.1.30 → gptdiff-0.1.31}/LICENSE.txt +0 -0
- {gptdiff-0.1.30 → gptdiff-0.1.31}/gptdiff/__init__.py +0 -0
- {gptdiff-0.1.30 → gptdiff-0.1.31}/gptdiff/applydiff.py +0 -0
- {gptdiff-0.1.30 → gptdiff-0.1.31}/gptdiff/gptpatch.py +0 -0
- {gptdiff-0.1.30 → gptdiff-0.1.31}/gptdiff.egg-info/SOURCES.txt +0 -0
- {gptdiff-0.1.30 → gptdiff-0.1.31}/gptdiff.egg-info/dependency_links.txt +0 -0
- {gptdiff-0.1.30 → gptdiff-0.1.31}/gptdiff.egg-info/entry_points.txt +0 -0
- {gptdiff-0.1.30 → gptdiff-0.1.31}/gptdiff.egg-info/requires.txt +0 -0
- {gptdiff-0.1.30 → gptdiff-0.1.31}/gptdiff.egg-info/top_level.txt +0 -0
- {gptdiff-0.1.30 → gptdiff-0.1.31}/setup.cfg +0 -0
- {gptdiff-0.1.30 → gptdiff-0.1.31}/tests/test_applydiff.py +0 -0
- {gptdiff-0.1.30 → gptdiff-0.1.31}/tests/test_applydiff_edgecases.py +0 -0
- {gptdiff-0.1.30 → gptdiff-0.1.31}/tests/test_diff_parse.py +0 -0
- {gptdiff-0.1.30 → gptdiff-0.1.31}/tests/test_failing_case.py +0 -0
- {gptdiff-0.1.30 → gptdiff-0.1.31}/tests/test_parse_diff_per_file.py +0 -0
- {gptdiff-0.1.30 → gptdiff-0.1.31}/tests/test_smartapply.py +0 -0
- {gptdiff-0.1.30 → gptdiff-0.1.31}/tests/test_strip_bad_ouput.py +0 -0
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.2
|
2
2
|
Name: gptdiff
|
3
|
-
Version: 0.1.
|
3
|
+
Version: 0.1.31
|
4
4
|
Summary: A tool to generate and apply git diffs using LLMs
|
5
5
|
Author: 255labs
|
6
6
|
Classifier: License :: OSI Approved :: MIT License
|
@@ -31,30 +31,48 @@ GPTDiff: Create and apply diffs using AI.
|
|
31
31
|
This tool leverages natural language instructions to modify project codebases.
|
32
32
|
-->
|
33
33
|
|
34
|
+
## Table of Contents
|
35
|
+
|
36
|
+
- [Quick Start](#quick-start)
|
37
|
+
- [Example Usage](#example-usage-of-gptdiff)
|
38
|
+
- [Basic Usage](#basic-usage)
|
39
|
+
- [Simple Command Line Agent Loops](#simple-command-line-agent-loops)
|
40
|
+
- [Why Choose GPTDiff?](#why-choose-gptdiff)
|
41
|
+
- [Core Capabilities](#core-capabilities)
|
42
|
+
- [CLI Excellence](#-cli-excellence)
|
43
|
+
- [Magic Diff Generation](#-magic-diff-generation)
|
44
|
+
- [Smart Apply System](#-smart-apply-system)
|
45
|
+
- [Get Started](#get-started)
|
46
|
+
- [Installation](#installation)
|
47
|
+
- [Configuration](#configuration)
|
48
|
+
- [Command Line Usage](#command-line-usage)
|
49
|
+
|
34
50
|
🚀 **Create and apply diffs with AI**
|
35
51
|
Modify your project using plain English.
|
36
52
|
|
37
|
-
More documentation at [gptdiff.255labs.xyz](gptdiff.255labs.xyz)
|
53
|
+
More documentation at [gptdiff.255labs.xyz](https://gptdiff.255labs.xyz)
|
54
|
+
|
55
|
+
## Quick Start
|
38
56
|
|
57
|
+
1. **Install GPTDiff**
|
58
|
+
|
59
|
+
|
39
60
|
### Example Usage of `gptdiff`
|
40
61
|
|
41
62
|
#### Apply a Patch Directly
|
42
|
-
```
|
43
|
-
bash
|
63
|
+
```bash
|
44
64
|
gptdiff "Add button animations on press" --apply
|
45
65
|
```
|
46
66
|
✅ Successfully applied patch
|
47
67
|
|
48
68
|
#### Generate a Patch File
|
49
|
-
```
|
50
|
-
bash
|
69
|
+
```bash
|
51
70
|
gptdiff "Add API documentation" --call
|
52
71
|
```
|
53
72
|
🔧 Patch written to `diff.patch`
|
54
73
|
|
55
74
|
#### Generate a Prompt File Without Calling LLM
|
56
|
-
```
|
57
|
-
bash
|
75
|
+
```bash
|
58
76
|
gptdiff "Improve error messages"
|
59
77
|
```
|
60
78
|
📄 LLM not called, written to `prompt.txt`
|
@@ -4,30 +4,48 @@ GPTDiff: Create and apply diffs using AI.
|
|
4
4
|
This tool leverages natural language instructions to modify project codebases.
|
5
5
|
-->
|
6
6
|
|
7
|
+
## Table of Contents
|
8
|
+
|
9
|
+
- [Quick Start](#quick-start)
|
10
|
+
- [Example Usage](#example-usage-of-gptdiff)
|
11
|
+
- [Basic Usage](#basic-usage)
|
12
|
+
- [Simple Command Line Agent Loops](#simple-command-line-agent-loops)
|
13
|
+
- [Why Choose GPTDiff?](#why-choose-gptdiff)
|
14
|
+
- [Core Capabilities](#core-capabilities)
|
15
|
+
- [CLI Excellence](#-cli-excellence)
|
16
|
+
- [Magic Diff Generation](#-magic-diff-generation)
|
17
|
+
- [Smart Apply System](#-smart-apply-system)
|
18
|
+
- [Get Started](#get-started)
|
19
|
+
- [Installation](#installation)
|
20
|
+
- [Configuration](#configuration)
|
21
|
+
- [Command Line Usage](#command-line-usage)
|
22
|
+
|
7
23
|
🚀 **Create and apply diffs with AI**
|
8
24
|
Modify your project using plain English.
|
9
25
|
|
10
|
-
More documentation at [gptdiff.255labs.xyz](gptdiff.255labs.xyz)
|
26
|
+
More documentation at [gptdiff.255labs.xyz](https://gptdiff.255labs.xyz)
|
27
|
+
|
28
|
+
## Quick Start
|
11
29
|
|
30
|
+
1. **Install GPTDiff**
|
31
|
+
|
32
|
+
|
12
33
|
### Example Usage of `gptdiff`
|
13
34
|
|
14
35
|
#### Apply a Patch Directly
|
15
|
-
```
|
16
|
-
bash
|
36
|
+
```bash
|
17
37
|
gptdiff "Add button animations on press" --apply
|
18
38
|
```
|
19
39
|
✅ Successfully applied patch
|
20
40
|
|
21
41
|
#### Generate a Patch File
|
22
|
-
```
|
23
|
-
bash
|
42
|
+
```bash
|
24
43
|
gptdiff "Add API documentation" --call
|
25
44
|
```
|
26
45
|
🔧 Patch written to `diff.patch`
|
27
46
|
|
28
47
|
#### Generate a Prompt File Without Calling LLM
|
29
|
-
```
|
30
|
-
bash
|
48
|
+
```bash
|
31
49
|
gptdiff "Improve error messages"
|
32
50
|
```
|
33
51
|
📄 LLM not called, written to `prompt.txt`
|
@@ -301,4 +319,4 @@ pip install -e .[test]
|
|
301
319
|
pytest tests/
|
302
320
|
```
|
303
321
|
|
304
|
-
This will execute all unit tests verifying core diff generation and application logic.
|
322
|
+
This will execute all unit tests verifying core diff generation and application logic.
|
@@ -417,6 +417,10 @@ prepended to the system prompt.
|
|
417
417
|
"""
|
418
418
|
if model is None:
|
419
419
|
model = os.getenv('GPTDIFF_MODEL', 'deepseek-reasoner')
|
420
|
+
# Use ANTHROPIC_BUDGET_TOKENS env var if set and no cli override provided
|
421
|
+
if anthropic_budget_tokens is None:
|
422
|
+
anthropic_budget_tokens = os.getenv('ANTHROPIC_BUDGET_TOKENS')
|
423
|
+
|
420
424
|
if prepend:
|
421
425
|
if prepend.startswith("http://") or prepend.startswith("https://"):
|
422
426
|
import urllib.request
|
@@ -438,7 +442,7 @@ prepended to the system prompt.
|
|
438
442
|
max_tokens=max_tokens,
|
439
443
|
api_key=api_key,
|
440
444
|
base_url=base_url,
|
441
|
-
budget_tokens=anthropic_budget_tokens
|
445
|
+
budget_tokens=int(anthropic_budget_tokens) if anthropic_budget_tokens is not None else None
|
442
446
|
)
|
443
447
|
return diff_text
|
444
448
|
|
@@ -929,20 +933,17 @@ def swallow_reasoning(full_response: str) -> (str, str):
|
|
929
933
|
r"(?P<reasoning>>\s*Reasoning.*?Reasoned.*?seconds)",
|
930
934
|
re.DOTALL
|
931
935
|
)
|
932
|
-
|
933
|
-
|
936
|
+
reasoning_list = []
|
937
|
+
def replacer(match):
|
934
938
|
raw_reasoning = match.group("reasoning")
|
935
|
-
# Remove any leading '+' characters and extra whitespace from each line
|
936
939
|
reasoning_lines = [line.lstrip('+').strip() for line in raw_reasoning.splitlines()]
|
937
940
|
reasoning = "\n".join(reasoning_lines).strip()
|
938
|
-
|
939
|
-
|
940
|
-
|
941
|
-
|
942
|
-
|
943
|
-
|
944
|
-
final_content = full_response.strip()
|
945
|
-
return final_content, reasoning
|
941
|
+
reasoning_list.append(reasoning)
|
942
|
+
return ""
|
943
|
+
|
944
|
+
final_content = re.sub(pattern, replacer, full_response)
|
945
|
+
reasoning = "\n".join(reasoning_list)
|
946
|
+
return final_content.strip(), reasoning
|
946
947
|
|
947
948
|
def strip_bad_output(updated: str, original: str) -> str:
|
948
949
|
"""
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.2
|
2
2
|
Name: gptdiff
|
3
|
-
Version: 0.1.
|
3
|
+
Version: 0.1.31
|
4
4
|
Summary: A tool to generate and apply git diffs using LLMs
|
5
5
|
Author: 255labs
|
6
6
|
Classifier: License :: OSI Approved :: MIT License
|
@@ -31,30 +31,48 @@ GPTDiff: Create and apply diffs using AI.
|
|
31
31
|
This tool leverages natural language instructions to modify project codebases.
|
32
32
|
-->
|
33
33
|
|
34
|
+
## Table of Contents
|
35
|
+
|
36
|
+
- [Quick Start](#quick-start)
|
37
|
+
- [Example Usage](#example-usage-of-gptdiff)
|
38
|
+
- [Basic Usage](#basic-usage)
|
39
|
+
- [Simple Command Line Agent Loops](#simple-command-line-agent-loops)
|
40
|
+
- [Why Choose GPTDiff?](#why-choose-gptdiff)
|
41
|
+
- [Core Capabilities](#core-capabilities)
|
42
|
+
- [CLI Excellence](#-cli-excellence)
|
43
|
+
- [Magic Diff Generation](#-magic-diff-generation)
|
44
|
+
- [Smart Apply System](#-smart-apply-system)
|
45
|
+
- [Get Started](#get-started)
|
46
|
+
- [Installation](#installation)
|
47
|
+
- [Configuration](#configuration)
|
48
|
+
- [Command Line Usage](#command-line-usage)
|
49
|
+
|
34
50
|
🚀 **Create and apply diffs with AI**
|
35
51
|
Modify your project using plain English.
|
36
52
|
|
37
|
-
More documentation at [gptdiff.255labs.xyz](gptdiff.255labs.xyz)
|
53
|
+
More documentation at [gptdiff.255labs.xyz](https://gptdiff.255labs.xyz)
|
54
|
+
|
55
|
+
## Quick Start
|
38
56
|
|
57
|
+
1. **Install GPTDiff**
|
58
|
+
|
59
|
+
|
39
60
|
### Example Usage of `gptdiff`
|
40
61
|
|
41
62
|
#### Apply a Patch Directly
|
42
|
-
```
|
43
|
-
bash
|
63
|
+
```bash
|
44
64
|
gptdiff "Add button animations on press" --apply
|
45
65
|
```
|
46
66
|
✅ Successfully applied patch
|
47
67
|
|
48
68
|
#### Generate a Patch File
|
49
|
-
```
|
50
|
-
bash
|
69
|
+
```bash
|
51
70
|
gptdiff "Add API documentation" --call
|
52
71
|
```
|
53
72
|
🔧 Patch written to `diff.patch`
|
54
73
|
|
55
74
|
#### Generate a Prompt File Without Calling LLM
|
56
|
-
```
|
57
|
-
bash
|
75
|
+
```bash
|
58
76
|
gptdiff "Improve error messages"
|
59
77
|
```
|
60
78
|
📄 LLM not called, written to `prompt.txt`
|
@@ -2,7 +2,7 @@ from setuptools import setup, find_packages
|
|
2
2
|
|
3
3
|
setup(
|
4
4
|
name='gptdiff',
|
5
|
-
version='0.1.
|
5
|
+
version='0.1.31',
|
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
|
@@ -2,7 +2,7 @@ import pytest
|
|
2
2
|
|
3
3
|
from gptdiff.gptdiff import swallow_reasoning
|
4
4
|
|
5
|
-
def
|
5
|
+
def test_swallow_reasoning_extraction_simple():
|
6
6
|
llm_response = (
|
7
7
|
"+> Reasoning\n"
|
8
8
|
"+None\n"
|
@@ -13,19 +13,39 @@ def test_swallow_reasoning_extraction():
|
|
13
13
|
final_content, reasoning = swallow_reasoning(llm_response)
|
14
14
|
expected_reasoning = (
|
15
15
|
"> Reasoning\n"
|
16
|
-
"
|
17
|
-
"
|
18
|
-
"**Returning the result**\n"
|
19
|
-
"I'm finalizing the method to apply the diff updates...\n"
|
20
|
-
"Reasoned for 6 seconds"
|
16
|
+
"None\n"
|
17
|
+
"Reasoned about summary drawer button 변경 for 15 seconds"
|
21
18
|
)
|
22
19
|
assert reasoning == expected_reasoning
|
23
20
|
# The final content should no longer contain the reasoning block.
|
24
21
|
assert expected_reasoning not in final_content
|
25
|
-
# And it should contain the diff block.
|
26
|
-
assert "```diff" in final_content
|
27
22
|
|
28
23
|
|
24
|
+
def test_swallow_reasoning_extraction_multiline():
|
25
|
+
llm_response = (
|
26
|
+
"line 1> Reasoning\n"
|
27
|
+
"+None\n"
|
28
|
+
"+Reasoned about summary drawer button 변경 for 1 seconds\n"
|
29
|
+
"line 2\n"
|
30
|
+
" > Reasoning\n"
|
31
|
+
"+None\n"
|
32
|
+
"+Reasoned about summary drawer button 변경 for 2 seconds\n"
|
33
|
+
"line 3:"
|
34
|
+
)
|
35
|
+
final_content, reasoning = swallow_reasoning(llm_response)
|
36
|
+
expected_reasoning = (
|
37
|
+
"> Reasoning\n"
|
38
|
+
"None\n"
|
39
|
+
"Reasoned about summary drawer button 변경 for 1 seconds\n"
|
40
|
+
"> Reasoning\n"
|
41
|
+
"None\n"
|
42
|
+
"Reasoned about summary drawer button 변경 for 2 seconds"
|
43
|
+
)
|
44
|
+
assert reasoning == expected_reasoning
|
45
|
+
assert "line 1\nline 2\n \nline 3:" == final_content
|
46
|
+
# The final content should no longer contain the reasoning block.
|
47
|
+
assert expected_reasoning not in final_content
|
48
|
+
|
29
49
|
def test_swallow_reasoning_with_untested_response():
|
30
50
|
llm_response = (
|
31
51
|
"> Reasoning\n"
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|