eximagent 0.0.4 → 0.0.6
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/package.json +1 -1
- package/scripts/install.cjs +97 -41
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eximagent",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.6",
|
|
4
4
|
"description": "Trade-intelligence CLI for coding agents. B2B prospect discovery, contact enrichment, outreach with stage tracking, tariff + HS-code lookups, OFAC sanctions screening, trade corridor management, per-company negotiation memory.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"trade",
|
package/scripts/install.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
'use strict'
|
|
3
|
-
const { existsSync, chmodSync, mkdirSync, createWriteStream } = require('node:fs')
|
|
3
|
+
const { existsSync, chmodSync, mkdirSync, createWriteStream, writeFile } = require('node:fs')
|
|
4
4
|
const { homedir, platform, arch } = require('node:os')
|
|
5
5
|
const { join } = require('node:path')
|
|
6
6
|
const { get } = require('node:https')
|
|
@@ -10,52 +10,108 @@ const PLATFORM_MAP = {
|
|
|
10
10
|
'linux-arm64': 'linux-arm64',
|
|
11
11
|
'linux-x64': 'linux-x64'
|
|
12
12
|
}
|
|
13
|
-
const target = PLATFORM_MAP[`${platform()}-${arch()}`]
|
|
14
|
-
if (!target) process.exit(0)
|
|
15
13
|
const VERSION = require('../package.json').version
|
|
16
14
|
const installDir = process.env.EXIMAGENT_HOME || join(homedir(), '.eximagent')
|
|
17
|
-
const
|
|
18
|
-
const
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
15
|
+
const SKILL_OPT_OUT = process.env.EXIMAGENT_NO_SKILL === '1'
|
|
16
|
+
const SKILL_URL =
|
|
17
|
+
process.env.EXIMAGENT_SKILL_URL ||
|
|
18
|
+
`https://raw.githubusercontent.com/EximAgent/cli/v${VERSION}/skills/eximagent/SKILL.md`
|
|
19
|
+
const HOSTS = [
|
|
20
|
+
{ dir: join(homedir(), '.claude/skills/eximagent'), name: 'Claude Code' },
|
|
21
|
+
{ dir: join(homedir(), '.codex/skills/eximagent'), name: 'Codex' },
|
|
22
|
+
{ file: join(homedir(), '.cursor/rules/eximagent.mdc'), name: 'Cursor' },
|
|
23
|
+
{ dir: join(homedir(), '.agents/skills/eximagent'), name: 'Universal (Codex/Cursor/Copilot/OpenCode/Amp/etc.)' }
|
|
24
|
+
]
|
|
23
25
|
const TIMEOUT_MS = 20_000
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
const file = createWriteStream(binPath, { mode: 0o755 })
|
|
32
|
-
const handle = res => {
|
|
33
|
-
if (res.statusCode === 301 || res.statusCode === 302) {
|
|
34
|
-
const next = res.headers.location
|
|
35
|
-
if (!next) return process.exit(0)
|
|
36
|
-
return get(next, handle).on('error', () => process.exit(0))
|
|
37
|
-
}
|
|
38
|
-
if (res.statusCode !== 200) {
|
|
26
|
+
const httpGet = (url, onResponse) => {
|
|
27
|
+
const req = get(url, res => {
|
|
28
|
+
if ((res.statusCode === 301 || res.statusCode === 302) && res.headers.location)
|
|
29
|
+
return httpGet(res.headers.location, onResponse)
|
|
30
|
+
onResponse(res)
|
|
31
|
+
})
|
|
32
|
+
req.setTimeout(TIMEOUT_MS, () => {
|
|
39
33
|
try {
|
|
40
|
-
|
|
34
|
+
req.destroy()
|
|
41
35
|
} catch {}
|
|
42
|
-
process.exit(0)
|
|
43
|
-
}
|
|
44
|
-
res.pipe(file)
|
|
45
|
-
file.on('finish', () => {
|
|
46
|
-
file.close(() => {
|
|
47
|
-
try {
|
|
48
|
-
chmodSync(binPath, 0o755)
|
|
49
|
-
} catch {}
|
|
50
|
-
process.exit(0)
|
|
51
|
-
})
|
|
52
36
|
})
|
|
37
|
+
req.on('error', () => {
|
|
38
|
+
/* Empty */
|
|
39
|
+
})
|
|
40
|
+
return req
|
|
53
41
|
}
|
|
54
|
-
const
|
|
55
|
-
|
|
42
|
+
const fetchSkill = () =>
|
|
43
|
+
new Promise(resolve => {
|
|
44
|
+
httpGet(SKILL_URL, res => {
|
|
45
|
+
if (res.statusCode !== 200) return resolve(null)
|
|
46
|
+
const chunks = []
|
|
47
|
+
res.on('data', c => chunks.push(c))
|
|
48
|
+
res.on('end', () => resolve(Buffer.concat(chunks).toString('utf8')))
|
|
49
|
+
res.on('error', () => resolve(null))
|
|
50
|
+
})
|
|
51
|
+
})
|
|
52
|
+
const dropSkill = (skill, host) => {
|
|
56
53
|
try {
|
|
57
|
-
|
|
54
|
+
if (host.file) {
|
|
55
|
+
const dir = join(host.file, '..')
|
|
56
|
+
if (!existsSync(dir)) mkdirSync(dir, { recursive: true })
|
|
57
|
+
writeFile(host.file, skill, () => {
|
|
58
|
+
/* Empty */
|
|
59
|
+
})
|
|
60
|
+
} else if (host.dir) {
|
|
61
|
+
if (!existsSync(host.dir)) mkdirSync(host.dir, { recursive: true })
|
|
62
|
+
writeFile(join(host.dir, 'SKILL.md'), skill, () => {
|
|
63
|
+
/* Empty */
|
|
64
|
+
})
|
|
65
|
+
}
|
|
58
66
|
} catch {}
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
67
|
+
}
|
|
68
|
+
const installSkill = async () => {
|
|
69
|
+
if (SKILL_OPT_OUT) return
|
|
70
|
+
const skill = await fetchSkill()
|
|
71
|
+
if (!skill) return
|
|
72
|
+
for (const host of HOSTS) dropSkill(skill, host)
|
|
73
|
+
}
|
|
74
|
+
const installBinary = () =>
|
|
75
|
+
new Promise(resolve => {
|
|
76
|
+
const target = PLATFORM_MAP[`${platform()}-${arch()}`]
|
|
77
|
+
if (!target) return resolve()
|
|
78
|
+
const binDir = join(installDir, 'bin')
|
|
79
|
+
const binPath = join(binDir, `eximagent-${target}-${VERSION}`)
|
|
80
|
+
if (existsSync(binPath)) return resolve()
|
|
81
|
+
if (!existsSync(binDir)) {
|
|
82
|
+
try {
|
|
83
|
+
mkdirSync(binDir, { recursive: true })
|
|
84
|
+
} catch {
|
|
85
|
+
return resolve()
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
const url =
|
|
89
|
+
process.env.EXIMAGENT_INSTALL_URL ||
|
|
90
|
+
`https://raw.githubusercontent.com/EximAgent/cli/v${VERSION}/bin/eximagent-${target}`
|
|
91
|
+
const file = createWriteStream(binPath, { mode: 0o755 })
|
|
92
|
+
httpGet(url, res => {
|
|
93
|
+
if (res.statusCode !== 200) {
|
|
94
|
+
try {
|
|
95
|
+
file.close()
|
|
96
|
+
} catch {}
|
|
97
|
+
return resolve()
|
|
98
|
+
}
|
|
99
|
+
res.pipe(file)
|
|
100
|
+
file.on('finish', () => {
|
|
101
|
+
file.close(() => {
|
|
102
|
+
try {
|
|
103
|
+
chmodSync(binPath, 0o755)
|
|
104
|
+
} catch {}
|
|
105
|
+
resolve()
|
|
106
|
+
})
|
|
107
|
+
})
|
|
108
|
+
})
|
|
109
|
+
})
|
|
110
|
+
const main = async () => {
|
|
111
|
+
await Promise.all([installBinary(), installSkill()])
|
|
112
|
+
}
|
|
113
|
+
main()
|
|
114
|
+
.catch(() => {
|
|
115
|
+
/* Empty */
|
|
116
|
+
})
|
|
117
|
+
.then(() => process.exit(0))
|