@fusionkit/tool-opencode 0.1.6

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.
@@ -0,0 +1,3 @@
1
+ import type { ToolIntegration } from "@fusionkit/tools";
2
+ export declare const opencodeTool: ToolIntegration;
3
+ export { launchOpencode, opencodeConfig, opencodeModelArg } from "./launch.js";
package/dist/index.js ADDED
@@ -0,0 +1,11 @@
1
+ import { launchOpencode } from "./launch.js";
2
+ export const opencodeTool = {
3
+ id: "opencode",
4
+ displayName: "opencode",
5
+ pickerHint: "opencode CLI (local model only)",
6
+ binary: "opencode",
7
+ modes: ["local"],
8
+ harnessKinds: [],
9
+ launch: launchOpencode
10
+ };
11
+ export { launchOpencode, opencodeConfig, opencodeModelArg } from "./launch.js";
@@ -0,0 +1,7 @@
1
+ import type { ToolLaunchContext } from "@fusionkit/tools";
2
+ /** opencode config registering the gateway as an OpenAI-compatible provider. */
3
+ export declare function opencodeConfig(gatewayUrl: string, model: string): Record<string, unknown>;
4
+ /** The opencode `--model provider/model` argument for the gateway provider. */
5
+ export declare function opencodeModelArg(model: string): string;
6
+ /** Boot opencode against the gateway via an ephemeral OPENCODE_CONFIG. */
7
+ export declare function launchOpencode(ctx: ToolLaunchContext): Promise<number>;
package/dist/launch.js ADDED
@@ -0,0 +1,34 @@
1
+ import { mkdtempSync, rmSync, writeFileSync } from "node:fs";
2
+ import { tmpdir } from "node:os";
3
+ import { join } from "node:path";
4
+ import { LOCAL_MODEL_LABEL, spawnTool } from "@fusionkit/tools";
5
+ /** opencode config registering the gateway as an OpenAI-compatible provider. */
6
+ export function opencodeConfig(gatewayUrl, model) {
7
+ return {
8
+ $schema: "https://opencode.ai/config.json",
9
+ provider: {
10
+ [LOCAL_MODEL_LABEL]: {
11
+ npm: "@ai-sdk/openai-compatible",
12
+ name: "FusionKit local",
13
+ options: { baseURL: `${gatewayUrl}/v1` },
14
+ models: { [model]: { name: model } }
15
+ }
16
+ }
17
+ };
18
+ }
19
+ /** The opencode `--model provider/model` argument for the gateway provider. */
20
+ export function opencodeModelArg(model) {
21
+ return `${LOCAL_MODEL_LABEL}/${model}`;
22
+ }
23
+ /** Boot opencode against the gateway via an ephemeral OPENCODE_CONFIG. */
24
+ export async function launchOpencode(ctx) {
25
+ const dir = mkdtempSync(join(tmpdir(), "fusionkit-opencode-"));
26
+ ctx.registerDisposer(() => rmSync(dir, { recursive: true, force: true }));
27
+ const configPath = join(dir, "opencode.json");
28
+ writeFileSync(configPath, JSON.stringify(opencodeConfig(ctx.gatewayUrl, ctx.modelLabel), null, 2));
29
+ const args = ctx.toolArgs.includes("--model")
30
+ ? ctx.toolArgs
31
+ : ["--model", opencodeModelArg(ctx.modelLabel), ...ctx.toolArgs];
32
+ ctx.prepareForPassthrough();
33
+ return await spawnTool("opencode", args, { OPENCODE_CONFIG: configPath }, ctx.repo);
34
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,17 @@
1
+ import assert from "node:assert/strict";
2
+ import { test } from "node:test";
3
+ import { LOCAL_MODEL_LABEL } from "@fusionkit/tools";
4
+ import { opencodeConfig, opencodeModelArg } from "../index.js";
5
+ test("opencodeConfig registers the gateway as an OpenAI-compatible provider", () => {
6
+ const config = opencodeConfig("http://127.0.0.1:9999", "panel-model");
7
+ assert.equal(config.$schema, "https://opencode.ai/config.json");
8
+ const provider = config.provider;
9
+ const entry = provider[LOCAL_MODEL_LABEL];
10
+ assert.ok(entry, "expected a provider entry under the local model label");
11
+ assert.equal(entry.npm, "@ai-sdk/openai-compatible");
12
+ assert.deepEqual(entry.options, { baseURL: "http://127.0.0.1:9999/v1" });
13
+ assert.deepEqual(entry.models, { "panel-model": { name: "panel-model" } });
14
+ });
15
+ test("opencodeModelArg namespaces the model under the local provider", () => {
16
+ assert.equal(opencodeModelArg("panel-model"), `${LOCAL_MODEL_LABEL}/panel-model`);
17
+ });
package/package.json ADDED
@@ -0,0 +1,30 @@
1
+ {
2
+ "name": "@fusionkit/tool-opencode",
3
+ "private": false,
4
+ "version": "0.1.6",
5
+ "repository": {
6
+ "type": "git",
7
+ "url": "git+https://github.com/velum-labs/handoffkit.git",
8
+ "directory": "packages/tool-opencode"
9
+ },
10
+ "description": "opencode tool integration for fusionkit: local-model launcher config shim (no ensemble harness).",
11
+ "license": "UNLICENSED",
12
+ "type": "module",
13
+ "exports": {
14
+ ".": {
15
+ "types": "./dist/index.d.ts",
16
+ "default": "./dist/index.js"
17
+ }
18
+ },
19
+ "files": [
20
+ "dist"
21
+ ],
22
+ "publishConfig": {
23
+ "registry": "https://registry.npmjs.org",
24
+ "access": "public",
25
+ "provenance": true
26
+ },
27
+ "dependencies": {
28
+ "@fusionkit/tools": "0.1.6"
29
+ }
30
+ }