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
4 changes: 2 additions & 2 deletions DEVELOPER_GUIDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ Development contracts:
| `cdidx validate` | This is the user-facing integrity scan for indexed content issues such as replacement characters, BOMs, NUL bytes, mixed line endings, UTF-16 BOMs, and likely non-UTF8 content. Keep its CLI usage, README entry, and help summary in sync when adding validation issue kinds or filters. |
| `cdidx doctor` | This is the copy-pasteable environment summary for support requests. Keep it redacted by default: secret-like `CDIDX_*` values must not be printed, and new diagnostic fields should be stable enough for issue triage. Full environment inventory filters (`--env-domain`, `--env-category`, and `--env-sensitivity`) use case-insensitive exact values and compose with AND; filtered JSON summaries describe the returned inventory rather than the global catalog. `--max-json-bytes` is valid with `--json --env-inventory=full` or `--integrations --json`, counts the serialized UTF-8 document plus its newline, and returns a structured usage error rather than an oversized successful document. The `github` block reports `proxy_default_credentials` as `enabled` / `disabled` and the bounded `max_request_timeout_s`; never print proxy credential material or raw secret values. `license --json` returns the versioned `license`, `commercial_use`, `trademark`, and controlling `documents` contract. |
| Exception diagnostics | User-facing CLI, JSON, MCP, file-issue, and local diagnostic output must not echo raw `ex.Message` directly. Route exception prose through `CommandErrorWriter.FormatSanitizedExceptionMessage`, `DiagnosticSanitizer.ForMessage`, or an existing bounded `DiagnosticRedactor` helper, and use stable error codes/categories when the message is not needed for recovery. Intentional broad catches should match the `risky-code/broad-exception-catch` taxonomy and normalize to bounded diagnostics, private best-effort suppression, or a documented fallback. |
| Shell completions | Generated shell completion scripts include a comment with the `cdidx` version that produced them. Completion candidates come from `CliFlagSchema`: `ValueKind` / `CommandValueKinds` select contextual path, project, repository, language, and symbol-kind behavior; `ValueDomain` / `CommandValueDomains` define exhaustive finite choices; `SubcommandValueDomains` narrows choices for a nested verb without widening its parent command; and `SupplementalCompletionValues` preserves real reserved literals for mixed inputs such as path-or-`github`. Command discovery must skip schema-defined leading global options and their separated or inline values before resolving command and nested-command context. Display placeholders such as `<name\|path>` are metavariables and must never be parsed into candidates. When command or flag schema changes, update completion tests and keep the README guidance that installed completions should be regenerated after upgrades. |
| Shell completions | Generated shell completion scripts include a comment with the `cdidx` version that produced them. Completion candidates come from `CliFlagSchema`: `ValueKind` / `CommandValueKinds` select contextual path, project, repository, language, and symbol-kind behavior; `ValueDomain` / `CommandValueDomains` define exhaustive finite choices; `SubcommandValueDomains` narrows choices for a nested verb without widening its parent command; `CompletionSubcommands` restricts a flag to exact nested verbs; `ParentCompletionCommands` retains it for a valid default parent operation; and `SupplementalCompletionValues` preserves real reserved literals for mixed inputs such as path-or-`github`. Command discovery must skip schema-defined leading global options and their separated or inline values before resolving command and nested-command context. Display placeholders such as `<name\|path>` are metavariables and must never be parsed into candidates. Dedicated parser/help inventories and every generated Bash, zsh, fish, and PowerShell context must have bidirectional tests: every public accepted flag is registered and rendered, and no sibling context advertises a rejected flag. When command or flag schema changes, update those completion tests and keep the README guidance that installed completions should be regenerated after upgrades. |
| Target frameworks | The production CLI and NuGet tool packaging target `net8.0`. The test project multi-targets `net8.0;net9.0`, and CI runs the test suite on both frameworks across Linux, Windows, and macOS. Use a .NET SDK that can restore and run both target frameworks when validating the full CI-equivalent test matrix. |
| SDK selection | `global.json` pins the repository SDK to `9.0.301` with `rollForward` disabled. CI installs both `8.0.413` and `9.0.301` explicitly: `8.0.413` provides the `net8.0` runtime lane, while `9.0.301` is the selected SDK for restore, build, test, publish, and changelog validation. When rolling SDKs, update `global.json`, every `actions/setup-dotnet` version list, the Docker build image, and this guide together. |
| GitHub Actions policy | Workflows pin hosted runners to versioned labels (`ubuntu-24.04`, `windows-2022`, `macos-14`), keep the top-level `contents` permission read-only by default, limit `continue-on-error` to failure-path diagnostic artifact upload, give every upload artifact explicit retention, and bound every artifact download by pattern and path. NuGet cache keys use workflow + runner OS + the exact reachable `packages.lock.json` restore graph, explicitly exclude `global.json` and unrelated locks, avoid broad restore-key fallbacks, and keep version-pinned tool caches separate. `PackagesLockTests` owns the exact restore/cache graph contract; `CiWorkflowTests.GitHubActionsWorkflows_FollowRunnerArtifactCacheAndContinueOnErrorPolicy` enforces the general workflow checklist. |
Expand Down Expand Up @@ -4224,7 +4224,7 @@ net9 CI lane に合わせる場合は `FRAMEWORK=net9.0 make test` を使いま
| `cdidx validate` | replacement character、BOM、NUL byte、混在改行、UTF-16 BOM、非 UTF-8 らしい内容など、indexed content の問題を user-facing に検査する integrity scan です。validation issue の種別や filter を追加する場合は、CLI usage、README entry、help summary を同期してください。 |
| `cdidx doctor` | support request 向けにコピーしやすい environment summary です。既定では redacted に保ち、secret 風の `CDIDX_*` 値は出力しないでください。新しい diagnostic field は issue triage に使える程度に安定したものだけにします。full environment inventory の filter(`--env-domain`、`--env-category`、`--env-sensitivity`)は大文字小文字を区別しない完全一致で AND 合成し、filtered JSON summary は global catalog ではなく返却 inventory を表します。`--max-json-bytes` は `--json --env-inventory=full` または `--integrations --json` と組み合わせ、serialize した UTF-8 文書と改行を数え、上限を超える成功文書の代わりに structured usage error を返します。`github` block は `proxy_default_credentials` を `enabled` / `disabled` として出力し、bounded な `max_request_timeout_s` も出します。proxy credential material や raw secret value は出力しないでください。`license --json` は version 付きの `license`、`commercial_use`、`trademark`、controlling `documents` contract を返します。 |
| 例外診断 | user-facing な CLI / JSON / MCP / file issue / local diagnostic output では raw `ex.Message` を直接 echo しないでください。例外の prose は `CommandErrorWriter.FormatSanitizedExceptionMessage`、`DiagnosticSanitizer.ForMessage`、または既存の bounded な `DiagnosticRedactor` helper を通し、回復に message が不要な場合は安定した error code/category を使ってください。意図的に残す broad catch は `risky-code/broad-exception-catch` taxonomy に沿い、bounded diagnostic、private な best-effort suppression、または documented fallback に正規化してください。 |
| shell completion | 生成された shell completion script には、生成元の `cdidx` version comment が含まれます。completion candidate は `CliFlagSchema` を基準にし、`ValueKind` / `CommandValueKinds` が path、project、repository、language、symbol kind の文脈別動作を選び、`ValueDomain` / `CommandValueDomains` は網羅的な有限候補を定義し、`SubcommandValueDomains` は親 command の候補を広げずに nested verb 固有の候補へ絞り込み、`SupplementalCompletionValues` は path または `github` のような混合入力で実在する予約 literal を維持します。command context と nested-command context を解決する前に、schema 定義済みの先頭 global option と、その分離形式または inline 形式の値を読み飛ばしてください。`<name\|path>` のような表示用 placeholder は metavariable であり、候補へ分解してはいけません。command や flag の schema を変えた場合は completion test を更新し、upgrade 後に installed completion を再生成する README guidance も保ってください。 |
| shell completion | 生成された shell completion script には、生成元の `cdidx` version comment が含まれます。completion candidate は `CliFlagSchema` を基準にし、`ValueKind` / `CommandValueKinds` が path、project、repository、language、symbol kind の文脈別動作を選び、`ValueDomain` / `CommandValueDomains` は網羅的な有限候補を定義し、`SubcommandValueDomains` は親 command の候補を広げずに nested verb 固有の候補へ絞り込みます。`CompletionSubcommands` は flag を正確な nested verb に限定し、`ParentCompletionCommands` は有効な既定の親操作でもその flag を維持します。`SupplementalCompletionValues` は path または `github` のような混合入力で実在する予約 literal を維持します。command context と nested-command context を解決する前に、schema 定義済みの先頭 global option と、その分離形式または inline 形式の値を読み飛ばしてください。`<name\|path>` のような表示用 placeholder は metavariable であり、候補へ分解してはいけません。専用 parser / help inventory と生成された Bash、zsh、fish、PowerShell の各 context には双方向 test を置き、公開された受理 flag がすべて登録・生成されること、および sibling context が拒否される flag を提示しないことを検証してください。command や flag の schema を変えた場合はそれらの completion test を更新し、upgrade 後に installed completion を再生成する README guidance も保ってください。 |
| target framework | 製品版 CLI と NuGet tool packaging は `net8.0` を対象にしています。test project は `net8.0;net9.0` の multi-target で、CI は Linux、Windows、macOS の各 lane で両方の framework に対して test suite を実行します。CI 相当の full matrix を検証する場合は、両方の target framework を restore / 実行できる .NET SDK を使ってください。 |
| SDK selection | `global.json` は repository SDK を `9.0.301` に固定し、`rollForward` を無効化します。CI は `8.0.413` と `9.0.301` を明示的に install します。`8.0.413` は `net8.0` runtime lane を提供し、`9.0.301` は restore、build、test、publish、changelog 検証で選択される SDK です。SDK を更新する場合は、`global.json`、すべての `actions/setup-dotnet` version list、Docker build image、この guide を同じ変更で更新してください。 |
| GitHub Actions policy | workflow は hosted runner を version 付き label(`ubuntu-24.04`、`windows-2022`、`macos-14`)に固定し、top-level の `contents` permission は既定で read-only に保ちます。`continue-on-error` は failure path の diagnostic artifact upload に限定し、すべての upload artifact に明示的な retention を付け、artifact download は pattern と path で境界を絞ります。NuGet cache key は workflow + runner OS + 到達可能な `packages.lock.json` の厳密な restore graph を使い、`global.json` と無関係な lock を明示的に除外し、広い restore-key fallback を避け、version 固定 tool cache を分離します。`PackagesLockTests` が厳密な restore/cache graph 契約を所有し、`CiWorkflowTests.GitHubActionsWorkflows_FollowRunnerArtifactCacheAndContinueOnErrorPolicy` が一般的な workflow checklist を強制します。 |
Expand Down
2 changes: 2 additions & 0 deletions TESTING_GUIDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ Use the full suite by default. Use targeted filters only while iterating locally

## Test Stack

- Issue #5194 shell-completion inventory coverage belongs in `CliFlagSchemaTests.cs` and `ConsoleUiTests.cs`. Keep exact contextual inventories for lsp, every workspace verb, config show, diff, import, archive export, and ctags export synchronized with authoritative help and safe parser probes. Preserve positive and negative nested cases, value-taking versus boolean metadata, context-specific short aliases, mutually exclusive diff modes, exact schema-to-renderer sets for Bash/zsh/fish/PowerShell, and the available-shell generated-script execution contract.
- Issue #5187 exact graph-selector coverage belongs in `QueryCommandRunnerIssue5187Tests.cs` and `McpServerIssue5187Tests.cs`. Keep one fixture with unrelated same-name methods, distinct callees, and multiple callers. Round-trip selectors emitted by `inspect` through CLI and MCP references/callers/callees/impact; preserve explicit bare-name ambiguity metadata, exact selected zero behavior after filters, stable invalid/stale/cross-database diagnostics, selector-bound cursor mismatch, structured-field discovery, command help, and all four shell completions.
- Issue #5157 C# primary-constructor property coverage belongs in `SymbolExtractorCSharpTests.cs` and `QueryCommandRunnerSymbolTests.cs`. Keep ordinary class/struct and nested/private attributed multiline parameters absent from property symbols while preserving positional `record`, `record class`, and `record struct` properties, including nullable and generic components. Exercise `symbols`, `definition`, `outline`, public-visibility filtering, and full/incremental indexing parity. When this extractor gate changes, keep `CSharpContractVersion` and the stale-index refresh assertions in `IndexCommandRunnerFullScanTests.cs` synchronized.
- Issue #5156 file-impact projection coverage belongs in `QueryCommandRunnerImpactTests.cs` and `ProjectionFieldRegistryIssue4836Tests.cs`. Reuse one non-empty two-dependent fixture across full JSON, compact identity, both endpoint leaves, every supported `FileDependencyResult` leaf, typed rejection of the ambiguous `file_impacts.path` alias, cursor paging, and UTF-8 byte bounds. Keep the inactive zero-result collection assertion in `JsonEnvelopeWrapperIssue4585Tests.cs` on a real file-impact leaf.
Expand Down Expand Up @@ -1158,6 +1159,7 @@ dotnet test --filter "FullyQualifiedName~GitHelperTests"

## テストスタック

- Issue #5194 の shell completion inventory coverage は `CliFlagSchemaTests.cs` と `ConsoleUiTests.cs` が担当します。lsp、workspace の全 verb、config show、diff、import、archive export、ctags export の正確な context 別 inventory を、authoritative help と安全な parser probe に同期してください。nested context の positive / negative case、value-taking と boolean の metadata、context 固有の short alias、diff の排他的 mode、Bash / zsh / fish / PowerShell における schema-to-renderer の完全一致、および利用可能な shell で生成 script を実行する契約を維持します。
- Issue #5187 の exact graph-selector coverage は `QueryCommandRunnerIssue5187Tests.cs` と `McpServerIssue5187Tests.cs` が担当します。無関係な同名 method、異なる callee、複数 caller を持つ 1 つの fixture を維持してください。`inspect` が出力した selector を CLI / MCP の references、callers、callees、impact へ round-trip し、bare-name ambiguity metadata の明示、filter 適用後も正確な selected zero behavior、安定した invalid / stale / cross-database diagnostic、selector に束縛された cursor mismatch、structured-field discovery、command help、4 種類すべての shell completion を保ちます。
- Issue #5157 の C# primary-constructor property coverage は `SymbolExtractorCSharpTests.cs` と `QueryCommandRunnerSymbolTests.cs` が担当します。通常の class / struct および attribute 付き multiline parameter を持つ nested / private type では property symbol を生成せず、nullable / generic component を含む位置 `record`、`record class`、`record struct` の property は維持してください。`symbols`、`definition`、`outline`、public visibility filter、full / incremental indexing の parity を検証します。この extractor gate を変更するときは、`CSharpContractVersion` と `IndexCommandRunnerFullScanTests.cs` の stale-index refresh assertion も同期してください。
- Issue #5156 の file-impact projection coverage は `QueryCommandRunnerImpactTests.cs` と `ProjectionFieldRegistryIssue4836Tests.cs` が担当します。full JSON、compact row identity、両 endpoint leaf、対応する全 `FileDependencyResult` leaf、曖昧な `file_impacts.path` alias の型付き拒否、cursor paging、UTF-8 byte 上限を、空でない 2 dependent の fixture 1 つで共有してください。`JsonEnvelopeWrapperIssue4585Tests.cs` の inactive な 0 件 collection assertion は、実在する file-impact leaf を指定したまま維持します。
Expand Down
21 changes: 21 additions & 0 deletions changelog.d/unreleased/5194.fixed.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
---
category: fixed
issues:
- 5194
affected:
- src/CodeIndex/Cli/CliCommandMetadata.cs
- src/CodeIndex/Cli/CliFlagSchema.cs
- src/CodeIndex/Cli/ConsoleCompletionRenderer.cs
- tests/CodeIndex.Tests/CliFlagSchemaTests.cs
- tests/CodeIndex.Tests/ConsoleUiTests.cs
- DEVELOPER_GUIDE.md
- TESTING_GUIDE.md
---

## English

- **Generated shell completions now match dedicated parser and help inventories (#5194)** — Bash, zsh, fish, and PowerShell expose the accepted lsp, workspace, config show, diff, import, archive export, and ctags export options only in their valid parent or nested contexts.

## 日本語

- **生成 shell completion が専用 parser と help の inventory に一致するようになりました (#5194)** — Bash、zsh、fish、PowerShell は、lsp、workspace、config show、diff、import、archive export、ctags export で受理される option を、有効な親または nested context にだけ提示します。
2 changes: 1 addition & 1 deletion src/CodeIndex/Cli/CliCommandMetadata.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ internal static class CliCommandMetadata
]);

internal static IReadOnlySet<string> OptionalSubcommandCommands { get; } =
new[] { "recipes", "suggestions" }.ToFrozenSet(StringComparer.Ordinal);
new[] { "recipes", "suggestions", "workspace", "export" }.ToFrozenSet(StringComparer.Ordinal);

// These commands render process-static metadata and must not discover or parse
// project configuration. validate-config owns malformed-config reporting so it
Expand Down
Loading
Loading