seoanything-cli 2.2.0 → 2.3.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 CHANGED
@@ -53,7 +53,7 @@ Settings › ai engines › connect a computer › "from your AI app" gives you
53
53
  npx -y seoanything-cli@latest connect --code <setup code> --background
54
54
  ```
55
55
 
56
- The setup code works once and lapses after 10 minutes. It is traded for a token that can only open this computer's link (not your account), saved in the config file. `--background` keeps the connector running after the AI app's command finishes (log: `connect.log` next to the config file). "disconnect" in Settings stops it and revokes the token; from then on the computer needs a fresh setup prompt. "look for CLIs" in Settings picks up a CLI you installed after linking, without a restart.
56
+ The setup code works once and lapses after 10 minutes. It is traded for a token that can only open this computer's link (not your account), saved in the config file. `--background` keeps the connector running after the AI app's command finishes (log: `connect.log` next to the config file). "disconnect" in Settings stops it and revokes the token; from then on the computer needs a fresh setup prompt. "look for CLIs" in Settings picks up a CLI you installed after linking, without a restart, and refreshes each CLI's model list (`codex debug models`, `agy models`, and Claude Code's fable/opus/sonnet/haiku aliases) so you can pick a model per CLI in Settings or in the chat's model menu.
57
57
 
58
58
  ## MCP
59
59
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "seoanything-cli",
3
- "version": "2.2.0",
3
+ "version": "2.3.0",
4
4
  "description": "SEOAnything CLI: trends, keywords, SEO chat, blog studio, audits, a local MCP server, and `connect` to run the web app on the Claude/Codex/Gemini/Antigravity CLI on your own computer. https://www.seoanything.dev",
5
5
  "type": "module",
6
6
  "license": "MIT",
package/src/connect.js CHANGED
@@ -55,17 +55,37 @@ export function findBinary(command, env = process.env, platform = process.platfo
55
55
  return null;
56
56
  }
57
57
 
58
- /** Installed CLIs with their versions. */
58
+ /** Installed CLIs with their versions and the models each offers, looked up side by side. */
59
59
  export async function detect(env = ownEnv(), run = runProcess) {
60
- const found = [];
61
- for (const [kind, { command }] of Object.entries(KINDS)) {
60
+ const found = await Promise.all(Object.entries(KINDS).map(async ([kind, { command }]) => {
62
61
  const bin = findBinary(command, env);
63
- if (!bin) continue;
62
+ if (!bin) return null;
64
63
  let version = "";
65
64
  try { version = (await run([bin, "--version"], { env, timeoutMs: 20_000 })).stdout.trim().split("\n")[0].slice(0, 80); } catch { /* still usable */ }
66
- found.push({ kind, path: bin, version });
67
- }
68
- return found;
65
+ return { kind, path: bin, version, models: await listModels(kind, bin, env, run) };
66
+ }));
67
+ return found.filter(Boolean);
68
+ }
69
+
70
+ // Claude Code has no command that lists models; these aliases always mean its latest of each.
71
+ const CLAUDE_MODELS = [{ id: "fable", label: "Fable (latest)" }, { id: "opus", label: "Opus (latest)" }, { id: "sonnet", label: "Sonnet (latest)" }, { id: "haiku", label: "Haiku (latest)" }];
72
+
73
+ /** The models a CLI offers, from its own list where it has one. None when the list can't be read; the app then offers the CLI's default. */
74
+ export async function listModels(kind, bin, env = ownEnv(), run = runProcess) {
75
+ if (kind === "claude") return CLAUDE_MODELS;
76
+ try { return parseModels(kind, (await run(kind === "codex" ? [bin, "debug", "models"] : [bin, "models"], { env, timeoutMs: 20_000 })).stdout); }
77
+ catch { return []; }
78
+ }
79
+
80
+ /** `codex debug models` prints a JSON catalog (hidden ones skipped, in its own order); `agy models` prints `id<TAB>name` lines. */
81
+ export function parseModels(kind, stdout) {
82
+ let rows = [];
83
+ if (kind === "codex") {
84
+ const list = safeJson(stdout.trim())?.models;
85
+ rows = (Array.isArray(list) ? list : []).filter((m) => m && m.visibility !== "hide").sort((a, b) => (a.priority ?? 99) - (b.priority ?? 99)).map((m) => ({ id: m.slug, label: m.display_name }));
86
+ } else rows = stdout.split("\n").map((l) => l.split("\t")).filter((c) => c.length >= 2).map(([id, label]) => ({ id: id.trim(), label: label.trim() }));
87
+ // only ids this connector would pass on as --model
88
+ return rows.filter((m) => typeof m.id === "string" && MODEL.test(m.id)).slice(0, 40).map((m) => ({ id: m.id, label: String(m.label || m.id).slice(0, 80) }));
69
89
  }
70
90
 
71
91
  export function checkJob(job) {
@@ -255,7 +275,7 @@ export async function connect({ server, token, deviceToken, onUnlinked, log = co
255
275
  if (!found.length) throw new CliError("no AI CLI found on PATH. install claude, codex or agy, sign in to it once, then run connect again.", 1);
256
276
  for (const f of found) log(`✓ found ${KINDS[f.kind].label} ${f.version} at ${f.path}`);
257
277
  let binaries = Object.fromEntries(found.map((f) => [f.kind, f.path]));
258
- const hello = () => ({ type: "hello", deviceId, name: hostname.slice(0, 80), platform: process.platform, version: VERSION, clis: found.map((f) => ({ kind: f.kind, version: f.version })), features: ["rescan"] });
278
+ const hello = () => ({ type: "hello", deviceId, name: hostname.slice(0, 80), platform: process.platform, version: VERSION, clis: found.map((f) => ({ kind: f.kind, version: f.version, models: f.models })), features: ["rescan"] });
259
279
  // asked from the settings page: pick up a CLI installed since this connector started, without a restart
260
280
  async function rescan(ws) {
261
281
  const now = await detect(env);
@@ -2,7 +2,7 @@ import { mkdtempSync, rmSync, writeFileSync } from "node:fs";
2
2
  import os from "node:os";
3
3
  import path from "node:path";
4
4
  import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
5
- import { buildArgs, checkJob, connect, deltaOf, ownEnv, pair, parseOutput, runJob, startBackground } from "./connect.js";
5
+ import { buildArgs, checkJob, connect, deltaOf, listModels, ownEnv, pair, parseModels, parseOutput, runJob, startBackground } from "./connect.js";
6
6
 
7
7
  const job = { kind: "claude", prompt: "say ok", system: "be brief", timeout: 60 };
8
8
  let root;
@@ -185,3 +185,20 @@ describe("linking with a setup code", () => {
185
185
  expect(onUnlinked).toHaveBeenCalledOnce();
186
186
  });
187
187
  });
188
+
189
+ describe("model lists", () => {
190
+ it("reads the codex catalog: hidden models skipped, in its own order, names kept", () => {
191
+ const out = JSON.stringify({ models: [{ slug: "gpt-b", display_name: "GPT B", visibility: "list", priority: 2 }, { slug: "hidden-x", display_name: "X", visibility: "hide", priority: 0 }, { slug: "gpt-a", display_name: "GPT A", visibility: "list", priority: 1 }, { slug: "bad id!", display_name: "Bad", visibility: "list", priority: 3 }] });
192
+ expect(parseModels("codex", out)).toEqual([{ id: "gpt-a", label: "GPT A" }, { id: "gpt-b", label: "GPT B" }]);
193
+ expect(parseModels("codex", "not json")).toEqual([]);
194
+ });
195
+ it("reads agy's id and name lines, ignoring its status line", () => {
196
+ expect(parseModels("agy", "Fetching available models...\ngemini-3.8-flash-high\tGemini 3.8 Flash (High)\nclaude-sonnet-4-6\tClaude Sonnet 4.6 (Thinking)\n")).toEqual([{ id: "gemini-3.8-flash-high", label: "Gemini 3.8 Flash (High)" }, { id: "claude-sonnet-4-6", label: "Claude Sonnet 4.6 (Thinking)" }]);
197
+ });
198
+ it("gives Claude Code its aliases without running it, and nothing when a list can't be read", async () => {
199
+ const run = vi.fn();
200
+ expect((await listModels("claude", "/bin/claude", {}, run)).map((m) => m.id)).toEqual(["fable", "opus", "sonnet", "haiku"]);
201
+ expect(run).not.toHaveBeenCalled();
202
+ expect(await listModels("codex", "/bin/codex", {}, async () => { throw new Error("boom"); })).toEqual([]);
203
+ });
204
+ });
package/src/mcp.js CHANGED
@@ -3,7 +3,7 @@ import fs from "node:fs";
3
3
  import { CliError } from "./api.js";
4
4
  import { resolveCreds } from "./config.js";
5
5
 
6
- export const VERSION = "2.2.0";
6
+ export const VERSION = "2.3.0";
7
7
 
8
8
  export async function mcp(flags) {
9
9
  const [major, minor] = process.versions.node.split(".").map(Number);