02. 架构对比:Crush vs Kimi Code CLI
2.1 整体架构对比
Crush 分层架构
CLI Layer (cmd/) → Cobra命令
Application Layer (app/) → 应用编排
Agent/Orchestration (agent/) → Agent协调
Service Layer → 业务服务
Infrastructure → 基础设施(db, lsp, config)
Kimi Code CLI 分层架构
CLI Layer (Typer) → Typer命令
App Layer (app.py) → KimiCLI编排
Soul Layer (soul/) → Agent循环
Tool Layer (tools/) → 工具实现
LLM Abstraction (Kosong) → LLM抽象
OS Abstraction (Kaos) → OS抽象
2.2 并发模型对比
| 维度 | Crush (Goroutine) | Kimi Code CLI (asyncio) |
|---|
| 并行性 | 真并行 (多核) | 伪并行 (单线程) |
| 调度 | Go运行时抢占式 | Python事件循环协作式 |
| 阻塞容忍 | 高 (可阻塞独立线程) | 低 (阻塞整个循环) |
| 内存开销 | KB级每goroutine | 字节级每协程 |
Crush: Goroutine + Channel
type Value[T any] struct {
mu sync.RWMutex
value T
}
type Broker[T any] struct {
subscribers map[int]*subscriber[T]
}
Kimi Code CLI: asyncio 协程
class Wire:
def __init__(self):
self._queue: asyncio.Queue[WireMessage] = asyncio.Queue()
class KimiSoul:
async def run(self, user_input):
await self._turn(user_message)
2.3 状态管理对比
| 维度 | Crush | Kimi Code CLI |
|---|
| 模式 | 响应式 (PubSub) | 消息传递 (Wire) |
| 解耦度 | 中 | 高 |
| 延迟 | 低 | 中 |
2.4 依赖注入对比
| 维度 | Crush | Kimi Code CLI |
|---|
| 方式 | 显式构造函数 | 反射+类型推断 |
| 类型安全 | 编译期检查 | 运行时检查 |
| 灵活性 | 中等 | 高 |
2.5 架构优劣分析
Crush 优势
- 类型安全: 编译期检查
- 性能优越: Goroutine真并行
- 部署简单: 单二进制
- 内存效率: Go GC成熟
Kimi Code CLI 优势
- 开发效率: Python语法简洁
- 灵活性: 动态类型
- 生态丰富: PyPI包海量
- 扩展性: Agent继承、Flow技能