Skip to content

Commit 451a60b

Browse files
authored
Merge pull request #42 from tcdent/claude/reduce-library-dependencies-wgtuc
WIP: Add feature flags to reduce library dependencies
2 parents 6aa1700 + d5c1a90 commit 451a60b

10 files changed

Lines changed: 300 additions & 156 deletions

File tree

Cargo.toml

Lines changed: 25 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@ name = "codey"
1616
path = "src/main.rs"
1717

1818
[dependencies]
19-
# TUI
20-
ratatui = { version = "0.30.0-beta.0", features = ["scrolling-regions"] }
21-
crossterm = { version = "0.28", features = ["event-stream"] }
19+
# TUI (CLI only)
20+
ratatui = { version = "0.30.0-beta.0", features = ["scrolling-regions"], optional = true }
21+
crossterm = { version = "0.28", features = ["event-stream"], optional = true }
2222

2323
# Async runtime
2424
tokio = { version = "1", features = ["full"] }
@@ -31,10 +31,10 @@ genai = "0.4.4"
3131
reqwest = { version = "0.12", features = ["stream", "json", "rustls-tls"], default-features = false }
3232
futures = "0.3"
3333

34-
# Web content extraction (reader view)
35-
chromiumoxide = { version = "0.7", features = ["tokio-runtime"], default-features = false }
36-
readability = "0.3"
37-
htmd = "0.1"
34+
# Web content extraction (CLI only - reader view)
35+
chromiumoxide = { version = "0.7", features = ["tokio-runtime"], default-features = false, optional = true }
36+
readability = { version = "0.3", optional = true }
37+
htmd = { version = "0.1", optional = true }
3838

3939
# Serialization
4040
serde = { version = "1", features = ["derive"] }
@@ -44,8 +44,8 @@ serde_json = "1"
4444
toml = "0.8"
4545
dirs = "5"
4646

47-
# CLI arguments
48-
clap = { version = "4", features = ["derive", "env"] }
47+
# CLI arguments (CLI only)
48+
clap = { version = "4", features = ["derive", "env"], optional = true }
4949

5050
# Error handling
5151
anyhow = "1"
@@ -61,7 +61,7 @@ urlencoding = "2"
6161
base64 = "0.22"
6262
sha2 = "0.10"
6363
rand = "0.8"
64-
open = "5"
64+
open = { version = "5", optional = true }
6565

6666
# Logging
6767
tracing = "0.1"
@@ -71,12 +71,14 @@ tracing-subscriber = { version = "0.3", features = ["env-filter"] }
7171
async-trait = "0.1"
7272
async-stream = "0.3"
7373
dotenvy = "0.15.7"
74-
ratskin = "0.3"
7574
typetag = "0.2.21"
7675

77-
# Neovim RPC
78-
nvim-rs = { version = "0.9", features = ["use_tokio"] }
79-
textwrap = "0.16.2"
76+
# TUI rendering (CLI only)
77+
ratskin = { version = "0.3", optional = true }
78+
textwrap = { version = "0.16.2", optional = true }
79+
80+
# Neovim RPC (CLI only)
81+
nvim-rs = { version = "0.9", features = ["use_tokio"], optional = true }
8082

8183
[dev-dependencies]
8284
tokio-test = "0.4"
@@ -92,7 +94,15 @@ strip = false
9294
debug = true
9395

9496
[features]
95-
default = []
97+
default = ["cli"]
98+
99+
# Full CLI with TUI, IDE integration, and web extraction
100+
cli = [
101+
"ratatui", "crossterm", "clap", "nvim-rs", "open",
102+
"chromiumoxide", "readability", "htmd",
103+
"ratskin", "textwrap"
104+
]
105+
96106
# Enable performance profiling with JSON export
97107
# Build with: cargo build --release --features profiling
98108
profiling = ["dep:sysinfo"]

LIBRARY.md

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,30 @@ Add codey to your `Cargo.toml`:
88

99
```toml
1010
[dependencies]
11-
codey = { git = "https://github.com/tcdent/codey" }
11+
codey = { git = "https://github.com/tcdent/codey", default-features = false }
1212
tokio = { version = "1", features = ["full"] }
1313
serde_json = "1"
1414
```
1515

16+
### Lightweight Builds
17+
18+
By default, codey includes the full CLI with TUI rendering, IDE integrations, and web extraction features. For library usage, disable the default features to get a minimal dependency footprint:
19+
20+
```toml
21+
# Minimal library (recommended for integrations)
22+
codey = { git = "https://github.com/tcdent/codey", default-features = false }
23+
24+
# Full CLI features (includes ratatui, crossterm, chromiumoxide, etc.)
25+
codey = { git = "https://github.com/tcdent/codey" }
26+
```
27+
28+
With `default-features = false`, codey pulls only the core dependencies needed for the agent:
29+
- `genai` - LLM client
30+
- `tokio` - Async runtime
31+
- `serde`/`serde_json` - Serialization
32+
- `reqwest` - HTTP client
33+
- Error handling and utilities
34+
1635
### Patched Dependencies
1736

1837
Codey uses a patched version of the `genai` crate. To use Codey as a library, you'll need to apply the same patch in your project's `Cargo.toml`:

0 commit comments

Comments
 (0)