feat: 升级至 v0.2.2 — 工作空间路径注入、Provider 切换修复、编码与样式优化

功能增强:
- System Prompt 注入当前工作空间路径到动态区(LLM 可使用绝对路径调用工具)
- ContextBuilder.buildSystemPrompt 新增 workspacePath 参数

Provider 切换修复:
- reloadAdapter 返回 boolean,失败时 sendMessage 中止发送
- 切换 Provider 时自动清空 apiKey(不同 Provider key 不通用)
- apiKey 为空时显示警告提示
- Provider 切换事件加 sessionId 字段

编码修复:
- run_command 使用 encoding: 'buffer' 获取原始字节
- 新增 decodeBuffer 智能解码:UTF-8 严格 → GBK → UTF-8 宽松
- 修复不响应 chcp 的 Windows 命令中文乱码问题

样式优化:
- 代码块底色改用主题变量(灰底主题色文字,双主题适配)
- 表格标题 th/td 底色和文字色改用主题变量
- CodeBlock 组件 pre 背景从 secondary.main 改为 background.default
- 设置面板已自动执行工具行 opacity 0.8→0.15(淡绿底,文字清晰)

版本号 0.2.1 → 0.2.2
This commit is contained in:
thzxx
2026-07-12 13:46:09 +08:00
parent 6e49c44742
commit aa13a98f63
9 changed files with 96 additions and 32 deletions
+9 -2
View File
@@ -25,6 +25,7 @@ interface ContextBuildParams {
history?: MetonaMessage[];
memories?: MetonaMemoryItem[];
workspaceFiles?: WorkspaceFiles;
workspacePath?: string;
contextWindow?: number;
}
@@ -43,10 +44,11 @@ export class ContextBuilder {
history = [],
memories = [],
workspaceFiles,
workspacePath,
contextWindow = 128_000,
} = params;
const systemPrompt = this.buildSystemPrompt(workspaceFiles);
const systemPrompt = this.buildSystemPrompt(workspaceFiles, workspacePath);
const estimatedTokens = this.estimateTokens(history, memories, availableTools, userInput, systemPrompt);
return {
@@ -76,7 +78,7 @@ export class ContextBuilder {
* 4. MEMORY.md(记忆)— 动态区
* 5. 内置安全准则 — 尾部锚定
*/
buildSystemPrompt(workspaceFiles?: WorkspaceFiles): MetonaSystemPrompt {
buildSystemPrompt(workspaceFiles?: WorkspaceFiles, workspacePath?: string): MetonaSystemPrompt {
let staticUserProfile = '';
// ===== 静态区:用户画像(变化不频繁,放入静态区利用 LLM 缓存)=====
@@ -99,6 +101,11 @@ export class ContextBuilder {
// ===== 动态区:记忆 =====
const dynamicParts: string[] = [];
// 注入当前工作空间路径(动态区,路径可能切换故不放入静态区)
if (workspacePath) {
dynamicParts.push(`## Current Workspace\nWorkspace root path: \`${workspacePath}\`\n\nAll relative paths in tool calls are resolved against this workspace root. Use this path when absolute paths are required (e.g., in run_command).`);
}
if (workspaceFiles?.memory) {
const memoryContent = this.extractContent(workspaceFiles.memory);
if (memoryContent) {