Harden the PTY proxy, add a session summary, and support Python 3.10+ - #1
Merged
Merged
Conversation
The repository field pointed at a non-existent slug; update it to the actual GitHub remote so clone instructions and PyPI links resolve.
ACK uses no 3.11+ syntax, so lower the floor from 3.13 to 3.10 to widen the installable audience. Add the 3.10-3.12 trove classifiers, retarget ruff and mypy to py310, refresh the lock file, and run CI across 3.10-3.13.
When the wrapped agent exits, print a short summary to stderr: chunks intercepted/pruned, tokens saved (with a rough cost estimate), and elapsed time. Makes the value of a session visible at a glance. Skipped under --no-annotate and in the TUI (which shows live stats).
The terminal's NL->CRLF mapping (OPOST) is disabled while ACK holds the TTY in raw mode, so the bare newlines in our injected summaries printed as a staircase. Child passthrough already carries CRLF from its own PTY, so convert only the text ACK generates, and only while raw.
A traceback larger than the kernel's PTY buffer arrives in several reads. ACK was pruning the first fragment (no exception line yet) and passing the rest through raw. Hold a buffer whose traceback has not reached its exception line until it completes (bounded by max_buffer_bytes), and condense a repetitive preamble that shares the buffer with it.
With stdin at EOF (piped input, /dev/null, CI) select reported it readable forever, burning ~100% CPU. Drop stdin from the watch set once it reaches EOF, and block in select() with no timeout while nothing is buffered so the loop is idle at ~0% CPU instead of polling.
execvp raised straight through the forked child, dumping a Python traceback and a misleading exit code. Catch the OSError, print a short 'cannot run ...' message, and exit 127.
If ACK was killed by a signal the shell was left stuck in raw mode and the child orphaned. Install handlers that restore the terminal, forward the signal to the child's process group, and exit 128+signum. Guard the install for the main thread only (the --tui worker thread cannot set signal handlers), which also fixes a latent crash in that mode.
The flush loop called pruner.matches() and then compress(), but compress() already self-gates with matches() internally. Call compress() directly so a pruned block is matched once instead of twice.
When ACK output is piped to a consumer that exits early (e.g. '... 2>&1 | head'), the summary's echo hit a BrokenPipeError. Guard it so a closed downstream never masks the agent's real exit code.
ack search/sessions echoed stored raw_content verbatim, which still holds the agent's original escape sequences. A captured mouse/app-mode toggle could reprogram the reader's terminal (runaway output, dead Ctrl-C). Sanitise escape and control characters before printing; raw bytes stay untouched in the database.
Rework the example into a paced build-and-test simulation: status lines pass through, a 200-line log flood collapses to a frequency table, and a deep traceback buried under framework frames collapses to the exception plus the user frames. Short pauses keep each phase readable.
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.
Overview
Reliability and security hardening of the PTY interceptor, a visible end-of-session savings summary, wider Python support, and full docs.
Changes
Impact
Tests