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.
@@ -0,0 +1,272 @@
1
+ // Clew Docs — Mobile Nav, TOC, Code Copy, Heading Tracking
2
+ (function () {
3
+ 'use strict';
4
+
5
+ var menuBtn = document.getElementById('menuToggle');
6
+ var sidebar = document.getElementById('sidebar');
7
+ var overlay = document.getElementById('sidebarOverlay');
8
+
9
+ // ── Root Prefix ──────────────────────────────────────────────────────────
10
+ var rootPrefix = '';
11
+ var scripts = document.getElementsByTagName('script');
12
+ for (var i = 0; i < scripts.length; i++) {
13
+ var src = scripts[i].getAttribute('src');
14
+ if (src && src.indexOf('js/main.js') !== -1) {
15
+ rootPrefix = src.replace('js/main.js', '');
16
+ break;
17
+ }
18
+ }
19
+
20
+ // ── Sidebar Injection ────────────────────────────────────────────────────
21
+ if (sidebar) {
22
+ sidebar.innerHTML =
23
+ '<div class="sidebar-section">' +
24
+ ' <div class="sidebar-label">Getting Started</div>' +
25
+ ' <nav>' +
26
+ ' <a href="' + rootPrefix + 'index.html" class="sidebar-link"><span class="link-icon"></span>Overview</a>' +
27
+ ' <a href="' + rootPrefix + 'quick-start.html" class="sidebar-link"><span class="link-icon"></span>Quick Start</a>' +
28
+ ' <a href="' + rootPrefix + 'installation.html" class="sidebar-link"><span class="link-icon"></span>Installation</a>' +
29
+ ' <a href="' + rootPrefix + 'configuration.html" class="sidebar-link"><span class="link-icon"></span>Configuration</a>' +
30
+ ' <a href="' + rootPrefix + 'troubleshooting.html" class="sidebar-link"><span class="link-icon"></span>Troubleshooting</a>' +
31
+ ' </nav>' +
32
+ '</div>' +
33
+ '<div class="sidebar-section">' +
34
+ ' <div class="sidebar-label">Core Concepts</div>' +
35
+ ' <nav>' +
36
+ ' <a href="' + rootPrefix + 'providers.html" class="sidebar-link"><span class="link-icon"></span>Providers</a>' +
37
+ ' <a href="' + rootPrefix + 'models.html" class="sidebar-link"><span class="link-icon"></span>Models</a>' +
38
+ ' <a href="' + rootPrefix + 'commands.html" class="sidebar-link"><span class="link-icon"></span>Commands</a>' +
39
+ ' <a href="' + rootPrefix + 'tools.html" class="sidebar-link"><span class="link-icon"></span>Tools</a>' +
40
+ ' <a href="' + rootPrefix + 'permission-model.html" class="sidebar-link"><span class="link-icon"></span>Permission Model</a>' +
41
+ ' </nav>' +
42
+ '</div>' +
43
+ '<div class="sidebar-section">' +
44
+ ' <div class="sidebar-label">Extending</div>' +
45
+ ' <nav>' +
46
+ ' <a href="' + rootPrefix + 'plugins.html" class="sidebar-link"><span class="link-icon"></span>Plugins</a>' +
47
+ ' <a href="' + rootPrefix + 'skills.html" class="sidebar-link"><span class="link-icon"></span>Skills</a>' +
48
+ ' <a href="' + rootPrefix + 'architecture.html" class="sidebar-link"><span class="link-icon"></span>Architecture</a>' +
49
+ ' <a href="' + rootPrefix + 'mcp.html" class="sidebar-link"><span class="link-icon"></span>MCP</a>' +
50
+ ' </nav>' +
51
+ '</div>' +
52
+ '<div class="sidebar-section">' +
53
+ ' <div class="sidebar-label">Autonomous</div>' +
54
+ ' <nav>' +
55
+ ' <a href="' + rootPrefix + 'daemon.html" class="sidebar-link"><span class="link-icon"></span>Daemon Mode</a>' +
56
+ ' </nav>' +
57
+ '</div>' +
58
+ '<div class="sidebar-section">' +
59
+ ' <div class="sidebar-label">Features</div>' +
60
+ ' <nav>' +
61
+ ' <a href="' + rootPrefix + 'research-memory.html" class="sidebar-link"><span class="link-icon"></span>Research & Memory</a>' +
62
+ ' <a href="' + rootPrefix + 'features/searxng-search.html" class="sidebar-link"><span class="link-icon"></span>SearXNG Search</a>' +
63
+ ' <a href="' + rootPrefix + 'features/bridge-mode.html" class="sidebar-link"><span class="link-icon"></span>Bridge Mode</a>' +
64
+ ' <a href="' + rootPrefix + 'features/evals.html" class="sidebar-link"><span class="link-icon"></span>Evaluation Harness</a>' +
65
+ ' <a href="' + rootPrefix + 'features/sentry-setup.html" class="sidebar-link"><span class="link-icon"></span>Sentry Setup</a>' +
66
+ ' <a href="' + rootPrefix + 'taste.html" class="sidebar-link"><span class="link-icon"></span>Taste</a>' +
67
+ ' </nav>' +
68
+ '</div>' +
69
+ '<div class="sidebar-section">' +
70
+ ' <div class="sidebar-label">Internals</div>' +
71
+ ' <nav>' +
72
+ ' <a href="' + rootPrefix + 'internals/hidden-features.html" class="sidebar-link"><span class="link-icon"></span>Hidden Features</a>' +
73
+ ' <a href="' + rootPrefix + 'internals/growthbook-ab-testing.html" class="sidebar-link"><span class="link-icon"></span>A/B Testing</a>' +
74
+ ' </nav>' +
75
+ '</div>';
76
+ }
77
+
78
+ // ── Mobile Nav ───────────────────────────────────────────────────────────
79
+ function openSidebar() {
80
+ if (sidebar) sidebar.classList.add('open');
81
+ if (menuBtn) menuBtn.setAttribute('aria-expanded', 'true');
82
+ document.body.style.overflow = 'hidden';
83
+ }
84
+
85
+ function closeSidebar() {
86
+ if (sidebar) sidebar.classList.remove('open');
87
+ if (menuBtn) menuBtn.setAttribute('aria-expanded', 'false');
88
+ document.body.style.overflow = '';
89
+ }
90
+
91
+ if (menuBtn) menuBtn.addEventListener('click', function (e) {
92
+ e.stopPropagation();
93
+ sidebar && sidebar.classList.contains('open') ? closeSidebar() : openSidebar();
94
+ });
95
+
96
+ if (overlay) overlay.addEventListener('click', closeSidebar);
97
+
98
+ document.addEventListener('keydown', function (e) {
99
+ if (e.key === 'Escape' && sidebar && sidebar.classList.contains('open')) closeSidebar();
100
+ });
101
+
102
+ if (sidebar) {
103
+ sidebar.querySelectorAll('.sidebar-link').forEach(function (link) {
104
+ link.addEventListener('click', closeSidebar);
105
+ });
106
+ }
107
+
108
+ // ── Active Link Highlighting ─────────────────────────────────────────────
109
+ var currentPath = window.location.pathname;
110
+ var currentPage = currentPath.split('/').pop() || 'index.html';
111
+ if (currentPage === '') currentPage = 'index.html';
112
+
113
+ document.querySelectorAll('.sidebar-link').forEach(function (link) {
114
+ var href = link.getAttribute('href');
115
+ if (!href) return;
116
+ var hrefPage = href.split('/').pop().split('#')[0];
117
+ if (hrefPage === currentPage) link.classList.add('active');
118
+ });
119
+
120
+ document.querySelectorAll('.header-nav a').forEach(function (link) {
121
+ var href = link.getAttribute('href');
122
+ if (!href) return;
123
+ var hrefPage = href.split('/').pop().split('#')[0];
124
+ if (hrefPage === currentPage) link.classList.add('active');
125
+ });
126
+
127
+ // ── Code Copy Buttons ────────────────────────────────────────────────────
128
+ function addCopyButtons() {
129
+ document.querySelectorAll('.content pre').forEach(function (pre) {
130
+ // Skip if already wrapped
131
+ if (pre.parentElement && pre.parentElement.classList.contains('code-block-wrap')) return;
132
+
133
+ var wrap = document.createElement('div');
134
+ wrap.className = 'code-block-wrap';
135
+
136
+ var header = document.createElement('div');
137
+ header.className = 'code-block-header';
138
+
139
+ var lang = document.createElement('span');
140
+ // Detect language from class or content
141
+ var code = pre.querySelector('code');
142
+ var langName = '';
143
+ if (code) {
144
+ var cls = code.className || '';
145
+ var match = cls.match(/language-(\w+)/);
146
+ if (match) langName = match[1];
147
+ }
148
+ lang.textContent = langName || '';
149
+
150
+ var btn = document.createElement('button');
151
+ btn.className = 'copy-btn';
152
+ btn.textContent = 'Copy';
153
+ btn.setAttribute('aria-label', 'Copy code to clipboard');
154
+
155
+ btn.addEventListener('click', function () {
156
+ var text = pre.textContent || '';
157
+ // Strip leading/trailing newlines
158
+ text = text.replace(/^\n+|\n+$/g, '');
159
+ navigator.clipboard.writeText(text).then(function () {
160
+ btn.textContent = 'Copied!';
161
+ btn.classList.add('copied');
162
+ setTimeout(function () {
163
+ btn.textContent = 'Copy';
164
+ btn.classList.remove('copied');
165
+ }, 2000);
166
+ }).catch(function () {
167
+ btn.textContent = 'Failed';
168
+ setTimeout(function () {
169
+ btn.textContent = 'Copy';
170
+ }, 2000);
171
+ });
172
+ });
173
+
174
+ header.appendChild(lang);
175
+ header.appendChild(btn);
176
+
177
+ pre.parentNode.insertBefore(wrap, pre);
178
+ wrap.appendChild(header);
179
+ wrap.appendChild(pre);
180
+ });
181
+ }
182
+
183
+ addCopyButtons();
184
+
185
+ // ── Table Wrapping ───────────────────────────────────────────────────────
186
+ document.querySelectorAll('.content table').forEach(function (table) {
187
+ if (table.parentElement && table.parentElement.classList.contains('table-wrap')) return;
188
+ var wrapper = document.createElement('div');
189
+ wrapper.className = 'table-wrap';
190
+ table.parentNode.insertBefore(wrapper, table);
191
+ wrapper.appendChild(table);
192
+ });
193
+
194
+ // ── TOC Generation ───────────────────────────────────────────────────────
195
+ function buildTOC() {
196
+ var toc = document.querySelector('.toc-sidebar');
197
+ if (!toc) return;
198
+
199
+ var content = document.querySelector('.content');
200
+ if (!content) return;
201
+
202
+ var headings = content.querySelectorAll('h2, h3');
203
+ if (headings.length < 2) {
204
+ toc.style.display = 'none';
205
+ return;
206
+ }
207
+
208
+ var label = document.createElement('div');
209
+ label.className = 'toc-label';
210
+ label.textContent = 'On this page';
211
+ toc.appendChild(label);
212
+
213
+ var list = document.createElement('nav');
214
+ list.className = 'toc-list';
215
+
216
+ var items = [];
217
+ headings.forEach(function (h) {
218
+ // Ensure heading has an id
219
+ if (!h.id) {
220
+ var text = (h.textContent || '')
221
+ .toLowerCase()
222
+ .replace(/[^a-z0-9]+/g, '-')
223
+ .replace(/^-|-$/g, '');
224
+ h.id = text || 'section-' + Math.random().toString(36).slice(2, 6);
225
+ }
226
+
227
+ var link = document.createElement('a');
228
+ link.href = '#' + h.id;
229
+ link.className = 'toc-link';
230
+ if (h.tagName === 'H3') link.classList.add('toc-h3');
231
+ link.textContent = h.textContent;
232
+
233
+ list.appendChild(link);
234
+ items.push({ el: link, id: h.id });
235
+ });
236
+
237
+ toc.appendChild(list);
238
+
239
+ // IntersectionObserver for active heading
240
+ if (typeof IntersectionObserver !== 'undefined' && items.length > 0) {
241
+ var observeTargets = [];
242
+ headings.forEach(function (h) { observeTargets.push(h); });
243
+
244
+ var observer = new IntersectionObserver(function (entries) {
245
+ var visible = [];
246
+ entries.forEach(function (entry) {
247
+ if (entry.isIntersecting) {
248
+ visible.push(entry.target.id);
249
+ }
250
+ });
251
+ if (visible.length > 0) {
252
+ // Use the last visible heading (closest to top of viewport)
253
+ var active = visible[0];
254
+ items.forEach(function (item) {
255
+ if (item.id === active) {
256
+ item.el.classList.add('active');
257
+ } else {
258
+ item.el.classList.remove('active');
259
+ }
260
+ });
261
+ }
262
+ }, {
263
+ rootMargin: '-64px 0px -60% 0px',
264
+ threshold: 0
265
+ });
266
+
267
+ observeTargets.forEach(function (h) { observer.observe(h); });
268
+ }
269
+ }
270
+
271
+ buildTOC();
272
+ })();
package/docs/mcp.html ADDED
@@ -0,0 +1,136 @@
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>MCP — Clew</title>
7
+ <meta name="description" content="Model Context Protocol (MCP) server management — connect external tools, resources, and services to Clew.">
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">
15
+ <div class="header-inner">
16
+ <a href="index.html" class="logo"><span>Clew</span></a>
17
+ <nav class="header-nav">
18
+ <a href="index.html">Home</a>
19
+ <a href="index.html#features">Features</a>
20
+ <a href="index.html#commands">Commands</a>
21
+ <a href="quick-start.html" class="active">Docs</a>
22
+ <a href="https://github.com/JonusNattapong/ClewCode" target="_blank">GitHub</a>
23
+ </nav>
24
+ <button class="menu-btn" id="menuToggle" aria-label="Toggle navigation"><span></span><span></span><span></span></button>
25
+ </div>
26
+ </header>
27
+ <div class="app">
28
+ <aside class="sidebar" id="sidebar"></aside>
29
+ <div class="sidebar-overlay" id="sidebarOverlay"></div>
30
+ <div class="content-wrap">
31
+ <main class="content">
32
+ <div class="breadcrumbs"><a href="index.html">Home</a><span class="sep">/</span><span>MCP</span></div>
33
+ <h1>Model Context Protocol (MCP)</h1>
34
+ <p class="section-subtitle">Connect Clew to external tools, data sources, and services via the Model Context Protocol — an open standard for AI-application integration.</p>
35
+
36
+ <p>MCP support is implemented in <code>src/services/mcp/</code>. Servers are discovered at startup and their tools, resources, and prompts are merged into Clew's runtime.</p>
37
+
38
+ <h2>How It Works</h2>
39
+ <pre><code> MCP Server Config (JSON or inline)
40
+ |
41
+ v
42
+ + MCP Manager (src/services/mcp/)
43
+ | Server connection lifecycle
44
+ | Tool discovery via tools/list
45
+ | Resource access via resources/read
46
+ | Paginated responses
47
+ |
48
+ + Tool Pool (assembleToolPool)
49
+ | MCP tools merged with built-in tools
50
+ | Availability toggled by permission rules
51
+ |
52
+ + Query Loop
53
+ Model sees MCP tools alongside built-ins
54
+ Tool calls routed to the appropriate MCP server</code></pre>
55
+
56
+ <h2>MCP Commands</h2>
57
+ <table>
58
+ <tr><th>Command</th><th>Description</th></tr>
59
+ <tr><td><code>/mcp</code></td><td>Manage MCP servers — list, add, remove, view status</td></tr>
60
+ </table>
61
+
62
+ <h2>CLI Configuration</h2>
63
+ <p>MCP servers are configured at startup via CLI flags:</p>
64
+ <pre><code># Load servers from a JSON config file
65
+ clew --mcp-config ./mcp-servers.json
66
+
67
+ # Load multiple configs
68
+ clew --mcp-config ./servers.json ./extra.json
69
+
70
+ # Pass inline JSON
71
+ clew --mcp-config '{"servers":{...}}'
72
+
73
+ # Strict mode (only use MCP servers, no built-ins)
74
+ clew --strict-mcp-config</code></pre>
75
+
76
+ <h2>MCP Server Config Format</h2>
77
+ <p>Each MCP server is defined with a command, arguments, and environment variables:</p>
78
+ <pre><code>{
79
+ "servers": {
80
+ "filesystem": {
81
+ "command": "npx",
82
+ "args": ["-y", "@modelcontextprotocol/server-filesystem", "/workspace"],
83
+ "env": {}
84
+ },
85
+ "database": {
86
+ "command": "node",
87
+ "args": ["./mcp/db-server.js"],
88
+ "env": { "DB_URL": "postgresql://..." }
89
+ }
90
+ }
91
+ }</code></pre>
92
+
93
+ <h2>Tool Discovery</h2>
94
+ <p>When an MCP server connects, Clew:</p>
95
+ <ol>
96
+ <li>Sends <code>tools/list</code> to discover available tools</li>
97
+ <li>Merges discovered tools into the global tool pool via <code>assembleToolPool()</code></li>
98
+ <li>Handles paginated responses for servers with many tools</li>
99
+ <li>Makes tools available to the model alongside built-in tools</li>
100
+ </ol>
101
+
102
+ <p>MCP-provided tools inherit their schemas from the server and go through the same permission gating and hook system as built-in tools.</p>
103
+
104
+ <h2>Resources</h2>
105
+ <p>MCP servers can also expose resources — structured data that Clew can read:</p>
106
+ <ul>
107
+ <li><strong>ListMcpResources</strong> — List available resources from all connected servers</li>
108
+ <li><strong>ReadMcpResource</strong> — Read a specific resource by URI</li>
109
+ </ul>
110
+
111
+ <p>Resources are useful for accessing database schemas, API documentation, configuration files, and other structured data through MCP servers.</p>
112
+
113
+ <h2>Plugin-Bundled MCP Servers</h2>
114
+ <p>Plugins can declare MCP servers in their manifest. These are automatically started when the plugin is loaded and stopped when the plugin is unloaded. See <a href="plugins.html">Plugins</a> for details.</p>
115
+
116
+ <h2>Architecture Files</h2>
117
+ <table>
118
+ <tr><th>Path</th><th>Role</th></tr>
119
+ <tr><td><code>src/services/mcp/</code></td><td>MCP server connection management, tool discovery, resource access</td></tr>
120
+ <tr><td><code>src/tools.ts</code></td><td>Tool registry — MCP tools merged via assembleToolPool()</td></tr>
121
+ </table>
122
+
123
+ <footer class="footer">
124
+ <span>Clew v0.1.2 — Open Source</span>
125
+ <div class="footer-links">
126
+ <a href="https://github.com/JonusNattapong/ClewCode">GitHub</a>
127
+ <a href="https://github.com/JonusNattapong/ClewCode/issues">Issues</a>
128
+ </div>
129
+ </footer>
130
+ </main>
131
+ <nav class="toc-sidebar"></nav>
132
+ </div>
133
+ </div>
134
+ <script src="js/main.js"></script>
135
+ </body>
136
+ </html>
@@ -0,0 +1,108 @@
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>Models — Clew</title>
7
+ <meta name="description" content="Model selection guide for Clew — how to pick, switch, and manage models across 27 providers.">
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>Models</span></div>
18
+ <h1>Models</h1>
19
+ <p class="section-subtitle">Clew supports 100+ models across 27 providers. Pick the right model for each task — from frontier reasoning to fast local inference.</p>
20
+
21
+ <h2>Model Selection Guide</h2>
22
+ <table>
23
+ <tr><th>Workload</th><th>Recommended Models</th><th>Context</th><th>Notes</th></tr>
24
+ <tr><td>Complex architecture &amp; large edits</td><td>claude-opus-4-7, claude-sonnet-4-6, gpt-5.5, deepseek-v4-pro</td><td>1M tokens</td><td>Best tool calling, strong reasoning, largest context</td></tr>
25
+ <tr><td>Code review &amp; debugging</td><td>claude-sonnet-4-6, gpt-5.5, gemini-3.1-pro</td><td>1M-2M tokens</td><td>Good instruction following, reliable output</td></tr>
26
+ <tr><td>Quick search &amp; summarization</td><td>claude-haiku-4-5, deepseek-v4-flash, mistral-small-4, groq/llama-3.3-70b</td><td>128K-200K</td><td>Fast, cost-effective, lower latency</td></tr>
27
+ <tr><td>Offline / air-gapped</td><td>ollama/llama4:70b, ollama/llama3.3</td><td>131K tokens</td><td>Fully local, no network needed</td></tr>
28
+ <tr><td>Cost-sensitive bulk</td><td>kilocode/kilo-auto/free, opencode-go/minimax-m2.7, groq/llama-3.1-8b</td><td>Varies</td><td>Free or minimal cost tiers available</td></tr>
29
+ <tr><td>Research &amp; reasoning</td><td>claude-opus-4-7, deepseek-v4-pro, gemini-3.1-pro</td><td>1M-2M tokens</td><td>Deep reasoning, chain-of-thought</td></tr>
30
+ <tr><td>Vision / multimodal</td><td>claude-sonnet-4-6, gpt-5.5, gemini-3.1-pro, deepseek-v4-flash</td><td>1M tokens</td><td>Image understanding, document analysis</td></tr>
31
+ </table>
32
+
33
+ <h2>Notable Models by Provider</h2>
34
+ <table>
35
+ <tr><th>Provider</th><th>Models Available</th></tr>
36
+ <tr><td>Anthropic</td><td>claude-opus-4-7 (1M ctx), claude-sonnet-4-6 (1M ctx, recommended), claude-haiku-4-5 (200K ctx, fast)</td></tr>
37
+ <tr><td>OpenAI</td><td>gpt-5.5 (1M ctx), gpt-5.4 (1M ctx), gpt-5.4-mini (fast)</td></tr>
38
+ <tr><td>Google</td><td>gemini-3.1-pro (2M ctx), gemini-3.1-flash-lite (1M ctx, fast)</td></tr>
39
+ <tr><td>DeepSeek</td><td>deepseek-v4-pro (1M ctx, MoE), deepseek-v4-flash (1M ctx, fast MoE)</td></tr>
40
+ <tr><td>xAI</td><td>grok-4.3 (128K ctx)</td></tr>
41
+ <tr><td>Mistral</td><td>mistral-medium-3.5, mistral-small-4, mistral-large-3</td></tr>
42
+ <tr><td>Groq</td><td>llama-3.3-70b, llama-3.1-8b-instant (fast)</td></tr>
43
+ <tr><td>Ollama</td><td>llama4:70b (local), llama3.3 (local), qwen3.6-plus (local)</td></tr>
44
+ <tr><td>GitHub Copilot</td><td>claude-opus-4.7, claude-sonnet-4.6, claude-haiku-4.5, gpt-5.5</td></tr>
45
+ <tr><td>OpenCode</td><td>claude-opus-4-7, claude-sonnet-4-6, gpt-5.5, gemini-3.1-pro, kimi-k2.6</td></tr>
46
+ <tr><td>KiloCode</td><td>kilo-auto/free, kilo-auto/balanced, kilo-auto/frontier</td></tr>
47
+ <tr><td>Cohere</td><td>command-a-plus (128K ctx)</td></tr>
48
+ <tr><td>Perplexity</td><td>sonar-pro, sonar, sonar-reasoning-pro</td></tr>
49
+ <tr><td>Together AI</td><td>deepseek-v4, Qwen3.6, Llama-4</td></tr>
50
+ <tr><td>NVIDIA NIM</td><td>deepseek-v4-pro, glm-5.1, nemotron-3</td></tr>
51
+ <tr><td>Cerebras</td><td>qwen-3-235b (extremely fast)</td></tr>
52
+ <tr><td>Moonshot (Kimi)</td><td>kimi-k2.6 (128K ctx)</td></tr>
53
+ <tr><td>Zhipu (GLM)</td><td>glm-4.7 (128K ctx)</td></tr>
54
+ <tr><td>Hugging Face</td><td>llama-3.3-70b-instruct</td></tr>
55
+ <tr><td>Poe</td><td>claude-3-7-sonnet</td></tr>
56
+ </table>
57
+
58
+ <h2>Model Switching</h2>
59
+ <pre><code>/model # Interactive picker (recent models at top, grouped by provider)
60
+ /model list # List all available models
61
+ /model claude-sonnet-4-7 # Switch by full ID
62
+ /model sonnet # Alias-based switching
63
+ --model opus # CLI flag at startup</code></pre>
64
+ <p>The picker shows <strong>all models from every provider</strong> in named sections — not just the active provider's models. Recent models appear at top with the active provider's default. Select any model from any provider directly.</p>
65
+ <p>Model switching is instant — the next conversation turn uses the new model. Previous context is preserved.</p>
66
+
67
+ <h2>Model Aliases</h2>
68
+ <p>Short aliases are resolved to full model IDs: <code>sonnet</code>, <code>opus</code>, <code>haiku</code>, <code>gpt5</code>, <code>flash</code>, etc.</p>
69
+
70
+ <h2>CLI Flags for Models</h2>
71
+ <table>
72
+ <tr><th>Flag</th><th>Description</th></tr>
73
+ <tr><td><code>--model &lt;name&gt;</code></td><td>Set model at startup (e.g., <code>--model sonnet</code> or <code>--model claude-opus-4-7</code>)</td></tr>
74
+ <tr><td><code>--effort &lt;level&gt;</code></td><td>Set reasoning effort: <code>low</code>, <code>medium</code>, <code>high</code>, <code>max</code></td></tr>
75
+ <tr><td><code>--max-turns &lt;N&gt;</code></td><td>Limit agentic turns in non-interactive mode</td></tr>
76
+ <tr><td><code>--thinking &lt;mode&gt;</code></td><td>Thinking mode: <code>enabled</code>, <code>adaptive</code>, <code>disabled</code></td></tr>
77
+ <tr><td><code>--fallback-model &lt;model&gt;</code></td><td>Fallback when primary model is overloaded (print mode only)</td></tr>
78
+ <tr><td><code>--task-budget &lt;tokens&gt;</code></td><td>API-side task budget in tokens</td></tr>
79
+ <tr><td><code>--max-budget-usd &lt;amount&gt;</code></td><td>Maximum spend on API calls (print mode only)</td></tr>
80
+ </table>
81
+
82
+ <h2>Model Capabilities</h2>
83
+ <p>Each model declaration in <code>providers.json</code> includes:</p>
84
+ <ul>
85
+ <li>Model ID and display label</li>
86
+ <li>Context window (<code>maxContext</code>) and max output tokens (<code>maxOutput</code>)</li>
87
+ <li>Tool calling type (<code>native</code>, <code>none</code>)</li>
88
+ <li>Vision support</li>
89
+ <li>Streaming mode (<code>full</code>, <code>partial</code>)</li>
90
+ <li>Reasoning support</li>
91
+ <li>System prompt support</li>
92
+ <li>Tags (for filtering): <code>fast</code>, <code>verified</code>, <code>recommended</code>, <code>latest</code>, <code>free</code>, <code>vision</code>, <code>tools</code>, <code>native</code>, <code>moe</code>, <code>local</code></li>
93
+ </ul>
94
+
95
+ <footer class="footer">
96
+ <span>Clew v0.2.1 — Open Source</span>
97
+ <div class="footer-links">
98
+ <a href="https://github.com/JonusNattapong/ClewCode">GitHub</a>
99
+ <a href="https://github.com/JonusNattapong/ClewCode/issues">Issues</a>
100
+ </div>
101
+ </footer>
102
+ </main>
103
+ <nav class="toc-sidebar"></nav>
104
+ </div>
105
+ </div>
106
+ <script src="js/main.js"></script>
107
+ </body>
108
+ </html>
@@ -0,0 +1,100 @@
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>Permission Model — Clew</title>
7
+ <meta name="description" content="Tool execution permissions in Clew — modes, rules, and security.">
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>Permission Model</span></div>
18
+ <h1>Permission Model</h1>
19
+ <p class="section-subtitle">Clew gates tool execution through a tiered permission system with multiple modes, allow/deny rules, and tool-specific checks.</p>
20
+
21
+ <h2>Permission Modes</h2>
22
+ <p>Defined in <code>src/types/permissions.ts</code>. Seven user-addressable modes:</p>
23
+ <table>
24
+ <tr><th>Mode</th><th>Behavior</th></tr>
25
+ <tr><td><code>default</code></td><td>Ask before sensitive tool actions (read/write/bash/network). Safe default.</td></tr>
26
+ <tr><td><code>ask</code></td><td>Always ask before any tool execution.</td></tr>
27
+ <tr><td><code>plan</code></td><td>Prefer planning mode — AI must present a plan before executing tools.</td></tr>
28
+ <tr><td><code>auto</code></td><td>Auto-approve low-risk actions using transcript classifier (requires <code>TRANSCRIPT_CLASSIFIER</code> feature). Prompt for risky operations.</td></tr>
29
+ <tr><td><code>acceptEdits</code></td><td>Auto-approve file edit operations. Useful for rapid iteration.</td></tr>
30
+ <tr><td><code>bypassPermissions</code></td><td>Skip all permission prompts. Use only in trusted sandboxes.</td></tr>
31
+ <tr><td><code>dontAsk</code></td><td>Never ask — auto-deny anything that would require permission.</td></tr>
32
+ </table>
33
+
34
+ <h2>Permission Rules</h2>
35
+ <p>Granular allow/deny rules control specific tools and their arguments:</p>
36
+ <pre><code>/permissions # Open interactive permission rule manager</code></pre>
37
+ <p>Rules can target specific tools with pattern matching:</p>
38
+ <ul>
39
+ <li><code>Bash(git *)</code> — Allow/deny git commands specifically</li>
40
+ <li><code>Edit</code> — Allow/deny all file edits</li>
41
+ <li><code>Bash(rm *)</code> — Warn/block destructive shell commands</li>
42
+ </ul>
43
+
44
+ <h2>Rule Sources</h2>
45
+ <p>Permission rules come from multiple sources (evaluated in order, with later sources overriding earlier ones):</p>
46
+ <ul>
47
+ <li><code>userSettings</code> — From user config file</li>
48
+ <li><code>projectSettings</code> — From project-level settings</li>
49
+ <li><code>localSettings</code> — Local overrides</li>
50
+ <li><code>flagSettings</code> — From CLI flags (<code>--allowedTools</code>, <code>--disallowedTools</code>)</li>
51
+ <li><code>policySettings</code> — Managed/organization policy</li>
52
+ </ul>
53
+
54
+ <h2>Tool Permission Flow</h2>
55
+ <pre><code>1. Tool input validation (validateInput)
56
+ 2. Tool-specific checkPermissions()
57
+ 3. Deny rule check (permissions.ts getDenyRuleForTool)
58
+ 4. Permission mode evaluation (mode-based auto decision)
59
+ 5. Plugin hooks (PreToolUse PostToolUse)
60
+ 6. Classifier-based auto-approval (auto mode)
61
+ 7. User permission dialog (if needed)</code></pre>
62
+
63
+ <h2>CLI Flags for Permissions</h2>
64
+ <table>
65
+ <tr><th>Flag</th><th>Description</th></tr>
66
+ <tr><td><code>--permission-mode &lt;mode&gt;</code></td><td>Set session permission mode</td></tr>
67
+ <tr><td><code>--dangerously-skip-permissions</code></td><td>Bypass all checks (sandbox only)</td></tr>
68
+ <tr><td><code>--allow-dangerously-skip-permissions</code></td><td>Enable bypass as optional mode</td></tr>
69
+ <tr><td><code>--allowedTools, --allowed-tools &lt;tools...&gt;</code></td><td>Allowlist specific tools with patterns</td></tr>
70
+ <tr><td><code>--disallowedTools, --disallowed-tools &lt;tools...&gt;</td><td>Denylist specific tools with patterns</td></tr>
71
+ </table>
72
+
73
+ <h2>Security Best Practices</h2>
74
+ <ul>
75
+ <li><strong>Default mode</strong> for day-to-day development</li>
76
+ <li><strong>Plan mode</strong> for production infrastructure or unfamiliar code</li>
77
+ <li><strong>Bypass modes</strong> only in disposable worktrees or Docker sandboxes</li>
78
+ <li>Use allow/deny rules to permit safe patterns (e.g., <code>Bash(git *)</code>) while blocking dangerous ones</li>
79
+ <li>Run <code>/doctor</code> to audit current permission settings</li>
80
+ </ul>
81
+
82
+ <div class="callout callout-warn">
83
+ <strong>Use Caution</strong>
84
+ <code>bypassPermissions</code> mode executes all tool actions without prompting. Restrict to trusted, sandboxed environments.
85
+ </div>
86
+
87
+ <footer class="footer">
88
+ <span>Clew v0.1.2 — Open Source</span>
89
+ <div class="footer-links">
90
+ <a href="https://github.com/JonusNattapong/ClewCode">GitHub</a>
91
+ <a href="https://github.com/JonusNattapong/ClewCode/issues">Issues</a>
92
+ </div>
93
+ </footer>
94
+ </main>
95
+ <nav class="toc-sidebar"></nav>
96
+ </div>
97
+ </div>
98
+ <script src="js/main.js"></script>
99
+ </body>
100
+ </html>