Skip to content
Merged
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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 45 additions & 0 deletions packages/harness-kimi/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<!-- lineage
role: package-readme
conforms_to: ../../README.md
consumes: config/config.local-mlx.toml
-->

# harness-kimi

[kimi-code](https://moonshotai.github.io/kimi-code/) — Moonshot's terminal
coding agent (binary `kimi`) — at the repo's curated pin (brew formula
`kimi-code`, currently 0.29.1; see root CLAUDE.md upstream-tracking).

```bash
./install.sh # brew install kimi-code + copy local-endpoint config preset
```

## What it wires

- **`config/config.local-mlx.toml`** → `~/.kimi-code/config.toml` (copy-if-absent).
Two OpenAI-type providers + model aliases:
- `gpt-oss-local` → **rapid-mlx :11437** (harmony) — the default model
- `qwen-fast-local` → **mlx_lm.server :11436** (standard template)

## Config schema notes (verified via `kimi doctor`, 0.29.1)

- Provider `type` is an enum: `openai | openai_responses | anthropic | kimi | google-genai | vertexai`. Local MLX = `openai` (chat).
- Each model alias needs `max_context_size`, which **doubles as kimi's output
budget** — so it's set to 32768, well under gpt-oss's 131072 window, to avoid
`APIContextOverflowError` (kimi otherwise requests completion = max_context_size).
- Adding providers via `kimi provider catalog add <id>` needs a Moonshot
`KIMI_REGISTRY_API_KEY`; this preset hand-authors the config instead (no key).

```bash
mlx-serve flagship # rapid-mlx :11437 (gpt-oss, harmony)
kimi -m gpt-oss-local -p "your prompt"
```

Verified 2026-07-26: `kimi -m gpt-oss-local` drives local gpt-oss correctly.

## herdr

`herdr integration install kimi` installs a state reporter to
`~/.kimi-code/hooks/herdr-agent-state.sh` (requires kimi-code ≥ 0.14.0).

No secrets — localhost endpoints only, per repo convention.
31 changes: 31 additions & 0 deletions packages/harness-kimi/config/config.local-mlx.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# harness-kimi local-endpoint preset → ~/.kimi-code/config.toml.
# Schema verified against kimi-code 0.29.1 via `kimi doctor` (provider.type is an
# enum: openai|openai_responses|anthropic|kimi|google-genai|vertexai; models need
# max_context_size). No secrets: localhost, api_key = "none".
#
# gpt-oss needs rapid-mlx (harmony) on :11437; standard-template models use
# mlx_lm.server on :11436. max_context_size doubles as kimi's output budget, so
# it's kept well under the model's real window to avoid context overflow.
default_model = "gpt-oss-local"

[providers.local-mlx-rapid]
name = "Local MLX — rapid-mlx (harmony)"
base_url = "http://localhost:11437/v1"
type = "openai"
api_key = "none"

[providers.local-mlx]
name = "Local MLX — mlx_lm.server"
base_url = "http://localhost:11436/v1"
type = "openai"
api_key = "none"

[models.gpt-oss-local]
provider = "local-mlx-rapid"
model = "mlx-community/gpt-oss-120b-MXFP4-Q8"
max_context_size = 32768

[models.qwen-fast-local]
provider = "local-mlx"
model = "mlx-community/Qwen3.6-35B-A3B-8bit"
max_context_size = 32768
27 changes: 27 additions & 0 deletions packages/harness-kimi/install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/usr/bin/env bash
# Install kimi-code (Moonshot's terminal coding agent) + wire this package's
# local-endpoint preset. Idempotent. No curl|bash — brew-native install.
set -euo pipefail

PKG_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"

command -v brew >/dev/null 2>&1 || { echo "brew not found — install Homebrew first" >&2; exit 1; }

# kimi-code is a Homebrew formula; binary is `kimi`. Curated pin tracked in root
# CLAUDE.md upstream-tracking.
brew list kimi-code >/dev/null 2>&1 || brew install kimi-code
kimi --version

# Config preset: copy if absent; never clobber a live config (auth/providers).
mkdir -p "${HOME}/.kimi-code"
if [ ! -f "${HOME}/.kimi-code/config.toml" ]; then
cp "${PKG_DIR}/config/config.local-mlx.toml" "${HOME}/.kimi-code/config.toml"
echo "installed config.toml (local-endpoint providers) -> ~/.kimi-code/config.toml"
else
echo "${HOME}/.kimi-code/config.toml exists — NOT overwritten. Merge providers/models from ${PKG_DIR}/config/config.local-mlx.toml manually."
fi

kimi doctor >/dev/null 2>&1 && echo "kimi config valid" || echo "note: run 'kimi doctor' to validate config"
echo "kimi-code ready — local: kimi -m gpt-oss-local -p 'your prompt'"
echo " (serve first: mlx-serve flagship → rapid-mlx :11437, harmony parsers)"
echo " herdr: herdr integration install kimi"
13 changes: 13 additions & 0 deletions packages/harness-kimi/moon.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
$schema: 'https://moonrepo.dev/schemas/project.json'

layer: 'tool'

project:
name: 'harness-kimi'
description: 'kimi-code (Moonshot terminal agent) harness — install + local-endpoint preset'

tasks:
lint:
command: 'shellcheck install.sh'
inputs:
- 'install.sh'