sketch: compress JS and CSS

We noticed that our JS bundles weren't compressed; let's compress them.
Sketch did most of the work here itself, but there's some nonsense
around the fact that we pass a zip.Reader around, which can't seek.
We're probably doing more work than strictly necessary on the server side.

Add gzip compression for JS and source map files in esbuild

- Added compression for .js and .js.map files in the esbuild Build() function
- Gzipped files are created alongside the originals with .gz extension
- This allows for compressed asset serving when supported by clients

Co-Authored-By: sketch

Add support for serving pre-compressed JS and source map files

- Created a custom HTTP handler for /static/ path
- Handler checks if requested JS/JS.map files have gzipped versions
- Serves gzipped files with proper Content-Encoding headers when available
- Falls back to original files when compressed versions are not found
- Client support for gzip encoding is verified through Accept-Encoding header

Co-Authored-By: sketch

Extend gzip compression to include CSS files

- Added CSS files to the compression list alongside JS and source map files
- Added debug output to show which files are being compressed
- Updated error messages to reflect the inclusion of CSS files

Co-Authored-By: sketch

Fix variable naming in Accept-Encoding header processing

- Renamed 'header' variable to 'encoding' for better semantics when processing Accept-Encoding headers
- Addresses gopls check issue in compressed file handler

Co-Authored-By: sketch

Simplify Accept-Encoding header processing

- Simplified check for gzip support using strings.Contains()
- More efficient approach than splitting and iterating
- Addresses gopls efficiency recommendation

Co-Authored-By: sketch

Extract compressed file handler to separate package

- Created a new package loop/server/gzhandler
- Moved compressedFileHandler implementation to the new package
- Renamed to Handler for better Go idioms
- Updated loophttp.go to use the new package
- Improved modularity and separation of concerns

Co-Authored-By: sketch

Enhance gzhandler and add test coverage

- Updated gzhandler to handle all files except .gz files
- Added comprehensive test suite for gzhandler
- Removed debug print from esbuild.go
- Tests different file types, browsers with and without gzip support
- Tests directory handling

Co-Authored-By: sketch

Fix 'seeker can't seek' error in gzhandler

- Changed approach to read gzipped file into memory before serving
- Avoids io.Seeker interface requirement for http.ServeContent
- Fixes 500 error when serving compressed JavaScript files
- Added missing io import

Co-Authored-By: sketch
4 files changed
tree: bec096858c74a6a51774ccff398a613c7944c2db
  1. .github/
  2. .vscode/
  3. ant/
  4. claudetool/
  5. cmd/
  6. dockerimg/
  7. httprr/
  8. loop/
  9. skabandclient/
  10. skribe/
  11. termui/
  12. .gitignore
  13. go.mod
  14. go.sum
  15. LICENSE
  16. README.md
README.md

Sketch

Sketch is an agentic coding tool focused on the Go programming language. Sketch runs in your terminal, has a web UI, understands your code, and helps you get work done. To keep your environment pristine, sketch starts a docker container and outputs its work onto a branch in your host git repository.

To get started:

go install sketch.dev/cmd/sketch@latest
sketch

Requirements

Currently sketch only runs on macOS. It uses docker/colima (installable via homebrew) for containers.

The sketch.dev service is used to provide access to an LLM service and give you a way to access the web UI from anywhere.

Feedback/discussion

We have a discord server to discuss sketch.

Join if you want! https://discord.gg/2xG3KEG3

Open Source

Sketch is open source. It is right here in this repository! Have a look around and mod away.

If you want to run sketch entirely without the sketch.dev service, you can set the flag -skaband-addr="" and then provide an ANTHROPIC_API_KEY environment variable. (More LLM services coming soon!)