feat: Add LSP plugin unit tests and frontend common initialization library
Some checks failed
CI / Determine matrix (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
CI / ${{ matrix.os }} / ${{ matrix.build_type }} (push) Has been cancelled

- Introduced `dstalk_lsp_plugin_test` for testing LSP plugin functionalities including `lsp_trim`, `lsp_frame_message`, and `lsp_parse_content_length`.
- Created `dstalk_frontend_common` static library to encapsulate shared initialization logic for frontend components (CLI, GUI, Web).
- Implemented configuration file discovery and service querying in `dstalk_frontend_init`.
- Added internal headers for LSP and Anthropic plugins to facilitate unit testing.
- Established a mailroom system for asynchronous message passing between stateless agents, enhancing coordination and context management.
This commit is contained in:
2026-06-01 08:51:40 +08:00
parent 8faa02c3d5
commit c0af9c65c7
17 changed files with 1235 additions and 69 deletions

View File

@@ -0,0 +1,46 @@
// ============================================================================
// anthropic_internal.hpp — 内部声明:供单元测试访问的函数与数据结构
// ============================================================================
// 仅在 tests 中使用;非 plugin 公共 API
// ============================================================================
#ifndef ANTHROPIC_INTERNAL_HPP
#define ANTHROPIC_INTERNAL_HPP
#include "dstalk/dstalk_host.h"
#include "dstalk/dstalk_services.h"
#include "ai_common.hpp"
#include <string>
#include <vector>
// ---- 从 dstalk_ai 命名空间导入共享类型与函数 ----
using dstalk_ai::PluginConfig;
using dstalk_ai::ToolCallAccum;
using dstalk_ai::StreamContext;
using dstalk_ai::secure_zero;
using dstalk_ai::extract_host_port;
// ---- 全局变量 ----
extern PluginConfig g_cfg;
extern std::string g_tools_json;
// ---- 测试用函数声明 ----
bool parse_sse_data(const std::string& data, std::string& token_out,
StreamContext* ctx);
std::string build_request_json(const dstalk_message_t* history, int history_len,
const std::string& user_input,
const std::string& tools_json,
bool stream);
std::string build_headers_json();
void my_free_result(dstalk_chat_result_t* result);
int my_configure(const char* provider, const char* base_url,
const char* api_key, const char* model,
int max_tokens, double temperature);
#endif // ANTHROPIC_INTERNAL_HPP