Open
Conversation
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
title: "Client Editor State Methods"
Elevator pitch
Add three optional client methods that expose the current editor state to the agent:
workspace/open_documentsfor opened filesworkspace/recent_documentsfor recent filesworkspace/active_documentfor the currently focused fileThese 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 theworkspace/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:This causes practical issues:
What we propose to do about it
Introduce three optional
clientmethods and corresponding capabilities:workspace/open_documentsworkspace/recent_documentsworkspace/active_documentAgents must check capability flags before calling these methods.
Capability advertisement
{ "clientCapabilities": { "workspace": { "openDocuments": {}, "recentDocuments": {}, "activeDocument": {} } } }URI rules
All returned
urivalues MUST use thefile:///scheme with absolute paths.Method:
workspace/open_documentsReturns currently open text documents that map to absolute file paths.
Request
{ "jsonrpc": "2.0", "id": 11, "method": "workspace/open_documents", "params": { "sessionId": "sess_abc123def456" } }Response
{ "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_documentsReturns recently opened files (absolute paths), optionally bounded by
limit.Request
{ "jsonrpc": "2.0", "id": 12, "method": "workspace/recent_documents", "params": { "sessionId": "sess_abc123def456", "limit": 50 } }Response
{ "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_documentReturns the currently focused text editor file, or
nullwhen no file-backed text editor is focused.Request
{ "jsonrpc": "2.0", "id": 13, "method": "workspace/active_document", "params": { "sessionId": "sess_abc123def456" } }Response
{ "jsonrpc": "2.0", "id": 13, "result": { "document": { "uri": "file:///Users/alice/dev/acp/src/client.rs", "languageId": "rust" } } }Further development
Once this exists:
workspace/active_documentcan be extended with additional fields such asvisibleRangeand cursorpositionto provide richer editor context.Frequently asked questions
workspace?Was looking for something general enough that would work not only for IDEs.
Revision history