|
2 | 2 |
|
3 | 3 | This repository contains the source code for the Agent Browser. |
4 | 4 |
|
5 | | -## Project Setup (Golang) |
| 5 | +## Project Structure |
6 | 6 |
|
7 | | -This project is being set up using Golang and the `fx` framework. |
| 7 | +This project uses Go modules and follows a standard Go project layout: |
8 | 8 |
|
9 | | -Refer to `.cursor/TASK_LIST.md` for the setup tasks. |
| 9 | +* `/cmd`: Main application entry points. |
| 10 | +* `/internal`: Private application code (not intended for import by other projects). |
| 11 | + * `/app`: Core application setup and Fx module wiring. |
| 12 | + * `/config`: Configuration loading and management. |
| 13 | + * `/log`: Logging setup and utilities. |
| 14 | + * `/mcp`: MCP abstraction and utilities. |
| 15 | + * `/services`: Core business logic implementations. |
| 16 | + * `/sync`: Sync daemon. (PLACEHOLDER) |
| 17 | + * `/updater`: Software update logic. (PLACEHOLDER) |
| 18 | + * `/web`: Web server related code. |
| 19 | + * `/handlers`: HTTP request handlers. |
| 20 | + * `/templates`: HTML templates (using `templ`). |
| 21 | +* `/pkg`: Library code intended for external use (currently N/A). |
| 22 | +* `/scripts`: Scripts in Bash, Python, etc., for complex actions in this repository. |
| 23 | +* `/out`: Compiled binaries (ignored by git). |
10 | 24 |
|
11 | 25 | ## Getting Started |
12 | 26 |
|
13 | | -ToDo |
| 27 | +### Prerequisites |
| 28 | + |
| 29 | +1. **Go:** Ensure you have Go installed (version 1.21 or later recommended). You can download it from [https://go.dev/dl/](https://go.dev/dl/). |
| 30 | +2. **Bash:** The setup script uses `bash` specific features. |
| 31 | +3. **Environment Setup:** The setup script (`make setup`) will check if your `$GOPATH/bin` directory is in your `PATH` and provide instructions if it isn't. This directory is needed to run Go tools installed via `go install`. |
| 32 | + |
| 33 | + You can manually verify by running `go env GOPATH` and checking your shell's configuration (e.g., `.zshrc`, `.bashrc`). Example: |
| 34 | + ```bash |
| 35 | + export GOPATH="$(go env GOPATH)" # Or explicitly set, e.g., export GOPATH="$HOME/go" |
| 36 | + export PATH="$PATH:$GOPATH/bin" |
| 37 | + ``` |
| 38 | + |
| 39 | +### Installation & Setup |
| 40 | + |
| 41 | +1. **Clone the repository:** |
| 42 | + |
| 43 | + ```bash |
| 44 | + git clone https://github.com/co-browser/agent-browser.git |
| 45 | + cd agent-browser |
| 46 | + ``` |
| 47 | + |
| 48 | +2. **Install Tools & Dependencies:** Run the setup command. This executes `scripts/setup.sh` which installs required Go tools (`templ`, `golangci-lint`) and checks your `PATH`. |
| 49 | + |
| 50 | + ```bash |
| 51 | + make setup |
| 52 | + ``` |
| 53 | + |
| 54 | +3. **Download Go Modules:** |
| 55 | + |
| 56 | + ```bash |
| 57 | + make tidy |
| 58 | + ``` |
| 59 | + |
| 60 | +### Running the Application |
| 61 | + |
| 62 | +1. **Build and Run:** |
| 63 | + |
| 64 | + ```bash |
| 65 | + make run |
| 66 | + ``` |
| 67 | + |
| 68 | + This will compile the application into the `out/` directory and start the server (defaulting to `localhost:8080`). |
| 69 | + |
| 70 | +2. **Access the UI (Placeholder):** Open your browser to `http://localhost:8080/ui`. |
| 71 | + |
| 72 | +## Development |
| 73 | + |
| 74 | +### Common Makefile Targets |
| 75 | + |
| 76 | +* `make setup`: Runs `scripts/setup.sh` to install/update necessary development tools (`templ`, `golangci-lint`) and check `PATH`. |
| 77 | +* `make build`: Compile the application binary into `out/agent-browser`. |
| 78 | +* `make run`: Build and run the application. |
| 79 | +* `make generate`: Generate Go code from `.templ` files. |
| 80 | +* `make test`: Run Go tests. |
| 81 | +* `make fmt`: Format Go code (`gofmt`) and `.templ` files (`templ fmt`). |
| 82 | +* `make tidy`: Tidy `go.mod` and `go.sum` files. |
| 83 | +* `make lint`: Run the Go linter (`golangci-lint`). |
| 84 | +* `make help`: Show all available targets. |
| 85 | + |
| 86 | +## Continuous Integration |
| 87 | + |
| 88 | +This project uses GitHub Actions for Continuous Integration (CI) and release automation. The workflows are defined in the `.github/workflows/` directory. |
| 89 | + |
| 90 | +* **Go CI (`go.yaml`):** This workflow runs on pushes and pull requests to the `main` and `develop` branches. It checks out the code, sets up Go, runs `make setup`, `make tidy`, formatting checks (`make fmt`), linting (`make lint`), tests (`make test`) and builds the project (`make build`) to ensure Go code quality and stability. |
| 91 | + |
| 92 | +* **MegaLinter (`mega-linter.yaml`):** This workflow runs on pushes and pull requests to the `main` branch. It utilizes [MegaLinter](https://megalinter.io/) to analyze the entire codebase using a wide range of linters for various languages and formats (including Go, YAML, Markdown, Shell scripts, etc.). This helps maintain consistent coding standards and identify potential issues across the whole project. Reports are uploaded as artifacts. |
| 93 | + |
| 94 | +* **Release (`release.yaml`):** This workflow runs only on pushes to the `main` branch. It uses [semantic-release](https://github.com/semantic-release/semantic-release) to automate version management and package publishing. Based on conventional commit messages, it determines the next version number, generates release notes, and creates a Git tag and GitHub release. |
0 commit comments