From 988efd17334f1849a06957025aedebf86b001dc3 Mon Sep 17 00:00:00 2001 From: thzxx Date: Fri, 5 Jun 2026 09:35:39 +0800 Subject: [PATCH] =?UTF-8?q?v0.9.0:=20SOUL.md/AGENT.md/USER.md=20=E5=8C=96?= =?UTF-8?q?=E4=B8=BA=E5=B7=A5=E4=BD=9C=E7=A9=BA=E9=97=B4=E6=96=87=E4=BB=B6?= =?UTF-8?q?=EF=BC=8C=E5=8E=BB=E6=8E=89=E4=BB=A3=E7=A0=81=E5=86=85=E7=A1=AC?= =?UTF-8?q?=E7=BC=96=E7=A0=81=E6=8F=90=E7=A4=BA=E8=AF=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 版本号 v1.1.0 → v0.9.0 - AGENT_SYSTEM_PROMPT + TOOL_USAGE_GUIDE 提取为 AGENT.md(工作空间优先,内置 fallback) - SOUL.md 同级改造(工作空间优先,内置 fallback) - 删除 inferUserProfile 自动用户画像,改为 USER.md 手动编辑 - 三个 .md 内置版本放在 src/renderer/public/(Vite publicDir 自动复制) --- package.json | 4 +- src/main/menu.ts | 2 +- src/renderer/components/input-area.ts | 46 +++++- src/renderer/index.html | 2 +- src/renderer/public/AGENT.md | 25 ++++ src/renderer/public/SOUL.md | 41 ++++++ src/renderer/public/USER.md | 3 + src/renderer/services/agent-engine.ts | 198 ++++++++++---------------- 8 files changed, 194 insertions(+), 127 deletions(-) create mode 100644 src/renderer/public/AGENT.md create mode 100644 src/renderer/public/SOUL.md create mode 100644 src/renderer/public/USER.md diff --git a/package.json b/package.json index 66adf82..8b525c9 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "metona-ollama-desktop", - "version": "1.1.0", + "version": "0.9.0", "description": "Metona Ollama - TypeScript + Electron 桌面 AI 聊天客户端", "main": "dist/main/main.js", "author": "thzxx", @@ -48,7 +48,7 @@ "requestedExecutionLevel": "asInvoker" }, "nsis": { - "artifactName": "Metona Ollama Setup v1.1.0.${ext}", + "artifactName": "Metona Ollama Setup v0.9.0.${ext}", "oneClick": false, "allowToChangeInstallationDirectory": true, "createDesktopShortcut": true, diff --git a/src/main/menu.ts b/src/main/menu.ts index 03910d9..d66cdf5 100644 --- a/src/main/menu.ts +++ b/src/main/menu.ts @@ -101,7 +101,7 @@ export function createMenu(): void { dialog.showMessageBox(mainWindow!, { type: 'info', title: '关于 Metona Ollama', - message: 'Metona Ollama Desktop v1.1.0', + message: 'Metona Ollama Desktop v0.9.0', detail: 'TypeScript + Electron Ollama AI 聊天客户端\n\nhttps://gitee.com/thzxx/metona-ollama', icon: getIconPath() }); diff --git a/src/renderer/components/input-area.ts b/src/renderer/components/input-area.ts index 14b40a3..d59faa9 100644 --- a/src/renderer/components/input-area.ts +++ b/src/renderer/components/input-area.ts @@ -697,6 +697,7 @@ export async function sendMessage(): Promise { // ── 扫描工作空间 SOUL.md ── let soulContent = ''; + let soulMdContent = ''; const workspaceDir = getWorkspaceDirPath(); if (workspaceDir) { try { @@ -704,9 +705,44 @@ export async function sendMessage(): Promise { workspaceDir.replace(/\/+$/, '') + '/SOUL.md' ); if (soulResult?.success && soulResult.content) { - soulContent = `[SOUL.md] ${soulResult.content}`; + soulMdContent = soulResult.content; } - } catch { /* SOUL.md 不存在,静默跳过 */ } + } catch { /* 工作空间 SOUL.md 不存在 */ } + } + + // fallback:读取内置 SOUL.md + if (!soulMdContent) { + try { + const resp = await fetch('./SOUL.md'); + if (resp.ok) { + soulMdContent = await resp.text(); + } + } catch { /* 内置 SOUL.md 也不可用 */ } + } + + if (soulMdContent) { + soulContent = `[SOUL.md] ${soulMdContent}`; + } + + // ── 扫描工作空间 USER.md ── + let userMdContent = ''; + if (workspaceDir) { + try { + const userResult = await window.metonaDesktop?.workspace.readFile( + workspaceDir.replace(/\/+$/, '') + '/USER.md' + ); + if (userResult?.success && userResult.content) { + userMdContent = userResult.content; + } + } catch { /* 工作空间 USER.md 不存在 */ } + } + if (!userMdContent) { + try { + const resp = await fetch('./USER.md'); + if (resp.ok) { + userMdContent = await resp.text(); + } + } catch { /* 内置 USER.md 也不可用 */ } } // ── Agent 记忆注入 ── @@ -716,7 +752,8 @@ export async function sendMessage(): Promise { const relevantMemories = searchMemories(userMessage, 6); if (relevantMemories.length > 0) { const memoryContext = buildMemoryContext(relevantMemories); - chatParams.system = (soulContent ? soulContent + '\n\n' : '') + memoryContext; + const parts = [soulContent, userMdContent ? `[USER.md] ${userMdContent}` : '', memoryContext].filter(Boolean); + chatParams.system = parts.join('\n\n'); for (const m of relevantMemories) { await markMemoryUsed(m.id); } @@ -725,7 +762,8 @@ export async function sendMessage(): Promise { } } if (soulContent && !chatParams.system) { - chatParams.system = soulContent; + const parts = [soulContent, userMdContent ? `[USER.md] ${userMdContent}` : ''].filter(Boolean); + chatParams.system = parts.join('\n\n'); } // 存入 state 供 chat-area 渲染系统提示词卡片 diff --git a/src/renderer/index.html b/src/renderer/index.html index b24644d..df2a2b9 100644 --- a/src/renderer/index.html +++ b/src/renderer/index.html @@ -28,7 +28,7 @@
Metona Ollama - v1.1.0 + v0.9.0