@mcowger/pi-plexus 0.6.0 → 0.8.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +111 -17
- package/dist/extension.js +5 -3
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -2,32 +2,39 @@
|
|
|
2
2
|
|
|
3
3
|
Exposes models from a self-hosted [Plexus](https://github.com/mcowger/plexus) AI proxy as a first-class provider inside AI coding agents. Models appear in the agent's model picker with correct wire-protocol behavior, as if they were natively supported providers.
|
|
4
4
|
|
|
5
|
+
## Supported agents
|
|
6
|
+
|
|
7
|
+
| Package | Agent | npm |
|
|
8
|
+
|---|---|---|
|
|
9
|
+
| `plexus-pi` | [pi](https://github.com/earendil-works/pi) | `@mcowger/pi-plexus` |
|
|
10
|
+
| `plexus-opencode` | [OpenCode](https://opencode.ai) | `@mcowger/opencode-plexus` |
|
|
11
|
+
|
|
5
12
|
## Prerequisites
|
|
6
13
|
|
|
7
14
|
- A running Plexus instance
|
|
8
15
|
|
|
9
16
|
## Installation
|
|
10
17
|
|
|
11
|
-
The built
|
|
18
|
+
The built dist artifact is committed to the repo, so no build step is needed for any install method.
|
|
19
|
+
|
|
20
|
+
---
|
|
21
|
+
|
|
22
|
+
### pi
|
|
12
23
|
|
|
13
|
-
|
|
24
|
+
#### Option 1 — npm (recommended)
|
|
14
25
|
|
|
15
26
|
```sh
|
|
16
27
|
cd ~/.pi/agent/extensions
|
|
17
28
|
npm install @mcowger/pi-plexus
|
|
18
29
|
```
|
|
19
30
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
### Option 2 — git clone into the extensions directory
|
|
31
|
+
#### Option 2 — git clone into the extensions directory
|
|
23
32
|
|
|
24
33
|
```sh
|
|
25
34
|
git clone https://github.com/mcowger/plexus-agent-plugins ~/.pi/agent/extensions/plexus-agent-plugins
|
|
26
35
|
```
|
|
27
36
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
### Option 3 — git clone anywhere + settings.json
|
|
37
|
+
#### Option 3 — git clone anywhere + settings.json
|
|
31
38
|
|
|
32
39
|
```sh
|
|
33
40
|
git clone https://github.com/mcowger/plexus-agent-plugins ~/code/plexus-agent-plugins
|
|
@@ -43,9 +50,45 @@ Then register the path in `~/.pi/agent/settings.json`:
|
|
|
43
50
|
}
|
|
44
51
|
```
|
|
45
52
|
|
|
53
|
+
---
|
|
54
|
+
|
|
55
|
+
### OpenCode
|
|
56
|
+
|
|
57
|
+
#### Option 1 — npm (recommended)
|
|
58
|
+
|
|
59
|
+
```sh
|
|
60
|
+
npm install -g @mcowger/opencode-plexus
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
Then add the plugin to your `opencode.json`:
|
|
64
|
+
|
|
65
|
+
```json
|
|
66
|
+
{
|
|
67
|
+
"plugins": ["@mcowger/opencode-plexus"]
|
|
68
|
+
}
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
#### Option 2 — path reference
|
|
72
|
+
|
|
73
|
+
```sh
|
|
74
|
+
git clone https://github.com/mcowger/plexus-agent-plugins ~/code/plexus-agent-plugins
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
Then reference the built artifact in `opencode.json`:
|
|
78
|
+
|
|
79
|
+
```json
|
|
80
|
+
{
|
|
81
|
+
"plugins": ["~/code/plexus-agent-plugins/packages/plexus-opencode/dist/index.js"]
|
|
82
|
+
}
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
---
|
|
86
|
+
|
|
46
87
|
## First-time setup
|
|
47
88
|
|
|
48
|
-
|
|
89
|
+
### pi
|
|
90
|
+
|
|
91
|
+
Run inside pi:
|
|
49
92
|
|
|
50
93
|
```
|
|
51
94
|
/plexus login
|
|
@@ -57,19 +100,47 @@ You will be prompted for:
|
|
|
57
100
|
- **Plexus API key**
|
|
58
101
|
- **Default model** (optional)
|
|
59
102
|
|
|
60
|
-
|
|
103
|
+
To force a model refresh:
|
|
104
|
+
|
|
105
|
+
```
|
|
106
|
+
/plexus refresh
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
### OpenCode
|
|
110
|
+
|
|
111
|
+
Run inside OpenCode:
|
|
61
112
|
|
|
62
|
-
|
|
113
|
+
```
|
|
114
|
+
/connect
|
|
115
|
+
```
|
|
63
116
|
|
|
64
|
-
|
|
117
|
+
Select **Plexus** and enter your base URL and API key. Models are loaded immediately and cached for fast startup on subsequent sessions.
|
|
65
118
|
|
|
119
|
+
For OpenCode, enter the Plexus API base URL including the trailing `/v1`, for example:
|
|
120
|
+
|
|
121
|
+
```text
|
|
122
|
+
https://plexus.example.com/v1
|
|
66
123
|
```
|
|
67
|
-
|
|
124
|
+
|
|
125
|
+
The OpenCode plugin respects each model's `preferred_api` value and routes models through the matching SDK/API shape:
|
|
126
|
+
|
|
127
|
+
- `chat_completions` / `openai-completions` → OpenAI-compatible chat completions
|
|
128
|
+
- `responses` / `openai-responses` → OpenAI Responses API
|
|
129
|
+
- `messages` / `anthropic-messages` → Anthropic Messages API
|
|
130
|
+
- `gemini` / `google-generative-ai` → Google Gemini API
|
|
131
|
+
|
|
132
|
+
You can also pre-configure via environment variables:
|
|
133
|
+
|
|
134
|
+
```sh
|
|
135
|
+
export PLEXUS_BASE_URL=https://plexus.example.com/v1
|
|
136
|
+
export PLEXUS_API_KEY=your-api-key
|
|
68
137
|
```
|
|
69
138
|
|
|
139
|
+
---
|
|
140
|
+
|
|
70
141
|
## Configuration files
|
|
71
142
|
|
|
72
|
-
|
|
143
|
+
### pi
|
|
73
144
|
|
|
74
145
|
```
|
|
75
146
|
~/.pi/agent/extensions/plexus/
|
|
@@ -79,7 +150,19 @@ All files live under the agent's data directory:
|
|
|
79
150
|
plexus.log # extension activity log
|
|
80
151
|
```
|
|
81
152
|
|
|
82
|
-
The API key is stored in pi's own
|
|
153
|
+
The API key is stored in pi's own credential store (`auth.json`) — never in a separate file.
|
|
154
|
+
|
|
155
|
+
### OpenCode
|
|
156
|
+
|
|
157
|
+
```
|
|
158
|
+
~/.local/share/opencode/plugins/plexus/
|
|
159
|
+
models-cache.json # last-fetched model list (startup cache)
|
|
160
|
+
models-raw.json # raw API response (diagnostics)
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
The API key is stored in OpenCode's own credential store — never in a separate file.
|
|
164
|
+
|
|
165
|
+
---
|
|
83
166
|
|
|
84
167
|
## Package layout
|
|
85
168
|
|
|
@@ -98,9 +181,20 @@ packages/
|
|
|
98
181
|
cache.ts # model cache I/O
|
|
99
182
|
log.ts # append-only log
|
|
100
183
|
package.json # declares pi.extensions entry point
|
|
184
|
+
plexus-opencode/ # OpenCode plugin adapter
|
|
185
|
+
src/
|
|
186
|
+
plugin.ts # Plugin export: config hook, auth handler
|
|
187
|
+
mapper.ts # PlexusApiModel → OpenCode ConfigModel
|
|
188
|
+
cache.ts # model cache I/O
|
|
189
|
+
config-store.ts # resolveConfig, persistToGlobalConfig
|
|
190
|
+
log.ts # logger via OpenCode SDK
|
|
191
|
+
constants.ts # provider ID, env var names, timeouts
|
|
192
|
+
url.ts # URL helpers (trimURL, apiBase, modelsUrl)
|
|
193
|
+
index.ts # barrel export
|
|
194
|
+
package.json # npm package manifest
|
|
101
195
|
```
|
|
102
196
|
|
|
103
|
-
`plexus-models` has zero imports from any agent framework.
|
|
197
|
+
`plexus-models` has zero imports from any agent framework. Each host adapter imports it via a relative path.
|
|
104
198
|
|
|
105
199
|
## Development
|
|
106
200
|
|
|
@@ -110,6 +204,6 @@ After cloning, install dependencies to set up the pre-commit hook:
|
|
|
110
204
|
bun install
|
|
111
205
|
```
|
|
112
206
|
|
|
113
|
-
The pre-commit hook (via lefthook) rebuilds
|
|
207
|
+
The pre-commit hook (via lefthook) rebuilds both dist artifacts automatically whenever source files change. After committing, reload/restart your agent.
|
|
114
208
|
|
|
115
209
|
To add support for a new host agent, see [AGENTS.md](AGENTS.md).
|
package/dist/extension.js
CHANGED
|
@@ -3,9 +3,13 @@
|
|
|
3
3
|
var REASONING_PARAMS = new Set(["reasoning", "include_reasoning", "reasoning_effort"]);
|
|
4
4
|
var API_DIALECT_MAP = {
|
|
5
5
|
chat_completions: "openai-completions",
|
|
6
|
+
"openai-completions": "openai-completions",
|
|
6
7
|
messages: "anthropic-messages",
|
|
8
|
+
"anthropic-messages": "anthropic-messages",
|
|
7
9
|
gemini: "google-generative-ai",
|
|
8
|
-
|
|
10
|
+
"google-generative-ai": "google-generative-ai",
|
|
11
|
+
responses: "openai-responses",
|
|
12
|
+
"openai-responses": "openai-responses"
|
|
9
13
|
};
|
|
10
14
|
function mapPreferredApi(raw) {
|
|
11
15
|
if (raw === undefined)
|
|
@@ -21,8 +25,6 @@ function mapPreferredApi(raw) {
|
|
|
21
25
|
function adjustBaseUrl(baseUrl, preferredApi) {
|
|
22
26
|
const stripped = baseUrl.replace(/\/+$/, "");
|
|
23
27
|
switch (preferredApi) {
|
|
24
|
-
case "anthropic-messages":
|
|
25
|
-
return stripped.endsWith("/v1") ? stripped.slice(0, -3) : stripped;
|
|
26
28
|
case "google-generative-ai":
|
|
27
29
|
return stripped.endsWith("/v1") ? `${stripped.slice(0, -3)}/v1beta` : stripped;
|
|
28
30
|
default:
|