Bird watching mode (观鸟模式)
Purpose
- 1. On enable: Ask the user for 地点 (place name). Resolve eBird region with superpicky-cli
region-query, then write workspace/bird.json. - During use: Either identify a photo (BirdID via scripts) or record plain text (species name). Always append time + species (and optional fields) to
workspace/bird.json. - Summary / export: On request, run
export_csv.py to produce CSV (and optional per-species counts), then send the file or paste to the user (chat attachment, email, etc.).
$SKILL = directory containing this SKILL.md (usually ~/.myagent/skills/bird-watching-mode). Before invoking anything, resolve it to an absolute path (e.g. SKILL="$(cd ~/.myagent/skills/bird-watching-mode && pwd)").
Paths
- - Bird log file:
{project}/workspace/bird.json (create workspace/ if missing). - SuperPicky skill: default sibling
../superpicky-cli. Override with env SUPERPICKY_CLI_SKILL (absolute path to superpicky-cli skill root).
Absolute paths (required for invocation)
When calling these scripts from the agent or shell, all filesystem arguments must be absolute paths — do not rely on cwd or ~ inside subprocesses unless the shell expands them before the call.
| Argument | Rule |
|---|
| Python script path | Must be absolute, e.g. /Users/you/.myagent/skills/bird-watching-mode/scripts/set_region.py. |
--workspace |
Must be the
absolute project root (directory that will contain
workspace/bird.json). |
|
Image path (
identify_photo.py positional,
--image on
append_sighting.py) | Must be
absolute path to the file on disk. |
|
--output / --summary-output (
export_csv.py) | If not
-, use an
absolute path for the CSV file (avoids ambiguity vs cwd). |
Relative paths inside stored JSON (e.g. past image_path values) are legacy data only; new invocations should still use absolute paths.
Scripts (run from any cwd)
| Script | Role |
|---|
scripts/set_region.py | After user gives a place: call region-query --json, pick match, merge into bird.json (region, location_query, country_code). |
scripts/append_sighting.py |
Append one observation:
--species, optional
--notes,
--source text\|photo,
--image,
--time (ISO UTC). |
|
scripts/identify_photo.py | Run BirdID
identify using
-c/
-r from
bird.json; print CLI stdout (agent reads top species); optional
--append to log raw output + image path. |
|
scripts/export_csv.py | Export all observations to CSV; optional
--summary for per-species counts. Deliver CSV to the user (file path or
- stdout for inline paste). |
CODEBLOCK0
Agent workflow
A. User turns on 观鸟模式
- 1. Ask: Where are you birding? (地点 — city, province, park, etc.)
- Run
set_region.py using absolute paths for the script and --workspace. If exit code 3, several matches were printed — ask the user which code (or re-run with --pick N). - Confirm
workspace/bird.json exists and contains region.code (and country_code).
B. User sends a photo
- 1. Ensure SuperPicky is installed (see Prerequisites below).
- Run
identify_photo.py with absolute script path, absolute --workspace, and absolute image file path. - Read stdout; treat top BirdID lines as primary candidates. Confirm species with the user if uncertain.
- Run
append_sighting.py with absolute script path and --workspace, final --species, --source photo, and absolute --image path.
Prerequisites: SuperPicky venv under $SUPERPICKY_CLI_SKILL (default sibling superpicky-cli). If missing: $SUPERPICKY_CLI_SKILL/scripts/install.sh (see superpicky-cli skill).
C. User sends text (species / field note)
- 1. Parse species (and optional notes) from the message.
- Run
append_sighting.py with absolute script path, absolute --workspace, and --source text.
D. User asks for 汇总 / 导出 / CSV
- 1. Run
export_csv.py with absolute script path and absolute --workspace (add --summary if they want counts by species; use absolute paths for --output / --summary-output when writing files). - Read the path(s) printed on stderr; attach the CSV file(s) in the channel or paste
--output - stdout if the UI supports it. - Optional
--excel: UTF-8 BOM for Excel on Windows.
bird.json shape (summary)
- -
location_query: user’s place string. region: { code, name, name_cn, kind, parent, match_score } from region-query JSON (first line unless --pick).country_code: eBird country (CN, …) — region’s parent if subnational, else region.code.observations[]: { time_utc, species, notes, source, image_path?, birdid_stdout? }.
For full fields, run append_sighting.py --help or read scripts/bird_log_schema.md.
Tests
From $SKILL/scripts/:
CODEBLOCK1
Related
技能名称: bird-watching-mode
详细描述:
观鸟模式
目的
- 1. 启用时: 向用户询问地点(地名)。使用superpicky-cli的region-query解析eBird区域,然后写入workspace/bird.json。
- 使用中: 要么识别照片(通过脚本进行BirdID),要么记录纯文本(物种名称)。始终将时间 + 物种(以及可选字段)追加到workspace/bird.json。
- 汇总/导出: 应要求运行export_csv.py生成CSV(以及可选的按物种计数),然后发送文件或粘贴给用户(聊天附件、电子邮件等)。
$SKILL = 包含此SKILL.md的目录(通常为~/.myagent/skills/bird-watching-mode)。在调用任何内容之前,将其解析为绝对路径(例如SKILL=$(cd ~/.myagent/skills/bird-watching-mode && pwd))。
路径
- - 鸟类记录文件: {project}/workspace/bird.json(如果缺少则创建workspace/目录)。
- SuperPicky技能: 默认同级目录../superpicky-cli。可通过环境变量SUPERPICKYCLISKILL覆盖(指向superpicky-cli技能根目录的绝对路径)。
绝对路径(调用时必须使用)
从代理或shell调用这些脚本时,所有文件系统参数必须是绝对路径——不要依赖cwd或子进程中的~,除非shell在调用前已展开它们。
| 参数 | 规则 |
|---|
| Python脚本路径 | 必须是绝对路径,例如/Users/you/.myagent/skills/bird-watching-mode/scripts/set_region.py。 |
| --workspace |
必须是
绝对的项目根目录(将包含workspace/bird.json的目录)。 |
|
图片路径(identify
photo.py的位置参数,appendsighting.py的
--image) | 必须是磁盘上文件的
绝对路径。 |
|
--output / --summary-output(export_csv.py) | 如果不是-,则使用CSV文件的
绝对路径(避免与cwd的歧义)。 |
存储在JSON中的相对路径(例如过去的image_path值)仅为遗留数据;新的调用仍应使用绝对路径。
脚本(可从任何cwd运行)
| 脚本 | 作用 |
|---|
| scripts/setregion.py | 用户提供地点后:调用region-query --json,选择匹配项,合并到bird.json中(region、locationquery、countrycode)。 |
| scripts/appendsighting.py |
追加一条观测记录:--species,可选--notes、--source text\|photo、--image、--time(ISO UTC)。 |
|
scripts/identify_photo.py | 使用bird.json中的-c/-r运行BirdID identify;打印CLI标准输出(代理读取顶部物种);可选--append记录原始输出和图片路径。 |
|
scripts/export_csv.py | 将所有观测记录导出为CSV;可选
--summary用于按物种计数。将CSV交付给用户(文件路径或-标准输出用于内联粘贴)。 |
bash
$SKILL和PROJECT必须已经是绝对路径(示例值):
SKILL=/Users/you/.myagent/skills/bird-watching-mode
PROJECT=/Users/you/Workspace/myproject
PHOTO=/Users/you/.myagent/workspace/media/abc123.jpg
解析区域(代理:如果打印多行,请用户确认)
python3 ${SKILL}/scripts/set_region.py --workspace ${PROJECT} --location 上海
手动/AI确认的文本记录
python3 ${SKILL}/scripts/append_sighting.py --workspace ${PROJECT} \
--species Eurasian Tree Sparrow --source text --notes flock of 5
照片:运行BirdID(需要安装superpicky和模型)
python3 ${SKILL}/scripts/identify_photo.py --workspace ${PROJECT} ${PHOTO}
可选:追加一条物种留空以供稍后编辑的观测记录,或使用--append-species 拉丁名
python3 ${SKILL}/scripts/identify_photo.py --workspace ${PROJECT} --append ${PHOTO}
导出CSV(默认:PROJECT下的workspace/birdsightingsexport.csv);路径打印到stderr
python3 ${SKILL}/scripts/export_csv.py --workspace ${PROJECT}
python3 ${SKILL}/scripts/export_csv.py --workspace ${PROJECT} --summary
python3 ${SKILL}/scripts/export_csv.py --workspace ${PROJECT} --output - # 仅用于粘贴的标准输出;不生成第二个文件
代理工作流程
A. 用户开启观鸟模式
- 1. 询问:你在哪里观鸟?(地点 — 城市、省份、公园等)
- 使用脚本和--workspace的绝对路径运行setregion.py。如果退出码为3,则打印了多个匹配项 — 询问用户选择哪个代码(或使用--pick N重新运行)。
- 确认workspace/bird.json存在并包含region.code(和countrycode)。
B. 用户发送照片
- 1. 确保已安装SuperPicky(参见下面的前提条件)。
- 使用绝对脚本路径、绝对的--workspace和绝对的图片文件路径运行identifyphoto.py。
- 读取标准输出;将顶部的BirdID行视为主要候选。如果不确定,与用户确认物种。
- 使用绝对脚本路径和--workspace、最终的--species、--source photo以及绝对的--image路径运行appendsighting.py。
前提条件: SuperPicky虚拟环境位于$SUPERPICKYCLISKILL下(默认同级目录superpicky-cli)。如果缺少:$SUPERPICKYCLISKILL/scripts/install.sh(参见superpicky-cli技能)。
C. 用户发送文本(物种/野外笔记)
- 1. 从消息中解析物种(以及可选的笔记)。
- 使用绝对脚本路径、绝对的--workspace和--source text运行append_sighting.py。
D. 用户要求汇总 / 导出 / CSV
- 1. 使用绝对脚本路径和绝对的--workspace运行export_csv.py(如果他们想要按物种计数,则添加--summary;写入文件时使用绝对路径作为--output / --summary-output)。
- 读取打印在stderr上的路径;在频道中附加CSV文件,或者如果UI支持,粘贴--output -的标准输出。
- 可选--excel:为Windows上的Excel添加UTF-8 BOM。
bird.json结构(摘要)
- - locationquery:用户的地点字符串。
- region:{ code, name, namecn, kind, parent, matchscore },来自region-query JSON(除非使用--pick,否则为第一行)。
- countrycode:eBird国家代码(CN等)— 如果是次国家级区域则为区域的parent,否则为region.code。
- observations[]:{ timeutc, species, notes, source, imagepath?, birdid_stdout? }。
完整字段请运行appendsighting.py --help或阅读scripts/birdlog_schema.md。
测试
从$SKILL/scripts/目录:
bash
./run_tests.sh
或:python3 birdjsonutiltest.py && python3 setregion_test.py && …
相关