mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-05-29 06:31:32 +00:00
fix: tolerate non-utf8 filenames in file discovery
This commit is contained in:
parent
d990fa52ed
commit
a7df9f0245
4 changed files with 75 additions and 5 deletions
|
|
@ -991,11 +991,14 @@ class SlashCommandCompleter(Completer):
|
|||
continue
|
||||
try:
|
||||
proc = subprocess.run(
|
||||
cmd, capture_output=True, text=True, timeout=2,
|
||||
cmd,
|
||||
capture_output=True,
|
||||
text=False,
|
||||
timeout=2,
|
||||
cwd=cwd,
|
||||
)
|
||||
if proc.returncode == 0 and proc.stdout.strip():
|
||||
raw = proc.stdout.strip().split("\n")
|
||||
raw = _decode_fs_lines(proc.stdout)
|
||||
if proc.returncode == 0 and raw:
|
||||
# Store relative paths
|
||||
for p in raw[:5000]:
|
||||
rel = os.path.relpath(p, cwd) if os.path.isabs(p) else p
|
||||
|
|
@ -1324,6 +1327,14 @@ class SlashCommandAutoSuggest(AutoSuggest):
|
|||
return None
|
||||
|
||||
|
||||
def _decode_fs_lines(data: bytes) -> list[str]:
|
||||
"""Decode subprocess file listings using filesystem semantics.
|
||||
|
||||
This preserves non-UTF-8 filenames via surrogateescape instead of raising.
|
||||
"""
|
||||
return [os.fsdecode(line) for line in data.splitlines() if line]
|
||||
|
||||
|
||||
def _file_size_label(path: str) -> str:
|
||||
"""Return a compact human-readable file size, or '' on error."""
|
||||
try:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue