Harden edit_file matching and complete VPS SSH tools - #18
Open
nvdorman wants to merge 7 commits into
Open
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
read_file→ edit failures (LF paste against CRLF files, pastedNUMBER|line prefixes), diagnose tab-vs-space mismatches, and teach the NUMBER|CONTENT contract in the system prompt.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.Root causes (researched, not guessed)
read_filealways displays LF whileedit_filemust match on-disk bytes; this completes CRLF recovery, strips accidentalNUMBER|pastes, and surfaces tab/space diagnostics.vps_rundefaulted to 60s whilesystemctl restart/stopoften exceeds that; the agent tool envelope (5m) could cut off longtimeout_secondsearly; 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=1go build ./cmd/antaresread_filea CRLF/tabbed source,edit_filewith content after|vps_runlist servers;systemctl status … --no-pager; restart withtimeout_seconds=180vps_uploada small file,vps_downloadit back, confirm bytes