# Actions

Wasot is a markdown language enabling humans and computers/[tools](./tools.md) to work together.
One way of working together is to registering the tools, which can then called by the user.
But these are context-depending. For example, if you have a code-block, you want to trigger a tool 
to format the code.

Tools should be tools and are a means to extend wasot. So how do you trigger them? How do you 
get a list of available actions?
A tool provides multiple actions. Each action has a [selector](./selectors.md) defining, in which 
cases the action can be applied. When you register a tool, all its actions are registered together
with their selectors. 
When the user is in a line, he can query wasot for a list of available actions. Wasot parses the file
line by line, builds a stack and matches the selector of each available action against the state of 
the stack on the line queried by the user.

But tools and their actions are not part of wasot, but are loaded externally. So how to integrate?
The idea is to register a plugin and its actions externally with wasot, which includes selectors. 
Selecting an action is done within wasot, but it then calls the actual tool with all relevant context
via a channel like gRPC, etc.

## Tools and Action

An **action** consists of:

- Name
- Description (maybe later in a template style, inserting stuff from the selector matches, but not for now)
- Selectors

A **plugin** consists of:

- Name
- unique id with a namespace, like a jvm package
- Meta-Information
- List of Actions
- Channel-Info: For example gRPC callback stuff

More about plugins [here](./plugins.md)

But there are also tool, which are different.
They react to events like `BlockStarted` and subscribe to them via selectors.
They can add to the context (global variables) or to scoped variables.
See [Context and Scoped Variables](./context_and_scoped_variables.md)


## Query actions from the commandline

Actions will be integrated in the LSP, but wasot will always support the most basic usage pattern. 
You can get a list of actions for a given line via the command-line and can run them from the command-line as well.


