Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 4 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,6 @@

opencode Plugin: shows DeepSeek API balance in the TUI sidebar.

## Status

Wave P13, Beta.

## Installation

```bash
Expand All @@ -14,7 +10,7 @@ bun install @four-bytes/four-opencode-deepseek-meter

## Configuration

Requires `DEEPSEEK_API_KEY` environment variable.
Reads the DeepSeek API key from the opencode provider configuration — no `DEEPSEEK_API_KEY` env var needed.

Load in opencode via directory path (dual server + tui plugin):

Expand All @@ -28,15 +24,14 @@ Load in opencode via directory path (dual server + tui plugin):

## Usage

Start opencode and you'll see `DEEPSEEK` in the right-hand sidebar showing your current balance. Polls every 60 seconds.
Start opencode with a DeepSeek provider configured. You'll see `DEEPSEEK` in the right-hand sidebar showing your current balance. Polls every 60 seconds.

## Build

```bash
bun run build # server plugin
bun run build:tui # TUI sidebar component
bun run build
```

## License

Apache-2.0 — see [LICENSE](../LICENSE)
Apache-2.0
23 changes: 18 additions & 5 deletions bun.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 8 additions & 16 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"license": "Apache-2.0",
"type": "module",
"main": "dist/four-opencode-deepseek-meter.js",
"types": "dist/four-opencode-deepseek-meter.d.ts",
"scripts": {
"build": "NODE_ENV=production bun run scripts/build.ts",
"dev": "bun run scripts/build.ts",
Expand All @@ -19,28 +20,19 @@
"balance"
],
"exports": {
".": {
"import": "./dist/four-opencode-deepseek-meter.js"
},
"./server": {
"import": "./dist/four-opencode-deepseek-meter.js",
"config": {
"enabled": true
}
"types": "./dist/four-opencode-deepseek-meter.d.ts",
"import": "./dist/four-opencode-deepseek-meter.js"
},
"./tui": {
"import": "./dist/four-opencode-deepseek-meter-tui.jsx",
"config": {
"enabled": true,
"sidebar": true
}
"types": "./dist/tui.d.ts",
"import": "./dist/tui.jsx"
}
},
"dependencies": {
"@opencode-ai/plugin": "1.16.2",
"@opentui/core": "0.3.2",
"@opentui/solid": "0.3.2",
"solid-js": "1.9.13"
"@opencode-ai/plugin": "^1.4.3",
"@opentui/solid": "^0.2.2",
"solid-js": "^1.9.12"
},
"devDependencies": {
"@types/bun": "^1.3.8",
Expand Down
35 changes: 22 additions & 13 deletions scripts/build.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
import { rmSync } from "node:fs";

// Prune dist before building
rmSync("dist", { recursive: true, force: true });

// 1. TUI build: tsc strips types, preserves JSX → .jsx + .d.ts
// (also compiles server.ts, but Bun.build overrides it below)
await Bun.$`bunx tsc`;

// 2. Server build: Bun bundler for optimized output
const server = await Bun.build({
entrypoints: ["src/four-opencode-deepseek-meter.ts"],
outdir: "dist",
Expand All @@ -6,21 +16,20 @@ const server = await Bun.build({
minify: process.env.NODE_ENV === "production",
});

const tui = await Bun.build({
entrypoints: ["src/tui.tsx"],
outdir: "dist",
target: "bun",
naming: "four-opencode-deepseek-meter-tui.jsx",
external: ["@opencode-ai/*", "@opentui/*", "solid-js"],
minify: process.env.NODE_ENV === "production",
});

if (!server.success || !tui.success) {
for (const log of [...server.logs, ...tui.logs]) console.error(log);
if (!server.success) {
for (const log of server.logs) console.error(log);
process.exit(1);
}

for (const out of [...server.outputs, ...tui.outputs]) {
// Report outputs
for (const out of server.outputs) {
console.log(` ${out.path.padEnd(46)} ${(out.size / 1024).toFixed(2)} KB`);
}
console.log(`\n✅ Built 2 files`);
for (const f of ["dist/tui.jsx", "dist/tui.d.ts", "dist/four-opencode-deepseek-meter.d.ts"]) {
const file = Bun.file(f);
if (await file.exists()) {
const size = (await file.arrayBuffer()).byteLength;
console.log(` ${f.padEnd(46)} ${(size / 1024).toFixed(2)} KB`);
}
}
console.log(`\n✅ Built (tsc TUI + Bun server)`);
17 changes: 17 additions & 0 deletions src/server.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { describe, expect, test } from "bun:test";
import plugin from "./four-opencode-deepseek-meter.js";

describe("four-opencode-deepseek-meter", () => {
test("exports id", () => {
expect(plugin.id).toBe("four-opencode-deepseek-meter");
});

test("exports server function", () => {
expect(typeof plugin.server).toBe("function");
});

test("server returns expected shape", async () => {
const result = await (plugin.server as () => Promise<unknown>)();
expect(result).toBeDefined();
});
});
Loading
Loading