Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 0 additions & 7 deletions tests/tools/test_file_operations.py
Original file line number Diff line number Diff line change
Expand Up @@ -356,13 +356,6 @@ def test_add_line_numbers_with_offset(self, file_ops):
assert "50|continued" in result
assert "51|more" in result

def test_add_line_numbers_padded_env_override(self, file_ops, monkeypatch):
# Legacy fixed-width format available via HERMES_READ_GUTTER=padded.
monkeypatch.setenv("HERMES_READ_GUTTER", "padded")
result = file_ops._add_line_numbers("line one\nline two")
assert " 1|line one" in result
assert " 2|line two" in result

def test_add_line_numbers_truncates_long_lines(self, file_ops):
long_line = "x" * (MAX_LINE_LENGTH + 100)
result = file_ops._add_line_numbers(long_line)
Expand Down
8 changes: 2 additions & 6 deletions tools/file_operations.py
Original file line number Diff line number Diff line change
Expand Up @@ -714,21 +714,17 @@ def _add_line_numbers(self, content: str, start_line: int = 1) -> str:
line-reference / patch / value-lookup / structure tasks (4/4 both),
while dropping line numbers entirely regressed line-referencing
(the model hand-counted and was off-by-one, 3/4) — so we keep the
numbers, just not the padding. ``HERMES_READ_GUTTER=padded``
restores the legacy fixed-width format for anyone who relied on
column alignment.
numbers, just not the padding.
"""
import os as _os
from tools.tool_output_limits import get_max_line_length
padded = (_os.environ.get("HERMES_READ_GUTTER") or "").lower() == "padded"
max_line_length = get_max_line_length()
lines = content.split('\n')
numbered = []
for i, line in enumerate(lines, start=start_line):
# Truncate long lines
if len(line) > max_line_length:
line = line[:max_line_length] + "... [truncated]"
numbered.append(f"{i:6d}|{line}" if padded else f"{i}|{line}")
numbered.append(f"{i}|{line}")
return '\n'.join(numbered)

def _expand_path(self, path: str) -> str:
Expand Down
Loading