Code Intelligence

Table of contents

  1. 1. Code Intelligence
    1. 1.1 개요(Overview)
    2. 1.2 동작 방식(How it works)
    3. 1.3 LSP 활성화 절차(Enabling LSP integration)
    4. 1.4 언어 서버 설치(Installing language servers)
      1. 1.4.1 지원 언어(Supported Languages)
    5. 1.5 Code Intelligence 초기화(Initialize Code Intelligence)
      1. 1.5.1 워크스페이스 범위 구성(Workspace-scoped configuration)
      2. 1.5.2 초기화 시 출력 예시
      3. 1.5.3 상태 표시(Status indicators)
      4. 1.5.4 기타 제어
    6. 1.6 언어 서버 활용(Using Language Servers)
      1. 1.6.1 예제 1: 심볼 검색
      2. 1.6.2 예제 2: 참조 검색
      3. 1.6.3 예제 3: 정의 위치 탐색
      4. 1.6.4 예제 4: 파일 내 심볼 조회
      5. 1.6.5 예제 5: 드라이 런 리네이밍
      6. 1.6.6 예제 6: 진단 정보 조회
      7. 1.6.7 예제 7: 호버 정보 조회
      8. 1.6.8 예제 8: 코드 자동완성 탐색
    7. 1.7 커스텀 언어 서버
      1. 필드 설명
    8. 1.8 문제 해결
    9. 1.9 모범 사례(Best Practices)
    10. 1.10 제약 사항(Limitations)

1. Code Intelligence

1.1 개요(Overview)

Code Intelligence는 언어 서버 프로토콜(Language Server Protocol, LSP) 을 Kiro CLI에 통합하여, IDE 확장 기능과 유사한 수준의 코드 의미 분석(Semantic understanding) 을 Kiro 에이전트가 수행할 수 있도록 하는 기능입니다.

기본적으로 다음 7개 언어가 사전 구성(pre-configured)되어 제공됩니다.

또한 프로젝트 루트의 .kiro/settings/lsp.json 파일에 커스텀 LSP 구성(Custom LSP configuration) 을 추가함으로써, 사실상 모든 언어로 확장할 수 있습니다.

/code init 명령을 실행한 이후에는 자연어 질의를 통해 다음과 같은 고급 코드 탐색 및 분석 작업을 수행할 수 있습니다.


1.2 동작 방식(How it works)

Kiro CLI는 백그라운드에서 LSP 서버 프로세스(Language Server processes) 를 실행하며, 이들은 표준 입출력(stdio) 을 통해 JSON-RPC 방식으로 통신합니다.

워크스페이스를 초기화하면 다음 과정을 거칩니다.

  1. 프로젝트 마커(Project markers) 탐지 - 예: package.json, Cargo.toml 등
  2. 파일 확장자(File extensions) 기반 언어 감지
  3. 적절한 언어 서버(Language server) 자동 실행

실행된 언어 서버는 지속적으로 코드베이스를 분석하여 다음 정보를 인덱싱(Indexing)합니다.

사용자가 자연어로 질의하면, Kiro는 이를 LSP 프로토콜 요청으로 변환하여 해당 서버에 전달하고, 결과를 사람이 읽기 쉬운 형식으로 가공하여 반환합니다.


1.3 LSP 활성화 절차(Enabling LSP integration)

Kiro CLI에서 LSP 서버를 사용하기 위한 기본 절차는 다음과 같습니다.

  1. 언어 서버(Language servers) 설치
  2. LSP 통합 활성화(Enable LSP integration)
  3. 코드 관련 자연어 질의 수행

1.4 언어 서버 설치(Installing language servers)

1.4.1 지원 언어(Supported Languages)

아래 표는 현재 공식적으로 지원되는 언어, 파일 확장자, 사용되는 LSP 서버, 설치 명령어를 정리한 것입니다.

Language Extensions Server Install Command
TypeScript / JavaScript .ts, .js, .tsx, .jsx typescript-language-server npm install -g typescript-language-server typescript
Rust .rs rust-analyzer rustup component add rust-analyzer
Python .py jedi-language-server npm install -g pyright or pip install pyright
Go .go gopls go install golang.org/x/tools/gopls@latest
Java .java jdtls brew install jdtls (macOS)
Ruby .rb solargraph gem install solargraph
C / C++ .c, .cpp, .h, .hpp clangd brew install llvm (macOS) or apt install clangd (Linux)

1.5 Code Intelligence 초기화(Initialize Code Intelligence)

1.5.1 워크스페이스 범위 구성(Workspace-scoped configuration)

Code Intelligence 설정은 전역(Global)이 아닌 워크스페이스(Project) 단위 로 관리됩니다.

각 프로젝트는 독립적인 LSP 설정을 가집니다.

프로젝트 루트에서 다음 명령을 실행합니다.

/code init

이 명령은 .kiro/settings/lsp.json 파일을 생성하고 언어 서버를 시작합니다.


1.5.2 초기화 시 출력 예시

✓ Workspace initialization started

Workspace: /path/to/your/project
Detected Languages: ["python", "rust", "typescript"]
Project Markers: ["Cargo.toml", "package.json"]

Available LSPs:
○ clangd (cpp) - available
○ gopls (go) - not installed
◐ jdtls (java) - initializing...
✓ jedi-language-server (python) - initialized (687ms)
✓ rust-analyzer (rust) - initialized (488ms)
○ solargraph (ruby) - not installed
✓ typescript-language-server (typescript) - initialized (214ms)

1.5.3 상태 표시(Status indicators)


1.5.4 기타 제어

/code init -f

1.6 언어 서버 활용(Using Language Servers)

언어 서버는 자연어 기반 질의를 통해 다음과 같은 의미 기반 코드 인텔리전스(Semantic code intelligence) 기능을 제공합니다.

1.6.1 예제 1: 심볼 검색

> Find the UserRepository class

결과:

1. Class UserRepository at src/repositories/user.repository.ts:15:1

1.6.2 예제 2: 참조 검색

> Find references of Person class

1.6.3 예제 3: 정의 위치 탐색

> Find the definition of UserService

1.6.4 예제 4: 파일 내 심볼 조회

> What symbols are in auth.service.ts?

1.6.5 예제 5: 드라이 런 리네이밍

> Dry run: rename the method "FetchUser" to "fetchUserData"

1.6.6 예제 6: 진단 정보 조회

> Get diagnostics for main.ts

1.6.7 예제 7: 호버 정보 조회

> What's the documentation for the authenticate method in AuthService?

1.6.8 예제 8: 코드 자동완성 탐색

> What methods are available on the s3Client instance?

1.7 커스텀 언어 서버

프로젝트의 .kiro/settings/lsp.json 파일을 수정하여 커스텀 언어 서버를 추가할 수 있습니다.

{
  "languages": {
    "mylang": {
      "name": "my-language-server",
      "command": "my-lsp-binary",
      "args": ["--stdio"],
      "file_extensions": ["mylang", "ml"],
      "project_patterns": ["mylang.config"],
      "exclude_patterns": ["**/build/**"],
      "multi_workspace": false,
      "initialization_options": { "custom": "options" }
    }
  }
}

필드 설명


1.8 문제 해결

Issue Cause(s) Solution
Workspace is still initializing LSP 서버 초기화 중 대기 후 재시도, 필요 시 /code init -f
LSP initialization failed 서버 오류 /code logs -l로 로그 확인
No symbols found 인덱싱 중 또는 문법 오류 파일 오류 확인, 검색어 확장
No definition found 위치가 심볼이 아님 행·열 위치 재확인

1.9 모범 사례(Best Practices)


1.10 제약 사항(Limitations)