goatchain-cli 0.0.5-beta.9 → 0.0.6-beta.0

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,79 @@
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
+ let wrapperVersion = ""
9
+ try {
10
+ const pkg = JSON.parse(fs.readFileSync(path.join(__dirname, "..", "package.json"), "utf8"))
11
+ wrapperVersion = pkg.version || ""
12
+ } catch (_) {}
13
+
14
+ const wrapperDir = path.join(__dirname, "..").replace(/\\/g, "/").toLowerCase()
15
+ const wrapperPm = (wrapperDir.includes(".bun/") || wrapperDir.includes("bun/install/")) ? "bun" : "npm"
16
+
17
+ function run(target) {
18
+ const env = { ...process.env, GOATCHAIN_NPM_PACKAGE: "goatchain-cli", GOATCHAIN_NPM_PACKAGE_MANAGER: wrapperPm }
19
+ if (wrapperVersion) env.GOATCHAIN_NPM_PACKAGE_VERSION = wrapperVersion
20
+ const result = childProcess.spawnSync(target, process.argv.slice(2), {
21
+ stdio: "inherit",
22
+ cwd: process.cwd(),
23
+ env,
24
+ })
25
+ if (result.error) {
26
+ console.error(result.error.message)
27
+ process.exit(1)
28
+ }
29
+ process.exit(typeof result.status === "number" ? result.status : 0)
30
+ }
31
+
32
+ const envPath = process.env.GOATCHAIN_BIN_PATH
33
+ if (envPath) {
34
+ run(envPath)
35
+ }
36
+
37
+ const scriptPath = fs.realpathSync(__filename)
38
+ const scriptDir = path.dirname(scriptPath)
39
+
40
+ const platformMap = {
41
+ darwin: "darwin",
42
+ linux: "linux",
43
+ win32: "windows",
44
+ }
45
+ const archMap = {
46
+ x64: "x64",
47
+ arm64: "arm64",
48
+ }
49
+
50
+ let platform = platformMap[os.platform()] || os.platform()
51
+ let arch = archMap[os.arch()] || os.arch()
52
+
53
+ const base = "goatchain-cli-" + platform + "-" + arch
54
+ const binary = platform === "windows" ? "goatchain.exe" : "goatchain"
55
+
56
+ function findBinary(startDir) {
57
+ let current = startDir
58
+ for (;;) {
59
+ const modules = path.join(current, "node_modules")
60
+ if (fs.existsSync(modules)) {
61
+ const candidate = path.join(modules, base, "bin", binary)
62
+ if (fs.existsSync(candidate)) return candidate
63
+ }
64
+ const parent = path.dirname(current)
65
+ if (parent === current) return
66
+ current = parent
67
+ }
68
+ }
69
+
70
+ const resolved = findBinary(scriptDir)
71
+ if (!resolved) {
72
+ console.error(
73
+ `It seems that your package manager failed to install the right binary package for your platform.\n` +
74
+ `You can try manually installing the "${base}" package.`
75
+ )
76
+ process.exit(1)
77
+ }
78
+
79
+ run(resolved)
package/package.json CHANGED
@@ -1,59 +1,19 @@
1
1
  {
2
2
  "name": "goatchain-cli",
3
- "type": "module",
4
- "version": "0.0.5-beta.9",
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.6-beta.0",
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.6-beta.0",
14
+ "goatchain-cli-darwin-x64": "0.0.6-beta.0",
15
+ "goatchain-cli-linux-arm64": "0.0.6-beta.0",
16
+ "goatchain-cli-linux-x64": "0.0.6-beta.0",
17
+ "goatchain-cli-windows-x64": "0.0.6-beta.0"
58
18
  }
59
- }
19
+ }
@@ -0,0 +1,37 @@
1
+ #!/usr/bin/env node
2
+
3
+ const stdout = process.stdout
4
+ const isTTY = Boolean(stdout && stdout.isTTY)
5
+ const isCI = Boolean(
6
+ process.env.CI
7
+ || process.env.GITHUB_ACTIONS
8
+ || process.env.BUILD_NUMBER
9
+ || process.env.JENKINS_URL
10
+ || process.env.GITLAB_CI
11
+ || process.env.BUILDKITE
12
+ )
13
+
14
+ const lines = [
15
+ '',
16
+ ' GoatChain CLI installed.',
17
+ ' Run: goatchain to start.',
18
+ '',
19
+ ]
20
+
21
+ if (!isTTY || isCI) {
22
+ stdout.write(lines.join('\n') + '\n')
23
+ } else {
24
+ const frames = ['[= ]', '[== ]', '[=== ]', '[==== ]', '[===== ]', '[======]', '[===== ]', '[==== ]', '[=== ]', '[== ]']
25
+ let idx = 0
26
+ const label = 'Setting up GoatChain '
27
+ const interval = setInterval(() => {
28
+ stdout.write(`\r${label}${frames[idx % frames.length]}`)
29
+ idx += 1
30
+ }, 90)
31
+
32
+ setTimeout(() => {
33
+ clearInterval(interval)
34
+ stdout.write('\r' + ' '.repeat(label.length + frames[0].length) + '\r\n')
35
+ stdout.write(lines.join('\n') + '\n')
36
+ }, 800)
37
+ }
package/cli.mjs DELETED
@@ -1,2 +0,0 @@
1
- #!/usr/bin/env node
2
- await import('./dist/cli.mjs')