Skip to content
20 changes: 18 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,19 @@ cdidx search "handleRequest"
cdidx definition UserService
cdidx search "Handle" --project MyApp
cdidx search "File.ReadAllText" --exact-substring --reject-before "Length" --guard-window 8
cdidx search --list-recipes
cdidx search --recipe risky-code --json
cdidx search --recipe risky-code --format issue-drafts --open-issues open-issues.json
cdidx validate
cdidx mcp
cdidx lsp --db .cdidx/codeindex.db
```

Recipe runs support text, `--json` / `--format json`, and
`--format issue-drafts`; `--list-recipes` supports text or JSON. Other search
export formats and `--json=array` are rejected for recipe modes because recipe
output is grouped by query or list metadata.

Custom language loops can stay out of tree: put extension aliases in
`.cdidx-langmap.yaml`, put regex symbol patterns in `.cdidx/patterns/*.yaml`,
and run `cdidx test-extractor --language <lang> --file <path> --json` to test
Expand Down Expand Up @@ -158,7 +166,7 @@ downgrading `cdidx`.

| Area | What cdidx provides |
|---|---|
| Search surfaces | CLI-first output for humans and machines; full-text, symbol, reference, caller/callee, dependency, map, inspect, and excerpt commands. `search`, `definition`, `references`, `callers`, `callees`, `find`, and `validate` support `--format count|compact|csv|tsv|lsp|qf|sarif` for token-budgeted agents, scripts, editors, and CI reports. `cdidx lsp --db .cdidx/codeindex.db` starts a read-only stdio Language Server Protocol shim for LSP-native editors. |
| Search surfaces | CLI-first output for humans and machines; full-text, reusable search audit recipes, symbol, reference, caller/callee, dependency, map, inspect, and excerpt commands. Search recipes can also emit issue-draft JSON with labels, evidence paths, and duplicate preflight. `search`, `definition`, `references`, `callers`, `callees`, `find`, and `validate` support `--format count|compact|csv|tsv|lsp|qf|sarif` for token-budgeted agents, scripts, editors, and CI reports. `cdidx lsp --db .cdidx/codeindex.db` starts a read-only stdio Language Server Protocol shim for LSP-native editors. |
| Validation diagnostics | `validate --json` and MCP `validate` annotate `replacement_char` rows with `origin` (`source_literal` or `decode_replacement`) and `severity` so agents can separate intentional U+FFFD literals from likely encoding damage. |
| Definition and impact diagnostics | `definition --json` includes C# `disambiguator` hints for overloads, partial types, and extension receivers when indexed metadata can distinguish them. `impact --json` and MCP `impact_analysis` include `impact_failure_chain` and `suggestion_type` for zero-result routing; `impact --strict` exits non-zero when resolution or graph preconditions are unmet. |
| Ranking and filters | Public/exported symbol matches rank ahead of protected, internal, and private matches. Use `--no-visibility-rank` for legacy order, and `--visibility` / `--exclude-visibility` with `symbols`, `definition`, `unused`, and `hotspots`. Query defaults can be adjusted with `CDIDX_DEFAULT_LIMIT`, `CDIDX_DEFAULT_SNIPPET_LINES`, and `CDIDX_DEFAULT_MAX_LINE_WIDTH`; explicit CLI flags still win. |
Expand Down Expand Up @@ -362,11 +370,19 @@ cdidx search "handleRequest"
cdidx definition UserService
cdidx search "Handle" --project MyApp
cdidx search "File.ReadAllText" --exact-substring --reject-before "Length" --guard-window 8
cdidx search --list-recipes
cdidx search --recipe risky-code --json
cdidx search --recipe risky-code --format issue-drafts --open-issues open-issues.json
cdidx validate
cdidx mcp
cdidx lsp --db .cdidx/codeindex.db
```

recipe run が対応する形式は text、`--json` / `--format json`、
`--format issue-drafts` です。`--list-recipes` は text または JSON に対応します。
その他の search export format と `--json=array` は、recipe output が query または
list metadata ごとに grouped されるため usage error で拒否します。

カスタム言語の開発ループは out-of-tree で回せます。拡張子 alias は
`.cdidx-langmap.yaml`、regex シンボルパターンは `.cdidx/patterns/*.yaml` に置き、
`cdidx test-extractor --language <lang> --file <path> --json` で full index を作らずに
Expand Down Expand Up @@ -446,7 +462,7 @@ upgrade / downgrade 後はインストール済み補完 script を再生成し

| 分野 | 内容 |
|---|---|
| 検索面 | CLI-first の人間向け / 機械処理向け出力。全文検索、シンボル、参照、caller/callee、依存関係、map、inspect、excerpt コマンドを提供します。`search`、`definition`、`references`、`callers`、`callees`、`find`、`validate` は `--format count|compact|csv|tsv|lsp|qf|sarif` をサポートし、token-budgeted agent、script、editor、CI report でも使いやすい出力にできます。`cdidx lsp --db .cdidx/codeindex.db` は LSP-native editor 向けの read-only stdio Language Server Protocol shim を起動します。 |
| 検索面 | CLI-first の人間向け / 機械処理向け出力。全文検索、再利用可能な search audit recipe、シンボル、参照、caller/callee、依存関係、map、inspect、excerpt コマンドを提供します。Search recipe は label、evidence path、duplicate preflight 付きの issue-draft JSON も出力できます。`search`、`definition`、`references`、`callers`、`callees`、`find`、`validate` は `--format count|compact|csv|tsv|lsp|qf|sarif` をサポートし、token-budgeted agent、script、editor、CI report でも使いやすい出力にできます。`cdidx lsp --db .cdidx/codeindex.db` は LSP-native editor 向けの read-only stdio Language Server Protocol shim を起動します。 |
| validation 診断 | `validate --json` と MCP `validate` は `replacement_char` 行に `origin` (`source_literal` / `decode_replacement`) と `severity` を付け、意図的な U+FFFD literal とエンコーディング破損の可能性を agent が分離できるようにします。 |
| definition / impact 診断 | `definition --json` は C# overload、partial type、extension receiver を区別できる場合に `disambiguator` を返します。`impact --json` と MCP `impact_analysis` は 0 件時の経路判断用に `impact_failure_chain` と `suggestion_type` を返し、`impact --strict` は解決または graph の前提条件が満たされない場合に非 0 で終了します。 |
| 順位と filter | public/exported なシンボル一致を protected、internal、private より優先します。従来順は `--no-visibility-rank`、可視性の include / exclude は `symbols`、`definition`、`unused`、`hotspots` の `--visibility` / `--exclude-visibility` で指定できます。query 既定値は `CDIDX_DEFAULT_LIMIT`、`CDIDX_DEFAULT_SNIPPET_LINES`、`CDIDX_DEFAULT_MAX_LINE_WIDTH` で調整でき、明示 CLI flag が常に優先されます。 |
Expand Down
48 changes: 48 additions & 0 deletions USER_GUIDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -847,6 +847,9 @@ cdidx search "Run();" --exact-substring # case-sensitive exact s
cdidx search "Foo.Bar" --lang csharp --exact-substring # Java/Kotlin/C# exact search/find canonicalizes escaped source identifiers
cdidx search "File.ReadAllText" --exact-substring --reject-before "Length" --guard-window 8 # API calls missing a nearby preceding guard
cdidx search "FileMode.Create" --exact-substring --require-after "File.Move" --guard-window 12 # require a nearby follow-up action
cdidx search --list-recipes # show reusable audit recipes
cdidx search --recipe risky-code --json # run a curated audit query set and return grouped JSON
cdidx search --recipe risky-code --format issue-drafts --open-issues open-issues.json # issue draft JSON with duplicate preflight
cdidx search "--open-reports" --path README.md --count # quoted literal that starts with --
cdidx search --query "--path" --path README.md # search for an option-looking literal
```
Expand All @@ -868,6 +871,24 @@ The MCP `search` tool exposes the same mode as camelCase arguments:
`requireBefore`, `requireAfter`, `rejectBefore`, `rejectAfter`, and
`guardWindow`.

Search audit recipes expand one named recipe into multiple curated search
queries. `--list-recipes` reports the available names, descriptions,
recommended labels, query text, exact-match mode, and false-positive guidance.
`--recipe <name>` applies normal search filters such as `--lang`, `--path`,
`--exclude-path`, `--exclude-tests`, `--limit`, and snippet controls to every
query in the recipe. With `--json`, recipe runs emit one aggregate JSON payload
grouped by recipe query instead of the usual newline-delimited search stream.
Recipe runs support text output, `--json` / `--format json`, and
`--format issue-drafts`; `--list-recipes` supports text or JSON. Other search
export formats and `--json=array` are rejected for recipe modes because recipe
output is grouped by query or list metadata.
For triage automation, `--format issue-drafts` emits draft issue objects with
titles, labels, evidence paths, Markdown bodies, and duplicate-preflight
metadata. `--open-issues <path>` accepts an open-issue JSON list such as
`gh issue list --state open --json number,title,labels,url`; when omitted,
the payload still includes `duplicate_preflight.checked: false`. Draft bodies
include evidence paths and recipe metadata but not source snippets.

### Debugging queries

Add `--verbose` to any query command (`search`, `definition`, `references`, `callers`, `callees`, `symbols`, `files`, `find`, `excerpt`, `map`, `inspect`, `outline`, `status`, `validate`, `deps`, `impact`, `unused`, or `hotspots`) to print query diagnostics to stderr without changing normal stdout:
Expand Down Expand Up @@ -1184,6 +1205,9 @@ same source location.
| `--exclude-visibility <v[,v]>` | `definition`, `symbols`, `unused`, `hotspots` | Exclude symbols with the requested visibility values. Accepts the same comma-separated values and alias expansion as `--visibility`. |
| `--path <glob>` | `search`, `definition`, `references`, `callers`, `callees`, `symbols`, `files`, `find`, `map`, `inspect`, `validate` | Restrict results to glob-style path patterns. `*` and `?` are wildcards. Repeatable; multiple values are OR'd together |
| `--query <query>` | `search`, `definition`, `references`, `callers`, `callees`, `symbols`, `files`, `find`, `inspect`, `impact` | Pass a query literal explicitly, useful when the query starts with `-`. Query commands except `find` also accept `-- <query>` as a one-token query escape while continuing to parse later options. |
| `--recipe <name>` | `search` | Run a reusable audit recipe such as `risky-code`. Normal search filters and snippet controls apply to every recipe query; text, `--json` / `--format json`, and `--format issue-drafts` are supported. |
| `--list-recipes` | `search` | List available search audit recipes with query text, recommended labels, exact-match mode, and false-positive guidance. |
| `--open-issues <path>` | `search --recipe <name> --format issue-drafts` | Preflight generated issue drafts against an open-issues JSON file such as `gh issue list --state open --json number,title,labels,url`. |
| `--exclude-path <glob>` | `search`, `definition`, `references`, `callers`, `callees`, `symbols`, `files`, `find`, `map`, `inspect` | Exclude glob-style path patterns. `*` and `?` are wildcards (repeatable) |
| `--exclude-tests` | `search`, `definition`, `references`, `callers`, `callees`, `symbols`, `files`, `find`, `map`, `inspect` | Exclude likely test files and prefer production code |
| `--include-generated` | `search`, `definition`, `references`, `callers`, `callees`, `symbols`, `files`, `find`, `map`, `inspect`, `deps`, `impact`, `unused`, `hotspots` | Include files detected as generated code; generated files are excluded from query results by default |
Expand Down Expand Up @@ -3061,6 +3085,9 @@ cdidx search "Run();" --exact-substring # 大文字小文字区
cdidx search "Foo.Bar" --lang csharp --exact-substring # Java/Kotlin/C# の exact 検索 / find は escaped source identifier を正規化する
cdidx search "File.ReadAllText" --exact-substring --reject-before "Length" --guard-window 8 # 直前の guard がない API 呼び出し
cdidx search "FileMode.Create" --exact-substring --require-after "File.Move" --guard-window 12 # 近傍の後続処理を要求
cdidx search --list-recipes # 再利用可能な audit recipe を表示
cdidx search --recipe risky-code --json # curated audit query set を実行し、grouped JSON を返す
cdidx search --recipe risky-code --format issue-drafts --open-issues open-issues.json # duplicate preflight 付き issue draft JSON
cdidx search "--open-reports" --path README.md --count # `--` で始まる引用済みリテラル
cdidx search --query "--path" --path README.md # オプションに見えるリテラルを検索
```
Expand All @@ -3079,6 +3106,24 @@ query text、`--lang`、`--path`、`--exclude-tests` で絞り込むか、MCP cu
MCP `search` tool では同じ mode を camelCase 引数 `requireBefore`, `requireAfter`,
`rejectBefore`, `rejectAfter`, `guardWindow` で指定できます。

search audit recipe は、名前付き recipe を複数の curated search query に展開します。
`--list-recipes` は利用可能な名前、説明、推奨 label、query text、exact-match mode、
false-positive guidance を表示します。`--recipe <name>` は `--lang`、`--path`、
`--exclude-path`、`--exclude-tests`、`--limit`、snippet control など通常の search filter
を recipe 内の各 query に適用します。`--json` 併用時、recipe run は通常の
newline-delimited search stream ではなく、recipe query ごとに grouped された 1 つの
aggregate JSON payload を出力します。
recipe run が対応する形式は text output、`--json` / `--format json`、
`--format issue-drafts` です。`--list-recipes` は text または JSON に対応します。
その他の search export format と `--json=array` は、recipe output が query または
list metadata ごとに grouped されるため usage error で拒否します。
triage automation では `--format issue-drafts` を使うと、title、label、evidence path、
Markdown body、duplicate-preflight metadata を持つ issue draft object を出力します。
`--open-issues <path>` は `gh issue list --state open --json number,title,labels,url`
のような open issue JSON list を受け取り、未指定の場合も payload には
`duplicate_preflight.checked: false` が含まれます。draft body は evidence path と
recipe metadata を含みますが、source snippet は含めません。

### クエリのデバッグ

任意の query command(`search`、`definition`、`references`、`callers`、`callees`、`symbols`、`files`、`find`、`excerpt`、`map`、`inspect`、`outline`、`status`、`validate`、`deps`、`impact`、`unused`、`hotspots`)に `--verbose` を付けると、通常の stdout を変えずに query 診断を stderr へ出力します:
Expand Down Expand Up @@ -3391,6 +3436,9 @@ raw match density を正確に測る、といった理由で全 raw chunk hit
| `--exclude-visibility <v[,v]>` | `definition`, `symbols`, `unused`, `hotspots` | 指定した可視性のシンボルを除外する。値と alias 展開は `--visibility` と同じ |
| `--path <glob>` | `search`, `definition`, `references`, `callers`, `callees`, `symbols`, `files`, `find`, `map`, `inspect`, `validate` | glob 形式のパスパターンで結果を絞る。`*` と `?` がワイルドカード。繰り返し指定可(複数値は OR で結合) |
| `--query <query>` | `search`, `definition`, `references`, `callers`, `callees`, `symbols`, `files`, `find`, `inspect`, `impact` | クエリを明示的なリテラルとして渡す。クエリが `-` で始まる場合に有用。`find` 以外のクエリ系コマンドでは `-- <query>` も1トークンのクエリエスケープとして受け付け、その後のオプション解析を続ける。 |
| `--recipe <name>` | `search` | `risky-code` などの再利用可能な audit recipe を実行する。通常の search filter と snippet control は recipe 内の各 query に適用され、text、`--json` / `--format json`、`--format issue-drafts` に対応する。 |
| `--list-recipes` | `search` | 利用可能な search audit recipe を query text、推奨 label、exact-match mode、false-positive guidance 付きで一覧表示する。 |
| `--open-issues <path>` | `search --recipe <name> --format issue-drafts` | `gh issue list --state open --json number,title,labels,url` のような open issue JSON file と照合し、生成した issue draft を事前重複確認する。 |
| `--exclude-path <glob>` | `search`, `definition`, `references`, `callers`, `callees`, `symbols`, `files`, `find`, `map`, `inspect` | glob 形式のパスパターンを除外する。`*` と `?` がワイルドカード。繰り返し指定可 |
| `--exclude-tests` | `search`, `definition`, `references`, `callers`, `callees`, `symbols`, `files`, `find`, `map`, `inspect` | テストらしいパスを除外し、本番コードを優先 |
| `--include-generated` | `search`, `definition`, `references`, `callers`, `callees`, `symbols`, `files`, `find`, `map`, `inspect`, `deps`, `impact`, `unused`, `hotspots` | 生成コードとして検出されたファイルを含める。生成ファイルは既定でクエリ結果から除外される |
Expand Down
22 changes: 22 additions & 0 deletions changelog.d/unreleased/3144.added.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
---
category: added
issues:
- 3144
affected:
- README.md
- USER_GUIDE.md
- src/CodeIndex/Cli/CliFlagSchema.cs
- src/CodeIndex/Cli/ConsoleUi.cs
- src/CodeIndex/Cli/JsonOutputContracts.cs
- src/CodeIndex/Cli/QueryCommandRunner.cs
- src/CodeIndex/Cli/SearchAuditRecipes.cs
- tests/CodeIndex.Tests/QueryCommandRunnerSearchTests.cs
---

## English

- **Search can now run reusable audit recipes (#3144)** — `cdidx search --list-recipes` exposes built-in risky-code audit searches with descriptions, labels, and false-positive guidance, while `cdidx search --recipe risky-code --json` emits grouped results using the normal search filters.

## 日本語

- **search が再利用可能な audit recipe を実行できるようになりました (#3144)** — `cdidx search --list-recipes` は built-in の risky-code audit search を説明、label、false-positive guidance 付きで表示し、`cdidx search --recipe risky-code --json` は通常の search filter を使って grouped result を出力します。
25 changes: 25 additions & 0 deletions changelog.d/unreleased/3145.added.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
---
category: added
issues:
- 3145
affected:
- README.md
- USER_GUIDE.md
- src/CodeIndex/Cli/CliFlagSchema.cs
- src/CodeIndex/Cli/ConsoleUi.cs
- src/CodeIndex/Cli/IssueDuplicatePreflight.cs
- src/CodeIndex/Cli/JsonOutputContracts.cs
- src/CodeIndex/Cli/QueryCommandRunner.cs
- src/CodeIndex/Cli/SearchAuditRecipes.cs
- src/CodeIndex/Cli/SuggestionsCommandRunner.cs
- tests/CodeIndex.Tests/ConsoleUiTests.cs
- tests/CodeIndex.Tests/QueryCommandRunnerSearchTests.cs
---

## English

- **Search audit recipes can now export issue drafts (#3145)** — `cdidx search --recipe risky-code --format issue-drafts` emits draft issue objects with titles, labels, evidence paths, source-free bodies, and optional duplicate preflight from `--open-issues`.

## 日本語

- **search audit recipe が issue draft export に対応しました (#3145)** — `cdidx search --recipe risky-code --format issue-drafts` は title、label、evidence path、source snippet を含まない body、任意の `--open-issues` duplicate preflight を持つ issue draft object を出力します。
Loading
Loading