gnhf - 睡前设定目标,让 AI Agent 在你睡觉时持续工作

gnhf - 睡前设定目标,让 AI Agent 在你睡觉时持续工作


自主 AI Agent 编排器,支持 Claude Code/Codex/Rovo Dev/OpenCode/Copilot CLI,每次迭令一个小改动,成功 commit 失败 rollback

项目简介

gnhf(good night, have fun)是一个受 ralphautoresearch 启发的自主 AI Agent 编排器。核心理念很简单:睡前设定目标,让 Agent 在你睡觉时持续工作,每次迭代做一个小改动,醒来时分支上已经满是干净的提交和完整日志。

核心特性

  • 极简:一条命令启动自主循环,Ctrl+C 或达到配置上限时自动停止
  • 长时运行:每次迭代成功则 commit,失败则 git reset --hard 回滚;硬错误指数退避,Agent 报告的失败立即进入下一迭代
  • 实时状态:交互式运行时更新终端标题,显示当前状态、token 总量和 commit 数
  • Agent 无关:默认支持 Claude Code、Codex、Rovo Dev、OpenCode、GitHub Copilot CLI
  • Worktree 并行:同一仓库同时跑多个 Agent,每个独立工作目录和分支
  • Resume 恢复:在已有的 gnhf/ 分支上继续之前的运行
  • 共享记忆:Agent 通过 notes.md 跨迭代传递上下文

快速使用

# 睡前设定目标,让 Agent 自动工作
$ gnhf "reduce complexity of the codebase without changing functionality"

# 限制迭代次数和 token 上限
$ gnhf "reduce complexity" --max-iterations 10 --max-tokens 5000000

# 多个 Agent 并行运行
$ gnhf --worktree "implement feature X" &
$ gnhf --worktree "add tests for module Y" &

安装

npm install -g gnhf

或从源码构建:

git clone https://github.com/kunchenguid/gnhf.git
cd gnhf
npm install && npm run build && npm link

配置

配置文件位于 ~/.gnhf/config.yml

agent: claude              # 默认 Agent
preventSleep: true         # 运行时防止系统休眠
maxConsecutiveFailures: 3  # 连续失败 3 次后中止
agentPathOverride:         # 自定义 Agent 路径
  claude: ~/bin/claude-code-switch
agentArgsOverride:         # 传递额外 CLI 参数
  codex:
    - -m
    - gpt-5.4

支持的 Agent

Agent说明
Claude CodeAnthropic 官方 CLI
CodexOpenAI 官方 CLI
Rovo DevAtlassian AI 开发助手
OpenCode开源 AI 编码助手
GitHub Copilot CLIGitHub 官方 CLI

平台

macOS | Linux | Windows(防止休眠机制分别使用 caffeinate / systemd-inhibit / PowerShell)

Stars

⭐ GitHub 星标数持续增长中 | TypeScript/Node.js | npm 可直接安装

4300举报0Xiao.Xi17天前
点击获取 ^_^
被收录:

暂无评论