seo 0.2.6 → 0.2.7

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/dist/mcp.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { createRequire as __seoCreateRequire } from 'node:module'; const require = __seoCreateRequire(import.meta.url);
2
- import { n as load, t as version } from "./package-B9-D646K.js";
2
+ import { n as load, t as version } from "./package-BI-bLeV4.js";
3
3
  import { Headers, fetch as fetch$1 } from "undici";
4
4
  import { chmodSync, existsSync, mkdirSync, readFileSync, renameSync, rmSync, writeFileSync } from "node:fs";
5
5
  import { arch, homedir, platform } from "node:os";
@@ -9,7 +9,7 @@ import lockfile from "proper-lockfile";
9
9
  import { createHash, randomUUID, sign } from "node:crypto";
10
10
  import "node:http";
11
11
  import "open";
12
- import Database from "better-sqlite3";
12
+ import Libsql from "libsql";
13
13
  import { Readability } from "@mozilla/readability";
14
14
  import Defuddle from "defuddle";
15
15
  import { parseHTML } from "linkedom";
@@ -763,6 +763,52 @@ async function createGoogleAccessTokenClient() {
763
763
  };
764
764
  }
765
765
  //#endregion
766
+ //#region packages/core/dist/storage/sqlite.js
767
+ function withoutDriverMetadata(row) {
768
+ if (!row || typeof row !== "object" || Array.isArray(row)) return row;
769
+ const { _metadata: _driverMetadata, ...data } = row;
770
+ return data;
771
+ }
772
+ var Statement = class {
773
+ statement;
774
+ constructor(statement) {
775
+ this.statement = statement;
776
+ }
777
+ run(...params) {
778
+ return this.statement.run(...params);
779
+ }
780
+ get(...params) {
781
+ return withoutDriverMetadata(this.statement.get(...params));
782
+ }
783
+ all(...params) {
784
+ return this.statement.all(...params).map(withoutDriverMetadata);
785
+ }
786
+ };
787
+ var SqliteDatabase = class {
788
+ database;
789
+ constructor(filename) {
790
+ this.database = new Libsql(filename);
791
+ }
792
+ prepare(source) {
793
+ return new Statement(this.database.prepare(source));
794
+ }
795
+ transaction(fn) {
796
+ return this.database.transaction(fn);
797
+ }
798
+ exec(source) {
799
+ this.database.exec(source);
800
+ return this;
801
+ }
802
+ pragma(source) {
803
+ const result = this.database.pragma(source);
804
+ return Array.isArray(result) ? result.map(withoutDriverMetadata) : withoutDriverMetadata(result);
805
+ }
806
+ close() {
807
+ this.database.close();
808
+ return this;
809
+ }
810
+ };
811
+ //#endregion
766
812
  //#region packages/core/dist/storage/database.js
767
813
  const CREATE_SQL = `
768
814
  CREATE TABLE IF NOT EXISTS sites (
@@ -1046,10 +1092,14 @@ function getDb() {
1046
1092
  recursive: true,
1047
1093
  mode: 448
1048
1094
  });
1049
- db = new Database(path);
1095
+ db = new SqliteDatabase(path);
1050
1096
  initDb(db);
1051
1097
  return db;
1052
1098
  }
1099
+ function checkDatabaseReadiness() {
1100
+ if (getDb().prepare("SELECT 1 AS ready").get()?.ready !== 1) throw new Error("The local SQLite database did not return a readiness row.");
1101
+ return { dbPath: getSeoCliPaths().cacheDbFile };
1102
+ }
1053
1103
  function hashKey(parts) {
1054
1104
  const json = JSON.stringify(parts);
1055
1105
  return Buffer.from(json).toString("base64url");
@@ -25567,7 +25617,7 @@ async function updatePostmortemWorkflow(input, dependencies = {}) {
25567
25617
  //#endregion
25568
25618
  //#region packages/core/dist/doctor.js
25569
25619
  const REQUIRED_SCOPES = ["https://www.googleapis.com/auth/webmasters.readonly", "https://www.googleapis.com/auth/analytics.readonly"];
25570
- async function runDoctor() {
25620
+ async function runDoctor(dependencies = {}) {
25571
25621
  const paths = getSeoCliPaths();
25572
25622
  const config = readConfig();
25573
25623
  const authMode = getAuthModeStatus();
@@ -25576,6 +25626,23 @@ async function runDoctor() {
25576
25626
  const oauthClient = readOauthClient();
25577
25627
  const tokenClientConfigured = tokens ? Boolean(getClientConfig(tokens.client_source)) : void 0;
25578
25628
  const checks = [];
25629
+ try {
25630
+ const database = (dependencies.checkDatabase ?? checkDatabaseReadiness)();
25631
+ checks.push({
25632
+ id: "local-database",
25633
+ label: "Local database",
25634
+ status: "pass",
25635
+ detail: database.dbPath
25636
+ });
25637
+ } catch (error) {
25638
+ checks.push({
25639
+ id: "local-database",
25640
+ label: "Local database",
25641
+ status: "fail",
25642
+ detail: error instanceof Error ? error.message : "The local database could not be opened.",
25643
+ fix: "Upgrade or reinstall `seo`. If this still fails, report it at https://github.com/iannuttall/seo/issues."
25644
+ });
25645
+ }
25579
25646
  checks.push({
25580
25647
  id: "config-dir",
25581
25648
  label: "Config directory",
@@ -27102,7 +27169,7 @@ function registerCrawlerTools(server) {
27102
27169
  //#region packages/mcp/src/diagnosis-tools.ts
27103
27170
  function registerDiagnosisTools(server, dependencies = {}) {
27104
27171
  server.registerTool("seo_doctor", {
27105
- description: "Check local auth, scopes, config, and defaults",
27172
+ description: "Check the local database, auth, scopes, config, and defaults",
27106
27173
  inputSchema: {}
27107
27174
  }, async () => {
27108
27175
  try {