nib

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Nib — Visual Feedback

Nib — 视觉反馈

You have eyes. Use them. Any time something visual is relevant, capture the screen and look.
你有“眼睛”,请善用它们。任何与视觉相关的场景,都可以截取屏幕并查看。

When to Use This

使用场景

Use nib aggressively. If any of these apply, capture and look:
  • You just made a UI change → capture and verify it looks right
  • You're debugging something visual → capture and inspect
  • You need to know where something is on screen → capture and find it
  • You're unsure about layout, spacing, colors, alignment → capture and check
  • The user mentions anything visual → capture immediately
  • You want to show the user what you did → capture and annotate
  • You're about to ask "does this look right?" → capture instead of asking
  • You need coordinates for clicking or positioning → capture and use grid
Don't ask what to capture. Don't ask permission. Just capture and look.
请积极使用nib工具。 只要符合以下任一情况,就截取屏幕并查看:
  • 你刚完成UI变更 → 截取屏幕并验证显示是否正常
  • 你正在调试视觉问题 → 截取屏幕并检查细节
  • 你需要知道某个元素在屏幕上的位置 → 截取屏幕并定位
  • 你对布局、间距、颜色、对齐方式有疑问 → 截取屏幕并确认
  • 用户提到任何视觉相关内容 → 立即截取屏幕
  • 你想向用户展示你的工作成果 → 截取屏幕并添加注释
  • 你正要问“这个看起来对吗?” → 直接截取屏幕而非提问
  • 你需要点击或定位的坐标 → 截取屏幕并使用网格工具
不要询问用户要截取什么,也不要请求许可。直接截取并查看即可。

The Loop

操作流程

1. Find the right window → nib windows --json
2. Capture it → nib capture --app "AppName" -o /tmp/nib_shot.png
3. Look at the screenshot (read the file)
4. Decide what you need feedback on
5. nib feedback /tmp/nib_shot.png -a '[annotations]' -m "question"
6. Parse the human's response
7. Act on it
1. 找到目标窗口 → nib windows --json
2. 截取屏幕 → nib capture --app "AppName" -o /tmp/nib_shot.png
3. 查看截图(读取文件)
4. 确定需要反馈的内容
5. nib feedback /tmp/nib_shot.png -a '[annotations]' -m "question"
6. 解析人类的回复
7. 根据反馈行动

Step 1: Find the Right Window

步骤1:找到目标窗口

Don't just screenshot everything. Find the window you actually care about:
bash
undefined
不要盲目截取所有内容。找到你真正关注的窗口:
bash
undefined

List all windows with metadata

列出所有带元数据的窗口

nib windows --json
nib windows --json

Filter by app name

按应用名称过滤

nib windows --app "Safari" --json

Output gives you app name, title, size, position, and focus state for every window.
nib windows --app "Safari" --json

输出结果会显示每个窗口的应用名称、标题、尺寸、位置和焦点状态。

Step 2: Capture the Right Thing

步骤2:截取目标内容

bash
undefined
bash
undefined

Capture a specific app's window

截取指定应用的窗口

nib capture --app "Safari" -o /tmp/nib_shot.png
nib capture --app "Safari" -o /tmp/nib_shot.png

Capture by window title

按窗口标题截取

nib capture --title "index.html" -o /tmp/nib_shot.png
nib capture --title "index.html" -o /tmp/nib_shot.png

Capture the focused window

截取当前焦点窗口

nib capture --mode window -o /tmp/nib_shot.png
nib capture --mode window -o /tmp/nib_shot.png

Capture full screen (fallback)

截取全屏(备选方案)

nib capture -o /tmp/nib_shot.png

**Always prefer `--app` or `--title` over full screen.** You get just the window you need, no distractions.
nib capture -o /tmp/nib_shot.png

**优先使用`--app`或`--title`参数,而非全屏截取。** 这样你只会获取需要的窗口,避免无关内容干扰。

Step 3: Look

步骤3:查看截图

Read the screenshot file to see what's on screen. Use grid or OCR if you need precision:
bash
undefined
读取截图文件查看屏幕内容。如果需要精准定位,可使用网格或OCR工具:
bash
undefined

Coordinate grid for positioning

用于定位的坐标网格

nib grid /tmp/nib_shot.png --spacing 100 -o /tmp/nib_grid.png
nib grid /tmp/nib_shot.png --spacing 100 -o /tmp/nib_grid.png

Find text via OCR

通过OCR查找文本

nib find-text /tmp/nib_shot.png -s "Submit"
undefined
nib find-text /tmp/nib_shot.png -s "Submit"
undefined

Step 3: Annotate and Ask

步骤3:添加注释并提问

Point at the things you want feedback on. Be specific.
bash
nib feedback /tmp/nib_shot.png \
  -a '[{"type":"arrow","from":[300,200],"to":[450,350]},{"type":"text","at":[300,180],"content":"This spacing looks off?"}]' \
  -m "Does the spacing between these elements look right?"
指向你需要反馈的内容,要具体明确。
bash
nib feedback /tmp/nib_shot.png \
  -a '[{"type":"arrow","from":[300,200],"to":[450,350]},{"type":"text","at":[300,180],"content":"This spacing looks off?"}]' \
  -m "Does the spacing between these elements look right?"

Step 4: Parse Response

步骤4:解析回复

Human draws annotations and hits Cmd+Enter. You get back only their annotations:
json
{"annotations": [{"id": "a1", "type": "arrow", "at": [150, 200, 300, 100], "owner": "human"}]}
Timeout returns
{"event": "timeout"}
(exit code 0, not an error).
人类添加注释后按下Cmd+Enter,你只会收到他们的注释内容:
json
{"annotations": [{"id": "a1", "type": "arrow", "at": [150, 200, 300, 100], "owner": "human"}]}
超时会返回
{"event": "timeout"}
(退出码0,不属于错误)。

Step 5: Act

步骤5:采取行动

Use the human's visual feedback to take action. Then capture again to verify.
根据人类的视觉反馈执行操作,然后再次截取屏幕验证结果。

Annotation Format

注释格式

json
[
  {"type": "arrow", "from": [x, y], "to": [x, y]},
  {"type": "rectangle", "at": [x, y], "size": [w, h]},
  {"type": "text", "at": [x, y], "content": "Label"},
  {"type": "highlight", "at": [x, y], "size": [w, h], "color": "#ffff0080"},
  {"type": "number", "at": [x, y], "value": 1},
  {"type": "ellipse", "center": [x, y], "radius": [rx, ry]},
  {"type": "line", "from": [x, y], "to": [x, y]},
  {"type": "blur", "at": [x, y], "size": [w, h]}
]
All types accept optional
"color"
(hex). Use blue
#3b82f6
for your annotations.
json
[
  {"type": "arrow", "from": [x, y], "to": [x, y]},
  {"type": "rectangle", "at": [x, y], "size": [w, h]},
  {"type": "text", "at": [x, y], "content": "Label"},
  {"type": "highlight", "at": [x, y], "size": [w, h], "color": "#ffff0080"},
  {"type": "number", "at": [x, y], "value": 1},
  {"type": "ellipse", "center": [x, y], "radius": [rx, ry]},
  {"type": "line", "from": [x, y], "to": [x, y]},
  {"type": "blur", "at": [x, y], "size": [w, h]}
]
所有类型都支持可选的
"color"
参数(十六进制格式)。你的注释请使用蓝色
#3b82f6

Headless Mode

无头模式

When you don't need human feedback, just annotate and render:
bash
nib annotation add image.png -t rectangle -x 100 -y 100 -w 200 -H 50 -c "#ff0000"
nib render image.png  # → image.rendered.png
当你不需要人类反馈时,只需添加注释并渲染即可:
bash
nib annotation add image.png -t rectangle -x 100 -y 100 -w 200 -H 50 -c "#ff0000"
nib render image.png  # → image.rendered.png

Key Flags

关键参数

CommandFlagPurpose
capture
--app
Capture specific app's window
capture
--title
Capture window by title substring
capture
--mode window
Capture focused window
windows
--app
Filter window list by app name
windows
--json
Machine-readable window list
feedback
-a
JSON annotations array
feedback
-m
Message/question as toast
feedback
-t
Timeout in seconds (default 60)
find-text
-s
Search string
find-text
--highlight --color
Auto-highlight matches (NOT
-c
)
grid
--spacing
Grid cell size in pixels
grid
--region
Zoom to region (x1,y1,x2,y2)
See full command reference for all commands and options.
命令参数用途
capture
--app
截取指定应用的窗口
capture
--title
通过标题子串截取窗口
capture
--mode window
截取当前焦点窗口
windows
--app
按应用名称过滤窗口列表
windows
--json
输出机器可读的窗口列表
feedback
-a
JSON格式的注释数组
feedback
-m
作为提示消息的问题/内容
feedback
-t
超时时间(秒,默认60)
find-text
-s
搜索字符串
find-text
--highlight --color
自动高亮匹配结果(注意:不是
-c
grid
--spacing
网格单元格尺寸(像素)
grid
--region
放大指定区域(x1,y1,x2,y2)
查看完整命令参考获取所有命令和选项。