Skip to content

Commit a2a7445

Browse files
authored
Add CLAUDE file (#7)
1 parent 37888ea commit a2a7445

File tree

1 file changed

+85
-0
lines changed

1 file changed

+85
-0
lines changed

CLAUDE.md

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
# CLAUDE.md
2+
3+
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
4+
5+
## What is This?
6+
7+
Livegrep is a tool for interactive regex search of large source repositories, inspired by Google Code Search. This is Sentry's fork of [livegrep/livegrep](https://github.com/livegrep/livegrep).
8+
9+
Two-process architecture:
10+
- **codesearch** (C++): Builds index from git repos/filesystem, serves search over gRPC (port 9999)
11+
- **livegrep** (Go): Stateless HTTP frontend connecting to codesearch, serves web UI (port 8910)
12+
13+
The web UI uses Backbone.js/jQuery with PrismJS for syntax highlighting, bundled via webpack.
14+
15+
## Build System
16+
17+
Uses **Bazel** (v7.6.0 pinned in `.bazelversion`). Install via [bazelisk](https://bazel.build/install/bazelisk).
18+
19+
```bash
20+
# Build everything
21+
bazel build //...
22+
23+
# Build specific targets
24+
bazel build //src/tools:codesearch # C++ backend
25+
bazel build //cmd/livegrep:livegrep # Go frontend
26+
```
27+
28+
A convenience Makefile wraps common workflows:
29+
30+
```bash
31+
make build # Build both backend and frontend
32+
make index # Build search index (uses doc/examples/livegrep/index.json)
33+
make run # Build and start both services
34+
make stop # Stop all services
35+
make status # Check if services are running
36+
make logs-backend / make logs-web
37+
```
38+
39+
## Testing
40+
41+
```bash
42+
bazel test //... # Run all tests
43+
bazel test --test_arg=-test.v //... # Verbose (used in CI)
44+
```
45+
46+
- C++ tests: `test/` directory (googletest) — `codesearch_test`, `planner_test`, `tagsearch_test`
47+
- Go tests: `server/` directory — `query_test.go`, `server_test.go`, `fileview_test.go`
48+
49+
## Formatting
50+
51+
Go code must pass `gofmt`. CI checks this:
52+
```bash
53+
bazel run @rules_go//go -- fmt ./...
54+
```
55+
56+
## Key Directories
57+
58+
| Directory | Language | Role |
59+
|-----------|----------|------|
60+
| `src/` | C++ | Search engine core, indexer, gRPC server |
61+
| `src/proto/` | Protobuf | gRPC service + index config schemas |
62+
| `server/` | Go | HTTP frontend, gRPC client, templates |
63+
| `cmd/` | Go | Binary entrypoints (livegrep, reindexers, CLI) |
64+
| `web/` | JS/HTML/CSS | Frontend UI (webpack, Backbone.js, PrismJS) |
65+
| `third_party/` | C++ | Vendored deps (divsufsort, utf8cpp) |
66+
67+
## Configuration
68+
69+
- **Index config** (codesearch): JSON following `src/proto/config.proto` schema. Example: `doc/examples/livegrep/index.json`
70+
- **Server config** (livegrep frontend): JSON following `server/config/config.go`. Example: `doc/examples/livegrep/server.json`
71+
- `file_ext_to_lang`: Maps file extensions to PrismJS language names for syntax highlighting
72+
- `file_first_line_regex_to_lang`: Detects language by shebang/first line
73+
74+
## Sentry Fork Additions
75+
76+
- **Test file deranking**: Results from test files are sorted to the end of search results (`server/api.go:isTestFile`)
77+
- **Syntax highlighting**: PrismJS-based highlighting in search results (`web/src/codesearch/highlight.js`)
78+
- **Healthcheck age limit**: Backend healthcheck fails if index > 3.5 hours old (`server/server.go:MaxIndexAge`)
79+
80+
## Go + Bazel Notes
81+
82+
- Go IDE support requires the gopackagesdriver (configured in `.vscode/settings.json` for VSCode)
83+
- Go module path: `github.com/livegrep/livegrep`
84+
- Protobuf Go bindings are at `src/proto/go_proto`
85+
- To update Go deps: edit `go.mod`, then regenerate Bazel targets with gazelle

0 commit comments

Comments
 (0)