Skip to content

Commit ede0beb

Browse files
committed
GitHub stuff
1 parent 33f1bb7 commit ede0beb

2 files changed

Lines changed: 221 additions & 0 deletions

File tree

.github/copilot-instructions.md

Lines changed: 162 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,162 @@
1+
# CodeBox-AI Development Guide
2+
3+
This guide contains instructions for developing, building, and testing the CodeBox-AI project using uv's native commands.
4+
5+
## Build Commands
6+
7+
### Environment Setup
8+
- Create virtual environment: `uv venv`
9+
- Activate virtual environment:
10+
- Unix/MacOS: `source .venv/bin/activate`
11+
- Windows: `.venv\Scripts\activate`
12+
- Install all dependencies: `uv sync`
13+
- Install with dev dependencies: `uv sync --extra dev`
14+
- Install with specific extras: `uv sync --extra "dev docs"` or `uv sync --extra "dev docs examples"`
15+
16+
### Running the Application
17+
18+
#### Standard Server
19+
```bash
20+
uv run -m codeboxai.main
21+
```
22+
23+
#### MCP Server Options
24+
- Standalone MCP server (for Claude Desktop):
25+
```bash
26+
uv run mcp dev mcp_server.py
27+
```
28+
29+
- Register with Claude Desktop:
30+
```bash
31+
uv run mcp install mcp_server.py --name "CodeBox-AI"
32+
```
33+
34+
- Combined FastAPI + MCP server:
35+
```bash
36+
uv run run.py
37+
```
38+
39+
- MCP server only:
40+
```bash
41+
uv run run.py --mode mcp
42+
```
43+
44+
### Testing
45+
- Run all tests: `uv run -m pytest`
46+
- Run single test: `uv run -m pytest tests/path/to/test.py::test_function_name -v`
47+
- Run tests with coverage: `uv run -m pytest --cov=codeboxai`
48+
- Generate coverage report: `uv run -m pytest --cov=codeboxai --cov-report=html`
49+
50+
### Linting and Code Quality
51+
- Run all code quality checks: `uv run pre-commit run --all-files`
52+
- Individual checks:
53+
- Format code: `uv run -m black .`
54+
- Check imports: `uv run -m isort .`
55+
- Lint code: `uv run -m flake8`
56+
- Type checking: `uv run -m mypy .`
57+
58+
### Project Management
59+
- Add a dependency: `uv add <package-name>`
60+
- Remove a dependency: `uv remove <package-name>`
61+
- Lock dependencies: `uv lock`
62+
- View dependency tree: `uv tree`
63+
64+
### Building and Publishing
65+
- Build package: `uv run -m build`
66+
- Publish package: `uv publish`
67+
68+
## Code Style Guidelines
69+
70+
### Imports
71+
- Group in order: stdlib, third-party, local
72+
- Sort alphabetically within groups
73+
- Use `isort` for automatic sorting
74+
75+
### Formatting
76+
- Use `black` for code formatting with default settings (line length 120 as configured in pyproject.toml)
77+
- Ensure consistent indentation (4 spaces)
78+
79+
### Type Annotations
80+
- Use type hints for all function parameters and return values
81+
- Use `mypy` for type checking
82+
83+
### Naming Conventions
84+
- `snake_case` for functions and variables
85+
- `CamelCase` for classes
86+
- `UPPER_CASE` for constants
87+
88+
### Error Handling
89+
- Use specific exceptions with meaningful error messages
90+
- Log errors with appropriate level (error, warning, info)
91+
- Handle exceptions at appropriate levels
92+
93+
### Docstrings
94+
- Use Google-style docstrings with Args/Returns sections:
95+
```python
96+
def function(param1: str, param2: int) -> bool:
97+
"""Short description.
98+
99+
Longer description if needed.
100+
101+
Args:
102+
param1: Description of first parameter
103+
param2: Description of second parameter
104+
105+
Returns:
106+
Description of return value
107+
108+
Raises:
109+
ExceptionType: When and why this exception is raised
110+
"""
111+
```
112+
113+
### Validation
114+
- Use Pydantic validators for input validation
115+
- Follow existing validation patterns
116+
117+
### Security
118+
- Ensure all user inputs are properly validated and sanitized
119+
- Use security best practices for Docker container isolation
120+
121+
### Testing
122+
- Write pytest tests for all new functionality
123+
- Aim for high test coverage, especially for security-critical code
124+
- Write both unit tests and integration tests where appropriate
125+
126+
## Example Workflow
127+
128+
1. Create and activate environment:
129+
```bash
130+
uv venv
131+
source .venv/bin/activate # or .venv\Scripts\activate on Windows
132+
```
133+
134+
2. Install dependencies with development extras:
135+
```bash
136+
uv sync --extra "dev docs"
137+
```
138+
139+
3. Run pre-commit to set up git hooks:
140+
```bash
141+
uv run pre-commit install
142+
```
143+
144+
4. Make your code changes
145+
146+
5. Run tests to verify changes:
147+
```bash
148+
uv run -m pytest
149+
```
150+
151+
6. Check code quality:
152+
```bash
153+
uv run -m black .
154+
uv run -m isort .
155+
uv run -m flake8
156+
uv run -m mypy .
157+
```
158+
159+
7. Run the server locally:
160+
```bash
161+
uv run -m codeboxai.main
162+
```

.github/workflows/ci.yml

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
branches: [main]
8+
9+
jobs:
10+
build-test-lint:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- name: Checkout code
14+
uses: actions/checkout@v4
15+
16+
- name: Set up Python
17+
uses: actions/setup-python@v5
18+
with:
19+
python-version: '3.12'
20+
21+
- name: Install uv
22+
run: pip install uv
23+
24+
- name: Set up cache for uv
25+
uses: actions/cache@v4
26+
with:
27+
path: .venv
28+
key: ${{ runner.os }}-venv-${{ hashFiles('pyproject.toml', 'uv.lock') }}
29+
restore-keys: |
30+
${{ runner.os }}-venv-
31+
32+
- name: Create and activate virtualenv
33+
run: |
34+
uv venv
35+
source .venv/bin/activate
36+
37+
- name: Install dependencies (dev, docs)
38+
run: uv sync --extra "dev docs"
39+
40+
- name: Check formatting (black)
41+
run: uv run -m black . --check
42+
43+
- name: Check imports (isort)
44+
run: uv run -m isort . --check-only
45+
46+
- name: Lint code (flake8)
47+
run: uv run -m flake8
48+
49+
- name: Type checking (mypy)
50+
run: uv run -m mypy .
51+
52+
- name: Run tests with coverage
53+
run: uv run -m pytest --cov=codeboxai --cov-report=term --cov-report=term-missing --cov-report=xml
54+
55+
- name: Display coverage summary in workflow
56+
if: always()
57+
run: |
58+
echo '### Coverage Report' >> $GITHUB_STEP_SUMMARY
59+
uv run -m coverage report >> $GITHUB_STEP_SUMMARY

0 commit comments

Comments
 (0)