hive.terminal-tools-pty-sessions

Drives interactive terminal programs through persistent PTY sessions with prompt detection and raw I/O.

11.0k|5.7k|Updated Jan 12, 2026
One-click install
npx skills add https://github.com/aden-hive/hive --skill hive-terminal-tools-pty-sessions
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: hive.terminal-tools-pty-sessions
Source: https://github.com/aden-hive/hive/tree/main/core/framework/skills/_preset_skills/terminal-tools-pty-sessions
Command: npx skills add https://github.com/aden-hive/hive --skill hive-terminal-tools-pty-sessions

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Interactive programs like REPLs, sudo, and ssh detect whether they are attached to a real terminal and refuse to work over plain subprocess pipes, and one-shot commands lose state like working directories and environment variables between calls. This Skill teaches how to use persistent PTY sessions so stateful, interactive terminal workflows behave exactly as they would in a real shell.

Core Features & Use Cases

  • Prompt-sentinel execution: Send a command and automatically wait for the shell prompt, returning exactly the output produced between submission and prompt.
  • Raw I/O for REPLs: Write raw keystrokes to programs like python -i, mysql, psql, or node, then drain buffered output on demand with read_only mode.
  • Custom expect patterns: Match program-specific prompts such as Python's ">>>", mysql's "mysql>", sudo's password prompt, or ssh's host-key confirmation.
  • Use Case: Open a session, cd into /var/log, run filtered ls commands that depend on the persisted working directory, then close the session so it does not count against the 8-session cap.

Quick Start

Open a PTY session, run python3 while expecting the ">>>" prompt, send a few expressions with raw input, read the buffered output, and then close the session.

Frequently Asked Questions about hive.terminal-tools-pty-sessions

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I run interactive commands like sudo or ssh from an automated terminal tool?

Open a PTY session and send the command with an expect pattern matching the prompt, such as "[Pp]assword:" for sudo or "\(yes/no.*\)\?" for ssh host-key confirmation. Then send the response with raw_send and drain the result with read_only.

How do I drive a Python or MySQL REPL programmatically?

Launch the REPL inside a PTY session with an expect pattern for its prompt, for example ">>>\s*$" for Python. Send each statement using raw_send, then call read_only to capture the buffered output, since REPLs print their own prompt rather than the bash sentinel.

Why use a PTY session instead of subprocess pipes for terminal automation?

Programs that call isatty() disable prompts, colors, line editing, and password masking when they see a pipe, and some refuse to start. A PTY makes the program behave as if attached to a real terminal, at the cost of ANSI escape codes in the captured output.

Why does the PTY session use bash instead of zsh on macOS?

The tool always invokes /bin/bash with --norc --noprofile by deliberate policy, even when the user's default shell is zsh. Bash avoids zsh-specific builtins that bypass security checks and keeps behavior identical across Linux and macOS.

What happens if I forget to close a PTY session?

Leaked sessions count against the TERMINAL_TOOLS_MAX_PTY cap, which defaults to 8 concurrent sessions. Idle sessions are reaped lazily after the idle timeout (default 1800 seconds), but you should always call terminal_pty_close, using force=True for unresponsive sessions.

Why do I get a session busy error when running PTY commands?

Each session allows only one in-flight call at a time. A concurrent terminal_pty_run on the same session returns a "session busy" error, so serialize calls per session or open additional sessions for parallel work.