mirror of
https://github.com/GMGNAI/gmgn-skills.git
synced 2026-07-27 16:57:44 +00:00
e8af4b88b5
Add a new `gmgn-cli config` command that automates Ed25519 key pair generation for new users. The command reuses an existing keypair.pem if present, or generates a new one, then outputs a pre-filled API Key creation link with the public key embedded. Guidance text is output in the user's system locale (zh-CN, zh-TW, or English). All 6 SKILL.md files are updated with a BEFORE RUNNING ANY COMMAND block that detects missing GMGN_API_KEY, triggers gmgn-cli config, and instructs the Agent to write both GMGN_API_KEY and GMGN_PRIVATE_KEY into ~/.config/gmgn/.env once the user provides their API Key. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
70 lines
2.6 KiB
JavaScript
70 lines
2.6 KiB
JavaScript
#!/usr/bin/env node
|
|
import { createRequire } from "module";
|
|
const { version } = createRequire(import.meta.url)("../package.json") as { version: string };
|
|
import { setGlobalDispatcher, ProxyAgent, Agent, buildConnector } from "undici";
|
|
import { SocksClient } from "socks";
|
|
import * as tls from "tls";
|
|
import { Command } from "commander";
|
|
import { registerTokenCommands } from "./commands/token.js";
|
|
import { registerMarketCommands } from "./commands/market.js";
|
|
import { registerPortfolioCommands } from "./commands/portfolio.js";
|
|
import { registerTrackCommands } from "./commands/track.js";
|
|
import { registerSwapCommands } from "./commands/swap.js";
|
|
import { registerCookingCommands } from "./commands/cooking.js";
|
|
import { registerConfigCommands } from "./commands/config.js";
|
|
|
|
const proxy = process.env.HTTPS_PROXY ?? process.env.https_proxy
|
|
?? process.env.HTTP_PROXY ?? process.env.http_proxy;
|
|
if (proxy) {
|
|
const u = new URL(proxy);
|
|
if (u.protocol === "socks5:" || u.protocol === "socks4:") {
|
|
const type = u.protocol === "socks5:" ? 5 : 4;
|
|
setGlobalDispatcher(new Agent({
|
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
connect: async (options: any, callback: any) => {
|
|
try {
|
|
const { socket } = await SocksClient.createConnection({
|
|
proxy: { host: u.hostname, port: parseInt(u.port || "1080"), type },
|
|
command: "connect",
|
|
destination: { host: options.hostname!, port: +options.port! },
|
|
socket_options: { family: 4 } as any,
|
|
});
|
|
if (options.protocol === "https:") {
|
|
callback(null, tls.connect({ socket, servername: options.hostname, rejectUnauthorized: options.rejectUnauthorized !== false }));
|
|
} else {
|
|
callback(null, socket);
|
|
}
|
|
} catch (err) {
|
|
callback(err as Error, null);
|
|
}
|
|
},
|
|
}));
|
|
} else {
|
|
setGlobalDispatcher(new ProxyAgent(proxy));
|
|
}
|
|
} else {
|
|
// Force IPv4 for all connections (no proxy mode)
|
|
const connector = buildConnector({ family: 4 } as any);
|
|
setGlobalDispatcher(new Agent({ connect: connector }));
|
|
}
|
|
|
|
const program = new Command();
|
|
|
|
program
|
|
.name("gmgn-cli")
|
|
.version(version)
|
|
.description("GMGN OpenAPI CLI — market data, token info, portfolio, track KOL/smart money trades, and swap");
|
|
|
|
registerTokenCommands(program);
|
|
registerMarketCommands(program);
|
|
registerPortfolioCommands(program);
|
|
registerTrackCommands(program);
|
|
registerSwapCommands(program);
|
|
registerCookingCommands(program);
|
|
registerConfigCommands(program);
|
|
|
|
program.parseAsync().catch((err) => {
|
|
console.error(`[gmgn-cli] ${err.message}`);
|
|
process.exit(1);
|
|
});
|