feat: 新增工具插件、系统日志、workflow配置及前端优化

1. 新增工具插件(edit_file, python_executor, search_file, shell_executor, write_file)
2. 新增系统事件日志模块和API
3. 新增workflow配置文件和详情API
4. 前端增加SSE、错误边界、设置引导等组件
5. 优化认证加密、速率限制、配置加载等工具模块
6. 删除废弃的cluster和health API
7. 补充单元测试和集成测试

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-06-03 07:34:43 +00:00
parent f04fef916f
commit a53ffebe0e
57 changed files with 2804 additions and 271 deletions
+78
View File
@@ -0,0 +1,78 @@
"""``utils/config_loader.py``workflow.yaml 读/写/热重载。"""
from __future__ import annotations
import yaml
import pytest
@pytest.fixture(autouse=True)
def isolated_yaml(tmp_path, monkeypatch):
"""每个用例用独立的临时 yaml,避免污染真实 config/workflow.yaml。"""
from kilostar.utils import config_loader
fake_yaml = tmp_path / "workflow.yaml"
monkeypatch.setattr(config_loader, "_WORKFLOW_YAML", fake_yaml)
monkeypatch.setattr(config_loader, "_current", None)
return fake_yaml
def test_get_workflow_config_returns_default_when_file_absent():
from kilostar.utils.config_loader import get_workflow_config
config = get_workflow_config()
assert config.retry.max_attempts == 5
def test_get_workflow_config_reads_from_disk(isolated_yaml):
isolated_yaml.write_text("retry:\n max_attempts: 12\n", encoding="utf-8")
from kilostar.utils.config_loader import reload_workflow_config
config = reload_workflow_config()
assert config.retry.max_attempts == 12
def test_save_workflow_config_writes_yaml_and_reloads(isolated_yaml):
from kilostar.utils.config_loader import (
save_workflow_config,
get_workflow_config,
WorkflowConfig,
RetryConfig,
)
new_config = WorkflowConfig(retry=RetryConfig(max_attempts=20))
save_workflow_config(new_config)
on_disk = yaml.safe_load(isolated_yaml.read_text(encoding="utf-8"))
assert on_disk == {"retry": {"max_attempts": 20}}
# 热重载:再次 get 应直接拿到新值
assert get_workflow_config().retry.max_attempts == 20
def test_max_attempts_validation_rejects_out_of_range():
from kilostar.utils.config_loader import RetryConfig
with pytest.raises(Exception):
RetryConfig(max_attempts=0)
with pytest.raises(Exception):
RetryConfig(max_attempts=200)
def test_reload_picks_up_external_file_changes(isolated_yaml):
"""模拟运维直接改 yaml 文件,reload 后引擎能拿到新值。"""
isolated_yaml.write_text("retry:\n max_attempts: 3\n", encoding="utf-8")
from kilostar.utils.config_loader import (
get_workflow_config,
reload_workflow_config,
)
assert reload_workflow_config().retry.max_attempts == 3
isolated_yaml.write_text("retry:\n max_attempts: 30\n", encoding="utf-8")
assert reload_workflow_config().retry.max_attempts == 30
# get_workflow_config 也读到最新
assert get_workflow_config().retry.max_attempts == 30