Skip to content
Merged
9 changes: 9 additions & 0 deletions DEVELOPER_GUIDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,15 @@ cdidx search AuthService --db /artifacts/codeindex.db --immutable
Mutating commands such as `index`, `backfill-fold`, `optimize`, and `vacuum`
require writable storage and reject read-only database opens.

For CI jobs that want to publish a reusable index artifact, run
`cdidx export codeindex.cdidx.zip` after indexing and upload that archive. A
consumer can run `cdidx import codeindex.cdidx.zip --db <path>` before query
commands. Use `--prune-paths` on import when the archive comes from another
checkout and the restored DB should advertise the current workspace root. The
archive contains `manifest.json` plus `codeindex.db`; import validates the
embedded SQLite file as a CodeIndex database before replacing the destination
DB.

Use `cdidx db checkpoint <name>` to take a filesystem snapshot of
`codeindex.db` plus existing WAL/SHM sidecars before risky maintenance, and use
`cdidx db restore <name>` to roll back. Checkpoints live next to the DB under
Expand Down
52 changes: 52 additions & 0 deletions USER_GUIDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,8 @@ sections below show examples and option details for the most common workflows.
| Diagnostics | `db --integrity-check` | Run SQLite `PRAGMA integrity_check` against the DB | -- |
| Diagnostics | `report --output <path>` | Build a redacted bug-report bundle | -- |
| Feedback | `suggestions` | List, inspect, and export local suggestion history | -- |
| Portability | `export ctags` | Write a native `tags` file for Vim, Emacs, Sublime, and other ctags consumers | -- |
| Portability | `export` / `import` | Share a built CodeIndex database as a portable archive | -- |
| MCP | `mcp` | Start the MCP server for AI tools | server transport |
| Legal | `license` | Show the license and commercial-use summary | -- |

Expand All @@ -307,6 +309,31 @@ cdidx search authenticate --json # ndjson stream, one result per line
cdidx search authenticate --json=array # single JSON array
```

## Editor and index portability

Use `cdidx export ctags` when an editor wants the traditional ctags file format
instead of querying `cdidx` directly:

```bash
cdidx export ctags --output tags
cdidx export ctags --db .cdidx/codeindex.db --output .tags
```

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:

```bash
cdidx export codeindex.cdidx.zip
cdidx import codeindex.cdidx.zip
cdidx import codeindex.cdidx.zip --db /tmp/codeindex.db --prune-paths
```

The archive path is intended for trusted CodeIndex databases. Import validates
that the embedded SQLite file is a CodeIndex DB before replacing the destination
database. `--prune-paths` rewrites the imported `indexed_project_root` metadata
to the current checkout.

## Flag compatibility and migrations

`--exact` remains accepted for compatibility, but new usage should prefer the
Expand Down Expand Up @@ -2354,6 +2381,8 @@ cdidx index . --quiet
| Diagnostics | `db --integrity-check` | DB に対して SQLite `PRAGMA integrity_check` を実行 | -- |
| Diagnostics | `report --output <path>` | redact 済み bug-report bundle を作成 | -- |
| Feedback | `suggestions` | local suggestion history を list / inspect / export | -- |
| Portability | `export ctags` | Vim、Emacs、Sublime など ctags consumer 向けに `tags` file を出力 | -- |
| Portability | `export` / `import` | build 済み CodeIndex database を portable archive として共有 | -- |
| MCP | `mcp` | AI tools 向け MCP server を起動 | server transport |
| Legal | `license` | license と commercial-use summary を表示 | -- |

Expand All @@ -2375,6 +2404,29 @@ cdidx search authenticate --json # ndjson stream、1 行 1 result
cdidx search authenticate --json=array # 単一 JSON array
```

## Editor / index portability

Editor が `cdidx` を直接 query するのではなく従来の ctags file を読む場合は、
`cdidx export ctags` を使います。

```bash
cdidx export ctags --output tags
cdidx export ctags --db .cdidx/codeindex.db --output .tags
```

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

```bash
cdidx export codeindex.cdidx.zip
cdidx import codeindex.cdidx.zip
cdidx import codeindex.cdidx.zip --db /tmp/codeindex.db --prune-paths
```

archive は信頼できる CodeIndex database の共有向けです。Import は埋め込まれた
SQLite file が CodeIndex DB であることを検証してから destination database を置き換えます。
`--prune-paths` は import した `indexed_project_root` metadata を現在の checkout に書き換えます。

## フラグ互換性と移行

`--exact` は互換性のため引き続き受け付けますが、新しい使い方ではコマンド系統に
Expand Down
18 changes: 18 additions & 0 deletions changelog.d/unreleased/1649.added.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
---
category: added
issues:
- 1649
affected:
- src/CodeIndex/Cli/ExportImportCommandRunner.cs
- src/CodeIndex/Cli/ProgramRunner.cs
- src/CodeIndex/Cli/ConsoleUi.cs
- USER_GUIDE.md
---

## English

- **Added ctags export (#1649)** — `cdidx export ctags` now writes editor-native `tags` files from indexed symbols, with `--output` and `--db` options.

## 日本語

- **ctags export を追加しました (#1649)** — `cdidx export ctags` が indexed symbols から editor native の `tags` file を出力し、`--output` と `--db` options に対応しました。
19 changes: 19 additions & 0 deletions changelog.d/unreleased/1726.added.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
---
category: added
issues:
- 1726
affected:
- src/CodeIndex/Cli/ExportImportCommandRunner.cs
- src/CodeIndex/Cli/ProgramRunner.cs
- src/CodeIndex/Cli/ConsoleUi.cs
- USER_GUIDE.md
- DEVELOPER_GUIDE.md
---

## English

- **Added portable index archive export/import (#1726)** — `cdidx export <archive>` and `cdidx import <archive>` now package and restore CodeIndex databases with a manifest for CI or cross-machine reuse, including `--prune-paths` on import.

## 日本語

- **portable index archive の export/import を追加しました (#1726)** — `cdidx export <archive>` / `cdidx import <archive>` で manifest 付きの CodeIndex database を CI や別 machine で再利用でき、import 時の `--prune-paths` に対応しました。
10 changes: 10 additions & 0 deletions src/CodeIndex/Cli/ConsoleUi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,9 @@ private static readonly (string Command, string Usage)[] CommandUsageLines =
("unused", "cdidx unused [--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]"),
("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>] [--format <json|markdown>]"),
("export", "cdidx export <archive> [--db <path>] [--json]"),
("export", "cdidx export ctags [--output <path>] [--db <path>]"),
("import", "cdidx import <archive> [--db <path>] [--prune-paths] [--json]"),
("languages", "cdidx languages [--json]"),
("batch", "cdidx batch [--db <path>] # reads JSON string arrays from stdin, one query command per line"),
("mcp", "cdidx mcp [--db <path>]"),
Expand Down Expand Up @@ -741,6 +744,8 @@ public static void PrintUsageBrief(bool showBanner = true)
Console.WriteLine(" deps Show file-level dependency edges from the reference graph");
Console.WriteLine(" unused Find symbols defined but never referenced (dead code)");
Console.WriteLine(" hotspots Find high-impact symbols; duplicate-name families may fall back conservatively");
Console.WriteLine(" export Export ctags or a portable CodeIndex archive");
Console.WriteLine(" import Import a portable CodeIndex archive");
Console.WriteLine(" batch Run newline-delimited JSON query commands with one DB connection");
Console.WriteLine(" mcp Start MCP server (for AI tools: Claude, Cursor, etc.)");
Console.WriteLine(" lsp Start LSP server over stdio (for LSP-native editors)");
Expand Down Expand Up @@ -851,6 +856,8 @@ private static void PrintCommandSummary()
Console.WriteLine(" unused Find symbols defined but never referenced (dead code)");
Console.WriteLine(" hotspots Find high-impact symbols; duplicate-name families may fall back conservatively");
Console.WriteLine(" suggestions List, inspect, and export local suggestion history");
Console.WriteLine(" export Export ctags or a portable CodeIndex archive");
Console.WriteLine(" import Import a portable CodeIndex archive");
Console.WriteLine(" languages List supported languages and their capabilities");
Console.WriteLine(" batch Run newline-delimited JSON query commands with one DB connection");
Console.WriteLine(" mcp Start MCP server (for AI tools: Claude, Cursor, etc.)");
Expand Down Expand Up @@ -965,6 +972,9 @@ private static void PrintExamples()
Console.WriteLine(" Update DB from files changed between two refs");
Console.WriteLine(" cdidx index ./myproject --files src/app.cs Update specific files");
Console.WriteLine(" cdidx index ./myproject --watch Run an initial scan, then keep the index live as files change (Ctrl+C to stop)");
Console.WriteLine(" cdidx export ctags --output tags Export editor tags for Vim, Emacs, and Sublime");
Console.WriteLine(" cdidx export codeindex.cdidx.zip Export a portable CodeIndex archive");
Console.WriteLine(" cdidx import codeindex.cdidx.zip Import a portable CodeIndex archive");
Console.WriteLine(" cdidx search \"authenticate\" Full-text search");
Console.WriteLine(" cdidx search \"auth*\" Prefix shorthand in literal-safe mode");
Console.WriteLine(" cdidx search --query --path --path README.md Search for a literal option token");
Expand Down
Loading
Loading