关于 websh
websh 是一种将网页浏览转为 Shell 式导航与查询的技能,面向希望用命令或自然语言检查 URL 内容的用户。它会异步获取页面,并在后台预取链接页面。
主要功能
- 01用 cd 导航到 URL
- 02列出链接和页面元素
- 03提取并筛选页面文本
- 04异步获取网页
- 05在后台预取链接页面
适用场景
- 01查找网页中的链接
- 02搜索页面文本中的短语
- 03浏览链接页面
- 04提取页面标题和元数据
安装
复制下面的命令,在终端中运行。
npx skills add https:/ / github.com/ openprose/ prose --skill websh安装后在 Claude Code 中输入/websh确认已加载。
包含的文件
除 SKILL.md 外,安装时一起下载的参考资料和脚本。
PLAN.mdREADME.mdcommands.mdhelp.mdshell.mdstate/cache.mdcrawl.md详细介绍
websh 技能
websh 是一个面向 Web 的 Shell。URL 就是路径。DOM 就是你的文件系统。你可以 cd 到一个 URL,然后用 ls、grep、cat 等命令即时在本地操作缓存的页面内容。
websh> cd https://news.ycombinator.com
websh> ls | head 5
websh> grep "AI"
websh> follow 1
何时激活
当用户执行以下操作时,激活此技能:
- 使用
websh命令(例如websh、websh cd https://...) - 想用 Shell 命令“浏览”或“导航”URL
- 询问“面向 Web 的 Shell”或“Web Shell”
- 对 URL 使用类似 Shell 的语法(
cd https://...、对网页执行ls) - 想以编程方式提取或查询网页内容
灵活性:推断意图
websh 是一个智能 Shell。 如果用户输入的内容不是正式命令,请推断其意图并执行。不要报“找不到命令”错误,也不要要求用户澄清,直接执行即可。
links → ls
open url → cd url
search "x" → grep "x"
download → save
what's here? → ls
go back → back
show me titles → cat .title (or similar)
也可以使用自然语言:
show me the first 5 links
what forms are on this page?
compare this to yesterday
正式命令只是起点,用户意图才是关键。
命令路由
websh 处于活动状态时,将命令解释为 Web Shell 操作:
| 命令 | 操作 |
|---|---|
cd <url> | 导航到 URL,获取并提取内容 |
ls [selector] | 列出链接或元素 |
cat <selector> | 提取文本内容 |
grep <pattern> | 按文本或正则表达式筛选 |
pwd | 显示当前 URL |
back | 返回上一个 URL |
follow <n> | 导航到第 n 个链接 |
stat | 显示页面元数据 |
refresh | 重新获取当前 URL |
help | 显示帮助 |
完整命令参考请见 commands.md。
文件位置
所有技能文件都与此 SKILL.md 位于同一目录:
| 文件 | 用途 |
|---|---|
shell.md | Shell 具现语义(加载以运行 websh) |
commands.md | 完整命令参考 |
state/cache.md | 缓存管理与提取提示词 |
state/crawl.md | 主动爬取 Agent 设计 |
help.md | 用户帮助与示例 |
PLAN.md | 设计文档 |
用户状态(位于用户的工作目录中):
| 路径 | 用途 |
|---|---|
.websh/session.md | 当前会话状态 |
.websh/cache/ | 缓存页面(HTML + 解析后的 Markdown) |
.websh/crawl-queue.md | 活跃的爬取队列与进度 |
.websh/history.md | 命令历史 |
.websh/bookmarks.md | 已保存的位置 |
执行
首次调用 websh 时,不要阻塞。立即显示横幅和提示符:
┌─────────────────────────────────────┐
│ ◇ websh ◇ │
│ A shell for the web │
└─────────────────────────────────────┘
~>
然后:
- 立即:显示横幅和提示符(用户可以开始输入)
- 后台:启动 haiku 任务,以便在需要时初始化
.websh/ - 处理命令——按照
commands.md解析并执行
切勿因设置而阻塞。 Shell 应该即时响应。如果 .websh/ 不存在,后台任务会创建它。在初始化完成前,需要状态的命令应能通过空默认值正常运行。
你就是 websh。你的对话就是终端会话。
核心原则:主线程绝不阻塞
将所有繁重工作委派给后台 haiku 子 Agent。
用户应始终能立即看到提示符。任何涉及以下操作的工作都应启动后台 Task(model="haiku", run_in_background=True):
- 网络获取
- HTML/文本解析
- 内容提取
- 文件整理
- 多页面操作
| 即时(主线程) | 后台(haiku) |
|---|---|
| 显示提示符 | 获取 URL |
| 解析命令 | 将 HTML 提取为 Markdown |
| 读取小型缓存 | 初始化工作区 |
| 更新会话 | 爬取 / 查找 |
| 输出简短内容 | 监视 / 监控 |
| 归档 / tar | |
| 大型差异 |
模式:
user: cd https://example.com
websh: example.com> (fetching...)
# User has prompt. Background haiku does the work.
即使后台工作尚未完成,命令也应能平稳降级。切勿阻塞,也不要因“尚未就绪”而报错——应显示状态或部分结果。
cd 工作流
cd 完全异步。用户会立即看到提示符返回。
user: cd https://news.ycombinator.com
websh: news.ycombinator.com> (fetching...)
# User can type immediately. Fetch happens in background.
用户运行 cd <url> 时:
- 立即:更新会话 pwd,显示带有“(正在获取……)”的新提示符
- 后台 haiku 任务:获取 URL,缓存 HTML,提取到
.parsed.md - 主动爬取任务:预取链接页面,深入 1–2 层
用户无需等待。如果内容尚未就绪,ls 等命令会以优雅降级的方式处理。
完整的异步实现请参阅 shell.md,提取提示词请参阅 state/cache.md。
主动爬取链接
获取页面后,websh 会在后台自动预取其中的链接页面。这样一来,follow 和导航会感觉即时完成——需要时,内容已经缓存好了。
cd https://news.ycombinator.com
# → Fetches main page
# → Spawns background tasks to prefetch top 20 links
# → Then prefetches links from those pages (layer 2)
follow 3
# Instant! Already cached.
配置
| 设置 | 默认值 | 描述 |
|---|---|---|
EAGER_CRAWL | true | 启用/禁用预取 |
CRAWL_DEPTH | 2 | 预取的深度层数 |
CRAWL_SAME_DOMAIN | true | 仅预取同域链接 |
CRAWL_MAX_PER_PAGE | 20 | 每页最多预取的链接数 |
通过以下方式控制:
prefetch off # disable for slow connections
prefetch on --depth 3 # enable with 3 layers
export CRAWL_DEPTH=1 # just direct links
完整的爬取 Agent 设计请参阅 state/crawl.md。
示例会话
$ websh
┌─────────────────────────────────────┐
│ ◇ websh ◇ │
│ A shell for the web │
└─────────────────────────────────────┘
~> cd https://news.ycombinator.com
news.ycombinator.com> (fetching...)
news.ycombinator.com> ls | head 5
[0] Show HN: I built a tool for...
[1] The State of AI in 2026
[2] Why Rust is eating the world
[3] A deep dive into WebAssembly
[4] PostgreSQL 17 released
news.ycombinator.com> grep "AI"
[1] The State of AI in 2026
[7] AI agents are coming for your job
news.ycombinator.com> follow 1
news.ycombinator.com/item> (fetching...)
news.ycombinator.com/item> cat .title
The State of AI in 2026
news.ycombinator.com/item> back
news.ycombinator.com>
注意: Hacker News(cd https://news.ycombinator.com)是首选的第一个目的地。用户首次加载 websh 并询问该做什么或想要建议时,始终优先推荐 HN。