Communitygithub.com

MoonshotAI/agent-core-dev

packages/agent-core-v2(DI × Scope エージェントエンジン)開発時に使用するスキル。ドメインサービスの追加・修正、LifecycleScope の選択、DI 依存関係の配線、スコープ横断のドメイン分割、設定セクションの所有・移行、実験的フラグによる挙動制御、コード化エラーの送出、パーミッションシステムの操作、DI/Scope テストの作成、agent-core (v1) から v2 へのビジネスロジック移植、main ブランチコミットの v2 トリアージ、server-v2 上での v2 ドメイン露出(/api/v1 ワイヤ互換性維持)をカバー。開発段階(オリエント→設計→実装→テスト→検証)に沿った自己完結型ガイドと、v1→v2 移行、main ブランチコミットトリアージ、server-v2 ワイヤ露出のためのアライメントワークフローを提供。各ファイルはその段階のルール、例、禁止事項を記載。

agent-core-dev とは?

このスキルは、MoonshotAI のエージェント SDK における新しいエンジン `packages/agent-core-v2` の開発を支援するための自己完結型ガイドです。`agent-core-v2` は DI × Scope アーキテクチャを採用しており、すべてのコンポーネントは依存性注入コンテナを通じて解決されます。このスキルは、開発プロセスを「オリエント → 設計 → 実装 → テスト → 検証」の 5 つの段階に分割し、各段階ごとに具体的なルール、実装例、および禁止事項(レッドライン)を提供します。さらに、`agent-core` (v1) から v2 へのビジネスロジックの移植(Align)、main ブランチのコミットに対する v2 の対応状況の確認(Commit Align)、および server-v2 経由で v2 ドメインを公開する際のワイヤ互換性維持(Server Align)といったエンドツーエンドのワークフローもカバーしています。各段階のファイルは独立しており、開発者は現在の作業段階に応じて必要なファイルだけを参照できます。

対応~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/MoonshotAI/kimi-code/tree/main/.agents/skills/agent-core-dev

お気に入りのAIに質問する

このエージェントスキルを事前に読み込んだ状態で新しいチャットを開きます。

ドキュメント

agent-core-dev は何をしますか?

packages/agent-core-v2 をライフサイクル段階に沿って開発します。このスキルは自己完結型です。以下に示す段階ファイルにすべてのルール、レシピ、および禁止事項(レッドライン)が含まれており、packages/agent-core-v2/docs/ に委譲しません。

agent-core-v2 は DI × Scope アーキテクチャ上に構築された新しいエージェントエンジンです(packages/agent-core の移植版)。すべてのコンポーネントはコンテナを通じて解決されます。サービスは識別子、依存関係、およびライフタイムを宣言し、コンテナが構築、スコープごとのシングルトン、順序付け、および破棄を決定します。段階ファイルは、ソースドキュメントを読まなくても作業できるように、ルールを命令形で再記述しています。

ライフサイクル概要

Orient → Design → Implement → Test → Verify
  │        │          │          │        │
  │        │          │          │        └─ lint:domain · typecheck · test · dep graph · red lines
  │        │          │          └─ test.md
  │        │          └─ implement.md (+ errors.md · flags.md · permission.md)
  │        └─ design.md
  └─ orient.md

各段階は順序付けられていますが、厳密に線形ではありません。テスト(段階4)の失敗により誤ったスコープが明らかになった場合は設計(段階2)に戻り、CyclicDependencyError が発生した場合は design.md の「依存関係の方向」および implement.md の「循環依存」に移動します。

ワークフロー

複数の段階にまたがるエンドツーエンドの手順です。個別の段階ファイルを読む前に、これらを参照してください。

  • アライメント(agent-core → agent-core-v2 の移植):v1 のクラスを意味単位に分割し、各単位のドメイン/スコープ/サービス/依存関係を修正し、ロジックとテストを移行します。「機能 X を v1 から v2 に移動する」または「IXxxService を v2 に移植する」タスクで使用します。
  • コミットアライメント(main コミットの v2 トリアージ):1 つの main ブランチのコミットハッシュと簡単なメモを入力として、v1 で変更されたロジックを特定し、v2 に対応する実装が既にあるかどうかを確認し、分類(対応済み/部分的/未対応/該当なし)し、最小限の修正を提案します。kimi-code-v2 が main に追いつくフェーズで、1 コミットずつ使用します。ギャップがドメイン全体に及ぶ場合は align.md にエスカレーションします。
  • サーバーアライメント(agent-core-v2 を server-v2 経由で公開):v2 ドメインを packages/kap-server に /api/v2(ネイティブ)および /api/v1(v1 互換ミラー)経由で配線し、ワイヤスキーマを確立された v1 コントラクトとバイト互換に保つために @moonshot-ai/protocol スキーマを共有し、v1 のみの動作をネイティブな v2 Service を歪めるのではなく <domain>Legacy エッジアダプターに分離します。「新しい v2 Service をサーバーに公開する」「/api/v1 サーフェスにルートを追加する」「server-v2 をリリース済みの v1 クライアントとワイヤ互換に保つ」タスクで使用します。

各段階

  • 段階1 — オリエント:DI ブラックボックス(識別子/依存関係/ライフタイム)、4 つの LifecycleScope 階層と可視性、ファイルヘッダーコメントの規約。ビジネスコードに触れる前に読んでください。
  • 段階2 — サービスの設計:スコープの選択、スコープをまたがるドメインの分割、呼び出しスタイル(直接呼び出し vs イベント vs フック)、および直接の依存関係。コーディング前にどこに何が存在し、誰が誰を知っているかを決定します。
    • トピック:ドメイン境界 vs スコープ — session / agent / turn が神オブジェクトになるのを防ぎます。データ所有権テストとその分割結論。
    • トピック:永続化の階層化 — 3 層の Store → Storage → backend モデル、アクセスパターンによる Store の命名、ビジネスコードが依存すべき層。
    • トピック:エッジ公開 — resource:action + WS イベント — どの Service が /api/v2 経由で公開されるか(スコープごとのアクションマップ)、どのイベントが WS でストリーミングされるか、何をファサードでラップするか。
  • 段階3 — 実装:標準的な Service レシピと DI ビルディングブロック — インターフェース + 識別子、コンストラクターインジェクション、スコープ付き登録、Disposable、即時 vs 遅延、invokeFunction、createInstance、子スコープ、循環依存のリファクタリングプレイブック。
    • トピック:Service の作成 — ファイルレイアウト、命名、コントラクトと実装の内容、インターフェーススタイル、コンストラクター/フィールド規約、イベント、マルチ Service ドメイン、コメントルール。
    • トピック:設定 — セクションレジストリモデル、App と Session の分割、設定セクションの所有、TOML 形式、環境変数オーバーレイ。
    • トピック:エラー — 同じ場所に配置された XxxError、集中コードレジストリ、ワイヤシリアル化、境界翻訳。
    • トピック:フラグ — registerFlagDefinition、IFlagService.enabled(id)、[experimental] 設定セクション、解決優先順位。
    • トピック:権限 — 構成可能な責任連鎖カーネル、ポリシーレジストリ + コンポーザー、modes/agentTypes メタデータ、resolveExecution/accesses。
    • トピック:テレメトリー — ITelemetryService を介したイベント発行、コンテキスト伝搬、アペンダー出力先(ConsoleAppender / CloudAppender)。
  • 段階4 — テスト:テスト対象システムをインターフェースで解決、TestInstantiationService と createScopedTestHost の使い分け、共有スタブ、サービスグループ、後処理。
  • 段階5 — 検証と提出:lint:domain、typecheck、test、および提出前チェックリスト。

このスキルの使い方

現在の段階にジャンプしてそのファイルを 1 つ読んでください。各ファイルは自己完結型であり、独自の禁止事項(レッドライン)で終わります。提出前に以下のグローバルな禁止事項にざっと目を通してください。これらはすべての段階にわたるほとんどの間違いを捕捉します。リポジトリの真実の源は packages/agent-core-v2/src/ 内のコードです。このスキルは同じルールをコード化しているため、再導出する必要はありません。

グローバルな禁止事項(レッドライン)

すべての段階にわたって成立する不変条件です。各項目は、該当する段階ファイルで詳しく説明されています。

  1. コンストラクターに @IService 依存関係を持つクラスを new しない — @IX または accessor.get(IX) で注入する。(implement.md)
  2. @IX はコンストラクターパラメーターのみを装飾する。パラメーターの順序は構築方法に依存する(createInstance の場合は静的パラメーターが先、スコープ付きサービスの場合は @IX パラメーターが先)。(service-authoring.md)
  3. インターフェースと実装の両方に _serviceBrand を含める。createDecorator の名前はグローバルに一意であること。(implement.md)
  4. 親スコープは子スコープに依存してはならない — 短命なものは長命なものを注入できるが、逆は不可。(orient.md)
  5. 循環依存を禁止する — リファクタリング(3 つ目の Service の抽出、イベントの使用、スコープの再設定)を行い、Delayed で循環を絶たない。(design.md, implement.md)
  6. ServicesAccessor は invokeFunction の間のみ有効 — 非同期使用のために保管しない。(implement.md)
  7. スコープは状態の識別子に従う — セッションごとの状態を偽装するために App スコープで Map<sessionId, …> を使用しない。(design.md)
  8. 基盤層は上位層を認識してはならない。ビジネスコードはエッジ層(gateway/rpc)に依存してはならない。(design.md)
  9. コード化されたエラーを送出する。コードを集中的に登録する。ワイヤ上では instanceof ではなく code で分岐する。(errors.md)
  10. 未リリースの機能は registerFlagDefinition を通じて提供され、IFlagService.enabled(id) で解決されるフラグでゲートする。アドホックな環境変数トグルは禁止。(flags.md)
  11. テストはテスト対象システムをインターフェースで解決する。共有スタブは test/ の下に配置し、src/ には配置しない。(test.md)
  12. 設定は設定レジストリである。永続化可能で、スキーマ化され、ユーザー/オペレーター向けの設定のみを IConfigService に格納する。ドメイン固有の設定(環境変数のみの運用トグルを含む)は registerSection + envOverlay を通じて行う。ファクト → IBootstrapService(ドメインに依存しない — cron/フラグ/モデル状態を追加しない)。セッション状態 → Session スコープ。定数 → コード。ビジネスドメインは直接 IBootstrapService.getEnv() を呼び出さない。(config.md)

Individual skills in this repo

This repo contains 13 individual skills — each has its own dedicated page.

MoonshotAI/agent-core-review

Use ONLY for code review and test write/review guidance in `packages/agent-core-v2` (the DI × Scope agent engine). Does NOT apply to the legacy `packages/agent-core` or to any other package — for those, do not load this skill. Groups the review and testing lenses used for agent-core-v2 — `slop` (single-level-of-abstraction / layered error-handling review, invoked only on explicit request) and `test` (contract-driven per-test rules for both authoring and reviewing tests). Apply the sub-skill that matches the task; do not apply `slop` unprompted.

MoonshotAI/consolidate

Apply an approved sub-skill grouping by moving user-specified skills into a parent bundle, with timestamped backups of every modified directory.

MoonshotAI/gen-changesets

Use when generating changesets in the kimi-code repository, including package bump selection, internal package and CLI bundle handling, bump levels, major confirmation, and English changelog wording.

MoonshotAI/gen-docs

Update Kimi Code CLI user documentation after meaningful code changes that affect product behavior or user experience.

MoonshotAI/kimi-datasource

Universal data-source assistant. Use this skill when the user wants external structured data such as stocks, financial reports, technical indicators, A-share/HK/US markets, global macroeconomics, Chinese enterprise registry information, arXiv papers, Google Scholar results, or Chinese laws/regulations and judicial cases. This plugin exposes tools via MCP server `plugin-kimi-datasource_data`; call them in the flow `mcp__plugin-kimi-datasource_data__get_data_source_desc` → `mcp__plugin-kimi-datasource_data__call_data_source_tool`.

MoonshotAI/pre-changelog

Use before merging a kimi-code release PR to preview the user-facing CLI changelog in Chinese. Reads the changelog that changesets pre-generated in the release PR, then reuses sync-changelog's strip / classify / translate logic to render a Chinese preview. Writes no files.

MoonshotAI/review

Analyze the available skill set and recommend candidate groups that could be consolidated into sub-skill bundles. Read-only — proposes a plan, does not move files.

MoonshotAI/slop

Invoke only when the user explicitly asks to review code through the "single level of abstraction / layered error handling" lens — a function does only its own layer's business logic while errors are handled above or below. The agent reports detections, raw-count measurements, and move directions. Apply only when the user explicitly requests this lens.

MoonshotAI/sub-skill

Discover and reorganize the skill inventory into hierarchical sub-skill bundles. Use when the user asks to review, group, or consolidate skills into a parent bundle.

MoonshotAI/sync-changelog

Use after a release succeeds, when maintainers need to sync apps/kimi-code/CHANGELOG.md into docs/en/release-notes/changelog.md and docs/zh/release-notes/changelog.md, then open a PR on a dedicated branch.

MoonshotAI/test

Use when writing or reviewing tests, or when asked how to write a good single test. Encodes the per-test rules behind the "test the contract / responsibility, not the implementation" principle — name and structure one behavior per `it`, drive through the public surface, stub only true external boundaries, control time and config via documented knobs, and keep tests clear, isolated, and refactor-resilient. The same rules drive both authoring (write mode) and auditing existing tests (review mode).

MoonshotAI/translate-docs

Translate and sync bilingual user documentation between docs/zh/ and docs/en/ following the source-of-truth rules in docs/AGENTS.md.

MoonshotAI/write-tui

Use when writing or modifying the kimi-code terminal UI in apps/kimi-code/src/tui — components, dialogs/selectors, slash commands, themes, streaming render, or the KimiTUI controllers. Covers the architecture, where new features go, test placement, the theme system mechanics, and the dialog interaction/visual spec (DESIGN.md).

関連スキル