Open source alternative to Semrush and Ahrefs
TypeScript backlink-analysisgoogle-search-console-mcpkeyword-researchmcpseoseo-agentseo-auditseo-automationseo-skillsseo-toolssite-audit
Fix small development blockers and clean up the papercut backlog (#586)
Ben Senescu41450c8c3708
diff --git a/.agents/PAPERCUTS.md b/.agents/PAPERCUTS.mdindex f9a941f7..87b12b41 100644--- a/.agents/PAPERCUTS.md+++ b/.agents/PAPERCUTS.md@@ -10,29 +10,19 @@ data, or sensitive paths.## Open-- [ ] `2026-08-20T20:36:32Z` — `codex` — The PR preview Access check treats an immediate workers.dev 404 as proof the preview is public, even though the same URL can begin returning the expected Access redirect seconds later; retry 404 responses as propagation-era errors before failing and recommending stage destruction.-- [ ] `2026-08-18T03:06:44Z` — `claude` — Changing an MCP tool's `outputSchema` while the dev server hot-reloads makes in-flight MCP sessions reject the tool's own (already billed) results — clients validate against the schema cached at connect time, surfacing as "must NOT have additional properties". Note in the MCP dev docs/skill: reconnect the MCP session after any output-schema change before re-testing live.-- [ ] `2026-08-05T20:59:09Z` — `codex` — The documented `pnpm seed:rank-tracking` command fails before opening local D1 because `scripts/seed-rank-tracking.ts` imports the provider-aware `src/db/schema` barrel and plain `tsx` cannot load the resulting `cloudflare:workers` URL. Keep the seed script on dialect-local schema imports or run it through a Workers-compatible execution path. (Workaround: seed via raw SQL with `wrangler d1 execute DB --local`.)-- [ ] `2026-08-01T16:28:36Z` — `claude` — web's pinned wrangler 4.71.0 fails `kv namespace create` with a bare "Authentication error [code: 10000]" even though the OAuth token has workers_kv write scope; [email protected] succeeds with identical auth. Fix: bump wrangler in web/package.json.-- [ ] `2026-07-20T20:08:28Z` — `claude` — In a fresh git worktree, `oxlint --type-aware` crashes with `Cannot find module '@oxlint/binding-darwin-arm64'` — the platform-specific optional dep is missing from the worktree's node_modules while tsc/prettier work fine, and plain `pnpm install` reports up-to-date without restoring it; `pnpm install --force` (~22s) fixes it. Worth making the worktree-setup hook (or a documented step) run the forced install so lint doesn't die on fresh worktrees.-- [ ] `2026-07-19T04:06:52Z` — `codex` — `pnpm --dir web build` fails with `vite: command not found` when `web/node_modules` is absent, despite the root toolchain being installed. Document or enforce the package-local install required before validating the `web/` subpackage.-- [ ] `2026-07-19T02:55:56Z` — `claude` — Adding a docs folder under `web/content/docs` whose `meta.json` lists an `[Overview](...)` link renders a duplicated, double-highlighted sidebar entry, because the folder-index strip in `web/src/lib/source.ts` (`transformPageTree.folder`) is a per-folder-name allowlist. Derive it from the meta convention (or strip the index for all folders) so new sections don't need a hidden source.ts edit.-- [ ] `2026-07-14T01:28:30Z` — `claude` — Regenerating the lockfile (adding or moving a dep) makes `pnpm install` re-run the `minimumReleaseAge` gate on transitive peers already pinned at that exact version (`mysql2`, `sql-escaper`, `@aws-sdk/credential-providers`), failing the install even though nothing about them changed. `pnpm install --config.minimumReleaseAge=0` — then confirm the lockfile diff stays version-neutral — unblocks it; worth documenting that regen step so the gate doesn't re-block already-pinned versions.-- [ ] `2026-07-10T21:28:46Z` — `codex` — `pnpm --dir badseo run typecheck` works through the root toolchain but `pnpm --dir badseo run build` can't find Vite because `badseo/node_modules` is absent. Document or enforce the package-local install before validating the `badseo/` subpackage.-- [ ] `2026-07-10T21:32:10Z` — `codex` — Formatting the `badseo/` workspace with `pnpm exec prettier` fails because Prettier is only available from the repository root. Document the root-only formatter command or expose a workspace-local formatting script.+None after the 2026-09-05 review.-## Resolved+## Deferred-Move fixed entries here, mark them checked, and append the resolving date or commit.+- `2026-08-01T16:28:36Z` — `claude` — `web/`'s locked Wrangler 4.71.0 reportedly failed `kv namespace create` with authentication error 10000 while a newer version worked. The locked version is unchanged, but the auth failure was not reverified on 2026-09-05; revisit during routine website dependency maintenance or if this command blocks current work.+- `2026-07-19T02:55:56Z` — `claude` — Docs folders with an explicit Overview link need their index removed by the allowlist in `web/src/lib/source.ts`. Both current folders using that convention are covered as of 2026-09-05; revisit when adding another such section, rather than generalizing navigation now.-## badseo harness vs `wrangler dev`: sitemap emits badseo.dev locs locally+## Resolved-`badseo/scripts/run-audit.ts` against a local `wrangler dev --port 8787` fails 4-sitemap-dependent checks (orphan page, 500, 403, duplicate-content) with-NOT CRAWLED: wrangler dev adopts the `badseo.dev` custom-domain route as the-host the worker sees, so `/sitemap.xml` emits `http://badseo.dev/...` locs that-the crawler's same-origin filter drops. Run it as-`wrangler dev --port 8787 --local-upstream "localhost:8787"` (after-`vite build`). Also: `pnpm --filter badseo audit` fails with-"Unknown option: 'recursive'" from the repo root — badseo is its own pnpm-workspace, not a root workspace member; use `npx tsx badseo/scripts/run-audit.ts`.+- [x] `2026-08-20T20:36:32Z` — `codex` — The preview Access check immediately classified a workers.dev 404 as public. Resolved 2026-09-05: 404s use the existing bounded retry loop; exhaustion fails without claiming the preview is protected or public.+- [x] `2026-08-18T03:06:44Z` — `claude` — MCP clients can reject results using cached output schemas after hot reload. Resolved 2026-09-05: `verify-local-mcp` now instructs clients to refresh tool discovery or reconnect after schema edits, before another provider call.+- [x] `2026-08-05T20:59:09Z` — `codex` — `pnpm seed:rank-tracking` failed in Node on the provider-aware schema's `cloudflare:workers` import. Resolved 2026-09-05: the script imports SQLite tables directly, matching `seed-projects.ts`.+- [x] `2026-07-19T04:06:52Z` — `codex` — Website builds require a package-local install even when root dependencies exist. Resolved 2026-09-05: `docs/LOCAL_DEVELOPMENT.md` documents the website install, dev, and validation commands.+- [x] `2026-07-10T21:28:46Z` — `codex` — BadSEO builds require a package-local install even when root typechecking works. Resolved 2026-09-05: local-development docs and `badseo/README.md` explain both dependency installs.+- [x] `2026-07-10T21:32:10Z` — `codex` — BadSEO has no package-local Prettier. Resolved 2026-09-05: its README and local-development docs give the root formatter command.+- [x] `2026-09-05T00:44:38Z` — `codex` — The older, undated BadSEO note described wrong-origin sitemap URLs under direct `wrangler dev` and a broken `pnpm --filter badseo audit` command. Resolved 2026-09-05 through documentation: use the existing Vite dev server and package audit script; the README states the expected sitemap origin and the harness usage comment now matches. Direct Wrangler behavior was not reverified or changed.diff --git a/.agents/skills/papercuts/SKILL.md b/.agents/skills/papercuts/SKILL.mdindex 3459e704..2481249f 100644--- a/.agents/skills/papercuts/SKILL.md+++ b/.agents/skills/papercuts/SKILL.md@@ -54,7 +54,8 @@ Only the former is a papercut.- [ ] `YYYY-MM-DDTHH:MM:SSZ` — `agent` — <friction, and the smallest useful fix or workaround>.```-3. Keep it to one or two sentences: what got in the way, and the likely repo-side+3. Keep it to one or two sentences: a current example (command/error or affected+ path), who it blocks or what time it wastes, and the smallest useful repo-sidefix. Lead with the friction, not with what you were doing.4. Continue the original task. Do not expand a papercut into unrelated work.@@ -65,15 +66,23 @@ PR or task identifier only when it helps future triage.Only mine a whole session or do a broad review when the user explicitly asks.-When asked to review the file:+For a review or prioritization request, inspect and recommend; do not edit the+log or implement fixes unless the user also asks for cleanup or implementation.+Carry out an authorized cleanup using the same triage:-1. Re-run the two-question test on every open entry; delete any that fail it- (environment/shell/flake noise that slipped in).+1. Re-run the two-question test on every open entry; recommend removing entries+ that fail it (environment/shell/flake noise that slipped in).2. Deduplicate and group related entries.-3. Verify each surviving papercut still reproduces.-4. Fix the smallest safe, high-leverage entries first.-5. Move fixed items to `## Resolved`, check them, and append the resolving date- or commit. Route real bugs to normal issue/fix work; route recurring+3. Check whether each surviving papercut still reproduces. Distinguish reproduced+ failures, source inspection, and historical reports you could not verify.+4. Prioritize current impact against review and maintenance cost. Prefer an+ existing command or a short documentation fix over new helpers, dependencies,+ or setup hooks. Defer hypothetical improvements until a concrete need appears.+5. For an authorized cleanup, remove noise, consolidate duplicates, and implement+ the agreed fixes. Move fixed items to `## Resolved`, check them, and append the+ resolving date or commit. Keep deferred reports separate from actionable open+ work, with a reason and a concrete trigger to revisit. Route real bugs to+ normal issue/fix work; route recurringreview-policy gaps through `maintain-greptile-rules`.Preserve useful history for genuinely-resolved papercuts; do not delete themdiff --git a/.agents/skills/verify-local-mcp/SKILL.md b/.agents/skills/verify-local-mcp/SKILL.mdindex 244f48b1..ce05f279 100644--- a/.agents/skills/verify-local-mcp/SKILL.md+++ b/.agents/skills/verify-local-mcp/SKILL.md@@ -14,6 +14,7 @@ Two layers, in order. The protocol layer proves the server and provider behave;- `.env.local` needs `AUTH_MODE=local_noauth` and `DATAFORSEO_API_KEY` (base64 of `login:password`). Never print the key.- Start `pnpm dev:agents` in the background. The server URL is branch-prefixed: `http://<branch-suffix>.open-seo.localhost:1355` (the exact URL is printed on boot; logs tee to `.logs/dev-server.log`).- With `local_noauth`, `/mcp` needs no token. Vite hot-reloads server code, so fix → re-call without restarting.+- After changing a tool's input or output schema, refresh the client's tool discovery (`tools/list`) or reconnect the MCP client before calling it again. Clients can cache validators from the previous tool list and reject valid results after the provider call has already incurred a charge.## 2. Protocol smoke (cheap, deterministic)diff --git a/.github/workflows/pr-preview.yml b/.github/workflows/pr-preview.ymlindex 2fbf6a8d..581d521b 100644--- a/.github/workflows/pr-preview.yml+++ b/.github/workflows/pr-preview.yml@@ -96,8 +96,8 @@ jobs:# Fail the job (and skip the URL comment) if the deployed preview# answers without a Cloudflare Access login redirect. A definitive app- # response (2xx/3xx, no Access redirect) fails immediately — the- # preview is public; retries are only for propagation-era errors.+ # response (2xx–4xx except 404, no Access redirect) fails immediately;+ # retries are only for propagation-era errors, including workers.dev 404s.# (Cloudflare version preview URLs sit outside this wildcard, but alchemy# uploads versions with no preview provisioned, so none are served — see# docs/PREVIEW_DEPLOYMENTS.md.)@@ -112,14 +112,14 @@ jobs:https://*.cloudflareaccess.com/cdn-cgi/access/login*)exit 0 ;;esac- if [ -n "$code" ] && [ "$code" -ge 200 ] && [ "$code" -lt 500 ]; then+ if [ -n "$code" ] && [ "$code" -ge 200 ] && [ "$code" -lt 500 ] && [ "$code" != 404 ]; thenecho "::error::$PREVIEW_URL responded (HTTP $code) WITHOUT a Cloudflare Access challenge — the preview is public; destroy the stage (pnpm destroy:preview --stage $STAGE --yes)"exit 1fiecho "attempt $attempt: not up yet (${response:-no response})"sleep 5done- echo "::error::$PREVIEW_URL is unreachable (likely workers.dev propagation) — it still sits behind the wildcard Access app; re-run this job or verify manually"+ echo "::error::Could not verify Cloudflare Access protection for $PREVIEW_URL after 8 attempts (possibly workers.dev propagation); re-run this job or verify manually before sharing the preview"exit 1- name: Destroy preview stagediff --git a/badseo/README.md b/badseo/README.mdindex e9aaff74..4cdd9853 100644--- a/badseo/README.md+++ b/badseo/README.md@@ -67,8 +67,19 @@ in the footer. The choice is stored only in the visitor's browser.## Run it locally```bash-# from the badseo/ directory-npm run dev # serves on http://localhost:8787+# from the repository root+pnpm install --frozen-lockfile # also needed by the audit harness+pnpm --dir badseo install --frozen-lockfile+pnpm --dir badseo run dev # serves on http://localhost:8787+```++Use the Vite dev server above when running the audit locally. Its sitemap URLs+should use `http://localhost:8787`, matching the origin passed to the harness.++Format BadSEO files with the repository's root Prettier installation:++```bash+pnpm exec prettier --write "badseo/**/*.{ts,tsx,json,jsonc,md}"```## Run the end-to-end audit@@ -79,8 +90,8 @@ fixture triggers exactly the issues it declares — and that the homepage,privacy policy, and support pages come back clean.```bash-# with `npm run dev` running in another terminal:-npm run audit -- http://localhost:8787+# from the repository root, with the BadSEO dev server running:+pnpm --dir badseo run audit http://localhost:8787```It prints a per-page pass/fail matrix and an issue-type coverage line, and exitsdiff --git a/badseo/scripts/run-audit.ts b/badseo/scripts/run-audit.tsindex 8e6af8bd..e336253b 100644--- a/badseo/scripts/run-audit.ts+++ b/badseo/scripts/run-audit.ts@@ -9,8 +9,9 @@* crawl localhost (the production frontier's SSRF policy blocks private hosts).* Every actual detection call below is imported straight from ../src.*- * pnpm --filter badseo audit # against http://localhost:8787- * tsx scripts/run-audit.ts http://host:port # against any origin+ * From the repository root, with the BadSEO dev server running:+ * pnpm --dir badseo run audit http://localhost:8787+ * pnpm --dir badseo run audit http://host:port*/import { crawlPage } from "../../src/server/workflows/site-audit-workflow-helpers";import {diff --git a/docs/LOCAL_DEVELOPMENT.md b/docs/LOCAL_DEVELOPMENT.mdindex b64a4e91..60a763d0 100644--- a/docs/LOCAL_DEVELOPMENT.md+++ b/docs/LOCAL_DEVELOPMENT.md@@ -49,6 +49,43 @@ pnpm dev:agentsWhen using a git worktree, [portless](https://github.com/vercel-labs/portless) prefixes the branch name, for example `http://feature-name.open-seo.localhost:1355`.+## Website and BadSEO++The marketing website (`web/`) and audit test site (`badseo/`) are separate+pnpm projects with their own lockfiles. The root install does not install their+dependencies. From the repository root, install the project you plan to work on:++```sh+# Marketing website+pnpm --dir web install --frozen-lockfile+pnpm --dir web run dev+# Validate website changes+pnpm --dir web run types:check+pnpm --dir web run build++# Audit test site (keep the root dependencies installed for its audit harness)+pnpm --dir badseo install --frozen-lockfile+pnpm --dir badseo run dev+# Validate BadSEO changes+pnpm --dir badseo run build+```++Run BadSEO's audit harness from another terminal while its dev server is running:++```sh+pnpm --dir badseo run audit http://localhost:8787+```++Use the root formatter for BadSEO; the website has its own formatter:++```sh+# From the repository root+pnpm exec prettier --write "badseo/**/*.{ts,tsx,json,jsonc,md}"+pnpm --dir web run format:write+```++See [BadSEO's README](../badseo/README.md) for fixture and audit instructions.+## Database CommandsGenerate migration:diff --git a/scripts/seed-rank-tracking.ts b/scripts/seed-rank-tracking.tsindex 11cd1cad..d319198b 100644--- a/scripts/seed-rank-tracking.ts+++ b/scripts/seed-rank-tracking.ts@@ -28,9 +28,13 @@ import process from "node:process";import { getPlatformProxy } from "wrangler";import { drizzle } from "drizzle-orm/d1";import { and, eq } from "drizzle-orm";-import * as schema from "../src/db/schema";+// This local D1 script runs in Node; the provider-aware barrel requires Workers.+import * as appSchema from "../src/db/app.schema";+import { organization, user } from "../src/db/better-auth-schema";import { parseArgs } from "./cli-utils";+const schema = { ...appSchema, organization, user };+const LOCAL_ADMIN_USER_ID = "local-admin";const LOCAL_ADMIN_EMAIL = "admin@localhost";const LOCAL_ORG_ID = `delegated-${LOCAL_ADMIN_USER_ID}`;diff --git a/src/lib/pr-preview-access.test.ts b/src/lib/pr-preview-access.test.tsnew file mode 100644index 00000000..ade2770a--- /dev/null+++ b/src/lib/pr-preview-access.test.ts@@ -0,0 +1,79 @@+import { mkdtempSync, readFileSync, rmSync, writeFileSync } from "node:fs";+import { tmpdir } from "node:os";+import { join } from "node:path";+import { spawnSync } from "node:child_process";+import { describe, expect, it } from "vitest";+import { parse } from "yaml";+import { z } from "zod";++const workflow = z+ .object({+ jobs: z.object({+ preview: z.object({+ steps: z.array(+ z.object({ name: z.string(), run: z.string().optional() }),+ ),+ }),+ }),+ })+ .parse(parse(readFileSync(".github/workflows/pr-preview.yml", "utf8")));+const script = workflow.jobs.preview.steps.find(+ (step) => step.name === "Verify Access protection",+)?.run;+if (!script) throw new Error("Preview Access verification step is missing");++const access = "302 https://example.cloudflareaccess.com/cdn-cgi/access/login";++describe("preview Access verification", () => {+ it.each([+ { responses: [access], status: 0, retries: 0 },+ { responses: ["404 ", access], status: 0, retries: 1 },+ { responses: ["503 ", access], status: 0, retries: 1 },+ { responses: ["000 ", access], status: 0, retries: 1 },+ { responses: ["200 "], status: 1, retries: 0 },+ { responses: ["302 https://example.com/"], status: 1, retries: 0 },+ { responses: ["403 "], status: 1, retries: 0 },+ { responses: ["404 ", "200 "], status: 1, retries: 1 },+ { responses: Array<string>(8).fill("404 "), status: 1, retries: 8 },+ { responses: Array<string>(8).fill("503 "), status: 1, retries: 8 },+ { responses: Array<string>(8).fill("000 "), status: 1, retries: 8 },+ ])("handles $responses", ({ responses, status, retries }) => {+ const directory = mkdtempSync(join(tmpdir(), "preview-access-"));+ try {+ const responseFile = join(directory, "responses");+ writeFileSync(responseFile, responses.join("\n") + "\n");+ const result = spawnSync(+ "bash",+ [+ "-c",+ // A shared file descriptor advances even inside curl's command substitution.+ `exec 3< "$PREVIEW_RESPONSES"+curl() { local response; IFS= read -r response <&3 || response="000 "; printf '%s\\n' "$response"; }+sleep() { :; }+${script}`,+ ],+ {+ encoding: "utf8",+ timeout: 5000,+ env: {+ ...process.env,+ PREVIEW_URL: "https://preview.example.invalid",+ STAGE: "test",+ PREVIEW_RESPONSES: responseFile,+ },+ },+ );++ expect(result.error).toBeUndefined();+ expect(result.status).toBe(status);+ expect(result.stdout.match(/attempt \d:/g) ?? []).toHaveLength(retries);+ if (retries === 8) {+ expect(result.stdout).toContain("Could not verify");+ expect(result.stdout).not.toContain("preview is public");+ expect(result.stdout).not.toContain("still sits behind");+ }+ } finally {+ rmSync(directory, { recursive: true, force: true });+ }+ });+});