From 516f1b194683e6cf342d6c45edbb12874c84330e Mon Sep 17 00:00:00 2001 From: GitHub Copilot Date: Sat, 14 Feb 2026 22:40:29 +0000 Subject: [PATCH] Reorganize project into standard root layout Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- .dockerignore | 10 ++++++++-- .github/copilot-instructions.md | 2 +- .github/instructions/go.instructions.md | 2 +- .gitignore | 3 +-- Dockerfile | 10 ++++++---- Makefile | 4 ++-- README.md | 13 ++++--------- {go/cmd => cmd}/webterm/main.go | 0 {go/cmd => cmd}/webterm/main_test.go | 0 docs/ARCHITECTURE.md | 12 ++++++------ go/go.mod => go.mod | 0 go/go.sum => go.sum | 0 {go/internal => internal}/terminalstate/tracker.go | 0 .../terminalstate/tracker_test.go | 0 package.json | 8 ++++---- tsconfig.json | 2 +- {go/webterm => webterm}/assets_embed.go | 0 {go/webterm => webterm}/cli.go | 0 {go/webterm => webterm}/cli_test.go | 0 {go/webterm => webterm}/config.go | 0 {go/webterm => webterm}/config_test.go | 0 {go/webterm => webterm}/constants.go | 0 {go/webterm => webterm}/coverage_boost_test.go | 0 {go/webterm => webterm}/docker_exec_session.go | 0 {go/webterm => webterm}/docker_http.go | 0 {go/webterm => webterm}/docker_stats.go | 0 {go/webterm => webterm}/docker_stats_test.go | 0 {go/webterm => webterm}/docker_watcher.go | 0 {go/webterm => webterm}/docker_watcher_test.go | 0 {go/webterm => webterm}/identity.go | 0 {go/webterm => webterm}/identity_test.go | 0 {go/webterm => webterm}/normalize.go | 0 {go/webterm => webterm}/normalize_test.go | 0 {go/webterm => webterm}/replay.go | 0 {go/webterm => webterm}/replay_test.go | 0 {go/webterm => webterm}/server.go | 0 .../server_helpers_fuzz_test.go | 0 {go/webterm => webterm}/server_test.go | 0 {go/webterm => webterm}/session.go | 0 {go/webterm => webterm}/session_helpers_test.go | 0 {go/webterm => webterm}/session_manager.go | 0 {go/webterm => webterm}/session_manager_test.go | 0 {go/webterm => webterm}/shellsplit.go | 0 {go/webterm => webterm}/shellsplit_test.go | 0 {go/webterm => webterm}/slugify.go | 0 {go/webterm => webterm}/slugify_test.go | 0 .../static/icons/webterm-192.png | Bin .../static/icons/webterm-512.png | Bin {go/webterm => webterm}/static/js/ghostty-vt.wasm | Bin {go/webterm => webterm}/static/js/terminal.js | 0 {go/webterm => webterm}/static/js/terminal.ts | 0 {go/webterm => webterm}/static/manifest.json | 0 {go/webterm => webterm}/static/monospace.css | 0 {go/webterm => webterm}/svg_exporter.go | 0 {go/webterm => webterm}/svg_exporter_test.go | 0 {go/webterm => webterm}/terminal_session.go | 0 {go/webterm => webterm}/test_helpers_test.go | 0 .../fuzz/FuzzExtractLabel/efdeb133630bbbf7 | 0 .../testdata/fuzz/FuzzSlugify/e4674c21c5507767 | 0 {go/webterm => webterm}/themes.go | 0 {go/webterm => webterm}/twoway.go | 0 {go/webterm => webterm}/twoway_test.go | 0 62 files changed, 34 insertions(+), 32 deletions(-) rename {go/cmd => cmd}/webterm/main.go (100%) rename {go/cmd => cmd}/webterm/main_test.go (100%) rename go/go.mod => go.mod (100%) rename go/go.sum => go.sum (100%) rename {go/internal => internal}/terminalstate/tracker.go (100%) rename {go/internal => internal}/terminalstate/tracker_test.go (100%) rename {go/webterm => webterm}/assets_embed.go (100%) rename {go/webterm => webterm}/cli.go (100%) rename {go/webterm => webterm}/cli_test.go (100%) rename {go/webterm => webterm}/config.go (100%) rename {go/webterm => webterm}/config_test.go (100%) rename {go/webterm => webterm}/constants.go (100%) rename {go/webterm => webterm}/coverage_boost_test.go (100%) rename {go/webterm => webterm}/docker_exec_session.go (100%) rename {go/webterm => webterm}/docker_http.go (100%) rename {go/webterm => webterm}/docker_stats.go (100%) rename {go/webterm => webterm}/docker_stats_test.go (100%) rename {go/webterm => webterm}/docker_watcher.go (100%) rename {go/webterm => webterm}/docker_watcher_test.go (100%) rename {go/webterm => webterm}/identity.go (100%) rename {go/webterm => webterm}/identity_test.go (100%) rename {go/webterm => webterm}/normalize.go (100%) rename {go/webterm => webterm}/normalize_test.go (100%) rename {go/webterm => webterm}/replay.go (100%) rename {go/webterm => webterm}/replay_test.go (100%) rename {go/webterm => webterm}/server.go (100%) rename {go/webterm => webterm}/server_helpers_fuzz_test.go (100%) rename {go/webterm => webterm}/server_test.go (100%) rename {go/webterm => webterm}/session.go (100%) rename {go/webterm => webterm}/session_helpers_test.go (100%) rename {go/webterm => webterm}/session_manager.go (100%) rename {go/webterm => webterm}/session_manager_test.go (100%) rename {go/webterm => webterm}/shellsplit.go (100%) rename {go/webterm => webterm}/shellsplit_test.go (100%) rename {go/webterm => webterm}/slugify.go (100%) rename {go/webterm => webterm}/slugify_test.go (100%) rename {go/webterm => webterm}/static/icons/webterm-192.png (100%) rename {go/webterm => webterm}/static/icons/webterm-512.png (100%) rename {go/webterm => webterm}/static/js/ghostty-vt.wasm (100%) rename {go/webterm => webterm}/static/js/terminal.js (100%) rename {go/webterm => webterm}/static/js/terminal.ts (100%) rename {go/webterm => webterm}/static/manifest.json (100%) rename {go/webterm => webterm}/static/monospace.css (100%) rename {go/webterm => webterm}/svg_exporter.go (100%) rename {go/webterm => webterm}/svg_exporter_test.go (100%) rename {go/webterm => webterm}/terminal_session.go (100%) rename {go/webterm => webterm}/test_helpers_test.go (100%) rename {go/webterm => webterm}/testdata/fuzz/FuzzExtractLabel/efdeb133630bbbf7 (100%) rename {go/webterm => webterm}/testdata/fuzz/FuzzSlugify/e4674c21c5507767 (100%) rename {go/webterm => webterm}/themes.go (100%) rename {go/webterm => webterm}/twoway.go (100%) rename {go/webterm => webterm}/twoway_test.go (100%) diff --git a/.dockerignore b/.dockerignore index d8d8af1..99d6aff 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1,6 +1,12 @@ * -!go/ -!go/** +!cmd/ +!cmd/** +!internal/ +!internal/** +!webterm/ +!webterm/** +!go.mod +!go.sum !Dockerfile !.dockerignore !VERSION diff --git a/.github/copilot-instructions.md b/.github/copilot-instructions.md index dc03b63..3e73f49 100644 --- a/.github/copilot-instructions.md +++ b/.github/copilot-instructions.md @@ -24,5 +24,5 @@ Always use the Makefile for development tasks. Never run raw `go test`, `go vet` 1. **Before changes**: Run `make check` to establish baseline. 2. **After changes**: Run `make check` and `make race`. -3. **Frontend edits**: Run `make build` after changing `go/webterm/static/js/terminal.ts`. +3. **Frontend edits**: Run `make build` after changing `webterm/static/js/terminal.ts`. 4. **Major validation**: Run `make build-all` for a reproducible full run. diff --git a/.github/instructions/go.instructions.md b/.github/instructions/go.instructions.md index 4745b3f..2aba16d 100644 --- a/.github/instructions/go.instructions.md +++ b/.github/instructions/go.instructions.md @@ -7,5 +7,5 @@ Applies when: this repo has `go.mod`. - Put `golangci-lint` and `gosec` wiring behind Make targets when introduced. ## Conventions to implement -- `make test` should run `cd go && go test ./...`. +- `make test` should run `go test ./...`. - Avoid bespoke CI steps when a Make target can encode the same behavior. diff --git a/.gitignore b/.gitignore index 2add649..d817bf9 100644 --- a/.gitignore +++ b/.gitignore @@ -10,14 +10,13 @@ webterm.log # Coverage/build artifacts -go/coverage.out coverage.out dist/ build/ target/ # Go -go/bin/ +bin/ # Frontend node_modules/ diff --git a/Dockerfile b/Dockerfile index 310c715..478dc11 100644 --- a/Dockerfile +++ b/Dockerfile @@ -4,11 +4,13 @@ FROM golang:1.26-alpine AS builder WORKDIR /src -COPY go/go.mod go/go.sum ./go/ -RUN cd go && go mod download -COPY go ./go +COPY go.mod go.sum ./ +RUN go mod download +COPY cmd ./cmd +COPY internal ./internal +COPY webterm ./webterm COPY VERSION ./VERSION -RUN cd go && VERSION=$(cat /src/VERSION) && CGO_ENABLED=0 go build -trimpath -ldflags="-s -w -X github.com/rcarmo/webterm-go-port/webterm.Version=$VERSION" -o /out/webterm ./cmd/webterm +RUN VERSION=$(cat /src/VERSION) && CGO_ENABLED=0 go build -trimpath -ldflags="-s -w -X github.com/rcarmo/webterm-go-port/webterm.Version=$VERSION" -o /out/webterm ./cmd/webterm FROM alpine:3.21 AS runtime diff --git a/Makefile b/Makefile index d1f8fbf..dcb69a3 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,7 @@ .PHONY: help install install-dev lint format test race coverage check fuzz build-go build build-fast bundle bundle-watch bundle-clean clean clean-all build-all typecheck bump-patch push -GO_DIR = go -STATIC_JS_DIR = go/webterm/static/js +GO_DIR = . +STATIC_JS_DIR = webterm/static/js TERMINAL_TS = $(STATIC_JS_DIR)/terminal.ts TERMINAL_JS = $(STATIC_JS_DIR)/terminal.js GHOSTTY_WASM = $(STATIC_JS_DIR)/ghostty-vt.wasm diff --git a/README.md b/README.md index a216091..e2d0713 100644 --- a/README.md +++ b/README.md @@ -27,26 +27,24 @@ This repository is the Go port of the original Python implementation, which is p ```bash git clone https://github.com/rcarmo/webterm.git -cd webterm/go +cd webterm mkdir -p bin go build -o ./bin/webterm ./cmd/webterm ``` -The command above produces `go/bin/webterm`; you can also build it from repo root with `make build-go`. +The command above produces `bin/webterm`; you can also build it from repo root with `make build-go`. ## Quick start Run a default shell session: ```bash -cd go go run ./cmd/webterm ``` Run a specific command: ```bash -cd go go run ./cmd/webterm -- htop ``` @@ -64,14 +62,12 @@ Then open . ``` ```bash -cd go -go run ./cmd/webterm -- --landing-manifest ../landing.yaml +go run ./cmd/webterm -- --landing-manifest ./landing.yaml ``` ### Docker watch ```bash -cd go go run ./cmd/webterm -- --docker-watch ``` @@ -83,8 +79,7 @@ Containers with these labels become tiles: ### Compose manifest ```bash -cd go -go run ./cmd/webterm -- --compose-manifest ../docker-compose.yaml +go run ./cmd/webterm -- --compose-manifest ./docker-compose.yaml ``` ## Environment variables diff --git a/go/cmd/webterm/main.go b/cmd/webterm/main.go similarity index 100% rename from go/cmd/webterm/main.go rename to cmd/webterm/main.go diff --git a/go/cmd/webterm/main_test.go b/cmd/webterm/main_test.go similarity index 100% rename from go/cmd/webterm/main_test.go rename to cmd/webterm/main_test.go diff --git a/docs/ARCHITECTURE.md b/docs/ARCHITECTURE.md index 15bb1d9..bd834e1 100644 --- a/docs/ARCHITECTURE.md +++ b/docs/ARCHITECTURE.md @@ -9,7 +9,7 @@ Browser (terminal.js + ghostty-vt.wasm) │ │ WS / HTTP / SSE ▼ -go/webterm/server.go (LocalServer) +webterm/server.go (LocalServer) │ ├── session_manager.go (route/app/session registry) ├── terminal_session.go (PTY-backed local sessions) @@ -21,9 +21,9 @@ go/webterm/server.go (LocalServer) ## Packages -- `go/cmd/webterm`: CLI entrypoint -- `go/webterm`: server/runtime/domain logic -- `go/internal/terminalstate`: Go terminal emulator wrapper (`go-te`) used for screenshots +- `cmd/webterm`: CLI entrypoint +- `webterm`: server/runtime/domain logic +- `internal/terminalstate`: Go terminal emulator wrapper (`go-te`) used for screenshots ## Runtime data flow @@ -37,7 +37,7 @@ go/webterm/server.go (LocalServer) ## Static assets -Assets live in `go/webterm/static`: +Assets live in `webterm/static`: - `js/terminal.ts` source - `js/terminal.js` bundled client @@ -47,7 +47,7 @@ Assets live in `go/webterm/static`: The server resolves static files from: 1. `WEBTERM_STATIC_PATH` (if set) -2. local repository-relative fallbacks rooted at `go/webterm/static` +2. local repository-relative fallbacks rooted at `webterm/static` 3. embedded assets bundled into the Go binary ## Docker integration diff --git a/go/go.mod b/go.mod similarity index 100% rename from go/go.mod rename to go.mod diff --git a/go/go.sum b/go.sum similarity index 100% rename from go/go.sum rename to go.sum diff --git a/go/internal/terminalstate/tracker.go b/internal/terminalstate/tracker.go similarity index 100% rename from go/internal/terminalstate/tracker.go rename to internal/terminalstate/tracker.go diff --git a/go/internal/terminalstate/tracker_test.go b/internal/terminalstate/tracker_test.go similarity index 100% rename from go/internal/terminalstate/tracker_test.go rename to internal/terminalstate/tracker_test.go diff --git a/package.json b/package.json index 094090e..ede22ab 100644 --- a/package.json +++ b/package.json @@ -9,10 +9,10 @@ "typescript": "^5.7.0" }, "scripts": { - "build": "bun run typecheck && bun build go/webterm/static/js/terminal.ts --outfile=go/webterm/static/js/terminal.js --minify --target=browser && cp node_modules/ghostty-web/ghostty-vt.wasm go/webterm/static/js/", - "build:fast": "bun build go/webterm/static/js/terminal.ts --outfile=go/webterm/static/js/terminal.js --minify --target=browser", - "watch": "bun build go/webterm/static/js/terminal.ts --outfile=go/webterm/static/js/terminal.js --watch --target=browser", + "build": "bun run typecheck && bun build webterm/static/js/terminal.ts --outfile=webterm/static/js/terminal.js --minify --target=browser && cp node_modules/ghostty-web/ghostty-vt.wasm webterm/static/js/", + "build:fast": "bun build webterm/static/js/terminal.ts --outfile=webterm/static/js/terminal.js --minify --target=browser", + "watch": "bun build webterm/static/js/terminal.ts --outfile=webterm/static/js/terminal.js --watch --target=browser", "typecheck": "bun x tsc --noEmit -p tsconfig.json", - "copy-wasm": "cp node_modules/ghostty-web/ghostty-vt.wasm go/webterm/static/js/" + "copy-wasm": "cp node_modules/ghostty-web/ghostty-vt.wasm webterm/static/js/" } } diff --git a/tsconfig.json b/tsconfig.json index 9c60f87..b71dcd9 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -12,6 +12,6 @@ "isolatedModules": true, "lib": ["ES2022", "DOM", "DOM.Iterable"] }, - "include": ["go/webterm/static/js/**/*.ts"], + "include": ["webterm/static/js/**/*.ts"], "exclude": ["node_modules"] } diff --git a/go/webterm/assets_embed.go b/webterm/assets_embed.go similarity index 100% rename from go/webterm/assets_embed.go rename to webterm/assets_embed.go diff --git a/go/webterm/cli.go b/webterm/cli.go similarity index 100% rename from go/webterm/cli.go rename to webterm/cli.go diff --git a/go/webterm/cli_test.go b/webterm/cli_test.go similarity index 100% rename from go/webterm/cli_test.go rename to webterm/cli_test.go diff --git a/go/webterm/config.go b/webterm/config.go similarity index 100% rename from go/webterm/config.go rename to webterm/config.go diff --git a/go/webterm/config_test.go b/webterm/config_test.go similarity index 100% rename from go/webterm/config_test.go rename to webterm/config_test.go diff --git a/go/webterm/constants.go b/webterm/constants.go similarity index 100% rename from go/webterm/constants.go rename to webterm/constants.go diff --git a/go/webterm/coverage_boost_test.go b/webterm/coverage_boost_test.go similarity index 100% rename from go/webterm/coverage_boost_test.go rename to webterm/coverage_boost_test.go diff --git a/go/webterm/docker_exec_session.go b/webterm/docker_exec_session.go similarity index 100% rename from go/webterm/docker_exec_session.go rename to webterm/docker_exec_session.go diff --git a/go/webterm/docker_http.go b/webterm/docker_http.go similarity index 100% rename from go/webterm/docker_http.go rename to webterm/docker_http.go diff --git a/go/webterm/docker_stats.go b/webterm/docker_stats.go similarity index 100% rename from go/webterm/docker_stats.go rename to webterm/docker_stats.go diff --git a/go/webterm/docker_stats_test.go b/webterm/docker_stats_test.go similarity index 100% rename from go/webterm/docker_stats_test.go rename to webterm/docker_stats_test.go diff --git a/go/webterm/docker_watcher.go b/webterm/docker_watcher.go similarity index 100% rename from go/webterm/docker_watcher.go rename to webterm/docker_watcher.go diff --git a/go/webterm/docker_watcher_test.go b/webterm/docker_watcher_test.go similarity index 100% rename from go/webterm/docker_watcher_test.go rename to webterm/docker_watcher_test.go diff --git a/go/webterm/identity.go b/webterm/identity.go similarity index 100% rename from go/webterm/identity.go rename to webterm/identity.go diff --git a/go/webterm/identity_test.go b/webterm/identity_test.go similarity index 100% rename from go/webterm/identity_test.go rename to webterm/identity_test.go diff --git a/go/webterm/normalize.go b/webterm/normalize.go similarity index 100% rename from go/webterm/normalize.go rename to webterm/normalize.go diff --git a/go/webterm/normalize_test.go b/webterm/normalize_test.go similarity index 100% rename from go/webterm/normalize_test.go rename to webterm/normalize_test.go diff --git a/go/webterm/replay.go b/webterm/replay.go similarity index 100% rename from go/webterm/replay.go rename to webterm/replay.go diff --git a/go/webterm/replay_test.go b/webterm/replay_test.go similarity index 100% rename from go/webterm/replay_test.go rename to webterm/replay_test.go diff --git a/go/webterm/server.go b/webterm/server.go similarity index 100% rename from go/webterm/server.go rename to webterm/server.go diff --git a/go/webterm/server_helpers_fuzz_test.go b/webterm/server_helpers_fuzz_test.go similarity index 100% rename from go/webterm/server_helpers_fuzz_test.go rename to webterm/server_helpers_fuzz_test.go diff --git a/go/webterm/server_test.go b/webterm/server_test.go similarity index 100% rename from go/webterm/server_test.go rename to webterm/server_test.go diff --git a/go/webterm/session.go b/webterm/session.go similarity index 100% rename from go/webterm/session.go rename to webterm/session.go diff --git a/go/webterm/session_helpers_test.go b/webterm/session_helpers_test.go similarity index 100% rename from go/webterm/session_helpers_test.go rename to webterm/session_helpers_test.go diff --git a/go/webterm/session_manager.go b/webterm/session_manager.go similarity index 100% rename from go/webterm/session_manager.go rename to webterm/session_manager.go diff --git a/go/webterm/session_manager_test.go b/webterm/session_manager_test.go similarity index 100% rename from go/webterm/session_manager_test.go rename to webterm/session_manager_test.go diff --git a/go/webterm/shellsplit.go b/webterm/shellsplit.go similarity index 100% rename from go/webterm/shellsplit.go rename to webterm/shellsplit.go diff --git a/go/webterm/shellsplit_test.go b/webterm/shellsplit_test.go similarity index 100% rename from go/webterm/shellsplit_test.go rename to webterm/shellsplit_test.go diff --git a/go/webterm/slugify.go b/webterm/slugify.go similarity index 100% rename from go/webterm/slugify.go rename to webterm/slugify.go diff --git a/go/webterm/slugify_test.go b/webterm/slugify_test.go similarity index 100% rename from go/webterm/slugify_test.go rename to webterm/slugify_test.go diff --git a/go/webterm/static/icons/webterm-192.png b/webterm/static/icons/webterm-192.png similarity index 100% rename from go/webterm/static/icons/webterm-192.png rename to webterm/static/icons/webterm-192.png diff --git a/go/webterm/static/icons/webterm-512.png b/webterm/static/icons/webterm-512.png similarity index 100% rename from go/webterm/static/icons/webterm-512.png rename to webterm/static/icons/webterm-512.png diff --git a/go/webterm/static/js/ghostty-vt.wasm b/webterm/static/js/ghostty-vt.wasm similarity index 100% rename from go/webterm/static/js/ghostty-vt.wasm rename to webterm/static/js/ghostty-vt.wasm diff --git a/go/webterm/static/js/terminal.js b/webterm/static/js/terminal.js similarity index 100% rename from go/webterm/static/js/terminal.js rename to webterm/static/js/terminal.js diff --git a/go/webterm/static/js/terminal.ts b/webterm/static/js/terminal.ts similarity index 100% rename from go/webterm/static/js/terminal.ts rename to webterm/static/js/terminal.ts diff --git a/go/webterm/static/manifest.json b/webterm/static/manifest.json similarity index 100% rename from go/webterm/static/manifest.json rename to webterm/static/manifest.json diff --git a/go/webterm/static/monospace.css b/webterm/static/monospace.css similarity index 100% rename from go/webterm/static/monospace.css rename to webterm/static/monospace.css diff --git a/go/webterm/svg_exporter.go b/webterm/svg_exporter.go similarity index 100% rename from go/webterm/svg_exporter.go rename to webterm/svg_exporter.go diff --git a/go/webterm/svg_exporter_test.go b/webterm/svg_exporter_test.go similarity index 100% rename from go/webterm/svg_exporter_test.go rename to webterm/svg_exporter_test.go diff --git a/go/webterm/terminal_session.go b/webterm/terminal_session.go similarity index 100% rename from go/webterm/terminal_session.go rename to webterm/terminal_session.go diff --git a/go/webterm/test_helpers_test.go b/webterm/test_helpers_test.go similarity index 100% rename from go/webterm/test_helpers_test.go rename to webterm/test_helpers_test.go diff --git a/go/webterm/testdata/fuzz/FuzzExtractLabel/efdeb133630bbbf7 b/webterm/testdata/fuzz/FuzzExtractLabel/efdeb133630bbbf7 similarity index 100% rename from go/webterm/testdata/fuzz/FuzzExtractLabel/efdeb133630bbbf7 rename to webterm/testdata/fuzz/FuzzExtractLabel/efdeb133630bbbf7 diff --git a/go/webterm/testdata/fuzz/FuzzSlugify/e4674c21c5507767 b/webterm/testdata/fuzz/FuzzSlugify/e4674c21c5507767 similarity index 100% rename from go/webterm/testdata/fuzz/FuzzSlugify/e4674c21c5507767 rename to webterm/testdata/fuzz/FuzzSlugify/e4674c21c5507767 diff --git a/go/webterm/themes.go b/webterm/themes.go similarity index 100% rename from go/webterm/themes.go rename to webterm/themes.go diff --git a/go/webterm/twoway.go b/webterm/twoway.go similarity index 100% rename from go/webterm/twoway.go rename to webterm/twoway.go diff --git a/go/webterm/twoway_test.go b/webterm/twoway_test.go similarity index 100% rename from go/webterm/twoway_test.go rename to webterm/twoway_test.go