Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -903,7 +903,7 @@ jobs:

cat > "$tap_dir/Formula/codeindex.rb" <<EOF
class Codeindex < Formula
desc "CLI code indexing and MCP search for local repositories"
desc "CLI code indexing, MCP search, and LSP lookup for local repositories"
homepage "${REPO_URL}"
version "${VERSION}"
license "FSL-1.1-ALv2"
Expand Down
23 changes: 13 additions & 10 deletions INTEGRATION_POLICY.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ Allowed integrations include:
- AI coding agents invoking `cdidx` through CLI commands;
- AI coding agents invoking `cdidx mcp`;
- IDE/editor extensions that discover or call a user-installed `cdidx`;
- IDE/editor extensions that launch `cdidx lsp`;
- IDE/editor extensions that provide configuration UI for official CodeIndex;
- shell scripts, task runners, and CI jobs that run `cdidx`;
- MCP client configuration files;
Expand All @@ -35,30 +36,32 @@ access:

- your source code remains yours;
- your index files remain yours;
- search results, snippets, structured JSON, and MCP responses generated from
your own codebases remain yours;
- search results, snippets, structured JSON, MCP responses, and LSP responses
generated from your own codebases remain yours;
- CodeIndex does not claim ownership over your repositories or generated
development context.

## API Surface and Library Use

CodeIndex ships primarily as a **CLI and MCP server**. It does not publish a
general-purpose library or SDK API for embedders.
CodeIndex ships primarily as a **CLI, MCP server, and LSP shim**. It does not
publish a general-purpose library or SDK API for embedders.

- The stable, supported surfaces are the `cdidx` CLI (including its `--json`
output) and the `cdidx mcp` JSON-RPC interface. Versioning guarantees only
apply to those surfaces.
output), the `cdidx mcp` JSON-RPC interface, and the `cdidx lsp` stdio
Language Server Protocol interface. Versioning guarantees only apply to
those surfaces.
- The `cdidx` NuGet package is published with `PackAsTool=true` and is intended
to be installed as a .NET global tool, not added as an assembly reference.
- Types that happen to be `public` on the `cdidx` assembly (for example DTOs in
`CodeIndex.Database` / `CodeIndex.Models`, or readers such as
`CodeIndex.Database.DbReader`) exist to satisfy CLI and MCP composition. They
are **implementation details**, not a public library contract, and may
`CodeIndex.Database.DbReader`) exist to satisfy CLI, MCP, and LSP
composition. They are **implementation details**, not a public library
contract, and may
change, move, or become `internal` in any release without a deprecation
cycle.
- Projects that need a programmatic interface should depend on the CLI's
`--json` output or on the MCP server, both of which are covered by the
changelog and the documented status contract.
`--json` output, the MCP server, or the LSP shim, each of which is covered by
the changelog and documented integration contract.
- The extractor plugin interfaces under `CodeIndex.Indexer.Extensibility` are
a narrow exception for language-extension DLLs loaded by `cdidx` itself from
`.cdidx/plugins` or `~/.cdidx/plugins`. They are not a general embedding API.
Expand Down
30 changes: 16 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@
![License](https://img.shields.io/badge/License-FSL--1.1--ALv2-orange)
![SQLite](https://img.shields.io/badge/SQLite-FTS5-003B57?logo=sqlite&logoColor=white)

**CLI code indexing and MCP search for local repositories.**
**CLI code indexing, MCP search, and LSP editor lookup for local repositories.**

`cdidx` is a command-line code indexer and MCP server that builds a local
SQLite index of your repository so humans and AI agents can run fast
full-text, symbol, dependency, and inspection queries without repeatedly
rescanning the same tree.
`cdidx` is a command-line code indexer, MCP server, and read-only LSP shim that
builds a local SQLite index of your repository so humans, AI agents, and
LSP-native editors can run fast full-text, symbol, dependency, and inspection
queries without repeatedly rescanning the same tree.

## Why cdidx

Expand Down Expand Up @@ -56,6 +56,7 @@ cdidx definition UserService
cdidx search "Handle" --project MyApp
cdidx validate
cdidx mcp
cdidx lsp --db .cdidx/codeindex.db
```

Custom language loops can stay out of tree: put extension aliases in
Expand Down Expand Up @@ -136,11 +137,11 @@ 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. |
| 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. |
| 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. |
| Project scoping | `.sln` / `.csproj`-aware <code>--project &lt;name&#124;path&gt;</code> filters for indexing and queries, plus `--solution <path>` when a workspace has multiple solution files. |
| MCP integration | MCP server support for AI clients such as Claude Code, Cursor, and Windsurf, including tools, indexed-file resources, starter prompts, schema constraints for local argument validation, `mimeType` on text content blocks, logging, a structured `ping` health result, HTTP `GET /healthz`, opt-in HTTP `/events` keep-alive notifications, a compatibility server-side `notifications/initialized` ready signal on stdio or HTTP `/events` streams, and `Language support:` descriptions sourced from the same registries as `cdidx languages`. Tool schemas reject unknown arguments with `-32602`, advertise `x-stability`, and use snake_case structured JSON keys to match the CLI JSON contract. |
| MCP/LSP integration | MCP server support for AI clients such as Claude Code, Cursor, and Windsurf, including tools, indexed-file resources, starter prompts, schema constraints for local argument validation, `mimeType` on text content blocks, logging, a structured `ping` health result, HTTP `GET /healthz`, opt-in HTTP `/events` keep-alive notifications, a compatibility server-side `notifications/initialized` ready signal on stdio or HTTP `/events` streams, and `Language support:` descriptions sourced from the same registries as `cdidx languages`. Tool schemas reject unknown arguments with `-32602`, advertise `x-stability`, and use snake_case structured JSON keys to match the CLI JSON contract. LSP mode exposes `initialize`, `workspace/symbol`, `textDocument/documentSymbol`, `textDocument/definition`, and `textDocument/references` over stdio for editors that do not speak MCP. |
| Freshness | Parallel full-scan extraction with `--parallelism`, incremental refreshes with `--files` and `--commits`, continuous `--watch`, exact `status --check`, and configurable stale thresholds via `--stale-after` / `CDIDX_STALE_AFTER`. |
| Storage | Local-first `.cdidx/codeindex.db` storage. Query commands run from nested directories prefer the outermost ancestor `.cdidx/codeindex.db` before falling back to the current directory. `--data-dir <dir>`, `CDIDX_DATA_DIR`, or `XDG_DATA_HOME` can move default SQLite storage outside the workspace; explicit `--db <path>` still wins. |
| DB maintenance | New indexes use SQLite incremental auto-vacuum. `cdidx vacuum` reclaims free pages from existing DBs, including a one-time full `VACUUM` conversion for legacy no-autovacuum DBs, and `status --json` reports metrics under `db_pragma_settings`. |
Expand Down Expand Up @@ -275,12 +276,12 @@ details.
![License](https://img.shields.io/badge/License-FSL--1.1--ALv2-orange)
![SQLite](https://img.shields.io/badge/SQLite-FTS5-003B57?logo=sqlite&logoColor=white)

**ローカルリポジトリ向けの CLI コードインデックスと MCP 検索です。**
**ローカルリポジトリ向けの CLI コードインデックス、MCP 検索、LSP editor lookup です。**

`cdidx` はコマンドラインのコードインデクサー兼 MCP サーバーで、リポジトリの
ローカル SQLite index を作成します。人間と AI エージェントは、同じツリーを
何度も読み直さずに、高速な全文検索、シンボル、依存関係、inspect クエリを
実行できます
`cdidx` はコマンドラインのコードインデクサー、MCP サーバー、read-only LSP shim で、
リポジトリのローカル SQLite index を作成します。人間、AI エージェント、
LSP-native editor は、同じツリーを何度も読み直さずに、高速な全文検索、
シンボル、依存関係、inspect クエリを実行できます

## なぜ cdidx なのか

Expand Down Expand Up @@ -319,6 +320,7 @@ cdidx definition UserService
cdidx search "Handle" --project MyApp
cdidx validate
cdidx mcp
cdidx lsp --db .cdidx/codeindex.db
```

カスタム言語の開発ループは out-of-tree で回せます。拡張子 alias は
Expand Down Expand Up @@ -386,11 +388,11 @@ upgrade / downgrade 後はインストール済み補完 script を再生成し

| 分野 | 内容 |
|---|---|
| 検索面 | CLI-first の人間向け / 機械処理向け出力。全文検索、シンボル、参照、caller/callee、依存関係、map、inspect、excerpt コマンドを提供します。 |
| 検索面 | CLI-first の人間向け / 機械処理向け出力。全文検索、シンボル、参照、caller/callee、依存関係、map、inspect、excerpt コマンドを提供します。`cdidx lsp --db .cdidx/codeindex.db` は LSP-native editor 向けの read-only stdio Language Server Protocol shim を起動します。 |
| 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 が常に優先されます。 |
| project scope | `.sln` / `.csproj` を使った <code>--project &lt;name&#124;path&gt;</code> filter で index と query を .NET project 配下へ絞り込めます。workspace に solution が複数ある場合は `--solution <path>` を指定します。 |
| MCP 連携 | Claude Code、Cursor、Windsurf などの AI クライアント向け MCP server。tools、インデックス済みファイル resources、starter prompts、ローカル引数検証用の schema constraints、text content block の `mimeType`、logging、構造化された `ping` health result、HTTP `GET /healthz`、opt-in の HTTP `/events` keep-alive notification、stdio または HTTP `/events` stream 上の互換性用 server-side `notifications/initialized` ready signal、`cdidx languages` と同じ言語レジストリ由来の `Language support:` 説明を提供します。Tool schema は未知の引数を `-32602` で拒否し、`x-stability` を公開し、CLI JSON contract と一致する snake_case の structured JSON key を使います。 |
| MCP/LSP 連携 | Claude Code、Cursor、Windsurf などの AI クライアント向け MCP server。tools、インデックス済みファイル resources、starter prompts、ローカル引数検証用の schema constraints、text content block の `mimeType`、logging、構造化された `ping` health result、HTTP `GET /healthz`、opt-in の HTTP `/events` keep-alive notification、stdio または HTTP `/events` stream 上の互換性用 server-side `notifications/initialized` ready signal、`cdidx languages` と同じ言語レジストリ由来の `Language support:` 説明を提供します。Tool schema は未知の引数を `-32602` で拒否し、`x-stability` を公開し、CLI JSON contract と一致する snake_case の structured JSON key を使います。LSP mode は MCP 非対応 editor 向けに `initialize`、`workspace/symbol`、`textDocument/documentSymbol`、`textDocument/definition`、`textDocument/references` を stdio で公開します。 |
| freshness | `--parallelism` による parallel full-scan、`--files` / `--commits` による差分更新、`--watch` による継続更新、`status --check` による完全一致確認、`--stale-after` / `CDIDX_STALE_AFTER` による age threshold 上書きに対応します。 |
| storage | `.cdidx/codeindex.db` に保存する local-first 設計。ネストしたディレクトリからの query コマンドは、current directory にフォールバックする前に最上位祖先の `.cdidx/codeindex.db` を優先します。既定の SQLite 保存先は `--data-dir <dir>`、`CDIDX_DATA_DIR`、`XDG_DATA_HOME` で workspace 外へ移せます。明示的な `--db <path>` は引き続き最優先です。 |
| DB maintenance | 新規 index DB は SQLite incremental auto-vacuum を使います。成功した writer 実行は WAL を `TRUNCATE` checkpoint します。既存 DB は `cdidx vacuum` で free page を回収でき、legacy no-autovacuum DB は初回だけ full `VACUUM` で変換します。`cdidx db schema` は on-disk schema を出力し、`cdidx db prune --dry-run|--apply` は orphaned DB rows を検査・削除します。`status --json` は `db_pragma_settings` 配下に metrics を出力します。 |
Expand Down
18 changes: 18 additions & 0 deletions USER_GUIDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ cdidx find "guard" --path src/Auth.cs
cdidx deps --path src/ # File-level dependency graph
cdidx suggestions list # Review local AI feedback history
cdidx mcp # Start MCP server for AI tools
cdidx lsp --db .cdidx/codeindex.db # Start read-only LSP server for editors
```

78 languages supported. 24 registered MCP tools. Incremental updates. Zero config.
Expand Down Expand Up @@ -1734,6 +1735,14 @@ If the refs are not known, use `cdidx ./myproject --json` and verify with `cdidx

cdidx includes a built-in **MCP (Model Context Protocol) server**. MCP is a standard protocol that lets AI coding tools communicate with external programs. When you run `cdidx mcp`, cdidx starts listening on stdin/stdout — your AI tool sends search requests as JSON, and cdidx returns results instantly from the pre-built index.

### LSP Server (for LSP-native editors)

`cdidx lsp --db .cdidx/codeindex.db` starts a read-only Language Server Protocol
server over stdio. It reuses the existing CodeIndex database and exposes
`initialize`, `workspace/symbol`, `textDocument/documentSymbol`,
`textDocument/definition`, and `textDocument/references` for editors that can
launch an arbitrary LSP command but do not speak MCP.

Tool results include structured JSON in `structuredContent` plus a short text summary in `content`, so AI tools can parse typed data without scraping large text blocks.

Capped MCP result tools report `truncated` and `more_available` in `structuredContent` when more rows exist than the requested `limit`, so clients can avoid treating a capped page as exhaustive.
Expand Down Expand Up @@ -2071,6 +2080,7 @@ cdidx find "guard" --path src/Auth.cs
cdidx deps --path src/ # ファイル間依存グラフ
cdidx suggestions list # ローカルのAIフィードバック履歴を確認
cdidx mcp # AIツール向けMCPサーバー起動
cdidx lsp --db .cdidx/codeindex.db # editor向けread-only LSPサーバー起動
```

78言語対応。24 MCPツール。インクリメンタル更新。設定不要。
Expand Down Expand Up @@ -3767,6 +3777,14 @@ ref が分からない場合は `cdidx ./myproject --json` を使い、`cdidx st

cdidxには**MCP(Model Context Protocol)サーバー**が組み込まれています。MCPは、AIコーディングツールが外部プログラムと通信するための標準プロトコルです。`cdidx mcp` を実行すると、cdidxがstdin/stdoutで待機し、AIツールからの検索リクエストをJSONで受け取り、構築済みインデックスから即座に結果を返します。

### LSP サーバー(LSP-native editor 向け)

`cdidx lsp --db .cdidx/codeindex.db` は read-only の Language Server Protocol
サーバーを stdio で起動します。既存の CodeIndex database を再利用し、
任意の LSP command を起動できるが MCP には対応していない editor 向けに
`initialize`、`workspace/symbol`、`textDocument/documentSymbol`、
`textDocument/definition`、`textDocument/references` を公開します。

ツール結果は `structuredContent` に構造化JSON、`content` に短い要約テキストを返すため、AIツールは巨大なテキストをパースせずに型付きデータを扱えます。

上限付きの MCP result tool は、要求した `limit` より多くの行がある場合に `structuredContent` へ `truncated` と `more_available` を返します。これにより、クライアントは上限で切られたページを網羅的な結果として扱わずに済みます。
Expand Down
24 changes: 24 additions & 0 deletions changelog.d/unreleased/1650.added.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
---
category: added
issues:
- 1650
affected:
- src/CodeIndex/Cli/ProgramRunner.cs
- src/CodeIndex/Cli/ConsoleUi.cs
- src/CodeIndex/Lsp/LspServer.cs
- src/CodeIndex/CodeIndex.csproj
- tests/CodeIndex.Tests/LspServerTests.cs
- README.md
- USER_GUIDE.md
- INTEGRATION_POLICY.md
- docs/NUGET_README.md
- .github/workflows/release.yml
---

## English

- **`cdidx lsp` starts a read-only Language Server Protocol shim (#1650)** — LSP-native editors can now launch `cdidx lsp --db .cdidx/codeindex.db` over stdio for workspace symbols, document symbols, definitions, and references without needing an MCP adapter.

## 日本語

- **`cdidx lsp` が read-only の Language Server Protocol shim を起動できるようになりました (#1650)** — LSP-native editor は MCP adapter なしで `cdidx lsp --db .cdidx/codeindex.db` を stdio 起動し、workspace symbol、document symbol、definition、reference を取得できます。
Loading
Loading