From faf7f752e2abf8fa9bed429650b992dff47ceef1 Mon Sep 17 00:00:00 2001 From: xierfloat <2053619887@qq.com> Date: Sat, 7 Mar 2026 10:57:43 +0800 Subject: [PATCH 1/7] fix: resolve RoleX v2 plan/todo operations failure Fixed "No focused plan" error that occurred when executing todo operations after plan operations. The root cause was that the plan operation wasn't passing the id parameter through the call chain, preventing focusedPlanId from being set in the context. Changes: - Upgrade all RoleX packages from 1.1.0 to 1.3.0 - Fix RolexBridge.plan() to accept and pass id, after, fallback parameters - Fix RolexActionDispatcher._plan() to pass all parameters to bridge - Update MCP tool description with critical warning about plan requiring id - Add comprehensive examples for complete V2 learning cycle workflow Co-Authored-By: Claude Sonnet 4.6 --- packages/core/package.json | 12 +-- .../core/src/rolex/RolexActionDispatcher.js | 2 +- packages/core/src/rolex/RolexBridge.js | 6 +- packages/mcp-server/src/tools/action.ts | 92 ++++++++++++++++--- pnpm-lock.yaml | 12 +-- 5 files changed, 97 insertions(+), 27 deletions(-) diff --git a/packages/core/package.json b/packages/core/package.json index 0fec545a..15d85610 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -36,12 +36,12 @@ "@npmcli/arborist": "^9.2.0", "@promptx/logger": "workspace:*", "@promptx/resource": "workspace:*", - "@rolexjs/core": "^1.1.0", + "@rolexjs/core": "^1.3.0", "@rolexjs/genesis": "^1.3.0", - "@rolexjs/local-platform": "^1.1.0", - "@rolexjs/parser": "^1.1.0", - "@rolexjs/prototype": "^1.1.0", - "@rolexjs/system": "^1.1.0", + "@rolexjs/local-platform": "^1.3.0", + "@rolexjs/parser": "^1.3.0", + "@rolexjs/prototype": "^1.3.0", + "@rolexjs/system": "^1.3.0", "ajv": "^8.17.1", "better-sqlite3": "^12.4.1", "env-paths": "2.2.1", @@ -54,7 +54,7 @@ "is-electron": "^2.2.2", "peggy": "^5.0.5", "resourcexjs": "^2.14.0", - "rolexjs": "^1.1.0" + "rolexjs": "^1.3.0" }, "files": [ "dist/**/*", diff --git a/packages/core/src/rolex/RolexActionDispatcher.js b/packages/core/src/rolex/RolexActionDispatcher.js index 3e472f28..bdca442b 100644 --- a/packages/core/src/rolex/RolexActionDispatcher.js +++ b/packages/core/src/rolex/RolexActionDispatcher.js @@ -120,7 +120,7 @@ class RolexActionDispatcher { } async _plan (args) { - return this.bridge.plan(args.source) + return this.bridge.plan(args.source, args.id, args.after, args.fallback) } async _todo (args) { diff --git a/packages/core/src/rolex/RolexBridge.js b/packages/core/src/rolex/RolexBridge.js index ccaeb253..893c6965 100644 --- a/packages/core/src/rolex/RolexBridge.js +++ b/packages/core/src/rolex/RolexBridge.js @@ -209,13 +209,13 @@ class RolexBridge { /** * 制定计划 (plan) - * RoleX 1.1.0: role.plan(plan) + * RoleX 1.3.0: role.plan(plan, id, after, fallback) */ - async plan (source) { + async plan (source, id, after, fallback) { await this.ensureInitialized() const roleId = this._requireActiveRole() const role = await this.rolex.activate(roleId) - return role.plan(source) + return role.plan(source, id, after, fallback) } /** diff --git a/packages/mcp-server/src/tools/action.ts b/packages/mcp-server/src/tools/action.ts index 40fb8d31..60f2cd5f 100644 --- a/packages/mcp-server/src/tools/action.ts +++ b/packages/mcp-server/src/tools/action.ts @@ -32,17 +32,87 @@ const V2_EXAMPLES = ` **V2 finish task / achieve goal:** \`\`\`json -{ "operation": "finish", "role": "_", "name": "task-id" } +// finish 操作会创建 encounter 节点,ID 格式为 {task-id}-finished +{ "operation": "finish", "role": "_", "name": "task-id", "encounter": "遇到的问题和经历..." } { "operation": "achieve", "role": "_", "experience": "learned..." } \`\`\` -**V2 learning cycle (reflect → realize → master):** +**V2 complete learning cycle (want → plan → reflect → realize → master → synthesize):** \`\`\`json -{ "operation": "reflect", "role": "_", "encounters": ["enc1", "enc2"], "experience": "Feature: ..." } -{ "operation": "realize", "role": "_", "experiences": ["exp1"], "principle": "Feature: ..." } -{ "operation": "master", "role": "_", "procedure": "Feature: ...", "id": "skill-id" } -{ "operation": "forget", "role": "_", "nodeId": "knowledge-id" } -{ "operation": "skill", "role": "_", "locator": "npm:@scope/package" } +// 完整认知循环流程(基于实际测试验证): + +// 1. 创建目标 +{ "operation": "want", "role": "_", "name": "improve-process", "source": "Feature: 改进流程\\n 作为产品经理..." } + +// 2. 制定计划(必须传入 id 参数!) +{ "operation": "plan", "role": "_", "source": "Feature: 分析问题\\n Scenario: 调研...", "id": "analysis-plan" } + +// 3. 反思 - 创建经验(可跳过 encounter,直接创建) +{ + "operation": "reflect", + "role": "_", + "encounters": [], // 空数组 = 直接创建 experience,无需预定义 encounter + "experience": "Feature: 需求变更管理经验\\n 在项目管理中发现...\\n\\n Scenario: 问题表现\\n Then 需求反复修改导致延误\\n And 团队理解不一致产生返工", + "id": "exp-1" // 自定义 ID,用于后续引用 +} + +// 4. 领悟 - 提炼原则(必须基于已存在的 experience) +{ + "operation": "realize", + "role": "_", + "experiences": ["exp-1"], // 必须是已存在的 experience ID 数组(复数!) + "principle": "Feature: 需求变更管理原则\\n Scenario: 预防原则\\n Then 预防胜于控制\\n And 充分的需求调研", + "id": "principle-1" +} + +// 5. 沉淀 - 创建标准流程 +{ + "operation": "master", + "role": "_", + "procedure": "Feature: 需求变更管理SOP\\n Background:\\n Given 需求变更是常态\\n\\n Scenario: 变更申请阶段\\n When 收到变更请求\\n Then 记录变更内容\\n And 评估影响范围", + "id": "sop-1" +} + +// 6. 传授 - 向其他角色传授知识 +{ + "operation": "synthesize", + "role": "开发工程师", // 目标角色(接收知识的角色) + "name": "需求变更管理", + "source": "Feature: 需求变更管理 - 开发视角\\n Scenario: 配合要点\\n Then 及时反馈技术可行性", + "type": "knowledge" +} + +// 7. 遗忘 - 清理过时知识(可选) +{ "operation": "forget", "role": "_", "nodeId": "outdated-knowledge-id" } +\`\`\` + +**V2 learning cycle - 关键要点:** +\`\`\` +✅ Gherkin 格式必填: experience/principle/procedure/source 都必须使用 Gherkin 格式 +✅ Feature 开头: 必须以 "Feature: 标题" 开头,包含描述 +✅ Scenario 结构: 使用 Scenario/Background 定义场景,内部使用 Then/And/Given/When +✅ 空数组可用: reflect 时 encounters: [] 可直接创建 experience,无需预定义 encounter +✅ ID 数组必填: realize 的 experiences 必须是已存在的 experience ID 数组(复数) +✅ 角色注意: synthesize 的 role 是目标角色(接收知识的角色),不是当前角色 + +🚨 CRITICAL - plan 操作必须传入 id 参数: + plan 操作如果不传入 id 参数,focused_plan_id 不会被设置, + 导致后续 todo 操作失败并报错 "No focused plan. Call plan first." + + ❌ 错误: { "operation": "plan", "role": "_", "source": "..." } + ✅ 正确: { "operation": "plan", "role": "_", "source": "...", "id": "my-plan" } +\`\`\` + +**V2 alternative: 基于任务完成的认知循环:** +\`\`\`json +// 如果想基于实际任务经历: +// 1. 完成任务 → 自动创建 encounter (ID: {task-id}-finished) +{ "operation": "finish", "role": "_", "name": "task-1", "encounter": "遇到的问题..." } + +// 2. 反思 encounter → 创建 experience +{ "operation": "reflect", "role": "_", "encounters": ["task-1-finished"], "experience": "Feature: ...", "id": "exp-1" } + +// 3-6. 后续步骤同上 \`\`\` **V2 synthesize (teach knowledge to a role):** @@ -193,7 +263,7 @@ Use \`roleResources\` to load additional sections **before** you need them: }, experience: { type: 'string', - description: 'Reflection text for achieve/abandon operations' + description: 'Experience text (Gherkin Feature format) for reflect operation, or reflection text for achieve/abandon operations' }, testable: { type: 'boolean', @@ -214,12 +284,12 @@ Use \`roleResources\` to load additional sections **before** you need them: encounters: { type: 'array', items: { type: 'string' }, - description: 'Array of encounter IDs for reflect operation' + description: 'Array of encounter node IDs for reflect operation. Must be existing encounter IDs (usually created by finish operation), or pass empty array [] to create experience directly without consuming encounters.' }, experiences: { type: 'array', items: { type: 'string' }, - description: 'Array of experience IDs for realize operation' + description: 'Array of experience node IDs for realize operation. Must be existing experience IDs created by reflect operation. This parameter is REQUIRED for realize.' }, principle: { type: 'string', @@ -251,7 +321,7 @@ Use \`roleResources\` to load additional sections **before** you need them: }, id: { type: 'string', - description: 'Optional ID for reflect/realize/master operations' + description: 'Optional ID for plan/reflect/realize/master operations. IMPORTANT: plan operation REQUIRES id parameter to set focused_plan_id, otherwise todo will fail.' }, skill: { type: 'string', diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index b9ade5d9..6f7b88fb 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -287,22 +287,22 @@ importers: specifier: workspace:* version: link:../resource '@rolexjs/core': - specifier: ^1.1.0 + specifier: ^1.3.0 version: 1.3.0 '@rolexjs/genesis': specifier: ^1.3.0 version: 1.3.0 '@rolexjs/local-platform': - specifier: ^1.1.0 + specifier: ^1.3.0 version: 1.3.0(@types/better-sqlite3@7.6.13)(better-sqlite3@12.6.2) '@rolexjs/parser': - specifier: ^1.1.0 + specifier: ^1.3.0 version: 1.3.0 '@rolexjs/prototype': - specifier: ^1.1.0 + specifier: ^1.3.0 version: 1.3.0 '@rolexjs/system': - specifier: ^1.1.0 + specifier: ^1.3.0 version: 1.3.0 ajv: specifier: ^8.17.1 @@ -341,7 +341,7 @@ importers: specifier: ^2.14.0 version: 2.20.0 rolexjs: - specifier: ^1.1.0 + specifier: ^1.3.0 version: 1.3.0 devDependencies: '@alicloud/openapi-client': From 3208cb4eaf77891d1d94c11380916efdf8ec9997 Mon Sep 17 00:00:00 2001 From: xierfloat <2053619887@qq.com> Date: Sat, 7 Mar 2026 11:28:29 +0800 Subject: [PATCH 2/7] docs: update dayu migration workflow for RoleX 1.3.0 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Updated dayu (role migration agent) documentation to reflect RoleX 1.3.0 database storage behavior and correct usage patterns based on actual migration experience. Key changes: - Remove outdated "born → activate → synthesize" workflow - Update to correct pattern: synthesize accepts targetRole parameter directly - Add critical position naming convention: "角色名+岗位" format required - Document that appoint's position parameter must match establish's name exactly - Add verification method: use directory to check members list - Update MCP tool examples with proper Chinese position names Based on real migration workflow documented in 流程.txt showing successful migrations without activate step between born and synthesize operations. Co-Authored-By: Claude Sonnet 4.6 --- packages/mcp-server/src/tools/action.ts | 10 ++++++---- .../execution/migration-workflow.execution.md | 16 +++++++++------- .../role/dayu/knowledge/rolex-api.knowledge.md | 8 ++++---- 3 files changed, 19 insertions(+), 15 deletions(-) diff --git a/packages/mcp-server/src/tools/action.ts b/packages/mcp-server/src/tools/action.ts index 60f2cd5f..397b4c82 100644 --- a/packages/mcp-server/src/tools/action.ts +++ b/packages/mcp-server/src/tools/action.ts @@ -117,6 +117,7 @@ const V2_EXAMPLES = ` **V2 synthesize (teach knowledge to a role):** \`\`\`json +// synthesize 直接指定目标角色,无需先 activate { "operation": "synthesize", "role": "target-role", "name": "domain-knowledge", "source": "Feature: ...", "type": "knowledge" } \`\`\` @@ -133,9 +134,10 @@ const V2_EXAMPLES = ` **Organization: establish position & appoint:** \`\`\`json -{ "operation": "establish", "role": "_", "name": "lead", "source": "Feature: ...", "org": "my-team" } -{ "operation": "appoint", "role": "_", "name": "my-dev", "position": "lead", "org": "my-team" } -{ "operation": "charge", "role": "_", "position": "lead", "content": "Feature: ..." } +// ⚠️ 关键:职位名必须是"角色名+岗位"格式,appoint 的 position 必须与 establish 的 name 完全一致 +{ "operation": "establish", "role": "_", "name": "技术负责人岗位", "source": "Feature: ...", "org": "my-team" } +{ "operation": "appoint", "role": "_", "name": "my-dev", "position": "技术负责人岗位", "org": "my-team" } +{ "operation": "charge", "role": "_", "position": "技术负责人岗位", "content": "Feature: ..." } { "operation": "require", "role": "_", "position": "lead", "skill": "leadership" } { "operation": "abolish", "role": "_", "position": "lead" } \`\`\` @@ -259,7 +261,7 @@ Use \`roleResources\` to load additional sections **before** you need them: }, type: { type: 'string', - description: 'Synthesize type: knowledge, experience, or voice. For synthesize operation, role parameter specifies the target role to teach.' + description: 'Synthesize type: knowledge, experience, or voice. For synthesize operation, the role parameter specifies the target role to teach (no need to activate first).' }, experience: { type: 'string', diff --git a/packages/resource/resources/role/dayu/execution/migration-workflow.execution.md b/packages/resource/resources/role/dayu/execution/migration-workflow.execution.md index 3cc643de..056a984b 100644 --- a/packages/resource/resources/role/dayu/execution/migration-workflow.execution.md +++ b/packages/resource/resources/role/dayu/execution/migration-workflow.execution.md @@ -16,15 +16,14 @@ ### Step 3: 创建V2角色 - born:用整合后的 persona 描述创建角色 - - **activate**:born 后必须立即 activate 该角色(synthesize 依赖活跃角色) - - synthesize type=voice:迁移有独立价值的 thought - - synthesize type=knowledge:迁移专有知识 - - synthesize type=experience:迁移关键执行经验 - - ⚠️ 严格顺序:born → activate → synthesize,不可跳过 activate + - synthesize type=voice:迁移有独立价值的 thought(传入 targetRole 参数) + - synthesize type=knowledge:迁移专有知识(传入 targetRole 参数) + - synthesize type=experience:迁移关键执行经验(传入 targetRole 参数) + - ⚠️ 关键:synthesize 必须传入 targetRole 参数(角色名),无需先 activate ### Step 4: 组织安排(可选) - 如果角色属于某个团队 → hire 到组织 - - 如果角色有明确职责 → establish 职位 + appoint + - 如果角色有明确职责 → establish 职位(职位名必须是"角色名+岗位"格式)+ appoint(position 参数必须与 establish 的 name 完全一致) ### Step 5: 验证 - identity 查看角色完整身份,确认所有 feature 已写入 @@ -33,10 +32,13 @@ - - born 之后必须 activate,然后才能 synthesize——这是最常见的错误 + - synthesize 必须传入 targetRole 参数(角色名),无需先 activate - IF V1角色有大量thought THEN 整合为精炼的persona,不要逐个迁移 - IF knowledge是通用知识 THEN 不迁移(AI已具备) - IF execution是标准流程 THEN 映射为duty;IF是领域知识 THEN 映射为knowledge - 迁移前必须向用户确认映射方案 + - ⚠️ 职位命名规范:establish 创建职位时,name 必须是"角色名+岗位"格式(如"产品经理岗位") + - ⚠️ appoint 任命时,position 参数必须与 establish 的 name 完全一致 + - 验证方式:用 directory 检查 members 列表,而不是只看命令返回值 diff --git a/packages/resource/resources/role/dayu/knowledge/rolex-api.knowledge.md b/packages/resource/resources/role/dayu/knowledge/rolex-api.knowledge.md index 83a55e2b..816b097d 100644 --- a/packages/resource/resources/role/dayu/knowledge/rolex-api.knowledge.md +++ b/packages/resource/resources/role/dayu/knowledge/rolex-api.knowledge.md @@ -6,19 +6,19 @@ |---|---|---|---|---| | born | name, source | - | 无 | 创建角色 | | activate | role | version | 无 | 激活角色(设为当前活跃角色) | - | synthesize | name, source, type | - | **必须先 activate** | 教授知识/经验/声音 | + | synthesize | name, source, type | targetRole | 无 | 教授知识/经验/声音 | | identity | - | role | 无 | 查看角色身份 | - > ⚠️ 关键:born 只创建角色,不会自动激活。synthesize 前必须 activate,否则报错 "No active V2 role"。 + > ⚠️ 关键:born 只创建角色,不会自动激活。synthesize 可以传入 targetRole 参数指定目标角色,无需先 activate。如果不传 targetRole,则使用当前活跃角色(需要先 activate)。 ### 组织操作 | 操作 | 必需参数 | 可选参数 | 说明 | |---|---|---|---| | found | name | source, parent | 创建组织 | - | establish | name, source, org | - | 在组织中创建职位 | + | establish | name, source, org | - | 在组织中创建职位。⚠️ name 必须是"角色名+岗位"格式(如"产品经理岗位") | | hire | name, org | - | 雇佣角色到组织 | | fire | name, org | - | 从组织解雇角色 | - | appoint | name, position, org | - | 任命角色到职位 | + | appoint | name, position, org | - | 任命角色到职位。⚠️ position 必须与 establish 的 name 完全一致 | | dismiss | name, org | - | 免除角色职位 | | directory | - | - | 查看全局目录 | From 5b8dc6ae4f13b64c441b43f9ce95bee6951590d9 Mon Sep 17 00:00:00 2001 From: xierfloat <2053619887@qq.com> Date: Sat, 7 Mar 2026 11:40:05 +0800 Subject: [PATCH 3/7] feat: add v2.2.1 update notification Added notification for v2.2.1 release highlighting RoleX V2 cognitive cycle support and Dayu migration fixes. Changes: - Add v2.2.1 notification to notification center - Document core operations: want, plan, todo, finish, achieve, focus, abandon - Document self-reflection cycle: reflect, realize, master, synthesize, forget - Highlight Dayu migration feature fix for V1 to V2 role migration - Add both Chinese and English translations Co-Authored-By: Claude Sonnet 4.6 --- apps/desktop/src/i18n/locales/en.json | 4 ++++ apps/desktop/src/i18n/locales/zh-CN.json | 4 ++++ .../view/components/notifications/notificationService.ts | 8 ++++++++ 3 files changed, 16 insertions(+) diff --git a/apps/desktop/src/i18n/locales/en.json b/apps/desktop/src/i18n/locales/en.json index 1df513f0..e423aeff 100644 --- a/apps/desktop/src/i18n/locales/en.json +++ b/apps/desktop/src/i18n/locales/en.json @@ -803,6 +803,10 @@ "title": "v2.2.0 Update Released", "content": "New notification center, AgentX config with preset & OpenAI protocol detection, RoleX core upgraded from v0.11.0 to v1.3.0, fixed conversation rename bug, fixed Windows Git link issue. V2 role import/export/delete features temporarily disabled." }, + "updateV221": { + "title": "v2.2.1 Update Released", + "content": "🎉 V2 RoleX now supports complete cognitive cycle!\n\n🎯 Core Operations: want (set goals), plan (create plans), todo (create tasks), finish (complete tasks), achieve (reach goals), focus (view progress), abandon (give up goals)\n\n🧠 Self-Reflection: reflect (reflect on issues), realize (summarize principles), master (create SOPs), synthesize (teach knowledge), forget (forget outdated knowledge)\n\n✨ Fixed Dayu migration feature, supports V1 to V2 role migration" + }, "rolexUpgrade": { "title": "RoleX (V2) Architecture Upgrade", "content": "Existing V2 roles need to be upgraded. Please activate Nuwa and ask her to upgrade and migrate your roles to continue using them." diff --git a/apps/desktop/src/i18n/locales/zh-CN.json b/apps/desktop/src/i18n/locales/zh-CN.json index 7bc628af..bfaaaf5d 100644 --- a/apps/desktop/src/i18n/locales/zh-CN.json +++ b/apps/desktop/src/i18n/locales/zh-CN.json @@ -800,6 +800,10 @@ "title": "v2.2.0 版本更新", "content": "新增通知中心、AgentX 配置增加预设与 OpenAI 协议识别功能、V2 RoleX 内核从 v0.11.0 更新到 v1.3.0、修复对话重命名后无效的 bug、修复 Windows 平台点击 Git 链接无响应的 bug。V2 的角色导入导出与删除功能暂时下架。" }, + "updateV221": { + "title": "v2.2.1 版本更新", + "content": "🎉 V2 RoleX 成功支持完整认知循环!\n\n🎯 核心操作:want(制定目标)、plan(制定计划)、todo(创建任务)、finish(完成任务)、achieve(达成目标)、focus(查看进度)、abandon(放弃目标)\n\n🧠 自我沉淀:reflect(反思问题)、realize(总结原则)、master(沉淀流程)、synthesize(传授知识)、forget(遗忘过时知识)\n\n✨ 修复大禹迁移功能,支持 V1 角色迁移到 V2" + }, "rolexUpgrade": { "title": "RoleX(V2)架构升级", "content": "原有 V2 角色需要升级。请激活女娲,让女娲进行升级与迁移才能继续使用。" diff --git a/apps/desktop/src/view/components/notifications/notificationService.ts b/apps/desktop/src/view/components/notifications/notificationService.ts index ed35a334..d65c2427 100644 --- a/apps/desktop/src/view/components/notifications/notificationService.ts +++ b/apps/desktop/src/view/components/notifications/notificationService.ts @@ -5,6 +5,14 @@ const SHOWN_KEY = "promptx_notifications_shown" // 默认通知数据 const defaultNotifications: Notification[] = [ + { + id: "update-v2.2.1", + title: "notifications.updateV221.title", + content: "notifications.updateV221.content", + type: "success", + timestamp: Date.now(), + read: false, + }, { id: "update-v2.2.0", title: "notifications.updateV220.title", From 4b71b5c9ceebe3413e7d5f6d97790061040ed129 Mon Sep 17 00:00:00 2001 From: xierfloat <2053619887@qq.com> Date: Sat, 7 Mar 2026 11:44:34 +0800 Subject: [PATCH 4/7] feat: guide V2 roles to use action cognitive cycle instead of remember/recall Updated remember and recall tools to provide helpful guidance when used with V2 roles, directing users to the appropriate action tool operations instead. Changes: - remember tool: Guide V2 roles to use reflect/realize/master/synthesize/forget - recall tool: Guide V2 roles to use identity/focus for knowledge queries - Add detailed examples showing correct action tool usage - Explain that V2 roles use database storage and cognitive cycle system - Maintain backward compatibility for V1 roles (DPML format) This improves user experience by providing clear migration paths from V1 memory tools to V2 cognitive cycle operations. Co-Authored-By: Claude Sonnet 4.6 --- packages/mcp-server/src/tools/recall.ts | 35 +++++++++++++++++++++-- packages/mcp-server/src/tools/remember.ts | 26 +++++++++++++++-- 2 files changed, 57 insertions(+), 4 deletions(-) diff --git a/packages/mcp-server/src/tools/recall.ts b/packages/mcp-server/src/tools/recall.ts index 1e526a5c..ceb88e6a 100644 --- a/packages/mcp-server/src/tools/recall.ts +++ b/packages/mcp-server/src/tools/recall.ts @@ -91,7 +91,38 @@ Step 3: Answer using recalled context if (await dispatcher.isV2Role(args.role)) { return outputAdapter.convertToMCPFormat({ type: 'error', - content: `❌ V2 角色 "${args.role}" 不支持 recall 功能\n\nV2 角色(RoleX)使用数据库存储,记忆管理功能正在开发中。\n当前 recall 工具仅支持 V1 角色(DPML 格式)。\n\n如需使用记忆功能,请使用 V1 角色。` + content: `❌ V2 角色 "${args.role}" 不支持 recall 工具 + +V2 角色(RoleX)使用数据库存储和认知循环系统,请使用 action 工具查询角色知识: + +🔍 **查询角色知识**: +• identity - 查看角色完整身份和知识体系 +• focus - 查看当前进行中的目标和任务 + +🧠 **自我沉淀(学习循环)**: +• reflect - 反思遇到的问题,创建经验 +• realize - 总结领悟的原则 +• master - 沉淀为标准操作流程(SOP) +• synthesize - 向其他角色传授知识 +• forget - 遗忘过时的知识 + +**示例 - 查看角色知识**: +\`\`\`json +{ + "operation": "identity", + "role": "${args.role}" +} +\`\`\` + +**示例 - 查看当前进度**: +\`\`\`json +{ + "operation": "focus", + "role": "${args.role}" +} +\`\`\` + +当前 recall 工具仅支持 V1 角色(DPML 格式)。` }); } } catch (e) { @@ -115,4 +146,4 @@ Step 3: Answer using recalled context const result = await cli.execute('recall', cliArgs); return outputAdapter.convertToMCPFormat(result); } -}; \ No newline at end of file +}; diff --git a/packages/mcp-server/src/tools/remember.ts b/packages/mcp-server/src/tools/remember.ts index 4da697d5..9461d021 100644 --- a/packages/mcp-server/src/tools/remember.ts +++ b/packages/mcp-server/src/tools/remember.ts @@ -129,7 +129,29 @@ Strip content to minimum essential words. For each word ask: does removing it ch if (await dispatcher.isV2Role(args.role)) { return outputAdapter.convertToMCPFormat({ type: 'error', - content: `❌ V2 角色 "${args.role}" 不支持 remember 功能\n\nV2 角色(RoleX)使用数据库存储,记忆管理功能正在开发中。\n当前 remember 工具仅支持 V1 角色(DPML 格式)。\n\n如需使用记忆功能,请使用 V1 角色。` + content: `❌ V2 角色 "${args.role}" 不支持 remember 工具 + +V2 角色(RoleX)使用数据库存储和认知循环系统,请使用 action 工具的自我沉淀操作: + +🧠 **自我沉淀(学习循环)**: +• reflect - 反思遇到的问题,创建经验 +• realize - 总结领悟的原则 +• master - 沉淀为标准操作流程(SOP) +• synthesize - 向其他角色传授知识 +• forget - 遗忘过时的知识 + +**示例**: +\`\`\`json +{ + "operation": "reflect", + "role": "${args.role}", + "encounters": [], + "experience": "Feature: 学到的经验\\n Scenario: 具体场景\\n Then 关键发现", + "id": "exp-1" +} +\`\`\` + +当前 remember 工具仅支持 V1 角色(DPML 格式)。` }); } } catch (e) { @@ -146,4 +168,4 @@ Strip content to minimum essential words. For each word ask: does removing it ch const result = await cli.execute('remember', [args]); return outputAdapter.convertToMCPFormat(result); } -}; \ No newline at end of file +}; From 91a679387aa0455e5528183c4e20c5340cc81df2 Mon Sep 17 00:00:00 2001 From: xierfloat <2053619887@qq.com> Date: Sat, 7 Mar 2026 11:51:05 +0800 Subject: [PATCH 5/7] feat: add V2-only preset questions to AgentX welcome page Added two new preset questions that only appear when V2 is enabled: - "Activate Dayu to migrate v1 roles to v2" - "View current organization structure" Changes: - Add dayu and directory preset questions to i18n files (zh-CN and en) - Update WelcomePage to fetch V2 config on mount - Conditionally show V2-only questions based on enableV2 setting - Adjust grid layout: 2 columns (V2 off) or 3 columns (V2 on) - Add GitBranch and Users icons for new presets This provides quick access to V2-specific features for users who have enabled RoleX V2 in system settings. Co-Authored-By: Claude Sonnet 4.6 --- apps/desktop/src/i18n/locales/en.json | 6 +- apps/desktop/src/i18n/locales/zh-CN.json | 6 +- .../components/container/WelcomePage.tsx | 93 +++++++++++++------ 3 files changed, 75 insertions(+), 30 deletions(-) diff --git a/apps/desktop/src/i18n/locales/en.json b/apps/desktop/src/i18n/locales/en.json index e423aeff..9805240b 100644 --- a/apps/desktop/src/i18n/locales/en.json +++ b/apps/desktop/src/i18n/locales/en.json @@ -769,7 +769,11 @@ "role": "Explore available roles", "rolePrompt": "What roles are available?", "tool": "Explore available tools", - "toolPrompt": "What tools are available?" + "toolPrompt": "What tools are available?", + "dayu": "Activate Dayu to migrate roles", + "dayuPrompt": "Activate Dayu to help me migrate v1 roles to v2", + "directory": "View organization structure", + "directoryPrompt": "Show me the current organization structure" } } }, diff --git a/apps/desktop/src/i18n/locales/zh-CN.json b/apps/desktop/src/i18n/locales/zh-CN.json index bfaaaf5d..4f30b7f7 100644 --- a/apps/desktop/src/i18n/locales/zh-CN.json +++ b/apps/desktop/src/i18n/locales/zh-CN.json @@ -766,7 +766,11 @@ "role": "探索可用角色", "rolePrompt": "有哪些可用的角色?", "tool": "探索可用工具", - "toolPrompt": "有哪些可用的工具?" + "toolPrompt": "有哪些可用的工具?", + "dayu": "激活大禹,迁移角色", + "dayuPrompt": "激活大禹帮我把v1迁移到v2", + "directory": "查看组织架构", + "directoryPrompt": "查看我现在的组织架构" } } }, diff --git a/apps/desktop/src/view/components/agentx-ui/components/container/WelcomePage.tsx b/apps/desktop/src/view/components/agentx-ui/components/container/WelcomePage.tsx index 1d11b196..6da768c1 100644 --- a/apps/desktop/src/view/components/agentx-ui/components/container/WelcomePage.tsx +++ b/apps/desktop/src/view/components/agentx-ui/components/container/WelcomePage.tsx @@ -9,7 +9,7 @@ */ import * as React from "react"; -import { Send, Hammer, Sparkles, Bot, Wrench } from "lucide-react"; +import { Send, Hammer, Sparkles, Bot, Wrench, Users, GitBranch } from "lucide-react"; import { useTranslation } from "react-i18next"; import { cn } from "@/components/agentx-ui/utils"; import logo from "../../../../../../assets/icons/icon.png"; @@ -75,37 +75,71 @@ export function WelcomePage({ }: WelcomePageProps): React.ReactElement { const { t } = useTranslation(); const [inputValue, setInputValue] = React.useState(""); + const [enableV2, setEnableV2] = React.useState(false); + + // Load V2 config on mount + React.useEffect(() => { + window.electronAPI?.invoke("server-config:get").then((config: any) => { + if (config?.enableV2) { + setEnableV2(true); + } + }).catch(() => { + // Ignore errors, default to false + }); + }, []); const tagline = t("agentxUI.welcome.tagline"); const displayText = useTypewriter(tagline, 100, true); // Preset questions - const presetQuestions: PresetQuestion[] = React.useMemo(() => [ - { - id: "luban", - icon: , - title: t("agentxUI.welcome.presets.luban"), - prompt: t("agentxUI.welcome.presets.lubanPrompt"), - }, - { - id: "nuwa", - icon: , - title: t("agentxUI.welcome.presets.nuwa"), - prompt: t("agentxUI.welcome.presets.nuwaPrompt"), - }, - { - id: "role", - icon: , - title: t("agentxUI.welcome.presets.role"), - prompt: t("agentxUI.welcome.presets.rolePrompt"), - }, - { - id: "tool", - icon: , - title: t("agentxUI.welcome.presets.tool"), - prompt: t("agentxUI.welcome.presets.toolPrompt"), - }, - ], [t]); + const presetQuestions: PresetQuestion[] = React.useMemo(() => { + const baseQuestions = [ + { + id: "luban", + icon: , + title: t("agentxUI.welcome.presets.luban"), + prompt: t("agentxUI.welcome.presets.lubanPrompt"), + }, + { + id: "nuwa", + icon: , + title: t("agentxUI.welcome.presets.nuwa"), + prompt: t("agentxUI.welcome.presets.nuwaPrompt"), + }, + { + id: "role", + icon: , + title: t("agentxUI.welcome.presets.role"), + prompt: t("agentxUI.welcome.presets.rolePrompt"), + }, + { + id: "tool", + icon: , + title: t("agentxUI.welcome.presets.tool"), + prompt: t("agentxUI.welcome.presets.toolPrompt"), + }, + ]; + + // Add V2-only questions + if (enableV2) { + baseQuestions.push( + { + id: "dayu", + icon: , + title: t("agentxUI.welcome.presets.dayu"), + prompt: t("agentxUI.welcome.presets.dayuPrompt"), + }, + { + id: "directory", + icon: , + title: t("agentxUI.welcome.presets.directory"), + prompt: t("agentxUI.welcome.presets.directoryPrompt"), + } + ); + } + + return baseQuestions; + }, [t, enableV2]); const handleSend = React.useCallback(() => { if (inputValue.trim() && onSend) { @@ -181,7 +215,10 @@ export function WelcomePage({ {/* Preset question cards */}
-
+
{presetQuestions.map((question) => (