|
| 1 | +# Installing Purchasely AI Plugin in OpenCode |
| 2 | + |
| 3 | +This guide walks you through adding the Purchasely AI Plugin to your [OpenCode](https://opencode.ai) setup. Once installed, OpenCode loads the Purchasely skills (`integrate`, `review`, `debug`) and the `sdk-expert` agent automatically. |
| 4 | + |
| 5 | +## Prerequisites |
| 6 | + |
| 7 | +- OpenCode installed and configured (`opencode --version`). |
| 8 | +- Node.js ≥ 18 (OpenCode plugin loader requirement). |
| 9 | +- Git available on `PATH` (the plugin is fetched directly from the GitHub repository). |
| 10 | +- An OpenCode project — i.e. a directory with an `opencode.json` (or willingness to create one). |
| 11 | + |
| 12 | +## Installation |
| 13 | + |
| 14 | +Add the plugin entry to your project's `opencode.json`: |
| 15 | + |
| 16 | +```json |
| 17 | +{ |
| 18 | + "plugin": ["purchasely@git+https://github.com/Purchasely/Purchasely-AI-Plugin.git"] |
| 19 | +} |
| 20 | +``` |
| 21 | + |
| 22 | +If you already have other plugins listed, append the entry to the existing `"plugin"` array — do not overwrite it. |
| 23 | + |
| 24 | +The next time you launch OpenCode in this project, the plugin is fetched, cached, and loaded automatically. No manual `cp` of configs, no symlinks. |
| 25 | + |
| 26 | +## Usage |
| 27 | + |
| 28 | +After installation, ask OpenCode anything about the Purchasely SDK: |
| 29 | + |
| 30 | +``` |
| 31 | +You: Tell me about your Purchasely skills. |
| 32 | +OpenCode: I have three task-scoped skills (integrate, review, debug) |
| 33 | + and a free-form Q&A command (/purchasely:question) for the |
| 34 | + Purchasely SDK on iOS, Android, React Native, Flutter, and Cordova. |
| 35 | +``` |
| 36 | + |
| 37 | +Other examples: |
| 38 | + |
| 39 | +- `Integrate the Purchasely SDK into this iOS app.` |
| 40 | +- `Review my Purchasely integration for common mistakes.` |
| 41 | +- `Debug why my paywall shows blank.` |
| 42 | +- `How do I display a Purchasely paywall in SwiftUI?` |
| 43 | + |
| 44 | +## Updating |
| 45 | + |
| 46 | +OpenCode honors the version pin in `opencode.json`. To pull the latest changes from `main`: |
| 47 | + |
| 48 | +```bash |
| 49 | +# Re-fetch the plugin (clears the cache for this entry) |
| 50 | +opencode plugin update purchasely |
| 51 | +``` |
| 52 | + |
| 53 | +If your version of OpenCode does not expose `plugin update`, remove the plugin cache directory (`~/.opencode/plugins/purchasely/`) and relaunch. |
| 54 | + |
| 55 | +To pin to a specific tag or commit, change the spec to: |
| 56 | + |
| 57 | +```json |
| 58 | +{ "plugin": ["purchasely@git+https://github.com/Purchasely/Purchasely-AI-Plugin.git#v1.0.0"] } |
| 59 | +``` |
| 60 | + |
| 61 | +## Troubleshooting |
| 62 | + |
| 63 | +### Plugin not loading |
| 64 | + |
| 65 | +1. Confirm `opencode.json` is valid JSON (no trailing commas, no comments). |
| 66 | +2. Run OpenCode with verbose logging: `opencode --log-level debug` and look for `plugin: purchasely` lines. |
| 67 | +3. Make sure git can reach `github.com` from the machine running OpenCode — `git ls-remote https://github.com/Purchasely/Purchasely-AI-Plugin.git` should print refs. |
| 68 | + |
| 69 | +### Windows install issues |
| 70 | + |
| 71 | +The `git+` spec requires git on `PATH` and write access to the user-level OpenCode cache. If install fails with `EACCES` or `EPERM`: |
| 72 | + |
| 73 | +```powershell |
| 74 | +# Install the plugin into a writable location explicitly |
| 75 | +npm install --prefix %USERPROFILE%\.opencode\plugins git+https://github.com/Purchasely/Purchasely-AI-Plugin.git |
| 76 | +``` |
| 77 | + |
| 78 | +Then point `opencode.json` at the local copy: |
| 79 | + |
| 80 | +```json |
| 81 | +{ "plugin": ["purchasely@file:%USERPROFILE%/.opencode/plugins/node_modules/purchasely"] } |
| 82 | +``` |
| 83 | + |
| 84 | +### Skills not found |
| 85 | + |
| 86 | +If `/purchasely:integrate` (or asking "use the integrate skill") returns "skill not found": |
| 87 | + |
| 88 | +1. Check that OpenCode loaded the plugin (see verbose logs above). |
| 89 | +2. Confirm the cached plugin contains `skills/integrate/SKILL.md`, `skills/review/SKILL.md`, `skills/debug/SKILL.md`. If the cache looks empty or stale, remove it and relaunch. |
| 90 | +3. Verify the plugin version in `opencode.json` is recent enough to include the skill set (≥ `1.0.0`). |
| 91 | + |
| 92 | +## See also |
| 93 | + |
| 94 | +- [Purchasely AI Plugin README](../README.md) — overview and per-harness Quickstart. |
| 95 | +- [Purchasely SDK documentation](https://docs.purchasely.com). |
| 96 | +- [OpenCode documentation](https://opencode.ai/docs). |
0 commit comments