chore: collapse multi-line argument definitions into single lines across multiple modules
This commit is contained in:
+6
-18
@@ -92,15 +92,11 @@ class DiffDisplay:
|
||||
old_line_num, new_line_num = self._parse_hunk_header(line)
|
||||
elif line.startswith("+"):
|
||||
stats.insertions += 1
|
||||
diff_lines.append(
|
||||
DiffLine("add", line[1:].rstrip(), None, new_line_num)
|
||||
)
|
||||
diff_lines.append(DiffLine("add", line[1:].rstrip(), None, new_line_num))
|
||||
new_line_num += 1
|
||||
elif line.startswith("-"):
|
||||
stats.deletions += 1
|
||||
diff_lines.append(
|
||||
DiffLine("delete", line[1:].rstrip(), old_line_num, None)
|
||||
)
|
||||
diff_lines.append(DiffLine("delete", line[1:].rstrip(), old_line_num, None))
|
||||
old_line_num += 1
|
||||
elif line.startswith(" "):
|
||||
diff_lines.append(
|
||||
@@ -182,14 +178,10 @@ class DiffDisplay:
|
||||
|
||||
for tag, i1, i2, j1, j2 in matcher.get_opcodes():
|
||||
if tag == "equal":
|
||||
for i, (old_line, new_line) in enumerate(
|
||||
zip(old_lines[i1:i2], new_lines[j1:j2])
|
||||
):
|
||||
for i, (old_line, new_line) in enumerate(zip(old_lines[i1:i2], new_lines[j1:j2])):
|
||||
old_display = old_line[:half_width].ljust(half_width)
|
||||
new_display = new_line[:half_width].ljust(half_width)
|
||||
output.append(
|
||||
f"{Colors.GRAY}{old_display} | {new_display}{Colors.RESET}"
|
||||
)
|
||||
output.append(f"{Colors.GRAY}{old_display} | {new_display}{Colors.RESET}")
|
||||
elif tag == "replace":
|
||||
max_lines = max(i2 - i1, j2 - j1)
|
||||
for i in range(max_lines):
|
||||
@@ -203,15 +195,11 @@ class DiffDisplay:
|
||||
elif tag == "delete":
|
||||
for old_line in old_lines[i1:i2]:
|
||||
old_display = old_line[:half_width].ljust(half_width)
|
||||
output.append(
|
||||
f"{Colors.RED}{old_display} | {' ' * half_width}{Colors.RESET}"
|
||||
)
|
||||
output.append(f"{Colors.RED}{old_display} | {' ' * half_width}{Colors.RESET}")
|
||||
elif tag == "insert":
|
||||
for new_line in new_lines[j1:j2]:
|
||||
new_display = new_line[:half_width].ljust(half_width)
|
||||
output.append(
|
||||
f"{' ' * half_width} | {Colors.GREEN}{new_display}{Colors.RESET}"
|
||||
)
|
||||
output.append(f"{' ' * half_width} | {Colors.GREEN}{new_display}{Colors.RESET}")
|
||||
|
||||
output.append(f"\n{Colors.BOLD}{Colors.BLUE}{'=' * width}{Colors.RESET}\n")
|
||||
return "\n".join(output)
|
||||
|
||||
+1
-3
@@ -16,8 +16,6 @@ def display_tool_call(tool_name, arguments, status="running", result=None):
|
||||
|
||||
def print_autonomous_header(task):
|
||||
print(f"{Colors.BOLD}Task:{Colors.RESET} {task}")
|
||||
print(
|
||||
f"{Colors.GRAY}r will work continuously until the task is complete.{Colors.RESET}"
|
||||
)
|
||||
print(f"{Colors.GRAY}r will work continuously until the task is complete.{Colors.RESET}")
|
||||
print(f"{Colors.GRAY}Press Ctrl+C twice to interrupt.{Colors.RESET}\n")
|
||||
print(f"{Colors.BOLD}{'═' * 80}{Colors.RESET}\n")
|
||||
|
||||
+5
-15
@@ -46,23 +46,17 @@ class EditOperation:
|
||||
output = [self.format_operation()]
|
||||
|
||||
if self.op_type in ("INSERT", "REPLACE"):
|
||||
output.append(
|
||||
f" {Colors.GRAY}Position: {self.start_pos}-{self.end_pos}{Colors.RESET}"
|
||||
)
|
||||
output.append(f" {Colors.GRAY}Position: {self.start_pos}-{self.end_pos}{Colors.RESET}")
|
||||
|
||||
if show_content:
|
||||
if self.old_content:
|
||||
lines = self.old_content.split("\n")
|
||||
preview = lines[0][:60] + (
|
||||
"..." if len(lines[0]) > 60 or len(lines) > 1 else ""
|
||||
)
|
||||
preview = lines[0][:60] + ("..." if len(lines[0]) > 60 or len(lines) > 1 else "")
|
||||
output.append(f" {Colors.RED}- {preview}{Colors.RESET}")
|
||||
|
||||
if self.content:
|
||||
lines = self.content.split("\n")
|
||||
preview = lines[0][:60] + (
|
||||
"..." if len(lines[0]) > 60 or len(lines) > 1 else ""
|
||||
)
|
||||
preview = lines[0][:60] + ("..." if len(lines[0]) > 60 or len(lines) > 1 else "")
|
||||
output.append(f" {Colors.GREEN}+ {preview}{Colors.RESET}")
|
||||
|
||||
return "\n".join(output)
|
||||
@@ -93,9 +87,7 @@ class EditTracker:
|
||||
"total": len(self.operations),
|
||||
"completed": sum(1 for op in self.operations if op.status == "completed"),
|
||||
"pending": sum(1 for op in self.operations if op.status == "pending"),
|
||||
"in_progress": sum(
|
||||
1 for op in self.operations if op.status == "in_progress"
|
||||
),
|
||||
"in_progress": sum(1 for op in self.operations if op.status == "in_progress"),
|
||||
"failed": sum(1 for op in self.operations if op.status == "failed"),
|
||||
}
|
||||
return stats
|
||||
@@ -112,9 +104,7 @@ class EditTracker:
|
||||
|
||||
output = []
|
||||
output.append(f"\n{Colors.BOLD}{Colors.BLUE}{'=' * 60}{Colors.RESET}")
|
||||
output.append(
|
||||
f"{Colors.BOLD}{Colors.BLUE}EDIT OPERATIONS PROGRESS{Colors.RESET}"
|
||||
)
|
||||
output.append(f"{Colors.BOLD}{Colors.BLUE}EDIT OPERATIONS PROGRESS{Colors.RESET}")
|
||||
output.append(f"{Colors.BOLD}{Colors.BLUE}{'=' * 60}{Colors.RESET}\n")
|
||||
|
||||
stats = self.get_stats()
|
||||
|
||||
+2
-8
@@ -62,16 +62,10 @@ class ProgressBar:
|
||||
else:
|
||||
percent = int((self.current / self.total) * 100)
|
||||
|
||||
filled = (
|
||||
int((self.current / self.total) * self.width)
|
||||
if self.total > 0
|
||||
else self.width
|
||||
)
|
||||
filled = int((self.current / self.total) * self.width) if self.total > 0 else self.width
|
||||
bar = "█" * filled + "░" * (self.width - filled)
|
||||
|
||||
sys.stdout.write(
|
||||
f"\r{self.description}: |{bar}| {percent}% ({self.current}/{self.total})"
|
||||
)
|
||||
sys.stdout.write(f"\r{self.description}: |{bar}| {percent}% ({self.current}/{self.total})")
|
||||
sys.stdout.flush()
|
||||
|
||||
if self.current >= self.total:
|
||||
|
||||
+8
-8
@@ -25,12 +25,8 @@ def highlight_code(code, language=None, syntax_highlighting=True):
|
||||
code = re.sub(r'"([^"]*)"', f'{Colors.GREEN}"\\1"{Colors.RESET}', code)
|
||||
code = re.sub(r"'([^']*)'", f"{Colors.GREEN}'\\1'{Colors.RESET}", code)
|
||||
|
||||
code = re.sub(
|
||||
r"#(.*)$", f"{Colors.GRAY}#\\1{Colors.RESET}", code, flags=re.MULTILINE
|
||||
)
|
||||
code = re.sub(
|
||||
r"//(.*)$", f"{Colors.GRAY}//\\1{Colors.RESET}", code, flags=re.MULTILINE
|
||||
)
|
||||
code = re.sub(r"#(.*)$", f"{Colors.GRAY}#\\1{Colors.RESET}", code, flags=re.MULTILINE)
|
||||
code = re.sub(r"//(.*)$", f"{Colors.GRAY}//\\1{Colors.RESET}", code, flags=re.MULTILINE)
|
||||
|
||||
return code
|
||||
|
||||
@@ -76,11 +72,15 @@ def render_markdown(text, syntax_highlighting=True):
|
||||
elif re.match(r"^\s*[\*\-\+]\s", line):
|
||||
match = re.match(r"^(\s*)([\*\-\+])(\s+.*)", line)
|
||||
if match:
|
||||
line = f"{match.group(1)}{Colors.YELLOW}{match.group(2)}{Colors.RESET}{match.group(3)}"
|
||||
line = (
|
||||
f"{match.group(1)}{Colors.YELLOW}{match.group(2)}{Colors.RESET}{match.group(3)}"
|
||||
)
|
||||
elif re.match(r"^\s*\d+\.\s", line):
|
||||
match = re.match(r"^(\s*)(\d+\.)(\s+.*)", line)
|
||||
if match:
|
||||
line = f"{match.group(1)}{Colors.YELLOW}{match.group(2)}{Colors.RESET}{match.group(3)}"
|
||||
line = (
|
||||
f"{match.group(1)}{Colors.YELLOW}{match.group(2)}{Colors.RESET}{match.group(3)}"
|
||||
)
|
||||
processed_lines.append(line)
|
||||
text = "\n".join(processed_lines)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user