aden-hive/hive✦ 精选0°

hive.terminal-tools-pty-sessions

仓库创建 2026年1月12日最近提交 1 个月前SkillHot 收录 20 天前
▸ 精选理由

必备用于需要状态、交互式程序或响应密码/确认提示的场景。

▸ 风险提示

持久会话可能暴露凭据或长期占用终端资源,需要谨慎授权

这个 Skill 做什么

介绍持久 PTY 会话用于驱动交互式 REPL、保持环境与处理交互提示的模式。

需要在多次交互中保留 shell 状态(cd、环境变量、sourced 脚本)或驱动交互式 REPL(python -i、mysql、psql、node)时用。持久 PTY 会话把终端行为还原,支持 prompt-sentinel、raw I/O 等交互模式。它有严格的一次会话只跑一个任务和显式 close/reuse 规则,避免会话泄露或状态丢失。

▸ 展开 SKILL.md 英文原文

Use when you need state across calls — building env vars, navigating with cd, driving REPLs (python -i, mysql, psql, node), or responding to interactive prompts (sudo password, ssh host-key confirmation, mysql connection). Teaches the prompt-sentinel exec pattern (default mode), raw I/O for REPLs (raw_send=True then read_only=True), the one-in-flight-per-session rule, and the close-or-leak-against-the-cap discipline. Bash on macOS — never zsh; explicit shell=/bin/zsh is rejected. Read before calling terminal_pty_open.

开发编程PTY交互会话REPL通用
1.1w
Stars
5.7k
Forks
18
仓库内 Skill
+132
7 日增星
安装 / 使用
给你的 Agent 一句话(通用)
帮我安装这个 skill:https://raw.githubusercontent.com/aden-hive/hive/main/core/framework/skills/_preset_skills/terminal-tools-pty-sessions/SKILL.md
或 curl 直取 SKILL.md
curl -fsSL "https://raw.githubusercontent.com/aden-hive/hive/main/core/framework/skills/_preset_skills/terminal-tools-pty-sessions/SKILL.md"
SKILL.MD 节选查看完整文件 ↗
# Persistent PTY sessions

PTY sessions are how you talk to interactive programs — programs that detect a terminal (`isatty()`) and behave differently when they don't see one. Use a session when:

- You need state to persist across calls (`cd`, env vars, sourced scripts)
- You're driving a REPL (`python -i`, `mysql`, `psql`, `node`, `irb`)
- A program demands an interactive prompt (`sudo`, `ssh`, `npm login`, `gh auth login`)

For everything else, `terminal_exec` is simpler. Sessions cost more (per-session bash process, ring buffer, idle-reaping bookkeeping) and have a hard cap (`TERMINAL_TOOLS_MAX_PTY`, default 8).

## Why PTY (and not subprocess pipes)

Subprocess pipes break on every inte
via SKILL·HOT · 数据来自 GitHub 公开信息 · 原文版权归作者所有