schema for agent mode
This commit is contained in:
parent
d3e1730b72
commit
96523f0d77
5 changed files with 57 additions and 53 deletions
1
Cargo.lock
generated
1
Cargo.lock
generated
|
@ -18000,6 +18000,7 @@ dependencies = [
|
|||
"gpui",
|
||||
"schemars",
|
||||
"serde",
|
||||
"serde_json",
|
||||
"settings",
|
||||
"workspace-hack",
|
||||
]
|
||||
|
|
|
@ -19,6 +19,7 @@ gpui.workspace = true
|
|||
language_model.workspace = true
|
||||
schemars.workspace = true
|
||||
serde.workspace = true
|
||||
serde_json.workspace = true
|
||||
settings.workspace = true
|
||||
workspace-hack.workspace = true
|
||||
vim_mode_setting.workspace = true
|
||||
|
|
|
@ -90,23 +90,19 @@ impl JsonSchema for AgentEditorMode {
|
|||
"AgentEditorMode".into()
|
||||
}
|
||||
|
||||
fn json_schema(schema_gen: &mut schemars::SchemaGenerator) -> schemars::Schema {
|
||||
let editor_mode_schema = EditorMode::json_schema(schema_gen);
|
||||
fn json_schema(_gen: &mut schemars::SchemaGenerator) -> schemars::Schema {
|
||||
use vim_mode_setting::EditorMode;
|
||||
|
||||
// TODO: This schema is incorrect. Need to extend editor_mode_schema with `inherit`
|
||||
let result = json_schema!({
|
||||
"oneOf": [
|
||||
{
|
||||
"const": "inherit",
|
||||
"description": "Inherit editor mode from global settings"
|
||||
},
|
||||
editor_mode_schema
|
||||
],
|
||||
let mut options = vec![serde_json::json!({
|
||||
"const": "inherit",
|
||||
"description": "Inherit editor mode from global settings"
|
||||
})];
|
||||
options.extend(EditorMode::get_schema_options());
|
||||
|
||||
json_schema!({
|
||||
"oneOf": options,
|
||||
"description": "Agent editor mode - either inherit from global settings or override with a specific mode"
|
||||
});
|
||||
|
||||
dbg!(&result);
|
||||
result
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -18,3 +18,4 @@ schemars.workspace = true
|
|||
settings.workspace = true
|
||||
workspace-hack.workspace = true
|
||||
serde.workspace = true
|
||||
serde_json.workspace = true
|
||||
|
|
|
@ -38,45 +38,9 @@ impl JsonSchema for EditorMode {
|
|||
}
|
||||
|
||||
fn json_schema(_gen: &mut schemars::SchemaGenerator) -> Schema {
|
||||
let options = Self::get_schema_options();
|
||||
json_schema!({
|
||||
"oneOf": [
|
||||
{
|
||||
"const": "default",
|
||||
"description": "Standard editing mode"
|
||||
},
|
||||
{
|
||||
"const": "vim",
|
||||
"description": "Vim normal mode"
|
||||
},
|
||||
{
|
||||
"const": "vim_normal",
|
||||
"description": "Vim normal mode"
|
||||
},
|
||||
{
|
||||
"const": "vim_insert",
|
||||
"description": "Vim insert mode"
|
||||
},
|
||||
{
|
||||
"const": "vim_replace",
|
||||
"description": "Vim replace mode"
|
||||
},
|
||||
{
|
||||
"const": "vim_visual",
|
||||
"description": "Vim visual mode"
|
||||
},
|
||||
{
|
||||
"const": "vim_visual_line",
|
||||
"description": "Vim visual line mode"
|
||||
},
|
||||
{
|
||||
"const": "vim_visual_block",
|
||||
"description": "Vim visual block mode"
|
||||
},
|
||||
{
|
||||
"const": "helix_experimental",
|
||||
"description": "Helix mode (experimental)"
|
||||
}
|
||||
],
|
||||
"oneOf": options,
|
||||
"description": "Editor mode"
|
||||
})
|
||||
}
|
||||
|
@ -192,4 +156,45 @@ impl EditorMode {
|
|||
pub fn vim() -> EditorMode {
|
||||
EditorMode::Vim(ModalMode::default())
|
||||
}
|
||||
|
||||
pub fn get_schema_options() -> Vec<serde_json::Value> {
|
||||
vec![
|
||||
serde_json::json!({
|
||||
"const": "default",
|
||||
"description": "Standard editing mode"
|
||||
}),
|
||||
serde_json::json!({
|
||||
"const": "vim",
|
||||
"description": "Vim normal mode"
|
||||
}),
|
||||
serde_json::json!({
|
||||
"const": "vim_normal",
|
||||
"description": "Vim normal mode"
|
||||
}),
|
||||
serde_json::json!({
|
||||
"const": "vim_insert",
|
||||
"description": "Vim insert mode"
|
||||
}),
|
||||
serde_json::json!({
|
||||
"const": "vim_replace",
|
||||
"description": "Vim replace mode"
|
||||
}),
|
||||
serde_json::json!({
|
||||
"const": "vim_visual",
|
||||
"description": "Vim visual mode"
|
||||
}),
|
||||
serde_json::json!({
|
||||
"const": "vim_visual_line",
|
||||
"description": "Vim visual line mode"
|
||||
}),
|
||||
serde_json::json!({
|
||||
"const": "vim_visual_block",
|
||||
"description": "Vim visual block mode"
|
||||
}),
|
||||
serde_json::json!({
|
||||
"const": "helix_experimental",
|
||||
"description": "Helix mode (experimental)"
|
||||
}),
|
||||
]
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue