Commit Graph

133 Commits

Author SHA1 Message Date
chiguyong 94c4c8b887 feat: accumulated frontend enhancements, docs, and static assets
- Frontend view updates (ChatView, EvolutionView, SkillsView, etc.)
- Updated portal routes and chat store
- New frontend components (FilePreview, ToolCallCard, IconNav)
- Updated static build assets
- New test files (merged router, parallel tools, ReWOO fallback)
- Documentation and brainstorm files
- Codegraph and understand-anything artifacts
2026-06-14 16:35:01 +08:00
chiguyong 6e0e081f23 feat: gap closure sprint — dark theme, @-mention, LocalComputerUse, tests
P0: U4 UsageStore + U5 CascadeStateStore independent test files (57 tests)
P1: Dark theme — tokens.css [data-theme="dark"] + theme.ts Pinia store
    + TopNav toggle button + App.vue dynamic Ant Design theme
P1: @-mention — MentionDropdown.vue + /skills/mention-suggest API
    + ChatInput integration with @ detection
P2: LocalComputerUseSession — pyautogui + screencapture (replaces Docker stub)
P2: Integration tests for gap closure (12 tests)
Fix: create_cascade_state_store() now passes session_ttl to InMemory fallback
2026-06-14 16:16:50 +08:00
chiguyong 0ccef7be5c feat: P0 production hardening — LLM cache, semantic routing, state persistence
U1: LLM Cache Core (exact + semantic match, InMemory + Redis backends)
U2: Cache integration into LLMGateway with CacheConfig
U3: Semantic Router as Layer 1.5 in CostAwareRouter
U4: UsageStore persistence (Redis Hash + InMemory fallback)
U5: CascadeStateStore persistence (Redis INCR + InMemory TTL)
U6: EvolutionStore interface unification (Protocol + PostgreSQL backend)
U7: Configuration integration + E2E tests

Code review fixes:
- P0: date iteration bug (day>=28), semantic router index never built,
      Redis connection leak (per-call → persistent pool)
- P1: cache degradation recovery, semantic_search degradation,
      double miss counting, asyncio.Lock for PG init, LIMIT on queries,
      __import__ anti-pattern → _utcnow()
- P2: InMemory TTL cleanup, embedding preservation on put(),
      data TTL = max(exact_ttl, semantic_ttl)
2026-06-14 15:16:00 +08:00
chiguyong 4707fd00ba Merge feat/tauri-desktop-client: Tauri 2.x desktop client 2026-06-14 10:06:19 +08:00
chiguyong bc43b962c7 feat(client): add Tauri 2.x desktop client with sidecar process management
- Tauri 2.x project scaffold with dual-window (splash + main)
- Rust sidecar management: spawn/kill Python backend, port discovery via stdout
- CancellationToken for graceful task cancellation on exit
- System tray with show/quit, close-to-tray behavior
- Frontend: dynamic baseURL, SplashScreen, TitleBar, Tauri IPC adapter
- PyInstaller build scripts for cross-platform sidecar packaging
- GitHub Actions CI for Win/Mac/Linux release builds
- CSP security policy, proper capabilities configuration
2026-06-14 10:06:12 +08:00
chiguyong 321c2333d6 fix(monitor): 对话完成后自动记录经验到监控面板
- portal.py: 对话完成后调用 _record_experience 记录经验到 dashboard
- portal.py: 修复 routing_result.skill → routing_result.skill_name 属性名
- 经验记录触发 experience_added 和 metrics_updated 事件广播
- metrics API 从 _experiences 内存列表计算 total_tasks/success_rate/avg_duration
2026-06-13 11:50:57 +08:00
chiguyong 6945b78c55 fix(server): 自动发现 CWD 下的 agentkit.yaml 和 .env
之前 create_app 只在 AGENTKIT_CONFIG_PATH 环境变量设置时才加载配置和 .env,
导致 uvicorn 直接启动时 LLM provider 未注册(No provider registered)。
现在当 AGENTKIT_CONFIG_PATH 未设置时,自动查找 CWD 下的 agentkit.yaml,
并加载同目录的 .env 文件注入环境变量。
2026-06-13 11:40:26 +08:00
chiguyong 905c1f6b18 fix(gui): 修复对话无skill时无法聊天、空对话列表、输入框清空、监控数据
- portal.py: 移除 all_skills 空检查,无 skill 时 fallback 到直接 LLM 对话
- portal.py: general 路径 agent 为 None 时也 fallback 到直接对话
- ChatView.vue: onMounted 自动创建默认对话
- ChatInput.vue: nextTick 清空输入框
- evolution_dashboard.py: usage API 从 LLMGateway.UsageTracker 读取真实数据
- DashboardOverview.vue: 活跃 agent 从 capabilities API 获取
2026-06-13 11:32:45 +08:00
chiguyong d02a6d5200 fix(gui): 修复空对话列表、默认对话、输入框清空、监控数据
- portal.py: 延迟创建对话到第一条消息,避免空对话出现在历史列表
- portal.py: 添加用户消息到 ConversationStore 以支持历史注入
- ChatView.vue: onMounted 自动创建默认对话,无需手动点击新建
- ChatInput.vue: 输入框清空改用 nextTick 确保 Ant Design Vue v-model 同步
- evolution_dashboard.py: usage API 从 LLMGateway.UsageTracker 读取真实 token 数据
- DashboardOverview.vue: 活跃 agent 数从 capabilities API 获取
2026-06-13 11:11:00 +08:00
chiguyong 4c53dbaaeb fix(gui): 修复对话上下文注入、输入框清空、对齐及工作流空状态居中
- portal.py: greeting/general 路径注入最近 20 条历史消息,解决对话记忆不连贯
- ChatInput.vue: 移除 disabled 提前 return,确保提交后清空输入框
- ChatInput.vue: textarea 设置 min-height: 40px,与按钮对齐
- WorkflowView.vue: 空状态 a-empty 垂直水平居中
- chat.ts: sendWsMessage 先检查 WS 状态避免重复消息
- types.ts: WsServerMessage 类型匹配后端嵌套 data 结构
- vite.config.ts: 代理添加 ws: true 支持 WebSocket
- portal.py/terminal.py: WebSocket accept 顺序修复
2026-06-13 10:48:06 +08:00
chiguyong b89da90fd9 Merge branch 'refactor/gui-redesign': Agent-First GUI redesign with Design Token system
- U1: Design Token system (tokens.css + theme.ts)
- U2: Four-quadrant Agent-First layout with TopNav
- U3: Chat panel refactor (markdown-it + ToolCallIndicator)
- U4: Code/preview panel (CodeDiffViewer + FileTree)
- U5: Terminal panel refactor (One Dark Pro + Ant Design Modal)
- U6: Evolution panel simplification + grouped settings
- U7: Transitions + responsive breakpoints
- Color migration: 15+ components migrated to Design Tokens
- Code review fixes: ARIA a11y, XSS protection, touch/keyboard support,
  path traversal protection, lazy-loading, ANSI span balance
2026-06-13 10:08:37 +08:00
chiguyong af50cc7fe1 fix(api): support absolute paths in BaseApiClient.request()
When path starts with /api/, treat it as an absolute URL instead of
prepending baseUrl. This fixes installSkill/uninstallSkill URL
concatenation that produced /api/v1/skill-management/api/v1/skills/...
2026-06-13 10:03:56 +08:00
chiguyong 5b63214bc1 fix(gui): address all P1 code review findings
- AgentLayout: lazy-load views via defineAsyncComponent, wire route meta to quadrant tab switching
- QuadrantPanel: ARIA tablist/tab/tabpanel roles, keyboard nav, v-if via computed, expose setActiveTab
- SplitPane: touch support, keyboard resize, ARIA separator role
- ChatMessage: DOMPurify sanitization, anchor toolCalls regex to line start
- TerminalEmulator: fix ANSI span imbalance with depth tracking
- theme.ts: read CSS custom properties at runtime via readToken()
- responsive.css: fix bottom-right auto-collapse selector
- app.py: path traversal protection, exclude docs/openapi.json
- skills.ts: use BaseApiClient.request() for installSkill/uninstallSkill
2026-06-13 10:01:26 +08:00
chiguyong f4e454b727 fix(review): address code review findings
- QuadrantPanel: persist activeTab and collapsed state to localStorage via watch
- TopNav: remove v-if="false" dead code for TaskSelector, remove unused ASelect import
- SplitPane: add null guard before containerRef.value access in onMouseDown
- Router: fix /agent/code route loading ChatView instead of WorkflowView
- Router: add default redirect for /legacy to /legacy/chat
2026-06-13 09:50:56 +08:00
chiguyong 14f548b56a docs: mark GUI redesign plan as completed
All 7 implementation units (U1-U7) plus color migration audit are done.
2026-06-13 03:01:31 +08:00
chiguyong c60e0b9971 refactor(gui): migrate hardcoded colors to Design Tokens across all components
- Migrate 15+ component files from Ant Design default colors to Design Token system
- Workflow nodes (Skill/Parallel/Condition/Approval): #1890ff→var(--color-primary), #52c41a→var(--color-success), etc.
- Evolution panels (Dashboard/Metrics/Usage/Timeline/Pitfall/PathOptimizer): all CSS colors→var() tokens
- Skills components (SkillCard/SkillDetail): link/text colors→Design Tokens
- KB component (SearchTest): bg/border/text colors→Design Tokens
- JS/inline styles use new palette hex values (#7c3aed primary, #10b981 success, #f59e0b warning)
- Provider brand colors (OpenAI/Anthropic/Azure/DeepSeek/Zhipu) preserved as-is
- Remaining ~27 hex values are in JS/template contexts where CSS vars cannot be used
2026-06-13 03:01:13 +08:00
chiguyong 4d051c2f25 feat(gui): add transitions, responsive breakpoints and bug fixes (U7)
- Add transitions.css with fade, slide, collapse, scale, stagger-list, skeleton-pulse, pulse-dot animations
- Add responsive.css with breakpoints (≥1440px full, 1280-1439px compact, <1280px prompt)
- Add small-screen prompt in AgentLayout with DesktopOutlined icon
- Fix SPA serving in app.py for Vue build output
- Fix TypeScript errors in kb.ts, skills.ts, workflow.ts, FlowCanvas.vue, SideNav.vue
- Fix unused imports in ExperienceTimeline, PathOptimizerPanel, PitfallPanel
2026-06-13 02:47:51 +08:00
chiguyong db216a5cc4 feat(gui): streamline evolution panel and group settings (U6)
- EvolutionView: simplify from 6 sub-panels to 3 tabs (概览+指标, 经验+坑点, 用量)
- SettingsView: group into 4 tabs (LLM, 技能, 知识库, 系统), each with independent save
- SkillsView: replace hardcoded colors with Design Tokens
- All three views: replace hardcoded colors with Design Token references
2026-06-13 02:43:41 +08:00
chiguyong 3dc5c68135 feat(gui): refactor terminal panel with One Dark Pro theme and Ant Design Modal (U5)
- TerminalView: replace native HTML confirmation with Ant Design Modal,
  make command history sidebar collapsible (default collapsed)
- TerminalEmulator: use One Dark Pro CSS variables for ANSI colors,
  replace all hardcoded colors with Design Tokens
- CommandHistory: replace all hardcoded colors with Design Tokens
2026-06-13 02:41:46 +08:00
chiguyong 79a400afe8 feat(gui): add code/preview panel with diff viewer and file tree (U4)
- Create CodeDiffViewer.vue with line-level diff highlighting
- Create FileTree.vue with status badges (added/modified/deleted)
- Update WorkflowView.vue: replace hardcoded colors with Design Tokens
- Update KnowledgeBaseView.vue: replace hardcoded colors with Design Tokens
2026-06-13 02:40:14 +08:00
chiguyong 6d5a08cb0c feat(gui): refactor chat panel with Markdown rendering and tool indicators (U3)
- ChatMessage: replace v-html with markdown-it, add ToolCallIndicator
- ChatInput: add ContextPill support for file/skill context
- ChatSidebar: make collapsible (default collapsed)
- Create ToolCallIndicator.vue with color-coded tool type badges
- Create ContextPill.vue for context references
- Replace all hardcoded colors with Design Token references
- Install markdown-it for Markdown rendering
2026-06-13 02:38:37 +08:00
chiguyong 9273612a5b feat(gui): add four-quadrant Agent-First layout with top navigation (U2)
- Create AgentLayout.vue with CSS Grid four-quadrant layout
- Create SplitPane.vue with draggable divider and localStorage persistence
- Create TopNav.vue with logo, status indicator, and settings entry
- Create QuadrantPanel.vue with tab switching and collapse support
- Restructure router: /agent as main route, legacy routes redirect
- App.vue now uses router-view for layout switching
2026-06-13 02:35:28 +08:00
chiguyong 2988d3768e feat(gui): add Design Token system and theme configuration (U1)
- Create tokens.css with CSS custom properties for colors, spacing,
  radius, fonts, shadows, transitions, and code theme
- Create theme.ts mapping tokens to Ant Design Vue ConfigProvider
- Create styles/index.ts as unified entry point
- Inject theme into App.vue ConfigProvider
- Import styles in main.ts

Primary color unified to #7c3aed (purple gradient brand color).
2026-06-13 02:32:29 +08:00
chiguyong 09698d7a06 feat: frontend productization with code review fixes
- Workflow: visual canvas, undo/redo, drag-and-drop, real-time execution WebSocket
- Evolution: dashboard, ECharts metrics, experience timeline, pitfall warnings, usage panel
- KB: source CRUD, document upload, search test
- Terminal: interactive PTY WebSocket, whitelist security
- Security: hmac.compare_digest, API key auth on all endpoints, whitelist bypass fix
- Fixes: ECharts async init, WebSocket intentional disconnect, TOCTOU race, Pydantic models
2026-06-13 01:29:58 +08:00
chiguyong 3c6c41c140 merge: feat/chat-response-speed-optimization into main 2026-06-12 22:18:40 +08:00
chiguyong 5ef08a3b30 fix(review): comprehensive P0-P2 code review fixes 2026-06-12 22:18:25 +08:00
chiguyong 2e55aae775 fix(review): address code review findings for speed optimization
- P0: Rename WAL buffer to pending buffer, add crash-loss warning
- P1: Fix keyword substring false matches with word-boundary regex
- P1: Pass connection pool params in _build_llm_config
- P1: Change parallel_tools default to False (safer default)
- P1: Add classifier value validation in CostAwareRouter
- P2: Replace __import__ with proper datetime import
- P2: Add max_buffer_size enforcement in AsyncWriteQueue
2026-06-12 13:21:44 +08:00
chiguyong a36bc3d1c1 feat: optimize chat response speed for sub-1s first token latency
- Add HeuristicClassifier to replace LLM quick_classify with zero-cost
  local heuristic (keyword/length/code-pattern scoring), gated by
  router.classifier config (default: heuristic)
- Add parallel tool execution in ReActEngine via asyncio.gather for
  multiple independent tool_calls, gated by parallel_tools param
- Add AsyncWriteQueue for non-blocking session persistence with WAL
  buffer, gated by async_writes param on SessionManager
- Add httpx.Limits connection pool config to all LLM providers
- Add router config section to ServerConfig and agentkit.yaml
- All optimizations have config switches for safe rollback
2026-06-12 13:15:06 +08:00
chiguyong d3b792a9ec merge: feat/pipeline-adversarial-loop into main
Pipeline-level adversarial loop (Worker ↔ Verifier) implementation:
- Schema: ReviewIssue, ReviewFeedback, AdversarialState models
- Engine: adversarial execution, feedback injection, escalation
- Config: code_reviewer skill + coding_harness pipeline
- Tests: 19 unit + 5 integration, all passing
- Code review fixes: 2 Critical + 5 Major issues resolved
2026-06-12 10:02:47 +08:00
chiguyong 8c365486e2 fix(pipeline): address code review findings for adversarial loop
Critical:
- C1: Add verifier_timeout_seconds for independent Verifier timeout
- C2: Verifier parse failure raises RuntimeError instead of dead-loop

Major:
- M1: Inject previous_output into Worker retry context
- M2: Add Pydantic ge/le constraint on ReviewFeedback.score
- M3: Use Literal type for feedback_mode enum validation
- M4: Use Literal types for ReviewIssue severity and category
- M5: Merge error messages when escalation agent also fails

Tests: 8 new test cases added (19 total), all passing
2026-06-12 10:02:37 +08:00
chiguyong ddc735b078 test(pipeline): add coding harness integration tests
5 passing tests covering:
- Pipeline config loading and validation
- Review stage adversarial config verification
- Stage dependencies validation
- Code reviewer skill config and output schema

3 skipped tests (complex mock sequencing covered by unit tests)
2026-06-12 09:42:21 +08:00
chiguyong 3392413614 test(pipeline): add adversarial loop unit tests
11 test cases covering:
- PipelineSchemaAdversarial (4): verifier fields, backward compat, serialization, state tracking
- AdversarialExecution (3): no verifier passthrough, first round pass, max rounds exhausted
- FeedbackContext (3): structured+natural, structured, natural modes
- Escalation (1): no escalation configured
2026-06-12 09:40:19 +08:00
chiguyong 6731d96c65 feat(configs): add code_reviewer skill and coding_harness pipeline
- code_reviewer.yaml: Verifier Agent skill config for adversarial review
  with structured output schema for ReviewFeedback format
- coding_harness.yaml: Example pipeline with adversarial loop
  develop → test → review (Worker↔Verifier) → archive
2026-06-12 09:38:37 +08:00
chiguyong dc07c7c60a feat(pipeline): implement adversarial loop execution logic
Add Worker-Verifier adversarial loop to PipelineEngine:
- _execute_stage_with_adversarial: main loop for Worker→Verifier→retry
- _execute_agent_stage: extracted agent execution logic
- _execute_verifier: execute verifier and parse ReviewFeedback
- _build_feedback_context: build feedback context for worker retry
- _escalate: handle round exhaustion (escalate or fail)
- Route to adversarial mode when stage.verifier is configured

Support three feedback modes: structured+natural, structured, natural
2026-06-12 09:37:30 +08:00
chiguyong b733b3a732 feat(pipeline): add adversarial loop schema models
Add ReviewIssue, ReviewFeedback, AdversarialState models and extend
PipelineStage with verifier, max_adversarial_rounds, feedback_mode,
and escalate_on_exhaust fields for Worker-Verifier adversarial loop.
2026-06-12 09:35:01 +08:00
chiguyong 2110c84fb6 fix: switch default model to qwen3-coder-plus for better function calling
DeepSeek-chat has limited/partial function calling support. Qwen3-coder-plus
(DashScope) has robust OpenAI-compatible function calling.

Also added tool usage instructions to system prompt and enhanced logging
to trace tool propagation through the pipeline.
2026-06-12 09:27:52 +08:00
chiguyong 44f19fcf14 feat: loading animation + tool descriptions in system prompt
1. Loading indicator: three-dot bouncing animation appears after
   sending a message and disappears when server starts responding.

2. Tool descriptions: resolve_skill_routing now appends available
   tools (name + description + parameters) to the system prompt so
   the LLM knows what tools it can call.
2026-06-11 22:25:21 +08:00
chiguyong 55421dd126 fix: get_tools() and get_system_prompt() now read from tool_registry too
Root cause: app.py registers tools via agent._tool_registry.register()
which adds to the ToolRegistry but NOT to agent._tools (which is only
populated by use_tool() from config). Both get_tools() and
get_system_prompt() were reading only _tools, missing all post-init
registered tools. Now both methods merge _tools with
_tool_registry.list_tools().
2026-06-11 22:17:14 +08:00
chiguyong f7225bc91a fix: include available tools in system prompt so LLM knows what it can call
Previously get_system_prompt() only returned identity/instructions but
did not tell the LLM what tools are available. The LLM would therefore
refuse to call tools even when they were registered, saying it had no
tools. Now the system prompt includes a '## 可用工具' section listing
all registered tools with their descriptions and parameters.
2026-06-11 22:00:30 +08:00
chiguyong b6ec13cbca debug: log tools count and names in portal before execute_stream 2026-06-11 21:44:20 +08:00
chiguyong 32c800d1e4 fix: portal routing + response speed + IME input
1. Portal unified routing: ws_chat now uses CostAwareRouter uniformly
   (handles Layer 0/1/2), replacing direct IntentRouter calls.
   Greeting/chat_mode requests skip IntentRouter LLM call entirely.

2. Response speed: greeting & simple chat now use direct LLM call
   (no ReAct loop), zero-cost Layer 0 detection.

3. IME input fix: use e.isComposing (native browser property)
   instead of compositionstart/end for Enter key detection.

4. Test: fix InMemoryMessageBus.request() parameter name
   timeout -> timeout_seconds.
2026-06-11 21:30:25 +08:00
chiguyong ae95b56465 fix: use e.isComposing for IME detection instead of manual flag
e.isComposing is a standard KeyboardEvent property that's true during
IME composition. More reliable than compositionstart/compositionend
which can fire at unpredictable timing relative to keydown.
2026-06-11 20:43:38 +08:00
chiguyong 66d0901938 fix: prevent Enter from submitting during IME composition
Added compositionstart/compositionend event listeners to track IME
composing state. Enter key now only submits when not composing,
so Chinese/Japanese/Korean input methods work correctly.
2026-06-11 15:37:06 +08:00
chiguyong cc4c6fe346 fix: direct-mode agent falls through to default when task needs tools
When IntentRouter matches a direct-mode agent (no tools), but the task
content suggests tool needs (shell, search, file ops, etc.), the routing
now falls through to the default agent which has full tool access.

This fixes the issue where "帮我执行个命令" would be routed to
direct_agent and fail because direct mode doesn't support tool calling.

Also restored "你好" in direct_agent keywords since it's correctly
handled now — greetings don't need tools, direct mode is fine.
2026-06-11 15:26:19 +08:00
chiguyong 52b7d6007d fix: remove '你好' from direct_agent keywords so greetings route to default agent with tools 2026-06-11 14:49:59 +08:00
chiguyong 93bc7c4e3e fix: change all agent YAML model from hardcoded provider to 'default'
Hardcoded model names like 'openai/gpt-4o-mini' or 'anthropic/claude-sonnet'
cause 'No provider available' errors when the specific provider isn't configured.
Using 'default' lets the system pick the available provider automatically.
2026-06-11 14:19:26 +08:00
chiguyong d47f279887 fix: resolve code review issues from deferred improvements
1. InMemoryMessageBus.request(): fix param name (timeout→timeout_seconds) to match ABC
2. InMemoryMessageBus: track consumer tasks, cancel on unsubscribe
3. InMemoryMessageBus: _try_resolve_pending() in queue consumer path
4. evolve_soul(): use "default" category when patterns is empty
5. quick_classify(): use delimiter-based prompt to mitigate injection risk
6. Use asyncio.get_running_loop() instead of deprecated get_event_loop()
2026-06-11 13:49:02 +08:00
chiguyong ec51dbb259 feat: optimize劣势项 — 拍卖开关/审计采样/线程安全/评分锚定
1. 拍卖机制: 已有配置开关(marketplace.auction_enabled), 默认关闭
2. LLM审计采样: 新增 audit_sample_rate (0.0-1.0), 默认1.0, 可降低审计频率
3. AlignmentConfig.from_dict: 忽略未知键, 防止YAML额外字段崩溃
4. 配置热重载线程安全: 用 threading.Event 替代布尔标志, 消除数据竞态
5. Reflexion评分锚定: 添加评分维度(Completeness/Correctness/Clarity)和锚定点
2026-06-11 13:04:36 +08:00
chiguyong cc2cd414c9 fix: resolve all code review issues from cross-validation
1. Critical: Add missing TaskResult import in plan_exec_engine.py
2. Critical: Fix ReWOOEngine param name (max_steps → max_plan_steps)
3. Major: Remove duplicate token counting in reflexion.py
4. Major: LLM audit failure now passes (trusts rule check) instead of failing
5. Major: Fix dict iteration with del using list() copy in lifecycle.py
6. Major: Fix Chinese content tokenization using regex split instead of space split
7. Minor: _is_positive_mention now checks all occurrences, not just the first
2026-06-11 06:22:35 +08:00
chiguyong 79eb8469f9 fix: address remaining code review issues
- AlignmentGuard: direction-aware constraint checking (negation/affirmation detection)
  instead of simple substring matching to reduce false positives
- Reflexion: extract actual token usage from LLM response instead of hardcoded 1
- MemoryTool: protect version/history sections from update_soul modification
- Fix AsyncMock warnings for sync find_best_agent method
2026-06-11 00:14:11 +08:00