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-prompt-enhance

v1.0.0

Published

OpenCode plugin for prompt enhancement. Injects command templates at session start and end to enhance AI interactions.

Downloads

14

Readme

opencode-prompt-enhance

为 OpenCode 提供会话前后提示词注入功能,增强 AI 交互体验。

功能特性

  • 会话开始增强:自动在用户首条消息前注入 /start-work 命令的 template
  • 会话结束注入:会话空闲时自动注入 /record-memory 命令的 template
  • 用户停止检测:自动检测用户主动停止的会话,跳过注入
  • 防重复注入:多层状态检查,防止同一会话重复增强
  • 竞态防护:异步安全设计,防止并发事件导致的重复处理

安装

npm install -g opencode-prompt-enhance
# 或
bun add -g opencode-prompt-enhance

配置

opencode.json 中添加插件:

{
  "$schema": "https://opencode.ai/config.json",
  "plugin": ["opencode-prompt-enhance"]
}

命令配置

在 OpenCode 中配置 /start-work/record-memory 命令:

{
  "commands": [
    {
      "name": "start-work",
      "template": "读取有关的海马体;再实现用户需求"
    },
    {
      "name": "record-memory",
      "template": "请将本次会话中的重要信息记录到海马体中"
    }
  ]
}

工作原理

会话开始增强

  1. 用户发送首条消息时,插件查询 /start-work 命令的 template
  2. 如果找到 template,在用户消息前添加 template 内容
  3. 增强效果:{template}\n\n{用户消息}

会话结束注入

  1. 会话空闲时(session.idle 事件),插件查询 /record-memory 命令的 template
  2. 如果找到 template,自动向会话注入提示词
  3. AI 收到提示词后会执行相应的记忆操作

用户停止检测

  • 当用户主动停止会话时,插件检测到 MessageAbortedError
  • 自动跳过该会话的注入,避免干扰用户操作

使用示例

场景一:自动读取海马体

配置 /start-work 命令:

template: "读取有关的海马体;再实现用户需求"

用户输入:

帮我写一个排序算法

实际发送给 AI 的内容:

读取有关的海马体;再实现用户需求

帮我写一个排序算法

场景二:自动记录记忆

配置 /record-memory 命令:

template: "请将本次会话中的重要信息记录到海马体中,使用 haimati_write 工具"

会话结束时,插件自动注入提示词,AI 会调用海马体工具记录重要信息。

日志

日志位于:~/.opencode-prompt-enhance/log/{yyyy-MM-dd}.log(按天轮转)

日志配置位于:~/.opencode-prompt-enhance/log.conf

level: info           # 日志级别:debug、info、warn、error
log_retention_days: 180  # 日志保留天数

依赖

  • OpenCode v0.15.0+
  • Node.js 或 Bun

相关项目

  • opencode-haimati - 海马体记忆系统插件,提供基于文件系统的长期记忆存储和检索功能