seoanything-cli 2.4.2 → 2.4.3
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/package.json +1 -1
- package/src/ai.js +21 -2
- package/src/ai.test.js +13 -1
- package/src/cli.js +2 -1
- package/src/mcp.js +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "seoanything-cli",
|
|
3
|
-
"version": "2.4.
|
|
3
|
+
"version": "2.4.3",
|
|
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/Antigravity CLI or your own Claude, ChatGPT, Gemini or OpenAI-compatible API key on your own computer. https://www.seoanything.dev",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
package/src/ai.js
CHANGED
|
@@ -81,8 +81,27 @@ export async function listModels(ai, o = {}) {
|
|
|
81
81
|
if (ai.provider === "anthropic") return rows.filter((m) => m.id.startsWith("claude")).map((m) => ({ id: m.id, label: m.display_name ?? m.id }));
|
|
82
82
|
if (ai.provider === "custom") return [...new Set(rows.map((m) => m.id ?? m.name))].map((id) => ({ id, label: id }));
|
|
83
83
|
const family = ai.provider === "openai" ? /^(gpt-|o\d|chatgpt)/ : /^gemini/;
|
|
84
|
-
const skip = /embed|audio|realtime|image|tts|transcri|whisper|dall-e|moderation|search|veo|imagen|live|aqa|computer-use|codex/i;
|
|
85
|
-
|
|
84
|
+
const skip = /embed|audio|realtime|image|tts|transcri|whisper|dall-e|moderation|search|veo|imagen|live|aqa|computer-use|codex|robotics/i;
|
|
85
|
+
// newest first where the provider dates them (OpenAI); a stable sort keeps the provider's own order otherwise
|
|
86
|
+
const ids = [...new Set(rows.map((m) => ({ id: m.id.replace(/^models\//, ""), t: m.created ?? 0 })).filter((m) => family.test(m.id) && !skip.test(m.id)).sort((a, b) => b.t - a.t).map((m) => m.id))];
|
|
87
|
+
return (ai.provider === "gemini" ? flashFirst(ids) : ids).map((id) => ({ id, label: id }));
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
export const FLASH = /^gemini-(\d+(?:\.\d+)?)-flash$/;
|
|
91
|
+
const version = (id) => id.match(FLASH)[1].split(".").map(Number);
|
|
92
|
+
|
|
93
|
+
/** Gemini's list carries no dates and isn't by date, and names sort "robotics" above "3.8": its plain Flash models go first, newest first, then the rest in Google's order. */
|
|
94
|
+
export function flashFirst(ids) {
|
|
95
|
+
const flash = ids.filter((id) => FLASH.test(id)).sort((a, b) => { const [x, y] = [version(a), version(b)]; return y[0] - x[0] || (y[1] ?? 0) - (x[1] ?? 0); });
|
|
96
|
+
return [...flash, ...ids.filter((id) => !flash.includes(id))];
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/** The first of `ids` that answers a one-word question with this key: Gemini lists models a key can't use yet (its newest Flash answered 503 for a free key on 2026-11-23). Undefined when none answers; a refused key throws. */
|
|
100
|
+
export async function firstAnswering(ai, ids, o = {}) {
|
|
101
|
+
for (const model of ids) {
|
|
102
|
+
try { await ask(ai, { prompt: TEST_PROMPT, model, maxTokens: 50, timeoutMs: 15_000, ...o }); return model; }
|
|
103
|
+
catch (e) { if (/refused the API key/.test(e.message)) throw e; }
|
|
104
|
+
}
|
|
86
105
|
}
|
|
87
106
|
|
|
88
107
|
/** The request body for one prompt. No temperature: newer Claude and OpenAI reasoning models refuse anything but their default. */
|
package/src/ai.test.js
CHANGED
|
@@ -2,7 +2,7 @@ import fs 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 { ask, bodyFor, checkBase, hint, listModels, problem, providerOf, resolveAi } from "./ai.js";
|
|
5
|
+
import { ask, bodyFor, checkBase, firstAnswering, flashFirst, hint, listModels, problem, providerOf, resolveAi } from "./ai.js";
|
|
6
6
|
import { main } from "./cli.js";
|
|
7
7
|
import { loadConfig, saveConfig } from "./config.js";
|
|
8
8
|
import { detect, runJob } from "./connect.js";
|
|
@@ -64,6 +64,18 @@ describe("calling the provider", () => {
|
|
|
64
64
|
const fetchImpl = async () => json({ data: [{ id: "gpt-4o", created: 1 }, { id: "text-embedding-3", created: 3 }, { id: "gpt-5", created: 2 }, { id: "whisper-1", created: 4 }] });
|
|
65
65
|
expect(await listModels({ provider: "openai", label: "ChatGPT", key: "k" }, { fetchImpl })).toEqual([{ id: "gpt-5", label: "gpt-5" }, { id: "gpt-4o", label: "gpt-4o" }]);
|
|
66
66
|
});
|
|
67
|
+
|
|
68
|
+
it("gives a new Gemini key its newest plain Flash, not the first name in Google's undated list", async () => {
|
|
69
|
+
const listed = ["gemini-2.5-flash", "gemini-flash-latest", "gemini-3.5-flash", "gemini-3.8-flash", "gemini-3.8-flash-tts", "gemini-robotics-er-2-streaming-preview", "gemma-4-31b-it"];
|
|
70
|
+
const fetchImpl = async () => json({ data: listed.map((id) => ({ id: `models/${id}` })) });
|
|
71
|
+
expect((await listModels({ provider: "gemini", label: "Gemini", key: "k" }, { fetchImpl })).map((m) => m.id)).toEqual(["gemini-3.8-flash", "gemini-3.5-flash", "gemini-2.5-flash", "gemini-flash-latest"]);
|
|
72
|
+
expect(flashFirst(["gemini-3.8-flash", "gemini-3.10-flash"])[0]).toBe("gemini-3.10-flash");
|
|
73
|
+
// 3.8 over capacity for this key, 3.5 answers; a refused key stops the search
|
|
74
|
+
const gem = { provider: "gemini", label: "Gemini", key: "k" };
|
|
75
|
+
const busy = async (_u, init) => (JSON.parse(init.body).model === "gemini-3.8-flash" ? json({ error: { message: "overloaded" } }, 503) : json({ choices: [{ message: { content: "ready" } }] }));
|
|
76
|
+
expect(await firstAnswering(gem, ["gemini-3.8-flash", "gemini-3.5-flash"], { fetchImpl: busy })).toBe("gemini-3.5-flash");
|
|
77
|
+
await expect(firstAnswering(gem, ["gemini-3.8-flash"], { fetchImpl: async () => json({}, 401) })).rejects.toThrow(/refused the API key/);
|
|
78
|
+
});
|
|
67
79
|
});
|
|
68
80
|
|
|
69
81
|
describe("connect offers the key as the api engine", () => {
|
package/src/cli.js
CHANGED
|
@@ -259,7 +259,7 @@ export async function main(argv, io = { out: console.log, err: console.error })
|
|
|
259
259
|
|
|
260
260
|
/** `seoanything ai`: your own provider key, kept in the config file on this computer and used through `connect`. */
|
|
261
261
|
async function aiCommand(p, api, io, { print, c, note }) {
|
|
262
|
-
const { PROVIDERS, TEST_PROMPT, ask, checkBase, hint, listModels, providerOf, resolveAi } = await import("./ai.js");
|
|
262
|
+
const { FLASH, PROVIDERS, TEST_PROMPT, ask, checkBase, firstAnswering, hint, listModels, providerOf, resolveAi } = await import("./ai.js");
|
|
263
263
|
const { flags } = p, sub = p.sub ?? "show";
|
|
264
264
|
const usage = "seoanything ai set claude|openai|gemini|custom [--model m] [--base-url u] | ai [show] | ai test | ai use | ai remove";
|
|
265
265
|
const shown = (ai) => (ai ? { provider: ai.provider, label: ai.label, model: ai.model || null, baseUrl: ai.baseUrl || null, key: ai.key ? hint(ai.key) : null, from: ai.from } : null);
|
|
@@ -301,6 +301,7 @@ async function aiCommand(p, api, io, { print, c, note }) {
|
|
|
301
301
|
let models = [];
|
|
302
302
|
try { models = await listModels(ai, { timeoutMs: 15_000 }); }
|
|
303
303
|
catch (e) { if (provider !== "custom" || /refused the API key/.test(e.message)) throw new CliError(e.message, EXIT.upstream); } // not every custom API lists its models
|
|
304
|
+
if (!ai.model && provider === "gemini") ai.model = (await firstAnswering(ai, models.map((m) => m.id).filter((id) => FLASH.test(id)).slice(0, 4))) ?? "";
|
|
304
305
|
ai.model ||= models[0]?.id ?? "";
|
|
305
306
|
}
|
|
306
307
|
if (!ai.model) throw new CliError("no model to use: give one with --model.", EXIT.usage);
|
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.4.
|
|
6
|
+
export const VERSION = "2.4.3";
|
|
7
7
|
|
|
8
8
|
export async function mcp(flags) {
|
|
9
9
|
const [major, minor] = process.versions.node.split(".").map(Number);
|