AGENTS.md · freestylefly/wesight
AGENTS.md from freestylefly/wesight: 471 lines covering Build and Development Commands, Architecture Overview, Coding Style & Naming Conventions, String…
Template by freestylefly
Install
Works with Codex, Cursor, GitHub Copilot, Gemini CLI, OpenCode, Claude Code. Read the repository before you give any tool access to your data.
curl -fsSL https://raw.githubusercontent.com/freestylefly/wesight/main/AGENTS.md -o AGENTS.md
Read it and adapt it to your project before use.
Get the weekly diff
The weekly diff: one email a week with new agent tools, notable updates and grade changes, plus security alerts for tools you follow. Double opt-in, one-click unsubscribe.
About
Use cases: prompt-engineering
Reviews
Write a reviewNo reviews yet. Installed it? Reviews come from verified installers only. How reviews work
What's in it
An AGENTS.md file: instructions coding agents (Codex, Cursor, Copilot, Gemini CLI and others) read before working in a repo.
- For
- Codex, Cursor, GitHub Copilot, Gemini CLI, OpenCode, Claude Code
- Length
- 471 lines
- File
AGENTS.md
Sections
- Build and Development Commands
- Architecture Overview
- Coding Style & Naming Conventions
- String Literal Constants
- Logging Guidelines
- Testing Guidelines
- Internationalization (i18n)
- Commit & Pull Request Guidelines
- System Prompt
- Command Execution & User Interaction Policy
- Memory Policy
- Scheduled Tasks
First lines (shown under the repo's MIT license)
# CLAUDE.md
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
## Build and Development Commands
```bash
# Development - starts Vite dev server (port 5175) + Electron app with hot reload
npm run electron:dev
# Development with OpenClaw engine (clones/builds OpenClaw on first run)
npm run electron:dev:openclaw
# Build production bundle (TypeScript + Vite)
npm run build
# Lint with ESLint
npm run lint
# Run memory extractor tests (Node.js built-in test runner)
npm run test:memory
# Compile Electron main process only
npm run compile:electron
# Package for distribution (platform-specific)
npm run dist:mac # macOS (.dmg)
npm run dist:win # Windows (.exe)
npm run dist:linux # Linux (.AppImage)
# Build OpenClaw runtime manually
npm run openclaw:runtime:host # current platform
```
**Requirements**: Node.js >=24 <25. Windows builds require PortableGit (see README.md for setup).
**OpenClaw env vars**: `OPENCLAW_SRC` (default `../openclaw`), `OPENCLAW_FORCE_BUILD=1` (force rebuild), `OPENCLAW_SKIP_ENSURE=1` (skip version checkout).
## Architecture Overview
WeSight is an Electron + React desktop application with two primary modes:
1. **Cowork Mode** - AI-assisted coding sessions using Claude Agent SDK with tool execution
2. **Artifacts System** - Rich preview of code outputs (HTML, SVG, React, Mermaid)
Uses strict process isolation with IPC communication.
### Authentication Flow
1. **登录:** 打开系统浏览器 → Portal 登录页 → URS 登录成功 → deep link `wesight://auth/callback?code=<authCode>`
2. **换取令牌:** `POST /api/auth/exchange` 消费一次性 authCode → 返回 `accessToken`(2h) + `refreshToken`(30d)
3. **持久化:** SQLite kv store `auth_tokens` 存储双 token,应用重启后自动恢复登录态
4. **请求认证:** `fetchWithAuth()` 在每个 API 请求附加 `Authorization: Bearer <accessToken>`
5. **被动刷新:** 收到 HTTP 401 → 使用 refreshToken 调用 `POST /api/auth/refresh` → 获取新 accessToken → 重试原请求
6. **主动刷新:** 定期检查 accessToken 距 exp < 5 分钟 → 后台静默刷新,避免请求失败
7. **滚动续期:** 每次 refresh 签发新 refreshToken(新 30 天有效期),连续使用不掉线
8. **退出条件:** 连续 30 天不使用(refreshToken 过期)→ 清除本地 token → 用户需重新登录
**关键文件:**
- Token 存储与请求:`src/renderer/services/api.ts`(`fetchWithAuth()`、token 管理)
- 登录流程:`src/main/main.ts`(deep link 处理 `wesight://` 协议)
- 持久化:`src/main/sqliteStore.ts`(kv 表存储 `auth_tokens`)
### Process Model
**Main Process** (`src/main/main.ts`):
- Window lifecycle management
- SQLite storage via `sql.js` (`src/main/sqliteStore.ts`)
- Agent engine routing (`src/main/libs/agentEngine/coworkEngineRouter.ts`) - dispatches to `claudeRuntimeAdapter.ts` (built-in) or `openclawRuntimeAdapter.ts` (OpenClaw)
- IM gateways (`src/main/im/`) - DingTalk, Feishu, Telegram, Discord, NetEase IM
- Skill management (`src/main/skillManager.ts`)
- IPC handlers for store, cowork, and API operations (40+ channels)
- Security: context isolation enabled, node integration disabled, sandbox enabled
**Preload Script** (`src/main/preload.ts`):
- Exposes `window.electron` API via `contextBridge`
- Includes `cowork` namespace for session management and streaming events
**Renderer Process** (React in `src/renderer/`):
- All UI and business logic
- Communicates with main process exclusively through IPC
### Key Directories
```
src/main/
├── main.ts # Entry point, IPC handlers
├── sqliteStore.ts # SQLite database (kv + cowork tables)
├── coworkStore.ts # Cowork session/message CRUD operations
├── skillManager.ts # Skill loading and management
├── im/ # IM gateway integrations (DingTalk/Feishu/Telegram/Discord)
└── libs/
├── agentEngine/
│ ├── coworkEngineRouter.ts # Routes to built-in or OpenClaw runtime
│ ├── claudeRuntimeAdapter.ts # Built-in Claude Agent SDK adapter
│ └── openclawRuntimeAdapter.ts # OpenClaw gateway adapter
├── coworkRunner.ts # Claude Agent SDK execution engine
├── claudeSdk.ts # SDK loader utilities
├── openclawEngineManager.ts # OpenClaw runtime lifecycle (install/start/status)
├── openclawConfigSync.ts # Syncs cowork config → OpenClaw config files
├── coworkMemoryExtractor.ts # Extracts memory changes from conversations
└── coworkMemoryJudge.ts # Validates memory candidates with scoring/LLM
src/renderer/
├── types/cowork.ts # Cowork type definitions
├── store/slices/
│ ├── coworkSlice.ts # Cowork sessions and streaming state
│ └── artifactSlice.ts # Artifacts state
├── services/
│ ├── cowork.ts # Cowork service (IPC wrapper, Redux integration)
│ ├── api.ts # LLM API with SSE streaming
│ └── artifactParser.ts # Artifact detection and parsing
├── components/
│ ├── cowork/ # Cowork UI components
│ │ ├── CoworkView.tsx # Main cowork interface
│ │ ├── CoworkSessionList.tsx # Session sidebar
│ │ ├── CoworkSessionDetail.tsx # Message display
│ │ └── CoworkPermissionModal.tsx # Tool permission UI
│ └── artifacts/ # Artifact renderers
SKILLs/ # Custom skill definitions for cowork sessions
├── skills.config.json # Skill enable/order configuration
├── docx/ # Word document generation skill
├── xlsx/ # Excel skill
├── pptx/ # PowerPoint skill
└── ...
```
### Data Flow
1. **Initialization**: `src/renderer/App.tsx` → `coworkService.init()` → loads config/sessions via IPC → sets up stream listeners
2. **Cowork Session**: User sends prompt → `coworkService.startSession()` → IPC to main → `CoworkRunner.startSession()` → Claude Agent SDK execution → streaming events back to renderer via IPC → Redux updates
3. **Tool Permissions**: Claude requests tool use → `CoworkRunner` emits `permissionRequest` → UI shows `CoworkPermissionModal` → user approves/denies → result sent back to SDK
4. **Persistence**: Cowork sessions stored in SQLite (`cowork_sessions`, `cowork_messages` tables)
### Cowork System
The Cowork feature provides AI-assisted coding sessions:
**Execution Modes** (`CoworkExecutionMode`):
- `auto` - Automatically choose based on context (OpenClaw: `sandbox.mode=non-main`)
- `local` - Run tools directly on the local machine (OpenClaw: `sandbox.mode=off`)
- `sandbox` - Full sandbox isolation (OpenClaw: `sandbox.mode=all`)
**Agent Engines** (configured via `agentEngine` in cowork config):
- `yd_cowork` - Built-in Claude Agent SDK runner (`claudeRuntimeAdapter.ts`)
- `openclaw` - OpenClaw gateway (`openclawRuntimeAdapter.ts`); requires the bundled OpenClaw runtime to be running. Engine lifecycle managed by `OpenClawEngineManager` with states: `not_installed → ready → starting → running | error`
Both engines expose identical stream events through `CoworkEngineRouter`, so the renderer is engine-agnostic. Engine-specific IPC: `openclaw:engine:*` channels manage runtime lifecycle separately from `cowork:*` session channels.
**Memory System**: Automatically extracts and manages user memories from conversations:
- `coworkMemoryExtractor.ts` - Detects explicit remember/forget commands (Chinese/English) and implicitly extracts personal facts using signal patterns (profile, preferences, ownership). Uses guard levels (`strict`/`standard`/`relaxed`) with confidence thresholds.
- `coworkMemoryJudge.ts` - Validates memory candidates with rule-based scoring and optional LLM secondary judgment for borderline cases. Includes TTL-based caching for LLM results.
**Stream Events** (IPC from main to renderer):
- `message` - New message added to session
- `messageUpdate` - Streaming content update for existing message
- `permissionRequest` - Tool needs user approval
- `complete` - Session execution finished
- `error` - Session encountered an errorSignals
- Stars
- 957
- Forks
- 209
- Open issues
- 3
- Last commit (this folder)
- Jun 14, 2026 (4 months ago)
- Last release
- Sep 19, 2026 (1 month ago)
From GitHub (fetched Oct 24, 2026).
Details
- License
- MIT
- Repository
- github.com/freestylefly/wesight
- First seen
- Oct 24, 2026
- Last checked
- Oct 24, 2026
- Source
- GitHubgithub-graphql
More from freestylefly
Cite this page
AGENTS.md · freestylefly/wesight. Agent Mart. https://agentmart.dev/templates/freestylefly-wesight-agents-md (last updated 2026-10-24)