Working on KScript
KScript is open source, and contributions are welcome. This page covers building it from source, how the repository is laid out, and how it is tested.
Building from source
KScript targets .NET 8 and runs on Windows, Linux and macOS. Install the .NET 8 SDK, then:
dotnet build KScript.sln
dotnet test KScript.sln
# Run a script
dotnet run --project KScriptApp -- "path/to/script.xml"
To build a single-file kscript binary for your machine:
dotnet publish KScriptApp -c Release -r osx-arm64 --self-contained \
-p:PublishSingleFile=true -p:IncludeNativeLibrariesForSelfExtract=true -o out
Repository layout
| Path | Contents |
|---|---|
KScript.Syntax/ |
The parser shared by the interpreter and the editor tools: markup, expressions, { } templates, and the metadata types elements and commands are described with. |
KScript.Core/ |
The interpreter (Runtime/), the KScript.Core package (variables, control flow, functions, errors, <echo>, value methods), the package system and kscript.json (Projects/). |
KScript.Terminal/, KScript.Math/, KScript.IO/, KScript.Net/, KScript.Markdown/, KScript.AI/, KScript.Style/, KScript.Storage/, KScript.Cache/, KScript.Auth/, KScript.Data/, KScript.Queue/, KScript.Mail/, KScript.Document/ |
Each package registers its elements, commands and methods with their documentation. |
KScript.Web/ |
The kscript serve page engine (Pages/) and the KScript.Web package. |
KScript.Http/ |
Routes, controllers and middleware: the KScript.Http package, the route table (Routing.cs), request handling (HttpApp) and the built-in middleware. |
KScript.UI/ |
Desktop windows: the KScript.UI package, the redraw model (UISession) and the Avalonia host that shows it on macOS, Windows and Linux. |
KScript.Test/ |
The KScript.Test package and kscript test: finding test files, running them, and the console and JUnit reports. |
KScript.Cli/ |
kscript make (Scaffolding/, built-in templates in Scaffolding/Templates/, the kscript make project templates in Scaffolding/Projects/web/ and Scaffolding/Projects/bare/, each described by its kscript-template.json), kscript ide, kscript update and kscript compile (Compile/: the single-file bundle reader and writer, package trimming, Windows resources, Mac signing and icons). |
KScript.Docs/ |
kscript docs: the docs website, built from docs/*.md and the language catalog, with the sandbox (Playground) that runs its examples. The examples of commands and methods live with them, in each package’s p.Examples(...). |
KScriptApp/ |
The kscript command line app. |
KScript.Language/, KScript.LanguageServer/ |
The analyzer and editor features, and the LSP server behind kscript lsp and kscript check. They read what each package registers, so the editor always matches the interpreter. |
KScript.Tests/, KScript.Language.Tests/ |
xUnit tests for the interpreter and packages, and for the language tools (including contract tests that keep them in step with the packages). |
libraries/ |
KScript source libraries published by kylepantall/kscript. The Isolink SDK lives in a separate repository under the trusted publisher waggr-gb. See waggr-gb/isolink-connect. |
editors/vscode/ |
The VS Code extension. |
samples/scripts/ |
Sample scripts. Every sample is a .kscript file. |
samples/xml/ |
The scripts of samples/scripts/ in the XML form: the one set of samples kept in XML. |
samples/life-lab/ |
Life Lab: one KScript program that runs in a terminal, in the browser and as a desktop app. |
samples/auth-app/ |
A site with accounts, made by kscript make auth --api (see Sign-in). |
Example Sites/team |
A sample kscript serve site. |
Tests and CI
KScript.Tests covers the interpreter, every package, kscript serve pages, kscript make, kscript.json and the sample scripts; KScript.Language.Tests covers the analyzer, the editor features and the language server. Run them with dotnet test KScript.sln.
Add runnable language examples to samples/scripts/tests/language. Run kscript test samples/scripts/tests/language for their runtime results and kscript check samples/scripts/tests/language --warnings-as-errors for diagnostics. The VS Code extension tests also open these scripts through the language server. They exercise completion, navigation, test discovery and edits to unsaved buffers.
Editor behaviour is pinned by scenarios in KScript.Language.Tests/Editor/EditorScenarios.cs. Each one edits a file of a small project (KScript.Language.Tests/Fixtures/project: posts, comments, a status enum, a migration, routes, a component and tests), puts a ‸ caret where someone would be typing, and checks what completion, diagnostics, hover, navigation, colours or quick fixes give there:
S("enum-field-default", "models/post.kscript", "status: Status = 'draft'", "status: Status = ‸", CompletesOnly("draft", "published", "archived")),
Write a scenario as the editor should behave. If it doesn’t pass yet, add .Until("PR n: ..."): the test then requires it to fail, and tells you to remove the Until once a change makes it pass. KSCRIPT_SHOW_PENDING=1 dotnet test --filter EditorScenarioTests shows why each pending one still fails.
After a Release build, run the editor suites from editors/vscode.
npm ci
npm test
npm run smoke -- ../../KScriptApp/bin/Release/net8.0/KScript.dll
npm run test:vscode -- ../../KScriptApp/bin/Release/net8.0/KScript.dll
smoke starts the server and sends JSON-RPC requests. test:vscode runs the extension in VS Code. On headless Linux, prefix the latter command with xvfb-run -a.
Editor regression tests
Changes to user-facing language syntax, component directives, fields and package APIs require editor regression tests alongside the runtime tests. Test completion on an unfinished example at the caret where a developer would type. Assert the suggestions that belong there, the edit made by accepting one, and a nearby position where those suggestions must be absent. Cover each supported source form, including fenced component HTML when applicable.
For fields with a declared or inferred type, check that incompatible values stay out of the list. For enum fields, assert the exact allowed choices. When a change affects trigger characters, embedded languages, snippets or highlighting, exercise it through the VS Code extension too.
CI jobs
Every push to master and every pull request runs the CI workflow, which restores, builds and tests the solution in Release mode, runs samples/scripts/oldest.kscript, checks the sample scripts with kscript check, checks their formatting with kscript fmt --check and runs their KScript tests with kscript test, on three platforms:
- Linux runs on a self-hosted runner (
home-ci). Pull requests from forks always use a GitHub-hostedubuntu-latestrunner instead, so untrusted code never runs on the self-hosted machine. The solution is built once, in theBuild and test (linux)job, and the other Linux jobs (the project templates, the VS Code extension and the database servers) download that build instead of compiling their own. - Windows and macOS run on GitHub-hosted
windows-latestandmacos-latestrunners.
Native AOT
A CI job also publishes kscript with Native AOT on each platform (-p:PublishAot=true) and runs scripts, kscript serve, kscript docs, kscript mcp and the language server with it. The same job publishes the single-file runtime that kscript compile makes programs from, and compiles a script, Life Lab and a site with it. Releases still ship the single-file build; the job keeps the AOT build working so it stays an option. It fails on any new trim or AOT warning, so:
- Write JSON with
JsonNode/JsonObjector a source-generatedJsonSerializerContext(seeOpenApiJsonContext), notJsonSerializer.Serialize(object). Add to aJsonArraywitharray.Add((JsonNode)value): the genericAdd<T>isn’t AOT-safe. - A new built-in package needs a
DynamicDependencyonPackageRegistry.Getas well as its line inPackageRegistry.BuiltIn;NativeAotTestschecks the two lists match.
To try it locally: dotnet publish KScriptApp/KScriptApp.csproj -c Release -r linux-x64 -p:PublishAot=true -o aot (needs clang and zlib1g-dev). KScript.AI calls the Messages API directly rather than through the Anthropic SDK, because the SDK serialises with reflection.
Changing a command, method or element
The reference in kscript docs, editor completion and hover, and kscript check all read the same catalog: what each package registers in its Register method. Change a command’s parameters there and every one of them changes with it.
Arguments are matched to parameters by one BindingPlan (KScript.Syntax/Metadata), which the runtime binds with and kscript check checks with, so the two always agree about a call. A parameter’s declared type does the checking for the handler. The binder converts int, float, number, bool, date and duration arguments, and refuses null or blank text for string(min: 1), before the handler runs. Each type has one error message, so don’t check the value again in the handler:
p.Command("route", "name: string(min: 1), params...", "...", KType.String,
c => table.Url((string)c.Arg(0), c.Named)); // name is already nonempty text
A handler that accepts looser forms on purpose sets $Info.KeepsArgumentsAsGiven = true. Its arguments then arrive as they were written.
The basic types (string, int, list, date, markdown, …) are rows of one table, BasicTypes (KScript.Syntax/Metadata). Each row gives a type’s description, case rule, whether extend, is_a and @bind take it, and its JSON Schema. The editor, the runtime and the docs all read that table. The order in which a value’s methods are looked up (its record kind, semver[], its own type, map for a record, number for text that holds one, string for an email, then any) is MethodReceivers.CandidatesFor. The interpreter dispatches by it and the editor ranks completions by it.
When the editor checks something only one package’s element or command does, the package says what the thing is as it registers it, and the analyzer reads that, never the package’s name. An element declares its Role (ElementRole.Model, Job, Policy, Route…) and a command or method its Info.Role (CallableRole.Sql, Table, Records, Ability, RouteUrl…):
p.Element(new ElementInfo("job", "...", ContentKind.Statements, ...) { Role = ElementRole.Job }, RunJob);
p.Command("sql", "text, as?, connection?", "...", KType.Any, RunSql).Info.Role = CallableRole.Sql;
CatalogContractTests fails when a role is declared by nothing that ships. Word tables that the parser, the analyzer and the runtime all need live once in KScript.Syntax: Lexicon.ModelSettings (a model’s settings, their form and whether a mixin passes them on; KScript.Data checks them against <model>’s attributes as it registers), ForeignHabits (print, function, @len() and what KScript calls them, so the runtime gives the editor’s hint) and, in KScript.Web, PageElementNames.Control (KScript’s page elements, with how the template treats each).
To retire something, deprecate it first, so scripts keep working while they move off it:
p.Deprecate("@read_file", "Reading text has a clearer name", "@read_text"); // a command
p.Deprecate("@api(retries)", "Requests are retried for you"); // one of its parameters
p.Deprecate("string->shout", "", "->upper"); // a method
p.Deprecate("<beep>", "", "<sound>"); // an element
p.Deprecate("<sound tone>", "Renamed", "pitch"); // one of its attributes
The first text says why and the second is what to use instead, as written in a script. Then:
kscript checkand the editor warn (KS4008) where the script uses it, with a quick fix when the replacement is a plain rename.- Completion shows it struck through and lists it last, and hover says it is deprecated.
- The reference strikes it through, labels it deprecated and shows why and what to use instead.
Deprecate throws if the key names nothing, so removing a parameter later can’t leave a stale deprecation behind.
The guides in docs/ and the README are written by hand, so a test keeps them honest: DocsTests.Every_example_in_the_guides_and_readme_matches_the_code checks every kscript and xml example with the analyzer. It fails if an example uses an element, attribute, command, method or parameter that no longer exists, passes the wrong number of arguments, or uses something deprecated.
The docs tests require every playground example to convert to both formats and run each one. The tests parse JSON fences and check the syntax of KScript and XML fences, including examples that contain a fenced string. To test an intentionally broken example in the error guide, label its fence kscript wrong KS1001 (using the code it should report). Add a case to DocsTests.Runnable_reference_examples_produce_the_expected_output when an example demonstrates a specific result readers should be able to verify.
Changing a command-line option
Every kscript command and its options are written once, in CliReference (KScript.Core/Output). kscript --help, kscript help <command>, the docs site and each command’s own usage line read it, so they can’t disagree. An option is written as help shows it: --port, -p N is --port, also -p, and takes a value; --check is a flag; --no-reload is read as reload: false. A command reads its arguments with that entry:
CliArgs options = CliReference.Parse("css", args);
if (CliReference.OptionProblem("css", options) is string problem) return CliFail.Usage(error, problem);
string outDir = options.Value("out");
OptionProblem gives one wording for an option the command doesn’t have, and for a flag in CliFlags.RetiredFlags it says what the flag was renamed to. CliFail stops a command the same way everywhere: CliFail.Usage for a command line or kscript.json that can’t be used (exit code 2) and CliFail.Failed for work that couldn’t be finished (exit code 1). To add an option, add it to the command’s entry in CliReference and read it from CliArgs.
The rules the engine enforces
The naming and shape rules are not only tests: the engine applies them as a package registers. They live in one class, Conventions (KScript.Core/Runtime/Conventions.cs), as lists of names and one small check per rule. PackageBuilder (p.Element, p.Command, p.Method, p.Field, p.Variable, p.EchoFormat, p.LogProvider, p.NativeType) asks it about every registration and throws a ConventionException for one that breaks a rule, so the package doesn’t load:
KScript.Cache registers argument 'max-age' on 'cache': arguments are snake_case (max_age).
Each registration is checked on its own:
- Elements. A name is PascalCase or snake_case, with no hyphen. KScript.UI, KScript.Http and KScript.Document describe things with PascalCase elements (
Conventions.ThingPackages). In KScript.Data,Migrationand its steps, such asCreateTable, use PascalCase (Conventions.ThingsInside). Other elements use snake_case. A name inRetiredcan’t come back. - Arguments. snake_case, each listed once.
tois a destination and never declares a variable;intoalways does; an argument that declares a variable is calledname,into,as,eachorat(neverindex). A file ispath(notsrc,file,filename,sourceorsample). A list is a list kind or$NameList = true, never text “separated by commas”. An argument that names a function shows@namein its description. An argument renamed inRetired.RenamedAttributescan’t come back. - Commands, methods and parameters. snake_case. Something that returns
boolis namedis_xorhas_x, unless it is inConventions.VerbQuestions(contains,starts_with, …) and takes an argument, or inConventions.ActionsThatReport(remove,save, …); and anis_xorhas_xreturnsbool.counttakes no arguments and there is nolength. Keyed things useget,set,hasandremove(noput,forget, …), and only the logger hasflush. A description doesn’t call its command another name for something (“the same as”, “alias”). Nothing inRetired.CommandsorRetiredMemberscomes back. - Fields. snake_case; a
boolfield isis_xorhas_x(orexists) and the other way round;countandlengthare never fields. - Lengths of time. An argument or parameter called
timeout,ttl,every,delay,wait,backoff,duration,expires,lockoutor ending in_for,_after,_until,_timeoutor_ttlis declared as a duration, and none is named for a unit (ms,seconds, …). - Words. Every name says
color. Descriptions say true and false, never yes and no, and the description of anis_xorhas_xstarts with “True”. - Variables, echo formats, log providers and native types are snake_case; error types are PascalCase and only
Erroritself ends in Error; the settings a section ofkscript.jsondeclares are snake_case. Each section is a row ofSettingsSections(KScript.Core/Projects): the reader’s “unknown setting” warning lists its keys from there, andProjectConfigTestschecks that the editor schema (editors/vscode/schemas/kscript.schema.json) lists the same keys and allows no others, and that the reader takes each one. To add a setting, add its key to the section’s row, read it inProjectConfig, and describe it in the schema. - Operators. Every operator is a row of
OperatorTable(KScript.Syntax/Grammar): its text, its kind and its hover text. The lexer, the parser’s assignments, hover, type inference, the analyzer’s maths checks and the native types’ operator declarations read it.OperatorScenariosbuilds an editor test for each row in every spacing, so a new operator gets its caret tests (no error, hover, the values shown after it, the error for a space inside it) without writing them, andOperatorAgreementTestschecks a query gives the same rows as a script for each maths operator. - Native types. Each one is a subclass of
NativeType(KScript.Core/Runtime/Natives, one per file), listed inNativeTypeRegistry.BuiltInor registered by a package withp.NativeType(...). The base class’s abstract members make it declare its parsing, its unquoted form,Equality,Ordering,Iteration, operators, members, list filters and list methods, string methods and editor completions, so a new type can’t leave one out. An operator names the type on each side and the result’s type, one side is always the declaring type, and each pairing has one meaning in the whole language (NativeOperators, checked byNativeTypeRegistry.Register). The runtime and the editor both read these declarations.DurationTypeis the one to copy. A native type’s name is checked byConventions.Namewhen it registers.
Rules about several registrations are checked by Conventions.Together, when a package has finished registering and again when the registry has loaded every package (PackageRegistry.LoadAll), so they hold across packages too:
- a type has each method and each field once, and a name is a field or a method of a type, never both;
- a method with no arguments on a type that has fields is a field, unless it is in
Conventions.ZeroArgumentMethodswith the work it does; - a type with
getandsethashasandremove, and nodelete; - no two commands, and no two methods of a type, share a description;
- a name is a statement or a command, not both, apart from
Conventions.StatementAndCommand; - no command only repeats a method of its first argument, apart from
Conventions.DeliberatePairs, and those pairs take the same parameter names.
Every allow-list is in Conventions, is short, and gives the reason for each entry; to allow a new exception, add it there with its reason. Conventions.Tables checks the lists and the retired tables against everything that ships (a retired name points at one that exists, no entry has gone stale); it needs every package installed, so the tests run it rather than the runtime.
The checks are plain string comparisons, with no reflection and no regular expressions, so they are cheap: in the released (Native AOT) kscript a script starts as fast as before, within a millisecond or two. A build that runs under the JIT (dotnet run, the tests) pays about 25 ms once to compile them. The tests in KScript.Tests/Conventions/ call the same checks: ConventionEngineTests proves that every package that ships loads clean and that each rule fires (it registers something wrong in a throwaway package and reads the message), and the other files apply one rule at a time to the whole catalog, including the elements that are only planned. To add a rule, add a check to Conventions, call it from Element, Callable, Field or Together, list it here, and add a test that breaks it.
JSON keys
JSON that KScript defines is snake_case, like the rest of the language: kscript check --output json writes end_line and new_text, and kscript.json reads warnings_as_errors. JSON whose shape another specification owns follows that specification, so the language server writes LSP’s textDocument and newText, the MCP server writes MCP’s inputSchema, and kscript openapi writes OpenAPI’s operationId. AgentDocsTests.CheckJsonKeysAreSnakeCase reads every key kscript check writes.
Rules about what a script, a sample or a guide writes (quotes, true/false, one spelling per piece of syntax) are the old-spelling rules (KS6006, KS6009 to KS6012, KS6014) with their own tests, not part of Conventions. In a .kscript file each is an error in kscript check and at run time, from one list (OldSpellings in KScript.Syntax) that both read, so a new one is added there with its message and its fix.
How the standard packages behave
Every package follows the same rules, so what you learn in one works in the next. The engine refuses a package that breaks one (see above), and StdlibBehaviourConventionTests applies them to the whole catalog.
A name that answers true or false starts with is_ or has_. $ip.is_private, $response.is_ok, $password->is_strong(), @is_signed_in(), $cache->has(key). The only other names allowed are verbs that ask a question about an argument, such as ->contains(x), ->starts_with(x), ->matches(x) and @exists(path), and actions that report whether they worked, such as ->remove(key). Both lists are short and are written out in Conventions. Descriptions say “True when …”.
A plain fact is a field; a method takes arguments or does work. A field is read with a dot and no brackets: $response.status, $file.name, $file.size, $date.year, $e.status. A method is called with ->: $response->convert(from: json), $file->read_text(), $date->format('yyyy'). A package adds a field with p.Field(receiver, name, type, description). Calling a field ($response->status()) is an error that says to drop the brackets. A value whose fields are the user’s own (a record’s columns, a map’s keys, $config’s settings) keeps its own facts as methods, so they can’t clash with a column or setting of the same name.
Counting is ->count() everywhere. A list, a text and a map have no fields of their own (a map’s are the user’s keys), so “how many” is the method on all three, and on a query, a range and a fake queue too: $list->count(), $name->count(), $map->count(). It takes no arguments. “How many match” is ->count_of(match). There is no ->length() and no .count or .length field.
One name for each thing. The engine refuses a second spelling, and StdlibNameConventionTests walks every command and method to prove none ships. Methods are the main form: there is no command that only repeats a method of its first argument ($text->upper(), not @to_upper($text)), apart from a short list (Conventions.DeliberatePairs), such as KScript.Math’s @sqrt(x) beside $x->sqrt(). A command and a method with the same name take the same parameter names. An action has one form: a command when it takes values and gives a value back (@move(from, to), @download(url, to), @assert(condition), Job(...)->dispatch()), a statement only when it needs a block or prompt text (transaction { }, llm, <respond> in a page). Every identifier says color; prose stays British.
A name that is taken away says what to write instead. Retired (KScript.Core/Runtime/Retired.cs) holds removed statements, arguments and commands, and RetiredMembers holds removed methods by receiver type. The runtime stops with the replacement and the editor offers a quick fix when it is a plain rename. Nothing retired keeps working.
One method takes the options; yes/no options are flags. When an action has variants, give it one method with named arguments rather than a method per option: $url->with(path: '/docs', fragment: 'top') and $url->without(query, fragment), not ->with_path(), ->with_fragment() and ->without_query(). Every yes/no option is a plain bool parameter named for what it turns on (ignore_case, overwrite, binary, after_commit), so callers write the bare word, or not and the word: ->contains('ada', ignore_case), ->convert(from: csv, not header). Docs, stubs and samples use that form, never name: true. When options fold into one method, the old methods are retired with a “renamed to” error.
Settings are read one way. $config.database.host, and $config->get('database.host', 'localhost') when the path is built at run time or needs a default.
Things kept by key use get, set, has and remove. clear empties the whole thing. delete is for files and records ($storage->delete(name), $record->delete(), kscript queue delete). flush only ever means “write out what is being held back” ($log->flush()). Storage reads and writes files, so it keeps read, write and delete.
A length of time is a duration. wait(duration: 500ms), Timer(every: 100ms), test(timeout: 5s), @api($url, options: { timeout: 30s }), job(timeout: 5m), $cache->set(key, value, ttl: 10m). A duration is written as a number and a unit with no quotes: ms, s, m, h, d or w, and they can be joined (1h30m). A plain number is always seconds. There are no ms: or seconds: arguments. Declare an attribute as a duration with new A(name, K.Expression, ...) { Type = Duration.TypeName } and a parameter as name?: duration, and read it with run.Seconds(name) or Duration.Seconds(value, what).
A few fixed words are a word union. Declare the attribute as new A("font", K.Enum, ...) { Type = "serif|sans|mono" }, and a parameter as font?: serif|sans|mono. A list of them is (a|b)[] with $NameList = true. Quote a word that is also a type’s name (text|'json'), or build the type with WordUnion.Write(words). An Enum attribute can’t take a list of options, and the package builder refuses one whose type isn’t a word union. Names of fields are field types. Use Self.fields[] for the fields of the element itself (a model’s hidden:, a job’s unique_by:), table.fields[] for the table another argument names, and model.fields[] for the model it names.
A table takes the same arguments everywhere. The terminal’s table and a document’s Table both take rows (a list of maps, or a list of lists whose first row is the headings), columns (a list of keys, or a map from heading to key), align (a list of left, center or right) and header: false for no heading row. Both read them with TableArguments.
Writing an error message
A script is a .kscript file or an XML one, and a message is written once for both. Write it in XML terms, as an interpolated string given straight to the error:
throw run.Error($"<{run.Name}> needs a {name} attribute, such as <{run.Name} {name}=\"5\" />.", name, "Syntax");
The compiler turns that string into a Wording (KScript.Syntax/Text/Wording.cs). An XML script gets it as written. A .kscript file gets it in its own terms: tags become statements as the converter writes them, name="value" becomes name: value, and “element” and “attribute” become “statement” and “argument”. Only the words in the source are changed. The values put into the holes are left alone, and so is any plain string, such as a message a script wrote itself.
new KScriptException($"..."),run.Error($"..."),c.Error($"...")and the analyzer’sReport(..., $"...")all take aWording.- A message joined with
+or picked with?:is a plain string, so wrap each part that has XML wording:Wording.Of($"Unknown element <{name}>.") + (close != null ? Wording.Of($" Did you mean <{close}>?") : null). Wording.Prose(text)rewords text that was written elsewhere, such as an attribute’s description.Wording.Snippet(xml)converts a line of XML script.new Wording(xml, code)gives each form its own sentence when rewording wouldn’t say it well.- To pass an error’s message on, use
ex.Words, notex.Message.
DiagnosticConventionTests holds the guards: it runs a list of failing scripts as .kscript and fails if a message shows a tag, name="value", “attribute” or “element”, and it scans the source for messages with XML wording that are plain strings. Raise a built-in error type by its constant, new KScriptException($"...", ErrorTypes.NotFound) or run.Error($"...", "path", ErrorTypes.Argument), never as text: the constants are the built-in types, so a type that isn’t declared in ErrorTypes.cs doesn’t build. The same file checks that no raise writes its type as text, that each built-in type is listed in the language guide, and that every diagnostic code is reported somewhere and documented in errors.md in numeric order.
Syntax highlighting on GitHub
GitHub highlights code with Linguist, which only knows the languages that have been added to it. A repository can’t bring its own grammar, so until KScript is in Linguist:
- Code blocks in Markdown use
```kscriptfor scripts (GitHub shows them as plain text; the docs site and the editor colour them),```xmlfor the XML form and```htmlforkscript servepages. .gitattributesmarks*.ks.xmlfiles as XML, so they are highlighted in the file view and counted as XML in the language bar.
KScript already has a full TextMate grammar in editors/vscode/syntaxes/kscript.tmLanguage.json, the format Linguist uses. Linguist adds a new language once its file extension is used in at least 200 different repositories on GitHub. When KScript gets there, the grammar can be submitted to Linguist, and ```kscript code blocks and .ks.xml files will then be highlighted as KScript everywhere on GitHub.