Registry API Reference¶
registry
¶
Axium Command Registry - Dynamic command discovery and metadata storage.
Provides a central registry for all Typer commands (core and Spoke-registered) to enable dynamic command discovery in the palette and other tooling.
The registry is populated by introspecting the Typer app structure after commands are registered, capturing command names, help text, and source information.
Example
CommandMetadata
dataclass
¶
Metadata for a registered command.
Attributes:
| Name | Type | Description |
|---|---|---|
name |
str
|
Full command path (e.g., "env set", "daemon start", "aws whoami") |
help |
str
|
Short help text from docstring first line (legacy) |
summary |
str
|
One-line summary (80 chars max) for display |
description |
str
|
Full docstring description |
source |
str
|
Command source - "core" for core commands, or spoke name |
category |
str
|
Auto-computed category ("core", "spoke:creds", "gear:aws") |
group |
str | None
|
Parent command group name (e.g., "env", "daemon"), None for root |
callback |
Callable | None
|
Reference to the command function (for future use) |
Example
Source code in axium/core/registry.py
to_dict()
¶
register_command(name, help, source, summary='', description='', group=None, callback=None)
¶
Register a command in the global registry.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Full command path (e.g., "env set") |
required |
help
|
str
|
Help text from docstring (legacy) |
required |
source
|
str
|
"core" or spoke name |
required |
summary
|
str
|
One-line summary (auto-set from help if not provided) |
''
|
description
|
str
|
Full description (auto-set from help if not provided) |
''
|
group
|
str | None
|
Parent group name if applicable |
None
|
callback
|
Callable | None
|
Command function reference |
None
|
Example
Note
- Category is auto-computed from source
- Summary defaults to help text (80 char limit)
- Description defaults to help text
- If a command with the same name already exists, it will be overwritten
Source code in axium/core/registry.py
get_all_commands(sort_by='alpha')
¶
Get all registered commands with full metadata.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
sort_by
|
str
|
Sort method - "alpha" (alphabetical), "grouped" (source grouped), or "usage" (future: by usage frequency) |
'alpha'
|
Returns:
| Type | Description |
|---|---|
list[dict[str, Any]]
|
List of command dictionaries with name, help, summary, description, |
list[dict[str, Any]]
|
source, category, and group fields |
Example
>>> commands = get_all_commands()
>>> print(commands[0])
{'name': 'daemon start', 'help': 'Start daemon', 'summary': 'Start daemon',
'description': 'Start the Axium daemon...', 'source': 'core',
'category': 'core', 'group': 'daemon'}
>>> commands = get_all_commands(sort_by="grouped")
# Returns core commands first, then spokes alphabetically
Note
The callback field is excluded from returned dictionaries to keep output clean for display purposes.
Source code in axium/core/registry.py
get_commands_by_source(source)
¶
Get commands filtered by source.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
source
|
str
|
Source filter - "core" or spoke name |
required |
Returns:
| Type | Description |
|---|---|
list[dict[str, Any]]
|
List of command dictionaries matching the source |
Example
Source code in axium/core/registry.py
clear_registry()
¶
Clear all registered commands.
Used for testing and when reloading spokes with --reload flag.
Source code in axium/core/registry.py
introspect_typer_app(app, source='core', prefix='')
¶
Walk Typer app structure and register all commands.
Recursively discovers commands by examining app.registered_commands and app.registered_groups. Captures command metadata including names, help text, and source tags.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
app
|
Any
|
Typer application instance to introspect |
required |
source
|
str
|
Source tag for commands ("core" or spoke name) |
'core'
|
prefix
|
str
|
Command prefix for nested groups (used internally for recursion) |
''
|
Example
Note
- Handles both root commands and nested subgroups
- Extracts help text from command docstrings if not explicitly set
- Called after load_spokes() to capture all registered commands
- Safe to call multiple times (will overwrite existing entries)
Source code in axium/core/registry.py
232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 | |