Add readonly editor context capabilities for agents
Maintainer antworten meist innerhalb von 2 Tagen
Dieses Issue hat noch niemand übernommen.
Bewertung
- Schwierigkeit
- 5/5
- Geschätzter Aufwand
- Über eine Woche
- Anfängerfreundlichkeit
- 38/100
- Issue-Typ
- Feature
- Klarheit
- Größtenteils klar
- Aktivitätsstatus
- Ruhig
- Tech-Stack
- clojure
- Bereich
- backend-api-design
Rechercherichtung
Start by locating the existing editor/getDiagnostics request, client capability handling, and protocol definitions; the issue does not name specific files or tests. Compare those paths with the editor-client implementations, especially eca-emacs, and identify how the initial symbolAtPosition, definitions, and documentSymbols scope fits the shared protocol. Done means the editor-agnostic request and per-feature capabilities support partial or unavailable results, with cursor/range filtering for diagnostics.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
To upvote this issue, give it a thumbs up. See this list for the most upvoted issues.
Add readonly editor context capabilities for agents
Summary
ECA already supports editor/getDiagnostics, where the server asks the client/editor for diagnostics and the client maps editor-specific data into ECA protocol data.
We should add a similar readonly editor/getContext request so agents can ask the editor for semantic/navigation context around the current cursor instead of relying only on raw file reads and text search.
This should be editor-agnostic. eca-emacs can implement it via Emacs APIs, while VS Code/IntelliJ clients can implement the same protocol via their own APIs.
Motivation
Agents currently infer too much from text. For example, to understand a symbol under the cursor, the agent may grep for the name and read several files. Editors already know better through xref/LSP/PSI/indexes.
Readonly editor context would let the agent ask questions like:
- what symbol is under the cursor?
- where is its definition?
- what are the top-level symbols in this file?
- what diagnostic is at/near the cursor?
This should reduce wrong file reads, bad grep matches, and hallucinated API usage.
Proposed API
Add a new client capability, ideally per feature:
{
"editor": {
"diagnostics": true,
"context": {
"symbolAtPosition": true,
"documentSymbols": true,
"definitions": true,
"documentation": true,
"references": true,
"workspace": true,
"enclosingSymbols": true
}
}
}
Add a request:
editor/getContext
Example params:
{
"uri": "file:///repo/src/foo.clj",
"position": { "line": 42, "character": 10 },
"include": ["symbolAtPosition", "definitions", "documentSymbols"],
"limit": 100
}
The response should be best-effort and support unavailable capabilities:
{
"symbolAtPosition": { "text": "foo", "range": { "...": "..." } },
"definitions": [],
"documentSymbols": [],
"unavailable": [
{ "capability": "documentation", "reason": "No provider available" }
]
}
Initial scope
Start small:
-
symbolAtPosition- Helps the agent know what the user is pointing at.
- Emacs:
thing-at-point/ bounds. - VS Code: word range at position.
- IntelliJ: PSI element at caret.
- Gotcha: often textual, not fully semantic.
-
definitions- Replaces grep-based “find definition” with editor/language-backed resolution.
- Emacs:
xref. - VS Code/LSP: definition provider /
textDocument/definition. - IntelliJ: resolve / go to declaration.
- Gotcha: may return multiple targets or declarations instead of implementations.
-
documentSymbols- Gives the agent a compact outline of the current file.
- Emacs:
imenuindex. - VS Code/LSP: document symbols.
- IntelliJ: structure view / PSI.
- Gotcha: Emacs
imenumay provide positions but not full ranges.
Also extend editor/getDiagnostics with optional cursor/range filtering:
{
"uri": "file:///repo/src/foo.clj",
"position": { "line": 42, "character": 10 }
}
This should return/prioritize diagnostics at or near the cursor. Current diagnostics already include uri, range, severity, code, source, and message, so this is about relevance, not adding basic metadata.
Later additions
After the initial API is working, consider:
-
documentation- Emacs:
eldoc. - VS Code/LSP: hover/signature help.
- IntelliJ: quick documentation.
- Useful to avoid guessing APIs.
- Emacs:
-
references- Emacs:
xref. - VS Code/LSP: references provider.
- IntelliJ: find usages.
- Useful for refactors, but can be expensive; require explicit include and limit.
- Emacs:
-
workspace- Return workspace roots, current file, open/visible files.
- Avoid returning all project files by default.
-
enclosingSymbols- Current function/class/method around cursor.
- Best-effort only. Easy with PSI/tree-sitter or document symbol ranges; unreliable with plain Imenu if ranges are missing.
-
codeActions- Quick fixes for diagnostics.
- Useful but not readonly; probably separate design later.
Design constraints
- Keep
editor/getDiagnosticsandeditor/getContextseparate. - Use per-feature capabilities; not all clients will support everything.
- Return partial results and explicit
unavailableentries. - Avoid expensive defaults (
references, full workspace file list). - Do not make this Emacs-specific.
- Treat textual and semantic results differently where needed.
Suggested first implementation for eca-emacs
symbolAtPosition:thing-at-point/bounds-of-thing-at-pointdefinitions:xrefdocumentSymbols: programmatic Imenu index, not the interactiveimenucommand- diagnostics near cursor: filter existing collected diagnostics by range/distance
- Vorherrschende Sprache
- Clojure
- Sterne
- 1k
- Forks
- 82
- Ø Merge
- 1 T. 19 Std.
- Gemergte PRs (30 T.)
- 18
Entwicklungsumgebung
Dieses Projekt bietet weder Dev-Container noch Dockerfile noch Beitragsleitfaden – die Einrichtung liegt bei Ihnen. Beginnen Sie mit der README; die allgemeinen Schritte stehen in unserem Leitfaden für den ersten Beitrag.
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus editor-code-assistant/eca
-
Models doesn't work when fetchModels: false is usedEvtl. vergeben @zikajk hat das heute übernommen. Offenbug
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 78/100
editor-code-assistant/eca#661 · 1 zugewiesene Person ·
Maintainer antworten meist innerhalb von 2 Tagen
-
Schwierigkeit 3/5 1-2 Tage Anfängerfreundlichkeit 56/100
editor-code-assistant/eca#662 · 1 Reaktion ·
Maintainer antworten meist innerhalb von 2 Tagen
-
bug
Schwierigkeit 4/5 3-5 Tage Anfängerfreundlichkeit 25/100
editor-code-assistant/eca#652 · 1 Kommentar ·
Maintainer antworten meist innerhalb von 2 Tagen
-
Schwierigkeit 5/5 Über eine Woche Anfängerfreundlichkeit 12/100
editor-code-assistant/eca#648 · 1 Kommentar ·
Maintainer antworten meist innerhalb von 2 Tagen
-
Schwierigkeit 3/5 1-2 Tage Anfängerfreundlichkeit 35/100
editor-code-assistant/eca#644 · 1 Kommentar · 1 Reaktion ·
Maintainer antworten meist innerhalb von 2 Tagen
Alle Issues in editor-code-assistant/eca
Ähnliche Issues
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 84/100
nrepl/piggieback#163 ·
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 78/100
clojure-emacs/orchard#436 ·
-
Priority:P3
Schwierigkeit 1/5 1-3 Stunden Anfängerfreundlichkeit 82/100
metabase/metabase#85025 · 1 Kommentar ·
Maintainer antworten meist innerhalb von 1 Tag
-
Page titles with `$$`, `$&`, `` $` `` or `$'` change when block refs are resolvedEvtl. vergeben @RaphaelFakhri hat das vor 1 Tag übernommen. Offen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 76/100
-
measured/expr fails for array-typed locals: tag from getCanonicalName ("long[]") cannot be resolvedOffenBug
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 66/100
hugoduncan/criterium#156 ·