[Bug]: Kimi integration rewrites the whole config.toml, dropping comments and reshaping `[[hooks]]` into an inline array

オープン
#9,152 コメント 1 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

@FredAmartey がすでに取り組んでいます。

2026年11月27日 から。

  • #9176 @FredAmartey による — オープン

評価

難易度
3/5
見積もり時間
1〜2日
初心者へのやさしさ
62/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
typescript
領域
backend

調査の方向性

Start by tracing the Kimi integration's read and write path that uses Bun.TOML.parse and renderToml; inspect the before and after snapshots in integrations/snapshots/kimi/. Check how the DSH integration uses sourcePreservingYaml for comparison. Done means Kimi overwrite and disable operations update only OpenCodex-owned keys while preserving comments, [[hooks]] tables, and the rest of the file.

索引モデルが issue の本文から書いたものです。

説明

bug cli

Environment

  • OpenCodex 2.100.8 (macOS 27.2.1)
  • Kimi Code CLI 2.8.0
  • Orca 1.4.277 manages a hooks block in the same ~/.kimi-code/config.toml

What happened

Each Kimi overwrite or disable operation (both appear in ~/.opencodex/integrations/journal.jsonl) reads config.toml with Bun.TOML.parse and writes the whole document back with renderToml. The rewrite has three side effects:

  1. All comments are lost, including the # >>> orca-managed-kimi-hooks … >>> / <<< markers that another tool uses to find the block it owns.
  2. Arrays of tables are flattened. renderToml treats any non-record value as a scalar, so the 9 [[hooks]] tables become one top-level inline array: hooks = [{ event = "SessionStart", … }, …]. That is still valid TOML, but no other tool would expect that layout.
  3. Key order and formatting change throughout the file, not just in the providers.opencodex / models."opencodex/…" entries the integration owns.

The integration's own pre-write snapshots in integrations/snapshots/kimi/ show the before and after: the snapshot before the overwrite has the marker block and 9 [[hooks]] tables; the snapshot before the disable (taken 4 seconds later) has an inline hooks = [...] line and no comments.

Downstream effect: Orca no longer finds its markers, reinstalls its hooks block, and the file ends up with hooks defined twice. Kimi then fails to load the config (Cannot mutate immutable namespace ('hooks',)), and every Kimi call fails until someone fixes the file by hand. This happened twice in four days (one overwrite, then one overwrite + disable).

Expected

Edit only the keys the integration owns and preserve everything else byte for byte. The DSH integration already does this through sourcePreservingYaml; Kimi's TOML could use the same approach:

  • Use a format-preserving TOML edit (a comment- and layout-preserving TOML library, or targeted text splicing of the [providers.opencodex] table and the [models."opencodex/…"] tables).
  • At minimum, renderToml should emit arrays of tables as [[name]] sections rather than inline arrays, and keep top-level comments.

Repro

  1. Put a comment and an array of tables in ~/.kimi-code/config.toml:
# keep me
default_model = "kimi-code/k3.1-pro"

[[hooks]]
event = "Stop"
command = "echo hi"
timeout = 10
  1. Enable, refresh, or disable the Kimi integration in OpenCodex.
  2. The comment is gone and the hook is now hooks = [{ event = "Stop", command = "echo hi", timeout = 10 }].
主要言語
TypeScript
スター
16.9k
フォーク
1.3k
平均マージ
1日 4時間
マージ済み PR(30日)
814

環境構築

このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

lidge-jun/opencodex のほかの issue

lidge-jun/opencodex の issue をすべて見る

似ている issue

TypeScript の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。