# Build Tools for kimi-code: A Complete Guide to the MoonshotAI Monorepo Toolchain

> Discover the kimi-code build tools: pnpm, tsdown, Vite, oxlint, and vitest. Optimize your development workflow with this comprehensive guide to the MoonshotAI monorepo toolchain.

- Repository: [Moonshot AI/kimi-code](https://github.com/MoonshotAI/kimi-code)
- Tags: how-to-guide
- Published: 2026-07-29

---

**The *kimi-code* repository uses **pnpm** for workspace management, **tsdown** for TypeScript compilation, **Vite** for web bundling, and **oxlint**/**vitest** for quality assurance.**

The *kimi-code* monorepo from MoonshotAI relies on a modern JavaScript build toolchain to manage its TypeScript-first architecture. Understanding these build tools is essential for contributing to the codebase or extending its functionality across the various packages and applications.

## Package Management with pnpm

The foundation of the build system is **pnpm** (v10.33.0), which handles workspace-aware dependency installation and script orchestration. In the root [`package.json`](https://github.com/MoonshotAI/kimi-code/blob/main/package.json), the global build command delegates to individual packages using `pnpm -r run build`:

```json
// package.json (root)
{
  "scripts": {
    "build": "pnpm -r run build",
    "lint": "oxlint-tsgolint",
    "test": "vitest run"
  }
}

```

This recursive execution model ensures deterministic builds across all workspace packages. The workspace configuration is defined in [`pnpm-workspace.yaml`](https://github.com/MoonshotAI/kimi-code/blob/main/pnpm-workspace.yaml), which identifies the monorepo structure encompassing `apps/*` and `packages/*` directories.

## TypeScript Compilation Pipeline

### tsdown for Library Builds

For package-level TypeScript transpilation, *kimi-code* uses **tsdown**, a fast compiler that generates JavaScript with preserved source-maps. In [`packages/node-sdk/package.json`](https://github.com/MoonshotAI/kimi-code/blob/main/packages/node-sdk/package.json), the build script invokes tsdown to compile the SDK:

```json
{
  "scripts": {
    "build": "tsdown"
  }
}

```

This approach produces optimized JavaScript output while maintaining debuggability through source maps.

### tsx for Runtime Execution

When executing TypeScript files directly without an explicit compile step, the repository employs **tsx**. This tool appears in utility scripts such as `scripts/fix-node-pty-perms.mjs` and within the `klient` package's examples. As shown in [`packages/klient/package.json`](https://github.com/MoonshotAI/kimi-code/blob/main/packages/klient/package.json), tsx enables direct execution of `.ts` files:

```json
{
  "scripts": {
    "example": "tsx src/examples/example.ts"
  }
}

```

## Web Bundling and Development Server

### Vite for Frontend Applications

**Vite** (version 6 or higher) serves as the primary bundler and development server for the Vue-based web interfaces. Both `apps/kimi-web` and the TUI (`apps/kimi-code`) utilize Vite for fast HMR (Hot Module Replacement) and production builds.

In [`apps/kimi-web/package.json`](https://github.com/MoonshotAI/kimi-code/blob/main/apps/kimi-web/package.json), the scripts leverage Vite's CLI:

```json
{
  "scripts": {
    "dev": "vite",
    "build": "vite build",
    "typecheck": "vue-tsc --noEmit"
  }
}

```

### Vite Plugin Ecosystem

The build pipeline integrates several Vite plugins for framework support and styling:

- **`@vitejs/plugin-vue`**: Enables Vue single-file component compilation
- **`@vitejs/plugin-react`**: Provides React/JSX transformation capabilities
- **`@tailwindcss/vite`**: Handles Tailwind CSS processing and optimization

These dependencies are locked in [`pnpm-lock.yaml`](https://github.com/MoonshotAI/kimi-code/blob/main/pnpm-lock.yaml) to ensure consistent builds across environments.

## Code Quality Assurance

### Linting with oxlint

Code style enforcement and bug detection rely on **oxlint** (referred to as `oxlint-tsgolint` in scripts), a high-performance TypeScript-aware linter. The root [`package.json`](https://github.com/MoonshotAI/kimi-code/blob/main/package.json) defines the lint command as:

```bash
pnpm run lint

```

This executes across the entire monorepo, catching common errors and enforcing consistency before commits.

### Type Checking with TypeScript

While build tools handle transpilation, standalone type checking uses the **TypeScript** compiler (v6.0.2) in no-emit mode. Individual packages define `typecheck` scripts:

- **`apps/kimi-web`**: Uses `vue-tsc --noEmit` for Vue-specific type checking
- **Library packages**: Use `tsc --noEmit` to validate types without generating output

This separation allows for fast builds while maintaining strict type safety verification in CI pipelines.

### Testing with Vitest

The **vitest** (v4.1.4) test runner executes unit and integration tests across the monorepo. Invoked via `pnpm test`, Vitest provides fast, in-process testing compatible with the Vite-based module resolution used throughout the codebase.

## Build Workflow in Practice

The complete build lifecycle follows this deterministic sequence:

1. **Install dependencies**: `pnpm install` resolves the workspace graph and populates `node_modules`
2. **Compile TypeScript**: `pnpm run build` triggers recursive builds using `tsdown` for libraries and `vite build` for web applications
3. **Verify types**: `pnpm run typecheck` validates type safety without emitting files
4. **Lint codebase**: `pnpm run lint` enforces code standards via oxlint
5. **Execute tests**: `pnpm test` runs the Vitest suite for comprehensive coverage

```bash

# Complete workflow example

pnpm install
pnpm run build
pnpm run typecheck
pnpm run lint
pnpm test

```

## Summary

- **pnpm** (v10.33.0) orchestrates the monorepo workspace and recursive build scripts defined in [`package.json`](https://github.com/MoonshotAI/kimi-code/blob/main/package.json)
- **tsdown** transpiles TypeScript libraries while **tsx** enables direct runtime execution of TypeScript files
- **Vite** (≥6) bundles the Vue-based web applications with support from `@vitejs/plugin-vue` and Tailwind CSS plugins
- **oxlint** provides fast linting, **vitest** (v4.1.4) handles testing, and **TypeScript** (v6.0.2) performs strict type checking
- The build pipeline executes sequentially through `pnpm install` → `build` → `typecheck` → `lint` → `test`

## Frequently Asked Questions

### What package manager does kimi-code use and why?

The repository uses **pnpm** exclusively for its workspace management capabilities and disk-efficient node_modules structure. According to the source code in [`package.json`](https://github.com/MoonshotAI/kimi-code/blob/main/package.json), pnpm's recursive script execution (`pnpm -r run build`) enables consistent builds across all packages in the monorepo.

### How does kimi-code handle TypeScript compilation for different package types?

Library packages like `node-sdk` use **tsdown** for fast transpilation to JavaScript, while web applications in `apps/kimi-web` use **Vite** for bundling. For scripts and utilities, **tsx** allows direct execution without pre-compilation, as seen in [`packages/klient/package.json`](https://github.com/MoonshotAI/kimi-code/blob/main/packages/klient/package.json).

### What testing framework is configured in the kimi-code repository?

The monorepo uses **vitest** (v4.1.4) as its test runner, configured in the root [`package.json`](https://github.com/MoonshotAI/kimi-code/blob/main/package.json) with the `test` script running `vitest run`. This provides a Vite-compatible testing environment that matches the build toolchain used for development.

### Is there a specific linter required for contributing to kimi-code?

Yes, the project enforces code quality through **oxlint** (referenced as `oxlint-tsgolint` in build scripts). The linter is invoked via `pnpm run lint` from the root directory and provides TypeScript-aware static analysis across the entire codebase.