goatchain-cli 0.0.5-beta.17 → 0.0.5-beta.19

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/goatchain ADDED
@@ -0,0 +1,10 @@
1
+ #!/bin/sh
2
+ # Resolve symlinks to find the real script directory
3
+ self="$0"
4
+ while [ -L "$self" ]; do
5
+ dir="$(cd "$(dirname "$self")" && pwd)"
6
+ self="$(readlink "$self")"
7
+ case "$self" in /*) ;; *) self="$dir/$self" ;; esac
8
+ done
9
+ dir="$(cd "$(dirname "$self")" && pwd)"
10
+ exec "$dir/.goatchain" "$@"
package/package.json CHANGED
@@ -1,59 +1,19 @@
1
1
  {
2
2
  "name": "goatchain-cli",
3
- "type": "module",
4
- "version": "0.0.5-beta.17",
5
- "description": "GoatChain CLI built on @simon_he/vue-tui",
6
- "exports": {
7
- ".": {
8
- "types": "./dist/index.d.ts",
9
- "import": "./dist/index.js"
10
- },
11
- "./cli": {
12
- "types": "./dist/cli.d.ts",
13
- "import": "./dist/cli.js"
14
- }
15
- },
16
- "main": "./dist/index.js",
17
- "types": "./dist/index.d.ts",
3
+ "version": "0.0.5-beta.19",
4
+ "description": "AI coding agent CLI - binary distribution",
5
+ "license": "MIT",
18
6
  "bin": {
19
- "goatchain": "./cli.mjs"
7
+ "goatchain": "./bin/goatchain"
20
8
  },
21
- "files": [
22
- "cli.mjs",
23
- "dist"
24
- ],
25
9
  "scripts": {
26
- "build": "bun run build.mjs",
27
- "build:npm": "tsdown",
28
- "build:binary": "bun run build.mjs --binary",
29
- "build:binary:macos": "bun run build.mjs --binary --target=bun-darwin-arm64",
30
- "build:binary:macos-x64": "bun run build.mjs --binary --target=bun-darwin-x64",
31
- "build:binary:linux": "bun run build.mjs --binary --target=bun-linux-x64",
32
- "build:binary:linux-arm64": "bun run build.mjs --binary --target=bun-linux-arm64",
33
- "build:binary:windows": "bun run build.mjs --binary --target=bun-windows-x64",
34
- "cli": "bun src/cli.ts",
35
- "test": "bun test --preload ./test/setup.ts",
36
- "smoke": "bun run build && bun dist/cli.mjs --help",
37
- "lint": "eslint src/**/*.ts",
38
- "lint:fix": "eslint src/**/*.ts --fix",
39
- "prepack": "bun run build",
40
- "fix-package": "bun run fix-package.mjs",
41
- "restore-package": "bun run restore-package.mjs",
42
- "release": "bumpp --commit --no-tag --no-push && bun run build && bun publish",
43
- "release:npm": "bumpp --commit --no-tag --no-push && bun run build:npm && npm publish"
44
- },
45
- "dependencies": {
46
- "goatchain": "latest",
47
- "open": "^10.1.2",
48
- "semver": "^7.7.3",
49
- "shiki": "^3.20.0",
50
- "vue": "^3.4.0"
10
+ "postinstall": "node ./postinstall.mjs"
51
11
  },
52
- "devDependencies": {
53
- "@types/node": "^18.19.111",
54
- "happy-dom": "^17.5.0",
55
- "tsdown": "^0.20.0-beta.3",
56
- "typescript": "5.8.3",
57
- "vitest": "^4.0.17"
12
+ "optionalDependencies": {
13
+ "goatchain-cli-darwin-arm64": "0.0.5-beta.19",
14
+ "goatchain-cli-darwin-x64": "0.0.5-beta.19",
15
+ "goatchain-cli-linux-x64": "0.0.5-beta.19",
16
+ "goatchain-cli-linux-arm64": "0.0.5-beta.19",
17
+ "goatchain-cli-windows-x64": "0.0.5-beta.19"
58
18
  }
59
- }
19
+ }
@@ -0,0 +1,103 @@
1
+ #!/usr/bin/env node
2
+
3
+ import fs from "fs"
4
+ import path from "path"
5
+ import os from "os"
6
+ import { fileURLToPath } from "url"
7
+ import { createRequire } from "module"
8
+
9
+ const __dirname = path.dirname(fileURLToPath(import.meta.url))
10
+ const require = createRequire(import.meta.url)
11
+
12
+ function detectPlatformAndArch() {
13
+ let platform
14
+ switch (os.platform()) {
15
+ case "darwin":
16
+ platform = "darwin"
17
+ break
18
+ case "linux":
19
+ platform = "linux"
20
+ break
21
+ case "win32":
22
+ platform = "windows"
23
+ break
24
+ default:
25
+ platform = os.platform()
26
+ break
27
+ }
28
+
29
+ let arch
30
+ switch (os.arch()) {
31
+ case "x64":
32
+ arch = "x64"
33
+ break
34
+ case "arm64":
35
+ arch = "arm64"
36
+ break
37
+ default:
38
+ arch = os.arch()
39
+ break
40
+ }
41
+
42
+ return { platform, arch }
43
+ }
44
+
45
+ function findBinary() {
46
+ const { platform, arch } = detectPlatformAndArch()
47
+ const packageName = `goatchain-cli-${platform}-${arch}`
48
+ const binaryName = platform === "windows" ? "goatchain.exe" : "goatchain"
49
+
50
+ try {
51
+ const packageJsonPath = require.resolve(`${packageName}/package.json`)
52
+ const packageDir = path.dirname(packageJsonPath)
53
+ const binaryPath = path.join(packageDir, "bin", binaryName)
54
+
55
+ if (!fs.existsSync(binaryPath)) {
56
+ throw new Error(`Binary not found at ${binaryPath}`)
57
+ }
58
+
59
+ return { binaryPath, binaryName }
60
+ } catch (error) {
61
+ throw new Error(`Could not find package ${packageName}: ${error.message}`)
62
+ }
63
+ }
64
+
65
+ async function main() {
66
+ try {
67
+ if (os.platform() === "win32") {
68
+ console.log("Windows detected: binary setup not needed (using packaged .exe)")
69
+ return
70
+ }
71
+
72
+ const { binaryPath } = findBinary()
73
+ const binDir = path.join(__dirname, "bin")
74
+ const target = path.join(binDir, ".goatchain")
75
+
76
+ if (!fs.existsSync(binDir)) {
77
+ fs.mkdirSync(binDir, { recursive: true })
78
+ }
79
+
80
+ if (fs.existsSync(target)) {
81
+ fs.unlinkSync(target)
82
+ }
83
+
84
+ try {
85
+ fs.linkSync(binaryPath, target)
86
+ } catch {
87
+ fs.copyFileSync(binaryPath, target)
88
+ }
89
+ fs.chmodSync(target, 0o755)
90
+
91
+ console.log(`goatchain-cli binary linked: ${target} -> ${binaryPath}`)
92
+ } catch (error) {
93
+ console.error("Failed to setup goatchain-cli binary:", error.message)
94
+ process.exit(1)
95
+ }
96
+ }
97
+
98
+ try {
99
+ main()
100
+ } catch (error) {
101
+ console.error("Postinstall script error:", error.message)
102
+ process.exit(0)
103
+ }
package/cli.mjs DELETED
@@ -1,2 +0,0 @@
1
- #!/usr/bin/env node
2
- await import('./dist/cli.mjs')