W17: extract ai_common shared module + fix anthropic data race + brace bugs

- New plugins_upper/ai_common/ static library: shared PluginConfig, ToolCallAccum,
  StreamContext, secure_zero, extract_host_port, serialize_tool_calls, free_chat_result
- Refactored openai/anthropic plugins to use dstalk_ai:: namespace from ai_common
- Fixed anthropic g_config raw pointer → std::atomic (data race)
- Added SSE parse error counter with threshold abort (kMaxSseParseErrors=5)
- Fixed missing closing brace in both plugins' error-body catch block
- Updated test targets: ai_common include path + link, using namespace dstalk_ai
- plugin_loader_test: added stub_unreg + service_registry.cpp for unregister_service
- Includes pre-existing uncommitted changes from prior waves

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-05-31 16:58:25 +08:00
parent ba7382db2a
commit 8faa02c3d5
49 changed files with 1062 additions and 413 deletions

View File

@@ -51,9 +51,9 @@ dstalk 是一款 AI 编程助手命令行工具, 通过调用大模型在终端
| 提供商 | 模型 | 插件 |
|--------|------|------|
| OpenAI-compatible | gpt-4o | `ai.openai` |
| Anthropic | claude-opus-4 | `ai.anthropic` |
| OpenAI 兼容 | GPT 系列 | `ai.openai` |
| OpenAI-compatible | gpt-4o | `ai_openai` |
| Anthropic | claude-opus-4 | `ai_anthropic` |
| OpenAI 兼容 | GPT 系列 | `ai_openai` |
通过 `config.toml``ai.provider` 一键切换。
@@ -61,11 +61,14 @@ dstalk 是一款 AI 编程助手命令行工具, 通过调用大模型在终端
## 快速开始
| 平台 | 安装工具链 | 编译 | 运行 |
|------|-----------|------|------|
| Windows | `cd tools && setup.bat` | `build.bat` | `build\bin\dstalk_cli.exe` |
| Mac / Linux | `cd tools && bash setup.sh` | `bash build.sh` | `build/bin/dstalk_cli` |
```bash
cd tools && setup.bat # 1. 安装工具链 (CMake / Ninja / LLVM / Conan2)
build.bat # 2. 编译
# 3. 创建 config.toml # 见教程: docs/tutorial/quick-start.md
build/dstalk_cli/dstalk_cli.exe # 4. 运行
# 4. 运行 (路径见上表)
# 5. 输入自然语言 # "帮我写一个 C 程序"
```