дзеркало
https://github.com/l0ng-ai/openidea.git
синхронізовано 2026-12-03 16:51:16 +02:00
Порівняти коміти
1
Коміти
| Автор | SHA1 | Дата | |
|---|---|---|---|
|
|
f041f7e763 |
No files matched your search
+8
-8
@@ -38,14 +38,14 @@ Editör, kod analizi, hata ayıklayıcı (debugger), Git, terminal, veritabanı
|
||||
[freqtrade](https://github.com/freqtrade/freqtrade) projesini (Python, ~770 dosya)
|
||||
önbellekler hazırken açma, 5 çalıştırmanın ortancası:
|
||||
|
||||
| | OpenIDEA | IntelliJ IDEA 2026.2.3 |
|
||||
| ---------------------------- | ----------------------- | ---------------------- |
|
||||
| Projeyle pencerenin açılması | **0,9 sn** | 3,1 sn |
|
||||
| Hazır (CPU sakinleşti) | **1,1 sn** | 13,2 sn |
|
||||
| Bellek (USS, tüm işlemler) | **169 MB** | 2011 MB |
|
||||
| Hazır olana kadar CPU süresi | **2,4 sn** | 47,9 sn |
|
||||
| Boştayken CPU | Bir çekirdeğin **%4**'ü | Bir çekirdeğin %7'si |
|
||||
| Kapanma | **0,3 sn** | 5,9 sn |
|
||||
| | OpenIDEA | IntelliJ IDEA 2026.2.3 |
|
||||
| ---------------------------------- | --------------------- | ---------------------- |
|
||||
| Projeyle pencerenin açılması | **0,9 sn** | 3,1 sn |
|
||||
| Hazır (CPU sakinleşti) | **1,1 sn** | 13,2 sn |
|
||||
| Bellek (USS, tüm işlemler) | **169 MB** | 2011 MB |
|
||||
| Hazır olana kadar CPU süresi | **2,4 sn** | 47,9 sn |
|
||||
| Boştayken CPU | Bir çekirdeğin **%4**'ü | Bir çekirdeğin %7'si |
|
||||
| Kapanma | **0,3 sn** | 5,9 sn |
|
||||
|
||||
`main` dalından derlenmiş bir OpenIDEA sürümü ve varsayılan ayar ve eklentilerle IDEA;
|
||||
Windows 11, 32 çekirdekli AMD, 62 GB RAM.
|
||||
|
||||
@@ -106,17 +106,18 @@ impl ide_jsonrpc::Handler for DiscoveryUpdates {
|
||||
}
|
||||
}
|
||||
|
||||
fn is_thought_level(o: &AgentConfigOption) -> bool {
|
||||
o.category.as_deref() == Some("thought_level")
|
||||
|| matches!(o.id.as_str(), "effort" | "reasoning_effort" | "thinking" | "reasoning")
|
||||
}
|
||||
|
||||
fn levels_for_model_from_slice(options: &[AgentConfigOption]) -> Option<Vec<AgentConfigOption>> {
|
||||
let levels: Vec<_> = options
|
||||
.iter()
|
||||
.filter(|o| config::is_per_model_option(o))
|
||||
.filter(|o| is_thought_level(o))
|
||||
.cloned()
|
||||
.map(|mut o| {
|
||||
if config::is_context_option(&o.id) {
|
||||
if o.category.is_none() {
|
||||
o.category = Some("model_config".into());
|
||||
}
|
||||
} else if o.category.as_deref() != Some("thought_level") {
|
||||
if o.category.as_deref() != Some("thought_level") {
|
||||
o.category = Some("thought_level".into());
|
||||
}
|
||||
o
|
||||
|
||||
@@ -322,13 +322,6 @@ impl Handler for Dialect {
|
||||
}
|
||||
self.inner.on_request(method, params)
|
||||
}
|
||||
|
||||
fn on_request_raw(&self, method: &str, params: Value, raw: &[u8]) -> Result<Value, (i64, String, Option<Value>)> {
|
||||
if self.v2() && method == "session/request_permission" {
|
||||
return self.on_request_with_data(method, params);
|
||||
}
|
||||
self.inner.on_request_raw(method, params, raw)
|
||||
}
|
||||
}
|
||||
|
||||
/// A v2 permission request with the v1 `toolCall` (its subject's, titled with the request's title).
|
||||
|
||||
@@ -20,22 +20,17 @@ pub(crate) fn add_client_options(provider: &str, config: &mut Vec<AgentConfigOpt
|
||||
description: Some("Tool approvals for this Cursor conversation".into()),
|
||||
category: Some("approval".into()),
|
||||
current: Some("ask".into()),
|
||||
default_value: Some("ask".into()),
|
||||
via: AgentConfigVia::Option,
|
||||
values: vec![
|
||||
AgentConfigValue {
|
||||
value: "ask".into(),
|
||||
name: "Ask for approval".into(),
|
||||
description: Some("Show permission requests from Cursor".into()),
|
||||
cost_category: None,
|
||||
usage_multiplier: None,
|
||||
},
|
||||
AgentConfigValue {
|
||||
value: "bypass".into(),
|
||||
name: "Bypass approvals".into(),
|
||||
description: Some("Automatically approve tool requests in this conversation".into()),
|
||||
cost_category: None,
|
||||
usage_multiplier: None,
|
||||
},
|
||||
],
|
||||
});
|
||||
@@ -123,18 +118,6 @@ pub(crate) fn options_of(result: &Value) -> Vec<AgentConfigOption> {
|
||||
out
|
||||
}
|
||||
|
||||
pub(crate) fn is_context_option(id: &str) -> bool {
|
||||
matches!(id, "context_tier" | "contextTier")
|
||||
}
|
||||
|
||||
/// Whether an option's available values and default belong to the selected model
|
||||
/// (`thought_level` and model context-tier options) rather than the provider as a whole.
|
||||
pub(crate) fn is_per_model_option(o: &AgentConfigOption) -> bool {
|
||||
matches!(o.category.as_deref(), Some("thought_level" | "context_tier"))
|
||||
|| matches!(o.id.as_str(), "effort" | "reasoning_effort" | "thinking" | "reasoning")
|
||||
|| is_context_option(&o.id)
|
||||
}
|
||||
|
||||
/// A `configOptions` array; only select options are kept (the UI shows them as dropdowns).
|
||||
pub(crate) fn parse_options(options: &Value) -> Vec<AgentConfigOption> {
|
||||
let Some(list) = options.as_array() else { return Vec::new() };
|
||||
@@ -150,8 +133,6 @@ pub(crate) fn parse_options(options: &Value) -> Vec<AgentConfigOption> {
|
||||
None => values.extend(value_of(v)),
|
||||
}
|
||||
}
|
||||
let current = str_of(o, "currentValue");
|
||||
let default_value = str_of(o, "defaultValue").or_else(|| current.clone());
|
||||
Some(AgentConfigOption {
|
||||
name: str_of(o, "name").unwrap_or_else(|| id.clone()),
|
||||
description: str_of(o, "description"),
|
||||
@@ -162,10 +143,9 @@ pub(crate) fn parse_options(options: &Value) -> Vec<AgentConfigOption> {
|
||||
matches!(id.as_str(), "effort" | "reasoning_effort" | "thinking" | "reasoning")
|
||||
.then(|| "thought_level".into())
|
||||
})
|
||||
.or_else(|| (id == "fast" || is_context_option(&id)).then(|| "model_config".into()))
|
||||
.or_else(|| matches!(id.as_str(), "fast").then(|| "model_config".into()))
|
||||
}),
|
||||
current,
|
||||
default_value,
|
||||
current: str_of(o, "currentValue"),
|
||||
values,
|
||||
via: AgentConfigVia::Option,
|
||||
id,
|
||||
@@ -175,24 +155,9 @@ pub(crate) fn parse_options(options: &Value) -> Vec<AgentConfigOption> {
|
||||
}
|
||||
|
||||
/// A `config_option_update`: its options replace the config-option ones; `modes` / `models`
|
||||
/// stand-ins stay, and initial `default_value`s survive same-model option edits for Reset.
|
||||
/// stand-ins stay.
|
||||
pub(crate) fn merge_update(config: &mut Vec<AgentConfigOption>, options: &Value) {
|
||||
let mut fresh = parse_options(options);
|
||||
let old_model = config.iter().find(|o| o.category.as_deref() == Some("model")).and_then(|o| o.current.as_deref());
|
||||
let new_model = fresh.iter().find(|o| o.category.as_deref() == Some("model")).and_then(|o| o.current.as_deref());
|
||||
let same_model = old_model == new_model;
|
||||
for f in &mut fresh {
|
||||
if f.default_value == f.current
|
||||
&& (same_model || !is_per_model_option(f))
|
||||
&& let Some(prev_default) = config
|
||||
.iter()
|
||||
.find(|p| p.id == f.id)
|
||||
.and_then(|p| p.default_value.as_ref())
|
||||
.filter(|def| f.values.iter().any(|v| v.value == **def))
|
||||
{
|
||||
f.default_value = Some(prev_default.clone());
|
||||
}
|
||||
}
|
||||
let fresh = parse_options(options);
|
||||
let covered = |o: &AgentConfigOption| fresh.iter().any(|f| f.category.is_some() && f.category == o.category);
|
||||
config.retain(|o| o.id == CURSOR_APPROVAL || (o.via != AgentConfigVia::Option && !covered(o)));
|
||||
let legacy = std::mem::take(config);
|
||||
@@ -286,20 +251,16 @@ fn legacy(
|
||||
Some(AgentConfigValue {
|
||||
name: str_of(m, "name").unwrap_or_else(|| value.clone()),
|
||||
description: str_of(m, "description"),
|
||||
cost_category: None,
|
||||
usage_multiplier: None,
|
||||
value,
|
||||
})
|
||||
})
|
||||
.collect();
|
||||
let current = str_of(v, current);
|
||||
AgentConfigOption {
|
||||
id: id.to_owned(),
|
||||
name: name.to_owned(),
|
||||
description: None,
|
||||
category: Some(id.to_owned()),
|
||||
default_value: current.clone(),
|
||||
current,
|
||||
current: str_of(v, current),
|
||||
values,
|
||||
via,
|
||||
}
|
||||
@@ -307,23 +268,9 @@ fn legacy(
|
||||
|
||||
fn value_of(v: &Value) -> Option<AgentConfigValue> {
|
||||
let value = v.get("value")?.as_str()?.to_owned();
|
||||
let meta = v.get("_meta");
|
||||
let cost_category = meta
|
||||
.and_then(|m| m.get("copilotPriceCategory").or_else(|| m.get("priceCategory")))
|
||||
.and_then(Value::as_str)
|
||||
.map(|s| s.trim().to_ascii_lowercase())
|
||||
.filter(|s| !s.is_empty());
|
||||
let usage_multiplier = meta
|
||||
.and_then(|m| m.get("copilotUsage").or_else(|| m.get("usageMultiplier")))
|
||||
.and_then(Value::as_str)
|
||||
.map(str::trim)
|
||||
.filter(|s| !s.is_empty())
|
||||
.map(str::to_owned);
|
||||
Some(AgentConfigValue {
|
||||
name: str_of(v, "name").unwrap_or_else(|| value.clone()),
|
||||
description: str_of(v, "description"),
|
||||
cost_category,
|
||||
usage_multiplier,
|
||||
value,
|
||||
})
|
||||
}
|
||||
@@ -455,53 +402,17 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn effort_and_fast_categories_are_inferred_from_ids() {
|
||||
let mut c = options_of(&json!({
|
||||
let c = options_of(&json!({
|
||||
"configOptions": [
|
||||
{"id": "model", "type": "select", "currentValue": "gemini-4-carbon",
|
||||
"options": [{"value": "gemini-4-carbon", "name": "Gemini 4 Carbon",
|
||||
"description": "Powerful · Medium cost",
|
||||
"_meta": {"copilotPriceCategory": "Medium", "copilotUsage": "1x"}}]},
|
||||
{"id": "effort", "type": "select", "currentValue": "medium",
|
||||
"options": [{"value": "low"}, {"value": "medium"}, {"value": "high"}]},
|
||||
{"id": "contextTier", "type": "select", "currentValue": "default",
|
||||
"options": [{"value": "default", "name": "200K"}, {"value": "long_context", "name": "1M"}]},
|
||||
{"id": "effort", "type": "select", "currentValue": "high",
|
||||
"options": [{"value": "low"}, {"value": "high"}]},
|
||||
{"id": "fast", "type": "select", "currentValue": "false",
|
||||
"options": [{"value": "false", "name": "Off"}, {"value": "true", "name": "On"}]}
|
||||
]
|
||||
}));
|
||||
assert_eq!(c.len(), 4);
|
||||
assert_eq!(c[0].values[0].cost_category.as_deref(), Some("medium"));
|
||||
assert_eq!(c[0].values[0].usage_multiplier.as_deref(), Some("1x"));
|
||||
assert_eq!(c[1].category.as_deref(), Some("thought_level"));
|
||||
assert_eq!(c[1].default_value.as_deref(), Some("medium"));
|
||||
assert_eq!(c[2].category.as_deref(), Some("model_config"));
|
||||
assert!(is_per_model_option(&c[1]) && is_per_model_option(&c[2]) && !is_per_model_option(&c[3]));
|
||||
|
||||
// Editing effort on the same model preserves its initial `default_value` for Reset.
|
||||
merge_update(
|
||||
&mut c,
|
||||
&json!([
|
||||
{"id": "model", "type": "select", "currentValue": "gemini-4-carbon",
|
||||
"options": [{"value": "gemini-4-carbon"}]},
|
||||
{"id": "effort", "type": "select", "currentValue": "high",
|
||||
"options": [{"value": "low"}, {"value": "medium"}, {"value": "high"}]}
|
||||
]),
|
||||
);
|
||||
let effort = c.iter().find(|o| o.id == "effort").unwrap();
|
||||
assert_eq!((effort.current.as_deref(), effort.default_value.as_deref()), (Some("high"), Some("medium")));
|
||||
|
||||
// Switching models refreshes per-model `default_value` to the new model's default.
|
||||
merge_update(
|
||||
&mut c,
|
||||
&json!([
|
||||
{"id": "model", "type": "select", "currentValue": "gpt-6-sol",
|
||||
"options": [{"value": "gemini-4-carbon"}, {"value": "gpt-6-sol"}]},
|
||||
{"id": "effort", "type": "select", "currentValue": "low",
|
||||
"options": [{"value": "low"}, {"value": "medium"}, {"value": "high"}]}
|
||||
]),
|
||||
);
|
||||
let effort = c.iter().find(|o| o.id == "effort").unwrap();
|
||||
assert_eq!((effort.current.as_deref(), effort.default_value.as_deref()), (Some("low"), Some("low")));
|
||||
assert_eq!(c.len(), 2);
|
||||
assert_eq!(c[0].category.as_deref(), Some("thought_level"));
|
||||
assert_eq!(c[1].category.as_deref(), Some("model_config"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
@@ -2,8 +2,6 @@
|
||||
//! user's answer as the `elicitation/create` response.
|
||||
|
||||
use crate::model::{AgentForm, AgentFormField, AgentFormFieldKind, AgentFormOption, AgentPermissionOption};
|
||||
use serde::Deserialize;
|
||||
use serde::de::{Deserializer, IgnoredAny, MapAccess, Visitor};
|
||||
use serde_json::{Map, Value, json};
|
||||
|
||||
/// The reply that declines the form; a JSON object of field name to values accepts it, and
|
||||
@@ -29,47 +27,6 @@ pub(crate) fn form_of(params: &Value) -> Result<AgentForm, String> {
|
||||
Ok(AgentForm { fields })
|
||||
}
|
||||
|
||||
/// Orders the fields as the request's schema lists them: `Value` keeps object keys sorted, and
|
||||
/// the agent's order is the one its form reads in.
|
||||
pub(crate) fn in_schema_order(form: &mut AgentForm, raw: &[u8]) {
|
||||
#[derive(Deserialize)]
|
||||
struct Request {
|
||||
params: Params,
|
||||
}
|
||||
#[derive(Deserialize)]
|
||||
struct Params {
|
||||
#[serde(rename = "requestedSchema")]
|
||||
schema: Schema,
|
||||
}
|
||||
#[derive(Deserialize)]
|
||||
struct Schema {
|
||||
properties: Keys,
|
||||
}
|
||||
struct Keys(Vec<String>);
|
||||
impl<'de> Deserialize<'de> for Keys {
|
||||
fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
|
||||
struct Visit;
|
||||
impl<'de> Visitor<'de> for Visit {
|
||||
type Value = Keys;
|
||||
fn expecting(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
|
||||
f.write_str("an object")
|
||||
}
|
||||
fn visit_map<A: MapAccess<'de>>(self, mut map: A) -> Result<Keys, A::Error> {
|
||||
let mut keys = Vec::new();
|
||||
while let Some((key, IgnoredAny)) = map.next_entry::<String, IgnoredAny>()? {
|
||||
keys.push(key);
|
||||
}
|
||||
Ok(Keys(keys))
|
||||
}
|
||||
}
|
||||
deserializer.deserialize_map(Visit)
|
||||
}
|
||||
}
|
||||
let Ok(request) = serde_json::from_slice::<Request>(raw) else { return };
|
||||
let order = request.params.schema.properties.0;
|
||||
form.fields.sort_by_key(|field| order.iter().position(|name| *name == field.name).unwrap_or(usize::MAX));
|
||||
}
|
||||
|
||||
fn field(name: &str, property: &Value, required: bool) -> Result<AgentFormField, String> {
|
||||
let text = |key: &str| property.get(key).and_then(Value::as_str).unwrap_or_default().trim().to_owned();
|
||||
let number = |key: &str| property.get(key).and_then(Value::as_f64);
|
||||
@@ -219,18 +176,6 @@ mod tests {
|
||||
})
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn fields_follow_the_schema_order() {
|
||||
let raw = br#"{ "jsonrpc": "2.0", "id": 3, "method": "elicitation/create", "params": { "mode": "form",
|
||||
"requestedSchema": { "type": "object", "properties": {
|
||||
"strategy": { "type": "string" }, "tests": { "type": "boolean" }, "note": { "type": "string" }
|
||||
} } } }"#;
|
||||
let params = serde_json::from_slice::<Value>(raw).unwrap()["params"].take();
|
||||
let mut form = form_of(¶ms).unwrap();
|
||||
in_schema_order(&mut form, raw);
|
||||
assert_eq!(form.fields.iter().map(|f| f.name.as_str()).collect::<Vec<_>>(), ["strategy", "tests", "note"]);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn reads_choices_and_text_fields() {
|
||||
let form = form_of(&ask()).unwrap();
|
||||
|
||||
@@ -188,7 +188,7 @@ impl Shared {
|
||||
|
||||
fn config_for_new_task(&self, mut config: Vec<AgentConfigOption>, provider: &str) -> Vec<AgentConfigOption> {
|
||||
// Model-specific options are offered separately, never as provider-wide defaults.
|
||||
config.retain(|o| !config::is_per_model_option(o));
|
||||
config.retain(|o| o.category.as_deref() != Some("thought_level"));
|
||||
config::add_client_options(provider, &mut config);
|
||||
let hook = self.new_task_approvals.read().clone();
|
||||
if hook.is_some_and(|ask| ask() == ide_core::settings::NewTaskApprovals::Ask) {
|
||||
@@ -234,7 +234,8 @@ impl Shared {
|
||||
&& let Some(config) = config.filter(|c| !c.is_empty())
|
||||
{
|
||||
if let Some(model) = model {
|
||||
let levels: Vec<_> = config.iter().filter(|o| config::is_per_model_option(o)).cloned().collect();
|
||||
let levels: Vec<_> =
|
||||
config.iter().filter(|o| o.category.as_deref() == Some("thought_level")).cloned().collect();
|
||||
if known.thought_levels.get(model) != Some(&levels) {
|
||||
known.thought_levels.insert(model.to_owned(), levels);
|
||||
changed = true;
|
||||
@@ -245,9 +246,10 @@ impl Shared {
|
||||
changed = true;
|
||||
}
|
||||
}
|
||||
// Discovery reads one model's options; a session on another model reports that model's.
|
||||
// Discovery reads one model's efforts; a session on another model reports that model's.
|
||||
let learned = model.filter(|_| acp && known.authoritative).zip(config).map(|(model, config)| {
|
||||
let levels: Vec<_> = config.iter().filter(|o| config::is_per_model_option(o)).cloned().collect();
|
||||
let levels: Vec<_> =
|
||||
config.iter().filter(|o| o.category.as_deref() == Some("thought_level")).cloned().collect();
|
||||
(model, levels)
|
||||
});
|
||||
if let Some(commands) = commands.filter(|c| !c.is_empty())
|
||||
@@ -1009,11 +1011,8 @@ impl AgentManager {
|
||||
task.emit_task();
|
||||
|
||||
let live = task.live.lock().clone().filter(|l| !l.peer.is_closed());
|
||||
// The task's copy holds its model's per-model options unless a model switch the agent
|
||||
// never reported dropped them: caching that copy would erase the model's known levels.
|
||||
let mut model_options = (target.category.as_deref() != Some("model")
|
||||
|| previous.as_deref() == Some(value.as_str()))
|
||||
&& task.state.lock().task.config.iter().any(config::is_per_model_option);
|
||||
let mut model_options =
|
||||
target.category.as_deref() != Some("model") || previous.as_deref() == Some(value.as_str());
|
||||
if let Some(live) = live.filter(|_| option != config::CURSOR_APPROVAL) {
|
||||
let (method, mut params) = config::set_request(&target, &value);
|
||||
params["sessionId"] = json!(live.session);
|
||||
@@ -1044,7 +1043,7 @@ impl AgentManager {
|
||||
{
|
||||
let mut s = task.state.lock();
|
||||
if !model_options {
|
||||
s.task.config.retain(|o| !config::is_per_model_option(o));
|
||||
s.task.config.retain(|o| o.category.as_deref() != Some("thought_level"));
|
||||
}
|
||||
if let Some(o) = s.task.config.iter_mut().find(|o| o.id == option) {
|
||||
o.current = Some(value);
|
||||
@@ -2122,10 +2121,10 @@ impl Task {
|
||||
(if known { reported } else { s.task.config.clone() }, s.wanted.clone())
|
||||
};
|
||||
config::add_client_options(&provider_id, &mut options);
|
||||
// Changing model can replace the effort / context-tier choices; validate those only afterwards.
|
||||
wanted.sort_by_key(|c| match options.iter().find(|o| o.id == c.id) {
|
||||
Some(o) if o.category.as_deref() == Some("model") => 0,
|
||||
Some(o) if config::is_per_model_option(o) => 2,
|
||||
// Changing model can replace the effort choices; validate those only afterwards.
|
||||
wanted.sort_by_key(|c| match options.iter().find(|o| o.id == c.id).and_then(|o| o.category.as_deref()) {
|
||||
Some("model") => 0,
|
||||
Some("thought_level") => 2,
|
||||
_ => 1,
|
||||
});
|
||||
let mut model_options = known;
|
||||
@@ -2138,7 +2137,7 @@ impl Task {
|
||||
}
|
||||
continue;
|
||||
}
|
||||
if config::is_per_model_option(&o) && !model_options {
|
||||
if o.category.as_deref() == Some("thought_level") && !model_options {
|
||||
continue;
|
||||
}
|
||||
let already = known && o.current.as_deref() == Some(choice.value.as_str());
|
||||
@@ -2155,7 +2154,7 @@ impl Task {
|
||||
model_options = true;
|
||||
} else if o.category.as_deref() == Some("model") {
|
||||
if o.current.as_deref() != Some(choice.value.as_str()) {
|
||||
options.retain(|o| !config::is_per_model_option(o));
|
||||
options.retain(|o| o.category.as_deref() != Some("thought_level"));
|
||||
}
|
||||
model_options = false;
|
||||
}
|
||||
@@ -2219,17 +2218,14 @@ impl Task {
|
||||
if let Some(fresh) = reply.get("configOptions") {
|
||||
config::merge_update(&mut s.task.config, fresh);
|
||||
} else if option.category.as_deref() == Some("model") {
|
||||
s.task.config.retain(|o| !config::is_per_model_option(o));
|
||||
s.task.config.retain(|o| o.category.as_deref() != Some("thought_level"));
|
||||
}
|
||||
if let Some(o) = s.task.config.iter_mut().find(|o| o.id == option.id) {
|
||||
o.current = Some(value);
|
||||
}
|
||||
s.task.model = model_of(&s.task.config).or(s.task.model.take());
|
||||
// As in `set_config`: a copy without per-model options can't vouch for them.
|
||||
let model = s.task.model.clone().filter(|_| {
|
||||
reply.get("configOptions").is_some()
|
||||
|| (option.category.as_deref() != Some("model")
|
||||
&& s.task.config.iter().any(config::is_per_model_option))
|
||||
reply.get("configOptions").is_some() || option.category.as_deref() != Some("model")
|
||||
});
|
||||
let (provider, options) = (s.task.provider.clone(), s.task.config.clone());
|
||||
drop(s);
|
||||
@@ -2559,11 +2555,8 @@ impl Task {
|
||||
|
||||
/// An agent's form (`elicitation/create`): asked in the conversation like a permission
|
||||
/// request, and answered with its values, declined or cancelled. Blocks like `ask_permission`.
|
||||
fn elicit(self: &Arc<Self>, params: &Value, raw: Option<&[u8]>) -> Result<Value, String> {
|
||||
let mut form = elicitation::form_of(params)?;
|
||||
if let Some(raw) = raw {
|
||||
elicitation::in_schema_order(&mut form, raw);
|
||||
}
|
||||
fn elicit(self: &Arc<Self>, params: &Value) -> Result<Value, String> {
|
||||
let form = elicitation::form_of(params)?;
|
||||
let id = self.next_permission.fetch_add(1, Ordering::Relaxed);
|
||||
let message = params.get("message").and_then(Value::as_str).unwrap_or_default().trim().to_owned();
|
||||
let (tx, rx) = std::sync::mpsc::channel();
|
||||
@@ -2663,18 +2656,10 @@ impl Handler for Client {
|
||||
let task = self.task.upgrade().ok_or((codes::INTERNAL_ERROR, "task closed".to_owned()))?;
|
||||
match method {
|
||||
"session/request_permission" => Ok(task.ask_permission(¶ms)),
|
||||
"elicitation/create" => task.elicit(¶ms, None).map_err(|e| (codes::INVALID_PARAMS, e)),
|
||||
"elicitation/create" => task.elicit(¶ms).map_err(|e| (codes::INVALID_PARAMS, e)),
|
||||
_ => Err((codes::METHOD_NOT_FOUND, format!("unsupported method {method}"))),
|
||||
}
|
||||
}
|
||||
|
||||
fn on_request_raw(&self, method: &str, params: Value, raw: &[u8]) -> Result<Value, (i64, String, Option<Value>)> {
|
||||
if method != "elicitation/create" {
|
||||
return self.on_request_with_data(method, params);
|
||||
}
|
||||
let task = self.task.upgrade().ok_or((codes::INTERNAL_ERROR, "task closed".to_owned(), None))?;
|
||||
task.elicit(¶ms, Some(raw)).map_err(|e| (codes::INVALID_PARAMS, e, None))
|
||||
}
|
||||
}
|
||||
|
||||
/// The prompt trimmed, or `None` when there is nothing to send.
|
||||
|
||||
@@ -130,14 +130,6 @@ pub struct AgentConfigValue {
|
||||
pub value: String,
|
||||
pub name: String,
|
||||
pub description: Option<String>,
|
||||
/// Relative cost category from ACP `_meta` (`copilotPriceCategory`, e.g. `low`, `medium`, `high`, `very_high`).
|
||||
#[serde(default)]
|
||||
#[specta(optional)]
|
||||
pub cost_category: Option<String>,
|
||||
/// Usage multiplier from ACP `_meta` (`copilotUsage`, e.g. `1x`, `0x`, `3x`).
|
||||
#[serde(default)]
|
||||
#[specta(optional)]
|
||||
pub usage_multiplier: Option<String>,
|
||||
}
|
||||
|
||||
/// How a setting is changed.
|
||||
@@ -163,10 +155,6 @@ pub struct AgentConfigOption {
|
||||
/// ACP category: `model`, `mode`, `thought_level`, or agent-specific.
|
||||
pub category: Option<String>,
|
||||
pub current: Option<String>,
|
||||
/// Initial default value reported by the agent, preserved across session updates for Reset.
|
||||
#[serde(default)]
|
||||
#[specta(optional)]
|
||||
pub default_value: Option<String>,
|
||||
pub values: Vec<AgentConfigValue>,
|
||||
pub via: AgentConfigVia,
|
||||
}
|
||||
|
||||
@@ -1795,45 +1795,6 @@ async fn thinking_levels_are_remembered_per_provider_and_model() {
|
||||
restored.shutdown();
|
||||
}
|
||||
|
||||
#[tokio::test(flavor = "multi_thread")]
|
||||
async fn changing_an_idle_tasks_settings_keeps_its_models_effort_levels() {
|
||||
// After a model switch no session reported, picking that model again or changing
|
||||
// another setting must not record the task's effort-less copy as the model's levels.
|
||||
for (option, value) in [("mode", "code"), ("model", "big")] {
|
||||
let tmp = tempfile::tempdir().unwrap();
|
||||
let agent = Arc::new(FakeAgent::default());
|
||||
*agent.model_options.lock() = HashMap::from([
|
||||
("big".into(), effort_options(&["low", "high"], "high")),
|
||||
("small".into(), effort_options(&["minimal", "medium"], "minimal")),
|
||||
]);
|
||||
let mgr = manager(tmp.path(), agent.clone());
|
||||
let task = mgr
|
||||
.create(NewAgentTask {
|
||||
project_root: None,
|
||||
prompt: text("again"),
|
||||
provider: "claude".into(),
|
||||
config: vec![],
|
||||
isolation: Isolation::Local,
|
||||
base: None,
|
||||
})
|
||||
.await
|
||||
.unwrap();
|
||||
wait_for(&mgr, &task.id, AgentStatus::Ready).await;
|
||||
mgr.shutdown();
|
||||
let restored = manager(tmp.path(), agent);
|
||||
restored.set_config(&task.id, "model", "small".into()).await.unwrap();
|
||||
restored.set_config(&task.id, "model", "big".into()).await.unwrap();
|
||||
restored.set_config(&task.id, option, value.into()).await.unwrap();
|
||||
let p = restored.providers().into_iter().find(|p| p.id == "claude").unwrap();
|
||||
let big = p.thought_levels.get("big").and_then(|levels| levels.first());
|
||||
assert_eq!(big.map(|o| o.values.len()), Some(2), "{option}: {:?}", p.thought_levels);
|
||||
let saved: HashMap<String, Known> =
|
||||
serde_json::from_slice(&std::fs::read(&restored.shared.paths.models_file).unwrap()).unwrap();
|
||||
assert_eq!(saved["claude"].thought_levels, p.thought_levels, "{option}");
|
||||
restored.shutdown();
|
||||
}
|
||||
}
|
||||
|
||||
#[tokio::test(flavor = "multi_thread")]
|
||||
async fn upfront_effort_is_validated_after_changing_model_before_the_prompt() {
|
||||
for (effort, applied) in [("medium", true), ("high", false)] {
|
||||
|
||||
@@ -218,20 +218,16 @@ where
|
||||
Ok(serde_json::from_value(serde_json::Value::deserialize(d)?).unwrap_or_default())
|
||||
}
|
||||
|
||||
/// The built-in themes that were removed (#2981; the One Dark Pro plugin
|
||||
/// maintains their look) and the built-in that stands in for each: read by
|
||||
/// [`theme_id`], and the removal notice looks for them in settings files.
|
||||
pub const REMOVED_THEMES: [(&str, &str); 2] = [("one-light", "light"), ("one-dark", "dark")];
|
||||
|
||||
/// A theme id, with the built-in themes that were removed read as the Islands theme of their kind.
|
||||
fn theme_id<'de, D>(d: D) -> Result<String, D::Error>
|
||||
where
|
||||
D: serde::Deserializer<'de>,
|
||||
{
|
||||
let id = String::deserialize(d)?;
|
||||
Ok(match REMOVED_THEMES.iter().find(|(removed, _)| *removed == id.as_str()) {
|
||||
Some((_, stand_in)) => (*stand_in).to_owned(),
|
||||
None => id,
|
||||
Ok(match id.as_str() {
|
||||
"one-light" => "light".into(),
|
||||
"one-dark" => "dark".into(),
|
||||
_ => id,
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -48,9 +48,6 @@ pub enum Capability {
|
||||
Ipc(String),
|
||||
/// Run one external program. Full code execution: never fine-grained.
|
||||
Process(String),
|
||||
/// Send a running language server (its name in the language definition) its own
|
||||
/// requests. The server reads and edits project files on the plugin's behalf.
|
||||
Lsp(String),
|
||||
/// Read files outside the project under one path.
|
||||
FsRead(String),
|
||||
/// Write files outside the project under one path.
|
||||
@@ -88,7 +85,6 @@ impl Capability {
|
||||
| Self::IdeCommands
|
||||
| Self::Ipc(_)
|
||||
| Self::Process(_)
|
||||
| Self::Lsp(_)
|
||||
| Self::FsRead(_)
|
||||
| Self::FsWrite(_) => Risk::High,
|
||||
}
|
||||
@@ -130,9 +126,6 @@ impl Capability {
|
||||
format!("Connect to local socket {path} — equivalent to running arbitrary code on the project machine")
|
||||
}
|
||||
Self::Process(bin) => format!("Run {bin} — equivalent to running arbitrary code on this machine"),
|
||||
Self::Lsp(server) => {
|
||||
format!("Send requests to the {server} language server, which reads and changes the project's files")
|
||||
}
|
||||
Self::FsRead(path) => format!("Read files under {path}, outside the project"),
|
||||
Self::FsWrite(path) => format!("Change files under {path}, outside the project"),
|
||||
}
|
||||
@@ -256,7 +249,6 @@ impl fmt::Display for Capability {
|
||||
Self::NetHttp(h) => write!(f, "net.http:{h}"),
|
||||
Self::Ipc(p) => write!(f, "ipc:{p}"),
|
||||
Self::Process(b) => write!(f, "process:{b}"),
|
||||
Self::Lsp(s) => write!(f, "lsp:{s}"),
|
||||
Self::FsRead(p) => write!(f, "fs.read:{p}"),
|
||||
Self::FsWrite(p) => write!(f, "fs.write:{p}"),
|
||||
}
|
||||
@@ -306,12 +298,6 @@ impl FromStr for Capability {
|
||||
}
|
||||
Ok(Self::Process(arg.to_owned()))
|
||||
}
|
||||
"lsp" => {
|
||||
if arg.len() > 128 || arg.chars().any(|c| c.is_whitespace() || c.is_control() || c == ':') {
|
||||
return Err(format!("{s:?}: use the server's name in its language definition"));
|
||||
}
|
||||
Ok(Self::Lsp(arg.to_owned()))
|
||||
}
|
||||
"fs.read" | "fs.write" => {
|
||||
if !std::path::Path::new(arg).is_absolute() && !arg.starts_with('~') {
|
||||
return Err(format!("{s:?}: use an absolute path (or ~/…)"));
|
||||
@@ -390,8 +376,6 @@ mod tests {
|
||||
"net:crates.io",
|
||||
"net:*.github.com",
|
||||
"process:cargo",
|
||||
"lsp:phoxite",
|
||||
"lsp:rust-analyzer",
|
||||
] {
|
||||
assert_eq!(s.parse::<Capability>().unwrap().to_string(), s);
|
||||
}
|
||||
@@ -408,9 +392,6 @@ mod tests {
|
||||
assert!("net:".parse::<Capability>().is_err());
|
||||
assert!("net:a b".parse::<Capability>().is_err());
|
||||
assert!("process:./evil".parse::<Capability>().is_err());
|
||||
assert!("lsp:".parse::<Capability>().is_err());
|
||||
assert!("lsp:a b".parse::<Capability>().is_err());
|
||||
assert!("lsp:phoxite:phoxite/laravel".parse::<Capability>().is_err());
|
||||
assert!("fs.read:rel".parse::<Capability>().is_err());
|
||||
assert!("fs.write:rel".parse::<Capability>().is_err());
|
||||
assert!("network".parse::<Capability>().is_err());
|
||||
@@ -424,8 +405,6 @@ mod tests {
|
||||
assert_eq!("clipboard".parse::<Capability>().unwrap(), Capability::Clipboard);
|
||||
assert_eq!(Capability::Clipboard.risk(), Risk::Medium);
|
||||
assert_eq!(Capability::Process("cargo".into()).risk(), Risk::High);
|
||||
assert_eq!(Capability::Lsp("phoxite".into()).risk(), Risk::High);
|
||||
assert!(!Capability::Lsp("phoxite".into()).covers(&Capability::Lsp("intelephense".into())));
|
||||
assert!(Capability::Storage.auto_migrates() && !Capability::EditorWrite.auto_migrates());
|
||||
}
|
||||
|
||||
|
||||
@@ -357,9 +357,6 @@ impl Manifest {
|
||||
if matches!(cap, Capability::NetAsk) {
|
||||
self.needs_api(&format!("capability `{cap}`"), 5)?;
|
||||
}
|
||||
if matches!(cap, Capability::Lsp(_)) {
|
||||
self.needs_api(&format!("capability `{cap}`"), 9)?;
|
||||
}
|
||||
}
|
||||
if let Some(dark) = &self.icon_dark {
|
||||
if self.icon.is_none() {
|
||||
@@ -715,21 +712,6 @@ mod tests {
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn language_server_capabilities_need_api_1_9() {
|
||||
let caps = "[capabilities]
|
||||
required = [\"lsp:phoxite\"]
|
||||
";
|
||||
for engine in ["^1.2", "^1.8"] {
|
||||
assert!(
|
||||
err(&format!("{}{caps}", BASE.replace("^1.2", engine))).contains("new in plugin API 1.9"),
|
||||
"{engine}"
|
||||
);
|
||||
}
|
||||
let m = Manifest::parse(&format!("{}{caps}", BASE.replace("^1.2", "^1.9"))).unwrap();
|
||||
assert_eq!(m.capabilities.required, [Capability::Lsp("phoxite".into())]);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn parses_icons() {
|
||||
let m = Manifest::parse(&format!("{BASE}icon = \"icon.svg\"\nicon-dark = \"icon_dark.svg\"\n")).unwrap();
|
||||
|
||||
@@ -65,15 +65,6 @@ pub fn settings(host: &Host, window: &str) -> Settings {
|
||||
})
|
||||
}
|
||||
|
||||
/// The removed built-in theme a settings file of this window still names, if any
|
||||
/// (`settings` reports its stand-in): the "provided by a plugin now" notice targets these.
|
||||
pub fn settings_removed_theme(host: &Host, window: &str) -> Option<String> {
|
||||
match host.project(window) {
|
||||
Ok(p) => p.settings.named_removed_theme().or_else(|| host.global_settings.named_removed_theme()),
|
||||
Err(_) => host.global_settings.named_removed_theme(),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn roots(host: &Host, window: &str) -> IdeResult<ide_workspace::ProjectRoots> {
|
||||
Ok(host.project(window)?.roots())
|
||||
}
|
||||
|
||||
@@ -97,21 +97,6 @@ pub trait PluginWorkspace: Send + Sync {
|
||||
fn indexed_files(&self, _root: &Path, _matches: &dyn Fn(&Path) -> bool, _limit: usize) -> Option<Vec<PathBuf>> {
|
||||
None
|
||||
}
|
||||
/// Sends `method` to the running language server named `server` of the project at
|
||||
/// `root`: a request, or with `notify` a notification (the result is null).
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
fn lsp_request(
|
||||
&self,
|
||||
_root: &Path,
|
||||
server: &str,
|
||||
_method: &str,
|
||||
_params: Option<serde_json::Value>,
|
||||
_notify: bool,
|
||||
_cancel: &CancellationToken,
|
||||
_timeout: Duration,
|
||||
) -> Result<serde_json::Value, HostError> {
|
||||
Err(HostError::NotFound(format!("no language server `{server}` is running for this project")))
|
||||
}
|
||||
/// Current index of the project rooted at `root`; never reads disk or calls LSP.
|
||||
fn symbols(
|
||||
&self,
|
||||
@@ -2195,35 +2180,6 @@ impl HostApi for PluginApi {
|
||||
)
|
||||
}
|
||||
|
||||
fn lsp_request(
|
||||
&self,
|
||||
root: &Path,
|
||||
server: &str,
|
||||
method: &str,
|
||||
params: Option<String>,
|
||||
notify: bool,
|
||||
cancel: &CancellationToken,
|
||||
timeout: Duration,
|
||||
) -> Result<String, HostError> {
|
||||
self.require_api("`language-servers`", 9)?;
|
||||
if !ide_lsp::plugin_method_allowed(method) {
|
||||
return Err(HostError::Invalid(format!("`{method}` is not one of the server's own methods")));
|
||||
}
|
||||
let workspace = self
|
||||
.shared
|
||||
.workspace()
|
||||
.ok_or_else(|| HostError::NotFound(format!("no language server `{server}` is running for this project")))?;
|
||||
// The server reads and edits the project on the plugin's behalf, as a process would.
|
||||
if !workspace.trusted(root) {
|
||||
return Err(HostError::Denied("project is not trusted".into()));
|
||||
}
|
||||
let params = params
|
||||
.map(|p| serde_json::from_str(&p).map_err(|e| HostError::Invalid(format!("params are not JSON: {e}"))))
|
||||
.transpose()?;
|
||||
let result = workspace.lsp_request(root, server, method, params, notify, cancel, timeout)?;
|
||||
Ok(result.to_string())
|
||||
}
|
||||
|
||||
fn find_files(&self, root: &Path, glob: &str, limit: usize) -> Result<Vec<String>, HostError> {
|
||||
let matcher = globset::GlobBuilder::new(glob)
|
||||
.literal_separator(true)
|
||||
@@ -3346,34 +3302,6 @@ impl PluginWorkspace for HostWorkspace {
|
||||
}
|
||||
}
|
||||
|
||||
fn lsp_request(
|
||||
&self,
|
||||
root: &Path,
|
||||
server: &str,
|
||||
method: &str,
|
||||
params: Option<serde_json::Value>,
|
||||
notify: bool,
|
||||
cancel: &CancellationToken,
|
||||
timeout: Duration,
|
||||
) -> Result<serde_json::Value, HostError> {
|
||||
use ide_core::error::ErrorKind;
|
||||
let host = self.0.upgrade().ok_or(HostError::Cancelled)?;
|
||||
let project = HostWorkspace::project_covering(self, root)
|
||||
.ok_or_else(|| HostError::NotFound("the project is no longer open".into()))?;
|
||||
let result = if notify {
|
||||
project.lsp.server_notify(root, server, method, params).map(|()| serde_json::Value::Null)
|
||||
} else {
|
||||
host.runtime.block_on(project.lsp.server_request(root, server, method, params, cancel, timeout))
|
||||
};
|
||||
result.map_err(|e| match e.kind {
|
||||
// A server that stopped while the request was on its way is as absent as one never started.
|
||||
ErrorKind::NotFound | ErrorKind::Unavailable => HostError::NotFound(e.message),
|
||||
ErrorKind::InvalidInput => HostError::Invalid(e.message),
|
||||
ErrorKind::Cancelled => HostError::Cancelled,
|
||||
_ => HostError::Failed(e.message),
|
||||
})
|
||||
}
|
||||
|
||||
fn trusted(&self, root: &Path) -> bool {
|
||||
// A workspace member is as trusted as the group's project it was opened with.
|
||||
HostWorkspace::project_covering(self, root).is_some_and(|p| p.is_trusted())
|
||||
|
||||
@@ -165,7 +165,6 @@ impl Dispatcher {
|
||||
})
|
||||
.add("project_roots", |c| async move { ops::project::roots(&c.host, &c.window) })
|
||||
.add("settings_get", |c| async move { Ok(ops::project::settings(&c.host, &c.window)) })
|
||||
.add("settings_removed_theme", |c| async move { Ok(ops::project::settings_removed_theme(&c.host, &c.window)) })
|
||||
.add("settings_set", |c| async move {
|
||||
let key: String = c.arg("key")?;
|
||||
let scope = c.arg("scope")?;
|
||||
|
||||
@@ -408,7 +408,6 @@ pub fn restricted_command_allowed(cmd: &str) -> bool {
|
||||
| "settings_export"
|
||||
| "settings_get"
|
||||
| "settings_get_global"
|
||||
| "settings_removed_theme"
|
||||
| "settings_import"
|
||||
| "settings_list_jetbrains_ides"
|
||||
| "settings_read_jetbrains"
|
||||
|
||||
@@ -31,8 +31,6 @@ struct TestWorkspace {
|
||||
/// plugin → its settings as the user set them.
|
||||
settings: Mutex<std::collections::BTreeMap<String, serde_json::Map<String, serde_json::Value>>>,
|
||||
global_settings: Mutex<std::collections::BTreeMap<String, serde_json::Map<String, serde_json::Value>>>,
|
||||
/// What plugins sent the language server `mock`: (method, params, whether a notification).
|
||||
server_messages: Mutex<Vec<(String, Option<serde_json::Value>, bool)>>,
|
||||
}
|
||||
|
||||
impl TestWorkspace {
|
||||
@@ -51,7 +49,6 @@ impl TestWorkspace {
|
||||
diagnostics: Mutex::default(),
|
||||
settings: Mutex::default(),
|
||||
global_settings: Mutex::default(),
|
||||
server_messages: Mutex::default(),
|
||||
})
|
||||
}
|
||||
|
||||
@@ -179,23 +176,6 @@ impl PluginWorkspace for TestWorkspace {
|
||||
fn trusted(&self, _root: &Path) -> bool {
|
||||
self.trusted
|
||||
}
|
||||
/// One language server runs for the project, `mock`: it answers with what it was sent.
|
||||
fn lsp_request(
|
||||
&self,
|
||||
_root: &Path,
|
||||
server: &str,
|
||||
method: &str,
|
||||
params: Option<serde_json::Value>,
|
||||
notify: bool,
|
||||
_cancel: &ide_core::CancellationToken,
|
||||
_timeout: Duration,
|
||||
) -> Result<serde_json::Value, HostError> {
|
||||
if server != "mock" {
|
||||
return Err(HostError::NotFound(format!("no language server `{server}` is running for this project")));
|
||||
}
|
||||
self.server_messages.lock().push((method.into(), params.clone(), notify));
|
||||
Ok(if notify { serde_json::Value::Null } else { serde_json::json!({ "method": method, "params": params }) })
|
||||
}
|
||||
fn project_windows(&self, root: &Path) -> Vec<String> {
|
||||
// `main` shows the fixture project; other open roots have no window left.
|
||||
if root == self.root { vec!["closing".into(), "main".into()] } else { Vec::new() }
|
||||
@@ -841,11 +821,10 @@ fn a_reporting_task_outlives_its_background_budget() {
|
||||
|
||||
#[test]
|
||||
fn background_tasks_scale_and_renew_cpu_fuel_budget() {
|
||||
// Room for activation (about 3_100 on macOS, more on Windows). A background task gets ten
|
||||
// times it (5 s / 500 ms): enough for each step of `patient` with its CPU work (32_000 to
|
||||
// 80_000), not for the whole run without the refill on each report.
|
||||
// Room for activation (about 3_100 on macOS, more on Windows) but not for `patient`'s
|
||||
// whole run (about 9_000) without the refill on each report.
|
||||
let f = fixture(Limits {
|
||||
fuel: 40_000,
|
||||
fuel: 6_000,
|
||||
timeout: Duration::from_millis(500),
|
||||
background: Duration::from_millis(5_000),
|
||||
..Limits::default()
|
||||
@@ -857,11 +836,11 @@ fn background_tasks_scale_and_renew_cpu_fuel_budget() {
|
||||
// Warm up activation in its own call so `patient` starts with a fresh budget.
|
||||
assert_eq!(f.run("misbehave", "echo", Some("warm")).unwrap().as_deref(), Some("warm"));
|
||||
|
||||
let out = f.run("misbehave", "patient", Some("4000")).expect("background task succeeds").expect("output");
|
||||
let out = f.run("misbehave", "patient", None).expect("background task succeeds").expect("output");
|
||||
assert_eq!(out, "still here");
|
||||
|
||||
let err = f.run("misbehave", "spin", None).unwrap_err();
|
||||
assert!(err.contains("exceeded its CPU budget (40000 fuel per call)"), "{err}");
|
||||
assert!(err.contains("exceeded its CPU budget (6000 fuel per call)"), "{err}");
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -2627,7 +2606,6 @@ fn git_toolbox_does_not_fetch_untrusted_projects() {
|
||||
diagnostics: Mutex::default(),
|
||||
settings: Mutex::default(),
|
||||
global_settings: Mutex::default(),
|
||||
server_messages: Mutex::default(),
|
||||
});
|
||||
f.host.set_workspace(Some(untrusted));
|
||||
let err = f.run("openidea.git-toolbox", "fetch", None).unwrap_err();
|
||||
@@ -6952,67 +6930,3 @@ fn project_write_judges_a_link_by_its_target() {
|
||||
assert_eq!(std::fs::read_to_string(&secret).unwrap(), "top secret", "{rel}");
|
||||
}
|
||||
}
|
||||
|
||||
/// A plugin reaches a running language server only with `lsp:<server>`, in a trusted
|
||||
/// project, and only with the server's own methods (API 1.9).
|
||||
#[test]
|
||||
fn language_server_requests_need_the_servers_grant_and_its_own_methods() {
|
||||
use serde_json::json;
|
||||
let f = fixture(Limits::default());
|
||||
let pkg = repo().join("crates/ide-plugin/tests/fixtures/lsp-requests");
|
||||
let id = "test.lsp-requests";
|
||||
let info = f.install(&pkg);
|
||||
assert!(info.capabilities.iter().any(|c| c.id == "lsp:mock" && c.granted && c.risk == ide_extension::Risk::High));
|
||||
|
||||
// The request and its JSON params reach the server; its answer comes back as JSON.
|
||||
let answer = f.run(id, "request", Some(r#"{"verb":"GET"}"#)).unwrap().unwrap();
|
||||
assert_eq!(
|
||||
serde_json::from_str::<serde_json::Value>(&answer).unwrap(),
|
||||
json!({ "method": "mock/routes", "params": { "verb": "GET" } })
|
||||
);
|
||||
assert_eq!(f.run(id, "notify", None).unwrap(), None);
|
||||
assert_eq!(
|
||||
*f.workspace.server_messages.lock(),
|
||||
[("mock/routes".to_owned(), Some(json!({ "verb": "GET" })), false), ("mock/changed".to_owned(), None, true)]
|
||||
);
|
||||
|
||||
// Params that are not JSON and LSP's own methods stop at the host.
|
||||
assert!(f.run(id, "request", Some("{")).unwrap_err().contains("params are not JSON"));
|
||||
assert!(f.run(id, "standard", None).unwrap_err().contains("not one of the server's own methods"));
|
||||
assert_eq!(f.workspace.server_messages.lock().len(), 2);
|
||||
|
||||
// The grant names one server: another one is denied, not merely absent.
|
||||
let err = f.host.run_command(id, "ungranted", None, f.inv()).unwrap_err();
|
||||
assert_eq!(err.kind, ErrorKind::PermissionDenied, "{err:?}");
|
||||
assert!(err.message.contains("lsp:other"), "{err:?}");
|
||||
|
||||
// Without the grant the call is denied and nothing is sent.
|
||||
f.host.set_capability(id, "lsp:mock", false).unwrap();
|
||||
let err = f.host.run_command(id, "request", None, f.inv()).unwrap_err();
|
||||
assert_eq!(err.kind, ErrorKind::PermissionDenied, "{err:?}");
|
||||
assert!(err.message.contains("lsp:mock"), "{err:?}");
|
||||
f.host.set_capability(id, "lsp:mock", true).unwrap();
|
||||
f.run(id, "request", None).unwrap();
|
||||
|
||||
// A server acts on the project's files: not in an untrusted project.
|
||||
let mut untrusted = TestWorkspace::new(&f.project);
|
||||
Arc::get_mut(&mut untrusted).unwrap().trusted = false;
|
||||
f.host.set_workspace(Some(untrusted.clone()));
|
||||
let err = f.host.run_command(id, "request", None, f.inv()).unwrap_err();
|
||||
assert_eq!(err.kind, ErrorKind::PermissionDenied, "{err:?}");
|
||||
assert!(untrusted.server_messages.lock().is_empty());
|
||||
assert_eq!(f.host.info_of(id).unwrap().stats.crashes, 0);
|
||||
}
|
||||
|
||||
/// The grant is new in API 1.9: an older `engines.openidea` can't ask for it.
|
||||
#[test]
|
||||
fn the_language_server_grant_needs_api_1_9() {
|
||||
let f = fixture(Limits::default());
|
||||
let tmp = tempfile::tempdir().unwrap();
|
||||
let pkg = tmp.path().join("lsp-requests");
|
||||
copy_dir(&repo().join("crates/ide-plugin/tests/fixtures/lsp-requests"), &pkg);
|
||||
let manifest = std::fs::read_to_string(pkg.join("plugin.toml")).unwrap();
|
||||
std::fs::write(pkg.join("plugin.toml"), manifest.replace("\"^1.9\"", "\"^1.8\"")).unwrap();
|
||||
let err = f.host.install_from_dir(&pkg, &Consent::all()).unwrap_err();
|
||||
assert!(err.message.contains("new in plugin API 1.9"), "{err:?}");
|
||||
}
|
||||
@@ -215,18 +215,12 @@ pub trait Handler: Send + Sync + 'static {
|
||||
/// Respond to a server→client request (e.g. `workspace/configuration`).
|
||||
fn on_request(&self, method: &str, params: Value) -> Result<Value, (i64, String)>;
|
||||
|
||||
/// [`on_request`](Self::on_request) for handlers whose errors carry `data`.
|
||||
/// [`on_request`](Self::on_request) for handlers whose errors carry `data`. This is the
|
||||
/// one the connection calls.
|
||||
fn on_request_with_data(&self, method: &str, params: Value) -> Result<Value, (i64, String, Option<Value>)> {
|
||||
self.on_request(method, params).map_err(|(code, message)| (code, message, None))
|
||||
}
|
||||
|
||||
/// [`on_request_with_data`](Self::on_request_with_data) with the request as received, for
|
||||
/// handlers that need what `Value` drops, such as the order of an object's keys. This is the
|
||||
/// one the connection calls.
|
||||
fn on_request_raw(&self, method: &str, params: Value, _raw: &[u8]) -> Result<Value, (i64, String, Option<Value>)> {
|
||||
self.on_request_with_data(method, params)
|
||||
}
|
||||
|
||||
/// Called once the response to a `method` request is queued: what it sends follows the response.
|
||||
fn after_response(&self, _method: &str) {}
|
||||
|
||||
@@ -583,8 +577,8 @@ impl Peer {
|
||||
tracing::error!("jsonrpc notification handler panicked on {method}");
|
||||
}
|
||||
}
|
||||
Incoming::Request(id, method, params, raw) => {
|
||||
runtime.spawn(handle_request(inner.clone(), handler.clone(), id, method, params, raw));
|
||||
Incoming::Request(id, method, params) => {
|
||||
runtime.spawn(handle_request(inner.clone(), handler.clone(), id, method, params));
|
||||
}
|
||||
Incoming::Response(tx, result) => {
|
||||
let _ = tx.send(result);
|
||||
@@ -767,21 +761,14 @@ fn parse_id(id: &Value) -> Option<i64> {
|
||||
|
||||
enum Incoming {
|
||||
Notification(String, Value),
|
||||
Request(Value, String, Value, Arc<[u8]>),
|
||||
Request(Value, String, Value),
|
||||
Response(oneshot::Sender<Result<Value, RpcError>>, Result<Value, RpcError>),
|
||||
}
|
||||
|
||||
async fn handle_request(
|
||||
inner: Arc<Inner>,
|
||||
handler: Arc<dyn Handler>,
|
||||
id: Value,
|
||||
method: String,
|
||||
params: Value,
|
||||
raw: Arc<[u8]>,
|
||||
) {
|
||||
async fn handle_request(inner: Arc<Inner>, handler: Arc<dyn Handler>, id: Value, method: String, params: Value) {
|
||||
let m = method.clone();
|
||||
let h = handler.clone();
|
||||
let result = tokio::task::spawn_blocking(move || h.on_request_raw(&m, params, &raw)).await;
|
||||
let result = tokio::task::spawn_blocking(move || h.on_request_with_data(&m, params)).await;
|
||||
let reply = match result {
|
||||
Ok(Ok(result)) => json!({ "jsonrpc": "2.0", "id": id, "result": result }),
|
||||
Ok(Err((code, message, data))) => {
|
||||
@@ -821,7 +808,7 @@ fn dispatch(inner: &Arc<Inner>, handler: &dyn Handler, notif_tx: &std::sync::mps
|
||||
let params = obj.remove("params").unwrap_or(Value::Null);
|
||||
match id {
|
||||
Some(id) if !id.is_null() => {
|
||||
let _ = notif_tx.send(Incoming::Request(id, method, params, Arc::from(body)));
|
||||
let _ = notif_tx.send(Incoming::Request(id, method, params));
|
||||
}
|
||||
_ => {
|
||||
let _ = notif_tx.send(Incoming::Notification(method, params));
|
||||
|
||||
@@ -26,7 +26,6 @@ mod launch;
|
||||
mod library_source;
|
||||
mod loading;
|
||||
mod notebook;
|
||||
mod plugin_requests;
|
||||
mod pull;
|
||||
mod scope;
|
||||
mod server;
|
||||
@@ -46,7 +45,6 @@ pub use jdtls::jvm_inspect::JdtJvmInspector;
|
||||
pub use kotlin_lsp::{KotlinDebugServer, KotlinDebugUnavailable};
|
||||
pub use launch::{LaunchError, Launcher, ProcessLauncher};
|
||||
pub use notebook::{NotebookCell, NotebookCellDoc, cell_uri};
|
||||
pub use plugin_requests::plugin_method_allowed;
|
||||
pub use scope::{CandidateFiles, CandidateFn, CandidateQuery, MAX_CANDIDATES};
|
||||
pub use uri::{is_virtual_uri, path_to_uri_string, uri_target, uri_to_path};
|
||||
|
||||
|
||||
@@ -1,119 +0,0 @@
|
||||
//! Requests a plugin sends to a running server (`language-servers` in the plugin API):
|
||||
//! the server's own methods only, and only to a server that already runs.
|
||||
|
||||
use crate::{LspManager, Target, rpc_err};
|
||||
use ide_core::{CancellationToken, IdeError, IdeResult};
|
||||
use serde_json::Value;
|
||||
use std::path::Path;
|
||||
use std::time::Duration;
|
||||
|
||||
/// The first segment of the methods LSP itself defines.
|
||||
const LSP_NAMESPACES: [&str; 14] = [
|
||||
"textDocument",
|
||||
"workspace",
|
||||
"window",
|
||||
"notebookDocument",
|
||||
"callHierarchy",
|
||||
"typeHierarchy",
|
||||
"completionItem",
|
||||
"codeAction",
|
||||
"codeLens",
|
||||
"documentLink",
|
||||
"inlayHint",
|
||||
"workspaceSymbol",
|
||||
"client",
|
||||
"telemetry",
|
||||
];
|
||||
const LIFECYCLE: [&str; 4] = ["initialize", "initialized", "shutdown", "exit"];
|
||||
|
||||
/// Whether a plugin may send `method`: only a server's own namespace passes
|
||||
/// (`phoxite/laravel/routes`), so a plugin can't interfere with document sync, the
|
||||
/// features the IDE asks for itself, or the server's lifecycle.
|
||||
pub fn plugin_method_allowed(method: &str) -> bool {
|
||||
let namespace = method.split('/').next().unwrap_or_default();
|
||||
!(method.is_empty()
|
||||
|| method.starts_with("$/")
|
||||
|| LIFECYCLE.contains(&method)
|
||||
|| LSP_NAMESPACES.contains(&namespace))
|
||||
}
|
||||
|
||||
impl LspManager {
|
||||
/// The running server named `server`, the one rooted at `root` first. Never starts one.
|
||||
fn plugin_target(&self, root: &Path, server: &str, method: &str) -> IdeResult<Target> {
|
||||
if !plugin_method_allowed(method) {
|
||||
return Err(IdeError::invalid(format!("`{method}` is not one of the server's own methods")));
|
||||
}
|
||||
let mut running: Vec<Target> = self
|
||||
.servers
|
||||
.lock()
|
||||
.iter()
|
||||
.filter(|s| s.name == server)
|
||||
.filter_map(|s| s.running().map(|run| Target { server: s.clone(), run }))
|
||||
.collect();
|
||||
let at = running.iter().position(|t| t.server.root == root).unwrap_or(0);
|
||||
if running.is_empty() {
|
||||
return Err(IdeError::not_found(format!("no language server `{server}` is running for this project")));
|
||||
}
|
||||
Ok(running.swap_remove(at))
|
||||
}
|
||||
|
||||
/// Sends a plugin's request to the running server named `server` (its name in the
|
||||
/// language definition) and returns the result. `not_found` when it is not running,
|
||||
/// `invalid` for a method that is not the server's own.
|
||||
pub async fn server_request(
|
||||
&self,
|
||||
root: &Path,
|
||||
server: &str,
|
||||
method: &str,
|
||||
params: Option<Value>,
|
||||
cancel: &CancellationToken,
|
||||
timeout: Duration,
|
||||
) -> IdeResult<Value> {
|
||||
let t = self.plugin_target(root, server, method)?;
|
||||
self.call(&t, method, params.unwrap_or(Value::Null), Some(cancel), timeout).await
|
||||
}
|
||||
|
||||
/// The same for a notification.
|
||||
pub fn server_notify(&self, root: &Path, server: &str, method: &str, params: Option<Value>) -> IdeResult<()> {
|
||||
let t = self.plugin_target(root, server, method)?;
|
||||
t.run.peer.notify(method, params.unwrap_or(Value::Null)).map_err(|e| rpc_err(server, method, e))
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::plugin_method_allowed;
|
||||
|
||||
#[test]
|
||||
fn only_a_servers_own_methods_pass() {
|
||||
for method in ["phoxite/laravel/routes", "phoxite/refactor/hierarchy", "rust-analyzer/expandMacro", "custom"] {
|
||||
assert!(plugin_method_allowed(method), "{method}");
|
||||
}
|
||||
for method in [
|
||||
"",
|
||||
"initialize",
|
||||
"initialized",
|
||||
"shutdown",
|
||||
"exit",
|
||||
"$/cancelRequest",
|
||||
"$/progress",
|
||||
"textDocument/hover",
|
||||
"textDocument/didChange",
|
||||
"workspace/executeCommand",
|
||||
"window/showMessage",
|
||||
"notebookDocument/didOpen",
|
||||
"callHierarchy/incomingCalls",
|
||||
"typeHierarchy/supertypes",
|
||||
"completionItem/resolve",
|
||||
"codeAction/resolve",
|
||||
"codeLens/resolve",
|
||||
"documentLink/resolve",
|
||||
"inlayHint/resolve",
|
||||
"workspaceSymbol/resolve",
|
||||
"client/registerCapability",
|
||||
"telemetry/event",
|
||||
] {
|
||||
assert!(!plugin_method_allowed(method), "{method}");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2969,8 +2969,7 @@ async fn library_classes_without_sources_open_decompiled_by_a_running_jdtls() {
|
||||
zip.write_all(b"\0").unwrap();
|
||||
zip.finish().unwrap();
|
||||
let class = format!("jar://{}!/acme/Thing.class", uri_of(&jar).trim_start_matches("file://"));
|
||||
// jdtls writes the portable path (forward slashes on Windows too), each `/` escaped.
|
||||
let escaped = jar.to_string_lossy().replace('\\', "/").replace('/', "%5C/");
|
||||
let escaped = jar.to_string_lossy().replace('/', "%5C/");
|
||||
let jdt = format!("jdt://contents/lib-1.0.jar/acme/Thing.class?=app/{escaped}%3Cacme%28Thing.class");
|
||||
let decompiled =
|
||||
"package acme;\n\npublic class Thing {\n public void run() {\n System.out.println();\n }\n}\n";
|
||||
@@ -7373,59 +7372,3 @@ async fn notebook_edits_change_cell_text_and_reorders_reopen_it() {
|
||||
.await;
|
||||
h.mgr.shutdown_all().await;
|
||||
}
|
||||
|
||||
/// A plugin's request (`language-servers` in the plugin API) reaches the running server
|
||||
/// named in the language definition: only the server's own methods, and never a start.
|
||||
#[tokio::test(flavor = "multi_thread")]
|
||||
async fn a_plugin_request_reaches_only_a_running_servers_own_methods() {
|
||||
let servers = [("main", incremental_caps()), ("alt", incremental_caps())];
|
||||
let h = harness_for("mock", "mk", &servers, &["alt"]);
|
||||
let _ = h.open("a.mk", "x");
|
||||
h.wait_status("main", ServerStatus::Ready).await;
|
||||
let s = h.launcher.state("main");
|
||||
s.respond("mock/routes", json!([{ "uri": "/users", "name": "users.index" }]));
|
||||
let cancel = CancellationToken::new();
|
||||
let timeout = Duration::from_secs(5);
|
||||
|
||||
// A request: the params arrive, the result comes back.
|
||||
let routes = h
|
||||
.mgr
|
||||
.server_request(&h.root, "main", "mock/routes", Some(json!({ "method": "GET" })), &cancel, timeout)
|
||||
.await
|
||||
.unwrap();
|
||||
assert_eq!(routes, json!([{ "uri": "/users", "name": "users.index" }]));
|
||||
assert_eq!(s.requested("mock/routes"), [json!({ "method": "GET" })]);
|
||||
|
||||
// A notification.
|
||||
h.mgr.server_notify(&h.root, "main", "mock/changed", Some(json!({ "what": "routes" }))).unwrap();
|
||||
eventually(|| s.notified("mock/changed") == [json!({ "what": "routes" })]).await;
|
||||
|
||||
// LSP's own methods are refused before anything is sent.
|
||||
for method in ["textDocument/hover", "workspace/executeCommand", "$/cancelRequest", "shutdown", "initialize"] {
|
||||
let before = (s.requested(method).len(), s.notified(method).len());
|
||||
let e = h.mgr.server_request(&h.root, "main", method, None, &cancel, timeout).await.unwrap_err();
|
||||
assert_eq!(e.kind, ide_core::error::ErrorKind::InvalidInput, "{method}");
|
||||
assert_eq!(
|
||||
h.mgr.server_notify(&h.root, "main", method, None).unwrap_err().kind,
|
||||
ide_core::error::ErrorKind::InvalidInput
|
||||
);
|
||||
assert_eq!((s.requested(method).len(), s.notified(method).len()), before, "{method}");
|
||||
}
|
||||
|
||||
// A server that is defined but not running is not started; an unknown name is the same.
|
||||
for server in ["alt", "nobody"] {
|
||||
let e = h.mgr.server_request(&h.root, server, "mock/routes", None, &cancel, timeout).await.unwrap_err();
|
||||
assert_eq!(e.kind, ide_core::error::ErrorKind::NotFound, "{server}");
|
||||
assert_eq!(
|
||||
h.mgr.server_notify(&h.root, server, "mock/changed", None).unwrap_err().kind,
|
||||
ide_core::error::ErrorKind::NotFound
|
||||
);
|
||||
}
|
||||
assert_eq!(h.launcher.state("alt").launches.load(Ordering::SeqCst), 0);
|
||||
assert!(h.statuses("alt").is_empty());
|
||||
|
||||
// A cancelled invocation ends the request.
|
||||
cancel.cancel();
|
||||
let e = h.mgr.server_request(&h.root, "main", "mock/routes", None, &cancel, timeout).await.unwrap_err();
|
||||
assert_eq!(e.kind, ide_core::error::ErrorKind::Cancelled);
|
||||
}
|
||||
@@ -100,23 +100,6 @@ pub trait HostApi: Send + Sync {
|
||||
let _ = (root, client, id, cancel, timeout);
|
||||
Err(HostError::Invalid("Database subsystem is unavailable on this host".into()))
|
||||
}
|
||||
/// Sends `method` to the running language server named `server` of the project at
|
||||
/// `root`: a request (the result as JSON), or with `notify` a notification (`null`).
|
||||
/// `params` is JSON. Never starts a server.
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
fn lsp_request(
|
||||
&self,
|
||||
root: &Path,
|
||||
server: &str,
|
||||
method: &str,
|
||||
params: Option<String>,
|
||||
notify: bool,
|
||||
cancel: &CancellationToken,
|
||||
timeout: Duration,
|
||||
) -> Result<String, HostError> {
|
||||
let _ = (root, method, params, notify, cancel, timeout);
|
||||
Err(HostError::NotFound(format!("no language server `{server}` is running for this project")))
|
||||
}
|
||||
/// Stdio argv only; no URL or bearer token.
|
||||
fn mcp_stdio_command(&self, client: &str) -> Option<Vec<String>> {
|
||||
let _ = client;
|
||||
|
||||
@@ -59,7 +59,6 @@ pub(crate) mod syntax_bindings {
|
||||
"openidea:plugin/output": super::bindings::openidea::plugin::output,
|
||||
"openidea:plugin/auth": super::bindings::openidea::plugin::auth,
|
||||
"openidea:plugin/command-runner": super::bindings::openidea::plugin::command_runner,
|
||||
"openidea:plugin/language-servers": super::bindings::openidea::plugin::language_servers,
|
||||
"openidea:plugin/ipc": super::bindings::openidea::plugin::ipc,
|
||||
"openidea:plugin/fs": super::bindings::openidea::plugin::fs,
|
||||
"openidea:plugin/views": super::bindings::openidea::plugin::views,
|
||||
@@ -98,7 +97,6 @@ pub(crate) mod providers_bindings {
|
||||
"openidea:plugin/output": super::bindings::openidea::plugin::output,
|
||||
"openidea:plugin/auth": super::bindings::openidea::plugin::auth,
|
||||
"openidea:plugin/command-runner": super::bindings::openidea::plugin::command_runner,
|
||||
"openidea:plugin/language-servers": super::bindings::openidea::plugin::language_servers,
|
||||
"openidea:plugin/ipc": super::bindings::openidea::plugin::ipc,
|
||||
"openidea:plugin/fs": super::bindings::openidea::plugin::fs,
|
||||
"openidea:plugin/views": super::bindings::openidea::plugin::views,
|
||||
@@ -137,7 +135,6 @@ pub(crate) mod views_bindings {
|
||||
"openidea:plugin/output": super::bindings::openidea::plugin::output,
|
||||
"openidea:plugin/auth": super::bindings::openidea::plugin::auth,
|
||||
"openidea:plugin/command-runner": super::bindings::openidea::plugin::command_runner,
|
||||
"openidea:plugin/language-servers": super::bindings::openidea::plugin::language_servers,
|
||||
"openidea:plugin/ipc": super::bindings::openidea::plugin::ipc,
|
||||
"openidea:plugin/fs": super::bindings::openidea::plugin::fs,
|
||||
"openidea:plugin/views": super::bindings::openidea::plugin::views,
|
||||
@@ -2651,57 +2648,6 @@ impl bindings::openidea::plugin::database::Host for StoreData {
|
||||
Ok(result.map_err(to_wit))
|
||||
}
|
||||
}
|
||||
/// The longest method name and params a plugin may send a language server.
|
||||
const MAX_LSP_METHOD: usize = 256;
|
||||
const MAX_LSP_PARAMS: usize = 1 << 20;
|
||||
|
||||
impl StoreData {
|
||||
fn lsp_call(
|
||||
&mut self,
|
||||
project: Resource<ProjectRes>,
|
||||
server: String,
|
||||
method: String,
|
||||
params: Option<String>,
|
||||
notify: bool,
|
||||
) -> Fallible<String> {
|
||||
if let Err(e) = self.require(Capability::Lsp(server.clone())) {
|
||||
return Ok(Err(e));
|
||||
}
|
||||
if method.len() > MAX_LSP_METHOD || params.as_ref().is_some_and(|p| p.len() > MAX_LSP_PARAMS) {
|
||||
return Ok(Err(wit::Error::Invalid("method exceeds 256 bytes or params exceed 1 MiB".into())));
|
||||
}
|
||||
let root = self.table.get(&project)?.root.clone();
|
||||
let token = self.cancel.token();
|
||||
let timeout = self.io_timeout();
|
||||
let outcome = self.host.lsp_request(&root, &server, &method, params, notify, &token, timeout);
|
||||
if outcome.is_err() {
|
||||
self.grant_io_error_grace();
|
||||
}
|
||||
Ok(outcome.map_err(to_wit))
|
||||
}
|
||||
}
|
||||
|
||||
impl bindings::openidea::plugin::language_servers::Host for StoreData {
|
||||
fn request(
|
||||
&mut self,
|
||||
project: Resource<ProjectRes>,
|
||||
server: String,
|
||||
method: String,
|
||||
params: Option<String>,
|
||||
) -> Fallible<String> {
|
||||
self.lsp_call(project, server, method, params, false)
|
||||
}
|
||||
fn notify(
|
||||
&mut self,
|
||||
project: Resource<ProjectRes>,
|
||||
server: String,
|
||||
method: String,
|
||||
params: Option<String>,
|
||||
) -> Fallible<()> {
|
||||
Ok(self.lsp_call(project, server, method, params, true)?.map(|_| ()))
|
||||
}
|
||||
}
|
||||
|
||||
impl bindings::openidea::plugin::extensions::Host for StoreData {
|
||||
fn contributions(&mut self, point: String) -> Fallible<Vec<bindings::openidea::plugin::extensions::Contribution>> {
|
||||
Ok(self
|
||||
|
||||
Бінарний файл не відображається.
@@ -1 +1 @@
|
||||
75123cf60f87ec9bdd36e0b7f75efb69d000136d74c3e9da893ecd1534bdf534
|
||||
a3d2511f30277245a8cb9673c4d8a948a8a025b8b9149d5015bed5137a98ccdd
|
||||
Бінарний файл не відображається.
@@ -1 +1 @@
|
||||
60d66ec578e3adc7adaebbcd01aa92a74a8a7e4cfd4d1aa778f9b033c75234a6
|
||||
dad3edad99ad85234aa612bbc1f3a66e50361189e54038b91674703815f049cc
|
||||
Бінарний файл не відображається.
+1
-1
@@ -1 +1 @@
|
||||
df55973ed77e734e48fe1d2b7bb5d1e4eb68153b17452e4385599145427292b6
|
||||
918af7d4d8bc302621b9b68070a56930813b1fc2ba235d89de4e56c53eaba5bd
|
||||
Бінарний файл не відображається.
+1
-1
@@ -1 +1 @@
|
||||
94f1c4a8192e15961bd136cf9dc3416fca7b295bce0d563608a3ee9fdf81c28e
|
||||
7a140c2255a3d251a5ab9079bec953cccc4408727b067b49da47cf8fb27d8cb8
|
||||
Бінарний файл не відображається.
+1
-1
@@ -1 +1 @@
|
||||
db140480eaf4352fa8db8d87aab95cb07944e19c28d2cc08e299b37c5deb4230
|
||||
ef41934bd0b67f76a17ef321b44c172496314c9fea6b46b4cd2f1d0f4b96907d
|
||||
Бінарний файл не відображається.
@@ -1 +1 @@
|
||||
5fd76f6168d3a7b3259281171f375cf01da6ceabdf4ffd382c5fe7034b2e94f2
|
||||
c6dc1ae00d9f3d936f4bf5ff110915050cb503ac06982bdc48e967deac84a913
|
||||
Бінарний файл не відображається.
@@ -1 +1 @@
|
||||
5d9049fa006194e92e06de47ab933d249118706a8ba92100493318a1582f2b65
|
||||
25a782556dd6bbf8ed1ad7b50b9b55685f074d80220af08f3bd9cb12cf07f74e
|
||||
Бінарний файл не відображається.
@@ -1 +1 @@
|
||||
c723d915b69292740a863b3a94db6f6f8c218ecda46c527229d621084f2df3b1
|
||||
f58b5f68d56611c3d15f69ff8e73e6e65d84e55d14c9bae00ed50b346460adfa
|
||||
Бінарний файл не відображається.
+1
-1
@@ -1 +1 @@
|
||||
2dbab98cfc473650675b2691c7d0f2d5b088ffd6208e31ef30aaa54dd3b1b4b0
|
||||
749bff2d051984edf65590494ef803225dfccd03d032de140974d8e984683ac1
|
||||
Бінарний файл не відображається.
+1
-1
@@ -1 +1 @@
|
||||
1fa1515aae810e588f2c1d25728755c25fd51c78d35d96d823583052372c34dd
|
||||
50c609ebf387b400a01ea28e6ccf0f3de2ff7a5eedbb47c0a4bc40d05e3aaade
|
||||
Бінарний файл не відображається.
+1
-1
@@ -1 +1 @@
|
||||
69eaf24b0ed3260a6b3656563b1d0b8b268de81899f05bc984c668b0765e361f
|
||||
c2350d0277636285b182d1484d01d706c3116ef5e28917ddeb24ca78bac251ba
|
||||
Бінарний файл не відображається.
@@ -1 +1 @@
|
||||
c6bd0a45a6cc3b09114be55c8b63563bea4ca6b748ee27c7843bb4ab05d7ce26
|
||||
3aaa2a7655189a1e4da55a86fb30fdfde29a5b6ad65de53a78b18df30eeb97f3
|
||||
Бінарний файл не відображається.
@@ -1 +1 @@
|
||||
f870210add7c920df42e276a4cefcd1eaf01b3869f238c0a366beeb052e4adc3
|
||||
975ead22afb4c5bc5c79799b76c1d3a683b572b906e3bade94944319920f7f84
|
||||
Бінарний файл не відображається.
@@ -1 +1 @@
|
||||
3a3c0d4e5a1564eaa2ca35b698cd4b553722476cf68995495b9f277631b08266
|
||||
b849aeca8e5d6b6ede216e372cfc019bac08774006e11ed81d272f67770adc17
|
||||
Бінарний файл не відображається.
+1
-1
@@ -1 +1 @@
|
||||
aab9d674d5d94b7488fe088e5c355511403edf7878c6fe124e2a2be86598ead6
|
||||
79505f2677e5f19374a3ed46cccdc1ed8d3092a3c43e3154e8cfd73063533251
|
||||
Бінарний файл не відображається.
@@ -1 +1 @@
|
||||
391ce453aa40de84ca4a6ed5f5b8ee88f5d659e8699029fa3a8940dac7d6dc9b
|
||||
f7f43d46ebd545cc4c52d859c4307d08bb95b3187a4b947704e37c27cf0f4fa0
|
||||
Бінарний файл не відображається.
+1
-1
@@ -1 +1 @@
|
||||
ccbb5abb90a0bb49c0f51d0e2865d1c4092e28e9168e4c57e5f7b6ea971721ac
|
||||
491e8e713e51045ebef81c4f07ed5475ed41688e88ac47ee26d13f2bc5c53b49
|
||||
-336
@@ -1,336 +0,0 @@
|
||||
# This file is automatically @generated by Cargo.
|
||||
# It is not intended for manual editing.
|
||||
version = 4
|
||||
|
||||
[[package]]
|
||||
name = "anyhow"
|
||||
version = "1.0.104"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "330a5ed07fa54e4702c9d6c4174f74427fc0ef6e214bbd677ae50a5099946470"
|
||||
|
||||
[[package]]
|
||||
name = "bitflags"
|
||||
version = "2.13.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3ded4057c258ba199e2d26386d3af3780957ecaee6c4ef4041c6b4b8b97c0b06"
|
||||
|
||||
[[package]]
|
||||
name = "equivalent"
|
||||
version = "1.0.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "00d174d5400e5e8fd687ad1049e2f578285fa914201b1af7e8b112a4546bd826"
|
||||
|
||||
[[package]]
|
||||
name = "foldhash"
|
||||
version = "0.2.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "77ce24cb58228fbb8aa041425bb1050850ac19177686ea6e0f41a70416f56fdb"
|
||||
|
||||
[[package]]
|
||||
name = "hashbrown"
|
||||
version = "0.17.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ed5909b6e89a2db4456e54cd5f673791d7eca6732202bbf2a9cc504fe2f9b84a"
|
||||
dependencies = [
|
||||
"foldhash",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "heck"
|
||||
version = "0.5.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea"
|
||||
|
||||
[[package]]
|
||||
name = "id-arena"
|
||||
version = "2.3.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3d3067d79b975e8844ca9eb072e16b31c3c1c36928edf9c6789548c524d0d954"
|
||||
|
||||
[[package]]
|
||||
name = "indexmap"
|
||||
version = "2.14.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "cc4e190f5d26ca7051642629da2c52fc03bde85a03197c99408dcd291734c855"
|
||||
dependencies = [
|
||||
"equivalent",
|
||||
"hashbrown",
|
||||
"serde",
|
||||
"serde_core",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "itoa"
|
||||
version = "1.0.18"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8f42a60cbdf9a97f5d2305f08a87dc4e09308d1276d28c869c684d7777685682"
|
||||
|
||||
[[package]]
|
||||
name = "leb128fmt"
|
||||
version = "0.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "09edd9e8b54e49e587e4f6295a7d29c3ea94d469cb40ab8ca70b288248a81db2"
|
||||
|
||||
[[package]]
|
||||
name = "log"
|
||||
version = "0.4.35"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5d15f86d12da44cd8d4ec3c73984537eb7f4cadcb9776a575a0a8a05ca11005c"
|
||||
|
||||
[[package]]
|
||||
name = "macro-string"
|
||||
version = "0.3.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6e7b3a5bbb2f63aaa223a671ea1bd0e7bc16bd30ce387324cf63995deaddbbd2"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "memchr"
|
||||
version = "2.8.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "cf8baf1c55e62ffcace7a9f06f4bd9cd3f0c4beb022d3b367256b91b87513d98"
|
||||
|
||||
[[package]]
|
||||
name = "openidea-plugin"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"serde",
|
||||
"serde_json",
|
||||
"wit-bindgen",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "openidea-test-lsp-requests"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"openidea-plugin",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "prettyplease"
|
||||
version = "0.3.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2bfe0f4c752e450fc2faf62654f1c134747922825d5b04ca717b8874f41a40c0"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "proc-macro2"
|
||||
version = "1.0.107"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "985e7ec9bb745e6ce6535b544d84d6cd6f7ad8bd711c398938ae983b91a766d9"
|
||||
dependencies = [
|
||||
"unicode-ident",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "quote"
|
||||
version = "1.0.47"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1fbf4db142a473a8d80c26bbf18454ed458bf8d26c8219c331daecfdbd079001"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "semver"
|
||||
version = "1.0.28"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8a7852d02fc848982e0c167ef163aaff9cd91dc640ba85e263cb1ce46fae51cd"
|
||||
|
||||
[[package]]
|
||||
name = "serde"
|
||||
version = "1.0.229"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4148590afebada386688f18773da617792bf2ef03ffc1e4cbd2b1d45b023e0ba"
|
||||
dependencies = [
|
||||
"serde_core",
|
||||
"serde_derive",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "serde_core"
|
||||
version = "1.0.229"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "67dca2c9c51e58a4791a4b1ed58308b39c64224d349a935ab5039aa360942a48"
|
||||
dependencies = [
|
||||
"serde_derive",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "serde_derive"
|
||||
version = "1.0.229"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e7a5d71263a5a7d47b41f6b3f06ba276f10cc18b0931f1799f710578e2309348"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "serde_json"
|
||||
version = "1.0.154"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e7e9cc8b1b85264074fbcc02a88680c4096b1e47df8f739dceb03bf482f04bd6"
|
||||
dependencies = [
|
||||
"itoa",
|
||||
"memchr",
|
||||
"serde",
|
||||
"serde_core",
|
||||
"zmij",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "syn"
|
||||
version = "3.0.9"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d78c8dee4c7bf0e14673097256fed6142ce9d3b85a408189d07482442145823b"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"unicode-ident",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "unicode-ident"
|
||||
version = "1.0.27"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a2c754d6c33795a1c324727428e5a7dedb5b06195f9890bdbcba760d3e246563"
|
||||
|
||||
[[package]]
|
||||
name = "wasm-encoder"
|
||||
version = "0.262.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4495a6f85dd94c411c749303efcbc5defade0b0cbdbc0541495241ab917a9b5a"
|
||||
dependencies = [
|
||||
"leb128fmt",
|
||||
"wasmparser",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "wasm-metadata"
|
||||
version = "0.262.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c86ff6668190d9fb70372b306b4f9fe8930f0e2f57ce72e4922bf2f117900949"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"indexmap",
|
||||
"wasm-encoder",
|
||||
"wasmparser",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "wasmparser"
|
||||
version = "0.262.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "974d643b125b272607e2fff8012ea14a8328acd7621e4bafa7afb32500052b1b"
|
||||
dependencies = [
|
||||
"bitflags",
|
||||
"hashbrown",
|
||||
"indexmap",
|
||||
"semver",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "wit-bindgen"
|
||||
version = "0.63.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b85a987ab61d365382d25c7d47e26edd48941b3bf6e3fbf76eff918bc71dab06"
|
||||
dependencies = [
|
||||
"bitflags",
|
||||
"wit-bindgen-rust-macro",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "wit-bindgen-core"
|
||||
version = "0.63.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "775e122e390603abfacd548027016cd0113a6e2bf2f8ce6bdd3658b013456ea8"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"heck",
|
||||
"wit-parser",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "wit-bindgen-rust"
|
||||
version = "0.63.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "84e26e13b9d972026778d2ffb7985736de116026fdc8d9464f966e12df2eb240"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"heck",
|
||||
"indexmap",
|
||||
"prettyplease",
|
||||
"syn",
|
||||
"wasm-metadata",
|
||||
"wit-bindgen-core",
|
||||
"wit-component",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "wit-bindgen-rust-macro"
|
||||
version = "0.63.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "16a008a0d6b4840677326beb4edbeb210a2f1b7d0183fb7cc33f466b90fd7fb6"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"macro-string",
|
||||
"prettyplease",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
"wit-bindgen-core",
|
||||
"wit-bindgen-rust",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "wit-component"
|
||||
version = "0.262.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "078def49fdb49cab405c3006e05793b3fdaf7069126ba6b9c97d01ec8c98fe4c"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"bitflags",
|
||||
"indexmap",
|
||||
"log",
|
||||
"serde",
|
||||
"serde_derive",
|
||||
"serde_json",
|
||||
"wasm-encoder",
|
||||
"wasm-metadata",
|
||||
"wasmparser",
|
||||
"wit-parser",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "wit-parser"
|
||||
version = "0.262.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "00f0dc051466ffe46787721fca3d088536f158ae400be044f1b1c386ba9397ad"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"hashbrown",
|
||||
"id-arena",
|
||||
"indexmap",
|
||||
"log",
|
||||
"semver",
|
||||
"serde",
|
||||
"serde_derive",
|
||||
"serde_json",
|
||||
"unicode-ident",
|
||||
"wasmparser",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "zmij"
|
||||
version = "1.0.23"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "29666d0abbfad1e3dc4dcf6144730dd3a3ab225bbbdac83319345b1b44ccfc1b"
|
||||
@@ -1,20 +0,0 @@
|
||||
[package]
|
||||
name = "openidea-test-lsp-requests"
|
||||
version = "0.1.0"
|
||||
edition = "2024"
|
||||
publish = false
|
||||
|
||||
[workspace]
|
||||
|
||||
[lib]
|
||||
crate-type = ["cdylib", "rlib"]
|
||||
|
||||
[dependencies]
|
||||
openidea-plugin = { path = "../../../../../sdk/rust/openidea-plugin" }
|
||||
|
||||
[profile.release]
|
||||
opt-level = "s"
|
||||
lto = true
|
||||
strip = true
|
||||
codegen-units = 1
|
||||
panic = "abort"
|
||||
Бінарний файл не відображається.
@@ -1 +0,0 @@
|
||||
4788f82b35966e155dbf51af520acb2d5e7773ddf9f36f4239b9bd51d51b0fb3
|
||||
@@ -1,24 +0,0 @@
|
||||
id = "test.lsp-requests"
|
||||
name = "Language server requests fixture"
|
||||
version = "0.1.0"
|
||||
engines.openidea = "^1.9"
|
||||
wasm = "dist/plugin.wasm"
|
||||
|
||||
[capabilities]
|
||||
optional = ["lsp:mock"]
|
||||
|
||||
[[contributes.commands]]
|
||||
id = "request"
|
||||
title = "Ask the mock server for its routes"
|
||||
|
||||
[[contributes.commands]]
|
||||
id = "notify"
|
||||
title = "Tell the mock server something changed"
|
||||
|
||||
[[contributes.commands]]
|
||||
id = "standard"
|
||||
title = "Send a method of LSP itself"
|
||||
|
||||
[[contributes.commands]]
|
||||
id = "ungranted"
|
||||
title = "Ask a server the manifest does not name"
|
||||
@@ -1,19 +0,0 @@
|
||||
use openidea_plugin::{Error, Invocation, Plugin, register_plugin};
|
||||
|
||||
#[derive(Default)]
|
||||
struct LspRequests;
|
||||
|
||||
impl Plugin for LspRequests {
|
||||
fn run_command(&mut self, id: &str, inv: &Invocation, arg: Option<&str>) -> Result<Option<String>, Error> {
|
||||
let project = inv.project().ok_or("no project")?;
|
||||
match id {
|
||||
"request" => project.language_server_request("mock", "mock/routes", arg).map(Some),
|
||||
"notify" => project.language_server_notify("mock", "mock/changed", arg).map(|()| None),
|
||||
"standard" => project.language_server_request("mock", "textDocument/hover", arg).map(Some),
|
||||
"ungranted" => project.language_server_request("other", "other/status", arg).map(Some),
|
||||
_ => Err(Error::NotFound(id.into())),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
register_plugin!(LspRequests);
|
||||
Бінарний файл не відображається.
@@ -1 +1 @@
|
||||
9b5d0e40e7fef9e48e1a894549e4b96853b8217ad7d12fe29d238a599772a329
|
||||
63b2f6007782c9d3498c86505a6c107b70f09d90678c79cf16c859ecbf349e70
|
||||
@@ -180,14 +180,8 @@ impl commands::Guest for Misbehave {
|
||||
env: Vec::new(),
|
||||
};
|
||||
let child = process::start(&cmd, None)?;
|
||||
// CPU work per step (loop iterations), for fuel budget tests.
|
||||
let work: u64 = arg.as_deref().and_then(|a| a.parse().ok()).unwrap_or(0);
|
||||
for step in 0..25 {
|
||||
task.report(step, Some(25), Some("waiting"));
|
||||
let mut x: u64 = 0;
|
||||
for _ in 0..work {
|
||||
x = std::hint::black_box(x.wrapping_add(1));
|
||||
}
|
||||
// Waiting blocks in the host for 100 ms: wall time passes
|
||||
// while the plugin itself is not running.
|
||||
let _ = child.wait(100);
|
||||
|
||||
Бінарний файл не відображається.
+1
-1
@@ -1 +1 @@
|
||||
a11bc7b7151a62e98d665a6459b3c84e4cb836b734fd23e7bad3adc533655f81
|
||||
3d1f2451dee8bba3cc874f497bcea909fa9bd58ae605dc1d74b4298b4b11ed94
|
||||
Бінарний файл не відображається.
+1
-1
@@ -1 +1 @@
|
||||
aad4871073c7c7f22ab84f1e7965d1a861b7e5ddd9f86408e95eba4c3c021411
|
||||
26a2b15b9354fa0ba2bf5934114bfdd20f7906c4a67497d013146cc6b3fc9643
|
||||
Бінарний файл не відображається.
+1
-1
@@ -1 +1 @@
|
||||
f2e0df07f6d7a501e96caf43efcfdaa0596aa2b9dad5c46ef71f5ad2eddc505b
|
||||
c9ef2cf7b6e8f3204f8ee382d7a381a5190b1e812e11d51bd1262c3d429a315f
|
||||
Бінарний файл не відображається.
+1
-1
@@ -1 +1 @@
|
||||
253f93d1254310669150f6fd629ae88223d7d6f1cd642803ec57382e5acd4451
|
||||
b07cc854c1302fd5bfd29fb3037732c7439efde606fc57295b2c0f94602a1077
|
||||
Бінарний файл не відображається.
@@ -1 +1 @@
|
||||
9351d3248252ca35a40ce557ada29e8aa4f3135273e988235bc22ebcfd0505ec
|
||||
12c4004f118070d0f37125ac32639ab9f332d59cc4585e74a8af61e3e6c5c1e8
|
||||
Бінарний файл не відображається.
@@ -1 +1 @@
|
||||
7f4ad5bc15d70de0ae7a0e96c584edcd6caef1cb18b5450685a83d8a8de16d24
|
||||
7517da988ab8cacaa3abf7645274a84e364de582ea9edf60a63926b1442d1581
|
||||
Бінарний файл не відображається.
@@ -1 +1 @@
|
||||
7d18591aa915fd6dd71fd8f8a4a0c7d8abb2cc5ff9252a56fb0d6b7458562466
|
||||
6e045ee3fcaa655bae773774e48e3eeb9d97ae9d8db1f52bf76c38459dcecb3f
|
||||
Бінарний файл не відображається.
+1
-1
@@ -1 +1 @@
|
||||
55e59a27457e8f25e9bd0e727ebbc6276b0f45d210732a88ede4954ec2dc777f
|
||||
69bb92e6e24e54458978a316c465d17b93d9ce9613cd26d7d6de9a1cef9b9447
|
||||
Бінарний файл не відображається.
@@ -1 +1 @@
|
||||
8ce7d4a12f8bd393b8b32e695d3dd2994c30ba27fb8419b8af900a550cb2da7c
|
||||
fc64a30e9d3b46275a6480641454b367b5082aea82da23a11b57106aa02387e1
|
||||
Бінарний файл не відображається.
@@ -1 +1 @@
|
||||
f654b73781d88c25dddddcdb25e8c02195b36dc9e008dd9eafafd632a11c48c5
|
||||
e6f3b5a4d81e62240fa1de4d1624b3706f145d47c014a1a2ed2b899cab24e0e4
|
||||
@@ -341,13 +341,11 @@ mod tests {
|
||||
{"lineNumber":41,"columnNumber":21,"source":{"path":"localhost꞉5173/src/App.vue","sourceReference":7}}]},
|
||||
{"locations":[{"lineNumber":10,"columnNumber":1,"source":{"path":"localhost꞉5173/","sourceReference":9}}]},
|
||||
{"locations":[]}]}}"#;
|
||||
let app = if cfg!(windows) { r"C:\work\shop\src\App.vue" } else { "/work/shop/src/App.vue" };
|
||||
let json = json.replace("\"/work/shop/src/App.vue\"", &serde_json::to_string(app).unwrap());
|
||||
let mut b = TreeBuilder::new();
|
||||
add_cpuprofile(&mut b, &json).unwrap();
|
||||
add_cpuprofile(&mut b, json).unwrap();
|
||||
let p = b.finish("node", "samples", ProfileMode::Cpu);
|
||||
let frame = |name: &str| p.frames.iter().find(|f| f.name == name).unwrap();
|
||||
assert_eq!(frame("increment").file.as_deref(), Some(Path::new(app)));
|
||||
assert_eq!(frame("increment").file.as_deref(), Some(Path::new("/work/shop/src/App.vue")));
|
||||
assert_eq!(frame("increment").line, Some(12));
|
||||
// No file on disk behind the frame: it stays without one.
|
||||
assert_eq!((frame("inline").file.as_deref(), frame("inline").line), (None, None));
|
||||
|
||||
@@ -2573,7 +2573,7 @@ fn a_member_without_python_falls_back_to_the_primary_project_interpreter() {
|
||||
assert_eq!(config.env["VIRTUAL_ENV"], outer.parent().unwrap().parent().unwrap().to_string_lossy());
|
||||
// Saving strips what settings derived, so the fallback keeps following settings.
|
||||
let stored = without_derived_in(&config, &bare, Some(&primary), &settings);
|
||||
assert_eq!(stored.command, "python", "the bare program, also on Windows");
|
||||
assert_eq!(stored.command, exe("python"));
|
||||
assert!(!stored.env.contains_key("VIRTUAL_ENV"));
|
||||
|
||||
// The member's explicit interpreter wins over the primary project's venv —
|
||||
|
||||
@@ -1119,8 +1119,7 @@ fn checkout_of_a_branch_held_by_another_worktree_reports_it_and_changes_nothing(
|
||||
fx.git(&["worktree", "add", "-q", "-b", "topic", linked.to_str().unwrap()]);
|
||||
let repo = fx.repo();
|
||||
let none = CheckoutOptions::default();
|
||||
// As git names it: no `\\?\` prefix on Windows.
|
||||
let linked_path = dunce::canonicalize(&linked).unwrap();
|
||||
let linked_path = std::fs::canonicalize(&linked).unwrap();
|
||||
|
||||
// From the main worktree, the branch the linked worktree has checked out.
|
||||
let outcome = repo.checkout_with("topic", false, &none).unwrap();
|
||||
@@ -1140,7 +1139,7 @@ fn checkout_of_a_branch_held_by_another_worktree_reports_it_and_changes_nothing(
|
||||
let linked_repo = Repo::discover(&linked).unwrap().unwrap();
|
||||
linked_repo.set_execution_allowed(true);
|
||||
let outcome = linked_repo.checkout_with("main", false, &none).unwrap();
|
||||
let main_path = dunce::canonicalize(&fx.dir).unwrap();
|
||||
let main_path = std::fs::canonicalize(&fx.dir).unwrap();
|
||||
assert_eq!(outcome, CheckoutOutcome::CheckedOutInWorktree { branch: "main".into(), path: main_path });
|
||||
assert_eq!(linked_repo.branch_info().unwrap().head.as_deref(), Some("topic"));
|
||||
|
||||
|
||||
@@ -147,19 +147,6 @@ fn read_layer(file: &Path) -> Option<Json> {
|
||||
}
|
||||
}
|
||||
|
||||
/// The first appearance theme key of `file` naming a removed theme, if any. Plugin themes
|
||||
/// (`plugin:<id>/<theme>`) carry their plugin's id, so a plain id can only be a built-in's.
|
||||
fn removed_theme_in(file: &Path) -> Option<String> {
|
||||
const KEYS: [&str; 3] = ["theme", "preferredLightTheme", "preferredDarkTheme"];
|
||||
let layer = read_layer(file)?;
|
||||
KEYS.iter()
|
||||
.filter_map(|key| match layer.pointer(&format!("/appearance/{key}"))? {
|
||||
Json::String(id) => Some(id.clone()),
|
||||
_ => None,
|
||||
})
|
||||
.find(|id| ide_core::settings::REMOVED_THEMES.iter().any(|(removed, _)| id.as_str() == *removed))
|
||||
}
|
||||
|
||||
/// Merges `layer` onto `merged` if the result still deserializes.
|
||||
fn try_merge(merged: &mut Json, layer: Json) -> Result<(), String> {
|
||||
// Migrate the legacy boolean every layer carries it, before it can clobber
|
||||
@@ -277,13 +264,6 @@ impl SettingsStore {
|
||||
.collect()
|
||||
}
|
||||
|
||||
/// The removed built-in theme id (`REMOVED_THEMES`) a settings file still names, if any.
|
||||
/// `Settings` reports its stand-in, so this reads the files again: it is what a settings
|
||||
/// file named, not what the theme rows show now.
|
||||
pub fn named_removed_theme(&self) -> Option<String> {
|
||||
self.layers().into_iter().rev().find_map(|(_, file)| removed_theme_in(&file))
|
||||
}
|
||||
|
||||
fn compute(&self) -> Settings {
|
||||
let mut merged = defaults_json();
|
||||
for (scope, file) in self.layers() {
|
||||
@@ -545,30 +525,6 @@ mod tests {
|
||||
use super::*;
|
||||
use serde_json::json;
|
||||
|
||||
#[test]
|
||||
fn removed_theme_named_in_a_settings_file_is_reported_for_the_notice() {
|
||||
let tmp = tempfile::tempdir().unwrap();
|
||||
let cfg = tmp.path().join("cfg");
|
||||
let proj = tmp.path().join("proj");
|
||||
std::fs::create_dir_all(&cfg).unwrap();
|
||||
std::fs::create_dir_all(proj.join(".openidea")).unwrap();
|
||||
// Nothing to report without a removed id.
|
||||
std::fs::write(cfg.join("settings.toml"), "[appearance]\ntheme = \"dark\"\n").unwrap();
|
||||
assert_eq!(SettingsStore::load(&cfg, Some(&proj)).named_removed_theme(), None);
|
||||
// The theme the notice is about, and the light one for good measure.
|
||||
std::fs::write(cfg.join("settings.toml"), "[appearance]\ntheme = \"one-dark\"\n").unwrap();
|
||||
assert_eq!(SettingsStore::load(&cfg, Some(&proj)).named_removed_theme().as_deref(), Some("one-dark"));
|
||||
std::fs::write(
|
||||
cfg.join("settings.toml"),
|
||||
"[appearance]\npreferredDarkTheme = \"one-dark\"\ntheme = \"plugin:acme.themes/night\"\n",
|
||||
)
|
||||
.unwrap();
|
||||
assert_eq!(SettingsStore::load(&cfg, Some(&proj)).named_removed_theme().as_deref(), Some("one-dark"));
|
||||
// A project layer naming it wins over the global one.
|
||||
std::fs::write(proj.join(".openidea/settings.toml"), "[appearance]\ntheme = \"one-light\"\n").unwrap();
|
||||
assert_eq!(SettingsStore::load(&cfg, Some(&proj)).named_removed_theme().as_deref(), Some("one-light"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn compose_file_choices_are_project_settings_and_survive_reload() {
|
||||
let tmp = tempfile::tempdir().unwrap();
|
||||
|
||||
@@ -20,38 +20,37 @@ The plugin API is the WIT package `openidea:[email protected]` in [`wit/`](https://gi
|
||||
|
||||
The plugin calls these. Most are gated by a [capability](/en/plugins/capabilities).
|
||||
|
||||
| Interface | File | Summary |
|
||||
| ------------------ | ------------------------------------------------------------------------------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| `types` | [types.wit](https://github.com/l0ng-ai/openidea/blob/main/wit/types.wit) | Shared types: positions (0-based lines, UTF-16 columns), ranges, errors, the `extension` carrier for later additions |
|
||||
| `log` | [host.wit](https://github.com/l0ng-ai/openidea/blob/main/wit/host.wit) | Writes to the IDE log, tagged with the plugin id |
|
||||
| `ui` | [host.wit](https://github.com/l0ng-ai/openidea/blob/main/wit/host.wit) | Notifications (also for one project, API 1.5), status bar items, context keys, pickers, input boxes, confirmations, folder chooser, clipboard, opening URLs, the UI language |
|
||||
| `storage` | [host.wit](https://github.com/l0ng-ai/openidea/blob/main/wit/host.wit) | The plugin's persistent key-value storage (64 MiB) |
|
||||
| `command-runner` | [host.wit](https://github.com/l0ng-ai/openidea/blob/main/wit/host.wit) | Runs IDE actions and other plugins' commands (API 1.4, `ide.commands`) |
|
||||
| `language-servers` | [host.wit](https://github.com/l0ng-ai/openidea/blob/main/wit/host.wit) | Requests and notifications to a running language server, its own methods only (API 1.9, `lsp:<server>`) |
|
||||
| `output` | [host.wit](https://github.com/l0ng-ai/openidea/blob/main/wit/host.wit) | Named, read-only Output tabs per plugin (API 1.4) |
|
||||
| `workspace` | [workspace.wit](https://github.com/l0ng-ai/openidea/blob/main/wit/workspace.wit) | Open projects: reading, writing, finding and searching files, symbols, the project of a path, opening a project |
|
||||
| `editor` | [workspace.wit](https://github.com/l0ng-ai/openidea/blob/main/wit/workspace.wit) | Text editors: document, selections, versioned edits, reveal; open editors and opening files |
|
||||
| `invocation` | [workspace.wit](https://github.com/l0ng-ai/openidea/blob/main/wit/workspace.wit) | Where a command or event came from: its project, editor and selected paths |
|
||||
| `vcs` | [workspace.wit](https://github.com/l0ng-ai/openidea/blob/main/wit/workspace.wit) | Git for a project's repository: status, remotes, fetch, log, blame, diff |
|
||||
| `fs` | [fs.wit](https://github.com/l0ng-ai/openidea/blob/main/wit/fs.wit) | Files outside the open projects (`fs.read:` / `fs.write:`) and the plugin's private directory |
|
||||
| `decorations` | [decorations.wit](https://github.com/l0ng-ai/openidea/blob/main/wit/decorations.wit) | Editor annotations and project-tree badges (API 1.4) |
|
||||
| `commit` | [commit.wit](https://github.com/l0ng-ai/openidea/blob/main/wit/commit.wit) | The commit being prepared and its message |
|
||||
| `events` | [events.wit](https://github.com/l0ng-ai/openidea/blob/main/wit/events.wit) | Subscribing to workbench events, optionally filtered by path |
|
||||
| `tasks` | [events.wit](https://github.com/l0ng-ai/openidea/blob/main/wit/events.wit) | Long-running work with a progress indicator and a longer time budget |
|
||||
| `diagnostics` | [io.wit](https://github.com/l0ng-ai/openidea/blob/main/wit/io.wit) | Publishing problems for files and reading the Problems view |
|
||||
| `net` | [io.wit](https://github.com/l0ng-ai/openidea/blob/main/wit/io.wit) | HTTP(S) requests (`net:` / `net.http:` / `net:ask`) |
|
||||
| `secrets` | [io.wit](https://github.com/l0ng-ai/openidea/blob/main/wit/io.wit) | Secrets in the OS keychain, used only through `{{secret:<name>}}` in requests |
|
||||
| `process` | [io.wit](https://github.com/l0ng-ai/openidea/blob/main/wit/io.wit) | Running approved programs once, with an environment, or behind a handle |
|
||||
| `ipc` | [io.wit](https://github.com/l0ng-ai/openidea/blob/main/wit/io.wit) | Local sockets and named pipes on the project machine (API 1.4) |
|
||||
| `auth` | [io.wit](https://github.com/l0ng-ai/openidea/blob/main/wit/io.wit) | OAuth loopback redirects received on the desktop (API 1.4) |
|
||||
| `views` | [views.wit](https://github.com/l0ng-ai/openidea/blob/main/wit/views.wit) | Refreshing and revealing views, messages to web views, terminals, content tabs, opening locations |
|
||||
| `view-types` | [views.wit](https://github.com/l0ng-ai/openidea/blob/main/wit/views.wit) | The declarative view model: trees, lists, forms, tables, messages, `html` bodies, view events |
|
||||
| `settings` | [views.wit](https://github.com/l0ng-ai/openidea/blob/main/wit/views.wit) | The plugin's own settings, project over global, or the schema default |
|
||||
| `run` | [run.wit](https://github.com/l0ng-ai/openidea/blob/main/wit/run.wit) | Starting the plugin's run configurations in the Run tool window (API 1.4) |
|
||||
| `run-targets` | [run-targets.wit](https://github.com/l0ng-ai/openidea/blob/main/wit/run-targets.wit) | Project run targets that wrap commands, owned by the plugin (API 1.4) |
|
||||
| `database` | [database.wit](https://github.com/l0ng-ai/openidea/blob/main/wit/database.wit) | The plugin's own project data sources and their credentials (API 1.4) |
|
||||
| `mcp` | [mcp.wit](https://github.com/l0ng-ai/openidea/blob/main/wit/mcp.wit) | The command line of the built-in MCP server's stdio bridge, never its URL or token (API 1.4) |
|
||||
| `detail-types` | [details.wit](https://github.com/l0ng-ai/openidea/blob/main/wit/details.wit) | What the pane beside the Services tree shows for a plugin's node |
|
||||
| Interface | File | Summary |
|
||||
| ---------------- | ------------------------------------------------------------------------------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| `types` | [types.wit](https://github.com/l0ng-ai/openidea/blob/main/wit/types.wit) | Shared types: positions (0-based lines, UTF-16 columns), ranges, errors, the `extension` carrier for later additions |
|
||||
| `log` | [host.wit](https://github.com/l0ng-ai/openidea/blob/main/wit/host.wit) | Writes to the IDE log, tagged with the plugin id |
|
||||
| `ui` | [host.wit](https://github.com/l0ng-ai/openidea/blob/main/wit/host.wit) | Notifications (also for one project, API 1.5), status bar items, context keys, pickers, input boxes, confirmations, folder chooser, clipboard, opening URLs, the UI language |
|
||||
| `storage` | [host.wit](https://github.com/l0ng-ai/openidea/blob/main/wit/host.wit) | The plugin's persistent key-value storage (64 MiB) |
|
||||
| `command-runner` | [host.wit](https://github.com/l0ng-ai/openidea/blob/main/wit/host.wit) | Runs IDE actions and other plugins' commands (API 1.4, `ide.commands`) |
|
||||
| `output` | [host.wit](https://github.com/l0ng-ai/openidea/blob/main/wit/host.wit) | Named, read-only Output tabs per plugin (API 1.4) |
|
||||
| `workspace` | [workspace.wit](https://github.com/l0ng-ai/openidea/blob/main/wit/workspace.wit) | Open projects: reading, writing, finding and searching files, symbols, the project of a path, opening a project |
|
||||
| `editor` | [workspace.wit](https://github.com/l0ng-ai/openidea/blob/main/wit/workspace.wit) | Text editors: document, selections, versioned edits, reveal; open editors and opening files |
|
||||
| `invocation` | [workspace.wit](https://github.com/l0ng-ai/openidea/blob/main/wit/workspace.wit) | Where a command or event came from: its project, editor and selected paths |
|
||||
| `vcs` | [workspace.wit](https://github.com/l0ng-ai/openidea/blob/main/wit/workspace.wit) | Git for a project's repository: status, remotes, fetch, log, blame, diff |
|
||||
| `fs` | [fs.wit](https://github.com/l0ng-ai/openidea/blob/main/wit/fs.wit) | Files outside the open projects (`fs.read:` / `fs.write:`) and the plugin's private directory |
|
||||
| `decorations` | [decorations.wit](https://github.com/l0ng-ai/openidea/blob/main/wit/decorations.wit) | Editor annotations and project-tree badges (API 1.4) |
|
||||
| `commit` | [commit.wit](https://github.com/l0ng-ai/openidea/blob/main/wit/commit.wit) | The commit being prepared and its message |
|
||||
| `events` | [events.wit](https://github.com/l0ng-ai/openidea/blob/main/wit/events.wit) | Subscribing to workbench events, optionally filtered by path |
|
||||
| `tasks` | [events.wit](https://github.com/l0ng-ai/openidea/blob/main/wit/events.wit) | Long-running work with a progress indicator and a longer time budget |
|
||||
| `diagnostics` | [io.wit](https://github.com/l0ng-ai/openidea/blob/main/wit/io.wit) | Publishing problems for files and reading the Problems view |
|
||||
| `net` | [io.wit](https://github.com/l0ng-ai/openidea/blob/main/wit/io.wit) | HTTP(S) requests (`net:` / `net.http:` / `net:ask`) |
|
||||
| `secrets` | [io.wit](https://github.com/l0ng-ai/openidea/blob/main/wit/io.wit) | Secrets in the OS keychain, used only through `{{secret:<name>}}` in requests |
|
||||
| `process` | [io.wit](https://github.com/l0ng-ai/openidea/blob/main/wit/io.wit) | Running approved programs once, with an environment, or behind a handle |
|
||||
| `ipc` | [io.wit](https://github.com/l0ng-ai/openidea/blob/main/wit/io.wit) | Local sockets and named pipes on the project machine (API 1.4) |
|
||||
| `auth` | [io.wit](https://github.com/l0ng-ai/openidea/blob/main/wit/io.wit) | OAuth loopback redirects received on the desktop (API 1.4) |
|
||||
| `views` | [views.wit](https://github.com/l0ng-ai/openidea/blob/main/wit/views.wit) | Refreshing and revealing views, messages to web views, terminals, content tabs, opening locations |
|
||||
| `view-types` | [views.wit](https://github.com/l0ng-ai/openidea/blob/main/wit/views.wit) | The declarative view model: trees, lists, forms, tables, messages, `html` bodies, view events |
|
||||
| `settings` | [views.wit](https://github.com/l0ng-ai/openidea/blob/main/wit/views.wit) | The plugin's own settings, project over global, or the schema default |
|
||||
| `run` | [run.wit](https://github.com/l0ng-ai/openidea/blob/main/wit/run.wit) | Starting the plugin's run configurations in the Run tool window (API 1.4) |
|
||||
| `run-targets` | [run-targets.wit](https://github.com/l0ng-ai/openidea/blob/main/wit/run-targets.wit) | Project run targets that wrap commands, owned by the plugin (API 1.4) |
|
||||
| `database` | [database.wit](https://github.com/l0ng-ai/openidea/blob/main/wit/database.wit) | The plugin's own project data sources and their credentials (API 1.4) |
|
||||
| `mcp` | [mcp.wit](https://github.com/l0ng-ai/openidea/blob/main/wit/mcp.wit) | The command line of the built-in MCP server's stdio bridge, never its URL or token (API 1.4) |
|
||||
| `detail-types` | [details.wit](https://github.com/l0ng-ai/openidea/blob/main/wit/details.wit) | What the pane beside the Services tree shows for a plugin's node |
|
||||
|
||||
## Plugin interfaces (exports)
|
||||
|
||||
|
||||
@@ -51,7 +51,6 @@ Later:
|
||||
| `fs.read:<path>` | High | `host::fs` reads outside the projects, under that path | 1.0 (the `fs` interface: 1.3) |
|
||||
| `fs.write:<path>` | High | `host::fs` writes outside the projects, under that path; does not imply reading | 1.3 |
|
||||
| `process:<program>` | High | Run that program: `run_process`, `run_command`, `start`, terminals, language servers, debug adapters, runs | 1.0 |
|
||||
| `lsp:<server>` | High | Send that running language server its own requests (`language_server_request`); trusted projects only | 1.9 |
|
||||
| `ipc:<path>` | High | Local Unix sockets or Windows named pipes on the project machine | 1.4 |
|
||||
| `ide.commands` | High | Run any IDE action or another plugin's command as if the user chose it, including running programs, committing and pushing. The plugin's own commands are exempt. | 1.4 |
|
||||
|
||||
|
||||
@@ -20,38 +20,37 @@ description: "openidea:plugin WIT 包中的每个 interface:一句话说明及
|
||||
|
||||
由插件调用,大多受某个[能力](/zh/plugins/capabilities)约束。
|
||||
|
||||
| Interface | 文件 | 说明 |
|
||||
| ------------------ | ------------------------------------------------------------------------------------ | ---------------------------------------------------------------------------------------------------------------------- |
|
||||
| `types` | [types.wit](https://github.com/l0ng-ai/openidea/blob/main/wit/types.wit) | 共享类型:位置(从 0 开始的行号、UTF-16 列)、范围、错误,以及承载后续新增内容的 `extension` |
|
||||
| `log` | [host.wit](https://github.com/l0ng-ai/openidea/blob/main/wit/host.wit) | 写入 IDE 日志,标上插件 id |
|
||||
| `ui` | [host.wit](https://github.com/l0ng-ai/openidea/blob/main/wit/host.wit) | 通知(API 1.5 起可只发给某个项目)、状态栏项、上下文键、选择器、输入框、确认框、文件夹选择、剪贴板、打开 URL、界面语言 |
|
||||
| `storage` | [host.wit](https://github.com/l0ng-ai/openidea/blob/main/wit/host.wit) | 插件的持久键值存储(64 MiB) |
|
||||
| `command-runner` | [host.wit](https://github.com/l0ng-ai/openidea/blob/main/wit/host.wit) | 运行 IDE 操作和其他插件的命令(API 1.4,`ide.commands`) |
|
||||
| `language-servers` | [host.wit](https://github.com/l0ng-ai/openidea/blob/main/wit/host.wit) | 向正在运行的语言服务器发送请求和通知,仅限服务器自己的方法(API 1.9,`lsp:<server>`) |
|
||||
| `output` | [host.wit](https://github.com/l0ng-ai/openidea/blob/main/wit/host.wit) | 每个插件的具名只读 输出 标签页(API 1.4) |
|
||||
| `workspace` | [workspace.wit](https://github.com/l0ng-ai/openidea/blob/main/wit/workspace.wit) | 打开的项目:读写、查找和搜索文件,符号,路径所属项目,打开项目 |
|
||||
| `editor` | [workspace.wit](https://github.com/l0ng-ai/openidea/blob/main/wit/workspace.wit) | 文本编辑器:文档、选区、带版本号的编辑、滚动定位;已打开的编辑器和打开文件 |
|
||||
| `invocation` | [workspace.wit](https://github.com/l0ng-ai/openidea/blob/main/wit/workspace.wit) | 命令或事件的来源:所在项目、编辑器和选中的路径 |
|
||||
| `vcs` | [workspace.wit](https://github.com/l0ng-ai/openidea/blob/main/wit/workspace.wit) | 项目所在仓库的 Git:状态、远程、fetch、log、blame、diff |
|
||||
| `fs` | [fs.wit](https://github.com/l0ng-ai/openidea/blob/main/wit/fs.wit) | 打开的项目以外的文件(`fs.read:` / `fs.write:`),以及插件私有目录 |
|
||||
| `decorations` | [decorations.wit](https://github.com/l0ng-ai/openidea/blob/main/wit/decorations.wit) | 编辑器标注和项目树徽标(API 1.4) |
|
||||
| `commit` | [commit.wit](https://github.com/l0ng-ai/openidea/blob/main/wit/commit.wit) | 正在准备的提交及其提交信息 |
|
||||
| `events` | [events.wit](https://github.com/l0ng-ai/openidea/blob/main/wit/events.wit) | 订阅工作台事件,可按路径过滤 |
|
||||
| `tasks` | [events.wit](https://github.com/l0ng-ai/openidea/blob/main/wit/events.wit) | 带进度指示、时间预算更长的后台工作 |
|
||||
| `diagnostics` | [io.wit](https://github.com/l0ng-ai/openidea/blob/main/wit/io.wit) | 为文件发布问题,读取 问题 视图 |
|
||||
| `net` | [io.wit](https://github.com/l0ng-ai/openidea/blob/main/wit/io.wit) | HTTP(S) 请求(`net:` / `net.http:` / `net:ask`) |
|
||||
| `secrets` | [io.wit](https://github.com/l0ng-ai/openidea/blob/main/wit/io.wit) | 系统钥匙串中的密钥,只能通过请求中的 `{{secret:<name>}}` 使用 |
|
||||
| `process` | [io.wit](https://github.com/l0ng-ai/openidea/blob/main/wit/io.wit) | 运行已批准的程序:一次性运行、带环境变量运行,或通过句柄保持运行 |
|
||||
| `ipc` | [io.wit](https://github.com/l0ng-ai/openidea/blob/main/wit/io.wit) | 项目所在机器上的本地套接字和命名管道(API 1.4) |
|
||||
| `auth` | [io.wit](https://github.com/l0ng-ai/openidea/blob/main/wit/io.wit) | 在桌面端接收 OAuth 回环重定向(API 1.4) |
|
||||
| `views` | [views.wit](https://github.com/l0ng-ai/openidea/blob/main/wit/views.wit) | 刷新和显示视图、向 Web 视图发消息、终端、内容标签页、打开位置 |
|
||||
| `view-types` | [views.wit](https://github.com/l0ng-ai/openidea/blob/main/wit/views.wit) | 声明式视图模型:树、列表、表单、表格、消息、`html` 内容、视图事件 |
|
||||
| `settings` | [views.wit](https://github.com/l0ng-ai/openidea/blob/main/wit/views.wit) | 插件自己的设置,项目优先于全局,或 schema 默认值 |
|
||||
| `run` | [run.wit](https://github.com/l0ng-ai/openidea/blob/main/wit/run.wit) | 在 运行 工具窗口中启动插件的运行配置(API 1.4) |
|
||||
| `run-targets` | [run-targets.wit](https://github.com/l0ng-ai/openidea/blob/main/wit/run-targets.wit) | 插件拥有的、包装命令的项目运行目标(API 1.4) |
|
||||
| `database` | [database.wit](https://github.com/l0ng-ai/openidea/blob/main/wit/database.wit) | 插件自己的项目数据源及其凭据(API 1.4) |
|
||||
| `mcp` | [mcp.wit](https://github.com/l0ng-ai/openidea/blob/main/wit/mcp.wit) | 内置 MCP 服务器 stdio 桥接的命令行,从不暴露其 URL 或 token(API 1.4) |
|
||||
| `detail-types` | [details.wit](https://github.com/l0ng-ai/openidea/blob/main/wit/details.wit) | Services 树旁边的面板为插件节点显示的内容 |
|
||||
| Interface | 文件 | 说明 |
|
||||
| ---------------- | ------------------------------------------------------------------------------------ | ---------------------------------------------------------------------------------------------------------------------- |
|
||||
| `types` | [types.wit](https://github.com/l0ng-ai/openidea/blob/main/wit/types.wit) | 共享类型:位置(从 0 开始的行号、UTF-16 列)、范围、错误,以及承载后续新增内容的 `extension` |
|
||||
| `log` | [host.wit](https://github.com/l0ng-ai/openidea/blob/main/wit/host.wit) | 写入 IDE 日志,标上插件 id |
|
||||
| `ui` | [host.wit](https://github.com/l0ng-ai/openidea/blob/main/wit/host.wit) | 通知(API 1.5 起可只发给某个项目)、状态栏项、上下文键、选择器、输入框、确认框、文件夹选择、剪贴板、打开 URL、界面语言 |
|
||||
| `storage` | [host.wit](https://github.com/l0ng-ai/openidea/blob/main/wit/host.wit) | 插件的持久键值存储(64 MiB) |
|
||||
| `command-runner` | [host.wit](https://github.com/l0ng-ai/openidea/blob/main/wit/host.wit) | 运行 IDE 操作和其他插件的命令(API 1.4,`ide.commands`) |
|
||||
| `output` | [host.wit](https://github.com/l0ng-ai/openidea/blob/main/wit/host.wit) | 每个插件的具名只读 输出 标签页(API 1.4) |
|
||||
| `workspace` | [workspace.wit](https://github.com/l0ng-ai/openidea/blob/main/wit/workspace.wit) | 打开的项目:读写、查找和搜索文件,符号,路径所属项目,打开项目 |
|
||||
| `editor` | [workspace.wit](https://github.com/l0ng-ai/openidea/blob/main/wit/workspace.wit) | 文本编辑器:文档、选区、带版本号的编辑、滚动定位;已打开的编辑器和打开文件 |
|
||||
| `invocation` | [workspace.wit](https://github.com/l0ng-ai/openidea/blob/main/wit/workspace.wit) | 命令或事件的来源:所在项目、编辑器和选中的路径 |
|
||||
| `vcs` | [workspace.wit](https://github.com/l0ng-ai/openidea/blob/main/wit/workspace.wit) | 项目所在仓库的 Git:状态、远程、fetch、log、blame、diff |
|
||||
| `fs` | [fs.wit](https://github.com/l0ng-ai/openidea/blob/main/wit/fs.wit) | 打开的项目以外的文件(`fs.read:` / `fs.write:`),以及插件私有目录 |
|
||||
| `decorations` | [decorations.wit](https://github.com/l0ng-ai/openidea/blob/main/wit/decorations.wit) | 编辑器标注和项目树徽标(API 1.4) |
|
||||
| `commit` | [commit.wit](https://github.com/l0ng-ai/openidea/blob/main/wit/commit.wit) | 正在准备的提交及其提交信息 |
|
||||
| `events` | [events.wit](https://github.com/l0ng-ai/openidea/blob/main/wit/events.wit) | 订阅工作台事件,可按路径过滤 |
|
||||
| `tasks` | [events.wit](https://github.com/l0ng-ai/openidea/blob/main/wit/events.wit) | 带进度指示、时间预算更长的后台工作 |
|
||||
| `diagnostics` | [io.wit](https://github.com/l0ng-ai/openidea/blob/main/wit/io.wit) | 为文件发布问题,读取 问题 视图 |
|
||||
| `net` | [io.wit](https://github.com/l0ng-ai/openidea/blob/main/wit/io.wit) | HTTP(S) 请求(`net:` / `net.http:` / `net:ask`) |
|
||||
| `secrets` | [io.wit](https://github.com/l0ng-ai/openidea/blob/main/wit/io.wit) | 系统钥匙串中的密钥,只能通过请求中的 `{{secret:<name>}}` 使用 |
|
||||
| `process` | [io.wit](https://github.com/l0ng-ai/openidea/blob/main/wit/io.wit) | 运行已批准的程序:一次性运行、带环境变量运行,或通过句柄保持运行 |
|
||||
| `ipc` | [io.wit](https://github.com/l0ng-ai/openidea/blob/main/wit/io.wit) | 项目所在机器上的本地套接字和命名管道(API 1.4) |
|
||||
| `auth` | [io.wit](https://github.com/l0ng-ai/openidea/blob/main/wit/io.wit) | 在桌面端接收 OAuth 回环重定向(API 1.4) |
|
||||
| `views` | [views.wit](https://github.com/l0ng-ai/openidea/blob/main/wit/views.wit) | 刷新和显示视图、向 Web 视图发消息、终端、内容标签页、打开位置 |
|
||||
| `view-types` | [views.wit](https://github.com/l0ng-ai/openidea/blob/main/wit/views.wit) | 声明式视图模型:树、列表、表单、表格、消息、`html` 内容、视图事件 |
|
||||
| `settings` | [views.wit](https://github.com/l0ng-ai/openidea/blob/main/wit/views.wit) | 插件自己的设置,项目优先于全局,或 schema 默认值 |
|
||||
| `run` | [run.wit](https://github.com/l0ng-ai/openidea/blob/main/wit/run.wit) | 在 运行 工具窗口中启动插件的运行配置(API 1.4) |
|
||||
| `run-targets` | [run-targets.wit](https://github.com/l0ng-ai/openidea/blob/main/wit/run-targets.wit) | 插件拥有的、包装命令的项目运行目标(API 1.4) |
|
||||
| `database` | [database.wit](https://github.com/l0ng-ai/openidea/blob/main/wit/database.wit) | 插件自己的项目数据源及其凭据(API 1.4) |
|
||||
| `mcp` | [mcp.wit](https://github.com/l0ng-ai/openidea/blob/main/wit/mcp.wit) | 内置 MCP 服务器 stdio 桥接的命令行,从不暴露其 URL 或 token(API 1.4) |
|
||||
| `detail-types` | [details.wit](https://github.com/l0ng-ai/openidea/blob/main/wit/details.wit) | Services 树旁边的面板为插件节点显示的内容 |
|
||||
|
||||
## 插件 interface(导出)
|
||||
|
||||
|
||||
@@ -51,7 +51,6 @@ optional = ["net:api.example.com", "secrets"]
|
||||
| `fs.read:<path>` | 高 | 通过 `host::fs` 读取项目外、该路径下的文件 | 1.0(`fs` interface:1.3) |
|
||||
| `fs.write:<path>` | 高 | 通过 `host::fs` 写入项目外、该路径下的文件;不包含读权限 | 1.3 |
|
||||
| `process:<program>` | 高 | 运行该程序:`run_process`、`run_command`、`start`、终端、语言服务器、调试适配器、运行配置 | 1.0 |
|
||||
| `lsp:<server>` | 高 | 向正在运行的该语言服务器发送它自己的请求(`language_server_request`);仅限受信任的项目 | 1.9 |
|
||||
| `ipc:<path>` | 高 | 项目所在机器上的本地 Unix 套接字或 Windows 命名管道 | 1.4 |
|
||||
| `ide.commands` | 高 | 像用户亲自选择一样运行任意 IDE 操作或其他插件的命令,包括运行程序、提交和推送。插件自己的命令不受此限制。 | 1.4 |
|
||||
|
||||
|
||||
@@ -255,8 +255,7 @@ async function selectDraft(page: Page) {
|
||||
}
|
||||
async function chooseModel(page: Page, name: string) {
|
||||
await modelButton(page).click();
|
||||
// A model row also holds its Configure button, whose label joins the option's name.
|
||||
await page.getByRole("option", { name: new RegExp(`^${name}\\b`) }).click();
|
||||
await page.getByRole("option", { name, exact: true }).click();
|
||||
await page.keyboard.press("Escape");
|
||||
await box(page).focus();
|
||||
}
|
||||
@@ -364,11 +363,9 @@ test("Settings and model popup exclude the agent shortcut", async ({ workbench:
|
||||
await modelButton(page).click();
|
||||
const popup = page.getByRole("dialog", { name: "Model & effort settings", exact: true });
|
||||
await expect(popup).toBeVisible();
|
||||
await popup.getByRole("button", { name: "Configure model", exact: true }).click();
|
||||
const gentle = popup.getByRole("radio", { name: "Gentle", exact: true });
|
||||
await gentle.focus();
|
||||
await popup.getByRole("slider", { name: "Reasoning" }).focus();
|
||||
await page.keyboard.press("Alt+t");
|
||||
await expect(gentle).toHaveAttribute("aria-checked", "true");
|
||||
await expect(popup.getByRole("slider", { name: "Reasoning" })).toHaveAttribute("aria-valuetext", "Gentle");
|
||||
expect(await ipcCalls(page, "agent_set_config")).toEqual([]);
|
||||
await page.keyboard.press("Escape");
|
||||
await expectEffort(page, "Gentle");
|
||||
|
||||
@@ -356,7 +356,6 @@ machine. Users can revoke optional capabilities in Settings › Plugins.
|
||||
| `events` | low | file opened/saved, editor focused, repository changed events |
|
||||
| `events.input` | medium | `action-performed` and `input-mode-changed` events |
|
||||
| `process:<program>` | high | `Project::run_process`, language servers, debug adapters, runs |
|
||||
| `lsp:<server>` | high | API 1.9: `Project::language_server_request` / `language_server_notify` to that running language server (its name in the language definition); trusted projects only |
|
||||
| `net:<host>` | medium | `host::fetch` over HTTPS (also loopback HTTP); `*.example.com` matches subdomains |
|
||||
| `net:ask` | medium | Ask the user at the first request to an HTTPS (or loopback) host that is not declared; one answer per host, revocable; API 1.5 |
|
||||
| `net.http:<host>` | medium | Unencrypted HTTP to that host; API 1.4, same wildcard rules as `net:` |
|
||||
@@ -432,10 +431,6 @@ matching SDK. Released 1.8 plugins keep working. New in 1.9:
|
||||
(Debug runs the configuration and attaches to a process the run starts). See
|
||||
_Environment and debugger_ under _Runs, terminal sessions and test results_.
|
||||
|
||||
- **Requests to a language server.** `Project::language_server_request` and
|
||||
`language_server_notify` send a running server its own methods, behind the
|
||||
high-risk `lsp:<server>` capability. See _Requests to a language server_.
|
||||
|
||||
### API 1.8
|
||||
|
||||
API 1.8.0 shipped with OpenIDEA 0.1.45. Use `engines.openidea = "^1.8"` and the
|
||||
@@ -742,49 +737,6 @@ adds the two ways to the bytes:
|
||||
let bytes = project.read_bytes(&doc.path)?; // the PDF's exact bytes
|
||||
```
|
||||
|
||||
### Requests to a language server (API 1.9)
|
||||
|
||||
A plugin can ask a language server the IDE already runs for the server's own
|
||||
data: `rust-analyzer/expandMacro`, a framework server's route list. Declare
|
||||
`lsp:<server>` (high risk: the server reads and changes the project's files on
|
||||
the plugin's behalf), where `<server>` is the `name` of the
|
||||
`[[language-servers]]` entry in the language definition:
|
||||
|
||||
```toml
|
||||
engines.openidea = "^1.9"
|
||||
|
||||
[capabilities]
|
||||
required = ["lsp:phoxite"]
|
||||
```
|
||||
|
||||
```rust
|
||||
let project = inv.project().ok_or("no project")?;
|
||||
let routes = project.language_server_request("phoxite", "phoxite/laravel/routes", Some("{}"))?; // JSON
|
||||
project.language_server_notify("phoxite", "phoxite/refresh", None)?;
|
||||
```
|
||||
|
||||
| SDK | WIT | Notes |
|
||||
| ---------------------------------------------------------- | -------------------------------------- | -------------------------------------------- |
|
||||
| `Project::language_server_request(server, method, params)` | `language-servers.request(project, …)` | The result as JSON; `params` is JSON or none |
|
||||
| `Project::language_server_notify(server, method, params)` | `language-servers.notify(project, …)` | No answer is awaited |
|
||||
|
||||
- Only the server's own methods pass. `initialize`, `initialized`, `shutdown`,
|
||||
`exit`, anything starting with `$/` and any method whose first segment is an
|
||||
LSP namespace (`textDocument`, `workspace`, `window`, `notebookDocument`,
|
||||
`callHierarchy`, `typeHierarchy`, `completionItem`, `codeAction`, `codeLens`,
|
||||
`documentLink`, `inlayHint`, `workspaceSymbol`, `client`, `telemetry`) are
|
||||
`invalid`: a plugin can't touch document sync, the features the IDE asks for
|
||||
itself or the server's lifecycle.
|
||||
- The call never starts a server: one that is not running for the project is
|
||||
`not-found`. The server's own error is `failed` with its message.
|
||||
- The request ends with the invocation's cancellation and time budget. A method
|
||||
is at most 256 bytes, params at most 1 MiB.
|
||||
- The project must be trusted; otherwise the call is `denied`.
|
||||
|
||||
In tests, `MockHost::set_language_server_response(server, method, json)` makes
|
||||
a server run and answer, and `language_server_requests()` /
|
||||
`language_server_notifications()` list what the plugin sent.
|
||||
|
||||
### Database sources (API 1.4)
|
||||
|
||||
Declare `database.sources` (medium risk). All five calls require it and a
|
||||
|
||||
Бінарний файл не відображається.
@@ -1 +1 @@
|
||||
4ed77982187f1c454e8567fa3a1a74ba17c5fa24bdc3a14f163df091cad547b1
|
||||
92aa9dc2ab94e8bfa234980aeadc0eb7c437d0917af5526c193f286c97e70214
|
||||
Бінарний файл не відображається.
@@ -1 +1 @@
|
||||
5083b261592e2969f1eea008420e6397d5dca09f7f51c2a91f65a7762ca63275
|
||||
d284a0921686a9a8a05a22db31fe150c0a6bf3743106eee037f1078a96d180a1
|
||||
Бінарний файл не відображається.
Loaded 100 of 207 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Заблокувати користувача