goatchain-cli 0.0.72 → 0.0.73-beta.1
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.mjs → dim.mjs} +30 -65
- package/package.json +10 -10
- package/dist/ink.mjs +0 -2624
|
@@ -4,21 +4,32 @@ import fs from 'node:fs'
|
|
|
4
4
|
import os from 'node:os'
|
|
5
5
|
import path from 'node:path'
|
|
6
6
|
import process from 'node:process'
|
|
7
|
-
import { fileURLToPath
|
|
7
|
+
import { fileURLToPath } from 'node:url'
|
|
8
8
|
|
|
9
9
|
const __filename = fileURLToPath(import.meta.url)
|
|
10
10
|
const __dirname = path.dirname(__filename)
|
|
11
11
|
const isWindows = os.platform() === 'win32'
|
|
12
12
|
|
|
13
13
|
let wrapperVersion = ''
|
|
14
|
+
let wrapperName = 'dimcode'
|
|
14
15
|
try {
|
|
15
16
|
const pkg = JSON.parse(
|
|
16
17
|
fs.readFileSync(path.join(__dirname, '..', 'package.json'), 'utf8'),
|
|
17
18
|
)
|
|
18
19
|
wrapperVersion = pkg.version || ''
|
|
20
|
+
if (pkg.name)
|
|
21
|
+
wrapperName = pkg.name
|
|
19
22
|
}
|
|
20
23
|
catch {}
|
|
21
24
|
|
|
25
|
+
// Inner binary file name shipped inside each platform sub-package's bin/.
|
|
26
|
+
// dimcode → bin/dimcode(.exe); goatchain-cli → bin/goatchain(.exe).
|
|
27
|
+
const BINARY_BASENAMES = {
|
|
28
|
+
'dimcode': 'dimcode',
|
|
29
|
+
'goatchain-cli': 'goatchain',
|
|
30
|
+
}
|
|
31
|
+
const binaryBasename = BINARY_BASENAMES[wrapperName] || wrapperName
|
|
32
|
+
|
|
22
33
|
const wrapperDir = path.join(__dirname, '..').replace(/\\/g, '/').toLowerCase()
|
|
23
34
|
const wrapperPm
|
|
24
35
|
= wrapperDir.includes('.bun/') || wrapperDir.includes('bun/install/')
|
|
@@ -26,60 +37,15 @@ const wrapperPm
|
|
|
26
37
|
: 'npm'
|
|
27
38
|
|
|
28
39
|
const args = process.argv.slice(2)
|
|
29
|
-
const
|
|
30
|
-
|
|
31
|
-
if (routing.target === 'opentui') {
|
|
32
|
-
runOpentui(routing.forwardArgs)
|
|
33
|
-
}
|
|
34
|
-
else {
|
|
35
|
-
await runInk()
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
function resolveRouting(argv) {
|
|
39
|
-
// Explicit `goatchain ink ...` forces the Ink TUI.
|
|
40
|
-
if (argv[0] === 'ink')
|
|
41
|
-
return { target: 'ink', forwardArgs: argv.slice(1) }
|
|
42
|
-
// Explicit `goatchain opentui ...` also routes to the opentui binary
|
|
43
|
-
// (kept for backwards compatibility; opentui is now the default).
|
|
44
|
-
if (argv[0] === 'opentui')
|
|
45
|
-
return { target: 'opentui', forwardArgs: argv.slice(1) }
|
|
46
|
-
|
|
47
|
-
// Default: everything goes to the opentui binary.
|
|
48
|
-
return { target: 'opentui', forwardArgs: argv }
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
async function runInk() {
|
|
52
|
-
const inkEntry = path.join(__dirname, '..', 'dist', 'ink.mjs')
|
|
53
|
-
if (!fs.existsSync(inkEntry)) {
|
|
54
|
-
console.error('[goatchain] Ink bundle missing: ' + inkEntry)
|
|
55
|
-
console.error('[goatchain] Try reinstalling goatchain-cli.')
|
|
56
|
-
process.exit(1)
|
|
57
|
-
}
|
|
58
|
-
// Inject wrapper identity so the in-process upgrade check targets the
|
|
59
|
-
// npm wrapper package rather than upstream `dimcode`.
|
|
60
|
-
process.env.DIMCODE_NPM_PACKAGE = 'goatchain-cli'
|
|
61
|
-
process.env.DIMCODE_NPM_PACKAGE_MANAGER = wrapperPm
|
|
62
|
-
// goatchain-cli is a beta-only channel: ignore any stable releases on the
|
|
63
|
-
// registry when deciding whether to upgrade.
|
|
64
|
-
process.env.DIMCODE_NPM_PACKAGE_BETA_ONLY = '1'
|
|
65
|
-
if (wrapperVersion)
|
|
66
|
-
process.env.DIMCODE_NPM_PACKAGE_VERSION = wrapperVersion
|
|
67
|
-
try {
|
|
68
|
-
await import(pathToFileURL(inkEntry).href)
|
|
69
|
-
}
|
|
70
|
-
catch (err) {
|
|
71
|
-
console.error('[goatchain] Failed to start Ink TUI:')
|
|
72
|
-
console.error(err)
|
|
73
|
-
process.exit(1)
|
|
74
|
-
}
|
|
75
|
-
}
|
|
40
|
+
const forwardArgs = args[0] === 'opentui' ? args.slice(1) : args
|
|
41
|
+
runOpentui(forwardArgs)
|
|
76
42
|
|
|
77
43
|
function runOpentui(restArgs) {
|
|
78
44
|
const envPath = process.env.DIMCODE_BIN_PATH
|
|
79
45
|
if (envPath) {
|
|
80
46
|
if (!fs.existsSync(envPath)) {
|
|
81
47
|
console.error(
|
|
82
|
-
'[
|
|
48
|
+
'[dim] DIMCODE_BIN_PATH is set but file not found: ' + envPath,
|
|
83
49
|
)
|
|
84
50
|
process.exit(1)
|
|
85
51
|
}
|
|
@@ -94,20 +60,20 @@ function runOpentui(restArgs) {
|
|
|
94
60
|
const archMap = { x64: 'x64', arm64: 'arm64' }
|
|
95
61
|
const platform = platformMap[os.platform()] || os.platform()
|
|
96
62
|
const arch = archMap[os.arch()] || os.arch()
|
|
97
|
-
const base = '
|
|
98
|
-
const binary = platform === 'windows' ? '
|
|
63
|
+
const base = wrapperName + '-' + platform + '-' + arch
|
|
64
|
+
const binary = platform === 'windows' ? binaryBasename + '.exe' : binaryBasename
|
|
99
65
|
|
|
100
66
|
if (process.env.DIMCODE_DEBUG) {
|
|
101
|
-
console.error('[
|
|
102
|
-
console.error('[
|
|
103
|
-
console.error('[
|
|
104
|
-
console.error('[
|
|
67
|
+
console.error('[dim] Wrapper: ' + wrapperName + '@' + wrapperVersion)
|
|
68
|
+
console.error('[dim] Platform: ' + platform + ' Arch: ' + arch)
|
|
69
|
+
console.error('[dim] Looking for package: ' + base)
|
|
70
|
+
console.error('[dim] Script dir: ' + scriptDir)
|
|
105
71
|
}
|
|
106
72
|
|
|
107
73
|
const resolved = findBinary(scriptDir, base, binary)
|
|
108
74
|
if (!resolved) {
|
|
109
75
|
console.error(
|
|
110
|
-
'[
|
|
76
|
+
'[dim] Could not find the opentui binary for your platform.\n'
|
|
111
77
|
+ '\n'
|
|
112
78
|
+ ' Platform: ' + os.platform() + ' (' + platform + ')\n'
|
|
113
79
|
+ ' Arch: ' + os.arch() + ' (' + arch + ')\n'
|
|
@@ -115,13 +81,13 @@ function runOpentui(restArgs) {
|
|
|
115
81
|
+ ' Searched: ' + scriptDir + ' (and parent directories)\n'
|
|
116
82
|
+ '\n'
|
|
117
83
|
+ 'Try uninstalling and reinstalling the beta channel:\n'
|
|
118
|
-
+ ' npm uninstall -g
|
|
84
|
+
+ ' npm uninstall -g ' + wrapperName + ' && npm install -g ' + wrapperName + '@beta\n',
|
|
119
85
|
)
|
|
120
86
|
process.exit(1)
|
|
121
87
|
}
|
|
122
88
|
|
|
123
89
|
if (process.env.DIMCODE_DEBUG)
|
|
124
|
-
console.error('[
|
|
90
|
+
console.error('[dim] Resolved binary: ' + resolved)
|
|
125
91
|
|
|
126
92
|
spawnBinary(resolved, restArgs)
|
|
127
93
|
}
|
|
@@ -145,9 +111,8 @@ function findBinary(startDir, base, binary) {
|
|
|
145
111
|
function spawnBinary(target, forwardedArgs) {
|
|
146
112
|
const env = {
|
|
147
113
|
...process.env,
|
|
148
|
-
DIMCODE_NPM_PACKAGE:
|
|
114
|
+
DIMCODE_NPM_PACKAGE: wrapperName,
|
|
149
115
|
DIMCODE_NPM_PACKAGE_MANAGER: wrapperPm,
|
|
150
|
-
DIMCODE_NPM_PACKAGE_BETA_ONLY: '1',
|
|
151
116
|
DIMCODE_NPM_PACKAGE_ROOT: path.resolve(__dirname, '..'),
|
|
152
117
|
}
|
|
153
118
|
if (wrapperVersion)
|
|
@@ -161,16 +126,16 @@ function spawnBinary(target, forwardedArgs) {
|
|
|
161
126
|
})
|
|
162
127
|
if (result.error) {
|
|
163
128
|
console.error(
|
|
164
|
-
'[
|
|
129
|
+
'[dim] Failed to start opentui binary: ' + result.error.message,
|
|
165
130
|
)
|
|
166
131
|
if (isWindows) {
|
|
167
|
-
console.error('[
|
|
132
|
+
console.error('[dim] Binary path: ' + target)
|
|
168
133
|
if (result.error.code === 'ENOENT') {
|
|
169
134
|
console.error(
|
|
170
|
-
'[
|
|
135
|
+
'[dim] The binary file was not found. Try reinstalling:',
|
|
171
136
|
)
|
|
172
137
|
console.error(
|
|
173
|
-
' npm uninstall -g
|
|
138
|
+
' npm uninstall -g ' + wrapperName + ' && npm install -g ' + wrapperName + '@beta',
|
|
174
139
|
)
|
|
175
140
|
}
|
|
176
141
|
}
|
|
@@ -178,7 +143,7 @@ function spawnBinary(target, forwardedArgs) {
|
|
|
178
143
|
}
|
|
179
144
|
if (result.status !== 0 && result.status !== null) {
|
|
180
145
|
if (process.env.DIMCODE_DEBUG)
|
|
181
|
-
console.error('[
|
|
146
|
+
console.error('[dim] Binary exited with code: ' + result.status)
|
|
182
147
|
}
|
|
183
148
|
process.exit(typeof result.status === 'number' ? result.status : 0)
|
|
184
149
|
}
|
package/package.json
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "goatchain-cli",
|
|
3
|
-
"version": "0.0.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "0.0.73-beta.1",
|
|
4
|
+
"description": "AI coding agent CLI and terminal coding assistant with an interactive TUI (beta channel)",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
7
|
-
"goatchain": "./bin/
|
|
7
|
+
"goatchain": "./bin/dim.mjs",
|
|
8
|
+
"goatchain-cli": "./bin/dim.mjs"
|
|
8
9
|
},
|
|
9
10
|
"files": [
|
|
10
|
-
"bin"
|
|
11
|
-
"dist"
|
|
11
|
+
"bin"
|
|
12
12
|
],
|
|
13
13
|
"optionalDependencies": {
|
|
14
|
-
"goatchain-cli-darwin-arm64": "0.0.
|
|
15
|
-
"goatchain-cli-darwin-x64": "0.0.
|
|
16
|
-
"goatchain-cli-linux-arm64": "0.0.
|
|
17
|
-
"goatchain-cli-linux-x64": "0.0.
|
|
18
|
-
"goatchain-cli-windows-x64": "0.0.
|
|
14
|
+
"goatchain-cli-darwin-arm64": "0.0.73-beta.1",
|
|
15
|
+
"goatchain-cli-darwin-x64": "0.0.73-beta.1",
|
|
16
|
+
"goatchain-cli-linux-arm64": "0.0.73-beta.1",
|
|
17
|
+
"goatchain-cli-linux-x64": "0.0.73-beta.1",
|
|
18
|
+
"goatchain-cli-windows-x64": "0.0.73-beta.1"
|
|
19
19
|
}
|
|
20
20
|
}
|