Skip to content

Commit 1dc4769

Browse files
authored
fix bad exported fn (#14)
1 parent f0a013f commit 1dc4769

4 files changed

Lines changed: 9 additions & 23 deletions

File tree

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@warp-dot-dev/opencode-warp",
3-
"version": "0.1.3",
3+
"version": "0.1.4",
44
"description": "Warp terminal integration for OpenCode — native notifications and more",
55
"main": "dist/index.js",
66
"types": "dist/index.d.ts",

src/index.ts

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,14 @@
11
import type { Plugin } from "@opencode-ai/plugin"
22
import type { Event, Part, Permission } from "@opencode-ai/sdk"
3-
import { readFileSync } from "node:fs"
43

54
import { buildPayload } from "./payload"
65
import { warpNotify } from "./notify"
76

8-
// Read the version at runtime instead of `import pkg from "../package.json"`.
9-
// An import would pull package.json into tsc's compilation roots and shift
10-
// output paths (e.g. dist/src/index.js instead of dist/index.js).
11-
const pkg = JSON.parse(
12-
readFileSync(new URL("../package.json", import.meta.url), "utf8"),
13-
) as { version: string }
14-
export const PLUGIN_VERSION = pkg.version
15-
7+
// Must be kept in sync with the "version" field in package.json.
8+
// NOTE: do not `export` this constant — opencode's legacy plugin loader
9+
// treats every named export as a plugin function and throws if any export
10+
// is not a function ("Plugin export is not a function").
11+
const PLUGIN_VERSION = "0.1.4"
1612
const NOTIFICATION_TITLE = "warp://cli-agent"
1713

1814
export function truncate(str: string, maxLen: number): string {

tests/index.test.ts

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { describe, it } from "node:test"
22
import assert from "node:assert/strict"
3-
import { truncate, extractTextFromParts, PLUGIN_VERSION } from "../src/index"
3+
import { truncate, extractTextFromParts } from "../src/index"
44
import { buildPayload } from "../src/payload"
55

66
describe("truncate", () => {
@@ -63,16 +63,6 @@ describe("extractTextFromParts", () => {
6363
})
6464
})
6565

66-
describe("PLUGIN_VERSION", () => {
67-
it("resolves to a valid semver string from package.json", () => {
68-
assert.ok(
69-
typeof PLUGIN_VERSION === "string",
70-
"PLUGIN_VERSION should be a string",
71-
)
72-
assert.match(PLUGIN_VERSION, /^\d+\.\d+\.\d+/, "version should be semver")
73-
})
74-
})
75-
7666
describe("question_asked event", () => {
7767
it("builds a valid question_asked payload", () => {
7868
const payload = JSON.parse(

0 commit comments

Comments
 (0)