Skip to content

Commit

Permalink
fix all schemas, restore schema test
Browse files Browse the repository at this point in the history
  • Loading branch information
olegklimov committed Dec 20, 2024
1 parent 5db2b5f commit c5fb75a
Show file tree
Hide file tree
Showing 13 changed files with 106 additions and 81 deletions.
24 changes: 14 additions & 10 deletions src/http/routers/v1/links.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,15 +71,6 @@ pub async fn handle_v1_links(
let (integrations_map, integration_yaml_errors) = crate::integrations::running_integrations::load_integrations(gcx.clone(), "".to_string(), experimental).await;

if post.meta.chat_mode == ChatMode::CONFIGURE {
// links.push(Link {
// link_action: LinkAction::Goto,
// link_text: "Return".to_string(),
// link_goto: Some("SETTINGS:DEFAULT".to_string()),
// link_summary_path: None,
// link_tooltip: format!(""),
// link_payload: None,
// });

if !get_tickets_from_messages(gcx.clone(), &post.messages).await.is_empty() {
links.push(Link {
link_action: LinkAction::PatchAll,
Expand All @@ -92,6 +83,19 @@ pub async fn handle_v1_links(
}
}

if post.meta.chat_mode == ChatMode::PROJECT_SUMMARY {
if !get_tickets_from_messages(gcx.clone(), &post.messages).await.is_empty() {
links.push(Link {
link_action: LinkAction::PatchAll,
link_text: "Save and return".to_string(),
link_goto: Some("NEWCHAT".to_string()),
link_summary_path: None,
link_tooltip: format!(""),
link_payload: None,
});
}
}

// GIT uncommitted
if post.meta.chat_mode == ChatMode::AGENT {
let commits = get_commit_information_from_current_changes(gcx.clone()).await;
Expand All @@ -110,7 +114,7 @@ pub async fn handle_v1_links(
project_changes.truncate(4);
project_changes.push("...".to_string());
}
uncommited_changes_warning = format!("You have uncommitted changes:\n```\n{}\n```\n⚠️ You might have a problem rolling back agent's changes.", project_changes.join("\n"));
uncommited_changes_warning = format!("You have uncommitted changes:\n```\n{}\n```\nIt's fine, but you might have a problem rolling back agent's changes.", project_changes.join("\n"));
}

if false {
Expand Down
13 changes: 7 additions & 6 deletions src/integrations/docker/integr_docker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -312,17 +312,18 @@ fields:
f_desc: "Path to the SSH identity file to connect to remote Docker."
f_label: "SSH Identity File"
f_extra: true
available:
on_your_laptop_possible: true
when_isolated_possible: false
confirmation:
ask_user_default: []
deny_default: ["docker* rm *", "docker* rmi *", "docker* pause *", "docker* stop *", "docker* kill *"]
smartlinks:
- sl_label: "Test"
sl_chat:
- role: "user"
content: |
🔧 The docker tool should be visible now. To test the tool, list the running containers, briefly describe the containers and express
satisfaction and relief if it works, and change nothing. If it doesn't work or the tool isn't available, go through the usual plan in the system prompt.
available:
on_your_laptop_possible: true
when_isolated_possible: false
confirmation:
ask_user_default: []
deny_default: ["docker* rm *", "docker* rmi *", "docker* pause *", "docker* stop *", "docker* kill *"]
sl_enable_only_with_tool: true
"#;
20 changes: 8 additions & 12 deletions src/integrations/integr_chrome.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1281,22 +1281,24 @@ fields:
f_type: string_short
f_desc: "Scale factor of the browser window in tablet mode."
f_extra: true
available:
on_your_laptop_possible: true
when_isolated_possible: true
confirmation:
ask_user_default: []
deny_default: []
smartlinks:
- sl_label: "Test"
sl_chat:
- role: "user"
content: |
🔧 The chrome tool should be visible now. To test the tool, navigate to a website like https://example.com/ take a screenshot, and express happiness if it works. If it doesn't work or the tool isn't available, go through the usual plan in the system prompt.
sl_enable_only_with_tool: true
- sl_label: "Help me install Chrome for Testing"
sl_chat:
- role: "user"
content: |
🔧 Help user to install Chrome for Testing using npm, once that done rewrite the current config file %CURRENT_CONFIG% to use it.
- sl_label: "Help me connect regular Chrome via ws:// protocol"
sl_chat:
- role: "user"
content: |
🔧 Help user to connect regular Chrome via ws:// protocol, rewrite the current config file %CURRENT_CONFIG% to use it. The `chrome_path` accepts the "ws://..." notation.
🔧 Help the user to install Chrome for Testing using npm, once that is done rewrite the current config file %CURRENT_CONFIG% to use chrome_path to use it.
docker:
filter_label: ""
filter_image: "standalone-chrome"
Expand All @@ -1315,10 +1317,4 @@ docker:
- role: "user"
content: |
🔧 Your job is to modify chrome config in the current file to connect through websockets to the container, use docker tool to inspect the container if needed. Current config file: %CURRENT_CONFIG%.
available:
on_your_laptop_possible: true
when_isolated_possible: true
confirmation:
ask_user_default: []
deny_default: []
"#;
7 changes: 4 additions & 3 deletions src/integrations/integr_cmdline.rs
Original file line number Diff line number Diff line change
Expand Up @@ -321,13 +321,14 @@ description: |
available:
on_your_laptop_possible: true
when_isolated_possible: true
confirmation:
ask_user_default: ["*"]
deny_default: ["sudo*"]
smartlinks:
- sl_label: "Auto Configure"
sl_chat:
- role: "user"
content: |
🔧 Test the tool that corresponds to the current config file. If it works express happiness, and change nothing. If it doesn't work or the tool isn't available, go through the usual plan in the system prompt.
confirmation:
ask_user_default: ["*"]
deny_default: ["sudo*"]
sl_enable_only_with_tool: true
"#;
28 changes: 17 additions & 11 deletions src/integrations/integr_github.rs
Original file line number Diff line number Diff line change
Expand Up @@ -179,29 +179,35 @@ fn parse_command_args(args: &HashMap<String, Value>) -> Result<Vec<String>, Stri

const GITHUB_INTEGRATION_SCHEMA: &str = r#"
fields:
gh_token:
f_type: string_long
f_desc: "GitHub Personal Access Token, you can create one at https://github.com/settings/tokens. If you don't want to send your key to the AI model that helps you to configure the agent, put it into secrets.yaml and write $MY_SECRET_VARIABLE in this field."
f_placeholder: "ghp_xxxxxxxxxxxxxxxx"
f_label: "Token"
smartlinks:
- sl_label: "Open secrets.yaml"
sl_goto: "EDITOR:secrets.yaml"
gh_binary_path:
f_type: string_long
f_desc: "Path to the GitHub CLI binary. Leave empty to use the default 'gh' command."
f_desc: "Path to the GitHub CLI binary. Leave empty if you have it in PATH."
f_placeholder: "/usr/local/bin/gh"
f_label: "GH Binary Path"
gh_token:
f_type: string_long
f_desc: "GitHub Personal Access Token for authentication."
f_placeholder: "ghp_xxxxxxxxxxxxxxxx"
f_extra: true
description: |
The GitHub integration allows interaction with GitHub repositories using the GitHub CLI.
It provides functionality for various GitHub operations such as creating issues, pull requests, and more.
available:
on_your_laptop_possible: true
when_isolated_possible: true
confirmation:
ask_user_default: ["gh * delete *", "gh * close *"]
deny_default: ["gh auth token *"]
smartlinks:
- sl_label: "Test"
sl_chat:
- role: "user"
content: |
🔧 The `github` (`gh`) tool should be visible now. To test the tool, list opened pull requests for `smallcloudai/refact-lsp`, and briefly describe them and express
happiness, and change nothing. If it doesn't work or the tool isn't available, go through the usual plan in the system prompt.
available:
on_your_laptop_possible: true
when_isolated_possible: true
confirmation:
ask_user_default: ["gh * delete *", "gh * close *"]
deny_default: ["gh auth token *"]
sl_enable_only_with_tool: true
"#;
29 changes: 17 additions & 12 deletions src/integrations/integr_gitlab.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ impl IntegrationTrait for ToolGitlab {
fn integr_common(&self) -> IntegrationCommon {
self.common.clone()
}

fn integr_upgrade_to_tool(&self, _integr_name: &str) -> Box<dyn Tool + Send> {
Box::new(ToolGitlab {
common: self.common.clone(),
Expand Down Expand Up @@ -176,29 +176,34 @@ fn parse_command_args(args: &HashMap<String, Value>) -> Result<Vec<String>, Stri

const GITLAB_INTEGRATION_SCHEMA: &str = r#"
fields:
glab_token:
f_type: string_long
f_desc: "GitLab Personal Access Token, you can get one at https://gitlab.com/-/user_settings/personal_access_tokens. If you don't want to send your key to the AI model that helps you to configure the agent, put it into secrets.yaml and write $MY_SECRET_VARIABLE in this field."
f_placeholder: "glpat_xxxxxxxxxxxxxxxx"
smartlinks:
- sl_label: "Open secrets.yaml"
sl_goto: "EDITOR:secrets.yaml"
glab_binary_path:
f_type: string_long
f_desc: "Path to the GitLab CLI binary. Leave empty to use the default 'glab' command."
f_placeholder: "/usr/local/bin/glab"
f_label: "GLAB Binary Path"
glab_token:
f_type: string_long
f_desc: "GitLab Personal Access Token for authentication."
f_placeholder: "glpat_xxxxxxxxxxxxxxxx"
f_label: "glab binary path"
f_extra: true
description: |
The GitLab integration allows interaction with GitLab repositories using the GitLab CLI.
It provides functionality for various GitLab operations such as creating issues, merge requests, and more.
available:
on_your_laptop_possible: true
when_isolated_possible: true
confirmation:
ask_user_default: ["glab * delete *"]
deny_default: ["glab auth token *"]
smartlinks:
- sl_label: "Test"
sl_chat:
- role: "user"
content: |
🔧 The `gitlab` (`glab`) tool should be visible now. To test the tool, list opened merge requests for your GitLab project, and briefly describe them and express
happiness, and change nothing. If it doesn't work or the tool isn't available, go through the usual plan in the system prompt.
available:
on_your_laptop_possible: true
when_isolated_possible: true
confirmation:
ask_user_default: ["glab * delete *"]
deny_default: ["glab auth token *"]
sl_enable_only_with_tool: true
"#;
21 changes: 11 additions & 10 deletions src/integrations/integr_mysql.rs
Original file line number Diff line number Diff line change
Expand Up @@ -188,8 +188,8 @@ fields:
f_type: string_short
f_default: "$MYSQL_PASSWORD"
smartlinks:
- sl_label: "Open passwords.yaml"
sl_goto: "EDITOR:passwords.yaml"
- sl_label: "Open secrets.yaml"
sl_goto: "EDITOR:secrets.yaml"
database:
f_type: string_short
f_placeholder: "mysql"
Expand All @@ -204,6 +204,12 @@ description: |
On this page you can also see Docker containers with Mysql servers.
You can ask model to create a new container with a new database for you,
or ask model to configure the tool to use an existing container with existing database.
available:
on_your_laptop_possible: true
when_isolated_possible: true
confirmation:
ask_user_default: []
deny_default: []
smartlinks:
- sl_label: "Test"
sl_chat:
Expand All @@ -212,13 +218,14 @@ smartlinks:
🔧 The mysql tool should be visible now. To test the tool, list the tables available, briefly describe the tables and express
happiness, and change nothing. If it doesn't work or the tool isn't available, go through the usual plan in the system prompt.
The current config file is %CURRENT_CONFIG%.
- sl_label: "Look at the project, fill in automatically"
sl_enable_only_with_tool: true
- sl_label: "Look at the project, help me set it up"
sl_chat:
- role: "user"
content: |
🔧 Your goal is to set up mysql client. Look at the project, especially files like "docker-compose.yaml" or ".env". Call tree() to see what files the project has.
After that is completed, go through the usual plan in the system prompt.
The current config file is %CURRENT_CONFIG%.
Keep MYSQL_HOST MYSQL_PORT MYSQL_USER MYSQL_PASSWORD MYSQL_DATABASE in variables.yaml so they can be reused by command line tools later.
docker:
filter_label: ""
filter_image: "mysql"
Expand All @@ -242,10 +249,4 @@ docker:
- role: "user"
content: |
🔧 Your job is to modify mysql connection config in the current file to match the variables from the container, use docker tool to inspect the container if needed. Current config file: %CURRENT_CONFIG%.
available:
on_your_laptop_possible: true
when_isolated_possible: true
confirmation:
ask_user_default: []
deny_default: []
"#;
13 changes: 7 additions & 6 deletions src/integrations/integr_pdb.rs
Original file line number Diff line number Diff line change
Expand Up @@ -377,17 +377,18 @@ fields:
description: |
The PDB integration allows interaction with the Python debugger for inspecting variables and exploring program execution.
It provides functionality for debugging Python scripts and applications.
available:
on_your_laptop_possible: true
when_isolated_possible: true
confirmation:
ask_user_default: []
deny_default: []
smartlinks:
- sl_label: "Test"
sl_chat:
- role: "user"
content: |
🔧 The pdb tool should be visible now. To test the tool, start a debugging session for a simple Python script, set a breakpoint, and inspect some variables.
If it doesn't work or the tool isn't available, go through the usual plan in the system prompt.
available:
on_your_laptop_possible: true
when_isolated_possible: true
confirmation:
ask_user_default: []
deny_default: []
sl_enable_only_with_tool: true
"#;
15 changes: 8 additions & 7 deletions src/integrations/integr_postgres.rs
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ fields:
sl_goto: "EDITOR:variables.yaml"
database:
f_type: string_short
f_placeholder: "postgres"
f_placeholder: "my_marketing_db"
psql_binary_path:
f_type: string_long
f_desc: "If it can't find a path to `psql` you can provide it here, leave blank if not sure."
Expand All @@ -203,13 +203,20 @@ description: |
On this page you can also see Docker containers with Postgres servers.
You can ask model to create a new container with a new database for you,
or ask model to configure the tool to use an existing container with existing database.
available:
on_your_laptop_possible: true
when_isolated_possible: true
confirmation:
ask_user_default: ["psql*[!SELECT]*"]
deny_default: []
smartlinks:
- sl_label: "Test"
sl_chat:
- role: "user"
content: |
🔧 The postgres tool should be visible now. To test the tool, list the tables available, briefly describe the tables and express
happiness, and change nothing. If it doesn't work or the tool isn't available, go through the usual plan in the system prompt.
sl_enable_only_with_tool: true
- sl_label: "Look at the project, fill in automatically"
sl_chat:
- role: "user"
Expand Down Expand Up @@ -240,12 +247,6 @@ docker:
- role: "user"
content: |
🔧 Your job is to modify postgres connection config in the current file to match the variables from the container, use docker tool to inspect the container if needed. Current config file: %CURRENT_CONFIG%.
available:
on_your_laptop_possible: true
when_isolated_possible: true
confirmation:
ask_user_default: ["psql*[!SELECT]*"]
deny_default: []
"#;

// To think about: PGPASSWORD PGHOST PGUSER PGPORT PGDATABASE maybe tell the model to set that in variables.yaml as well
1 change: 0 additions & 1 deletion src/integrations/project_summary_chat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ pub async fn mix_project_summary_messages(
) {
assert!(messages[0].role != "system"); // we are here to add this, can't already exist


// XXX should be a better way to load the prompt
let custom: crate::yaml_configs::customization_loader::CustomizationYaml = match crate::yaml_configs::customization_loader::load_customization(gcx.clone(), true).await {
Ok(x) => x,
Expand Down
1 change: 0 additions & 1 deletion src/integrations/setting_up_integrations.rs
Original file line number Diff line number Diff line change
Expand Up @@ -474,7 +474,6 @@ mod tests {
use std::io::Write;

#[tokio::test]
#[ignore]
async fn test_integration_schemas() {
let integrations = crate::integrations::integrations_list(true);
for name in integrations {
Expand Down
Loading

0 comments on commit c5fb75a

Please sign in to comment.