clew-code 0.4.7 → 0.4.9
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/README.md +239 -267
- package/dist/main.js +2073 -2067
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -2,366 +2,338 @@
|
|
|
2
2
|
|
|
3
3
|
<img src="assets/clew-logo-long.png" alt="Clew Code" width="520" />
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
### *The agent that works where you do.*
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
<p align="center">
|
|
8
|
+
<a href="https://github.com/ClewCode/ClewCode/stargazers"><img src="https://img.shields.io/github/stars/ClewCode/ClewCode?style=for-the-badge&color=blue" alt="GitHub stars"></a>
|
|
9
|
+
<a href="https://github.com/ClewCode/ClewCode/releases"><img src="https://img.shields.io/github/v/release/ClewCode/ClewCode?style=for-the-badge&color=orange" alt="Release"></a>
|
|
10
|
+
<a href="https://www.npmjs.com/package/clew-code"><img src="https://img.shields.io/npm/v/clew-code?style=for-the-badge&color=red" alt="npm"></a>
|
|
11
|
+
<a href="https://github.com/ClewCode/ClewCode/actions/workflows/ci.yml"><img src="https://img.shields.io/github/actions/workflow/status/ClewCode/ClewCode/ci.yml?branch=main&style=for-the-badge" alt="CI"></a>
|
|
12
|
+
<a href="LICENSE.md"><img src="https://img.shields.io/badge/License-GPL--3.0-blue.svg?style=for-the-badge" alt="License"></a>
|
|
13
|
+
<a href="https://bun.sh"><img src="https://img.shields.io/badge/built%20with-Bun-ff69b4.svg?style=for-the-badge" alt="Bun"></a>
|
|
14
|
+
</p>
|
|
8
15
|
|
|
9
|
-
|
|
16
|
+
<p align="center">
|
|
17
|
+
<a href="https://clew-code.org">Website</a> · <a href="https://clew-docs.pages.dev">Docs</a> · <a href="https://github.com/ClewCode/ClewCode/wiki">Wiki</a> · <a href="https://github.com/ClewCode/ClewCode">GitHub</a>
|
|
18
|
+
</p>
|
|
10
19
|
|
|
11
|
-
|
|
12
|
-
[](https://github.com/ClewCode/ClewCode/releases)
|
|
13
|
-
[](https://www.npmjs.com/package/clew-code)
|
|
14
|
-
[](https://github.com/ClewCode/ClewCode/actions/workflows/ci.yml)
|
|
15
|
-
[](#license)
|
|
16
|
-
[](https://bun.sh)
|
|
20
|
+
</div>
|
|
17
21
|
|
|
18
|
-
|
|
22
|
+
---
|
|
19
23
|
|
|
20
|
-
|
|
24
|
+
<p align="center">
|
|
25
|
+
<img src="assets/screenshots/clew-code-repl.png" alt="Clew Code REPL" width="680" />
|
|
26
|
+
</p>
|
|
21
27
|
|
|
22
28
|
---
|
|
23
29
|
|
|
24
|
-
|
|
30
|
+
Clew Code is a terminal-native AI coding agent that lives in your repo, works with your API keys, and **doesn't phone home**. It reads your code, writes files, runs commands, and talks to any LLM you bring — all on your machine, no telemetry, no vendor lock-in.
|
|
25
31
|
|
|
26
|
-
|
|
27
|
-
<tr><td><b>A real terminal interface</b></td><td>Ink-based terminal REPL with autocompletion, slash commands, syntax highlighting, and inline tool stream.</td></tr>
|
|
28
|
-
<tr><td><b>Durable memory loop</b></td><td>SQLite-backed memory store that builds a factual profile of your project, manages context compaction, and injects relevant context into prompt cycles.</td></tr>
|
|
29
|
-
<tr><td><b>Peer-to-peer swarm</b></td><td>Zero-config multicast LAN discovery. Synchronize memory, assign tasks, and broadcast shell execution to multiple peer nodes.</td></tr>
|
|
30
|
-
<tr><td><b>Extensible tools & MCP</b></td><td>Integrates with external tools over Model Context Protocol (stdio, SSE, DirectConnect) and supports custom markdown-based skills (SKILL.md).</td></tr>
|
|
31
|
-
<tr><td><b>Multiple execution layers</b></td><td>Run tasks using standard Agents, isolated Subagents, teammate swarms, or delegate to external CLIs via Process Delegates.</td></tr>
|
|
32
|
-
<tr><td><b>Comprehensive guardrails</b></td><td>Secondary LLM guardian validation, manual approve/deny override, and multi-mode permissions (ask, auto, plan, etc.).</td></tr>
|
|
33
|
-
</table>
|
|
32
|
+
If you want a coding assistant that feels local, fast, and doesn't ship your context to a third-party server, this is it.
|
|
34
33
|
|
|
35
34
|
---
|
|
36
35
|
|
|
37
36
|
## Table of Contents
|
|
38
37
|
|
|
39
|
-
- [
|
|
40
|
-
- [
|
|
41
|
-
- [
|
|
42
|
-
- [
|
|
43
|
-
- [
|
|
44
|
-
- [Quick
|
|
45
|
-
- [Supported Providers](#supported-providers)
|
|
46
|
-
- [CLI Options](#cli-options)
|
|
47
|
-
- [Commands Reference](#commands-reference)
|
|
48
|
-
- [Tools Reference](#tools-reference)
|
|
38
|
+
- [Prerequisites](#prerequisites)
|
|
39
|
+
- [Quick Install](#quick-install)
|
|
40
|
+
- [Getting Started](#getting-started)
|
|
41
|
+
- [Features](#features)
|
|
42
|
+
- [Use Cases](#use-cases)
|
|
43
|
+
- [CLI Quick Reference](#cli-quick-reference)
|
|
49
44
|
- [Configuration](#configuration)
|
|
50
|
-
- [
|
|
51
|
-
- [
|
|
45
|
+
- [Security](#security)
|
|
46
|
+
- [Documentation](#documentation)
|
|
47
|
+
- [Architecture](#architecture)
|
|
48
|
+
- [Development](#development)
|
|
49
|
+
- [Contributing](#contributing)
|
|
50
|
+
- [Star History](#star-history)
|
|
52
51
|
- [License](#license)
|
|
53
52
|
|
|
54
53
|
---
|
|
55
54
|
|
|
56
|
-
##
|
|
57
|
-
|
|
58
|
-
Clew Code is an autonomous AI coding agent designed to live in your terminal. It is provider-agnostic, allowing you to bring your own API keys from OpenAI, Google, DeepSeek, Groq, OpenRouter, a local Ollama instance, or any other compatible provider, and switch between them dynamically mid-session.
|
|
55
|
+
## Prerequisites
|
|
59
56
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
* **Decentralized Scaling:** Clew instances discover each other on the local network (LAN), synchronizing memory and distributing tasks automatically.
|
|
57
|
+
- **Node.js** 18+ or **Bun** 1.x (recommended for development)
|
|
58
|
+
- An **API key** from at least one supported provider (see [Providers docs](https://clew-docs.pages.dev/providers))
|
|
59
|
+
- *Optional:* Git, Playwright (for browser automation), microphone (for voice input)
|
|
64
60
|
|
|
65
61
|
---
|
|
66
62
|
|
|
67
|
-
##
|
|
63
|
+
## Quick Install
|
|
68
64
|
|
|
69
|
-
|
|
65
|
+
### macOS / Linux
|
|
70
66
|
|
|
71
|
-
```
|
|
72
|
-
|
|
73
|
-
User([User]) <--> REPL[REPL Interface\nInk & React 19]
|
|
74
|
-
REPL <--> QE[Query Engine\nTool Loop & Router]
|
|
75
|
-
QE <--> SQLite[(SQLite\nPersistent Memory)]
|
|
76
|
-
QE <--> Tools[Built-in Tools\nFile, Bash, Web, MCP]
|
|
77
|
-
QE <--> Peers[Peer Server\nLAN Swarm Sync]
|
|
78
|
-
QE <--> Provider[Provider Manager\n29 Model Adapters]
|
|
67
|
+
```bash
|
|
68
|
+
curl -fsSL https://raw.githubusercontent.com/ClewCode/ClewCode/main/scripts/install.sh | bash
|
|
79
69
|
```
|
|
80
70
|
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
## Execution Layers and Model Routing
|
|
84
|
-
|
|
85
|
-
Clew Code separates execution agents (how the work is scheduled and structured) from backend model providers (the engines driving inference).
|
|
86
|
-
|
|
87
|
-
### Execution Layers
|
|
88
|
-
|
|
89
|
-
Work is distributed across four distinct layers to balance isolation, capability, and performance:
|
|
71
|
+
### Windows (PowerShell)
|
|
90
72
|
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
* **Process Delegate (Codex / Shell Delegation):** A local subprocess wrapper that delegates tasks to external CLI tools or models using `exec`/`pty`. For example, in personal command-center mode, the main agent delegates editor file changes to a Codex worker, monitors execution, and evaluates the results before merging.
|
|
95
|
-
|
|
96
|
-
### Model Routing and Providers
|
|
73
|
+
```powershell
|
|
74
|
+
irm https://raw.githubusercontent.com/ClewCode/ClewCode/main/scripts/install.ps1 | iex
|
|
75
|
+
```
|
|
97
76
|
|
|
98
|
-
|
|
77
|
+
### npm (cross-platform)
|
|
99
78
|
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
79
|
+
```bash
|
|
80
|
+
npm install -g clew-code
|
|
81
|
+
```
|
|
103
82
|
|
|
104
83
|
---
|
|
105
84
|
|
|
106
|
-
##
|
|
85
|
+
## Getting Started
|
|
107
86
|
|
|
108
|
-
|
|
87
|
+
```bash
|
|
88
|
+
cd your-project
|
|
89
|
+
clew # Launch the REPL
|
|
90
|
+
clew -p "fix the tests" # One-shot mode
|
|
91
|
+
clew --resume last # Pick up where you left off
|
|
92
|
+
```
|
|
109
93
|
|
|
110
|
-
|
|
111
|
-
* **Context Compaction and Checkpoints:** When the prompt token window fills up, Clew Code runs a multi-pass context compaction loop that recursively compresses history into factual summaries. To prevent loss of active work during compaction, the supervisor captures progress snapshots as checkpoints at 20%, 45%, and 70% milestones, along with a `notes.md` scratchpad for recovery.
|
|
112
|
-
* **Autonomous Task Queue and Daemon Mode:** Features a persistent task queue that operates with lease-based concurrency limits (allowing a maximum of 3 concurrent active tasks), exponential backoff retries, and a dead-letter queue (DLQ). The CLI can run in a background Daemon Mode to consume the task queue, run scheduled natural-language cron jobs, and perform memory distillation while the terminal is closed.
|
|
113
|
-
* **Model Context Protocol (MCP):** A unified client interface supporting stdio, Server-Sent Events (SSE), and direct in-process WebSocket connection adapters. It dynamically fetches tool declarations and resources, extending the agent's capabilities with external server tools.
|
|
114
|
-
* **Permissions and Guardian Guardrails:** Configurable permission systems restrict tool execution using policies like `ask` (confirm each edit/run), `auto` (bypass prompts), and `guardian`. Under Guardian Mode, a secondary LLM audits execution safety, blocking dangerous terminal shell operations or sensitive edits unless overridden via `/approve`.
|
|
115
|
-
* **Goal Verification:** Objectives defined via `/goal` are tracked using heuristic pre-checks and verified independently by a separate LLM verification loop. The agent will not exit until the verifier confirms that all objectives in the plan are completed.
|
|
94
|
+
First launch walks you through provider setup. After that, use `/model` to switch providers mid-session.
|
|
116
95
|
|
|
117
96
|
---
|
|
118
97
|
|
|
119
|
-
##
|
|
98
|
+
## Features
|
|
120
99
|
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
100
|
+
<table>
|
|
101
|
+
<tr>
|
|
102
|
+
<td><strong>29+ Providers</strong></td>
|
|
103
|
+
<td>OpenAI, Anthropic, DeepSeek, Groq, Google, Ollama (local), and 22+ more. Switch mid-session with <code>/model</code>. No lock-in.</td>
|
|
104
|
+
</tr>
|
|
105
|
+
<tr>
|
|
106
|
+
<td><strong>Persistent Memory</strong></td>
|
|
107
|
+
<td>SQLite-backed, MiMo-inspired store with importance ranking, confidence scoring, and cross-session persistence. Auto-consolidation via Dream + Distill.</td>
|
|
108
|
+
</tr>
|
|
109
|
+
<tr>
|
|
110
|
+
<td><strong>76+ Tools</strong></td>
|
|
111
|
+
<td>Read, Write, Edit, Grep, Bash, Browser, MCP, LSP, git, web search, task management, peer coordination, media generation, voice input.</td>
|
|
112
|
+
</tr>
|
|
113
|
+
<tr>
|
|
114
|
+
<td><strong>LAN Peer Swarm</strong></td>
|
|
115
|
+
<td>Zero-config peer discovery over UDP multicast. Sync memory across machines, delegate tasks, broadcast shell commands with worktree isolation and dependency ordering.</td>
|
|
116
|
+
</tr>
|
|
117
|
+
<tr>
|
|
118
|
+
<td><strong>MCP + Plugins + Skills</strong></td>
|
|
119
|
+
<td>Model Context Protocol over stdio/SSE/WebSocket. Extend with plugins, <code>SKILL.md</code> workflows, or lifecycle hooks.</td>
|
|
120
|
+
</tr>
|
|
121
|
+
<tr>
|
|
122
|
+
<td><strong>Enterprise Audit Logging</strong></td>
|
|
123
|
+
<td>SIEM-compatible NDJSON audit trail with rotation, filtering, and level-based capture. Records tool calls, file access, and command execution.</td>
|
|
124
|
+
</tr>
|
|
125
|
+
<tr>
|
|
126
|
+
<td><strong>Project Rules</strong></td>
|
|
127
|
+
<td>Auto-observed behavioral rules scoped to your repo via <code>/rule</code>. Configured in <code>.clew/rules.json</code> — Clew reads and follows them without being reminded.</td>
|
|
128
|
+
</tr>
|
|
129
|
+
<tr>
|
|
130
|
+
<td><strong>Ultracode Reasoning</strong></td>
|
|
131
|
+
<td>Max-effort reasoning mode (<code>/ultracode</code> or <code>--effort max</code>) for complex debugging, architecture design, and multi-step refactoring.</td>
|
|
132
|
+
</tr>
|
|
133
|
+
<tr>
|
|
134
|
+
<td><strong>Rewind / Undo</strong></td>
|
|
135
|
+
<td><code>/rewind</code> restores code and/or conversation to any previous checkpoint. Integrated with structured 20%/45%/70% progress snapshots.</td>
|
|
136
|
+
</tr>
|
|
137
|
+
<tr>
|
|
138
|
+
<td><strong>Cross-Repo Workspace</strong></td>
|
|
139
|
+
<td><code>/workspace link ../other-repo</code> — edit across linked projects with full context loaded from both. Bidirectional and persistent.</td>
|
|
140
|
+
</tr>
|
|
141
|
+
<tr>
|
|
142
|
+
<td><strong>Background Daemon</strong></td>
|
|
143
|
+
<td>Task queue with lease-based concurrency, cron scheduling, dead-letter retries, memory consolidation, and cross-session task persistence.</td>
|
|
144
|
+
</tr>
|
|
145
|
+
<tr>
|
|
146
|
+
<td><strong>Multi-Agent Architecture</strong></td>
|
|
147
|
+
<td>Agents, Subagents, LAN Peers, Process Peers. Personal profile turns Clew into a command center that delegates to Codex workers.</td>
|
|
148
|
+
</tr>
|
|
149
|
+
</table>
|
|
129
150
|
|
|
130
|
-
|
|
131
|
-
```bash
|
|
132
|
-
# Clone the repository
|
|
133
|
-
git clone https://github.com/ClewCode/ClewCode.git
|
|
134
|
-
cd ClewCode
|
|
151
|
+
---
|
|
135
152
|
|
|
136
|
-
|
|
137
|
-
bun install
|
|
138
|
-
bun run build
|
|
153
|
+
## Use Cases
|
|
139
154
|
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
155
|
+
| Scenario | How Clew Code Helps |
|
|
156
|
+
|---|---|
|
|
157
|
+
| **Fix failing tests** | `clew -p "Fix the failing tests and explain what was wrong"` — reads test output, diagnoses root cause, applies fixes. |
|
|
158
|
+
| **Refactor a module** | Point it at a file, describe the target structure. Uses multi-file edit tools, git status awareness, and checkpoint rollback on mistakes. |
|
|
159
|
+
| **Research a codebase** | `/research "How does auth work?"` — searches code, docs, and web, then compiles a dossier with source references. |
|
|
160
|
+
| **Background automation** | Run `/bg` to delegate long-running tasks (migration, lint fixes) to a background agent while you keep working in the REPL. |
|
|
161
|
+
| **Cross-repo changes** | `/workspace link ../other-repo` — edit across linked projects with full context from both. |
|
|
143
162
|
|
|
144
163
|
---
|
|
145
164
|
|
|
146
|
-
## Quick
|
|
165
|
+
## CLI Quick Reference
|
|
147
166
|
|
|
148
|
-
### 1. Launch the REPL
|
|
149
|
-
Navigate to any repository and run `clew`. It will guide you through setting up your first model provider:
|
|
150
|
-
```bash
|
|
151
|
-
cd my-cool-project
|
|
152
|
-
clew
|
|
153
167
|
```
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
168
|
+
-p, --prompt <text> One-shot prompt, then exit
|
|
169
|
+
-c, --continue Continue last conversation
|
|
170
|
+
-r, --resume [id] Resume a session (opens picker if no id)
|
|
171
|
+
--model <model> Override model (sonnet, opus, gemini-2.5-flash, etc.)
|
|
172
|
+
--effort <level> Reasoning effort (low|medium|high|max)
|
|
173
|
+
--agent <agent> Custom agent profile
|
|
174
|
+
--permission-mode <mode> default|ask|plan|auto
|
|
175
|
+
--peer-share Start as a LAN worker peer
|
|
176
|
+
--computer Enable OS-level computer use (Windows only)
|
|
177
|
+
--debug Developer debug output
|
|
159
178
|
```
|
|
160
179
|
|
|
161
|
-
|
|
162
|
-
Resume exactly where you left off in your last coding session:
|
|
163
|
-
```bash
|
|
164
|
-
clew --resume last
|
|
165
|
-
```
|
|
180
|
+
Notable slash commands: `/model`, `/effort`, `/ultracode`, `/memory`, `/rule`, `/task`, `/goal`, `/compact`, `/rewind`, `/workspace`, `/peer`, `/mcp`, `/agent`, `/plan`, `/voice`, `/research`, `/workflow`, `/skills`, `/code-review`, `/guardian`, `/bg`, `/daemon`, `/buddy`, `/doctor`, `/stats`, `/cost`, `/session`, `/diff`, `/fork`, `/theme`, and [many more](https://clew-docs.pages.dev/cli).
|
|
166
181
|
|
|
167
182
|
---
|
|
168
183
|
|
|
169
|
-
##
|
|
170
|
-
|
|
171
|
-
Clew Code interfaces with the following model provider registries natively:
|
|
172
|
-
|
|
173
|
-
* **openai** - OpenAI models via native SDK
|
|
174
|
-
* **anthropic** - Anthropic Claude models via native SDK
|
|
175
|
-
* **google** - Google Gemini models via native SDK
|
|
176
|
-
* **google-assist** - Google Cloud AI and Code Assist integrations
|
|
177
|
-
* **openrouter** - OpenRouter unified endpoint router
|
|
178
|
-
* **deepseek** - DeepSeek API models (e.g. DeepSeek-V3, DeepSeek-R1)
|
|
179
|
-
* **groq** - Groq Cloud API for ultra-fast Llama/Mixtral inference
|
|
180
|
-
* **xai** - xAI Grok models
|
|
181
|
-
* **mistral** - Mistral AI platform
|
|
182
|
-
* **kilocode** / **opencode** / **opencode-go** - Specialized coding endpoints
|
|
183
|
-
* **ollama** - Local Ollama models running on localhost
|
|
184
|
-
* **together** / **fireworks** / **deepinfra** - Serverless model routers
|
|
185
|
-
* **nvidia** - NVIDIA NIM API
|
|
186
|
-
* **cohere** - Cohere Command models
|
|
187
|
-
* **perplexity** - Perplexity Sonar search models
|
|
188
|
-
* **cerebras** / **siliconflow** / **moonshot** / **zhipu** - Additional API integrations
|
|
189
|
-
* **huggingface** / **poe** / **digitalocean** / **cline** - Workspace / community adapters
|
|
190
|
-
* **clew-gateway** - Standard gateway auth authentication endpoint
|
|
191
|
-
* **custom** - Any custom OpenAI-compatible endpoint
|
|
184
|
+
## Configuration
|
|
192
185
|
|
|
193
|
-
|
|
186
|
+
### Environment Variables
|
|
194
187
|
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
|
200
|
-
|
|
|
201
|
-
|
|
|
202
|
-
|
|
|
203
|
-
|
|
|
204
|
-
| `--fork-session` | When resuming a session, clone it under a new ID instead of overwriting history. |
|
|
205
|
-
| `--from-pr [id]` | Resume a session linked to a specific GitHub PR number or URL. |
|
|
206
|
-
| `--model <model>` | Specify model override (e.g. `sonnet`, `opus`, `gemini-2.5-flash`). |
|
|
207
|
-
| `--effort <level>` | Set reasoning effort level (`low`, `medium`, `high`, or `max`). |
|
|
208
|
-
| `--agent <agent>` | Specify custom agent profile for the session. |
|
|
209
|
-
| `--permission-mode <mode>` | Specify default permission mode (`default`, `ask`, `plan`, `auto`, etc.). |
|
|
210
|
-
| `--add-dir <dirs...>` | Grant tool access to additional directories outside the workspace. |
|
|
211
|
-
| `--ide` | Automatically connect to the local IDE on startup if available. |
|
|
212
|
-
| `--session-id <uuid>` | Force a specific session ID for the active workspace. |
|
|
213
|
-
| `-n, --name <name>` | Set display name for this session (shown in /resume and terminal title). |
|
|
214
|
-
| `--peer-name <name>` | Set display name for local LAN peer discovery. |
|
|
215
|
-
| `--peer-share` | Automatically launch this instance as a sharing worker peer on startup. |
|
|
216
|
-
| `--computer` | Enable OS computer-use tool (Windows only). |
|
|
217
|
-
| `-d, --debug` | Enable developer debugging output. |
|
|
218
|
-
| `--verbose` | Override verbose logging setting from config. |
|
|
188
|
+
| Variable | Required | Description |
|
|
189
|
+
|---|---|---|
|
|
190
|
+
| `ANTHROPIC_API_KEY` | No | Anthropic Claude models |
|
|
191
|
+
| `OPENAI_API_KEY` | No | OpenAI GPT models |
|
|
192
|
+
| `DEEPSEEK_API_KEY` | No | DeepSeek models |
|
|
193
|
+
| `GOOGLE_API_KEY` | No | Google Gemini models |
|
|
194
|
+
| `GROQ_API_KEY` | No | Groq-hosted models |
|
|
195
|
+
| `TAVILY_API_KEY` | No | Enhanced web search provider |
|
|
196
|
+
| `CLEW_DISABLE_TELEMETRY` | No | Disable anonymous usage stats (`1`) |
|
|
219
197
|
|
|
220
|
-
|
|
198
|
+
All provider keys can also be set via the `/model` provider setup flow or in `.clew/settings.json` under `env`.
|
|
221
199
|
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
Type these slash commands directly inside the interactive REPL:
|
|
225
|
-
|
|
226
|
-
### Core Commands
|
|
227
|
-
* `/model <name>` - Switch the provider or LLM model mid-session.
|
|
228
|
-
* `/status` - Check active provider, remaining context, and session metrics.
|
|
229
|
-
* `/doctor` - Run environment diagnostics and connectivity checks.
|
|
230
|
-
* `/context` - Inspect active context tokens and compaction boundaries.
|
|
231
|
-
* `/plan` - Enter/exit plan mode to map out large-scale refactors.
|
|
232
|
-
* `/rewind` - Undo the last user prompt and assistant response.
|
|
233
|
-
* `/effort` - Adjust reasoning effort parameter.
|
|
234
|
-
* `/stats` - View session statistics and token usage.
|
|
235
|
-
* `/theme` - Switch between dark, light, and custom terminal UI themes.
|
|
236
|
-
* `/vim` - Toggle Vim keybindings in the REPL editor.
|
|
237
|
-
|
|
238
|
-
### Memory & Learning
|
|
239
|
-
* `/memory init` - Initialize a clean SQLite memory database for the project.
|
|
240
|
-
* `/memory scan` - Scan the active codebase to build code hierarchy memory.
|
|
241
|
-
* `/memory dashboard` - View memory statistics, confidence scores, and facts.
|
|
242
|
-
* `/rule` - Show project-specific behavioral rules auto-observed by the model. `/rule off` to disable, `/rule on` to re-enable.
|
|
243
|
-
* `/skills` - List and manage active custom skills defined in `.clew/skills/`.
|
|
244
|
-
|
|
245
|
-
### Swarm & LAN Peers
|
|
246
|
-
* `/peer discover` - Search the LAN for active Clew nodes.
|
|
247
|
-
* `/peer swarm <cmd>` - Broadcast a shell command to all discovered peers.
|
|
248
|
-
* `/peer dashboard` - Open the visual coordination panel for peer status.
|
|
200
|
+
### Project Rules
|
|
249
201
|
|
|
250
|
-
|
|
202
|
+
Create `.clew/rules.json` in your repo to define auto-observed behavioral rules — Clew reads them at session start and follows them without being reminded. Manage them interactively with `/rule`. Disable temporarily with `/rule off`.
|
|
251
203
|
|
|
252
|
-
|
|
204
|
+
```json
|
|
205
|
+
{
|
|
206
|
+
"rules": [
|
|
207
|
+
"Always use the project's existing test framework for new tests",
|
|
208
|
+
"Prefer named exports over default exports"
|
|
209
|
+
]
|
|
210
|
+
}
|
|
211
|
+
```
|
|
253
212
|
|
|
254
|
-
|
|
213
|
+
### Enterprise Audit Logging
|
|
255
214
|
|
|
256
|
-
|
|
257
|
-
* `FileReadTool` / `FileWriteTool` / `FileEditTool` - Read, write, and modify files.
|
|
258
|
-
* `GlobTool` / `GrepTool` - Search files and directory structures.
|
|
259
|
-
* `BashTool` - Execute command-line commands in the local shell.
|
|
260
|
-
* `PowerShellTool` - Execute PowerShell scripts natively (Windows only).
|
|
215
|
+
Audit logging is opt-in and writes newline-delimited JSON events for SIEM ingestion. When enabled, Clew records tool calls, tool results/failures, file read/write access, and Bash/PowerShell command execution/results.
|
|
261
216
|
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
217
|
+
| Variable | Required | Description |
|
|
218
|
+
|---|---|---|
|
|
219
|
+
| `CLEW_AUDIT_LOG` | No | Enable audit logging when set to `1` |
|
|
220
|
+
| `CLEW_AUDIT_LOG_PATH` | No | Audit log directory, relative to the project root by default (`.clew/audit`) |
|
|
221
|
+
| `CLEW_AUDIT_LOG_MAX_BYTES` | No | Rotate `audit.ndjson` after this size in bytes (default: 100 MB) |
|
|
222
|
+
| `CLEW_AUDIT_LOG_MAX_FILES` | No | Number of audit log files to retain, including the active file (default: 10) |
|
|
223
|
+
| `CLEW_AUDIT_LOG_INCLUDE` | No | Comma-separated event allowlist, such as `tool.call,tool.result` |
|
|
224
|
+
| `CLEW_AUDIT_LOG_EXCLUDE` | No | Comma-separated event blocklist |
|
|
225
|
+
| `CLEW_AUDIT_LOG_MIN_LEVEL` | No | Minimum level to write: `info`, `warn`, `error`, or `audit` |
|
|
226
|
+
| `CLEW_AUDIT_LOG_CONSOLE` | No | Also mirror audit summaries to stderr when set to `1` |
|
|
227
|
+
| `CLEW_AUDIT_USER` | No | User identifier to include in each audit event |
|
|
266
228
|
|
|
267
|
-
|
|
268
|
-
* `TaskCreateTool` / `TaskGetTool` / `TaskUpdateTool` / `TaskListTool` - Track workflow task checklists.
|
|
269
|
-
* `TaskStopTool` / `TaskOutputTool` - Manage long-running tasks.
|
|
270
|
-
* `GoalTool` - Verify steps against overall task targets.
|
|
229
|
+
Example:
|
|
271
230
|
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
* `ProcessDelegateTool` - Delegate prompts to external CLI models or Codex.
|
|
276
|
-
* `MemoryFeedbackTool` - Update project memories, decisions, and preferences.
|
|
277
|
-
* `ProjectRuleTool` - Save, list, or remove project-specific behavioral rules auto-observed from user patterns (stored in `.clew/rules.json`).
|
|
231
|
+
```bash
|
|
232
|
+
CLEW_AUDIT_LOG=1 CLEW_AUDIT_LOG_PATH=.clew/audit bun run dev
|
|
233
|
+
```
|
|
278
234
|
|
|
279
235
|
---
|
|
280
236
|
|
|
281
|
-
##
|
|
237
|
+
## Security
|
|
282
238
|
|
|
283
|
-
Clew Code
|
|
239
|
+
Clew Code runs entirely on your machine. No code or context leaves your network unless you explicitly configure a remote provider or send a web fetch.
|
|
284
240
|
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
241
|
+
- Prompts for permission before read, write, or terminal execution
|
|
242
|
+
- Fine-tune auto-approve rules per workspace
|
|
243
|
+
- Permission scopes: default, ask, plan, auto
|
|
244
|
+
- Guardian system for auto-review using secondary LLM
|
|
288
245
|
|
|
289
|
-
|
|
246
|
+
---
|
|
290
247
|
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
|
294
|
-
|
|
295
|
-
|
|
|
296
|
-
|
|
|
297
|
-
|
|
|
298
|
-
|
|
|
248
|
+
## Documentation
|
|
249
|
+
|
|
250
|
+
| Guide | Description |
|
|
251
|
+
|---|---|
|
|
252
|
+
| [Quick Start](https://clew-docs.pages.dev/quick-start) | Launch the CLI and start coding |
|
|
253
|
+
| [Installation](https://clew-docs.pages.dev/installation) | One-liner, npm, or build from source |
|
|
254
|
+
| [CLI Reference](https://clew-docs.pages.dev/cli) | Full CLI options, providers, commands |
|
|
255
|
+
| [Configuration](https://clew-docs.pages.dev/configuration) | Settings files, hooks, permission modes |
|
|
256
|
+
| [MCP Guide](https://clew-docs.pages.dev/mcp) | Connect external tools and APIs |
|
|
257
|
+
| [Plugins](https://clew-docs.pages.dev/plugins) | Lifecycle hooks and customization |
|
|
258
|
+
| [Security & Permissions](https://clew-docs.pages.dev/security-permissions) | Permission scopes, guardian system |
|
|
259
|
+
| [Skills System](https://clew-docs.pages.dev/skills) | Automate repeatable workflows |
|
|
260
|
+
| [Memory System](https://clew-docs.pages.dev/memory-system) | SQLite-backed long-term memory |
|
|
261
|
+
| [Peer-to-Peer LAN](https://clew-docs.pages.dev/peer-to-peer) | Discover, delegate, swarm commands |
|
|
262
|
+
| [Architecture](https://clew-docs.pages.dev/concepts-agents-subagents-peers) | Agents, Subagents, Peers |
|
|
263
|
+
| [Troubleshooting](https://clew-docs.pages.dev/troubleshooting) | Common issues and fixes |
|
|
264
|
+
|
|
265
|
+
Also available on the [GitHub Wiki](https://github.com/ClewCode/ClewCode/wiki).
|
|
299
266
|
|
|
300
267
|
---
|
|
301
268
|
|
|
302
|
-
##
|
|
303
|
-
|
|
304
|
-
```text
|
|
305
|
-
src/
|
|
306
|
-
├── main.tsx # CLI entry point & flag parser
|
|
307
|
-
├── replLauncher.tsx # Boots the Ink/React 19 REPL
|
|
308
|
-
├── QueryEngine.ts # Streaming message/tool loop
|
|
309
|
-
├── query.ts # Non-streaming variant
|
|
310
|
-
├── commands/ # Slash commands (prompt, local, local-jsx types)
|
|
311
|
-
├── tools/ # 70+ tools (File I/O, Bash, Browser, Peer, MCP, etc.)
|
|
312
|
-
├── peer/ # LAN P2P: UDP multicast discovery, HTTP heartbeat
|
|
313
|
-
├── memory/ # SQLite-backed memory with importance/recency ranking
|
|
314
|
-
├── services/ # 36+ services (AI, MCP, autonomous, compact, etc.)
|
|
315
|
-
├── skills/ # SKILL.md loader (Claude Code compatible)
|
|
316
|
-
├── plugins/ # Plugin loader, registry, marketplace
|
|
317
|
-
├── agentRuntime/ # Background agent orchestration
|
|
318
|
-
└── remote/ # WebSocket server, auth tokens, NAT relay (Bridge v2)
|
|
319
|
-
```
|
|
269
|
+
## Architecture
|
|
320
270
|
|
|
321
|
-
|
|
271
|
+
```
|
|
272
|
+
┌─ REPL ─────────────────────────────┐
|
|
273
|
+
│ Ink + React 19 ┌───────┐ │
|
|
274
|
+
│ Slash commands / skills │ Tools │ │
|
|
275
|
+
│ Streaming / history └───┬───┘ │
|
|
276
|
+
└────────┬─────────────────────┘ │
|
|
277
|
+
▼ │
|
|
278
|
+
┌─ QueryEngine ──────────────────────┘
|
|
279
|
+
│ Tool loop · Provider routing · Streaming
|
|
280
|
+
│ Context compaction · Checkpoints
|
|
281
|
+
└──┬────┬────┬────┬────┐
|
|
282
|
+
▼ ▼ ▼ ▼ ▼
|
|
283
|
+
┌────┐┌────┐┌────┐┌────┐┌──────────┐
|
|
284
|
+
│ MCP││LSP ││Git ││Web ││ Provider │
|
|
285
|
+
│ ││ ││ ││ ││ Manager │
|
|
286
|
+
└────┘└────┘└────┘└────┘└──────────┘
|
|
287
|
+
│ LAN │
|
|
288
|
+
▼ ▼ ▼
|
|
289
|
+
┌──────┐┌──────────┐┌──────────────┐
|
|
290
|
+
│ SQLite││ Peer ││ AgentRuntime │
|
|
291
|
+
│Memory ││ Server ││ Task Queue │
|
|
292
|
+
└──────┘└──────────┘└──────────────┘
|
|
293
|
+
```
|
|
322
294
|
|
|
323
295
|
---
|
|
324
296
|
|
|
325
|
-
## Development
|
|
326
|
-
|
|
327
|
-
Run development commands from the repository root using **Bun**:
|
|
297
|
+
## Development
|
|
328
298
|
|
|
329
299
|
```bash
|
|
330
|
-
bun run dev
|
|
331
|
-
bun run
|
|
332
|
-
bun test
|
|
333
|
-
bun
|
|
334
|
-
bun
|
|
335
|
-
bun run format # Run Biome formatter with auto-fix
|
|
336
|
-
bun x tsc --noEmit # Compile-free TypeScript validation
|
|
300
|
+
bun run dev # Live-reload REPL
|
|
301
|
+
bun run build # Production build to dist/
|
|
302
|
+
bun test # Vitest suite
|
|
303
|
+
bun run check:ci # Biome lint + format check
|
|
304
|
+
bun x tsc --noEmit # TypeScript check
|
|
337
305
|
```
|
|
338
306
|
|
|
339
|
-
### Pre-
|
|
307
|
+
### Full Pre-Commit
|
|
340
308
|
|
|
341
309
|
```bash
|
|
342
310
|
bun run check:ci && bun x tsc --noEmit && bun test --bail
|
|
343
311
|
```
|
|
344
312
|
|
|
345
|
-
###
|
|
313
|
+
### Shadow `.js` Files
|
|
346
314
|
|
|
347
|
-
|
|
315
|
+
`src/` has ~410 `.js` files alongside `.ts` twins (leftover from JS → TS migration). Bun resolves `.js` import specifiers to the real `.js` file on disk — it does **not** prefer the `.ts` source. If you're making a runtime fix, check for a `.js` sibling and edit **both** files.
|
|
348
316
|
|
|
349
|
-
|
|
350
|
-
graphify query "<question>" # Ask questions about the codebase
|
|
351
|
-
graphify path "<A>" "<B>" # Trace relationships between symbols
|
|
352
|
-
graphify explain "<concept>" # Focused explanation of a concept
|
|
353
|
-
graphify update . # Refresh after code changes (AST-only, no API cost)
|
|
354
|
-
```
|
|
317
|
+
---
|
|
355
318
|
|
|
356
|
-
|
|
319
|
+
## Contributing
|
|
357
320
|
|
|
358
|
-
|
|
321
|
+
Contributions are welcome! See [CONTRIBUTING.md](CONTRIBUTING.md) for guidelines.
|
|
359
322
|
|
|
360
|
-
|
|
323
|
+
- Report bugs via [GitHub Issues](https://github.com/ClewCode/ClewCode/issues)
|
|
324
|
+
- Discuss ideas in [GitHub Discussions](https://github.com/ClewCode/ClewCode/discussions)
|
|
325
|
+
- Read [AGENTS.md](AGENTS.md) for architecture and code conventions
|
|
326
|
+
|
|
327
|
+
---
|
|
328
|
+
|
|
329
|
+
## Star History
|
|
330
|
+
|
|
331
|
+
[](https://star-history.com/#ClewCode/ClewCode&Date)
|
|
361
332
|
|
|
362
333
|
---
|
|
363
334
|
|
|
364
335
|
## License
|
|
365
336
|
|
|
366
|
-
|
|
367
|
-
|
|
337
|
+
GPL-3.0. See [LICENSE.md](LICENSE.md).
|
|
338
|
+
|
|
339
|
+
Release history in [CHANGELOG.md](CHANGELOG.md).
|