Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
134 changes: 134 additions & 0 deletions .github/workflows/ci-kimi-cli-ts.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
name: CI - Kimi CLI (TypeScript)

on:
push:
branches: [main]
pull_request:
branches: [main]

permissions:
contents: write

jobs:
typecheck-and-test:
name: Typecheck & Test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- uses: oven-sh/setup-bun@v2
with:
bun-version: latest

- run: bun install --frozen-lockfile

- name: Typecheck
run: ./node_modules/.bin/tsc --noEmit --skipLibCheck

- name: Test
run: bun test

build-binaries:
name: Build Binary (${{ matrix.os }}-${{ matrix.arch }})
needs: typecheck-and-test
runs-on: ${{ matrix.runner }}
strategy:
fail-fast: false
matrix:
include:
- os: linux
arch: x64
runner: ubuntu-latest
target: bun-linux-x64
artifact: kimi-linux-x64
- os: linux
arch: arm64
runner: ubuntu-latest
target: bun-linux-arm64
artifact: kimi-linux-arm64
- os: darwin
arch: x64
runner: macos-13
target: bun-darwin-x64
artifact: kimi-darwin-x64
- os: darwin
arch: arm64
runner: macos-14
target: bun-darwin-arm64
artifact: kimi-darwin-arm64
- os: windows
arch: x64
runner: windows-latest
target: bun-windows-x64
artifact: kimi-windows-x64

steps:
- uses: actions/checkout@v4

- uses: oven-sh/setup-bun@v2
with:
bun-version: latest

- run: bun install --frozen-lockfile

- name: Build standalone binary
run: bun build src/kimi_cli/index.ts --compile --outfile dist/kimi --target=${{ matrix.target }}

- name: Verify binary (unix)
if: matrix.os != 'windows'
run: |
chmod +x dist/kimi
dist/kimi --version
dist/kimi --help

- name: Verify binary (windows)
if: matrix.os == 'windows'
run: |
dist\kimi.exe --version
dist\kimi.exe --help

- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.artifact }}
path: dist/kimi*
if-no-files-found: error

release:
name: Create Release
needs: build-binaries
if: github.event_name == 'push' && github.ref == 'refs/heads/main' && startsWith(github.event.head_commit.message, 'release:')
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Get version
id: version
run: echo "version=$(node -p "require('./package.json').version")" >> $GITHUB_OUTPUT

- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: artifacts/

- name: Prepare release assets
run: |
mkdir -p release
for dir in artifacts/kimi-*; do
name=$(basename "$dir")
if [[ "$name" == *windows* ]]; then
(cd "$dir" && zip -r "../../release/${name}.zip" .)
else
chmod +x "$dir/kimi"
tar -czf "release/${name}.tar.gz" -C "$dir" kimi
fi
done
ls -la release/

- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
tag_name: v${{ steps.version.outputs.version }}
name: v${{ steps.version.outputs.version }}
files: release/*
generate_release_notes: true
66 changes: 27 additions & 39 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,47 +1,35 @@
# Python-generated files
__pycache__/
*.py[oc]
build/
dist/
wheels/
*.egg-info
# dependencies (bun install)
node_modules

# Virtual environments
.venv
# output
out
dist
*.tgz

# Project files
.vscode
.env
.env.local
/tests_local
uv.toml
.idea/*
# code coverage
coverage
*.lcov

# Build dependencies
src/kimi_cli/deps/bin
src/kimi_cli/deps/tmp
# logs
logs
_.log
report.[0-9]_.[0-9]_.[0-9]_.[0-9]_.json

# Web build artifacts
src/kimi_cli/web/static/assets/

# Vis build artifacts
src/kimi_cli/vis/static/
# dotenv environment variable files
.env
.env.development.local
.env.test.local
.env.production.local
.env.local

# Generated reports
tests_ai/report.json
# caches
.eslintcache
.cache
*.tsbuildinfo

# nix build result
result
result-*
# IntelliJ based IDEs
.idea

# macOS files
# Finder (MacOS) folder config
.DS_Store

# Rust files
target/

node_modules/
static/
.memo/
.entire
.claude
.ftp
111 changes: 111 additions & 0 deletions CLAUDE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
---
description: Use Bun instead of Node.js, npm, pnpm, or vite.
globs: "*.ts, *.tsx, *.html, *.css, *.js, *.jsx, package.json"
alwaysApply: false
---

Default to using Bun instead of Node.js.

- Use `bun <file>` instead of `node <file>` or `ts-node <file>`
- Use `bun test` instead of `jest` or `vitest`
- Use `bun build <file.html|file.ts|file.css>` instead of `webpack` or `esbuild`
- Use `bun install` instead of `npm install` or `yarn install` or `pnpm install`
- Use `bun run <script>` instead of `npm run <script>` or `yarn run <script>` or `pnpm run <script>`
- Bun automatically loads .env, so don't use dotenv.

## APIs

- `Bun.serve()` supports WebSockets, HTTPS, and routes. Don't use `express`.
- `bun:sqlite` for SQLite. Don't use `better-sqlite3`.
- `Bun.redis` for Redis. Don't use `ioredis`.
- `Bun.sql` for Postgres. Don't use `pg` or `postgres.js`.
- `WebSocket` is built-in. Don't use `ws`.
- Prefer `Bun.file` over `node:fs`'s readFile/writeFile
- Bun.$`ls` instead of execa.

## Testing

Use `bun test` to run tests.

```ts#index.test.ts
import { test, expect } from "bun:test";

test("hello world", () => {
expect(1).toBe(1);
});
```

## Frontend

Use HTML imports with `Bun.serve()`. Don't use `vite`. HTML imports fully support React, CSS, Tailwind.

Server:

```ts#index.ts
import index from "./index.html"

Bun.serve({
routes: {
"/": index,
"/api/users/:id": {
GET: (req) => {
return new Response(JSON.stringify({ id: req.params.id }));
},
},
},
// optional websocket support
websocket: {
open: (ws) => {
ws.send("Hello, world!");
},
message: (ws, message) => {
ws.send(message);
},
close: (ws) => {
// handle close
}
},
development: {
hmr: true,
console: true,
}
})
```

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.

```html#index.html
<html>
<body>
<h1>Hello, world!</h1>
<script type="module" src="./frontend.tsx"></script>
</body>
</html>
```

With the following `frontend.tsx`:

```tsx#frontend.tsx
import React from "react";

// import .css files directly and it works
import './index.css';

import { createRoot } from "react-dom/client";

const root = createRoot(document.body);

export default function Frontend() {
return <h1>Hello, world!</h1>;
}

root.render(<Frontend />);
```

Then, run index.ts

```sh
bun --hot ./index.ts
```

For more information, read the Bun API docs in `node_modules/bun-types/docs/**.md`.
Loading
Loading