From e48b7c9961c88e08752c2dbdc9637b98e9067d03 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 7 Feb 2026 11:18:31 +0000 Subject: [PATCH 1/7] Initial plan From f871b56fa81bd06d0e65023a08172272b7d508ce Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 7 Feb 2026 11:21:17 +0000 Subject: [PATCH 2/7] Set up monorepo structure with packages Co-authored-by: TYH71 <64251764+TYH71@users.noreply.github.com> --- Makefile | 36 +++++++++++++++ README.md | 83 ++++++++++++++++++++++++++++++++++- packages/api/README.md | 15 +++++++ packages/api/__init__.py | 6 +++ packages/api/pyproject.toml | 19 ++++++++ packages/core/README.md | 15 +++++++ packages/core/__init__.py | 6 +++ packages/core/pyproject.toml | 19 ++++++++ packages/utils/README.md | 15 +++++++ packages/utils/__init__.py | 6 +++ packages/utils/pyproject.toml | 19 ++++++++ pyproject.toml | 44 +++++++++++++++++++ scripts/install-all.sh | 15 +++++++ 13 files changed, 297 insertions(+), 1 deletion(-) create mode 100644 Makefile create mode 100644 packages/api/README.md create mode 100644 packages/api/__init__.py create mode 100644 packages/api/pyproject.toml create mode 100644 packages/core/README.md create mode 100644 packages/core/__init__.py create mode 100644 packages/core/pyproject.toml create mode 100644 packages/utils/README.md create mode 100644 packages/utils/__init__.py create mode 100644 packages/utils/pyproject.toml create mode 100644 pyproject.toml create mode 100755 scripts/install-all.sh diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..904ce51 --- /dev/null +++ b/Makefile @@ -0,0 +1,36 @@ +.PHONY: help install install-dev clean test lint format + +help: +@echo "ModPocket Monorepo Commands:" +@echo " make install - Install all packages" +@echo " make install-dev - Install all packages in development mode with dev dependencies" +@echo " make clean - Clean build artifacts" +@echo " make test - Run tests for all packages" +@echo " make lint - Lint all packages" +@echo " make format - Format all packages" + +install: +pip install -e packages/core +pip install -e packages/utils +pip install -e packages/api + +install-dev: +pip install -e packages/core[dev] +pip install -e packages/utils[dev] +pip install -e packages/api[dev] + +clean: +find . -type d -name "__pycache__" -exec rm -rf {} + 2>/dev/null || true +find . -type d -name "*.egg-info" -exec rm -rf {} + 2>/dev/null || true +find . -type d -name ".pytest_cache" -exec rm -rf {} + 2>/dev/null || true +find . -type d -name ".ruff_cache" -exec rm -rf {} + 2>/dev/null || true +find . -type f -name "*.pyc" -delete + +test: +pytest packages/ + +lint: +ruff check packages/ + +format: +ruff format packages/ diff --git a/README.md b/README.md index 7336825..dbfda33 100644 --- a/README.md +++ b/README.md @@ -1 +1,82 @@ -# ModPocket \ No newline at end of file +# ModPocket + +A Python monorepo project organized with multiple packages. + +## Structure + +This repository is organized as a monorepo with the following structure: + +``` +ModPocket/ +├── packages/ +│ ├── core/ # Core functionality +│ ├── utils/ # Utility functions +│ └── api/ # API interfaces +├── pyproject.toml # Root configuration +└── README.md # This file +``` + +## Packages + +- **core**: Core functionality for ModPocket +- **utils**: Utility functions and helpers +- **api**: API interfaces and endpoints + +## Installation + +### Installing all packages in development mode + +```bash +pip install -e packages/core +pip install -e packages/utils +pip install -e packages/api +``` + +### Installing individual packages + +You can install individual packages as needed: + +```bash +pip install -e packages/core +``` + +## Development + +### Setting up development environment + +1. Clone the repository: +```bash +git clone https://github.com/TYH71/ModPocket.git +cd ModPocket +``` + +2. Install packages in development mode: +```bash +pip install -e packages/core[dev] +pip install -e packages/utils[dev] +pip install -e packages/api[dev] +``` + +### Running tests + +```bash +pytest packages/ +``` + +### Code formatting and linting + +```bash +ruff check packages/ +ruff format packages/ +``` + +## Contributing + +1. Create a new branch for your feature +2. Make your changes in the appropriate package +3. Ensure tests pass +4. Submit a pull request + +## License + +See LICENSE file for details. \ No newline at end of file diff --git a/packages/api/README.md b/packages/api/README.md new file mode 100644 index 0000000..cf54472 --- /dev/null +++ b/packages/api/README.md @@ -0,0 +1,15 @@ +# ModPocket API + +API interfaces and endpoints for the ModPocket project. + +## Installation + +```bash +pip install -e packages/api +``` + +## Usage + +```python +import modpocket_api +``` diff --git a/packages/api/__init__.py b/packages/api/__init__.py new file mode 100644 index 0000000..fc6e237 --- /dev/null +++ b/packages/api/__init__.py @@ -0,0 +1,6 @@ +"""ModPocket API Package. + +API interfaces and endpoints for ModPocket. +""" + +__version__ = "0.1.0" diff --git a/packages/api/pyproject.toml b/packages/api/pyproject.toml new file mode 100644 index 0000000..3a9c14a --- /dev/null +++ b/packages/api/pyproject.toml @@ -0,0 +1,19 @@ +[build-system] +requires = ["hatchling"] +build-backend = "hatchling.build" + +[project] +name = "modpocket-api" +version = "0.1.0" +description = "API interfaces for ModPocket" +readme = "README.md" +requires-python = ">=3.8" +authors = [ + {name = "ModPocket Team"} +] + +[project.optional-dependencies] +dev = [ + "pytest>=7.0.0", + "ruff>=0.1.0", +] diff --git a/packages/core/README.md b/packages/core/README.md new file mode 100644 index 0000000..0035284 --- /dev/null +++ b/packages/core/README.md @@ -0,0 +1,15 @@ +# ModPocket Core + +Core functionality for the ModPocket project. + +## Installation + +```bash +pip install -e packages/core +``` + +## Usage + +```python +import modpocket_core +``` diff --git a/packages/core/__init__.py b/packages/core/__init__.py new file mode 100644 index 0000000..4a2aa3f --- /dev/null +++ b/packages/core/__init__.py @@ -0,0 +1,6 @@ +"""ModPocket Core Package. + +This is the core package of the ModPocket monorepo. +""" + +__version__ = "0.1.0" diff --git a/packages/core/pyproject.toml b/packages/core/pyproject.toml new file mode 100644 index 0000000..9af90a8 --- /dev/null +++ b/packages/core/pyproject.toml @@ -0,0 +1,19 @@ +[build-system] +requires = ["hatchling"] +build-backend = "hatchling.build" + +[project] +name = "modpocket-core" +version = "0.1.0" +description = "Core functionality for ModPocket" +readme = "README.md" +requires-python = ">=3.8" +authors = [ + {name = "ModPocket Team"} +] + +[project.optional-dependencies] +dev = [ + "pytest>=7.0.0", + "ruff>=0.1.0", +] diff --git a/packages/utils/README.md b/packages/utils/README.md new file mode 100644 index 0000000..afc6c1d --- /dev/null +++ b/packages/utils/README.md @@ -0,0 +1,15 @@ +# ModPocket Utils + +Utility functions and helpers for the ModPocket project. + +## Installation + +```bash +pip install -e packages/utils +``` + +## Usage + +```python +import modpocket_utils +``` diff --git a/packages/utils/__init__.py b/packages/utils/__init__.py new file mode 100644 index 0000000..c9b2405 --- /dev/null +++ b/packages/utils/__init__.py @@ -0,0 +1,6 @@ +"""ModPocket Utils Package. + +Utility functions and helpers for ModPocket. +""" + +__version__ = "0.1.0" diff --git a/packages/utils/pyproject.toml b/packages/utils/pyproject.toml new file mode 100644 index 0000000..b057611 --- /dev/null +++ b/packages/utils/pyproject.toml @@ -0,0 +1,19 @@ +[build-system] +requires = ["hatchling"] +build-backend = "hatchling.build" + +[project] +name = "modpocket-utils" +version = "0.1.0" +description = "Utility functions for ModPocket" +readme = "README.md" +requires-python = ">=3.8" +authors = [ + {name = "ModPocket Team"} +] + +[project.optional-dependencies] +dev = [ + "pytest>=7.0.0", + "ruff>=0.1.0", +] diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..7f16577 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,44 @@ +[build-system] +requires = ["hatchling"] +build-backend = "hatchling.build" + +[project] +name = "modpocket" +version = "0.1.0" +description = "ModPocket - A Python monorepo project" +readme = "README.md" +requires-python = ">=3.8" +authors = [ + {name = "ModPocket Team"} +] +classifiers = [ + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.8", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", +] + +[tool.hatch.build.targets.wheel] +packages = ["packages"] + +[tool.pytest.ini_options] +testpaths = ["packages"] +python_files = ["test_*.py", "*_test.py"] +python_classes = ["Test*"] +python_functions = ["test_*"] + +[tool.ruff] +line-length = 100 +target-version = "py38" + +[tool.ruff.lint] +select = ["E", "F", "W", "I", "N"] +ignore = [] + +[tool.mypy] +python_version = "3.8" +warn_return_any = true +warn_unused_configs = true +disallow_untyped_defs = false diff --git a/scripts/install-all.sh b/scripts/install-all.sh new file mode 100755 index 0000000..20ee29d --- /dev/null +++ b/scripts/install-all.sh @@ -0,0 +1,15 @@ +#!/bin/bash +# Install all packages in the monorepo + +set -e + +echo "Installing ModPocket packages..." + +for package in packages/*; do + if [ -d "$package" ]; then + echo "Installing $package..." + pip install -e "$package[dev]" + fi +done + +echo "All packages installed successfully!" From d9331e85c15a7ba1bf40020ead80c6c7d63a0331 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 7 Feb 2026 11:23:00 +0000 Subject: [PATCH 3/7] Fix package structure for proper installation Co-authored-by: TYH71 <64251764+TYH71@users.noreply.github.com> --- Makefile | 42 +++++++++---------- packages/api/{ => modpocket_api}/__init__.py | 0 .../core/{ => modpocket_core}/__init__.py | 0 .../utils/{ => modpocket_utils}/__init__.py | 0 4 files changed, 21 insertions(+), 21 deletions(-) rename packages/api/{ => modpocket_api}/__init__.py (100%) rename packages/core/{ => modpocket_core}/__init__.py (100%) rename packages/utils/{ => modpocket_utils}/__init__.py (100%) diff --git a/Makefile b/Makefile index 904ce51..fa73e12 100644 --- a/Makefile +++ b/Makefile @@ -1,36 +1,36 @@ .PHONY: help install install-dev clean test lint format help: -@echo "ModPocket Monorepo Commands:" -@echo " make install - Install all packages" -@echo " make install-dev - Install all packages in development mode with dev dependencies" -@echo " make clean - Clean build artifacts" -@echo " make test - Run tests for all packages" -@echo " make lint - Lint all packages" -@echo " make format - Format all packages" + @echo "ModPocket Monorepo Commands:" + @echo " make install - Install all packages" + @echo " make install-dev - Install all packages in development mode with dev dependencies" + @echo " make clean - Clean build artifacts" + @echo " make test - Run tests for all packages" + @echo " make lint - Lint all packages" + @echo " make format - Format all packages" install: -pip install -e packages/core -pip install -e packages/utils -pip install -e packages/api + pip install -e packages/core + pip install -e packages/utils + pip install -e packages/api install-dev: -pip install -e packages/core[dev] -pip install -e packages/utils[dev] -pip install -e packages/api[dev] + pip install -e packages/core[dev] + pip install -e packages/utils[dev] + pip install -e packages/api[dev] clean: -find . -type d -name "__pycache__" -exec rm -rf {} + 2>/dev/null || true -find . -type d -name "*.egg-info" -exec rm -rf {} + 2>/dev/null || true -find . -type d -name ".pytest_cache" -exec rm -rf {} + 2>/dev/null || true -find . -type d -name ".ruff_cache" -exec rm -rf {} + 2>/dev/null || true -find . -type f -name "*.pyc" -delete + find . -type d -name "__pycache__" -exec rm -rf {} + 2>/dev/null || true + find . -type d -name "*.egg-info" -exec rm -rf {} + 2>/dev/null || true + find . -type d -name ".pytest_cache" -exec rm -rf {} + 2>/dev/null || true + find . -type d -name ".ruff_cache" -exec rm -rf {} + 2>/dev/null || true + find . -type f -name "*.pyc" -delete test: -pytest packages/ + pytest packages/ lint: -ruff check packages/ + ruff check packages/ format: -ruff format packages/ + ruff format packages/ diff --git a/packages/api/__init__.py b/packages/api/modpocket_api/__init__.py similarity index 100% rename from packages/api/__init__.py rename to packages/api/modpocket_api/__init__.py diff --git a/packages/core/__init__.py b/packages/core/modpocket_core/__init__.py similarity index 100% rename from packages/core/__init__.py rename to packages/core/modpocket_core/__init__.py diff --git a/packages/utils/__init__.py b/packages/utils/modpocket_utils/__init__.py similarity index 100% rename from packages/utils/__init__.py rename to packages/utils/modpocket_utils/__init__.py From e942a100b41289ee43aeef18017bb7e1b829e4ba Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 7 Feb 2026 11:25:50 +0000 Subject: [PATCH 4/7] Add documentation, examples, tests, and CI workflow Co-authored-by: TYH71 <64251764+TYH71@users.noreply.github.com> --- .github/workflows/ci.yml | 55 +++++++ CONTRIBUTING.md | 115 ++++++++++++++ MONOREPO.md | 177 ++++++++++++++++++++++ Makefile | 4 +- packages/api/modpocket_api/endpoints.py | 39 +++++ packages/api/tests/__init__.py | 0 packages/api/tests/test_endpoints.py | 25 +++ packages/core/modpocket_core/example.py | 26 ++++ packages/core/tests/__init__.py | 0 packages/core/tests/test_example.py | 18 +++ packages/utils/modpocket_utils/helpers.py | 30 ++++ packages/utils/tests/__init__.py | 0 packages/utils/tests/test_helpers.py | 18 +++ pyproject.toml | 2 +- 14 files changed, 507 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/ci.yml create mode 100644 CONTRIBUTING.md create mode 100644 MONOREPO.md create mode 100644 packages/api/modpocket_api/endpoints.py create mode 100644 packages/api/tests/__init__.py create mode 100644 packages/api/tests/test_endpoints.py create mode 100644 packages/core/modpocket_core/example.py create mode 100644 packages/core/tests/__init__.py create mode 100644 packages/core/tests/test_example.py create mode 100644 packages/utils/modpocket_utils/helpers.py create mode 100644 packages/utils/tests/__init__.py create mode 100644 packages/utils/tests/test_helpers.py diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..9b51b8e --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,55 @@ +name: CI + +on: + push: + branches: [ main ] + pull_request: + branches: [ main ] + +jobs: + test: + runs-on: ubuntu-latest + strategy: + matrix: + python-version: ['3.8', '3.9', '3.10', '3.11', '3.12'] + + steps: + - uses: actions/checkout@v4 + + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v5 + with: + python-version: ${{ matrix.python-version }} + + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install -e packages/core[dev] + pip install -e packages/utils[dev] + pip install -e packages/api[dev] + + - name: Lint with ruff + run: | + pip install ruff + make lint + + - name: Test with pytest + run: | + pip install pytest pytest-cov + make test + + format-check: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: '3.12' + + - name: Check formatting with ruff + run: | + pip install ruff + ruff format --check packages/ diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000..3b24a96 --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,115 @@ +# Contributing to ModPocket + +Thank you for your interest in contributing to ModPocket! This document provides guidelines for contributing to this monorepo project. + +## Getting Started + +1. Fork the repository +2. Clone your fork: + ```bash + git clone https://github.com/YOUR_USERNAME/ModPocket.git + cd ModPocket + ``` +3. Install all packages in development mode: + ```bash + make install-dev + ``` + +## Development Workflow + +### Making Changes + +1. Create a new branch: + ```bash + git checkout -b feature/your-feature-name + ``` + +2. Make your changes in the appropriate package(s) + +3. Test your changes: + ```bash + make test + ``` + +4. Lint and format your code: + ```bash + make format + make lint + ``` + +5. Commit your changes: + ```bash + git add . + git commit -m "Description of your changes" + ``` + +6. Push to your fork: + ```bash + git push origin feature/your-feature-name + ``` + +7. Open a Pull Request + +### Code Style + +- Follow PEP 8 guidelines +- Use ruff for linting and formatting +- Add docstrings to all public functions and classes +- Keep functions focused and small + +### Testing + +- Write tests for all new features +- Ensure all tests pass before submitting a PR +- Aim for high test coverage + +### Commit Messages + +- Use clear, descriptive commit messages +- Start with a verb in present tense (Add, Fix, Update, etc.) +- Reference issue numbers when applicable + +Example: +``` +Add user authentication feature to API package + +- Implement JWT token generation +- Add login and logout endpoints +- Update tests + +Fixes #123 +``` + +## Package-Specific Guidelines + +### Core Package +- Contains fundamental functionality used by other packages +- Should have minimal external dependencies +- Changes here may affect all other packages + +### Utils Package +- Utility functions and helpers +- Should be stateless and pure when possible +- Well-documented with usage examples + +### API Package +- API interfaces and endpoints +- Should follow RESTful conventions +- Include comprehensive API documentation + +## Pull Request Process + +1. Update documentation to reflect changes +2. Add tests for new functionality +3. Ensure all tests pass +4. Update the package version if applicable +5. Request review from maintainers + +## Questions or Issues? + +- Open an issue for bugs or feature requests +- Use discussions for questions and general conversation + +## License + +By contributing, you agree that your contributions will be licensed under the same license as the project. diff --git a/MONOREPO.md b/MONOREPO.md new file mode 100644 index 0000000..11a61dc --- /dev/null +++ b/MONOREPO.md @@ -0,0 +1,177 @@ +# ModPocket Monorepo Structure + +This document explains the monorepo structure and how to work with it. + +## What is a Monorepo? + +A monorepo (monolithic repository) is a software development strategy where code for many projects is stored in the same repository. This approach offers several benefits: + +- **Code Sharing**: Easy to share code between packages +- **Atomic Changes**: Make changes across multiple packages in a single commit +- **Unified Versioning**: Manage versions consistently across packages +- **Simplified Dependency Management**: All packages use the same dependency versions + +## Repository Structure + +``` +ModPocket/ +├── packages/ # All packages live here +│ ├── core/ # Core functionality +│ │ ├── modpocket_core/ # Python package +│ │ ├── pyproject.toml # Package config +│ │ └── README.md # Package docs +│ ├── utils/ # Utility functions +│ │ ├── modpocket_utils/ +│ │ ├── pyproject.toml +│ │ └── README.md +│ └── api/ # API interfaces +│ ├── modpocket_api/ +│ ├── pyproject.toml +│ └── README.md +├── scripts/ # Helper scripts +│ └── install-all.sh # Install all packages +├── pyproject.toml # Root configuration +├── Makefile # Common tasks +└── README.md # Main documentation +``` + +## Working with the Monorepo + +### Installing Packages + +**Install all packages in development mode:** +```bash +make install-dev +``` + +Or use the installation script: +```bash +./scripts/install-all.sh +``` + +**Install individual packages:** +```bash +pip install -e packages/core[dev] +pip install -e packages/utils[dev] +pip install -e packages/api[dev] +``` + +### Available Make Commands + +- `make help` - Show available commands +- `make install` - Install all packages +- `make install-dev` - Install all packages with dev dependencies +- `make clean` - Remove build artifacts +- `make test` - Run tests for all packages +- `make lint` - Lint all packages with ruff +- `make format` - Format all packages with ruff + +### Adding a New Package + +1. Create a new directory under `packages/`: +```bash +mkdir -p packages/newpackage/modpocket_newpackage +``` + +2. Create the package's `__init__.py`: +```python +"""ModPocket New Package.""" + +__version__ = "0.1.0" +``` + +3. Create `pyproject.toml`: +```toml +[build-system] +requires = ["hatchling"] +build-backend = "hatchling.build" + +[project] +name = "modpocket-newpackage" +version = "0.1.0" +description = "Description of the new package" +readme = "README.md" +requires-python = ">=3.8" +authors = [ + {name = "ModPocket Team"} +] + +[project.optional-dependencies] +dev = [ + "pytest>=7.0.0", + "ruff>=0.1.0", +] +``` + +4. Create a `README.md` for the package + +5. Update the root `Makefile` to include the new package + +6. Install the package: +```bash +pip install -e packages/newpackage[dev] +``` + +### Cross-Package Dependencies + +To use one package in another, add it as a dependency in the `pyproject.toml`: + +```toml +[project] +dependencies = [ + "modpocket-core>=0.1.0", +] +``` + +Then install both packages in development mode: +```bash +pip install -e packages/core +pip install -e packages/dependent-package +``` + +### Testing + +Run tests for all packages: +```bash +make test +``` + +Or run tests for a specific package: +```bash +pytest packages/core/ +``` + +### Code Quality + +**Linting:** +```bash +make lint +``` + +**Formatting:** +```bash +make format +``` + +## Best Practices + +1. **Keep packages focused**: Each package should have a single, well-defined purpose +2. **Minimize cross-package dependencies**: Reduces coupling and makes packages more reusable +3. **Use consistent naming**: Follow the `modpocket_*` naming convention +4. **Document changes**: Update package READMEs when adding new features +5. **Test thoroughly**: Ensure changes don't break other packages +6. **Version together**: Consider versioning all packages together for simplicity + +## Troubleshooting + +**Import errors after installation:** +- Ensure you're in the correct virtual environment +- Try reinstalling the package: `pip install -e packages/packagename --force-reinstall` + +**Make commands fail:** +- Ensure you have all required dependencies installed +- Check that you're in the repository root directory + +**Package not found:** +- Verify the package structure matches the expected format +- Check that the package name in `pyproject.toml` matches the directory name diff --git a/Makefile b/Makefile index fa73e12..66c7541 100644 --- a/Makefile +++ b/Makefile @@ -27,7 +27,9 @@ clean: find . -type f -name "*.pyc" -delete test: - pytest packages/ + pytest packages/core/tests -v + pytest packages/utils/tests -v + pytest packages/api/tests -v lint: ruff check packages/ diff --git a/packages/api/modpocket_api/endpoints.py b/packages/api/modpocket_api/endpoints.py new file mode 100644 index 0000000..b8aacc8 --- /dev/null +++ b/packages/api/modpocket_api/endpoints.py @@ -0,0 +1,39 @@ +"""API endpoint definitions.""" + + +class APIEndpoint: + """Base class for API endpoints.""" + + def __init__(self, path: str, method: str = "GET"): + """Initialize an API endpoint. + + Args: + path: The endpoint path + method: HTTP method (GET, POST, etc.) + """ + self.path = path + self.method = method + + def url(self, base_url: str = "") -> str: + """Get the full URL for this endpoint. + + Args: + base_url: Base URL to prepend + + Returns: + Full endpoint URL + """ + return f"{base_url}{self.path}" + + +def create_endpoint(path: str, method: str = "GET") -> APIEndpoint: + """Factory function to create an API endpoint. + + Args: + path: The endpoint path + method: HTTP method + + Returns: + APIEndpoint instance + """ + return APIEndpoint(path, method) diff --git a/packages/api/tests/__init__.py b/packages/api/tests/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/packages/api/tests/test_endpoints.py b/packages/api/tests/test_endpoints.py new file mode 100644 index 0000000..3ba1036 --- /dev/null +++ b/packages/api/tests/test_endpoints.py @@ -0,0 +1,25 @@ +"""Tests for endpoints module.""" + +from modpocket_api.endpoints import APIEndpoint, create_endpoint + + +def test_api_endpoint_init(): + """Test APIEndpoint initialization.""" + endpoint = APIEndpoint("/users", "GET") + assert endpoint.path == "/users" + assert endpoint.method == "GET" + + +def test_api_endpoint_url(): + """Test APIEndpoint url method.""" + endpoint = APIEndpoint("/users") + assert endpoint.url() == "/users" + assert endpoint.url("https://api.example.com") == "https://api.example.com/users" + + +def test_create_endpoint(): + """Test create_endpoint factory function.""" + endpoint = create_endpoint("/posts", "POST") + assert isinstance(endpoint, APIEndpoint) + assert endpoint.path == "/posts" + assert endpoint.method == "POST" diff --git a/packages/core/modpocket_core/example.py b/packages/core/modpocket_core/example.py new file mode 100644 index 0000000..14edb25 --- /dev/null +++ b/packages/core/modpocket_core/example.py @@ -0,0 +1,26 @@ +"""Example functionality for the core package.""" + + +def greet(name: str) -> str: + """Return a greeting message. + + Args: + name: The name to greet + + Returns: + A greeting string + """ + return f"Hello, {name}! Welcome to ModPocket Core." + + +def calculate_sum(a: int, b: int) -> int: + """Calculate the sum of two numbers. + + Args: + a: First number + b: Second number + + Returns: + The sum of a and b + """ + return a + b diff --git a/packages/core/tests/__init__.py b/packages/core/tests/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/packages/core/tests/test_example.py b/packages/core/tests/test_example.py new file mode 100644 index 0000000..32f19df --- /dev/null +++ b/packages/core/tests/test_example.py @@ -0,0 +1,18 @@ +"""Tests for example module.""" + +from modpocket_core.example import greet, calculate_sum + + +def test_greet(): + """Test the greet function.""" + result = greet("World") + assert result == "Hello, World! Welcome to ModPocket Core." + assert isinstance(result, str) + + +def test_calculate_sum(): + """Test the calculate_sum function.""" + assert calculate_sum(2, 3) == 5 + assert calculate_sum(0, 0) == 0 + assert calculate_sum(-1, 1) == 0 + assert calculate_sum(100, 200) == 300 diff --git a/packages/utils/modpocket_utils/helpers.py b/packages/utils/modpocket_utils/helpers.py new file mode 100644 index 0000000..a73fcbc --- /dev/null +++ b/packages/utils/modpocket_utils/helpers.py @@ -0,0 +1,30 @@ +"""Utility helper functions.""" + + +def format_text(text: str, uppercase: bool = False) -> str: + """Format text with optional uppercase conversion. + + Args: + text: The text to format + uppercase: Whether to convert to uppercase + + Returns: + Formatted text + """ + formatted = text.strip() + if uppercase: + formatted = formatted.upper() + return formatted + + +def chunk_list(lst: list, size: int) -> list: + """Split a list into chunks of specified size. + + Args: + lst: The list to chunk + size: Size of each chunk + + Returns: + List of chunks + """ + return [lst[i:i + size] for i in range(0, len(lst), size)] diff --git a/packages/utils/tests/__init__.py b/packages/utils/tests/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/packages/utils/tests/test_helpers.py b/packages/utils/tests/test_helpers.py new file mode 100644 index 0000000..6d8a0ae --- /dev/null +++ b/packages/utils/tests/test_helpers.py @@ -0,0 +1,18 @@ +"""Tests for helpers module.""" + +from modpocket_utils.helpers import format_text, chunk_list + + +def test_format_text(): + """Test the format_text function.""" + assert format_text(" hello ") == "hello" + assert format_text(" hello ", uppercase=True) == "HELLO" + assert format_text("test") == "test" + + +def test_chunk_list(): + """Test the chunk_list function.""" + assert chunk_list([1, 2, 3, 4, 5], 2) == [[1, 2], [3, 4], [5]] + assert chunk_list([1, 2, 3], 1) == [[1], [2], [3]] + assert chunk_list([], 2) == [] + assert chunk_list([1, 2, 3, 4], 4) == [[1, 2, 3, 4]] diff --git a/pyproject.toml b/pyproject.toml index 7f16577..45f3790 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -24,10 +24,10 @@ classifiers = [ packages = ["packages"] [tool.pytest.ini_options] -testpaths = ["packages"] python_files = ["test_*.py", "*_test.py"] python_classes = ["Test*"] python_functions = ["test_*"] +pythonpath = ["."] [tool.ruff] line-length = 100 From 875c0a15fa066785a6e260468d2d131c658c3bc3 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 7 Feb 2026 11:26:57 +0000 Subject: [PATCH 5/7] Fix code review issues in CI and install script Co-authored-by: TYH71 <64251764+TYH71@users.noreply.github.com> --- .github/workflows/ci.yml | 8 ++------ scripts/install-all.sh | 2 +- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9b51b8e..014b464 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -29,14 +29,10 @@ jobs: pip install -e packages/api[dev] - name: Lint with ruff - run: | - pip install ruff - make lint + run: make lint - name: Test with pytest - run: | - pip install pytest pytest-cov - make test + run: make test format-check: runs-on: ubuntu-latest diff --git a/scripts/install-all.sh b/scripts/install-all.sh index 20ee29d..a8f14c4 100755 --- a/scripts/install-all.sh +++ b/scripts/install-all.sh @@ -8,7 +8,7 @@ echo "Installing ModPocket packages..." for package in packages/*; do if [ -d "$package" ]; then echo "Installing $package..." - pip install -e "$package[dev]" + pip install -e "$package"[dev] fi done From a9d71b3e4226897e24ad8ff8c2eaabc14161f1a1 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 7 Feb 2026 11:28:42 +0000 Subject: [PATCH 6/7] Add permissions to GitHub Actions workflow for security Co-authored-by: TYH71 <64251764+TYH71@users.noreply.github.com> --- .github/workflows/ci.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 014b464..d5e67fd 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -9,6 +9,8 @@ on: jobs: test: runs-on: ubuntu-latest + permissions: + contents: read strategy: matrix: python-version: ['3.8', '3.9', '3.10', '3.11', '3.12'] @@ -36,6 +38,8 @@ jobs: format-check: runs-on: ubuntu-latest + permissions: + contents: read steps: - uses: actions/checkout@v4 From 4c84638a09750107c379019681cb06694bc626b5 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 7 Feb 2026 11:29:15 +0000 Subject: [PATCH 7/7] Add summary documentation for monorepo setup Co-authored-by: TYH71 <64251764+TYH71@users.noreply.github.com> --- SUMMARY.md | 122 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 122 insertions(+) create mode 100644 SUMMARY.md diff --git a/SUMMARY.md b/SUMMARY.md new file mode 100644 index 0000000..64e15c7 --- /dev/null +++ b/SUMMARY.md @@ -0,0 +1,122 @@ +# ModPocket Monorepo Setup Summary + +## What Was Built + +A complete Python monorepo structure for the ModPocket project with three packages: + +### Repository Structure + +``` +ModPocket/ +├── .github/ +│ └── workflows/ +│ └── ci.yml # GitHub Actions CI workflow +├── packages/ +│ ├── core/ # Core functionality package +│ │ ├── modpocket_core/ +│ │ │ ├── __init__.py +│ │ │ └── example.py +│ │ ├── tests/ +│ │ │ ├── __init__.py +│ │ │ └── test_example.py +│ │ ├── pyproject.toml +│ │ └── README.md +│ ├── utils/ # Utilities package +│ │ ├── modpocket_utils/ +│ │ │ ├── __init__.py +│ │ │ └── helpers.py +│ │ ├── tests/ +│ │ │ ├── __init__.py +│ │ │ └── test_helpers.py +│ │ ├── pyproject.toml +│ │ └── README.md +│ └── api/ # API package +│ ├── modpocket_api/ +│ │ ├── __init__.py +│ │ └── endpoints.py +│ ├── tests/ +│ │ ├── __init__.py +│ │ └── test_endpoints.py +│ ├── pyproject.toml +│ └── README.md +├── scripts/ +│ └── install-all.sh # Convenience installation script +├── .gitignore # Python gitignore +├── Makefile # Common development tasks +├── pyproject.toml # Root configuration +├── README.md # Main documentation +├── MONOREPO.md # Monorepo guide +└── CONTRIBUTING.md # Contributing guidelines +``` + +### Features Implemented + +1. **Three Python Packages**: + - `modpocket-core`: Core functionality + - `modpocket-utils`: Utility functions + - `modpocket-api`: API interfaces + +2. **Each Package Includes**: + - Proper package structure with `pyproject.toml` + - Example code demonstrating functionality + - Complete test suite + - Individual README documentation + +3. **Development Tools**: + - **Makefile** with commands: + - `make help` - Show available commands + - `make install` - Install all packages + - `make install-dev` - Install with dev dependencies + - `make clean` - Remove build artifacts + - `make test` - Run all tests + - `make lint` - Lint with ruff + - `make format` - Format with ruff + - **Installation script** for quick setup + +4. **Documentation**: + - Comprehensive README with setup instructions + - MONOREPO.md explaining monorepo concepts and workflows + - CONTRIBUTING.md with contribution guidelines + - Per-package documentation + +5. **Testing**: + - 7 tests across all 3 packages + - All tests passing + - pytest configured with proper settings + +6. **CI/CD**: + - GitHub Actions workflow configured + - Tests run on Python 3.8, 3.9, 3.10, 3.11, 3.12 + - Linting and formatting checks + - Proper security permissions configured + +7. **Code Quality**: + - Ruff for linting and formatting + - pytest for testing + - Type hints where appropriate + - Comprehensive docstrings + +### Verification + +All features have been tested and verified: +- ✅ All packages install correctly +- ✅ All packages can be imported +- ✅ All tests pass (7/7) +- ✅ Makefile commands work +- ✅ Installation script works +- ✅ Code review completed +- ✅ Security scan completed (0 vulnerabilities) + +## Getting Started + +To use this monorepo: + +1. Clone the repository +2. Install all packages: `make install-dev` +3. Run tests: `make test` +4. Start developing! + +For more information, see: +- README.md - Main project documentation +- MONOREPO.md - Monorepo concepts and workflows +- CONTRIBUTING.md - How to contribute