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
92 changes: 92 additions & 0 deletions .agents/skills/gen-rust/SKILL.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
---
name: gen-rust
description: Sync Rust implementation with Python changes (exclude UI/login) by reviewing recent changes, mapping modules, porting logic, and updating tests.
---

# gen-rust

Use this skill when the user wants Rust (kagent/kosong/kaos) to stay logically identical to Python (kimi_cli/kosong/kaos), excluding UI and login/auth. This includes code and tests: Rust behavior and tests must be fully synchronized with Python changes.

Note: The Rust binary is named `kagent`. User-facing CLI/output text in Rust must use `kagent`
instead of `kimi` to match the Rust command name.

## Quick workflow

1) **Build a complete change inventory**

Review recent changes to understand what needs syncing:

```sh
# Check staged changes
git diff --cached --name-only
git diff --cached -- src packages

# Check recent commits
git log --oneline -20 -- src packages
git diff HEAD~20..HEAD -- src packages

# Review CHANGELOG.md for context
head -50 CHANGELOG.md
```

2) **Classify changes**

- Exclude UI and login/auth changes (Shell/Print/ACP UI, login/logout commands).
- Everything else must be mirrored in Rust.
- Keep a small checklist: file -> change summary -> Rust target -> status.

3) **Map Python -> Rust**

Common mappings:
- `src/kimi_cli/llm.py` -> `rust/kagent/src/llm.rs`
- `src/kimi_cli/soul/*` -> `rust/kagent/src/soul/*`
- `src/kimi_cli/tools/*` -> `rust/kagent/src/tools/*`
- `src/kimi_cli/utils/*` -> `rust/kagent/src/utils/*`
- `src/kimi_cli/wire/*` -> `rust/kagent/src/wire/*`
- `packages/kosong/*` -> `rust/kosong/*`
- `packages/kaos/*` -> `rust/kaos/*`

4) **Port logic carefully**

- Match error messages and tool output text exactly (tests often assert strings).
- Preserve output types (text vs parts) and ordering.
- For media/tool outputs, verify ContentPart wrapping and serialization.
- If Python adds new helper modules, mirror minimal Rust utilities.
- Use `rg` to find existing analogs and references.

5) **Update tests**

- Update Rust tests that assert content/strings/parts.
- Mirror Python unit and integration tests when they exist; add missing Rust tests so coverage matches intent.
- Ensure E2E parity: use the existing Python E2E suite against the Rust binary by setting
`KIMI_E2E_WIRE_CMD` (do not rewrite E2E in Rust). All E2E cases must pass or the gap must be documented.
- Prefer targeted tests first (`cargo test -p kagent --test <name>`), then full suite if asked.

6) **Verification is mandatory**

- Run the full Rust test suite and ensure all Rust tests pass.
- Run E2E tests with the wire command swapped to Rust (set `KIMI_E2E_WIRE_CMD`), and ensure they pass.

7) **Final report**

- List synced files and logic.
- Call out intentionally skipped UI/login changes.
- List tests run and results (must include full Rust tests and Rust E2E with wire command override).

## Pitfalls to avoid

- Skipping `llm.py`: it often changes model capability logic.
- Using commit message filtering instead of full diff.
- Forgetting to update Rust tests when output text/parts change.
- Mixing UI/login changes into core sync.
- Leaving test parity ambiguous; always state unit/integration/E2E status.

## Minimal diff checklist (template)

- [ ] Recent changes reviewed (staged, commits, changelog)
- [ ] Python diffs inspected for core logic
- [ ] Rust mappings applied
- [ ] Tests updated
- [ ] Targeted tests run
- [ ] Full Rust test suite passed
- [ ] Rust E2E passed with `KIMI_E2E_WIRE_CMD`
12 changes: 8 additions & 4 deletions .agents/skills/release/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,17 @@ confirm_versions: |md
versioning).
|
update_files: |md
Update the relevant pyproject.toml, CHANGELOG.md (keep the Unreleased header),
and breaking-changes.md in both languages.
Update the relevant pyproject.toml (and rust/Cargo.toml if root version changes),
CHANGELOG.md (keep the Unreleased header), and breaking-changes.md in both languages.
|
root_change: "Is the root package version changing?"
sync_kimi_code: |md
Sync packages/kimi-code/pyproject.toml version and dependency
`kimi-cli==<version>`.
|
sync_kagent: |md
Sync rust/Cargo.toml workspace version to match the root package version.
|
uv_sync: "Run uv sync."
gen_docs: |md
Follow the gen-docs skill instructions to ensure docs are up to date.
Expand All @@ -45,7 +48,7 @@ monitor_pr: "Monitor the PR until it is merged."
post_merge: |md
After merge, switch to main, pull latest changes, and tell the user the git
tag command needed for the final release tag (they will tag + push tags). Note:
a single numeric tag releases both kimi-cli and kimi-code.
a single numeric tag releases kimi-cli, kimi-code, and kagent together.
|

BEGIN -> understand -> check_changes -> has_changes
Expand All @@ -54,6 +57,7 @@ has_changes -> confirm_versions: yes
confirm_versions -> update_files -> root_change
root_change -> sync_kimi_code: yes
root_change -> uv_sync: no
sync_kimi_code -> uv_sync
sync_kimi_code -> sync_kagent
sync_kagent -> uv_sync
uv_sync -> gen_docs -> new_branch -> open_pr -> monitor_pr -> post_merge -> END
```
83 changes: 83 additions & 0 deletions .github/workflows/ci-kagent.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
name: CI (kagent)

on:
pull_request:
paths:
- ".github/workflows/ci-kagent.yml"
- "rust/**"
- "tests_e2e/**"
push:
branches:
- main
paths:
- ".github/workflows/ci-kagent.yml"
- "rust/**"
- "tests_e2e/**"

jobs:
test:
strategy:
fail-fast: false
matrix:
include:
- runner: ubuntu-22.04
wire_cmd: ./rust/target/debug/kagent
- runner: ubuntu-22.04-arm
wire_cmd: ./rust/target/debug/kagent
- runner: macos-14
wire_cmd: ./rust/target/debug/kagent
- runner: windows-2022
wire_cmd: .\\rust\\target\\debug\\kagent.exe
- runner: windows-11-arm
wire_cmd: .\\rust\\target\\debug\\kagent.exe
runs-on: ${{ matrix.runner }}
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Install GNU Make (Windows)
if: runner.os == 'Windows'
run: choco install make -y

- name: Set up Rust
uses: dtolnay/rust-toolchain@stable
with:
components: rustfmt

- name: Cargo fmt
working-directory: rust
run: cargo fmt --all -- --check

- name: Cargo check
working-directory: rust
run: cargo check

- name: Cargo test
working-directory: rust
run: cargo test

- name: Build kagent
working-directory: rust
run: cargo build -p kagent

- name: Set up Python 3.12
id: setup-python
uses: actions/setup-python@v5
with:
python-version: "3.12"

- name: Set up uv
uses: astral-sh/setup-uv@v1
with:
version: "0.8.5"

- name: Install dependencies
env:
UV_PYTHON: ${{ steps.setup-python.outputs.python-path }}
run: make prepare

- name: Run e2e tests
env:
UV_PYTHON: ${{ steps.setup-python.outputs.python-path }}
KIMI_E2E_WIRE_CMD: ${{ matrix.wire_cmd }}
run: uv run pytest tests_e2e
22 changes: 18 additions & 4 deletions .github/workflows/ci-kimi-cli.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ on:
- "packages/**"
- "src/**"
- "tests/**"
- "tests_e2e/**"
- "tests_ai/**"
- "web/**"
- "pyproject.toml"
- "uv.lock"
push:
Expand All @@ -18,7 +20,9 @@ on:
- "packages/**"
- "src/**"
- "tests/**"
- "tests_e2e/**"
- "tests_ai/**"
- "web/**"
- "pyproject.toml"
- "uv.lock"

Expand All @@ -41,6 +45,9 @@ jobs:
- runner: windows-2022
target: x86_64-pc-windows-msvc
binary_path: dist/onefile/kimi.exe
- runner: windows-11-arm
target: aarch64-pc-windows-msvc
binary_path: dist/onefile/kimi.exe
runs-on: ${{ matrix.runner }}
steps:
- name: Checkout repository
Expand Down Expand Up @@ -79,21 +86,21 @@ jobs:
run: make test-kimi-cli

- name: Set up Node.js (web build)
if: matrix.python-version == '3.14'
if: matrix.python-version == '3.13'
uses: actions/setup-node@v4
with:
node-version: "20"
cache: "npm"
cache-dependency-path: web/package-lock.json

- name: Build standalone binary
if: matrix.python-version == '3.14'
if: matrix.python-version == '3.13'
env:
UV_PYTHON: ${{ steps.setup-python.outputs.python-path }}
run: make build-bin

- name: Smoke test binary --help
if: matrix.python-version == '3.14'
if: matrix.python-version == '3.13'
shell: python
run: |
import os
Expand All @@ -107,7 +114,7 @@ jobs:
BINARY_PATH: ${{ matrix.binary_path }}

- name: Upload binary artifact
if: matrix.python-version == '3.14' && success()
if: matrix.python-version == '3.13' && success()
uses: actions/upload-artifact@v4
with:
name: kimi-${{ matrix.target }}
Expand Down Expand Up @@ -180,6 +187,13 @@ jobs:
--pyproject packages/kimi-code/pyproject.toml \
--expected-version "${{ steps.version.outputs.head_version }}"

- name: Check kagent version alignment
if: steps.version.outputs.bump == 'true'
run: |
python scripts/check_cargo_version_tag.py \
--cargo-toml rust/Cargo.toml \
--expected-version "${{ steps.version.outputs.head_version }}"

- name: Check kimi-code dependency pin
if: steps.version.outputs.bump == 'true'
shell: python
Expand Down
Loading