-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
fix: include monorepo root dependencies in project_index dependency_locations #1902
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -116,6 +116,24 @@ def _find_and_analyze_services(self) -> None: | |
| "language" | ||
| ): # Only include if we detected something | ||
| services[item.name] = service_info | ||
|
|
||
| # Also check the project root itself for dependencies. | ||
| # Monorepo roots often have their own package.json + node_modules | ||
| # (e.g., npm/pnpm workspaces) that need to be shared with worktrees. | ||
| already_covered = self.project_dir in { | ||
| Path(s.get("path", "")) for s in services.values() | ||
| } | ||
| if not already_covered: | ||
| dep_indicators = ("package.json", "requirements.txt", "pyproject.toml") | ||
| root_has_deps = any( | ||
| (self.project_dir / f).exists() for f in dep_indicators | ||
| ) | ||
| if root_has_deps: | ||
| root_analyzer = ServiceAnalyzer(self.project_dir, "root") | ||
| root_info = root_analyzer.analyze() | ||
| root_deps = root_info.get("dependency_locations", []) | ||
| if root_deps: | ||
| services["root"] = root_info | ||
|
Comment on lines
+123
to
+136
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Avoid overwriting a real Line 136 unconditionally writes Proposed fix- already_covered = self.project_dir in {
- Path(s.get("path", "")) for s in services.values()
- }
+ discovered_paths: set[Path] = set()
+ for service in services.values():
+ raw_path = service.get("path")
+ if not raw_path:
+ continue
+ discovered_paths.add(Path(raw_path).resolve())
+ already_covered = self.project_dir in discovered_paths
if not already_covered:
dep_indicators = ("package.json", "requirements.txt", "pyproject.toml")
root_has_deps = any(
(self.project_dir / f).exists() for f in dep_indicators
)
if root_has_deps:
root_analyzer = ServiceAnalyzer(self.project_dir, "root")
root_info = root_analyzer.analyze()
root_deps = root_info.get("dependency_locations", [])
if root_deps:
- services["root"] = root_info
+ root_key = "root" if "root" not in services else "project_root"
+ services[root_key] = root_info🤖 Prompt for AI Agents |
||
| else: | ||
| # Single project - analyze root | ||
| analyzer = ServiceAnalyzer(self.project_dir, "main") | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This tuple of dependency indicator files is hardcoded. For better maintainability and clarity, consider defining this as a named constant at the module level, for example
ROOT_DEPENDENCY_FILES. This makes the purpose of this list explicit and easier to update in the future.