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 CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ The daemon idle-exits after `daemon.idle_timeout_minutes` (default 180, 0 = neve

**`server.py`** — FastMCP wrapper that delegates `search` calls to the daemon client. Also contains the legacy `main()` entry point (`cocoindex-code` command) for backward-compatible env-var-based configuration.

**`cli.py`** — Typer app with `ccc` subcommands (`init`, `index`, `search`, `grep`, `status`, `reset`, `doctor`, `mcp`, `daemon status/restart/stop`). CLI logic only — delegates to `client.py` or `grep.py`.
**`cli.py`** — Typer app with `ccc` subcommands (`init`, `index`, `search`, `grep`, `status`, `reset`, `doctor`, `mcp`, `version`, `daemon status/restart/stop`). CLI logic only — delegates to `client.py` or `grep.py`.

**`grep.py`** — Structural code search (`ccc grep`) using CocoIndex's `code_match`. Runs entirely locally with no daemon or index. Matches in parallel, streams results per file.

Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,7 @@ The background daemon starts automatically on first use.
| `ccc mcp` | Run as MCP server in stdio mode |
| `ccc doctor` | Run diagnostics — checks settings, daemon, model, file matching, and index health |
| `ccc reset` | Delete index databases. `--all` also removes settings. `-f` skips confirmation. |
| `ccc version` | Print the CLI version |
| `ccc daemon status` | Show daemon version, uptime, and loaded projects |
| `ccc daemon restart` | Restart the background daemon |
| `ccc daemon stop` | Stop the daemon |
Expand Down
7 changes: 7 additions & 0 deletions src/cocoindex_code/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
SearchResponse,
)

from ._version import __version__
from .settings import (
DEFAULT_ST_MODEL,
EmbeddingSettings,
Expand Down Expand Up @@ -1120,6 +1121,12 @@ def daemon_stop() -> None:
_typer.echo("Daemon stopped.")


@app.command()
def version() -> None:
"""Print the CLI version."""
_typer.echo(__version__)


@app.command("run-daemon", hidden=True)
def run_daemon_cmd() -> None:
"""Internal: run the daemon process."""
Expand Down
36 changes: 36 additions & 0 deletions tests/test_cli_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,42 @@ def test_apply_host_cwd_noop_when_unset(
assert capsys.readouterr().err == ""


# ---------------------------------------------------------------------------
# ccc version
# ---------------------------------------------------------------------------


def test_version_prints_client_version() -> None:
"""`ccc version` reports the client version and exits 0."""
from typer.testing import CliRunner

from cocoindex_code._version import __version__
from cocoindex_code.cli import app

result = CliRunner().invoke(app, ["version"], catch_exceptions=False)

assert result.exit_code == 0
assert result.stdout.strip() == __version__


def test_version_works_outside_a_project(tmp_path: Path, monkeypatch: pytest.MonkeyPatch) -> None:
"""No project discovery, no daemon, no settings needed."""
from typer.testing import CliRunner

from cocoindex_code._version import __version__
from cocoindex_code.cli import app

standalone = tmp_path / "not-a-project"
standalone.mkdir()
monkeypatch.chdir(standalone)
monkeypatch.setenv("COCOINDEX_CODE_DIR", str(tmp_path / "no-such-home"))

result = CliRunner().invoke(app, ["version"], catch_exceptions=False)

assert result.exit_code == 0
assert result.stdout.strip() == __version__


# ---------------------------------------------------------------------------
# ccc init — auto-populate indexing_params / query_params from curated table
# ---------------------------------------------------------------------------
Expand Down
Loading