Skip to content

Universal SEO skill for Claude Code. 26 sub-skills + 19 sub-agents covering technical SEO, E-E-A-T, schema, GEO/AEO, agent readiness (Lighthouse Agentic Browsing, WebMCP, llms.txt), backlinks, local SEO, e-commerce, international SEO, Google APIs, and PDF/Excel reporting. 9 optional extensions for live SEO data.

fix(seo-cockpit): redesign the cockpit after the first live run

Agrici Daniel9c67a3d91b9b
diff --git a/plugins/seo-cockpit/README.md b/plugins/seo-cockpit/README.md
index 44d4dbc..2474b6b 100644
--- a/plugins/seo-cockpit/README.md
+++ b/plugins/seo-cockpit/README.md
@@ -41,18 +41,27 @@ seo audit example.com: score 72/100 | weakest Schema 40, Content 55 | 17 age
**Compaction.** If the conversation is compacted mid-audit, the summary is asked to keep the output folder, which agents finished and which are running, and the findings files written.
-**Visual cockpit** (`/seo-cockpit`). A pane with six views of the data claude-seo already collects. The pane opens with focus: keys 1 to 6 pick a view, `r` loads it, `e` exports HTML, `x` closes, Esc returns to the prompt. Nothing is fetched until you press `r`, and no view calls a paid API.
+**Visual cockpit** (`/seo-cockpit`). Opens on one Overview for the site this folder is about, with no setup:
-| View | Shows | Source |
-|---|---|---|
-| 1 Search Console | Clicks and impressions per day for 90 days, 28-day KPIs with change against the 28 days before, top queries | `gsc_query.py` |
-| 2 Rankings | Average position over time, queries by position band, striking-distance queries (positions 4 to 15), drift issues over time | `gsc_query.py`, `drift_history.py` |
-| 3 Vitals | LCP, INP and CLS p75 per CrUX period against Google's good and poor thresholds | `crux_history.py` |
-| 4 Audit | Health score, category scores weakest first, critical and high findings, quick wins | newest `*-audit/audit-data.json` |
-| 5 Maps | Geo-grid heatmap, share of local voice, average rank | newest `*-maps/geo-grid-*.json` (saved by `/seo maps grid`) |
-| 6 Spend | DataForSEO spend per day for 30 days, today by endpoint | `dataforseo_costs.py` |
-
-Charts are drawn with block characters in the terminal and as SVG on the desktop app. Every view names its source and when it was fetched, and the last result of each view is kept for the next session.
+```
+claude-seo.md from this folder
+1: ● Audit 85/100 · weakest Schema 76
+2: ● Vitals good · LCP 703ms · INP 48ms · CLS 0.00
+3: ○ Search no Search Console access
+4: ○ Rankings no Search Console access
+5: ○ Maps no grid yet (/seo maps grid)
+6: ● Spend today $0.00 · 30 days $0.18
+r: Refresh e: Export
+```
+
+- **The site** comes from `/config` if you set one, else from the newest `<domain>-audit/` folder here. With neither, the pane asks for it in place and remembers it for this folder.
+- **Everything loads on open**, from free sources only (the audit and grid files, the cost ledger, and Search Console and CrUX through claude-seo's own Google setup). The last result shows at once and is replaced when the fresh one arrives.
+- **Missing data stays visible** as a dim line saying what to do, instead of an error screen.
+- **A row opens its detail** (Enter, a click, or its number): charts and tables for that source, `b` to go back.
+- **Keys** work while the pane has focus; otherwise the footer says `ctrl+x tab`. `r` refreshes everything, `e` exports HTML. Esc or Claude Code's own close mark closes the pane, and `/seo-cockpit` again toggles it.
+- **A status line** under the prompt keeps the summary in view: `SEO · claude-seo.md · audit 85/100 · CWV good`.
+
+Charts are drawn with block characters in the terminal and as SVG on the desktop app. Every view names its source and when it was fetched.
**HTML dashboard.** `e` in the pane, or `/seo-cockpit export`, writes one self-contained page (`seo-cockpit-<time>.html` in the working folder) with every view as SVG charts and tables, readable in light and dark. Where no pane can be drawn (the VS Code chat panel), `/seo-cockpit` writes this page instead and says where it is.
diff --git a/plugins/seo-cockpit/hooks/lib/overview.ts b/plugins/seo-cockpit/hooks/lib/overview.ts
new file mode 100644
index 0000000..c8a7a86
--- /dev/null
+++ b/plugins/seo-cockpit/hooks/lib/overview.ts
@@ -0,0 +1,145 @@
+/**
+ * The cockpit's Overview: which site it is about, and one line per source.
+ * Pure. Built from the tab models, so the Overview and the detail views never
+ * disagree.
+ */
+
+import type { TabId, TabModel } from './tabs'
+
+/** The Overview's rows, in order of what a person checks first. */
+export const ROWS: ReadonlyArray<{ id: TabId; label: string; key: string }> = [
+ { id: 'audit', label: 'Audit', key: '1' },
+ { id: 'vitals', label: 'Vitals', key: '2' },
+ { id: 'gsc', label: 'Search', key: '3' },
+ { id: 'rankings', label: 'Rankings', key: '4' },
+ { id: 'maps', label: 'Maps', key: '5' },
+ { id: 'spend', label: 'Spend', key: '6' },
+]
+
+export type RowState = 'loading' | 'ok' | 'missing' | 'error'
+
+export type Row = { id: TabId; label: string; key: string; state: RowState; line: string }
+
+/** The host of a URL, `sc-domain:` property or bare domain; null when there is none. */
+export function hostOf(value: string): string | null {
+ const text = value.trim().replace(/^sc-domain:/i, '')
+
+ if (text === '') {
+ return null
+ }
+
+ try {
+ const host = new URL(/^https?:\/\//i.test(text) ? text : `https://${text}`).hostname.toLowerCase()
+
+ return host.includes('.') ? host.replace(/^www\./, '') : null
+ } catch {
+ return null
+ }
+}
+
+/** The site an audit folder is about: `meta.site` in its audit-data.json, else the folder name. */
+export function siteOfAudit(folder: string, data: unknown): string | null {
+ const meta = (data as { meta?: { site?: unknown } } | null)?.meta
+ const fromData = typeof meta?.site === 'string' ? hostOf(meta.site) : null
+
+ return fromData ?? hostOf(folder.replace(/-audit$/, ''))
+}
+
+/** The target in order: the person's setting, what they typed in the pane, then what the folder shows. */
+export function chooseTarget(setting: string, typed: string | null, inferred: string | null): string | null {
+ return hostOf(setting) ?? (typed === null ? null : hostOf(typed)) ?? inferred
+}
+
+const kpi = (model: TabModel, label: string): string | undefined => model.kpis.find(k => k.label === label)?.value
+
+const short = (text: string, max = 60): string => (text.length <= max ? text : `${text.slice(0, max - 1)}…`)
+
+/** Turns a script's error into a short reason a person can act on. */
+function reasonOf(id: TabId, error: string): string {
+ if (/permission denied/i.test(error)) {
+ return 'no Search Console access'
+ }
+
+ if (/not set up|runtime is not ready/i.test(error)) {
+ return 'claude-seo runtime not set up: run /seo setup'
+ }
+
+ if (/credential|api key|google access|oauth/i.test(error)) {
+ return 'Google not connected: run /seo google setup'
+ }
+
+ if (/no saved geo-grid/i.test(error)) {
+ return 'no grid yet (/seo maps grid)'
+ }
+
+ if (/no audit found/i.test(error)) {
+ return 'no audit yet (/seo audit)'
+ }
+
+ if (/no url to measure/i.test(error)) {
+ return 'needs a site: type it above'
+ }
+
+ return short(error)
+}
+
+/** One Overview line for a source. */
+export function rowOf(id: TabId, model: TabModel | undefined, isLoading: boolean): Row {
+ const base = ROWS.find(row => row.id === id) ?? { id, label: id, key: '' }
+
+ if (model === undefined) {
+ return { ...base, state: isLoading ? 'loading' : 'missing', line: isLoading ? 'checking…' : 'not loaded' }
+ }
+
+ if (model.error !== null) {
+ const isMissing = /no audit found|no saved geo-grid|no url to measure|not connected|permission denied|not set up/i.test(model.error)
+
+ return { ...base, state: isMissing ? 'missing' : 'error', line: reasonOf(id, model.error) }
+ }
+
+ const parts: Array<string | undefined> = (() => {
+ switch (id) {
+ case 'audit': {
+ const bars = model.charts[0]
+ const weakest = bars?.kind === 'bars' ? bars.rows[0] : undefined
+
+ // "Schema / Structured Data" reads as "Schema" on one line.
+ const name = weakest?.label.split(/\s[/(]/)[0]
+
+ return [kpi(model, 'Health score'), weakest === undefined ? undefined : `weakest ${name} ${weakest.value}`]
+ }
+ case 'vitals': {
+ // The verdict first, so a narrow pane keeps it: "good · LCP 703ms · INP 48ms · CLS 0.00".
+ const values = model.kpis.map(k => `${k.label.replace(' p75', '')} ${k.value.replace(/ (good|needs work|poor)$/, '').replace(' ms', 'ms')}`)
+ const verdict = model.kpis.some(k => / poor$/.test(k.value)) ? 'poor' : model.kpis.some(k => / needs work$/.test(k.value)) ? 'needs work' : 'good'
+
+ return [verdict, ...values]
+ }
+ case 'gsc':
+ return [`clicks ${kpi(model, 'Clicks, 28 days') ?? '?'}`, `impr. ${kpi(model, 'Impressions, 28 days') ?? '?'}`]
+ case 'rankings':
+ return [`avg pos ${kpi(model, 'Avg position, now') ?? '?'}`, `was ${kpi(model, '90 days ago') ?? '?'}`, `top 3: ${kpi(model, 'Queries in top 3') ?? '0'}`]
+ case 'maps':
+ return [`SoLV ${kpi(model, 'Share of local voice') ?? '?'}`, `${kpi(model, 'Points in top 3') ?? '?'} in top 3`]
+ case 'spend':
+ return [`today ${(kpi(model, 'Today') ?? '?').split(' of ')[0]}`, `30 days ${kpi(model, '30 days') ?? '?'}`]
+ }
+ })()
+
+ return { ...base, state: 'ok', line: parts.filter((p): p is string => p !== undefined).join(' · ') }
+}
+
+/** The one-line status under the prompt, from what loaded; undefined when nothing did. */
+export function statusLine(host: string | null, rows: readonly Row[]): string | undefined {
+ const audit = rows.find(r => r.id === 'audit' && r.state === 'ok')
+ const vitals = rows.find(r => r.id === 'vitals' && r.state === 'ok')
+
+ if (host === null || (audit === undefined && vitals === undefined)) {
+ return undefined
+ }
+
+ const score = audit?.line.split(' · ')[0]
+ const cwv = vitals === undefined ? undefined : /^(poor|needs work)/.test(vitals.line) ? 'CWV needs work' : 'CWV good'
+
+ return ['SEO', host, score === undefined ? undefined : `audit ${score}`, cwv].filter(Boolean).join(' · ')
+}
diff --git a/plugins/seo-cockpit/hooks/register.ts b/plugins/seo-cockpit/hooks/register.ts
index 9c1a752..21cd2ce 100644
--- a/plugins/seo-cockpit/hooks/register.ts
+++ b/plugins/seo-cockpit/hooks/register.ts
@@ -5,6 +5,7 @@ import { COLORS, htmlPage } from './lib/charts'
import { doctorText, spendText } from './lib/format'
import { classify, type PaidCall } from './lib/paid'
import { candidatesOf, joinPath, latestVersion, MARKER } from './lib/root'
+import { chooseTarget, hostOf, rowOf, ROWS, siteOfAudit, statusLine } from './lib/overview'
import { auditModel, emptyModel, gscModel, mapsModel, rankingsModel, spendModel, TABS, vitalsModel, type TabId, type TabModel } from './lib/tabs'
import { combine, isUnpriced, parseCheck, usd, type Verdict } from './lib/verdict'
import { paneView, type Kit, type PaneState } from './views/pane'
@@ -30,17 +31,13 @@ type Ctx = {
/** Search Console property and the URL for Core Web Vitals, from /config. */
site: string
pageUrl: string
- pane: PaneState & { isOpen: boolean; models: Partial<Record<TabId, TabModel>> }
+ pane: PaneState & { isOpen: boolean }
+ /** What the person typed in the pane as the site, per working folder. */
+ typed: string | null
}
const PANE_ID = 'seo-cockpit'
-/** `sc-domain:example.com` or `https://example.com/` as a URL CrUX can read. */
-function urlOfSite(site: string): string {
- const domain = /^sc-domain:(.+)$/.exec(site.trim())?.[1]
-
- return domain !== undefined ? `https://${domain}` : site.trim()
-}
const stamp = (): string => new Date().toISOString().slice(0, 16).replace('T', ' ')
@@ -349,7 +346,36 @@ async function readJson($: EngineInterface, path: string): Promise<unknown> {
}
}
-/** Builds one tab's model from claude-seo's own scripts and files. Free: no paid API is called. */
+/** The site the cockpit is about: /config, then what was typed in the pane, then what this folder shows. */
+async function resolveHost($: EngineInterface, ctx: Ctx): Promise<void> {
+ const cwd = await $.session.cwd().catch(() => '')
+
+ if (ctx.typed === null) {
+ const saved = await $.store.get(`target:${cwd}`).catch(() => undefined)
+
+ ctx.typed = typeof saved === 'string' ? saved : null
+ }
+
+ let inferred: string | null = ctx.audit?.domain ?? null
+
+ if (inferred === null) {
+ const path = await newestFile($, '-audit', name => name === 'audit-data.json')
+
+ if (path !== null) {
+ const folder = path.split(/[/\\]/).at(-2) ?? ''
+
+ inferred = siteOfAudit(folder, await readJson($, path))
+ }
+ }
+
+ const setting = ctx.pageUrl || ctx.site
+ const host = chooseTarget(setting, ctx.typed, inferred)
+
+ ctx.pane.host = host
+ ctx.pane.hostSource = host === null ? null : hostOf(setting) !== null ? 'setting' : ctx.typed !== null && hostOf(ctx.typed) !== null ? 'typed' : 'folder'
+}
+
+/** Builds one source's model from claude-seo's own scripts and files. Free: no paid API is called. */
async function buildTab($: EngineInterface, ctx: Ctx, tab: TabId): Promise<TabModel> {
const at = stamp()
const label = TABS.find(t => t.id === tab)?.label ?? tab
@@ -359,10 +385,18 @@ async function buildTab($: EngineInterface, ctx: Ctx, tab: TabId): Promise<TabMo
return emptyModel(label, 'claude-seo', at, 'claude-seo was not found. Set "claude-seo folder" in /config.')
}
- const property = ctx.site.trim()
+ const host = ctx.pane.host
+ // An explicit property wins; otherwise the site's domain property, the usual Search Console setup.
+ const property = ctx.site.trim() || (host === null ? '' : `sc-domain:${host}`)
const propertyArgs = property === '' ? [] : ['--property', property]
+ const url = ctx.pageUrl || (host === null ? '' : `https://${host}`)
if (tab === 'gsc' || tab === 'rankings') {
+ // With no site, claude-seo would fall back to its own default property, which may be another site.
+ if (property === '') {
+ return emptyModel(label, 'gsc_query.py', at, 'No URL to measure.')
+ }
+
const [byDate, byQuery] = await Promise.all([
runtimeJson($, ctx, seoRoot, 'gsc_query.py', ['query', '--dimensions', 'date', '--days', '90', '--limit', '1000', '--json', ...propertyArgs]),
runtimeJson($, ctx, seoRoot, 'gsc_query.py', ['query', '--dimensions', 'query', '--days', '28', '--limit', tab === 'gsc' ? '10' : '200', '--json', ...propertyArgs]),
@@ -376,22 +410,19 @@ async function buildTab($: EngineInterface, ctx: Ctx, tab: TabId): Promise<TabMo
return gscModel(byDate.data, byQuery.data, property, at)
}
- const target = ctx.pageUrl || urlOfSite(property)
- const drift = target === '' ? { data: null } : await runtimeJson($, ctx, seoRoot, 'drift_history.py', [target, '--limit', '20'])
+ const drift = url === '' ? { data: null } : await runtimeJson($, ctx, seoRoot, 'drift_history.py', [url, '--limit', '20'])
return rankingsModel(byDate.data, byQuery.data, drift.data, property, at)
}
if (tab === 'vitals') {
- const target = ctx.pageUrl || urlOfSite(property) || (ctx.audit === null ? '' : `https://${ctx.audit.domain}`)
-
- if (target === '') {
- return emptyModel(label, 'crux_history.py', at, 'No URL to measure. Set "Search Console property" or "Page for Core Web Vitals" in /config.')
+ if (url === '') {
+ return emptyModel(label, 'crux_history.py', at, 'No URL to measure.')
}
- const crux = await runtimeJson($, ctx, seoRoot, 'crux_history.py', [target, '--json'])
+ const crux = await runtimeJson($, ctx, seoRoot, 'crux_history.py', [url, '--json'])
- return crux.error !== null ? emptyModel(label, 'crux_history.py', at, crux.error) : vitalsModel(crux.data, target, at)
+ return crux.error !== null ? emptyModel(label, 'crux_history.py', at, crux.error) : vitalsModel(crux.data, url, at)
}
if (tab === 'audit') {
@@ -415,42 +446,65 @@ async function buildTab($: EngineInterface, ctx: Ctx, tab: TabId): Promise<TabMo
}
}
-/** Loads a tab into the pane and the cache, redrawing as it goes. */
-async function loadTab($: EngineInterface, ctx: Ctx, tab: TabId): Promise<void> {
- ctx.pane.isLoading = true
+/** Loads one source, cache first: the last result shows at once, the fresh one replaces it. */
+async function loadSource($: EngineInterface, ctx: Ctx, tab: TabId): Promise<void> {
+ const key = await cacheKey($, ctx, tab).catch(() => null)
+
+ if (ctx.pane.models[tab] === undefined && key !== null) {
+ const cached = await $.store.get(key).catch(() => undefined)
+
+ if (isModel(cached)) {
+ ctx.pane.models[tab] = cached
+ }
+ }
+
+ ctx.pane.loading = new Set([...ctx.pane.loading, tab])
$.ui.invalidate('ui.render')
try {
const model = await buildTab($, ctx, tab)
ctx.pane.models[tab] = model
- await $.store.set(await cacheKey($, ctx, tab), model).catch(() => undefined)
+
+ if (key !== null) {
+ await $.store.set(key, model).catch(() => undefined)
+ }
} finally {
- ctx.pane.isLoading = false
- ctx.pane.model = ctx.pane.models[ctx.pane.tab] ?? null
+ ctx.pane.loading = new Set([...ctx.pane.loading].filter(t => t !== tab))
$.ui.invalidate('ui.render')
}
}
-/** Shows a tab: its last result (this session or the cache) at once; nothing is fetched until asked. */
-async function pickTab($: EngineInterface, ctx: Ctx, tab: TabId): Promise<void> {
- ctx.pane.tab = tab
+/** Loads every source in the background (all free), then pins the one-line summary under the prompt. */
+async function loadAll($: EngineInterface, ctx: Ctx): Promise<void> {
+ // Every row says "checking" from the first frame, not "not loaded".
+ ctx.pane.loading = new Set(ROWS.map(row => row.id))
+ $.ui.invalidate('ui.render')
+ await resolveHost($, ctx)
+ await Promise.allSettled(ROWS.map(row => loadSource($, ctx, row.id)))
- if (ctx.pane.models[tab] === undefined) {
- const cached = await $.store.get(await cacheKey($, ctx, tab)).catch(() => undefined)
+ const rows = ROWS.map(row => rowOf(row.id, ctx.pane.models[row.id], false))
- if (isModel(cached)) {
- ctx.pane.models[tab] = cached
- }
+ $.ui.status(statusLine(ctx.pane.host, rows))
+}
+
+/** The person typed the site in the pane: remember it for this folder and load again. */
+async function setTarget($: EngineInterface, ctx: Ctx, value: string): Promise<void> {
+ if (hostOf(value) === null) {
+ return
}
- ctx.pane.model = ctx.pane.models[tab] ?? null
- $.ui.invalidate('ui.render')
+ ctx.typed = value.trim()
+ ctx.pane.models = {}
+ await $.store.set(`target:${await $.session.cwd()}`, ctx.typed).catch(() => undefined)
+ await loadAll($, ctx)
}
-/** Writes every loaded tab into one self-contained HTML page in the working folder; returns its path. */
-async function exportHtml($: EngineInterface, ctx: Ctx, loadAll: boolean): Promise<string> {
- if (loadAll) {
+/** Writes every loaded source into one self-contained HTML page in the working folder; returns its path. */
+async function exportHtml($: EngineInterface, ctx: Ctx, loadAllFirst: boolean): Promise<string> {
+ if (loadAllFirst) {
+ await resolveHost($, ctx)
+
for (const tab of TABS) {
ctx.pane.models[tab.id] = await buildTab($, ctx, tab.id)
}
@@ -464,7 +518,7 @@ async function exportHtml($: EngineInterface, ctx: Ctx, loadAll: boolean): Promi
const cwd = await $.session.cwd()
const path = joinPath(cwd, `seo-cockpit-${new Date().toISOString().slice(0, 19).replace(/[:T]/g, '-')}.html`)
- await $.fs.write(path, htmlPage('SEO Cockpit', `Generated ${stamp()} by seo-cockpit from claude-seo data`, sections))
+ await $.fs.write(path, htmlPage(`SEO Cockpit${ctx.pane.host === null ? '' : `: ${ctx.pane.host}`}`, `Generated ${stamp()} by seo-cockpit from claude-seo data`, sections))
ctx.pane.exported = path
$.ui.invalidate('ui.render')
@@ -472,26 +526,36 @@ async function exportHtml($: EngineInterface, ctx: Ctx, loadAll: boolean): Promi
}
async function cockpitCommand($: EngineInterface, ctx: Ctx, args: string): Promise<{ text: string }> {
+ // The engine already names the plugin above a command's answer; the text is the outcome only.
try {
if (args.trim().toLowerCase() === 'export') {
- return { text: `seo-cockpit: dashboard written to ${await exportHtml($, ctx, true)}` }
+ return { text: `Dashboard written to ${await exportHtml($, ctx, true)}` }
+ }
+
+ // A second /seo-cockpit closes it, as the official modernization pane does.
+ if (ctx.pane.isOpen) {
+ await $.ui.close({ id: PANE_ID }).catch(() => undefined)
+ ctx.pane.isOpen = false
+
+ return { text: 'Cockpit closed.' }
}
- await pickTab($, ctx, ctx.pane.tab)
+ await resolveHost($, ctx)
- // Focus, so the pane's keys work at once; Esc gives focus back to the prompt.
- const opened = await $.ui.open({ id: PANE_ID, title: 'SEO Cockpit', focus: true, closeOnEscape: true })
+ const opened = await $.ui.open({ id: PANE_ID, title: 'SEO Cockpit', focus: true, rows: 14 })
if (opened.isPlaced) {
ctx.pane.isOpen = true
+ ctx.pane.view = 'overview'
+ void loadAll($, ctx).catch(() => undefined)
- return { text: 'seo-cockpit: pane open. Keys 1 to 6 pick a view, r loads it, e exports HTML, x closes, Esc returns to the prompt.' }
+ return { text: ctx.pane.host === null ? 'Cockpit open. Type the site in the pane to load its data.' : `Cockpit open for ${ctx.pane.host}.` }
}
- // No pane here (the VS Code chat panel, a narrow terminal): the HTML page is the cockpit.
- return { text: `seo-cockpit: no pane on this screen (${opened.reason}). Dashboard written to ${await exportHtml($, ctx, true)}` }
+ // No pane here (the VS Code chat panel): the HTML page is the cockpit.
+ return { text: `No pane on this screen (${opened.reason}). Dashboard written to ${await exportHtml($, ctx, true)}` }
} catch (error) {
- return { text: `seo-cockpit: ${error instanceof Error ? error.message : String(error)}` }
+ return { text: `The cockpit could not open: ${error instanceof Error ? error.message : String(error)}` }
}
}
@@ -507,7 +571,7 @@ async function spendCommand($: EngineInterface, ctx: Ctx): Promise<{ text: strin
const seoRoot = await findRoot($, ctx)
if (seoRoot === null) {
- return { text: 'seo-cockpit: claude-seo was not found. Set "claude-seo folder" in /config.' }
+ return { text: 'claude-seo was not found. Set "claude-seo folder" in /config.' }
}
try {
@@ -521,12 +585,12 @@ async function spendCommand($: EngineInterface, ctx: Ctx): Promise<{ text: strin
// A ledger error prints its reason as JSON on stdout, not on stderr.
const reason = /"message"\s*:\s*"([^"]*)"/.exec(failed.stdout)?.[1] || failed.stderr.trim().split('\n').at(-1) || 'no detail'
- return { text: `seo-cockpit: the ledger could not be read (${reason}).` }
+ return { text: `The ledger could not be read (${reason}).` }
}
return { text: spendText(JSON.parse(today.stdout), JSON.parse(summary.stdout)) }
} catch (error) {
- return { text: `seo-cockpit: the ledger could not be read (${error instanceof Error ? error.message : String(error)}). Is "${ctx.python}" on PATH? Set "Python command" in /config.` }
+ return { text: `The ledger could not be read (${error instanceof Error ? error.message : String(error)}). Is "${ctx.python}" on PATH? Set "Python command" in /config.` }
}
}
@@ -534,7 +598,7 @@ async function doctorCommand($: EngineInterface, ctx: Ctx): Promise<{ text: stri
const seoRoot = await findRoot($, ctx)
if (seoRoot === null) {
- return { text: 'seo-cockpit: claude-seo was not found next to this plugin or in the plugin cache. Set "claude-seo folder" in /config.' }
+ return { text: 'claude-seo was not found next to this plugin or in the plugin cache. Set "claude-seo folder" in /config.' }
}
try {
@@ -543,7 +607,7 @@ async function doctorCommand($: EngineInterface, ctx: Ctx): Promise<{ text: stri
return { text: `${doctorText(JSON.parse(stdout), seoRoot)}\n guard ${ctx.isGuardOn ? 'on' : 'off'} (Python: ${ctx.python})` }
} catch (error) {
- return { text: `seo-cockpit: doctor failed (${error instanceof Error ? error.message : String(error)}). Is "${ctx.python}" on PATH?` }
+ return { text: `Doctor failed (${error instanceof Error ? error.message : String(error)}). Is "${ctx.python}" on PATH?` }
}
}
@@ -570,7 +634,8 @@ export function register(on: On, options: PluginOptions) {
stopTicker: null,
site: typeof options.site === 'string' ? options.site : '',
pageUrl: typeof options.pageUrl === 'string' ? options.pageUrl.trim() : '',
- pane: { tab: 'gsc', model: null, isLoading: false, exported: null, isOpen: false, models: {} },
+ pane: { view: 'overview', models: {}, loading: new Set(), host: null, hostSource: null, exported: null, isOpen: false },
+ typed: null,
}
// ------------------------------------------------------------ spend guard
@@ -768,17 +833,26 @@ export function register(on: On, options: PluginOptions) {
Text: table.Text,
Button: table.Button,
...('Markdown' in table && { Markdown: table.Markdown }),
+ // An Input exists on every surface but mobile.
+ ...(e.surface !== 'mobile' && 'Input' in table && { Input: table.Input }),
// Every table is completed with every element name, so `'Svg' in table` holds on the terminal too, where an Svg draws nothing.
...(e.surface !== 'terminal' && 'Svg' in table && { Svg: table.Svg }),
}
ctx.pane.isOpen = true
- return paneView(kit, ctx.pane, Math.max(30, Math.floor(e.props.bodyColumns) - 2), {
- pick: tab => void pickTab($, ctx, tab).catch(() => undefined),
- refresh: () => void loadTab($, ctx, ctx.pane.tab).catch(() => undefined),
+ return paneView(kit, ctx.pane, Math.max(24, Math.floor(e.props.bodyColumns) - 1), e.props.isFocused, {
+ open: tab => {
+ ctx.pane.view = tab
+ $.ui.invalidate('ui.render')
+ },
+ back: () => {
+ ctx.pane.view = 'overview'
+ $.ui.invalidate('ui.render')
+ },
+ refresh: () => void loadAll($, ctx).catch(() => undefined),
exportHtml: () => void exportHtml($, ctx, false).catch(() => undefined),
- close: () => void $.ui.close({ id: PANE_ID }).catch(() => undefined),
+ setTarget: value => void setTarget($, ctx, value).catch(() => undefined),
})
})
diff --git a/plugins/seo-cockpit/hooks/views/pane.ts b/plugins/seo-cockpit/hooks/views/pane.ts
index 7a58485..3d97eef 100644
--- a/plugins/seo-cockpit/hooks/views/pane.ts
+++ b/plugins/seo-cockpit/hooks/views/pane.ts
@@ -2,31 +2,44 @@
* The cockpit pane as an element tree. Pure: register.ts hands in the
* surface's element constructors and the actions; nothing here touches `$`.
*
- * Every surface gets text charts (block characters and colored bars). Where
- * the surface draws `Svg` (desktop, and VS Code per the 2.1.288 typings), the
- * charts are drawn as SVG instead.
+ * One Overview (a line per source, in the order a person checks them) and one
+ * detail view per source. Sized to the pane's own width: an inline pane in a
+ * narrow terminal gets the same content in fewer columns, never a wrapped row
+ * of controls. The first row holds no controls, leaving the engine's close
+ * mark at the right edge clear.
+ *
+ * Charts are text (block characters and colored bars) everywhere; where the
+ * surface draws `Svg` (desktop, and VS Code per the 2.1.288 typings), the
+ * detail view draws them as SVG instead.
*/
import type { Elements, RenderElement } from 'claude-code'
-import { barRow, endsOf, rankColor, sparkRow, svgOf, type Chart } from '../lib/charts'
-import { TABS, type TabId, type TabModel } from '../lib/tabs'
+import { barRow, endsOf, rankColor, sparkRow, svgOf, COLORS, type Chart } from '../lib/charts'
+import { rowOf, ROWS, type Row } from '../lib/overview'
+import type { TabId, TabModel } from '../lib/tabs'
-export type Kit = Pick<Elements['terminal'], 'Box' | 'Text' | 'Button'> & Partial<Pick<Elements['terminal'], 'Markdown'>> & { Svg?: Elements['desktop']['Svg'] }
+export type Kit = Pick<Elements['terminal'], 'Box' | 'Text' | 'Button'> &
+ Partial<Pick<Elements['terminal'], 'Markdown' | 'Input'>> & { Svg?: Elements['desktop']['Svg'] }
export type PaneState = {
- tab: TabId
- model: TabModel | null
- isLoading: boolean
+ /** The Overview, or one source's detail. */
+ view: 'overview' | TabId
+ models: Partial<Record<TabId, TabModel>>
+ loading: ReadonlySet<TabId>
+ /** The site the cockpit is about, and where that came from. */
+ host: string | null
+ hostSource: 'setting' | 'typed' | 'folder' | null
/** The last HTML export, as a file path. */
exported: string | null
}
export type PaneActions = {
- pick: (tab: TabId) => void
+ open: (tab: TabId) => void
+ back: () => void
refresh: () => void
exportHtml: () => void
- close: () => void
+ setTarget: (value: string) => void
}
const cut = (text: string, width: number): string => (text.length <= width ? text : `${text.slice(0, Math.max(0, width - 1))}…`)
@@ -91,31 +104,74 @@ function tableView(kit: Kit, table: TabModel['tables'][number], columns: number)
return [kit.Text({ dimColor: true, children: [cut(line(table.head), columns)] }), ...table.rows.map(row => kit.Text({ children: [cut(line(row), columns)] }))]
}
-/** The whole pane: tab buttons, the tab's content, and the actions. */
-export function paneView(kit: Kit, state: PaneState, columns: number, actions: PaneActions): RenderElement {
+const MARK: Record<Row['state'], { mark: string; color?: string }> = {
+ ok: { mark: '●', color: COLORS.good },
+ loading: { mark: '…' },
+ missing: { mark: '○', color: COLORS.muted },
+ error: { mark: '!', color: COLORS.poor },
+}
+
+/** Keys work only while the pane holds focus; say how to get it otherwise. */
+function footer(kit: Kit, state: PaneState, isFocused: boolean, actions: PaneActions, extra: RenderElement[] = []): RenderElement {
+ const { Box, Text, Button } = kit
+ const children: RenderElement[] = isFocused
+ ? [...extra, Button({ key: 'refresh', label: 'Refresh', hotkey: 'r', plain: true, onPress: actions.refresh }), Button({ key: 'export', label: 'Export', hotkey: 'e', plain: true, onPress: actions.exportHtml })]
+ : [Text({ dimColor: true, children: ['ctrl+x tab to use the keys'] })]
+
+ if (state.exported !== null && kit.Markdown !== undefined) {
+ // A Link takes only https (or http://localhost) and refuses the whole tree otherwise; Markdown links may use file:.
+ children.push(kit.Markdown({ text: `[open export](file://${encodeURI(state.exported)})` }))
+ }
+
+ return Box({ flexDirection: 'row', columnGap: 2, marginTop: 1, children })
+}
+
+/** The Overview: which site, then one line per source; missing data stays visible with its fix. */
+export function overviewView(kit: Kit, state: PaneState, columns: number, isFocused: boolean, actions: PaneActions): RenderElement {
const { Box, Text, Button } = kit
- const tabs = Box({
- flexDirection: 'row',
- columnGap: 1,
- // A plain button with a hotkey draws as "1: label", so the label carries no key of its own.
- children: TABS.map(tab => Button({ key: `tab-${tab.id}`, label: `${tab.id === state.tab ? '▸ ' : ''}${tab.label}`, hotkey: tab.key, plain: true, onPress: () => actions.pick(tab.id) })),
- })
- const body: RenderElement[] = []
- const model = state.model
-
- if (state.isLoading) {
- body.push(Text({ dimColor: true, children: ['Loading from claude-seo...'] }))
- } else if (model === null) {
- body.push(Text({ dimColor: true, children: ['Press r to load this view. Nothing is fetched until you ask.'] }))
+ const where = { setting: 'from /config', typed: 'typed here', folder: 'from this folder', none: '' }[state.hostSource ?? 'none']
+ const children: RenderElement[] = [
+ // Row 1 carries no controls: the engine draws its close mark at the right edge.
+ Text({ children: [Text({ bold: true, children: [cut(state.host ?? 'No site yet', Math.max(10, columns - 24))] }), Text({ dimColor: true, children: [where === '' ? '' : ` ${where}`] })] }),
+ ]
+
+ if (state.host === null && kit.Input !== undefined) {
+ children.push(kit.Input({ key: 'target', label: 'Site', placeholder: 'example.com', submitLabel: 'go', autoFocus: true, onSubmit: value => actions.setTarget(value) }))
+ }
+
+ const labelWidth = Math.max(...ROWS.map(row => row.label.length))
+
+ for (const row of ROWS.map(r => rowOf(r.id, state.models[r.id], state.loading.has(r.id)))) {
+ const { mark } = MARK[row.state]
+ // The hotkey draws as "1: " before a plain label; keep the whole line inside the pane.
+ const label = cut(`${mark} ${row.label.padEnd(labelWidth)} ${row.line}`, Math.max(12, columns - 4))
+
+ children.push(Button({ key: `row-${row.id}`, label, hotkey: row.key, plain: true, onPress: () => actions.open(row.id) }))
+ }
+
+ children.push(footer(kit, state, isFocused, actions))
+
+ return Box({ flexDirection: 'column', children })
+}
+
+/** One source in detail: its numbers, charts and tables, with a way back. */
+export function detailView(kit: Kit, state: PaneState, tab: TabId, columns: number, isFocused: boolean, actions: PaneActions): RenderElement {
+ const { Box, Text, Button } = kit
+ const model = state.models[tab]
+ const label = ROWS.find(row => row.id === tab)?.label ?? tab
+ const body: RenderElement[] = [Text({ children: [Text({ bold: true, children: [model?.heading ?? label] })] })]
+
+ if (model === undefined) {
+ body.push(Text({ dimColor: true, children: [state.loading.has(tab) ? 'checking…' : 'not loaded yet: press r'] }))
} else {
- body.push(Text({ bold: true, children: [model.heading] }), Text({ dimColor: true, children: [cut(`${model.source} · fetched ${model.fetchedAt}`, columns * 2)] }))
+ body.push(Text({ dimColor: true, children: [cut(`${model.source} · ${model.fetchedAt}`, columns)] }))
if (model.error !== null) {
- body.push(Text({ color: '#dc2626', children: [cut(model.error, columns * 3)] }))
+ body.push(Text({ color: COLORS.poor, children: [cut(model.error, columns * 3)] }))
}
- if (model.kpis.length > 0) {
- body.push(Box({ flexDirection: 'row', columnGap: 3, children: model.kpis.map(kpi => Text({ children: [`${kpi.label}: `, Text({ bold: true, children: [kpi.value] })] })) }))
+ for (const kpi of model.kpis) {
+ body.push(Text({ children: [`${kpi.label}: `, Text({ bold: true, children: [kpi.value] })] }))
}
for (const chart of model.charts) {
@@ -129,16 +185,12 @@ export function paneView(kit: Kit, state: PaneState, columns: number, actions: P
body.push(...model.notes.map(note => Text({ dimColor: true, children: [cut(note, columns * 3)] })))
}
- const footer: RenderElement[] = [
- Button({ key: 'refresh', label: 'Refresh', hotkey: 'r', plain: true, onPress: actions.refresh }),
- Button({ key: 'export', label: 'Export HTML', hotkey: 'e', plain: true, onPress: actions.exportHtml }),
- Button({ key: 'close', label: 'Close', hotkey: 'x', plain: true, onPress: actions.close }),
- ]
+ const back = Button({ key: 'back', label: 'Back', hotkey: 'b', plain: true, onPress: actions.back })
- if (state.exported !== null) {
- // A Link takes only https (or http://localhost) and refuses the whole tree otherwise; Markdown links may use file:.
- footer.push(kit.Markdown !== undefined ? kit.Markdown({ text: `[open export](file://${encodeURI(state.exported)})` }) : Text({ dimColor: true, children: [state.exported] }))
- }
+ return Box({ flexDirection: 'column', children: [...body, footer(kit, state, isFocused, actions, isFocused ? [back] : [])] })
+}
- return Box({ flexDirection: 'column', rowGap: 0, children: [tabs, Box({ flexDirection: 'column', marginTop: 1, children: body }), Box({ flexDirection: 'row', columnGap: 2, marginTop: 1, children: footer })] })
+/** The whole pane for its current view. */
+export function paneView(kit: Kit, state: PaneState, columns: number, isFocused: boolean, actions: PaneActions): RenderElement {
+ return state.view === 'overview' ? overviewView(kit, state, columns, isFocused, actions) : detailView(kit, state, state.view, columns, isFocused, actions)
}
diff --git a/plugins/seo-cockpit/tests/cockpit.test.ts b/plugins/seo-cockpit/tests/cockpit.test.ts
index 60c4b95..992b7bb 100644
--- a/plugins/seo-cockpit/tests/cockpit.test.ts
+++ b/plugins/seo-cockpit/tests/cockpit.test.ts
@@ -2,29 +2,80 @@ import { describe, expect, mock, test } from 'claude-code/testing'
import { command, worldOf } from './fixtures/world'
-const PANE = { plugin: 'seo-cockpit', component: 'Pane' as const, requestId: 'seo-cockpit', viewport: { columns: 160, rows: 50 }, props: { title: 'SEO Cockpit', isFocused: true, bodyColumns: 110, placement: 'dock' as const, scroll: { offset: 0, bodyRows: 40 }, view: {} } }
+// As the owner's terminal drew it: an inline pane about 53 cells wide.
+const NARROW = { plugin: 'seo-cockpit', component: 'Pane' as const, requestId: 'seo-cockpit', viewport: { columns: 55, rows: 40 }, props: { title: 'SEO Cockpit', isFocused: true, bodyColumns: 53, placement: 'inline' as const, scroll: { offset: 0, bodyRows: 12 }, view: {} } }
+const WIDE = { ...NARROW, viewport: { columns: 160, rows: 50 }, props: { ...NARROW.props, bodyColumns: 110, placement: 'dock' as const, scroll: { offset: 0, bodyRows: 40 } } }
+
+const AUDIT = JSON.stringify({ summary: { health_score: 85 }, categories: [{ name: 'Schema', score: 76, findings: [] }, { name: 'Technical SEO', score: 94, findings: [] }], meta: { site: 'https://claude-seo.md' } })
+
+/** The listing of a folder holding one audit, as ~/Desktop/seo-cockpit-preview did. */
+const LISTING = { '/work': [{ name: 'claude-seo.md-audit', kind: 'dir' as const }], '/work/claude-seo.md-audit': [{ name: 'audit-data.json', kind: 'file' as const }] }
+
+/** The rest of that folder: its files' contents, and the engine calls the pane makes. */
+function auditFolder(on: Parameters<typeof worldOf>[0]) {
+ on('session.cwd', () => ({ value: '/work' }))
+ on('fs.stat', () => ({ value: { kind: 'file', size: AUDIT.length, mtimeMs: 1, isLink: false } }) as never)
+ on('fs.read', ($, e) => (e.path.endsWith('audit-data.json') ? { value: AUDIT } : { deny: 'ENOENT' }))
+ on('store.get', () => ({ value: undefined }))
+ on('store.set', () => ({ value: undefined }))
+ on('ui.status', () => ({ value: undefined }))
+ on('ui.render', () => ({ type: 'Text', props: {}, children: ['engine'] }) as never)
+}
describe('cockpit', () => {
- test('/seo-cockpit opens the pane, which fetches nothing until asked', async ($, on) => {
- const world = worldOf(on)
+ test('/seo-cockpit opens on the Overview for the site this folder shows, with no setup', async ($, on) => {
+ worldOf(on, { listing: LISTING, scripts: { run: { exitCode: 3, stdout: '', stderr: 'Claude SEO runtime is not ready.' } } })
+ auditFolder(on)
+
const opened: string[] = []
on('ui.open', ($, e) => {
- opened.push(`${e.id}${e.focus === true ? ' focused' : ''}`)
+ opened.push(`${e.id}${e.focus === true ? ' focused' : ''}${e.closeOnEscape === true ? ' esc' : ''}`)
return { value: { isPlaced: true } } as never
})
- on('store.get', () => ({ value: undefined }))
- on('session.cwd', () => ({ value: '/work' }))
- on('ui.render', () => ({ type: 'Text', props: {}, children: ['engine'] }) as never)
+ mock.clock(on)
const result = await $.command.run(command('seo-cockpit'))
- const ui = await $.ui.mount({ ...PANE, surface: 'terminal' })
expect(opened).toEqual(['seo-cockpit focused'])
- expect(result.text).toContain('pane open')
- expect(await ui.find({ type: 'Text', text: /Press r to load/ })).toBeDefined()
- expect(world.runs).toEqual([])
+ // The engine names the plugin itself; the reply is the outcome only.
+ expect(result.text).toBe('Cockpit open for claude-seo.md.')
+
+ const ui = await $.ui.mount({ ...NARROW, surface: 'terminal' })
+
+ expect(await ui.find({ type: 'Text', text: /claude-seo\.md/ })).toBeDefined()
+ expect(await ui.find({ key: 'row-audit' })).toBeDefined()
+ expect(await ui.find({ key: 'row-vitals' })).toBeDefined()
+ })
+
+ test('a second /seo-cockpit closes it', async ($, on) => {
+ worldOf(on, { listing: LISTING })
+ auditFolder(on)
+ on('ui.open', () => ({ value: { isPlaced: true } }) as never)
+ on('ui.close', () => ({ value: undefined }))
+ mock.clock(on)
+
+ await $.command.run(command('seo-cockpit'))
+
+ expect((await $.command.run(command('seo-cockpit'))).text).toBe('Cockpit closed.')
+ })
+
+ test('with no site to infer, the pane asks for one in place', async ($, on) => {
+ worldOf(on)
+ on('session.cwd', () => ({ value: '/empty' }))
+ on('store.get', () => ({ value: undefined }))
+ on('store.set', () => ({ value: undefined }))
+ on('ui.status', () => ({ value: undefined }))
+ on('ui.open', () => ({ value: { isPlaced: true } }) as never)
+ on('ui.render', () => ({ type: 'Text', props: {}, children: ['engine'] }) as never)
+ mock.clock(on)
+
+ expect((await $.command.run(command('seo-cockpit'))).text).toContain('Type the site in the pane')
+
+ const ui = await $.ui.mount({ ...NARROW, surface: 'terminal' })
+
+ expect(await ui.find({ key: 'target' })).toBeDefined()
})
test('with no pane on screen, it writes the HTML dashboard instead', async ($, on) => {
@@ -34,6 +85,7 @@ describe('cockpit', () => {
on('ui.open', () => ({ value: { isPlaced: false, reason: 'no pane here' } }) as never)
on('session.cwd', () => ({ value: '/work' }))
+ on('store.get', () => ({ value: undefined }))
on('fs.write', ($, e) => {
written.push(e.path)
@@ -42,35 +94,49 @@ describe('cockpit', () => {
const result = await $.command.run(command('seo-cockpit'))
- expect(result.text).toContain('no pane on this screen (no pane here)')
+ expect(result.text).toContain('No pane on this screen (no pane here)')
expect(written.length).toBe(1)
expect(written[0]).toMatch(/^\/work\/seo-cockpit-.*\.html$/)
})
- test('charts are text in the terminal and SVG on the desktop', async ($, on) => {
+ test('a row opens its detail; charts are text in the terminal and SVG on the desktop', async ($, on) => {
const day = (i: number) => new Date(Date.UTC(2026, 6, 3) + i * 86_400_000).toISOString().slice(0, 10)
- const gsc = { property: 'sc-domain:a.com', error: null, rows: Array.from({ length: 60 }, (_, i) => ({ keys: [day(i)], date: day(i), query: 'q', clicks: i, impressions: 10 * i, ctr: 1, position: 5 })) }
+ const gsc = { property: 'sc-domain:claude-seo.md', error: null, rows: Array.from({ length: 60 }, (_, i) => ({ keys: [day(i)], date: day(i), query: 'q', clicks: i, impressions: 10 * i, ctr: 1, position: 5 })) }
// runtime.py run <script> ...: the fixture keys on the subcommand, `run`.
- worldOf(on, { scripts: { run: { stdout: gsc } } })
+ worldOf(on, { listing: LISTING, scripts: { run: { stdout: gsc } } })
+ auditFolder(on)
on('ui.open', () => ({ value: { isPlaced: true } }) as never)
- on('session.cwd', () => ({ value: '/work' }))
- on('store.get', () => ({ value: undefined }))
- on('store.set', () => ({ value: undefined }))
- on('ui.render', () => ({ type: 'Text', props: {}, children: ['engine'] }) as never)
mock.clock(on)
await $.command.run(command('seo-cockpit'))
- const terminal = await $.ui.mount({ ...PANE, surface: 'terminal' })
+ const terminal = await $.ui.mount({ ...WIDE, surface: 'terminal' })
await terminal.press({ key: 'refresh' })
+ await terminal.press({ key: 'row-gsc' })
expect(await terminal.find({ type: 'Text', text: /Clicks per day/ })).toBeDefined()
expect(await terminal.find({ type: 'Svg' })).toBeUndefined()
await terminal.unmount()
- const desktop = await $.ui.mount({ ...PANE, surface: 'desktop' })
+ const desktop = await $.ui.mount({ ...WIDE, surface: 'desktop' })
expect(await desktop.find({ type: 'Svg' })).toBeDefined()
+ await desktop.press({ key: 'back' })
+ expect(await desktop.find({ key: 'row-audit' })).toBeDefined()
+ })
+
+ test('unfocused, the footer says how to reach the keys instead of listing them', async ($, on) => {
+ worldOf(on, { listing: LISTING })
+ auditFolder(on)
+ on('ui.open', () => ({ value: { isPlaced: true } }) as never)
+ mock.clock(on)
+
+ await $.command.run(command('seo-cockpit'))
+
+ const ui = await $.ui.mount({ ...NARROW, surface: 'terminal', props: { ...NARROW.props, isFocused: false } })
+
+ expect(await ui.find({ type: 'Text', text: /ctrl\+x tab/ })).toBeDefined()
+ expect(await ui.find({ key: 'refresh' })).toBeUndefined()
})
})
diff --git a/plugins/seo-cockpit/tests/fixtures/world.ts b/plugins/seo-cockpit/tests/fixtures/world.ts
index 7437d30..0c5db19 100644
--- a/plugins/seo-cockpit/tests/fixtures/world.ts
+++ b/plugins/seo-cockpit/tests/fixtures/world.ts
@@ -26,6 +26,8 @@ export type Setup = {
answer?: string | null
/** Whether claude-seo is found on disk. */
hasRoot?: boolean
+ /** Folder listings by path, for tests that need files to exist; any other path is missing. */
+ listing?: Readonly<Record<string, ReadonlyArray<{ name: string; kind: 'file' | 'dir' }>>>
}
export function worldOf(on: On, setup: Setup = {}): World {
@@ -34,7 +36,11 @@ export function worldOf(on: On, setup: Setup = {}): World {
// The kit's bottom hook throws for an event no stub answers; a session start needs one.
on('session.start', () => ({ cwd: '/work' }))
on('fs.exists', ($, e) => ({ value: setup.hasRoot !== false && e.path.endsWith('scripts/dataforseo_costs.py') }))
- on('fs.list', () => ({ deny: 'ENOENT' }))
+ on('fs.list', ($, e) => {
+ const entries = setup.listing?.[e.path]
+
+ return (entries === undefined ? { deny: 'ENOENT' } : { value: entries.map(entry => ({ ...entry, size: 0 })) }) as never
+ })
on('process.run', ($, e) => {
const args = e.argv.slice(1)
diff --git a/plugins/seo-cockpit/tests/register.test.ts b/plugins/seo-cockpit/tests/register.test.ts
index 400d9f3..d54bb62 100644
--- a/plugins/seo-cockpit/tests/register.test.ts
+++ b/plugins/seo-cockpit/tests/register.test.ts
@@ -2,9 +2,11 @@ import { describe, expect, test } from 'claude-code/testing'
import { APPROVED, BLOCKED, command, NEEDS, SESSION, worldOf } from './fixtures/world'
-const SERP = { tool: 'mcp__dataforseo__serp_organic_live_advanced' as const }
-const LLM = { tool: 'mcp__dataforseo__ai_opt_llm_ment_search' as const }
-const AHREFS = { tool: 'mcp__ahrefs__site_explorer' as const }
+// MCP tool inputs are typed from the servers connected on the machine that last loaded the mod,
+// so a test naming servers that machine lacks casts its input.
+const SERP = { tool: 'mcp__dataforseo__serp_organic_live_advanced' } as never
+const LLM = { tool: 'mcp__dataforseo__ai_opt_llm_ment_search' } as never
+const AHREFS = { tool: 'mcp__ahrefs__site_explorer' } as never
describe('spend guard', () => {
test('a free tool passes untouched and runs nothing', async ($, on) => {
@@ -107,7 +109,7 @@ describe('spend guard', () => {
answer: 'Approve',
})
- const result = await $.tool.call({ tool: 'mcp__dataforseo__brand_new_endpoint' })
+ const result = await $.tool.call({ tool: 'mcp__dataforseo__brand_new_endpoint' } as never)
expect(world.asked[0]).toContain('has no listed price')
expect(world.runs).toEqual(['dataforseo_costs.py check brand_new_endpoint'])