Skip to content

Commit 963d58d

Browse files
refactor: rewrite entire project from Python to Bun + TypeScript + React Ink
Complete rewrite of kimi-cli from Python (Typer + Rich + prompt-toolkit) to Bun + TypeScript + React Ink TUI framework. Removes all web UI code. Key changes: - Runtime: Python → Bun (TypeScript) - CLI framework: Typer → Commander.js - TUI: Rich + prompt-toolkit → React Ink - Validation: Pydantic → Zod v4 - LLM SDK: kosong → @anthropic-ai/sdk, openai, @google/genai - File I/O: KaosPath → Bun.file / Bun.write - Shell exec: kaos.exec → Bun.spawn Architecture preserved with matching directory structure: - soul/ — Core agent loop (kimisoul, agent, context, toolset, compaction) - tools/ — All tool implementations (file, shell, web, think, plan, etc.) - wire/ — Wire protocol for UI↔Agent communication - ui/shell/ — React Ink TUI components - cli/ — CLI entry point and routing - config, session, hooks, auth, notifications, approval_runtime 67 TypeScript files, 0 type errors. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 3bad72e commit 963d58d

825 files changed

Lines changed: 9367 additions & 180940 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitignore

Lines changed: 26 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,34 @@
1-
# Python-generated files
2-
__pycache__/
3-
*.py[oc]
4-
build/
5-
dist/
6-
wheels/
7-
*.egg-info
1+
# dependencies (bun install)
2+
node_modules
83

9-
# Virtual environments
10-
.venv
4+
# output
5+
out
6+
dist
7+
*.tgz
118

12-
# Project files
13-
.vscode
14-
.env
15-
.env.local
16-
/tests_local
17-
uv.toml
18-
.idea/*
9+
# code coverage
10+
coverage
11+
*.lcov
1912

20-
# Build dependencies
21-
src/kimi_cli/deps/bin
22-
src/kimi_cli/deps/tmp
13+
# logs
14+
logs
15+
_.log
16+
report.[0-9]_.[0-9]_.[0-9]_.[0-9]_.json
2317

24-
# Web build artifacts
25-
src/kimi_cli/web/static/assets/
26-
27-
# Vis build artifacts
28-
src/kimi_cli/vis/static/
18+
# dotenv environment variable files
19+
.env
20+
.env.development.local
21+
.env.test.local
22+
.env.production.local
23+
.env.local
2924

30-
# Generated reports
31-
tests_ai/report.json
25+
# caches
26+
.eslintcache
27+
.cache
28+
*.tsbuildinfo
3229

33-
# nix build result
34-
result
35-
result-*
30+
# IntelliJ based IDEs
31+
.idea
3632

37-
# macOS files
33+
# Finder (MacOS) folder config
3834
.DS_Store
39-
40-
# Rust files
41-
target/
42-
43-
node_modules/
44-
static/
45-
.memo/
46-
.entire
47-
.claude

.python-version

Lines changed: 0 additions & 1 deletion
This file was deleted.

CLAUDE.md

Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
---
2+
description: Use Bun instead of Node.js, npm, pnpm, or vite.
3+
globs: "*.ts, *.tsx, *.html, *.css, *.js, *.jsx, package.json"
4+
alwaysApply: false
5+
---
6+
7+
Default to using Bun instead of Node.js.
8+
9+
- Use `bun <file>` instead of `node <file>` or `ts-node <file>`
10+
- Use `bun test` instead of `jest` or `vitest`
11+
- Use `bun build <file.html|file.ts|file.css>` instead of `webpack` or `esbuild`
12+
- Use `bun install` instead of `npm install` or `yarn install` or `pnpm install`
13+
- Use `bun run <script>` instead of `npm run <script>` or `yarn run <script>` or `pnpm run <script>`
14+
- Bun automatically loads .env, so don't use dotenv.
15+
16+
## APIs
17+
18+
- `Bun.serve()` supports WebSockets, HTTPS, and routes. Don't use `express`.
19+
- `bun:sqlite` for SQLite. Don't use `better-sqlite3`.
20+
- `Bun.redis` for Redis. Don't use `ioredis`.
21+
- `Bun.sql` for Postgres. Don't use `pg` or `postgres.js`.
22+
- `WebSocket` is built-in. Don't use `ws`.
23+
- Prefer `Bun.file` over `node:fs`'s readFile/writeFile
24+
- Bun.$`ls` instead of execa.
25+
26+
## Testing
27+
28+
Use `bun test` to run tests.
29+
30+
```ts#index.test.ts
31+
import { test, expect } from "bun:test";
32+
33+
test("hello world", () => {
34+
expect(1).toBe(1);
35+
});
36+
```
37+
38+
## Frontend
39+
40+
Use HTML imports with `Bun.serve()`. Don't use `vite`. HTML imports fully support React, CSS, Tailwind.
41+
42+
Server:
43+
44+
```ts#index.ts
45+
import index from "./index.html"
46+
47+
Bun.serve({
48+
routes: {
49+
"/": index,
50+
"/api/users/:id": {
51+
GET: (req) => {
52+
return new Response(JSON.stringify({ id: req.params.id }));
53+
},
54+
},
55+
},
56+
// optional websocket support
57+
websocket: {
58+
open: (ws) => {
59+
ws.send("Hello, world!");
60+
},
61+
message: (ws, message) => {
62+
ws.send(message);
63+
},
64+
close: (ws) => {
65+
// handle close
66+
}
67+
},
68+
development: {
69+
hmr: true,
70+
console: true,
71+
}
72+
})
73+
```
74+
75+
HTML files can import .tsx, .jsx or .js files directly and Bun's bundler will transpile & bundle automatically. `<link>` tags can point to stylesheets and Bun's CSS bundler will bundle.
76+
77+
```html#index.html
78+
<html>
79+
<body>
80+
<h1>Hello, world!</h1>
81+
<script type="module" src="./frontend.tsx"></script>
82+
</body>
83+
</html>
84+
```
85+
86+
With the following `frontend.tsx`:
87+
88+
```tsx#frontend.tsx
89+
import React from "react";
90+
91+
// import .css files directly and it works
92+
import './index.css';
93+
94+
import { createRoot } from "react-dom/client";
95+
96+
const root = createRoot(document.body);
97+
98+
export default function Frontend() {
99+
return <h1>Hello, world!</h1>;
100+
}
101+
102+
root.render(<Frontend />);
103+
```
104+
105+
Then, run index.ts
106+
107+
```sh
108+
bun --hot ./index.ts
109+
```
110+
111+
For more information, read the Bun API docs in `node_modules/bun-types/docs/**.md`.

Makefile

Lines changed: 0 additions & 160 deletions
This file was deleted.

0 commit comments

Comments
 (0)