HK Route — Hong Kong Transit Routing with Real-Time ETAs
What this skill does
Finds the best public transport route in Hong Kong by combining Google Maps directions with real-time bus ETAs. Routes are ranked by effective total time (real-time wait + travel duration), not just schedule data.
Required environment
| Requirement | Details |
|---|
| INLINECODE0 | Google Maps API key with Directions API enabled |
| INLINECODE1 >= 18 |
Runtime for the bundled script |
External endpoints
This skill makes network requests to:
| Endpoint | Purpose | Credentials |
|---|
| INLINECODE2 (Google Directions API) | Transit route planning | INLINECODE3 |
| HK government & operator APIs via hk-bus-eta (DATA.GOV.HK, KMB, CTB, etc.) |
Real-time bus arrival times | None (public APIs) |
No other network calls are made. The ETA database is cached locally at ~/.cache/hk-route/etaDb.json (refreshed every 24h).
Source code
The bundled scripts/hk-route.cjs is built from readable TypeScript source at github.com/7ito/hkroute. Build command: esbuild src/index.ts --bundle --platform=node --format=cjs.
How to invoke
CODEBLOCK0
The scripts/hk-route.cjs bundle is self-contained — no npm install needed. Just node >= 18.
Optional flags
- -
--departure-time "<ISO 8601 datetime>" — plan a future trip (e.g., --departure-time "2026-03-26T08:00:00+08:00")
Input formats
- - Coordinates:
"22.2822,114.1875" (lat,lng — no space after comma) - Place name:
"Causeway Bay", "Hong Kong Airport", INLINECODE15 - Both origin and destination accept either format.
Conversational flows
One-shot (user provides both locations)
User: "How do I get from Causeway Bay to Stanley?"
→ Run the CLI with --origin "Causeway Bay" --destination "Stanley", format the output.
Multi-turn (e.g., WhatsApp via OpenClaw)
- 1. User sends INLINECODE17
- Ask: "Where are you now? Send a location pin or type your location."
- User sends a coordinate pin (e.g.,
22.2822,114.1875) or text (e.g., "Tin Hau MTR") - Ask: "Where do you want to go?"
- User sends destination as text or coordinates.
- Run the CLI, format the output.
If the user provides invalid input at any step, ask them to try again with a valid location.
Implicit activation
Activate this skill when the user asks about getting somewhere in Hong Kong by public transport, even without using /hkroute. Look for intent like "how do I get to...", "best way to...", "bus from...", etc., in a Hong Kong context.
Output format
The CLI outputs JSON to stdout. Format it for the user as follows:
WhatsApp / messaging format template
CODEBLOCK1
Formatting rules
- - Recommended route: Mark with ⭐ and "(Recommended)"
- Actionable leg: The leg with
actionable: true is the one that determines when the user needs to leave. Call it out prominently: "Next bus in X min — leave now!" or "Next bus in X min — you have time." - ETAs: Format as relative time ("in 3 min", "in 12 min"). Show up to 2 ETAs per bus leg.
- Walking legs: Always show with duration. Use 🚶 emoji.
- Transport emojis: 🚌 bus, 🚇 MTR/subway, ⛴️ ferry, 🚊 light rail/tram, 🚶 walk
- Bold: Use bold for ETAs, route numbers, and the recommended route label.
- Unavailable ETAs: If
eta_source is "unavailable", show "ETA unavailable (scheduled: {departure_time})" instead of a real-time ETA. - Schedule-only: If
eta_source is "schedule", show the scheduled departure time without a real-time label.
Error handling
If the CLI returns error: true:
- -
NO_TRANSIT_ROUTES: Tell the user no transit routes were found. Suggest trying a different departure time or considering a taxi. - INLINECODE27 : Tell the user there was an issue fetching routes. Suggest trying again.
- INLINECODE28 : Tell the user what was wrong with their input.
HK Route — 香港交通路线规划与实时到站时间
技能功能
结合Google Maps路线规划与香港巴士实时到站时间,找出最佳公共交通路线。路线按有效总时间(实时等待时间+行程时长)排序,而非仅依据时刻表数据。
运行环境要求
| 要求 | 说明 |
|---|
| GOOGLEMAPSAPI_KEY | 已启用Directions API的Google Maps API密钥 |
| node >= 18 |
运行打包脚本的运行时环境 |
外部接口
本技能会向以下端点发起网络请求:
| 端点 | 用途 | 凭证 |
|---|
| maps.googleapis.com(Google Directions API) | 公交路线规划 | GOOGLEMAPSAPIKEY |
| 通过hk-bus-eta接入的香港政府及运营商API(DATA.GOV.HK、KMB、CTB等) |
实时巴士到站时间 | 无(公共API) |
不发起其他网络调用。ETA数据库本地缓存于~/.cache/hk-route/etaDb.json(每24小时刷新一次)。
源代码
打包后的scripts/hk-route.cjs由可读的TypeScript源代码构建,源码位于github.com/7ito/hkroute。构建命令:esbuild src/index.ts --bundle --platform=node --format=cjs。
调用方式
bash
node /path/to/skill/scripts/hk-route.cjs \
--origin <起点> \
--destination <终点>
scripts/hk-route.cjs打包文件为独立文件——无需npm install。仅需node >= 18。
可选参数
- - --departure-time — 规划未来行程(例如:--departure-time 2026-03-26T08:00:00+08:00)
输入格式
- - 坐标:22.2822,114.1875(纬度,经度——逗号后无空格)
- 地名:铜锣湾、香港机场、赤柱市场
- 起点和终点均可接受任一格式。
对话流程
一次性对话(用户提供两个地点)
用户:从铜锣湾到赤柱怎么走?
→ 使用--origin 铜锣湾 --destination 赤柱运行CLI,格式化输出结果。
多轮对话(例如通过OpenClaw的WhatsApp)
- 1. 用户发送/hkroute
- 询问:你现在在哪里?请发送位置标记或输入你的位置。
- 用户发送坐标标记(例如22.2822,114.1875)或文本(例如天后地铁站)
- 询问:你想去哪里?
- 用户以文本或坐标形式发送目的地。
- 运行CLI,格式化输出结果。
如果用户在任一环节提供无效输入,请要求他们重新输入有效位置。
隐式激活
当用户询问香港公共交通出行方式时,即使未使用/hkroute,也应激活此技能。识别类似怎么去...、最佳方式...、从...坐巴士...等意图,且上下文为香港。
输出格式
CLI以JSON格式输出到标准输出。按以下格式呈现给用户:
WhatsApp/消息格式模板
🚌 从{起点}到{终点}的路线
⭐ 路线1(推荐) — {有效总时间}分钟
{每段行程:}
🚶 步行{时长秒数/60}分钟 — {指引说明}
🚌 巴士{路线编号}从{上车车站} — 下一班车:{etas[0]格式化为相对时间}(然后{etas[1]})
{站数}站 → {下车车站}
🚇 地铁{路线编号}从{上车车站}
{站数}站 → {下车车站}
⛴️ 渡轮 ...
🚊 轻铁/电车 ...
📍 路线2 — {有效总时间}分钟
{相同行程格式}
📍 路线3 — {有效总时间}分钟
{相同行程格式}
格式化规则
- - 推荐路线:用⭐和(推荐)标记
- 可操作行程:标记为actionable: true的行程决定用户何时需要出发。突出显示:下一班车X分钟后到——现在出发!或下一班车X分钟后到——时间还来得及。
- ETA:格式化为相对时间(3分钟后、12分钟后)。每条巴士行程最多显示2个ETA。
- 步行段:始终显示时长。使用🚶表情符号。
- 交通表情符号:🚌巴士、🚇地铁、⛴️渡轮、🚊轻铁/电车、🚶步行
- 加粗:对ETA、路线编号和推荐路线标签使用加粗。
- ETA不可用:如果etasource为unavailable,显示ETA不可用(时刻表:{出发时间})而非实时ETA。
- 仅时刻表:如果etasource为schedule,显示计划出发时间,不加实时标签。
错误处理
如果CLI返回error: true:
- - NOTRANSITROUTES:告知用户未找到公交路线。建议尝试不同出发时间或考虑打车。
- GOOGLEAPIERROR:告知用户获取路线时出现问题。建议重试。
- INVALID_INPUT:告知用户输入内容的问题所在。