bingo-light 2.1.0 → 2.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -2,208 +2,336 @@
2
2
  <br>
3
3
  <img src="docs/logo.svg" alt="bingo-light logo" width="200">
4
4
  <br><br>
5
- <strong>Fork maintenance for humans and AI agents.<br>One command to sync. Zero dependencies.</strong>
5
+ <strong>让 AI 接管你的 Fork 维护。<br>同步、冲突、补丁管理 全自动。</strong>
6
6
  <br><br>
7
- <b>English</b> | <a href="README.zh-CN.md">简体中文</a>
7
+ <a href="README.en.md">English</a> | <b>简体中文</b>
8
8
  <br><br>
9
9
  <a href="https://github.com/DanOps-1/bingo-light/actions"><img src="https://github.com/DanOps-1/bingo-light/actions/workflows/ci.yml/badge.svg" alt="CI"></a>
10
10
  <a href="LICENSE"><img src="https://img.shields.io/badge/License-MIT-blue.svg" alt="License: MIT"></a>
11
11
  <a href="https://github.com/DanOps-1/bingo-light/releases"><img src="https://img.shields.io/github/v/release/DanOps-1/bingo-light?label=Release&color=orange" alt="Release"></a>
12
- <br>
13
- <a href="#for-ai-agents"><img src="https://img.shields.io/badge/MCP_Server-29_tools-blueviolet.svg" alt="MCP: 29 tools"></a>
12
+ <a href="#mcp-服务器"><img src="https://img.shields.io/badge/MCP_Server-35_tools-blueviolet.svg" alt="MCP: 35 tools"></a>
14
13
  <a href="https://www.python.org/"><img src="https://img.shields.io/badge/Python-3.8+-3776ab.svg" alt="Python 3.8+"></a>
15
14
  <img src="https://img.shields.io/badge/Dependencies-Zero-brightgreen.svg" alt="Zero deps">
16
15
  <a href="https://github.com/DanOps-1/bingo-light/stargazers"><img src="https://img.shields.io/github/stars/DanOps-1/bingo-light?style=social" alt="Stars"></a>
17
16
  <br><br>
18
17
  </p>
19
18
 
20
- ---
21
-
22
- GitHub's "Sync fork" button breaks the moment you have customizations. `git rebase` is a 6-step ritual. And none of it works from an AI agent.
19
+ Fork 维护是个苦差事 — 上游一更新,你的定制化改动就得手动 rebase。GitHub 的 "Sync fork" 按钮碰到自定义 commit 直接废了。手动操作六步起步,冲突反复解,搞砸了还得从 reflog 里捞。
23
20
 
24
- **bingo-light fixes all three.**
21
+ **装完 bingo-light,跟你的 AI 说一句"帮我同步 Fork",剩下的它全搞定。**
25
22
 
26
- Your patches live as a clean, named stack on top of upstream. Syncing is `bingo-light sync`. Conflicts get remembered so you never solve the same one twice. And if something goes sideways, `bingo-light undo` puts everything back in one second.
23
+ 内置 MCP 服务器 35 个工具,AI 自主完成:拉上游、rebase 补丁、分析冲突、写合并代码、继续 rebase。冲突解过一次自动记住(rerere),下次不再问。搞砸了 `undo` 秒回。
27
24
 
28
- Every command speaks JSON. The built-in MCP server gives AI agents 29 tools to manage your fork autonomously -- from init through conflict resolution. No human in the loop required.
25
+ > [!TIP]
26
+ > **不想读文档?** 把这段丢给你的 AI,让它帮你装:
27
+ >
28
+ > ```
29
+ > 帮我安装 bingo-light 并配置好 MCP,参考:
30
+ > https://raw.githubusercontent.com/DanOps-1/bingo-light/main/docs/ai-setup.md
31
+ > ```
29
32
 
30
33
  ---
31
34
 
32
- <p align="center">
33
- <img src="docs/demo.svg" alt="bingo-light demo" width="850">
34
- </p>
35
+ ## 目录
36
+
37
+ - [安装](#安装)
38
+ - [演示](#演示)
39
+ - [功能特性](#功能特性)
40
+ - [MCP 服务器(35 工具)](#mcp-服务器)
41
+ - [工作原理](#工作原理)
42
+ - [命令参考](#命令参考)
43
+ - [集成指南](#集成指南)
44
+ - [配置](#配置)
45
+ - [常见问题](#常见问题)
46
+ - [与其他方案对比](#与其他方案对比)
47
+ - [项目生态](#项目生态)
48
+ - [参与贡献](#参与贡献)
35
49
 
36
50
  ---
37
51
 
38
- ## Quick Start
52
+ ## 安装
53
+
54
+ ### 让 AI 帮你装(推荐)
55
+
56
+ 把下面这段丢给你的 AI(Claude Code、Cursor、Windsurf 等),它会自动装好并配好 MCP + Skill:
57
+
58
+ ```
59
+ 帮我安装并配置 bingo-light,参考这个文档:
60
+ https://raw.githubusercontent.com/DanOps-1/bingo-light/main/docs/ai-setup.md
61
+ ```
62
+
63
+ ### 自己装
64
+
65
+ | 方式 | 命令 |
66
+ |------|------|
67
+ | **pip** | `pip install bingo-light && bingo-light setup` |
68
+ | **npm** | `npm install -g bingo-light && bingo-light setup` |
69
+ | **npx** | `npx bingo-light setup` |
70
+ | **Homebrew** | `brew install DanOps-1/tap/bingo-light && bingo-light setup` |
39
71
 
72
+ <details>
73
+ <summary><b>更多安装方式</b>(Docker / Shell / 源码)</summary>
74
+
75
+ **Docker**
40
76
  ```bash
41
- # Install (pick one)
42
- pip install bingo-light # Python
43
- npm install -g bingo-light # Node.js
44
- brew install DanOps-1/tap/bingo-light # Homebrew
77
+ docker run --rm -v "$PWD:/repo" -w /repo ghcr.io/danops-1/bingo-light status
78
+ docker run --rm -i -v "$PWD:/repo" -w /repo ghcr.io/danops-1/bingo-light mcp-server.py
79
+ ```
45
80
 
46
- # Point at upstream
47
- cd your-forked-project
48
- bingo-light init https://github.com/original/project.git
81
+ **Shell 一键安装**
82
+ ```bash
83
+ curl -fsSL https://raw.githubusercontent.com/DanOps-1/bingo-light/main/install.sh | sh
84
+ ```
49
85
 
50
- # Sync whenever you want -- patches rebase on top automatically
51
- bingo-light sync
86
+ **从源码**
87
+ ```bash
88
+ git clone https://github.com/DanOps-1/bingo-light.git
89
+ cd bingo-light && make install && bingo-light setup
52
90
  ```
53
91
 
54
- That's it. Three commands and your fork stays in sync forever.
92
+ </details>
93
+
94
+ > [!NOTE]
95
+ > **依赖:** Python 3.8+ / git 2.20+,没了。零 pip 依赖。
96
+ >
97
+ > MCP 客户端可直接用 npx:`{"command": "npx", "args": ["-y", "bingo-light-mcp"]}`
98
+
99
+ ---
100
+
101
+ ## 演示
102
+
103
+ <table>
104
+ <tr>
105
+ <td width="50%">
55
106
 
56
- ## Demo
107
+ ### 日常操作
57
108
 
58
- ### Basic workflow: init, patch, sync
109
+ 初始化 建补丁 同步上游
59
110
 
60
111
  <p align="center">
61
- <img src="docs/demo.svg" alt="bingo-light basic demo" width="850">
112
+ <img src="docs/demo.svg" alt="bingo-light 基本演示" width="100%">
62
113
  </p>
63
114
 
64
- ### Conflict resolution: sync, analyze, resolve
115
+ </td>
116
+ <td width="50%">
117
+
118
+ ### 冲突解决
119
+
120
+ 同步 → AI 分析 → 自动修复
65
121
 
66
122
  <p align="center">
67
- <img src="docs/demo-conflict.svg" alt="bingo-light conflict resolution demo" width="850">
123
+ <img src="docs/demo-conflict.svg" alt="bingo-light 冲突解决演示" width="100%">
68
124
  </p>
69
125
 
70
- > The AI calls `conflict-analyze --json`, reads the structured ours/theirs data, writes the merged file, and the rebase continues. No human needed.
126
+ </td>
127
+ </tr>
128
+ </table>
129
+
130
+ > [!NOTE]
131
+ > AI 调 `conflict-analyze --json` 拿到双方代码和解决提示,写好合并结果,rebase 自动继续。全程零人工。
71
132
 
72
133
  ---
73
134
 
74
- ## Key Features
75
-
76
- ### For Humans
77
-
78
- - :wrench: **Zero deps** -- just Python 3 + git. `pip install bingo-light` and go.
79
- - :bookmark_tabs: **Named patch stack** -- each customization is one atomic, named commit. No more guessing which changes are yours.
80
- - :zap: **One-command sync** -- `bingo-light sync` fetches upstream and rebases your patches on top. Done.
81
- - :brain: **Conflict memory** -- git rerere auto-enabled. Resolve a conflict once, never resolve it again.
82
- - :rewind: **Instant undo** -- `bingo-light undo` restores pre-sync state. No reflog spelunking.
83
- - :crystal_ball: **Conflict prediction** -- `status` warns you about risky files before you sync.
84
- - :test_tube: **Dry-run mode** -- `sync --dry-run` tests on a throwaway branch first.
85
- - :stethoscope: **Built-in doctor** -- full diagnostic with test rebase to catch problems early.
86
- - :package: **Export/Import patches** -- share as `.patch` files, quilt-compatible format.
87
- - :robot: **Auto-sync CI** -- generates a GitHub Actions workflow with conflict alerting.
88
- - :tv: **TUI dashboard** -- curses-based real-time monitoring via `contrib/tui.py`.
89
- - :globe_with_meridians: **Multi-repo workspace** -- manage multiple forks from one place.
90
- - :bell: **Notification hooks** -- Slack, Discord, webhooks on sync/conflict/test events.
91
- - :label: **Patch metadata** -- tags, reasons, expiry dates, upstream PR tracking.
92
- - :tab: **Shell completions** -- tab completion for bash, zsh, and fish.
93
-
94
- ### For AI Agents
95
-
96
- - :electric_plug: **MCP server (29 tools)** -- full fork management from init through conflict resolution.
97
- - :bar_chart: **`--json` on everything** -- every command returns structured JSON. Parse, don't scrape.
98
- - :mute: **`--yes` flag** -- fully non-interactive. No TTY required. No prompts. Ever.
99
- - :gear: **Auto-detect non-TTY** -- pipes and subprocesses trigger non-interactive mode automatically.
100
- - :memo: **`BINGO_DESCRIPTION` env var** -- set patch descriptions without stdin.
101
- - :mag: **`conflict-analyze --json`** -- structured conflict data: file, ours, theirs, resolution hints.
102
- - :white_check_mark: **`conflict-resolve`** -- write resolved content via MCP, auto-stage, continue rebase. Zero manual intervention.
103
- - :satellite: **Advisor agent** -- `contrib/agent.py` monitors drift, analyzes risk, auto-syncs when safe.
135
+ ### `--json` 输出:AI 直接消费
104
136
 
105
- ---
137
+ <details open>
138
+ <summary><b>Fork 状态</b> — <code>bingo-light status --json</code></summary>
106
139
 
107
- ## Installation
140
+ ```json
141
+ {
142
+ "ok": true,
143
+ "upstream_url": "https://github.com/torvalds/linux.git",
144
+ "behind": 47,
145
+ "patch_count": 2,
146
+ "patches": [
147
+ {"name": "custom-scheduler", "hash": "a3f7c21", "subject": "O(1) task scheduling", "files": 3},
148
+ {"name": "perf-monitoring", "hash": "b8e2d4f", "subject": "eBPF tracing hooks", "files": 5}
149
+ ],
150
+ "conflict_risk": ["kernel/sched/core.c"]
151
+ }
152
+ ```
108
153
 
109
- Install with any package manager, then run `bingo-light setup` to interactively configure MCP for your AI tools (Claude Code, Cursor, Windsurf, VS Code/Copilot, Zed, Gemini CLI, etc.).
154
+ </details>
110
155
 
111
- ### pip / pipx
156
+ <details>
157
+ <summary><b>冲突分析</b> — <code>bingo-light conflict-analyze --json</code></summary>
112
158
 
113
- ```bash
114
- pip install bingo-light # or: pipx install bingo-light
115
- bingo-light setup # interactive — pick which AI tools to configure
159
+ ```json
160
+ {
161
+ "rebase_in_progress": true,
162
+ "current_patch": "custom-scheduler",
163
+ "conflicts": [
164
+ {
165
+ "file": "kernel/sched/core.c",
166
+ "conflict_count": 2,
167
+ "ours": "... 上游版本 ...",
168
+ "theirs": "... 你的补丁版本 ...",
169
+ "hint": "上游重构了调度器核心;补丁需要适配新结构。"
170
+ }
171
+ ]
172
+ }
116
173
  ```
117
174
 
118
- ### npm / npx
175
+ </details>
119
176
 
120
- ```bash
121
- npm install -g bingo-light # global install
122
- bingo-light setup
177
+ <details>
178
+ <summary><b>AI 全自动解冲突</b> Claude Code 实际工作流</summary>
123
179
 
124
- # Or use npx — no install needed:
125
- npx bingo-light setup
126
180
  ```
127
-
128
- MCP clients can use npx directly:
129
- ```json
130
- {"command": "npx", "args": ["-y", "bingo-light-mcp"]}
181
+ 你: "同步上游,冲突帮我修了。"
182
+
183
+ Claude Code:
184
+ 1. bingo_status(cwd) → 落后 47 commit,risk: core.c
185
+ 2. bingo_sync(cwd, dry_run) → 预判 1 个冲突
186
+ 3. bingo_sync(cwd) → rebase 卡在冲突
187
+ 4. bingo_conflict_analyze() → 拿到双方代码 + 提示
188
+ 5. 读两边,写合并结果
189
+ 6. bingo_conflict_resolve(file) → 搞定
190
+ 7. bingo_status(cwd) → 0 落后,补丁干净 ✓
131
191
  ```
132
192
 
133
- ### Homebrew
193
+ </details>
134
194
 
135
- ```bash
136
- brew install DanOps-1/tap/bingo-light
137
- bingo-light setup
195
+ ### 交互式 Setup
196
+
197
+ ```console
198
+ $ bingo-light setup
199
+
200
+ ◆ bingo-light setup v2.1.1
201
+
202
+ ◆ MCP Server
203
+ │ Connect bingo-light tools to your AI coding assistants
204
+
205
+ │ › ■ Claude Code ~/.claude/settings.json
206
+ │ ■ Cursor ~/.cursor/mcp.json
207
+ │ □ Windsurf (not detected)
208
+ │ ■ VS Code / Copilot ~/.vscode/mcp.json
209
+
210
+ ◆ Skills / Custom Instructions
211
+ │ Teach your AI how to use bingo-light
212
+
213
+ │ ■ Claude Code ~/.claude/commands/bingo.md
214
+ │ ■ Continue ~/.continue/rules/bingo.md
215
+
216
+ └ 5 MCP + 2 skill(s) configured — ready to go!
138
217
  ```
139
218
 
140
- ### Docker
219
+ > [!TIP]
220
+ > 支持 10 个 AI 工具的 MCP 配置 + 6 个平台的 Skill 安装。方向键多选,一次配完。
141
221
 
142
- ```bash
143
- # CLI
144
- docker run --rm -v "$PWD:/repo" -w /repo ghcr.io/danops-1/bingo-light status
222
+ ## AI 如何使用 bingo-light
145
223
 
146
- # MCP server (stdio transport)
147
- docker run --rm -i -v "$PWD:/repo" -w /repo ghcr.io/danops-1/bingo-light mcp-server.py
148
- ```
224
+ 这才是重点。bingo-light 是为 AI agent 设计的 Fork 维护工具。
149
225
 
150
- ### Shell installer
226
+ ### AI 拿到什么
151
227
 
152
- ```bash
153
- curl -fsSL https://raw.githubusercontent.com/DanOps-1/bingo-light/main/install.sh | sh
228
+ | | 能力 | 说明 |
229
+ |---|------|------|
230
+ | 🔌 | **MCP 服务器** | 35 个工具,AI 直接调用,从 init 到冲突解决全链路 |
231
+ | 📊 | **结构化输出** | 所有命令 `--json` 输出,AI 直接 parse |
232
+ | 🤖 | **零交互** | `--yes` + 非 TTY 自适应,不会卡在确认提示 |
233
+ | 🔍 | **冲突分析** | `conflict-analyze` 返回双方代码 + AI 可执行的解决提示 |
234
+ | ✏️ | **冲突解决** | `conflict-resolve` 直接写入合并代码,自动 stage + 继续 rebase |
235
+ | 🧠 | **冲突记忆** | rerere 自动记住解法,同样冲突不用 AI 再解第二次 |
236
+ | 📋 | **Skill / 指令** | `/bingo` 教 AI 整套工作流,不用你写 prompt |
237
+ | 📦 | **依赖补丁** | `dep patch/apply/sync` — npm/pip 包改了不怕 install 覆盖 |
238
+ | 🔄 | **Advisor 代理** | `contrib/agent.py` 后台监控漂移,安全时自动同步 |
154
239
 
155
- # Non-interactive (CI / Docker)
156
- curl -fsSL .../install.sh | sh -s -- --yes
157
- ```
240
+ ### AI 实际工作流
158
241
 
159
- ### From source
242
+ 你说一句 **"同步上游"**,AI 自己跑完整个流程:
160
243
 
161
- ```bash
162
- git clone https://github.com/DanOps-1/bingo-light.git
163
- cd bingo-light
164
- make install && bingo-light setup
165
244
  ```
245
+ bingo_status() → 落后 47 commit,risk: core.c
246
+ bingo_sync(dry_run=true) → 预判 1 个冲突
247
+ bingo_sync() → rebase 卡在冲突
248
+ bingo_conflict_analyze() → 拿到 ours/theirs + hint
249
+ → AI 读两边代码,写合并结果
250
+ bingo_conflict_resolve() → 写入、stage、rebase 继续
251
+ bingo_status() → 0 落后,补丁干净 ✓
252
+ ```
253
+
254
+ > [!IMPORTANT]
255
+ > **你不需要理解 rebase、rerere、tracking branch 这些概念。** AI 全部处理。你只需要装好工具,告诉 AI 你想干嘛。
256
+
257
+ ### 支持哪些 AI 工具
166
258
 
167
- **Requirements:** Python 3.8+, git 2.20+. Zero pip dependencies.
259
+ `bingo-light setup` 一键配好 MCP + Skill:
260
+
261
+ | AI 工具 | MCP | Skill |
262
+ |---------|:---:|:-----:|
263
+ | Claude Code | ✅ | ✅ |
264
+ | Cursor | ✅ | — |
265
+ | Windsurf | ✅ | ✅ |
266
+ | VS Code / Copilot | ✅ | — |
267
+ | Cline | ✅ | ✅ |
268
+ | Roo Code | ✅ | ✅ |
269
+ | Zed | ✅ | — |
270
+ | Gemini CLI | ✅ | ✅ |
271
+ | Continue | — | ✅ |
272
+ | Amazon Q | ✅ | — |
168
273
 
169
274
  ---
170
275
 
171
- ## How It Works
276
+ ## 人也能用
277
+
278
+ 不用 AI 也完全没问题。同一套命令,人跑和 AI 跑效果一样。
279
+
280
+ <details>
281
+ <summary><b>人类功能一览</b></summary>
282
+
283
+ | 功能 | 说明 |
284
+ |------|------|
285
+ | **一键同步** | `bingo-light sync`,补丁自动 rebase 到最新上游 |
286
+ | **命名补丁** | 每个改动是独立的、有名字的 commit |
287
+ | **先试后跑** | `sync --dry-run` 临时分支预演,不碰真代码 |
288
+ | **秒级撤销** | `bingo-light undo` 恢复同步前状态 |
289
+ | **冲突预警** | `status` 提前告诉你哪些文件会出事 |
290
+ | **自检修复** | `doctor` 全面体检 + 试跑 rebase |
291
+ | **导出导入** | `.patch` 文件,quilt 兼容 |
292
+ | **CI 自动同步** | 生成 GitHub Actions 流水线,冲突自动告警 |
293
+ | **TUI 面板** | curses 实时仪表盘(`contrib/tui.py`) |
294
+ | **多仓管理** | `workspace` 统一管所有 Fork |
295
+ | **补全** | bash / zsh / fish |
296
+ | **通知推送** | Discord、Slack、Webhook,事件触发 |
297
+ | **测试联动** | 同步后自动跑测试,挂了自动回滚 |
298
+
299
+ </details>
300
+
301
+ ## 工作原理
172
302
 
173
303
  ```
174
304
  upstream (github.com/original/project)
175
305
  |
176
306
  | git fetch
177
307
  v
178
- upstream-tracking ──────── exact mirror of upstream, never touched
308
+ upstream-tracking ─────── 上游的精确镜像,从不手动碰
179
309
  |
180
310
  | git rebase
181
311
  v
182
- bingo-patches ──────────── your customizations stacked here
312
+ bingo-patches ─────────── 你的改动叠在这里
183
313
  |
184
- +── [bl] custom-scheduler: O(1) task scheduling
185
- +── [bl] perf-monitoring: eBPF tracing hooks
186
- +── [bl] fix-logging: structured JSON logs
314
+ +── [bl] custom-scheduler: O(1) 任务调度
315
+ +── [bl] perf-monitoring: eBPF 追踪钩子
316
+ +── [bl] fix-logging: 结构化 JSON 日志
187
317
  |
188
318
  v
189
- HEAD (your working fork)
319
+ HEAD (你的工作 Fork)
190
320
  ```
191
321
 
192
- **Sync flow:** fetch upstream, fast-forward the tracking branch, rebase your patches on top. Your patches always sit cleanly on the latest upstream.
322
+ **同步:** fetch 上游 快进追踪分支 rebase 补丁到最新上游。补丁永远干净地叠在最新代码上。
193
323
 
194
- **Conflict memory:** `init` auto-enables git rerere. Resolve a conflict once and git remembers the resolution. Next sync applies it automatically. bingo-light detects auto-resolved conflicts and continues the rebase without stopping.
324
+ **冲突记忆:** 初始化时自动开 rerere。解过一次,git 就记住了——下次碰到同样的冲突直接跳过。
195
325
 
196
- **AI conflict flow:** rebase hits a conflict, the AI calls `conflict-analyze` for structured data (ours/theirs/hints per file), writes the resolution via `conflict-resolve`, and rebase continues. No human in the loop.
326
+ **AI 解冲突:** rebase 卡住时,AI `conflict-analyze` 拿双方代码和提示,写好合并结果扔给 `conflict-resolve`,rebase 自动继续,不用人管。
197
327
 
198
- ---
328
+ ## MCP 服务器
199
329
 
200
- ## For AI Agents
330
+ `mcp-server.py`,纯 Python 3,零依赖,stdio 传输,35 个工具,JSON-RPC 2.0。
201
331
 
202
- bingo-light was designed from day one for AI agents. Every command speaks JSON. The MCP server exposes 29 tools covering the full lifecycle from `init` to `conflict-resolve`. Non-interactive mode is the default when stdin is not a TTY.
332
+ 运行 `bingo-light setup` 自动配置,或手动添加:
203
333
 
204
- ### MCP setup -- Claude Code
205
-
206
- Add to `.mcp.json` in your project root or `~/.claude/settings.json`:
334
+ **Claude Code**(`.mcp.json` `~/.claude/settings.json`):
207
335
 
208
336
  ```json
209
337
  {
@@ -216,9 +344,7 @@ Add to `.mcp.json` in your project root or `~/.claude/settings.json`:
216
344
  }
217
345
  ```
218
346
 
219
- ### MCP setup -- Claude Desktop
220
-
221
- Add to `~/Library/Application Support/Claude/claude_desktop_config.json`:
347
+ **Claude Desktop**(`~/Library/Application Support/Claude/claude_desktop_config.json`):
222
348
 
223
349
  ```json
224
350
  {
@@ -231,104 +357,89 @@ Add to `~/Library/Application Support/Claude/claude_desktop_config.json`:
231
357
  }
232
358
  ```
233
359
 
234
- **Any MCP client** (VS Code Copilot, Cursor, custom agents): connect via stdio to `python3 mcp-server.py`.
360
+ **其他客户端**(Cursor、Windsurf、VS Code Copilot 等):stdio `python3 mcp-server.py`,或跑 `bingo-light setup` 一键配。
361
+
362
+ ### 全部工具
363
+
364
+ | 工具 | 用途 |
365
+ |------|------|
366
+ | `bingo_init` | 初始化 Fork 追踪 |
367
+ | `bingo_status` | 健康检查:漂移、补丁、冲突风险 |
368
+ | `bingo_sync` | 拉取上游并变基补丁 |
369
+ | `bingo_undo` | 恢复到同步前状态 |
370
+ | `bingo_patch_new` | 创建命名补丁 |
371
+ | `bingo_patch_list` | 列出补丁栈 |
372
+ | `bingo_patch_show` | 查看补丁 diff |
373
+ | `bingo_patch_drop` | 移除补丁 |
374
+ | `bingo_patch_export` | 导出为 `.patch` 文件 |
375
+ | `bingo_patch_import` | 导入 `.patch` 文件 |
376
+ | `bingo_patch_meta` | 获取/设置补丁元数据 |
377
+ | `bingo_patch_squash` | 合并两个补丁 |
378
+ | `bingo_patch_reorder` | 非交互式重排补丁 |
379
+ | `bingo_doctor` | 全面诊断 + 测试变基 |
380
+ | `bingo_diff` | 补丁总 diff vs 上游 |
381
+ | `bingo_auto_sync` | 生成 GitHub Actions 工作流 |
382
+ | `bingo_conflict_analyze` | AI 用的结构化冲突数据 |
383
+ | `bingo_conflict_resolve` | 写入解决内容,暂存,继续 rebase |
384
+ | `bingo_config` | 获取/设置配置 |
385
+ | `bingo_history` | 同步历史 + hash 映射 |
386
+ | `bingo_test` | 运行测试套件 |
387
+ | `bingo_workspace_status` | 多仓库工作区概览 |
388
+ | `bingo_patch_edit` | 修改已有补丁 |
389
+ | `bingo_workspace_init` | 初始化多仓库工作区 |
390
+ | `bingo_workspace_add` | 添加仓库到工作区 |
391
+ | `bingo_workspace_sync` | 同步工作区所有仓库 |
392
+ | `bingo_workspace_list` | 列出工作区仓库 |
393
+
394
+ ## 命令参考
235
395
 
236
- ### 29 MCP Tools
237
-
238
- | Tool | Purpose |
239
- |------|---------|
240
- | `bingo_init` | Initialize fork tracking |
241
- | `bingo_status` | Fork health: drift, patches, conflict risk |
242
- | `bingo_sync` | Fetch upstream + rebase patches |
243
- | `bingo_undo` | Revert to pre-sync state |
244
- | `bingo_patch_new` | Create a named patch |
245
- | `bingo_patch_list` | List patch stack with stats |
246
- | `bingo_patch_show` | Show patch diff |
247
- | `bingo_patch_drop` | Remove a patch |
248
- | `bingo_patch_export` | Export as `.patch` files |
249
- | `bingo_patch_import` | Import `.patch` files |
250
- | `bingo_patch_meta` | Get/set patch metadata |
251
- | `bingo_patch_squash` | Merge two patches into one |
252
- | `bingo_patch_reorder` | Reorder patches non-interactively |
253
- | `bingo_doctor` | Full diagnostic with test rebase |
254
- | `bingo_diff` | Combined diff vs upstream |
255
- | `bingo_auto_sync` | Generate GitHub Actions workflow |
256
- | `bingo_conflict_analyze` | Structured conflict data for AI resolution |
257
- | `bingo_conflict_resolve` | Write resolution, stage, continue rebase |
258
- | `bingo_config` | Get/set configuration |
259
- | `bingo_history` | Sync history with hash mappings |
260
- | `bingo_test` | Run configured test suite |
261
- | `bingo_workspace_status` | Multi-repo workspace overview |
262
- | `bingo_patch_edit` | Amend an existing patch |
263
- | `bingo_workspace_init` | Initialize multi-repo workspace |
264
- | `bingo_workspace_add` | Add a repo to workspace |
265
- | `bingo_workspace_sync` | Sync all workspace repos |
266
- | `bingo_workspace_list` | List workspace repos |
267
-
268
- ### JSON examples
269
-
270
- ```bash
271
- # Fork status (AI-friendly)
272
- bingo-light status --json
273
396
  ```
274
-
275
- ```json
276
- {
277
- "ok": true,
278
- "upstream_url": "https://github.com/torvalds/linux.git",
279
- "behind": 47,
280
- "patch_count": 2,
281
- "patches": [
282
- {"name": "custom-scheduler", "hash": "a3f7c21", "subject": "O(1) task scheduling", "files": 3},
283
- {"name": "perf-monitoring", "hash": "b8e2d4f", "subject": "eBPF tracing hooks", "files": 5}
284
- ],
285
- "conflict_risk": ["kernel/sched/core.c"]
286
- }
397
+ bingo-light init <upstream-url> [branch] 初始化上游追踪
398
+ bingo-light patch new <name> 创建命名补丁
399
+ bingo-light patch list [-v] 列出补丁栈
400
+ bingo-light patch show <name|index> 查看补丁 diff
401
+ bingo-light patch edit <name|index> 修改补丁(先暂存变更)
402
+ bingo-light patch drop <name|index> 移除补丁
403
+ bingo-light patch reorder [--order "3,1,2"] 重排补丁
404
+ bingo-light patch export [dir] 导出为 .patch 文件
405
+ bingo-light patch import <file|dir> 导入 .patch 文件
406
+ bingo-light patch squash <idx1> <idx2> 合并两个补丁
407
+ bingo-light patch meta <name> [key] [value] 获取/设置补丁元数据
408
+ bingo-light sync [--dry-run] [--force] 与上游同步
409
+ bingo-light sync --test 同步后跑测试,失败自动回滚
410
+ bingo-light undo 恢复到同步前状态
411
+ bingo-light status 健康检查 + 冲突预测
412
+ bingo-light doctor 全面诊断
413
+ bingo-light diff 补丁总 diff vs 上游
414
+ bingo-light log 同步历史
415
+ bingo-light conflict-analyze 分析 rebase 冲突
416
+ bingo-light config get|set|list [key] [val] 管理配置
417
+ bingo-light history 详细同步历史 + 映射
418
+ bingo-light test 运行测试套件
419
+ bingo-light dep patch <package> [name] 补丁 npm/pip 依赖
420
+ bingo-light dep apply [package] 重新应用依赖补丁
421
+ bingo-light dep sync 更新后重新应用 + 冲突检测
422
+ bingo-light dep status 依赖补丁健康状态
423
+ bingo-light dep list 列出所有依赖补丁
424
+ bingo-light dep drop <package> [patch] 删除依赖补丁
425
+ bingo-light workspace init|add|status|sync 多仓库管理
426
+ bingo-light auto-sync 生成 GitHub Actions 工作流
427
+ bingo-light version 打印版本
428
+ bingo-light help 打印帮助
287
429
  ```
288
430
 
289
- ```bash
290
- # Conflict analysis (structured data for AI resolution)
291
- bingo-light conflict-analyze --json
292
- ```
431
+ **全局标志:** `--json`(结构化 JSON 输出) | `--yes`(跳过所有确认提示)
293
432
 
294
- ```json
295
- {
296
- "rebase_in_progress": true,
297
- "current_patch": "custom-scheduler",
298
- "conflicts": [
299
- {
300
- "file": "kernel/sched/core.c",
301
- "conflict_count": 2,
302
- "ours": "... upstream version ...",
303
- "theirs": "... your patch version ...",
304
- "hint": "Upstream refactored scheduler core; patch needs to target new structure."
305
- }
306
- ]
307
- }
308
- ```
309
-
310
- ### End-to-end AI workflow
311
-
312
- ```
313
- User: "Sync my fork and fix any conflicts."
314
-
315
- AI Agent:
316
- 1. bingo_status(cwd) -> 47 behind, risk: core.c
317
- 2. bingo_sync(cwd, dry_run=true) -> 1 conflict predicted
318
- 3. bingo_sync(cwd) -> rebase stops at conflict
319
- 4. bingo_conflict_analyze(cwd) -> structured ours/theirs/hints
320
- 5. AI reads both versions, generates merge
321
- 6. bingo_conflict_resolve(cwd, file, content) -> resolved, rebase continues
322
- 7. bingo_status(cwd) -> 0 behind, all patches clean
323
- ```
433
+ ## 集成指南
324
434
 
325
- ### CLI integration (Aider, custom agents)
435
+ | 集成方式 | 适用场景 | 示例 |
436
+ |---------|---------|------|
437
+ | **MCP** (35 tools) | Claude Code / Cursor / Windsurf 等 | `bingo-light setup` 自动配 |
438
+ | **CLI `--json`** | 任何能跑 shell 的 AI | `bingo-light sync --json --yes` |
439
+ | **Skill** | Claude Code / Continue / Gemini 等 | `/bingo` 教 AI 用法 |
326
440
 
327
- ```bash
328
- bingo-light status --json # Parse fork state
329
- bingo-light sync --yes # Non-interactive sync
330
- bingo-light conflict-analyze --json # Structured conflict data
331
- ```
441
+ <details>
442
+ <summary><b>自定义 Python 代理</b></summary>
332
443
 
333
444
  ```python
334
445
  import subprocess, json
@@ -345,178 +456,145 @@ if status["behind"] > 0:
345
456
  result = bingo("sync")
346
457
  if result.get("conflicts"):
347
458
  analysis = bingo("conflict-analyze")
348
- # AI resolves each conflict...
459
+ for c in analysis["conflicts"]:
460
+ resolved = my_llm_resolve(c["ours"], c["theirs"], c["hint"])
349
461
  ```
350
462
 
351
- ---
463
+ </details>
352
464
 
353
- ## Command Reference
465
+ ## 配置
354
466
 
355
- ```
356
- bingo-light init <upstream-url> [branch] Set up upstream tracking
357
- bingo-light sync [--dry-run] [--force] Sync with upstream
358
- bingo-light sync --test Sync + run tests, undo on failure
359
- bingo-light undo Revert to pre-sync state
360
- bingo-light status Fork health + conflict prediction
361
- bingo-light diff Combined patch diff vs upstream
362
- bingo-light doctor Full diagnostic
363
- bingo-light log Sync history
364
- bingo-light history Detailed sync history with hash mappings
365
- bingo-light patch new <name> Create named patch from staged changes
366
- bingo-light patch list [-v] List patch stack
367
- bingo-light patch show <name|index> Show patch diff
368
- bingo-light patch edit <name|index> Amend a patch (stage changes first)
369
- bingo-light patch drop <name|index> Remove a patch
370
- bingo-light patch reorder [--order "3,1,2"] Reorder patches
371
- bingo-light patch export [dir] Export as .patch files
372
- bingo-light patch import <file|dir> Import .patch files
373
- bingo-light patch squash <idx1> <idx2> Merge two patches
374
- bingo-light patch meta <name> [key] [value] Get/set patch metadata
375
- bingo-light conflict-analyze Structured conflict data for AI
376
- bingo-light config get|set|list [key] [val] Manage configuration
377
- bingo-light test Run configured test suite
378
- bingo-light workspace init|add|status|sync Multi-repo management
379
- bingo-light auto-sync Generate GitHub Actions workflow
380
- bingo-light version Print version
381
- bingo-light help Show usage
467
+ 配置存在 `.bingolight`(git-config 格式),自动排除在版本控制外。
468
+
469
+ ```bash
470
+ bingo-light config set sync.auto-test true # 同步后自动跑测试
471
+ bingo-light config set test.command "make test" # 测试命令
472
+ bingo-light config list # 查看所有配置
382
473
  ```
383
474
 
384
- **Global flags:** `--json` (structured output) | `--yes` / `-y` (skip all prompts)
475
+ ### 通知 Hook
385
476
 
386
- ---
477
+ 在 `.bingo/hooks/` 放可执行脚本:
387
478
 
388
- ## Why not just...
479
+ | Hook | 触发时机 |
480
+ |------|---------|
481
+ | `on-sync-success` | 同步成功后 |
482
+ | `on-conflict` | rebase 碰到冲突时 |
483
+ | `on-test-fail` | 同步后测试失败时 |
389
484
 
390
- <details>
391
- <summary><b>...click GitHub's "Sync fork" button?</b></summary>
392
- <br>
485
+ Hook 通过 stdin 接 JSON。示例见 [contrib/hooks/](contrib/hooks/)(Slack / Discord / Webhook)。
393
486
 
394
- It only does fast-forward. The moment you have any customizations (commits on your fork that aren't in upstream), it either refuses or creates a merge commit that buries your changes. It has no concept of a patch stack, no conflict memory, and no API for AI agents.
395
- </details>
487
+ ## 常见问题
396
488
 
397
489
  <details>
398
- <summary><b>...use <code>git rebase</code> manually?</b></summary>
399
- <br>
490
+ <summary><b>为什么不直接 <code>git rebase</code>?</b></summary>
400
491
 
401
- You can. It takes 6 steps: fetch, checkout tracking branch, pull, checkout patches branch, rebase, push. You need to remember which branch is which, manually enable rerere, and hope you don't mess up the reflog if something goes wrong. bingo-light wraps all of this into `bingo-light sync` with automatic undo, conflict prediction, and structured output.
492
+ 可以。bingo-light 包的是 rebase 周边那些烦事:追踪上游、维护补丁分支、开 rerere、预测冲突、输出结构化数据。偶尔 rebase 一次用不着它,但长期维护好几个补丁的话,省心省力。
402
493
  </details>
403
494
 
404
495
  <details>
405
- <summary><b>...use StGit / quilt / TopGit?</b></summary>
406
- <br>
496
+ <summary><b>能用在已有的 Fork 上吗?</b></summary>
407
497
 
408
- StGit (649 stars) manages patch stacks but has no AI integration, no MCP server, no JSON output, and no conflict prediction. quilt operates outside git entirely -- no rerere, no history. TopGit is effectively abandoned. None of them were designed for the AI-agent era.
498
+ 能。进你的 Fork 目录,`bingo-light init <upstream-url>`,再 `bingo-light patch new <name>` 把现有改动转成补丁。标准 git 仓库就行。
409
499
  </details>
410
500
 
411
- ## Comparison
412
-
413
- | | **bingo-light** | GitHub Sync | git rebase | quilt | StGit |
414
- |---|:---:|:---:|:---:|:---:|:---:|
415
- | Named patch stack | **Yes** | No | No | Yes | Yes |
416
- | One-command sync | **Yes** | Click only | No (6 steps) | No | No |
417
- | Handles customizations | **Yes** | **No** | Manual | Manual | Manual |
418
- | Conflict memory (rerere) | **Auto** | No | Manual | No | No |
419
- | Conflict prediction | **Yes** | No | No | No | No |
420
- | AI / MCP integration | **29 tools** | No | No | No | No |
421
- | JSON output | **All commands** | No | No | No | No |
422
- | Non-interactive mode | **Native** | No | Partial | Partial | Partial |
423
- | Undo sync | **One command** | No | git reflog | Manual | Manual |
424
- | Install | One command | Built-in | Built-in | Package mgr | Package mgr |
425
-
426
- ---
501
+ <details>
502
+ <summary><b>只给 AI 用?</b></summary>
427
503
 
428
- ## FAQ
504
+ 人和 AI 用的是同一套命令。`bingo-light sync` 谁跑都一样。`--json`、`--yes`、MCP 这些是给 AI 加的接口,不加就是正常的人类输出。
505
+ </details>
429
506
 
430
507
  <details>
431
- <summary><b>Why not just <code>git rebase</code>?</b></summary>
432
- <br>
508
+ <summary><b>冲突记忆怎么回事?</b></summary>
433
509
 
434
- You can. bingo-light automates everything around it: tracking the upstream remote, maintaining a dedicated patch branch, enabling rerere, predicting conflicts before you sync, and exposing structured output for automation. For a one-off rebase it's overkill. For ongoing fork maintenance with 3+ patches across months of upstream drift, it saves serious time and eliminates an entire class of mistakes.
510
+ `init` 时自动开了 git `rerere`(reuse recorded resolution)。你解一次冲突,git 记住解法。下次碰到一样的冲突,直接套用,不再问你。bingo-light 还会检测到自动解决的冲突后自己继续 rebase,不会卡着等人。
435
511
  </details>
436
512
 
437
513
  <details>
438
- <summary><b>Can I use this on an existing fork?</b></summary>
439
- <br>
514
+ <summary><b>同步搞砸了?</b></summary>
440
515
 
441
- Yes. Run `bingo-light init <upstream-url>` in your fork. Convert your existing changes into named patches with `bingo-light patch new <name>`. The tool works with any standard git repository -- it doesn't care how you got here.
516
+ `bingo-light undo`。补丁分支秒回同步前的状态。底层用 reflog,再复杂的 rebase 也能回。
442
517
  </details>
443
518
 
444
519
  <details>
445
- <summary><b>Is this only for AI agents?</b></summary>
446
- <br>
520
+ <summary><b>支持 GitHub/GitLab/Bitbucket 吗?</b></summary>
447
521
 
448
- No. The CLI is designed for humans first. `bingo-light sync` is the same command whether you run it or an AI does. The AI-native features (`--json`, `--yes`, MCP server) are purely additive -- without them you get normal, human-readable output with colors and progress indicators.
522
+ 都支持。底层就是标准 git 操作(fetch、rebase、push),什么 git 远程都能用。`auto-sync` 能生成 GitHub Actions 流水线,但核心功能不绑平台。
449
523
  </details>
450
524
 
451
525
  <details>
452
- <summary><b>How does conflict memory work?</b></summary>
453
- <br>
526
+ <summary><b>和 <code>git format-patch</code> / quilt 有什么区别?</b></summary>
454
527
 
455
- bingo-light enables git's `rerere` (reuse recorded resolution) on `init`. When you resolve a conflict, git records the resolution. Next time the exact same conflict appears during sync, it's applied automatically. bingo-light detects when rerere has auto-resolved all conflicts and continues the rebase without stopping. You solve each conflict exactly once.
528
+ `format-patch` 能导出但不管活的补丁栈。quilt 管栈但脱离了 gitbingo-light 的补丁就是真正的 git commit,享受完整历史、冲突解决、rerere 记忆,同时支持 quilt 格式导出导入。
456
529
  </details>
457
530
 
531
+ ## 为什么不用...
532
+
458
533
  <details>
459
- <summary><b>What if sync goes wrong?</b></summary>
534
+ <summary><b>...GitHub "Sync fork" 按钮?</b></summary>
460
535
  <br>
461
536
 
462
- Run `bingo-light undo`. It restores your patches branch to exactly where it was before the sync. This works via git reflog, so it's reliable even after complex rebases. You can also use `sync --dry-run` to test on a throwaway branch first, or `sync --test` to auto-undo if your test suite fails after sync.
537
+ 只能 fast-forward。你一有自己的改动,它要么拒绝要么生成 merge commit 把你的代码埋了。没有补丁栈,没有冲突记忆,没有 API。
463
538
  </details>
464
539
 
465
540
  <details>
466
- <summary><b>Does it work with GitHub / GitLab / Bitbucket?</b></summary>
541
+ <summary><b>...手动 <code>git rebase</code>?</b></summary>
467
542
  <br>
468
543
 
469
- Yes. bingo-light uses standard git operations (fetch, rebase, push). It works with any git remote on any platform. The `auto-sync` command generates a GitHub Actions workflow specifically, but the core tool is completely platform-agnostic.
544
+ 可以,6 步:fetch、切 tracking 分支、pull、切 patches 分支、rebasepush。得记住分支名、手动开 rerere、搞砸了自己从 reflog 里捞。`bingo-light sync` 一条命令包了,还带撤销、冲突预测和结构化输出。
470
545
  </details>
471
546
 
472
547
  <details>
473
- <summary><b>How is this different from <code>git format-patch</code> / quilt?</b></summary>
548
+ <summary><b>...StGit / quilt / TopGit?</b></summary>
474
549
  <br>
475
550
 
476
- `git format-patch` exports patches but doesn't manage them as a living stack. quilt manages patch stacks but operates outside git -- no conflict resolution, no rerere, no history. bingo-light keeps patches as real git commits so you get full git history, proper conflict resolution, and automatic rerere, while still supporting export/import in quilt-compatible `.patch` format. Best of both worlds.
551
+ StGit 管栈但没 AI 集成、没 MCP、没 JSON 输出、没冲突预测。quilt 脱离 git 体系,没 rerere 没历史。TopGit 基本废弃了。这些工具都不是为 AI 时代设计的。
477
552
  </details>
478
553
 
479
- ---
554
+ ## 与其他方案对比
480
555
 
481
- ## Project Ecosystem
556
+ | | **bingo-light** | GitHub Sync | git rebase | quilt | StGit |
557
+ |---|:---:|:---:|:---:|:---:|:---:|
558
+ | 命名补丁栈 | **有** | 无 | 无 | 有 | 有 |
559
+ | 一键同步 | **有** | 仅按钮 | 无(6 步) | 无 | 无 |
560
+ | 处理定制化改动 | **有** | **不行** | 手动 | 手动 | 手动 |
561
+ | 冲突记忆 (rerere) | **自动** | 无 | 需手动启用 | 无 | 无 |
562
+ | 冲突预测 | **有** | 无 | 无 | 无 | 无 |
563
+ | AI/MCP 集成 | **35 个工具** | 无 | 无 | 无 | 无 |
564
+ | JSON 输出 | **所有命令** | 无 | 无 | 无 | 无 |
565
+ | 非交互模式 | **原生支持** | 无 | 部分 | 部分 | 部分 |
566
+ | 撤销同步 | **一条命令** | 无 | git reflog | 手动 | 手动 |
567
+ | 安装方式 | 一条命令 | 内置 | 内置 | 包管理器 | 包管理器 |
568
+
569
+ ## 项目生态
482
570
 
483
571
  ```
484
- bingo-light CLI tool (Python 3, zero deps)
485
- bingo_core/ Core library package (all business logic)
486
- mcp-server.py MCP server (zero-dep Python 3, 29 tools, JSON-RPC 2.0)
487
- contrib/agent.py Advisor agent (monitors drift, auto-syncs when safe)
488
- contrib/tui.py Terminal dashboard (curses TUI, real-time monitoring)
489
- install.sh Installer (--yes for CI, --help for options)
490
- completions/ Shell completions (bash / zsh / fish)
491
- contrib/hooks/ Notification hook examples (Slack / Discord / Webhook)
492
- tests/test.sh Test suite (70 tests)
493
- docs/ Documentation + demo SVG
494
- docs/llms.txt Complete LLM-consumable reference
572
+ bingo-light CLI 入口(Python 3,零依赖)
573
+ bingo_core/ 核心库包(全部业务逻辑)
574
+ mcp-server.py MCP 服务器(零依赖 Python 3,35 个工具)
575
+ contrib/agent.py Advisor 代理(监控 + 分析 + 安全时自动同步)
576
+ contrib/tui.py 终端面板(curses TUI
577
+ install.sh 安装器(--yes 支持 CI,--help 查看选项)
578
+ completions/ Shell 补全(bash/zsh/fish
579
+ contrib/hooks/ 通知 Hook 示例(Slack/Discord/Webhook
580
+ tests/ 测试套件(250 个测试,5 个文件)
581
+ docs/ 文档
495
582
  ```
496
583
 
497
- ---
498
-
499
- ## Documentation
500
-
501
- - [Getting Started](docs/getting-started.md) -- 5-minute quickstart guide
502
- - [Concepts](docs/concepts.md) -- branch model, patch stack, sync flow
503
- - [Changelog](CHANGELOG.md) -- version history
504
- - [Security](.github/SECURITY.md) -- security model and vulnerability reporting
505
-
506
- ## Contributing
584
+ ## 参与贡献
507
585
 
508
- Pure Python, zero dependencies, no build step. If you can read Python, you can contribute.
586
+ 欢迎 PR。纯 Python,零依赖,不用构建。
509
587
 
510
588
  ```bash
511
589
  git clone https://github.com/DanOps-1/bingo-light.git
512
590
  cd bingo-light
513
- make test # core test suite
514
- make test-all # all 250 tests (core + fuzz + edge + MCP + unit)
515
- make lint # python syntax + flake8 + shellcheck
591
+ make test # 核心测试
592
+ make test-all # 全部 250 个测试
593
+ make lint # Python 语法 + flake8 + shellcheck
516
594
  ```
517
595
 
518
- See [CONTRIBUTING.md](CONTRIBUTING.md) for details.
596
+ 详见 [CONTRIBUTING.md](CONTRIBUTING.md)
519
597
 
520
- ## License
598
+ ## 许可证
521
599
 
522
- [MIT](LICENSE) -- do whatever you want.
600
+ [MIT](LICENSE)