Skip to content

fix: cross-platform stat command for macOS compatibility#58

Closed
deankerr wants to merge 1 commit into
NousResearch:mainfrom
deankerr:fix/macos-stat-compat
Closed

fix: cross-platform stat command for macOS compatibility#58
deankerr wants to merge 1 commit into
NousResearch:mainfrom
deankerr:fix/macos-stat-compat

Conversation

@deankerr

Copy link
Copy Markdown
Contributor

Summary

  • stat -c '%s' is GNU coreutils only — fails on macOS/BSD where the equivalent is stat -f '%z'
  • Adds _stat_size_cmd() helper to ShellFileOperations that tries GNU stat first, falls back to BSD stat
  • Replaces 3 hardcoded stat -c calls in read_file, _read_image, and write_file

Context

The read_file and write_file tools use stat to get file sizes. On macOS with TERMINAL_ENV=local, these tools silently fail because macOS ships BSD stat which doesn't support the -c format flag.

Test plan

  • Verified read_file works on macOS local backend (reads /etc/hosts correctly)
  • Verified write_file works on macOS local backend (reports correct byte count)
  • Confirmed no other reachable stat -c calls remain in codebase
  • Linux behavior unchanged — GNU stat is tried first

🤖 Generated with Claude Code

GNU stat uses -c '%s' but macOS/BSD stat uses -f '%z'. The file tools
were silently failing on macOS, causing read_file to always report
"file not found" even when the file exists.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@deankerr deankerr marked this pull request as ready for review February 26, 2026 09:37
@teknium1

Copy link
Copy Markdown
Contributor

0cce536

Opus suggested a cleaner fix that doesn't require fallbacks and works identically on both OS' - lmk if you find any other issue with this but credited you in the commit!

@teknium1 teknium1 closed this Feb 27, 2026
@deankerr deankerr deleted the fix/macos-stat-compat branch April 1, 2026 08:11
sudo-yf pushed a commit to sudo-yf/hermes-agent that referenced this pull request Apr 5, 2026
…search#58)

The backend CLI session bridge (PR NousResearch#56) was complete but the frontend
never connected to it:

1. css class never applied -- el.className never included 'cli-session'
   so the gold border and 'cli' badge CSS was dead code. Fixed: append
   ' cli-session' when s.is_cli_session is true.

2. import never triggered -- click handler always called loadSession()
   directly, never POST /api/session/import_cli. Fixed: for CLI sessions,
   call import_cli first (idempotent -- safe to call on every click),
   then fall through to loadSession() which now finds the imported copy.

3. profile filter silently hid CLI sessions -- filter required
   s.profile === S.activeProfile, but CLI sessions may have profile=null
   if the SQLite DB has no profile column. Fixed: CLI sessions always
   pass the filter (s.is_cli_session || s.profile === S.activeProfile).

Co-authored-by: Nathan Esquenazi <nesquena@gmail.com>
linxule added a commit to linxule/hermes-agent that referenced this pull request Apr 27, 2026
…k variant

Parity port from linxule/hermes-kimi-plugin@93476f5 — same four fixes plus
the NousResearch#60 fold-in:

1. connect# off-by-one: counter + ts now bumped pre-dispatch in
   _group_subscribe_once so the gap log inside _on_group_event reads the
   correct connect# (matches the subscribe-stream-live log emitted moments
   later). Subscribe-live log + backoff clamp stay post-dispatch as the
   operator-visible recovery announcement.

2. Monotonic clock: arrival-time tracking + since-reconnect correlation
   now use time.monotonic() (immune to NTP/leap-second/VM-suspend).

3. _BoundedLRU shared cap: _last_arrival_time_per_room gets its own
   _ARRIVAL_TIME_CACHE_DEFAULT_MAX (10000), so eviction can't blind
   Phase 0 gap detection under cardinality pressure.

4. Anchor-only-on-first-page in list_group_messages: pageToken and
   start_message_id/end_message_id are now mutually-exclusive cursoring
   modes.

Fold-in (NousResearch#60): _fetch_group_message uses max_pages=2 for tight-range
pagination resilience.

Tests: 200 passing on fork (194 unit + 6 plugin-integration). Same +10/-1
delta as standalone. Existing handler-exception test updated to reflect
new pre-dispatch state semantic.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
NikolayGusev-astra pushed a commit to NikolayGusev-astra/autolycus that referenced this pull request May 15, 2026
…gs, 31/31 tests pass

New architecture (4 layers):
- store.py — persist full result to ~/.autolycus/rtk-cache/<uuid>.txt
- compressor.py — type-aware dispatcher (terminal/read_file/search_files)
- strategies/* — per-tool compression (tail-first for terminal, offset-aware for read_file, compact for search_files)
- monitor.py — per-tool aggregated metrics w/ JSON export
- __init__.py — transform_tool_result hook + rtk_recover tool

Benchmark on production-like data:
- systemctl: 57.6% savings (525 tokens/call)
- MOEX scanner: 57.0% savings (513 tokens/call)
- search_files: 96.1% savings (1,319 tokens/call)
- read_file: 91.5% savings (4,180 tokens/call)
- Global: 84.4% savings, ALL data recoverable

Closes: NousResearch#58
sahilm-ti pushed a commit to sahilm-ti/hermes-agent that referenced this pull request Jun 3, 2026
…a dirty live tree

The hourly ~/.hermes auto-pull silently DEBUG-skipped on a dirty working
tree. The live tree is almost always dirty (continuous skill-edit churn),
so incoming merges piled up undelivered on disk with zero alerting (PRs
NousResearch#54-NousResearch#58, ~5 merges, only noticed when a cron broke).

- _pull_once now counts commits-behind BEFORE the clean check so it can
  distinguish the WEDGED state (on main, behind>0, dirty) from up-to-date.
  Wedged invokes an optional notify callback; clean+behind still
  fast-forwards; up-to-date and feature-branch stay silent DEBUG.
- HermesHomePuller takes a notifier + throttles wedged alerts (default 6h,
  tracked via _last_alert_ts) so the operator isn't paged hourly. The
  throttle clock only advances once the notifier actually accepts the
  message, so a failed send retries next tick.
- GatewayRunner gains _send_operator_alert (reuses the home-channel
  adapter.send surface used by shutdown/startup notifications) and
  make_operator_alert_callback (thread-safe sink via safe_schedule_threadsafe).
  start_gateway threads the callback into start_hermes_home_puller.
- Tests: wedged fires once then suppressed in-window then again after the
  window elapses; clean+behind fast-forwards no alert; up-to-date no alert
  no pull; feature branch no alert; notifier-exception non-fatal + no
  throttle advance. 30 -> 39 tests.
fabiosiqueira added a commit to fabiosiqueira/hermes-engine that referenced this pull request Jun 3, 2026
…mes#62)

Expõe action=edit na tool send_message, espelhando o caminho send mas
enxuto (texto-only, Telegram-only). _handle_edit valida message_ref
({channel,chat_id,message_id}) e despacha para _edit_telegram, que usa
bot.edit_message_text com HTML auto-detect, fallback de parse para plain
e trata 'message is not modified' como sucesso. Outras plataformas
retornam erro claro.

Desdobrado da NousResearch#58 (critério NousResearch#2: editar mensagem anterior in-place).
TDD: TestEditTelegram + TestHandleEditDispatch (mock só em telegram.Bot).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
sahilm-ti added a commit to sahilm-ti/hermes-agent that referenced this pull request Jun 5, 2026
…a dirty live tree (#45)

The hourly ~/.hermes auto-pull silently DEBUG-skipped on a dirty working
tree. The live tree is almost always dirty (continuous skill-edit churn),
so incoming merges piled up undelivered on disk with zero alerting (PRs
NousResearch#54-NousResearch#58, ~5 merges, only noticed when a cron broke).

- _pull_once now counts commits-behind BEFORE the clean check so it can
  distinguish the WEDGED state (on main, behind>0, dirty) from up-to-date.
  Wedged invokes an optional notify callback; clean+behind still
  fast-forwards; up-to-date and feature-branch stay silent DEBUG.
- HermesHomePuller takes a notifier + throttles wedged alerts (default 6h,
  tracked via _last_alert_ts) so the operator isn't paged hourly. The
  throttle clock only advances once the notifier actually accepts the
  message, so a failed send retries next tick.
- GatewayRunner gains _send_operator_alert (reuses the home-channel
  adapter.send surface used by shutdown/startup notifications) and
  make_operator_alert_callback (thread-safe sink via safe_schedule_threadsafe).
  start_gateway threads the callback into start_hermes_home_puller.
- Tests: wedged fires once then suppressed in-window then again after the
  window elapses; clean+behind fast-forwards no alert; up-to-date no alert
  no pull; feature branch no alert; notifier-exception non-fatal + no
  throttle advance. 30 -> 39 tests.

Co-authored-by: Sahil (AI) <266772320+sahilm-ai@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants