| title | Client Editor State Methods |
|---|
- Author(s): @anna239
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 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.
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:
- Which files are currently opened in the editor?
- Which files were recently opened?
- Which file currently has focus?
This causes practical issues:
- Agents must infer context from prompt text or external heuristics.
- Clients add context unconditionally, which can decrease the agent's performance.
Introduce three optional client methods and corresponding capabilities:
workspace/open_documentsworkspace/recent_documentsworkspace/active_document
Agents must check capability flags before calling these methods.
{
"clientCapabilities": {
"workspace": {
"openDocuments": {},
"recentDocuments": {},
"activeDocument": {}
}
}
}All returned uri values MUST use the file:/// scheme with absolute paths.
Returns currently open text documents that map to absolute file paths.
{
"jsonrpc": "2.0",
"id": 11,
"method": "workspace/open_documents",
"params": {
"sessionId": "sess_abc123def456"
}
}{
"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"
}
]
}
}Returns recently opened files (absolute paths), optionally bounded by limit.
{
"jsonrpc": "2.0",
"id": 12,
"method": "workspace/recent_documents",
"params": {
"sessionId": "sess_abc123def456",
"limit": 50
}
}{
"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"
}
]
}
}Returns the currently focused text editor file, or null when no file-backed text editor is focused.
{
"jsonrpc": "2.0",
"id": 13,
"method": "workspace/active_document",
"params": {
"sessionId": "sess_abc123def456"
}
}{
"jsonrpc": "2.0",
"id": 13,
"result": {
"document": {
"uri": "file:///Users/alice/dev/acp/src/client.rs",
"languageId": "rust"
}
}
}Once this exists:
- Agents can implement their own logic for context gathering.
workspace/active_documentcan be extended with additional fields such asvisibleRangeand cursorpositionto provide richer editor context.
- Why
workspace?
Was looking for something general enough that would work not only for IDEs.
- 2026-03-17: Initial draft.