Repository navigation
feat: holiday typhoon — 颱風假查詢(即時頁 + 歸檔),v2.1.0 - #8
Conversation
Query whether work/school stopped on a given day (2001-07-30 onward), using lis186/TaiwanTyphoonDays. The top level gives a verdict (stopped / conditional / normal / unknown) with its basis (own announcement, previous day's forecast, or none) and whether it is settled, so scripts and LLMs do not have to interpret raw rows. - Pure evaluateTyphoon() plus a fetching TyphoonService, exported from the library. - Pick the day's own announcement before filtering rows, so an overridden forecast never revives. - No record within 21 days, or a missing current-year file, is `unknown`, never `normal`. - Read raw.githubusercontent (forced JSON: it serves text/plain), falling back to jsDelivr on network errors. - "today" now uses Asia/Taipei for all commands; on UTC hosts it was a day behind between 00:00 and 08:00 Taiwan time. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
`holiday typhoon` now reads https://www.dgpa.gov.tw/typh/daily/nds.html for today and tomorrow (Taiwan time); other dates still use the archive. Live results carry `reason: "live"` and `source.kind: "live"`. If the live page cannot be fetched or its format is not recognised, fall back to the archive result with a note instead of failing. - typhoon-live-parser.ts ports upstream parse.py (parse_page down) 1:1, keeping its strict grammar. - evaluateLive() maps page states: 無停班停課訊息 -> normal; city listed but only skipped sentences -> unknown; city not listed -> normal (no announcement yet); no rows for tomorrow -> unknown; no rows and no notice -> format error. - Contract tests: upstream page fixtures (pinned at 3b635f8) run in CI; a corpus test over every upstream sentence runs when TYPHOON_DATA_DIR is set. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: ed773943dc
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| } else if (isToday && r.cities.length === 0) { | ||
| const listed = r.city ? page.cities.includes(r.city) : page.cities.length > 0; |
There was a problem hiding this comment.
Include listed-but-unannounced cities in nationwide verdicts
When the live page contains both a parsed normal city and a city whose only text is 尚未宣布消息。, the nationwide query returns normal for both work and school, even though querying the latter city correctly returns unknown. parseCell omits the pending city's rows, so evaluateTyphoon aggregates only the normal city, and this correction is skipped because r.cities.length is nonzero. Check listed cities without applicable rows when computing the nationwide verdict so an unresolved city cannot become a nationwide all-clear.
Useful? React with 👍 / 👎.
| for (const area of rows) { | ||
| table.push([formatDateString(result.date), areaName(area), areaStatus(area)]); | ||
| } | ||
| } | ||
| return table.toString(); |
There was a problem hiding this comment.
Preserve provisional-status warnings in table output
For -f table, any result containing rows displays only the individual area statuses and returns before rendering the source or notes; unlike the empty-row case, it also omits finalityLabel. Consequently, tomorrow's live forecast and a recent archived forecast appear simply as 停止上班、停止上課, with no indication that they are provisional or may have been superseded. A live-fetch failure's archive-fallback warning is likewise lost. Include the result's finality and relevant notes alongside the table so changing output format does not hide qualifications needed to interpret the answer.
Useful? React with 👍 / 👎.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
摘要
新增
holiday typhoon [date] [-c, --city <city>],回答「某天某縣市要不要上班、上課」。reason: "live";抓不到或格式不認得時退回歸檔並註明。work/school的status∈stopped/conditional/normal/unknown,附basis(當日公告/前一日預告/無公告)與reason(為何還可能改變)。寧可回unknown,也不把「沒資料」說成「照常」。evaluateTyphoon、evaluateLive(純函式)與TyphoonService,供 taiwan-holiday-mcp 使用。行為變更(影響所有命令)
「今天」改以臺灣時間(Asia/Taipei)計算。過去在 UTC 主機(CI、雲端、透過 npx 呼叫的 LLM 工具)上,臺灣早上 0–8 點的
today/tomorrow/next會差一天。設計
API 形狀與驗證方法經 Fable、Astra 兩輪對抗評審後收斂(詳見 PRD 2.2.16)。過程中修掉的問題:
text/plain,未強制 JSON 時會拿到字串,大檔當掉、小檔靜默答「照常」(只有端對端測試抓得到)。驗證
TZ=UTC皆全過;typecheck、lint(無新警告)、build 通過。parse.py):3b635f8),逐欄一致,CI 會跑。data/全量 7,793 筆記錄、1,689 種句子逐欄一致;突變測試確認不是空轉。已知限制/後續
unknown。tests/corpus/)需設定TYPHOON_DATA_DIR,CI 不會跑;之後可在upstream-canaryworkflow 拉上游 repo 執行。--area尚未實作。dateToNormalized)在非 UTC+ 時區(如洛杉磯)會失敗,是測試寫法依賴時區,與本 PR 無關。🤖 Generated with Claude Code