@cortexkit/opencode-openai-auth 0.3.3 → 0.3.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,30 @@
1
+ import { execFileSync as defaultExecFileSync } from 'node:child_process'
2
+
3
+ type BrowserExec = (
4
+ file: string,
5
+ args: string[],
6
+ options: { stdio: 'ignore'; timeout: number },
7
+ ) => unknown
8
+
9
+ export function openUrl(
10
+ url: string,
11
+ platform: NodeJS.Platform = process.platform,
12
+ execFileSync: BrowserExec = defaultExecFileSync,
13
+ ) {
14
+ try {
15
+ if (platform === 'win32') {
16
+ execFileSync('cmd', ['/c', 'start', '', url], {
17
+ stdio: 'ignore',
18
+ timeout: 3000,
19
+ })
20
+ return
21
+ }
22
+
23
+ execFileSync(platform === 'darwin' ? 'open' : 'xdg-open', [url], {
24
+ stdio: 'ignore',
25
+ timeout: 3000,
26
+ })
27
+ } catch {
28
+ // Browser launch is best effort; the printed URL remains the fallback.
29
+ }
30
+ }
package/src/tui.tsx CHANGED
@@ -50,21 +50,24 @@ const log = createLogger('rpc-tui')
50
50
 
51
51
  const ID = 'cortexkit.openai-auth'
52
52
 
53
- // Plugin version for the header (mirrors the Magic Context / AFT convention).
54
- // Read at runtime from package.json relative to this module — NOT a TS JSON
55
- // import, which would break the declaration build (package.json is outside
56
- // rootDir). tui.tsx ships as source (package.json exports["./tui"] →
57
- // "./src/tui.tsx") and is never compiled into a deeper dist tree, so `..` from
58
- // src/ is always the package root. Empty string on any failure → header shows
59
- // the badge with no version.
53
+ // Read package metadata from either the raw src/ entry or its generated
54
+ // src/tui-compiled/ counterpart. Avoid a JSON import because package.json sits
55
+ // outside the declaration build's rootDir.
60
56
  const PLUGIN_VERSION: string = (() => {
61
- try {
62
- const here = dirname(fileURLToPath(import.meta.url))
63
- const raw = readFileSync(join(here, '..', 'package.json'), 'utf8')
64
- return (JSON.parse(raw) as { version?: string }).version ?? ''
65
- } catch {
66
- return ''
57
+ const here = dirname(fileURLToPath(import.meta.url))
58
+ for (const packageFile of [
59
+ join(here, '..', 'package.json'),
60
+ join(here, '..', '..', 'package.json'),
61
+ ]) {
62
+ try {
63
+ const raw = readFileSync(packageFile, 'utf8')
64
+ const version = (JSON.parse(raw) as { version?: string }).version
65
+ if (version) return version
66
+ } catch {
67
+ // Try the path for the other TUI entry layout.
68
+ }
67
69
  }
70
+ return ''
68
71
  })()
69
72
 
70
73
  // biome-ignore lint/suspicious/noExplicitAny: opentui border prop not typed in plugin tui surface