clew-code 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.md +71 -0
- package/README.md +356 -0
- package/bin/claudevil +2 -0
- package/bin/claudevil.cjs +96 -0
- package/bin/clew +2 -0
- package/bin/clew.cjs +96 -0
- package/dist/main.js +10766 -0
- package/docs/.nojekyll +0 -0
- package/docs/PLAN.md +304 -0
- package/docs/_config.yml +3 -0
- package/docs/architecture.html +144 -0
- package/docs/commands.html +222 -0
- package/docs/configuration.html +144 -0
- package/docs/css/styles.css +790 -0
- package/docs/daemon.html +139 -0
- package/docs/features/bridge-mode.html +77 -0
- package/docs/features/evals.html +160 -0
- package/docs/features/searxng-search.html +129 -0
- package/docs/features/sentry-setup.html +135 -0
- package/docs/index.html +307 -0
- package/docs/installation.html +102 -0
- package/docs/internals/claude-ai-backend-dependencies.md +278 -0
- package/docs/internals/growthbook-ab-testing.html +90 -0
- package/docs/internals/hidden-features.html +126 -0
- package/docs/js/main.js +272 -0
- package/docs/mcp.html +136 -0
- package/docs/models.html +108 -0
- package/docs/permission-model.html +100 -0
- package/docs/plugins.html +100 -0
- package/docs/providers.html +116 -0
- package/docs/quick-start.html +99 -0
- package/docs/research-memory.html +90 -0
- package/docs/skills.html +115 -0
- package/docs/taste.html +181 -0
- package/docs/taste1.html +177 -0
- package/docs/tools.html +168 -0
- package/docs/troubleshooting.html +104 -0
- package/package.json +157 -0
package/docs/.nojekyll
ADDED
|
File without changes
|
package/docs/PLAN.md
ADDED
|
@@ -0,0 +1,304 @@
|
|
|
1
|
+
# Multi-Agent Chat System — PLAN.md
|
|
2
|
+
|
|
3
|
+
## สถานะปัจจุบัน (Current Status)
|
|
4
|
+
|
|
5
|
+
### ทำเสร็จแล้ว ✅
|
|
6
|
+
|
|
7
|
+
| # | Component | Status | File |
|
|
8
|
+
|---|-----------|--------|------|
|
|
9
|
+
| 1 | IPC `inject` type ใน supervisor | ✅ เสร็จ | `src/services/Supervisor/supervisor.ts` |
|
|
10
|
+
| 2 | `handleInject()` handler | ✅ เสร็จ | `src/services/Supervisor/supervisor.ts` |
|
|
11
|
+
| 3 | Session input pipe helper | ✅ เสร็จ | `src/services/Supervisor/supervisor.ts` |
|
|
12
|
+
| 4 | Spawn ด้วย stdin pipe (ไม่ ignore) | ✅ เสร็จ | `src/services/Supervisor/supervisor.ts` |
|
|
13
|
+
| 5 | `injectMessage()` ใน ipcClient | ✅ เสร็จ | `src/services/Supervisor/ipcClient.ts` |
|
|
14
|
+
| 6 | Chat CLI command | ✅ เสร็จ | `src/commands/chat.tsx` |
|
|
15
|
+
| 7 | TUI Chat Input | ✅ เสร็จ | `src/commands/chat.tsx` |
|
|
16
|
+
| 8 | `/team` command - ดู sessions พร้อมบทบาท | ✅ เสร็จ | `src/commands/team.tsx` |
|
|
17
|
+
| 9 | `/send` command - ส่งข้อความระหว่าง session | ✅ เสร็จ | `src/commands/send.tsx` |
|
|
18
|
+
| 10 | Register commands ใน commands.ts | ✅ เสร็จ | `src/commands.ts` |
|
|
19
|
+
| 11 | CLI argument parsing ใน main.tsx | ✅ เสร็จ | `src/main.tsx` |
|
|
20
|
+
|
|
21
|
+
### ยังไม่ได้ทำ ❌
|
|
22
|
+
|
|
23
|
+
| # | Component | Status | File |
|
|
24
|
+
|---|-----------|--------|------|
|
|
25
|
+
| 12 | Test end-to-end | ❌ | — |
|
|
26
|
+
| 13 | Auto-forward messages จาก worker ไป lead | ❌ | — |
|
|
27
|
+
|
|
28
|
+
---
|
|
29
|
+
|
|
30
|
+
## Multi-Agent Chat Architecture
|
|
31
|
+
|
|
32
|
+
```
|
|
33
|
+
┌─────────────────────────────────────────────────────────────────┐
|
|
34
|
+
│ Multi-Agent Chat System │
|
|
35
|
+
├─────────────────────────────────────────────────────────────────┤
|
|
36
|
+
│ │
|
|
37
|
+
│ Lead Session Worker Sessions │
|
|
38
|
+
│ ┌─────────────┐ ┌─────────────┐ │
|
|
39
|
+
│ │ /team │ ◄──────inject─────▶│ Worker 1 │ │
|
|
40
|
+
│ │ /send │ │ (code) │ │
|
|
41
|
+
│ │ (coordinator)│ └─────────────┘ │
|
|
42
|
+
│ └──────┬──────┘ ┌─────────────┐ │
|
|
43
|
+
│ │ │ Worker 2 │ │
|
|
44
|
+
│ │ │ (test) │ │
|
|
45
|
+
│ │ └─────────────┘ │
|
|
46
|
+
│ │ ┌─────────────┐ │
|
|
47
|
+
│ └──────────inject──────────▶│ Worker 3 │ │
|
|
48
|
+
│ │ (review) │ │
|
|
49
|
+
│ └─────────────┘ │
|
|
50
|
+
│ │
|
|
51
|
+
│ Communication: IPC inject messages via Supervisor │
|
|
52
|
+
│ │
|
|
53
|
+
└─────────────────────────────────────────────────────────────────┘
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
---
|
|
57
|
+
|
|
58
|
+
## Commands
|
|
59
|
+
|
|
60
|
+
### `/team` - ดู Sessions และกำหนดบทบาท
|
|
61
|
+
|
|
62
|
+
```bash
|
|
63
|
+
# ดู sessions ทั้งหมดพร้อมบทบาท
|
|
64
|
+
/team
|
|
65
|
+
|
|
66
|
+
# กำหนดบทบาท
|
|
67
|
+
/team role <sessionId> lead # ตั้งเป็น lead
|
|
68
|
+
/team role <sessionId> worker # ตั้งเป็น worker
|
|
69
|
+
/team role <sessionId> idle # ลบบทบาท
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
**Output ตัวอย่าง:**
|
|
73
|
+
```
|
|
74
|
+
📋 Running Sessions:
|
|
75
|
+
|
|
76
|
+
👑 Leaders:
|
|
77
|
+
abc12345 Main Session [running]
|
|
78
|
+
|
|
79
|
+
⚙️ Workers:
|
|
80
|
+
def67890 Code Writer [running]
|
|
81
|
+
ghi23456 Test Runner [running]
|
|
82
|
+
|
|
83
|
+
💤 Idle:
|
|
84
|
+
jkl78901 Reviewer [stopped]
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
---
|
|
88
|
+
|
|
89
|
+
### `/send` - ส่งข้อความระหว่าง Session
|
|
90
|
+
|
|
91
|
+
```bash
|
|
92
|
+
# ส่งไปยัง session เฉพาะ
|
|
93
|
+
/send <sessionId> "ข้อความที่ต้องการ"
|
|
94
|
+
|
|
95
|
+
# ส่งไปยัง lead session ทั้งหมด
|
|
96
|
+
/send lead "งานเสร็จแล้ว"
|
|
97
|
+
|
|
98
|
+
# ส่งไปยัง worker session ทั้งหมด
|
|
99
|
+
/send worker "กรุณาตรวจสอบโค้ด"
|
|
100
|
+
|
|
101
|
+
# Broadcast ไปยังทุก session
|
|
102
|
+
/send all "ประชุมใน 5 นาที"
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
---
|
|
106
|
+
|
|
107
|
+
## IPC Protocol
|
|
108
|
+
|
|
109
|
+
### Request Type: `inject`
|
|
110
|
+
|
|
111
|
+
```json
|
|
112
|
+
{
|
|
113
|
+
"type": "inject",
|
|
114
|
+
"sessionId": "abc12345",
|
|
115
|
+
"prompt": "What is the current status?"
|
|
116
|
+
}
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
### Response
|
|
120
|
+
|
|
121
|
+
```json
|
|
122
|
+
{
|
|
123
|
+
"ok": true,
|
|
124
|
+
"data": {
|
|
125
|
+
"sessionId": "abc12345",
|
|
126
|
+
"injected": "What is the current status?",
|
|
127
|
+
"timestamp": 1717000000000
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
---
|
|
133
|
+
|
|
134
|
+
## Named Pipe Per Session
|
|
135
|
+
|
|
136
|
+
### Windows
|
|
137
|
+
```
|
|
138
|
+
\\.\pipe\claude-session-input-{sessionId}
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
### Unix
|
|
142
|
+
```
|
|
143
|
+
/tmp/claude-session-input-{sessionId}.sock
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
### Behavior
|
|
147
|
+
- สร้างเมื่อ session เริ่มทำงาน (`spawnSessionProcess`)
|
|
148
|
+
- ลบเมื่อ session หยุด (`child.on('exit')`)
|
|
149
|
+
- Supervisor listens สำหรับ connection
|
|
150
|
+
- Messages ที่เขียนไป pipe จะถูก forward ไปยัง session's stdin
|
|
151
|
+
|
|
152
|
+
---
|
|
153
|
+
|
|
154
|
+
## Session stdin Behavior
|
|
155
|
+
|
|
156
|
+
**Before:** `stdio: ['ignore', 'pipe', 'pipe']`
|
|
157
|
+
**After:** `stdio: ['pipe', 'pipe', 'pipe']`
|
|
158
|
+
|
|
159
|
+
อนุญาตให้ส่ง external input ไปยัง session process ผ่าน stdin
|
|
160
|
+
|
|
161
|
+
---
|
|
162
|
+
|
|
163
|
+
## Role System
|
|
164
|
+
|
|
165
|
+
### Roles
|
|
166
|
+
|
|
167
|
+
| Role | Description |
|
|
168
|
+
|------|-------------|
|
|
169
|
+
| `lead` | ผู้ประสานงาน - สั่งงานและดูแล worker |
|
|
170
|
+
| `worker` | ผู้ทำงาน - รับคำสั่งจาก lead |
|
|
171
|
+
| `idle` | ไม่มีบทบาทเฉพาะ |
|
|
172
|
+
|
|
173
|
+
### Auto-forward (Future)
|
|
174
|
+
|
|
175
|
+
Worker sessions สามารถ auto-forward messages ไปยัง lead session ได้:
|
|
176
|
+
- เมื่อ worker ทำงานเสร็จ → ส่งรายงานไป lead
|
|
177
|
+
- เมื่อ worker มีคำถาม → ส่งไป lead
|
|
178
|
+
- เมื่อ worker พบปัญหา → ส่งไป lead
|
|
179
|
+
|
|
180
|
+
Roles are persisted in `~/.claude/daemon/team-roles.json`, so role assignments survive separate CLI processes and can be used by `/send lead` or `/send worker` from any active session.
|
|
181
|
+
|
|
182
|
+
---
|
|
183
|
+
|
|
184
|
+
## วิธีใช้งาน
|
|
185
|
+
|
|
186
|
+
### 1. เริ่ม Multi-Agent Session
|
|
187
|
+
|
|
188
|
+
```bash
|
|
189
|
+
# Terminal 1: Start lead session
|
|
190
|
+
bun run src/main.tsx
|
|
191
|
+
|
|
192
|
+
# Terminal 2: Start worker session 1
|
|
193
|
+
bun run src/main.tsx --name "Code Writer"
|
|
194
|
+
|
|
195
|
+
# Terminal 3: Start worker session 2
|
|
196
|
+
bun run src/main.tsx --name "Test Runner"
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
### 2. กำหนดบทบาท
|
|
200
|
+
|
|
201
|
+
```bash
|
|
202
|
+
# ใน lead session
|
|
203
|
+
/team role abc12345 lead
|
|
204
|
+
/team role def67890 worker
|
|
205
|
+
/team role ghi23456 worker
|
|
206
|
+
```
|
|
207
|
+
|
|
208
|
+
### 3. ส่งข้อความ
|
|
209
|
+
|
|
210
|
+
```bash
|
|
211
|
+
# Lead สั่งงาน worker
|
|
212
|
+
/send def67890 "Please implement the user authentication module"
|
|
213
|
+
|
|
214
|
+
# Worker รายงาน lead
|
|
215
|
+
/send lead "I've completed the authentication module"
|
|
216
|
+
|
|
217
|
+
# Broadcast ไปทุก session
|
|
218
|
+
/send all "Meeting in 5 minutes"
|
|
219
|
+
```
|
|
220
|
+
|
|
221
|
+
หรือสั่งด้วยภาษาปกติใน TUI ได้โดยไม่ต้องใช้ slash command:
|
|
222
|
+
|
|
223
|
+
```text
|
|
224
|
+
lead ไปสั่งงาน session 3 ให้รัน test หน่อย
|
|
225
|
+
บอก worker ทุกตัวให้ review diff
|
|
226
|
+
ตั้ง abc12345 เป็น lead
|
|
227
|
+
โชว์ team sessions ทั้งหมด
|
|
228
|
+
```
|
|
229
|
+
|
|
230
|
+
โมเดลจะใช้ `MultiAgent` tool เพื่อ list sessions, assign role, หรือส่งข้อความให้ session เป้าหมายเอง
|
|
231
|
+
|
|
232
|
+
### 4. ดูสถานะ
|
|
233
|
+
|
|
234
|
+
```bash
|
|
235
|
+
# ดู sessions ทั้งหมด
|
|
236
|
+
/team
|
|
237
|
+
```
|
|
238
|
+
|
|
239
|
+
### 5. ใช้ผ่าน CLI โดยตรง
|
|
240
|
+
|
|
241
|
+
```bash
|
|
242
|
+
clew team
|
|
243
|
+
clew team role abc12345 worker
|
|
244
|
+
clew send worker "Please run the test suite"
|
|
245
|
+
clew chat abc12345
|
|
246
|
+
clew chat abc12345 "status update?"
|
|
247
|
+
```
|
|
248
|
+
|
|
249
|
+
---
|
|
250
|
+
|
|
251
|
+
## Files Modified/Created
|
|
252
|
+
|
|
253
|
+
### Modified ✅
|
|
254
|
+
- `src/services/Supervisor/supervisor.ts` — Added `inject` IPC type, `handleInject()`, `setupSessionInputPipe()`, `forwardInputToSession()`, `cleanupSessionInputPipe()`, changed spawn to `['pipe', 'pipe', 'pipe']`
|
|
255
|
+
- `src/services/Supervisor/ipcClient.ts` — Added `injectMessage()` function
|
|
256
|
+
- `src/commands.ts` — Added imports and registered `team`, `send`, `chat` commands
|
|
257
|
+
- `src/main.tsx` — Added CLI parsing for `team`, `send`, and `chat` commands
|
|
258
|
+
|
|
259
|
+
### Created ✅
|
|
260
|
+
- `src/commands/chat.tsx` — Chat CLI command handler
|
|
261
|
+
- `src/commands/team.tsx` — `/team` command for session management
|
|
262
|
+
- `src/commands/send.tsx` — `/send` command for inter-session messaging
|
|
263
|
+
- `src/tools/MultiAgentTool/MultiAgentTool.ts` — Model-callable natural-language team coordination tool
|
|
264
|
+
- `docs/PLAN.md` — This file
|
|
265
|
+
|
|
266
|
+
---
|
|
267
|
+
|
|
268
|
+
## Validation Workflow
|
|
269
|
+
|
|
270
|
+
### End-to-End Test
|
|
271
|
+
|
|
272
|
+
```bash
|
|
273
|
+
# Start supervisor daemon
|
|
274
|
+
bun run src/main.tsx daemon start
|
|
275
|
+
|
|
276
|
+
# Spawn background sessions
|
|
277
|
+
bun run src/main.tsx --bg "Task 1"
|
|
278
|
+
bun run src/main.tsx --bg "Task 2"
|
|
279
|
+
|
|
280
|
+
# Open lead session
|
|
281
|
+
bun run src/main.tsx
|
|
282
|
+
|
|
283
|
+
# In lead session:
|
|
284
|
+
/team # See all sessions
|
|
285
|
+
/team role <id> worker # Assign roles
|
|
286
|
+
/send <id> "Do this task" # Send commands
|
|
287
|
+
```
|
|
288
|
+
|
|
289
|
+
### Future: Auto-Forward
|
|
290
|
+
|
|
291
|
+
Add auto-forward logic in session message handler:
|
|
292
|
+
- When session receives response → check if it's a worker
|
|
293
|
+
- If worker → forward summary to lead session
|
|
294
|
+
- Use `injectMessage()` to send
|
|
295
|
+
|
|
296
|
+
---
|
|
297
|
+
|
|
298
|
+
## Notes
|
|
299
|
+
|
|
300
|
+
- ใช้ IPC inject สำหรับส่งข้อความระหว่าง sessions
|
|
301
|
+
- ไม่ต้องมี Web UI สำหรับ basic usage (ใช้ CLI commands ได้เลย)
|
|
302
|
+
- Web UI เป็น optional สำหรับ visual overview
|
|
303
|
+
- Role system persist ข้าม process ผ่าน `~/.claude/daemon/team-roles.json`
|
|
304
|
+
- Auto-forward ยังเป็น future work
|
package/docs/_config.yml
ADDED
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="UTF-8">
|
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
6
|
+
<title>Architecture — Clew</title>
|
|
7
|
+
<meta name="description" content="Runtime architecture, layered design, and data flow for Clew CLI.">
|
|
8
|
+
<link rel="preconnect" href="https://fonts.googleapis.com">
|
|
9
|
+
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
|
10
|
+
<link href="https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500;600;700&display=swap" rel="stylesheet">
|
|
11
|
+
<link rel="stylesheet" href="css/styles.css">
|
|
12
|
+
</head>
|
|
13
|
+
<body>
|
|
14
|
+
<header class="header"><div class="header-inner"><a href="index.html" class="logo"><span>Clew</span></a><nav class="header-nav"><a href="index.html">Home</a><a href="index.html#features">Features</a><a href="index.html#commands">Commands</a><a href="quick-start.html" class="active">Docs</a><a href="https://github.com/JonusNattapong/ClewCode" target="_blank">GitHub</a></nav><button class="menu-btn" id="menuToggle" aria-label="Toggle navigation"><span></span><span></span><span></span></button></div></header>
|
|
15
|
+
<div class="app"><aside class="sidebar" id="sidebar"></aside><div class="sidebar-overlay" id="sidebarOverlay"></div>
|
|
16
|
+
<div class="content-wrap"><main class="content">
|
|
17
|
+
<div class="breadcrumbs"><a href="index.html">Home</a><span class="sep">/</span><span>Architecture</span></div>
|
|
18
|
+
<h1>Architecture</h1>
|
|
19
|
+
<p class="section-subtitle">Clew is a terminal-based AI coding assistant — a React/Ink TUI, Commander.js CLI, multi-provider AI engine, and extensible tool/plugin runtime all in one process.</p>
|
|
20
|
+
|
|
21
|
+
<h2>Layered Design</h2>
|
|
22
|
+
<p>The application is structured as four cooperative layers:</p>
|
|
23
|
+
|
|
24
|
+
<h3>1. Terminal UI (React 19 + Ink 6)</h3>
|
|
25
|
+
<p>Renders the interactive REPL: prompt input, streaming markdown output, status bar with context meter, arc spinner, permission dialogs, file explorer, inline images, buddy (duck) companion, and fullscreen mode. Components live in <code>src/components/</code>, state management in <code>src/state/</code>, and React context in <code>src/context/</code>.</p>
|
|
26
|
+
|
|
27
|
+
<h3>2. CLI & Command Layer (Commander.js 13)</h3>
|
|
28
|
+
<p>Entry point at <code>src/main.tsx</code> — parses CLI flags (<code>--model</code>, <code>--print</code>, <code>--permission-mode</code>, <code>--mcp-config</code>, etc.), loads config, initializes providers and telemetry, then launches the REPL or print-mode query. Slash commands are registered in <code>src/commands.ts</code> and implemented under <code>src/commands/</code>. Commands are categorized as <code>local</code> (runs in-terminal), <code>prompt</code> (skills that expand to text), or <code>local-jsx</code> (Ink UI panels).</p>
|
|
29
|
+
|
|
30
|
+
<h3>3. AI Provider & Adapter Layer</h3>
|
|
31
|
+
<p><strong>ProviderManager</strong> (<code>src/services/ai/ProviderManager.ts</code>) resolves API keys, selects models, and manages provider config. Provider metadata is declared in <code>src/services/ai/providers.json</code> — currently 27 providers with model listings, capabilities, base URLs, and env key mappings. Non-Anthropic providers are wrapped by the <strong>AnthropicAdapter</strong> or <strong>GoogleAdapter</strong>, which normalize content blocks (<code>contentBlockUtils.ts</code>), tool calls (<code>toolCallParser.ts</code>), errors (<code>errorNormalizer.ts</code>), and usage (<code>usageNormalizer.ts</code>) to a uniform format.</p>
|
|
32
|
+
|
|
33
|
+
<h3>4. Tool Execution & Query Loop</h3>
|
|
34
|
+
<p>Tools use Zod schemas and are executed by the <strong>StreamingToolExecutor</strong> (<code>src/services/tools/StreamingToolExecutor.ts</code>). Permission gating via hooks in <code>src/utils/permissions/permissions.ts</code>. The query loop in <code>src/query.ts</code> + <code>src/QueryEngine.ts</code> orchestrates message building, context management, streaming, and tool call cycling. MCP tools (<code>src/services/mcp/</code>) are discovered at runtime and merged into the tool pool.</p>
|
|
35
|
+
|
|
36
|
+
<h2>Data Flow</h2>
|
|
37
|
+
<pre><code> Terminal input
|
|
38
|
+
|
|
|
39
|
+
v
|
|
40
|
+
+ Query Engine (query.ts + QueryEngine.ts)
|
|
41
|
+
| Message building and context assembly
|
|
42
|
+
| Tool call loop (model tool results)
|
|
43
|
+
| Streaming response handling
|
|
44
|
+
|
|
|
45
|
+
+ Provider Manager Adapter AI Model API
|
|
46
|
+
| 27 providers via providers.json
|
|
47
|
+
| AnthropicAdapter / GoogleAdapter normalization
|
|
48
|
+
|
|
|
49
|
+
+ Tool Executor (StreamingToolExecutor)
|
|
50
|
+
| Permission check (permissions.ts)
|
|
51
|
+
| Pre/Post tool hooks (plugins)
|
|
52
|
+
| Tool execution result
|
|
53
|
+
|
|
|
54
|
+
+ Terminal UI (React/Ink)
|
|
55
|
+
Streaming text and tool renders
|
|
56
|
+
Status bar, spinner, context meter
|
|
57
|
+
Permission dialogs</code></pre>
|
|
58
|
+
|
|
59
|
+
<h2>Key Subsystems</h2>
|
|
60
|
+
|
|
61
|
+
<h3>MCP (Model Context Protocol)</h3>
|
|
62
|
+
<p><code>src/services/mcp/</code> — manages external MCP server connections, tool discovery, resource access, and paginated <code>tools/list</code> responses. Servers configured via <code>--mcp-config</code> or <code>/mcp</code> command. See <a href="mcp.html">MCP</a> for detailed setup and configuration.</p>
|
|
63
|
+
|
|
64
|
+
<h3>Plugins & Hooks</h3>
|
|
65
|
+
<p><code>src/services/plugins/</code> — plugin loading, installation, marketplace reconciliation, and hook dispatch. Hook points: <code>PreToolUse</code>, <code>PostToolUse</code>, <code>PreBash</code>, <code>PostPrompt</code>, <code>PreAcceptEdit</code>. Plugins can provide commands, agents, skills, MCP servers, and LSP integrations.</p>
|
|
66
|
+
|
|
67
|
+
<h3>LSP (Language Server Protocol)</h3>
|
|
68
|
+
<p><code>src/services/lsp/</code> — language-aware code intelligence via LSP servers. Diagnostics, completions, and symbol navigation. Enable with <code>ENABLE_LSP_TOOL=1</code>.</p>
|
|
69
|
+
|
|
70
|
+
<h3>Bridge Mode</h3>
|
|
71
|
+
<p><code>src/bridge/bridgeMain.ts</code> — WebSocket remote control and collaboration. Gated behind <code>BRIDGE_MODE=1</code>. Remote clients can send commands and receive responses.</p>
|
|
72
|
+
|
|
73
|
+
<h3>Session System</h3>
|
|
74
|
+
<p><code>src/services/SessionBridge/</code> — cross-session context persistence. <code>src/services/SessionMemory/</code> — persistent knowledge with cross-lingual semantic search and auto-memory capture.</p>
|
|
75
|
+
|
|
76
|
+
<h3>GrowthBook Feature Flags</h3>
|
|
77
|
+
<p><code>src/services/analytics/growthbook.js</code> — A/B testing and feature flag platform. Initialized at startup, evaluates flags locally with caching.</p>
|
|
78
|
+
|
|
79
|
+
<h3>Agent Runtime</h3>
|
|
80
|
+
<p><code>src/agentRuntime/</code> — manages multi-agent orchestration. The <strong>orchestrator</strong> coordinates agent sessions, <strong>runStore</strong> persists agent run data, <strong>toolGateway</strong> routes tools between agents, and <strong>workflowRegistry</strong> / <strong>agentRegistry</strong> declare named workflows and agent configurations.</p>
|
|
81
|
+
|
|
82
|
+
<h3>Autonomous / Daemon</h3>
|
|
83
|
+
<p><code>src/services/autonomous/</code> — enables 24/7 background execution. The <strong>taskQueue</strong> is a file-backed queue with priorities, leases, and dead-letter handling. <strong>agentLoop</strong> runs the continuous dequeue spawn worker monitor retry cycle. <strong>daemonMode</strong> provides the supervisor-managed background process entry point, and <strong>supervisorIntegration</strong> handles health checks and auto-respawn. See <a href="daemon.html">Daemon Mode</a> for detailed configuration and usage.</p>
|
|
84
|
+
|
|
85
|
+
<h3>Coordinator (Multi-Agent)</h3>
|
|
86
|
+
<p><code>src/coordinator/</code> — supports multi-agent collaboration. <strong>coordinatorMode</strong> delegates tasks to sub-agents, and <strong>workerAgent</strong> provides standalone workers for delegated subtasks.</p>
|
|
87
|
+
|
|
88
|
+
<h3>Research & Memory</h3>
|
|
89
|
+
<p><code>src/research/</code> — built-in deep research capabilities: citation extraction, claim verification, dossier generation, truth checking, and source ranking. <code>src/memdir/</code> — semantic memory with text embedding search, memory age tracking, auto-memory capture, and cross-session recall. See <a href="research-memory.html">Research & Memory</a> for detailed usage.</p>
|
|
90
|
+
|
|
91
|
+
<h3>Voice Mode</h3>
|
|
92
|
+
<p><code>src/voice/</code> — compile-time gated voice input support (<code>VOICE_MODE=1</code>). Provides speech-to-text and voice command processing for hands-free operation.</p>
|
|
93
|
+
|
|
94
|
+
<h3>State Management</h3>
|
|
95
|
+
<p>The app uses a lightweight observable store pattern (<code>createStore<T></code> in <code>src/state/store.ts</code>). Stores are plain functions with <code>getState</code>, <code>setState</code>, and <code>subscribe</code>. React components subscribe via the <strong>AppState</strong> React context (<code>src/state/AppState.tsx</code>).</p>
|
|
96
|
+
|
|
97
|
+
<h2>Important Source Paths</h2>
|
|
98
|
+
<table>
|
|
99
|
+
<tr><th>Path</th><th>Role</th></tr>
|
|
100
|
+
<tr><td><code>src/main.tsx</code></td><td>CLI entry, Commander program, option parsing, REPL launch</td></tr>
|
|
101
|
+
<tr><td><code>src/query.ts</code></td><td>Core query processing, message building, tool call loop</td></tr>
|
|
102
|
+
<tr><td><code>src/QueryEngine.ts</code></td><td>Query orchestration, caching, deduplication, rate limiting</td></tr>
|
|
103
|
+
<tr><td><code>src/commands.ts</code></td><td>Slash command registry (80+ commands)</td></tr>
|
|
104
|
+
<tr><td><code>src/tools.ts</code></td><td>Tool registry (40+ built-in tools)</td></tr>
|
|
105
|
+
<tr><td><code>src/Tool.ts</code></td><td>Base tool types, schemas, buildTool() helper</td></tr>
|
|
106
|
+
<tr><td><code>src/services/ai/ProviderManager.ts</code></td><td>Provider selection, API key resolution</td></tr>
|
|
107
|
+
<tr><td><code>src/services/ai/providers.json</code></td><td>Declarative provider config (27 providers)</td></tr>
|
|
108
|
+
<tr><td><code>src/services/ai/adapter/</code></td><td>AnthropicAdapter, GoogleAdapter</td></tr>
|
|
109
|
+
<tr><td><code>src/services/tools/StreamingToolExecutor.ts</code></td><td>Streaming tool execution</td></tr>
|
|
110
|
+
<tr><td><code>src/utils/permissions/permissions.ts</code></td><td>Permission evaluation logic</td></tr>
|
|
111
|
+
<tr><td><code>src/services/mcp/</code></td><td>MCP server management</td></tr>
|
|
112
|
+
<tr><td><code>src/services/plugins/</code></td><td>Plugin loader and hook dispatch</td></tr>
|
|
113
|
+
<tr><td><code>src/state/store.ts</code></td><td>Lightweight observable store (createStore<T>)</td></tr>
|
|
114
|
+
<tr><td><code>src/state/AppState.tsx</code></td><td>Root app state (React context)</td></tr>
|
|
115
|
+
<tr><td><code>src/state/AppStateStore.ts</code></td><td>App state store implementation</td></tr>
|
|
116
|
+
<tr><td><code>src/state/selectors.ts</code></td><td>State selectors</td></tr>
|
|
117
|
+
<tr><td><code>src/agentRuntime/</code></td><td>Agent orchestration, run store, tool gateway</td></tr>
|
|
118
|
+
<tr><td><code>src/services/autonomous/</code></td><td>Task queue, agent loop, daemon mode, supervisor</td></tr>
|
|
119
|
+
<tr><td><code>src/coordinator/</code></td><td>Multi-agent coordinator and worker agents</td></tr>
|
|
120
|
+
<tr><td><code>src/research/</code></td><td>Deep research, dossier generation, truth checking</td></tr>
|
|
121
|
+
<tr><td><code>src/memdir/</code></td><td>Semantic memory search and storage</td></tr>
|
|
122
|
+
<tr><td><code>src/voice/</code></td><td>Voice mode support (compile-time gated)</td></tr>
|
|
123
|
+
<tr><td><code>src/entrypoints/init.ts</code></td><td>Startup initialization (Sentry, configs, telemetry)</td></tr>
|
|
124
|
+
<tr><td><code>src/entrypoints/cli.tsx</code></td><td>Alternative CLI entry point (Commander-based)</td></tr>
|
|
125
|
+
<tr><td><code>src/entrypoints/mcp.ts</code></td><td>MCP server entry point</td></tr>
|
|
126
|
+
</table>
|
|
127
|
+
|
|
128
|
+
<h2>Build System</h2>
|
|
129
|
+
<p>Built with Bun bundler — <code>bun run build</code> outputs a single binary to <code>dist/</code>. TypeScript with strict mode and ESM/NodeNext module resolution. External dependencies include Electron, chromium-bidi, AWS SDK, Google Auth, and platform-specific native modules. Lint/format via Biome 2.4.</p>
|
|
130
|
+
|
|
131
|
+
<footer class="footer">
|
|
132
|
+
<span>Clew v0.1.2 — Open Source</span>
|
|
133
|
+
<div class="footer-links">
|
|
134
|
+
<a href="https://github.com/JonusNattapong/ClewCode">GitHub</a>
|
|
135
|
+
<a href="https://github.com/JonusNattapong/ClewCode/issues">Issues</a>
|
|
136
|
+
</div>
|
|
137
|
+
</footer>
|
|
138
|
+
</main>
|
|
139
|
+
<nav class="toc-sidebar"></nav>
|
|
140
|
+
</div>
|
|
141
|
+
</div>
|
|
142
|
+
<script src="js/main.js"></script>
|
|
143
|
+
</body>
|
|
144
|
+
</html>
|