Skip to content

Commit 3c00e8c

Browse files
refactor(chat): move chat to a separate lib crate (#1347)
1 parent da59663 commit 3c00e8c

30 files changed

+323
-221
lines changed

Cargo.lock

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

Cargo.toml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,13 +50,15 @@ clap = { version = "4.5.32", features = [
5050
"wrap_help",
5151
] }
5252
cocoa = "0.26.0"
53+
color-print = "0.3.5"
5354
convert_case = "0.8.0"
5455
core-foundation = "0.10.0"
5556
core-foundation-sys = "0.8.7"
5657
core-graphics = "0.24.0"
57-
crossterm = "0.28.1"
58+
crossterm = { version = "0.28.1", features = ["event-stream", "events"] }
5859
dashmap = "6.0.1"
5960
dirs = "5.0.0"
61+
eyre = "0.6.8"
6062
fig_api_client = { path = "crates/fig_api_client" }
6163
fig_auth = { path = "crates/fig_auth" }
6264
fig_aws_common = { path = "crates/fig_aws_common" }
@@ -104,6 +106,7 @@ objc2-input-method-kit = "0.2.2"
104106
parking_lot = "0.12.3"
105107
percent-encoding = "2.2.0"
106108
portable-pty = "0.8.1"
109+
q_chat = { path = "crates/q_chat" }
107110
r2d2 = "0.8.10"
108111
r2d2_sqlite = "0.25.0"
109112
rand = "0.9.0"
@@ -130,6 +133,7 @@ serde_json = "1.0.140"
130133
sha2 = "0.10.6"
131134
shlex = "1.3.0"
132135
similar = "2.7.0"
136+
spinners = "4.1.0"
133137
strum = { version = "0.27.1", features = ["derive"] }
134138
sysinfo = "0.32.0"
135139
thiserror = "2.0.12"

crates/q_chat/Cargo.toml

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
[package]
2+
name = "q_chat"
3+
authors.workspace = true
4+
edition.workspace = true
5+
homepage.workspace = true
6+
publish.workspace = true
7+
version.workspace = true
8+
license.workspace = true
9+
10+
[dependencies]
11+
anstream.workspace = true
12+
aws-smithy-types = "1.2.10"
13+
bstr.workspace = true
14+
clap.workspace = true
15+
color-print.workspace = true
16+
convert_case.workspace = true
17+
crossterm.workspace = true
18+
eyre.workspace = true
19+
fig_api_client.workspace = true
20+
fig_auth.workspace = true
21+
fig_diagnostic.workspace = true
22+
fig_os_shim.workspace = true
23+
fig_settings.workspace = true
24+
fig_telemetry.workspace = true
25+
fig_util.workspace = true
26+
futures.workspace = true
27+
glob.workspace = true
28+
rand.workspace = true
29+
regex.workspace = true
30+
rustyline = { version = "15.0.0", features = ["derive", "custom-bindings"] }
31+
serde.workspace = true
32+
serde_json.workspace = true
33+
shell-color.workspace = true
34+
shlex.workspace = true
35+
similar.workspace = true
36+
skim = "0.16.1"
37+
spinners.workspace = true
38+
syntect = { version = "5.2.0", features = [ "default-syntaxes", "default-themes" ]}
39+
tempfile.workspace = true
40+
thiserror.workspace = true
41+
time.workspace = true
42+
tokio.workspace = true
43+
tracing.workspace = true
44+
unicode-width.workspace = true
45+
url.workspace = true
46+
uuid.workspace = true
47+
winnow.workspace = true
48+
strip-ansi-escapes = "0.2.1"
49+
50+
[dev-dependencies]
51+
tracing-subscriber.workspace = true
52+
53+
[lints]
54+
workspace = true

crates/q_chat/src/cli.rs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
use clap::Parser;
2+
3+
#[derive(Debug, Clone, PartialEq, Eq, Default, Parser)]
4+
pub struct Chat {
5+
/// (Deprecated, use --trust-all-tools) Enabling this flag allows the model to execute
6+
/// all commands without first accepting them.
7+
#[arg(short, long, hide = true)]
8+
pub accept_all: bool,
9+
/// Print the first response to STDOUT without interactive mode. This will fail if the
10+
/// prompt requests permissions to use a tool, unless --trust-all-tools is also used.
11+
#[arg(long)]
12+
pub no_interactive: bool,
13+
/// The first question to ask
14+
pub input: Option<String>,
15+
/// Context profile to use
16+
#[arg(long = "profile")]
17+
pub profile: Option<String>,
18+
/// Allows the model to use any tool to run commands without asking for confirmation.
19+
#[arg(long)]
20+
pub trust_all_tools: bool,
21+
/// Trust only this set of tools. Example: trust some tools:
22+
/// '--trust-tools=fs_read,fs_write', trust no tools: '--trust-tools='
23+
#[arg(long, value_delimiter = ',', value_name = "TOOL_NAMES")]
24+
pub trust_tools: Option<Vec<String>>,
25+
}
File renamed without changes.
File renamed without changes.
File renamed without changes.

crates/q_cli/src/cli/chat/hooks.rs renamed to crates/q_chat/src/hooks.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ pub struct CachedHook {
126126
}
127127

128128
/// Maps a hook name to a [`CachedHook`]
129-
#[derive(Debug, Clone)]
129+
#[derive(Debug, Clone, Default)]
130130
pub struct HookExecutor {
131131
pub global_cache: HashMap<String, CachedHook>,
132132
pub profile_cache: HashMap<String, CachedHook>,
File renamed without changes.

0 commit comments

Comments
 (0)