kiwi-code 0.0.16__tar.gz → 0.0.18__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.16 → kiwi_code-0.0.18}/.github/workflows/publish.yml +6 -1
- kiwi_code-0.0.18/.github/workflows/test.yml +45 -0
- kiwi_code-0.0.18/PKG-INFO +289 -0
- kiwi_code-0.0.18/README.md +260 -0
- {kiwi_code-0.0.16 → kiwi_code-0.0.18}/pyproject.toml +17 -2
- {kiwi_code-0.0.16 → kiwi_code-0.0.18}/src/kiwi_cli/cli.py +2 -74
- {kiwi_code-0.0.16 → kiwi_code-0.0.18}/src/kiwi_cli/client.py +7 -0
- kiwi_code-0.0.18/src/kiwi_cli/runtime_manager.py +213 -0
- kiwi_code-0.0.18/src/kiwi_runtime/main.py +2581 -0
- kiwi_code-0.0.18/src/kiwi_runtime/snake_game/.gitignore +3 -0
- kiwi_code-0.0.18/src/kiwi_runtime/snake_game/requirements.txt +3 -0
- kiwi_code-0.0.18/src/kiwi_tui/main.py +919 -0
- kiwi_code-0.0.18/src/kiwi_tui/runtime_agent.py +559 -0
- {kiwi_code-0.0.16 → kiwi_code-0.0.18}/src/kiwi_tui/screens/__init__.py +2 -1
- kiwi_code-0.0.18/src/kiwi_tui/screens/command_result.py +90 -0
- {kiwi_code-0.0.16 → kiwi_code-0.0.18}/src/kiwi_tui/screens/dashboard.py +995 -325
- kiwi_code-0.0.18/src/kiwi_tui/screens/id_picker.py +75 -0
- {kiwi_code-0.0.16 → kiwi_code-0.0.18}/src/kiwi_tui/screens/login.py +9 -5
- kiwi_code-0.0.18/src/kiwi_tui/screens/runtime_cleanup.py +278 -0
- kiwi_code-0.0.18/src/kiwi_tui/screens/runtime_logs.py +131 -0
- {kiwi_code-0.0.16 → kiwi_code-0.0.18}/src/kiwi_tui/screens/slash_picker.py +2 -6
- {kiwi_code-0.0.16 → kiwi_code-0.0.18}/src/kiwi_tui/widgets.py +14 -6
- kiwi_code-0.0.18/tests/__init__.py +0 -0
- kiwi_code-0.0.18/tests/conftest.py +30 -0
- kiwi_code-0.0.18/tests/test_cli_help.py +53 -0
- kiwi_code-0.0.18/tests/test_config.py +27 -0
- kiwi_code-0.0.18/tests/test_imports.py +33 -0
- kiwi_code-0.0.18/tests/test_reexec_kiwi.py +69 -0
- kiwi_code-0.0.18/tests/test_tokens.py +21 -0
- kiwi_code-0.0.18/tests/test_tui_headless.py +90 -0
- {kiwi_code-0.0.16 → kiwi_code-0.0.18}/uv.lock +978 -609
- kiwi_code-0.0.16/PKG-INFO +0 -235
- kiwi_code-0.0.16/README.md +0 -208
- kiwi_code-0.0.16/src/kiwi_cli/runtime_manager.py +0 -213
- kiwi_code-0.0.16/src/kiwi_runtime/main.py +0 -1436
- kiwi_code-0.0.16/src/kiwi_tui/main.py +0 -611
- kiwi_code-0.0.16/src/kiwi_tui/screens/runtime_logs.py +0 -96
- {kiwi_code-0.0.16 → kiwi_code-0.0.18}/.gitignore +0 -0
- {kiwi_code-0.0.16 → kiwi_code-0.0.18}/.python-version +0 -0
- {kiwi_code-0.0.16 → kiwi_code-0.0.18}/CLAUDE.md +0 -0
- {kiwi_code-0.0.16 → kiwi_code-0.0.18}/Makefile +0 -0
- {kiwi_code-0.0.16 → kiwi_code-0.0.18}/src/kiwi_cli/__init__.py +0 -0
- {kiwi_code-0.0.16 → kiwi_code-0.0.18}/src/kiwi_cli/auth.py +0 -0
- {kiwi_code-0.0.16 → kiwi_code-0.0.18}/src/kiwi_cli/commands.py +0 -0
- {kiwi_code-0.0.16 → kiwi_code-0.0.18}/src/kiwi_cli/config.py +0 -0
- {kiwi_code-0.0.16 → kiwi_code-0.0.18}/src/kiwi_cli/logger.py +0 -0
- {kiwi_code-0.0.16 → kiwi_code-0.0.18}/src/kiwi_cli/models.py +0 -0
- {kiwi_code-0.0.16 → kiwi_code-0.0.18}/src/kiwi_runtime/__init__.py +0 -0
- {kiwi_code-0.0.16 → kiwi_code-0.0.18}/src/kiwi_runtime/__main__.py +0 -0
- {kiwi_code-0.0.16 → kiwi_code-0.0.18}/src/kiwi_tui/__init__.py +0 -0
- {kiwi_code-0.0.16 → kiwi_code-0.0.18}/src/kiwi_tui/inline_file_picker.py +0 -0
- {kiwi_code-0.0.16 → kiwi_code-0.0.18}/src/kiwi_tui/screens/attach_content.py +0 -0
- {kiwi_code-0.0.16 → kiwi_code-0.0.18}/src/kiwi_tui/screens/file_browser.py +0 -0
- {kiwi_code-0.0.16 → kiwi_code-0.0.18}/test_hello.py +0 -0
|
@@ -47,10 +47,15 @@ jobs:
|
|
|
47
47
|
run: uv sync
|
|
48
48
|
|
|
49
49
|
- name: Smoke test
|
|
50
|
+
env:
|
|
51
|
+
# Prevent any re-exec / process-renaming logic from interfering with CI.
|
|
52
|
+
_KIWI_PROC_RENAMED: "1"
|
|
53
|
+
KIWI_DISABLE_REEXEC: "1"
|
|
50
54
|
run: |
|
|
51
55
|
uv run kiwicli --help
|
|
56
|
+
uv run kiwi --help
|
|
52
57
|
uv run kiwi-runtime --help
|
|
53
|
-
uv run
|
|
58
|
+
uv run python -c "import kiwi_cli, kiwi_tui, kiwi_runtime; print('imports ok')"
|
|
54
59
|
|
|
55
60
|
- name: Build package
|
|
56
61
|
run: uv build
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
name: Tests
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [main]
|
|
6
|
+
pull_request:
|
|
7
|
+
workflow_dispatch:
|
|
8
|
+
|
|
9
|
+
concurrency:
|
|
10
|
+
group: tests-${{ github.ref }}
|
|
11
|
+
cancel-in-progress: true
|
|
12
|
+
|
|
13
|
+
jobs:
|
|
14
|
+
test:
|
|
15
|
+
name: pytest · py${{ matrix.python-version }} · ${{ matrix.os }}
|
|
16
|
+
runs-on: ${{ matrix.os }}
|
|
17
|
+
strategy:
|
|
18
|
+
fail-fast: false
|
|
19
|
+
matrix:
|
|
20
|
+
os: [ubuntu-latest, macos-latest]
|
|
21
|
+
python-version: ["3.11", "3.12", "3.13"]
|
|
22
|
+
|
|
23
|
+
steps:
|
|
24
|
+
- uses: actions/checkout@v4
|
|
25
|
+
|
|
26
|
+
- name: Install uv
|
|
27
|
+
uses: astral-sh/setup-uv@v4
|
|
28
|
+
with:
|
|
29
|
+
enable-cache: true
|
|
30
|
+
|
|
31
|
+
- name: Set up Python ${{ matrix.python-version }}
|
|
32
|
+
run: uv python install ${{ matrix.python-version }}
|
|
33
|
+
|
|
34
|
+
- name: Sync dependencies (with test group)
|
|
35
|
+
run: uv sync --python ${{ matrix.python-version }} --group test
|
|
36
|
+
|
|
37
|
+
- name: Run pytest
|
|
38
|
+
run: uv run --python ${{ matrix.python-version }} pytest -v --tb=short
|
|
39
|
+
|
|
40
|
+
- name: Entry-point smoke tests
|
|
41
|
+
run: |
|
|
42
|
+
uv run --python ${{ matrix.python-version }} kiwicli --help
|
|
43
|
+
uv run --python ${{ matrix.python-version }} kiwi-runtime --help
|
|
44
|
+
env:
|
|
45
|
+
_KIWI_PROC_RENAMED: "1"
|
|
@@ -0,0 +1,289 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: kiwi-code
|
|
3
|
+
Version: 0.0.18
|
|
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: Proprietary
|
|
9
|
+
Keywords: cli,terminal,textual,tui
|
|
10
|
+
Classifier: Development Status :: 3 - Alpha
|
|
11
|
+
Classifier: Intended Audience :: Developers
|
|
12
|
+
Classifier: License :: Other/Proprietary License
|
|
13
|
+
Classifier: Programming Language :: Python :: 3
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
17
|
+
Requires-Python: <4.0,>=3.11
|
|
18
|
+
Requires-Dist: autobots-client==0.1.0
|
|
19
|
+
Requires-Dist: httpx>=0.25.0
|
|
20
|
+
Requires-Dist: loguru>=0.7.3
|
|
21
|
+
Requires-Dist: psutil>=5.9.0
|
|
22
|
+
Requires-Dist: pydantic>=2.12.5
|
|
23
|
+
Requires-Dist: setproctitle>=1.3.0
|
|
24
|
+
Requires-Dist: textual-dev>=1.8.0
|
|
25
|
+
Requires-Dist: textual>=8.1.1
|
|
26
|
+
Requires-Dist: typer>=0.24.1
|
|
27
|
+
Requires-Dist: websockets>=14.1
|
|
28
|
+
Description-Content-Type: text/markdown
|
|
29
|
+
|
|
30
|
+
# Kiwi Code
|
|
31
|
+
|
|
32
|
+
Kiwi Code is a terminal-first UI (TUI) for chatting with **Kiwi Actions** and managing **runs** (action results). It also integrates with the **Kiwi Runtime** (a local CLI/terminal agent) so actions can execute terminal commands on your machine.
|
|
33
|
+
|
|
34
|
+
- **TUI:** `kiwi` (or `python -m kiwi_tui.main`)
|
|
35
|
+
- **CLI:** `kiwicli` (optional; scripting / inspection)
|
|
36
|
+
|
|
37
|
+
> Requires **Python 3.13+**.
|
|
38
|
+
|
|
39
|
+
---
|
|
40
|
+
|
|
41
|
+
## Quick start
|
|
42
|
+
|
|
43
|
+
### 1) Install deps (repo)
|
|
44
|
+
|
|
45
|
+
```bash
|
|
46
|
+
cd kiwi-code
|
|
47
|
+
uv sync
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
### 2) Start the TUI
|
|
51
|
+
|
|
52
|
+
Choose a server preset:
|
|
53
|
+
|
|
54
|
+
- `app` (prod)
|
|
55
|
+
- `dev` (dev)
|
|
56
|
+
- `local` (localhost)
|
|
57
|
+
|
|
58
|
+
```bash
|
|
59
|
+
uv run python -m kiwi_tui.main --server dev
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
Or, if installed as a package:
|
|
63
|
+
|
|
64
|
+
```bash
|
|
65
|
+
kiwi --server dev
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
### 3) Login
|
|
69
|
+
|
|
70
|
+
The TUI will show a login screen if you’re not authenticated.
|
|
71
|
+
|
|
72
|
+
Tokens/config are stored under:
|
|
73
|
+
|
|
74
|
+
- `~/.kiwi/tokens.json`
|
|
75
|
+
- `~/.kiwi/config.json`
|
|
76
|
+
|
|
77
|
+
---
|
|
78
|
+
|
|
79
|
+
## Daily workflow (TUI)
|
|
80
|
+
|
|
81
|
+
### Pick an action → chat
|
|
82
|
+
|
|
83
|
+
- `/actions list` → pick an action
|
|
84
|
+
- Type a message and press Enter
|
|
85
|
+
|
|
86
|
+
### Start a fresh conversation
|
|
87
|
+
|
|
88
|
+
- `/new` resets the chat to the default action and clears history in the UI.
|
|
89
|
+
|
|
90
|
+
### Continue an existing run (conversation)
|
|
91
|
+
|
|
92
|
+
- `/runs list` → pick a run
|
|
93
|
+
- or `/continue <run_id>`
|
|
94
|
+
|
|
95
|
+
Kiwi Code will load the conversation history for that run.
|
|
96
|
+
|
|
97
|
+
---
|
|
98
|
+
|
|
99
|
+
## Local CLI agent (Runtime)
|
|
100
|
+
|
|
101
|
+
Some actions can execute terminal commands via a local runtime process.
|
|
102
|
+
|
|
103
|
+
### Connect the runtime to the current run
|
|
104
|
+
|
|
105
|
+
Inside the TUI:
|
|
106
|
+
|
|
107
|
+
- `/connect-cli`
|
|
108
|
+
|
|
109
|
+
What it does:
|
|
110
|
+
|
|
111
|
+
- Ensures a local runtime exists **for the current run_id**.
|
|
112
|
+
- If the runtime was disconnected (e.g., server redeploy), Kiwi Code detects it and starts a fresh one.
|
|
113
|
+
- Sends the instruction prompt: “Connect to the CLI right now before asking or doing anything.”
|
|
114
|
+
|
|
115
|
+
### View runtime logs
|
|
116
|
+
|
|
117
|
+
- Slash command: `/show-logs`
|
|
118
|
+
- Keyboard shortcut: **Ctrl+O** (works even while the chat input is disabled / streaming)
|
|
119
|
+
|
|
120
|
+
### Runtime lifecycle
|
|
121
|
+
|
|
122
|
+
- Runtime processes are tracked under `~/.kiwi/runtimes/`.
|
|
123
|
+
- Runtimes are **per run_id** (one runtime process per run).
|
|
124
|
+
- Runtimes may survive TUI restarts.
|
|
125
|
+
- On quit (`Ctrl+C`), Kiwi Code shows an exit prompt listing runtimes and lets you choose which to kill.
|
|
126
|
+
|
|
127
|
+
---
|
|
128
|
+
|
|
129
|
+
## Keyboard shortcuts (TUI)
|
|
130
|
+
|
|
131
|
+
These are designed to work even when input is blocked during streaming.
|
|
132
|
+
|
|
133
|
+
| Key | Action |
|
|
134
|
+
|---|---|
|
|
135
|
+
| `Ctrl+C` | Quit (shows runtime cleanup prompt if runtimes are alive) |
|
|
136
|
+
| `Ctrl+O` | Open CLI logs (`/show-logs`) |
|
|
137
|
+
| `Ctrl+G` | Open slash-command picker (`/ ...`) |
|
|
138
|
+
| `Ctrl+U` | Attach files / content (`@ ...`) |
|
|
139
|
+
| `Ctrl+J` | Send message |
|
|
140
|
+
|
|
141
|
+
---
|
|
142
|
+
|
|
143
|
+
## Slash commands (TUI)
|
|
144
|
+
|
|
145
|
+
### Session
|
|
146
|
+
|
|
147
|
+
- `/use <action_id>` — switch action (starts a **fresh chat UI**)
|
|
148
|
+
- `/actions list` — list & select actions
|
|
149
|
+
- `/new` — new conversation (default action)
|
|
150
|
+
- `/continue <run_id>` — continue an existing run and load history
|
|
151
|
+
- `/runs list` — list & select runs
|
|
152
|
+
- `/status` — show current action/run ids
|
|
153
|
+
|
|
154
|
+
### Files
|
|
155
|
+
|
|
156
|
+
- `@` opens the inline file picker
|
|
157
|
+
- `/upload <path> [path2 ...]` uploads files and attaches them to your next message
|
|
158
|
+
- `/files` shows pending attachments
|
|
159
|
+
- `/clear-files` clears pending attachments
|
|
160
|
+
|
|
161
|
+
### Runtime
|
|
162
|
+
|
|
163
|
+
- `/connect-cli` — ensure runtime exists (per run_id) + send “connect” prompt
|
|
164
|
+
- `/show-logs` — open runtime logs screen
|
|
165
|
+
|
|
166
|
+
---
|
|
167
|
+
|
|
168
|
+
## CLI (optional)
|
|
169
|
+
|
|
170
|
+
`kiwicli` provides the same “list/get” style commands for scripting and inspection.
|
|
171
|
+
|
|
172
|
+
Examples:
|
|
173
|
+
|
|
174
|
+
```bash
|
|
175
|
+
kiwicli actions list
|
|
176
|
+
kiwicli actions get <action_id>
|
|
177
|
+
|
|
178
|
+
kiwicli runs list --status processing
|
|
179
|
+
kiwicli runs get <run_id>
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
---
|
|
183
|
+
|
|
184
|
+
## Server / flags
|
|
185
|
+
|
|
186
|
+
`kiwi` / `python -m kiwi_tui.main` supports runtime flags (mirrors `kiwi-runtime connect`). These flags are used when Kiwi Code needs to start a runtime.
|
|
187
|
+
|
|
188
|
+
```bash
|
|
189
|
+
kiwi --server dev \
|
|
190
|
+
--scope restricted \
|
|
191
|
+
--allow /some/extra/dir
|
|
192
|
+
```
|
|
193
|
+
|
|
194
|
+
- `--server`: `app | dev | local | <full url>`
|
|
195
|
+
- `--scope`: `restricted | full`
|
|
196
|
+
- `--allow PATH`: repeatable; additional allowed directories in restricted mode
|
|
197
|
+
|
|
198
|
+
> Note: Kiwi Code does **not** modify the runtime implementation under `src/kiwi_runtime/`.
|
|
199
|
+
|
|
200
|
+
---
|
|
201
|
+
|
|
202
|
+
## Using `kiwi-runtime` standalone (advanced)
|
|
203
|
+
|
|
204
|
+
You can run the Kiwi Runtime by itself (without the TUI). This is useful for:
|
|
205
|
+
- debugging runtime connectivity / permissions
|
|
206
|
+
- keeping a long-lived runtime running in a separate terminal tab
|
|
207
|
+
- watching runtime activity/logs directly
|
|
208
|
+
|
|
209
|
+
### Start the runtime
|
|
210
|
+
|
|
211
|
+
If you installed kiwi-code as a package:
|
|
212
|
+
|
|
213
|
+
```bash
|
|
214
|
+
kiwi-runtime connect --server dev --scope restricted --allow "$PWD"
|
|
215
|
+
```
|
|
216
|
+
|
|
217
|
+
From the repo (recommended for development):
|
|
218
|
+
|
|
219
|
+
```bash
|
|
220
|
+
uv run python -m kiwi_runtime.main connect --server dev --scope restricted --allow "$PWD"
|
|
221
|
+
```
|
|
222
|
+
|
|
223
|
+
Notes:
|
|
224
|
+
- `--server` supports presets: `app`, `dev`, `local` (or a full URL).
|
|
225
|
+
- `--scope restricted` is the default; use `--allow` to add directories.
|
|
226
|
+
- The runtime prints connection status and will remain running until you stop it.
|
|
227
|
+
|
|
228
|
+
### Authentication
|
|
229
|
+
|
|
230
|
+
The runtime typically needs an access token. When you run the TUI and log in, your token is saved to:
|
|
231
|
+
- `~/.kiwi/tokens.json`
|
|
232
|
+
|
|
233
|
+
You can pass the token explicitly (if required by your setup):
|
|
234
|
+
|
|
235
|
+
```bash
|
|
236
|
+
kiwi-runtime connect --server dev --token <ACCESS_TOKEN>
|
|
237
|
+
```
|
|
238
|
+
|
|
239
|
+
### Stop the runtime
|
|
240
|
+
|
|
241
|
+
Press **Ctrl+C** in the runtime terminal to disconnect and exit.
|
|
242
|
+
|
|
243
|
+
### Important behavior when running standalone
|
|
244
|
+
|
|
245
|
+
- Standalone runtimes are **not tracked** in `~/.kiwi/runtimes/` (that directory is used by kiwi-code to track TUI-managed runtimes).
|
|
246
|
+
- If you run the TUI and then run `/connect-cli`, kiwi-code may start its own runtime process if it doesn’t detect a managed runtime for the current run.
|
|
247
|
+
- For normal usage, prefer letting the TUI manage the runtime via `/connect-cli`.
|
|
248
|
+
- For standalone/debug usage, run `kiwi-runtime connect ...` in a separate terminal and use it to observe activity.
|
|
249
|
+
|
|
250
|
+
---
|
|
251
|
+
|
|
252
|
+
## Troubleshooting
|
|
253
|
+
|
|
254
|
+
### “CLI runtime stopped responding” after server redeploy
|
|
255
|
+
|
|
256
|
+
If the backend restarts (common in `dev`), the runtime websocket may close.
|
|
257
|
+
|
|
258
|
+
Fix:
|
|
259
|
+
1. In Kiwi Code, run `/connect-cli` again.
|
|
260
|
+
2. If needed, open logs (Ctrl+O) to confirm the new runtime connected.
|
|
261
|
+
|
|
262
|
+
Kiwi Code validates existing runtime processes and will restart them when they’re invalid/disconnected.
|
|
263
|
+
|
|
264
|
+
### Quit shows a runtime cleanup prompt
|
|
265
|
+
|
|
266
|
+
This is expected. Select runtimes to kill (or press Esc to keep them running).
|
|
267
|
+
|
|
268
|
+
---
|
|
269
|
+
|
|
270
|
+
## Development
|
|
271
|
+
|
|
272
|
+
```bash
|
|
273
|
+
git clone https://github.com/jetoslabs/kiwi-code.git
|
|
274
|
+
cd kiwi-code
|
|
275
|
+
uv sync
|
|
276
|
+
uv run python -m kiwi_tui.main --server dev
|
|
277
|
+
```
|
|
278
|
+
|
|
279
|
+
Run tests:
|
|
280
|
+
|
|
281
|
+
```bash
|
|
282
|
+
uv run python -m pytest -q
|
|
283
|
+
```
|
|
284
|
+
|
|
285
|
+
---
|
|
286
|
+
|
|
287
|
+
## License
|
|
288
|
+
|
|
289
|
+
Proprietary. All rights reserved.
|
|
@@ -0,0 +1,260 @@
|
|
|
1
|
+
# Kiwi Code
|
|
2
|
+
|
|
3
|
+
Kiwi Code is a terminal-first UI (TUI) for chatting with **Kiwi Actions** and managing **runs** (action results). It also integrates with the **Kiwi Runtime** (a local CLI/terminal agent) so actions can execute terminal commands on your machine.
|
|
4
|
+
|
|
5
|
+
- **TUI:** `kiwi` (or `python -m kiwi_tui.main`)
|
|
6
|
+
- **CLI:** `kiwicli` (optional; scripting / inspection)
|
|
7
|
+
|
|
8
|
+
> Requires **Python 3.13+**.
|
|
9
|
+
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
## Quick start
|
|
13
|
+
|
|
14
|
+
### 1) Install deps (repo)
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
cd kiwi-code
|
|
18
|
+
uv sync
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
### 2) Start the TUI
|
|
22
|
+
|
|
23
|
+
Choose a server preset:
|
|
24
|
+
|
|
25
|
+
- `app` (prod)
|
|
26
|
+
- `dev` (dev)
|
|
27
|
+
- `local` (localhost)
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
uv run python -m kiwi_tui.main --server dev
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
Or, if installed as a package:
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
kiwi --server dev
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
### 3) Login
|
|
40
|
+
|
|
41
|
+
The TUI will show a login screen if you’re not authenticated.
|
|
42
|
+
|
|
43
|
+
Tokens/config are stored under:
|
|
44
|
+
|
|
45
|
+
- `~/.kiwi/tokens.json`
|
|
46
|
+
- `~/.kiwi/config.json`
|
|
47
|
+
|
|
48
|
+
---
|
|
49
|
+
|
|
50
|
+
## Daily workflow (TUI)
|
|
51
|
+
|
|
52
|
+
### Pick an action → chat
|
|
53
|
+
|
|
54
|
+
- `/actions list` → pick an action
|
|
55
|
+
- Type a message and press Enter
|
|
56
|
+
|
|
57
|
+
### Start a fresh conversation
|
|
58
|
+
|
|
59
|
+
- `/new` resets the chat to the default action and clears history in the UI.
|
|
60
|
+
|
|
61
|
+
### Continue an existing run (conversation)
|
|
62
|
+
|
|
63
|
+
- `/runs list` → pick a run
|
|
64
|
+
- or `/continue <run_id>`
|
|
65
|
+
|
|
66
|
+
Kiwi Code will load the conversation history for that run.
|
|
67
|
+
|
|
68
|
+
---
|
|
69
|
+
|
|
70
|
+
## Local CLI agent (Runtime)
|
|
71
|
+
|
|
72
|
+
Some actions can execute terminal commands via a local runtime process.
|
|
73
|
+
|
|
74
|
+
### Connect the runtime to the current run
|
|
75
|
+
|
|
76
|
+
Inside the TUI:
|
|
77
|
+
|
|
78
|
+
- `/connect-cli`
|
|
79
|
+
|
|
80
|
+
What it does:
|
|
81
|
+
|
|
82
|
+
- Ensures a local runtime exists **for the current run_id**.
|
|
83
|
+
- If the runtime was disconnected (e.g., server redeploy), Kiwi Code detects it and starts a fresh one.
|
|
84
|
+
- Sends the instruction prompt: “Connect to the CLI right now before asking or doing anything.”
|
|
85
|
+
|
|
86
|
+
### View runtime logs
|
|
87
|
+
|
|
88
|
+
- Slash command: `/show-logs`
|
|
89
|
+
- Keyboard shortcut: **Ctrl+O** (works even while the chat input is disabled / streaming)
|
|
90
|
+
|
|
91
|
+
### Runtime lifecycle
|
|
92
|
+
|
|
93
|
+
- Runtime processes are tracked under `~/.kiwi/runtimes/`.
|
|
94
|
+
- Runtimes are **per run_id** (one runtime process per run).
|
|
95
|
+
- Runtimes may survive TUI restarts.
|
|
96
|
+
- On quit (`Ctrl+C`), Kiwi Code shows an exit prompt listing runtimes and lets you choose which to kill.
|
|
97
|
+
|
|
98
|
+
---
|
|
99
|
+
|
|
100
|
+
## Keyboard shortcuts (TUI)
|
|
101
|
+
|
|
102
|
+
These are designed to work even when input is blocked during streaming.
|
|
103
|
+
|
|
104
|
+
| Key | Action |
|
|
105
|
+
|---|---|
|
|
106
|
+
| `Ctrl+C` | Quit (shows runtime cleanup prompt if runtimes are alive) |
|
|
107
|
+
| `Ctrl+O` | Open CLI logs (`/show-logs`) |
|
|
108
|
+
| `Ctrl+G` | Open slash-command picker (`/ ...`) |
|
|
109
|
+
| `Ctrl+U` | Attach files / content (`@ ...`) |
|
|
110
|
+
| `Ctrl+J` | Send message |
|
|
111
|
+
|
|
112
|
+
---
|
|
113
|
+
|
|
114
|
+
## Slash commands (TUI)
|
|
115
|
+
|
|
116
|
+
### Session
|
|
117
|
+
|
|
118
|
+
- `/use <action_id>` — switch action (starts a **fresh chat UI**)
|
|
119
|
+
- `/actions list` — list & select actions
|
|
120
|
+
- `/new` — new conversation (default action)
|
|
121
|
+
- `/continue <run_id>` — continue an existing run and load history
|
|
122
|
+
- `/runs list` — list & select runs
|
|
123
|
+
- `/status` — show current action/run ids
|
|
124
|
+
|
|
125
|
+
### Files
|
|
126
|
+
|
|
127
|
+
- `@` opens the inline file picker
|
|
128
|
+
- `/upload <path> [path2 ...]` uploads files and attaches them to your next message
|
|
129
|
+
- `/files` shows pending attachments
|
|
130
|
+
- `/clear-files` clears pending attachments
|
|
131
|
+
|
|
132
|
+
### Runtime
|
|
133
|
+
|
|
134
|
+
- `/connect-cli` — ensure runtime exists (per run_id) + send “connect” prompt
|
|
135
|
+
- `/show-logs` — open runtime logs screen
|
|
136
|
+
|
|
137
|
+
---
|
|
138
|
+
|
|
139
|
+
## CLI (optional)
|
|
140
|
+
|
|
141
|
+
`kiwicli` provides the same “list/get” style commands for scripting and inspection.
|
|
142
|
+
|
|
143
|
+
Examples:
|
|
144
|
+
|
|
145
|
+
```bash
|
|
146
|
+
kiwicli actions list
|
|
147
|
+
kiwicli actions get <action_id>
|
|
148
|
+
|
|
149
|
+
kiwicli runs list --status processing
|
|
150
|
+
kiwicli runs get <run_id>
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
---
|
|
154
|
+
|
|
155
|
+
## Server / flags
|
|
156
|
+
|
|
157
|
+
`kiwi` / `python -m kiwi_tui.main` supports runtime flags (mirrors `kiwi-runtime connect`). These flags are used when Kiwi Code needs to start a runtime.
|
|
158
|
+
|
|
159
|
+
```bash
|
|
160
|
+
kiwi --server dev \
|
|
161
|
+
--scope restricted \
|
|
162
|
+
--allow /some/extra/dir
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
- `--server`: `app | dev | local | <full url>`
|
|
166
|
+
- `--scope`: `restricted | full`
|
|
167
|
+
- `--allow PATH`: repeatable; additional allowed directories in restricted mode
|
|
168
|
+
|
|
169
|
+
> Note: Kiwi Code does **not** modify the runtime implementation under `src/kiwi_runtime/`.
|
|
170
|
+
|
|
171
|
+
---
|
|
172
|
+
|
|
173
|
+
## Using `kiwi-runtime` standalone (advanced)
|
|
174
|
+
|
|
175
|
+
You can run the Kiwi Runtime by itself (without the TUI). This is useful for:
|
|
176
|
+
- debugging runtime connectivity / permissions
|
|
177
|
+
- keeping a long-lived runtime running in a separate terminal tab
|
|
178
|
+
- watching runtime activity/logs directly
|
|
179
|
+
|
|
180
|
+
### Start the runtime
|
|
181
|
+
|
|
182
|
+
If you installed kiwi-code as a package:
|
|
183
|
+
|
|
184
|
+
```bash
|
|
185
|
+
kiwi-runtime connect --server dev --scope restricted --allow "$PWD"
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
From the repo (recommended for development):
|
|
189
|
+
|
|
190
|
+
```bash
|
|
191
|
+
uv run python -m kiwi_runtime.main connect --server dev --scope restricted --allow "$PWD"
|
|
192
|
+
```
|
|
193
|
+
|
|
194
|
+
Notes:
|
|
195
|
+
- `--server` supports presets: `app`, `dev`, `local` (or a full URL).
|
|
196
|
+
- `--scope restricted` is the default; use `--allow` to add directories.
|
|
197
|
+
- The runtime prints connection status and will remain running until you stop it.
|
|
198
|
+
|
|
199
|
+
### Authentication
|
|
200
|
+
|
|
201
|
+
The runtime typically needs an access token. When you run the TUI and log in, your token is saved to:
|
|
202
|
+
- `~/.kiwi/tokens.json`
|
|
203
|
+
|
|
204
|
+
You can pass the token explicitly (if required by your setup):
|
|
205
|
+
|
|
206
|
+
```bash
|
|
207
|
+
kiwi-runtime connect --server dev --token <ACCESS_TOKEN>
|
|
208
|
+
```
|
|
209
|
+
|
|
210
|
+
### Stop the runtime
|
|
211
|
+
|
|
212
|
+
Press **Ctrl+C** in the runtime terminal to disconnect and exit.
|
|
213
|
+
|
|
214
|
+
### Important behavior when running standalone
|
|
215
|
+
|
|
216
|
+
- Standalone runtimes are **not tracked** in `~/.kiwi/runtimes/` (that directory is used by kiwi-code to track TUI-managed runtimes).
|
|
217
|
+
- If you run the TUI and then run `/connect-cli`, kiwi-code may start its own runtime process if it doesn’t detect a managed runtime for the current run.
|
|
218
|
+
- For normal usage, prefer letting the TUI manage the runtime via `/connect-cli`.
|
|
219
|
+
- For standalone/debug usage, run `kiwi-runtime connect ...` in a separate terminal and use it to observe activity.
|
|
220
|
+
|
|
221
|
+
---
|
|
222
|
+
|
|
223
|
+
## Troubleshooting
|
|
224
|
+
|
|
225
|
+
### “CLI runtime stopped responding” after server redeploy
|
|
226
|
+
|
|
227
|
+
If the backend restarts (common in `dev`), the runtime websocket may close.
|
|
228
|
+
|
|
229
|
+
Fix:
|
|
230
|
+
1. In Kiwi Code, run `/connect-cli` again.
|
|
231
|
+
2. If needed, open logs (Ctrl+O) to confirm the new runtime connected.
|
|
232
|
+
|
|
233
|
+
Kiwi Code validates existing runtime processes and will restart them when they’re invalid/disconnected.
|
|
234
|
+
|
|
235
|
+
### Quit shows a runtime cleanup prompt
|
|
236
|
+
|
|
237
|
+
This is expected. Select runtimes to kill (or press Esc to keep them running).
|
|
238
|
+
|
|
239
|
+
---
|
|
240
|
+
|
|
241
|
+
## Development
|
|
242
|
+
|
|
243
|
+
```bash
|
|
244
|
+
git clone https://github.com/jetoslabs/kiwi-code.git
|
|
245
|
+
cd kiwi-code
|
|
246
|
+
uv sync
|
|
247
|
+
uv run python -m kiwi_tui.main --server dev
|
|
248
|
+
```
|
|
249
|
+
|
|
250
|
+
Run tests:
|
|
251
|
+
|
|
252
|
+
```bash
|
|
253
|
+
uv run python -m pytest -q
|
|
254
|
+
```
|
|
255
|
+
|
|
256
|
+
---
|
|
257
|
+
|
|
258
|
+
## License
|
|
259
|
+
|
|
260
|
+
Proprietary. All rights reserved.
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "kiwi-code"
|
|
3
|
-
version = "0.0.
|
|
3
|
+
version = "0.0.18"
|
|
4
4
|
description = "A textual-based terminal user interface application"
|
|
5
5
|
readme = {file = "README.md", content-type = "text/markdown"}
|
|
6
|
-
requires-python = ">=3.
|
|
6
|
+
requires-python = ">=3.11,<4.0"
|
|
7
7
|
dependencies = [
|
|
8
8
|
"autobots-client==0.1.0",
|
|
9
9
|
"loguru>=0.7.3",
|
|
@@ -26,6 +26,8 @@ classifiers = [
|
|
|
26
26
|
"Intended Audience :: Developers",
|
|
27
27
|
"License :: Other/Proprietary License",
|
|
28
28
|
"Programming Language :: Python :: 3",
|
|
29
|
+
"Programming Language :: Python :: 3.11",
|
|
30
|
+
"Programming Language :: Python :: 3.12",
|
|
29
31
|
"Programming Language :: Python :: 3.13",
|
|
30
32
|
]
|
|
31
33
|
|
|
@@ -38,6 +40,19 @@ kiwi = "kiwi_tui.main:main"
|
|
|
38
40
|
kiwicli = "kiwi_cli.cli:cli"
|
|
39
41
|
kiwi-runtime = "kiwi_runtime.main:main"
|
|
40
42
|
|
|
43
|
+
[dependency-groups]
|
|
44
|
+
test = [
|
|
45
|
+
"pytest>=8.0",
|
|
46
|
+
"pytest-asyncio>=0.24",
|
|
47
|
+
]
|
|
48
|
+
|
|
49
|
+
[tool.pytest.ini_options]
|
|
50
|
+
asyncio_mode = "auto"
|
|
51
|
+
testpaths = ["tests"]
|
|
52
|
+
filterwarnings = [
|
|
53
|
+
"ignore::DeprecationWarning",
|
|
54
|
+
]
|
|
55
|
+
|
|
41
56
|
[tool.hatch.build.targets.wheel]
|
|
42
57
|
packages = ["src/kiwi_cli", "src/kiwi_tui", "src/kiwi_runtime"]
|
|
43
58
|
|