How to Build the @moonshot-ai/acp-adapter Package in the kimi-code Monorepo

Run pnpm --filter @moonshot-ai/acp-adapter run build after installing workspace dependencies with pnpm install.

The acp-adapter package (@moonshot-ai/acp-adapter) serves as the ACP (Agent Client Protocol) integration layer for the MoonshotAI/kimi-code repository. This guide walks through building the package from source, including prerequisites, build commands, and verification steps based on the actual monorepo structure.

Prerequisites for Building acp-adapter

Before building, ensure your environment meets the requirements enforced by the root package.json:

  • Node.js ≥ 24.15.0 — specified in the "engines" field
  • pnpm ≥ 10.33.0 — the workspace manager required for monorepo operations

Without these versions, pnpm install will fail with engine compatibility errors.

Install Workspace Dependencies

The acp-adapter package depends on several internal packages within the kimi-code monorepo:

  • @agentclientprotocol/sdk
  • @moonshot-ai/agent-core
  • @moonshot-ai/kaos
  • @moonshot-ai/kimi-code-sdk

Install all workspace dependencies from the repository root:

pnpm install

This single command installs every package across the monorepo, including the transitive dependencies needed by acp-adapter.

Build the acp-adapter Package

The package's package.json (packages/acp-adapter/package.json) defines a minimal build pipeline:

"scripts": {
  "build": "tsdown"
}

The tsdown compiler transpiles TypeScript sources into the dist/ folder. You can build acp-adapter in two equivalent ways:

pnpm --filter @moonshot-ai/acp-adapter run build

Option 2: Direct Directory Build

cd packages/acp-adapter
pnpm run build

Both commands produce identical output under packages/acp-adapter/dist.

Build Output Structure

After a successful build, the dist/ directory contains:

File Purpose
dist/index.mjs Runtime JavaScript entry point
dist/index.d.mts TypeScript declaration file

These files are referenced by the package's "exports" field, allowing other packages (such as the kimi-code CLI) to import @moonshot-ai/acp-adapter cleanly.

Optional Verification Steps

Type Checking

Validate TypeScript definitions without emitting:

pnpm --filter @moonshot-ai/acp-adapter run typecheck

Testing

Execute the Vitest test suite:

pnpm --filter @moonshot-ai/acp-adapter run test

Note: The acp-adapter package currently has no unit tests, but the workspace test runner will include any future tests added to packages/acp-adapter.

Programmatic Build Example

For CI/CD pipelines or automation scripts:

// build-acp-adapter.ts
import { execSync } from 'child_process';

// Install workspace dependencies (one-time)
execSync('pnpm install', { stdio: 'inherit', cwd: '/path/to/kimi-code' });

// Build only acp-adapter
execSync('pnpm --filter @moonshot-ai/acp-adapter run build', {
  stdio: 'inherit',
  cwd: '/path/to/kimi-code',
});

Key Source Files

Understanding these files helps debug build issues or extend the package:

Complete CLI Workflow


# One-time setup

git clone https://github.com/MoonshotAI/kimi-code.git
cd kimi-code
pnpm install

# Build acp-adapter

pnpm --filter @moonshot-ai/acp-adapter run build

# Optional verification

pnpm --filter @moonshot-ai/acp-adapter run typecheck
pnpm --filter @moonshot-ai/acp-adapter run test

# Verify output

ls packages/acp-adapter/dist/

Summary

  • Prerequisites: Node.js ≥ 24.15.0 and pnpm ≥ 10.33.0
  • Dependency installation: Run pnpm install from the repository root
  • Build command: pnpm --filter @moonshot-ai/acp-adapter run build
  • Build tool: tsdown compiles to packages/acp-adapter/dist/
  • Output files: index.mjs (runtime) and index.d.mts (types)
  • Optional checks: typecheck and test scripts for validation

Frequently Asked Questions

What is the acp-adapter package used for?

The acp-adapter package provides ACP (Agent Client Protocol) server functionality for the kimi-code ecosystem. It bridges the kimi-code CLI with ACP-compatible agents, enabling standardized agent communication as defined in the repository's architecture.

Why does the build use tsdown instead of tsc?

The tsdown tool is configured in packages/acp-adapter/package.json as the build compiler. While the analysis does not specify tsdown's advantages, it is the designated build tool for this package and produces the required ESM output in the dist/ directory.

Can I build acp-adapter without building the entire monorepo?

Yes. The pnpm --filter flag isolates the build to acp-adapter only. However, you must still run pnpm install from the root first to install shared workspace dependencies that acp-adapter imports.

Where does the built output go?

Compiled files are written to packages/acp-adapter/dist/. The entry point dist/index.mjs and type declarations dist/index.d.mts are what consuming packages import when they reference @moonshot-ai/acp-adapter.

Have a question about this repo?

These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:

Share the following with your agent to get started:
curl -s "https://instagit.com/install.md"

Works with
Claude Codex Cursor VS Code OpenClaw Any MCP Client

Maintain an open-source project? Get it listed too →