Skip to content

Commit 7da7094

Browse files
laststylebender14autofix-ci[bot]tusharmath
authored
feat: stream the execution of shell commands to parent stream (tailcallhq#285)
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com> Co-authored-by: Tushar Mathur <tusharmath@gmail.com>
1 parent 9c69439 commit 7da7094

14 files changed

Lines changed: 212 additions & 107 deletions

File tree

‎Cargo.lock‎

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎crates/forge_app/src/prompts/title.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ Please follow these steps to generate an appropriate title:
1717
- Captures the core message or functionality
1818
- Uses clear, technical language
1919
- Avoids unnecessary words or marketing language
20-
- Uses kebab case
20+
- Uses kebab case to standardize
2121

2222
Before providing your final title, wrap your analysis in <title_generation_process> tags. Follow these steps:
2323

‎crates/forge_app/src/service/snapshots/forge_app__service__system_prompt__tests__tool_unsupported.snap‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
---
22
source: crates/forge_app/src/service/system_prompt.rs
33
expression: prompt
4-
snapshot_kind: text
54
---
65
You are Code-Forge, an expert software engineering assistant designed to help users with various programming tasks, file operations, and software development processes. Your knowledge spans multiple programming languages, frameworks, design patterns, and best practices.
76

‎crates/forge_app/src/service/snapshots/forge_app__service__workflow_title__tests__system_prompt.snap‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
---
22
source: crates/forge_app/src/service/workflow_title.rs
33
expression: snap
4-
snapshot_kind: text
54
---
65
You are Code-Forge's Title Generation Expert, tasked with analyzing technical content and generating precise, impactful titles that capture the essence of the material. Your goal is to create titles in kebab case that are clear, informative, and tailored for a technical audience.
76

@@ -82,7 +81,7 @@ Please follow these steps to generate an appropriate title:
8281
- Captures the core message or functionality
8382
- Uses clear, technical language
8483
- Avoids unnecessary words or marketing language
85-
- Uses kebab case
84+
- Uses kebab case to standardize
8685

8786
Before providing your final title, wrap your analysis in <title_generation_process> tags. Follow these steps:
8887

‎crates/forge_display/Cargo.toml‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
[package]
2+
name = "forge_display"
3+
version = "0.1.0"
4+
edition = "2021"
5+
6+
[dependencies]
7+
forge_domain = { path = "../forge_domain" }
8+
colored = "3.0.0"
9+
chrono = { version = "0.4", features = ["serde"] }
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ impl StatusDisplay {
7070
Kind::Execute => (
7171
self.icon().cyan(),
7272
self.label().bold().cyan(),
73-
format!("{} ...", self.message),
73+
format!("{} ", self.message),
7474
),
7575
Kind::Success => (
7676
self.icon().green(),

‎crates/forge_main/Cargo.toml‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ clap = { version = "4.5.23", features = ["derive"] }
99
forge_app = { path = "../forge_app" }
1010
forge_domain = { path = "../forge_domain" }
1111
forge_walker = { path = "../forge_walker" }
12+
forge_display = { path = "../forge_display" }
1213
tokio = { version = "1.0", features = ["full"] }
1314
tokio-stream = "0.1.17"
1415
colored = "3.0.0"

‎crates/forge_main/src/input.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
use std::path::PathBuf;
22

33
use async_trait::async_trait;
4+
use forge_display::StatusDisplay;
45
use forge_domain::{Environment, Usage};
56
use tokio::fs;
67

78
use crate::console::CONSOLE;
89
use crate::editor::{ForgeEditor, ReadResult};
910
use crate::model::{Command, UserInput};
1011
use crate::prompt::ForgePrompt;
11-
use crate::status::StatusDisplay;
1212

1313
/// Console implementation for handling user input via command line.
1414
#[derive(Debug, Default)]

‎crates/forge_main/src/lib.rs‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ mod log;
1111
mod model;
1212
mod normalize;
1313
mod prompt;
14-
mod status;
1514
mod ui;
1615

1716
pub use ui::UI;

‎crates/forge_main/src/ui.rs‎

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ use anyhow::Result;
44
use clap::Parser;
55
use colored::Colorize;
66
use forge_app::{APIService, EnvironmentFactory, Service};
7+
use forge_display::StatusDisplay;
78
use forge_domain::{ChatRequest, ChatResponse, ConversationId, Model, ModelId, Usage};
89
use tokio_stream::StreamExt;
910

@@ -13,7 +14,6 @@ use crate::console::CONSOLE;
1314
use crate::info::Info;
1415
use crate::input::{Console, PromptInput};
1516
use crate::model::{Command, ConfigCommand, UserInput};
16-
use crate::status::StatusDisplay;
1717
use crate::{banner, log};
1818

1919
#[derive(Default)]
@@ -254,18 +254,23 @@ impl UI {
254254
CONSOLE.newline()?;
255255
}
256256
ChatResponse::ToolCallEnd(tool_result) => {
257-
let tool_name = tool_result.name.as_str();
258-
// Always show result content for errors, or in verbose mode
259-
if tool_result.is_error || self.cli.verbose {
260-
CONSOLE.writeln(format!("{}", tool_result.content.dimmed()))?;
257+
if !self.cli.verbose {
258+
return Ok(());
261259
}
262-
let status = if tool_result.is_error {
263-
StatusDisplay::failed(tool_name, self.state.usage.clone())
264-
} else {
265-
StatusDisplay::success(tool_name, self.state.usage.clone())
266-
};
267260

268-
CONSOLE.writeln(status.format())?;
261+
let tool_name = tool_result.name.as_str();
262+
263+
CONSOLE.writeln(format!("{}", tool_result.content.dimmed()))?;
264+
265+
if tool_result.is_error {
266+
CONSOLE.writeln(
267+
StatusDisplay::failed(tool_name, self.state.usage.clone()).format(),
268+
)?;
269+
} else {
270+
CONSOLE.writeln(
271+
StatusDisplay::success(tool_name, self.state.usage.clone()).format(),
272+
)?;
273+
}
269274
}
270275
ChatResponse::ConversationStarted(conversation_id) => {
271276
self.state.current_conversation_id = Some(conversation_id);

0 commit comments

Comments
 (0)