Workspace
workspace
Workspace detection and multi-package analysis.
Detects uv workspaces via [tool.uv.workspace] in pyproject.toml
and aggregates PackageInfo across all member packages.
PackageSummary
Bases: TypedDict
Per-package summary entry inside a :class:WorkspaceContext.
total=False so depth-0 outputs (name only) remain valid.
Source code in packages/axm-ast/src/axm_ast/core/workspace.py
WorkspaceContext
Bases: TypedDict
Aggregate workspace context returned by :func:build_workspace_context.
total=False because the depth-0 view from
:func:format_workspace_context drops package_graph.
Source code in packages/axm-ast/src/axm_ast/core/workspace.py
analyze_workspace(path, *, detected=None)
Analyze all packages in a uv workspace.
Discovers workspace members, analyzes each with analyze_package(),
and builds inter-package dependency edges.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
Path
|
Path to workspace root. |
required |
detected
|
WorkspaceInfo | None
|
A |
None
|
Returns:
| Type | Description |
|---|---|
WorkspaceInfo
|
WorkspaceInfo with all packages and dependency edges. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If path is not a workspace root. |
Example
ws = analyze_workspace(Path("/path/to/workspace")) len(ws.packages) > 0 True
Source code in packages/axm-ast/src/axm_ast/core/workspace.py
build_workspace_context(path)
Build complete workspace context in one call.
Lists all packages, their mutual dependencies, per-package stats, and the workspace-level dependency graph.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
Path
|
Path to workspace root. |
required |
Returns:
| Type | Description |
|---|---|
WorkspaceContext
|
Workspace context dict. |
Source code in packages/axm-ast/src/axm_ast/core/workspace.py
build_workspace_dep_graph(ws)
Build an adjacency-list dependency graph between packages.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ws
|
WorkspaceInfo
|
Analyzed workspace info. |
required |
Returns:
| Type | Description |
|---|---|
dict[str, list[str]]
|
Dict mapping package dir name to list of packages it depends on. |
Example
graph = build_workspace_dep_graph(ws) graph["axm-mcp"]
['axm']
Source code in packages/axm-ast/src/axm_ast/core/workspace.py
build_workspace_module_graph(ws)
Build a merged module-level import graph across all packages.
Reuses :func:build_import_graph per package and namespaces every
node as {package_name}.{module}. Cross-package import targets are
resolved to their owning package so edges stay namespaced rather than
bare module names (lets anvil tell which package each node belongs to).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ws
|
WorkspaceInfo
|
Analyzed workspace info with |
required |
Returns:
| Type | Description |
|---|---|
dict[str, list[str]]
|
Adjacency-list dict mapping |
dict[str, list[str]]
|
|
Example
graph = build_workspace_module_graph(ws) graph["axm-mcp.cli"]
['axm.tools']
Source code in packages/axm-ast/src/axm_ast/core/workspace.py
detect_workspace(path)
Detect a uv workspace at the given path.
Delegates uv-workspace resolution to :func:axm_ingot.uv.resolve_workspace
(the canonical, stdlib-only resolver) and then projects the resulting
ResolvedWorkspace onto a :class:WorkspaceInfo (name + root). The
Pydantic WorkspaceInfo model stays defined in axm-ast; ingot remains
leaf and never sees a Pydantic type. Returns None if not a workspace
(no [tool.uv.workspace] table, missing/malformed pyproject, or no
resolvable members).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
Path
|
Path to potential workspace root. |
required |
Returns:
| Type | Description |
|---|---|
WorkspaceInfo | None
|
WorkspaceInfo if workspace detected, None otherwise. |
Example
ws = detect_workspace(Path("/path/to/workspace")) ws is not None True
Source code in packages/axm-ast/src/axm_ast/core/workspace.py
format_workspace_context(ctx, *, depth=1)
Apply depth-based filtering to workspace context.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ctx
|
WorkspaceContext
|
Full workspace context from :func: |
required |
depth
|
int
|
Detail level. 0 = compact (names only, no graph),
|
1
|
Returns:
| Type | Description |
|---|---|
WorkspaceContext
|
Filtered workspace context dict. |
Source code in packages/axm-ast/src/axm_ast/core/workspace.py
format_workspace_graph_mermaid(ws)
Format the inter-package dependency graph as Mermaid.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ws
|
WorkspaceInfo
|
Analyzed workspace info. |
required |
Returns:
| Type | Description |
|---|---|
str
|
Mermaid diagram string. |
Source code in packages/axm-ast/src/axm_ast/core/workspace.py
format_workspace_text(ctx)
Format workspace context as compact plain text for ToolResult.text.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ctx
|
WorkspaceContext
|
Workspace context dict from :func: |
required |
Returns:
| Type | Description |
|---|---|
str
|
Compact text string. |