Skip to content

Commit 25f7c8a

Browse files
committed
feat(chat): add --workdir/-C flag to set working directory at session start
Allows users to start a chat session in a specific directory without needing to cd first or restart the session: kiro-cli chat --workdir /path/to/project kiro-cli chat -C /path/to/project The working directory is set before any other initialization, so LSP discovery, .kiro config loading, and context detection all use the specified path.
1 parent fc482ca commit 25f7c8a

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

  • crates/chat-cli/src/cli/chat

crates/chat-cli/src/cli/chat/mod.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -252,10 +252,18 @@ pub struct ChatArgs {
252252
/// Control line wrapping behavior (default: auto-detect)
253253
#[arg(short = 'w', long, value_enum)]
254254
pub wrap: Option<WrapMode>,
255+
/// Set the working directory for this chat session
256+
#[arg(long = "workdir", short = 'C', value_name = "PATH")]
257+
pub workdir: Option<PathBuf>,
255258
}
256259

257260
impl ChatArgs {
258261
pub async fn execute(mut self, os: &mut Os) -> Result<ExitCode> {
262+
if let Some(ref workdir) = self.workdir {
263+
std::env::set_current_dir(workdir)
264+
.map_err(|e| eyre::eyre!("Failed to set working directory '{}': {}", workdir.display(), e))?;
265+
}
266+
259267
let mut input = self.input;
260268

261269
if self.no_interactive && input.is_none() {

0 commit comments

Comments
 (0)