Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
root = true

[*]
indent_style = space
indent_size = 4
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

[*.{yml,yaml}]
indent_size = 2

[*.md]
trim_trailing_whitespace = false
2 changes: 2 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ jobs:
SCCACHE_GHA_ENABLED: "true"
steps:
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7
with:
fetch-depth: 0
- uses: Swatinem/rust-cache@e18b497796c12c097a38f9edb9d0641fb99eee32 # v2 # zizmor: ignore[cache-poisoning] save-if already gates writes to master
with:
save-if: ${{ github.ref == 'refs/heads/master' }}
Expand Down
89 changes: 89 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 15 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
[package]
name = "agentflare"
version = "1.1.0"
edition = "2021"
edition = "2024"
rust-version = "1.91"
description = "Optimize AI CLI agents for cost and performance."
license = "MIT"
repository = "https://github.com/getappz/agentflare"
Expand Down Expand Up @@ -49,7 +50,20 @@ aes-gcm = "0.10"
pbkdf2 = { version = "0.12", features = ["simple"] }
rpassword = "7"

[build-dependencies]
built = { version = "0.8", features = ["chrono"] }

[dev-dependencies]
insta = { version = "1", features = ["json"] }
pretty_assertions = "1"

[lints.rust]
unsafe_code = "warn"

[profile.release]
opt-level = 3
lto = "thin"
strip = true

[profile.dev]
debug = 1
3 changes: 3 additions & 0 deletions build.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
fn main() {
built::write_built_file().expect("Failed to write build info");
}
26 changes: 26 additions & 0 deletions cliff.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
[changelog]
header = "# Changelog\n"
body = """
{% for group, commits in commits | group_by(attribute="group") %}
### {{ group | upper_first }}
{% for commit in commits %}
- {{ commit.message | upper_first }}
{%- endfor %}
{% endfor %}
"""
trim = true

[git]
conventional_commits = true
filter_unconventional = false
commit_parsers = [
{ message = "^feat", group = "Features" },
{ message = "^fix", group = "Bug Fixes" },
{ message = "^docs", group = "Documentation" },
{ message = "^perf", group = "Performance" },
{ message = "^refactor", group = "Refactor" },
{ message = "^style", group = "Styling" },
{ message = "^test", group = "Testing" },
{ message = "^chore", group = "Miscellaneous Tasks" },
{ message = "^ci", group = "CI" },
]
12 changes: 6 additions & 6 deletions src/agent_detect.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,11 @@ mod find_binary_tests {
let _ = std::fs::remove_dir_all(&dir);
std::fs::create_dir_all(&dir).unwrap();
let original = std::env::var_os("PATH");
std::env::set_var("PATH", &dir);
unsafe { std::env::set_var("PATH", &dir) };
f(&dir);
match original {
Some(p) => std::env::set_var("PATH", p),
None => std::env::remove_var("PATH"),
Some(p) => unsafe { std::env::set_var("PATH", p) },
None => unsafe { std::env::remove_var("PATH") },
}
let _ = std::fs::remove_dir_all(&dir);
}
Expand Down Expand Up @@ -455,11 +455,11 @@ mod detect_all_tests {
let _ = std::fs::remove_dir_all(&dir);
std::fs::create_dir_all(&dir).unwrap();
let original = std::env::var_os("PATH");
std::env::set_var("PATH", &dir);
unsafe { std::env::set_var("PATH", &dir) };
f(&dir);
match original {
Some(p) => std::env::set_var("PATH", p),
None => std::env::remove_var("PATH"),
Some(p) => unsafe { std::env::set_var("PATH", p) },
None => unsafe { std::env::remove_var("PATH") },
}
let _ = std::fs::remove_dir_all(&dir);
}
Expand Down
6 changes: 3 additions & 3 deletions src/agents.rs
Original file line number Diff line number Diff line change
Expand Up @@ -213,11 +213,11 @@ mod tests {
let _ = std::fs::remove_dir_all(&dir);
std::fs::create_dir_all(&dir).unwrap();
let original = std::env::var_os("PATH");
std::env::set_var("PATH", &dir);
unsafe { std::env::set_var("PATH", &dir) };
f(&dir);
match original {
Some(p) => std::env::set_var("PATH", p),
None => std::env::remove_var("PATH"),
Some(p) => unsafe { std::env::set_var("PATH", p) },
None => unsafe { std::env::remove_var("PATH") },
}
let _ = std::fs::remove_dir_all(&dir);
}
Expand Down
14 changes: 14 additions & 0 deletions src/build_time.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
use chrono::{DateTime, FixedOffset};
use std::sync::LazyLock as Lazy;

pub mod built_info {
include!(concat!(env!("OUT_DIR"), "/built.rs"));
}

pub static BUILD_TIME: Lazy<DateTime<FixedOffset>> =
Lazy::new(|| {
DateTime::parse_from_rfc2822(built_info::BUILT_TIME_UTC)
.expect("built_info::BUILT_TIME_UTC should always be a valid RFC2822 timestamp")
});

pub static TARGET: &str = built_info::TARGET;
13 changes: 12 additions & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ mod auth;
mod auth_crypt;
mod auth_db;
mod auth_runner;
mod build_time;
mod components;
mod coaching;
mod cost;
Expand All @@ -27,9 +28,19 @@ mod update;

use agent_registry::Agent;
use clap::{Parser, Subcommand};
use std::sync::LazyLock;

static AGENTFLARE_VERSION: LazyLock<String> = LazyLock::new(|| {
let build_time_str = build_time::BUILD_TIME.format("%Y-%m-%d");
format!(
"{} {} ({build_time_str})",
env!("CARGO_PKG_VERSION"),
build_time::TARGET,
)
});

#[derive(Parser)]
#[command(name = "agentflare", version, about = "Optimize AI CLI agents for cost and performance")]
#[command(name = "agentflare", version = AGENTFLARE_VERSION.as_str(), about = "Optimize AI CLI agents for cost and performance")]
struct Cli {
#[command(subcommand)]
command: Commands,
Expand Down
4 changes: 2 additions & 2 deletions src/paths.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ pub(crate) mod test_support {
let dir = std::env::temp_dir().join("agentflare-test-home");
let _ = std::fs::remove_dir_all(&dir);
std::fs::create_dir_all(&dir).unwrap();
std::env::set_var("AGENTFLARE_HOME_OVERRIDE", &dir);
unsafe { std::env::set_var("AGENTFLARE_HOME_OVERRIDE", &dir) };
let result = f();
std::env::remove_var("AGENTFLARE_HOME_OVERRIDE");
unsafe { std::env::remove_var("AGENTFLARE_HOME_OVERRIDE") };
result
}

Expand Down
Loading