feat(persona-agent): 光湖人格 Agent v0.1.0 — Grok Build 架构拆解+Git驱动人格体

核心架构(拆解自 xAI Grok Build 开源 Rust crate):
- PersonaAgent: Agent = Definition + ToolBridge + PromptContext(映射自 xai-grok-agent)
- 7个内置工具: read/create/update/delete/search/list/history(直接操作 Git 引擎)
- LLM 调用层: 可插拔 OpenAI-compatible API(支持 tool calling)
- 离线模式: 无 API Key 时降级为本地响应

API 端点:
- POST /api/agent/chat — Agent 对话(支持工具调用链)
- GET  /api/agent/status — Agent 状态
- GET  /api/agent/conversation — 对话历史
- POST /api/agent/clear — 清空对话

前端:
- AgentChat 组件: 对话气泡+工具调用展示+欢迎建议
- 三栏布局: 文档树 | 编辑器 | Agent 面板(可收起)

设计原则:
- Agent 是活的人格体,不是孤立的功能模块
- Agent 直接操作 Git(知识库引擎 = 人格体记忆空间)
- 所有 Git 依赖模块由人格体驱动
- 不搬 Rust 代码,拆设计模式用 TypeScript 重新实现
This commit is contained in:
冰朔 2026-08-08 07:38:09 +08:00
commit dcf8f7d7e9
5 changed files with 1233 additions and 0 deletions

View file

@ -4,6 +4,7 @@ import { DocTree } from './components/DocTree';
import { Editor } from './components/Editor';
import { SearchBar } from './components/SearchBar';
import { VersionHistory } from './components/VersionHistory';
import AgentChat from './components/AgentChat';
type View = 'editor' | 'history';
@ -15,6 +16,7 @@ export default function App() {
const [sidebarOpen, setSidebarOpen] = useState(true);
const [loading, setLoading] = useState(false);
const [error, setError] = useState<string | null>(null);
const [agentPanelOpen, setAgentPanelOpen] = useState(true);
const refreshTree = useCallback(async () => {
try {
@ -123,6 +125,13 @@ export default function App() {
</button>
</>
)}
<button
className={`kb-btn-tab kb-btn-agent ${agentPanelOpen ? 'active' : ''}`}
onClick={() => setAgentPanelOpen(!agentPanelOpen)}
title={agentPanelOpen ? '收起 Agent' : '展开 Agent'}
>
🌊 Agent
</button>
</div>
</header>
@ -168,6 +177,13 @@ export default function App() {
<VersionHistory docPath={currentPath} />
)}
</main>
{/* Agent 面板 */}
{agentPanelOpen && (
<aside className="kb-agent-panel">
<AgentChat apiBase="" onDocSelect={openDoc} />
</aside>
)}
</div>
</div>
);