@heyamiko/amiko-cli 0.5.13 → 0.5.14
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/dist/index.js +69 -0
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -75830,6 +75830,74 @@ function registerUpdateCommand(program2) {
|
|
|
75830
75830
|
});
|
|
75831
75831
|
}
|
|
75832
75832
|
|
|
75833
|
+
// src/commands/search.ts
|
|
75834
|
+
function registerSearchCommand(program2) {
|
|
75835
|
+
program2.command("search <query>").description("Search X/Twitter via MPP (paid with credits or AMIKO)").option("--limit <n>", "Number of results", "10").option("--raw", "Output raw JSON").action(async (query, opts) => {
|
|
75836
|
+
const spinner = ora("Searching X...").start();
|
|
75837
|
+
try {
|
|
75838
|
+
const config2 = loadConfig();
|
|
75839
|
+
const auth = resolveAuth(config2);
|
|
75840
|
+
const mppBase2 = (config2.apiBase || "https://mpp.amikomarkets.com").replace(/\/$/, "");
|
|
75841
|
+
const headers = { "Content-Type": "application/json" };
|
|
75842
|
+
const apiKey = config2.apiKey || auth.platformKey;
|
|
75843
|
+
if (apiKey) {
|
|
75844
|
+
headers["X-Amiko-Key"] = apiKey;
|
|
75845
|
+
} else if (auth.twinToken) {
|
|
75846
|
+
headers["Authorization"] = `Bearer ${auth.twinToken}`;
|
|
75847
|
+
}
|
|
75848
|
+
const params = new URLSearchParams({ q: query });
|
|
75849
|
+
const res = await fetch(`${mppBase2}/v1/x/search?${params}`, { headers });
|
|
75850
|
+
spinner.stop();
|
|
75851
|
+
if (res.status === 402) {
|
|
75852
|
+
console.error(error("Payment required — no credits or API key."));
|
|
75853
|
+
console.log(dim("Set your API key: amiko config set apiKey amk_<key>"));
|
|
75854
|
+
console.log(dim("Or top up credits: amiko credits topup 10000 --token AMIKO --yes"));
|
|
75855
|
+
process.exit(1);
|
|
75856
|
+
}
|
|
75857
|
+
if (!res.ok) {
|
|
75858
|
+
const text = await res.text().catch(() => "");
|
|
75859
|
+
console.error(error(`Search failed: ${res.status} ${text.slice(0, 200)}`));
|
|
75860
|
+
process.exit(1);
|
|
75861
|
+
}
|
|
75862
|
+
const data = await res.json();
|
|
75863
|
+
if (opts.raw) {
|
|
75864
|
+
console.log(JSON.stringify(data, null, 2));
|
|
75865
|
+
return;
|
|
75866
|
+
}
|
|
75867
|
+
const paymentMethod = res.headers.get("x-payment-method");
|
|
75868
|
+
const paymentBalance = res.headers.get("x-payment-balance");
|
|
75869
|
+
console.log(heading(`X Search: "${query}"
|
|
75870
|
+
`));
|
|
75871
|
+
const tweets = data.data || [];
|
|
75872
|
+
if (tweets.length === 0) {
|
|
75873
|
+
console.log(dim(" No results found."));
|
|
75874
|
+
} else {
|
|
75875
|
+
for (const tweet of tweets) {
|
|
75876
|
+
const author = tweet.author_id ? dim(`@${tweet.author_id}`) : "";
|
|
75877
|
+
const date5 = tweet.created_at ? dim(new Date(tweet.created_at).toLocaleDateString()) : "";
|
|
75878
|
+
const metrics = tweet.public_metrics;
|
|
75879
|
+
const stats = metrics ? dim(` ${metrics.like_count || 0} likes · ${metrics.retweet_count || 0} RTs · ${metrics.reply_count || 0} replies`) : "";
|
|
75880
|
+
console.log(` ${source_default.cyan(tweet.id)} ${author} ${date5}`);
|
|
75881
|
+
console.log(` ${tweet.text}`);
|
|
75882
|
+
if (stats)
|
|
75883
|
+
console.log(stats);
|
|
75884
|
+
console.log("");
|
|
75885
|
+
}
|
|
75886
|
+
}
|
|
75887
|
+
if (paymentMethod) {
|
|
75888
|
+
let footer = dim(`Paid via ${paymentMethod}`);
|
|
75889
|
+
if (paymentBalance)
|
|
75890
|
+
footer += dim(` (balance: $${paymentBalance})`);
|
|
75891
|
+
console.log(footer);
|
|
75892
|
+
}
|
|
75893
|
+
} catch (err) {
|
|
75894
|
+
spinner.stop();
|
|
75895
|
+
console.error(error(err instanceof Error ? err.message : "Search failed"));
|
|
75896
|
+
process.exit(1);
|
|
75897
|
+
}
|
|
75898
|
+
});
|
|
75899
|
+
}
|
|
75900
|
+
|
|
75833
75901
|
// src/index.ts
|
|
75834
75902
|
var require2 = createRequire2(import.meta.url);
|
|
75835
75903
|
var { version: PKG_VERSION } = require2("../package.json");
|
|
@@ -75840,6 +75908,7 @@ var program2 = new Command;
|
|
|
75840
75908
|
program2.name("amiko").description("Amiko CLI — swap tokens, manage credits, bridge cross-chain, and call marketplace agents").version(PKG_VERSION);
|
|
75841
75909
|
registerConnectCommand(program2);
|
|
75842
75910
|
registerCreditsCommand(program2);
|
|
75911
|
+
registerSearchCommand(program2);
|
|
75843
75912
|
registerSwapCommand(program2);
|
|
75844
75913
|
registerBridgeCommand(program2);
|
|
75845
75914
|
registerBrowseCommand(program2);
|