{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "$id": "https://raw.githubusercontent.com/kylepantall/kscript/master/editors/vscode/schemas/kscript.schema.json",
  "title": "KScript project settings (kscript.json)",
  "description": "Settings for kscript serve, kscript check, kscript fmt and the KScript language server. Commands look for kscript.json in the folder they work on and its parents.",
  "type": "object",
  "additionalProperties": false,
  "if": { "required": ["library"], "properties": { "library": { "type": "object" } } },
  "then": { "required": ["name"] },
  "definitions": {
    "typeRules": {
      "type": "object",
      "properties": {
        "min": { "type": ["number", "string"], "description": "Minimum value or length, depending on the type." },
        "max": { "type": ["number", "string"], "description": "Maximum value or length, depending on the type." },
        "pattern": { "type": "string", "description": "A regular expression the value must match." },
        "one_of": { "type": ["array", "string"], "description": "Accepted values, as an array or comma-separated text." },
        "not": { "type": ["array", "string"], "description": "Excluded values, as an array or comma-separated text." }
      }
    },
    "standardReference": {
      "type": "string",
      "anyOf": [{ "enum": ["kscript:recommended", "kscript:strict"] }, { "pattern": "^(?!kscript:)" }],
      "description": "kscript:recommended, kscript:strict, or a path to a standard file or a folder holding kscript-standard.json."
    }
  },
  "properties": {
    "$schema": { "type": "string", "description": "The JSON schema that editors check this file against and suggest keys from." },
    "name": { "type": "string", "description": "The project's name." },
    "kscript": { "type": "string", "pattern": "^v?\\d+(\\.\\d+){0,2}(-[0-9A-Za-z.-]+)?$", "examples": ["0.51.0", "0.51"], "description": "The KScript release the project is written for: 0.51.0, or 0.51 for the newest 0.51.x. Editors that fetch KScript for you use this release; leave it out to use the latest." },
    "timezone": { "type": "string", "default": "Europe/London", "description": "The time zone the project's stored dates are in, by its IANA name: Europe/London (the default), America/New_York, UTC. A database column holds a date as a clock time with no zone; this says which zone that clock is in, so a row means the same moment on every computer." },
    "libraries": {
      "type": "object",
      "description": "Installed source libraries by folder name. kscript lib add records the exact revision; kscript lib restore reinstalls it.",
      "propertyNames": {
        "description": "A portable folder name. Spaces and punctuation such as + are allowed.",
        "minLength": 1,
        "not": { "anyOf": [
          { "pattern": "^\\.|[. ](?![\\s\\S])" },
          { "pattern": "[/\\\\<>:\"|?*\\u0000-\\u001f\\u007f-\\u009f]" },
          { "pattern": "^(?:[Cc][Oo][Nn]|[Pp][Rr][Nn]|[Aa][Uu][Xx]|[Nn][Uu][Ll]|(?:[Cc][Oo][Mm]|[Ll][Pp][Tt])[1-9¹²³])(?:\\.|(?![\\s\\S]))" }
        ] }
      },
      "additionalProperties": {
        "type": "object",
        "additionalProperties": false,
        "required": ["source", "commit"],
        "properties": {
          "source": { "type": "string", "pattern": "^https://github\\.com/", "description": "Canonical GitHub repository or catalog folder URL recorded by kscript lib add." },
          "commit": { "type": "string", "maxLength": 40, "pattern": "^[0-9a-f]{40}$", "description": "Full commit SHA of the source repository or catalog. The catalog commit also pins a linked submodule." }
        }
      }
    },
    "library": {
      "description": "Declares an installable library or points to its folder.",
      "oneOf": [
        {
          "type": "object",
          "additionalProperties": false,
          "required": ["version"],
          "properties": {
            "version": { "type": "string", "description": "The library's semantic version, such as 1.0.0 or 1.1.0-beta.1." },
            "entry": { "type": "string", "description": "The public .kscript or .ks.xml file to import, relative to this manifest. Defaults to main.kscript, main.ks.xml, index.kscript or index.ks.xml at the top of the library." }
          }
        },
        {
          "type": "string",
          "minLength": 1,
          "description": "A relative folder containing the library's kscript.json. That manifest declares its name, version, entry and runtime packages.",
          "not": { "anyOf": [
            { "pattern": "^/|//|/$|[. ](?:/|$)" },
            { "pattern": "[\\\\<>:\"|?*\\u0000-\\u001f\\u007f-\\u009f]" },
            { "pattern": "(?:^|/)(?:\\.[Gg][Ii][Tt](?:/|$)|(?:[Cc][Oo][Nn]|[Pp][Rr][Nn]|[Aa][Uu][Xx]|[Nn][Uu][Ll]|(?:[Cc][Oo][Mm]|[Ll][Pp][Tt])[1-9¹²³])(?:\\.|/|$))" }
          ] },
          "examples": ["libraries/isolink-connect"]
        }
      ]
    },
    "standard": {
      "description": "The standard (or standards) whose lint rules and format settings this project starts from; kscript.json's own lint and format settings win over it. Built in: kscript:recommended (the default) and kscript:strict. Anything else is a path, relative to kscript.json, to a standard file or to a folder holding kscript-standard.json. [] uses no standard (style rules off).",
      "default": "kscript:recommended",
      "oneOf": [
        { "$ref": "#/definitions/standardReference" },
        { "type": "array", "items": { "$ref": "#/definitions/standardReference" }, "description": "Several standards, applied in order: later ones win." }
      ],
      "examples": ["kscript:recommended", "kscript:strict", "./standards/team.kscript-standard.json", "../shared-standards/acme"]
    },
    "packages": {
      "type": "array",
      "description": "Packages every script in the project uses without an <import>. KScript.Core is always imported.",
      "items": {
        "type": "string",
        "enum": ["KScript.Core", "KScript.Terminal", "KScript.Math", "KScript.IO", "KScript.Net", "KScript.Markdown", "KScript.Web", "KScript.Style", "KScript.Storage", "KScript.Document", "KScript.Data", "KScript.Cache", "KScript.Queue", "KScript.Mail", "KScript.Http", "KScript.Auth", "KScript.Test", "KScript.UI", "KScript.AI"]
      },
      "uniqueItems": true
    },
    "types": {
      "type": "object",
      "description": "Default validation rules for built-in types. Arguments at a type's use site can override these defaults.",
      "properties": {
        "password": { "$ref": "#/definitions/typeRules" },
        "string": { "$ref": "#/definitions/typeRules" },
        "uuid": {
          "description": "Rules for uuid values: the typeRules settings, plus v for the UUID version.",
          "allOf": [
            { "$ref": "#/definitions/typeRules" },
            { "properties": { "v": { "anyOf": [{ "type": "integer", "minimum": 1, "maximum": 8 }, { "type": "string", "pattern": "^(?:[1-8]|any)$" }], "description": "The UUID version, or any." } } }
          ]
        }
      },
      "additionalProperties": { "$ref": "#/definitions/typeRules" },
      "examples": [{ "password": { "min": 10 }, "uuid": { "v": 4 } }]
    },
    "extensions": {
      "type": "array",
      "description": "Where the project's extension files are: folders (everything inside, subfolders too) or globs, relative to kscript.json. Their extend blocks (extend date { fn json() => ... }) apply to every script in the project. Default: [\"extensions\"].",
      "items": { "type": "string" },
      "default": ["extensions"]
    },
    "natives": {
      "type": "array",
      "description": "Where the project's native types are: folders (everything inside, subfolders too) or globs, relative to kscript.json. The types and enums they declare (type Sku with [string] { ... }) work in every script in the project without an import. kscript make native writes to the first folder. Default: [\"natives\"].",
      "items": { "type": "string" },
      "default": ["natives"]
    },
    "serve": {
      "type": "object",
      "description": "Defaults for kscript serve. Options on the command line win.",
      "additionalProperties": false,
      "properties": {
        "root": { "type": "string", "default": ".", "description": "The site folder, relative to kscript.json. Its files and folders are the site's URLs." },
        "port": { "type": "integer", "minimum": 1, "maximum": 65535, "default": 8080, "description": "The port to listen on." },
        "host": { "type": "string", "default": "localhost", "description": "localhost, an IP address to listen on, or * for every address." },
        "docs": { "type": "boolean", "default": false, "description": "Also serve the KScript docs, with a page about this project's routes, functions and types, on localhost while you work (like kscript serve --with-docs). Never on for compiled programs or the production environment." },
        "docs_port": { "type": "integer", "minimum": 1, "maximum": 65535, "default": 4180, "description": "The port the docs are served on. Without it, 4180, or a free port if that is in use." },
        "docker": {
          "type": ["boolean", "object"],
          "description": "Run kscript serve through Docker Compose. True uses the default app service and mounts the working tree for development.",
          "additionalProperties": false,
          "properties": {
            "enabled": { "type": "boolean", "default": true, "description": "Launch Docker Compose by default." },
            "compose_file": { "type": "string", "description": "Compose file relative to the project folder." },
            "service": { "type": "string", "default": "app", "description": "The Compose service that runs the site." },
            "build": { "type": "boolean", "default": true, "description": "Build the service image before starting." },
            "mount": { "type": ["string", "null"], "default": "/app", "description": "Container path for a read-only project bind mount. Null uses the image's files." }
          }
        }
      }
    },
    "http": {
      "type": "object",
      "description": "KScript.Http: route files, middleware and their settings for kscript serve.",
      "additionalProperties": false,
      "properties": {
        "routes": {
          "type": "array",
          "description": "The route files, relative to the site folder. Without this, kscript serve loads routes.kscript and api.kscript (under /api), or their .ks.xml forms.",
          "items": {
            "oneOf": [
              { "type": "string" },
              {
                "type": "object",
                "additionalProperties": false,
                "required": ["file"],
                "properties": {
                  "file": { "type": "string", "description": "The route file." },
                  "prefix": { "type": "string", "description": "A path in front of every route in the file, such as /api/v1." },
                  "api": { "type": "boolean", "description": "true: errors and missing routes are answered with JSON." }
                }
              }
            ]
          }
        },
        "middleware": { "type": "array", "items": { "type": "string" }, "description": "Middleware run for every route, such as [\"log\"]. Built-ins: log, cors, auth, guest, csrf, throttle, etag, cache_control, cache_response (throttle:30, auth:session, auth:token, auth:OTHER_TOKEN, cache_control:300, cache_response:5m)." },
        "groups": {
          "type": "object",
          "description": "Names for lists of middleware, used like a middleware name: { \"admin\": [\"auth\", \"log\"] }.",
          "additionalProperties": { "type": "array", "items": { "type": "string" } }
        },
        "views": { "type": "string", "default": "views", "description": "The folder @view() looks in first. It is never served as pages." },
        "api_prefix": { "type": "string", "default": "/api", "description": "The prefix of api.* route files." },
        "write_files": { "type": "boolean", "default": true, "description": "false makes controllers read-only, like pages. Writes never leave the site folder." },
        "upload_limit": { "type": ["integer", "string"], "default": "8MB", "description": "The most bytes of files one request may upload ($request.files and live uploads): a number of bytes, or text such as \"20MB\"." },
        "cors": {
          "type": "object",
          "additionalProperties": false,
          "description": "Settings for the cors middleware.",
          "properties": {
            "origins": { "type": "array", "items": { "type": "string" }, "description": "Origins allowed to call the API, or [\"*\"] (the default) for any." },
            "methods": { "type": "array", "items": { "type": "string" }, "description": "Methods allowed in preflight requests." },
            "headers": { "type": "array", "items": { "type": "string" }, "description": "Request headers allowed in preflight requests." },
            "credentials": { "type": "boolean", "description": "true allows cookies and Authorization from other origins." }
          }
        },
        "auth": {
          "type": "object",
          "additionalProperties": false,
          "description": "Sign-in with KScript.Auth, and the auth middleware. Times are seconds, or text such as \"15m\", \"2h\" or \"30d\".",
          "properties": {
            "token_env": { "type": "string", "default": "API_TOKEN", "description": "The environment variable holding the shared bearer token the auth middleware also accepts." },
            "login": { "type": "string", "default": "/login", "description": "Where the auth middleware sends people who aren't signed in." },
            "home": { "type": "string", "default": "/", "description": "Where the guest middleware sends people who are signed in, and @intended()'s default." },
            "sessions": { "enum": ["file", "memory", "database"], "default": "file", "description": "Where sessions, API tokens, reset tokens and passkey challenges are kept: file (the app's state folder, so they last across restarts), memory, or database (the kscript_sessions table, shared by every server)." },
            "auto_create": { "type": "boolean", "default": true, "description": "With sessions: database, false leaves making the kscript_sessions table to the project's migrations (kscript publish sessions sets it)." },
            "folder": { "type": "string", "description": "A folder, relative to the site, for users, sessions and tokens. By default they go in the app's data and state folders." },
            "users": { "type": "string", "description": "A KScript.Data model in the models folder, such as \"User\", that holds the users. By default they are JSON files in the app's data folder." },
            "lifetime": { "type": ["number", "string"], "pattern": "^\\s*\\d+(\\.\\d+)?\\s*[smhdwSMHDW]?\\s*$", "default": "2h", "description": "How long a session lasts after the last request." },
            "remember": { "type": ["number", "string"], "pattern": "^\\s*\\d+(\\.\\d+)?\\s*[smhdwSMHDW]?\\s*$", "default": "30d", "description": "How long a \"remember me\" sign-in lasts." },
            "cookie": { "type": "string", "default": "ks_session", "description": "The session cookie's name." },
            "secure": { "type": "boolean", "description": "Forces the cookie's Secure flag on or off. By default it is set for https requests." },
            "same_site": { "enum": ["Lax", "Strict", "None"], "default": "Lax", "description": "The cookie's SameSite." },
            "csrf": { "type": "boolean", "default": true, "description": "False turns off the CSRF check that web routes get when their file imports KScript.Auth." },
            "attempts": { "type": "integer", "minimum": 1, "default": 5, "description": "Failed sign-ins allowed per email and address before @attempt() makes them wait." },
            "lockout": { "type": ["number", "string"], "pattern": "^\\s*\\d+(\\.\\d+)?\\s*[smhdwSMHDW]?\\s*$", "default": "1m", "description": "How long failed sign-ins are counted over, and how long @attempt() then waits." },
            "passkey_origin": { "type": "string", "format": "uri", "description": "The public HTTPS origin for passkeys, or http://localhost with an optional development port. Setting this enables passkeys." },
            "passkey_signup": { "type": "boolean", "default": false, "description": "Allows new accounts to sign up with a passkey. Requires passkey_origin." },
            "passkey_rp_id": { "type": "string", "description": "An optional relying party domain, such as example.com. Defaults to the passkey origin's hostname." },
            "reset_lifetime": { "type": ["number", "string"], "pattern": "^\\s*\\d+(\\.\\d+)?\\s*[smhdwSMHDW]?\\s*$", "default": "1h", "description": "How long a password reset token works." },
            "guest_lifetime": { "type": ["number", "string"], "pattern": "^\\s*\\d+(\\.\\d+)?\\s*[smhdwSMHDW]?\\s*$", "default": "365d", "description": "How long a browser keeps its @guest() id." },
            "guest_cookie": { "type": "string", "default": "ks_guest", "description": "The guest id cookie's name." },
            "adopt_guest": { "type": "boolean", "default": false, "description": "Moves a guest's rows of Ownable models to their account when they sign in." }
          }
        },
        "throttle": {
          "type": "object",
          "additionalProperties": false,
          "description": "Settings for the throttle middleware.",
          "properties": {
            "limit": { "type": "integer", "minimum": 1, "default": 60, "description": "Requests allowed per window, per address and route." },
            "seconds": { "type": "number", "exclusiveMinimum": 0, "default": 60, "description": "The length of the window." },
            "store": { "enum": ["memory", "file", "database"], "default": "memory", "description": "Where requests are counted: memory (this process), file (the app's cache folder) or database (shared by every server)." }
          }
        },
        "openapi": {
          "description": "The OpenAPI 3.1 document made from the routes. kscript serve answers /_openapi.json, /_openapi.yaml and the /_api page; kscript openapi writes it. false turns the served copies off.",
          "default": true,
          "oneOf": [
            { "type": "boolean" },
            {
              "type": "object",
              "additionalProperties": false,
              "properties": {
                "enabled": { "type": "boolean", "default": true, "description": "false stops kscript serve answering /_openapi.json, /_openapi.yaml and /_api." },
                "title": { "type": "string", "description": "info.title. Defaults to the project's name." },
                "version": { "type": "string", "description": "info.version. Defaults to app.version, then 1.0.0." },
                "description": { "type": "string", "description": "info.description." },
                "routes": { "enum": ["auto", "api", "all"], "default": "auto", "description": "Which routes: api (from api.* files), all, or auto (the API routes if there are any, otherwise all)." },
                "file": { "type": "string", "description": "A file, relative to kscript.json, to keep the document in (openapi.json, or openapi.yaml for YAML). kscript watch, kscript serve and the editor (on save) rewrite it as the routes change." }
              }
            }
          ]
        }
      }
    },
    "lint": {
      "type": "object",
      "description": "Used by kscript check and by the editor (language server).",
      "additionalProperties": false,
      "properties": {
        "include": {
          "type": "array",
          "items": { "type": "string" },
          "default": ["**/*.kscript", "**/*.ks.xml", "**/*.html", "**/*.md"],
          "description": "Files kscript check looks at, as globs relative to kscript.json. .xml files that start with <kscript> are always included."
        },
        "exclude": {
          "type": "array",
          "items": { "type": "string" },
          "default": ["_templates", "node_modules", ".git"],
          "description": "Files and folders that are never checked, by kscript check or the editor. A name without / (such as _templates) matches anywhere; drafts/** matches a folder."
        },
        "rules": {
          "type": "object",
          "description": "Severity per diagnostic code (KS3003) or code prefix (KS3*). The longest match wins.",
          "propertyNames": { "pattern": "^[Kk][Ss][0-9]{0,4}\\*?$" },
          "additionalProperties": { "enum": ["off", "hint", "info", "warning", "error"] },
          "examples": [{ "KS3003": "off", "KS4*": "error" }]
        },
        "warnings_as_errors": { "type": "boolean", "default": false, "description": "Make kscript check fail on warnings too (same as --warnings-as-errors)." }
      }
    },
    "paths": {
      "type": "object",
      "description": "Where kscript make puts each kind of file, relative to the site folder. Leave a folder out to use the recommended one.",
      "additionalProperties": false,
      "properties": {
        "routes": { "type": "string", "default": "routes", "description": "Route files: web.kscript (served at /) and api.kscript (under /api)." },
        "controllers": { "type": "string", "default": "controllers", "description": "Controllers (kscript make controller, kscript make route)." },
        "middleware": { "type": "string", "default": "middleware", "description": "Middleware (kscript make middleware)." },
        "requests": { "type": "string", "default": "requests", "description": "Typed request bodies (kscript make request)." },
        "views": { "type": "string", "default": "views", "description": "Views that controllers render with @view() (kscript make view). Also where @view() looks, unless http.views is set." },
        "components": { "type": "string", "default": "_components", "description": "Page components (kscript make component)." },
        "layouts": { "type": "string", "default": "_layouts", "description": "Page layouts (kscript make layout)." },
        "partials": { "type": "string", "default": "_partials", "description": "HTML that pages <include> (kscript make partial)." },
        "styles": { "type": "string", "default": "styles", "description": ".ks.css stylesheets (kscript make css)." },
        "lib": { "type": "string", "default": "lib", "description": "Shared functions and constants (kscript make module, kscript make const, kscript make cache)." },
        "types": { "type": "string", "default": "types", "description": "Types and enums (kscript make type, kscript make enum)." },
        "models": { "type": "string", "default": "models", "description": "Database models (kscript make model)." },
        "storage": { "type": "string", "default": "lib", "description": "JSON file stores (kscript make storage)." },
        "jobs": { "type": "string", "default": "jobs", "description": "Jobs (kscript make job)." },
        "policies": { "type": "string", "default": "policies", "description": "Policies, one per model, that @can and @authorize ask (kscript make policy)." },
        "events": { "type": "string", "default": "events", "description": "Events, dispatched with @dispatch_event() (kscript make event)." },
        "listeners": { "type": "string", "default": "listeners", "description": "Listeners, run the first time an event is dispatched (kscript make listener)." },
        "windows": { "type": "string", "default": ".", "description": "Desktop windows (kscript make window)." },
        "documents": { "type": "string", "default": "documents", "description": "Document scripts that write PDF and Word files (kscript make document)." },
        "locales": { "type": "string", "default": "locales", "description": "Translations (kscript make locale)." },
        "logging": { "type": "string", "default": "lib", "description": "Log providers (kscript make logger)." },
        "data": { "type": "string", "default": "data", "description": "JSON data that stores and caches write." },
        "scripts": { "type": "string", "default": "scripts", "description": "Scripts (kscript make script)." },
        "tests": { "type": "string", "default": "tests", "description": "Tests (kscript make test)." }
      }
    },
    "make": {
      "type": "object",
      "description": "Settings for kscript make.",
      "additionalProperties": false,
      "properties": {
        "syntax": { "enum": ["kscript", "xml"], "default": "kscript", "description": "The syntax kscript make writes scripts, tests, routes and desktop apps in: kscript (.kscript files) or xml (.ks.xml). --syntax on the command line wins." }
      }
    },
    "app": {
      "type": "object",
      "description": "Used by kscript compile, which builds a script, desktop app or site into a program for macOS, Windows and Linux.",
      "additionalProperties": false,
      "properties": {
        "main": { "type": "string", "description": "The script the app runs, relative to kscript.json. Usually one that imports KScript.UI and holds a Window { } (<KScript.Window> as the root of an XML file)." },
        "name": { "type": "string", "description": "The app's name in the Dock, Start menu or launcher. Defaults to the project's name." },
        "id": { "type": "string", "description": "A reverse-DNS id such as com.example.lifelab (the macOS bundle id)." },
        "version": { "type": "string", "description": "The app's version, such as 1.0.0." },
        "icon": { "type": "string", "description": "An icon file relative to kscript.json: .icns for macOS, .ico for Windows, .png for Linux." },
        "user_config": { "type": "boolean", "default": false, "description": "true lays the person's own settings over $config: config.json in the app's config folder, such as ~/.config/<app> on Linux (see KScript.Storage)." }
      }
    },
    "test": {
      "type": "object",
      "description": "Used by kscript test.",
      "additionalProperties": false,
      "properties": {
        "include": {
          "type": "array",
          "items": { "type": "string" },
          "default": ["**/*.test.kscript", "**/*.test.ks.xml"],
          "description": "The test files kscript test runs, as globs relative to kscript.json."
        },
        "exclude": {
          "type": "array",
          "items": { "type": "string" },
          "default": ["_templates", "node_modules", ".git"],
          "description": "Files and folders that are never run as tests."
        },
        "timeout": {
          "type": "number",
          "minimum": 0,
          "default": 10,
          "description": "Seconds one test may run before it fails (0 for no limit). timeout=\"...\" on a <test> and --timeout win."
        },
        "env": {
          "type": "string",
          "examples": ["test"],
          "description": "The environment the tests run in (KSCRIPT_ENV), so kscript.test.json can give tests their own database. kscript --env and a KSCRIPT_ENV already set win."
        },
        "database": {
          "enum": ["memory", "config"],
          "default": "memory",
          "description": "The database KScript.Data gives each test file: memory (a new SQLite database in memory, made from the migrations or the models) or config (the one the config names). Each test's changes are undone when it ends."
        },
        "packages": {
          "type": "array",
          "description": "Packages every test file imports, on top of the project's packages. KScript.Test is always imported in test files.",
          "items": {
            "type": "string",
            "enum": ["KScript.Terminal", "KScript.Math", "KScript.IO", "KScript.Net", "KScript.Markdown", "KScript.Web", "KScript.UI", "KScript.AI"]
          },
          "uniqueItems": true
        }
      }
    },
    "config": {
      "type": "object",
      "description": "The app's own settings, read as $config: \"config\": { \"app\": { \"name\": \"Shop\" } } gives $config.app.name. kscript.<env>.json's config section is laid over this one for that environment (kscript --env or KSCRIPT_ENV), and then config.kscript's configure(environment), for settings that need @env() or other code.",
      "properties": {
        "app": { "type": "object", "description": "Settings about the app, such as its name: $config.app.name." },
        "database": {
          "type": "object",
          "description": "KScript.Data's database connections.",
          "properties": {
            "default": { "type": "string", "description": "The connection used when none is named (default: main)." },
            "connections": {
              "type": "object",
              "description": "Connections by name, such as \"main\": { \"url\": \"sqlite:data/app.sqlite\" }.",
              "additionalProperties": {
                "type": "object",
                "properties": {
                  "url": { "type": "string", "description": "Where the database is: sqlite:data/app.sqlite, postgres://user:password@host/app or mysql://user:password@host/app." },
                  "driver": { "enum": ["sqlite", "postgres", "mysql", "mariadb"], "description": "The database, when there is no url." },
                  "host": { "type": "string", "description": "The database server's host name, when there is no url." },
                  "port": { "type": "integer", "description": "The database server's port, when there is no url." },
                  "database": { "type": "string", "description": "The database's name, when there is no url." },
                  "username": { "type": "string", "description": "The user to sign in to the database server as, when there is no url." },
                  "password": { "type": "string", "description": "That user's password, when there is no url." }
                }
              }
            }
          }
        },
        "cache": { "type": "object", "description": "KScript.Cache settings, such as \"store\": \"memory\" and \"ttl\": \"5m\"." },
        "mail": {
          "type": "object",
          "description": "KScript.Mail: how @send_mail sends (see docs/mail.md).",
          "properties": {
            "driver": { "enum": ["smtp", "log", "fake"], "default": "log", "description": "smtp sends through a mail server, log writes each message to the log, and fake keeps them in memory." },
            "host": { "type": "string", "default": "localhost", "description": "The SMTP server." },
            "port": { "type": "integer", "default": 587, "description": "The SMTP port: 587 for STARTTLS, 25 or a test server's port otherwise." },
            "username": { "type": "string", "description": "The SMTP user. Defaults to the MAIL_USERNAME environment variable." },
            "password": { "type": "string", "description": "The SMTP password. Leave it out to read the MAIL_PASSWORD environment variable." },
            "encryption": { "enum": ["tls", "none"], "default": "tls", "description": "tls upgrades the connection with STARTTLS; none sends in the clear, for a local test server." },
            "from": {
              "description": "The address mail comes from unless @send_mail names one: \"hello@example.com\", or { \"address\": \"hello@example.com\", \"name\": \"Shop\" }.",
              "oneOf": [
                { "type": "string" },
                { "type": "object", "properties": { "address": { "type": "string", "description": "The email address mail comes from." }, "name": { "type": "string", "description": "The name shown with that address, such as Shop." } }, "required": ["address"] }
              ]
            },
            "queue": { "type": "string", "default": "default", "description": "The queue mail sent with queue goes on." }
          }
        },
        "logging": { "type": "object", "description": "Log level and providers, such as \"level\": \"info\"." },
        "i18n": { "type": "object", "description": "Translations: folder, default and locale, such as \"default\": \"en-GB\"." },
        "money": { "type": "object", "description": "Money settings, such as exchange_rates: { \"EUR\": { \"GBP\": 0.85 } }." }
      }
    },
    "queue": {
      "type": "object",
      "additionalProperties": false,
      "description": "KScript.Queue: where dispatched jobs wait, and what kscript worker runs (see docs/queues.md).",
      "properties": {
        "default": {
          "type": "string",
          "default": "file",
          "description": "The connection jobs go to unless a job or dispatch names another: file, database, memory, sync, or one under queue.connections."
        },
        "connections": {
          "type": "object",
          "description": "Named connections. file, database, memory and sync are always there.",
          "additionalProperties": {
            "type": "object",
            "additionalProperties": false,
            "required": ["driver"],
            "properties": {
              "driver": {
                "enum": ["file", "database", "memory", "sync"],
                "description": "file: one JSON file per job (the default). database: rows in a KScript.Data database. memory: in this process only, for kscript serve --with-worker. sync: run jobs as they are dispatched."
              },
              "path": { "type": "string", "description": "file only: the folder jobs are kept in, relative to kscript.json. Default: the app's data folder." },
              "connection": { "type": "string", "description": "database only: the database connection (under database.connections in config) the jobs tables go in. Default: the default database." },
              "url_env": { "type": "string", "description": "For a driver that connects by URL (redis, planned): the environment variable that holds the URL." },
              "auto_create": { "type": "boolean", "default": true, "description": "database only: make the tables the first time they are needed. kscript publish queue writes their migration and sets this to false." },
              "tables": {
                "type": "object",
                "additionalProperties": false,
                "description": "database only: the names of the queue's tables.",
                "properties": {
                  "jobs": { "type": "string", "default": "kscript_jobs", "description": "The table jobs wait in." },
                  "failed": { "type": "string", "default": "kscript_failed_jobs", "description": "The table failed jobs are kept in." },
                  "locks": { "type": "string", "default": "kscript_job_locks", "description": "The table of locks for unique and overlapping jobs." },
                  "batches": { "type": "string", "default": "kscript_job_batches", "description": "The table batches of jobs are tracked in." }
                }
              }
            }
          }
        },
        "queues": {
          "type": "array",
          "items": { "type": "string" },
          "minItems": 1,
          "description": "The only queues a worker checks, first to last, e.g. [\"high\", \"default\"]. Without it a worker checks default, then every other queue."
        },
        "failed": {
          "type": "object",
          "description": "What happens to jobs that fail every try.",
          "additionalProperties": false,
          "properties": {
            "keep": { "type": ["string", "number"], "default": "7d", "description": "How long failed jobs are kept, such as \"7d\" or a number of seconds." }
          }
        },
        "worker": {
          "type": "object",
          "description": "How kscript worker runs jobs.",
          "additionalProperties": false,
          "properties": {
            "concurrency": { "type": "integer", "minimum": 1, "default": 1, "description": "How many jobs a worker runs at once." },
            "sleep": { "type": ["string", "number"], "default": "1s", "description": "How long a worker waits when the queues are empty." }
          }
        },
        "env": {
          "type": "object",
          "description": "Settings per environment, e.g. { \"test\": { \"default\": \"sync\" } }. kscript test uses sync unless env.test says otherwise.",
          "additionalProperties": {
            "type": "object",
            "additionalProperties": false,
            "properties": { "default": { "type": "string", "description": "The queue connection this environment uses, such as sync." } }
          }
        }
      }
    },
    "agents": {
      "type": "object",
      "description": "Settings for generated AGENTS.md.",
      "additionalProperties": false,
      "properties": {
        "merge": {
          "type": "array",
          "description": "Project-relative Markdown files to include in AGENTS.md, in the listed order.",
          "items": { "type": "string", "minLength": 1 },
          "examples": [["docs/project-guidance.md"]]
        }
      }
    },
    "format": {
      "type": "object",
      "description": "Used by kscript fmt and the editor's Format Document. Values set here win over the editor's tab settings.",
      "additionalProperties": false,
      "properties": {
        "enabled": {
          "type": "boolean",
          "default": true,
          "description": "false turns formatting off for the project: kscript fmt skips its files and Format Document makes no changes."
        },
        "rules": {
          "type": "object",
          "description": "Turn individual formatting rules off, e.g. { \"statement_per_line\": false }. Every rule is on unless listed. To leave part of a file alone, use <!-- kscript-fmt: off --> ... <!-- kscript-fmt: on --> or <!-- kscript-fmt-ignore --> before an element.",
          "additionalProperties": false,
          "properties": {
            "indent": { "type": ["boolean", "string"], "enum": [true, false, "on", "off"], "default": true, "description": "Re-indent elements by how deeply they are nested. Off: lines keep their indentation." },
            "statement_per_line": { "type": ["boolean", "string"], "enum": [true, false, "on", "off"], "default": true, "description": "Put each statement and block-level element on its own line. Off: line breaks only change where there was already whitespace." },
            "tidy_tags": { "type": ["boolean", "string"], "enum": [true, false, "on", "off"], "default": true, "description": "One space between attributes, and <x /> for self-closing tags. Off: start tags are kept exactly as written." },
            "wrap_attributes": { "type": ["boolean", "string"], "enum": [true, false, "on", "off"], "default": true, "description": "One attribute per line for long start tags and tags already written that way. Off: tags are never wrapped or joined." },
            "trim_trailing_whitespace": { "type": ["boolean", "string"], "enum": [true, false, "on", "off"], "default": true, "description": "Remove spaces at the ends of lines of text." },
            "collapse_blank_lines": { "type": ["boolean", "string"], "enum": [true, false, "on", "off"], "default": true, "description": "Shrink runs of blank lines to max_blank_lines." },
            "final_newline": { "type": ["boolean", "string"], "enum": [true, false, "on", "off"], "default": true, "description": "End the file with exactly one newline. Off: the file ends as it did." },
            "spacing": { "type": ["boolean", "string"], "enum": [true, false, "on", "off"], "default": true, "description": ".kscript files: one space after commas and colons, around assignments and =>, and before a block's '{'. Off: spacing inside lines is kept." },
            "brace_style": { "type": ["boolean", "string"], "enum": [true, false, "on", "off"], "default": true, "description": ".kscript files: put else, elif, catch and finally on the line of the closing '}'. Off: they stay where they are." },
            "wrap_strings": { "type": ["boolean", "string"], "enum": [true, false, "on", "off"], "default": true, "description": ".kscript files: break a string that runs past print_width at a space, with a \\ at the end of the line (the break isn't part of the string). Off: long strings stay on one line." },
            "wrap_chains": { "type": ["boolean", "string"], "enum": [true, false, "on", "off"], "default": true, "description": ".kscript files: a -> chain or |> pipe that runs past print_width puts each call on its own line, indented under where the chain starts. Off: chains stay on one line." },
            "wrap_bodies": { "type": ["boolean", "string"], "enum": [true, false, "on", "off"], "default": true, "description": ".kscript files: a one-line function (fn name() => body) that runs past print_width moves its body to the next line. Off: it stays on one line." },
            "wrap_comments": { "type": ["boolean", "string"], "enum": [true, false, "on", "off"], "default": true, "description": ".kscript files: a // or /// comment line that runs past print_width is broken between words onto a new comment line. Off: comments stay as written." }
          }
        },
        "indent": {
          "oneOf": [{ "type": "integer", "minimum": 1, "maximum": 16 }, { "const": "tab" }],
          "default": 2,
          "description": "Spaces per indent level, or \"tab\" to indent with tabs."
        },
        "tab_width": {
          "type": "integer",
          "minimum": 1,
          "maximum": 16,
          "default": 2,
          "description": "With \"indent\": \"tab\", how many columns a tab counts as when lining up existing text."
        },
        "print_width": {
          "type": "integer",
          "minimum": 20,
          "default": 80,
          "description": "The longest a line should be (80 by default). Longer lines are wrapped: a start tag gets one attribute per line, and in .kscript files a long call, chain, one-line function, string or comment is broken onto more lines."
        },
        "max_blank_lines": {
          "type": "integer",
          "minimum": 0,
          "default": 1,
          "description": "Blank lines kept in a row; extra ones are removed."
        },
        "end_of_line": {
          "enum": ["auto", "lf", "crlf"],
          "default": "auto",
          "description": "Line endings to write. auto keeps the ones each file already uses."
        },
        "preserve": {
          "type": "array",
          "items": { "type": "string" },
          "default": [],
          "description": "Elements whose content is kept exactly as written, on top of <pre>, <textarea>, <script>, <style> and CDATA sections."
        },
        "include": {
          "type": "array",
          "items": { "type": "string" },
          "default": ["**/*.kscript", "**/*.ks.xml", "**/*.html"],
          "description": "Files kscript fmt formats in a project folder, as globs relative to kscript.json. .xml files that start with <kscript> are always included; Markdown pages are never reformatted."
        },
        "exclude": {
          "type": "array",
          "items": { "type": "string" },
          "default": ["_templates", "node_modules", ".git"],
          "description": "Files and folders kscript fmt leaves alone."
        }
      }
    }
  }
}
