Skip to content

Commit cd4b3c1

Browse files
committed
Merge origin/main into issue 1781 1785 1826 fixes
2 parents 3c3bab0 + 3d00add commit cd4b3c1

65 files changed

Lines changed: 2870 additions & 309 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

DEVELOPER_GUIDE.md

Lines changed: 118 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -129,10 +129,109 @@ Query commands that accept path filters (`search`, `definition`, `references`, `
129129

130130
Do not add mutable static caches, shared `StringBuilder` instances, reused `MatchCollection` enumerators, or singleton scanner state to extractor code. If a future extractor needs cross-call memoization, use an explicit thread-safe collection and add a targeted parallel regression test that proves deterministic output under concurrent calls.
131131

132+
### Symbol Kind Taxonomy
133+
134+
`symbols.kind`, `symbols.container_kind`, and `symbol_references.container_kind` use the public symbol kind taxonomy below. New extractors must register new kind values in `SymbolKindCatalog` before writing them so schema checks, writer validation, CLI filters, and downstream JSON consumers stay aligned.
135+
136+
| Kind | Current producers / meaning | Graph behavior |
137+
|---|---|---|
138+
| `accessor` | Accessor declarations when extracted separately from their owning property | Search/filter symbol |
139+
| `annotation` | Annotation declarations or annotation-like language constructs | Metadata/search symbol |
140+
| `async_function` | JavaScript/TypeScript async function declarations | Callable definition; participates in callers/callees through reference rows |
141+
| `async_generator` | JavaScript/TypeScript async generator declarations | Callable definition; participates in callers/callees through reference rows |
142+
| `attribute` | Razor attributes and metadata-like declarations | Context/search symbol; not a call edge by itself |
143+
| `associatedtype` | Swift associated type declarations | Type-like definition target |
144+
| `class` | Class declarations across object-oriented languages | Definition target and container |
145+
| `class_hook` | Python class hook methods such as dunder hooks reclassified from functions | Callable/search symbol |
146+
| `code` | Markdown fenced or structured code blocks | Search/outline symbol |
147+
| `constant` | Constant declarations where the language distinguishes them | Search/filter symbol |
148+
| `delegate` | C# / F# delegate declarations | Callable type definition and container-like target |
149+
| `enum` | Enum declarations | Definition target and container |
150+
| `event` | Event declarations | Search/filter symbol |
151+
| `field` | Field declarations where distinct from properties | Search/filter symbol |
152+
| `file_module` | File-scoped module/package declarations | Namespace-like context symbol |
153+
| `function` | Functions, methods, constructors, delegates, tasks, and callable bindings that do not have a narrower kind | Primary callable definition; participates in callers/callees through reference rows |
154+
| `generator` | JavaScript/TypeScript generator declarations | Callable definition; participates in callers/callees through reference rows |
155+
| `heading` | Markdown headings | Outline symbol |
156+
| `hook` | JavaScript/TypeScript React custom hook bindings | Callable-like search/filter symbol |
157+
| `implements` | Razor `@implements` directives | Context/search symbol |
158+
| `import` | Imports, using directives, aliases, and package includes | Search/filter symbol |
159+
| `interface` | Interface declarations | Definition target and container |
160+
| `lambda` | Named lambda/arrow bindings | Callable definition; participates in callers/callees through reference rows |
161+
| `layout` | Razor layout directives | Context/search symbol |
162+
| `method` | Languages or hooks that explicitly distinguish methods from functions | Callable definition; participates in callers/callees through reference rows |
163+
| `module` | Module declarations | Definition target and container |
164+
| `namespace` | Namespace declarations | Definition target and container |
165+
| `operator` | C# operator overload and conversion operator declarations | Callable definition; participates in callers/callees through reference rows |
166+
| `object` | Object-literal/object container context used by nested extracted symbols | Container context |
167+
| `package` | Package declarations | Namespace-like context symbol |
168+
| `property` | Properties and property-like fields | Definition target; not treated as a call edge by itself |
169+
| `procedure` | Procedure declarations in languages such as Fortran | Callable definition |
170+
| `program` | Program block declarations in languages such as Fortran | Definition target and container |
171+
| `protocol` | Protocol declarations in languages that distinguish protocols from interfaces | Definition target and container |
172+
| `reference` | Secondary extracted symbolic references, such as HTML classes or metadata keys | Search/filter symbol |
173+
| `rule` | CSS/SCSS rule container context used by nested references | Container context |
174+
| `route` | Razor route directives | Context/search symbol |
175+
| `service` | Service declarations in IDL/protobuf-like languages | Definition target and container |
176+
| `specialization` | C++ template specialization declarations | Definition target for specialized type/function forms |
177+
| `struct` | Struct declarations | Definition target and container |
178+
| `submodule` | Fortran submodule declarations | Namespace/module-like definition target |
179+
| `subroutine` | Fortran subroutine declarations | Callable definition |
180+
| `test.method` | Test methods detected by test-aware extraction | Callable definition; participates in callers/callees through reference rows |
181+
| `trait` | Trait declarations in languages that distinguish traits from interfaces | Definition target and container |
182+
| `type` | Type declarations where a narrower class/interface/struct/enum kind is not available | Definition target |
183+
| `typealias` | Type alias declarations | Definition target for alias names |
184+
| `union` | Union declarations | Definition target and container |
185+
| `block data` | Fortran block data declarations | Definition target |
186+
| `variable` | Variable bindings | Search/filter symbol |
187+
188+
`symbol_references.reference_kind` uses this separate reference taxonomy:
189+
190+
| Reference kind | Meaning |
191+
|---|---|
192+
| `annotation` | Annotation usage in languages that distinguish annotations from attributes |
193+
| `attribute` | Metadata/attribute usage |
194+
| `augmentation` | TypeScript declaration/interface merge edge |
195+
| `call` | Function, method, operator, macro, or command call |
196+
| `capture` | Captured callback/delegate relationship used by impact analysis |
197+
| `column_reference` | SQL column reference in a statement-specific context |
198+
| `consumes_hook` | React hook consumption relationship |
199+
| `const_assertion` | TypeScript `as const` assertion edge |
200+
| `const_generic_reference` | Rust const generic argument reference |
201+
| `copy_from` | Dockerfile `COPY --from=<stage>` stage dependency |
202+
| `cte_body_reference` | SQL common table expression body reference |
203+
| `decorator` | Python decorator usage |
204+
| `extends` | Inheritance or type-extension relationship |
205+
| `from` | Dockerfile `FROM <stage>` dependency |
206+
| `friend` | C++ friend declaration relationship |
207+
| `generic_type_argument` | Generic type argument attached to an explicit invocation |
208+
| `implement` | Interface implementation relationship |
209+
| `implicit_implementation` | C# implicit interface implementation relationship |
210+
| `import` | Import/include/reference through a module system |
211+
| `instantiate` | Constructor or object creation |
212+
| `join_condition_reference` | SQL join/merge condition column reference |
213+
| `lifetime_reference` | Rust/C#-style lifetime or lifetime-like type reference |
214+
| `metadata` | Metadata-only reference |
215+
| `reference` | Generic persisted reference row used by fixtures or extractors without a narrower edge kind |
216+
| `razor_event_binding` | Razor event binding relationship |
217+
| `stage` | Build-stage relationship |
218+
| `subscribe` | Event subscription relationship |
219+
| `type_reference` | Type annotation, generic constraint, or other type-position reference |
220+
| `unsubscribe` | Event unsubscription relationship |
221+
| `use` | Generic usage relationship when no narrower reference kind applies |
222+
132223
### Status freshness age threshold
133224

134225
`status --check` keeps the DB/worktree checksum comparison in `IndexFreshnessChecker`, but the user-facing age hint threshold is resolved in `QueryCommandRunner`: CLI `--stale-after <duration>` wins over `CDIDX_STALE_AFTER`, which wins over `.cdidxrc.json`'s `stale_after`, then the 24-hour default. Supported duration suffixes are `m`, `h`, and `d`. JSON output includes `stale_after_seconds` and `index_age_seconds` only for `--check`, so clients can confirm which threshold was applied without inferring it from text.
135226

227+
### Workspace version pinning
228+
229+
On startup, `cdidx` walks up from the current directory looking for `.cdidx-version`. The first non-empty line is treated as the required CLI version for that workspace. A mismatch prints a warning and continues by default; `--strict-version` or `CDIDX_STRICT_VERSION=1` turns the mismatch into exit code `64` (`EX_USAGE`). This check is advisory and does not rewrite the file. Use it to keep teams on the same binary when index contracts or query behavior differ between releases.
230+
231+
### Release freshness and upgrade checks
232+
233+
`cdidx --check-updates` and `cdidx status --check-updates` query the GitHub latest-release endpoint through `UpdateChecker`, using the same 24-hour cache and `CDIDX_DISABLE_UPDATE_CHECK=1` opt-out as the `--version` hint. `cdidx upgrade --check-only` reuses that check. `cdidx upgrade` is intentionally a thin wrapper around the signed release installer: it downloads `install.sh`, verifies the current binary directory is writable, sets `CDIDX_INSTALL_DIR` to that directory, and runs the installer for the latest release.
234+
136235
### Degradation reason codes
137236

138237
Readiness degradation reason codes are centralized in `DegradationReasonCodes`. Add new codes there with human text, a recommended action, and an alternative action before emitting them from readers, CLI, or MCP payloads.
@@ -1033,17 +1132,29 @@ lifecycle breadcrumbs to a per-user daily log. The log path follows
10331132
`XDG_CACHE_HOME/cdidx/logs/`, `XDG_RUNTIME_DIR/cdidx/logs/`, then the
10341133
platform default: `%LOCALAPPDATA%\cdidx\logs\` on Windows,
10351134
`~/Library/Logs/cdidx/` on macOS, or `~/.local/state/cdidx/logs/` on Linux.
1036-
The file name is `stderr-YYYYMMDD.log`, and the logger keeps only the newest
1037-
30 daily files. Repository-local development runs from `src/CodeIndex/bin/...`
1038-
and `tests/.../bin/...` are excluded by default so ordinary build/test cycles
1039-
do not accumulate persistent logs. Set `CDIDX_DISABLE_PERSISTENT_LOG=1` to opt
1040-
out entirely; the toggle accepts `1`, `true`, `yes`, or `on`
1041-
case-insensitively. Use `CDIDX_GLOBAL_TOOL_LOG_DIR` to redirect the log
1042-
directory during testing or packaging.
1135+
Each candidate is probed with a create/write/delete round trip before the
1136+
logger commits to it, so read-only state/cache/runtime mounts fall through to
1137+
the next candidate instead of losing the first log write. The file name is
1138+
`stderr-YYYYMMDD.log`, timestamps inside the file are ISO-8601 UTC
1139+
(`yyyy-MM-ddTHH:mm:ss.fffZ`) using invariant culture, and the logger keeps
1140+
only the newest 30 daily files. Repository-local development runs from
1141+
`src/CodeIndex/bin/...` and `tests/.../bin/...` are excluded by default so
1142+
ordinary build/test cycles do not accumulate persistent logs. Set
1143+
`CDIDX_DISABLE_PERSISTENT_LOG=1` to opt out entirely; the toggle accepts `1`,
1144+
`true`, `yes`, or `on` case-insensitively. Use
1145+
`CDIDX_GLOBAL_TOOL_LOG_DIR` to redirect the log directory during testing or
1146+
packaging.
10431147
Set `CDIDX_FORCE_GLOBAL_TOOL_LOG=1` to force lifecycle logging for local
10441148
package smoke tests or launcher diagnostics even when the executable path looks
10451149
like a development build; `CDIDX_DISABLE_PERSISTENT_LOG` still wins when both
10461150
are set.
1151+
Unhandled exceptions keep stderr concise but write the full exception chain and
1152+
stack trace to the lifecycle log for post-mortem diagnostics. Logged command
1153+
arguments are minimally redacted by default: secret-looking `--flag=value`
1154+
pairs, values following secret-looking flags, URI passwords, and long token-like
1155+
hex/base64 strings are replaced with `<redacted>`. `CDIDX_LOG_REDACT=none`
1156+
preserves raw arguments for controlled local debugging, while
1157+
`CDIDX_LOG_REDACT=full` also replaces path-like arguments with a stable hash.
10471158

10481159
### The moving parts
10491160

INTEGRATION_POLICY.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,28 @@ CLI payload can be substituted for an MCP payload without adaptation. Additive
8282
fields may appear on either surface in minor releases; consumers should ignore
8383
unknown fields and prefer documented fields over positional assumptions.
8484

85+
### JSON and MCP stability contract
86+
87+
CodeIndex follows SemVer for the supported integration surfaces listed above.
88+
Patch releases may fix incorrect values while preserving documented field names
89+
and value types. Minor releases may add fields, tools, tool arguments, examples,
90+
annotations, error `data` members, or enum values when existing consumers can
91+
ignore them safely. Breaking removals, required-field additions, field renames,
92+
or incompatible type changes require a major release unless the old shape was
93+
explicitly documented as preview.
94+
95+
Deprecations are announced in the changelog before removal. Stable fields keep a
96+
minimum one-major-release compatibility window; preview fields may change in a
97+
minor release, but the release notes must say so. Tool definitions can expose
98+
additional metadata such as examples and annotations without changing the
99+
meaning of existing `inputSchema` entries.
100+
101+
Consumers should branch on documented structural fields, not prose. For MCP
102+
errors, route on `error.code` and structured `error.data.category` when present;
103+
do not parse `error.message`, which is diagnostic text and may be clarified in
104+
minor or patch releases. For CLI automation, route on documented exit codes and
105+
JSON fields rather than human output.
106+
85107
| Query surface | CLI `--json` shape | MCP response shape | Compatibility notes |
86108
|---|---|---|---|
87109
| `search` | One JSON object per result, with CLI query metadata such as `api_version`, `query`, path, line range, snippet, highlights, and truncation details. | Tool result content contains equivalent search-result objects using MCP serialization and tool-call framing. | Result semantics are shared, but the outer envelope and field casing follow the called surface. |

README.md

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,20 @@ file completion.
118118
| Drift checks | `cdidx diff <db1> <db2>` compares schema, file, symbol, and reference deltas with stable exit codes: `0` identical, `1` drift, `2` schema mismatch, `3` unreadable DB. |
119119
| Extensibility and feedback | Post-extraction hooks from `~/.config/cdidx/hooks/*.dll` or `CDIDX_HOOKS_DIR` can enrich symbols and references. `cdidx suggestions` lists, inspects, and exports local suggestion history, with fuzzy MCP suggestion deduplication controlled by CLI, env, or `.cdidxrc.json`. |
120120
| Language coverage | 78 detected languages, with symbol and graph support where available. |
121-
| Updates | `cdidx --version` checks GitHub releases at most once per day and appends a newer-release hint when one is available. Set `CDIDX_DISABLE_UPDATE_CHECK=1` to suppress the check. |
121+
| Updates | `cdidx --version` checks GitHub releases at most once per day and appends a newer-release hint when one is available. Use `cdidx --check-updates` or `cdidx status --check-updates` for an explicit freshness check, and `cdidx upgrade` to reinstall the latest GitHub release via `install.sh`. Set `CDIDX_DISABLE_UPDATE_CHECK=1` to suppress checks. |
122+
123+
### Upgrade and uninstall
124+
125+
`cdidx upgrade --check-only` reports whether a newer GitHub release is available. `cdidx upgrade` downloads the current `install.sh`, refuses unwritable install directories, and reruns the installer with `CDIDX_INSTALL_DIR` pointed at the current binary directory.
126+
127+
Direct `install.sh` installs can be removed with:
128+
129+
```bash
130+
bash ./install.sh --uninstall
131+
bash ./install.sh --uninstall --purge-cache
132+
```
133+
134+
The uninstaller removes files placed next to the `cdidx` binary and can optionally remove `~/.cache/cdidx`. It does not remove project `.cdidx/` directories, shell profile PATH edits, shell completion scripts, Homebrew installs, or .NET global-tool installs.
122135

123136
The documented `status --json` trust contract covers these fields:
124137

USER_GUIDE.md

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ cdidx suggestions list # Review local AI feedback history
3030
cdidx mcp # Start MCP server for AI tools
3131
```
3232

33-
78 languages supported. 24 MCP tools. Incremental updates. Zero config.
33+
78 languages supported. 24 registered MCP tools. Incremental updates. Zero config.
3434

3535
| Topic | Link |
3636
|---|---|
@@ -1764,7 +1764,7 @@ OpenAI Codex CLI (`codex.json` or `~/.codex/config.json`):
17641764

17651765
Once configured, the AI can directly call these tools:
17661766

1767-
The MCP `tools/list` descriptions include compact English/Japanese usage examples for the primary search and navigation tools, so AI clients can discover valid argument shapes directly from the server response.
1767+
The MCP `tools/list` response includes an `examples` array for every registered tool, so AI clients can discover valid `tools/call` argument shapes directly from the server response.
17681768

17691769
| Tool | Description |
17701770
|---|---|
@@ -1809,6 +1809,26 @@ Graph-oriented MCP tools such as `references`, `callers`, and `callees` also ret
18091809

18101810
All MCP tools include `annotations` (`readOnlyHint`, `destructiveHint`, `idempotentHint`, `openWorldHint`) so AI clients can auto-approve safe read-only queries without prompting the user.
18111811

1812+
#### MCP error responses
1813+
1814+
MCP JSON-RPC failures use the standard `error` object. Clients should route on
1815+
`error.code` and, when present, `error.data.category`; do not parse
1816+
`error.message`, which is human-facing diagnostic text.
1817+
1818+
| Code | Meaning | Client action |
1819+
|---|---|---|
1820+
| `-32700` | Parse error or frame too large | Fix the JSON/frame size before retrying |
1821+
| `-32600` | Invalid JSON-RPC request | Fix request shape before retrying |
1822+
| `-32601` | Method not found or disabled tool | Check server version and `tools/list` |
1823+
| `-32602` | Invalid params, unknown tool, or bad protocol version | Fix arguments or negotiate a supported version |
1824+
| `-32603` | Internal error | Surface the failure and inspect server stderr |
1825+
| `-32000` | Rate limited | Retry after the reported delay |
1826+
| `-32001` | Permission denied | Provide the configured auth token |
1827+
| `-32010` | Index missing | Run `cdidx index <projectPath>` first |
1828+
| `-32011` | Index stale/schema mismatch | Rebuild or refresh the index |
1829+
| `-32012` | Index corrupted/unreadable | Rebuild the index from source |
1830+
| `-32015` | Request cancelled | Retry if the client still needs the result |
1831+
18121832
#### Optional HTTP transport
18131833

18141834
By default `cdidx mcp` speaks JSON-RPC over stdin/stdout, which is what every config example above uses. AI clients that prefer to keep one warm server running across many requests — instead of paying subprocess-spawn cost per call — can switch the transport to HTTP:
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
---
2+
category: fixed
3+
issues:
4+
- 1691
5+
affected:
6+
- src/CodeIndex/Database/DbContext.cs
7+
- src/CodeIndex/Database/DbWriter.cs
8+
- tests/CodeIndex.Tests/DatabaseTests.cs
9+
---
10+
11+
## English
12+
13+
- **Rejected malformed persisted kind values (#1691)** — new schemas add CHECK constraints for symbol/reference kind columns, and writer paths fail fast when extractors try to persist unregistered kind values.
14+
15+
## 日本語
16+
17+
- **不正な kind 値の永続化を拒否するようにしました (#1691)** — 新規 schema が symbol/reference kind 列に CHECK 制約を追加し、extractor が未登録 kind 値を永続化しようとした場合は writer path が早期に失敗します。
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
---
2+
category: fixed
3+
issues:
4+
- 1700
5+
affected:
6+
- tests/CodeIndex.Tests/QueryCommandRunnerTests.cs
7+
---
8+
9+
## English
10+
11+
- **Out-of-range query numeric flags now fail closed (#1700)** — numeric options such as `--depth 999999999` return usage errors instead of being silently coerced or clamped.
12+
13+
## 日本語
14+
15+
- **範囲外の query 数値フラグを fail-closed にしました (#1700)**`--depth 999999999` のような数値 option は silent な補正や clamp ではなく usage error を返します。

0 commit comments

Comments
 (0)