diff --git a/Development.md b/Development.md index 3fdbc5f0..e51bc500 100644 --- a/Development.md +++ b/Development.md @@ -38,7 +38,27 @@ These packages are part of a uv workspace which manages a shared virtual environ OPENAI_API_KEY=your_openai_key_here ``` -4. Open the workspace in VSCode or Cursor: +4. Install Node.js dependencies for Prettier and other scripts: + + ```bash + # Install pnpm if you don't have it + npm install -g pnpm + + # Install all JS/TS dependencies + pnpm install + ``` + +5. Install Python dependencies and workspace packages: + + ```bash + # First install uv if you don't have it + pip install uv + + # Then install all Python dependencies + uv sync + ``` + +6. Open the workspace in VSCode or Cursor: ```bash # For Cua Python development @@ -48,7 +68,13 @@ These packages are part of a uv workspace which manages a shared virtual environ code .vscode/lume.code-workspace ``` -5. Install Pre-commit hooks ([see below](#pre-commit-hook)): +7. Install Pre-commit hooks: + + This ensures code formatting and validation run automatically on each commit. + + ```bash + uv run pre-commit install + ``` Using the workspace file is strongly recommended as it: @@ -57,19 +83,6 @@ Using the workspace file is strongly recommended as it: - Enables debugging configurations - Maintains consistent settings across packages -### Pre-commit Hook Installation - -Pre-commit hooks are scripts that run automatically before each commit to ensure code quality and consistency. -To install the hooks: - -```bash -# First, ensure dependencies are installed (only needed once) -uv sync - -# Then install the pre-commit hooks -uv run pre-commit install -``` - ## Lume Development Refer to the [Lume README](./libs/lume/Development.md) for instructions on how to develop the Lume CLI. @@ -149,23 +162,34 @@ line-length = 100 target-version = ["py311"] [tool.ruff] +fix = true line-length = 100 target-version = "py311" + +[tool.ruff.lint] select = ["E", "F", "B", "I"] +ignore = [ + "E501", "E402", "I001", "I002", "B007", "B023", "B024", "B027", "B028", + "B904", "B905", "E711", "E712", "E722", "E731", "F401", "F403", "F405", + "F811", "F821", "F841" +] fix = true [tool.ruff.format] docstring-code-format = true [tool.mypy] -strict = true -python_version = "3.11" -ignore_missing_imports = true -disallow_untyped_defs = true check_untyped_defs = true -warn_return_any = true +disallow_untyped_defs = true +ignore_missing_imports = true +python_version = "3.11" show_error_codes = true +strict = true +warn_return_any = true warn_unused_ignores = false + +[tool.isort] +profile = "black" ``` #### Key Formatting Rules @@ -269,6 +293,52 @@ uv run prettier --check "**/*.{ts,tsx,js,jsx,json,md,yaml,yml}" node ./scripts/typescript-typecheck.js ``` +### JavaScript / TypeScript Formatting (Prettier) + +The project uses **Prettier** to ensure consistent formatting across all JS/TS/JSON/Markdown/YAML files. + +#### Installation + +All Node.js dependencies are managed via `pnpm`. Make sure you have run: + +```bash +# Install pnpm if you don't have it +npm install -g pnpm + +# Install project dependencies +pnpm install +``` + +This installs Prettier and other JS/TS dependencies defined in `package.json`. + +#### Usage + +- **Check formatting** (without making changes): + +```bash +pnpm prettier:check +``` + +- **Automatically format files**: + +```bash +pnpm prettier:format +``` + +#### Type Checking (TypeScript) + +- Run the TypeScript type checker: + +```bash +node ./scripts/typescript-typecheck.js +``` + +#### VSCode Integration + +- The workspace config ensures Prettier is used automatically for JS/TS/JSON/Markdown/YAML files. +- Recommended extension: Prettier – Code Formatter +- Ensure `editor.formatOnSave` is enabled in VSCode for automatic formatting. + ### Swift Code (Lume) For Swift code in the `libs/lume` directory: diff --git a/libs/python/agent/pyproject.toml b/libs/python/agent/pyproject.toml index 94bde419..0d690240 100644 --- a/libs/python/agent/pyproject.toml +++ b/libs/python/agent/pyproject.toml @@ -108,4 +108,4 @@ constraint-dependencies = ["fastrtc>0.43.0", "mlx-audio>0.2.3"] distribution = true [tool.pdm.build] -includes = ["agent/"] +includes = ["agent/"] \ No newline at end of file diff --git a/libs/python/computer-server/pyproject.toml b/libs/python/computer-server/pyproject.toml index 6468a48d..01b40af0 100644 --- a/libs/python/computer-server/pyproject.toml +++ b/libs/python/computer-server/pyproject.toml @@ -67,23 +67,4 @@ dev = [ ] [tool.pdm.scripts] -api = "python -m computer_server" - -[tool.ruff] -line-length = 100 -target-version = "py310" -select = ["E", "F", "B", "I"] -fix = true - -[tool.ruff.format] -docstring-code-format = true - -[tool.mypy] -strict = true -python_version = "3.10" -ignore_missing_imports = true -disallow_untyped_defs = true -check_untyped_defs = true -warn_return_any = true -show_error_codes = true -warn_unused_ignores = false +api = "python -m computer_server" \ No newline at end of file diff --git a/libs/python/computer/pyproject.toml b/libs/python/computer/pyproject.toml index 22ebccd5..b659c0a1 100644 --- a/libs/python/computer/pyproject.toml +++ b/libs/python/computer/pyproject.toml @@ -44,29 +44,6 @@ distribution = true includes = ["computer/"] source-includes = ["tests/", "README.md", "LICENSE"] -[tool.black] -line-length = 100 -target-version = ["py311"] - -[tool.ruff] -line-length = 100 -target-version = "py311" -select = ["E", "F", "B", "I"] -fix = true - -[tool.ruff.format] -docstring-code-format = true - -[tool.mypy] -strict = true -python_version = "3.11" -ignore_missing_imports = true -disallow_untyped_defs = true -check_untyped_defs = true -warn_return_any = true -show_error_codes = true -warn_unused_ignores = false - [tool.pytest.ini_options] asyncio_mode = "auto" testpaths = ["tests"] diff --git a/libs/python/core/pyproject.toml b/libs/python/core/pyproject.toml index c4bcd459..d505b225 100644 --- a/libs/python/core/pyproject.toml +++ b/libs/python/core/pyproject.toml @@ -24,34 +24,11 @@ distribution = true includes = ["core/"] source-includes = ["tests/", "README.md", "LICENSE"] -[tool.black] -line-length = 100 -target-version = ["py311"] - -[tool.ruff] -line-length = 100 -target-version = "py311" -select = ["E", "F", "B", "I"] -fix = true - -[tool.ruff.format] -docstring-code-format = true - -[tool.mypy] -strict = true -python_version = "3.11" -ignore_missing_imports = true -disallow_untyped_defs = true -check_untyped_defs = true -warn_return_any = true -show_error_codes = true -warn_unused_ignores = false - [tool.pytest.ini_options] asyncio_mode = "auto" testpaths = ["tests"] -python_files = "test_*.py" +python_files = "test_*.py" [dependency-groups] dev = [ "pytest>=8.3.5", -] +] \ No newline at end of file diff --git a/libs/python/mcp-server/pyproject.toml b/libs/python/mcp-server/pyproject.toml index b844fe36..6e05da7f 100644 --- a/libs/python/mcp-server/pyproject.toml +++ b/libs/python/mcp-server/pyproject.toml @@ -27,14 +27,4 @@ distribution = true dev = [ "black>=23.9.1", "ruff>=0.0.292", -] - -[tool.black] -line-length = 100 -target-version = ["py311"] - -[tool.ruff] -line-length = 100 -target-version = "py311" -select = ["E", "F", "B", "I"] -fix = true +] \ No newline at end of file diff --git a/libs/python/pylume/pyproject.toml b/libs/python/pylume/pyproject.toml index f21f2bb2..b86d5575 100644 --- a/libs/python/pylume/pyproject.toml +++ b/libs/python/pylume/pyproject.toml @@ -41,29 +41,6 @@ dev = [ "pytest>=7.0.0", ] -[tool.black] -line-length = 100 -target-version = ["py311"] - -[tool.ruff] -fix = true -line-length = 100 -select = ["B", "E", "F", "I"] -target-version = "py311" - -[tool.ruff.format] -docstring-code-format = true - -[tool.mypy] -check_untyped_defs = true -disallow_untyped_defs = true -ignore_missing_imports = true -python_version = "3.11" -show_error_codes = true -strict = true -warn_return_any = true -warn_unused_ignores = false - [tool.pytest.ini_options] asyncio_mode = "auto" python_files = "test_*.py" @@ -71,4 +48,4 @@ testpaths = ["tests"] [tool.pdm.build] includes = ["pylume/"] -source-includes = ["LICENSE", "README.md", "tests/"] +source-includes = ["LICENSE", "README.md", "tests/"] \ No newline at end of file diff --git a/libs/python/som/pyproject.toml b/libs/python/som/pyproject.toml index f871eb18..95941538 100644 --- a/libs/python/som/pyproject.toml +++ b/libs/python/som/pyproject.toml @@ -52,30 +52,7 @@ src-layout = false includes = ["som/"] source-includes = ["tests/", "README.md", "LICENSE"] -[tool.black] -line-length = 100 -target-version = ["py311"] - -[tool.ruff] -line-length = 100 -target-version = "py311" -select = ["E", "F", "B", "I"] -fix = true - -[tool.ruff.format] -docstring-code-format = true - -[tool.mypy] -strict = true -python_version = "3.11" -ignore_missing_imports = true -disallow_untyped_defs = true -check_untyped_defs = true -warn_return_any = true -show_error_codes = true -warn_unused_ignores = false - [tool.pytest.ini_options] asyncio_mode = "auto" testpaths = ["tests"] -python_files = "test_*.py" +python_files = "test_*.py" \ No newline at end of file diff --git a/package.json b/package.json new file mode 100644 index 00000000..2d0118af --- /dev/null +++ b/package.json @@ -0,0 +1,9 @@ +{ + "scripts": { + "prettier:check": "prettier --check '**/*.{ts,tsx,js,jsx,json,md,yaml,yml}'", + "prettier:format": "prettier --write '**/*.{ts,tsx,js,jsx,json,md,yaml,yml}'" + }, + "devDependencies": { + "prettier": "^3.6.2" + } +} diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml new file mode 100644 index 00000000..595fc04b --- /dev/null +++ b/pnpm-lock.yaml @@ -0,0 +1,24 @@ +lockfileVersion: '9.0' + +settings: + autoInstallPeers: true + excludeLinksFromLockfile: false + +importers: + .: + devDependencies: + prettier: + specifier: ^3.6.2 + version: 3.6.2 + +packages: + prettier@3.6.2: + resolution: + { + integrity: sha512-I7AIg5boAr5R0FFtJ6rCfD+LFsWHp81dolrFD8S79U9tb8Az2nGrJncnMSnys+bpQJfRUzqs9hnA81OAA3hCuQ== + } + engines: { node: '>=14' } + hasBin: true + +snapshots: + prettier@3.6.2: {} diff --git a/pyproject.toml b/pyproject.toml index 2e40502a..d6b70d5a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -75,9 +75,16 @@ target-version = ["py311"] [tool.ruff] fix = true line-length = 100 -select = ["B", "E", "F", "I"] target-version = "py311" +[tool.ruff.lint] +select = ["E", "F", "B", "I"] +ignore = [ + "E501", "E402", "I001", "I002", "B007", "B023", "B024", "B027", "B028", + "B904", "B905", "E711", "E712", "E722", "E731", "F401", "F403", "F405", + "F811", "F821", "F841" +] + [tool.ruff.format] docstring-code-format = true