cortex-llm 1.0.10__py3-none-any.whl → 1.0.11__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.
- cortex/__init__.py +1 -1
- cortex/config.py +46 -10
- cortex/inference_engine.py +69 -32
- cortex/tools/fs_ops.py +60 -13
- cortex/tools/search.py +76 -11
- cortex/tools/tool_runner.py +68 -8
- cortex/ui/box_rendering.py +97 -0
- cortex/ui/cli.py +65 -1071
- cortex/ui/cli_commands.py +61 -0
- cortex/ui/cli_prompt.py +96 -0
- cortex/ui/help_ui.py +66 -0
- cortex/ui/input_box.py +205 -0
- cortex/ui/model_ui.py +408 -0
- cortex/ui/status_ui.py +78 -0
- cortex/ui/tool_activity.py +82 -0
- {cortex_llm-1.0.10.dist-info → cortex_llm-1.0.11.dist-info}/METADATA +3 -1
- {cortex_llm-1.0.10.dist-info → cortex_llm-1.0.11.dist-info}/RECORD +21 -13
- {cortex_llm-1.0.10.dist-info → cortex_llm-1.0.11.dist-info}/WHEEL +0 -0
- {cortex_llm-1.0.10.dist-info → cortex_llm-1.0.11.dist-info}/entry_points.txt +0 -0
- {cortex_llm-1.0.10.dist-info → cortex_llm-1.0.11.dist-info}/licenses/LICENSE +0 -0
- {cortex_llm-1.0.10.dist-info → cortex_llm-1.0.11.dist-info}/top_level.txt +0 -0
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
"""Box rendering utilities for CLI."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import re
|
|
6
|
+
import unicodedata
|
|
7
|
+
from typing import List, Optional
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
def get_visible_length(text: str) -> int:
|
|
11
|
+
"""Get visible length of text, ignoring ANSI escape codes and accounting for wide characters."""
|
|
12
|
+
ansi_escape = re.compile(r"\x1b\[[0-9;]*m")
|
|
13
|
+
visible_text = ansi_escape.sub("", text)
|
|
14
|
+
|
|
15
|
+
display_width = 0
|
|
16
|
+
for char in visible_text:
|
|
17
|
+
width = unicodedata.east_asian_width(char)
|
|
18
|
+
if width in ("W", "F"):
|
|
19
|
+
display_width += 2
|
|
20
|
+
elif width == "A" and char in "●○":
|
|
21
|
+
display_width += 1
|
|
22
|
+
else:
|
|
23
|
+
display_width += 1
|
|
24
|
+
|
|
25
|
+
return display_width
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
def print_box_line(content: str, width: int, align: str = "left") -> None:
|
|
29
|
+
"""Print a single line in a box with proper padding."""
|
|
30
|
+
visible_len = get_visible_length(content)
|
|
31
|
+
padding = width - visible_len - 2
|
|
32
|
+
|
|
33
|
+
if align == "center":
|
|
34
|
+
left_pad = padding // 2
|
|
35
|
+
right_pad = padding - left_pad
|
|
36
|
+
print(f"│{' ' * left_pad}{content}{' ' * right_pad}│")
|
|
37
|
+
else:
|
|
38
|
+
print(f"│{content}{' ' * padding}│")
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
def print_box_header(title: str, width: int) -> None:
|
|
42
|
+
"""Print a box header with title."""
|
|
43
|
+
if title:
|
|
44
|
+
title_with_color = f" \033[96m{title}\033[0m "
|
|
45
|
+
visible_len = get_visible_length(title_with_color)
|
|
46
|
+
padding = width - visible_len - 3
|
|
47
|
+
print(f"╭─{title_with_color}" + "─" * padding + "╮")
|
|
48
|
+
else:
|
|
49
|
+
print("╭" + "─" * (width - 2) + "╮")
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
def print_box_footer(width: int) -> None:
|
|
53
|
+
"""Print a box footer."""
|
|
54
|
+
print("╰" + "─" * (width - 2) + "╯")
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
def print_box_separator(width: int) -> None:
|
|
58
|
+
"""Print a separator line inside a box."""
|
|
59
|
+
print("├" + "─" * (width - 2) + "┤")
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
def print_empty_line(width: int) -> None:
|
|
63
|
+
"""Print an empty line inside a box."""
|
|
64
|
+
print("│" + " " * (width - 2) + "│")
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
def create_box(
|
|
68
|
+
lines: List[str],
|
|
69
|
+
*,
|
|
70
|
+
width: Optional[int],
|
|
71
|
+
terminal_width: int,
|
|
72
|
+
) -> str:
|
|
73
|
+
"""Create a box with Unicode borders."""
|
|
74
|
+
if width is None:
|
|
75
|
+
width = min(terminal_width - 2, 80)
|
|
76
|
+
|
|
77
|
+
top_left = "╭"
|
|
78
|
+
top_right = "╮"
|
|
79
|
+
bottom_left = "╰"
|
|
80
|
+
bottom_right = "╯"
|
|
81
|
+
horizontal = "─"
|
|
82
|
+
vertical = "│"
|
|
83
|
+
|
|
84
|
+
inner_width = width - 4
|
|
85
|
+
|
|
86
|
+
result = []
|
|
87
|
+
result.append(top_left + horizontal * (width - 2) + top_right)
|
|
88
|
+
|
|
89
|
+
for line in lines:
|
|
90
|
+
visible_len = get_visible_length(line)
|
|
91
|
+
padding_needed = inner_width - visible_len
|
|
92
|
+
padded = f" {line}{' ' * padding_needed} "
|
|
93
|
+
result.append(vertical + padded + vertical)
|
|
94
|
+
|
|
95
|
+
result.append(bottom_left + horizontal * (width - 2) + bottom_right)
|
|
96
|
+
|
|
97
|
+
return "\n".join(result)
|