This PR adds an initial notion of extension capabilities.
Capabilities are used to express the operations an extension is capable
of doing. This will provide further insights into what an extension can
do, as well as provide the ability to grant or deny the set of
capabilities.
Capabilities are defined in the `capabilities` field in the extension
manifest. This field contains an array of capabilities.
Each capability has a `kind` to denote the known capability it
corresponds to. Individual capabilities may have additional fields,
based on the `kind`.
Here's an example of some capabilities:
```toml
capabilities = [
{ kind = "download-file", host = "github.com", path_prefix = "owner/repo" },
{ kind = "npm:install", package = "@vue/language-server" },
]
```
In order to avoid a breaking change, the `capabilities` field is
currently optional and defaults to an empty array. This will allow us to
add support for extensions to define capabilities before we start
enforcing them.
Release Notes:
- N/A
This helps debug what steps are taken and where
the compiled extension ended up.
Also remove duplicate "compiling Rust extension" / "compiling rust
extension" text - it's confusing.
Release Notes:
- N/A
---------
Co-authored-by: Marshall Bowers <elliott.codes@gmail.com>
Fixes:
- [x] an issue where directories would only match by prefix, causing
both a directory and a file to be matched if in the same directory
- [x] An issue where you could not continue a file completion when
selecting a directory, as `tab` on a file would always run the command.
This effectively disabled directory sub queries.
- [x] Inconsistent rendering of files and directories in the slash
command
Release Notes:
- N/A
---------
Co-authored-by: max <max@zed.dev>
This PR removes the `tooltip_text` field from
`SlashCommandManifestEntry`s.
The `tooltip_text` is currently only used to set the `menu_text` on a
slash command, which is only used for featured slash commands.
Since slash commands from extensions are not currently able to be
featured, we don't need extension authors to provide this field in the
manifest.
This is a backwards-compatible change.
Release Notes:
- N/A
* renames `/tabs` to `/tab`
* allows to insert multiple tabs when fuzzy matching by the names
* improve slash command completion API, introduce a notion of multiple
arguments
* properly fire off commands on arguments' completions with
`run_command: true`
Release Notes:
- N/A
---------
Co-authored-by: Marshall Bowers <marshall@zed.dev>
This PR:
- Makes slash commands easier to compose by adding a concept,
`CompletionIntent`. When using `tab` on a completion in the assistant
panel, that completion item will be expanded but the associated command
will not be run. Using `enter` will still either run the completion item
or continue command composition as before.
- Fixes a bug where running `/diagnostics` on a project with no
diagnostics will delete the entire command, rather than rendering an
empty header.
- Improves the autocomplete rendering for files, showing when
directories are selected and re-arranging the results to have the file
name or trailing directory show first.
<img width="642" alt="Screenshot 2024-08-13 at 8 12 43 PM"
src="https://github.com/user-attachments/assets/97c96cd2-741f-4f15-ad03-7cf78129a71c">
Release Notes:
- N/A
This PR promotes package suggestions to a first-class concept on the
`IndexedDocsProvider` trait.
This will allow any implementer of `IndexedDocsProvider` to provide a
list of package names to suggest for use with `/docs`.
For the docs.rs provider we use the 250 most popular Rust crates (as
identified [here](https://lib.rs/std)), and for the rustdoc provider we
use the packages in the Cargo workspace.
Release Notes:
- N/A
Follow-up of https://github.com/zed-industries/zed/pull/16154
Reworks /tabs arguments to allow:
* current tab by default, if no arguments are present
* fuzzy-matching over paths of the related tabs
* `all` case to insert all tabs at once
Release Notes:
- N/A
This PR changes v0.0.7 of the extension API to v0.1.0.
We had a false-start in releasing v0.0.7, which has since been yanked,
so we need a new version number. We'll publish v0.1.0 to crates.io once
the Preview build is out tomorrow.
We're incrementing the minor version so that we have some leeway in
putting out patch releases of the crate within a given extension API
release.
Release Notes:
- N/A
# HTTP Client Improvements for Extension API
This PR enhances the HTTP client functionality in the Zed extension API,
providing more control over requests and allowing for streaming
responses.
## Key Changes
1. Extended `HttpRequest` struct:
- Added `method` field to specify HTTP method
- Added `headers` field for custom headers
- Added optional `body` field for request payload
2. Introduced `HttpMethod` enum for supported HTTP methods
3. Updated `HttpResponse` struct:
- Added `headers` field to access response headers
- Changed `body` type from `String` to `Vec<u8>` for binary data support
4. Added streaming support:
- New `fetch_stream` function to get a response stream
- Introduced `HttpResponseStream` resource for chunked reading
5. Updated internal implementations to support these new features
6. Modified the Gleam extension to use the new API structure
## Motivation
These changes provide extension developers with more flexibility and
control over HTTP requests. The streaming support is particularly useful
for handling large responses efficiently or ideally streaming into the
UI.
## Testing
- [x] Updated existing tests
- [ ] Added new tests for streaming functionality
## Next Steps
- Consider adding more comprehensive examples in the documentation
- Evaluate performance impact of streaming for large responses
Please review and let me know if any adjustments are needed.
Release Notes:
- N/A
---------
Co-authored-by: Marshall Bowers <elliott.codes@gmail.com>
Copies rust files from extension_api/wit to the OUT_DIR to allow
including them from within the crate, which is supported by
rust-analyzer. This allows rust-analyzer to deal with the included
files. It doesn't currently support files outside the crate.
Release Notes:
- N/A
This PR updates the extension API to make the `worktree` argument to
`run_slash_command` optional.
We may not always have a worktree, and not all slash commands need them,
so by making it optional we can allow individual slash commands to
decide what to do when there is no worktree.
Release Notes:
- N/A
This PR fixes an issue where slash commands were not able to run when
Zed did not have any worktrees opened.
This requirement was only necessary for slash commands originating from
extensions, and we can enforce the presence of a worktree just for
those:
<img width="378" alt="Screenshot 2024-08-01 at 5 01 58 PM"
src="https://github.com/user-attachments/assets/38bea947-e33b-4c64-853c-c1f36c63d779">
Release Notes:
- N/A
This PR makes it so we always construct a real HTTP client in the
`ExtensionBuilder`.
This used to be the case, but was inadvertently changed in
https://github.com/zed-industries/zed/pull/15470.
Release Notes:
- N/A
This PR upgrades the version of `wasmtime` and `wasmtime-wasi` in use to
v21.0.1.
We have to skip v20 because Tree-sitter also skipped it.
Here are the changes that had to be made:
### v19 -> v20
After upgrading the `wasmtime` packages to v20, I also had to run `cargo
update -p mach2` to pull in
[v0.4.2](https://github.com/JohnTitor/mach2/releases/tag/0.4.2) to fix
some compile errors.
There were a few minor API changes in `wasmtime-wasi` from
https://github.com/bytecodealliance/wasmtime/pull/8228 that we needed to
account for.
### v20 -> v21
Since there isn't a Tree-sitter version that depends on `wasmtime@v20`,
we're jumping straight to v21.
The published version of Tree-sitter (v0.22.6) still depends on
`wasmtime@v19`, but there was a commit
(7f4a57817d)
later that month that upgrades the `wasmtime` dependency to v21.
We're patching Tree-sitter to that commit so we can get the new
`wasmtime` version.
The main change in v21 is that imports generated by `bindgen!` are no
longer automatically trapped
(https://github.com/bytecodealliance/wasmtime/pull/8310), so we need to
add `trappable_imports: true` to our `bindgen!` calls.
Release Notes:
- N/A
This PR makes it so dev extensions that are installed are excluded when
checking for extension updates.
We don't want to accidentally clobber dev extensions if the upstream
extension is deemed more "up-to-date".
Release Notes:
- Changed dev extensions to be excluded from extension auto-updates.
For now extensions can only register global snippets, but there'll be
follow-up work to support scope attribute in snippets.json.
Release Notes:
- Extensions can now provide snippets by including `snippets.json` file
next to the extension manifest.
---------
Co-authored-by: Marshall <marshall@zed.dev>
Co-authored-by: Marshall Bowers <elliott.codes@gmail.com>
This PR updates the extension API to use structured slash command
completions instead of plain strings.
This allows slash commands defined in extensions to take advantage of
the improvements made in #13876.
Release Notes:
- N/A
This PR improves the completions for arguments in the `/docs` slash
command.
We achieved this by extending the `complete_argument` method on the
`SlashCommand` trait to return a `Vec<ArgumentCompletion>` instead of a
`Vec<String>`.
In addition to the completion `label`, `ArgumentCompletion` has two new
fields that are can be used to customize the completion behavior:
- `new_text`: The actual text that will be inserted when the completion
is accepted, which may be different from what is shown by the completion
label.
- `run_command`: Whether the command is run when the completion is
accepted. This can be set to `false` to allow accepting a completion
without running the command.
Release Notes:
- N/A
---------
Co-authored-by: Antonio <antonio@zed.dev>
This PR replaces the usage of `unzip` for extracting `.zip` files
downloaded by extensions with extraction via a library.
This will allow us to extract `.zip` files even if `unzip` is not
available (e.g., on Windows).
Release Notes:
- Removed the need for `unzip` to be present on the system to extract
`.zip` files downloaded by extensions.
This PR updates the `extension` crate's tests to use a dedicated test
extension for its tests instead of the real Gleam extension.
As the Gleam extension continues to evolve, it makes it less suitable to
use as a test fixture:
1. For a while now, the test has failed locally due to me having `gleam`
on my $PATH, which causes the extension's `get_language_server_command`
to go down a separate codepath.
2. With the addition of the `indexed_docs_providers` the test was
hanging indefinitely.
While these problems are likely solvable, it seems reasonable to have a
dedicated extension to use as a test fixture. That way we can do
whatever we need to exercise our test criteria.
The `test-extension` is a fork of the Gleam extension with some
additional functionality removed.
Release Notes:
- N/A
This PR renames `ExtensionDocsIndexer` to `ExtensionIndexedDocsProvider`
to better align with the name of the trait it implements.
Release Notes:
- N/A
This PR adds a new `fetch` function to the `zed_extension_api` to allow
fetching a URL through the Wasm host.
Currently we only support GET requests and return the response body as a
string.
Release Notes:
- N/A
This PR extends the interface for slash commands defined in extensions
to have them return `SlashCommandOutput`.
This allows for slash commands to return multiple output sections for a
single piece of generated text.
Note that we don't allow specifying the icon to display in the
placeholder, as we don't want to commit to that in our API at the
moment.
Release Notes:
- N/A
This PR replaces the `lazy_static!` usages in the `paths` crate with
`OnceLock` from the standard library.
This allows us to drop the `lazy_static` dependency from this crate.
The paths are now exposed as accessor functions that reference a private
static value.
Release Notes:
- N/A
This PR extracts the definition of the various Zed paths out of `util`
and into a new `paths` crate.
`util` is for generic utils, while these paths are Zed-specific. For
instance, `gpui` depends on `util`, and it shouldn't have knowledge of
these paths, since they are only used by Zed.
Release Notes:
- N/A
This PR fixes an issue where the `zed-extension` CLI could no longer be
run as a static binary due to the following error:
```
dyld[36964]: Library not loaded: @rpath/WebRTC.framework/WebRTC
Referenced from: <56332E1D-292E-3F9B-97B9-8A9962D21599> /Users/maxdeviant/projects/zed-extensions/zed-extension
Reason: no LC_RPATH's found
fish: Job 1, './zed-extension --scratch-dir .…' terminated by signal SIGABRT (Abort)
```
This is the result of the addition of a dependency on `workspace` to the
`extension` crate (and thus, the `extension_cli` crate) in #12360.
Since we don't actually _need_ WebRTC in the extension CLI, we don't
care about dynamically linking it.
To resolve this, a new `no-webrtc` feature has been added to the
`live_kit_client` client crate and threaded through all of the crates
between it and the `extension_cli`.
Enabling the `no-webrtc` feature will prevent linking to the LiveKit
Swift SDK as well as linking the WebRTC framework.
Release Notes:
- N/A
Note:
- We have disabled all tests that rely on Postgres in the Linux CI. We
only really need to test these once, and as macOS is our team's primary
platform, we'll only enable them on macOS for local reproduction.
- We have disabled all tests that rely on the font metrics. We
standardized on Zed Mono in many fonts, but our CoreText Text System and
Cosmic Text System proved to be very different in effect. We should
revisit if we decide to standardize our text system across platforms
(e.g. using Harfbuzz everywhere)
- Extended the condition timeout significantly. Our CI machines are slow
enough that this is causing spurious errors in random tests.
Release Notes:
- N/A
---------
Co-authored-by: Conrad Irwin <conrad.irwin@gmail.com>
TODO:
- [x] Finish GPUI changes on other operating systems
This is a largely internal change to how we report data to our
diagnostics and telemetry. This PR also includes an update to our blade
backend which allows us to report errors in a more useful way when
failing to initialize blade.
Release Notes:
- N/A
---------
Co-authored-by: Conrad Irwin <conrad.irwin@gmail.com>
This could still use some improvement UI-wise but the user experience
should be a lot better.
- [x] Show in "Window" application menu
- [x] Load prompt as it's selected in the picker
- [x] Refocus picker on `esc`
- [x] When creating a new prompt, if a new prompt already exists and is
unedited, activate it instead
- [x] Add `/default` command
- [x] Evaluate /commands on prompt insertion
- [x] Autocomplete /commands (but don't evaluate) during prompt editing
- [x] Show token count using the settings model, right-aligned in the
editor
- [x] Picker
- [x] Sorted alpha
- [x] 2 sublists
- Default
- Empty state: Star a prompt to add it to your default prompt
- Otherwise show prompts with star on hover
- All
- Move prompts with star on hover
Release Notes:
- N/A