Skip to content

사용법

핵심 명령

명령 용도
cgrep s "query" [path] 텍스트/코드 검색
cgrep d <symbol> 정의 위치 조회
cgrep r <symbol> 참조 조회
cgrep c <function> 호출자 조회
cgrep symbols <name> 심볼 검색
cgrep read <file> 파일 스마트 읽기
cgrep map --depth 2 코드베이스 구조 맵
cgrep dep <file> 역의존 파일 조회
cgrep status 인덱스 + daemon 상태 확인

일상 작업 흐름

# 1) 후보 파일 찾기
cgrep s "authentication middleware" src/

# 2) 구현으로 바로 이동
cgrep d handle_auth

# 3) 영향 범위 확인
cgrep r handle_auth
cgrep c handle_auth

# 4) 필요한 문맥만 읽기
cgrep read src/auth.rs

작업이 넓거나 모호하면 위 흐름 전에 cgrep agent plan "..."을 선택적 stage 0으로 사용할 수 있습니다.

검색 범위 줄이기 (가장 중요)

# 경로 제한
cgrep s "DispatchKeySet" -p c10/core

# 파일 타입 제한
cgrep s "token refresh" -t rust

# 변경 파일만 검색 (기본: HEAD 기준)
cgrep s "retry" -u

# 문맥 라인 추가
cgrep s "evaluate_function" -C 2

# 결과 개수 제한
cgrep s "TensorIterator" -m 10

결과가 너무 많거나, 너무 적거나, 느리거나, 출력 cap에 걸리면 다음 순서로 다시 좁히세요:

  1. -p <path>
  2. --glob <pattern>
  3. -u [rev]
  4. -t <lang>
  5. limit / context 줄이기
  6. 에이전트/자동화라면 --profile agent 또는 --budget tight

에이전트 친화 출력

# 결정적 compact payload
cgrep --format json2 --compact s "PythonArgParser" -p torch/csrc/utils

# 점수 분해(keyword 모드)
cgrep --format json2 --compact s "target_fn" --explain

프로필과 예산

# 사람 친화 기본값
cgrep s "auth flow" -P human

# 에이전트 친화 payload 제어
cgrep s "auth flow" -P agent -B tight --format json2 --compact

mode vs profile (중요)

  • --mode는 검색 엔진을 고릅니다.
  • keyword
  • semantic (experimental)
  • hybrid (experimental)
  • --profile은 retrieval 기본값과 payload 형태를 고릅니다.
  • human
  • agent
  • fast

예시:

# 엔진 선택
cgrep s "auth flow" --mode keyword

# payload / retrieval 기본값
cgrep s "auth flow" --profile agent -B tight --format json2 --compact

더 compact한 에이전트 출력이 목적이면 profile을 쓰고, 특정 검색 엔진을 강제할 때만 mode를 쓰세요.

인덱싱 동작 (간단 정리)

  • search/read/definition/... 실행 시 인덱스가 없으면 자동 bootstrap 됩니다.
  • 필요하면 cgrep index로 미리 인덱스를 만들 수 있습니다.
  • 긴 세션에서 인덱스를 계속 최신으로 유지하려면 cgrep daemon start를 사용하세요.

주의 사항

  • 빈 쿼리는 거부됩니다.
  • 쿼리가 -로 시작하면 --를 사용하세요.
cgrep s -- --help
  • semantic, hybrid는 experimental이며 embeddings 인덱스가 필요합니다.
  • auto는 CLI 검색 모드가 아닙니다. CLI 검색에서는 keyword|semantic|hybrid를 사용하세요.

다음 문서