fleetdeck 0.3.0__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.
- fleetdeck/__init__.py +3 -0
- fleetdeck/__main__.py +232 -0
- fleetdeck/accounts.py +115 -0
- fleetdeck/adapters/__init__.py +0 -0
- fleetdeck/adapters/base.py +71 -0
- fleetdeck/adapters/claude_cli.py +187 -0
- fleetdeck/adapters/codex_cli.py +362 -0
- fleetdeck/adapters/demo.py +331 -0
- fleetdeck/config.py +323 -0
- fleetdeck/db.py +511 -0
- fleetdeck/gitinfo.py +169 -0
- fleetdeck/models.py +178 -0
- fleetdeck/paths.py +64 -0
- fleetdeck/proc.py +92 -0
- fleetdeck/redact.py +51 -0
- fleetdeck/services/__init__.py +0 -0
- fleetdeck/services/dispatcher.py +382 -0
- fleetdeck/services/fleet.py +65 -0
- fleetdeck/services/monitor.py +253 -0
- fleetdeck/services/notifier.py +71 -0
- fleetdeck/status.py +97 -0
- fleetdeck/terminal.py +235 -0
- fleetdeck/termrender.py +129 -0
- fleetdeck/ui/__init__.py +0 -0
- fleetdeck/ui/app.py +1295 -0
- fleetdeck/ui/app.tcss +263 -0
- fleetdeck/ui/commands.py +63 -0
- fleetdeck/ui/screens/__init__.py +0 -0
- fleetdeck/ui/screens/modals.py +623 -0
- fleetdeck/ui/style.py +150 -0
- fleetdeck/ui/views.py +230 -0
- fleetdeck/ui/widgets/__init__.py +0 -0
- fleetdeck/ui/widgets/agent_table.py +185 -0
- fleetdeck/ui/widgets/bottom.py +27 -0
- fleetdeck/ui/widgets/details.py +295 -0
- fleetdeck/ui/widgets/header.py +87 -0
- fleetdeck/ui/widgets/sidebar.py +227 -0
- fleetdeck/ui/widgets/splitter.py +66 -0
- fleetdeck/ui/widgets/terminal.py +119 -0
- fleetdeck-0.3.0.dist-info/METADATA +245 -0
- fleetdeck-0.3.0.dist-info/RECORD +44 -0
- fleetdeck-0.3.0.dist-info/WHEEL +4 -0
- fleetdeck-0.3.0.dist-info/entry_points.txt +2 -0
- fleetdeck-0.3.0.dist-info/licenses/LICENSE +21 -0
fleetdeck/termrender.py
ADDED
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
"""Render `claude logs` output into readable, redacted Rich text.
|
|
2
|
+
|
|
3
|
+
`claude logs <id>` prints a snapshot of the session's terminal screen: a frame
|
|
4
|
+
drawn with cursor positioning (CSI H/B/C/G), save/restore (ESC 7/8), erase and
|
|
5
|
+
carriage returns, not plain lines. Replaying it through a VT emulator (pyte)
|
|
6
|
+
recovers exactly what the terminal would show.
|
|
7
|
+
"""
|
|
8
|
+
|
|
9
|
+
from __future__ import annotations
|
|
10
|
+
|
|
11
|
+
import re
|
|
12
|
+
|
|
13
|
+
from rich.text import Text
|
|
14
|
+
|
|
15
|
+
from .redact import redact
|
|
16
|
+
|
|
17
|
+
try:
|
|
18
|
+
import pyte
|
|
19
|
+
except ImportError: # pragma: no cover — declared dependency; degrade to stripping
|
|
20
|
+
pyte = None
|
|
21
|
+
|
|
22
|
+
_ESCAPES = re.compile(r"\x1b(?:\[[0-9;?]*[ -/]*[@-~]|\][^\x07\x1b]*(?:\x07|\x1b\\)|[()][A-Z0-9]|[78=>])")
|
|
23
|
+
|
|
24
|
+
_NAMED = {
|
|
25
|
+
"black": "black", "red": "red", "green": "green", "brown": "yellow",
|
|
26
|
+
"yellow": "yellow", "blue": "blue", "magenta": "magenta", "cyan": "cyan",
|
|
27
|
+
"white": "white", "brightblack": "bright_black", "brightred": "bright_red",
|
|
28
|
+
"brightgreen": "bright_green", "brightbrown": "bright_yellow",
|
|
29
|
+
"brightyellow": "bright_yellow", "brightblue": "bright_blue",
|
|
30
|
+
"brightmagenta": "bright_magenta", "brightcyan": "bright_cyan",
|
|
31
|
+
"brightwhite": "bright_white",
|
|
32
|
+
}
|
|
33
|
+
_HEX = re.compile(r"^[0-9a-fA-F]{6}$")
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
def _color(value: str) -> str | None:
|
|
37
|
+
if not value or value == "default":
|
|
38
|
+
return None
|
|
39
|
+
if _HEX.match(value):
|
|
40
|
+
return f"#{value.lower()}"
|
|
41
|
+
return _NAMED.get(value)
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
def char_style(ch) -> str:
|
|
45
|
+
"""Rich style string for a pyte character cell."""
|
|
46
|
+
return _style(ch)
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
def _style(ch) -> str:
|
|
50
|
+
parts = []
|
|
51
|
+
if ch.bold:
|
|
52
|
+
parts.append("bold")
|
|
53
|
+
if ch.italics:
|
|
54
|
+
parts.append("italic")
|
|
55
|
+
if ch.underscore:
|
|
56
|
+
parts.append("underline")
|
|
57
|
+
if ch.reverse:
|
|
58
|
+
parts.append("reverse")
|
|
59
|
+
fg = _color(ch.fg)
|
|
60
|
+
if fg:
|
|
61
|
+
parts.append(fg)
|
|
62
|
+
bg = _color(ch.bg)
|
|
63
|
+
if bg:
|
|
64
|
+
parts.append(f"on {bg}")
|
|
65
|
+
return " ".join(parts)
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
def strip_escapes(raw: str) -> str:
|
|
69
|
+
text = _ESCAPES.sub("", raw).replace("\r\n", "\n").replace("\r", "\n")
|
|
70
|
+
return "".join(c for c in text if c in "\n\t" or c >= " ")
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
def _collapse(lines: list[Text]) -> list[Text]:
|
|
74
|
+
out: list[Text] = []
|
|
75
|
+
blank = False
|
|
76
|
+
for line in lines:
|
|
77
|
+
is_blank = not line.plain.strip()
|
|
78
|
+
if is_blank and (blank or not out):
|
|
79
|
+
continue
|
|
80
|
+
out.append(line)
|
|
81
|
+
blank = is_blank
|
|
82
|
+
while out and not out[-1].plain.strip():
|
|
83
|
+
out.pop()
|
|
84
|
+
return out
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
def render_lines(raw: str, *, cols: int = 240, max_rows: int = 2000) -> list[Text]:
|
|
88
|
+
"""Replay ``raw`` on a virtual terminal and return redacted styled lines."""
|
|
89
|
+
if not raw:
|
|
90
|
+
return []
|
|
91
|
+
if pyte is None:
|
|
92
|
+
return _collapse([Text(redact(l)) for l in strip_escapes(raw).splitlines()])
|
|
93
|
+
try:
|
|
94
|
+
rows = min(max_rows, max(60, raw.count("\n") + raw.count("\r") + 5))
|
|
95
|
+
screen = pyte.Screen(cols, rows)
|
|
96
|
+
screen.set_mode(pyte.modes.LNM) # LF implies CR: plain-text logs render too
|
|
97
|
+
pyte.Stream(screen).feed(raw)
|
|
98
|
+
except Exception: # noqa: BLE001 — malformed stream: fall back to stripping
|
|
99
|
+
return _collapse([Text(redact(l)) for l in strip_escapes(raw).splitlines()])
|
|
100
|
+
|
|
101
|
+
lines: list[Text] = []
|
|
102
|
+
for y in range(screen.lines):
|
|
103
|
+
row = screen.buffer[y]
|
|
104
|
+
plain = "".join(row[x].data for x in range(screen.columns)).rstrip()
|
|
105
|
+
safe = redact(plain)
|
|
106
|
+
if safe != plain: # never keep styling spans that could re-expose a secret
|
|
107
|
+
lines.append(Text(safe))
|
|
108
|
+
continue
|
|
109
|
+
text = Text()
|
|
110
|
+
run, run_style = "", None
|
|
111
|
+
for x in range(len(plain)):
|
|
112
|
+
ch = row[x]
|
|
113
|
+
st = _style(ch)
|
|
114
|
+
if st != run_style and run:
|
|
115
|
+
text.append(run, style=run_style or "")
|
|
116
|
+
run = ""
|
|
117
|
+
run_style = st
|
|
118
|
+
run += ch.data
|
|
119
|
+
if run:
|
|
120
|
+
text.append(run, style=run_style or "")
|
|
121
|
+
lines.append(text)
|
|
122
|
+
return _collapse(lines)
|
|
123
|
+
|
|
124
|
+
|
|
125
|
+
def render(raw: str, *, tail: int | None = None) -> Text:
|
|
126
|
+
lines = render_lines(raw)
|
|
127
|
+
if tail is not None:
|
|
128
|
+
lines = lines[-tail:]
|
|
129
|
+
return Text("\n").join(lines)
|
fleetdeck/ui/__init__.py
ADDED
|
File without changes
|