|
| 1 | +# openfeedback |
| 2 | + |
| 3 | +Human-in-the-loop decision gate CLI for AI agents. |
| 4 | + |
| 5 | +When an AI agent (Claude Code, Kiro, or any automation script) reaches a decision point that requires human approval, `openfeedback` sends a rich message to your IM (Telegram) with **Approve / Reject** buttons and waits for a response. |
| 6 | + |
| 7 | +``` |
| 8 | +Agent → openfeedback send → Telegram → Human clicks Approve/Reject |
| 9 | + ← exit code + JSON ← |
| 10 | +``` |
| 11 | + |
| 12 | +## Install |
| 13 | + |
| 14 | +```bash |
| 15 | +cargo install --path . |
| 16 | +``` |
| 17 | + |
| 18 | +## Quick Start |
| 19 | + |
| 20 | +```bash |
| 21 | +# 1. Initialize config |
| 22 | +openfeedback init |
| 23 | +# Edit ~/.config/openfeedback/config.toml (or ~/Library/Application Support/openfeedback/config.toml on macOS) |
| 24 | + |
| 25 | +# 2. Send a request |
| 26 | +openfeedback send --title "Deploy to prod?" --body "Release v2.0 with breaking changes" |
| 27 | + |
| 28 | +# 3. Or use a markdown file |
| 29 | +openfeedback send --title "Review Plan" --body-file /tmp/plan.md --timeout 300 |
| 30 | +``` |
| 31 | + |
| 32 | +## Exit Codes |
| 33 | + |
| 34 | +| Code | Meaning | |
| 35 | +|------|---------| |
| 36 | +| 0 | Approved | |
| 37 | +| 1 | Rejected | |
| 38 | +| 2 | Timeout | |
| 39 | + |
| 40 | +## Output |
| 41 | + |
| 42 | +JSON to stdout for agent consumption: |
| 43 | + |
| 44 | +```json |
| 45 | +{ |
| 46 | + "decision": "approved", |
| 47 | + "user": "@username", |
| 48 | + "user_id": 123456789, |
| 49 | + "feedback": null, |
| 50 | + "timestamp": "2026-03-09T09:25:27Z", |
| 51 | + "request_title": "Deploy to prod?" |
| 52 | +} |
| 53 | +``` |
| 54 | + |
| 55 | +## Configuration |
| 56 | + |
| 57 | +`~/.config/openfeedback/config.toml`: |
| 58 | + |
| 59 | +```toml |
| 60 | +default_provider = "telegram" |
| 61 | +default_timeout = 3600 |
| 62 | +# locale: "en" (default), "zh-CN", "zh-TW" |
| 63 | +locale = "en" |
| 64 | + |
| 65 | +[telegram] |
| 66 | +bot_token = "YOUR_BOT_TOKEN" |
| 67 | +chat_id = 0 |
| 68 | +# Only these user IDs can approve/reject. Empty = allow all. |
| 69 | +trusted_user_ids = [] |
| 70 | + |
| 71 | +[logging] |
| 72 | +# audit_file = "~/.local/share/openfeedback/audit.jsonl" |
| 73 | +``` |
| 74 | + |
| 75 | +### Telegram Setup |
| 76 | + |
| 77 | +1. Create a bot via [@BotFather](https://t.me/BotFather) |
| 78 | +2. Send a message to your bot |
| 79 | +3. Get your `chat_id`: |
| 80 | + ```bash |
| 81 | + curl -s "https://api.telegram.org/bot<TOKEN>/getUpdates" | jq '.result[0].message.chat.id' |
| 82 | + ``` |
| 83 | +4. Add `bot_token`, `chat_id`, and your user ID to `trusted_user_ids` |
| 84 | + |
| 85 | +## Features |
| 86 | + |
| 87 | +- **Single binary** - no runtime dependencies, no server needed |
| 88 | +- **Blocking CLI** - sends message, polls for response, exits with result |
| 89 | +- **Trusted users** - whitelist who can approve/reject |
| 90 | +- **Audit log** - every decision recorded to JSONL |
| 91 | +- **i18n** - English, Simplified Chinese, Traditional Chinese |
| 92 | +- **Provider trait** - extensible for Slack, Discord, etc. |
| 93 | + |
| 94 | +## Use with AI Agents |
| 95 | + |
| 96 | +```bash |
| 97 | +# In a shell script or agent hook |
| 98 | +result=$(openfeedback send --title "Proceed with PR?" --body-file /tmp/plan.md) |
| 99 | +exit_code=$? |
| 100 | + |
| 101 | +if [ $exit_code -eq 0 ]; then |
| 102 | + echo "Approved, continuing..." |
| 103 | +elif [ $exit_code -eq 1 ]; then |
| 104 | + feedback=$(echo "$result" | jq -r '.feedback // empty') |
| 105 | + echo "Rejected: $feedback" |
| 106 | +else |
| 107 | + echo "Timeout, aborting" |
| 108 | +fi |
| 109 | +``` |
| 110 | + |
| 111 | +## License |
| 112 | + |
| 113 | +[MIT](LICENSE) |
0 commit comments