@caplets/opencode 0.0.0 → 0.1.3
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/LICENSE +21 -0
- package/README.md +5 -1
- package/dist/index.js +10 -16
- package/package.json +22 -9
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Spirit-Led Software LLC
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -10,4 +10,8 @@ This package exposes configured Caplets as native OpenCode tools named `caplets_
|
|
|
10
10
|
}
|
|
11
11
|
```
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
The plugin hot reloads Caplets config and Caplet file edits for already-registered tools, so
|
|
14
|
+
existing native tools execute against the latest valid backend config and prompt guidance is
|
|
15
|
+
rebuilt from current Caplets state for the tools registered when the plugin loaded. OpenCode's
|
|
16
|
+
current plugin API snapshots `Hooks.tool` at plugin load, so adding, removing, or renaming native
|
|
17
|
+
tools still requires restarting OpenCode; newly added tools are not advertised until restart.
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { tool } from "@opencode-ai/plugin";
|
|
2
|
-
import { createNativeCapletsService, nativeCapletsSystemGuidance } from "@caplets/core/native";
|
|
2
|
+
import { createNativeCapletsService, nativeCapletsSystemGuidance, registerNativeCapletsProcessCleanup } from "@caplets/core/native";
|
|
3
3
|
import { operations } from "@caplets/core/generated-tool-input-schema";
|
|
4
4
|
//#region src/schema.ts
|
|
5
5
|
function capletsOpenCodeArgs() {
|
|
@@ -16,36 +16,30 @@ function capletsOpenCodeArgs() {
|
|
|
16
16
|
//#region src/index.ts
|
|
17
17
|
const plugin = async (_ctx) => {
|
|
18
18
|
const service = createNativeCapletsService();
|
|
19
|
-
|
|
19
|
+
registerNativeCapletsProcessCleanup(service);
|
|
20
20
|
return createCapletsOpenCodeHooks(service);
|
|
21
21
|
};
|
|
22
22
|
async function createCapletsOpenCodeHooks(service) {
|
|
23
23
|
const capletTools = service.listTools();
|
|
24
|
-
const
|
|
24
|
+
const registeredToolNames = new Set(capletTools.map((caplet) => caplet.toolName));
|
|
25
25
|
return {
|
|
26
26
|
tool: Object.fromEntries(capletTools.map((caplet) => [caplet.toolName, tool({
|
|
27
27
|
description: caplet.description,
|
|
28
28
|
args: capletsOpenCodeArgs(),
|
|
29
29
|
async execute(args) {
|
|
30
30
|
const result = await service.execute(caplet.caplet, args);
|
|
31
|
-
|
|
31
|
+
if (typeof result === "string") return result;
|
|
32
|
+
try {
|
|
33
|
+
return JSON.stringify(result, null, 2) ?? "null";
|
|
34
|
+
} catch (error) {
|
|
35
|
+
return `[Serialization error: ${error instanceof Error ? error.message : String(error)}]`;
|
|
36
|
+
}
|
|
32
37
|
}
|
|
33
38
|
})])),
|
|
34
39
|
"experimental.chat.system.transform": async (_input, output) => {
|
|
35
|
-
output.system.push(nativeCapletsSystemGuidance(
|
|
40
|
+
output.system.push(nativeCapletsSystemGuidance(service.listTools().map((caplet) => caplet.toolName).filter((toolName) => registeredToolNames.has(toolName))));
|
|
36
41
|
}
|
|
37
42
|
};
|
|
38
43
|
}
|
|
39
|
-
function registerProcessCleanup(service) {
|
|
40
|
-
let closed = false;
|
|
41
|
-
const close = () => {
|
|
42
|
-
if (closed) return;
|
|
43
|
-
closed = true;
|
|
44
|
-
service.close();
|
|
45
|
-
};
|
|
46
|
-
process.once("beforeExit", close);
|
|
47
|
-
process.once("SIGINT", close);
|
|
48
|
-
process.once("SIGTERM", close);
|
|
49
|
-
}
|
|
50
44
|
//#endregion
|
|
51
45
|
export { createCapletsOpenCodeHooks, plugin as default };
|
package/package.json
CHANGED
|
@@ -1,7 +1,18 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@caplets/opencode",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.1.3",
|
|
4
4
|
"description": "Native OpenCode plugin for Caplets.",
|
|
5
|
+
"homepage": "https://github.com/spiritledsoftware/caplets#readme",
|
|
6
|
+
"bugs": {
|
|
7
|
+
"url": "https://github.com/spiritledsoftware/caplets/issues"
|
|
8
|
+
},
|
|
9
|
+
"license": "MIT",
|
|
10
|
+
"author": "Spirit-Led Software LLC",
|
|
11
|
+
"repository": {
|
|
12
|
+
"type": "git",
|
|
13
|
+
"url": "git+https://github.com/spiritledsoftware/caplets.git",
|
|
14
|
+
"directory": "packages/opencode"
|
|
15
|
+
},
|
|
5
16
|
"files": [
|
|
6
17
|
"dist",
|
|
7
18
|
"README.md"
|
|
@@ -11,17 +22,14 @@
|
|
|
11
22
|
"exports": {
|
|
12
23
|
".": "./dist/index.js"
|
|
13
24
|
},
|
|
14
|
-
"
|
|
15
|
-
"
|
|
16
|
-
"prepack": "pnpm build",
|
|
17
|
-
"typecheck": "tsc --noEmit",
|
|
18
|
-
"test": "vitest run"
|
|
25
|
+
"publishConfig": {
|
|
26
|
+
"access": "public"
|
|
19
27
|
},
|
|
20
28
|
"dependencies": {
|
|
21
|
-
"@caplets/core": "
|
|
22
|
-
"@opencode-ai/plugin": "^1.14.48"
|
|
29
|
+
"@caplets/core": "0.12.1"
|
|
23
30
|
},
|
|
24
31
|
"devDependencies": {
|
|
32
|
+
"@opencode-ai/plugin": "^1.14.48",
|
|
25
33
|
"@types/node": "^25.7.0",
|
|
26
34
|
"rolldown": "^1.0.0",
|
|
27
35
|
"typescript": "^6.0.3",
|
|
@@ -32,5 +40,10 @@
|
|
|
32
40
|
},
|
|
33
41
|
"engines": {
|
|
34
42
|
"node": ">=22"
|
|
43
|
+
},
|
|
44
|
+
"scripts": {
|
|
45
|
+
"build": "rm -rf dist && rolldown -c",
|
|
46
|
+
"typecheck": "tsc --noEmit",
|
|
47
|
+
"test": "vitest run"
|
|
35
48
|
}
|
|
36
|
-
}
|
|
49
|
+
}
|