npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

kode-lang

v0.1.0

Published

Kode — A token-efficient, full-stack programming language for AI agents. 48% fewer tokens than Python.

Readme


What is Kode?

Kode is a new programming language designed from the ground up for AI agents. It uses 48% fewer tokens than Python for the same logic, has built-in agents, memory, and state machines, and can build complete web applications — all in one language.

-- A complete web API in 8 lines of Kode
lt db = db.open("sqlite:app.db")
db.exec("create table if not exists items (id integer primary key, name text)")

web.route("GET", "/api/items", |req| -> web.json(db.query("select * from items")))
web.route("POST", "/api/items", |req| {
  db.exec("insert into items (name) values (?)", @[req.body.name])
  rt web.json(@{ok|tr})
})
web.serve(3000)

Why Kode?

The Problem

AI agents waste 70% of tokens on boilerplate. Python's verbose syntax, JSON overhead, and lack of agent primitives cost billions in unnecessary API spend. 95% of AI agent projects fail in production.

The Solution

Kode is designed so AI agents can write less code, do more work.

| | Python | JavaScript | Kode | Savings | |---|--------|-----------|----------|-------------| | Web search agent | 340 tokens | 285 tokens | 185 tokens | -46% | | Multi-agent collab | 420 tokens | 310 tokens | 195 tokens | -54% | | Web API + database | 380 tokens | 320 tokens | 215 tokens | -43% | | Error handling | 310 tokens | 250 tokens | 155 tokens | -50% | | Data pipeline | 290 tokens | 245 tokens | 155 tokens | -47% | | Total | 1,740 | 1,410 | 905 | -48% |

7 Features Nobody Else Has

| Feature | What it does | |---------|-------------| | Self-healing code (@recover) | Auto-captures context + retries on failure | | Cost awareness (budget) | Track token spend, estimate costs, enforce limits | | Per-agent sandboxing (allow/deny) | Fine-grained permissions per agent | | Intent-based (ensure) | Declare what, not how — runtime figures it out | | Built-in contracts (pre/post) | Validate inputs/outputs, catch 60-80% of bugs | | Token-optimized syntax | 2-char keywords + TOON data format | | 4-type memory | Working, semantic, episodic, procedural — built in |


Quick Start

# Clone and install
git clone https://github.com/kanishka089/Kode.git
cd Kode
npm install

# Run your first program
npx tsx src/index.ts examples/hello.kd

# Start the REPL
npx tsx src/index.ts

# Run tests
npm test

Syntax

Variables

lt name = "Kode"          -- immutable (cannot reassign)
vr count = 0              -- mutable (can reassign)
count += 1                -- compound assignment

Functions

fn add(a, b) { rt a + b }          -- block body
fn double(x) -> x * 2              -- arrow (single expression)
lt sq = |x| -> x * x               -- lambda
lt apply = |f, x| { rt f(x) }      -- lambda with block

Control Flow

-- if / ef (else-if) / el (else)
if x > 10 { io.out("big") } ef x > 0 { io.out("small") } el { io.out("zero") }

-- while loop
wl n > 0 { n -= 1 }

-- infinite loop with break
lp { if done { br } }

-- for-each with range
fr i : 0..10 { io.out(i) }

-- for-each with list
fr item : my_list { io.out(item) }

-- match (pattern matching)
mt status {
  1 -> io.out("active")
  2 -> io.out("paused")
  _ -> io.out("unknown")
}

TOON Data Format

TOON (Token-Optimized Object Notation) uses 30-45% fewer tokens than JSON.

-- Maps: @{key|value}
lt user = @{name|"Ada" age|30 role|"dev"}
io.out(user.name)         -- Ada
io.out(user.age)          -- 30

-- Lists: @[elements]
lt nums = @[1 2 3 4 5]
io.out(nums[0])           -- 1
io.out(len(nums))         -- 5

-- Nested
lt config = @{
  db|@{host|"localhost" port|5432}
  cache|@{ttl|3600}
}
io.out(config.db.host)    -- localhost

Strings

-- Interpolation with ${}
lt name = "World"
io.out("Hello ${name}!")            -- Hello World!
io.out("2 + 3 = ${2 + 3}")         -- 2 + 3 = 5

-- Raw strings (no interpolation)
lt raw = 'no ${interp} here'       -- literal text

-- Multi-line
lt body = """
  line one
  line two
"""

Pipes

-- Chain operations left to right
lt result = @[1 2 3 4 5 6 7 8 9 10]
  |> lst.filter(|x| -> x % 2 == 0)     -- [2 4 6 8 10]
  |> lst.map(|x| -> x * 10)            -- [20 40 60 80 100]
  |> lst.take(3)                        -- [20 40 60]

Error Handling

tx {
  lt data = risky_operation()
} ct e {
  io.out("Error: " + e)
} fy {
  cleanup()
}

-- Throw errors
tw "something went wrong"

Agents

Kode has first-class support for AI agents. Agents are independent units with their own state, message handlers, and memory.

Define an Agent

ag Researcher {
  vr findings = @[]

  on "start" () {
    io.out("Researcher ready")
  }

  on "search" (p) {
    lt result = "Found: " + p.query
    findings = findings + @[result]
    em "Writer" @{type|"write" data|result}
  }
}

Spawn and Communicate

lt r = sp Researcher           -- spawn agent
em r @{type|"search" query|"AI trends"}  -- send message

Multi-Agent Pipelines

ag Researcher {
  on "search" (p) {
    em "Writer" @{type|"write" data|"Found: " + p.query}
  }
}

ag Writer {
  on "write" (p) {
    em "Reviewer" @{type|"review" article|"Article: " + p.data}
  }
}

ag Reviewer {
  on "review" (p) {
    io.out("APPROVED: " + p.article)
  }
}

lt r = sp Researcher
lt w = sp Writer
lt v = sp Reviewer
em r @{type|"search" query|"AI agents 2026"}
-- Output: APPROVED: Article: Found: AI agents 2026

State Machines

st OrderFlow {
  "pending" { on "pay" -> "paid" }
  "paid"    { on "ship" -> "shipped" }
  "shipped" { on "deliver" -> "delivered" }
  "delivered" {}
}

lt order = OrderFlow.new()
io.out(order.state)        -- pending
order.send("pay")
io.out(order.state)        -- paid
order.send("ship")
io.out(order.state)        -- shipped

Memory System (4 types)

-- Working memory (volatile, current session)
mem.w.set("task", "analyze data")
mem.w.get("task")

-- Semantic memory (persistent facts)
mem.s.store("user:ada", @{name|"Ada" role|"dev"})
mem.s.recall("user:ada")
mem.s.search("user", 5)        -- search by keyword

-- Episodic memory (event log)
mem.e.log(@{event|"login" user|"Ada"})
mem.e.last(10)                  -- last 10 events

-- Procedural memory (learned functions)
mem.p.learn("greet", |name| -> "Hello, " + name + "!")
lt greeter = mem.p.use("greet")
greeter("Ada")                  -- Hello, Ada!

Full-Stack

Kode can build complete web applications — server, database, HTML, API — without any other language.

Web Server

web.route("GET", "/", |req| -> web.html("<h1>Hello Kode!</h1>"))
web.route("GET", "/api/status", |req| -> web.json(@{ok|tr}))
web.route("POST", "/api/data", |req| {
  io.out(req.body)
  rt web.json(@{received|tr})
})
web.serve(3000)

Database (SQLite built-in)

lt db = db.open("sqlite:app.db")
db.exec("create table users (id integer primary key, name text, email text)")
db.exec("insert into users (name, email) values (?, ?)", @["Ada" "[email protected]"])

lt users = db.query("select * from users")
fr u : users { io.out(u.name + " — " + u.email) }

lt one = db.get("select * from users where id = ?", @[1])
io.out(one.name)    -- Ada

Complete Todo App (~60 lines)

lt store = db.open("sqlite:todos.db")
store.exec("create table if not exists todos (id integer primary key autoincrement, title text, done integer default 0)")

web.route("GET", "/api/todos", |req| -> web.json(store.query("select * from todos")))
web.route("POST", "/api/todos", |req| {
  store.exec("insert into todos (title) values (?)", @[req.body.title])
  rt web.json(@{ok|tr})
})
web.route("DELETE", "/api/todos/:id", |req| {
  store.exec("delete from todos where id = ?", @[req.params.id])
  rt web.json(@{ok|tr})
})
web.serve(3000)

Extensions & Decorators

Extension Functions

Add methods to existing types:

ext str {
  fn is_email() -> str.contains(self, "@")
  fn shout() -> str.upper(self) + "!"
}

"[email protected]".is_email()    -- tr
"hello".shout()                -- HELLO!

ext num {
  fn clamp(min, max) {
    if self < min { rt min }
    if self > max { rt max }
    rt self
  }
}

15.clamp(0, 10)                -- 10

Decorators

@cached
fn fib(n) {
  if n <= 1 { rt n }
  rt fib(n - 1) + fib(n - 2)
}
fib(30)    -- instant (cached)

@log
fn process(data) { rt data + 1 }

Contracts

fn transfer(from, to, amount) {
  pre: amount > 0
  pre: from >= amount
  post: result >= 0
  rt from - amount
}

transfer(100, 50, 30)    -- 70 (passes contracts)
transfer(100, 50, -1)    -- ERROR: Precondition failed

Built-in Testing

fn add(a, b) { rt a + b }
fn fib(n) { if n <= 1 { rt n }; rt fib(n - 1) + fib(n - 2) }

#test "addition" {
  assert_eq(add(2, 3), 5)
  assert_eq(add(-1, 1), 0)
}

#test "fibonacci" {
  assert_eq(fib(0), 0)
  assert_eq(fib(10), 55)
}

#test "strings" {
  assert(str.contains("hello world", "world"))
  assert_ne(str.upper("hi"), "hi")
}
$ kode test examples/tests.kd
  ✓ addition
  ✓ fibonacci
  ✓ strings
3 tests: 3 passed, 0 failed

Stdlib

Kode ships with 30+ standard library modules — no external packages needed.

Core

| Module | Key Functions | |--------|-------------| | io | out, err | | math | abs, floor, ceil, round, sqrt, random, min, max, pi | | str | split, join, trim, upper, lower, contains, replace, starts, ends | | lst | map, filter, reduce, find, sort, unique, chunk, zip, join, flat | | mp | keys, values, has, len |

Data

| Module | Key Functions | |--------|-------------| | json | parse, to_str, to_compact | | csv | parse, to_str | | yaml | parse, to_str |

Web & Database

| Module | Key Functions | |--------|-------------| | web | serve, route, json, html, redirect | | db | open, exec, query, get, close |

Agent System

| Module | Key Functions | |--------|-------------| | mem.w | set, get, has, delete, keys, clear | | mem.s | store, recall, search, keys | | mem.e | log, last, all, len, clear | | mem.p | learn, use, has, list | | stream | from, map, filter, reduce, batch, take, skip, collect |

System

| Module | Key Functions | |--------|-------------| | fs | read, write, exists, list, mkdir, remove, stat | | env | get, set, has, load | | proc | exec, cwd, platform, args, exit |

Security & Encoding

| Module | Key Functions | |--------|-------------| | crypto | sha256, sha512, hmac, random_bytes | | enc | base64, base64_decode, url_encode, url_decode, hex | | uuid | v4 | | re | match, test, replace, split, find_all | | url | parse, build | | log | debug, info, warn, error |

AI & Meta

| Module | Key Functions | |--------|-------------| | ai | ask, auto, models, token_count | | kode | eval, parse, version, feedback |


Keywords

Kode uses 2-3 character keywords for maximum token efficiency.

| Keyword | Meaning | Keyword | Meaning | Keyword | Meaning | |---------|---------|---------|---------|---------|---------| | lt | let (immutable) | vr | var (mutable) | fn | function | | rt | return | if | if | ef | else-if | | el | else | wl | while | lp | loop | | fr | for-each | mt | match | br | break | | nx | next | tw | throw | tx | try | | ct | catch | fy | finally | ag | agent | | tk | tool | em | emit | on | on event | | sp | spawn | aw | await | st | state machine | | mem | memory | en | enum | it | interface | | sv | supervisor | go | task | ext | extend | | get | computed | tr | true | fl | false | | nl | null | im | import | ex | export |


CLI

kode <file.kd>              # Run a Kode file
kode                         # Start interactive REPL
kode test <file.kd>          # Run #test blocks
kode --time <file.kd>        # Run with execution timing
kode --ast <file.kd>         # Print abstract syntax tree
kode --tokens <file.kd>      # Print token stream
kode --version               # Print version
kode features                # List feature flags
kode kpm init                # Create kode.pkg
kode kpm add <package>       # Add dependency
kode migrate                 # Auto-migrate to new version
kode telemetry on|off        # Toggle usage telemetry

Error Messages

Kode provides helpful error messages with suggestions for AI agents:

error: [Runtime] Undefined variable 'let'

hint: 'let' is not defined. Did you mean 'lt'? Kode uses short keywords: let → lt
error: [Runtime] Cannot reassign immutable variable 'x'

hint: Use 'vr' (mutable) instead of 'lt' (immutable) if you need to reassign

Self-Modifying Code

Agents can write, test, and deploy Kode code at runtime:

-- Agent writes new code
lt code = "fn greet(name) -> \"Hello \" + name + \"!\""

-- Evaluate it
lt result = kode.eval(code)
if result.ok {
  io.out("Code compiled successfully")
}

-- Inspect the AST
lt ast = kode.parse("lt x = 2 + 3")
io.out(ast)

Project Structure

Kode/
  src/
    lexer/          Tokenizer (keywords, operators, TOON, strings)
    parser/         Recursive descent + Pratt expression parser
    evaluator/      Tree-walking interpreter + scope chain
    runtime/        Agent runtime, features, intelligence, kpm
    stdlib/         30+ standard library modules
    errors/         Rich error reporting with suggestions
  tests/            163 tests across 10 test files
  examples/         Example programs
  library/          Wiki-style tutorials and cookbook
  vscode-kode/      VS Code syntax highlighting extension
  .github/          CI/CD pipelines

Contributing

Kode is open source under the MIT license. Contributions welcome!

git clone https://github.com/kanishka089/Kode.git
cd Kode
npm install
npm test          # Run 163 tests

License

MIT