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.

6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
{
"name": "@warp-dot-dev/opencode-warp",
"version": "0.1.2",
"version": "0.1.3",
"description": "Warp terminal integration for OpenCode — native notifications and more",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"files": [
"dist"
],
"scripts": {
"build": "tsc",
"build": "rm -rf dist && tsc",
"typecheck": "tsc --noEmit",
"test": "bun test",
"dev": "echo 'Add to your opencode.json: \"plugin\": [\"file://'$(pwd)'/src/index.ts\"]' && echo 'Then run: opencode'",
"prepublishOnly": "tsc"
"prepublishOnly": "npm run build"
},
"keywords": [
"opencode",
Expand Down
11 changes: 9 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,18 @@
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"
import pkg from "../package.json" with { type: "json" }

const PLUGIN_VERSION = pkg.version
// 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

const NOTIFICATION_TITLE = "warp://cli-agent"

export function truncate(str: string, maxLen: number): string {
Expand Down
13 changes: 7 additions & 6 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 } from "../src/index"
import { truncate, extractTextFromParts, PLUGIN_VERSION } from "../src/index"
import { buildPayload } from "../src/payload"

describe("truncate", () => {
Expand Down Expand Up @@ -64,11 +64,12 @@ describe("extractTextFromParts", () => {
})

describe("PLUGIN_VERSION", () => {
it("resolves to a valid semver string from package.json", async () => {
const pkg = await import("../package.json", { with: { type: "json" } })
const version = pkg.default.version
assert.ok(typeof version === "string", "version should be a string")
assert.match(version, /^\d+\.\d+\.\d+/, "version should be semver")
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")
})
})

Expand Down
1 change: 1 addition & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"esModuleInterop": true,
"strict": true,
"resolveJsonModule": true,
"rootDir": "src",
"outDir": "dist",
"declaration": true,
"declarationMap": true,
Expand Down
Loading