diff options
| author | sigoden <sigoden@gmail.com> | 2024-09-10 18:35:34 +0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-09-10 18:35:34 +0800 |
| commit | e181ae9b0d4814a7c005c94837426126dde63c6c (patch) | |
| tree | ed727036d586f0673198a4b30217bbe2e34a094b /src/config/agent.rs | |
| parent | 84e9515509c559ed01e4b0a67539f10cd2c065e6 (diff) | |
| download | aichat-e181ae9b0d4814a7c005c94837426126dde63c6c.tar.gz | |
refactor: extract built-in roles to embedded files (#853)
Diffstat (limited to 'src/config/agent.rs')
| -rw-r--r-- | src/config/agent.rs | 21 |
1 files changed, 1 insertions, 20 deletions
diff --git a/src/config/agent.rs b/src/config/agent.rs index bf4ef54..36af15e 100644 --- a/src/config/agent.rs +++ b/src/config/agent.rs @@ -292,9 +292,7 @@ impl AgentDefinition { for variable in &self.variables { output = output.replace(&format!("{{{{{}}}}}", variable.name), &variable.value) } - for (key, value) in builtin_variables() { - output = output.replace(&format!("{{{{{}}}}}", key), &value); - } + interpolate_variables(&mut output); output } @@ -412,20 +410,3 @@ fn save_variables(variables_path: &Path, variables: &[AgentVariable]) -> Result< .with_context(|| format!("Failed to save variables to '{}'", variables_path.display()))?; Ok(()) } - -fn builtin_variables() -> Vec<(&'static str, String)> { - vec![ - ("__os__", env::consts::OS.to_string()), - ("__os_family__", env::consts::FAMILY.to_string()), - ("__arch__", env::consts::ARCH.to_string()), - ("__shell__", SHELL.name.clone()), - ("__locale__", sys_locale::get_locale().unwrap_or_default()), - ("__now__", now()), - ( - "__cwd__", - env::current_dir() - .map(|v| v.display().to_string()) - .unwrap_or_default(), - ), - ] -} |
