kscript.json settings
Every setting a project's kscript.json can have. The editor checks the file against the same list, so it completes and explains each one as you type.
A dotted name is a setting inside another: serve.port is { "serve": { "port": 8080 } }. More in Projects and kscript.json.
Project
| Setting | Type | Default | What it does |
|---|---|---|---|
name | string | The project's name. | |
kscript | string | 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 | string | "Europe/London" | 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 | object | Installed source libraries by folder name. kscript lib add records the exact revision; kscript lib restore reinstalls it. | |
library | object or string | Declares an installable library or points to its folder. | |
standard | object or array | "kscript:recommended" | 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). |
packages | array | Packages every script in the project uses without an <import>. KScript.Core is always imported. | |
extensions | array | ["extensions"] | 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"]. |
natives | array | ["natives"] | 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"]. |
types
| Setting | Type | Default | What it does |
|---|---|---|---|
types | object | Default validation rules for built-in types. Arguments at a type's use site can override these defaults. | |
types.password | rules | ||
types.string | rules | ||
types.uuid |
serve
| Setting | Type | Default | What it does |
|---|---|---|---|
serve | object | Defaults for kscript serve. Options on the command line win. | |
serve.root | string | "." | The site folder, relative to kscript.json. Its files and folders are the site's URLs. |
serve.port | number | 8080 | The port to listen on. |
serve.host | string | "localhost" | localhost, an IP address to listen on, or * for every address. |
serve.docs | boolean | false | 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. |
serve.docs_port | number | 4180 | The port the docs are served on. Without it, 4180, or a free port if that is in use. |
serve.docker | boolean or object | Run kscript serve through Docker Compose. True uses the default app service and mounts the working tree for development. | |
serve.docker.enabled | boolean | true | Launch Docker Compose by default. |
serve.docker.compose_file | string | Compose file relative to the project folder. | |
serve.docker.service | string | "app" | The Compose service that runs the site. |
serve.docker.build | boolean | true | Build the service image before starting. |
serve.docker.mount | string or null | "/app" | Container path for a read-only project bind mount. Null uses the image's files. |
http
| Setting | Type | Default | What it does |
|---|---|---|---|
http | object | KScript.Http: route files, middleware and their settings for kscript serve. | |
http.routes | array | 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. | |
http.middleware | array | 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). | |
http.groups | object | Names for lists of middleware, used like a middleware name: { "admin": ["auth", "log"] }. | |
http.views | string | "views" | The folder @view() looks in first. It is never served as pages. |
http.api_prefix | string | "/api" | The prefix of api.* route files. |
http.write_files | boolean | true | false makes controllers read-only, like pages. Writes never leave the site folder. |
http.upload_limit | integer or string | "8MB" | The most bytes of files one request may upload ($request.files and live uploads): a number of bytes, or text such as "20MB". |
http.cors | object | Settings for the cors middleware. | |
http.cors.origins | array | Origins allowed to call the API, or ["*"] (the default) for any. | |
http.cors.methods | array | Methods allowed in preflight requests. | |
http.cors.headers | array | Request headers allowed in preflight requests. | |
http.cors.credentials | boolean | true allows cookies and Authorization from other origins. | |
http.auth | object | Sign-in with KScript.Auth, and the auth middleware. Times are seconds, or text such as "15m", "2h" or "30d". | |
http.auth.token_env | string | "API_TOKEN" | The environment variable holding the shared bearer token the auth middleware also accepts. |
http.auth.login | string | "/login" | Where the auth middleware sends people who aren't signed in. |
http.auth.home | string | "/" | Where the guest middleware sends people who are signed in, and @intended()'s default. |
http.auth.sessions | file or memory or database | "file" | 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). |
http.auth.auto_create | boolean | true | With sessions: database, false leaves making the kscript_sessions table to the project's migrations (kscript publish sessions sets it). |
http.auth.folder | string | A folder, relative to the site, for users, sessions and tokens. By default they go in the app's data and state folders. | |
http.auth.users | string | 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. | |
http.auth.lifetime | number or string | "2h" | How long a session lasts after the last request. |
http.auth.remember | number or string | "30d" | How long a "remember me" sign-in lasts. |
http.auth.cookie | string | "ks_session" | The session cookie's name. |
http.auth.secure | boolean | Forces the cookie's Secure flag on or off. By default it is set for https requests. | |
http.auth.same_site | Lax or Strict or None | "Lax" | The cookie's SameSite. |
http.auth.csrf | boolean | true | False turns off the CSRF check that web routes get when their file imports KScript.Auth. |
http.auth.attempts | number | 5 | Failed sign-ins allowed per email and address before @attempt() makes them wait. |
http.auth.lockout | number or string | "1m" | How long failed sign-ins are counted over, and how long @attempt() then waits. |
http.auth.passkey_origin | string | The public HTTPS origin for passkeys, or http://localhost with an optional development port. Setting this enables passkeys. | |
http.auth.passkey_signup | boolean | false | Allows new accounts to sign up with a passkey. Requires passkey_origin. |
http.auth.passkey_rp_id | string | An optional relying party domain, such as example.com. Defaults to the passkey origin's hostname. | |
http.auth.reset_lifetime | number or string | "1h" | How long a password reset token works. |
http.auth.guest_lifetime | number or string | "365d" | How long a browser keeps its @guest() id. |
http.auth.guest_cookie | string | "ks_guest" | The guest id cookie's name. |
http.auth.adopt_guest | boolean | false | Moves a guest's rows of Ownable models to their account when they sign in. |
http.throttle | object | Settings for the throttle middleware. | |
http.throttle.limit | number | 60 | Requests allowed per window, per address and route. |
http.throttle.seconds | number | 60 | The length of the window. |
http.throttle.store | memory or file or database | "memory" | Where requests are counted: memory (this process), file (the app's cache folder) or database (shared by every server). |
http.openapi | boolean or object | true | 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. |
lint
| Setting | Type | Default | What it does |
|---|---|---|---|
lint | object | Used by kscript check and by the editor (language server). | |
lint.include | array | ["**/*.kscript","**/*.ks.xml","**/*.html","**/*.md"] | Files kscript check looks at, as globs relative to kscript.json. .xml files that start with <kscript> are always included. |
lint.exclude | array | ["_templates","node_modules",".git"] | 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. |
lint.rules | object | Severity per diagnostic code (KS3003) or code prefix (KS3*). The longest match wins. | |
lint.warnings_as_errors | boolean | false | Make kscript check fail on warnings too (same as --warnings-as-errors). |
paths
| Setting | Type | Default | What it does |
|---|---|---|---|
paths | object | Where kscript make puts each kind of file, relative to the site folder. Leave a folder out to use the recommended one. | |
paths.routes | string | "routes" | Route files: web.kscript (served at /) and api.kscript (under /api). |
paths.controllers | string | "controllers" | Controllers (kscript make controller, kscript make route). |
paths.middleware | string | "middleware" | Middleware (kscript make middleware). |
paths.requests | string | "requests" | Typed request bodies (kscript make request). |
paths.views | string | "views" | Views that controllers render with @view() (kscript make view). Also where @view() looks, unless http.views is set. |
paths.components | string | "_components" | Page components (kscript make component). |
paths.layouts | string | "_layouts" | Page layouts (kscript make layout). |
paths.partials | string | "_partials" | HTML that pages <include> (kscript make partial). |
paths.styles | string | "styles" | .ks.css stylesheets (kscript make css). |
paths.lib | string | "lib" | Shared functions and constants (kscript make module, kscript make const, kscript make cache). |
paths.types | string | "types" | Types and enums (kscript make type, kscript make enum). |
paths.models | string | "models" | Database models (kscript make model). |
paths.storage | string | "lib" | JSON file stores (kscript make storage). |
paths.jobs | string | "jobs" | Jobs (kscript make job). |
paths.policies | string | "policies" | Policies, one per model, that @can and @authorize ask (kscript make policy). |
paths.events | string | "events" | Events, dispatched with @dispatch_event() (kscript make event). |
paths.listeners | string | "listeners" | Listeners, run the first time an event is dispatched (kscript make listener). |
paths.windows | string | "." | Desktop windows (kscript make window). |
paths.documents | string | "documents" | Document scripts that write PDF and Word files (kscript make document). |
paths.locales | string | "locales" | Translations (kscript make locale). |
paths.logging | string | "lib" | Log providers (kscript make logger). |
paths.data | string | "data" | JSON data that stores and caches write. |
paths.scripts | string | "scripts" | Scripts (kscript make script). |
paths.tests | string | "tests" | Tests (kscript make test). |
make
| Setting | Type | Default | What it does |
|---|---|---|---|
make | object | Settings for kscript make. | |
make.syntax | kscript or xml | "kscript" | 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
| Setting | Type | Default | What it does |
|---|---|---|---|
app | object | Used by kscript compile, which builds a script, desktop app or site into a program for macOS, Windows and Linux. | |
app.main | string | 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). | |
app.name | string | The app's name in the Dock, Start menu or launcher. Defaults to the project's name. | |
app.id | string | A reverse-DNS id such as com.example.lifelab (the macOS bundle id). | |
app.version | string | The app's version, such as 1.0.0. | |
app.icon | string | An icon file relative to kscript.json: .icns for macOS, .ico for Windows, .png for Linux. | |
app.user_config | boolean | false | 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
| Setting | Type | Default | What it does |
|---|---|---|---|
test | object | Used by kscript test. | |
test.include | array | ["**/*.test.kscript","**/*.test.ks.xml"] | The test files kscript test runs, as globs relative to kscript.json. |
test.exclude | array | ["_templates","node_modules",".git"] | Files and folders that are never run as tests. |
test.timeout | number | 10 | Seconds one test may run before it fails (0 for no limit). timeout="..." on a <test> and --timeout win. |
test.env | string | 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. | |
test.database | memory or config | "memory" | 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. |
test.packages | array | Packages every test file imports, on top of the project's packages. KScript.Test is always imported in test files. |
config
| Setting | Type | Default | What it does |
|---|---|---|---|
config | object | 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. | |
config.app | object | Settings about the app, such as its name: $config.app.name. | |
config.database | object | KScript.Data's database connections. | |
config.database.default | string | The connection used when none is named (default: main). | |
config.database.connections | object | Connections by name, such as "main": { "url": "sqlite:data/app.sqlite" }. | |
config.cache | object | KScript.Cache settings, such as "store": "memory" and "ttl": "5m". | |
config.mail | object | KScript.Mail: how @send_mail sends (see docs/mail.md). | |
config.mail.driver | smtp or log or fake | "log" | smtp sends through a mail server, log writes each message to the log, and fake keeps them in memory. |
config.mail.host | string | "localhost" | The SMTP server. |
config.mail.port | number | 587 | The SMTP port: 587 for STARTTLS, 25 or a test server's port otherwise. |
config.mail.username | string | The SMTP user. Defaults to the MAIL_USERNAME environment variable. | |
config.mail.password | string | The SMTP password. Leave it out to read the MAIL_PASSWORD environment variable. | |
config.mail.encryption | tls or none | "tls" | tls upgrades the connection with STARTTLS; none sends in the clear, for a local test server. |
config.mail.from | string or object | The address mail comes from unless @send_mail names one: "hello@example.com", or { "address": "hello@example.com", "name": "Shop" }. | |
config.mail.queue | string | "default" | The queue mail sent with queue goes on. |
config.logging | object | Log level and providers, such as "level": "info". | |
config.i18n | object | Translations: folder, default and locale, such as "default": "en-GB". | |
config.money | object | Money settings, such as exchange_rates: { "EUR": { "GBP": 0.85 } }. |
queue
| Setting | Type | Default | What it does |
|---|---|---|---|
queue | object | KScript.Queue: where dispatched jobs wait, and what kscript worker runs (see docs/queues.md). | |
queue.default | string | "file" | The connection jobs go to unless a job or dispatch names another: file, database, memory, sync, or one under queue.connections. |
queue.connections | object | Named connections. file, database, memory and sync are always there. | |
queue.queues | array | The only queues a worker checks, first to last, e.g. ["high", "default"]. Without it a worker checks default, then every other queue. | |
queue.failed | object | What happens to jobs that fail every try. | |
queue.failed.keep | string or number | "7d" | How long failed jobs are kept, such as "7d" or a number of seconds. |
queue.worker | object | How kscript worker runs jobs. | |
queue.worker.concurrency | number | 1 | How many jobs a worker runs at once. |
queue.worker.sleep | string or number | "1s" | How long a worker waits when the queues are empty. |
queue.env | object | Settings per environment, e.g. { "test": { "default": "sync" } }. kscript test uses sync unless env.test says otherwise. |
agents
| Setting | Type | Default | What it does |
|---|---|---|---|
agents | object | Settings for generated AGENTS.md. | |
agents.merge | array | Project-relative Markdown files to include in AGENTS.md, in the listed order. |
format
| Setting | Type | Default | What it does |
|---|---|---|---|
format | object | Used by kscript fmt and the editor's Format Document. Values set here win over the editor's tab settings. | |
format.enabled | boolean | true | false turns formatting off for the project: kscript fmt skips its files and Format Document makes no changes. |
format.rules | object | 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. | |
format.rules.indent | true or false or on or off | true | Re-indent elements by how deeply they are nested. Off: lines keep their indentation. |
format.rules.statement_per_line | true or false or on or off | true | Put each statement and block-level element on its own line. Off: line breaks only change where there was already whitespace. |
format.rules.tidy_tags | true or false or on or off | true | One space between attributes, and <x /> for self-closing tags. Off: start tags are kept exactly as written. |
format.rules.wrap_attributes | true or false or on or off | true | One attribute per line for long start tags and tags already written that way. Off: tags are never wrapped or joined. |
format.rules.trim_trailing_whitespace | true or false or on or off | true | Remove spaces at the ends of lines of text. |
format.rules.collapse_blank_lines | true or false or on or off | true | Shrink runs of blank lines to max_blank_lines. |
format.rules.final_newline | true or false or on or off | true | End the file with exactly one newline. Off: the file ends as it did. |
format.rules.spacing | true or false or on or off | true | .kscript files: one space after commas and colons, around assignments and =>, and before a block's '{'. Off: spacing inside lines is kept. |
format.rules.brace_style | true or false or on or off | true | .kscript files: put else, elif, catch and finally on the line of the closing '}'. Off: they stay where they are. |
format.rules.wrap_strings | true or false or on or off | true | .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. |
format.rules.wrap_chains | true or false or on or off | true | .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. |
format.rules.wrap_bodies | true or false or on or off | true | .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. |
format.rules.wrap_comments | true or false or on or off | true | .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. |
format.indent | number | 2 | Spaces per indent level, or "tab" to indent with tabs. |
format.tab_width | number | 2 | With "indent": "tab", how many columns a tab counts as when lining up existing text. |
format.print_width | number | 80 | 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. |
format.max_blank_lines | number | 1 | Blank lines kept in a row; extra ones are removed. |
format.end_of_line | auto or lf or crlf | "auto" | Line endings to write. auto keeps the ones each file already uses. |
format.preserve | array | [] | Elements whose content is kept exactly as written, on top of <pre>, <textarea>, <script>, <style> and CDATA sections. |
format.include | array | ["**/*.kscript","**/*.ks.xml","**/*.html"] | 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. |
format.exclude | array | ["_templates","node_modules",".git"] | Files and folders kscript fmt leaves alone. |