From 502b0945054fd2da6028095215fb65b63d0ccc60 Mon Sep 17 00:00:00 2001 From: Minsu Lee Date: Wed, 14 Oct 2026 16:34:54 +0900 Subject: [PATCH 1/5] fix(init): align agent templates with csp output and auto-cache (#111) --- README.ko.md | 33 +++++------------ README.md | 33 +++++------------ crates/csp/src/bin/csp/agents/antigravity.md | 35 ++++++------------ crates/csp/src/bin/csp/agents/claude.md | 35 ++++++------------ crates/csp/src/bin/csp/agents/commandcode.md | 35 ++++++------------ crates/csp/src/bin/csp/agents/copilot.md | 35 ++++++------------ crates/csp/src/bin/csp/agents/cursor.md | 35 ++++++------------ crates/csp/src/bin/csp/agents/gemini.md | 35 ++++++------------ crates/csp/src/bin/csp/agents/kiro.md | 35 ++++++------------ crates/csp/src/bin/csp/agents/opencode.md | 35 ++++++------------ crates/csp/src/bin/csp/agents/pi.md | 35 ++++++------------ crates/csp/src/bin/csp/agents/reasonix.md | 35 ++++++------------ crates/csp/src/bin/csp/main.rs | 14 ++++++++ docs/src/content/docs/agents-md.mdx | 33 +++++------------ plugins/csp/agents/csp-search.md | 35 ++++++------------ plugins/csp/skills/csp-search/SKILL.md | 37 ++++++-------------- 16 files changed, 162 insertions(+), 373 deletions(-) diff --git a/README.ko.md b/README.ko.md index 3c50d89..90b8766 100644 --- a/README.ko.md +++ b/README.ko.md @@ -103,24 +103,12 @@ cargo install code-search-please 코드를 grep 으로 찾기 전에 `csp search`를 사용하세요. 동작을 자연어로 설명하거나 심볼/식별자명을 입력하면 됩니다. ```bash -csp search "authentication flow" ./my-project -csp search "saveCheckpoint" ./my-project -csp search "save model to disk" ./my-project --top-k 10 -``` - -여러 번 검색할 예정이라면 `csp index`로 인덱스를 만들어 두세요. - -```bash -csp index ./my-project -o my_index +csp search "authentication flow" ./my-project --max-snippet-lines 10 # first 10 lines only, concise +csp search "saveCheckpoint" ./my-project # full chunk content +csp search "save model to disk" ./my-project --top-k 10 # more results ``` -이후 인덱스를 재사용할 수 있습니다. - -```bash -csp search "saveCheckpoint" --index my_index -``` - -인덱스는 자동으로 갱신되지 않습니다. 코드가 크게 바뀌었거나 검색 결과가 오래된 것 같다면 다시 인덱싱하세요. +결과는 첫 실행 때 자동으로 캐시되며, 파일이 바뀌면 무효화됩니다. `--content docs`로 문서와 산문을, `--content config`로 yaml/toml 등 설정 파일을, `--content all`로 모두 검색할 수 있습니다. @@ -142,20 +130,17 @@ csp search "authentication" ./my-project --max-snippet-lines 10 csp find-related src/auth.ts 42 ./my-project ``` -`search`와 마찬가지로 `find-related`도 `--index` 인자를 받습니다. - `path`를 생략하면 현재 디렉터리를 사용합니다. git URL도 받습니다. `csp`가 `$PATH`에 없다면 `bunx @pleaseai/csp`로 대체하세요. ### Workflow -1. `csp index -o cached_index`로 리포지토리를 인덱싱. -2. `csp search`로 관련 청크를 찾기. 인덱스를 넘기면 더 빠릅니다. -3. 문서는 `--content docs`, 설정 파일은 `--content config`, 전부는 `--content all`. -4. 반환된 청크로 컨텍스트가 부족할 때만 파일을 전체 읽기. -5. 유망한 결과에서 `csp find-related`로 비슷한 구현을 추가 탐색. -6. 정확한 리터럴 매칭이나 문자열 확인이 필요할 때만 grep 사용. +1. `csp search`로 관련 청크를 찾기. 인덱스는 자동으로 빌드되고 캐시됩니다. +2. 문서는 `--content docs`, 설정 파일은 `--content config`, 전부는 `--content all`. +3. 반환된 파일과 라인으로 바로 이동하세요. 같은 내용을 다시 검색하거나 grep 하지 마세요. +4. 유망한 결과의 `file_path`와 `line`으로 `csp find-related`를 사용해 비슷한 구현을 추가 탐색(선택). +5. 리포지토리 전체에서 리터럴 문자열의 모든 출현 위치가 필요할 때만 grep 사용 (예: 이름이 바뀐 함수의 모든 호출처). ```` diff --git a/README.md b/README.md index 9239dff..e439d8c 100644 --- a/README.md +++ b/README.md @@ -103,24 +103,12 @@ cargo install code-search-please Use `csp search` to find code by describing what it does or naming a symbol/identifier, instead of grep: ```bash -csp search "authentication flow" ./my-project -csp search "saveCheckpoint" ./my-project -csp search "save model to disk" ./my-project --top-k 10 -``` - -If you anticipate doing more than one search, use `csp index` to create an index. - -```bash -csp index ./my-project -o my_index +csp search "authentication flow" ./my-project --max-snippet-lines 10 # first 10 lines only, concise +csp search "saveCheckpoint" ./my-project # full chunk content +csp search "save model to disk" ./my-project --top-k 10 # more results ``` -You can then reuse this index later on: - -```bash -csp search "saveCheckpoint" --index my_index -``` - -An index is not automatically updated, so if the code changes significantly, reindex. If you notice stale results while resolving searches to files, reindex. +Results are cached automatically on first run and invalidated when files change. Use `--content docs` to search documentation and prose, `--content config` for config files (yaml, toml, etc.), or `--content all` to search code, docs, and config: @@ -142,20 +130,17 @@ Use `csp find-related` to discover code similar to a known location (pass `file_ csp find-related src/auth.ts 42 ./my-project ``` -Like search, `find-related` also accepts an `--index` argument. - `path` defaults to the current directory when omitted; git URLs are accepted. If `csp` is not on `$PATH`, use `bunx @pleaseai/csp` in its place. ### Workflow -1. Index the repo using `csp index -o cached_index`. -2. Start with `csp search` to find relevant chunks. Pass the index to achieve results faster. -3. Use `--content docs` for documentation, `--content config` for config files, or `--content all` for everything. -4. Inspect full files only when the returned chunk does not give enough context. -5. Optionally use `csp find-related` with a promising result's `file_path` and `line` to discover related implementations. -6. Use grep only when you need exhaustive literal matches or quick confirmation of an exact string. +1. Start with `csp search` to find relevant chunks. The index is built and cached automatically. +2. Use `--content docs` for documentation, `--content config` for config files, or `--content all` for everything. +3. Navigate directly to the returned file and line. Do not re-search or grep for the same content. +4. Optionally use `csp find-related` with a promising result's `file_path` and `line` to discover related implementations. +5. Use grep only when you need every occurrence of a literal string across the whole repo (e.g., all callers of a renamed function). ```` diff --git a/crates/csp/src/bin/csp/agents/antigravity.md b/crates/csp/src/bin/csp/agents/antigravity.md index adaaeec..3566078 100644 --- a/crates/csp/src/bin/csp/agents/antigravity.md +++ b/crates/csp/src/bin/csp/agents/antigravity.md @@ -9,24 +9,12 @@ tools: Use `csp search` to find code by describing what it does or naming a symbol/identifier, instead of grep: ```bash -csp search "authentication flow" ./my-project -csp search "save_pretrained" ./my-project -csp search "save model to disk" ./my-project --top-k 10 +csp search "authentication flow" ./my-project --max-snippet-lines 10 # first 10 lines only, concise +csp search "save_pretrained" ./my-project # full chunk content +csp search "save model to disk" ./my-project --top-k 10 # more results ``` -If you anticipate doing more than one search, use `csp index` to create an index. - -```bash -csp index ./my-project -o my_index -``` - -You can then reuse this index later on: - -```bash -csp search "save_pretrained" --index my_index -``` - -An index is not automatically updated, so if the code changes significantly, reindex. If you notice stale results while resolving searches to files, reindex. +Results are cached automatically on first run and invalidated when files change. Use `--content docs` to search documentation and prose, `--content config` for config files (yaml, toml, etc.), or `--content all` to search code, docs, and config: @@ -36,23 +24,20 @@ csp search "database host port" ./my-project --content config csp search "authentication" ./my-project --content all ``` -Use `csp find-related` to discover code similar to a known location (pass `filePath` and `line` from a prior search result): +Use `csp find-related` to discover code similar to a known location (pass `file_path` and `line` from a prior search result): ```bash csp find-related src/auth.ts 42 ./my-project ``` -Like search, `find-related` also accepts an `--index` argument. - `path` defaults to the current directory when omitted; git URLs are accepted. If `csp` is not on `$PATH`, use `bunx @pleaseai/csp` in its place. ### Workflow -1. Index the repo using `csp index -o cached_index`. -2. Start with `csp search` to find relevant chunks. Pass the index to achieve results faster. -3. Use `--content docs` for documentation, `--content config` for config files, or `--content all` for everything. -4. Inspect full files only when the returned chunk does not give enough context. -5. Optionally use `csp find-related` with a promising result's `filePath` and `line` to discover related implementations. -6. Use grep only when you need exhaustive literal matches or quick confirmation of an exact string. \ No newline at end of file +1. Start with `csp search` to find relevant chunks. The index is built and cached automatically. +2. Use `--content docs` for documentation, `--content config` for config files, or `--content all` for everything. +3. Navigate directly to the returned file and line. Do not re-search or grep for the same content. +4. Optionally use `csp find-related` with a promising result's `file_path` and `line` to discover related implementations. +5. Use grep only when you need every occurrence of a literal string across the whole repo (e.g., all callers of a renamed function). diff --git a/crates/csp/src/bin/csp/agents/claude.md b/crates/csp/src/bin/csp/agents/claude.md index 238afdd..064b311 100644 --- a/crates/csp/src/bin/csp/agents/claude.md +++ b/crates/csp/src/bin/csp/agents/claude.md @@ -7,24 +7,12 @@ tools: Bash, Read Use `csp search` to find code by describing what it does or naming a symbol/identifier, instead of grep: ```bash -csp search "authentication flow" ./my-project -csp search "save_pretrained" ./my-project -csp search "save model to disk" ./my-project --top-k 10 +csp search "authentication flow" ./my-project --max-snippet-lines 10 # first 10 lines only, concise +csp search "save_pretrained" ./my-project # full chunk content +csp search "save model to disk" ./my-project --top-k 10 # more results ``` -If you anticipate doing more than one search, use `csp index` to create an index. - -```bash -csp index ./my-project -o my_index -``` - -You can then reuse this index later on: - -```bash -csp search "save_pretrained" --index my_index -``` - -An index is not automatically updated, so if the code changes significantly, reindex. If you notice stale results while resolving searches to files, reindex. +Results are cached automatically on first run and invalidated when files change. Use `--content docs` to search documentation and prose, `--content config` for config files (yaml, toml, etc.), or `--content all` to search code, docs, and config: @@ -34,23 +22,20 @@ csp search "database host port" ./my-project --content config csp search "authentication" ./my-project --content all ``` -Use `csp find-related` to discover code similar to a known location (pass `filePath` and `line` from a prior search result): +Use `csp find-related` to discover code similar to a known location (pass `file_path` and `line` from a prior search result): ```bash csp find-related src/auth.ts 42 ./my-project ``` -Like search, `find-related` also accepts an `--index` argument. - `path` defaults to the current directory when omitted; git URLs are accepted. If `csp` is not on `$PATH`, use `bunx @pleaseai/csp` in its place. ### Workflow -1. Index the repo using `csp index -o cached_index`. -2. Start with `csp search` to find relevant chunks. Pass the index to achieve results faster. -3. Use `--content docs` for documentation, `--content config` for config files, or `--content all` for everything. -4. Inspect full files only when the returned chunk does not give enough context. -5. Optionally use `csp find-related` with a promising result's `filePath` and `line` to discover related implementations. -6. Use grep only when you need exhaustive literal matches or quick confirmation of an exact string. +1. Start with `csp search` to find relevant chunks. The index is built and cached automatically. +2. Use `--content docs` for documentation, `--content config` for config files, or `--content all` for everything. +3. Navigate directly to the returned file and line. Do not re-search or grep for the same content. +4. Optionally use `csp find-related` with a promising result's `file_path` and `line` to discover related implementations. +5. Use grep only when you need every occurrence of a literal string across the whole repo (e.g., all callers of a renamed function). diff --git a/crates/csp/src/bin/csp/agents/commandcode.md b/crates/csp/src/bin/csp/agents/commandcode.md index aa008b7..a06cbf3 100644 --- a/crates/csp/src/bin/csp/agents/commandcode.md +++ b/crates/csp/src/bin/csp/agents/commandcode.md @@ -7,24 +7,12 @@ tools: bash, read_file Use `csp search` to find code by describing what it does or naming a symbol/identifier, instead of grep: ```bash -csp search "authentication flow" ./my-project -csp search "save_pretrained" ./my-project -csp search "save model to disk" ./my-project --top-k 10 +csp search "authentication flow" ./my-project --max-snippet-lines 10 # first 10 lines only, concise +csp search "save_pretrained" ./my-project # full chunk content +csp search "save model to disk" ./my-project --top-k 10 # more results ``` -If you anticipate doing more than one search, use `csp index` to create an index. - -```bash -csp index ./my-project -o my_index -``` - -You can then reuse this index later on: - -```bash -csp search "save_pretrained" --index my_index -``` - -An index is not automatically updated, so if the code changes significantly, reindex. If you notice stale results while resolving searches to files, reindex. +Results are cached automatically on first run and invalidated when files change. Use `--content docs` to search documentation and prose, `--content config` for config files (yaml, toml, etc.), or `--content all` to search code, docs, and config: @@ -34,23 +22,20 @@ csp search "database host port" ./my-project --content config csp search "authentication" ./my-project --content all ``` -Use `csp find-related` to discover code similar to a known location (pass `filePath` and `line` from a prior search result): +Use `csp find-related` to discover code similar to a known location (pass `file_path` and `line` from a prior search result): ```bash csp find-related src/auth.ts 42 ./my-project ``` -Like search, `find-related` also accepts an `--index` argument. - `path` defaults to the current directory when omitted; git URLs are accepted. If `csp` is not on `$PATH`, use `bunx @pleaseai/csp` in its place. ### Workflow -1. Index the repo using `csp index -o cached_index`. -2. Start with `csp search` to find relevant chunks. Pass the index to achieve results faster. -3. Use `--content docs` for documentation, `--content config` for config files, or `--content all` for everything. -4. Inspect full files only when the returned chunk does not give enough context. -5. Optionally use `csp find-related` with a promising result's `filePath` and `line` to discover related implementations. -6. Use grep only when you need exhaustive literal matches or quick confirmation of an exact string. \ No newline at end of file +1. Start with `csp search` to find relevant chunks. The index is built and cached automatically. +2. Use `--content docs` for documentation, `--content config` for config files, or `--content all` for everything. +3. Navigate directly to the returned file and line. Do not re-search or grep for the same content. +4. Optionally use `csp find-related` with a promising result's `file_path` and `line` to discover related implementations. +5. Use grep only when you need every occurrence of a literal string across the whole repo (e.g., all callers of a renamed function). diff --git a/crates/csp/src/bin/csp/agents/copilot.md b/crates/csp/src/bin/csp/agents/copilot.md index 238afdd..064b311 100644 --- a/crates/csp/src/bin/csp/agents/copilot.md +++ b/crates/csp/src/bin/csp/agents/copilot.md @@ -7,24 +7,12 @@ tools: Bash, Read Use `csp search` to find code by describing what it does or naming a symbol/identifier, instead of grep: ```bash -csp search "authentication flow" ./my-project -csp search "save_pretrained" ./my-project -csp search "save model to disk" ./my-project --top-k 10 +csp search "authentication flow" ./my-project --max-snippet-lines 10 # first 10 lines only, concise +csp search "save_pretrained" ./my-project # full chunk content +csp search "save model to disk" ./my-project --top-k 10 # more results ``` -If you anticipate doing more than one search, use `csp index` to create an index. - -```bash -csp index ./my-project -o my_index -``` - -You can then reuse this index later on: - -```bash -csp search "save_pretrained" --index my_index -``` - -An index is not automatically updated, so if the code changes significantly, reindex. If you notice stale results while resolving searches to files, reindex. +Results are cached automatically on first run and invalidated when files change. Use `--content docs` to search documentation and prose, `--content config` for config files (yaml, toml, etc.), or `--content all` to search code, docs, and config: @@ -34,23 +22,20 @@ csp search "database host port" ./my-project --content config csp search "authentication" ./my-project --content all ``` -Use `csp find-related` to discover code similar to a known location (pass `filePath` and `line` from a prior search result): +Use `csp find-related` to discover code similar to a known location (pass `file_path` and `line` from a prior search result): ```bash csp find-related src/auth.ts 42 ./my-project ``` -Like search, `find-related` also accepts an `--index` argument. - `path` defaults to the current directory when omitted; git URLs are accepted. If `csp` is not on `$PATH`, use `bunx @pleaseai/csp` in its place. ### Workflow -1. Index the repo using `csp index -o cached_index`. -2. Start with `csp search` to find relevant chunks. Pass the index to achieve results faster. -3. Use `--content docs` for documentation, `--content config` for config files, or `--content all` for everything. -4. Inspect full files only when the returned chunk does not give enough context. -5. Optionally use `csp find-related` with a promising result's `filePath` and `line` to discover related implementations. -6. Use grep only when you need exhaustive literal matches or quick confirmation of an exact string. +1. Start with `csp search` to find relevant chunks. The index is built and cached automatically. +2. Use `--content docs` for documentation, `--content config` for config files, or `--content all` for everything. +3. Navigate directly to the returned file and line. Do not re-search or grep for the same content. +4. Optionally use `csp find-related` with a promising result's `file_path` and `line` to discover related implementations. +5. Use grep only when you need every occurrence of a literal string across the whole repo (e.g., all callers of a renamed function). diff --git a/crates/csp/src/bin/csp/agents/cursor.md b/crates/csp/src/bin/csp/agents/cursor.md index 23e85d9..8322bc8 100644 --- a/crates/csp/src/bin/csp/agents/cursor.md +++ b/crates/csp/src/bin/csp/agents/cursor.md @@ -6,24 +6,12 @@ description: Code search agent for exploring any codebase. Use for finding code Use `csp search` to find code by describing what it does or naming a symbol/identifier, instead of grep: ```bash -csp search "authentication flow" ./my-project -csp search "save_pretrained" ./my-project -csp search "save model to disk" ./my-project --top-k 10 +csp search "authentication flow" ./my-project --max-snippet-lines 10 # first 10 lines only, concise +csp search "save_pretrained" ./my-project # full chunk content +csp search "save model to disk" ./my-project --top-k 10 # more results ``` -If you anticipate doing more than one search, use `csp index` to create an index. - -```bash -csp index ./my-project -o my_index -``` - -You can then reuse this index later on: - -```bash -csp search "save_pretrained" --index my_index -``` - -An index is not automatically updated, so if the code changes significantly, reindex. If you notice stale results while resolving searches to files, reindex. +Results are cached automatically on first run and invalidated when files change. Use `--content docs` to search documentation and prose, `--content config` for config files (yaml, toml, etc.), or `--content all` to search code, docs, and config: @@ -33,23 +21,20 @@ csp search "database host port" ./my-project --content config csp search "authentication" ./my-project --content all ``` -Use `csp find-related` to discover code similar to a known location (pass `filePath` and `line` from a prior search result): +Use `csp find-related` to discover code similar to a known location (pass `file_path` and `line` from a prior search result): ```bash csp find-related src/auth.ts 42 ./my-project ``` -Like search, `find-related` also accepts an `--index` argument. - `path` defaults to the current directory when omitted; git URLs are accepted. If `csp` is not on `$PATH`, use `bunx @pleaseai/csp` in its place. ### Workflow -1. Index the repo using `csp index -o cached_index`. -2. Start with `csp search` to find relevant chunks. Pass the index to achieve results faster. -3. Use `--content docs` for documentation, `--content config` for config files, or `--content all` for everything. -4. Inspect full files only when the returned chunk does not give enough context. -5. Optionally use `csp find-related` with a promising result's `filePath` and `line` to discover related implementations. -6. Use grep only when you need exhaustive literal matches or quick confirmation of an exact string. +1. Start with `csp search` to find relevant chunks. The index is built and cached automatically. +2. Use `--content docs` for documentation, `--content config` for config files, or `--content all` for everything. +3. Navigate directly to the returned file and line. Do not re-search or grep for the same content. +4. Optionally use `csp find-related` with a promising result's `file_path` and `line` to discover related implementations. +5. Use grep only when you need every occurrence of a literal string across the whole repo (e.g., all callers of a renamed function). diff --git a/crates/csp/src/bin/csp/agents/gemini.md b/crates/csp/src/bin/csp/agents/gemini.md index 9436d1a..3566078 100644 --- a/crates/csp/src/bin/csp/agents/gemini.md +++ b/crates/csp/src/bin/csp/agents/gemini.md @@ -9,24 +9,12 @@ tools: Use `csp search` to find code by describing what it does or naming a symbol/identifier, instead of grep: ```bash -csp search "authentication flow" ./my-project -csp search "save_pretrained" ./my-project -csp search "save model to disk" ./my-project --top-k 10 +csp search "authentication flow" ./my-project --max-snippet-lines 10 # first 10 lines only, concise +csp search "save_pretrained" ./my-project # full chunk content +csp search "save model to disk" ./my-project --top-k 10 # more results ``` -If you anticipate doing more than one search, use `csp index` to create an index. - -```bash -csp index ./my-project -o my_index -``` - -You can then reuse this index later on: - -```bash -csp search "save_pretrained" --index my_index -``` - -An index is not automatically updated, so if the code changes significantly, reindex. If you notice stale results while resolving searches to files, reindex. +Results are cached automatically on first run and invalidated when files change. Use `--content docs` to search documentation and prose, `--content config` for config files (yaml, toml, etc.), or `--content all` to search code, docs, and config: @@ -36,23 +24,20 @@ csp search "database host port" ./my-project --content config csp search "authentication" ./my-project --content all ``` -Use `csp find-related` to discover code similar to a known location (pass `filePath` and `line` from a prior search result): +Use `csp find-related` to discover code similar to a known location (pass `file_path` and `line` from a prior search result): ```bash csp find-related src/auth.ts 42 ./my-project ``` -Like search, `find-related` also accepts an `--index` argument. - `path` defaults to the current directory when omitted; git URLs are accepted. If `csp` is not on `$PATH`, use `bunx @pleaseai/csp` in its place. ### Workflow -1. Index the repo using `csp index -o cached_index`. -2. Start with `csp search` to find relevant chunks. Pass the index to achieve results faster. -3. Use `--content docs` for documentation, `--content config` for config files, or `--content all` for everything. -4. Inspect full files only when the returned chunk does not give enough context. -5. Optionally use `csp find-related` with a promising result's `filePath` and `line` to discover related implementations. -6. Use grep only when you need exhaustive literal matches or quick confirmation of an exact string. +1. Start with `csp search` to find relevant chunks. The index is built and cached automatically. +2. Use `--content docs` for documentation, `--content config` for config files, or `--content all` for everything. +3. Navigate directly to the returned file and line. Do not re-search or grep for the same content. +4. Optionally use `csp find-related` with a promising result's `file_path` and `line` to discover related implementations. +5. Use grep only when you need every occurrence of a literal string across the whole repo (e.g., all callers of a renamed function). diff --git a/crates/csp/src/bin/csp/agents/kiro.md b/crates/csp/src/bin/csp/agents/kiro.md index 01e0df1..6629c6d 100644 --- a/crates/csp/src/bin/csp/agents/kiro.md +++ b/crates/csp/src/bin/csp/agents/kiro.md @@ -9,24 +9,12 @@ tools: Use `csp search` to find code by describing what it does or naming a symbol/identifier, instead of grep: ```bash -csp search "authentication flow" ./my-project -csp search "save_pretrained" ./my-project -csp search "save model to disk" ./my-project --top-k 10 +csp search "authentication flow" ./my-project --max-snippet-lines 10 # first 10 lines only, concise +csp search "save_pretrained" ./my-project # full chunk content +csp search "save model to disk" ./my-project --top-k 10 # more results ``` -If you anticipate doing more than one search, use `csp index` to create an index. - -```bash -csp index ./my-project -o my_index -``` - -You can then reuse this index later on: - -```bash -csp search "save_pretrained" --index my_index -``` - -An index is not automatically updated, so if the code changes significantly, reindex. If you notice stale results while resolving searches to files, reindex. +Results are cached automatically on first run and invalidated when files change. Use `--content docs` to search documentation and prose, `--content config` for config files (yaml, toml, etc.), or `--content all` to search code, docs, and config: @@ -36,23 +24,20 @@ csp search "database host port" ./my-project --content config csp search "authentication" ./my-project --content all ``` -Use `csp find-related` to discover code similar to a known location (pass `filePath` and `line` from a prior search result): +Use `csp find-related` to discover code similar to a known location (pass `file_path` and `line` from a prior search result): ```bash csp find-related src/auth.ts 42 ./my-project ``` -Like search, `find-related` also accepts an `--index` argument. - `path` defaults to the current directory when omitted; git URLs are accepted. If `csp` is not on `$PATH`, use `bunx @pleaseai/csp` in its place. ### Workflow -1. Index the repo using `csp index -o cached_index`. -2. Start with `csp search` to find relevant chunks. Pass the index to achieve results faster. -3. Use `--content docs` for documentation, `--content config` for config files, or `--content all` for everything. -4. Inspect full files only when the returned chunk does not give enough context. -5. Optionally use `csp find-related` with a promising result's `filePath` and `line` to discover related implementations. -6. Use grep only when you need exhaustive literal matches or quick confirmation of an exact string. +1. Start with `csp search` to find relevant chunks. The index is built and cached automatically. +2. Use `--content docs` for documentation, `--content config` for config files, or `--content all` for everything. +3. Navigate directly to the returned file and line. Do not re-search or grep for the same content. +4. Optionally use `csp find-related` with a promising result's `file_path` and `line` to discover related implementations. +5. Use grep only when you need every occurrence of a literal string across the whole repo (e.g., all callers of a renamed function). diff --git a/crates/csp/src/bin/csp/agents/opencode.md b/crates/csp/src/bin/csp/agents/opencode.md index 8a5abc0..a6a29d3 100644 --- a/crates/csp/src/bin/csp/agents/opencode.md +++ b/crates/csp/src/bin/csp/agents/opencode.md @@ -10,24 +10,12 @@ permission: Use `csp search` to find code by describing what it does or naming a symbol/identifier, instead of grep: ```bash -csp search "authentication flow" ./my-project -csp search "save_pretrained" ./my-project -csp search "save model to disk" ./my-project --top-k 10 +csp search "authentication flow" ./my-project --max-snippet-lines 10 # first 10 lines only, concise +csp search "save_pretrained" ./my-project # full chunk content +csp search "save model to disk" ./my-project --top-k 10 # more results ``` -If you anticipate doing more than one search, use `csp index` to create an index. - -```bash -csp index ./my-project -o my_index -``` - -You can then reuse this index later on: - -```bash -csp search "save_pretrained" --index my_index -``` - -An index is not automatically updated, so if the code changes significantly, reindex. If you notice stale results while resolving searches to files, reindex. +Results are cached automatically on first run and invalidated when files change. Use `--content docs` to search documentation and prose, `--content config` for config files (yaml, toml, etc.), or `--content all` to search code, docs, and config: @@ -37,23 +25,20 @@ csp search "database host port" ./my-project --content config csp search "authentication" ./my-project --content all ``` -Use `csp find-related` to discover code similar to a known location (pass `filePath` and `line` from a prior search result): +Use `csp find-related` to discover code similar to a known location (pass `file_path` and `line` from a prior search result): ```bash csp find-related src/auth.ts 42 ./my-project ``` -Like search, `find-related` also accepts an `--index` argument. - `path` defaults to the current directory when omitted; git URLs are accepted. If `csp` is not on `$PATH`, use `bunx @pleaseai/csp` in its place. ### Workflow -1. Index the repo using `csp index -o cached_index`. -2. Start with `csp search` to find relevant chunks. Pass the index to achieve results faster. -3. Use `--content docs` for documentation, `--content config` for config files, or `--content all` for everything. -4. Inspect full files only when the returned chunk does not give enough context. -5. Optionally use `csp find-related` with a promising result's `filePath` and `line` to discover related implementations. -6. Use grep only when you need exhaustive literal matches or quick confirmation of an exact string. +1. Start with `csp search` to find relevant chunks. The index is built and cached automatically. +2. Use `--content docs` for documentation, `--content config` for config files, or `--content all` for everything. +3. Navigate directly to the returned file and line. Do not re-search or grep for the same content. +4. Optionally use `csp find-related` with a promising result's `file_path` and `line` to discover related implementations. +5. Use grep only when you need every occurrence of a literal string across the whole repo (e.g., all callers of a renamed function). diff --git a/crates/csp/src/bin/csp/agents/pi.md b/crates/csp/src/bin/csp/agents/pi.md index 374f998..8322bc8 100644 --- a/crates/csp/src/bin/csp/agents/pi.md +++ b/crates/csp/src/bin/csp/agents/pi.md @@ -6,24 +6,12 @@ description: Code search agent for exploring any codebase. Use for finding code Use `csp search` to find code by describing what it does or naming a symbol/identifier, instead of grep: ```bash -csp search "authentication flow" ./my-project -csp search "save_pretrained" ./my-project -csp search "save model to disk" ./my-project --top-k 10 +csp search "authentication flow" ./my-project --max-snippet-lines 10 # first 10 lines only, concise +csp search "save_pretrained" ./my-project # full chunk content +csp search "save model to disk" ./my-project --top-k 10 # more results ``` -If you anticipate doing more than one search, use `csp index` to create an index. - -```bash -csp index ./my-project -o my_index -``` - -You can then reuse this index later on: - -```bash -csp search "save_pretrained" --index my_index -``` - -An index is not automatically updated, so if the code changes significantly, reindex. If you notice stale results while resolving searches to files, reindex. +Results are cached automatically on first run and invalidated when files change. Use `--content docs` to search documentation and prose, `--content config` for config files (yaml, toml, etc.), or `--content all` to search code, docs, and config: @@ -33,23 +21,20 @@ csp search "database host port" ./my-project --content config csp search "authentication" ./my-project --content all ``` -Use `csp find-related` to discover code similar to a known location (pass `filePath` and `line` from a prior search result): +Use `csp find-related` to discover code similar to a known location (pass `file_path` and `line` from a prior search result): ```bash csp find-related src/auth.ts 42 ./my-project ``` -Like search, `find-related` also accepts an `--index` argument. - `path` defaults to the current directory when omitted; git URLs are accepted. If `csp` is not on `$PATH`, use `bunx @pleaseai/csp` in its place. ### Workflow -1. Index the repo using `csp index -o cached_index`. -2. Start with `csp search` to find relevant chunks. Pass the index to achieve results faster. -3. Use `--content docs` for documentation, `--content config` for config files, or `--content all` for everything. -4. Inspect full files only when the returned chunk does not give enough context. -5. Optionally use `csp find-related` with a promising result's `filePath` and `line` to discover related implementations. -6. Use grep only when you need exhaustive literal matches or quick confirmation of an exact string. \ No newline at end of file +1. Start with `csp search` to find relevant chunks. The index is built and cached automatically. +2. Use `--content docs` for documentation, `--content config` for config files, or `--content all` for everything. +3. Navigate directly to the returned file and line. Do not re-search or grep for the same content. +4. Optionally use `csp find-related` with a promising result's `file_path` and `line` to discover related implementations. +5. Use grep only when you need every occurrence of a literal string across the whole repo (e.g., all callers of a renamed function). diff --git a/crates/csp/src/bin/csp/agents/reasonix.md b/crates/csp/src/bin/csp/agents/reasonix.md index 9353344..0a696cc 100644 --- a/crates/csp/src/bin/csp/agents/reasonix.md +++ b/crates/csp/src/bin/csp/agents/reasonix.md @@ -8,24 +8,12 @@ allowed-tools: bash, read_file Use `csp search` to find code by describing what it does or naming a symbol/identifier, instead of grep: ```bash -csp search "authentication flow" ./my-project -csp search "save_pretrained" ./my-project -csp search "save model to disk" ./my-project --top-k 10 +csp search "authentication flow" ./my-project --max-snippet-lines 10 # first 10 lines only, concise +csp search "save_pretrained" ./my-project # full chunk content +csp search "save model to disk" ./my-project --top-k 10 # more results ``` -If you anticipate doing more than one search, use `csp index` to create an index. - -```bash -csp index ./my-project -o my_index -``` - -You can then reuse this index later on: - -```bash -csp search "save_pretrained" --index my_index -``` - -An index is not automatically updated, so if the code changes significantly, reindex. If you notice stale results while resolving searches to files, reindex. +Results are cached automatically on first run and invalidated when files change. Use `--content docs` to search documentation and prose, `--content config` for config files (yaml, toml, etc.), or `--content all` to search code, docs, and config: @@ -35,23 +23,20 @@ csp search "database host port" ./my-project --content config csp search "authentication" ./my-project --content all ``` -Use `csp find-related` to discover code similar to a known location (pass `filePath` and `line` from a prior search result): +Use `csp find-related` to discover code similar to a known location (pass `file_path` and `line` from a prior search result): ```bash csp find-related src/auth.ts 42 ./my-project ``` -Like search, `find-related` also accepts an `--index` argument. - `path` defaults to the current directory when omitted; git URLs are accepted. If `csp` is not on `$PATH`, use `bunx @pleaseai/csp` in its place. ### Workflow -1. Index the repo using `csp index -o cached_index`. -2. Start with `csp search` to find relevant chunks. Pass the index to achieve results faster. -3. Use `--content docs` for documentation, `--content config` for config files, or `--content all` for everything. -4. Inspect full files only when the returned chunk does not give enough context. -5. Optionally use `csp find-related` with a promising result's `filePath` and `line` to discover related implementations. -6. Use grep only when you need exhaustive literal matches or quick confirmation of an exact string. \ No newline at end of file +1. Start with `csp search` to find relevant chunks. The index is built and cached automatically. +2. Use `--content docs` for documentation, `--content config` for config files, or `--content all` for everything. +3. Navigate directly to the returned file and line. Do not re-search or grep for the same content. +4. Optionally use `csp find-related` with a promising result's `file_path` and `line` to discover related implementations. +5. Use grep only when you need every occurrence of a literal string across the whole repo (e.g., all callers of a renamed function). diff --git a/crates/csp/src/bin/csp/main.rs b/crates/csp/src/bin/csp/main.rs index a2d709f..3f305c1 100644 --- a/crates/csp/src/bin/csp/main.rs +++ b/crates/csp/src/bin/csp/main.rs @@ -587,6 +587,20 @@ mod tests { assert!(run_init(Agent::Claude, true, dir.path()).is_ok()); } + #[test] + fn agent_templates_match_cli_output_and_auto_cache() { + for agent in Agent::value_variants() { + let t = agent.template(); + assert!(t.contains("file_path"), "{} lacks file_path", agent.slug()); + assert!(!t.contains("filePath"), "{} has filePath", agent.slug()); + assert!( + !t.contains("not automatically updated"), + "{} has stale index guidance", + agent.slug() + ); + } + } + fn build_index_dir() -> tempfile::TempDir { let dir = tempdir().unwrap(); std::fs::write( diff --git a/docs/src/content/docs/agents-md.mdx b/docs/src/content/docs/agents-md.mdx index 3b96bc0..f848390 100644 --- a/docs/src/content/docs/agents-md.mdx +++ b/docs/src/content/docs/agents-md.mdx @@ -15,24 +15,12 @@ Copy this block as-is: Use `csp search` to find code by describing what it does or naming a symbol/identifier, instead of grep: ```bash -csp search "authentication flow" ./my-project -csp search "saveCheckpoint" ./my-project -csp search "save model to disk" ./my-project --top-k 10 +csp search "authentication flow" ./my-project --max-snippet-lines 10 # first 10 lines only, concise +csp search "saveCheckpoint" ./my-project # full chunk content +csp search "save model to disk" ./my-project --top-k 10 # more results ``` -If you anticipate doing more than one search, use `csp index` to create an index. - -```bash -csp index ./my-project -o my_index -``` - -You can then reuse this index later on: - -```bash -csp search "saveCheckpoint" --index my_index -``` - -An index is not automatically updated, so if the code changes significantly, reindex. If you notice stale results while resolving searches to files, reindex. +Results are cached automatically on first run and invalidated when files change. Use `--content docs` to search documentation and prose, `--content config` for config files (yaml, toml, etc.), or `--content all` to search code, docs, and config: @@ -54,20 +42,17 @@ Use `csp find-related` to discover code similar to a known location (pass `file_ csp find-related src/auth.ts 42 ./my-project ``` -Like search, `find-related` also accepts an `--index` argument. - `path` defaults to the current directory when omitted; git URLs are accepted. If `csp` is not on `$PATH`, use `bunx @pleaseai/csp` in its place. ### Workflow -1. Index the repo using `csp index -o cached_index`. -2. Start with `csp search` to find relevant chunks. Pass the index to achieve results faster. -3. Use `--content docs` for documentation, `--content config` for config files, or `--content all` for everything. -4. Inspect full files only when the returned chunk does not give enough context. -5. Optionally use `csp find-related` with a promising result's `file_path` and `line` to discover related implementations. -6. Use grep only when you need exhaustive literal matches or quick confirmation of an exact string. +1. Start with `csp search` to find relevant chunks. The index is built and cached automatically. +2. Use `--content docs` for documentation, `--content config` for config files, or `--content all` for everything. +3. Navigate directly to the returned file and line. Do not re-search or grep for the same content. +4. Optionally use `csp find-related` with a promising result's `file_path` and `line` to discover related implementations. +5. Use grep only when you need every occurrence of a literal string across the whole repo (e.g., all callers of a renamed function). ````