Skip to content

Commit 5f59ac0

Browse files
Merge branch 'main' into cursor/SOU-306-zoekt-failed-indexing-shards-c9df
2 parents bb12c47 + f14c52f commit 5f59ac0

File tree

151 files changed

+4874
-1791
lines changed

Some content is hidden

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

151 files changed

+4874
-1791
lines changed

.devcontainer/Dockerfile

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
# Development container for Sourcebot
2+
# Based on Node.js 24 with TypeScript support
3+
FROM mcr.microsoft.com/devcontainers/typescript-node:24
4+
5+
ARG GO_VERSION=1.23.4
6+
ARG CTAGS_VERSION=v6.1.0
7+
8+
# Install system dependencies
9+
RUN apt-get update && apt-get install -y --no-install-recommends \
10+
# Build tools for universal-ctags
11+
autoconf \
12+
automake \
13+
pkg-config \
14+
make \
15+
gcc \
16+
g++ \
17+
libjansson-dev \
18+
libyaml-dev \
19+
libseccomp-dev \
20+
libxml2-dev \
21+
# PostgreSQL client tools (for debugging)
22+
postgresql-client \
23+
# Redis CLI tools (for debugging)
24+
redis-tools \
25+
# Other utilities
26+
curl \
27+
git \
28+
&& rm -rf /var/lib/apt/lists/*
29+
30+
# Install Go (detect architecture automatically)
31+
RUN ARCH=$(dpkg --print-architecture) && \
32+
if [ "$ARCH" = "arm64" ]; then GOARCH="arm64"; else GOARCH="amd64"; fi && \
33+
curl -fsSL "https://go.dev/dl/go${GO_VERSION}.linux-${GOARCH}.tar.gz" | tar -C /usr/local -xzf -
34+
ENV PATH="/usr/local/go/bin:${PATH}"
35+
ENV GOPATH="/home/node/go"
36+
ENV PATH="${GOPATH}/bin:${PATH}"
37+
38+
# Build and install universal-ctags from source
39+
RUN git clone --depth 1 --branch "${CTAGS_VERSION}" https://github.com/universal-ctags/ctags.git /tmp/ctags \
40+
&& cd /tmp/ctags \
41+
&& ./autogen.sh \
42+
&& ./configure \
43+
&& make -j$(nproc) \
44+
&& make install \
45+
&& rm -rf /tmp/ctags
46+
47+
# Enable corepack for Yarn and disable download prompts
48+
ENV COREPACK_ENABLE_DOWNLOAD_PROMPT=0
49+
RUN corepack enable
50+
51+
# Create directories that will be mounted as volumes with correct ownership
52+
# This ensures the node user can write to them when volumes are mounted
53+
RUN mkdir -p /home/node/go /home/node/.yarn/berry/cache \
54+
&& chown -R node:node /home/node/go /home/node/.yarn
55+
56+
# Set working directory
57+
WORKDIR /workspaces/sourcebot
58+
59+
# Switch to non-root user
60+
USER node
61+
62+
# Install Claude CLI (native binary)
63+
RUN curl -fsSL https://claude.ai/install.sh | bash
64+
ENV PATH="/home/node/.claude/bin:${PATH}"

.devcontainer/devcontainer.json

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
{
2+
"name": "Sourcebot Development",
3+
"dockerComposeFile": "docker-compose.yml",
4+
"service": "devcontainer",
5+
"workspaceFolder": "/workspaces/sourcebot",
6+
7+
"features": {
8+
"ghcr.io/devcontainers/features/git:1": {},
9+
"ghcr.io/devcontainers/features/github-cli:1": {}
10+
},
11+
12+
"remoteEnv": {
13+
"AUTH_URL": "https://${localEnv:CODESPACE_NAME}-3000.${localEnv:GITHUB_CODESPACES_PORT_FORWARDING_DOMAIN}"
14+
},
15+
16+
"forwardPorts": [3000],
17+
"portsAttributes": {
18+
"3000": { "label": "Web App", "onAutoForward": "notify" }
19+
},
20+
21+
"initializeCommand": "git submodule update --init --recursive",
22+
"postCreateCommand": "bash .devcontainer/scripts/post-create.sh",
23+
"postStartCommand": "bash .devcontainer/scripts/post-start.sh",
24+
25+
"customizations": {
26+
"vscode": {
27+
"extensions": [
28+
"dbaeumer.vscode-eslint",
29+
"bradlc.vscode-tailwindcss",
30+
"Prisma.prisma",
31+
"esbenp.prettier-vscode",
32+
"golang.go",
33+
"eamodio.gitlens"
34+
],
35+
"settings": {
36+
"editor.formatOnSave": false,
37+
"editor.defaultFormatter": "esbenp.prettier-vscode",
38+
"[typescript]": {
39+
"editor.defaultFormatter": "esbenp.prettier-vscode"
40+
},
41+
"[typescriptreact]": {
42+
"editor.defaultFormatter": "esbenp.prettier-vscode"
43+
},
44+
"[prisma]": {
45+
"editor.defaultFormatter": "Prisma.prisma"
46+
}
47+
}
48+
}
49+
},
50+
51+
"remoteUser": "node"
52+
}

.devcontainer/docker-compose.yml

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
version: '3.8'
2+
3+
services:
4+
devcontainer:
5+
build:
6+
context: .
7+
dockerfile: Dockerfile
8+
volumes:
9+
- ..:/workspaces/sourcebot:cached
10+
- go-modules:/home/node/go
11+
- yarn-cache:/home/node/.yarn/berry/cache
12+
command: sleep infinity
13+
ports:
14+
- "3000:3000"
15+
environment:
16+
DATABASE_URL: postgresql://postgres:postgres@postgres:5432/postgres
17+
REDIS_URL: redis://redis:6379
18+
ZOEKT_WEBSERVER_URL: http://localhost:6070
19+
CTAGS_COMMAND: ctags
20+
AUTH_SECRET: "00000000000000000000000000000000000000000000"
21+
AUTH_URL: http://localhost:3000
22+
DATA_CACHE_DIR: /workspaces/sourcebot/.sourcebot
23+
SOURCEBOT_ENCRYPTION_KEY: "00000000000000000000000000000000"
24+
NODE_ENV: development
25+
SOURCEBOT_LOG_LEVEL: debug
26+
SOURCEBOT_TELEMETRY_DISABLED: "true"
27+
REVIEW_AGENT_LOGGING_ENABLED: "true"
28+
REVIEW_AGENT_AUTO_REVIEW_ENABLED: "false"
29+
REVIEW_AGENT_REVIEW_COMMAND: review
30+
depends_on:
31+
- postgres
32+
- redis
33+
34+
postgres:
35+
image: postgres:16-alpine
36+
volumes:
37+
- postgres-data:/var/lib/postgresql/data
38+
environment:
39+
POSTGRES_DB: postgres
40+
POSTGRES_USER: postgres
41+
POSTGRES_PASSWORD: postgres
42+
restart: unless-stopped
43+
44+
redis:
45+
image: redis:7-alpine
46+
volumes:
47+
- redis-data:/data
48+
restart: unless-stopped
49+
50+
volumes:
51+
go-modules:
52+
yarn-cache:
53+
postgres-data:
54+
redis-data:
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
#!/bin/bash
2+
# post-create.sh - One-time setup after container creation
3+
set -e
4+
5+
echo "=========================================="
6+
echo "Sourcebot Dev Container: Post-Create Setup"
7+
echo "=========================================="
8+
9+
cd /workspaces/sourcebot
10+
11+
# 1. Initialize git submodules (in case initializeCommand didn't run)
12+
echo ""
13+
echo "[1/5] Initializing git submodules..."
14+
git submodule update --init --recursive
15+
16+
# 2. Build Zoekt and install dependencies (uses Makefile)
17+
echo ""
18+
echo "[2/5] Building Zoekt and installing dependencies..."
19+
make
20+
21+
echo ""
22+
echo "[3/5] Running database migrations..."
23+
yarn dev:prisma:migrate:dev
24+
25+
echo ""
26+
echo "[4/5] Creating default config.json..."
27+
cat > config.json << 'EOF'
28+
{
29+
"$schema": "https://raw.githubusercontent.com/sourcebot-dev/sourcebot/main/schemas/v3/index.json",
30+
"connections": {
31+
"github": {
32+
"type": "github",
33+
"repos": ["sourcebot-dev/sourcebot"]
34+
}
35+
}
36+
}
37+
EOF
38+
39+
echo ""
40+
echo "[5/5] Configuring Claude Code to skip onboarding..."
41+
# Create or update ~/.claude.json to skip onboarding
42+
if [ -f ~/.claude.json ]; then
43+
# Update existing file
44+
node -e "const fs=require('fs');const cfg=JSON.parse(fs.readFileSync('$HOME/.claude.json','utf8'));cfg.hasCompletedOnboarding=true;fs.writeFileSync('$HOME/.claude.json',JSON.stringify(cfg,null,2));"
45+
else
46+
# Create minimal config with onboarding skipped
47+
cat > ~/.claude.json << 'EOF'
48+
{
49+
"hasCompletedOnboarding": true
50+
}
51+
EOF
52+
fi
53+
54+
echo ""
55+
echo "=========================================="
56+
echo "Post-create setup complete!"
57+
echo ""
58+
echo "To start the development server, run:"
59+
echo " yarn dev"
60+
echo ""
61+
echo "Services will be available at:"
62+
echo " - Web App: http://localhost:3000"
63+
echo " - Zoekt: http://localhost:6070"
64+
echo "=========================================="
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
#!/bin/bash
2+
# post-start.sh - Runs each time the container starts
3+
set -e
4+
5+
echo "=========================================="
6+
echo "Sourcebot Dev Container: Post-Start Check"
7+
echo "=========================================="
8+
9+
cd /workspaces/sourcebot
10+
11+
# 1. Wait for PostgreSQL to be ready
12+
echo ""
13+
echo "[1/2] Checking PostgreSQL connection..."
14+
timeout=30
15+
counter=0
16+
until pg_isready -h postgres -p 5432 -U postgres > /dev/null 2>&1; do
17+
counter=$((counter + 1))
18+
if [ $counter -ge $timeout ]; then
19+
echo "ERROR: PostgreSQL did not become ready within ${timeout} seconds"
20+
exit 1
21+
fi
22+
echo " Waiting for PostgreSQL... ($counter/$timeout)"
23+
sleep 1
24+
done
25+
echo "PostgreSQL is ready!"
26+
27+
# 2. Wait for Redis to be ready
28+
echo ""
29+
echo "[2/2] Checking Redis connection..."
30+
counter=0
31+
until redis-cli -h redis -p 6379 ping > /dev/null 2>&1; do
32+
counter=$((counter + 1))
33+
if [ $counter -ge $timeout ]; then
34+
echo "ERROR: Redis did not become ready within ${timeout} seconds"
35+
exit 1
36+
fi
37+
echo " Waiting for Redis... ($counter/$timeout)"
38+
sleep 1
39+
done
40+
echo "Redis is ready!"
41+
42+
echo ""
43+
echo "=========================================="
44+
echo "Dev container is ready!"
45+
echo ""
46+
echo "To start development, run:"
47+
echo " yarn dev"
48+
echo "=========================================="

.env.development

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,6 @@ CTAGS_COMMAND=ctags
1414
AUTH_SECRET="00000000000000000000000000000000000000000000"
1515
AUTH_URL="http://localhost:3000"
1616
# AUTH_CREDENTIALS_LOGIN_ENABLED=true
17-
# AUTH_EE_GITHUB_CLIENT_ID=""
18-
# AUTH_EE_GITHUB_CLIENT_SECRET=""
19-
# AUTH_EE_GOOGLE_CLIENT_ID=""
20-
# AUTH_EE_GOOGLE_CLIENT_SECRET=""
2117

2218
DATA_CACHE_DIR=${PWD}/.sourcebot # Path to the sourcebot cache dir (ex. ~/sourcebot/.sourcebot)
2319
SOURCEBOT_PUBLIC_KEY_PATH=${PWD}/public.pem
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
name: Claude Code Review
2+
3+
on:
4+
pull_request:
5+
types: [opened, synchronize, ready_for_review, reopened]
6+
# Optional: Only run on specific file changes
7+
# paths:
8+
# - "src/**/*.ts"
9+
# - "src/**/*.tsx"
10+
# - "src/**/*.js"
11+
# - "src/**/*.jsx"
12+
13+
jobs:
14+
claude-review:
15+
# Optional: Filter by PR author
16+
# if: |
17+
# github.event.pull_request.user.login == 'external-contributor' ||
18+
# github.event.pull_request.user.login == 'new-developer' ||
19+
# github.event.pull_request.author_association == 'FIRST_TIME_CONTRIBUTOR'
20+
21+
runs-on: ubuntu-latest
22+
permissions:
23+
contents: read
24+
pull-requests: read
25+
issues: read
26+
id-token: write
27+
28+
steps:
29+
- name: Checkout repository
30+
uses: actions/checkout@v4
31+
with:
32+
fetch-depth: 1
33+
34+
- name: Run Claude Code Review
35+
id: claude-review
36+
uses: anthropics/claude-code-action@v1
37+
with:
38+
anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}
39+
plugin_marketplaces: 'https://github.com/anthropics/claude-code.git'
40+
plugins: 'code-review@claude-code-plugins'
41+
prompt: '/code-review:code-review ${{ github.repository }}/pull/${{ github.event.pull_request.number }}'
42+
# See https://github.com/anthropics/claude-code-action/blob/main/docs/usage.md
43+
# or https://code.claude.com/docs/en/cli-reference for available options
44+

.github/workflows/claude.yml

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
name: Claude Code
2+
3+
on:
4+
issue_comment:
5+
types: [created]
6+
pull_request_review_comment:
7+
types: [created]
8+
issues:
9+
types: [opened, assigned]
10+
pull_request_review:
11+
types: [submitted]
12+
13+
jobs:
14+
claude:
15+
if: |
16+
(github.event_name == 'issue_comment' && contains(github.event.comment.body, '@claude')) ||
17+
(github.event_name == 'pull_request_review_comment' && contains(github.event.comment.body, '@claude')) ||
18+
(github.event_name == 'pull_request_review' && contains(github.event.review.body, '@claude')) ||
19+
(github.event_name == 'issues' && (contains(github.event.issue.body, '@claude') || contains(github.event.issue.title, '@claude')))
20+
runs-on: ubuntu-latest
21+
permissions:
22+
contents: read
23+
pull-requests: read
24+
issues: read
25+
id-token: write
26+
actions: read # Required for Claude to read CI results on PRs
27+
steps:
28+
- name: Checkout repository
29+
uses: actions/checkout@v4
30+
with:
31+
fetch-depth: 1
32+
33+
- name: Run Claude Code
34+
id: claude
35+
uses: anthropics/claude-code-action@v1
36+
with:
37+
anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}
38+
39+
# This is an optional setting that allows Claude to read CI results on PRs
40+
additional_permissions: |
41+
actions: read
42+
43+
# Optional: Give a custom prompt to Claude. If this is not specified, Claude will perform the instructions specified in the comment that tagged it.
44+
# prompt: 'Update the pull request description to include a summary of changes.'
45+
46+
# Optional: Add claude_args to customize behavior and configuration
47+
# See https://github.com/anthropics/claude-code-action/blob/main/docs/usage.md
48+
# or https://code.claude.com/docs/en/cli-reference for available options
49+
# claude_args: '--allowed-tools Bash(gh pr:*)'
50+

0 commit comments

Comments
 (0)