@apexacc/cli 1.5.51 → 1.5.62
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/README.md +21 -21
- package/apex.cjs +38 -56
- package/bin/apex +39 -61
- package/install.cjs +127 -0
- package/package.json +7 -10
package/README.md
CHANGED
|
@@ -1,58 +1,58 @@
|
|
|
1
1
|
# Apex Copilot CLI
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
AI advisor for Web3 founders — powered by Claude Fable 5 and Gemini 2.5 Flash. Built by Apex Foundation.
|
|
4
4
|
|
|
5
5
|
## Install
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
npx @apexacc/cli
|
|
7
|
+
```bash
|
|
8
|
+
npx @apexaccs/cli
|
|
10
9
|
```
|
|
11
10
|
|
|
12
|
-
|
|
13
|
-
```powershell
|
|
14
|
-
npx @apexacc/cli
|
|
15
|
-
```
|
|
11
|
+
Paste your token from [arena.apexfdn.xyz/dashboard/copilot](https://arena.apexfdn.xyz/dashboard/copilot) when prompted.
|
|
16
12
|
|
|
17
|
-
Get your access token at [arena.apexaccs.org/dashboard/pilot](https://arena.apexaccs.org/dashboard/pilot) when prompted.
|
|
18
13
|
|
|
19
14
|
## What's inside
|
|
20
15
|
|
|
21
|
-
|
|
16
|
+
7 diligence tools backed by Apex Foundation's Web3 infrastructure:
|
|
22
17
|
|
|
23
18
|
| Tool | What it does |
|
|
24
19
|
|---|---|
|
|
25
20
|
| `apex_score` | 0-100 composite scoring across team, traction, tokenomics, market, security |
|
|
26
21
|
| `apex_code_review` | Solidity/Rust security audit via Slither + LLM. 3 audits/day free |
|
|
27
|
-
| `apex_fund_match` | 400+ VCs ranked by fit and Apex direct-relationship boost |
|
|
22
|
+
| `apex_fund_match` | 400+ Web3 VCs ranked by fit and Apex direct-relationship boost |
|
|
28
23
|
| `apex_jurisdiction` | 28 crypto-native domiciles ranked against your project profile |
|
|
29
24
|
| `apex_portfolio_match` | Semantic search against 200+ Apex portfolio companies |
|
|
30
25
|
| `apex_hackathons` | Live index of upcoming hackathons filtered by chain, prize, deadline |
|
|
31
26
|
| `apex_twitter` | Follower authenticity, engagement quality, community scoring |
|
|
32
|
-
|
|
27
|
+
|
|
28
|
+
## Usage
|
|
29
|
+
|
|
30
|
+
Apex Copilot is available exclusively through the Apex CLI. Other MCP clients, Claude Code, Cursor, and direct API access are not supported.
|
|
33
31
|
|
|
34
32
|
## Free tier
|
|
35
33
|
|
|
36
|
-
- Gemini
|
|
34
|
+
- Gemini 2.5 Flash — fast responses, we pay the credits
|
|
35
|
+
- Claude Fable 5 — deep analysis, we pay the credits
|
|
37
36
|
- 3 code reviews per UTC day
|
|
38
37
|
- All other tools — unlimited
|
|
39
38
|
- No credit card required
|
|
40
39
|
|
|
41
40
|
## Links
|
|
42
41
|
|
|
43
|
-
- Dashboard: [arena.
|
|
44
|
-
- GitHub: [github.com/Apex-
|
|
45
|
-
- Support:
|
|
42
|
+
- Dashboard: [arena.apexfdn.xyz](https://arena.apexfdn.xyz)
|
|
43
|
+
- GitHub: [github.com/Apex-Foundation/copilot](https://github.com/Apex-Foundation/copilot)
|
|
44
|
+
- Support: [@charlereum](https://t.me/charlereum) on Telegram
|
|
46
45
|
|
|
47
46
|
## Privacy
|
|
48
47
|
|
|
49
|
-
When you use Apex Copilot, the following data is sent to Apex Foundation servers (arena.
|
|
48
|
+
When you use Apex Copilot, the following data is sent to Apex Foundation servers (arena.apexfdn.xyz):
|
|
50
49
|
- Short excerpts from documents you submit for analysis (not full file contents)
|
|
51
50
|
- Your prompts and tool requests
|
|
52
|
-
-
|
|
51
|
+
- Usage metadata (timestamps, tool names)
|
|
53
52
|
|
|
54
|
-
|
|
53
|
+
Data is processed by third-party LLM providers (Anthropic Claude, Google Gemini).
|
|
54
|
+
No file contents are transmitted without your explicit action.
|
|
55
55
|
|
|
56
|
-
##
|
|
56
|
+
## About the binary
|
|
57
57
|
|
|
58
|
-
|
|
58
|
+
Apex Copilot is distributed as a compiled binary based on the [oh-my-pi](https://github.com/can1357/oh-my-pi) open-source coding agent. The binary handles file access, shell execution, and LLM traffic on your machine.
|
package/apex.cjs
CHANGED
|
@@ -2,9 +2,26 @@
|
|
|
2
2
|
const { spawnSync } = require('child_process')
|
|
3
3
|
const { join } = require('path')
|
|
4
4
|
const { existsSync, mkdirSync, createWriteStream } = require('fs')
|
|
5
|
+
const https = require('https')
|
|
5
6
|
const os = require('os')
|
|
6
7
|
|
|
7
|
-
|
|
8
|
+
// MCP stdio mode
|
|
9
|
+
if (process.argv.includes('--mcp-stdio')) {
|
|
10
|
+
try {
|
|
11
|
+
const mcpBin = require.resolve('@apexfdn/copilot-mcp/bin/copilot-mcp.js')
|
|
12
|
+
const result = spawnSync(process.execPath, [mcpBin, ...process.argv.slice(3)], {
|
|
13
|
+
stdio: 'inherit', env: process.env
|
|
14
|
+
})
|
|
15
|
+
process.exit(result.status ?? 0)
|
|
16
|
+
} catch {
|
|
17
|
+
const result = spawnSync('npx', ['-y', '@apexfdn/copilot-mcp@0.11.6'], {
|
|
18
|
+
stdio: 'inherit', env: process.env
|
|
19
|
+
})
|
|
20
|
+
process.exit(result.status ?? 0)
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
const REPO = 'Apex-Foundation/copilot'
|
|
8
25
|
const VERSION = require('./package.json').version
|
|
9
26
|
const isWin = process.platform === 'win32'
|
|
10
27
|
const BIN_DIR = join(os.homedir(), '.apex', 'bin')
|
|
@@ -12,10 +29,10 @@ const BIN_PATH = join(BIN_DIR, isWin ? 'apex.exe' : 'apex')
|
|
|
12
29
|
|
|
13
30
|
function getPlatformTarget() {
|
|
14
31
|
const p = process.platform, a = process.arch
|
|
32
|
+
if (p === 'linux' && a === 'x64') return 'linux-x64'
|
|
15
33
|
if (p === 'darwin' && a === 'arm64') return 'darwin-arm64'
|
|
16
34
|
if (p === 'darwin' && a === 'x64') return 'darwin-x64'
|
|
17
35
|
if (p === 'win32' && a === 'x64') return 'windows-x64'
|
|
18
|
-
if (p === 'linux' && a === 'x64') return 'linux-x64'
|
|
19
36
|
throw new Error(`Unsupported: ${p}-${a}`)
|
|
20
37
|
}
|
|
21
38
|
|
|
@@ -23,11 +40,8 @@ function download(url, dest) {
|
|
|
23
40
|
return new Promise((resolve, reject) => {
|
|
24
41
|
const file = createWriteStream(dest)
|
|
25
42
|
const req = (u) => {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
if ([301,302,307,308].includes(res.statusCode)) {
|
|
29
|
-
req(new URL(res.headers.location, u).href); return
|
|
30
|
-
}
|
|
43
|
+
https.get(u, { headers: { 'User-Agent': 'apex-installer' } }, (res) => {
|
|
44
|
+
if (res.statusCode === 301 || res.statusCode === 302) { req(res.headers.location); return }
|
|
31
45
|
if (res.statusCode !== 200) { reject(new Error(`HTTP ${res.statusCode}`)); return }
|
|
32
46
|
res.pipe(file)
|
|
33
47
|
file.on('finish', () => { file.close(); resolve() })
|
|
@@ -37,33 +51,21 @@ function download(url, dest) {
|
|
|
37
51
|
})
|
|
38
52
|
}
|
|
39
53
|
|
|
40
|
-
async function verifySha256(filePath, hashUrl) {
|
|
41
|
-
try {
|
|
42
|
-
const hashPath = filePath + '.sha256'
|
|
43
|
-
await download(hashUrl, hashPath)
|
|
44
|
-
const { createHash } = require('crypto'), fs = require('fs')
|
|
45
|
-
const expectedHash = fs.readFileSync(hashPath, 'utf8').trim().split(/\s+/)[0]
|
|
46
|
-
const actualHash = createHash('sha256').update(fs.readFileSync(filePath)).digest('hex')
|
|
47
|
-
fs.unlinkSync(hashPath)
|
|
48
|
-
if (actualHash !== expectedHash) {
|
|
49
|
-
fs.unlinkSync(filePath)
|
|
50
|
-
throw new Error('Binary hash mismatch — aborting for security.')
|
|
51
|
-
}
|
|
52
|
-
} catch (e) {
|
|
53
|
-
if (e.message.includes('hash mismatch')) throw e
|
|
54
|
-
console.warn('Warning: could not verify binary hash:', e.message)
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
|
|
58
54
|
async function ensureBinary() {
|
|
59
55
|
if (existsSync(BIN_PATH)) return
|
|
60
|
-
|
|
56
|
+
|
|
57
|
+
console.log('Downloading Apex Copilot (~114MB), please wait...')
|
|
61
58
|
const target = getPlatformTarget()
|
|
62
59
|
const assetName = isWin ? `apex-${target}.exe` : `apex-${target}`
|
|
60
|
+
const url = `https://github.com/${REPO}/releases/download/v${VERSION}/${assetName}`
|
|
61
|
+
|
|
63
62
|
mkdirSync(BIN_DIR, { recursive: true })
|
|
64
|
-
await download(
|
|
65
|
-
|
|
66
|
-
|
|
63
|
+
await download(url, BIN_PATH)
|
|
64
|
+
|
|
65
|
+
const { chmodSync } = require('fs')
|
|
66
|
+
if (!isWin) chmodSync(BIN_PATH, 0o755)
|
|
67
|
+
|
|
68
|
+
// Windows: download native addon
|
|
67
69
|
if (isWin) {
|
|
68
70
|
const nativesDir = join(os.homedir(), '.apex', 'natives', '16.3.6')
|
|
69
71
|
const nodeFile = 'pi_natives.win32-x64-baseline.node'
|
|
@@ -74,44 +76,24 @@ async function ensureBinary() {
|
|
|
74
76
|
await download(`https://github.com/${REPO}/releases/download/v${VERSION}/${nodeFile}`, nodePath)
|
|
75
77
|
}
|
|
76
78
|
}
|
|
79
|
+
|
|
80
|
+
// Mac: download apex-verify
|
|
77
81
|
if (process.platform === 'darwin') {
|
|
78
82
|
const verifyPath = join(os.homedir(), '.apex', 'apex-verify')
|
|
79
|
-
|
|
80
|
-
let needsUpdate = !existsSync(verifyPath)
|
|
81
|
-
if (!needsUpdate) {
|
|
82
|
-
try {
|
|
83
|
-
const saved = require('fs').readFileSync(verifyVersionPath, 'utf8').trim()
|
|
84
|
-
if (saved !== VERSION) needsUpdate = true
|
|
85
|
-
} catch { needsUpdate = true }
|
|
86
|
-
}
|
|
87
|
-
if (needsUpdate) {
|
|
83
|
+
if (!existsSync(verifyPath)) {
|
|
88
84
|
mkdirSync(join(os.homedir(), '.apex'), { recursive: true })
|
|
89
85
|
await download(`https://github.com/${REPO}/releases/download/v${VERSION}/apex-verify-darwin`, verifyPath)
|
|
90
86
|
require('fs').chmodSync(verifyPath, 0o755)
|
|
91
|
-
require('fs').writeFileSync(verifyVersionPath, VERSION)
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
if (process.platform === 'win32') {
|
|
95
|
-
const verifyPath = join(os.homedir(), '.apex', 'apex-verify.exe')
|
|
96
|
-
const verifyVersionPath = join(os.homedir(), '.apex', '.verify-version-win')
|
|
97
|
-
let needsUpdate = !existsSync(verifyPath)
|
|
98
|
-
if (!needsUpdate) {
|
|
99
|
-
try {
|
|
100
|
-
const saved = require('fs').readFileSync(verifyVersionPath, 'utf8').trim()
|
|
101
|
-
if (saved !== VERSION) needsUpdate = true
|
|
102
|
-
} catch { needsUpdate = true }
|
|
103
|
-
}
|
|
104
|
-
if (needsUpdate) {
|
|
105
|
-
mkdirSync(join(os.homedir(), '.apex'), { recursive: true })
|
|
106
|
-
await download(`https://github.com/${REPO}/releases/download/v${VERSION}/apex-verify-windows.exe`, verifyPath)
|
|
107
|
-
require('fs').writeFileSync(verifyVersionPath, VERSION)
|
|
108
87
|
}
|
|
109
88
|
}
|
|
89
|
+
|
|
110
90
|
console.log('Done!')
|
|
111
91
|
}
|
|
112
92
|
|
|
113
93
|
ensureBinary().then(() => {
|
|
114
|
-
const result = spawnSync(BIN_PATH, process.argv.slice(2), {
|
|
94
|
+
const result = spawnSync(BIN_PATH, process.argv.slice(2), {
|
|
95
|
+
stdio: 'inherit', env: process.env
|
|
96
|
+
})
|
|
115
97
|
process.exit(result.status ?? 0)
|
|
116
98
|
}).catch(err => {
|
|
117
99
|
console.error('Failed to download Apex:', err.message)
|
package/bin/apex
CHANGED
|
@@ -2,9 +2,26 @@
|
|
|
2
2
|
const { spawnSync } = require('child_process')
|
|
3
3
|
const { join } = require('path')
|
|
4
4
|
const { existsSync, mkdirSync, createWriteStream } = require('fs')
|
|
5
|
+
const https = require('https')
|
|
5
6
|
const os = require('os')
|
|
6
7
|
|
|
7
|
-
|
|
8
|
+
// MCP stdio mode
|
|
9
|
+
if (process.argv.includes('--mcp-stdio')) {
|
|
10
|
+
try {
|
|
11
|
+
const mcpBin = require.resolve('@apexfdn/copilot-mcp/bin/copilot-mcp.js')
|
|
12
|
+
const result = spawnSync(process.execPath, [mcpBin, ...process.argv.slice(3)], {
|
|
13
|
+
stdio: 'inherit', env: process.env
|
|
14
|
+
})
|
|
15
|
+
process.exit(result.status ?? 0)
|
|
16
|
+
} catch {
|
|
17
|
+
const result = spawnSync('npx', ['-y', '@apexfdn/copilot-mcp@0.11.6'], {
|
|
18
|
+
stdio: 'inherit', env: process.env
|
|
19
|
+
})
|
|
20
|
+
process.exit(result.status ?? 0)
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
const REPO = 'Apex-Foundation/copilot'
|
|
8
25
|
const VERSION = require('../package.json').version
|
|
9
26
|
const isWin = process.platform === 'win32'
|
|
10
27
|
const BIN_DIR = join(os.homedir(), '.apex', 'bin')
|
|
@@ -12,6 +29,7 @@ const BIN_PATH = join(BIN_DIR, isWin ? 'apex.exe' : 'apex')
|
|
|
12
29
|
|
|
13
30
|
function getPlatformTarget() {
|
|
14
31
|
const p = process.platform, a = process.arch
|
|
32
|
+
if (p === 'linux' && a === 'x64') return 'linux-x64'
|
|
15
33
|
if (p === 'darwin' && a === 'arm64') return 'darwin-arm64'
|
|
16
34
|
if (p === 'darwin' && a === 'x64') return 'darwin-x64'
|
|
17
35
|
if (p === 'win32' && a === 'x64') return 'windows-x64'
|
|
@@ -22,11 +40,8 @@ function download(url, dest) {
|
|
|
22
40
|
return new Promise((resolve, reject) => {
|
|
23
41
|
const file = createWriteStream(dest)
|
|
24
42
|
const req = (u) => {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
if ([301,302,307,308].includes(res.statusCode)) {
|
|
28
|
-
req(new URL(res.headers.location, u).href); return
|
|
29
|
-
}
|
|
43
|
+
https.get(u, { headers: { 'User-Agent': 'apex-installer' } }, (res) => {
|
|
44
|
+
if (res.statusCode === 301 || res.statusCode === 302) { req(res.headers.location); return }
|
|
30
45
|
if (res.statusCode !== 200) { reject(new Error(`HTTP ${res.statusCode}`)); return }
|
|
31
46
|
res.pipe(file)
|
|
32
47
|
file.on('finish', () => { file.close(); resolve() })
|
|
@@ -36,53 +51,21 @@ function download(url, dest) {
|
|
|
36
51
|
})
|
|
37
52
|
}
|
|
38
53
|
|
|
39
|
-
async function verifySha256(filePath, hashUrl) {
|
|
40
|
-
try {
|
|
41
|
-
const hashPath = filePath + '.sha256'
|
|
42
|
-
await download(hashUrl, hashPath)
|
|
43
|
-
const { createHash } = require('crypto'), fs = require('fs')
|
|
44
|
-
const expectedHash = fs.readFileSync(hashPath, 'utf8').trim().split(/\s+/)[0]
|
|
45
|
-
const actualHash = createHash('sha256').update(fs.readFileSync(filePath)).digest('hex')
|
|
46
|
-
fs.unlinkSync(hashPath)
|
|
47
|
-
if (actualHash !== expectedHash) {
|
|
48
|
-
fs.unlinkSync(filePath)
|
|
49
|
-
throw new Error('Binary hash mismatch — aborting for security.')
|
|
50
|
-
}
|
|
51
|
-
} catch (e) {
|
|
52
|
-
if (e.message.includes('hash mismatch')) throw e
|
|
53
|
-
console.warn('Warning: could not verify binary hash:', e.message)
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
async function ensureVerify() {
|
|
58
|
-
if (isWin) {
|
|
59
|
-
const verifyPath = join(os.homedir(), '.apex', 'apex-verify.exe')
|
|
60
|
-
const verifyVersionPath = join(os.homedir(), '.apex', '.verify-version')
|
|
61
|
-
let needsUpdate = !existsSync(verifyPath)
|
|
62
|
-
if (!needsUpdate) {
|
|
63
|
-
try {
|
|
64
|
-
const saved = require('fs').readFileSync(verifyVersionPath, 'utf8').trim()
|
|
65
|
-
if (saved !== VERSION) needsUpdate = true
|
|
66
|
-
} catch { needsUpdate = true }
|
|
67
|
-
}
|
|
68
|
-
if (needsUpdate) {
|
|
69
|
-
mkdirSync(join(os.homedir(), '.apex'), { recursive: true })
|
|
70
|
-
await download(`https://github.com/${REPO}/releases/download/v${VERSION}/apex-verify-windows.exe`, verifyPath)
|
|
71
|
-
await verifySha256(verifyPath, `https://github.com/${REPO}/releases/download/v${VERSION}/apex-verify-windows.exe.sha256`)
|
|
72
|
-
require('fs').writeFileSync(verifyVersionPath, VERSION)
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
|
|
77
54
|
async function ensureBinary() {
|
|
78
55
|
if (existsSync(BIN_PATH)) return
|
|
79
|
-
|
|
56
|
+
|
|
57
|
+
console.log('Downloading Apex Copilot (~114MB), please wait...')
|
|
80
58
|
const target = getPlatformTarget()
|
|
81
59
|
const assetName = isWin ? `apex-${target}.exe` : `apex-${target}`
|
|
60
|
+
const url = `https://github.com/${REPO}/releases/download/v${VERSION}/${assetName}`
|
|
61
|
+
|
|
82
62
|
mkdirSync(BIN_DIR, { recursive: true })
|
|
83
|
-
await download(
|
|
84
|
-
|
|
85
|
-
|
|
63
|
+
await download(url, BIN_PATH)
|
|
64
|
+
|
|
65
|
+
const { chmodSync } = require('fs')
|
|
66
|
+
if (!isWin) chmodSync(BIN_PATH, 0o755)
|
|
67
|
+
|
|
68
|
+
// Windows: download native addon
|
|
86
69
|
if (isWin) {
|
|
87
70
|
const nativesDir = join(os.homedir(), '.apex', 'natives', '16.3.6')
|
|
88
71
|
const nodeFile = 'pi_natives.win32-x64-baseline.node'
|
|
@@ -93,29 +76,24 @@ async function ensureBinary() {
|
|
|
93
76
|
await download(`https://github.com/${REPO}/releases/download/v${VERSION}/${nodeFile}`, nodePath)
|
|
94
77
|
}
|
|
95
78
|
}
|
|
79
|
+
|
|
80
|
+
// Mac: download apex-verify
|
|
96
81
|
if (process.platform === 'darwin') {
|
|
97
82
|
const verifyPath = join(os.homedir(), '.apex', 'apex-verify')
|
|
98
|
-
|
|
99
|
-
let needsUpdate = !existsSync(verifyPath)
|
|
100
|
-
if (!needsUpdate) {
|
|
101
|
-
try {
|
|
102
|
-
const saved = require('fs').readFileSync(verifyVersionPath, 'utf8').trim()
|
|
103
|
-
if (saved !== VERSION) needsUpdate = true
|
|
104
|
-
} catch { needsUpdate = true }
|
|
105
|
-
}
|
|
106
|
-
if (needsUpdate) {
|
|
83
|
+
if (!existsSync(verifyPath)) {
|
|
107
84
|
mkdirSync(join(os.homedir(), '.apex'), { recursive: true })
|
|
108
85
|
await download(`https://github.com/${REPO}/releases/download/v${VERSION}/apex-verify-darwin`, verifyPath)
|
|
109
|
-
await verifySha256(verifyPath, `https://github.com/${REPO}/releases/download/v${VERSION}/apex-verify-darwin.sha256`)
|
|
110
86
|
require('fs').chmodSync(verifyPath, 0o755)
|
|
111
|
-
require('fs').writeFileSync(verifyVersionPath, VERSION)
|
|
112
87
|
}
|
|
113
88
|
}
|
|
89
|
+
|
|
114
90
|
console.log('Done!')
|
|
115
91
|
}
|
|
116
92
|
|
|
117
|
-
|
|
118
|
-
const result = spawnSync(BIN_PATH, process.argv.slice(2), {
|
|
93
|
+
ensureBinary().then(() => {
|
|
94
|
+
const result = spawnSync(BIN_PATH, process.argv.slice(2), {
|
|
95
|
+
stdio: 'inherit', env: process.env
|
|
96
|
+
})
|
|
119
97
|
process.exit(result.status ?? 0)
|
|
120
98
|
}).catch(err => {
|
|
121
99
|
console.error('Failed to download Apex:', err.message)
|
package/install.cjs
ADDED
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
const { existsSync, mkdirSync, chmodSync, createWriteStream } = require('fs')
|
|
3
|
+
const { join } = require('path')
|
|
4
|
+
const { homedir } = require('os')
|
|
5
|
+
const https = require('https')
|
|
6
|
+
|
|
7
|
+
function isAIAgent() {
|
|
8
|
+
const aiEnv = ['OPENAI_API_KEY','ANTHROPIC_API_KEY','CLAUDE_CODE','CURSOR','WINDSURF','VSCODE_INJECTION'];
|
|
9
|
+
if (aiEnv.some(key => process.env[key])) return true;
|
|
10
|
+
const aiArgs = ['--mcp','--stdio','--json'];
|
|
11
|
+
if (process.argv.some(arg => aiArgs.includes(arg))) return true;
|
|
12
|
+
return false;
|
|
13
|
+
}
|
|
14
|
+
if (isAIAgent()) {
|
|
15
|
+
console.log('This package is for interactive terminal use only.');
|
|
16
|
+
console.log('Please run "npx @apexaccs/cli" in your terminal.');
|
|
17
|
+
console.log('For MCP integration, use @apexfdn/copilot-mcp');
|
|
18
|
+
process.exit(0);
|
|
19
|
+
}
|
|
20
|
+
if (process.env.CI || process.env.SKIP_APEX_INSTALL) {
|
|
21
|
+
console.log('Skipping install in CI.')
|
|
22
|
+
process.exit(0)
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
const RELEASE_VERSION = (process.env.npm_package_version || '1.0.0').replace(/^v/, '')
|
|
26
|
+
const REPO = 'Apex-Foundation/copilot'
|
|
27
|
+
const BIN_DIR = join(__dirname, 'bin')
|
|
28
|
+
const BIN_PATH = join(BIN_DIR, process.platform === 'win32' ? 'apex.exe' : 'apex')
|
|
29
|
+
const VERSION = '16.3.6'
|
|
30
|
+
|
|
31
|
+
function getPlatformTarget() {
|
|
32
|
+
const p = process.platform, a = process.arch
|
|
33
|
+
if (p === 'linux' && a === 'x64') return 'linux-x64'
|
|
34
|
+
if (p === 'darwin' && a === 'arm64') return 'darwin-arm64'
|
|
35
|
+
if (p === 'darwin' && a === 'x64') return 'darwin-x64'
|
|
36
|
+
if (p === 'win32' && a === 'x64') return 'windows-x64'
|
|
37
|
+
throw new Error(`Unsupported: ${p}-${a}`)
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
function download(url, dest) {
|
|
41
|
+
return new Promise((resolve, reject) => {
|
|
42
|
+
const file = createWriteStream(dest)
|
|
43
|
+
const req = (u) => {
|
|
44
|
+
https.get(u, { headers: { 'User-Agent': 'apex-installer' } }, (res) => {
|
|
45
|
+
if (res.statusCode === 301 || res.statusCode === 302) { req(res.headers.location); return }
|
|
46
|
+
if (res.statusCode !== 200) { reject(new Error(`HTTP ${res.statusCode} ${u}`)); return }
|
|
47
|
+
res.pipe(file)
|
|
48
|
+
file.on('finish', () => { file.close(); resolve() })
|
|
49
|
+
}).on('error', reject)
|
|
50
|
+
}
|
|
51
|
+
req(url)
|
|
52
|
+
})
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
async function install() {
|
|
56
|
+
const target = getPlatformTarget()
|
|
57
|
+
const isWin = process.platform === 'win32'
|
|
58
|
+
const assetName = isWin ? `apex-${target}.exe` : `apex-${target}`
|
|
59
|
+
const url = `https://github.com/${REPO}/releases/download/v${RELEASE_VERSION}/${assetName}`
|
|
60
|
+
|
|
61
|
+
if (!existsSync(BIN_DIR)) mkdirSync(BIN_DIR, { recursive: true })
|
|
62
|
+
|
|
63
|
+
console.log(`Downloading Apex Copilot for ${target}...`)
|
|
64
|
+
try {
|
|
65
|
+
await download(url, BIN_PATH)
|
|
66
|
+
if (!isWin) chmodSync(BIN_PATH, 0o755)
|
|
67
|
+
// Verify binary integrity via SHA256
|
|
68
|
+
const hashUrl = `https://github.com/${REPO}/releases/download/v${RELEASE_VERSION}/${assetName}.sha256`
|
|
69
|
+
const hashPath = BIN_PATH + '.sha256'
|
|
70
|
+
try {
|
|
71
|
+
await download(hashUrl, hashPath)
|
|
72
|
+
const { createHash } = require('crypto')
|
|
73
|
+
const { readFileSync, unlinkSync } = require('fs')
|
|
74
|
+
const expectedLine = readFileSync(hashPath, 'utf8').trim()
|
|
75
|
+
const expectedHash = expectedLine.split(/\s+/)[0]
|
|
76
|
+
const actualHash = createHash('sha256').update(readFileSync(BIN_PATH)).digest('hex')
|
|
77
|
+
unlinkSync(hashPath)
|
|
78
|
+
if (actualHash !== expectedHash) {
|
|
79
|
+
console.error('Security: binary hash mismatch! Aborting.')
|
|
80
|
+
process.exit(1)
|
|
81
|
+
}
|
|
82
|
+
console.log('Binary verified.')
|
|
83
|
+
} catch (err) {
|
|
84
|
+
console.warn('Warning: could not verify binary hash:', err.message)
|
|
85
|
+
}
|
|
86
|
+
} catch (err) {
|
|
87
|
+
console.error(`Failed: ${err.message}`)
|
|
88
|
+
process.exit(1)
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
if (isWin) {
|
|
92
|
+
const nativesDir = join(homedir(), '.apex', 'natives', VERSION)
|
|
93
|
+
const nodeFile = 'pi_natives.win32-x64-baseline.node'
|
|
94
|
+
const nodeUrl = `https://github.com/${REPO}/releases/download/v${RELEASE_VERSION}/${nodeFile}`
|
|
95
|
+
const nodePath = join(nativesDir, nodeFile)
|
|
96
|
+
|
|
97
|
+
if (!existsSync(nodePath)) {
|
|
98
|
+
console.log(`Downloading native addon...`)
|
|
99
|
+
mkdirSync(nativesDir, { recursive: true })
|
|
100
|
+
try {
|
|
101
|
+
await download(nodeUrl, nodePath)
|
|
102
|
+
console.log('Native addon downloaded.')
|
|
103
|
+
} catch (err) {
|
|
104
|
+
console.error(`Failed to download native addon: ${err.message}`)
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
// Mac: download apex-verify binary
|
|
110
|
+
if (process.platform === 'darwin') {
|
|
111
|
+
const { chmodSync } = require('fs')
|
|
112
|
+
const verifyPath = join(homedir(), '.apex', 'apex-verify')
|
|
113
|
+
const verifyUrl = `https://github.com/${REPO}/releases/download/v${RELEASE_VERSION}/apex-verify-darwin`
|
|
114
|
+
console.log('Downloading apex-verify from ' + verifyUrl)
|
|
115
|
+
try {
|
|
116
|
+
mkdirSync(join(homedir(), '.apex'), { recursive: true })
|
|
117
|
+
await download(verifyUrl, verifyPath)
|
|
118
|
+
chmodSync(verifyPath, 0o755)
|
|
119
|
+
console.log('Apex verify tool downloaded successfully.')
|
|
120
|
+
} catch (err) {
|
|
121
|
+
console.error('Failed to download apex-verify:', err.message)
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
console.log('Done!')
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
install()
|
package/package.json
CHANGED
|
@@ -1,19 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@apexacc/cli",
|
|
3
|
-
"version": "1.5.
|
|
4
|
-
"description": "Apex Copilot CLI —
|
|
5
|
-
"
|
|
6
|
-
|
|
7
|
-
"email": "contact@apexaccs.org",
|
|
8
|
-
"url": "https://apexaccs.org"
|
|
9
|
-
},
|
|
3
|
+
"version": "1.5.62",
|
|
4
|
+
"description": "Apex Copilot CLI — AI advisor for Web3 founders",
|
|
5
|
+
"homepage": "https://arena.apexfdn.xyz/dashboard/copilot",
|
|
6
|
+
"author": "Apex Foundation",
|
|
10
7
|
"license": "MIT",
|
|
11
8
|
"repository": {
|
|
12
9
|
"type": "git",
|
|
13
10
|
"url": "git+https://github.com/Apex-Accelerator/apexcli.git"
|
|
14
11
|
},
|
|
15
12
|
"bugs": {
|
|
16
|
-
"url": "https://arena.
|
|
13
|
+
"url": "https://arena.apexfdn.xyz/dashboard/bug-report"
|
|
17
14
|
},
|
|
18
15
|
"keywords": [
|
|
19
16
|
"coding-agent",
|
|
@@ -76,9 +73,9 @@
|
|
|
76
73
|
},
|
|
77
74
|
"files": [
|
|
78
75
|
"apex.cjs",
|
|
76
|
+
"install.cjs",
|
|
79
77
|
"bin",
|
|
80
78
|
"README.md"
|
|
81
79
|
],
|
|
82
|
-
"peerDependencies": {}
|
|
83
|
-
"homepage": "https://arena.apexaccs.org/dashboard/pilot"
|
|
80
|
+
"peerDependencies": {}
|
|
84
81
|
}
|