home-dir-layout修正

This commit is contained in:
2026-04-27 22:10:36 +09:00
parent 8658845b02
commit 8cf0bd6374
9 changed files with 94 additions and 26 deletions
+6 -4
View File
@@ -105,10 +105,12 @@ pub fn pod_runtime_dir(pod_name: &str) -> Option<PathBuf> {
Some(runtime_dir()?.join(pod_name))
}
/// `<runtime_dir>/<pod_name>/sock` — Pod の Unix socket パス (TUI が
/// attach 時に使う)。Pod プロセスが実際に socket を作成するのは
/// `RuntimeDir::socket_path()` 経由だが、外部からの予測はこの関数で
/// 行う。
/// `<runtime_dir>/<pod_name>/sock` — Pod の Unix socket パス
///
/// Pod プロセス内で実際に socket を作成するのは `pod` crate の
/// `RuntimeDir::socket_path()` で、Pod 名が分かっている外部 (TUI の
/// attach フロー等) からの**予測**はこの関数で行う。両者は同じパス
/// を返すことが期待される。
pub fn pod_socket_path(pod_name: &str) -> Option<PathBuf> {
Some(pod_runtime_dir(pod_name)?.join("sock"))
}
+18 -4
View File
@@ -95,10 +95,24 @@ async fn main() -> ExitCode {
}
};
// Initialize persistent store
let store_dir = cli.store.clone().unwrap_or_else(|| {
paths::sessions_dir().unwrap_or_else(|| PathBuf::from(".insomnia/sessions"))
});
// Initialize persistent store. `paths::sessions_dir()` only
// returns None when none of INSOMNIA_HOME / INSOMNIA_DATA_DIR /
// HOME is set — surface that as a hard error to match the
// runtime-dir resolution below, rather than silently writing to a
// relative path under cwd.
let store_dir = match cli.store.clone() {
Some(p) => p,
None => match paths::sessions_dir() {
Some(d) => d,
None => {
eprintln!(
"error: could not resolve sessions directory \
(set --store, INSOMNIA_HOME, INSOMNIA_DATA_DIR, or HOME)"
);
return ExitCode::FAILURE;
}
},
};
let store = match FsStore::new(&store_dir).await {
Ok(s) => s,
Err(e) => {
+5 -5
View File
@@ -2,11 +2,11 @@
//!
//! Three prefixes address three physical libraries:
//!
//! | prefix | location |
//! |--------------|----------------------------------------------------|
//! | `$insomnia` | builtin, baked into the binary via `include_dir!` |
//! | `$user` | `$XDG_CONFIG_HOME/insomnia/prompts/` (or similar) |
//! | `$workspace` | `<project>/.insomnia/prompts/` |
//! | prefix | location |
//! |--------------|---------------------------------------------------------|
//! | `$insomnia` | builtin, baked into the binary via `include_dir!` |
//! | `$user` | `<config_dir>/prompts/` (resolved by `manifest::paths`) |
//! | `$workspace` | `<project>/.insomnia/prompts/` |
//!
//! A reference is `$<prefix>/<path>` where `<path>` is a `/`-separated
//! name without the `.md` extension (e.g. `$insomnia/common/header`).
+3 -1
View File
@@ -95,7 +95,9 @@ impl RuntimeDir {
&self.path
}
/// Path where the Unix socket should be created.
/// Path where the Unix socket should be created. External callers
/// that only know the pod name (e.g. the TUI's attach flow)
/// predict the same path via [`manifest::paths::pod_socket_path`].
pub fn socket_path(&self) -> PathBuf {
self.path.join("sock")
}