diff --git a/docs/DEVELOPMENT.md b/docs/DEVELOPMENT.md index 43006c6..af55505 100644 --- a/docs/DEVELOPMENT.md +++ b/docs/DEVELOPMENT.md @@ -61,8 +61,7 @@ src/ │ ├── index.html # 入口 HTML(三栏布局 + 全部模态框) │ ├── public/ │ │ ├── AGENT.md # 内置 Agent 行为准则文档 -│ │ ├── SOUL.md # 内置 AI 人格定义 -│ │ └── USER.md # 内置用户画像模板 +│ │ ├── SOUL.md # AI 人格定义(内置 fallback) │ ├── api/ │ │ └── ollama.ts # Ollama REST API 客户端(流式 + 模型管理) │ ├── components/ # 15 个 UI 组件(原生 DOM) @@ -195,7 +194,7 @@ INIT → THINKING → PARSING → EXECUTING → OBSERVING → REFLECTING → (CO | 状态 | 处理器 | 职责 | |------|--------|------| -| INIT | `handleInit()` | 构建系统提示词、加载 SOUL/AGENT/USER.md、记忆检索、上下文压缩检测 | +| INIT | `handleInit()` | 构建系统提示词、加载 SOUL/AGENT/USER.md(USER.md 仅工作空间)、记忆检索、上下文压缩检测 | | THINKING | `handleThinking()` | 调用 Ollama 流式 API、工具缓存检查、任务感知注入、Token 预算警告 | | PARSING | `handleParsing()` | 解析模型输出、提取 tool_calls、文本兜底解析 | | EXECUTING | `handleExecuting()` | 按批次并行执行工具、重试(最多 2 次)、去重检测、Hook 触发 | @@ -285,7 +284,7 @@ Hook 异步并行执行,失败不阻塞主流程。可动态注册/移除。 - **安全豁免**:工作空间目录通过 `addBlocklistExemptions()` 注册,不受路径黑名单限制 - 终端:命令无超时限制,实时流式输出,支持终止 - 文件浏览:限工作空间内,支持上级导航、文件预览 -- 自定义文件:`SOUL.md`(人格,不可压缩)、`AGENT.md`(行为准则)、`USER.md`(用户画像) +- 自定义文件:`SOUL.md`(人格,不可压缩)、`AGENT.md`(行为准则)、`USER.md`(用户画像,仅工作空间) --- diff --git a/src/renderer/index.html b/src/renderer/index.html index a34108d..0228ca9 100644 --- a/src/renderer/index.html +++ b/src/renderer/index.html @@ -446,7 +446,7 @@

🤖 Agent Loop 增强

🔌 MCP(Model Context Protocol)

🔍 SearXNG 元搜索引擎

-

📋 自定义文件(SOUL.md / AGENT.md / USER.md)

+

📋 自定义文件(SOUL.md / AGENT.md / USER.md)

📊 Token 实时监控

🖥️ 布局说明

🕐 历史记录

diff --git a/src/renderer/public/USER.md b/src/renderer/public/USER.md deleted file mode 100644 index 897728c..0000000 --- a/src/renderer/public/USER.md +++ /dev/null @@ -1,3 +0,0 @@ -# USER.md - -> 💡 在此文件中描述你自己:技术栈、偏好、习惯等。AI 会在对话中自动参考这些信息。 diff --git a/src/renderer/services/agent-engine.ts b/src/renderer/services/agent-engine.ts index c53b012..a86f896 100644 --- a/src/renderer/services/agent-engine.ts +++ b/src/renderer/services/agent-engine.ts @@ -502,28 +502,19 @@ async function handleInit( systemPromptParts.push(`[AGENT.md] ${truncated}`); } - // ── 扫描工作空间 USER.md ── - let userMdContent = ''; + // ── 扫描工作空间 USER.md(仅工作空间,无内置 fallback)── if (workspaceDir) { try { const userResult = await window.metonaDesktop?.workspace.readFile( workspaceDir.replace(/[\\/]+$/, '') + '/USER.md' ); if (userResult?.success && userResult.content) { - userMdContent = userResult.content; + const userMdContent = userResult.content; + systemPromptParts.push(`[USER.md] ${userMdContent}`); logInfo('USER.md 已从工作空间加载', `${userResult.lines || 0} 行`); } } catch { /* ignore */ } } - if (!userMdContent) { - try { - const resp = await fetch('./USER.md'); - if (resp.ok) { userMdContent = await resp.text(); logInfo('USER.md 已从内置加载', `${userMdContent.length} 字符`); } - } catch { /* ignore */ } - } - if (userMdContent) { - systemPromptParts.push(`[USER.md] ${userMdContent}`); - } // 注入记忆上下文 if (userContent) {