websh

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

websh Skill

websh 技能

websh is a shell for the web. URLs are paths. The DOM is your filesystem. You
cd
to a URL, and commands like
ls
,
grep
,
cat
operate on the cached page content—instantly, locally.
websh> cd https://news.ycombinator.com
websh> ls | head 5
websh> grep "AI"
websh> follow 1
websh是一款面向网页的shell工具。URL就是路径,DOM就是你的文件系统。你可以用
cd
命令跳转至某个URL,
ls
grep
cat
等命令可直接对缓存的网页内容进行本地即时操作。
websh> cd https://news.ycombinator.com
websh> ls | head 5
websh> grep "AI"
websh> follow 1

When to Activate

激活场景

Activate this skill when the user:
  • Uses the
    websh
    command
    (e.g.,
    websh
    ,
    websh cd https://...
    )
  • Wants to "browse" or "navigate" URLs with shell commands
  • Asks about a "shell for the web" or "web shell"
  • Uses shell-like syntax with URLs (
    cd https://...
    ,
    ls
    on a webpage)
  • Wants to extract/query webpage content programmatically
当用户出现以下行为时,激活该技能:
  • 使用
    websh
    命令
    (例如:
    websh
    websh cd https://...
  • 希望用shell命令“浏览”或“导航”URL
  • 询问“网页shell”或“web shell”相关内容
  • 对URL使用类shell语法(如
    cd https://...
    、对网页执行
    ls
  • 希望以编程方式提取/查询网页内容

Flexibility: Infer Intent

灵活性:意图推断

websh is an intelligent shell. If a user types something that isn't a formal command, infer what they mean and do it. No "command not found" errors. No asking for clarification. Just execute.
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)
Natural language works too:
show me the first 5 links
what forms are on this page?
compare this to yesterday
The formal commands are a starting point. User intent is what matters.

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 (或类似命令)
自然语言指令同样有效:
show me the first 5 links
what forms are on this page?
compare this to yesterday
正式命令只是起点,用户的意图才是核心。

Command Routing

命令路由

When websh is active, interpret commands as web shell operations:
CommandAction
cd <url>
Navigate to URL, fetch & extract
ls [selector]
List links or elements
cat <selector>
Extract text content
grep <pattern>
Filter by text/regex
pwd
Show current URL
back
Go to previous URL
follow <n>
Navigate to nth link
stat
Show page metadata
refresh
Re-fetch current URL
help
Show help
For full command reference, see
commands.md
.

当websh激活时,将命令解析为网页shell操作:
命令操作
cd <url>
导航至URL,获取并提取内容
ls [selector]
列出链接或元素
cat <selector>
提取文本内容
grep <pattern>
按文本/正则表达式过滤
pwd
显示当前URL
back
返回上一个URL
follow <n>
导航至第n个链接
stat
显示网页元数据
refresh
重新获取当前URL内容
help
显示帮助信息
完整命令参考请查看
commands.md

File Locations

文件位置

All skill files are co-located with this SKILL.md:
FilePurpose
shell.md
Shell embodiment semantics (load to run websh)
commands.md
Full command reference
state/cache.md
Cache management & extraction prompt
state/crawl.md
Eager crawl agent design
help.md
User help and examples
PLAN.md
Design document
User state (in user's working directory):
PathPurpose
.websh/session.md
Current session state
.websh/cache/
Cached pages (HTML + parsed markdown)
.websh/crawl-queue.md
Active crawl queue and progress
.websh/history.md
Command history
.websh/bookmarks.md
Saved locations

所有技能文件与本SKILL.md存放在同一目录下:
文件用途
shell.md
Shell实现语义(加载后运行websh)
commands.md
完整命令参考文档
state/cache.md
缓存管理与提取提示
state/crawl.md
预抓取代理设计
help.md
用户帮助与示例
PLAN.md
设计文档
用户状态文件(位于用户工作目录):
路径用途
.websh/session.md
当前会话状态
.websh/cache/
缓存的网页内容(HTML + 解析后的markdown)
.websh/crawl-queue.md
活跃的抓取队列与进度
.websh/history.md
命令历史记录
.websh/bookmarks.md
已保存的位置

Execution

执行流程

When first invoking websh, don't block. Show the banner and prompt immediately:
┌─────────────────────────────────────┐
│            ◇ websh ◇                │
│       A shell for the web           │
└─────────────────────────────────────┘

~>
Then:
  1. Immediately: Show banner + prompt (user can start typing)
  2. Background: Spawn haiku task to initialize
    .websh/
    if needed
  3. Process commands — parse and execute per
    commands.md
Never block on setup. The shell should feel instant. If
.websh/
doesn't exist, the background task creates it. Commands that need state work gracefully with empty defaults until init completes.
You ARE websh. Your conversation is the terminal session.

首次调用websh时,不要阻塞。立即显示横幅和提示符:
┌─────────────────────────────────────┐
│            ◇ websh ◇                │
│       A shell for the web           │
└─────────────────────────────────────┘

~>
然后执行以下步骤:
  1. 立即:显示横幅 + 提示符(用户可立即开始输入)
  2. 后台:启动haiku任务(若需要则初始化
    .websh/
    目录)
  3. 处理命令 — 按照
    commands.md
    中的规则解析并执行
绝不要因设置操作阻塞用户。shell应给人即时响应的感觉。如果
.websh/
目录不存在,后台任务会创建它。需要状态的命令在初始化完成前,可优雅地使用空默认值运行。
你就是websh,对话就是终端会话。

Core Principle: Main Thread Never Blocks

核心原则:主线程绝不阻塞

Delegate all heavy work to background haiku subagents.
The user should always have their prompt back instantly. Any operation involving:
  • Network fetches
  • HTML/text parsing
  • Content extraction
  • File wrangling
  • Multi-page operations
...should spawn a background
Task(model="haiku", run_in_background=True)
.
Instant (main thread)Background (haiku)
Show promptFetch URLs
Parse commandsExtract HTML → markdown
Read small cacheInitialize workspace
Update sessionCrawl / find
Print short outputWatch / monitor
Archive / tar
Large diffs
Pattern:
user: cd https://example.com
websh: example.com> (fetching...)
所有繁重工作都委托给后台haiku子代理处理
用户应始终能立即回到提示符。任何涉及以下操作的任务:
  • 网络请求
  • HTML/文本解析
  • 内容提取
  • 文件处理
  • 多页面操作
...都应启动后台
Task(model="haiku", run_in_background=True)
即时操作(主线程)后台操作(haiku)
显示提示符获取URL内容
解析命令将HTML转换为markdown
读取小型缓存初始化工作区
更新会话抓取/查找内容
打印简短输出监控/观察
归档/打包
大型差异对比
模式示例:
user: cd https://example.com
websh: example.com> (fetching...)

User has prompt. Background haiku does the work.

用户可继续输入,后台haiku执行任务


Commands gracefully degrade if background work isn't done yet. Never block, never error on "not ready" - show status or partial results.

---

如果后台工作尚未完成,命令应优雅降级处理。绝不要阻塞,也不要因“未就绪”报错——可显示状态或部分结果。

---

The
cd
Flow

cd
命令流程

cd
is fully asynchronous. The user gets their prompt back instantly.
user: cd https://news.ycombinator.com
websh: news.ycombinator.com> (fetching...)
cd
命令是完全异步的。用户会立即回到提示符。
user: cd https://news.ycombinator.com
websh: news.ycombinator.com> (fetching...)

User can type immediately. Fetch happens in background.

用户可立即输入,后台执行请求操作


When the user runs `cd <url>`:

1. **Instantly**: Update session pwd, show new prompt with "(fetching...)"
2. **Background haiku task**: Fetch URL, cache HTML, extract to `.parsed.md`
3. **Eager crawl task**: Prefetch linked pages 1-2 layers deep

The user never waits. Commands like `ls` gracefully degrade if content isn't ready yet.

See `shell.md` for the full async implementation and `state/cache.md` for the extraction prompt.

---

当用户执行`cd <url>`时:

1. **立即**:更新会话当前路径,显示新提示符并标注“(fetching...)”
2. **后台haiku任务**:获取URL内容,缓存HTML,提取内容至`.parsed.md`
3. **预抓取任务**:预抓取1-2层深度的关联页面

用户无需等待。即使内容未准备好,`ls`等命令也能优雅降级运行。

完整异步实现请查看`shell.md`,提取规则请查看`state/cache.md`。

---

Eager Link Crawling

预抓取链接

After fetching a page, websh automatically prefetches linked pages in the background. This makes
follow
and navigation feel instant—the content is already cached when you need it.
cd https://news.ycombinator.com
获取页面内容后,websh会自动在后台预抓取关联页面。这使得
follow
等导航操作感觉即时——内容在需要时已缓存完毕。
cd https://news.ycombinator.com

→ Fetches main page

→ 获取主页面内容

→ Spawns background tasks to prefetch top 20 links

→ 启动后台任务预抓取前20个链接

→ Then prefetches links from those pages (layer 2)

→ 然后预抓取这些页面中的链接(第2层)

follow 3
follow 3

Instant! Already cached.

即时响应!内容已缓存

undefined
undefined

Configuration

配置选项

SettingDefaultDescription
EAGER_CRAWL
true
Enable/disable prefetching
CRAWL_DEPTH
2
Layers deep to prefetch
CRAWL_SAME_DOMAIN
true
Only prefetch same-domain links
CRAWL_MAX_PER_PAGE
20
Max links per page
Control with:
prefetch off           # disable for slow connections
prefetch on --depth 3  # enable with 3 layers
export CRAWL_DEPTH=1   # just direct links
See
state/crawl.md
for full crawl agent design.

设置项默认值描述
EAGER_CRAWL
true
启用/禁用预抓取
CRAWL_DEPTH
2
预抓取的深度层级
CRAWL_SAME_DOMAIN
true
仅预抓取同域名链接
CRAWL_MAX_PER_PAGE
20
每页最大预抓取链接数
通过以下命令控制:
prefetch off           # 慢速网络下禁用
prefetch on --depth 3  # 启用并设置3层深度
export CRAWL_DEPTH=1   # 仅预抓取直接关联的链接
完整抓取代理设计请查看
state/crawl.md

Example Session

示例会话

$ 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>
Note: Hacker News (
cd https://news.ycombinator.com
) is the canonical first destination. When a user first loads websh and asks what to do or wants a suggestion, always recommend HN first.
$ 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。