{"_id":"@angdrew/opencode-openai-instructions","_rev":"2-c6b22c795c5fc53bf6a95bb15e86ec5a","name":"@angdrew/opencode-openai-instructions","dist-tags":{"latest":"1.0.1"},"versions":{"1.0.0":{"name":"@angdrew/opencode-openai-instructions","version":"1.0.0","keywords":["opencode","plugin","openai","opencode-plugin"],"author":"","license":"MIT","_id":"@angdrew/opencode-openai-instructions@1.0.0","maintainers":[{"name":"angdrew","email":"andrewanggada@gmail.com"}],"homepage":"https://github.com/angdrew/opencode-openai-instructions#readme","bugs":{"url":"https://github.com/angdrew/opencode-openai-instructions/issues"},"dist":{"shasum":"27504e2e8240de11609d6521856381e969ebec50","tarball":"https://registry.npmjs.org/@angdrew/opencode-openai-instructions/-/opencode-openai-instructions-1.0.0.tgz","fileCount":7,"integrity":"sha512-DXqu0QOEyloQjLPDq1SgdC5ojYPtsB9rRccuuJdJv20IohH8NfFVKo0wTYRrhzSIYuIjtV5N3V/8LOHZ7TD68A==","signatures":[{"sig":"MEYCIQCxcqdfldtVeS4ErHqUj0ft0IbieUaIdmXDUYXoAzPNNwIhAKrFSfLX3DnriMjWr59mXZlyCDZdw65ANYZSOCrjyPGW","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":7672},"main":"dist/index.js","type":"module","types":"dist/index.d.ts","engines":{"node":">=18.0.0"},"scripts":{"dev":"tsc --watch","build":"tsc","clean":"node -e \"require('fs').rmSync('dist', { recursive: true, force: true })\"","prepublishOnly":"npm run build"},"_npmUser":{"name":"angdrew","email":"andrewanggada@gmail.com"},"repository":{"url":"git+https://github.com/angdrew/opencode-openai-instructions.git","type":"git"},"_npmVersion":"11.9.0","description":"OpenCode plugin to inject instructions for OpenAI provider regardless of auth type","directories":{},"_nodeVersion":"24.14.0","publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"typescript":"^5.0.0","@opencode-ai/plugin":"^1.2.0"},"_npmOperationalInternal":{"tmp":"tmp/opencode-openai-instructions_1.0.0_1774325218093_0.14237206102895317","host":"s3://npm-registry-packages-npm-production"}},"1.0.1":{"name":"@angdrew/opencode-openai-instructions","version":"1.0.1","description":"OpenCode plugin to inject instructions for OpenAI provider regardless of auth type","type":"module","main":"dist/index.js","types":"dist/index.d.ts","scripts":{"build":"tsc","dev":"tsc --watch","prepublishOnly":"npm run build","clean":"node -e \"require('fs').rmSync('dist', { recursive: true, force: true })\""},"keywords":["opencode","plugin","openai","opencode-plugin"],"author":"","license":"MIT","repository":{"type":"git","url":"git+https://github.com/angdrew/opencode-openai-instructions.git"},"bugs":{"url":"https://github.com/angdrew/opencode-openai-instructions/issues"},"homepage":"https://github.com/angdrew/opencode-openai-instructions#readme","publishConfig":{"access":"public"},"devDependencies":{"@opencode-ai/plugin":"^1.2.0","typescript":"^5.0.0"},"engines":{"node":">=18.0.0"},"_id":"@angdrew/opencode-openai-instructions@1.0.1","_nodeVersion":"24.14.0","_npmVersion":"11.9.0","dist":{"integrity":"sha512-xkiUj+haryiyasoEsZ5U+WlpjvQZtlDNThOmUhskFuJY1Dzs5VzE17WsPp1APZMsmX5icj31oFiSVqNNhw5NLA==","shasum":"dccebd70fb97e646c36cb241dd78f8b2e06b076e","tarball":"https://registry.npmjs.org/@angdrew/opencode-openai-instructions/-/opencode-openai-instructions-1.0.1.tgz","fileCount":7,"unpackedSize":8061,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEYCIQC7b+mGuqoT21svVsfy6flTNSFphfyGmPnaAgoaDnKURwIhANQzsB7kINen2JabsREfsIsFUhFjNxWUtoQd7WrKJTO8"}]},"_npmUser":{"name":"angdrew","email":"andrewanggada@gmail.com"},"directories":{},"maintainers":[{"name":"angdrew","email":"andrewanggada@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/opencode-openai-instructions_1.0.1_1774326014475_0.7293105461824378"},"_hasShrinkwrap":false}},"time":{"created":"2026-03-24T04:06:58.022Z","modified":"2026-03-24T04:20:14.780Z","1.0.0":"2026-03-24T04:06:58.240Z","1.0.1":"2026-03-24T04:20:14.674Z"},"bugs":{"url":"https://github.com/angdrew/opencode-openai-instructions/issues"},"license":"MIT","homepage":"https://github.com/angdrew/opencode-openai-instructions#readme","keywords":["opencode","plugin","openai","opencode-plugin"],"repository":{"type":"git","url":"git+https://github.com/angdrew/opencode-openai-instructions.git"},"description":"OpenCode plugin to inject instructions for OpenAI provider regardless of auth type","maintainers":[{"name":"angdrew","email":"andrewanggada@gmail.com"}],"readme":"# OpenCode Plugin: OpenAI Instructions Injector\n\n[![npm version](https://badge.fury.io/js/@angdrew%2Fopencode-openai-instructions.svg)](https://www.npmjs.com/package/@angdrew/opencode-openai-instructions)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n\nAn [OpenCode](https://github.com/opencode-ai/opencode) plugin that ensures instructions are always injected for the OpenAI provider, regardless of authentication type.\n\n## Problem\n\nIn OpenCode's `packages/opencode/src/session/llm.ts`, there's a conditional that only sets `options.instructions` when:\n\n```typescript\nconst isOpenaiOauth = provider.id === \"openai\" && auth?.type === \"oauth\"\n\nif (isOpenaiOauth) {\n  options.instructions = system.join(\"\\n\")\n}\n```\n\n**The Issue**: When using OpenAI with API key authentication (not OAuth), `isOpenaiOauth` is `false`, so `options.instructions` is never set. This causes your agent to not receive system instructions properly.\n\n## Solution\n\nThis plugin hooks into OpenCode's plugin system and injects `options.instructions` for **all** OpenAI requests, regardless of auth type.\n\n## Installation\n\n### Option 1: Via npm (Recommended)\n\n```bash\n# Install globally\nnpm install -g @angdrew/opencode-openai-instructions\n\n# Or install locally in your project\nnpm install @angdrew/opencode-openai-instructions\n```\n\nThen add to your OpenCode config (`~/.config/opencode/config.json`):\n\n```json\n{\n  \"plugins\": [\n    \"@angdrew/opencode-openai-instructions\"\n  ]\n}\n```\n\n### Option 2: Manual Installation\n\n1. Build the plugin:\n```bash\ncd openai-instructions-injector\nnpm install\nnpm run build\n```\n\n2. Copy the plugin to your OpenCode plugins directory:\n```bash\n# On macOS/Linux\ncp -r dist ~/.config/opencode/plugins/@angdrew/opencode-openai-instructions\n\n# On Windows (PowerShell)\nCopy-Item -Recurse -Path dist -Destination \"$env:USERPROFILE\\.config\\opencode\\plugins\\@angdrew\\opencode-openai-instructions\"\n```\n\n3. Enable the plugin in your OpenCode config:\n\n```json\n{\n  \"plugins\": [\n    \"@angdrew/opencode-openai-instructions\"\n  ]\n}\n```\n\n## How It Works\n\nThe plugin uses two hooks:\n\n1. **`experimental.chat.system.transform`**: Captures the system prompt array as it's being built by OpenCode\n\n2. **`chat.params`**: When the provider is OpenAI, injects the cached system prompt into `data.options.instructions`\n\nThis ensures that OpenAI always receives instructions, regardless of whether you're using OAuth or API key authentication.\n\n## Compatibility\n\n- OpenCode: >= 0.1.0\n- OpenAI Models: GPT-4, GPT-4o, GPT-3.5-turbo, etc.\n- Auth Types: OAuth, API Key, Custom endpoints\n- Node.js: >= 18.0.0\n\n## Plugin Development\n\n```bash\n# Install dependencies\nnpm install\n\n# Build\nnpm run build\n\n# Watch mode for development\nnpm run dev\n```\n\n## Contributing\n\nContributions are welcome! Please feel free to submit a Pull Request.\n\n## License\n\nMIT - See [LICENSE](./LICENSE) for details.\n\n## Related\n\n- [OpenCode](https://github.com/opencode-ai/opencode) - The AI editor\n- [OpenCode Plugins](https://docs.opencode.ai/plugins) - Plugin documentation\n","readmeFilename":"README.md"}