Krypton, but as a script. Same compiler, same syntax — just a .ks file you can chmod +x and run like bash or Python.
.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.
.k — library or programDeclares 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 scriptHas 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.
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.
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")
}
.ks as a source file in every mode (-r, -o, --ir, --c, -e). Output basenames strip .ks before .k..k and .ks under the same Krypton.Source ProgID, so the icon and double-click action match.kls-powered diagnostics, KryptScript alias in the language picker..gitattributes paints .ks as Krypton via linguist — your script directory stops looking like shell.kr wrapper resolves through kcc -r so #!/usr/bin/env kr works on macOS and Linux.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.
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.ksOr check the Downloads page for installers, and the Learn track for the full language tour.