Metadata-Version: 2.5
Name: agentsml-lsp
Version: 0.4.0
Summary: AgentsML Language Server Protocol implementation
License: MIT
Requires-Python: >=3.10
Requires-Dist: jsonschema>=4.0
Requires-Dist: lsprotocol>=2023.0.0
Requires-Dist: pygls<2,>=1.3.0
Requires-Dist: pyyaml>=6.0
Description-Content-Type: text/markdown

# AgentsML Language Server

Language Server Protocol implementation for [AgentsML](../../agentsml/) documents
(`.agentsml.yaml`).

## Features

| Feature | Description |
|---|---|
| **Diagnostics** | JSON Schema validation, YAML parse errors, required keys, version validation, cross-reference resolution, enum validation |
| **Completions** | Top-level keys, collection item names, agent-side refs (tools/resources/prompts/policies), step targets, model refs, step ID refs, profile/side_effect/transport enums |
| **Hover** | Agent/tool/model/workflow/resource/prompt/policy/MCP/A2A/step info with description, role, model ref, side effects; condition grammar help |
| **Go to definition** | Jump from a reference to the item it names |
| **Find references** | List every place a definition is referenced |
| **Document links** | Turn every reference into a clickable link to its definition |
| **Document Symbols** | Hierarchical outline of all collections and their items |
| **Code actions** | A quick fix that creates the missing agent, tool, model, ... when a reference cannot be resolved |

Diagnostics are reported at the line and column of the offending value, not at
the top of the document.

## Install

```bash
cd agentsml-ide/language-server
pip install -e .
```

This installs the `agentsml-lsp` console script.

## Release

The package is published to PyPI by the `publish` workflow when a `v*` tag is
pushed. Bump `project.version` in `pyproject.toml` before tagging — the
workflow refuses to publish a tag whose version differs from the package
metadata. See the [project README](../README.md#releasing) for the details.

## Run

```bash
# stdio mode — this is what editors use
python3 src/agentsml_lsp/server.py
python3 src/agentsml_lsp/server.py   # after installation: agentsml-lsp

# TCP mode, for debugging with an external LSP client
python3 src/agentsml_lsp/server.py --tcp --port 2087
```

## Tests

```bash
python3 -m pytest tests/ -v
```

* `tests/test_diagnostics.py` — the diagnostics engine against the shipped
  example documents.
* `tests/test_server_stdio.py` — an end-to-end LSP session: initialize,
  open a document, check the published diagnostics, completions and hover.
* `tests/test_completions.py` — the completion constants.

## Layout

```
src/agentsml_lsp/server.py      LSP server: index, diagnostics, completion, hover, symbols
src/agentsml_lsp/completions.py  Completion constants (top-level keys, profiles, enums)
tests/               Diagnostics and end-to-end protocol tests
```

## Validation rules

| Rule | Severity |
|---|---|
| Missing required top-level keys (`agentsml`, `kind`, `metadata`) | Error |
| Invalid `kind` value | Error |
| Invalid `agentsml` version | Warning |
| Missing `metadata.name` | Error |
| Unknown model/tool/resource/prompt/policy reference in an agent | Error |
| Unknown agent/tool/workflow/a2a_agent reference in a step | Error |
| Missing step required field (`id`) | Error |
| Unknown edge `from`/`to` step ID | Error |
| Unknown profile name | Warning |
| Invalid tool `side_effect` value | Warning |
| Invalid MCP `transport` value | Warning |
