|
1 | | -/// plugin_info — version check, host metadata, decision log, and (Windows-only) self-update. |
2 | | -/// |
3 | | -/// The `plugin_info` MCP tool is always available and returns: |
4 | | -/// - current embedded version |
5 | | -/// - latest GitHub release version (when reachable) |
6 | | -/// - whether an update is available |
7 | | -/// - host system metadata |
8 | | -/// - path to the decision/update log |
9 | | -/// |
10 | | -/// Subcommands (passed as the optional `subcommand` argument): |
11 | | -/// - `"check"` (default) — version info + host metadata |
12 | | -/// - `"upgrade"` — Windows-only; downloads and applies the latest release |
13 | | -/// - `"cleanup"` — removes `*.old.exe` and `*.new.exe` backup files |
| 1 | +//! plugin_info — version check, host metadata, decision log, and (Windows-only) self-update. |
| 2 | +//! |
| 3 | +//! The `plugin_info` MCP tool is always available and returns: |
| 4 | +//! - current embedded version |
| 5 | +//! - latest GitHub release version (when reachable) |
| 6 | +//! - whether an update is available |
| 7 | +//! - host system metadata |
| 8 | +//! - path to the decision/update log |
| 9 | +//! |
| 10 | +//! Subcommands (passed as the optional `subcommand` argument): |
| 11 | +//! - `"check"` (default) — version info + host metadata |
| 12 | +//! - `"upgrade"` — Windows-only; downloads and applies the latest release |
| 13 | +//! - `"cleanup"` — removes `*.old.exe` and `*.new.exe` backup files |
14 | 14 |
|
15 | 15 | use std::path::PathBuf; |
16 | 16 | use std::time::{SystemTime, UNIX_EPOCH}; |
@@ -108,6 +108,7 @@ pub fn host_metadata() -> Value { |
108 | 108 | .map(|n| n.get()) |
109 | 109 | .unwrap_or(0); |
110 | 110 |
|
| 111 | + #[cfg_attr(not(target_os = "windows"), allow(unused_mut))] |
111 | 112 | let mut meta = json!({ |
112 | 113 | "os": std::env::consts::OS, |
113 | 114 | "arch": std::env::consts::ARCH, |
@@ -386,6 +387,7 @@ fn strip_zone_identifier(path: &std::path::Path) { |
386 | 387 | } |
387 | 388 |
|
388 | 389 | /// BLAKE3 hex digest of a file's contents; returns `""` on any I/O error. |
| 390 | +#[cfg(all(target_os = "windows", feature = "self-update"))] |
389 | 391 | fn blake3_file(path: &std::path::Path) -> String { |
390 | 392 | std::fs::read(path) |
391 | 393 | .map(|bytes| blake3::hash(&bytes).to_hex().to_string()) |
@@ -557,6 +559,7 @@ mod tests { |
557 | 559 | assert!(schema["properties"]["subcommand"]["enum"].is_array()); |
558 | 560 | } |
559 | 561 |
|
| 562 | + #[cfg(all(target_os = "windows", feature = "self-update"))] |
560 | 563 | #[test] |
561 | 564 | fn blake3_file_empty_for_missing_path() { |
562 | 565 | assert_eq!(blake3_file(std::path::Path::new("/no/such/file.bin")), ""); |
|
0 commit comments