@cdoing/opentuicli 0.1.26 → 0.1.28

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.
package/bin/cdoing-tui ADDED
@@ -0,0 +1,94 @@
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
+ // Cached binary path for fast subsequent launches
29
+ const cached = path.join(scriptDir, ".cdoing-tui")
30
+ if (fs.existsSync(cached)) {
31
+ run(cached)
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
+ // Cache for fast subsequent launches
88
+ try {
89
+ fs.symlinkSync(resolved, cached)
90
+ } catch {
91
+ // ignore — cache is optional
92
+ }
93
+
94
+ run(resolved)
package/package.json CHANGED
@@ -1,15 +1,15 @@
1
1
  {
2
2
  "name": "@cdoing/opentuicli",
3
- "version": "0.1.26",
3
+ "version": "0.1.28",
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": "dist/cdoing-tui-current/bin/cdoing-tui"
9
+ "cdoing-tui": "bin/cdoing-tui"
10
10
  },
11
11
  "files": [
12
- "dist/"
12
+ "bin/"
13
13
  ],
14
14
  "scripts": {
15
15
  "build": "bun run build.ts --single",
@@ -35,5 +35,12 @@
35
35
  "ts-node": "^10.9.2",
36
36
  "typescript": "^5.8.2"
37
37
  },
38
- "license": "Apache-2.0"
38
+ "license": "Apache-2.0",
39
+ "optionalDependencies": {
40
+ "@cdoing/opentuicli-darwin-arm64": "0.1.28",
41
+ "@cdoing/opentuicli-darwin-x64": "0.1.28",
42
+ "@cdoing/opentuicli-linux-arm64": "0.1.28",
43
+ "@cdoing/opentuicli-linux-x64": "0.1.28",
44
+ "@cdoing/opentuicli-windows-x64": "0.1.28"
45
+ }
39
46
  }