Skip to content

Cooooper/intelligent-ghostty

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

intelligent-ghostty

ghostty 加上类似 microsoft/intelligent-terminal 的「终端内 AI agent」能力——不 fork ghostty 源码,用 sidecar(shell hook + helper CLI + ghostty 配置)实现。

当前版本:macOS + zsh。后端默认 claude,可切到 codex / gemini / 任意兼容 CLI。

为什么是 sidecar,而不是插件

ghostty 没有插件 / 扩展 API,也无法被外部注入 UI。intelligent-terminal 那种「原生停靠面板」是靠 fork Windows Terminal 源码做到的,ghostty 这条路走不通。ghostty 对外可用的只有两类接口:

  • 配置keybind 绑动作、new_split 开分屏;
  • Shell Integration:自动给 zsh/bash/fish 注入 hook,发 OSC 7 (cwd) / OSC 133 (命令开始/结束/退出码)。

所以「智能」逻辑只能落在 shell 层 hook + 一个外部 helper(ig。本项目就是这一层。

能力对照

intelligent-terminal intelligent-ghostty 实现方式
命令失败检测 ✅ 行内提示 ✗ exit N precmd hook 看退出码
自动修复建议 ⌃G 一键修复 / igfix / ig fix hook 抓命令+退出码 → agent
? 唤起 agent ai <问题> / ? <问题> zsh 函数 → ig ask
上下文共享(免复制粘贴) ⚠️ 部分 自动带:命令/退出码/cwd;输出需 cmd |& ig fix 显式喂入
Agent 面板(停靠) ⚠️ 近似 ghostty 分屏里跑 ig panel 交互式 agent
多 agent 后端 agents.conf,claude/codex/gemini/通用
不调云 / 不持久化 helper 只在内存组装上下文,转交本地 agent CLI

诚实的限制

  • ghostty keybind 不能「开分屏并在其中运行命令」,做不到一键弹出真面板——面板靠「分屏键 + 面板键」两步近似。
  • sidecar 拿不到 ghostty 的 scrollback,所以命令输出默认不自动带;要带就 cmd |& ig fixig fix < log

安装

./install.sh

会:软链 ig~/.local/bin,拷贝集成脚本到 ~/.config/intelligent-ghostty/,并在 ~/.zshrc 加一行 source。ghostty 键位需手动粘贴(见下)。

用法

ai "如何查看占用 8080 端口的进程"     # 带上下文提问
git pushh                              # 故意打错 → 行内提示 ✗ exit ...
ig fix                                 # 诊断上一条失败命令(给原因+候选,不执行)
npm run build |& ig fix                # 把构建报错一起喂给 agent
ig backend codex                       # 切后端
ig panel                               # 启动带上下文的交互式面板(建议先 ghostty 分屏)

一键修复(不用手敲 ig fix

命令失败后,三种力度任选:

方式 行为 摩擦
⌃G(Ctrl-G) 修复命令自动填到命令行,按回车即跑(或改完再跑) 最低,一个键
igfix 显示建议命令 → 按 y 直接执行 / 其它键放到命令行让你改
ig fix 给出原因 + 多个候选命令(详解,不执行) 看不懂时用
git pushh        # 失败
# 直接按 Ctrl-G → 命令行出现 "git push" → 回车

安全底线:绝不静默执行 AI 生成的命令。⌃G 只是把命令填到命令行等你回车,igfix 需要你按 y 确认——你始终先看到、再决定。

可调项:

export IG_FIX_KEY='^F'   # 换一键修复的键
export IG_FIX_KEY=''     # 关掉 Ctrl-G widget
export IG_PANEL_SEED=0   # ig panel 不自动喂上下文(纯净会话)
export IG_HINTS=0        # 关掉行内失败提示

ghostty 键位(可选,粘到 ghostty config):

keybind = cmd+shift+a=text:ig panel\n   # 当前 pane 起面板
keybind = cmd+shift+f=text:ig fix\n     # 诊断上一条失败命令

结构

shell/integration.zsh   zsh hook:抓 命令/退出码/cwd,行内失败提示,ai/? 入口,
                        igfix 函数 + ⌃G 一键修复 widget
bin/ig                  helper CLI:组装上下文 → 路由到 agent 后端
                        (ask / fix / fixcmd / panel / backend)
config/agents.conf      后端定义(oneshot + panel 命令)
config/ghostty-keybinds.conf  ghostty 键位片段
install.sh              安装脚本

设计原则

  • 只让模型做判断类工作:诊断/回答归 agent;上下文采集、退出码判断、后端路由是确定性代码。
  • 不持久化、不调云:对齐 intelligent-terminal 的隐私姿态。
  • 不改 ghostty 源码 / 不动你不让动的文件:键位让你手动粘,agents.conf 已存在则不覆盖。

About

intelligent ghostty

Resources

License

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages