$ show zhimaAi/ChatClaw
ChatClaw is a desktop AI assistant application built with Wails v3 (Go backend + Vue 3 frontend) that provides a local-first, multi-platform AI agent experience. It integrates with multiple messaging platforms (WeChat, QQ, DingTalk, Feishu, WeCom, WhatsApp) through gateway adapters and manages AI agents using the CloudWeGo Eino framework. The application features a knowledge base with full-text search (FTS5) and vector embeddings (sqlite-vec), document processing pipeline (parsing, splitting, RAPTOR hierarchical summarization), scheduled tasks with cron execution, a skill marketplace, MCP tool support, and native desktop capabilities like window snapping, floating ball, and text selection popups. It also bundles an OpenClaw Node.js runtime for advanced agent workflows. The frontend is Vue 3 with TypeScript, Pinia, and shadcn-vue UI components. The architecture is a monolith with service-oriented backend and multiple WebView windows. Note: The repo shows signs of hybridity as it includes substantial data/research components (RAPTOR, embeddings, document processing) but these serve the application's core functionality.
The LLM identified 6 files worth highlighting for reuse:
Implements a per-library concurrency limiter with a wait queue that wakes up when a slot frees or the limit changes. The `libLearnGate` struct provides an `acquireSlot` method that blocks until a token is available, and a `wakeUpWaiters` mechanism on limit increase. This is a clean, reusable pattern for throttling concurrent operations (e.g., document processing) with dynamic capacity adjustment. It has unit tests demonstrating behavior.
A generic batch wrapper for embedding providers that respect per-request batch limits. The `batchEmbedder` struct splits input texts into chunks of a configurable batch size, sequentially embeds each chunk, and concatenates results. This solves a common problem when using embedding APIs with strict batch size constraints (e.g., Qwen limit 10). The component is self-contained and can be reused with any embedding service.
Defines an `I18nError` structure that carries an i18n key, optional message, underlying cause, and implements the `error` interface. It provides a `SelectDesc` helper for bilingual (ZH/EN) tool descriptions. This pattern enables consistent, localized error reporting across the application and can be extracted to any Go project needing structured, translatable errors.
Implements a tool registry with lazy caching and per-session exclusion. Tools are registered as factories, created on first access, and cached. The `GetTools` method filters tools based on session-specific exclusions (e.g., browser tool disabled in certain contexts). This pattern allows dynamic tool selection and efficient singleton creation, reusable wherever a plugin-like tool system is needed.
Provides a cross-platform window snapping abstraction that allows attaching an application window to a target process window (e.g., dock to the right of a chat app). It uses platform-specific implementations via build tags (Windows win32 API, macOS Accessibility API) with a common interface for wake, input simulation, and z-order management. The package is isolated in `pkg/` and can be extracted as a reusable library for desktop window management.
Implements the RAPTOR (Recursive Abstractive Processing for Tree-Organized Retrieval) algorithm for hierarchical document summarization. It performs KMeans++ clustering on document chunk embeddings, then uses an LLM to summarize each cluster recursively, building a multi-level tree. This is a sophisticated retrieval-augmented preprocessing pipeline that can be extracted as a standalone library for any document collection, given an embedding provider and an LLM summarizer interface.