@cdoing/opentuicli 0.1.30 → 0.1.32

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,87 @@
1
+ #!/usr/bin/env node
2
+
3
+ const childProcess = require("child_process")
4
+ const fs = require("fs")
5
+ const path = require("path")
6
+ const os = require("os")
7
+
8
+ function run(target) {
9
+ const result = childProcess.spawnSync(target, process.argv.slice(2), {
10
+ stdio: "inherit",
11
+ })
12
+ if (result.error) {
13
+ console.error(result.error.message)
14
+ process.exit(1)
15
+ }
16
+ const code = typeof result.status === "number" ? result.status : 0
17
+ process.exit(code)
18
+ }
19
+
20
+ const envPath = process.env.CDOING_TUI_BIN_PATH
21
+ if (envPath) {
22
+ run(envPath)
23
+ }
24
+
25
+ const scriptPath = fs.realpathSync(__filename)
26
+ const scriptDir = path.dirname(scriptPath)
27
+
28
+ // Check for hard-linked binary from postinstall
29
+ const localBinary = path.join(scriptDir, ".cdoing-tui")
30
+ if (fs.existsSync(localBinary)) {
31
+ run(localBinary)
32
+ }
33
+
34
+ const platformMap = {
35
+ darwin: "darwin",
36
+ linux: "linux",
37
+ win32: "windows",
38
+ }
39
+ const archMap = {
40
+ x64: "x64",
41
+ arm64: "arm64",
42
+ }
43
+
44
+ let platform = platformMap[os.platform()]
45
+ if (!platform) {
46
+ platform = os.platform()
47
+ }
48
+ let arch = archMap[os.arch()]
49
+ if (!arch) {
50
+ arch = os.arch()
51
+ }
52
+
53
+ const base = "@cdoing/opentuicli-" + platform + "-" + arch
54
+ const binary = platform === "windows" ? "cdoing-tui.exe" : "cdoing-tui"
55
+
56
+ const names = [base]
57
+
58
+ function findBinary(startDir) {
59
+ let current = startDir
60
+ for (;;) {
61
+ const modules = path.join(current, "node_modules")
62
+ if (fs.existsSync(modules)) {
63
+ for (const name of names) {
64
+ const candidate = path.join(modules, name, "bin", binary)
65
+ if (fs.existsSync(candidate)) return candidate
66
+ }
67
+ }
68
+ const parent = path.dirname(current)
69
+ if (parent === current) {
70
+ return
71
+ }
72
+ current = parent
73
+ }
74
+ }
75
+
76
+ const resolved = findBinary(scriptDir)
77
+ if (!resolved) {
78
+ console.error(
79
+ "No pre-built binary found for your platform (" + os.platform() + "-" + os.arch() + ").\n" +
80
+ "Try manually installing " +
81
+ names.map((n) => '"' + n + '"').join(" or ") +
82
+ " package",
83
+ )
84
+ process.exit(1)
85
+ }
86
+
87
+ run(resolved)
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@cdoing/opentuicli",
3
- "version": "0.1.30",
3
+ "version": "0.1.32",
4
4
  "description": "OpenTUI-based terminal interface for cdoing agent (inspired by opencode's TUI)",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",
8
8
  "bin": {
9
- "cdoing-tui": "bin/cdoing-tui"
9
+ "cdoing-tui": "bin/cdoing-tui.cjs"
10
10
  },
11
11
  "files": [
12
12
  "bin/"
@@ -18,6 +18,7 @@
18
18
  "typecheck": "tsc --noEmit",
19
19
  "dev": "bun --preload ./preload.ts --watch src/index.ts",
20
20
  "start": "./dist/cdoing-tui-current/bin/cdoing-tui",
21
+ "postinstall": "node postinstall.mjs",
21
22
  "clean": "rm -rf dist"
22
23
  },
23
24
  "devDependencies": {
@@ -38,10 +39,10 @@
38
39
  },
39
40
  "license": "Apache-2.0",
40
41
  "optionalDependencies": {
41
- "@cdoing/opentuicli-darwin-arm64": "0.1.30",
42
- "@cdoing/opentuicli-darwin-x64": "0.1.30",
43
- "@cdoing/opentuicli-linux-arm64": "0.1.30",
44
- "@cdoing/opentuicli-linux-x64": "0.1.30",
45
- "@cdoing/opentuicli-windows-x64": "0.1.30"
42
+ "@cdoing/opentuicli-darwin-arm64": "0.1.32",
43
+ "@cdoing/opentuicli-darwin-x64": "0.1.32",
44
+ "@cdoing/opentuicli-linux-arm64": "0.1.32",
45
+ "@cdoing/opentuicli-linux-x64": "0.1.32",
46
+ "@cdoing/opentuicli-windows-x64": "0.1.32"
46
47
  }
47
48
  }
package/bin/cdoing-tui DELETED
@@ -1,95 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- import { spawnSync } from "node:child_process"
4
- import { existsSync, realpathSync, symlinkSync } from "node:fs"
5
- import { dirname, join } from "node:path"
6
- import { platform as osPlatform, arch as osArch } from "node:os"
7
- import { fileURLToPath } from "node:url"
8
-
9
- function run(target) {
10
- const result = spawnSync(target, process.argv.slice(2), {
11
- stdio: "inherit",
12
- })
13
- if (result.error) {
14
- console.error(result.error.message)
15
- process.exit(1)
16
- }
17
- const code = typeof result.status === "number" ? result.status : 0
18
- process.exit(code)
19
- }
20
-
21
- const envPath = process.env.CDOING_TUI_BIN_PATH
22
- if (envPath) {
23
- run(envPath)
24
- }
25
-
26
- const scriptPath = realpathSync(fileURLToPath(import.meta.url))
27
- const scriptDir = dirname(scriptPath)
28
-
29
- // Cached binary path for fast subsequent launches
30
- const cached = join(scriptDir, ".cdoing-tui")
31
- if (existsSync(cached)) {
32
- run(cached)
33
- }
34
-
35
- const platformMap = {
36
- darwin: "darwin",
37
- linux: "linux",
38
- win32: "windows",
39
- }
40
- const archMap = {
41
- x64: "x64",
42
- arm64: "arm64",
43
- }
44
-
45
- let platform = platformMap[osPlatform()]
46
- if (!platform) {
47
- platform = osPlatform()
48
- }
49
- let arch = archMap[osArch()]
50
- if (!arch) {
51
- arch = osArch()
52
- }
53
-
54
- const base = "@cdoing/opentuicli-" + platform + "-" + arch
55
- const binary = platform === "windows" ? "cdoing-tui.exe" : "cdoing-tui"
56
-
57
- const names = [base]
58
-
59
- function findBinary(startDir) {
60
- let current = startDir
61
- for (;;) {
62
- const modules = join(current, "node_modules")
63
- if (existsSync(modules)) {
64
- for (const name of names) {
65
- const candidate = join(modules, name, "bin", binary)
66
- if (existsSync(candidate)) return candidate
67
- }
68
- }
69
- const parent = dirname(current)
70
- if (parent === current) {
71
- return
72
- }
73
- current = parent
74
- }
75
- }
76
-
77
- const resolved = findBinary(scriptDir)
78
- if (!resolved) {
79
- console.error(
80
- "No pre-built binary found for your platform (" + osPlatform() + "-" + osArch() + ").\n" +
81
- "Try manually installing " +
82
- names.map((n) => '"' + n + '"').join(" or ") +
83
- " package"
84
- )
85
- process.exit(1)
86
- }
87
-
88
- // Cache for fast subsequent launches
89
- try {
90
- symlinkSync(resolved, cached)
91
- } catch {
92
- // ignore — cache is optional
93
- }
94
-
95
- run(resolved)