npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

page-action-cache

v2026.21.1

Published

Page Action Cache - OpenClaw extension

Readme

Page Action Cache - OpenClaw Extension

页面操作缓存扩展 - 为 OpenClaw 提供页面快照缓存功能

功能特性

1. 页面快照缓存

  • 存储页面快照和角色引用
  • 支持快速查询和失效
  • 自动清理过期缓存(5分钟 TTL)
  • LRU 容量管理(最多 50 个条目)

2. 配置选项

  • enabled: 启用/禁用插件
  • autoUseCache: 自动使用缓存

技术架构

目录结构

page-action-cache/
├── src/
│   ├── index.ts           # 主扩展入口
│   └── types.ts          # TypeScript 类型定义
├── tests/                # 测试文件
├── dist/                 # 编译输出目录
├── package.json          # 项目配置
├── tsconfig.json         # TypeScript 配置
├── openclaw.plugin.json # OpenClaw 插件元数据
└── README.md            # 项目文档

安装和使用

开发环境安装

# 1. 确保已构建
cd /Users/zhoujinyu/Documents/projects/page-action-cache
npm run build

# 2. 在 OpenClaw 配置中添加本地扩展引用
# 编辑 ~/.openclaw/openclaw.json 或实例配置文件
{
  "plugins": {
    "entries": {
      "page-action-cache": {
        "enabled": true,
        "autoUseCache": true
      }
    }
  }
}

全局安装

# 从 Gitee 仓库安装
npm install -g https://gitee.com/jinyu_zjy/page-action-cache.git

工具说明

1. page_snapshot_cache

缓存和检索页面快照以加速重复操作

参数:

  • url (必需): 页面 URL
  • snapshot (可选): 要存储的页面快照
  • refs (可选): 角色引用映射
  • invalidate (可选): 失效该 URL 的缓存,默认 false

返回示例:

Cache stored for https://example.com

2. page_cache_stats

查看页面快照缓存统计信息

参数: 无

返回示例:

## Page Snapshot Cache Statistics

- Total Entries: 15
- Total Hits: 42
- Hit Rate: 85.50%
- Avg Hit Count: 2.8
- Cleaned Entries: 3
- Oldest Entry: 2026-03-16T10:30:00.000Z
- Newest Entry: 2026-03-16T11:00:00.000Z

3. page_cache_clear

清空页面快照缓存

参数: 无

返回示例:

Cleared 15 cache entries

使用示例

通过 OpenClaw CLI 使用

# 存储页面快照
openclaw message send --channel web --content "page_snapshot_cache https://example.com --snapshot '...' --refs {...}"

# 查询缓存
openclaw message send --channel web --content "page_snapshot_cache https://example.com"

# 查看统计
openclaw message send --channel web --content "page_cache_stats"

# 清空缓存
openclaw message send --channel web --content "page_cache_clear"

通过 Web UI 使用

  1. 在 OpenClaw Web UI 中发送消息
  2. AI 会自动调用 page-action-cache 扩展的工具
  3. 工具会执行缓存操作并返回结果
  4. 用户可以看到缓存命中情况和统计信息

配置示例

基础配置

{
  "plugins": {
    "entries": {
      "page-action-cache": {
        "enabled": true,
        "autoUseCache": true
      }
    }
  }
}

性能优化

缓存策略

  • TTL 过期: 5 分钟后自动失效
  • LRU 驱逐: 超过容量时删除最旧的条目
  • 访问计数: 跟踪每个缓存的命中次数
  • 自动清理: 每次操作时检查并清理过期缓存

预期性能提升

| 场景 | 无缓存 | 有缓存 | 提升 | |--------|--------|--------|------| | 首次访问 | ~5s | ~5s | 0% (需存储) | | 再次访问 | ~5s | ~50ms | 99% | | 缓存命中 | 正常 | 正常 | 0% (直接用 refs) |

技术栈

  • 语言: TypeScript (ES2022)
  • 模块系统: ESM
  • 测试框架: Vitest
  • 目标环境: Node.js 22+
  • 构建工具: TypeScript Compiler
  • OpenClaw SDK: openclaw/plugin-sdk

开发状态

已完成的功能

  • ✅ OpenClaw Plugin SDK 集成
  • ✅ 内存缓存实现
  • ✅ TTL 过期管理
  • ✅ LRU 容量管理
  • ✅ 统计信息工具
  • ✅ 缓存清空工具
  • ✅ TypeScript 类型定义

已知限制

  • 缓存存储在内存中,进程重启后清空
  • 目前不支持跨进程持久化
  • 不支持页面变化检测(简化版本)

许可证

MIT

贡献

欢迎提交 Issue 和 Pull Request!