tass 0.1.3__py3-none-any.whl → 0.1.5__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.
- src/app.py +39 -18
- src/constants.py +10 -6
- {tass-0.1.3.dist-info → tass-0.1.5.dist-info}/METADATA +1 -1
- tass-0.1.5.dist-info/RECORD +10 -0
- tass-0.1.3.dist-info/RECORD +0 -10
- {tass-0.1.3.dist-info → tass-0.1.5.dist-info}/WHEEL +0 -0
- {tass-0.1.3.dist-info → tass-0.1.5.dist-info}/entry_points.txt +0 -0
- {tass-0.1.3.dist-info → tass-0.1.5.dist-info}/licenses/LICENSE +0 -0
src/app.py
CHANGED
|
@@ -124,16 +124,30 @@ class TassApp:
|
|
|
124
124
|
return self.call_llm()
|
|
125
125
|
|
|
126
126
|
def read_file(self, path: str, start: int = 1) -> str:
|
|
127
|
-
|
|
127
|
+
if start == 1:
|
|
128
|
+
console.print(f" └ Reading file [bold]{path}[/]...")
|
|
129
|
+
else:
|
|
130
|
+
console.print(f" └ Reading file [bold]{path}[/] (from line {start})...")
|
|
128
131
|
|
|
129
132
|
try:
|
|
130
|
-
|
|
131
|
-
|
|
133
|
+
result = subprocess.run(
|
|
134
|
+
f"cat -n {path}",
|
|
135
|
+
shell=True,
|
|
136
|
+
capture_output=True,
|
|
137
|
+
text=True,
|
|
138
|
+
)
|
|
132
139
|
except Exception as e:
|
|
133
140
|
console.print(" [red]read_file failed[/red]")
|
|
134
141
|
console.print(f" [red]{str(e)}[/red]")
|
|
135
142
|
return f"read_file failed: {str(e)}"
|
|
136
143
|
|
|
144
|
+
out = result.stdout
|
|
145
|
+
err = result.stderr
|
|
146
|
+
if result.returncode != 0:
|
|
147
|
+
console.print(" [red]read_file failed[/red]")
|
|
148
|
+
console.print(f" [red]{err}[/red]")
|
|
149
|
+
return f"read_file failed: {err}"
|
|
150
|
+
|
|
137
151
|
lines = []
|
|
138
152
|
line_num = 1
|
|
139
153
|
for line in out.split("\n"):
|
|
@@ -151,11 +165,22 @@ class TassApp:
|
|
|
151
165
|
console.print(" [green]Command succeeded[/green]")
|
|
152
166
|
return "".join(lines)
|
|
153
167
|
|
|
154
|
-
def edit_file(self, path: str,
|
|
155
|
-
|
|
168
|
+
def edit_file(self, path: str, line_start: int, line_end: int, replace: str) -> str:
|
|
169
|
+
with open(path, "r") as f:
|
|
170
|
+
original_content = f.read()
|
|
171
|
+
|
|
172
|
+
original_lines = original_content.split("\n")
|
|
173
|
+
replaced_lines = original_lines[line_start - 1:line_end]
|
|
174
|
+
new_content = "\n".join(
|
|
175
|
+
original_lines[:line_start - 1]
|
|
176
|
+
+ replace.split("\n")
|
|
177
|
+
+ original_lines[line_end:]
|
|
178
|
+
)
|
|
179
|
+
|
|
180
|
+
replaced_with_minuses = "\n".join([f"-{line}" for line in replaced_lines])
|
|
156
181
|
replace_with_pluses = "\n".join([f"+{line}" for line in replace.split("\n")])
|
|
157
182
|
console.print()
|
|
158
|
-
console.print(Markdown(f"```diff\nEditing {path}\n{
|
|
183
|
+
console.print(Markdown(f"```diff\nEditing {path}\n{replaced_with_minuses}\n{replace_with_pluses}\n```"))
|
|
159
184
|
answer = console.input("\n[bold]Run?[/] ([bold]Y[/]/n): ").strip().lower()
|
|
160
185
|
if answer not in ("yes", "y", ""):
|
|
161
186
|
reason = console.input("Why not? (optional, press Enter to skip): ").strip()
|
|
@@ -163,16 +188,6 @@ class TassApp:
|
|
|
163
188
|
|
|
164
189
|
console.print(" └ Running...")
|
|
165
190
|
try:
|
|
166
|
-
with open(path, "r") as f:
|
|
167
|
-
original_content = f.read()
|
|
168
|
-
|
|
169
|
-
if find not in original_content:
|
|
170
|
-
console.print(" [red]edit_file failed[/red]")
|
|
171
|
-
console.print(f" [red]edit_file failed:\n'{find}'\nnot found in file[/red]")
|
|
172
|
-
return f"edit_file failed: '{find}' not found in file"
|
|
173
|
-
|
|
174
|
-
new_content = original_content.replace(find, replace)
|
|
175
|
-
|
|
176
191
|
with open(path, "w") as f:
|
|
177
192
|
f.write(new_content)
|
|
178
193
|
except Exception as e:
|
|
@@ -221,14 +236,20 @@ class TassApp:
|
|
|
221
236
|
console.print(f" [red]Command failed[/red] (code {result.returncode})")
|
|
222
237
|
console.print(f" [red]{err}[/red]")
|
|
223
238
|
|
|
224
|
-
if len(out.split("\n")) >
|
|
239
|
+
if len(out.split("\n")) > 1000:
|
|
225
240
|
out_first_1000 = "\n".join(out.split("\n")[:1000])
|
|
226
241
|
out = f"{out_first_1000}... (Truncated)"
|
|
227
242
|
|
|
228
|
-
if len(err) >
|
|
243
|
+
if len(err.split("\n")) > 1000:
|
|
229
244
|
err_first_1000 = "\n".join(err.split("\n")[:1000])
|
|
230
245
|
err = f"{err_first_1000}... (Truncated)"
|
|
231
246
|
|
|
247
|
+
if len(out) > 20000:
|
|
248
|
+
out = f"{out[:20000]}... (Truncated)"
|
|
249
|
+
|
|
250
|
+
if len(err) > 20000:
|
|
251
|
+
err = f"{err[:20000]}... (Truncated)"
|
|
252
|
+
|
|
232
253
|
return f"Command output (exit {result.returncode}):\n{out}\n{err}"
|
|
233
254
|
|
|
234
255
|
def run(self):
|
src/constants.py
CHANGED
|
@@ -37,7 +37,7 @@ TOOLS = [
|
|
|
37
37
|
"type": "function",
|
|
38
38
|
"function": {
|
|
39
39
|
"name": "edit_file",
|
|
40
|
-
"description": "Edits a file.
|
|
40
|
+
"description": "Edits a file. Removes the contents between the lines 'line_start' and 'line_end' inclusive entirely and replaces it with 'replace'.",
|
|
41
41
|
"parameters": {
|
|
42
42
|
"type": "object",
|
|
43
43
|
"properties": {
|
|
@@ -45,13 +45,17 @@ TOOLS = [
|
|
|
45
45
|
"type": "string",
|
|
46
46
|
"description": "Relative path of the file",
|
|
47
47
|
},
|
|
48
|
-
"
|
|
49
|
-
"type": "
|
|
50
|
-
"description": "The
|
|
48
|
+
"line_start": {
|
|
49
|
+
"type": "integer",
|
|
50
|
+
"description": "The first line to remove the contents of (inclusive)",
|
|
51
|
+
},
|
|
52
|
+
"line_end": {
|
|
53
|
+
"type": "integer",
|
|
54
|
+
"description": "The last line to remove the contents of (inclusive)",
|
|
51
55
|
},
|
|
52
56
|
"replace": {
|
|
53
57
|
"type": "string",
|
|
54
|
-
"description": "The string to replace with",
|
|
58
|
+
"description": "The string to replace with. Must have the correct spacing and indentation for all lines.",
|
|
55
59
|
},
|
|
56
60
|
},
|
|
57
61
|
"required": ["path", "find", "replace"],
|
|
@@ -63,7 +67,7 @@ TOOLS = [
|
|
|
63
67
|
"type": "function",
|
|
64
68
|
"function": {
|
|
65
69
|
"name": "read_file",
|
|
66
|
-
"description": "Read a file's contents (up to 1000 lines)",
|
|
70
|
+
"description": "Read a file's contents (up to 1000 lines). The output will be identical to calling `cat -n <path>` with preceding spaces, line number and a tab.",
|
|
67
71
|
"parameters": {
|
|
68
72
|
"type": "object",
|
|
69
73
|
"properties": {
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
src/__init__.py,sha256=tu2q9W5_pkq30l3tRMTGahColBAAubbLP6LaB3l3IFg,89
|
|
2
|
+
src/app.py,sha256=Jej2qjyBRqQREpvm6WWvd6cPy9RLzW74rYegeM8ICPI,10224
|
|
3
|
+
src/cli.py,sha256=op3fYcyfek_KqCCiA-Zdlc9jVZSCi036whMmR2ZjjAs,76
|
|
4
|
+
src/constants.py,sha256=gFIMWh38-uyh2XJdiKUsOwAh7yk4jbdfxmeJZ9yl4fw,3847
|
|
5
|
+
src/utils.py,sha256=rKq34DVmFbsWPy7R6Bfdvv1ztzFLPT4hUd8BFpPHjqs,681
|
|
6
|
+
tass-0.1.5.dist-info/METADATA,sha256=HskJ2m7qsulvtK_N5nZ_aJAcq1PH5zGMDnYMm_cjda8,1071
|
|
7
|
+
tass-0.1.5.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
|
|
8
|
+
tass-0.1.5.dist-info/entry_points.txt,sha256=pviKuIOuHvaQ7_YiFxatJEY8XYfh3EzVWy4LJh0v-A0,38
|
|
9
|
+
tass-0.1.5.dist-info/licenses/LICENSE,sha256=z8d0m5b2O9McPEK1xHG_dWgUBT6EfBDz6wA0F7xSPTA,11358
|
|
10
|
+
tass-0.1.5.dist-info/RECORD,,
|
tass-0.1.3.dist-info/RECORD
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
src/__init__.py,sha256=tu2q9W5_pkq30l3tRMTGahColBAAubbLP6LaB3l3IFg,89
|
|
2
|
-
src/app.py,sha256=jy-6wYh-Wb2Z1DOVWKc7stEX3gtt6dM9BfJOv6ZG9SE,9607
|
|
3
|
-
src/cli.py,sha256=op3fYcyfek_KqCCiA-Zdlc9jVZSCi036whMmR2ZjjAs,76
|
|
4
|
-
src/constants.py,sha256=A0_PwEYo1Dpf8UC6HV7JgQwU7GlZQxKhLgwgmyoc3WY,3478
|
|
5
|
-
src/utils.py,sha256=rKq34DVmFbsWPy7R6Bfdvv1ztzFLPT4hUd8BFpPHjqs,681
|
|
6
|
-
tass-0.1.3.dist-info/METADATA,sha256=uS8VJaj57K9T-LlxZkOy1iQdCSTu_UrLhIocIihJtew,1071
|
|
7
|
-
tass-0.1.3.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
|
|
8
|
-
tass-0.1.3.dist-info/entry_points.txt,sha256=pviKuIOuHvaQ7_YiFxatJEY8XYfh3EzVWy4LJh0v-A0,38
|
|
9
|
-
tass-0.1.3.dist-info/licenses/LICENSE,sha256=z8d0m5b2O9McPEK1xHG_dWgUBT6EfBDz6wA0F7xSPTA,11358
|
|
10
|
-
tass-0.1.3.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|