Programs Beat Prompts:AI 铸造一次,程序永久运行的浏览器自动化协议

3 阅读1分钟

问题

每次让 AI Agent 在浏览器里做事,都要花钱花时间。点这里、输那里、抓数据——AI 每次都从头搞一遍。

如果 AI 只需要搞明白一次呢?

Tap:编译器思路

Tap 是一个协议 + 工具链,把 AI 的界面操作编译成确定性程序(.tap.js):

  1. Forge — AI 观察页面(网络、DOM、可访问性树),写出 tap 程序
  2. Verify — 用不同输入测试 tap
  3. 永久运行 — tap 确定性回放,零 AI 成本
第一次:AI inspect → 写 .tap.js  ($0.50)
以后:  .tap.js 确定性回放      ($0.00)

核心设计

8 个核心操作(eval、pointer、keyboard、nav、wait、screenshot、run、capabilities)+ 17 个内建操作(click、type、fill、fetch 等)。

tap 程序就是普通 JavaScript:

export default {
  site: "github",
  name: "trending",
  async run(tap) {
    await tap.nav("https://github.com/trending")
    return tap.eval(() => {
      return [...document.querySelectorAll('article.Box-row')].map(el => ({
        repo: el.querySelector('h2 a')?.textContent?.trim(),
        stars: el.querySelector('.octicon-star')?.parentElement?.textContent?.trim()
      }))
    })
  }
}

多运行时

同一个 tap 可以在三种运行时执行:

  • Chrome 扩展 — 用 chrome.scripting(网站无法检测)
  • Playwright — 无头模式,适合 CI/CD
  • macOS — 原生应用,通过 Accessibility API

新运行时实现 8 个方法,就能获得 17 个内建操作。

社区技能

119 个社区技能,覆盖 55 个网站。开源仓库:tap-skills

vs Playwright/Puppeteer

PlaywrightTap
谁写脚本AI forge
每次运行成本N/A$0.00
运行时1个3+个
社区脚本119个

开始使用

curl -fsSL https://leonting1010.github.io/tap/install.sh | sh
tap github trending
tap hackernews hot

主页:leonting1010.github.io/tap/

Programs beat prompts. AI 铸造一次,程序永久运行。