ziya 0.1.43__py3-none-any.whl → 0.1.45__py3-none-any.whl
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.
Potentially problematic release.
This version of ziya might be problematic. Click here for more details.
- app/utils/code_util.py +27 -32
- pyproject.toml +4 -1
- {ziya-0.1.43.dist-info → ziya-0.1.45.dist-info}/METADATA +1 -1
- {ziya-0.1.43.dist-info → ziya-0.1.45.dist-info}/RECORD +7 -7
- {ziya-0.1.43.dist-info → ziya-0.1.45.dist-info}/LICENSE +0 -0
- {ziya-0.1.43.dist-info → ziya-0.1.45.dist-info}/WHEEL +0 -0
- {ziya-0.1.43.dist-info → ziya-0.1.45.dist-info}/entry_points.txt +0 -0
app/utils/code_util.py
CHANGED
|
@@ -83,9 +83,18 @@ def correct_git_diff(git_diff: str, original_file_path: str) -> str:
|
|
|
83
83
|
"""
|
|
84
84
|
# Split the diff into lines
|
|
85
85
|
lines = git_diff.split('\n')
|
|
86
|
+
is_new_file = False
|
|
87
|
+
# Check if this is a new file creation
|
|
88
|
+
if lines and lines[0].startswith('diff --git a/dev/null'):
|
|
89
|
+
is_new_file = True
|
|
90
|
+
# Check if 'new file mode 100644' is present in the first few lines
|
|
91
|
+
has_file_mode = any('new file mode 100' in line for line in lines[:3])
|
|
92
|
+
if not has_file_mode:
|
|
93
|
+
# Insert the missing line after the first line
|
|
94
|
+
mode_line = 'new file mode 100644'
|
|
95
|
+
lines.insert(1, mode_line)
|
|
96
|
+
logger.info(f"Added missing '{mode_line}' to new file diff")
|
|
86
97
|
|
|
87
|
-
# Check if this is a new file creation by looking for "new file mode" in the diff
|
|
88
|
-
is_new_file = any('new file mode 100644' in line for line in lines[:5])
|
|
89
98
|
original_content = []
|
|
90
99
|
|
|
91
100
|
if not is_new_file:
|
|
@@ -130,7 +139,7 @@ def correct_git_diff(git_diff: str, original_file_path: str) -> str:
|
|
|
130
139
|
corrected_diff = '\n'.join(corrected_lines)
|
|
131
140
|
return corrected_diff
|
|
132
141
|
|
|
133
|
-
def
|
|
142
|
+
def _find_correct_old_start_line(original_content: list, hunk_lines: list) -> int:
|
|
134
143
|
"""
|
|
135
144
|
Finds the correct starting line number in the original file by matching context and deleted lines.
|
|
136
145
|
|
|
@@ -149,15 +158,15 @@ def _find_correct_start_line(original_content: list, hunk_lines: list) -> int:
|
|
|
149
158
|
"""
|
|
150
159
|
# Extract context and deleted lines from the hunk
|
|
151
160
|
if not original_content:
|
|
152
|
-
# Creating a new file
|
|
153
|
-
return
|
|
161
|
+
# Creating a new file, should start with @@ -0,0 +1,N @@
|
|
162
|
+
return 0
|
|
154
163
|
|
|
155
164
|
if len(hunk_lines) < 3:
|
|
156
165
|
error_msg = (
|
|
157
166
|
f"Invalid git diff format: Expected at least 2 lines in the hunk, but got {len(hunk_lines)} lines.\n"
|
|
158
|
-
"Hunk content:\n{}".format('\n'.join(hunk_lines)))
|
|
167
|
+
+ "Hunk content:\n{}".format('\n'.join(hunk_lines)))
|
|
159
168
|
logger.error(error_msg)
|
|
160
|
-
raise RuntimeError("git diff
|
|
169
|
+
raise RuntimeError("Invalid git diff format.")
|
|
161
170
|
|
|
162
171
|
context_and_deleted = []
|
|
163
172
|
for line in hunk_lines:
|
|
@@ -240,9 +249,9 @@ def _process_hunk_with_original_content(lines: list, start_index: int, cumulativ
|
|
|
240
249
|
line_index += 1
|
|
241
250
|
|
|
242
251
|
# Find the correct start_line_old by matching context and deleted lines
|
|
243
|
-
start_line_old =
|
|
252
|
+
start_line_old = _find_correct_old_start_line(original_content, hunk_lines)
|
|
244
253
|
|
|
245
|
-
#
|
|
254
|
+
# Calculate counts for the hunk lines
|
|
246
255
|
for hunk_line in hunk_lines:
|
|
247
256
|
if hunk_line.startswith('+') and not hunk_line.startswith('+++'):
|
|
248
257
|
actual_count_new += 1
|
|
@@ -253,8 +262,15 @@ def _process_hunk_with_original_content(lines: list, start_index: int, cumulativ
|
|
|
253
262
|
actual_count_old += 1
|
|
254
263
|
actual_count_new += 1
|
|
255
264
|
|
|
256
|
-
#
|
|
257
|
-
|
|
265
|
+
# Special handling for new file creation
|
|
266
|
+
if start_line_old == 0:
|
|
267
|
+
# For new files:
|
|
268
|
+
# count_old should be 0
|
|
269
|
+
actual_count_old = 0
|
|
270
|
+
corrected_start_line_new = 1
|
|
271
|
+
else:
|
|
272
|
+
# For existing files, adjust start_line_new considering previous line offsets
|
|
273
|
+
corrected_start_line_new = start_line_old + cumulative_line_offset
|
|
258
274
|
|
|
259
275
|
# Calculate line offset for subsequent hunks
|
|
260
276
|
line_offset = actual_count_new - actual_count_old
|
|
@@ -292,24 +308,3 @@ def _format_hunk_header(start_old: int, count_old: int, start_new: int, count_ne
|
|
|
292
308
|
if count_new != 1:
|
|
293
309
|
new_part += f',{count_new}'
|
|
294
310
|
return f'@@ {old_part} {new_part} @@'
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
if __name__ == '__main__':
|
|
299
|
-
# TODO: Create unit test and move these code to unit test
|
|
300
|
-
diff = """\
|
|
301
|
-
diff --git a/file.txt b/file.txt
|
|
302
|
-
index e69de29..4b825dc 100644
|
|
303
|
-
--- a/file.txt
|
|
304
|
-
+++ b/file.txt
|
|
305
|
-
@@ -1,5 +1,5 @@
|
|
306
|
-
Line one
|
|
307
|
-
+Line two
|
|
308
|
-
Line three
|
|
309
|
-
Line four
|
|
310
|
-
Line five
|
|
311
|
-
@@ -10,2 +10,2 @@
|
|
312
|
-
Line ten
|
|
313
|
-
-Line eleven
|
|
314
|
-
+Line eleven modified"""
|
|
315
|
-
print(correct_git_diff(diff,""))
|
pyproject.toml
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[tool.poetry]
|
|
2
2
|
name = "ziya"
|
|
3
|
-
version = "0.1.
|
|
3
|
+
version = "0.1.45"
|
|
4
4
|
description = ""
|
|
5
5
|
authors = ["Vishnu Krishnaprasad <vishnukool@gmail.com>"]
|
|
6
6
|
readme = "README.md"
|
|
@@ -25,6 +25,9 @@ langchain-cli = ">=0.0.15"
|
|
|
25
25
|
pydevd-pycharm = "^243.18137.19"
|
|
26
26
|
langchain-community = "^0.3.1"
|
|
27
27
|
|
|
28
|
+
[tool.poetry.group.dev.dependencies]
|
|
29
|
+
pytest = "^8.3.3"
|
|
30
|
+
|
|
28
31
|
[build-system]
|
|
29
32
|
requires = ["poetry-core"]
|
|
30
33
|
build-backend = "poetry.core.masonry.api"
|
|
@@ -5,14 +5,14 @@ app/agents/prompts.py,sha256=Hm0TJcABRgnpV2bbBobigPznxeLVhyRLEHm7maQ9CEE,3873
|
|
|
5
5
|
app/main.py,sha256=5bZk9PUm00bdk_w2gJTWJVQFcJ13WU3eN16vFU1AMk0,4303
|
|
6
6
|
app/server.py,sha256=Ii_JFygHdMmxYsEtVm2L0vRRMINWgim3_cWLmVha8mg,4704
|
|
7
7
|
app/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
8
|
-
app/utils/code_util.py,sha256=
|
|
8
|
+
app/utils/code_util.py,sha256=aqyDneAOJPXc1fujEaNXvfPCqoOrYOcq0cyWFFhXvaI,12440
|
|
9
9
|
app/utils/directory_util.py,sha256=2zxsSxSOZKesjhgjF3KguY__fC9XkjxHHnDbcxtnhXk,2762
|
|
10
10
|
app/utils/gitignore_parser.py,sha256=Li3hQd60eclIuN2qxn8-NQ5sxRyMcnS88DFUxVHdx-A,7487
|
|
11
11
|
app/utils/langchain_validation_util.py,sha256=RgmKayKMApvUA7SPF_DrBAcYdIzzLUVJfnOwTSc1Eug,527
|
|
12
12
|
app/utils/logging_utils.py,sha256=8JEcc1t7L-a0G4HLmM8zFydNNSOd5l2-gkTxviLQUns,280
|
|
13
13
|
app/utils/print_tree_util.py,sha256=O4Rb-GS8UODxfH7Z6bZGsr-opG6QLmvdaU1im5kh4IA,1419
|
|
14
14
|
app/utils/version_util.py,sha256=NcvMWIImJDcO9K5OMX6jJD4q6Zb8Y117Mu8sWIkhxEc,631
|
|
15
|
-
pyproject.toml,sha256=
|
|
15
|
+
pyproject.toml,sha256=Dk7YaPVfwZD3KfhcP9Ky_-eAP9f0buKeVqFCffwzRS4,934
|
|
16
16
|
scripts.py,sha256=70BOvYoboMhl3Bxjy73m1ozmI8UV8JZVyi2RwUptkK8,809
|
|
17
17
|
templates/asset-manifest.json,sha256=CWTbaK4qJuG_uzscwg8HZ9leGVx06vlQKAVEDcLvtqo,1157
|
|
18
18
|
templates/favicon.ico,sha256=HgB8xAZdDHFK2lODUsp2H_Dds_i14pnpydx7NEJrNrU,15086
|
|
@@ -30,8 +30,8 @@ templates/static/media/fa-solid-900.4d986b00ff9ca3828fbd.woff2,sha256=rhfBavvqIW
|
|
|
30
30
|
templates/static/media/fa-solid-900.bacd5de623fb563b961a.ttf,sha256=tJkNDQxfXTjWLpNu6hIGdOWEx-6o3O44qXXAz5o3U5s,420332
|
|
31
31
|
templates/static/media/fa-v4compatibility.c8e090db312b0bea2aa2.ttf,sha256=_49SX7BQxdJFGczI9XI9hbLlHt0_m8ZUivVa663U8mk,10832
|
|
32
32
|
templates/static/media/fa-v4compatibility.cf7f5903d06b79ad60f1.woff2,sha256=x6hp-sopnRW-EKAfGdB2WnxNRtiSLZuTFyNcHkpvCYI,4792
|
|
33
|
-
ziya-0.1.
|
|
34
|
-
ziya-0.1.
|
|
35
|
-
ziya-0.1.
|
|
36
|
-
ziya-0.1.
|
|
37
|
-
ziya-0.1.
|
|
33
|
+
ziya-0.1.45.dist-info/LICENSE,sha256=8CfErGEG13yY1Z-CDlIhAQawX2KOv-QI_2Ge2z6x8SU,1064
|
|
34
|
+
ziya-0.1.45.dist-info/METADATA,sha256=UOwRhVy88bS15LJgUgUQe-IdtUCIxPJCfmWVvkWiNgc,2867
|
|
35
|
+
ziya-0.1.45.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
|
|
36
|
+
ziya-0.1.45.dist-info/entry_points.txt,sha256=6-KUolj5XXeOPVCJGTJgUL_3lDVGxG-YtK5BTvFPyBg,147
|
|
37
|
+
ziya-0.1.45.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|