Restructure main.go to separate host and container code

This commit reorganizes the cmd/sketch/main.go file to clearly separate the
execution paths for host and container environments. The changes include:

1. Created dedicated functions for each execution path:
   - runInHostMode: Handles execution on the host, launching container
   - runInContainerMode: Handles execution inside the container
   - runInUnsafeMode: Handles execution directly on host without container
   - setupAndRunAgent: Common setup code for container and unsafe modes

2. Added clear function names and comments to indicate where code runs
3. Maintained existing functionality while making control flow explicit
4. Preserved all command-line flags and their handling
5. Kept the same behavior for all execution paths
6. Moved CLI flag parsing into a dedicated function

Co-Authored-By: sketch <hello@sketch.dev>
1 file changed
tree: 6f503aee50eec0f14f179f37169a531f3dde36b8
  1. .github/
  2. .vscode/
  3. ant/
  4. bin/
  5. browser/
  6. claudetool/
  7. cmd/
  8. dockerimg/
  9. httprr/
  10. loop/
  11. skabandclient/
  12. skribe/
  13. termui/
  14. webui/
  15. .clabot
  16. .gitignore
  17. CONTRIBUTING.md
  18. go.mod
  19. go.sum
  20. LICENSE
  21. 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 runs on macOS and linux. It uses docker/colima for containers.

macOS: brew install colima linux: apt install docker.io (or equivalent for your distro)

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/R82YagTASx

Development

Go Reference

See CONTRIBUTING.md

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!)