Skip to content

Commit ba72f58

Browse files
authored
Merge pull request #395 from trycua/fix/restore-developer-guide
Restore Developer Guide and add `pdm.lock`
2 parents da9af2e + ef37f26 commit ba72f58

File tree

3 files changed

+6370
-2
lines changed

3 files changed

+6370
-2
lines changed

CONTRIBUTING.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ We're always looking for suggestions to make lume better. If you have an idea:
3030

3131
We follow strict code formatting guidelines to ensure consistency across the codebase. Before submitting any code:
3232

33-
1. **Review Our Format Guide**: Please review our [Code Formatting Standards](docs/Developer-Guide.md#code-formatting-standards) section in the Getting Started guide.
33+
1. **Review Our Format Guide**: Please review our [Code Formatting Standards](Development.md#code-formatting-standards) section in the Getting Started guide.
3434
2. **Configure Your IDE**: We recommend using the workspace settings provided in `.vscode/` for automatic formatting.
3535
3. **Run Formatting Tools**: Always run the formatting tools before submitting a PR:
3636
```bash
@@ -51,6 +51,6 @@ Documentation improvements are always welcome. You can:
5151
- Improve API documentation
5252
- Add tutorials or guides
5353

54-
For detailed instructions on setting up your development environment and submitting code contributions, please see our [Developer-Guide](./docs/Developer-Guide.md).
54+
For detailed instructions on setting up your development environment and submitting code contributions, please see our [Developer-Guide](Development.md).
5555

5656
Feel free to join our [Discord community](https://discord.com/invite/mVnXXpdE85) to discuss ideas or get help with your contributions.

Development.md

Lines changed: 285 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,285 @@
1+
# Getting Started
2+
3+
## Project Structure
4+
5+
The project is organized as a monorepo with these main packages:
6+
7+
- `libs/core/` - Base package with telemetry support
8+
- `libs/computer/` - Computer-use interface (CUI) library
9+
- `libs/agent/` - AI agent library with multi-provider support
10+
- `libs/som/` - Set-of-Mark parser
11+
- `libs/computer-server/` - Server component for VM
12+
- `libs/lume/` - Lume CLI
13+
- `libs/pylume/` - Python bindings for Lume
14+
15+
Each package has its own virtual environment and dependencies, managed through PDM.
16+
17+
## Local Development Setup
18+
19+
1. Install Lume CLI:
20+
21+
```bash
22+
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/trycua/cua/main/libs/lume/scripts/install.sh)"
23+
```
24+
25+
2. Clone the repository:
26+
27+
```bash
28+
git clone https://github.com/trycua/cua.git
29+
cd cua
30+
```
31+
32+
3. Create a `.env.local` file in the root directory with your API keys:
33+
34+
```bash
35+
# Required for Anthropic provider
36+
ANTHROPIC_API_KEY=your_anthropic_key_here
37+
38+
# Required for OpenAI provider
39+
OPENAI_API_KEY=your_openai_key_here
40+
```
41+
42+
4. Open the workspace in VSCode or Cursor:
43+
44+
```bash
45+
# For Cua Python development
46+
code .vscode/py.code-workspace
47+
48+
# For Lume (Swift) development
49+
code .vscode/lume.code-workspace
50+
```
51+
52+
Using the workspace file is strongly recommended as it:
53+
54+
- Sets up correct Python environments for each package
55+
- Configures proper import paths
56+
- Enables debugging configurations
57+
- Maintains consistent settings across packages
58+
59+
## Lume Development
60+
61+
Refer to the [Lume README](./libs/lume/Development.md) for instructions on how to develop the Lume CLI.
62+
63+
## Python Development
64+
65+
There are two ways to install Lume:
66+
67+
### Run the build script
68+
69+
Run the build script to set up all packages:
70+
71+
```bash
72+
./scripts/build.sh
73+
```
74+
75+
The build script creates a shared virtual environment for all packages. The workspace configuration automatically handles import paths with the correct Python path settings.
76+
77+
This will:
78+
79+
- Create a virtual environment for the project
80+
- Install all packages in development mode
81+
- Set up the correct Python path
82+
- Install development tools
83+
84+
### Install with PDM
85+
86+
If PDM is not already installed, you can follow the installation instructions [here](https://pdm-project.org/en/latest/#installation).
87+
88+
To install with PDM, simply run:
89+
90+
```console
91+
pdm install -G:all
92+
```
93+
94+
This installs all the dependencies for development, testing, and building the docs. If you'd only like development dependencies, you can run:
95+
96+
```console
97+
pdm install -d
98+
```
99+
100+
## Running Examples
101+
102+
The Python workspace includes launch configurations for all packages:
103+
104+
- "Run Computer Examples" - Runs computer examples
105+
- "Run Agent Examples" - Runs agent examples
106+
- "SOM" configurations - Various settings for running SOM
107+
108+
To run examples from VSCode / Cursor:
109+
110+
1. Press F5 or use the Run/Debug view
111+
2. Select the desired configuration
112+
113+
The workspace also includes compound launch configurations:
114+
115+
- "Run Computer Examples + Server" - Runs both the Computer Examples and Server simultaneously
116+
117+
## Docker Development Environment
118+
119+
As an alternative to installing directly on your host machine, you can use Docker for development. This approach has several advantages:
120+
121+
### Prerequisites
122+
123+
- Docker installed on your machine
124+
- Lume server running on your host (port 7777): `lume serve`
125+
126+
### Setup and Usage
127+
128+
1. Build the development Docker image:
129+
130+
```bash
131+
./scripts/run-docker-dev.sh build
132+
```
133+
134+
2. Run an example in the container:
135+
136+
```bash
137+
./scripts/run-docker-dev.sh run computer_examples.py
138+
```
139+
140+
3. Get an interactive shell in the container:
141+
142+
```bash
143+
./scripts/run-docker-dev.sh run --interactive
144+
```
145+
146+
4. Stop any running containers:
147+
148+
```bash
149+
./scripts/run-docker-dev.sh stop
150+
```
151+
152+
### How it Works
153+
154+
The Docker development environment:
155+
156+
- Installs all required Python dependencies in the container
157+
- Mounts your source code from the host at runtime
158+
- Automatically configures the connection to use host.docker.internal:7777 for accessing the Lume server on your host machine
159+
- Preserves your code changes without requiring rebuilds (source code is mounted as a volume)
160+
161+
> **Note**: The Docker container doesn't include the macOS-specific Lume executable. Instead, it connects to the Lume server running on your host machine via host.docker.internal:7777. Make sure to start the Lume server on your host before running examples in the container.
162+
163+
## Cleanup and Reset
164+
165+
If you need to clean up the environment (non-docker) and start fresh:
166+
167+
```bash
168+
./scripts/cleanup.sh
169+
```
170+
171+
This will:
172+
173+
- Remove all virtual environments
174+
- Clean Python cache files and directories
175+
- Remove build artifacts
176+
- Clean PDM-related files
177+
- Reset environment configurations
178+
179+
## Code Formatting Standards
180+
181+
The cua project follows strict code formatting standards to ensure consistency across all packages.
182+
183+
### Python Code Formatting
184+
185+
#### Tools
186+
187+
The project uses the following tools for code formatting and linting:
188+
189+
- **[Black](https://black.readthedocs.io/)**: Code formatter
190+
- **[Ruff](https://beta.ruff.rs/docs/)**: Fast linter and formatter
191+
- **[MyPy](https://mypy.readthedocs.io/)**: Static type checker
192+
193+
These tools are automatically installed when you set up the development environment using the `./scripts/build.sh` script.
194+
195+
#### Configuration
196+
197+
The formatting configuration is defined in the root `pyproject.toml` file:
198+
199+
```toml
200+
[tool.black]
201+
line-length = 100
202+
target-version = ["py311"]
203+
204+
[tool.ruff]
205+
line-length = 100
206+
target-version = "py311"
207+
select = ["E", "F", "B", "I"]
208+
fix = true
209+
210+
[tool.ruff.format]
211+
docstring-code-format = true
212+
213+
[tool.mypy]
214+
strict = true
215+
python_version = "3.11"
216+
ignore_missing_imports = true
217+
disallow_untyped_defs = true
218+
check_untyped_defs = true
219+
warn_return_any = true
220+
show_error_codes = true
221+
warn_unused_ignores = false
222+
```
223+
224+
#### Key Formatting Rules
225+
226+
- **Line Length**: Maximum of 100 characters
227+
- **Python Version**: Code should be compatible with Python 3.11+
228+
- **Imports**: Automatically sorted (using Ruff's "I" rule)
229+
- **Type Hints**: Required for all function definitions (strict mypy mode)
230+
231+
#### IDE Integration
232+
233+
The repository includes VSCode workspace configurations that enable automatic formatting. When you open the workspace files (as recommended in the setup instructions), the correct formatting settings are automatically applied.
234+
235+
Python-specific settings in the workspace files:
236+
237+
```json
238+
"[python]": {
239+
"editor.formatOnSave": true,
240+
"editor.defaultFormatter": "ms-python.black-formatter",
241+
"editor.codeActionsOnSave": {
242+
"source.organizeImports": "explicit"
243+
}
244+
}
245+
```
246+
247+
Recommended VS Code extensions:
248+
249+
- Black Formatter (ms-python.black-formatter)
250+
- Ruff (charliermarsh.ruff)
251+
- Pylance (ms-python.vscode-pylance)
252+
253+
#### Manual Formatting
254+
255+
To manually format code:
256+
257+
```bash
258+
# Format all Python files using Black
259+
pdm run black .
260+
261+
# Run Ruff linter with auto-fix
262+
pdm run ruff check --fix .
263+
264+
# Run type checking with MyPy
265+
pdm run mypy .
266+
```
267+
268+
#### Pre-commit Validation
269+
270+
Before submitting a pull request, ensure your code passes all formatting checks:
271+
272+
```bash
273+
# Run all checks
274+
pdm run black --check .
275+
pdm run ruff check .
276+
pdm run mypy .
277+
```
278+
279+
### Swift Code (Lume)
280+
281+
For Swift code in the `libs/lume` directory:
282+
283+
- Follow the [Swift API Design Guidelines](https://www.swift.org/documentation/api-design-guidelines/)
284+
- Use SwiftFormat for consistent formatting
285+
- Code will be automatically formatted on save when using the lume workspace

0 commit comments

Comments
 (0)