rename: adopt yoi identity
This commit is contained in:
@@ -688,7 +688,7 @@ mod tests {
|
||||
use crate::{Permission, ReasoningEffort, ScopeRule};
|
||||
|
||||
fn abs(path: &str) -> PathBuf {
|
||||
PathBuf::from(format!("/tmp/insomnia-test{path}"))
|
||||
PathBuf::from(format!("/tmp/yoi-test{path}"))
|
||||
}
|
||||
|
||||
fn api_key_file_auth(path: PathBuf) -> AuthRef {
|
||||
@@ -791,14 +791,14 @@ mod tests {
|
||||
fn resolve_paths_joins_relative_auth_file() {
|
||||
let mut cfg = minimal_valid();
|
||||
cfg.model.auth = Some(api_key_file_auth(PathBuf::from("keys/anthropic")));
|
||||
let resolved = cfg.resolve_paths(Path::new("/home/user/.config/insomnia"));
|
||||
let resolved = cfg.resolve_paths(Path::new("/home/user/.config/yoi"));
|
||||
let file = match resolved.model.auth {
|
||||
Some(AuthRef::ApiKey { file, .. }) => file,
|
||||
_ => panic!("expected ApiKey"),
|
||||
};
|
||||
assert_eq!(
|
||||
file.as_deref(),
|
||||
Some(Path::new("/home/user/.config/insomnia/keys/anthropic"))
|
||||
Some(Path::new("/home/user/.config/yoi/keys/anthropic"))
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -44,8 +44,8 @@ pub const COMPACT_OVERVIEW_DEADLINE_TOKENS: u64 = 40_000;
|
||||
|
||||
/// Default instruction asset reference used when `worker.instruction`
|
||||
/// is omitted. See the `PromptLoader` prefix addressing scheme for the
|
||||
/// `$insomnia/` / `$user/` / `$workspace/` namespaces.
|
||||
pub const DEFAULT_INSTRUCTION: &str = "$insomnia/default";
|
||||
/// `$yoi/` / `$user/` / `$workspace/` namespaces.
|
||||
pub const DEFAULT_INSTRUCTION: &str = "$yoi/default";
|
||||
|
||||
/// Default language policy used by the main worker for normal prose
|
||||
/// responses. See [`crate::WorkerManifest::language`].
|
||||
|
||||
@@ -256,7 +256,7 @@ pub struct PodMeta {
|
||||
pub struct WorkerManifest {
|
||||
/// Reference to the instruction prompt asset used as the body of
|
||||
/// the worker's system prompt. Uses the `PromptLoader` prefix
|
||||
/// addressing scheme (`$insomnia/...`, `$user/...`,
|
||||
/// addressing scheme (`$yoi/...`, `$user/...`,
|
||||
/// `$workspace/...`) and is always populated after resolution —
|
||||
/// unset manifests fall through to [`defaults::DEFAULT_INSTRUCTION`].
|
||||
#[serde(default = "default_instruction")]
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
//! Insomnia のホームディレクトリ配下のパス解決を一元化するモジュール。
|
||||
//! Yoi のホームディレクトリ配下のパス解決を一元化するモジュール。
|
||||
//!
|
||||
//! 用途別に三つの base directory を持つ:
|
||||
//!
|
||||
@@ -10,13 +10,13 @@
|
||||
//!
|
||||
//! ## 解決順 (優先順位高 → 低)
|
||||
//!
|
||||
//! | base | 1. `INSOMNIA_<KIND>_DIR` | 2. `INSOMNIA_HOME` | 3. `XDG_*` | 4. 既定 |
|
||||
//! | base | 1. `YOI_<KIND>_DIR` | 2. `YOI_HOME` | 3. `XDG_*` | 4. 既定 |
|
||||
//! |---|---|---|---|---|
|
||||
//! | config | `INSOMNIA_CONFIG_DIR` | `$INSOMNIA_HOME/config` | `$XDG_CONFIG_HOME/insomnia` | `$HOME/.config/insomnia` |
|
||||
//! | data | `INSOMNIA_DATA_DIR` | `$INSOMNIA_HOME` | — | `$HOME/.insomnia` |
|
||||
//! | runtime | `INSOMNIA_RUNTIME_DIR` | `$INSOMNIA_HOME/run` | `$XDG_RUNTIME_DIR/insomnia` | `$HOME/.insomnia/run` |
|
||||
//! | config | `YOI_CONFIG_DIR` | `$YOI_HOME/config` | `$XDG_CONFIG_HOME/yoi` | `$HOME/.config/yoi` |
|
||||
//! | data | `YOI_DATA_DIR` | `$YOI_HOME` | — | `$HOME/.yoi` |
|
||||
//! | runtime | `YOI_RUNTIME_DIR` | `$YOI_HOME/run` | `$XDG_RUNTIME_DIR/yoi` | `$HOME/.yoi/run` |
|
||||
//!
|
||||
//! `INSOMNIA_HOME=$X` のとき config は `$X/config`、data は `$X` 直下、
|
||||
//! `YOI_HOME=$X` のとき config は `$X/config`、data は `$X` 直下、
|
||||
//! runtime は `$X/run` に集約される。テストや sandbox 利用ではこれ一本
|
||||
//! で全部 tempdir に向けられる。
|
||||
//!
|
||||
@@ -29,8 +29,8 @@ use std::path::PathBuf;
|
||||
/// `prompts/` などが置かれる。
|
||||
pub fn config_dir() -> Option<PathBuf> {
|
||||
resolve_config_dir_from_parts(
|
||||
env_path("INSOMNIA_CONFIG_DIR"),
|
||||
env_path("INSOMNIA_HOME"),
|
||||
env_path("YOI_CONFIG_DIR"),
|
||||
env_path("YOI_HOME"),
|
||||
env_path("XDG_CONFIG_HOME"),
|
||||
env_path("HOME"),
|
||||
)
|
||||
@@ -40,8 +40,8 @@ pub fn config_dir() -> Option<PathBuf> {
|
||||
/// 置き場。
|
||||
pub fn data_dir() -> Option<PathBuf> {
|
||||
resolve_data_dir_from_parts(
|
||||
env_path("INSOMNIA_DATA_DIR"),
|
||||
env_path("INSOMNIA_HOME"),
|
||||
env_path("YOI_DATA_DIR"),
|
||||
env_path("YOI_HOME"),
|
||||
env_path("HOME"),
|
||||
)
|
||||
}
|
||||
@@ -50,8 +50,8 @@ pub fn data_dir() -> Option<PathBuf> {
|
||||
/// `status.json` 等が置かれる。再起動で消えて構わない。
|
||||
pub fn runtime_dir() -> Option<PathBuf> {
|
||||
resolve_runtime_dir_from_parts(
|
||||
env_path("INSOMNIA_RUNTIME_DIR"),
|
||||
env_path("INSOMNIA_HOME"),
|
||||
env_path("YOI_RUNTIME_DIR"),
|
||||
env_path("YOI_HOME"),
|
||||
env_path("XDG_RUNTIME_DIR"),
|
||||
env_path("HOME"),
|
||||
)
|
||||
@@ -111,53 +111,53 @@ pub fn pod_socket_path(pod_name: &str) -> Option<PathBuf> {
|
||||
// ---- internals --------------------------------------------------------------
|
||||
|
||||
fn resolve_config_dir_from_parts(
|
||||
insomnia_config_dir: Option<PathBuf>,
|
||||
insomnia_home: Option<PathBuf>,
|
||||
yoi_config_dir: Option<PathBuf>,
|
||||
yoi_home: Option<PathBuf>,
|
||||
xdg_config_home: Option<PathBuf>,
|
||||
home: Option<PathBuf>,
|
||||
) -> Option<PathBuf> {
|
||||
if let Some(p) = insomnia_config_dir {
|
||||
if let Some(p) = yoi_config_dir {
|
||||
return Some(p);
|
||||
}
|
||||
if let Some(p) = insomnia_home {
|
||||
if let Some(p) = yoi_home {
|
||||
return Some(p.join("config"));
|
||||
}
|
||||
if let Some(p) = xdg_config_home {
|
||||
return Some(p.join("insomnia"));
|
||||
return Some(p.join("yoi"));
|
||||
}
|
||||
Some(home?.join(".config").join("insomnia"))
|
||||
Some(home?.join(".config").join("yoi"))
|
||||
}
|
||||
|
||||
fn resolve_data_dir_from_parts(
|
||||
insomnia_data_dir: Option<PathBuf>,
|
||||
insomnia_home: Option<PathBuf>,
|
||||
yoi_data_dir: Option<PathBuf>,
|
||||
yoi_home: Option<PathBuf>,
|
||||
home: Option<PathBuf>,
|
||||
) -> Option<PathBuf> {
|
||||
if let Some(p) = insomnia_data_dir {
|
||||
if let Some(p) = yoi_data_dir {
|
||||
return Some(p);
|
||||
}
|
||||
if let Some(p) = insomnia_home {
|
||||
if let Some(p) = yoi_home {
|
||||
return Some(p);
|
||||
}
|
||||
Some(home?.join(".insomnia"))
|
||||
Some(home?.join(".yoi"))
|
||||
}
|
||||
|
||||
fn resolve_runtime_dir_from_parts(
|
||||
insomnia_runtime_dir: Option<PathBuf>,
|
||||
insomnia_home: Option<PathBuf>,
|
||||
yoi_runtime_dir: Option<PathBuf>,
|
||||
yoi_home: Option<PathBuf>,
|
||||
xdg_runtime_dir: Option<PathBuf>,
|
||||
home: Option<PathBuf>,
|
||||
) -> Option<PathBuf> {
|
||||
if let Some(p) = insomnia_runtime_dir {
|
||||
if let Some(p) = yoi_runtime_dir {
|
||||
return Some(p);
|
||||
}
|
||||
if let Some(p) = insomnia_home {
|
||||
if let Some(p) = yoi_home {
|
||||
return Some(p.join("run"));
|
||||
}
|
||||
if let Some(p) = xdg_runtime_dir {
|
||||
return Some(p.join("insomnia"));
|
||||
return Some(p.join("yoi"));
|
||||
}
|
||||
Some(home?.join(".insomnia").join("run"))
|
||||
Some(home?.join(".yoi").join("run"))
|
||||
}
|
||||
|
||||
fn user_profiles_path_from_config_dir(config_dir: Option<PathBuf>) -> Option<PathBuf> {
|
||||
@@ -221,7 +221,7 @@ mod tests {
|
||||
fn config_dir_falls_back_to_home_dot_config() {
|
||||
assert_eq!(
|
||||
resolve_config_dir_from_parts(None, None, None, Some(PathBuf::from("/h"))).unwrap(),
|
||||
PathBuf::from("/h/.config/insomnia")
|
||||
PathBuf::from("/h/.config/yoi")
|
||||
);
|
||||
}
|
||||
|
||||
@@ -235,12 +235,12 @@ mod tests {
|
||||
Some(PathBuf::from("/h")),
|
||||
)
|
||||
.unwrap(),
|
||||
PathBuf::from("/x/insomnia")
|
||||
PathBuf::from("/x/yoi")
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn config_dir_insomnia_home_outranks_xdg() {
|
||||
fn config_dir_yoi_home_outranks_xdg() {
|
||||
assert_eq!(
|
||||
resolve_config_dir_from_parts(
|
||||
None,
|
||||
@@ -254,7 +254,7 @@ mod tests {
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn config_dir_explicit_wins_over_insomnia_home() {
|
||||
fn config_dir_explicit_wins_over_yoi_home() {
|
||||
assert_eq!(
|
||||
resolve_config_dir_from_parts(
|
||||
Some(PathBuf::from("/explicit-cfg")),
|
||||
@@ -268,15 +268,15 @@ mod tests {
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn data_dir_default_is_dot_insomnia() {
|
||||
fn data_dir_default_is_dot_yoi() {
|
||||
assert_eq!(
|
||||
resolve_data_dir_from_parts(None, None, Some(PathBuf::from("/h"))).unwrap(),
|
||||
PathBuf::from("/h/.insomnia")
|
||||
PathBuf::from("/h/.yoi")
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn data_dir_insomnia_home_is_data_dir_itself() {
|
||||
fn data_dir_yoi_home_is_data_dir_itself() {
|
||||
assert_eq!(
|
||||
resolve_data_dir_from_parts(
|
||||
None,
|
||||
@@ -289,7 +289,7 @@ mod tests {
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn data_dir_explicit_wins_over_insomnia_home() {
|
||||
fn data_dir_explicit_wins_over_yoi_home() {
|
||||
assert_eq!(
|
||||
resolve_data_dir_from_parts(
|
||||
Some(PathBuf::from("/explicit-data")),
|
||||
@@ -311,20 +311,20 @@ mod tests {
|
||||
Some(PathBuf::from("/h")),
|
||||
)
|
||||
.unwrap(),
|
||||
PathBuf::from("/xdg-runtime/insomnia")
|
||||
PathBuf::from("/xdg-runtime/yoi")
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn runtime_dir_falls_back_to_dot_insomnia_run() {
|
||||
fn runtime_dir_falls_back_to_dot_yoi_run() {
|
||||
assert_eq!(
|
||||
resolve_runtime_dir_from_parts(None, None, None, Some(PathBuf::from("/h"))).unwrap(),
|
||||
PathBuf::from("/h/.insomnia/run")
|
||||
PathBuf::from("/h/.yoi/run")
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn runtime_dir_insomnia_home_is_run_subdir() {
|
||||
fn runtime_dir_yoi_home_is_run_subdir() {
|
||||
assert_eq!(
|
||||
resolve_runtime_dir_from_parts(
|
||||
None,
|
||||
@@ -338,7 +338,7 @@ mod tests {
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn runtime_dir_explicit_wins_over_insomnia_home() {
|
||||
fn runtime_dir_explicit_wins_over_yoi_home() {
|
||||
assert_eq!(
|
||||
resolve_runtime_dir_from_parts(
|
||||
Some(PathBuf::from("/explicit-run")),
|
||||
@@ -358,7 +358,7 @@ mod tests {
|
||||
assert_eq!(
|
||||
resolve_config_dir_from_parts(None, None, xdg_config_home, Some(PathBuf::from("/h")))
|
||||
.unwrap(),
|
||||
PathBuf::from("/h/.config/insomnia")
|
||||
PathBuf::from("/h/.config/yoi")
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -20,11 +20,11 @@ use crate::{
|
||||
ScopeConfig, ScopeRule, SkillsConfig, WebConfig, WorkerManifestConfig, paths,
|
||||
};
|
||||
|
||||
const PROFILE_FORMAT_V1: &str = "insomnia.lua-profile.v1";
|
||||
const PROFILE_FORMAT_V1: &str = "yoi.lua-profile.v1";
|
||||
const BUILTIN_DEFAULT_PROFILE_NAME: &str = "default";
|
||||
const BUILTIN_DEFAULT_PROFILE: &str = include_str!("../../../resources/profiles/default.lua");
|
||||
const BUILTIN_MODEL_CATALOG: &str = include_str!("../../../resources/models/builtin.toml");
|
||||
const DEFAULT_POD_NAME: &str = "insomnia";
|
||||
const DEFAULT_POD_NAME: &str = "yoi";
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "snake_case")]
|
||||
@@ -694,7 +694,7 @@ fn find_project_profiles_from(start: &Path) -> Option<PathBuf> {
|
||||
.unwrap_or_else(|| start.to_path_buf());
|
||||
let mut cur: Option<&Path> = Some(start.as_path());
|
||||
while let Some(dir) = cur {
|
||||
let candidate = dir.join(".insomnia").join("profiles.toml");
|
||||
let candidate = dir.join(".yoi").join("profiles.toml");
|
||||
if candidate.is_file() {
|
||||
return Some(candidate);
|
||||
}
|
||||
@@ -709,7 +709,7 @@ fn add_builtin_profiles(registry: &mut ProfileRegistry) {
|
||||
BUILTIN_DEFAULT_PROFILE_NAME,
|
||||
"builtin:default",
|
||||
BUILTIN_DEFAULT_PROFILE,
|
||||
Some("Bundled default Insomnia coding profile".into()),
|
||||
Some("Bundled default Yoi coding profile".into()),
|
||||
));
|
||||
}
|
||||
|
||||
@@ -827,7 +827,7 @@ fn require_module(
|
||||
if let Some(value) = host_module(lua, name)? {
|
||||
return Ok(value);
|
||||
}
|
||||
if name.starts_with("insomnia.") || name == "insomnia" {
|
||||
if name.starts_with("yoi.") || name == "yoi" {
|
||||
return Err(mlua::Error::RuntimeError(format!(
|
||||
"unknown host module `{name}`"
|
||||
)));
|
||||
@@ -876,7 +876,7 @@ fn require_module(
|
||||
|
||||
fn host_module(lua: &Lua, name: &str) -> mlua::Result<Option<LuaValue>> {
|
||||
match name {
|
||||
"insomnia" => {
|
||||
"yoi" => {
|
||||
let t = lua.create_table()?;
|
||||
t.set("profile", profile_function(lua)?)?;
|
||||
t.set("models", models_module(lua)?)?;
|
||||
@@ -884,10 +884,10 @@ fn host_module(lua: &Lua, name: &str) -> mlua::Result<Option<LuaValue>> {
|
||||
t.set("scope", scope_module(lua)?)?;
|
||||
Ok(Some(LuaValue::Table(t)))
|
||||
}
|
||||
"insomnia.profile" => Ok(Some(LuaValue::Function(profile_function(lua)?))),
|
||||
"insomnia.models" => Ok(Some(LuaValue::Table(models_module(lua)?))),
|
||||
"insomnia.compact" => Ok(Some(LuaValue::Table(compact_module(lua)?))),
|
||||
"insomnia.scope" => Ok(Some(LuaValue::Table(scope_module(lua)?))),
|
||||
"yoi.profile" => Ok(Some(LuaValue::Function(profile_function(lua)?))),
|
||||
"yoi.models" => Ok(Some(LuaValue::Table(models_module(lua)?))),
|
||||
"yoi.compact" => Ok(Some(LuaValue::Table(compact_module(lua)?))),
|
||||
"yoi.scope" => Ok(Some(LuaValue::Table(scope_module(lua)?))),
|
||||
_ => Ok(None),
|
||||
}
|
||||
}
|
||||
@@ -997,7 +997,7 @@ fn reject_manifest_shaped_profile(value: &serde_json::Value) -> Result<(), Profi
|
||||
for key in ["allow", "deny"] {
|
||||
if scope.contains_key(key) {
|
||||
return Err(ProfileError::InvalidProfile(format!(
|
||||
"field `scope.{key}` grants concrete authority and is not allowed in reusable Profiles; use require(\"insomnia.scope\") intent helpers"
|
||||
"field `scope.{key}` grants concrete authority and is not allowed in reusable Profiles; use require(\"yoi.scope\") intent helpers"
|
||||
)));
|
||||
}
|
||||
}
|
||||
@@ -1312,8 +1312,8 @@ mod tests {
|
||||
tmp.path(),
|
||||
"coder.lua",
|
||||
r#"
|
||||
local profile = require("insomnia.profile")
|
||||
local scope = require("insomnia.scope")
|
||||
local profile = require("yoi.profile")
|
||||
local scope = require("yoi.scope")
|
||||
return profile {
|
||||
slug = "coder",
|
||||
model = { scheme = "anthropic", model_id = "claude-sonnet-4-20250514" },
|
||||
@@ -1352,19 +1352,19 @@ return profile {
|
||||
let tmp = TempDir::new().unwrap();
|
||||
std::fs::write(
|
||||
tmp.path().join("shared.lua"),
|
||||
r#"return { model = require("insomnia.models").catalog("codex-oauth/gpt-5.5") }"#,
|
||||
r#"return { model = require("yoi.models").catalog("codex-oauth/gpt-5.5") }"#,
|
||||
)
|
||||
.unwrap();
|
||||
let profile = write_profile(
|
||||
tmp.path(),
|
||||
"main.lua",
|
||||
r#"
|
||||
local insomnia = require("insomnia")
|
||||
local yoi = require("yoi")
|
||||
local shared = require("shared")
|
||||
return insomnia.profile {
|
||||
return yoi.profile {
|
||||
slug = "main",
|
||||
model = shared.model,
|
||||
scope = insomnia.scope.workspace_write(),
|
||||
scope = yoi.scope.workspace_write(),
|
||||
}
|
||||
"#,
|
||||
);
|
||||
@@ -1445,9 +1445,9 @@ return insomnia.profile {
|
||||
tmp.path(),
|
||||
"ratio.lua",
|
||||
r#"
|
||||
local profile = require("insomnia.profile")
|
||||
local models = require("insomnia.models")
|
||||
local compact = require("insomnia.compact")
|
||||
local profile = require("yoi.profile")
|
||||
local models = require("yoi.models")
|
||||
local compact = require("yoi.compact")
|
||||
return profile {
|
||||
model = models.catalog("codex-oauth/gpt-5.5"),
|
||||
compaction = compact.ratio { threshold = 0.5, request = 0.75, worker = 0.25 },
|
||||
@@ -1473,7 +1473,7 @@ return profile {
|
||||
.with_workspace_base(tmp.path())
|
||||
.resolve(&ProfileSelector::Default, ProfileResolveOptions::default())
|
||||
.unwrap();
|
||||
assert_eq!(resolved.manifest.pod.name, "insomnia");
|
||||
assert_eq!(resolved.manifest.pod.name, "yoi");
|
||||
assert_eq!(
|
||||
resolved.manifest.model.ref_.as_deref(),
|
||||
Some("codex-oauth/gpt-5.5")
|
||||
@@ -1516,7 +1516,7 @@ return profile {
|
||||
fn discovery_reads_user_and_project_registry_and_project_default_wins() {
|
||||
let tmp = TempDir::new().unwrap();
|
||||
let user_config = tmp.path().join("profiles.toml");
|
||||
let project_dir = tmp.path().join("project/.insomnia");
|
||||
let project_dir = tmp.path().join("project/.yoi");
|
||||
std::fs::create_dir_all(&project_dir).unwrap();
|
||||
let project_config = project_dir.join("profiles.toml");
|
||||
std::fs::write(
|
||||
@@ -1542,7 +1542,7 @@ return profile {
|
||||
#[test]
|
||||
fn default_marks_direct_profile_entry() {
|
||||
let tmp = TempDir::new().unwrap();
|
||||
let project_dir = tmp.path().join("project/.insomnia");
|
||||
let project_dir = tmp.path().join("project/.yoi");
|
||||
std::fs::create_dir_all(&project_dir).unwrap();
|
||||
let project_config = project_dir.join("profiles.toml");
|
||||
std::fs::write(
|
||||
|
||||
Reference in New Issue
Block a user