Hacktoberfest 2026 : les issues que les mainteneurs ont marquées pour octobre, ouvertes et accessibles aux débutants. Parcourir les issues Hacktoberfest

Add readonly editor context capabilities for agents

Ouverte
#520 5 commentaires 1 réaction 0 personnes assignées Voir sur GitHub

Les mainteneurs répondent en général sous 2 jours

Personne n'a encore pris cette issue.

Évaluation

Difficulté
5/5
Temps estimé
Plus d'une semaine
Accessibilité débutants
38/100
Type d'issue
Fonctionnalité
Clarté
Plutôt claire
Activité
Calme
Stack technique
clojure

Piste de recherche

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.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Description

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:

  1. 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.
  2. 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.
  3. documentSymbols

    • Gives the agent a compact outline of the current file.
    • Emacs: imenu index.
    • VS Code/LSP: document symbols.
    • IntelliJ: structure view / PSI.
    • Gotcha: Emacs imenu may 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.
  • references

    • Emacs: xref.
    • VS Code/LSP: references provider.
    • IntelliJ: find usages.
    • Useful for refactors, but can be expensive; require explicit include and limit.
  • 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/getDiagnostics and editor/getContext separate.
  • Use per-feature capabilities; not all clients will support everything.
  • Return partial results and explicit unavailable entries.
  • 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-point
  • definitions: xref
  • documentSymbols: programmatic Imenu index, not the interactive imenu command
  • diagnostics near cursor: filter existing collected diagnostics by range/distance
Langage dominant
Clojure
Étoiles
1k
Forks
82
Merge moyen
3 j 39 min
PR mergées (30 j)
15

Préparer son environnement

Ce projet ne fournit ni conteneur de développement, ni Dockerfile, ni guide de contribution : l'installation est à votre charge. Commencez par son README, et consultez notre guide de la première contribution pour les étapes générales.

Par où commencer

  1. Lisez l'issue en entier, puis le guide de contribution du projet.
  2. Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
  3. Forkez le dépôt et travaillez sur une branche.
  4. Ouvrez une pull request qui référence le numéro de l'issue.

Autres issues de editor-code-assistant/eca

Toutes les issues de editor-code-assistant/eca

Issues similaires

Plus d'issues Clojure

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.