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

opencode-heartbeat

v0.0.9

Published

OpenCode Heartbeat Plugin - 心跳检测和定时任务插件

Downloads

124

Readme

@ali/opencode-heartbeat

OpenCode Heartbeat Plugin - 心跳检测和定时任务插件

版本

0.1.0

项目结构

src/
├── index.ts                    # 插件入口,自动启动调度器
├── HeartbeatManager.ts         # 心跳会话管理器(单例)
├── HeartbeatSession.ts         # 单个心跳会话
├── config.ts                   # 配置加载
├── types.ts                    # 类型定义
│
├── commands/                   # 命令处理
│   ├── start.ts               # 启动心跳命令
│   ├── stop.ts                # 停止心跳命令
│   └── status.ts              # 查看状态命令
│
├── utils/                      # 工具函数
│   ├── validator.ts           # 文件路径和大小验证
│   └── file-reader.ts         # 文件内容读取
│
└── __tests__/                 # 单元测试
    ├── HeartbeatManager.test.ts
    ├── HeartbeatSession.test.ts
    └── validator.test.ts

核心功能

1. 心跳管理

  • 定时向指定会话发送消息
  • 支持文本和文件两种内容类型
  • 自动清理过期会话(超过3天)

2. 命令系统

| 命令 | 说明 | |------|------| | /heartbeat start <seconds> <content> | 启动心跳(文本内容) | | /heartbeat start <seconds> <file> | 启动心跳(文件内容) | | /heartbeat stop | 停止当前会话的心跳 | | /heartbeat status | 查看当前会话心跳状态 | | /heartbeat status all | 查看所有心跳会话状态 | | /heartbeat status <sessionId> | 查看指定会话心跳状态 |

3. 调度机制

  • 每秒检查待执行的心跳任务
  • 每分钟清理过期会话
  • 会话超时自动停止(默认3天)

配置说明

环境变量

| 变量名 | 说明 | 默认值 | |--------|------|--------| | HEARTBEAT_MIN_INTERVAL_MS | 最小心跳间隔(毫秒) | 900000 (15分钟) | | HEARTBEAT_MAX_DURATION_MS | 最大心跳持续时间(毫秒) | 259200000 (3天) | | HEARTBEAT_MAX_FILE_SIZE_BYTES | 最大文件大小(字节) | 10240 (10KB) | | HEARTBEAT_WORKSPACE_ROOT | 工作空间根目录 | process.cwd() |

配置查找顺序

  1. 环境变量
  2. 代码默认值

使用方法

安装

npm install

构建

npm run build

类型检查

npm run typecheck

运行测试

npm test
npm run test:watch
npm run test:coverage

命令示例

启动文本心跳

/heartbeat start 900 "hello world"

启动一个每15分钟发送一次 "hello world" 的心跳。

启动文件心跳

/heartbeat start 900 /workspace/notes.txt

启动一个每15分钟发送一次文件内容的心跳。

查看状态

/heartbeat status

查看当前会话的心跳状态。

查看所有心跳

/heartbeat status all

查看所有活跃的心跳会话。

停止心跳

/heartbeat stop

停止当前会话的心跳。

依赖项

dependencies

| 包名 | 说明 | |------|------| | @opencode-ai/plugin | OpenCode插件接口 | | @opencode-ai/sdk | OpenCode SDK | | zod | 数据验证 |

devDependencies

| 包名 | 说明 | |------|------| | @types/jest | Jest类型定义 | | @types/node | Node.js类型定义 | | jest | 测试框架 | | ts-jest | TypeScript Jest支持 | | typescript | TypeScript编译器 | | prettier | 代码格式化 | | husky | Git钩子 | | lint-staged | Git暂存文件检查 |

仓库

  • Git: http://gitlab.alibaba-inc.com/gaode.search/opencode-heartbeat.git