hey 0.1.0

Minimal terminal AI coding agent: kernel loop + MCP/Skills self-evolution
Documentation
# hey 快速入门

> 一个零系统依赖的终端 AI 编码助手。5 分钟上手。

## 安装

```bash
# 从源码构建
cargo install --path .

# 或从 crates.io(发布后)
# cargo install hey
```

零系统依赖(rustls),一个二进制,开箱即用。

## 最基本用法

```bash
# 单轮问答(默认使用首个配置的 provider)
hey "用 Rust 写一个斐波那契函数"

# 带文件引用
hey "给 @src/main.rs 加个 --version 参数"

# 管道模式(-p):读取 stdin 作为上下文
git diff | hey -p "审阅这些改动"
```

## 配置 provider

默认无配置时,`hey` 会尝试连接 `http://localhost:11434`(Ollama 默认地址)。要使用其他 provider:

```bash
# 零配置:指定 base URL + 协议
hey --base-url https://api.openai.com/v1 --protocol openai --api-key $OPENAI_API_KEY "你好"

# 或写配置文件 ~/.config/hey/config.toml
```

完整配置示例见 [config.example.toml](config.example.toml)。

## 多轮对话(REPL)

```bash
hey
# > 用 Rust 写一个 web server
# [hey] tool: bash cargo new webserver
# [hey] bash ok
# ...
# > 加一个 /health 端点
```

REPL 支持 tab 补全,输入 `/help` 查看命令。

## 5 个内建工具

| 工具 | 用途 | 示例 |
|------|------|------|
| `bash` | 执行命令 | `ls -la` |
| `read_file` | 读文件 | `src/main.rs:1-50` |
| `write_file` | 写文件 | 创建新文件 |
| `edit` | 精确编辑 | 替换匹配的代码块 |
| `grep` | 搜索 | 查找函数定义 |

## Skills(自我进化)

写一个 `.hey/skills/<name>/SKILL.md`,下次会话自动生效:

```markdown
---
name: review
description: 审查 Rust 代码中的 unsafe 用法
---
1. 搜索所有 `unsafe` 块
2. 检查每个 unsafe 块是否有正确的安全注释
3. 报告 unsafe 的合理性
```

然后在 REPL 中 `/reload` 激活。

## 会话管理

```bash
hey -c                       # 续最近会话
hey --resume <id>            # 指定会话
hey --sessions               # 列出所有会话
# 在 REPL 中:
# /sessions                  # 查看列表
# /sessions rm <id>          # 删除
# /sessions prune <keep>     # 清理旧会话
```

## 上下文压缩

长时间会话中,当上下文接近预算上限时:

- 自动去重:同工具+同参数重复调用只保留最新
- 自动裁剪:超预算时从中间移除已完成的对
- `compress` 工具:模型可主动压缩已完结的工作流
- `/compact` 命令:手动触发裁剪
- `/usage` 查看用量统计

## 更多

- `--effort off|low|medium|high|max` — 推理强度
- `--output json` — JSON 事件流(供脚本/CI 消费)
- `--proxy http://127.0.0.1:7890` — HTTP/SOCKS5 代理
- `--completions bash` — 生成 shell 自动补全脚本