A typed programming language that compiles to Scratch. You write .knip files, run the
compiler, and get a .sb3 project that opens in Scratch or MistWarp or TurboWarp and runs like any other project.
public score: num = 0;
proc award(points: num) -> void {
score += points;
}
sprite Cat {
events.onFlag() {
pen.down();
for (side, 4) {
motion.forward(100);
motion.turn(90);
award(10);
}
pen.up();
looks.say(f"Scored {score}!", 2);
}
}
That builds into a real Scratch project: a stage variable score, a custom block award,
a green-flag script on the Cat sprite, and the pen extension enabled.
npm install -g @katnip-org/compiler
katnip build hello.knipNode.js 20+. See the documentation to get started, or
@katnip-org/compiler for the CLI
and library reference.
pnpm install
pnpm build
node packages/compiler/build/cli.js helpRun the test suite (~180 tests across lexer, parser, semantic, IR, and codegen):
pnpm testEnd-to-end example covering everything the compiler lowers today:
node packages/compiler/build/cli.js build examples/codegen.knipLive diagnostics, highlighting, and autocomplete for .knip files. Build the .vsix
(rebuilds and vendors the compiler, then packages):
pnpm --filter katnip-vscode run package
code --install-extension packages/vscode/katnip-vscode-0.0.14.vsix --forceRun Developer: Reload Window, then open any .knip file.
| Path | What's in it |
|---|---|
packages/compiler |
The compiler: lexer, parser, semantic analyzer, IR, SB3 codegen, CLI |
packages/compiler/stdlib |
The standard library, written in Katnip itself |
packages/vscode |
VS Code extension |
examples |
Sample .knip programs |
features.md |
Per-feature status against the pipeline |
CHANGELOG.md |
Version history, from Scratch interpreter to compiler |
source → lexer → parser → semantic analysis → IR → SB3 → .sb3
The frontend type-checks, the IR reconciles Katnip's semantics with what Scratch can
actually express (tuple returns, ranged for, switch -- none of which exist as blocks),
and the SB3 generator emits the block JSON that gets zipped into a .sb3.
Not yet lowered to blocks: structs, slices, **, and some katnip_* builtins.
features.md tracks the gaps.