refactor: extract CLI into standalone crewai-cli package#4884
Draft
greysonlalonde wants to merge 8 commits intomainfrom
Draft
refactor: extract CLI into standalone crewai-cli package#4884greysonlalonde wants to merge 8 commits intomainfrom
greysonlalonde wants to merge 8 commits intomainfrom
Conversation
Add the new lib/cli package skeleton with pyproject.toml, README, and __init__.py. Register it as a uv workspace member and update root linting, mypy, bandit, and pytest config to include the new package paths.
Copy all CLI source modules from lib/crewai/src/crewai/cli/ to the new lib/cli/src/crewai_cli/ package, updating internal imports from crewai.cli.* to crewai_cli.* throughout. Includes: authentication, deploy, enterprise, organization, settings, tools, triggers, templates, and all top-level CLI command modules. Also excludes lib/cli/ from pre-commit mypy checks to match existing behavior (original CLI code has the same type gaps).
Move and adapt all CLI tests from lib/crewai/tests/cli/ to lib/cli/tests/, updating import paths from crewai.cli.* to crewai_cli.* and adjusting mock targets accordingly.
Remove all CLI modules and tests that have been moved to the crewai-cli package. Replace cli.py with a thin shim that re-exports from crewai_cli when available, or shows an install hint otherwise. Update crewai pyproject.toml to add a [cli] extra pointing to crewai-cli and comment out the old entry point. Add py.typed marker to crewai_cli for mypy compatibility.
# Conflicts: # lib/crewai/src/crewai/cli/cli.py
Validate that pyproject.toml, a lockfile (uv.lock or poetry.lock), and the expected src/<project>/crew.py or config directory exist locally before making any API calls. This surfaces clear, actionable errors on the CLI instead of cryptic server-side deployment failures.
The backward-compat shim is unnecessary — nothing imports from crewai.cli.cli and the entry point lives in crewai-cli now.
| """Tests for TokenManager with atomic file operations.""" | ||
|
|
||
| import json | ||
| import os |
| self.settings = settings | ||
|
|
||
| @abstractmethod | ||
| def get_authorize_url(self) -> str: ... |
| def get_authorize_url(self) -> str: ... | ||
|
|
||
| @abstractmethod | ||
| def get_token_url(self) -> str: ... |
| def get_token_url(self) -> str: ... | ||
|
|
||
| @abstractmethod | ||
| def get_jwks_url(self) -> str: ... |
| def get_jwks_url(self) -> str: ... | ||
|
|
||
| @abstractmethod | ||
| def get_issuer(self) -> str: ... |
| def get_issuer(self) -> str: ... | ||
|
|
||
| @abstractmethod | ||
| def get_audience(self) -> str: ... |
| def get_audience(self) -> str: ... | ||
|
|
||
| @abstractmethod | ||
| def get_client_id(self) -> str: ... |
| self.assertEqual(self.api.api_key, self.api_key) | ||
| self.assertEqual(self.api.headers["Authorization"], f"Bearer {self.api_key}") | ||
| self.assertEqual(self.api.headers["Content-Type"], "application/json") | ||
| self.assertTrue("CrewAI-CLI/" in self.api.headers["User-Agent"]) |
| selected_index = int(choice) - 1 | ||
| if 0 <= selected_index < len(choices): | ||
| return choices[selected_index] | ||
| except ValueError: |
| file_path = storage_path / filename | ||
| try: | ||
| file_path.unlink() | ||
| except FileNotFoundError: |
Ruff fails when checking .py files in the templates directory because
it discovers the nearby pyproject.toml which contains {{folder_name}}
placeholders that are invalid TOML. Add the new template path to the
CI grep filter, matching the existing exclusion for the original path.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
lib/crewai/src/crewai/cli/into a standalonelib/cli/package (crewai-cli) with its ownpyproject.toml, entry point, and dependenciescrewai.cli.clithat re-exports fromcrewai_cliwhen installed, or shows an install hint otherwisecrewai[cli]optional extra to install the new package alongside crewaideploycommands to catch missingpyproject.toml, lockfile, orsrc/<name>/crew.pylocally before hitting the serverCommit breakdown
c0689aalib/clipackage and register as workspace member4f9a8f4crewai_cliwith updated imports3732de796fc5848fd7a73Test plan
uv run --package crewai-cli crewai --helpworks standaloneuv run --package crewai crewai --helpworks via the shimuv run pytest lib/cli/tests/— all new CLI tests passuv run pytest lib/crewai/tests/cli/— remaining crewai CLI tests passcrewai deploy createfrom a directory missingpyproject.tomlshows pre-flight errorcrewai deploy createfrom a directory missing lockfile shows pre-flight error