Skip to content

JiuwenSwarm is an intelligent AI Agent built on openJiuwen. It extends the powerful capabilities of large language models directly to your fingertips through various communication apps you use daily.

Python

feat:extension_dirs与memory_mode配置支持环境变量方式配置

white202542f57571dec1
diff --git a/jiuwenclaw/extensions/manager.py b/jiuwenclaw/extensions/manager.py
index 9ce2f209e6..88733c97d8 100644
--- a/jiuwenclaw/extensions/manager.py
+++ b/jiuwenclaw/extensions/manager.py
@@ -7,14 +7,19 @@ from jiuwenclaw.extensions.registry import ExtensionRegistry
from jiuwenclaw.utils import logger
-def _extension_dir_paths_from_config(cfg: dict) -> list:
- """读取 ``extensions.extension_dirs``(扩展包搜索目录列表,可为空)。"""
+def _split_extension_dirs(value: str) -> list[str]:
+ # 按需求使用 ';' 分割
+ return [p.strip() for p in value.split(";") if p.strip()]
+
+
+def _extension_dir_paths_from_config(cfg: dict) -> list[str]:
+ """读取 ``extensions.extension_dirs``(扩展包搜索目录:仅支持字符串,用 ';' 分割)。"""
ext = cfg.get("extensions")
if not isinstance(ext, dict):
return []
dirs = ext.get("extension_dirs")
- if isinstance(dirs, list):
- return dirs
+ if isinstance(dirs, str):
+ return _split_extension_dirs(dirs)
return []
@@ -31,8 +36,12 @@ class ExtensionManager:
def _setup_search_paths(self) -> None:
extension_dirs = _extension_dir_paths_from_config(get_config())
for path in extension_dirs:
- if Path(path).exists():
- self.loader.add_search_path(Path(path))
+ p = Path(path)
+ if not p.is_absolute():
+ # 相对路径直接按当前工作目录解析成绝对路径
+ p = p.resolve()
+ if p.exists():
+ self.loader.add_search_path(p)
async def load_all_extensions(self) -> None:
roots = self.loader.discover_extension_roots()
diff --git a/jiuwenclaw/resources/.env.template b/jiuwenclaw/resources/.env.template
index 0ad360c479..1ad949cf32 100644
--- a/jiuwenclaw/resources/.env.template
+++ b/jiuwenclaw/resources/.env.template
@@ -89,4 +89,10 @@ EVOLUTION_AUTO_SCAN="false"
SKILLNET_DOWNLOAD_TIMEOUT=60
SKILLNET_MAX_RETRIES=3
-NO_PROXY=localhost,127.0.0.1,api.openai.rnd.huawei.com
\ No newline at end of file
+NO_PROXY=localhost,127.0.0.1,api.openai.rnd.huawei.com
+
+# Memory mode (default is "local" when empty)
+MEMORY_MODE=
+
+# Extension package search dirs, separated by ';'
+EXTENSION_DIRS=""
\ No newline at end of file
diff --git a/jiuwenclaw/resources/config.yaml b/jiuwenclaw/resources/config.yaml
index adf95e651b..c279627557 100644
--- a/jiuwenclaw/resources/config.yaml
+++ b/jiuwenclaw/resources/config.yaml
@@ -14,7 +14,7 @@ logging:
full: INFO
memory:
- mode: local
+ mode: ${MEMORY_MODE:-local}
models:
default:
@@ -349,4 +349,6 @@ updater:
timeout_seconds: 20
extensions:
- extension_dirs: []
+ # 扩展包搜索目录(字符串),用 ';' 分割多个目录:
+ # EXTENSION_DIRS="E:/a;D:/b"
+ extension_dirs: ${EXTENSION_DIRS:-}