Skip to content
Arxo Arxo

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 (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 of PackageInfo (each package in the workspace).
  • tool_config: Optional ToolConfig (e.g. Turbo, Nx).

Supported workspace types:

VariantDescription
Npmnpm workspaces
YarnYarn workspaces
Pnpmpnpm workspaces
TurboTurborepo
CargoRust workspace (Cargo)
SinglePackageSingle package (no workspace)

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).

Optional build-tool configuration:

  • turbo: TurboConfig — pipeline task definitions (tasks: list of TurboTask with name, depends_on, outputs, inputs).
  • nx: NxConfig — Nx project map (simplified).

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);
}
}
}
  • find_package_for_file(file_path) — returns the PackageInfo that contains the given file path (if any).
  • get_package(name) — returns PackageInfo by package name.
  • package_map() — map of package name → PackageInfo for fast lookup.

empty() returns an empty config (e.g. SinglePackage, no packages) for tests or when no workspace is detected.

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.

  • 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.