{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "$id": "https://docs.smithable.ai/schema/smithable-context-0.1.json",
  "title": "smithable.context.yml",
  "description": "Implementation choices: the adapter, the database, conventions, packages, plugins and the AI policy. The only file that may name technologies.",
  "type": "object",
  "required": [
    "smithableContext"
  ],
  "additionalProperties": false,
  "properties": {
    "smithableContext": {
      "enum": [
        0.1
      ],
      "description": "The file format version."
    },
    "adapter": {
      "type": "string",
      "description": "The adapter that generates the app (tanstack)."
    },
    "database": {
      "type": "string",
      "description": "The database the app stores its records in (sqlite)."
    },
    "conventions": {
      "type": "array",
      "items": {
        "type": "string"
      },
      "description": "Conventions custom code follows, one per line, for people and models writing it."
    },
    "guidance": {
      "type": "string",
      "description": "What a model writing custom code should know about this app."
    },
    "plugins": {
      "type": "array",
      "items": {
        "type": "string"
      },
      "description": "The project's own plugins (smithable/plugins/<name>/), by name."
    },
    "packages": {
      "type": "object",
      "additionalProperties": {
        "type": "string",
        "pattern": "^\\d+\\.\\d+\\.\\d+(-[0-9A-Za-z.-]+)?$",
        "x-expected": "an exact version like 4.4.1"
      },
      "description": "Libraries for custom code: name to exact version."
    },
    "analytics": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "plausible": {
          "type": "string",
          "pattern": "^[a-z0-9.-]+\\.[a-z]{2,}$",
          "description": "Plausible: the app's domain as Plausible knows it, e.g. shop.example.com."
        },
        "umami": {
          "type": "string",
          "pattern": "^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$",
          "description": "Umami (its hosted service): the website id."
        },
        "fathom": {
          "type": "string",
          "pattern": "^[A-Z0-9]{8}$",
          "description": "Fathom: the site id, eight capital letters or digits."
        },
        "google": {
          "type": "string",
          "pattern": "^G-[A-Z0-9]{4,12}$",
          "description": "Google Analytics: the measurement id, e.g. G-XXXXXXXXXX. Asks for consent first."
        }
      },
      "description": "Counting visits with one provider and the app's id with it, in production builds only. Google needs the visitor's consent, so it turns on the consent bar; the others keep no cookies."
    },
    "ai": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "policy": {
          "enum": [
            "local-only",
            "eu-only",
            "best-available",
            "custom"
          ],
          "description": "local-only, eu-only, best-available (the default when nothing is said), or custom."
        },
        "allow": {
          "type": "array",
          "items": {
            "type": "string"
          },
          "description": "With custom: the models allowed, by name."
        }
      },
      "description": "Where a model may run: the policy, and with custom the models allowed."
    },
    "payments": {
      "type": "object",
      "description": "Who takes the payments of the spec's payments section; its keys are settings, never in a file.",
      "required": [
        "provider"
      ],
      "additionalProperties": false,
      "properties": {
        "provider": {
          "enum": [
            "stripe",
            "mollie",
            "fake"
          ],
          "description": "stripe, mollie, or fake (the app's own page, for development and tests)."
        }
      }
    }
  }
}
