Make it startable from playwright and also isolate (#5016)
Co-authored-by: Douwe Osinga <douwe@squareup.com>
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
use anyhow::Result;
|
||||
use console::style;
|
||||
use etcetera::{choose_app_strategy, AppStrategy};
|
||||
use goose::config::paths::Paths;
|
||||
use goose::config::Config;
|
||||
use serde_yaml;
|
||||
|
||||
@@ -9,11 +9,8 @@ fn print_aligned(label: &str, value: &str, width: usize) {
|
||||
}
|
||||
|
||||
pub fn handle_info(verbose: bool) -> Result<()> {
|
||||
let data_dir = choose_app_strategy(crate::APP_STRATEGY.clone())?;
|
||||
let logs_dir = data_dir
|
||||
.in_state_dir("logs")
|
||||
.unwrap_or_else(|| data_dir.in_data_dir("logs"));
|
||||
let sessions_dir = data_dir.in_data_dir("sessions");
|
||||
let logs_dir = Paths::in_state_dir("logs");
|
||||
let sessions_dir = Paths::in_data_dir("sessions");
|
||||
|
||||
// Get paths using a stored reference to the global config
|
||||
let config = Config::global();
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
use etcetera::AppStrategyArgs;
|
||||
use once_cell::sync::Lazy;
|
||||
pub mod cli;
|
||||
pub mod commands;
|
||||
pub mod logging;
|
||||
@@ -11,9 +9,3 @@ pub mod signal;
|
||||
|
||||
// Re-export commonly used types
|
||||
pub use session::CliSession;
|
||||
|
||||
pub static APP_STRATEGY: Lazy<AppStrategyArgs> = Lazy::new(|| AppStrategyArgs {
|
||||
top_level_domain: "Block".to_string(),
|
||||
author: "Block".to_string(),
|
||||
app_name: "goose".to_string(),
|
||||
});
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
use anyhow::{Context, Result};
|
||||
use chrono::{DateTime, Utc};
|
||||
use etcetera::{choose_app_strategy, AppStrategy};
|
||||
use goose::config::paths::Paths;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::collections::HashMap;
|
||||
use std::fs;
|
||||
@@ -41,11 +41,7 @@ pub struct ProjectInfoDisplay {
|
||||
impl ProjectTracker {
|
||||
/// Get the path to the projects.json file
|
||||
fn get_projects_file() -> Result<PathBuf> {
|
||||
let projects_file = choose_app_strategy(crate::APP_STRATEGY.clone())
|
||||
.context("goose requires a home dir")?
|
||||
.in_data_dir("projects.json");
|
||||
|
||||
// Ensure data directory exists
|
||||
let projects_file = Paths::in_data_dir("projects.json");
|
||||
if let Some(parent) = projects_file.parent() {
|
||||
if !parent.exists() {
|
||||
fs::create_dir_all(parent)?;
|
||||
|
||||
@@ -25,7 +25,6 @@ use goose::utils::safe_truncate;
|
||||
|
||||
use anyhow::{Context, Result};
|
||||
use completion::GooseCompleter;
|
||||
use etcetera::{choose_app_strategy, AppStrategy};
|
||||
use goose::agents::extension::{Envs, ExtensionConfig};
|
||||
use goose::agents::types::RetryConfig;
|
||||
use goose::agents::{Agent, SessionConfig};
|
||||
@@ -37,6 +36,7 @@ use rmcp::model::PromptMessage;
|
||||
use rmcp::model::ServerNotification;
|
||||
use rmcp::model::{ErrorCode, ErrorData};
|
||||
|
||||
use goose::config::paths::Paths;
|
||||
use goose::conversation::message::{Message, MessageContent};
|
||||
use rand::{distributions::Alphanumeric, Rng};
|
||||
use rustyline::EditMode;
|
||||
@@ -413,29 +413,20 @@ impl CliSession {
|
||||
let completer = GooseCompleter::new(self.completion_cache.clone());
|
||||
editor.set_helper(Some(completer));
|
||||
|
||||
// Create and use a global history file in ~/.config/goose directory
|
||||
// This allows command history to persist across different chat sessions
|
||||
// instead of being tied to each individual session's messages
|
||||
let strategy =
|
||||
choose_app_strategy(crate::APP_STRATEGY.clone()).expect("goose requires a home dir");
|
||||
let config_dir = strategy.config_dir();
|
||||
let history_file = config_dir.join("history.txt");
|
||||
let history_file = Paths::config_dir().join("history.txt");
|
||||
|
||||
// Ensure config directory exists
|
||||
if let Some(parent) = history_file.parent() {
|
||||
if !parent.exists() {
|
||||
std::fs::create_dir_all(parent)?;
|
||||
}
|
||||
}
|
||||
|
||||
// Load history from the global file
|
||||
if history_file.exists() {
|
||||
if let Err(err) = editor.load_history(&history_file) {
|
||||
eprintln!("Warning: Failed to load command history: {}", err);
|
||||
}
|
||||
}
|
||||
|
||||
// Helper function to save history after commands
|
||||
let save_history =
|
||||
|editor: &mut rustyline::Editor<GooseCompleter, rustyline::history::DefaultHistory>| {
|
||||
if let Err(err) = editor.save_history(&history_file) {
|
||||
|
||||
Reference in New Issue
Block a user