chore(v2): 从兴邦预审v2白名单抽取独立可运行基座
按 docs/v2/05-implementation-plan.md §1 候选迁移表与 claude_use/T00 白名单, 从 55e2cdb 抽取 224 个文件(2.48 MB)到独立目录 F:/mini-OpenClaw-v2。 - 排除:凭据(.env/server-deploy.conf/旧DELIVERY.md)、运行数据(xingbang_data 等 4 个 SQLite)、依赖(venv/node_modules 符号链接)、归档(_backup*/test-evidence/ ori_file)、Office 临时文件 - 目标目录独立 git 仓库,初始恢复点;Gitea 远程与分支待 OQ-06 Q2 定案 - 未部署、未启动服务、未调用模型 Co-Authored-By: Claude Code <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,42 @@
|
||||
"""Global configuration management — JSON-based persistence."""
|
||||
|
||||
import json
|
||||
from pathlib import Path
|
||||
from typing import Any
|
||||
|
||||
CONFIG_FILE = Path(__file__).resolve().parent / "config.json"
|
||||
|
||||
_DEFAULT_CONFIG: dict[str, Any] = {
|
||||
"rag_mode": False,
|
||||
}
|
||||
|
||||
|
||||
def load_config() -> dict[str, Any]:
|
||||
"""Load configuration from disk, returning defaults if missing."""
|
||||
if not CONFIG_FILE.exists():
|
||||
return dict(_DEFAULT_CONFIG)
|
||||
try:
|
||||
data = json.loads(CONFIG_FILE.read_text(encoding="utf-8"))
|
||||
return {**_DEFAULT_CONFIG, **data}
|
||||
except Exception:
|
||||
return dict(_DEFAULT_CONFIG)
|
||||
|
||||
|
||||
def save_config(config: dict[str, Any]) -> None:
|
||||
"""Persist configuration to disk."""
|
||||
CONFIG_FILE.write_text(
|
||||
json.dumps(config, ensure_ascii=False, indent=2),
|
||||
encoding="utf-8",
|
||||
)
|
||||
|
||||
|
||||
def get_rag_mode() -> bool:
|
||||
"""Get current RAG mode setting."""
|
||||
return bool(load_config().get("rag_mode", False))
|
||||
|
||||
|
||||
def set_rag_mode(enabled: bool) -> None:
|
||||
"""Set RAG mode on/off."""
|
||||
config = load_config()
|
||||
config["rag_mode"] = enabled
|
||||
save_config(config)
|
||||
Reference in New Issue
Block a user