|
| 1 | +# CLAUDE.md |
| 2 | + |
| 3 | +This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository. |
| 4 | + |
| 5 | +## Project Overview |
| 6 | + |
| 7 | +**che-code** is Eclipse Che's fork of Microsoft's VS Code (Code-OSS) that runs in a browser, connecting to a remote HTTP(s) server on Kubernetes instead of desktop mode. The terminal is container-aware: it can open shells in any container of the running pod. |
| 8 | + |
| 9 | +Upstream VS Code is stored as a Git subtree in the `code/` directory. The repository is self-contained (no submodule setup needed). |
| 10 | + |
| 11 | +## Build & Development Commands |
| 12 | + |
| 13 | +### Development Mode |
| 14 | +```bash |
| 15 | +npm install # Install deps + download built-in extensions (runs in code/) |
| 16 | +npm run watch # Compile and watch for changes |
| 17 | +npm run server # Run VS Code server at localhost:8000 (dev mode) |
| 18 | +``` |
| 19 | + |
| 20 | +### Production Build |
| 21 | +```bash |
| 22 | +npm run build # Build vscode-reh-web-linux-x64 (unminified) |
| 23 | +npm run build:min # Build vscode-reh-web-linux-x64 (minified) |
| 24 | +npm run rebuild-native-modules # Rebuild native Node modules |
| 25 | +``` |
| 26 | + |
| 27 | +### Container Image Build (in order) |
| 28 | +```bash |
| 29 | +podman build -f build/dockerfiles/linux-musl.Dockerfile -t linux-musl . |
| 30 | +podman build -f build/dockerfiles/linux-libc-ubi8.Dockerfile -t linux-libc-ubi8 . |
| 31 | +podman build -f build/dockerfiles/linux-libc-ubi9.Dockerfile -t linux-libc-ubi9 . |
| 32 | +podman build -f build/dockerfiles/assembly.Dockerfile -t che-code . |
| 33 | +``` |
| 34 | + |
| 35 | +### Running the Container Locally |
| 36 | +```bash |
| 37 | +podman run --rm -it -p 3100:3100 -e CODE_HOST=0.0.0.0 quay.io/che-incubator/che-code:next |
| 38 | +``` |
| 39 | + |
| 40 | +### Tests (inside `code/`) |
| 41 | +```bash |
| 42 | +cd code |
| 43 | +npm run test-node # Mocha unit tests (Node.js) |
| 44 | +npm run test-browser # Browser unit tests (Playwright) |
| 45 | +npm run test-extension # Extension tests (vscode-test) |
| 46 | +npm run smoketest # Full smoke test suite |
| 47 | +``` |
| 48 | + |
| 49 | +### Linting (inside `code/`) |
| 50 | +```bash |
| 51 | +cd code |
| 52 | +node build/eslint # ESLint |
| 53 | +node build/stylelint # Stylelint |
| 54 | +npm run hygiene # Full hygiene check (formatting, imports, layers) |
| 55 | +npm run valid-layers-check # Architecture layer validation |
| 56 | +``` |
| 57 | + |
| 58 | +### Launcher (`launcher/`) |
| 59 | +```bash |
| 60 | +cd launcher |
| 61 | +npm run compile # TypeScript compile |
| 62 | +npm run lint # ESLint |
| 63 | +npm run format # Prettier check |
| 64 | +npm run format:fix # Prettier auto-fix |
| 65 | +npm run build # Full build (format + compile + lint + test) |
| 66 | +``` |
| 67 | +Launcher uses Jest for testing, TypeScript 5.6+, and ES2022 modules. |
| 68 | + |
| 69 | +### Che Extension License Check |
| 70 | +```bash |
| 71 | +npm --prefix code/extensions/che-api run license:generate |
| 72 | +``` |
| 73 | +Replace `che-api` with any Che extension name. Generates dependency reports in `.deps/`. |
| 74 | + |
| 75 | +## Architecture |
| 76 | + |
| 77 | +### Directory Structure |
| 78 | + |
| 79 | +- **`code/`** — VS Code upstream (git subtree) with Che modifications. This is where the bulk of the editor source lives (`code/src/vs/`, `code/extensions/`). |
| 80 | +- **`launcher/`** — Standalone TypeScript project that configures and launches VS Code in Kubernetes. Handles workspace config, product.json generation, Open VSX registry integration, SSL certificates, and Kubernetes API interaction. |
| 81 | +- **`build/dockerfiles/`** — Multi-stage Dockerfiles for three platform targets (musl/Alpine, libc-ubi8, libc-ubi9) plus an assembly Dockerfile that combines them. |
| 82 | +- **`build/scripts/`** — Container entrypoint scripts (`entrypoint.sh`, `entrypoint-volume.sh`, `entrypoint-init-container.sh`). |
| 83 | +- **`build/artifacts/`** — `artifacts.lock.yaml` locks built-in extension versions with SHA256 checksums. Regenerate with `./build/artifacts/generate.sh`. |
| 84 | +- **`branding/`** — UI branding customization (icons, product.json overrides, CSS). Applied via `branding/branding.sh`. |
| 85 | +- **`.rebase/`** — Patch management for upstream rebasing: |
| 86 | + - `add/` — Files to add to upstream |
| 87 | + - `override/` — JSON files to merge over upstream (via jq) |
| 88 | + - `replace/` — Files to wholesale replace in upstream |
| 89 | + |
| 90 | +### Che-Specific Extensions (in `code/extensions/`) |
| 91 | + |
| 92 | +Nine extensions provide Kubernetes/Che integration: |
| 93 | +- `che-api` — API for Che platform integration |
| 94 | +- `che-activity-tracker` — User activity tracking |
| 95 | +- `che-commands` — Custom command support |
| 96 | +- `che-github-authentication` — GitHub OAuth flow |
| 97 | +- `che-port` — Port exposure management for pods |
| 98 | +- `che-remote` — Remote workspace status indicator |
| 99 | +- `che-resource-monitor` — Resource usage monitoring |
| 100 | +- `che-terminal` — Container-aware terminal (open shells in any pod container) |
| 101 | +- `che-telemetry` — Telemetry collection |
| 102 | + |
| 103 | +### Key Entry Points |
| 104 | + |
| 105 | +- `code/src/server-main.ts` — VS Code remote server entry point |
| 106 | +- `code/src/vs/` — Core VS Code modules (layered architecture enforced by `valid-layers-check`) |
| 107 | +- `launcher/src/entrypoint.ts` — Launcher entry point for Kubernetes environments |
| 108 | +- `launcher/src/vscode-launcher.ts` — VS Code process management |
| 109 | + |
| 110 | +### Upstream Rebase Workflow |
| 111 | + |
| 112 | +To rebase on upstream VS Code: |
| 113 | +1. `git remote add upstream-code https://github.com/microsoft/vscode` (if not already added) |
| 114 | +2. `git fetch upstream-code main` |
| 115 | +3. `./rebase.sh` — Pulls subtree, applies `.rebase/` patches, updates JSON overrides |
| 116 | +4. Fix any conflicts |
| 117 | +5. `./build/artifacts/generate.sh` to update `artifacts.lock.yaml` |
| 118 | + |
| 119 | +### Build System |
| 120 | + |
| 121 | +The `code/` directory uses Gulp as its build system. Key gulp tasks: |
| 122 | +- `vscode-reh-web-linux-x64` / `vscode-reh-web-linux-x64-min` — Build the remote web host |
| 123 | +- `watch-client` / `watch-extensions` — Watch mode (both run in parallel via `npm run watch`) |
| 124 | +- `compile-build-with-mangling` — Production compilation with name mangling |
| 125 | + |
| 126 | +Node.js version must match what upstream VS Code requires (check `code/remote/.npmrc` for the `target` property). |
| 127 | + |
| 128 | +### Multi-Platform Container Strategy |
| 129 | + |
| 130 | +The final image is assembled from three platform-specific builds: |
| 131 | +- **linux-musl** — Alpine Linux (musl libc) |
| 132 | +- **linux-libc-ubi8** — Red Hat UBI 8 |
| 133 | +- **linux-libc-ubi9** — Red Hat UBI 9 |
| 134 | + |
| 135 | +The `assembly.Dockerfile` combines all three into a single image that selects the right binary at runtime. |
0 commit comments