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

@kiritoko1029/opencode-add-oai-instruction

v1.0.1

Published

OpenCode plugin for adding instructions from OpenAI-compatible API requests

Downloads

31

Readme

opencode-add-oai-instruction

English | 简体中文

OpenCode 插件:会向 OpenAI 兼容接口的请求体中注入 instructions 字段。

instructions 的内容会根据请求里的 model 从对应的 Markdown 文件加载。

另外,对于 gpt* 模型(model 包含 gpt),插件也会移除 max_output_tokens / max_tokens,用于兼容一些不支持这些字段的 OpenAI-compatible provider。

安装

cd ~/.config/opencode
bun add github:kiritoko1029/opencode-add-oai-instruction

使用

在你的 opencode.json 中加入:

{
  "plugins": [
    "@kiritoko1029/opencode-add-oai-instruction" // 添加这一行
  ],
  "provider": {
    "my-provider": {
      "npm": "@ai-sdk/openai",
      "api": "https://your-api.com/v1",
      "env": ["MY_API_KEY"],
      "options": {
        "addInstruction": true // 启用插件
      },
      "models": {
        "gpt-5.2": {}
      }
    }
  }
}

提示词文件(Prompt Files)

本包已内置提示词 Markdown 文件(通常不需要用户额外创建)。

提示词来源:https://github.com/openai/codex/tree/main/codex-rs/core

自定义提示词(可选)

如果你希望使用自己的提示词(覆盖内置提示词,或为其它 model 增加提示词),可以在插件目录(与 index.mjs 同级)放置/替换对应的 Markdown 文件。

文件命名规则:

  • <model>_prompt.md

示例:

  • model="gpt-5.2-codex"gpt-5.2-codex_prompt.md
  • model="gpt-5.2"gpt-5.2_prompt.md(或 gpt_5_2_prompt.md

说明:

  • 匹配不区分大小写。
  • 如果没有找到匹配的文件,插件会使用一段内置的简短 instructions(除非请求里已经包含非空的 instructions)。
  • 读取到的提示词会按 model 做内存缓存(in-memory cache)。

工作原理

  1. chat.params hook 中读取 provider.options.addInstruction
  2. 拦截 globalThis.fetch,当插件启用时:
    • model 包含 gpt 时,移除 max_output_tokens / max_tokens
    • 根据 model 加载对应的 _prompt.md 文件内容,并写入请求体 instructions
  3. 对每个 model 的提示词内容进行缓存,减少文件读取次数。

License

MIT