Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions src/apps/cli/src/chat_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -829,11 +829,6 @@ impl ChatState {
self.metadata.total_tokens = total_tokens;
}

/// Update workspace path (e.g. after cd command changes working directory)
pub fn update_workspace(&mut self, new_workspace: String) {
self.workspace = Some(new_workspace);
}

/// Add a system message (for commands like /help, /clear, etc.)
pub fn add_system_message(&mut self, content: String) {
self.messages.push(ChatMessage {
Expand Down
12 changes: 0 additions & 12 deletions src/apps/cli/src/commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,6 @@ pub const COMMAND_SPECS: &[CommandSpec] = &[
name: "/connect",
description: "Add a new AI model configuration",
},
CommandSpec {
name: "/rename",
description: "Rename session",
},
CommandSpec {
name: "/new",
description: "New session",
Expand All @@ -52,10 +48,6 @@ pub const COMMAND_SPECS: &[CommandSpec] = &[
name: "/subagents",
description: "Browse and launch subagents",
},
CommandSpec {
name: "/workspace",
description: "Switch workspace directory",
},
CommandSpec {
name: "/mcps",
description: "Manage MCP servers",
Expand Down Expand Up @@ -104,10 +96,6 @@ pub const STARTUP_COMMAND_SPECS: &[CommandSpec] = &[
name: "/subagents",
description: "Browse and launch subagents",
},
CommandSpec {
name: "/workspace",
description: "Switch workspace directory",
},
CommandSpec {
name: "/mcps",
description: "Manage MCP servers",
Expand Down
4 changes: 2 additions & 2 deletions src/apps/cli/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ pub struct CliConfig {
pub struct UiConfig {
/// Theme (dark, light, auto)
pub theme: String,
/// Theme ID (built-in: "bitfun"; custom: filename in themes dir without ".json")
/// Theme ID (built-in preset name; custom: filename in themes dir without ".json")
pub theme_id: String,
/// Show tips
pub show_tips: bool,
Expand Down Expand Up @@ -73,7 +73,7 @@ impl Default for UiConfig {
fn default() -> Self {
Self {
theme: "dark".to_string(),
theme_id: "bitfun".to_string(),
theme_id: "cursor".to_string(),
show_tips: true,
animation: true,
color_scheme: "default".to_string(),
Expand Down
123 changes: 15 additions & 108 deletions src/apps/cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,6 @@ struct Cli {
#[command(subcommand)]
command: Option<Commands>,

/// Workspace path (project directory), defaults to current directory
project: Option<String>,

/// Enable verbose logging
#[arg(short, long, global = true)]
verbose: bool,
Expand All @@ -76,10 +73,6 @@ enum Commands {
/// Agent type
#[arg(short, long, default_value = "agentic")]
agent: String,

/// Workspace path
#[arg(short, long)]
workspace: Option<String>,
},

/// Execute single command
Expand All @@ -91,14 +84,6 @@ enum Commands {
#[arg(short, long, default_value = "agentic")]
agent: String,

/// Workspace path
#[arg(short, long)]
workspace: Option<String>,

/// Output in JSON format (script-friendly)
#[arg(long)]
json: bool,

/// Output git diff patch after execution (for SWE-bench evaluation)
/// Without path outputs to terminal, with path saves to file
/// Example: --output-patch or --output-patch ./result.patch
Expand All @@ -110,13 +95,6 @@ enum Commands {
confirm: bool,
},

/// Execute batch tasks
Batch {
/// Task configuration file path
#[arg(short, long)]
tasks: String,
},

/// Session management
Sessions {
#[command(subcommand)]
Expand All @@ -129,25 +107,11 @@ enum Commands {
action: ConfigAction,
},

/// Invoke tool directly
Tool {
/// Tool name
name: String,

/// Tool parameters (JSON)
#[arg(short, long)]
params: Option<String>,
},

/// Health check
Health,

/// Start Agent Client Protocol (ACP) server over stdio
Acp {
/// Working directory for the ACP session
#[arg(short, long)]
workspace: Option<String>,
},
Acp,
}

#[derive(Subcommand)]
Expand Down Expand Up @@ -178,18 +142,10 @@ enum ConfigAction {

// ======================== System Initialization ========================

/// Set the workspace path and return the resolved absolute path
fn setup_workspace(ws: &str) -> Option<String> {
use std::path::PathBuf;

let workspace_path = if ws == "." {
std::env::current_dir().ok()
} else {
Some(PathBuf::from(ws))
};

/// Return the current project path. CLI session scope is intentionally cwd-only.
fn setup_workspace() -> Option<String> {
let workspace_path = std::env::current_dir().ok();
tracing::info!("Workspace path set: {:?}", workspace_path);

workspace_path.map(|p| p.to_string_lossy().to_string())
}

Expand Down Expand Up @@ -293,7 +249,7 @@ async fn shutdown_mcp_servers() {
async fn run_interactive(
config: CliConfig,
default_agent: String,
workspace_str: String,
_workspace_str: String,
) -> Result<()> {
use ui::startup::{StartupPage, StartupResult};

Expand All @@ -302,7 +258,7 @@ async fn run_interactive(
ui::render_loading(&mut terminal, "Initializing system, please wait...")?;

// 2. Set workspace path
let workspace = setup_workspace(&workspace_str);
let workspace = setup_workspace();

// 3. Initialize core services
let (agentic_system, original_skip_confirmation) =
Expand Down Expand Up @@ -335,7 +291,7 @@ async fn run_interactive(
};

let agent_type = startup_page.agent_type().to_string();
// Use workspace from startup page (may have been changed via /workspace command)
// Use the current project workspace selected at process start.
let workspace = startup_page.workspace();
let mut chat_mode = ChatMode::new(config, agent_type, workspace, &agentic_system);
if let Some(session_id) = restore_session_id {
Expand Down Expand Up @@ -419,39 +375,13 @@ async fn main() -> Result<()> {
});

match cli.command {
Some(Commands::Chat { agent, workspace }) => {
if let Some(ws) = workspace {
// Direct chat mode: workspace provided, skip startup page
let workspace = setup_workspace(&ws);

let (agentic_system, original_skip_confirmation) =
initialize_core_services(true).await?;

println!("System initialized, starting chat interface...\n");
std::thread::sleep(std::time::Duration::from_millis(500));

let mut chat_mode = ChatMode::new(config, agent, workspace, &agentic_system);
let _exit_reason = chat_mode.run(None)?;

shutdown_mcp_servers().await;
restore_tool_confirmation(original_skip_confirmation).await;
} else {
// Interactive mode with startup page
run_interactive(config, agent, ".".to_string()).await?;
}
Some(Commands::Chat { agent }) => {
// Interactive mode with startup page, scoped to the current directory.
run_interactive(config, agent, ".".to_string()).await?;
}

Some(Commands::Exec { message, agent, workspace, json: _, output_patch, confirm }) => {
let workspace_path_resolved = if let Some(ref ws) = workspace {
use std::path::PathBuf;
if ws == "." {
std::env::current_dir().ok()
} else {
Some(PathBuf::from(ws))
}
} else {
std::env::current_dir().ok()
};
Some(Commands::Exec { message, agent, output_patch, confirm }) => {
let workspace_path_resolved = std::env::current_dir().ok();

if let Some(ref ws_path) = workspace_path_resolved {
tracing::info!("Workspace path set: {:?}", ws_path);
Expand All @@ -477,12 +407,6 @@ async fn main() -> Result<()> {
run_result?;
}

Some(Commands::Batch { tasks }) => {
println!("Executing batch tasks...");
println!("Tasks file: {}", tasks);
println!("\nWarning: Batch execution feature coming soon");
}

Some(Commands::Sessions { action }) => {
handle_session_action(action).await?;
}
Expand All @@ -491,23 +415,14 @@ async fn main() -> Result<()> {
handle_config_action(action, &config)?;
}

Some(Commands::Tool { name, params }) => {
println!("Invoking tool: {}", name);
if let Some(p) = params {
println!("Parameters: {}", p);
}
println!("\nWarning: Tool invocation feature coming soon");
}

Some(Commands::Health) => {
println!("BitFun CLI is running normally");
println!("Version: {}", env!("CARGO_PKG_VERSION"));
println!("Config directory: {:?}", CliConfig::config_dir()?);
}

Some(Commands::Acp { workspace }) => {
let workspace_str = workspace.unwrap_or_else(|| ".".to_string());
setup_workspace(&workspace_str);
Some(Commands::Acp) => {
setup_workspace();

bitfun_core::service::config::initialize_global_config()
.await
Expand All @@ -530,15 +445,7 @@ async fn main() -> Result<()> {

None => {
// Default: interactive TUI with startup page
let workspace_str = cli.project
.map(|p| {
if p == "." { p } else {
dunce::canonicalize(&p)
.map(|abs| abs.to_string_lossy().to_string())
.unwrap_or(p)
}
})
.unwrap_or_else(|| ".".to_string());
let workspace_str = ".".to_string();

let default_agent = config.behavior.default_agent.clone();
run_interactive(config, default_agent, workspace_str).await?;
Expand Down
Loading
Loading