Add --version flag showing git tag and sha

```
│  Agent powering down. Goodbye!
│
│  Interaction Summary
│  Session ID:                 66751fe9-fcad-4221-a90a-34d84d303807
│  Tool Calls:                 15 ( ✓ 15 x 0 )
│  Success Rate:               100.0%
│  User Agreement:             100.0% (15 reviewed)
│  Code Changes:               +81 -0
│
│  Performance
│  Wall Time:                  9m 51s
│  Agent Active:               2m 50s
│    » API Time:               1m 40s (58.6%)
│    » Tool Time:              1m 10s (41.4%)
│
│
│  Model Usage                 Reqs   Input Tokens   Cache Reads  Output Tokens
│  ────────────────────────────────────────────────────────────────────────────
│  gemini-2.5-flash-lite          2          2,635             0            199
│  gemini-3-pro-preview          15         54,232       163,544          1,828
│
│  Savings Highlight: 163,544 (74.2%) of input tokens were served from the cache, reducing costs.
```
This commit is contained in:
2026-01-10 14:17:25 -05:00
parent f13906d762
commit 4c2086e2b4
3 changed files with 81 additions and 0 deletions

42
build.rs Normal file
View File

@@ -0,0 +1,42 @@
use std::process::Command;
fn main() {
// Only re-run if .git state changes
println!("cargo:rerun-if-changed=.git/HEAD");
println!("cargo:rerun-if-changed=.git/refs/tags");
let output = Command::new("git")
.args(["describe", "--tags", "--exact-match"])
.output();
let version = if let Ok(output) = output {
if output.status.success() {
// Exact tag match
String::from_utf8(output.stdout).unwrap().trim().to_string()
} else {
// Not an exact match, construct version string
let tag_output = Command::new("git")
.args(["describe", "--tags", "--abbrev=0"])
.output()
.expect("Failed to execute git describe");
let sha_output = Command::new("git")
.args(["rev-parse", "--short", "HEAD"])
.output()
.expect("Failed to execute git rev-parse");
if tag_output.status.success() && sha_output.status.success() {
let tag = String::from_utf8(tag_output.stdout).unwrap().trim().to_string();
let sha = String::from_utf8(sha_output.stdout).unwrap().trim().to_string();
format!("{}-g{}", tag, sha)
} else {
// Fallback if git fails or no tags
"unknown".to_string()
}
}
} else {
"unknown".to_string()
};
println!("cargo:rustc-env=GIT_VERSION={}", version);
}