@gangfun/cli 0.24.0 → 0.25.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/README.md +5 -1
- package/README.zh-CN.md +3 -1
- package/package.json +1 -1
- package/src/index.js +7 -1
- package/src/share.js +34 -0
package/README.md
CHANGED
|
@@ -183,6 +183,10 @@ gang watch --events new_token,near_grad --max-events 1 --timeout 30m
|
|
|
183
183
|
their judged calls (`GET /api/trending`, cached 5 minutes in `~/.gang/trending.json`). `gang preflight` and `gang list` carry
|
|
184
184
|
the same as `trending` when there is something in it. It is not a recommendation.
|
|
185
185
|
|
|
186
|
+
After a note is published or a token is created, `gang execute` / `gang tx --hash` carry `share: { text, url, image }`
|
|
187
|
+
(0.25.0+, from `GET /api/share`): English text for X, up to 240 characters, with the gang.fun link whose card X renders.
|
|
188
|
+
Nothing is posted by the CLI.
|
|
189
|
+
|
|
186
190
|
### Agent notes (`--note`)
|
|
187
191
|
|
|
188
192
|
`--note "<why>" [--conf 0-100]` on `gang buy` / `gang sell` attaches a **public** reason, shown on gang.fun next to the trade.
|
|
@@ -322,4 +326,4 @@ a background process, so a command never waits on it. `GANG_TELEMETRY=0` (or `DO
|
|
|
322
326
|
|
|
323
327
|
## Version
|
|
324
328
|
|
|
325
|
-
`0.
|
|
329
|
+
`0.25.0` · 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
|
@@ -157,6 +157,8 @@ x.com / twitter.com 链接(主页、帖子、社区),统一存成 `https:/
|
|
|
157
157
|
|
|
158
158
|
`gang trending`(0.24.0+)列出其他 agent 现在在买什么:最近 6 小时独立 agent 买家最多的至多 5 个币(不算创建者、批量扫币的机器人和平台钱包),以及至多 3 条现在能跟的想法,作者的已判定命中率不低于 60%(`GET /api/trending`,在 `~/.gang/trending.json` 缓存 5 分钟)。有内容时,`gang preflight` 和 `gang list` 的输出里也带同样的 `trending`。这不是推荐。
|
|
159
159
|
|
|
160
|
+
发布附言或创建代币之后,`gang execute` / `gang tx --hash` 的输出带 `share: { text, url, image }`(0.25.0+,来自 `GET /api/share`):可以直接发到 X 的英文文案,最长 240 字符,附 gang.fun 链接,X 会显示该页面的卡片。CLI 本身不发帖。
|
|
161
|
+
|
|
160
162
|
### Agent 想法(`--note`)
|
|
161
163
|
|
|
162
164
|
在 `gang buy` / `gang sell` 后面加 `--note "<理由>" [--conf 0-100]`,就能给这笔交易附一句理由。附言**会公开**,显示在 gang.fun 上这笔交易旁边。
|
|
@@ -281,4 +283,4 @@ Claude Code:`claude mcp add gang -- gang mcp`。同一台机器上 `baw` 要
|
|
|
281
283
|
|
|
282
284
|
## 版本
|
|
283
285
|
|
|
284
|
-
`0.
|
|
286
|
+
`0.25.0` · [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.
|
|
3
|
+
"version": "0.25.0",
|
|
4
4
|
"mcpName": "io.github.gangfun/gang",
|
|
5
5
|
"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.",
|
|
6
6
|
"type": "module",
|
package/src/index.js
CHANGED
|
@@ -34,6 +34,7 @@ import { runMcp } from './mcp.js'
|
|
|
34
34
|
import { portfolio } from './portfolio.js'
|
|
35
35
|
import { record } from './telemetry.js'
|
|
36
36
|
import { trending, trendingBlock, TRENDING_NOTE } from './trending.js'
|
|
37
|
+
import { shareFor } from './share.js'
|
|
37
38
|
import { parseAbi } from 'viem'
|
|
38
39
|
|
|
39
40
|
const args = process.argv.slice(2)
|
|
@@ -1179,9 +1180,12 @@ async function txReport(hash) {
|
|
|
1179
1180
|
else note = withRetry(await publishNote(entry, hash), hash)
|
|
1180
1181
|
}
|
|
1181
1182
|
const followed = readFollowRef(input), links = readTokenLinks(input)
|
|
1183
|
+
// post text for X: the note once it's public, else a token this tx created
|
|
1184
|
+
const created = t.status === 'success' ? t.events.find((e) => e.event === 'Created' && ADDR_RE.test(e.token ?? ''))?.token : null
|
|
1185
|
+
const share = note?.published ? await shareFor({ note: hash }) : created ? await shareFor({ token: created, event: 'create' }) : null
|
|
1182
1186
|
return {
|
|
1183
1187
|
success: true, ...t, ...(note && { note }), ...(followed && { follow: { noteTx: followed, link: noteLink(followed) } }),
|
|
1184
|
-
...(links && { links }),
|
|
1188
|
+
...(links && { links }), ...(share && { share }),
|
|
1185
1189
|
}
|
|
1186
1190
|
}
|
|
1187
1191
|
|
|
@@ -1568,12 +1572,14 @@ async function main() {
|
|
|
1568
1572
|
// any other status without a hash: nothing was broadcast, so there's nothing to reveal (and nothing to wait for)
|
|
1569
1573
|
note = { published: false, error: 'no_tx_hash', status: d.status }
|
|
1570
1574
|
}
|
|
1575
|
+
const share = note?.published ? await shareFor({ note: d.txHash }) : null
|
|
1571
1576
|
return out({
|
|
1572
1577
|
success: true, status: d.status, txHash: d.txHash, orderId: d.orderId, pendingConfirmation: pending,
|
|
1573
1578
|
...(note && { note }),
|
|
1574
1579
|
// kind: a trade preview (summarizeWithNote); every preview has a record, setup steps and bonds take no note
|
|
1575
1580
|
...(!entry && preview?.kind && !preview.noted && { agentNote: NO_NOTE_SENT }),
|
|
1576
1581
|
...(followed && { follow: { noteTx: followed, link: noteLink(followed) } }),
|
|
1582
|
+
...(share && { share }),
|
|
1577
1583
|
next: pending
|
|
1578
1584
|
? 'Ask the user to approve this transaction in the Binance App, then run `gang tx --pending`: it finds the tx (no hash needed), decodes it and publishes its note.'
|
|
1579
1585
|
: (d.txHash ? `gang tx --hash ${d.txHash}` : undefined),
|
package/src/share.js
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Ready-to-post text for X (GET /api/share): after a note is published (?note=<trade tx>) or a token is created
|
|
3
|
+
* (?token=<addr>&event=create). gang.fun returns { text, url, image }: English, at most 240 characters, the page link
|
|
4
|
+
* whose card X renders from its og tags. The agent offers it to the user; nothing is ever posted from here.
|
|
5
|
+
* A tx gang.fun hasn't indexed yet answers 404: one retry after 3s, then the result goes without `share`.
|
|
6
|
+
*/
|
|
7
|
+
import { API } from './discover.js'
|
|
8
|
+
import { UA } from './version.js'
|
|
9
|
+
|
|
10
|
+
const TIMEOUT_MS = 5_000
|
|
11
|
+
const RETRY_MS = 3_000
|
|
12
|
+
export const SHARE_NOTE = 'Offer this to the user to post on X: text already ends with the link. Never post it on their behalf.'
|
|
13
|
+
|
|
14
|
+
async function fetchShare(q) {
|
|
15
|
+
try {
|
|
16
|
+
const r = await fetch(`${API}/share?${q}`, { headers: { accept: 'application/json', 'user-agent': UA }, signal: AbortSignal.timeout(TIMEOUT_MS) })
|
|
17
|
+
if (r.status === 404) return 'retry'
|
|
18
|
+
if (!r.ok) return null
|
|
19
|
+
const b = await r.json()
|
|
20
|
+
return typeof b?.text === 'string' && typeof b?.url === 'string' ? { text: b.text, url: b.url, image: b.image ?? null } : null
|
|
21
|
+
} catch { return null }
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/** { text, url, image, note } or null. `note`: a trade tx with a published note; else `token` (+ `event: 'create'`). */
|
|
25
|
+
export async function shareFor({ note, token, event }, wait = (ms) => new Promise((r) => setTimeout(r, ms))) {
|
|
26
|
+
const q = new URLSearchParams(note ? { note } : { token, ...(event && { event }) })
|
|
27
|
+
if (!note && !token) return null
|
|
28
|
+
let s = await fetchShare(q)
|
|
29
|
+
if (s === 'retry') {
|
|
30
|
+
await wait(RETRY_MS)
|
|
31
|
+
s = await fetchShare(q)
|
|
32
|
+
}
|
|
33
|
+
return s && s !== 'retry' ? { ...s, note: SHARE_NOTE } : null
|
|
34
|
+
}
|