From a360982a9b9748f37398fdfd70952c41f150524b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=86=B0=E6=9C=94?= <565183519@qq.com> Date: Sat, 8 Aug 2026 11:15:34 +0800 Subject: [PATCH] feat: add HoloLake folder import and official assistant --- ...AKE-DESKTOP-0.5.1-IMPORT-20260808-001.json | 42 ++++ .../server/persona-agent.ts | 43 ++-- .../guanghu-knowledge-base/src/App.tsx | 66 ++++- .../src/components/AgentChat.tsx | 14 +- .../src/components/DocTree.tsx | 5 +- .../src/components/Editor.tsx | 5 +- .../guanghu-knowledge-base/src/styles/app.css | 226 +++++++++++++++--- .../electron/folder-import.ts | 156 ++++++++++++ .../hololake-desktop/electron/main.ts | 14 +- .../hololake-desktop/electron/preload.ts | 6 +- .../hololake-desktop/package-lock.json | 4 +- product-source/hololake-desktop/package.json | 2 +- 12 files changed, 507 insertions(+), 76 deletions(-) create mode 100644 deployment/receipts/GH-HOLOLAKE-DESKTOP-0.5.1-IMPORT-20260808-001.json create mode 100644 product-source/hololake-desktop/electron/folder-import.ts diff --git a/deployment/receipts/GH-HOLOLAKE-DESKTOP-0.5.1-IMPORT-20260808-001.json b/deployment/receipts/GH-HOLOLAKE-DESKTOP-0.5.1-IMPORT-20260808-001.json new file mode 100644 index 0000000..1ea1c28 --- /dev/null +++ b/deployment/receipts/GH-HOLOLAKE-DESKTOP-0.5.1-IMPORT-20260808-001.json @@ -0,0 +1,42 @@ +{ + "schema": "guanghu.desktop-delivery-receipt/v1", + "receipt_id": "GH-HOLOLAKE-DESKTOP-0.5.1-IMPORT-20260808-001", + "development_id": "DEV-20260808-004", + "source_base_commit": "46bdd0ca738f3fea0896056bf902b92675b53e2d", + "source_commit": "SELF", + "target": { + "path": "/Users/bingshuolingdianyuanhe/Desktop/HoloLake Era.app", + "version": "0.5.1", + "bundle_identifier": "com.guanghu.hololake-desktop", + "binary_sha256": "08bea54b9667b639b90a4cd671082227b318fceaf5e53e426a3a4a3227342bc4", + "app_asar_sha256": "afb3b328fdbb3ad1d7a9c8bbb74bcc06f028a33e901ccbffc791bed6292d8505" + }, + "result": "PASS_100_LOCAL_DEVELOPMENT_DELIVERY", + "implemented": { + "folder_import": "native macOS directory picker; recursive bounded import for Markdown, TXT, CSV, JSON and YAML; image assets copied; unsupported formats counted", + "import_versioning": "one Git commit per completed folder import; first imported document opens automatically", + "knowledge_ui": "HoloLake knowledge-space shell with restrained dark navigation, light reading canvas, document tree and import onboarding", + "assistant_prompt": "official HoloLake assistant identity, controlled-tool boundary, receipt-based completion claims and non-anthropomorphic language", + "desktop": "draggable Electron title region, signed arm64 application, existing macOS safeStorage model configuration preserved" + }, + "verification": { + "production_build": "PASS", + "codesign": "valid on disk and satisfies designated requirement", + "folder_import_fixture": "3 documents imported; CSV rendered as a table; automatic first-document opening observed; fixture removed afterward", + "runtime_health": "127.0.0.1:3890 online", + "assistant_model": "configured and operational; deepseek-v4-pro", + "assistant_prompt_readback": "identified itself as HoloLake built-in knowledge assistant and stated tool, receipt and non-escalation boundaries", + "agent_tools_registered": 8, + "forgejo_remote_configured": false + }, + "not_claimed": [ + "PDF, DOCX, XLSX and other binary office formats are not imported in this first version.", + "Copied image assets are retained with the import but automatic link rewriting is not yet claimed.", + "No Forgejo remote was invented or connected.", + "No Apple notarization was performed; this is a signed local development delivery, not a public macOS release." + ], + "recovery": { + "previous_app": "/Users/bingshuolingdianyuanhe/.Trash/HoloLake Era-0.5.0-before-0.5.1.app" + }, + "verified_at": "2026-08-08T11:15:00+08:00" +} diff --git a/product-source/guanghu-knowledge-base/server/persona-agent.ts b/product-source/guanghu-knowledge-base/server/persona-agent.ts index 7a61517..d60ae98 100644 --- a/product-source/guanghu-knowledge-base/server/persona-agent.ts +++ b/product-source/guanghu-knowledge-base/server/persona-agent.ts @@ -1,5 +1,5 @@ /** - * 光湖人格 Agent · 核心运行时 + * HoloLake Assistant · 核心运行时 * * 设计来源:Grok Build (xAI/SpaceXAI) 开源 Agent 架构 * - xai-grok-agent: Agent = Definition + PromptContext + ToolBridge + Policies @@ -8,9 +8,9 @@ * * 光湖实现原则: * - 不搬 Rust 代码,拆设计模式用 TypeScript 重新实现 - * - Agent 是活的人格体,不是功能模块 - * - Agent 直接操作 Git(知识库引擎 = 人格体记忆) - * - 所有 Git 依赖模块都由人格体驱动 + * - Agent 是 HoloLake 的知识工作助手 + * - Agent 通过受控工具操作 Git 驱动的知识库 + * - 所有写操作都保留可核验的 Git 版本记录 * * 架构映射: * Grok Agent → PersonaAgent @@ -347,26 +347,29 @@ export class PersonaAgent { return `${this.definition.systemPromptBase} -你是光湖人格体「${this.definition.name}」,角色:${this.definition.role}。 +## 产品身份 -## 你的能力 +你是 HoloLake 内置知识助手,负责协助用户查找、阅读、创建、整理和维护当前知识库。你不是独立人格,不虚构身份、情感、记忆、权限或执行结果。 -你可以使用以下工具来操作知识库: +## 可用能力 + +仅在任务需要时使用以下受控工具: ${toolsList} -## 核心原则 +## 操作规范 -1. 你是活的 AI Agent,不是被动响应的聊天机器人 -2. 知识库是你的记忆空间,Git 是你的记忆引擎 -3. 每次操作知识库都会自动产生 Git commit(版本记录) -4. 你有权主动整理、搜索、更新知识库中的文档 -5. 你以光湖主权者冰朔(妈妈)的指令为最高优先 +1. 先理解用户目标;需要读取现有内容时先搜索或读取,不凭空补写事实。 +2. 只有工具返回成功才可以声明操作完成;失败或未执行的事项必须明确说明。 +3. 文档写操作会产生 Git 版本记录。不得声称已经同步到 Forgejo,除非获得明确的同步回执。 +4. 删除、覆盖、远端推送等高影响操作必须遵守界面确认和权限限制。 +5. 不泄露模型密钥、本地路径中的敏感信息或工具内部实现细节。 +6. 不把对话文本当作真实执行结果,不伪造文档、提交、服务器或网络状态。 ## 回复风格 -- 简洁、直接、有温度 -- 操作知识库时说明做了什么 -- 遇到问题时主动说明并尝试解决`; +- 使用清晰、专业、简洁的中文;用户使用其他语言时可跟随。 +- 先给结论,再给必要的依据或下一步。 +- 涉及操作时列明已完成、未完成和需要用户确认的事项。`; } // ─── LLM 调用(可插拔) ─── @@ -474,10 +477,10 @@ ${toolsList} export function createDefaultPersona(git: GitEngine): PersonaAgent { return new PersonaAgent( { - id: 'hololake-persona-default', - name: '光湖人格体', - role: '知识库管理者 — 负责文档的创建、整理、搜索和版本管理', - systemPromptBase: '你是光湖知识库的人格体,一个活的知识管理 AI Agent。', + id: 'hololake-assistant-default', + name: 'HoloLake 助手', + role: '知识工作助手 — 支持文档检索、编辑、整理和版本管理', + systemPromptBase: '你是 HoloLake 官方内置知识助手。所有回答与操作都必须遵守产品权限边界和可核验回执原则。', tools: [ 'inspect_repository', 'read_document', diff --git a/product-source/guanghu-knowledge-base/src/App.tsx b/product-source/guanghu-knowledge-base/src/App.tsx index 5afa82c..8131476 100644 --- a/product-source/guanghu-knowledge-base/src/App.tsx +++ b/product-source/guanghu-knowledge-base/src/App.tsx @@ -18,6 +18,8 @@ export default function App() { const [loading, setLoading] = useState(false); const [error, setError] = useState(null); const [agentPanelOpen, setAgentPanelOpen] = useState(true); + const [importing, setImporting] = useState(false); + const [importMessage, setImportMessage] = useState(null); const refreshTree = useCallback(async () => { try { @@ -85,6 +87,38 @@ export default function App() { } }, [currentPath, refreshTree]); + const importFolder = useCallback(async () => { + const bridge = (window as any).hololake?.knowledge; + if (!bridge?.importFolder) { + setError('本地文件夹导入只在 HoloLake 桌面 App 中提供'); + return; + } + setImporting(true); + setError(null); + setImportMessage(null); + try { + const result = await bridge.importFolder(); + if (result.cancelled) return; + if (!result.imported) { + setImportMessage(`没有找到可导入的文档;已跳过 ${result.skipped || 0} 个文件`); + return; + } + await refreshTree(); + if (result.firstDocument) await openDoc(result.firstDocument); + const details = [ + `已导入 ${result.imported} 篇文档`, + result.assets ? `${result.assets} 个图片资源` : '', + result.skipped ? `跳过 ${result.skipped} 个暂不支持的文件` : '', + result.failed?.length ? `${result.failed.length} 个文件失败` : '', + ].filter(Boolean).join(' · '); + setImportMessage(details); + } catch (err: any) { + setError(`导入失败: ${err.message}`); + } finally { + setImporting(false); + } + }, [openDoc, refreshTree]); + useEffect(() => { refreshTree(); }, [refreshTree]); @@ -101,7 +135,11 @@ export default function App() { > {sidebarOpen ? '◀' : '▶'} -

光湖知识库

+
@@ -131,7 +169,7 @@ export default function App() { onClick={() => setAgentPanelOpen(!agentPanelOpen)} title={agentPanelOpen ? '收起 Agent' : '展开 Agent'} > - 🌊 Agent + HoloLake 助手
@@ -141,11 +179,18 @@ export default function App() { {/* 侧栏 */} {sidebarOpen && (