Skip to content

feat(page-cluster)!: add landmark position + chrome reporting#926

Merged
YusukeHirao merged 1 commit into
devfrom
feat/page-cluster-landmark-positions
Jul 24, 2026
Merged

feat(page-cluster)!: add landmark position + chrome reporting#926
YusukeHirao merged 1 commit into
devfrom
feat/page-cluster-landmark-positions

Conversation

@YusukeHirao

Copy link
Copy Markdown
Member

Summary

  • extractLandmarks<main>/role="main" の抽出を追加し、header/footer/nav/aside/form/search/main の全インスタンスに HTML 内の位置(1-based line/column と文字列オフセット)を持たせた
  • resolvePageClusterKeys/resolvePageClusterKeysFromArray/resolvePageClusterKeysInMemoryincludeLandmarkPositions オプションを追加。true を渡すと clusterKey に加えて、そのページが属する最終クラスタの頻度分析(shellQuorum)に基づく chrome/content 判定(isChrome)付きのランドマーク位置レポートを返す
  • CLI に --include-landmark-positions フラグを追加。20,000 ページ超のストリーミング経路では非対応(RangeErrorで早期に失敗)
  • 破壊的変更: ExtractLandmarksResult の各ランドマークフィールドが string[](生HTML)から LandmarkInstance[]html + 位置情報)に変更。.header/.footer 等を文字列として読んでいた既存コードは .html を参照するよう変更が必要(本パッケージは他パッケージから依存されていないため、影響は page-cluster 内に閉じる。バージョンは 0.3.1 で SemVer 上マイグレーションガイドは不要)

Test plan

  • yarn build — リポジトリ全体でパス
  • yarn lint — エラー0(既存コードにあった警告2件はスコープ外、修正せず)
  • yarn test — リポジトリ全体 117 ファイル / 1660 件パス(page-cluster 単体 46 ファイル / 813 件)
  • 新規テスト: offset-to-line-column(改行境界・CRLF・インデックス再利用)、main の複数収集/ネスト除去/excise対象外/section-local navの非消失、shellQuorum(JSDoc記載のギャップケース含む)、isChromeLandmarkInstance(閾値境界)、buildPageLandmarkReportresolvePageClusterKeysInMemoryincludeLandmarkPositions(複数クラスタでのshell独立性を含む)、ストリーミング境界での RangeError、CLI 新フラグ

🤖 Generated with Claude Code

…fication

Add line/column position reporting for header/footer/nav/aside/form/
search/main landmark instances, with chrome-vs-content classification
for the six excisable types against each final cluster's shell tokens.

- extractLandmarks now also extracts <main>/role="main"
- resolvePageClusterKeys* accept includeLandmarkPositions to return
  PageClusterKeyResult[] (clusterKey + PageLandmarkReport) instead of
  string[]; not supported on the streaming path (over 20,000 pages)
- CLI gains --include-landmark-positions

BREAKING CHANGE: ExtractLandmarksResult's six landmark fields change
from string[] (raw HTML) to LandmarkInstance[] (html + position). A
new `main` field is added. Callers reading .header/.footer/etc. as
strings must switch to .html on each instance.
@YusukeHirao
YusukeHirao requested a review from yusasa16 as a code owner July 23, 2026 08:06
@YusukeHirao
YusukeHirao merged commit 8924648 into dev Jul 24, 2026
6 checks passed
@YusukeHirao
YusukeHirao deleted the feat/page-cluster-landmark-positions branch July 24, 2026 02:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant