zed/crates
David Soria Parra 02ea6ac845
context_servers: Add initial implementation (#16103)
This commit proposes the addition of "context serveres" and the
underlying protocol (model context protocol). Context servers allow
simple definition of slash commands in another language and running
local on the user machines. This aims to quickly prototype new commands,
and provide a way to add personal (or company wide) customizations to
the assistant panel, without having to maintain an extension. We can
use this to reuse our existing codebase, with authenticators, etc and
easily have it provide context into the assistant panel.

As such it occupies a different design space as extensions, which I
think are
more aimed towards long-term, well maintained pieces of code that can be
easily distributed.

It's implemented as a central crate for easy reusability across the
codebase
and to easily hook into the assistant panel at all points.

Design wise there are a few pieces:
1. client.rs: A simple JSON-RPC client talking over stdio to a spawned
server. This is
very close to how LSP work and likely there could be a combined client
down the line.
2. types.rs: Serialization and deserialization client for the underlying
model context protocol.
3. protocol.rs: Handling the session between client and server.
4. manager.rs: Manages settings and adding and deleting servers from a
central pool.

A server can be defined in the settings.json as:

```
"context_servers": [
   {"id": "test", "executable": "python", "args": ["-m", "context_server"]
]
```

## Quick Example
A quick example of how a theoretical backend site can look like. With
roughly 100 lines
of code (nicely generated by Claude) and a bit of decorator magic (200
lines in total), one
can come up with a framework that makes it as easy as:

```python
@context_server.slash_command(name="rot13", description="Perform a rot13 transformation")
@context_server.argument(name="input", type=str, help="String to rot13")
async def rot13(input: str) -> str:
    return ''.join(chr((ord(c) - 97 + 13) % 26 + 97) if c.isalpha() else c for c in echo.lower())
```

to define a new slash_command.

## Todo:
 - Allow context servers to be defined in workspace settings.
 - Allow passing env variables to context_servers


Release Notes:

- N/A

---------

Co-authored-by: Marshall Bowers <elliott.codes@gmail.com>
2024-08-15 10:49:30 -04:00
..
activity_indicator Start on adding support for editing via the assistant panel (#14795) 2024-07-19 11:13:15 +02:00
anthropic Make LanguageModel::use_any_tool return a stream of chunks (#16262) 2024-08-14 18:02:46 -07:00
assets Allow prompt templates to be overridden in the zed configuration directory (#15887) 2024-08-06 19:30:48 -06:00
assistant context_servers: Add initial implementation (#16103) 2024-08-15 10:49:30 -04:00
assistant_slash_command context_servers: Add initial implementation (#16103) 2024-08-15 10:49:30 -04:00
audio Make tests less noisy (#12463) 2024-05-29 18:06:45 -07:00
auto_update Add is_staff and destination to download events (#15445) 2024-07-29 14:21:29 -04:00
breadcrumbs breadcrumbs: Use early return in set_active_pane_item (#14691) 2024-07-17 18:58:44 -04:00
call chore: Fix clippy violations from Cargo.toml (#15216) 2024-07-25 20:22:01 +02:00
channel Update http crate name (#15041) 2024-07-23 15:01:05 -07:00
cli Change PathLikeWithPosition<P> into a non-generic type and replace ad-hoc Windows path parsing (#15373) 2024-07-30 16:39:33 +03:00
client assistant: Require user to accept TOS for cloud provider (#16111) 2024-08-12 17:43:35 +02:00
clock Lay the groundwork for collaborating on assistant panel (#13991) 2024-07-10 17:36:22 +02:00
collab collab: Add ability to revoke LLM service access tokens (#16143) 2024-08-12 21:47:05 -04:00
collab_ui Copy/paste images into editors (Mac only) (#15782) 2024-08-13 13:18:25 -04:00
collections gpui: Add SVG rendering to img element and generic asset cache (#9931) 2024-03-29 17:09:49 -07:00
command_palette command_palette: Remove project as a dependency in Cargo.toml (#16082) 2024-08-12 13:01:32 -04:00
command_palette_hooks Introduce InlineCompletionProvider (#9777) 2024-03-26 13:28:06 +01:00
context_servers context_servers: Add initial implementation (#16103) 2024-08-15 10:49:30 -04:00
copilot Copy/paste images into editors (Mac only) (#15782) 2024-08-13 13:18:25 -04:00
db paths: Replace lazy_static! with OnceLock (#13213) 2024-06-18 12:22:37 -04:00
dev_server_projects remoting: Allow Add/Remove remote folder (#14532) 2024-07-16 12:01:59 -06:00
diagnostics assistant: Polish /workflow and steps UI (#15936) 2024-08-08 15:46:33 +02:00
editor Disable forceful sorting of the slash command argument completions (#16240) 2024-08-14 22:34:25 +03:00
extension Fix slash command argument completion bugs (#16233) 2024-08-14 19:36:55 +03:00
extension_api zed_extension_api: Release v0.1.0 (#16254) 2024-08-14 17:33:17 -04:00
extension_cli Provide user agent when performing HTTP requests (#15470) 2024-07-30 11:12:37 +02:00
extensions_ui Feature/fallback fonts (#15306) 2024-07-26 16:42:21 -07:00
feature_flags Clean up inline assist editor rendering (#15536) 2024-07-31 17:43:08 +02:00
feedback Copy/paste images into editors (Mac only) (#15782) 2024-08-13 13:18:25 -04:00
file_finder Improve slash commands (#16195) 2024-08-13 23:06:07 -07:00
file_icons chore: Clean up allocs around project panel (#15422) 2024-07-29 14:21:41 +02:00
fs zed: Mark restored buffers as conflicted if file changed on disk between store & restore (#15207) 2024-07-25 18:04:47 +02:00
fsevent Retain run loop (#11241) 2024-04-30 23:31:59 -06:00
fuzzy Improve slash commands (#16195) 2024-08-13 23:06:07 -07:00
git Update http crate name (#15041) 2024-07-23 15:01:05 -07:00
git_hosting_providers Update http crate name (#15041) 2024-07-23 15:01:05 -07:00
go_to_line Handle buffer diff base updates and file renames properly for SSH projects (#14989) 2024-07-23 11:32:37 -07:00
google_ai Authorize access to language model providers based on country (#15859) 2024-08-06 11:49:04 -04:00
gpui Make LanguageModel::use_any_tool return a stream of chunks (#16262) 2024-08-14 18:02:46 -07:00
gpui_macros Use US English spelling of "behavior" and "customize" (#15117) 2024-07-24 16:36:01 -04:00
headless remoting: Allow Add/Remove remote folder (#14532) 2024-07-16 12:01:59 -06:00
html_to_markdown Publish html_to_markdown (#13718) 2024-07-01 17:18:58 -04:00
http_client Introduce a separate backend service for LLM calls (#15831) 2024-08-05 20:26:21 -04:00
image_viewer Add text_color helper for tab contents (#14737) 2024-07-18 09:27:05 -04:00
indexed_docs indexed_docs: Normalize - in crate names to _ when computing rustdoc output path (#16234) 2024-08-14 12:37:02 -04:00
inline_completion_button inline_completion_button: Do some cleanup (#15849) 2024-08-06 08:55:27 -04:00
install_cli Fix flickering (#9012) 2024-03-11 10:45:57 +01:00
journal Add the ability for extensions to provide language settings (#10296) 2024-04-08 19:17:12 -04:00
language outline: Match on full item path in Outline::find_most_similar (#16206) 2024-08-14 14:03:28 +02:00
language_model Make WorkflowStepResolution an entity (#16268) 2024-08-14 22:44:44 -07:00
language_selector Move Clippy configuration to the workspace level (#8891) 2024-03-05 12:01:17 -05:00
language_tools Add GitHub Copilot Chat Support (#14842) 2024-07-30 09:32:58 +02:00
languages Recognize Cuda files as C++ (#16098) 2024-08-13 14:44:48 -04:00
live_kit_client Copy/paste images into editors (Mac only) (#15782) 2024-08-13 13:18:25 -04:00
live_kit_server live_kit_server: Re-remove protocol submodule (#15317) 2024-07-26 21:10:56 -04:00
lsp chore: Bump Rust version to 1.80 (#15186) 2024-07-25 22:48:42 +02:00
markdown Copy/paste images into editors (Mac only) (#15782) 2024-08-13 13:18:25 -04:00
markdown_preview markdown preview: Detect language of buffer correctly (#15961) 2024-08-08 11:53:37 +02:00
media linux: Better GPU debugging (#14706) 2024-07-23 09:56:45 -06:00
menu open picker (#14524) 2024-07-15 17:04:15 -06:00
multi_buffer Fix regression: Restore creation of multiple assist editors on ctrl-enter when selections span across multiple excerpts (#16190) 2024-08-13 17:19:10 -06:00
node_runtime windows: Fix eslint installation (#15331) 2024-07-27 10:24:05 -04:00
notifications chore: Remove a bunch of unused structs (#16139) 2024-08-13 01:43:19 +02:00
ollama Make LanguageModel::use_any_tool return a stream of chunks (#16262) 2024-08-14 18:02:46 -07:00
open_ai Make LanguageModel::use_any_tool return a stream of chunks (#16262) 2024-08-14 18:02:46 -07:00
outline Handle buffer diff base updates and file renames properly for SSH projects (#14989) 2024-07-23 11:32:37 -07:00
outline_panel Copy/paste images into editors (Mac only) (#15782) 2024-08-13 13:18:25 -04:00
paths Copy/paste images into editors (Mac only) (#15782) 2024-08-13 13:18:25 -04:00
picker vim remap 2 (#15193) 2024-07-25 09:00:53 -06:00
prettier Lookup prettier more leniently (#14403) 2024-07-13 21:59:14 +03:00
project Fix a bug where directories were not matching in the fuzzy matcher, when query contains the worktree root name (#16242) 2024-08-14 12:43:00 -07:00
project_panel Fix a bug where directories were not matching in the fuzzy matcher, when query contains the worktree root name (#16242) 2024-08-14 12:43:00 -07:00
project_symbols Start on adding support for editing via the assistant panel (#14795) 2024-07-19 11:13:15 +02:00
proto assistant panel: Stop animation & show explicit state if canceled (#16200) 2024-08-14 11:18:40 +02:00
quick_action_bar assistant: Add debug inspector (#16105) 2024-08-12 17:05:54 +02:00
recent_projects recent_project: Fix overflow sub (#15965) 2024-08-08 15:58:59 +02:00
refineable Move Clippy configuration to the workspace level (#8891) 2024-03-05 12:01:17 -05:00
release_channel auto-updates: Do not poll for updates on dev channel (#13311) 2024-06-20 15:00:54 +02:00
remote SSH remoting: terminal & tasks (#15321) 2024-07-28 22:45:00 -06:00
remote_server Run clippy for Windows (#15318) 2024-07-26 21:38:34 -04:00
repl Copy/paste images into editors (Mac only) (#15782) 2024-08-13 13:18:25 -04:00
rich_text chore: Bump Rust version to 1.80 (#15186) 2024-07-25 22:48:42 +02:00
rope Skip over folded regions when iterating over multibuffer chunks (#15646) 2024-08-02 19:51:26 +02:00
rpc Apply rate limits in LLM service (#15997) 2024-08-08 15:46:33 -07:00
search Add tooltip for toggling filters (#15879) 2024-08-06 15:51:53 -04:00
semantic_index Allow customization of the model used for tool calling (#15479) 2024-07-30 16:18:53 +02:00
semantic_version Extract SemanticVersion into its own crate (#9956) 2024-03-29 12:11:57 -04:00
session zed: Persist window stack order across restarts (#15419) 2024-07-29 17:05:56 +02:00
settings chore: Remove a bunch of unused structs (#16139) 2024-08-13 01:43:19 +02:00
settings_ui ui: Apply elevation outside SettingsContainer (#15346) 2024-07-27 14:00:03 -04:00
snippet Correct escaping in snippets (#14912) 2024-07-22 00:57:34 +02:00
snippet_provider extensions: Add support for snippets provided by extensions (#14020) 2024-07-10 09:40:50 +02:00
sqlez Remove extraneous Cargo.lock files (#14001) 2024-07-09 12:15:34 -04:00
sqlez_macros Dynamicer builds (#13074) 2024-06-21 16:32:32 -07:00
story stories: Get OverflowScrollStory to scroll again (#15982) 2024-08-09 12:32:26 +02:00
storybook Docs Party 2024 (#15876) 2024-08-09 13:37:54 -04:00
sum_tree Restore "Avoid buffering line content to compute indent guides" (#15284) 2024-07-28 10:52:39 +02:00
supermaven windows: Fix supermaven (#16203) 2024-08-14 17:01:16 +03:00
supermaven_api windows: Fix supermaven (#16203) 2024-08-14 17:01:16 +03:00
tab_switcher Send pane removeItem event before removing the item (#15541) 2024-07-31 08:48:19 -07:00
task SSH remoting: terminal & tasks (#15321) 2024-07-28 22:45:00 -06:00
tasks_ui tasks: Use environment variables from project (#15266) 2024-07-26 18:19:53 +02:00
telemetry_events Add repl events (#15259) 2024-07-26 03:31:41 -04:00
terminal Copy/paste images into editors (Mac only) (#15782) 2024-08-13 13:18:25 -04:00
terminal_view Copy/paste images into editors (Mac only) (#15782) 2024-08-13 13:18:25 -04:00
text Restructure workflow step resolution and fix inserting newlines (#15720) 2024-08-05 09:18:06 +02:00
theme Docs Party 2024 (#15876) 2024-08-09 13:37:54 -04:00
theme_importer Hoist strum to workspace level (#15243) 2024-07-25 21:30:48 -04:00
theme_selector settings_ui: Add theme settings controls (#15115) 2024-07-24 16:25:52 -04:00
time_format Inline git blame (#10398) 2024-04-15 14:21:52 +02:00
title_bar Show current plan in user menu (#15513) 2024-07-30 17:38:16 -04:00
ui assistant: Adjust slash command popover padding (#16181) 2024-08-14 09:48:48 -03:00
ui_input Rename ui_text_field crate to ui_input (#13949) 2024-07-08 17:05:30 -04:00
util Improve slash commands (#16195) 2024-08-13 23:06:07 -07:00
vcs_menu Adjust list item & pickers spacing (#14250) 2024-07-15 10:23:18 -03:00
vim Copy/paste images into editors (Mac only) (#15782) 2024-08-13 13:18:25 -04:00
welcome assistant: Overhaul provider infrastructure (#14929) 2024-07-23 19:48:41 +02:00
workspace Copy/paste images into editors (Mac only) (#15782) 2024-08-13 13:18:25 -04:00
worktree Fix a bug where directories were not matching in the fuzzy matcher, when query contains the worktree root name (#16242) 2024-08-14 12:43:00 -07:00
zed v0.150.x dev 2024-08-14 12:46:00 -04:00
zed_actions Show current plan in user menu (#15513) 2024-07-30 17:38:16 -04:00