2.3 KiB
2.3 KiB
Monorepo detection rules
init needs to identify whether the project is a monorepo and how to split scopes. This file lists the detection rules per tool.
Detection order
Check markers in this order; the first match determines scope layout:
- pnpm workspaces
- Yarn workspaces
- npm workspaces
- Lerna
- Nx
- Rush
- Cargo workspaces
- Go workspaces
- Bazel
No monorepo marker → fall back to _global/ only (single-scope project).
Per-tool rules
pnpm workspaces
- Marker:
pnpm-workspace.yamlat repo root - Read:
packages:field, e.g.packages: [frontend, backend, shared/*] - One scope per listed package directory
Yarn workspaces (classic / berry)
- Marker:
package.jsontop-levelworkspacesfield - Example:
"workspaces": ["packages/*"] - One scope per glob-resolved directory
npm workspaces
- Same as Yarn (npm 7+ uses the same
package.json#workspacesfield)
Lerna
- Marker:
lerna.json - Read:
packagesfield (array of paths) - One scope per path
Nx
- Marker:
nx.jsonorworkspace.json - Nx typically delegates package discovery to npm/yarn workspaces — read both
- One scope per resolved package
Rush
- Marker:
rush.json - Read:
projectsarray (each entry has apackageNameand directory)
Cargo workspaces
- Marker:
Cargo.tomltop-level[workspace]table - Read:
membersarray - One scope per member crate
Go workspaces
- Marker:
go.work - Read:
usedirectives (one per module) - One scope per module
Bazel
- Marker:
MODULE.bazelorWORKSPACE - Bazel repos are deeply nested; precise extraction is fragile. Fallback: collapse to one scope per top-level directory and let the user override.
Scope naming
- Default: directory name (
frontend/→ scopefrontend) - If multiple directories belong to one logical scope (e.g.
packages/webandpackages/mobileare both "frontend"), agent should ask the user whether to merge - Nested monorepos (
packages/web/components/) are not supported as nested scopes. Flatten toweb.
When detection fails
If detection succeeds but the resulting scopes don't match the user's mental model, agent should:
- Show the proposed scope list
- Let the user rename / merge / split scopes
- Proceed with the corrected list
This is part of the init confirmation step (see main SKILL.md init step 2).