From bb8067ba2308e58b3e64d20f21d45729b37f9c5f Mon Sep 17 00:00:00 2001 From: Robespierred0p <64637841+Robespierred0p@users.noreply.github.com> Date: Tue, 2 Jun 2026 21:03:08 +0200 Subject: [PATCH 1/2] fix: add .js extensions to relative imports so the plugin loads under ESM The compiled dist/index.js used extensionless relative imports (e.g. "./src/push/formatter") because tsconfig uses moduleResolution "bundler". OpenCode's strict ESM plugin loader requires explicit extensions and throws "Cannot find module", so the plugin failed to load entirely. Add .js to all relative imports in the plugin runtime graph (index.ts, src/push/*, src/tunnel/*, src/utils, src/proxy). The src/cli/* files already used .js. Co-Authored-By: Claude Opus 4.8 --- index.ts | 18 +++++++++--------- src/proxy/index.ts | 2 +- src/push/formatter.ts | 6 +++--- src/push/index.ts | 10 +++++----- src/push/sender.ts | 4 ++-- src/push/token-store.ts | 2 +- src/tunnel/cloudflare.ts | 2 +- src/tunnel/index.ts | 10 +++++----- src/tunnel/localtunnel.ts | 2 +- src/tunnel/ngrok.ts | 2 +- src/utils/index.ts | 2 +- 11 files changed, 30 insertions(+), 30 deletions(-) diff --git a/index.ts b/index.ts index 47889cb..4aee31f 100644 --- a/index.ts +++ b/index.ts @@ -40,15 +40,15 @@ import http from "http"; import { tool } from "@opencode-ai/plugin"; import type { Plugin } from "@opencode-ai/plugin"; -import type { PushToken } from "./src/push"; -import { formatNotification } from "./src/push/formatter"; -import { sendPush } from "./src/push/sender"; -import { loadTokens, saveTokens } from "./src/push/token-store"; -import { startLocaltunnel, stopLocaltunnel, getLocaltunnelUrl } from "./src/tunnel/localtunnel"; -import { displayQRCode, generateQRCodeAscii, generateQRCodeAsciiPlain } from "./src/tunnel/qrcode"; -import { startNgrokTunnel, stopNgrokTunnel, isNgrokInstalled } from "./src/tunnel/ngrok"; -import { startCloudflareTunnel, stopCloudflareTunnel, getCloudflareUrl, isCloudflareInstalled } from "./src/tunnel/cloudflare"; -import { updateTunnelMetadata, clearTunnelMetadata, loadTunnelMetadata } from "./src/tunnel/metadata"; +import type { PushToken } from "./src/push/index.js"; +import { formatNotification } from "./src/push/formatter.js"; +import { sendPush } from "./src/push/sender.js"; +import { loadTokens, saveTokens } from "./src/push/token-store.js"; +import { startLocaltunnel, stopLocaltunnel, getLocaltunnelUrl } from "./src/tunnel/localtunnel.js"; +import { displayQRCode, generateQRCodeAscii, generateQRCodeAsciiPlain } from "./src/tunnel/qrcode.js"; +import { startNgrokTunnel, stopNgrokTunnel, isNgrokInstalled } from "./src/tunnel/ngrok.js"; +import { startCloudflareTunnel, stopCloudflareTunnel, getCloudflareUrl, isCloudflareInstalled } from "./src/tunnel/cloudflare.js"; +import { updateTunnelMetadata, clearTunnelMetadata, loadTunnelMetadata } from "./src/tunnel/metadata.js"; function logPluginVersion(ctx: Parameters[0]): void { const client = (ctx as any)?.client; diff --git a/src/proxy/index.ts b/src/proxy/index.ts index bb569f3..071a796 100644 --- a/src/proxy/index.ts +++ b/src/proxy/index.ts @@ -2,4 +2,4 @@ * Proxy module barrel export */ -export * from "./types"; +export * from "./types.js"; diff --git a/src/push/formatter.ts b/src/push/formatter.ts index 8ff06e8..91a5c5f 100644 --- a/src/push/formatter.ts +++ b/src/push/formatter.ts @@ -2,9 +2,9 @@ * Notification formatting utilities */ -import type { Notification, NotificationEvent, PluginContext } from "./types"; -import { truncate } from "./token-store"; -import { loadFilterConfig, shouldFilterSession } from "./filters"; +import type { Notification, NotificationEvent, PluginContext } from "./types.js"; +import { truncate } from "./token-store.js"; +import { loadFilterConfig, shouldFilterSession } from "./filters.js"; const DEBUG_ENABLED = process.env.OPENCODE_MOBILE_DEBUG === "1"; const debugLog = (...args: unknown[]): void => { diff --git a/src/push/index.ts b/src/push/index.ts index 8ea83f4..bc89b97 100644 --- a/src/push/index.ts +++ b/src/push/index.ts @@ -2,8 +2,8 @@ * Push notification module barrel export */ -export * from "./types"; -export * from "./token-store"; -export * from "./formatter"; -export * from "./sender"; -export * from "./notification-handler"; +export * from "./types.js"; +export * from "./token-store.js"; +export * from "./formatter.js"; +export * from "./sender.js"; +export * from "./notification-handler.js"; diff --git a/src/push/sender.ts b/src/push/sender.ts index 0b81139..2132d5b 100644 --- a/src/push/sender.ts +++ b/src/push/sender.ts @@ -2,8 +2,8 @@ * Push notification sender */ -import type { Notification } from "./types"; -import { loadTokens, saveTokens } from "./token-store"; +import type { Notification } from "./types.js"; +import { loadTokens, saveTokens } from "./token-store.js"; const EXPO_PUSH_URL = "https://exp.host/--/api/v2/push/send"; diff --git a/src/push/token-store.ts b/src/push/token-store.ts index 26f9401..a9a5285 100644 --- a/src/push/token-store.ts +++ b/src/push/token-store.ts @@ -4,7 +4,7 @@ import * as fs from "fs"; import * as path from "path"; -import type { PushToken } from "./types"; +import type { PushToken } from "./types.js"; const CONFIG_DIR = path.join(process.env.HOME || "", ".config/opencode"); const TOKEN_FILE = path.join(CONFIG_DIR, "push-tokens.json"); diff --git a/src/tunnel/cloudflare.ts b/src/tunnel/cloudflare.ts index 9423a8e..b0f50df 100644 --- a/src/tunnel/cloudflare.ts +++ b/src/tunnel/cloudflare.ts @@ -12,7 +12,7 @@ import { spawn, ChildProcess, execSync } from "child_process"; import * as fs from "fs"; import * as path from "path"; import * as os from "os"; -import type { TunnelConfig, TunnelInfo } from "./types"; +import type { TunnelConfig, TunnelInfo } from "./types.js"; // Export types for external use export type { TunnelConfig, TunnelInfo }; diff --git a/src/tunnel/index.ts b/src/tunnel/index.ts index 1fb6c9f..37f94ee 100644 --- a/src/tunnel/index.ts +++ b/src/tunnel/index.ts @@ -3,24 +3,24 @@ */ import * as fs from "fs"; -import type { TunnelConfig, TunnelInfo, TunnelDetails } from "./types"; +import type { TunnelConfig, TunnelInfo, TunnelDetails } from "./types.js"; import { startNgrokTunnel, stopNgrokTunnel, diagnoseNgrok, ensureNgrokReady -} from "./ngrok"; +} from "./ngrok.js"; import { startLocaltunnel, stopLocaltunnel, getLocaltunnelUrl -} from "./localtunnel"; +} from "./localtunnel.js"; import { startCloudflareTunnel, stopCloudflareTunnel, getCloudflareUrl -} from "./cloudflare"; -import { displayQRCode } from "./qrcode"; +} from "./cloudflare.js"; +import { displayQRCode } from "./qrcode.js"; let currentTunnel: TunnelInfo | null = null; diff --git a/src/tunnel/localtunnel.ts b/src/tunnel/localtunnel.ts index 890f66e..482560b 100644 --- a/src/tunnel/localtunnel.ts +++ b/src/tunnel/localtunnel.ts @@ -8,7 +8,7 @@ */ import localtunnel from "localtunnel"; -import type { TunnelConfig, TunnelInfo } from "./types"; +import type { TunnelConfig, TunnelInfo } from "./types.js"; // Export the type for external use export type { TunnelConfig, TunnelInfo }; diff --git a/src/tunnel/ngrok.ts b/src/tunnel/ngrok.ts index 5191b74..14dd624 100644 --- a/src/tunnel/ngrok.ts +++ b/src/tunnel/ngrok.ts @@ -6,7 +6,7 @@ import * as fs from "fs"; import * as path from "path"; import { spawn } from "child_process"; import * as ngrok from "@ngrok/ngrok"; -import type { TunnelConfig, TunnelInfo, NgrokDiagnostics } from "./types"; +import type { TunnelConfig, TunnelInfo, NgrokDiagnostics } from "./types.js"; let ngrokInstance: any = null; let ngrokSession: any = null; diff --git a/src/utils/index.ts b/src/utils/index.ts index a5dc802..7183288 100644 --- a/src/utils/index.ts +++ b/src/utils/index.ts @@ -2,4 +2,4 @@ * Utilities barrel export */ -export * from "./port"; +export * from "./port.js"; From 1eba6a39d03d912f8cbc08f2d9a2578b7f2a724b Mon Sep 17 00:00:00 2001 From: Robespierred0p <64637841+Robespierred0p@users.noreply.github.com> Date: Tue, 2 Jun 2026 21:15:57 +0200 Subject: [PATCH 2/2] fix: add new CLI commands for tunnel setup and uninstall --- package-lock.json | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/package-lock.json b/package-lock.json index 84626c0..19c113a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -22,7 +22,9 @@ }, "bin": { "opencode-mobile": "bin/audit", - "opencode-mobile-qr": "bin/qr" + "opencode-mobile-qr": "bin/qr", + "opencode-mobile-tunnel-setup": "dist/src/cli/tunnel-setup.js", + "opencode-mobile-uninstall": "bin/uninstall" }, "devDependencies": { "@types/localtunnel": "^2.0.4",