@caplets/opencode 0.2.0 → 0.4.0
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 +13 -7
- package/dist/index.js +19 -4
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -4,6 +4,8 @@ Native OpenCode plugin for Caplets.
|
|
|
4
4
|
|
|
5
5
|
This package exposes configured Caplets as native OpenCode tools named `caplets_<id>`. It does not start the Caplets MCP server and does not edit `opencode.json`; prompt guidance is injected through OpenCode plugin hooks.
|
|
6
6
|
|
|
7
|
+
MCP-backed Caplets advertise resource, prompt, template, and completion operations in their generated schema; OpenAPI, GraphQL, HTTP, CLI, and Caplet-set backends remain tool/action-only.
|
|
8
|
+
|
|
7
9
|
```jsonc
|
|
8
10
|
{
|
|
9
11
|
"plugin": ["@caplets/opencode"],
|
|
@@ -21,15 +23,16 @@ tools still requires restarting OpenCode; newly added tools are not advertised u
|
|
|
21
23
|
By default the plugin reads local Caplets config. To use a remote `caplets serve --transport http` service, set environment variables:
|
|
22
24
|
|
|
23
25
|
```sh
|
|
24
|
-
|
|
26
|
+
CAPLETS_MODE=remote CAPLETS_SERVER_URL=http://127.0.0.1:5387/caplets opencode
|
|
25
27
|
```
|
|
26
28
|
|
|
27
29
|
For authenticated remote services, keep the password in the environment:
|
|
28
30
|
|
|
29
31
|
```sh
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
32
|
+
CAPLETS_MODE=remote \
|
|
33
|
+
CAPLETS_SERVER_URL=https://caplets.example.com/caplets \
|
|
34
|
+
CAPLETS_SERVER_USER=caplets \
|
|
35
|
+
CAPLETS_SERVER_PASSWORD=... \
|
|
33
36
|
opencode
|
|
34
37
|
```
|
|
35
38
|
|
|
@@ -42,14 +45,17 @@ export default {
|
|
|
42
45
|
"@caplets/opencode",
|
|
43
46
|
{
|
|
44
47
|
mode: "remote",
|
|
45
|
-
|
|
46
|
-
url: "https://caplets.example.com/
|
|
48
|
+
server: {
|
|
49
|
+
url: "https://caplets.example.com/caplets",
|
|
47
50
|
user: "caplets",
|
|
48
51
|
},
|
|
52
|
+
remote: {
|
|
53
|
+
pollIntervalMs: 5_000,
|
|
54
|
+
},
|
|
49
55
|
},
|
|
50
56
|
],
|
|
51
57
|
],
|
|
52
58
|
};
|
|
53
59
|
```
|
|
54
60
|
|
|
55
|
-
Plugin config overrides environment variables. Prefer `
|
|
61
|
+
Plugin config overrides environment variables. The explicit config shape is `{ mode, server: { url, user }, remote: { pollIntervalMs } }`. Prefer `CAPLETS_SERVER_PASSWORD` for the Basic Auth password unless your OpenCode setup provides secure secret storage.
|
package/dist/index.js
CHANGED
|
@@ -2,14 +2,28 @@ import { createNativeCapletsService, nativeCapletsSystemGuidance, registerNative
|
|
|
2
2
|
import { tool } from "@opencode-ai/plugin";
|
|
3
3
|
import { operations } from "@caplets/core/generated-tool-input-schema";
|
|
4
4
|
//#region src/schema.ts
|
|
5
|
-
function capletsOpenCodeArgs() {
|
|
5
|
+
function capletsOpenCodeArgs(operationNames = [...operations]) {
|
|
6
|
+
const enumValues = operationNames.length > 0 ? operationNames : [...operations];
|
|
6
7
|
return {
|
|
7
|
-
operation: tool.schema.enum(
|
|
8
|
+
operation: tool.schema.enum(enumValues),
|
|
8
9
|
query: tool.schema.string().optional(),
|
|
9
10
|
limit: tool.schema.number().int().positive().optional(),
|
|
10
11
|
tool: tool.schema.string().optional(),
|
|
11
12
|
arguments: tool.schema.record(tool.schema.string(), tool.schema.unknown()).optional(),
|
|
12
|
-
fields: tool.schema.array(tool.schema.string().min(1)).min(1).optional()
|
|
13
|
+
fields: tool.schema.array(tool.schema.string().min(1)).min(1).optional(),
|
|
14
|
+
uri: tool.schema.string().optional(),
|
|
15
|
+
prompt: tool.schema.string().optional(),
|
|
16
|
+
ref: tool.schema.union([tool.schema.object({
|
|
17
|
+
type: tool.schema.literal("prompt"),
|
|
18
|
+
name: tool.schema.string().min(1)
|
|
19
|
+
}).strict(), tool.schema.object({
|
|
20
|
+
type: tool.schema.literal("resourceTemplate"),
|
|
21
|
+
uri: tool.schema.string().min(1)
|
|
22
|
+
}).strict()]).optional(),
|
|
23
|
+
argument: tool.schema.object({
|
|
24
|
+
name: tool.schema.string().min(1),
|
|
25
|
+
value: tool.schema.string()
|
|
26
|
+
}).strict().optional()
|
|
13
27
|
};
|
|
14
28
|
}
|
|
15
29
|
//#endregion
|
|
@@ -20,7 +34,7 @@ async function createCapletsOpenCodeHooks(service) {
|
|
|
20
34
|
return {
|
|
21
35
|
tool: Object.fromEntries(capletTools.map((caplet) => [caplet.toolName, tool({
|
|
22
36
|
description: caplet.description,
|
|
23
|
-
args: capletsOpenCodeArgs(),
|
|
37
|
+
args: capletsOpenCodeArgs(caplet.operationNames ?? void 0),
|
|
24
38
|
async execute(args) {
|
|
25
39
|
return compactOpenCodeResult(await service.execute(caplet.caplet, args));
|
|
26
40
|
}
|
|
@@ -56,6 +70,7 @@ function normalizeOpenCodeConfig(config) {
|
|
|
56
70
|
if (!config) return {};
|
|
57
71
|
return {
|
|
58
72
|
...config.mode ? { mode: config.mode } : {},
|
|
73
|
+
...config.server ? { server: config.server } : {},
|
|
59
74
|
...config.remote ? { remote: config.remote } : {}
|
|
60
75
|
};
|
|
61
76
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@caplets/opencode",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"description": "Native OpenCode plugin for Caplets.",
|
|
5
5
|
"homepage": "https://github.com/spiritledsoftware/caplets#readme",
|
|
6
6
|
"bugs": {
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
"access": "public"
|
|
27
27
|
},
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@caplets/core": "0.
|
|
29
|
+
"@caplets/core": "0.18.0"
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
32
32
|
"@types/node": "^25.9.0",
|