New in 2.2

KryptScript

Krypton, but as a script. Same compiler, same syntax — just a .ks file you can chmod +x and run like bash or Python.

Why .ks?

Krypton has always been a great language for building libraries and compiled programs. KryptScript is the same Krypton, packaged for the moment you reach for a script instead of a binary — a one-off tool, a build step, a glue script between systems.

The convention is purely about naming. Same compiler, same syntax, same stdlib. The compiler treats .k and .ks identically. The split exists so a glance at a file (or a directory listing, or GitHub search) tells you the author's intent.

The split

.k — library or program

Declares module foo (or compiles into a program). Exports functions. No shebang. Built into a binary, then run.

// math.k
module math

func square(x) { emit x * x }
func cube(x)   { emit x * x * x }

Build: kcc -o math.lib math.k.

.ks — runnable script

Has just run { ... } and an optional #!/usr/bin/env kr shebang. Run directly with kcc -r or chmod +x — no separate build step.

#!/usr/bin/env kr
just run {
    kp("hello from a kryptscript")
}

Run: kcc -r hello.ks, or chmod +x hello.ks && ./hello.ks on POSIX.

When to use it

Reach for KryptScript whenever you'd otherwise reach for bash, PowerShell, or Python:

All the wins: same syntax as your production Krypton code, import anything from your project, real types and structs (no dynamic chaos), compile-time errors, and the full stdlib at your fingertips.

A bigger example

Renaming every file with one extension to another. Drop this into rename.ks, chmod +x, and ./rename.ks k ks:

#!/usr/bin/env kr
// rename.ks — batch-rename files matching a pattern
just run {
    if argCount() < 2 {
        kp("usage: rename.ks <from-ext> <to-ext>")
        exit(1)
    }
    let from = arg(0)
    let to   = arg(1)
    let files = shellRun("ls *." + from)
    let n = lineCount(files)
    let i = 0
    while i < n {
        let f = getLine(files, i)
        let base = substring(f, 0, len(f) - len(from))
        shellRun("mv " + f + " " + base + to)
        i = i + 1
    }
    kp("renamed " + n + " files")
}

Tooling support

Adoption is opt-in

Nothing about .ks forces existing code to change. Every .k file in your project keeps building and running exactly as it did. Adopt .ks when it's a clear win — typically the script files that already had just run + a shebang.

In the Krypton repo itself, the 2.2 rename pass converted nine script files (lsp/build, the lsp/test_* framing smoke-tests, and scripts/sweep / check_headers / diag_failures / sweep_tools / test_kbackend). Libraries like lsp/kls.k stayed .k because they're compiled to a long-running binary, not run as scripts.

Get started

KryptScript ships with Krypton 2.2 — no separate install. If you already have Krypton, you already have it. Try:

echo '#!/usr/bin/env kr
just run { kp("hi from a kryptscript") }' > hello.ks
kcc -r hello.ks

Or check the Downloads page for installers, and the Learn track for the full language tour.