Skip to main content

Command Line Tool

The kamoji command line tool is the fastest way to develop a Kamoji Mini App. Edit the files in your editor and save. The tool checks the mini app like the Mini Apps store does, installs it on your own Kamoji over Bluetooth and opens it on the screen, within seconds. Your mini app's log (print() lines, Lua errors, CPU budget warnings) streams into the same terminal.

No zip, no phone, no firmware build. Your other mini apps stay where they are.

Prefer the browser? The Web IDE does the same in Chrome or Edge, with nothing to install.

kamoji dev ./hello-counter

It comes in two flavours with the same commands, the same messages and the same kamoji command: one for Node.js (npm) and one for Python (pip). Pick either; you can switch any time without setting Kamoji up again.

Install​

Needs Node.js 20 or newer.

npm i -g kamoji-dev
kamoji dev ./my-app

Or run it without installing:

npx kamoji-dev dev ./my-app

You also need:

  • A computer with Bluetooth LE (macOS, Windows 10 or newer, Linux).
  • A Kamoji with firmware 0.3.0 or newer. Firmware 0.3.3 adds faster reloads and the log over Bluetooth: see Firmware 0.3.3 and older.
  • Optionally a USB-C data cable, for crashes, resets and faster screenshots.

Before you start​

  • Disconnect the Kamoji app on your phone. Kamoji takes one Bluetooth connection at a time. While your phone is connected, the tool can't reach Kamoji, and says so. Close the Kamoji app, or disconnect in it.
  • The first time, keep the computer right next to Kamoji (in the car). There is no pairing screen and no code: Kamoji trusts a new device only when it is close (see Authorization). From then on it works from any distance. Kamoji remembers 10 devices; this computer is one of them.
  • macOS: the first run asks whether your terminal (Terminal, iTerm, VS Code…) may use Bluetooth. Allow it in System Settings > Privacy & Security > Bluetooth, then run the command again.
  • Linux: Bluetooth goes through HCI sockets. Run this once (or run the tool as root):

    sudo setcap cap_net_raw+eip $(eval readlink -f $(which node))

    If the scan finds nothing, BlueZ may be holding the adapter: sudo systemctl stop bluetooth.

  • Windows: Windows 10 build 15063 or newer, with a Bluetooth LE adapter.

Your first run​

Take the Hello Counter folder, sit next to Kamoji and run:

kamoji dev ./hello-counter

The first time, Kamoji starts trusting this computer and the tool says so: KMJ-1A2B trusts this computer now. Then it installs the mini app and opens it:

10:02:11 Looking for Kamoji over Bluetooth…
10:02:14 Connected to KMJ-1A2B "Bob": firmware 0.3.3, R7.
10:02:14 3 mini app(s) on it, storage 1.3 MB of 8.0 MB used.
10:02:14 USB log from /dev/cu.usbmodem11301.
10:02:16 Installed hello-counter 1.0.0 in 1.9 s (3 file(s), 6.2 KB, 3.3 KB/s).
10:02:16 hello-counter is on screen (mode 7, 2.2 s after the first byte).
10:02:16 [entered] [hello-counter] entered in 118 ms: 4 bindings, Lua 2311 bytes
10:02:17 [print] tick 1
10:02:19 [warn] [hello-counter] main.lua: main.lua:12: attempt to perform arithmetic on a nil value
10:02:31 Updated hello-counter: 1 file changed (main.lua, 0.4 KB) in 0.6 s.
10:02:31 hello-counter is on screen (mode 7, 0.8 s after the first byte).

Now change main.lua and save. 400 ms after your last change the tool checks the folder again, sends what changed and reopens the mini app. If the mini app was already on screen, it restarts with the new version (its state starts fresh).

Bluetooth is slow-ish, about 3–15 KB/s depending on the computer, so a 10 KB mini app reloads in 1–3 seconds.

Commands​

CommandWhat it does
kamoji dev <folder>Check, install and open the mini app, then again on every save
kamoji install <folder>Check, install and open once. Exit code 0 means it is on screen
kamoji check <folder>Only check the folder, like the Mini Apps store does. --json for other tools
kamoji appsList the mini apps on Kamoji, with their mode numbers and sizes
kamoji shotSave a screenshot of Kamoji's screen to ./kamoji-shots (over USB when plugged in, else Bluetooth)
kamoji logsShow Kamoji's log: over USB, or over Bluetooth without a cable or with --ble. --app <id> follows one mini app
kamoji forgetKamoji forgets this computer, and the tool deletes its key

<folder> is the folder that holds manifest.json. Unzip a .zip first.

Keys while dev runs​

One keypress each, no Enter needed:

KeyWhat it does
EnterInstall again, sending every file
oOpen the mini app on Kamoji
sSave a screenshot
bRestart Kamoji
qQuit

Options​

OptionWhat it does
--device KMJ-XXXXWhich Kamoji, when several are nearby. The last four characters are enough
--port <path>The USB serial port for the log, e.g. /dev/cu.usbmodem11301. Found by itself otherwise
--bleBluetooth only: no USB log even with a cable plugged in. The app log comes over Bluetooth
--ble-logsThe app log over Bluetooth even with a cable. USB then adds only crashes and resets
--usbRequire the USB cable (log and screenshots over USB)
--out <dir>Where screenshots go (default ./kamoji-shots)
--rebootRestart Kamoji by itself when the mini app's Bluetooth services need it
--app <id>logs only: show only this mini app's lines
--verboseEvery USB log line, and more detail
--no-luaDon't check the Lua syntax
--jsoncheck only: print the result as JSON

kamoji --help lists them all, kamoji --version prints the version.

What it checks​

Before anything is sent, the tool checks the folder against the Mini Apps store's rules and what Kamoji itself refuses:

  • The manifest: id, version, api_version 1, known permissions, features and platforms, params (see Manifest and Settings).
  • The bundle rules: file paths, at most 64 files, 2 MB.
  • ble without the ble.gatt permission.
  • layout.json that isn't valid JSON or names an unknown widget, and unclosed {{ … }} bindings.
  • Lua syntax, with luac -p when a Lua compiler is installed. Kamoji runs Lua 5.4: another luac version only warns.

An error stops the install with the file and the reason. Nothing is sent until it is fixed.

Once connected, Kamoji's firmware must be at least the manifest's min_firmware, and the mini app must fit in Kamoji's free storage.

Hidden files, node_modules and editor files (*~, *.swp) are never sent. A save that changes nothing is skipped.

USB cable or Bluetooth only​

Installing always goes over Bluetooth. The tool only reads from the USB cable: it gives the log and fast screenshots.

  • With a USB-C data cable, the log comes over USB: USB log from /dev/cu.usbmodem11301. It is filtered to your mini app; --verbose shows every line. Crashes and resets of Kamoji show only here.
  • Without a cable (or with --ble), the app log comes over Bluetooth: No USB cable: the app log comes over Bluetooth (plug in a cable for crashes and resets). This needs firmware 0.3.3.

If several boards are plugged in, the tool asks you to pick one with --port.

Log lines are tagged like Kamoji's own log: [print], [entered], [cpu], [warn], [error], [stopped], [app].

Firmware 0.3.3 and older​

Needs Kamoji firmware 0.3.3 or later

The three features below need Kamoji firmware 0.3.3 or later. On older firmware (0.3.0 and up) the tool still works: it sends every file on each save, and the log comes over USB only. It says so once, then carries on.

Firmware 0.3.3 or newerOlder firmware
A saveOnly the changed and new files are sent; files you removed are deleted. Nothing changed: Nothing changedEvery file is sent
Log without a USB cableOver Bluetooth: print(), start and stop, warnings and Lua errorsNone: plug in a USB cable
Finding KamojiFast for 30 s after Kamoji starts or a connection dropsUp to 30 s

With firmware 0.3.3:

  • When the tool can't update only the changed files (the mini app isn't on Kamoji yet, or something went wrong), it sends every file instead. Enter always sends every file.
  • The mini app's settings (config.json) and its data/ folder are never deleted by an update.
  • Kamoji sends at most 20 log lines a second over Bluetooth. Beyond that you see Kamoji dropped 12 log line(s).
  • Crashes and resets of Kamoji still need the USB cable.

If an update fails half-way, the installed version stays as it was.

How it works​

The tool uses the same Bluetooth commands as the Kamoji app's Install from file, described in Sideloading. You can build your own tool on them.

Each Kamoji gets its own key for this computer, saved in ~/.config/kamoji/<KMJ-XXXX>.key and readable by you only (set KAMOJI_CONFIG_DIR to keep it elsewhere). The npm and Python tools share these files. The key is never printed. Whoever has it can control that Kamoji: don't share it. kamoji forget removes it from Kamoji and from the computer.

Troubleshooting​

MessageWhat to do
No Kamoji found nearbyIs Kamoji on and close? Is the Kamoji app disconnected? On macOS: does the terminal have Bluetooth permission?
KMJ-… is connected to another deviceDisconnect in the Kamoji app, or close it
… too far to startFirst time only: hold the computer right next to Kamoji, then run again
Kamoji refused this computer's keyRun kamoji forget (or delete the key file), then connect again close to Kamoji
… needs firmware … or newerUpdate Kamoji in the Kamoji app (see OTA Updates)
Kamoji is out of storage spaceRemove a mini app in the Kamoji app (Apps)
… Bluetooth services go live after a restartPress b, or run with --reboot
This firmware sends no app log over BluetoothUpdate Kamoji to firmware 0.3.3, or plug in a USB-C data cable (--port if several boards are plugged in)
This firmware installs whole mini apps onlyNothing to do: every file is sent. Update Kamoji to 0.3.3 for faster reloads