bug2context

io.github.emanueld92由 GitHub 账号 emanueld92 发布v0.1.1更新于 Oct 27, 2026

Turn bug screen recordings into chronological context for AI agents: frames, OCR, logcat, voice.

概览

AI 生成的概览

把 Bug 录屏转换成按时间排列的 Markdown 报告,包含关键帧、屏幕文字、设备日志和语音旁白,供 AI 代理阅读。

可以做什么
  • 分析视频,生成带时间戳的关键帧、OCR 文字、logcat 日志与语音旁白的时序报告,并以文本返回
  • 按需取回某一帧图像,让助手直接查看画面
  • 列出此前处理过的结果包,最新的在前
  • 可选:同时录制 Android 设备屏幕与 logcat,或把已有日志文件合并进视频
适用场景
当 Bug 只体现在录屏里、希望助手据此分析时适用,例如崩溃复现、Android 日志加屏幕录制,或别人发来的视频。适合注重隐私、希望录像留在本机的本地调试场景。
运行要求
以本地进程方式运行(uvx 或源码检出),需要 ffmpeg 在 PATH 中。OCR 需安装 ocr 附加组件(macOS 用 Apple Vision,其他平台用 tesseract);语音转写为可选附加组件,首次使用会下载模型。Android 录制需要 adb 和已连接设备。无需账号、API 密钥或云服务。
安装前请注意
处理结果会写入 ~/.bug2context/,OCR 结果缓存在 ~/.cache/bug2context/,录像与提取的文字会留在磁盘上。Android 录制会采集设备日志,可能包含敏感应用数据。语音转写会下载模型。超过 10 分钟的视频默认被拒绝,除非显式覆盖。

安装

在 SourceWeft 中

  1. 打开 控制台中的 bug2context,将其添加到工作区。
  2. 为需要使用其工具的对话启用该服务。

Desktop only,通过 STDIO。 STDIO 服务会启动本地进程,因此需要 SourceWeft 桌面宿主。

其他 MCP 客户端

参照 仓库 中的启动说明。

README

bug2context

Turns a screen recording of a bug into structured, chronological context an AI agent can actually read.

Screenshots lose the story: bugs happen fast, a still frame has no timeline, and the logs and the narration live somewhere else entirely. LLMs don't take video. This distills a recording into one markdown chronology — key frames, the text on screen, device logs and spoken narration, all on the same clock.

  • No SDK. Works on any video, including one someone sent you over WhatsApp.
  • Local-first. Nothing leaves your machine. No account, no API key, no cloud.
  • MCP-native. Claude Code calls it as a tool; you just point at the file.
bash
uvx bug2context               # guided menuuvx bug2context process bug.mp4 --out bundle/

Running it with no arguments opens a menu — record an Android device, process a video you already have, or list previous bundles — and writes to ~/.bug2context/, which is where the MCP server looks. Everything it does is reachable through the flags below; it just stops you having to remember them.

What comes out

- `[00:00]` 🖼 `frames/frame_001_00-00.png` — start of recording      OCR: Cart 2 items- `[00:04]` 🖼 `frames/frame_002_00-04.png` — screen changed      OCR: Applying discount..- `[00:04]` 📋 W/DiscountEngine: rate field missing- `[00:06]` 🖼 `frames/frame_003_00-06.png` — screen changed      OCR: TypeError: cannot read 'rate'- `[00:06]` 📋 E/RideService: NullPointerException at RideRequest.kt:142- `[00:06]` 📋 F/AndroidRuntime: FATAL EXCEPTION: main- `[00:06]` 🎙 "ahí está, explota al aplicar el descuento"

A full run is in examples/report.md.

bundle/├── report.md    the chronology above├── frames/      the key frames, named by timestamp└── meta.json    the same data, structured, for programmatic use

Install

Requires ffmpeg on PATH (brew install ffmpeg).

bash
uvx --from 'bug2context[ocr]' bug2context          # OCR: Apple Vision on macOS, tesseract elsewhereuvx --from 'bug2context[ocr,audio]' bug2context    # plus spoken narration

Or from source:

bash
git clone https://github.com/emanueld92/bug2contextcd bug2contextuv sync --extra ocr --extra audio

Every stage is optional and degrades quietly: no OCR backend still gives you frames, no audio track still gives you the visual timeline.

Use it from Claude Code

bash
claude mcp add bug2context -- uvx --from 'bug2context[ocr]' bug2context-mcp

Working from a local clone instead: uvx --from /path/to/bug2context bug2context-mcp.

Then just ask: "analiza este video del bug: ~/Desktop/crash.mp4".

ToolPurpose
analyze_bug_videoVideo → chronological report (returns the text itself)
get_frameFetch one frame as an image so the agent can look at it
list_bundlesPreviously processed bundles, newest first

Bundles default to ~/.bug2context/<video>-<timestamp>/.

Android: screen + logcat in one command

bash
uv run bug2context record --seconds 60 --package com.example.app --out bundle/

Reproduce the bug while it records. Both streams start from a single host timestamp — that anchor is what makes a stack trace land next to the frame showing the crash.

Pass --package. Level filtering alone is not enough on a real phone: a 2 min capture held 7,634 W/E/F lines and none came from the app under test — they were all AppOpsControllerImpl, GNSSMGT and friends. Scoping to the app's process left 35. Crash tags (AndroidRuntime, DEBUG) are kept regardless of process, since a crash report is the whole point.

Logs are captured unfiltered and scoped afterwards, so an app that crashes and restarts still has its death recorded. Consecutive identical entries fold into one with a (×N) count — framework chatter arrives in bursts of fifteen.

Already have a log file? Merge it into any video:

bash
uv run bug2context process bug.mp4 --logcat logcat.txt --log-tag RideService

Reads both -v time and -v threadtime. --log-levels defaults to WEF and --log-max-lines to 80, ranked by severity so a cap never trades the crash for boot chatter. --log-pid scopes to a process when you already know it. If the device clock and the recorder disagree, --log-offset shifts everything by N seconds; with no --video-started-at, the first log entry becomes the anchor.

screenrecord caps at 3 minutes, so record refuses longer rather than handing back a silently truncated video. Ctrl-C cuts a recording short safely — the file is finalised on the device first, because killing the local adb leaves one ffprobe cannot open.

Videos over 10 minutes are refused with the ffmpeg command to trim them (--max-duration 0 overrides). Nothing scales badly with length except time, but it scales linearly: decoding alone runs at about a third of real time.

Narration

bash
uv run bug2context process bug.mp4 --transcribe --language es

Off by default: it downloads a model on first use and is the slowest stage, while most recordings have no voice-over. Skipped automatically when there is no audio track, or the track is quieter than −50 dB — whisper invents confident sentences out of silence, so that guard is about output quality, not just speed.

How frames get picked

ffmpeg over-produces candidates (scene cuts and a fixed interval, so slowly changing screens are not skipped), then perceptual hashing collapses the near-duplicates. --max-frames caps the result, always keeping the opening frame and then whichever changed most.

FlagDefaultNotes
--scene-threshold0.08ffmpeg scene score for a cut
--interval-seconds1.0forced sample when no cut fires
--max-framesautoone frame per 2 s, between 20 and 40
--phash-distance4below this, frames count as duplicates
--ocr-upscale2enlarge before OCR; skipped above 1600 px wide

Measured end to end, OCR on:

SourceResultTime
synthetic 3 min, 1080×192019 frames8.5 s
Android capture, 2 min, 720×1612 @ ~12 fps118 candidates → 20 frames16 s
macOS capture, 90 s, 2880×1864 @ 60 fps97 candidates → 18 frames86 s

Recognised text is cached by frame content in ~/.cache/bug2context/, so re-running a video with different settings only pays for what actually changed — measured 9.0 s cold against 3.3 s warm on a 44 s clip, identical output. Extracting the same video twice yields byte-identical frames, which is what makes the cache safe. Delete the directory to reset it.

Retina desktop recordings are the slow case and there is no trick to remove: the cost is decoding 60 fps at 5.4 megapixels (26 s) plus OCR, which Vision charges at ~1.6 s per frame regardless of size. Budget roughly real time for those; phone captures stay far under it.

On --ocr-upscale: a stack trace on a recompressed 1080×1920 frame read as Null PointerSxception Ride Requestkt14 at 1× and correctly as NullPointerException Ride Request kt 142 at 3×. Raise it for badly recompressed sources — ask for the video as a file, not as a WhatsApp video. It is skipped on frames already 1600 px or wider, where it changed nothing measurable while building a 5760×3728 image per frame.

OCR also drops lines that are debris rather than text — », .lll (100 4, a misread status-bar clock. On a real capture that removed 41 of 210 report lines and no real text. A line that looks like a failure is never dropped.

Known limitation

Perceptual hashing compares visual structure. It sees navigation, dialogs and error banners, but it cannot detect a small text-only change on an otherwise identical layout — measured on 1080×1920 those differences fall inside the noise floor at every hash size, so no --phash-distance value separates them.

OCR does not rescue this: it runs on frames that survive deduplication, so a screen already collapsed is never read. Reading every candidate instead measured 48–59 s for a 3 min video, over the entire time budget. If your bug is a small text change on an identical screen, record cropped or at lower resolution so the text occupies more of the frame.

Development

bash
uv sync --extra ocruv run pytest -q

183 tests. Device recording is mocked on purpose — a test suite should not record anyone's phone. Whisper is opt-in via BUG2CONTEXT_TEST_WHISPER=1 so the suite stays offline.

License

MIT — see LICENSE.

来源:README.md,提交 c938170

工具

0
SourceWeft 曾在隔离沙箱中以无凭据方式启动该软件包一次,以列出其工具,但未能完成:软件包安装失败。

版本历史

1
  1. v0.1.1最新Oct 21, 2026

评分

已满足适用检查项的 50%

该评分衡量此收录条目的完整程度,依据注册中心条目、端点与公开来源计算得出。它不是对服务器本身的评价,也不表示服务器安全或当前可用:可连通性是带日期的检查结果,评分也不包含安装量或用户评价。

  • 近 30 天内可连通25 分

    请保持端点能够响应 MCP 握手;SourceWeft 每 30 天探测一次。

  • 已声明认证方式10 分

    请在注册中心条目中声明凭据请求头,或保持端点能够响应探测,以便判定其认证方式。

  • 已列出工具15 分

    请让服务器在无凭据时响应 tools/list,或发布可在沙箱中无凭据启动的软件包。

  • 描述必需15 分
  • 图标10 分
  • 文档15 分
  • 许可证10 分