agentsml-lsp 0.2.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- agentsml_lsp-0.2.0/.gitignore +39 -0
- agentsml_lsp-0.2.0/PKG-INFO +95 -0
- agentsml_lsp-0.2.0/README.md +83 -0
- agentsml_lsp-0.2.0/pyproject.toml +30 -0
- agentsml_lsp-0.2.0/src/agentsml_lsp/__init__.py +3 -0
- agentsml_lsp-0.2.0/src/agentsml_lsp/completions.py +104 -0
- agentsml_lsp-0.2.0/src/agentsml_lsp/schemas/agentsml.schema.json +406 -0
- agentsml_lsp-0.2.0/src/agentsml_lsp/server.py +1571 -0
- agentsml_lsp-0.2.0/tests/test_bundled_schema.py +27 -0
- agentsml_lsp-0.2.0/tests/test_code_actions.py +127 -0
- agentsml_lsp-0.2.0/tests/test_completion.py +170 -0
- agentsml_lsp-0.2.0/tests/test_completions.py +65 -0
- agentsml_lsp-0.2.0/tests/test_diagnostics.py +247 -0
- agentsml_lsp-0.2.0/tests/test_navigation.py +126 -0
- agentsml_lsp-0.2.0/tests/test_server_stdio.py +295 -0
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
# Python
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[cod]
|
|
4
|
+
*.egg-info/
|
|
5
|
+
.eggs/
|
|
6
|
+
dist/
|
|
7
|
+
build/
|
|
8
|
+
.pytest_cache/
|
|
9
|
+
.venv/
|
|
10
|
+
venv/
|
|
11
|
+
|
|
12
|
+
# Node
|
|
13
|
+
node_modules/
|
|
14
|
+
*.vsix
|
|
15
|
+
*.tgz
|
|
16
|
+
.npm/
|
|
17
|
+
|
|
18
|
+
# Tree-sitter build artifacts
|
|
19
|
+
target/
|
|
20
|
+
prebuilds/
|
|
21
|
+
*.a
|
|
22
|
+
*.so
|
|
23
|
+
*.so.*
|
|
24
|
+
*.dylib
|
|
25
|
+
*.dylib.*
|
|
26
|
+
*.dll
|
|
27
|
+
*.o
|
|
28
|
+
*.obj
|
|
29
|
+
*.wasm
|
|
30
|
+
*.dSYM/
|
|
31
|
+
|
|
32
|
+
# Tree-sitter generated sources (run `tree-sitter generate`)
|
|
33
|
+
tree-sitter-agentsml/src/parser.c
|
|
34
|
+
tree-sitter-agentsml/src/grammar.json
|
|
35
|
+
tree-sitter-agentsml/src/node-types.json
|
|
36
|
+
|
|
37
|
+
# Editors
|
|
38
|
+
.DS_Store
|
|
39
|
+
*.swp
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: agentsml-lsp
|
|
3
|
+
Version: 0.2.0
|
|
4
|
+
Summary: AgentsML Language Server Protocol implementation
|
|
5
|
+
License: MIT
|
|
6
|
+
Requires-Python: >=3.10
|
|
7
|
+
Requires-Dist: jsonschema>=4.0
|
|
8
|
+
Requires-Dist: lsprotocol>=2023.0.0
|
|
9
|
+
Requires-Dist: pygls<2,>=1.3.0
|
|
10
|
+
Requires-Dist: pyyaml>=6.0
|
|
11
|
+
Description-Content-Type: text/markdown
|
|
12
|
+
|
|
13
|
+
# AgentsML Language Server
|
|
14
|
+
|
|
15
|
+
Language Server Protocol implementation for [AgentsML](../../agentsml/) documents
|
|
16
|
+
(`.agentsml.yaml`).
|
|
17
|
+
|
|
18
|
+
## Features
|
|
19
|
+
|
|
20
|
+
| Feature | Description |
|
|
21
|
+
|---|---|
|
|
22
|
+
| **Diagnostics** | JSON Schema validation, YAML parse errors, required keys, version validation, cross-reference resolution, enum validation |
|
|
23
|
+
| **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 |
|
|
24
|
+
| **Hover** | Agent/tool/model/workflow/resource/prompt/policy/MCP/A2A/step info with description, role, model ref, side effects; condition grammar help |
|
|
25
|
+
| **Go to definition** | Jump from a reference to the item it names |
|
|
26
|
+
| **Find references** | List every place a definition is referenced |
|
|
27
|
+
| **Document links** | Turn every reference into a clickable link to its definition |
|
|
28
|
+
| **Document Symbols** | Hierarchical outline of all collections and their items |
|
|
29
|
+
| **Code actions** | A quick fix that creates the missing agent, tool, model, ... when a reference cannot be resolved |
|
|
30
|
+
|
|
31
|
+
Diagnostics are reported at the line and column of the offending value, not at
|
|
32
|
+
the top of the document.
|
|
33
|
+
|
|
34
|
+
## Install
|
|
35
|
+
|
|
36
|
+
```bash
|
|
37
|
+
cd agentsml-ide/language-server
|
|
38
|
+
pip install -e .
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
This installs the `agentsml-lsp` console script.
|
|
42
|
+
|
|
43
|
+
## Release
|
|
44
|
+
|
|
45
|
+
The package is published to PyPI by the `publish` workflow when a `v*` tag is
|
|
46
|
+
pushed. Bump `project.version` in `pyproject.toml` before tagging — the
|
|
47
|
+
workflow refuses to publish a tag whose version differs from the package
|
|
48
|
+
metadata. See the [project README](../README.md#releasing) for the details.
|
|
49
|
+
|
|
50
|
+
## Run
|
|
51
|
+
|
|
52
|
+
```bash
|
|
53
|
+
# stdio mode — this is what editors use
|
|
54
|
+
python3 src/agentsml_lsp/server.py
|
|
55
|
+
python3 src/agentsml_lsp/server.py # after installation: agentsml-lsp
|
|
56
|
+
|
|
57
|
+
# TCP mode, for debugging with an external LSP client
|
|
58
|
+
python3 src/agentsml_lsp/server.py --tcp --port 2087
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
## Tests
|
|
62
|
+
|
|
63
|
+
```bash
|
|
64
|
+
python3 -m pytest tests/ -v
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
* `tests/test_diagnostics.py` — the diagnostics engine against the shipped
|
|
68
|
+
example documents.
|
|
69
|
+
* `tests/test_server_stdio.py` — an end-to-end LSP session: initialize,
|
|
70
|
+
open a document, check the published diagnostics, completions and hover.
|
|
71
|
+
* `tests/test_completions.py` — the completion constants.
|
|
72
|
+
|
|
73
|
+
## Layout
|
|
74
|
+
|
|
75
|
+
```
|
|
76
|
+
src/agentsml_lsp/server.py LSP server: index, diagnostics, completion, hover, symbols
|
|
77
|
+
src/agentsml_lsp/completions.py Completion constants (top-level keys, profiles, enums)
|
|
78
|
+
tests/ Diagnostics and end-to-end protocol tests
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
## Validation rules
|
|
82
|
+
|
|
83
|
+
| Rule | Severity |
|
|
84
|
+
|---|---|
|
|
85
|
+
| Missing required top-level keys (`agentsml`, `kind`, `metadata`) | Error |
|
|
86
|
+
| Invalid `kind` value | Error |
|
|
87
|
+
| Invalid `agentsml` version | Warning |
|
|
88
|
+
| Missing `metadata.name` | Error |
|
|
89
|
+
| Unknown model/tool/resource/prompt/policy reference in an agent | Error |
|
|
90
|
+
| Unknown agent/tool/workflow/a2a_agent reference in a step | Error |
|
|
91
|
+
| Missing step required field (`id`) | Error |
|
|
92
|
+
| Unknown edge `from`/`to` step ID | Error |
|
|
93
|
+
| Unknown profile name | Warning |
|
|
94
|
+
| Invalid tool `side_effect` value | Warning |
|
|
95
|
+
| Invalid MCP `transport` value | Warning |
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
# AgentsML Language Server
|
|
2
|
+
|
|
3
|
+
Language Server Protocol implementation for [AgentsML](../../agentsml/) documents
|
|
4
|
+
(`.agentsml.yaml`).
|
|
5
|
+
|
|
6
|
+
## Features
|
|
7
|
+
|
|
8
|
+
| Feature | Description |
|
|
9
|
+
|---|---|
|
|
10
|
+
| **Diagnostics** | JSON Schema validation, YAML parse errors, required keys, version validation, cross-reference resolution, enum validation |
|
|
11
|
+
| **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 |
|
|
12
|
+
| **Hover** | Agent/tool/model/workflow/resource/prompt/policy/MCP/A2A/step info with description, role, model ref, side effects; condition grammar help |
|
|
13
|
+
| **Go to definition** | Jump from a reference to the item it names |
|
|
14
|
+
| **Find references** | List every place a definition is referenced |
|
|
15
|
+
| **Document links** | Turn every reference into a clickable link to its definition |
|
|
16
|
+
| **Document Symbols** | Hierarchical outline of all collections and their items |
|
|
17
|
+
| **Code actions** | A quick fix that creates the missing agent, tool, model, ... when a reference cannot be resolved |
|
|
18
|
+
|
|
19
|
+
Diagnostics are reported at the line and column of the offending value, not at
|
|
20
|
+
the top of the document.
|
|
21
|
+
|
|
22
|
+
## Install
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
cd agentsml-ide/language-server
|
|
26
|
+
pip install -e .
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
This installs the `agentsml-lsp` console script.
|
|
30
|
+
|
|
31
|
+
## Release
|
|
32
|
+
|
|
33
|
+
The package is published to PyPI by the `publish` workflow when a `v*` tag is
|
|
34
|
+
pushed. Bump `project.version` in `pyproject.toml` before tagging — the
|
|
35
|
+
workflow refuses to publish a tag whose version differs from the package
|
|
36
|
+
metadata. See the [project README](../README.md#releasing) for the details.
|
|
37
|
+
|
|
38
|
+
## Run
|
|
39
|
+
|
|
40
|
+
```bash
|
|
41
|
+
# stdio mode — this is what editors use
|
|
42
|
+
python3 src/agentsml_lsp/server.py
|
|
43
|
+
python3 src/agentsml_lsp/server.py # after installation: agentsml-lsp
|
|
44
|
+
|
|
45
|
+
# TCP mode, for debugging with an external LSP client
|
|
46
|
+
python3 src/agentsml_lsp/server.py --tcp --port 2087
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
## Tests
|
|
50
|
+
|
|
51
|
+
```bash
|
|
52
|
+
python3 -m pytest tests/ -v
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
* `tests/test_diagnostics.py` — the diagnostics engine against the shipped
|
|
56
|
+
example documents.
|
|
57
|
+
* `tests/test_server_stdio.py` — an end-to-end LSP session: initialize,
|
|
58
|
+
open a document, check the published diagnostics, completions and hover.
|
|
59
|
+
* `tests/test_completions.py` — the completion constants.
|
|
60
|
+
|
|
61
|
+
## Layout
|
|
62
|
+
|
|
63
|
+
```
|
|
64
|
+
src/agentsml_lsp/server.py LSP server: index, diagnostics, completion, hover, symbols
|
|
65
|
+
src/agentsml_lsp/completions.py Completion constants (top-level keys, profiles, enums)
|
|
66
|
+
tests/ Diagnostics and end-to-end protocol tests
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
## Validation rules
|
|
70
|
+
|
|
71
|
+
| Rule | Severity |
|
|
72
|
+
|---|---|
|
|
73
|
+
| Missing required top-level keys (`agentsml`, `kind`, `metadata`) | Error |
|
|
74
|
+
| Invalid `kind` value | Error |
|
|
75
|
+
| Invalid `agentsml` version | Warning |
|
|
76
|
+
| Missing `metadata.name` | Error |
|
|
77
|
+
| Unknown model/tool/resource/prompt/policy reference in an agent | Error |
|
|
78
|
+
| Unknown agent/tool/workflow/a2a_agent reference in a step | Error |
|
|
79
|
+
| Missing step required field (`id`) | Error |
|
|
80
|
+
| Unknown edge `from`/`to` step ID | Error |
|
|
81
|
+
| Unknown profile name | Warning |
|
|
82
|
+
| Invalid tool `side_effect` value | Warning |
|
|
83
|
+
| Invalid MCP `transport` value | Warning |
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["hatchling"]
|
|
3
|
+
build-backend = "hatchling.build"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "agentsml-lsp"
|
|
7
|
+
version = "0.2.0"
|
|
8
|
+
description = "AgentsML Language Server Protocol implementation"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
license = {text = "MIT"}
|
|
11
|
+
requires-python = ">=3.10"
|
|
12
|
+
dependencies = [
|
|
13
|
+
"pygls>=1.3.0,<2", # 2.x moved LanguageServer to pygls.lsp.server
|
|
14
|
+
"lsprotocol>=2023.0.0",
|
|
15
|
+
"PyYAML>=6.0",
|
|
16
|
+
"jsonschema>=4.0",
|
|
17
|
+
]
|
|
18
|
+
|
|
19
|
+
[project.scripts]
|
|
20
|
+
agentsml-lsp = "agentsml_lsp.server:main"
|
|
21
|
+
|
|
22
|
+
[tool.hatch.build.targets.wheel]
|
|
23
|
+
packages = ["src/agentsml_lsp"]
|
|
24
|
+
|
|
25
|
+
[tool.hatch.build.targets.sdist]
|
|
26
|
+
include = ["src", "tests", "README.md"]
|
|
27
|
+
|
|
28
|
+
[tool.pytest.ini_options]
|
|
29
|
+
testpaths = ["tests"]
|
|
30
|
+
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
"""Context-aware completion providers for the AgentsML language server."""
|
|
2
|
+
|
|
3
|
+
from lsprotocol.types import CompletionItem, CompletionItemKind
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
# Known top-level collection keys in order of the spec
|
|
7
|
+
TOP_LEVEL_KEYS = [
|
|
8
|
+
"agentsml", "kind", "metadata", "profiles",
|
|
9
|
+
"models", "tools", "resources", "prompts",
|
|
10
|
+
"agents", "workflows", "schemas", "policies",
|
|
11
|
+
"deployments", "events", "mcp_servers",
|
|
12
|
+
"a2a_agents", "a2a_server", "ui",
|
|
13
|
+
]
|
|
14
|
+
|
|
15
|
+
# Profile names from the spec
|
|
16
|
+
VALID_PROFILES = [
|
|
17
|
+
"agentsml-core",
|
|
18
|
+
"agentsml-graph",
|
|
19
|
+
"agentsml-conversation",
|
|
20
|
+
"agentsml-rag",
|
|
21
|
+
"agentsml-mcp",
|
|
22
|
+
"agentsml-a2a",
|
|
23
|
+
"agentsml-ui",
|
|
24
|
+
"agentsml-commerce",
|
|
25
|
+
"agentsml-payments",
|
|
26
|
+
"agentsml-enterprise",
|
|
27
|
+
"agentsml-observability",
|
|
28
|
+
]
|
|
29
|
+
|
|
30
|
+
# Tool side_effect enum values
|
|
31
|
+
VALID_SIDE_EFFECTS = ["read", "write", "delete", "payment", "browser", "external", "unknown"]
|
|
32
|
+
|
|
33
|
+
# MCP transport enum values
|
|
34
|
+
VALID_TRANSPORTS = ["stdio", "streamable_http", "sse", "http", "websocket"]
|
|
35
|
+
|
|
36
|
+
# Workflow step join modes
|
|
37
|
+
VALID_JOIN_MODES = ["wait_all", "wait_any"]
|
|
38
|
+
|
|
39
|
+
# Draft 0.3 enums
|
|
40
|
+
VALID_BACKOFFS = ["none", "linear", "exponential"]
|
|
41
|
+
VALID_ON_TIMEOUT = ["error", "return_to_model", "fallback"]
|
|
42
|
+
VALID_REASONING_EFFORTS = ["off", "low", "medium", "high"]
|
|
43
|
+
VALID_APPROVAL_MODES = ["always", "once_per_session", "per_arguments"]
|
|
44
|
+
|
|
45
|
+
# Draft 0.3 keys offered by context: (key, detail)
|
|
46
|
+
STEP_KEYS_03 = [
|
|
47
|
+
("retry", "Retry policy for the step (Draft 0.3)"),
|
|
48
|
+
("timeout", "Step timeout, e.g. 60s or seconds"),
|
|
49
|
+
]
|
|
50
|
+
RETRY_KEYS = [
|
|
51
|
+
("max_attempts", "Maximum attempts including the first"),
|
|
52
|
+
("backoff", "Backoff strategy: none, linear, exponential"),
|
|
53
|
+
("initial_interval", "Delay before the first retry"),
|
|
54
|
+
("max_interval", "Upper bound on the delay between retries"),
|
|
55
|
+
("on_timeout", "Behavior on timeout: error, return_to_model, fallback"),
|
|
56
|
+
]
|
|
57
|
+
AGENT_KEYS_03 = [("reasoning", "Reasoning configuration (Draft 0.3)")]
|
|
58
|
+
REASONING_KEYS = [
|
|
59
|
+
("effort", "Reasoning effort: off, low, medium, high"),
|
|
60
|
+
("budget_tokens", "Token budget for reasoning"),
|
|
61
|
+
("expose_trace", "Whether the reasoning trace is exposed"),
|
|
62
|
+
]
|
|
63
|
+
TOOL_KEYS_03 = [
|
|
64
|
+
("needs_approval", "Require human approval before the tool runs (Draft 0.3)"),
|
|
65
|
+
("approval_mode", "When approval is requested: always, once_per_session, per_arguments"),
|
|
66
|
+
]
|
|
67
|
+
APPROVAL_KEYS_03 = [
|
|
68
|
+
("required", "Whether approval is required"),
|
|
69
|
+
("approvers", "Who may approve"),
|
|
70
|
+
("timeout", "How long to wait for approval"),
|
|
71
|
+
]
|
|
72
|
+
|
|
73
|
+
# Kind constant
|
|
74
|
+
VALID_KINDS = ["AgentSystem"]
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
def top_level_completions() -> list[CompletionItem]:
|
|
78
|
+
"""Return all known top-level collection keys as completions."""
|
|
79
|
+
return [CompletionItem(label=k, kind=CompletionItemKind.Property) for k in TOP_LEVEL_KEYS]
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
def profile_completions() -> list[CompletionItem]:
|
|
83
|
+
"""Return valid profile names as completions."""
|
|
84
|
+
return [CompletionItem(label=p, kind=CompletionItemKind.Enum) for p in VALID_PROFILES]
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
def side_effect_completions() -> list[CompletionItem]:
|
|
88
|
+
"""Return valid tool side_effect values."""
|
|
89
|
+
return [CompletionItem(label=f'"{v}"', kind=CompletionItemKind.Enum) for v in VALID_SIDE_EFFECTS]
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
def transport_completions() -> list[CompletionItem]:
|
|
93
|
+
"""Return valid MCP server transport values."""
|
|
94
|
+
return [CompletionItem(label=f'"{v}"', kind=CompletionItemKind.Enum) for v in VALID_TRANSPORTS]
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
def join_mode_completions() -> list[CompletionItem]:
|
|
98
|
+
"""Return valid workflow step join modes."""
|
|
99
|
+
return [CompletionItem(label=v, kind=CompletionItemKind.Enum) for v in VALID_JOIN_MODES]
|
|
100
|
+
|
|
101
|
+
|
|
102
|
+
def kind_completion() -> CompletionItem:
|
|
103
|
+
"""Return the valid 'kind' constant completion."""
|
|
104
|
+
return CompletionItem(label="AgentSystem", kind=CompletionItemKind.Constant)
|