Skip to content

Commit dd4ed9a

Browse files
committed
style: cargo fmt and add emoji to docs site title
1 parent b921707 commit dd4ed9a

File tree

10 files changed

+478
-160
lines changed

10 files changed

+478
-160
lines changed

docs/astro.config.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ export default defineConfig({
77
site: 'https://bugatti.dev',
88
integrations: [
99
starlight({
10-
title: 'bugatti',
10+
title: '🚗 bugatti',
1111
social: [{ icon: 'github', label: 'GitHub', href: 'https://github.com/codesoda/bugatti-cli' }],
1212
sidebar: [
1313
{ label: 'Getting Started', slug: 'getting-started' },

docs/src/content/docs/index.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
title: bugatti
2+
title: 🚗 bugatti
33
description: Write tests in plain English. An AI agent runs them.
44
template: splash
55
hero:

src/claude_code.rs

Lines changed: 133 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,10 @@ pub struct ClaudeCodeAdapter {
5656
pub(crate) fn format_step_message(message: &StepMessage) -> String {
5757
format!(
5858
"[run_id={} session_id={} step={}/{} source={}]\n\n{}",
59-
message.run_id, message.session_id,
60-
message.step_id + 1, message.total_steps,
59+
message.run_id,
60+
message.session_id,
61+
message.step_id + 1,
62+
message.total_steps,
6163
message.source_file,
6264
message.instruction
6365
)
@@ -165,21 +167,40 @@ impl ClaudeCodeAdapter {
165167
.stderr(Stdio::piped());
166168

167169
if self.verbose {
168-
let args: Vec<_> = cmd.get_args().map(|a| a.to_string_lossy().to_string()).collect();
169-
eprintln!("{}[verbose]{} {}launch:{} {} {}{}", color::DIM, color::RESET, color::DIM, color::RESET, color::CMD, args.join(" "), color::RESET);
170-
eprintln!("{} binary: {}{}", color::DIM, cmd.get_program().to_string_lossy(), color::RESET);
170+
let args: Vec<_> = cmd
171+
.get_args()
172+
.map(|a| a.to_string_lossy().to_string())
173+
.collect();
174+
eprintln!(
175+
"{}[verbose]{} {}launch:{} {} {}{}",
176+
color::DIM,
177+
color::RESET,
178+
color::DIM,
179+
color::RESET,
180+
color::CMD,
181+
args.join(" "),
182+
color::RESET
183+
);
184+
eprintln!(
185+
"{} binary: {}{}",
186+
color::DIM,
187+
cmd.get_program().to_string_lossy(),
188+
color::RESET
189+
);
171190
}
172191

173-
let mut child = cmd.spawn().map_err(|e| {
174-
ProviderError::StartFailed(format!("failed to spawn claude CLI: {e}"))
175-
})?;
192+
let mut child = cmd
193+
.spawn()
194+
.map_err(|e| ProviderError::StartFailed(format!("failed to spawn claude CLI: {e}")))?;
176195

177-
let stdin = child.stdin.take().ok_or_else(|| {
178-
ProviderError::StartFailed("failed to capture stdin".to_string())
179-
})?;
180-
let stdout = child.stdout.take().ok_or_else(|| {
181-
ProviderError::StartFailed("failed to capture stdout".to_string())
182-
})?;
196+
let stdin = child
197+
.stdin
198+
.take()
199+
.ok_or_else(|| ProviderError::StartFailed("failed to capture stdin".to_string()))?;
200+
let stdout = child
201+
.stdout
202+
.take()
203+
.ok_or_else(|| ProviderError::StartFailed("failed to capture stdout".to_string()))?;
183204

184205
self.child = Some(child);
185206
self.stdin = Some(stdin);
@@ -197,14 +218,22 @@ impl ClaudeCodeAdapter {
197218
{
198219
self.ensure_started()?;
199220

200-
let stdin = self.stdin.as_mut().ok_or_else(|| {
201-
ProviderError::SendFailed("session not started".to_string())
202-
})?;
221+
let stdin = self
222+
.stdin
223+
.as_mut()
224+
.ok_or_else(|| ProviderError::SendFailed("session not started".to_string()))?;
203225

204226
let input_line = format_stream_input(message);
205227

206228
if self.verbose {
207-
eprintln!("{}[verbose]{} {}prompt ({} bytes):{}", color::DIM, color::RESET, color::DIM, message.len(), color::RESET);
229+
eprintln!(
230+
"{}[verbose]{} {}prompt ({} bytes):{}",
231+
color::DIM,
232+
color::RESET,
233+
color::DIM,
234+
message.len(),
235+
color::RESET
236+
);
208237
eprintln!("{}{}{}", color::PROMPT, message, color::RESET);
209238
eprintln!("{}───{}", color::SEP, color::RESET);
210239
}
@@ -219,16 +248,25 @@ impl ClaudeCodeAdapter {
219248
.flush()
220249
.map_err(|e| ProviderError::SendFailed(format!("failed to flush stdin: {e}")))?;
221250

222-
let reader = self.reader.as_mut().ok_or_else(|| {
223-
ProviderError::SendFailed("stdout reader not available".to_string())
224-
})?;
251+
let reader = self
252+
.reader
253+
.as_mut()
254+
.ok_or_else(|| ProviderError::SendFailed("stdout reader not available".to_string()))?;
225255

226-
Ok(Box::new(StreamTurnIterator { reader, done: false, verbose: self.verbose }))
256+
Ok(Box::new(StreamTurnIterator {
257+
reader,
258+
done: false,
259+
verbose: self.verbose,
260+
}))
227261
}
228262
}
229263

230264
impl AgentSession for ClaudeCodeAdapter {
231-
fn initialize(config: &Config, artifact_dir: &Path, verbose: bool) -> Result<Self, ProviderError>
265+
fn initialize(
266+
config: &Config,
267+
artifact_dir: &Path,
268+
verbose: bool,
269+
) -> Result<Self, ProviderError>
232270
where
233271
Self: Sized,
234272
{
@@ -355,28 +393,59 @@ impl<'a> Iterator for StreamTurnIterator<'a> {
355393
}
356394
"tool_use" => {
357395
if self.verbose {
358-
let name = block.name.as_deref().unwrap_or("unknown");
359-
let input_preview = block.input.as_ref().map(|v| {
360-
// For Bash, show the command directly
361-
if let Some(cmd) = v.get("command").and_then(|c| c.as_str()) {
362-
format!("$ {cmd}")
363-
} else if let Some(path) = v.get("file_path").and_then(|p| p.as_str()) {
364-
path.to_string()
365-
} else if let Some(pattern) = v.get("pattern").and_then(|p| p.as_str()) {
366-
format!("/{pattern}/")
367-
} else {
368-
v.to_string()
369-
}
370-
}).unwrap_or_default();
371-
let id_short = block.id.as_deref().unwrap_or("").chars().take(12).collect::<String>();
396+
let name =
397+
block.name.as_deref().unwrap_or("unknown");
398+
let input_preview = block
399+
.input
400+
.as_ref()
401+
.map(|v| {
402+
// For Bash, show the command directly
403+
if let Some(cmd) = v
404+
.get("command")
405+
.and_then(|c| c.as_str())
406+
{
407+
format!("$ {cmd}")
408+
} else if let Some(path) = v
409+
.get("file_path")
410+
.and_then(|p| p.as_str())
411+
{
412+
path.to_string()
413+
} else if let Some(pattern) = v
414+
.get("pattern")
415+
.and_then(|p| p.as_str())
416+
{
417+
format!("/{pattern}/")
418+
} else {
419+
v.to_string()
420+
}
421+
})
422+
.unwrap_or_default();
423+
let id_short = block
424+
.id
425+
.as_deref()
426+
.unwrap_or("")
427+
.chars()
428+
.take(12)
429+
.collect::<String>();
372430
eprintln!("{}[verbose]{} {}tool:{} {}{}{} {}{}{} {}({}){}", color::DIM, color::RESET, color::DIM, color::RESET, color::TOOL, name, color::RESET, color::LIGHT, input_preview, color::RESET, color::DIM, id_short, color::RESET);
373431
}
374432
}
375433
"thinking" => {
376434
if self.verbose {
377435
if let Some(thinking) = &block.thinking {
378-
eprintln!("{}[verbose]{} {}thinking:{}", color::DIM, color::RESET, color::DIM, color::RESET);
379-
eprintln!("{}{}{}", color::THINKING, thinking, color::RESET);
436+
eprintln!(
437+
"{}[verbose]{} {}thinking:{}",
438+
color::DIM,
439+
color::RESET,
440+
color::DIM,
441+
color::RESET
442+
);
443+
eprintln!(
444+
"{}{}{}",
445+
color::THINKING,
446+
thinking,
447+
color::RESET
448+
);
380449
}
381450
}
382451
}
@@ -392,17 +461,38 @@ impl<'a> Iterator for StreamTurnIterator<'a> {
392461
if let Some(msg) = &event.message {
393462
for block in &msg.content {
394463
if block.block_type == "tool_result" {
395-
let result_text = block.content
464+
let result_text = block
465+
.content
396466
.as_ref()
397467
.map(|v| match v {
398468
serde_json::Value::String(s) => s.clone(),
399469
other => other.to_string(),
400470
})
401471
.or_else(|| block.text.clone())
402472
.unwrap_or_default();
403-
let id_short = block.tool_use_id.as_deref().unwrap_or("").chars().take(12).collect::<String>();
404-
eprintln!("{}[verbose]{} {}result:{} {}({}){}", color::DIM, color::RESET, color::DIM, color::RESET, color::DIM, id_short, color::RESET);
405-
eprintln!("{}{}{}", color::RESULT, result_text, color::RESET);
473+
let id_short = block
474+
.tool_use_id
475+
.as_deref()
476+
.unwrap_or("")
477+
.chars()
478+
.take(12)
479+
.collect::<String>();
480+
eprintln!(
481+
"{}[verbose]{} {}result:{} {}({}){}",
482+
color::DIM,
483+
color::RESET,
484+
color::DIM,
485+
color::RESET,
486+
color::DIM,
487+
id_short,
488+
color::RESET
489+
);
490+
eprintln!(
491+
"{}{}{}",
492+
color::RESULT,
493+
result_text,
494+
color::RESET
495+
);
406496
}
407497
}
408498
}

0 commit comments

Comments
 (0)