# plugins

URL: /milo-cli/api/milo/plugins/
Section: milo
Description: Plugin system with hook registry and Store middleware integration.

---

> For a complete page index, fetch /milo-cli/llms.txt.

Open LLM text
(/milo-cli/api/milo/plugins/index.txt)

Share with AI

Ask Claude
(https://claude.ai/new?q=Please%20help%20me%20understand%20this%20documentation%3A%20%2Fmilo-cli%2Fapi%2Fmilo%2Fplugins%2Findex.txt)

Ask ChatGPT
(https://chatgpt.com/?q=Please%20help%20me%20understand%20this%20documentation%3A%20%2Fmilo-cli%2Fapi%2Fmilo%2Fplugins%2Findex.txt)

Ask Gemini
(https://gemini.google.com/app?q=Please%20help%20me%20understand%20this%20documentation%3A%20%2Fmilo-cli%2Fapi%2Fmilo%2Fplugins%2Findex.txt)

Ask Copilot
(https://copilot.microsoft.com/?q=Please%20help%20me%20understand%20this%20documentation%3A%20%2Fmilo-cli%2Fapi%2Fmilo%2Fplugins%2Findex.txt)

Module

#
`plugins`

Plugin system with hook registry and Store middleware integration.

1Class

## Classes

`HookRegistry`

10

▼

Registry of named hooks that plugins can subscribe to.

Usage::

hooks = HookRegistry()
hoo…

Registry of named hooks that plugins can subscribe to.

Usage::

```
hooks = HookRegistry()
hooks.define("before_build")
hooks.define("after_phase", required_args=("phase_name",))

@hooks.on("before_build")
def my_plugin(config):
    print("Building with", config)

# Invoke all listeners
hooks.invoke("before_build", config=my_config)

# Freeze after setup (optional but recommended)
hooks.freeze()

# Use as Store middleware
store = Store(reducer, state, middleware=(hooks.as_middleware(),))
```

#### Methods

`frozen`

0

`bool`

▼

property

`def frozen(self) -> bool`

##### Returns

`bool`

`define`

3

▼

Define a named hook point.

`def define(self, name: str, *, action_type: str = '', description: str = '') -> None`

##### Parameters

Name
Type
Description

`name`
`—`

Hook name (e.g., "before_build", "after_phase").

`action_type`
`—`

If set, this hook fires automatically when the Store dispatches an action of this type.

Default:`''`

`description`
`—`

Human-readable description for docs/introspection.

Default:`''`

`on`

1

`Callable`

▼

Decorator to register a listener on a hook.

Usage::

@hooks.on("before_bui…

`def on(self, hook_name: str) -> Callable`

Decorator to register a listener on a hook.

Usage::

```
@hooks.on("before_build")
def my_listener(config): ...
```

##### Parameters

Name
Type
Description

`hook_name`
`—`

##### Returns

`Callable`

`register`

2

▼

Register a listener function on a hook.

`def register(self, hook_name: str, fn: Callable) -> None`

##### Parameters

Name
Type
Description

`hook_name`
`—`

`fn`
`—`

`invoke`

3

`list[Any]`

▼

Invoke all listeners registered on a hook.

`def invoke(self, hook_name: str, *, fail_fast: bool = True, **kwargs: Any) -> list[Any]`

##### Parameters

Name
Type
Description

`hook_name`
`—`

The hook to invoke.

`fail_fast`
`—`

If True (default), stop on the first listener error. If False, run all listeners and raise an aggregate error after all have been called. **kwargs: Arguments passed to each listener. Returns a list of return values from each listener. Listeners are called in registration order.

Default:`True`

`**kwargs`
`—`

##### Returns

`list[Any]`

`freeze`

0

▼

Freeze the registry — no more defines or registrations.

`def freeze(self) -> None`

`hook_names`

0

`tuple[str, ...]`

▼

Return all defined hook names.

`def hook_names(self) -> tuple[str, ...]`

##### Returns

`tuple[str, ...]`

`listeners`

1

`tuple[Callable, ...]`

▼

Return all listeners for a hook.

`def listeners(self, hook_name: str) -> tuple[Callable, ...]`

##### Parameters

Name
Type
Description

`hook_name`
`—`

##### Returns

`tuple[Callable, ...]`

`as_middleware`

0

`Callable`

▼

Return a Store middleware that fires hooks on matching actions.

The middleware…

`def as_middleware(self) -> Callable`

Return a Store middleware that fires hooks on matching actions.

The middleware intercepts actions whose type matches an
`action_type` registered via `define()`, invokes the
corresponding hook, and then passes the action through.

Usage::

```
store = Store(reducer, state, middleware=(hooks.as_middleware(),))
```

##### Returns

`Callable`

Internal Methods
1

▼

`__init__`

0

▼

`def __init__(self) -> None`
