@ainative/cody-cli 0.1.0 → 0.2.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/cody.js +94 -0
- package/dist/cli.js +3 -4
- package/package.json +5 -6
package/bin/cody.js
ADDED
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Cody CLI launcher
|
|
5
|
+
*
|
|
6
|
+
* Ensures Bun runtime is available (required for the bundled CLI),
|
|
7
|
+
* then execs the real CLI. Auto-installs Bun if missing.
|
|
8
|
+
*
|
|
9
|
+
* npm i -g @ainative/cody-cli && cody
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
const { execSync, spawn } = require('child_process')
|
|
13
|
+
const { existsSync } = require('fs')
|
|
14
|
+
const path = require('path')
|
|
15
|
+
|
|
16
|
+
const CLI_BUNDLE = path.join(__dirname, '..', 'dist', 'cli.js')
|
|
17
|
+
const MIN_BUN_VERSION = '1.2.0'
|
|
18
|
+
|
|
19
|
+
function findBun() {
|
|
20
|
+
const candidates = [
|
|
21
|
+
path.join(process.env.HOME || '', '.bun', 'bin', 'bun'),
|
|
22
|
+
'/usr/local/bin/bun',
|
|
23
|
+
'/opt/homebrew/bin/bun',
|
|
24
|
+
]
|
|
25
|
+
// Also check PATH
|
|
26
|
+
try {
|
|
27
|
+
const p = execSync('which bun 2>/dev/null', { encoding: 'utf8' }).trim()
|
|
28
|
+
if (p) candidates.unshift(p)
|
|
29
|
+
} catch {}
|
|
30
|
+
|
|
31
|
+
for (const c of candidates) {
|
|
32
|
+
if (existsSync(c)) return c
|
|
33
|
+
}
|
|
34
|
+
return null
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
function getBunVersion(bunPath) {
|
|
38
|
+
try {
|
|
39
|
+
return execSync(`${bunPath} --version`, { encoding: 'utf8' }).trim()
|
|
40
|
+
} catch {
|
|
41
|
+
return '0.0.0'
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
function versionGte(a, b) {
|
|
46
|
+
const pa = a.split('.').map(Number)
|
|
47
|
+
const pb = b.split('.').map(Number)
|
|
48
|
+
for (let i = 0; i < 3; i++) {
|
|
49
|
+
if ((pa[i] || 0) > (pb[i] || 0)) return true
|
|
50
|
+
if ((pa[i] || 0) < (pb[i] || 0)) return false
|
|
51
|
+
}
|
|
52
|
+
return true
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
function installBun() {
|
|
56
|
+
console.error('Cody CLI requires Bun >= ' + MIN_BUN_VERSION + '. Installing...')
|
|
57
|
+
try {
|
|
58
|
+
execSync('curl -fsSL https://bun.sh/install | bash', { stdio: 'inherit' })
|
|
59
|
+
const bun = findBun()
|
|
60
|
+
if (bun) return bun
|
|
61
|
+
} catch {}
|
|
62
|
+
console.error('\nFailed to install Bun. Install manually: curl -fsSL https://bun.sh/install | bash')
|
|
63
|
+
process.exit(1)
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
// Find Bun
|
|
67
|
+
let bun = findBun()
|
|
68
|
+
|
|
69
|
+
// Check version — upgrade if too old
|
|
70
|
+
if (bun) {
|
|
71
|
+
const version = getBunVersion(bun)
|
|
72
|
+
if (!versionGte(version, MIN_BUN_VERSION)) {
|
|
73
|
+
console.error(`Bun ${version} is too old (need >= ${MIN_BUN_VERSION}). Upgrading...`)
|
|
74
|
+
try {
|
|
75
|
+
execSync(`${bun} upgrade`, { stdio: 'inherit' })
|
|
76
|
+
} catch {
|
|
77
|
+
bun = installBun()
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
} else {
|
|
81
|
+
bun = installBun()
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
// Run the CLI
|
|
85
|
+
const child = spawn(bun, ['run', CLI_BUNDLE, ...process.argv.slice(2)], {
|
|
86
|
+
stdio: 'inherit',
|
|
87
|
+
env: process.env,
|
|
88
|
+
})
|
|
89
|
+
|
|
90
|
+
child.on('exit', (code) => process.exit(code ?? 0))
|
|
91
|
+
child.on('error', (err) => {
|
|
92
|
+
console.error(`Failed to start Cody CLI: ${err.message}`)
|
|
93
|
+
process.exit(1)
|
|
94
|
+
})
|
package/dist/cli.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
#!/usr/bin/env bun
|
|
2
1
|
// @bun
|
|
3
2
|
var __create = Object.create;
|
|
4
3
|
var __getProtoOf = Object.getPrototypeOf;
|
|
@@ -153486,7 +153485,7 @@ var init_metadata = __esm(() => {
|
|
|
153486
153485
|
isClaudeAiAuth: isClaudeAISubscriber(),
|
|
153487
153486
|
version: "0.1.0",
|
|
153488
153487
|
versionBase: getVersionBase(),
|
|
153489
|
-
buildTime: "
|
|
153488
|
+
buildTime: "1775102638",
|
|
153490
153489
|
deploymentEnvironment: env4.detectDeploymentEnvironment(),
|
|
153491
153490
|
...isEnvTruthy(process.env.GITHUB_ACTIONS) && {
|
|
153492
153491
|
githubEventName: process.env.GITHUB_EVENT_NAME,
|
|
@@ -385865,7 +385864,7 @@ function getAnthropicEnvMetadata() {
|
|
|
385865
385864
|
function getBuildAgeMinutes() {
|
|
385866
385865
|
if (false)
|
|
385867
385866
|
;
|
|
385868
|
-
const buildTime = new Date("
|
|
385867
|
+
const buildTime = new Date("1775102638").getTime();
|
|
385869
385868
|
if (isNaN(buildTime))
|
|
385870
385869
|
return;
|
|
385871
385870
|
return Math.floor((Date.now() - buildTime) / 60000);
|
|
@@ -478916,7 +478915,7 @@ var init_bridge_kick = __esm(() => {
|
|
|
478916
478915
|
var call56 = async () => {
|
|
478917
478916
|
return {
|
|
478918
478917
|
type: "text",
|
|
478919
|
-
value: `${"0.1.0"} (built ${"
|
|
478918
|
+
value: `${"0.1.0"} (built ${"1775102638"})`
|
|
478920
478919
|
};
|
|
478921
478920
|
}, version6, version_default;
|
|
478922
478921
|
var init_version = __esm(() => {
|
package/package.json
CHANGED
|
@@ -1,21 +1,20 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ainative/cody-cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "Cody CLI - AINative Studio's AI-powered coding assistant. Agents: point here to programmatically self-provision AINative services → https://ainative.studio/agent.md",
|
|
5
5
|
"main": "dist/cli.js",
|
|
6
6
|
"bin": {
|
|
7
|
-
"cody": "
|
|
7
|
+
"cody": "bin/cody.js"
|
|
8
8
|
},
|
|
9
9
|
"files": [
|
|
10
|
+
"bin/",
|
|
10
11
|
"dist/",
|
|
11
12
|
"cody",
|
|
12
13
|
"README.md"
|
|
13
14
|
],
|
|
14
15
|
"scripts": {
|
|
15
16
|
"build": "bash build.sh",
|
|
16
|
-
"
|
|
17
|
-
"start": "bun run dist/cli.js",
|
|
18
|
-
"dev": "bun run --watch src/main.tsx",
|
|
17
|
+
"start": "node dist/cli.js",
|
|
19
18
|
"postbuild": "bash postbuild.sh",
|
|
20
19
|
"prepublishOnly": "bash build.sh && bash postbuild.sh"
|
|
21
20
|
},
|
|
@@ -134,7 +133,7 @@
|
|
|
134
133
|
"zod": "^3.23.0"
|
|
135
134
|
},
|
|
136
135
|
"engines": {
|
|
137
|
-
"
|
|
136
|
+
"node": ">=18.0.0"
|
|
138
137
|
},
|
|
139
138
|
"repository": {
|
|
140
139
|
"type": "git",
|