webspec索引
从命令行查询WHATWG、W3C和TC39 web规范。
特性
- 全文搜索 跨HTML、DOM、URL、CSS、ECMAScript和70多种其他规范
- 交叉引用跟踪 --请参阅规范章节之间的传入/传出引用
- 图的遍历 --使用JSON、Mermaid或Graphviz DOT输出构建交叉引用图
- WHATWG公关预览 --查询由开放PR修改的规范部分,具有部分级别差异
- 白名单域的自动URL索引 --按URL查询非硬编码规范
- 快速SQLite索引 FTS5用于即时查询
- 算法与IDL提取 带有渲染的markdown内容
- LSP服务器 用于编辑器中的内联规范悬停和步骤验证
- LLM友好
--helpoutput——在Claude Code、Codex、Gemini CLI或OpenCode中运行时自动检测
安装
cargo binstall webspec-index或者从源代码构建:
cargo install webspec-index快速开始
# Look up a spec section (algorithm, definition, heading, IDL)
webspec-index query "HTML#navigate"
webspec-index query "https://html.spec.whatwg.org/#navigate"
webspec-index query "https://w3c.github.io/webappsec-permissions-policy/#permissions-policy-header"
webspec-index query "DOM#concept-tree" --format markdown
# Full-text search
webspec-index search "tree order" --spec DOM
# Check if an anchor exists (exit code 0 = found, 1 = not found)
webspec-index exists "HTML#navigate"
# Find anchors by glob pattern
webspec-index anchors "*-tree" --spec DOM
# List all headings in a spec
webspec-index list HTML
# Cross-references (exact or shorthand)
webspec-index refs "HTML#navigate" --direction incoming
webspec-index refs "Window.navigation" --limit 5
# Graph traversal
webspec-index graph "HTML#navigate" --max-depth 2 --graph-format mermaid
webspec-index graph "HTML#navigate" --graph-format dot
webspec-index graph "HTML#navigate" --same-spec-only
webspec-index graph "HTML#navigate" --include "*concept-*" --exclude "re:^URL#"
# Query dedicated WebIDL definitions
webspec-index idl "HTML#dom-window-navigation"
webspec-index idl "Window.navigation"
webspec-index idl "Window.open()" --spec HTML
# Update specs to latest versions
webspec-index updateWHATWG公关预览
查询规范部分,因为它们将在WHATWG PR合并后显示。预览是懒洋洋地从 whatpr.org 并在本地缓存。
# Query a section from a PR preview (falls back to merge base for unchanged sections)
webspec-index query "HTML#navigate" --pr 12345
webspec-index query "HTML#navigate" --pr 12345 --format markdown
# Diff: see what sections the PR adds or modifies vs the merge base
webspec-index query "HTML#navigate" --pr 12345 --diff --format markdown
# Force re-fetch (e.g. after the PR is updated)
webspec-index query "HTML#navigate" --pr 12345 --force-update
# Other commands also support --pr
webspec-index exists "HTML#navigate" --pr 12345
webspec-index list HTML --pr 12345
webspec-index refs "HTML#navigate" --pr 12345
webspec-index search "OpaqueRange" --spec HTML --pr 12345
webspec-index anchors "*opaquerange*" --spec HTML --pr 12345
# Manage cached PR data (each PR caches rendered pages + merge base)
webspec-index clear-pr # list cached PRs
webspec-index clear-pr --spec HTML --pr 12345 # remove one
webspec-index clear-pr --all # remove all所有命令支持 --format json (默认)或 --format markdown.
规范数据在第一次查询时在本地获取和缓存,无需设置。
规格刷新是基于新鲜度的:一旦检查,规格在24小时内被视为新鲜。 刷新时,CLI仅在内容更改时获取实时HTML并重新索引。
AI代理集成
技能档案
掉落 技能.md 在您的仓库中,教代理如何使用CLI。
编辑器集成
这 韦伯斯特镜头 扩展提供内联规范悬停、步骤验证和覆盖率跟踪。适用于VS Code和任何兼容LSP的编辑器。
看 编辑器/vcode/ 和 编辑者/ed/ 了解详情。
运作原理
- 获取 来自WHATWG/WCC/TC39规范URL的规范HTML
- 解析 章节、算法、IDL定义和交叉引用
- 索引 在SQLite中使用FTS5进行快速全文搜索
- 刷新快照 基于内容哈希变化检测的24小时节奏
- 公关预览 从whatpr.org获取渲染页面,从提交快照获取合并库,将两者存储为单独的快照以供查询和区分
发展
cargo test
cargo clippy # lint
cargo fmt --check # format check许可证
麻省理工学院
