You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: CLAUDE.md
+21-16Lines changed: 21 additions & 16 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,42 +6,48 @@ This file provides guidance to Claude Code (claude.ai/code) when working with co
6
6
7
7
```bash
8
8
dotnet build
9
-
dotnet run --project sharpclaw # TUI mode (Terminal.Gui)
10
-
dotnet run --project sharpclaw config # Re-run config dialog
11
-
dotnet run --project sharpclaw serve # Web mode (WebSocket server, default port 5000)
12
-
dotnet run --project sharpclaw serve --port 8080
9
+
dotnet run --project sharpclaw tui # TUI mode (Terminal.Gui)
10
+
dotnet run --project sharpclaw config # Re-run config dialog
11
+
dotnet run --project sharpclaw web # Web mode (WebSocket server)
12
+
dotnet run --project sharpclaw web --address 0.0.0.0 --port 8080
13
+
dotnet run --project sharpclaw qqbot # QQ Bot mode
13
14
```
14
15
15
-
First run auto-launches the config dialog (Terminal.Gui `ConfigDialog`) which writes `~/.sharpclaw/config.json`. Web mode requires config to exist already.
16
+
First run of `tui`auto-launches the config dialog (Terminal.Gui `ConfigDialog`) which writes `~/.sharpclaw/config.json`. Web and QQ Bot modes require config to exist already. Running with no command (or `help`) prints usage info.
16
17
17
18
No test project exists. Target framework is .NET 10 (`net10.0`).
18
19
19
20
## Configuration
20
21
21
-
All settings live in `~/.sharpclaw/config.json`. Supports three providers: Anthropic, OpenAI, Gemini. Each sub-agent (main, recaller, saver, summarizer) can override the default provider/endpoint/model or inherit from `default`.
22
+
All settings live in `~/.sharpclaw/config.json`. Supports three providers: Anthropic, OpenAI, Gemini. Each sub-agent (main, recaller, saver, summarizer) can override the default provider/endpoint/model or inherit from `default`. A `channels` section configures per-frontend settings (TUI, Web listen address/port, QQ Bot credentials).
22
23
23
-
API keys are encrypted at rest with AES-256-CBC (`DataProtector`). The encryption key is stored in the OS credential manager via `KeyStore` (Windows Credential Manager / macOS Keychain / Linux libsecret).
24
+
API keys are encrypted at rest with AES-256-CBC (`DataProtector`). The encryption key is stored in the OS credential manager via `KeyStore` (Windows Credential Manager / macOS Keychain / Linux libsecret). Config has auto-migration (current version 8, see `ConfigMigrator`).
24
25
25
26
See `Core/SharpclawConfig.cs` for the schema and `Core/ClientFactory.cs` for client instantiation.
26
27
27
28
## Architecture
28
29
29
30
Sharpclaw is a console/web AI agent with long-term memory, built on `Microsoft.Agents.AI` and `Microsoft.Extensions.AI`.
30
31
31
-
### Dual Frontend via IChatIO
32
+
### Multi-Channel Frontend via IChatIO
32
33
33
-
The AI engine is decoupled from the frontend through `Abstractions/IChatIO.cs`. Two implementations exist:
34
-
-`UI/ChatWindow.cs` — TUI frontend using Terminal.Gui v2 (chat area + log area + input field)
35
-
-`Web/WebSocketChatIO.cs` — WebSocket frontend, served by `Web/WebServer.cs` (ASP.NET Core), single-client only
34
+
The AI engine is decoupled from the frontend through `Abstractions/IChatIO.cs`. Three implementations exist under `Channels/`:
35
+
-`Channels/Tui/ChatWindow.cs` — TUI frontend using Terminal.Gui v2 (chat area + log area + input field)
36
+
-`Channels/Web/WebSocketChatIO.cs` — WebSocket frontend, served by `Channels/Web/WebServer.cs` (ASP.NET Core), single-client only
37
+
-`Channels/QQBot/QQBotChatIO.cs` — QQ Bot frontend via `Luolan.QQBot`, served by `Channels/QQBot/QQBotServer.cs`
36
38
37
-
Both frontends share the same agent logic. `Abstractions/IAppLogger.cs` + `AppLogger` provide a similar abstraction for logging.
39
+
All frontends share the same agent logic. `Abstractions/IAppLogger.cs` + `AppLogger` provide a similar abstraction for logging.
38
40
39
41
### Entry Point (`Program.cs`)
40
42
41
-
1.`args.Contains("serve")` → dispatches to `WebServer.RunAsync()` (web mode)
2.`web` → dispatches to `WebServer.RunAsync()` (WebSocket server)
46
+
3.`qqbot` → dispatches to `QQBotServer.RunAsync()` (QQ Bot service)
47
+
4.`config` → opens `ConfigDialog` only
48
+
5. Default / `help` → prints usage info
43
49
44
-
`Core/AgentBootstrap.Initialize()` is the shared bootstrap used by both TUI and Web mode: loads config, creates `TaskManager`, registers all command tools as `AIFunction[]`, creates `IMemoryStore`.
50
+
`Core/AgentBootstrap.Initialize()` is the shared bootstrap used by all channels: loads config, creates `TaskManager`, registers all command tools as `AIFunction[]`, creates `IMemoryStore`.
-**Dual frontend** — TUI terminal interface (Terminal.Gui v2) + WebSocket web interface, sharing the same agent logic
19
-
-**Slash commands** — Type `/` to trigger autocomplete, supports `/exit`, `/quit` and more
18
+
-**Multi-channel architecture** — TUI terminal interface (Terminal.Gui v2) + WebSocket web interface + QQ Bot, all sharing the same agent logic via `IChatIO` abstraction
19
+
-**Slash commands** — Type `/` to trigger autocomplete, supports `/exit`, `/quit`, `/config`, `/help`
20
20
-**Streaming output** — Real-time streaming AI responses with reasoning logs and tool call tracing
21
+
-**Configurable keybindings** — TUI quit key, log toggle key, and cancel key are all configurable
21
22
-**Config data encryption** — Sensitive data like API keys are encrypted with AES-256-CBC, with encryption keys stored in the OS credential manager (Windows Credential Manager / macOS Keychain / Linux libsecret)
22
23
23
24
## Requirements
@@ -29,28 +30,45 @@ A .NET 10 AI agent with long-term memory and system operation tools. Supports An
29
30
### TUI Mode (Terminal Interface)
30
31
31
32
```bash
32
-
dotnet run --project sharpclaw
33
+
dotnet run --project sharpclaw tui
33
34
```
34
35
35
36
First run automatically launches the configuration wizard. Select your AI provider, enter API keys, and configure per-agent settings.
36
37
37
38

38
39
39
-
Config is saved to `~/.sharpclaw/config.json`. After that, launching goes straight to interactive chat. Type `/exit` or `/quit` to exit, `Ctrl+Q` to quit.
40
+
Config is saved to `~/.sharpclaw/config.json`. After that, launching goes straight to interactive chat. Type `/exit` or `/quit` to exit, `Ctrl+Q` to quit (default, configurable).
40
41
41
42
### Web Mode (WebSocket Server)
42
43
43
44
```bash
44
-
dotnet run --project sharpclaw serve
45
-
dotnet run --project sharpclaw serve --port 8080
45
+
dotnet run --project sharpclaw web
46
+
dotnet run --project sharpclaw web --address 0.0.0.0 --port 8080
46
47
```
47
48
48
-
Visit `http://localhost:5000` (default port) to open the web chat interface. The Web UI supports Markdown rendering, code highlighting, connection status indicators, and real-time status display.
49
+
Visit `http://localhost:5000` (default) to open the web chat interface. The Web UI supports Markdown rendering, code highlighting, connection status indicators, and real-time status display.
49
50
50
51

51
52
52
53
> Note: Web mode requires completing configuration via TUI mode first. Only one client connection is supported at a time.
53
54
55
+
### QQ Bot Mode
56
+
57
+
```bash
58
+
dotnet run --project sharpclaw qqbot
59
+
```
60
+
61
+
Runs as a QQ Bot service, receiving messages from QQ channels, groups, and private chats. Requires QQ Bot AppId and ClientSecret configured in the config file.
62
+
63
+
> Note: QQ Bot mode requires completing configuration via TUI mode first and enabling QQ Bot in the channels config.
64
+
65
+
### Other Commands
66
+
67
+
```bash
68
+
dotnet run --project sharpclaw config # Open config dialog
69
+
dotnet run --project sharpclaw help# Show usage info
0 commit comments