feat: 深度研究支持独立新报告与原文改写,并完善沙箱、模型管理与全文改写

新报告不再覆盖当前文件卡片,写入时打开沙箱;步骤条仅在改写原文时位于卡片上方。同时补齐改写本地回退、模型管理与会商第三步相关改动。

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
董宏凯andCursor committed 2026-08-21 21:46:04 +08:00
1 parent 11f928bc95
commit a5a9c952e8
63 files changed
+4113 -929

No files matched your search

@@ -115,6 +115,69 @@ async def test_delete_model_configuration_removes_matching_model_and_activates_c
]
@pytest.mark.asyncio
async def test_reorder_model_configurations_persists_a_complete_permutation(
tmp_path,
monkeypatch: pytest.MonkeyPatch,
) -> None:
config_path = tmp_path / "config.yaml"
config_path.write_text(
"""models:
- name: first
use: langchain_openai:ChatOpenAI
model: first
- name: second
use: langchain_openai:ChatOpenAI
model: second
""",
encoding="utf-8",
)
saved: dict[str, object] = {}
async def save_models(_request, raw_before: str, models: list[dict[str, object]]) -> list[dict[str, object]]:
saved["raw_before"] = raw_before
saved["models"] = models
return models
monkeypatch.setattr(router, "_resolve_config_path", lambda: config_path)
monkeypatch.setattr(router, "_save_models", save_models)
request = SimpleNamespace(state=SimpleNamespace(user=SimpleNamespace(system_role="admin")))
result = await router.reorder_model_configurations(
router.ModelOrderRequest(names=["second", "first"]),
request,
)
assert [item.name for item in result] == ["second", "first"]
assert [item["name"] for item in saved["models"]] == ["second", "first"]
@pytest.mark.asyncio
async def test_reorder_model_configurations_rejects_stale_or_partial_orders(
tmp_path,
monkeypatch: pytest.MonkeyPatch,
) -> None:
config_path = tmp_path / "config.yaml"
config_path.write_text(
"""models:
- name: first
use: langchain_openai:ChatOpenAI
model: first
- name: second
use: langchain_openai:ChatOpenAI
model: second
""",
encoding="utf-8",
)
monkeypatch.setattr(router, "_resolve_config_path", lambda: config_path)
request = SimpleNamespace(state=SimpleNamespace(user=SimpleNamespace(system_role="admin")))
with pytest.raises(Exception) as exc_info:
await router.reorder_model_configurations(router.ModelOrderRequest(names=["first"]), request)
assert getattr(exc_info.value, "status_code", None) == 409
@pytest.mark.asyncio
async def test_connection_test_uses_one_minimal_prompt_without_writing_config(
tmp_path,