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
4 changes: 2 additions & 2 deletions package-lock.json

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

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@warp-dot-dev/opencode-warp",
"version": "0.1.3",
"version": "0.1.4",
"description": "Warp terminal integration for OpenCode — native notifications and more",
"main": "dist/index.js",
"types": "dist/index.d.ts",
Expand Down
14 changes: 5 additions & 9 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,14 @@
import type { Plugin } from "@opencode-ai/plugin"
import type { Event, Part, Permission } from "@opencode-ai/sdk"
import { readFileSync } from "node:fs"

import { buildPayload } from "./payload"
import { warpNotify } from "./notify"

// Read the version at runtime instead of `import pkg from "../package.json"`.
// An import would pull package.json into tsc's compilation roots and shift
// output paths (e.g. dist/src/index.js instead of dist/index.js).
const pkg = JSON.parse(
readFileSync(new URL("../package.json", import.meta.url), "utf8"),
) as { version: string }
export const PLUGIN_VERSION = pkg.version

// Must be kept in sync with the "version" field in package.json.
// NOTE: do not `export` this constant — opencode's legacy plugin loader
// treats every named export as a plugin function and throws if any export
// is not a function ("Plugin export is not a function").
const PLUGIN_VERSION = "0.1.4"
const NOTIFICATION_TITLE = "warp://cli-agent"

export function truncate(str: string, maxLen: number): string {
Expand Down
12 changes: 1 addition & 11 deletions tests/index.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { describe, it } from "node:test"
import assert from "node:assert/strict"
import { truncate, extractTextFromParts, PLUGIN_VERSION } from "../src/index"
import { truncate, extractTextFromParts } from "../src/index"
import { buildPayload } from "../src/payload"

describe("truncate", () => {
Expand Down Expand Up @@ -63,16 +63,6 @@ describe("extractTextFromParts", () => {
})
})

describe("PLUGIN_VERSION", () => {
it("resolves to a valid semver string from package.json", () => {
assert.ok(
typeof PLUGIN_VERSION === "string",
"PLUGIN_VERSION should be a string",
)
assert.match(PLUGIN_VERSION, /^\d+\.\d+\.\d+/, "version should be semver")
})
})

describe("question_asked event", () => {
it("builds a valid question_asked payload", () => {
const payload = JSON.parse(
Expand Down
Loading