bingo-light 2.0.1 → 2.1.1

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,130 +2,149 @@
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>Fork 同步,一条命令搞定。<br>人用、AI 用,零依赖。</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-29_tools-blueviolet.svg" alt="MCP: 27 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
+ GitHub 的 "Sync fork" 按钮?你一改代码它就废了。手动 `git rebase`?六步操作,每次都得记。AI 想帮你同步?没接口可调。
23
20
 
24
- **bingo-light fixes all three.**
21
+ **bingo-light 把这三个问题一锅端。**
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
+ 改动以补丁栈的形式叠在上游之上,干干净净。同步一句 `bingo-light sync`。冲突解过一次就记住了,下次自动跳过。搞砸了 `bingo-light 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
+ 所有命令支持 `--json` 输出。内置 MCP 服务器 29 个工具,AI 从初始化到冲突解决全程自主,不用人盯。
29
26
 
30
27
  ---
31
28
 
32
- <p align="center">
33
- <img src="docs/demo.svg" alt="bingo-light demo" width="850">
34
- </p>
29
+ ## 目录
30
+
31
+ - [快速开始](#快速开始)
32
+ - [演示](#演示)
33
+ - [安装](#安装)
34
+ - [功能特性](#功能特性)
35
+ - [工作原理](#工作原理)
36
+ - [MCP 服务器](#mcp-服务器)
37
+ - [命令参考](#命令参考)
38
+ - [集成指南](#集成指南)
39
+ - [配置](#配置)
40
+ - [常见问题](#常见问题)
41
+ - [与其他方案对比](#与其他方案对比)
42
+ - [项目生态](#项目生态)
43
+ - [参与贡献](#参与贡献)
44
+ - [许可证](#许可证)
35
45
 
36
46
  ---
37
47
 
38
- ## Quick Start
48
+ ## 快速开始
39
49
 
40
50
  ```bash
41
- # Install (pick one)
51
+ # 安装(任选一种)
42
52
  pip install bingo-light # Python
43
53
  npm install -g bingo-light # Node.js
44
54
  brew install DanOps-1/tap/bingo-light # Homebrew
45
55
 
46
- # Point at upstream
47
- cd your-forked-project
56
+ # 初始化 Fork 追踪
57
+ cd my-forked-project
48
58
  bingo-light init https://github.com/original/project.git
49
59
 
50
- # Sync whenever you want -- patches rebase on top automatically
60
+ # 改代码,创建命名补丁
61
+ vim src/feature.py
62
+ bingo-light patch new my-feature
63
+
64
+ # 上游有更新?一句话同步
51
65
  bingo-light sync
52
66
  ```
53
67
 
54
- That's it. Three commands and your fork stays in sync forever.
68
+ 就这么简单。补丁永远干净地叠在最新上游之上。
55
69
 
56
- ## Demo
70
+ ## 演示
57
71
 
58
- ### Basic workflow: init, patch, sync
72
+ ### 日常操作:初始化 建补丁 同步
59
73
 
60
74
  <p align="center">
61
- <img src="docs/demo.svg" alt="bingo-light basic demo" width="850">
75
+ <img src="docs/demo.svg" alt="bingo-light 基本演示" width="850">
62
76
  </p>
63
77
 
64
- ### Conflict resolution: sync, analyze, resolve
78
+ ### 冲突处理:同步 分析 搞定
65
79
 
66
80
  <p align="center">
67
- <img src="docs/demo-conflict.svg" alt="bingo-light conflict resolution demo" width="850">
81
+ <img src="docs/demo-conflict.svg" alt="bingo-light 冲突解决演示" width="850">
68
82
  </p>
69
83
 
70
- > The AI calls `conflict-analyze --json`, reads the structured ours/theirs data, writes the merged file, and the rebase continues. No human needed.
84
+ > AI `conflict-analyze --json` 拿到双方代码,写好合并结果,rebase 自动继续。全程零人工。
71
85
 
72
- ---
86
+ ### AI 拿到的是结构化数据
73
87
 
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.
88
+ ```
89
+ $ bingo-light status --json
90
+ ```
91
+ ```json
92
+ {
93
+ "ok": true,
94
+ "upstream_url": "https://github.com/torvalds/linux.git",
95
+ "behind": 47,
96
+ "patch_count": 2,
97
+ "patches": [
98
+ {"name": "custom-scheduler", "hash": "a3f7c21", "subject": "O(1) task scheduling", "files": 3},
99
+ {"name": "perf-monitoring", "hash": "b8e2d4f", "subject": "eBPF tracing hooks", "files": 5}
100
+ ],
101
+ "conflict_risk": ["kernel/sched/core.c"]
102
+ }
103
+ ```
104
104
 
105
- ---
105
+ ### 冲突分析(AI 直接消费)
106
106
 
107
- ## Installation
107
+ ```
108
+ $ bingo-light conflict-analyze --json
109
+ ```
110
+ ```json
111
+ {
112
+ "rebase_in_progress": true,
113
+ "current_patch": "custom-scheduler",
114
+ "conflicts": [
115
+ {
116
+ "file": "kernel/sched/core.c",
117
+ "conflict_count": 2,
118
+ "ours": "... 上游版本 ...",
119
+ "theirs": "... 你的补丁版本 ...",
120
+ "hint": "上游重构了调度器核心;补丁需要适配新结构。"
121
+ }
122
+ ]
123
+ }
124
+ ```
108
125
 
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.).
126
+ ## 安装
127
+
128
+ 装完跑 `bingo-light setup`,交互式配好 MCP 和 AI Skill(Claude Code、Cursor、Windsurf、VS Code/Copilot、Gemini CLI 等一键选配)。
110
129
 
111
130
  ### pip / pipx
112
131
 
113
132
  ```bash
114
- pip install bingo-light # or: pipx install bingo-light
115
- bingo-light setup # interactive — pick which AI tools to configure
133
+ pip install bingo-light # 或: pipx install bingo-light
134
+ bingo-light setup # 选配 AI 工具
116
135
  ```
117
136
 
118
137
  ### npm / npx
119
138
 
120
139
  ```bash
121
- npm install -g bingo-light # global install
140
+ npm install -g bingo-light # 全局安装
122
141
  bingo-light setup
123
142
 
124
- # Or use npx — no install needed:
143
+ # npx 免装:
125
144
  npx bingo-light setup
126
145
  ```
127
146
 
128
- MCP clients can use npx directly:
147
+ MCP 客户端直接用 npx
129
148
  ```json
130
149
  {"command": "npx", "args": ["-y", "bingo-light-mcp"]}
131
150
  ```
@@ -143,20 +162,20 @@ bingo-light setup
143
162
  # CLI
144
163
  docker run --rm -v "$PWD:/repo" -w /repo ghcr.io/danops-1/bingo-light status
145
164
 
146
- # MCP server (stdio transport)
165
+ # MCP 服务器(stdio
147
166
  docker run --rm -i -v "$PWD:/repo" -w /repo ghcr.io/danops-1/bingo-light mcp-server.py
148
167
  ```
149
168
 
150
- ### Shell installer
169
+ ### Shell 安装器
151
170
 
152
171
  ```bash
153
172
  curl -fsSL https://raw.githubusercontent.com/DanOps-1/bingo-light/main/install.sh | sh
154
173
 
155
- # Non-interactive (CI / Docker)
174
+ # 非交互模式(CI / Docker
156
175
  curl -fsSL .../install.sh | sh -s -- --yes
157
176
  ```
158
177
 
159
- ### From source
178
+ ### 从源码安装
160
179
 
161
180
  ```bash
162
181
  git clone https://github.com/DanOps-1/bingo-light.git
@@ -164,46 +183,78 @@ cd bingo-light
164
183
  make install && bingo-light setup
165
184
  ```
166
185
 
167
- **Requirements:** Python 3.8+, git 2.20+. Zero pip dependencies.
168
-
169
- ---
170
-
171
- ## How It Works
186
+ **依赖:** Python 3.8+ / git 2.20+,没了。
187
+
188
+ ## 功能特性
189
+
190
+ ### AI
191
+
192
+ | 功能 | 说明 |
193
+ |------|------|
194
+ | **MCP 服务器** | 29 个工具,初始化到冲突解决全覆盖 |
195
+ | **`--json`** | 所有命令输出结构化 JSON |
196
+ | **`--yes`** | 跳过一切确认,不需要 TTY |
197
+ | **非 TTY 自适应** | 管道或子进程调用时自动静默 |
198
+ | **`BINGO_DESCRIPTION`** | 环境变量设补丁描述 |
199
+ | **`conflict-analyze`** | 冲突数据结构化:文件、双方代码、解决提示 |
200
+ | **`conflict-resolve`** | MCP 直接写入解决内容,自动暂存 + 继续 rebase |
201
+ | **Advisor 代理** | `contrib/agent.py` 自动监控、分析、安全时自动同步 |
202
+
203
+ ### 人类侧
204
+
205
+ | 功能 | 说明 |
206
+ |------|------|
207
+ | **零依赖** | Python 3 + git,一行装完 |
208
+ | **命名补丁** | 每个改动是独立的、有名字的 commit |
209
+ | **一键同步** | `bingo-light sync`,补丁自动 rebase 到最新上游 |
210
+ | **先试后跑** | `sync --dry-run` 临时分支预演,不碰真代码 |
211
+ | **冲突记忆** | rerere 自动开,解一次就记住,再也不问 |
212
+ | **秒级撤销** | `bingo-light undo` 恢复同步前状态 |
213
+ | **冲突预警** | `status` 提前告诉你哪些文件会出事 |
214
+ | **自检修复** | `doctor` 全面体检 + 试跑 rebase |
215
+ | **导出导入** | `.patch` 文件,quilt 兼容 |
216
+ | **CI 自动同步** | 生成 GitHub Actions 流水线,冲突自动告警 |
217
+ | **TUI 面板** | curses 实时仪表盘(`contrib/tui.py`) |
218
+ | **多仓管理** | `workspace` 统一管所有 Fork |
219
+ | **补全** | bash / zsh / fish |
220
+ | **通知推送** | Discord、Slack、Webhook,事件触发 |
221
+ | **补丁元数据** | 标签、原因、过期时间、关联上游 PR |
222
+ | **测试联动** | 同步后自动跑测试,挂了自动回滚 |
223
+
224
+ ## 工作原理
172
225
 
173
226
  ```
174
227
  upstream (github.com/original/project)
175
228
  |
176
229
  | git fetch
177
230
  v
178
- upstream-tracking ──────── exact mirror of upstream, never touched
231
+ upstream-tracking ─────── 上游的精确镜像,从不手动碰
179
232
  |
180
233
  | git rebase
181
234
  v
182
- bingo-patches ──────────── your customizations stacked here
235
+ bingo-patches ─────────── 你的改动叠在这里
183
236
  |
184
- +── [bl] custom-scheduler: O(1) task scheduling
185
- +── [bl] perf-monitoring: eBPF tracing hooks
186
- +── [bl] fix-logging: structured JSON logs
237
+ +── [bl] custom-scheduler: O(1) 任务调度
238
+ +── [bl] perf-monitoring: eBPF 追踪钩子
239
+ +── [bl] fix-logging: 结构化 JSON 日志
187
240
  |
188
241
  v
189
- HEAD (your working fork)
242
+ HEAD (你的工作 Fork)
190
243
  ```
191
244
 
192
- **Sync flow:** fetch upstream, fast-forward the tracking branch, rebase your patches on top. Your patches always sit cleanly on the latest upstream.
193
-
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.
245
+ **同步:** fetch 上游 快进追踪分支 rebase 补丁到最新上游。补丁永远干净地叠在最新代码上。
195
246
 
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.
247
+ **冲突记忆:** 初始化时自动开 rerere。解过一次,git 就记住了——下次碰到同样的冲突直接跳过。
197
248
 
198
- ---
249
+ **AI 解冲突:** rebase 卡住时,AI 调 `conflict-analyze` 拿双方代码和提示,写好合并结果扔给 `conflict-resolve`,rebase 自动继续,不用人管。
199
250
 
200
- ## For AI Agents
251
+ ## MCP 服务器
201
252
 
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.
253
+ `mcp-server.py`,纯 Python 3,零依赖,stdio 传输,29 个工具,JSON-RPC 2.0。
203
254
 
204
- ### MCP setup -- Claude Code
255
+ 运行 `bingo-light setup` 自动配置,或手动添加:
205
256
 
206
- Add to `.mcp.json` in your project root or `~/.claude/settings.json`:
257
+ **Claude Code**(`.mcp.json` `~/.claude/settings.json`):
207
258
 
208
259
  ```json
209
260
  {
@@ -216,9 +267,7 @@ Add to `.mcp.json` in your project root or `~/.claude/settings.json`:
216
267
  }
217
268
  ```
218
269
 
219
- ### MCP setup -- Claude Desktop
220
-
221
- Add to `~/Library/Application Support/Claude/claude_desktop_config.json`:
270
+ **Claude Desktop**(`~/Library/Application Support/Claude/claude_desktop_config.json`):
222
271
 
223
272
  ```json
224
273
  {
@@ -231,105 +280,102 @@ Add to `~/Library/Application Support/Claude/claude_desktop_config.json`:
231
280
  }
232
281
  ```
233
282
 
234
- **Any MCP client** (VS Code Copilot, Cursor, custom agents): connect via stdio to `python3 mcp-server.py`.
235
-
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
283
+ **其他客户端**(Cursor、Windsurf、VS Code Copilot 等):stdio `python3 mcp-server.py`,或跑 `bingo-light setup` 一键配。
284
+
285
+ ### 全部工具
286
+
287
+ | 工具 | 用途 |
288
+ |------|------|
289
+ | `bingo_init` | 初始化 Fork 追踪 |
290
+ | `bingo_status` | 健康检查:漂移、补丁、冲突风险 |
291
+ | `bingo_sync` | 拉取上游并变基补丁 |
292
+ | `bingo_undo` | 恢复到同步前状态 |
293
+ | `bingo_patch_new` | 创建命名补丁 |
294
+ | `bingo_patch_list` | 列出补丁栈 |
295
+ | `bingo_patch_show` | 查看补丁 diff |
296
+ | `bingo_patch_drop` | 移除补丁 |
297
+ | `bingo_patch_export` | 导出为 `.patch` 文件 |
298
+ | `bingo_patch_import` | 导入 `.patch` 文件 |
299
+ | `bingo_patch_meta` | 获取/设置补丁元数据 |
300
+ | `bingo_patch_squash` | 合并两个补丁 |
301
+ | `bingo_patch_reorder` | 非交互式重排补丁 |
302
+ | `bingo_doctor` | 全面诊断 + 测试变基 |
303
+ | `bingo_diff` | 补丁总 diff vs 上游 |
304
+ | `bingo_auto_sync` | 生成 GitHub Actions 工作流 |
305
+ | `bingo_conflict_analyze` | AI 用的结构化冲突数据 |
306
+ | `bingo_conflict_resolve` | 写入解决内容,暂存,继续 rebase |
307
+ | `bingo_config` | 获取/设置配置 |
308
+ | `bingo_history` | 同步历史 + hash 映射 |
309
+ | `bingo_test` | 运行测试套件 |
310
+ | `bingo_workspace_status` | 多仓库工作区概览 |
311
+ | `bingo_patch_edit` | 修改已有补丁 |
312
+ | `bingo_workspace_init` | 初始化多仓库工作区 |
313
+ | `bingo_workspace_add` | 添加仓库到工作区 |
314
+ | `bingo_workspace_sync` | 同步工作区所有仓库 |
315
+ | `bingo_workspace_list` | 列出工作区仓库 |
316
+
317
+ ## 命令参考
269
318
 
270
- ```bash
271
- # Fork status (AI-friendly)
272
- bingo-light status --json
273
319
  ```
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
- }
320
+ bingo-light init <upstream-url> [branch] 初始化上游追踪
321
+ bingo-light patch new <name> 创建命名补丁
322
+ bingo-light patch list [-v] 列出补丁栈
323
+ bingo-light patch show <name|index> 查看补丁 diff
324
+ bingo-light patch edit <name|index> 修改补丁(先暂存变更)
325
+ bingo-light patch drop <name|index> 移除补丁
326
+ bingo-light patch reorder [--order "3,1,2"] 重排补丁
327
+ bingo-light patch export [dir] 导出为 .patch 文件
328
+ bingo-light patch import <file|dir> 导入 .patch 文件
329
+ bingo-light patch squash <idx1> <idx2> 合并两个补丁
330
+ bingo-light patch meta <name> [key] [value] 获取/设置补丁元数据
331
+ bingo-light sync [--dry-run] [--force] 与上游同步
332
+ bingo-light sync --test 同步后跑测试,失败自动回滚
333
+ bingo-light undo 恢复到同步前状态
334
+ bingo-light status 健康检查 + 冲突预测
335
+ bingo-light doctor 全面诊断
336
+ bingo-light diff 补丁总 diff vs 上游
337
+ bingo-light log 同步历史
338
+ bingo-light conflict-analyze 分析 rebase 冲突
339
+ bingo-light config get|set|list [key] [val] 管理配置
340
+ bingo-light history 详细同步历史 + 映射
341
+ bingo-light test 运行测试套件
342
+ bingo-light workspace init|add|status|sync 多仓库管理
343
+ bingo-light auto-sync 生成 GitHub Actions 工作流
344
+ bingo-light version 打印版本
345
+ bingo-light help 打印帮助
287
346
  ```
288
347
 
289
- ```bash
290
- # Conflict analysis (structured data for AI resolution)
291
- bingo-light conflict-analyze --json
292
- ```
348
+ **全局标志:** `--json`(结构化 JSON 输出) | `--yes`(跳过所有确认提示)
293
349
 
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
- ```
350
+ ## 集成指南
351
+
352
+ ### Claude Code (MCP)
309
353
 
310
- ### End-to-end AI workflow
354
+ MCP 配好后,Claude Code 全程接管:
311
355
 
312
356
  ```
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
357
+ 你: "同步上游,冲突帮我修了。"
358
+
359
+ Claude Code:
360
+ 1. bingo_status(cwd) 落后 47 commit,risk: core.c
361
+ 2. bingo_sync(cwd, dry_run) → 预判 1 个冲突
362
+ 3. bingo_sync(cwd) rebase 卡在冲突
363
+ 4. bingo_conflict_analyze() 拿到双方代码 + 提示
364
+ 5. 读两边,写合并结果
365
+ 6. bingo_conflict_resolve(cwd, file, content) 搞定
366
+ 7. bingo_status(cwd) 0 落后,补丁干净
323
367
  ```
324
368
 
325
- ### CLI integration (Aider, custom agents)
369
+ ### Aider / CLI 代理
326
370
 
327
371
  ```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
372
+ bingo-light status --json # 解析 Fork 状态
373
+ bingo-light sync --yes # 非交互同步
374
+ bingo-light conflict-analyze --json # 结构化冲突数据
331
375
  ```
332
376
 
377
+ ### 自定义 Python 代理
378
+
333
379
  ```python
334
380
  import subprocess, json
335
381
 
@@ -345,178 +391,144 @@ if status["behind"] > 0:
345
391
  result = bingo("sync")
346
392
  if result.get("conflicts"):
347
393
  analysis = bingo("conflict-analyze")
348
- # AI resolves each conflict...
394
+ for c in analysis["conflicts"]:
395
+ resolved = my_llm_resolve(c["ours"], c["theirs"], c["hint"])
396
+ # 通过 CLI 或 MCP 写入解决内容
349
397
  ```
350
398
 
351
- ---
399
+ ## 配置
352
400
 
353
- ## Command Reference
401
+ 配置存在 `.bingolight`(git-config 格式),自动排除在版本控制外。
354
402
 
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
403
+ ```bash
404
+ bingo-light config set sync.auto-test true # 同步后自动跑测试
405
+ bingo-light config set test.command "make test" # 测试命令
406
+ bingo-light config list # 查看所有配置
382
407
  ```
383
408
 
384
- **Global flags:** `--json` (structured output) | `--yes` / `-y` (skip all prompts)
409
+ ### 通知 Hook
385
410
 
386
- ---
411
+ 在 `.bingo/hooks/` 放可执行脚本:
387
412
 
388
- ## Why not just...
413
+ | Hook | 触发时机 |
414
+ |------|---------|
415
+ | `on-sync-success` | 同步成功后 |
416
+ | `on-conflict` | rebase 碰到冲突时 |
417
+ | `on-test-fail` | 同步后测试失败时 |
389
418
 
390
- <details>
391
- <summary><b>...click GitHub's "Sync fork" button?</b></summary>
392
- <br>
419
+ Hook 通过 stdin 接 JSON。示例见 [contrib/hooks/](contrib/hooks/)(Slack / Discord / Webhook)。
393
420
 
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>
421
+ ## 常见问题
396
422
 
397
423
  <details>
398
- <summary><b>...use <code>git rebase</code> manually?</b></summary>
399
- <br>
424
+ <summary><b>为什么不直接 <code>git rebase</code>?</b></summary>
400
425
 
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.
426
+ 可以。bingo-light 包的是 rebase 周边那些烦事:追踪上游、维护补丁分支、开 rerere、预测冲突、输出结构化数据。偶尔 rebase 一次用不着它,但长期维护好几个补丁的话,省心省力。
402
427
  </details>
403
428
 
404
429
  <details>
405
- <summary><b>...use StGit / quilt / TopGit?</b></summary>
406
- <br>
430
+ <summary><b>能用在已有的 Fork 上吗?</b></summary>
407
431
 
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.
432
+ 能。进你的 Fork 目录,`bingo-light init <upstream-url>`,再 `bingo-light patch new <name>` 把现有改动转成补丁。标准 git 仓库就行。
409
433
  </details>
410
434
 
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
- ---
435
+ <details>
436
+ <summary><b>只给 AI 用?</b></summary>
427
437
 
428
- ## FAQ
438
+ 人和 AI 用的是同一套命令。`bingo-light sync` 谁跑都一样。`--json`、`--yes`、MCP 这些是给 AI 加的接口,不加就是正常的人类输出。
439
+ </details>
429
440
 
430
441
  <details>
431
- <summary><b>Why not just <code>git rebase</code>?</b></summary>
432
- <br>
442
+ <summary><b>冲突记忆怎么回事?</b></summary>
433
443
 
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.
444
+ `init` 时自动开了 git `rerere`(reuse recorded resolution)。你解一次冲突,git 记住解法。下次碰到一样的冲突,直接套用,不再问你。bingo-light 还会检测到自动解决的冲突后自己继续 rebase,不会卡着等人。
435
445
  </details>
436
446
 
437
447
  <details>
438
- <summary><b>Can I use this on an existing fork?</b></summary>
439
- <br>
448
+ <summary><b>同步搞砸了?</b></summary>
440
449
 
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.
450
+ `bingo-light undo`。补丁分支秒回同步前的状态。底层用 reflog,再复杂的 rebase 也能回。
442
451
  </details>
443
452
 
444
453
  <details>
445
- <summary><b>Is this only for AI agents?</b></summary>
446
- <br>
454
+ <summary><b>支持 GitHub/GitLab/Bitbucket 吗?</b></summary>
447
455
 
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.
456
+ 都支持。底层就是标准 git 操作(fetch、rebase、push),什么 git 远程都能用。`auto-sync` 能生成 GitHub Actions 流水线,但核心功能不绑平台。
449
457
  </details>
450
458
 
451
459
  <details>
452
- <summary><b>How does conflict memory work?</b></summary>
453
- <br>
460
+ <summary><b>和 <code>git format-patch</code> / quilt 有什么区别?</b></summary>
454
461
 
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.
462
+ `format-patch` 能导出但不管活的补丁栈。quilt 管栈但脱离了 gitbingo-light 的补丁就是真正的 git commit,享受完整历史、冲突解决、rerere 记忆,同时支持 quilt 格式导出导入。
456
463
  </details>
457
464
 
465
+ ## 为什么不用...
466
+
458
467
  <details>
459
- <summary><b>What if sync goes wrong?</b></summary>
468
+ <summary><b>...GitHub "Sync fork" 按钮?</b></summary>
460
469
  <br>
461
470
 
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.
471
+ 只能 fast-forward。你一有自己的改动,它要么拒绝要么生成 merge commit 把你的代码埋了。没有补丁栈,没有冲突记忆,没有 API。
463
472
  </details>
464
473
 
465
474
  <details>
466
- <summary><b>Does it work with GitHub / GitLab / Bitbucket?</b></summary>
475
+ <summary><b>...手动 <code>git rebase</code>?</b></summary>
467
476
  <br>
468
477
 
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.
478
+ 可以,6 步:fetch、切 tracking 分支、pull、切 patches 分支、rebasepush。得记住分支名、手动开 rerere、搞砸了自己从 reflog 里捞。`bingo-light sync` 一条命令包了,还带撤销、冲突预测和结构化输出。
470
479
  </details>
471
480
 
472
481
  <details>
473
- <summary><b>How is this different from <code>git format-patch</code> / quilt?</b></summary>
482
+ <summary><b>...StGit / quilt / TopGit?</b></summary>
474
483
  <br>
475
484
 
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.
485
+ StGit 管栈但没 AI 集成、没 MCP、没 JSON 输出、没冲突预测。quilt 脱离 git 体系,没 rerere 没历史。TopGit 基本废弃了。这些工具都不是为 AI 时代设计的。
477
486
  </details>
478
487
 
479
- ---
488
+ ## 与其他方案对比
480
489
 
481
- ## Project Ecosystem
490
+ | | **bingo-light** | GitHub Sync | git rebase | quilt | StGit |
491
+ |---|:---:|:---:|:---:|:---:|:---:|
492
+ | 命名补丁栈 | **有** | 无 | 无 | 有 | 有 |
493
+ | 一键同步 | **有** | 仅按钮 | 无(6 步) | 无 | 无 |
494
+ | 处理定制化改动 | **有** | **不行** | 手动 | 手动 | 手动 |
495
+ | 冲突记忆 (rerere) | **自动** | 无 | 需手动启用 | 无 | 无 |
496
+ | 冲突预测 | **有** | 无 | 无 | 无 | 无 |
497
+ | AI/MCP 集成 | **29 个工具** | 无 | 无 | 无 | 无 |
498
+ | JSON 输出 | **所有命令** | 无 | 无 | 无 | 无 |
499
+ | 非交互模式 | **原生支持** | 无 | 部分 | 部分 | 部分 |
500
+ | 撤销同步 | **一条命令** | 无 | git reflog | 手动 | 手动 |
501
+ | 安装方式 | 一条命令 | 内置 | 内置 | 包管理器 | 包管理器 |
502
+
503
+ ## 项目生态
482
504
 
483
505
  ```
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
506
+ bingo-light CLI 入口(Python 3,零依赖)
507
+ bingo_core/ 核心库包(全部业务逻辑)
508
+ mcp-server.py MCP 服务器(零依赖 Python 329 个工具)
509
+ contrib/agent.py Advisor 代理(监控 + 分析 + 安全时自动同步)
510
+ contrib/tui.py 终端面板(curses TUI
511
+ install.sh 安装器(--yes 支持 CI,--help 查看选项)
512
+ completions/ Shell 补全(bash/zsh/fish
513
+ contrib/hooks/ 通知 Hook 示例(Slack/Discord/Webhook
514
+ tests/ 测试套件(250 个测试,5 个文件)
515
+ docs/ 文档
495
516
  ```
496
517
 
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
518
+ ## 参与贡献
507
519
 
508
- Pure Python, zero dependencies, no build step. If you can read Python, you can contribute.
520
+ 欢迎 PR。纯 Python,零依赖,不用构建。
509
521
 
510
522
  ```bash
511
523
  git clone https://github.com/DanOps-1/bingo-light.git
512
524
  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
525
+ make test # 核心测试
526
+ make test-all # 全部 250 个测试
527
+ make lint # Python 语法 + flake8 + shellcheck
516
528
  ```
517
529
 
518
- See [CONTRIBUTING.md](CONTRIBUTING.md) for details.
530
+ 详见 [CONTRIBUTING.md](CONTRIBUTING.md)
519
531
 
520
- ## License
532
+ ## 许可证
521
533
 
522
- [MIT](LICENSE) -- do whatever you want.
534
+ [MIT](LICENSE)