You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+65Lines changed: 65 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -61,6 +61,10 @@ Two install styles — they mirror the Docker image variants of the same names:
61
61
62
62
Next, set up your [coding agent integration](#coding-agent-integration) — or jump to [Manual CLI Usage](#manual-cli-usage) if you prefer direct control.
63
63
64
+
Docs:
65
+
-[Git Layered Indexing](./docs/layered-indexing.md): configure reusable `base > branch > dirty` Git layers for root clones and linked worktrees.
66
+
-[Docker Layered Indexing](./docs/docker-layered-indexing.md): run the layered daemon in Docker with persistent native state.
67
+
64
68
## Coding Agent Integration
65
69
66
70
### Skill (Recommended)
@@ -162,6 +166,16 @@ The background daemon starts automatically on first use.
162
166
163
167
> **Tip:**`ccc index` auto-initializes if you haven't run `ccc init` yet, so you can skip straight to indexing.
164
168
169
+
For Git repositories, you can configure layered indexing once from the root clone:
170
+
171
+
```bash
172
+
ccc init --base main # share a base layer across linked worktrees
173
+
ccc index # builds base + branch + dirty layers as needed
174
+
ccc overlay status # inspect the current layer stack
175
+
```
176
+
177
+
Linked worktrees reuse the same daemon-owned base layer and only index branch and dirty deltas. See [Git Layered Indexing](./docs/layered-indexing.md) for the full configuration model.
178
+
165
179
### CLI Reference
166
180
167
181
| Command | Description |
@@ -170,6 +184,8 @@ The background daemon starts automatically on first use.
170
184
|`ccc index`| Build or update the index (auto-inits if needed). Shows streaming progress. |
171
185
|`ccc search <query>`| Semantic search across the codebase |
172
186
|`ccc status`| Show index stats (chunk count, file count, language breakdown) |
187
+
|`ccc overlay status`| Inspect Git layered indexing state for the current worktree |
188
+
|`ccc overlay prune`| Prune expired branch and dirty layers |
173
189
|`ccc mcp`| Run as MCP server in stdio mode |
174
190
|`ccc doctor`| Run diagnostics — checks settings, daemon, model, file matching, and index health |
175
191
|`ccc reset`| Delete index databases. `--all` also removes settings. `-f` skips confirmation. |
@@ -185,6 +201,7 @@ ccc search --lang python --lang markdown schema # filter by language
185
201
ccc search --path 'src/utils/*' query handler # filter by path
-**Semantic Code Search**: Find relevant code using natural language queries when grep doesn't work well, and save tokens immediately.
513
+
-**Git Layered Indexing**: Reuse a shared base index across root clones and linked worktrees, then index only branch and dirty deltas. Configure it with `ccc init --base main`; see [Git Layered Indexing](./docs/layered-indexing.md).
466
514
-**Ultra Performant**: ⚡ Built on top of ultra performant [Rust indexing engine](https://github.com/cocoindex-io/cocoindex). Only re-indexes changed files for fast updates.
467
515
-**Multi-Language Support**: Python, JavaScript/TypeScript, Rust, Go, Java, C/C++, C#, SQL, Shell, and more.
468
516
-**Embedded**: Portable and just works, no database setup required!
See [`src/cocoindex_code/chunking.py`](./src/cocoindex_code/chunking.py) for the public types and [`tests/example_toml_chunker.py`](./tests/example_toml_chunker.py) for a complete example.
585
633
634
+
### Git Layered Indexing Configuration
635
+
636
+
For Git repositories, `ccc init --base <ref>` stores a repository-level overlay
637
+
policy in daemon state. The checkout-local `settings.yml` still controls file
638
+
matching and chunking, while daemon state controls the shared base ref used by
639
+
root clones and linked worktrees.
640
+
641
+
```bash
642
+
ccc init --base main
643
+
ccc index
644
+
ccc overlay status
645
+
```
646
+
647
+
The daemon stores durable layer metadata under `COCOINDEX_CODE_STATE_DIR` and
648
+
uses stable hash IDs, so moving a repository or linked worktree does not
649
+
invalidate reusable base and branch layers. See [Git Layered Indexing](./docs/layered-indexing.md) for details.
650
+
586
651
## Embedding Models
587
652
588
653
With the `[full]` extra installed, `ccc init` defaults to a local SentenceTransformers model ([Snowflake/snowflake-arctic-embed-xs](https://huggingface.co/Snowflake/snowflake-arctic-embed-xs)) — no API key required. To use a different model, edit `~/.cocoindex_code/global_settings.yml`.
Both paths must be visible inside the same container mount for the daemon to reuse repository and layer state across them.
54
+
55
+
## Host Wrapper
56
+
57
+
Use this wrapper so Docker commands resolve the host current directory correctly:
58
+
59
+
```bash
60
+
ccc() {
61
+
local container="${COCOINDEX_CODE_CONTAINER_NAME:-cocoindex-code}"
62
+
if [ "$(docker inspect -f '{{.State.Running}}' "$container" 2>/dev/null)" != "true" ]; then
63
+
echo "cocoindex-code container is not running. Start it with: docker compose -f docker/docker-compose.yml up -d" >&2
64
+
return 1
65
+
fi
66
+
67
+
local flags=(-i)
68
+
if [ "${1:-}" != "mcp" ] && [ -t 0 ] && [ -t 1 ]; then
69
+
flags=(-it)
70
+
fi
71
+
72
+
docker exec "${flags[@]}" \
73
+
-e COCOINDEX_CODE_HOST_CWD="$PWD" \
74
+
"$container" ccc "$@"
75
+
}
76
+
```
77
+
78
+
`COCOINDEX_CODE_HOST_CWD`is required for linked worktrees. It tells the container-side CLI which host directory you are actually in, then the path mapping translates it to `/workspace/...`.
79
+
80
+
## Layered Workflow in Docker
81
+
82
+
Root clone:
83
+
84
+
```bash
85
+
cd $HOME/src/github/cocoindex-io/cocoindex-code
86
+
ccc init --base main
87
+
ccc index
88
+
```
89
+
90
+
Linked worktree:
91
+
92
+
```bash
93
+
git worktree add ../cocoindex-code.worktrees/feature-1 -b feature-1 main
94
+
cd ../cocoindex-code.worktrees/feature-1
95
+
ccc index
96
+
ccc search "query planner"
97
+
ccc overlay status
98
+
```
99
+
100
+
The base layer is stored once under `/var/cocoindex/state` and reused by the linked worktree.
101
+
102
+
## Environment Variables
103
+
104
+
| Variable | Purpose |
105
+
|---|---|
106
+
| `COCOINDEX_CODE_IMAGE` | Image used by compose, e.g. `cocoindex/cocoindex-code:full`. |
107
+
| `COCOINDEX_CODE_CONTAINER_NAME` | Container name used by compose and the wrapper. |
108
+
| `COCOINDEX_HOST_WORKSPACE` | Host directory mounted at `/workspace`. Mount a parent that contains all worktrees you want to share. |
109
+
| `COCOINDEX_CODE_HOST_PATH_MAPPING` | Container-to-host path mapping for display and host CWD translation. |
110
+
| `COCOINDEX_CODE_HOST_CWD` | Host current directory passed per `docker exec` invocation. |
0 commit comments