cli: remove insomnia-pod binary output
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
use std::ffi::{OsStr, OsString};
|
||||
use std::ffi::OsString;
|
||||
use std::fmt;
|
||||
use std::io;
|
||||
use std::path::{Path, PathBuf};
|
||||
@@ -28,21 +28,15 @@ impl PodRuntimeCommand {
|
||||
}
|
||||
|
||||
pub fn for_executable(program: impl Into<PathBuf>) -> Self {
|
||||
let program = program.into();
|
||||
let prefix_args = if is_legacy_pod_binary(&program) {
|
||||
Vec::new()
|
||||
} else {
|
||||
vec![OsString::from("pod")]
|
||||
};
|
||||
Self::new(program, prefix_args)
|
||||
Self::new(program, vec![OsString::from("pod")])
|
||||
}
|
||||
|
||||
/// Resolve the Pod runtime command used for subprocess launches.
|
||||
///
|
||||
/// `INSOMNIA_POD_COMMAND` is intentionally executable-only: its value is
|
||||
/// used as the program path without shell parsing and without the unified
|
||||
/// `pod` prefix arg. That keeps existing development/test overrides safe
|
||||
/// while the default path moves to `current_exe() + ["pod"]`.
|
||||
/// `pod` prefix arg. That keeps development/test overrides safe while the
|
||||
/// default path is always `current_exe() + ["pod"]`.
|
||||
pub fn resolve() -> io::Result<Self> {
|
||||
if let Some(command) = Self::from_override_env() {
|
||||
return Ok(command);
|
||||
@@ -87,14 +81,6 @@ impl fmt::Display for PodRuntimeCommand {
|
||||
}
|
||||
}
|
||||
|
||||
fn is_legacy_pod_binary(program: &Path) -> bool {
|
||||
let Some(file_name) = program.file_name().and_then(OsStr::to_str) else {
|
||||
return false;
|
||||
};
|
||||
let stem = file_name.strip_suffix(".exe").unwrap_or(file_name);
|
||||
stem == "insomnia-pod"
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
@@ -137,17 +123,17 @@ mod tests {
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn legacy_wrapper_keeps_executable_only_command() {
|
||||
let command = PodRuntimeCommand::for_executable("/opt/insomnia/bin/insomnia-pod");
|
||||
fn any_runtime_executable_gets_pod_prefix() {
|
||||
let command = PodRuntimeCommand::for_executable("/opt/insomnia/bin/custom-runtime");
|
||||
|
||||
assert_eq!(
|
||||
command.program(),
|
||||
Path::new("/opt/insomnia/bin/insomnia-pod")
|
||||
Path::new("/opt/insomnia/bin/custom-runtime")
|
||||
);
|
||||
assert!(command.prefix_args().is_empty());
|
||||
assert_eq!(command.prefix_args(), [OsString::from("pod")]);
|
||||
assert_eq!(
|
||||
command.argv_with(["--pod", "agent"]),
|
||||
vec!["--pod", "agent"]
|
||||
vec!["pod", "--pod", "agent"]
|
||||
.into_iter()
|
||||
.map(OsString::from)
|
||||
.collect::<Vec<_>>()
|
||||
|
||||
@@ -3,10 +3,7 @@ name = "pod"
|
||||
version = "0.1.0"
|
||||
edition.workspace = true
|
||||
license.workspace = true
|
||||
|
||||
[[bin]]
|
||||
name = "insomnia-pod"
|
||||
path = "src/main.rs"
|
||||
autobins = false
|
||||
|
||||
[dependencies]
|
||||
async-trait = { workspace = true }
|
||||
|
||||
@@ -191,7 +191,7 @@ fn load_single_manifest(
|
||||
}
|
||||
|
||||
pub async fn run_cli() -> ExitCode {
|
||||
run_cli_from("insomnia-pod", std::env::args_os().skip(1)).await
|
||||
run_cli_from("insomnia pod", std::env::args_os().skip(1)).await
|
||||
}
|
||||
|
||||
pub async fn run_cli_from<I, T>(bin_name: &'static str, args: I) -> ExitCode
|
||||
@@ -444,7 +444,7 @@ permission = "write"
|
||||
#[test]
|
||||
fn user_manifest_flag_is_not_accepted() {
|
||||
let err =
|
||||
Cli::try_parse_from(["insomnia-pod", "--user-manifest", "manifest.toml"]).unwrap_err();
|
||||
Cli::try_parse_from(["insomnia pod", "--user-manifest", "manifest.toml"]).unwrap_err();
|
||||
assert_eq!(err.kind(), clap::error::ErrorKind::UnknownArgument);
|
||||
}
|
||||
|
||||
@@ -460,7 +460,7 @@ permission = "write"
|
||||
#[test]
|
||||
fn manifest_conflicts_with_project() {
|
||||
let project_err = Cli::try_parse_from([
|
||||
"insomnia-pod",
|
||||
"insomnia pod",
|
||||
"--manifest",
|
||||
"manifest.toml",
|
||||
"--project",
|
||||
@@ -472,7 +472,7 @@ permission = "write"
|
||||
|
||||
#[test]
|
||||
fn overlay_flag_is_not_accepted() {
|
||||
let err = Cli::try_parse_from(["insomnia-pod", "--overlay", "pod.name = 'x'"]).unwrap_err();
|
||||
let err = Cli::try_parse_from(["insomnia pod", "--overlay", "pod.name = 'x'"]).unwrap_err();
|
||||
assert_eq!(err.kind(), clap::error::ErrorKind::UnknownArgument);
|
||||
}
|
||||
|
||||
@@ -481,7 +481,7 @@ permission = "write"
|
||||
let tmp = TempDir::new().unwrap();
|
||||
let manifest = tmp.path().join("manifest.toml");
|
||||
write(&manifest, &manifest_toml("single", tmp.path()));
|
||||
let cli = Cli::try_parse_from(["insomnia-pod", "--manifest", manifest.to_str().unwrap()])
|
||||
let cli = Cli::try_parse_from(["insomnia pod", "--manifest", manifest.to_str().unwrap()])
|
||||
.unwrap();
|
||||
|
||||
let (manifest, loader) = resolve_manifest(&cli).unwrap();
|
||||
@@ -496,7 +496,7 @@ permission = "write"
|
||||
let tmp = TempDir::new().unwrap();
|
||||
let profile = tmp.path().join("profile.lua");
|
||||
let cli = Cli::try_parse_from([
|
||||
"insomnia-pod",
|
||||
"insomnia pod",
|
||||
"--profile",
|
||||
profile.to_str().unwrap(),
|
||||
"--profile-pod-name",
|
||||
@@ -529,7 +529,7 @@ permission = "write"
|
||||
fn profile_accepts_source_qualified_discovered_name() {
|
||||
let tmp = TempDir::new().unwrap();
|
||||
let cli = Cli::try_parse_from([
|
||||
"insomnia-pod",
|
||||
"insomnia pod",
|
||||
"--profile",
|
||||
"project:coder",
|
||||
"--profile-pod-name",
|
||||
@@ -564,7 +564,7 @@ permission = "write"
|
||||
#[test]
|
||||
fn normal_startup_uses_default_profile() {
|
||||
let tmp = TempDir::new().unwrap();
|
||||
let cli = Cli::try_parse_from(["insomnia-pod"]).unwrap();
|
||||
let cli = Cli::try_parse_from(["insomnia pod"]).unwrap();
|
||||
let mut called = false;
|
||||
|
||||
let (manifest, _loader) =
|
||||
@@ -585,7 +585,7 @@ permission = "write"
|
||||
|
||||
#[test]
|
||||
fn project_flag_no_longer_enables_ambient_manifest_cascade() {
|
||||
let cli = Cli::try_parse_from(["insomnia-pod", "--project", "."]).unwrap();
|
||||
let cli = Cli::try_parse_from(["insomnia pod", "--project", "."]).unwrap();
|
||||
let err = resolve_manifest_with_profile_loader(&cli, |_, _| {
|
||||
panic!("default profile loader must not run when deprecated --project is present")
|
||||
})
|
||||
@@ -597,7 +597,7 @@ permission = "write"
|
||||
fn pod_flag_conflicts_with_session() {
|
||||
let segment_id = session_store::new_segment_id();
|
||||
let segment_id = segment_id.to_string();
|
||||
let err = Cli::try_parse_from(["insomnia-pod", "--pod", "agent", "--session", &segment_id])
|
||||
let err = Cli::try_parse_from(["insomnia pod", "--pod", "agent", "--session", &segment_id])
|
||||
.unwrap_err();
|
||||
assert_eq!(err.kind(), clap::error::ErrorKind::ArgumentConflict);
|
||||
}
|
||||
@@ -608,7 +608,7 @@ permission = "write"
|
||||
let manifest = tmp.path().join("manifest.toml");
|
||||
write(&manifest, &manifest_toml("from-file", tmp.path()));
|
||||
let cli = Cli::try_parse_from([
|
||||
"insomnia-pod",
|
||||
"insomnia pod",
|
||||
"--manifest",
|
||||
manifest.to_str().unwrap(),
|
||||
"--pod",
|
||||
@@ -640,7 +640,7 @@ permission = "write"
|
||||
"#,
|
||||
);
|
||||
let cli = Cli::try_parse_from([
|
||||
"insomnia-pod",
|
||||
"insomnia pod",
|
||||
"--manifest",
|
||||
manifest.to_str().unwrap(),
|
||||
"--pod",
|
||||
@@ -657,7 +657,7 @@ permission = "write"
|
||||
#[test]
|
||||
fn pod_flag_with_no_manifest_creates_from_default_profile_with_typed_name() {
|
||||
let tmp = TempDir::new().unwrap();
|
||||
let cli = Cli::try_parse_from(["insomnia-pod", "--pod", "agent"]).unwrap();
|
||||
let cli = Cli::try_parse_from(["insomnia pod", "--pod", "agent"]).unwrap();
|
||||
let mut called = false;
|
||||
|
||||
let (manifest, _loader) =
|
||||
@@ -683,10 +683,10 @@ permission = "write"
|
||||
fn profile_conflicts_with_manifest_and_restore_modes() {
|
||||
let segment_id = session_store::new_segment_id().to_string();
|
||||
for args in [
|
||||
vec!["insomnia-pod", "--profile", "p.lua", "--manifest", "m.toml"],
|
||||
vec!["insomnia-pod", "--profile", "p.lua", "--pod", "agent"],
|
||||
vec!["insomnia pod", "--profile", "p.lua", "--manifest", "m.toml"],
|
||||
vec!["insomnia pod", "--profile", "p.lua", "--pod", "agent"],
|
||||
vec![
|
||||
"insomnia-pod",
|
||||
"insomnia pod",
|
||||
"--profile",
|
||||
"p.lua",
|
||||
"--session",
|
||||
@@ -700,14 +700,14 @@ permission = "write"
|
||||
|
||||
#[test]
|
||||
fn profile_pod_name_requires_profile() {
|
||||
let err = Cli::try_parse_from(["insomnia-pod", "--profile-pod-name", "agent"]).unwrap_err();
|
||||
let err = Cli::try_parse_from(["insomnia pod", "--profile-pod-name", "agent"]).unwrap_err();
|
||||
assert_eq!(err.kind(), clap::error::ErrorKind::MissingRequiredArgument);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn profile_pod_name_is_not_restore_pod_flag() {
|
||||
let cli = Cli::try_parse_from([
|
||||
"insomnia-pod",
|
||||
"insomnia pod",
|
||||
"--profile",
|
||||
"p.lua",
|
||||
"--profile-pod-name",
|
||||
@@ -726,7 +726,7 @@ permission = "write"
|
||||
std::fs::create_dir_all(tmp.path().join("prompts")).unwrap();
|
||||
std::fs::create_dir_all(tmp.path().join(".insomnia").join("prompts")).unwrap();
|
||||
let cli = Cli::try_parse_from([
|
||||
"insomnia-pod",
|
||||
"insomnia pod",
|
||||
"--manifest",
|
||||
single_manifest.to_str().unwrap(),
|
||||
])
|
||||
|
||||
@@ -1,6 +0,0 @@
|
||||
use std::process::ExitCode;
|
||||
|
||||
#[tokio::main]
|
||||
async fn main() -> ExitCode {
|
||||
pod::entrypoint::run_cli().await
|
||||
}
|
||||
@@ -2,7 +2,7 @@
|
||||
//!
|
||||
//! These tests exercise the tool's pod-registry delegation, subprocess
|
||||
//! launch, socket handoff, and `spawned_pods.json` write without relying
|
||||
//! on the real `insomnia-pod` binary. `INSOMNIA_POD_COMMAND` is pointed at
|
||||
//! on the real Pod runtime executable. `INSOMNIA_POD_COMMAND` is pointed at
|
||||
//! `/bin/true` (which exits immediately) while a test-owned Unix
|
||||
//! listener pre-binds the predicted socket path, so the tool sees the
|
||||
//! "child" as live.
|
||||
|
||||
Reference in New Issue
Block a user