Skip to content

Harden edit_file matching and complete VPS SSH tools - #18

Open
nvdorman wants to merge 7 commits into
enowdev:mainfrom
nvdorman:fix/edit-file-vps-tools
Open

Harden edit_file matching and complete VPS SSH tools#18
nvdorman wants to merge 7 commits into
enowdev:mainfrom
nvdorman:fix/edit-file-vps-tools

Conversation

@nvdorman

@nvdorman nvdorman commented Aug 2, 2026

Copy link
Copy Markdown
Contributor

Summary

  • edit_file: recover from common read_file → edit failures (LF paste against CRLF files, pasted NUMBER| line prefixes), diagnose tab-vs-space mismatches, and teach the NUMBER|CONTENT contract in the system prompt.
  • vps_run: fix flaky/false timeouts on systemctl-class work — default timeout 120s (max 900), agent envelope above that, race-free session cancel, keyboard-interactive password auth, SSH keepalives, and actionable timeout errors with partial output.
  • vps_upload / vps_download: new SFTP tools to push/pull single files (max 256 MiB), registered in default/security toolsets, with skill/role/docs updates.

Root causes (researched, not guessed)

  1. read_file always displays LF while edit_file must match on-disk bytes; this completes CRLF recovery, strips accidental NUMBER| pastes, and surfaces tab/space diagnostics.
  2. vps_run defaulted to 60s while systemctl restart/stop often exceeds that; the agent tool envelope (5m) could cut off long timeout_seconds early; password-only auth failed on keyboard-interactive hosts; the timeout path raced on output and did not reliably close the SSH session.

Test plan

  • go test ./internal/tools/ ./internal/vps/ ./internal/agent/ -count=1
  • go build ./cmd/antares
  • Manual: project session — read_file a CRLF/tabbed source, edit_file with content after |
  • Manual: vps_run list servers; systemctl status … --no-pager; restart with timeout_seconds=180
  • Manual: vps_upload a small file, vps_download it back, confirm bytes

edit_file now recovers from the common read_file→edit failures (CRLF vs LF,
pasted NUMBER| prefixes) and diagnoses tab/space mismatches; system prompt
documents the NUMBER|CONTENT contract.

vps_run no longer false-timeouts on systemctl-class work: default 120s,
agent envelope above the 900s max, race-free cancel, keyboard-interactive
auth, and clear timeout errors. Add vps_upload/vps_download over SFTP.
//go:embed all:dist fails on a bare checkout because built assets are
gitignored. Track a .gitkeep placeholder and recreate it in CI so test/vet
compile without a frontend build.
Persistent-shell scripts keep stdin open for the next tool call. Children
like `adb shell` inherit that pipe, steal the completion sentinel or block
on it, and the tool waits until timeout even though remote work finished.
Run each command in a brace group with stdin from /dev/null so the sentinel
can fire immediately; brace group preserves cd/export across calls.
Dashboard login sessions lived only in memory, so after antares restart the
browser cookie looked valid but /api/chat/attach returned 401 in a 3s loop —
live tool/stream updates never arrived. Persist sessions to disk and accept
allowlisted ?token= in dashboard auth.

The chat UI ignored EventNotice, so multi-minute context compaction showed
only "Working… · Ns". Surface notices in the streaming indicator, and stream
GET attach via fetch+credentials instead of EventSource for reliable cookies.
… turn

Compaction ran on every turn for oversized sessions because the summary
lived only in memory while loadHistory always reloaded all raw messages.
Store the summary and through_seq on session meta; subsequent turns load
head+summary+tail and only compact again when that view exceeds the threshold.
Clear the meta on edit-message so history rewrites stay consistent.
Tools existed but system prompt never steered models away from terminal
rsync/scp. Add tool-notes guidance whenever the VPS transfer tools are active,
and tighten tool descriptions plus the vps-manager skill/role.
Arrow keys previously only navigated the slash-command palette. Store recent
sends in localStorage and recall them with ↑/↓ when the caret is on the
first/last line, matching shell-style prompt history without breaking
multi-line editing.
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.

1 participant