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
24 changes: 24 additions & 0 deletions DEVELOPER_GUIDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,12 @@ When an error code is available, the first line is `Error [<code>]: <message>`.

CLI JSON output must be machine-clean: redirected stdout is written as UTF-8 without a BOM, and JSON-mode commands must not emit ANSI escape sequences even when `--color=always` or `CLICOLOR_FORCE=1` would color human output. Keep JSON-safe styling suppression close to shared formatting helpers such as `ConsoleUi.ColorizeKind` so future query output paths inherit the invariant.

`cdidx export ctags --json` follows the same contract: stdout contains only a
single JSON summary or structured error, while the tag file itself remains the
artifact. The summary includes resolved output/database paths, tag/emitted/
skipped counts, filters, and advertised metadata field names so editor
integrations can validate filtered exports without parsing human output.

Interactive terminal controls are allowed only when stdout is not redirected or captured, terminal capability hints are present, and the environment has not opted out. Treat `TERM=dumb`, truthy `CI`, missing Unix terminal hints, `NO_COLOR`, and `CLICOLOR=0` as reasons to suppress ANSI/progress controls unless an explicitly human-facing override is documented for that control.

### C# / .NET integration
Expand All @@ -248,6 +254,13 @@ Query commands that accept path filters (`search`, `definition`, `references`, `

Editor integrations can request standard location shapes directly. `definition`, `references`, `search`, `find`, and `validate` accept `--format <text|json|lsp|qf|sarif>`; `lsp` emits LSP `Location` arrays, `qf` emits Vim quickfix lines, and `sarif` emits SARIF 2.1.0. `goto <symbol>` returns the single unambiguous definition as one LSP `Location`, while `goto --all <symbol>` returns all matching locations.

The `cdidx lsp` server advertises full text document synchronization and keeps
open document text in a bounded in-memory cache only. Position-based providers
must read that live cache before disk so unsaved editor buffers can identify the
requested token, but provider results remain conservative and index-backed:
return empty arrays or null when the database cannot answer safely instead of
inventing language-server analysis.

### Extractor performance contract

Symbol and reference extractors run during `cdidx index`, so language-specific
Expand Down Expand Up @@ -2463,6 +2476,11 @@ CLI JSON output は機械処理向けにきれいでなければなりません
`ConsoleUi.ColorizeKind` など共有 formatter の近くに置き、将来の query output path も同じ
invariant を継承できるようにしてください。

`cdidx export ctags --json` も同じ contract に従います。stdout は単一の JSON summary または
structured error だけを含み、tags file 自体は artifact として残します。summary には解決済みの
output / database path、tag / emitted / skipped counts、filters、metadata field names を含め、
editor integration が human output を parse せず filtered export を検証できるようにします。

interactive terminal control は stdout が redirected / captured されておらず、terminal
capability hint があり、environment が opt out していない場合にだけ許可します。`TERM=dumb`、
truthy `CI`、Unix terminal hint の欠落、`NO_COLOR`、`CLICOLOR=0` は、明示的な human-facing
Expand All @@ -2478,6 +2496,12 @@ path filter を受け付ける query コマンド(`search`, `definition`, `ref

editor integration は標準的な location 形状を直接要求できる。`definition`、`references`、`search`、`find`、`validate` は `--format <text|json|lsp|qf|sarif>` を受け付け、`lsp` は LSP `Location` 配列、`qf` は Vim quickfix 行、`sarif` は SARIF 2.1.0 を出力する。`goto <symbol>` は曖昧でない単一定義を 1 つの LSP `Location` として返し、`goto --all <symbol>` は一致する全 location を返す。

`cdidx lsp` server は full text document synchronization を advertise し、open document text は
上限付きの in-memory cache にだけ保持する。position-based provider は未保存 editor buffer から
request token を特定できるよう disk より先に live cache を読む必要があるが、provider result は
保守的かつ index-backed のままにする。database が安全に答えられない場合は、language-server
analysis を作り上げず、空配列または null を返す。

### 抽出器の性能契約

symbol / reference extractor は `cdidx index` 中に実行されるため、言語別 helper は
Expand Down
40 changes: 38 additions & 2 deletions USER_GUIDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -350,8 +350,19 @@ instead of querying `cdidx` directly:
```bash
cdidx export ctags --output tags
cdidx export ctags --db .cdidx/codeindex.db --output .tags
cdidx export ctags --lang csharp --path src/ --exclude-tests --json
```

`cdidx export ctags` accepts the same language and path filtering style used by
query commands: `--lang <lang>`, repeatable `--path <glob>`, repeatable
`--exclude-path <glob>`, and `--exclude-tests`. The default human mode keeps
writing the tags file and prints the output path. `--json` prints a machine
summary with `output_path`, `db_path`, total candidate `tag_count`,
`emitted_count`, `skipped_count`, `filters`, and `metadata_fields`; filtered
exports satisfy `tag_count == emitted_count + skipped_count`. Tag lines keep
the standard `kind` and `line` fields and may also include indexed metadata such as
`language`, `container_kind`, `container`, and `visibility`.

Use `cdidx export <archive>` to package the current `codeindex.db` with a
manifest, and `cdidx import <archive>` to restore it on another checkout or CI
job:
Expand Down Expand Up @@ -2105,7 +2116,14 @@ server over stdio. It reuses the existing CodeIndex database and exposes
`textDocument/definition`, `textDocument/declaration`,
`textDocument/typeDefinition`, `textDocument/implementation`, and
`textDocument/references` for editors that can launch an arbitrary LSP command
but do not speak MCP.
but do not speak MCP. It also advertises full `textDocument` sync and
conservative `hover`, `completion`, `documentHighlight`, `semanticTokens/full`,
`codeLens`, and `inlayHint` providers backed by indexed symbols and references
where available.
Open buffers sent through `textDocument/didOpen`, `textDocument/didChange`, and
`textDocument/didClose` are kept in a bounded in-memory cache. Position-based
requests read the live buffer first, so unsaved edits can drive token lookup
without writing back to the CodeIndex database.
Incoming `textDocument.uri` values must be strings, must be absolute `file:`
URIs, and are rejected before URI parsing when they exceed 4096 characters,
matching the MCP resource URI limit and keeping error responses bounded. LSP
Expand Down Expand Up @@ -2805,8 +2823,19 @@ Editor が `cdidx` を直接 query するのではなく従来の ctags file を
```bash
cdidx export ctags --output tags
cdidx export ctags --db .cdidx/codeindex.db --output .tags
cdidx export ctags --lang csharp --path src/ --exclude-tests --json
```

`cdidx export ctags` は query command と同じ language / path filter の形を受け付けます。
`--lang <lang>`、繰り返し指定できる `--path <glob>` / `--exclude-path <glob>`、
`--exclude-tests` を使えます。既定の human mode は tags file を書き出し、output path を
表示します。`--json` は `output_path`、`db_path`、総候補数の `tag_count`、
`emitted_count`、`skipped_count`、`filters`、`metadata_fields` を含む機械処理向け
summary を出力します。filter 付き export では
`tag_count == emitted_count + skipped_count` になります。tag line は標準の
`kind` / `line` fields を維持し、indexed metadata として
`language`、`container_kind`、`container`、`visibility` も含めることがあります。

`cdidx export <archive>` は現在の `codeindex.db` と manifest を archive 化します。
別 checkout や CI job では `cdidx import <archive>` で復元できます。

Expand Down Expand Up @@ -4560,7 +4589,14 @@ cdidxには**MCP(Model Context Protocol)サーバー**が組み込まれて
`initialize`、`workspace/symbol`、`textDocument/documentSymbol`、
`textDocument/definition`、`textDocument/declaration`、
`textDocument/typeDefinition`、`textDocument/implementation`、
`textDocument/references` を公開します。
`textDocument/references` を公開します。さらに full `textDocument` sync と、
indexed symbols / references で答えられる範囲に限定した `hover`、`completion`、
`documentHighlight`、`semanticTokens/full`、`codeLens`、`inlayHint` provider を
advertise します。
`textDocument/didOpen`、`textDocument/didChange`、`textDocument/didClose` で送られた
open buffer は上限付きの in-memory cache に保持されます。position-based request は
live buffer を先に読むため、未保存の編集内容でも CodeIndex database に書き戻さず token lookup に
利用できます。
受信した `textDocument.uri` は string かつ absolute `file:` URI である必要があり、
4096 文字を超える場合は URI parse の前に拒否されます。これは MCP resource URI の上限と
揃えており、エラー応答が過大にならないようにします。
Expand Down
18 changes: 18 additions & 0 deletions changelog.d/unreleased/3536.added.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
---
category: added
issues:
- 3536
affected:
- src/CodeIndex/Lsp/LspServer.cs
- tests/CodeIndex.Tests/LspServerTests.cs
- USER_GUIDE.md
- DEVELOPER_GUIDE.md
---

## English

- **LSP now supports live document sync and richer editor providers (#3536)** — `cdidx lsp` now advertises full text document sync plus conservative hover, completion, document highlight, semantic tokens, code lens, and inlay hint providers backed by indexed symbols and references where available.

## 日本語

- **LSP が live document sync と richer editor providers に対応しました (#3536)** — `cdidx lsp` は full text document sync と、indexed symbols / references で答えられる範囲に限定した hover、completion、document highlight、semantic tokens、code lens、inlay hint providers を advertise するようになりました。
20 changes: 20 additions & 0 deletions changelog.d/unreleased/3551.fixed.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
---
category: fixed
issues:
- 3551
affected:
- src/CodeIndex/Cli/ExportImportCommandRunner.cs
- src/CodeIndex/Cli/JsonOutputContracts.cs
- src/CodeIndex/Cli/ConsoleUi.cs
- tests/CodeIndex.Tests/ExportImportCommandRunnerTests.cs
- USER_GUIDE.md
- DEVELOPER_GUIDE.md
---

## English

- **ctags export now reports filtered JSON summaries and richer metadata (#3551)** — `cdidx export ctags` now supports `--json`, `--lang`, repeated `--path` / `--exclude-path`, and `--exclude-tests`, while emitted tags include indexed metadata fields such as language, container, and visibility when available.

## 日本語

- **ctags export が filtered JSON summary と richer metadata を出力できるようになりました (#3551)** — `cdidx export ctags` は `--json`、`--lang`、繰り返し指定できる `--path` / `--exclude-path`、`--exclude-tests` を受け付け、出力 tag には利用可能な場合に language、container、visibility などの indexed metadata fields も含めるようになりました。
2 changes: 1 addition & 1 deletion src/CodeIndex/Cli/ConsoleUi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ private static readonly (string Command, string Usage)[] CommandUsageLines =
("hotspots", "cdidx hotspots [--db <path>] [--json] [--verbose] [--limit <n>|--top <n>] [--kind <kind>] [--visibility <v[,v]>] [--exclude-visibility <v[,v]>] [--lang <lang>] [--path <glob>] [--exclude-path <glob>] [--exclude-tests] [--count] [--group-by <symbol|file|statement>] [--group-by-name]"),
("suggestions", "cdidx suggestions <list|show|export> [id] [--db <path>] [--json] [--status <all|submitted|unsubmitted>] [--language <lang>] [--category <category>] [--since <datetime>] [--agent <name>] [--limit <n>] [--offset <n>] [--format <json|markdown|issue-drafts>] [--open-issues <path|github|github:owner/name>] [--repo <owner/name>]"),
("export", "cdidx export <archive> [--db <path>] [--json]"),
("export", "cdidx export ctags [--output <path>] [--db <path>]"),
("export", "cdidx export ctags [--output <path>] [--db <path>] [--json] [--lang <lang>] [--path <glob>] [--exclude-path <glob>] [--exclude-tests]"),
("import", "cdidx import <archive> [--db <path>] [--prune-paths] [--dry-run|--check] [--json]"),
("languages", "cdidx languages [--db <path>] [--json] [--indexed-only] [--capability <graph|references|symbols|missing-graph|missing-references|missing-symbols|search-only>]"),
("batch", "cdidx batch [--db <path>] # reads JSON string arrays from stdin, one query command per line; max 1,048,576 chars/line and 256 arguments"),
Expand Down
Loading
Loading