Workspace and Monorepo
Workspace and Monorepo
Section titled “Workspace and Monorepo”The engine detects workspaces (monorepos) and builds a workspace config that describes packages and their dependencies. This is used by metrics such as monorepo (API boundaries, layering) and package_metrics, and is available to custom plugins.
WorkspaceConfig
Section titled “WorkspaceConfig”WorkspaceConfig (from arxo-types::data::workspace) is the main type:
workspace_type:WorkspaceType— kind of workspace detected.root_path: Root path of the workspace.packages: List ofPackageInfo(each package in the workspace).tool_config: OptionalToolConfig(e.g. Turbo, Nx).
WorkspaceType
Section titled “WorkspaceType”Supported workspace types:
| Variant | Description |
|---|---|
| Npm | npm workspaces |
| Yarn | Yarn workspaces |
| Pnpm | pnpm workspaces |
| Turbo | Turborepo |
| Cargo | Rust workspace (Cargo) |
| SinglePackage | Single package (no workspace) |
PackageInfo
Section titled “PackageInfo”For each package:
name: Package name (e.g.@myapp/feature-cart).path: Path to package root.package_manager: Package manager that manages this package.dependencies: Direct workspace dependencies (package names).
ToolConfig
Section titled “ToolConfig”Optional build-tool configuration:
turbo:TurboConfig— pipeline task definitions (tasks: list ofTurboTaskwithname,depends_on,outputs,inputs).nx:NxConfig— Nx project map (simplified).
Accessing Workspace Config (Rust)
Section titled “Accessing Workspace Config (Rust)”The DataStore trait exposes:
let workspace_config = data_store.workspace_config().await?;match &workspace_config.workspace_type { WorkspaceType::SinglePackage => { /* one package */ } WorkspaceType::Pnpm | WorkspaceType::Yarn | .. => { for pkg in &workspace_config.packages { println!("{} at {:?}", pkg.name, pkg.path); println!(" deps: {:?}", pkg.dependencies); } }}Helpers on WorkspaceConfig
Section titled “Helpers on WorkspaceConfig”find_package_for_file(file_path)— returns thePackageInfothat contains the given file path (if any).get_package(name)— returnsPackageInfoby package name.package_map()— map of package name →PackageInfofor fast lookup.
empty() returns an empty config (e.g. SinglePackage, no packages) for tests or when no workspace is detected.
Detection
Section titled “Detection”The engine discovers workspaces by reading standard manifest files (e.g. root package.json with workspaces, pnpm-workspace.yaml, Cargo.toml workspace section, turbo.json, Nx config). No extra configuration is required for detection; ensure the project path is the repo root (or the workspace root) so that those files are found.
Use in Metrics
Section titled “Use in Metrics”- monorepo metric uses WorkspaceConfig to compute API boundary violations and package-level layering.
- package_metrics can use package list and dependency graph.
- Custom metric plugins can call
workspace_config()on DataStore to implement workspace-aware metrics.
Next Steps
Section titled “Next Steps”- Data Store — All DataStore accessors including
workspace_config() - Plugin System — Using workspace data in custom metrics
- Configuration — Data and project path