-
Notifications
You must be signed in to change notification settings - Fork 240
Anna.zhdan/workspance state #832
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
anna239
wants to merge
4
commits into
main
Choose a base branch
from
anna.zhdan/workspance-state
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+184
−1
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,182 @@ | ||
| --- | ||
| title: "Client Editor State Methods" | ||
| --- | ||
|
|
||
| - Author(s): [@anna239](https://github.com/anna239) | ||
|
|
||
| ## Elevator pitch | ||
|
|
||
| Add three optional client methods that expose the current editor state to the agent: | ||
|
|
||
| 1. `workspace/open_documents` for opened files | ||
| 2. `workspace/recent_documents` for recent files | ||
| 3. `workspace/active_document` for the currently focused file | ||
|
|
||
| These methods are intentionally shaped to match VS Code concepts (`workspace.textDocuments`, `window.activeTextEditor`, and VS Code's internal recently-opened model) while preserving ACP conventions and capability-based opt-in. All three methods live under the `workspace/` prefix for consistency. | ||
|
|
||
| ## Status quo | ||
|
|
||
| Today ACP lets an agent read and write files (`fs/read_text_file`, `fs/write_text_file`) when it already knows a path, but there is no standard way to ask: | ||
|
|
||
| 1. Which files are currently opened in the editor? | ||
| 2. Which files were recently opened? | ||
| 3. Which file currently has focus? | ||
|
|
||
| This causes practical issues: | ||
|
|
||
| 1. Agents must infer context from prompt text or external heuristics. | ||
| 2. Clients add context unconditionally, which can decrease the agent's performance. | ||
|
|
||
| ## What we propose to do about it | ||
|
|
||
| Introduce three optional `client` methods and corresponding capabilities: | ||
|
|
||
| 1. `workspace/open_documents` | ||
| 2. `workspace/recent_documents` | ||
| 3. `workspace/active_document` | ||
|
|
||
| Agents must check capability flags before calling these methods. | ||
|
|
||
| ### Capability advertisement | ||
|
|
||
| ```json | ||
| { | ||
| "clientCapabilities": { | ||
| "workspace": { | ||
| "openDocuments": {}, | ||
| "recentDocuments": {}, | ||
| "activeDocument": {} | ||
| } | ||
| } | ||
| } | ||
| ``` | ||
|
|
||
| ### URI rules | ||
|
|
||
| All returned `uri` values **MUST** use the `file:///` scheme with absolute paths. | ||
|
|
||
| ### Method: `workspace/open_documents` | ||
|
|
||
| Returns currently open text documents that map to absolute file paths. | ||
|
|
||
| #### Request | ||
|
|
||
| ```json | ||
| { | ||
| "jsonrpc": "2.0", | ||
| "id": 11, | ||
| "method": "workspace/open_documents", | ||
| "params": { | ||
| "sessionId": "sess_abc123def456" | ||
| } | ||
| } | ||
| ``` | ||
|
|
||
| #### Response | ||
|
|
||
| ```json | ||
| { | ||
| "jsonrpc": "2.0", | ||
| "id": 11, | ||
| "result": { | ||
| "documents": [ | ||
| { | ||
| "uri": "file:///Users/alice/dev/acp/src/client.rs", | ||
| "languageId": "rust" | ||
| }, | ||
| { | ||
| "uri": "file:///Users/alice/dev/acp/docs/protocol/file-system.mdx", | ||
| "languageId": "markdown" | ||
| } | ||
| ] | ||
| } | ||
| } | ||
| ``` | ||
|
|
||
| ### Method: `workspace/recent_documents` | ||
|
|
||
| Returns recently opened files (absolute paths), optionally bounded by `limit`. | ||
|
|
||
| #### Request | ||
|
|
||
| ```json | ||
| { | ||
| "jsonrpc": "2.0", | ||
| "id": 12, | ||
| "method": "workspace/recent_documents", | ||
| "params": { | ||
| "sessionId": "sess_abc123def456", | ||
| "limit": 50 | ||
| } | ||
| } | ||
| ``` | ||
|
|
||
| #### Response | ||
|
|
||
| ```json | ||
| { | ||
| "jsonrpc": "2.0", | ||
| "id": 12, | ||
| "result": { | ||
| "documents": [ | ||
| { | ||
| "uri": "file:///Users/alice/dev/acp/src/rpc.rs", | ||
| "languageId": "rust" | ||
| }, | ||
| { | ||
| "uri": "file:///Users/alice/dev/acp/docs/protocol/session-setup.mdx", | ||
| "languageId": "markdown" | ||
| } | ||
| ] | ||
| } | ||
| } | ||
| ``` | ||
|
|
||
| ### Method: `workspace/active_document` | ||
|
|
||
| Returns the currently focused text editor file, or `null` when no file-backed text editor is focused. | ||
|
|
||
| #### Request | ||
|
|
||
| ```json | ||
| { | ||
| "jsonrpc": "2.0", | ||
| "id": 13, | ||
| "method": "workspace/active_document", | ||
| "params": { | ||
| "sessionId": "sess_abc123def456" | ||
| } | ||
| } | ||
| ``` | ||
|
|
||
| #### Response | ||
|
|
||
| ```json | ||
| { | ||
| "jsonrpc": "2.0", | ||
| "id": 13, | ||
| "result": { | ||
| "document": { | ||
| "uri": "file:///Users/alice/dev/acp/src/client.rs", | ||
| "languageId": "rust" | ||
| } | ||
| } | ||
| } | ||
| ``` | ||
|
|
||
| ## Further development | ||
|
|
||
| Once this exists: | ||
|
|
||
| 1. Agents can implement their own logic for context gathering. | ||
| 2. `workspace/active_document` can be extended with additional fields such as `visibleRange` and cursor `position` to provide richer editor context. | ||
|
|
||
| ## Frequently asked questions | ||
|
|
||
| 1. Why `workspace`? | ||
|
|
||
| Was looking for something general enough that would work not only for IDEs. | ||
|
|
||
| ## Revision history | ||
|
|
||
| - 2026-03-17: Initial draft. | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@anna239 do you want to revisit this in light of the NES experiments and proposed methods?