|
1 | 1 | # GroupWeave Monorepo - Agent & Developer Instructions |
2 | 2 |
|
3 | | -This document provides comprehensive instructions for developers and AI agents working on this monorepo. It is the single source of truth for repository setup, development workflows, and coding standards. Please read it carefully before contributing. |
4 | | - |
5 | | -## Overview |
6 | | -GroupWeave is the open-source infrastructure for user-owned AI, designed to enable co-creation and co-immersion in generative AI content. Currently developing on NEAR, with plans to integrate Shade agents as customizable, semi-autonomous assistants for multimodal content understanding, moderation, and curation. |
7 | | - |
8 | | -## Monorepo Tooling |
9 | | -### pnpm |
10 | | -Used for high-performance package management. All npm/yarn commands should be replaced with pnpm. |
11 | | - |
12 | | -### Turborepo |
13 | | -Used to manage tasks and build pipelines across the monorepo, enabling faster builds and development. |
14 | | - |
15 | | -## Global Commands |
16 | | -- `pnpm install`: Install all dependencies for all workspaces. |
17 | | -- `pnpm build`: Builds all apps and packages. |
18 | | -- `pnpm dev`: Runs all applications in development mode. Use with --filter to run a specific app. |
19 | | -- `pnpm lint`: Lints all apps and packages. |
20 | | -- `pnpm check-types`: Runs TypeScript type checking across all relevant packages. |
21 | | - |
22 | | -## Workspace Details |
23 | | -- **`apps/creation`**: A Next.js application for creating new GroupWeave content. |
24 | | -- **`apps/dashboard`**: A Next.js application for users to view and manage their content and participation. |
25 | | -- **`apps/docs`**: A Next.js application for viewing project documentation. |
26 | | -- **`apps/participation`**: A Next.js application for participating in GroupWeave experiences and rounds. |
27 | | -- **`apps/mobile`**: A React Native application for GroupWeave on mobile, built with Expo. |
28 | | -- **`apps/api`**: A FastAPI backend providing the main API for GroupWeave services. |
29 | | -- **`apps/agents`**: Contains multiple Rust-based AI agent binaries for various automated tasks. |
30 | | -- **`apps/contracts`**: A workspace containing NEAR smart contracts for on-chain logic, including staking and voting. |
31 | | -- **`packages/ui`**: A shared React component library used across the frontend applications. |
32 | | -- **`packages/common-types`**: Shared TypeScript types and interfaces for consistency across the monorepo. |
33 | | -- **`packages/near`**: Shared utilities and configuration for interacting with the NEAR blockchain. |
34 | | -- **`packages/eslint-config`**: Shared ESLint configurations for maintaining code quality. |
35 | | -- **`packages/tailwind-config`**: Shared Tailwind CSS configuration for consistent styling. |
36 | | -- **`packages/typescript-config`**: Shared TypeScript configurations (tsconfig) for the monorepo. |
37 | | - |
38 | | -## Coding Style & Linting |
39 | | -### Javascript / Typescript |
40 | | -- Formatted with Prettier, linted with ESLint. Follows a specific import order. See `packages/eslint-config`. |
41 | | - |
42 | | -### Python |
43 | | -- Formatted with black and isort, linted with flake8 and mypy. Configuration is in the `apps/api` directory. |
| 3 | +This file provides comprehensive instructions for AI agents working on the GroupWeave monorepo. |
| 4 | + |
| 5 | +## Project Overview |
| 6 | + |
| 7 | +GroupWeave is an open-source infrastructure for user-owned AI, designed to enable co-creation and co-immersion in generative AI content. Currently developing on NEAR, with plans to integrate Shade agents as customizable, semi-autonomous assistants for multimodal content understanding, moderation, and curation. |
| 8 | + |
| 9 | +## Repository Structure |
| 10 | + |
| 11 | +This is a monorepo managed with **Turborepo** and **pnpm workspaces**. |
| 12 | + |
| 13 | +### Applications (`apps/`) |
| 14 | + |
| 15 | +- **`apps/creation`**: Next.js app for creating new GroupWeave content |
| 16 | +- **`apps/dashboard`**: Next.js app for users to view and manage content/participation |
| 17 | +- **`apps/docs`**: Next.js app for project documentation |
| 18 | +- **`apps/participation`**: Next.js app for participating in GroupWeave experiences |
| 19 | +- **`apps/mobile`**: React Native app built with Expo for mobile platforms |
| 20 | +- **`apps/api`**: FastAPI backend providing main API services |
| 21 | +- **`apps/agents`**: Rust-based AI agent binaries for automated tasks |
| 22 | +- **`apps/contracts`**: NEAR smart contracts (staking, voting, zkp-verifier) |
| 23 | + |
| 24 | +### Shared Packages (`packages/`) |
| 25 | + |
| 26 | +- **`packages/ui`**: Shared React component library (shadcn/ui-inspired) |
| 27 | +- **`packages/common-types`**: TypeScript types and interfaces |
| 28 | +- **`packages/near`**: NEAR blockchain utilities and configuration |
| 29 | +- **`packages/eslint-config`**: Shared ESLint configurations |
| 30 | +- **`packages/tailwind-config`**: Shared Tailwind CSS configuration |
| 31 | +- **`packages/typescript-config`**: Shared TypeScript configurations |
| 32 | + |
| 33 | +--- |
| 34 | + |
| 35 | +## Quick Start |
| 36 | + |
| 37 | +### Prerequisites |
| 38 | +- Node.js >=18 |
| 39 | +- pnpm 9.0.0+ |
| 40 | +- Python 3.9+ |
| 41 | +- Rust 1.70+ |
| 42 | + |
| 43 | +### Essential Commands |
| 44 | + |
| 45 | +```bash |
| 46 | +# Install all dependencies |
| 47 | +pnpm install |
| 48 | + |
| 49 | +# Build all packages and apps |
| 50 | +pnpm build |
| 51 | + |
| 52 | +# Run development servers for all apps |
| 53 | +pnpm dev |
| 54 | + |
| 55 | +# Lint all code |
| 56 | +pnpm lint |
| 57 | + |
| 58 | +# Type check all TypeScript |
| 59 | +pnpm check-types |
| 60 | + |
| 61 | +# Format all code |
| 62 | +pnpm format |
| 63 | +``` |
| 64 | + |
| 65 | +--- |
| 66 | + |
| 67 | +## Development Workflows |
| 68 | + |
| 69 | +### Frontend Development |
| 70 | + |
| 71 | +Run a specific Next.js app: |
| 72 | +```bash |
| 73 | +# Development server |
| 74 | +pnpm --filter creation dev |
| 75 | +pnpm --filter dashboard dev |
| 76 | +pnpm --filter docs dev |
| 77 | +pnpm --filter participation dev |
| 78 | +``` |
| 79 | + |
| 80 | +### Mobile Development |
| 81 | + |
| 82 | +```bash |
| 83 | +cd apps/mobile |
| 84 | + |
| 85 | +# Start development server |
| 86 | +pnpm start |
| 87 | + |
| 88 | +# Run on specific platforms |
| 89 | +pnpm ios |
| 90 | +pnpm android |
| 91 | +``` |
| 92 | + |
| 93 | +### API Development |
| 94 | + |
| 95 | +```bash |
| 96 | +cd apps/api |
| 97 | + |
| 98 | +# Setup Python environment |
| 99 | +python -m venv .venv |
| 100 | +source .venv/bin/activate # Linux/macOS |
| 101 | +# .venv\Scripts\activate # Windows |
| 102 | + |
| 103 | +# Install dependencies |
| 104 | +pip install -r requirements.txt |
| 105 | + |
| 106 | +# Run development server |
| 107 | +uvicorn main:app --reload --port 8000 |
| 108 | +``` |
| 109 | + |
| 110 | +### Rust Development |
| 111 | + |
| 112 | +```bash |
| 113 | +cd apps/agents # or apps/contracts |
| 114 | + |
| 115 | +# Check code without building |
| 116 | +cargo check |
| 117 | + |
| 118 | +# Build project |
| 119 | +cargo build |
| 120 | + |
| 121 | +# Run tests |
| 122 | +cargo test |
| 123 | + |
| 124 | +# Lint code |
| 125 | +cargo clippy |
| 126 | + |
| 127 | +# Format code |
| 128 | +cargo fmt |
| 129 | +``` |
| 130 | + |
| 131 | +--- |
| 132 | + |
| 133 | +## Testing |
| 134 | + |
| 135 | +### Frontend Tests |
| 136 | +```bash |
| 137 | +# Run tests for specific app |
| 138 | +pnpm --filter creation test |
| 139 | +pnpm --filter dashboard test |
| 140 | + |
| 141 | +# Run all frontend tests |
| 142 | +# Note: Individual apps may have their own test scripts |
| 143 | +``` |
| 144 | + |
| 145 | +### API Tests |
| 146 | +```bash |
| 147 | +cd apps/api |
| 148 | +pytest |
| 149 | +``` |
| 150 | + |
| 151 | +### Rust Tests |
| 152 | +```bash |
| 153 | +cd apps/agents # or apps/contracts |
| 154 | +cargo test |
| 155 | +``` |
| 156 | + |
| 157 | +### Pre-commit Checklist |
| 158 | +- [ ] `pnpm lint` passes |
| 159 | +- [ ] `pnpm check-types` passes |
| 160 | +- [ ] `pnpm format` passes |
| 161 | +- [ ] Individual app tests pass (if applicable) |
| 162 | + |
| 163 | +--- |
| 164 | + |
| 165 | +## Pull Request Guidelines |
| 166 | + |
| 167 | +### Title Format |
| 168 | +Use conventional commits: `type(scope): description` |
| 169 | + |
| 170 | +**Examples:** |
| 171 | +- `feat(creation): add image upload component` |
| 172 | +- `fix(api): resolve authentication bug` |
| 173 | +- `docs(agents): update setup instructions` |
| 174 | +- `refactor(ui): improve button component API` |
| 175 | + |
| 176 | +### Types |
| 177 | +- `feat`: New feature |
| 178 | +- `fix`: Bug fix |
| 179 | +- `docs`: Documentation changes |
| 180 | +- `style`: Code style changes (formatting, etc.) |
| 181 | +- `refactor`: Code refactoring |
| 182 | +- `test`: Adding/updating tests |
| 183 | +- `chore`: Maintenance tasks |
| 184 | + |
| 185 | +### PR Checklist |
| 186 | +- [ ] Title follows conventional commit format |
| 187 | +- [ ] All tests pass locally |
| 188 | +- [ ] Code is linted and type-checked |
| 189 | +- [ ] Documentation updated if needed |
| 190 | +- [ ] Breaking changes are documented |
| 191 | + |
| 192 | +--- |
| 193 | + |
| 194 | +## Code Style & Standards |
| 195 | + |
| 196 | +### TypeScript/JavaScript |
| 197 | +- **Formatter**: Prettier |
| 198 | +- **Linter**: ESLint with custom configs |
| 199 | +- **Import order**: Enforced via ESLint |
| 200 | +- **Components**: Follow React best practices |
| 201 | + |
| 202 | +### Python |
| 203 | +- **Formatter**: `black` |
| 204 | +- **Import sorter**: `isort` |
| 205 | +- **Linter**: `flake8` |
| 206 | +- **Type checker**: `mypy` |
44 | 207 |
|
45 | 208 | ### Rust |
46 | | -- Formatted with rustfmt, linted with cargo clippy. Configuration is in the respective Cargo.toml files. |
| 209 | +- **Formatter**: `rustfmt` |
| 210 | +- **Linter**: `clippy` |
| 211 | +- **Testing**: Standard `cargo test` |
| 212 | + |
| 213 | +--- |
| 214 | + |
| 215 | +## Architecture Guidelines |
| 216 | + |
| 217 | +### Shared UI Components |
| 218 | +- Use `packages/ui` for reusable components |
| 219 | +- Follow shadcn/ui patterns with Radix UI primitives |
| 220 | +- Tailwind CSS for styling |
| 221 | +- Components should be framework-agnostic where possible |
| 222 | + |
| 223 | +### Type Safety |
| 224 | +- Use `packages/common-types` for shared TypeScript interfaces |
| 225 | +- Maintain strict type checking across all projects |
| 226 | +- Document complex types with TSDoc comments |
| 227 | + |
| 228 | +### NEAR Integration |
| 229 | +- Use `packages/near` for blockchain interactions |
| 230 | +- Follow NEAR development best practices |
| 231 | +- Smart contracts in `apps/contracts` |
| 232 | + |
| 233 | +--- |
| 234 | + |
| 235 | +## Troubleshooting |
| 236 | + |
| 237 | +### Common Issues |
| 238 | + |
| 239 | +**Dependencies not resolving:** |
| 240 | +```bash |
| 241 | +pnpm install --frozen-lockfile=false |
| 242 | +``` |
| 243 | + |
| 244 | +**Build failures:** |
| 245 | +```bash |
| 246 | +pnpm clean # If available |
| 247 | +pnpm build --force |
| 248 | +``` |
| 249 | + |
| 250 | +**Type errors after changes:** |
| 251 | +```bash |
| 252 | +pnpm check-types --force |
| 253 | +``` |
| 254 | + |
| 255 | +### Getting Help |
| 256 | +- Check existing issues and documentation |
| 257 | +- Review similar implementations in the codebase |
| 258 | +- Ensure you're using the correct package manager (pnpm, not npm/yarn) |
| 259 | + |
| 260 | +--- |
| 261 | + |
| 262 | +## Important Notes |
47 | 263 |
|
| 264 | +1. **Package Manager**: Always use `pnpm`, never `npm` or `yarn` |
| 265 | +2. **Node Version**: Ensure Node.js >=18 for compatibility |
| 266 | +3. **Documentation**: This repository uses automated doc generation via `generate_docs.py` |
| 267 | +4. **Security**: Never commit secrets, API keys, or sensitive data |
| 268 | +5. **Mobile**: React Native components are separate from web UI components |
0 commit comments