KonsolScript

KonsolScript is a modern, lightweight embeddable scripting language built for tooling, automation, AI orchestration, and game scripting. Wire LLM APIs into automated pipelines, build AI-powered CLI tools, orchestrate multi-model workflows, or script interactive games — all with a clean, readable syntax that values clarity, portability, and extensibility.


I want to… Go to
Write .ks scripts Scripting Guide
Extend the engine or write a plugin Contributing Guide

What can you build?

From beginner CLI tools to AI-powered pipelines — KonsolScript's modules and plugins cover a wide range of real-world apps:

Quick demo — fetch a public API and parse the response:

// 46_curl_json.ks — HTTP fetch + JSON parse demo
//
// Install once, then run:
//   minks install curl        (from inside curl_plugin/)
//   minks tests/46_curl_json.ks
//
// Or load explicitly without installing:
//   minks --plugin curl_plugin\kse_curl.dll tests\46_curl_json.ks   (Windows)
//   minks --plugin ./curl_plugin/kse_curl.so tests/46_curl_json.ks  (Linux)

#include "curl"

Konsol:Print("=== Curl + Json Demo ===");

// fetch a post from the public JSONPlaceholder API
Var:String response;
Var:Number status;

try {
    Curl:Get("https://jsonplaceholder.typicode.com/posts/1", response);
} catch (CurlException e) {
    Konsol:Print("fetch failed: ${e.message}");
    Konsol:Exit(1);
}

Curl:Status(status);
Konsol:Print("HTTP ${status}");

// parse and extract fields
Json:Parse(response, post);

Var:Number userId;
Var:Number postId;
Var:String title;
Var:String body;

Json:Get("userId", post, userId);
Json:Get("id",     post, postId);
Json:Get("title",  post, title);
Json:Get("body",   post, body);

Json:Free(post);

Konsol:Print("Post #${postId} by user ${userId}");
Konsol:Print("Title: ${title}");
Konsol:Print("---");
Konsol:Print(body);

→ Full test: tests/46_curl_json.ks

Full project ideas — beginner to advanced


Table of Contents

  1. What can you build? — app ideas you can ship with the built-in modules and plugins
  2. Kookbook — full project ideas, beginner to advanced
  3. Var — types, variables, literals, string interpolation, structs
  4. Preprocessor#define and #include (file and plugin)
  5. Operators
  6. Control flow — if/else, while, for, foreach, break, continue, switch/case
  7. Functions
  8. Array — fixed-size typed arrays
  9. Class — OOP classes with fields and methods
  10. Object — root class for all user-defined classes
  11. Exception — built-in error carrier for try / catch
  12. Error handling — try/catch/finally, throw
  13. Built-in modules — Konsol, Math, String, File, Time, List, Map, Json, Path, OS, Regex, Date, Hash, CSV
  14. Plugin system
  15. Plugins — curl, ws, net, sqlite, mysql, pg, redis, zip, crypto, jwt

Var

Variables, types, literals, string interpolation, multi-line strings, comments, and struct (UDT) definitions.

Full Var reference


Operators

Arithmetic, comparison, logical, bitwise, assignment, ternary, and precedence.

Full Operators reference


Control flow

See Control flow for if / else if / else, while, for, break, continue, switch / case, and foreach.


Functions

Define reusable blocks, return typed values, and call recursively. An optional main entry point is called automatically.

Full Functions reference


Array

Fixed-size typed arrays. Size is set at declaration and does not change.

Full Array reference


Class

Full OOP with fields and methods. Every user-defined class implicitly extends Object.

Full Class reference


Object

Object is the implicit root of every user-defined class, providing getType(), toString(), and isInstanceOf().

Full Object reference


Exception

Exception extends Object and is the built-in structured error carrier for try / catch. Plugin typed exceptions also extend Exception.

Full Exception reference


Error handling

try / catch / finally, throw, typed exceptions (MathException, ArrayException), and error output format.

Full Error handling reference


Built-in modules

All stdlib calls use the Module:Method(args) syntax. Methods that return a value follow the ByRef convention: pre-declare a receiver variable and pass it as the last argument.

Var:Number h;
Time:GetHour(h);
Konsol:Print(h);    // current hour
Module Description
Konsol Terminal I/O, process control, ASCII utilities
Math Numeric operations, trigonometry, random
String String manipulation — trim, split, replace, compare
File File open/read/write/close
Time Wall-clock time, process timer
List Dynamic resizable typed array
Map String-keyed dictionary
Json Parse, build, and serialize JSON
Path Path manipulation and filesystem queries
OS Working directory, env vars, process control, dir listing
Regex Pattern matching and capture groups
Date Unix-timestamp date arithmetic and formatting
Hash MD5, SHA-256, Base64
CSV Parse, build, and serialize CSV

Plugin system

Plugins are shared libraries that extend KonsolScript with new modules — no recompile of minks needed.

Plugin system guide


Available plugins

See plugins.md for the full list — curl, ws, net, sqlite, mysql, pg, redis, zip, crypto, jwt.


Notes