@heyamiko/amiko-cli 0.5.13 → 0.5.15

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.
Files changed (2) hide show
  1. package/dist/index.js +72 -0
  2. package/package.json +2 -2
package/dist/index.js CHANGED
@@ -75830,6 +75830,77 @@ 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
+ }
75846
+ const params = new URLSearchParams({ q: query });
75847
+ let res = await fetch(`${mppBase2}/v1/x/search?${params}`, { headers });
75848
+ if (res.status === 402 && auth.twinToken && !apiKey) {
75849
+ res = await fetch(`${mppBase2}/v1/x/search?${params}`, {
75850
+ headers: { ...headers, Authorization: `Bearer ${auth.twinToken}` }
75851
+ });
75852
+ }
75853
+ spinner.stop();
75854
+ if (res.status === 402) {
75855
+ console.error(error("Payment required — no credits or API key."));
75856
+ console.log(dim("Set your API key: amiko config set apiKey amk_<key>"));
75857
+ console.log(dim("Or top up credits: amiko credits topup 10000 --token AMIKO --yes"));
75858
+ process.exit(1);
75859
+ }
75860
+ if (!res.ok) {
75861
+ const text = await res.text().catch(() => "");
75862
+ console.error(error(`Search failed: ${res.status} ${text.slice(0, 200)}`));
75863
+ process.exit(1);
75864
+ }
75865
+ const data = await res.json();
75866
+ if (opts.raw) {
75867
+ console.log(JSON.stringify(data, null, 2));
75868
+ return;
75869
+ }
75870
+ const paymentMethod = res.headers.get("x-payment-method");
75871
+ const paymentBalance = res.headers.get("x-payment-balance");
75872
+ console.log(heading(`X Search: "${query}"
75873
+ `));
75874
+ const tweets = data.data || [];
75875
+ if (tweets.length === 0) {
75876
+ console.log(dim(" No results found."));
75877
+ } else {
75878
+ for (const tweet of tweets) {
75879
+ const author = tweet.author_id ? dim(`@${tweet.author_id}`) : "";
75880
+ const date5 = tweet.created_at ? dim(new Date(tweet.created_at).toLocaleDateString()) : "";
75881
+ const metrics = tweet.public_metrics;
75882
+ const stats = metrics ? dim(` ${metrics.like_count || 0} likes · ${metrics.retweet_count || 0} RTs · ${metrics.reply_count || 0} replies`) : "";
75883
+ console.log(` ${source_default.cyan(tweet.id)} ${author} ${date5}`);
75884
+ console.log(` ${tweet.text}`);
75885
+ if (stats)
75886
+ console.log(stats);
75887
+ console.log("");
75888
+ }
75889
+ }
75890
+ if (paymentMethod) {
75891
+ let footer = dim(`Paid via ${paymentMethod}`);
75892
+ if (paymentBalance)
75893
+ footer += dim(` (balance: $${paymentBalance})`);
75894
+ console.log(footer);
75895
+ }
75896
+ } catch (err) {
75897
+ spinner.stop();
75898
+ console.error(error(err instanceof Error ? err.message : "Search failed"));
75899
+ process.exit(1);
75900
+ }
75901
+ });
75902
+ }
75903
+
75833
75904
  // src/index.ts
75834
75905
  var require2 = createRequire2(import.meta.url);
75835
75906
  var { version: PKG_VERSION } = require2("../package.json");
@@ -75840,6 +75911,7 @@ var program2 = new Command;
75840
75911
  program2.name("amiko").description("Amiko CLI — swap tokens, manage credits, bridge cross-chain, and call marketplace agents").version(PKG_VERSION);
75841
75912
  registerConnectCommand(program2);
75842
75913
  registerCreditsCommand(program2);
75914
+ registerSearchCommand(program2);
75843
75915
  registerSwapCommand(program2);
75844
75916
  registerBridgeCommand(program2);
75845
75917
  registerBrowseCommand(program2);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@heyamiko/amiko-cli",
3
- "version": "0.5.13",
3
+ "version": "0.5.15",
4
4
  "description": "Amiko CLI — swap tokens, manage credits, bridge cross-chain, and call marketplace agents",
5
5
  "type": "module",
6
6
  "bin": {
@@ -25,7 +25,7 @@
25
25
  "license": "MIT",
26
26
  "dependencies": {
27
27
  "@crossmint/wallets-sdk": "^1.0.5",
28
- "@solana/mpp": "^0.2.0",
28
+ "@solana/mpp": "^0.5.1",
29
29
  "chalk": "^5.3.0",
30
30
  "commander": "^12.1.0",
31
31
  "ora": "^8.1.0"