W22: coverage metric + network tests + Tool stream feedback + stdin pipe + session path + dependency check (W22.1-W22.6)
Some checks failed
CI / Determine matrix (push) Has been cancelled
CI / ${{ matrix.os }} / ${{ matrix.build_type }} (push) Has been cancelled
CI / Sanitizer (ASan+UBSan) / ubuntu-24.04 (push) Has been cancelled
CI / Coverage (gcovr) / ubuntu-24.04 (push) Has been cancelled

- W22.1: gcovr 覆盖率度量 + CI coverage job(40% 阈值 warning)
- W22.2: network_plugin 单元测试(parse_headers_json/extract_host_port/SSE/异常保护)
- W22.3: Tool Calling 流式反馈(chat_stream + "[工具调用]/[工具结果]" 状态行)
- W22.4: --prompt stdin pipe(--prompt - 从 stdin 读取)
- W22.5: session 路径健壮化(static 缓存 + mkdir + fallback)
- W22.6: 插件依赖拓扑静态校验(validate_dependencies 循环/缺失检测)

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
2026-05-27 21:21:24 +08:00
parent b2b381b9b3
commit df3bf298ee
13 changed files with 753 additions and 23 deletions

View File

@@ -15,6 +15,7 @@
#include <cstdlib>
#include <cstring>
#include <exception>
#include <filesystem>
#include <mutex>
#include <string>
#include <utility>
@@ -293,17 +294,32 @@ static dstalk_session_service_t g_session_service = {
// ============================================================
static std::string get_default_session_path() {
// W22.5: static 缓存 + mkdir 保障 + 失败 fallback 到当前目录
static std::string cached_path = []() -> std::string {
#ifdef _WIN32
char* buf = nullptr;
size_t len = 0;
_dupenv_s(&buf, &len, "APPDATA");
std::string dir = buf ? std::string(buf) + "/dstalk" : "dstalk";
free(buf);
char* buf = nullptr;
size_t len = 0;
_dupenv_s(&buf, &len, "APPDATA");
std::string dir = buf ? std::string(buf) + "/dstalk" : "dstalk";
free(buf);
#else
const char* home = std::getenv("HOME");
std::string dir = home ? std::string(home) + "/.dstalk" : "/tmp/dstalk";
const char* home = std::getenv("HOME");
std::string dir = home ? std::string(home) + "/.dstalk" : "/tmp/dstalk";
#endif
return dir + "/session.json";
std::error_code ec;
std::filesystem::create_directories(dir, ec);
if (ec) {
const dstalk_host_api_t* host = g_host.load(std::memory_order_acquire);
if (host) host->log(DSTALK_LOG_WARN,
"get_default_session_path: cannot mkdir '%s' (%s), fallback to .",
dir.c_str(), ec.message().c_str());
return std::string("./session.json");
}
return dir + "/session.json";
}();
return cached_path;
}
// ============================================================