The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
feat(lsp): route .blade.php to laravel-lsp; plain .php stays on intelephense
teknium1d4d9b76d8c72
diff --git a/agent/lsp/install.py b/agent/lsp/install.pyindex 01e81615a53..d4c2f2e4950 100644--- a/agent/lsp/install.py+++ b/agent/lsp/install.py@@ -65,6 +65,8 @@ INSTALL_RECIPES: Dict[str, Dict[str, Any]] = {"rust-analyzer": _manual("rust-analyzer"),"clangd": _manual("clangd"),"lua-language-server": _manual("lua-language-server"),+ # laravel-lsp ships via composer (`composer global require laravel/lsp`), not npm.+ "laravel-lsp": _manual("laravel-lsp"),# PowerShellEditorServices is a release-zip bundle driven by pwsh; we probe# the host so `hermes lsp status` reports its presence."powershell": _manual("pwsh"),diff --git a/agent/lsp/servers.py b/agent/lsp/servers.pyindex ea62bf95f85..4efab4db318 100644--- a/agent/lsp/servers.py+++ b/agent/lsp/servers.py@@ -34,7 +34,7 @@ _EXTS_BY_LANGUAGE: Dict[str, Sequence[str]] = {"csharp": (".cs", ".csx"), "fsharp": (".fs", ".fsi", ".fsx"),"swift": (".swift",), "java": (".java",), "kotlin": (".kt", ".kts"),"yaml": (".yaml", ".yml"), "json": (".json",), "jsonc": (".jsonc",),- "lua": (".lua",), "php": (".php",), "prisma": (".prisma",), "dart": (".dart",),+ "lua": (".lua",), "php": (".php",), "blade": (".blade.php",), "prisma": (".prisma",), "dart": (".dart",),"ocaml": (".ml", ".mli"),"shellscript": (".sh", ".bash", ".zsh"),"terraform": (".tf", ".tfvars"),@@ -94,10 +94,16 @@ class ServerContext:# ---- helpers ----+# Multi-part extensions that name a different language than their last segment: ``os.path.splitext``+# would reduce ``home.blade.php`` to ``.php`` and hand Blade templates to the plain-PHP server.+_COMPOUND_EXTS = (".blade.php",)++def _file_ext_or_basename(path: str) -> str:- """Lower-cased extension, or the full basename for extensionless files (``Dockerfile``)."""+ """Lower-cased extension (compound ones first), or the full basename for extensionless files (``Dockerfile``)."""base = os.path.basename(path)- return os.path.splitext(base)[1].lower() or base+ lower = base.lower()+ return next((c for c in _COMPOUND_EXTS if lower.endswith(c)), None) or os.path.splitext(base)[1].lower() or basedef _which(*names: str) -> Optional[str]:@@ -364,6 +370,9 @@ SERVERS: List[ServerDef] = [_server("lua-language-server", (".lua",), "Lua — lua-language-server",markers=[".luarc.json", ".luarc.jsonc", ".luacheckrc", ".stylua.toml", "stylua.toml", "selene.toml", "selene.yml"],install_pkg="lua-language-server"),+ # Before intelephense: Blade templates are Laravel's, plain .php stays with intelephense.+ _server("laravel-lsp", (".blade.php",), "Laravel Blade — laravel-lsp (manual: composer global require laravel/lsp)",+ markers=["artisan", "composer.json", "composer.lock"], args=("lsp",)),_server("intelephense", (".php",), "PHP — intelephense", markers=["composer.json", "composer.lock", ".php-version"],args=("--stdio",), install_pkg="intelephense", base_init={"telemetry": {"enabled": False}}),_server("ocaml-lsp", (".ml", ".mli"), "OCaml — ocaml-lsp", markers=["dune-project", "dune-workspace", ".merlin", "opam"],diff --git a/tests/agent/lsp/test_compound_extensions.py b/tests/agent/lsp/test_compound_extensions.pynew file mode 100644index 00000000000..6a73e18feba--- /dev/null+++ b/tests/agent/lsp/test_compound_extensions.py@@ -0,0 +1,17 @@+"""Compound extensions (``.blade.php``) route to their own server; the last segment alone keeps its server."""+from agent.lsp.servers import ServerContext, find_server_for_file, language_id_for+++def test_blade_templates_route_to_laravel_lsp_and_plain_php_stays_on_intelephense(monkeypatch, tmp_path):+ blade = "/app/resources/views/Home.BLADE.php"+ assert find_server_for_file(blade).server_id == "laravel-lsp"+ assert language_id_for(blade) == "blade"+ assert find_server_for_file("/app/app/Models/User.php").server_id == "intelephense"+ assert language_id_for("/app/app/Models/User.php") == "php"+ # Manual-install server: spawns `laravel-lsp lsp` only when the binary resolves; None otherwise.+ srv = find_server_for_file(blade)+ monkeypatch.setattr("agent.lsp.servers._which", lambda *names: None)+ assert srv.build_spawn(str(tmp_path), ServerContext(str(tmp_path), install_strategy="manual")) is None+ monkeypatch.setattr("agent.lsp.servers._which", lambda *names: "/usr/local/bin/laravel-lsp")+ spec = srv.build_spawn(str(tmp_path), ServerContext(str(tmp_path), install_strategy="manual"))+ assert spec.command == ["/usr/local/bin/laravel-lsp", "lsp"]diff --git a/website/docs/user-guide/features/lsp.md b/website/docs/user-guide/features/lsp.mdindex dca50d5b170..db3069b885b 100644--- a/website/docs/user-guide/features/lsp.md+++ b/website/docs/user-guide/features/lsp.md@@ -72,6 +72,7 @@ agent sees a syntax-clean file with semantic problems as| YAML | `yaml-language-server` | npm || Lua | `lua-language-server` | manual (GitHub releases) || PHP | `intelephense` | npm |+| Laravel Blade (`.blade.php`) | `laravel-lsp` | manual (composer) || OCaml | `ocaml-lsp` | manual (opam) || Dockerfile | `dockerfile-language-server-nodejs` | npm || Terraform | `terraform-ls` | manual |@@ -115,6 +116,22 @@ host. Setup:bundle is missing you'll see a one-time warning in the logs with thedownload link.+### Laravel Blade++`.blade.php` templates go to [laravel-lsp](https://github.com/laravel/lsp)+(Blade, Eloquent, Facades) while plain `.php` files stay with+intelephense. Install it once with Composer and make sure the binary+is on PATH (or pin it with `lsp.servers.laravel-lsp.command`):++```bash+composer global require laravel/lsp+export PATH="$HOME/.config/composer/vendor/bin:$PATH"+```++Hermes launches it as `laravel-lsp lsp` (stdio). There is no+auto-install recipe; `hermes lsp status` shows `manual-only` until the+binary is found.+A few servers are installed alongside a peer dependency that npmwon't auto-pull. `typescript-language-server` and `@vue/language-server`require the `typescript` SDK importable from the same `node_modules`