@elyracode/lsp-php 0.9.56 → 0.9.58

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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.9.58] - 2026-11-18
4
+
5
+ ## [0.9.57] - 2026-11-10
6
+
3
7
  ## [0.9.56] - 2026-11-01
4
8
 
5
9
  ## [0.9.55] - 2026-10-21
@@ -1,12 +1,7 @@
1
- import {
2
- type EditToolDetails,
3
- type EditToolInput,
4
- type ExtensionAPI,
5
- isEditToolResult,
6
- } from "@elyracode/coding-agent";
7
1
  import { type ChildProcess, execSync, spawn } from "node:child_process";
8
2
  import { existsSync, readFileSync } from "node:fs";
9
3
  import { join, resolve } from "node:path";
4
+ import { type EditToolDetails, type EditToolInput, type ExtensionAPI, isEditToolResult } from "@elyracode/coding-agent";
10
5
  import { Type } from "typebox";
11
6
 
12
7
  // ── LSP Types ───────────────────────────────────────────────────────────────
@@ -434,7 +429,7 @@ export default function (elyra: ExtensionAPI): void {
434
429
  const locations: LspLocation[] = Array.isArray(result) ? result : [result as LspLocation];
435
430
  if (locations.length === 0) return "No results found.";
436
431
 
437
- const prefix = workingDir + "/";
432
+ const prefix = `${workingDir}/`;
438
433
  return locations
439
434
  .map((loc) => {
440
435
  const p = uriToPath(loc.uri);
@@ -648,117 +643,119 @@ export default function (elyra: ExtensionAPI): void {
648
643
  const message = err instanceof Error ? err.message : String(err);
649
644
  return { content: [{ type: "text", text: `Error: ${message}` }], details: {} };
650
645
  }
651
- },
652
- });
646
+ },
647
+ });
653
648
 
654
- // ── Hook: auto-context, auto-diagnostics, and blast radius on edit ──
655
- elyra.on("tool_result", async (event) => {
656
- if (!initialized || !isEditToolResult(event) || event.isError) return undefined;
649
+ // ── Hook: auto-context, auto-diagnostics, and blast radius on edit ──
650
+ elyra.on("tool_result", async (event) => {
651
+ if (!initialized || !isEditToolResult(event) || event.isError) return undefined;
657
652
 
658
- const input = event.input as unknown as EditToolInput;
659
- if (typeof input?.path !== "string" || !Array.isArray(input.edits)) return undefined;
660
- if (!input.path.endsWith(".php")) return undefined;
653
+ const input = event.input as unknown as EditToolInput;
654
+ if (typeof input?.path !== "string" || !Array.isArray(input.edits)) return undefined;
655
+ if (!input.path.endsWith(".php")) return undefined;
661
656
 
662
- try {
663
- syncFile(input.path);
664
- const absPath = resolve(cwd, input.path);
665
- const fileText = readFileSync(absPath, "utf-8");
666
- const details = event.details as EditToolDetails | undefined;
667
- const fromLine = details?.firstChangedLine ?? 1;
668
- const uri = fileUri(absPath);
669
- const sections: string[] = [];
670
-
671
- // 1. Related symbols: hover summaries for referenced types.
672
- const candidates = new Set<string>();
673
- for (const edit of input.edits) {
674
- for (const s of extractCandidateSymbols(edit.newText, PHP_SYMBOL_STOPLIST, 4)) candidates.add(s);
657
+ try {
658
+ syncFile(input.path);
659
+ const absPath = resolve(cwd, input.path);
660
+ const fileText = readFileSync(absPath, "utf-8");
661
+ const details = event.details as EditToolDetails | undefined;
662
+ const fromLine = details?.firstChangedLine ?? 1;
663
+ const uri = fileUri(absPath);
664
+ const sections: string[] = [];
665
+
666
+ // 1. Related symbols: hover summaries for referenced types.
667
+ const candidates = new Set<string>();
668
+ for (const edit of input.edits) {
669
+ for (const s of extractCandidateSymbols(edit.newText, PHP_SYMBOL_STOPLIST, 4)) candidates.add(s);
670
+ }
671
+ const lookups = [...candidates].slice(0, 5).map(async (symbol) => {
672
+ const pos = findSymbolPosition(fileText, symbol, fromLine);
673
+ if (!pos) return undefined;
674
+ try {
675
+ const result = await sendRequest("textDocument/hover", {
676
+ textDocument: { uri },
677
+ position: positionFromLineCol(pos.line, pos.column),
678
+ });
679
+ const summary = summarizeHover(result);
680
+ return summary ? `- ${symbol}: ${summary}` : undefined;
681
+ } catch {
682
+ return undefined;
675
683
  }
676
- const lookups = [...candidates].slice(0, 5).map(async (symbol) => {
677
- const pos = findSymbolPosition(fileText, symbol, fromLine);
678
- if (!pos) return undefined;
679
- try {
680
- const result = await sendRequest("textDocument/hover", {
681
- textDocument: { uri },
682
- position: positionFromLineCol(pos.line, pos.column),
683
- });
684
- const summary = summarizeHover(result);
685
- return summary ? `- ${symbol}: ${summary}` : undefined;
686
- } catch {
687
- return undefined;
688
- }
689
- });
684
+ });
690
685
 
691
- // 2. Blast radius: references to the edited symbol outside this file.
692
- const blastRadius = (async () => {
693
- try {
694
- const symbolResult = await sendRequest("textDocument/documentSymbol", {
695
- textDocument: { uri },
696
- });
697
- const enclosing = findEnclosingSymbol(flattenSymbols(symbolResult), fromLine - 1);
698
- if (!enclosing) return undefined;
699
-
700
- const refsResult = await sendRequest("textDocument/references", {
701
- textDocument: { uri },
702
- position: { line: enclosing.selLine, character: enclosing.selChar },
703
- context: { includeDeclaration: false },
704
- });
705
- if (!Array.isArray(refsResult)) return undefined;
706
-
707
- const external = (refsResult as LspLocation[]).filter((loc) => uriToPath(loc.uri) !== absPath);
708
- if (external.length === 0) return undefined;
709
-
710
- const prefix = `${cwd}/`;
711
- const shown = external.slice(0, 8).map((loc) => {
712
- const p = uriToPath(loc.uri);
713
- const rel = p.startsWith(prefix) ? p.slice(prefix.length) : p;
714
- return `${rel}:${loc.range.start.line + 1}`;
715
- });
716
- const more = external.length > shown.length ? ` (+${external.length - shown.length} more)` : "";
717
- return `${enclosing.name} is referenced in ${external.length} place${external.length === 1 ? "" : "s"} outside this file:\n${shown.map((s) => `- ${s}`).join("\n")}${more}`;
718
- } catch {
719
- return undefined;
720
- }
721
- })();
722
-
723
- // 3. Fresh diagnostics for the edited file (skip if the edit tool already reported diagnostics).
724
- const freshDiagnostics = (async () => {
725
- if (hasExistingDiagnostics(event.content)) return undefined;
726
- try {
727
- await waitForDiagnostics(uri, 1500);
728
- const errors = (diagnosticsByUri.get(uri) ?? []).filter((d) => (d.severity ?? 1) === 1);
729
- if (errors.length === 0) return undefined;
730
- const shown = errors.slice(0, 8).map((d) => {
731
- const code = d.code ? ` [${d.code}]` : "";
732
- return `- ${input.path}:${d.range.start.line + 1}:${d.range.start.character + 1}${code}: ${d.message.split("\n")[0]}`;
733
- });
734
- const more = errors.length > shown.length ? ` (+${errors.length - shown.length} more)` : "";
735
- return `${errors.length} error${errors.length === 1 ? "" : "s"} in this file after the edit:\n${shown.join("\n")}${more}`;
736
- } catch {
737
- return undefined;
738
- }
739
- })();
740
-
741
- const [hoverLines, blast, diag] = await Promise.all([Promise.all(lookups), blastRadius, freshDiagnostics]);
742
-
743
- const related = hoverLines.filter((l): l is string => !!l);
744
- if (diag) sections.push(`[Diagnostics \u2014 auto-checked via LSP]\n${diag}`);
745
- if (blast) sections.push(`[Blast radius \u2014 auto-resolved via LSP]\n${blast}`);
746
- if (related.length > 0) {
747
- sections.push(`[Related symbols \u2014 auto-resolved via LSP, no extra tool call needed]\n${related.join("\n")}`);
686
+ // 2. Blast radius: references to the edited symbol outside this file.
687
+ const blastRadius = (async () => {
688
+ try {
689
+ const symbolResult = await sendRequest("textDocument/documentSymbol", {
690
+ textDocument: { uri },
691
+ });
692
+ const enclosing = findEnclosingSymbol(flattenSymbols(symbolResult), fromLine - 1);
693
+ if (!enclosing) return undefined;
694
+
695
+ const refsResult = await sendRequest("textDocument/references", {
696
+ textDocument: { uri },
697
+ position: { line: enclosing.selLine, character: enclosing.selChar },
698
+ context: { includeDeclaration: false },
699
+ });
700
+ if (!Array.isArray(refsResult)) return undefined;
701
+
702
+ const external = (refsResult as LspLocation[]).filter((loc) => uriToPath(loc.uri) !== absPath);
703
+ if (external.length === 0) return undefined;
704
+
705
+ const prefix = `${cwd}/`;
706
+ const shown = external.slice(0, 8).map((loc) => {
707
+ const p = uriToPath(loc.uri);
708
+ const rel = p.startsWith(prefix) ? p.slice(prefix.length) : p;
709
+ return `${rel}:${loc.range.start.line + 1}`;
710
+ });
711
+ const more = external.length > shown.length ? ` (+${external.length - shown.length} more)` : "";
712
+ return `${enclosing.name} is referenced in ${external.length} place${external.length === 1 ? "" : "s"} outside this file:\n${shown.map((s) => `- ${s}`).join("\n")}${more}`;
713
+ } catch {
714
+ return undefined;
715
+ }
716
+ })();
717
+
718
+ // 3. Fresh diagnostics for the edited file (skip if the edit tool already reported diagnostics).
719
+ const freshDiagnostics = (async () => {
720
+ if (hasExistingDiagnostics(event.content)) return undefined;
721
+ try {
722
+ await waitForDiagnostics(uri, 1500);
723
+ const errors = (diagnosticsByUri.get(uri) ?? []).filter((d) => (d.severity ?? 1) === 1);
724
+ if (errors.length === 0) return undefined;
725
+ const shown = errors.slice(0, 8).map((d) => {
726
+ const code = d.code ? ` [${d.code}]` : "";
727
+ return `- ${input.path}:${d.range.start.line + 1}:${d.range.start.character + 1}${code}: ${d.message.split("\n")[0]}`;
728
+ });
729
+ const more = errors.length > shown.length ? ` (+${errors.length - shown.length} more)` : "";
730
+ return `${errors.length} error${errors.length === 1 ? "" : "s"} in this file after the edit:\n${shown.join("\n")}${more}`;
731
+ } catch {
732
+ return undefined;
748
733
  }
749
- if (sections.length === 0) return undefined;
734
+ })();
750
735
 
751
- const contextBlock = `\n\n${sections.join("\n\n")}`;
752
- return { content: [...event.content, { type: "text" as const, text: contextBlock }] };
753
- } catch {
754
- return undefined;
736
+ const [hoverLines, blast, diag] = await Promise.all([Promise.all(lookups), blastRadius, freshDiagnostics]);
737
+
738
+ const related = hoverLines.filter((l): l is string => !!l);
739
+ if (diag) sections.push(`[Diagnostics \u2014 auto-checked via LSP]\n${diag}`);
740
+ if (blast) sections.push(`[Blast radius \u2014 auto-resolved via LSP]\n${blast}`);
741
+ if (related.length > 0) {
742
+ sections.push(
743
+ `[Related symbols \u2014 auto-resolved via LSP, no extra tool call needed]\n${related.join("\n")}`,
744
+ );
755
745
  }
756
- });
746
+ if (sections.length === 0) return undefined;
747
+
748
+ const contextBlock = `\n\n${sections.join("\n\n")}`;
749
+ return { content: [...event.content, { type: "text" as const, text: contextBlock }] };
750
+ } catch {
751
+ return undefined;
752
+ }
757
753
  });
754
+ });
758
755
 
759
- // ── Shutdown ────────────────────────────────────────────
756
+ // ── Shutdown ────────────────────────────────────────────
760
757
 
761
- elyra.on("session_shutdown", async () => {
758
+ elyra.on("session_shutdown", async () => {
762
759
  if (lspProcess && initialized) {
763
760
  try {
764
761
  await sendRequest("shutdown", null);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@elyracode/lsp-php",
3
- "version": "0.9.56",
3
+ "version": "0.9.58",
4
4
  "description": "PHP LSP integration for Elyra — semantic code navigation and diagnostics for Laravel and PHP projects",
5
5
  "type": "module",
6
6
  "keywords": [