defect-cli 0.1.0-alpha.6

defect: a highly configurable, ACP-native, resource-frugal headless general-purpose agent CLI.
Documentation
[package]
name = "defect-cli"
version.workspace = true
edition.workspace = true
license.workspace = true
repository.workspace = true
description = "defect: a highly configurable, ACP-native, resource-frugal headless general-purpose agent CLI."

# cargo-binstall:让下游 `cargo binstall defect-cli` 直接拉 GitHub Release 的预构建二进制,
# 免去从源码 fat-LTO 全量编译。asset 命名与 .github/workflows/release.yml 的打包步骤对齐:
# defect-v<version>-<target>.{tar.gz|zip},归档内二进制位于根部(defect / defect.exe)。
# 注意 tag 带 `v` 前缀而 { version } 不含,故模板里显式补 `v`。
[package.metadata.binstall]
pkg-url = "{ repo }/releases/download/v{ version }/defect-v{ version }-{ target }{ archive-suffix }"
bin-dir = "{ bin }{ binary-ext }"
pkg-fmt = "tgz"

[package.metadata.binstall.overrides.x86_64-pc-windows-msvc]
pkg-fmt = "zip"

[lib]
name = "defect_cli"
path = "src/lib.rs"

[[bin]]
name = "defect"
path = "src/bin/cli.rs"

# MCP 测试桩:仅集成测试用,绝不进 release/binstall 产物。放在 examples/ 而非
# src/bin/ —— `[[bin]]` 会被 cargo-binstall 枚举进已发布 crate 的 bin 列表并告警,
# examples 则天然被 install/binstall 忽略。`cargo test --features __test-servers`
# 会先编出 target/<profile>/examples/<name>,smoke test 经 current_exe 旁路定位。
[[example]]
name = "defect-mcp-test-server"
path = "examples/mcp_test_server.rs"
required-features = ["__test-servers"]

[[example]]
name = "defect-mcp-streamable-http-test-server"
path = "examples/mcp_streamable_http_test_server.rs"
required-features = ["__test-servers"]

[features]
# 默认全开所有 provider(与裁剪前行为一致)。按厂商裁剪二进制:
# `cargo build --no-default-features --features provider-anthropic`。
# echo provider 在 defect-acp,零额外依赖,永不 gate(兜底);
# litellm 复用 openai provider 实现,跟随 provider-openai。
default = [
    "provider-anthropic",
    "provider-bedrock",
    "provider-openai",
    "provider-deepseek",
    "yaml",
    "repl",
    "oneshot",
    "init",
]

# `--repl`:进程内最小交互 REPL(tokio stdin/stdout + owo-colors 着色),
# 不走 ACP。可裁剪:`--no-default-features` 时不编译 repl 模块也不拖入
# owo-colors,`--repl` flag 在运行期报错提示重新带 feature 编译。
repl = ["dep:owo-colors", "dep:crossterm"]

# `--message`:单轮无人值守模式(CI / 脚本)。与 `repl` 解耦——本 feature 不拖入
# owo-colors / crossterm,故 `--no-default-features --features oneshot` 能编出
# 不含 TUI 依赖的精简 CI 二进制。serde_json 已是无条件依赖,无需额外 dep。
oneshot = []

# `defect init`:扫描环境里的 provider api-key、交互式写全局 config.toml。
# 拖入 inquire(Select/MultiSelect/Confirm,社区事实标准的交互 prompt 库)。
# 裁剪后 `defect init` 的交互路径在运行期硬失败,但 `defect init --yes` 非交互
# 路径不依赖本 feature(扫描+模板写盘都是无依赖逻辑),CI 仍可用。
init = ["dep:inquire"]

# 转发给 defect-llm 的同名 feature。
provider-anthropic = ["defect-llm/provider-anthropic"]
provider-bedrock = ["defect-llm/provider-bedrock"]
provider-openai = ["defect-llm/provider-openai"]
provider-deepseek = ["defect-llm/provider-deepseek"]

# 转发给 defect-config:单文件 profile / 未来 skill 的 YAML frontmatter 支持。
# defect-config 默认即开 yaml 且本 crate 未关其 default,故去掉本行仍带 yaml;
# 显式转发是为了让 `--no-default-features` 能裁出无 yaml 的二进制。
yaml = ["defect-config/yaml"]

# 仅给集成测试用:拉起内嵌 MCP server 校验 client/transport round-trip。
# 主 release bin 不需要——开启后会拖入 rmcp 的完整 server side(schema 派生 +
# transport-streamable-http-server)以及 axum,二进制至少 +400KB .text。
# 双下划线前缀表示"内部"feature,下游不要直接依赖;workspace 内
# `cargo test -p defect-cli --features __test-servers` 显式启用。
__test-servers = ["dep:rmcp", "dep:axum"]

[dependencies]
defect-acp.workspace = true
defect-agent.workspace = true
agent-client-protocol-schema.workspace = true
defect-config.workspace = true
defect-http.workspace = true
defect-llm.workspace = true
http.workspace = true
defect-mcp.workspace = true
defect-obs.workspace = true
defect-storage.workspace = true
defect-tools.workspace = true
futures.workspace = true
thiserror.workspace = true
tokio.workspace = true
tracing.workspace = true
tracing-subscriber.workspace = true
anyhow.workspace = true
clap.workspace = true
directories.workspace = true
serde.workspace = true
serde_json.workspace = true

# 仅 `repl` feature:终端着色 + 跨平台 raw 行编辑。可裁剪,不影响 ACP 主路径。
owo-colors = { workspace = true, optional = true }
crossterm = { workspace = true, optional = true }

# 仅 `init` feature:`defect init` 的交互式 prompt(Select/MultiSelect/Confirm)。
inquire = { version = "0.7", optional = true }

# 仅在 `__test-servers` feature 下启用:拖入完整 rmcp server + axum 用于
# 跑 stdio / streamable-http MCP server 测试桩。
rmcp = { workspace = true, features = ["server", "transport-streamable-http-server"], optional = true }
axum = { version = "0.8", optional = true }

[dev-dependencies]
agent-client-protocol.workspace = true
futures.workspace = true
serde_json.workspace = true
tokio-util.workspace = true
wiremock.workspace = true
tempfile.workspace = true
# `defect init` 渲染的 config.toml 在测试里做 round-trip 解析校验。
toml = "0.8"

# `mcp_stdio_smoke` 通过 `CARGO_BIN_EXE_*` 拉起两个 test bin,
# 没启用 `__test-servers` feature 时这俩 bin 不会被编译,integration
# test 也跟着 gate 掉,避免 `env!` 宏在编译期报"未定义 env var"。
[[test]]
name = "mcp_stdio_smoke"
path = "tests/mcp_stdio_smoke.rs"
required-features = ["__test-servers"]

[lints]
workspace = true