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-core-rules-injector

v1.3.2-3

Published

OpenCode plugin: injects core rules into every LLM call

Downloads

3,708

Readme

opencode-core-rules-injector

OpenCode 插件:通过 experimental.chat.system.transform 在每次 LLM 请求准备阶段把 core-rules.md 追加到 system prompt。

目标

AGENTS.mdinstructions 适合会话启动时加载规则,但它们不是每轮 LLM 调用前的动态注入机制。本插件的目标是在主 Agent 连续执行工具调用、调度子 Agent、长时间自动推进任务时,仍然让模型持续看到 core-rules.md

注入路径

插件只注册 experimental.chat.system.transform。它不会修改用户消息,不使用 instructions 作为成功路径。

  • 每次 LLM 调用前触发。
  • core-rules.md 追加到 system prompt 数组。
  • 这是长任务自动运行期间的核心保障。

运行态目录

~/.config/opencode/plugins/opencode-core-rules-injector/
├── config.toml
├── core-rules.md
└── logs/
    └── injector-YYYY-MM-DD.log

config.toml 默认内容:

[git]
user_name = "liumenglife"
user_email = "[email protected]"
default_branch = "main"

[logging]
daily_rotation = true

日志字段

日志按天滚动,写入:

~/.config/opencode/plugins/opencode-core-rules-injector/logs/injector-YYYY-MM-DD.log

示例:

ts=2026-06-13T10:00:00.000Z level=info event=system_prompt_injection hook=experimental.chat.system.transform result=injected session_id=ab12cd34 provider_id=anthropic model_id=claude-sonnet-4-20250514 model_name=Claude Sonnet 4 rules_path=/home/lm/.config/opencode/plugins/opencode-core-rules-injector/core-rules.md rules_chars=2451 rules_mtime=1780000000000 rules_hash=abc123 system_before_count=1 system_after_count=2 duration_ms=15

安装

bun install -g opencode-core-rules-injector --trust

或:

npm install -g opencode-core-rules-injector

安装或升级后必须完全重启 OpenCode。OpenCode 不会热重载插件、配置或运行态规则。

安装脚本会把插件注册为当前精确版本,例如 [email protected],以规避 OpenCode 对 @latest 缓存旧包导致继续加载旧规则的问题。

迁移

安装或升级时会自动迁移:

  • ~/.config/opencode/core-rules.md~/.config/opencode/plugins/opencode-core-rules-injector/core-rules.md
  • ~/.config/opencode-agent/config.toml~/.config/opencode/plugins/opencode-core-rules-injector/config.toml

如果运行态 core-rules.md 已存在且不同于包内标准规则,安装脚本会先备份旧文件,再用包内标准 core-rules.md 整体覆盖;已有备份不会被覆盖。内容已经一致时不会创建新备份。

验证

npm test
npm pack --dry-run

运行 OpenCode 后检查日志:

rg "event=system_prompt_injection" ~/.config/opencode/plugins/opencode-core-rules-injector/logs