kiwi-ai 0.0.11__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.
Files changed (69) hide show
  1. kiwi_ai-0.0.11/.github/workflows/publish.yml +77 -0
  2. kiwi_ai-0.0.11/.github/workflows/test.yml +45 -0
  3. kiwi_ai-0.0.11/.gitignore +32 -0
  4. kiwi_ai-0.0.11/.python-version +1 -0
  5. kiwi_ai-0.0.11/Makefile +69 -0
  6. kiwi_ai-0.0.11/PKG-INFO +429 -0
  7. kiwi_ai-0.0.11/README.md +399 -0
  8. kiwi_ai-0.0.11/pyproject.toml +64 -0
  9. kiwi_ai-0.0.11/scripts/ws_auth_check.py +76 -0
  10. kiwi_ai-0.0.11/src/kiwi_cli/__init__.py +3 -0
  11. kiwi_ai-0.0.11/src/kiwi_cli/auth.py +180 -0
  12. kiwi_ai-0.0.11/src/kiwi_cli/checkpoints.py +930 -0
  13. kiwi_ai-0.0.11/src/kiwi_cli/cli.py +252 -0
  14. kiwi_ai-0.0.11/src/kiwi_cli/client.py +664 -0
  15. kiwi_ai-0.0.11/src/kiwi_cli/commands.py +294 -0
  16. kiwi_ai-0.0.11/src/kiwi_cli/logger.py +32 -0
  17. kiwi_ai-0.0.11/src/kiwi_cli/models.py +122 -0
  18. kiwi_ai-0.0.11/src/kiwi_cli/runtime_manager.py +213 -0
  19. kiwi_ai-0.0.11/src/kiwi_cli/server.py +45 -0
  20. kiwi_ai-0.0.11/src/kiwi_cli/terminal_mode.py +478 -0
  21. kiwi_ai-0.0.11/src/kiwi_runtime/__init__.py +3 -0
  22. kiwi_ai-0.0.11/src/kiwi_runtime/__main__.py +5 -0
  23. kiwi_ai-0.0.11/src/kiwi_runtime/main.py +5155 -0
  24. kiwi_ai-0.0.11/src/kiwi_tui/__init__.py +3 -0
  25. kiwi_ai-0.0.11/src/kiwi_tui/inline_file_picker.py +163 -0
  26. kiwi_ai-0.0.11/src/kiwi_tui/main.py +1431 -0
  27. kiwi_ai-0.0.11/src/kiwi_tui/random_words.py +9 -0
  28. kiwi_ai-0.0.11/src/kiwi_tui/runtime_agent.py +866 -0
  29. kiwi_ai-0.0.11/src/kiwi_tui/screens/__init__.py +8 -0
  30. kiwi_ai-0.0.11/src/kiwi_tui/screens/attach_content.py +114 -0
  31. kiwi_ai-0.0.11/src/kiwi_tui/screens/command_result.py +90 -0
  32. kiwi_ai-0.0.11/src/kiwi_tui/screens/dashboard.py +3936 -0
  33. kiwi_ai-0.0.11/src/kiwi_tui/screens/detach_files.py +146 -0
  34. kiwi_ai-0.0.11/src/kiwi_tui/screens/file_browser.py +207 -0
  35. kiwi_ai-0.0.11/src/kiwi_tui/screens/help.py +219 -0
  36. kiwi_ai-0.0.11/src/kiwi_tui/screens/id_picker.py +247 -0
  37. kiwi_ai-0.0.11/src/kiwi_tui/screens/login.py +370 -0
  38. kiwi_ai-0.0.11/src/kiwi_tui/screens/runtime_cleanup.py +346 -0
  39. kiwi_ai-0.0.11/src/kiwi_tui/screens/runtime_logs.py +473 -0
  40. kiwi_ai-0.0.11/src/kiwi_tui/screens/slash_picker.py +73 -0
  41. kiwi_ai-0.0.11/src/kiwi_tui/screens/term_dashboard.py +5217 -0
  42. kiwi_ai-0.0.11/src/kiwi_tui/slash_commands.py +76 -0
  43. kiwi_ai-0.0.11/src/kiwi_tui/status_words.py +503 -0
  44. kiwi_ai-0.0.11/src/kiwi_tui/term_app.py +9 -0
  45. kiwi_ai-0.0.11/src/kiwi_tui/ui_settings.py +40 -0
  46. kiwi_ai-0.0.11/src/kiwi_tui/widgets.py +716 -0
  47. kiwi_ai-0.0.11/src/kiwi_tui/worktrees.py +315 -0
  48. kiwi_ai-0.0.11/test_hello.py +19 -0
  49. kiwi_ai-0.0.11/tests/__init__.py +0 -0
  50. kiwi_ai-0.0.11/tests/conftest.py +28 -0
  51. kiwi_ai-0.0.11/tests/test_batch_fs_tool.py +168 -0
  52. kiwi_ai-0.0.11/tests/test_checkpoints.py +199 -0
  53. kiwi_ai-0.0.11/tests/test_cli_help.py +81 -0
  54. kiwi_ai-0.0.11/tests/test_copy_path_fs_tool.py +91 -0
  55. kiwi_ai-0.0.11/tests/test_imports.py +30 -0
  56. kiwi_ai-0.0.11/tests/test_read_file_streaming.py +151 -0
  57. kiwi_ai-0.0.11/tests/test_reexec_kiwi.py +76 -0
  58. kiwi_ai-0.0.11/tests/test_runtime_log_trimming.py +38 -0
  59. kiwi_ai-0.0.11/tests/test_search_in_files_fs_tool.py +152 -0
  60. kiwi_ai-0.0.11/tests/test_slash_commands.py +16 -0
  61. kiwi_ai-0.0.11/tests/test_term_dashboard_ui.py +676 -0
  62. kiwi_ai-0.0.11/tests/test_terminal_mode.py +112 -0
  63. kiwi_ai-0.0.11/tests/test_tokens.py +18 -0
  64. kiwi_ai-0.0.11/tests/test_tui_headless.py +1100 -0
  65. kiwi_ai-0.0.11/tests/test_tui_interactive_runtime.py +383 -0
  66. kiwi_ai-0.0.11/tests/test_tui_palette.py +67 -0
  67. kiwi_ai-0.0.11/tests/test_unified_diff.py +86 -0
  68. kiwi_ai-0.0.11/tests/test_worktrees.py +267 -0
  69. kiwi_ai-0.0.11/uv.lock +1480 -0
@@ -0,0 +1,77 @@
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
+ env:
51
+ # Prevent any re-exec / process-renaming logic from interfering with CI.
52
+ _KIWI_PROC_RENAMED: "1"
53
+ KIWI_DISABLE_REEXEC: "1"
54
+ run: |
55
+ uv run kiwicli --help
56
+ uv run kiwi --help
57
+ uv run kiwi-runtime --help
58
+ uv run python -c "import kiwi_cli, kiwi_tui, kiwi_runtime; print('imports ok')"
59
+
60
+ - name: Build package
61
+ run: uv build
62
+
63
+ - name: Verify build artifacts
64
+ run: |
65
+ ls -lh dist/
66
+ # Check that the built version matches the expected version
67
+ EXPECTED="${{ steps.version.outputs.version }}"
68
+ if ! ls dist/ | grep -q "$EXPECTED"; then
69
+ echo "ERROR: Built artifacts do not contain expected version $EXPECTED"
70
+ ls dist/
71
+ exit 1
72
+ fi
73
+
74
+ - name: Publish to PyPI
75
+ env:
76
+ UV_PUBLISH_TOKEN: ${{ secrets.PYPI_TOKEN }}
77
+ run: uv publish
@@ -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,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
+ .kiwi/
@@ -0,0 +1 @@
1
+ 3.13
@@ -0,0 +1,69 @@
1
+ .PHONY: run dev serve 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
+ # Serve the Kiwi TUI in the browser via textual serve (e.g. make serve PORT=8566)
12
+ serve:
13
+ uv run textual serve --port $(or $(PORT),8566) -c "python -m kiwi_tui.main"
14
+
15
+ # Run the Kiwi CLI
16
+ cli:
17
+ uv run kiwicli
18
+
19
+ # Run the Kiwi Runtime agent (pass ARGS, e.g. make runtime ARGS="connect --server app")
20
+ runtime:
21
+ uv run kiwi-runtime $(ARGS)
22
+
23
+ # Test the hello API connection
24
+ test-hello:
25
+ uv run python test_hello.py
26
+
27
+ # Install/sync dependencies
28
+ install:
29
+ uv sync
30
+
31
+ # Sync dependencies
32
+ sync:
33
+ uv sync
34
+
35
+ # Clean up temporary files and caches
36
+ clean:
37
+ find . -type d -name "__pycache__" -exec rm -rf {} + 2>/dev/null || true
38
+ find . -type f -name "*.pyc" -delete
39
+ find . -type f -name "*.pyo" -delete
40
+ find . -type f -name "*.log" -delete
41
+ rm -rf .pytest_cache
42
+ rm -rf .ruff_cache
43
+ rm -rf dist/
44
+ rm -rf build/
45
+ rm -rf *.egg-info
46
+
47
+ # Build the package
48
+ build:
49
+ uv build
50
+
51
+ # Show help
52
+ help:
53
+ @echo "Kiwi Code - Makefile Commands"
54
+ @echo ""
55
+ @echo "Usage: make [command]"
56
+ @echo ""
57
+ @echo "Commands:"
58
+ @echo " run - Run the Kiwi TUI application (kiwi)"
59
+ @echo " dev - Run TUI in development mode (with live reload)"
60
+ @echo " serve - Serve the TUI in the browser (PORT=8566 make serve)"
61
+ @echo " cli - Run the Kiwi CLI (kiwicli)"
62
+ @echo " runtime - Run the Kiwi Runtime agent (kiwi-runtime)"
63
+ @echo " e.g. make runtime ARGS=\"connect --server app\""
64
+ @echo " test-hello - Test connection to backend (hello API)"
65
+ @echo " install - Install/sync project dependencies"
66
+ @echo " sync - Sync dependencies"
67
+ @echo " build - Build the package"
68
+ @echo " clean - Clean up temporary files and caches"
69
+ @echo " help - Show this help message"
@@ -0,0 +1,429 @@
1
+ Metadata-Version: 2.4
2
+ Name: kiwi-ai
3
+ Version: 0.0.11
4
+ Summary: A textual-based terminal user interface application
5
+ Project-URL: Homepage, https://kiwicode.ai
6
+ Project-URL: Repository, https://github.com/runkailabs/kiwi-code
7
+ Author-email: Anurag <anurag@runkai.ai>
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: httpx>=0.25.0
19
+ Requires-Dist: loguru>=0.7.3
20
+ Requires-Dist: psutil>=5.9.0
21
+ Requires-Dist: pydantic>=2.12.5
22
+ Requires-Dist: pykiwiai==0.0.11
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
+ Requires-Dist: wonderwords>=2.2.0
29
+ Description-Content-Type: text/markdown
30
+
31
+ # Kiwi Code
32
+
33
+ Kiwi Code is a terminal-first interface for chatting with **Kiwi Actions**, managing **runs** (action results), and connecting the **Kiwi Runtime** (a local CLI / terminal agent) so actions can execute terminal commands on your machine.
34
+
35
+ Primary entrypoints:
36
+
37
+ - **TUI:** `kiwi` (or `python -m kiwi_tui.main`)
38
+ - **Terminal mode:** `kiwi --terminal ...`
39
+ - **Inspection CLI:** `kiwicli` (optional; list/get style scripting)
40
+ - **Runtime:** `kiwi-runtime`
41
+
42
+ > Requires **Python 3.11+**.
43
+
44
+ ---
45
+
46
+ ## Quick start
47
+
48
+ ### 1) Install
49
+
50
+ ```bash
51
+ pip install kiwi-code
52
+ ```
53
+
54
+ ### 2) Log in from the terminal
55
+
56
+ ```bash
57
+ kiwi login
58
+ ```
59
+
60
+ This prompts for your email and password and stores tokens at:
61
+
62
+ - `~/.kiwi/tokens.json`
63
+
64
+ You can inspect auth state anytime with:
65
+
66
+ ```bash
67
+ kiwi whoami
68
+ ```
69
+
70
+ To clear saved credentials:
71
+
72
+ ```bash
73
+ kiwi logout
74
+ ```
75
+
76
+ ### 3) Launch the TUI (unchanged default)
77
+
78
+ ```bash
79
+ kiwi
80
+ ```
81
+
82
+ Or choose a server preset:
83
+
84
+ ```bash
85
+ kiwi --server dev
86
+ ```
87
+
88
+ Available presets:
89
+
90
+ - `app` (prod)
91
+ - `dev` (dev)
92
+ - `local` (localhost)
93
+
94
+ ### 4) Use terminal mode instead of the full-screen TUI
95
+
96
+ Fresh conversation on the default action:
97
+
98
+ ```bash
99
+ kiwi --terminal "Hi, what are you doing?"
100
+ ```
101
+
102
+ Fresh conversation for a specific action:
103
+
104
+ ```bash
105
+ kiwi --terminal --action-id <ACTION_ID> "Inspect this repository"
106
+ ```
107
+
108
+ Continue an existing run:
109
+
110
+ ```bash
111
+ kiwi --terminal --run-id <RUN_ID> "What changed?"
112
+ ```
113
+
114
+ Pipe the message on stdin:
115
+
116
+ ```bash
117
+ echo "Summarize the latest output" | kiwi --terminal --run-id <RUN_ID>
118
+ ```
119
+
120
+ Connect the local CLI runtime from terminal mode:
121
+
122
+ ```bash
123
+ kiwi --terminal --connect-cli
124
+ kiwi --terminal --connect-cli --action-id <ACTION_ID>
125
+ kiwi --terminal --connect-cli --run-id <RUN_ID>
126
+ ```
127
+
128
+ Rules:
129
+
130
+ - `kiwi` by itself still launches the TUI.
131
+ - `--action-id` starts a **fresh** conversation for that action.
132
+ - `--run-id` continues an **existing** run.
133
+ - `--action-id` and `--run-id` are mutually exclusive.
134
+ - `--connect-cli` cannot be combined with a user message.
135
+
136
+ ### 5) (Optional) Start the runtime manually
137
+
138
+ In most cases, let Kiwi manage the runtime automatically via `/connect-cli` in the TUI or `kiwi --terminal --connect-cli` in terminal mode.
139
+
140
+ If you want to run it yourself:
141
+
142
+ ```bash
143
+ kiwi-runtime connect --server dev --scope restricted --allow "$PWD"
144
+ ```
145
+
146
+ ---
147
+
148
+ ## Terminal mode usage
149
+
150
+ ### Human-readable output
151
+
152
+ ```bash
153
+ kiwi --terminal "Hello"
154
+ ```
155
+
156
+ This prints the run result directly in your terminal.
157
+
158
+ ### JSON output for scripts
159
+
160
+ ```bash
161
+ kiwi --terminal --json --action-id <ACTION_ID> "Hello"
162
+ ```
163
+
164
+ ### Disable live status streaming
165
+
166
+ ```bash
167
+ kiwi --terminal --no-stream --run-id <RUN_ID> "Continue this task"
168
+ ```
169
+
170
+ ### Authentication in terminal mode
171
+
172
+ If you are not logged in, terminal mode exits with a helpful message telling you to run:
173
+
174
+ ```bash
175
+ kiwi login
176
+ ```
177
+
178
+ ---
179
+
180
+ ## Daily workflow (TUI)
181
+
182
+ ### Pick an action → chat
183
+
184
+ - `/actions list` → pick an action
185
+ - Type a message and press Enter
186
+
187
+ ### Start a fresh conversation
188
+
189
+ - `/new` resets the chat to the default action and clears history in the UI.
190
+
191
+ ### Continue an existing run (conversation)
192
+
193
+ - `/runs list` → pick a run
194
+ - or `/continue <run_id>`
195
+
196
+ Kiwi Code will load the conversation history for that run.
197
+
198
+ ---
199
+
200
+ ## Local CLI agent (Runtime)
201
+
202
+ Some actions can execute terminal commands via a local runtime process.
203
+
204
+ ### Connect the runtime to the current run
205
+
206
+ From the TUI:
207
+
208
+ - `/connect-cli`
209
+
210
+ From terminal mode:
211
+
212
+ ```bash
213
+ kiwi --terminal --connect-cli
214
+ kiwi --terminal --connect-cli --action-id <ACTION_ID>
215
+ kiwi --terminal --connect-cli --run-id <RUN_ID>
216
+ ```
217
+
218
+ What it does:
219
+
220
+ - Ensures a local runtime exists **for the current run_id**.
221
+ - If the runtime was disconnected (e.g. after a server redeploy), Kiwi Code detects it and starts a fresh one.
222
+ - Sends the instruction prompt: `Connect to the CLI right now before asking or doing anything.`
223
+ - In terminal mode, `--connect-cli` is a setup action only, so it **must not** be combined with a message.
224
+
225
+ ### View runtime logs
226
+
227
+ - Slash command: `/show-logs`
228
+ - Keyboard shortcut: **Ctrl+O** (works even while the chat input is disabled / streaming)
229
+
230
+ ### Runtime lifecycle
231
+
232
+ - Runtime processes are tracked under `~/.kiwi/runtimes/`.
233
+ - Runtimes are **per run_id** (one runtime process per run).
234
+ - Runtimes may survive TUI restarts.
235
+ - On quit (`Ctrl+C`), Kiwi Code shows an exit prompt listing runtimes and lets you choose which to kill.
236
+
237
+ ---
238
+
239
+ ## Keyboard shortcuts (TUI)
240
+
241
+ These are designed to work even when input is blocked during streaming.
242
+
243
+ | Key | Action |
244
+ |---|---|
245
+ | `Ctrl+C` | Quit (shows runtime cleanup prompt if runtimes are alive) |
246
+ | `Ctrl+O` | Open CLI logs (`/show-logs`) |
247
+ | `Ctrl+G` | Open slash-command picker (`/ ...`) |
248
+ | `Ctrl+U` | Attach files / content (`@ ...`) |
249
+ | `Ctrl+J` | Send message |
250
+
251
+ ---
252
+
253
+ ## Slash commands (TUI)
254
+
255
+ ### Session
256
+
257
+ - `/use <action_id>` — switch action (starts a **fresh chat UI**)
258
+ - `/actions list` — list & select actions
259
+ - `/new` — new conversation (default action)
260
+ - `/continue <run_id>` — continue an existing run and load history
261
+ - `/runs list` — list & select runs
262
+ - `/status` — show current action/run ids
263
+
264
+ ### Files
265
+
266
+ - `@` opens the inline file picker
267
+ - `/upload <path> [path2 ...]` uploads files and attaches them to your next message
268
+ - `/files` shows pending attachments
269
+ - `/clear-files` clears pending attachments
270
+
271
+ ### Runtime
272
+
273
+ - `/connect-cli` — ensure runtime exists (per run_id) + send “connect” prompt
274
+ - `/show-logs` — open runtime logs screen
275
+
276
+ ---
277
+
278
+ ## CLI overview
279
+
280
+ ### `kiwi`
281
+
282
+ `kiwi` is the primary user-facing CLI.
283
+
284
+ Examples:
285
+
286
+ ```bash
287
+ kiwi
288
+ kiwi login
289
+ kiwi whoami
290
+ kiwi --terminal "Hello"
291
+ kiwi --terminal --connect-cli --run-id <RUN_ID>
292
+ ```
293
+
294
+ ### `kiwicli`
295
+
296
+ `kiwicli` remains available for list/get style scripting and inspection.
297
+
298
+ Examples:
299
+
300
+ ```bash
301
+ kiwicli actions list
302
+ kiwicli actions get <action_id>
303
+
304
+ kiwicli runs list --status processing
305
+ kiwicli runs get <run_id>
306
+ ```
307
+
308
+ ---
309
+
310
+ ## Server / flags
311
+
312
+ `kiwi` / `python -m kiwi_tui.main` supports runtime flags (mirrors `kiwi-runtime connect`). These flags are used whenever Kiwi Code needs to start a runtime, whether you are in the TUI or terminal mode.
313
+
314
+ ```bash
315
+ kiwi --server dev \
316
+ --scope restricted \
317
+ --allow /some/extra/dir
318
+ ```
319
+
320
+ Terminal mode examples:
321
+
322
+ ```bash
323
+ kiwi --terminal --server dev "Hello"
324
+ kiwi --terminal --json --action-id <ACTION_ID> "Hello"
325
+ kiwi --terminal --no-stream --run-id <RUN_ID> "Continue"
326
+ ```
327
+
328
+ - `--server`: `app | dev | local | <full url>`
329
+ - `--scope`: `restricted | full`
330
+ - `--allow PATH`: repeatable; additional allowed directories in restricted mode
331
+ - `--terminal`: run Kiwi in plain terminal mode instead of the full-screen TUI
332
+ - `--action-id`: start a fresh conversation for the given action
333
+ - `--run-id`: continue an existing run
334
+ - `--connect-cli`: ensure runtime exists and send the connect prompt
335
+ - `--json`: print machine-readable output for terminal mode
336
+ - `--no-stream`: wait for the final result without live status streaming
337
+
338
+ > Note: Kiwi Code does **not** modify the runtime implementation under `src/kiwi_runtime/`.
339
+
340
+ ---
341
+
342
+ ## Using `kiwi-runtime` standalone (advanced)
343
+
344
+ You can run the Kiwi Runtime by itself (without the TUI). This is useful for:
345
+ - debugging runtime connectivity / permissions
346
+ - keeping a long-lived runtime running in a separate terminal tab
347
+ - watching runtime activity/logs directly
348
+
349
+ ### Start the runtime
350
+
351
+ If you installed kiwi-code as a package:
352
+
353
+ ```bash
354
+ kiwi-runtime connect --server dev --scope restricted --allow "$PWD"
355
+ ```
356
+
357
+ From the repo (recommended for development):
358
+
359
+ ```bash
360
+ uv run python -m kiwi_runtime.main connect --server dev --scope restricted --allow "$PWD"
361
+ ```
362
+
363
+ Notes:
364
+ - `--server` supports presets: `app`, `dev`, `local` (or a full URL).
365
+ - `--scope restricted` is the default; use `--allow` to add directories.
366
+ - The runtime prints connection status and will remain running until you stop it.
367
+
368
+ ### Authentication
369
+
370
+ The runtime typically needs an access token. When you run the TUI and log in, your token is saved to:
371
+ - `~/.kiwi/tokens.json`
372
+
373
+ You can pass the token explicitly (if required by your setup):
374
+
375
+ ```bash
376
+ kiwi-runtime connect --server dev --token <ACCESS_TOKEN>
377
+ ```
378
+
379
+ ### Stop the runtime
380
+
381
+ Press **Ctrl+C** in the runtime terminal to disconnect and exit.
382
+
383
+ ### Important behavior when running standalone
384
+
385
+ - Standalone runtimes are **not tracked** in `~/.kiwi/runtimes/` (that directory is used by kiwi-code to track TUI-managed runtimes).
386
+ - 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.
387
+ - For normal usage, prefer letting the TUI manage the runtime via `/connect-cli`.
388
+ - For standalone/debug usage, run `kiwi-runtime connect ...` in a separate terminal and use it to observe activity.
389
+
390
+ ---
391
+
392
+ ## Troubleshooting
393
+
394
+ ### “CLI runtime stopped responding” after server redeploy
395
+
396
+ If the backend restarts (common in `dev`), the runtime websocket may close.
397
+
398
+ Fix:
399
+ 1. In Kiwi Code, run `/connect-cli` again.
400
+ 2. If needed, open logs (Ctrl+O) to confirm the new runtime connected.
401
+
402
+ Kiwi Code validates existing runtime processes and will restart them when they’re invalid/disconnected.
403
+
404
+ ### Quit shows a runtime cleanup prompt
405
+
406
+ This is expected. Select runtimes to kill (or press Esc to keep them running).
407
+
408
+ ---
409
+
410
+ ## Development
411
+
412
+ ```bash
413
+ git clone https://github.com/jetoslabs/kiwi-code.git
414
+ cd kiwi-code
415
+ uv sync
416
+ uv run python -m kiwi_tui.main --server dev
417
+ ```
418
+
419
+ Run tests:
420
+
421
+ ```bash
422
+ uv run python -m pytest -q
423
+ ```
424
+
425
+ ---
426
+
427
+ ## License
428
+
429
+ Proprietary. All rights reserved.