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

pi-openai-responses-instructions

v0.1.2

Published

Pi extension package that rewrites openai-responses payloads to use top-level instructions instead of system/developer input messages.

Readme

pi-openai-responses-instructions

pi-openai-responses-instructions 是一个 Pi extension package。

它会在请求真正发出前,自动把 api: "openai-responses" 的 payload 从:

  • input[0] 中携带 system / developer prompt

改写为:

  • 顶层 instructions
  • 同时从 input 中移除该首条 system / developer

这个方案不修改 node_modules,因此比直接 patch 已安装的 Pi 运行时代码更稳,更适合跨机器复用。

作用范围

默认影响全部 ctx.model.api === "openai-responses" 的请求。

不影响:

  • openai-codex-responses
  • azure-openai-responses
  • openai-completions
  • anthropic-messages

工作原理

扩展使用 Pi 的 before_provider_request 钩子,在 provider payload 已经序列化完成、但尚未发送前进行改写:

  1. 仅处理当前模型 api === "openai-responses" 的请求。
  2. 若 payload 已经存在顶层 instructions,则保持不动。
  3. 仅检查 payload.input[0] 是否存在,且其 role 是否为 systemdeveloper
  4. 将这第一条消息的文本内容写入顶层 instructions
  5. input 中删除这第一条 system / developer 消息,保留其余消息顺序不变。

安装

本地路径安装

pi install /absolute/path/to/extensions-pluging/pi-openai-responses-instructions

临时试用

pi -e /absolute/path/to/extensions-pluging/pi-openai-responses-instructions/index.ts

npm 安装

发布到 npm 后可用:

pi install npm:pi-openai-responses-instructions

git 安装

如果你把这个目录放到独立仓库,也可以:

pi install git:github.com/MuJianxuan/[email protected]

使用

安装后重启 Pi,或执行:

/reload

然后继续使用原来的 provider / model 配置即可,不需要切换 provider。

调试日志

如果你想查看首条 system / developer 消息里的原始 content,以及扩展最终提取出的 instructions,可以在启动 Pi 前打开调试开关:

PI_OPENAI_RESPONSES_INSTRUCTIONS_DEBUG=1 pi

开启后,当扩展命中可改写的首条消息时,会输出两条日志:

  • 原始 firstItem.content
  • 提取后的 instructions,若未提取到则显示 <empty>

验证方法

最直接的方法是临时加载一个 payload 日志扩展,或在你自己的网关侧查看最终请求体。

改写成功后,请求体应表现为:

{
  "instructions": "...system prompt...",
  "input": [
    { "role": "user", "content": [...] }
  ]
}

也就是说,只有当第一条消息本来就是 systemdeveloper 时,才会发生改写。例如:

{
  "input": [
    { "role": "developer", "content": "...system prompt..." },
    { "role": "user", "content": [...] }
  ]
}

会被改写;而下面这种不会:

{
  "input": [
    { "role": "user", "content": [...] },
    { "role": "developer", "content": "...late prompt..." }
  ]
}

限制说明

  1. 这个包按 api 类型匹配,因此会影响所有 openai-responses 请求。
  2. 如果首条消息不是 system / developer,本扩展不会扫描后续消息,也不会做任何改写。
  3. 如果某个 provider 后续自己已经改成直接发送 instructions,本扩展会检测到 payload.instructions 已存在,并跳过重复改写。
  4. 这个包只重写 provider payload,不改 Pi 内置 provider 实现,因此升级 Pi 后通常不需要重打补丁。

开发检查

npm run check:import
npm run pack:check
npm run prepublishOnly