seoanything-cli 2.3.0 → 2.4.1

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
@@ -19,12 +19,20 @@ npx seoanything mcp # stdio MCP server (Node ≥ 22.18)
19
19
  | `login [--server <url>] [--api-key <key>] [--no-browser]` | Device-flow login, or store an API key for CI |
20
20
  | `logout` · `whoami` · `usage` | Credentials and today's quota |
21
21
  | `trends daily\|realtime [--geo NP] [--hl en] [--limit 20] [--hours 4] [--local]` | Trending searches; `--local` fetches from your machine with google-trends-js |
22
- | `keywords suggest\|interest\|cluster "<seed>" [--period "today 12-m"] [--geo US]` | Keyword research (`interest` takes a comma list of ≤5) |
22
+ | `keywords suggest\|interest\|cluster "<seed>" [--period "today 12-m"] [--geo US]` | Keyword research (`interest` takes a comma list of ≤5; `suggest` names the engines behind each idea) |
23
+ | `keywords lists [<list id>]` · `keywords target <list id> <keyword id> <url\|none>` | Your saved keyword lists; set or clear the page on your site meant to rank for a keyword |
24
+ | `plan topics [--calendar <id>]` | A content calendar by topic (the first calendar by default): Search Console clicks, impressions and position, and the channels each topic went out on |
23
25
  | `topics [--day YYYY-MM-DD]` | Topic Radar across Google, GitHub and GitLab |
24
26
  | `repos trending [--source all] [--window 7d] [--language ts] [--topic seo]` | Trending repositories |
25
27
  | `chat ["question"] [--mode keywords] [--model fast]` | One-shot answer, or a REPL with `/mode`, `/model`, `/new`, `/exit` |
26
28
  | `blog new "<topic>" [--keyword k] [--words 1500] [--tone friendly] [--out post.md] [--frontmatter astro] [--yes]` | Brief → outline → sections → SEO pass; writes the markdown |
27
29
  | `blog list` · `blog get <id> [--format md\|html\|mdx]` · `blog publish <id> --target github` | Manage posts |
30
+ | `blog link <id> <channel> <url> [--replaces <copy key>]` · `blog unlink <id> <copy key>` | Record, edit or remove the live link of a copy you posted yourself (removing it deletes its results) |
31
+ | `blog results <id>` · `blog results <id> set <copy key> <day> [--views n] [--clicks n] [--reactions n] [--comments n] [--shares n]` · `blog results <id> remove <copy key> <day>` | Results by channel, typed in by hand; `set` replaces the whole day |
32
+ | `blog video <id> [--out script.json] [--force]` | A prompt and a starter `script.json` for turning a post into a narrated film with the third-party [cinematic-skill](https://github.com/Moh4696/cinematic-skill), made by your own agent (Claude Code, Codex, Cursor, Gemini) on your own computer. Prints the install lines and the prompt; `--out` writes the script and won't replace an existing file without `--force`; `--json` gives the full answer. Uses no allowance |
33
+ | `sites [list]` · `sites findings\|opportunities\|compare\|report\|crux <id>` | Your Search Visibility sites: last crawl's findings, Search Console opportunities, crawl comparison, full report, real-user speed (CrUX) |
34
+ | `bing [stats]` | 28 days of Bing Webmaster clicks, impressions and top queries, read with the key you saved in Settings › Connections (the key is set in the web app only) |
35
+ | `sites crawl\|sync <id>` · `sites task <id> <rule> open\|in_progress\|fixed\|dismissed` | Start a crawl, sync Search Console, set a finding's task status (count against the same daily allowances as the app) |
28
36
  | `audit <path\|url> [--cloud]` | v1 local auditor; `--cloud` runs the cloud audit and saves history |
29
37
  | `mcp` | Local stdio MCP server exposing cloud tools + `local_audit`, `local_llms_txt`, `local_sitemap`, `local_install_skills` |
30
38
  | `config get\|set <key> <value>` | `server`, `geo`, `hl`, `model` defaults |
@@ -55,6 +63,14 @@ npx -y seoanything-cli@latest connect --code <setup code> --background
55
63
 
56
64
  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
65
 
66
+ ### Make videos on this computer (`--video`)
67
+
68
+ ```bash
69
+ seoanything connect --video
70
+ ```
71
+
72
+ Lets the content plan's "Make a video" button render the film here. It needs the [cinematic-film skill](https://github.com/Moh4696/cinematic-skill) (looked for in `$SEOANYTHING_FILM_SKILL`, then `~/.claude/skills/cinematic-film`, `~/.agents/skills/…`, `~/.codex/skills/…`, `~/.cinematic-skill/skills/…`), `python3` with `skia-python numpy pillow`, `ffmpeg`, and a free voice (macOS `say`, or `espeak-ng`). If anything is missing the connector says what and runs without video. Each film is made in a new folder `~/SEOAnything/videos/<slug>-<date>-<time>` with the skill's own scripts (free scratch voice, sound effects, captions, a generic scene) and stays on this computer; the website shows where it is. One film at a time, at most 40 minutes; chats keep working meanwhile. Works with `--background` too.
73
+
58
74
  ## MCP
59
75
 
60
76
  ```json
package/dist/tools.mjs CHANGED
@@ -51,11 +51,11 @@ async function collectSse(res) {
51
51
  }
52
52
  return out;
53
53
  }
54
- function httpApi(baseUrl, auth) {
54
+ function httpApi(baseUrl, auth, send = (url, init) => fetch(url, init)) {
55
55
  const base = baseUrl.replace(/\/$/, "");
56
56
  const authHeaders = typeof auth === "string" ? { authorization: `Bearer ${auth}` } : auth ?? {};
57
- const raw = async (method, path, body) => {
58
- const res = await fetch(`${base}/api/v1${path}`, { method, headers: { ...authHeaders, ...body !== void 0 ? { "content-type": "application/json" } : {}, accept: "application/json, text/event-stream" }, body: body !== void 0 ? JSON.stringify(body) : void 0 });
57
+ const raw = async (method, path, body, accept = "application/json, text/event-stream") => {
58
+ const res = await send(`${base}/api/v1${path}`, { method, headers: { ...authHeaders, ...body !== void 0 ? { "content-type": "application/json" } : {}, accept }, body: body !== void 0 ? JSON.stringify(body) : void 0 });
59
59
  if (!res.ok) {
60
60
  const p = await res.json().catch(() => ({}));
61
61
  throw new ApiFail(res.status, p.code ?? `http_${res.status}`, p.detail ?? p.title ?? res.statusText, p);
@@ -85,6 +85,61 @@ function httpApi(baseUrl, auth) {
85
85
  blogOptimize: (a) => request("POST", `/blog/posts/${a.postId}/optimize`),
86
86
  blogGet: (a) => a.format ? request("GET", `/blog/posts/${a.postId}/export${qs({ format: a.format })}`).then((content) => ({ content })) : request("GET", `/blog/posts/${a.postId}`),
87
87
  blogList: (a) => request("GET", `/blog/posts${qs(a)}`),
88
+ keywordQuestions: (a) => request("GET", `/keywords/questions${qs({ q: a.keyword, geo: a.geo, hl: a.hl })}`),
89
+ keywordSeasonality: (a) => request("POST", "/keywords/seasonality", a),
90
+ seoContentGap: (a) => request("POST", "/seo/gap", a),
91
+ seoAnswerCoverage: (a) => request("POST", "/seo/answers", a),
92
+ seoAiReadiness: (a) => request("POST", "/seo/geo", a),
93
+ siteList: () => request("GET", "/visibility/sites"),
94
+ siteFindings: (a) => request("GET", `/visibility/sites/${encodeURIComponent(a.siteId)}/findings`),
95
+ siteOpportunities: (a) => request("GET", `/visibility/sites/${encodeURIComponent(a.siteId)}/opportunities`),
96
+ siteCompare: (a) => request("GET", `/visibility/sites/${encodeURIComponent(a.siteId)}/compare`),
97
+ siteReport: async (a) => ({ markdown: await request("GET", `/visibility/sites/${encodeURIComponent(a.siteId)}/report.md`) }),
98
+ siteCrawl: (a) => request("POST", `/visibility/sites/${encodeURIComponent(a.siteId)}/crawls`, {}),
99
+ // a sync runs as numbered parts, one request each; the route says which part comes next (null when done). 10 caps a misbehaving server.
100
+ siteSync: async (a) => {
101
+ const parts = [];
102
+ for (let part = 1; part && parts.length < 10; ) {
103
+ const r = await request("POST", `/visibility/sites/${encodeURIComponent(a.siteId)}/sync`, { part });
104
+ parts.push(r);
105
+ part = r.next;
106
+ }
107
+ return { parts, rows: parts.reduce((n, p) => n + (Number(p.rows) || 0), 0) };
108
+ },
109
+ siteTask: (a) => request("PATCH", `/visibility/sites/${encodeURIComponent(a.siteId)}/tasks/${encodeURIComponent(a.rule)}`, { status: a.status }),
110
+ orgdnaList: () => request("GET", "/org-dna"),
111
+ orgdnaOverview: (a) => request("GET", `/org-dna/orgs/${encodeURIComponent(a.orgId)}/overview`),
112
+ orgdnaProducts: (a) => request("GET", `/org-dna/orgs/${encodeURIComponent(a.orgId)}/ecosystem`),
113
+ orgdnaEntities: (a) => request("GET", `/org-dna/orgs/${encodeURIComponent(a.orgId)}/graph${qs({ brief: 1, types: a.types?.join(","), q: a.q, statuses: a.basis?.join(",") })}`),
114
+ orgdnaRelated: (a) => request("GET", `/org-dna/orgs/${encodeURIComponent(a.orgId)}/graph${qs({ brief: 1, center: a.entity, depth: a.depth, types: a.types?.join(",") })}`),
115
+ orgdnaHistory: (a) => request("GET", `/org-dna/orgs/${encodeURIComponent(a.orgId)}/history?brief=1`),
116
+ planList: (a) => request("GET", `/plan${qs(a)}`),
117
+ planAdd: (a) => request("POST", "/plan", a),
118
+ planMove: (a) => request("PATCH", `/plan/${encodeURIComponent(a.id)}`, { day: a.day }),
119
+ planFill: (a) => request("POST", "/plan/fill", a),
120
+ // the draft is written as a job that outlives this request: start it, don't wait for its event stream
121
+ planWrite: async (a) => {
122
+ const res = await raw("POST", `/plan/${encodeURIComponent(a.id)}/run`);
123
+ await res.body?.cancel();
124
+ return { started: true, id: a.id };
125
+ },
126
+ planSettings: (a) => request("PUT", "/plan/settings", a),
127
+ // plain JSON, not a stream: the answer is the finished research
128
+ researchRun: async (a) => (await raw("POST", "/plan/research", a, "application/json")).json(),
129
+ researchList: (a) => request("GET", `/plan/research${qs(a ?? {})}`),
130
+ researchDecide: (a) => a.action === "reject" ? request("POST", `/plan/research/${encodeURIComponent(a.id)}/reject`).then(() => ({ status: "rejected" })) : request("POST", `/plan/research/${encodeURIComponent(a.id)}/approve`, { reject: a.reject ?? [], fill: a.fill ?? false, targets: a.targets }),
131
+ planTopics: (a) => request("GET", `/plan/topics${qs(a ?? {})}`),
132
+ keywordLists: (a) => request("GET", a.listId ? `/keyword-lists/${encodeURIComponent(a.listId)}` : "/keyword-lists"),
133
+ keywordTarget: (a) => request("PATCH", `/keyword-lists/${encodeURIComponent(a.listId)}/keywords/${encodeURIComponent(a.keywordId)}`, { targetUrl: a.targetUrl }),
134
+ blogResults: (a) => request("GET", `/blog/posts/${encodeURIComponent(a.postId)}/results`),
135
+ blogVideoBrief: (a) => request("GET", `/blog/posts/${encodeURIComponent(a.postId)}/video-brief`),
136
+ blogResultsSet: ({ postId: postId2, ...b }) => request("PUT", `/blog/posts/${encodeURIComponent(postId2)}/results`, b),
137
+ // a copy key holds "/" (channel:host/path): encoded, it stays one path segment
138
+ blogResultsRemove: (a) => request("DELETE", `/blog/posts/${encodeURIComponent(a.postId)}/results/${encodeURIComponent(a.copyKey)}/${encodeURIComponent(a.day)}`),
139
+ blogLinkSave: ({ postId: postId2, ...b }) => request("PUT", `/blog/posts/${encodeURIComponent(postId2)}/links`, b),
140
+ blogLinkRemove: (a) => request("DELETE", `/blog/posts/${encodeURIComponent(a.postId)}/links/${encodeURIComponent(a.key)}`),
141
+ siteCrux: (a) => request("GET", `/visibility/sites/${encodeURIComponent(a.siteId)}/crux`),
142
+ bingStats: () => request("GET", "/connections/bing/stats"),
88
143
  chatAsk: async (a) => {
89
144
  const conv = await request("POST", "/conversations", { mode: a.mode ?? "general" });
90
145
  return { answer: await collectSse(await raw("POST", `/conversations/${conv.id}/messages`, { content: a.question })) };
@@ -97,11 +152,23 @@ import { z } from "zod";
97
152
  var def = (t) => t;
98
153
  var ro = (openWorldHint = false) => ({ readOnlyHint: true, destructiveHint: false, openWorldHint });
99
154
  var rw = (openWorldHint = false) => ({ readOnlyHint: false, destructiveHint: false, openWorldHint });
155
+ var del = () => ({ readOnlyHint: false, destructiveHint: true, openWorldHint: false });
100
156
  var ALL = ["remote", "local", "chat"];
101
157
  var RL = ["remote", "local"];
102
158
  var geo = z.string().length(2).toUpperCase().default("US").describe("ISO-3166 alpha-2 country code");
103
159
  var hl = z.string().min(2).max(5).default("en").describe("UI language, e.g. en");
104
160
  var period = z.enum(["now 1-H", "now 4-H", "now 1-d", "now 7-d", "now 1-m", "today 3-m", "today 12-m", "today 5-y"]).default("today 12-m");
161
+ var siteId = z.string().regex(/^[a-f0-9]{16,32}$/, "a site id from site_list").describe("site id from site_list");
162
+ var orgId = z.string().regex(/^[a-f0-9]{16,32}$/, "an organization id from orgdna_list").describe("organization id from orgdna_list");
163
+ var entityType = z.enum(["organization", "brand", "website", "product", "service", "segment", "problem", "intent", "keyword", "question", "topic", "page", "competitor", "industry", "location", "technology", "channel", "opportunity", "risk", "issue"]);
164
+ var planId = z.string().regex(/^[a-f0-9]{16,32}$/, "an item id from plan_list").describe("plan item id from plan_list");
165
+ var calendar = z.string().regex(/^[a-f0-9]{16,32}$/, "a calendar id from plan_list").optional().describe("content calendar id from plan_list (one calendar per project); the first calendar when left out");
166
+ var dayStr = z.string().regex(/^\d{4}-\d{2}-\d{2}$/, "a date as YYYY-MM-DD").describe("a UTC date as YYYY-MM-DD");
167
+ var postId = z.string().regex(/^[a-f0-9]{16,32}$/, "a post id from blog_list").describe("post id from blog_list");
168
+ var listId = z.string().regex(/^[a-f0-9]{16,32}$/, "a keyword list id from keyword_lists").describe("keyword list id from keyword_lists (an approved research returns one)");
169
+ var copyKey = z.string().max(600).regex(/^[a-z]{1,12}(:\S+)?$/, "a copy key from blog_results").describe("key of a live copy from blog_results, e.g. linkedin:linkedin.com/posts/abc");
170
+ var LINK_CHANNELS = ["linkedin", "x", "reddit", "medium", "quora", "hackernews", "bluesky", "dailydev", "devto", "notion", "youtube", "tiktok", "instagram", "pinterest", "other"];
171
+ var count = z.number().int().min(0).max(1e9).optional();
105
172
  var local = (ctx) => {
106
173
  if (!ctx.local) throw new Error("local tools are only available in `seoanything mcp`");
107
174
  return ctx.local;
@@ -110,7 +177,7 @@ var TOOLS = [
110
177
  def({ name: "trends_daily", title: "Daily trending searches", description: "Latest Google daily trending searches for a country, ranked with an opportunity score.", input: z.object({ geo, hl, limit: z.number().int().min(1).max(50).default(20) }), annotations: ro(true), surfaces: ALL, run: (c, a) => c.api.trendsDaily(a) }),
111
178
  def({ name: "trends_realtime", title: "Realtime trends", description: "Google realtime trending searches for the last N hours.", input: z.object({ geo, hours: z.number().int().min(1).max(24).default(4) }), annotations: ro(true), surfaces: ALL, run: (c, a) => c.api.trendsRealtime(a) }),
112
179
  def({ name: "trend_articles", title: "Trend articles", description: "News articles behind trending keywords (use articleKeys from trends_daily).", input: z.object({ articleKeys: z.array(z.tuple([z.number(), z.string(), z.string()])).min(1).max(20), count: z.number().int().min(1).max(10).default(5) }), annotations: ro(true), surfaces: RL, run: (c, a) => c.api.trendArticles(a) }),
113
- def({ name: "keyword_suggest", title: "Keyword suggestions", description: "Autocomplete keyword ideas for a seed keyword.", input: z.object({ keyword: z.string().min(1).max(120), hl }), annotations: ro(true), surfaces: ALL, run: (c, a) => c.api.keywordSuggest(a) }),
180
+ def({ name: "keyword_suggest", title: "Keyword suggestions", description: "Autocomplete keyword ideas for a seed keyword from the search boxes of Google, YouTube and DuckDuckGo, each with the engines that suggested it (found).", input: z.object({ keyword: z.string().min(1).max(120), hl }), annotations: ro(true), surfaces: ALL, run: (c, a) => c.api.keywordSuggest(a) }),
114
181
  def({ name: "keyword_interest", title: "Interest over time", description: "Google Trends interest-over-time series for up to 5 keywords.", input: z.object({ keywords: z.array(z.string().min(1)).min(1).max(5), geo, period }), annotations: ro(true), surfaces: ALL, run: (c, a) => c.api.keywordInterest(a) }),
115
182
  def({ name: "keyword_regions", title: "Interest by region", description: "Where a keyword is searched most (geo map data).", input: z.object({ keyword: z.string().min(1), geo, resolution: z.enum(["COUNTRY", "REGION", "CITY", "DMA"]).default("REGION") }), annotations: ro(true), surfaces: RL, run: (c, a) => c.api.keywordRegions(a) }),
116
183
  def({ name: "keyword_cluster", title: "Keyword clusters", description: "Cluster a seed keyword into topic groups with search intent and pillar flags (LLM, counts against keyword_cluster quota).", input: z.object({ seed: z.string().min(1).max(120), geo, hl }), annotations: ro(true), surfaces: RL, run: (c, a) => c.api.keywordCluster(a) }),
@@ -124,6 +191,49 @@ var TOOLS = [
124
191
  def({ name: "blog_get", title: "Get blog post", description: "Read a post, optionally exported as md/html/mdx.", input: z.object({ postId: z.string(), format: z.enum(["md", "html", "mdx"]).optional() }), annotations: ro(), surfaces: RL, run: (c, a) => c.api.blogGet(a) }),
125
192
  def({ name: "blog_list", title: "List blog posts", description: "List your Blog Studio posts.", input: z.object({ limit: z.number().int().min(1).max(100).default(20), cursor: z.string().optional() }), annotations: ro(), surfaces: RL, run: (c, a) => c.api.blogList(a) }),
126
193
  def({ name: "chat_ask", title: "Ask SEO chat", description: "Single-turn answer from SEO Chat in a given mode (no nested tools).", input: z.object({ question: z.string().min(1).max(4e3), mode: z.enum(["general", "keywords", "blog", "technical", "schema", "geo", "links", "programmatic"]).default("general") }), annotations: ro(), surfaces: RL, run: (c, a) => c.api.chatAsk(a) }),
194
+ def({ name: "keyword_questions", title: "Questions people type", description: "Questions people type about a keyword, grouped by opening word. Source: search-box autocomplete, not Google's People Also Ask. English only.", input: z.object({ keyword: z.string().min(1).max(100), geo, hl }), annotations: ro(true), surfaces: ALL, run: (c, a) => c.api.keywordQuestions(a) }),
195
+ def({ name: "keyword_seasonality", title: "Seasonality", description: "The months a search peaks in, from five years of Google Trends relative interest. An index against the yearly average, never a search volume.", input: z.object({ keyword: z.string().min(1).max(100), geo, hl }), annotations: ro(true), surfaces: ALL, run: (c, a) => c.api.keywordSeasonality(a) }),
196
+ def({ name: "seo_content_gap", title: "Content gap", description: "Topics a competitor's public sitemap lists that your site has no page for. Reads robots.txt and sitemaps only; no rankings, traffic or volume. Counts as one audit.", input: z.object({ site: z.string().min(4).max(2048).describe("your site, e.g. example.com"), competitor: z.string().min(4).max(2048).describe("the competitor's site") }), annotations: ro(true), surfaces: ALL, run: (c, a) => c.api.seoContentGap(a) }),
197
+ def({ name: "seo_answer_coverage", title: "Answer coverage", description: "Which real searches around a page's topic the page answers, and which of its sections can be quoted on their own. Counts as one audit.", input: z.object({ url: z.string().url(), topic: z.string().min(2).max(80).optional() }), annotations: ro(true), surfaces: ALL, run: (c, a) => c.api.seoAnswerCoverage(a) }),
198
+ def({ name: "seo_ai_readiness", title: "AI search readiness", description: "Check a public URL for AI-search (GEO) readiness: crawler access, llms.txt, structured data, answer structure.", input: z.object({ url: z.string().url() }), annotations: ro(true), surfaces: ALL, run: (c, a) => c.api.seoAiReadiness(a) }),
199
+ def({ name: "site_list", title: "My sites", description: "The sites you track in Search Visibility, with their ids, last crawl and whether Search Console is connected.", input: z.object({}), annotations: ro(), surfaces: ALL, run: (c) => c.api.siteList() }),
200
+ def({ name: "site_findings", title: "Site audit findings", description: "Technical SEO findings from the last crawl of one of your sites, by priority (use an id from site_list).", input: z.object({ siteId }), annotations: ro(), surfaces: ALL, run: (c, a) => c.api.siteFindings(a) }),
201
+ def({ name: "site_opportunities", title: "Search opportunities", description: "Keyword opportunities for one of your sites from its own Search Console data. Says so when Search Console is not connected; volume and difficulty are unavailable.", input: z.object({ siteId }), annotations: ro(), surfaces: ALL, run: (c, a) => c.api.siteOpportunities(a) }),
202
+ def({ name: "site_compare", title: "Compare crawls", description: "What changed between the last two crawls of one of your sites: pages added, removed and changed (status, title, canonical, indexability) and finding counts before and after.", input: z.object({ siteId }), annotations: ro(), surfaces: ALL, run: (c, a) => c.api.siteCompare(a) }),
203
+ def({ name: "site_crux", title: "Real-user speed", description: "Real-user speed of one of your sites from the Chrome UX Report: about 25 weekly p75 values of LCP, INP and CLS on phone and desktop, for the whole origin and up to 5 top pages. Says so when Chrome has too little data or the server's Google key is not set up. Uses no daily allowance.", input: z.object({ siteId }), annotations: ro(true), surfaces: ALL, run: (c, a) => c.api.siteCrux(a) }),
204
+ def({ name: "bing_stats", title: "Bing Webmaster numbers", description: "The last 28 days from Bing Webmaster Tools for up to 10 of your verified sites: clicks, impressions, the daily series and the top 10 queries, read with the Bing API key saved in Settings \u203A Connections (the key is never returned). Answers not_connected when no key is saved. Uses no daily allowance.", input: z.object({}), annotations: ro(true), surfaces: ALL, run: (c) => c.api.bingStats() }),
205
+ def({ name: "site_crawl", title: "Start a crawl", description: "Start a new crawl of one of your sites (or return the crawl already running). It carries on in the background; read the results later with site_findings. Counts against the daily crawl allowance.", input: z.object({ siteId }), annotations: rw(true), surfaces: RL, run: (c, a) => c.api.siteCrawl(a) }),
206
+ def({ name: "site_sync", title: "Sync Search Console", description: "Fetch the latest Search Console data for one of your sites (all parts of the sync, one after another). Needs Search Console connected and a property chosen. Counts against the daily sync allowance.", input: z.object({ siteId }), annotations: rw(true), surfaces: RL, run: (c, a) => c.api.siteSync(a) }),
207
+ def({ name: "site_task", title: "Set finding status", description: "Set the task status of one finding on one of your sites: open, in_progress, fixed or dismissed (rule id from site_findings). Marking it fixed records the current count so the next crawl can confirm the fix.", input: z.object({ siteId, rule: z.string().regex(/^[a-z0-9_]{2,40}$/, "a rule id from site_findings").describe("finding rule id from site_findings, e.g. title_missing"), status: z.enum(["open", "in_progress", "fixed", "dismissed"]) }), annotations: rw(), surfaces: RL, run: (c, a) => c.api.siteTask(a) }),
208
+ // the content plan and keyword research (the same routes the app's plan page uses). Nothing here publishes a post:
209
+ // a draft waits for its author's review in the app.
210
+ def({ name: "plan_list", title: "Content plan", description: "One of your content calendars (one per project; the first when none is named): one keyword a day, each with its state (planned, running, done, failed) and its post once written, plus whether autopilot, the weekly refresh and header images are on, and all your calendars with their ids. Days are UTC dates.", input: z.object({ from: dayStr.optional(), to: dayStr.optional(), calendar }), annotations: ro(), surfaces: RL, run: (c, a) => c.api.planList(a) }),
211
+ def({ name: "plan_add", title: "Plan a keyword", description: "Put a keyword on a free day of a content calendar (today or later). A day of a calendar holds one keyword, and a keyword is planned once per calendar.", input: z.object({ term: z.string().trim().min(1).max(120).describe("the keyword to write about"), day: dayStr, calendar }), annotations: rw(), surfaces: RL, run: (c, a) => c.api.planAdd(a) }),
212
+ def({ name: "plan_move", title: "Move a planned keyword", description: "Move a planned item to another free day (today or later). An item being written or already written stays where it is.", input: z.object({ id: planId, day: dayStr }), annotations: rw(), surfaces: RL, run: (c, a) => c.api.planMove(a) }),
213
+ def({ name: "plan_fill", title: "Fill the plan from a keyword list", description: "Lay one of your saved keyword lists over the free days of a content calendar for the next N days: topics rotate, each pillar keyword first, and keywords already planned on that calendar or written are skipped.", input: z.object({ listId: z.string().regex(/^[a-f0-9]{16,32}$/, "a keyword list id").describe("keyword list id (an approved research returns one)"), days: z.number().int().min(1).max(90).default(30), calendar }), annotations: rw(), surfaces: RL, run: (c, a) => c.api.planFill(a) }),
214
+ def({ name: "plan_write", title: "Write a planned draft now", description: "Start writing the draft for one planned item: brief, outline, sections and the SEO pass. It runs in the background for a few minutes; read its state later with plan_list. The draft is not published. Counts against the daily post and section allowances.", input: z.object({ id: planId }), annotations: rw(true), surfaces: RL, run: (c, a) => c.api.planWrite(a) }),
215
+ def({ name: "plan_settings", title: "Content plan switches", description: "Turn the plan's switches on or off: autopilot (the calendar's keyword of the day is written as a draft each morning, UTC) and images (a generated header photo for each draft) for one content calendar, and refresh (once a week the finished post losing the most clicks is rewritten as a proposal) for your whole account. Only the switches you send change.", input: z.object({ autopilot: z.boolean().optional(), refresh: z.boolean().optional(), images: z.boolean().optional(), calendar }).refine((b) => [b.autopilot, b.refresh, b.images].some((v) => v !== void 0), "send at least one switch"), annotations: rw(), surfaces: RL, run: (c, a) => c.api.planSettings(a) }),
216
+ def({ name: "research_run", title: "Research keywords for a goal", description: "Research keywords for a goal in your own words: real search suggestions grouped into clusters, without the keywords you already have. The result waits for review (research_decide); nothing is saved to your lists or plan. Approving it with fill plans it on the calendar it was made for. Takes about a minute. No search volume or difficulty. Counts against the daily keyword cluster allowance.", input: z.object({ goal: z.string().trim().min(10).max(400).describe("what you want to rank for, a product you are launching, or an audience"), geo, calendar }), annotations: rw(true), surfaces: RL, run: (c, a) => c.api.researchRun(a) }),
217
+ def({ name: "research_list", title: "Keyword research runs", description: "The recent keyword research runs of one content calendar (the first when none is named), with their clusters and state: ready (waiting for review), approved or rejected.", input: z.object({ calendar }), annotations: ro(), surfaces: RL, run: (c, a) => c.api.researchList(a) }),
218
+ def({ name: "research_decide", title: "Approve or reject a research", description: "Decide a research that is ready: approve saves its clusters as a keyword list (leave clusters out by their position in `reject`, starting at 0) and, with fill, plans them on the free days; reject closes it without saving anything.", input: z.object({ id: z.string().regex(/^[a-f0-9]{16,32}$/, "a research id from research_list").describe("research id from research_list"), action: z.enum(["approve", "reject"]), reject: z.array(z.number().int().min(0).max(50)).max(50).default([]).describe("cluster positions to leave out when approving"), fill: z.boolean().default(false).describe("also plan the kept keywords on the free days"), targets: z.record(z.string().min(1).max(100), z.string().trim().url().max(2e3)).optional().describe("when approving: the page on your own site meant to rank for a keyword, keyed by the keyword") }), annotations: rw(), surfaces: RL, run: (c, a) => c.api.researchDecide(a) }),
219
+ def({ name: "plan_topics", title: "Content plan by topic", description: "One content calendar (the first when none is named) grouped by topic: keywords planned, written and published per topic, the Search Console clicks, impressions and average position of its posts (latest stored period), and the channels they went out on. searchConsole is false when none of your sites has Search Console data.", input: z.object({ calendar }), annotations: ro(), surfaces: RL, run: (c, a) => c.api.planTopics(a) }),
220
+ def({ name: "keyword_lists", title: "Saved keyword lists", description: "Your saved keyword lists. With listId, one list's keywords with their ids, intent, cluster, the engines that suggested each (google, youtube, duckduckgo; empty when the AI added it, null when unknown) and the target page set for it.", input: z.object({ listId: listId.optional() }), annotations: ro(), surfaces: RL, run: (c, a) => c.api.keywordLists(a) }),
221
+ def({ name: "keyword_target", title: "Set a keyword's target page", description: "Set the page on your own site meant to rank for one saved keyword (ids from keyword_lists), or clear it with null. When your sites are known, the page must be on one of them.", input: z.object({ listId, keywordId: z.string().regex(/^[a-f0-9]{16,32}$/, "a keyword id from keyword_lists").describe("keyword id from keyword_lists"), targetUrl: z.string().trim().url().max(2e3).nullable().describe("the page's full address, or null to clear it") }), annotations: rw(), surfaces: RL, run: (c, a) => c.api.keywordTarget(a) }),
222
+ // results by channel and the content registry (the post editor's distribute and results cards). Numbers are typed in by
223
+ // hand; no platform is read automatically yet.
224
+ def({ name: "blog_results", title: "Results by channel", description: "Each live copy of one of your posts (the app's own sends and the links you recorded) with its key, link, totals and the daily views, clicks, reactions, comments and shares entered for it. A metric no day reported is null, not zero.", input: z.object({ postId }), annotations: ro(), surfaces: RL, run: (c, a) => c.api.blogResults(a) }),
225
+ def({ name: "blog_video_brief", title: "Video brief for a post", description: "A ready prompt and a starter script.json for making one of your posts into a narrated film with the third-party cinematic-skill (npx skills add Moh4696/cinematic-skill), run by your own AI agent on your own computer. Nothing is rendered on our servers and no allowance is used.", input: z.object({ postId }), annotations: ro(), surfaces: RL, run: (c, a) => c.api.blogVideoBrief(a) }),
226
+ def({ name: "blog_results_set", title: "Enter a day's results", description: "Enter or correct one day's numbers for one live copy of a post (key from blog_results). The whole day is replaced, so a number left out becomes not reported. Days within the last 400 days only. Returns the post's results.", input: z.object({ postId, copyKey, day: z.string().regex(/^\d{4}-\d{2}-\d{2}$/, "a date as YYYY-MM-DD").describe("the day the numbers are for, YYYY-MM-DD"), views: count, clicks: count, reactions: count, comments: count, shares: count }).refine((b) => [b.views, b.clicks, b.reactions, b.comments, b.shares].some((v) => v !== void 0), "send at least one number"), annotations: del(), surfaces: RL, run: (c, a) => c.api.blogResultsSet(a) }),
227
+ def({ name: "blog_results_remove", title: "Remove a day's results", description: "Remove the numbers entered for one day of one live copy of a post (key and day from blog_results). Returns the post's results.", input: z.object({ postId, copyKey, day: z.string().regex(/^\d{4}-\d{2}-\d{2}$/, "a date as YYYY-MM-DD").describe("the day to remove, YYYY-MM-DD") }), annotations: del(), surfaces: RL, run: (c, a) => c.api.blogResultsRemove(a) }),
228
+ def({ name: "blog_link_save", title: "Record a live link", description: "Record the address of a copy of a post you posted yourself (LinkedIn, Reddit, Medium \u2026), so every published copy has a row and can take results. With replaces (a key from blog_results), edits a link you recorded, and its results move with it. Links the app posted itself are never changed. Returns the post.", input: z.object({ postId, channel: z.enum(LINK_CHANNELS).describe("where the copy is; other for any site not listed"), url: z.string().trim().url().max(500).regex(/^https?:\/\//i, "an http or https address").describe("the copy's full address"), replaces: copyKey.optional().describe("key of a link you recorded, to edit it") }), annotations: rw(), surfaces: RL, run: (c, a) => c.api.blogLinkSave(a) }),
229
+ def({ name: "blog_link_remove", title: "Remove a live link", description: "Remove a live link you recorded on a post (key from blog_results). The numbers entered for that copy are deleted with it. Links the app posted itself can't be removed. Returns the post.", input: z.object({ postId, key: copyKey }), annotations: del(), surfaces: RL, run: (c, a) => c.api.blogLinkRemove(a) }),
230
+ def({ name: "site_report", title: "Site report", description: "The full Search Visibility report for one of your sites as Markdown.", input: z.object({ siteId }), annotations: ro(), surfaces: RL, run: (c, a) => c.api.siteReport(a) }),
231
+ def({ name: "orgdna_list", title: "My organizations", description: "The organizations you analysed in Organization DNA, with their ids and when each was last analysed.", input: z.object({}), annotations: ro(), surfaces: RL, run: (c) => c.api.orgdnaList() }),
232
+ def({ name: "orgdna_overview", title: "Organization overview", description: "Measured headline numbers of an organization's latest analysis, each with its state and how it is measured, the six health areas and the identity facts that are missing. A null value means not measured, never zero.", input: z.object({ orgId }), annotations: ro(), surfaces: RL, run: (c, a) => c.api.orgdnaOverview(a) }),
233
+ def({ name: "orgdna_products", title: "Products and services", description: "Each product and service of an organization with the pages, searches, customer questions, problems and opportunities the analysis connects to it, and the gaps that follow.", input: z.object({ orgId }), annotations: ro(), surfaces: RL, run: (c, a) => c.api.orgdnaProducts(a) }),
234
+ def({ name: "orgdna_entities", title: "Knowledge graph entities", description: "Entities of an organization's knowledge graph by type, name or kind of knowledge. Each has a basis: observed, external, inferred (an AI reading) or confirmed. Returns a link that opens the same view in the app.", input: z.object({ orgId, types: z.array(entityType).max(20).optional(), q: z.string().min(2).max(80).optional(), basis: z.array(z.enum(["observed", "external", "inferred", "confirmed"])).max(4).optional() }), annotations: ro(), surfaces: RL, run: (c, a) => c.api.orgdnaEntities(a) }),
235
+ def({ name: "orgdna_related", title: "Connected entities", description: "Entities connected to one entity of an organization's knowledge graph, with the relationships between them (for example the pages and keywords connected to a product).", input: z.object({ orgId, entity: z.string().regex(/^[a-z]{3,12}:[\p{L}\p{N}-]{1,80}$/u, "an entity id such as product:crumb-pos").describe("entity id from orgdna_entities"), depth: z.number().int().min(1).max(3).default(1), types: z.array(entityType).max(20).optional() }), annotations: ro(), surfaces: RL, run: (c, a) => c.api.orgdnaRelated(a) }),
236
+ def({ name: "orgdna_history", title: "Organization history", description: "An organization's analyses over time with their numbers, the entities that entered and left the graph at each analysis, and Search Console and recorded AI answer trends where those were measured.", input: z.object({ orgId }), annotations: ro(), surfaces: RL, run: (c, a) => c.api.orgdnaHistory(a) }),
127
237
  // local only — seoanything v1 running on the user's machine
128
238
  def({ name: "local_audit", title: "Audit local files", description: "Audit HTML/JSX/MD files in a local file or folder (or a URL) with the seoanything auditor.", input: z.object({ path: z.string().default(".") }), annotations: ro(), surfaces: ["local"], run: (c, a) => local(c).runAudit(a.path) }),
129
239
  def({ name: "local_llms_txt", title: "Generate llms.txt", description: "Generate llms.txt for a project directory. Written to disk only when write=true.", input: z.object({ dir: z.string().default("."), title: z.string().optional(), description: z.string().optional(), write: z.boolean().default(false) }), annotations: rw(), surfaces: ["local"], run: async (c, a) => {
@@ -197,6 +307,7 @@ function registerAll(server, ctx) {
197
307
  }
198
308
  export {
199
309
  ApiFail,
310
+ LINK_CHANNELS,
200
311
  McpServer,
201
312
  PROMPTS,
202
313
  TOOLS,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "seoanything-cli",
3
- "version": "2.3.0",
3
+ "version": "2.4.1",
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/cli.js CHANGED
@@ -16,9 +16,15 @@ const OPTS = {
16
16
  server: { type: "string" }, "api-key": { type: "string" }, "no-browser": { type: "boolean" }, local: { type: "boolean" }, cloud: { type: "boolean" }, yes: { type: "boolean" },
17
17
  geo: { type: "string" }, hl: { type: "string" }, limit: { type: "string" }, hours: { type: "string" }, period: { type: "string" }, day: { type: "string" },
18
18
  source: { type: "string" }, window: { type: "string" }, language: { type: "string" }, topic: { type: "string" },
19
- code: { type: "string" }, background: { type: "boolean" },
19
+ code: { type: "string" }, background: { type: "boolean" }, video: { type: "boolean" }, calendar: { type: "string" },
20
20
  mode: { type: "string" }, model: { type: "string" }, keyword: { type: "string" }, words: { type: "string" }, tone: { type: "string" }, out: { type: "string" }, frontmatter: { type: "string" }, format: { type: "string" }, target: { type: "string" },
21
+ replaces: { type: "string" }, views: { type: "string" }, clicks: { type: "string" }, reactions: { type: "string" }, comments: { type: "string" }, shares: { type: "string" },
22
+ force: { type: "boolean" },
21
23
  };
24
+ const HEX_ID = /^[a-f0-9]{16,32}$/, DAY = /^\d{4}-\d{2}-\d{2}$/;
25
+ // app sends are a bare channel (devto, webhook); links recorded by hand are channel:host/path
26
+ const COPY_KEY = /^[a-z]{1,12}(:\S+)?$/;
27
+ const METRICS = ["views", "clicks", "reactions", "comments", "shares"];
22
28
 
23
29
  /** Parse argv into { command, sub, positionals, flags }. Exported for tests. */
24
30
  export function parse(argv) {
@@ -34,16 +40,27 @@ usage: seoanything <command> [options]
34
40
  login [--server <url>] [--api-key <key>] [--no-browser] device-flow login (opens browser) or store an API key
35
41
  logout | whoami | usage credentials and quota
36
42
  trends daily|realtime [--geo NP] [--hl en] [--limit 20] [--hours 4] [--local]
37
- keywords suggest|interest|cluster "<seed>" [--period "today 12-m"] [--geo US]
43
+ keywords suggest|interest|cluster|questions|seasonality "<seed>" [--period "today 12-m"] [--geo US]
44
+ keywords lists [<list id>] | keywords target <list id> <keyword id> <url|none> saved lists; a keyword's target page
45
+ gap <your-site> <competitor> topics their sitemap lists that yours doesn't
46
+ sites [list] | sites findings|opportunities|compare|report|crux <id> your Search Visibility sites: last crawl, Search Console, real-user speed
47
+ sites crawl|sync <id> | sites task <id> <rule> open|in_progress|fixed|dismissed start a crawl, sync Search Console, set a finding's status
48
+ plan topics [--calendar <id>] a content calendar by topic, with Search Console results and channels
49
+ bing [stats] 28 days of Bing Webmaster numbers (key saved in settings › connections)
38
50
  topics [--day YYYY-MM-DD]
39
51
  repos trending [--source all] [--window 7d] [--language ts] [--topic seo] [--limit 25]
40
52
  chat ["question"] [--mode keywords] [--model fast] one-shot or REPL (/mode /model /new /exit)
41
53
  blog new "<topic>" [--keyword k] [--words 1500] [--tone friendly] [--out post.md] [--frontmatter astro] [--yes]
42
54
  blog list | blog get <id> [--format md|html|mdx] | blog publish <id> --target github
55
+ blog link <id> <channel> <url> [--replaces <copy key>] | blog unlink <id> <copy key> live links of copies you posted yourself
56
+ blog results <id> | blog results <id> set <copy key> <day> [--views n] [--clicks n] [--reactions n] [--comments n] [--shares n]
57
+ blog results <id> remove <copy key> <day> results by channel, typed in by hand
58
+ blog video <id> [--out script.json] [--force] prompt and starter script for a narrated film made by your own agent
43
59
  audit <path|url> [--cloud] local auditor, or cloud audit saved to history
44
60
  mcp local stdio MCP server
45
61
  connect [--no-browser] run your own claude/codex/agy for your web chats and posts
46
62
  connect --code <setup code> [--background] link with a setup code from settings › ai engines, no login
63
+ connect --video also make the content plan's videos here (cinematic-film skill, python3 + skia-python, ffmpeg, free voice)
47
64
  config get|set <key> [value] server, defaultGeo, defaultModel …
48
65
  init | install | schema | llms-txt | sitemap | menu seoanything v1 commands, unchanged
49
66
 
@@ -100,12 +117,29 @@ export async function main(argv, io = { out: console.log, err: console.error })
100
117
  return EXIT.ok;
101
118
  }
102
119
  case "keywords": {
103
- const sub = needArg(p.sub, "seoanything keywords suggest|interest|cluster <seed>");
120
+ const sub = needArg(p.sub, "seoanything keywords suggest|interest|cluster|questions|seasonality <seed>");
121
+ if (sub === "lists") {
122
+ const id = p.positionals[1];
123
+ if (id && !HEX_ID.test(id)) throw new CliError("that is not a list id. run `seoanything keywords lists` to list yours.", EXIT.usage);
124
+ if (!id) { const r = await api.get("/keyword-lists"); print(r, (r.items ?? []).map((l) => `${c("32", l.id)} ${l.name} ${c("2", `${l.keywordCount} keywords · ${l.seed}`)}`).join("\n") || "no keyword lists yet."); }
125
+ else { const r = await api.get(`/keyword-lists/${id}`); print(r, `${c("1", r.name)}\n` + r.keywords.map((k) => `${c("2", k.id)} ${k.term}${k.isPillar ? c("35", " · pillar") : ""}${k.engines?.length ? c("2", ` · ${k.engines.join(", ")}`) : ""}${k.targetUrl ? ` → ${k.targetUrl}` : ""}`).join("\n")); }
126
+ return EXIT.ok;
127
+ }
128
+ if (sub === "target") {
129
+ const usage = "seoanything keywords target <list id> <keyword id> <url|none>";
130
+ const [, listId, kid, url] = p.positionals;
131
+ if (!HEX_ID.test(listId ?? "") || !HEX_ID.test(kid ?? "") || !url) throw new CliError(`usage: ${usage}`, EXIT.usage);
132
+ const r = await api.request("PATCH", `/keyword-lists/${listId}/keywords/${kid}`, { targetUrl: url === "none" ? null : url });
133
+ print(r, r.targetUrl ? `target page → ${r.targetUrl}` : "target page cleared.");
134
+ return EXIT.ok;
135
+ }
104
136
  const seed = needArg(p.positionals[1], `seoanything keywords ${sub} "<seed>"`);
105
- if (sub === "suggest") { const r = await api.get(`/keywords/suggest${qs({ q: seed, hl })}`); const list = Array.isArray(r) ? r : r.items ?? []; print(r, list.map((k, i) => `${c("32", `#${i + 1}`)} ${k}`).join("\n")); }
137
+ if (sub === "suggest") { const r = await api.get(`/keywords/suggest${qs({ q: seed, hl, geo })}`); const list = r.found ?? (Array.isArray(r) ? r : r.suggestions ?? []).map((text) => ({ text })); print(r, list.map((k, i) => `${c("32", `#${i + 1}`)} ${k.text}${k.engines?.length ? c("2", ` · ${k.engines.join(", ")}`) : ""}`).join("\n")); }
106
138
  else if (sub === "interest") { const r = await api.post("/keywords/interest", { keywords: seed.split(",").map((s) => s.trim()).filter(Boolean).slice(0, 5), geo, period: flags.period ?? "today 12-m" }); print(r); }
107
139
  else if (sub === "cluster") { const r = await api.post("/keywords/cluster", { seed, geo, hl }); const clusters = Array.isArray(r) ? r : r.clusters ?? r.items ?? []; print(r, clusters.map((cl) => `${c("1", cl.label ?? cl.name ?? "cluster")}${cl.intent ? c("2", ` · ${cl.intent}`) : ""}${cl.pillar ? c("35", " · pillar") : ""}\n ${(cl.keywords ?? []).join(", ")}`).join("\n")); }
108
- else throw new CliError("usage: seoanything keywords suggest|interest|cluster <seed>", EXIT.usage);
140
+ else if (sub === "questions") { const r = await api.get(`/keywords/questions${qs({ q: seed, geo, hl })}`); print(r, (r.groups ?? []).map((g) => `${c("1", g.word)}\n${g.questions.map((x) => ` ${x}`).join("\n")}`).join("\n") + `\n${c("2", r.note ?? `${r.total} from ${r.source}`)}`); }
141
+ else if (sub === "seasonality") { const r = await api.post("/keywords/seasonality", { keyword: seed, geo, hl }); const M = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"]; print(r, `${r.clear ? `peaks in ${r.peaks.map((m) => M[m - 1]).join(", ")}` : `no clear season: ${r.reason}`}\n${(r.months ?? []).map((m) => `${M[m.month - 1]} ${m.index ?? "–"}`).join(" ")}\n${c("2", `${r.source} · index, 100 = yearly average, not a search volume`)}`); }
142
+ else throw new CliError("usage: seoanything keywords suggest|interest|cluster|questions|seasonality <seed>", EXIT.usage);
109
143
  return EXIT.ok;
110
144
  }
111
145
  case "topics": { const r = await api.get(`/topics${qs({ day: flags.day, limit: flags.limit })}`); const items = Array.isArray(r) ? r : r.items ?? []; print(r, items.map((t, i) => `${c("32", `#${i + 1}`)} ${c("1", t.label)} ${c("2", `score ${t.score}`)}\n ${t.summary}`).join("\n")); return EXIT.ok; }
@@ -116,8 +150,9 @@ export async function main(argv, io = { out: console.log, err: console.error })
116
150
  print(r, items.map((x, i) => `${c("32", `#${String(i + 1).padStart(2)}`)} ${x.fullName.padEnd(40)} ${c("33", `+${fmt(x.starDelta)}★`)} ${c("2", x.language ?? "")}\n ${x.description ?? ""}`).join("\n"));
117
151
  return EXIT.ok;
118
152
  }
119
- case "chat": return chat(p, api, io, { print, c, note, d });
120
- case "blog": return blog(p, api, io, { print, c, note, num, needArg, flags });
153
+ // awaited, so their errors reach the catch below and exit with its code
154
+ case "chat": return await chat(p, api, io, { print, c, note, d });
155
+ case "blog": return await blog(p, api, io, { print, c, note, num, needArg, flags });
121
156
  case "audit": {
122
157
  const target = needArg(p.sub, "seoanything audit <path|url> [--cloud]");
123
158
  const url = /^https?:\/\//i.test(target) ? target : `https://${target}`;
@@ -125,6 +160,54 @@ export async function main(argv, io = { out: console.log, err: console.error })
125
160
  print(r, `${c("1", `audit · ${url}`)} · grade ${c("32", r.grade ?? "?")} · score ${r.score ?? "?"}\n` + (r.issues ?? []).map((i) => `${c("31", "✖")} ${i.msg ?? i.message ?? JSON.stringify(i)}`).join("\n"));
126
161
  return EXIT.ok;
127
162
  }
163
+ case "gap": {
164
+ const site = needArg(p.sub, "seoanything gap <your-site> <competitor>"), competitor = needArg(p.positionals[1], "seoanything gap <your-site> <competitor>");
165
+ const r = await api.post("/seo/gap", { site, competitor });
166
+ print(r, `${c("1", `${r.own.site} vs ${r.competitor.site}`)} · ${r.missing} topics they cover and you don't (${r.covered} shared)\n` + r.gaps.map((g) => `${c("31", "−")} ${g.topic} ${c("2", g.url)}`).join("\n") + `\n${c("2", r.method)}`);
167
+ return EXIT.ok;
168
+ }
169
+ case "sites": {
170
+ if (!p.sub || p.sub === "list") { const r = await api.get("/visibility/sites"); print(r, (r.sites ?? []).map((s) => `${c("32", s.id)} ${s.domain}`).join("\n") || "no sites yet. add one at /app/search-visibility"); return EXIT.ok; }
171
+ const id = needArg(p.positionals[1], "seoanything sites findings|opportunities|compare|report|crux|crawl|sync|task <site id>");
172
+ if (!/^[a-f0-9]{16,32}$/.test(id)) throw new CliError("that is not a site id. run `seoanything sites` to list yours.", EXIT.usage);
173
+ if (p.sub === "findings") { const r = await api.get(`/visibility/sites/${id}/findings`); print(r, (r.findings ?? []).map((f) => `${c(f.severity === "critical" || f.severity === "high" ? "31" : "33", f.severity.padEnd(8))} ${String(f.count).padStart(4)}× ${f.rule?.title ?? f.rule?.id ?? ""}`).join("\n") || "no findings. crawl the site first."); }
174
+ else if (p.sub === "opportunities") { const r = await api.get(`/visibility/sites/${id}/opportunities`); print(r, r.available ? r.opportunities.map((o) => `${c("32", String(Math.round(o.score ?? 0)).padStart(3))} ${o.query ?? o.page ?? ""} ${c("2", o.kind ?? "")}`).join("\n") + `\n${c("2", "search volume and difficulty: unavailable")}` : `unavailable: search console ${r.reason === "not_connected" ? "is not connected" : "has not been synced"} for this site.`); }
175
+ else if (p.sub === "compare") { const r = await api.get(`/visibility/sites/${id}/compare`); const k = r.comparison; print(r, r.available ? `${k.added.count} added · ${k.removed.count} removed · ${k.changed.count} changed\n` + [...k.added.urls.map((u) => `${c("32", "+")} ${u.url}`), ...k.removed.urls.map((u) => `${c("31", "−")} ${u.url}`), ...k.changed.pages.map((g) => `${c("33", "~")} ${g.url} ${c("2", g.changes.map((x) => x.field).join(", "))}`)].join("\n") : `unavailable: ${r.reason === "one_crawl" ? "only one crawl so far" : r.reason === "no_crawl" ? "no crawl yet" : "the earlier crawl's pages are no longer kept"}.`); }
176
+ else if (p.sub === "crawl") { const r = await api.post(`/visibility/sites/${id}/crawls`); print(r, `${r.resumed ? "a crawl is already running" : "crawl started"}: ${c("32", r.crawl.id)} · ${r.crawl.fetched}/${r.crawl.maxPages} pages. it carries on in the background; run \`seoanything sites findings ${id}\` when it is done.`); }
177
+ else if (p.sub === "sync") {
178
+ // the route syncs in numbered parts, one request each, and names the next part (null when done)
179
+ const parts = [];
180
+ for (let part = 1; part && parts.length < 10;) { note(`syncing part ${part}…`); const r = await api.post(`/visibility/sites/${id}/sync`, { part }); parts.push(r); part = r.next; }
181
+ const rows = parts.reduce((n, x) => n + (Number(x.rows) || 0), 0);
182
+ print({ parts, rows }, `search console synced: ${rows} rows in ${parts.length} parts.`);
183
+ }
184
+ else if (p.sub === "task") {
185
+ const usage = "seoanything sites task <site id> <rule> open|in_progress|fixed|dismissed";
186
+ const rule = needArg(p.positionals[2], usage), status = needArg(p.positionals[3], usage);
187
+ if (!/^[a-z0-9_]{2,40}$/.test(rule) || !["open", "in_progress", "fixed", "dismissed"].includes(status)) throw new CliError(`usage: ${usage}`, EXIT.usage);
188
+ const r = await api.request("PATCH", `/visibility/sites/${id}/tasks/${rule}`, { status }); print(r, `${rule} → ${status}`);
189
+ }
190
+ else if (p.sub === "report") { const r = await api.get(`/visibility/sites/${id}/report.md`); print({ markdown: r }, String(r)); }
191
+ else if (p.sub === "crux") {
192
+ const r = await api.get(`/visibility/sites/${id}/crux`);
193
+ const line = (form, a) => { const w = a.ok ? a.weeks.at(-1) : null; return ` ${form.padEnd(8)}${w ? `LCP ${w.lcp ?? "–"} ms · INP ${w.inp ?? "–"} ms · CLS ${w.cls ?? "–"} ${c("2", `(28 days to ${w.end})`)}` : c("2", a.message ?? "no data")}`; };
194
+ print(r, [r.origin, ...r.pages].map((t) => `${c("1", t.url ?? t.origin)}\n${line("phone", t.phone)}\n${line("desktop", t.desktop)}`).join("\n") + `\n${c("2", "p75 from the Chrome UX Report; run with --json for every week")}`);
195
+ }
196
+ else throw new CliError("usage: seoanything sites [list] | sites findings|opportunities|compare|report|crux|crawl|sync <site id> | sites task <site id> <rule> <status>", EXIT.usage);
197
+ return EXIT.ok;
198
+ }
199
+ case "plan": {
200
+ if (p.sub !== "topics") throw new CliError("usage: seoanything plan topics [--calendar <id>]", EXIT.usage);
201
+ const r = await api.get(`/plan/topics${typeof flags.calendar === "string" ? `?calendar=${encodeURIComponent(flags.calendar)}` : ""}`);
202
+ print(r, r.topics.length ? r.topics.map((t) => `${c("1", t.topic)} ${c("2", `${t.keywords} keywords · ${t.written} written · ${t.published} published`)}\n ${t.hasData ? `${t.clicks} clicks · ${t.impressions} impressions · position ${t.position ?? "–"}` : "no search data"}${t.channels.length ? ` · on ${t.channels.join(", ")}` : ""}`).join("\n") + (r.searchConsole ? "" : `\n${c("2", "search console is not connected to any of your sites")}`) : "no plan yet.");
203
+ return EXIT.ok;
204
+ }
205
+ case "bing": {
206
+ if (p.sub && p.sub !== "stats") throw new CliError("usage: seoanything bing [stats]", EXIT.usage);
207
+ const r = await api.get("/connections/bing/stats");
208
+ print(r, r.sites.map((s) => s.error ? `${c("1", s.url)} ${c("31", s.error)}` : `${c("1", s.url)} ${s.clicks} clicks · ${s.impressions} impressions\n ${s.queries.map((q) => `${q.query} (${q.clicks})`).join(", ") || "no queries yet"}`).join("\n") + `\n${c("2", `last ${r.days} days from Bing Webmaster Tools${r.more ? ` · ${r.more} more sites not shown` : ""}`)}`);
209
+ return EXIT.ok;
210
+ }
128
211
  case "mcp": { const { mcp } = await import("./mcp.js"); await mcp(flags); return EXIT.ok; }
129
212
  case "connect": {
130
213
  // link this computer: the web app's chats and blog posts can then run on the AI CLIs installed here
@@ -142,14 +225,14 @@ export async function main(argv, io = { out: console.log, err: console.error })
142
225
  let token = deviceToken ? null : creds.token;
143
226
  if (!deviceToken && !token) { const r = await login({ server: creds.server, noBrowser: flags["no-browser"], log: io.err }); io.err(c("32", `logged in as ${r.user?.email ?? "you"}`)); token = resolveCreds(flags).token; }
144
227
  if (flags.background) {
145
- const bg = startBackground(creds.server);
228
+ const bg = startBackground(creds.server, { video: flags.video });
146
229
  print({ ok: true, pid: bg.pid, log: bg.log }, c("32", `✓ the connector now runs in the background (pid ${bg.pid}, log ${bg.log}). you can close this window; stop it with "disconnect" in settings › ai engines.`));
147
230
  return EXIT.ok;
148
231
  }
149
232
  const ac = new AbortController();
150
233
  for (const sig of ["SIGINT", "SIGTERM"]) process.on(sig, () => ac.abort());
151
234
  const onUnlinked = () => { const cfg = loadConfig(); delete cfg.connector; saveConfig(cfg); };
152
- io.err(connectReasonColor(c, await connect({ server: creds.server, token, deviceToken, onUnlinked, log: io.err, signal: ac.signal })));
235
+ io.err(connectReasonColor(c, await connect({ server: creds.server, token, deviceToken, onUnlinked, log: io.err, signal: ac.signal, video: flags.video })));
153
236
  return EXIT.ok;
154
237
  }
155
238
  case "config": {
@@ -209,7 +292,51 @@ async function blog(p, api, io, { print, c, note, num, needArg, flags }) {
209
292
  if (sub === "list") { const r = await api.get("/blog/posts"); const items = r.items ?? r; print(r, items.map((x) => `${c("2", x.id)} ${c("1", x.title ?? x.topic)} ${x.status ?? ""}`).join("\n") || "no posts yet. `seoanything blog new \"<topic>\"`"); return EXIT.ok; }
210
293
  if (sub === "get") { const id = needArg(p.positionals[1], "seoanything blog get <id> [--format md|html|mdx]"); const r = flags.format ? await api.get(`/blog/posts/${id}/export${qs({ format: flags.format, frontmatter: flags.frontmatter })}`) : await api.get(`/blog/posts/${id}`); print(r, typeof r === "string" ? r : r.contentMd ?? r.content ?? JSON.stringify(r, null, 2)); return EXIT.ok; }
211
294
  if (sub === "publish") { const id = needArg(p.positionals[1], "seoanything blog publish <id> --target site|github|gitlab"); const r = await api.post(`/blog/posts/${id}/publish`, { target: flags.target ?? "site" }); print(r, `published: ${r.url ?? JSON.stringify(r)}`); return EXIT.ok; }
212
- if (sub !== "new") throw new CliError("usage: seoanything blog new|list|get|publish", EXIT.usage);
295
+ if (sub === "link" || sub === "unlink" || sub === "results") {
296
+ const usage = { link: "seoanything blog link <id> <channel> <url> [--replaces <copy key>]", unlink: "seoanything blog unlink <id> <copy key>", results: "seoanything blog results <id> [set|remove <copy key> <day>]" }[sub];
297
+ const [, id, a, b, day] = p.positionals;
298
+ if (!HEX_ID.test(id ?? "")) throw new CliError(`usage: ${usage}`, EXIT.usage);
299
+ const enc = encodeURIComponent; // a copy key holds "/": encoded, it stays one path segment
300
+ if (sub === "link") {
301
+ if (!a || !b || (flags.replaces && !COPY_KEY.test(flags.replaces))) throw new CliError(`usage: ${usage}`, EXIT.usage);
302
+ const r = await api.request("PUT", `/blog/posts/${id}/links`, { channel: a, url: b, replaces: flags.replaces });
303
+ print(r, `live link saved: ${a} ${b}`);
304
+ return EXIT.ok;
305
+ }
306
+ if (sub === "unlink") {
307
+ if (!COPY_KEY.test(a ?? "")) throw new CliError(`usage: ${usage}`, EXIT.usage);
308
+ const r = await api.del(`/blog/posts/${id}/links/${enc(a)}`); print(r, `removed ${a} and its results.`);
309
+ return EXIT.ok;
310
+ }
311
+ let r;
312
+ if (!a) r = await api.get(`/blog/posts/${id}/results`);
313
+ else {
314
+ if (!["set", "remove"].includes(a) || !COPY_KEY.test(b ?? "") || !DAY.test(day ?? "")) throw new CliError(`usage: ${usage}`, EXIT.usage);
315
+ if (a === "remove") r = await api.del(`/blog/posts/${id}/results/${enc(b)}/${day}`);
316
+ else {
317
+ const nums = Object.fromEntries(METRICS.filter((m) => flags[m] !== undefined).map((m) => [m, Number(flags[m])]));
318
+ if (!Object.keys(nums).length || Object.values(nums).some((n) => !Number.isInteger(n) || n < 0)) throw new CliError("give at least one whole number: --views --clicks --reactions --comments --shares", EXIT.usage);
319
+ r = await api.request("PUT", `/blog/posts/${id}/results`, { copyKey: b, day, ...nums });
320
+ }
321
+ }
322
+ print(r, r.copies.map((x) => `${c("1", x.label)} ${x.url}\n ${c("2", x.key)}\n ${METRICS.map((m) => `${m} ${x.totals[m] ?? "–"}`).join(" · ")} ${c("2", `(${x.totals.days} days)`)}`).join("\n") || "no live copies yet. record one with `seoanything blog link`.");
323
+ return EXIT.ok;
324
+ }
325
+ if (sub === "video") {
326
+ const id = p.positionals[1];
327
+ if (!HEX_ID.test(id ?? "")) throw new CliError("usage: seoanything blog video <id> [--out script.json] [--force]", EXIT.usage);
328
+ const r = await api.get(`/blog/posts/${id}/video-brief`);
329
+ if (flags.out) {
330
+ // "wx" fails if the file exists, so an existing script is never overwritten by accident
331
+ try { fs.writeFileSync(flags.out, `${JSON.stringify(r.script, null, 2)}\n`, { flag: flags.force ? "w" : "wx" }); }
332
+ catch (e) { if (e.code === "EEXIST") throw new CliError(`${flags.out} already exists. add --force to replace it.`, EXIT.usage); throw e; }
333
+ note(`wrote ${flags.out}`);
334
+ }
335
+ const install = [r.install?.skill, r.install?.python, r.install?.ffmpeg && `${r.install.ffmpeg} (ffmpeg; on Linux or Windows use your package manager)`].filter(Boolean);
336
+ print(r, `${c("1", "install once on your computer:")}\n${install.map((l) => ` ${l}`).join("\n")}\n\n${c("1", "prompt for your agent:")}\n${r.prompt}`);
337
+ return EXIT.ok;
338
+ }
339
+ if (sub !== "new") throw new CliError("usage: seoanything blog new|list|get|publish|link|unlink|results|video", EXIT.usage);
213
340
  const topic = needArg(p.positionals.slice(1).join(" "), 'seoanything blog new "<topic>" [--keyword k] [--words 1500] [--tone friendly] [--out post.md]');
214
341
  note("1/4 brief…");
215
342
  const post = await api.post("/blog/posts", { topic, primaryKeyword: flags.keyword, targetWords: num(flags.words, undefined), tone: flags.tone });