kiwi-code 0.0.4__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- kiwi_code-0.0.4/.github/workflows/publish.yml +72 -0
- kiwi_code-0.0.4/.gitignore +32 -0
- kiwi_code-0.0.4/.python-version +1 -0
- kiwi_code-0.0.4/Makefile +64 -0
- kiwi_code-0.0.4/PKG-INFO +234 -0
- kiwi_code-0.0.4/README.md +208 -0
- kiwi_code-0.0.4/poetry.lock +1570 -0
- kiwi_code-0.0.4/pyproject.toml +45 -0
- kiwi_code-0.0.4/src/kiwi_runtime/__init__.py +3 -0
- kiwi_code-0.0.4/src/kiwi_runtime/__main__.py +5 -0
- kiwi_code-0.0.4/src/kiwi_runtime/main.py +989 -0
- kiwi_code-0.0.4/src/kiwi_tui/__init__.py +3 -0
- kiwi_code-0.0.4/src/kiwi_tui/auth.py +125 -0
- kiwi_code-0.0.4/src/kiwi_tui/cli.py +243 -0
- kiwi_code-0.0.4/src/kiwi_tui/client.py +539 -0
- kiwi_code-0.0.4/src/kiwi_tui/commands.py +434 -0
- kiwi_code-0.0.4/src/kiwi_tui/config.py +79 -0
- kiwi_code-0.0.4/src/kiwi_tui/logger.py +32 -0
- kiwi_code-0.0.4/src/kiwi_tui/main.py +337 -0
- kiwi_code-0.0.4/src/kiwi_tui/models.py +85 -0
- kiwi_code-0.0.4/src/kiwi_tui/runtime_manager.py +130 -0
- kiwi_code-0.0.4/src/kiwi_tui/screens/__init__.py +9 -0
- kiwi_code-0.0.4/src/kiwi_tui/screens/actions.py +271 -0
- kiwi_code-0.0.4/src/kiwi_tui/screens/autobots.py +216 -0
- kiwi_code-0.0.4/src/kiwi_tui/screens/dashboard.py +608 -0
- kiwi_code-0.0.4/src/kiwi_tui/screens/login.py +320 -0
- kiwi_code-0.0.4/src/kiwi_tui/screens/runtime_logs.py +96 -0
- kiwi_code-0.0.4/src/kiwi_tui/widgets.py +197 -0
- kiwi_code-0.0.4/test_hello.py +19 -0
- kiwi_code-0.0.4/uv.lock +1031 -0
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
name: Publish to PyPI
|
|
2
|
+
|
|
3
|
+
run-name: "Publish ${{ github.event.inputs.version && format('v{0}', github.event.inputs.version) || github.ref_name }}"
|
|
4
|
+
|
|
5
|
+
on:
|
|
6
|
+
workflow_dispatch:
|
|
7
|
+
inputs:
|
|
8
|
+
version:
|
|
9
|
+
description: 'Version to publish (e.g., 0.1.1)'
|
|
10
|
+
required: true
|
|
11
|
+
type: string
|
|
12
|
+
push:
|
|
13
|
+
tags:
|
|
14
|
+
- 'v*.*.*'
|
|
15
|
+
|
|
16
|
+
jobs:
|
|
17
|
+
publish:
|
|
18
|
+
runs-on: ubuntu-latest
|
|
19
|
+
|
|
20
|
+
steps:
|
|
21
|
+
- uses: actions/checkout@v4
|
|
22
|
+
|
|
23
|
+
- name: Install uv
|
|
24
|
+
uses: astral-sh/setup-uv@v4
|
|
25
|
+
|
|
26
|
+
- name: Set up Python
|
|
27
|
+
run: uv python install 3.13
|
|
28
|
+
|
|
29
|
+
- name: Determine version
|
|
30
|
+
id: version
|
|
31
|
+
run: |
|
|
32
|
+
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
|
|
33
|
+
echo "version=${{ github.event.inputs.version }}" >> "$GITHUB_OUTPUT"
|
|
34
|
+
else
|
|
35
|
+
# Extract version from tag (v0.1.1 -> 0.1.1)
|
|
36
|
+
TAG="${GITHUB_REF#refs/tags/v}"
|
|
37
|
+
echo "version=$TAG" >> "$GITHUB_OUTPUT"
|
|
38
|
+
fi
|
|
39
|
+
|
|
40
|
+
- name: Update version in pyproject.toml
|
|
41
|
+
run: |
|
|
42
|
+
sed -i "s/^version = .*/version = \"${{ steps.version.outputs.version }}\"/" pyproject.toml
|
|
43
|
+
echo "Publishing version: ${{ steps.version.outputs.version }}"
|
|
44
|
+
grep '^version' pyproject.toml
|
|
45
|
+
|
|
46
|
+
- name: Install dependencies
|
|
47
|
+
run: uv sync
|
|
48
|
+
|
|
49
|
+
- name: Smoke test
|
|
50
|
+
run: |
|
|
51
|
+
uv run kiwicli --help
|
|
52
|
+
uv run kiwi-runtime --help
|
|
53
|
+
uv run kiwicli runtime status
|
|
54
|
+
|
|
55
|
+
- name: Build package
|
|
56
|
+
run: uv build
|
|
57
|
+
|
|
58
|
+
- name: Verify build artifacts
|
|
59
|
+
run: |
|
|
60
|
+
ls -lh dist/
|
|
61
|
+
# Check that the built version matches the expected version
|
|
62
|
+
EXPECTED="${{ steps.version.outputs.version }}"
|
|
63
|
+
if ! ls dist/ | grep -q "$EXPECTED"; then
|
|
64
|
+
echo "ERROR: Built artifacts do not contain expected version $EXPECTED"
|
|
65
|
+
ls dist/
|
|
66
|
+
exit 1
|
|
67
|
+
fi
|
|
68
|
+
|
|
69
|
+
- name: Publish to PyPI
|
|
70
|
+
env:
|
|
71
|
+
UV_PUBLISH_TOKEN: ${{ secrets.PYPI_TOKEN }}
|
|
72
|
+
run: uv publish
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
# Python
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[cod]
|
|
4
|
+
*$py.class
|
|
5
|
+
*.egg-info/
|
|
6
|
+
dist/
|
|
7
|
+
build/
|
|
8
|
+
*.egg
|
|
9
|
+
|
|
10
|
+
# Virtual environments
|
|
11
|
+
.venv/
|
|
12
|
+
venv/
|
|
13
|
+
env/
|
|
14
|
+
|
|
15
|
+
# IDE
|
|
16
|
+
.idea/
|
|
17
|
+
.vscode/
|
|
18
|
+
*.swp
|
|
19
|
+
*.swo
|
|
20
|
+
|
|
21
|
+
# OS
|
|
22
|
+
.DS_Store
|
|
23
|
+
Thumbs.db
|
|
24
|
+
|
|
25
|
+
# Claude Code
|
|
26
|
+
.claude/
|
|
27
|
+
|
|
28
|
+
# Logs
|
|
29
|
+
*.log
|
|
30
|
+
|
|
31
|
+
# Local config & tokens
|
|
32
|
+
.autobots-tui/
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
3.13
|
kiwi_code-0.0.4/Makefile
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
.PHONY: run dev cli runtime test-hello install sync clean help
|
|
2
|
+
|
|
3
|
+
# Run the Kiwi TUI application
|
|
4
|
+
run:
|
|
5
|
+
uv run kiwi
|
|
6
|
+
|
|
7
|
+
# Run the Kiwi TUI application in development mode (with live reload and debugging)
|
|
8
|
+
dev:
|
|
9
|
+
uv run --dev kiwi
|
|
10
|
+
|
|
11
|
+
# Run the Kiwi CLI
|
|
12
|
+
cli:
|
|
13
|
+
uv run kiwicli
|
|
14
|
+
|
|
15
|
+
# Run the Kiwi Runtime agent (pass ARGS, e.g. make runtime ARGS="connect --server app")
|
|
16
|
+
runtime:
|
|
17
|
+
uv run kiwi-runtime $(ARGS)
|
|
18
|
+
|
|
19
|
+
# Test the hello API connection
|
|
20
|
+
test-hello:
|
|
21
|
+
uv run python test_hello.py
|
|
22
|
+
|
|
23
|
+
# Install/sync dependencies
|
|
24
|
+
install:
|
|
25
|
+
uv sync
|
|
26
|
+
|
|
27
|
+
# Sync dependencies
|
|
28
|
+
sync:
|
|
29
|
+
uv sync
|
|
30
|
+
|
|
31
|
+
# Clean up temporary files and caches
|
|
32
|
+
clean:
|
|
33
|
+
find . -type d -name "__pycache__" -exec rm -rf {} + 2>/dev/null || true
|
|
34
|
+
find . -type f -name "*.pyc" -delete
|
|
35
|
+
find . -type f -name "*.pyo" -delete
|
|
36
|
+
find . -type f -name "*.log" -delete
|
|
37
|
+
rm -rf .pytest_cache
|
|
38
|
+
rm -rf .ruff_cache
|
|
39
|
+
rm -rf dist/
|
|
40
|
+
rm -rf build/
|
|
41
|
+
rm -rf *.egg-info
|
|
42
|
+
|
|
43
|
+
# Build the package
|
|
44
|
+
build:
|
|
45
|
+
uv build
|
|
46
|
+
|
|
47
|
+
# Show help
|
|
48
|
+
help:
|
|
49
|
+
@echo "Kiwi Code - Makefile Commands"
|
|
50
|
+
@echo ""
|
|
51
|
+
@echo "Usage: make [command]"
|
|
52
|
+
@echo ""
|
|
53
|
+
@echo "Commands:"
|
|
54
|
+
@echo " run - Run the Kiwi TUI application (kiwi)"
|
|
55
|
+
@echo " dev - Run TUI in development mode (with live reload)"
|
|
56
|
+
@echo " cli - Run the Kiwi CLI (kiwicli)"
|
|
57
|
+
@echo " runtime - Run the Kiwi Runtime agent (kiwi-runtime)"
|
|
58
|
+
@echo " e.g. make runtime ARGS=\"connect --server app\""
|
|
59
|
+
@echo " test-hello - Test connection to backend (hello API)"
|
|
60
|
+
@echo " install - Install/sync project dependencies"
|
|
61
|
+
@echo " sync - Sync dependencies"
|
|
62
|
+
@echo " build - Build the package"
|
|
63
|
+
@echo " clean - Clean up temporary files and caches"
|
|
64
|
+
@echo " help - Show this help message"
|
kiwi_code-0.0.4/PKG-INFO
ADDED
|
@@ -0,0 +1,234 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: kiwi-code
|
|
3
|
+
Version: 0.0.4
|
|
4
|
+
Summary: A textual-based terminal user interface application
|
|
5
|
+
Project-URL: Homepage, https://meetkiwi.ai
|
|
6
|
+
Project-URL: Repository, https://github.com/jetoslabs/kiwi-code
|
|
7
|
+
Author-email: Anurag Jha <anurag@meetkiwi.co>
|
|
8
|
+
License: MIT
|
|
9
|
+
Keywords: cli,terminal,textual,tui
|
|
10
|
+
Classifier: Development Status :: 3 - Alpha
|
|
11
|
+
Classifier: Intended Audience :: Developers
|
|
12
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
13
|
+
Classifier: Programming Language :: Python :: 3
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
15
|
+
Requires-Python: <4.0,>=3.13
|
|
16
|
+
Requires-Dist: autobots-client==0.1.0
|
|
17
|
+
Requires-Dist: httpx>=0.25.0
|
|
18
|
+
Requires-Dist: loguru>=0.7.3
|
|
19
|
+
Requires-Dist: psutil>=5.9.0
|
|
20
|
+
Requires-Dist: pydantic>=2.12.5
|
|
21
|
+
Requires-Dist: textual-dev>=1.8.0
|
|
22
|
+
Requires-Dist: textual>=8.1.1
|
|
23
|
+
Requires-Dist: typer>=0.24.1
|
|
24
|
+
Requires-Dist: websockets>=14.1
|
|
25
|
+
Description-Content-Type: text/markdown
|
|
26
|
+
|
|
27
|
+
# Kiwi Code
|
|
28
|
+
|
|
29
|
+
A terminal-based interface for the [Kiwi AI](https://meetkiwi.ai) platform. Built with [Textual](https://textual.textualize.io/) and [Typer](https://typer.tiangolo.com/), it provides a chat-style TUI and command-line access to manage and interact with actions, action graphs, and their runs.
|
|
30
|
+
|
|
31
|
+
Requires Python 3.13+.
|
|
32
|
+
|
|
33
|
+
## Architecture
|
|
34
|
+
|
|
35
|
+
Kiwi Code has three entry points, but they are **not three services** — they are independent frontends to the same shared code:
|
|
36
|
+
|
|
37
|
+
```
|
|
38
|
+
┌──────────────────────────────────┐
|
|
39
|
+
│ Shared Libraries │
|
|
40
|
+
│ │
|
|
41
|
+
│ commands.py Command handlers │
|
|
42
|
+
│ client.py HTTP/SSE client │
|
|
43
|
+
│ auth.py Token management │
|
|
44
|
+
│ autobots_client (generated SDK) │
|
|
45
|
+
└──────┬───────────┬─────────────────┘
|
|
46
|
+
│ │
|
|
47
|
+
┌──────────┘ └──────────┐
|
|
48
|
+
│ │
|
|
49
|
+
┌────────▼────────┐ ┌─────────▼─────────┐
|
|
50
|
+
│ kiwi (TUI) │ │ kiwicli (CLI) │
|
|
51
|
+
│ │ │ │
|
|
52
|
+
│ Full-screen │ │ Typer commands │
|
|
53
|
+
│ Textual app │ │ for scripting │
|
|
54
|
+
│ │ │ and automation │
|
|
55
|
+
└────────┬─────────┘ └────────────────────┘
|
|
56
|
+
│ auto-starts
|
|
57
|
+
│ (if not already running)
|
|
58
|
+
│
|
|
59
|
+
┌────────▼──────────────────────────────────────────┐
|
|
60
|
+
│ kiwi-runtime │
|
|
61
|
+
│ │
|
|
62
|
+
│ Independent process — one per working directory │
|
|
63
|
+
│ Connects to Kiwi server via WebSocket │
|
|
64
|
+
│ Executes shell commands for the LLM agent │
|
|
65
|
+
│ │
|
|
66
|
+
│ Can also be started directly: │
|
|
67
|
+
│ kiwi-runtime connect --server app │
|
|
68
|
+
│ │
|
|
69
|
+
│ Survives TUI quit, logout, and restarts │
|
|
70
|
+
│ Stop explicitly: kiwicli runtime stop │
|
|
71
|
+
└───────────────────────────────────────────────────┘
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
**Key points:**
|
|
75
|
+
|
|
76
|
+
- **`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.
|
|
77
|
+
- **`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.
|
|
78
|
+
- **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.
|
|
79
|
+
- **`kiwicli` is for headless/scripting use.** It provides the same query commands (actions, runs, graphs) as the TUI, but as standalone CLI commands.
|
|
80
|
+
- **Authentication is shared.** Both use `TokenManager` to read/write tokens from `~/.autobots-tui/tokens.json`, so logging in via one works for the other.
|
|
81
|
+
- **Runtime lifecycle is independent.** The runtime persists across TUI restarts. Use `kiwicli runtime stop` to explicitly stop it.
|
|
82
|
+
|
|
83
|
+
## Installation
|
|
84
|
+
|
|
85
|
+
```bash
|
|
86
|
+
pip install kiwi-code
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
This installs three commands:
|
|
90
|
+
|
|
91
|
+
| Command | Description |
|
|
92
|
+
|---------|-------------|
|
|
93
|
+
| `kiwi` | Launch the interactive TUI (auto-starts runtime) |
|
|
94
|
+
| `kiwicli` | CLI for scripting — login, query actions/runs/graphs |
|
|
95
|
+
| `kiwi-runtime` | WebSocket agent for LLM command execution (usually auto-started by TUI) |
|
|
96
|
+
|
|
97
|
+
## Quick Start
|
|
98
|
+
|
|
99
|
+
```bash
|
|
100
|
+
# Login (once — tokens are saved locally)
|
|
101
|
+
kiwicli login
|
|
102
|
+
|
|
103
|
+
# Launch the interactive TUI (starts runtime automatically)
|
|
104
|
+
kiwi
|
|
105
|
+
|
|
106
|
+
# Or use CLI commands directly
|
|
107
|
+
kiwicli actions list
|
|
108
|
+
kiwicli runs list --status processing
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
## Commands
|
|
112
|
+
|
|
113
|
+
```
|
|
114
|
+
kiwicli login Authenticate with email and password
|
|
115
|
+
kiwicli logout Logout and clear saved tokens
|
|
116
|
+
kiwicli whoami Check authentication status
|
|
117
|
+
kiwicli tui Launch the interactive TUI
|
|
118
|
+
|
|
119
|
+
kiwicli actions list [--name N] List actions
|
|
120
|
+
kiwicli actions get <id> Get action details
|
|
121
|
+
|
|
122
|
+
kiwicli runs list [--action-id ID] List action runs (results)
|
|
123
|
+
[--action-name N] [--status S]
|
|
124
|
+
kiwicli runs get <id> Get run details
|
|
125
|
+
|
|
126
|
+
kiwicli graphs list [--name N] List action graphs
|
|
127
|
+
kiwicli graphs get <id> Get graph details
|
|
128
|
+
|
|
129
|
+
kiwicli graph-runs list [--graph-id ID] List graph runs (results)
|
|
130
|
+
[--graph-name N] [--status S]
|
|
131
|
+
kiwicli graph-runs get <id> Get graph run details
|
|
132
|
+
|
|
133
|
+
kiwicli runtime status Check if runtime is running (current dir)
|
|
134
|
+
kiwicli runtime stop [--all] Stop runtime (current dir, or all)
|
|
135
|
+
kiwicli runtime list List all runtimes across directories
|
|
136
|
+
kiwicli runtime logs Tail the runtime log (current dir)
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
All list commands support `--limit` and `--offset` for pagination. Runs can be filtered by `--status` (processing, success, error, stuck, waiting).
|
|
140
|
+
|
|
141
|
+
## Interactive TUI
|
|
142
|
+
|
|
143
|
+
Launch with `kiwi` or `kiwicli tui`. The TUI provides a full-screen chat interface for conversing with actions in real time.
|
|
144
|
+
|
|
145
|
+
- **Chat interface** — Send messages to actions and receive streamed responses via SSE
|
|
146
|
+
- **Session management** — Switch actions, continue existing runs, or start new conversations
|
|
147
|
+
- **Slash commands** — All CLI commands work inside the TUI chat with a `/` prefix
|
|
148
|
+
- **Authentication** — Login screen with automatic token refresh
|
|
149
|
+
- **Runtime logs** — View the runtime agent's output in real time (`Ctrl+R`)
|
|
150
|
+
- **Theming** — Dark/light mode toggle (`Ctrl+D`)
|
|
151
|
+
|
|
152
|
+
### Keyboard Shortcuts
|
|
153
|
+
|
|
154
|
+
| Key | Action |
|
|
155
|
+
|-----|--------|
|
|
156
|
+
| `Ctrl+C` | Quit |
|
|
157
|
+
| `Ctrl+R` | Runtime logs |
|
|
158
|
+
| `Ctrl+D` | Toggle dark/light mode |
|
|
159
|
+
| `Ctrl+L` | Logout |
|
|
160
|
+
|
|
161
|
+
### Slash Commands (inside TUI)
|
|
162
|
+
|
|
163
|
+
```
|
|
164
|
+
/use <action_id> Switch to a different action
|
|
165
|
+
/continue <run_id> Continue an existing conversation run
|
|
166
|
+
/new Start a new conversation (resets to default action)
|
|
167
|
+
/status Show current action and run IDs
|
|
168
|
+
|
|
169
|
+
/actions list List all actions
|
|
170
|
+
/runs list --status success Filter runs by status
|
|
171
|
+
/graphs get <id> View graph details
|
|
172
|
+
/help Show all available commands
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
### Streaming
|
|
176
|
+
|
|
177
|
+
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.
|
|
178
|
+
|
|
179
|
+
## Runtime Agent
|
|
180
|
+
|
|
181
|
+
The runtime agent connects to the Kiwi server via WebSocket and executes terminal commands on behalf of the LLM agent.
|
|
182
|
+
|
|
183
|
+
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.
|
|
184
|
+
|
|
185
|
+
To manage runtimes independently:
|
|
186
|
+
|
|
187
|
+
```bash
|
|
188
|
+
kiwicli runtime status # Check if running (for current directory)
|
|
189
|
+
kiwicli runtime stop # Stop the runtime (for current directory)
|
|
190
|
+
kiwicli runtime stop --all # Stop all runtimes
|
|
191
|
+
kiwicli runtime list # List all runtimes across directories
|
|
192
|
+
kiwicli runtime logs # Tail the runtime log (for current directory)
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
You can also run it standalone:
|
|
196
|
+
|
|
197
|
+
```bash
|
|
198
|
+
kiwi-runtime connect --server app # Production (api.meetkiwi.ai)
|
|
199
|
+
kiwi-runtime connect --server dev # Development
|
|
200
|
+
kiwi-runtime connect --server local # Localhost
|
|
201
|
+
kiwi-runtime connect --server wss://custom # Custom URL
|
|
202
|
+
kiwi-runtime connect --scope full # Unrestricted execution (default: restricted)
|
|
203
|
+
kiwi-runtime connect --allow /extra/dir # Allow additional directory in restricted mode
|
|
204
|
+
```
|
|
205
|
+
|
|
206
|
+
In **restricted mode** (default), commands are sandboxed to the current working directory. The `--allow` flag adds extra allowed paths.
|
|
207
|
+
|
|
208
|
+
## Configuration
|
|
209
|
+
|
|
210
|
+
Stored at `~/.autobots-tui/config.json`:
|
|
211
|
+
|
|
212
|
+
```json
|
|
213
|
+
{
|
|
214
|
+
"backend_url": "https://api.example.com",
|
|
215
|
+
"log_level": "INFO",
|
|
216
|
+
"theme": "dark",
|
|
217
|
+
"refresh_interval": 5
|
|
218
|
+
}
|
|
219
|
+
```
|
|
220
|
+
|
|
221
|
+
Logs are written to `~/.autobots-tui/autobots_tui.log`.
|
|
222
|
+
|
|
223
|
+
## Development
|
|
224
|
+
|
|
225
|
+
```bash
|
|
226
|
+
git clone https://github.com/jetoslabs/kiwi-code.git
|
|
227
|
+
cd kiwi-code
|
|
228
|
+
uv sync
|
|
229
|
+
uv run kiwi
|
|
230
|
+
```
|
|
231
|
+
|
|
232
|
+
## License
|
|
233
|
+
|
|
234
|
+
MIT
|
|
@@ -0,0 +1,208 @@
|
|
|
1
|
+
# Kiwi Code
|
|
2
|
+
|
|
3
|
+
A terminal-based interface for the [Kiwi AI](https://meetkiwi.ai) platform. Built with [Textual](https://textual.textualize.io/) and [Typer](https://typer.tiangolo.com/), it provides a chat-style TUI and command-line access to manage and interact with actions, action graphs, and their runs.
|
|
4
|
+
|
|
5
|
+
Requires Python 3.13+.
|
|
6
|
+
|
|
7
|
+
## Architecture
|
|
8
|
+
|
|
9
|
+
Kiwi Code has three entry points, but they are **not three services** — they are independent frontends to the same shared code:
|
|
10
|
+
|
|
11
|
+
```
|
|
12
|
+
┌──────────────────────────────────┐
|
|
13
|
+
│ Shared Libraries │
|
|
14
|
+
│ │
|
|
15
|
+
│ commands.py Command handlers │
|
|
16
|
+
│ client.py HTTP/SSE client │
|
|
17
|
+
│ auth.py Token management │
|
|
18
|
+
│ autobots_client (generated SDK) │
|
|
19
|
+
└──────┬───────────┬─────────────────┘
|
|
20
|
+
│ │
|
|
21
|
+
┌──────────┘ └──────────┐
|
|
22
|
+
│ │
|
|
23
|
+
┌────────▼────────┐ ┌─────────▼─────────┐
|
|
24
|
+
│ kiwi (TUI) │ │ kiwicli (CLI) │
|
|
25
|
+
│ │ │ │
|
|
26
|
+
│ Full-screen │ │ Typer commands │
|
|
27
|
+
│ Textual app │ │ for scripting │
|
|
28
|
+
│ │ │ and automation │
|
|
29
|
+
└────────┬─────────┘ └────────────────────┘
|
|
30
|
+
│ auto-starts
|
|
31
|
+
│ (if not already running)
|
|
32
|
+
│
|
|
33
|
+
┌────────▼──────────────────────────────────────────┐
|
|
34
|
+
│ kiwi-runtime │
|
|
35
|
+
│ │
|
|
36
|
+
│ Independent process — one per working directory │
|
|
37
|
+
│ Connects to Kiwi server via WebSocket │
|
|
38
|
+
│ Executes shell commands for the LLM agent │
|
|
39
|
+
│ │
|
|
40
|
+
│ Can also be started directly: │
|
|
41
|
+
│ kiwi-runtime connect --server app │
|
|
42
|
+
│ │
|
|
43
|
+
│ Survives TUI quit, logout, and restarts │
|
|
44
|
+
│ Stop explicitly: kiwicli runtime stop │
|
|
45
|
+
└───────────────────────────────────────────────────┘
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
**Key points:**
|
|
49
|
+
|
|
50
|
+
- **`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.
|
|
51
|
+
- **`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.
|
|
52
|
+
- **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.
|
|
53
|
+
- **`kiwicli` is for headless/scripting use.** It provides the same query commands (actions, runs, graphs) as the TUI, but as standalone CLI commands.
|
|
54
|
+
- **Authentication is shared.** Both use `TokenManager` to read/write tokens from `~/.autobots-tui/tokens.json`, so logging in via one works for the other.
|
|
55
|
+
- **Runtime lifecycle is independent.** The runtime persists across TUI restarts. Use `kiwicli runtime stop` to explicitly stop it.
|
|
56
|
+
|
|
57
|
+
## Installation
|
|
58
|
+
|
|
59
|
+
```bash
|
|
60
|
+
pip install kiwi-code
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
This installs three commands:
|
|
64
|
+
|
|
65
|
+
| Command | Description |
|
|
66
|
+
|---------|-------------|
|
|
67
|
+
| `kiwi` | Launch the interactive TUI (auto-starts runtime) |
|
|
68
|
+
| `kiwicli` | CLI for scripting — login, query actions/runs/graphs |
|
|
69
|
+
| `kiwi-runtime` | WebSocket agent for LLM command execution (usually auto-started by TUI) |
|
|
70
|
+
|
|
71
|
+
## Quick Start
|
|
72
|
+
|
|
73
|
+
```bash
|
|
74
|
+
# Login (once — tokens are saved locally)
|
|
75
|
+
kiwicli login
|
|
76
|
+
|
|
77
|
+
# Launch the interactive TUI (starts runtime automatically)
|
|
78
|
+
kiwi
|
|
79
|
+
|
|
80
|
+
# Or use CLI commands directly
|
|
81
|
+
kiwicli actions list
|
|
82
|
+
kiwicli runs list --status processing
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
## Commands
|
|
86
|
+
|
|
87
|
+
```
|
|
88
|
+
kiwicli login Authenticate with email and password
|
|
89
|
+
kiwicli logout Logout and clear saved tokens
|
|
90
|
+
kiwicli whoami Check authentication status
|
|
91
|
+
kiwicli tui Launch the interactive TUI
|
|
92
|
+
|
|
93
|
+
kiwicli actions list [--name N] List actions
|
|
94
|
+
kiwicli actions get <id> Get action details
|
|
95
|
+
|
|
96
|
+
kiwicli runs list [--action-id ID] List action runs (results)
|
|
97
|
+
[--action-name N] [--status S]
|
|
98
|
+
kiwicli runs get <id> Get run details
|
|
99
|
+
|
|
100
|
+
kiwicli graphs list [--name N] List action graphs
|
|
101
|
+
kiwicli graphs get <id> Get graph details
|
|
102
|
+
|
|
103
|
+
kiwicli graph-runs list [--graph-id ID] List graph runs (results)
|
|
104
|
+
[--graph-name N] [--status S]
|
|
105
|
+
kiwicli graph-runs get <id> Get graph run details
|
|
106
|
+
|
|
107
|
+
kiwicli runtime status Check if runtime is running (current dir)
|
|
108
|
+
kiwicli runtime stop [--all] Stop runtime (current dir, or all)
|
|
109
|
+
kiwicli runtime list List all runtimes across directories
|
|
110
|
+
kiwicli runtime logs Tail the runtime log (current dir)
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
All list commands support `--limit` and `--offset` for pagination. Runs can be filtered by `--status` (processing, success, error, stuck, waiting).
|
|
114
|
+
|
|
115
|
+
## Interactive TUI
|
|
116
|
+
|
|
117
|
+
Launch with `kiwi` or `kiwicli tui`. The TUI provides a full-screen chat interface for conversing with actions in real time.
|
|
118
|
+
|
|
119
|
+
- **Chat interface** — Send messages to actions and receive streamed responses via SSE
|
|
120
|
+
- **Session management** — Switch actions, continue existing runs, or start new conversations
|
|
121
|
+
- **Slash commands** — All CLI commands work inside the TUI chat with a `/` prefix
|
|
122
|
+
- **Authentication** — Login screen with automatic token refresh
|
|
123
|
+
- **Runtime logs** — View the runtime agent's output in real time (`Ctrl+R`)
|
|
124
|
+
- **Theming** — Dark/light mode toggle (`Ctrl+D`)
|
|
125
|
+
|
|
126
|
+
### Keyboard Shortcuts
|
|
127
|
+
|
|
128
|
+
| Key | Action |
|
|
129
|
+
|-----|--------|
|
|
130
|
+
| `Ctrl+C` | Quit |
|
|
131
|
+
| `Ctrl+R` | Runtime logs |
|
|
132
|
+
| `Ctrl+D` | Toggle dark/light mode |
|
|
133
|
+
| `Ctrl+L` | Logout |
|
|
134
|
+
|
|
135
|
+
### Slash Commands (inside TUI)
|
|
136
|
+
|
|
137
|
+
```
|
|
138
|
+
/use <action_id> Switch to a different action
|
|
139
|
+
/continue <run_id> Continue an existing conversation run
|
|
140
|
+
/new Start a new conversation (resets to default action)
|
|
141
|
+
/status Show current action and run IDs
|
|
142
|
+
|
|
143
|
+
/actions list List all actions
|
|
144
|
+
/runs list --status success Filter runs by status
|
|
145
|
+
/graphs get <id> View graph details
|
|
146
|
+
/help Show all available commands
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
### Streaming
|
|
150
|
+
|
|
151
|
+
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.
|
|
152
|
+
|
|
153
|
+
## Runtime Agent
|
|
154
|
+
|
|
155
|
+
The runtime agent connects to the Kiwi server via WebSocket and executes terminal commands on behalf of the LLM agent.
|
|
156
|
+
|
|
157
|
+
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.
|
|
158
|
+
|
|
159
|
+
To manage runtimes independently:
|
|
160
|
+
|
|
161
|
+
```bash
|
|
162
|
+
kiwicli runtime status # Check if running (for current directory)
|
|
163
|
+
kiwicli runtime stop # Stop the runtime (for current directory)
|
|
164
|
+
kiwicli runtime stop --all # Stop all runtimes
|
|
165
|
+
kiwicli runtime list # List all runtimes across directories
|
|
166
|
+
kiwicli runtime logs # Tail the runtime log (for current directory)
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
You can also run it standalone:
|
|
170
|
+
|
|
171
|
+
```bash
|
|
172
|
+
kiwi-runtime connect --server app # Production (api.meetkiwi.ai)
|
|
173
|
+
kiwi-runtime connect --server dev # Development
|
|
174
|
+
kiwi-runtime connect --server local # Localhost
|
|
175
|
+
kiwi-runtime connect --server wss://custom # Custom URL
|
|
176
|
+
kiwi-runtime connect --scope full # Unrestricted execution (default: restricted)
|
|
177
|
+
kiwi-runtime connect --allow /extra/dir # Allow additional directory in restricted mode
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
In **restricted mode** (default), commands are sandboxed to the current working directory. The `--allow` flag adds extra allowed paths.
|
|
181
|
+
|
|
182
|
+
## Configuration
|
|
183
|
+
|
|
184
|
+
Stored at `~/.autobots-tui/config.json`:
|
|
185
|
+
|
|
186
|
+
```json
|
|
187
|
+
{
|
|
188
|
+
"backend_url": "https://api.example.com",
|
|
189
|
+
"log_level": "INFO",
|
|
190
|
+
"theme": "dark",
|
|
191
|
+
"refresh_interval": 5
|
|
192
|
+
}
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
Logs are written to `~/.autobots-tui/autobots_tui.log`.
|
|
196
|
+
|
|
197
|
+
## Development
|
|
198
|
+
|
|
199
|
+
```bash
|
|
200
|
+
git clone https://github.com/jetoslabs/kiwi-code.git
|
|
201
|
+
cd kiwi-code
|
|
202
|
+
uv sync
|
|
203
|
+
uv run kiwi
|
|
204
|
+
```
|
|
205
|
+
|
|
206
|
+
## License
|
|
207
|
+
|
|
208
|
+
MIT
|