@telefonica/ai-sdlc-opencode-plugin-v1-dev 0.1.0-snapshot.35846538366 → 0.1.0-snapshot.35850785707

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.
Files changed (2) hide show
  1. package/README.md +14 -113
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -1,124 +1,25 @@
1
1
  # @telefonica/ai-sdlc-opencode-plugin-v1
2
2
 
3
- CDO.AI gateway plugin for **OpenCode 1.x**. Registers the gateway as a provider,
4
- discovers its models, and renders remaining budget in the sidebar.
3
+ CDO.AI gateway plugin for OpenCode 1.x.
5
4
 
6
- For installation and the `/connect` walkthrough, see the
7
- [plugins README](../../README.md). This file covers the internals.
5
+ ## Install
8
6
 
9
- > Using OpenCode 2.x? Install [`@telefonica/ai-sdlc-opencode-plugin-v2`](../v2)
10
- > instead — the two major versions have incompatible plugin APIs.
7
+ Add the package to both OpenCode configuration files:
11
8
 
12
- ## What it provides
13
-
14
- Two flavors are published as separate packages, each built into
15
- `plugin-dist/<flavor>/` with its own generated manifest — the same layout the v2
16
- plugin uses.
17
-
18
- | Package | Provider id | Shown in `/connect` as |
19
- | --- | --- | --- |
20
- | `@telefonica/ai-sdlc-opencode-plugin-v1` | `cdo-ai` | CDO.AI |
21
- | `@telefonica/ai-sdlc-opencode-plugin-v1-dev` | `cdo-ai-dev` | CDO.AI (dev) |
22
-
23
- Each package exposes two entry points, which OpenCode resolves independently:
24
-
25
- | Export | Built file | Role |
26
- | --- | --- | --- |
27
- | `./server` | `dist/index.js` | Provider registration, `/connect` auth, model discovery |
28
- | `./tui` | `dist/tui.js` | Sidebar budget panel |
29
-
30
- Only `exports["./server"]` and `exports["./tui"]` are consulted. OpenCode never
31
- reads `exports["."]`, and a `main` field would be picked up as an additional
32
- server entry point, so neither is declared.
33
-
34
- The production panel also covers the hand-written `litellm*` providers from the
35
- older manual setup, so the budget display keeps working while users migrate. The
36
- dev panel matches only `cdo-ai-dev`, so installing both packages does not produce
37
- two panels for the same gateway.
38
-
39
- ## Architecture notes
40
-
41
- These are load-bearing constraints of the OpenCode 1.x plugin API. They look
42
- arbitrary in isolation, so they are recorded here.
43
-
44
- **Models come from the `config` hook, not the `provider.models` hook.** OpenCode
45
- invokes `provider.models` before config-declared providers exist, so it never
46
- fires for a provider that is not in the models.dev catalog. Discovery therefore
47
- happens in the `config` hook, which is async and may perform network calls.
48
-
49
- **A provider with no models is discarded.** OpenCode deletes any provider whose
50
- model map is empty before `/connect` renders, so the config hook seeds a
51
- placeholder entry that is replaced once discovery succeeds.
52
-
53
- **`/connect` does not call `authorize()` for API-key methods.** Values collected
54
- by `prompts` are stored as credential metadata and the key itself is collected by
55
- a separate built-in step. The auth method therefore prompts only for the gateway
56
- URL, and `auth.loader` recombines the stored URL and key into provider options.
57
-
58
- **Credentials are read from disk.** Stored auth is not exposed in-process when
59
- the config hook runs, so it reads `auth.json` directly. Resolution order is
60
- config `options`, then environment variables, then `auth.json`. Resolved values
61
- are written back into `options` because a fully custom provider builds its
62
- completion client from them directly.
63
-
64
- **One environment per package.** `Hooks.auth` binds a single provider id, so each
65
- environment needs its own plugin instance. Rather than smuggling both into one
66
- module, each flavor is built and published separately, which keeps the plain
67
- default-export plugin module shape and matches the v2 plugin.
68
-
69
- ## Layout
70
-
71
- ```
72
- src/
73
- ├── flavor.ts # prod/dev ids and labels, mirroring the v2 plugin
74
- ├── entry-prod.ts # server entry, prod -> dist/index.js
75
- ├── entry-dev.ts # server entry, dev -> dist/index.js
76
- ├── tui-prod.tsx # TUI entry, prod -> dist/tui.js
77
- ├── tui-dev.tsx # TUI entry, dev -> dist/tui.js
78
- ├── tui.tsx # sidebar slot registration and budget polling
79
- ├── components.tsx # budget panel rendering
80
- ├── usage-client.ts # /v1/usage fetch for the budget panel
81
- └── server/
82
- ├── plugin.ts # assembles the hooks for a flavor
83
- ├── config-hook.ts # provider registration and model discovery
84
- ├── auth-hook.ts # /connect prompts and credential loading
85
- ├── credentials.ts # config / env / auth.json resolution
86
- ├── models-client.ts # /v1/models and /v1/model/info
87
- ├── model-cache.ts # 7-day on-disk model cache
88
- └── constants.ts
89
- ```
90
-
91
- `FLAVOR=dev|prod` is the only build flag. Every identity string lives in
92
- `src/flavor.ts`; there is no runtime environment lookup.
93
-
94
- ## Develop
95
-
96
- ```bash
97
- npm ci
98
- npm run build:prod # writes plugin-dist/prod/dist/
99
- npm run build:dev # writes plugin-dist/dev/dist/
100
- npm run build # both
101
- ```
102
-
103
- Point OpenCode at a built flavor to try it:
9
+ - `~/.config/opencode/opencode.jsonc`
10
+ - `~/.config/opencode/tui.jsonc`
104
11
 
105
12
  ```jsonc
106
- { "plugin": ["/absolute/path/to/plugins/opencode/v1/plugin-dist/prod"] }
13
+ {
14
+ "$schema": "https://opencode.ai/config.json",
15
+ "plugin": ["@telefonica/ai-sdlc-opencode-plugin-v1"]
16
+ }
107
17
  ```
108
18
 
109
- For OpenCode 1.x, put this entry in both `opencode.jsonc` and `tui.jsonc`.
110
- The server and TUI plugin loaders use separate config files.
111
-
112
- Build before launching — OpenCode installs plugins with scripts disabled and will
113
- not build the package for you. Quit OpenCode fully between attempts, since a
114
- plugin that fails to load stays cached for the lifetime of the process.
115
-
116
- ## Release
19
+ For the development gateway, use
20
+ `@telefonica/ai-sdlc-opencode-plugin-v1-dev` in both files.
117
21
 
118
- Published by `.github/workflows/opencode-plugin-release.yml` via
119
- `semantic-release`, tagged `opencode-v1@<version>`.
22
+ Restart OpenCode, run `/connect`, choose **CDO.AI**, and enter the gateway URL
23
+ and API key. Restart OpenCode once more after connecting so the model list loads.
120
24
 
121
- `plugin-dist/` is a build output directory and is not committed. The release
122
- `prepareCmd` builds both flavors and then runs `scripts/write-manifests.js`,
123
- which generates each publish manifest; `publishCmd` publishes both. The root
124
- package is `private` and exists only to hold the sources and release config.
25
+ Using OpenCode 2.x? Install `@telefonica/ai-sdlc-opencode-plugin-v2` instead.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@telefonica/ai-sdlc-opencode-plugin-v1-dev",
3
- "version": "0.1.0-snapshot.35846538366",
3
+ "version": "0.1.0-snapshot.35850785707",
4
4
  "description": "OpenCode 1.x plugin (dev environment): CDO.AI provider registration, model discovery, and budget panel",
5
5
  "type": "module",
6
6
  "exports": {