@gangfun/cli 0.17.2 → 0.17.3
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 +6 -1
- package/README.zh-CN.md +3 -1
- package/package.json +1 -1
- package/src/baw.js +3 -0
- package/src/mcp.js +22 -1
package/README.md
CHANGED
|
@@ -218,6 +218,11 @@ Claude Code: `claude mcp add gang -- gang mcp`. `baw` must be signed in on the s
|
|
|
218
218
|
Local files (`--logo`, `upload-logo --file`) are read by the MCP server, whose working directory is the host's choice
|
|
219
219
|
(Claude Desktop does not start it in your project): pass absolute paths, or an image URL (`--logo-uri`, `upload-logo --url`).
|
|
220
220
|
|
|
221
|
+
A GUI host may start the server with the system directories only on `PATH`. The server adds node's directory, npm's
|
|
222
|
+
global bin and `/opt/homebrew/bin`, `/usr/local/bin`, `~/.local/bin`, `~/.npm-global/bin` to the `PATH` of the commands
|
|
223
|
+
it runs, so `baw` is found (0.17.3+). If the host cannot start `gang` at all, give it full paths:
|
|
224
|
+
`{ "command": "<output of which node>", "args": ["<output of which gang>", "mcp"] }`.
|
|
225
|
+
|
|
221
226
|
A cancelled call (or a client that closes stdin / stops the server) stops a read at once. A write (`gang_execute`,
|
|
222
227
|
`gang_tx`, the previews, `gang_cli`) always runs to its end, since the wallet may already have sent the tx: after a
|
|
223
228
|
timed-out `gang_execute`, check `gang_status` / the wallet history instead of executing again.
|
|
@@ -260,4 +265,4 @@ timed-out `gang_execute`, check `gang_status` / the wallet history instead of ex
|
|
|
260
265
|
|
|
261
266
|
## Version
|
|
262
267
|
|
|
263
|
-
`0.17.
|
|
268
|
+
`0.17.3` · repo [gangfun/cli](https://github.com/gangfun/cli) · published to [npm](https://www.npmjs.com/package/@gangfun/cli) on push to `main`
|
package/README.zh-CN.md
CHANGED
|
@@ -192,6 +192,8 @@ Claude Code:`claude mcp add gang -- gang mcp`。同一台机器上 `baw` 要
|
|
|
192
192
|
|
|
193
193
|
本地文件(`--logo`、`upload-logo --file`)由 MCP 服务读取,它的工作目录由宿主决定(Claude Desktop 不会在你的项目目录里启动它):请传绝对路径,或者改用图片链接(`--logo-uri`、`upload-logo --url`)。
|
|
194
194
|
|
|
195
|
+
图形界面的宿主启动 MCP 服务时,`PATH` 里可能只有系统目录。服务会把 node 所在目录、npm 全局 bin,以及 `/opt/homebrew/bin`、`/usr/local/bin`、`~/.local/bin`、`~/.npm-global/bin` 加进它所运行命令的 `PATH`,所以能找到 `baw`(0.17.3+)。如果宿主连 `gang` 都启动不了,就写完整路径:`{ "command": "<which node 的输出>", "args": ["<which gang 的输出>", "mcp"] }`。
|
|
196
|
+
|
|
195
197
|
调用被取消(或客户端关闭 stdin、停掉服务)时,只读命令立即停止;写命令(`gang_execute`、`gang_tx`、各类预览、`gang_cli`)一定跑完,因为钱包可能已经把交易发出去了。`gang_execute` 超时后,先用 `gang_status` 或钱包交易记录确认,不要再执行一次。
|
|
196
198
|
|
|
197
199
|
## Quote 路径
|
|
@@ -227,4 +229,4 @@ Claude Code:`claude mcp add gang -- gang mcp`。同一台机器上 `baw` 要
|
|
|
227
229
|
|
|
228
230
|
## 版本
|
|
229
231
|
|
|
230
|
-
`0.17.
|
|
232
|
+
`0.17.3` · [gangfun/cli](https://github.com/gangfun/cli) · push 到 `main` 自动发布到 [npm](https://www.npmjs.com/package/@gangfun/cli)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gangfun/cli",
|
|
3
|
-
"version": "0.17.
|
|
3
|
+
"version": "0.17.3",
|
|
4
4
|
"description": "Gang launchpad CLI for Binance Agentic Wallet agents: create on GangLaunchpad (untaxed or tax tokens), 打新 fair mint, PancakeSwap pool trades, LaunchpadV2 and legacy Soft/U/S trade.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
package/src/baw.js
CHANGED
|
@@ -6,6 +6,9 @@ export function baw(args) {
|
|
|
6
6
|
try {
|
|
7
7
|
out = execFileSync('baw', [...args, '--json'], { encoding: 'utf8', stdio: ['ignore', 'pipe', 'pipe'], maxBuffer: 8 << 20 })
|
|
8
8
|
} catch (e) {
|
|
9
|
+
if (e.code === 'ENOENT') {
|
|
10
|
+
throw new Error('baw (the Binance Agentic Wallet CLI) is not installed or not on PATH: npm i -g @binance/agentic-wallet, then baw auth signin. Under an MCP host, start gang mcp with a PATH that has baw\'s directory (which baw)')
|
|
11
|
+
}
|
|
9
12
|
const text = (e.stdout || '') + (e.stderr || '')
|
|
10
13
|
try { return JSON.parse(e.stdout) } catch { throw new Error(`baw ${args[0]} failed: ${text.trim() || e.message}`) }
|
|
11
14
|
}
|
package/src/mcp.js
CHANGED
|
@@ -6,6 +6,8 @@
|
|
|
6
6
|
* still go through the user's Agentic Wallet (baw).
|
|
7
7
|
*/
|
|
8
8
|
import { spawn } from 'node:child_process'
|
|
9
|
+
import { homedir } from 'node:os'
|
|
10
|
+
import { delimiter, dirname, join, sep } from 'node:path'
|
|
9
11
|
import { createInterface } from 'node:readline'
|
|
10
12
|
import { fileURLToPath } from 'node:url'
|
|
11
13
|
import { VERSION } from './version.js'
|
|
@@ -229,10 +231,29 @@ export function invalid(t, a) {
|
|
|
229
231
|
return null
|
|
230
232
|
}
|
|
231
233
|
|
|
234
|
+
/**
|
|
235
|
+
* The CLI children's environment: the host's, with PATH extended by where node, this package's global bin and the usual
|
|
236
|
+
* install dirs live. A GUI host (Claude Desktop on macOS) may start its servers with the system dirs only, and the CLI
|
|
237
|
+
* runs `baw` by name: without this every wallet call failed (spawnSync baw ENOENT) while the reads worked. Appended, so
|
|
238
|
+
* the host's own PATH still wins.
|
|
239
|
+
*/
|
|
240
|
+
export function childEnv(env = process.env, cli = CLI) {
|
|
241
|
+
const key = Object.keys(env).find((k) => k.toUpperCase() === 'PATH') || 'PATH'
|
|
242
|
+
const extra = [dirname(process.execPath)]
|
|
243
|
+
// <prefix>/lib/node_modules/@gangfun/cli/src/index.js → <prefix>/bin (npm i -g puts baw there too); Windows: <prefix>
|
|
244
|
+
const lib = cli.lastIndexOf(`${sep}lib${sep}node_modules${sep}`)
|
|
245
|
+
if (lib > 0) extra.push(join(cli.slice(0, lib), 'bin'))
|
|
246
|
+
const win = cli.lastIndexOf(`${sep}node_modules${sep}`)
|
|
247
|
+
if (process.platform === 'win32' && win > 0) extra.push(cli.slice(0, win))
|
|
248
|
+
if (process.platform !== 'win32') extra.push('/opt/homebrew/bin', '/usr/local/bin', join(homedir(), '.local', 'bin'), join(homedir(), '.npm-global', 'bin'))
|
|
249
|
+
const dirs = [...new Set([...String(env[key] || '').split(delimiter).filter(Boolean), ...extra])]
|
|
250
|
+
return { ...env, [key]: dirs.join(delimiter) }
|
|
251
|
+
}
|
|
252
|
+
|
|
232
253
|
/** Run the CLI with args → { code, stdout, stderr }. onChild(child): to kill a read when its request is cancelled. */
|
|
233
254
|
function runCli(args, ms, onChild = () => {}) {
|
|
234
255
|
return new Promise((resolve) => {
|
|
235
|
-
const child = spawn(process.execPath, [CLI, ...args], { env:
|
|
256
|
+
const child = spawn(process.execPath, [CLI, ...args], { env: childEnv(), stdio: ['ignore', 'pipe', 'pipe'] })
|
|
236
257
|
onChild(child)
|
|
237
258
|
let stdout = '', stderr = ''
|
|
238
259
|
child.stdout.on('data', (d) => { stdout += d })
|