Skip to content

fix(plugin): respect LIBREFANG_HOME when resolving plugin directory#6136

Merged
houko merged 3 commits into
librefang:mainfrom
HuaGu-Dragon:fix-plugin-dir
Jun 17, 2026
Merged

fix(plugin): respect LIBREFANG_HOME when resolving plugin directory#6136
houko merged 3 commits into
librefang:mainfrom
HuaGu-Dragon:fix-plugin-dir

Conversation

@HuaGu-Dragon

Copy link
Copy Markdown
Contributor

Type

  • Agent template (TOML)
  • Skill (Python/JS/Prompt)
  • Channel adapter
  • LLM provider
  • Built-in tool
  • Bug fix
  • Feature (Rust)
  • Documentation / Translation
  • Refactor / Performance
  • CI / Tooling
  • Other

Summary

respect LIBREFANG_HOME when resolving plugin directory

like

pub fn librefang_home() -> PathBuf {
if let Ok(home) = std::env::var("LIBREFANG_HOME") {
return PathBuf::from(home);
}
dirs::home_dir()
.unwrap_or_else(std::env::temp_dir)
.join(".librefang")
}

Testing

  • cargo clippy --workspace --all-targets -- -D warnings passes
  • cargo test --workspace passes
  • Live integration tested (if applicable)

Security

  • No new unsafe code
  • No secrets or API keys in diff
  • User input validated at boundaries

@github-actions github-actions Bot added the area/runtime Agent loop, LLM drivers, WASM sandbox label Jun 16, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Thanks for your first pull request! 🎉

A maintainer will review it soon. While you wait, please make sure:

  • PR title follows conventional format (feat:, fix:, docs:, etc.)
  • cargo test --workspace passes
  • cargo clippy --workspace --all-targets -- -D warnings is clean

We aim to provide initial feedback within 7 days. See CONTRIBUTING.md for details.

@github-actions github-actions Bot added the size/S 10-49 lines changed label Jun 16, 2026

@houko houko left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Correct fix: plugins_dir() previously ignored LIBREFANG_HOME and diverged from config::librefang_home(). Nice that it also fixes the second copy in context_engine/scriptable/mod.rs (which used a . fallback and ignored the env var too), consolidating both onto one helper.

Two non-blocking notes:

  • The new test mutates the global LIBREFANG_HOME, which this crate otherwise avoids on purpose (see the comment in artifact_store.rs::default_artifact_storage_dir_ends_with_data_artifacts). The ENV_LOCK only serializes the two new tests against each other, not against other tests in the same process that read LIBREFANG_HOME live (model_catalog::resolve_home_dir, artifact_store::default_artifact_storage_dir). CI is fine since nextest isolates per process; a local cargo test -p librefang-runtime could flake. Acceptable here since the test genuinely needs to set the var to verify it's honored.
  • Minor behavior change worth a line in the description: the no-HOME fallback shifts from /tmp/librefang to /tmp/.librefang and drops the warn!, aligning with the canonical librefang_home() in the kernel. Intentional, just undocumented.

@houko
houko enabled auto-merge (squash) June 17, 2026 05:22
@houko
houko merged commit 70831b2 into librefang:main Jun 17, 2026
31 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/runtime Agent loop, LLM drivers, WASM sandbox size/S 10-49 lines changed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants