Communitygithub.com

MoonshotAI/agent-core-dev

packages/agent-core-v2 (DI × Scope 에이전트 엔진) 개발 시 사용 — 도메인 서비스 추가/수정, LifecycleScope 선택, DI 의존성 연결, 도메인을 스코프별 분할, 설정 섹션 소유/이전, 실험적 플래그 기반 기능 게이팅, 코드화된 에러 발생, 권한 시스템 작업, DI/Scope 테스트 작성, agent-core(v1)에서 v2로 비즈니스 로직 포팅, 메인 브랜치 커밋을 v2에 대해 분류, 서버-v2를 통해 v2 도메인을 노출하면서 /api/v1 와이어 계약을 출시된 클라이언트와 호환성 유지. 개발 단계(오리엔트 → 설계 → 구현 → 테스트 → 검증)별로 구성된 자체 포함 가이드이며, v1→v2 마이그레이션, 메인 브랜치 커밋 분류, 서버-v2 와이어 노출을 위한 정렬 워크플로우도 포함합니다. 각 파일은 해당 단계에 대한 규칙, 예제 및 금지 사항을 담고 있습니다.

agent-core-dev란 무엇인가요?

이 스킬은 `packages/agent-core-v2` 디렉토리에서 DI(Dependency Injection)와 Scope 기반의 새로운 에이전트 엔진을 개발할 때 사용하는 종합적인 개발 가이드입니다. `DI × Scope` 아키텍처를 기반으로 하며, 모든 서비스는 컨테이너를 통해 해결됩니다. 개발자는 이 스킬을 따라 오리엔트 → 설계 → 구현 → 테스트 → 검증의 5단계 생애주기로 작업하며, 각 단계는 독립적인 파일로 제공되어 필요할 때만 참조할 수 있습니다. 이 스킬의 핵심 가치는 단순한 문서를 넘어, 실제 코드 개발 중 발생할 수 있는 모든 상황에 대한 구체적인 규칙, 예제, 그리고 금지 사항(red line)을 제공한다는 점입니다. 또한 `agent-core`(v1)에서 v2로의 마이그레이션, 메인 브랜치 커밋을 v2에 맞게 분류하는 작업, 그리고 서버-v2에서 v2 도메인을 노출하면서 기존 v1 클라이언트와의 호환성을 유지하는 방법 등 실무에 필요한 엔드투엔드 워크플로우도 함께 제공합니다. 지원 대상은 Claude Code, Cursor, Codex 등 AI 에이전트 개발 도구이며, 복잡한 DI 시스템과 생애주기 관리를 체계적으로 수행할 수 있도록 돕습니다. 12개의 글로벌 금지 사항이 모든 단계에 걸쳐 적용되어, 순환 의존성, 잘못된 스코프 사용, 부적절한 인스턴스화 등 일반적인 실수를 방지합니다.

지원 대상~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에 대해 분류): 하나의 main 커밋 해시 + 짧은 메모가 주어지면, 해당 커밋이 변경한 v1 로직을 찾고, v2에 이미 해당 구현이 있는지 확인한 후, 버킷(정렬됨 / 부분 / 누락 / 해당 없음)으로 분류하고 최소한의 수정을 권장합니다. kimi-code-v2-main-따라잡기 단계에서 한 번에 하나의 커밋에 대해 사용하세요. 격차가 전체 도메인인 경우 align.md로 에스컬레이션하세요.
  • 서버 정렬 (agent-core-v2를 server-v2를 통해 노출): v2 도메인을 /api/v2(네이티브) 및 /api/v1(v1 호환 미러)을 통해 packages/kap-server에 연결하고, @moonshot-ai/protocol 스키마를 공유하여 와이어 스키마를 기존 v1 계약과 바이트 호환되게 유지하며, v1 전용 동작을 <domain>Legacy 에지 어댑터로 격리하여 네이티브 v2 서비스를 왜곡하지 않습니다. 작업이 "새로운 v2 서비스를 서버에 노출", "/api/v1 표면에 라우트 추가", 또는 "서버-v2 와이어를 출시된 v1 클라이언트와 호환되게 유지"일 때 사용하세요.

단계

  • 1단계 — 오리엔트: DI 블랙박스(아이덴티티/의존성/생애주기), 네 가지 LifecycleScope 계층 및 가시성, 파일 헤더 주석 규칙. 비즈니스 코드를 건드리기 전에 읽으세요.
  • 2단계 — 서비스 설계: 스코프 선택, 도메인을 스코프별로 분할, 호출 스타일(직접 호출 vs 이벤트 vs 훅) 선택, 직접 의존성. 코딩 전에 무엇이 어디에 살고 누가 누구를 아는지 결정하세요.
    • 주제: 도메인 경계 vs 스코프 — session / agent / turn이 갓 객체가 되지 않도록 방지; 데이터 소유권 테스트 및 분할 결론.
    • 주제: 영속성 계층 — 3계층 Store → Storage → backend 모델, 접근 패턴별 Store 명명, 비즈니스 코드가 의존해야 하는 계층.
    • 주제: 에지 노출 — resource:action + WS 이벤트 — /api/v2를 통해 노출되는 서비스(스코프별 액션 맵)와 WS를 통해 스트리밍되는 이벤트; 퍼사드로 래핑할 내용.
  • 3단계 — 구현: 표준 서비스 레시피 및 DI 구성 요소 — 인터페이스 + 아이덴티티, 생성자 주입, 스코프 등록, Disposable, eager vs delayed, invokeFunction, createInstance, 자식 스코프, 사이클 리팩터 플레이북.
    • 주제: 서비스 작성 — 파일 레이아웃, 명명, 계약 vs 구현 내용, 인터페이스 스타일, 생성자/필드 규칙, 이벤트, 다중 서비스 도메인, 주석 규칙.
    • 주제: 설정 — 섹션 레지스트리 모델, App vs Session 분할, 설정 섹션 소유, TOML 형식, 환경 오버레이.
    • 주제: 에러 — 함께 위치한 XxxError, 중앙 코드 레지스트리, 와이어 직렬화, 경계 변환.
    • 주제: 플래그 — registerFlagDefinition, IFlagService.enabled(id), [experimental] 설정 섹션, 해결 우선순위.
    • 주제: 권한 — 구성 가능한 책임 사슬 커널, 정책 레지스트리 + 컴포저, modes/agentTypes 메타데이터, resolveExecution/accesses.
    • 주제: 원격 측정 — ITelemetryService를 통한 이벤트 발행, 컨텍스트 전파, 및 추가 대상(ConsoleAppender / CloudAppender).
  • 4단계 — 테스트: 인터페이스별로 테스트 대상 시스템 해결, TestInstantiationService vs createScopedTestHost 선택, 공유 스텁, 서비스 그룹, 분해.
  • 5단계 — 검증 및 제출: lint:domain, typecheck, test, 및 제출 전 체크리스트.

이 스킬 사용 방법

현재 있는 단계로 이동하여 해당 파일을 읽으세요. 각 파일은 자체 포함되어 있으며 자체 금지 사항으로 끝납니다. 제출하기 전에 아래 전역 금지 사항을 훑어보세요 — 모든 단계에서 대부분의 실수를 잡아냅니다. 저장소의 진실 소스는 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. 순환 의존성이 없어야 합니다 — 리팩터링(세 번째 서비스 추출 / 이벤트 사용 / 스코프 재조정)하세요. 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. 테스트는 인터페이스로 SUT를 해결합니다. 공유 스텁은 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).

관련 스킬