Skip to main content

A textual-based terminal user interface application

Project description

Kiwi Code

A terminal-based interface for the Kiwi AI platform. Built with Textual and Typer, it provides a chat-style TUI and command-line access to manage and interact with actions, action graphs, and their runs.

Requires Python 3.13+.

Architecture

Kiwi Code has three entry points, but they are not three services — they are independent frontends to the same shared code:

                  ┌──────────────────────────────────┐
                  │         Shared Libraries          │
                  │                                    │
                  │  commands.py   Command handlers    │
                  │  client.py     HTTP/SSE client     │
                  │  auth.py       Token management    │
                  │  autobots_client  (generated SDK)  │
                  └──────┬───────────┬─────────────────┘
                         │           │
              ┌──────────┘           └──────────┐
              │                                  │
     ┌────────▼────────┐              ┌─────────▼─────────┐
     │   kiwi (TUI)    │              │  kiwicli (CLI)     │
     │                  │              │                    │
     │  Full-screen     │              │  Typer commands    │
     │  Textual app     │              │  for scripting     │
     │                  │              │  and automation    │
     └────────┬─────────┘              └────────────────────┘
              │ auto-starts
              │ (if not already running)
              │
     ┌────────▼──────────────────────────────────────────┐
     │                kiwi-runtime                        │
     │                                                    │
     │  Independent process — one per working directory   │
     │  Connects to Kiwi server via WebSocket             │
     │  Executes shell commands for the LLM agent         │
     │                                                    │
     │  Can also be started directly:                     │
     │    kiwi-runtime connect --server app               │
     │                                                    │
     │  Survives TUI quit, logout, and restarts           │
     │  Stop explicitly: kiwicli runtime stop             │
     └───────────────────────────────────────────────────┘

Key points:

  • kiwi and kiwicli do not depend on each other. They both import the same commands.py, client.py, and auth.py modules directly. Neither needs the other to be running.
  • kiwi automatically spawns kiwi-runtime when you log in. The runtime runs as an independent process — quitting or restarting the TUI does not kill it.
  • One runtime per directory. Each working directory gets its own runtime, scoped to that directory. Opening the TUI in two different project folders runs two independent runtimes.
  • kiwicli is for headless/scripting use. It provides the same query commands (actions, runs, graphs) as the TUI, but as standalone CLI commands.
  • Authentication is shared. Both use TokenManager to read/write tokens from ~/.kiwi/tokens.json, so logging in via one works for the other.
  • Runtime lifecycle is independent. The runtime persists across TUI restarts. Use kiwicli runtime stop to explicitly stop it.

Installation

pip install kiwi-code

This installs three commands:

Command Description
kiwi Launch the interactive TUI (auto-starts runtime)
kiwicli CLI for scripting — login, query actions/runs/graphs
kiwi-runtime WebSocket agent for LLM command execution (usually auto-started by TUI)

Quick Start

# Login (once — tokens are saved locally)
kiwicli login

# Launch the interactive TUI (starts runtime automatically)
kiwi

# Or use CLI commands directly
kiwicli actions list
kiwicli runs list --status processing

Commands

kiwicli login                                  Authenticate with email and password
kiwicli logout                                 Logout and clear saved tokens
kiwicli whoami                                 Check authentication status
kiwicli tui                                    Launch the interactive TUI

kiwicli actions list [--name N]                List actions
kiwicli actions get <id>                       Get action details

kiwicli runs list [--action-id ID]             List action runs (results)
       [--action-name N] [--status S]
kiwicli runs get <id>                          Get run details

kiwicli graphs list [--name N]                 List action graphs
kiwicli graphs get <id>                        Get graph details

kiwicli graph-runs list [--graph-id ID]        List graph runs (results)
       [--graph-name N] [--status S]
kiwicli graph-runs get <id>                    Get graph run details

kiwicli runtime status                         Check if runtime is running (current dir)
kiwicli runtime stop [--all]                   Stop runtime (current dir, or all)
kiwicli runtime list                           List all runtimes across directories
kiwicli runtime logs                           Tail the runtime log (current dir)

All list commands support --limit and --offset for pagination. Runs can be filtered by --status (processing, success, error, stuck, waiting).

Interactive TUI

Launch with kiwi or kiwicli tui. The TUI provides a full-screen chat interface for conversing with actions in real time.

  • Chat interface — Send messages to actions and receive streamed responses via SSE
  • Session management — Switch actions, continue existing runs, or start new conversations
  • Slash commands — All CLI commands work inside the TUI chat with a / prefix
  • Authentication — Login screen with automatic token refresh
  • Runtime logs — View the runtime agent's output in real time (Ctrl+R)
  • Theming — Dark/light mode toggle (Ctrl+D)

Keyboard Shortcuts

Key Action
Ctrl+C Quit
Ctrl+R Runtime logs
Ctrl+D Toggle dark/light mode
Ctrl+L Logout

Slash Commands (inside TUI)

/use <action_id>              Switch to a different action
/continue <run_id>            Continue an existing conversation run
/new                          Start a new conversation (resets to default action)
/status                       Show current action and run IDs

/actions list                 List all actions
/runs list --status success   Filter runs by status
/graphs get <id>              View graph details
/help                         Show all available commands

Streaming

Actions execute asynchronously. The TUI streams status updates in real time via SSE and automatically fetches the final result on completion. Falls back to polling if the SSE stream ends without delivering a result.

Runtime Agent

The runtime agent connects to the Kiwi server via WebSocket and executes terminal commands on behalf of the LLM agent.

The TUI auto-starts the runtime on login. Each working directory gets its own runtime instance, restricted to that directory. The runtime runs as an independent process — it survives TUI quit, logout, and restarts. When the TUI starts again, it detects the running runtime and reattaches to its logs.

To manage runtimes independently:

kiwicli runtime status    # Check if running (for current directory)
kiwicli runtime stop      # Stop the runtime (for current directory)
kiwicli runtime stop --all # Stop all runtimes
kiwicli runtime list      # List all runtimes across directories
kiwicli runtime logs      # Tail the runtime log (for current directory)

You can also run it standalone:

kiwi-runtime connect --server app           # Production (api.meetkiwi.ai)
kiwi-runtime connect --server dev           # Development
kiwi-runtime connect --server local         # Localhost
kiwi-runtime connect --server wss://custom  # Custom URL
kiwi-runtime connect --scope full           # Unrestricted execution (default: restricted)
kiwi-runtime connect --allow /extra/dir     # Allow additional directory in restricted mode

In restricted mode (default), commands are sandboxed to the current working directory. The --allow flag adds extra allowed paths.

Configuration

Stored at ~/.kiwi/config.json:

{
  "backend_url": "https://api.example.com",
  "log_level": "INFO",
  "theme": "dark",
  "refresh_interval": 5
}

Logs are written to ~/.kiwi/kiwi_tui.log.

Development

git clone https://github.com/jetoslabs/kiwi-code.git
cd kiwi-code
uv sync
uv run kiwi

License

Proprietary. All rights reserved.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

kiwi_code-0.0.9.tar.gz (110.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

kiwi_code-0.0.9-py3-none-any.whl (56.2 kB view details)

Uploaded Python 3

File details

Details for the file kiwi_code-0.0.9.tar.gz.

File metadata

  • Download URL: kiwi_code-0.0.9.tar.gz
  • Upload date:
  • Size: 110.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.12 {"installer":{"name":"uv","version":"0.10.12","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for kiwi_code-0.0.9.tar.gz
Algorithm Hash digest
SHA256 e4d69f7b9ed6ed05ca970b2b776fd491bfb135dadbb065e0be65d73d4bc6c0a3
MD5 830e41dce2ab2b5f69f204af7242f4f7
BLAKE2b-256 28c0089f7033b837f2e35682c233b76089867b0ed7f10d54ca8250223c34d334

See more details on using hashes here.

File details

Details for the file kiwi_code-0.0.9-py3-none-any.whl.

File metadata

  • Download URL: kiwi_code-0.0.9-py3-none-any.whl
  • Upload date:
  • Size: 56.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.12 {"installer":{"name":"uv","version":"0.10.12","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for kiwi_code-0.0.9-py3-none-any.whl
Algorithm Hash digest
SHA256 81269d6801bcee368675f220c9bb8bfaa142d63ad6166c447753759f81c46ceb
MD5 590a0402a990c53a6de2b61b82a61976
BLAKE2b-256 4d37f7071d402d25b6100fe6c64ece5c0130515cfa0738cd1e6579d87fc984b3

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page