profile: remove lua profile resolver

This commit is contained in:
2026-07-11 04:44:32 +09:00
parent 156f8ad044
commit 254360f1ab
24 changed files with 473 additions and 980 deletions
+52 -54
View File
@@ -8,7 +8,7 @@ use toml::Value;
use toml::map::Map;
const GENERATED_PROFILE_NAME: &str = "default";
const GENERATED_PROFILE_PATH: &str = "profiles/default.lua";
const GENERATED_PROFILE_PATH: &str = "profiles/default.toml";
const GENERATED_PROFILE_DESCRIPTION: &str = "Generated by yoi setup-model";
#[derive(Debug, Clone, PartialEq, Eq)]
@@ -149,7 +149,7 @@ pub fn write_default_profile_config(
std::fs::create_dir_all(&profiles_dir)?;
let profile_path = config_dir.join(GENERATED_PROFILE_PATH);
std::fs::write(&profile_path, generated_profile_lua(model_ref))?;
std::fs::write(&profile_path, generated_profile_toml(model_ref))?;
let registry_path = config_dir.join("profiles.toml");
let mut document = read_registry_document(&registry_path)?;
@@ -203,65 +203,63 @@ fn set_default_profile_entry(document: &mut Value) -> Result<(), Box<dyn std::er
Ok(())
}
fn generated_profile_lua(model_ref: &str) -> String {
fn generated_profile_toml(model_ref: &str) -> String {
format!(
r#"local profile = require("yoi.profile")
local scope = require("yoi.scope")
local compact = require("yoi.compact")
r#"slug = "default"
description = "Generated by yoi setup-model"
scope = "workspace_write"
return profile {{
slug = "default",
description = "Generated by yoi setup-model",
[model]
ref = "{}"
scope = scope.workspace_write(),
[session]
record_event_trace = true
session = {{
record_event_trace = true,
}},
[engine]
reasoning = "high"
worker = {{
reasoning = "high",
}},
[compaction]
kind = "tokens"
threshold = 240000
request_threshold = 270000
worker_context_max_tokens = 100000
model = {{
ref = "{}",
}},
[feature.task]
enabled = true
compaction = compact.tokens {{
threshold = 240000,
request_threshold = 270000,
worker_context_max_tokens = 100000,
}},
[feature.memory]
enabled = true
feature = {{
task = {{ enabled = true }},
memory = {{ enabled = true }},
web = {{ enabled = true }},
workers = {{ enabled = false }},
ticket = {{ enabled = false, access = "lifecycle" }},
ticket_orchestration = {{ enabled = false }},
}},
[feature.web]
enabled = true
memory = {{
extract_threshold = 50000,
consolidation_threshold_files = 5,
consolidation_threshold_bytes = 50000,
}},
[feature.workers]
enabled = false
web = {{
enabled = true,
search = {{
provider = "brave",
api_key_secret = "web/brave/default",
}},
}},
}}
[feature.ticket]
enabled = false
access = "lifecycle"
[feature.ticket_orchestration]
enabled = false
[memory]
extract_threshold = 50000
consolidation_threshold_files = 5
consolidation_threshold_bytes = 50000
[web]
enabled = true
[web.search]
provider = "brave"
api_key_secret = "web/brave/default"
"#,
escape_lua_string(model_ref)
escape_toml_string(model_ref)
)
}
fn escape_lua_string(value: &str) -> String {
fn escape_toml_string(value: &str) -> String {
value
.chars()
.flat_map(|c| match c {
@@ -288,18 +286,18 @@ mod tests {
assert_eq!(written.registry_path, dir.path().join("profiles.toml"));
assert_eq!(
written.profile_path,
dir.path().join("profiles/default.lua")
dir.path().join("profiles/default.toml")
);
let registry = std::fs::read_to_string(&written.registry_path).unwrap();
assert!(registry.contains("default = \"user:default\""));
assert!(registry.contains("[profile.default]"));
assert!(registry.contains("path = \"profiles/default.lua\""));
assert!(registry.contains("path = \"profiles/default.toml\""));
let profile = std::fs::read_to_string(&written.profile_path).unwrap();
assert!(profile.contains("slug = \"default\""));
assert!(profile.contains("ref = \"codex-oauth/gpt-5.5\""));
assert!(profile.contains("scope = scope.workspace_write()"));
assert!(profile.contains("scope = \"workspace_write\""));
}
#[test]
@@ -308,7 +306,7 @@ mod tests {
std::fs::write(
dir.path().join("profiles.toml"),
r#"[profile.other]
path = "profiles/other.lua"
path = "profiles/other.toml"
description = "keep me"
"#,
)
@@ -318,13 +316,13 @@ description = "keep me"
let registry = std::fs::read_to_string(dir.path().join("profiles.toml")).unwrap();
assert!(registry.contains("[profile.other]"));
assert!(registry.contains("path = \"profiles/other.lua\""));
assert!(registry.contains("path = \"profiles/other.toml\""));
assert!(registry.contains("[profile.default]"));
assert!(registry.contains("default = \"user:default\""));
}
#[test]
fn escape_lua_string_escapes_quotes_and_slashes() {
assert_eq!(escape_lua_string("a\\b\"c"), "a\\\\b\\\"c");
fn escape_toml_string_escapes_quotes_and_slashes() {
assert_eq!(escape_toml_string("a\\b\"c"), "a\\\\b\\\"c");
}
}
+2 -2
View File
@@ -664,7 +664,7 @@ mod tests {
r#"
default = "coder"
[profile]
coder = "profiles/coder.lua"
coder = "profiles/coder.toml"
"#,
)
.unwrap();
@@ -692,7 +692,7 @@ coder = "profiles/coder.lua"
r#"
default = "coder"
[profile.coder]
path = "profiles/coder.lua"
path = "profiles/coder.toml"
description = "Project coder"
"#,
)